@stigmer/runner 3.12.4 → 3.12.5
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/dist/.build-fingerprint +1 -1
- package/dist/activities/execute-cursor/cursor-mcp-config.d.ts +45 -0
- package/dist/activities/execute-cursor/cursor-mcp-config.js +76 -0
- package/dist/activities/execute-cursor/cursor-mcp-config.js.map +1 -0
- package/dist/activities/execute-cursor/index.d.ts +10 -1
- package/dist/activities/execute-cursor/index.js +47 -29
- package/dist/activities/execute-cursor/index.js.map +1 -1
- package/dist/activities/execute-cursor/prompt-builder.d.ts +13 -2
- package/dist/activities/execute-cursor/prompt-builder.js +11 -0
- package/dist/activities/execute-cursor/prompt-builder.js.map +1 -1
- package/dist/activities/execute-cursor/session-lifecycle.d.ts +1 -1
- package/dist/activities/execute-cursor/skill-resolver.d.ts +2 -21
- package/dist/activities/execute-cursor/skill-resolver.js +5 -108
- package/dist/activities/execute-cursor/skill-resolver.js.map +1 -1
- package/dist/activities/execute-deep-agent/approval-file-change.d.ts +9 -0
- package/dist/activities/execute-deep-agent/approval-file-change.js +2 -1
- package/dist/activities/execute-deep-agent/approval-file-change.js.map +1 -1
- package/dist/activities/execute-deep-agent/cas-capture-backend.d.ts +18 -1
- package/dist/activities/execute-deep-agent/cas-capture-backend.js +20 -3
- package/dist/activities/execute-deep-agent/cas-capture-backend.js.map +1 -1
- package/dist/activities/execute-deep-agent/index.js +57 -5
- package/dist/activities/execute-deep-agent/index.js.map +1 -1
- package/dist/activities/execute-deep-agent/prompt-builder.d.ts +9 -0
- package/dist/activities/execute-deep-agent/prompt-builder.js +10 -0
- package/dist/activities/execute-deep-agent/prompt-builder.js.map +1 -1
- package/dist/activities/execute-deep-agent/setup.js +17 -16
- package/dist/activities/execute-deep-agent/setup.js.map +1 -1
- package/dist/activities/execute-deep-agent/subagent-transformer.js +17 -11
- package/dist/activities/execute-deep-agent/subagent-transformer.js.map +1 -1
- package/dist/activities/execute-deep-agent/subagent-wiring.d.ts +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/middleware/path-normalization.d.ts +49 -49
- package/dist/middleware/path-normalization.js +73 -84
- package/dist/middleware/path-normalization.js.map +1 -1
- package/dist/middleware/types.d.ts +3 -3
- package/dist/runner-manager.d.ts +1 -1
- package/dist/runner-manager.js +22 -15
- package/dist/runner-manager.js.map +1 -1
- package/dist/runner.js +11 -0
- package/dist/runner.js.map +1 -1
- package/dist/shared/args-preview.d.ts +8 -0
- package/dist/shared/args-preview.js +14 -3
- package/dist/shared/args-preview.js.map +1 -1
- package/dist/shared/artifact-storage.d.ts +11 -1
- package/dist/shared/artifact-storage.js +10 -1
- package/dist/shared/artifact-storage.js.map +1 -1
- package/dist/shared/declared-preferences.d.ts +47 -0
- package/dist/shared/declared-preferences.js +64 -0
- package/dist/shared/declared-preferences.js.map +1 -0
- package/dist/shared/mcp-enabled-tools.d.ts +2 -3
- package/dist/shared/mcp-enabled-tools.js +2 -3
- package/dist/shared/mcp-enabled-tools.js.map +1 -1
- package/dist/shared/mcp-resolver.d.ts +20 -15
- package/dist/shared/mcp-resolver.js +11 -12
- package/dist/shared/mcp-resolver.js.map +1 -1
- package/dist/shared/placeholder-resolver.d.ts +9 -2
- package/dist/shared/placeholder-resolver.js +9 -2
- package/dist/shared/placeholder-resolver.js.map +1 -1
- package/dist/shared/plan-mode-permissions.d.ts +26 -46
- package/dist/shared/plan-mode-permissions.js +27 -55
- package/dist/shared/plan-mode-permissions.js.map +1 -1
- package/dist/shared/skill-mount.d.ts +89 -0
- package/dist/shared/skill-mount.js +142 -0
- package/dist/shared/skill-mount.js.map +1 -0
- package/dist/shared/skill-writer.d.ts +28 -26
- package/dist/shared/skill-writer.js +79 -102
- package/dist/shared/skill-writer.js.map +1 -1
- package/dist/shared/worker-shutdown.d.ts +67 -0
- package/dist/shared/worker-shutdown.js +79 -0
- package/dist/shared/worker-shutdown.js.map +1 -0
- package/dist/shared/workspace/types.d.ts +3 -2
- package/dist/workflow-engine/loader.js +38 -1
- package/dist/workflow-engine/loader.js.map +1 -1
- package/dist/workflow-engine/tasks/human-input.js +23 -2
- package/dist/workflow-engine/tasks/human-input.js.map +1 -1
- package/package.json +15 -11
- package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +50 -0
- package/src/activities/execute-cursor/__tests__/cursor-mcp-config.test.ts +111 -0
- package/src/activities/execute-cursor/__tests__/skill-resolver.test.ts +3 -94
- package/src/activities/execute-cursor/cursor-mcp-config.ts +107 -0
- package/src/activities/execute-cursor/index.ts +63 -35
- package/src/activities/execute-cursor/prompt-builder.ts +29 -2
- package/src/activities/execute-cursor/session-lifecycle.ts +1 -1
- package/src/activities/execute-cursor/skill-resolver.ts +10 -137
- package/src/activities/execute-deep-agent/__tests__/approval-file-change.test.ts +15 -0
- package/src/activities/execute-deep-agent/__tests__/cas-capture-backend.test.ts +75 -0
- package/src/activities/execute-deep-agent/__tests__/hitl-reject.test.ts +1 -0
- package/src/activities/execute-deep-agent/__tests__/hitl-resume-approve-all.test.ts +1 -0
- package/src/activities/execute-deep-agent/__tests__/hitl-resume-history.test.ts +1 -0
- package/src/activities/execute-deep-agent/__tests__/index.test.ts +1 -0
- package/src/activities/execute-deep-agent/__tests__/plan-mode-path-normalization.test.ts +42 -29
- package/src/activities/execute-deep-agent/__tests__/prompt-builder.test.ts +52 -0
- package/src/activities/execute-deep-agent/__tests__/sequential-gate-resume.test.ts +1 -0
- package/src/activities/execute-deep-agent/__tests__/subagent-plan-mode-permissions.test.ts +11 -8
- package/src/activities/execute-deep-agent/approval-file-change.ts +11 -1
- package/src/activities/execute-deep-agent/cas-capture-backend.ts +20 -3
- package/src/activities/execute-deep-agent/index.ts +57 -5
- package/src/activities/execute-deep-agent/prompt-builder.ts +22 -0
- package/src/activities/execute-deep-agent/setup.ts +21 -19
- package/src/activities/execute-deep-agent/subagent-transformer.ts +19 -12
- package/src/activities/execute-deep-agent/subagent-wiring.ts +3 -3
- package/src/index.ts +1 -1
- package/src/middleware/__tests__/path-normalization.test.ts +32 -32
- package/src/middleware/path-normalization.ts +78 -90
- package/src/middleware/types.ts +3 -3
- package/src/runner-manager.ts +26 -16
- package/src/runner.ts +14 -0
- package/src/shared/__tests__/artifact-storage.test.ts +28 -0
- package/src/shared/__tests__/bedrock-seam.test.ts +5 -5
- package/src/shared/__tests__/declared-preferences.test.ts +109 -0
- package/src/shared/__tests__/foundry-seam.test.ts +5 -5
- package/src/shared/__tests__/plan-mode-permissions.test.ts +15 -44
- package/src/shared/__tests__/skill-mount.test.ts +238 -0
- package/src/shared/__tests__/skill-writer.test.ts +151 -128
- package/src/shared/__tests__/vertex-adapter.test.ts +30 -3
- package/src/shared/__tests__/vertex-seam.test.ts +5 -5
- package/src/shared/__tests__/worker-shutdown.test.ts +101 -0
- package/src/shared/args-preview.ts +17 -3
- package/src/shared/artifact-storage.ts +20 -1
- package/src/shared/declared-preferences.ts +84 -0
- package/src/shared/mcp-enabled-tools.ts +2 -3
- package/src/shared/mcp-resolver.ts +20 -20
- package/src/shared/placeholder-resolver.ts +9 -2
- package/src/shared/plan-mode-permissions.ts +27 -58
- package/src/shared/skill-mount.ts +179 -0
- package/src/shared/skill-writer.ts +96 -130
- package/src/shared/worker-shutdown.ts +99 -0
- package/src/shared/workspace/types.ts +3 -2
- package/src/workflow-engine/__tests__/loader.test.ts +51 -0
- package/src/workflow-engine/__tests__/tasks/human-input.test.ts +117 -0
- package/src/workflow-engine/loader.ts +46 -1
- package/src/workflow-engine/tasks/human-input.ts +33 -5
- package/dist/activities/execute-cursor/connect-backfill.d.ts +0 -19
- package/dist/activities/execute-cursor/connect-backfill.js +0 -27
- package/dist/activities/execute-cursor/connect-backfill.js.map +0 -1
- package/dist/activities/execute-cursor/mcp-resolver.d.ts +0 -120
- package/dist/activities/execute-cursor/mcp-resolver.js +0 -194
- package/dist/activities/execute-cursor/mcp-resolver.js.map +0 -1
- package/dist/activities/execute-cursor/placeholder-resolver.d.ts +0 -34
- package/dist/activities/execute-cursor/placeholder-resolver.js +0 -82
- package/dist/activities/execute-cursor/placeholder-resolver.js.map +0 -1
- package/src/activities/execute-cursor/__tests__/mcp-resolver.test.ts +0 -125
- package/src/activities/execute-cursor/connect-backfill.ts +0 -52
- package/src/activities/execute-cursor/mcp-resolver.ts +0 -324
- package/src/activities/execute-cursor/placeholder-resolver.ts +0 -109
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
* Resolves Stigmer McpServerUsage references into an intermediate
|
|
3
3
|
* ResolvedMcpServer format.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
5
|
+
* THE single resolver for both harnesses (oss#387 retired the Cursor
|
|
6
|
+
* harness's near-duplicate): the deep-agent harness
|
|
7
|
+
* (execute-deep-agent/setup.ts), the Cursor harness
|
|
8
|
+
* (execute-cursor/index.ts), the connect backfill
|
|
9
|
+
* (shared/connect-backfill.ts), and the discovery activity
|
|
10
|
+
* (activities/discover-mcp-server.ts, via mcpServerToResolved) all consume
|
|
11
|
+
* it. Each harness maps the result into its SDK format at the last hop:
|
|
12
|
+
* toMcpClientConfig (shared/mcp-manager.ts) for LangChain,
|
|
13
|
+
* toCursorMcpConfig (execute-cursor/cursor-mcp-config.ts) for the Cursor
|
|
14
|
+
* SDK — so a behavioral change here (like the transport guard) lands in
|
|
15
|
+
* both execution paths by construction.
|
|
12
16
|
*/
|
|
13
17
|
import type { McpServerUsage, ToolApprovalOverride } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/spec_pb";
|
|
14
18
|
import type { McpServer } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/api_pb";
|
|
@@ -38,8 +42,11 @@ export interface ResolvedMcpServer {
|
|
|
38
42
|
* enabled_tools, falling back to the server's default_enabled_tools when
|
|
39
43
|
* the usage's list is empty (see shared/mcp-enabled-tools.ts). Absent when
|
|
40
44
|
* unrestricted — which keeps synthesized attachment servers (built without
|
|
41
|
-
* a usage) and the discovery path unfiltered by construction.
|
|
42
|
-
*
|
|
45
|
+
* a usage) and the discovery path unfiltered by construction. Enforcement
|
|
46
|
+
* is per-harness: the deep-agent path filters at connect time
|
|
47
|
+
* (connectMcpServers, shared/mcp-manager.ts); the Cursor SDK config cannot
|
|
48
|
+
* hide tools, so that harness denies non-enabled calls in the HITL hook
|
|
49
|
+
* (see hook-script.ts).
|
|
43
50
|
*/
|
|
44
51
|
enabledTools?: string[];
|
|
45
52
|
/**
|
|
@@ -48,11 +55,10 @@ export interface ResolvedMcpServer {
|
|
|
48
55
|
* override to its own server — a flat cross-server list is how an
|
|
49
56
|
* override once leaked onto (or silently un-gated) a same-named tool on
|
|
50
57
|
* another server. Deliberately REQUIRED, not optional: empty means "no
|
|
51
|
-
* overrides", and every construction site — including the
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* (shared/approval-policy.ts).
|
|
58
|
+
* overrides", and every construction site — including the synthesized
|
|
59
|
+
* attachments, which have no usage and therefore no layer 3 — must say so
|
|
60
|
+
* explicitly, so a forgotten site cannot compile. Consumed by
|
|
61
|
+
* mergeApprovalPolicies (shared/approval-policy.ts).
|
|
56
62
|
*/
|
|
57
63
|
toolApprovalOverrides: ToolApprovalOverride[];
|
|
58
64
|
}
|
|
@@ -69,7 +75,6 @@ export interface McpResolutionResult {
|
|
|
69
75
|
*/
|
|
70
76
|
export declare function resolveMcpServers(client: StigmerClient, usages: McpServerUsage[], envVars: Record<string, string>, transportPosture: McpTransportPosture): Promise<McpResolutionResult>;
|
|
71
77
|
export declare function mcpServerToResolved(server: McpServer, slug: string, envVars: Record<string, string>, usageEnabledTools?: readonly string[], usageToolApprovalOverrides?: ToolApprovalOverride[]): ResolvedMcpServer | null;
|
|
72
|
-
export declare function extractMcpServerSlugs(usages: McpServerUsage[]): string[];
|
|
73
78
|
/**
|
|
74
79
|
* Merge MCP server usages from agent (base) and session (overlay).
|
|
75
80
|
*
|
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
* Resolves Stigmer McpServerUsage references into an intermediate
|
|
3
3
|
* ResolvedMcpServer format.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
5
|
+
* THE single resolver for both harnesses (oss#387 retired the Cursor
|
|
6
|
+
* harness's near-duplicate): the deep-agent harness
|
|
7
|
+
* (execute-deep-agent/setup.ts), the Cursor harness
|
|
8
|
+
* (execute-cursor/index.ts), the connect backfill
|
|
9
|
+
* (shared/connect-backfill.ts), and the discovery activity
|
|
10
|
+
* (activities/discover-mcp-server.ts, via mcpServerToResolved) all consume
|
|
11
|
+
* it. Each harness maps the result into its SDK format at the last hop:
|
|
12
|
+
* toMcpClientConfig (shared/mcp-manager.ts) for LangChain,
|
|
13
|
+
* toCursorMcpConfig (execute-cursor/cursor-mcp-config.ts) for the Cursor
|
|
14
|
+
* SDK — so a behavioral change here (like the transport guard) lands in
|
|
15
|
+
* both execution paths by construction.
|
|
12
16
|
*/
|
|
13
17
|
import { assertTransportAllowed, McpTransportError, } from "./mcp-transport-guard.js";
|
|
14
18
|
import { resolveHeaders, resolvePlaceholders, filterEnvToDeclaredKeys, PlaceholderResolutionError, } from "./placeholder-resolver.js";
|
|
@@ -112,11 +116,6 @@ export function mcpServerToResolved(server, slug, envVars, usageEnabledTools, us
|
|
|
112
116
|
return null;
|
|
113
117
|
}
|
|
114
118
|
}
|
|
115
|
-
export function extractMcpServerSlugs(usages) {
|
|
116
|
-
return usages
|
|
117
|
-
.map((u) => u.mcpServerRef?.slug)
|
|
118
|
-
.filter((s) => !!s);
|
|
119
|
-
}
|
|
120
119
|
/**
|
|
121
120
|
* Merge MCP server usages from agent (base) and session (overlay).
|
|
122
121
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-resolver.js","sourceRoot":"","sources":["../../src/shared/mcp-resolver.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mcp-resolver.js","sourceRoot":"","sources":["../../src/shared/mcp-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAElB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAkD/D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAqB,EACrB,MAAwB,EACxB,OAA+B,EAC/B,gBAAqC;IAErC,MAAM,QAAQ,GAAwB,EAAE,CAAC;IAEzC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,GAAG,GAAG,KAAK,CAAC,YAAY,CAAC;QAC/B,IAAI,CAAC,GAAG,EAAE,IAAI;YAAE,SAAS;QAEzB,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAC;YAC5D,MAAM,SAAS,GAAG,uBAAuB,CACvC,SAAS,CAAC,IAAI,EAAE,GAAG,EACnB,OAAO,EACP,GAAG,CAAC,IAAI,CACT,CAAC;YACF,MAAM,MAAM,GAAG,mBAAmB,CAChC,SAAS,EACT,GAAG,CAAC,IAAI,EACR,SAAS,EACT,KAAK,CAAC,YAAY,EAClB,KAAK,CAAC,qBAAqB,IAAI,EAAE,CAClC,CAAC;YACF,IAAI,MAAM,EAAE,CAAC;gBACX,sBAAsB,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;gBAC7E,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;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MCP server configs.
|
|
3
3
|
*
|
|
4
|
+
* Port of the Python agent-runner's PlaceholderResolver (strict mode only).
|
|
4
5
|
* Always raises on unresolved placeholders — sending literal ${VAR} as an
|
|
5
|
-
* HTTP header value
|
|
6
|
+
* HTTP header value (e.g. Authorization: Bearer ${API_KEY}) produces
|
|
7
|
+
* cryptic auth failures from the remote server.
|
|
6
8
|
*/
|
|
7
9
|
export declare class PlaceholderResolutionError extends Error {
|
|
8
10
|
readonly variableName: string;
|
|
@@ -17,11 +19,16 @@ export declare class PlaceholderResolutionError extends Error {
|
|
|
17
19
|
export declare function resolvePlaceholders(template: string, envVars: Record<string, string>, context?: string): string;
|
|
18
20
|
/**
|
|
19
21
|
* Resolve placeholders in all values of a headers map.
|
|
22
|
+
*
|
|
23
|
+
* @throws PlaceholderResolutionError if any header value contains an
|
|
24
|
+
* unresolvable placeholder.
|
|
20
25
|
*/
|
|
21
26
|
export declare function resolveHeaders(headers: Record<string, string>, envVars: Record<string, string>): Record<string, string>;
|
|
22
27
|
/**
|
|
23
28
|
* Filter env vars to only keys declared in the MCP server's spec.env.
|
|
24
|
-
*
|
|
29
|
+
*
|
|
30
|
+
* Mirrors the agent-runner's _filter_env_to_declared_keys: prevents
|
|
31
|
+
* secret over-sharing by restricting the subprocess/HTTP environment to
|
|
25
32
|
* explicitly declared variables.
|
|
26
33
|
*/
|
|
27
34
|
export declare function filterEnvToDeclaredKeys(declaredEnv: Record<string, unknown> | undefined, envVars: Record<string, string>, serverSlug: string): Record<string, string>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Strict placeholder resolver for ${VAR_NAME} syntax in MCP server configs.
|
|
3
3
|
*
|
|
4
|
+
* Port of the Python agent-runner's PlaceholderResolver (strict mode only).
|
|
4
5
|
* Always raises on unresolved placeholders — sending literal ${VAR} as an
|
|
5
|
-
* HTTP header value
|
|
6
|
+
* HTTP header value (e.g. Authorization: Bearer ${API_KEY}) produces
|
|
7
|
+
* cryptic auth failures from the remote server.
|
|
6
8
|
*/
|
|
7
9
|
const PLACEHOLDER_RE = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
8
10
|
export class PlaceholderResolutionError extends Error {
|
|
@@ -32,6 +34,9 @@ export function resolvePlaceholders(template, envVars, context) {
|
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
34
36
|
* Resolve placeholders in all values of a headers map.
|
|
37
|
+
*
|
|
38
|
+
* @throws PlaceholderResolutionError if any header value contains an
|
|
39
|
+
* unresolvable placeholder.
|
|
35
40
|
*/
|
|
36
41
|
export function resolveHeaders(headers, envVars) {
|
|
37
42
|
const resolved = {};
|
|
@@ -42,7 +47,9 @@ export function resolveHeaders(headers, envVars) {
|
|
|
42
47
|
}
|
|
43
48
|
/**
|
|
44
49
|
* Filter env vars to only keys declared in the MCP server's spec.env.
|
|
45
|
-
*
|
|
50
|
+
*
|
|
51
|
+
* Mirrors the agent-runner's _filter_env_to_declared_keys: prevents
|
|
52
|
+
* secret over-sharing by restricting the subprocess/HTTP environment to
|
|
46
53
|
* explicitly declared variables.
|
|
47
54
|
*/
|
|
48
55
|
export function filterEnvToDeclaredKeys(declaredEnv, envVars, serverSlug) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placeholder-resolver.js","sourceRoot":"","sources":["../../src/shared/placeholder-resolver.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"placeholder-resolver.js","sourceRoot":"","sources":["../../src/shared/placeholder-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,cAAc,GAAG,iCAAiC,CAAC;AAEzD,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAEjC;IACA;IAFlB,YACkB,YAAoB,EACpB,OAAgB;QAEhC,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9C,KAAK,CACH,6BAA6B,YAAY,IAAI,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mode filesystem permission rules — the enforcement twin of
|
|
3
3
|
* `plan-mode-prompt.ts` (which carries the instruction half of the contract).
|
|
4
4
|
*
|
|
5
|
-
* Plan mode is
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
5
|
+
* Plan mode's policy is: reads anywhere in the workspace, writes nowhere.
|
|
6
|
+
* Only the write half needs a RULE. The read boundary that issue #528 built
|
|
7
|
+
* out of rules (workspace read-allow + read-deny, glob-escaped real root) is
|
|
8
|
+
* now STRUCTURAL: every native-harness backend is virtual-rooted
|
|
9
|
+
* (`virtualMode: true` — see cas-capture-backend.ts, issue #754), so every
|
|
10
|
+
* path a tool can express resolves inside the workspace root and traversal
|
|
11
|
+
* is rejected at resolution. A rule cannot widen that, and no workspace-root
|
|
12
|
+
* glob is needed to narrow it — which also retires the whole
|
|
13
|
+
* special-characters-in-the-root hazard (`escapeGlobLiteral` and its
|
|
14
|
+
* end-to-end matcher suite) that the real-path rules carried.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
* path (
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* both; do not "harden" this into one.
|
|
16
|
+
* Paths in these rules are VIRTUAL: "/" is the workspace root, matched by
|
|
17
|
+
* micromatch against the raw tool-call path (dot:true) after the
|
|
18
|
+
* path-normalization middleware has canonicalized it (relative → "/"-rooted;
|
|
19
|
+
* see middleware/path-normalization.ts). The legitimate platform-dir reads
|
|
20
|
+
* (skills, attachments, the approved plan) keep working exactly as before:
|
|
21
|
+
* they are addressed through the `{workspace}/.stigmer` symlink
|
|
22
|
+
* (shared/workspace/stigmer-link.ts), an in-root path string in either
|
|
23
|
+
* dialect.
|
|
25
24
|
*
|
|
26
25
|
* Applied in execute-deep-agent/setup.ts to the parent graph AND threaded
|
|
27
26
|
* into every compiled sub-agent graph: deepagents' parent-permission
|
|
@@ -30,13 +29,6 @@
|
|
|
30
29
|
* (issue #255). Kept as its own side-effect-free module so tests can pin the
|
|
31
30
|
* production rules without dragging in setup.ts's import graph.
|
|
32
31
|
*
|
|
33
|
-
* Rules travel with a companion: every graph that carries them also installs
|
|
34
|
-
* the path-normalization middleware (middleware/path-normalization.ts,
|
|
35
|
-
* issues #429/#528), because deepagents' rule validation refuses
|
|
36
|
-
* workspace-relative paths outright and its `ls`/`glob`/`grep` schema default
|
|
37
|
-
* of "/" would deny the bare first listing. Both are derived from the same
|
|
38
|
-
* expression at each composition site so they cannot drift apart.
|
|
39
|
-
*
|
|
40
32
|
* Invariant: never combine these rules with a shell-capable (sandbox)
|
|
41
33
|
* backend — deepagents rejects that pairing at graph construction (see the
|
|
42
34
|
* cas-capture-backend.ts header). Plan mode guarantees it by construction:
|
|
@@ -45,25 +37,13 @@
|
|
|
45
37
|
*/
|
|
46
38
|
import type { FilesystemPermission } from "deepagents";
|
|
47
39
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* silently never match — bricking every plan-mode read for that workspace.
|
|
53
|
-
* Semantics are pinned end-to-end through deepagents' own matcher by the
|
|
54
|
-
* special-character workspace suite in plan-mode-path-normalization.test.ts.
|
|
55
|
-
*/
|
|
56
|
-
export declare function escapeGlobLiteral(literal: string): string;
|
|
57
|
-
/**
|
|
58
|
-
* Build the plan-mode rule set for a graph whose filesystem backend is
|
|
59
|
-
* rooted at `workspaceRootDir`. The three rules read as the policy:
|
|
60
|
-
* reads allowed in the workspace, reads denied everywhere else, writes
|
|
61
|
-
* denied everywhere.
|
|
40
|
+
* Build the plan-mode rule set. One rule IS the policy: writes denied
|
|
41
|
+
* everywhere ("/**" is every virtual path; deepagents evaluates
|
|
42
|
+
* first-match-wins with a permissive default, so reads stay allowed —
|
|
43
|
+
* workspace-confined structurally, not by rule).
|
|
62
44
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* paths (collapsed slashes, no trailing separator) before matching — a
|
|
67
|
-
* trailing slash in the pattern would silently match nothing.
|
|
45
|
+
* Deliberately parameterless: the pre-#754 signature took the workspace root
|
|
46
|
+
* to build a real-path read fence; resurrecting a root-derived rule would
|
|
47
|
+
* silently mismatch the virtual dialect the enforcement now sees.
|
|
68
48
|
*/
|
|
69
|
-
export declare function buildPlanModePermissions(
|
|
49
|
+
export declare function buildPlanModePermissions(): FilesystemPermission[];
|
|
@@ -2,26 +2,25 @@
|
|
|
2
2
|
* The Plan-mode filesystem permission rules — the enforcement twin of
|
|
3
3
|
* `plan-mode-prompt.ts` (which carries the instruction half of the contract).
|
|
4
4
|
*
|
|
5
|
-
* Plan mode is
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
5
|
+
* Plan mode's policy is: reads anywhere in the workspace, writes nowhere.
|
|
6
|
+
* Only the write half needs a RULE. The read boundary that issue #528 built
|
|
7
|
+
* out of rules (workspace read-allow + read-deny, glob-escaped real root) is
|
|
8
|
+
* now STRUCTURAL: every native-harness backend is virtual-rooted
|
|
9
|
+
* (`virtualMode: true` — see cas-capture-backend.ts, issue #754), so every
|
|
10
|
+
* path a tool can express resolves inside the workspace root and traversal
|
|
11
|
+
* is rejected at resolution. A rule cannot widen that, and no workspace-root
|
|
12
|
+
* glob is needed to narrow it — which also retires the whole
|
|
13
|
+
* special-characters-in-the-root hazard (`escapeGlobLiteral` and its
|
|
14
|
+
* end-to-end matcher suite) that the real-path rules carried.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
* path (
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* both; do not "harden" this into one.
|
|
16
|
+
* Paths in these rules are VIRTUAL: "/" is the workspace root, matched by
|
|
17
|
+
* micromatch against the raw tool-call path (dot:true) after the
|
|
18
|
+
* path-normalization middleware has canonicalized it (relative → "/"-rooted;
|
|
19
|
+
* see middleware/path-normalization.ts). The legitimate platform-dir reads
|
|
20
|
+
* (skills, attachments, the approved plan) keep working exactly as before:
|
|
21
|
+
* they are addressed through the `{workspace}/.stigmer` symlink
|
|
22
|
+
* (shared/workspace/stigmer-link.ts), an in-root path string in either
|
|
23
|
+
* dialect.
|
|
25
24
|
*
|
|
26
25
|
* Applied in execute-deep-agent/setup.ts to the parent graph AND threaded
|
|
27
26
|
* into every compiled sub-agent graph: deepagents' parent-permission
|
|
@@ -30,50 +29,23 @@
|
|
|
30
29
|
* (issue #255). Kept as its own side-effect-free module so tests can pin the
|
|
31
30
|
* production rules without dragging in setup.ts's import graph.
|
|
32
31
|
*
|
|
33
|
-
* Rules travel with a companion: every graph that carries them also installs
|
|
34
|
-
* the path-normalization middleware (middleware/path-normalization.ts,
|
|
35
|
-
* issues #429/#528), because deepagents' rule validation refuses
|
|
36
|
-
* workspace-relative paths outright and its `ls`/`glob`/`grep` schema default
|
|
37
|
-
* of "/" would deny the bare first listing. Both are derived from the same
|
|
38
|
-
* expression at each composition site so they cannot drift apart.
|
|
39
|
-
*
|
|
40
32
|
* Invariant: never combine these rules with a shell-capable (sandbox)
|
|
41
33
|
* backend — deepagents rejects that pairing at graph construction (see the
|
|
42
34
|
* cas-capture-backend.ts header). Plan mode guarantees it by construction:
|
|
43
35
|
* it is the mode that clears `shellEnv`, and `shellEnv` is the single switch
|
|
44
36
|
* for shell capability on both the parent and sub-agent backends.
|
|
45
37
|
*/
|
|
46
|
-
import { resolve } from "node:path";
|
|
47
|
-
/**
|
|
48
|
-
* Backslash-escape every character micromatch/picomatch treats as glob
|
|
49
|
-
* syntax, so the result matches the input literally. micromatch exports no
|
|
50
|
-
* escape API of its own, and this is correctness, not caution: an unescaped
|
|
51
|
-
* `(` in a desktop project path would make the workspace read-allow rule
|
|
52
|
-
* silently never match — bricking every plan-mode read for that workspace.
|
|
53
|
-
* Semantics are pinned end-to-end through deepagents' own matcher by the
|
|
54
|
-
* special-character workspace suite in plan-mode-path-normalization.test.ts.
|
|
55
|
-
*/
|
|
56
|
-
export function escapeGlobLiteral(literal) {
|
|
57
|
-
return literal.replace(/[\\*?()[\]{}!+@]/g, "\\$&");
|
|
58
|
-
}
|
|
59
38
|
/**
|
|
60
|
-
* Build the plan-mode rule set
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
39
|
+
* Build the plan-mode rule set. One rule IS the policy: writes denied
|
|
40
|
+
* everywhere ("/**" is every virtual path; deepagents evaluates
|
|
41
|
+
* first-match-wins with a permissive default, so reads stay allowed —
|
|
42
|
+
* workspace-confined structurally, not by rule).
|
|
64
43
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* paths (collapsed slashes, no trailing separator) before matching — a
|
|
69
|
-
* trailing slash in the pattern would silently match nothing.
|
|
44
|
+
* Deliberately parameterless: the pre-#754 signature took the workspace root
|
|
45
|
+
* to build a real-path read fence; resurrecting a root-derived rule would
|
|
46
|
+
* silently mismatch the virtual dialect the enforcement now sees.
|
|
70
47
|
*/
|
|
71
|
-
export function buildPlanModePermissions(
|
|
72
|
-
|
|
73
|
-
return [
|
|
74
|
-
{ operations: ["read"], paths: [`${escapeGlobLiteral(canonicalRoot)}/**`] },
|
|
75
|
-
{ operations: ["read"], paths: ["/**"], mode: "deny" },
|
|
76
|
-
{ operations: ["write"], paths: ["/**"], mode: "deny" },
|
|
77
|
-
];
|
|
48
|
+
export function buildPlanModePermissions() {
|
|
49
|
+
return [{ operations: ["write"], paths: ["/**"], mode: "deny" }];
|
|
78
50
|
}
|
|
79
51
|
//# sourceMappingURL=plan-mode-permissions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-mode-permissions.js","sourceRoot":"","sources":["../../src/shared/plan-mode-permissions.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"plan-mode-permissions.js","sourceRoot":"","sources":["../../src/shared/plan-mode-permissions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAIH;;;;;;;;;GASG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill mount mechanics — the ONE cache shape shared by both harnesses.
|
|
3
|
+
*
|
|
4
|
+
* A skill "mount" is the on-disk materialization of a skill inside the
|
|
5
|
+
* session's platform directory: `{platformDir}/skills/{name}/` holding
|
|
6
|
+
* SKILL.md plus the artifact's supporting files. Both harnesses write to
|
|
7
|
+
* that same physical location — the Cursor harness directly, the native
|
|
8
|
+
* (deep-agent) harness through the `.stigmer/` virtual namespace that
|
|
9
|
+
* LocalWorkspaceBackend routes there — so they MUST share one cache shape
|
|
10
|
+
* (issues #337/#672). This module owns that shape:
|
|
11
|
+
*
|
|
12
|
+
* - The mount is cached by the skill's content-addressed
|
|
13
|
+
* `status.version_hash`: metadata is still fetched every execution
|
|
14
|
+
* (that keeps latest-version freshness — push a skill update and the
|
|
15
|
+
* very next message picks it up), but the artifact download and file
|
|
16
|
+
* rewrite are skipped when the mounted content's hash already matches.
|
|
17
|
+
* - Remounts rebuild the directory from scratch, so files deleted between
|
|
18
|
+
* skill versions never linger in the mount.
|
|
19
|
+
* - Crash-safe by ordering: the marker is stamped LAST, after every file
|
|
20
|
+
* of the mount landed — a crash mid-write leaves no marker, so the next
|
|
21
|
+
* execution remounts instead of trusting a partial tree.
|
|
22
|
+
*
|
|
23
|
+
* Extracted from execute-cursor/skill-resolver.ts (PR #682) when the
|
|
24
|
+
* deep-agent path adopted the same cache (issue #337). Orchestration —
|
|
25
|
+
* which skills to mount, prompt metadata, degradation logging — stays
|
|
26
|
+
* with each harness; only the per-skill-directory mechanics live here.
|
|
27
|
+
*/
|
|
28
|
+
import type { StigmerClient } from "../client/stigmer-client.js";
|
|
29
|
+
import type { Skill } from "@stigmer/protos/ai/stigmer/agentic/skill/v1/api_pb";
|
|
30
|
+
/** Subdirectory of the platform dir where skill mounts live. */
|
|
31
|
+
export declare const SKILLS_SUBDIR = "skills";
|
|
32
|
+
/**
|
|
33
|
+
* Marker recording what a skill's mount directory currently holds. Written
|
|
34
|
+
* LAST, after every file of the mount landed — a crash mid-write leaves no
|
|
35
|
+
* marker, so the next execution remounts instead of trusting a partial tree.
|
|
36
|
+
*/
|
|
37
|
+
export declare const MOUNT_MARKER_FILE = ".stigmer-mount.json";
|
|
38
|
+
export interface MountMarker {
|
|
39
|
+
/** Content-addressed version hash (`Skill.status.version_hash`) of the mounted content. */
|
|
40
|
+
versionHash: string;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the artifact's files are part of the mount. `false` when the
|
|
43
|
+
* skill has no artifact OR when the download failed and the mount fell
|
|
44
|
+
* back to SKILL.md only — the latter makes the next execution retry the
|
|
45
|
+
* download rather than cache the degraded mount.
|
|
46
|
+
*/
|
|
47
|
+
artifactMounted: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Whether the mount at `skillDir` already holds this version's content.
|
|
51
|
+
*
|
|
52
|
+
* Fresh means: the marker's hash matches AND the mount isn't a degraded
|
|
53
|
+
* SKILL.md-only fallback when the skill does carry an artifact. Any read or
|
|
54
|
+
* parse failure counts as stale — the remount is the safe default.
|
|
55
|
+
*/
|
|
56
|
+
export declare function mountIsFresh(skillDir: string, versionHash: string, wantsArtifact: boolean): Promise<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Download a skill artifact's ZIP bytes, transfer lane first (#675).
|
|
59
|
+
*
|
|
60
|
+
* The URL lane (getArtifactDownloadUrl → HTTP GET) carries any valid skill
|
|
61
|
+
* size; the unary getArtifact response is capped by the server's 10MB gRPC
|
|
62
|
+
* message limit. Servers that predate the lane (and cloud until its sibling
|
|
63
|
+
* lands) answer the mint with UNIMPLEMENTED — those fall back to the unary
|
|
64
|
+
* path, which behaves exactly as before for ≤10MB artifacts.
|
|
65
|
+
*
|
|
66
|
+
* Runs only on a mount-cache miss (the hash-keyed marker above) — a hit
|
|
67
|
+
* skips the transfer entirely, whichever lane would have carried it.
|
|
68
|
+
*/
|
|
69
|
+
export declare function downloadArtifact(client: StigmerClient, artifactStorageKey: string): Promise<Uint8Array | undefined>;
|
|
70
|
+
/**
|
|
71
|
+
* (Re)write a skill's mount directory from scratch.
|
|
72
|
+
*
|
|
73
|
+
* The directory is removed first so files deleted between versions don't
|
|
74
|
+
* linger in the mount, then SKILL.md and the artifact files are written, and
|
|
75
|
+
* the marker is stamped LAST (see MOUNT_MARKER_FILE for the crash-safety
|
|
76
|
+
* contract). SKILL.md always comes from `spec.skillMd` — the server's
|
|
77
|
+
* authoritative copy, which the push pipeline guarantees is non-empty
|
|
78
|
+
* (push.go hard-fails a ZIP without an extractable SKILL.md) — never from
|
|
79
|
+
* the zip; both the zip's SKILL.md and any stray marker-named entry are
|
|
80
|
+
* excluded from extraction so the mount's ownership of those two files is
|
|
81
|
+
* unconditional.
|
|
82
|
+
*
|
|
83
|
+
* Every extracted entry must resolve inside `skillDir`. The server already
|
|
84
|
+
* rejects traversal at push (google/safearchive), but this runner-side
|
|
85
|
+
* check is kept as defense-in-depth: it is the guard the deep-agent path
|
|
86
|
+
* used to get from LocalWorkspaceBackend's platform-path routing, preserved
|
|
87
|
+
* here when skill writes moved to direct fs.
|
|
88
|
+
*/
|
|
89
|
+
export declare function writeSkillMount(skill: Skill, skillDir: string, artifactBytes: Uint8Array | undefined): Promise<void>;
|