dsh-agent-plugins-market 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +117 -111
  2. package/README.zh.md +112 -98
  3. package/client/client.js +547 -540
  4. package/client/client.js.map +1 -1
  5. package/lib/application/catalog-context.js +181 -0
  6. package/lib/application/catalog.js +217 -1110
  7. package/lib/application/details.js +6 -6
  8. package/lib/application/install-store.js +95 -0
  9. package/lib/application/lsp-service.js +97 -0
  10. package/lib/application/mcp-service.js +246 -0
  11. package/lib/application/panel-resources.js +29 -12
  12. package/lib/application/ports.js +21 -0
  13. package/lib/application/project-agent-roles.js +1 -1
  14. package/lib/application/snapshot-cache.js +160 -0
  15. package/lib/application/source-store.js +521 -0
  16. package/lib/catalog/archive.js +34 -29
  17. package/lib/catalog/component-files.js +14 -6
  18. package/lib/catalog/fs-probes.js +43 -0
  19. package/lib/catalog/manifests.js +53 -92
  20. package/lib/catalog/native-project.js +2 -2
  21. package/lib/catalog/paths.js +66 -55
  22. package/lib/catalog/project-config.js +2 -1
  23. package/lib/catalog/project-hooks.js +9 -1
  24. package/lib/catalog/scan-resolvers.js +29 -45
  25. package/lib/catalog/skills-parse.js +14 -10
  26. package/lib/catalog/source-catalog.js +3 -2
  27. package/lib/catalog/suite-components.js +5 -5
  28. package/lib/catalog/suite-scanner.js +3 -1
  29. package/lib/catalog/surfaces.js +5 -26
  30. package/lib/catalog/validate.js +7 -11
  31. package/lib/contracts/market.js +1 -0
  32. package/lib/index.js +91 -208
  33. package/lib/model/types.js +26 -3
  34. package/lib/routes.js +45 -15
  35. package/lib/runtime/agent-role-names.js +70 -0
  36. package/lib/runtime/agent-role-router.js +116 -102
  37. package/lib/runtime/commands-mounts.js +9 -6
  38. package/lib/runtime/deadline.js +28 -0
  39. package/lib/runtime/feedback-tool.js +94 -43
  40. package/lib/runtime/hooks-mounts.js +9 -11
  41. package/lib/runtime/host-locale.js +10 -21
  42. package/lib/runtime/lsp-direct-config.js +19 -19
  43. package/lib/runtime/lsp-mounts.js +159 -68
  44. package/lib/runtime/lsp-server-state.js +4 -4
  45. package/lib/runtime/lsp-status.js +1 -1
  46. package/lib/runtime/mcp-auth-record.js +42 -0
  47. package/lib/runtime/mcp-backend.js +6 -5
  48. package/lib/runtime/mcp-client/config.js +0 -1
  49. package/lib/runtime/mcp-client/connection.js +32 -37
  50. package/lib/runtime/mcp-client/host-contract.js +10 -0
  51. package/lib/runtime/mcp-client/oauth.js +5 -7
  52. package/lib/runtime/mcp-client/plugin-identity.js +28 -0
  53. package/lib/runtime/mcp-client/projection.js +202 -0
  54. package/lib/runtime/mcp-client/tools.js +4 -189
  55. package/lib/runtime/mcp-config.js +29 -10
  56. package/lib/runtime/mcp-direct-config.js +33 -16
  57. package/lib/runtime/mcp-mounts.js +35 -75
  58. package/lib/runtime/mcp-overrides.js +5 -5
  59. package/lib/runtime/mcp-redaction.js +3 -2
  60. package/lib/runtime/mcp-status.js +7 -8
  61. package/lib/runtime/mount-lifecycle.js +73 -0
  62. package/lib/runtime/profile-seam.js +321 -0
  63. package/lib/runtime/project-runtime.js +11 -8
  64. package/lib/runtime/reconcile-scheduler.js +99 -0
  65. package/lib/runtime/reconciler.js +4 -0
  66. package/lib/runtime/server-config.js +6 -4
  67. package/lib/runtime/settings-namespace.js +136 -0
  68. package/lib/runtime/skills-provider.js +5 -3
  69. package/lib/runtime/source-auto-update.js +70 -0
  70. package/lib/{model/state.js → runtime/state-store.js} +9 -11
  71. package/lib/runtime/storage-migration.js +35 -18
  72. package/lib/runtime/subagent-catalog.js +5 -4
  73. package/lib/runtime/user-commands.js +2 -2
  74. package/lib/runtime/user-panels.js +31 -21
  75. package/lib/runtime/user-store.js +12 -13
  76. package/lib/types/application/catalog-context.d.ts +118 -0
  77. package/lib/types/application/catalog.d.ts +99 -304
  78. package/lib/types/application/install-store.d.ts +21 -0
  79. package/lib/types/application/lsp-service.d.ts +36 -0
  80. package/lib/types/application/mcp-service.d.ts +71 -0
  81. package/lib/types/application/panel-resources.d.ts +8 -0
  82. package/lib/types/application/ports.d.ts +72 -0
  83. package/lib/types/application/queries.d.ts +13 -26
  84. package/lib/types/application/snapshot-cache.d.ts +51 -0
  85. package/lib/types/application/source-store.d.ts +100 -0
  86. package/lib/types/catalog/archive.d.ts +3 -11
  87. package/lib/types/catalog/component-files.d.ts +4 -0
  88. package/lib/types/catalog/fs-probes.d.ts +10 -0
  89. package/lib/types/catalog/manifests.d.ts +17 -16
  90. package/lib/types/catalog/native-project.d.ts +2 -2
  91. package/lib/types/catalog/paths.d.ts +47 -15
  92. package/lib/types/catalog/scan-pipeline.d.ts +3 -3
  93. package/lib/types/catalog/scan-resolvers.d.ts +3 -9
  94. package/lib/types/catalog/skills-parse.d.ts +0 -7
  95. package/lib/types/catalog/source-catalog.d.ts +3 -3
  96. package/lib/types/catalog/suite-scanner.d.ts +8 -6
  97. package/lib/types/catalog/validate.d.ts +0 -2
  98. package/lib/types/contracts/lsp-status.d.ts +35 -0
  99. package/lib/types/contracts/market.d.ts +3 -2
  100. package/lib/types/contracts/mcp-status.d.ts +4 -0
  101. package/lib/types/model/types.d.ts +29 -5
  102. package/lib/types/runtime/agent-role-names.d.ts +6 -0
  103. package/lib/types/runtime/agent-role-router.d.ts +54 -51
  104. package/lib/types/runtime/deadline.d.ts +18 -0
  105. package/lib/types/runtime/feedback-tool.d.ts +33 -11
  106. package/lib/types/runtime/hooks-mounts.d.ts +1 -1
  107. package/lib/types/runtime/host-locale.d.ts +1 -1
  108. package/lib/types/runtime/lsp-direct-config.d.ts +3 -3
  109. package/lib/types/runtime/lsp-mounts.d.ts +62 -19
  110. package/lib/types/runtime/lsp-status.d.ts +2 -1
  111. package/lib/types/runtime/mcp-auth-record.d.ts +29 -0
  112. package/lib/types/runtime/mcp-backend.d.ts +7 -4
  113. package/lib/types/runtime/mcp-client/config.d.ts +0 -2
  114. package/lib/types/runtime/mcp-client/host-contract.d.ts +78 -0
  115. package/lib/types/runtime/mcp-client/oauth.d.ts +1 -1
  116. package/lib/types/runtime/mcp-client/plugin-identity.d.ts +16 -0
  117. package/lib/types/runtime/mcp-client/projection.d.ts +45 -0
  118. package/lib/types/runtime/mcp-client/tools.d.ts +5 -72
  119. package/lib/types/runtime/mcp-config.d.ts +25 -4
  120. package/lib/types/runtime/mcp-direct-config.d.ts +18 -4
  121. package/lib/types/runtime/mcp-mounts.d.ts +10 -15
  122. package/lib/types/runtime/mcp-overrides.d.ts +1 -1
  123. package/lib/types/runtime/mcp-status.d.ts +1 -1
  124. package/lib/types/runtime/mount-lifecycle.d.ts +53 -0
  125. package/lib/types/runtime/profile-seam.d.ts +64 -0
  126. package/lib/types/runtime/reconcile-scheduler.d.ts +45 -0
  127. package/lib/types/runtime/reconciler.d.ts +2 -0
  128. package/lib/types/runtime/settings-namespace.d.ts +76 -0
  129. package/lib/types/runtime/source-auto-update.d.ts +33 -0
  130. package/lib/types/{model/state.d.ts → runtime/state-store.d.ts} +2 -2
  131. package/lib/types/runtime/storage-migration.d.ts +5 -3
  132. package/lib/types/runtime/subagent-catalog.d.ts +2 -0
  133. package/lib/types/runtime/user-panels.d.ts +8 -11
  134. package/lib/types/runtime/user-store.d.ts +2 -4
  135. package/package.json +48 -21
  136. package/schemas/README.md +1 -1
