@caupulican/pi-adaptative 0.90.0 → 0.90.4
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 +43 -0
- package/dist/core/agent-session-contracts.d.ts +2 -0
- package/dist/core/agent-session-contracts.d.ts.map +1 -1
- package/dist/core/agent-session-contracts.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +5 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts +10 -1
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js +24 -2
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +9 -1
- package/dist/core/autonomy/lane-tracker.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +1 -3
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/compaction-controller.d.ts.map +1 -1
- package/dist/core/compaction-controller.js +0 -1
- package/dist/core/compaction-controller.js.map +1 -1
- package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -1
- package/dist/core/delegation/managed-lane-controller.js +5 -1
- package/dist/core/delegation/managed-lane-controller.js.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts +8 -1
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.js +94 -36
- package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-agent-control.d.ts +1 -0
- package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control.js.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.js +7 -2
- package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.js +26 -3
- package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts +7 -4
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js +110 -27
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/delegation/worker-fleet-limits.d.ts +9 -2
- package/dist/core/delegation/worker-fleet-limits.d.ts.map +1 -1
- package/dist/core/delegation/worker-fleet-limits.js +39 -3
- package/dist/core/delegation/worker-fleet-limits.js.map +1 -1
- package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -1
- package/dist/core/delegation/worker-lane-projection.js +4 -0
- package/dist/core/delegation/worker-lane-projection.js.map +1 -1
- package/dist/core/delegation/worker-lease-heartbeat.d.ts +16 -0
- package/dist/core/delegation/worker-lease-heartbeat.d.ts.map +1 -0
- package/dist/core/delegation/worker-lease-heartbeat.js +37 -0
- package/dist/core/delegation/worker-lease-heartbeat.js.map +1 -0
- package/dist/core/delegation/worker-lifecycle.d.ts +1 -0
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
- package/dist/core/delegation/worker-lifecycle.js +6 -0
- package/dist/core/delegation/worker-lifecycle.js.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.js +2 -1
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-runner.js +2 -2
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-terminal-handoff-coordinator.d.ts +1 -0
- package/dist/core/delegation/worker-terminal-handoff-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-terminal-handoff-coordinator.js +1 -0
- package/dist/core/delegation/worker-terminal-handoff-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-tree-budget-coordinator.d.ts +4 -2
- package/dist/core/delegation/worker-tree-budget-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-tree-budget-coordinator.js +10 -2
- package/dist/core/delegation/worker-tree-budget-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.d.ts +14 -0
- package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.js +121 -33
- package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
- package/dist/core/foreground-terminal-handoff-controller.d.ts +5 -0
- package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -1
- package/dist/core/foreground-terminal-handoff-controller.js +28 -12
- package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
- package/dist/core/goals/goal-session-controller.d.ts +6 -0
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-session-controller.js +16 -13
- package/dist/core/goals/goal-session-controller.js.map +1 -1
- package/dist/core/orchestration/capability-gateway.d.ts +2 -1
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
- package/dist/core/orchestration/capability-gateway.js +9 -2
- package/dist/core/orchestration/capability-gateway.js.map +1 -1
- package/dist/core/orchestration/contracts.d.ts +16 -1
- package/dist/core/orchestration/contracts.d.ts.map +1 -1
- package/dist/core/orchestration/contracts.js +5 -0
- package/dist/core/orchestration/contracts.js.map +1 -1
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
- package/dist/core/orchestration/profile-registry.js +38 -1
- package/dist/core/orchestration/profile-registry.js.map +1 -1
- package/dist/core/orchestration/risk-budget.d.ts +10 -0
- package/dist/core/orchestration/risk-budget.d.ts.map +1 -1
- package/dist/core/orchestration/risk-budget.js +14 -0
- package/dist/core/orchestration/risk-budget.js.map +1 -1
- package/dist/core/orchestration/task-runtime-reducer.d.ts +1 -0
- package/dist/core/orchestration/task-runtime-reducer.d.ts.map +1 -1
- package/dist/core/orchestration/task-runtime-reducer.js +34 -0
- package/dist/core/orchestration/task-runtime-reducer.js.map +1 -1
- package/dist/core/orchestration/task-runtime.d.ts +1 -0
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
- package/dist/core/orchestration/task-runtime.js +24 -1
- package/dist/core/orchestration/task-runtime.js.map +1 -1
- package/dist/core/provider-prompt-contracts.d.ts.map +1 -1
- package/dist/core/provider-prompt-contracts.js +2 -1
- package/dist/core/provider-prompt-contracts.js.map +1 -1
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +8 -1
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/settings-manager.d.ts +2 -2
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +2 -2
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/tools/bash.d.ts +3 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +13 -2
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +1 -0
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +19 -1
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +9 -1
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +198 -64
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +14 -1
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-failure-recovery.d.ts +3 -0
- package/dist/core/tools/file-failure-recovery.d.ts.map +1 -1
- package/dist/core/tools/file-failure-recovery.js +11 -0
- package/dist/core/tools/file-failure-recovery.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +1 -1
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
- package/dist/core/tools/orchestration-panel.js +1 -0
- package/dist/core/tools/orchestration-panel.js.map +1 -1
- package/dist/core/tools/profile-writer.d.ts.map +1 -1
- package/dist/core/tools/profile-writer.js +2 -8
- package/dist/core/tools/profile-writer.js.map +1 -1
- package/dist/core/tools/search-command-guard.d.ts.map +1 -1
- package/dist/core/tools/search-command-guard.js +10 -3
- package/dist/core/tools/search-command-guard.js.map +1 -1
- package/dist/core/tools/tool-task.d.ts.map +1 -1
- package/dist/core/tools/tool-task.js +4 -0
- package/dist/core/tools/tool-task.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +10 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/modes/interactive/components/activity-lane.d.ts +1 -1
- package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
- package/dist/modes/interactive/components/activity-lane.js +11 -2
- package/dist/modes/interactive/components/activity-lane.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +1 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/utils/shell.d.ts +2 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +3 -1
- package/dist/utils/shell.js.map +1 -1
- package/docs/harness-architecture.md +6 -3
- package/docs/settings.md +8 -6
- package/docs/tool-repair.md +1 -1
- package/docs/worker-profiles.md +2 -2
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capability-gateway.js","sourceRoot":"","sources":["../../../src/core/orchestration/capability-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OA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AAG,EAAE,MAAM,CAAC,CAAC;YAC/C,IAAI,IAAI,IAAI,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC;gBAAE,OAAO,KAAK,CAAC;QAC3D,CAAC;QACD,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAChD,OAAO,IAAI,KAAK,SAAS,IAAI,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACJ,CAAC;IAEO,IAAI,CAAC,QAAgB,EAAE,UAA+B,EAAE,OAAe;QAC9E,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QACzC,MAAM,IAAI,4BAA4B,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAEO,KAAK,CAAC,QAAgB,EAAE,OAAyB,EAAE,UAA+B;QACzF,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;YAC3B,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;YAC/B,QAAQ;YACR,OAAO;YACP,UAAU;YACV,EAAE,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,WAAW,EAAE;SAC9C,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import { resolve } from \"node:path\";\nimport { extractPathArguments } from \"../autonomy/envelope-enforcement.ts\";\nimport { isPathWithinScope, safeRealpathSync } from \"../autonomy/path-scope.ts\";\nimport { validateAttemptUsageSnapshot } from \"./attempt-usage.ts\";\nimport type { AttemptUsageSnapshot, ExecutionGrant, HarnessCapability, ToolCapabilityManifest } from \"./contracts.ts\";\n\nexport type GatewayDecisionCode =\n\t| \"allowed\"\n\t| \"grant_expired\"\n\t| \"tool_not_granted\"\n\t| \"manifest_name_mismatch\"\n\t| \"capability_not_granted\"\n\t| \"path_argument_required\"\n\t| \"path_outside_scope\"\n\t| \"tool_call_budget_exhausted\"\n\t| \"token_budget_exhausted\"\n\t| \"cost_budget_exhausted\"\n\t| \"wall_clock_budget_exhausted\";\n\nexport interface GatewayAuditRecord {\n\tgrantId: string;\n\tattemptId: string;\n\ttoolName: string;\n\toutcome: \"allow\" | \"deny\";\n\treasonCode: GatewayDecisionCode;\n\tat: string;\n}\n\nexport interface CapabilityGatewayOptions {\n\tgrant: ExecutionGrant;\n\tcwd: string;\n\t/** Durable active usage carried forward when an attempt resumes in a new process. */\n\tinitialUsage?: GatewayInitialUsage;\n\tnow?: () => number;\n\tonAudit?: (record: GatewayAuditRecord) => void;\n\t/** Session-tree cumulative budget owner. Per-attempt grants remain independently enforced. */\n\tsharedBudget?: SharedCapabilityBudget;\n}\n\nexport interface GatewayUsageDelta {\n\tinputTokens?: number;\n\toutputTokens?: number;\n\tcacheReadTokens?: number;\n\tcacheWriteTokens?: number;\n\t/** Provider-authoritative total. Defaults to the supplied detail sum when omitted. */\n\ttotalTokens?: number;\n\tcostUsd?: number;\n}\n\nexport interface GatewayUsageSnapshot {\n\ttoolCalls: number;\n\tinputTokens: number;\n\toutputTokens: number;\n\tcacheReadTokens: number;\n\tcacheWriteTokens: number;\n\ttotalTokens: number;\n\tcostUsd: number;\n\twallClockMs: number;\n}\n\nexport interface ProviderBudgetReservation {\n\tmaxTokens: number;\n\trelease(): void;\n}\n\nexport interface SharedCapabilityBudget {\n\tassertBudgetAvailable(subject: string): void;\n\trecordAttemptUsage(usage: GatewayUsageSnapshot): void;\n\tremainingTokens(): number | undefined;\n\treserveProviderBudget(\n\t\trequestedMaxTokens: number,\n\t\tsubject: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<ProviderBudgetReservation>;\n}\n\n/** Persistable cumulative usage from a prior active segment; excludes restart downtime. */\nexport type GatewayInitialUsage = AttemptUsageSnapshot;\n\n/**\n * Weight applied to prompt-cache reads when charging token budgets. Cache reads re-bill the\n * same context on every request (a worker's fixed system prompt alone is thousands of tokens),\n * so charging them at face value turns `maxTokens` into a request counter: a 9k grant died in\n * 2-3 responses while doing ~500 tokens of real work per response (field session 019fd4dc).\n * The weight mirrors the typical cache-read price ratio; money stays bounded by `maxCostUsd`.\n */\nexport const CACHE_READ_BUDGET_WEIGHT = 0.1;\n\n/**\n * Tokens charged against `maxTokens` budgets: real work at face value, cache reads discounted.\n * A provider-authoritative total above the detail sum is unattributed usage and charges fully.\n */\nexport function budgetedTokens(usage: {\n\tinputTokens: number;\n\toutputTokens: number;\n\tcacheReadTokens: number;\n\tcacheWriteTokens: number;\n\ttotalTokens: number;\n}): number {\n\tconst detailed = usage.inputTokens + usage.outputTokens + usage.cacheWriteTokens;\n\tconst unattributed = Math.max(0, usage.totalTokens - detailed - usage.cacheReadTokens);\n\treturn detailed + unattributed + Math.ceil(usage.cacheReadTokens * CACHE_READ_BUDGET_WEIGHT);\n}\n\nexport class CapabilityGatewayDeniedError extends Error {\n\treadonly reasonCode: GatewayDecisionCode;\n\n\tconstructor(reasonCode: GatewayDecisionCode, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"CapabilityGatewayDeniedError\";\n\t\tthis.reasonCode = reasonCode;\n\t}\n}\n\nconst PATH_CAPABILITIES: ReadonlySet<HarnessCapability> = new Set([\n\t\"filesystem.read\",\n\t\"filesystem.write\",\n\t\"worktree.read\",\n\t\"worktree.mutate\",\n]);\n\nconst WRITE_CAPABILITIES: ReadonlySet<HarnessCapability> = new Set([\"filesystem.write\", \"worktree.mutate\"]);\n\nfunction resolveRealPath(cwd: string, value: string): string | undefined {\n\ttry {\n\t\treturn safeRealpathSync(resolve(cwd, value));\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction validateInitialUsage(usage: GatewayInitialUsage): void {\n\ttry {\n\t\tvalidateAttemptUsageSnapshot(usage, \"CapabilityGateway: initial usage\");\n\t} catch {\n\t\tthrow new Error(\n\t\t\t\"CapabilityGateway: initial usage must contain finite non-negative values and safe-integer counts.\",\n\t\t);\n\t}\n}\n\nfunction validatedUsageDelta(delta: GatewayUsageDelta): Required<GatewayUsageDelta> {\n\tconst inputTokens = delta.inputTokens === undefined ? 0 : delta.inputTokens;\n\tconst outputTokens = delta.outputTokens === undefined ? 0 : delta.outputTokens;\n\tconst cacheReadTokens = delta.cacheReadTokens === undefined ? 0 : delta.cacheReadTokens;\n\tconst cacheWriteTokens = delta.cacheWriteTokens === undefined ? 0 : delta.cacheWriteTokens;\n\tconst totalTokens =\n\t\tdelta.totalTokens === undefined\n\t\t\t? inputTokens + outputTokens + cacheReadTokens + cacheWriteTokens\n\t\t\t: delta.totalTokens;\n\tconst costUsd = delta.costUsd === undefined ? 0 : delta.costUsd;\n\tif (\n\t\t!Number.isSafeInteger(inputTokens) ||\n\t\tinputTokens < 0 ||\n\t\t!Number.isSafeInteger(outputTokens) ||\n\t\toutputTokens < 0 ||\n\t\t!Number.isSafeInteger(cacheReadTokens) ||\n\t\tcacheReadTokens < 0 ||\n\t\t!Number.isSafeInteger(cacheWriteTokens) ||\n\t\tcacheWriteTokens < 0 ||\n\t\t!Number.isSafeInteger(totalTokens) ||\n\t\ttotalTokens < 0 ||\n\t\t!Number.isFinite(costUsd) ||\n\t\tcostUsd < 0\n\t) {\n\t\tthrow new Error(\n\t\t\t\"CapabilityGateway: usage delta must contain finite non-negative values and safe-integer token counts.\",\n\t\t);\n\t}\n\treturn { inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens, totalTokens, costUsd };\n}\n\n/**\n * Per-invocation enforcement for an already-compiled grant. The compiler controls what may be\n * loaded; this gateway independently rechecks authority, path scope, expiry, and cumulative budget\n * immediately before execution.\n */\nexport class CapabilityGateway {\n\tprivate readonly grant: ExecutionGrant;\n\tprivate readonly cwd: string;\n\tprivate readonly now: () => number;\n\tprivate readonly onAudit?: (record: GatewayAuditRecord) => void;\n\tprivate readonly sharedBudget?: SharedCapabilityBudget;\n\tprivate readonly startedAt: number;\n\tprivate readonly initialWallClockMs: number;\n\tprivate toolCalls: number;\n\tprivate inputTokens: number;\n\tprivate outputTokens: number;\n\tprivate cacheReadTokens: number;\n\tprivate cacheWriteTokens: number;\n\tprivate totalTokens: number;\n\tprivate costUsd: number;\n\n\tconstructor(options: CapabilityGatewayOptions) {\n\t\tconst initialUsage: GatewayInitialUsage = options.initialUsage ?? {\n\t\t\ttoolCalls: 0,\n\t\t\tinputTokens: 0,\n\t\t\toutputTokens: 0,\n\t\t\tcacheReadTokens: 0,\n\t\t\tcacheWriteTokens: 0,\n\t\t\ttotalTokens: 0,\n\t\t\tcostUsd: 0,\n\t\t\tactiveWallClockMs: 0,\n\t\t};\n\t\tvalidateInitialUsage(initialUsage);\n\t\tthis.grant = options.grant;\n\t\tthis.cwd = options.cwd;\n\t\tthis.now = options.now ?? Date.now;\n\t\tthis.onAudit = options.onAudit;\n\t\tthis.sharedBudget = options.sharedBudget;\n\t\tthis.startedAt = this.currentTime();\n\t\tthis.initialWallClockMs = initialUsage.activeWallClockMs;\n\t\tthis.toolCalls = initialUsage.toolCalls;\n\t\tthis.inputTokens = initialUsage.inputTokens;\n\t\tthis.outputTokens = initialUsage.outputTokens;\n\t\tthis.cacheReadTokens = initialUsage.cacheReadTokens;\n\t\tthis.cacheWriteTokens = initialUsage.cacheWriteTokens;\n\t\tthis.totalTokens = initialUsage.totalTokens;\n\t\tthis.costUsd = initialUsage.costUsd;\n\t\tthis.sharedBudget?.recordAttemptUsage(this.getUsage());\n\t}\n\n\tasync execute<T>(\n\t\tmanifest: ToolCapabilityManifest,\n\t\ttoolName: string,\n\t\tparams: unknown,\n\t\tinvoke: () => Promise<T> | T,\n\t): Promise<T> {\n\t\tthis.authorizeToolCall(manifest, toolName, params);\n\t\treturn await invoke();\n\t}\n\n\t/** Immediate pre-execution authorization for runtimes that expose a before-tool-call hook. */\n\tauthorizeToolCall(manifest: ToolCapabilityManifest, toolName: string, params: unknown): void {\n\t\tconst now = this.currentTime();\n\t\tconst wallClockMs = this.wallClockMsAt(now);\n\t\tthis.authorize(manifest, toolName, params, now, wallClockMs);\n\t\tconst toolCalls = this.toolCalls + 1;\n\t\tif (!Number.isSafeInteger(toolCalls)) {\n\t\t\tthrow new Error(\"CapabilityGateway: tool-call count would exceed safe cumulative usage bounds.\");\n\t\t}\n\t\tthis.toolCalls = toolCalls;\n\t\tthis.sharedBudget?.recordAttemptUsage(this.getUsage());\n\t\tthis.audit(toolName, \"allow\", \"allowed\");\n\t}\n\n\trecordUsage(delta: GatewayUsageDelta): void {\n\t\tconst validated = validatedUsageDelta(delta);\n\t\tconst inputTokens = this.inputTokens + validated.inputTokens;\n\t\tconst outputTokens = this.outputTokens + validated.outputTokens;\n\t\tconst cacheReadTokens = this.cacheReadTokens + validated.cacheReadTokens;\n\t\tconst cacheWriteTokens = this.cacheWriteTokens + validated.cacheWriteTokens;\n\t\tconst totalTokens = this.totalTokens + validated.totalTokens;\n\t\tconst costUsd = this.costUsd + validated.costUsd;\n\t\tif (\n\t\t\t!Number.isSafeInteger(inputTokens) ||\n\t\t\t!Number.isSafeInteger(outputTokens) ||\n\t\t\t!Number.isSafeInteger(cacheReadTokens) ||\n\t\t\t!Number.isSafeInteger(cacheWriteTokens) ||\n\t\t\t!Number.isSafeInteger(totalTokens) ||\n\t\t\t!Number.isFinite(costUsd)\n\t\t) {\n\t\t\tthrow new Error(\"CapabilityGateway: usage delta would exceed safe cumulative usage bounds.\");\n\t\t}\n\t\tthis.inputTokens = inputTokens;\n\t\tthis.outputTokens = outputTokens;\n\t\tthis.cacheReadTokens = cacheReadTokens;\n\t\tthis.cacheWriteTokens = cacheWriteTokens;\n\t\tthis.totalTokens = totalTokens;\n\t\tthis.costUsd = costUsd;\n\t\tthis.sharedBudget?.recordAttemptUsage(this.getUsage());\n\t}\n\n\t/** Enforce resumed cumulative budgets before a provider request that has no tool-call boundary. */\n\tassertBudgetAvailable(subject = \"provider\"): void {\n\t\tthis.enforceBudget(subject, this.wallClockMsAt(this.currentTime()));\n\t\tthis.sharedBudget?.assertBudgetAvailable(subject);\n\t}\n\n\tasync reserveProviderBudget(\n\t\trequestedMaxTokens: number,\n\t\tsubject = \"provider\",\n\t\tsignal?: AbortSignal,\n\t): Promise<ProviderBudgetReservation> {\n\t\tif (!Number.isSafeInteger(requestedMaxTokens) || requestedMaxTokens <= 0) {\n\t\t\tthrow new Error(\"CapabilityGateway: provider token reservation must be a positive safe integer.\");\n\t\t}\n\t\tthis.assertBudgetAvailable(subject);\n\t\tconst localRemaining = this.remainingAttemptTokenBudget();\n\t\tconst maxTokens = Math.min(requestedMaxTokens, localRemaining ?? requestedMaxTokens);\n\t\tif (maxTokens <= 0) {\n\t\t\tthis.deny(subject, \"token_budget_exhausted\", \"Token budget exhausted.\");\n\t\t}\n\t\tif (this.sharedBudget) return this.sharedBudget.reserveProviderBudget(maxTokens, subject, signal);\n\t\tif (signal?.aborted) throw signal.reason;\n\t\treturn {\n\t\t\tmaxTokens,\n\t\t\trelease: () => undefined,\n\t\t};\n\t}\n\n\tremainingAttemptTokenBudget(): number | undefined {\n\t\tconst maximum = this.grant.budget.maxTokens;\n\t\treturn maximum === undefined ? undefined : Math.max(0, maximum - budgetedTokens(this.getUsage()));\n\t}\n\n\tremainingTokenBudget(): number | undefined {\n\t\tconst localRemaining = this.remainingAttemptTokenBudget();\n\t\tconst sharedRemaining = this.sharedBudget?.remainingTokens();\n\t\tif (localRemaining === undefined) return sharedRemaining;\n\t\tif (sharedRemaining === undefined) return localRemaining;\n\t\treturn Math.min(localRemaining, sharedRemaining);\n\t}\n\n\tgetUsage(): GatewayUsageSnapshot {\n\t\treturn {\n\t\t\ttoolCalls: this.toolCalls,\n\t\t\tinputTokens: this.inputTokens,\n\t\t\toutputTokens: this.outputTokens,\n\t\t\tcacheReadTokens: this.cacheReadTokens,\n\t\t\tcacheWriteTokens: this.cacheWriteTokens,\n\t\t\ttotalTokens: this.totalTokens,\n\t\t\tcostUsd: this.costUsd,\n\t\t\twallClockMs: this.wallClockMsAt(this.currentTime()),\n\t\t};\n\t}\n\n\tprivate authorize(\n\t\tmanifest: ToolCapabilityManifest,\n\t\ttoolName: string,\n\t\tparams: unknown,\n\t\tnow: number,\n\t\twallClockMs: number,\n\t): void {\n\t\tif (this.grant.expiresAt && Date.parse(this.grant.expiresAt) <= now) {\n\t\t\tthis.deny(toolName, \"grant_expired\", `Execution grant '${this.grant.grantId}' expired.`);\n\t\t}\n\t\tif (!this.grant.allowedTools.includes(toolName)) {\n\t\t\tthis.deny(toolName, \"tool_not_granted\", `Tool '${toolName}' is not in grant '${this.grant.grantId}'.`);\n\t\t}\n\t\tif (manifest.toolName !== toolName) {\n\t\t\tthis.deny(toolName, \"manifest_name_mismatch\", `Tool '${toolName}' does not match its capability manifest.`);\n\t\t}\n\t\tif (!manifest.capabilities.every((capability) => this.grant.capabilities.includes(capability))) {\n\t\t\tthis.deny(toolName, \"capability_not_granted\", `Tool '${toolName}' requires an ungranted capability.`);\n\t\t}\n\t\tthis.enforceBudget(toolName, wallClockMs);\n\t\tthis.sharedBudget?.assertBudgetAvailable(toolName);\n\n\t\tif (manifest.capabilities.some((capability) => PATH_CAPABILITIES.has(capability))) {\n\t\t\tconst allowedPaths = manifest.capabilities.some((capability) => WRITE_CAPABILITIES.has(capability))\n\t\t\t\t? this.grant.writePaths\n\t\t\t\t: this.grant.readPaths;\n\t\t\tconst paths = extractPathArguments(params);\n\t\t\tif (paths.length === 0) {\n\t\t\t\tthis.deny(toolName, \"path_argument_required\", `Tool '${toolName}' requires an explicit path argument.`);\n\t\t\t}\n\t\t\tfor (const rawPath of paths) {\n\t\t\t\tif (!this.pathAllowed(rawPath, allowedPaths)) {\n\t\t\t\t\tthis.deny(toolName, \"path_outside_scope\", `Path '${rawPath}' is outside grant '${this.grant.grantId}'.`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate enforceBudget(toolName: string, wallClockMs: number): void {\n\t\tconst budget = this.grant.budget;\n\t\tif (budget.maxToolCalls !== undefined && this.toolCalls >= budget.maxToolCalls) {\n\t\t\tthis.deny(toolName, \"tool_call_budget_exhausted\", \"Tool-call budget exhausted.\");\n\t\t}\n\t\tif (budget.maxTokens !== undefined && budgetedTokens(this.getUsage()) >= budget.maxTokens) {\n\t\t\tthis.deny(toolName, \"token_budget_exhausted\", \"Token budget exhausted.\");\n\t\t}\n\t\tif (budget.maxCostUsd !== undefined && this.costUsd >= budget.maxCostUsd) {\n\t\t\tthis.deny(toolName, \"cost_budget_exhausted\", \"Cost budget exhausted.\");\n\t\t}\n\t\tif (budget.maxWallClockMs !== undefined && wallClockMs >= budget.maxWallClockMs) {\n\t\t\tthis.deny(toolName, \"wall_clock_budget_exhausted\", \"Wall-clock budget exhausted.\");\n\t\t}\n\t}\n\n\tprivate currentTime(): number {\n\t\tconst now = this.now();\n\t\tif (!Number.isFinite(now)) {\n\t\t\tthrow new Error(\"CapabilityGateway: clock source must return a finite time.\");\n\t\t}\n\t\treturn now;\n\t}\n\n\tprivate wallClockMsAt(now: number): number {\n\t\tconst elapsed = now - this.startedAt;\n\t\tif (!Number.isFinite(elapsed)) {\n\t\t\tthrow new Error(\"CapabilityGateway: active wall-clock elapsed time must be finite.\");\n\t\t}\n\t\tconst wallClockMs = this.initialWallClockMs + Math.max(0, elapsed);\n\t\tif (!Number.isFinite(wallClockMs) || wallClockMs < 0) {\n\t\t\tthrow new Error(\"CapabilityGateway: accumulated wall-clock usage must be finite and non-negative.\");\n\t\t}\n\t\treturn wallClockMs;\n\t}\n\n\tprivate pathAllowed(rawPath: string, allowedPaths: readonly string[]): boolean {\n\t\tconst target = resolveRealPath(this.cwd, rawPath);\n\t\tif (!target || allowedPaths.length === 0) return false;\n\t\tfor (const denied of this.grant.deniedPaths) {\n\t\t\tconst root = resolveRealPath(this.cwd, denied);\n\t\t\tif (root && isPathWithinScope(target, root)) return false;\n\t\t}\n\t\treturn allowedPaths.some((allowed) => {\n\t\t\tconst root = resolveRealPath(this.cwd, allowed);\n\t\t\treturn root !== undefined && isPathWithinScope(target, root);\n\t\t});\n\t}\n\n\tprivate deny(toolName: string, reasonCode: GatewayDecisionCode, message: string): never {\n\t\tthis.audit(toolName, \"deny\", reasonCode);\n\t\tthrow new CapabilityGatewayDeniedError(reasonCode, message);\n\t}\n\n\tprivate audit(toolName: string, outcome: \"allow\" | \"deny\", reasonCode: GatewayDecisionCode): void {\n\t\tthis.onAudit?.({\n\t\t\tgrantId: this.grant.grantId,\n\t\t\tattemptId: this.grant.attemptId,\n\t\t\ttoolName,\n\t\t\toutcome,\n\t\t\treasonCode,\n\t\t\tat: new Date(this.currentTime()).toISOString(),\n\t\t});\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"capability-gateway.js","sourceRoot":"","sources":["../../../src/core/orchestration/capability-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AA4ElE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAM9B;IACA,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,gBAAgB,CAAC;IACjF,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,GAAG,QAAQ,GAAG,KAAK,CAAC,eAAe,CAAC,CAAC;IACvF,OAAO,QAAQ,GAAG,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,wBAAw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CAAC;IACJ,CAAC;IAEO,IAAI,CAAC,QAAgB,EAAE,UAA+B,EAAE,OAAe;QAC9E,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QACzC,MAAM,IAAI,4BAA4B,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAEO,KAAK,CAAC,QAAgB,EAAE,OAAyB,EAAE,UAA+B;QACzF,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;YAC3B,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;YAC/B,QAAQ;YACR,OAAO;YACP,UAAU;YACV,EAAE,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,WAAW,EAAE;SAC9C,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import { resolve } from \"node:path\";\nimport { BoundedCompletionFailureError } from \"../autonomy/bounded-completion.ts\";\nimport { extractPathArguments } from \"../autonomy/envelope-enforcement.ts\";\nimport { isPathWithinScope, safeRealpathSync } from \"../autonomy/path-scope.ts\";\nimport { validateAttemptUsageSnapshot } from \"./attempt-usage.ts\";\nimport type { AttemptUsageSnapshot, ExecutionGrant, HarnessCapability, ToolCapabilityManifest } from \"./contracts.ts\";\n\nexport type GatewayDecisionCode =\n\t| \"allowed\"\n\t| \"grant_expired\"\n\t| \"tool_not_granted\"\n\t| \"manifest_name_mismatch\"\n\t| \"capability_not_granted\"\n\t| \"path_argument_required\"\n\t| \"path_outside_scope\"\n\t| \"tool_call_budget_exhausted\"\n\t| \"token_budget_exhausted\"\n\t| \"cost_budget_exhausted\"\n\t| \"wall_clock_budget_exhausted\";\n\nexport interface GatewayAuditRecord {\n\tgrantId: string;\n\tattemptId: string;\n\ttoolName: string;\n\toutcome: \"allow\" | \"deny\";\n\treasonCode: GatewayDecisionCode;\n\tat: string;\n}\n\nexport interface CapabilityGatewayOptions {\n\tgrant: ExecutionGrant;\n\tcwd: string;\n\t/** Durable active usage carried forward when an attempt resumes in a new process. */\n\tinitialUsage?: GatewayInitialUsage;\n\tnow?: () => number;\n\tonAudit?: (record: GatewayAuditRecord) => void;\n\t/** Session-tree cumulative budget owner. Per-attempt grants remain independently enforced. */\n\tsharedBudget?: SharedCapabilityBudget;\n}\n\nexport interface GatewayUsageDelta {\n\tinputTokens?: number;\n\toutputTokens?: number;\n\tcacheReadTokens?: number;\n\tcacheWriteTokens?: number;\n\t/** Provider-authoritative total. Defaults to the supplied detail sum when omitted. */\n\ttotalTokens?: number;\n\tcostUsd?: number;\n}\n\nexport interface GatewayUsageSnapshot {\n\ttoolCalls: number;\n\tinputTokens: number;\n\toutputTokens: number;\n\tcacheReadTokens: number;\n\tcacheWriteTokens: number;\n\ttotalTokens: number;\n\tcostUsd: number;\n\twallClockMs: number;\n}\n\nexport interface ProviderBudgetReservation {\n\tmaxTokens: number;\n\trelease(): void;\n}\n\nexport interface SharedCapabilityBudget {\n\tassertBudgetAvailable(subject: string): void;\n\trecordAttemptUsage(usage: GatewayUsageSnapshot): void;\n\tremainingTokens(): number | undefined;\n\treserveProviderBudget(\n\t\trequestedMaxTokens: number,\n\t\tsubject: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<ProviderBudgetReservation>;\n}\n\n/** Persistable cumulative usage from a prior active segment; excludes restart downtime. */\nexport type GatewayInitialUsage = AttemptUsageSnapshot;\n\n/**\n * Weight applied to prompt-cache reads when charging token budgets. Cache reads re-bill the\n * same context on every request (a worker's fixed system prompt alone is thousands of tokens),\n * so charging them at face value turns `maxTokens` into a request counter: a 9k grant died in\n * 2-3 responses while doing ~500 tokens of real work per response (field session 019fd4dc).\n * The weight mirrors the typical cache-read price ratio; money stays bounded by `maxCostUsd`.\n */\nexport const CACHE_READ_BUDGET_WEIGHT = 0.1;\n\n/**\n * Tokens charged against `maxTokens` budgets: real work at face value, cache reads discounted.\n * A provider-authoritative total above the detail sum is unattributed usage and charges fully.\n */\nexport function budgetedTokens(usage: {\n\tinputTokens: number;\n\toutputTokens: number;\n\tcacheReadTokens: number;\n\tcacheWriteTokens: number;\n\ttotalTokens: number;\n}): number {\n\tconst detailed = usage.inputTokens + usage.outputTokens + usage.cacheWriteTokens;\n\tconst unattributed = Math.max(0, usage.totalTokens - detailed - usage.cacheReadTokens);\n\treturn detailed + unattributed + Math.ceil(usage.cacheReadTokens * CACHE_READ_BUDGET_WEIGHT);\n}\n\nconst BUDGET_EXHAUSTION_DECISION_CODES: ReadonlySet<GatewayDecisionCode> = new Set([\n\t\"tool_call_budget_exhausted\",\n\t\"token_budget_exhausted\",\n\t\"cost_budget_exhausted\",\n\t\"wall_clock_budget_exhausted\",\n]);\n\nexport class CapabilityGatewayDeniedError extends BoundedCompletionFailureError {\n\treadonly reasonCode: GatewayDecisionCode;\n\n\tconstructor(reasonCode: GatewayDecisionCode, message: string) {\n\t\tsuper(BUDGET_EXHAUSTION_DECISION_CODES.has(reasonCode) ? \"budget_exhausted\" : \"failed\", reasonCode, message);\n\t\tthis.name = \"CapabilityGatewayDeniedError\";\n\t\tthis.reasonCode = reasonCode;\n\t}\n}\n\nconst PATH_CAPABILITIES: ReadonlySet<HarnessCapability> = new Set([\n\t\"filesystem.read\",\n\t\"filesystem.write\",\n\t\"worktree.read\",\n\t\"worktree.mutate\",\n]);\n\nconst WRITE_CAPABILITIES: ReadonlySet<HarnessCapability> = new Set([\"filesystem.write\", \"worktree.mutate\"]);\n\nfunction resolveRealPath(cwd: string, value: string): string | undefined {\n\ttry {\n\t\treturn safeRealpathSync(resolve(cwd, value));\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction validateInitialUsage(usage: GatewayInitialUsage): void {\n\ttry {\n\t\tvalidateAttemptUsageSnapshot(usage, \"CapabilityGateway: initial usage\");\n\t} catch {\n\t\tthrow new Error(\n\t\t\t\"CapabilityGateway: initial usage must contain finite non-negative values and safe-integer counts.\",\n\t\t);\n\t}\n}\n\nfunction validatedUsageDelta(delta: GatewayUsageDelta): Required<GatewayUsageDelta> {\n\tconst inputTokens = delta.inputTokens === undefined ? 0 : delta.inputTokens;\n\tconst outputTokens = delta.outputTokens === undefined ? 0 : delta.outputTokens;\n\tconst cacheReadTokens = delta.cacheReadTokens === undefined ? 0 : delta.cacheReadTokens;\n\tconst cacheWriteTokens = delta.cacheWriteTokens === undefined ? 0 : delta.cacheWriteTokens;\n\tconst totalTokens =\n\t\tdelta.totalTokens === undefined\n\t\t\t? inputTokens + outputTokens + cacheReadTokens + cacheWriteTokens\n\t\t\t: delta.totalTokens;\n\tconst costUsd = delta.costUsd === undefined ? 0 : delta.costUsd;\n\tif (\n\t\t!Number.isSafeInteger(inputTokens) ||\n\t\tinputTokens < 0 ||\n\t\t!Number.isSafeInteger(outputTokens) ||\n\t\toutputTokens < 0 ||\n\t\t!Number.isSafeInteger(cacheReadTokens) ||\n\t\tcacheReadTokens < 0 ||\n\t\t!Number.isSafeInteger(cacheWriteTokens) ||\n\t\tcacheWriteTokens < 0 ||\n\t\t!Number.isSafeInteger(totalTokens) ||\n\t\ttotalTokens < 0 ||\n\t\t!Number.isFinite(costUsd) ||\n\t\tcostUsd < 0\n\t) {\n\t\tthrow new Error(\n\t\t\t\"CapabilityGateway: usage delta must contain finite non-negative values and safe-integer token counts.\",\n\t\t);\n\t}\n\treturn { inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens, totalTokens, costUsd };\n}\n\n/**\n * Per-invocation enforcement for an already-compiled grant. The compiler controls what may be\n * loaded; this gateway independently rechecks authority, path scope, expiry, and cumulative budget\n * immediately before execution.\n */\nexport class CapabilityGateway {\n\tprivate readonly grant: ExecutionGrant;\n\tprivate readonly cwd: string;\n\tprivate readonly now: () => number;\n\tprivate readonly onAudit?: (record: GatewayAuditRecord) => void;\n\tprivate readonly sharedBudget?: SharedCapabilityBudget;\n\tprivate readonly startedAt: number;\n\tprivate readonly initialWallClockMs: number;\n\tprivate toolCalls: number;\n\tprivate inputTokens: number;\n\tprivate outputTokens: number;\n\tprivate cacheReadTokens: number;\n\tprivate cacheWriteTokens: number;\n\tprivate totalTokens: number;\n\tprivate costUsd: number;\n\n\tconstructor(options: CapabilityGatewayOptions) {\n\t\tconst initialUsage: GatewayInitialUsage = options.initialUsage ?? {\n\t\t\ttoolCalls: 0,\n\t\t\tinputTokens: 0,\n\t\t\toutputTokens: 0,\n\t\t\tcacheReadTokens: 0,\n\t\t\tcacheWriteTokens: 0,\n\t\t\ttotalTokens: 0,\n\t\t\tcostUsd: 0,\n\t\t\tactiveWallClockMs: 0,\n\t\t};\n\t\tvalidateInitialUsage(initialUsage);\n\t\tthis.grant = options.grant;\n\t\tthis.cwd = options.cwd;\n\t\tthis.now = options.now ?? Date.now;\n\t\tthis.onAudit = options.onAudit;\n\t\tthis.sharedBudget = options.sharedBudget;\n\t\tthis.startedAt = this.currentTime();\n\t\tthis.initialWallClockMs = initialUsage.activeWallClockMs;\n\t\tthis.toolCalls = initialUsage.toolCalls;\n\t\tthis.inputTokens = initialUsage.inputTokens;\n\t\tthis.outputTokens = initialUsage.outputTokens;\n\t\tthis.cacheReadTokens = initialUsage.cacheReadTokens;\n\t\tthis.cacheWriteTokens = initialUsage.cacheWriteTokens;\n\t\tthis.totalTokens = initialUsage.totalTokens;\n\t\tthis.costUsd = initialUsage.costUsd;\n\t\tthis.sharedBudget?.recordAttemptUsage(this.getUsage());\n\t}\n\n\tasync execute<T>(\n\t\tmanifest: ToolCapabilityManifest,\n\t\ttoolName: string,\n\t\tparams: unknown,\n\t\tinvoke: () => Promise<T> | T,\n\t): Promise<T> {\n\t\tthis.authorizeToolCall(manifest, toolName, params);\n\t\treturn await invoke();\n\t}\n\n\t/** Immediate pre-execution authorization for runtimes that expose a before-tool-call hook. */\n\tauthorizeToolCall(manifest: ToolCapabilityManifest, toolName: string, params: unknown): void {\n\t\tconst now = this.currentTime();\n\t\tconst wallClockMs = this.wallClockMsAt(now);\n\t\tthis.authorize(manifest, toolName, params, now, wallClockMs);\n\t\tconst toolCalls = this.toolCalls + 1;\n\t\tif (!Number.isSafeInteger(toolCalls)) {\n\t\t\tthrow new Error(\"CapabilityGateway: tool-call count would exceed safe cumulative usage bounds.\");\n\t\t}\n\t\tthis.toolCalls = toolCalls;\n\t\tthis.sharedBudget?.recordAttemptUsage(this.getUsage());\n\t\tthis.audit(toolName, \"allow\", \"allowed\");\n\t}\n\n\trecordUsage(delta: GatewayUsageDelta): void {\n\t\tconst validated = validatedUsageDelta(delta);\n\t\tconst inputTokens = this.inputTokens + validated.inputTokens;\n\t\tconst outputTokens = this.outputTokens + validated.outputTokens;\n\t\tconst cacheReadTokens = this.cacheReadTokens + validated.cacheReadTokens;\n\t\tconst cacheWriteTokens = this.cacheWriteTokens + validated.cacheWriteTokens;\n\t\tconst totalTokens = this.totalTokens + validated.totalTokens;\n\t\tconst costUsd = this.costUsd + validated.costUsd;\n\t\tif (\n\t\t\t!Number.isSafeInteger(inputTokens) ||\n\t\t\t!Number.isSafeInteger(outputTokens) ||\n\t\t\t!Number.isSafeInteger(cacheReadTokens) ||\n\t\t\t!Number.isSafeInteger(cacheWriteTokens) ||\n\t\t\t!Number.isSafeInteger(totalTokens) ||\n\t\t\t!Number.isFinite(costUsd)\n\t\t) {\n\t\t\tthrow new Error(\"CapabilityGateway: usage delta would exceed safe cumulative usage bounds.\");\n\t\t}\n\t\tthis.inputTokens = inputTokens;\n\t\tthis.outputTokens = outputTokens;\n\t\tthis.cacheReadTokens = cacheReadTokens;\n\t\tthis.cacheWriteTokens = cacheWriteTokens;\n\t\tthis.totalTokens = totalTokens;\n\t\tthis.costUsd = costUsd;\n\t\tthis.sharedBudget?.recordAttemptUsage(this.getUsage());\n\t}\n\n\t/** Enforce resumed cumulative budgets before a provider request that has no tool-call boundary. */\n\tassertBudgetAvailable(subject = \"provider\"): void {\n\t\tthis.enforceBudget(subject, this.wallClockMsAt(this.currentTime()));\n\t\tthis.sharedBudget?.assertBudgetAvailable(subject);\n\t}\n\n\tasync reserveProviderBudget(\n\t\trequestedMaxTokens: number,\n\t\tsubject = \"provider\",\n\t\tsignal?: AbortSignal,\n\t): Promise<ProviderBudgetReservation> {\n\t\tif (!Number.isSafeInteger(requestedMaxTokens) || requestedMaxTokens <= 0) {\n\t\t\tthrow new Error(\"CapabilityGateway: provider token reservation must be a positive safe integer.\");\n\t\t}\n\t\tthis.assertBudgetAvailable(subject);\n\t\tconst localRemaining = this.remainingAttemptTokenBudget();\n\t\tconst maxTokens = Math.min(requestedMaxTokens, localRemaining ?? requestedMaxTokens);\n\t\tif (maxTokens <= 0) {\n\t\t\tthis.deny(subject, \"token_budget_exhausted\", \"Token budget exhausted.\");\n\t\t}\n\t\tif (this.sharedBudget) return this.sharedBudget.reserveProviderBudget(maxTokens, subject, signal);\n\t\tif (signal?.aborted) throw signal.reason;\n\t\treturn {\n\t\t\tmaxTokens,\n\t\t\trelease: () => undefined,\n\t\t};\n\t}\n\n\tremainingAttemptTokenBudget(): number | undefined {\n\t\tconst maximum = this.grant.budget.maxTokens;\n\t\treturn maximum === undefined ? undefined : Math.max(0, maximum - budgetedTokens(this.getUsage()));\n\t}\n\n\tremainingTokenBudget(): number | undefined {\n\t\tconst localRemaining = this.remainingAttemptTokenBudget();\n\t\tconst sharedRemaining = this.sharedBudget?.remainingTokens();\n\t\tif (localRemaining === undefined) return sharedRemaining;\n\t\tif (sharedRemaining === undefined) return localRemaining;\n\t\treturn Math.min(localRemaining, sharedRemaining);\n\t}\n\n\tgetUsage(): GatewayUsageSnapshot {\n\t\treturn {\n\t\t\ttoolCalls: this.toolCalls,\n\t\t\tinputTokens: this.inputTokens,\n\t\t\toutputTokens: this.outputTokens,\n\t\t\tcacheReadTokens: this.cacheReadTokens,\n\t\t\tcacheWriteTokens: this.cacheWriteTokens,\n\t\t\ttotalTokens: this.totalTokens,\n\t\t\tcostUsd: this.costUsd,\n\t\t\twallClockMs: this.wallClockMsAt(this.currentTime()),\n\t\t};\n\t}\n\n\tprivate authorize(\n\t\tmanifest: ToolCapabilityManifest,\n\t\ttoolName: string,\n\t\tparams: unknown,\n\t\tnow: number,\n\t\twallClockMs: number,\n\t): void {\n\t\tif (this.grant.expiresAt && Date.parse(this.grant.expiresAt) <= now) {\n\t\t\tthis.deny(toolName, \"grant_expired\", `Execution grant '${this.grant.grantId}' expired.`);\n\t\t}\n\t\tif (!this.grant.allowedTools.includes(toolName)) {\n\t\t\tthis.deny(toolName, \"tool_not_granted\", `Tool '${toolName}' is not in grant '${this.grant.grantId}'.`);\n\t\t}\n\t\tif (manifest.toolName !== toolName) {\n\t\t\tthis.deny(toolName, \"manifest_name_mismatch\", `Tool '${toolName}' does not match its capability manifest.`);\n\t\t}\n\t\tif (!manifest.capabilities.every((capability) => this.grant.capabilities.includes(capability))) {\n\t\t\tthis.deny(toolName, \"capability_not_granted\", `Tool '${toolName}' requires an ungranted capability.`);\n\t\t}\n\t\tthis.enforceBudget(toolName, wallClockMs);\n\t\tthis.sharedBudget?.assertBudgetAvailable(toolName);\n\n\t\tif (manifest.capabilities.some((capability) => PATH_CAPABILITIES.has(capability))) {\n\t\t\tconst allowedPaths = manifest.capabilities.some((capability) => WRITE_CAPABILITIES.has(capability))\n\t\t\t\t? this.grant.writePaths\n\t\t\t\t: this.grant.readPaths;\n\t\t\tconst paths = extractPathArguments(params);\n\t\t\tif (paths.length === 0) {\n\t\t\t\tthis.deny(toolName, \"path_argument_required\", `Tool '${toolName}' requires an explicit path argument.`);\n\t\t\t}\n\t\t\tfor (const rawPath of paths) {\n\t\t\t\tif (!this.pathAllowed(rawPath, allowedPaths)) {\n\t\t\t\t\tthis.deny(toolName, \"path_outside_scope\", `Path '${rawPath}' is outside grant '${this.grant.grantId}'.`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate enforceBudget(toolName: string, wallClockMs: number): void {\n\t\tconst budget = this.grant.budget;\n\t\tif (budget.maxToolCalls !== undefined && this.toolCalls >= budget.maxToolCalls) {\n\t\t\tthis.deny(toolName, \"tool_call_budget_exhausted\", \"Tool-call budget exhausted.\");\n\t\t}\n\t\tif (budget.maxTokens !== undefined && budgetedTokens(this.getUsage()) >= budget.maxTokens) {\n\t\t\tthis.deny(toolName, \"token_budget_exhausted\", \"Token budget exhausted.\");\n\t\t}\n\t\tif (budget.maxCostUsd !== undefined && this.costUsd >= budget.maxCostUsd) {\n\t\t\tthis.deny(toolName, \"cost_budget_exhausted\", \"Cost budget exhausted.\");\n\t\t}\n\t\tif (budget.maxWallClockMs !== undefined && wallClockMs >= budget.maxWallClockMs) {\n\t\t\tthis.deny(toolName, \"wall_clock_budget_exhausted\", \"Wall-clock budget exhausted.\");\n\t\t}\n\t}\n\n\tprivate currentTime(): number {\n\t\tconst now = this.now();\n\t\tif (!Number.isFinite(now)) {\n\t\t\tthrow new Error(\"CapabilityGateway: clock source must return a finite time.\");\n\t\t}\n\t\treturn now;\n\t}\n\n\tprivate wallClockMsAt(now: number): number {\n\t\tconst elapsed = now - this.startedAt;\n\t\tif (!Number.isFinite(elapsed)) {\n\t\t\tthrow new Error(\"CapabilityGateway: active wall-clock elapsed time must be finite.\");\n\t\t}\n\t\tconst wallClockMs = this.initialWallClockMs + Math.max(0, elapsed);\n\t\tif (!Number.isFinite(wallClockMs) || wallClockMs < 0) {\n\t\t\tthrow new Error(\"CapabilityGateway: accumulated wall-clock usage must be finite and non-negative.\");\n\t\t}\n\t\treturn wallClockMs;\n\t}\n\n\tprivate pathAllowed(rawPath: string, allowedPaths: readonly string[]): boolean {\n\t\tconst target = resolveRealPath(this.cwd, rawPath);\n\t\tif (!target || allowedPaths.length === 0) return false;\n\t\tfor (const denied of this.grant.deniedPaths) {\n\t\t\tconst root = resolveRealPath(this.cwd, denied);\n\t\t\tif (root && isPathWithinScope(target, root)) return false;\n\t\t}\n\t\treturn allowedPaths.some((allowed) => {\n\t\t\tconst root = resolveRealPath(this.cwd, allowed);\n\t\t\treturn root !== undefined && isPathWithinScope(target, root);\n\t\t});\n\t}\n\n\tprivate deny(toolName: string, reasonCode: GatewayDecisionCode, message: string): never {\n\t\tthis.audit(toolName, \"deny\", reasonCode);\n\t\tthrow new CapabilityGatewayDeniedError(reasonCode, message);\n\t}\n\n\tprivate audit(toolName: string, outcome: \"allow\" | \"deny\", reasonCode: GatewayDecisionCode): void {\n\t\tthis.onAudit?.({\n\t\t\tgrantId: this.grant.grantId,\n\t\t\tattemptId: this.grant.attemptId,\n\t\t\ttoolName,\n\t\t\toutcome,\n\t\t\treasonCode,\n\t\t\tat: new Date(this.currentTime()).toISOString(),\n\t\t});\n\t}\n}\n"]}
|
|
@@ -31,6 +31,10 @@ export declare const MAX_ORCHESTRATION_NOTIFICATIONS = 512;
|
|
|
31
31
|
export declare const MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE = 512;
|
|
32
32
|
export declare const MAX_ORCHESTRATION_EVIDENCE = 4096;
|
|
33
33
|
export declare const MAX_ORCHESTRATION_CHECKPOINT_SUMMARY_LENGTH: number;
|
|
34
|
+
/** Absolute durable lineage bound enforced even when a profile requests broader recursion. */
|
|
35
|
+
export declare const MAX_ORCHESTRATION_AGENT_DEPTH = 8;
|
|
36
|
+
/** Retained direct-child identity bound enforced even when a profile requests broader fan-out. */
|
|
37
|
+
export declare const MAX_ORCHESTRATION_DIRECT_CHILDREN = 64;
|
|
34
38
|
/** One changed retained map value; aggregate projection accounting remains the authoritative ceiling. */
|
|
35
39
|
export declare const MAX_ORCHESTRATION_RETAINED_RECORD_BYTES: number;
|
|
36
40
|
/** Leaves room for bounded idempotency evidence and the snapshot envelope below the on-disk ceiling. */
|
|
@@ -61,6 +65,15 @@ export interface OrchestrationExecutionPolicy {
|
|
|
61
65
|
allowedEnvironmentVariables: readonly string[];
|
|
62
66
|
maxOutputBytes: number;
|
|
63
67
|
}
|
|
68
|
+
/** Outbound recursive delegation authority retained with an immutable worker profile snapshot. */
|
|
69
|
+
export interface OrchestrationDelegationLimits {
|
|
70
|
+
/** Greatest absolute AgentBindingContract.depth that this worker may create. */
|
|
71
|
+
maxDepth: number;
|
|
72
|
+
/** Greatest number of retained direct child identities that this worker may create. */
|
|
73
|
+
maxChildrenPerAgent: number;
|
|
74
|
+
/** Greatest number of retained non-root identities across this durable session. */
|
|
75
|
+
maxNestedAgentsPerSession?: number;
|
|
76
|
+
}
|
|
64
77
|
export declare const OBJECTIVE_STATUSES: readonly ["active", "paused", "completed", "cancelled"];
|
|
65
78
|
export type ObjectiveStatus = (typeof OBJECTIVE_STATUSES)[number];
|
|
66
79
|
export declare const TASK_STATUSES: readonly ["pending", "ready", "running", "blocked", "completed", "failed", "cancelled"];
|
|
@@ -188,6 +201,8 @@ export interface OrchestrationProfile {
|
|
|
188
201
|
/** Optional preset-routing metadata retained for authored profiles; never an admission allowlist. */
|
|
189
202
|
dispatchProfileIds: readonly string[];
|
|
190
203
|
executionPolicy?: OrchestrationExecutionPolicy;
|
|
204
|
+
/** Omitted authored profiles use the host ceiling; adaptive profiles carry a lean explicit limit. */
|
|
205
|
+
delegationLimits?: OrchestrationDelegationLimits;
|
|
191
206
|
budget: RiskBudget;
|
|
192
207
|
/** Authored scheduling hint retained in the snapshot; the global scheduler owns actual concurrency. */
|
|
193
208
|
maxConcurrent: number;
|
|
@@ -394,7 +409,7 @@ export interface ApprovalResolutionContract {
|
|
|
394
409
|
reasonCode: string;
|
|
395
410
|
resolvedAt: string;
|
|
396
411
|
}
|
|
397
|
-
export declare const ORCHESTRATION_EVENT_TYPES: readonly ["objective.created", "objective.updated", "objective.evidence_recorded", "objective.paused", "objective.resumed", "objective.completed", "objective.cancelled", "task.created", "task.attempt_prepared", "task.ready", "task.failed", "task.verification_finished", "agent.registered", "agent.retired", "agent.suspended", "agent.resume_requested", "agent.resumed", "attempt.queued", "attempt.grant_bound", "attempt.leased", "attempt.started", "attempt.checkpointed", "attempt.suspended", "attempt.resumed", "attempt.cancelled", "attempt.finished", "attempt.lease_expired", "approval.requested", "approval.resolved", "notification.enqueued", "notification.delivered"];
|
|
412
|
+
export declare const ORCHESTRATION_EVENT_TYPES: readonly ["objective.created", "objective.updated", "objective.evidence_recorded", "objective.paused", "objective.resumed", "objective.completed", "objective.cancelled", "task.created", "task.attempt_prepared", "task.ready", "task.failed", "task.verification_finished", "agent.registered", "agent.retired", "agent.suspended", "agent.resume_requested", "agent.resumed", "attempt.queued", "attempt.grant_bound", "attempt.leased", "attempt.started", "attempt.lease_renewed", "attempt.checkpointed", "attempt.suspended", "attempt.resumed", "attempt.cancelled", "attempt.finished", "attempt.lease_expired", "approval.requested", "approval.resolved", "notification.enqueued", "notification.delivered"];
|
|
398
413
|
export type OrchestrationEventType = (typeof ORCHESTRATION_EVENT_TYPES)[number];
|
|
399
414
|
export type OrchestrationActorKind = "human" | "kernel" | "runtime" | "policy" | "router" | "worker";
|
|
400
415
|
export interface OrchestrationEvent {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAwB,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEzF,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAErF,OAAO,EAAE,oBAAoB,EAAE,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEzF;;;;GAIG;AAEH,eAAO,MAAM,4BAA4B,EAAG,CAAU,CAAC;AAEvD,yGAAyG;AACzG,eAAO,MAAM,mCAAmC,MAAM,CAAC;AACvD,eAAO,MAAM,uCAAuC,MAAM,CAAC;AAC3D,eAAO,MAAM,iCAAiC,MAAM,CAAC;AACrD,eAAO,MAAM,oCAAoC,QAAW,CAAC;AAC7D,eAAO,MAAM,mCAAmC,KAAK,CAAC;AACtD,eAAO,MAAM,8CAA8C,QAAY,CAAC;AACxE;;;GAGG;AACH,eAAO,MAAM,gCAAgC,MAAM,CAAC;AACpD,eAAO,MAAM,4BAA4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rB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,UAAU,CAAC;CACpB;AAmBD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAE9E;AAED,qGAAqG;AACrG,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAKvD;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAiBhF"}
|
|
@@ -30,6 +30,10 @@ export const MAX_ORCHESTRATION_NOTIFICATIONS = 512;
|
|
|
30
30
|
export const MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE = 512;
|
|
31
31
|
export const MAX_ORCHESTRATION_EVIDENCE = 4_096;
|
|
32
32
|
export const MAX_ORCHESTRATION_CHECKPOINT_SUMMARY_LENGTH = 4 * 1024;
|
|
33
|
+
/** Absolute durable lineage bound enforced even when a profile requests broader recursion. */
|
|
34
|
+
export const MAX_ORCHESTRATION_AGENT_DEPTH = 8;
|
|
35
|
+
/** Retained direct-child identity bound enforced even when a profile requests broader fan-out. */
|
|
36
|
+
export const MAX_ORCHESTRATION_DIRECT_CHILDREN = 64;
|
|
33
37
|
/** One changed retained map value; aggregate projection accounting remains the authoritative ceiling. */
|
|
34
38
|
export const MAX_ORCHESTRATION_RETAINED_RECORD_BYTES = 1024 * 1024;
|
|
35
39
|
/** Leaves room for bounded idempotency evidence and the snapshot envelope below the on-disk ceiling. */
|
|
@@ -115,6 +119,7 @@ export const ORCHESTRATION_EVENT_TYPES = [
|
|
|
115
119
|
"attempt.grant_bound",
|
|
116
120
|
"attempt.leased",
|
|
117
121
|
"attempt.started",
|
|
122
|
+
"attempt.lease_renewed",
|
|
118
123
|
"attempt.checkpointed",
|
|
119
124
|
"attempt.suspended",
|
|
120
125
|
"attempt.resumed",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/core/orch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KAAc;IAClD,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACxC,OAAO,CACN,KAAK,CAAC,aAAa,KAAK,4BAA4B;QACpD,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC;QACnC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QACzB,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC;QAC/B,cAAc,CAAC,yBAAyB,EAAE,KAAK,CAAC,IAAI,CAAC;QACrD,gBAAgB,CAAC,KAAK,CAAC,WAAW,CAAC;QACnC,cAAc,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAU,EAAE,KAAK,CAAC,KAAK,CAAC;QAClG,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC;QAClC,CAAC,KAAK,CAAC,aAAa,KAAK,SAAS,IAAI,gBAAgB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAC5E,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS,IAAI,gBAAgB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACxE,CAAC,KAAK,CAAC,cAAc,KAAK,SAAS,IAAI,gBAAgB,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC9E,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC;QAC5B,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAC1B,CAAC;AACH,CAAC","sourcesContent":["import type { JsonObject, JsonValue } from \"../autonomy/contracts.ts\";\nimport { HARNESS_CAPABILITIES, type HarnessCapability } from \"../capability-contract.ts\";\nimport { isPlainRecord } from \"../util/value-guards.ts\";\nimport type { WorkerContextForkReference } from \"./worker-context-fork-reference.ts\";\n\nexport { HARNESS_CAPABILITIES, type HarnessCapability } from \"../capability-contract.ts\";\n\n/**\n * Versioned control-plane contracts. These records are the durable truth exchanged between the\n * deterministic kernel/runtime and replaceable execution-plane workers. They deliberately do not\n * contain callbacks, provider objects, tool implementations, or transcript messages.\n */\n\nexport const ORCHESTRATION_SCHEMA_VERSION = 1 as const;\n\n/** Shared durable-control bounds. Keep persisted orchestration records small enough to replay safely. */\nexport const MAX_ORCHESTRATION_IDENTIFIER_LENGTH = 512;\nexport const MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH = 128;\nexport const MAX_ORCHESTRATION_MODEL_ID_LENGTH = 512;\nexport const MAX_ORCHESTRATION_DESCRIPTION_LENGTH = 4 * 1024;\nexport const MAX_ORCHESTRATION_COLLECTION_LENGTH = 64;\nexport const MAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH = 16 * 1024;\n/**\n * Lifetime ceilings for the retained hot projection. Terminal records are intentionally retained,\n * so these limits match the durable worker-fleet ceiling rather than only counting active work.\n */\nexport const MAX_ORCHESTRATION_AGENT_BINDINGS = 256;\nexport const MAX_ORCHESTRATION_OBJECTIVES = 256;\nexport const MAX_ORCHESTRATION_TASKS = 256;\nexport const MAX_ORCHESTRATION_ATTEMPTS = 256;\nexport const MAX_ORCHESTRATION_CHECKPOINTS = 4_096;\nexport const MAX_ORCHESTRATION_APPROVALS = 256;\n/** Approval prompts and terminal handoffs may each retain one notification per attempt. */\nexport const MAX_ORCHESTRATION_NOTIFICATIONS = 512;\n/** Source goal state admits at most 512 evidence entries for one objective. */\nexport const MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE = 512;\nexport const MAX_ORCHESTRATION_EVIDENCE = 4_096;\nexport const MAX_ORCHESTRATION_CHECKPOINT_SUMMARY_LENGTH = 4 * 1024;\n/** One changed retained map value; aggregate projection accounting remains the authoritative ceiling. */\nexport const MAX_ORCHESTRATION_RETAINED_RECORD_BYTES = 1024 * 1024;\n/** Leaves room for bounded idempotency evidence and the snapshot envelope below the on-disk ceiling. */\nexport const MAX_ORCHESTRATION_PROJECTION_BYTES = 24 * 1024 * 1024;\nexport const MAX_ORCHESTRATION_SNAPSHOT_IDEMPOTENCY_BYTES = 4 * 1024 * 1024;\nexport const MAX_ORCHESTRATION_PROJECTION_SNAPSHOT_BYTES = 32 * 1024 * 1024;\n/** Matches the bounded worker/process result contract retained by the execution plane. */\nexport const MAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES = 512 * 1024;\nexport const MAX_WORKER_AUTHORITY_PATHS = 64;\nexport const MAX_WORKER_AUTHORITY_PATH_LENGTH = 4 * 1024;\nexport const MAX_WORKER_SOUL_LENGTH = 16 * 1024;\n\nexport const WORKER_ROLES = [\n\t\"orchestrator\",\n\t\"planner\",\n\t\"explorer\",\n\t\"implementer\",\n\t\"operator\",\n\t\"verifier\",\n\t\"database\",\n] as const;\nexport type WorkerRole = (typeof WORKER_ROLES)[number];\n\nexport const ORCHESTRATION_THINKING_LEVELS = [\n\t\"off\",\n\t\"minimal\",\n\t\"low\",\n\t\"medium\",\n\t\"high\",\n\t\"xhigh\",\n\t\"max\",\n\t\"ultra\",\n] as const;\nexport type OrchestrationThinkingLevel = (typeof ORCHESTRATION_THINKING_LEVELS)[number];\n\nexport interface OrchestrationModelBinding {\n\tprovider: string;\n\tmodelId: string;\n\tthinkingLevel: OrchestrationThinkingLevel;\n}\n\nexport interface OrchestrationModelPolicy {\n\tmode: \"fixed\" | \"ordered-fallback\";\n\tcandidates: readonly OrchestrationModelBinding[];\n}\n\n/** Constrained direct-argv launcher policy. This is allowlisting, not OS/container isolation. */\nexport interface OrchestrationExecutionPolicy {\n\tallowedExecutables: readonly string[];\n\tallowedEnvironmentVariables: readonly string[];\n\tmaxOutputBytes: number;\n}\n\nexport const OBJECTIVE_STATUSES = [\"active\", \"paused\", \"completed\", \"cancelled\"] as const;\nexport type ObjectiveStatus = (typeof OBJECTIVE_STATUSES)[number];\n\nexport const TASK_STATUSES = [\"pending\", \"ready\", \"running\", \"blocked\", \"completed\", \"failed\", \"cancelled\"] as const;\nexport type OrchestrationTaskStatus = (typeof TASK_STATUSES)[number];\n\nexport const ATTEMPT_STATUSES = [\n\t\"queued\",\n\t\"leased\",\n\t\"running\",\n\t\"suspended\",\n\t\"completed\",\n\t\"partial\",\n\t\"blocked\",\n\t\"failed\",\n\t\"cancelled\",\n\t\"expired\",\n] as const;\nexport type AttemptStatus = (typeof ATTEMPT_STATUSES)[number];\n\nexport const WORKER_RESULT_STATUSES = [\"completed\", \"partial\", \"blocked\", \"failed\", \"cancelled\"] as const;\nexport type WorkerResultContractStatus = (typeof WORKER_RESULT_STATUSES)[number];\n\nexport type AgentBindingStatus = \"registered\" | \"active\" | \"suspended\" | \"resuming\" | \"retired\";\n\nexport interface AgentResumeContext {\n\tprovider: \"pi\" | \"external\";\n\tsessionId: string;\n\tsessionDir?: string;\n\tsessionFile?: string;\n\tcwd: string;\n\tworktreeLaneKey?: string;\n\torchestrationProfileId?: string;\n\tresourceProfileNames: readonly string[];\n\tmodelRef?: string;\n\tcontextPointers: readonly ResourcePointer[];\n\tlatestCheckpointId?: string;\n}\n\n/** Provider-neutral logical identity shared by durable orchestration and process supervision. */\nexport interface AgentIdentityContract {\n\tagentId: string;\n\tresumeContext: AgentResumeContext;\n}\n\n/** Durable logical identity. A replacement OS process resumes this same binding after interruption. */\nexport interface AgentBindingContract extends AgentIdentityContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\t/** Direct creator in the durable orchestration tree. Root agents omit this field. */\n\tparentAgentId?: string;\n\t/** Stable root identity retained across bounded recursive delegation depth. */\n\trootAgentId: string;\n\t/** Durable lineage depth. Fleet admission enforces the host-configured depth ceiling. */\n\tdepth: number;\n\trole: WorkerRole;\n\tstatus: AgentBindingStatus;\n\tactiveAttemptId?: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface RiskBudget {\n\t/**\n\t * Budget-counted tokens, not raw provider totals: input/output/cache-write tokens charge at\n\t * face value, prompt-cache reads at CACHE_READ_BUDGET_WEIGHT (see capability-gateway.ts).\n\t * Charging cache reads fully would turn this into a request counter, since every request\n\t * re-reads the fixed system prompt.\n\t */\n\tmaxTokens?: number;\n\tmaxWallClockMs?: number;\n\tmaxCostUsd?: number;\n\tmaxAttempts?: number;\n\tmaxToolCalls?: number;\n\trequireApprovalAboveCostUsd?: number;\n}\n\nexport interface AcceptanceCriterion {\n\tid: string;\n\tdescription: string;\n\trequired: boolean;\n\tevaluator?: string;\n}\n\nexport interface ObjectiveContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tobjectiveId: string;\n\ttitle: string;\n\tdescription: string;\n\tstatus: ObjectiveStatus;\n\tconstraints: readonly string[];\n\tacceptanceCriteria: readonly AcceptanceCriterion[];\n\triskBudget: RiskBudget;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface TaskContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\ttaskId: string;\n\tobjectiveId: string;\n\ttitle: string;\n\tdescription: string;\n\trole: WorkerRole;\n\tstatus: OrchestrationTaskStatus;\n\tdependsOn: readonly string[];\n\trequiredCapabilities: readonly HarnessCapability[];\n\tacceptanceCriterionIds: readonly string[];\n\t/** Implementer task this verifier task must independently reconcile. */\n\tverificationOfTaskId?: string;\n\triskBudget: RiskBudget;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport const RESOURCE_POINTER_KINDS = [\n\t\"repository\",\n\t\"worktree\",\n\t\"artifact\",\n\t\"evidence\",\n\t\"memory-query\",\n\t\"skill\",\n\t\"prompt\",\n\t\"service\",\n] as const;\nexport type ResourcePointerKind = (typeof RESOURCE_POINTER_KINDS)[number];\n\nexport function isResourcePointerKind(value: unknown): value is ResourcePointerKind {\n\treturn RESOURCE_POINTER_KINDS.some((kind) => kind === value);\n}\n\nexport interface ResourcePointer {\n\tid: string;\n\tkind: ResourcePointerKind;\n\turi: string;\n\treadOnly: boolean;\n\tdigest?: string;\n\tmetadata?: JsonObject;\n}\n\n/** Bounded metadata-only resources retained in one worker execution contract. */\nexport const MAX_WORKER_RESOURCE_POINTERS = 64;\nexport const MAX_WORKER_RESOURCE_PATH_LENGTH = 4096;\nexport const MAX_WORKER_RESOURCE_METADATA_NAME_LENGTH = 256;\n\n/** Lightweight metadata catalogued without importing the executable tool module. */\nexport interface ToolCapabilityManifest {\n\ttoolName: string;\n\tmoduleSpecifier: string;\n\tcapabilities: readonly HarnessCapability[];\n\troles: readonly WorkerRole[];\n\tenforcements: readonly CapabilityEnforcementKind[];\n\tsourcePath?: string;\n}\n\nexport interface OrchestrationProfile {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tprofileId: string;\n\tdescription: string;\n\trole: WorkerRole;\n\tmodelPolicy: OrchestrationModelPolicy;\n\tcapabilityCeiling: readonly HarnessCapability[];\n\ttoolNames: readonly string[];\n\tresourceProfileNames: readonly string[];\n\t/** Optional preset-routing metadata retained for authored profiles; never an admission allowlist. */\n\tdispatchProfileIds: readonly string[];\n\texecutionPolicy?: OrchestrationExecutionPolicy;\n\tbudget: RiskBudget;\n\t/** Authored scheduling hint retained in the snapshot; the global scheduler owns actual concurrency. */\n\tmaxConcurrent: number;\n\tleaseTtlMs: number;\n\trequireIndependentVerification: boolean;\n\t/** Owner-pinned verifier profile. Required when independent verification is enabled. */\n\tverificationProfileId?: string;\n\t/** Resolved origin retained for controlled improvements; omitted from authored JSON. */\n\tsourcePath?: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\n/** Admission-time worker profile materialization. Profile files are never consulted after this is persisted. */\nexport interface WorkerProfileExecutionContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tprofile: OrchestrationProfile;\n\tmodelBinding: OrchestrationModelBinding;\n\tauthority: WorkerExecutionAuthorityContract;\n\t/** Metadata-only resources fixed at admission; their content remains lazy and non-durable. */\n\tresourcePointers: readonly ResourcePointer[];\n\t/** Resolved resource-profile identity text. Other worker resources are represented by profile tools. */\n\tsoul?: string;\n}\n\n/** Effective authority admitted for one materialized worker profile. */\nexport interface WorkerExecutionAuthorityContract {\n\tcapabilities: readonly HarnessCapability[];\n\ttoolNames: readonly string[];\n\treadPaths: readonly string[];\n\twritePaths: readonly string[];\n\tdeniedPaths: readonly string[];\n\tbudget: RiskBudget;\n}\n\n/** Immutable execution contract owned by the runtime, including any mandatory verifier. */\nexport interface WorkerExecutionContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tworker: WorkerProfileExecutionContract;\n\tverifier?: WorkerProfileExecutionContract;\n}\n\n/** Durable dispatch metadata. Model/tool choices are retained in the runtime-owned executionContract. */\nexport interface OrchestrationDispatchRequest {\n\ttaskId: string;\n\tprofileId: string;\n\tinstructions: string;\n\tresourcePointerIds: readonly string[];\n\t/** Direct logical-agent creator for recursively delegated in-process work. */\n\tparentAgentId?: string;\n\t/** Runtime-owned goal/task correlation. Omitted by legacy records and normalized to an empty list. */\n\trequirementIds?: readonly string[];\n\t/** Execution owner. Omitted on legacy records and normalized to in-process. */\n\texecutionKind?: \"in-process\" | \"managed-process\";\n\t/** Stable external lane identity shared by successive managed-process turns. */\n\tlogicalLaneId?: string;\n\t/** Monotonic dispatch sequence within a managed-process logical lane. */\n\tdispatchSequence?: number;\n\t/** Durable mailbox message whose task-bearing intent owns this logical-agent turn. */\n\tcontrolMessageId?: string;\n\t/** External provider identity retained for routing and diagnostics. */\n\tprovider?: string;\n\t/** Owner approval or standing-grant record that authorized an external launch. */\n\tauthorizationId?: string;\n\t/** Worktree-sync lane claimed by the external dispatcher. */\n\tworktreeLaneKey?: string;\n\t/** Immutable sanitized parent context captured for this persistent logical worker at birth. */\n\tbirthContextForkReference?: WorkerContextForkReference;\n\t/** Runtime-owned immutable worker materialization. Never accepted from a model tool call. */\n\texecutionContract?: WorkerExecutionContract;\n}\n\nexport type CapabilityEnforcementKind =\n\t| \"path-scope\"\n\t| \"process-launcher\"\n\t| \"service-proxy\"\n\t| \"memory-broker\"\n\t| \"control-plane\";\n\nexport interface CapabilityDecision {\n\tcapability: HarnessCapability;\n\toutcome: \"allow\" | \"deny\";\n\treasonCode: string;\n\tsource: string;\n}\n\nexport interface ExecutionGrant {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tgrantId: string;\n\tobjectiveId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tsubjectId: string;\n\trole: WorkerRole;\n\tcapabilities: readonly HarnessCapability[];\n\tallowedTools: readonly string[];\n\tresources: readonly ResourcePointer[];\n\treadPaths: readonly string[];\n\twritePaths: readonly string[];\n\tdeniedPaths: readonly string[];\n\tbudget: RiskBudget;\n\tpolicyVersion: string;\n\tdecisionTrace: readonly CapabilityDecision[];\n\tissuedAt: string;\n\texpiresAt?: string;\n}\n\nexport interface AttemptLease {\n\tleaseId: string;\n\tattemptId: string;\n\townerId: string;\n\tfencingToken: number;\n\tissuedAt: string;\n\texpiresAt: string;\n}\n\n/** Restart-durable host retry ladder state for one resumable worker attempt. */\nexport interface AttemptRetryState {\n\t/** Scheduled retries already consumed; the initial execution is not included. */\n\tretriesUsed: number;\n\t/** Earliest instant at which the suspended attempt may receive a fresh lease. */\n\tnotBefore: string;\n}\n\n/** Complete cumulative active usage for one execution attempt. Restart downtime is never included. */\nexport interface AttemptUsageSnapshot {\n\ttoolCalls: number;\n\tinputTokens: number;\n\toutputTokens: number;\n\tcacheReadTokens: number;\n\tcacheWriteTokens: number;\n\t/** Provider-authoritative total; detail categories are not assumed to be additive. */\n\ttotalTokens: number;\n\tcostUsd: number;\n\tactiveWallClockMs: number;\n}\n\nexport interface AttemptCheckpoint {\n\tcheckpointId: string;\n\tattemptId: string;\n\tfencingToken: number;\n\tsummary: string;\n\tartifactIds: readonly string[];\n\tevidenceIds: readonly string[];\n\t/** Omitted only by legacy checkpoints created before durable usage accounting existed. */\n\tusage?: AttemptUsageSnapshot;\n\tcreatedAt: string;\n}\n\nexport interface ArtifactContract {\n\tartifactId: string;\n\tkind: \"diff\" | \"file\" | \"report\" | \"test-result\" | \"log\" | \"structured-data\";\n\turi: string;\n\tdigest?: string;\n\tsizeBytes?: number;\n\tcreatedAt: string;\n\tmetadata?: JsonObject;\n}\n\nexport interface EvidenceContract {\n\tevidenceId: string;\n\tcriterionId?: string;\n\tkind: \"observation\" | \"command\" | \"test\" | \"review\" | \"external\";\n\tsummary: string;\n\tartifactIds: readonly string[];\n\ttrusted: boolean;\n\tcreatedAt: string;\n\tmetadata?: JsonObject;\n}\n\nexport interface WorkerErrorContract {\n\tcode: string;\n\tmessage: string;\n\tretryable: boolean;\n\tdetails?: JsonObject;\n}\n\nexport interface WorkerUsageContract {\n\tinputTokens?: number;\n\toutputTokens?: number;\n\ttotalTokens?: number;\n\tcostUsd?: number;\n\twallClockMs: number;\n\ttoolCalls: number;\n}\n\nexport interface WorkerResultContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tresultId: string;\n\tobjectiveId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tleaseId: string;\n\tfencingToken: number;\n\tstatus: WorkerResultContractStatus;\n\treasonCode: string;\n\tsummary: string;\n\tartifacts: readonly ArtifactContract[];\n\tevidence: readonly EvidenceContract[];\n\terrors: readonly WorkerErrorContract[];\n\tnextAction?: string;\n\tusage: WorkerUsageContract;\n\tcreatedAt: string;\n}\n\nexport interface ApprovalRequestContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tapprovalId: string;\n\tobjectiveId: string;\n\ttaskId?: string;\n\tattemptId?: string;\n\treasonCode: string;\n\tsummary: string;\n\trequestedCapabilities: readonly HarnessCapability[];\n\trequestedBudget?: RiskBudget;\n\treversible: boolean;\n\tcreatedAt: string;\n}\n\nexport const APPROVAL_OUTCOMES = [\"approved\", \"rejected\"] as const;\nexport type ApprovalOutcome = (typeof APPROVAL_OUTCOMES)[number];\n\n/** Human decision only. Approval is not an execution grant; policy must compile a new grant afterward. */\nexport interface ApprovalResolutionContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tapprovalId: string;\n\toutcome: ApprovalOutcome;\n\treasonCode: string;\n\tresolvedAt: string;\n}\n\nexport const ORCHESTRATION_EVENT_TYPES = [\n\t\"objective.created\",\n\t\"objective.updated\",\n\t\"objective.evidence_recorded\",\n\t\"objective.paused\",\n\t\"objective.resumed\",\n\t\"objective.completed\",\n\t\"objective.cancelled\",\n\t\"task.created\",\n\t\"task.attempt_prepared\",\n\t\"task.ready\",\n\t\"task.failed\",\n\t\"task.verification_finished\",\n\t\"agent.registered\",\n\t\"agent.retired\",\n\t\"agent.suspended\",\n\t\"agent.resume_requested\",\n\t\"agent.resumed\",\n\t\"attempt.queued\",\n\t\"attempt.grant_bound\",\n\t\"attempt.leased\",\n\t\"attempt.started\",\n\t\"attempt.checkpointed\",\n\t\"attempt.suspended\",\n\t\"attempt.resumed\",\n\t\"attempt.cancelled\",\n\t\"attempt.finished\",\n\t\"attempt.lease_expired\",\n\t\"approval.requested\",\n\t\"approval.resolved\",\n\t\"notification.enqueued\",\n\t\"notification.delivered\",\n] as const;\n\nexport type OrchestrationEventType = (typeof ORCHESTRATION_EVENT_TYPES)[number];\nexport type OrchestrationActorKind = \"human\" | \"kernel\" | \"runtime\" | \"policy\" | \"router\" | \"worker\";\n\nexport interface OrchestrationEvent {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tordinal: number;\n\teventId: string;\n\ttype: OrchestrationEventType;\n\taggregateId: string;\n\tactor: OrchestrationActorKind;\n\toccurredAt: string;\n\tcorrelationId?: string;\n\tcausationId?: string;\n\tidempotencyKey?: string;\n\tpayload: JsonObject;\n}\n\nexport interface AppendOrchestrationEventInput {\n\ttype: OrchestrationEventType;\n\taggregateId: string;\n\tactor: OrchestrationActorKind;\n\tcorrelationId?: string;\n\tcausationId?: string;\n\tidempotencyKey?: string;\n\tpayload: JsonObject;\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n\treturn typeof value === \"string\" && value.length > 0;\n}\n\nfunction isJsonValue(value: unknown, depth = 0): value is JsonValue {\n\tif (depth > 30) return false;\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return true;\n\tif (typeof value === \"number\") return Number.isFinite(value);\n\tif (Array.isArray(value)) return value.every((entry) => isJsonValue(entry, depth + 1));\n\tif (!isPlainRecord(value)) return false;\n\treturn Object.values(value).every((entry) => isJsonValue(entry, depth + 1));\n}\n\nfunction includesString<const T extends readonly string[]>(values: T, value: unknown): value is T[number] {\n\treturn typeof value === \"string\" && values.includes(value);\n}\n\nexport function isHarnessCapability(value: unknown): value is HarnessCapability {\n\treturn includesString(HARNESS_CAPABILITIES, value);\n}\n\n/** Clone a runtime value into the persisted JSON domain, rejecting unsupported or over-deep data. */\nexport function toJsonObject(value: unknown): JsonObject {\n\tif (!isPlainRecord(value) || !isJsonValue(value)) {\n\t\tthrow new TypeError(\"Value is not a valid orchestration JSON object.\");\n\t}\n\treturn structuredClone(value);\n}\n\nexport function isOrchestrationEvent(value: unknown): value is OrchestrationEvent {\n\tif (!isPlainRecord(value)) return false;\n\treturn (\n\t\tvalue.schemaVersion === ORCHESTRATION_SCHEMA_VERSION &&\n\t\tNumber.isSafeInteger(value.ordinal) &&\n\t\tNumber(value.ordinal) > 0 &&\n\t\tisNonEmptyString(value.eventId) &&\n\t\tincludesString(ORCHESTRATION_EVENT_TYPES, value.type) &&\n\t\tisNonEmptyString(value.aggregateId) &&\n\t\tincludesString([\"human\", \"kernel\", \"runtime\", \"policy\", \"router\", \"worker\"] as const, value.actor) &&\n\t\tisNonEmptyString(value.occurredAt) &&\n\t\t(value.correlationId === undefined || isNonEmptyString(value.correlationId)) &&\n\t\t(value.causationId === undefined || isNonEmptyString(value.causationId)) &&\n\t\t(value.idempotencyKey === undefined || isNonEmptyString(value.idempotencyKey)) &&\n\t\tisPlainRecord(value.payload) &&\n\t\tisJsonValue(value.payload)\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/core/orchestration/contracts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAA0B,MA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IACD,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAc;IAClD,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACxC,OAAO,CACN,KAAK,CAAC,aAAa,KAAK,4BAA4B;QACpD,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC;QACnC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QACzB,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC;QAC/B,cAAc,CAAC,yBAAyB,EAAE,KAAK,CAAC,IAAI,CAAC;QACrD,gBAAgB,CAAC,KAAK,CAAC,WAAW,CAAC;QACnC,cAAc,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAU,EAAE,KAAK,CAAC,KAAK,CAAC;QAClG,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC;QAClC,CAAC,KAAK,CAAC,aAAa,KAAK,SAAS,IAAI,gBAAgB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAC5E,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS,IAAI,gBAAgB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACxE,CAAC,KAAK,CAAC,cAAc,KAAK,SAAS,IAAI,gBAAgB,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC9E,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC;QAC5B,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAC1B,CAAC;AACH,CAAC","sourcesContent":["import type { JsonObject, JsonValue } from \"../autonomy/contracts.ts\";\nimport { HARNESS_CAPABILITIES, type HarnessCapability } from \"../capability-contract.ts\";\nimport { isPlainRecord } from \"../util/value-guards.ts\";\nimport type { WorkerContextForkReference } from \"./worker-context-fork-reference.ts\";\n\nexport { HARNESS_CAPABILITIES, type HarnessCapability } from \"../capability-contract.ts\";\n\n/**\n * Versioned control-plane contracts. These records are the durable truth exchanged between the\n * deterministic kernel/runtime and replaceable execution-plane workers. They deliberately do not\n * contain callbacks, provider objects, tool implementations, or transcript messages.\n */\n\nexport const ORCHESTRATION_SCHEMA_VERSION = 1 as const;\n\n/** Shared durable-control bounds. Keep persisted orchestration records small enough to replay safely. */\nexport const MAX_ORCHESTRATION_IDENTIFIER_LENGTH = 512;\nexport const MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH = 128;\nexport const MAX_ORCHESTRATION_MODEL_ID_LENGTH = 512;\nexport const MAX_ORCHESTRATION_DESCRIPTION_LENGTH = 4 * 1024;\nexport const MAX_ORCHESTRATION_COLLECTION_LENGTH = 64;\nexport const MAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH = 16 * 1024;\n/**\n * Lifetime ceilings for the retained hot projection. Terminal records are intentionally retained,\n * so these limits match the durable worker-fleet ceiling rather than only counting active work.\n */\nexport const MAX_ORCHESTRATION_AGENT_BINDINGS = 256;\nexport const MAX_ORCHESTRATION_OBJECTIVES = 256;\nexport const MAX_ORCHESTRATION_TASKS = 256;\nexport const MAX_ORCHESTRATION_ATTEMPTS = 256;\nexport const MAX_ORCHESTRATION_CHECKPOINTS = 4_096;\nexport const MAX_ORCHESTRATION_APPROVALS = 256;\n/** Approval prompts and terminal handoffs may each retain one notification per attempt. */\nexport const MAX_ORCHESTRATION_NOTIFICATIONS = 512;\n/** Source goal state admits at most 512 evidence entries for one objective. */\nexport const MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE = 512;\nexport const MAX_ORCHESTRATION_EVIDENCE = 4_096;\nexport const MAX_ORCHESTRATION_CHECKPOINT_SUMMARY_LENGTH = 4 * 1024;\n/** Absolute durable lineage bound enforced even when a profile requests broader recursion. */\nexport const MAX_ORCHESTRATION_AGENT_DEPTH = 8;\n/** Retained direct-child identity bound enforced even when a profile requests broader fan-out. */\nexport const MAX_ORCHESTRATION_DIRECT_CHILDREN = 64;\n/** One changed retained map value; aggregate projection accounting remains the authoritative ceiling. */\nexport const MAX_ORCHESTRATION_RETAINED_RECORD_BYTES = 1024 * 1024;\n/** Leaves room for bounded idempotency evidence and the snapshot envelope below the on-disk ceiling. */\nexport const MAX_ORCHESTRATION_PROJECTION_BYTES = 24 * 1024 * 1024;\nexport const MAX_ORCHESTRATION_SNAPSHOT_IDEMPOTENCY_BYTES = 4 * 1024 * 1024;\nexport const MAX_ORCHESTRATION_PROJECTION_SNAPSHOT_BYTES = 32 * 1024 * 1024;\n/** Matches the bounded worker/process result contract retained by the execution plane. */\nexport const MAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES = 512 * 1024;\nexport const MAX_WORKER_AUTHORITY_PATHS = 64;\nexport const MAX_WORKER_AUTHORITY_PATH_LENGTH = 4 * 1024;\nexport const MAX_WORKER_SOUL_LENGTH = 16 * 1024;\n\nexport const WORKER_ROLES = [\n\t\"orchestrator\",\n\t\"planner\",\n\t\"explorer\",\n\t\"implementer\",\n\t\"operator\",\n\t\"verifier\",\n\t\"database\",\n] as const;\nexport type WorkerRole = (typeof WORKER_ROLES)[number];\n\nexport const ORCHESTRATION_THINKING_LEVELS = [\n\t\"off\",\n\t\"minimal\",\n\t\"low\",\n\t\"medium\",\n\t\"high\",\n\t\"xhigh\",\n\t\"max\",\n\t\"ultra\",\n] as const;\nexport type OrchestrationThinkingLevel = (typeof ORCHESTRATION_THINKING_LEVELS)[number];\n\nexport interface OrchestrationModelBinding {\n\tprovider: string;\n\tmodelId: string;\n\tthinkingLevel: OrchestrationThinkingLevel;\n}\n\nexport interface OrchestrationModelPolicy {\n\tmode: \"fixed\" | \"ordered-fallback\";\n\tcandidates: readonly OrchestrationModelBinding[];\n}\n\n/** Constrained direct-argv launcher policy. This is allowlisting, not OS/container isolation. */\nexport interface OrchestrationExecutionPolicy {\n\tallowedExecutables: readonly string[];\n\tallowedEnvironmentVariables: readonly string[];\n\tmaxOutputBytes: number;\n}\n\n/** Outbound recursive delegation authority retained with an immutable worker profile snapshot. */\nexport interface OrchestrationDelegationLimits {\n\t/** Greatest absolute AgentBindingContract.depth that this worker may create. */\n\tmaxDepth: number;\n\t/** Greatest number of retained direct child identities that this worker may create. */\n\tmaxChildrenPerAgent: number;\n\t/** Greatest number of retained non-root identities across this durable session. */\n\tmaxNestedAgentsPerSession?: number;\n}\n\nexport const OBJECTIVE_STATUSES = [\"active\", \"paused\", \"completed\", \"cancelled\"] as const;\nexport type ObjectiveStatus = (typeof OBJECTIVE_STATUSES)[number];\n\nexport const TASK_STATUSES = [\"pending\", \"ready\", \"running\", \"blocked\", \"completed\", \"failed\", \"cancelled\"] as const;\nexport type OrchestrationTaskStatus = (typeof TASK_STATUSES)[number];\n\nexport const ATTEMPT_STATUSES = [\n\t\"queued\",\n\t\"leased\",\n\t\"running\",\n\t\"suspended\",\n\t\"completed\",\n\t\"partial\",\n\t\"blocked\",\n\t\"failed\",\n\t\"cancelled\",\n\t\"expired\",\n] as const;\nexport type AttemptStatus = (typeof ATTEMPT_STATUSES)[number];\n\nexport const WORKER_RESULT_STATUSES = [\"completed\", \"partial\", \"blocked\", \"failed\", \"cancelled\"] as const;\nexport type WorkerResultContractStatus = (typeof WORKER_RESULT_STATUSES)[number];\n\nexport type AgentBindingStatus = \"registered\" | \"active\" | \"suspended\" | \"resuming\" | \"retired\";\n\nexport interface AgentResumeContext {\n\tprovider: \"pi\" | \"external\";\n\tsessionId: string;\n\tsessionDir?: string;\n\tsessionFile?: string;\n\tcwd: string;\n\tworktreeLaneKey?: string;\n\torchestrationProfileId?: string;\n\tresourceProfileNames: readonly string[];\n\tmodelRef?: string;\n\tcontextPointers: readonly ResourcePointer[];\n\tlatestCheckpointId?: string;\n}\n\n/** Provider-neutral logical identity shared by durable orchestration and process supervision. */\nexport interface AgentIdentityContract {\n\tagentId: string;\n\tresumeContext: AgentResumeContext;\n}\n\n/** Durable logical identity. A replacement OS process resumes this same binding after interruption. */\nexport interface AgentBindingContract extends AgentIdentityContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\t/** Direct creator in the durable orchestration tree. Root agents omit this field. */\n\tparentAgentId?: string;\n\t/** Stable root identity retained across bounded recursive delegation depth. */\n\trootAgentId: string;\n\t/** Durable lineage depth. Fleet admission enforces the host-configured depth ceiling. */\n\tdepth: number;\n\trole: WorkerRole;\n\tstatus: AgentBindingStatus;\n\tactiveAttemptId?: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface RiskBudget {\n\t/**\n\t * Budget-counted tokens, not raw provider totals: input/output/cache-write tokens charge at\n\t * face value, prompt-cache reads at CACHE_READ_BUDGET_WEIGHT (see capability-gateway.ts).\n\t * Charging cache reads fully would turn this into a request counter, since every request\n\t * re-reads the fixed system prompt.\n\t */\n\tmaxTokens?: number;\n\tmaxWallClockMs?: number;\n\tmaxCostUsd?: number;\n\tmaxAttempts?: number;\n\tmaxToolCalls?: number;\n\trequireApprovalAboveCostUsd?: number;\n}\n\nexport interface AcceptanceCriterion {\n\tid: string;\n\tdescription: string;\n\trequired: boolean;\n\tevaluator?: string;\n}\n\nexport interface ObjectiveContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tobjectiveId: string;\n\ttitle: string;\n\tdescription: string;\n\tstatus: ObjectiveStatus;\n\tconstraints: readonly string[];\n\tacceptanceCriteria: readonly AcceptanceCriterion[];\n\triskBudget: RiskBudget;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface TaskContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\ttaskId: string;\n\tobjectiveId: string;\n\ttitle: string;\n\tdescription: string;\n\trole: WorkerRole;\n\tstatus: OrchestrationTaskStatus;\n\tdependsOn: readonly string[];\n\trequiredCapabilities: readonly HarnessCapability[];\n\tacceptanceCriterionIds: readonly string[];\n\t/** Implementer task this verifier task must independently reconcile. */\n\tverificationOfTaskId?: string;\n\triskBudget: RiskBudget;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport const RESOURCE_POINTER_KINDS = [\n\t\"repository\",\n\t\"worktree\",\n\t\"artifact\",\n\t\"evidence\",\n\t\"memory-query\",\n\t\"skill\",\n\t\"prompt\",\n\t\"service\",\n] as const;\nexport type ResourcePointerKind = (typeof RESOURCE_POINTER_KINDS)[number];\n\nexport function isResourcePointerKind(value: unknown): value is ResourcePointerKind {\n\treturn RESOURCE_POINTER_KINDS.some((kind) => kind === value);\n}\n\nexport interface ResourcePointer {\n\tid: string;\n\tkind: ResourcePointerKind;\n\turi: string;\n\treadOnly: boolean;\n\tdigest?: string;\n\tmetadata?: JsonObject;\n}\n\n/** Bounded metadata-only resources retained in one worker execution contract. */\nexport const MAX_WORKER_RESOURCE_POINTERS = 64;\nexport const MAX_WORKER_RESOURCE_PATH_LENGTH = 4096;\nexport const MAX_WORKER_RESOURCE_METADATA_NAME_LENGTH = 256;\n\n/** Lightweight metadata catalogued without importing the executable tool module. */\nexport interface ToolCapabilityManifest {\n\ttoolName: string;\n\tmoduleSpecifier: string;\n\tcapabilities: readonly HarnessCapability[];\n\troles: readonly WorkerRole[];\n\tenforcements: readonly CapabilityEnforcementKind[];\n\tsourcePath?: string;\n}\n\nexport interface OrchestrationProfile {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tprofileId: string;\n\tdescription: string;\n\trole: WorkerRole;\n\tmodelPolicy: OrchestrationModelPolicy;\n\tcapabilityCeiling: readonly HarnessCapability[];\n\ttoolNames: readonly string[];\n\tresourceProfileNames: readonly string[];\n\t/** Optional preset-routing metadata retained for authored profiles; never an admission allowlist. */\n\tdispatchProfileIds: readonly string[];\n\texecutionPolicy?: OrchestrationExecutionPolicy;\n\t/** Omitted authored profiles use the host ceiling; adaptive profiles carry a lean explicit limit. */\n\tdelegationLimits?: OrchestrationDelegationLimits;\n\tbudget: RiskBudget;\n\t/** Authored scheduling hint retained in the snapshot; the global scheduler owns actual concurrency. */\n\tmaxConcurrent: number;\n\tleaseTtlMs: number;\n\trequireIndependentVerification: boolean;\n\t/** Owner-pinned verifier profile. Required when independent verification is enabled. */\n\tverificationProfileId?: string;\n\t/** Resolved origin retained for controlled improvements; omitted from authored JSON. */\n\tsourcePath?: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\n/** Admission-time worker profile materialization. Profile files are never consulted after this is persisted. */\nexport interface WorkerProfileExecutionContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tprofile: OrchestrationProfile;\n\tmodelBinding: OrchestrationModelBinding;\n\tauthority: WorkerExecutionAuthorityContract;\n\t/** Metadata-only resources fixed at admission; their content remains lazy and non-durable. */\n\tresourcePointers: readonly ResourcePointer[];\n\t/** Resolved resource-profile identity text. Other worker resources are represented by profile tools. */\n\tsoul?: string;\n}\n\n/** Effective authority admitted for one materialized worker profile. */\nexport interface WorkerExecutionAuthorityContract {\n\tcapabilities: readonly HarnessCapability[];\n\ttoolNames: readonly string[];\n\treadPaths: readonly string[];\n\twritePaths: readonly string[];\n\tdeniedPaths: readonly string[];\n\tbudget: RiskBudget;\n}\n\n/** Immutable execution contract owned by the runtime, including any mandatory verifier. */\nexport interface WorkerExecutionContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tworker: WorkerProfileExecutionContract;\n\tverifier?: WorkerProfileExecutionContract;\n}\n\n/** Durable dispatch metadata. Model/tool choices are retained in the runtime-owned executionContract. */\nexport interface OrchestrationDispatchRequest {\n\ttaskId: string;\n\tprofileId: string;\n\tinstructions: string;\n\tresourcePointerIds: readonly string[];\n\t/** Direct logical-agent creator for recursively delegated in-process work. */\n\tparentAgentId?: string;\n\t/** Runtime-owned goal/task correlation. Omitted by legacy records and normalized to an empty list. */\n\trequirementIds?: readonly string[];\n\t/** Execution owner. Omitted on legacy records and normalized to in-process. */\n\texecutionKind?: \"in-process\" | \"managed-process\";\n\t/** Stable external lane identity shared by successive managed-process turns. */\n\tlogicalLaneId?: string;\n\t/** Monotonic dispatch sequence within a managed-process logical lane. */\n\tdispatchSequence?: number;\n\t/** Durable mailbox message whose task-bearing intent owns this logical-agent turn. */\n\tcontrolMessageId?: string;\n\t/** External provider identity retained for routing and diagnostics. */\n\tprovider?: string;\n\t/** Owner approval or standing-grant record that authorized an external launch. */\n\tauthorizationId?: string;\n\t/** Worktree-sync lane claimed by the external dispatcher. */\n\tworktreeLaneKey?: string;\n\t/** Immutable sanitized parent context captured for this persistent logical worker at birth. */\n\tbirthContextForkReference?: WorkerContextForkReference;\n\t/** Runtime-owned immutable worker materialization. Never accepted from a model tool call. */\n\texecutionContract?: WorkerExecutionContract;\n}\n\nexport type CapabilityEnforcementKind =\n\t| \"path-scope\"\n\t| \"process-launcher\"\n\t| \"service-proxy\"\n\t| \"memory-broker\"\n\t| \"control-plane\";\n\nexport interface CapabilityDecision {\n\tcapability: HarnessCapability;\n\toutcome: \"allow\" | \"deny\";\n\treasonCode: string;\n\tsource: string;\n}\n\nexport interface ExecutionGrant {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tgrantId: string;\n\tobjectiveId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tsubjectId: string;\n\trole: WorkerRole;\n\tcapabilities: readonly HarnessCapability[];\n\tallowedTools: readonly string[];\n\tresources: readonly ResourcePointer[];\n\treadPaths: readonly string[];\n\twritePaths: readonly string[];\n\tdeniedPaths: readonly string[];\n\tbudget: RiskBudget;\n\tpolicyVersion: string;\n\tdecisionTrace: readonly CapabilityDecision[];\n\tissuedAt: string;\n\texpiresAt?: string;\n}\n\nexport interface AttemptLease {\n\tleaseId: string;\n\tattemptId: string;\n\townerId: string;\n\tfencingToken: number;\n\tissuedAt: string;\n\texpiresAt: string;\n}\n\n/** Restart-durable host retry ladder state for one resumable worker attempt. */\nexport interface AttemptRetryState {\n\t/** Scheduled retries already consumed; the initial execution is not included. */\n\tretriesUsed: number;\n\t/** Earliest instant at which the suspended attempt may receive a fresh lease. */\n\tnotBefore: string;\n}\n\n/** Complete cumulative active usage for one execution attempt. Restart downtime is never included. */\nexport interface AttemptUsageSnapshot {\n\ttoolCalls: number;\n\tinputTokens: number;\n\toutputTokens: number;\n\tcacheReadTokens: number;\n\tcacheWriteTokens: number;\n\t/** Provider-authoritative total; detail categories are not assumed to be additive. */\n\ttotalTokens: number;\n\tcostUsd: number;\n\tactiveWallClockMs: number;\n}\n\nexport interface AttemptCheckpoint {\n\tcheckpointId: string;\n\tattemptId: string;\n\tfencingToken: number;\n\tsummary: string;\n\tartifactIds: readonly string[];\n\tevidenceIds: readonly string[];\n\t/** Omitted only by legacy checkpoints created before durable usage accounting existed. */\n\tusage?: AttemptUsageSnapshot;\n\tcreatedAt: string;\n}\n\nexport interface ArtifactContract {\n\tartifactId: string;\n\tkind: \"diff\" | \"file\" | \"report\" | \"test-result\" | \"log\" | \"structured-data\";\n\turi: string;\n\tdigest?: string;\n\tsizeBytes?: number;\n\tcreatedAt: string;\n\tmetadata?: JsonObject;\n}\n\nexport interface EvidenceContract {\n\tevidenceId: string;\n\tcriterionId?: string;\n\tkind: \"observation\" | \"command\" | \"test\" | \"review\" | \"external\";\n\tsummary: string;\n\tartifactIds: readonly string[];\n\ttrusted: boolean;\n\tcreatedAt: string;\n\tmetadata?: JsonObject;\n}\n\nexport interface WorkerErrorContract {\n\tcode: string;\n\tmessage: string;\n\tretryable: boolean;\n\tdetails?: JsonObject;\n}\n\nexport interface WorkerUsageContract {\n\tinputTokens?: number;\n\toutputTokens?: number;\n\ttotalTokens?: number;\n\tcostUsd?: number;\n\twallClockMs: number;\n\ttoolCalls: number;\n}\n\nexport interface WorkerResultContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tresultId: string;\n\tobjectiveId: string;\n\ttaskId: string;\n\tattemptId: string;\n\tleaseId: string;\n\tfencingToken: number;\n\tstatus: WorkerResultContractStatus;\n\treasonCode: string;\n\tsummary: string;\n\tartifacts: readonly ArtifactContract[];\n\tevidence: readonly EvidenceContract[];\n\terrors: readonly WorkerErrorContract[];\n\tnextAction?: string;\n\tusage: WorkerUsageContract;\n\tcreatedAt: string;\n}\n\nexport interface ApprovalRequestContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tapprovalId: string;\n\tobjectiveId: string;\n\ttaskId?: string;\n\tattemptId?: string;\n\treasonCode: string;\n\tsummary: string;\n\trequestedCapabilities: readonly HarnessCapability[];\n\trequestedBudget?: RiskBudget;\n\treversible: boolean;\n\tcreatedAt: string;\n}\n\nexport const APPROVAL_OUTCOMES = [\"approved\", \"rejected\"] as const;\nexport type ApprovalOutcome = (typeof APPROVAL_OUTCOMES)[number];\n\n/** Human decision only. Approval is not an execution grant; policy must compile a new grant afterward. */\nexport interface ApprovalResolutionContract {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tapprovalId: string;\n\toutcome: ApprovalOutcome;\n\treasonCode: string;\n\tresolvedAt: string;\n}\n\nexport const ORCHESTRATION_EVENT_TYPES = [\n\t\"objective.created\",\n\t\"objective.updated\",\n\t\"objective.evidence_recorded\",\n\t\"objective.paused\",\n\t\"objective.resumed\",\n\t\"objective.completed\",\n\t\"objective.cancelled\",\n\t\"task.created\",\n\t\"task.attempt_prepared\",\n\t\"task.ready\",\n\t\"task.failed\",\n\t\"task.verification_finished\",\n\t\"agent.registered\",\n\t\"agent.retired\",\n\t\"agent.suspended\",\n\t\"agent.resume_requested\",\n\t\"agent.resumed\",\n\t\"attempt.queued\",\n\t\"attempt.grant_bound\",\n\t\"attempt.leased\",\n\t\"attempt.started\",\n\t\"attempt.lease_renewed\",\n\t\"attempt.checkpointed\",\n\t\"attempt.suspended\",\n\t\"attempt.resumed\",\n\t\"attempt.cancelled\",\n\t\"attempt.finished\",\n\t\"attempt.lease_expired\",\n\t\"approval.requested\",\n\t\"approval.resolved\",\n\t\"notification.enqueued\",\n\t\"notification.delivered\",\n] as const;\n\nexport type OrchestrationEventType = (typeof ORCHESTRATION_EVENT_TYPES)[number];\nexport type OrchestrationActorKind = \"human\" | \"kernel\" | \"runtime\" | \"policy\" | \"router\" | \"worker\";\n\nexport interface OrchestrationEvent {\n\tschemaVersion: typeof ORCHESTRATION_SCHEMA_VERSION;\n\tordinal: number;\n\teventId: string;\n\ttype: OrchestrationEventType;\n\taggregateId: string;\n\tactor: OrchestrationActorKind;\n\toccurredAt: string;\n\tcorrelationId?: string;\n\tcausationId?: string;\n\tidempotencyKey?: string;\n\tpayload: JsonObject;\n}\n\nexport interface AppendOrchestrationEventInput {\n\ttype: OrchestrationEventType;\n\taggregateId: string;\n\tactor: OrchestrationActorKind;\n\tcorrelationId?: string;\n\tcausationId?: string;\n\tidempotencyKey?: string;\n\tpayload: JsonObject;\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n\treturn typeof value === \"string\" && value.length > 0;\n}\n\nfunction isJsonValue(value: unknown, depth = 0): value is JsonValue {\n\tif (depth > 30) return false;\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return true;\n\tif (typeof value === \"number\") return Number.isFinite(value);\n\tif (Array.isArray(value)) return value.every((entry) => isJsonValue(entry, depth + 1));\n\tif (!isPlainRecord(value)) return false;\n\treturn Object.values(value).every((entry) => isJsonValue(entry, depth + 1));\n}\n\nfunction includesString<const T extends readonly string[]>(values: T, value: unknown): value is T[number] {\n\treturn typeof value === \"string\" && values.includes(value);\n}\n\nexport function isHarnessCapability(value: unknown): value is HarnessCapability {\n\treturn includesString(HARNESS_CAPABILITIES, value);\n}\n\n/** Clone a runtime value into the persisted JSON domain, rejecting unsupported or over-deep data. */\nexport function toJsonObject(value: unknown): JsonObject {\n\tif (!isPlainRecord(value) || !isJsonValue(value)) {\n\t\tthrow new TypeError(\"Value is not a valid orchestration JSON object.\");\n\t}\n\treturn structuredClone(value);\n}\n\nexport function isOrchestrationEvent(value: unknown): value is OrchestrationEvent {\n\tif (!isPlainRecord(value)) return false;\n\treturn (\n\t\tvalue.schemaVersion === ORCHESTRATION_SCHEMA_VERSION &&\n\t\tNumber.isSafeInteger(value.ordinal) &&\n\t\tNumber(value.ordinal) > 0 &&\n\t\tisNonEmptyString(value.eventId) &&\n\t\tincludesString(ORCHESTRATION_EVENT_TYPES, value.type) &&\n\t\tisNonEmptyString(value.aggregateId) &&\n\t\tincludesString([\"human\", \"kernel\", \"runtime\", \"policy\", \"router\", \"worker\"] as const, value.actor) &&\n\t\tisNonEmptyString(value.occurredAt) &&\n\t\t(value.correlationId === undefined || isNonEmptyString(value.correlationId)) &&\n\t\t(value.causationId === undefined || isNonEmptyString(value.causationId)) &&\n\t\t(value.idempotencyKey === undefined || isNonEmptyString(value.idempotencyKey)) &&\n\t\tisPlainRecord(value.payload) &&\n\t\tisJsonValue(value.payload)\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-registry.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/profile-registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,cAAc,EACd,4BAA4B,EAC5B,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EAEf,YAAY,EACZ,sBAAsB,EACtB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"profile-registry.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/profile-registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,cAAc,EACd,4BAA4B,EAC5B,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EAEf,YAAY,EACZ,sBAAsB,EACtB,MAAM,gBAAgB,CAAC;AAoBxB,OAAO,EAGN,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,MAAM,sBAAsB,CAAC;AAG9B,MAAM,WAAW,eAAe;IAC/B,SAAS,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC;CACvD;AAED,MAAM,WAAW,mBAAmB;IACnC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,KAAK,EAAE,yBAAyB,CAAC;IACjC,KAAK,EAAE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AS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,4BAA4B,CAAC;IACvC,MAAM,EAAE,eAAe,CAAC;IACxB,cAAc,EAAE,uBAAuB,CAAC;IACxC,aAAa,EAAE,SAAS,sBAAsB,EAAE,CAAC;IACjD,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;IACtC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,aAAa,EAAE,MAAM,CAAC;CACtB,GAAG,yBAAyB,CAoC5B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describeToolCapabilityAuthority, resolveProfileToolCapability } from "../tool-capability-policy.js";
|
|
2
2
|
import { hasOnlyKeys, isPlainRecord } from "../util/value-guards.js";
|
|
3
|
-
import { HARNESS_CAPABILITIES, MAX_ORCHESTRATION_COLLECTION_LENGTH, MAX_ORCHESTRATION_DESCRIPTION_LENGTH, MAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH, MAX_ORCHESTRATION_IDENTIFIER_LENGTH, MAX_ORCHESTRATION_MODEL_ID_LENGTH, MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH, MAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES, MAX_WORKER_AUTHORITY_PATH_LENGTH, ORCHESTRATION_SCHEMA_VERSION, ORCHESTRATION_THINKING_LEVELS, toJsonObject, WORKER_ROLES, } from "./contracts.js";
|
|
3
|
+
import { HARNESS_CAPABILITIES, MAX_ORCHESTRATION_AGENT_BINDINGS, MAX_ORCHESTRATION_AGENT_DEPTH, MAX_ORCHESTRATION_COLLECTION_LENGTH, MAX_ORCHESTRATION_DESCRIPTION_LENGTH, MAX_ORCHESTRATION_DIRECT_CHILDREN, MAX_ORCHESTRATION_DISPATCH_INSTRUCTIONS_LENGTH, MAX_ORCHESTRATION_IDENTIFIER_LENGTH, MAX_ORCHESTRATION_MODEL_ID_LENGTH, MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH, MAX_ORCHESTRATION_PROCESS_OUTPUT_BYTES, MAX_WORKER_AUTHORITY_PATH_LENGTH, ORCHESTRATION_SCHEMA_VERSION, ORCHESTRATION_THINKING_LEVELS, toJsonObject, WORKER_ROLES, } from "./contracts.js";
|
|
4
4
|
import { ORCHESTRATION_PROFILE_TOOL_NAMES } from "./lane-tool-manifests.js";
|
|
5
5
|
import { DEFAULT_ROLE_CAPABILITY_CEILINGS, } from "./policy-compiler.js";
|
|
6
6
|
import { parseRiskBudget, validateRiskBudget } from "./risk-budget.js";
|
|
@@ -129,6 +129,19 @@ export function validateOrchestrationProfile(profile) {
|
|
|
129
129
|
if (!Number.isSafeInteger(profile.leaseTtlMs) || profile.leaseTtlMs <= 0) {
|
|
130
130
|
throw new OrchestrationProfileError(`Profile '${profile.profileId}' leaseTtlMs must be positive.`);
|
|
131
131
|
}
|
|
132
|
+
if (profile.delegationLimits &&
|
|
133
|
+
(!Number.isSafeInteger(profile.delegationLimits.maxDepth) ||
|
|
134
|
+
profile.delegationLimits.maxDepth < 0 ||
|
|
135
|
+
profile.delegationLimits.maxDepth > MAX_ORCHESTRATION_AGENT_DEPTH ||
|
|
136
|
+
!Number.isSafeInteger(profile.delegationLimits.maxChildrenPerAgent) ||
|
|
137
|
+
profile.delegationLimits.maxChildrenPerAgent < 0 ||
|
|
138
|
+
profile.delegationLimits.maxChildrenPerAgent > MAX_ORCHESTRATION_DIRECT_CHILDREN ||
|
|
139
|
+
(profile.delegationLimits.maxNestedAgentsPerSession !== undefined &&
|
|
140
|
+
(!Number.isSafeInteger(profile.delegationLimits.maxNestedAgentsPerSession) ||
|
|
141
|
+
profile.delegationLimits.maxNestedAgentsPerSession < 0 ||
|
|
142
|
+
profile.delegationLimits.maxNestedAgentsPerSession > MAX_ORCHESTRATION_AGENT_BINDINGS)))) {
|
|
143
|
+
throw new OrchestrationProfileError(`Profile '${profile.profileId}' delegationLimits are invalid.`);
|
|
144
|
+
}
|
|
132
145
|
try {
|
|
133
146
|
validateRiskBudget(profile.budget, `Profile '${profile.profileId}' budget`);
|
|
134
147
|
}
|
|
@@ -192,6 +205,7 @@ export function parseOrchestrationProfile(value, sourcePath) {
|
|
|
192
205
|
"resourceProfileNames",
|
|
193
206
|
"dispatchProfileIds",
|
|
194
207
|
"executionPolicy",
|
|
208
|
+
"delegationLimits",
|
|
195
209
|
"budget",
|
|
196
210
|
"maxConcurrent",
|
|
197
211
|
"leaseTtlMs",
|
|
@@ -206,6 +220,7 @@ export function parseOrchestrationProfile(value, sourcePath) {
|
|
|
206
220
|
const rawBudget = value.budget;
|
|
207
221
|
let budget;
|
|
208
222
|
const executionPolicy = value.executionPolicy;
|
|
223
|
+
const delegationLimits = value.delegationLimits;
|
|
209
224
|
if (!isPlainRecord(modelPolicy) ||
|
|
210
225
|
!hasOnlyKeys(modelPolicy, ["mode", "candidates"]) ||
|
|
211
226
|
!Array.isArray(modelPolicy.candidates) ||
|
|
@@ -226,6 +241,15 @@ export function parseOrchestrationProfile(value, sourcePath) {
|
|
|
226
241
|
!Number.isSafeInteger(executionPolicy.maxOutputBytes))) {
|
|
227
242
|
throw new OrchestrationProfileError("Orchestration profile executionPolicy is invalid.");
|
|
228
243
|
}
|
|
244
|
+
if (delegationLimits !== undefined &&
|
|
245
|
+
(!isPlainRecord(delegationLimits) ||
|
|
246
|
+
!hasOnlyKeys(delegationLimits, ["maxDepth", "maxChildrenPerAgent", "maxNestedAgentsPerSession"]) ||
|
|
247
|
+
!Number.isSafeInteger(delegationLimits.maxDepth) ||
|
|
248
|
+
!Number.isSafeInteger(delegationLimits.maxChildrenPerAgent) ||
|
|
249
|
+
(delegationLimits.maxNestedAgentsPerSession !== undefined &&
|
|
250
|
+
!Number.isSafeInteger(delegationLimits.maxNestedAgentsPerSession)))) {
|
|
251
|
+
throw new OrchestrationProfileError("Orchestration profile delegationLimits are invalid.");
|
|
252
|
+
}
|
|
229
253
|
const candidates = modelPolicy.candidates.map((candidate) => {
|
|
230
254
|
if (!isPlainRecord(candidate) || !hasOnlyKeys(candidate, ["provider", "modelId", "thinkingLevel"])) {
|
|
231
255
|
throw new OrchestrationProfileError("Orchestration profile model candidate is invalid.");
|
|
@@ -297,6 +321,17 @@ export function parseOrchestrationProfile(value, sourcePath) {
|
|
|
297
321
|
},
|
|
298
322
|
}
|
|
299
323
|
: {}),
|
|
324
|
+
...(isPlainRecord(delegationLimits)
|
|
325
|
+
? {
|
|
326
|
+
delegationLimits: {
|
|
327
|
+
maxDepth: Number(delegationLimits.maxDepth),
|
|
328
|
+
maxChildrenPerAgent: Number(delegationLimits.maxChildrenPerAgent),
|
|
329
|
+
...(delegationLimits.maxNestedAgentsPerSession !== undefined
|
|
330
|
+
? { maxNestedAgentsPerSession: Number(delegationLimits.maxNestedAgentsPerSession) }
|
|
331
|
+
: {}),
|
|
332
|
+
},
|
|
333
|
+
}
|
|
334
|
+
: {}),
|
|
300
335
|
budget,
|
|
301
336
|
maxConcurrent: Number(value.maxConcurrent),
|
|
302
337
|
leaseTtlMs: Number(value.leaseTtlMs),
|
|
@@ -326,6 +361,8 @@ function freezeProfile(profile) {
|
|
|
326
361
|
Object.freeze(clone.executionPolicy.allowedEnvironmentVariables);
|
|
327
362
|
Object.freeze(clone.executionPolicy);
|
|
328
363
|
}
|
|
364
|
+
if (clone.delegationLimits)
|
|
365
|
+
Object.freeze(clone.delegationLimits);
|
|
329
366
|
Object.freeze(clone.budget);
|
|
330
367
|
return Object.freeze(clone);
|
|
331
368
|
}
|