operon-agents-core 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +55 -0
- package/README.md +7 -0
- package/dist/agent/agent.d.ts +65 -0
- package/dist/agent/agent.js +39 -0
- package/dist/agent/compose-hooks.d.ts +13 -0
- package/dist/agent/compose-hooks.js +197 -0
- package/dist/agent/concurrency.d.ts +22 -0
- package/dist/agent/concurrency.js +70 -0
- package/dist/agent/context-report.d.ts +60 -0
- package/dist/agent/context-report.js +45 -0
- package/dist/agent/graph.d.ts +48 -0
- package/dist/agent/graph.js +129 -0
- package/dist/agent/guardrail.d.ts +105 -0
- package/dist/agent/guardrail.js +314 -0
- package/dist/agent/handoff-executor.d.ts +21 -0
- package/dist/agent/handoff-executor.js +95 -0
- package/dist/agent/handoff.d.ts +42 -0
- package/dist/agent/handoff.js +70 -0
- package/dist/agent/index.d.ts +25 -0
- package/dist/agent/index.js +19 -0
- package/dist/agent/instruction-context.d.ts +33 -0
- package/dist/agent/instruction-context.js +100 -0
- package/dist/agent/pause.d.ts +12 -0
- package/dist/agent/pause.js +82 -0
- package/dist/agent/profile-builtins.d.ts +8 -0
- package/dist/agent/profile-builtins.js +130 -0
- package/dist/agent/profiles.d.ts +94 -0
- package/dist/agent/profiles.js +264 -0
- package/dist/agent/recovery.d.ts +10 -0
- package/dist/agent/recovery.js +151 -0
- package/dist/agent/run-support.d.ts +79 -0
- package/dist/agent/run-support.js +211 -0
- package/dist/agent/runner.d.ts +246 -0
- package/dist/agent/runner.js +786 -0
- package/dist/agent/session.d.ts +363 -0
- package/dist/agent/session.js +937 -0
- package/dist/agent/subagent-tools.d.ts +18 -0
- package/dist/agent/subagent-tools.js +650 -0
- package/dist/agent/subagent.d.ts +56 -0
- package/dist/agent/subagent.js +50 -0
- package/dist/agent/toolset.d.ts +24 -0
- package/dist/agent/toolset.js +112 -0
- package/dist/agent/workflow/index.d.ts +9 -0
- package/dist/agent/workflow/index.js +8 -0
- package/dist/agent/workflow/journal.d.ts +180 -0
- package/dist/agent/workflow/journal.js +224 -0
- package/dist/agent/workflow/manager.d.ts +27 -0
- package/dist/agent/workflow/manager.js +33 -0
- package/dist/agent/workflow/parse.d.ts +17 -0
- package/dist/agent/workflow/parse.js +174 -0
- package/dist/agent/workflow/prompt.d.ts +8 -0
- package/dist/agent/workflow/prompt.js +84 -0
- package/dist/agent/workflow/runtime.d.ts +64 -0
- package/dist/agent/workflow/runtime.js +380 -0
- package/dist/agent/workflow/sandbox.d.ts +35 -0
- package/dist/agent/workflow/sandbox.js +90 -0
- package/dist/agent/workflow/snapshot.d.ts +36 -0
- package/dist/agent/workflow/snapshot.js +9 -0
- package/dist/agent/workflow/structured.d.ts +35 -0
- package/dist/agent/workflow/structured.js +79 -0
- package/dist/agent/workflow/tool.d.ts +14 -0
- package/dist/agent/workflow/tool.js +569 -0
- package/dist/agent/workflow/types.d.ts +100 -0
- package/dist/agent/workflow/types.js +17 -0
- package/dist/agent/worktree.d.ts +38 -0
- package/dist/agent/worktree.js +56 -0
- package/dist/capabilities/assembler.d.ts +39 -0
- package/dist/capabilities/assembler.js +171 -0
- package/dist/capabilities/background/agent-task.d.ts +51 -0
- package/dist/capabilities/background/agent-task.js +101 -0
- package/dist/capabilities/background/command-task.d.ts +43 -0
- package/dist/capabilities/background/command-task.js +86 -0
- package/dist/capabilities/background/index.d.ts +20 -0
- package/dist/capabilities/background/index.js +57 -0
- package/dist/capabilities/background/manager.d.ts +194 -0
- package/dist/capabilities/background/manager.js +1131 -0
- package/dist/capabilities/background/persist-disk.d.ts +17 -0
- package/dist/capabilities/background/persist-disk.js +66 -0
- package/dist/capabilities/background/persist.d.ts +61 -0
- package/dist/capabilities/background/persist.js +117 -0
- package/dist/capabilities/background/question-task.d.ts +32 -0
- package/dist/capabilities/background/question-task.js +56 -0
- package/dist/capabilities/background/registrar.d.ts +12 -0
- package/dist/capabilities/background/registrar.js +9 -0
- package/dist/capabilities/background/swappable-sink.d.ts +20 -0
- package/dist/capabilities/background/swappable-sink.js +20 -0
- package/dist/capabilities/background/task.d.ts +114 -0
- package/dist/capabilities/background/task.js +20 -0
- package/dist/capabilities/background/tools.d.ts +6 -0
- package/dist/capabilities/background/tools.js +190 -0
- package/dist/capabilities/background/workflow-task.d.ts +48 -0
- package/dist/capabilities/background/workflow-task.js +91 -0
- package/dist/capabilities/capability-state.d.ts +13 -0
- package/dist/capabilities/capability-state.js +37 -0
- package/dist/capabilities/capability.d.ts +145 -0
- package/dist/capabilities/capability.js +2 -0
- package/dist/capabilities/compaction/full.d.ts +27 -0
- package/dist/capabilities/compaction/full.js +155 -0
- package/dist/capabilities/compaction/index.d.ts +17 -0
- package/dist/capabilities/compaction/index.js +145 -0
- package/dist/capabilities/compaction/instruction.d.ts +2 -0
- package/dist/capabilities/compaction/instruction.js +31 -0
- package/dist/capabilities/compaction/micro.d.ts +17 -0
- package/dist/capabilities/compaction/micro.js +57 -0
- package/dist/capabilities/compaction/service.d.ts +28 -0
- package/dist/capabilities/compaction/service.js +52 -0
- package/dist/capabilities/compaction/strategy.d.ts +43 -0
- package/dist/capabilities/compaction/strategy.js +116 -0
- package/dist/capabilities/compaction/tokens.d.ts +5 -0
- package/dist/capabilities/compaction/tokens.js +28 -0
- package/dist/capabilities/goal/goal-store.d.ts +69 -0
- package/dist/capabilities/goal/goal-store.js +172 -0
- package/dist/capabilities/goal/index.d.ts +6 -0
- package/dist/capabilities/goal/index.js +31 -0
- package/dist/capabilities/goal/injector.d.ts +9 -0
- package/dist/capabilities/goal/injector.js +79 -0
- package/dist/capabilities/goal/tools.d.ts +6 -0
- package/dist/capabilities/goal/tools.js +86 -0
- package/dist/capabilities/index.d.ts +25 -0
- package/dist/capabilities/index.js +22 -0
- package/dist/capabilities/injection.d.ts +44 -0
- package/dist/capabilities/injection.js +112 -0
- package/dist/capabilities/plan/index.d.ts +6 -0
- package/dist/capabilities/plan/index.js +25 -0
- package/dist/capabilities/plan/injector.d.ts +13 -0
- package/dist/capabilities/plan/injector.js +83 -0
- package/dist/capabilities/plan/plan-mode.d.ts +38 -0
- package/dist/capabilities/plan/plan-mode.js +113 -0
- package/dist/capabilities/plan/policies.d.ts +6 -0
- package/dist/capabilities/plan/policies.js +89 -0
- package/dist/capabilities/plan/tools.d.ts +15 -0
- package/dist/capabilities/plan/tools.js +87 -0
- package/dist/capabilities/skills/flow-provider.d.ts +6 -0
- package/dist/capabilities/skills/flow-provider.js +50 -0
- package/dist/capabilities/skills/index.d.ts +43 -0
- package/dist/capabilities/skills/index.js +48 -0
- package/dist/capabilities/skills/injector.d.ts +11 -0
- package/dist/capabilities/skills/injector.js +27 -0
- package/dist/capabilities/skills/parser.d.ts +36 -0
- package/dist/capabilities/skills/parser.js +334 -0
- package/dist/capabilities/skills/registry.d.ts +33 -0
- package/dist/capabilities/skills/registry.js +118 -0
- package/dist/capabilities/skills/scanner.d.ts +26 -0
- package/dist/capabilities/skills/scanner.js +154 -0
- package/dist/capabilities/skills/service.d.ts +39 -0
- package/dist/capabilities/skills/service.js +68 -0
- package/dist/capabilities/skills/skill-tool.d.ts +13 -0
- package/dist/capabilities/skills/skill-tool.js +72 -0
- package/dist/capabilities/skills/types.d.ts +62 -0
- package/dist/capabilities/skills/types.js +26 -0
- package/dist/capabilities/task/index.d.ts +23 -0
- package/dist/capabilities/task/index.js +38 -0
- package/dist/capabilities/task/injector.d.ts +9 -0
- package/dist/capabilities/task/injector.js +62 -0
- package/dist/capabilities/task/persist-disk.d.ts +19 -0
- package/dist/capabilities/task/persist-disk.js +84 -0
- package/dist/capabilities/task/persist.d.ts +52 -0
- package/dist/capabilities/task/persist.js +84 -0
- package/dist/capabilities/task/task-store.d.ts +44 -0
- package/dist/capabilities/task/task-store.js +106 -0
- package/dist/capabilities/task/tools.d.ts +12 -0
- package/dist/capabilities/task/tools.js +164 -0
- package/dist/capabilities/todo/index.d.ts +8 -0
- package/dist/capabilities/todo/index.js +21 -0
- package/dist/capabilities/todo/injector.d.ts +9 -0
- package/dist/capabilities/todo/injector.js +68 -0
- package/dist/capabilities/todo/todo-store.d.ts +19 -0
- package/dist/capabilities/todo/todo-store.js +36 -0
- package/dist/capabilities/todo/tools.d.ts +6 -0
- package/dist/capabilities/todo/tools.js +70 -0
- package/dist/capabilities/tool-provider.d.ts +12 -0
- package/dist/capabilities/tool-provider.js +20 -0
- package/dist/capabilities/user-hooks/engine.d.ts +22 -0
- package/dist/capabilities/user-hooks/engine.js +105 -0
- package/dist/capabilities/user-hooks/index.d.ts +13 -0
- package/dist/capabilities/user-hooks/index.js +126 -0
- package/dist/capabilities/user-hooks/types.d.ts +26 -0
- package/dist/capabilities/user-hooks/types.js +19 -0
- package/dist/capabilities/workflow/index.d.ts +16 -0
- package/dist/capabilities/workflow/index.js +15 -0
- package/dist/commands/index.d.ts +31 -0
- package/dist/commands/index.js +318 -0
- package/dist/config/config-store.d.ts +29 -0
- package/dist/config/config-store.js +103 -0
- package/dist/config/file-source.d.ts +40 -0
- package/dist/config/file-source.js +78 -0
- package/dist/config/flags.d.ts +13 -0
- package/dist/config/flags.js +25 -0
- package/dist/config/index.d.ts +17 -0
- package/dist/config/index.js +10 -0
- package/dist/config/merge.d.ts +5 -0
- package/dist/config/merge.js +57 -0
- package/dist/config/model-catalog.d.ts +17 -0
- package/dist/config/model-catalog.js +37 -0
- package/dist/config/paths.d.ts +31 -0
- package/dist/config/paths.js +28 -0
- package/dist/config/provider-manager.d.ts +57 -0
- package/dist/config/provider-manager.js +344 -0
- package/dist/config/resolver.d.ts +40 -0
- package/dist/config/resolver.js +52 -0
- package/dist/config/schema.d.ts +389 -0
- package/dist/config/schema.js +132 -0
- package/dist/events/events.d.ts +348 -0
- package/dist/events/events.js +146 -0
- package/dist/events/index.d.ts +10 -0
- package/dist/events/index.js +5 -0
- package/dist/events/projection.d.ts +207 -0
- package/dist/events/projection.js +438 -0
- package/dist/events/publisher.d.ts +48 -0
- package/dist/events/publisher.js +404 -0
- package/dist/events/redacting-sink.d.ts +11 -0
- package/dist/events/redacting-sink.js +31 -0
- package/dist/home.d.ts +16 -0
- package/dist/home.js +20 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +22 -0
- package/dist/internal.d.ts +33 -0
- package/dist/internal.js +29 -0
- package/dist/llm/auth.d.ts +22 -0
- package/dist/llm/auth.js +112 -0
- package/dist/llm/capability.d.ts +13 -0
- package/dist/llm/capability.js +45 -0
- package/dist/llm/define-model.d.ts +110 -0
- package/dist/llm/define-model.js +252 -0
- package/dist/llm/errors.d.ts +33 -0
- package/dist/llm/errors.js +154 -0
- package/dist/llm/index.d.ts +14 -0
- package/dist/llm/index.js +8 -0
- package/dist/llm/model.d.ts +43 -0
- package/dist/llm/model.js +9 -0
- package/dist/llm/retry.d.ts +35 -0
- package/dist/llm/retry.js +160 -0
- package/dist/llm/runtime.d.ts +25 -0
- package/dist/llm/runtime.js +38 -0
- package/dist/logging/diagnostics.d.ts +21 -0
- package/dist/logging/diagnostics.js +46 -0
- package/dist/logging/index.d.ts +11 -0
- package/dist/logging/index.js +7 -0
- package/dist/logging/logger.d.ts +25 -0
- package/dist/logging/logger.js +54 -0
- package/dist/logging/paths.d.ts +11 -0
- package/dist/logging/paths.js +20 -0
- package/dist/logging/policy.d.ts +5 -0
- package/dist/logging/policy.js +19 -0
- package/dist/logging/redact.d.ts +10 -0
- package/dist/logging/redact.js +95 -0
- package/dist/logging/sinks.d.ts +67 -0
- package/dist/logging/sinks.js +117 -0
- package/dist/loop/context.d.ts +69 -0
- package/dist/loop/context.js +129 -0
- package/dist/loop/errors.d.ts +8 -0
- package/dist/loop/errors.js +27 -0
- package/dist/loop/events.d.ts +14 -0
- package/dist/loop/events.js +2 -0
- package/dist/loop/index.d.ts +10 -0
- package/dist/loop/index.js +7 -0
- package/dist/loop/interruption.d.ts +118 -0
- package/dist/loop/interruption.js +191 -0
- package/dist/loop/run-turn.d.ts +54 -0
- package/dist/loop/run-turn.js +203 -0
- package/dist/loop/scheduler.d.ts +18 -0
- package/dist/loop/scheduler.js +71 -0
- package/dist/loop/steer.d.ts +122 -0
- package/dist/loop/steer.js +209 -0
- package/dist/loop/tool-call.d.ts +41 -0
- package/dist/loop/tool-call.js +326 -0
- package/dist/loop/turn-step.d.ts +57 -0
- package/dist/loop/turn-step.js +298 -0
- package/dist/loop/types.d.ts +217 -0
- package/dist/loop/types.js +2 -0
- package/dist/loop/usage.d.ts +6 -0
- package/dist/loop/usage.js +44 -0
- package/dist/mcp/auth-tool.d.ts +12 -0
- package/dist/mcp/auth-tool.js +92 -0
- package/dist/mcp/capability.d.ts +7 -0
- package/dist/mcp/capability.js +91 -0
- package/dist/mcp/config-loader.d.ts +28 -0
- package/dist/mcp/config-loader.js +115 -0
- package/dist/mcp/filter.d.ts +18 -0
- package/dist/mcp/filter.js +35 -0
- package/dist/mcp/index.d.ts +23 -0
- package/dist/mcp/index.js +13 -0
- package/dist/mcp/manager.d.ts +51 -0
- package/dist/mcp/manager.js +412 -0
- package/dist/mcp/mock-transport.d.ts +40 -0
- package/dist/mcp/mock-transport.js +68 -0
- package/dist/mcp/oauth/callback-server.d.ts +14 -0
- package/dist/mcp/oauth/callback-server.js +122 -0
- package/dist/mcp/oauth/index.d.ts +9 -0
- package/dist/mcp/oauth/index.js +5 -0
- package/dist/mcp/oauth/provider.d.ts +39 -0
- package/dist/mcp/oauth/provider.js +121 -0
- package/dist/mcp/oauth/service.d.ts +34 -0
- package/dist/mcp/oauth/service.js +130 -0
- package/dist/mcp/oauth/store.d.ts +40 -0
- package/dist/mcp/oauth/store.js +134 -0
- package/dist/mcp/output.d.ts +12 -0
- package/dist/mcp/output.js +110 -0
- package/dist/mcp/provider.d.ts +7 -0
- package/dist/mcp/provider.js +56 -0
- package/dist/mcp/sdk-transport.d.ts +25 -0
- package/dist/mcp/sdk-transport.js +228 -0
- package/dist/mcp/server.d.ts +77 -0
- package/dist/mcp/server.js +120 -0
- package/dist/mcp/tool-naming.d.ts +4 -0
- package/dist/mcp/tool-naming.js +26 -0
- package/dist/mcp/types.d.ts +75 -0
- package/dist/mcp/types.js +2 -0
- package/dist/net/index.d.ts +3 -0
- package/dist/net/index.js +2 -0
- package/dist/net/proxy.d.ts +16 -0
- package/dist/net/proxy.js +42 -0
- package/dist/permission/auto-approver/index.d.ts +3 -0
- package/dist/permission/auto-approver/index.js +3 -0
- package/dist/permission/auto-approver/llm-auto-approver.d.ts +53 -0
- package/dist/permission/auto-approver/llm-auto-approver.js +122 -0
- package/dist/permission/auto-approver/prompts-data.d.ts +9 -0
- package/dist/permission/auto-approver/prompts-data.js +155 -0
- package/dist/permission/auto-approver/prompts.d.ts +18 -0
- package/dist/permission/auto-approver/prompts.js +40 -0
- package/dist/permission/auto-approver/transcript.d.ts +22 -0
- package/dist/permission/auto-approver/transcript.js +75 -0
- package/dist/permission/auto-approver/xml.d.ts +5 -0
- package/dist/permission/auto-approver/xml.js +25 -0
- package/dist/permission/index.d.ts +7 -0
- package/dist/permission/index.js +5 -0
- package/dist/permission/manager.d.ts +74 -0
- package/dist/permission/manager.js +162 -0
- package/dist/permission/matches-rule.d.ts +27 -0
- package/dist/permission/matches-rule.js +54 -0
- package/dist/permission/policies.d.ts +14 -0
- package/dist/permission/policies.js +233 -0
- package/dist/permission/types.d.ts +84 -0
- package/dist/permission/types.js +2 -0
- package/dist/plugins/archive.d.ts +3 -0
- package/dist/plugins/archive.js +58 -0
- package/dist/plugins/github-resolver.d.ts +13 -0
- package/dist/plugins/github-resolver.js +20 -0
- package/dist/plugins/hooks.d.ts +28 -0
- package/dist/plugins/hooks.js +296 -0
- package/dist/plugins/index.d.ts +23 -0
- package/dist/plugins/index.js +23 -0
- package/dist/plugins/injector.d.ts +11 -0
- package/dist/plugins/injector.js +32 -0
- package/dist/plugins/manager.d.ts +37 -0
- package/dist/plugins/manager.js +330 -0
- package/dist/plugins/manifest.d.ts +9 -0
- package/dist/plugins/manifest.js +234 -0
- package/dist/plugins/marketplace.d.ts +85 -0
- package/dist/plugins/marketplace.js +205 -0
- package/dist/plugins/source.d.ts +23 -0
- package/dist/plugins/source.js +87 -0
- package/dist/plugins/store.d.ts +20 -0
- package/dist/plugins/store.js +30 -0
- package/dist/plugins/types.d.ts +118 -0
- package/dist/plugins/types.js +5 -0
- package/dist/protocol/index.d.ts +4 -0
- package/dist/protocol/index.js +2 -0
- package/dist/protocol/tool-schema.d.ts +6 -0
- package/dist/protocol/tool-schema.js +2 -0
- package/dist/store/blob-store.d.ts +45 -0
- package/dist/store/blob-store.js +120 -0
- package/dist/store/catalog-store.d.ts +32 -0
- package/dist/store/catalog-store.js +73 -0
- package/dist/store/disk-store.d.ts +58 -0
- package/dist/store/disk-store.js +369 -0
- package/dist/store/index.d.ts +23 -0
- package/dist/store/index.js +15 -0
- package/dist/store/lock.d.ts +86 -0
- package/dist/store/lock.js +104 -0
- package/dist/store/log-store.d.ts +89 -0
- package/dist/store/log-store.js +296 -0
- package/dist/store/migrate.d.ts +26 -0
- package/dist/store/migrate.js +32 -0
- package/dist/store/origin.d.ts +89 -0
- package/dist/store/origin.js +16 -0
- package/dist/store/pg.d.ts +90 -0
- package/dist/store/pg.js +344 -0
- package/dist/store/redacting-store.d.ts +21 -0
- package/dist/store/redacting-store.js +46 -0
- package/dist/store/redis.d.ts +89 -0
- package/dist/store/redis.js +370 -0
- package/dist/store/repository.d.ts +150 -0
- package/dist/store/repository.js +508 -0
- package/dist/store/session-catalog.d.ts +32 -0
- package/dist/store/session-catalog.js +117 -0
- package/dist/store/storage.d.ts +27 -0
- package/dist/store/storage.js +54 -0
- package/dist/store/store.d.ts +262 -0
- package/dist/store/store.js +129 -0
- package/dist/store/workdir-key.d.ts +4 -0
- package/dist/store/workdir-key.js +28 -0
- package/dist/tool/access.d.ts +37 -0
- package/dist/tool/access.js +79 -0
- package/dist/tool/ask.d.ts +22 -0
- package/dist/tool/ask.js +38 -0
- package/dist/tool/background.d.ts +109 -0
- package/dist/tool/background.js +39 -0
- package/dist/tool/builtin/ask-user-question.d.ts +2 -0
- package/dist/tool/builtin/ask-user-question.js +175 -0
- package/dist/tool/builtin/bash.d.ts +2 -0
- package/dist/tool/builtin/bash.js +407 -0
- package/dist/tool/builtin/edit.d.ts +2 -0
- package/dist/tool/builtin/edit.js +202 -0
- package/dist/tool/builtin/glob.d.ts +3 -0
- package/dist/tool/builtin/glob.js +260 -0
- package/dist/tool/builtin/grep.d.ts +2 -0
- package/dist/tool/builtin/grep.js +574 -0
- package/dist/tool/builtin/line-endings.d.ts +10 -0
- package/dist/tool/builtin/line-endings.js +41 -0
- package/dist/tool/builtin/read.d.ts +28 -0
- package/dist/tool/builtin/read.js +498 -0
- package/dist/tool/builtin/write.d.ts +2 -0
- package/dist/tool/builtin/write.js +179 -0
- package/dist/tool/define.d.ts +46 -0
- package/dist/tool/define.js +45 -0
- package/dist/tool/file-freshness.d.ts +81 -0
- package/dist/tool/file-freshness.js +67 -0
- package/dist/tool/filesystem-tools.d.ts +16 -0
- package/dist/tool/filesystem-tools.js +19 -0
- package/dist/tool/git-context.d.ts +20 -0
- package/dist/tool/git-context.js +114 -0
- package/dist/tool/index.d.ts +37 -0
- package/dist/tool/index.js +34 -0
- package/dist/tool/machine-base.d.ts +138 -0
- package/dist/tool/machine-base.js +388 -0
- package/dist/tool/machine-local.d.ts +35 -0
- package/dist/tool/machine-local.js +316 -0
- package/dist/tool/machine-null.d.ts +36 -0
- package/dist/tool/machine-null.js +64 -0
- package/dist/tool/machine-ssh.d.ts +86 -0
- package/dist/tool/machine-ssh.js +576 -0
- package/dist/tool/machine.d.ts +333 -0
- package/dist/tool/machine.js +15 -0
- package/dist/tool/policies/path-access.d.ts +48 -0
- package/dist/tool/policies/path-access.js +186 -0
- package/dist/tool/policies/sensitive.d.ts +3 -0
- package/dist/tool/policies/sensitive.js +60 -0
- package/dist/tool/questions.d.ts +40 -0
- package/dist/tool/questions.js +8 -0
- package/dist/tool/search/activation.d.ts +13 -0
- package/dist/tool/search/activation.js +31 -0
- package/dist/tool/search/deferral.d.ts +37 -0
- package/dist/tool/search/deferral.js +128 -0
- package/dist/tool/search/search-tool.d.ts +9 -0
- package/dist/tool/search/search-tool.js +62 -0
- package/dist/tool/shell-env.d.ts +9 -0
- package/dist/tool/shell-env.js +34 -0
- package/dist/tool/support/bash-destructive.d.ts +24 -0
- package/dist/tool/support/bash-destructive.js +63 -0
- package/dist/tool/support/bash-paths.d.ts +7 -0
- package/dist/tool/support/bash-paths.js +247 -0
- package/dist/tool/support/bash-read-only.d.ts +8 -0
- package/dist/tool/support/bash-read-only.js +165 -0
- package/dist/tool/support/bash-rule-match.d.ts +20 -0
- package/dist/tool/support/bash-rule-match.js +191 -0
- package/dist/tool/support/file-type.d.ts +10 -0
- package/dist/tool/support/file-type.js +149 -0
- package/dist/tool/support/git-worktree.d.ts +10 -0
- package/dist/tool/support/git-worktree.js +63 -0
- package/dist/tool/support/image-compress.d.ts +69 -0
- package/dist/tool/support/image-compress.js +265 -0
- package/dist/tool/support/machine-ops.d.ts +34 -0
- package/dist/tool/support/machine-ops.js +34 -0
- package/dist/tool/support/path-glob-match.d.ts +12 -0
- package/dist/tool/support/path-glob-match.js +84 -0
- package/dist/tool/support/result-builder.d.ts +27 -0
- package/dist/tool/support/result-builder.js +108 -0
- package/dist/tool/support/rg-locator.d.ts +20 -0
- package/dist/tool/support/rg-locator.js +42 -0
- package/dist/tool/support/ripgrep-run.d.ts +65 -0
- package/dist/tool/support/ripgrep-run.js +40 -0
- package/dist/tool/support/rule-match.d.ts +6 -0
- package/dist/tool/support/rule-match.js +23 -0
- package/dist/tool/support/tool-path.d.ts +8 -0
- package/dist/tool/support/tool-path.js +28 -0
- package/dist/tool/support/workspace.d.ts +5 -0
- package/dist/tool/support/workspace.js +2 -0
- package/dist/tool/types.d.ts +131 -0
- package/dist/tool/types.js +2 -0
- package/dist/tool/web/fetch-url.d.ts +4 -0
- package/dist/tool/web/fetch-url.js +61 -0
- package/dist/tool/web/index.d.ts +11 -0
- package/dist/tool/web/index.js +7 -0
- package/dist/tool/web/providers/direct-fetch.d.ts +33 -0
- package/dist/tool/web/providers/direct-fetch.js +198 -0
- package/dist/tool/web/providers/firecrawl.d.ts +16 -0
- package/dist/tool/web/providers/firecrawl.js +59 -0
- package/dist/tool/web/providers/tavily.d.ts +14 -0
- package/dist/tool/web/providers/tavily.js +43 -0
- package/dist/tool/web/types.d.ts +41 -0
- package/dist/tool/web/types.js +7 -0
- package/dist/tool/web/web-search.d.ts +4 -0
- package/dist/tool/web/web-search.js +68 -0
- package/dist/tool/workspace-spec.d.ts +74 -0
- package/dist/tool/workspace-spec.js +177 -0
- package/dist/tracing/bridge.d.ts +7 -0
- package/dist/tracing/bridge.js +171 -0
- package/dist/tracing/index.d.ts +9 -0
- package/dist/tracing/index.js +5 -0
- package/dist/tracing/otel.d.ts +38 -0
- package/dist/tracing/otel.js +221 -0
- package/dist/tracing/processor.d.ts +47 -0
- package/dist/tracing/processor.js +94 -0
- package/dist/tracing/spans.d.ts +94 -0
- package/dist/tracing/spans.js +56 -0
- package/dist/ui/ai-sdk.d.ts +114 -0
- package/dist/ui/ai-sdk.js +175 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +2 -0
- package/package.json +101 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { Machine, RunCommandResult } from "./machine.ts";
|
|
2
|
+
import type { ToolResult } from "./types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Starts ONE command and resolves with how it ended.
|
|
5
|
+
*
|
|
6
|
+
* This — not a process handle — is what a background task actually needs: stop it
|
|
7
|
+
* (`signal`), watch it (`onOutput`), learn how it ended (the resolved result). All three are
|
|
8
|
+
* `run`'s intent fields, so every backend delivers them with its own native means. Demanding
|
|
9
|
+
* a live handle instead would require a capability sandbox transports cannot provide
|
|
10
|
+
* honestly, which is what used to force a fake handle whose `kill()` did nothing.
|
|
11
|
+
*/
|
|
12
|
+
export type CommandStarter = (opts: {
|
|
13
|
+
readonly signal: AbortSignal;
|
|
14
|
+
/** Live pipe tap for an inline foreground run. File-backed background/attached commands omit
|
|
15
|
+
* it because their canonical output is already on the Machine. */
|
|
16
|
+
readonly onOutput?: (chunk: string) => void;
|
|
17
|
+
}) => Promise<RunCommandResult>;
|
|
18
|
+
export interface QuestionSpawnOptions {
|
|
19
|
+
readonly questionCount: number;
|
|
20
|
+
readonly parentAddress?: string;
|
|
21
|
+
readonly toolCallId?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ProcessSpawnOptions {
|
|
24
|
+
/** The Machine file the process's output is redirected to (its durable work product);
|
|
25
|
+
* set together with `machine` so the task can read it back on demand. */
|
|
26
|
+
readonly logPath?: string;
|
|
27
|
+
readonly machine?: Machine;
|
|
28
|
+
/** Parent conversation line. Namespaces `toolCallId`, which is not globally unique. */
|
|
29
|
+
readonly parentAddress?: string;
|
|
30
|
+
/** The tool call that started this command. Carried onto the settle notification so a UI can
|
|
31
|
+
* reattach the completion to the card that spawned it — the two are otherwise unrelated
|
|
32
|
+
* events separated by however long the command ran. */
|
|
33
|
+
readonly toolCallId?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Terminal status of an attached run that finished in the foreground (never detached). */
|
|
36
|
+
export type AttachedSettleStatus = "completed" | "failed" | "timed_out" | "killed";
|
|
37
|
+
/** Options for {@link BackgroundSpawner.runCommandAttached}. Extends the command spawn
|
|
38
|
+
* options (log file / machine) with the foreground-attachment seams. */
|
|
39
|
+
export interface AttachedRunOptions extends ProcessSpawnOptions {
|
|
40
|
+
/** The tool call's abort signal. While attached, aborting it KILLS the process
|
|
41
|
+
* (foreground semantics). Dropped the instant the run detaches. */
|
|
42
|
+
readonly foregroundSignal: AbortSignal;
|
|
43
|
+
/** The tool call's detach trigger (`ctx.detachSignal`). Aborting it moves the still-running
|
|
44
|
+
* process into a background task and resolves with `{ kind: "detached" }`. */
|
|
45
|
+
readonly detachSignal?: AbortSignal;
|
|
46
|
+
/** Foreground-only timeout (ms). Applies while attached; dropped on detach. */
|
|
47
|
+
readonly foregroundTimeoutMs?: number;
|
|
48
|
+
/** Live output tap while attached — feed the tool's result builder + `ctx.onUpdate`.
|
|
49
|
+
* Stops being called the instant the run detaches (output then flows to the task tail). */
|
|
50
|
+
readonly onLive?: (chunk: string) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Fired once, when the run has lasted long enough to be worth offering to the user as
|
|
53
|
+
* "move this to the background". Deliberately NOT at start: a command that finishes in
|
|
54
|
+
* milliseconds should never make the UI flash an offer the user cannot act on.
|
|
55
|
+
*
|
|
56
|
+
* A driver that cannot detach never fires it.
|
|
57
|
+
*/
|
|
58
|
+
readonly onDetachable?: () => void;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The default {@link BackgroundSpawner.runCommandAttached} for a host with no task system:
|
|
62
|
+
* run the command, honour the foreground timeout and abort, and report how it ended. It can
|
|
63
|
+
* never return `detached` — there is nowhere for a task to live once the tool call returns.
|
|
64
|
+
*
|
|
65
|
+
* This exists so the CALLER has one code path. The alternative — a tool that branches on
|
|
66
|
+
* whether the capability is present — is two implementations of "run a command in the
|
|
67
|
+
* foreground" that drift apart, which is exactly what happened before it existed.
|
|
68
|
+
*/
|
|
69
|
+
export declare function runCommandInline(start: CommandStarter, options: AttachedRunOptions): Promise<AttachedOutcome>;
|
|
70
|
+
/** Result of an attached run: it either settled in the foreground or was detached. */
|
|
71
|
+
export type AttachedOutcome = {
|
|
72
|
+
readonly kind: "settled";
|
|
73
|
+
readonly status: AttachedSettleStatus;
|
|
74
|
+
readonly exitCode: number | null;
|
|
75
|
+
} | {
|
|
76
|
+
readonly kind: "detached";
|
|
77
|
+
readonly taskId: string;
|
|
78
|
+
};
|
|
79
|
+
export interface BackgroundSpawner {
|
|
80
|
+
spawnCommand(start: CommandStarter, command: string, description: string, options?: ProcessSpawnOptions): string;
|
|
81
|
+
/**
|
|
82
|
+
* Run an interactive question as a background task (AskUserQuestion `background: true`).
|
|
83
|
+
* The spawner owns task construction and lifecycle; the tool only supplies the run
|
|
84
|
+
* closure. Optional: a BackgroundSpawner without task management omits it.
|
|
85
|
+
*/
|
|
86
|
+
spawnQuestion?(run: (signal: AbortSignal) => Promise<ToolResult>, description: string, options: QuestionSpawnOptions): {
|
|
87
|
+
readonly taskId: string;
|
|
88
|
+
readonly status: string;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Run a command ATTACHED to the foreground, with the option to detach it into a background
|
|
92
|
+
* task mid-flight. The spawner owns task construction, the swappable settlement sink, and the
|
|
93
|
+
* abort re-ownership on detach; the tool supplies the starter + the foreground seams and
|
|
94
|
+
* frames the result from the returned {@link AttachedOutcome}. Optional: a spawner without
|
|
95
|
+
* detach support omits it, and the tool falls back to a plain foreground `run`.
|
|
96
|
+
*/
|
|
97
|
+
runCommandAttached?(start: CommandStarter, command: string, description: string, options: AttachedRunOptions): Promise<AttachedOutcome>;
|
|
98
|
+
/**
|
|
99
|
+
* Register a per-call detach trigger and return the signal to pass as `ctx.detachSignal`.
|
|
100
|
+
* The loop calls this before running a tool and {@link unregisterDetachable} after. Firing
|
|
101
|
+
* the trigger is {@link detach}. Optional: a spawner without detach routing omits all three.
|
|
102
|
+
*/
|
|
103
|
+
registerDetachable?(toolCallId: string): AbortSignal;
|
|
104
|
+
unregisterDetachable?(toolCallId: string): void;
|
|
105
|
+
/** Fire the detach trigger for a running tool call (foreground → background). Returns false
|
|
106
|
+
* if no such call is currently registered. */
|
|
107
|
+
detach?(toolCallId: string): boolean;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=background.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default {@link BackgroundSpawner.runCommandAttached} for a host with no task system:
|
|
3
|
+
* run the command, honour the foreground timeout and abort, and report how it ended. It can
|
|
4
|
+
* never return `detached` — there is nowhere for a task to live once the tool call returns.
|
|
5
|
+
*
|
|
6
|
+
* This exists so the CALLER has one code path. The alternative — a tool that branches on
|
|
7
|
+
* whether the capability is present — is two implementations of "run a command in the
|
|
8
|
+
* foreground" that drift apart, which is exactly what happened before it existed.
|
|
9
|
+
*/
|
|
10
|
+
export async function runCommandInline(start, options) {
|
|
11
|
+
const controller = new AbortController();
|
|
12
|
+
let timedOut = false;
|
|
13
|
+
const stop = (why) => {
|
|
14
|
+
if (why === "timeout")
|
|
15
|
+
timedOut = true;
|
|
16
|
+
controller.abort();
|
|
17
|
+
};
|
|
18
|
+
const onAbort = () => stop("aborted");
|
|
19
|
+
if (options.foregroundSignal.aborted)
|
|
20
|
+
stop("aborted");
|
|
21
|
+
else
|
|
22
|
+
options.foregroundSignal.addEventListener("abort", onAbort);
|
|
23
|
+
const timer = options.foregroundTimeoutMs === undefined ? undefined : setTimeout(() => stop("timeout"), options.foregroundTimeoutMs);
|
|
24
|
+
try {
|
|
25
|
+
const result = await start({
|
|
26
|
+
signal: controller.signal,
|
|
27
|
+
onOutput: (chunk) => options.onLive?.(chunk),
|
|
28
|
+
});
|
|
29
|
+
// `run` reports its OWN timeout too; either route means the same thing to the caller.
|
|
30
|
+
const status = timedOut || result.timedOut ? "timed_out" : options.foregroundSignal.aborted ? "killed" : result.exitCode === 0 ? "completed" : "failed";
|
|
31
|
+
return { kind: "settled", status, exitCode: result.exitCode ?? null };
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
if (timer !== undefined)
|
|
35
|
+
clearTimeout(timer);
|
|
36
|
+
options.foregroundSignal.removeEventListener("abort", onAbort);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=background.js.map
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineTool } from "../define.js";
|
|
3
|
+
import { ToolAccesses } from "../access.js";
|
|
4
|
+
const QUESTION_DISMISSED_MESSAGE = "User dismissed the question without answering.";
|
|
5
|
+
const QUESTION_UNSUPPORTED_FAILURE_MESSAGE = "The connected client does not support interactive questions. Do NOT call this tool again. Ask the user directly in your text response instead.";
|
|
6
|
+
// Answers come back keyed by question text with option labels as values, so both
|
|
7
|
+
// must be unambiguous: question texts unique across the call, option labels unique
|
|
8
|
+
// within each question. Otherwise the model cannot tell which answer maps to which.
|
|
9
|
+
const QUESTION_UNIQUENESS_MESSAGE = "Question texts must be unique across questions, and option labels must be unique within each question.";
|
|
10
|
+
const QuestionOptionSchema = z.object({
|
|
11
|
+
label: z.string().describe("Concise display text (1-5 words). If recommended, append '(Recommended)'."),
|
|
12
|
+
description: z.string().default("").describe("Brief explanation of trade-offs or implications."),
|
|
13
|
+
});
|
|
14
|
+
const QuestionItemSchema = z.object({
|
|
15
|
+
question: z.string().describe("A specific, actionable question. End with '?'."),
|
|
16
|
+
header: z.string().default("").describe("Short category tag (max 12 chars, e.g. 'Auth', 'Style')."),
|
|
17
|
+
options: z
|
|
18
|
+
.array(QuestionOptionSchema)
|
|
19
|
+
.min(2)
|
|
20
|
+
.max(4)
|
|
21
|
+
.describe("2-4 meaningful, distinct options. Do NOT include an 'Other' option — the system adds one automatically."),
|
|
22
|
+
multi_select: z.boolean().default(false).describe("Whether the user can select multiple options."),
|
|
23
|
+
});
|
|
24
|
+
const AskUserQuestionInput = z.object({
|
|
25
|
+
background: z
|
|
26
|
+
.boolean()
|
|
27
|
+
.default(false)
|
|
28
|
+
.describe("Set true to ask in the background and return immediately with a task_id when background tasks are available.")
|
|
29
|
+
.optional(),
|
|
30
|
+
questions: z.array(QuestionItemSchema).min(1).max(4).describe("The questions to ask the user (1-4 questions)."),
|
|
31
|
+
});
|
|
32
|
+
const ASK_USER_QUESTION_DESCRIPTION = [
|
|
33
|
+
"Use this tool when you need to ask the user questions with structured options during execution. This allows you to:",
|
|
34
|
+
"1. Collect user preferences or requirements before proceeding",
|
|
35
|
+
"2. Resolve ambiguous or underspecified instructions",
|
|
36
|
+
"3. Let the user decide between implementation approaches as you work",
|
|
37
|
+
"4. Present concrete options when multiple valid directions exist",
|
|
38
|
+
"",
|
|
39
|
+
"**When NOT to use:**",
|
|
40
|
+
"- When you can infer the answer from context — be decisive and proceed",
|
|
41
|
+
"- Trivial decisions that don't materially affect the outcome",
|
|
42
|
+
"",
|
|
43
|
+
"Overusing this tool interrupts the user's flow. Only use it when the user's input genuinely changes your next action.",
|
|
44
|
+
"",
|
|
45
|
+
"**Usage notes:**",
|
|
46
|
+
"- Users always have an \"Other\" option for custom input — don't create one yourself",
|
|
47
|
+
"- Use multi_select to allow multiple answers to be selected for a question",
|
|
48
|
+
"- Keep option labels concise (1-5 words), use descriptions for trade-offs and details",
|
|
49
|
+
"- Each question should have 2-4 meaningful, distinct options",
|
|
50
|
+
"- Answers come back keyed by question text with the chosen option labels as values, so keep question texts unique across the call and option labels unique within each question",
|
|
51
|
+
"- You can ask 1-4 questions at a time; group related questions to minimize interruptions",
|
|
52
|
+
"- If you recommend a specific option, list it first and append \"(Recommended)\" to its label",
|
|
53
|
+
"- Set background=true when you can keep working without the answer. This starts a background question task and returns a task_id immediately when background tasks are available. The answer arrives automatically in a later turn; continue with other work and never fabricate or predict the answer.",
|
|
54
|
+
].join("\n");
|
|
55
|
+
export const askUserQuestionTool = defineTool({
|
|
56
|
+
name: "AskUserQuestion",
|
|
57
|
+
description: ASK_USER_QUESTION_DESCRIPTION,
|
|
58
|
+
params: AskUserQuestionInput,
|
|
59
|
+
resolve: (args) => ({
|
|
60
|
+
approvalRule: "AskUserQuestion",
|
|
61
|
+
accesses: ToolAccesses.none(),
|
|
62
|
+
display: {
|
|
63
|
+
title: args.background === true ? "Start background question" : "Ask user question",
|
|
64
|
+
detail: questionDescription(args.questions),
|
|
65
|
+
},
|
|
66
|
+
run: async (ctx) => {
|
|
67
|
+
// Continuation of a durable suspension: the caller's answer arrived via Runner.resume.
|
|
68
|
+
if (ctx.resumed !== undefined) {
|
|
69
|
+
return questionResultToToolResult(ctx.resumed.answer);
|
|
70
|
+
}
|
|
71
|
+
// Guard the answer-keying contract before asking: duplicate question texts or
|
|
72
|
+
// option labels make the returned answers ambiguous. Fail soft with a retry hint.
|
|
73
|
+
const uniquenessError = questionUniquenessError(args.questions);
|
|
74
|
+
if (uniquenessError !== null)
|
|
75
|
+
return textResult(uniquenessError, true);
|
|
76
|
+
if (args.background === true) {
|
|
77
|
+
const spawnQuestion = ctx.background?.spawnQuestion?.bind(ctx.background);
|
|
78
|
+
if (spawnQuestion === undefined) {
|
|
79
|
+
return textResult("Background questions are unavailable because no BackgroundManager is attached.", true);
|
|
80
|
+
}
|
|
81
|
+
const task = spawnQuestion((signal) => executeQuestion(ctx.responder, args, { turnId: ctx.turnId, toolCallId: ctx.toolCallId, signal }), questionDescription(args.questions), {
|
|
82
|
+
questionCount: args.questions.length,
|
|
83
|
+
...(ctx.address !== undefined ? { parentAddress: ctx.address } : {}),
|
|
84
|
+
toolCallId: ctx.toolCallId,
|
|
85
|
+
});
|
|
86
|
+
return textResult([
|
|
87
|
+
`task_id: ${task.taskId}`,
|
|
88
|
+
`description: ${questionDescription(args.questions)}`,
|
|
89
|
+
`status: ${task.status}`,
|
|
90
|
+
"automatic_notification: true",
|
|
91
|
+
"next_step: Continue your current work; the answer will arrive automatically when the user responds.",
|
|
92
|
+
"next_step: Use BackgroundOutput with this task_id for a non-blocking status/answer snapshot.",
|
|
93
|
+
].join("\n"));
|
|
94
|
+
}
|
|
95
|
+
// No responder at all (headless / durable session): suspend instead of failing — the
|
|
96
|
+
// questions surface on the paused run and the answer comes back through Runner.resume.
|
|
97
|
+
// A responder WITHOUT requestQuestion stays the soft-failure path below: that client is
|
|
98
|
+
// live but cannot render questions, so pausing durably would hang the conversation.
|
|
99
|
+
if (ctx.responder === undefined) {
|
|
100
|
+
ctx.suspend({ kind: "question", display: { questions: toQuestionItems(args.questions) } });
|
|
101
|
+
// suspend() must interrupt (typed `never`); a non-conforming context falling
|
|
102
|
+
// through would misreport the pause as the "unsupported" soft failure below.
|
|
103
|
+
throw new Error("ToolRunContext.suspend() returned instead of interrupting the run — non-conforming implementation.");
|
|
104
|
+
}
|
|
105
|
+
return executeQuestion(ctx.responder, args, { turnId: ctx.turnId, toolCallId: ctx.toolCallId, signal: ctx.signal });
|
|
106
|
+
},
|
|
107
|
+
}),
|
|
108
|
+
});
|
|
109
|
+
async function executeQuestion(responder, args, ctx) {
|
|
110
|
+
if (responder?.requestQuestion === undefined)
|
|
111
|
+
return textResult(QUESTION_UNSUPPORTED_FAILURE_MESSAGE, true);
|
|
112
|
+
const result = await responder.requestQuestion({ turnId: ctx.turnId, toolCallId: ctx.toolCallId, questions: toQuestionItems(args.questions) }, { signal: ctx.signal });
|
|
113
|
+
return questionResultToToolResult(result);
|
|
114
|
+
}
|
|
115
|
+
function toQuestionItems(questions) {
|
|
116
|
+
return questions.map((question) => ({
|
|
117
|
+
question: question.question,
|
|
118
|
+
header: question.header,
|
|
119
|
+
options: question.options.map((option) => ({ label: option.label, description: option.description })),
|
|
120
|
+
multiSelect: question.multi_select,
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
function questionResultToToolResult(result) {
|
|
124
|
+
const normalized = normalizeQuestionResult(result);
|
|
125
|
+
if (normalized === null || Object.keys(normalized.answers).length === 0) {
|
|
126
|
+
return textResult(JSON.stringify({ answers: {}, note: QUESTION_DISMISSED_MESSAGE }));
|
|
127
|
+
}
|
|
128
|
+
return textResult(JSON.stringify({ answers: normalized.answers }));
|
|
129
|
+
}
|
|
130
|
+
function normalizeQuestionResult(result) {
|
|
131
|
+
if (result === null)
|
|
132
|
+
return null;
|
|
133
|
+
if (isQuestionResponse(result))
|
|
134
|
+
return { answers: result.answers, method: result.method };
|
|
135
|
+
return { answers: result };
|
|
136
|
+
}
|
|
137
|
+
function isQuestionResponse(result) {
|
|
138
|
+
if (typeof result !== "object" || result === null || Array.isArray(result))
|
|
139
|
+
return false;
|
|
140
|
+
if (!Object.hasOwn(result, "answers"))
|
|
141
|
+
return false;
|
|
142
|
+
const answers = result.answers;
|
|
143
|
+
return typeof answers === "object" && answers !== null && !Array.isArray(answers);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Reject a question set that would produce ambiguous answers: a question text
|
|
147
|
+
* repeated across the call, or an option label repeated within one question.
|
|
148
|
+
* Returns a model-facing retry message, or null when the set is unambiguous.
|
|
149
|
+
*/
|
|
150
|
+
function questionUniquenessError(questions) {
|
|
151
|
+
const questionTexts = new Set();
|
|
152
|
+
for (const q of questions) {
|
|
153
|
+
if (questionTexts.has(q.question)) {
|
|
154
|
+
return `Invalid questions: duplicate question text ${JSON.stringify(q.question)}. ${QUESTION_UNIQUENESS_MESSAGE} Rephrase the duplicates and call the tool again.`;
|
|
155
|
+
}
|
|
156
|
+
questionTexts.add(q.question);
|
|
157
|
+
const labels = new Set();
|
|
158
|
+
for (const option of q.options) {
|
|
159
|
+
if (labels.has(option.label)) {
|
|
160
|
+
return `Invalid questions: duplicate option label ${JSON.stringify(option.label)} in question ${JSON.stringify(q.question)}. ${QUESTION_UNIQUENESS_MESSAGE} Rephrase the duplicates and call the tool again.`;
|
|
161
|
+
}
|
|
162
|
+
labels.add(option.label);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
function questionDescription(questions) {
|
|
168
|
+
const first = questions[0]?.question.trim();
|
|
169
|
+
const label = first === undefined || first.length === 0 ? "Ask user question" : first;
|
|
170
|
+
return questions.length <= 1 ? label : `${label} (+${String(questions.length - 1)} more)`;
|
|
171
|
+
}
|
|
172
|
+
function textResult(text, isError = false) {
|
|
173
|
+
return { content: [{ type: "text", text }], isError };
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=ask-user-question.js.map
|