@@ -32,5 +32,3 @@ export declare function validateMcpJson(pluginRoot: string, raw: unknown, option
32
32
  export declare function expandPlaceholders(value: string, pluginRoot: string, pluginData: string, env?: NodeJS.ProcessEnv): string;
33
33
  /** Resolve an expanded plugin-relative cwd to an absolute path. */
34
34
  export declare function resolveCwd(value: string, pluginRoot: string, pluginData: string): string;
35
- /** Whether one absolute path equals or lies under another absolute path. */
36
- export declare function isWithin(root: string, candidate: string): boolean;
@@ -50,4 +50,39 @@ export interface LspStatusPayload {
50
50
  };
51
51
  /** True when the host lacks the LSP packages, so every declaration is blocked. */
52
52
  hostMissing: boolean;
53
+ /**
54
+ * A profile layer that still registers the seam this plugin owns, present
55
+ * only while a `seam-conflict` is actually being reported. Releases before
56
+ * the plugin provisioned LSP itself told users to add such a layer by hand,
57
+ * so an upgrade can land here and the panel offers to remove it.
58
+ */
59
+ legacySeam?: LspLegacySeam;
60
+ }
61
+ /** One profile layer that must be removed before this plugin can own the LSP seam. */
62
+ export interface LspLegacySeam {
63
+ /** Profile name, as passed to `dsh --profile`. */
64
+ profile: string;
65
+ /** Absolute path of the profile's patch file. */
66
+ patchPath: string;
67
+ /** The conflicting `insert` rows, as `id` plus package name. */
68
+ rows: Array<{
69
+ id: string;
70
+ name: string;
71
+ }>;
72
+ /** Other profiles carrying a legacy layer, which this action does not touch. */
73
+ otherProfiles: string[];
74
+ /** Whether the host must restart before the removal takes effect. */
75
+ restartRequired: boolean;
76
+ /** Human-readable summary of the layer, used in the panel copy. */
77
+ summary: string;
78
+ }
79
+ /** The outcome of removing one profile's legacy LSP layer. */
80
+ export interface LspLegacySeamMigration {
81
+ profile: string;
82
+ /** Absolute path of the patch file that was edited. */
83
+ patchPath: string;
84
+ /** Where the pre-edit content was kept. */
85
+ backupPath: string;
86
+ /** True when the host must restart before the removal takes effect. */
87
+ restartRequired: boolean;
53
88
  }
