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,498 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ToolAccesses } from "../access.js";
|
|
3
|
+
import { defineTool } from "../define.js";
|
|
4
|
+
import { FILE_UNCHANGED_STUB } from "../file-freshness.js";
|
|
5
|
+
import { detectFileType, MEDIA_SNIFF_BYTES } from "../support/file-type.js";
|
|
6
|
+
import { compressImageForModel } from "../support/image-compress.js";
|
|
7
|
+
import { fileVersionFromInfo, fileVersionsMatch, normalizeForCompare, readTextFile } from "../support/machine-ops.js";
|
|
8
|
+
import { pathApproval, resolveToolPath } from "../support/tool-path.js";
|
|
9
|
+
import { makeCarriageReturnsVisible } from "./line-endings.js";
|
|
10
|
+
/**
|
|
11
|
+
* Ceiling on an EXPLICIT line request (`n_lines`, or a negative `line_offset`). Not a default
|
|
12
|
+
* truncation: an unpaged read returns the whole file, bounded by the two limits below.
|
|
13
|
+
*
|
|
14
|
+
* A default that quietly served the first N lines was the worst of both worlds — the caller
|
|
15
|
+
* asked for a file and got a prefix, and the ledger recorded a partial view, which is exactly
|
|
16
|
+
* what disables the content-comparison fallback that the mtime-coarse backends depend on.
|
|
17
|
+
*/
|
|
18
|
+
export const MAX_LINES = 2000;
|
|
19
|
+
export const MAX_LINE_LENGTH = 2000;
|
|
20
|
+
/** Rendered-output ceiling. Past it the read is refused, never silently cut short. */
|
|
21
|
+
export const MAX_BYTES = 100 * 1024;
|
|
22
|
+
/**
|
|
23
|
+
* Whole-file ceiling for an UNPAGED read (no `line_offset`/`n_lines`): past this the read is
|
|
24
|
+
* refused instead of served truncated.
|
|
25
|
+
*
|
|
26
|
+
* Truncation is not the problem — the `<system>` footer says plainly how much was cut. The
|
|
27
|
+
* cost is: a multi-megabyte file answers with `MAX_BYTES` of its opening, which is rarely
|
|
28
|
+
* what the caller wanted and never cheap. Refusing costs a two-line error and leaves the
|
|
29
|
+
* caller to page in, grep, or give up, all of which beat paying for a prefix nobody asked for.
|
|
30
|
+
*
|
|
31
|
+
* Only unpaged reads are gated. A caller that passed a range already said what it wants, and
|
|
32
|
+
* gating that on the file's TOTAL size would refuse exactly the paging that is the way
|
|
33
|
+
* out of this error.
|
|
34
|
+
*/
|
|
35
|
+
export const MAX_UNPAGED_FILE_BYTES = 256 * 1024;
|
|
36
|
+
const MAX_IMAGE_MEGABYTES = 100;
|
|
37
|
+
const MAX_IMAGE_BYTES = MAX_IMAGE_MEGABYTES * 1024 * 1024;
|
|
38
|
+
const PositiveLineOffset = z.number().int().min(1);
|
|
39
|
+
const TailLineOffset = z.number().int().min(-MAX_LINES).max(-1);
|
|
40
|
+
const ReadInput = z.object({
|
|
41
|
+
path: z
|
|
42
|
+
.string()
|
|
43
|
+
.describe("Path to a text or image file. Relative paths resolve against the working directory; a path outside the working directory must be absolute. Directories are not supported; use `ls` via Bash for a known directory, or Glob for pattern search."),
|
|
44
|
+
line_offset: z
|
|
45
|
+
.union([PositiveLineOffset, TailLineOffset])
|
|
46
|
+
.optional()
|
|
47
|
+
.describe(`The line number to start reading from. Omit to start at line 1. Negative values read from the end of the file; the absolute value cannot exceed ${String(MAX_LINES)}.`),
|
|
48
|
+
n_lines: z
|
|
49
|
+
.number()
|
|
50
|
+
.int()
|
|
51
|
+
.positive()
|
|
52
|
+
.max(MAX_LINES)
|
|
53
|
+
.optional()
|
|
54
|
+
.describe(`The number of lines to read, at most ${String(MAX_LINES)}. Omit to read to the end of the file.`),
|
|
55
|
+
});
|
|
56
|
+
const READ_DESCRIPTION = [
|
|
57
|
+
"Read a text or image file from the local filesystem.",
|
|
58
|
+
"",
|
|
59
|
+
"If the user provides a concrete file path to a text or image file, call Read directly. Do not `Glob`, `ls`, or otherwise pre-check known file paths; missing or invalid file paths return errors you can handle. Do not use Read for directories; use `ls` via Bash for a known directory, or Glob when you need files matching a pattern. Use `Grep` only when the task is to search for unknown content or locations.",
|
|
60
|
+
"",
|
|
61
|
+
"When you need several files, prefer to read them in parallel: emit multiple `Read` calls in a single response instead of reading one file per turn.",
|
|
62
|
+
"",
|
|
63
|
+
"- Relative paths resolve against the working directory; a path outside the working directory must be absolute.",
|
|
64
|
+
"- Omitting `line_offset`/`n_lines` reads the WHOLE file — do that by default; you get the complete content and later edits are checked against it.",
|
|
65
|
+
`- Two limits, and passing either is an error rather than a silent partial answer: a whole-file read needs the file under ${String(MAX_UNPAGED_FILE_BYTES / 1024)} KB, and any read must render under ${String(MAX_BYTES / 1024)} KB. Both errors say how to narrow the request.`,
|
|
66
|
+
`- Page with \`line_offset\` (1-based start line) and \`n_lines\` (at most ${String(MAX_LINES)}) when a file is too big to read whole, or use Grep to locate the relevant part first.`,
|
|
67
|
+
`- Lines longer than ${String(MAX_LINE_LENGTH)} chars are truncated mid-line; that is the one case where content is shortened rather than refused, and the \`<system>\` footer lists the affected line numbers.`,
|
|
68
|
+
`- Supported image files return a <system> summary and image content directly; image files can be up to ${String(MAX_IMAGE_MEGABYTES)}MB.`,
|
|
69
|
+
"- Only UTF-8 text files and supported image files can be read. Non-UTF-8 encodings, video files, other binary files, and files containing NUL bytes are refused; use Bash or an MCP tool for unsupported binary formats.",
|
|
70
|
+
`- Negative line_offset reads from the end of the file (for example, -100 reads the last 100 lines); the absolute value cannot exceed ${String(MAX_LINES)}.`,
|
|
71
|
+
"- Text output format: `<line-number>\\t<content>` per line.",
|
|
72
|
+
"- A `<system>...</system>` status block is appended after text file content; it summarizes how much was read (line and byte counts, truncation, line-ending notes) and is not part of the file itself.",
|
|
73
|
+
"- Pure CRLF files are displayed with LF line endings; `Edit` and `Write`-append match this output and preserve CRLF when writing back.",
|
|
74
|
+
"- Mixed or lone carriage-return line endings are shown as `\\r` and require exact `Edit.old_string` escapes.",
|
|
75
|
+
"- For images, the `<system>` block summarizes the mime type, byte size and original pixel dimensions when available. When outputting coordinates, give relative coordinates first and compute absolute coordinates from the original image size. After generating or editing images via commands or scripts, read the result back before continuing.",
|
|
76
|
+
"- If the same file range is read again and the file is unchanged, Read may return a `file unchanged` stub instead of repeating the content; use the earlier Read tool result in this conversation. Ask for a different range only when you need different content.",
|
|
77
|
+
"- After a successful `Edit`/`Write`, do not re-read solely to prove the write landed. When the task depends on an exact file, API, or output shape, inspect the final external contract before finishing.",
|
|
78
|
+
].join("\n");
|
|
79
|
+
function truncateLine(line, maxLength) {
|
|
80
|
+
if (line.length <= maxLength)
|
|
81
|
+
return line;
|
|
82
|
+
const marker = "...";
|
|
83
|
+
const target = Math.max(maxLength, marker.length);
|
|
84
|
+
return line.slice(0, target - marker.length) + marker;
|
|
85
|
+
}
|
|
86
|
+
function stripTrailingLf(line) {
|
|
87
|
+
return line.endsWith("\n") ? line.slice(0, -1) : line;
|
|
88
|
+
}
|
|
89
|
+
function updateLineEndingFlags(flags, text) {
|
|
90
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
91
|
+
const code = text.codePointAt(i);
|
|
92
|
+
if (code === 13) {
|
|
93
|
+
if (text.codePointAt(i + 1) === 10) {
|
|
94
|
+
flags.hasCrLf = true;
|
|
95
|
+
i += 1;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
flags.hasLoneCr = true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else if (code === 10) {
|
|
102
|
+
flags.hasLf = true;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function lineEndingStyleFromFlags(flags) {
|
|
107
|
+
if (flags.hasLoneCr || (flags.hasCrLf && flags.hasLf))
|
|
108
|
+
return "mixed";
|
|
109
|
+
if (flags.hasCrLf)
|
|
110
|
+
return "crlf";
|
|
111
|
+
return "lf";
|
|
112
|
+
}
|
|
113
|
+
function renderLine(entry, lineEndingStyle) {
|
|
114
|
+
const modelContent = lineEndingStyle === "crlf" && entry.rawContent.endsWith("\r")
|
|
115
|
+
? entry.rawContent.slice(0, -1)
|
|
116
|
+
: entry.rawContent;
|
|
117
|
+
const truncated = truncateLine(modelContent, MAX_LINE_LENGTH);
|
|
118
|
+
const renderedContent = lineEndingStyle === "mixed" ? makeCarriageReturnsVisible(truncated) : truncated;
|
|
119
|
+
return {
|
|
120
|
+
line: `${String(entry.lineNo)}\t${renderedContent}`,
|
|
121
|
+
wasTruncated: truncated !== modelContent,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function renderedLineBytes(renderedLine, isFirst) {
|
|
125
|
+
return (isFirst ? 0 : 1) + Buffer.byteLength(renderedLine, "utf8");
|
|
126
|
+
}
|
|
127
|
+
/** Whole-file line iteration (terminators included). */
|
|
128
|
+
function* readLinesStrict(text) {
|
|
129
|
+
let start = 0;
|
|
130
|
+
for (let i = 0; i < text.length; i++) {
|
|
131
|
+
if (text[i] === "\n") {
|
|
132
|
+
yield text.slice(start, i + 1);
|
|
133
|
+
start = i + 1;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (start < text.length)
|
|
137
|
+
yield text.slice(start);
|
|
138
|
+
}
|
|
139
|
+
function isFileNotFoundError(error) {
|
|
140
|
+
if (typeof error !== "object" || error === null)
|
|
141
|
+
return false;
|
|
142
|
+
const code = error["code"];
|
|
143
|
+
return code === "ENOENT" || code === "ENOTDIR";
|
|
144
|
+
}
|
|
145
|
+
function isTextDecodeError(error) {
|
|
146
|
+
if (typeof error !== "object" || error === null)
|
|
147
|
+
return false;
|
|
148
|
+
const code = error["code"];
|
|
149
|
+
if (code === "ERR_ENCODING_INVALID_ENCODED_DATA")
|
|
150
|
+
return true;
|
|
151
|
+
if (!(error instanceof Error))
|
|
152
|
+
return false;
|
|
153
|
+
return /encoded data was not valid|invalid.*encoding|invalid.*utf-?8/i.test(error.message);
|
|
154
|
+
}
|
|
155
|
+
function containsNulByte(text) {
|
|
156
|
+
return text.includes("\u0000");
|
|
157
|
+
}
|
|
158
|
+
function notReadableFileOutput(path) {
|
|
159
|
+
return (`"${path}" is not readable as UTF-8 text. ` +
|
|
160
|
+
"Only UTF-8 text files and supported image files can be read. " +
|
|
161
|
+
"For video or other binary formats, use Bash or an MCP tool if available.");
|
|
162
|
+
}
|
|
163
|
+
function ok(output) {
|
|
164
|
+
return { content: [{ type: "text", text: output }] };
|
|
165
|
+
}
|
|
166
|
+
function err(output) {
|
|
167
|
+
return { content: [{ type: "text", text: output }], isError: true };
|
|
168
|
+
}
|
|
169
|
+
export const readTool = defineTool({
|
|
170
|
+
name: "Read",
|
|
171
|
+
description: READ_DESCRIPTION,
|
|
172
|
+
params: ReadInput,
|
|
173
|
+
async resolve(args, ctx) {
|
|
174
|
+
const path = await resolveToolPath(args.path, ctx.machine, "read");
|
|
175
|
+
return {
|
|
176
|
+
accesses: ToolAccesses.readFile(path),
|
|
177
|
+
display: { title: `Reading ${args.path}` },
|
|
178
|
+
...pathApproval("Read", ctx.machine, path),
|
|
179
|
+
run: (runCtx) => execute(args, path, runCtx),
|
|
180
|
+
};
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
async function execute(args, safePath, ctx) {
|
|
184
|
+
const machine = ctx.machine;
|
|
185
|
+
try {
|
|
186
|
+
let info;
|
|
187
|
+
try {
|
|
188
|
+
info = await machine.fileInfo(safePath);
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
if (isFileNotFoundError(error))
|
|
192
|
+
return err(`"${args.path}" does not exist.`);
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
195
|
+
if (info.kind !== "file")
|
|
196
|
+
return err(`"${args.path}" is not a file.`);
|
|
197
|
+
const header = await machine.readBytes(safePath, { length: MEDIA_SNIFF_BYTES });
|
|
198
|
+
const fileType = detectFileType(safePath, header);
|
|
199
|
+
if (fileType.kind === "image")
|
|
200
|
+
return readImageFile(args, safePath, info, machine, fileType.mimeType);
|
|
201
|
+
if (fileType.kind === "unknown")
|
|
202
|
+
return err(notReadableFileOutput(args.path));
|
|
203
|
+
const lineOffset = args.line_offset ?? 1;
|
|
204
|
+
// No `n_lines` means to the end of the file — the byte ceiling is what bounds it.
|
|
205
|
+
const requestedLines = args.n_lines ?? Number.POSITIVE_INFINITY;
|
|
206
|
+
const range = rangeKeyForArgs(args);
|
|
207
|
+
const record = ctx.fileLedger?.get(safePath);
|
|
208
|
+
if (record?.range && rangesEqual(record.range, range)) {
|
|
209
|
+
const current = fileVersionFromInfo(info);
|
|
210
|
+
if (fileVersionsMatch(record.version, current))
|
|
211
|
+
return ok(FILE_UNCHANGED_STUB);
|
|
212
|
+
}
|
|
213
|
+
// After the dedup stub: an unchanged file answers for free no matter how large it is.
|
|
214
|
+
if (args.line_offset === undefined && args.n_lines === undefined && info.size > MAX_UNPAGED_FILE_BYTES) {
|
|
215
|
+
return err(`"${args.path}" is ${String(Math.round(info.size / 1024))} KB, over the ${String(MAX_UNPAGED_FILE_BYTES / 1024)} KB limit for reading a whole file at once. ` +
|
|
216
|
+
"Read a range with `line_offset` (and `n_lines`), or use Grep to find the relevant part first.");
|
|
217
|
+
}
|
|
218
|
+
const rawText = await readTextFile(machine, safePath, { errors: "strict" });
|
|
219
|
+
const outcome = lineOffset < 0
|
|
220
|
+
? readTail(rawText, args.path, lineOffset, requestedLines, range)
|
|
221
|
+
: readForward(rawText, args.path, lineOffset, requestedLines, range);
|
|
222
|
+
if (outcome.result.isError !== true) {
|
|
223
|
+
ctx.fileLedger?.recordRead(safePath, {
|
|
224
|
+
version: fileVersionFromInfo(info),
|
|
225
|
+
...(outcome.fullRead ? { content: normalizeForCompare(rawText) } : {}),
|
|
226
|
+
fullRead: outcome.fullRead,
|
|
227
|
+
range: outcome.range,
|
|
228
|
+
lineEndings: outcome.lineEndings,
|
|
229
|
+
encoding: "utf8",
|
|
230
|
+
readAt: Date.now(),
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return outcome.result;
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
if (isTextDecodeError(error))
|
|
237
|
+
return err(notReadableFileOutput(args.path));
|
|
238
|
+
return err(error instanceof Error ? error.message : String(error));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
async function readImageFile(args, safePath, info, machine, mimeType) {
|
|
242
|
+
if (args.line_offset !== undefined || args.n_lines !== undefined) {
|
|
243
|
+
return err("line_offset and n_lines are only supported for text files.");
|
|
244
|
+
}
|
|
245
|
+
if (info.size === 0)
|
|
246
|
+
return err(`"${args.path}" is empty.`);
|
|
247
|
+
if (info.size > MAX_IMAGE_BYTES) {
|
|
248
|
+
return err(`"${args.path}" is ${String(info.size)} bytes, which exceeds the maximum ${String(MAX_IMAGE_MEGABYTES)}MB for image files.`);
|
|
249
|
+
}
|
|
250
|
+
const data = await machine.readBytes(safePath);
|
|
251
|
+
// Downsample/re-encode oversized images before sending to the model (best
|
|
252
|
+
// effort; the original bytes are returned unchanged on any failure).
|
|
253
|
+
const compressed = await compressImageForModel(data, mimeType);
|
|
254
|
+
const sniffed = sniffImageDimensions(data);
|
|
255
|
+
const originalDimensions = compressed.changed
|
|
256
|
+
? { width: compressed.originalWidth, height: compressed.originalHeight }
|
|
257
|
+
: sniffed;
|
|
258
|
+
const systemText = buildImageSystemSummary({
|
|
259
|
+
mimeType: compressed.mimeType,
|
|
260
|
+
byteSize: info.size,
|
|
261
|
+
originalDimensions: originalDimensions && originalDimensions.width > 0 ? originalDimensions : null,
|
|
262
|
+
compression: compressed.changed
|
|
263
|
+
? {
|
|
264
|
+
width: compressed.width,
|
|
265
|
+
height: compressed.height,
|
|
266
|
+
byteSize: compressed.finalByteLength,
|
|
267
|
+
mimeType: compressed.mimeType,
|
|
268
|
+
}
|
|
269
|
+
: null,
|
|
270
|
+
});
|
|
271
|
+
const imageData = Buffer.isBuffer(compressed.data)
|
|
272
|
+
? compressed.data.toString("base64")
|
|
273
|
+
: Buffer.from(compressed.data).toString("base64");
|
|
274
|
+
return {
|
|
275
|
+
content: [
|
|
276
|
+
{ type: "text", text: systemText },
|
|
277
|
+
{ type: "text", text: `<image path="${safePath}">` },
|
|
278
|
+
{ type: "image", data: imageData, mimeType: compressed.mimeType },
|
|
279
|
+
{ type: "text", text: "</image>" },
|
|
280
|
+
],
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
function buildImageSystemSummary(input) {
|
|
284
|
+
const parts = [`Read image file.`];
|
|
285
|
+
if (input.compression) {
|
|
286
|
+
// A downsampled copy is being sent; be explicit so the model does not treat
|
|
287
|
+
// the reduced resolution as the source of truth.
|
|
288
|
+
parts.push(`Mime type: ${input.compression.mimeType}.`, `Size: ${String(input.compression.byteSize)} bytes (compressed from ${String(input.byteSize)} bytes).`);
|
|
289
|
+
if (input.originalDimensions) {
|
|
290
|
+
parts.push(`Original dimensions: ${String(input.originalDimensions.width)}x${String(input.originalDimensions.height)} pixels.`, `This image was downsampled to ${String(input.compression.width)}x${String(input.compression.height)} pixels before sending. If you need finer detail, read a specific region with a tool that supports it, or ask for the original.`, "If you need to output coordinates, output relative coordinates first and compute absolute coordinates using the original image size.");
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
parts.push(`Mime type: ${input.mimeType}.`, `Size: ${String(input.byteSize)} bytes.`);
|
|
295
|
+
if (input.originalDimensions) {
|
|
296
|
+
parts.push(`Original dimensions: ${String(input.originalDimensions.width)}x${String(input.originalDimensions.height)} pixels.`, "If you need to output coordinates, output relative coordinates first and compute absolute coordinates using the original image size.");
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
parts.push("If you generate or edit images via commands or scripts, read the result back immediately before continuing.");
|
|
300
|
+
return `<system>${parts.join(" ")}</system>`;
|
|
301
|
+
}
|
|
302
|
+
function sniffImageDimensions(data) {
|
|
303
|
+
if (data.length >= 24 && data.subarray(0, 8).equals(Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]))) {
|
|
304
|
+
return { width: data.readUInt32BE(16), height: data.readUInt32BE(20) };
|
|
305
|
+
}
|
|
306
|
+
if (data.length >= 10 && (data.subarray(0, 6).toString("latin1") === "GIF87a" || data.subarray(0, 6).toString("latin1") === "GIF89a")) {
|
|
307
|
+
return { width: data.readUInt16LE(6), height: data.readUInt16LE(8) };
|
|
308
|
+
}
|
|
309
|
+
if (data.length >= 26 && data.subarray(0, 2).toString("latin1") === "BM") {
|
|
310
|
+
return { width: Math.abs(data.readInt32LE(18)), height: Math.abs(data.readInt32LE(22)) };
|
|
311
|
+
}
|
|
312
|
+
return sniffJpegDimensions(data);
|
|
313
|
+
}
|
|
314
|
+
function sniffJpegDimensions(data) {
|
|
315
|
+
if (data.length < 4 || data[0] !== 0xff || data[1] !== 0xd8)
|
|
316
|
+
return null;
|
|
317
|
+
let offset = 2;
|
|
318
|
+
while (offset + 9 < data.length) {
|
|
319
|
+
if (data[offset] !== 0xff)
|
|
320
|
+
return null;
|
|
321
|
+
const marker = data[offset + 1];
|
|
322
|
+
offset += 2;
|
|
323
|
+
if (marker === 0xd8 || marker === 0xd9)
|
|
324
|
+
continue;
|
|
325
|
+
if (offset + 2 > data.length)
|
|
326
|
+
return null;
|
|
327
|
+
const length = data.readUInt16BE(offset);
|
|
328
|
+
if (length < 2 || offset + length > data.length)
|
|
329
|
+
return null;
|
|
330
|
+
if (isJpegStartOfFrame(marker) && length >= 7) {
|
|
331
|
+
return { width: data.readUInt16BE(offset + 5), height: data.readUInt16BE(offset + 3) };
|
|
332
|
+
}
|
|
333
|
+
offset += length;
|
|
334
|
+
}
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
function isJpegStartOfFrame(marker) {
|
|
338
|
+
return ((marker >= 0xc0 && marker <= 0xc3) ||
|
|
339
|
+
(marker >= 0xc5 && marker <= 0xc7) ||
|
|
340
|
+
(marker >= 0xc9 && marker <= 0xcb) ||
|
|
341
|
+
(marker >= 0xcd && marker <= 0xcf));
|
|
342
|
+
}
|
|
343
|
+
function rangeKeyForArgs(args) {
|
|
344
|
+
const lineOffset = args.line_offset ?? 1;
|
|
345
|
+
return {
|
|
346
|
+
lineOffset: lineOffset < 0 ? lineOffset : lineOffset - 1,
|
|
347
|
+
...(args.n_lines !== undefined ? { maxLines: args.n_lines } : {}),
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function rangesEqual(a, b) {
|
|
351
|
+
return a.lineOffset === b.lineOffset && a.maxLines === b.maxLines;
|
|
352
|
+
}
|
|
353
|
+
function toLedgerLineEndings(style) {
|
|
354
|
+
if (style === "crlf")
|
|
355
|
+
return "CRLF";
|
|
356
|
+
if (style === "mixed")
|
|
357
|
+
return "mixed";
|
|
358
|
+
return "LF";
|
|
359
|
+
}
|
|
360
|
+
function errorOutcome(result, range) {
|
|
361
|
+
return { result, fullRead: false, lineEndings: "LF", range };
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Refusal for a range whose rendered output does not fit. It names how many lines DID fit, so
|
|
365
|
+
* the retry is a single obvious call (`n_lines` at or under that) rather than a guess.
|
|
366
|
+
*/
|
|
367
|
+
function outputTooLargeOutcome(displayPath, startLine, linesThatFit, range) {
|
|
368
|
+
const suggestion = linesThatFit > 0
|
|
369
|
+
? `About ${String(linesThatFit)} lines from line ${String(startLine)} fit — retry with \`n_lines\` at or below that`
|
|
370
|
+
: "Even a single line of this range exceeds the limit";
|
|
371
|
+
return errorOutcome(err(`Reading "${displayPath}" from line ${String(startLine)} produces more than ${String(MAX_BYTES / 1024)} KB of output. ` +
|
|
372
|
+
`${suggestion}, or narrow the search with Grep.`), range);
|
|
373
|
+
}
|
|
374
|
+
function readForward(text, displayPath, lineOffset, limit, range) {
|
|
375
|
+
const selectedEntries = [];
|
|
376
|
+
const flags = { hasCrLf: false, hasLf: false, hasLoneCr: false };
|
|
377
|
+
let currentLineNo = 0;
|
|
378
|
+
// The whole file is walked even once `limit` is met: `totalLines` in the footer is the
|
|
379
|
+
// file's real length, not how far the read happened to get.
|
|
380
|
+
for (const rawLine of readLinesStrict(text)) {
|
|
381
|
+
if (containsNulByte(rawLine))
|
|
382
|
+
return errorOutcome(err(notReadableFileOutput(displayPath)), range);
|
|
383
|
+
currentLineNo += 1;
|
|
384
|
+
updateLineEndingFlags(flags, rawLine);
|
|
385
|
+
if (currentLineNo < lineOffset || selectedEntries.length >= limit)
|
|
386
|
+
continue;
|
|
387
|
+
selectedEntries.push({ lineNo: currentLineNo, rawContent: stripTrailingLf(rawLine) });
|
|
388
|
+
}
|
|
389
|
+
const lineEndingStyle = lineEndingStyleFromFlags(flags);
|
|
390
|
+
const renderedLines = [];
|
|
391
|
+
const truncatedLineNumbers = [];
|
|
392
|
+
let bytes = 0;
|
|
393
|
+
for (const entry of selectedEntries) {
|
|
394
|
+
const rendered = renderLine(entry, lineEndingStyle);
|
|
395
|
+
const lineBytes = renderedLineBytes(rendered.line, renderedLines.length === 0);
|
|
396
|
+
if (bytes + lineBytes > MAX_BYTES) {
|
|
397
|
+
return outputTooLargeOutcome(displayPath, lineOffset, renderedLines.length, range);
|
|
398
|
+
}
|
|
399
|
+
if (rendered.wasTruncated)
|
|
400
|
+
truncatedLineNumbers.push(entry.lineNo);
|
|
401
|
+
renderedLines.push(rendered.line);
|
|
402
|
+
bytes += lineBytes;
|
|
403
|
+
}
|
|
404
|
+
const result = finishReadResult({
|
|
405
|
+
renderedLines,
|
|
406
|
+
truncatedLineNumbers,
|
|
407
|
+
lineEndingStyle,
|
|
408
|
+
startLine: renderedLines.length > 0 ? lineOffset : 0,
|
|
409
|
+
totalLines: currentLineNo,
|
|
410
|
+
requestedLines: limit,
|
|
411
|
+
});
|
|
412
|
+
return {
|
|
413
|
+
result,
|
|
414
|
+
// Every line of the file, none of them cut short. Reaching a limit no longer produces a
|
|
415
|
+
// result at all, so the only ways to fall short here are an offset past line 1 or an
|
|
416
|
+
// over-long line that had to be clipped.
|
|
417
|
+
fullRead: lineOffset === 1 && truncatedLineNumbers.length === 0 && renderedLines.length === currentLineNo,
|
|
418
|
+
lineEndings: toLedgerLineEndings(lineEndingStyle),
|
|
419
|
+
range,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
function readTail(text, displayPath, lineOffset, limit, range) {
|
|
423
|
+
const tailCount = Math.abs(lineOffset);
|
|
424
|
+
const entries = [];
|
|
425
|
+
const flags = { hasCrLf: false, hasLf: false, hasLoneCr: false };
|
|
426
|
+
let currentLineNo = 0;
|
|
427
|
+
for (const rawLine of readLinesStrict(text)) {
|
|
428
|
+
if (containsNulByte(rawLine))
|
|
429
|
+
return errorOutcome(err(notReadableFileOutput(displayPath)), range);
|
|
430
|
+
currentLineNo += 1;
|
|
431
|
+
updateLineEndingFlags(flags, rawLine);
|
|
432
|
+
entries.push({ lineNo: currentLineNo, rawContent: stripTrailingLf(rawLine) });
|
|
433
|
+
if (entries.length > tailCount)
|
|
434
|
+
entries.shift();
|
|
435
|
+
}
|
|
436
|
+
const lineEndingStyle = lineEndingStyleFromFlags(flags);
|
|
437
|
+
const renderedCandidates = entries.slice(0, limit).map((entry) => ({
|
|
438
|
+
entry,
|
|
439
|
+
rendered: renderLine(entry, lineEndingStyle),
|
|
440
|
+
}));
|
|
441
|
+
const renderedLines = [];
|
|
442
|
+
const truncatedLineNumbers = [];
|
|
443
|
+
let bytes = 0;
|
|
444
|
+
for (const [index, candidate] of renderedCandidates.entries()) {
|
|
445
|
+
const lineBytes = renderedLineBytes(candidate.rendered.line, index === 0);
|
|
446
|
+
if (bytes + lineBytes > MAX_BYTES) {
|
|
447
|
+
// A tail read that does not fit is refused like any other range. Silently keeping the
|
|
448
|
+
// last N that fit would answer "the last 500 lines" with some other number of lines.
|
|
449
|
+
return outputTooLargeOutcome(displayPath, candidate.entry.lineNo, renderedLines.length, range);
|
|
450
|
+
}
|
|
451
|
+
renderedLines.push(candidate.rendered.line);
|
|
452
|
+
if (candidate.rendered.wasTruncated)
|
|
453
|
+
truncatedLineNumbers.push(candidate.entry.lineNo);
|
|
454
|
+
bytes += lineBytes;
|
|
455
|
+
}
|
|
456
|
+
const result = finishReadResult({
|
|
457
|
+
renderedLines,
|
|
458
|
+
truncatedLineNumbers,
|
|
459
|
+
lineEndingStyle,
|
|
460
|
+
startLine: renderedCandidates[0]?.entry.lineNo ?? 0,
|
|
461
|
+
totalLines: currentLineNo,
|
|
462
|
+
requestedLines: limit,
|
|
463
|
+
});
|
|
464
|
+
return {
|
|
465
|
+
result,
|
|
466
|
+
fullRead: false,
|
|
467
|
+
lineEndings: toLedgerLineEndings(lineEndingStyle),
|
|
468
|
+
range,
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
function finishReadResult(input) {
|
|
472
|
+
return ok(finishOutput(input.renderedLines, finishMessage(input)));
|
|
473
|
+
}
|
|
474
|
+
function finishOutput(renderedLines, message) {
|
|
475
|
+
const rendered = renderedLines.join("\n");
|
|
476
|
+
const status = `<system>${message}</system>`;
|
|
477
|
+
return rendered.length > 0 ? `${rendered}\n${status}` : status;
|
|
478
|
+
}
|
|
479
|
+
function finishMessage(input) {
|
|
480
|
+
const lineCount = input.renderedLines.length;
|
|
481
|
+
const lineWord = lineCount === 1 ? "line" : "lines";
|
|
482
|
+
const parts = lineCount > 0
|
|
483
|
+
? [`${String(lineCount)} ${lineWord} read from file starting from line ${String(input.startLine)}.`]
|
|
484
|
+
: ["No lines read from file."];
|
|
485
|
+
parts.push(`Total lines in file: ${String(input.totalLines)}.`);
|
|
486
|
+
// Fewer lines than asked for can only mean the file ran out — a limit reached mid-range is
|
|
487
|
+
// now a refusal, so no result ever carries a silent shortfall.
|
|
488
|
+
if (lineCount < input.requestedLines)
|
|
489
|
+
parts.push("End of file reached.");
|
|
490
|
+
if (input.truncatedLineNumbers.length > 0) {
|
|
491
|
+
parts.push(`Lines [${input.truncatedLineNumbers.join(", ")}] were truncated.`);
|
|
492
|
+
}
|
|
493
|
+
if (input.lineEndingStyle === "mixed") {
|
|
494
|
+
parts.push("Mixed or lone carriage-return line endings are shown as \\r. Use exact \\r\\n or \\r escapes in Edit.old_string for those lines.");
|
|
495
|
+
}
|
|
496
|
+
return parts.join(" ");
|
|
497
|
+
}
|
|
498
|
+
//# sourceMappingURL=read.js.map
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { ToolAccesses } from "../access.js";
|
|
4
|
+
import { defineTool } from "../define.js";
|
|
5
|
+
import { FileExistsError, StaleFileError } from "../machine.js";
|
|
6
|
+
import { checkFreshness, FILE_MODIFIED_MESSAGE, FILE_NOT_READ_MESSAGE } from "../file-freshness.js";
|
|
7
|
+
import { fileVersionFromInfo, normalizeForCompare } from "../support/machine-ops.js";
|
|
8
|
+
import { pathApproval, resolveToolPath } from "../support/tool-path.js";
|
|
9
|
+
import { detectLineEndingStyle, materializeModelText } from "./line-endings.js";
|
|
10
|
+
const WriteInput = z.object({
|
|
11
|
+
path: z
|
|
12
|
+
.string()
|
|
13
|
+
.describe("Path to the file to create, append to, or completely overwrite. Relative paths resolve against the working directory; a path outside the working directory must be absolute. The parent directory must already exist."),
|
|
14
|
+
content: z
|
|
15
|
+
.string()
|
|
16
|
+
.describe("Content to write. Overwrite writes this exactly as the full file content. Append adds this content to the end without inserting a newline."),
|
|
17
|
+
mode: z
|
|
18
|
+
.enum(["overwrite", "append"])
|
|
19
|
+
.optional()
|
|
20
|
+
.describe("Write mode. Defaults to overwrite. append adds content to the end without adding a newline."),
|
|
21
|
+
});
|
|
22
|
+
const WRITE_DESCRIPTION = [
|
|
23
|
+
"Overwrite or append to a file, creating the file if needed; the parent directory must already exist. Defaults to overwrite; append adds content to the end without adding a newline. Write does not use the Read/Edit model text view and writes content exactly as provided — `\\n` stays LF, `\\r\\n` stays CRLF. The one exception: appending to a file whose existing lines are all CRLF writes your `\\n` as CRLF too, so the file stays consistent. Use Edit for targeted changes to existing files. When the content is very large, you can split it across multiple calls: write the first chunk with overwrite, then add the remaining chunks with append.",
|
|
24
|
+
"",
|
|
25
|
+
"For an existing file you must Read it first; Write fails otherwise. Overwrite replaces the ENTIRE file — whatever you did not read is replaced too, so prefer Edit for changing part of a file and keep Write for new files and complete rewrites. Reading the file in full (no paging) also lets Write tell a real concurrent change from a timestamp that merely moved. Creating a missing file does not require a prior Read.",
|
|
26
|
+
"Never use Write to talk to the user — output text directly.",
|
|
27
|
+
].join("\n");
|
|
28
|
+
export const writeTool = defineTool({
|
|
29
|
+
name: "Write",
|
|
30
|
+
description: WRITE_DESCRIPTION,
|
|
31
|
+
params: WriteInput,
|
|
32
|
+
// Expose path + content so the judge can see what is being written (e.g. a curl|bash
|
|
33
|
+
// payload, an SSH key), projected as `${file_path}: ${content}`.
|
|
34
|
+
toAutoApprovalInput: (args) => `${args.path}: ${args.content}`,
|
|
35
|
+
async resolve(args, ctx) {
|
|
36
|
+
const path = await resolveToolPath(args.path, ctx.machine, "write");
|
|
37
|
+
return {
|
|
38
|
+
accesses: ToolAccesses.writeFile(path),
|
|
39
|
+
display: { title: `Writing ${args.path}` },
|
|
40
|
+
...pathApproval("Write", ctx.machine, path),
|
|
41
|
+
run: (runCtx) => execute(args, path, runCtx),
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
async function execute(args, safePath, ctx) {
|
|
46
|
+
const machine = ctx.machine;
|
|
47
|
+
const parentError = await checkParentDirectory(safePath, machine);
|
|
48
|
+
if (parentError !== undefined)
|
|
49
|
+
return errorResult(parentError);
|
|
50
|
+
try {
|
|
51
|
+
const mode = args.mode ?? "overwrite";
|
|
52
|
+
const info = await statOrUndefined(machine, safePath);
|
|
53
|
+
if (info !== undefined)
|
|
54
|
+
await validateWrite(safePath, ctx);
|
|
55
|
+
const ledger = ctx.fileLedger;
|
|
56
|
+
const record = info !== undefined ? ledger?.get(safePath) : undefined;
|
|
57
|
+
let nextContent = args.content;
|
|
58
|
+
let writtenContent = args.content;
|
|
59
|
+
if (mode === "append") {
|
|
60
|
+
// Append composed from the core members: read-concat-write. Fine for the
|
|
61
|
+
// tool's occasional appends; high-frequency log appends belong elsewhere.
|
|
62
|
+
let prior = "";
|
|
63
|
+
try {
|
|
64
|
+
prior = (await machine.readBytes(safePath)).toString("utf8");
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error.code !== "ENOENT")
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
const priorLineEndings = detectLineEndingStyle(prior);
|
|
71
|
+
writtenContent =
|
|
72
|
+
prior.length > 0 && priorLineEndings === "crlf"
|
|
73
|
+
? materializeModelText(args.content, priorLineEndings)
|
|
74
|
+
: args.content;
|
|
75
|
+
nextContent = prior + writtenContent;
|
|
76
|
+
}
|
|
77
|
+
const result = await machine.writeTextIfUnchanged(safePath, nextContent, {
|
|
78
|
+
expected: info !== undefined ? record.version : "must-not-exist",
|
|
79
|
+
// Only a full read's content can be compared against the whole file; a paged
|
|
80
|
+
// record's text would differ from it by definition and read as a conflict.
|
|
81
|
+
...(record?.fullRead === true && record.content !== undefined ? { expectedContent: record.content } : {}),
|
|
82
|
+
});
|
|
83
|
+
ledger?.recordWrite(safePath, result.version, {
|
|
84
|
+
content: normalizeForCompare(nextContent),
|
|
85
|
+
lineEndings: toLedgerLineEndings(detectLineEndingStyle(nextContent)),
|
|
86
|
+
encoding: "utf8",
|
|
87
|
+
});
|
|
88
|
+
// Report UTF-8 bytes written; string length only equals byte count for pure ASCII.
|
|
89
|
+
const bytesWritten = Buffer.byteLength(writtenContent, "utf8");
|
|
90
|
+
return textResult(`${mode === "append" ? "Appended" : "Wrote"} ${String(bytesWritten)} bytes to ${args.path}`);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
if (error instanceof StaleFileError || error instanceof FileExistsError)
|
|
94
|
+
return errorResult(FILE_MODIFIED_MESSAGE);
|
|
95
|
+
const code = error?.code;
|
|
96
|
+
if (code === "ENOENT") {
|
|
97
|
+
return errorResult(`Failed to write ${args.path}: parent directory does not exist.`);
|
|
98
|
+
}
|
|
99
|
+
return errorResult(error instanceof Error ? error.message : String(error));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function requireLedger(ctx) {
|
|
103
|
+
if (ctx.fileLedger === undefined) {
|
|
104
|
+
throw new Error("File freshness tracking unavailable - cannot verify read-before-write safety for this session.");
|
|
105
|
+
}
|
|
106
|
+
return ctx.fileLedger;
|
|
107
|
+
}
|
|
108
|
+
async function statOrUndefined(machine, path) {
|
|
109
|
+
try {
|
|
110
|
+
return await machine.fileInfo(path);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
const code = error.code;
|
|
114
|
+
if (code === "ENOENT" || code === "ENOTDIR")
|
|
115
|
+
return undefined;
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async function validateWrite(path, ctx) {
|
|
120
|
+
const info = await statOrUndefined(ctx.machine, path);
|
|
121
|
+
if (info === undefined)
|
|
122
|
+
return;
|
|
123
|
+
const ledger = requireLedger(ctx);
|
|
124
|
+
// "Has this agent seen the file", not "did it see all of it" — see the same gate in
|
|
125
|
+
// edit.ts. Overwriting a file the model only paged through DOES discard the part it
|
|
126
|
+
// never saw — an accepted trade, since the alternative locks Write out of every
|
|
127
|
+
// file past the Read tool's caps.
|
|
128
|
+
const record = ledger.get(path);
|
|
129
|
+
if (record === undefined)
|
|
130
|
+
throw new Error(FILE_NOT_READ_MESSAGE);
|
|
131
|
+
const verdict = await checkFreshness({
|
|
132
|
+
ledger,
|
|
133
|
+
path,
|
|
134
|
+
current: fileVersionFromInfo(info),
|
|
135
|
+
currentContent: async () => {
|
|
136
|
+
try {
|
|
137
|
+
return normalizeForCompare((await ctx.machine.readBytes(path)).toString(record.encoding));
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
if (verdict.kind === "not-read")
|
|
145
|
+
throw new Error(FILE_NOT_READ_MESSAGE);
|
|
146
|
+
if (verdict.kind === "stale")
|
|
147
|
+
throw new Error(FILE_MODIFIED_MESSAGE);
|
|
148
|
+
}
|
|
149
|
+
function toLedgerLineEndings(style) {
|
|
150
|
+
if (style === "crlf")
|
|
151
|
+
return "CRLF";
|
|
152
|
+
if (style === "mixed")
|
|
153
|
+
return "mixed";
|
|
154
|
+
return "LF";
|
|
155
|
+
}
|
|
156
|
+
async function checkParentDirectory(safePath, machine) {
|
|
157
|
+
const parent = dirname(safePath);
|
|
158
|
+
let info;
|
|
159
|
+
try {
|
|
160
|
+
info = await machine.fileInfo(parent);
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
if (error.code === "ENOENT") {
|
|
164
|
+
return `Parent directory does not exist: ${parent}. Create it before writing this file.`;
|
|
165
|
+
}
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
if (info.kind !== "dir") {
|
|
169
|
+
return `Parent path is not a directory: ${parent}.`;
|
|
170
|
+
}
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
function errorResult(text) {
|
|
174
|
+
return { content: [{ type: "text", text }], isError: true };
|
|
175
|
+
}
|
|
176
|
+
function textResult(text) {
|
|
177
|
+
return { content: [{ type: "text", text }] };
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=write.js.map
|