Files
deepseek-harness/packages/host/plugin-inventory/src/index.ts
T
Yichen Jiang e5f36cc70f feat(plugin-inventory): carry every agent preset's composition and group the settings plugin list by scope
The settings plugin list projected ctx.loader.entries() alone, hiding the
plugins sessions actually run and rendering the web overlay's deliberate
disabled tombstones (tool-bash, tool-fs, ...) as two dozen plainly disabled
rows while the same modules ran in every standard-preset session.

- dsh-agent-presets: compositionInventory() answers flattened rows per
  preset — newest live standing generation when mounted, composition file
  otherwise with !!js disabled gates evaluated against the Loader context;
  reading never mounts (regression-tested), refusal stays 'conditional',
  raced files report broken with the reason.
- dsh-host-plugin-inventory: list() gains an optional agentPresets block,
  resolving the roster as an optional peer and mapping fiber states to the
  public phase vocabulary.
- ui-settings-plugin-inventory: preset group first behind a display-only
  switcher opening on the default preset; global group collapsed with
  failures floated; host-disabled modules enabled by >=1 preset fold into a
  session-plugins drawer naming providers; search spans scopes and points
  at matches in unselected presets.
- ui-agent-preset: the General-settings default-preset row is deleted — the
  roster section's make-default and the new-session chip keep the field —
  and the settings store slims to the display roster the header label reads.

Docs, catalogs, module graph, settings-chrome goldens, and the bilingual
Agent Note ride along.
2026-08-29 17:13:45 +08:00

93 lines
3.3 KiB
TypeScript

/** Read-only projection of the current Cordis Loader plugin entries. */
import type { Context, FiberState } from '@deepseek-ai/cordis'
import type {} from '@deepseek-ai/cordis-plugin-loader'
// Type-only: the optional agent-preset roster resolved through `ctx.get`.
import type {} from '@deepseek-ai/dsh-agent-presets'
import { TypertRemoteService, Remote } from '@deepseek-ai/dsh-typert-protocol'
// Typert-generated ./typert and ./remote artifacts import Zod at runtime.
import type {} from 'zod'
import type {
AgentPresetPluginGroup,
PluginEntryId,
PluginFiberPhase,
PluginInventoryEntry,
PluginInventorySnapshot,
} from './types.ts'
export type * from './types.ts'
/** Brand an existing Loader-tree entry id at the owning boundary. */
function pluginEntryId(value: string): PluginEntryId {
return value as PluginEntryId
}
/** Runtime mirror: FiberState is a cross-package const enum. */
const FIBER_STATE = {
PENDING: 0 as FiberState.PENDING,
LOADING: 1 as FiberState.LOADING,
ACTIVE: 2 as FiberState.ACTIVE,
FAILED: 3 as FiberState.FAILED,
DISPOSED: 4 as FiberState.DISPOSED,
UNLOADING: 5 as FiberState.UNLOADING,
} as const
/** Complete public projection of Cordis Fiber states. */
const FIBER_PHASE = {
[FIBER_STATE.PENDING]: 'pending',
[FIBER_STATE.LOADING]: 'loading',
[FIBER_STATE.ACTIVE]: 'active',
[FIBER_STATE.FAILED]: 'failed',
[FIBER_STATE.DISPOSED]: null,
[FIBER_STATE.UNLOADING]: 'unloading',
} as const satisfies Record<FiberState, PluginFiberPhase>
/** Remote-only service exposing the Loader's current non-group entry state. */
export class PluginInventoryGateway extends TypertRemoteService {
static inject = ['loader']
constructor(ctx: Context) {
super(ctx, 'pluginInventory')
}
/**
* Read the Loader directly on every call. Cordis's internal plugin/status
* events already maintain Entry.fiber and Fiber.state, so a second cache
* would only add another lifecycle truth to keep synchronized.
*
* When an agent-preset roster is composed, the snapshot also carries each
* preset's composition rows, because those rows — not the Loader's own
* entries — are where a deployment that mounts the roster runs its
* model-facing plugins.
* @returns Current non-group Loader entries in Loader order, with per-preset
* compositions when a roster is composed.
*/
@Remote('list')
async list(): Promise<PluginInventorySnapshot> {
const entries: PluginInventoryEntry[] = []
for (const entry of this.ctx.loader.entries()) {
if (entry.options.group) continue
entries.push({
entryId: pluginEntryId(entry.id),
moduleName: entry.options.name,
enabled: !entry.disabled,
fiberPhase: entry.fiber === undefined ? null : FIBER_PHASE[entry.fiber.state],
})
}
const presets = this.ctx.get('agentPresets')
if (presets === undefined) return { entries }
const agentPresets: AgentPresetPluginGroup[] = (await presets.compositionInventory()).map(
composition => ({
...composition,
rows: composition.rows.map(({ fiberState, ...row }) => ({
...row,
fiberPhase: fiberState === undefined ? null : FIBER_PHASE[fiberState],
})),
}),
)
return { entries, agentPresets }
}
}
export default PluginInventoryGateway