merge #338: 移除公开版 cordis peer,迁移类型基底到 @deepseek-ai/cordis
# Conflicts: # README.md # README_EN.md # package.json
This commit is contained in:
@@ -313,7 +313,7 @@ export function apply(ctx: Context): void {
|
||||
return registerTurnTailInterception(ctx, sidebarStore)
|
||||
} catch (error) {
|
||||
fail('interception', error)
|
||||
return undefined
|
||||
return () => {}
|
||||
}
|
||||
},
|
||||
'dsh-better-sidebar: turn-tail interception',
|
||||
@@ -325,7 +325,7 @@ export function apply(ctx: Context): void {
|
||||
return registerOpenPathInterception(ctx, sidebarStore)
|
||||
} catch (error) {
|
||||
fail('interception', error)
|
||||
return undefined
|
||||
return () => {}
|
||||
}
|
||||
},
|
||||
'dsh-better-sidebar: open-path interception',
|
||||
@@ -369,7 +369,7 @@ export function apply(ctx: Context): void {
|
||||
})
|
||||
} catch (error) {
|
||||
fail('interception', error)
|
||||
return undefined
|
||||
return () => {}
|
||||
}
|
||||
},
|
||||
'dsh-better-sidebar: link interception',
|
||||
@@ -389,7 +389,7 @@ export function apply(ctx: Context): void {
|
||||
return registerImeGuard()
|
||||
} catch (error) {
|
||||
fail('ime guard', error)
|
||||
return undefined
|
||||
return () => {}
|
||||
}
|
||||
},
|
||||
'dsh-better-sidebar: IME composition guard',
|
||||
|
||||
+87
-103
@@ -1,31 +1,34 @@
|
||||
/**
|
||||
* Structural types for the cordis services this plugin consumes, plus the
|
||||
* Context augmentation both halves share. A third-party plugin resolves
|
||||
* outside the DSH monorepo's single cordis instance, so the upstream
|
||||
* `declare module 'cordis'` augmentations do not reach this Context — and
|
||||
* the npm cordis package does not declare the DSH-vendored runtime members
|
||||
* (`ctx.effect`, service properties). The members below mirror the actual
|
||||
* runtime shapes this plugin touches:
|
||||
* - webServer: @deepseek-ai/dsh-host-webserver (the WebServer)
|
||||
* - sessions: host side @deepseek-ai/dsh-session (SessionStore), client
|
||||
* side the runtime ISessions list feed
|
||||
* - conversation: client side ui-conversation's IConversation (composer
|
||||
* draft), read lazily through `ctx.get` — cross-plugin service reads need
|
||||
* an inject declaration, so the direct property is never typed here
|
||||
* - webRuntime: @deepseek-ai/dsh-web-app (bind-derived trusted hosts)
|
||||
* - slots: the client runtime SlotRegistry
|
||||
* - effect: the DSH-vendored cordis lifecycle helper
|
||||
* Drift from upstream is contained to this file.
|
||||
* Context face both halves share.
|
||||
*
|
||||
* The type base is the vendored `@deepseek-ai/cordis` Context (the runtime
|
||||
* DSH actually runs); the service members this plugin touches are restated
|
||||
* below as structural mirrors and combined with the base by INTERSECTION.
|
||||
* Intersection (not `declare module` augmentation) is deliberate: DSH's own
|
||||
* packages already augment `@deepseek-ai/cordis`, and the host and client
|
||||
* packages declare *different* types for the same member — host
|
||||
* `sessions: SessionStore` vs client runtime `sessions: ISessions` — so a
|
||||
* single program that re-declares them would fail interface merging
|
||||
* (TS2717). Intersecting keeps every face available and lets each call site
|
||||
* resolve against the member it needs without any module-level conflict.
|
||||
*
|
||||
* `effect`, `get`, `provide`, `inject`, `logger`, `emit`, `isolate` and the
|
||||
* event helpers come from the vendored cordis base and are intentionally NOT
|
||||
* restated here: their strict shapes are the runtime contract (e.g. an
|
||||
* effect body must return a disposer). Only the string-keyed session-feed
|
||||
* `on` overload is added, because the cordis `on` is keyed to its own
|
||||
* typed `Events` map and the harness session feed is a plain string event.
|
||||
*
|
||||
* This file must stay FREE of Node.js types (`node:http`, `node:stream`,
|
||||
* `Buffer`): it is part of the CLIENT-reachable declaration graph (the
|
||||
* `Context` in `TabComponentProps` and the `declare module` augmentation),
|
||||
* `Context` in `TabComponentProps` and the `betterSidebar` augmentation),
|
||||
* so a Node import here would leak into browser-only consumer builds. The
|
||||
* webServer faces below are therefore structural mirrors with plain
|
||||
* interfaces (the host casts to real Node types at the few boundaries that
|
||||
* need them — e.g. the `ws` upgrade hook in src/index.ts).
|
||||
*/
|
||||
import type { Context } from 'cordis'
|
||||
import type { Context as CordisContext } from '@deepseek-ai/cordis'
|
||||
import type { BetterSidebarService } from './client/service.ts'
|
||||
|
||||
/** The request face route handlers see (structural subset of node's
|
||||
@@ -514,97 +517,78 @@ export interface SidebarAgent {
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'cordis' {
|
||||
interface Context {
|
||||
webServer: SidebarWebServer
|
||||
sessions: SidebarSessionStore & SidebarSessionsService
|
||||
connection: SidebarConnectionHandle
|
||||
webRuntime: SidebarWebRuntime
|
||||
slots: SidebarSlotsService
|
||||
workspaces: SidebarWorkspacesService
|
||||
settings: SidebarSettingsService
|
||||
invariants: SidebarInvariantsService
|
||||
tools: SidebarToolsService
|
||||
/**
|
||||
* The client locale service (`@deepseek-ai/dsh-client-locale`): the
|
||||
* sidebar's copy follows its active locale and registers its
|
||||
* dictionaries under the `betterSidebar` namespace. Client side only.
|
||||
*/
|
||||
locale: SidebarLocaleService
|
||||
/**
|
||||
* The client module system (rc.8+): resolves module-table specifiers
|
||||
* (seed words, graph rows) — the chunk loader's externals go through it
|
||||
* (`ctx.modules.import`). rc.7 exposed the same surface as the
|
||||
* `window.__DSH_MODULES__` page global; the loader keeps that fallback.
|
||||
*/
|
||||
modules: { import(specifier: string): Promise<unknown> }
|
||||
/**
|
||||
* The host background-job registry (`ctx.get('jobs')`; optional — the
|
||||
* sidebar routes degrade to a 503 when the deployment lacks it).
|
||||
*/
|
||||
jobs: SidebarJobsService
|
||||
/**
|
||||
* The host live-agent registry (`ctx.get('agents')`; optional — used to
|
||||
* resolve the caller the jobs fence compares against, and to create /
|
||||
* resume the Side Chat thread agents).
|
||||
*/
|
||||
agents: SidebarAgentsService
|
||||
/**
|
||||
* The host subagent runtime (`ctx.subagents`; optional — the Subagent
|
||||
* page's live batch route reads descendant catalogs through it).
|
||||
*/
|
||||
subagents: SidebarSubagentsService
|
||||
/**
|
||||
* The host agent-presets service (`ctx.get('agentPresets')`; optional —
|
||||
* absent deployments compose nothing and every session shares the host
|
||||
* composition).
|
||||
*/
|
||||
agentPresets: SidebarAgentPresetsService
|
||||
/**
|
||||
* The host session-title service (`ctx.get('sessionTitle')`; optional —
|
||||
* the Side Chat thread label pin degrades to the auto-generated title).
|
||||
*/
|
||||
sessionTitle: SidebarSessionTitleService
|
||||
/**
|
||||
* The host session-persistence service (`ctx.get('sessionPersistence')`;
|
||||
* optional — needed only for the Side Chat cold-resume composition).
|
||||
*/
|
||||
sessionPersistence: SidebarSessionPersistenceService
|
||||
/**
|
||||
* The client-side sidebar registry: external plugins register tab types
|
||||
* and file previewers here. Provided by the client half (see
|
||||
* {@link ./client/index.tsx}); undefined on the host side.
|
||||
*/
|
||||
betterSidebar: BetterSidebarService
|
||||
/**
|
||||
* Subscribe to the session append feed (mirror of the cordis event API):
|
||||
* the listener receives every appended session event with the LIVE
|
||||
* Session instance that appended it. The api-proxy pushes the same feed
|
||||
* to browsers; the sidebar uses it to mirror job_output events the
|
||||
* session store's own log can lag behind (restart divergence). Returns
|
||||
* the disposer.
|
||||
*/
|
||||
on(event: string, listener: (session: unknown, event: SidebarSessionEvent) => void): () => void
|
||||
/**
|
||||
* Register a lifecycle callback (DSH-vendored cordis): runs at plugin
|
||||
* activation; its returned cleanup runs at disposal.
|
||||
*/
|
||||
effect(fn: () => void | (() => void), label?: string): void
|
||||
}
|
||||
/**
|
||||
* The shape this plugin actually consumes, intersected with the vendored
|
||||
* cordis `Context` below (see the file header for why intersection is used
|
||||
* instead of module augmentation).
|
||||
*/
|
||||
export interface SidebarContextShape {
|
||||
/** The webServer service face this plugin uses. */
|
||||
webServer: SidebarWebServer
|
||||
/** The session store (host `.get`) and the client list feed (`.list`) faces. */
|
||||
sessions: SidebarSessionStore & SidebarSessionsService
|
||||
/** The wire handle the Side Chat transcript polls through. */
|
||||
connection: SidebarConnectionHandle
|
||||
/** The web runtime trust list (bind-derived). */
|
||||
webRuntime: SidebarWebRuntime
|
||||
/** The client slot registry (register/inject). */
|
||||
slots: SidebarSlotsService
|
||||
/** The client workspaces service face (file-open funnel). */
|
||||
workspaces: SidebarWorkspacesService
|
||||
/** The settings service face (prefs persistence + namespace reads). */
|
||||
settings: SidebarSettingsService
|
||||
/** The invariant registry face. */
|
||||
invariants: SidebarInvariantsService
|
||||
/** The tool registry face. */
|
||||
tools: SidebarToolsService
|
||||
/** The client locale service face. */
|
||||
locale: SidebarLocaleService
|
||||
/** The client module system (rc.8+ chunk-loader externals). */
|
||||
modules: { import(specifier: string): Promise<unknown> }
|
||||
/** The host background-job registry (optional; routes degrade to 503). */
|
||||
jobs: SidebarJobsService
|
||||
/** The host live-agent registry (optional; side chat thread agents). */
|
||||
agents: SidebarAgentsService
|
||||
/** The host subagent runtime (optional; live topology batch route). */
|
||||
subagents: SidebarSubagentsService
|
||||
/** The host agent-presets service (optional; side chat cold resume). */
|
||||
agentPresets: SidebarAgentPresetsService
|
||||
/** The host session-title service (optional; side chat thread label pin). */
|
||||
sessionTitle: SidebarSessionTitleService
|
||||
/** The host session-persistence service (optional; side chat cold resume). */
|
||||
sessionPersistence: SidebarSessionPersistenceService
|
||||
/** The composer draft face (client ui-conversation, lazy `ctx.get` probe). */
|
||||
conversation: SidebarConversation
|
||||
/**
|
||||
* The client-side sidebar registry: external plugins register tab types
|
||||
* and file previewers here. Provided by the client half (see
|
||||
* {@link ./client/index.tsx}); undefined on the host side.
|
||||
*/
|
||||
betterSidebar: BetterSidebarService
|
||||
/**
|
||||
* String-keyed session feed subscribe (the vendored cordis `on` is keyed
|
||||
* to its typed Events map; the harness session feed is a plain string
|
||||
* event). The listener receives every appended session event with the
|
||||
* LIVE Session instance that appended it.
|
||||
*/
|
||||
on(event: string, listener: (session: unknown, event: SidebarSessionEvent) => void): () => void
|
||||
}
|
||||
|
||||
/**
|
||||
* Dual cordis-scope augmentation: DSH's runtime (and the public packages)
|
||||
* resolve against the vendored `@deepseek-ai/cordis` scope, which DSH's own
|
||||
* packages already augment with `effect`/`on`/service members. This side only
|
||||
* adds the sidebar service member so consumers importing `Context` from
|
||||
* `@deepseek-ai/cordis` (instead of the public `cordis` above) still see
|
||||
* `ctx.betterSidebar`.
|
||||
* The Context this plugin sees: the vendored cordis Context intersected with
|
||||
* the structural service faces above. Re-exported from the package root so a
|
||||
* consumer can `import type { Context } from 'dsh-better-sidebar'`.
|
||||
*/
|
||||
export type Context = CordisContext & SidebarContextShape
|
||||
|
||||
/**
|
||||
* Consumer-facing augmentation (deliberately the only one kept): a plugin
|
||||
* that imports `Context` from `@deepseek-ai/cordis` and does
|
||||
* `import type {} from 'dsh-better-sidebar'` sees `ctx.betterSidebar`
|
||||
* without importing this package's own Context type.
|
||||
*/
|
||||
declare module '@deepseek-ai/cordis' {
|
||||
interface Context {
|
||||
betterSidebar: BetterSidebarService
|
||||
}
|
||||
}
|
||||
|
||||
export type { Context }
|
||||
|
||||
+4
-2
@@ -54,8 +54,10 @@ import { readJsonBody, requireString, SidebarError, writeError, writeJson, write
|
||||
|
||||
export { Config }
|
||||
export type { SidebarConfig, ResolvedSidebarConfig }
|
||||
// Re-export the Context augmentation (declare module 'cordis') so consumers
|
||||
// `import type {} from 'dsh-better-sidebar'` and gain `ctx.betterSidebar`.
|
||||
// Re-export the Context augmentation (`declare module '@deepseek-ai/cordis'`)
|
||||
// so consumers `import type {} from 'dsh-better-sidebar'` and gain
|
||||
// `ctx.betterSidebar`; the Context re-export below is the vendored cordis
|
||||
// Context intersected with the structural service faces.
|
||||
// Also re-export the service descriptor types so consumers can type their
|
||||
// registerTab / registerFileViewer arguments without reaching into /client.
|
||||
export type { Context } from './context-types.ts'
|
||||
|
||||
Reference in New Issue
Block a user