@stigmer/runner 3.0.8-dev.20260613085218 → 3.0.8
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/hook-script.d.ts +23 -12
- package/dist/activities/execute-cursor/hook-script.js +85 -51
- package/dist/activities/execute-cursor/hook-script.js.map +1 -1
- package/dist/activities/execute-cursor/index.js +210 -79
- package/dist/activities/execute-cursor/index.js.map +1 -1
- package/dist/activities/execute-cursor/message-translator.d.ts +35 -0
- package/dist/activities/execute-cursor/message-translator.js +114 -6
- package/dist/activities/execute-cursor/message-translator.js.map +1 -1
- package/dist/activities/execute-cursor/prompt-builder.d.ts +25 -0
- package/dist/activities/execute-cursor/prompt-builder.js +54 -0
- package/dist/activities/execute-cursor/prompt-builder.js.map +1 -1
- package/dist/activities/execute-cursor/workspace-setup.d.ts +8 -2
- package/dist/activities/execute-cursor/workspace-setup.js +62 -30
- package/dist/activities/execute-cursor/workspace-setup.js.map +1 -1
- package/dist/activities/execute-deep-agent/index.js +14 -4
- package/dist/activities/execute-deep-agent/index.js.map +1 -1
- package/dist/activities/execute-deep-agent/status-builder-shared.d.ts +0 -1
- package/dist/activities/execute-deep-agent/status-builder-shared.js +32 -8
- package/dist/activities/execute-deep-agent/status-builder-shared.js.map +1 -1
- package/dist/activities/execute-deep-agent/status-builder.js +4 -5
- package/dist/activities/execute-deep-agent/status-builder.js.map +1 -1
- package/dist/activities/execute-deep-agent/streaming-v3.js +3 -4
- package/dist/activities/execute-deep-agent/streaming-v3.js.map +1 -1
- package/dist/activities/execute-deep-agent/streaming.d.ts +8 -0
- package/dist/activities/execute-deep-agent/streaming.js +3 -4
- package/dist/activities/execute-deep-agent/streaming.js.map +1 -1
- package/dist/activities/execute-deep-agent/subagent-tracker.js +4 -5
- package/dist/activities/execute-deep-agent/subagent-tracker.js.map +1 -1
- package/dist/activities/execute-deep-agent/v3-status-builder.js +6 -5
- package/dist/activities/execute-deep-agent/v3-status-builder.js.map +1 -1
- package/dist/config.d.ts +21 -0
- package/dist/config.js +12 -0
- package/dist/config.js.map +1 -1
- package/dist/in-flight.d.ts +35 -0
- package/dist/in-flight.js +61 -0
- package/dist/in-flight.js.map +1 -0
- package/dist/runner-manager.d.ts +2 -0
- package/dist/runner-manager.js +90 -29
- package/dist/runner-manager.js.map +1 -1
- package/dist/runner.d.ts +2 -0
- package/dist/runner.js +2 -0
- package/dist/runner.js.map +1 -1
- package/dist/shared/grpc-retry.d.ts +9 -20
- package/dist/shared/grpc-retry.js +9 -52
- package/dist/shared/grpc-retry.js.map +1 -1
- package/dist/shared/stall-watchdog.d.ts +68 -0
- package/dist/shared/stall-watchdog.js +102 -0
- package/dist/shared/stall-watchdog.js.map +1 -0
- package/dist/shared/status-offload.d.ts +84 -0
- package/dist/shared/status-offload.js +292 -0
- package/dist/shared/status-offload.js.map +1 -0
- package/dist/shared/status.d.ts +34 -3
- package/dist/shared/status.js +102 -9
- package/dist/shared/status.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/config.test.ts +8 -0
- package/src/__tests__/in-flight.test.ts +84 -0
- package/src/activities/__tests__/classify-tool-approvals.test.ts +1 -0
- package/src/activities/__tests__/discover-mcp-server.test.ts +1 -0
- package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +74 -0
- package/src/activities/execute-cursor/__tests__/hook-script.test.ts +90 -15
- package/src/activities/execute-cursor/__tests__/tool-result-image.test.ts +244 -0
- package/src/activities/execute-cursor/__tests__/workspace-setup.test.ts +53 -4
- package/src/activities/execute-cursor/hook-script.ts +85 -51
- package/src/activities/execute-cursor/index.ts +170 -35
- package/src/activities/execute-cursor/message-translator.ts +113 -6
- package/src/activities/execute-cursor/prompt-builder.ts +59 -0
- package/src/activities/execute-cursor/workspace-setup.ts +76 -44
- package/src/activities/execute-deep-agent/__tests__/index.test.ts +1 -0
- package/src/activities/execute-deep-agent/__tests__/status-builder-shared.test.ts +66 -0
- package/src/activities/execute-deep-agent/__tests__/status-builder.test.ts +6 -3
- package/src/activities/execute-deep-agent/__tests__/streaming-v3.test.ts +70 -0
- package/src/activities/execute-deep-agent/index.ts +16 -4
- package/src/activities/execute-deep-agent/status-builder-shared.ts +27 -5
- package/src/activities/execute-deep-agent/status-builder.ts +3 -5
- package/src/activities/execute-deep-agent/streaming-v3.ts +4 -4
- package/src/activities/execute-deep-agent/streaming.ts +13 -4
- package/src/activities/execute-deep-agent/subagent-tracker.ts +4 -5
- package/src/activities/execute-deep-agent/v3-status-builder.ts +5 -5
- package/src/config.ts +27 -0
- package/src/in-flight.ts +71 -0
- package/src/runner-manager.ts +127 -33
- package/src/runner.ts +6 -0
- package/src/shared/__tests__/artifact-storage.test.ts +1 -0
- package/src/shared/__tests__/grpc-retry-extended.test.ts +6 -144
- package/src/shared/__tests__/grpc-retry.test.ts +5 -134
- package/src/shared/__tests__/stall-watchdog.test.ts +193 -0
- package/src/shared/__tests__/status-offload.test.ts +256 -0
- package/src/shared/__tests__/status.test.ts +199 -0
- package/src/shared/grpc-retry.ts +9 -72
- package/src/shared/stall-watchdog.ts +122 -0
- package/src/shared/status-offload.ts +342 -0
- package/src/shared/status.ts +142 -8
package/dist/.build-fingerprint
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"hash":"
|
|
1
|
+
{"hash":"7d80f933d9ecca52","builtAt":"2026-06-15T13:01:42.140Z","fileCount":197}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Template for the
|
|
2
|
+
* Template for the approval hook script that Cursor spawns.
|
|
3
3
|
*
|
|
4
|
-
* This module doesn't execute as a hook itself — it generates the shell
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* This module doesn't execute as a hook itself — it generates the shell script
|
|
5
|
+
* written to the HITL dir as stigmer-approval.sh. Cursor invokes that ONE script
|
|
6
|
+
* for TWO events (registered in .cursor/hooks.json by workspace-setup.ts):
|
|
7
|
+
* - `preToolUse` — fires for built-in tools (Write/Shell/Delete/…).
|
|
8
|
+
* - `beforeMCPExecution` — the only event Cursor enforces for MCP tool calls;
|
|
9
|
+
* `preToolUse` does NOT gate MCP (confirmed by a live
|
|
10
|
+
* payload capture). MCP is therefore gated in exactly
|
|
11
|
+
* ONE place, so a denial is never double-recorded.
|
|
12
|
+
* The script branches on the payload's `hook_event_name`: MCP tools are gated on
|
|
13
|
+
* the beforeMCPExecution invocation, built-ins on the preToolUse invocation.
|
|
7
14
|
*
|
|
8
15
|
* The hook script:
|
|
9
16
|
* 1. Reads the tool call JSON from stdin
|
|
10
17
|
* 2. Reads the approval state JSON file written by the cursor-runner
|
|
11
|
-
* 3. Evaluates the policy: auto-approve, approved grants (reinvocation),
|
|
12
|
-
* gated built-in tools
|
|
18
|
+
* 3. Evaluates the policy: auto-approve, approved grants (reinvocation), then —
|
|
19
|
+
* by event — gated built-in tools (preToolUse) or MCP require-approval
|
|
20
|
+
* policies (beforeMCPExecution)
|
|
13
21
|
* 4. On a deny, appends the call's identity token to the denial ledger
|
|
14
22
|
* (stigmer-denials.jsonl) so the runner can mark the gated tool call as
|
|
15
23
|
* WAITING_APPROVAL — the hook is the only place the deny decision is made,
|
|
@@ -49,14 +57,17 @@
|
|
|
49
57
|
* Policy evaluation order (first match wins). The model is "gate the dangerous
|
|
50
58
|
* set, allow the rest" — matching the native harness and avoiding denial of
|
|
51
59
|
* auto-approved MCP tools (which are absent from mcpToolPolicies):
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
60
|
+
* 0. Scope guard: not the runner's own agent → allow (never touch the ledger)
|
|
61
|
+
* 1. Missing state file → deny (fail-closed); autoApproveAll → allow
|
|
62
|
+
* 2. beforeMCPExecution event → MCP tool present in mcpToolPolicies
|
|
63
|
+
* (require-approval):
|
|
64
|
+
* a. name token in approvedGrantTokens → allow (reinvocation grant)
|
|
55
65
|
* b. otherwise → record denial, deny
|
|
56
|
-
*
|
|
57
|
-
*
|
|
66
|
+
* (auto-approved / unlisted MCP tools fall through → allow)
|
|
67
|
+
* 3. preToolUse event → gated built-in (category non-empty):
|
|
68
|
+
* a. identity token in approvedGrantTokens → allow (reinvocation grant)
|
|
58
69
|
* b. otherwise → record denial, deny
|
|
59
|
-
*
|
|
70
|
+
* (read-only / ungated built-ins fall through → allow)
|
|
60
71
|
*/
|
|
61
72
|
/**
|
|
62
73
|
* Generates the bash hook script content.
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Template for the
|
|
2
|
+
* Template for the approval hook script that Cursor spawns.
|
|
3
3
|
*
|
|
4
|
-
* This module doesn't execute as a hook itself — it generates the shell
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* This module doesn't execute as a hook itself — it generates the shell script
|
|
5
|
+
* written to the HITL dir as stigmer-approval.sh. Cursor invokes that ONE script
|
|
6
|
+
* for TWO events (registered in .cursor/hooks.json by workspace-setup.ts):
|
|
7
|
+
* - `preToolUse` — fires for built-in tools (Write/Shell/Delete/…).
|
|
8
|
+
* - `beforeMCPExecution` — the only event Cursor enforces for MCP tool calls;
|
|
9
|
+
* `preToolUse` does NOT gate MCP (confirmed by a live
|
|
10
|
+
* payload capture). MCP is therefore gated in exactly
|
|
11
|
+
* ONE place, so a denial is never double-recorded.
|
|
12
|
+
* The script branches on the payload's `hook_event_name`: MCP tools are gated on
|
|
13
|
+
* the beforeMCPExecution invocation, built-ins on the preToolUse invocation.
|
|
7
14
|
*
|
|
8
15
|
* The hook script:
|
|
9
16
|
* 1. Reads the tool call JSON from stdin
|
|
10
17
|
* 2. Reads the approval state JSON file written by the cursor-runner
|
|
11
|
-
* 3. Evaluates the policy: auto-approve, approved grants (reinvocation),
|
|
12
|
-
* gated built-in tools
|
|
18
|
+
* 3. Evaluates the policy: auto-approve, approved grants (reinvocation), then —
|
|
19
|
+
* by event — gated built-in tools (preToolUse) or MCP require-approval
|
|
20
|
+
* policies (beforeMCPExecution)
|
|
13
21
|
* 4. On a deny, appends the call's identity token to the denial ledger
|
|
14
22
|
* (stigmer-denials.jsonl) so the runner can mark the gated tool call as
|
|
15
23
|
* WAITING_APPROVAL — the hook is the only place the deny decision is made,
|
|
@@ -49,20 +57,32 @@
|
|
|
49
57
|
* Policy evaluation order (first match wins). The model is "gate the dangerous
|
|
50
58
|
* set, allow the rest" — matching the native harness and avoiding denial of
|
|
51
59
|
* auto-approved MCP tools (which are absent from mcpToolPolicies):
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
60
|
+
* 0. Scope guard: not the runner's own agent → allow (never touch the ledger)
|
|
61
|
+
* 1. Missing state file → deny (fail-closed); autoApproveAll → allow
|
|
62
|
+
* 2. beforeMCPExecution event → MCP tool present in mcpToolPolicies
|
|
63
|
+
* (require-approval):
|
|
64
|
+
* a. name token in approvedGrantTokens → allow (reinvocation grant)
|
|
55
65
|
* b. otherwise → record denial, deny
|
|
56
|
-
*
|
|
57
|
-
*
|
|
66
|
+
* (auto-approved / unlisted MCP tools fall through → allow)
|
|
67
|
+
* 3. preToolUse event → gated built-in (category non-empty):
|
|
68
|
+
* a. identity token in approvedGrantTokens → allow (reinvocation grant)
|
|
58
69
|
* b. otherwise → record denial, deny
|
|
59
|
-
*
|
|
70
|
+
* (read-only / ungated built-ins fall through → allow)
|
|
60
71
|
*/
|
|
61
72
|
import { SALIENT_ARG_FIELDS, getBuiltInGatedCategories } from "./approval-policy.js";
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
// Shown to the model when the gate denies a tool call. It must NOT teach the
|
|
74
|
+
// model to ask for permission in prose or to "stop and wait" — that framing
|
|
75
|
+
// makes the model narrate approval requests instead of invoking tools (the
|
|
76
|
+
// platform's approval surface is driven by tool invocation; see
|
|
77
|
+
// formatToolApprovalProtocol in prompt-builder.ts). Instead it tells the model
|
|
78
|
+
// the approval is automatic and that it should not retry or work around THIS
|
|
79
|
+
// action. Embedded verbatim into the generated hook script inside a
|
|
80
|
+
// single-quoted bash echo of a JSON object, so the text must contain no double
|
|
81
|
+
// quotes, apostrophes, or backslashes.
|
|
82
|
+
const APPROVAL_REQUIRED_AGENT_MESSAGE = "This action has been submitted to the user for approval automatically; you " +
|
|
83
|
+
"do not need to ask for permission. Do not retry it or attempt a workaround " +
|
|
84
|
+
"for this action. The platform will resume you automatically after the user " +
|
|
85
|
+
"responds — continue with the rest of the task.";
|
|
66
86
|
/**
|
|
67
87
|
* Build the bash `case` arms that map an incoming hook `tool_name` to its
|
|
68
88
|
* canonical approval category. Generated from approval-policy.ts so the hook and
|
|
@@ -86,9 +106,11 @@ function buildCategoryCaseArms() {
|
|
|
86
106
|
* Build the inline Node.js identity extractor embedded in the hook script.
|
|
87
107
|
*
|
|
88
108
|
* Parses the hook's stdin JSON properly (the bash fallback's grep truncates
|
|
89
|
-
* string values at the first escaped quote) and emits
|
|
90
|
-
*
|
|
91
|
-
*
|
|
109
|
+
* string values at the first escaped quote) and emits five lines: tool_name,
|
|
110
|
+
* canonical category, identity token, MCP name-token, and hook_event_name (the
|
|
111
|
+
* event discriminator: `preToolUse` for built-ins, `beforeMCPExecution` for MCP).
|
|
112
|
+
* The token encodings must stay byte-identical to grantToken() in
|
|
113
|
+
* approval-state.ts.
|
|
92
114
|
*
|
|
93
115
|
* Authored as a single-quoted bash string, so the JS must not contain single
|
|
94
116
|
* quotes. The category map and salient field list are baked from
|
|
@@ -110,7 +132,8 @@ function buildNodeIdentityScript() {
|
|
|
110
132
|
`let s="";`,
|
|
111
133
|
`for(const f of ${fields}){const v=a[f];if(typeof v==="string"&&v){s=v;break;}}`,
|
|
112
134
|
`const b=(x)=>Buffer.from(x,"utf8").toString("base64");`,
|
|
113
|
-
`
|
|
135
|
+
`const ev=typeof t.hook_event_name==="string"?t.hook_event_name:"";`,
|
|
136
|
+
`process.stdout.write(name+"\\n"+cat+"\\n"+b(cat+"\\n"+s)+"\\n"+b(name+"\\n")+"\\n"+ev);`,
|
|
114
137
|
].join("");
|
|
115
138
|
}
|
|
116
139
|
/**
|
|
@@ -146,13 +169,15 @@ export function generateHookScript(stateFilePath, ledgerFilePath, runnerPid) {
|
|
|
146
169
|
const categoryCaseArms = buildCategoryCaseArms();
|
|
147
170
|
const nodeIdentityScript = buildNodeIdentityScript();
|
|
148
171
|
return `#!/bin/bash
|
|
149
|
-
# Stigmer HITL approval hook for Cursor preToolUse
|
|
172
|
+
# Stigmer HITL approval hook for Cursor (preToolUse + beforeMCPExecution).
|
|
150
173
|
# Generated by cursor-runner — do not edit manually.
|
|
151
174
|
#
|
|
152
|
-
# Reads tool call from stdin (JSON), checks approval state file, returns a
|
|
153
|
-
# permission decision on stdout (JSON).
|
|
154
|
-
#
|
|
155
|
-
#
|
|
175
|
+
# Reads a tool call from stdin (JSON), checks the approval state file, returns a
|
|
176
|
+
# permission decision on stdout (JSON). Branches on hook_event_name: MCP tools
|
|
177
|
+
# are gated on beforeMCPExecution, built-ins on preToolUse (preToolUse does not
|
|
178
|
+
# enforce MCP). On a deny, appends the call's canonical identity token to the
|
|
179
|
+
# denial ledger so the runner can mark the gated tool call as WAITING_APPROVAL.
|
|
180
|
+
# See hook-script.ts for the cross-taxonomy identity design.
|
|
156
181
|
|
|
157
182
|
set -euo pipefail
|
|
158
183
|
|
|
@@ -209,6 +234,7 @@ if [ -n "$IDENTITY" ]; then
|
|
|
209
234
|
CATEGORY=$(printf '%s\\n' "$IDENTITY" | sed -n 2p)
|
|
210
235
|
TOKEN=$(printf '%s\\n' "$IDENTITY" | sed -n 3p)
|
|
211
236
|
MCP_TOKEN=$(printf '%s\\n' "$IDENTITY" | sed -n 4p)
|
|
237
|
+
HOOK_EVENT=$(printf '%s\\n' "$IDENTITY" | sed -n 5p)
|
|
212
238
|
else
|
|
213
239
|
# Fallback when the Node binary cannot run: grep/cut extraction. Best-effort
|
|
214
240
|
# only — '"field":"[^"]*"' truncates at the first JSON-escaped quote, so the
|
|
@@ -217,6 +243,7 @@ else
|
|
|
217
243
|
# Every extraction ends with '|| true': under 'set -e' a non-matching grep
|
|
218
244
|
# would otherwise abort the script and emit no decision.
|
|
219
245
|
TOOL_NAME=$(echo "$INPUT" | grep -o '"tool_name":"[^"]*"' | head -1 | cut -d'"' -f4 || true)
|
|
246
|
+
HOOK_EVENT=$(echo "$INPUT" | grep -o '"hook_event_name":"[^"]*"' | head -1 | cut -d'"' -f4 || true)
|
|
220
247
|
SALIENT=""
|
|
221
248
|
for field in ${salientFields}; do
|
|
222
249
|
v=$(echo "$INPUT" | grep -o "\\"$field\\":\\"[^\\"]*\\"" | head -1 | cut -d'"' -f4 || true)
|
|
@@ -252,7 +279,37 @@ record_denial() {
|
|
|
252
279
|
echo '{"toolName":"'"$TOOL_NAME"'","token":"'"$1"'"}' >> "$LEDGER_FILE" 2>/dev/null || true
|
|
253
280
|
}
|
|
254
281
|
|
|
255
|
-
# --- 2.
|
|
282
|
+
# --- 2. MCP tools (beforeMCPExecution event) ---
|
|
283
|
+
# preToolUse does NOT enforce gating for MCP calls — beforeMCPExecution does — so
|
|
284
|
+
# MCP is gated here and ONLY here (never double-recorded). mcpToolPolicies holds
|
|
285
|
+
# only require-approval tools (auto-approved MCP tools are absent), so presence
|
|
286
|
+
# means "deny" unless an entry is explicitly false. MCP tool names are consistent
|
|
287
|
+
# across the hook and the stream, so the identity token is name-only:
|
|
288
|
+
# base64("$TOOL_NAME\\n").
|
|
289
|
+
if [ "$HOOK_EVENT" = "beforeMCPExecution" ]; then
|
|
290
|
+
if echo "$STATE" | grep -q "\\"mcpToolPolicies\\"" && [ -n "$TOOL_NAME" ]; then
|
|
291
|
+
TOOL_POLICY=$(echo "$STATE" | grep -o "\\"$TOOL_NAME\\":{[^}]*}" | head -1 || true)
|
|
292
|
+
if [ -n "$TOOL_POLICY" ] && ! echo "$TOOL_POLICY" | grep -q '"requiresApproval":false'; then
|
|
293
|
+
# Reinvocation grant: this tool was approved earlier → allow.
|
|
294
|
+
if echo "$STATE" | grep -qF "\\"$MCP_TOKEN\\""; then
|
|
295
|
+
echo '{"permission":"allow"}'
|
|
296
|
+
exit 0
|
|
297
|
+
fi
|
|
298
|
+
MSG=$(echo "$TOOL_POLICY" | grep -o '"message":"[^"]*"' | head -1 | cut -d'"' -f4 || true)
|
|
299
|
+
if [ -z "$MSG" ]; then
|
|
300
|
+
MSG="Tool requires approval: $TOOL_NAME"
|
|
301
|
+
fi
|
|
302
|
+
record_denial "$MCP_TOKEN"
|
|
303
|
+
echo '{"permission":"deny","agent_message":"${APPROVAL_REQUIRED_AGENT_MESSAGE}","user_message":"'"$MSG"'"}'
|
|
304
|
+
exit 0
|
|
305
|
+
fi
|
|
306
|
+
fi
|
|
307
|
+
# Auto-approved or unlisted MCP tool → allow.
|
|
308
|
+
echo '{"permission":"allow"}'
|
|
309
|
+
exit 0
|
|
310
|
+
fi
|
|
311
|
+
|
|
312
|
+
# --- 3. Gated built-in tools (preToolUse event, category non-empty) ---
|
|
256
313
|
if [ -n "$CATEGORY" ]; then
|
|
257
314
|
# Reinvocation grant: this exact resource was approved earlier → allow.
|
|
258
315
|
if echo "$STATE" | grep -qF "\\"$TOKEN\\""; then
|
|
@@ -264,32 +321,9 @@ if [ -n "$CATEGORY" ]; then
|
|
|
264
321
|
exit 0
|
|
265
322
|
fi
|
|
266
323
|
|
|
267
|
-
# --- 3. MCP tools that require approval → deny ---
|
|
268
|
-
# mcpToolPolicies holds only require-approval tools (auto-approved MCP tools are
|
|
269
|
-
# absent), so presence means "deny" unless an entry is explicitly false. MCP tool
|
|
270
|
-
# names are consistent across the hook and the stream, so the identity token is
|
|
271
|
-
# name-only: base64("$TOOL_NAME\\n").
|
|
272
|
-
if echo "$STATE" | grep -q "\\"mcpToolPolicies\\"" && [ -n "$TOOL_NAME" ]; then
|
|
273
|
-
TOOL_POLICY=$(echo "$STATE" | grep -o "\\"$TOOL_NAME\\":{[^}]*}" | head -1 || true)
|
|
274
|
-
if [ -n "$TOOL_POLICY" ] && ! echo "$TOOL_POLICY" | grep -q '"requiresApproval":false'; then
|
|
275
|
-
if echo "$STATE" | grep -qF "\\"$MCP_TOKEN\\""; then
|
|
276
|
-
echo '{"permission":"allow"}'
|
|
277
|
-
exit 0
|
|
278
|
-
fi
|
|
279
|
-
MSG=$(echo "$TOOL_POLICY" | grep -o '"message":"[^"]*"' | head -1 | cut -d'"' -f4 || true)
|
|
280
|
-
if [ -z "$MSG" ]; then
|
|
281
|
-
MSG="Tool requires approval: $TOOL_NAME"
|
|
282
|
-
fi
|
|
283
|
-
record_denial "$MCP_TOKEN"
|
|
284
|
-
echo '{"permission":"deny","agent_message":"${APPROVAL_REQUIRED_AGENT_MESSAGE}","user_message":"'"$MSG"'"}'
|
|
285
|
-
exit 0
|
|
286
|
-
fi
|
|
287
|
-
fi
|
|
288
|
-
|
|
289
324
|
# --- 4. Everything else → allow ---
|
|
290
|
-
# Read-only built-ins
|
|
291
|
-
#
|
|
292
|
-
# rest) and prevents denying auto-approved MCP tools the state cannot enumerate.
|
|
325
|
+
# Read-only built-ins and anything not explicitly gated. Fail-open mirrors the
|
|
326
|
+
# native harness (gate the dangerous set, allow the rest).
|
|
293
327
|
echo '{"permission":"allow"}'
|
|
294
328
|
exit 0
|
|
295
329
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook-script.js","sourceRoot":"","sources":["../../../src/activities/execute-cursor/hook-script.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"hook-script.js","sourceRoot":"","sources":["../../../src/activities/execute-cursor/hook-script.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAErF,6EAA6E;AAC7E,4EAA4E;AAC5E,2EAA2E;AAC3E,gEAAgE;AAChE,+EAA+E;AAC/E,6EAA6E;AAC7E,oEAAoE;AACpE,+EAA+E;AAC/E,uCAAuC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