@caupulican/pi-adaptative 0.86.17 → 0.90.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/README.md +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +14 -15
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +14 -16
- package/dist/bundled-resources/skills/worker-profile-writer/SKILL.md +4 -4
- package/dist/core/agent-session.d.ts +23 -33
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +81 -110
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/contracts.d.ts +1 -1
- package/dist/core/autonomy/contracts.js.map +1 -1
- package/dist/core/autonomy/gates.d.ts.map +1 -1
- package/dist/core/autonomy/gates.js +16 -0
- package/dist/core/autonomy/gates.js.map +1 -1
- package/dist/core/autonomy/subagent-prompt.d.ts +2 -1
- package/dist/core/autonomy/subagent-prompt.d.ts.map +1 -1
- package/dist/core/autonomy/subagent-prompt.js +2 -18
- package/dist/core/autonomy/subagent-prompt.js.map +1 -1
- package/dist/core/background-tool-task-controller.js +5 -5
- package/dist/core/background-tool-task-controller.js.map +1 -1
- package/dist/core/compaction-controller.d.ts +22 -2
- package/dist/core/compaction-controller.d.ts.map +1 -1
- package/dist/core/compaction-controller.js +75 -39
- package/dist/core/compaction-controller.js.map +1 -1
- package/dist/core/context/brain-curator.d.ts +2 -3
- package/dist/core/context/brain-curator.d.ts.map +1 -1
- package/dist/core/context/brain-curator.js +3 -20
- package/dist/core/context/brain-curator.js.map +1 -1
- package/dist/core/context/context-composition.d.ts +2 -1
- package/dist/core/context/context-composition.d.ts.map +1 -1
- package/dist/core/context/context-composition.js +6 -1
- package/dist/core/context/context-composition.js.map +1 -1
- package/dist/core/context/memory-prompt-block.js +1 -1
- package/dist/core/context/memory-prompt-block.js.map +1 -1
- package/dist/core/context/tool-output-packer.js +1 -1
- package/dist/core/context/tool-output-packer.js.map +1 -1
- package/dist/core/context-gc.js +10 -10
- package/dist/core/context-gc.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +4 -4
- package/dist/core/context-pipeline.js +4 -4
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +1 -2
- package/dist/core/default-tool-surface.js.map +1 -1
- package/dist/core/delegation/session-worker-claim.d.ts +2 -2
- package/dist/core/delegation/session-worker-claim.js +2 -2
- package/dist/core/delegation/session-worker-claim.js.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.js +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-resource-materializer.js +3 -3
- package/dist/core/delegation/worker-resource-materializer.js.map +1 -1
- package/dist/core/delegation/worker-runner.d.ts +2 -13
- package/dist/core/delegation/worker-runner.d.ts.map +1 -1
- package/dist/core/delegation/worker-runner.js +5 -67
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/extensions/builtin.js +4 -4
- package/dist/core/extensions/builtin.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +6 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +21 -9
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +9 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/foreground-terminal-handoff-controller.js +2 -2
- package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
- package/dist/core/goals/compact-goal-context.d.ts.map +1 -1
- package/dist/core/goals/compact-goal-context.js +13 -9
- package/dist/core/goals/compact-goal-context.js.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js +1 -1
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-session-controller.d.ts +6 -0
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-session-controller.js +16 -13
- package/dist/core/goals/goal-session-controller.js.map +1 -1
- package/dist/core/human-input-controller.js +1 -1
- package/dist/core/human-input-controller.js.map +1 -1
- package/dist/core/improvement-loop.js +13 -13
- package/dist/core/improvement-loop.js.map +1 -1
- package/dist/core/learning/reflection-engine.d.ts +2 -1
- package/dist/core/learning/reflection-engine.d.ts.map +1 -1
- package/dist/core/learning/reflection-engine.js +4 -24
- package/dist/core/learning/reflection-engine.js.map +1 -1
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +1 -1
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-router/route-judge.d.ts +2 -1
- package/dist/core/model-router/route-judge.d.ts.map +1 -1
- package/dist/core/model-router/route-judge.js +4 -12
- package/dist/core/model-router/route-judge.js.map +1 -1
- package/dist/core/models/perf-profile.d.ts +1 -1
- package/dist/core/models/perf-profile.d.ts.map +1 -1
- package/dist/core/models/perf-profile.js +2 -8
- package/dist/core/models/perf-profile.js.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.d.ts +1 -1
- package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
- package/dist/core/orchestration/lane-tool-manifests.js +1 -6
- package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
- package/dist/core/process-matrix/resume-launcher.js +3 -3
- package/dist/core/process-matrix/resume-launcher.js.map +1 -1
- package/dist/core/process-matrix/runtime.d.ts +2 -0
- package/dist/core/process-matrix/runtime.d.ts.map +1 -1
- package/dist/core/process-matrix/runtime.js +23 -19
- package/dist/core/process-matrix/runtime.js.map +1 -1
- package/dist/core/provider-prompt-contracts.d.ts +34 -0
- package/dist/core/provider-prompt-contracts.d.ts.map +1 -0
- package/dist/core/provider-prompt-contracts.js +133 -0
- package/dist/core/provider-prompt-contracts.js.map +1 -0
- package/dist/core/provider-request-context-controller.d.ts +40 -0
- package/dist/core/provider-request-context-controller.d.ts.map +1 -0
- package/dist/core/provider-request-context-controller.js +68 -0
- package/dist/core/provider-request-context-controller.js.map +1 -0
- package/dist/core/provider-request-runtime-controller.d.ts +22 -0
- package/dist/core/provider-request-runtime-controller.d.ts.map +1 -0
- package/dist/core/provider-request-runtime-controller.js +87 -0
- package/dist/core/provider-request-runtime-controller.js.map +1 -0
- package/dist/core/provider-tool-text.d.ts +7 -0
- package/dist/core/provider-tool-text.d.ts.map +1 -0
- package/dist/core/provider-tool-text.js +42 -0
- package/dist/core/provider-tool-text.js.map +1 -0
- package/dist/core/research/model-fitness.d.ts +2 -5
- package/dist/core/research/model-fitness.d.ts.map +1 -1
- package/dist/core/research/model-fitness.js +2 -20
- package/dist/core/research/model-fitness.js.map +1 -1
- package/dist/core/research/research-runner.d.ts +2 -1
- package/dist/core/research/research-runner.d.ts.map +1 -1
- package/dist/core/research/research-runner.js +6 -21
- package/dist/core/research/research-runner.js.map +1 -1
- package/dist/core/risk-classifier.d.ts.map +1 -1
- package/dist/core/risk-classifier.js +9 -1
- package/dist/core/risk-classifier.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +3 -0
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +20 -25
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/scout-controller.d.ts +2 -1
- package/dist/core/scout-controller.d.ts.map +1 -1
- package/dist/core/scout-controller.js +2 -16
- package/dist/core/scout-controller.js.map +1 -1
- package/dist/core/sdk.d.ts +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.js +6 -6
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
- package/dist/core/secrets/credential-manager.d.ts +11 -1
- package/dist/core/secrets/credential-manager.d.ts.map +1 -1
- package/dist/core/secrets/credential-manager.js +28 -7
- package/dist/core/secrets/credential-manager.js.map +1 -1
- package/dist/core/secrets/credential-migration-source.d.ts +20 -0
- package/dist/core/secrets/credential-migration-source.d.ts.map +1 -0
- package/dist/core/secrets/credential-migration-source.js +113 -0
- package/dist/core/secrets/credential-migration-source.js.map +1 -0
- package/dist/core/secrets/credential-session-connection.d.ts +9 -0
- package/dist/core/secrets/credential-session-connection.d.ts.map +1 -0
- package/dist/core/secrets/credential-session-connection.js +39 -0
- package/dist/core/secrets/credential-session-connection.js.map +1 -0
- package/dist/core/security/untrusted-boundary.d.ts +2 -2
- package/dist/core/security/untrusted-boundary.d.ts.map +1 -1
- package/dist/core/security/untrusted-boundary.js +3 -10
- package/dist/core/security/untrusted-boundary.js.map +1 -1
- package/dist/core/session-role.d.ts.map +1 -1
- package/dist/core/session-role.js +1 -2
- package/dist/core/session-role.js.map +1 -1
- package/dist/core/skill-vault.d.ts +98 -0
- package/dist/core/skill-vault.d.ts.map +1 -0
- package/dist/core/skill-vault.js +270 -0
- package/dist/core/skill-vault.js.map +1 -0
- package/dist/core/skills.d.ts +10 -9
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +42 -50
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt-builder.d.ts +1 -1
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +20 -60
- package/dist/core/system-prompt-builder.js.map +1 -1
- package/dist/core/system-prompt.d.ts +4 -4
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +87 -121
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/task-state.d.ts.map +1 -1
- package/dist/core/tasks/task-state.js +6 -7
- package/dist/core/tasks/task-state.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts.map +1 -1
- package/dist/core/tool-capability-policy.js +2 -1
- package/dist/core/tool-capability-policy.js.map +1 -1
- package/dist/core/tool-protocol-controller.d.ts.map +1 -1
- package/dist/core/tool-protocol-controller.js +4 -7
- package/dist/core/tool-protocol-controller.js.map +1 -1
- package/dist/core/tool-selection/promotion.d.ts.map +1 -1
- package/dist/core/tool-selection/promotion.js +2 -6
- package/dist/core/tool-selection/promotion.js.map +1 -1
- package/dist/core/toolkit/reflex-interpreter.d.ts +2 -1
- package/dist/core/toolkit/reflex-interpreter.d.ts.map +1 -1
- package/dist/core/toolkit/reflex-interpreter.js +2 -14
- package/dist/core/toolkit/reflex-interpreter.js.map +1 -1
- package/dist/core/tools/ask-question.js +6 -6
- package/dist/core/tools/ask-question.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +8 -7
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +17 -13
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +111 -226
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +29 -2
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +149 -48
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/edit.js +3 -3
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/extensionify-runtime.js +4 -4
- package/dist/core/tools/extensionify-runtime.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +2 -4
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/goal.js +3 -3
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/grep.js +2 -2
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +1 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/model-fitness.js +4 -4
- package/dist/core/tools/model-fitness.js.map +1 -1
- package/dist/core/tools/profile-writer.d.ts +30 -16
- package/dist/core/tools/profile-writer.d.ts.map +1 -1
- package/dist/core/tools/profile-writer.js +98 -59
- package/dist/core/tools/profile-writer.js.map +1 -1
- package/dist/core/tools/python.js +6 -6
- package/dist/core/tools/python.js.map +1 -1
- package/dist/core/tools/run-process.js +4 -4
- package/dist/core/tools/run-process.js.map +1 -1
- package/dist/core/tools/run-toolkit-script.js +4 -4
- package/dist/core/tools/run-toolkit-script.js.map +1 -1
- package/dist/core/tools/secret-store.d.ts +32 -3
- package/dist/core/tools/secret-store.d.ts.map +1 -1
- package/dist/core/tools/secret-store.js +141 -34
- package/dist/core/tools/secret-store.js.map +1 -1
- package/dist/core/tools/skill.d.ts +29 -0
- package/dist/core/tools/skill.d.ts.map +1 -0
- package/dist/core/tools/skill.js +79 -0
- package/dist/core/tools/skill.js.map +1 -0
- package/dist/core/tools/task-steps.js +4 -4
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +2 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/tool-task.d.ts.map +1 -1
- package/dist/core/tools/tool-task.js +4 -0
- package/dist/core/tools/tool-task.js.map +1 -1
- package/dist/core/tools/worktree-sync.js +6 -6
- package/dist/core/tools/worktree-sync.js.map +1 -1
- package/dist/core/tools/write.js +3 -3
- package/dist/core/tools/write.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.js +1 -1
- package/dist/modes/interactive/interactive-event-controller.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/report-commands.js +1 -1
- package/dist/modes/interactive/report-commands.js.map +1 -1
- package/dist/modes/interactive/secret-menu-controller.d.ts.map +1 -1
- package/dist/modes/interactive/secret-menu-controller.js +2 -18
- package/dist/modes/interactive/secret-menu-controller.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +1 -1
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/docs/compaction.md +45 -25
- package/docs/extensions.md +23 -7
- package/docs/settings.md +3 -3
- package/docs/skills.md +14 -10
- package/docs/task-steps.md +2 -2
- package/docs/tmux-agent-manager.md +1 -1
- package/docs/tool-repair.md +18 -1
- package/docs/usage.md +4 -2
- package/docs/worker-profiles.md +3 -3
- package/docs/worktree-sync.md +2 -2
- package/examples/extensions/custom-compaction.ts +5 -17
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/summarize.ts +3 -5
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/04-skills.ts +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
- package/dist/core/util/json-size.d.ts +0 -3
- package/dist/core/util/json-size.d.ts.map +0 -1
- package/dist/core/util/json-size.js +0 -95
- package/dist/core/util/json-size.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EAGV,YAAY,EACZ,YAAY,EACZ,YAAY,GACZ,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAIN,0BAA0B,EAC1B,oCAAoC,GACpC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAON,cAAc,EACd,wBAAwB,EACxB,yBAAyB,EACzB,kCAAkC,EAClC,+BAA+B,GAC/B,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,sBAAsB,EAItB,gCAAgC,EAChC,iBAAiB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,sB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,EAAE,aAAa,CAAC,KAAK,CAAC;QAChD,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,EAAE,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;QAClC,WAAW,EAAE,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,WAAW,CAAC;QAC5D,QAAQ,EAAE,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC;QACpD,YAAY,EAAE,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY,CAAC;QAChE,iBAAiB,EAAE,0BAA0B,CAAC,GAAG,EAAE,OAAO,EAAE,iBAAiB,CAAC;KAC9E,CAAC;AACH,CAAC","sourcesContent":["export {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"@caupulican/pi-agent-core/node\";\nexport {\n\ttype ArtifactRetrieveToolDetails,\n\ttype ArtifactRetrieveToolInput,\n\ttype ArtifactRetrieveToolOptions,\n\tcreateArtifactRetrieveTool,\n\tcreateArtifactRetrieveToolDefinition,\n} from \"./artifact-retrieve.ts\";\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n\tcreateLocalPlatformShellOperations,\n\tcreateLocalPowerShellOperations,\n} from \"./bash.ts\";\nexport {\n\tCONTEXT_SCOUT_GUIDANCE,\n\ttype ContextScoutToolDependencies,\n\ttype ContextScoutToolDetails,\n\ttype ContextScoutToolInput,\n\tcreateContextScoutToolDefinition,\n\tformatScoutResult,\n} from \"./context-scout.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport {\n\tcreateExtensionifyTool,\n\tcreateExtensionifyToolDefinition,\n\ttype ExtensionifyInput,\n\ttype ExtensionifyReport,\n\ttype ExtensionifyToolDetails,\n\ttype ExtensionifyToolOptions,\n} from \"./extensionify.ts\";\nexport {\n\tcreateFileFailureRecoveryAuthority,\n\ttype FileFailureRecoveryAuthority,\n} from \"./file-failure-recovery.ts\";\nexport {\n\ttype FileContentReference,\n\tFileMutationIntentController,\n\ttype FileMutationIntentControllerOptions,\n\ttype FileMutationIntentOperations,\n\ttype FileMutationKind,\n\ttype FileMutationLease,\n\ttype FileMutationPayloadReference,\n\tFileMutationPreflightError,\n\ttype FileMutationPreflightFailureReason,\n\ttype FilePathIdentity,\n\ttype FilePathInspection,\n\tlocalFileMutationIntentOperations,\n} from \"./file-mutation-intent.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateProfileWriterToolDefinition,\n\ttype ProfileWriterToolDetails,\n\ttype ProfileWriterToolInput,\n} from \"./profile-writer.ts\";\nexport {\n\tcreatePythonTool,\n\tcreatePythonToolDefinition,\n\tDEFAULT_PYTHON_TIMEOUT_SECONDS,\n\tMAX_PYTHON_OUTPUT_BYTES,\n\tMAX_PYTHON_TIMEOUT_SECONDS,\n\ttype PythonExecutionRequest,\n\ttype PythonExecutionResult,\n\ttype PythonOperations,\n\ttype PythonToolDetails,\n\ttype PythonToolInput,\n\ttype PythonToolOptions,\n\tresolvePythonToolPath,\n} from \"./python.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tcreateSecretStoreToolDefinition,\n\ttype SecretStoreStatus,\n\ttype SecretStoreToolDetails,\n\ttype SecretStoreToolInput,\n\ttype SecretStoreToolOptions,\n} from \"./secret-store.ts\";\nexport {\n\tcreateSkillAuditTool,\n\tcreateSkillAuditToolDefinition,\n\tjaccard,\n\ttype SkillAuditInput,\n\ttype SkillAuditReport,\n\ttype SkillAuditToolDetails,\n\ttype SkillAuditToolOptions,\n\ttokenize,\n} from \"./skill-audit.ts\";\nexport {\n\tcreateSkillifyTool,\n\tcreateSkillifyToolDefinition,\n\ttype SkillifyInput,\n\ttype SkillifyReport,\n\ttype SkillifyToolDetails,\n\ttype SkillifyToolOptions,\n} from \"./skillify.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolDetails,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport {\n\ttype ArtifactRetrieveToolOptions,\n\tcreateArtifactRetrieveTool,\n\tcreateArtifactRetrieveToolDefinition,\n} from \"./artifact-retrieve.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport {\n\tcreateDefaultExtensionifyRuntimeOptions,\n\tcreateExtensionifyTool,\n\tcreateExtensionifyToolDefinition,\n\ttype ExtensionifyToolOptions,\n} from \"./extensionify.ts\";\nimport { FileMutationIntentController } from \"./file-mutation-intent.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createPythonTool, createPythonToolDefinition, type PythonToolOptions } from \"./python.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createSkillAuditTool, createSkillAuditToolDefinition, type SkillAuditToolOptions } from \"./skill-audit.ts\";\nimport { createSkillifyTool, createSkillifyToolDefinition, type SkillifyToolOptions } from \"./skillify.ts\";\nimport { createToolDefinitionWithRuntime, type ToolDef, type ToolName } from \"./tool-definition-factory.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport { allToolNames, type ToolDef, type ToolName } from \"./tool-definition-factory.ts\";\n\nexport type Tool = AgentTool<any>;\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\tpython?: PythonToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n\tskill_audit?: SkillAuditToolOptions;\n\tskillify?: SkillifyToolOptions;\n\textensionify?: ExtensionifyToolOptions;\n\tartifact_retrieve?: ArtifactRetrieveToolOptions;\n}\n\nfunction withSharedFileMutationIntents(options?: ToolsOptions): ToolsOptions {\n\tconst writeController = options?.write?.intentController;\n\tconst editController = options?.edit?.intentController;\n\tif ((options?.write?.operations || options?.edit?.operations) && !writeController && !editController) {\n\t\tthrow new Error(\"Custom file operations require an explicit shared file mutation intent controller.\");\n\t}\n\tif (writeController && editController && writeController !== editController) {\n\t\tthrow new Error(\"Write and edit tools in one surface must share one file mutation intent controller.\");\n\t}\n\tconst intentController = writeController ?? editController ?? new FileMutationIntentController();\n\treturn {\n\t\t...options,\n\t\twrite: { ...options?.write, intentController },\n\t\tedit: { ...options?.edit, intentController },\n\t};\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\treturn createToolDefinitionWithRuntime(toolName, cwd, {\n\t\t...options,\n\t\textensionify: createDefaultExtensionifyRuntimeOptions(options?.extensionify),\n\t});\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"python\":\n\t\t\treturn createPythonTool(cwd, options?.python);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"skill_audit\":\n\t\t\treturn createSkillAuditTool(cwd, options?.skill_audit);\n\t\tcase \"skillify\":\n\t\t\treturn createSkillifyTool(cwd, options?.skillify);\n\t\tcase \"extensionify\":\n\t\t\treturn createExtensionifyTool(cwd, options?.extensionify);\n\t\tcase \"artifact_retrieve\":\n\t\t\treturn createArtifactRetrieveTool(cwd, options?.artifact_retrieve);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tplatform: NodeJS.Platform = process.platform,\n): ToolDef[] {\n\tconst sharedOptions = withSharedFileMutationIntents(options);\n\tconst bashOptions: BashToolOptions = { ...options?.bash, platform };\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, bashOptions),\n\t\tcreatePythonToolDefinition(cwd, options?.python),\n\t\tcreateEditToolDefinition(cwd, sharedOptions.edit),\n\t\tcreateWriteToolDefinition(cwd, sharedOptions.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tplatform: NodeJS.Platform = process.platform,\n): Partial<Record<ToolName, ToolDef>> {\n\tconst sharedOptions = withSharedFileMutationIntents(options);\n\tconst bashOptions: BashToolOptions = { ...options?.bash, platform };\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, bashOptions),\n\t\tpython: createPythonToolDefinition(cwd, options?.python),\n\t\tedit: createEditToolDefinition(cwd, sharedOptions.edit),\n\t\twrite: createWriteToolDefinition(cwd, sharedOptions.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\tskill_audit: createSkillAuditToolDefinition(cwd, options?.skill_audit),\n\t\tskillify: createSkillifyToolDefinition(cwd, options?.skillify),\n\t\textensionify: createExtensionifyToolDefinition(cwd, options?.extensionify),\n\t\tartifact_retrieve: createArtifactRetrieveToolDefinition(cwd, options?.artifact_retrieve),\n\t};\n}\n\nexport function createCodingTools(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tplatform: NodeJS.Platform = process.platform,\n): Tool[] {\n\tconst sharedOptions = withSharedFileMutationIntents(options);\n\tconst bashOptions: BashToolOptions = { ...options?.bash, platform };\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, bashOptions),\n\t\tcreatePythonTool(cwd, options?.python),\n\t\tcreateEditTool(cwd, sharedOptions.edit),\n\t\tcreateWriteTool(cwd, sharedOptions.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tplatform: NodeJS.Platform = process.platform,\n): Partial<Record<ToolName, Tool>> {\n\tconst sharedOptions = withSharedFileMutationIntents(options);\n\tconst bashOptions: BashToolOptions = { ...options?.bash, platform };\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, bashOptions),\n\t\tpython: createPythonTool(cwd, options?.python),\n\t\tedit: createEditTool(cwd, sharedOptions.edit),\n\t\twrite: createWriteTool(cwd, sharedOptions.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\tskill_audit: createSkillAuditTool(cwd, options?.skill_audit),\n\t\tskillify: createSkillifyTool(cwd, options?.skillify),\n\t\textensionify: createExtensionifyTool(cwd, options?.extensionify),\n\t\tartifact_retrieve: createArtifactRetrieveTool(cwd, options?.artifact_retrieve),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EAGV,YAAY,EACZ,YAAY,EACZ,YAAY,GACZ,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAIN,0BAA0B,EAC1B,oCAAoC,GACpC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAON,cAAc,EACd,wBAAwB,EACxB,yBAAyB,EACzB,kCAAkC,EAClC,+BAA+B,GAC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W,CAAC;QACtC,MAAM,EAAE,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC;QAC9C,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,aAAa,CAAC,IAAI,CAAC;QAC7C,KAAK,EAAE,eAAe,CAAC,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC;QAChD,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,EAAE,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;QAClC,WAAW,EAAE,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,WAAW,CAAC;QAC5D,QAAQ,EAAE,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC;QACpD,YAAY,EAAE,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY,CAAC;QAChE,iBAAiB,EAAE,0BAA0B,CAAC,GAAG,EAAE,OAAO,EAAE,iBAAiB,CAAC;KAC9E,CAAC;AACH,CAAC","sourcesContent":["export {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"@caupulican/pi-agent-core/node\";\nexport {\n\ttype ArtifactRetrieveToolDetails,\n\ttype ArtifactRetrieveToolInput,\n\ttype ArtifactRetrieveToolOptions,\n\tcreateArtifactRetrieveTool,\n\tcreateArtifactRetrieveToolDefinition,\n} from \"./artifact-retrieve.ts\";\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n\tcreateLocalPlatformShellOperations,\n\tcreateLocalPowerShellOperations,\n} from \"./bash.ts\";\nexport {\n\tCONTEXT_SCOUT_GUIDANCE,\n\ttype ContextScoutToolDependencies,\n\ttype ContextScoutToolDetails,\n\ttype ContextScoutToolInput,\n\tcreateContextScoutToolDefinition,\n\tformatScoutResult,\n} from \"./context-scout.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport {\n\tcreateExtensionifyTool,\n\tcreateExtensionifyToolDefinition,\n\ttype ExtensionifyInput,\n\ttype ExtensionifyReport,\n\ttype ExtensionifyToolDetails,\n\ttype ExtensionifyToolOptions,\n} from \"./extensionify.ts\";\nexport {\n\tcreateFileFailureRecoveryAuthority,\n\ttype FileFailureRecoveryAuthority,\n} from \"./file-failure-recovery.ts\";\nexport {\n\ttype FileContentReference,\n\tFileMutationIntentController,\n\ttype FileMutationIntentControllerOptions,\n\ttype FileMutationIntentOperations,\n\ttype FileMutationKind,\n\ttype FileMutationLease,\n\ttype FileMutationPayloadReference,\n\tFileMutationPreflightError,\n\ttype FileMutationPreflightFailureReason,\n\ttype FilePathIdentity,\n\ttype FilePathInspection,\n\tlocalFileMutationIntentOperations,\n} from \"./file-mutation-intent.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreatePythonTool,\n\tcreatePythonToolDefinition,\n\tDEFAULT_PYTHON_TIMEOUT_SECONDS,\n\tMAX_PYTHON_OUTPUT_BYTES,\n\tMAX_PYTHON_TIMEOUT_SECONDS,\n\ttype PythonExecutionRequest,\n\ttype PythonExecutionResult,\n\ttype PythonOperations,\n\ttype PythonToolDetails,\n\ttype PythonToolInput,\n\ttype PythonToolOptions,\n\tresolvePythonToolPath,\n} from \"./python.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tcreateSecretStoreToolDefinition,\n\ttype SecretStoreStatus,\n\ttype SecretStoreToolDetails,\n\ttype SecretStoreToolInput,\n\ttype SecretStoreToolOptions,\n} from \"./secret-store.ts\";\nexport {\n\tcreateSkillVaultToolDefinition,\n\ttype SkillToolDetails,\n\ttype SkillToolInput,\n} from \"./skill.ts\";\nexport {\n\tcreateSkillAuditTool,\n\tcreateSkillAuditToolDefinition,\n\tjaccard,\n\ttype SkillAuditInput,\n\ttype SkillAuditReport,\n\ttype SkillAuditToolDetails,\n\ttype SkillAuditToolOptions,\n\ttokenize,\n} from \"./skill-audit.ts\";\nexport {\n\tcreateSkillifyTool,\n\tcreateSkillifyToolDefinition,\n\ttype SkillifyInput,\n\ttype SkillifyReport,\n\ttype SkillifyToolDetails,\n\ttype SkillifyToolOptions,\n} from \"./skillify.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolDetails,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport {\n\ttype ArtifactRetrieveToolOptions,\n\tcreateArtifactRetrieveTool,\n\tcreateArtifactRetrieveToolDefinition,\n} from \"./artifact-retrieve.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport {\n\tcreateDefaultExtensionifyRuntimeOptions,\n\tcreateExtensionifyTool,\n\tcreateExtensionifyToolDefinition,\n\ttype ExtensionifyToolOptions,\n} from \"./extensionify.ts\";\nimport { FileMutationIntentController } from \"./file-mutation-intent.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createPythonTool, createPythonToolDefinition, type PythonToolOptions } from \"./python.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createSkillAuditTool, createSkillAuditToolDefinition, type SkillAuditToolOptions } from \"./skill-audit.ts\";\nimport { createSkillifyTool, createSkillifyToolDefinition, type SkillifyToolOptions } from \"./skillify.ts\";\nimport { createToolDefinitionWithRuntime, type ToolDef, type ToolName } from \"./tool-definition-factory.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport { allToolNames, type ToolDef, type ToolName } from \"./tool-definition-factory.ts\";\n\nexport type Tool = AgentTool<any>;\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\tpython?: PythonToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n\tskill_audit?: SkillAuditToolOptions;\n\tskillify?: SkillifyToolOptions;\n\textensionify?: ExtensionifyToolOptions;\n\tartifact_retrieve?: ArtifactRetrieveToolOptions;\n}\n\nfunction withSharedFileMutationIntents(options?: ToolsOptions): ToolsOptions {\n\tconst writeController = options?.write?.intentController;\n\tconst editController = options?.edit?.intentController;\n\tif ((options?.write?.operations || options?.edit?.operations) && !writeController && !editController) {\n\t\tthrow new Error(\"Custom file operations require an explicit shared file mutation intent controller.\");\n\t}\n\tif (writeController && editController && writeController !== editController) {\n\t\tthrow new Error(\"Write and edit tools in one surface must share one file mutation intent controller.\");\n\t}\n\tconst intentController = writeController ?? editController ?? new FileMutationIntentController();\n\treturn {\n\t\t...options,\n\t\twrite: { ...options?.write, intentController },\n\t\tedit: { ...options?.edit, intentController },\n\t};\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\treturn createToolDefinitionWithRuntime(toolName, cwd, {\n\t\t...options,\n\t\textensionify: createDefaultExtensionifyRuntimeOptions(options?.extensionify),\n\t});\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"python\":\n\t\t\treturn createPythonTool(cwd, options?.python);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tcase \"skill_audit\":\n\t\t\treturn createSkillAuditTool(cwd, options?.skill_audit);\n\t\tcase \"skillify\":\n\t\t\treturn createSkillifyTool(cwd, options?.skillify);\n\t\tcase \"extensionify\":\n\t\t\treturn createExtensionifyTool(cwd, options?.extensionify);\n\t\tcase \"artifact_retrieve\":\n\t\t\treturn createArtifactRetrieveTool(cwd, options?.artifact_retrieve);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tplatform: NodeJS.Platform = process.platform,\n): ToolDef[] {\n\tconst sharedOptions = withSharedFileMutationIntents(options);\n\tconst bashOptions: BashToolOptions = { ...options?.bash, platform };\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, bashOptions),\n\t\tcreatePythonToolDefinition(cwd, options?.python),\n\t\tcreateEditToolDefinition(cwd, sharedOptions.edit),\n\t\tcreateWriteToolDefinition(cwd, sharedOptions.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\n\nexport function createAllToolDefinitions(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tplatform: NodeJS.Platform = process.platform,\n): Partial<Record<ToolName, ToolDef>> {\n\tconst sharedOptions = withSharedFileMutationIntents(options);\n\tconst bashOptions: BashToolOptions = { ...options?.bash, platform };\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, bashOptions),\n\t\tpython: createPythonToolDefinition(cwd, options?.python),\n\t\tedit: createEditToolDefinition(cwd, sharedOptions.edit),\n\t\twrite: createWriteToolDefinition(cwd, sharedOptions.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\tskill_audit: createSkillAuditToolDefinition(cwd, options?.skill_audit),\n\t\tskillify: createSkillifyToolDefinition(cwd, options?.skillify),\n\t\textensionify: createExtensionifyToolDefinition(cwd, options?.extensionify),\n\t\tartifact_retrieve: createArtifactRetrieveToolDefinition(cwd, options?.artifact_retrieve),\n\t};\n}\n\nexport function createCodingTools(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tplatform: NodeJS.Platform = process.platform,\n): Tool[] {\n\tconst sharedOptions = withSharedFileMutationIntents(options);\n\tconst bashOptions: BashToolOptions = { ...options?.bash, platform };\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, bashOptions),\n\t\tcreatePythonTool(cwd, options?.python),\n\t\tcreateEditTool(cwd, sharedOptions.edit),\n\t\tcreateWriteTool(cwd, sharedOptions.write),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tplatform: NodeJS.Platform = process.platform,\n): Partial<Record<ToolName, Tool>> {\n\tconst sharedOptions = withSharedFileMutationIntents(options);\n\tconst bashOptions: BashToolOptions = { ...options?.bash, platform };\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, bashOptions),\n\t\tpython: createPythonTool(cwd, options?.python),\n\t\tedit: createEditTool(cwd, sharedOptions.edit),\n\t\twrite: createWriteTool(cwd, sharedOptions.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\tskill_audit: createSkillAuditTool(cwd, options?.skill_audit),\n\t\tskillify: createSkillifyTool(cwd, options?.skillify),\n\t\textensionify: createExtensionifyTool(cwd, options?.extensionify),\n\t\tartifact_retrieve: createArtifactRetrieveTool(cwd, options?.artifact_retrieve),\n\t};\n}\n"]}
|
|
@@ -13,11 +13,11 @@ export function createModelFitnessToolDefinition(deps) {
|
|
|
13
13
|
name: "model_fitness",
|
|
14
14
|
label: "model_fitness",
|
|
15
15
|
description: "Probe whether a candidate model can drive the harness's subagent contracts: runs the real research-lane, delegated-worker, and routing-judge runners against the model and reports parse/success rates, judge discrimination, latency, and probe cost. Use it to evaluate small/local models (e.g. Ollama) before configuring them as lane or judge models.",
|
|
16
|
-
promptSnippet: "Benchmark
|
|
16
|
+
promptSnippet: "Benchmark model against research/worker/judge contracts.",
|
|
17
17
|
promptGuidelines: [
|
|
18
|
-
"Use
|
|
19
|
-
"
|
|
20
|
-
"Probes spend real tokens
|
|
18
|
+
"Use before pinning model in worker profile, researchLane.model, modelRouter.judgeModel.",
|
|
19
|
+
"Lane: high research/worker success. Judge: trivial cheap, planning elevated.",
|
|
20
|
+
"Probes spend real tokens; prefer local/free models or few trials.",
|
|
21
21
|
],
|
|
22
22
|
parameters: modelFitnessSchema,
|
|
23
23
|
async execute(toolCallId, input) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-fitness.js","sourceRoot":"","sources":["../../../src/core/tools/model-fitness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAExE,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CACrC;IACC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;QAClB,WAAW,EACV,4IAA4I;KAC7I,CAAC;IACF,MAAM,EAAE,IAAI,CAAC,QAAQ,CACpB,IAAI,CAAC,MAAM,CAAC;QACX,WAAW,EACV,qGAAqG;KACtG,CAAC,CACF;CACD,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAC/B,CAAC;AAyBF,MAAM,UAAU,gCAAgC,CAAC,IAAkC;IAClF,OAAO;QACN,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,eAAe;QACtB,WAAW,EACV,6VAA6V;QAC9V,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"model-fitness.js","sourceRoot":"","sources":["../../../src/core/tools/model-fitness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAA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E,CAAC;gBAC3F,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE;aAChE,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport type { ModelFitnessReport } from \"../research/model-fitness.ts\";\nimport { formatModelFitnessReport } from \"../research/model-fitness.ts\";\n\nconst modelFitnessSchema = Type.Object(\n\t{\n\t\tmodel: Type.String({\n\t\t\tdescription:\n\t\t\t\t'Model pattern to probe, e.g. \"ollama/qwen3:0.6b\" or any registered provider/model pattern. The model must be registered and authenticated.',\n\t\t}),\n\t\ttrials: Type.Optional(\n\t\t\tType.Number({\n\t\t\t\tdescription:\n\t\t\t\t\t\"Trials per lane surface (research/worker), 1-20. Default 3. The judge always runs its 6-prompt set.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type ModelFitnessToolInput = Static<typeof modelFitnessSchema>;\n\nexport interface ModelFitnessToolDetails {\n\tstarted: boolean;\n\tskipReason?: string;\n\tmodel?: string;\n\treport?: ModelFitnessReport;\n}\n\nexport interface ModelFitnessToolDependencies {\n\trunProbe: (args: {\n\t\tmodel: string;\n\t\ttrials?: number;\n\t\t/**\n\t\t * The LLM tool-call id for THIS invocation: the idempotency token a retry of the same\n\t\t * tool call reuses, so the spawned-usage reportId stays stable on a retry instead of falling\n\t\t * back to a bare (model, trials) identity — which two deliberately separate tool calls on the\n\t\t * same model/trials would otherwise collide on and silently under-count.\n\t\t */\n\t\ttoolCallId?: string;\n\t}) => Promise<{ started: true; model: string; report: ModelFitnessReport } | { started: false; skipReason: string }>;\n}\n\nexport function createModelFitnessToolDefinition(deps: ModelFitnessToolDependencies): ToolDefinition {\n\treturn {\n\t\tname: \"model_fitness\",\n\t\tlabel: \"model_fitness\",\n\t\tdescription:\n\t\t\t\"Probe whether a candidate model can drive the harness's subagent contracts: runs the real research-lane, delegated-worker, and routing-judge runners against the model and reports parse/success rates, judge discrimination, latency, and probe cost. Use it to evaluate small/local models (e.g. Ollama) before configuring them as lane or judge models.\",\n\t\tpromptSnippet: \"Benchmark model against research/worker/judge contracts.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use before pinning model in worker profile, researchLane.model, modelRouter.judgeModel.\",\n\t\t\t\"Lane: high research/worker success. Judge: trivial cheap, planning elevated.\",\n\t\t\t\"Probes spend real tokens; prefer local/free models or few trials.\",\n\t\t],\n\t\tparameters: modelFitnessSchema,\n\t\tasync execute(\n\t\t\ttoolCallId,\n\t\t\tinput: ModelFitnessToolInput,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: ModelFitnessToolDetails;\n\t\t}> {\n\t\t\tconst run = await deps.runProbe({ model: input.model, trials: input.trials, toolCallId });\n\t\t\tif (!run.started) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `model_fitness skipped: ${run.skipReason}` }],\n\t\t\t\t\tdetails: { started: false, skipReason: run.skipReason },\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\" as const, text: formatModelFitnessReport(run.model, run.report) }],\n\t\t\t\tdetails: { started: true, model: run.model, report: run.report },\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
declare const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import type { TaskProfileCreateInput, TaskProfileCreateResult, TaskProfileInspection, TaskProfileWriterPort } from "../orchestration/task-profile-writer.ts";
|
|
3
|
+
import type { OrchestrationPanelModel } from "./orchestration-panel.ts";
|
|
4
|
+
export declare const DELEGATE_PROFILE_ACTIONS: readonly ["profile_inspect", "profile_create"];
|
|
5
|
+
export type DelegateProfileAction = (typeof DELEGATE_PROFILE_ACTIONS)[number];
|
|
6
|
+
export interface DelegateProfileInput {
|
|
7
|
+
task?: string;
|
|
8
|
+
baseProfileId?: string;
|
|
9
|
+
model?: TaskProfileCreateInput["model"];
|
|
10
|
+
toolNames?: readonly string[];
|
|
11
|
+
resourceProfileNames?: readonly string[];
|
|
12
|
+
budget?: TaskProfileCreateInput["budget"];
|
|
13
|
+
}
|
|
14
|
+
export interface DelegateProfileToolDetails extends TaskProfileCreateResult {
|
|
15
|
+
started: boolean;
|
|
16
|
+
action: DelegateProfileAction;
|
|
17
|
+
kind: "profile";
|
|
18
|
+
inspection?: TaskProfileInspection;
|
|
19
|
+
}
|
|
20
|
+
export declare function createDelegateProfileParameterSchemas(): {
|
|
21
|
+
task: Type.TOptional<Type.TString>;
|
|
9
22
|
baseProfileId: Type.TOptional<Type.TString>;
|
|
10
23
|
model: Type.TOptional<Type.TObject<{
|
|
11
24
|
provider: Type.TString;
|
|
@@ -22,12 +35,13 @@ declare const profileWriterSchema: Type.TUnion<[Type.TObject<{
|
|
|
22
35
|
maxToolCalls: Type.TOptional<Type.TNumber>;
|
|
23
36
|
requireApprovalAboveCostUsd: Type.TOptional<Type.TNumber>;
|
|
24
37
|
}>>;
|
|
25
|
-
}
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
};
|
|
39
|
+
export declare function delegateProfilePanelModel(details: DelegateProfileToolDetails): OrchestrationPanelModel;
|
|
40
|
+
export declare function executeDelegateProfileAction(action: DelegateProfileAction, input: DelegateProfileInput, writer: TaskProfileWriterPort): {
|
|
41
|
+
content: Array<{
|
|
42
|
+
type: "text";
|
|
43
|
+
text: string;
|
|
44
|
+
}>;
|
|
45
|
+
details: DelegateProfileToolDetails;
|
|
46
|
+
};
|
|
33
47
|
//# sourceMappingURL=profile-writer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-writer.d.ts","sourceRoot":"","sources":["../../../src/core/tools/profile-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"profile-writer.d.ts","sourceRoot":"","sources":["../../../src/core/tools/profile-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAQ/B,OAAO,KAAK,EACX,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAExE,eAAO,MAAM,wBAAwB,YAAI,iBAAiB,EAAE,gBAAgB,CAAU,CAAC;AAEvF,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9E,MAAM,WAAW,oBAAoB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACxC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,oBAAoB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,MAAM,CAAC,EAAE,sBAAsB,CAAC,QAAQ,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,0BAA2B,SAAQ,uBAAuB;IAC1E,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,qBAAqB,CAAC;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,CAAC,EAAE,qBAAqB,CAAC;CACnC;AAED,wBAAgB,qCAAqC;IAEnD,IAAI;IACJ,aAAa;IACb,KAAK;;;;;IAaL,SAAS;IAKT,oBAAoB;IAKpB,MAAM;;;;;;;;EAcP;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,0BAA0B,GAAG,uBAAuB,CA2BtG;AAED,wBAAgB,4BAA4B,CAC3C,MAAM,EAAE,qBAAqB,EAC7B,KAAK,EAAE,oBAAoB,EAC3B,MAAM,EAAE,qBAAqB,GAC3B;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,EAAE,0BAA0B,CAAA;CAAE,CA8CzF"}
|
|
@@ -1,67 +1,106 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
-
import { ORCHESTRATION_THINKING_LEVELS } from "../orchestration/contracts.js";
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
maxAttempts: Type.Optional(Type.Number({ minimum: 0 })),
|
|
9
|
-
maxToolCalls: Type.Optional(Type.Number({ minimum: 0 })),
|
|
10
|
-
requireApprovalAboveCostUsd: Type.Optional(Type.Number({ minimum: 0 })),
|
|
11
|
-
}, { additionalProperties: false });
|
|
12
|
-
const profileWriterSchema = Type.Union([
|
|
13
|
-
Type.Object({ action: Type.Literal("inspect") }, { additionalProperties: false }),
|
|
14
|
-
Type.Object({
|
|
15
|
-
action: Type.Literal("create"),
|
|
16
|
-
task: Type.String({ minLength: 1, maxLength: 3_500 }),
|
|
17
|
-
baseProfileId: Type.Optional(Type.String({ minLength: 1 })),
|
|
2
|
+
import { MAX_ORCHESTRATION_COLLECTION_LENGTH, MAX_ORCHESTRATION_IDENTIFIER_LENGTH, MAX_ORCHESTRATION_MODEL_ID_LENGTH, MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH, ORCHESTRATION_THINKING_LEVELS, } from "../orchestration/contracts.js";
|
|
3
|
+
export const DELEGATE_PROFILE_ACTIONS = ["profile_inspect", "profile_create"];
|
|
4
|
+
export function createDelegateProfileParameterSchemas() {
|
|
5
|
+
return {
|
|
6
|
+
task: Type.Optional(Type.String({ minLength: 1, maxLength: 3_500 })),
|
|
7
|
+
baseProfileId: Type.Optional(Type.String({ minLength: 1, maxLength: MAX_ORCHESTRATION_IDENTIFIER_LENGTH })),
|
|
18
8
|
model: Type.Optional(Type.Object({
|
|
19
|
-
provider: Type.String({
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
provider: Type.String({
|
|
10
|
+
minLength: 1,
|
|
11
|
+
maxLength: MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,
|
|
12
|
+
}),
|
|
13
|
+
modelId: Type.String({ minLength: 1, maxLength: MAX_ORCHESTRATION_MODEL_ID_LENGTH }),
|
|
14
|
+
thinkingLevel: Type.Union(ORCHESTRATION_THINKING_LEVELS.map((level) => Type.Literal(level))),
|
|
15
|
+
}, { additionalProperties: false })),
|
|
16
|
+
toolNames: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: MAX_ORCHESTRATION_IDENTIFIER_LENGTH }), {
|
|
17
|
+
maxItems: MAX_ORCHESTRATION_COLLECTION_LENGTH,
|
|
18
|
+
})),
|
|
19
|
+
resourceProfileNames: Type.Optional(Type.Array(Type.String({ minLength: 1, maxLength: MAX_ORCHESTRATION_IDENTIFIER_LENGTH }), {
|
|
20
|
+
maxItems: MAX_ORCHESTRATION_COLLECTION_LENGTH,
|
|
21
|
+
})),
|
|
22
|
+
budget: Type.Optional(Type.Object({
|
|
23
|
+
maxTokens: Type.Optional(Type.Number({ minimum: 0 })),
|
|
24
|
+
maxWallClockMs: Type.Optional(Type.Number({ minimum: 0 })),
|
|
25
|
+
maxCostUsd: Type.Optional(Type.Number({ minimum: 0 })),
|
|
26
|
+
maxAttempts: Type.Optional(Type.Number({ minimum: 0 })),
|
|
27
|
+
maxToolCalls: Type.Optional(Type.Number({ minimum: 0 })),
|
|
28
|
+
requireApprovalAboveCostUsd: Type.Optional(Type.Number({ minimum: 0 })),
|
|
22
29
|
}, { additionalProperties: false })),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function delegateProfilePanelModel(details) {
|
|
33
|
+
if (details.action === "profile_inspect") {
|
|
34
|
+
return {
|
|
35
|
+
label: "worker profiles",
|
|
36
|
+
action: "inspected",
|
|
37
|
+
status: "success",
|
|
38
|
+
summary: [
|
|
39
|
+
`${details.inspection?.baseProfiles.length ?? 0} bases`,
|
|
40
|
+
`${details.inspection?.models.length ?? 0} models`,
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
label: "worker profiles",
|
|
46
|
+
action: details.created ? "created" : "rejected",
|
|
47
|
+
status: details.created ? "success" : "warning",
|
|
48
|
+
rows: details.profileId
|
|
49
|
+
? [
|
|
50
|
+
{
|
|
51
|
+
status: "succeeded",
|
|
52
|
+
label: details.profileId,
|
|
53
|
+
meta: details.baseProfileId ? [`base ${details.baseProfileId}`] : undefined,
|
|
54
|
+
},
|
|
55
|
+
]
|
|
56
|
+
: undefined,
|
|
57
|
+
emptyText: details.reason,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function executeDelegateProfileAction(action, input, writer) {
|
|
61
|
+
if (action === "profile_inspect") {
|
|
62
|
+
const inspection = writer.inspectTaskProfileOptions();
|
|
63
|
+
return {
|
|
64
|
+
content: [
|
|
65
|
+
{
|
|
66
|
+
type: "text",
|
|
67
|
+
text: `Authorized bases: ${inspection.baseProfiles.map((profile) => profile.profileId).join(", ") || "none"}. Available configured models: ${inspection.models.length}.`,
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
details: { started: true, action, kind: "profile", created: false, inspection },
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (input.task === undefined) {
|
|
74
|
+
return {
|
|
75
|
+
content: [{ type: "text", text: "delegate profile_create requires task" }],
|
|
76
|
+
details: {
|
|
77
|
+
started: false,
|
|
78
|
+
action,
|
|
79
|
+
kind: "profile",
|
|
80
|
+
created: false,
|
|
81
|
+
reason: "missing_profile_task",
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const request = {
|
|
86
|
+
task: input.task,
|
|
87
|
+
...(input.baseProfileId !== undefined ? { baseProfileId: input.baseProfileId } : {}),
|
|
88
|
+
...(input.model !== undefined ? { model: input.model } : {}),
|
|
89
|
+
...(input.toolNames !== undefined ? { toolNames: input.toolNames } : {}),
|
|
90
|
+
...(input.resourceProfileNames !== undefined ? { resourceProfileNames: input.resourceProfileNames } : {}),
|
|
91
|
+
...(input.budget !== undefined ? { budget: input.budget } : {}),
|
|
92
|
+
};
|
|
93
|
+
const result = writer.createTaskProfile(request);
|
|
29
94
|
return {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
95
|
+
content: [
|
|
96
|
+
{
|
|
97
|
+
type: "text",
|
|
98
|
+
text: result.created
|
|
99
|
+
? `Created immutable session task profile ${result.profileId} from ${result.baseProfileId}.`
|
|
100
|
+
: `delegate profile_create rejected the request: ${result.reason}.`,
|
|
101
|
+
},
|
|
37
102
|
],
|
|
38
|
-
|
|
39
|
-
execute(_toolCallId, input) {
|
|
40
|
-
if (input.action === "inspect") {
|
|
41
|
-
const inspection = writer.inspectTaskProfileOptions();
|
|
42
|
-
return Promise.resolve({
|
|
43
|
-
content: [
|
|
44
|
-
{
|
|
45
|
-
type: "text",
|
|
46
|
-
text: `Authorized bases: ${inspection.baseProfiles.map((profile) => profile.profileId).join(", ") || "none"}. Available configured models: ${inspection.models.length}.`,
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
details: { action: "inspect", created: false, inspection },
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
const result = writer.createTaskProfile(input);
|
|
53
|
-
return Promise.resolve({
|
|
54
|
-
content: [
|
|
55
|
-
{
|
|
56
|
-
type: "text",
|
|
57
|
-
text: result.created
|
|
58
|
-
? `Created immutable session task profile ${result.profileId} from ${result.baseProfileId}.`
|
|
59
|
-
: `profile_writer rejected the request: ${result.reason}.`,
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
details: { action: "create", ...result },
|
|
63
|
-
});
|
|
64
|
-
},
|
|
103
|
+
details: { started: result.created, action, kind: "profile", ...result },
|
|
65
104
|
};
|
|
66
105
|
}
|
|
67
106
|
//# sourceMappingURL=profile-writer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-writer.js","sourceRoot":"","sources":["../../../src/core/tools/profile-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAQ9E,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,6BAA6B,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAE1G,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAC/B;IACC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IACrD,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1D,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IACtD,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IACvD,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,O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OAAO;4BACnB,CAAC,CAAC,0CAA0C,MAAM,CAAC,SAAS,SAAS,MAAM,CAAC,aAAa,GAAG;4BAC5F,CAAC,CAAC,wCAAwC,MAAM,CAAC,MAAM,GAAG;qBAC3D;iBACD;gBACD,OAAO,EAAE,EAAE,MAAM,EAAE,QAAiB,EAAE,GAAG,MAAM,EAAE;aACjD,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { ORCHESTRATION_THINKING_LEVELS } from \"../orchestration/contracts.ts\";\nimport type {\n\tTaskProfileCreateInput,\n\tTaskProfileCreateResult,\n\tTaskProfileInspection,\n\tTaskProfileWriterPort,\n} from \"../orchestration/task-profile-writer.ts\";\n\nconst thinkingLevelSchema = Type.Union(ORCHESTRATION_THINKING_LEVELS.map((level) => Type.Literal(level)));\n\nconst budgetSchema = Type.Object(\n\t{\n\t\tmaxTokens: Type.Optional(Type.Number({ minimum: 0 })),\n\t\tmaxWallClockMs: Type.Optional(Type.Number({ minimum: 0 })),\n\t\tmaxCostUsd: Type.Optional(Type.Number({ minimum: 0 })),\n\t\tmaxAttempts: Type.Optional(Type.Number({ minimum: 0 })),\n\t\tmaxToolCalls: Type.Optional(Type.Number({ minimum: 0 })),\n\t\trequireApprovalAboveCostUsd: Type.Optional(Type.Number({ minimum: 0 })),\n\t},\n\t{ additionalProperties: false },\n);\n\nconst profileWriterSchema = Type.Union([\n\tType.Object({ action: Type.Literal(\"inspect\") }, { additionalProperties: false }),\n\tType.Object(\n\t\t{\n\t\t\taction: Type.Literal(\"create\"),\n\t\t\ttask: Type.String({ minLength: 1, maxLength: 3_500 }),\n\t\t\tbaseProfileId: Type.Optional(Type.String({ minLength: 1 })),\n\t\t\tmodel: Type.Optional(\n\t\t\t\tType.Object(\n\t\t\t\t\t{\n\t\t\t\t\t\tprovider: Type.String({ minLength: 1 }),\n\t\t\t\t\t\tmodelId: Type.String({ minLength: 1 }),\n\t\t\t\t\t\tthinkingLevel: thinkingLevelSchema,\n\t\t\t\t\t},\n\t\t\t\t\t{ additionalProperties: false },\n\t\t\t\t),\n\t\t\t),\n\t\t\ttoolNames: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 64 })),\n\t\t\tresourceProfileNames: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 64 })),\n\t\t\tbudget: Type.Optional(budgetSchema),\n\t\t},\n\t\t{ additionalProperties: false },\n\t),\n]);\n\nexport type ProfileWriterToolInput = Static<typeof profileWriterSchema>;\n\nexport interface ProfileWriterToolDetails extends TaskProfileCreateResult {\n\taction: \"inspect\" | \"create\";\n\tinspection?: TaskProfileInspection;\n}\n\nexport function createProfileWriterToolDefinition(writer: TaskProfileWriterPort): ToolDefinition {\n\treturn {\n\t\tname: \"profile_writer\",\n\t\tlabel: \"profile_writer\",\n\t\tdescription:\n\t\t\t\"Inspect authorized worker bases or create an optional immutable session preset that only narrows a base. Direct delegation does not require a profile.\",\n\t\tpromptSnippet: \"Inspect or create an optional session worker preset\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use this only when a reusable task-specific preset helps; delegate.authority can select execution directly.\",\n\t\t\t\"Pass the returned profileId unchanged to delegate; never invent ids or write one-off profile files.\",\n\t\t],\n\t\tparameters: profileWriterSchema,\n\t\texecute(_toolCallId, input: ProfileWriterToolInput) {\n\t\t\tif (input.action === \"inspect\") {\n\t\t\t\tconst inspection = writer.inspectTaskProfileOptions();\n\t\t\t\treturn Promise.resolve({\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\t\ttext: `Authorized bases: ${inspection.baseProfiles.map((profile) => profile.profileId).join(\", \") || \"none\"}. Available configured models: ${inspection.models.length}.`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { action: \"inspect\" as const, created: false, inspection },\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst result = writer.createTaskProfile(input as TaskProfileCreateInput);\n\t\t\treturn Promise.resolve({\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\ttext: result.created\n\t\t\t\t\t\t\t? `Created immutable session task profile ${result.profileId} from ${result.baseProfileId}.`\n\t\t\t\t\t\t\t: `profile_writer rejected the request: ${result.reason}.`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdetails: { action: \"create\" as const, ...result },\n\t\t\t});\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"profile-writer.js","sourceRoot":"","sources":["../../../src/core/tools/profile-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EACN,mCAAmC,EACnC,mCAAmC,EACnC,iCAAiC,EACjC,uCAAuC,EACvC,6BAA6B,GAC7B,MAAM,+BAA+B,CAAC;AASvC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,iBAAiB,EAAE,gBAAgB,CAAU,CAAC;AAoBvF,MAAM,UAAU,qCAAqC;IACpD,OAAO;QACN,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;QACpE,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,mCAAmC,EAAE,CAAC,CAAC;QAC3G,KAAK,EAAE,IAAI,CAAC,QAAQ,CACnB,IAAI,CAAC,MAAM,CACV;YACC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC;gBACrB,SAAS,EAAE,CAAC;gBACZ,SAAS,EAAE,uCAAuC;aAClD,CAAC;YACF,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,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,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxE,GAAG,CAAC,KAAK,CAAC,oBAAoB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,oBAAoB,EAAE,KAAK,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzG,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC/D,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACjD,OAAO;QACN,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,MAAM,CAAC,OAAO;oBACnB,CAAC,CAAC,0CAA0C,MAAM,CAAC,SAAS,SAAS,MAAM,CAAC,aAAa,GAAG;oBAC5F,CAAC,CAAC,iDAAiD,MAAM,CAAC,MAAM,GAAG;aACpE;SACD;QACD,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE;KACxE,CAAC;AACH,CAAC","sourcesContent":["import { Type } from \"typebox\";\nimport {\n\tMAX_ORCHESTRATION_COLLECTION_LENGTH,\n\tMAX_ORCHESTRATION_IDENTIFIER_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_ID_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,\n\tORCHESTRATION_THINKING_LEVELS,\n} from \"../orchestration/contracts.ts\";\nimport type {\n\tTaskProfileCreateInput,\n\tTaskProfileCreateResult,\n\tTaskProfileInspection,\n\tTaskProfileWriterPort,\n} from \"../orchestration/task-profile-writer.ts\";\nimport type { OrchestrationPanelModel } from \"./orchestration-panel.ts\";\n\nexport const DELEGATE_PROFILE_ACTIONS = [\"profile_inspect\", \"profile_create\"] as const;\n\nexport type DelegateProfileAction = (typeof DELEGATE_PROFILE_ACTIONS)[number];\n\nexport interface DelegateProfileInput {\n\ttask?: string;\n\tbaseProfileId?: string;\n\tmodel?: TaskProfileCreateInput[\"model\"];\n\ttoolNames?: readonly string[];\n\tresourceProfileNames?: readonly string[];\n\tbudget?: TaskProfileCreateInput[\"budget\"];\n}\n\nexport interface DelegateProfileToolDetails extends TaskProfileCreateResult {\n\tstarted: boolean;\n\taction: DelegateProfileAction;\n\tkind: \"profile\";\n\tinspection?: TaskProfileInspection;\n}\n\nexport function createDelegateProfileParameterSchemas() {\n\treturn {\n\t\ttask: Type.Optional(Type.String({ minLength: 1, maxLength: 3_500 })),\n\t\tbaseProfileId: Type.Optional(Type.String({ minLength: 1, maxLength: MAX_ORCHESTRATION_IDENTIFIER_LENGTH })),\n\t\tmodel: Type.Optional(\n\t\t\tType.Object(\n\t\t\t\t{\n\t\t\t\t\tprovider: Type.String({\n\t\t\t\t\t\tminLength: 1,\n\t\t\t\t\t\tmaxLength: MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,\n\t\t\t\t\t}),\n\t\t\t\t\tmodelId: Type.String({ minLength: 1, maxLength: MAX_ORCHESTRATION_MODEL_ID_LENGTH }),\n\t\t\t\t\tthinkingLevel: Type.Union(ORCHESTRATION_THINKING_LEVELS.map((level) => Type.Literal(level))),\n\t\t\t\t},\n\t\t\t\t{ additionalProperties: false },\n\t\t\t),\n\t\t),\n\t\ttoolNames: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1, maxLength: MAX_ORCHESTRATION_IDENTIFIER_LENGTH }), {\n\t\t\t\tmaxItems: MAX_ORCHESTRATION_COLLECTION_LENGTH,\n\t\t\t}),\n\t\t),\n\t\tresourceProfileNames: Type.Optional(\n\t\t\tType.Array(Type.String({ minLength: 1, maxLength: MAX_ORCHESTRATION_IDENTIFIER_LENGTH }), {\n\t\t\t\tmaxItems: MAX_ORCHESTRATION_COLLECTION_LENGTH,\n\t\t\t}),\n\t\t),\n\t\tbudget: Type.Optional(\n\t\t\tType.Object(\n\t\t\t\t{\n\t\t\t\t\tmaxTokens: Type.Optional(Type.Number({ minimum: 0 })),\n\t\t\t\t\tmaxWallClockMs: Type.Optional(Type.Number({ minimum: 0 })),\n\t\t\t\t\tmaxCostUsd: Type.Optional(Type.Number({ minimum: 0 })),\n\t\t\t\t\tmaxAttempts: Type.Optional(Type.Number({ minimum: 0 })),\n\t\t\t\t\tmaxToolCalls: Type.Optional(Type.Number({ minimum: 0 })),\n\t\t\t\t\trequireApprovalAboveCostUsd: Type.Optional(Type.Number({ minimum: 0 })),\n\t\t\t\t},\n\t\t\t\t{ additionalProperties: false },\n\t\t\t),\n\t\t),\n\t};\n}\n\nexport function delegateProfilePanelModel(details: DelegateProfileToolDetails): OrchestrationPanelModel {\n\tif (details.action === \"profile_inspect\") {\n\t\treturn {\n\t\t\tlabel: \"worker profiles\",\n\t\t\taction: \"inspected\",\n\t\t\tstatus: \"success\",\n\t\t\tsummary: [\n\t\t\t\t`${details.inspection?.baseProfiles.length ?? 0} bases`,\n\t\t\t\t`${details.inspection?.models.length ?? 0} models`,\n\t\t\t],\n\t\t};\n\t}\n\treturn {\n\t\tlabel: \"worker profiles\",\n\t\taction: details.created ? \"created\" : \"rejected\",\n\t\tstatus: details.created ? \"success\" : \"warning\",\n\t\trows: details.profileId\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tstatus: \"succeeded\",\n\t\t\t\t\t\tlabel: details.profileId,\n\t\t\t\t\t\tmeta: details.baseProfileId ? [`base ${details.baseProfileId}`] : undefined,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: undefined,\n\t\temptyText: details.reason,\n\t};\n}\n\nexport function executeDelegateProfileAction(\n\taction: DelegateProfileAction,\n\tinput: DelegateProfileInput,\n\twriter: TaskProfileWriterPort,\n): { content: Array<{ type: \"text\"; text: string }>; details: DelegateProfileToolDetails } {\n\tif (action === \"profile_inspect\") {\n\t\tconst inspection = writer.inspectTaskProfileOptions();\n\t\treturn {\n\t\t\tcontent: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: `Authorized bases: ${inspection.baseProfiles.map((profile) => profile.profileId).join(\", \") || \"none\"}. Available configured models: ${inspection.models.length}.`,\n\t\t\t\t},\n\t\t\t],\n\t\t\tdetails: { started: true, action, kind: \"profile\", created: false, inspection },\n\t\t};\n\t}\n\n\tif (input.task === undefined) {\n\t\treturn {\n\t\t\tcontent: [{ type: \"text\", text: \"delegate profile_create requires task\" }],\n\t\t\tdetails: {\n\t\t\t\tstarted: false,\n\t\t\t\taction,\n\t\t\t\tkind: \"profile\",\n\t\t\t\tcreated: false,\n\t\t\t\treason: \"missing_profile_task\",\n\t\t\t},\n\t\t};\n\t}\n\tconst request: TaskProfileCreateInput = {\n\t\ttask: input.task,\n\t\t...(input.baseProfileId !== undefined ? { baseProfileId: input.baseProfileId } : {}),\n\t\t...(input.model !== undefined ? { model: input.model } : {}),\n\t\t...(input.toolNames !== undefined ? { toolNames: input.toolNames } : {}),\n\t\t...(input.resourceProfileNames !== undefined ? { resourceProfileNames: input.resourceProfileNames } : {}),\n\t\t...(input.budget !== undefined ? { budget: input.budget } : {}),\n\t};\n\tconst result = writer.createTaskProfile(request);\n\treturn {\n\t\tcontent: [\n\t\t\t{\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: result.created\n\t\t\t\t\t? `Created immutable session task profile ${result.profileId} from ${result.baseProfileId}.`\n\t\t\t\t\t: `delegate profile_create rejected the request: ${result.reason}.`,\n\t\t\t},\n\t\t],\n\t\tdetails: { started: result.created, action, kind: \"profile\", ...result },\n\t};\n}\n"]}
|
|
@@ -102,13 +102,13 @@ export function createPythonToolDefinition(baseCwd, options = {}) {
|
|
|
102
102
|
name: "python",
|
|
103
103
|
label: "python",
|
|
104
104
|
description: `Run a bounded Python snippet or script without a shell. Pi resolves Python through uv, defaults to a ${DEFAULT_PYTHON_TIMEOUT_SECONDS}-second wall-clock timeout (maximum ${MAX_PYTHON_TIMEOUT_SECONDS}), streams bounded stdout/stderr, and spills truncated full output to the process work directory rather than the repository.`,
|
|
105
|
-
promptSnippet: "Run bounded Python
|
|
105
|
+
promptSnippet: "Run bounded Python code/scripts through Pi's uv runtime.",
|
|
106
106
|
promptGuidelines: [
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"
|
|
107
|
+
"Use python for bounded scripts/data transforms/cross-platform logic clearer than shell.",
|
|
108
|
+
"Small exact source edits: read/edit/write. Python transforms: preserve encoding/newlines, write atomically, verify diff.",
|
|
109
|
+
"Scope roots/filters; never scan home/filesystem recursively. Raise timeout only for justified bounded work.",
|
|
110
|
+
"Never inspect/print credentials; use activated environment only through credential consumer.",
|
|
111
|
+
"Explicit approval required: destructive deletion, publish/push/release, long-running services.",
|
|
112
112
|
],
|
|
113
113
|
parameters: pythonSchema,
|
|
114
114
|
async execute(_toolCallId, input, signal) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"python.js","sourceRoot":"","sources":["../../../src/core/tools/python.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,kCAAkC,EAAE,MAAM,8BAA8B,CAAC;AAEhG,OAAO,EAAE,mBAAmB,EAA6B,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,MAAM,C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B;IAC5E,OAAO,kBAAkB,CAAC,0BAA0B,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AACzE,CAAC","sourcesContent":["import { stat } from \"node:fs/promises\";\nimport { posix, win32 } from \"node:path\";\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport type { TruncationResult } from \"@caupulican/pi-agent-core/node\";\nimport { Text } from \"@caupulican/pi-tui\";\nimport { type Static, Type } from \"typebox\";\nimport { spawnProcess, waitForChildProcessWithTermination } from \"../../utils/child-process.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { ensurePythonRuntime, type PythonRuntimeOutcome } from \"../python-runtime.ts\";\nimport { withExclusiveMutationBarrier } from \"./file-mutation-queue.ts\";\nimport { OutputAccumulator } from \"./output-accumulator.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nexport const DEFAULT_PYTHON_TIMEOUT_SECONDS = 30;\nexport const MAX_PYTHON_TIMEOUT_SECONDS = 300;\nexport const MAX_PYTHON_OUTPUT_BYTES = 200_000;\nconst MIN_PYTHON_OUTPUT_BYTES = 1_000;\nconst PYTHON_KILL_GRACE_MS = 2_000;\n\nconst pythonSchema = Type.Object(\n\t{\n\t\tcode: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Python code to execute on stdin. Provide exactly one of code or scriptPath.\",\n\t\t\t\tmaxLength: 200_000,\n\t\t\t}),\n\t\t),\n\t\tscriptPath: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Python script path. Relative paths resolve from cwd; one leading @ is ignored.\",\n\t\t\t\tmaxLength: 32_768,\n\t\t\t}),\n\t\t),\n\t\targs: Type.Optional(\n\t\t\tType.Array(Type.String({ maxLength: 16_384 }), {\n\t\t\t\tdescription: \"Arguments passed directly to Python after '-' or scriptPath; no shell interpolation.\",\n\t\t\t\tmaxItems: 256,\n\t\t\t}),\n\t\t),\n\t\tcwd: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Working directory. Defaults to Pi's cwd; relative paths resolve from Pi's cwd.\",\n\t\t\t\tmaxLength: 32_768,\n\t\t\t}),\n\t\t),\n\t\ttimeoutSeconds: Type.Optional(\n\t\t\tType.Number({\n\t\t\t\tdescription: `Wall-clock timeout. Defaults to ${DEFAULT_PYTHON_TIMEOUT_SECONDS} seconds and is capped at ${MAX_PYTHON_TIMEOUT_SECONDS}.`,\n\t\t\t}),\n\t\t),\n\t\tmaxOutputBytes: Type.Optional(\n\t\t\tType.Number({\n\t\t\t\tdescription: `Maximum returned bytes per stream before full output spills to a work artifact. Maximum ${MAX_PYTHON_OUTPUT_BYTES}.`,\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type PythonToolInput = Static<typeof pythonSchema>;\n\nexport interface PythonToolDetails {\n\tmode: \"code\" | \"script\";\n\tcwd: string;\n\tuvPath: string;\n\tpythonPath: string;\n\tscriptPath?: string;\n\targs: string[];\n\texitCode: number | null;\n\tsignal: string | null;\n\ttimedOut: boolean;\n\tstdoutTruncation?: TruncationResult;\n\tstderrTruncation?: TruncationResult;\n\tstdoutOutputPath?: string;\n\tstderrOutputPath?: string;\n\tstdoutOutputError?: string;\n\tstderrOutputError?: string;\n}\n\nexport interface PythonExecutionRequest {\n\tpython: string;\n\targs: string[];\n\tcwd: string;\n\tstdin?: string;\n\ttimeoutMs: number;\n\tsignal?: AbortSignal;\n\tenv: NodeJS.ProcessEnv;\n\tonStdout: (chunk: Buffer) => void;\n\tonStderr: (chunk: Buffer) => void;\n}\n\nexport interface PythonExecutionResult {\n\texitCode: number | null;\n\treason: \"exited\" | \"aborted\" | \"timeout\";\n\tsignal: string | null;\n}\n\nexport interface PythonOperations {\n\texec(request: PythonExecutionRequest): Promise<PythonExecutionResult>;\n}\n\nexport interface PythonToolOptions {\n\tresolveRuntime?: () => Promise<PythonRuntimeOutcome>;\n\toperations?: PythonOperations;\n\t/** Additional process environment resolved from the final execution cwd. */\n\tenvironment?: (cwd: string) => NodeJS.ProcessEnv;\n\t/** Owner-only variables that must never reach model-controlled Python. */\n\tomitEnvironmentVariables?: readonly string[];\n\t/** Override only for tests or embedded runtimes; production uses the process work directory. */\n\toutputDirectory?: string;\n}\n\nfunction stripAtPrefix(value: string): string {\n\treturn value.startsWith(\"@\") ? value.slice(1) : value;\n}\n\nexport function resolvePythonToolPath(\n\tbase: string,\n\trequested: string,\n\tplatform: NodeJS.Platform = process.platform,\n): string {\n\treturn (platform === \"win32\" ? win32 : posix).resolve(base, stripAtPrefix(requested));\n}\n\nasync function resolveWorkingDirectory(baseCwd: string, requested?: string): Promise<string> {\n\tconst cwd = requested ? resolvePythonToolPath(baseCwd, requested) : baseCwd;\n\tconst entry = await stat(cwd).catch(() => {\n\t\tthrow new Error(`cwd does not exist: ${cwd}`);\n\t});\n\tif (!entry.isDirectory()) throw new Error(`cwd is not a directory: ${cwd}`);\n\treturn cwd;\n}\n\nasync function resolveScriptPath(cwd: string, requested: string): Promise<string> {\n\tconst scriptPath = resolvePythonToolPath(cwd, requested);\n\tconst entry = await stat(scriptPath).catch(() => {\n\t\tthrow new Error(`scriptPath does not exist: ${scriptPath}`);\n\t});\n\tif (!entry.isFile()) throw new Error(`scriptPath is not a file: ${scriptPath}`);\n\treturn scriptPath;\n}\n\nfunction clampInteger(value: number | undefined, fallback: number, minimum: number, maximum: number): number {\n\tif (typeof value !== \"number\" || !Number.isFinite(value) || value <= 0) return fallback;\n\treturn Math.max(minimum, Math.min(maximum, Math.trunc(value)));\n}\n\nfunction createLocalPythonOperations(): PythonOperations {\n\treturn {\n\t\tasync exec(request) {\n\t\t\tif (request.signal?.aborted) throw new Error(\"Python execution aborted before start\");\n\t\t\tconst child = spawnProcess(request.python, request.args, {\n\t\t\t\tcwd: request.cwd,\n\t\t\t\tdetached: process.platform !== \"win32\",\n\t\t\t\tenv: request.env,\n\t\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t\t});\n\t\t\tchild.stdout?.on(\"data\", (chunk: Buffer) => request.onStdout(chunk));\n\t\t\tchild.stderr?.on(\"data\", (chunk: Buffer) => request.onStderr(chunk));\n\t\t\tchild.stdin?.end(request.stdin ?? \"\");\n\t\t\tconst terminal = await waitForChildProcessWithTermination(child, {\n\t\t\t\tkillGraceMs: PYTHON_KILL_GRACE_MS,\n\t\t\t\tsignal: request.signal,\n\t\t\t\ttimeoutMs: request.timeoutMs,\n\t\t\t});\n\t\t\treturn { exitCode: terminal.code, reason: terminal.reason, signal: child.signalCode };\n\t\t},\n\t};\n}\n\nfunction renderStreamNotice(label: string, path: string | undefined, error: string | undefined): string | undefined {\n\tif (path) return `[${label} truncated; full output: ${path}]`;\n\tif (error) return `[${label} truncated; full-output artifact failed: ${error}]`;\n\treturn undefined;\n}\n\nexport function createPythonToolDefinition(\n\tbaseCwd: string,\n\toptions: PythonToolOptions = {},\n): ToolDefinition<typeof pythonSchema, PythonToolDetails> {\n\tconst resolveRuntime = options.resolveRuntime ?? (() => ensurePythonRuntime({ silent: true }));\n\tconst operations = options.operations ?? createLocalPythonOperations();\n\treturn {\n\t\tname: \"python\",\n\t\tlabel: \"python\",\n\t\tdescription: `Run a bounded Python snippet or script without a shell. Pi resolves Python through uv, defaults to a ${DEFAULT_PYTHON_TIMEOUT_SECONDS}-second wall-clock timeout (maximum ${MAX_PYTHON_TIMEOUT_SECONDS}), streams bounded stdout/stderr, and spills truncated full output to the process work directory rather than the repository.`,\n\t\tpromptSnippet: \"Run bounded Python snippets or scripts through Pi's uv-managed runtime.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Prefer python for bounded scripts, data shaping, structured transformations, and cross-platform logic when it is clearer than a shell pipeline.\",\n\t\t\t\"Prefer read/edit/write for small exact source edits. For Python file transformations, preserve encoding and newline style, write atomically, and verify the resulting diff.\",\n\t\t\t\"Keep work scoped: avoid recursive home/filesystem scans, pass explicit roots and filters, and request a larger timeout only when the bounded workload justifies it.\",\n\t\t\t\"Do not inspect or print credentials. When secret_store activates a bound profile, use its injected environment only through the credential-consuming program.\",\n\t\t\t\"Do not use python for destructive deletion, publish/push/release, or long-running services without explicit user approval.\",\n\t\t],\n\t\tparameters: pythonSchema,\n\t\tasync execute(_toolCallId, input, signal) {\n\t\t\tconst hasCode = typeof input.code === \"string\";\n\t\t\tconst hasScript = typeof input.scriptPath === \"string\" && input.scriptPath.trim().length > 0;\n\t\t\tif (hasCode === hasScript) throw new Error(\"Provide exactly one of code or scriptPath.\");\n\t\t\tconst cwd = await resolveWorkingDirectory(baseCwd, input.cwd);\n\t\t\tconst scriptPath = hasScript ? await resolveScriptPath(cwd, input.scriptPath as string) : undefined;\n\t\t\tconst runtime = await resolveRuntime();\n\t\t\tif (runtime.status !== \"ready\") throw new Error(runtime.reason);\n\t\t\tconst args = input.args ? [...input.args] : [];\n\t\t\tconst timeoutSeconds = clampInteger(\n\t\t\t\tinput.timeoutSeconds,\n\t\t\t\tDEFAULT_PYTHON_TIMEOUT_SECONDS,\n\t\t\t\t1,\n\t\t\t\tMAX_PYTHON_TIMEOUT_SECONDS,\n\t\t\t);\n\t\t\tconst maxOutputBytes = clampInteger(\n\t\t\t\tinput.maxOutputBytes,\n\t\t\t\t50 * 1024,\n\t\t\t\tMIN_PYTHON_OUTPUT_BYTES,\n\t\t\t\tMAX_PYTHON_OUTPUT_BYTES,\n\t\t\t);\n\t\t\tconst accumulatorOptions = {\n\t\t\t\tmaxBytes: maxOutputBytes,\n\t\t\t\t...(options.outputDirectory ? { tempDirectory: options.outputDirectory } : {}),\n\t\t\t};\n\t\t\tconst stdout = new OutputAccumulator({ ...accumulatorOptions, tempFilePrefix: \"pi-python-stdout\" });\n\t\t\tconst stderr = new OutputAccumulator({ ...accumulatorOptions, tempFilePrefix: \"pi-python-stderr\" });\n\t\t\tconst finishStreams = () => {\n\t\t\t\tstdout.finish();\n\t\t\t\tstderr.finish();\n\t\t\t\treturn {\n\t\t\t\t\tstdout: stdout.snapshot({ persistIfTruncated: true }),\n\t\t\t\t\tstderr: stderr.snapshot({ persistIfTruncated: true }),\n\t\t\t\t};\n\t\t\t};\n\t\t\tlet execution: PythonExecutionResult;\n\t\t\ttry {\n\t\t\t\texecution = await withExclusiveMutationBarrier(() => {\n\t\t\t\t\tconst environment: NodeJS.ProcessEnv = {\n\t\t\t\t\t\t...process.env,\n\t\t\t\t\t\t...options.environment?.(cwd),\n\t\t\t\t\t\tPI_PYTHON_TOOL: \"1\",\n\t\t\t\t\t\tPYTHONDONTWRITEBYTECODE: \"1\",\n\t\t\t\t\t\tPYTHONIOENCODING: \"utf-8\",\n\t\t\t\t\t\tPYTHONUNBUFFERED: \"1\",\n\t\t\t\t\t\tPYTHONUTF8: \"1\",\n\t\t\t\t\t};\n\t\t\t\t\tfor (const name of options.omitEnvironmentVariables ?? []) delete environment[name];\n\t\t\t\t\treturn operations.exec({\n\t\t\t\t\t\tpython: runtime.pythonPath,\n\t\t\t\t\t\targs: scriptPath ? [\"-B\", scriptPath, ...args] : [\"-B\", \"-\", ...args],\n\t\t\t\t\t\tcwd,\n\t\t\t\t\t\tstdin: hasCode ? input.code : undefined,\n\t\t\t\t\t\ttimeoutMs: timeoutSeconds * 1000,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\tenv: environment,\n\t\t\t\t\t\tonStdout: (chunk) => stdout.append(chunk),\n\t\t\t\t\t\tonStderr: (chunk) => stderr.append(chunk),\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\tconst snapshots = finishStreams();\n\t\t\t\tconst sections: string[] = [];\n\t\t\t\tif (snapshots.stdout.content) sections.push(snapshots.stdout.content.trimEnd());\n\t\t\t\tif (snapshots.stderr.content) sections.push(`[stderr]\\n${snapshots.stderr.content.trimEnd()}`);\n\t\t\t\tconst stdoutNotice = renderStreamNotice(\n\t\t\t\t\t\"stdout\",\n\t\t\t\t\tsnapshots.stdout.fullOutputPath,\n\t\t\t\t\tsnapshots.stdout.fullOutputError,\n\t\t\t\t);\n\t\t\t\tconst stderrNotice = renderStreamNotice(\n\t\t\t\t\t\"stderr\",\n\t\t\t\t\tsnapshots.stderr.fullOutputPath,\n\t\t\t\t\tsnapshots.stderr.fullOutputError,\n\t\t\t\t);\n\t\t\t\tif (stdoutNotice) sections.push(stdoutNotice);\n\t\t\t\tif (stderrNotice) sections.push(stderrNotice);\n\t\t\t\tconst status = `[python exitCode=${execution.exitCode ?? \"null\"}${execution.signal ? `; signal=${execution.signal}` : \"\"}]`;\n\t\t\t\tsections.push(status);\n\t\t\t\tconst text = sections.join(\"\\n\\n\");\n\t\t\t\tif (execution.reason === \"timeout\")\n\t\t\t\t\tthrow new Error(`${text}\\n\\nPython timed out after ${timeoutSeconds} seconds`);\n\t\t\t\tif (execution.reason === \"aborted\") throw new Error(`${text}\\n\\nPython execution aborted`);\n\t\t\t\tif (execution.exitCode !== 0) {\n\t\t\t\t\tconst termination = execution.signal\n\t\t\t\t\t\t? `signal ${execution.signal}`\n\t\t\t\t\t\t: `code ${execution.exitCode ?? \"unknown\"}`;\n\t\t\t\t\tthrow new Error(`${text}\\n\\nPython exited with ${termination}`);\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text }],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tmode: scriptPath ? \"script\" : \"code\",\n\t\t\t\t\t\tcwd,\n\t\t\t\t\t\tuvPath: runtime.uvPath,\n\t\t\t\t\t\tpythonPath: runtime.pythonPath,\n\t\t\t\t\t\tscriptPath,\n\t\t\t\t\t\targs,\n\t\t\t\t\t\texitCode: execution.exitCode,\n\t\t\t\t\t\tsignal: execution.signal,\n\t\t\t\t\t\ttimedOut: false,\n\t\t\t\t\t\t...(snapshots.stdout.truncation.truncated ? { stdoutTruncation: snapshots.stdout.truncation } : {}),\n\t\t\t\t\t\t...(snapshots.stderr.truncation.truncated ? { stderrTruncation: snapshots.stderr.truncation } : {}),\n\t\t\t\t\t\tstdoutOutputPath: snapshots.stdout.fullOutputPath,\n\t\t\t\t\t\tstderrOutputPath: snapshots.stderr.fullOutputPath,\n\t\t\t\t\t\tstdoutOutputError: snapshots.stdout.fullOutputError,\n\t\t\t\t\t\tstderrOutputError: snapshots.stderr.fullOutputError,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} finally {\n\t\t\t\tawait Promise.all([stdout.closeTempFile(), stderr.closeTempFile()]);\n\t\t\t}\n\t\t},\n\t\trenderCall(args, theme) {\n\t\t\tconst mode = args.scriptPath ? args.scriptPath : \"code\";\n\t\t\treturn new Text(`${theme.fg(\"toolTitle\", theme.bold(\"python\"))} ${theme.fg(\"muted\", mode)}`, 0, 0);\n\t\t},\n\t\trenderResult(result, { expanded, isPartial }, theme) {\n\t\t\tif (isPartial) return new Text(theme.fg(\"warning\", \"python running\"), 0, 0);\n\t\t\tconst details = result.details as PythonToolDetails | undefined;\n\t\t\tif (!details) return new Text(theme.fg(\"dim\", \"python done\"), 0, 0);\n\t\t\tconst status =\n\t\t\t\tdetails.exitCode === 0 && !details.timedOut ? \"python ok\" : `python exit ${details.exitCode ?? \"unknown\"}`;\n\t\t\tlet text = theme.fg(details.exitCode === 0 ? \"success\" : \"warning\", status);\n\t\t\tif (expanded) {\n\t\t\t\tconst content = result.content[0];\n\t\t\t\tif (content?.type === \"text\") {\n\t\t\t\t\tconst lines = content.text.split(\"\\n\").slice(-20);\n\t\t\t\t\tfor (const line of lines) text += `\\n${theme.fg(\"dim\", line)}`;\n\t\t\t\t}\n\t\t\t\tfor (const outputPath of [details.stdoutOutputPath, details.stderrOutputPath]) {\n\t\t\t\t\tif (outputPath) text += `\\n${theme.fg(\"muted\", `full output: ${outputPath}`)}`;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn new Text(text, 0, 0);\n\t\t},\n\t};\n}\n\nexport function createPythonTool(baseCwd: string, options?: PythonToolOptions): AgentTool<typeof pythonSchema> {\n\treturn wrapToolDefinition(createPythonToolDefinition(baseCwd, options));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"python.js","sourceRoot":"","sources":["../../../src/core/tools/python.ts"],"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IAAI,IAAI,KAAK;wBAAE,IAAI,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC;gBAChE,CAAC;gBACD,KAAK,MAAM,UAAU,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC;oBAC/E,IAAI,UAAU;wBAAE,IAAI,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,UAAU,EAAE,CAAC,EAAE,CAAC;gBAChF,CAAC;YACF,CAAC;YACD,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7B,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAe,EAAE,OAA2B;IAC5E,OAAO,kBAAkB,CAAC,0BAA0B,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AACzE,CAAC","sourcesContent":["import { stat } from \"node:fs/promises\";\nimport { posix, win32 } from \"node:path\";\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport type { TruncationResult } from \"@caupulican/pi-agent-core/node\";\nimport { Text } from \"@caupulican/pi-tui\";\nimport { type Static, Type } from \"typebox\";\nimport { spawnProcess, waitForChildProcessWithTermination } from \"../../utils/child-process.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { ensurePythonRuntime, type PythonRuntimeOutcome } from \"../python-runtime.ts\";\nimport { withExclusiveMutationBarrier } from \"./file-mutation-queue.ts\";\nimport { OutputAccumulator } from \"./output-accumulator.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nexport const DEFAULT_PYTHON_TIMEOUT_SECONDS = 30;\nexport const MAX_PYTHON_TIMEOUT_SECONDS = 300;\nexport const MAX_PYTHON_OUTPUT_BYTES = 200_000;\nconst MIN_PYTHON_OUTPUT_BYTES = 1_000;\nconst PYTHON_KILL_GRACE_MS = 2_000;\n\nconst pythonSchema = Type.Object(\n\t{\n\t\tcode: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Python code to execute on stdin. Provide exactly one of code or scriptPath.\",\n\t\t\t\tmaxLength: 200_000,\n\t\t\t}),\n\t\t),\n\t\tscriptPath: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Python script path. Relative paths resolve from cwd; one leading @ is ignored.\",\n\t\t\t\tmaxLength: 32_768,\n\t\t\t}),\n\t\t),\n\t\targs: Type.Optional(\n\t\t\tType.Array(Type.String({ maxLength: 16_384 }), {\n\t\t\t\tdescription: \"Arguments passed directly to Python after '-' or scriptPath; no shell interpolation.\",\n\t\t\t\tmaxItems: 256,\n\t\t\t}),\n\t\t),\n\t\tcwd: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Working directory. Defaults to Pi's cwd; relative paths resolve from Pi's cwd.\",\n\t\t\t\tmaxLength: 32_768,\n\t\t\t}),\n\t\t),\n\t\ttimeoutSeconds: Type.Optional(\n\t\t\tType.Number({\n\t\t\t\tdescription: `Wall-clock timeout. Defaults to ${DEFAULT_PYTHON_TIMEOUT_SECONDS} seconds and is capped at ${MAX_PYTHON_TIMEOUT_SECONDS}.`,\n\t\t\t}),\n\t\t),\n\t\tmaxOutputBytes: Type.Optional(\n\t\t\tType.Number({\n\t\t\t\tdescription: `Maximum returned bytes per stream before full output spills to a work artifact. Maximum ${MAX_PYTHON_OUTPUT_BYTES}.`,\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type PythonToolInput = Static<typeof pythonSchema>;\n\nexport interface PythonToolDetails {\n\tmode: \"code\" | \"script\";\n\tcwd: string;\n\tuvPath: string;\n\tpythonPath: string;\n\tscriptPath?: string;\n\targs: string[];\n\texitCode: number | null;\n\tsignal: string | null;\n\ttimedOut: boolean;\n\tstdoutTruncation?: TruncationResult;\n\tstderrTruncation?: TruncationResult;\n\tstdoutOutputPath?: string;\n\tstderrOutputPath?: string;\n\tstdoutOutputError?: string;\n\tstderrOutputError?: string;\n}\n\nexport interface PythonExecutionRequest {\n\tpython: string;\n\targs: string[];\n\tcwd: string;\n\tstdin?: string;\n\ttimeoutMs: number;\n\tsignal?: AbortSignal;\n\tenv: NodeJS.ProcessEnv;\n\tonStdout: (chunk: Buffer) => void;\n\tonStderr: (chunk: Buffer) => void;\n}\n\nexport interface PythonExecutionResult {\n\texitCode: number | null;\n\treason: \"exited\" | \"aborted\" | \"timeout\";\n\tsignal: string | null;\n}\n\nexport interface PythonOperations {\n\texec(request: PythonExecutionRequest): Promise<PythonExecutionResult>;\n}\n\nexport interface PythonToolOptions {\n\tresolveRuntime?: () => Promise<PythonRuntimeOutcome>;\n\toperations?: PythonOperations;\n\t/** Additional process environment resolved from the final execution cwd. */\n\tenvironment?: (cwd: string) => NodeJS.ProcessEnv;\n\t/** Owner-only variables that must never reach model-controlled Python. */\n\tomitEnvironmentVariables?: readonly string[];\n\t/** Override only for tests or embedded runtimes; production uses the process work directory. */\n\toutputDirectory?: string;\n}\n\nfunction stripAtPrefix(value: string): string {\n\treturn value.startsWith(\"@\") ? value.slice(1) : value;\n}\n\nexport function resolvePythonToolPath(\n\tbase: string,\n\trequested: string,\n\tplatform: NodeJS.Platform = process.platform,\n): string {\n\treturn (platform === \"win32\" ? win32 : posix).resolve(base, stripAtPrefix(requested));\n}\n\nasync function resolveWorkingDirectory(baseCwd: string, requested?: string): Promise<string> {\n\tconst cwd = requested ? resolvePythonToolPath(baseCwd, requested) : baseCwd;\n\tconst entry = await stat(cwd).catch(() => {\n\t\tthrow new Error(`cwd does not exist: ${cwd}`);\n\t});\n\tif (!entry.isDirectory()) throw new Error(`cwd is not a directory: ${cwd}`);\n\treturn cwd;\n}\n\nasync function resolveScriptPath(cwd: string, requested: string): Promise<string> {\n\tconst scriptPath = resolvePythonToolPath(cwd, requested);\n\tconst entry = await stat(scriptPath).catch(() => {\n\t\tthrow new Error(`scriptPath does not exist: ${scriptPath}`);\n\t});\n\tif (!entry.isFile()) throw new Error(`scriptPath is not a file: ${scriptPath}`);\n\treturn scriptPath;\n}\n\nfunction clampInteger(value: number | undefined, fallback: number, minimum: number, maximum: number): number {\n\tif (typeof value !== \"number\" || !Number.isFinite(value) || value <= 0) return fallback;\n\treturn Math.max(minimum, Math.min(maximum, Math.trunc(value)));\n}\n\nfunction createLocalPythonOperations(): PythonOperations {\n\treturn {\n\t\tasync exec(request) {\n\t\t\tif (request.signal?.aborted) throw new Error(\"Python execution aborted before start\");\n\t\t\tconst child = spawnProcess(request.python, request.args, {\n\t\t\t\tcwd: request.cwd,\n\t\t\t\tdetached: process.platform !== \"win32\",\n\t\t\t\tenv: request.env,\n\t\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t\t});\n\t\t\tchild.stdout?.on(\"data\", (chunk: Buffer) => request.onStdout(chunk));\n\t\t\tchild.stderr?.on(\"data\", (chunk: Buffer) => request.onStderr(chunk));\n\t\t\tchild.stdin?.end(request.stdin ?? \"\");\n\t\t\tconst terminal = await waitForChildProcessWithTermination(child, {\n\t\t\t\tkillGraceMs: PYTHON_KILL_GRACE_MS,\n\t\t\t\tsignal: request.signal,\n\t\t\t\ttimeoutMs: request.timeoutMs,\n\t\t\t});\n\t\t\treturn { exitCode: terminal.code, reason: terminal.reason, signal: child.signalCode };\n\t\t},\n\t};\n}\n\nfunction renderStreamNotice(label: string, path: string | undefined, error: string | undefined): string | undefined {\n\tif (path) return `[${label} truncated; full output: ${path}]`;\n\tif (error) return `[${label} truncated; full-output artifact failed: ${error}]`;\n\treturn undefined;\n}\n\nexport function createPythonToolDefinition(\n\tbaseCwd: string,\n\toptions: PythonToolOptions = {},\n): ToolDefinition<typeof pythonSchema, PythonToolDetails> {\n\tconst resolveRuntime = options.resolveRuntime ?? (() => ensurePythonRuntime({ silent: true }));\n\tconst operations = options.operations ?? createLocalPythonOperations();\n\treturn {\n\t\tname: \"python\",\n\t\tlabel: \"python\",\n\t\tdescription: `Run a bounded Python snippet or script without a shell. Pi resolves Python through uv, defaults to a ${DEFAULT_PYTHON_TIMEOUT_SECONDS}-second wall-clock timeout (maximum ${MAX_PYTHON_TIMEOUT_SECONDS}), streams bounded stdout/stderr, and spills truncated full output to the process work directory rather than the repository.`,\n\t\tpromptSnippet: \"Run bounded Python code/scripts through Pi's uv runtime.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use python for bounded scripts/data transforms/cross-platform logic clearer than shell.\",\n\t\t\t\"Small exact source edits: read/edit/write. Python transforms: preserve encoding/newlines, write atomically, verify diff.\",\n\t\t\t\"Scope roots/filters; never scan home/filesystem recursively. Raise timeout only for justified bounded work.\",\n\t\t\t\"Never inspect/print credentials; use activated environment only through credential consumer.\",\n\t\t\t\"Explicit approval required: destructive deletion, publish/push/release, long-running services.\",\n\t\t],\n\t\tparameters: pythonSchema,\n\t\tasync execute(_toolCallId, input, signal) {\n\t\t\tconst hasCode = typeof input.code === \"string\";\n\t\t\tconst hasScript = typeof input.scriptPath === \"string\" && input.scriptPath.trim().length > 0;\n\t\t\tif (hasCode === hasScript) throw new Error(\"Provide exactly one of code or scriptPath.\");\n\t\t\tconst cwd = await resolveWorkingDirectory(baseCwd, input.cwd);\n\t\t\tconst scriptPath = hasScript ? await resolveScriptPath(cwd, input.scriptPath as string) : undefined;\n\t\t\tconst runtime = await resolveRuntime();\n\t\t\tif (runtime.status !== \"ready\") throw new Error(runtime.reason);\n\t\t\tconst args = input.args ? [...input.args] : [];\n\t\t\tconst timeoutSeconds = clampInteger(\n\t\t\t\tinput.timeoutSeconds,\n\t\t\t\tDEFAULT_PYTHON_TIMEOUT_SECONDS,\n\t\t\t\t1,\n\t\t\t\tMAX_PYTHON_TIMEOUT_SECONDS,\n\t\t\t);\n\t\t\tconst maxOutputBytes = clampInteger(\n\t\t\t\tinput.maxOutputBytes,\n\t\t\t\t50 * 1024,\n\t\t\t\tMIN_PYTHON_OUTPUT_BYTES,\n\t\t\t\tMAX_PYTHON_OUTPUT_BYTES,\n\t\t\t);\n\t\t\tconst accumulatorOptions = {\n\t\t\t\tmaxBytes: maxOutputBytes,\n\t\t\t\t...(options.outputDirectory ? { tempDirectory: options.outputDirectory } : {}),\n\t\t\t};\n\t\t\tconst stdout = new OutputAccumulator({ ...accumulatorOptions, tempFilePrefix: \"pi-python-stdout\" });\n\t\t\tconst stderr = new OutputAccumulator({ ...accumulatorOptions, tempFilePrefix: \"pi-python-stderr\" });\n\t\t\tconst finishStreams = () => {\n\t\t\t\tstdout.finish();\n\t\t\t\tstderr.finish();\n\t\t\t\treturn {\n\t\t\t\t\tstdout: stdout.snapshot({ persistIfTruncated: true }),\n\t\t\t\t\tstderr: stderr.snapshot({ persistIfTruncated: true }),\n\t\t\t\t};\n\t\t\t};\n\t\t\tlet execution: PythonExecutionResult;\n\t\t\ttry {\n\t\t\t\texecution = await withExclusiveMutationBarrier(() => {\n\t\t\t\t\tconst environment: NodeJS.ProcessEnv = {\n\t\t\t\t\t\t...process.env,\n\t\t\t\t\t\t...options.environment?.(cwd),\n\t\t\t\t\t\tPI_PYTHON_TOOL: \"1\",\n\t\t\t\t\t\tPYTHONDONTWRITEBYTECODE: \"1\",\n\t\t\t\t\t\tPYTHONIOENCODING: \"utf-8\",\n\t\t\t\t\t\tPYTHONUNBUFFERED: \"1\",\n\t\t\t\t\t\tPYTHONUTF8: \"1\",\n\t\t\t\t\t};\n\t\t\t\t\tfor (const name of options.omitEnvironmentVariables ?? []) delete environment[name];\n\t\t\t\t\treturn operations.exec({\n\t\t\t\t\t\tpython: runtime.pythonPath,\n\t\t\t\t\t\targs: scriptPath ? [\"-B\", scriptPath, ...args] : [\"-B\", \"-\", ...args],\n\t\t\t\t\t\tcwd,\n\t\t\t\t\t\tstdin: hasCode ? input.code : undefined,\n\t\t\t\t\t\ttimeoutMs: timeoutSeconds * 1000,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\tenv: environment,\n\t\t\t\t\t\tonStdout: (chunk) => stdout.append(chunk),\n\t\t\t\t\t\tonStderr: (chunk) => stderr.append(chunk),\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\tconst snapshots = finishStreams();\n\t\t\t\tconst sections: string[] = [];\n\t\t\t\tif (snapshots.stdout.content) sections.push(snapshots.stdout.content.trimEnd());\n\t\t\t\tif (snapshots.stderr.content) sections.push(`[stderr]\\n${snapshots.stderr.content.trimEnd()}`);\n\t\t\t\tconst stdoutNotice = renderStreamNotice(\n\t\t\t\t\t\"stdout\",\n\t\t\t\t\tsnapshots.stdout.fullOutputPath,\n\t\t\t\t\tsnapshots.stdout.fullOutputError,\n\t\t\t\t);\n\t\t\t\tconst stderrNotice = renderStreamNotice(\n\t\t\t\t\t\"stderr\",\n\t\t\t\t\tsnapshots.stderr.fullOutputPath,\n\t\t\t\t\tsnapshots.stderr.fullOutputError,\n\t\t\t\t);\n\t\t\t\tif (stdoutNotice) sections.push(stdoutNotice);\n\t\t\t\tif (stderrNotice) sections.push(stderrNotice);\n\t\t\t\tconst status = `[python exitCode=${execution.exitCode ?? \"null\"}${execution.signal ? `; signal=${execution.signal}` : \"\"}]`;\n\t\t\t\tsections.push(status);\n\t\t\t\tconst text = sections.join(\"\\n\\n\");\n\t\t\t\tif (execution.reason === \"timeout\")\n\t\t\t\t\tthrow new Error(`${text}\\n\\nPython timed out after ${timeoutSeconds} seconds`);\n\t\t\t\tif (execution.reason === \"aborted\") throw new Error(`${text}\\n\\nPython execution aborted`);\n\t\t\t\tif (execution.exitCode !== 0) {\n\t\t\t\t\tconst termination = execution.signal\n\t\t\t\t\t\t? `signal ${execution.signal}`\n\t\t\t\t\t\t: `code ${execution.exitCode ?? \"unknown\"}`;\n\t\t\t\t\tthrow new Error(`${text}\\n\\nPython exited with ${termination}`);\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text }],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tmode: scriptPath ? \"script\" : \"code\",\n\t\t\t\t\t\tcwd,\n\t\t\t\t\t\tuvPath: runtime.uvPath,\n\t\t\t\t\t\tpythonPath: runtime.pythonPath,\n\t\t\t\t\t\tscriptPath,\n\t\t\t\t\t\targs,\n\t\t\t\t\t\texitCode: execution.exitCode,\n\t\t\t\t\t\tsignal: execution.signal,\n\t\t\t\t\t\ttimedOut: false,\n\t\t\t\t\t\t...(snapshots.stdout.truncation.truncated ? { stdoutTruncation: snapshots.stdout.truncation } : {}),\n\t\t\t\t\t\t...(snapshots.stderr.truncation.truncated ? { stderrTruncation: snapshots.stderr.truncation } : {}),\n\t\t\t\t\t\tstdoutOutputPath: snapshots.stdout.fullOutputPath,\n\t\t\t\t\t\tstderrOutputPath: snapshots.stderr.fullOutputPath,\n\t\t\t\t\t\tstdoutOutputError: snapshots.stdout.fullOutputError,\n\t\t\t\t\t\tstderrOutputError: snapshots.stderr.fullOutputError,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} finally {\n\t\t\t\tawait Promise.all([stdout.closeTempFile(), stderr.closeTempFile()]);\n\t\t\t}\n\t\t},\n\t\trenderCall(args, theme) {\n\t\t\tconst mode = args.scriptPath ? args.scriptPath : \"code\";\n\t\t\treturn new Text(`${theme.fg(\"toolTitle\", theme.bold(\"python\"))} ${theme.fg(\"muted\", mode)}`, 0, 0);\n\t\t},\n\t\trenderResult(result, { expanded, isPartial }, theme) {\n\t\t\tif (isPartial) return new Text(theme.fg(\"warning\", \"python running\"), 0, 0);\n\t\t\tconst details = result.details as PythonToolDetails | undefined;\n\t\t\tif (!details) return new Text(theme.fg(\"dim\", \"python done\"), 0, 0);\n\t\t\tconst status =\n\t\t\t\tdetails.exitCode === 0 && !details.timedOut ? \"python ok\" : `python exit ${details.exitCode ?? \"unknown\"}`;\n\t\t\tlet text = theme.fg(details.exitCode === 0 ? \"success\" : \"warning\", status);\n\t\t\tif (expanded) {\n\t\t\t\tconst content = result.content[0];\n\t\t\t\tif (content?.type === \"text\") {\n\t\t\t\t\tconst lines = content.text.split(\"\\n\").slice(-20);\n\t\t\t\t\tfor (const line of lines) text += `\\n${theme.fg(\"dim\", line)}`;\n\t\t\t\t}\n\t\t\t\tfor (const outputPath of [details.stdoutOutputPath, details.stderrOutputPath]) {\n\t\t\t\t\tif (outputPath) text += `\\n${theme.fg(\"muted\", `full output: ${outputPath}`)}`;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn new Text(text, 0, 0);\n\t\t},\n\t};\n}\n\nexport function createPythonTool(baseCwd: string, options?: PythonToolOptions): AgentTool<typeof pythonSchema> {\n\treturn wrapToolDefinition(createPythonToolDefinition(baseCwd, options));\n}\n"]}
|
|
@@ -122,11 +122,11 @@ export function createRunProcessToolDefinition(cwd, options) {
|
|
|
122
122
|
name: "run_process",
|
|
123
123
|
label: "Run Process",
|
|
124
124
|
description: `Run one owner-allowed executable using direct argv without a shell. Allowed executables: ${executableCatalogDescription(options.policy.allowedExecutables)}.`,
|
|
125
|
-
promptSnippet: "Run
|
|
125
|
+
promptSnippet: "Run owner-allowed executable via constrained direct argv; not OS isolation.",
|
|
126
126
|
promptGuidelines: [
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
"
|
|
127
|
+
"Executable must be profile-listed. Arguments literal; no shell operators/interpolation.",
|
|
128
|
+
"Project credentials inject only when execution profile also allows variable names.",
|
|
129
|
+
"Nonzero exit/timeout/abort/output-limit means failure.",
|
|
130
130
|
],
|
|
131
131
|
parameters: runProcessSchema,
|
|
132
132
|
async execute(_toolCallId, input, signal) {
|