@namzu/cli 23.0.0 → 25.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 +845 -0
- package/README.md +13 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +18 -10
- package/dist/cli.js.map +1 -1
- package/dist/commands/drain.d.ts +0 -23
- package/dist/commands/drain.d.ts.map +1 -1
- package/dist/commands/drain.js +23 -9
- package/dist/commands/drain.js.map +1 -1
- package/dist/commands/resident-flags.d.ts +24 -0
- package/dist/commands/resident-flags.d.ts.map +1 -0
- package/dist/commands/resident-flags.js +191 -0
- package/dist/commands/resident-flags.js.map +1 -0
- package/dist/commands/resident-learning.d.ts +6 -0
- package/dist/commands/resident-learning.d.ts.map +1 -0
- package/dist/commands/resident-learning.js +293 -0
- package/dist/commands/resident-learning.js.map +1 -0
- package/dist/commands/resident.d.ts +20 -0
- package/dist/commands/resident.d.ts.map +1 -0
- package/dist/commands/resident.js +418 -0
- package/dist/commands/resident.js.map +1 -0
- package/dist/commands/run-flags.d.ts +2 -2
- package/dist/commands/run-flags.d.ts.map +1 -1
- package/dist/commands/run-flags.js +6 -6
- package/dist/commands/run-flags.js.map +1 -1
- package/dist/commands/run-stream.d.ts.map +1 -1
- package/dist/commands/run-stream.js +9 -10
- package/dist/commands/run-stream.js.map +1 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +3 -2
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/upgrade.d.ts +1 -0
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +6 -3
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +27 -4
- package/dist/config/load.js.map +1 -1
- package/dist/config/run-limits.d.ts +11 -0
- package/dist/config/run-limits.d.ts.map +1 -0
- package/dist/config/run-limits.js +64 -0
- package/dist/config/run-limits.js.map +1 -0
- package/dist/config/schema.d.ts +12 -4
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/context/runtime-message.d.ts.map +1 -1
- package/dist/context/runtime-message.js +2 -0
- package/dist/context/runtime-message.js.map +1 -1
- package/dist/integrations/npm-invocation.d.ts +10 -0
- package/dist/integrations/npm-invocation.d.ts.map +1 -0
- package/dist/integrations/npm-invocation.js +23 -0
- package/dist/integrations/npm-invocation.js.map +1 -0
- package/dist/integrations/plugins/runtime.d.ts +19 -1
- package/dist/integrations/plugins/runtime.d.ts.map +1 -1
- package/dist/integrations/plugins/runtime.js +89 -1
- package/dist/integrations/plugins/runtime.js.map +1 -1
- package/dist/integrations/plugins/settings.d.ts +15 -0
- package/dist/integrations/plugins/settings.d.ts.map +1 -0
- package/dist/integrations/plugins/settings.js +106 -0
- package/dist/integrations/plugins/settings.js.map +1 -0
- package/dist/integrations/providers/credential-store.d.ts +8 -7
- package/dist/integrations/providers/credential-store.d.ts.map +1 -1
- package/dist/integrations/providers/credential-store.js +44 -17
- package/dist/integrations/providers/credential-store.js.map +1 -1
- package/dist/integrations/providers/discover.d.ts.map +1 -1
- package/dist/integrations/providers/discover.js +7 -2
- package/dist/integrations/providers/discover.js.map +1 -1
- package/dist/integrations/providers/harness-credentials.d.ts +2 -2
- package/dist/integrations/providers/harness-credentials.d.ts.map +1 -1
- package/dist/integrations/providers/harness-credentials.js +13 -8
- package/dist/integrations/providers/harness-credentials.js.map +1 -1
- package/dist/integrations/providers/setup.d.ts.map +1 -1
- package/dist/integrations/providers/setup.js +52 -5
- package/dist/integrations/providers/setup.js.map +1 -1
- package/dist/integrations/resident/foreground.d.ts +19 -0
- package/dist/integrations/resident/foreground.d.ts.map +1 -0
- package/dist/integrations/resident/foreground.js +95 -0
- package/dist/integrations/resident/foreground.js.map +1 -0
- package/dist/integrations/resident/inspection.d.ts +10 -0
- package/dist/integrations/resident/inspection.d.ts.map +1 -0
- package/dist/integrations/resident/inspection.js +263 -0
- package/dist/integrations/resident/inspection.js.map +1 -0
- package/dist/integrations/resident/learning-sources.d.ts +4 -0
- package/dist/integrations/resident/learning-sources.d.ts.map +1 -0
- package/dist/integrations/resident/learning-sources.js +79 -0
- package/dist/integrations/resident/learning-sources.js.map +1 -0
- package/dist/integrations/resident/learning-storage.d.ts +5 -0
- package/dist/integrations/resident/learning-storage.d.ts.map +1 -0
- package/dist/integrations/resident/learning-storage.js +51 -0
- package/dist/integrations/resident/learning-storage.js.map +1 -0
- package/dist/integrations/resident/lifecycle-errors.d.ts +9 -0
- package/dist/integrations/resident/lifecycle-errors.d.ts.map +1 -0
- package/dist/integrations/resident/lifecycle-errors.js +15 -0
- package/dist/integrations/resident/lifecycle-errors.js.map +1 -0
- package/dist/integrations/resident/owned-runner.d.ts +17 -0
- package/dist/integrations/resident/owned-runner.d.ts.map +1 -0
- package/dist/integrations/resident/owned-runner.js +91 -0
- package/dist/integrations/resident/owned-runner.js.map +1 -0
- package/dist/integrations/resident/runner-control.d.ts +47 -0
- package/dist/integrations/resident/runner-control.d.ts.map +1 -0
- package/dist/integrations/resident/runner-control.js +238 -0
- package/dist/integrations/resident/runner-control.js.map +1 -0
- package/dist/integrations/resident/runner-launch.d.ts +52 -0
- package/dist/integrations/resident/runner-launch.d.ts.map +1 -0
- package/dist/integrations/resident/runner-launch.js +142 -0
- package/dist/integrations/resident/runner-launch.js.map +1 -0
- package/dist/integrations/resident/runner-store.d.ts +44 -0
- package/dist/integrations/resident/runner-store.d.ts.map +1 -0
- package/dist/integrations/resident/runner-store.js +281 -0
- package/dist/integrations/resident/runner-store.js.map +1 -0
- package/dist/integrations/resident/runner-worker.d.ts +2 -0
- package/dist/integrations/resident/runner-worker.d.ts.map +1 -0
- package/dist/integrations/resident/runner-worker.js +146 -0
- package/dist/integrations/resident/runner-worker.js.map +1 -0
- package/dist/integrations/resident/session-step.d.ts +29 -0
- package/dist/integrations/resident/session-step.d.ts.map +1 -0
- package/dist/integrations/resident/session-step.js +462 -0
- package/dist/integrations/resident/session-step.js.map +1 -0
- package/dist/integrations/resident/storage.d.ts +17 -0
- package/dist/integrations/resident/storage.d.ts.map +1 -0
- package/dist/integrations/resident/storage.js +140 -0
- package/dist/integrations/resident/storage.js.map +1 -0
- package/dist/integrations/resident/tool-evidence.d.ts +6 -0
- package/dist/integrations/resident/tool-evidence.d.ts.map +1 -0
- package/dist/integrations/resident/tool-evidence.js +117 -0
- package/dist/integrations/resident/tool-evidence.js.map +1 -0
- package/dist/integrations/resident/verification.d.ts +11 -0
- package/dist/integrations/resident/verification.d.ts.map +1 -0
- package/dist/integrations/resident/verification.js +109 -0
- package/dist/integrations/resident/verification.js.map +1 -0
- package/dist/integrations/sessions/compaction-evidence.d.ts +5 -0
- package/dist/integrations/sessions/compaction-evidence.d.ts.map +1 -0
- package/dist/integrations/sessions/compaction-evidence.js +59 -0
- package/dist/integrations/sessions/compaction-evidence.js.map +1 -0
- package/dist/integrations/sessions/context-inventory.js +1 -1
- package/dist/integrations/sessions/context-inventory.js.map +1 -1
- package/dist/integrations/sessions/conversation-search.d.ts +56 -8
- package/dist/integrations/sessions/conversation-search.d.ts.map +1 -1
- package/dist/integrations/sessions/conversation-search.js +600 -63
- package/dist/integrations/sessions/conversation-search.js.map +1 -1
- package/dist/integrations/sessions/database.d.ts +5 -0
- package/dist/integrations/sessions/database.d.ts.map +1 -0
- package/dist/integrations/sessions/database.js +34 -0
- package/dist/integrations/sessions/database.js.map +1 -0
- package/dist/integrations/sessions/evidence-page-validation.d.ts +8 -0
- package/dist/integrations/sessions/evidence-page-validation.d.ts.map +1 -0
- package/dist/integrations/sessions/evidence-page-validation.js +74 -0
- package/dist/integrations/sessions/evidence-page-validation.js.map +1 -0
- package/dist/integrations/sessions/evidence-recall.d.ts +5 -0
- package/dist/integrations/sessions/evidence-recall.d.ts.map +1 -0
- package/dist/integrations/sessions/evidence-recall.js +173 -0
- package/dist/integrations/sessions/evidence-recall.js.map +1 -0
- package/dist/integrations/sessions/paths.d.ts +7 -0
- package/dist/integrations/sessions/paths.d.ts.map +1 -0
- package/dist/integrations/sessions/paths.js +14 -0
- package/dist/integrations/sessions/paths.js.map +1 -0
- package/dist/integrations/sessions/run-discovery.d.ts +24 -0
- package/dist/integrations/sessions/run-discovery.d.ts.map +1 -0
- package/dist/integrations/sessions/run-discovery.js +142 -0
- package/dist/integrations/sessions/run-discovery.js.map +1 -0
- package/dist/integrations/sessions/store.d.ts +8 -18
- package/dist/integrations/sessions/store.d.ts.map +1 -1
- package/dist/integrations/sessions/store.js +14 -39
- package/dist/integrations/sessions/store.js.map +1 -1
- package/dist/integrations/sessions/transcript-export.d.ts +0 -1
- package/dist/integrations/sessions/transcript-export.d.ts.map +1 -1
- package/dist/integrations/sessions/transcript-export.js +3 -2
- package/dist/integrations/sessions/transcript-export.js.map +1 -1
- package/dist/integrations/sessions/turn-evidence.d.ts +0 -9
- package/dist/integrations/sessions/turn-evidence.d.ts.map +1 -1
- package/dist/integrations/sessions/turn-evidence.js +5 -2
- package/dist/integrations/sessions/turn-evidence.js.map +1 -1
- package/dist/integrations/state/private-directory.d.ts +4 -2
- package/dist/integrations/state/private-directory.d.ts.map +1 -1
- package/dist/integrations/state/private-directory.js +6 -4
- package/dist/integrations/state/private-directory.js.map +1 -1
- package/dist/integrations/state/report.d.ts.map +1 -1
- package/dist/integrations/state/report.js +78 -21
- package/dist/integrations/state/report.js.map +1 -1
- package/dist/integrations/subagents/parent.d.ts +3 -2
- package/dist/integrations/subagents/parent.d.ts.map +1 -1
- package/dist/integrations/subagents/parent.js +11 -6
- package/dist/integrations/subagents/parent.js.map +1 -1
- package/dist/integrations/subagents/policy.d.ts +2 -5
- package/dist/integrations/subagents/policy.d.ts.map +1 -1
- package/dist/integrations/subagents/policy.js +2 -5
- package/dist/integrations/subagents/policy.js.map +1 -1
- package/dist/integrations/subagents/runtime.d.ts +7 -0
- package/dist/integrations/subagents/runtime.d.ts.map +1 -1
- package/dist/integrations/subagents/runtime.js +9 -7
- package/dist/integrations/subagents/runtime.js.map +1 -1
- package/dist/permissions/rules.d.ts +2 -8
- package/dist/permissions/rules.d.ts.map +1 -1
- package/dist/permissions/rules.js +19 -10
- package/dist/permissions/rules.js.map +1 -1
- package/dist/tui/App.d.ts +0 -12
- package/dist/tui/App.d.ts.map +1 -1
- package/dist/tui/App.js +235 -15
- package/dist/tui/App.js.map +1 -1
- package/dist/tui/ChoicePicker.d.ts +2 -1
- package/dist/tui/ChoicePicker.d.ts.map +1 -1
- package/dist/tui/ChoicePicker.js +10 -8
- package/dist/tui/ChoicePicker.js.map +1 -1
- package/dist/tui/ToolOutputViewer.js +1 -1
- package/dist/tui/ToolOutputViewer.js.map +1 -1
- package/dist/tui/agent.d.ts +29 -3
- package/dist/tui/agent.d.ts.map +1 -1
- package/dist/tui/agent.js +233 -46
- package/dist/tui/agent.js.map +1 -1
- package/dist/tui/conversation-evidence-view.d.ts +6 -0
- package/dist/tui/conversation-evidence-view.d.ts.map +1 -0
- package/dist/tui/conversation-evidence-view.js +96 -0
- package/dist/tui/conversation-evidence-view.js.map +1 -0
- package/dist/tui/conversation-history.d.ts +3 -1
- package/dist/tui/conversation-history.d.ts.map +1 -1
- package/dist/tui/conversation-history.js +16 -1
- package/dist/tui/conversation-history.js.map +1 -1
- package/dist/tui/exit-summary.d.ts +1 -1
- package/dist/tui/exit-summary.d.ts.map +1 -1
- package/dist/tui/exit-summary.js +17 -5
- package/dist/tui/exit-summary.js.map +1 -1
- package/dist/tui/markdownParser.d.ts.map +1 -1
- package/dist/tui/markdownParser.js +2 -1
- package/dist/tui/markdownParser.js.map +1 -1
- package/dist/tui/plugin-view.d.ts +9 -0
- package/dist/tui/plugin-view.d.ts.map +1 -0
- package/dist/tui/plugin-view.js +59 -0
- package/dist/tui/plugin-view.js.map +1 -0
- package/dist/tui/run-interruption.d.ts +2 -2
- package/dist/tui/run-interruption.d.ts.map +1 -1
- package/dist/tui/run-interruption.js +5 -1
- package/dist/tui/run-interruption.js.map +1 -1
- package/dist/tui/run-limits-settings.d.ts +39 -0
- package/dist/tui/run-limits-settings.d.ts.map +1 -0
- package/dist/tui/run-limits-settings.js +88 -0
- package/dist/tui/run-limits-settings.js.map +1 -0
- package/dist/tui/slashCommands.d.ts +6 -1
- package/dist/tui/slashCommands.d.ts.map +1 -1
- package/dist/tui/slashCommands.js +40 -9
- package/dist/tui/slashCommands.js.map +1 -1
- package/dist/tui/types.d.ts +4 -2
- package/dist/tui/types.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/config/schema.d.ts
CHANGED
|
@@ -48,10 +48,12 @@ export type HookEntry = ShellHookEntry;
|
|
|
48
48
|
export type HooksConfig = ShellHooksConfig;
|
|
49
49
|
/** See `NamzuCliConfig.limits`. */
|
|
50
50
|
export interface RunLimitsConfig {
|
|
51
|
-
/**
|
|
51
|
+
/** Main-loop iterations one run may make. Omitted or 0 means unlimited. */
|
|
52
52
|
readonly maxIterations?: number;
|
|
53
|
-
/** Aggregate prompt and completion tokens for the run and descendants. Omitted means unlimited. */
|
|
53
|
+
/** Aggregate prompt and completion tokens for the run and descendants. Omitted or 0 means unlimited. */
|
|
54
54
|
readonly tokenBudget?: number;
|
|
55
|
+
/** Total run duration in milliseconds. Omitted or 0 means unlimited. */
|
|
56
|
+
readonly timeoutMs?: number;
|
|
55
57
|
/**
|
|
56
58
|
* Milliseconds a headless run may spend waiting out provider pauses — a
|
|
57
59
|
* rate limit, an outage — resuming from its checkpoint after each, before
|
|
@@ -61,6 +63,12 @@ export interface RunLimitsConfig {
|
|
|
61
63
|
}
|
|
62
64
|
/** See `NamzuCliConfig.compaction`. */
|
|
63
65
|
export interface CompactionCliConfig {
|
|
66
|
+
/** Bounded historical evidence recall in recorded conversations. Default true; false disables it. */
|
|
67
|
+
readonly recallEvidence?: boolean;
|
|
68
|
+
/** Resolve follow-up search references with a metered model call when recall is enabled. Default true. */
|
|
69
|
+
readonly resolveEvidenceQueries?: boolean;
|
|
70
|
+
/** Retained overflow preview in recorded conversations; default 4,000 chars. 0 keeps the ordinary 40,000-char budget. */
|
|
71
|
+
readonly retainedToolPreviewChars?: number;
|
|
64
72
|
/** Mask exact repeated read-only observations in model requests; enabled unless false. */
|
|
65
73
|
readonly deduplicateObservations?: boolean;
|
|
66
74
|
/**
|
|
@@ -170,8 +178,8 @@ export interface NamzuCliConfig {
|
|
|
170
178
|
/**
|
|
171
179
|
* How far one run may go before the kernel stops it. Headless `run` and
|
|
172
180
|
* `run-stream` read these; `--max-iterations` and `--token-budget` override
|
|
173
|
-
* them for one run. Absent means
|
|
174
|
-
*
|
|
181
|
+
* them for one run. Absent means unlimited tokens, iterations and run duration.
|
|
182
|
+
* Explicit token budgets cover descendants.
|
|
175
183
|
*/
|
|
176
184
|
readonly limits?: RunLimitsConfig;
|
|
177
185
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,SAAS,CAAC,CAAA;AAExE,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAA;AAEpE,iEAAiE;AACjE,MAAM,MAAM,yBAAyB,GAAG,cAAc,GAAG,mBAAmB,CAAA;AAE5E,kEAAkE;AAClE,MAAM,MAAM,0BAA0B,GAAG,MAAM,GAAG,KAAK,CAAA;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AAC,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC,EAAE,CAAA;IAC7E;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,mBAAmB,GAAG,WAAW,CAAA;IACtD;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CACnC;AAED,eAAO,MAAM,cAAc,EAAE,cAG3B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA8UH,MAAM,CAAC,MAAM,cAAc,GAAmB,MAAM,CAAC,MAAM,CAAC;IAC3D,MAAM,EAAE,MAAM;IACd,KAAK,EAAE,KAAK;CACZ,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-message.d.ts","sourceRoot":"","sources":["../../src/context/runtime-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAE3D,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,yBAAyB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"runtime-message.d.ts","sourceRoot":"","sources":["../../src/context/runtime-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAE3D,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,yBAAyB,GAAG,MAAM,CAmB3E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-message.js","sourceRoot":"","sources":["../../src/context/runtime-message.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,MAAM,UAAU,mBAAmB,CAAC,IAA+B;IAClE,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,UAAU;YACd,OAAO,iBAAiB,CAAA;QACzB,KAAK,eAAe;YACnB,OAAO,wBAAwB,CAAA;QAChC,KAAK,mBAAmB;YACvB,OAAO,wBAAwB,CAAA;QAChC,KAAK,oBAAoB;YACxB,OAAO,4BAA4B,CAAA;QACpC,KAAK,UAAU;YACd,OAAO,kBAAkB,CAAA;QAC1B,KAAK,mBAAmB;YACvB,OAAO,yBAAyB,CAAA;QACjC,KAAK,iBAAiB;YACrB,OAAO,yBAAyB,CAAA;IAClC,CAAC;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"runtime-message.js","sourceRoot":"","sources":["../../src/context/runtime-message.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,MAAM,UAAU,mBAAmB,CAAC,IAA+B;IAClE,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,cAAc;YAClB,OAAO,cAAc,CAAA;QACtB,KAAK,UAAU;YACd,OAAO,iBAAiB,CAAA;QACzB,KAAK,eAAe;YACnB,OAAO,wBAAwB,CAAA;QAChC,KAAK,mBAAmB;YACvB,OAAO,wBAAwB,CAAA;QAChC,KAAK,oBAAoB;YACxB,OAAO,4BAA4B,CAAA;QACpC,KAAK,UAAU;YACd,OAAO,kBAAkB,CAAA;QAC1B,KAAK,mBAAmB;YACvB,OAAO,yBAAyB,CAAA;QACjC,KAAK,iBAAiB;YACrB,OAAO,yBAAyB,CAAA;IAClC,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native Windows cannot execute npm.cmd with shell:false. Use the npm CLI
|
|
3
|
+
* bundled with the Node runtime running Namzu, keeping every argument literal.
|
|
4
|
+
* Custom PATH wrappers are not interpreted or silently selected in its place.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveNpmInvocation(executable: string, args: readonly string[], platform?: NodeJS.Platform, nodeExecutable?: string): {
|
|
7
|
+
readonly executable: string;
|
|
8
|
+
readonly args: readonly string[];
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=npm-invocation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm-invocation.d.ts","sourceRoot":"","sources":["../../src/integrations/npm-invocation.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,QAAQ,GAAE,MAAM,CAAC,QAA2B,EAC5C,cAAc,GAAE,MAAyB,GACvC;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAenE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { statSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Native Windows cannot execute npm.cmd with shell:false. Use the npm CLI
|
|
5
|
+
* bundled with the Node runtime running Namzu, keeping every argument literal.
|
|
6
|
+
* Custom PATH wrappers are not interpreted or silently selected in its place.
|
|
7
|
+
*/
|
|
8
|
+
export function resolveNpmInvocation(executable, args, platform = process.platform, nodeExecutable = process.execPath) {
|
|
9
|
+
if (platform !== 'win32' || (executable !== 'npm' && executable !== 'npm.cmd')) {
|
|
10
|
+
return { executable, args };
|
|
11
|
+
}
|
|
12
|
+
const npmCli = join(dirname(nodeExecutable), 'node_modules', 'npm', 'bin', 'npm-cli.js');
|
|
13
|
+
try {
|
|
14
|
+
if (statSync(npmCli).isFile()) {
|
|
15
|
+
return { executable: nodeExecutable, args: [npmCli, ...args] };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
// Give the same actionable refusal for absent or unreadable bundles.
|
|
20
|
+
}
|
|
21
|
+
throw new Error(`npm's JavaScript entry point is unavailable at ${npmCli}. Namzu uses the npm bundled with its Node runtime on Windows. Repair that Node installation or run npm manually; custom PATH wrappers are not used.`);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=npm-invocation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm-invocation.js","sourceRoot":"","sources":["../../src/integrations/npm-invocation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEzC;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CACnC,UAAkB,EAClB,IAAuB,EACvB,WAA4B,OAAO,CAAC,QAAQ,EAC5C,iBAAyB,OAAO,CAAC,QAAQ;IAEzC,IAAI,QAAQ,KAAK,OAAO,IAAI,CAAC,UAAU,KAAK,KAAK,IAAI,UAAU,KAAK,SAAS,CAAC,EAAE,CAAC;QAChF,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAA;IAC5B,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,CAAA;IACxF,IAAI,CAAC;QACJ,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;YAC/B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAA;QAC/D,CAAC;IACF,CAAC;IAAC,MAAM,CAAC;QACR,qEAAqE;IACtE,CAAC;IACD,MAAM,IAAI,KAAK,CACd,kDAAkD,MAAM,sJAAsJ,CAC9M,CAAA;AACF,CAAC"}
|
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
import { PluginLifecycleManager, SkillRegistry, type ToolRegistry } from '@namzu/sdk';
|
|
2
|
-
import type { HooksConfig, PluginConfig } from '../../config/schema.js';
|
|
2
|
+
import type { HooksConfig, PluginConfig, PluginScope } from '../../config/schema.js';
|
|
3
3
|
export interface CliPluginRuntime {
|
|
4
4
|
readonly manager: PluginLifecycleManager;
|
|
5
5
|
readonly skills: SkillRegistry;
|
|
6
6
|
readonly pluginCount: number;
|
|
7
|
+
list(): readonly CliPluginInfo[];
|
|
8
|
+
setEnabled(name: string, enabled: boolean): Promise<void>;
|
|
9
|
+
rememberState(name: string): Promise<void>;
|
|
7
10
|
close(): Promise<void>;
|
|
8
11
|
}
|
|
12
|
+
/** Public operator metadata only; never expose MCP environment or hook bodies. */
|
|
13
|
+
export interface CliPluginInfo {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly version: string;
|
|
16
|
+
readonly description: string;
|
|
17
|
+
readonly scope: PluginScope;
|
|
18
|
+
readonly rootDir: string;
|
|
19
|
+
readonly status: string;
|
|
20
|
+
readonly startupEnabled?: boolean;
|
|
21
|
+
readonly startupError?: string;
|
|
22
|
+
readonly tools: readonly string[];
|
|
23
|
+
readonly skills: readonly string[];
|
|
24
|
+
readonly hookModules: readonly string[];
|
|
25
|
+
readonly mcpServers: readonly string[];
|
|
26
|
+
}
|
|
9
27
|
/**
|
|
10
28
|
* Build the executable extension runtime owned by one agent session.
|
|
11
29
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/integrations/plugins/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,sBAAsB,EAEtB,aAAa,EAEb,KAAK,YAAY,EAGjB,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/integrations/plugins/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,sBAAsB,EAEtB,aAAa,EAEb,KAAK,YAAY,EAGjB,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,wB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AAW,GACjB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAyKvC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PluginLifecycleManager, PluginRegistry, SkillRegistry, SkillTool, attachShellHooks, discoverAllPluginDirs, } from '@namzu/sdk';
|
|
2
2
|
import { cliLogger } from '../../logging.js';
|
|
3
3
|
import { resolveNamzuHome } from '../state/home.js';
|
|
4
|
+
import { PluginSettingsStore } from './settings.js';
|
|
4
5
|
function message(error) {
|
|
5
6
|
return error instanceof Error ? error.message : String(error);
|
|
6
7
|
}
|
|
@@ -24,6 +25,7 @@ hooks) {
|
|
|
24
25
|
return undefined;
|
|
25
26
|
const log = cliLogger();
|
|
26
27
|
const userRoot = resolveNamzuHome();
|
|
28
|
+
const settings = new PluginSettingsStore(userRoot);
|
|
27
29
|
const plugins = new PluginRegistry();
|
|
28
30
|
const skills = new SkillRegistry(log);
|
|
29
31
|
const manager = new PluginLifecycleManager({
|
|
@@ -54,7 +56,9 @@ hooks) {
|
|
|
54
56
|
for (const dir of dirs) {
|
|
55
57
|
const plugin = await manager.install(dir, scope);
|
|
56
58
|
installed.push(plugin);
|
|
57
|
-
|
|
59
|
+
const enabled = settings.read({ rootDir: plugin.rootDir, name: plugin.manifest.name });
|
|
60
|
+
if (enabled)
|
|
61
|
+
await manager.enable(plugin.id);
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
if (skills.size > 0 && !tools.has(SkillTool.name)) {
|
|
@@ -82,14 +86,98 @@ hooks) {
|
|
|
82
86
|
});
|
|
83
87
|
}
|
|
84
88
|
let closePromise;
|
|
89
|
+
let closed = false;
|
|
90
|
+
let mutation;
|
|
91
|
+
const syncSkillTool = () => {
|
|
92
|
+
if (skills.size > 0 && !tools.has(SkillTool.name)) {
|
|
93
|
+
tools.register(SkillTool);
|
|
94
|
+
ownsSkillTool = true;
|
|
95
|
+
}
|
|
96
|
+
else if (skills.size === 0 && ownsSkillTool) {
|
|
97
|
+
tools.unregister(SkillTool.name);
|
|
98
|
+
ownsSkillTool = false;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
85
101
|
return {
|
|
86
102
|
manager,
|
|
87
103
|
skills,
|
|
88
104
|
pluginCount: installed.length,
|
|
105
|
+
list: () => plugins
|
|
106
|
+
.getAll()
|
|
107
|
+
.map((plugin) => {
|
|
108
|
+
const prefix = `${plugin.manifest.name}__`;
|
|
109
|
+
let startupEnabled;
|
|
110
|
+
let startupError;
|
|
111
|
+
try {
|
|
112
|
+
startupEnabled = settings.read({ rootDir: plugin.rootDir, name: plugin.manifest.name });
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
startupError = message(error);
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
name: plugin.manifest.name,
|
|
119
|
+
version: plugin.manifest.version,
|
|
120
|
+
description: plugin.manifest.description,
|
|
121
|
+
scope: plugin.scope,
|
|
122
|
+
rootDir: plugin.rootDir,
|
|
123
|
+
status: plugin.status === 'installed' ? 'disabled' : plugin.status,
|
|
124
|
+
...(startupEnabled !== undefined ? { startupEnabled } : {}),
|
|
125
|
+
...(startupError ? { startupError } : {}),
|
|
126
|
+
tools: tools
|
|
127
|
+
.listNames()
|
|
128
|
+
.filter((name) => name.startsWith(prefix))
|
|
129
|
+
.sort(),
|
|
130
|
+
skills: skills
|
|
131
|
+
.list()
|
|
132
|
+
.map((skill) => skill.metadata.name)
|
|
133
|
+
.filter((name) => name.startsWith(prefix))
|
|
134
|
+
.sort(),
|
|
135
|
+
hookModules: [...(plugin.manifest.hooks ?? [])],
|
|
136
|
+
mcpServers: (plugin.manifest.mcpServers ?? []).map((server) => server.name),
|
|
137
|
+
};
|
|
138
|
+
})
|
|
139
|
+
.sort((a, b) => a.name.localeCompare(b.name)),
|
|
140
|
+
async setEnabled(name, enabled) {
|
|
141
|
+
if (closed)
|
|
142
|
+
throw new Error('Plugin runtime is closed.');
|
|
143
|
+
if (mutation)
|
|
144
|
+
throw new Error('Another plugin change is in progress.');
|
|
145
|
+
const plugin = plugins.findByName(name);
|
|
146
|
+
if (!plugin)
|
|
147
|
+
throw new Error(`Plugin "${name}" is not loaded in this session.`);
|
|
148
|
+
if ((enabled && plugin.status === 'enabled') ||
|
|
149
|
+
(!enabled && (plugin.status === 'disabled' || plugin.status === 'installed')))
|
|
150
|
+
return;
|
|
151
|
+
mutation = enabled ? manager.enable(plugin.id) : manager.disable(plugin.id);
|
|
152
|
+
try {
|
|
153
|
+
await mutation;
|
|
154
|
+
}
|
|
155
|
+
finally {
|
|
156
|
+
syncSkillTool();
|
|
157
|
+
mutation = undefined;
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
async rememberState(name) {
|
|
161
|
+
if (closed)
|
|
162
|
+
throw new Error('Plugin runtime is closed.');
|
|
163
|
+
if (mutation)
|
|
164
|
+
throw new Error('Another plugin change is in progress.');
|
|
165
|
+
const plugin = plugins.findByName(name);
|
|
166
|
+
if (!plugin)
|
|
167
|
+
throw new Error(`Plugin "${name}" is not loaded in this session.`);
|
|
168
|
+
if (!['enabled', 'disabled', 'installed'].includes(plugin.status)) {
|
|
169
|
+
throw new Error('Resolve the plugin error before remembering its state.');
|
|
170
|
+
}
|
|
171
|
+
const enabled = plugin.status === 'enabled';
|
|
172
|
+
settings.write({ rootDir: plugin.rootDir, name }, enabled);
|
|
173
|
+
},
|
|
89
174
|
close() {
|
|
90
175
|
if (closePromise)
|
|
91
176
|
return closePromise;
|
|
177
|
+
closed = true;
|
|
92
178
|
closePromise = (async () => {
|
|
179
|
+
if (mutation)
|
|
180
|
+
await mutation.catch(() => { });
|
|
93
181
|
const errors = [];
|
|
94
182
|
if (ownsSkillTool) {
|
|
95
183
|
tools.unregister(SkillTool.name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/integrations/plugins/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,sBAAsB,EACtB,cAAc,EACd,aAAa,EACb,SA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AK,CAAC,CAAA;oBACnB,CAAC;gBACF,CAAC;gBACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACvB,MAAM,IAAI,cAAc,CAAC,MAAM,EAAE,+CAA+C,CAAC,CAAA;gBAClF,CAAC;YACF,CAAC,CAAC,EAAE,CAAA;YACJ,OAAO,YAAY,CAAA;QACpB,CAAC;KACD,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface PluginLocation {
|
|
2
|
+
readonly rootDir: string;
|
|
3
|
+
readonly name: string;
|
|
4
|
+
}
|
|
5
|
+
/** One atomic setting per admitted physical plugin, independent of other projects. */
|
|
6
|
+
export declare class PluginSettingsStore {
|
|
7
|
+
private readonly home;
|
|
8
|
+
readonly directory: string;
|
|
9
|
+
constructor(home: string);
|
|
10
|
+
private path;
|
|
11
|
+
read(plugin: PluginLocation): boolean;
|
|
12
|
+
write(plugin: PluginLocation, enabled: boolean): void;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../../src/integrations/plugins/settings.ts"],"names":[],"mappings":"AAkBA,UAAU,cAAc;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACrB;AAID,sFAAsF;AACtF,qBAAa,mBAAmB;IAGnB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;gBAEG,IAAI,EAAE,MAAM;IAIzC,OAAO,CAAC,IAAI;IASZ,IAAI,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO;IAiDrC,KAAK,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;CA6BrD"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { constants, closeSync, fstatSync, fsyncSync, lstatSync, openSync, readSync, renameSync, unlinkSync, writeFileSync, } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { restrictToOwner } from '../providers/credential-store.js';
|
|
5
|
+
import { ensurePrivateStateDirectory } from '../state/private-directory.js';
|
|
6
|
+
const MAX_RECORD_BYTES = 64 * 1024;
|
|
7
|
+
/** One atomic setting per admitted physical plugin, independent of other projects. */
|
|
8
|
+
export class PluginSettingsStore {
|
|
9
|
+
home;
|
|
10
|
+
directory;
|
|
11
|
+
constructor(home) {
|
|
12
|
+
this.home = home;
|
|
13
|
+
this.directory = join(home, 'plugin-settings');
|
|
14
|
+
}
|
|
15
|
+
path(plugin) {
|
|
16
|
+
// The lifecycle manager supplies a canonical root. Names alone would make
|
|
17
|
+
// disabling a project plugin disable unrelated plugins in other projects.
|
|
18
|
+
const key = createHash('sha256')
|
|
19
|
+
.update(JSON.stringify([plugin.rootDir, plugin.name]))
|
|
20
|
+
.digest('hex');
|
|
21
|
+
return join(this.directory, `${key}.json`);
|
|
22
|
+
}
|
|
23
|
+
read(plugin) {
|
|
24
|
+
const path = this.path(plugin);
|
|
25
|
+
try {
|
|
26
|
+
try {
|
|
27
|
+
const directory = lstatSync(this.directory);
|
|
28
|
+
if (!directory.isDirectory() || directory.isSymbolicLink()) {
|
|
29
|
+
throw new Error('settings directory must be a real directory');
|
|
30
|
+
}
|
|
31
|
+
const entry = lstatSync(path);
|
|
32
|
+
if (!entry.isFile() || entry.isSymbolicLink()) {
|
|
33
|
+
throw new Error('setting must be a regular file');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (error.code === 'ENOENT')
|
|
38
|
+
return true;
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
const fd = openSync(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
|
|
42
|
+
let raw;
|
|
43
|
+
try {
|
|
44
|
+
if (!fstatSync(fd).isFile())
|
|
45
|
+
throw new Error('setting must be a regular file');
|
|
46
|
+
const buffer = Buffer.alloc(MAX_RECORD_BYTES + 1);
|
|
47
|
+
let size = 0;
|
|
48
|
+
while (size < buffer.length) {
|
|
49
|
+
const bytes = readSync(fd, buffer, size, buffer.length - size, null);
|
|
50
|
+
if (bytes === 0)
|
|
51
|
+
break;
|
|
52
|
+
size += bytes;
|
|
53
|
+
}
|
|
54
|
+
if (size > MAX_RECORD_BYTES)
|
|
55
|
+
throw new Error('setting exceeds 64 KiB');
|
|
56
|
+
raw = buffer.toString('utf8', 0, size);
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
closeSync(fd);
|
|
60
|
+
}
|
|
61
|
+
const value = JSON.parse(raw);
|
|
62
|
+
if (!value ||
|
|
63
|
+
value.version !== 1 ||
|
|
64
|
+
value.rootDir !== plugin.rootDir ||
|
|
65
|
+
value.name !== plugin.name ||
|
|
66
|
+
typeof value.enabled !== 'boolean') {
|
|
67
|
+
throw new Error('setting has an invalid version, plugin identity or enabled value');
|
|
68
|
+
}
|
|
69
|
+
return value.enabled;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
// Corruption must not quietly turn a disabled executable plugin on.
|
|
73
|
+
throw new Error(`Could not read plugin setting ${path}: ${String(error)}`, { cause: error });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
write(plugin, enabled) {
|
|
77
|
+
ensurePrivateStateDirectory(this.home, 'plugin-settings');
|
|
78
|
+
this.read(plugin);
|
|
79
|
+
const path = this.path(plugin);
|
|
80
|
+
const temporary = `${path}.tmp.${randomUUID()}`;
|
|
81
|
+
const fd = openSync(temporary, 'wx', 0o600);
|
|
82
|
+
try {
|
|
83
|
+
try {
|
|
84
|
+
writeFileSync(fd, `${JSON.stringify({ version: 1, rootDir: plugin.rootDir, name: plugin.name, enabled }, null, 2)}\n`);
|
|
85
|
+
fsyncSync(fd);
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
closeSync(fd);
|
|
89
|
+
}
|
|
90
|
+
restrictToOwner(temporary);
|
|
91
|
+
// Separate plugins never overwrite each other's settings. For this
|
|
92
|
+
// plugin the last complete replacement wins, without a stale RMW merge.
|
|
93
|
+
renameSync(temporary, path);
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
try {
|
|
97
|
+
unlinkSync(temporary);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
// Cleanup must not mask a write error or turn a committed rename
|
|
101
|
+
// into a reported failure. Temporary names are never read as settings.
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../src/integrations/plugins/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EACN,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,UAAU,EACV,aAAa,GACb,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAA;AAO3E,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,CAAA;AAElC,sFAAsF;AACtF,MAAM,OAAO,mBAAmB;IAGF;IAFpB,SAAS,CAAQ;IAE1B,YAA6B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;QACxC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAA;IAC/C,CAAC;IAEO,IAAI,CAAC,MAAsB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,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;QAC7F,CAAC;IACF,CAAC;IAED,KAAK,CAAC,MAAsB,EAAE,OAAgB;QAC7C,2BAA2B,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAA;QACzD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACjB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC9B,MAAM,SAAS,GAAG,GAAG,IAAI,QAAQ,UAAU,EAAE,EAAE,CAAA;QAC/C,MAAM,EAAE,GAAG,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;QAC3C,IAAI,CAAC;YACJ,IAAI,CAAC;gBACJ,aAAa,CACZ,EAAE,EACF,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CACnG,CAAA;gBACD,SAAS,CAAC,EAAE,CAAC,CAAA;YACd,CAAC;oBAAS,CAAC;gBACV,SAAS,CAAC,EAAE,CAAC,CAAA;YACd,CAAC;YACD,eAAe,CAAC,SAAS,CAAC,CAAA;YAC1B,mEAAmE;YACnE,wEAAwE;YACxE,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;QAC5B,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC;gBACJ,UAAU,CAAC,SAAS,CAAC,CAAA;YACtB,CAAC;YAAC,MAAM,CAAC;gBACR,iEAAiE;gBACjE,uEAAuE;YACxE,CAAC;QACF,CAAC;IACF,CAAC;CACD"}
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
* - Windows: POSIX modes do not exist — `fs.chmod` there only toggles the
|
|
29
29
|
* read-only attribute, so a `0600` that "succeeded" would prove nothing.
|
|
30
30
|
* The equivalent is a discretionary ACL, so inheritance is removed and a
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* full-control entry is granted to the current user's SID; the ACL is then
|
|
32
|
+
* saved back as SDDL and checked for access by that user. An existing
|
|
33
|
+
* LocalSystem grant is permitted; grants to other accounts are refused.
|
|
34
34
|
*
|
|
35
35
|
* ## What is in the file
|
|
36
36
|
*
|
|
@@ -107,8 +107,9 @@ export declare function clearStoredCodexCredential(home?: string): void;
|
|
|
107
107
|
/** Remove every credential Namzu owns in one store mutation. */
|
|
108
108
|
export declare function clearAllStoredCredentials(home?: string): void;
|
|
109
109
|
/**
|
|
110
|
-
* Make `path`
|
|
111
|
-
*
|
|
110
|
+
* Make `path` private to the current account, and PROVE it. Windows may retain
|
|
111
|
+
* access for the operating system's LocalSystem account. Throws
|
|
112
|
+
* `CredentialStoreError` when the proof cannot be produced.
|
|
112
113
|
*
|
|
113
114
|
* Exported because it is the load-bearing half of this module and a security
|
|
114
115
|
* property nobody can check by reading the caller.
|
|
@@ -141,8 +142,8 @@ export declare function readAclSddl(path: string): string | null;
|
|
|
141
142
|
/** The current account's security identifier, or `null` off Windows / on failure. */
|
|
142
143
|
export declare function currentUserSid(): string | null;
|
|
143
144
|
/**
|
|
144
|
-
* Require
|
|
145
|
-
* principal
|
|
145
|
+
* Require a protected SDDL discretionary ACL that grants the current account
|
|
146
|
+
* access, with no other allowed principal except Windows LocalSystem.
|
|
146
147
|
*
|
|
147
148
|
* Split out from the spawning above because it is the actual assertion, and
|
|
148
149
|
* an assertion that can only run on one operating system is an assertion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-store.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/credential-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAqBH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAKzD,eAAO,MA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AI7D;AAsGD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAiBlD;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAMpE;AA8DD;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiBvD;AAED,qFAAqF;AACrF,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,CAc9C;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAmDjF"}
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
* - Windows: POSIX modes do not exist — `fs.chmod` there only toggles the
|
|
29
29
|
* read-only attribute, so a `0600` that "succeeded" would prove nothing.
|
|
30
30
|
* The equivalent is a discretionary ACL, so inheritance is removed and a
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* full-control entry is granted to the current user's SID; the ACL is then
|
|
32
|
+
* saved back as SDDL and checked for access by that user. An existing
|
|
33
|
+
* LocalSystem grant is permitted; grants to other accounts are refused.
|
|
34
34
|
*
|
|
35
35
|
* ## What is in the file
|
|
36
36
|
*
|
|
@@ -374,8 +374,9 @@ function publishLockAtomically(lockPath, token) {
|
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
/**
|
|
377
|
-
* Make `path`
|
|
378
|
-
*
|
|
377
|
+
* Make `path` private to the current account, and PROVE it. Windows may retain
|
|
378
|
+
* access for the operating system's LocalSystem account. Throws
|
|
379
|
+
* `CredentialStoreError` when the proof cannot be produced.
|
|
379
380
|
*
|
|
380
381
|
* Exported because it is the load-bearing half of this module and a security
|
|
381
382
|
* property nobody can check by reading the caller.
|
|
@@ -413,8 +414,12 @@ export function assertOwnerOnlyMode(mode, path) {
|
|
|
413
414
|
}
|
|
414
415
|
/**
|
|
415
416
|
* The Windows half: remove inheritance, grant the current user's SID full
|
|
416
|
-
* control, then read the resulting ACL back as SDDL
|
|
417
|
-
*
|
|
417
|
+
* control, then read the resulting ACL back as SDDL. Existing explicit grants
|
|
418
|
+
* survive `/inheritance:r` and `/grant:r`; only LocalSystem may remain beside
|
|
419
|
+
* the current account. Directory grants propagate to children, so Windows does
|
|
420
|
+
* not substitute the creator token's default ACL for new state partitions.
|
|
421
|
+
* Directory protection also removes the built-in Administrators grant; it does
|
|
422
|
+
* not accept that group as private. Other account grants are refused.
|
|
418
423
|
*
|
|
419
424
|
* Both helpers are invoked by absolute path under `%SystemRoot%\System32`.
|
|
420
425
|
* Resolving them through `PATH` is how a same-named executable earlier on the
|
|
@@ -441,7 +446,17 @@ function restrictToOwnerWindows(path) {
|
|
|
441
446
|
if (!sid) {
|
|
442
447
|
throw new CredentialStoreError(`could not determine the current account's security identifier, so the protection of ${path} cannot be established.`);
|
|
443
448
|
}
|
|
444
|
-
|
|
449
|
+
const directory = statSync(path).isDirectory();
|
|
450
|
+
run('icacls.exe', [
|
|
451
|
+
path,
|
|
452
|
+
'/inheritance:r',
|
|
453
|
+
'/grant:r',
|
|
454
|
+
`*${sid}:${directory ? '(OI)(CI)F' : 'F'}`,
|
|
455
|
+
// Tighten the named private directory, including older generated state
|
|
456
|
+
// whose non-inheritable parent caused Windows to add this default grant.
|
|
457
|
+
// Never reset the ACL through a potentially wider parent descriptor.
|
|
458
|
+
...(directory ? ['/remove:g', '*S-1-5-32-544'] : []),
|
|
459
|
+
]);
|
|
445
460
|
const saved = readAclSddl(path);
|
|
446
461
|
if (saved === null) {
|
|
447
462
|
throw new CredentialStoreError(`could not read back the access-control list of ${path}, so its privacy is unestablished.`);
|
|
@@ -501,8 +516,8 @@ export function currentUserSid() {
|
|
|
501
516
|
}
|
|
502
517
|
}
|
|
503
518
|
/**
|
|
504
|
-
* Require
|
|
505
|
-
* principal
|
|
519
|
+
* Require a protected SDDL discretionary ACL that grants the current account
|
|
520
|
+
* access, with no other allowed principal except Windows LocalSystem.
|
|
506
521
|
*
|
|
507
522
|
* Split out from the spawning above because it is the actual assertion, and
|
|
508
523
|
* an assertion that can only run on one operating system is an assertion
|
|
@@ -511,10 +526,10 @@ export function currentUserSid() {
|
|
|
511
526
|
* at a match would call that private.
|
|
512
527
|
*/
|
|
513
528
|
export function assertSoleOwnerSddl(sddl, sid, path) {
|
|
514
|
-
const dacl = sddl.match(/D:([A-Z]*)((
|
|
529
|
+
const dacl = sddl.match(/D:([A-Z]*)(.*?)(?=[OGS]:|[\r\n]|$)/u);
|
|
515
530
|
const flags = dacl?.[1] ?? '';
|
|
516
531
|
const body = dacl?.[2] ?? '';
|
|
517
|
-
if (!dacl || body
|
|
532
|
+
if (!dacl || !/^(?:\([^()]*\))+$/u.test(body)) {
|
|
518
533
|
throw new CredentialStoreError(`the access-control list of ${path} could not be read back, so its privacy is unestablished.`);
|
|
519
534
|
}
|
|
520
535
|
if (!flags.includes('P')) {
|
|
@@ -524,18 +539,30 @@ export function assertSoleOwnerSddl(sddl, sid, path) {
|
|
|
524
539
|
if (aces.length === 0) {
|
|
525
540
|
throw new CredentialStoreError(`the access-control list of ${path} could not be read back, so its privacy is unestablished.`);
|
|
526
541
|
}
|
|
542
|
+
let grantsCurrentAccount = false;
|
|
543
|
+
const normalizeSid = (value) => value.toUpperCase() === 'SY' ? 'S-1-5-18' : value.toUpperCase();
|
|
527
544
|
for (const ace of aces) {
|
|
528
545
|
const type = ace[0] ?? '';
|
|
529
546
|
const trustee = ace[5] ?? '';
|
|
530
|
-
//
|
|
531
|
-
|
|
547
|
+
// Object/conditional ACEs need a different parser. They cannot be
|
|
548
|
+
// classified as harmless merely because their type is not plain A.
|
|
549
|
+
if (ace.length !== 6 || (type !== 'A' && type !== 'D') || ace[3] || ace[4]) {
|
|
550
|
+
throw new CredentialStoreError(`the access-control list of ${path} contains an unsupported entry, so its privacy is unestablished.`);
|
|
551
|
+
}
|
|
552
|
+
if (type === 'D')
|
|
532
553
|
continue;
|
|
533
|
-
|
|
554
|
+
const currentAccount = normalizeSid(trustee) === normalizeSid(sid);
|
|
555
|
+
if (!currentAccount && normalizeSid(trustee) !== 'S-1-5-18') {
|
|
534
556
|
throw new CredentialStoreError(`${path} grants access to an account other than yours (${trustee}) — refusing to keep a credential there.`);
|
|
535
557
|
}
|
|
558
|
+
// An inherit-only grant applies to descendants, not this path. A
|
|
559
|
+
// SYSTEM-only list likewise says nothing about the current user's access.
|
|
560
|
+
if (currentAccount && !(ace[1] ?? '').includes('IO') && ace[2]) {
|
|
561
|
+
grantsCurrentAccount = true;
|
|
562
|
+
}
|
|
536
563
|
}
|
|
537
|
-
if (!
|
|
538
|
-
throw new CredentialStoreError(`${path} ended with no
|
|
564
|
+
if (!grantsCurrentAccount) {
|
|
565
|
+
throw new CredentialStoreError(`${path} ended with no access granted to your account, which is not a credential store — refusing.`);
|
|
539
566
|
}
|
|
540
567
|
}
|
|
541
568
|
//# sourceMappingURL=credential-store.js.map
|