@openai/agents-core 0.8.5 → 0.9.1
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/dist/agentToolRunConfig.js +3 -0
- package/dist/agentToolRunConfig.js.map +1 -1
- package/dist/agentToolRunConfig.mjs +3 -0
- package/dist/agentToolRunConfig.mjs.map +1 -1
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +15 -1
- package/dist/errors.js.map +1 -1
- package/dist/errors.mjs +13 -0
- package/dist/errors.mjs.map +1 -1
- package/dist/handoff.js +1 -1
- package/dist/handoff.js.map +1 -1
- package/dist/handoff.mjs +1 -1
- package/dist/handoff.mjs.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/dist/items.d.ts +13 -0
- package/dist/items.js +15 -0
- package/dist/items.js.map +1 -1
- package/dist/items.mjs +15 -0
- package/dist/items.mjs.map +1 -1
- package/dist/memory/historyMutations.d.ts +6 -0
- package/dist/memory/historyMutations.js +32 -0
- package/dist/memory/historyMutations.js.map +1 -0
- package/dist/memory/historyMutations.mjs +29 -0
- package/dist/memory/historyMutations.mjs.map +1 -0
- package/dist/memory/memorySession.d.ts +3 -2
- package/dist/memory/memorySession.js +7 -0
- package/dist/memory/memorySession.js.map +1 -1
- package/dist/memory/memorySession.mjs +7 -0
- package/dist/memory/memorySession.mjs.map +1 -1
- package/dist/memory/session.d.ts +22 -0
- package/dist/memory/session.js +6 -0
- package/dist/memory/session.js.map +1 -1
- package/dist/memory/session.mjs +5 -0
- package/dist/memory/session.mjs.map +1 -1
- package/dist/metadata.js +2 -2
- package/dist/metadata.mjs +2 -2
- package/dist/model.d.ts +21 -0
- package/dist/run.d.ts +7 -1
- package/dist/run.js +152 -57
- package/dist/run.js.map +1 -1
- package/dist/run.mjs +153 -58
- package/dist/run.mjs.map +1 -1
- package/dist/runState.d.ts +110 -3
- package/dist/runState.js +414 -53
- package/dist/runState.js.map +1 -1
- package/dist/runState.mjs +412 -53
- package/dist/runState.mjs.map +1 -1
- package/dist/runner/errorHandlers.d.ts +13 -4
- package/dist/runner/errorHandlers.js +22 -4
- package/dist/runner/errorHandlers.js.map +1 -1
- package/dist/runner/errorHandlers.mjs +21 -4
- package/dist/runner/errorHandlers.mjs.map +1 -1
- package/dist/runner/items.js +11 -1
- package/dist/runner/items.js.map +1 -1
- package/dist/runner/items.mjs +11 -1
- package/dist/runner/items.mjs.map +1 -1
- package/dist/runner/modelPreparation.d.ts +1 -1
- package/dist/runner/modelPreparation.js +7 -7
- package/dist/runner/modelPreparation.js.map +1 -1
- package/dist/runner/modelPreparation.mjs +7 -7
- package/dist/runner/modelPreparation.mjs.map +1 -1
- package/dist/runner/runLoop.d.ts +2 -1
- package/dist/runner/runLoop.js +2 -2
- package/dist/runner/runLoop.js.map +1 -1
- package/dist/runner/runLoop.mjs +2 -2
- package/dist/runner/runLoop.mjs.map +1 -1
- package/dist/runner/sandbox.d.ts +33 -0
- package/dist/runner/sandbox.js +92 -0
- package/dist/runner/sandbox.js.map +1 -0
- package/dist/runner/sandbox.mjs +83 -0
- package/dist/runner/sandbox.mjs.map +1 -0
- package/dist/runner/sessionPersistence.js +33 -12
- package/dist/runner/sessionPersistence.js.map +1 -1
- package/dist/runner/sessionPersistence.mjs +33 -12
- package/dist/runner/sessionPersistence.mjs.map +1 -1
- package/dist/runner/streamReconciliation.d.ts +14 -0
- package/dist/runner/streamReconciliation.js +80 -0
- package/dist/runner/streamReconciliation.js.map +1 -0
- package/dist/runner/streamReconciliation.mjs +72 -0
- package/dist/runner/streamReconciliation.mjs.map +1 -0
- package/dist/runner/toolExecution.js +25 -13
- package/dist/runner/toolExecution.js.map +1 -1
- package/dist/runner/toolExecution.mjs +25 -13
- package/dist/runner/toolExecution.mjs.map +1 -1
- package/dist/runner/toolUseTracker.d.ts +3 -1
- package/dist/runner/toolUseTracker.js +2 -2
- package/dist/runner/toolUseTracker.js.map +1 -1
- package/dist/runner/toolUseTracker.mjs +2 -2
- package/dist/runner/toolUseTracker.mjs.map +1 -1
- package/dist/runner/tracing.js +1 -0
- package/dist/runner/tracing.js.map +1 -1
- package/dist/runner/tracing.mjs +1 -0
- package/dist/runner/tracing.mjs.map +1 -1
- package/dist/runner/turnPreparation.d.ts +2 -4
- package/dist/runner/turnPreparation.js +7 -3
- package/dist/runner/turnPreparation.js.map +1 -1
- package/dist/runner/turnPreparation.mjs +7 -3
- package/dist/runner/turnPreparation.mjs.map +1 -1
- package/dist/runner/turnResolution.js +158 -31
- package/dist/runner/turnResolution.js.map +1 -1
- package/dist/runner/turnResolution.mjs +160 -33
- package/dist/runner/turnResolution.mjs.map +1 -1
- package/dist/runner/types.d.ts +8 -8
- package/dist/sandbox/agent.d.ts +24 -0
- package/dist/sandbox/agent.js +68 -0
- package/dist/sandbox/agent.js.map +1 -0
- package/dist/sandbox/agent.mjs +64 -0
- package/dist/sandbox/agent.mjs.map +1 -0
- package/dist/sandbox/brand.d.ts +1 -0
- package/dist/sandbox/brand.js +5 -0
- package/dist/sandbox/brand.js.map +1 -0
- package/dist/sandbox/brand.mjs +2 -0
- package/dist/sandbox/brand.mjs.map +1 -0
- package/dist/sandbox/capabilities/base.d.ts +25 -0
- package/dist/sandbox/capabilities/base.js +89 -0
- package/dist/sandbox/capabilities/base.js.map +1 -0
- package/dist/sandbox/capabilities/base.mjs +84 -0
- package/dist/sandbox/capabilities/base.mjs.map +1 -0
- package/dist/sandbox/capabilities/compaction.d.ts +33 -0
- package/dist/sandbox/capabilities/compaction.js +172 -0
- package/dist/sandbox/capabilities/compaction.js.map +1 -0
- package/dist/sandbox/capabilities/compaction.mjs +164 -0
- package/dist/sandbox/capabilities/compaction.mjs.map +1 -0
- package/dist/sandbox/capabilities/filesystem.d.ts +14 -0
- package/dist/sandbox/capabilities/filesystem.js +447 -0
- package/dist/sandbox/capabilities/filesystem.js.map +1 -0
- package/dist/sandbox/capabilities/filesystem.mjs +444 -0
- package/dist/sandbox/capabilities/filesystem.mjs.map +1 -0
- package/dist/sandbox/capabilities/index.d.ts +19 -0
- package/dist/sandbox/capabilities/index.js +31 -0
- package/dist/sandbox/capabilities/index.js.map +1 -0
- package/dist/sandbox/capabilities/index.mjs +17 -0
- package/dist/sandbox/capabilities/index.mjs.map +1 -0
- package/dist/sandbox/capabilities/memory.d.ts +52 -0
- package/dist/sandbox/capabilities/memory.js +290 -0
- package/dist/sandbox/capabilities/memory.js.map +1 -0
- package/dist/sandbox/capabilities/memory.mjs +286 -0
- package/dist/sandbox/capabilities/memory.mjs.map +1 -0
- package/dist/sandbox/capabilities/shell.d.ts +15 -0
- package/dist/sandbox/capabilities/shell.js +130 -0
- package/dist/sandbox/capabilities/shell.js.map +1 -0
- package/dist/sandbox/capabilities/shell.mjs +127 -0
- package/dist/sandbox/capabilities/shell.mjs.map +1 -0
- package/dist/sandbox/capabilities/skills.d.ts +47 -0
- package/dist/sandbox/capabilities/skills.js +453 -0
- package/dist/sandbox/capabilities/skills.js.map +1 -0
- package/dist/sandbox/capabilities/skills.mjs +449 -0
- package/dist/sandbox/capabilities/skills.mjs.map +1 -0
- package/dist/sandbox/capabilities/transport.d.ts +3 -0
- package/dist/sandbox/capabilities/transport.js +33 -0
- package/dist/sandbox/capabilities/transport.js.map +1 -0
- package/dist/sandbox/capabilities/transport.mjs +28 -0
- package/dist/sandbox/capabilities/transport.mjs.map +1 -0
- package/dist/sandbox/client.d.ts +53 -0
- package/dist/sandbox/client.js +34 -0
- package/dist/sandbox/client.js.map +1 -0
- package/dist/sandbox/client.mjs +31 -0
- package/dist/sandbox/client.mjs.map +1 -0
- package/dist/sandbox/entries/factories.d.ts +17 -0
- package/dist/sandbox/entries/factories.js +112 -0
- package/dist/sandbox/entries/factories.js.map +1 -0
- package/dist/sandbox/entries/factories.mjs +94 -0
- package/dist/sandbox/entries/factories.mjs.map +1 -0
- package/dist/sandbox/entries/guards.d.ts +5 -0
- package/dist/sandbox/entries/guards.js +19 -0
- package/dist/sandbox/entries/guards.js.map +1 -0
- package/dist/sandbox/entries/guards.mjs +13 -0
- package/dist/sandbox/entries/guards.mjs.map +1 -0
- package/dist/sandbox/entries/index.d.ts +3 -0
- package/dist/sandbox/entries/index.js +26 -0
- package/dist/sandbox/entries/index.js.map +1 -0
- package/dist/sandbox/entries/index.mjs +3 -0
- package/dist/sandbox/entries/index.mjs.map +1 -0
- package/dist/sandbox/entries/types.d.ts +177 -0
- package/dist/sandbox/entries/types.js +3 -0
- package/dist/sandbox/entries/types.js.map +1 -0
- package/dist/sandbox/entries/types.mjs +2 -0
- package/dist/sandbox/entries/types.mjs.map +1 -0
- package/dist/sandbox/errors.d.ts +151 -0
- package/dist/sandbox/errors.js +303 -0
- package/dist/sandbox/errors.js.map +1 -0
- package/dist/sandbox/errors.mjs +251 -0
- package/dist/sandbox/errors.mjs.map +1 -0
- package/dist/sandbox/events.d.ts +51 -0
- package/dist/sandbox/events.js +104 -0
- package/dist/sandbox/events.js.map +1 -0
- package/dist/sandbox/events.mjs +95 -0
- package/dist/sandbox/events.mjs.map +1 -0
- package/dist/sandbox/index.d.ts +14 -0
- package/dist/sandbox/index.js +31 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/sandbox/index.mjs +15 -0
- package/dist/sandbox/index.mjs.map +1 -0
- package/dist/sandbox/internal.d.ts +7 -0
- package/dist/sandbox/internal.js +46 -0
- package/dist/sandbox/internal.js.map +1 -0
- package/dist/sandbox/internal.mjs +8 -0
- package/dist/sandbox/internal.mjs.map +1 -0
- package/dist/sandbox/local.d.ts +3 -0
- package/dist/sandbox/local.js +20 -0
- package/dist/sandbox/local.js.map +1 -0
- package/dist/sandbox/local.mjs +4 -0
- package/dist/sandbox/local.mjs.map +1 -0
- package/dist/sandbox/localSkills.d.ts +13 -0
- package/dist/sandbox/localSkills.js +62 -0
- package/dist/sandbox/localSkills.js.map +1 -0
- package/dist/sandbox/localSkills.mjs +59 -0
- package/dist/sandbox/localSkills.mjs.map +1 -0
- package/dist/sandbox/manifest.d.ts +86 -0
- package/dist/sandbox/manifest.js +553 -0
- package/dist/sandbox/manifest.js.map +1 -0
- package/dist/sandbox/manifest.mjs +545 -0
- package/dist/sandbox/manifest.mjs.map +1 -0
- package/dist/sandbox/memory/generation.d.ts +56 -0
- package/dist/sandbox/memory/generation.js +426 -0
- package/dist/sandbox/memory/generation.js.map +1 -0
- package/dist/sandbox/memory/generation.mjs +385 -0
- package/dist/sandbox/memory/generation.mjs.map +1 -0
- package/dist/sandbox/memory/prompts.d.ts +16 -0
- package/dist/sandbox/memory/prompts.js +1685 -0
- package/dist/sandbox/memory/prompts.js.map +1 -0
- package/dist/sandbox/memory/prompts.mjs +1679 -0
- package/dist/sandbox/memory/prompts.mjs.map +1 -0
- package/dist/sandbox/memory/rollouts.d.ts +33 -0
- package/dist/sandbox/memory/rollouts.js +228 -0
- package/dist/sandbox/memory/rollouts.js.map +1 -0
- package/dist/sandbox/memory/rollouts.mjs +221 -0
- package/dist/sandbox/memory/rollouts.mjs.map +1 -0
- package/dist/sandbox/memory/storage.d.ts +70 -0
- package/dist/sandbox/memory/storage.js +543 -0
- package/dist/sandbox/memory/storage.js.map +1 -0
- package/dist/sandbox/memory/storage.mjs +537 -0
- package/dist/sandbox/memory/storage.mjs.map +1 -0
- package/dist/sandbox/pathGrants.d.ts +11 -0
- package/dist/sandbox/pathGrants.js +28 -0
- package/dist/sandbox/pathGrants.js.map +1 -0
- package/dist/sandbox/pathGrants.mjs +25 -0
- package/dist/sandbox/pathGrants.mjs.map +1 -0
- package/dist/sandbox/permissions.d.ts +29 -0
- package/dist/sandbox/permissions.js +140 -0
- package/dist/sandbox/permissions.js.map +1 -0
- package/dist/sandbox/permissions.mjs +134 -0
- package/dist/sandbox/permissions.mjs.map +1 -0
- package/dist/sandbox/runtime/agentKeys.d.ts +7 -0
- package/dist/sandbox/runtime/agentKeys.js +76 -0
- package/dist/sandbox/runtime/agentKeys.js.map +1 -0
- package/dist/sandbox/runtime/agentKeys.mjs +69 -0
- package/dist/sandbox/runtime/agentKeys.mjs.map +1 -0
- package/dist/sandbox/runtime/agentPreparation.d.ts +20 -0
- package/dist/sandbox/runtime/agentPreparation.js +178 -0
- package/dist/sandbox/runtime/agentPreparation.js.map +1 -0
- package/dist/sandbox/runtime/agentPreparation.mjs +172 -0
- package/dist/sandbox/runtime/agentPreparation.mjs.map +1 -0
- package/dist/sandbox/runtime/index.d.ts +5 -0
- package/dist/sandbox/runtime/index.js +22 -0
- package/dist/sandbox/runtime/index.js.map +1 -0
- package/dist/sandbox/runtime/index.mjs +6 -0
- package/dist/sandbox/runtime/index.mjs.map +1 -0
- package/dist/sandbox/runtime/livePreservedSessions.d.ts +25 -0
- package/dist/sandbox/runtime/livePreservedSessions.js +58 -0
- package/dist/sandbox/runtime/livePreservedSessions.js.map +1 -0
- package/dist/sandbox/runtime/livePreservedSessions.mjs +51 -0
- package/dist/sandbox/runtime/livePreservedSessions.mjs.map +1 -0
- package/dist/sandbox/runtime/manager.d.ts +68 -0
- package/dist/sandbox/runtime/manager.js +704 -0
- package/dist/sandbox/runtime/manager.js.map +1 -0
- package/dist/sandbox/runtime/manager.mjs +697 -0
- package/dist/sandbox/runtime/manager.mjs.map +1 -0
- package/dist/sandbox/runtime/prompts.d.ts +6 -0
- package/dist/sandbox/runtime/prompts.js +108 -0
- package/dist/sandbox/runtime/prompts.js.map +1 -0
- package/dist/sandbox/runtime/prompts.mjs +101 -0
- package/dist/sandbox/runtime/prompts.mjs.map +1 -0
- package/dist/sandbox/runtime/providedSessionManifest.d.ts +3 -0
- package/dist/sandbox/runtime/providedSessionManifest.js +175 -0
- package/dist/sandbox/runtime/providedSessionManifest.js.map +1 -0
- package/dist/sandbox/runtime/providedSessionManifest.mjs +172 -0
- package/dist/sandbox/runtime/providedSessionManifest.mjs.map +1 -0
- package/dist/sandbox/runtime/runAsManifest.d.ts +4 -0
- package/dist/sandbox/runtime/runAsManifest.js +40 -0
- package/dist/sandbox/runtime/runAsManifest.js.map +1 -0
- package/dist/sandbox/runtime/runAsManifest.mjs +36 -0
- package/dist/sandbox/runtime/runAsManifest.mjs.map +1 -0
- package/dist/sandbox/runtime/sessionLifecycle.d.ts +6 -0
- package/dist/sandbox/runtime/sessionLifecycle.js +222 -0
- package/dist/sandbox/runtime/sessionLifecycle.js.map +1 -0
- package/dist/sandbox/runtime/sessionLifecycle.mjs +215 -0
- package/dist/sandbox/runtime/sessionLifecycle.mjs.map +1 -0
- package/dist/sandbox/runtime/sessionSerialization.d.ts +12 -0
- package/dist/sandbox/runtime/sessionSerialization.js +74 -0
- package/dist/sandbox/runtime/sessionSerialization.js.map +1 -0
- package/dist/sandbox/runtime/sessionSerialization.mjs +71 -0
- package/dist/sandbox/runtime/sessionSerialization.mjs.map +1 -0
- package/dist/sandbox/runtime/sessionState.d.ts +26 -0
- package/dist/sandbox/runtime/sessionState.js +113 -0
- package/dist/sandbox/runtime/sessionState.js.map +1 -0
- package/dist/sandbox/runtime/sessionState.mjs +104 -0
- package/dist/sandbox/runtime/sessionState.mjs.map +1 -0
- package/dist/sandbox/runtime/spans.d.ts +1 -0
- package/dist/sandbox/runtime/spans.js +51 -0
- package/dist/sandbox/runtime/spans.js.map +1 -0
- package/dist/sandbox/runtime/spans.mjs +48 -0
- package/dist/sandbox/runtime/spans.mjs.map +1 -0
- package/dist/sandbox/runtime/toolRehydration.d.ts +34 -0
- package/dist/sandbox/runtime/toolRehydration.js +207 -0
- package/dist/sandbox/runtime/toolRehydration.js.map +1 -0
- package/dist/sandbox/runtime/toolRehydration.mjs +200 -0
- package/dist/sandbox/runtime/toolRehydration.mjs.map +1 -0
- package/dist/sandbox/sandboxes/docker.d.ts +75 -0
- package/dist/sandbox/sandboxes/docker.js +2015 -0
- package/dist/sandbox/sandboxes/docker.js.map +1 -0
- package/dist/sandbox/sandboxes/docker.mjs +2010 -0
- package/dist/sandbox/sandboxes/docker.mjs.map +1 -0
- package/dist/sandbox/sandboxes/index.d.ts +3 -0
- package/dist/sandbox/sandboxes/index.js +20 -0
- package/dist/sandbox/sandboxes/index.js.map +1 -0
- package/dist/sandbox/sandboxes/index.mjs +4 -0
- package/dist/sandbox/sandboxes/index.mjs.map +1 -0
- package/dist/sandbox/sandboxes/shared/localSnapshotPaths.d.ts +1 -0
- package/dist/sandbox/sandboxes/shared/localSnapshotPaths.js +22 -0
- package/dist/sandbox/sandboxes/shared/localSnapshotPaths.js.map +1 -0
- package/dist/sandbox/sandboxes/shared/localSnapshotPaths.mjs +19 -0
- package/dist/sandbox/sandboxes/shared/localSnapshotPaths.mjs.map +1 -0
- package/dist/sandbox/sandboxes/shared/localSnapshots.d.ts +34 -0
- package/dist/sandbox/sandboxes/shared/localSnapshots.js +525 -0
- package/dist/sandbox/sandboxes/shared/localSnapshots.js.map +1 -0
- package/dist/sandbox/sandboxes/shared/localSnapshots.mjs +508 -0
- package/dist/sandbox/sandboxes/shared/localSnapshots.mjs.map +1 -0
- package/dist/sandbox/sandboxes/shared/localWorkspace.d.ts +27 -0
- package/dist/sandbox/sandboxes/shared/localWorkspace.js +693 -0
- package/dist/sandbox/sandboxes/shared/localWorkspace.js.map +1 -0
- package/dist/sandbox/sandboxes/shared/localWorkspace.mjs +684 -0
- package/dist/sandbox/sandboxes/shared/localWorkspace.mjs.map +1 -0
- package/dist/sandbox/sandboxes/shared/manifestPersistence.d.ts +15 -0
- package/dist/sandbox/sandboxes/shared/manifestPersistence.js +191 -0
- package/dist/sandbox/sandboxes/shared/manifestPersistence.js.map +1 -0
- package/dist/sandbox/sandboxes/shared/manifestPersistence.mjs +182 -0
- package/dist/sandbox/sandboxes/shared/manifestPersistence.mjs.map +1 -0
- package/dist/sandbox/sandboxes/shared/pty.d.ts +9 -0
- package/dist/sandbox/sandboxes/shared/pty.js +151 -0
- package/dist/sandbox/sandboxes/shared/pty.js.map +1 -0
- package/dist/sandbox/sandboxes/shared/pty.mjs +148 -0
- package/dist/sandbox/sandboxes/shared/pty.mjs.map +1 -0
- package/dist/sandbox/sandboxes/shared/runProcess.d.ts +16 -0
- package/dist/sandbox/sandboxes/shared/runProcess.js +90 -0
- package/dist/sandbox/sandboxes/shared/runProcess.js.map +1 -0
- package/dist/sandbox/sandboxes/shared/runProcess.mjs +86 -0
- package/dist/sandbox/sandboxes/shared/runProcess.mjs.map +1 -0
- package/dist/sandbox/sandboxes/shared/sessionStateValues.d.ts +18 -0
- package/dist/sandbox/sandboxes/shared/sessionStateValues.js +40 -0
- package/dist/sandbox/sandboxes/shared/sessionStateValues.js.map +1 -0
- package/dist/sandbox/sandboxes/shared/sessionStateValues.mjs +35 -0
- package/dist/sandbox/sandboxes/shared/sessionStateValues.mjs.map +1 -0
- package/dist/sandbox/sandboxes/shared/shellCommand.d.ts +17 -0
- package/dist/sandbox/sandboxes/shared/shellCommand.js +38 -0
- package/dist/sandbox/sandboxes/shared/shellCommand.js.map +1 -0
- package/dist/sandbox/sandboxes/shared/shellCommand.mjs +34 -0
- package/dist/sandbox/sandboxes/shared/shellCommand.mjs.map +1 -0
- package/dist/sandbox/sandboxes/types.d.ts +11 -0
- package/dist/sandbox/sandboxes/types.js +3 -0
- package/dist/sandbox/sandboxes/types.js.map +1 -0
- package/dist/sandbox/sandboxes/types.mjs +2 -0
- package/dist/sandbox/sandboxes/types.mjs.map +1 -0
- package/dist/sandbox/sandboxes/unixLocal.d.ts +95 -0
- package/dist/sandbox/sandboxes/unixLocal.js +863 -0
- package/dist/sandbox/sandboxes/unixLocal.js.map +1 -0
- package/dist/sandbox/sandboxes/unixLocal.mjs +858 -0
- package/dist/sandbox/sandboxes/unixLocal.mjs.map +1 -0
- package/dist/sandbox/session.d.ts +123 -0
- package/dist/sandbox/session.js +58 -0
- package/dist/sandbox/session.js.map +1 -0
- package/dist/sandbox/session.mjs +50 -0
- package/dist/sandbox/session.mjs.map +1 -0
- package/dist/sandbox/shared/compare.d.ts +2 -0
- package/dist/sandbox/shared/compare.js +13 -0
- package/dist/sandbox/shared/compare.js.map +1 -0
- package/dist/sandbox/shared/compare.mjs +9 -0
- package/dist/sandbox/shared/compare.mjs.map +1 -0
- package/dist/sandbox/shared/environment.d.ts +14 -0
- package/dist/sandbox/shared/environment.js +69 -0
- package/dist/sandbox/shared/environment.js.map +1 -0
- package/dist/sandbox/shared/environment.mjs +59 -0
- package/dist/sandbox/shared/environment.mjs.map +1 -0
- package/dist/sandbox/shared/hostPath.d.ts +4 -0
- package/dist/sandbox/shared/hostPath.js +22 -0
- package/dist/sandbox/shared/hostPath.js.map +1 -0
- package/dist/sandbox/shared/hostPath.mjs +16 -0
- package/dist/sandbox/shared/hostPath.mjs.map +1 -0
- package/dist/sandbox/shared/manifestCollections.d.ts +12 -0
- package/dist/sandbox/shared/manifestCollections.js +40 -0
- package/dist/sandbox/shared/manifestCollections.js.map +1 -0
- package/dist/sandbox/shared/manifestCollections.mjs +34 -0
- package/dist/sandbox/shared/manifestCollections.mjs.map +1 -0
- package/dist/sandbox/shared/media.d.ts +6 -0
- package/dist/sandbox/shared/media.js +126 -0
- package/dist/sandbox/shared/media.js.map +1 -0
- package/dist/sandbox/shared/media.mjs +119 -0
- package/dist/sandbox/shared/media.mjs.map +1 -0
- package/dist/sandbox/shared/output.d.ts +12 -0
- package/dist/sandbox/shared/output.js +108 -0
- package/dist/sandbox/shared/output.js.map +1 -0
- package/dist/sandbox/shared/output.mjs +103 -0
- package/dist/sandbox/shared/output.mjs.map +1 -0
- package/dist/sandbox/shared/posixPath.d.ts +7 -0
- package/dist/sandbox/shared/posixPath.js +90 -0
- package/dist/sandbox/shared/posixPath.js.map +1 -0
- package/dist/sandbox/shared/posixPath.mjs +81 -0
- package/dist/sandbox/shared/posixPath.mjs.map +1 -0
- package/dist/sandbox/shared/remoteMountCommandAllowlist.d.ts +3 -0
- package/dist/sandbox/shared/remoteMountCommandAllowlist.js +33 -0
- package/dist/sandbox/shared/remoteMountCommandAllowlist.js.map +1 -0
- package/dist/sandbox/shared/remoteMountCommandAllowlist.mjs +28 -0
- package/dist/sandbox/shared/remoteMountCommandAllowlist.mjs.map +1 -0
- package/dist/sandbox/shared/shell.d.ts +1 -0
- package/dist/sandbox/shared/shell.js +7 -0
- package/dist/sandbox/shared/shell.js.map +1 -0
- package/dist/sandbox/shared/shell.mjs +4 -0
- package/dist/sandbox/shared/shell.mjs.map +1 -0
- package/dist/sandbox/shared/stableJson.d.ts +12 -0
- package/dist/sandbox/shared/stableJson.js +40 -0
- package/dist/sandbox/shared/stableJson.js.map +1 -0
- package/dist/sandbox/shared/stableJson.mjs +35 -0
- package/dist/sandbox/shared/stableJson.mjs.map +1 -0
- package/dist/sandbox/shared/typeGuards.d.ts +6 -0
- package/dist/sandbox/shared/typeGuards.js +34 -0
- package/dist/sandbox/shared/typeGuards.js.map +1 -0
- package/dist/sandbox/shared/typeGuards.mjs +26 -0
- package/dist/sandbox/shared/typeGuards.mjs.map +1 -0
- package/dist/sandbox/snapshot.d.ts +60 -0
- package/dist/sandbox/snapshot.js +45 -0
- package/dist/sandbox/snapshot.js.map +1 -0
- package/dist/sandbox/snapshot.mjs +39 -0
- package/dist/sandbox/snapshot.mjs.map +1 -0
- package/dist/sandbox/users.d.ts +11 -0
- package/dist/sandbox/users.js +31 -0
- package/dist/sandbox/users.js.map +1 -0
- package/dist/sandbox/users.mjs +26 -0
- package/dist/sandbox/users.mjs.map +1 -0
- package/dist/sandbox/workspacePaths.d.ts +20 -0
- package/dist/sandbox/workspacePaths.js +73 -0
- package/dist/sandbox/workspacePaths.js.map +1 -0
- package/dist/sandbox/workspacePaths.mjs +69 -0
- package/dist/sandbox/workspacePaths.mjs.map +1 -0
- package/dist/tool.js +1 -1
- package/dist/tool.js.map +1 -1
- package/dist/tool.mjs +1 -1
- package/dist/tool.mjs.map +1 -1
- package/dist/types/protocol.d.ts +8 -0
- package/dist/types/protocol.js +1 -0
- package/dist/types/protocol.js.map +1 -1
- package/dist/types/protocol.mjs +1 -0
- package/dist/types/protocol.mjs.map +1 -1
- package/dist/utils/messages.d.ts +6 -0
- package/dist/utils/messages.js +21 -0
- package/dist/utils/messages.js.map +1 -1
- package/dist/utils/messages.mjs +20 -0
- package/dist/utils/messages.mjs.map +1 -1
- package/dist/utils/strictToolSchema.d.ts +4 -0
- package/dist/utils/strictToolSchema.js +358 -0
- package/dist/utils/strictToolSchema.js.map +1 -0
- package/dist/utils/strictToolSchema.mjs +353 -0
- package/dist/utils/strictToolSchema.mjs.map +1 -0
- package/dist/utils/tools.d.ts +3 -1
- package/dist/utils/tools.js +18 -7
- package/dist/utils/tools.js.map +1 -1
- package/dist/utils/tools.mjs +18 -7
- package/dist/utils/tools.mjs.map +1 -1
- package/dist/utils/zodJsonSchemaCompat.js +18 -16
- package/dist/utils/zodJsonSchemaCompat.js.map +1 -1
- package/dist/utils/zodJsonSchemaCompat.mjs +18 -16
- package/dist/utils/zodJsonSchemaCompat.mjs.map +1 -1
- package/package.json +25 -1
package/dist/runState.js
CHANGED
|
@@ -37,7 +37,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.RunState = exports.SerializedRunState = exports.CURRENT_SCHEMA_VERSION = void 0;
|
|
40
|
+
exports.rehydrateProcessedResponseTools = rehydrateProcessedResponseTools;
|
|
40
41
|
exports.buildAgentMap = buildAgentMap;
|
|
42
|
+
exports.buildAgentIdentityMap = buildAgentIdentityMap;
|
|
41
43
|
exports.deserializeSpan = deserializeSpan;
|
|
42
44
|
exports.deserializeModelResponse = deserializeModelResponse;
|
|
43
45
|
exports.deserializeItem = deserializeItem;
|
|
@@ -56,11 +58,13 @@ const tracing_1 = require("./tracing/index.js");
|
|
|
56
58
|
const logger_1 = __importDefault(require("./logger.js"));
|
|
57
59
|
const handoff_1 = require("./handoff.js");
|
|
58
60
|
const protocol = __importStar(require("./types/protocol.js"));
|
|
61
|
+
const session_1 = require("./sandbox/session.js");
|
|
59
62
|
const safeExecute_1 = require("./utils/safeExecute.js");
|
|
60
63
|
const tool_1 = require("./tool.js");
|
|
61
64
|
const toolIdentity_1 = require("./toolIdentity.js");
|
|
62
65
|
const toolSearch_1 = require("./utils/toolSearch.js");
|
|
63
66
|
const toolSearch_2 = require("./runner/toolSearch.js");
|
|
67
|
+
const toolRehydration_1 = require("./sandbox/runtime/toolRehydration.js");
|
|
64
68
|
/**
|
|
65
69
|
* The schema version of the serialized run state. This is used to ensure that the serialized
|
|
66
70
|
* run state is compatible with the current version of the SDK.
|
|
@@ -79,8 +83,12 @@ const toolSearch_2 = require("./runner/toolSearch.js");
|
|
|
79
83
|
* - 1.7: Adds optional approval rejection messages.
|
|
80
84
|
* - 1.8: Adds tool search item variants, batched computer actions, and GA computer tool
|
|
81
85
|
* aliasing to serialized run state payloads.
|
|
86
|
+
* - 1.9: Adds optional sandbox session persistence with a versioned session-state
|
|
87
|
+
* envelope for sandbox-agent resume.
|
|
88
|
+
* - 1.10: Adds optional stable agent identity keys so duplicate-name agent graphs can
|
|
89
|
+
* serialize and resume without ambiguous name resolution.
|
|
82
90
|
*/
|
|
83
|
-
exports.CURRENT_SCHEMA_VERSION = '1.
|
|
91
|
+
exports.CURRENT_SCHEMA_VERSION = '1.10';
|
|
84
92
|
const SUPPORTED_SCHEMA_VERSIONS = [
|
|
85
93
|
'1.0',
|
|
86
94
|
'1.1',
|
|
@@ -90,11 +98,14 @@ const SUPPORTED_SCHEMA_VERSIONS = [
|
|
|
90
98
|
'1.5',
|
|
91
99
|
'1.6',
|
|
92
100
|
'1.7',
|
|
101
|
+
'1.8',
|
|
102
|
+
'1.9',
|
|
93
103
|
exports.CURRENT_SCHEMA_VERSION,
|
|
94
104
|
];
|
|
95
105
|
const $schemaVersion = zod_1.z.enum(SUPPORTED_SCHEMA_VERSIONS);
|
|
96
106
|
const serializedAgentSchema = zod_1.z.object({
|
|
97
107
|
name: zod_1.z.string(),
|
|
108
|
+
identity: zod_1.z.string().optional(),
|
|
98
109
|
});
|
|
99
110
|
const serializedSpanBase = zod_1.z.object({
|
|
100
111
|
object: zod_1.z.literal('trace.span'),
|
|
@@ -203,6 +214,32 @@ const serializedTraceSchema = zod_1.z.object({
|
|
|
203
214
|
// and serialization opts in to include it. By default this is omitted to avoid persisting secrets.
|
|
204
215
|
tracing_api_key: zod_1.z.string().optional().nullable(),
|
|
205
216
|
});
|
|
217
|
+
const sandboxSessionStateEnvelopeSchema = zod_1.z.object({
|
|
218
|
+
version: zod_1.z.literal(session_1.SANDBOX_SESSION_STATE_VERSION),
|
|
219
|
+
backendId: zod_1.z.string(),
|
|
220
|
+
manifest: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
|
|
221
|
+
snapshot: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).nullable().optional(),
|
|
222
|
+
snapshotFingerprint: zod_1.z.string().nullable().optional(),
|
|
223
|
+
snapshotFingerprintVersion: zod_1.z.string().nullable().optional(),
|
|
224
|
+
workspaceReady: zod_1.z.boolean(),
|
|
225
|
+
exposedPorts: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
|
|
226
|
+
providerState: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
|
|
227
|
+
});
|
|
228
|
+
const sandboxSessionEntrySchema = zod_1.z.object({
|
|
229
|
+
backendId: zod_1.z.string(),
|
|
230
|
+
currentAgentKey: zod_1.z.string(),
|
|
231
|
+
currentAgentName: zod_1.z.string(),
|
|
232
|
+
sessionState: sandboxSessionStateEnvelopeSchema,
|
|
233
|
+
preservedOwnedSession: zod_1.z.boolean().optional(),
|
|
234
|
+
reuseLiveSession: zod_1.z.boolean().optional(),
|
|
235
|
+
});
|
|
236
|
+
const sandboxStateSchema = zod_1.z.object({
|
|
237
|
+
backendId: zod_1.z.string(),
|
|
238
|
+
currentAgentKey: zod_1.z.string(),
|
|
239
|
+
currentAgentName: zod_1.z.string(),
|
|
240
|
+
sessionState: sandboxSessionStateEnvelopeSchema,
|
|
241
|
+
sessionsByAgent: zod_1.z.record(zod_1.z.string(), sandboxSessionEntrySchema),
|
|
242
|
+
});
|
|
206
243
|
const serializedProcessedResponseSchema = zod_1.z.object({
|
|
207
244
|
newItems: zod_1.z.array(itemSchema),
|
|
208
245
|
toolsUsed: zod_1.z.array(zod_1.z.string()),
|
|
@@ -343,6 +380,7 @@ exports.SerializedRunState = zod_1.z.object({
|
|
|
343
380
|
previousResponseId: zod_1.z.string().optional(),
|
|
344
381
|
reasoningItemIdPolicy: zod_1.z.enum(['preserve', 'omit']).optional(),
|
|
345
382
|
trace: serializedTraceSchema.nullable(),
|
|
383
|
+
sandbox: sandboxStateSchema.optional(),
|
|
346
384
|
});
|
|
347
385
|
/**
|
|
348
386
|
* Serializable snapshot of an agent's run, including context, usage and trace.
|
|
@@ -481,10 +519,14 @@ class RunState {
|
|
|
481
519
|
*/
|
|
482
520
|
_trace = null;
|
|
483
521
|
/**
|
|
484
|
-
* Runtime-only tool_search-loaded tools, scoped by agent
|
|
522
|
+
* Runtime-only tool_search-loaded tools, scoped by agent object and preserved across turns for
|
|
485
523
|
* the lifetime of this in-memory run.
|
|
486
524
|
*/
|
|
487
|
-
|
|
525
|
+
_toolSearchRuntimeToolsByAgent = new Map();
|
|
526
|
+
/**
|
|
527
|
+
* Persisted sandbox session metadata for sandbox-agent resume.
|
|
528
|
+
*/
|
|
529
|
+
_sandbox = undefined;
|
|
488
530
|
constructor(context, originalInput, startingAgent, maxTurns) {
|
|
489
531
|
this._context = context;
|
|
490
532
|
this._agentToolInvocation = undefined;
|
|
@@ -524,20 +566,20 @@ class RunState {
|
|
|
524
566
|
setCurrentAgentSpan(span) {
|
|
525
567
|
this._currentAgentSpan = span;
|
|
526
568
|
}
|
|
527
|
-
getOrCreateToolSearchRuntimeToolState(
|
|
528
|
-
let state = this.
|
|
569
|
+
getOrCreateToolSearchRuntimeToolState(agent) {
|
|
570
|
+
let state = this._toolSearchRuntimeToolsByAgent.get(agent);
|
|
529
571
|
if (!state) {
|
|
530
572
|
state = {
|
|
531
573
|
anonymousEntries: [],
|
|
532
574
|
keyedEntries: new Map(),
|
|
533
575
|
nextOrder: 0,
|
|
534
576
|
};
|
|
535
|
-
this.
|
|
577
|
+
this._toolSearchRuntimeToolsByAgent.set(agent, state);
|
|
536
578
|
}
|
|
537
579
|
return state;
|
|
538
580
|
}
|
|
539
581
|
recordToolSearchRuntimeTools(agent, toolSearchOutput, tools) {
|
|
540
|
-
const runtimeState = this.getOrCreateToolSearchRuntimeToolState(agent
|
|
582
|
+
const runtimeState = this.getOrCreateToolSearchRuntimeToolState(agent);
|
|
541
583
|
const entry = {
|
|
542
584
|
order: runtimeState.nextOrder++,
|
|
543
585
|
tools,
|
|
@@ -550,7 +592,7 @@ class RunState {
|
|
|
550
592
|
runtimeState.anonymousEntries.push(entry);
|
|
551
593
|
}
|
|
552
594
|
getToolSearchRuntimeTools(agent) {
|
|
553
|
-
const runtimeState = this.
|
|
595
|
+
const runtimeState = this._toolSearchRuntimeToolsByAgent.get(agent);
|
|
554
596
|
if (!runtimeState) {
|
|
555
597
|
return [];
|
|
556
598
|
}
|
|
@@ -687,15 +729,13 @@ class RunState {
|
|
|
687
729
|
* rehydrate in a separate process that lacks the original environment variables).
|
|
688
730
|
*/
|
|
689
731
|
toJSON(options = {}) {
|
|
690
|
-
|
|
732
|
+
const agentIdentity = buildAgentIdentityMap(this.#startingAgent);
|
|
691
733
|
const includeTracingApiKey = options.includeTracingApiKey === true;
|
|
692
734
|
const contextJson = this._context.toJSON();
|
|
693
735
|
const output = {
|
|
694
736
|
$schemaVersion: exports.CURRENT_SCHEMA_VERSION,
|
|
695
737
|
currentTurn: this._currentTurn,
|
|
696
|
-
currentAgent:
|
|
697
|
-
name: this._currentAgent.name,
|
|
698
|
-
},
|
|
738
|
+
currentAgent: serializeAgentReference(this._currentAgent, agentIdentity.byAgent),
|
|
699
739
|
originalInput: this._originalInput,
|
|
700
740
|
modelResponses: this._modelResponses.map((response) => {
|
|
701
741
|
return {
|
|
@@ -727,7 +767,9 @@ class RunState {
|
|
|
727
767
|
};
|
|
728
768
|
}),
|
|
729
769
|
context: contextJson,
|
|
730
|
-
toolUseTracker: this._toolUseTracker.toJSON(
|
|
770
|
+
toolUseTracker: this._toolUseTracker.toJSON({
|
|
771
|
+
agentIdentityKeys: agentIdentity.byAgent,
|
|
772
|
+
}),
|
|
731
773
|
maxTurns: this._maxTurns,
|
|
732
774
|
currentAgentSpan: this._currentAgentSpan?.toJSON(),
|
|
733
775
|
noActiveAgentRun: this._noActiveAgentRun,
|
|
@@ -735,22 +777,25 @@ class RunState {
|
|
|
735
777
|
inputGuardrailResults: this._inputGuardrailResults,
|
|
736
778
|
outputGuardrailResults: this._outputGuardrailResults.map((r) => ({
|
|
737
779
|
...r,
|
|
738
|
-
agent: r.agent.
|
|
780
|
+
agent: serializeAgentReference(r.agent, agentIdentity.byAgent),
|
|
739
781
|
})),
|
|
740
782
|
toolInputGuardrailResults: this._toolInputGuardrailResults,
|
|
741
783
|
toolOutputGuardrailResults: this._toolOutputGuardrailResults,
|
|
742
|
-
currentStep: this._currentStep,
|
|
784
|
+
currentStep: serializeCurrentStep(this._currentStep, agentIdentity.byAgent),
|
|
743
785
|
lastModelResponse: this._lastTurnResponse,
|
|
744
|
-
generatedItems: this._generatedItems.map((item) => item.
|
|
786
|
+
generatedItems: this._generatedItems.map((item) => serializeRunItem(item, agentIdentity.byAgent)),
|
|
745
787
|
pendingAgentToolRuns: Object.fromEntries(this._pendingAgentToolRuns.entries()),
|
|
746
788
|
currentTurnPersistedItemCount: this._currentTurnPersistedItemCount,
|
|
747
|
-
lastProcessedResponse: this._lastProcessedResponse
|
|
789
|
+
lastProcessedResponse: this._lastProcessedResponse
|
|
790
|
+
? serializeProcessedResponse(this._lastProcessedResponse, agentIdentity.byAgent)
|
|
791
|
+
: undefined,
|
|
748
792
|
conversationId: this._conversationId,
|
|
749
793
|
previousResponseId: this._previousResponseId,
|
|
750
794
|
reasoningItemIdPolicy: this._reasoningItemIdPolicy,
|
|
751
795
|
trace: this._trace
|
|
752
796
|
? this._trace.toJSON({ includeTracingApiKey })
|
|
753
797
|
: null,
|
|
798
|
+
sandbox: this._sandbox,
|
|
754
799
|
};
|
|
755
800
|
// parsing the schema to ensure the output is valid for reparsing
|
|
756
801
|
const parsed = exports.SerializedRunState.safeParse(output);
|
|
@@ -804,7 +849,9 @@ async function buildRunStateFromString(initialAgent, str, options = {}) {
|
|
|
804
849
|
return buildRunStateFromJson(initialAgent, stateJson, options);
|
|
805
850
|
}
|
|
806
851
|
function assertSchemaVersionSupportsToolSearch(schemaVersion, stateJson) {
|
|
807
|
-
if (schemaVersion === '1.8'
|
|
852
|
+
if (schemaVersion === '1.8' ||
|
|
853
|
+
schemaVersion === '1.9' ||
|
|
854
|
+
schemaVersion === exports.CURRENT_SCHEMA_VERSION) {
|
|
808
855
|
return;
|
|
809
856
|
}
|
|
810
857
|
if (!containsSerializedToolSearchState(stateJson)) {
|
|
@@ -812,6 +859,9 @@ function assertSchemaVersionSupportsToolSearch(schemaVersion, stateJson) {
|
|
|
812
859
|
}
|
|
813
860
|
throw new errors_1.UserError(`Run state schema version ${schemaVersion} does not support tool_search items. Please reserialize the run state with schema ${exports.CURRENT_SCHEMA_VERSION}.`);
|
|
814
861
|
}
|
|
862
|
+
function schemaVersionSupportsAgentIdentity(schemaVersion) {
|
|
863
|
+
return schemaVersion === exports.CURRENT_SCHEMA_VERSION;
|
|
864
|
+
}
|
|
815
865
|
function containsSerializedToolSearchState(stateJson) {
|
|
816
866
|
return (containsToolSearchProtocolItems(stateJson.originalInput) ||
|
|
817
867
|
containsToolSearchInModelResponses(stateJson.modelResponses) ||
|
|
@@ -915,17 +965,17 @@ function assertRuntimeToolKeysMatch(args) {
|
|
|
915
965
|
throw new errors_1.UserError(`RunState cannot resume custom client tool_search call ${callId} for agent ${agent.name} because the registered execute callback returned runtime tools [${formatRuntimeToolKeys(actualRuntimeToolKeys)}] but the serialized state expects [${formatRuntimeToolKeys(expectedRuntimeToolKeys)}].`);
|
|
916
966
|
}
|
|
917
967
|
async function getConfiguredAgentTools(args) {
|
|
918
|
-
const { agent, context,
|
|
919
|
-
const existing =
|
|
968
|
+
const { agent, context, configuredToolsByAgent } = args;
|
|
969
|
+
const existing = configuredToolsByAgent.get(agent);
|
|
920
970
|
if (existing) {
|
|
921
971
|
return existing;
|
|
922
972
|
}
|
|
923
973
|
const configuredTools = (await agent.getAllTools(context));
|
|
924
|
-
|
|
974
|
+
configuredToolsByAgent.set(agent, configuredTools);
|
|
925
975
|
return configuredTools;
|
|
926
976
|
}
|
|
927
977
|
async function rehydrateToolSearchRuntimeTools(state) {
|
|
928
|
-
const
|
|
978
|
+
const configuredToolsByAgent = new Map();
|
|
929
979
|
const pendingToolSearchCalls = new Map();
|
|
930
980
|
for (const item of state._generatedItems) {
|
|
931
981
|
if (item instanceof items_1.RunToolSearchCallItem) {
|
|
@@ -933,10 +983,14 @@ async function rehydrateToolSearchRuntimeTools(state) {
|
|
|
933
983
|
continue;
|
|
934
984
|
}
|
|
935
985
|
const callId = (0, toolSearch_1.resolveToolSearchCallId)(item.rawItem);
|
|
936
|
-
|
|
986
|
+
const agent = item.agent;
|
|
987
|
+
const pendingCallsById = pendingToolSearchCalls.get(agent) ??
|
|
988
|
+
new Map();
|
|
989
|
+
pendingCallsById.set(callId, {
|
|
937
990
|
agent: item.agent,
|
|
938
991
|
toolSearchCall: item.rawItem,
|
|
939
992
|
});
|
|
993
|
+
pendingToolSearchCalls.set(agent, pendingCallsById);
|
|
940
994
|
continue;
|
|
941
995
|
}
|
|
942
996
|
if (!(item instanceof items_1.RunToolSearchOutputItem)) {
|
|
@@ -948,7 +1002,7 @@ async function rehydrateToolSearchRuntimeTools(state) {
|
|
|
948
1002
|
const configuredTools = await getConfiguredAgentTools({
|
|
949
1003
|
agent: item.agent,
|
|
950
1004
|
context: state._context,
|
|
951
|
-
|
|
1005
|
+
configuredToolsByAgent,
|
|
952
1006
|
});
|
|
953
1007
|
const configuredToolKeys = getRuntimeToolKeys(configuredTools, {
|
|
954
1008
|
allowUnsupported: true,
|
|
@@ -958,7 +1012,9 @@ async function rehydrateToolSearchRuntimeTools(state) {
|
|
|
958
1012
|
continue;
|
|
959
1013
|
}
|
|
960
1014
|
const callId = (0, toolSearch_1.resolveToolSearchCallId)(item.rawItem);
|
|
961
|
-
const pendingCall = pendingToolSearchCalls
|
|
1015
|
+
const pendingCall = pendingToolSearchCalls
|
|
1016
|
+
.get(item.agent)
|
|
1017
|
+
?.get(callId);
|
|
962
1018
|
if (!pendingCall) {
|
|
963
1019
|
throw new errors_1.UserError(`RunState cannot resume custom client tool_search output ${callId} for agent ${item.agent.name} because the serialized state is missing the matching tool_search call item.`);
|
|
964
1020
|
}
|
|
@@ -1001,7 +1057,9 @@ async function rehydrateToolSearchRuntimeTools(state) {
|
|
|
1001
1057
|
}
|
|
1002
1058
|
}
|
|
1003
1059
|
async function buildRunStateFromJson(initialAgent, stateJson, options = {}) {
|
|
1004
|
-
const agentMap =
|
|
1060
|
+
const agentMap = schemaVersionSupportsAgentIdentity(stateJson.$schemaVersion)
|
|
1061
|
+
? buildAgentIdentityMap(initialAgent).byIdentity
|
|
1062
|
+
: buildAgentMap(initialAgent);
|
|
1005
1063
|
const contextOverride = options.contextOverride;
|
|
1006
1064
|
const contextStrategy = options.contextStrategy ?? 'merge';
|
|
1007
1065
|
//
|
|
@@ -1026,10 +1084,7 @@ async function buildRunStateFromJson(initialAgent, stateJson, options = {}) {
|
|
|
1026
1084
|
//
|
|
1027
1085
|
// Find the current agent from the initial agent
|
|
1028
1086
|
//
|
|
1029
|
-
const currentAgent =
|
|
1030
|
-
if (!currentAgent) {
|
|
1031
|
-
throw new errors_1.UserError(`Agent ${stateJson.currentAgent.name} not found`);
|
|
1032
|
-
}
|
|
1087
|
+
const currentAgent = resolveSerializedAgent(stateJson.currentAgent, agentMap);
|
|
1033
1088
|
const state = new RunState(context, '', initialAgent, stateJson.maxTurns);
|
|
1034
1089
|
state._currentAgent = currentAgent;
|
|
1035
1090
|
state._currentTurn = stateJson.currentTurn;
|
|
@@ -1040,7 +1095,13 @@ async function buildRunStateFromJson(initialAgent, stateJson, options = {}) {
|
|
|
1040
1095
|
// rebuild tool use tracker
|
|
1041
1096
|
state._toolUseTracker = new toolUseTracker_1.AgentToolUseTracker();
|
|
1042
1097
|
for (const [agentName, toolNames] of Object.entries(stateJson.toolUseTracker)) {
|
|
1043
|
-
|
|
1098
|
+
const agent = agentMap.get(agentName);
|
|
1099
|
+
if (!agent) {
|
|
1100
|
+
throw new errors_1.UserError(`Agent ${agentName} not found`);
|
|
1101
|
+
}
|
|
1102
|
+
state._toolUseTracker.addToolUse(agent, toolNames, {
|
|
1103
|
+
allowEmpty: true,
|
|
1104
|
+
});
|
|
1044
1105
|
}
|
|
1045
1106
|
state._pendingAgentToolRuns = new Map(Object.entries(stateJson.pendingAgentToolRuns ?? {}));
|
|
1046
1107
|
// rebuild current agent span
|
|
@@ -1063,7 +1124,7 @@ async function buildRunStateFromJson(initialAgent, stateJson, options = {}) {
|
|
|
1063
1124
|
stateJson.inputGuardrailResults;
|
|
1064
1125
|
state._outputGuardrailResults = stateJson.outputGuardrailResults.map((r) => ({
|
|
1065
1126
|
...r,
|
|
1066
|
-
agent:
|
|
1127
|
+
agent: resolveSerializedAgent(r.agent, agentMap),
|
|
1067
1128
|
}));
|
|
1068
1129
|
state._toolInputGuardrailResults =
|
|
1069
1130
|
stateJson.toolInputGuardrailResults;
|
|
@@ -1078,6 +1139,7 @@ async function buildRunStateFromJson(initialAgent, stateJson, options = {}) {
|
|
|
1078
1139
|
state._generatedItems = stateJson.generatedItems.map((item) => deserializeItem(item, agentMap));
|
|
1079
1140
|
state._currentTurnPersistedItemCount =
|
|
1080
1141
|
stateJson.currentTurnPersistedItemCount ?? 0;
|
|
1142
|
+
state._sandbox = stateJson.sandbox ?? undefined;
|
|
1081
1143
|
await rehydrateToolSearchRuntimeTools(state);
|
|
1082
1144
|
state._lastProcessedResponse = stateJson.lastProcessedResponse
|
|
1083
1145
|
? await deserializeProcessedResponse(agentMap, state, stateJson.lastProcessedResponse)
|
|
@@ -1085,7 +1147,7 @@ async function buildRunStateFromJson(initialAgent, stateJson, options = {}) {
|
|
|
1085
1147
|
if (stateJson.currentStep?.type === 'next_step_handoff') {
|
|
1086
1148
|
state._currentStep = {
|
|
1087
1149
|
type: 'next_step_handoff',
|
|
1088
|
-
newAgent:
|
|
1150
|
+
newAgent: resolveSerializedAgent(stateJson.currentStep.newAgent, agentMap),
|
|
1089
1151
|
};
|
|
1090
1152
|
}
|
|
1091
1153
|
else if (stateJson.currentStep?.type === 'next_step_interruption') {
|
|
@@ -1099,6 +1161,20 @@ async function buildRunStateFromJson(initialAgent, stateJson, options = {}) {
|
|
|
1099
1161
|
}
|
|
1100
1162
|
return state;
|
|
1101
1163
|
}
|
|
1164
|
+
/**
|
|
1165
|
+
* @internal
|
|
1166
|
+
*/
|
|
1167
|
+
async function rehydrateProcessedResponseTools(initialAgent, state, executionTools) {
|
|
1168
|
+
if (!state._lastProcessedResponse) {
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1171
|
+
const agentIdentity = buildAgentIdentityMap(initialAgent);
|
|
1172
|
+
const serializedProcessedResponse = serializeProcessedResponse(state._lastProcessedResponse, agentIdentity.byAgent);
|
|
1173
|
+
state._lastProcessedResponse = await deserializeProcessedResponse(agentIdentity.byIdentity, state, serializedProcessedResponse, {
|
|
1174
|
+
executionTools,
|
|
1175
|
+
allowSerializedExecutionToolPlaceholder: false,
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1102
1178
|
/**
|
|
1103
1179
|
* @internal
|
|
1104
1180
|
*/
|
|
@@ -1134,6 +1210,249 @@ function buildAgentMap(initialAgent) {
|
|
|
1134
1210
|
}
|
|
1135
1211
|
return map;
|
|
1136
1212
|
}
|
|
1213
|
+
/**
|
|
1214
|
+
* @internal
|
|
1215
|
+
*/
|
|
1216
|
+
function buildAgentIdentityMap(initialAgent) {
|
|
1217
|
+
const agents = collectAgentGraph(initialAgent);
|
|
1218
|
+
const groups = new Map();
|
|
1219
|
+
const literalNames = new Set();
|
|
1220
|
+
for (const entry of agents) {
|
|
1221
|
+
literalNames.add(entry.agent.name);
|
|
1222
|
+
const group = groups.get(entry.agent.name) ?? [];
|
|
1223
|
+
group.push(entry);
|
|
1224
|
+
groups.set(entry.agent.name, group);
|
|
1225
|
+
}
|
|
1226
|
+
const byIdentity = new Map();
|
|
1227
|
+
const byAgent = new Map();
|
|
1228
|
+
const usedIdentities = new Set();
|
|
1229
|
+
for (const [agentName, group] of groups) {
|
|
1230
|
+
const sortedGroup = group.length === 1
|
|
1231
|
+
? group
|
|
1232
|
+
: [...group].sort((left, right) => {
|
|
1233
|
+
if (left.agent === initialAgent) {
|
|
1234
|
+
return -1;
|
|
1235
|
+
}
|
|
1236
|
+
if (right.agent === initialAgent) {
|
|
1237
|
+
return 1;
|
|
1238
|
+
}
|
|
1239
|
+
const leftSignature = getAgentIdentitySignature(left.agent);
|
|
1240
|
+
const rightSignature = getAgentIdentitySignature(right.agent);
|
|
1241
|
+
if (leftSignature !== rightSignature) {
|
|
1242
|
+
return leftSignature < rightSignature ? -1 : 1;
|
|
1243
|
+
}
|
|
1244
|
+
return left.index - right.index;
|
|
1245
|
+
});
|
|
1246
|
+
let nextSuffix = 0;
|
|
1247
|
+
for (const { agent } of sortedGroup) {
|
|
1248
|
+
let identity;
|
|
1249
|
+
do {
|
|
1250
|
+
identity =
|
|
1251
|
+
nextSuffix === 0 ? agentName : `${agentName}#${nextSuffix + 1}`;
|
|
1252
|
+
nextSuffix += 1;
|
|
1253
|
+
} while (usedIdentities.has(identity) ||
|
|
1254
|
+
(identity !== agent.name && literalNames.has(identity)));
|
|
1255
|
+
usedIdentities.add(identity);
|
|
1256
|
+
byIdentity.set(identity, agent);
|
|
1257
|
+
byAgent.set(agent, identity);
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
return { byIdentity, byAgent };
|
|
1261
|
+
}
|
|
1262
|
+
function collectAgentGraph(initialAgent) {
|
|
1263
|
+
const agents = [];
|
|
1264
|
+
const visitedAgents = new Set();
|
|
1265
|
+
const queue = [initialAgent];
|
|
1266
|
+
while (queue.length > 0) {
|
|
1267
|
+
const currentAgent = queue.shift();
|
|
1268
|
+
if (visitedAgents.has(currentAgent)) {
|
|
1269
|
+
continue;
|
|
1270
|
+
}
|
|
1271
|
+
visitedAgents.add(currentAgent);
|
|
1272
|
+
agents.push({ agent: currentAgent, index: agents.length });
|
|
1273
|
+
for (const handoff of currentAgent.handoffs) {
|
|
1274
|
+
if (handoff instanceof agent_1.Agent) {
|
|
1275
|
+
queue.push(handoff);
|
|
1276
|
+
}
|
|
1277
|
+
else if (handoff.agent) {
|
|
1278
|
+
queue.push(handoff.agent);
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
for (const tool of currentAgent.tools) {
|
|
1282
|
+
const sourceAgent = (0, agentToolSourceRegistry_1.getAgentToolSourceAgent)(tool);
|
|
1283
|
+
if (sourceAgent) {
|
|
1284
|
+
queue.push(sourceAgent);
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
return agents;
|
|
1289
|
+
}
|
|
1290
|
+
function getAgentIdentitySignature(agent) {
|
|
1291
|
+
const sandboxAgent = agent;
|
|
1292
|
+
const signature = {
|
|
1293
|
+
type: agent.constructor?.name,
|
|
1294
|
+
name: agent.name,
|
|
1295
|
+
handoffDescription: agent.handoffDescription,
|
|
1296
|
+
instructions: summarizeIdentityValue(agent.instructions),
|
|
1297
|
+
prompt: summarizeIdentityValue(agent.prompt),
|
|
1298
|
+
model: summarizeIdentityValue(agent.model),
|
|
1299
|
+
modelSettings: summarizeIdentityValue(agent.modelSettings),
|
|
1300
|
+
tools: agent.tools.map(summarizeToolIdentity),
|
|
1301
|
+
handoffs: agent.handoffs.map((entry) => entry instanceof agent_1.Agent
|
|
1302
|
+
? { type: 'agent', name: entry.name }
|
|
1303
|
+
: {
|
|
1304
|
+
type: 'handoff',
|
|
1305
|
+
toolName: entry.toolName,
|
|
1306
|
+
agentName: entry.agentName,
|
|
1307
|
+
targetName: entry.agent?.name,
|
|
1308
|
+
}),
|
|
1309
|
+
mcpServers: agent.mcpServers.map(summarizeIdentityValue),
|
|
1310
|
+
inputGuardrails: agent.inputGuardrails.map(summarizeIdentityValue),
|
|
1311
|
+
outputGuardrails: agent.outputGuardrails.map(summarizeIdentityValue),
|
|
1312
|
+
outputType: summarizeIdentityValue(agent.outputType),
|
|
1313
|
+
toolUseBehavior: summarizeIdentityValue(agent.toolUseBehavior),
|
|
1314
|
+
resetToolChoice: agent.resetToolChoice,
|
|
1315
|
+
defaultManifest: summarizeIdentityValue(sandboxAgent.defaultManifest),
|
|
1316
|
+
baseInstructions: summarizeIdentityValue(sandboxAgent.baseInstructions),
|
|
1317
|
+
capabilities: sandboxAgent.capabilities?.map(summarizeIdentityValue),
|
|
1318
|
+
runAs: summarizeIdentityValue(sandboxAgent.runAs),
|
|
1319
|
+
};
|
|
1320
|
+
return stableStringify(signature);
|
|
1321
|
+
}
|
|
1322
|
+
function summarizeToolIdentity(tool) {
|
|
1323
|
+
return {
|
|
1324
|
+
type: tool.type,
|
|
1325
|
+
name: tool.name,
|
|
1326
|
+
namespace: tool.namespace,
|
|
1327
|
+
strict: tool.strict,
|
|
1328
|
+
parameters: summarizeIdentityValue(tool.parameters),
|
|
1329
|
+
};
|
|
1330
|
+
}
|
|
1331
|
+
function summarizeIdentityValue(value) {
|
|
1332
|
+
return normalizeForIdentity(value, new WeakSet(), 0);
|
|
1333
|
+
}
|
|
1334
|
+
function normalizeForIdentity(value, seen, depth) {
|
|
1335
|
+
if (value === null || typeof value === 'undefined') {
|
|
1336
|
+
return value;
|
|
1337
|
+
}
|
|
1338
|
+
if (typeof value === 'string' ||
|
|
1339
|
+
typeof value === 'number' ||
|
|
1340
|
+
typeof value === 'boolean') {
|
|
1341
|
+
return value;
|
|
1342
|
+
}
|
|
1343
|
+
if (typeof value === 'function') {
|
|
1344
|
+
return `[function:${value.name || 'anonymous'}]`;
|
|
1345
|
+
}
|
|
1346
|
+
if (typeof value !== 'object') {
|
|
1347
|
+
return String(value);
|
|
1348
|
+
}
|
|
1349
|
+
if (seen.has(value)) {
|
|
1350
|
+
return '[circular]';
|
|
1351
|
+
}
|
|
1352
|
+
if (depth >= 4) {
|
|
1353
|
+
return `[${value.constructor?.name ?? 'Object'}]`;
|
|
1354
|
+
}
|
|
1355
|
+
seen.add(value);
|
|
1356
|
+
if (Array.isArray(value)) {
|
|
1357
|
+
return value.map((item) => normalizeForIdentity(item, seen, depth + 1));
|
|
1358
|
+
}
|
|
1359
|
+
if (value instanceof Map) {
|
|
1360
|
+
return [...value.entries()]
|
|
1361
|
+
.map(([key, entryValue]) => [
|
|
1362
|
+
normalizeForIdentity(key, seen, depth + 1),
|
|
1363
|
+
normalizeForIdentity(entryValue, seen, depth + 1),
|
|
1364
|
+
])
|
|
1365
|
+
.sort((left, right) => stableStringify(left).localeCompare(stableStringify(right)));
|
|
1366
|
+
}
|
|
1367
|
+
if (value instanceof Set) {
|
|
1368
|
+
return [...value.values()]
|
|
1369
|
+
.map((entry) => normalizeForIdentity(entry, seen, depth + 1))
|
|
1370
|
+
.sort((left, right) => stableStringify(left).localeCompare(stableStringify(right)));
|
|
1371
|
+
}
|
|
1372
|
+
const record = value;
|
|
1373
|
+
const normalized = {
|
|
1374
|
+
constructor: value.constructor?.name,
|
|
1375
|
+
};
|
|
1376
|
+
for (const key of Object.keys(record).sort()) {
|
|
1377
|
+
normalized[key] = normalizeForIdentity(record[key], seen, depth + 1);
|
|
1378
|
+
}
|
|
1379
|
+
return normalized;
|
|
1380
|
+
}
|
|
1381
|
+
function stableStringify(value) {
|
|
1382
|
+
return JSON.stringify(value, (_key, currentValue) => {
|
|
1383
|
+
if (!currentValue ||
|
|
1384
|
+
typeof currentValue !== 'object' ||
|
|
1385
|
+
Array.isArray(currentValue)) {
|
|
1386
|
+
return currentValue;
|
|
1387
|
+
}
|
|
1388
|
+
return Object.fromEntries(Object.entries(currentValue).sort(([left], [right]) => left.localeCompare(right)));
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
function serializeAgentReference(agent, agentIdentityKeys) {
|
|
1392
|
+
const identity = agentIdentityKeys.get(agent);
|
|
1393
|
+
if (!identity || identity === agent.name) {
|
|
1394
|
+
return { name: agent.name };
|
|
1395
|
+
}
|
|
1396
|
+
return { name: agent.name, identity };
|
|
1397
|
+
}
|
|
1398
|
+
function resolveSerializedAgent(serializedAgent, agentMap, fallbackAgent) {
|
|
1399
|
+
const identity = serializedAgent.identity ?? serializedAgent.name;
|
|
1400
|
+
const agent = agentMap.get(identity);
|
|
1401
|
+
if (agent) {
|
|
1402
|
+
return agent;
|
|
1403
|
+
}
|
|
1404
|
+
if (!serializedAgent.identity && fallbackAgent) {
|
|
1405
|
+
return fallbackAgent;
|
|
1406
|
+
}
|
|
1407
|
+
if (serializedAgent.identity) {
|
|
1408
|
+
throw new errors_1.UserError(`Agent identity ${serializedAgent.identity} not found`);
|
|
1409
|
+
}
|
|
1410
|
+
throw new errors_1.UserError(`Agent ${serializedAgent.name} not found`);
|
|
1411
|
+
}
|
|
1412
|
+
function serializeRunItem(item, agentIdentityKeys) {
|
|
1413
|
+
const serialized = item.toJSON();
|
|
1414
|
+
switch (item.type) {
|
|
1415
|
+
case 'handoff_output_item':
|
|
1416
|
+
serialized.sourceAgent = serializeAgentReference(item.sourceAgent, agentIdentityKeys);
|
|
1417
|
+
serialized.targetAgent = serializeAgentReference(item.targetAgent, agentIdentityKeys);
|
|
1418
|
+
return serialized;
|
|
1419
|
+
default:
|
|
1420
|
+
serialized.agent = serializeAgentReference(item.agent, agentIdentityKeys);
|
|
1421
|
+
return serialized;
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
function serializeCurrentStep(currentStep, agentIdentityKeys) {
|
|
1425
|
+
if (!currentStep) {
|
|
1426
|
+
return undefined;
|
|
1427
|
+
}
|
|
1428
|
+
if (currentStep.type === 'next_step_handoff') {
|
|
1429
|
+
return {
|
|
1430
|
+
...currentStep,
|
|
1431
|
+
newAgent: serializeAgentReference(currentStep.newAgent, agentIdentityKeys),
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
if (currentStep.type === 'next_step_interruption') {
|
|
1435
|
+
const interruptions = Array.isArray(currentStep.data?.interruptions)
|
|
1436
|
+
? currentStep.data.interruptions.map((item) => item instanceof items_1.RunToolApprovalItem
|
|
1437
|
+
? serializeRunItem(item, agentIdentityKeys)
|
|
1438
|
+
: item)
|
|
1439
|
+
: currentStep.data?.interruptions;
|
|
1440
|
+
return {
|
|
1441
|
+
...currentStep,
|
|
1442
|
+
data: {
|
|
1443
|
+
...currentStep.data,
|
|
1444
|
+
interruptions,
|
|
1445
|
+
},
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1448
|
+
return currentStep;
|
|
1449
|
+
}
|
|
1450
|
+
function serializeProcessedResponse(processedResponse, agentIdentityKeys) {
|
|
1451
|
+
return {
|
|
1452
|
+
...processedResponse,
|
|
1453
|
+
newItems: processedResponse.newItems.map((item) => serializeRunItem(item, agentIdentityKeys)),
|
|
1454
|
+
};
|
|
1455
|
+
}
|
|
1137
1456
|
/**
|
|
1138
1457
|
* @internal
|
|
1139
1458
|
*/
|
|
@@ -1172,23 +1491,23 @@ function deserializeModelResponse(serializedModelResponse) {
|
|
|
1172
1491
|
function deserializeItem(serializedItem, agentMap) {
|
|
1173
1492
|
switch (serializedItem.type) {
|
|
1174
1493
|
case 'message_output_item':
|
|
1175
|
-
return new items_1.RunMessageOutputItem(serializedItem.rawItem,
|
|
1494
|
+
return new items_1.RunMessageOutputItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.agent, agentMap));
|
|
1176
1495
|
case 'tool_search_call_item':
|
|
1177
|
-
return new items_1.RunToolSearchCallItem(serializedItem.rawItem,
|
|
1496
|
+
return new items_1.RunToolSearchCallItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.agent, agentMap));
|
|
1178
1497
|
case 'tool_search_output_item':
|
|
1179
|
-
return new items_1.RunToolSearchOutputItem(serializedItem.rawItem,
|
|
1498
|
+
return new items_1.RunToolSearchOutputItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.agent, agentMap));
|
|
1180
1499
|
case 'tool_call_item':
|
|
1181
|
-
return new items_1.RunToolCallItem(serializedItem.rawItem,
|
|
1500
|
+
return new items_1.RunToolCallItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.agent, agentMap));
|
|
1182
1501
|
case 'tool_call_output_item':
|
|
1183
|
-
return new items_1.RunToolCallOutputItem(serializedItem.rawItem,
|
|
1502
|
+
return new items_1.RunToolCallOutputItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.agent, agentMap), serializedItem.output);
|
|
1184
1503
|
case 'reasoning_item':
|
|
1185
|
-
return new items_1.RunReasoningItem(serializedItem.rawItem,
|
|
1504
|
+
return new items_1.RunReasoningItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.agent, agentMap));
|
|
1186
1505
|
case 'handoff_call_item':
|
|
1187
|
-
return new items_1.RunHandoffCallItem(serializedItem.rawItem,
|
|
1506
|
+
return new items_1.RunHandoffCallItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.agent, agentMap));
|
|
1188
1507
|
case 'handoff_output_item':
|
|
1189
|
-
return new items_1.RunHandoffOutputItem(serializedItem.rawItem,
|
|
1508
|
+
return new items_1.RunHandoffOutputItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.sourceAgent, agentMap), resolveSerializedAgent(serializedItem.targetAgent, agentMap));
|
|
1190
1509
|
case 'tool_approval_item':
|
|
1191
|
-
return new items_1.RunToolApprovalItem(serializedItem.rawItem,
|
|
1510
|
+
return new items_1.RunToolApprovalItem(serializedItem.rawItem, resolveSerializedAgent(serializedItem.agent, agentMap), serializedItem.toolName);
|
|
1192
1511
|
}
|
|
1193
1512
|
}
|
|
1194
1513
|
function deserializeInterruptionItem(serializedItem, agentMap, currentAgent) {
|
|
@@ -1198,7 +1517,7 @@ function deserializeInterruptionItem(serializedItem, agentMap, currentAgent) {
|
|
|
1198
1517
|
const parsed = itemSchema.safeParse(serializedItem);
|
|
1199
1518
|
if (parsed.success) {
|
|
1200
1519
|
if (parsed.data.type === 'tool_approval_item') {
|
|
1201
|
-
const mappedAgent =
|
|
1520
|
+
const mappedAgent = resolveSerializedAgent(parsed.data.agent, agentMap, currentAgent);
|
|
1202
1521
|
return new items_1.RunToolApprovalItem(parsed.data.rawItem, mappedAgent, parsed.data.toolName);
|
|
1203
1522
|
}
|
|
1204
1523
|
const item = deserializeItem(parsed.data, agentMap);
|
|
@@ -1222,7 +1541,15 @@ function deserializeInterruptionItem(serializedItem, agentMap, currentAgent) {
|
|
|
1222
1541
|
const agentName = value.agent && typeof value.agent.name === 'string'
|
|
1223
1542
|
? value.agent.name
|
|
1224
1543
|
: undefined;
|
|
1225
|
-
const
|
|
1544
|
+
const agentIdentity = value.agent && typeof value.agent.identity === 'string'
|
|
1545
|
+
? value.agent.identity
|
|
1546
|
+
: undefined;
|
|
1547
|
+
const mappedAgent = agentName || agentIdentity
|
|
1548
|
+
? resolveSerializedAgent({
|
|
1549
|
+
name: agentName ?? currentAgent.name,
|
|
1550
|
+
identity: agentIdentity,
|
|
1551
|
+
}, agentMap, currentAgent)
|
|
1552
|
+
: currentAgent;
|
|
1226
1553
|
const toolName = typeof value.toolName === 'string'
|
|
1227
1554
|
? value.toolName
|
|
1228
1555
|
: typeof rawItem.name === 'string'
|
|
@@ -1241,13 +1568,15 @@ function deserializeInterruptions(serializedInterruptions, agentMap, currentAgen
|
|
|
1241
1568
|
/**
|
|
1242
1569
|
* @internal
|
|
1243
1570
|
*/
|
|
1244
|
-
async function deserializeProcessedResponse(agentMap, state, serializedProcessedResponse) {
|
|
1571
|
+
async function deserializeProcessedResponse(agentMap, state, serializedProcessedResponse, options = {}) {
|
|
1245
1572
|
const currentAgent = state._currentAgent;
|
|
1246
|
-
const configuredTools = await currentAgent.getAllTools(state._context);
|
|
1573
|
+
const configuredTools = options.executionTools ?? (await currentAgent.getAllTools(state._context));
|
|
1247
1574
|
const allTools = [
|
|
1248
1575
|
...configuredTools,
|
|
1249
1576
|
...state.getToolSearchRuntimeTools(currentAgent),
|
|
1250
1577
|
];
|
|
1578
|
+
const baseAgentTools = currentAgent.tools;
|
|
1579
|
+
const allowSerializedExecutionToolPlaceholder = options.allowSerializedExecutionToolPlaceholder ?? true;
|
|
1251
1580
|
const tools = new Map(allTools
|
|
1252
1581
|
.filter((tool) => tool.type === 'function')
|
|
1253
1582
|
.map((tool) => [(0, toolIdentity_1.getFunctionToolQualifiedName)(tool) ?? tool.name, tool]));
|
|
@@ -1294,17 +1623,33 @@ async function deserializeProcessedResponse(agentMap, state, serializedProcessed
|
|
|
1294
1623
|
functions: await Promise.all(serializedProcessedResponse.functions.map(async (functionCall) => {
|
|
1295
1624
|
const toolIdentity = (0, toolIdentity_1.resolveFunctionToolCallName)(functionCall.toolCall, tools) ??
|
|
1296
1625
|
functionCall.tool.name;
|
|
1297
|
-
|
|
1626
|
+
const resolvedTool = tools.get(toolIdentity) ??
|
|
1627
|
+
(0, toolRehydration_1.getSerializedFunctionToolPlaceholder)({
|
|
1628
|
+
agent: currentAgent,
|
|
1629
|
+
baseAgentTools,
|
|
1630
|
+
serializedTool: functionCall.tool,
|
|
1631
|
+
toolCall: functionCall.toolCall,
|
|
1632
|
+
toolIdentity,
|
|
1633
|
+
allowSerializedExecutionToolPlaceholder,
|
|
1634
|
+
});
|
|
1635
|
+
if (!resolvedTool) {
|
|
1298
1636
|
throw new errors_1.UserError(`Tool ${toolIdentity} not found`);
|
|
1299
1637
|
}
|
|
1300
1638
|
return {
|
|
1301
1639
|
toolCall: functionCall.toolCall,
|
|
1302
|
-
tool:
|
|
1640
|
+
tool: resolvedTool,
|
|
1303
1641
|
};
|
|
1304
1642
|
})),
|
|
1305
1643
|
computerActions: serializedProcessedResponse.computerActions.map((computerAction) => {
|
|
1306
1644
|
const toolName = computerAction.computer.name;
|
|
1307
|
-
const computerTool = resolveComputerTool(toolName)
|
|
1645
|
+
const computerTool = resolveComputerTool(toolName) ??
|
|
1646
|
+
(0, toolRehydration_1.getSerializedComputerToolPlaceholder)({
|
|
1647
|
+
agent: currentAgent,
|
|
1648
|
+
baseAgentTools,
|
|
1649
|
+
serializedTool: computerAction.computer,
|
|
1650
|
+
toolName,
|
|
1651
|
+
allowSerializedExecutionToolPlaceholder,
|
|
1652
|
+
});
|
|
1308
1653
|
if (!computerTool) {
|
|
1309
1654
|
throw new errors_1.UserError(`Computer tool ${toolName} not found`);
|
|
1310
1655
|
}
|
|
@@ -1315,22 +1660,38 @@ async function deserializeProcessedResponse(agentMap, state, serializedProcessed
|
|
|
1315
1660
|
}),
|
|
1316
1661
|
shellActions: (serializedProcessedResponse.shellActions ?? []).map((shellAction) => {
|
|
1317
1662
|
const toolName = shellAction.shell.name;
|
|
1318
|
-
|
|
1663
|
+
const shellTool = shellTools.get(toolName) ??
|
|
1664
|
+
(0, toolRehydration_1.getSerializedShellToolPlaceholder)({
|
|
1665
|
+
agent: currentAgent,
|
|
1666
|
+
baseAgentTools,
|
|
1667
|
+
serializedTool: shellAction.shell,
|
|
1668
|
+
toolName,
|
|
1669
|
+
allowSerializedExecutionToolPlaceholder,
|
|
1670
|
+
});
|
|
1671
|
+
if (!shellTool) {
|
|
1319
1672
|
throw new errors_1.UserError(`Shell tool ${toolName} not found`);
|
|
1320
1673
|
}
|
|
1321
1674
|
return {
|
|
1322
1675
|
toolCall: shellAction.toolCall,
|
|
1323
|
-
shell:
|
|
1676
|
+
shell: shellTool,
|
|
1324
1677
|
};
|
|
1325
1678
|
}),
|
|
1326
1679
|
applyPatchActions: (serializedProcessedResponse.applyPatchActions ?? []).map((applyPatchAction) => {
|
|
1327
1680
|
const toolName = applyPatchAction.applyPatch.name;
|
|
1328
|
-
|
|
1681
|
+
const applyPatchTool = applyPatchTools.get(toolName) ??
|
|
1682
|
+
(0, toolRehydration_1.getSerializedApplyPatchToolPlaceholder)({
|
|
1683
|
+
agent: currentAgent,
|
|
1684
|
+
baseAgentTools,
|
|
1685
|
+
serializedTool: applyPatchAction.applyPatch,
|
|
1686
|
+
toolName,
|
|
1687
|
+
allowSerializedExecutionToolPlaceholder,
|
|
1688
|
+
});
|
|
1689
|
+
if (!applyPatchTool) {
|
|
1329
1690
|
throw new errors_1.UserError(`Apply patch tool ${toolName} not found`);
|
|
1330
1691
|
}
|
|
1331
1692
|
return {
|
|
1332
1693
|
toolCall: applyPatchAction.toolCall,
|
|
1333
|
-
applyPatch:
|
|
1694
|
+
applyPatch: applyPatchTool,
|
|
1334
1695
|
};
|
|
1335
1696
|
}),
|
|
1336
1697
|
mcpApprovalRequests: (serializedProcessedResponse.mcpApprovalRequests ?? []).map((approvalRequest) => ({
|