@@ -9,6 +9,7 @@ export declare const MARKET_ROUTES: {
9
9
  readonly lspStatus: "/api/agent-plugins/lsp-status";
10
10
  readonly lspServers: "/api/agent-plugins/lsp-servers";
11
11
  readonly addLspServer: "/api/agent-plugins/lsp-servers/add";
12
+ readonly migrateLspSeam: "/api/agent-plugins/lsp-servers/migrate-seam";
12
13
  readonly serverConfig: "/api/agent-plugins/server-config";
13
14
  readonly saveServerConfig: "/api/agent-plugins/server-config/save";
14
15
  readonly progress: "/api/agent-plugins/progress";
@@ -71,7 +72,7 @@ export declare function userPanelRoute(kind: UserPanelKind): string;
71
72
  /** Build one user-panel mutation route URL (all POSTs). */
72
73
  export declare function userPanelMutationRoute(kind: UserPanelKind, mutation: UserPanelMutation, name?: string): string;
73
74
  /** The MCP mount backend state reported to the settings page. */
74
- export interface McpBackendPayload {
75
+ export type McpBackendInfo = {
75
76
  backend: 'builtin' | 'host';
76
77
  /** Whether the host `dsh-mcp-client` resolves from the plugin context. */
77
78
  hostClient: {
@@ -83,7 +84,7 @@ export interface McpBackendPayload {
83
84
  setting: 'auto' | 'global' | 'china';
84
85
  effective: 'global' | 'china';
85
86
  };
86
- }
87
+ };
87
88
  /** One unmanaged `.sources/` checkout the user can adopt as a source. */
88
89
  export interface UnmanagedSource {
89
90
  id: string;
@@ -35,6 +35,10 @@ export interface McpStatusEntry {
35
35
  advertisedTools?: boolean;
36
36
  /** Whether a failed server will be retried automatically. */
37
37
  retryable?: boolean;
38
+ /** A remote server whose suite declares no `auth` block: the bridge still
39
+ * runs the OAuth flow when the server answers 401, which the redacted
40
+ * configuration alone cannot show. */
41
+ oauthDefault?: boolean;
38
42
  }
39
43
  /** The MCP status response returned by the host. */
40
44
  export interface McpStatusPayload {
@@ -26,8 +26,20 @@ export interface SourceRef {
26
26
  /** The checkout pre-existed (manually cloned or adopted); never deleted on source removal. */
27
27
  adopted?: boolean;
28
28
  }
29
+ /**
30
+ * Archive URL suffixes with the payload kind each names, longest suffix first
31
+ * so `.tar.gz` wins over `.tar`. Source-kind inference, source-id derivation,
32
+ * and archive extraction all read this one table.
33
+ */
34
+ export declare const ARCHIVE_SUFFIXES: readonly [readonly [".tar.gz", "targz"], readonly [".tgz", "targz"], readonly [".zip", "zip"], readonly [".tar", "tar"]];
35
+ /** Payload kind of an archive source. */
36
+ export type ArchiveFormat = (typeof ARCHIVE_SUFFIXES)[number][1];
37
+ /** Classify an archive URL by extension; undefined when unsupported. */
38
+ export declare function archiveFormatOf(url: string): ArchiveFormat | undefined;
29
39
  /** Whether a URL points at a downloadable archive. */
30
40
  export declare function isArchiveUrl(url: string): boolean;
41
+ /** Drop a trailing archive suffix (`plugin-0.1.zip` → `plugin-0.1`); other values pass through. */
42
+ export declare function stripArchiveSuffix(value: string): string;
31
43
  /**
32
44
  * Effective acquisition kind of a source: the explicit `kind` wins, the
33
45
  * legacy `local` flag maps to `'local'`, archive-shaped URLs infer
@@ -163,8 +175,13 @@ export interface LspSuiteConfig {
163
175
  }
164
176
  /** Install dimension of a suite. */
165
177
  export type SuiteDimension = 'user' | 'project';
166
- /** One discovered suite with runtime-relevant fields resolved. */
167
- export interface Suite {
178
+ /**
179
+ * One suite as scanning produced it, with runtime-relevant fields resolved:
180
+ * no install entry has been merged in, so there is no lock commit, install
181
+ * timestamp, or effective surface set — except where the layout describes the
182
+ * set itself (project-native). Runtime consumers take {@link Suite}.
183
+ */
184
+ export interface DiscoveredSuite {
168
185
  resources?: {
169
186
  commands: SuiteMarkdownResource[];
170
187
  agents: SuiteMarkdownResource[];
@@ -184,7 +201,7 @@ export interface Suite {
184
201
  surfaces: SuiteSurfaceCounts;
185
202
  dimension: SuiteDimension;
186
203
  enabled: boolean;
187
- /** Effective per-surface enablement (overrides merged over enabled defaults). */
204
+ /** Effective per-surface enablement, declared only by a self-describing layout. */
188
205
  activeSurfaces?: Record<SuiteSurfaceKey, boolean>;
189
206
  lockCommit?: string;
190
207
  installedAt?: string;
@@ -196,6 +213,15 @@ export interface Suite {
196
213
  /** Surface diagnostics on a surviving suite; invalid declared manifests are rejected before discovery returns a suite. */
197
214
  errors: string[];
198
215
  }
216
+ /**
217
+ * A suite with its install state applied: the shape `CatalogContext.project()`
218
+ * returns and every runtime consumer takes. The effective surface set is
219
+ * always present, so no consumer has to interpret its absence.
220
+ */
221
+ export interface Suite extends DiscoveredSuite {
222
+ /** Effective per-surface enablement (overrides merged over enabled defaults). */
223
+ activeSurfaces: Record<SuiteSurfaceKey, boolean>;
224
+ }
199
225
  export interface ProjectHooks {
200
226
  projectRoot: string;
201
227
  events: Record<string, Array<{
@@ -229,5 +255,3 @@ export interface SuiteState {
229
255
  sources: SourceRef[];
230
256
  installed: Record<string, InstalledEntry>;
231
257
  }
232
- /** Browser-safe market records are shared from the transport contracts. */
233
- export type { OverviewPayload, SourceOverview, SuiteOverviewCard } from '../contracts/market.js';
@@ -0,0 +1,6 @@
1
+ /** Internal IDs stay opaque to callers; only colliding resource names need qualification. */
2
+ export declare function namedAgentRoles<T extends {
3
+ name: string;
4
+ }>(entries: readonly T[]): Array<T & {
5
+ callName: string;
6
+ }>;
@@ -1,10 +1,7 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
2
  import { type SubagentCatalogEntry } from './subagent-catalog.js';
3
3
  import { type HostTranslate } from './host-locale.js';
4
- type JsonValue = string | number | boolean | null | JsonValue[] | {
5
- [key: string]: JsonValue;
6
- };
7
- export declare const AGENT_ROLE_TOOL_NAME = "subagents_run";
4
+ export declare const AGENT_ROLE_TOOL_NAME = "subagent_run";
8
5
  /** Panel identity is preserved so identically named cards from different suites remain addressable. */
9
6
  export interface AgentRoleEntry {
10
7
  name: string;
@@ -14,6 +11,10 @@ export interface AgentRoleEntry {
14
11
  title?: string;
15
12
  rawText?: string;
16
13
  }
14
+ /**
15
+ * The executable part of one card. `tools` / `disallowedTools` stay in the file
16
+ * and are preserved by the editors, but they are not applied.
17
+ */
17
18
  export interface AgentRolePolicy {
18
19
  content: string;
19
20
  model?: string;
@@ -21,75 +22,77 @@ export interface AgentRolePolicy {
21
22
  reasoningEffort?: string;
22
23
  title?: string;
23
24
  description?: string;
24
- tools?: string[];
25
- disallowedTools?: string[];
26
25
  disabled: boolean;
27
26
  }
28
- /** Strict YAML parsing prevents malformed routing/restriction metadata from silently inheriting wider privileges. */
29
- export declare function parseAgentRole(text: string): AgentRolePolicy;
30
- interface ModelCatalog {
31
- listProviders(): {
32
- id: string;
33
- }[];
34
- listModels(provider: string): Promise<{
35
- id: string;
36
- }[]>;
37
- resolveCallConfig(config: {
38
- provider: string;
39
- model: string;
40
- reasoningEffort?: string;
41
- }, signal?: AbortSignal): Promise<unknown>;
42
- }
43
- /** Bare ids must resolve uniquely; Claude aliases are accepted only if actually advertised by a DSH provider. */
44
- export declare function resolveAgentModel(policy: AgentRolePolicy, catalog: ModelCatalog): Promise<{
27
+ /** Child LLM options this plugin sends; never carries inherited parent values. */
28
+ export interface AgentRoleOptions {
45
29
  provider?: string;
46
30
  model?: string;
47
- }>;
48
- export interface AgentRoleRequest {
49
- label: string;
31
+ reasoningEffort?: string;
32
+ }
33
+ /** What the host `ctx.subagents` seam receives for one role delegation. */
34
+ export interface AgentRoleDelegation {
50
35
  prompt: {
51
36
  type: 'text';
52
37
  text: string;
53
38
  }[];
54
39
  parent: unknown;
55
- signal: AbortSignal;
56
40
  maxDepth: number;
57
- agentOptions: {
58
- provider?: string;
59
- model?: string;
60
- reasoningEffort?: string;
61
- };
62
41
  persona: string;
63
- toolFilter?: {
64
- allow?: string[];
65
- deny?: string[];
66
- };
42
+ agentOptions?: AgentRoleOptions;
67
43
  }
68
44
  export interface AgentRoleHost {
69
45
  tools: {
70
46
  register(definition: unknown): () => void;
71
47
  };
72
- llm: ModelCatalog;
48
+ llm: {
49
+ resolveCallConfig(config: {
50
+ provider: string;
51
+ model: string;
52
+ reasoningEffort?: string;
53
+ }, signal?: AbortSignal): Promise<unknown>;
54
+ };
73
55
  subagents: {
74
- start(provider: string, request: AgentRoleRequest): Promise<{
75
- id: string;
76
- result: Promise<{
77
- stopReason: string;
78
- output: JsonValue[];
79
- }>;
80
- dispose(): void | Promise<void>;
56
+ startContinuable(spec: {
57
+ provider: string;
58
+ label: string;
59
+ request: AgentRoleDelegation;
60
+ signal: AbortSignal;
61
+ }): Promise<{
62
+ childId: string;
63
+ messageId: string;
81
64
  }>;
82
65
  };
83
66
  }
84
- /** Read the same declaration for catalog summaries and execution, including inline resources. */
85
- export declare function readAgentRole(entry: AgentRoleEntry): Promise<AgentRolePolicy>;
67
+ /** Strict YAML parsing prevents malformed routing metadata from silently inheriting wider privileges. */
68
+ export declare function parseAgentRole(text: string): AgentRolePolicy;
69
+ /**
70
+ * Resolve the child LLM options one card may contribute.
71
+ *
72
+ * A card route is advisory. Only an exact `provider` plus `model` pair is
73
+ * applied, and only when the live LLM runtime accepts it; every other
74
+ * declaration — a bare id, a Claude alias, a lone `provider`, an unsupported
75
+ * effort — degrades to inheriting the parent route and reports a diagnostic.
76
+ * @param policy - the card's parsed routing metadata.
77
+ * @param parent - the calling Agent whose route an unusable declaration falls back to.
78
+ * @param llm - live LLM runtime owning provider, model and effort validation.
79
+ * @param signal - tool-call cancellation signal.
80
+ * @param subject - role name used in diagnostics.
81
+ * @param diagnose - diagnostic sink; degradation is reported, never silent.
82
+ * @returns the options to send, or undefined for pure inheritance.
83
+ */
84
+ export declare function resolveAgentOptions(policy: AgentRolePolicy, parent: unknown, llm: AgentRoleHost['llm'], signal: AbortSignal, subject: string, diagnose: (message: string) => void): Promise<AgentRoleOptions | undefined>;
86
85
  /** Stable summaries; invalid declarations are excluded and transient read failures abort publication. */
87
86
  export declare function agentRoleCatalog(entries: AgentRoleEntry[], signal: AbortSignal, diagnose?: (message: string) => void): Promise<SubagentCatalogEntry[]>;
88
- /** Resolve fresh panel state and raw Markdown on every call, including after edits, disabling and uninstall. */
89
- export declare function executeAgentRole(host: AgentRoleHost, listRoles: (parent?: unknown) => Promise<AgentRoleEntry[]>, name: string, prompt: string, parent: unknown, signal: AbortSignal): Promise<{
90
- runId: string;
91
- output: JsonValue[];
87
+ /** Read the same declaration for catalog summaries and execution, including inline resources. */
88
+ export declare function readAgentRole(entry: AgentRoleEntry): Promise<AgentRolePolicy>;
89
+ /**
90
+ * Start one role child and return its durable id without waiting for the result.
91
+ * Resume state, steering, and the settlement notice belong to the host's
92
+ * continuation manager; this executor owns only role resolution.
93
+ */
94
+ export declare function executeAgentRole(host: AgentRoleHost, listRoles: (parent?: unknown) => Promise<AgentRoleEntry[]>, agentName: string, prompt: string, parent: unknown, signal: AbortSignal, diagnose?: (message: string) => void): Promise<{
95
+ subagentId: string;
92
96
  }>;
93
97
  /** Mount once after tools, llm and subagents are available; the returned disposer belongs to the plugin lifecycle. */
94
98
  export declare function mountAgentRoleTool(ctx: Context, listRoles: (parent?: unknown) => Promise<AgentRoleEntry[]>, t?: HostTranslate): () => void;
95
- export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Bounded waits for work this plugin cannot cancel.
3
+ *
4
+ * Every wait here is a race against a timer: the caller stops waiting and the
5
+ * underlying work keeps running. That is the only safe shape for a mount and
6
+ * for the change pipeline that drives it — a spawned server process or a
7
+ * browser authorization the user is completing must not be abandoned just
8
+ * because nobody is waiting for it any more.
9
+ *
10
+ * @module runtime/deadline
11
+ */
12
+ /**
13
+ * Resolve `true` once `work` settles, or `false` when `deadlineMs` elapses.
14
+ *
15
+ * A rejection counts as settled: this helper only reports timing, so callers
16
+ * that need the failure attach their own handler to `work`.
17
+ */
18
+ export declare function settlesWithin(work: Promise<unknown>, deadlineMs: number): Promise<boolean>;
@@ -5,13 +5,16 @@
5
5
  * default true), the model can call `report_market_issue` when it concludes a
6
6
  * problem it is looking at is caused by dsh-agent-plugins-market — a failed
7
7
  * install, a misdetected source, a market UI defect the user just described.
8
- * The tool files a GitHub issue on the plugin repository through the GitHub
9
- * REST API, or falls back to appending a local JSONL record under the plugin
10
- * data root when no repository host context is available.
8
+ *
9
+ * Filing happens in three steps, most preferred first: the `gh` CLI when it is
10
+ * installed and authenticated, the GitHub REST API when the process carries a
11
+ * `GITHUB_TOKEN` / `GH_TOKEN`, and otherwise nothing is filed — the caller
12
+ * gets the complete issue text plus a prefilled "new issue" URL that is opened
13
+ * in the browser and handed back to the user to submit.
11
14
  *
12
15
  * The tool is deliberately narrow: the title/body must describe the problem,
13
- * submissions are rate-limited, and the setting switch unregisters the tool
14
- * on the next reconcile pass.
16
+ * real submissions are rate-limited, and the setting switch unregisters the
17
+ * tool on the next reconcile pass.
15
18
  * @module runtime/feedback-tool
16
19
  */
17
20
  import type { Context } from '@deepseek-ai/cordis';
@@ -23,8 +26,13 @@ export declare const FEEDBACK_LABEL = "agent-feedback";
23
26
  /** One accepted or rejected submission outcome, mirrored to the model. */
24
27
  export interface FeedbackOutcome {
25
28
  ok: boolean;
26
- /** Where the report went: the issue URL, or the local fallback path label. */
29
+ /**
30
+ * The created issue URL, or — when nothing could file it — the prefilled
31
+ * "new issue" URL the user opens to submit the report themselves.
32
+ */
27
33
  location?: string;
34
+ /** The complete issue title and body; present when nothing was filed automatically. */
35
+ issueText?: string;
28
36
  reason?: string;
29
37
  }
30
38
  /** A structured experience report the model composes. */
@@ -36,14 +44,28 @@ export interface FeedbackReport {
36
44
  /** What actually happened (errors, wrong state, broken flow). */
37
45
  actual?: string;
38
46
  }
47
+ /** Injectable effects, so tests never reach the network or a real browser. */
48
+ export interface FeedbackPorts {
49
+ /** File the issue through the `gh` CLI; undefined when gh is missing or refused. */
50
+ ghIssue?: (title: string, body: string) => Promise<string | undefined>;
51
+ /** Open the prefilled issue page; best effort. */
52
+ openPage?: (url: string) => Promise<void>;
53
+ }
54
+ /** The public "new issue" page for one report, prefilled with title and body. */
55
+ export declare function newIssueUrl(title: string, body: string): string;
39
56
  /**
40
- * Submit one experience report. Tries the GitHub issue API first (works when
41
- * the deployment carries a GITHUB_TOKEN / GH_TOKEN with repo scope), then
42
- * falls back to the local JSONL spool under `<dataRoot>/feedback/`.
57
+ * Submit one experience report through `gh`, then the REST API, then a
58
+ * prefilled issue page the user submits themselves. Only a real submission
59
+ * advances the burst cooldown.
43
60
  */
44
- export declare function submitFeedback(dataRoot: string, report: FeedbackReport, now?: number): Promise<FeedbackOutcome>;
61
+ export declare function submitFeedback(dataRoot: string, report: FeedbackReport, now?: number, ports?: FeedbackPorts): Promise<FeedbackOutcome>;
45
62
  /** Render the model's structured report into a deterministic issue body. */
46
63
  export declare function renderFeedbackBody(report: FeedbackReport): string;
47
64
  export declare const FEEDBACK_TOOL_NAME: "report_market_issue";
48
- /** Register the feedback tool; returns the disposer. Undefined when the host has no tools service. */
65
+ /**
66
+ * Register the feedback tool; returns the disposer. Undefined when the host has
67
+ * no tools service to register on — the caller turns that into a mount-path
68
+ * diagnostic instead of an error, since the setting can simply have no effect
69
+ * on this host.
70
+ */
49
71
  export declare function mountFeedbackTool(hostCtx: Context, dataRoot: string, t: (key: string, params?: Record<string, string>) => string): (() => void) | undefined;
@@ -9,7 +9,7 @@ export declare class HooksMountRegistry {
9
9
  private readonly live;
10
10
  private readonly fingerprints;
11
11
  private readonly temporary;
12
- private queue;
12
+ private readonly passes;
13
13
  constructor(ctx: Context);
14
14
  /** Mount/unmount one bridge per suite to match the enabled suites exactly. */
15
15
  reconcile(enabledSuites: Suite[]): Promise<HooksMountDiagnostic[]>;
@@ -1,5 +1,5 @@
1
1
  /** Host runtime dictionary keys (mirrored for zh and en). */
2
- export type HostLocaleKey = 'subagentCatalogIntro' | 'subagentCatalogUpdated' | 'subagentCatalogEmpty' | 'subagentCatalogCall' | 'subagentCatalogInherit' | 'subagentCatalogDefaultEffort' | 'commandForwardTitle' | 'commandAcknowledged' | 'userCommandSourceLabel' | 'userCommandForwardTitle' | 'userCommandAcknowledged' | 'userSkillDescription' | 'feedbackToolCardTitle';
2
+ export type HostLocaleKey = 'subagentCatalogIntro' | 'subagentCatalogUpdated' | 'subagentCatalogEmpty' | 'subagentCatalogCall' | 'commandAcknowledged' | 'userCommandSourceLabel' | 'feedbackToolCardTitle';
3
3
  export type HostTranslate = (key: HostLocaleKey, params?: Record<string, string>) => string;
4
4
  interface ResolvedLocale {
5
5
  t: HostTranslate;
@@ -1,12 +1,12 @@
1
1
  import type { LspServerSpec } from '../model/types.js';
2
2
  /** The direct LSP server configuration file path. */
3
- export declare function lspServersPath(dataRoot: string): string;
3
+ export declare function lspServersPath(agentsRoot: string): string;
4
4
  /** Load the user-configured LSP servers; unreadable or invalid files yield an empty table. */
5
- export declare function loadLspServers(dataRoot: string): Promise<{
5
+ export declare function loadLspServers(agentsRoot: string): Promise<{
6
6
  servers: Record<string, LspServerSpec>;
7
7
  errors: string[];
8
8
  }>;
9
9
  /** Validate and persist the user-configured LSP servers; returns normalized specs. */
10
- export declare function saveLspServers(dataRoot: string, raw: unknown): Promise<{
10
+ export declare function saveLspServers(agentsRoot: string, raw: unknown): Promise<{
11
11
  servers: Record<string, LspServerSpec>;
12
12
  }>;
@@ -4,11 +4,22 @@
4
4
  *
5
5
  * Mounts reconcile against the enabled-suite set exactly like the MCP mounts:
6
6
  * reconcile() unmounts rows whose suite was disabled or removed and mounts
7
- * rows that appeared. The host LSP package is optional at runtime — without
8
- * it, suites keep every other surface and the manager reports a one-line
9
- * `host-missing` diagnostic that does not enter the retry schedule (a missing
10
- * package is not a transient failure). Mount failures that can resolve after
11
- * user action (installing the language server executable) do retry.
7
+ * rows that appeared. The first wanted server also mounts the capability seam
8
+ * this plugin owns end to end — `ctx.lsp` and the model-facing `lsp` tool —
9
+ * because the dsh installation does not carry the LSP packages; the last one
10
+ * releases it, so a profile that never enables an LSP suite never grows the
11
+ * `lsp` tool.
12
+ *
13
+ * Provisioning is a property of the plugin, not of the profile: both mounts
14
+ * are unconditional and the version comes from this package's dependency
15
+ * declaration. Nothing probes whether the profile already carries a seam — a
16
+ * seam another layer registered comes back as a `seam-conflict` diagnostic
17
+ * naming the layer to remove, so the aligned copy is the only one that can run.
18
+ *
19
+ * A failure the plugin cannot fix itself (a package that is genuinely absent
20
+ * from the profile) reports a one-line `host-missing` diagnostic that does not
21
+ * enter the retry schedule. Mount failures that can resolve after user action
22
+ * (installing the language server executable) do retry.
12
23
  *
13
24
  * Provider identity: one `${suiteId}/${serverKey}` provider id per server, so
14
25
  * two suites declaring the same server key mount independently. Extension
@@ -17,7 +28,8 @@
17
28
  * user resolves it through per-suite surface toggles.
18
29
  */
19
30
  import type { Context } from '@deepseek-ai/cordis';
20
- import type { Suite } from '../model/types.js';
31
+ import { type LegacyLspSeam } from './profile-seam.js';
32
+ import { type Suite } from '../model/types.js';
21
33
  export interface LspMountDiagnostic {
22
34
  suiteId: string;
23
35
  serverKey: string;
@@ -42,34 +54,71 @@ export declare function toLspServerConfig(spec: {
42
54
  initializationOptions?: unknown;
43
55
  configuration?: unknown;
44
56
  }): LspStdioServerConfig;
45
- /** Minimal structural shape of the dynamically imported `dsh-lsp-stdio` module. */
46
- interface LspStdioModule {
57
+ /** Minimal structural shape of a dynamically imported host plugin module. */
58
+ interface HostModule {
47
59
  default?: unknown;
48
60
  }
49
61
  export declare class LspMountRegistry {
50
62
  private readonly ctx;
51
63
  private readonly live;
52
64
  /** Serialize mount and unmount passes so a disable cannot race an in-flight spawn. */
53
- private reconcileQueue;
54
- /** Pending retry timers keyed by mount key, so a teardown can cancel them. */
65
+ private readonly passes;
66
+ /** Delayed re-attempts for mounts that are not live yet. */
55
67
  private readonly retries;
56
- /** Attempt count per mount key; reset whenever a retry succeeds. */
57
- private readonly attempts;
58
68
  /** Snapshot of the last reconciled suite set, replayed by retry passes. */
59
69
  private lastEnabled;
60
70
  /** Host module loader; overridable for tests. */
61
71
  private loadHost;
72
+ /**
73
+ * Reads the profile files when a seam conflict needs explaining. Injectable
74
+ * because it touches the machine's own `$DSH_HOME`, so a test must not
75
+ * inherit whatever the developer running it happens to have configured.
76
+ */
77
+ private readonly locateSeams;
78
+ /** `ctx.lsp` seam loader, mounted only when the profile supplies no service. */
79
+ private loadService;
80
+ /** `lsp` tool loader, mounted only when the profile publishes no such tool. */
81
+ private loadTool;
82
+ /** Capability plugins this registry mounted, in mount order, disposed with the last server. */
83
+ private readonly capability;
84
+ /** Whether the capability seam was already resolved for the current wanted set. */
85
+ private capabilityReady;
86
+ /** Why the capability seam is unavailable; re-attempted on the next reconcile pass. */
87
+ private capabilityFailure;
62
88
  /** Latest diagnostic per suite id; cleared when its suite mounts or leaves the wanted set. */
63
89
  private readonly lastDiagnostics;
64
90
  /** Direct (user-configured) server provider; defaults to none. */
65
91
  private directProvider;
66
92
  private disabledProvider;
67
93
  private disabledSnapshot;
68
- constructor(ctx: Context, loadHost?: () => Promise<LspStdioModule | undefined>);
94
+ constructor(ctx: Context, loadHost?: () => Promise<HostModule | undefined>, loadService?: () => Promise<HostModule | undefined>, loadTool?: () => Promise<HostModule | undefined>, locateSeams?: () => Promise<LegacyLspSeam[]>);
69
95
  /** Queue one reconciliation behind any in-flight mount/unmount pass. */
70
96
  reconcile(enabledSuites: Suite[]): Promise<LspMountDiagnostic[]>;
71
97
  /** Mount/unmount LSP servers to match the enabled suites plus direct config exactly. */
72
98
  private reconcileNow;
99
+ /**
100
+ * Mount the capability seam this plugin delivers end to end: `ctx.lsp`, then the model-facing
101
+ * `lsp` tool.
102
+ *
103
+ * The plugin never asks what the profile already carries. Its dependency declaration decides
104
+ * the version, so deferring to a seam another layer registered would silently run whatever
105
+ * version that layer picked. Both mounts are therefore unconditional; a seam that is already
106
+ * taken comes back as a `seam-conflict` diagnostic naming the layer to remove, which is the
107
+ * only way the aligned copy can own it.
108
+ * @returns the failure, or undefined when the seam is ready.
109
+ */
110
+ private ensureCapability;
111
+ /** Mount one capability plugin and remember it for teardown with the last server. */
112
+ private mountCapability;
113
+ /**
114
+ * Explain a taken seam, naming the profile layer to remove when one can be
115
+ * found on disk. Releases before the plugin provisioned LSP itself told users
116
+ * to add that layer by hand, so the message points at the exact file and rows
117
+ * rather than at "the profile" in general.
118
+ */
119
+ private seamConflictReason;
120
+ /** Dispose the capability seam this registry mounted, once no wanted server needs it. */
121
+ private releaseCapability;
73
122
  /** Install the direct (user-configured) server provider used at reconcile time. */
74
123
  setDirectProvider(provider: () => Promise<Record<string, import('../model/types.js').LspServerSpec>>): void;
75
124
  setDisabledProvider(provider: () => Promise<Set<string>>): void;
@@ -81,12 +130,6 @@ export declare class LspMountRegistry {
81
130
  /** Mount one suite's full server table as a single `dsh-lsp-stdio` instance. */
82
131
  private mountWith;
83
132
  private unmount;
84
- /**
85
- * Schedule a delayed re-attempt for a mount that still is not live. A
86
- * `host-missing` failure passes no diagnostic and is never retried; the
87
- * schedule is bounded and resets with every reconcile pass.
88
- */
89
- private scheduleRetry;
90
133
  /** Dispose every live mount after queued reconciliation passes settle. */
91
134
  disposeAll(): Promise<void>;
92
135
  }
@@ -7,7 +7,8 @@
7
7
  * so a row's state is a declaration-and-diagnostic judgment: a suite whose
8
8
  * mount succeeded yields `mounted` (the seam guarantees registration), a
9
9
  * stored diagnostic yields its own state, and a declaration with neither
10
- * mounts nor diagnostics means the host packages are absent (`host-missing`).
10
+ * mounts nor diagnostics means the capability packages could not be loaded
11
+ * (`host-missing`).
11
12
  * Direct user-configured rows follow the same model under the sentinel suite
12
13
  * id `direct` (mirroring mcp-status's `plugin`/`direct` split).
13
14
  */
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The credential record one MCP server's OAuth grant lives under.
3
+ *
4
+ * `runtime/mcp-client/oauth.ts` writes those records; this module addresses
5
+ * the same key so a grant can be dropped without waking the transport that
6
+ * wrote it. The scope and the name fold must stay identical to that writer's,
7
+ * or the delete silently misses the record.
8
+ *
9
+ * @module runtime/mcp-auth-record
10
+ */
11
+ import { type CredentialKey } from './mcp-client/host-seams.js';
12
+ /** Credential-record scope for MCP OAuth state; per-server ids follow it. */
13
+ export declare const MCP_AUTH_RECORD_SCOPE = "mcp-auth";
14
+ /**
15
+ * Fold a `serverName` into a credential-key id segment. Server names carry
16
+ * `__` separators (e.g. `cloudflare__cloudflare-api`), and the key grammar
17
+ * admits only `[a-z0-9-]`, so non-conforming characters collapse to `-` —
18
+ * deterministic, so the same server always reads and writes one record.
19
+ */
20
+ export declare function mcpAuthRecordId(serverName: string): string;
21
+ /** The credential record key one MCP server's OAuth grant is stored under. */
22
+ export declare function mcpAuthRecordKey(serverName: string): CredentialKey;
23
+ /**
24
+ * Drop one MCP server's OAuth grant record so the next mount re-runs the
25
+ * browser authorization — the path for "I picked too narrow a scope".
26
+ * @param store - the host credentials service, when one is mounted.
27
+ * @throws when the credentials service is not mounted.
28
+ */
29
+ export declare function deleteMcpAuthGrant(store: unknown, serverName: string): Promise<void>;
@@ -16,28 +16,31 @@
16
16
  import z from '@deepseek-ai/schemastery';
17
17
  /** The MCP mount backend the market uses for suite servers. */
18
18
  export type McpBackend = 'builtin' | 'host';
19
- export declare const MCP_BACKENDS: readonly McpBackend[];
20
19
  /** Settings namespace this plugin registers; the key the plugin-config tab pairs our card by. */
21
20
  export declare const MCP_SETTINGS_NAMESPACE = "dsh-agent-plugins-market";
22
- /** Schema of the market settings namespace: the MCP enhancement switch, the download region, and the feedback tool switch. */
21
+ /** Schema of the market settings namespace: the switches this plugin's config card serves. */
23
22
  export declare const MarketSettingsSchema: z<Schemastery.ObjectS<{
24
23
  /** ON (default) = the built-in bridge with OAuth and SSE; OFF = host client compat mode. */
25
24
  mcpEnhanced: z<boolean, boolean>;
26
- /** Read native Agent layouts under the project root; default preserves existing discovery. */
25
+ /** Read native Agent layouts under the project root; OFF (default) scans configured sources only. */
27
26
  scanProjectLayouts: z<boolean, boolean>;
28
27
  /** Download region for GitHub acquisition; `auto` follows the interface language. */
29
28
  downloadRegion: z<"auto" | "global" | "china", "auto" | "global" | "china">;
30
29
  /** ON (default) = the `report_market_issue` model tool is registered; OFF = unregistered. */
31
30
  feedbackEnabled: z<boolean, boolean>;
31
+ /** ON = refresh every configured source in the background; OFF (default) = never. */
32
+ autoUpdateSources: z<boolean, boolean>;
32
33
  }>, Schemastery.ObjectT<{
33
34
  /** ON (default) = the built-in bridge with OAuth and SSE; OFF = host client compat mode. */
34
35
  mcpEnhanced: z<boolean, boolean>;
35
- /** Read native Agent layouts under the project root; default preserves existing discovery. */
36
+ /** Read native Agent layouts under the project root; OFF (default) scans configured sources only. */
36
37
  scanProjectLayouts: z<boolean, boolean>;
37
38
  /** Download region for GitHub acquisition; `auto` follows the interface language. */
38
39
  downloadRegion: z<"auto" | "global" | "china", "auto" | "global" | "china">;
39
40
  /** ON (default) = the `report_market_issue` model tool is registered; OFF = unregistered. */
40
41
  feedbackEnabled: z<boolean, boolean>;
42
+ /** ON = refresh every configured source in the background; OFF (default) = never. */
43
+ autoUpdateSources: z<boolean, boolean>;
41
44
  }>>;
42
45
  /** Path of the legacy persisted settings file under the plugin data root. */
43
46
  export declare function marketSettingsPath(dataRoot: string): string;