@aiwg/cli 2026.11.6 → 2026.11.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agentic/code/addons/aiwg-hooks/hooks/aiwg-prompt-discovery.cjs +3 -2
- package/agentic/code/providers/model-capabilities.v1.json +22 -21
- package/agentic/code/providers/model-catalog.v1.json +11 -10
- package/dist/src/artifacts/browser-export.js +1 -0
- package/dist/src/artifacts/fortemi-core-query-adapter.js +2 -0
- package/dist/src/artifacts/index-builder.js +1 -0
- package/dist/src/artifacts/query-engine-discover-output.js +1 -0
- package/dist/src/artifacts/query-engine-discover.js +2 -2
- package/dist/src/artifacts/query-engine-scoring.js +7 -0
- package/dist/src/artifacts/template-output-kind.js +10 -0
- package/dist/src/artifacts/types.js +1 -1
- package/dist/src/cli/handlers/dataset.js +11 -2
- package/dist/src/cli/handlers/refresh-managed-deployment.js +13 -3
- package/dist/src/cli/handlers/refresh-user-hooks.js +102 -0
- package/dist/src/cli/handlers/refresh.js +2 -0
- package/dist/src/cli/handlers/update.js +26 -12
- package/dist/src/cli/handlers/use.js +4 -3
- package/dist/src/cli/handlers/writing.js +7 -1
- package/dist/src/config/worker-guidance-warning.js +8 -0
- package/dist/src/dataset/backend-selection.d.ts +3 -0
- package/dist/src/dataset/backend-selection.js +11 -0
- package/dist/src/dataset/contract-range.d.ts +7 -0
- package/dist/src/dataset/contract-range.js +55 -0
- package/dist/src/dataset/fortemi-execution-bridge.d.ts +2 -0
- package/dist/src/dataset/fortemi-execution-bridge.js +12 -1
- package/dist/src/dataset/index.d.ts +2 -0
- package/dist/src/dataset/index.js +2 -0
- package/dist/src/dataset/orchestration-service.d.ts +1 -1
- package/dist/src/dataset/orchestration-service.js +7 -8
- package/dist/src/dataset/orchestration-types.d.ts +2 -0
- package/dist/src/dataset/service-binding-checkpoints.d.ts +10 -0
- package/dist/src/dataset/service-binding-checkpoints.js +26 -0
- package/dist/src/dataset/service-binding-contract.d.ts +46 -0
- package/dist/src/dataset/service-binding-contract.js +25 -0
- package/dist/src/dataset/service-binding-registry.d.ts +12 -0
- package/dist/src/dataset/service-binding-registry.js +118 -0
- package/dist/src/extensions/manifest.js +23 -7
- package/dist/src/extensions/project-local-doctor.js +2 -1
- package/dist/src/extensions/project-quickref-discovery.js +11 -0
- package/dist/src/extensions/project-quickref.js +4 -7
- package/dist/src/extensions/user-hook-diagnostics.js +16 -1
- package/dist/src/extensions/verified-hook-command.js +7 -0
- package/dist/src/mcp/tools/worker-invoke.mjs +6 -4
- package/dist/src/mcp/tools/worker-launch-ledger.mjs +33 -0
- package/dist/src/mcp/tools/worker-verify-deliver-schema.mjs +22 -6
- package/dist/src/mcp/tools/worker-verify-deliver.mjs +4 -6
- package/dist/src/models/cursor-models.js +92 -0
- package/dist/src/models/model-capabilities.v1.json +22 -21
- package/dist/src/models/model-catalog.v1.json +11 -10
- package/dist/src/models/model-discovery.js +4 -3
- package/dist/src/models/provider-policy.js +1 -1
- package/dist/src/models/worker-health-readiness.js +4 -0
- package/dist/src/models/worker-installation.d.mts +2 -0
- package/dist/src/models/worker-installation.mjs +8 -2
- package/dist/src/models/worker-invocation-policy.js +21 -1
- package/dist/src/models/worker-plan.js +3 -1
- package/dist/src/models/worker-wiring-diagnostics.js +25 -0
- package/dist/src/providers/deployment-input-session.d.mts +2 -0
- package/dist/src/providers/deployment-input-session.mjs +38 -0
- package/dist/src/providers/provider-context-contracts.js +3 -0
- package/dist/src/providers/provider-seeds-1.js +1 -1
- package/dist/src/serve/worker-invocation-preparation.js +52 -33
- package/dist/src/serve/worker-invocation.js +4 -2
- package/dist/src/serve/worker-shell-prompt.d.mts +6 -0
- package/dist/src/serve/worker-shell-prompt.mjs +78 -0
- package/dist/src/smiths/context-pipeline/muse-bridge.js +7 -4
- package/dist/src/smiths/context-pipeline/workspace-audit.js +37 -6
- package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +3 -1
- package/dist/src/smiths/context-pipeline/workspace-doctor.js +16 -4
- package/dist/src/smiths/context-pipeline/workspace-document.js +4 -2
- package/dist/src/smiths/hook-bridge/codex-trust.js +56 -7
- package/dist/src/smiths/hook-bridge/cursor-translator.js +89 -0
- package/dist/src/smiths/hook-bridge/index.js +4 -1
- package/dist/src/writing/campaign-patterns.js +96 -0
- package/dist/src/writing/campaign-report.js +41 -0
- package/dist/src/writing/contextual-diagnostics.js +30 -5
- package/dist/src/writing/current-patterns.catalogue.json +87 -0
- package/dist/src/writing/current-patterns.js +99 -0
- package/dist/src/writing/prose-mask.js +80 -0
- package/dist/src/writing/structural-patterns.js +126 -0
- package/dist/src/writing/validation-campaign.js +19 -0
- package/dist/src/writing/validation-engine.js +17 -10
- package/dist/src/writing/validation-rules.js +4 -3
- package/package.json +1 -1
- package/schemas/dataset/service-binding.v1.schema.json +70 -0
- package/tools/agents/providers/base-models-platforms.mjs +87 -48
- package/tools/agents/providers/cursor-prompt-discovery.mjs +13 -0
- package/tools/agents/providers/cursor.mjs +2 -0
- package/tools/agents/providers/openclaw-context.mjs +6 -0
- package/tools/agents/providers/openclaw.mjs +14 -12
- package/tools/agents/providers/rule-delivery-surface.mjs +1 -1
- package/tools/agents/providers/rule-deployment-corpus-inputs.mjs +19 -0
- package/tools/agents/providers/rule-deployment-input-session.mjs +40 -0
- package/tools/agents/providers/rule-deployment-prepare.mjs +16 -6
- package/tools/agents/providers/rule-presentation.mjs +1 -1
- package/tools/agents/providers/rule-startup.mjs +3 -1
- package/tools/plugin/package-plugins.mjs +2 -0
- package/tools/ralph-external/lib/typed-stop-delivery.mjs +10 -1
- package/tools/ralph-external/lib/worker-delivery-guards.mjs +47 -1
- package/tools/ralph-external/lib/worker-run-directory-refusal.mjs +2 -1
- package/tools/ralph-external/lib/worker-verification-cli.mjs +1 -1
- package/vscode-extension/schemas/aiwg.config.v1.json +13 -0
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import os from 'node:os';
|
|
5
|
-
|
|
5
|
+
function hasPromptHook(doc) {
|
|
6
|
+
const groups = doc?.hooks?.UserPromptSubmit;
|
|
7
|
+
return Array.isArray(groups) && groups.some(group => Array.isArray(group?.hooks) && group.hooks.some((hook) => hook?.type === 'command' && hook._aiwg_managed === true && hook._aiwg_id === 'aiwg-prompt-discovery'
|
|
8
|
+
&& typeof hook.command === 'string' && hook.command.trim()));
|
|
9
|
+
}
|
|
10
|
+
export async function diagnoseUserHookCommands(projectRoot) {
|
|
6
11
|
const diagnostics = [];
|
|
7
12
|
for (const provider of ['claude', 'muse']) {
|
|
8
13
|
const file = path.join(os.homedir(), `.${provider}`, provider === 'claude' ? 'settings.json' : 'hooks.json');
|
|
@@ -13,6 +18,16 @@ export async function diagnoseUserHookCommands() {
|
|
|
13
18
|
catch {
|
|
14
19
|
continue;
|
|
15
20
|
} // Existing config diagnostics own unreadable documents.
|
|
21
|
+
if (provider === 'claude' && projectRoot && path.resolve(projectRoot) !== path.resolve(os.homedir()) && hasPromptHook(doc)) {
|
|
22
|
+
try {
|
|
23
|
+
const projectFile = path.join(projectRoot, '.claude/settings.json');
|
|
24
|
+
if (hasPromptHook(JSON.parse(await fs.readFile(projectFile, 'utf8')))) {
|
|
25
|
+
diagnostics.push({ severity: 'warning', code: 'duplicate-prompt-hook', path: projectFile,
|
|
26
|
+
message: 'Claude user and project settings both register AIWG prompt discovery. The current user loader defers to the project hook; refresh older global hooks with aiwg use all --global --providers claude.' });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch { /* Existing config diagnostics own unreadable project settings. */ }
|
|
30
|
+
}
|
|
16
31
|
for (const [event, groups] of Object.entries(doc.hooks || {})) {
|
|
17
32
|
if (!Array.isArray(groups))
|
|
18
33
|
continue;
|
|
@@ -18,6 +18,13 @@ export function verifiedHookCommand(root, relative, bytes, args = [], scope) {
|
|
|
18
18
|
const loader = [
|
|
19
19
|
"const fs=require('node:fs'),p=require('node:path'),M=require('node:module');",
|
|
20
20
|
`const c=JSON.parse(Buffer.from('${data}','base64').toString());`,
|
|
21
|
+
// Claude merges project and user hooks. The project registration wins;
|
|
22
|
+
// keep the global fallback active when this is the home settings itself.
|
|
23
|
+
...(user && relative === '.claude/hooks/aiwg-prompt-discovery.cjs' ? [
|
|
24
|
+
"try{const project=p.resolve(process.env.CLAUDE_PROJECT_DIR||process.cwd());",
|
|
25
|
+
"if(project!==c.anchor){const groups=JSON.parse(fs.readFileSync(p.join(project,'.claude/settings.json'),'utf8')).hooks?.UserPromptSubmit;",
|
|
26
|
+
"if(Array.isArray(groups)&&groups.some(g=>Array.isArray(g?.hooks)&&g.hooks.some(h=>h?.type==='command'&&h._aiwg_managed===true&&h._aiwg_id==='aiwg-prompt-discovery'&&typeof h.command==='string'&&h.command.trim())))process.exit(0);}}catch{}",
|
|
27
|
+
] : []),
|
|
21
28
|
'const root=c.projectEnv?process.env[c.projectEnv]||c.anchor:c.anchor;',
|
|
22
29
|
`const script=p.resolve(root,'${relative}');`,
|
|
23
30
|
"if(p.relative(fs.realpathSync(script),script)!==''||!fs.lstatSync(script).isFile())throw Error('Unsafe AIWG hook path');",
|
|
@@ -157,6 +157,7 @@
|
|
|
157
157
|
*/
|
|
158
158
|
|
|
159
159
|
import { registerWorkerVerifyDeliverTool } from './worker-verify-deliver.mjs';
|
|
160
|
+
import { createWorkerLaunchLedger } from './worker-launch-ledger.mjs';
|
|
160
161
|
import { workerFailureDiagnostics } from './worker-failure-diagnostics.mjs';
|
|
161
162
|
import { workerLocalOnlyPreflight } from './worker-local-only-preflight.mjs';
|
|
162
163
|
import { signalChild } from '../../process/signal-child.mjs';
|
|
@@ -1692,9 +1693,10 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
|
|
|
1692
1693
|
return;
|
|
1693
1694
|
}
|
|
1694
1695
|
const servedRootReal = await resolveServedProjectRoot(options.projectRoot);
|
|
1696
|
+
const launches = createWorkerLaunchLedger();
|
|
1695
1697
|
registerWorkerVerifyDeliverTool(server, { projectRoot: servedRootReal,
|
|
1696
1698
|
assertPath: candidate => assertServedPath(servedRootReal, candidate),
|
|
1697
|
-
verify: async input => (await loadRalphExternal('lib/worker-verification-cli.mjs')).verifyWorkerRun(input),
|
|
1699
|
+
verify: async input => (await loadRalphExternal('lib/worker-verification-cli.mjs')).verifyWorkerRun(input, { recordedLaunches: launches.count }),
|
|
1698
1700
|
});
|
|
1699
1701
|
await sweepWorkerStdin(options.stdinRuntimeRoot);
|
|
1700
1702
|
// Pinned once, here, at registration — never re-resolved per request, and
|
|
@@ -1710,9 +1712,9 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
|
|
|
1710
1712
|
const loadWorkerInputsImpl = options.loadWorkerInputs ?? defaultLoadWorkerInputs;
|
|
1711
1713
|
const recordedShell = recordedShellLauncher({ loadRalphExternal, loadInputs: () => loadWorkerInputsImpl(servedRootReal),
|
|
1712
1714
|
assertPath: candidate => assertServedPath(servedRootReal, candidate), registry, now: options.now ?? (() => new Date()) });
|
|
1713
|
-
const launchShellWorkerImpl = options.launchShellWorker ?? ((invocation, context) => recordedShell.requested(invocation)
|
|
1714
|
-
? recordedShell.launch(invocation, context) : defaultLaunchShellWorker(invocation, context));
|
|
1715
|
-
const callMcpWorkerImpl = options.callMcpWorker ?? defaultCallMcpWorker;
|
|
1715
|
+
const launchShellWorkerImpl = launches.track(options.launchShellWorker ?? ((invocation, context) => recordedShell.requested(invocation)
|
|
1716
|
+
? recordedShell.launch(invocation, context) : defaultLaunchShellWorker(invocation, context)), 'shell');
|
|
1717
|
+
const callMcpWorkerImpl = launches.track(options.callMcpWorker ?? defaultCallMcpWorker, 'mcp');
|
|
1716
1718
|
// Both continuations use the audited observer and hardened stop controls.
|
|
1717
1719
|
const waitForUnitTerminationOverride = options.waitForUnitTermination;
|
|
1718
1720
|
// #2915 review 5 ("a second worker over unresolved execution"): the
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Retain cumulative server-session launch counts independently of registry pruning.
|
|
2
|
+
export function createWorkerLaunchLedger() {
|
|
3
|
+
let count = 0;
|
|
4
|
+
return {
|
|
5
|
+
count: () => count,
|
|
6
|
+
track(launch, transport) {
|
|
7
|
+
return async (...args) => {
|
|
8
|
+
let recorded = false;
|
|
9
|
+
const record = () => { if (!recorded) { recorded = true; count++; } };
|
|
10
|
+
// MCP calls can remain pending long after their process starts.
|
|
11
|
+
// A registered non-null stop control is already launch evidence.
|
|
12
|
+
const context = args[2];
|
|
13
|
+
if (transport === 'mcp' && typeof context?.registerControl === 'function') {
|
|
14
|
+
args[2] = { ...context, registerControl(control) {
|
|
15
|
+
if (control) record();
|
|
16
|
+
return context.registerControl(control);
|
|
17
|
+
} };
|
|
18
|
+
}
|
|
19
|
+
let result;
|
|
20
|
+
try { result = await launch(...args); }
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (error.launchAttempted) record();
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
const launched = transport === 'shell'
|
|
26
|
+
? result.launched || result.launchAttempted || result.dispatchState === 'submission-uncertain'
|
|
27
|
+
: result.dispatchState ? result.dispatchState !== 'never-began' : result.outcome !== 'blocked';
|
|
28
|
+
if (launched) record();
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -18,16 +18,32 @@ export const typedStopSchema = z.strictObject({
|
|
|
18
18
|
reason: z.string().max(4000).optional(),
|
|
19
19
|
});
|
|
20
20
|
export const typedStopDeliverySchema = z.strictObject({ deliverablePath: absolute, typedStop: typedStopSchema });
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const workerPublication = z.strictObject({ run_dir: absolute, artifact_path: absolute.optional(), deliverable_path: absolute, checks: z.array(check).min(1).max(32) });
|
|
22
|
+
const stopPublication = z.strictObject({ deliverable_path: absolute, typed_stop: typedStopSchema });
|
|
23
|
+
export const publicationSchema = z.union([workerPublication, stopPublication]);
|
|
24
|
+
|
|
25
|
+
// Select by presence, including null/undefined stops, so malformed requests
|
|
26
|
+
// receive only the relevant branch's remedies rather than a union dump.
|
|
27
|
+
export function parsePublication(input) {
|
|
28
|
+
const isStop = input !== null && typeof input === 'object' && Object.hasOwn(input, 'typed_stop');
|
|
29
|
+
const parsed = (isStop ? stopPublication : workerPublication).safeParse(input);
|
|
30
|
+
if (parsed.success) return parsed.data;
|
|
31
|
+
const code = isStop ? 'TYPED_STOP_INVALID' : 'PUBLICATION_INVALID';
|
|
32
|
+
const shape = isStop ? 'a typed stop' : 'a worker publication';
|
|
33
|
+
const findings = parsed.error.issues.flatMap(issue => {
|
|
34
|
+
const key = issue.path.join('.');
|
|
35
|
+
if (issue.code === 'unrecognized_keys') return issue.keys.map(unknown => `${code}: ${[...issue.path, unknown].join('.')} is unknown for ${shape}`);
|
|
36
|
+
const missing = issue.path.length && issue.path.reduce((value, part) => value?.[part], input) === undefined;
|
|
37
|
+
return [`${code}: ${key || 'request'} ${missing ? `is required for ${shape}` : issue.message}`];
|
|
38
|
+
});
|
|
39
|
+
throw Object.assign(new Error(findings.join('\n')), { code, findings });
|
|
40
|
+
}
|
|
25
41
|
|
|
26
42
|
// The SDK advertises only object schemas. Preserve the strict union in both
|
|
27
43
|
// its advertised JSON Schema and validation, with a stable refusal code.
|
|
28
44
|
export const publicationInputSchema = z.looseObject({}).superRefine((input, context) => {
|
|
29
|
-
|
|
30
|
-
|
|
45
|
+
try { parsePublication(input); }
|
|
46
|
+
catch (error) { for (const message of error.findings) context.addIssue({ code: 'custom', message }); }
|
|
31
47
|
}).meta({ anyOf: z.toJSONSchema(publicationSchema).anyOf });
|
|
32
48
|
|
|
33
49
|
export const invalidTypedStop = message => Object.assign(new Error(`TYPED_STOP_INVALID: ${message}`), { code: 'TYPED_STOP_INVALID' });
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
// Narrow workers-toolset adapter: protected checks and publication share one verifier call.
|
|
2
2
|
import { mcpError, mcpJson } from '../helpers.mjs';
|
|
3
|
-
import { publicationInputSchema,
|
|
3
|
+
import { publicationInputSchema, parsePublication } from './worker-verify-deliver-schema.mjs';
|
|
4
4
|
|
|
5
5
|
export function registerWorkerVerifyDeliverTool(server, { projectRoot, assertPath, verify }) {
|
|
6
6
|
server.registerTool('worker-verify-deliver', {
|
|
7
7
|
title: 'Verify and Deliver a Worker Artifact or Typed Stop',
|
|
8
|
-
description: 'Publish a checked stopped-worker artifact, or a typed denied/blocked stop with launch_count 0 and no run_dir/artifact_path/checks. Both produce signed delivery records. The server must run outside conductor confinement.',
|
|
8
|
+
description: 'Publish a checked stopped-worker artifact, or a typed denied/blocked stop with launch_count 0 and no run_dir/artifact_path/checks. Malformed publications return PUBLICATION_INVALID; malformed typed stops return TYPED_STOP_INVALID. launch_count is checked against this MCP server session\'s recorded worker-invoke launches; undercounts return TYPED_STOP_LAUNCH_MISMATCH. A typed stop can only be published before any worker launch in this session; after a launch, the conductor must retry the worker or publish a verified worker artifact. Both produce signed delivery records. The server must run outside conductor confinement.',
|
|
9
9
|
inputSchema: publicationInputSchema,
|
|
10
10
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
|
|
11
11
|
}, async input => {
|
|
12
12
|
try {
|
|
13
|
-
const
|
|
14
|
-
if (!parsed.success) throw invalidTypedStop(parsed.error.message);
|
|
15
|
-
const request = parsed.data;
|
|
13
|
+
const request = parsePublication(input);
|
|
16
14
|
const deliverablePath = await assertPath(request.deliverable_path);
|
|
17
15
|
if ('typed_stop' in request) return mcpJson(await verify({ projectDir: projectRoot, deliverablePath, typedStop: request.typed_stop }));
|
|
18
16
|
if (new Set(request.checks.map(entry => entry.id)).size !== request.checks.length) throw new Error('Protected check IDs must be unique');
|
|
@@ -20,7 +18,7 @@ export function registerWorkerVerifyDeliverTool(server, { projectRoot, assertPat
|
|
|
20
18
|
const artifactPath = request.artifact_path && await assertPath(request.artifact_path);
|
|
21
19
|
return mcpJson(await verify({ projectDir: projectRoot, runDir, artifactPath, deliverablePath, checks: request.checks }));
|
|
22
20
|
} catch (error) {
|
|
23
|
-
if (
|
|
21
|
+
if (['PUBLICATION_INVALID', 'TYPED_STOP_INVALID', 'TYPED_STOP_LAUNCH_MISMATCH'].includes(error.code)) return { ...mcpJson({ status: 'rejected', errorCode: error.code, code: error.code, findings: error.findings ?? [error.message] }), isError: true };
|
|
24
22
|
return mcpError(`worker-verify-deliver: ${error.message}`);
|
|
25
23
|
}
|
|
26
24
|
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { tmpdir } from 'node:os';
|
|
2
|
+
import { stripVTControlCharacters } from 'node:util';
|
|
3
|
+
import { buildWorkerObservation, classifyDiscoveryError, discoveryDigest, redactModelDiscoveryText, runModelDiscoveryCommand } from './model-discovery.js';
|
|
4
|
+
function diagnostic(value) {
|
|
5
|
+
// Redact bearer values before assignment redaction consumes the scheme.
|
|
6
|
+
return redactModelDiscoveryText(value.replace(/\bbearer\s+[A-Za-z0-9._~+/=-]+/gi, 'Bearer [REDACTED]'));
|
|
7
|
+
}
|
|
8
|
+
export async function discoverCursorListModels(command = 'cursor-agent', runner = runModelDiscoveryCommand, options = {}) {
|
|
9
|
+
const observedAt = (options.now?.() ?? new Date()).toISOString();
|
|
10
|
+
const base = { provider: 'cursor', source: 'native', observedAt,
|
|
11
|
+
accountScope: 'local-account', ...(options.accountBinding ? { accountBinding: options.accountBinding } : {}), models: [] };
|
|
12
|
+
try {
|
|
13
|
+
let version = options.runtimeVersion;
|
|
14
|
+
if (!version) {
|
|
15
|
+
const probe = await runner(command, ['--version'], { cwd: tmpdir(), timeoutMs: 5000 });
|
|
16
|
+
// Cursor emits a plain date-version banner. Retain only that known shape.
|
|
17
|
+
if (probe.exitCode === 0)
|
|
18
|
+
version = /^(\d+\.\d+\.\d+-[\w.-]+)$/.exec(probe.stdout.trim())?.[1]
|
|
19
|
+
.replace(/^(\d+)\.(\d+)\.(\d+)/, (_, major, minor, patch) => [major, minor, patch].map(Number).join('.'));
|
|
20
|
+
}
|
|
21
|
+
if (version)
|
|
22
|
+
base.runtimeVersion = version;
|
|
23
|
+
const result = await runner(command, ['--list-models'], { cwd: tmpdir(), timeoutMs: 15_000 });
|
|
24
|
+
if (result.exitCode !== 0) {
|
|
25
|
+
const error = diagnostic(result.stderr.trim() || result.stdout.trim())
|
|
26
|
+
|| `Cursor --list-models exited ${result.exitCode}`;
|
|
27
|
+
return { ...base, errorKind: /not logged in|log in|sign in/i.test(error) ? 'authentication' : classifyDiscoveryError(error), error };
|
|
28
|
+
}
|
|
29
|
+
const diagnostics = [];
|
|
30
|
+
const seen = new Set();
|
|
31
|
+
for (const [index, raw] of result.stdout.split(/\r?\n/).entries()) {
|
|
32
|
+
const line = stripVTControlCharacters(raw).replace(/[\u200B-\u200D\u2060\uFEFF]/g, '').trim();
|
|
33
|
+
if (!line || /^Available models$/i.test(line) || /^Tip: use --model <id>/.test(line))
|
|
34
|
+
continue;
|
|
35
|
+
const match = /^([a-z0-9][a-z0-9._-]*) - (\S.*)$/i.exec(line);
|
|
36
|
+
if (!match || /[\x00-\x1f\x7f]/.test(line)) {
|
|
37
|
+
diagnostics.push(`Cursor --list-models line ${index + 1}: malformed model row`);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const [, id, label] = match;
|
|
41
|
+
if (seen.has(id)) {
|
|
42
|
+
diagnostics.push(`Cursor --list-models line ${index + 1}: duplicate model selector`);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
seen.add(id);
|
|
46
|
+
const displayName = label.replace(/(?:\s+\([^()]*\))+$/, '').trim();
|
|
47
|
+
const automatic = /^(?:auto|default)$/i.test(id);
|
|
48
|
+
// Effort belongs to the exact selector; never invent bracket overrides or
|
|
49
|
+
// a default effort for a name that does not report a variant.
|
|
50
|
+
const effort = /-extra-high(?:-fast)?$/.test(id) ? 'xhigh'
|
|
51
|
+
: /-(minimal|none|low|medium|high|xhigh|max)(?:-fast)?$/.exec(id)?.[1];
|
|
52
|
+
const declared = Object.hasOwn(options.modelLimits ?? {}, id) ? options.modelLimits[id] : undefined;
|
|
53
|
+
const displayContext = /(?:^|\s)1M(?:\s|$)/.test(displayName) ? 1_000_000 : undefined;
|
|
54
|
+
const worker = buildWorkerObservation({ cliId: options.cliId ?? 'cursor', source: `${command} --list-models`,
|
|
55
|
+
pointer: `/lines/${index + 1}`, runtimeVersion: version ?? 'unknown', accountScope: 'local-account',
|
|
56
|
+
accountBinding: options.accountBinding, observedAt, contentDigest: discoveryDigest(line) }, {
|
|
57
|
+
modelId: id, family: 'unknown', visibility: 'listed', lifecycle: 'active',
|
|
58
|
+
availability: automatic ? 'unavailable' : 'accessible',
|
|
59
|
+
contextTokens: declared?.contextTokens ?? displayContext, maxOutputTokens: declared?.maxOutputTokens,
|
|
60
|
+
efforts: !automatic && effort ? [{ id: effort, selfDelegates: null }] : [],
|
|
61
|
+
provenanceFields: ['/apiModelId:listed-selector', '/llmProvider:cursor-gateway', '/displayName', '/efforts:selector-suffix',
|
|
62
|
+
...(!declared && displayContext ? ['/contextTokens:display-name-1M'] : [])],
|
|
63
|
+
});
|
|
64
|
+
if (declared) {
|
|
65
|
+
// The native list does not attest operator limits.
|
|
66
|
+
worker.provenance[0].fields = worker.provenance[0].fields.filter(field => field !== '/contextTokens' && (declared.maxOutputTokens === undefined || field !== '/maxOutputTokens'));
|
|
67
|
+
const source = `/parallelism/clis/${options.cliId ?? 'cursor'}/modelLimits`;
|
|
68
|
+
worker.provenance.push({ fields: ['/contextTokens', ...(declared.maxOutputTokens === undefined ? [] : ['/maxOutputTokens'])],
|
|
69
|
+
source, kind: 'operator', observedAt, digest: discoveryDigest(JSON.stringify({ id, ...declared })), confidence: 'reported' });
|
|
70
|
+
worker.evidenceDigest = discoveryDigest(JSON.stringify({ native: worker.evidenceDigest, source, id, ...declared }));
|
|
71
|
+
}
|
|
72
|
+
// The list identifies the Cursor gateway selector, not an attested
|
|
73
|
+
// upstream API model, vendor, family or data policy.
|
|
74
|
+
base.models.push({ id, apiModelId: id, llmProvider: 'cursor', displayName,
|
|
75
|
+
isDefault: /\([^()]*\bdefault\b[^()]*\)/i.test(label), hidden: false,
|
|
76
|
+
reasoningEfforts: worker.efforts.map(entry => entry.id), worker });
|
|
77
|
+
}
|
|
78
|
+
return { ...base, ...(diagnostics.length || !base.models.length ? { errorKind: 'invalid-output',
|
|
79
|
+
error: diagnostics.join('; ') || 'Cursor returned no parseable model rows.' } : {}) };
|
|
80
|
+
}
|
|
81
|
+
catch (cause) {
|
|
82
|
+
const error = diagnostic(cause instanceof Error ? cause.message : 'Cursor discovery command failed');
|
|
83
|
+
return { ...base, models: [], errorKind: classifyDiscoveryError(error), error };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** Bind refresh to the configured Cursor executable and account label when unambiguous. */
|
|
87
|
+
export async function discoverProjectCursorModels(options) {
|
|
88
|
+
const clis = Object.entries(options.parallelism?.clis ?? {}).filter(([id, cli]) => cli.enabled !== false && !cli.localModels && (cli.adapter ?? `providers:${id}`) === 'providers:cursor');
|
|
89
|
+
const [cliId, cli] = clis.length === 1 ? clis[0] : [];
|
|
90
|
+
return discoverCursorListModels(cli?.executable, options.runner, { cliId, accountBinding: cli?.accountScope, modelLimits: cli?.modelLimits, now: options.now });
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=cursor-models.js.map
|
|
@@ -891,7 +891,7 @@
|
|
|
891
891
|
"id": "cursor-direct",
|
|
892
892
|
"provider": "cursor",
|
|
893
893
|
"adapterVersion": "1",
|
|
894
|
-
"supportedVersions": "2026.
|
|
894
|
+
"supportedVersions": "2026.11.13-eacade1",
|
|
895
895
|
"runtimeDriver": "installed:cursor",
|
|
896
896
|
"catalogAdapter": {
|
|
897
897
|
"kind": "file",
|
|
@@ -946,67 +946,67 @@
|
|
|
946
946
|
"invocationProfiles": {
|
|
947
947
|
"direct-shell": {
|
|
948
948
|
"transport": "shell",
|
|
949
|
-
"supportedVersions": "2026.
|
|
949
|
+
"supportedVersions": "2026.11.13-eacade1",
|
|
950
950
|
"controls": {
|
|
951
951
|
"model": {
|
|
952
952
|
"support": "unqualified",
|
|
953
|
-
"mapping": "[--model MODEL
|
|
954
|
-
"evidence": "H: cursor-agent 2026.
|
|
953
|
+
"mapping": "[--model MODEL]; exact catalog model ID including its effort variant, never a generic alias, never the CLI's own auto-selection ('auto'/'default'); the captured --help documents only --model, no -m short alias",
|
|
954
|
+
"evidence": "H: cursor-agent 2026.11.13-eacade1 --help and live --list-models observed 2026-11-17; composer-2.5 stdin smoke exited 0 with one success result; dispatch remains unqualified pending human review of a live run"
|
|
955
955
|
},
|
|
956
956
|
"effort": {
|
|
957
957
|
"support": "unqualified",
|
|
958
|
-
"mapping": "
|
|
959
|
-
"evidence": "H:
|
|
958
|
+
"mapping": "select the exact catalog model ID encoding effort, e.g. gpt-5.3-codex-high; never append bracket overrides; composer-2.5 has no separate effort selector",
|
|
959
|
+
"evidence": "H: 2026.11.13-eacade1 help still advertises parameterized bracket overrides, but the live list encodes effort in IDs; observed 2026-11-17: claude-sonnet-5-thinking-high[effort=low] rejected with plain-text Cannot use this model, exit 1 and no JSON"
|
|
960
960
|
},
|
|
961
961
|
"sandbox": {
|
|
962
962
|
"support": "unqualified",
|
|
963
963
|
"mapping": "both contracts emit [--sandbox enabled] (never --sandbox disabled); read-only additionally emits [--mode ask] (the CLI's own documented read-only mode) on top of --sandbox enabled; -f/--force, --yolo, --auto-review and --approve-mcps are out of this contract's scope and are never emitted (--approve-mcps is a bypass, not a non-approval convenience; see pitfalls)",
|
|
964
|
-
"evidence": "H: cursor-agent 2026.
|
|
964
|
+
"evidence": "H: cursor-agent 2026.11.13-eacade1 --help documents --sandbox <enabled|disabled>, --mode <plan|ask> ('ask: ... (read-only)') and -f/--force/--yolo/--auto-review/--approve-mcps; D: installed-module bundle read on noodle (~/.local/share/cursor-agent/versions/2026.10.01-e373342/7000.index.js and 8192.index.js), never executed, shows sandboxMode:\"enabled\" pairs with approvalMode:\"allowlist\" and --approve-mcps sets ignoreApprovals:true on the MCP approval source; Observed 2026-11-17: composer-2.5 smoke with --sandbox enabled exited 0 on titan after host AppArmor setup; read-only mode is help-evidenced only; dispatch unqualified pending human review"
|
|
965
965
|
},
|
|
966
966
|
"approval": {
|
|
967
967
|
"support": "unqualified",
|
|
968
968
|
"mapping": "unavailable as a separate flag: --sandbox/--mode are the only non-bypass permission gates; the direct profile never emits -f/--force, --yolo, --auto-review or --approve-mcps",
|
|
969
|
-
"evidence": "H: cursor-agent 2026.
|
|
969
|
+
"evidence": "H: cursor-agent 2026.11.13-eacade1 --help documents no non-bypass approval-policy flag; Observed 2026-11-17: unapproved project MCP server never ran; smoke exited 0 without error or interaction_query events; dispatch unqualified pending human review"
|
|
970
970
|
},
|
|
971
971
|
"workdir": {
|
|
972
972
|
"support": "unqualified",
|
|
973
973
|
"mapping": "[--workspace W] conductor working root, plus the conductor process cwd",
|
|
974
|
-
"evidence": "H: cursor-agent 2026.
|
|
974
|
+
"evidence": "H: cursor-agent 2026.11.13-eacade1 --help documents --workspace <path-or-name>; Observed 2026-11-17: smoke system/init cwd matched the supplied temporary workspace; dispatch unqualified pending human review"
|
|
975
975
|
},
|
|
976
976
|
"finalOutput": {
|
|
977
977
|
"support": "unqualified",
|
|
978
978
|
"mapping": "unavailable as a file target: no output-file flag is documented; the final is the last type:\"result\" line of the captured --output-format stream-json stdout stream",
|
|
979
|
-
"evidence": "H: cursor-agent 2026.
|
|
979
|
+
"evidence": "H: cursor-agent 2026.11.13-eacade1 --help documents --output-format <text|json|stream-json> with no file-path argument; D: installed-module bundle read on noodle (~/.local/share/cursor-agent/versions/2026.10.01-e373342/7000.index.js), never executed shows the single terminal result object shape; Observed 2026-11-17: plain-model smoke emitted exactly one result with subtype success, is_error false and result cursor-smoke-ok, exit 0; dispatch unqualified pending human review"
|
|
980
980
|
},
|
|
981
981
|
"stdin": {
|
|
982
982
|
"support": "unqualified",
|
|
983
983
|
"mapping": "brief-text: omitting the prompt argument makes the CLI read the prompt from stdin to EOF; brief text never enters argv, rendered commands or serialized plans",
|
|
984
|
-
"evidence": "D: installed-module bundle read on noodle (~/.local/share/cursor-agent/versions/2026.10.01-e373342/7000.index.js), never executed shows the prompt-building function reads stdin to EOF only when no positional prompt argument is supplied; unqualified
|
|
984
|
+
"evidence": "D: installed-module bundle read on noodle (~/.local/share/cursor-agent/versions/2026.10.01-e373342/7000.index.js), never executed shows the prompt-building function reads stdin to EOF only when no positional prompt argument is supplied; Observed 2026-11-17: brief piped on stdin with no positional prompt produced cursor-smoke-ok, exit 0; dispatch unqualified pending human review"
|
|
985
985
|
},
|
|
986
986
|
"structuredOutput": {
|
|
987
987
|
"support": "unqualified",
|
|
988
988
|
"mapping": "unavailable: no output-schema flag is documented",
|
|
989
|
-
"evidence": "H: cursor-agent 2026.
|
|
989
|
+
"evidence": "H: cursor-agent 2026.11.13-eacade1 --help advertises no output-schema flag; unqualified until live evidence"
|
|
990
990
|
},
|
|
991
991
|
"stepCap": {
|
|
992
992
|
"support": "unqualified",
|
|
993
993
|
"mapping": "unavailable: no step or turn cap flag is evidenced; deadline and output-byte bounds come from the invoking shell",
|
|
994
|
-
"evidence": "H: cursor-agent 2026.
|
|
994
|
+
"evidence": "H: cursor-agent 2026.11.13-eacade1 --help advertises no step-cap flag; unknown controls block tasks requiring them"
|
|
995
995
|
},
|
|
996
996
|
"trust": {
|
|
997
997
|
"support": "unqualified",
|
|
998
998
|
"mapping": "always emitted: [--trust] removes the only documented workspace-trust prompt so the non-interactive run cannot block on it",
|
|
999
|
-
"evidence": "H: cursor-agent 2026.
|
|
999
|
+
"evidence": "H: cursor-agent 2026.11.13-eacade1 --help documents --trust ('Trust the current workspace without prompting'); Observed 2026-11-17: --trust smoke completed with no interaction_query or error events; dispatch unqualified pending human review"
|
|
1000
1000
|
},
|
|
1001
1001
|
"children": {
|
|
1002
1002
|
"support": "unqualified",
|
|
1003
1003
|
"mapping": "unknown: no subagent/child-process fan-out flag is documented for -p",
|
|
1004
|
-
"evidence": "H: cursor-agent 2026.
|
|
1004
|
+
"evidence": "H: cursor-agent 2026.11.13-eacade1 --help documents no child-process flag for -p; unqualified until live evidence"
|
|
1005
1005
|
},
|
|
1006
1006
|
"fallback": {
|
|
1007
1007
|
"support": "unqualified",
|
|
1008
1008
|
"mapping": "unavailable: no fallback-model flag is documented",
|
|
1009
|
-
"evidence": "H: cursor-agent 2026.
|
|
1009
|
+
"evidence": "H: cursor-agent 2026.11.13-eacade1 --help advertises no fallback-model flag; unknown controls block tasks requiring them"
|
|
1010
1010
|
}
|
|
1011
1011
|
},
|
|
1012
1012
|
"envAllowlist": [
|
|
@@ -1015,16 +1015,17 @@
|
|
|
1015
1015
|
"PATH"
|
|
1016
1016
|
],
|
|
1017
1017
|
"pitfalls": [
|
|
1018
|
-
"
|
|
1018
|
+
"Help, live model list and smoke observations from 2026-11-17 are recorded in docs/providers/cursor-direct.md; dispatch remains unqualified pending human review of a live run.",
|
|
1019
1019
|
"Unknown model, effort, permission or required step mappings block dispatch.",
|
|
1020
|
+
"On hosts with kernel.apparmor_restrict_unprivileged_userns=1, cursorsandbox needs a host AppArmor profile; without it the CLI reports Sandbox mode is enabled but not available in plain text and exits non-zero.",
|
|
1020
1021
|
"Native MCP/client, MSP/ACP, gateway and conversation capabilities do not establish worker authority.",
|
|
1021
1022
|
"-f/--force, --yolo and --auto-review are never part of the direct profile; none was ever shipped as a new argv-prompt path.",
|
|
1022
1023
|
"--approve-mcps is a BYPASS, not a harmless convenience: it sets ignoreApprovals:true on the MCP approval source (installed-module bundle read, 8192.index.js), which is folded with --force/--yolo into one upstream bypass flag. Without it, an MCP server not already recorded as approved fails its load() call and is skipped; the run continues without that server's tools. It is never emitted by this profile.",
|
|
1023
1024
|
"This version's non-interactive path has no type:\"error\" terminal event: a thrown error writes plain text and exits non-zero with no JSON result line at all; a missing terminal plus a non-zero exit is the failure signal here. Defensively, ANY type:\"error\" event or non-null top-level error field fails the stream regardless of position, including after an earlier success.",
|
|
1024
1025
|
"A type:\"interaction_query\" line means the CLI is waiting for an approval answer this profile cannot supply; treated as fatal regardless of position (before or after a success line), never as a pending success.",
|
|
1025
1026
|
"The template placeholder ${mode} documents the conditional --mode ask that read-only additionally emits on top of --sandbox enabled; it is omitted entirely for workspace-write, never rendered as an empty token.",
|
|
1026
|
-
"
|
|
1027
|
-
"SE4:
|
|
1027
|
+
"Auth may use CURSOR_API_KEY or an existing login (live smoke used login); HOME locates ~/.cursor for persistent settings.",
|
|
1028
|
+
"SE4: historical raw banner 2026.10.01-e373342 needs semver normalization to 2026.10.1-e373342; current supported version 2026.11.13-eacade1 needs no normalization."
|
|
1028
1029
|
],
|
|
1029
1030
|
"health": {
|
|
1030
1031
|
"version": 1,
|
|
@@ -1050,8 +1051,8 @@
|
|
|
1050
1051
|
{
|
|
1051
1052
|
"kind": "help",
|
|
1052
1053
|
"ref": "tools/ralph-external/lib/cursor-adapter.mjs",
|
|
1053
|
-
"observedAt": "2026-
|
|
1054
|
-
"cliVersion": "2026.
|
|
1054
|
+
"observedAt": "2026-11-17T00:00:00Z",
|
|
1055
|
+
"cliVersion": "2026.11.13-eacade1"
|
|
1055
1056
|
},
|
|
1056
1057
|
{
|
|
1057
1058
|
"kind": "repository",
|
|
@@ -141,23 +141,24 @@
|
|
|
141
141
|
"cursor": {
|
|
142
142
|
"roles": {
|
|
143
143
|
"reasoning": {
|
|
144
|
-
"id": "claude-
|
|
145
|
-
"status": "
|
|
146
|
-
"observed":
|
|
144
|
+
"id": "claude-opus-5-thinking-high",
|
|
145
|
+
"status": "active",
|
|
146
|
+
"observed": true
|
|
147
147
|
},
|
|
148
148
|
"coding": {
|
|
149
|
-
"id": "
|
|
150
|
-
"status": "
|
|
151
|
-
"observed":
|
|
149
|
+
"id": "gpt-5.3-codex-high",
|
|
150
|
+
"status": "active",
|
|
151
|
+
"observed": true
|
|
152
152
|
},
|
|
153
153
|
"efficiency": {
|
|
154
|
-
"id": "
|
|
155
|
-
"status": "
|
|
156
|
-
"observed":
|
|
154
|
+
"id": "composer-2.5",
|
|
155
|
+
"status": "active",
|
|
156
|
+
"observed": true
|
|
157
157
|
}
|
|
158
158
|
},
|
|
159
159
|
"sourceUrl": "https://cursor.com/docs/models",
|
|
160
|
-
"verifiedAt": "2026-
|
|
160
|
+
"verifiedAt": "2026-11-17",
|
|
161
|
+
"evidence": "Source: live cursor-agent 2026.11.13-eacade1 --list-models on 2026-11-17 (models.txt); account-offered IDs observed, not dispatch qualification. See docs/providers/cursor-direct.md#live-observations-2026-11-17."
|
|
161
162
|
},
|
|
162
163
|
"factory": {
|
|
163
164
|
"roles": {
|
|
@@ -33,9 +33,9 @@ export const PROVIDER_DISCOVERY_DECISIONS = {
|
|
|
33
33
|
},
|
|
34
34
|
cursor: {
|
|
35
35
|
provider: 'cursor',
|
|
36
|
-
status: '
|
|
37
|
-
interface:
|
|
38
|
-
reason: '
|
|
36
|
+
status: 'native',
|
|
37
|
+
interface: 'cursor-agent --list-models',
|
|
38
|
+
reason: 'The read-only account list reports exact Cursor selectors; automatic selectors are observed but unavailable for workers.',
|
|
39
39
|
documentation: 'https://docs.cursor.com/en/cli/reference/parameters',
|
|
40
40
|
},
|
|
41
41
|
factory: {
|
|
@@ -636,6 +636,7 @@ export async function resolveDynamicModelCatalog(options) {
|
|
|
636
636
|
muse: () => discoverMuseCatalogModels({
|
|
637
637
|
...options.muse, catalogDir: options.muse?.catalogDir ?? join(homeDir, MUSE_CATALOG_DIR), now: options.now,
|
|
638
638
|
}),
|
|
639
|
+
cursor: async () => (await import('./cursor-models.js')).discoverProjectCursorModels(options),
|
|
639
640
|
factory: async () => {
|
|
640
641
|
const { discoverProjectFactoryModels } = await import('./factory-models.js');
|
|
641
642
|
return discoverProjectFactoryModels(options.inventory.projectDir, { homeDir, runner: options.runner, now: options.now });
|
|
@@ -356,7 +356,7 @@ export function validateWorkerPolicyRoute(input) {
|
|
|
356
356
|
if (input.context && !workerContextHeadroom(input.context, observation).fits) {
|
|
357
357
|
const missing = [observation.contextTokens === null ? 'contextTokens' : ''].filter(Boolean);
|
|
358
358
|
deny('OG_MODEL_UNAPPROVED', '/worker/contextTokens', missing.length
|
|
359
|
-
? `Bounded context and output cannot be checked: catalog does not report a qualified ${missing.join(', ')} limit. Refresh discovery with reported limits; operator approval does not invent limits.`
|
|
359
|
+
? `Bounded context and output cannot be checked: catalog does not report a qualified ${missing.join(', ')} limit. Refresh discovery with reported limits; operator approval does not invent limits.${input.inferenceProvider === 'cursor' ? ` Set parallelism.clis.${observation.cliId}.modelLimits["${input.selectedModel}"].contextTokens and refresh discovery/requalify.` : ''}`
|
|
360
360
|
: 'Bounded context and output do not fit qualified limits; reduce the request context or reserved output.');
|
|
361
361
|
}
|
|
362
362
|
if (input.context && observation.contextTokens !== null && observation.maxOutputTokens === null) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** Offline S1 health readiness projection; never launch authority or a probe. */
|
|
2
|
+
import { workerWiringDiagnostics } from './worker-wiring-diagnostics.js';
|
|
2
3
|
import { homedir } from 'node:os';
|
|
3
4
|
import { collectLocalOnlyPaths } from './conductor-data-policy.mjs';
|
|
4
5
|
import { isAbsolute, join, resolve } from 'node:path';
|
|
@@ -119,6 +120,9 @@ export function diagnoseWorkerHealthReadiness(snapshot, request, paths = {}) {
|
|
|
119
120
|
nextAction: 'use-direct-checkpoint', role: null });
|
|
120
121
|
return report;
|
|
121
122
|
}
|
|
123
|
+
for (const diagnostic of workerWiringDiagnostics(p, snapshot.models.defaults.workerSelection)) {
|
|
124
|
+
add({ ...diagnostic, status: 'warn', role: null, nextAction: 'review-worker-configuration' });
|
|
125
|
+
}
|
|
122
126
|
const enabledGroups = Object.values(p?.groups ?? {});
|
|
123
127
|
const required = new Set(enabledGroups.flatMap(group => group.requiredRoles ?? []));
|
|
124
128
|
const roles = new Set([...Object.keys(snapshot.models.defaults.workerSelection?.roleGuidance ?? {}), ...required]);
|
|
@@ -47,6 +47,8 @@ export function inspectRecordedWorkerQualifications(input: {
|
|
|
47
47
|
cwd: string; policy: WorkerSelectionPolicy; parallelism: import('../config/aiwg-config.js').ParallelismConfig;
|
|
48
48
|
/** Include signed historical inputs for offline health projection, never launch authority. */
|
|
49
49
|
includeInputs?: boolean;
|
|
50
|
+
/** Signed policy drift only; rejected records never grant authority. */
|
|
51
|
+
diagnostics?: import('./types.js').WorkerPolicyDiagnostic[];
|
|
50
52
|
}): Promise<Array<{ cli: string; provider: string; binding?: WorkerResolutionBinding;
|
|
51
53
|
adapter?: import('./provider-policy.js').WorkerAdapterMetadata;
|
|
52
54
|
observations?: import('./model-discovery.js').ProviderModelDiscovery }>>;
|
|
@@ -754,7 +754,7 @@ async function qualificationSignatureFailure(record, trust) {
|
|
|
754
754
|
* This is historical evidence, not current launch authority; loadRecordedWorkerInstallations
|
|
755
755
|
* performs binary/version/scope checks when dispatch actually requests a binding.
|
|
756
756
|
*/
|
|
757
|
-
export async function inspectRecordedWorkerQualifications({ cwd, policy, parallelism, includeInputs = false }) {
|
|
757
|
+
export async function inspectRecordedWorkerQualifications({ cwd, policy, parallelism, includeInputs = false, diagnostics = [] }) {
|
|
758
758
|
const filename = installationStorePath();
|
|
759
759
|
await assertTrustedStore(filename, [cwd]);
|
|
760
760
|
const { stored } = await readInstallationStore(filename);
|
|
@@ -767,8 +767,8 @@ export async function inspectRecordedWorkerQualifications({ cwd, policy, paralle
|
|
|
767
767
|
const configured = parallelism?.clis?.[cli];
|
|
768
768
|
if (!configured || configured.enabled === false || !/^[a-z][a-z0-9-]{0,62}$/.test(cli)
|
|
769
769
|
|| await realpath(installation.cwd) !== workspace
|
|
770
|
-
|| qualificationDigest(policy) !== installation.effectiveConfigDigest
|
|
771
770
|
|| (installation.localModelsDigest || configured.localModels) && installation.localModelsDigest !== qualificationDigest(configured.localModels ?? null)
|
|
771
|
+
|| (installation.modelLimitsDigest || configured.modelLimits) && installation.modelLimitsDigest !== qualificationDigest(configured.modelLimits ?? null)
|
|
772
772
|
|| configured.adapter !== `providers:${adapter.provider}` && configured.adapter !== adapter.id
|
|
773
773
|
|| configured.accountScope !== binding.accountScope
|
|
774
774
|
|| binding.profile !== installation.profile || binding.cliVersion !== installation.cliVersion
|
|
@@ -776,6 +776,11 @@ export async function inspectRecordedWorkerQualifications({ cwd, policy, paralle
|
|
|
776
776
|
const proof = adapter.invocationProfiles?.[binding.profile]?.installationQualification;
|
|
777
777
|
if (!proof || ['scopeDigest', 'fixtureDigest', 'verifiedAt', 'evidenceRef'].some(key => proof[key] !== installation.evidence?.[key])) continue;
|
|
778
778
|
if (await qualificationSignatureFailure(record, () => qualificationTrust(cwd))) continue;
|
|
779
|
+
if (qualificationDigest(policy) !== installation.effectiveConfigDigest) {
|
|
780
|
+
const { workerQualificationPolicyDiagnostic } = await import('./worker-qualification-policy.js');
|
|
781
|
+
diagnostics.push(workerQualificationPolicyDiagnostic([{ registration: 0, reason: 'effective-config-digest' }], [record], policy));
|
|
782
|
+
continue;
|
|
783
|
+
}
|
|
779
784
|
await assertWorkerInstallationEvidence({ ...installation, adapter, now: Date.now(), policy }, proof.scopeDigest);
|
|
780
785
|
results.push({ cli, provider: adapter.provider, ...(includeInputs
|
|
781
786
|
? { binding: structuredClone(binding), adapter: structuredClone(adapter), observations: structuredClone(record.modelObservations) } : {}) });
|
|
@@ -917,6 +922,7 @@ export async function loadRecordedWorkerInstallations({ registry, cwd, policy, p
|
|
|
917
922
|
|| binding.accountScope !== installation.accountScope
|
|
918
923
|
|| qualificationDigest(binding.boundary) !== qualificationDigest(installation.boundary)) throw fail();
|
|
919
924
|
if (parallelism && (installation.localModelsDigest || parallelism.clis?.[cli]?.localModels) && installation.localModelsDigest !== qualificationDigest(parallelism.clis?.[cli]?.localModels ?? null)) throw fail();
|
|
925
|
+
if (parallelism && (installation.modelLimitsDigest || parallelism.clis?.[cli]?.modelLimits) && installation.modelLimitsDigest !== qualificationDigest(parallelism.clis?.[cli]?.modelLimits ?? null)) throw fail();
|
|
920
926
|
reason = 'effective-config-digest';
|
|
921
927
|
if (qualificationDigest(policy) !== installation.effectiveConfigDigest) throw fail();
|
|
922
928
|
reason = 'evidence';
|
|
@@ -45,7 +45,7 @@ export function isOperatorQualifiedWorkerAdapter(adapter) {
|
|
|
45
45
|
}
|
|
46
46
|
/** Bundled renderers with an independently checked native direct baseline. */
|
|
47
47
|
export function hasOperatorWorkerNativeRenderer(adapter) {
|
|
48
|
-
return isOperatorQualifiedWorkerAdapter(adapter) && ['codex', 'muse', 'factory'].includes(adapter.provider)
|
|
48
|
+
return isOperatorQualifiedWorkerAdapter(adapter) && ['codex', 'muse', 'factory', 'cursor'].includes(adapter.provider)
|
|
49
49
|
&& adapter.invocation.kind === 'process';
|
|
50
50
|
}
|
|
51
51
|
/** The process-group launch boundary requires the independently verified native renderer. */
|
|
@@ -73,6 +73,26 @@ export function assertOperatorWorkerNativeArgv(adapter, argv, selected, permissi
|
|
|
73
73
|
const sandbox = permissions?.sandbox ?? 'workspace-write';
|
|
74
74
|
if (!['read-only', 'workspace-write', 'external'].includes(sandbox))
|
|
75
75
|
throw new Error('Requested sandbox has no verified native renderer');
|
|
76
|
+
if (adapter.provider === 'cursor') {
|
|
77
|
+
if (sandbox === 'external' || (permissions?.approval ?? 'never') !== 'never') {
|
|
78
|
+
throw new Error('Cursor direct worker requires native sandbox and never approval');
|
|
79
|
+
}
|
|
80
|
+
if (!selected.model || /[\0[\]"]/.test(selected.model)
|
|
81
|
+
|| ['opus', 'sonnet', 'haiku', 'auto', 'default'].includes(selected.model.toLowerCase())
|
|
82
|
+
|| selected.effort.value === null || !/^[A-Za-z0-9_.-]+$/.test(selected.effort.value)) {
|
|
83
|
+
throw new Error('Cursor direct worker requires an exact model ID and explicit effort metadata');
|
|
84
|
+
}
|
|
85
|
+
const cwd = args[args.indexOf('--workspace') + 1];
|
|
86
|
+
if (!args.includes('--workspace') || !cwd?.startsWith('/') || cwd.includes('\0')) {
|
|
87
|
+
throw new Error('Cursor direct worker requires an absolute workspace');
|
|
88
|
+
}
|
|
89
|
+
const expected = ['-p', '--output-format', 'stream-json', '--trust', '--sandbox', 'enabled',
|
|
90
|
+
...(sandbox === 'read-only' ? ['--mode', 'ask'] : []), '--workspace', cwd, '--model', selected.model];
|
|
91
|
+
if (args.length !== expected.length || args.some((value, index) => value !== expected[index])) {
|
|
92
|
+
throw new Error('Cursor native worker controls could be overridden');
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
76
96
|
if (adapter.provider === 'factory') {
|
|
77
97
|
if (sandbox === 'external' || (permissions?.approval ?? 'never') !== 'never') {
|
|
78
98
|
throw new Error('Factory direct worker requires native sandbox and never approval');
|
|
@@ -124,10 +124,12 @@ export function resolveWorkerPlan(snapshot, request, ceilingDefaults = {}) {
|
|
|
124
124
|
if (request.member && !request.group)
|
|
125
125
|
block('OG_CONFIG_REFERENCE', '/request/member', 'Group-local member pins require a group');
|
|
126
126
|
if (request.group && !guidance?.groups.includes(request.group))
|
|
127
|
-
block('OG_CONFIG_REFERENCE', '/request/group',
|
|
127
|
+
block('OG_CONFIG_REFERENCE', '/request/group', `Group is outside role guidance. Edit models.json: add ${JSON.stringify(request.group)} to defaults.workerSelection.roleGuidance.${role}.groups.`);
|
|
128
128
|
if ([request.maxParallel, snapshot.constraints?.maxParallel].some(value => value !== undefined && (!Number.isSafeInteger(value) || value < 0)))
|
|
129
129
|
block('OG_CONFIG_REFERENCE', '/request/maxParallel', 'Capacity ceilings must be nonnegative integers');
|
|
130
130
|
plan.diagnostics.push(...workerReviewLineageDiagnostics(request));
|
|
131
|
+
if (plan.diagnostics.some(diagnostic => diagnostic.code === 'OG_CONFIG_REFERENCE'))
|
|
132
|
+
return plan;
|
|
131
133
|
const candidateGroups = request.group ? [request.group] : guidance?.groups ?? [];
|
|
132
134
|
const unqualifiedGroups = new Set(qualificationGaps.map(gapGroup));
|
|
133
135
|
const qualifiedGroups = candidateGroups.filter(groupId => !unqualifiedGroups.has(groupId));
|