@hearsay-tools/squawk 0.18.0-dev.6896 → 0.18.0-dev.6924
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 +4 -5
- package/dist/agent-config/account-identity.js +0 -1
- package/dist/agent-config/account-identity.js.map +1 -1
- package/dist/agent-config/catalog.d.ts +0 -2
- package/dist/agent-config/catalog.js +3 -41
- package/dist/agent-config/catalog.js.map +1 -1
- package/dist/agent-config/models.js +0 -4
- package/dist/agent-config/models.js.map +1 -1
- package/dist/automations/service.d.ts +14 -14
- package/dist/ci-wait/controller.d.ts +20 -5
- package/dist/ci-wait/errors.js +2 -0
- package/dist/ci-wait/errors.js.map +1 -1
- package/dist/ci-wait/tool-catalog.js +1 -1
- package/dist/ci-wait/tool-catalog.js.map +1 -1
- package/dist/ci-wait/tools.d.ts +20 -5
- package/dist/config.d.ts +0 -2
- package/dist/config.js +0 -1
- package/dist/config.js.map +1 -1
- package/dist/contract/activity.d.ts +0 -7
- package/dist/contract/agent-config.d.ts +0 -2
- package/dist/contract/agent-profiles.d.ts +0 -15
- package/dist/contract/automation-requests.d.ts +0 -6
- package/dist/contract/automation-storage.d.ts +0 -6
- package/dist/contract/automations.d.ts +0 -18
- package/dist/contract/config-requests.d.ts +0 -2
- package/dist/contract/delegation.d.ts +0 -8
- package/dist/contract/discovery.d.ts +0 -8
- package/dist/contract/health.d.ts +0 -3
- package/dist/contract/index.d.ts +1 -0
- package/dist/contract/index.js +50 -42
- package/dist/contract/per-runner-optional-strings.d.ts +1 -2
- package/dist/contract/provider-requests.d.ts +0 -5
- package/dist/contract/query-requests.d.ts +0 -1
- package/dist/contract/run-predicates.d.ts +8 -2
- package/dist/contract/run-requests.d.ts +0 -1
- package/dist/contract/runner-facts.d.ts +2 -42
- package/dist/contract/runner.d.ts +4 -1
- package/dist/contract/runs.d.ts +42 -44
- package/dist/contract/waits.d.ts +37 -0
- package/dist/contract/workflow-file.d.ts +0 -1
- package/dist/contract/workflows.d.ts +0 -6
- package/dist/contract/workspace-events.d.ts +2 -4
- package/dist/contract/workspace.d.ts +1 -20
- package/dist/core/agent-env.js +0 -1
- package/dist/core/agent-env.js.map +1 -1
- package/dist/core/agent-profiles.js +0 -3
- package/dist/core/agent-profiles.js.map +1 -1
- package/dist/core/agent-runner.d.ts +10 -15
- package/dist/core/agent-runner.js +3 -2
- package/dist/core/agent-runner.js.map +1 -1
- package/dist/core/backend-detect.js +0 -14
- package/dist/core/backend-detect.js.map +1 -1
- package/dist/core/host-model-catalog.js +0 -2
- package/dist/core/host-model-catalog.js.map +1 -1
- package/dist/core/model-identity.js +0 -3
- package/dist/core/model-identity.js.map +1 -1
- package/dist/core/model-presets.js +0 -4
- package/dist/core/model-presets.js.map +1 -1
- package/dist/core/model-probe-spawn.d.ts +9 -0
- package/dist/core/model-probe-spawn.js +7 -0
- package/dist/core/model-probe-spawn.js.map +1 -0
- package/dist/core/omp-model-catalog.d.ts +3 -5
- package/dist/core/omp-model-catalog.js +3 -8
- package/dist/core/omp-model-catalog.js.map +1 -1
- package/dist/core/pi-model-catalog.d.ts +3 -5
- package/dist/core/pi-model-catalog.js +3 -7
- package/dist/core/pi-model-catalog.js.map +1 -1
- package/dist/core/process-usage.d.ts +1 -1
- package/dist/core/process-usage.js +1 -1
- package/dist/core/process-usage.js.map +1 -1
- package/dist/core/provider-auth.d.ts +1 -1
- package/dist/core/provider-auth.js +0 -29
- package/dist/core/provider-auth.js.map +1 -1
- package/dist/core/runner-cli.js +0 -2
- package/dist/core/runner-cli.js.map +1 -1
- package/dist/core/runner-factory.d.ts +1 -4
- package/dist/core/runner-factory.js +1 -4
- package/dist/core/runner-factory.js.map +1 -1
- package/dist/core/runner-facts.d.ts +5 -28
- package/dist/core/runner-facts.js +0 -20
- package/dist/core/runner-facts.js.map +1 -1
- package/dist/core/runner-model-catalog.d.ts +0 -3
- package/dist/core/runner-model-catalog.js +1 -25
- package/dist/core/runner-model-catalog.js.map +1 -1
- package/dist/core/session-process.d.ts +0 -4
- package/dist/core/session-process.js +0 -15
- package/dist/core/session-process.js.map +1 -1
- package/dist/core/ui-events.d.ts +1 -1
- package/dist/delegation/conversations.d.ts +24 -8
- package/dist/delegation/execution-identity.d.ts +3 -9
- package/dist/delegation/execution-identity.js +7 -1
- package/dist/delegation/execution-identity.js.map +1 -1
- package/dist/delegation/provision.js +2 -1
- package/dist/delegation/provision.js.map +1 -1
- package/dist/delegation/routes.d.ts +9 -9
- package/dist/delegation/transport.d.ts +7 -7
- package/dist/discovery/cli.js +2 -1
- package/dist/discovery/cli.js.map +1 -1
- package/dist/paths.js +1 -4
- package/dist/paths.js.map +1 -1
- package/dist/runs/legacy-run-rows.d.ts +13 -0
- package/dist/runs/legacy-run-rows.js +60 -0
- package/dist/runs/legacy-run-rows.js.map +1 -1
- package/dist/runs/outcome-commit.d.ts +24 -1
- package/dist/runs/outcome-commit.js +15 -0
- package/dist/runs/outcome-commit.js.map +1 -1
- package/dist/runs/run-exits.d.ts +68 -20
- package/dist/runs/run-summary-page.js +2 -0
- package/dist/runs/run-summary-page.js.map +1 -1
- package/dist/runs/store.d.ts +25 -19
- package/dist/runs/store.js +3 -3
- package/dist/runs/store.js.map +1 -1
- package/dist/server/activity-routes.d.ts +2 -2
- package/dist/server/live-routes.d.ts +6 -6
- package/dist/server/open-in-app.js +0 -1
- package/dist/server/open-in-app.js.map +1 -1
- package/dist/server/server.d.ts +369 -240
- package/dist/server/server.js +10 -37
- package/dist/server/server.js.map +1 -1
- package/dist/server/workspace-live-routes.d.ts +6 -6
- package/dist/server-install/steps.js +0 -1
- package/dist/server-install/steps.js.map +1 -1
- package/dist/skills-remote.d.ts +1 -1
- package/dist/skills-remote.js +1 -1
- package/dist/skills-remote.js.map +1 -1
- package/dist/workflows/continuation-admission.d.ts +26 -13
- package/dist/workflows/continuation-admission.js +16 -13
- package/dist/workflows/continuation-admission.js.map +1 -1
- package/dist/workflows/run/continuation-session.d.ts +1 -2
- package/dist/workflows/run/continuation-session.js +1 -5
- package/dist/workflows/run/continuation-session.js.map +1 -1
- package/dist/workflows/run/done-accepted.d.ts +36 -0
- package/dist/workflows/run/done-accepted.js +123 -0
- package/dist/workflows/run/done-accepted.js.map +1 -0
- package/dist/workflows/run/input-delivery.d.ts +11 -0
- package/dist/workflows/run/input-delivery.js +45 -9
- package/dist/workflows/run/input-delivery.js.map +1 -1
- package/dist/workflows/run/launch-read-resolver.d.ts +11 -14
- package/dist/workflows/run/launch-read-resolver.js +8 -22
- package/dist/workflows/run/launch-read-resolver.js.map +1 -1
- package/dist/workflows/run/queued-revival.d.ts +2 -2
- package/dist/workflows/run/queued-revival.js +17 -6
- package/dist/workflows/run/queued-revival.js.map +1 -1
- package/dist/workflows/run/run-finish.d.ts +11 -7
- package/dist/workflows/run/run-finish.js +33 -10
- package/dist/workflows/run/run-finish.js.map +1 -1
- package/dist/workflows/run/run-skills.d.ts +2 -2
- package/dist/workflows/run/run-skills.js +3 -4
- package/dist/workflows/run/run-skills.js.map +1 -1
- package/dist/workflows/run/session-events.js +1 -2
- package/dist/workflows/run/session-events.js.map +1 -1
- package/dist/workflows/run/turn-boundary.d.ts +6 -5
- package/dist/workflows/run/turn-boundary.js +8 -11
- package/dist/workflows/run/turn-boundary.js.map +1 -1
- package/dist/workflows/run/turn-nudges.d.ts +1 -1
- package/dist/workflows/run/turn-nudges.js +2 -2
- package/dist/workflows/run/turn-nudges.js.map +1 -1
- package/dist/workflows/run/turn-settler.d.ts +45 -4
- package/dist/workflows/run/turn-settler.js +85 -9
- package/dist/workflows/run/turn-settler.js.map +1 -1
- package/dist/workflows/run/types.d.ts +3 -1
- package/dist/workflows/run/wait-engine.d.ts +12 -4
- package/dist/workflows/run/wait-kinds.d.ts +5 -0
- package/dist/workflows/run/wait-kinds.js +13 -0
- package/dist/workflows/run/wait-kinds.js.map +1 -1
- package/dist/workflows/run-scheduling.js +4 -0
- package/dist/workflows/run-scheduling.js.map +1 -1
- package/dist/workflows/run-states.js +1 -1
- package/dist/workflows/run-states.js.map +1 -1
- package/dist/workflows/run.js +12 -0
- package/dist/workflows/run.js.map +1 -1
- package/dist/workflows/turn-end.d.ts +8 -1
- package/dist/workflows/turn-end.js +6 -0
- package/dist/workflows/turn-end.js.map +1 -1
- package/dist/workflows/types.js +0 -1
- package/dist/workflows/types.js.map +1 -1
- package/dist/workspace/agent-accounts.d.ts +1 -5
- package/dist/workspace/agent-accounts.js +0 -1
- package/dist/workspace/agent-accounts.js.map +1 -1
- package/dist/workspace/config.d.ts +1 -3
- package/dist/workspace/config.js +0 -1
- package/dist/workspace/config.js.map +1 -1
- package/package.json +4 -4
- package/scripts/mock-ci-tool.mjs +2 -15
- package/scripts/mock-deferred-turn-start.mjs +1 -1
- package/scripts/mock-provider-failures.mjs +0 -9
- package/scripts/mock-scenario.d.mts +1 -1
- package/scripts/mock-scenario.mjs +2 -2
- package/web/dist/assets/activity-motion-DXtoOkpz.js +2 -0
- package/web/dist/assets/{activity-route-BtpWRWaI.js → activity-route-r-em7Y-G.js} +1 -1
- package/web/dist/assets/agent-accounts-DuMsyDoO.js +18 -0
- package/web/dist/assets/attention-CB_z05E7.js +1 -0
- package/web/dist/assets/{cez-idle-BqmM5iRr.js → cez-idle-D49bY6KR.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-BAcn8Zwc.js → commit-diff-panel-BGLQaKRb.js} +1 -1
- package/web/dist/assets/diff-BRFJnYsC.js +3 -0
- package/web/dist/assets/{diff-view-CAj8XOsx.js → diff-view-JWqbvzMs.js} +3 -3
- package/web/dist/assets/{file-preview-CzhHbtFx.js → file-preview-BW__Krxm.js} +1 -1
- package/web/dist/assets/{git-toolbar-pjYcYQ1l.js → git-toolbar-DoXf_s-G.js} +1 -1
- package/web/dist/assets/{github-Db4ZPDpJ.js → github-CijmslJ6.js} +1 -1
- package/web/dist/assets/{global-activity-route-CfZ-oTGX.js → global-activity-route-B2EeYnAW.js} +1 -1
- package/web/dist/assets/index-BHoqo9RG.js +17 -0
- package/web/dist/assets/{live-protocol-BmbbwF5R.js → live-protocol-DHEBTIRD.js} +1 -1
- package/web/dist/assets/preview-pane-connected-D6vrA6hJ.js +3 -0
- package/web/dist/assets/{project-router-BqAKGSaS.js → project-router-C5EZmTkk.js} +1 -1
- package/web/dist/assets/project-scope-context-HUq7jkZN.js +4 -0
- package/web/dist/assets/{prompt-template-menu-DpCrLDWG.js → prompt-template-menu-DOYsMTKv.js} +1 -1
- package/web/dist/assets/queries-BXHx1ZPw.js +1 -0
- package/web/dist/assets/{reference-chip-Dd_YU2KX.js → reference-chip-CjJnlcQb.js} +1 -1
- package/web/dist/assets/{repo-git-DidsKXQR.js → repo-git-CyRoQgtr.js} +1 -1
- package/web/dist/assets/{report-reader-Bot131OL.js → report-reader-BJiEbYfZ.js} +1 -1
- package/web/dist/assets/reports-Ddn-WBxa.js +1 -0
- package/web/dist/assets/run-header-B7qHisMu.js +2 -0
- package/web/dist/assets/runner-facts-BpvNgJqf.js +1 -0
- package/web/dist/assets/skills-D2wzJWpY.js +1 -0
- package/web/dist/assets/{tab-link-CGzPcVvS.js → tab-link-B_gKjZgM.js} +1 -1
- package/web/dist/assets/{task-changes-Cn3UEQgA.js → task-changes-CqKQIYHP.js} +1 -1
- package/web/dist/assets/{task-commits-P_uuPKA_.js → task-commits-CY7XFJBU.js} +1 -1
- package/web/dist/assets/{task-files-Ny2doN2P.js → task-files-CW1gWAY3.js} +1 -1
- package/web/dist/assets/{task-github-item-C0Ymd8MZ.js → task-github-item-Djq-z2As.js} +1 -1
- package/web/dist/assets/task-thread-DyZ9WjLc.js +9 -0
- package/web/dist/assets/{thread-state-vR42DISv.js → thread-state-Dbru_dO3.js} +1 -1
- package/web/dist/assets/use-desktop-BCMH-x7R.js +1 -0
- package/web/dist/assets/{use-hand-to-agent-state-J8aDr8ea.js → use-hand-to-agent-state-C94Si0KS.js} +1 -1
- package/web/dist/assets/{useInfiniteQuery-DYAQvmMU.js → useInfiniteQuery-O53uZ95W.js} +1 -1
- package/web/dist/assets/useQuery-C9ErlZEv.js +1 -0
- package/web/dist/assets/workflows-CwS6zbSa.js +7 -0
- package/web/dist/assets/{ws-BXpZYApG.js → ws-CRnL5yIc.js} +1 -1
- package/web/dist/index.html +15 -14
- package/web/dist/live-worker.js +1 -1
- package/dist/core/cursor-cli-flags.d.ts +0 -19
- package/dist/core/cursor-cli-flags.js +0 -47
- package/dist/core/cursor-cli-flags.js.map +0 -1
- package/dist/core/cursor-config-options.d.ts +0 -18
- package/dist/core/cursor-config-options.js +0 -31
- package/dist/core/cursor-config-options.js.map +0 -1
- package/dist/core/cursor-model-catalog.d.ts +0 -50
- package/dist/core/cursor-model-catalog.js +0 -306
- package/dist/core/cursor-model-catalog.js.map +0 -1
- package/dist/core/cursor-print-capabilities.d.ts +0 -14
- package/dist/core/cursor-print-capabilities.js +0 -169
- package/dist/core/cursor-print-capabilities.js.map +0 -1
- package/dist/core/cursor-print-process.d.ts +0 -36
- package/dist/core/cursor-print-process.js +0 -117
- package/dist/core/cursor-print-process.js.map +0 -1
- package/dist/core/cursor-print-runner.d.ts +0 -50
- package/dist/core/cursor-print-runner.js +0 -582
- package/dist/core/cursor-print-runner.js.map +0 -1
- package/dist/core/cursor-print-tool-catalog.d.ts +0 -3
- package/dist/core/cursor-print-tool-catalog.js +0 -13
- package/dist/core/cursor-print-tool-catalog.js.map +0 -1
- package/dist/core/cursor-print-ui-mapper.d.ts +0 -47
- package/dist/core/cursor-print-ui-mapper.js +0 -574
- package/dist/core/cursor-print-ui-mapper.js.map +0 -1
- package/dist/core/cursor-provider-error.d.ts +0 -9
- package/dist/core/cursor-provider-error.js +0 -15
- package/dist/core/cursor-provider-error.js.map +0 -1
- package/dist/core/cursor-runner.d.ts +0 -53
- package/dist/core/cursor-runner.js +0 -145
- package/dist/core/cursor-runner.js.map +0 -1
- package/scripts/mock-cursor-hang-stdin-late.mjs +0 -35
- package/scripts/mock-cursor-hang-stdin.mjs +0 -30
- package/scripts/mock-cursor-print.mjs +0 -237
- package/scripts/probe-cursor-print.mjs +0 -699
- package/web/dist/assets/activity-motion-G1BZ9DIT.js +0 -2
- package/web/dist/assets/agent-accounts-D3q1WLxk.js +0 -18
- package/web/dist/assets/attention-CdwMIvQG.js +0 -1
- package/web/dist/assets/diff-Ddd4e5lP.js +0 -3
- package/web/dist/assets/index-D1o36xol.js +0 -17
- package/web/dist/assets/preview-pane-connected-DWfaVvcP.js +0 -3
- package/web/dist/assets/project-scope-context-B0yKt2yI.js +0 -4
- package/web/dist/assets/queries-DoYRza8s.js +0 -1
- package/web/dist/assets/reports-5btvRQBd.js +0 -1
- package/web/dist/assets/run-header-CW2gc5KU.js +0 -2
- package/web/dist/assets/skills-D4z3ycnU.js +0 -1
- package/web/dist/assets/task-thread-BiDNqWXW.js +0 -9
- package/web/dist/assets/use-desktop-BwkqVHep.js +0 -1
- package/web/dist/assets/useQuery-CnVG8NoC.js +0 -1
- package/web/dist/assets/workflows-CzgcLCOI.js +0 -7
|
@@ -1,699 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { productEnv } from './product-env.mjs';
|
|
3
|
-
// Opt-in vendor probe. It saves only a small allowlisted summary, never a transcript.
|
|
4
|
-
import { spawn, spawnSync } from 'node:child_process';
|
|
5
|
-
import { createHash, randomBytes, randomUUID } from 'node:crypto';
|
|
6
|
-
import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
7
|
-
import { tmpdir } from 'node:os';
|
|
8
|
-
import { join, resolve } from 'node:path';
|
|
9
|
-
import { parseArgs } from 'node:util';
|
|
10
|
-
import { deflateSync } from 'node:zlib';
|
|
11
|
-
|
|
12
|
-
const { values } = parseArgs({ options: {
|
|
13
|
-
model: { type: 'string' },
|
|
14
|
-
'output-dir': { type: 'string' },
|
|
15
|
-
case: { type: 'string' },
|
|
16
|
-
} });
|
|
17
|
-
if (!values.model || !values['output-dir'] || !['native-question', 'delegation', 'mcp', 'plugins', 'resume-missing', 'fields', 'plugin-lifecycle', 'errors'].includes(values.case)) {
|
|
18
|
-
process.stderr.write('Usage: probe-cursor-print.mjs --model <discovered-id> --output-dir <path> --case native-question|delegation|mcp|plugins|resume-missing|fields|plugin-lifecycle|errors\n');
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const bin = productEnv('CURSOR_BIN') || 'agent';
|
|
23
|
-
const scratch = mkdtempSync(join(tmpdir(), 'cez-cursor-print-probe-'));
|
|
24
|
-
const checkout = join(scratch, 'checkout');
|
|
25
|
-
const outputDir = resolve(values['output-dir']);
|
|
26
|
-
|
|
27
|
-
function git(args) {
|
|
28
|
-
const result = spawnSync('git', args, { encoding: 'utf8', timeout: 15_000 });
|
|
29
|
-
if (result.status !== 0) throw new Error(`git ${args[0]} failed`);
|
|
30
|
-
return result.stdout.trim();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Keep the probed build installed while it is probed (hearsay-tools/cezarion#1257). A build
|
|
34
|
-
// that rejects the hidden option exits 1 with commander's unknown-option line before any work,
|
|
35
|
-
// so the probe reruns that call without it and leaves it out from then on.
|
|
36
|
-
let disableAutoUpdate = true;
|
|
37
|
-
async function runAgent(args, cwd, timeoutMs, env = process.env) {
|
|
38
|
-
const run = await runAgentOnce(disableAutoUpdate ? ['--disable-auto-update', ...args] : args, cwd, timeoutMs, env);
|
|
39
|
-
if (!disableAutoUpdate || run.code !== 1 || !run.stderr.includes("unknown option '--disable-auto-update'")) return run;
|
|
40
|
-
disableAutoUpdate = false;
|
|
41
|
-
return runAgentOnce(args, cwd, timeoutMs, env);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function runAgentOnce(args, cwd, timeoutMs, env) {
|
|
45
|
-
return new Promise((resolveRun, rejectRun) => {
|
|
46
|
-
const child = spawn(bin, args, { cwd, env, detached: process.platform !== 'win32', stdio: ['ignore', 'pipe', 'pipe'] });
|
|
47
|
-
let stdout = '';
|
|
48
|
-
let stderr = '';
|
|
49
|
-
let truncated = false;
|
|
50
|
-
let timedOut = false;
|
|
51
|
-
const append = (current, chunk) => {
|
|
52
|
-
if (current.length + chunk.length > 1_048_576) { truncated = true; return current; }
|
|
53
|
-
return current + chunk;
|
|
54
|
-
};
|
|
55
|
-
child.stdout.setEncoding('utf8');
|
|
56
|
-
child.stderr.setEncoding('utf8');
|
|
57
|
-
child.stdout.on('data', chunk => { stdout = append(stdout, chunk); });
|
|
58
|
-
child.stderr.on('data', chunk => { stderr = append(stderr, chunk); });
|
|
59
|
-
const signalGroup = signal => {
|
|
60
|
-
try { process.kill(process.platform === 'win32' ? child.pid : -child.pid, signal); } catch { /* already gone */ }
|
|
61
|
-
};
|
|
62
|
-
const groupAlive = () => {
|
|
63
|
-
try { process.kill(process.platform === 'win32' ? child.pid : -child.pid, 0); return true; } catch { return false; }
|
|
64
|
-
};
|
|
65
|
-
const timer = setTimeout(() => { timedOut = true; signalGroup('SIGTERM'); }, timeoutMs);
|
|
66
|
-
const escalation = setTimeout(() => signalGroup('SIGKILL'), timeoutMs + 2_000);
|
|
67
|
-
child.on('error', error => { clearTimeout(timer); clearTimeout(escalation); rejectRun(error); });
|
|
68
|
-
child.on('close', async code => {
|
|
69
|
-
clearTimeout(timer);
|
|
70
|
-
clearTimeout(escalation);
|
|
71
|
-
signalGroup('SIGTERM');
|
|
72
|
-
await new Promise(done => setTimeout(done, 500));
|
|
73
|
-
if (groupAlive()) signalGroup('SIGKILL');
|
|
74
|
-
await new Promise(done => setTimeout(done, 100));
|
|
75
|
-
resolveRun({ code, stdout, stderr, truncated, timedOut, processGroupGone: !groupAlive() });
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function framesOf(stdout) {
|
|
81
|
-
return stdout.split('\n').flatMap(line => {
|
|
82
|
-
try { return [JSON.parse(line)]; } catch { return []; }
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function toolKindsOf(frames) {
|
|
87
|
-
return [...new Set(frames.flatMap(frame => frame.type === 'tool_call'
|
|
88
|
-
? Object.keys(frame.tool_call ?? {}).filter(key => key.endsWith('ToolCall')) : []))].sort();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function resultOf(frames) {
|
|
92
|
-
return frames.findLast(frame => frame.type === 'result');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function askQuestionQueryOf(frames) {
|
|
96
|
-
const request = frames.find(frame => frame.type === 'interaction_query' && frame.subtype === 'request' && frame.query_type === 'askQuestionInteractionQuery');
|
|
97
|
-
const response = frames.find(frame => frame.type === 'interaction_query' && frame.subtype === 'response' && frame.query_type === 'askQuestionInteractionQuery');
|
|
98
|
-
const rejection = response?.response?.askQuestionInteractionResponse?.result?.rejected?.reason;
|
|
99
|
-
return { request, response, rejection };
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function askQuestionKindOf(response, rejection) {
|
|
103
|
-
return {
|
|
104
|
-
responseKind: rejection ? 'rejected' : response ? 'other' : 'none',
|
|
105
|
-
rejectionKind: typeof rejection === 'string' && rejection.includes('skipped') ? 'skipped' : rejection ? 'other' : 'none',
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function askQuestionSessionOf(request, response) {
|
|
110
|
-
return {
|
|
111
|
-
sameSession: Boolean(request && response && request.session_id === response.session_id),
|
|
112
|
-
responseDelayMs: request && response ? response.timestamp_ms - request.timestamp_ms : null,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function nativeQuestionOutcome(run, request, response, rejection) {
|
|
117
|
-
return run.code === 0 && !run.timedOut && !run.truncated && request && response && request.session_id === response.session_id && rejection?.includes('skipped')
|
|
118
|
-
? 'blocked' : request && response ? 'unqualified' : 'inconclusive';
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
async function probeNativeQuestion(version) {
|
|
122
|
-
const run = await runAgent([
|
|
123
|
-
'-p', '--force', '--trust', '--output-format', 'stream-json',
|
|
124
|
-
'--model', values.model, '--allowed-tools', 'ask_question_tool_call',
|
|
125
|
-
'Use the native AskQuestion tool now. Ask me to choose Alpha or Beta. Do not answer it yourself and do not use any other tool.',
|
|
126
|
-
], checkout, 45_000);
|
|
127
|
-
|
|
128
|
-
const frames = framesOf(run.stdout);
|
|
129
|
-
const { request, response, rejection } = askQuestionQueryOf(frames);
|
|
130
|
-
return {
|
|
131
|
-
schema: 1,
|
|
132
|
-
case: 'native-question',
|
|
133
|
-
cliVersion: version,
|
|
134
|
-
model: values.model,
|
|
135
|
-
invocation: ['-p', '--force', '--trust', '--output-format stream-json', '--allowed-tools ask_question_tool_call'],
|
|
136
|
-
exitCode: run.code,
|
|
137
|
-
timedOut: run.timedOut,
|
|
138
|
-
outputTruncated: run.truncated,
|
|
139
|
-
nativeQuestionRequested: Boolean(request),
|
|
140
|
-
nativeQuestionAnswered: Boolean(response),
|
|
141
|
-
...askQuestionKindOf(response, rejection),
|
|
142
|
-
...askQuestionSessionOf(request, response),
|
|
143
|
-
outcome: nativeQuestionOutcome(run, request, response, rejection),
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const nativeDelegationEntries = [
|
|
148
|
-
'task_tool_call', 'create_agent_tool_call', 'adopt_tool_call',
|
|
149
|
-
'send_to_agent_tool_call', 'send_message_tool_call',
|
|
150
|
-
'get_agent_status_tool_call', 'stop_agent_tool_call',
|
|
151
|
-
'read_agent_transcript_tool_call', 'start_grind_execution_tool_call',
|
|
152
|
-
'start_grind_planning_tool_call',
|
|
153
|
-
];
|
|
154
|
-
|
|
155
|
-
async function discoverSafeAllowedTools() {
|
|
156
|
-
// Cursor validates this public proto-oneof list before inference. The name
|
|
157
|
-
// is deliberately invalid; no model or native worker can run in this step.
|
|
158
|
-
const catalogRun = await runAgent([
|
|
159
|
-
'-p', '--force', '--trust', '--output-format', 'stream-json',
|
|
160
|
-
'--model', values.model, '--allowed-tools', 'definitelyNotATool', 'Reply OK.',
|
|
161
|
-
], checkout, 15_000);
|
|
162
|
-
const names = catalogRun.stderr.match(/Expected one of: ([a-z_, ]+)/)?.[1]
|
|
163
|
-
?.split(',').map(value => value.trim()).filter(Boolean) ?? [];
|
|
164
|
-
const safeAllowedTools = names.filter(name => !nativeDelegationEntries.includes(name));
|
|
165
|
-
return { catalogRun, names, safeAllowedTools };
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function writeCanary(name) {
|
|
169
|
-
const canary = randomBytes(16).toString('hex');
|
|
170
|
-
writeFileSync(join(checkout, name), `${canary}\n`, { mode: 0o600 });
|
|
171
|
-
return canary;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const delegationPrompt = name => `Use the native Read tool to read ${name}, then reply with its exact contents. Do not use any other tool.`;
|
|
175
|
-
|
|
176
|
-
async function delegationReadTurn(args) {
|
|
177
|
-
return runAgent(['-p', '--force', '--trust', '--output-format', 'stream-json',
|
|
178
|
-
'--model', values.model, ...args], checkout, 45_000);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function delegationTurnFacts(frames, canary) {
|
|
182
|
-
return { tools: toolKindsOf(frames), sawCanary: String(resultOf(frames)?.result ?? '').includes(canary) };
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function sameDelegationSession(firstId, secondFrames, thirdFrames) {
|
|
186
|
-
return Boolean(firstId && firstId === resultOf(secondFrames)?.session_id
|
|
187
|
-
&& firstId === resultOf(thirdFrames)?.session_id);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function delegationCatalogVerified(catalogRun, names, noDelegationEntriesInAllowlist) {
|
|
191
|
-
return catalogRun.code === 1 && !catalogRun.timedOut
|
|
192
|
-
&& names.includes('task_tool_call') && names.includes('create_agent_tool_call')
|
|
193
|
-
&& nativeDelegationEntries.every(name => names.includes(name)) && noDelegationEntriesInAllowlist;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function delegationTurnVerified(run, facts, toolExpected) {
|
|
197
|
-
return run?.code === 0 && !run.timedOut && !run.truncated
|
|
198
|
-
&& facts.tools.includes('readToolCall') === toolExpected && facts.sawCanary === toolExpected;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function delegationOutcome(catalogRun, names, noDelegationEntriesInAllowlist, first, firstFacts, second, secondFacts, third, thirdFacts, sameSession) {
|
|
202
|
-
return delegationCatalogVerified(catalogRun, names, noDelegationEntriesInAllowlist)
|
|
203
|
-
&& delegationTurnVerified(first, firstFacts, true)
|
|
204
|
-
&& delegationTurnVerified(second, secondFacts, false)
|
|
205
|
-
&& delegationTurnVerified(third, thirdFacts, true)
|
|
206
|
-
&& sameSession ? 'pass' : 'blocked';
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
async function probeDelegation(version) {
|
|
210
|
-
const { catalogRun, names, safeAllowedTools } = await discoverSafeAllowedTools();
|
|
211
|
-
|
|
212
|
-
const firstCanary = writeCanary('probe-first.txt');
|
|
213
|
-
const first = await delegationReadTurn(['--allowed-tools', 'read_tool_call', delegationPrompt('probe-first.txt')]);
|
|
214
|
-
const firstFrames = framesOf(first.stdout);
|
|
215
|
-
const firstId = resultOf(firstFrames)?.session_id;
|
|
216
|
-
|
|
217
|
-
const secondCanary = writeCanary('probe-second.txt');
|
|
218
|
-
const second = firstId ? await delegationReadTurn(['--resume', firstId,
|
|
219
|
-
'--allowed-tools', 'read_todos_tool_call', delegationPrompt('probe-second.txt')]) : undefined;
|
|
220
|
-
const secondFrames = second ? framesOf(second.stdout) : [];
|
|
221
|
-
|
|
222
|
-
const thirdCanary = writeCanary('probe-third.txt');
|
|
223
|
-
const third = firstId && second ? await delegationReadTurn(['--resume', firstId,
|
|
224
|
-
'--allowed-tools', safeAllowedTools.join(','), delegationPrompt('probe-third.txt')]) : undefined;
|
|
225
|
-
const thirdFrames = third ? framesOf(third.stdout) : [];
|
|
226
|
-
|
|
227
|
-
const firstFacts = delegationTurnFacts(firstFrames, firstCanary);
|
|
228
|
-
const secondFacts = delegationTurnFacts(secondFrames, secondCanary);
|
|
229
|
-
const thirdFacts = delegationTurnFacts(thirdFrames, thirdCanary);
|
|
230
|
-
const sameSession = sameDelegationSession(firstId, secondFrames, thirdFrames);
|
|
231
|
-
const noDelegationEntriesInAllowlist = nativeDelegationEntries.every(name => !safeAllowedTools.includes(name));
|
|
232
|
-
return {
|
|
233
|
-
schema: 1,
|
|
234
|
-
case: 'delegation',
|
|
235
|
-
cliVersion: version,
|
|
236
|
-
model: values.model,
|
|
237
|
-
testedMechanism: '--allowed-tools',
|
|
238
|
-
catalogValidatedBeforeInference: catalogRun.code === 1 && names.includes('task_tool_call'),
|
|
239
|
-
nativeDelegationEntries,
|
|
240
|
-
safeAllowedTools,
|
|
241
|
-
freshReadToolCalled: firstFacts.tools.includes('readToolCall'),
|
|
242
|
-
freshReadSucceeded: firstFacts.sawCanary,
|
|
243
|
-
resumedReadToolCalled: secondFacts.tools.includes('readToolCall'),
|
|
244
|
-
resumedReadSucceeded: secondFacts.sawCanary,
|
|
245
|
-
fullAllowlistReadToolCalled: thirdFacts.tools.includes('readToolCall'),
|
|
246
|
-
fullAllowlistReadSucceeded: thirdFacts.sawCanary,
|
|
247
|
-
noDelegationEntriesInAllowlist,
|
|
248
|
-
sameNativeSession: sameSession,
|
|
249
|
-
directTaskCallAttempted: false,
|
|
250
|
-
outcome: delegationOutcome(catalogRun, names, noDelegationEntriesInAllowlist, first, firstFacts, second, secondFacts, third, thirdFacts, sameSession),
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function mcpCatalogSafe(catalogRun, names, safeAllowedTools) {
|
|
255
|
-
return catalogRun.code === 1 && names.includes('mcp_tool_call')
|
|
256
|
-
&& nativeDelegationEntries.every(name => names.includes(name) && !safeAllowedTools.includes(name));
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
function mcpOutcome(catalogSafe, first, second) {
|
|
260
|
-
return catalogSafe && first.ok && second?.ok && first.id === second.id
|
|
261
|
-
&& !first.stderrMentionsApproval && !second.stderrMentionsApproval ? 'pass' : 'blocked';
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
async function probeMcp(version) {
|
|
265
|
-
const { catalogRun, names, safeAllowedTools } = await discoverSafeAllowedTools();
|
|
266
|
-
const pluginDir = join(checkout, 'cez-probe-plugin');
|
|
267
|
-
mkdirSync(pluginDir);
|
|
268
|
-
writeFileSync(join(pluginDir, 'plugin.json'), JSON.stringify({ name: 'cez-probe-plugin', version: '0.0.1', description: 'Inert local qualification plugin' }));
|
|
269
|
-
writeFileSync(join(pluginDir, 'mcp.json'), JSON.stringify({ mcpServers: { 'cez-probe': {
|
|
270
|
-
type: 'stdio', command: 'node', args: [join(pluginDir, 'server.mjs')],
|
|
271
|
-
env: { CEZ_PROBE_CANARY: '${CEZ_PROBE_CANARY}' },
|
|
272
|
-
} } }));
|
|
273
|
-
writeFileSync(join(pluginDir, 'server.mjs'), `
|
|
274
|
-
import { createHash } from 'node:crypto';
|
|
275
|
-
import { writeFileSync } from 'node:fs';
|
|
276
|
-
writeFileSync(new URL('./started', import.meta.url), '1');
|
|
277
|
-
let buffer = '';
|
|
278
|
-
process.stdin.setEncoding('utf8');
|
|
279
|
-
process.stdin.on('data', chunk => {
|
|
280
|
-
buffer += chunk;
|
|
281
|
-
while (buffer.includes('\\n')) {
|
|
282
|
-
const end = buffer.indexOf('\\n');
|
|
283
|
-
const line = buffer.slice(0, end);
|
|
284
|
-
buffer = buffer.slice(end + 1);
|
|
285
|
-
let request;
|
|
286
|
-
try { request = JSON.parse(line); } catch { continue; }
|
|
287
|
-
if (request.id === undefined) continue;
|
|
288
|
-
let result = {};
|
|
289
|
-
if (request.method === 'initialize') result = {
|
|
290
|
-
protocolVersion: request.params?.protocolVersion || '2024-11-05',
|
|
291
|
-
capabilities: { tools: {} }, serverInfo: { name: 'cez-probe', version: '0.0.1' },
|
|
292
|
-
};
|
|
293
|
-
if (request.method === 'tools/list') result = { tools: [{
|
|
294
|
-
name: 'check_env', description: 'Return a hash of an inherited synthetic environment value',
|
|
295
|
-
inputSchema: { type: 'object', properties: {}, additionalProperties: false },
|
|
296
|
-
}] };
|
|
297
|
-
if (request.method === 'tools/call') {
|
|
298
|
-
writeFileSync(new URL('./called', import.meta.url), '1');
|
|
299
|
-
result = { content: [{ type: 'text', text: 'env-hash:' + createHash('sha256').update(process.env.CEZ_PROBE_CANARY || '').digest('hex') }], isError: false };
|
|
300
|
-
}
|
|
301
|
-
process.stdout.write(JSON.stringify({ jsonrpc: '2.0', id: request.id, result }) + '\\n');
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
`);
|
|
305
|
-
|
|
306
|
-
const runTurn = async (id) => {
|
|
307
|
-
const canary = randomBytes(16).toString('hex');
|
|
308
|
-
const expectedHash = createHash('sha256').update(canary).digest('hex');
|
|
309
|
-
rmSync(join(pluginDir, 'called'), { force: true });
|
|
310
|
-
const run = await runAgent([
|
|
311
|
-
'-p', '--force', '--trust', '--output-format', 'stream-json', '--model', values.model,
|
|
312
|
-
...(id ? ['--resume', id] : []), '--allowed-tools', safeAllowedTools.join(','),
|
|
313
|
-
'--plugin-dir', pluginDir,
|
|
314
|
-
id ? 'The synthetic environment value changed since the last turn. Call cez-probe check_env again now; the previous hash is stale. Report only the new hash. Do not use another tool.'
|
|
315
|
-
: 'Call the cez-probe MCP check_env tool once and report its hash. Do not use any other tool.',
|
|
316
|
-
], checkout, 45_000, { ...process.env, CEZ_PROBE_CANARY: canary });
|
|
317
|
-
const frames = framesOf(run.stdout);
|
|
318
|
-
return {
|
|
319
|
-
id: resultOf(frames)?.session_id,
|
|
320
|
-
ok: run.code === 0 && !run.timedOut && !run.truncated && existsSync(join(pluginDir, 'called'))
|
|
321
|
-
&& run.stdout.includes(expectedHash) && toolKindsOf(frames).includes('mcpToolCall'),
|
|
322
|
-
mcpToolCalled: toolKindsOf(frames).includes('mcpToolCall'),
|
|
323
|
-
serverCalled: existsSync(join(pluginDir, 'called')),
|
|
324
|
-
environmentHashSeen: run.stdout.includes(expectedHash),
|
|
325
|
-
stderrMentionsApproval: /approv/i.test(run.stderr),
|
|
326
|
-
};
|
|
327
|
-
};
|
|
328
|
-
const first = await runTurn();
|
|
329
|
-
const second = first.id ? await runTurn(first.id) : undefined;
|
|
330
|
-
const catalogSafe = mcpCatalogSafe(catalogRun, names, safeAllowedTools);
|
|
331
|
-
return {
|
|
332
|
-
schema: 1, case: 'mcp', cliVersion: version, model: values.model,
|
|
333
|
-
invocation: ['-p', '--force', '--trust', '--output-format stream-json', '--allowed-tools <non-agent catalog>', '--plugin-dir <disposable local plugin>', '--resume <exact native id>'],
|
|
334
|
-
environmentBinding: 'MCP env placeholder expanded from per-process environment',
|
|
335
|
-
globalCursorConfigWritten: false, blanketMcpApprovalUsed: false,
|
|
336
|
-
catalogSafe, freshToolCalled: first.mcpToolCalled, freshServerCalled: first.serverCalled,
|
|
337
|
-
freshEnvironmentHashSeen: first.environmentHashSeen,
|
|
338
|
-
resumedToolCalled: second?.mcpToolCalled ?? false, resumedServerCalled: second?.serverCalled ?? false,
|
|
339
|
-
resumedEnvironmentHashSeen: second?.environmentHashSeen ?? false,
|
|
340
|
-
sameNativeSession: Boolean(first.id && first.id === second?.id),
|
|
341
|
-
stderrMentionsApproval: first.stderrMentionsApproval || Boolean(second?.stderrMentionsApproval),
|
|
342
|
-
outcome: mcpOutcome(catalogSafe, first, second),
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
async function probePlugins(version) {
|
|
347
|
-
// This project-local disable is a negative control. It never changes a
|
|
348
|
-
// user's Cursor installation, marketplace state or Claude settings.
|
|
349
|
-
const claudeSettings = join(checkout, '.claude');
|
|
350
|
-
mkdirSync(claudeSettings, { recursive: true });
|
|
351
|
-
writeFileSync(join(claudeSettings, 'settings.json'), JSON.stringify({ enabledPlugins: {
|
|
352
|
-
'superpowers@apptension-dev': false,
|
|
353
|
-
'superpowers@claude-plugins-official': false,
|
|
354
|
-
'superpowers@apptension-toolkit-dev': false,
|
|
355
|
-
} }));
|
|
356
|
-
const pluginDir = join(checkout, 'cez-inert-plugin');
|
|
357
|
-
mkdirSync(pluginDir);
|
|
358
|
-
writeFileSync(join(pluginDir, 'plugin.json'), JSON.stringify({ name: 'cez-inert-plugin', version: '0.0.1', description: 'Inert qualification plugin' }));
|
|
359
|
-
const { catalogRun, names, safeAllowedTools } = await discoverSafeAllowedTools();
|
|
360
|
-
const run = await runAgent([
|
|
361
|
-
'-p', '--force', '--trust', '--output-format', 'stream-json', '--model', values.model,
|
|
362
|
-
'--allowed-tools', safeAllowedTools.join(','), '--plugin-dir', pluginDir,
|
|
363
|
-
'From your loaded skills, read the Superpowers brainstorming SKILL.md and report its first heading. Do not search the filesystem for a disabled skill.',
|
|
364
|
-
], checkout, 45_000);
|
|
365
|
-
const frames = framesOf(run.stdout);
|
|
366
|
-
const reads = frames.filter(frame => frame.type === 'tool_call' && frame.tool_call?.readToolCall)
|
|
367
|
-
.map(frame => JSON.stringify(frame.tool_call.readToolCall));
|
|
368
|
-
const marketplaceSkillRead = reads.some(read => /\.cursor\/plugins\/cache\/.*superpowers.*SKILL\.md/i.test(read));
|
|
369
|
-
const claudeSkillRead = reads.some(read => /\.claude\/plugins\/.*superpowers.*SKILL\.md/i.test(read));
|
|
370
|
-
return {
|
|
371
|
-
schema: 1, case: 'plugins', cliVersion: version, model: values.model,
|
|
372
|
-
invocation: ['-p', '--force', '--trust', '--output-format stream-json', '--allowed-tools <non-agent catalog>', '--plugin-dir <disposable inert plugin>'],
|
|
373
|
-
projectSettings: '.claude/settings.json enabledPlugins=false for known Superpowers IDs in disposable worktree',
|
|
374
|
-
globalConfigurationWritten: false,
|
|
375
|
-
catalogValidatedBeforeInference: catalogRun.code === 1 && names.includes('read_tool_call'),
|
|
376
|
-
readToolFrames: reads.length, marketplaceSkillRead, claudeSkillRead,
|
|
377
|
-
outcome: run.code === 0 && !run.timedOut && !run.truncated && marketplaceSkillRead
|
|
378
|
-
? 'blocked' : 'inconclusive',
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
async function probeResumeMissing(version) {
|
|
383
|
-
const nonexistentId = randomUUID();
|
|
384
|
-
const run = await runAgent([
|
|
385
|
-
'-p', '--force', '--trust', '--output-format', 'stream-json', '--model', values.model,
|
|
386
|
-
'--resume', nonexistentId, '--allowed-tools', 'read_todos_tool_call',
|
|
387
|
-
'What exact phrase did I ask you to remember in the previous turn of this chat? If this chat has no previous turn, answer NO_PRIOR_TURN.',
|
|
388
|
-
], checkout, 45_000);
|
|
389
|
-
const frames = framesOf(run.stdout);
|
|
390
|
-
const result = resultOf(frames);
|
|
391
|
-
const successWithRequestedId = run.code === 0 && result?.subtype === 'success'
|
|
392
|
-
&& result.session_id === nonexistentId;
|
|
393
|
-
const noPriorTurn = String(result?.result ?? '').includes('NO_PRIOR_TURN');
|
|
394
|
-
return {
|
|
395
|
-
schema: 1, case: 'resume-missing', cliVersion: version, model: values.model,
|
|
396
|
-
invocation: ['-p', '--force', '--trust', '--output-format stream-json', '--resume <random never-seen UUID>', '--allowed-tools read_todos_tool_call'],
|
|
397
|
-
exitCode: run.code, timedOut: run.timedOut, outputTruncated: run.truncated,
|
|
398
|
-
successWithRequestedId, noPriorTurn,
|
|
399
|
-
missingSessionError: /not found|missing|resume|session/i.test(run.stderr),
|
|
400
|
-
outcome: !run.timedOut && !run.truncated && successWithRequestedId && noPriorTurn
|
|
401
|
-
? 'blocked' : run.code !== 0 && !result ? 'pass' : 'inconclusive',
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
function writeStripedPng(path) {
|
|
406
|
-
// A small randomized red/blue control, generated locally and never retained.
|
|
407
|
-
const colors = Math.random() < 0.5
|
|
408
|
-
? [[255, 0, 0], [0, 0, 255]] : [[0, 0, 255], [255, 0, 0]];
|
|
409
|
-
const width = 40;
|
|
410
|
-
const height = 20;
|
|
411
|
-
const raw = Buffer.concat(Array.from({ length: height }, () => Buffer.from([
|
|
412
|
-
0, ...Array.from({ length: width }, (_, x) => colors[x < width / 2 ? 0 : 1]).flat(),
|
|
413
|
-
])));
|
|
414
|
-
const crc = bytes => {
|
|
415
|
-
let value = 0xffffffff;
|
|
416
|
-
for (const byte of bytes) {
|
|
417
|
-
value ^= byte;
|
|
418
|
-
for (let bit = 0; bit < 8; bit++) value = (value >>> 1) ^ (value & 1 ? 0xedb88320 : 0);
|
|
419
|
-
}
|
|
420
|
-
return (value ^ 0xffffffff) >>> 0;
|
|
421
|
-
};
|
|
422
|
-
const chunk = (type, data) => {
|
|
423
|
-
const label = Buffer.from(type);
|
|
424
|
-
const size = Buffer.alloc(4);
|
|
425
|
-
size.writeUInt32BE(data.length);
|
|
426
|
-
const checksum = Buffer.alloc(4);
|
|
427
|
-
checksum.writeUInt32BE(crc(Buffer.concat([label, data])));
|
|
428
|
-
return Buffer.concat([size, label, data, checksum]);
|
|
429
|
-
};
|
|
430
|
-
const header = Buffer.alloc(13);
|
|
431
|
-
header.writeUInt32BE(width, 0);
|
|
432
|
-
header.writeUInt32BE(height, 4);
|
|
433
|
-
header[8] = 8;
|
|
434
|
-
header[9] = 2;
|
|
435
|
-
writeFileSync(path, Buffer.concat([
|
|
436
|
-
Buffer.from('89504e470d0a1a0a', 'hex'), chunk('IHDR', header),
|
|
437
|
-
chunk('IDAT', deflateSync(raw)), chunk('IEND', Buffer.alloc(0)),
|
|
438
|
-
]));
|
|
439
|
-
return colors[0][0] === 255 ? 'RED_BLUE' : 'BLUE_RED';
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
async function fieldsModelChecks() {
|
|
443
|
-
const modelListing = await runAgent(['--list-models'], checkout, 15_000);
|
|
444
|
-
const modelLines = modelListing.stdout.split('\n');
|
|
445
|
-
const advertisedModel = modelListing.code === 0 && modelLines.some(line => line.startsWith(`${values.model} - `));
|
|
446
|
-
const lowEffortModel = values.model.replace(/-medium$/, '-low');
|
|
447
|
-
const lowEffortAdvertised = lowEffortModel !== values.model && modelLines.some(line => line.startsWith(`${lowEffortModel} - `));
|
|
448
|
-
const lowEffort = lowEffortAdvertised ? await runAgent([
|
|
449
|
-
'-p', '--force', '--trust', '--output-format', 'stream-json',
|
|
450
|
-
'--model', lowEffortModel, '--allowed-tools', 'read_todos_tool_call', 'Reply OK.',
|
|
451
|
-
], checkout, 45_000) : undefined;
|
|
452
|
-
const invalid = await runAgent([
|
|
453
|
-
'-p', '--force', '--trust', '--output-format', 'stream-json',
|
|
454
|
-
'--model', 'cez-nonexistent-model-pin', 'Reply OK.',
|
|
455
|
-
], checkout, 15_000);
|
|
456
|
-
const invalidRejectedBeforeInference = invalid.code !== 0
|
|
457
|
-
&& !framesOf(invalid.stdout).some(frame => frame.type === 'assistant' || frame.type === 'result');
|
|
458
|
-
return { advertisedModel, lowEffortAdvertised, lowEffort, invalidRejectedBeforeInference };
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
function effortVariantAdmitted(lowEffort) {
|
|
462
|
-
return lowEffort?.code === 0 && resultOf(framesOf(lowEffort.stdout))?.subtype === 'success';
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
async function fieldsExtraRootTurns() {
|
|
466
|
-
const extraRoot = join(scratch, 'extra-root');
|
|
467
|
-
mkdirSync(extraRoot);
|
|
468
|
-
const canary = randomBytes(12).toString('hex');
|
|
469
|
-
writeFileSync(join(extraRoot, 'root-canary.txt'), canary, { mode: 0o600 });
|
|
470
|
-
const image = join(checkout, 'stripes.png');
|
|
471
|
-
const colorOrder = writeStripedPng(image);
|
|
472
|
-
const args = [
|
|
473
|
-
'-p', '--force', '--trust', '--output-format', 'stream-json',
|
|
474
|
-
'--model', values.model, '--allowed-tools', 'read_tool_call',
|
|
475
|
-
'--add-dir', extraRoot, '--image', image,
|
|
476
|
-
];
|
|
477
|
-
const first = await runAgent([...args,
|
|
478
|
-
`Read ${join(extraRoot, 'root-canary.txt')} with the native Read tool. Then describe the image's colors from left to right as RED_BLUE or BLUE_RED. Reply with the file contents and that code only.`,
|
|
479
|
-
], checkout, 45_000);
|
|
480
|
-
const firstFrames = framesOf(first.stdout);
|
|
481
|
-
const firstId = resultOf(firstFrames)?.session_id;
|
|
482
|
-
const second = firstId ? await runAgent([
|
|
483
|
-
'-p', '--force', '--trust', '--output-format', 'stream-json', '--model', values.model,
|
|
484
|
-
'--resume', firstId, '--allowed-tools', 'read_todos_tool_call',
|
|
485
|
-
'What was the image color-order code from the previous turn? Reply with just that code.',
|
|
486
|
-
], checkout, 45_000) : undefined;
|
|
487
|
-
const secondResult = second ? resultOf(framesOf(second.stdout)) : undefined;
|
|
488
|
-
return { canary, colorOrder, first, firstFrames, firstId, second, secondResult };
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
function fieldsReadOf(firstFrames) {
|
|
492
|
-
const rootRead = firstFrames.some(frame => frame.type === 'tool_call' && frame.tool_call?.readToolCall);
|
|
493
|
-
const readCall = firstFrames.find(frame => frame.type === 'tool_call' && frame.subtype === 'completed'
|
|
494
|
-
&& frame.tool_call?.readToolCall)?.tool_call.readToolCall;
|
|
495
|
-
const text = String(resultOf(firstFrames)?.result ?? '');
|
|
496
|
-
return { rootRead, readCall, text };
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
function readCallKeys(readCall) {
|
|
500
|
-
return {
|
|
501
|
-
readArgKeys: readCall?.args && typeof readCall.args === 'object' ? Object.keys(readCall.args).sort() : [],
|
|
502
|
-
readResultKeys: readCall?.result && typeof readCall.result === 'object' ? Object.keys(readCall.result).sort() : [],
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
function fieldsFreshVerified(invalidRejectedBeforeInference, first, rootRead, text, canary, colorOrder) {
|
|
507
|
-
return invalidRejectedBeforeInference && first.code === 0 && rootRead
|
|
508
|
-
&& text.includes(canary) && text.includes(colorOrder);
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
function fieldsResumedVerified(firstId, second, secondResult, colorOrder) {
|
|
512
|
-
return second?.code === 0 && secondResult?.session_id === firstId
|
|
513
|
-
&& String(secondResult?.result ?? '').trim() === colorOrder;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
function fieldsOutcome(checks, first, second, rootRead, text, canary, colorOrder, firstId, secondResult) {
|
|
517
|
-
return checks.advertisedModel && checks.lowEffortAdvertised && effortVariantAdmitted(checks.lowEffort)
|
|
518
|
-
&& fieldsFreshVerified(checks.invalidRejectedBeforeInference, first, rootRead, text, canary, colorOrder)
|
|
519
|
-
&& fieldsResumedVerified(firstId, second, secondResult, colorOrder) ? 'pass' : 'blocked';
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
async function probeFields(version) {
|
|
523
|
-
const checks = await fieldsModelChecks();
|
|
524
|
-
const turns = await fieldsExtraRootTurns();
|
|
525
|
-
const { rootRead, readCall, text } = fieldsReadOf(turns.firstFrames);
|
|
526
|
-
return {
|
|
527
|
-
schema: 1, case: 'fields', cliVersion: version, model: values.model,
|
|
528
|
-
invocation: ['-p', '--force', '--trust', '--output-format stream-json', '--model <advertised ID>', '--allowed-tools read_tool_call', '--add-dir <disposable root>', '--image <disposable PNG>', '--resume <exact native ID>'],
|
|
529
|
-
advertisedModel: checks.advertisedModel, invalidRejectedBeforeInference: checks.invalidRejectedBeforeInference,
|
|
530
|
-
advertisedEffortVariant: checks.lowEffortAdvertised,
|
|
531
|
-
advertisedEffortVariantAdmitted: effortVariantAdmitted(checks.lowEffort),
|
|
532
|
-
extraRootToolRead: rootRead, extraRootCanarySeen: text.includes(turns.canary),
|
|
533
|
-
...readCallKeys(readCall),
|
|
534
|
-
imageOrderSeen: text.includes(turns.colorOrder),
|
|
535
|
-
sameNativeSession: Boolean(turns.firstId && turns.secondResult?.session_id === turns.firstId),
|
|
536
|
-
currentInstructionFollowedOnResume: String(turns.secondResult?.result ?? '').trim() === turns.colorOrder,
|
|
537
|
-
freshExitCode: turns.first.code, resumedExitCode: turns.second?.code ?? null,
|
|
538
|
-
timedOut: turns.first.timedOut || Boolean(turns.second?.timedOut),
|
|
539
|
-
outputTruncated: turns.first.truncated || Boolean(turns.second?.truncated),
|
|
540
|
-
outcome: fieldsOutcome(checks, turns.first, turns.second, rootRead, text, turns.canary, turns.colorOrder, turns.firstId, turns.secondResult),
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
async function probeErrors(version) {
|
|
545
|
-
const invalidKey = `cez-invalid-${randomBytes(16).toString('hex')}`;
|
|
546
|
-
const auth = await runAgent([
|
|
547
|
-
'-p', '--force', '--trust', '--output-format', 'stream-json',
|
|
548
|
-
'--model', values.model, '--allowed-tools', 'read_todos_tool_call', 'Reply OK.',
|
|
549
|
-
], checkout, 20_000, { ...process.env, CURSOR_API_KEY: invalidKey });
|
|
550
|
-
const authFrames = framesOf(auth.stdout);
|
|
551
|
-
const authFailedWithoutSuccess = auth.code !== 0
|
|
552
|
-
&& !authFrames.some(frame => frame.type === 'result' && frame.subtype === 'success');
|
|
553
|
-
const timeout = await runAgent([
|
|
554
|
-
'-p', '--force', '--trust', '--output-format', 'stream-json',
|
|
555
|
-
'--model', values.model, '--allowed-tools', 'read_todos_tool_call', 'Reply OK.',
|
|
556
|
-
], checkout, 10);
|
|
557
|
-
return {
|
|
558
|
-
schema: 1, case: 'errors', cliVersion: version, model: values.model,
|
|
559
|
-
invocation: ['-p', '--force', '--trust', '--output-format stream-json', '--allowed-tools read_todos_tool_call', 'invalid synthetic CURSOR_API_KEY in process env', '10 ms timeout in disposable worktree'],
|
|
560
|
-
invalidKeyNotEchoed: !auth.stdout.includes(invalidKey) && !auth.stderr.includes(invalidKey),
|
|
561
|
-
invalidKeyRejected: authFailedWithoutSuccess,
|
|
562
|
-
noFallbackToLoggedInAccount: authFailedWithoutSuccess,
|
|
563
|
-
authProcessGroupGone: auth.processGroupGone,
|
|
564
|
-
timeoutTriggered: timeout.timedOut,
|
|
565
|
-
timeoutProcessGroupGone: timeout.processGroupGone,
|
|
566
|
-
outcome: authFailedWithoutSuccess && !auth.stdout.includes(invalidKey)
|
|
567
|
-
&& !auth.stderr.includes(invalidKey) && auth.processGroupGone
|
|
568
|
-
&& timeout.timedOut && timeout.processGroupGone ? 'pass' : 'blocked',
|
|
569
|
-
};
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
function writeLifecyclePlugin(pluginDir) {
|
|
573
|
-
const manifestDir = join(pluginDir, '.cursor-plugin');
|
|
574
|
-
const hooksDir = join(pluginDir, 'hooks');
|
|
575
|
-
const skillDir = join(pluginDir, 'skills', 'print-qualification');
|
|
576
|
-
mkdirSync(manifestDir, { recursive: true });
|
|
577
|
-
mkdirSync(hooksDir);
|
|
578
|
-
mkdirSync(skillDir, { recursive: true });
|
|
579
|
-
const heading = `# Print qualification ${randomBytes(6).toString('hex')}`;
|
|
580
|
-
const hookPhrase = randomBytes(12).toString('hex');
|
|
581
|
-
writeFileSync(join(skillDir, 'SKILL.md'), `${heading}\nA local test skill.\n`);
|
|
582
|
-
writeFileSync(join(manifestDir, 'plugin.json'), JSON.stringify({
|
|
583
|
-
name: 'cez-print-qualification', version: '0.0.1',
|
|
584
|
-
description: 'Disposable local plugin for fork 590 qualification',
|
|
585
|
-
skills: './skills/', hooks: './hooks/hooks.json',
|
|
586
|
-
}));
|
|
587
|
-
const hookOutput = join(hooksDir, 'started');
|
|
588
|
-
writeFileSync(join(hooksDir, 'start.mjs'), `import { appendFileSync } from 'node:fs';\nappendFileSync(${JSON.stringify(hookOutput)}, '1\\n');\nprocess.stdout.write(JSON.stringify({ additional_context: ${JSON.stringify(`Remember this hook phrase for later: ${hookPhrase}`)} }));\n`);
|
|
589
|
-
writeFileSync(join(hooksDir, 'hooks.json'), JSON.stringify({
|
|
590
|
-
version: 1, hooks: { sessionStart: [{ command: `node ${join(hooksDir, 'start.mjs')}` }] },
|
|
591
|
-
}));
|
|
592
|
-
return { heading, hookPhrase, hookOutput };
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
function lifecycleHookCount(hookOutput) {
|
|
596
|
-
return existsSync(hookOutput) ? readFileSync(hookOutput, 'utf8').split('\n').filter(Boolean).length : 0;
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
function lifecycleReadOf(frames, isTargetRead) {
|
|
600
|
-
return frames.some(frame => frame.type === 'tool_call'
|
|
601
|
-
&& frame.tool_call?.readToolCall && isTargetRead(JSON.stringify(frame.tool_call.readToolCall)));
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
function lifecycleResultIncludes(frames, needle) {
|
|
605
|
-
return String(resultOf(frames)?.result ?? '').includes(needle);
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
function lifecycleRunsVerified(catalogRun, first, second, absent) {
|
|
609
|
-
return catalogRun.code === 1 && first.code === 0 && second?.code === 0 && absent.code === 0;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
function lifecycleOutcome(runsVerified, evidence) {
|
|
613
|
-
return runsVerified && evidence.localSkillRead && evidence.localHeadingSeen
|
|
614
|
-
&& evidence.marketplaceSkillRead && evidence.firstIdEqualsSecondId && evidence.freshHookRan
|
|
615
|
-
&& evidence.hookContextRecalledOnResume && !evidence.absentLocalRead
|
|
616
|
-
&& evidence.absentModelReportedMissing ? 'pass' : 'blocked';
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
async function probePluginLifecycle(version) {
|
|
620
|
-
const { catalogRun, names, safeAllowedTools } = await discoverSafeAllowedTools();
|
|
621
|
-
const pluginDir = join(checkout, 'cez-print-qualification-plugin');
|
|
622
|
-
const { heading, hookPhrase, hookOutput } = writeLifecyclePlugin(pluginDir);
|
|
623
|
-
const base = ['-p', '--force', '--trust', '--output-format', 'stream-json',
|
|
624
|
-
'--model', values.model, '--allowed-tools', safeAllowedTools.join(',')];
|
|
625
|
-
const first = await runAgent([...base, '--plugin-dir', pluginDir,
|
|
626
|
-
'Use your loaded print-qualification skill. Read its SKILL.md with the native Read tool and report the first heading exactly.',
|
|
627
|
-
], checkout, 45_000);
|
|
628
|
-
const firstFrames = framesOf(first.stdout);
|
|
629
|
-
const firstId = resultOf(firstFrames)?.session_id;
|
|
630
|
-
const firstHookCount = lifecycleHookCount(hookOutput);
|
|
631
|
-
const localSkillRead = lifecycleReadOf(firstFrames, text => text.includes('print-qualification/SKILL.md'));
|
|
632
|
-
const second = firstId ? await runAgent([...base, '--resume', firstId, '--plugin-dir', pluginDir,
|
|
633
|
-
'From your enabled marketplace plugins, read the Superpowers brainstorming SKILL.md with the native Read tool. Then report its first heading and the hook phrase injected at the start of this session.',
|
|
634
|
-
], checkout, 45_000) : undefined;
|
|
635
|
-
const secondFrames = second ? framesOf(second.stdout) : [];
|
|
636
|
-
const secondId = resultOf(secondFrames)?.session_id;
|
|
637
|
-
const secondHookCount = lifecycleHookCount(hookOutput);
|
|
638
|
-
const marketplaceSkillRead = lifecycleReadOf(secondFrames,
|
|
639
|
-
text => /\.cursor\/plugins\/cache\/.*superpowers.*SKILL\.md/i.test(text));
|
|
640
|
-
rmSync(pluginDir, { recursive: true, force: true });
|
|
641
|
-
const absent = await runAgent([...base,
|
|
642
|
-
'If a loaded skill named print-qualification is available, read its SKILL.md. Otherwise reply ABSENT. Do not search the filesystem.',
|
|
643
|
-
], checkout, 45_000);
|
|
644
|
-
const absentFrames = framesOf(absent.stdout);
|
|
645
|
-
const absentLocalRead = lifecycleReadOf(absentFrames, text => text.includes('print-qualification/SKILL.md'));
|
|
646
|
-
const evidence = {
|
|
647
|
-
localSkillRead,
|
|
648
|
-
localHeadingSeen: lifecycleResultIncludes(firstFrames, heading),
|
|
649
|
-
marketplaceSkillRead,
|
|
650
|
-
firstIdEqualsSecondId: firstId === secondId,
|
|
651
|
-
freshHookRan: firstHookCount > 0,
|
|
652
|
-
hookContextRecalledOnResume: lifecycleResultIncludes(secondFrames, hookPhrase),
|
|
653
|
-
absentLocalRead,
|
|
654
|
-
absentModelReportedMissing: lifecycleResultIncludes(absentFrames, 'ABSENT'),
|
|
655
|
-
};
|
|
656
|
-
return {
|
|
657
|
-
schema: 1, case: 'plugin-lifecycle', cliVersion: version, model: values.model,
|
|
658
|
-
invocation: ['-p', '--force', '--trust', '--output-format stream-json', '--allowed-tools <non-agent catalog>', '--plugin-dir <disposable local plugin>', '--resume <exact native ID>'],
|
|
659
|
-
catalogValidatedBeforeInference: catalogRun.code === 1 && names.includes('read_tool_call'),
|
|
660
|
-
localSkillRead, localHeadingSeen: evidence.localHeadingSeen,
|
|
661
|
-
marketplaceSkillRead, sameNativeSession: Boolean(firstId && secondId === firstId),
|
|
662
|
-
freshHookRan: evidence.freshHookRan, resumedHookRan: secondHookCount > firstHookCount,
|
|
663
|
-
hookContextRecalledOnResume: evidence.hookContextRecalledOnResume,
|
|
664
|
-
absentLocalSkillRead: absentLocalRead,
|
|
665
|
-
absentModelReportedMissing: evidence.absentModelReportedMissing,
|
|
666
|
-
globalConfigurationWritten: false,
|
|
667
|
-
outcome: lifecycleOutcome(lifecycleRunsVerified(catalogRun, first, second, absent), evidence),
|
|
668
|
-
};
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
let added = false;
|
|
672
|
-
let cleaned = true;
|
|
673
|
-
try {
|
|
674
|
-
const version = await runAgent(['--version'], process.cwd(), 10_000);
|
|
675
|
-
if (version.code !== 0 || version.timedOut) throw new Error('Cursor version check failed');
|
|
676
|
-
git(['worktree', 'add', '--quiet', '--detach', checkout, 'HEAD']);
|
|
677
|
-
added = true;
|
|
678
|
-
|
|
679
|
-
const probes = { 'native-question': probeNativeQuestion, delegation: probeDelegation, mcp: probeMcp, plugins: probePlugins, 'resume-missing': probeResumeMissing, fields: probeFields, 'plugin-lifecycle': probePluginLifecycle, errors: probeErrors };
|
|
680
|
-
const summary = await probes[values.case](version.stdout.trim());
|
|
681
|
-
mkdirSync(outputDir, { recursive: true });
|
|
682
|
-
const output = join(outputDir, `print-${values.case}.json`);
|
|
683
|
-
writeFileSync(output, `${JSON.stringify(summary, null, 2)}\n`, { mode: 0o600 });
|
|
684
|
-
process.stdout.write(`${output}\n`);
|
|
685
|
-
process.exitCode = summary.outcome === 'pass' ? 0 : summary.outcome === 'blocked' ? 2 : 1;
|
|
686
|
-
} catch (error) {
|
|
687
|
-
process.stderr.write(`Probe failed: ${error instanceof Error ? error.message : 'unknown error'}\n`);
|
|
688
|
-
process.exitCode = 1;
|
|
689
|
-
} finally {
|
|
690
|
-
if (added) {
|
|
691
|
-
const removed = spawnSync('git', ['worktree', 'remove', '--force', checkout], { encoding: 'utf8', timeout: 15_000 });
|
|
692
|
-
if (removed.status !== 0) {
|
|
693
|
-
process.stderr.write(`Probe cleanup failed; inspect ${checkout}\n`);
|
|
694
|
-
process.exitCode = 1;
|
|
695
|
-
cleaned = false;
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
if (cleaned) rmSync(scratch, { recursive: true, force: true });
|
|
699
|
-
}
|