hiveagents-runtime 0.0.0-stage → 0.1.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +89 -2
  3. package/dist/adapter-kit.d.ts +37 -0
  4. package/dist/adapter-kit.js +34 -0
  5. package/dist/adapter-kit.js.map +1 -0
  6. package/dist/agent-Bj5YPrO7.d.ts +169 -0
  7. package/dist/agent-D6OXR7UF.js +24 -0
  8. package/dist/agent-D6OXR7UF.js.map +1 -0
  9. package/dist/agent-readiness-KSGNKTGK.js +19 -0
  10. package/dist/agent-readiness-KSGNKTGK.js.map +1 -0
  11. package/dist/capture-runtime-GP6NZ2ee.d.ts +54 -0
  12. package/dist/chunk-2RK74GCA.js +2397 -0
  13. package/dist/chunk-2RK74GCA.js.map +1 -0
  14. package/dist/chunk-3TIYA3K5.js +55 -0
  15. package/dist/chunk-3TIYA3K5.js.map +1 -0
  16. package/dist/chunk-6FIXXWNM.js +1 -0
  17. package/dist/chunk-6FIXXWNM.js.map +1 -0
  18. package/dist/chunk-6XIJW65Q.js +52 -0
  19. package/dist/chunk-6XIJW65Q.js.map +1 -0
  20. package/dist/chunk-7LDQKJKI.js +248 -0
  21. package/dist/chunk-7LDQKJKI.js.map +1 -0
  22. package/dist/chunk-CPN4DOXH.js +115 -0
  23. package/dist/chunk-CPN4DOXH.js.map +1 -0
  24. package/dist/chunk-DAXPAV2L.js +810 -0
  25. package/dist/chunk-DAXPAV2L.js.map +1 -0
  26. package/dist/chunk-DQEMIGKC.js +291 -0
  27. package/dist/chunk-DQEMIGKC.js.map +1 -0
  28. package/dist/chunk-DZFFGUIA.js +81 -0
  29. package/dist/chunk-DZFFGUIA.js.map +1 -0
  30. package/dist/chunk-EEUYQFCP.js +106 -0
  31. package/dist/chunk-EEUYQFCP.js.map +1 -0
  32. package/dist/chunk-G6JV7WV6.js +521 -0
  33. package/dist/chunk-G6JV7WV6.js.map +1 -0
  34. package/dist/chunk-GFVYNPLS.js +118 -0
  35. package/dist/chunk-GFVYNPLS.js.map +1 -0
  36. package/dist/chunk-GS5U3KUN.js +201 -0
  37. package/dist/chunk-GS5U3KUN.js.map +1 -0
  38. package/dist/chunk-HB7FBSH2.js +960 -0
  39. package/dist/chunk-HB7FBSH2.js.map +1 -0
  40. package/dist/chunk-HZFZX5A3.js +21 -0
  41. package/dist/chunk-HZFZX5A3.js.map +1 -0
  42. package/dist/chunk-J7VAYJKM.js +595 -0
  43. package/dist/chunk-J7VAYJKM.js.map +1 -0
  44. package/dist/chunk-NCNSHOF7.js +52 -0
  45. package/dist/chunk-NCNSHOF7.js.map +1 -0
  46. package/dist/chunk-RH5A5U7G.js +202 -0
  47. package/dist/chunk-RH5A5U7G.js.map +1 -0
  48. package/dist/chunk-RX3XZENU.js +385 -0
  49. package/dist/chunk-RX3XZENU.js.map +1 -0
  50. package/dist/chunk-RXU2Q2HF.js +49 -0
  51. package/dist/chunk-RXU2Q2HF.js.map +1 -0
  52. package/dist/chunk-TG7NTMTR.js +208 -0
  53. package/dist/chunk-TG7NTMTR.js.map +1 -0
  54. package/dist/chunk-TWGEYWMO.js +1217 -0
  55. package/dist/chunk-TWGEYWMO.js.map +1 -0
  56. package/dist/chunk-UZPDDQVJ.js +2910 -0
  57. package/dist/chunk-UZPDDQVJ.js.map +1 -0
  58. package/dist/chunk-WMKO5XOE.js +601 -0
  59. package/dist/chunk-WMKO5XOE.js.map +1 -0
  60. package/dist/chunk-WOQBVJH5.js +175 -0
  61. package/dist/chunk-WOQBVJH5.js.map +1 -0
  62. package/dist/chunk-WVT5SEKC.js +581 -0
  63. package/dist/chunk-WVT5SEKC.js.map +1 -0
  64. package/dist/cli.d.ts +1 -0
  65. package/dist/cli.js +26 -0
  66. package/dist/cli.js.map +1 -0
  67. package/dist/errors-BNHvvjn9.d.ts +98 -0
  68. package/dist/execution-halt-B8G0fOKS.d.ts +12 -0
  69. package/dist/execution-types-ClYYqPQP.d.ts +239 -0
  70. package/dist/host-ledger-VPRWVVOS.js +25 -0
  71. package/dist/host-ledger-VPRWVVOS.js.map +1 -0
  72. package/dist/hosted-runtime.d.ts +168 -0
  73. package/dist/hosted-runtime.js +858 -0
  74. package/dist/hosted-runtime.js.map +1 -0
  75. package/dist/index-B86C6VAD.d.ts +41 -0
  76. package/dist/index.d.ts +344 -0
  77. package/dist/index.js +8825 -0
  78. package/dist/index.js.map +1 -0
  79. package/dist/memory-items-BSTC0_R0.d.ts +28 -0
  80. package/dist/memory-tools.d.ts +222 -0
  81. package/dist/memory-tools.js +923 -0
  82. package/dist/memory-tools.js.map +1 -0
  83. package/dist/orchestration/dynamic.d.ts +854 -0
  84. package/dist/orchestration/dynamic.js +3150 -0
  85. package/dist/orchestration/dynamic.js.map +1 -0
  86. package/dist/orchestration/graph.d.ts +11 -0
  87. package/dist/orchestration/graph.js +9 -0
  88. package/dist/orchestration/graph.js.map +1 -0
  89. package/dist/orchestration/index.d.ts +2385 -0
  90. package/dist/orchestration/index.js +6409 -0
  91. package/dist/orchestration/index.js.map +1 -0
  92. package/dist/orchestration/log.d.ts +301 -0
  93. package/dist/orchestration/log.js +3058 -0
  94. package/dist/orchestration/log.js.map +1 -0
  95. package/dist/orchestration/memory.d.ts +711 -0
  96. package/dist/orchestration/memory.js +27 -0
  97. package/dist/orchestration/memory.js.map +1 -0
  98. package/dist/provider-DX5Mf0uq.d.ts +151 -0
  99. package/dist/routing/index.d.ts +29 -0
  100. package/dist/routing/index.js +386 -0
  101. package/dist/routing/index.js.map +1 -0
  102. package/dist/routing/learning/index.d.ts +433 -0
  103. package/dist/routing/learning/index.js +2502 -0
  104. package/dist/routing/learning/index.js.map +1 -0
  105. package/dist/runtime-BSjrnxeF.d.ts +283 -0
  106. package/dist/runtime-OISPXS4I.js +19 -0
  107. package/dist/runtime-OISPXS4I.js.map +1 -0
  108. package/dist/store-types-2YdceOMy.d.ts +78 -0
  109. package/dist/types-BB7KqceP.d.ts +52 -0
  110. package/dist/types-CIqkKXix.d.ts +86 -0
  111. package/dist/types-DTFc1qO6.d.ts +1065 -0
  112. package/dist/types-DYex3p7_.d.ts +88 -0
  113. package/docs/licenses/ruflo-memory-MIT.txt +21 -0
  114. package/docs/releases/0.1.0-beta.3.md +13 -0
  115. package/package.json +114 -4
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/orchestration/log/store-types.ts","../src/orchestration/log/capture-codec.ts","../src/orchestration/log/validation.ts","../src/orchestration/log/encoding.ts","../src/orchestration/log/capture.ts","../src/orchestration/log/capture-writes.ts"],"sourcesContent":["import type { LogCommit, LogDraft, LogPosition, PayloadReference, RunIdentity } from './types.js';\n\nexport interface LogSourceDescriptor { readonly format: 1; readonly sourceId: string; readonly systemId: string }\nexport interface LogEntry extends LogPosition {\n readonly format: 1; readonly requestId: string; readonly ordinal: number;\n readonly previousDigest: string; readonly record: LogDraft;\n}\n/** Trusted content verification only. This port grants no execution or retention authority. */\nexport interface LogPayloadVerifier {\n verify(reference: PayloadReference, options?: { signal?: AbortSignal }): Promise<{\n readonly kind: 'verified' | 'missing' | 'corrupt'; readonly reference: PayloadReference;\n }>;\n}\nexport interface LogStoreOptions {\n readonly databasePath: string; readonly systemId: string; readonly busyTimeoutMs?: number;\n readonly maxPending?: number; readonly supportedSchemas?: readonly Readonly<{ id: string; version: number }>[];\n readonly payloadVerifier?: LogPayloadVerifier;\n}\n/** A cursor is private DATA, neither a capability nor an independent whole-history proof. */\nexport interface LogCursor {\n readonly format: 1; readonly filterDigest: string; readonly after: LogPosition; readonly through: LogPosition;\n}\nexport interface LogQuery {\n readonly generation?: number; readonly runId?: string; readonly agentId?: string;\n readonly limit?: number; readonly cursor?: LogCursor;\n}\nexport interface LogPage {\n readonly source: LogSourceDescriptor; readonly through: LogPosition;\n readonly items: readonly LogEntry[]; readonly scanned: number; readonly nextCursor?: LogCursor;\n}\nexport type ReconstructionIssue = 'RUN_NOT_FOUND' | 'UNKNOWN_SCHEMA' | 'UNRESOLVED_CAUSAL_REFERENCE'\n | 'PAYLOAD_UNVERIFIED' | 'PAYLOAD_MISSING' | 'PAYLOAD_CORRUPT' | 'LOG_CORRUPT';\n/** Completeness refers ONLY to captured history at `through`, never operational resume or success. */\nexport interface RunReconstruction {\n readonly scope: 'captured-history'; readonly kind: 'complete' | 'incomplete' | 'corrupt';\n readonly identity: RunIdentity; readonly through?: LogPosition; readonly eventCount: number;\n readonly issues: readonly ReconstructionIssue[];\n}\ndeclare const prepared: unique symbol;\n/** Opaque preverified DATA. Reusable only with its original binding after rollback/ACK loss. */\nexport interface PreparedLogCommit { readonly [prepared]: true }\nexport type LogStoreErrorCode = 'INVALID_INPUT' | 'INTEGRITY' | 'STORAGE' | 'CLOSED' | 'BUSY'\n | 'REQUEST_CONFLICT' | 'PAYLOAD_UNAVAILABLE' | 'TRANSACTION_REQUIRED' | 'UNSUPPORTED_RUNTIME';\nconst errors = new WeakSet<object>();\nexport class LogStoreError extends Error {\n readonly code: LogStoreErrorCode;\n constructor(code: LogStoreErrorCode) {\n const safe = ['INVALID_INPUT', 'INTEGRITY', 'STORAGE', 'CLOSED', 'BUSY', 'REQUEST_CONFLICT', 'PAYLOAD_UNAVAILABLE', 'TRANSACTION_REQUIRED', 'UNSUPPORTED_RUNTIME'].includes(code) ? code : 'INVALID_INPUT';\n super(`Invalid execution log: ${safe}`); this.code = safe; this.name = 'LogStoreError'; errors.add(this); Object.freeze(this);\n }\n}\nexport function isLogStoreError(value: unknown): value is LogStoreError { return !!value && typeof value === 'object' && errors.has(value); }\nexport function logError(code: LogStoreErrorCode): never { throw new LogStoreError(code); }\nexport function safeFailure(error: unknown): never {\n if (isLogStoreError(error)) throw error;\n return logError('STORAGE');\n}\nexport type CapturedCommit = LogCommit;\n","import { types } from 'node:util';\nimport { canonical, freeze, hash, object } from '../../shared/json.js';\nimport type { AgentEvent, Usage } from '../../public/types.js';\nimport type { TraceEventInput } from '../tracing/types.js';\nimport { projectAgentEvent } from '../tracing/projector.js';\nimport { validateEvent, validateUsage } from '../tracing/validation.js';\nimport { captureLogCommit } from './validation.js';\nimport { digest } from './encoding.js';\nimport type { LogReceipt, RunIdentity } from './types.js';\n\nexport const AGENT_METADATA_SCHEMA = 'oar.sdk.agent-event-metadata';\nexport const CAPTURE_OPERATION_SCHEMA = 'oar.sdk.capture-operation';\nconst eventTypes = ['session.started', 'turn.started', 'message.delta', 'message.completed', 'tool.started', 'tool.updated', 'tool.completed',\n 'subagent.started', 'subagent.completed', 'interaction.requested', 'context.compacted', 'turn.completed', 'provider.event'];\nconst usageKeys = ['inputTokens', 'outputTokens', 'cachedInputTokens', 'cacheCreationTokens', 'reportedCostUsd'];\nconst eventKeys = ['type', 'sessionId', 'turnId', 'status', 'count', 'toolId', 'subagentId', 'interactionId', 'usage'];\nexport interface CaptureActual { readonly providerDigest: string; readonly modelDigest?: string; readonly attemptDigest: string; readonly transport?: 'exec' | 'control'; readonly phase?: 'startup' | 'turn'; readonly sessionIdDigest?: string; readonly transportEpochDigest?: string }\nexport interface CapturedAgentMetadata {\n readonly mode: 'metadata-only'; readonly invocationDigest: string; readonly actual: CaptureActual; readonly event: TraceEventInput;\n readonly sessionBinding?: Readonly<{ bindingDigest: string; sessionIdDigest: string; transportEpochDigest: string; providerDigest: string; modelDigest?: string; transport: 'exec' | 'control'; persistence: 'provider' | 'process' }>;\n}\nexport interface CapturedOperationMetadata {\n readonly mode: 'metadata-only'; readonly invocationDigest: string; readonly actual: CaptureActual;\n readonly stage: 'started' | 'settled' | 'interrupted'; readonly outcome?: 'returned' | 'failed' | 'halted'; readonly usage?: Usage;\n}\nexport function invalidCapture(): never { throw new TypeError('Invalid required log capture'); }\n/** Only selected own data descriptors are read. Ignored native fields are never traversed. */\nexport function field(value: unknown, key: string): unknown {\n if (!value || typeof value !== 'object' || types.isProxy(value) || Array.isArray(value)\n || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) return invalidCapture();\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (!descriptor) return undefined;\n if (!Object.hasOwn(descriptor, 'value')) return invalidCapture(); return descriptor.value;\n}\nexport function boundedInteger(value: unknown, min: number, max: number): number {\n if (!Number.isSafeInteger(value) || Number(value) < min || Number(value) > max) invalidCapture(); return value as number;\n}\nexport function boundedDataArray(input: unknown, max: number): readonly unknown[] {\n if (types.isProxy(input) || !Array.isArray(input) || Object.getPrototypeOf(input) !== Array.prototype || input.length > max || Object.getOwnPropertySymbols(input).length) invalidCapture();\n const descriptors = Object.getOwnPropertyDescriptors(input); if (Object.keys(descriptors).length !== input.length + 1) invalidCapture();\n for (let i = 0; i < input.length; i++) { const d = descriptors[String(i)]; if (!d || !Object.hasOwn(d, 'value') || !d.enumerable) invalidCapture(); }\n return input;\n}\nexport function idDigest(value: unknown): string {\n if (typeof value !== 'string' || !value.trim() || value.length > 4096 || Buffer.from(value).toString('utf8') !== value) invalidCapture(); return digest(value);\n}\nexport function captureIdentity(input: RunIdentity): RunIdentity {\n return captureLogCommit({ requestId: 'capture-validation', records: [{ identity: input, schema: { id: CAPTURE_OPERATION_SCHEMA, version: 1 }, type: 'capture.started', causal: [], payload: { inline: null } }] }).records[0]!.identity;\n}\n/** A receipt is trusted store DATA; its shape cannot supply an execution or closure capability. */\nexport function captureReceipt(input: unknown, sourceId?: string): LogReceipt {\n object(input, ['first', 'head', 'count']); if (input.count !== 1) invalidCapture();\n for (const value of [input.first, input.head]) {\n object(value, ['sourceId', 'sequence', 'digest']);\n if (typeof value.sourceId !== 'string' || !value.sourceId || value.sourceId.length > 128 || sourceId !== undefined && value.sourceId !== sourceId) invalidCapture();\n boundedInteger(value.sequence, 1, Number.MAX_SAFE_INTEGER); hash(value.digest);\n }\n if (canonical(input.first) !== canonical(input.head)) invalidCapture();\n return freeze({ first: { ...input.first as LogReceipt['first'] }, head: { ...input.head as LogReceipt['head'] }, count: 1 });\n}\nexport function captureActual(input: unknown): CaptureActual {\n object(input, ['provider', 'model', 'attemptId', 'transport', 'phase', 'sessionId', 'transportEpoch']);\n if (input.transport !== undefined && !['exec', 'control'].includes(input.transport as string) || input.phase !== undefined && !['startup', 'turn'].includes(input.phase as string)) invalidCapture();\n return freeze({ providerDigest: idDigest(input.provider), ...(input.model === undefined ? {} : { modelDigest: idDigest(input.model) }), attemptDigest: idDigest(input.attemptId), ...(input.transport === undefined ? {} : { transport: input.transport as 'exec' | 'control' }), ...(input.phase === undefined ? {} : { phase: input.phase as 'startup' | 'turn' }), ...(input.sessionId === undefined ? {} : { sessionIdDigest: idDigest(input.sessionId) }), ...(input.transportEpoch === undefined ? {} : { transportEpochDigest: idDigest(input.transportEpoch) }) });\n}\nexport function safeUsage(input: unknown): Usage {\n object(input, [...usageKeys, 'costMeaning', 'perModel']); const copy: Record<string, unknown> = {};\n for (const key of [...usageKeys, 'costMeaning']) if (Object.hasOwn(input, key)) copy[key] = input[key];\n if (Object.hasOwn(input, 'perModel')) {\n object(input.perModel); const names = Object.keys(input.perModel); if (names.length > 32) invalidCapture();\n const models: Record<string, unknown> = Object.create(null);\n for (const name of names) { object(input.perModel[name], usageKeys); models[idDigest(name)] = { ...input.perModel[name] }; }\n copy.perModel = models;\n }\n return freeze(validateUsage(copy));\n}\nfunction optionalId(input: unknown, key: string) { const value = field(input, key); return value === undefined ? {} : { [key]: idDigest(value) }; }\n/** Reuses the SDK projector on an owned minimal object; private text is counted, never serialized. */\nexport function captureAgentEvent(input: AgentEvent): TraceEventInput {\n const type = field(input, 'type'); if (typeof type !== 'string' || !eventTypes.includes(type)) invalidCapture();\n let safe: unknown;\n switch (type) {\n case 'session.started': safe = { type, session: { id: idDigest(field(field(input, 'session'), 'id')) } }; break;\n case 'turn.started': safe = { type, ...optionalId(input, 'turnId') }; break;\n case 'message.delta': case 'message.completed': {\n const text = field(input, 'text'); if (typeof text !== 'string') invalidCapture(); safe = { type, text }; break;\n }\n case 'tool.started': case 'tool.updated': case 'tool.completed': case 'subagent.started': case 'subagent.completed': safe = { type, id: idDigest(field(input, 'id')) }; break;\n case 'interaction.requested': {\n const binding = field(field(input, 'request'), 'binding'); safe = { type, request: { binding: { interactionId: idDigest(field(binding, 'interactionId')), sessionId: idDigest(field(binding, 'sessionId')), ...optionalId(binding, 'turnId') } } }; break;\n }\n case 'turn.completed': {\n const turn = field(input, 'turn'), usage = field(turn, 'usage'); safe = { type, turn: { ...optionalId(turn, 'id'), status: field(turn, 'status'), session: { id: idDigest(field(field(turn, 'session'), 'id')) }, ...(usage === undefined ? {} : { usage: safeUsage(usage) }) } }; break;\n }\n default: safe = { type };\n }\n return freeze(projectAgentEvent(safe as AgentEvent));\n}\n/** Preserve the actual complete SessionIdentity as a digest-bound fact without exposing cwd/native labels. */\nexport function captureSessionBinding(event: AgentEvent): CapturedAgentMetadata['sessionBinding'] {\n const type = field(event, 'type'), session = type === 'session.started' ? field(event, 'session') : type === 'turn.completed' ? field(field(event, 'turn'), 'session') : undefined;\n if (session === undefined || field(session, 'schemaVersion') === undefined) return undefined;\n const fields = ['schemaVersion', 'id', 'provider', 'model', 'cwd', 'transport', 'persistence', 'transportEpoch', 'createdAt'];\n const copy: Record<string, unknown> = {};\n for (const key of fields) { const value = field(session, key); if (key === 'model' && value === undefined) continue; copy[key] = value; }\n if (copy.schemaVersion !== 1 || !['exec', 'control'].includes(copy.transport as string) || !['provider', 'process'].includes(copy.persistence as string)) invalidCapture();\n for (const key of ['id', 'provider', 'cwd', 'transportEpoch', 'createdAt']) idDigest(copy[key]); if (copy.model !== undefined) idDigest(copy.model);\n return freeze({ bindingDigest: digest(canonical(copy)), sessionIdDigest: idDigest(copy.id), transportEpochDigest: idDigest(copy.transportEpoch), providerDigest: idDigest(copy.provider), ...(copy.model === undefined ? {} : { modelDigest: idDigest(copy.model) }), transport: copy.transport as 'exec' | 'control', persistence: copy.persistence as 'provider' | 'process' });\n}\nfunction validateActual(input: unknown): CaptureActual {\n object(input, ['providerDigest', 'modelDigest', 'attemptDigest', 'transport', 'phase', 'sessionIdDigest', 'transportEpochDigest']); hash(input.providerDigest); hash(input.attemptDigest); for (const key of ['modelDigest', 'sessionIdDigest', 'transportEpochDigest']) if (input[key] !== undefined) hash(input[key]);\n if (input.transport !== undefined && !['exec', 'control'].includes(input.transport as string) || input.phase !== undefined && !['startup', 'turn'].includes(input.phase as string)) invalidCapture();\n return input as unknown as CaptureActual;\n}\n/** Decoder accepts only the closed metadata grammar, never arbitrary TraceEvent fields/prose. */\nexport function decodeCaptureMetadata(schema: string, type: string, input: unknown): CapturedAgentMetadata | CapturedOperationMetadata {\n object(input, schema === AGENT_METADATA_SCHEMA ? ['mode', 'invocationDigest', 'actual', 'event', 'sessionBinding'] : ['mode', 'invocationDigest', 'actual', 'stage', 'outcome', 'usage']);\n if (input.mode !== 'metadata-only') invalidCapture(); hash(input.invocationDigest); validateActual(input.actual);\n if (schema === AGENT_METADATA_SCHEMA) {\n object(input.event, eventKeys); if (!eventTypes.includes(input.event.type as string) || input.event.type !== type) invalidCapture();\n for (const key of ['sessionId', 'turnId', 'toolId', 'subagentId', 'interactionId']) if (input.event[key] !== undefined) hash(input.event[key]);\n if (input.event.status !== undefined && !['completed', 'failed', 'interrupted', 'refused'].includes(input.event.status as string)) invalidCapture();\n const required: Record<string, string[]> = { 'session.started': ['sessionId'], 'message.delta': ['count'], 'message.completed': ['count'], 'tool.started': ['toolId'], 'tool.updated': ['toolId'], 'tool.completed': ['toolId'], 'subagent.started': ['subagentId'], 'subagent.completed': ['subagentId'], 'interaction.requested': ['interactionId', 'sessionId'], 'turn.completed': ['sessionId', 'status'] };\n const allowed = ['type', ...(required[type] ?? []), ...(type === 'turn.started' || type === 'turn.completed' || type === 'interaction.requested' ? ['turnId'] : []), ...(type === 'turn.completed' ? ['usage'] : [])];\n object(input.event, allowed); for (const key of required[type] ?? []) if (!Object.hasOwn(input.event, key)) invalidCapture();\n if (input.event.usage !== undefined) validateEncodedUsage(input.event.usage);\n if (input.sessionBinding !== undefined) {\n const binding = input.sessionBinding; object(binding, ['bindingDigest', 'sessionIdDigest', 'transportEpochDigest', 'providerDigest', 'modelDigest', 'transport', 'persistence']);\n for (const key of ['bindingDigest', 'sessionIdDigest', 'transportEpochDigest', 'providerDigest']) hash(binding[key]); if (binding.modelDigest !== undefined) hash(binding.modelDigest);\n if (!['exec', 'control'].includes(binding.transport as string) || !['provider', 'process'].includes(binding.persistence as string) || binding.sessionIdDigest !== input.event.sessionId) invalidCapture();\n }\n validateEvent(input.event);\n } else {\n if (schema !== CAPTURE_OPERATION_SCHEMA || !['started', 'settled', 'interrupted'].includes(input.stage as string) || type !== `capture.${input.stage}`) invalidCapture();\n if (input.stage === 'started' ? input.outcome !== undefined || input.usage !== undefined : !['returned', 'failed', 'halted'].includes(input.outcome as string)) invalidCapture();\n if (input.usage !== undefined) validateEncodedUsage(input.usage);\n }\n if (Buffer.byteLength(canonical(input)) > 16384) invalidCapture();\n return freeze(input) as unknown as CapturedAgentMetadata | CapturedOperationMetadata;\n}\nfunction validateEncodedUsage(input: unknown): void {\n object(input, [...usageKeys, 'costMeaning', 'perModel']);\n if (input.perModel !== undefined) { object(input.perModel); for (const key of Object.keys(input.perModel)) { hash(key); object(input.perModel[key], usageKeys); } }\n validateUsage(input);\n}\n","import { types } from 'node:util';\nimport { canonical, freeze, hash, identifier, jsonClone, object } from '../../shared/json.js';\nimport type { LogCommit } from './types.js';\n\nexport const LOG_FORMAT_LIMITS = Object.freeze({ depth: 64, nodes: 65536, records: 256, causal: 64,\n envelopeBytes: 16384, inlineBytes: 65536, batchInlineBytes: 1048576, batchBytes: 6 * 1048576 });\nfunction invalid(): never { throw new TypeError('Invalid execution log data'); }\nconst byteLength = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), 'byteLength')!.get!;\nfunction bounded(input: unknown): void {\n let nodes = 0, bytes = 0; const ancestors = new Set<object>();\n function visit(value: unknown, depth: number): void {\n if (++nodes > LOG_FORMAT_LIMITS.nodes || depth > LOG_FORMAT_LIMITS.depth) invalid();\n if (typeof value === 'string') {\n bytes += Buffer.byteLength(value); if (bytes > LOG_FORMAT_LIMITS.batchBytes || Buffer.from(value).toString('utf8') !== value) invalid(); return;\n }\n if (value === null || typeof value === 'boolean' || typeof value === 'number' && Number.isFinite(value)) return;\n if (!value || typeof value !== 'object' || types.isProxy(value) || ancestors.has(value)) invalid();\n if (Array.isArray(value) && value.length > LOG_FORMAT_LIMITS.nodes) invalid();\n const proto = Object.getPrototypeOf(value);\n if (Array.isArray(value) ? proto !== Array.prototype : proto !== Object.prototype && proto !== null) invalid();\n if (Object.getOwnPropertySymbols(value).length) invalid();\n ancestors.add(value);\n for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value))) {\n if (Array.isArray(value) && key === 'length') continue;\n if (!Object.hasOwn(descriptor, 'value') || !descriptor.enumerable) invalid();\n bytes += Buffer.byteLength(key); if (bytes > LOG_FORMAT_LIMITS.batchBytes || Buffer.from(key).toString('utf8') !== key) invalid(); visit(descriptor.value, depth + 1);\n }\n ancestors.delete(value);\n }\n visit(input, 0);\n}\nfunction closed(value: unknown, fields: readonly string[]): asserts value is Record<string, unknown> {\n object(value, fields); if (fields.some(field => !Object.hasOwn(value, field))) invalid();\n}\nfunction positive(value: unknown, zero = false): asserts value is number {\n if (!Number.isSafeInteger(value) || (value as number) < (zero ? 0 : 1)) invalid();\n}\n/** Strict data capture only. Payload-schema support and execution authority are checked by later consumers. */\nexport function captureLogCommit(input: unknown): LogCommit {\n try {\n bounded(input); const commit = jsonClone(input); closed(commit, ['requestId', 'records']); identifier(commit.requestId);\n if (!Array.isArray(commit.records) || !commit.records.length || commit.records.length > LOG_FORMAT_LIMITS.records) invalid();\n let totalInline = 0;\n for (const draft of commit.records) {\n closed(draft, ['identity', 'schema', 'type', 'causal', 'payload']); identifier(draft.type);\n closed(draft.identity, ['systemId', 'generation', 'runId', 'agentId', 'harness']);\n for (const key of ['systemId', 'runId', 'agentId']) identifier(draft.identity[key]); positive(draft.identity.generation);\n closed(draft.identity.harness, ['id', 'version', 'digest']); identifier(draft.identity.harness.id); identifier(draft.identity.harness.version); hash(draft.identity.harness.digest);\n closed(draft.schema, ['id', 'version']); identifier(draft.schema.id); positive(draft.schema.version);\n if (!Array.isArray(draft.causal) || draft.causal.length > LOG_FORMAT_LIMITS.causal) invalid();\n for (const position of draft.causal) { closed(position, ['sourceId', 'sequence', 'digest']); identifier(position.sourceId); positive(position.sequence); hash(position.digest); }\n object(draft.payload, ['inline', 'artifact']);\n if (Object.keys(draft.payload).length !== 1) invalid();\n if (Object.hasOwn(draft.payload, 'inline')) {\n const bytes = Buffer.byteLength(canonical(draft.payload.inline)); totalInline += bytes;\n if (bytes > LOG_FORMAT_LIMITS.inlineBytes || totalInline > LOG_FORMAT_LIMITS.batchInlineBytes) invalid();\n } else {\n const ref = draft.payload.artifact; closed(ref, ['sourceId', 'systemId', 'generation', 'digest', 'bytes', 'mediaType']);\n identifier(ref.sourceId); identifier(ref.systemId); positive(ref.generation); positive(ref.bytes, true); hash(ref.digest);\n if (ref.systemId !== draft.identity.systemId || ref.generation !== draft.identity.generation\n || ref.mediaType !== 'application/json' && ref.mediaType !== 'application/octet-stream') invalid();\n }\n const { payload: _, ...envelope } = draft;\n if (Buffer.byteLength(canonical(envelope)) > LOG_FORMAT_LIMITS.envelopeBytes) invalid();\n }\n if (Buffer.byteLength(canonical(commit)) > LOG_FORMAT_LIMITS.batchBytes) invalid();\n return freeze(commit) as unknown as LogCommit;\n } catch { return invalid(); }\n}\nexport function encodeLogCommit(input: unknown): string { return canonical(captureLogCommit(input)); }\nexport function decodeLogCommit(input: string | Uint8Array): LogCommit {\n try {\n if (typeof input !== 'string' && (types.isProxy(input) || !types.isUint8Array(input))) invalid();\n if (typeof input === 'string' ? Buffer.byteLength(input) > LOG_FORMAT_LIMITS.batchBytes : Reflect.apply(byteLength, input, []) > LOG_FORMAT_LIMITS.batchBytes) invalid();\n const text = typeof input === 'string' ? input : new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(input);\n const value = captureLogCommit(JSON.parse(text)); if (canonical(value) !== text) invalid(); return value;\n } catch { return invalid(); }\n}\n","import { createHash } from 'node:crypto';\nimport { canonical, freeze, hash, object } from '../../shared/json.js';\nimport { captureLogCommit } from './validation.js';\nimport { logError } from './store-types.js';\nimport type { LogEntry, LogSourceDescriptor } from './store-types.js';\nimport type { LogCommit, LogDraft } from './types.js';\n\nexport const MAX_EVENT_BYTES = 128 * 1024;\nexport function digest(text: string): string { return createHash('sha256').update(text).digest('hex'); }\nexport function genesis(source: LogSourceDescriptor): string { return digest(`oar-neutral-log-v1\\n${canonical(source)}`); }\nexport function capture(input: unknown, source: LogSourceDescriptor): LogCommit {\n try {\n const captured = captureLogCommit(input);\n for (const record of captured.records) if (record.identity.systemId !== source.systemId\n || 'artifact' in record.payload && record.payload.artifact.sourceId !== source.sourceId) logError('INVALID_INPUT');\n return captured;\n } catch { return logError('INVALID_INPUT'); }\n}\nexport function entryBody(source: LogSourceDescriptor, sequence: number, requestId: string, ordinal: number, previousDigest: string, record: LogDraft) {\n return { format: 1 as const, sourceId: source.sourceId, sequence, requestId, ordinal, previousDigest, record };\n}\nexport function decodeEntry(text: string, expectedDigest: unknown, source: LogSourceDescriptor): LogEntry {\n try {\n if (Buffer.byteLength(text) > MAX_EVENT_BYTES || digest(text) !== expectedDigest) logError('INTEGRITY');\n const body = JSON.parse(text); object(body, ['format', 'sourceId', 'sequence', 'requestId', 'ordinal', 'previousDigest', 'record']);\n if (Object.keys(body).length !== 7 || canonical(body) !== text || body.format !== 1 || body.sourceId !== source.sourceId\n || !Number.isSafeInteger(body.sequence) || Number(body.sequence) < 1 || !Number.isSafeInteger(body.ordinal) || Number(body.ordinal) < 1 || Number(body.ordinal) > 256) logError('INTEGRITY');\n hash(body.previousDigest); const checked = capture({ requestId: body.requestId, records: [body.record] }, source);\n return freeze({ format: 1, sourceId: source.sourceId, sequence: Number(body.sequence), requestId: checked.requestId,\n ordinal: Number(body.ordinal), previousDigest: body.previousDigest, record: checked.records[0]!, digest: expectedDigest as string });\n } catch { return logError('INTEGRITY'); }\n}\n","import { randomBytes } from 'node:crypto';\nimport { types } from 'node:util';\nimport { freeze, method, object } from '../../shared/json.js';\nimport { ExecutionHaltedError, isExecutionHalted } from '../../public/execution-halt.js';\nimport type { AgentEvent, Usage } from '../../public/types.js';\nimport type { LogCommit, LogJsonValue, LogReceipt, RunIdentity } from './types.js';\nimport { AGENT_METADATA_SCHEMA, CAPTURE_OPERATION_SCHEMA, boundedInteger, captureActual, captureAgentEvent, captureIdentity, captureReceipt, captureSessionBinding, decodeCaptureMetadata, safeUsage } from './capture-codec.js';\nimport { captureLogCommit } from './validation.js';\nimport { awaitCaptureWrite, captureWriteOptions } from './capture-writes.js';\nexport interface RequiredLogCaptureOptions {\n readonly store: { append(commit: LogCommit): Promise<LogReceipt> }; readonly identity: RunIdentity;\n readonly actual: { readonly provider: string; readonly model?: string; readonly attemptId: string; readonly transport?: 'exec' | 'control'; readonly phase?: 'startup' | 'turn'; readonly sessionId?: string; readonly transportEpoch?: string }; readonly maxPending?: number;\n readonly maxWriteMs?: number; readonly signal?: AbortSignal;\n}\nexport interface RequiredLogCapture {\n run<T>(work: () => Promise<T>): Promise<T>; observe(event: AgentEvent): Promise<LogReceipt>; drain(): Promise<void>;\n recordUsage(usage: Usage): void; markInterrupted(): void;\n readonly signal: AbortSignal;\n snapshot(): Readonly<{ state: 'idle' | 'starting' | 'running' | 'draining' | 'settled' | 'halted'; pending: number; maxPending: number; mode: 'metadata-only'; textReconstruction: 'unavailable' }>;\n}\n/** Awaited capture boundary. Completion means only this observed invocation settled, never a business postcondition. */\nexport function createRequiredLogCapture(options: RequiredLogCaptureOptions): RequiredLogCapture {\n object(options, ['store', 'identity', 'actual', 'maxPending', 'maxWriteMs', 'signal']); const { maxWriteMs, signal } = captureWriteOptions(options);\n const identity = captureIdentity(options.identity), actual = captureActual(options.actual), maxPending = boundedInteger(options.maxPending ?? 2, 1, 64);\n const append = method<(commit: LogCommit) => Promise<LogReceipt>>(options.store, 'append');\n const invocationDigest = randomBytes(32).toString('hex'), controller = new AbortController();\n const pending = new Set<Promise<LogReceipt>>(); let state: 'idle' | 'starting' | 'running' | 'draining' | 'settled' | 'halted' = 'idle';\n let failure: ExecutionHaltedError | undefined, usage: Usage | undefined, sourceId: string | undefined, interrupted = false;\n function halt(cause: unknown): ExecutionHaltedError {\n if (!failure) { failure = new ExecutionHaltedError({ ...(usage ? { observedUsage: usage } : {}) }, { cause }); state = 'halted'; controller.abort(failure); }\n return failure;\n }\n function write(schema: string, type: string, metadata: unknown): Promise<LogReceipt> {\n if (failure) return observedRejection(failure);\n if (pending.size >= maxPending) return observedRejection(halt(Error('CAPTURE_CAPACITY')));\n let operation: Promise<LogReceipt>;\n try {\n decodeCaptureMetadata(schema, type, metadata);\n const commit = captureLogCommit({ requestId: randomBytes(24).toString('hex'), records: [{ identity, schema: { id: schema, version: 1 }, type, causal: [], payload: { inline: metadata as LogJsonValue } }] });\n operation = Promise.resolve(append(commit));\n } catch (error) { return observedRejection(halt(error)); }\n const tracked = operation.then(value => { const receipt = captureReceipt(value, sourceId); sourceId = receipt.head.sourceId; return receipt; }).catch(error => { throw halt(error); }); pending.add(tracked);\n void tracked.then(() => pending.delete(tracked), () => pending.delete(tracked));\n return awaitCaptureWrite(tracked, maxWriteMs, state === 'draining' ? undefined : signal, halt);\n }\n function observedRejection(error: unknown): Promise<never> { const promise = Promise.reject(error); void promise.catch(() => {}); return promise; }\n async function drain(): Promise<void> {\n if (failure) throw failure;\n while (pending.size) await awaitCaptureWrite(Promise.allSettled([...pending]), maxWriteMs, undefined, halt);\n if (failure) throw failure;\n }\n function observe(event: AgentEvent): Promise<LogReceipt> {\n if (state !== 'running' || failure) return observedRejection(failure ?? halt(Error('CAPTURE_NOT_RUNNING')));\n try {\n const projected = captureAgentEvent(event); if (projected.usage) usage = projected.usage;\n const sessionBinding = captureSessionBinding(event);\n return write(AGENT_METADATA_SCHEMA, projected.type, freeze({ mode: 'metadata-only', invocationDigest, actual, event: projected, ...(sessionBinding ? { sessionBinding } : {}) }));\n } catch (error) { return observedRejection(halt(error)); }\n }\n async function run<T>(work: () => Promise<T>): Promise<T> {\n if (state !== 'idle' || typeof work !== 'function' || types.isProxy(work)) throw failure ?? halt(Error('CAPTURE_ALREADY_USED'));\n state = 'starting';\n await write(CAPTURE_OPERATION_SCHEMA, 'capture.started', freeze({ mode: 'metadata-only', invocationDigest, actual, stage: 'started' }));\n if (failure) throw failure; state = 'running';\n let result: T | undefined, original: unknown, failed = false;\n try { result = await work(); } catch (error) { original = error; failed = true; const observed = errorUsage(error); if (observed) usage = observed; }\n if (!failure) state = 'draining'; let secondary: unknown;\n try {\n await drain();\n const stage = interrupted ? 'interrupted' : 'settled';\n await write(CAPTURE_OPERATION_SCHEMA, `capture.${stage}`, freeze({ mode: 'metadata-only', invocationDigest, actual, stage, outcome: failed ? isExecutionHalted(original) ? 'halted' : 'failed' : 'returned', ...(usage ? { usage } : {}) }));\n } catch (error) { secondary = error; }\n if (!secondary) state = 'settled';\n if (failed) {\n if (secondary && !isExecutionHalted(original)) throw new ExecutionHaltedError({ ...(usage ? { observedUsage: usage } : {}) }, { cause: original });\n throw original;\n }\n if (secondary) throw secondary; state = 'settled'; return result as T;\n }\n return Object.freeze({ run, observe, drain, recordUsage: (input: Usage) => { usage = safeUsage(input); }, markInterrupted: () => { interrupted = true; }, signal: controller.signal,\n snapshot: () => freeze({ state, pending: pending.size, maxPending, mode: 'metadata-only' as const, textReconstruction: 'unavailable' as const }) });\n}\nfunction errorUsage(error: unknown): Usage | undefined {\n const pending = [{ value: error, depth: 0 }], seen = new Set<object>();\n while (pending.length && seen.size < 64) {\n const { value, depth } = pending.shift()!;\n if (!value || typeof value !== 'object' || types.isProxy(value) || !types.isNativeError(value) || seen.has(value) || depth >= 16) continue; seen.add(value);\n const context = Object.getOwnPropertyDescriptor(value, 'context');\n if (context && Object.hasOwn(context, 'value') && context.value && typeof context.value === 'object' && !types.isProxy(context.value)) {\n const observed = Object.getOwnPropertyDescriptor(context.value, 'observedUsage');\n if (observed && Object.hasOwn(observed, 'value')) try { return safeUsage(observed.value); } catch { /* Unknown usage remains absent. */ }\n }\n const cause = Object.getOwnPropertyDescriptor(value, 'cause'); if (cause && Object.hasOwn(cause, 'value')) pending.push({ value: cause.value, depth: depth + 1 });\n const errors = Object.getOwnPropertyDescriptor(value, 'errors');\n if (errors && Object.hasOwn(errors, 'value') && !types.isProxy(errors.value) && Array.isArray(errors.value) && errors.value.length <= 64 - pending.length) {\n for (let i = 0; i < errors.value.length; i++) { const item = Object.getOwnPropertyDescriptor(errors.value, String(i)); if (item && Object.hasOwn(item, 'value')) pending.push({ value: item.value, depth: depth + 1 }); }\n }\n }\n return undefined;\n}\n","import { types } from 'node:util';\nimport { boundedInteger, invalidCapture } from './capture-codec.js';\nconst aborted = Object.getOwnPropertyDescriptor(AbortSignal.prototype, 'aborted')!.get!;\nconst reason = Object.getOwnPropertyDescriptor(AbortSignal.prototype, 'reason')!.get!;\nexport function captureWriteOptions(input: { maxWriteMs?: number; signal?: AbortSignal }) {\n const maxWriteMs = boundedInteger(input.maxWriteMs ?? 5000, 1, 30000), signal = input.signal;\n if (signal !== undefined) {\n if (types.isProxy(signal)) invalidCapture();\n try { Reflect.apply(aborted, signal, []); } catch { invalidCapture(); }\n }\n return { maxWriteMs, signal };\n}\n/** Abandoned writes remain observed/charged by the owner; cancellation is not a durable ACK. */\nexport function awaitCaptureWrite<T>(work: Promise<T>, maxWriteMs: number, signal: AbortSignal | undefined, halt: (cause: unknown) => Error): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n let settled = false, timer: ReturnType<typeof setTimeout> | undefined;\n const clean = () => { if (timer) clearTimeout(timer); if (signal) EventTarget.prototype.removeEventListener.call(signal, 'abort', cancel); };\n const complete = (callback: () => void) => { if (settled) return; settled = true; clean(); callback(); };\n const cancel = () => complete(() => reject(halt(signal ? Reflect.apply(reason, signal, []) : Error('CAPTURE_WRITE_INTERRUPTED'))));\n work.then(value => complete(() => resolve(value)), error => complete(() => reject(error)));\n if (signal && Reflect.apply(aborted, signal, [])) { cancel(); return; }\n if (signal) EventTarget.prototype.addEventListener.call(signal, 'abort', cancel, { once: true });\n timer = setTimeout(() => complete(() => reject(halt(Error('CAPTURE_WRITE_TIMEOUT')))), maxWriteMs);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2CA,IAAM,SAAS,oBAAI,QAAgB;AAC5B,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACT,YAAY,MAAyB;AACnC,UAAM,OAAO,CAAC,iBAAiB,aAAa,WAAW,UAAU,QAAQ,oBAAoB,uBAAuB,wBAAwB,qBAAqB,EAAE,SAAS,IAAI,IAAI,OAAO;AAC3L,UAAM,0BAA0B,IAAI,EAAE;AAAG,SAAK,OAAO;AAAM,SAAK,OAAO;AAAiB,WAAO,IAAI,IAAI;AAAG,WAAO,OAAO,IAAI;AAAA,EAC9H;AACF;AACO,SAAS,gBAAgB,OAAwC;AAAE,SAAO,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,OAAO,IAAI,KAAK;AAAG;AACrI,SAAS,SAAS,MAAgC;AAAE,QAAM,IAAI,cAAc,IAAI;AAAG;AACnF,SAAS,YAAY,OAAuB;AACjD,MAAI,gBAAgB,KAAK,EAAG,OAAM;AAClC,SAAO,SAAS,SAAS;AAC3B;;;ACxDA,SAAS,SAAAA,cAAa;;;ACAtB,SAAS,aAAa;AAIf,IAAM,oBAAoB,OAAO,OAAO;AAAA,EAAE,OAAO;AAAA,EAAI,OAAO;AAAA,EAAO,SAAS;AAAA,EAAK,QAAQ;AAAA,EAC9F,eAAe;AAAA,EAAO,aAAa;AAAA,EAAO,kBAAkB;AAAA,EAAS,YAAY,IAAI;AAAQ,CAAC;AAChG,SAAS,UAAiB;AAAE,QAAM,IAAI,UAAU,4BAA4B;AAAG;AAC/E,IAAM,aAAa,OAAO,yBAAyB,OAAO,eAAe,WAAW,SAAS,GAAG,YAAY,EAAG;AAC/G,SAAS,QAAQ,OAA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G,SAAQ,KAAK,EAAE,OAAO,MAAM,OAAO,OAAO,QAAQ,EAAE,CAAC;AAChK,UAAMC,UAAS,OAAO,yBAAyB,OAAO,QAAQ;AAC9D,QAAIA,WAAU,OAAO,OAAOA,SAAQ,OAAO,KAAK,CAACD,OAAM,QAAQC,QAAO,KAAK,KAAK,MAAM,QAAQA,QAAO,KAAK,KAAKA,QAAO,MAAM,UAAU,KAAK,QAAQ,QAAQ;AACzJ,eAAS,IAAI,GAAG,IAAIA,QAAO,MAAM,QAAQ,KAAK;AAAE,cAAM,OAAO,OAAO,yBAAyBA,QAAO,OAAO,OAAO,CAAC,CAAC;AAAG,YAAI,QAAQ,OAAO,OAAO,MAAM,OAAO,EAAG,SAAQ,KAAK,EAAE,OAAO,KAAK,OAAO,OAAO,QAAQ,EAAE,CAAC;AAAA,MAAG;AAAA,IAC1N;AAAA,EACF;AACA,SAAO;AACT;","names":["types","field","types","types","types","types","types","errors"]}
@@ -0,0 +1,52 @@
1
+ import {
2
+ AgentRuntimeError
3
+ } from "./chunk-TG7NTMTR.js";
4
+
5
+ // src/public/execution-halt.ts
6
+ import { types } from "node:util";
7
+ var halts = /* @__PURE__ */ new WeakSet();
8
+ var ExecutionHaltedError = class extends AgentRuntimeError {
9
+ constructor(context = {}, options) {
10
+ super("EXECUTION_HALTED", "Execution halted", { ...context, retryable: false }, options);
11
+ halts.add(this);
12
+ }
13
+ };
14
+ var MAX_NODES = 64;
15
+ var MAX_DEPTH = 16;
16
+ function inspect(error) {
17
+ const pending = [{ value: error, depth: 0 }], seen = /* @__PURE__ */ new Set();
18
+ while (pending.length) {
19
+ const { value, depth } = pending.pop();
20
+ if (!value || typeof value !== "object" || types.isProxy(value)) continue;
21
+ if (halts.has(value)) return "halted";
22
+ if (!types.isNativeError(value) || seen.has(value)) continue;
23
+ if (seen.size >= MAX_NODES || depth >= MAX_DEPTH) return "uninspectable";
24
+ seen.add(value);
25
+ const cause = Object.getOwnPropertyDescriptor(value, "cause");
26
+ if (cause && Object.hasOwn(cause, "value")) pending.push({ value: cause.value, depth: depth + 1 });
27
+ const descriptor = Object.getOwnPropertyDescriptor(value, "errors");
28
+ if (!descriptor || !Object.hasOwn(descriptor, "value") || types.isProxy(descriptor.value) || !Array.isArray(descriptor.value)) continue;
29
+ const errors = descriptor.value;
30
+ if (errors.length > MAX_NODES || pending.length + errors.length > MAX_NODES) return "uninspectable";
31
+ for (let i = 0; i < errors.length; i++) {
32
+ const item = Object.getOwnPropertyDescriptor(errors, String(i));
33
+ if (item && Object.hasOwn(item, "value")) pending.push({ value: item.value, depth: depth + 1 });
34
+ }
35
+ }
36
+ return "clear";
37
+ }
38
+ function isExecutionHalted(error) {
39
+ return inspect(error) !== "clear";
40
+ }
41
+ function rethrowExecutionHalt(error) {
42
+ const state = inspect(error);
43
+ if (state === "halted") throw error;
44
+ if (state === "uninspectable") throw new ExecutionHaltedError({ sanitizedDiagnostics: { reason: "ERROR_GRAPH_LIMIT" } }, { cause: error });
45
+ }
46
+
47
+ export {
48
+ ExecutionHaltedError,
49
+ isExecutionHalted,
50
+ rethrowExecutionHalt
51
+ };
52
+ //# sourceMappingURL=chunk-NCNSHOF7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/public/execution-halt.ts"],"sourcesContent":["import { types } from 'node:util';\nimport { AgentRuntimeError, type ErrorContext } from './errors.js';\n\nconst halts = new WeakSet<object>();\n/** A failed infrastructure boundary must stop execution, selection and dependent retries. */\nexport class ExecutionHaltedError extends AgentRuntimeError {\n constructor(context: Omit<ErrorContext, 'retryable'> = {}, options?: ErrorOptions) {\n super('EXECUTION_HALTED', 'Execution halted', { ...context, retryable: false }, options);\n halts.add(this);\n }\n}\nconst MAX_NODES = 64, MAX_DEPTH = 16;\ntype HaltState = 'clear' | 'halted' | 'uninspectable';\nfunction inspect(error: unknown): HaltState {\n const pending = [{ value: error, depth: 0 }], seen = new Set<object>();\n while (pending.length) {\n const { value, depth } = pending.pop()!;\n if (!value || typeof value !== 'object' || types.isProxy(value)) continue;\n if (halts.has(value)) return 'halted';\n if (!types.isNativeError(value) || seen.has(value)) continue;\n if (seen.size >= MAX_NODES || depth >= MAX_DEPTH) return 'uninspectable';\n seen.add(value);\n const cause = Object.getOwnPropertyDescriptor(value, 'cause');\n if (cause && Object.hasOwn(cause, 'value')) pending.push({ value: cause.value, depth: depth + 1 });\n const descriptor = Object.getOwnPropertyDescriptor(value, 'errors');\n if (!descriptor || !Object.hasOwn(descriptor, 'value') || types.isProxy(descriptor.value) || !Array.isArray(descriptor.value)) continue;\n const errors = descriptor.value as unknown[];\n if (errors.length > MAX_NODES || pending.length + errors.length > MAX_NODES) return 'uninspectable';\n for (let i = 0; i < errors.length; i++) {\n const item = Object.getOwnPropertyDescriptor(errors, String(i));\n if (item && Object.hasOwn(item, 'value')) pending.push({ value: item.value, depth: depth + 1 });\n }\n }\n return 'clear';\n}\n/** Genuine nominal errors only; oversized native error graphs are conservatively halting. */\nexport function isExecutionHalted(error: unknown): boolean { return inspect(error) !== 'clear'; }\n/** Preserve the original outer aggregate/cause, without invoking provider getters or proxy traps. */\nexport function rethrowExecutionHalt(error: unknown): void {\n const state = inspect(error);\n if (state === 'halted') throw error;\n if (state === 'uninspectable') throw new ExecutionHaltedError({ sanitizedDiagnostics: { reason: 'ERROR_GRAPH_LIMIT' } }, { cause: error });\n}\n"],"mappings":";;;;;AAAA,SAAS,aAAa;AAGtB,IAAM,QAAQ,oBAAI,QAAgB;AAE3B,IAAM,uBAAN,cAAmC,kBAAkB;AAAA,EAC1D,YAAY,UAA2C,CAAC,GAAG,SAAwB;AACjF,UAAM,oBAAoB,oBAAoB,EAAE,GAAG,SAAS,WAAW,MAAM,GAAG,OAAO;AACvF,UAAM,IAAI,IAAI;AAAA,EAChB;AACF;AACA,IAAM,YAAY;AAAlB,IAAsB,YAAY;AAElC,SAAS,QAAQ,OAA2B;AAC1C,QAAM,UAAU,CAAC,EAAE,OAAO,OAAO,OAAO,EAAE,CAAC,GAAG,OAAO,oBA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BAAsB,EAAE,QAAQ,oBAAoB,EAAE,GAAG,EAAE,OAAO,MAAM,CAAC;AAC3I;","names":[]}
@@ -0,0 +1,202 @@
1
+ import {
2
+ agentMemory,
3
+ snapshotAgentOptions
4
+ } from "./chunk-UZPDDQVJ.js";
5
+ import {
6
+ digest,
7
+ hash,
8
+ identifier,
9
+ jsonClone,
10
+ object,
11
+ ownObject,
12
+ snapshot,
13
+ strings
14
+ } from "./chunk-EEUYQFCP.js";
15
+
16
+ // src/routing/config.ts
17
+ var optionKeys = ["model", "tools", "cwd", "instructions", "effort", "transport", "context", "permissions", "environment", "capabilities", "providerOptions", "requireAuth", "memory"];
18
+ var capabilityKeys = ["interactiveApprovals", "userInputDuringTurn", "steering", "inProcessTools", "processPersistence", "messageDeltas", "tokenDeltas", "dynamicPermissions", "sessionInspection", "checkpointOrRollback", "subagentLifecycle", "subagentMessages", "subagentDeltas", "refusalDetection", "forkWithPrompt", "forkWithoutPrompt", "images", "files"];
19
+ function enumValue(value, values) {
20
+ if (!values.includes(value)) throw new TypeError("Invalid option value");
21
+ }
22
+ function optionalEnum(value, key, choices) {
23
+ if (key in value) enumValue(value[key], choices);
24
+ }
25
+ function textFields(value, keys) {
26
+ for (const key of keys) if (key in value && typeof value[key] !== "string") throw new TypeError(`Invalid ${key}`);
27
+ }
28
+ function validateOptions(value) {
29
+ object(value, optionKeys);
30
+ textFields(value, ["cwd", "instructions", "effort"]);
31
+ optionalEnum(value, "transport", ["exec", "control", "auto"]);
32
+ optionalEnum(value, "requireAuth", ["any", "subscription"]);
33
+ optionalEnum(value, "memory", [false]);
34
+ if ("context" in value) {
35
+ object(value.context, ["profile", "memory"]);
36
+ optionalEnum(value.context, "profile", ["native", "project", "clean"]);
37
+ optionalEnum(value.context, "memory", ["inherit", "off", "read-only"]);
38
+ }
39
+ if ("permissions" in value) {
40
+ object(value.permissions, ["mode", "network", "additionalDirectories", "minimumEnforcement", "strict"]);
41
+ enumValue(value.permissions.mode, ["analyze", "respond", "edit", "unrestricted"]);
42
+ optionalEnum(value.permissions, "network", ["allow", "deny"]);
43
+ optionalEnum(value.permissions, "minimumEnforcement", ["harness", "sandbox", "external"]);
44
+ optionalEnum(value.permissions, "strict", [true, false]);
45
+ if ("additionalDirectories" in value.permissions) strings(value.permissions.additionalDirectories, 1024);
46
+ }
47
+ if ("environment" in value) {
48
+ object(value.environment, ["mode", "variables", "passthrough"]);
49
+ enumValue(value.environment.mode, ["inherit", "minimal", "explicit"]);
50
+ if ("variables" in value.environment) {
51
+ object(value.environment.variables);
52
+ textFields(value.environment.variables, Object.keys(value.environment.variables));
53
+ }
54
+ if ("passthrough" in value.environment) strings(value.environment.passthrough, 1024);
55
+ }
56
+ if ("capabilities" in value) {
57
+ object(value.capabilities, capabilityKeys);
58
+ for (const entry of Object.values(value.capabilities)) enumValue(entry, [true, false, "required", "preferred"]);
59
+ }
60
+ if ("providerOptions" in value) {
61
+ const p = value.providerOptions;
62
+ object(p, ["external", "claude", "codex", "experimentalControl", "experimentalApi"]);
63
+ optionalEnum(p, "experimentalControl", [true, false]);
64
+ optionalEnum(p, "experimentalApi", [true, false]);
65
+ if ("external" in p) {
66
+ object(p.external);
67
+ for (const entry of Object.values(p.external)) object(entry);
68
+ }
69
+ if ("claude" in p) {
70
+ object(p.claude, ["systemPromptMode", "settings", "mcpConfigs", "tools", "strictMcpConfig"]);
71
+ optionalEnum(p.claude, "systemPromptMode", ["append", "replace"]);
72
+ optionalEnum(p.claude, "strictMcpConfig", [true, false]);
73
+ if ("settings" in p.claude && typeof p.claude.settings !== "string") object(p.claude.settings);
74
+ for (const key of ["mcpConfigs", "tools"]) if (key in p.claude) strings(p.claude[key], 1024);
75
+ }
76
+ if ("codex" in p) {
77
+ object(p.codex, ["config", "skipGitRepoCheck", "ignoreUserConfig", "ignoreRules", "ephemeral"]);
78
+ for (const key of ["skipGitRepoCheck", "ignoreUserConfig", "ignoreRules", "ephemeral"]) optionalEnum(p.codex, key, [true, false]);
79
+ if ("config" in p.codex) object(p.codex.config);
80
+ }
81
+ }
82
+ if ("tools" in value) {
83
+ if (!Array.isArray(value.tools)) throw new TypeError("Expected tools array");
84
+ for (const tool of value.tools) object(tool, ["name", "description", "inputSchema", "timeoutMs", "maxOutputBytes", "authorize", "execute"]);
85
+ }
86
+ }
87
+ function normalize(definition, runtime, task) {
88
+ definition = snapshot(definition, true);
89
+ object(definition);
90
+ validateOptions(definition);
91
+ if (task !== void 0) {
92
+ task = jsonClone(task);
93
+ object(task, ["id", "version", "inputDigest", "tags"]);
94
+ identifier(task.id);
95
+ identifier(task.version);
96
+ hash(task.inputDigest);
97
+ if (task.tags !== void 0) {
98
+ strings(task.tags, 32);
99
+ task.tags.forEach(identifier);
100
+ }
101
+ task = jsonClone(task);
102
+ }
103
+ const fixed = typeof definition.model === "string";
104
+ let auto;
105
+ const resolve = (name) => {
106
+ if (typeof name !== "string" || !name.trim() || name.length > 512) throw new TypeError("Invalid model");
107
+ const model = runtime.resolveModel(name);
108
+ if (!["available", "unavailable", "unverified"].includes(model.availability)) throw new TypeError("Invalid model availability");
109
+ if (`${model.provider}/${model.id}`.length > 512) throw new TypeError("Invalid canonical model");
110
+ return model;
111
+ };
112
+ let models;
113
+ if (fixed) models = [resolve(definition.model)];
114
+ else {
115
+ const raw = definition.model;
116
+ object(raw, ["mode", "candidates", "providers", "allowUnverifiedModels", "allowUnknownAuth", "rules", "fallback"]);
117
+ if (raw.mode !== "auto") throw new TypeError("Invalid selection mode");
118
+ optionalEnum(raw, "allowUnverifiedModels", [true, false]);
119
+ optionalEnum(raw, "allowUnknownAuth", [true, false]);
120
+ if (raw.providers !== void 0) {
121
+ strings(raw.providers, 64);
122
+ for (const provider of raw.providers) runtime.registration(provider);
123
+ }
124
+ if (raw.candidates !== void 0) {
125
+ strings(raw.candidates, 64);
126
+ models = raw.candidates.map(resolve);
127
+ } else {
128
+ models = runtime.providers().flatMap((provider) => {
129
+ try {
130
+ return [...runtime.registration(provider).modelCatalog].map((model) => resolve(`${provider}/${model.id}`));
131
+ } catch (error) {
132
+ if (error.code === "UNKNOWN_PROVIDER") return [];
133
+ throw error;
134
+ }
135
+ });
136
+ }
137
+ auto = jsonClone(raw);
138
+ }
139
+ const names = models.map((model) => `${model.provider}/${model.id}`);
140
+ if (models.length > 64 || new Set(names).size !== names.length) throw new TypeError("Too many or duplicate canonical candidates");
141
+ let fallback;
142
+ let ruleId;
143
+ let primary = [...names];
144
+ if (auto) {
145
+ const member = (value) => {
146
+ const model = resolve(value);
147
+ const name = `${model.provider}/${model.id}`;
148
+ if (!names.includes(name)) throw new TypeError("Model reference outside candidate universe");
149
+ return name;
150
+ };
151
+ if (auto.fallback !== void 0) fallback = member(auto.fallback);
152
+ if (auto.rules !== void 0) {
153
+ if (!Array.isArray(auto.rules) || auto.rules.length > 64) throw new TypeError("Invalid rules");
154
+ const ids = /* @__PURE__ */ new Set();
155
+ const normalizedRules = auto.rules.map((rule2) => {
156
+ object(rule2, ["id", "allTags", "models"]);
157
+ identifier(rule2.id);
158
+ if (ids.has(rule2.id)) throw new TypeError("Duplicate rule ID");
159
+ ids.add(rule2.id);
160
+ strings(rule2.allTags, 32, true);
161
+ rule2.allTags.forEach(identifier);
162
+ strings(rule2.models, 64, true);
163
+ const ruleModels = rule2.models.map(member);
164
+ if (new Set(ruleModels).size !== ruleModels.length) throw new TypeError("Duplicate canonical rule models");
165
+ return { id: rule2.id, allTags: rule2.allTags, models: ruleModels };
166
+ });
167
+ const rule = normalizedRules.find((rule2) => rule2.allTags.every((tag) => task?.tags?.includes(tag)));
168
+ primary = rule?.models ?? [];
169
+ ruleId = rule?.id;
170
+ auto = jsonClone({ ...auto, rules: normalizedRules });
171
+ }
172
+ auto = { ...auto, candidates: names, ...fallback === void 0 ? {} : { fallback }, allowUnknownAuth: auto.allowUnknownAuth ?? false, allowUnverifiedModels: auto.allowUnverifiedModels ?? false };
173
+ }
174
+ primary = primary.filter((name) => name !== fallback);
175
+ const { model: _model, ...rawRest } = definition;
176
+ const rest = ownObject(rawRest, optionKeys);
177
+ const options = snapshot(snapshotAgentOptions({ ...rest, ...(rest.tools?.length ?? 0) > 0 ? { capabilities: rest.capabilities ?? {} } : {}, model: names[0] ?? "", ...!fixed && rest.transport === void 0 ? { transport: "exec" } : {} }), true);
178
+ const { model: _ignore, tools, memory: _memory, ...metadata } = options;
179
+ const safeTools = tools?.map(({ authorize: _a, execute: _e, ...tool }) => tool);
180
+ const memory = memoryDigest(options, runtime, models);
181
+ return {
182
+ options,
183
+ models,
184
+ ...auto === void 0 ? {} : { auto },
185
+ primary,
186
+ ...fallback === void 0 ? {} : { fallback },
187
+ ...ruleId === void 0 ? {} : { ruleId },
188
+ configDigest: digest({ ...metadata, model: auto ?? names[0], ...safeTools === void 0 ? {} : { tools: safeTools }, ...memory === void 0 ? {} : { memory } }),
189
+ taskDigest: digest(task ?? null)
190
+ };
191
+ }
192
+ function memoryDigest(options, runtime, models) {
193
+ const fallback = options.memory === false ? void 0 : runtime.memoryDefault();
194
+ if (fallback === void 0) return void 0;
195
+ const identities = models.map((model) => agentMemory(void 0, fallback, { model: structuredClone(model), ...options.cwd === void 0 ? {} : { cwd: options.cwd } }).identity);
196
+ return identities.length === 0 ? void 0 : { provider: identities[0].provider, scopes: identities.map(({ scope }) => scope) };
197
+ }
198
+
199
+ export {
200
+ normalize
201
+ };
202
+ //# sourceMappingURL=chunk-RH5A5U7G.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/routing/config.ts"],"sourcesContent":["import { snapshotAgentOptions } from '../public/agent-options.js';\nimport type { AgentOptions, ModelInfo } from '../public/types.js';\nimport type { Runtime } from '../core/runtime.js';\nimport { agentMemory } from '../session/memory.js';\nimport { digest, hash, identifier, jsonClone, object, strings, snapshot, ownObject } from '../shared/json.js';\nimport type { AutoModelSelection, RoutingAgentDefinition, RoutingTask } from './types.js';\n// `memory` takes only `false` (the opt-out of a Runtime default): a provider object is code, and has no digest.\nconst optionKeys = ['model', 'tools', 'cwd', 'instructions', 'effort', 'transport', 'context', 'permissions', 'environment', 'capabilities', 'providerOptions', 'requireAuth', 'memory'];\nconst capabilityKeys = ['interactiveApprovals', 'userInputDuringTurn', 'steering', 'inProcessTools', 'processPersistence', 'messageDeltas', 'tokenDeltas', 'dynamicPermissions', 'sessionInspection', 'checkpointOrRollback', 'subagentLifecycle', 'subagentMessages', 'subagentDeltas', 'refusalDetection', 'forkWithPrompt', 'forkWithoutPrompt', 'images', 'files'];\nfunction enumValue(value: unknown, values: readonly unknown[]): void { if (!values.includes(value)) throw new TypeError('Invalid option value'); }\nfunction optionalEnum(value: Record<string, unknown>, key: string, choices: readonly unknown[]): void { if (key in value) enumValue(value[key], choices); }\nfunction textFields(value: Record<string, unknown>, keys: readonly string[]): void {\n for (const key of keys) if (key in value && typeof value[key] !== 'string') throw new TypeError(`Invalid ${key}`);\n}\nfunction validateOptions(value: Record<string, unknown>): void {\n object(value, optionKeys); textFields(value, ['cwd', 'instructions', 'effort']);\n optionalEnum(value, 'transport', ['exec', 'control', 'auto']); optionalEnum(value, 'requireAuth', ['any', 'subscription']); optionalEnum(value, 'memory', [false]);\n if ('context' in value) {\n object(value.context, ['profile', 'memory']); optionalEnum(value.context, 'profile', ['native', 'project', 'clean']); optionalEnum(value.context, 'memory', ['inherit', 'off', 'read-only']);\n }\n if ('permissions' in value) {\n object(value.permissions, ['mode', 'network', 'additionalDirectories', 'minimumEnforcement', 'strict']);\n enumValue(value.permissions.mode, ['analyze', 'respond', 'edit', 'unrestricted']); optionalEnum(value.permissions, 'network', ['allow', 'deny']);\n optionalEnum(value.permissions, 'minimumEnforcement', ['harness', 'sandbox', 'external']); optionalEnum(value.permissions, 'strict', [true, false]);\n if ('additionalDirectories' in value.permissions) strings(value.permissions.additionalDirectories, 1024);\n }\n if ('environment' in value) {\n object(value.environment, ['mode', 'variables', 'passthrough']); enumValue(value.environment.mode, ['inherit', 'minimal', 'explicit']);\n if ('variables' in value.environment) { object(value.environment.variables); textFields(value.environment.variables, Object.keys(value.environment.variables)); }\n if ('passthrough' in value.environment) strings(value.environment.passthrough, 1024);\n }\n if ('capabilities' in value) { object(value.capabilities, capabilityKeys); for (const entry of Object.values(value.capabilities)) enumValue(entry, [true, false, 'required', 'preferred']); }\n if ('providerOptions' in value) {\n const p = value.providerOptions; object(p, ['external', 'claude', 'codex', 'experimentalControl', 'experimentalApi']);\n optionalEnum(p, 'experimentalControl', [true, false]); optionalEnum(p, 'experimentalApi', [true, false]);\n if ('external' in p) { object(p.external); for (const entry of Object.values(p.external)) object(entry); }\n if ('claude' in p) {\n object(p.claude, ['systemPromptMode', 'settings', 'mcpConfigs', 'tools', 'strictMcpConfig']);\n optionalEnum(p.claude, 'systemPromptMode', ['append', 'replace']); optionalEnum(p.claude, 'strictMcpConfig', [true, false]);\n if ('settings' in p.claude && typeof p.claude.settings !== 'string') object(p.claude.settings);\n for (const key of ['mcpConfigs', 'tools']) if (key in p.claude) strings(p.claude[key], 1024);\n }\n if ('codex' in p) {\n object(p.codex, ['config', 'skipGitRepoCheck', 'ignoreUserConfig', 'ignoreRules', 'ephemeral']);\n for (const key of ['skipGitRepoCheck', 'ignoreUserConfig', 'ignoreRules', 'ephemeral']) optionalEnum(p.codex, key, [true, false]);\n if ('config' in p.codex) object(p.codex.config);\n }\n }\n if ('tools' in value) {\n if (!Array.isArray(value.tools)) throw new TypeError('Expected tools array');\n for (const tool of value.tools) object(tool, ['name', 'description', 'inputSchema', 'timeoutMs', 'maxOutputBytes', 'authorize', 'execute']);\n }\n}\nexport interface NormalizedSelection {\n options: Readonly<Omit<AgentOptions, 'model'>>; models: ModelInfo[]; auto?: AutoModelSelection;\n primary: string[]; fallback?: string; ruleId?: string; configDigest: string; taskDigest: string;\n}\nexport function normalize(definition: RoutingAgentDefinition, runtime: Runtime, task?: RoutingTask): NormalizedSelection {\n definition = snapshot(definition, true); object(definition); validateOptions(definition);\n if (task !== undefined) {\n task = jsonClone(task); object(task, ['id', 'version', 'inputDigest', 'tags']); identifier(task.id); identifier(task.version); hash(task.inputDigest);\n if (task.tags !== undefined) { strings(task.tags, 32); task.tags.forEach(identifier); }\n task = jsonClone(task);\n }\n const fixed = typeof definition.model === 'string'; let auto: AutoModelSelection | undefined;\n const resolve = (name: string): ModelInfo => {\n if (typeof name !== 'string' || !name.trim() || name.length > 512) throw new TypeError('Invalid model');\n const model = runtime.resolveModel(name);\n if (!['available', 'unavailable', 'unverified'].includes(model.availability)) throw new TypeError('Invalid model availability');\n if (`${model.provider}/${model.id}`.length > 512) throw new TypeError('Invalid canonical model'); return model;\n };\n let models: ModelInfo[];\n if (fixed) models = [resolve(definition.model as string)];\n else {\n const raw = definition.model; object(raw, ['mode', 'candidates', 'providers', 'allowUnverifiedModels', 'allowUnknownAuth', 'rules', 'fallback']);\n if (raw.mode !== 'auto') throw new TypeError('Invalid selection mode');\n optionalEnum(raw, 'allowUnverifiedModels', [true, false]); optionalEnum(raw, 'allowUnknownAuth', [true, false]);\n if (raw.providers !== undefined) { strings(raw.providers, 64); for (const provider of raw.providers) runtime.registration(provider); }\n if (raw.candidates !== undefined) { strings(raw.candidates, 64); models = raw.candidates.map(resolve); }\n else {\n models = runtime.providers().flatMap(provider => {\n try { return [...runtime.registration(provider).modelCatalog].map(model => resolve(`${provider}/${model.id}`)); }\n catch (error) { if ((error as { code?: string }).code === 'UNKNOWN_PROVIDER') return []; throw error; }\n });\n }\n auto = jsonClone(raw) as unknown as AutoModelSelection;\n }\n const names = models.map(model => `${model.provider}/${model.id}`);\n if (models.length > 64 || new Set(names).size !== names.length) throw new TypeError('Too many or duplicate canonical candidates');\n let fallback: string | undefined; let ruleId: string | undefined; let primary = [...names];\n if (auto) {\n const member = (value: string): string => { const model = resolve(value); const name = `${model.provider}/${model.id}`; if (!names.includes(name)) throw new TypeError('Model reference outside candidate universe'); return name; };\n if (auto.fallback !== undefined) fallback = member(auto.fallback);\n if (auto.rules !== undefined) {\n if (!Array.isArray(auto.rules) || auto.rules.length > 64) throw new TypeError('Invalid rules');\n const ids = new Set<string>(); const normalizedRules = auto.rules.map(rule => {\n object(rule, ['id', 'allTags', 'models']); identifier(rule.id);\n if (ids.has(rule.id)) throw new TypeError('Duplicate rule ID'); ids.add(rule.id);\n strings(rule.allTags, 32, true); rule.allTags.forEach(identifier); strings(rule.models, 64, true);\n const ruleModels = rule.models.map(member);\n if (new Set(ruleModels).size !== ruleModels.length) throw new TypeError('Duplicate canonical rule models');\n return { id: rule.id as string, allTags: rule.allTags as string[], models: ruleModels };\n });\n const rule = normalizedRules.find(rule => rule.allTags.every(tag => task?.tags?.includes(tag)));\n primary = rule?.models ?? []; ruleId = rule?.id; auto = jsonClone({ ...auto, rules: normalizedRules });\n }\n auto = { ...auto, candidates: names, ...(fallback === undefined ? {} : { fallback }), allowUnknownAuth: auto.allowUnknownAuth ?? false, allowUnverifiedModels: auto.allowUnverifiedModels ?? false };\n }\n primary = primary.filter(name => name !== fallback);\n const { model: _model, ...rawRest } = definition;\n const rest = ownObject(rawRest, optionKeys);\n const options = snapshot(snapshotAgentOptions({ ...rest, ...((rest.tools?.length ?? 0) > 0 ? { capabilities: rest.capabilities ?? {} } : {}), model: names[0] ?? '', ...(!fixed && rest.transport === undefined ? { transport: 'exec' } : {}) }), true);\n const { model: _ignore, tools, memory: _memory, ...metadata } = options;\n const safeTools = tools?.map(({ authorize: _a, execute: _e, ...tool }) => tool);\n const memory = memoryDigest(options, runtime, models);\n return { options, models, ...(auto === undefined ? {} : { auto }), primary,\n ...(fallback === undefined ? {} : { fallback }), ...(ruleId === undefined ? {} : { ruleId }),\n configDigest: digest({ ...metadata, model: auto ?? names[0], ...(safeTools === undefined ? {} : { tools: safeTools }), ...(memory === undefined ? {} : { memory }) }), taskDigest: digest(task ?? null) };\n}\n\n/**\n * The memory each candidate's Agent gets (the Runtime default unless `memory: false`), as the\n * config digest records it: the provider id and the scope for each candidate, never a function.\n * Undefined without memory, so the digest of a definition without memory is unchanged.\n */\nfunction memoryDigest(options: Readonly<Omit<AgentOptions, 'model'>>, runtime: Runtime, models: readonly ModelInfo[]) {\n const fallback = options.memory === false ? undefined : runtime.memoryDefault();\n if (fallback === undefined) return undefined;\n const identities = models.map((model) => agentMemory(undefined, fallback, { model: structuredClone(model), ...(options.cwd === undefined ? {} : { cwd: options.cwd }) })!.identity);\n return identities.length === 0 ? undefined : { provider: identities[0]!.provider, scopes: identities.map(({ scope }) => scope) };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAOA,IAAM,aAAa,CAAC,SAAS,SAAS,OAAO,gBAAgB,UAAU,aAAa,WAAW,eAAe,eAAe,gBAAgB,mBAAmB,eAAe,QAAQ;AACvL,IAAM,iBAAiB,CAAC,wBAAwB,uBAAuB,YAAY,kBAAkB,sBAAsB,iBAAiB,eAAe,sBAAsB,qBAAqB,wBAAwB,qBAAqB,oBAAoB,kBAAkB,oBAAoB,kBAAkB,qBAAqB,UAAU,OAAO;AACrW,SAAS,UAAU,OAAgB,QAAkC;AAAE,MAAI,CAAC,OAAO,SAAS,KAAK,EAAG,OAAM,IAAI,UAAU,sBAAsB;AAAG;AACjJ,SAAS,aAAa,OAAgC,KAAa,SAAmC;AAAE,MAAI,OAAO,MAAO,WAAU,MAAM,GAAG,GAAG,OAAO;AAAG;AAC1J,SAAS,WAAW,OAAgC,MAA+B;AACjF,aAAW,OAAO,KAAM,KAAI,OAAO,SAAS,OAAO,MAAM,GAAG,MAAM,SAAU,OAAM,IAAI,UAAU,WAAW,GAAG,EAAE;AAClH;AACA,SAAS,gBAAgB,OAAsC;AAC7D,SAAO,OAAO,UAAU;AAAG,aAAW,OAAO,CAAC,OAAO,gBAAgB,QAAQ,CAAC;AAC9E,eAAa,OAAO,aAAa,CAAC,QAAQ,WAAW,MAAM,CAAC;AAAG,eAAa,OAAO,eAAe,CAAC,OAAO,cAAc,CAAC;AAAG,eAAa,OAAO,UAAU,CAAC,KAAK,CAAC;AACjK,MAAI,aAAa,OAAO;AACtB,WAAO,MAAM,SAAS,CAAC,WAAW,QAAQ,CAAC;AAAG,iBAAa,MAAM,SA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