fullcourtdefense-cli 1.34.21 → 1.34.25

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.
Files changed (91) hide show
  1. package/README.md +1 -0
  2. package/dist/actionIdentity.d.ts +1 -0
  3. package/dist/actionIdentity.js +2 -0
  4. package/dist/actionPolicyEngine.d.ts +5 -0
  5. package/dist/actionPolicyEngine.js +273 -30
  6. package/dist/agentTerminal.d.ts +1 -3
  7. package/dist/agentTerminal.js +14 -29
  8. package/dist/approvalPrompt.d.ts +7 -0
  9. package/dist/approvalPrompt.js +46 -0
  10. package/dist/askDialog.d.ts +87 -0
  11. package/dist/askDialog.js +209 -0
  12. package/dist/blockExplanation.js +18 -6
  13. package/dist/boundaryVerification.d.ts +20 -0
  14. package/dist/boundaryVerification.js +147 -0
  15. package/dist/commands/daemon.js +198 -70
  16. package/dist/commands/deterministicGuard.d.ts +2 -0
  17. package/dist/commands/deterministicGuard.js +161 -9
  18. package/dist/commands/hook.js +81 -29
  19. package/dist/commands/installClaudeHook.js +11 -5
  20. package/dist/commands/installCursorHook.js +5 -4
  21. package/dist/commands/mcpGateway.d.ts +2 -0
  22. package/dist/commands/mcpGateway.js +163 -56
  23. package/dist/commands/onboard.js +6 -5
  24. package/dist/commands/onboardingSummary.d.ts +5 -0
  25. package/dist/commands/onboardingSummary.js +11 -0
  26. package/dist/commands/protectedRun.d.ts +14 -0
  27. package/dist/commands/protectedRun.js +207 -0
  28. package/dist/containment-runtime/index.mjs +30118 -0
  29. package/dist/containment-runtime/licenses/_anthropic-ai_sandbox-runtime.txt +201 -0
  30. package/dist/containment-runtime/licenses/_pondwader_socks5-server.txt +20 -0
  31. package/dist/containment-runtime/licenses/commander.txt +22 -0
  32. package/dist/containment-runtime/licenses/node-forge.txt +331 -0
  33. package/dist/containment-runtime/licenses/zod.txt +21 -0
  34. package/dist/containment-runtime/runtime-version.json +1 -0
  35. package/dist/containment-runtime/vendor/java-proxy-agent/build.ts +95 -0
  36. package/dist/containment-runtime/vendor/java-proxy-agent/srt-proxy-agent.jar +0 -0
  37. package/dist/containment-runtime/vendor/seccomp/arm64/apply-seccomp +0 -0
  38. package/dist/containment-runtime/vendor/seccomp/build.ts +69 -0
  39. package/dist/containment-runtime/vendor/seccomp/x64/apply-seccomp +0 -0
  40. package/dist/containment-runtime/vendor/srt-win/arm64/srt-win.exe +0 -0
  41. package/dist/containment-runtime/vendor/srt-win/build.ts +21 -0
  42. package/dist/containment-runtime/vendor/srt-win/x64/srt-win.exe +0 -0
  43. package/dist/containmentLease.d.ts +5 -0
  44. package/dist/containmentLease.js +72 -0
  45. package/dist/detectionUpdates.d.ts +23 -3
  46. package/dist/detectionUpdates.js +45 -14
  47. package/dist/detectorArtifact.d.ts +17 -0
  48. package/dist/detectorArtifact.js +35 -0
  49. package/dist/detectorBaseline.d.ts +2 -0
  50. package/dist/detectorBaseline.js +5 -0
  51. package/dist/detectorModule.d.ts +9 -0
  52. package/dist/detectorModule.js +84 -0
  53. package/dist/detectorRuntime.d.ts +21 -0
  54. package/dist/detectorRuntime.js +49 -0
  55. package/dist/detectorUpdates.d.ts +21 -0
  56. package/dist/detectorUpdates.js +86 -0
  57. package/dist/devConfirm.d.ts +97 -15
  58. package/dist/devConfirm.js +447 -117
  59. package/dist/distress.d.ts +2 -0
  60. package/dist/distress.js +2 -0
  61. package/dist/frictionRollout.js +103 -0
  62. package/dist/gatewayRuntime.d.ts +19 -0
  63. package/dist/gatewayRuntime.js +93 -0
  64. package/dist/hookSlim.js +17 -18
  65. package/dist/index.js +35 -0
  66. package/dist/localDetectionUpdates.d.ts +3 -1
  67. package/dist/localDetectionUpdates.js +8 -1
  68. package/dist/localSafetySnapshot.d.ts +9 -5
  69. package/dist/localSafetySnapshot.js +42 -15
  70. package/dist/mcpToolReview.d.ts +17 -0
  71. package/dist/mcpToolReview.js +127 -0
  72. package/dist/mcpToolTrust.d.ts +22 -0
  73. package/dist/mcpToolTrust.js +66 -0
  74. package/dist/nativeHook.d.ts +4 -0
  75. package/dist/nativeHook.js +31 -17
  76. package/dist/policyRefresh.d.ts +3 -0
  77. package/dist/policyRefresh.js +27 -0
  78. package/dist/protectionMaintenance.d.ts +10 -0
  79. package/dist/protectionMaintenance.js +64 -0
  80. package/dist/protectionProfile.d.ts +26 -0
  81. package/dist/protectionProfile.js +63 -0
  82. package/dist/runtimeConfig.d.ts +2 -0
  83. package/dist/runtimeConfig.js +65 -26
  84. package/dist/selfTest.d.ts +2 -0
  85. package/dist/selfTest.js +9 -1
  86. package/dist/sessionLimits.d.ts +2 -0
  87. package/dist/sessionLimits.js +24 -0
  88. package/dist/telemetry.d.ts +5 -0
  89. package/dist/telemetry.js +8 -0
  90. package/dist/version.json +1 -1
  91. package/package.json +10 -6
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ContainedLaunchFailure = void 0;
37
+ exports.verifiedProtectionProfile = verifiedProtectionProfile;
38
+ exports.protectedRunCommand = protectedRunCommand;
39
+ exports.runProtectedLaunch = runProtectedLaunch;
40
+ exports.containedExecutionEnvironment = containedExecutionEnvironment;
41
+ exports.runContainedCommand = runContainedCommand;
42
+ const fs = __importStar(require("fs"));
43
+ const path = __importStar(require("path"));
44
+ const child_process_1 = require("child_process");
45
+ const url_1 = require("url");
46
+ const config_1 = require("../config");
47
+ const runtimeConfig_1 = require("../runtimeConfig");
48
+ const machineIdentity_1 = require("../machineIdentity");
49
+ const machineActionVerify_1 = require("../machineActionVerify");
50
+ const protectionProfile_1 = require("../protectionProfile");
51
+ const containmentLease_1 = require("../containmentLease");
52
+ const telemetry_1 = require("../telemetry");
53
+ function verifiedProtectionProfile(envelope, machineId, shieldId) {
54
+ if (!envelope || envelope.type !== 'protection_profile' || envelope.machineId !== machineId || !envelope.organizationId || !envelope.signature)
55
+ throw new Error('No signed protection settings for this computer.');
56
+ const created = Date.parse(envelope.createdAt), expires = Date.parse(envelope.expiresAt);
57
+ if (!Number.isFinite(created) || !Number.isFinite(expires) || created > Date.now() + 60_000 || expires <= Date.now() || expires - created > 24 * 60 * 60_000)
58
+ throw new Error('Protection settings expired or have invalid dates. Reconnect before launching.');
59
+ const verdict = (0, machineActionVerify_1.verifyMachineAction)(envelope, { localMachineId: machineId });
60
+ if (!verdict.ok || verdict.reason)
61
+ throw new Error('Protection settings failed signature verification.');
62
+ const payload = JSON.parse(envelope.reason);
63
+ if (!shieldId || payload.shieldId !== shieldId)
64
+ throw new Error('Protection settings belong to another enrollment.');
65
+ return (0, protectionProfile_1.parseProtectionProfile)(payload.profile);
66
+ }
67
+ async function protectedRunCommand(config, command, inspect = false) {
68
+ const identity = (0, machineIdentity_1.getMachineIdentity)();
69
+ const creds = (0, config_1.resolveCliCredentials)(config);
70
+ if (!creds.shieldId)
71
+ throw new Error('Enroll this computer before using managed protection.');
72
+ const bundle = await (0, runtimeConfig_1.getRuntimeBundle)({ apiUrl: creds.apiUrl, shieldId: creds.shieldId, shieldKey: creds.shieldKey, machineId: identity.machineId,
73
+ developerName: identity.developerName, machineName: identity.hostname, force: true, timeoutMs: 5000 });
74
+ if (bundle.suspended)
75
+ throw new Error('This computer is suspended.');
76
+ const profile = verifiedProtectionProfile(bundle.protectionProfile, identity.machineId, creds.shieldId);
77
+ if (profile.platform !== process.platform)
78
+ throw new Error('The protection profile is for a different operating system.');
79
+ if (inspect) {
80
+ console.log(JSON.stringify({ profile, revision: bundle.protectionProfile.id, expiresAt: bundle.protectionProfile.expiresAt, status: 'configured', enforcing: false }, null, 2));
81
+ return;
82
+ }
83
+ if (!command || command.length > 32000)
84
+ throw new Error('Provide --command with the command to launch.');
85
+ if (!fs.statSync(profile.workspace).isDirectory())
86
+ throw new Error('The working folder is unavailable.');
87
+ // The existing action checker remains authoritative for the initial command.
88
+ const hook = (0, child_process_1.spawnSync)(process.execPath, [path.resolve(__dirname, '../index.js'), 'hook', '--event', 'shell'], {
89
+ input: JSON.stringify({ command, cwd: profile.workspace, conversation_id: `protected-run-${process.pid}` }), cwd: profile.workspace,
90
+ encoding: 'utf8', timeout: 15000, maxBuffer: 1024 * 1024, windowsHide: true,
91
+ });
92
+ let verdict = {};
93
+ try {
94
+ verdict = JSON.parse(hook.stdout || '{}');
95
+ }
96
+ catch { /* failed checker blocks launch */ }
97
+ if (hook.error || hook.status !== 0 || verdict.permission !== 'allow')
98
+ throw new Error('The action checker did not allow this launch. Resolve its decision before retrying.');
99
+ process.exitCode = await runProtectedLaunch(profile, command, bundle.protectionProfile.id);
100
+ }
101
+ /** Existing machine Activity receives minimized launch outcome evidence. */
102
+ class ContainedLaunchFailure extends Error {
103
+ executionStarted;
104
+ constructor(message, executionStarted) {
105
+ super(message);
106
+ this.executionStarted = executionStarted;
107
+ }
108
+ }
109
+ exports.ContainedLaunchFailure = ContainedLaunchFailure;
110
+ async function runProtectedLaunch(profile, command, revision, launch = runContainedCommand) {
111
+ const record = (decision, reason) => {
112
+ try {
113
+ (0, telemetry_1.spoolEvent)({ decision, toolName: 'shell', operation: 'containment:launch', ruleId: `protection-profile:${revision}`, reason });
114
+ (0, telemetry_1.triggerFlush)(decision === 'block');
115
+ }
116
+ catch { /* Telemetry cannot change the launch result. */ }
117
+ };
118
+ try {
119
+ const code = await launch(profile, command);
120
+ record(code === 0 ? 'allow' : 'warn', `Protected launcher exited with code ${code}. This records the launch outcome, not a boundary test.`);
121
+ return code;
122
+ }
123
+ catch (error) {
124
+ const started = error instanceof ContainedLaunchFailure && error.executionStarted;
125
+ record(started ? 'warn' : 'block', started
126
+ ? 'Protected execution started, but the launcher or cleanup failed. This is not a blocked-action claim.'
127
+ : 'Protected launch could not start. No ordinary-shell fallback was used.');
128
+ throw error;
129
+ }
130
+ }
131
+ function containedExecutionEnvironment(source) {
132
+ const env = { ...source };
133
+ for (const key of Object.keys(env))
134
+ if (/^(NODE_OPTIONS|NODE_PATH|BASH_ENV|ENV|LD_.*|DYLD_.*|.*_PROXY)$/i.test(key))
135
+ delete env[key];
136
+ return env;
137
+ }
138
+ /** Runtime adapter, shared with real-process OS acceptance tests. */
139
+ async function runContainedCommand(value, command) {
140
+ const profile = (0, protectionProfile_1.parseProtectionProfile)(value);
141
+ if (profile.platform !== process.platform)
142
+ throw new Error('Profile operating system mismatch.');
143
+ if (!command || command.length > 32000)
144
+ throw new Error('Invalid launch command.');
145
+ // Keep the ESM runtime lazy: existing hooks and older Node versions never load it.
146
+ const runtimeRoot = path.resolve(__dirname, '../containment-runtime');
147
+ const runtime = await new Function('url', 'return import(url)')((0, url_1.pathToFileURL)(path.join(runtimeRoot, 'index.mjs')).href);
148
+ const settings = (0, protectionProfile_1.protectionRuntimeSettings)(profile);
149
+ const helper = process.platform === 'win32' ? path.join(runtimeRoot, 'vendor/srt-win', process.arch, 'srt-win.exe') : undefined;
150
+ if (helper && !fs.existsSync(helper))
151
+ throw new Error('The Windows containment helper is missing. Repair the CLI installation before launching.');
152
+ const lease = await (0, containmentLease_1.acquireContainmentLease)();
153
+ let leaseLost = false;
154
+ let running;
155
+ let executionStarted = false;
156
+ void lease.lost.then(() => { leaseLost = true; running?.kill(); });
157
+ try {
158
+ // srt-win's bulk session stamp loses read denial when the same path is
159
+ // also supplied as denyWrite. Keep read denial held by the session and
160
+ // apply write denial through the runtime's separate per-exec holder.
161
+ await runtime.SandboxManager.initialize({ ...settings, ...(helper ? { filesystem: { ...settings.filesystem, denyWrite: [] }, windows: { srtWin: { path: helper } } } : {}) });
162
+ if (!runtime.SandboxManager.isSupportedPlatform() || !runtime.SandboxManager.isSandboxingEnabled() || !await runtime.SandboxManager.waitForNetworkInitialization())
163
+ throw new Error('Containment is unavailable. The command was not started.');
164
+ const env = containedExecutionEnvironment(process.env);
165
+ let executable, args, childEnv = env;
166
+ if (process.platform === 'win32') {
167
+ const wrapped = await runtime.SandboxManager.wrapWithSandboxArgv(command, undefined, { filesystem: { allowWrite: [], denyRead: [], denyWrite: settings.filesystem.denyWrite } }, undefined, profile.workspace);
168
+ executable = wrapped.argv[0];
169
+ args = wrapped.argv.slice(1);
170
+ childEnv = { ...env, ...wrapped.env };
171
+ }
172
+ else {
173
+ executable = '/bin/sh';
174
+ args = ['-c', await runtime.SandboxManager.wrapWithSandbox(command)];
175
+ }
176
+ console.error(`Starting contained execution with profile "${profile.name}". Existing processes are unaffected.`);
177
+ if (leaseLost)
178
+ throw new Error('Containment lock was lost before launch.');
179
+ return await new Promise((resolve, reject) => {
180
+ const child = (0, child_process_1.spawn)(executable, args, { cwd: profile.workspace, env: childEnv, shell: false, stdio: 'inherit', windowsHide: true });
181
+ running = child;
182
+ child.once('spawn', () => { executionStarted = true; });
183
+ child.once('error', reject);
184
+ child.once('close', code => { running = undefined; resolve(leaseLost ? 1 : code ?? 1); });
185
+ });
186
+ }
187
+ catch (error) {
188
+ throw new ContainedLaunchFailure(error instanceof Error ? error.message : 'Contained execution failed.', executionStarted);
189
+ }
190
+ finally {
191
+ let cleanupError;
192
+ try {
193
+ await runtime.SandboxManager.reset();
194
+ }
195
+ catch (error) {
196
+ cleanupError = error;
197
+ }
198
+ try {
199
+ await lease.release();
200
+ }
201
+ catch (error) {
202
+ cleanupError ||= error;
203
+ }
204
+ if (cleanupError)
205
+ throw new ContainedLaunchFailure('Containment cleanup failed. Check the endpoint before another launch.', executionStarted);
206
+ }
207
+ }