@scopebond/hook 0.6.0 → 0.8.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/README.md +123 -13
- package/dist/cli.d.ts +2 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +825 -92
- package/dist/cli.js.map +1 -1
- package/dist/cloud.d.ts +2 -0
- package/dist/cloud.d.ts.map +1 -1
- package/dist/cloud.js +1 -1
- package/dist/cloud.js.map +1 -1
- package/dist/explain.d.ts +44 -0
- package/dist/explain.d.ts.map +1 -0
- package/dist/explain.js +75 -0
- package/dist/explain.js.map +1 -0
- package/dist/index.d.ts +11 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +41 -4
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +104 -21
- package/dist/init.js.map +1 -1
- package/dist/install.d.ts +70 -2
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +262 -10
- package/dist/install.js.map +1 -1
- package/dist/map.d.ts +6 -0
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +4 -1
- package/dist/map.js.map +1 -1
- package/dist/minimize.d.ts +11 -3
- package/dist/minimize.d.ts.map +1 -1
- package/dist/minimize.js +35 -6
- package/dist/minimize.js.map +1 -1
- package/dist/rules.d.ts +51 -0
- package/dist/rules.d.ts.map +1 -0
- package/dist/rules.js +216 -0
- package/dist/rules.js.map +1 -0
- package/dist/runtime-install.d.ts +25 -0
- package/dist/runtime-install.d.ts.map +1 -0
- package/dist/runtime-install.js +106 -0
- package/dist/runtime-install.js.map +1 -0
- package/dist/runtime.d.ts +13 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +52 -7
- package/dist/runtime.js.map +1 -1
- package/dist/version.d.ts +5 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +6 -2
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js.map
CHANG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,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;AAAC,CAAC;KAClD,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;IAAC,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;AAAC,CAAC;KAC1C,IAAI,GAAG,KAAK,QAAQ,EAAE,CAAC;IAAC,MAAM,SAAS,EAAE,CAAC;AAAC,CAAC;KAC5C,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;IAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;AAAC,CAAC;KAC5C,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;IAAC,MAAM,QAAQ,EAAE,CAAC;AAAC,CAAC;KAC1C,IAAI,GAAG,KAAK,QAAQ,EAAE,CAAC;IAAC,SAAS,EAAE,CAAC;AAAC,CAAC;KACtC,IAAI,GAAG,KAAK,QAAQ,EAAE,CAAC;IAAC,MAAM,SAAS,EAAE,CAAC;AAAC,CAAC;KAC5C,IAAI,GAAG,KAAK,WAAW,EAAE,CAAC;IAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AAAC,CAAC;KAChD,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;IAAC,QAAQ,EAAE,CAAC;AAAC,CAAC;KACpC,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;IAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAAC,CAAC;KACxC,CAAC;IACJ,OAAO,CAAC,KAAK,CAAC,6MAA6M,CAAC,CAAC;IAC7N,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","sourcesContent":["#!/usr/bin/env node\n// scopebond-hook — govern a coding agent's tool calls against policy, in-path,\n// before they run, with a signed local receipt.\n//\n// scopebond-hook claude evaluate a Claude Code PreToolUse call (stdin JSON)\n// scopebond-hook cursor evaluate a Cursor hook event (stdin JSON)\n// scopebond-hook codex evaluate a Codex PreToolUse call (stdin JSON)\n// scopebond-hook init [--cursor|--codex] [--no-install] [--yes]\n// scopebond-hook connect <url> <bundle.json> [--cursor|--codex]\n// enroll with a Cloud workspace and start exporting\n// scopebond-hook log [-n N] show the most recent local receipts\n// scopebond-hook verify verify every local receipt offline against the attester key\n// scopebond-hook test \"<shell command>\" show the decision for a command without recording it\n// scopebond-hook flush deliver any queued receipts to Cloud now\n// scopebond-hook trust [--yes] let this project's .scopebond policy govern here (pinned)\n//\n// Config dir: $SCOPEBOND_HOOK_DIR, else ./.scopebond\n// Fail-closed: any error denies the action with a repair message.\n\nimport { readFileSync, existsSync, mkdtempSync, rmSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { tmpdir } from \"node:os\";\nimport { execFileSync } from \"node:child_process\";\nimport type { CloudEnrollmentBundle } from \"@scopebond/gateway\";\nimport { verifyReceipt } from \"@scopebond/gateway\";\nimport { openReceiptStore, loadOrCreateAttester } from \"@scopebond/gateway/node\";\nimport { mapClaudeToolUse, mapCodexToolUse, mapCursorEvent, fillPushBranch, type Mapped } from \"./map.js\";\nimport { createHookRuntime } from \"./runtime.js\";\nimport { scaffold, harnessSnippet, installHarness } from \"./init.js\";\nimport {\n userHome, userHarnessFile, resolveConfigDir, writeHarnessConfig, removeHarnessConfig,\n cursorDetected, codexDetected, absoluteHookCommand, isHarnessConfigured, purgeHome, type Harness,\n trustProjectPolicy, untrustedProjectPolicy,\n} from \"./install.js\";\nimport { connectCloud, loadConnection, connectionPath } from \"./cloud.js\";\nimport { cliCommand, hookVersion } from \"./version.js\";\nimport { fileURLToPath } from \"node:url\";\n\n/** The current git branch in `cwd` (best-effort). A bare `git push` pushes it, so\n * the runtime fills it in before evaluating; on failure the ref stays absent and\n * the starter policy fails closed. */\nfunction currentBranch(cwd: string): string | null {\n try {\n return execFileSync(\"git\", [\"-C\", cwd, \"symbolic-ref\", \"--quiet\", \"--short\", \"HEAD\"], {\n encoding: \"utf8\", stdio: [\"ignore\", \"pipe\", \"ignore\"],\n }).trim() || null;\n } catch { return null; }\n}\n\n/** Read an enrollment bundle from a file path, an inline base64 blob, or inline raw\n * JSON (the portal hands out a base64 blob so it is one clean argument). */\nfunction readBundleArg(bundleArg: string | undefined, stdin: () => string): CloudEnrollmentBundle {\n let text: string;\n if (!bundleArg) text = stdin();\n else if (existsSync(bundleArg)) text = readFileSync(bundleArg, \"utf8\");\n else if (bundleArg.trim().startsWith(\"{\")) text = bundleArg;\n else { try { text = Buffer.from(bundleArg, \"base64\").toString(\"utf8\"); } catch { text = bundleArg; } }\n return JSON.parse(text) as CloudEnrollmentBundle;\n}\n\nfunction configDir(): string {\n return process.env.SCOPEBOND_HOOK_DIR ?? join(process.cwd(), \".scopebond\");\n}\nfunction runtimePaths(dir: string) {\n const connection = loadConnection(dir);\n return {\n policyPath: join(dir, \"policy.json\"),\n keyPath: join(dir, \"agent.key\"),\n attesterPath: join(dir, \"attester.key\"),\n dbPath: join(dir, \"receipts.db\"),\n // Strict: deny (not just observe) tools with no taxonomy mapping.\n strict: process.argv.includes(\"--strict\") || process.env.SCOPEBOND_HOOK_STRICT === \"1\",\n // When connected, auto-export receipts. A short bounded flush keeps the hot path\n // fast; undelivered receipts persist in the durable outbox and flush next time\n // (or via `scopebond-hook flush`, e.g. on a session-end hook).\n ...(connection ? { cloud: { connection, flushTimeoutMs: Number(process.env.SCOPEBOND_HOOK_FLUSH_MS ?? 800) } } : {}),\n };\n}\nfunction readStdin(): string {\n try { return readFileSync(0, \"utf8\"); } catch { return \"\"; }\n}\n\nfunction denyClaude(reason: string): never {\n process.stdout.write(JSON.stringify({\n hookSpecificOutput: { hookEventName: \"PreToolUse\", permissionDecision: \"deny\", permissionDecisionReason: reason },\n }) + \"\\n\");\n process.stderr.write(`Scopebond: ${reason}\\n`);\n process.exit(2);\n}\n\n/** Codex accepts the structured deny response on a successful hook exit. Keeping\n * exit 0 lets its UI show a completed policy check instead of a failed hook while\n * still preventing the tool call. */\nfunction denyCodex(reason: string): never {\n process.stdout.write(JSON.stringify({\n hookSpecificOutput: { hookEventName: \"PreToolUse\", permissionDecision: \"deny\", permissionDecisionReason: reason },\n }) + \"\\n\");\n process.exit(0);\n}\n\nconst harnessName = (harness: Harness): string => harness === \"claude\" ? \"Claude Code\" : harness === \"cursor\" ? \"Cursor\" : \"Codex\";\nconst harnessFileName = (harness: Harness): string => harness === \"claude\" ? \".claude/settings.json\" : harness === \"cursor\" ? \".cursor/hooks.json\" : \".codex/hooks.json\";\nconst selectedHarness = (args: string[]): Harness => args.includes(\"--codex\") ? \"codex\" : args.includes(\"--cursor\") ? \"cursor\" : \"claude\";\nconst codexTrustStep = \"Open Codex, run `/hooks`, review Scopebond, and choose Trust. Then start a new task.\";\n\nasync function runPreToolUse(mapper: (input: Record<string, unknown>) => Mapped[], deny: (reason: string) => never = denyClaude): Promise<void> {\n let input: Record<string, unknown>;\n try { input = JSON.parse(readStdin()); } catch { deny(\"hook received invalid JSON on stdin\"); }\n try {\n const cwd = input?.cwd ? String(input.cwd) : process.cwd();\n const runtime = createHookRuntime(runtimePaths(resolveConfigDir(cwd)));\n const decision = await runtime.evaluate(fillPushBranch(mapper(input!), currentBranch(cwd)));\n await runtime.flush();\n if (decision.decision === \"deny\") deny(decision.reason);\n // Stay silent on allow/not_evaluated so the coding agent's normal permission\n // flow remains in charge. Scopebond blocks; it never silently approves.\n process.exit(0);\n } catch (error) {\n deny(`Scopebond hook failed closed: ${(error as Error).message}. Repair: run \\`${cliCommand(\"init\")}\\`.`);\n }\n}\n\nasync function runClaude(): Promise<void> {\n await runPreToolUse(mapClaudeToolUse);\n}\n\nasync function runCodex(): Promise<void> {\n await runPreToolUse(mapCodexToolUse, denyCodex);\n}\n\nasync function runCursor(): Promise<void> {\n let input: Record<string, unknown> = {};\n try { input = JSON.parse(readStdin()); } catch { /* fall through to fail-closed deny below */ }\n const event = String(input?.hook_event_name ?? input?.event ?? process.argv[3] ?? \"\");\n let permission: \"allow\" | \"deny\" | \"ask\" = \"deny\";\n let message = \"Scopebond hook failed closed\";\n try {\n const cwd = input?.cwd ? String(input.cwd) : process.cwd();\n const runtime = createHookRuntime(runtimePaths(resolveConfigDir(cwd)));\n const decision = await runtime.evaluate(fillPushBranch(mapCursorEvent(event, input), currentBranch(cwd)));\n await runtime.flush();\n // Only an out-of-policy action is denied outright; an allowed or unevaluated\n // action defers to Cursor's own prompt (\"ask\"), never a silent auto-allow.\n permission = decision.decision === \"deny\" ? \"deny\" : \"ask\";\n message = decision.reason;\n } catch (error) {\n permission = \"deny\";\n message = `Scopebond hook failed closed: ${(error as Error).message}. Repair: run \\`${cliCommand(\"init\")}\\`.`;\n }\n process.stdout.write(JSON.stringify({ permission, agentMessage: message }) + \"\\n\");\n process.exit(0);\n}\n\n/** `init`, `trust` and `uninstall` change what governs the agent, so they are for a\n * person at a terminal. A coding agent's shell is not interactive: without a TTY on\n * stdin they refuse unless `--yes` is passed (for scripts and CI). The starter policy\n * also denies the agent running them. */\nfunction requireInteractive(command: string, args: string[]): void {\n if (process.stdin.isTTY || args.includes(\"--yes\")) return;\n console.error(`scopebond ${command} changes what governs your coding agent, so it must be run from an interactive terminal.`);\n console.error(`In a script or CI, pass --yes: ${cliCommand(`${command} --yes`)}`);\n process.exit(1);\n}\n\nfunction runInit(args: string[]): void {\n requireInteractive(\"init\", args);\n const harness = selectedHarness(args);\n const dir = configDir();\n const { agentKid, policyPath } = scaffold(dir, { force: args.includes(\"--force\") });\n console.log(`Scopebond hook enrolled in ${dir}`);\n console.log(` machine key ${agentKid}`);\n console.log(` policy ${policyPath} (starter — edit the limits)`);\n // With a user-level install present, a project policy governs only once trusted.\n // Running init here is that decision, so pin this policy now.\n if (!process.env.SCOPEBOND_HOOK_DIR && existsSync(join(userHome(), \"policy.json\"))) {\n trustProjectPolicy(dir);\n console.log(` trusted overrides ${userHome()} here; after editing it, run \\`${cliCommand(\"trust\")}\\``);\n }\n console.log(\"\");\n // Configure the agent automatically by default (idempotent), so there is no\n // hand-editing step; --no-install prints the snippet instead.\n if (!args.includes(\"--no-install\")) {\n let file: string;\n try { file = installHarness(harness); } catch (error) { console.error((error as Error).message); process.exit(1); }\n console.log(`✓ ${harnessName(harness)} configured in ${file}`);\n if (harness === \"codex\") console.log(`\\nOne last step: ${codexTrustStep}`);\n } else {\n console.log(`Add this to your ${harnessFileName(harness)}:`);\n console.log(harnessSnippet(harness));\n }\n console.log(\"\");\n // Print the runnable `npx` form: after `npx @scopebond/hook init` there is no\n // `scopebond-hook` binary on PATH, so a bare `scopebond-hook log` would fail.\n console.log(`Next: run one command in the agent, then \\`${cliCommand(\"log\")}\\` to see the receipt`);\n console.log(`and \\`${cliCommand(\"verify\")}\\` to check it offline. Try \\`${cliCommand('test \"rm -rf /\"')}\\`.`);\n console.log(`To send receipts to a workspace: ${cliCommand(\"connect <workspace-url> <enrollment>\")}`);\n}\n\nfunction decisionOf(payload: Record<string, unknown>): string {\n const rr = String(payload.realtime_result ?? \"\");\n const state = String((payload.execution as Record<string, unknown> | undefined)?.state ?? \"\");\n if (state === \"observed_not_evaluated\") return \"not_evaluated\";\n if (rr === \"deny\") return state === \"cooperative_allow\" || state === \"executed\" ? \"monitor\" : \"deny\";\n return \"allow\";\n}\n\nfunction describeIntent(payload: Record<string, unknown>): string {\n const intent = (payload.intent ?? {}) as Record<string, unknown>;\n const p = (intent.params ?? {}) as Record<string, unknown>;\n const bits = intent.action_type === \"shell.exec\" ? String(p.program ?? \"\")\n : intent.action_type === \"git.push\" ? `${p.remote ?? \"\"} ${p.ref ?? \"\"}`.trim()\n : intent.action_type === \"file.write\" || intent.action_type === \"file.read\" ? String(p.path ?? \"\")\n : intent.action_type === \"mcp.tool.call\" ? `${p.server ?? \"\"}/${p.tool ?? \"\"}`\n : intent.action_type === \"net.fetch\" ? String(p.host ?? \"\") : \"\";\n return `${String(intent.action_type ?? \"?\")}${bits ? ` ${bits}` : \"\"}`;\n}\n\nasync function runLog(args: string[]): Promise<void> {\n const dir = resolveConfigDir(process.cwd());\n const dbPath = join(dir, \"receipts.db\");\n if (!existsSync(dbPath)) { console.log(\"no receipts yet — run a command in the agent first.\"); process.exit(0); }\n const nIdx = args.indexOf(\"-n\");\n const n = nIdx >= 0 ? Math.max(1, Number(args[nIdx + 1]) || 20) : 20;\n const { store } = openReceiptStore({ db: dbPath });\n const all = await Promise.resolve(store.list());\n const recent = all.slice(-n);\n if (recent.length === 0) { console.log(\"no receipts yet.\"); process.exit(0); }\n for (const r of recent) {\n const p = r.payload as unknown as Record<string, unknown>;\n console.log(`${String(p.timestamp ?? \"\")} ${decisionOf(p).padEnd(13)} ${describeIntent(p)}`);\n }\n console.log(`\\n${recent.length} of ${all.length} receipt(s). Verify them: ${cliCommand(\"verify\")}`);\n}\n\nasync function runVerify(): Promise<void> {\n const dir = resolveConfigDir(process.cwd());\n const dbPath = join(dir, \"receipts.db\");\n const attesterPath = join(dir, \"attester.key\");\n if (!existsSync(dbPath) || !existsSync(attesterPath)) { console.log(\"nothing to verify yet (no receipts or no attester key).\"); process.exit(0); }\n const { attester } = loadOrCreateAttester({ file: attesterPath });\n const { store } = openReceiptStore({ db: dbPath });\n const all = await Promise.resolve(store.list());\n let ok = 0;\n const bad: string[] = [];\n for (const r of all) {\n const result = verifyReceipt(r, attester.publicKeyPem) as unknown as Record<string, boolean>;\n if (result.valid) ok += 1;\n else {\n const failed = Object.entries(result).filter(([k, v]) => k.endsWith(\"_valid\") && v === false).map(([k]) => k);\n bad.push(`${String((r.payload as unknown as Record<string, unknown>).timestamp ?? \"\")}: ${failed.join(\", \") || \"invalid\"}`);\n }\n }\n console.log(`${ok}/${all.length} receipt(s) verify offline against ${attesterPath}.`);\n if (bad.length) { for (const b of bad) console.error(` ✗ ${b}`); process.exit(1); }\n process.exit(0);\n}\n\nasync function runTest(args: string[]): Promise<void> {\n const command = args.find((a) => !a.startsWith(\"-\"));\n if (!command) { console.error('usage: scopebond-hook test \"<shell command>\"'); process.exit(1); }\n const dir = resolveConfigDir(process.cwd());\n if (!existsSync(join(dir, \"policy.json\"))) { console.error(\"no policy yet — run `scopebond-hook init` first.\"); process.exit(1); }\n // Evaluate against the real policy and keys, but a throwaway store, so `test`\n // never records a receipt or exports anything.\n const tmp = mkdtempSync(join(tmpdir(), \"sb-hook-test-\"));\n try {\n const runtime = createHookRuntime({\n policyPath: join(dir, \"policy.json\"), keyPath: join(dir, \"agent.key\"),\n attesterPath: join(dir, \"attester.key\"), dbPath: join(tmp, \"receipts.db\"),\n strict: process.argv.includes(\"--strict\"),\n });\n const mapped = fillPushBranch(mapClaudeToolUse({ tool_name: \"Bash\", tool_input: { command } }), currentBranch(process.cwd()));\n console.log(`command: ${command}`);\n for (const m of mapped) {\n const d = await runtime.evaluateOne(m);\n console.log(` ${describeIntent({ intent: m.intent }).padEnd(28)} → ${d.decision}${d.reason ? ` (${d.reason})` : \"\"}`);\n }\n const overall = await runtime.evaluate(mapped);\n console.log(`\\noverall: ${overall.decision}${overall.reason ? ` · ${overall.reason}` : \"\"}`);\n process.exit(overall.decision === \"deny\" ? 2 : 0);\n } finally {\n rmSync(tmp, { recursive: true, force: true });\n }\n}\n\nasync function runConnect(args: string[]): Promise<void> {\n const positional = args.filter((a) => !a.startsWith(\"--\"));\n const url = positional[0];\n const bundleArg = positional[1];\n const harness = selectedHarness(args);\n if (!url) {\n console.error(\"usage: scopebond-hook connect <workspace-url> <enrollment> [--claude|--cursor|--codex] [--no-install]\");\n process.exit(1);\n }\n const dir = configDir();\n // One command sets everything up: scaffold the key, attester and starter policy if\n // they do not exist, then enroll and persist the scoped machine credential. The\n // enrollment can be a file, an inline base64 blob (what the portal hands out) or\n // raw JSON — the user never has to save or open a JSON file.\n scaffold(dir, {});\n let bundle: CloudEnrollmentBundle;\n try { bundle = readBundleArg(bundleArg, readStdin); }\n catch { console.error(\"could not read the enrollment (expected a file, inline blob, or JSON on stdin)\"); process.exit(1); }\n try {\n const c = await connectCloud(dir, url, bundle);\n console.log(`✓ Connected to ${c.url}`);\n // Configure the agent automatically (merges into the existing config), unless the\n // caller opts out. This removes the \"paste this snippet\" step.\n if (!args.includes(\"--no-install\")) {\n const file = installHarness(harness);\n console.log(`✓ ${harnessName(harness)} configured in ${file}`);\n if (harness === \"codex\") console.log(`\\nOne last step: ${codexTrustStep}`);\n } else {\n console.log(`Add this to your ${harnessFileName(harness)}:`);\n console.log(harnessSnippet(harness));\n }\n console.log(\"\");\n console.log(\"Run your agent — the first action appears in your workspace within seconds.\");\n } catch (error) {\n console.error(`connect failed: ${(error as Error).message}`);\n process.exit(1);\n }\n}\n\nasync function runFlush(): Promise<void> {\n const dir = resolveConfigDir(process.cwd());\n if (!loadConnection(dir)) { console.error(\"not connected to a workspace; run `scopebond-hook connect` first\"); process.exit(1); }\n const runtime = createHookRuntime(runtimePaths(dir));\n await runtime.exporter?.flush();\n const status = runtime.exporter?.status();\n runtime.exporter?.stop();\n console.log(`flushed; ${status?.pending ?? 0} receipt(s) still pending${status?.lastError ? ` (last error: ${status.lastError})` : \"\"}`);\n // Let pending HTTP handles close normally (forced exit can abort on Windows).\n process.exitCode = status && status.pending > 0 ? 1 : 0;\n}\n\n/** The absolute path to this CLI file, for registering the hook by absolute path. */\nfunction cliPath(): string {\n return fileURLToPath(import.meta.url);\n}\n\n/** `install` — the once-per-machine, user-level install (SB112). Scaffolds the\n * user home and registers the hook by absolute path in the user-level agent config,\n * so every project a developer opens is governed without a per-repo `init`. */\nfunction runInstall(args: string[]): void {\n const dir = userHome();\n const { agentKid, policyPath } = scaffold(dir, { force: args.includes(\"--force\") });\n console.log(`Scopebond installed for this user in ${dir}`);\n console.log(` machine key ${agentKid}`);\n console.log(` policy ${policyPath} (starter — edit the limits)`);\n console.log(\"\");\n const harnesses: Harness[] = args.includes(\"--codex\") ? [\"codex\"]\n : args.includes(\"--cursor\") ? [\"cursor\"]\n : args.includes(\"--claude\") ? [\"claude\"]\n : [\"claude\", ...(cursorDetected() ? [\"cursor\" as const] : []), ...(codexDetected() ? [\"codex\" as const] : [])];\n if (!args.includes(\"--no-install\")) {\n for (const h of harnesses) {\n try {\n const file = writeHarnessConfig(userHarnessFile(h), h, absoluteHookCommand(cliPath(), h));\n console.log(`✓ ${harnessName(h)} configured in ${file}`);\n } catch (error) { console.error(`✗ ${harnessName(h)}: ${(error as Error).message}`); process.exitCode = 1; }\n }\n } else {\n console.log(\"Add this to your user-level agent config:\");\n console.log(harnessSnippet(harnesses[0]));\n }\n if (harnesses.includes(\"codex\")) console.log(`\\nOne last step for Codex: ${codexTrustStep}`);\n console.log(\"\");\n console.log(`A project's own .scopebond policy applies only after you trust it there (${cliCommand(\"trust\")}).`);\n console.log(`Check it: ${cliCommand(\"doctor\")} · see decisions: ${cliCommand(\"log\")}`);\n console.log(`To send receipts to a workspace: ${cliCommand(\"connect <workspace-url> <enrollment>\")}`);\n}\n\nfunction runStatus(): void {\n const home = userHome();\n const installed = existsSync(join(home, \"policy.json\"));\n const claude = isHarnessConfigured(userHarnessFile(\"claude\"));\n const cursor = isHarnessConfigured(userHarnessFile(\"cursor\"));\n const codex = isHarnessConfigured(userHarnessFile(\"codex\"));\n const connected = !!loadConnection(resolveConfigDir(process.cwd()));\n const dbPath = join(resolveConfigDir(process.cwd()), \"receipts.db\");\n console.log(`Scopebond hook ${hookVersion()}`);\n console.log(` user home ${home} ${installed ? \"(installed)\" : \"(not installed — run `scopebond install`)\"}`);\n console.log(` active config ${resolveConfigDir(process.cwd())}`);\n const ignored = untrustedProjectPolicy(process.cwd());\n if (ignored) console.log(` project policy ${ignored} ignored — not trusted (run \\`${cliCommand(\"trust\")}\\` to use it)`);\n console.log(` Claude Code ${claude ? \"configured\" : \"not configured\"}`);\n console.log(` Cursor ${cursor ? \"configured\" : cursorDetected() ? \"detected, not configured\" : \"not detected\"}`);\n console.log(` Codex ${codex ? \"configured (approve once with /hooks)\" : codexDetected() ? \"detected, not configured\" : \"not detected\"}`);\n console.log(` cloud workspace ${connected ? \"connected\" : \"not connected (local only)\"}`);\n console.log(` local receipts ${existsSync(dbPath) ? dbPath : \"none yet\"}`);\n}\n\nasync function runDoctor(): Promise<void> {\n const problems: string[] = [];\n const [major, minor] = process.versions.node.split(\".\").map(Number);\n const nodeOk = major > 22 || (major === 22 && minor >= 13);\n console.log(`Scopebond doctor`);\n console.log(` node ${process.versions.node} ${nodeOk ? \"ok\" : \"TOO OLD (need >=22.13)\"}`);\n if (!nodeOk) problems.push(\"node >=22.13 is required (the Cloud outbox uses node:sqlite)\");\n const cli = cliPath();\n console.log(` cli ${cli} ${existsSync(cli) ? \"ok\" : \"MISSING\"}`);\n const active = resolveConfigDir(process.cwd());\n const hasPolicy = existsSync(join(active, \"policy.json\"));\n console.log(` active config ${active} ${hasPolicy ? \"ok\" : \"no policy (run `scopebond install` or `init`)\"}`);\n if (!hasPolicy) problems.push(\"no policy found in the active config dir\");\n const ignored = untrustedProjectPolicy(process.cwd());\n if (ignored) console.log(` project policy ${ignored} IGNORED — not trusted (never trusted, or edited since). Review it, then \\`${cliCommand(\"trust\")}\\``);\n const codex = isHarnessConfigured(userHarnessFile(\"codex\"));\n console.log(` Codex hook ${codex ? \"configured\" : codexDetected() ? \"not configured — run `scopebond install --codex`\" : \"not detected\"}`);\n if (codex) console.log(` Codex approval run /hooks in Codex and approve Scopebond once`);\n const connection = loadConnection(active);\n if (!connection) {\n console.log(` cloud not connected (local only) — receipts stay on this machine`);\n } else {\n let reachable = \"unknown\";\n try {\n const res = await fetch(new URL(\"/healthz\", connection.url).toString(), { method: \"GET\" });\n reachable = res.ok ? \"reachable\" : `unhealthy (${res.status})`;\n } catch (error) { reachable = `unreachable (${(error as Error).message})`; }\n console.log(` cloud ${connection.url} — ${reachable}`);\n }\n console.log(problems.length ? `\\n${problems.length} problem(s): ${problems.join(\"; \")}` : `\\nAll good.`);\n process.exitCode = problems.length ? 1 : 0;\n}\n\nfunction runUninstall(args: string[]): void {\n requireInteractive(\"uninstall\", args);\n let removed = 0;\n for (const h of [\"claude\", \"cursor\", \"codex\"] as Harness[]) {\n if (removeHarnessConfig(userHarnessFile(h))) { console.log(`✓ removed the Scopebond hook from ${userHarnessFile(h)}`); removed++; }\n }\n if (removed === 0) console.log(\"no user-level harness config found.\");\n if (args.includes(\"--purge\")) { purgeHome(); console.log(`✓ purged ${userHome()} (keys, policy, receipts)`); }\n else console.log(`Kept ${userHome()} (keys, policy, receipts). Use --purge to remove it too.`);\n}\n\n/** `trust` — let this project's .scopebond policy govern here instead of the user\n * home, pinned to its current contents. Run by the user, not the agent: the file it\n * writes lives in the user home, which the starter policy write-protects. */\nfunction runTrust(args: string[]): void {\n requireInteractive(\"trust\", args);\n const dir = join(process.cwd(), \".scopebond\");\n if (!existsSync(join(dir, \"policy.json\"))) { console.error(`no project policy at ${join(dir, \"policy.json\")}`); process.exit(1); }\n const digest = trustProjectPolicy(dir);\n console.log(`✓ trusted ${join(dir, \"policy.json\")} (sha256 ${digest.slice(0, 12)}…)`);\n console.log(\"It governs agents in this project until it changes; after any edit, review it and run trust again.\");\n}\n\nfunction runLogin(): void {\n console.log(\"Device-code login is not available yet.\");\n console.log(`For now, connect with a one-time enrollment from your workspace:`);\n console.log(` ${cliCommand(\"connect <workspace-url> <enrollment>\")}`);\n process.exit(0);\n}\n\nconst [cmd, ...rest] = process.argv.slice(2);\nif (cmd === \"claude\") { await runClaude(); }\nelse if (cmd === \"cursor\") { await runCursor(); }\nelse if (cmd === \"codex\") { await runCodex(); }\nelse if (cmd === \"init\") { runInit(rest); }\nelse if (cmd === \"install\") { runInstall(rest); }\nelse if (cmd === \"connect\") { await runConnect(rest); }\nelse if (cmd === \"log\") { await runLog(rest); }\nelse if (cmd === \"verify\") { await runVerify(); }\nelse if (cmd === \"test\") { await runTest(rest); }\nelse if (cmd === \"flush\") { await runFlush(); }\nelse if (cmd === \"status\") { runStatus(); }\nelse if (cmd === \"doctor\") { await runDoctor(); }\nelse if (cmd === \"uninstall\") { runUninstall(rest); }\nelse if (cmd === \"login\") { runLogin(); }\nelse if (cmd === \"trust\") { runTrust(rest); }\nelse {\n console.error(\"usage: scopebond <claude|cursor|codex|init|install|connect|log|verify|test|flush|status|doctor|uninstall|login|trust> [--cursor] [--claude] [--codex] [--force] [--strict] [--no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C,CAAC,CAAC;AAAC,CAAC;KACpG,CAAC;IACJ,OAAO,CAAC,KAAK,CAAC,oBAAoB,GAAG,EAAE,CAAC,CAAC;IACzC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","sourcesContent":["#!/usr/bin/env node\n// scopebond-hook — govern a coding agent's tool calls against policy, in-path,\n// before they run, with a signed local receipt.\n//\n// The command list, arguments and examples live in `COMMANDS` near the bottom of this\n// file, which is what `scopebond-hook help [command]` prints — one source rather than a\n// comment here that drifts from it.\n//\n// Config dir: $SCOPEBOND_HOOK_DIR, else ./.scopebond\n// Fail-closed: any error denies the action with a repair message.\n\n// `node:sqlite` (the receipt store) is still flagged experimental on Node 22, and Node\n// prints a warning on stderr the first time it loads — on every `verify`, and into the\n// agent's transcript on every hook call. It is a notice about Node, not about the user's\n// setup, so it is dropped; every other warning still prints through Node's own handler.\n// (The store is required lazily, after this module has run, so the filter is in place.)\n{\n const nodeWarningHandlers = process.listeners(\"warning\");\n process.removeAllListeners(\"warning\");\n process.on(\"warning\", (warning) => {\n if (warning.name === \"ExperimentalWarning\" && /sqlite/i.test(warning.message)) return;\n for (const handler of nodeWarningHandlers) handler.call(process, warning);\n });\n}\n\nimport { readFileSync, writeFileSync, existsSync, mkdtempSync, rmSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { hostname, tmpdir } from \"node:os\";\nimport { execFileSync } from \"node:child_process\";\nimport type { CloudEnrollmentBundle } from \"@scopebond/gateway\";\nimport { verifyReceipt } from \"@scopebond/gateway\";\nimport { openReceiptStore, loadOrCreateAttester } from \"@scopebond/gateway/node\";\nimport { mapClaudeToolUse, mapCodexToolUse, mapCursorEvent, fillPushBranch, type Mapped } from \"./map.js\";\nimport { createHookRuntime } from \"./runtime.js\";\nimport { useDigestKey, loadOrCreateDigestKey } from \"./minimize.js\";\nimport { scaffold, harnessSnippet, placeHook, type HookPlacement } from \"./init.js\";\nimport {\n userHome, userHarnessFile, resolveConfigDir, writeHarnessConfig, removeHarnessConfig,\n cursorDetected, codexDetected, absoluteHookCommand, isHarnessConfigured, purgeHome, type Harness,\n harnessScopes, harnessScopeLabel, configuredHookCommands, hookCommandResolves, projectHarnessFile,\n localHarnessFile, gitShareState, isMachineSpecificCommand, trustProjectPolicy, untrustedProjectPolicy,\n} from \"./install.js\";\nimport { connectCloud, loadConnection, connectionPath } from \"./cloud.js\";\nimport { compile, defaultRules, describeRules, loadRules, saveRules, rulesPath, pathRuleFor } from \"./rules.js\";\nimport { createSigner } from \"@scopebond/sdk\";\nimport { describeAction, type ExplainIntent } from \"./explain.js\";\nimport { ensureDurableRuntime, pinnedCliPath, isEphemeralPath } from \"./runtime-install.js\";\nimport { cliCommand, hookCommand, hookVersion } from \"./version.js\";\nimport { fileURLToPath } from \"node:url\";\n\n/** The current git branch in `cwd` (best-effort). A bare `git push` pushes it, so\n * the runtime fills it in before evaluating; on failure the ref stays absent and\n * the starter policy fails closed. */\nfunction currentBranch(cwd: string): string | null {\n try {\n return execFileSync(\"git\", [\"-C\", cwd, \"symbolic-ref\", \"--quiet\", \"--short\", \"HEAD\"], {\n encoding: \"utf8\", stdio: [\"ignore\", \"pipe\", \"ignore\"],\n }).trim() || null;\n } catch { return null; }\n}\n\n/** Read an enrollment bundle from a file path, an inline base64 blob, or inline raw\n * JSON (the portal hands out a base64 blob so it is one clean argument). */\nfunction readBundleArg(bundleArg: string | undefined, stdin: () => string): CloudEnrollmentBundle {\n let text: string;\n if (!bundleArg) text = stdin();\n else if (existsSync(bundleArg)) text = readFileSync(bundleArg, \"utf8\");\n else if (bundleArg.trim().startsWith(\"{\")) text = bundleArg;\n else { try { text = Buffer.from(bundleArg, \"base64\").toString(\"utf8\"); } catch { text = bundleArg; } }\n return JSON.parse(text) as CloudEnrollmentBundle;\n}\n\nfunction configDir(): string {\n return process.env.SCOPEBOND_HOOK_DIR ?? join(process.cwd(), \".scopebond\");\n}\nfunction runtimePaths(dir: string) {\n const connection = loadConnection(dir);\n return {\n policyPath: join(dir, \"policy.json\"),\n keyPath: join(dir, \"agent.key\"),\n attesterPath: join(dir, \"attester.key\"),\n dbPath: join(dir, \"receipts.db\"),\n // Strict: deny (not just observe) tools with no taxonomy mapping.\n strict: process.argv.includes(\"--strict\") || process.env.SCOPEBOND_HOOK_STRICT === \"1\",\n // When connected, auto-export receipts. A short bounded flush keeps the hot path\n // fast; undelivered receipts persist in the durable outbox and flush next time\n // (or via `scopebond-hook flush`, e.g. on a session-end hook).\n ...(connection ? { cloud: { connection, flushTimeoutMs: Number(process.env.SCOPEBOND_HOOK_FLUSH_MS ?? 800) } } : {}),\n };\n}\nfunction readStdin(): string {\n try { return readFileSync(0, \"utf8\"); } catch { return \"\"; }\n}\n\nfunction denyClaude(reason: string): never {\n process.stdout.write(JSON.stringify({\n hookSpecificOutput: { hookEventName: \"PreToolUse\", permissionDecision: \"deny\", permissionDecisionReason: reason },\n }) + \"\\n\");\n // A composed explanation already names Scopebond in its first line; only the\n // bare internal messages need the prefix.\n process.stderr.write(`${reason.startsWith(\"Scopebond\") ? reason : `Scopebond: ${reason}`}\\n`);\n process.exit(2);\n}\n\n/** Codex accepts the structured deny response on a successful hook exit. Keeping\n * exit 0 lets its UI show a completed policy check instead of a failed hook while\n * still preventing the tool call. */\nfunction denyCodex(reason: string): never {\n process.stdout.write(JSON.stringify({\n hookSpecificOutput: { hookEventName: \"PreToolUse\", permissionDecision: \"deny\", permissionDecisionReason: reason },\n }) + \"\\n\");\n process.exit(0);\n}\n\nconst harnessName = (harness: Harness): string => harness === \"claude\" ? \"Claude Code\" : harness === \"cursor\" ? \"Cursor\" : \"Codex\";\nconst harnessFileName = (harness: Harness): string => harness === \"claude\" ? \".claude/settings.json\" : harness === \"cursor\" ? \".cursor/hooks.json\" : \".codex/hooks.json\";\nconst selectedHarness = (args: string[]): Harness => args.includes(\"--codex\") ? \"codex\" : args.includes(\"--cursor\") ? \"cursor\" : \"claude\";\nconst codexTrustStep = \"Open Codex, run `/hooks`, review Scopebond, and choose Trust. Then start a new task.\";\n/** What Cursor can and cannot stop. Cursor has before-hooks for shell commands, MCP\n * calls and file reads, but reports file *edits* only after they are written, so an\n * out-of-policy edit is recorded and flagged rather than prevented. Said at install\n * time, because someone choosing a guardrail needs to know its edges up front. */\nconst cursorCoverageNote = [\n \"What this covers in Cursor:\",\n \" prevented shell commands, MCP tool calls, file reads — checked before they run\",\n \" recorded file edits — Cursor reports an edit only after writing it, so an\",\n \" out-of-policy edit is signed and flagged, not blocked\",\n \"For edits that must be blocked before they land, use the GitHub Action as a required\",\n \"check on pull requests.\",\n].join(\"\\n\");\n\nasync function runPreToolUse(mapper: (input: Record<string, unknown>) => Mapped[], deny: (reason: string) => never = denyClaude): Promise<void> {\n let input: Record<string, unknown>;\n try { input = JSON.parse(readStdin()); } catch { deny(\"hook received invalid JSON on stdin\"); }\n let runtime: ReturnType<typeof createHookRuntime> | undefined;\n try {\n const cwd = input?.cwd ? String(input.cwd) : process.cwd();\n const dir = resolveConfigDir(cwd);\n runtime = createHookRuntime(runtimePaths(dir));\n useDigestKey(loadOrCreateDigestKey(dir));\n const decision = await runtime.evaluate(fillPushBranch(mapper(input!), currentBranch(cwd)));\n await runtime.flush();\n // Close before deciding: the receipt is already committed, and leaving the handle\n // open is what made the write-ahead log grow without bound.\n runtime.close();\n runtime = undefined;\n if (decision.decision === \"deny\") deny(decision.reason);\n // Stay silent on allow/not_evaluated so the coding agent's normal permission\n // flow remains in charge. Scopebond blocks; it never silently approves.\n process.exit(0);\n } catch (error) {\n try { runtime?.close(); } catch { /* already failing; the deny below is what matters */ }\n deny(`Scopebond hook failed closed: ${(error as Error).message}. Repair: run \\`${cliCommand(\"init\")}\\`.`);\n }\n}\n\nasync function runClaude(): Promise<void> {\n await runPreToolUse(mapClaudeToolUse);\n}\n\nasync function runCodex(): Promise<void> {\n await runPreToolUse(mapCodexToolUse, denyCodex);\n}\n\nfunction denyCursor(reason: string): never {\n process.stdout.write(JSON.stringify({ permission: \"deny\", agentMessage: reason }) + \"\\n\");\n process.exit(0);\n}\n\nasync function runCursor(): Promise<void> {\n // Unparseable input denies, like every other adapter. Previously this fell through\n // to evaluation with an empty payload, which mapped to no known action and so\n // answered \"ask\" — handing an unreadable request to a prompt the user would very\n // likely accept. Deny-by-default on unparseable input is not optional.\n let parsed: unknown;\n try { parsed = JSON.parse(readStdin()); } catch { denyCursor(\"Scopebond: hook received invalid JSON on stdin\"); }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n denyCursor(\"Scopebond: hook received a payload that is not a JSON object\");\n }\n const input = parsed as Record<string, unknown>;\n const event = String(input.hook_event_name ?? input.event ?? process.argv[3] ?? \"\");\n let permission: \"allow\" | \"deny\" | \"ask\" = \"deny\";\n let message = \"Scopebond hook failed closed\";\n let postHoc = false;\n let runtime: ReturnType<typeof createHookRuntime> | undefined;\n try {\n const cwd = input?.cwd ? String(input.cwd) : process.cwd();\n const dir = resolveConfigDir(cwd);\n runtime = createHookRuntime(runtimePaths(dir));\n useDigestKey(loadOrCreateDigestKey(dir));\n const mapped = fillPushBranch(mapCursorEvent(event, input), currentBranch(cwd));\n const decision = await runtime.evaluate(mapped);\n await runtime.flush();\n // An `afterFileEdit` violation is real and recorded, but the edit has already\n // landed. Say so rather than letting \"blocked\" imply it was stopped.\n postHoc = mapped.some((m) => m.postHoc);\n // Three outcomes, three answers:\n // deny — out of policy, blocked outright.\n // allow — a rule was evaluated and permitted it. Returning \"ask\" here put a\n // confirmation prompt in front of every ordinary command, which is not\n // \"your agent works as normal\"; it also trained people to click through\n // prompts, which makes the real denials easier to miss. An evaluated\n // allow is a decision, not a silent auto-approval.\n // ask — nothing was evaluated (no rule covers this action), so Cursor's own\n // permission flow stays in charge. That is the fail-closed case and it\n // keeps its prompt.\n permission = decision.decision === \"deny\" ? \"deny\" : decision.decision === \"allow\" ? \"allow\" : \"ask\";\n message = decision.reason;\n } catch (error) {\n permission = \"deny\";\n message = `Scopebond hook failed closed: ${(error as Error).message}. Repair: run \\`${cliCommand(\"init\")}\\`.`;\n } finally {\n // Release the SQLite handles on every path: an unclosed writer leaves its\n // write-ahead log behind for the next tool call to extend.\n try { runtime?.close(); } catch { /* the decision is already recorded */ }\n }\n if (postHoc && permission === \"deny\") {\n message = `${message}\\nCursor reports a file edit only after it is written, so this edit was not prevented. Review and revert it yourself.`;\n }\n process.stdout.write(JSON.stringify({ permission, agentMessage: message }) + \"\\n\");\n process.exit(0);\n}\n\n/** `init`, `trust` and `uninstall` change what governs the agent, so they are for a\n * person at a terminal. A coding agent's shell is not interactive: without a TTY on\n * stdin they refuse unless `--yes` is passed (for scripts and CI). The starter policy\n * also denies the agent running them. */\nfunction requireInteractive(command: string, args: string[]): void {\n if (process.stdin.isTTY || args.includes(\"--yes\")) return;\n console.error(`scopebond ${command} changes what governs your coding agent, so it does not run unattended.`);\n console.error(`There is no terminal on stdin here — which is also what it looks like when the agent itself`);\n console.error(`tries to run this, so the refusal is deliberate rather than a bug.`);\n console.error(``);\n console.error(`If you are a person: run it in your own terminal, or confirm it now with --yes:`);\n console.error(` ${cliCommand(`${command} --yes`)}`);\n console.error(`Scripts, CI and container builds should always pass --yes.`);\n process.exit(1);\n}\n\nfunction runInit(args: string[]): void {\n const harness = selectedHarness(args);\n const dir = configDir();\n // A dry run changes nothing, so it needs no terminal and no --yes.\n if (args.includes(\"--dry-run\")) {\n const shared = projectHarnessFile(harness, process.cwd());\n const local = localHarnessFile(harness, process.cwd());\n const personal = args.includes(\"--shared\") || args.includes(\"--npx\") ? null\n : local ?? (gitShareState(shared) === \"tracked\" ? null : shared);\n console.log(`Dry run — nothing is written.\\n`);\n console.log(`Would scaffold ${dir} (machine key, countersigning key, starter policy, .gitignore)`);\n if (args.includes(\"--no-install\")) {\n console.log(`Would print the ${harnessFileName(harness)} snippet instead of writing it`);\n } else if (personal) {\n console.log(`Would configure ${personal} (this machine only; kept out of git)`);\n console.log(` adding hook \"<node>\" \"${pinnedCliPath(hookVersion())}\" ${harness}`);\n console.log(` (or the path this copy runs from, when it is already installed durably)`);\n if (local) console.log(` and remove any machine-specific Scopebond entry from ${shared}`);\n } else {\n console.log(`Would configure ${shared} (shared — safe to commit)`);\n console.log(` adding hook ${hookCommand(harness)}`);\n }\n console.log(`\\nNothing else in those files is changed. Run without --dry-run to apply.`);\n process.exit(0);\n }\n requireInteractive(\"init\", args);\n const { agentKid, policyPath, rulesPath: rulesFile } = scaffold(dir, { force: args.includes(\"--force\") });\n console.log(`Scopebond hook enrolled in ${dir}`);\n console.log(` machine key ${agentKid}`);\n console.log(` rules ${rulesFile} (the readable list — edit this)`);\n console.log(` policy ${policyPath} (compiled from the rules; don't hand-edit)`);\n // With a user-level install present, a project policy governs only once trusted.\n // Running init here is that decision, so pin this policy now.\n if (!process.env.SCOPEBOND_HOOK_DIR && existsSync(join(userHome(), \"policy.json\"))) {\n trustProjectPolicy(dir);\n console.log(` trusted overrides ${userHome()} here; after editing it, run \\`${cliCommand(\"trust\")}\\``);\n }\n // The hook command runs once per tool call, so it must start fast. `npx` re-resolves\n // a package that is already on disk and costs ~830 ms a call; the same CLI invoked\n // directly costs ~110 ms. Pin a durable copy and use that, and fall back to `npx`\n // (slow, but it always starts) when no durable copy can be made. `--npx` forces the\n // portable form for anyone who wants it.\n const shared = args.includes(\"--shared\");\n const pin = args.includes(\"--npx\") || shared ? { cli: null, how: \"unavailable\" as const } : ensureDurableRuntime(cliPath(), hookVersion());\n const command = pin.cli ? absoluteHookCommand(pin.cli, harness) : undefined;\n // Configure the agent automatically by default (idempotent), so there is no\n // hand-editing step; --no-install prints the snippet instead.\n if (!args.includes(\"--no-install\")) {\n let placed: HookPlacement;\n try { placed = placeHook(harness, process.cwd(), command, { shared }); } catch (error) { console.error((error as Error).message); process.exit(1); }\n // No per-action millisecond claim here: it varies by machine, and this project only\n // states numbers it has measured. The measured comparison lives in the changelog.\n console.log(` hook runtime ${placed.scope === \"personal\"\n ? `${pin.cli}\\n pinned — no npx resolution per action`\n : `npx @scopebond/hook@${hookVersion()} — portable, but re-resolves on every action`}`);\n console.log(\"\");\n console.log(`✓ ${harnessName(harness)} configured in ${placed.file}`);\n console.log(placed.scope === \"personal\"\n ? ` this machine only — kept out of git, so no teammate inherits a path that does not exist for them`\n : ` shared — the portable command starts on any machine that clones this project`);\n if (placed.repaired > 0) console.log(` moved a machine-specific hook out of ${projectHarnessFile(harness, process.cwd())}; commit that change`);\n if (placed.note) console.log(` note: ${placed.note}`);\n if (harness === \"codex\") console.log(`\\nOne last step: ${codexTrustStep}`);\n if (harness === \"cursor\") console.log(`\\n${cursorCoverageNote}`);\n } else {\n // The snippet is for a file the user will likely commit, so it carries the portable\n // command; the pinned one is offered separately, for a file only this machine uses.\n console.log(`Add this to your ${harnessFileName(harness)}:`);\n console.log(harnessSnippet(harness));\n const local = localHarnessFile(harness, process.cwd());\n if (command && local) {\n console.log(`\\nFaster, for this machine only — use this command in ${local} instead (keep that file out of git):`);\n console.log(` ${command}`);\n }\n if (harness === \"cursor\") console.log(`\\n${cursorCoverageNote}`);\n }\n console.log(\"\");\n // Print the runnable `npx` form: after `npx @scopebond/hook init` there is no\n // `scopebond-hook` binary on PATH, so a bare `scopebond-hook log` would fail.\n console.log(`Next: run one command in the agent, then \\`${cliCommand(\"log\")}\\` to see the receipt`);\n console.log(`and \\`${cliCommand(\"verify\")}\\` to check it offline. Try \\`${cliCommand('test \"rm -rf /\"')}\\`.`);\n console.log(`To send receipts to a workspace: ${cliCommand(\"connect <workspace-url> <enrollment>\")}`);\n}\n\nfunction decisionOf(payload: Record<string, unknown>): string {\n const rr = String(payload.realtime_result ?? \"\");\n const state = String((payload.execution as Record<string, unknown> | undefined)?.state ?? \"\");\n if (state === \"observed_not_evaluated\") return \"not_evaluated\";\n if (rr === \"deny\") return state === \"cooperative_allow\" || state === \"executed\" ? \"monitor\" : \"deny\";\n return \"allow\";\n}\n\nfunction describeIntent(payload: Record<string, unknown>): string {\n return describeAction(payload.intent as ExplainIntent | undefined);\n}\n\n/** `log [-n N] [--deny] [--since <when>]` — the recent decisions.\n *\n * \"What did my agents get blocked on this week\" had no answer at the CLI: the only\n * output was an unfiltered tail. `--deny` and `--since` make it answerable, and the\n * tail is read as a tail (`ORDER BY id DESC LIMIT`) rather than by loading and parsing\n * every receipt ever recorded and slicing the end off. */\nasync function runLog(args: string[]): Promise<void> {\n const dir = resolveConfigDir(process.cwd());\n const dbPath = join(dir, \"receipts.db\");\n if (!existsSync(dbPath)) { console.log(\"no receipts yet — run a command in the agent first.\"); process.exit(0); }\n const nIdx = args.indexOf(\"-n\");\n const n = nIdx >= 0 ? Math.max(1, Number(args[nIdx + 1]) || 20) : 20;\n const denyOnly = args.includes(\"--deny\");\n const sinceIdx = args.indexOf(\"--since\");\n const since = sinceIdx >= 0 ? parseSince(args[sinceIdx + 1]) : null;\n if (sinceIdx >= 0 && since === null) {\n console.error(`--since wants a duration (7d, 24h, 30m) or a date (2026-09-25); got ${args[sinceIdx + 1] ?? \"nothing\"}`);\n process.exit(1);\n }\n const { store } = openReceiptStore({ db: dbPath });\n try {\n const total = store.count ? await Promise.resolve(store.count()) : (await Promise.resolve(store.list())).length;\n // A filter has to look past the last N to find N matches; without one, read only the\n // tail. The scan is still bounded so a huge log cannot hang the command.\n const budget = denyOnly || since ? Math.min(Math.max(n * 50, 1000), 20000) : n;\n const scanned = store.recent\n ? await Promise.resolve(store.recent(budget))\n : (await Promise.resolve(store.list())).slice(-budget).reverse();\n const matching = scanned.filter((r) => {\n const p = r.payload as unknown as Record<string, unknown>;\n if (denyOnly && decisionOf(p) !== \"deny\") return false;\n if (since) {\n const at = Date.parse(String(p.timestamp ?? \"\"));\n if (!Number.isFinite(at) || at < since) return false;\n }\n return true;\n });\n const shown = matching.slice(0, n).reverse(); // oldest-first on screen, newest last\n if (shown.length === 0) {\n console.log(denyOnly || since ? \"no receipts match that filter.\" : \"no receipts yet.\");\n process.exit(0);\n }\n for (const r of shown) {\n const p = r.payload as unknown as Record<string, unknown>;\n console.log(`${String(p.timestamp ?? \"\")} ${decisionOf(p).padEnd(13)} ${describeIntent(p)}`);\n }\n const filters = [denyOnly ? \"denied\" : \"\", since ? `since ${new Date(since).toISOString()}` : \"\"].filter(Boolean).join(\", \");\n const scope = filters ? ` matching ${filters}` : \"\";\n const capped = (denyOnly || since) && scanned.length >= budget && total > budget;\n console.log(`\\n${shown.length}${scope} of ${total} receipt(s)${capped ? ` — searched the most recent ${budget}` : \"\"}. Verify them: ${cliCommand(\"verify\")}`);\n } finally {\n try { store.close?.(); } catch { /* read-only */ }\n }\n}\n\n/** `rules` — read and change the limits in plain terms.\n *\n * Without this, \"edit the limits\" meant hand-writing a ~700-character case-folded\n * negative lookahead, which nobody does — so the starter policy was effectively the only\n * policy. The lists live in `.scopebond/rules.json`; `policy.json` is compiled from them. */\nfunction runRules(args: string[]): void {\n const dir = resolveConfigDir(process.cwd());\n if (!existsSync(join(dir, \"policy.json\"))) {\n console.error(`no policy here yet — run \\`${cliCommand(\"init\")}\\` first.`);\n process.exit(1);\n }\n const rules = loadRules(dir) ?? defaultRules();\n const [verb, ...values] = args.filter((a) => !a.startsWith(\"--\"));\n const value = values.join(\" \").trim();\n\n if (!verb || verb === \"show\") {\n console.log(`Rules for ${dir}`);\n if (!loadRules(dir)) console.log(`(showing the defaults — ${rulesPath(dir)} will be written on your first change)`);\n console.log(\"\");\n console.log(describeRules(rules));\n console.log(\"\");\n console.log(`Change them:`);\n console.log(` ${cliCommand(\"rules allow <program>\")} stop blocking a program`);\n console.log(` ${cliCommand(\"rules block <program>\")} start blocking one`);\n console.log(` ${cliCommand(\"rules protect <path>\")} never write there`);\n console.log(` ${cliCommand(\"rules unprotect <path>\")} allow writing there again`);\n console.log(` ${cliCommand(\"rules protect-branch <name>\")} never push there`);\n console.log(` ${cliCommand(\"rules unprotect-branch <name>\")}`);\n console.log(`Or edit ${rulesPath(dir)} directly, then \\`${cliCommand(\"rules apply\")}\\`.`);\n process.exit(0);\n }\n\n const needsValue = [\"allow\", \"block\", \"protect\", \"unprotect\", \"protect-branch\", \"unprotect-branch\"];\n if (needsValue.includes(verb) && !value) {\n console.error(`\\`rules ${verb}\\` needs a value, e.g. \\`${cliCommand(`rules ${verb} ${verb.includes(\"branch\") ? \"production\" : verb.includes(\"protect\") ? \"infra/\" : \"dd\"}`)}\\``);\n process.exit(1);\n }\n\n let changed = \"\";\n switch (verb) {\n case \"allow\": {\n const before = rules.destructive_programs.length;\n rules.destructive_programs = rules.destructive_programs.filter((p) => p.toLowerCase() !== value.toLowerCase());\n if (rules.destructive_programs.length === before) { console.log(`${value} was not in the blocked list; nothing to change.`); process.exit(0); }\n changed = `${value} is no longer blocked`;\n break;\n }\n case \"block\": {\n if (rules.destructive_programs.some((p) => p.toLowerCase() === value.toLowerCase())) { console.log(`${value} is already blocked.`); process.exit(0); }\n rules.destructive_programs.push(value.toLowerCase());\n changed = `${value} is now blocked`;\n break;\n }\n case \"protect\": case \"unprotect\": {\n const list = verb === \"protect\" ? \"protected_write\" : \"protected_write\";\n const rule = pathRuleFor(value);\n if (verb === \"protect\") {\n if (rules[list].some((r) => r.label === rule.label)) { console.log(`${value} is already protected.`); process.exit(0); }\n rules[list].push(rule);\n changed = `writes to ${rule.label} are now blocked`;\n } else {\n const before = rules[list].length;\n rules[list] = rules[list].filter((r) => r.label !== rule.label && !r.label.startsWith(`${value.replace(/\\/$/, \"\")}/`));\n if (rules[list].length === before) {\n console.log(`${value} is not in the protected list. Current list:`);\n for (const r of rules[list]) console.log(` ${r.label}`);\n process.exit(1);\n }\n changed = `writes to ${value} are allowed again`;\n }\n break;\n }\n case \"protect-branch\": {\n if (rules.protected_branches.some((b) => b.toLowerCase() === value.toLowerCase())) { console.log(`${value} is already protected.`); process.exit(0); }\n rules.protected_branches.push(value);\n changed = `pushes to ${value} are now blocked`;\n break;\n }\n case \"unprotect-branch\": {\n const before = rules.protected_branches.length;\n rules.protected_branches = rules.protected_branches.filter((b) => b.toLowerCase() !== value.toLowerCase());\n if (rules.protected_branches.length === before) { console.log(`${value} was not protected; nothing to change.`); process.exit(0); }\n changed = `pushes to ${value} are allowed again`;\n break;\n }\n case \"apply\":\n changed = `recompiled from ${rulesPath(dir)}`;\n break;\n default:\n console.error(`unknown: rules ${verb}`);\n printHelp(\"rules\", true);\n process.exit(1);\n }\n\n // Changing what governs the agent is the same class of action as `init`.\n requireInteractive(\"rules\", args);\n const policyPath = join(dir, \"policy.json\");\n const agentKid = createSigner({ privateKeyPem: readFileSync(join(dir, \"agent.key\"), \"utf8\") }).kid;\n saveRules(dir, rules);\n writeFileSync(policyPath, `${JSON.stringify(compile(rules, agentKid), null, 2)}\\n`);\n console.log(`✓ ${changed}`);\n console.log(` rules ${rulesPath(dir)}`);\n console.log(` policy ${policyPath} (recompiled)`);\n // A project policy governs only once trusted, and the hash just changed.\n if (!process.env.SCOPEBOND_HOOK_DIR && existsSync(join(userHome(), \"policy.json\"))) {\n trustProjectPolicy(dir);\n console.log(` trusted re-pinned for this project`);\n }\n console.log(`\\nCheck it: ${cliCommand('test \"rm -rf /\"')}`);\n process.exit(0);\n}\n\n/** `prune --before <when> [--yes]` — bound the local receipt store.\n *\n * Signed receipts are the product, so this never runs on its own and never quietly\n * destroys anything: it archives what it will remove to a JSONL file beside the\n * database first, and it refuses entirely once the log has been anchored, because a\n * receipt's position is its anchor leaf index. Without a `--before` it reports the\n * footprint and exits. */\nasync function runPrune(args: string[]): Promise<void> {\n const dir = resolveConfigDir(process.cwd());\n const dbPath = join(dir, \"receipts.db\");\n if (!existsSync(dbPath)) { console.log(\"no local receipts yet — nothing to prune.\"); process.exit(0); }\n const beforeIdx = args.indexOf(\"--before\");\n if (beforeIdx < 0) {\n console.log(`local receipts ${dbPath}`);\n console.log(` ${describeStore(dbPath)}`);\n console.log(`\\nNothing is removed automatically. To bound it, name a cutoff:`);\n console.log(` ${cliCommand(\"prune --before 90d\")} # older than 90 days`);\n console.log(` ${cliCommand(\"prune --before 2026-01-01\")}`);\n console.log(`Receipts are archived beside the database before removal.`);\n process.exit(0);\n }\n const cutoff = parseSince(args[beforeIdx + 1]);\n if (cutoff === null) {\n console.error(`--before wants a duration (90d, 24h) or a date (2026-01-01); got ${args[beforeIdx + 1] ?? \"nothing\"}`);\n process.exit(1);\n }\n const iso = new Date(cutoff).toISOString();\n const { store } = openReceiptStore({ db: dbPath });\n const sqlite = store as typeof store & {\n before?(iso: string): unknown[];\n removeBefore?(iso: string): { removed: number };\n };\n if (!sqlite.before || !sqlite.removeBefore) {\n console.error(\"this receipt store does not support pruning (no SQLite available).\");\n process.exit(1);\n }\n try {\n const doomed = sqlite.before(iso);\n if (doomed.length === 0) { console.log(`no receipts older than ${iso}.`); process.exit(0); }\n const before = describeStore(dbPath);\n console.log(`${doomed.length} receipt(s) recorded before ${iso} (store is currently ${before}).`);\n if (!args.includes(\"--yes\") && !process.stdin.isTTY) {\n console.error(`\\nThis removes signed evidence, so it needs an explicit confirmation:`);\n console.error(` ${cliCommand(`prune --before ${args[beforeIdx + 1]} --yes`)}`);\n process.exit(1);\n }\n const archive = join(dir, `receipts-archived-${new Date().toISOString().replace(/[:.]/g, \"-\")}.jsonl`);\n writeFileSync(archive, `${doomed.map((r) => JSON.stringify(r)).join(\"\\n\")}\\n`);\n console.log(`archived to ${archive}`);\n const { removed } = sqlite.removeBefore(iso);\n console.log(`removed ${removed} receipt(s)`);\n store.close?.();\n console.log(`store now ${describeStore(dbPath)}`);\n console.log(`\\nThe archive is a plain JSONL of signed receipts — still verifiable, still yours.`);\n process.exit(0);\n } catch (error) {\n try { store.close?.(); } catch { /* closing after a failure */ }\n console.error(`prune refused: ${(error as Error).message}`);\n process.exit(1);\n }\n}\n\n/** A `--since` value: a duration (`7d`, `24h`, `30m`) or an ISO-ish date. */\nexport function parseSince(value: string | undefined, now: number = Date.now()): number | null {\n if (!value) return null;\n const duration = /^(\\d+)\\s*([dhm])$/i.exec(value.trim());\n if (duration) {\n const scale = { d: 86_400_000, h: 3_600_000, m: 60_000 }[duration[2].toLowerCase() as \"d\" | \"h\" | \"m\"];\n return now - Number(duration[1]) * scale;\n }\n const at = Date.parse(value);\n return Number.isFinite(at) ? at : null;\n}\n\nasync function runVerify(): Promise<void> {\n const dir = resolveConfigDir(process.cwd());\n const dbPath = join(dir, \"receipts.db\");\n const attesterPath = join(dir, \"attester.key\");\n if (!existsSync(dbPath) || !existsSync(attesterPath)) { console.log(\"nothing to verify yet (no receipts or no attester key).\"); process.exit(0); }\n const { attester } = loadOrCreateAttester({ file: attesterPath });\n const { store } = openReceiptStore({ db: dbPath });\n // Verification is the one command that must read everything — that is the point of it.\n // It just should not look hung while doing so: at ~2.6 s per 20,000 receipts a long\n // history is a visible wait, so report progress on a TTY.\n const all = await Promise.resolve(store.list());\n try { store.close?.(); } catch { /* read-only */ }\n const progress = process.stdout.isTTY && all.length >= 2000;\n let ok = 0;\n const bad: string[] = [];\n for (const [index, r] of all.entries()) {\n const result = verifyReceipt(r, attester.publicKeyPem) as unknown as Record<string, boolean>;\n if (result.valid) ok += 1;\n else {\n const failed = Object.entries(result).filter(([k, v]) => k.endsWith(\"_valid\") && v === false).map(([k]) => k);\n bad.push(`${String((r.payload as unknown as Record<string, unknown>).timestamp ?? \"\")}: ${failed.join(\", \") || \"invalid\"}`);\n }\n if (progress && (index + 1) % 1000 === 0) process.stderr.write(`\\rverifying ${index + 1}/${all.length}…`);\n }\n if (progress) process.stderr.write(\"\\r\".padEnd(40) + \"\\r\");\n console.log(`${ok}/${all.length} receipt(s) verify offline against ${attesterPath}.`);\n if (bad.length) { for (const b of bad) console.error(` ✗ ${b}`); process.exit(1); }\n process.exit(0);\n}\n\nasync function runTest(args: string[]): Promise<void> {\n const command = args.find((a) => !a.startsWith(\"-\"));\n if (!command) { console.error('usage: scopebond-hook test \"<shell command>\"'); process.exit(1); }\n const dir = resolveConfigDir(process.cwd());\n if (!existsSync(join(dir, \"policy.json\"))) { console.error(`no policy yet — run \\`${cliCommand(\"init\")}\\` first.`); process.exit(1); }\n // Evaluate against the real policy and keys, but a throwaway store, so `test`\n // never records a receipt or exports anything.\n const tmp = mkdtempSync(join(tmpdir(), \"sb-hook-test-\"));\n try {\n const runtime = createHookRuntime({\n policyPath: join(dir, \"policy.json\"), keyPath: join(dir, \"agent.key\"),\n attesterPath: join(dir, \"attester.key\"), dbPath: join(tmp, \"receipts.db\"),\n strict: process.argv.includes(\"--strict\"),\n });\n const mapped = fillPushBranch(mapClaudeToolUse({ tool_name: \"Bash\", tool_input: { command } }), currentBranch(process.cwd()));\n console.log(`command: ${command}`);\n for (const m of mapped) {\n const d = await runtime.evaluateOne(m);\n // One tidy row per action. A deny's full explanation is multi-line, so the\n // row carries only the deciding rule and the whole message is printed once,\n // below — exactly as the agent will receive it.\n const note = d.decision === \"deny\" ? (d.clauseId ? `rule \"${d.clauseId}\"` : \"\")\n : d.decision === \"not_evaluated\" ? d.reason : \"\";\n console.log(` ${describeIntent({ intent: m.intent }).padEnd(28)} → ${d.decision.padEnd(14)}${note}`);\n }\n const overall = await runtime.evaluate(mapped);\n console.log(`\\noverall: ${overall.decision}`);\n if (overall.decision === \"deny\" && overall.reason) console.log(`\\n${overall.reason}`);\n process.exit(overall.decision === \"deny\" ? 2 : 0);\n } finally {\n rmSync(tmp, { recursive: true, force: true });\n }\n}\n\nasync function runConnect(args: string[]): Promise<void> {\n const positional = args.filter((a) => !a.startsWith(\"--\"));\n const url = positional[0];\n const bundleArg = positional[1];\n const harness = selectedHarness(args);\n if (!url) {\n console.error(`usage: ${cliCommand(\"connect <workspace-url> <enrollment> [--claude|--cursor|--codex] [--no-install]\")}`);\n console.error(enrollmentHelp);\n process.exit(1);\n }\n const dir = configDir();\n // One command sets everything up: scaffold the key, attester and starter policy if\n // they do not exist, then enroll and persist the scoped machine credential. The\n // enrollment can be a file, an inline base64 blob (what the portal hands out) or\n // raw JSON — the user never has to save or open a JSON file.\n scaffold(dir, {});\n let bundle: CloudEnrollmentBundle;\n try { bundle = readBundleArg(bundleArg, readStdin); }\n catch { console.error(`could not read the enrollment (expected a file, inline blob, or JSON on stdin)\\n${enrollmentHelp}`); process.exit(1); }\n await finishConnect(dir, url, bundle, harness, args);\n}\n\n/** Enroll with a bundle and wire the agent: shared by `connect` (a pasted enrollment)\n * and `login` (one received through device-code approval). */\nasync function finishConnect(dir: string, url: string, bundle: CloudEnrollmentBundle, harness: Harness, args: string[]): Promise<void> {\n try {\n const c = await connectCloud(dir, url, bundle);\n console.log(`✓ Connected to ${c.url}`);\n // Configure the agent automatically (merges into the existing config), unless the\n // caller opts out. This removes the \"paste this snippet\" step. A hook that is already\n // configured — pinned by `init`, or user-level by `install` — is left as it is:\n // connecting changes where receipts go, not how the hook starts.\n const scopes = harnessScopes(harness, process.cwd());\n const existing = scopes.local ?? scopes.project ?? scopes.user;\n if (existing && !args.includes(\"--no-install\")) {\n console.log(`✓ ${harnessName(harness)} already configured in ${existing}`);\n } else if (!args.includes(\"--no-install\")) {\n const { file } = placeHook(harness, process.cwd(), undefined);\n console.log(`✓ ${harnessName(harness)} configured in ${file}`);\n if (harness === \"codex\") console.log(`\\nOne last step: ${codexTrustStep}`);\n } else {\n console.log(`Add this to your ${harnessFileName(harness)}:`);\n console.log(harnessSnippet(harness));\n }\n console.log(\"\");\n console.log(\"Run your agent — the first action appears in your workspace within seconds.\");\n } catch (error) {\n const message = (error as Error).message;\n console.error(`connect failed: ${message}`);\n if (/enrollment|expired|401|403/i.test(message)) console.error(enrollmentHelp);\n process.exit(1);\n }\n}\n\n/** Where an enrollment comes from, for every connect error that means \"this one will\n * not work\": the bare \"invalid enrollment token\" told the reader nothing about what to\n * do next. */\nconst enrollmentHelp = [\n \"An enrollment comes from your Scopebond workspace: open it, choose to connect an agent,\",\n \"and copy the command it shows — it includes the workspace URL and a fresh enrollment.\",\n \"Each enrollment is single-use and expires soon after it is created; if this one was\",\n \"used or has expired, create a new one there.\",\n].join(\"\\n\");\n\nasync function runFlush(): Promise<void> {\n const dir = resolveConfigDir(process.cwd());\n if (!loadConnection(dir)) { console.error(`not connected to a workspace; run \\`${cliCommand(\"connect <workspace-url> <enrollment>\")}\\` first`); process.exit(1); }\n const runtime = createHookRuntime(runtimePaths(dir));\n await runtime.exporter?.flush();\n const status = runtime.exporter?.status();\n runtime.exporter?.stop();\n console.log(`flushed; ${status?.pending ?? 0} receipt(s) still pending${status?.lastError ? ` (last error: ${status.lastError})` : \"\"}`);\n // Let pending HTTP handles close normally (forced exit can abort on Windows).\n process.exitCode = status && status.pending > 0 ? 1 : 0;\n}\n\n/** The absolute path to this CLI file, for registering the hook by absolute path. */\nfunction cliPath(): string {\n return fileURLToPath(import.meta.url);\n}\n\n/** `install` — the once-per-machine, user-level install (SB112). Scaffolds the\n * user home and registers the hook by absolute path in the user-level agent config,\n * so every project a developer opens is governed without a per-repo `init`. */\nfunction runInstall(args: string[]): void {\n const dir = userHome();\n // Run through `npx`, this CLI lives in npm's throwaway cache; registering that path\n // would leave a hook that stops starting whenever npm clears it — and a hook that\n // cannot start lets every action through. Pin the durable copy, as `init` does, and\n // fall back to the portable `npx` command when none can be made.\n const commandFor = (h: Harness): string => {\n const pin = ensureDurableRuntime(cliPath(), hookVersion());\n return pin.cli ? absoluteHookCommand(pin.cli, h) : hookCommand(h);\n };\n const harnessesFor = (): Harness[] => args.includes(\"--codex\") ? [\"codex\"]\n : args.includes(\"--cursor\") ? [\"cursor\"]\n : args.includes(\"--claude\") ? [\"claude\"]\n : [\"claude\", ...(cursorDetected() ? [\"cursor\" as const] : []), ...(codexDetected() ? [\"codex\" as const] : [])];\n // `install` rewrites agent config files the user did not create — their theme, plugins\n // and permissions live in ~/.claude/settings.json — so there is a way to see exactly\n // what it would touch before it touches anything.\n if (args.includes(\"--dry-run\")) {\n console.log(`Dry run — nothing is written.\\n`);\n console.log(`Would scaffold ${dir} (machine key, countersigning key, starter policy)`);\n for (const h of harnessesFor()) {\n const file = userHarnessFile(h);\n const exists = existsSync(file);\n console.log(`Would ${exists ? \"modify\" : \"create\"} ${file}`);\n if (exists) console.log(` backing it up to ${file}.scopebond-backup`);\n // Previewed without copying anything: the path the real run would pin.\n console.log(` adding hook ${absoluteHookCommand(isEphemeralPath(cliPath()) ? pinnedCliPath(hookVersion()) : cliPath(), h)}`);\n if (exists && isHarnessConfigured(file)) console.log(` (a Scopebond hook is already there; it would be replaced, not duplicated)`);\n }\n console.log(`\\nNothing else in those files is changed. Run without --dry-run to apply.`);\n process.exit(0);\n }\n const { agentKid, policyPath } = scaffold(dir, { force: args.includes(\"--force\") });\n console.log(`Scopebond installed for this user in ${dir}`);\n console.log(` machine key ${agentKid}`);\n console.log(` policy ${policyPath} (starter — edit the limits)`);\n console.log(\"\");\n const harnesses: Harness[] = harnessesFor();\n if (!args.includes(\"--no-install\")) {\n for (const h of harnesses) {\n try {\n const target = userHarnessFile(h);\n const backup = existsSync(target) ? `${target}.scopebond-backup` : null;\n const file = writeHarnessConfig(target, h, commandFor(h));\n console.log(`✓ ${harnessName(h)} configured in ${file}`);\n if (backup && existsSync(backup)) console.log(` original kept at ${backup}`);\n } catch (error) { console.error(`✗ ${harnessName(h)}: ${(error as Error).message}`); process.exitCode = 1; }\n }\n } else {\n console.log(\"Add this to your user-level agent config:\");\n console.log(harnessSnippet(harnesses[0]));\n }\n if (harnesses.includes(\"codex\")) console.log(`\\nOne last step for Codex: ${codexTrustStep}`);\n console.log(\"\");\n console.log(`A project's own .scopebond policy applies only after you trust it there (${cliCommand(\"trust\")}).`);\n console.log(`Check it: ${cliCommand(\"doctor\")} · see decisions: ${cliCommand(\"log\")}`);\n console.log(`To send receipts to a workspace: ${cliCommand(\"connect <workspace-url> <enrollment>\")}`);\n}\n\n/** Size and count of the local receipt store, plus its write-ahead log. Signed evidence\n * accumulates in the user's project directory and there is no automatic deletion — so\n * the footprint is reported rather than left to be discovered. */\nfunction describeStore(dbPath: string): string {\n const bytes = (file: string): number => { try { return statSync(file).size; } catch { return 0; } };\n const total = bytes(dbPath) + bytes(`${dbPath}-wal`) + bytes(`${dbPath}-shm`);\n const human = total >= 1024 * 1024 ? `${(total / 1024 / 1024).toFixed(1)} MiB` : `${Math.max(1, Math.round(total / 1024))} KiB`;\n let count: number | null = null;\n try {\n const { store } = openReceiptStore({ db: dbPath });\n try { count = store.count ? Number(store.count()) : null; } finally { store.close?.(); }\n } catch { count = null; }\n return count === null ? human : `${count} receipt(s), ${human}`;\n}\n\nfunction runStatus(): void {\n const home = userHome();\n const installed = existsSync(join(home, \"policy.json\"));\n // Both scopes, always: `init` writes the project config and `install` writes the\n // user one, so a single-scope check contradicts whichever command the user ran.\n const claude = harnessScopes(\"claude\", process.cwd());\n const cursor = harnessScopes(\"cursor\", process.cwd());\n const codex = harnessScopes(\"codex\", process.cwd());\n const connected = !!loadConnection(resolveConfigDir(process.cwd()));\n const dbPath = join(resolveConfigDir(process.cwd()), \"receipts.db\");\n console.log(`Scopebond hook ${hookVersion()}`);\n console.log(` user home ${home} ${installed ? \"(installed)\" : `(not installed — run \\`${cliCommand(\"install\")}\\`)`}`);\n console.log(` active config ${resolveConfigDir(process.cwd())}`);\n const ignored = untrustedProjectPolicy(process.cwd());\n if (ignored) console.log(` project policy ${ignored} ignored — not trusted (run \\`${cliCommand(\"trust\")}\\` to use it)`);\n console.log(` Claude Code ${harnessScopeLabel(claude) || \"not configured\"}`);\n console.log(` Cursor ${harnessScopeLabel(cursor) || (cursorDetected() ? \"detected, not configured\" : \"not detected\")}`);\n console.log(` Codex ${codex.project || codex.user ? `${harnessScopeLabel(codex)} — approve once with /hooks` : codexDetected() ? \"detected, not configured\" : \"not detected\"}`);\n console.log(` cloud workspace ${connected ? \"connected\" : \"not connected (local only)\"}`);\n console.log(` local receipts ${existsSync(dbPath) ? `${dbPath} (${describeStore(dbPath)})` : \"none yet\"}`);\n for (const [name, scopes] of [[\"Claude Code\", claude], [\"Cursor\", cursor], [\"Codex\", codex]] as const) {\n for (const file of [scopes.project, scopes.local, scopes.user]) if (file) console.log(` ${name}: ${file}`);\n }\n}\n\nasync function runDoctor(): Promise<void> {\n const problems: string[] = [];\n const [major, minor] = process.versions.node.split(\".\").map(Number);\n const nodeOk = major > 22 || (major === 22 && minor >= 13);\n console.log(`Scopebond doctor`);\n console.log(` node ${process.versions.node} ${nodeOk ? \"ok\" : \"TOO OLD (need >=22.13)\"}`);\n if (!nodeOk) problems.push(\"node >=22.13 is required (the Cloud outbox uses node:sqlite)\");\n const cli = cliPath();\n console.log(` cli ${cli} ${existsSync(cli) ? \"ok\" : \"MISSING\"}`);\n const active = resolveConfigDir(process.cwd());\n const hasPolicy = existsSync(join(active, \"policy.json\"));\n console.log(` active config ${active} ${hasPolicy ? \"ok\" : `no policy (run \\`${cliCommand(\"init\")}\\` here, or \\`${cliCommand(\"install\")}\\` once for your user)`}`);\n if (!hasPolicy) problems.push(\"no policy found in the active config dir\");\n const ignored = untrustedProjectPolicy(process.cwd());\n if (ignored) console.log(` project policy ${ignored} IGNORED — not trusted (never trusted, or edited since). Review it, then \\`${cliCommand(\"trust\")}\\``);\n // Every harness, in both scopes, plus a check that each configured command can\n // actually start. A pinned path that has gone missing is the one failure mode of\n // the fast absolute-path install, so doctor is where it must surface.\n let anyHarness = false;\n for (const harness of [\"claude\", \"cursor\", \"codex\"] as const) {\n const scopes = harnessScopes(harness, process.cwd());\n const label = harnessScopeLabel(scopes);\n const name = harnessName(harness);\n if (!label) {\n const detected = harness === \"claude\" || (harness === \"cursor\" ? cursorDetected() : codexDetected());\n console.log(` ${name.padEnd(15)} ${detected ? `not configured — run \\`${cliCommand(`init${harness === \"claude\" ? \"\" : ` --${harness}`}`)}\\`` : \"not detected\"}`);\n continue;\n }\n anyHarness = true;\n console.log(` ${name.padEnd(15)} ${label}`);\n for (const file of [scopes.project, scopes.local, scopes.user]) {\n if (!file) continue;\n // A project file git shares must not name a path on this machine: it starts here,\n // so the resolve check below passes, but on every teammate's machine it cannot\n // start — and a hook that cannot start is a non-blocking error, so their agent runs\n // unchecked. Only the doctor on the machine that wrote it can see this coming.\n const share = file === scopes.project ? gitShareState(file) : \"none\";\n const shared = share === \"tracked\" || share === \"untracked\";\n for (const command of configuredHookCommands(file)) {\n const ok = hookCommandResolves(command);\n const leaks = ok && shared && isMachineSpecificCommand(command);\n console.log(` ${ok && !leaks ? \"ok \" : \"BAD \"} ${file}`);\n if (!ok) {\n console.log(` command cannot start: ${command}`);\n problems.push(`${name} hook command no longer resolves in ${file} — run \\`${cliCommand(\"init\")}\\` to repair it`);\n } else if (leaks) {\n console.log(` machine-specific command in a file git shares: ${command}`);\n problems.push(`${name} hook in ${file} names a path on this machine and git shares that file — anyone who clones it gets a hook that cannot start, and their agent runs unchecked. Run \\`${cliCommand(`init${harness === \"claude\" ? \"\" : ` --${harness}`}`)}\\` to move it, then commit the change`);\n }\n }\n }\n if (harness === \"codex\") console.log(` run /hooks in Codex and approve Scopebond once`);\n }\n if (!anyHarness) problems.push(`no coding agent is configured — run \\`${cliCommand(\"init\")}\\` in your project root`);\n const connection = loadConnection(active);\n if (!connection) {\n console.log(` cloud not connected (local only) — receipts stay on this machine`);\n } else {\n let reachable = \"unknown\";\n try {\n const res = await fetch(new URL(\"/healthz\", connection.url).toString(), { method: \"GET\" });\n reachable = res.ok ? \"reachable\" : `unhealthy (${res.status})`;\n } catch (error) { reachable = `unreachable (${(error as Error).message})`; }\n console.log(` cloud ${connection.url} — ${reachable}`);\n }\n console.log(problems.length ? `\\n${problems.length} problem(s): ${problems.join(\"; \")}` : `\\nAll good.`);\n process.exitCode = problems.length ? 1 : 0;\n}\n\nfunction runUninstall(args: string[]): void {\n requireInteractive(\"uninstall\", args);\n let removed = 0;\n // Both scopes. Checking only the user config meant that after a per-project `init` —\n // the install the site actually tells people to run — `uninstall` reported \"no\n // user-level harness config found\" and left the project hook in place.\n for (const h of [\"claude\", \"cursor\", \"codex\"] as Harness[]) {\n for (const file of [projectHarnessFile(h, process.cwd()), localHarnessFile(h, process.cwd()), userHarnessFile(h)]) {\n if (file && removeHarnessConfig(file)) { console.log(`✓ removed the Scopebond hook from ${file}`); removed++; }\n }\n }\n if (removed === 0) console.log(\"no Scopebond hook found in this project or your user config.\");\n if (args.includes(\"--purge\")) { purgeHome(); console.log(`✓ purged ${userHome()} (keys, policy, receipts)`); }\n else console.log(`Kept ${userHome()} (keys, policy, receipts). Use --purge to remove it too.`);\n const projectDir = resolveConfigDir(process.cwd());\n if (existsSync(join(projectDir, \"policy.json\"))) {\n console.log(`Kept ${projectDir} (this project's keys, policy and receipts) — delete it by hand if you want it gone.`);\n }\n}\n\n/** `trust` — let this project's .scopebond policy govern here instead of the user\n * home, pinned to its current contents. Run by the user, not the agent: the file it\n * writes lives in the user home, which the starter policy write-protects. */\nfunction runTrust(args: string[]): void {\n requireInteractive(\"trust\", args);\n const dir = join(process.cwd(), \".scopebond\");\n if (!existsSync(join(dir, \"policy.json\"))) { console.error(`no project policy at ${join(dir, \"policy.json\")}`); process.exit(1); }\n const digest = trustProjectPolicy(dir);\n console.log(`✓ trusted ${join(dir, \"policy.json\")} (sha256 ${digest.slice(0, 12)}…)`);\n console.log(\"It governs agents in this project until it changes; after any edit, review it and run trust again.\");\n}\n\n/** `login <workspace-url>` — connect this computer without pasting anything. It asks\n * the workspace for a short code, shows it with the page to open, and waits while a\n * person who can manage the workspace approves it there for an environment and agent.\n * The approval hands back a single-use enrollment, which completes exactly as\n * `connect` does. Nothing secret is printed: the device code stays in memory. */\nasync function runLogin(args: string[]): Promise<void> {\n const positional = args.filter((a) => !a.startsWith(\"--\"));\n const harness = selectedHarness(args);\n let origin: string;\n try {\n const parsed = new URL(positional[0] ?? \"\");\n const local = parsed.hostname === \"localhost\" || parsed.hostname === \"127.0.0.1\" || parsed.hostname === \"[::1]\";\n if (parsed.protocol !== \"https:\" && !(local && parsed.protocol === \"http:\")) throw new Error(\"https required\");\n origin = parsed.origin;\n } catch {\n console.error(`usage: ${cliCommand(\"login <workspace-url> [--claude|--cursor|--codex] [--no-install]\")}`);\n console.error(\"The workspace URL is the address of your Scopebond workspace, for example https://cloud.scopebond.com.\");\n process.exit(1);\n }\n const post = async (path: string, body: unknown): Promise<{ status: number; json: Record<string, unknown> }> => {\n const response = await fetch(new URL(path, origin), {\n method: \"POST\", headers: { \"content-type\": \"application/json\" }, body: JSON.stringify(body),\n redirect: \"error\", signal: AbortSignal.timeout(15_000),\n });\n return { status: response.status, json: await response.json().catch(() => ({})) as Record<string, unknown> };\n };\n let start: { status: number; json: Record<string, unknown> };\n try { start = await post(\"/v1/device/code\", { client_name: hostname(), harness }); }\n catch (error) { console.error(`could not reach ${origin}: ${(error as Error).message}`); process.exit(1); }\n const deviceCode = typeof start.json.device_code === \"string\" ? start.json.device_code : \"\";\n if (start.status !== 200 || !deviceCode) {\n console.error(`${origin} did not start a login (HTTP ${start.status}). Check the workspace URL, or use ${cliCommand(\"connect <workspace-url> <enrollment>\")}.`);\n process.exit(1);\n }\n const userCode = String(start.json.user_code ?? \"\");\n const verify = String(start.json.verification_uri_complete ?? start.json.verification_uri ?? origin);\n let intervalMs = Math.max(1, Number(start.json.interval ?? 5)) * 1000;\n const deadline = Date.now() + Math.max(60, Number(start.json.expires_in ?? 600)) * 1000;\n console.log(`To connect this computer, open:\\n\\n ${verify}\\n\\nand check that it shows the code ${userCode}\\n`);\n console.log(\"Waiting for approval (the code expires in 10 minutes; Ctrl+C to stop)…\");\n const dir = configDir();\n scaffold(dir, {});\n while (Date.now() < deadline) {\n await new Promise((resolve) => setTimeout(resolve, intervalMs));\n let polled: { status: number; json: Record<string, unknown> };\n try { polled = await post(\"/v1/device/token\", { device_code: deviceCode }); }\n catch { continue; } // a transient network error: keep waiting until the deadline\n if (polled.status === 200 && polled.json.enrollment && typeof polled.json.enrollment === \"object\") {\n console.log(\"✓ Approved\");\n await finishConnect(dir, origin, polled.json.enrollment as CloudEnrollmentBundle, harness, args);\n return;\n }\n const error = polled.json.error;\n if (error === \"authorization_pending\") continue;\n if (error === \"slow_down\") { intervalMs += 5_000; continue; }\n if (error === \"access_denied\") { console.error(\"The request was denied in the workspace. Nothing was connected.\"); process.exit(1); }\n if (error === \"expired_token\") break;\n console.error(`login failed (${String(error ?? `HTTP ${polled.status}`)}). Run the command again for a new code.`);\n process.exit(1);\n }\n console.error(\"The code expired before it was approved. Run the command again for a new one.\");\n process.exit(1);\n}\n\n/** What each command does, its arguments, and one example. The whole help used to be a\n * single usage line listing 15 command names, which told a reader nothing about what any\n * of them did or what arguments they take. */\nconst COMMANDS: Array<{ name: string; args?: string; summary: string; detail?: string[] }> = [\n { name: \"init\", args: \"[--cursor|--codex] [--shared] [--dry-run] [--no-install] [--npx] [--force] [--yes]\",\n summary: \"set this project up: keys, a starter policy, and your agent wired to the hook\",\n detail: [\n \"Writes .scopebond/ (machine key, countersigning key, starter policy, .gitignore) and\",\n \"wires your agent to the hook. It pins a durable copy of this package so the hook starts\",\n \"fast, and because that command names paths on this machine it goes where git will not\",\n \"share it: .claude/settings.local.json (kept out of git for this clone), or for Cursor\",\n \"and Codex their project file only while git does not track it. --shared writes the\",\n \"portable npx command to .claude/settings.json, .cursor/hooks.json or .codex/hooks.json\",\n \"instead, so everyone who clones the project gets the hook. --dry-run shows what it\",\n \"would write. --no-install prints the config snippet rather than writing it.\",\n \"Needs a terminal, or --yes in a script, because it changes what governs your agent.\",\n ] },\n { name: \"install\", args: \"[--claude] [--cursor] [--codex] [--dry-run] [--force] [--yes]\",\n summary: \"set up once for this user, so every project you open is governed\",\n detail: [\n \"Scaffolds ~/.scopebond and registers the hook in your user-level agent config.\",\n \"--dry-run prints exactly which files it would touch and changes nothing. Each config\",\n \"is copied to <file>.scopebond-backup before its first modification.\",\n ] },\n { name: \"rules\", args: \"[show|allow|block|protect|unprotect|protect-branch|unprotect-branch|apply] [value]\",\n summary: \"read and change the limits in plain terms\",\n detail: [\n \"With no arguments, prints what is blocked in plain English — no regular expressions.\",\n \"The editable lists are .scopebond/rules.json; policy.json is compiled from them, so\",\n \"you never hand-write a lookahead.\",\n \" rules allow dd stop blocking a program\",\n \" rules protect infra/ never write there\",\n \" rules protect-branch production\",\n \" rules apply recompile after editing rules.json by hand\",\n ] },\n { name: \"status\", summary: \"what is configured, where, and how big the local log is\" },\n { name: \"doctor\", summary: \"check the setup and whether each configured hook command can start\",\n detail: [\"Exits non-zero when something is wrong, so it works in a script.\"] },\n { name: \"log\", args: \"[-n N] [--deny] [--since 7d]\",\n summary: \"the recent decisions\",\n detail: [`--deny shows only blocked actions; --since takes 7d, 24h, 30m or a date.`, `e.g. ${cliCommand(\"log --deny --since 7d\")}`] },\n { name: \"verify\", summary: \"check every local receipt offline against the countersigning key\",\n detail: [\"No network, no account. Exits non-zero if any receipt fails.\"] },\n { name: \"test\", args: '\"<shell command>\"',\n summary: \"show the decision for a command without running or recording it\",\n detail: [`e.g. ${cliCommand('test \"rm -rf /\"')}`] },\n { name: \"prune\", args: \"[--before 90d] [--yes]\",\n summary: \"report the local store's size, or bound it\",\n detail: [\n \"With no --before it only reports. With one, it archives the receipts it will remove\",\n \"to a JSONL file beside the database, then removes them. Refuses once the log has been\",\n \"anchored, because a receipt's position is its anchor leaf index.\",\n ] },\n { name: \"login\", args: \"<workspace-url> [--claude|--cursor|--codex] [--no-install]\",\n summary: \"connect this computer to a Scopebond Cloud workspace by approving a short code there\",\n detail: [\n \"Prints a code and a link; someone who manages the workspace opens it, checks the code\",\n \"and approves it for an environment and agent. Nothing is copied or pasted.\",\n ] },\n { name: \"connect\", args: \"<workspace-url> <enrollment> [--claude|--cursor|--codex]\",\n summary: \"send receipts to a Scopebond Cloud workspace as well as keeping them locally\" },\n { name: \"flush\", summary: \"deliver any receipts still queued for the workspace now\" },\n { name: \"trust\", args: \"[--yes]\", summary: \"let this project's .scopebond policy govern here (pinned by hash)\" },\n { name: \"uninstall\", args: \"[--purge] [--yes]\", summary: \"remove the hook from your agent config; --purge also deletes the home\" },\n { name: \"claude\", summary: \"(internal) decide one Claude Code PreToolUse call, JSON on stdin\" },\n { name: \"cursor\", summary: \"(internal) decide one Cursor hook event, JSON on stdin\" },\n { name: \"codex\", summary: \"(internal) decide one Codex PreToolUse call, JSON on stdin\" },\n];\n\nfunction printHelp(topic: string | undefined, toStderr = false): void {\n const out = toStderr ? console.error : console.log;\n const match = topic ? COMMANDS.find((c) => c.name === topic.replace(/^--?/, \"\")) : undefined;\n if (match) {\n out(`scopebond-hook ${match.name}${match.args ? ` ${match.args}` : \"\"}`);\n out(\"\");\n out(` ${match.summary}`);\n if (match.detail) { out(\"\"); for (const line of match.detail) out(` ${line}`); }\n return;\n }\n if (topic) { out(`no such command: ${topic}`); out(\"\"); }\n out(`scopebond-hook — govern a coding agent's tool calls against policy, before they run.`);\n out(\"\");\n out(`Usage: scopebond-hook <command> [options]`);\n out(\"\");\n out(` ${cliCommand(\"init\")} set up this project`);\n out(` ${cliCommand('test \"rm -rf /\"')} see a decision without running it`);\n out(` ${cliCommand(\"log --deny\")} what got blocked`);\n out(` ${cliCommand(\"rules\")} what is blocked, in plain English`);\n out(\"\");\n out(\"Commands:\");\n const width = Math.max(...COMMANDS.map((c) => c.name.length));\n for (const command of COMMANDS) {\n if (command.summary.startsWith(\"(internal)\")) continue;\n out(` ${command.name.padEnd(width)} ${command.summary}`);\n }\n out(\"\");\n out(` ${\"help\".padEnd(width)} \\`help <command>\\` for that command's arguments and examples`);\n out(\"\");\n out(`Receipts and keys stay in .scopebond/ in this project. Nothing leaves your machine`);\n out(`unless you run \\`connect\\`. Docs: https://github.com/avouro-com/scopebond`);\n}\n\nconst [cmd, ...rest] = process.argv.slice(2);\nif (cmd === \"claude\") { await runClaude(); }\nelse if (cmd === \"cursor\") { await runCursor(); }\nelse if (cmd === \"codex\") { await runCodex(); }\nelse if (cmd === \"init\") { runInit(rest); }\nelse if (cmd === \"install\") { runInstall(rest); }\nelse if (cmd === \"connect\") { await runConnect(rest); }\nelse if (cmd === \"log\") { await runLog(rest); }\nelse if (cmd === \"verify\") { await runVerify(); }\nelse if (cmd === \"test\") { await runTest(rest); }\nelse if (cmd === \"flush\") { await runFlush(); }\nelse if (cmd === \"status\") { runStatus(); }\nelse if (cmd === \"doctor\") { await runDoctor(); }\nelse if (cmd === \"uninstall\") { runUninstall(rest); }\nelse if (cmd === \"login\") { await runLogin(rest); }\nelse if (cmd === \"trust\") { runTrust(rest); }\nelse if (cmd === \"prune\") { await runPrune(rest); }\nelse if (cmd === \"rules\") { runRules(rest); }\nelse if (cmd === \"help\" || cmd === \"--help\" || cmd === \"-h\" || cmd === undefined) { printHelp(rest[0]); }\nelse {\n console.error(`unknown command: ${cmd}`);\n printHelp(undefined, true);\n process.exit(1);\n}\n"]}
|
package/dist/cloud.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type CloudEnrollmentBundle, type CloudEnrollmentResult, type CloudExporter, type ReceiptStore } from "@scopebond/gateway";
|
|
2
|
+
import { SqliteCloudOutbox } from "@scopebond/gateway/node";
|
|
2
3
|
/** The persisted connection between this machine and a Cloud workspace. Holds the
|
|
3
4
|
* scoped machine credential; treat cloud.json as a secret (written 0600). */
|
|
4
5
|
export interface HookConnection extends CloudEnrollmentResult {
|
|
@@ -16,6 +17,7 @@ export declare function connectCloud(dir: string, url: string, bundle: CloudEnro
|
|
|
16
17
|
export declare function attachExporter(outboxDbPath: string, connection: HookConnection, store: ReceiptStore, fetchImpl?: typeof fetch): {
|
|
17
18
|
store: ReceiptStore;
|
|
18
19
|
exporter: CloudExporter;
|
|
20
|
+
outbox: SqliteCloudOutbox;
|
|
19
21
|
};
|
|
20
22
|
/** Attempt delivery with a bounded timeout so a per-invocation hook never hangs the
|
|
21
23
|
* agent; undelivered receipts stay in the durable outbox and flush next time. */
|
package/dist/cloud.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud.d.ts","sourceRoot":"","sources":["../src/cloud.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,KAAK,qBAAqB,EAAE,KAAK,qBAAqB,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAC9F,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"cloud.d.ts","sourceRoot":"","sources":["../src/cloud.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,KAAK,qBAAqB,EAAE,KAAK,qBAAqB,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAC9F,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAwB,MAAM,yBAAyB,CAAC;AAElF;8EAC8E;AAC9E,MAAM,WAAW,cAAe,SAAQ,qBAAqB;IAC3D,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,MAAiC,CAAC;AAE/E,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAQjE;AAED;;wFAEwF;AACxF,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,GAChF,OAAO,CAAC,cAAc,CAAC,CAOzB;AAED;oFACoF;AACpF,wBAAgB,cAAc,CAC5B,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,GAC9F;IAAE,KAAK,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,iBAAiB,CAAA;CAAE,CAI7E;AAED;kFACkF;AAClF,wBAAsB,YAAY,CAAC,QAAQ,EAAE,aAAa,EAAE,SAAS,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAK3F"}
|
package/dist/cloud.js
CHANGED
|
@@ -37,7 +37,7 @@ export async function connectCloud(dir, url, bundle, fetchImpl) {
|
|
|
37
37
|
export function attachExporter(outboxDbPath, connection, store, fetchImpl) {
|
|
38
38
|
const outbox = new SqliteCloudOutbox(outboxDbPath);
|
|
39
39
|
const exporter = createCloudExporter({ url: connection.url, credential: connection.credential, outbox, fetch: fetchImpl });
|
|
40
|
-
return { store: withCloudExporter(store, exporter), exporter };
|
|
40
|
+
return { store: withCloudExporter(store, exporter), exporter, outbox };
|
|
41
41
|
}
|
|
42
42
|
/** Attempt delivery with a bounded timeout so a per-invocation hook never hangs the
|
|
43
43
|
* agent; undelivered receipts stay in the durable outbox and flush next time. */
|
package/dist/cloud.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../src/cloud.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,iFAAiF;AACjF,oFAAoF;AACpF,qFAAqF;AACrF,oFAAoF;AAEpF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,uBAAuB,EAAE,mBAAmB,EAAE,iBAAiB,GAEhE,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAQlF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;AAE/E,sFAAsF;AACtF,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAA4B,CAAC;QACjF,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ;YAAE,OAAO,MAAwB,CAAC;IAC/G,CAAC;IAAC,MAAM,CAAC,CAAC,k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AAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;KACtF,CAAC,CAAC;AACL,CAAC","sourcesContent":["// scopebond-hook → Scopebond Cloud: enroll the machine's countersigning key with a\n// workspace and auto-export signed receipts to the hosted portal, so a connected\n// hook starts monitoring automatically. Reuses the gateway's enrollment and bounded\n// durable exporter (D40 — no new transport). The machine credential and the complete\n// receipt log stay local-first; export is best-effort and never blocks a tool call.\n\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport {\n completeCloudEnrollment, createCloudExporter, withCloudExporter,\n type CloudEnrollmentBundle, type CloudEnrollmentResult, type CloudExporter, type ReceiptStore,\n} from \"@scopebond/gateway\";\nimport { SqliteCloudOutbox, loadOrCreateAttester } from \"@scopebond/gateway/node\";\n\n/** The persisted connection between this machine and a Cloud workspace. Holds the\n * scoped machine credential; treat cloud.json as a secret (written 0600). */\nexport interface HookConnection extends CloudEnrollmentResult {\n url: string;\n}\n\nexport const connectionPath = (dir: string): string => join(dir, \"cloud.json\");\n\n/** Read the persisted connection, or null when the hook is not connected to Cloud. */\nexport function loadConnection(dir: string): HookConnection | null {\n const path = connectionPath(dir);\n if (!existsSync(path)) return null;\n try {\n const parsed = JSON.parse(readFileSync(path, \"utf8\")) as Partial<HookConnection>;\n if (typeof parsed.url === \"string\" && typeof parsed.credential === \"string\") return parsed as HookConnection;\n } catch { /* fall through */ }\n return null;\n}\n\n/** Enroll the machine's attester with a workspace using the portal's one-use handoff,\n * then persist the scoped machine credential. The attester whose possession is proved\n * here is the same key the hook countersigns receipts with, so ingest accepts them. */\nexport async function connectCloud(\n dir: string, url: string, bundle: CloudEnrollmentBundle, fetchImpl?: typeof fetch,\n): Promise<HookConnection> {\n const { attester } = loadOrCreateAttester({ file: join(dir, \"attester.key\") });\n const { attester: agent } = loadOrCreateAttester({ file: join(dir, \"agent.key\") });\n const result = await completeCloudEnrollment({ url, bundle, attester, agent, fetch: fetchImpl });\n const connection: HookConnection = { url, ...result };\n writeFileSync(connectionPath(dir), JSON.stringify(connection, null, 2) + \"\\n\", { mode: 0o600 });\n return connection;\n}\n\n/** Wrap a receipt store so every stored receipt is enqueued to a durable outbox and\n * exported to Cloud. Returns the wrapped store and the exporter (flush + stop). */\nexport function attachExporter(\n outboxDbPath: string, connection: HookConnection, store: ReceiptStore, fetchImpl?: typeof fetch,\n): { store: ReceiptStore; exporter: CloudExporter; outbox: SqliteCloudOutbox } {\n const outbox = new SqliteCloudOutbox(outboxDbPath);\n const exporter = createCloudExporter({ url: connection.url, credential: connection.credential, outbox, fetch: fetchImpl });\n return { store: withCloudExporter(store, exporter), exporter, outbox };\n}\n\n/** Attempt delivery with a bounded timeout so a per-invocation hook never hangs the\n * agent; undelivered receipts stay in the durable outbox and flush next time. */\nexport async function flushBounded(exporter: CloudExporter, timeoutMs = 3000): Promise<void> {\n await Promise.race([\n exporter.flush().catch(() => {}),\n new Promise<void>((resolve) => setTimeout(resolve, Math.max(0, timeoutMs)).unref?.()),\n ]);\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** A policy clause, as much of it as the message needs. */
|
|
2
|
+
export interface ExplainClause {
|
|
3
|
+
id?: unknown;
|
|
4
|
+
mode?: unknown;
|
|
5
|
+
description?: unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface ExplainPolicy {
|
|
8
|
+
clauses?: unknown;
|
|
9
|
+
}
|
|
10
|
+
/** An intent, as much of it as the message needs. */
|
|
11
|
+
export interface ExplainIntent {
|
|
12
|
+
action_type?: unknown;
|
|
13
|
+
params?: unknown;
|
|
14
|
+
}
|
|
15
|
+
/** One line naming the action: `git.push origin main`, `shell.exec rm`,
|
|
16
|
+
* `file.read .env`. Shared with `log` so a decision reads the same in both. */
|
|
17
|
+
export declare function describeAction(intent: ExplainIntent | undefined): string;
|
|
18
|
+
/** Find the clause that decided, by the id the verdict reported. */
|
|
19
|
+
export declare function findClause(policy: ExplainPolicy | undefined, clauseId: string | null | undefined): ExplainClause | null;
|
|
20
|
+
export interface ExplainDenyInput {
|
|
21
|
+
/** The loaded policy, for the deciding clause's own words. */
|
|
22
|
+
policy?: ExplainPolicy;
|
|
23
|
+
/** The clause id the verdict reported, when it reported one. */
|
|
24
|
+
clauseId?: string | null;
|
|
25
|
+
/** The engine's reason — kept verbatim as the technical detail. */
|
|
26
|
+
detail: string;
|
|
27
|
+
/** The action that was blocked. */
|
|
28
|
+
intent?: ExplainIntent;
|
|
29
|
+
/** Where the rule lives, so the next step is a real path. */
|
|
30
|
+
policyPath?: string;
|
|
31
|
+
/** How to change it, when there is something better to say than "edit this file" — the
|
|
32
|
+
* compiled policy is generated, so pointing a reader at it invites them to hand-edit
|
|
33
|
+
* something that will be overwritten. */
|
|
34
|
+
remedy?: string;
|
|
35
|
+
/** The harness reported this action only after it happened, so the decision records
|
|
36
|
+
* and flags it but did not prevent it. The wording must not claim otherwise. */
|
|
37
|
+
postHoc?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** Compose the block message. Degrades in order: with a clause and a description
|
|
40
|
+
* it explains the rule; with a clause but no description it still names it; with
|
|
41
|
+
* no clause at all (an undetermined verdict, a kill switch) it reports the
|
|
42
|
+
* engine's reason unchanged rather than inventing a rule that did not decide. */
|
|
43
|
+
export declare function explainDeny(input: ExplainDenyInput): string;
|
|
44
|
+
//# sourceMappingURL=explain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain.d.ts","sourceRoot":"","sources":["../src/explain.ts"],"names":[],"mappings":"AAcA,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAQD;gFACgF;AAChF,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,GAAG,MAAM,CASxE;AAWD,oEAAoE;AACpE,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,aAAa,GAAG,IAAI,CAQvH;AAED,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;8CAE0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;qFACiF;IACjF,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;kFAGkF;AAClF,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAoB3D"}
|