@namzu/cli 30.0.0 → 32.0.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.
- package/CHANGELOG.md +217 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +5 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/acp.d.ts +20 -2
- package/dist/commands/acp.d.ts.map +1 -1
- package/dist/commands/acp.js +42 -5
- package/dist/commands/acp.js.map +1 -1
- package/dist/commands/drain.d.ts.map +1 -1
- package/dist/commands/drain.js +2 -1
- package/dist/commands/drain.js.map +1 -1
- package/dist/commands/exec-json.d.ts.map +1 -1
- package/dist/commands/exec-json.js +24 -1
- package/dist/commands/exec-json.js.map +1 -1
- package/dist/commands/exec.d.ts.map +1 -1
- package/dist/commands/exec.js +2 -1
- package/dist/commands/exec.js.map +1 -1
- package/dist/commands/prior-messages.d.ts.map +1 -1
- package/dist/commands/prior-messages.js +42 -2
- package/dist/commands/prior-messages.js.map +1 -1
- package/dist/commands/schedule.d.ts.map +1 -1
- package/dist/commands/schedule.js +7 -5
- package/dist/commands/schedule.js.map +1 -1
- package/dist/config/composer-triggers.d.ts +41 -0
- package/dist/config/composer-triggers.d.ts.map +1 -0
- package/dist/config/composer-triggers.js +80 -0
- package/dist/config/composer-triggers.js.map +1 -0
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +58 -0
- package/dist/config/load.js.map +1 -1
- package/dist/config/schema.d.ts +34 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/context/doctrine.d.ts +3 -3
- package/dist/context/doctrine.d.ts.map +1 -1
- package/dist/context/doctrine.js +3 -3
- package/dist/context/doctrine.js.map +1 -1
- package/dist/context/runtime-message.d.ts.map +1 -1
- package/dist/context/runtime-message.js +4 -0
- package/dist/context/runtime-message.js.map +1 -1
- package/dist/integrations/mcp/servers.d.ts +72 -5
- package/dist/integrations/mcp/servers.d.ts.map +1 -1
- package/dist/integrations/mcp/servers.js +144 -23
- package/dist/integrations/mcp/servers.js.map +1 -1
- package/dist/integrations/plugins/runtime.d.ts +11 -9
- package/dist/integrations/plugins/runtime.d.ts.map +1 -1
- package/dist/integrations/plugins/runtime.js +17 -36
- package/dist/integrations/plugins/runtime.js.map +1 -1
- package/dist/integrations/resident/session-step.d.ts.map +1 -1
- package/dist/integrations/resident/session-step.js +2 -1
- package/dist/integrations/resident/session-step.js.map +1 -1
- package/dist/integrations/sessions/store.d.ts.map +1 -1
- package/dist/integrations/sessions/store.js +20 -2
- package/dist/integrations/sessions/store.js.map +1 -1
- package/dist/integrations/subagents/NamzuCliAgent.d.ts +8 -0
- package/dist/integrations/subagents/NamzuCliAgent.d.ts.map +1 -0
- package/dist/integrations/subagents/NamzuCliAgent.js +9 -0
- package/dist/integrations/subagents/NamzuCliAgent.js.map +1 -0
- package/dist/integrations/subagents/runtime.d.ts +5 -4
- package/dist/integrations/subagents/runtime.d.ts.map +1 -1
- package/dist/integrations/subagents/runtime.js +46 -11
- package/dist/integrations/subagents/runtime.js.map +1 -1
- package/dist/integrations/web/search.d.ts.map +1 -1
- package/dist/integrations/web/search.js +8 -6
- package/dist/integrations/web/search.js.map +1 -1
- package/dist/permissions/rules.d.ts +5 -1
- package/dist/permissions/rules.d.ts.map +1 -1
- package/dist/permissions/rules.js +85 -3
- package/dist/permissions/rules.js.map +1 -1
- package/dist/schedule/build.d.ts +19 -2
- package/dist/schedule/build.d.ts.map +1 -1
- package/dist/schedule/build.js +119 -21
- package/dist/schedule/build.js.map +1 -1
- package/dist/schedule/changes.d.ts.map +1 -1
- package/dist/schedule/changes.js +13 -0
- package/dist/schedule/changes.js.map +1 -1
- package/dist/schedule/commands/add.d.ts +1 -1
- package/dist/schedule/commands/add.d.ts.map +1 -1
- package/dist/schedule/commands/add.js +186 -40
- package/dist/schedule/commands/add.js.map +1 -1
- package/dist/schedule/commands/list.d.ts +2 -0
- package/dist/schedule/commands/list.d.ts.map +1 -1
- package/dist/schedule/commands/list.js +64 -19
- package/dist/schedule/commands/list.js.map +1 -1
- package/dist/schedule/daemon/daemon.d.ts +1 -1
- package/dist/schedule/daemon/daemon.d.ts.map +1 -1
- package/dist/schedule/daemon/daemon.js +17 -5
- package/dist/schedule/daemon/daemon.js.map +1 -1
- package/dist/schedule/daemon/notify.d.ts +21 -1
- package/dist/schedule/daemon/notify.d.ts.map +1 -1
- package/dist/schedule/daemon/notify.js +43 -0
- package/dist/schedule/daemon/notify.js.map +1 -1
- package/dist/schedule/fire/fire.d.ts +1 -1
- package/dist/schedule/fire/fire.d.ts.map +1 -1
- package/dist/schedule/fire/fire.js +200 -14
- package/dist/schedule/fire/fire.js.map +1 -1
- package/dist/schedule/fire/result.d.ts +1 -1
- package/dist/schedule/fire/result.d.ts.map +1 -1
- package/dist/schedule/fire/result.js +2 -1
- package/dist/schedule/fire/result.js.map +1 -1
- package/dist/schedule/fire/run-script.d.ts +46 -0
- package/dist/schedule/fire/run-script.d.ts.map +1 -0
- package/dist/schedule/fire/run-script.js +81 -0
- package/dist/schedule/fire/run-script.js.map +1 -0
- package/dist/schedule/fire/unattended-note.d.ts +8 -0
- package/dist/schedule/fire/unattended-note.d.ts.map +1 -1
- package/dist/schedule/fire/unattended-note.js +5 -0
- package/dist/schedule/fire/unattended-note.js.map +1 -1
- package/dist/schedule/fire/wake-gate.d.ts +39 -0
- package/dist/schedule/fire/wake-gate.d.ts.map +1 -0
- package/dist/schedule/fire/wake-gate.js +90 -0
- package/dist/schedule/fire/wake-gate.js.map +1 -0
- package/dist/schedule/floor.d.ts +1 -1
- package/dist/schedule/floor.d.ts.map +1 -1
- package/dist/schedule/floor.js +288 -16
- package/dist/schedule/floor.js.map +1 -1
- package/dist/schedule/policy.d.ts +40 -0
- package/dist/schedule/policy.d.ts.map +1 -1
- package/dist/schedule/policy.js +36 -0
- package/dist/schedule/policy.js.map +1 -1
- package/dist/schedule/script-check.d.ts +53 -0
- package/dist/schedule/script-check.d.ts.map +1 -0
- package/dist/schedule/script-check.js +145 -0
- package/dist/schedule/script-check.js.map +1 -0
- package/dist/schedule/script-shell.d.ts +3 -0
- package/dist/schedule/script-shell.d.ts.map +1 -0
- package/dist/schedule/script-shell.js +5 -0
- package/dist/schedule/script-shell.js.map +1 -0
- package/dist/schedule/service/manifest.js +1 -1
- package/dist/schedule/service/manifest.js.map +1 -1
- package/dist/schedule/store/atomic.d.ts +5 -2
- package/dist/schedule/store/atomic.d.ts.map +1 -1
- package/dist/schedule/store/atomic.js +7 -4
- package/dist/schedule/store/atomic.js.map +1 -1
- package/dist/schedule/store/claims.js +1 -1
- package/dist/schedule/store/claims.js.map +1 -1
- package/dist/schedule/store/history.d.ts +1 -1
- package/dist/schedule/store/history.d.ts.map +1 -1
- package/dist/schedule/store/history.js +4 -1
- package/dist/schedule/store/history.js.map +1 -1
- package/dist/schedule/store/jobs.d.ts +19 -3
- package/dist/schedule/store/jobs.d.ts.map +1 -1
- package/dist/schedule/store/jobs.js +83 -16
- package/dist/schedule/store/jobs.js.map +1 -1
- package/dist/schedule/store/state.js +1 -1
- package/dist/schedule/store/state.js.map +1 -1
- package/dist/schedule/types.d.ts +71 -6
- package/dist/schedule/types.d.ts.map +1 -1
- package/dist/schedule/types.js +25 -1
- package/dist/schedule/types.js.map +1 -1
- package/dist/schedule/visible-source.d.ts +18 -0
- package/dist/schedule/visible-source.d.ts.map +1 -0
- package/dist/schedule/visible-source.js +59 -0
- package/dist/schedule/visible-source.js.map +1 -0
- package/dist/test-support/toolset.d.ts +23 -0
- package/dist/test-support/toolset.d.ts.map +1 -0
- package/dist/test-support/toolset.js +27 -0
- package/dist/test-support/toolset.js.map +1 -0
- package/dist/tui/App.d.ts.map +1 -1
- package/dist/tui/App.js +323 -60
- package/dist/tui/App.js.map +1 -1
- package/dist/tui/ChoicePicker.d.ts +2 -0
- package/dist/tui/ChoicePicker.d.ts.map +1 -1
- package/dist/tui/ChoicePicker.js +10 -2
- package/dist/tui/ChoicePicker.js.map +1 -1
- package/dist/tui/Composer.d.ts +62 -3
- package/dist/tui/Composer.d.ts.map +1 -1
- package/dist/tui/Composer.js +162 -25
- package/dist/tui/Composer.js.map +1 -1
- package/dist/tui/ComposerFrame.d.ts +1 -1
- package/dist/tui/ComposerFrame.js +3 -3
- package/dist/tui/ComposerFrame.js.map +1 -1
- package/dist/tui/EffortSlider.d.ts +8 -9
- package/dist/tui/EffortSlider.d.ts.map +1 -1
- package/dist/tui/EffortSlider.js +15 -12
- package/dist/tui/EffortSlider.js.map +1 -1
- package/dist/tui/StatusBar.d.ts +12 -12
- package/dist/tui/StatusBar.d.ts.map +1 -1
- package/dist/tui/StatusBar.js +15 -15
- package/dist/tui/StatusBar.js.map +1 -1
- package/dist/tui/agent.d.ts +46 -7
- package/dist/tui/agent.d.ts.map +1 -1
- package/dist/tui/agent.js +386 -178
- package/dist/tui/agent.js.map +1 -1
- package/dist/tui/hypermode.d.ts +37 -0
- package/dist/tui/hypermode.d.ts.map +1 -0
- package/dist/tui/hypermode.js +58 -0
- package/dist/tui/hypermode.js.map +1 -0
- package/dist/tui/permission-review.d.ts +1 -1
- package/dist/tui/permission-review.js +1 -1
- package/dist/tui/schedule/host-commands.d.ts.map +1 -1
- package/dist/tui/schedule/host-commands.js +94 -33
- package/dist/tui/schedule/host-commands.js.map +1 -1
- package/dist/tui/schedule/integration.d.ts +6 -2
- package/dist/tui/schedule/integration.d.ts.map +1 -1
- package/dist/tui/schedule/integration.js +3 -1
- package/dist/tui/schedule/integration.js.map +1 -1
- package/dist/tui/schedule/resume.d.ts.map +1 -1
- package/dist/tui/schedule/resume.js +10 -1
- package/dist/tui/schedule/resume.js.map +1 -1
- package/dist/tui/schedule/tool-host.d.ts +4 -1
- package/dist/tui/schedule/tool-host.d.ts.map +1 -1
- package/dist/tui/schedule/tool-host.js +155 -40
- package/dist/tui/schedule/tool-host.js.map +1 -1
- package/dist/tui/slashCommands.d.ts +23 -5
- package/dist/tui/slashCommands.d.ts.map +1 -1
- package/dist/tui/slashCommands.js +80 -31
- package/dist/tui/slashCommands.js.map +1 -1
- package/dist/tui/theme.d.ts +10 -4
- package/dist/tui/theme.d.ts.map +1 -1
- package/dist/tui/theme.js +4 -3
- package/dist/tui/theme.js.map +1 -1
- package/dist/tui/triggers/analyze.d.ts +57 -0
- package/dist/tui/triggers/analyze.d.ts.map +1 -0
- package/dist/tui/triggers/analyze.js +221 -0
- package/dist/tui/triggers/analyze.js.map +1 -0
- package/dist/tui/triggers/context-text.d.ts +21 -0
- package/dist/tui/triggers/context-text.d.ts.map +1 -0
- package/dist/tui/triggers/context-text.js +44 -0
- package/dist/tui/triggers/context-text.js.map +1 -0
- package/dist/tui/triggers/copy.d.ts +38 -0
- package/dist/tui/triggers/copy.d.ts.map +1 -0
- package/dist/tui/triggers/copy.js +163 -0
- package/dist/tui/triggers/copy.js.map +1 -0
- package/dist/tui/triggers/detect.d.ts +83 -0
- package/dist/tui/triggers/detect.d.ts.map +1 -0
- package/dist/tui/triggers/detect.js +295 -0
- package/dist/tui/triggers/detect.js.map +1 -0
- package/dist/tui/triggers/fold.d.ts +34 -0
- package/dist/tui/triggers/fold.d.ts.map +1 -0
- package/dist/tui/triggers/fold.js +44 -0
- package/dist/tui/triggers/fold.js.map +1 -0
- package/dist/tui/triggers/pattern.d.ts +66 -0
- package/dist/tui/triggers/pattern.d.ts.map +1 -0
- package/dist/tui/triggers/pattern.js +243 -0
- package/dist/tui/triggers/pattern.js.map +1 -0
- package/dist/tui/triggers/provenance.d.ts +58 -0
- package/dist/tui/triggers/provenance.d.ts.map +1 -0
- package/dist/tui/triggers/provenance.js +98 -0
- package/dist/tui/triggers/provenance.js.map +1 -0
- package/dist/tui/triggers/registry.d.ts +113 -0
- package/dist/tui/triggers/registry.d.ts.map +1 -0
- package/dist/tui/triggers/registry.js +164 -0
- package/dist/tui/triggers/registry.js.map +1 -0
- package/dist/tui/triggers/setting.d.ts +18 -0
- package/dist/tui/triggers/setting.d.ts.map +1 -0
- package/dist/tui/triggers/setting.js +61 -0
- package/dist/tui/triggers/setting.js.map +1 -0
- package/dist/tui/triggers/verbs.d.ts +29 -0
- package/dist/tui/triggers/verbs.d.ts.map +1 -0
- package/dist/tui/triggers/verbs.js +140 -0
- package/dist/tui/triggers/verbs.js.map +1 -0
- package/dist/tui/types.d.ts +3 -1
- package/dist/tui/types.d.ts.map +1 -1
- package/package.json +12 -12
- package/skills/schedule-task/SKILL.md +115 -3
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* "search": { "url": "https://tools.example.internal/mcp" }
|
|
15
15
|
* }
|
|
16
16
|
*
|
|
17
|
-
* Its tools arrive prefixed with the server's name (`
|
|
17
|
+
* Its tools arrive prefixed with the server's name (`mcp__tickets__create`), so
|
|
18
18
|
* two servers offering `search` do not collide and the transcript says where a
|
|
19
19
|
* call went.
|
|
20
20
|
*
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* and a headless run has nobody to read anything, so it refuses. This module
|
|
32
32
|
* reports; the callers decide.
|
|
33
33
|
*/
|
|
34
|
-
import { type MCPTransportUnion, type ToolDefinition } from '@namzu/sdk';
|
|
34
|
+
import { type MCPToolDrift, type MCPTransportUnion, type ToolDefinition, type Toolset } from '@namzu/sdk';
|
|
35
35
|
/**
|
|
36
36
|
* How long a single server gets to connect, hand shake and list its tools.
|
|
37
37
|
*
|
|
@@ -55,6 +55,15 @@ export interface McpServerSpec {
|
|
|
55
55
|
/** Stdio: the executable to run. */
|
|
56
56
|
readonly command?: string;
|
|
57
57
|
readonly args?: readonly string[];
|
|
58
|
+
/**
|
|
59
|
+
* A value may reference the operator's own environment with a bare
|
|
60
|
+
* `${VAR_NAME}` — no `${VAR:-default}` fallback, and an unset
|
|
61
|
+
* `VAR_NAME` fails this server with a named reason rather than running
|
|
62
|
+
* with an empty string. See {@link expandEnvRefsInRecord}. Prefer
|
|
63
|
+
* `inheritEnv` below for a plain "grant this variable under its own
|
|
64
|
+
* name"; use `${VAR_NAME}` here to rename a variable into whatever key
|
|
65
|
+
* the server expects.
|
|
66
|
+
*/
|
|
58
67
|
readonly env?: Readonly<Record<string, string>>;
|
|
59
68
|
/**
|
|
60
69
|
* Variables from the operator's own environment this server may have.
|
|
@@ -72,6 +81,11 @@ export interface McpServerSpec {
|
|
|
72
81
|
readonly cwd?: string;
|
|
73
82
|
/** HTTP: the server's endpoint. */
|
|
74
83
|
readonly url?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Same `${VAR_NAME}` expansion as `env` above — the only secret-safe
|
|
86
|
+
* option for a header value, since `inheritEnv` reaches the stdio
|
|
87
|
+
* child's process environment only, never an HTTP header.
|
|
88
|
+
*/
|
|
75
89
|
readonly headers?: Readonly<Record<string, string>>;
|
|
76
90
|
/**
|
|
77
91
|
* How long THIS server gets to connect, hand shake and list its tools, in
|
|
@@ -100,6 +114,18 @@ export interface McpServerSpec {
|
|
|
100
114
|
* `connectTimeoutMs` for the handshake that will actually answer.
|
|
101
115
|
*/
|
|
102
116
|
readonly eraProbeTimeoutMs?: number;
|
|
117
|
+
/** Server-reported names admitted from tools, prompts and resources. */
|
|
118
|
+
readonly allow?: readonly string[];
|
|
119
|
+
/** Server-reported names refused even if `allow` includes them. */
|
|
120
|
+
readonly deny?: readonly string[];
|
|
121
|
+
/** Retries only tool calls the SDK marks safe to repeat. Defaults to none. */
|
|
122
|
+
readonly maxRetries?: number;
|
|
123
|
+
/** Require a person to approve every call this server contributes. */
|
|
124
|
+
readonly requireApproval?: boolean;
|
|
125
|
+
/** Trust this server's read-only hints for review exemptions. Defaults to false. */
|
|
126
|
+
readonly readOnlyHintTrusted?: boolean;
|
|
127
|
+
/** Include the server's own initialize instructions as untrusted turn context. Default false. */
|
|
128
|
+
readonly instructions?: boolean;
|
|
103
129
|
}
|
|
104
130
|
export type McpServersConfig = Readonly<Record<string, McpServerSpec>>;
|
|
105
131
|
export interface ConnectedMcpServer {
|
|
@@ -109,11 +135,21 @@ export interface ConnectedMcpServer {
|
|
|
109
135
|
* What this server actually contributes, by tool name.
|
|
110
136
|
*
|
|
111
137
|
* Carried from the listing rather than recovered later. The names arrive
|
|
112
|
-
* prefixed with the server's own (`
|
|
138
|
+
* prefixed with the server's own (`mcp__tickets__create`), so a caller COULD
|
|
113
139
|
* split them back apart — but that turns an encoding this file owns into a
|
|
114
140
|
* format two places have to agree about, and the list is free right here.
|
|
115
141
|
*/
|
|
116
142
|
readonly tools: readonly string[];
|
|
143
|
+
/** The server's current initialize instructions, if it supplied any. */
|
|
144
|
+
readonly instructions?: string;
|
|
145
|
+
/** Names changed since this connection's first listing; changed definitions remain held. */
|
|
146
|
+
readonly drift?: MCPToolDrift;
|
|
147
|
+
/** Current allow/deny refusals, by server-reported name. */
|
|
148
|
+
readonly refused?: readonly {
|
|
149
|
+
kind: 'tools' | 'prompts' | 'resources';
|
|
150
|
+
name: string;
|
|
151
|
+
reason: 'not_allowed' | 'denied';
|
|
152
|
+
}[];
|
|
117
153
|
}
|
|
118
154
|
export interface FailedMcpServer {
|
|
119
155
|
readonly name: string;
|
|
@@ -121,8 +157,13 @@ export interface FailedMcpServer {
|
|
|
121
157
|
readonly reason: string;
|
|
122
158
|
}
|
|
123
159
|
export interface McpConnection {
|
|
124
|
-
/**
|
|
160
|
+
/** Current definitions from every connected server, read from its live toolsets. */
|
|
125
161
|
readonly tools: readonly ToolDefinition[];
|
|
162
|
+
/**
|
|
163
|
+
* Two live entries per connected server: its configured main tools and its
|
|
164
|
+
* always-deferred resource tools. Both carry the `mcp:<server>` source.
|
|
165
|
+
*/
|
|
166
|
+
readonly toolsets: readonly Toolset[];
|
|
126
167
|
/** One coherent live snapshot; use this when successes and failures are shown together. */
|
|
127
168
|
current(): {
|
|
128
169
|
readonly connected: readonly ConnectedMcpServer[];
|
|
@@ -142,6 +183,32 @@ export interface McpConnection {
|
|
|
142
183
|
*/
|
|
143
184
|
close(): Promise<void>;
|
|
144
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Expand `${VAR}` references inside `env`/`headers` values against the
|
|
188
|
+
* operator's own environment.
|
|
189
|
+
*
|
|
190
|
+
* Deliberately narrower than the interpolation some other MCP clients'
|
|
191
|
+
* configs use (see docs/cli/mcp-servers.md): bare `${VAR}` only, no
|
|
192
|
+
* `${VAR:-default}` fallback, and only inside `env` and `headers` values —
|
|
193
|
+
* never `command`, `args`, `url` or `cwd`, which have no legitimate secret
|
|
194
|
+
* use case and would only widen the surface for an accidental literal `${`
|
|
195
|
+
* to break. A referenced variable that is unset is refused with a named
|
|
196
|
+
* reason, not silently substituted with an empty string: that is exactly
|
|
197
|
+
* the footgun a `:-default` fallback would reintroduce, and this module's
|
|
198
|
+
* whole design is "every failure is named" rather than a server running
|
|
199
|
+
* quietly with a secret it never got.
|
|
200
|
+
*
|
|
201
|
+
* `inheritEnv` stays the primary idiom for "grant this named variable to
|
|
202
|
+
* the child process under its own name" — this is for the config VALUE
|
|
203
|
+
* itself, letting an operator rename an env var into whatever key or
|
|
204
|
+
* header a server expects, and giving `headers` a secret-safe option it
|
|
205
|
+
* has never had (`inheritEnv` only reaches the stdio child's process env,
|
|
206
|
+
* not header values).
|
|
207
|
+
*
|
|
208
|
+
* Returns the expanded record, or a reason string naming the first unset
|
|
209
|
+
* variable a value referenced.
|
|
210
|
+
*/
|
|
211
|
+
export declare function expandEnvRefsInRecord(record: Readonly<Record<string, string>>, env: NodeJS.ProcessEnv): Readonly<Record<string, string>> | string;
|
|
145
212
|
/**
|
|
146
213
|
* Turn one spec into a transport, or say why it is not one.
|
|
147
214
|
*
|
|
@@ -149,7 +216,7 @@ export interface McpConnection {
|
|
|
149
216
|
* operator who edited one into a file that already had the other, and picking
|
|
150
217
|
* either would run something they did not mean to run.
|
|
151
218
|
*/
|
|
152
|
-
export declare function transportFor(spec: McpServerSpec, defaultCwd: string): MCPTransportUnion | string;
|
|
219
|
+
export declare function transportFor(spec: McpServerSpec, defaultCwd: string, env?: NodeJS.ProcessEnv): MCPTransportUnion | string;
|
|
153
220
|
/**
|
|
154
221
|
* The connect deadline a spec asks for, or why it cannot have it.
|
|
155
222
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"servers.d.ts","sourceRoot":"","sources":["../../../src/integrations/mcp/servers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAEN,KAAK,iBAAiB,EACtB,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"servers.d.ts","sourceRoot":"","sources":["../../../src/integrations/mcp/servers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAEN,KAAK,YAAY,EAEjB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,OAAO,EAGZ,MAAM,YAAY,CAAA;AAEnB;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,QAAS,CAAA;AAExC;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,OAAQ,CAAA;AAErC,gFAAgF;AAChF,MAAM,WAAW,aAAa;IAC7B,oCAAoC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACjC;;;;;;;;OAQG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAC/C;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACvC,gEAAgE;IAChE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,mCAAmC;IACnC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACnD;;;;;;;;;OASG;IACH,QAAQ,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iBAAiB,CACtC,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACpC,OAAO,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC/B,OAAO,CAAC,aAAa,CAAC,CA0KxB"}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* "search": { "url": "https://tools.example.internal/mcp" }
|
|
15
15
|
* }
|
|
16
16
|
*
|
|
17
|
-
* Its tools arrive prefixed with the server's name (`
|
|
17
|
+
* Its tools arrive prefixed with the server's name (`mcp__tickets__create`), so
|
|
18
18
|
* two servers offering `search` do not collide and the transcript says where a
|
|
19
19
|
* call went.
|
|
20
20
|
*
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* and a headless run has nobody to read anything, so it refuses. This module
|
|
32
32
|
* reports; the callers decide.
|
|
33
33
|
*/
|
|
34
|
-
import { MCPClient,
|
|
34
|
+
import { MCPClient, mcpToolset, requireApproval, } from '@namzu/sdk';
|
|
35
35
|
/**
|
|
36
36
|
* How long a single server gets to connect, hand shake and list its tools.
|
|
37
37
|
*
|
|
@@ -50,6 +50,55 @@ export const CONNECT_TIMEOUT_MS = 10_000;
|
|
|
50
50
|
* command open past the work it was asked to do.
|
|
51
51
|
*/
|
|
52
52
|
export const CLOSE_TIMEOUT_MS = 2_000;
|
|
53
|
+
/**
|
|
54
|
+
* A bare `${VAR}` reference inside an `env` or `headers` value — identifier
|
|
55
|
+
* characters only, no `:-default` fallback. See {@link expandEnvRefsInRecord}.
|
|
56
|
+
*/
|
|
57
|
+
const ENV_REF_PATTERN = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
58
|
+
/**
|
|
59
|
+
* Expand `${VAR}` references inside `env`/`headers` values against the
|
|
60
|
+
* operator's own environment.
|
|
61
|
+
*
|
|
62
|
+
* Deliberately narrower than the interpolation some other MCP clients'
|
|
63
|
+
* configs use (see docs/cli/mcp-servers.md): bare `${VAR}` only, no
|
|
64
|
+
* `${VAR:-default}` fallback, and only inside `env` and `headers` values —
|
|
65
|
+
* never `command`, `args`, `url` or `cwd`, which have no legitimate secret
|
|
66
|
+
* use case and would only widen the surface for an accidental literal `${`
|
|
67
|
+
* to break. A referenced variable that is unset is refused with a named
|
|
68
|
+
* reason, not silently substituted with an empty string: that is exactly
|
|
69
|
+
* the footgun a `:-default` fallback would reintroduce, and this module's
|
|
70
|
+
* whole design is "every failure is named" rather than a server running
|
|
71
|
+
* quietly with a secret it never got.
|
|
72
|
+
*
|
|
73
|
+
* `inheritEnv` stays the primary idiom for "grant this named variable to
|
|
74
|
+
* the child process under its own name" — this is for the config VALUE
|
|
75
|
+
* itself, letting an operator rename an env var into whatever key or
|
|
76
|
+
* header a server expects, and giving `headers` a secret-safe option it
|
|
77
|
+
* has never had (`inheritEnv` only reaches the stdio child's process env,
|
|
78
|
+
* not header values).
|
|
79
|
+
*
|
|
80
|
+
* Returns the expanded record, or a reason string naming the first unset
|
|
81
|
+
* variable a value referenced.
|
|
82
|
+
*/
|
|
83
|
+
export function expandEnvRefsInRecord(record, env) {
|
|
84
|
+
const result = {};
|
|
85
|
+
for (const [key, raw] of Object.entries(record)) {
|
|
86
|
+
let missing;
|
|
87
|
+
const expanded = raw.replace(ENV_REF_PATTERN, (whole, name) => {
|
|
88
|
+
const value = env[name];
|
|
89
|
+
if (value === undefined) {
|
|
90
|
+
missing = name;
|
|
91
|
+
return whole;
|
|
92
|
+
}
|
|
93
|
+
return value;
|
|
94
|
+
});
|
|
95
|
+
if (missing !== undefined) {
|
|
96
|
+
return `references \${${missing}}, which is not set in the operator's environment`;
|
|
97
|
+
}
|
|
98
|
+
result[key] = expanded;
|
|
99
|
+
}
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
53
102
|
/**
|
|
54
103
|
* Turn one spec into a transport, or say why it is not one.
|
|
55
104
|
*
|
|
@@ -57,27 +106,33 @@ export const CLOSE_TIMEOUT_MS = 2_000;
|
|
|
57
106
|
* operator who edited one into a file that already had the other, and picking
|
|
58
107
|
* either would run something they did not mean to run.
|
|
59
108
|
*/
|
|
60
|
-
export function transportFor(spec, defaultCwd) {
|
|
109
|
+
export function transportFor(spec, defaultCwd, env = process.env) {
|
|
61
110
|
const hasCommand = typeof spec.command === 'string' && spec.command.trim().length > 0;
|
|
62
111
|
const hasUrl = typeof spec.url === 'string' && spec.url.trim().length > 0;
|
|
63
112
|
if (hasCommand && hasUrl) {
|
|
64
113
|
return 'it declares both a command and a url — pick one';
|
|
65
114
|
}
|
|
66
115
|
if (hasCommand) {
|
|
116
|
+
const expandedEnv = spec.env ? expandEnvRefsInRecord(spec.env, env) : undefined;
|
|
117
|
+
if (typeof expandedEnv === 'string')
|
|
118
|
+
return expandedEnv;
|
|
67
119
|
return {
|
|
68
120
|
type: 'stdio',
|
|
69
121
|
command: spec.command,
|
|
70
122
|
...(spec.args ? { args: [...spec.args] } : {}),
|
|
71
|
-
...(
|
|
123
|
+
...(expandedEnv ? { env: expandedEnv } : {}),
|
|
72
124
|
...(spec.inheritEnv ? { inheritEnv: [...spec.inheritEnv] } : {}),
|
|
73
125
|
cwd: spec.cwd ?? defaultCwd,
|
|
74
126
|
};
|
|
75
127
|
}
|
|
76
128
|
if (hasUrl) {
|
|
129
|
+
const expandedHeaders = spec.headers ? expandEnvRefsInRecord(spec.headers, env) : undefined;
|
|
130
|
+
if (typeof expandedHeaders === 'string')
|
|
131
|
+
return expandedHeaders;
|
|
77
132
|
return {
|
|
78
133
|
type: 'streamable-http',
|
|
79
134
|
url: spec.url,
|
|
80
|
-
...(
|
|
135
|
+
...(expandedHeaders ? { headers: expandedHeaders } : {}),
|
|
81
136
|
};
|
|
82
137
|
}
|
|
83
138
|
return 'it declares neither a command nor a url';
|
|
@@ -136,9 +191,38 @@ export function eraProbeTimeoutFor(spec) {
|
|
|
136
191
|
}
|
|
137
192
|
return ms;
|
|
138
193
|
}
|
|
194
|
+
function toolsetOptionsFor(spec, name) {
|
|
195
|
+
for (const field of ['allow', 'deny']) {
|
|
196
|
+
const value = spec[field];
|
|
197
|
+
if (value !== undefined &&
|
|
198
|
+
(!Array.isArray(value) || !value.every((item) => typeof item === 'string' && item.length > 0))) {
|
|
199
|
+
return `${field} must be a list of nonempty server-reported names`;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (spec.maxRetries !== undefined &&
|
|
203
|
+
(!Number.isSafeInteger(spec.maxRetries) || spec.maxRetries < 0)) {
|
|
204
|
+
return `maxRetries must be a nonnegative integer, got ${JSON.stringify(spec.maxRetries)}`;
|
|
205
|
+
}
|
|
206
|
+
if (spec.requireApproval !== undefined && typeof spec.requireApproval !== 'boolean') {
|
|
207
|
+
return 'requireApproval must be true or false';
|
|
208
|
+
}
|
|
209
|
+
if (spec.readOnlyHintTrusted !== undefined && typeof spec.readOnlyHintTrusted !== 'boolean') {
|
|
210
|
+
return 'readOnlyHintTrusted must be true or false';
|
|
211
|
+
}
|
|
212
|
+
if (spec.instructions !== undefined && typeof spec.instructions !== 'boolean') {
|
|
213
|
+
return 'instructions must be true or false';
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
id: `mcp:${name}`,
|
|
217
|
+
allow: spec.allow,
|
|
218
|
+
deny: spec.deny,
|
|
219
|
+
maxRetries: spec.maxRetries,
|
|
220
|
+
readOnlyHintTrusted: spec.readOnlyHintTrusted,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
139
223
|
export async function connectMcpServers(config, options) {
|
|
140
224
|
const entries = Object.entries(config ?? {});
|
|
141
|
-
const
|
|
225
|
+
const toolsets = [];
|
|
142
226
|
const startupFailed = [];
|
|
143
227
|
const clients = [];
|
|
144
228
|
const liveServers = [];
|
|
@@ -147,6 +231,10 @@ export async function connectMcpServers(config, options) {
|
|
|
147
231
|
// of nothing and the failure output arrive interleaved, for a saving that
|
|
148
232
|
// matters only to someone running many servers, who has other problems.
|
|
149
233
|
for (const [name, spec] of entries) {
|
|
234
|
+
if (typeof spec !== 'object' || spec === null) {
|
|
235
|
+
startupFailed.push({ name, reason: 'server spec must be a mapping' });
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
150
238
|
const transport = transportFor(spec, options.cwd);
|
|
151
239
|
if (typeof transport === 'string') {
|
|
152
240
|
startupFailed.push({ name, reason: transport });
|
|
@@ -162,26 +250,41 @@ export async function connectMcpServers(config, options) {
|
|
|
162
250
|
startupFailed.push({ name, reason: eraProbeTimeoutMs });
|
|
163
251
|
continue;
|
|
164
252
|
}
|
|
253
|
+
const toolsetOptions = toolsetOptionsFor(spec, name);
|
|
254
|
+
if (typeof toolsetOptions === 'string') {
|
|
255
|
+
startupFailed.push({ name, reason: toolsetOptions });
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
165
258
|
const client = new MCPClient({
|
|
166
259
|
serverName: name,
|
|
167
260
|
transport,
|
|
168
261
|
...(eraProbeTimeoutMs !== undefined ? { eraProbeTimeoutMs } : {}),
|
|
169
262
|
});
|
|
263
|
+
const discovery = {
|
|
264
|
+
added: new Set(),
|
|
265
|
+
removed: new Set(),
|
|
266
|
+
changed: new Set(),
|
|
267
|
+
refused: new Map(),
|
|
268
|
+
};
|
|
170
269
|
try {
|
|
171
270
|
await withDeadline(client.connect(), deadline, `server "${name}"`);
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
};
|
|
184
|
-
|
|
271
|
+
const discovered = await withDeadline(mcpToolset(client, {
|
|
272
|
+
...toolsetOptions,
|
|
273
|
+
onDrift: ({ drift }) => {
|
|
274
|
+
for (const item of drift.added)
|
|
275
|
+
discovery.added.add(item);
|
|
276
|
+
for (const item of drift.removed)
|
|
277
|
+
discovery.removed.add(item);
|
|
278
|
+
for (const item of drift.changed)
|
|
279
|
+
discovery.changed.add(item);
|
|
280
|
+
},
|
|
281
|
+
onRefused: ({ kind, refused }) => discovery.refused.set(kind, refused),
|
|
282
|
+
}), deadline, `server "${name}" discovering its tools`);
|
|
283
|
+
const mounted = spec.requireApproval
|
|
284
|
+
? discovered.map((entry) => requireApproval(entry))
|
|
285
|
+
: [...discovered];
|
|
286
|
+
toolsets.push(...mounted);
|
|
287
|
+
liveServers.push({ client, name, toolsets: mounted, discovery });
|
|
185
288
|
clients.push(client);
|
|
186
289
|
}
|
|
187
290
|
catch (err) {
|
|
@@ -207,14 +310,28 @@ export async function connectMcpServers(config, options) {
|
|
|
207
310
|
const current = () => {
|
|
208
311
|
const connected = [];
|
|
209
312
|
const failed = [...startupFailed];
|
|
210
|
-
for (const { client,
|
|
313
|
+
for (const { client, name, toolsets: serverToolsets, discovery } of liveServers) {
|
|
211
314
|
const state = client.getState();
|
|
212
315
|
if (state.status === 'connected') {
|
|
213
|
-
|
|
316
|
+
const names = serverToolsets.flatMap((entry) => entry.tools().map((tool) => tool.name));
|
|
317
|
+
connected.push({
|
|
318
|
+
name,
|
|
319
|
+
toolCount: names.length,
|
|
320
|
+
tools: names,
|
|
321
|
+
drift: {
|
|
322
|
+
added: [...discovery.added],
|
|
323
|
+
removed: [...discovery.removed],
|
|
324
|
+
changed: [...discovery.changed],
|
|
325
|
+
},
|
|
326
|
+
refused: [...discovery.refused.entries()].flatMap(([kind, items]) => items.map((item) => ({ kind, ...item }))),
|
|
327
|
+
...(state.serverInstructions !== undefined
|
|
328
|
+
? { instructions: state.serverInstructions }
|
|
329
|
+
: {}),
|
|
330
|
+
});
|
|
214
331
|
continue;
|
|
215
332
|
}
|
|
216
333
|
failed.push({
|
|
217
|
-
name
|
|
334
|
+
name,
|
|
218
335
|
reason: state.error ??
|
|
219
336
|
(state.status === 'disconnected'
|
|
220
337
|
? 'connection closed after startup'
|
|
@@ -224,7 +341,10 @@ export async function connectMcpServers(config, options) {
|
|
|
224
341
|
return { connected, failed };
|
|
225
342
|
};
|
|
226
343
|
return {
|
|
227
|
-
tools
|
|
344
|
+
get tools() {
|
|
345
|
+
return toolsets.flatMap((entry) => entry.tools());
|
|
346
|
+
},
|
|
347
|
+
toolsets,
|
|
228
348
|
current,
|
|
229
349
|
get connected() {
|
|
230
350
|
return current().connected;
|
|
@@ -233,6 +353,7 @@ export async function connectMcpServers(config, options) {
|
|
|
233
353
|
return current().failed;
|
|
234
354
|
},
|
|
235
355
|
close: async () => {
|
|
356
|
+
await Promise.all(toolsets.map((entry) => entry.close?.()));
|
|
236
357
|
await Promise.all(clients.map((c) => withDeadline(c.disconnect(), CLOSE_TIMEOUT_MS, 'closing a tool server').catch(() => {
|
|
237
358
|
// Shutting down is best effort by definition: the process may
|
|
238
359
|
// already be gone, and nothing useful follows from saying so.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"servers.js","sourceRoot":"","sources":["../../../src/integrations/mcp/servers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EACN,SAAS,
|
|
1
|
+
{"version":3,"file":"servers.js","sourceRoot":"","sources":["../../../src/integrations/mcp/servers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EACN,SAAS,EAMT,UAAU,EACV,eAAe,GACf,MAAM,YAAY,CAAA;AAEnB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAExC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAA;AA4IrC;;;GAGG;AACH,MAAM,eAAe,GAAG,iCAAiC,CAAA;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,qBAAqB,CACpC,MAAwC,EACxC,GAAsB;IAEtB,MAAM,MAAM,GAA2B,EAAE,CAAA;IACzC,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACjD,IAAI,OAA2B,CAAA;QAC/B,M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} from '@namzu/sdk';
|
|
2
2
|
import type { HooksConfig, PluginConfig, PluginScope } from '../../config/schema.js';
|
|
3
3
|
export interface CliPluginRuntime {
|
|
4
4
|
readonly manager: PluginLifecycleManager;
|
|
@@ -30,18 +30,20 @@ export interface CliPluginInfo {
|
|
|
30
30
|
* The exact `enabled === true` check is the default-off boundary. Nothing in
|
|
31
31
|
* the plugin directories is discovered, read, or imported on every other
|
|
32
32
|
* value. Callers invoke this only after project trust has pinned `cwd`.
|
|
33
|
+
*
|
|
34
|
+
* No longer takes a tool registry to register into (plan.md v3 §7):
|
|
35
|
+
* `PluginLifecycleManager` exposes one live file source per plugin and one
|
|
36
|
+
* live MCP source per plugin server (`manager.toolsets`); a caller folds them into
|
|
37
|
+
* its own `toolsets` array. The `skill` tool itself is the CALLER's concern
|
|
38
|
+
* now too — this runtime only reports `skills.size` so the caller can decide
|
|
39
|
+
* live whether to offer it, rather than this module owning a "who registered
|
|
40
|
+
* it first" flag over a shared mutable registry.
|
|
33
41
|
*/
|
|
34
|
-
export declare function createCliPluginRuntime(config: PluginConfig | undefined,
|
|
42
|
+
export declare function createCliPluginRuntime(config: PluginConfig | undefined, cwd: string,
|
|
35
43
|
/**
|
|
36
44
|
* Operator shell hooks. They ride the same lifecycle manager plugins use,
|
|
37
45
|
* so a session with hooks and no plugins still builds one — with nothing
|
|
38
46
|
* installed, and `pluginCount` honestly 0.
|
|
39
47
|
*/
|
|
40
|
-
hooks?: HooksConfig
|
|
41
|
-
/**
|
|
42
|
-
* The `skill` tool to register when plugin skills arrive and the session
|
|
43
|
-
* has none yet: the session's own, so a plugin skill is told the same
|
|
44
|
-
* directory rules as a file skill. Defaults to the SDK's `SkillTool`.
|
|
45
|
-
*/
|
|
46
|
-
skillTool?: ToolDefinition): Promise<CliPluginRuntime | undefined>;
|
|
48
|
+
hooks?: HooksConfig): Promise<CliPluginRuntime | undefined>;
|
|
47
49
|
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/integrations/plugins/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,sBAAsB,EAEtB,aAAa,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/integrations/plugins/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,sBAAsB,EAEtB,aAAa,EAGb,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAKpF,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAA;IACxC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAA;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,IAAI,IAAI,SAAS,aAAa,EAAE,CAAA;IAChC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACzD,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACtB;AAED,kFAAkF;AAClF,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAA;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAA;IACjC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;IACjC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;IAClC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;IACvC,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;CACtC;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,sBAAsB,CAC3C,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,GAAG,EAAE,MAAM;AACX;;;;GAIG;AACH,KAAK,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAuJvC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PluginLifecycleManager, PluginRegistry, SkillRegistry,
|
|
1
|
+
import { PluginLifecycleManager, PluginRegistry, SkillRegistry, attachShellHooks, discoverAllPluginDirs, } from '@namzu/sdk';
|
|
2
2
|
import { cliLogger } from '../../logging.js';
|
|
3
3
|
import { resolveNamzuHome } from '../state/home.js';
|
|
4
4
|
import { PluginSettingsStore } from './settings.js';
|
|
@@ -11,20 +11,22 @@ function message(error) {
|
|
|
11
11
|
* The exact `enabled === true` check is the default-off boundary. Nothing in
|
|
12
12
|
* the plugin directories is discovered, read, or imported on every other
|
|
13
13
|
* value. Callers invoke this only after project trust has pinned `cwd`.
|
|
14
|
+
*
|
|
15
|
+
* No longer takes a tool registry to register into (plan.md v3 §7):
|
|
16
|
+
* `PluginLifecycleManager` exposes one live file source per plugin and one
|
|
17
|
+
* live MCP source per plugin server (`manager.toolsets`); a caller folds them into
|
|
18
|
+
* its own `toolsets` array. The `skill` tool itself is the CALLER's concern
|
|
19
|
+
* now too — this runtime only reports `skills.size` so the caller can decide
|
|
20
|
+
* live whether to offer it, rather than this module owning a "who registered
|
|
21
|
+
* it first" flag over a shared mutable registry.
|
|
14
22
|
*/
|
|
15
|
-
export async function createCliPluginRuntime(config,
|
|
23
|
+
export async function createCliPluginRuntime(config, cwd,
|
|
16
24
|
/**
|
|
17
25
|
* Operator shell hooks. They ride the same lifecycle manager plugins use,
|
|
18
26
|
* so a session with hooks and no plugins still builds one — with nothing
|
|
19
27
|
* installed, and `pluginCount` honestly 0.
|
|
20
28
|
*/
|
|
21
|
-
hooks
|
|
22
|
-
/**
|
|
23
|
-
* The `skill` tool to register when plugin skills arrive and the session
|
|
24
|
-
* has none yet: the session's own, so a plugin skill is told the same
|
|
25
|
-
* directory rules as a file skill. Defaults to the SDK's `SkillTool`.
|
|
26
|
-
*/
|
|
27
|
-
skillTool = SkillTool) {
|
|
29
|
+
hooks) {
|
|
28
30
|
const pluginsEnabled = config?.enabled === true;
|
|
29
31
|
const hookCount = hooks ? Object.values(hooks).reduce((n, list) => n + (list?.length ?? 0), 0) : 0;
|
|
30
32
|
if (!pluginsEnabled && hookCount === 0)
|
|
@@ -36,7 +38,6 @@ skillTool = SkillTool) {
|
|
|
36
38
|
const skills = new SkillRegistry(log);
|
|
37
39
|
const manager = new PluginLifecycleManager({
|
|
38
40
|
pluginRegistry: plugins,
|
|
39
|
-
toolRegistry: tools,
|
|
40
41
|
skillRegistry: skills,
|
|
41
42
|
scopeRoots: { project: cwd, user: userRoot },
|
|
42
43
|
log,
|
|
@@ -55,7 +56,6 @@ skillTool = SkillTool) {
|
|
|
55
56
|
})
|
|
56
57
|
: { project: [], user: [] };
|
|
57
58
|
const installed = [];
|
|
58
|
-
let ownsSkillTool = false;
|
|
59
59
|
try {
|
|
60
60
|
for (const scope of allowedScopes) {
|
|
61
61
|
const dirs = [...discovered[scope]].sort((a, b) => a.localeCompare(b));
|
|
@@ -67,14 +67,8 @@ skillTool = SkillTool) {
|
|
|
67
67
|
await manager.enable(plugin.id);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
if (skills.size > 0 && !tools.has(skillTool.name)) {
|
|
71
|
-
tools.register(skillTool);
|
|
72
|
-
ownsSkillTool = true;
|
|
73
|
-
}
|
|
74
70
|
}
|
|
75
71
|
catch (error) {
|
|
76
|
-
if (ownsSkillTool)
|
|
77
|
-
tools.unregister(skillTool.name);
|
|
78
72
|
const cleanupErrors = [];
|
|
79
73
|
for (const plugin of [...installed].reverse()) {
|
|
80
74
|
try {
|
|
@@ -94,16 +88,11 @@ skillTool = SkillTool) {
|
|
|
94
88
|
let closePromise;
|
|
95
89
|
let closed = false;
|
|
96
90
|
let mutation;
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
else if (skills.size === 0 && ownsSkillTool) {
|
|
103
|
-
tools.unregister(skillTool.name);
|
|
104
|
-
ownsSkillTool = false;
|
|
105
|
-
}
|
|
106
|
-
};
|
|
91
|
+
const contributedToolNames = (prefix) => manager.toolsets
|
|
92
|
+
.flatMap((ts) => ts.tools())
|
|
93
|
+
.map((tool) => tool.name)
|
|
94
|
+
.filter((name) => name.startsWith(prefix))
|
|
95
|
+
.sort();
|
|
107
96
|
return {
|
|
108
97
|
manager,
|
|
109
98
|
skills,
|
|
@@ -129,10 +118,7 @@ skillTool = SkillTool) {
|
|
|
129
118
|
status: plugin.status === 'installed' ? 'disabled' : plugin.status,
|
|
130
119
|
...(startupEnabled !== undefined ? { startupEnabled } : {}),
|
|
131
120
|
...(startupError ? { startupError } : {}),
|
|
132
|
-
tools:
|
|
133
|
-
.listNames()
|
|
134
|
-
.filter((name) => name.startsWith(prefix))
|
|
135
|
-
.sort(),
|
|
121
|
+
tools: contributedToolNames(prefix),
|
|
136
122
|
skills: skills
|
|
137
123
|
.list()
|
|
138
124
|
.map((skill) => skill.metadata.name)
|
|
@@ -159,7 +145,6 @@ skillTool = SkillTool) {
|
|
|
159
145
|
await mutation;
|
|
160
146
|
}
|
|
161
147
|
finally {
|
|
162
|
-
syncSkillTool();
|
|
163
148
|
mutation = undefined;
|
|
164
149
|
}
|
|
165
150
|
},
|
|
@@ -185,10 +170,6 @@ skillTool = SkillTool) {
|
|
|
185
170
|
if (mutation)
|
|
186
171
|
await mutation.catch(() => { });
|
|
187
172
|
const errors = [];
|
|
188
|
-
if (ownsSkillTool) {
|
|
189
|
-
tools.unregister(skillTool.name);
|
|
190
|
-
ownsSkillTool = false;
|
|
191
|
-
}
|
|
192
173
|
for (const plugin of [...installed].reverse()) {
|
|
193
174
|
try {
|
|
194
175
|
await manager.uninstall(plugin.id);
|