@openai/agents-core 0.8.4 → 0.9.0
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 +15 -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 +116 -57
- package/dist/run.js.map +1 -1
- package/dist/run.mjs +117 -58
- package/dist/run.mjs.map +1 -1
- package/dist/runState.d.ts +83 -1
- package/dist/runState.js +96 -11
- package/dist/runState.js.map +1 -1
- package/dist/runState.mjs +95 -11
- 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/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/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
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { UserError } from "../../errors.mjs";
|
|
3
|
+
import { applyPatchTool, tool, } from "../../tool.mjs";
|
|
4
|
+
import { ApplyPatchOperation } from "../../types/protocol.mjs";
|
|
5
|
+
import { encodeUint8ArrayToBase64 } from "../../utils/base64.mjs";
|
|
6
|
+
import { withSandboxSpan } from "../runtime/spans.mjs";
|
|
7
|
+
import { isRecord } from "../shared/typeGuards.mjs";
|
|
8
|
+
import { Capability, requireBoundSession, } from "./base.mjs";
|
|
9
|
+
import { supportsApplyPatchTransport, supportsStructuredToolOutputTransport, } from "./transport.mjs";
|
|
10
|
+
const applyPatchFunctionParameters = {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
patch: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
description: 'A freeform apply_patch payload wrapped in *** Begin Patch and *** End Patch.',
|
|
16
|
+
},
|
|
17
|
+
operation: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
description: 'A single structured apply_patch operation.',
|
|
20
|
+
},
|
|
21
|
+
operations: {
|
|
22
|
+
type: 'array',
|
|
23
|
+
items: { type: 'object' },
|
|
24
|
+
description: 'Structured apply_patch operations to apply in order.',
|
|
25
|
+
},
|
|
26
|
+
command: {
|
|
27
|
+
type: 'array',
|
|
28
|
+
description: 'Optional ["apply_patch", patch] command tuple form.',
|
|
29
|
+
},
|
|
30
|
+
type: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
enum: ['create_file', 'update_file', 'delete_file'],
|
|
33
|
+
description: 'The patch operation to apply.',
|
|
34
|
+
},
|
|
35
|
+
path: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'The sandbox file path to patch.',
|
|
38
|
+
},
|
|
39
|
+
diff: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'The V4A patch diff for create_file and update_file operations.',
|
|
42
|
+
},
|
|
43
|
+
moveTo: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
description: 'Optional destination path for update_file move operations.',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
required: [],
|
|
49
|
+
additionalProperties: true,
|
|
50
|
+
};
|
|
51
|
+
const BEGIN_PATCH = '*** Begin Patch';
|
|
52
|
+
const END_PATCH = '*** End Patch';
|
|
53
|
+
const ADD_FILE = '*** Add File: ';
|
|
54
|
+
const DELETE_FILE = '*** Delete File: ';
|
|
55
|
+
const UPDATE_FILE = '*** Update File: ';
|
|
56
|
+
const MOVE_TO = '*** Move to: ';
|
|
57
|
+
function toErrorMessage(error) {
|
|
58
|
+
if (error instanceof Error) {
|
|
59
|
+
return error.message || error.toString();
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
return JSON.stringify(error);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return String(error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function renderImageForTextTransport(output) {
|
|
69
|
+
if (typeof output === 'string') {
|
|
70
|
+
return output;
|
|
71
|
+
}
|
|
72
|
+
const image = output.image;
|
|
73
|
+
if (typeof image === 'string') {
|
|
74
|
+
return image;
|
|
75
|
+
}
|
|
76
|
+
if (!isRecord(image)) {
|
|
77
|
+
return 'No image data was returned by the sandbox session.';
|
|
78
|
+
}
|
|
79
|
+
const imageRecord = image;
|
|
80
|
+
if (typeof imageRecord.url === 'string') {
|
|
81
|
+
return imageRecord.url;
|
|
82
|
+
}
|
|
83
|
+
if (typeof imageRecord.fileId === 'string') {
|
|
84
|
+
return `OpenAI file reference: ${imageRecord.fileId}`;
|
|
85
|
+
}
|
|
86
|
+
if (typeof imageRecord.data === 'string') {
|
|
87
|
+
const mediaType = typeof imageRecord.mediaType === 'string'
|
|
88
|
+
? imageRecord.mediaType
|
|
89
|
+
: 'application/octet-stream';
|
|
90
|
+
return `data:${mediaType};base64,${imageRecord.data}`;
|
|
91
|
+
}
|
|
92
|
+
if (imageRecord.data instanceof Uint8Array) {
|
|
93
|
+
const mediaType = typeof imageRecord.mediaType === 'string'
|
|
94
|
+
? imageRecord.mediaType
|
|
95
|
+
: 'application/octet-stream';
|
|
96
|
+
return `data:${mediaType};base64,${encodeUint8ArrayToBase64(imageRecord.data)}`;
|
|
97
|
+
}
|
|
98
|
+
return 'No image data was returned by the sandbox session.';
|
|
99
|
+
}
|
|
100
|
+
function renderViewImageError(path, error) {
|
|
101
|
+
const message = toErrorMessage(error);
|
|
102
|
+
if (/not found/iu.test(message)) {
|
|
103
|
+
return `image path \`${path}\` was not found`;
|
|
104
|
+
}
|
|
105
|
+
if (/not a file/iu.test(message)) {
|
|
106
|
+
return `image path \`${path}\` is not a file`;
|
|
107
|
+
}
|
|
108
|
+
if (/exceeds the 10 MB limit|exceeded the allowed size/iu.test(message)) {
|
|
109
|
+
return `image path \`${path}\` exceeded the allowed size of 10MB; resize or compress the image and try again`;
|
|
110
|
+
}
|
|
111
|
+
if (/unsupported image format|not a supported image/iu.test(message)) {
|
|
112
|
+
return `image path \`${path}\` is not a supported image file`;
|
|
113
|
+
}
|
|
114
|
+
const name = error instanceof Error ? error.name : typeof error;
|
|
115
|
+
return `unable to read image at \`${path}\`: ${name}`;
|
|
116
|
+
}
|
|
117
|
+
function parseApplyPatchInput(rawInput) {
|
|
118
|
+
const trimmedInput = rawInput.trimStart();
|
|
119
|
+
if (trimmedInput.startsWith(BEGIN_PATCH)) {
|
|
120
|
+
return parseFreeformPatch(trimmedInput);
|
|
121
|
+
}
|
|
122
|
+
let payload;
|
|
123
|
+
try {
|
|
124
|
+
payload = JSON.parse(rawInput);
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
return {
|
|
128
|
+
ok: false,
|
|
129
|
+
error: `Invalid apply_patch JSON: ${toErrorMessage(error)}`,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
return parseApplyPatchPayload(payload);
|
|
133
|
+
}
|
|
134
|
+
function parseApplyPatchPayload(payload) {
|
|
135
|
+
if (typeof payload === 'string') {
|
|
136
|
+
return parseFreeformPatch(payload);
|
|
137
|
+
}
|
|
138
|
+
if (Array.isArray(payload)) {
|
|
139
|
+
return parseStructuredOperations(payload);
|
|
140
|
+
}
|
|
141
|
+
if (!isRecord(payload)) {
|
|
142
|
+
return {
|
|
143
|
+
ok: false,
|
|
144
|
+
error: 'apply_patch input must be an object or array.',
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (typeof payload.patch === 'string') {
|
|
148
|
+
return parseFreeformPatch(payload.patch);
|
|
149
|
+
}
|
|
150
|
+
if (Array.isArray(payload.command)) {
|
|
151
|
+
const [commandName, patch] = payload.command;
|
|
152
|
+
if (commandName === 'apply_patch' && typeof patch === 'string') {
|
|
153
|
+
return parseFreeformPatch(patch);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (Array.isArray(payload.operations)) {
|
|
157
|
+
return parseStructuredOperations(payload.operations);
|
|
158
|
+
}
|
|
159
|
+
if (payload.operation !== undefined) {
|
|
160
|
+
return parseStructuredOperations([payload.operation]);
|
|
161
|
+
}
|
|
162
|
+
return parseStructuredOperations([payload]);
|
|
163
|
+
}
|
|
164
|
+
function parseStructuredOperations(payloads) {
|
|
165
|
+
const operations = [];
|
|
166
|
+
for (const payload of payloads) {
|
|
167
|
+
const parsed = ApplyPatchOperation.safeParse(payload);
|
|
168
|
+
if (!parsed.success) {
|
|
169
|
+
return {
|
|
170
|
+
ok: false,
|
|
171
|
+
error: `Invalid apply_patch operation: ${parsed.error.message}`,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
operations.push(parsed.data);
|
|
175
|
+
}
|
|
176
|
+
if (operations.length === 0) {
|
|
177
|
+
return { ok: false, error: 'apply_patch input must include an operation.' };
|
|
178
|
+
}
|
|
179
|
+
return { ok: true, operations };
|
|
180
|
+
}
|
|
181
|
+
function parseFreeformPatch(rawPatch) {
|
|
182
|
+
const lines = rawPatch.split(/\r?\n/);
|
|
183
|
+
if (lines.at(-1) === '') {
|
|
184
|
+
lines.pop();
|
|
185
|
+
}
|
|
186
|
+
if (lines[0] !== BEGIN_PATCH) {
|
|
187
|
+
return {
|
|
188
|
+
ok: false,
|
|
189
|
+
error: `apply_patch input must start with "${BEGIN_PATCH}".`,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
if (lines.length < 2 || lines.at(-1) !== END_PATCH) {
|
|
193
|
+
return {
|
|
194
|
+
ok: false,
|
|
195
|
+
error: `apply_patch input must end with "${END_PATCH}".`,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
const operations = [];
|
|
199
|
+
let index = 1;
|
|
200
|
+
while (index < lines.length - 1) {
|
|
201
|
+
const line = lines[index];
|
|
202
|
+
let parsed;
|
|
203
|
+
if (line.startsWith(ADD_FILE)) {
|
|
204
|
+
parsed = parseAddFilePatch(lines, index);
|
|
205
|
+
}
|
|
206
|
+
else if (line.startsWith(DELETE_FILE)) {
|
|
207
|
+
parsed = parseDeleteFilePatch(lines, index);
|
|
208
|
+
}
|
|
209
|
+
else if (line.startsWith(UPDATE_FILE)) {
|
|
210
|
+
parsed = parseUpdateFilePatch(lines, index);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
return {
|
|
214
|
+
ok: false,
|
|
215
|
+
error: `Invalid apply_patch file operation header: ${line}`,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
if ('error' in parsed) {
|
|
219
|
+
return { ok: false, error: parsed.error };
|
|
220
|
+
}
|
|
221
|
+
operations.push(parsed.operation);
|
|
222
|
+
index = parsed.nextIndex;
|
|
223
|
+
}
|
|
224
|
+
if (operations.length === 0) {
|
|
225
|
+
return {
|
|
226
|
+
ok: false,
|
|
227
|
+
error: 'apply_patch input must include at least one file operation.',
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
return { ok: true, operations };
|
|
231
|
+
}
|
|
232
|
+
function parseAddFilePatch(lines, index) {
|
|
233
|
+
const path = parsePatchHeader(lines[index], ADD_FILE);
|
|
234
|
+
if (!path) {
|
|
235
|
+
return { error: `Missing path in apply_patch header: ${lines[index]}` };
|
|
236
|
+
}
|
|
237
|
+
index += 1;
|
|
238
|
+
const diffLines = [];
|
|
239
|
+
while (index < lines.length - 1 && !isFileOperationHeader(lines[index])) {
|
|
240
|
+
const line = lines[index];
|
|
241
|
+
if (!line.startsWith('+')) {
|
|
242
|
+
return { error: `Invalid Add File line: ${line}` };
|
|
243
|
+
}
|
|
244
|
+
diffLines.push(line);
|
|
245
|
+
index += 1;
|
|
246
|
+
}
|
|
247
|
+
if (diffLines.length === 0) {
|
|
248
|
+
return {
|
|
249
|
+
error: `Add File patch for ${path} must include at least one + line.`,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
operation: {
|
|
254
|
+
type: 'create_file',
|
|
255
|
+
path,
|
|
256
|
+
diff: joinDiff(diffLines),
|
|
257
|
+
},
|
|
258
|
+
nextIndex: index,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function parseDeleteFilePatch(lines, index) {
|
|
262
|
+
const path = parsePatchHeader(lines[index], DELETE_FILE);
|
|
263
|
+
if (!path) {
|
|
264
|
+
return { error: `Missing path in apply_patch header: ${lines[index]}` };
|
|
265
|
+
}
|
|
266
|
+
index += 1;
|
|
267
|
+
if (index < lines.length - 1 && !isFileOperationHeader(lines[index])) {
|
|
268
|
+
return { error: `Delete File patch for ${path} must not include a diff.` };
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
operation: {
|
|
272
|
+
type: 'delete_file',
|
|
273
|
+
path,
|
|
274
|
+
},
|
|
275
|
+
nextIndex: index,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function parseUpdateFilePatch(lines, index) {
|
|
279
|
+
const path = parsePatchHeader(lines[index], UPDATE_FILE);
|
|
280
|
+
if (!path) {
|
|
281
|
+
return { error: `Missing path in apply_patch header: ${lines[index]}` };
|
|
282
|
+
}
|
|
283
|
+
index += 1;
|
|
284
|
+
let moveTo;
|
|
285
|
+
if (index < lines.length - 1 && lines[index].startsWith(MOVE_TO)) {
|
|
286
|
+
const parsedMoveTo = parsePatchHeader(lines[index], MOVE_TO);
|
|
287
|
+
if (!parsedMoveTo) {
|
|
288
|
+
return { error: `Missing path in apply_patch header: ${lines[index]}` };
|
|
289
|
+
}
|
|
290
|
+
moveTo = parsedMoveTo;
|
|
291
|
+
index += 1;
|
|
292
|
+
}
|
|
293
|
+
const diffLines = [];
|
|
294
|
+
while (index < lines.length - 1 && !isFileOperationHeader(lines[index])) {
|
|
295
|
+
diffLines.push(lines[index]);
|
|
296
|
+
index += 1;
|
|
297
|
+
}
|
|
298
|
+
if (diffLines.length === 0 && !moveTo) {
|
|
299
|
+
return { error: `Update File patch for ${path} must include a hunk.` };
|
|
300
|
+
}
|
|
301
|
+
return {
|
|
302
|
+
operation: {
|
|
303
|
+
type: 'update_file',
|
|
304
|
+
path,
|
|
305
|
+
diff: diffLines.length > 0 ? joinDiff(diffLines) : '',
|
|
306
|
+
...(moveTo ? { moveTo } : {}),
|
|
307
|
+
},
|
|
308
|
+
nextIndex: index,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
function parsePatchHeader(line, prefix) {
|
|
312
|
+
const path = line.slice(prefix.length).trim();
|
|
313
|
+
return path ? path : null;
|
|
314
|
+
}
|
|
315
|
+
function isFileOperationHeader(line) {
|
|
316
|
+
return (line.startsWith(ADD_FILE) ||
|
|
317
|
+
line.startsWith(DELETE_FILE) ||
|
|
318
|
+
line.startsWith(UPDATE_FILE));
|
|
319
|
+
}
|
|
320
|
+
function joinDiff(lines) {
|
|
321
|
+
return `${lines.join('\n')}\n`;
|
|
322
|
+
}
|
|
323
|
+
async function applyPatchOperation(editor, operation, runContext) {
|
|
324
|
+
let result;
|
|
325
|
+
try {
|
|
326
|
+
switch (operation.type) {
|
|
327
|
+
case 'create_file':
|
|
328
|
+
result = await editor.createFile(operation, { runContext });
|
|
329
|
+
break;
|
|
330
|
+
case 'update_file':
|
|
331
|
+
result = await editor.updateFile(operation, { runContext });
|
|
332
|
+
break;
|
|
333
|
+
case 'delete_file':
|
|
334
|
+
result = await editor.deleteFile(operation, { runContext });
|
|
335
|
+
break;
|
|
336
|
+
default:
|
|
337
|
+
return 'Unsupported apply_patch operation.';
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
catch (error) {
|
|
341
|
+
return `Failed to apply patch: ${toErrorMessage(error)}`;
|
|
342
|
+
}
|
|
343
|
+
if (result?.status === 'failed') {
|
|
344
|
+
return result.output ? `Patch failed: ${result.output}` : 'Patch failed.';
|
|
345
|
+
}
|
|
346
|
+
return result?.output ?? 'Patch applied.';
|
|
347
|
+
}
|
|
348
|
+
async function applyPatchOperations(editor, operations, runContext) {
|
|
349
|
+
const outputs = [];
|
|
350
|
+
for (const operation of operations) {
|
|
351
|
+
const output = await applyPatchOperation(editor, operation, runContext);
|
|
352
|
+
if (output) {
|
|
353
|
+
outputs.push(output);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return outputs.join('\n') || 'Patch applied.';
|
|
357
|
+
}
|
|
358
|
+
function applyPatchFunctionTool(editor) {
|
|
359
|
+
const fallbackTool = {
|
|
360
|
+
type: 'function',
|
|
361
|
+
name: 'apply_patch',
|
|
362
|
+
description: 'Applies a create, update, move, or delete file patch in the sandbox workspace. Accepts a freeform patch string or structured apply_patch operations.',
|
|
363
|
+
parameters: applyPatchFunctionParameters,
|
|
364
|
+
strict: false,
|
|
365
|
+
deferLoading: false,
|
|
366
|
+
needsApproval: async () => false,
|
|
367
|
+
isEnabled: async () => true,
|
|
368
|
+
invoke: async (runContext, input) => {
|
|
369
|
+
const parsed = parseApplyPatchInput(input);
|
|
370
|
+
if (!parsed.ok) {
|
|
371
|
+
return parsed.error;
|
|
372
|
+
}
|
|
373
|
+
return await applyPatchOperations(editor, parsed.operations, runContext);
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
return fallbackTool;
|
|
377
|
+
}
|
|
378
|
+
class FilesystemCapability extends Capability {
|
|
379
|
+
type = 'filesystem';
|
|
380
|
+
configureTools;
|
|
381
|
+
constructor(args = {}) {
|
|
382
|
+
super();
|
|
383
|
+
this.configureTools = args.configureTools;
|
|
384
|
+
}
|
|
385
|
+
tools() {
|
|
386
|
+
const session = requireBoundSession(this.type, this._session);
|
|
387
|
+
const editor = session.createEditor?.(this._runAs);
|
|
388
|
+
if (!editor) {
|
|
389
|
+
throw new UserError('Filesystem sandbox sessions must provide createEditor().');
|
|
390
|
+
}
|
|
391
|
+
const tools = [];
|
|
392
|
+
const viewImage = async (path) => {
|
|
393
|
+
if (!session.viewImage) {
|
|
394
|
+
throw new UserError('Filesystem sandbox sessions must provide viewImage().');
|
|
395
|
+
}
|
|
396
|
+
try {
|
|
397
|
+
return await withSandboxSpan('sandbox.view_image', {
|
|
398
|
+
path,
|
|
399
|
+
run_as: this._runAs,
|
|
400
|
+
}, async () => await session.viewImage({
|
|
401
|
+
path,
|
|
402
|
+
runAs: this._runAs,
|
|
403
|
+
}));
|
|
404
|
+
}
|
|
405
|
+
catch (error) {
|
|
406
|
+
return renderViewImageError(path, error);
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
if (supportsStructuredToolOutputTransport(this._modelInstance)) {
|
|
410
|
+
tools.push(tool({
|
|
411
|
+
name: 'view_image',
|
|
412
|
+
description: 'Returns an image output from a local path in the sandbox workspace.',
|
|
413
|
+
parameters: z.object({
|
|
414
|
+
path: z.string().describe('Local filesystem path to an image file'),
|
|
415
|
+
}),
|
|
416
|
+
execute: async ({ path, }) => await viewImage(path),
|
|
417
|
+
}));
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
tools.push(tool({
|
|
421
|
+
name: 'view_image',
|
|
422
|
+
description: 'Returns an image from a local path in the sandbox workspace as a data URL or reference string.',
|
|
423
|
+
parameters: z.object({
|
|
424
|
+
path: z.string().describe('Local filesystem path to an image file'),
|
|
425
|
+
}),
|
|
426
|
+
execute: async ({ path }) => renderImageForTextTransport(await viewImage(path)),
|
|
427
|
+
}));
|
|
428
|
+
}
|
|
429
|
+
if (supportsApplyPatchTransport(this._modelInstance)) {
|
|
430
|
+
tools.push(applyPatchTool({
|
|
431
|
+
name: 'apply_patch',
|
|
432
|
+
editor,
|
|
433
|
+
}));
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
tools.push(applyPatchFunctionTool(editor));
|
|
437
|
+
}
|
|
438
|
+
return this.configureTools ? this.configureTools([...tools]) : tools;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
export function filesystem(args = {}) {
|
|
442
|
+
return new FilesystemCapability(args);
|
|
443
|
+
}
|
|
444
|
+
//# sourceMappingURL=filesystem.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem.mjs","sourceRoot":"","sources":["../../../src/sandbox/capabilities/filesystem.ts"],"names":[],"mappings":"OAAO,EAAE,CAAC,EAAE,MAAM,KAAK;OAEhB,EAAE,SAAS,EAAE;OACb,EACL,cAAc,EACd,IAAI,GAIL;OAKM,EAAE,mBAAmB,EAAE;OACvB,EAAE,wBAAwB,EAAE;OAE5B,EAAE,eAAe,EAAE;OACnB,EAAE,QAAQ,EAAE;OACZ,EACL,UAAU,EAEV,mBAAmB,GACpB;OACM,EACL,2BAA2B,EAC3B,qCAAqC,GACtC;AAMD,MAAM,4BAA4B,GAE9B;IACF,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EACT,8EAA8E;SACjF;QACD,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,4CAA4C;SAC1D;QACD,UAAU,EAAE;YACV,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,EAAE,IAAI,EAAE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;QACJ,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACvE,CAAC;CACF;AAID,MAAM,UAAU,UAAU,CAAC,OAAuB,EAAE;IAClD,OAAO,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Capability } from './base';
|
|
2
|
+
export { Capability } from './base';
|
|
3
|
+
export type { ConfigureCapabilityTools } from './base';
|
|
4
|
+
export { CompactionModelInfo, CompactionPolicy, DynamicCompactionPolicy, StaticCompactionPolicy, compaction, } from './compaction';
|
|
5
|
+
export type { Compaction } from './compaction';
|
|
6
|
+
export { filesystem } from './filesystem';
|
|
7
|
+
export type { Filesystem, FilesystemArgs } from './filesystem';
|
|
8
|
+
export { memory } from './memory';
|
|
9
|
+
export { InMemoryMemoryStore } from '../memory/storage';
|
|
10
|
+
export type { Memory, MemoryArgs, MemoryGenerateConfig, MemoryLayoutConfig, MemoryReadConfig, } from './memory';
|
|
11
|
+
export type { MemoryStore } from '../memory/storage';
|
|
12
|
+
export { shell } from './shell';
|
|
13
|
+
export type { Shell, ShellArgs } from './shell';
|
|
14
|
+
export { skills } from './skills';
|
|
15
|
+
export type { LocalDirLazySkillSource, SkillDescriptor, SkillIndexEntry, Skills, SkillsArgs, } from './skills';
|
|
16
|
+
declare function defaultCapabilities(): Capability[];
|
|
17
|
+
export declare const Capabilities: {
|
|
18
|
+
readonly default: typeof defaultCapabilities;
|
|
19
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Capabilities = exports.skills = exports.shell = exports.InMemoryMemoryStore = exports.memory = exports.filesystem = exports.compaction = exports.StaticCompactionPolicy = exports.DynamicCompactionPolicy = exports.CompactionPolicy = exports.CompactionModelInfo = exports.Capability = void 0;
|
|
4
|
+
const compaction_1 = require("./compaction.js");
|
|
5
|
+
const filesystem_1 = require("./filesystem.js");
|
|
6
|
+
const shell_1 = require("./shell.js");
|
|
7
|
+
var base_1 = require("./base.js");
|
|
8
|
+
Object.defineProperty(exports, "Capability", { enumerable: true, get: function () { return base_1.Capability; } });
|
|
9
|
+
var compaction_2 = require("./compaction.js");
|
|
10
|
+
Object.defineProperty(exports, "CompactionModelInfo", { enumerable: true, get: function () { return compaction_2.CompactionModelInfo; } });
|
|
11
|
+
Object.defineProperty(exports, "CompactionPolicy", { enumerable: true, get: function () { return compaction_2.CompactionPolicy; } });
|
|
12
|
+
Object.defineProperty(exports, "DynamicCompactionPolicy", { enumerable: true, get: function () { return compaction_2.DynamicCompactionPolicy; } });
|
|
13
|
+
Object.defineProperty(exports, "StaticCompactionPolicy", { enumerable: true, get: function () { return compaction_2.StaticCompactionPolicy; } });
|
|
14
|
+
Object.defineProperty(exports, "compaction", { enumerable: true, get: function () { return compaction_2.compaction; } });
|
|
15
|
+
var filesystem_2 = require("./filesystem.js");
|
|
16
|
+
Object.defineProperty(exports, "filesystem", { enumerable: true, get: function () { return filesystem_2.filesystem; } });
|
|
17
|
+
var memory_1 = require("./memory.js");
|
|
18
|
+
Object.defineProperty(exports, "memory", { enumerable: true, get: function () { return memory_1.memory; } });
|
|
19
|
+
var storage_1 = require("../memory/storage.js");
|
|
20
|
+
Object.defineProperty(exports, "InMemoryMemoryStore", { enumerable: true, get: function () { return storage_1.InMemoryMemoryStore; } });
|
|
21
|
+
var shell_2 = require("./shell.js");
|
|
22
|
+
Object.defineProperty(exports, "shell", { enumerable: true, get: function () { return shell_2.shell; } });
|
|
23
|
+
var skills_1 = require("./skills.js");
|
|
24
|
+
Object.defineProperty(exports, "skills", { enumerable: true, get: function () { return skills_1.skills; } });
|
|
25
|
+
function defaultCapabilities() {
|
|
26
|
+
return [(0, filesystem_1.filesystem)(), (0, shell_1.shell)(), (0, compaction_1.compaction)()];
|
|
27
|
+
}
|
|
28
|
+
exports.Capabilities = {
|
|
29
|
+
default: defaultCapabilities,
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sandbox/capabilities/index.ts"],"names":[],"mappings":";;;AACA,gDAA0C;AAC1C,gDAA0C;AAC1C,sCAAgC;AAEhC,kCAAoC;AAA3B,kGAAA,UAAU,OAAA;AAEnB,8CAMsB;AALpB,iHAAA,mBAAmB,OAAA;AACnB,8GAAA,gBAAgB,OAAA;AAChB,qHAAA,uBAAuB,OAAA;AACvB,oHAAA,sBAAsB,OAAA;AACtB,wGAAA,UAAU,OAAA;AAGZ,8CAA0C;AAAjC,wGAAA,UAAU,OAAA;AAEnB,sCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,gDAAwD;AAA/C,8GAAA,mBAAmB,OAAA;AAS5B,oCAAgC;AAAvB,8FAAA,KAAK,OAAA;AAEd,sCAAkC;AAAzB,gGAAA,MAAM,OAAA;AASf,SAAS,mBAAmB;IAC1B,OAAO,CAAC,IAAA,uBAAU,GAAE,EAAE,IAAA,aAAK,GAAE,EAAE,IAAA,uBAAU,GAAE,CAAC,CAAC;AAC/C,CAAC;AAEY,QAAA,YAAY,GAAG;IAC1B,OAAO,EAAE,mBAAmB;CACpB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { compaction } from "./compaction.mjs";
|
|
2
|
+
import { filesystem } from "./filesystem.mjs";
|
|
3
|
+
import { shell } from "./shell.mjs";
|
|
4
|
+
export { Capability } from "./base.mjs";
|
|
5
|
+
export { CompactionModelInfo, CompactionPolicy, DynamicCompactionPolicy, StaticCompactionPolicy, compaction, } from "./compaction.mjs";
|
|
6
|
+
export { filesystem } from "./filesystem.mjs";
|
|
7
|
+
export { memory } from "./memory.mjs";
|
|
8
|
+
export { InMemoryMemoryStore } from "../memory/storage.mjs";
|
|
9
|
+
export { shell } from "./shell.mjs";
|
|
10
|
+
export { skills } from "./skills.mjs";
|
|
11
|
+
function defaultCapabilities() {
|
|
12
|
+
return [filesystem(), shell(), compaction()];
|
|
13
|
+
}
|
|
14
|
+
export const Capabilities = {
|
|
15
|
+
default: defaultCapabilities,
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/sandbox/capabilities/index.ts"],"names":[],"mappings":"OACO,EAAE,UAAU,EAAE;OACd,EAAE,UAAU,EAAE;OACd,EAAE,KAAK,EAAE;OAET,EAAE,UAAU,EAAE;OAEd,EACL,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,UAAU,GACX;OAEM,EAAE,UAAU,EAAE;OAEd,EAAE,MAAM,EAAE;OACV,EAAE,mBAAmB,EAAE;OASvB,EAAE,KAAK,EAAE;OAET,EAAE,MAAM,EAAE;AASjB,SAAS,mBAAmB;IAC1B,OAAO,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE,mBAAmB;CACpB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Model, ModelSettings } from '../../model';
|
|
2
|
+
import { type Manifest } from '../manifest';
|
|
3
|
+
import { type MemoryStore } from '../memory/storage';
|
|
4
|
+
import { Capability } from './base';
|
|
5
|
+
export type MemoryReadConfig = {
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
liveUpdate?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type MemoryGenerateConfig = {
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
maxRawMemoriesForConsolidation?: number;
|
|
12
|
+
phaseOneModel?: string | Model;
|
|
13
|
+
phaseOneModelSettings?: ModelSettings;
|
|
14
|
+
phaseTwoModel?: string | Model;
|
|
15
|
+
phaseTwoModelSettings?: ModelSettings;
|
|
16
|
+
extraPrompt?: string;
|
|
17
|
+
model?: string | Model;
|
|
18
|
+
instructions?: string;
|
|
19
|
+
};
|
|
20
|
+
export type MemoryLayoutConfig = {
|
|
21
|
+
memoriesDir?: string;
|
|
22
|
+
sessionsDir?: string;
|
|
23
|
+
directory?: string;
|
|
24
|
+
summaryFile?: string;
|
|
25
|
+
};
|
|
26
|
+
export type MemoryArgs = {
|
|
27
|
+
read?: boolean | MemoryReadConfig | null;
|
|
28
|
+
generate?: boolean | MemoryGenerateConfig | null;
|
|
29
|
+
layout?: MemoryLayoutConfig;
|
|
30
|
+
store?: MemoryStore;
|
|
31
|
+
};
|
|
32
|
+
declare class MemoryCapability extends Capability {
|
|
33
|
+
readonly type = "memory";
|
|
34
|
+
readonly read: MemoryReadConfig | null;
|
|
35
|
+
readonly generate: MemoryGenerateConfig | null;
|
|
36
|
+
readonly layout: {
|
|
37
|
+
memoriesDir: string;
|
|
38
|
+
sessionsDir: string;
|
|
39
|
+
summaryFile: string;
|
|
40
|
+
};
|
|
41
|
+
readonly store?: MemoryStore;
|
|
42
|
+
constructor(args?: MemoryArgs);
|
|
43
|
+
requiredCapabilityTypes(): Set<string>;
|
|
44
|
+
processManifest(manifest: Manifest): Manifest;
|
|
45
|
+
instructions(_manifest: Manifest): Promise<string | null>;
|
|
46
|
+
private readMemorySummary;
|
|
47
|
+
private readStoredText;
|
|
48
|
+
}
|
|
49
|
+
export type Memory = MemoryCapability;
|
|
50
|
+
export declare function memory(args?: MemoryArgs): Memory;
|
|
51
|
+
export declare function isMemoryCapability(capability: Capability): capability is Memory;
|
|
52
|
+
export {};
|