@parcha/agentrun-serve 0.1.0-beta.51 → 0.1.0-beta.53
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/CHANGELOG.md +160 -1
- package/README.md +306 -36
- package/dist/adapters.js +1 -1
- package/dist/agent-delete.d.ts +14 -4
- package/dist/agent-delete.js +30 -58
- package/dist/agent-package.d.ts +71 -0
- package/dist/agent-package.js +345 -0
- package/dist/agents-store.d.ts +28 -18
- package/dist/agents-store.js +48 -34
- package/dist/api-only.d.ts +30 -8
- package/dist/api-only.js +40 -16
- package/dist/archil-routes.d.ts +1 -0
- package/dist/archil-routes.js +28 -2
- package/dist/claude-login.d.ts +1 -0
- package/dist/claude-login.js +1 -1
- package/dist/cli-learning/cli.d.ts +3 -0
- package/dist/cli-learning/cli.js +17 -3
- package/dist/cli-learning/connections.js +3 -2
- package/dist/cli-learning/schema.js +2 -1
- package/dist/cli.js +70 -7
- package/dist/composio-preset.d.ts +2 -1
- package/dist/composio-preset.js +4 -3
- package/dist/composio-triggers.d.ts +4 -0
- package/dist/composio-triggers.js +4 -1
- package/dist/computer-needs.d.ts +32 -0
- package/dist/computer-needs.js +80 -0
- package/dist/computer-setting.d.ts +9 -0
- package/dist/computer-setting.js +19 -1
- package/dist/computers.d.ts +6 -2
- package/dist/computers.js +2 -2
- package/dist/console/assets/index-BFgyZzF_.js +734 -0
- package/dist/console/assets/index-DbilxljH.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/console-links.d.ts +1 -0
- package/dist/console-links.js +2 -0
- package/dist/env-switch.d.ts +14 -0
- package/dist/env-switch.js +23 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +3 -0
- package/dist/eval-previous.js +4 -3
- package/dist/fal-price.d.ts +76 -0
- package/dist/fal-price.js +365 -0
- package/dist/handed-secret.d.ts +4 -0
- package/dist/handed-secret.js +10 -0
- package/dist/harness-archive.d.ts +15 -5
- package/dist/harness-archive.js +71 -34
- package/dist/harness-check.d.ts +2 -1
- package/dist/harness-check.js +36 -95
- package/dist/harness-egress.d.ts +23 -0
- package/dist/harness-egress.js +69 -0
- package/dist/harness-recipe-entry.d.ts +71 -0
- package/dist/harness-recipe-entry.js +184 -0
- package/dist/harness-recipe.d.ts +73 -6
- package/dist/harness-recipe.js +185 -31
- package/dist/harness-sign-in.d.ts +29 -0
- package/dist/harness-sign-in.js +122 -0
- package/dist/harness-table.d.ts +21 -0
- package/dist/harness-table.js +58 -3
- package/dist/harness-zip.d.ts +6 -0
- package/dist/harness-zip.js +203 -0
- package/dist/ids.d.ts +11 -0
- package/dist/ids.js +36 -0
- package/dist/learn/commit.d.ts +19 -1
- package/dist/learn/commit.js +160 -2
- package/dist/learn/compile.d.ts +13 -5
- package/dist/learn/compile.js +46 -15
- package/dist/learn/delete.d.ts +12 -6
- package/dist/learn/delete.js +17 -11
- package/dist/learn/folder.d.ts +16 -0
- package/dist/learn/folder.js +30 -4
- package/dist/learn/learning-of.d.ts +8 -0
- package/dist/learn/learning-of.js +8 -0
- package/dist/learn/learning.sh +29 -4
- package/dist/learn/promote.d.ts +51 -7
- package/dist/learn/promote.js +51 -8
- package/dist/learn/secrets.js +30 -7
- package/dist/learning-reset.d.ts +18 -0
- package/dist/learning-reset.js +115 -0
- package/dist/learning-routes.d.ts +23 -11
- package/dist/learning-routes.js +110 -20
- package/dist/learning-words.d.ts +5 -0
- package/dist/learning-words.js +5 -0
- package/dist/learning.d.ts +15 -10
- package/dist/learning.js +14 -8
- package/dist/llms.txt +1 -0
- package/dist/mcp-gateway.d.ts +39 -2
- package/dist/mcp-gateway.js +56 -12
- package/dist/mcp-pin-first.js +1 -1
- package/dist/mcp-probe.d.ts +3 -0
- package/dist/mcp-probe.js +7 -2
- package/dist/mcp-resources.d.ts +44 -0
- package/dist/mcp-resources.js +100 -0
- package/dist/mcp-servers-store.d.ts +17 -12
- package/dist/mcp-servers-store.js +2 -1
- package/dist/media-duration.d.ts +2 -0
- package/dist/media-duration.js +136 -0
- package/dist/model.d.ts +4 -4
- package/dist/model.js +6 -6
- package/dist/native/cli.js +9 -2
- package/dist/native/connection.d.ts +2 -2
- package/dist/native/connection.js +5 -2
- package/dist/native/discovery.d.ts +2 -0
- package/dist/native/discovery.js +10 -6
- package/dist/native/remote-worker-bridge.js +36 -4
- package/dist/native/remote.d.ts +18 -1
- package/dist/native/remote.js +126 -37
- package/dist/native/schema.d.ts +6 -0
- package/dist/native/schema.js +31 -6
- package/dist/native/source-account.d.ts +13 -0
- package/dist/native/source-account.js +114 -0
- package/dist/native/source-capture-hooks.d.ts +5 -0
- package/dist/native/source-capture-hooks.js +102 -0
- package/dist/native/source-mcp-selection.d.ts +13 -0
- package/dist/native/source-mcp-selection.js +72 -0
- package/dist/native/source-runtime-tools.d.ts +19 -0
- package/dist/native/source-runtime-tools.js +103 -0
- package/dist/native/source-snapshot-types.d.ts +138 -0
- package/dist/native/source-snapshot-types.js +12 -0
- package/dist/native/source-snapshot.d.ts +8 -0
- package/dist/native/source-snapshot.js +1201 -0
- package/dist/observation/learning.js +3 -2
- package/dist/openapi.js +211 -47
- package/dist/print.js +1 -1
- package/dist/provider.d.ts +8 -0
- package/dist/provider.js +14 -2
- package/dist/purged-workflow.d.ts +12 -0
- package/dist/purged-workflow.js +43 -0
- package/dist/refusal-words.d.ts +0 -3
- package/dist/refusal-words.js +0 -3
- package/dist/request-metadata.d.ts +20 -0
- package/dist/request-metadata.js +24 -0
- package/dist/run-keys.d.ts +46 -0
- package/dist/run-keys.js +109 -0
- package/dist/run-launch.d.ts +29 -5
- package/dist/run-launch.js +44 -4
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-model-key.d.ts +2 -2
- package/dist/run-model-key.js +5 -5
- package/dist/run-secrets.d.ts +2 -0
- package/dist/run-secrets.js +7 -4
- package/dist/run-usage.d.ts +48 -4
- package/dist/run-usage.js +156 -39
- package/dist/run-view.d.ts +18 -1
- package/dist/run-view.js +28 -8
- package/dist/runner/adapter-loop.d.ts +14 -4
- package/dist/runner/adapter-loop.js +150 -31
- package/dist/runner/adapter-run-spec.d.ts +1 -1
- package/dist/runner/adapter-run-spec.js +35 -22
- package/dist/runner/audit.d.ts +10 -3
- package/dist/runner/audit.js +30 -7
- package/dist/runner/beside.js +2 -1
- package/dist/runner/claim-secrets.d.ts +31 -4
- package/dist/runner/claim-secrets.js +43 -7
- package/dist/runner/cli-run-spec.d.ts +1 -1
- package/dist/runner/cli-run-spec.js +32 -20
- package/dist/runner/conformance/harness.js +4 -2
- package/dist/runner/dispatch.js +4 -2
- package/dist/runner/harness-loops.d.ts +6 -0
- package/dist/runner/harness-loops.js +16 -3
- package/dist/runner/held.d.ts +4 -0
- package/dist/runner/journal-kinds.d.ts +5 -0
- package/dist/runner/learned-first.d.ts +2 -0
- package/dist/runner/learned-first.js +1 -1
- package/dist/runner/learning-end.d.ts +9 -3
- package/dist/runner/learning-end.js +66 -29
- package/dist/runner/learning-seed.d.ts +9 -3
- package/dist/runner/learning-seed.js +2 -2
- package/dist/runner/main.d.ts +1 -0
- package/dist/runner/main.js +20 -13
- package/dist/runner/mcp-claim.js +7 -2
- package/dist/runner/mcp-run.d.ts +12 -0
- package/dist/runner/mcp-run.js +14 -1
- package/dist/runner/model-route.js +7 -4
- package/dist/runner/monid-run.js +9 -11
- package/dist/runner/project-checkpoint.d.ts +35 -0
- package/dist/runner/project-checkpoint.js +116 -0
- package/dist/runner/project-drain.d.ts +8 -0
- package/dist/runner/project-drain.js +25 -0
- package/dist/runner/project-host.d.ts +10 -0
- package/dist/runner/project-host.js +52 -0
- package/dist/runner/promotion.d.ts +51 -24
- package/dist/runner/promotion.js +206 -78
- package/dist/runner/redact.d.ts +13 -0
- package/dist/runner/redact.js +67 -1
- package/dist/runner/run-channel.d.ts +9 -0
- package/dist/runner/run-channel.js +15 -2
- package/dist/runner/run-child-host.d.ts +8 -4
- package/dist/runner/run-child-host.js +174 -42
- package/dist/runner/run-errors.js +2 -2
- package/dist/runner/runner-check.js +5 -2
- package/dist/runner/runner.js +41 -12
- package/dist/runner/sdk-loop.d.ts +2 -2
- package/dist/runner/sdk-loop.js +3 -3
- package/dist/runner/store-port.d.ts +3 -0
- package/dist/runner/store-secrets.js +7 -3
- package/dist/runner/workflow-first.d.ts +4 -0
- package/dist/runner/workflow-first.js +13 -0
- package/dist/runner/workflow-loop.d.ts +2 -1
- package/dist/runner/workflow-loop.js +2 -1
- package/dist/runner/workflow-spec.js +4 -4
- package/dist/runs-over-store.d.ts +39 -8
- package/dist/runs-over-store.js +147 -32
- package/dist/sdk/check.d.ts +6 -5
- package/dist/sdk/check.js +17 -16
- package/dist/sdk/runs.d.ts +11 -1
- package/dist/sdk/runs.js +185 -78
- package/dist/sdk/schema.js +12 -2
- package/dist/sdk/workflows.d.ts +1 -1
- package/dist/server.d.ts +68 -32
- package/dist/server.js +678 -124
- package/dist/skills/agentrun-serve/SKILL.md +2 -1
- package/dist/source-sync/adoption.d.ts +15 -0
- package/dist/source-sync/adoption.js +36 -0
- package/dist/source-sync/auxiliary.d.ts +23 -0
- package/dist/source-sync/auxiliary.js +64 -0
- package/dist/source-sync/capture-git.d.ts +5 -0
- package/dist/source-sync/capture-git.js +272 -0
- package/dist/source-sync/capture-project.d.ts +53 -0
- package/dist/source-sync/capture-project.js +206 -0
- package/dist/source-sync/capture-refusal.d.ts +7 -0
- package/dist/source-sync/capture-refusal.js +16 -0
- package/dist/source-sync/capture.d.ts +11 -0
- package/dist/source-sync/capture.js +22 -0
- package/dist/source-sync/checkpoint-gate.d.ts +21 -0
- package/dist/source-sync/checkpoint-gate.js +52 -0
- package/dist/source-sync/checkpoints.d.ts +66 -0
- package/dist/source-sync/checkpoints.js +168 -0
- package/dist/source-sync/claim.d.ts +11 -0
- package/dist/source-sync/claim.js +48 -0
- package/dist/source-sync/destination.d.ts +47 -0
- package/dist/source-sync/destination.js +239 -0
- package/dist/source-sync/io.d.ts +15 -0
- package/dist/source-sync/io.js +52 -0
- package/dist/source-sync/local.d.ts +43 -0
- package/dist/source-sync/local.js +229 -0
- package/dist/source-sync/prepare.d.ts +59 -0
- package/dist/source-sync/prepare.js +93 -0
- package/dist/source-sync/projects.d.ts +61 -0
- package/dist/source-sync/projects.js +130 -0
- package/dist/source-sync/registry.d.ts +95 -0
- package/dist/source-sync/registry.js +226 -0
- package/dist/source-sync/service.d.ts +33 -0
- package/dist/source-sync/service.js +118 -0
- package/dist/source-sync/skill-edits.d.ts +12 -0
- package/dist/source-sync/skill-edits.js +122 -0
- package/dist/source-sync/snapshots.d.ts +48 -0
- package/dist/source-sync/snapshots.js +448 -0
- package/dist/source-sync/types.d.ts +9 -0
- package/dist/source-sync/types.js +14 -0
- package/dist/source-sync/workspace.d.ts +66 -0
- package/dist/source-sync/workspace.js +273 -0
- package/dist/store/agent-body.d.ts +8 -0
- package/dist/store/agent-body.js +20 -6
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.d.ts +2 -0
- package/dist/store/journal/storage.js +2 -1
- package/dist/store/postgres/migrations/0025_run_attempts.sql +27 -0
- package/dist/store/postgres/migrations/0026_run_disk.sql +23 -0
- package/dist/store/schema.d.ts +15 -1
- package/dist/store/schema.js +43 -4
- package/dist/store/seal.d.ts +5 -1
- package/dist/store/seal.js +12 -3
- package/dist/store/sqlite/project-checkpoints.d.ts +11 -0
- package/dist/store/sqlite/project-checkpoints.js +70 -0
- package/dist/store/sqlite/run-launch.d.ts +14 -0
- package/dist/store/sqlite/run-launch.js +58 -7
- package/dist/store/sqlite/run-patch.d.ts +2 -1
- package/dist/store/sqlite/run-patch.js +4 -3
- package/dist/store/sqlite/store.js +319 -153
- package/dist/store/store-schema.js +2 -2
- package/dist/store/store.d.ts +173 -33
- package/dist/store/store.js +14 -1
- package/dist/store-reads/learning.d.ts +12 -8
- package/dist/store-reads/learning.js +33 -24
- package/dist/store-reads/loop.d.ts +4 -3
- package/dist/store-reads/loop.js +7 -5
- package/dist/store-view.d.ts +3 -1
- package/dist/store-view.js +17 -5
- package/dist/template-eval.js +4 -4
- package/dist/template-import.d.ts +10 -2
- package/dist/template-import.js +116 -13
- package/dist/templates.d.ts +29 -5
- package/dist/templates.js +68 -14
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/labels.js +1 -1
- package/dist/timeline/timeline.d.ts +5 -0
- package/dist/timeline/timeline.js +8 -0
- package/dist/tool-plane.d.ts +12 -12
- package/dist/tools.d.ts +8 -8
- package/dist/tools.js +1 -1
- package/dist/trigger-launch-hook.d.ts +47 -0
- package/dist/trigger-launch-hook.js +90 -0
- package/dist/trigger-targets.d.ts +14 -1
- package/dist/trigger-targets.js +20 -0
- package/dist/triggers.d.ts +54 -5
- package/dist/triggers.js +143 -8
- package/dist/uploads-archil.js +2 -1
- package/dist/uploads.d.ts +0 -3
- package/dist/uploads.js +2 -11
- package/dist/validate.js +4 -1
- package/dist/web-save.d.ts +3 -0
- package/dist/web-save.js +17 -2
- package/dist/workspace/archil-exec.js +1 -1
- package/dist/workspace/archil.js +1 -1
- package/dist/workspace/computer-for-claim.d.ts +2 -0
- package/dist/workspace/computer-for-claim.js +43 -0
- package/dist/workspace/paths.d.ts +6 -0
- package/dist/workspace/paths.js +6 -0
- package/dist/workspace/resolve-computer.d.ts +1 -0
- package/dist/workspace/revision-skills.js +24 -11
- package/dist/workspace/run-tools.d.ts +2 -0
- package/dist/workspace/run-tools.js +8 -0
- package/dist/workspace/synced-folder.d.ts +3 -3
- package/dist/workspace/synced-folder.js +7 -6
- package/launcher/agentrun-serve +1 -1
- package/package.json +10 -10
- package/skills/agentrun-serve/SKILL.md +2 -1
- package/templates/README.md +5 -2
- package/dist/console/assets/index-Bt1B51b7.js +0 -733
- package/dist/console/assets/index-sVftE9Ht.css +0 -1
package/dist/native/schema.js
CHANGED
|
@@ -2,6 +2,7 @@ const text = { type: 'string' };
|
|
|
2
2
|
const nullableText = { type: ['string', 'null'] };
|
|
3
3
|
const strings = { type: 'array', items: text };
|
|
4
4
|
const object = (properties, required = Object.keys(properties)) => ({ type: 'object', additionalProperties: false, properties, required });
|
|
5
|
+
export const SOURCE_LOCAL_CONSENT = object({ version: { const: 1 }, scope: { type: 'string', pattern: '^[a-f0-9]{64}$' } });
|
|
5
6
|
export const NATIVE_SELECTOR = object({ kind: { enum: ['project', 'agent', 'profile'] }, name: text }, ['kind']);
|
|
6
7
|
export const NATIVE_USAGE = object({ input_tokens: { type: ['integer', 'null'] }, output_tokens: { type: ['integer', 'null'] }, cache_read_tokens: { type: ['integer', 'null'] }, cache_write_tokens: { type: ['integer', 'null'] }, cost_usd: { type: ['number', 'null'] } });
|
|
7
8
|
export const NATIVE_TARGET = object({ runtime: { enum: ['claude-code', 'codex'] }, project: text, selector: NATIVE_SELECTOR, machine_id: text, version: nullableText, model: nullableText, fingerprint: text, configuration: { type: 'array', items: object({ path: text, sha256: text }) }, skills: strings, mcp_servers: strings, state: { enum: ['needs_verification', 'needs_attention', 'ready'] }, issues: strings, capabilities: object({ launch: { type: 'boolean' }, learning: { type: 'boolean' }, workflows: { const: false }, approval: { enum: ['native', 'unavailable'] }, usage: { type: 'boolean' } }) });
|
|
@@ -13,29 +14,53 @@ const mark = { 'x-agentrun-serve': 'native/1', security: [{ bearer: [] }, { owne
|
|
|
13
14
|
const id = { $ref: '#/components/parameters/AgentId' };
|
|
14
15
|
export const NATIVE_PATHS = {
|
|
15
16
|
'/native/discover': { post: { ...mark, operationId: 'discoverNative', summary: 'Discover existing native projects on this source machine without running a model', requestBody: body(object({ project: text, runtime: { enum: ['claude-code', 'codex'] } }, ['project'])), responses: { '200': response(object({ machine_id: text, targets: { type: 'array', items: NATIVE_TARGET } })) } } },
|
|
16
|
-
'/native/connect': { post: { ...mark, operationId: 'connectNative', summary: 'Connect a native project using ordinary agent and revision storage', requestBody: body(object({ project: text, runtime: { enum: ['claude-code', 'codex'] }, selector: NATIVE_SELECTOR }, ['project', 'runtime'])), responses: { '200': response(object({ agent: { $ref: '#/components/schemas/Agent' }, native: NATIVE_BINDING })) } } },
|
|
17
|
+
'/native/connect': { post: { ...mark, operationId: 'connectNative', summary: 'Connect a native project using ordinary agent and revision storage', requestBody: body(object({ project: text, runtime: { enum: ['claude-code', 'codex'] }, selector: NATIVE_SELECTOR, source_sync: SOURCE_LOCAL_CONSENT }, ['project', 'runtime'])), responses: { '200': response(object({ agent: { $ref: '#/components/schemas/Agent' }, native: NATIVE_BINDING })) } } },
|
|
17
18
|
'/agents/{agent_id}/native': { get: { ...mark, operationId: 'getNative', summary: 'Read a native connection', parameters: [id], responses: { '200': response(object({ native: { oneOf: [NATIVE_BINDING, { type: 'null' }] } })) } } },
|
|
18
19
|
'/agents/{agent_id}/native/verify': { post: { ...mark, operationId: 'verifyNative', summary: 'Check native CLI and sign-in without a paid model call', parameters: [id], responses: { '200': response(object({ native: NATIVE_BINDING })) } } },
|
|
19
20
|
'/agents/{agent_id}/native/disconnect': { post: { ...mark, operationId: 'disconnectNative', summary: 'Disconnect future native jobs while retaining source configuration and history', parameters: [id], responses: { '200': response(object({ native: NATIVE_BINDING })) } } },
|
|
20
21
|
};
|
|
21
22
|
const targetId = { name: 'target_id', in: 'path', required: true, schema: text };
|
|
22
|
-
const scopes = object({ native_execution: { type: 'boolean' }, history_import: { type: 'boolean' } }, []);
|
|
23
|
+
const scopes = object({ native_execution: { type: 'boolean' }, history_import: { type: 'boolean' }, config_sync: { type: 'boolean' } }, []);
|
|
23
24
|
const connectorId = { name: 'connector_id', in: 'path', required: true, schema: text };
|
|
24
25
|
const commandId = { name: 'command_id', in: 'path', required: true, schema: text };
|
|
25
26
|
const opaqueObject = { type: 'object', additionalProperties: true };
|
|
26
|
-
const connector = object({ id: text, connector_id: text, label: text, created_at: text, last_seen_at: nullableText, status: { enum: ['online', 'offline', 'revoked'] }, capabilities: object({ observe: { const: true }, native_execution: { type: 'boolean' }, history_import: { type: 'boolean' } }), targets: { type: 'array', items: opaqueObject } });
|
|
27
|
+
const connector = object({ id: text, connector_id: text, label: text, created_at: text, last_seen_at: nullableText, status: { enum: ['online', 'offline', 'revoked'] }, capabilities: object({ observe: { const: true }, native_execution: { type: 'boolean' }, history_import: { type: 'boolean' }, config_sync: { type: 'boolean' } }), targets: { type: 'array', items: opaqueObject } });
|
|
27
28
|
const remoteMark = { ...mark, tags: ['connectors'], 'x-agentrun-serve': 'connectors/1' };
|
|
28
29
|
const workerMark = { ...remoteMark, security: [{ bearer: [] }] };
|
|
29
30
|
Object.assign(NATIVE_PATHS, {
|
|
30
31
|
'/connectors': {
|
|
31
32
|
get: { ...remoteMark, operationId: 'listRemoteConnectors', summary: 'List remote source machines and imported agent targets', responses: { '200': response(object({ connectors: { type: 'array', items: connector } })) } },
|
|
32
|
-
post: { ...workerMark, operationId: 'registerRemoteConnector', summary: 'Exchange a one-use enrollment code for a connector-scoped credential', requestBody: body(object({ installation_id: text, operation_id: text, label: text, capabilities: object({ native_execution: { type: 'boolean' }, history_import: { type: 'boolean' } }, ['native_execution']) }, ['installation_id', 'operation_id', 'capabilities'])), responses: { '200': response(object({ connector, credential: text, credential_expires_at: text })) } }
|
|
33
|
+
post: { ...workerMark, operationId: 'registerRemoteConnector', summary: 'Exchange a one-use enrollment code for a connector-scoped credential', requestBody: body(object({ installation_id: text, operation_id: text, label: text, capabilities: object({ native_execution: { type: 'boolean' }, history_import: { type: 'boolean' }, config_sync: { type: 'boolean' } }, ['native_execution']) }, ['installation_id', 'operation_id', 'capabilities'])), responses: { '200': response(object({ connector, credential: text, credential_expires_at: text })) } }
|
|
33
34
|
},
|
|
34
|
-
'/connectors/enrollment': { post: { ...remoteMark, operationId: 'enrollRemoteConnector', summary: 'Create a ten-minute one-use connection code', requestBody: body(object({ label: text, capabilities: scopes }, [])), responses: { '200': response(object({ enrollment_token: text, expires_at: text, workspace_id: { const: 'local' } })) } } },
|
|
35
|
+
'/connectors/enrollment': { post: { ...remoteMark, operationId: 'enrollRemoteConnector', summary: 'Create a ten-minute one-use connection code', requestBody: body(object({ label: text, capabilities: scopes, connector_id: text }, [])), responses: { '200': response(object({ enrollment_token: text, expires_at: text, workspace_id: { const: 'local' } })) } } },
|
|
35
36
|
'/connectors/{connector_id}': { delete: { ...remoteMark, operationId: 'revokeRemoteConnector', summary: 'Revoke a source connector and stop its outstanding commands', parameters: [connectorId], responses: { '200': response(object({ connector })) } } },
|
|
36
|
-
'/connectors/{connector_id}/import': { post: { ...workerMark, operationId: 'importRemoteTarget', summary: 'Import an explicitly selected source-native agent reference', parameters: [connectorId], requestBody: body(object({ target_id: text, name: text, target: NATIVE_BINDING, history_only: { type: 'boolean' } }, ['target_id', 'target'])), responses: { '200': response(object({ agent_id: text, native: NATIVE_BINDING })) } } },
|
|
37
|
+
'/connectors/{connector_id}/import': { post: { ...workerMark, operationId: 'importRemoteTarget', summary: 'Import an explicitly selected source-native agent reference', parameters: [connectorId], requestBody: body(object({ target_id: text, name: text, target: NATIVE_BINDING, history_only: { type: 'boolean' }, cli_adoption: object({ connection_id: text, credential_epoch: text, proof: text }) }, ['target_id', 'target'])), responses: { '200': response(object({ agent_id: text, native: NATIVE_BINDING })) } } },
|
|
37
38
|
'/connectors/{connector_id}/targets/{target_id}/history': { post: { ...workerMark, operationId: 'importRemoteHistory', summary: 'Import explicitly selected, redacted past sessions without running or learning from them', parameters: [connectorId, targetId], requestBody: body(object({ sessions: { type: 'array', minItems: 1, maxItems: 20, items: opaqueObject } })), responses: { '200': response(object({ agent_id: text, runs: { type: 'array', items: object({ session_id: text, run_id: text, already: { type: 'boolean' } }) }, imported: { type: 'integer' }, already: { type: 'integer' } })) } } },
|
|
38
39
|
'/connectors/{connector_id}/poll': { post: { ...workerMark, operationId: 'pollRemoteConnector', summary: 'Renew active source leases and claim one command without replay', parameters: [connectorId], requestBody: body(object({ worker_id: text, active: { type: 'array', items: object({ command_id: text, lease_token: text }) } }, ['worker_id'])), responses: { '200': response(object({ commands: { type: 'array', items: opaqueObject }, cancelled: strings, server_time: { type: 'number' }, lease_ttl_ms: { type: 'number' } })) } } },
|
|
39
40
|
'/connectors/{connector_id}/commands/{command_id}/events': { post: { ...workerMark, operationId: 'remoteCommandEvents', summary: 'Append an ordered idempotent native event batch for a valid command lease', parameters: [connectorId, commandId], requestBody: body(object({ lease_token: text, sequence: { type: 'integer', minimum: 0 }, events: { type: 'array', items: opaqueObject } })), responses: { '200': response(object({ accepted: { const: true } })) } } },
|
|
40
41
|
'/connectors/{connector_id}/commands/{command_id}/complete': { post: { ...workerMark, operationId: 'completeRemoteCommand', summary: 'Complete a source command once under its valid lease', parameters: [connectorId, commandId], requestBody: body(object({ lease_token: text, result: {}, error: text }, ['lease_token'])), responses: { '200': response(object({ accepted: { const: true } })) } } }
|
|
41
42
|
});
|
|
43
|
+
const sourceProjectIdentities = [
|
|
44
|
+
object({ run_id: text, entry_id: { type: 'integer', minimum: 1 } }),
|
|
45
|
+
object({ run_id: text, entry_id: { type: 'null' }, attempt_epoch: { type: 'integer', minimum: 1 } }),
|
|
46
|
+
];
|
|
47
|
+
const sourceProjectReceipt = { oneOf: sourceProjectIdentities };
|
|
48
|
+
const sourceProjectIssue = { oneOf: sourceProjectIdentities.map(identity => object({ ...identity.properties, status: { enum: ['pending', 'conflict', 'uncertain'] }, reason: text }, [...identity.required, 'status'])) };
|
|
49
|
+
const sourceStatus = object({ project_issues: { type: 'array', items: sourceProjectIssue }, enabled: { type: 'boolean' }, moved: { type: 'boolean' }, state: { enum: ['needs_connection', 'paused', 'syncing', 'needs_attention', 'ready', 'moved', 'conflict'] }, blockers: { type: 'array', items: object({ code: text, message: text, path: text }, ['code', 'message']) }, snapshot: text, current_snapshot: text, connection: object({ connector_id: text, target_id: text }), files: { type: 'integer' }, bytes: { type: 'integer' }, skills: { type: 'integer' }, tools: { type: 'integer' }, tool_connections: { type: 'array', items: object({ name: text, ready: { type: 'boolean' }, selected: text, candidates: { type: 'array', items: object({ name: text, auth: text }) } }, ['name', 'ready', 'candidates']) } }, ['enabled', 'moved', 'state', 'blockers']);
|
|
50
|
+
Object.assign(NATIVE_PATHS, {
|
|
51
|
+
'/connectors/{connector_id}/targets/{target_id}/sync/grant': { post: { ...workerMark, operationId: 'grantSourceSync', summary: 'Read or establish this explicitly authorized source sync grant without re-enabling a paused grant', parameters: [connectorId, targetId], requestBody: body(object({})), responses: { '200': response(opaqueObject) } } },
|
|
52
|
+
'/connectors/{connector_id}/targets/{target_id}/sync': { post: { ...workerMark, operationId: 'publishSourceSync', summary: 'Publish a bounded source snapshot under its grant and sequence', parameters: [connectorId, targetId], requestBody: body(object({ generation: text, sequence: { type: 'integer', minimum: 0 }, snapshot: opaqueObject })), responses: { '200': response(opaqueObject) } } },
|
|
53
|
+
'/connectors/{connector_id}/targets/{target_id}/sync/status': { post: { ...workerMark, operationId: 'sourceSyncFailure', summary: 'Record a fixed source failure while preserving its last complete snapshot', parameters: [connectorId, targetId], requestBody: body(object({ generation: text, sequence: { type: 'integer', minimum: 0 }, code: { enum: ['unsupported_platform', 'source_changed', 'source_unavailable', 'snapshot_too_large'] } })), responses: { '200': response(opaqueObject) } } },
|
|
54
|
+
'/agents/{agent_id}/source': {
|
|
55
|
+
get: { ...mark, operationId: 'getSourceSync', summary: 'Read source sync and managed Move readiness', parameters: [id], responses: { '200': response(sourceStatus) } },
|
|
56
|
+
patch: { ...mark, operationId: 'setSourceSync', summary: 'Enable or pause this agent’s source sync', parameters: [id], requestBody: body(object({ enabled: { type: 'boolean' } })), responses: { '200': response(sourceStatus) } }
|
|
57
|
+
},
|
|
58
|
+
'/agents/{agent_id}/source/move': { post: { ...mark, operationId: 'moveSourceAgent', summary: 'Move the same agent to server-managed execution from its complete synchronized setup', parameters: [id], requestBody: body(object({})), responses: { '200': response(object({ agent: { $ref: '#/components/schemas/Agent' }, source: sourceStatus })) } } },
|
|
59
|
+
'/agents/{agent_id}/source/tools': { post: { ...mark, operationId: 'bindSourceTool', summary: 'Choose the existing destination account for a required source tool', parameters: [id], requestBody: body(object({ tool: text, server: text })), responses: { '200': response(sourceStatus) } } }
|
|
60
|
+
});
|
|
61
|
+
Object.assign(NATIVE_PATHS, {
|
|
62
|
+
'/agents/{agent_id}/source/resolve': { post: { ...mark, operationId: 'resolveSourceSync', summary: 'Use an explicitly reviewed source snapshot while retaining the prior managed revision in history', parameters: [id], requestBody: body(object({ revision: text, snapshot: text })), responses: { '200': response(object({ agent: { $ref: '#/components/schemas/Agent' }, source: sourceStatus })) } } }
|
|
63
|
+
});
|
|
64
|
+
Object.assign(NATIVE_PATHS, {
|
|
65
|
+
'/agents/{agent_id}/source/project-review': { post: { ...mark, operationId: 'reviewSourceProject', summary: 'Acknowledge exact unresolved run receipts and allow later runs to use the saved project', parameters: [id], requestBody: body(object({ receipts: { type: 'array', minItems: 1, maxItems: 1000, items: sourceProjectReceipt } })), responses: { '200': response(sourceStatus) } } }
|
|
66
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Codex 0.171.0's local auth metadata rules, not authentication or token verification.
|
|
2
|
+
* login/auth/manager.rs resolved_mode and account_plan_type, token_data.rs, and
|
|
3
|
+
* manager/workspace_switching.rs selected_workspace_tokens define these projections.
|
|
4
|
+
* Native code itself decodes these saved claims without signature verification. We use them
|
|
5
|
+
* only to refuse unproven policy portability; destination sign-in remains independently required. */
|
|
6
|
+
import type { SourceNativeAccount } from "./source-snapshot-types.js";
|
|
7
|
+
/** Consumes a bounded private buffer. Returns fixed nonsecret labels only: no claims, IDs, email,
|
|
8
|
+
* expiry, token hashes or raw values. Unknown/refresh-due state cannot establish portability. */
|
|
9
|
+
export declare function sourceAccountMetadata(bytes: Uint8Array | null, now?: number): SourceNativeAccount;
|
|
10
|
+
export declare function sourceAccountMetadataValid(value: unknown): value is SourceNativeAccount;
|
|
11
|
+
/** Boolean-only private check, including escaped/percent/base64/hex spellings used by the existing
|
|
12
|
+
* held-secret scanner. The credential strings and matcher exist only for this bounded call. */
|
|
13
|
+
export declare function sourceAccountContainsSecret(bytes: Uint8Array, contents: Iterable<string>): boolean;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { valueMatcher } from "../learn/secrets.js";
|
|
2
|
+
import { keyShaped } from "../secret-name.js";
|
|
3
|
+
const object = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
4
|
+
const unknown = () => ({ source: "codex-auth-file", mode: "unknown", plan: "unknown" });
|
|
5
|
+
const ordinary = new Set(["free", "go", "plus", "pro", "prolite", "promax"]);
|
|
6
|
+
const managed = new Set(["team", "self_serve_business_prolite", "self_serve_business_usage_based", "business", "ent26", "enterprise_cbp_automation", "enterprise_cbp_usage_based", "enterprise", "edu", "edu_plus", "edu_pro", "sci", "sci_plus"]);
|
|
7
|
+
function claims(value) {
|
|
8
|
+
if (typeof value !== "string" || value.length > 32_768)
|
|
9
|
+
return;
|
|
10
|
+
const parts = value.split(".");
|
|
11
|
+
if (parts.length !== 3 || parts.some(part => !part || !/^[A-Za-z0-9_-]+$/.test(part)))
|
|
12
|
+
return;
|
|
13
|
+
const payload = Buffer.from(parts[1], "base64url");
|
|
14
|
+
if (payload.toString("base64url") !== parts[1])
|
|
15
|
+
return;
|
|
16
|
+
try {
|
|
17
|
+
const parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(payload));
|
|
18
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
19
|
+
return;
|
|
20
|
+
const value = parsed, auth = value["https://api.openai.com/auth"], profile = value["https://api.openai.com/profile"];
|
|
21
|
+
const optionalText = (value) => value == null || typeof value === "string";
|
|
22
|
+
if (!optionalText(value.email) || profile != null && (typeof profile !== "object" || Array.isArray(profile) || !optionalText(profile.email))
|
|
23
|
+
|| auth != null && (typeof auth !== "object" || Array.isArray(auth)
|
|
24
|
+
|| ["chatgpt_plan_type", "chatgpt_user_id", "user_id", "chatgpt_account_id"].some(key => !optionalText(auth[key]))
|
|
25
|
+
|| auth.chatgpt_account_is_fedramp !== undefined && typeof auth.chatgpt_account_is_fedramp !== "boolean"))
|
|
26
|
+
return;
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
payload.fill(0);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Consumes a bounded private buffer. Returns fixed nonsecret labels only: no claims, IDs, email,
|
|
37
|
+
* expiry, token hashes or raw values. Unknown/refresh-due state cannot establish portability. */
|
|
38
|
+
export function sourceAccountMetadata(bytes, now = Date.now()) {
|
|
39
|
+
if (bytes === null)
|
|
40
|
+
return { source: "codex-auth-file", mode: "none", plan: null };
|
|
41
|
+
if (bytes.length > 65_536)
|
|
42
|
+
return unknown();
|
|
43
|
+
try {
|
|
44
|
+
const auth = object(JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes)));
|
|
45
|
+
const mode = auth.auth_mode ?? (auth.personal_access_token != null ? "personalAccessToken"
|
|
46
|
+
: auth.bedrock_api_key != null ? "bedrockApiKey" : auth.bedrock_access_keys != null ? "bedrockAccessKeys"
|
|
47
|
+
: auth.OPENAI_API_KEY != null ? "apikey" : "chatgpt");
|
|
48
|
+
if (mode === "apikey")
|
|
49
|
+
return typeof auth.OPENAI_API_KEY === "string" && auth.OPENAI_API_KEY.trim()
|
|
50
|
+
? { source: "codex-auth-file", mode: "apikey", plan: null } : unknown();
|
|
51
|
+
// External, keyring and host-owned credentials cannot be established by this file projection.
|
|
52
|
+
if (mode !== "chatgpt")
|
|
53
|
+
return unknown();
|
|
54
|
+
const tokens = object(auth.tokens), id = claims(tokens.id_token), access = claims(tokens.access_token);
|
|
55
|
+
if (!id || !access || typeof tokens.refresh_token !== "string" || !tokens.refresh_token
|
|
56
|
+
|| typeof auth.last_refresh !== "string" || !/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d+)?(?:Z|[+-]\d\d:\d\d)$/.test(auth.last_refresh) || !Number.isFinite(Date.parse(auth.last_refresh))
|
|
57
|
+
|| tokens.account_id != null && typeof tokens.account_id !== "string"
|
|
58
|
+
|| !Number.isSafeInteger(access.exp) || access.exp * 1000 > 8.64e15 || access.exp * 1000 <= now + 5 * 60_000)
|
|
59
|
+
return unknown();
|
|
60
|
+
let selected = object(id["https://api.openai.com/auth"]);
|
|
61
|
+
const current = object(access["https://api.openai.com/auth"]), account = tokens.account_id ?? null;
|
|
62
|
+
// The retained ID token may describe a previous workspace. Match native's account/user
|
|
63
|
+
// equality before taking the current access-token plan; an unresolved mismatch stays blocked.
|
|
64
|
+
if (account !== (selected.chatgpt_account_id ?? null)) {
|
|
65
|
+
if (account !== (current.chatgpt_account_id ?? null)
|
|
66
|
+
|| (current.chatgpt_user_id ?? current.user_id ?? null) !== (selected.chatgpt_user_id ?? selected.user_id ?? null))
|
|
67
|
+
return unknown();
|
|
68
|
+
selected = current;
|
|
69
|
+
}
|
|
70
|
+
const plan = selected.chatgpt_plan_type;
|
|
71
|
+
if (selected.chatgpt_account_is_fedramp === true)
|
|
72
|
+
return { source: "codex-auth-file", mode: "chatgpt", plan: "managed" };
|
|
73
|
+
return { source: "codex-auth-file", mode: "chatgpt", plan: ordinary.has(plan) ? "ordinary" : managed.has(plan) ? "managed" : "unknown" };
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return unknown();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export function sourceAccountMetadataValid(value) {
|
|
80
|
+
const v = object(value);
|
|
81
|
+
return Object.keys(v).length === 3 && v.source === "codex-auth-file"
|
|
82
|
+
&& (["none", "apikey"].includes(v.mode) ? v.plan === null : v.mode === "chatgpt" ? ["ordinary", "managed", "unknown"].includes(v.plan) : v.mode === "unknown" && v.plan === "unknown");
|
|
83
|
+
}
|
|
84
|
+
/** Boolean-only private check, including escaped/percent/base64/hex spellings used by the existing
|
|
85
|
+
* held-secret scanner. The credential strings and matcher exist only for this bounded call. */
|
|
86
|
+
export function sourceAccountContainsSecret(bytes, contents) {
|
|
87
|
+
if (bytes.length > 65_536)
|
|
88
|
+
return false; // No bytes of an oversized auth file are read.
|
|
89
|
+
const values = [];
|
|
90
|
+
try {
|
|
91
|
+
const pending = [JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes))];
|
|
92
|
+
for (let count = 0; pending.length; count++) {
|
|
93
|
+
if (count > 10_000)
|
|
94
|
+
return true;
|
|
95
|
+
const value = pending.pop();
|
|
96
|
+
if (!value || typeof value !== "object")
|
|
97
|
+
continue;
|
|
98
|
+
for (const [key, child] of Object.entries(value)) {
|
|
99
|
+
if (typeof child === "string" && child && keyShaped(key))
|
|
100
|
+
values.push(child);
|
|
101
|
+
else if (child && typeof child === "object")
|
|
102
|
+
pending.push(child);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const matches = valueMatcher(values);
|
|
106
|
+
for (const content of contents)
|
|
107
|
+
if (values.some(value => content.includes(value) || content.includes(JSON.stringify(value).slice(1, -1))) || matches(content))
|
|
108
|
+
return true;
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return false;
|
|
113
|
+
} // Malformed auth already makes the snapshot incomplete.
|
|
114
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/** Pure verifier for the sole source-to-destination rewrite: remove exact installer-owned capture handlers.
|
|
2
|
+
* It never treats arbitrary hooks, a command substring, or a matching filename as owned AgentRun behavior. */
|
|
3
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
4
|
+
import { isAbsolute, basename } from 'node:path';
|
|
5
|
+
import { NATIVE_RUNTIME_FACTS } from "./runtimes.js";
|
|
6
|
+
const object = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
7
|
+
const quote = (value) => `'${value.replaceAll("'", "'\"'\"'")}'`;
|
|
8
|
+
function argumentsOf(line) {
|
|
9
|
+
const values = [];
|
|
10
|
+
let offset = 0;
|
|
11
|
+
while (offset < line.length) {
|
|
12
|
+
if (line[offset++] !== "'")
|
|
13
|
+
return;
|
|
14
|
+
let value = '', closed = false;
|
|
15
|
+
while (offset < line.length) {
|
|
16
|
+
if (line.startsWith("'\"'\"'", offset)) {
|
|
17
|
+
value += "'";
|
|
18
|
+
offset += 5;
|
|
19
|
+
}
|
|
20
|
+
else if (line[offset] === "'") {
|
|
21
|
+
offset++;
|
|
22
|
+
closed = true;
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
else
|
|
26
|
+
value += line[offset++];
|
|
27
|
+
}
|
|
28
|
+
if (!closed)
|
|
29
|
+
return;
|
|
30
|
+
values.push(value);
|
|
31
|
+
if (offset < line.length && line[offset++] !== ' ')
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
return values.map(quote).join(' ') === line ? values : undefined;
|
|
35
|
+
}
|
|
36
|
+
const failure = () => { throw new Error('Source hooks are not an unchanged, complete AgentRun capture installation.'); };
|
|
37
|
+
export function removeOwnedCaptureHooks(original, receiptBytes, source) {
|
|
38
|
+
let config, receipt;
|
|
39
|
+
try {
|
|
40
|
+
const decoder = new TextDecoder('utf-8', { fatal: true });
|
|
41
|
+
config = JSON.parse(decoder.decode(original));
|
|
42
|
+
receipt = JSON.parse(decoder.decode(receiptBytes));
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return failure();
|
|
46
|
+
}
|
|
47
|
+
const events = NATIVE_RUNTIME_FACTS[source.runtime].protocol === 'codex-json' ? ['UserPromptSubmit', 'Stop', 'Interrupt', 'SessionEnd'] : ['UserPromptSubmit', 'Stop', 'StopFailure', 'SessionEnd'];
|
|
48
|
+
if (!object(config) || !object(config.hooks) || config.disableAllHooks === true || !object(receipt)
|
|
49
|
+
|| ![1, 2].includes(receipt.version) || receipt.runtime !== source.runtime || receipt.project !== source.project
|
|
50
|
+
|| typeof receipt.dataDir !== 'string' || !isAbsolute(receipt.dataDir) || receipt.dataDir === source.project || receipt.dataDir.startsWith(source.project + '/')
|
|
51
|
+
|| typeof receipt.url !== 'string' || typeof receipt.hadHooks !== 'boolean' || !Array.isArray(receipt.createdEvents)
|
|
52
|
+
|| receipt.createdEvents.some((event) => typeof event !== 'string' || !events.includes(event))
|
|
53
|
+
|| !object(receipt.handlers) || !isDeepStrictEqual(Object.keys(receipt.handlers).sort(), [...events].sort()) || receipt.legacy !== undefined)
|
|
54
|
+
return failure();
|
|
55
|
+
let url;
|
|
56
|
+
try {
|
|
57
|
+
url = new URL(receipt.url);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return failure();
|
|
61
|
+
}
|
|
62
|
+
if (!['http:', 'https:'].includes(url.protocol) || !['localhost', '127.0.0.1', '[::1]'].includes(url.hostname)
|
|
63
|
+
|| url.username || url.password || url.search || url.hash || url.pathname !== '/')
|
|
64
|
+
return failure();
|
|
65
|
+
const configRoot = receipt.version === 1 ? source.project : receipt.configRoot;
|
|
66
|
+
if (typeof configRoot !== 'string' || !isAbsolute(configRoot) || receipt.version === 2 && (NATIVE_RUNTIME_FACTS[source.runtime].protocol !== 'codex-json' || receipt.format !== 'codex-shared-json' || configRoot === source.project))
|
|
67
|
+
return failure();
|
|
68
|
+
for (const event of events) {
|
|
69
|
+
const owned = receipt.handlers[event], groups = config.hooks[event];
|
|
70
|
+
if (!object(owned) || !isDeepStrictEqual(Object.keys(owned).sort(), ['command', 'timeout', 'type']) || owned.type !== 'command' || owned.timeout !== 5 || typeof owned.command !== 'string' || !Array.isArray(groups))
|
|
71
|
+
return failure();
|
|
72
|
+
const args = argumentsOf(owned.command), suffix = ['learning', 'hook', '--runtime', source.runtime, '--project', source.project, '--data', receipt.dataDir, '--url', receipt.url];
|
|
73
|
+
if (!args || args.length !== suffix.length + 2 || !isAbsolute(args[0]) || basename(args[0]) !== 'node' || !isAbsolute(args[1])
|
|
74
|
+
|| !args[1].endsWith('/cli-learning/entry.js') || !isDeepStrictEqual(args.slice(2), suffix))
|
|
75
|
+
return failure();
|
|
76
|
+
let found = false;
|
|
77
|
+
const kept = [];
|
|
78
|
+
for (const group of groups) {
|
|
79
|
+
if (!object(group) || !Array.isArray(group.hooks))
|
|
80
|
+
return failure();
|
|
81
|
+
const ownedGroup = group.matcher === undefined || group.matcher === '' || group.matcher === '*';
|
|
82
|
+
const hooks = group.hooks.filter((handler) => {
|
|
83
|
+
if (ownedGroup && isDeepStrictEqual(handler, owned)) {
|
|
84
|
+
found = true;
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
});
|
|
89
|
+
if (hooks.length)
|
|
90
|
+
kept.push({ ...group, hooks });
|
|
91
|
+
}
|
|
92
|
+
if (!found)
|
|
93
|
+
return failure();
|
|
94
|
+
if (kept.length)
|
|
95
|
+
config.hooks[event] = kept;
|
|
96
|
+
else
|
|
97
|
+
delete config.hooks[event];
|
|
98
|
+
}
|
|
99
|
+
if (!Object.keys(config.hooks).length)
|
|
100
|
+
delete config.hooks;
|
|
101
|
+
return { bytes: Buffer.from(JSON.stringify(config, null, 2) + '\n'), configRoot };
|
|
102
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Native MCP selection without contacting a server or opening credentials. Codex 0.171.0's
|
|
2
|
+
* ToolFilter uses exact names. Claude 2.1.322's agent selectors use qualified mcp__ names;
|
|
3
|
+
* keeping the whole name avoids confusing a server containing __ with another server's tool. */
|
|
4
|
+
import type { SourceMcpSelection } from "./source-snapshot-types.js";
|
|
5
|
+
export declare const claudeMcpSelector: (value: unknown) => value is string;
|
|
6
|
+
export declare function sourceMcpSelection(value: unknown): value is SourceMcpSelection;
|
|
7
|
+
export declare function selectedMcpTool(selection: SourceMcpSelection, server: string, tool: string): boolean;
|
|
8
|
+
/** Whether a server can contribute a selected tool, before its destination catalog is opened. */
|
|
9
|
+
export declare function selectedMcpServer(selection: SourceMcpSelection, server: string): boolean;
|
|
10
|
+
/** Exact, positively selected names must exist. Wildcards mean the available pool, possibly empty;
|
|
11
|
+
* a deny always wins, including an exact name present in both lists. */
|
|
12
|
+
export declare function missingMcpTools(selection: SourceMcpSelection, server: string, available: readonly string[]): string[];
|
|
13
|
+
export declare const nativeToolNames: (value: unknown) => string[] | undefined;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const text = (value) => typeof value === "string" && value.length > 0 && value.length <= 512 && !/[\s\x00-\x1f\x7f]/.test(value);
|
|
2
|
+
export const claudeMcpSelector = (value) => text(value) && value.startsWith("mcp__") && value.length > 5 && !/[()\[\]{}?\\]/.test(value);
|
|
3
|
+
export function sourceMcpSelection(value) {
|
|
4
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
5
|
+
return false;
|
|
6
|
+
const v = value;
|
|
7
|
+
if (Object.keys(v).some(key => !["dialect", "allow", "deny"].includes(key)) || !["exact", "claude"].includes(v.dialect))
|
|
8
|
+
return false;
|
|
9
|
+
const names = (items) => Array.isArray(items) && items.length <= 1000 && items.every(v.dialect === "claude" ? claudeMcpSelector : text) && new Set(items).size === items.length;
|
|
10
|
+
return (v.allow === null || names(v.allow)) && names(v.deny);
|
|
11
|
+
}
|
|
12
|
+
/** Literal chunks and * only. Each search advances through the name; no regexp backtracking on an upstream name. */
|
|
13
|
+
const glob = (pattern, value) => {
|
|
14
|
+
const parts = pattern.split("*");
|
|
15
|
+
if (parts.length === 1)
|
|
16
|
+
return pattern === value;
|
|
17
|
+
const first = parts[0], last = parts.at(-1);
|
|
18
|
+
if (!value.startsWith(first) || !value.endsWith(last))
|
|
19
|
+
return false;
|
|
20
|
+
const end = value.length - last.length;
|
|
21
|
+
let at = first.length;
|
|
22
|
+
for (const part of parts.slice(1, -1)) {
|
|
23
|
+
if (!part)
|
|
24
|
+
continue;
|
|
25
|
+
const found = value.indexOf(part, at);
|
|
26
|
+
if (found < 0)
|
|
27
|
+
return false;
|
|
28
|
+
at = found + part.length;
|
|
29
|
+
if (at > end)
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return at <= end;
|
|
33
|
+
};
|
|
34
|
+
function claudeMatches(pattern, qualified, deny = false) {
|
|
35
|
+
if (glob(pattern, qualified))
|
|
36
|
+
return true;
|
|
37
|
+
// A bare server deny is a prefix in Claude; a server named reports__v2 is consequently
|
|
38
|
+
// excluded by mcp__reports as documented. Allow entries do not get this implicit wildcard.
|
|
39
|
+
return deny && !pattern.includes("*") && !pattern.slice(5).includes("__") && qualified.startsWith(`${pattern}__`);
|
|
40
|
+
}
|
|
41
|
+
export function selectedMcpTool(selection, server, tool) {
|
|
42
|
+
if (selection.dialect === "exact")
|
|
43
|
+
return (selection.allow === null || selection.allow.includes(tool)) && !selection.deny.includes(tool);
|
|
44
|
+
const qualified = `mcp__${server}__${tool}`;
|
|
45
|
+
return (selection.allow === null || selection.allow.some(pattern => claudeMatches(pattern, qualified))) && !selection.deny.some(pattern => claudeMatches(pattern, qualified, true));
|
|
46
|
+
}
|
|
47
|
+
/** Whether a server can contribute a selected tool, before its destination catalog is opened. */
|
|
48
|
+
export function selectedMcpServer(selection, server) {
|
|
49
|
+
if (selection.dialect === "exact")
|
|
50
|
+
return selection.allow === null || selection.allow.some(name => !selection.deny.includes(name));
|
|
51
|
+
const prefix = `mcp__${server}__`;
|
|
52
|
+
if (selection.deny.some(pattern => pattern === "mcp__*" || pattern === `${prefix}*`
|
|
53
|
+
|| !pattern.includes("*") && !pattern.slice(5).includes("__") && prefix.startsWith(`${pattern}__`)))
|
|
54
|
+
return false;
|
|
55
|
+
return selection.allow === null || selection.allow.some(pattern => {
|
|
56
|
+
const fixed = pattern.split("*", 1)[0];
|
|
57
|
+
return fixed.startsWith(prefix) || pattern.includes("*") && prefix.startsWith(fixed);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/** Exact, positively selected names must exist. Wildcards mean the available pool, possibly empty;
|
|
61
|
+
* a deny always wins, including an exact name present in both lists. */
|
|
62
|
+
export function missingMcpTools(selection, server, available) {
|
|
63
|
+
if (selection.allow === null)
|
|
64
|
+
return [];
|
|
65
|
+
if (selection.dialect === "exact")
|
|
66
|
+
return selection.allow.filter(name => !selection.deny.includes(name) && !available.includes(name));
|
|
67
|
+
const prefix = `mcp__${server}__`;
|
|
68
|
+
return selection.allow.filter(name => !name.includes("*") && name.startsWith(prefix)
|
|
69
|
+
&& !selection.deny.some(pattern => claudeMatches(pattern, name, true)) && !available.includes(name.slice(prefix.length)));
|
|
70
|
+
}
|
|
71
|
+
export const nativeToolNames = (value) => Array.isArray(value) && value.every(item => typeof item === "string") ? value
|
|
72
|
+
: typeof value === "string" ? value.split(/[,\s]+/).filter(Boolean) : undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { NativeRuntime } from "./types.js";
|
|
2
|
+
import { type SourceNativeTools, type SourceSnapshotBlocker } from "./source-snapshot-types.js";
|
|
3
|
+
/** Only these non-credential environment selectors affect the supported snapshot resolver. Consent hashes
|
|
4
|
+
* their exact source values; neither the consent wire nor a saved grant contains the values themselves. */
|
|
5
|
+
export declare const SOURCE_NATIVE_ENV_KEYS: readonly ["HOME", "PATH", "CODEX_HOME", "CLAUDE_CONFIG_DIR", "ANTHROPIC_MODEL", "ANTHROPIC_DEFAULT_MODEL", "ANTHROPIC_DEFAULT_OPUS_MODEL", "ANTHROPIC_DEFAULT_SONNET_MODEL", "ANTHROPIC_DEFAULT_HAIKU_MODEL", "ANTHROPIC_BASE_URL", "OPENAI_BASE_URL", "CLAUDE_CODE_USE_BEDROCK", "CLAUDE_CODE_USE_VERTEX", "CLAUDE_CODE_USE_FOUNDRY", "CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST", "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS", "CLAUDE_CODE_SUBAGENT_MODEL", "CLAUDE_CODE_ENABLE_TASKS"];
|
|
6
|
+
export declare function sourceNativeEnvironmentFacts(environment: Readonly<Record<string, string | undefined>>): Record<string, string | null>;
|
|
7
|
+
export declare const SOURCE_CODEX_FEATURES: readonly ["shell_tool", "view_image", "multi_agent", "apps", "plugins", "image_generation", "tool_suggest", "goals", "memories", "current_time_reminder", "sleep_tool", "token_budget"];
|
|
8
|
+
export declare function sourceNativeTools(input: {
|
|
9
|
+
runtime: NativeRuntime;
|
|
10
|
+
version: string | null;
|
|
11
|
+
model: string | null;
|
|
12
|
+
config: Record<string, any>;
|
|
13
|
+
permissions: Record<string, unknown>;
|
|
14
|
+
mcp: boolean;
|
|
15
|
+
modelCache?: unknown;
|
|
16
|
+
}): {
|
|
17
|
+
tools: SourceNativeTools;
|
|
18
|
+
blockers: SourceSnapshotBlocker[];
|
|
19
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/** Read-only native capability evidence. This resolver never starts a session, runs hooks or connects MCP.
|
|
2
|
+
* Codex facts: openai/codex rust-v0.171.0, core/src/tools/spec_plan.rs, features/src/lib.rs,
|
|
3
|
+
* models-manager/models.json and app-server/src/extensions.rs. Claude 2.1.322's explicit agent tool
|
|
4
|
+
* list is documented in code.claude.com/docs/en/{sub-agents,tools-reference,cli-reference}.
|
|
5
|
+
* Default/account catalogs remain prerequisites unless their enabled closure is established. */
|
|
6
|
+
import { NATIVE_RUNTIME_FACTS } from "./runtimes.js";
|
|
7
|
+
import { claudeMcpSelector, nativeToolNames } from "./source-mcp-selection.js";
|
|
8
|
+
import { SOURCE_NATIVE_CAPABILITIES } from "./source-snapshot-types.js";
|
|
9
|
+
/** Only these non-credential environment selectors affect the supported snapshot resolver. Consent hashes
|
|
10
|
+
* their exact source values; neither the consent wire nor a saved grant contains the values themselves. */
|
|
11
|
+
export const SOURCE_NATIVE_ENV_KEYS = ["HOME", "PATH", "CODEX_HOME", "CLAUDE_CONFIG_DIR", "ANTHROPIC_MODEL", "ANTHROPIC_DEFAULT_MODEL", "ANTHROPIC_DEFAULT_OPUS_MODEL", "ANTHROPIC_DEFAULT_SONNET_MODEL", "ANTHROPIC_DEFAULT_HAIKU_MODEL", "ANTHROPIC_BASE_URL", "OPENAI_BASE_URL", "CLAUDE_CODE_USE_BEDROCK", "CLAUDE_CODE_USE_VERTEX", "CLAUDE_CODE_USE_FOUNDRY", "CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST", "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS", "CLAUDE_CODE_SUBAGENT_MODEL", "CLAUDE_CODE_ENABLE_TASKS"];
|
|
12
|
+
export function sourceNativeEnvironmentFacts(environment) {
|
|
13
|
+
return Object.fromEntries(SOURCE_NATIVE_ENV_KEYS.map(name => [name, environment[name] ?? null]));
|
|
14
|
+
}
|
|
15
|
+
const object = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
16
|
+
const CLAUDE_TOOLS = {
|
|
17
|
+
Bash: ["shell", "file_read", "file_write", "file_edit", "file_search"], Read: ["file_read", "image_read"], Write: ["file_write"], Edit: ["file_edit"], Glob: ["file_search"], Grep: ["file_search"],
|
|
18
|
+
WebSearch: ["web_search"], WebFetch: ["web_fetch"], Agent: ["subagents"], Task: ["subagents"], NotebookEdit: ["notebook_edit"],
|
|
19
|
+
AskUserQuestion: ["user_input"], EnterPlanMode: ["planning"], ExitPlanMode: ["planning"], EndConversation: ["session_end"],
|
|
20
|
+
Skill: ["skills"], ListMcpResourcesTool: ["mcp_resources"], ReadMcpResourceTool: ["mcp_resources"],
|
|
21
|
+
TaskCreate: ["task_tracking"], TaskUpdate: ["task_tracking"], TaskGet: ["task_tracking"], TaskList: ["task_tracking"], TaskStop: ["task_tracking"],
|
|
22
|
+
EnterWorktree: ["worktree"], ExitWorktree: ["worktree"], SendMessage: ["session_messaging"], ListAgents: ["session_messaging"],
|
|
23
|
+
PushNotification: ["notifications"], SendFeedback: ["feedback"], Artifact: ["artifact_publish"], RemoteTrigger: ["remote_tasks"], SendUserFile: ["remote_files"],
|
|
24
|
+
};
|
|
25
|
+
const CODEX_MODELS = Object.fromEntries([
|
|
26
|
+
...["gpt-6.2-sol", "gpt-6.2-astra"].map(name => [name, { agent: "v2", clock: true, async: ["request_user_input_async", "send_message_to_user_async"], lite: true, extra: ["literature_search_query"] }]),
|
|
27
|
+
...["gpt-6-astra", "gpt-6.1-sol", "gpt-6.1-terra", "gpt-6-sol", "gpt-6-luna"].map(name => [name, { agent: "v2", clock: true, async: ["send_user_message_async"], lite: true, extra: [] }]),
|
|
28
|
+
...["gpt-5.6-sol", "gpt-5.6-terra"].map(name => [name, { agent: "v2", clock: false, async: [], lite: true, extra: [] }]),
|
|
29
|
+
["gpt-5.6-luna", { agent: "v1", clock: false, async: [], lite: true, extra: [] }],
|
|
30
|
+
["gpt-5.5", { agent: null, clock: false, async: [], lite: false, extra: [] }],
|
|
31
|
+
]);
|
|
32
|
+
export const SOURCE_CODEX_FEATURES = ["shell_tool", "view_image", "multi_agent", "apps", "plugins", "image_generation", "tool_suggest", "goals", "memories", "current_time_reminder", "sleep_tool", "token_budget"];
|
|
33
|
+
export function sourceNativeTools(input) {
|
|
34
|
+
const enabled = new Set(), disabled = new Set(), blockers = [];
|
|
35
|
+
const block = (code, message) => blockers.push({ code, message, path: "configuration/native_tools" });
|
|
36
|
+
const set = (capability, on) => (on ? enabled : disabled).add(capability);
|
|
37
|
+
const tools = { version: input.version, complete: false, source: "versioned-runtime", capabilities: [], disabled: [] };
|
|
38
|
+
if (NATIVE_RUNTIME_FACTS[input.runtime].protocol === "codex-json") {
|
|
39
|
+
if (input.version !== "0.171.0")
|
|
40
|
+
block("native_version", "This Codex version needs a verified native capability resolver before Move.");
|
|
41
|
+
const features = object(input.config.features), on = (name, fallback) => typeof features[name] === "boolean" ? features[name] : fallback;
|
|
42
|
+
const model = input.model ? CODEX_MODELS[input.model] : undefined;
|
|
43
|
+
if (!model)
|
|
44
|
+
block("native_model_tools", "Choose an exact source model with verified builtin tool metadata before Move.");
|
|
45
|
+
// A cache with different tool facts could be active under the source account. Never infer its auth identity.
|
|
46
|
+
const cache = object(input.modelCache), cached = Array.isArray(cache.models) ? cache.models.find((row) => row?.slug === input.model) : undefined;
|
|
47
|
+
if (cache.client_version === input.version && cache.identity && cached && model) {
|
|
48
|
+
const expectedExtras = [...model.async, ...(model.clock ? ["clock"] : [])];
|
|
49
|
+
const actualExtras = (Array.isArray(cached.experimental_supported_tools) ? cached.experimental_supported_tools : []).filter((name) => name !== "multi_agent_v2_in_code_mode").sort();
|
|
50
|
+
if (cached.shell_type !== "shell_command" || cached.apply_patch_tool_type !== "freeform" || (cached.multi_agent_version ?? null) !== model.agent || cached.use_responses_lite !== model.lite || (cached.tool_mode ?? null) !== (model.lite ? "code_mode_only" : null) || JSON.stringify(actualExtras) !== JSON.stringify([...expectedExtras, ...model.extra].sort()))
|
|
51
|
+
block("native_model_catalog", "The source model cache has different builtin tools; resolve its active catalog before Move.");
|
|
52
|
+
}
|
|
53
|
+
set("shell", on("shell_tool", true));
|
|
54
|
+
for (const name of ["file_read", "file_write", "file_edit", "file_search"])
|
|
55
|
+
set(name, on("shell_tool", true) || name === "file_edit");
|
|
56
|
+
set("image_read", on("view_image", true));
|
|
57
|
+
set("subagents", object(input.config.agents).enabled !== false && (model?.agent !== null && model?.agent !== undefined || on("multi_agent", true)));
|
|
58
|
+
set("web_search", input.permissions.web_search !== "disabled");
|
|
59
|
+
set("mcp_resources", input.mcp || model?.lite === true);
|
|
60
|
+
set("user_input", object(object(input.config.tools).experimental_request_user_input).enabled !== false || model?.async.includes("send_message_to_user_async") === true);
|
|
61
|
+
set("planning", object(object(input.config.tools).update_plan).enabled === true);
|
|
62
|
+
set("clock", on("current_time_reminder", false) || model?.clock === true);
|
|
63
|
+
set("sleep", on("sleep_tool", true) && enabled.has("clock"));
|
|
64
|
+
set("task_tracking", on("goals", true));
|
|
65
|
+
set("context_management", on("token_budget", false));
|
|
66
|
+
set("skills", true);
|
|
67
|
+
for (const [name, capability] of [["apps", "apps"], ["plugins", "plugins"], ["image_generation", "image_generate"]]) {
|
|
68
|
+
set(capability, on(name, true));
|
|
69
|
+
if (on(name, true))
|
|
70
|
+
block(`native_${name}`, "An enabled source account integration needs its exact destination capability and account before Move.");
|
|
71
|
+
}
|
|
72
|
+
if (object(object(input.config.cloud).skills).enabled !== false)
|
|
73
|
+
block("native_cloud_skills", "Source account skills need a verified export or explicit source disable before Move.");
|
|
74
|
+
if (on("memories", false))
|
|
75
|
+
block("native_memory", "Source native memory tools need an explicit destination equivalent before Move.");
|
|
76
|
+
if (model?.extra.length && enabled.has("web_search"))
|
|
77
|
+
block("native_model_tools", "This model enables additional native tools without a verified destination equivalent.");
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
if (input.version !== "2.1.322")
|
|
81
|
+
block("native_version", "This Claude Code version needs a verified native capability resolver before Move.");
|
|
82
|
+
const selected = input.permissions.tools, denied = input.permissions.disallowedTools;
|
|
83
|
+
const list = nativeToolNames(selected), exclusions = nativeToolNames(denied) ?? [];
|
|
84
|
+
if (!list || list.some(name => !Object.hasOwn(CLAUDE_TOOLS, name) && !claudeMcpSelector(name)))
|
|
85
|
+
block("native_tool_list", "Select an explicit supported Claude agent tool list; default and account tools are not yet fully resolved.");
|
|
86
|
+
if (denied !== undefined && !nativeToolNames(denied) || exclusions.some(name => !Object.hasOwn(CLAUDE_TOOLS, name) && !claudeMcpSelector(name)))
|
|
87
|
+
block("native_tool_restriction", "A source tool restriction needs exact native tool resolution before Move.");
|
|
88
|
+
for (const name of list ?? [])
|
|
89
|
+
if (typeof name === "string" && !exclusions.includes(name))
|
|
90
|
+
for (const capability of CLAUDE_TOOLS[name] ?? [])
|
|
91
|
+
enabled.add(capability);
|
|
92
|
+
// Claude 2.1.322 keeps EndConversation even when an explicit nonempty tool list omits it.
|
|
93
|
+
if (list?.length || input.mcp)
|
|
94
|
+
enabled.add("session_end");
|
|
95
|
+
for (const capability of SOURCE_NATIVE_CAPABILITIES)
|
|
96
|
+
if (!enabled.has(capability))
|
|
97
|
+
disabled.add(capability);
|
|
98
|
+
}
|
|
99
|
+
tools.capabilities = [...enabled].sort();
|
|
100
|
+
tools.disabled = [...disabled].filter(name => !enabled.has(name)).sort();
|
|
101
|
+
tools.complete = blockers.length === 0;
|
|
102
|
+
return { tools, blockers };
|
|
103
|
+
}
|