@theokit/sdk 1.5.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/CHANGELOG.md +1571 -0
- package/LICENSE +201 -0
- package/README.md +80 -0
- package/bin/theokit-migrate-config.mjs +269 -0
- package/bin/theokit-migrate-memory.mjs +116 -0
- package/dist/agent-builder.d.ts +52 -0
- package/dist/agent-factory.d.ts +39 -0
- package/dist/agent.d.ts +175 -0
- package/dist/batch.d.ts +11 -0
- package/dist/budget.d.ts +48 -0
- package/dist/cache.d.ts +74 -0
- package/dist/cron-1yxL3K2S.d.cts +221 -0
- package/dist/cron-BYVdYzob.d.ts +221 -0
- package/dist/cron.cjs +14655 -0
- package/dist/cron.cjs.map +1 -0
- package/dist/cron.d.cts +3 -0
- package/dist/cron.d.ts +71 -0
- package/dist/cron.js +14652 -0
- package/dist/cron.js.map +1 -0
- package/dist/define-tool.d.ts +35 -0
- package/dist/errors-CK8brCJ1.d.cts +448 -0
- package/dist/errors-CvAeEWgE.d.ts +448 -0
- package/dist/errors.cjs +255 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +3 -0
- package/dist/errors.d.ts +356 -0
- package/dist/errors.js +238 -0
- package/dist/errors.js.map +1 -0
- package/dist/eval.cjs +14826 -0
- package/dist/eval.cjs.map +1 -0
- package/dist/eval.d.cts +35 -0
- package/dist/eval.d.ts +35 -0
- package/dist/eval.js +14821 -0
- package/dist/eval.js.map +1 -0
- package/dist/generate-object.d.ts +67 -0
- package/dist/handoff.d.ts +55 -0
- package/dist/index.cjs +17127 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1878 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +17095 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/agent-loop/loop-types.d.ts +29 -0
- package/dist/internal/agent-loop/loop.d.ts +2 -0
- package/dist/internal/agent-loop/message-builders.d.ts +6 -0
- package/dist/internal/agent-loop/tool-dispatch.d.ts +4 -0
- package/dist/internal/agent-loop/usage-and-cost.d.ts +25 -0
- package/dist/internal/budget/calendar-window.d.ts +19 -0
- package/dist/internal/budget/compute-cost.d.ts +28 -0
- package/dist/internal/budget/enforcement.d.ts +32 -0
- package/dist/internal/budget/ledger.d.ts +25 -0
- package/dist/internal/budget/normalize-usage.d.ts +27 -0
- package/dist/internal/budget/pricing-registry.d.ts +36 -0
- package/dist/internal/budget/registry.d.ts +16 -0
- package/dist/internal/budget/usage-accumulator.d.ts +31 -0
- package/dist/internal/cache/cosine.d.ts +14 -0
- package/dist/internal/cache/embed-helper.d.ts +15 -0
- package/dist/internal/cache/key.d.ts +15 -0
- package/dist/internal/cache/lookup.d.ts +28 -0
- package/dist/internal/cache/store-handler.d.ts +24 -0
- package/dist/internal/cache/store-json.d.ts +48 -0
- package/dist/internal/cache/store.d.ts +54 -0
- package/dist/internal/cache/telemetry.d.ts +20 -0
- package/dist/internal/cache/ttl.d.ts +11 -0
- package/dist/internal/catalog/fixtures.d.ts +16 -0
- package/dist/internal/catalog/local-models.d.ts +24 -0
- package/dist/internal/cron/run-job.d.ts +1 -0
- package/dist/internal/cron/scheduler.d.ts +1 -0
- package/dist/internal/cron/store.d.ts +1 -0
- package/dist/internal/cron/validate.d.ts +1 -0
- package/dist/internal/env.d.ts +1 -0
- package/dist/internal/errors/mappers/anthropic.d.ts +30 -0
- package/dist/internal/errors/mappers/bedrock.d.ts +16 -0
- package/dist/internal/errors/mappers/ollama.d.ts +41 -0
- package/dist/internal/errors/mappers/openai-compatible.d.ts +25 -0
- package/dist/internal/errors/mappers/shared.d.ts +10 -0
- package/dist/internal/errors/mappers/vertex.d.ts +15 -0
- package/dist/internal/eval/aggregate.d.ts +9 -0
- package/dist/internal/eval/dataset-iter.d.ts +9 -0
- package/dist/internal/eval/runner.d.ts +9 -0
- package/dist/internal/eval/single-flight.d.ts +16 -0
- package/dist/internal/eval/telemetry.d.ts +23 -0
- package/dist/internal/fixture-mode.d.ts +16 -0
- package/dist/internal/handoff/dispatcher.d.ts +29 -0
- package/dist/internal/handoff/registry.d.ts +23 -0
- package/dist/internal/handoff/telemetry.d.ts +18 -0
- package/dist/internal/handoff/tool-injector.d.ts +34 -0
- package/dist/internal/http.d.ts +1 -0
- package/dist/internal/ids.d.ts +1 -0
- package/dist/internal/judge/judge-call.d.ts +35 -0
- package/dist/internal/judge/parse-verdict.d.ts +11 -0
- package/dist/internal/judge/types.d.ts +17 -0
- package/dist/internal/llm/anthropic-shared.d.ts +89 -0
- package/dist/internal/llm/anthropic.d.ts +9 -0
- package/dist/internal/llm/bedrock-anthropic.d.ts +36 -0
- package/dist/internal/llm/bedrock-token-cache.d.ts +18 -0
- package/dist/internal/llm/credential-pool-context.d.ts +11 -0
- package/dist/internal/llm/credential-pool-types.d.ts +22 -0
- package/dist/internal/llm/credential-pool.d.ts +18 -0
- package/dist/internal/llm/fallback-client.d.ts +1 -0
- package/dist/internal/llm/fault-injection.d.ts +50 -0
- package/dist/internal/llm/finish.d.ts +1 -0
- package/dist/internal/llm/model-identifier.d.ts +24 -0
- package/dist/internal/llm/ollama-native.d.ts +27 -0
- package/dist/internal/llm/openai.d.ts +9 -0
- package/dist/internal/llm/pool-aware-client.d.ts +16 -0
- package/dist/internal/llm/router.d.ts +17 -0
- package/dist/internal/llm/sse.d.ts +9 -0
- package/dist/internal/llm/stream-relay.d.ts +17 -0
- package/dist/internal/llm/types.d.ts +70 -0
- package/dist/internal/llm/vertex-anthropic.d.ts +40 -0
- package/dist/internal/llm/vertex-auth.d.ts +30 -0
- package/dist/internal/llm/vertex-gemini.d.ts +28 -0
- package/dist/internal/llm/vertex-router.d.ts +21 -0
- package/dist/internal/mcp/client.d.ts +16 -0
- package/dist/internal/memory/active-memory-cache.d.ts +10 -0
- package/dist/internal/memory/active-memory.d.ts +45 -0
- package/dist/internal/memory/adapters/catalog.d.ts +1 -0
- package/dist/internal/memory/adapters/deepinfra-embedding.d.ts +2 -0
- package/dist/internal/memory/adapters/mistral-embedding.d.ts +2 -0
- package/dist/internal/memory/adapters/ollama-embedding.d.ts +34 -0
- package/dist/internal/memory/adapters/openai-compatible.d.ts +23 -0
- package/dist/internal/memory/adapters/openai-embedding.d.ts +2 -0
- package/dist/internal/memory/adapters/openrouter-embedding.d.ts +2 -0
- package/dist/internal/memory/adapters/voyage-embedding.d.ts +2 -0
- package/dist/internal/memory/atomic-write.d.ts +7 -0
- package/dist/internal/memory/chunk-markdown.d.ts +2 -0
- package/dist/internal/memory/circuit-breaker.d.ts +22 -0
- package/dist/internal/memory/cwd-mutex.d.ts +1 -0
- package/dist/internal/memory/dreaming/diary.d.ts +4 -0
- package/dist/internal/memory/dreaming/phases.d.ts +15 -0
- package/dist/internal/memory/dreaming/run.d.ts +10 -0
- package/dist/internal/memory/embedding-adapter.d.ts +42 -0
- package/dist/internal/memory/embedding-cache.d.ts +1 -0
- package/dist/internal/memory/index-db.d.ts +10 -0
- package/dist/internal/memory/index-manager-dispatch.d.ts +23 -0
- package/dist/internal/memory/index-manager.d.ts +68 -0
- package/dist/internal/memory/index-schema.d.ts +21 -0
- package/dist/internal/memory/lance-index.d.ts +32 -0
- package/dist/internal/memory/lance-memory-adapter.d.ts +43 -0
- package/dist/internal/memory/markdown-store.d.ts +16 -0
- package/dist/internal/memory/memory-index.d.ts +52 -0
- package/dist/internal/memory/migrate-sqlite-to-lance.d.ts +15 -0
- package/dist/internal/memory/migration.d.ts +9 -0
- package/dist/internal/memory/reader.d.ts +8 -0
- package/dist/internal/memory/session-loader.d.ts +1 -0
- package/dist/internal/memory/session-summary-writer.d.ts +2 -0
- package/dist/internal/memory/sqlite-vec-loader.d.ts +3 -0
- package/dist/internal/memory/tools.d.ts +14 -0
- package/dist/internal/memory/transcript-store.d.ts +1 -0
- package/dist/internal/memory/types.d.ts +17 -0
- package/dist/internal/memory/vec-index.d.ts +28 -0
- package/dist/internal/memory/wiki-loader.d.ts +2 -0
- package/dist/internal/observability/tracer-loader.d.ts +20 -0
- package/dist/internal/persistence/atomic-write.d.ts +1 -0
- package/dist/internal/persistence/conversation-storage-fs.d.ts +37 -0
- package/dist/internal/persistence/conversation-storage-memory.d.ts +24 -0
- package/dist/internal/persistence/cwd-mutex.d.ts +1 -0
- package/dist/internal/persistence/file-lock.d.ts +14 -0
- package/dist/internal/persistence/fts5-sanitize.d.ts +16 -0
- package/dist/internal/persistence/markdown-config-loader.d.ts +35 -0
- package/dist/internal/persistence/paths.d.ts +19 -0
- package/dist/internal/persistence/persistence-schema.d.ts +17 -0
- package/dist/internal/persistence/schema-version.d.ts +13 -0
- package/dist/internal/persistence/sqlite-wal.d.ts +10 -0
- package/dist/internal/personality/context.d.ts +17 -0
- package/dist/internal/personality/registry.d.ts +17 -0
- package/dist/internal/personality/store.d.ts +27 -0
- package/dist/internal/personality/switch.d.ts +36 -0
- package/dist/internal/personality/types.d.ts +18 -0
- package/dist/internal/plugins/context.d.ts +31 -0
- package/dist/internal/plugins/manager.d.ts +37 -0
- package/dist/internal/plugins/types.d.ts +102 -0
- package/dist/internal/providers/builtin/anthropic.d.ts +2 -0
- package/dist/internal/providers/builtin/bedrock.d.ts +25 -0
- package/dist/internal/providers/builtin/gemini.d.ts +10 -0
- package/dist/internal/providers/builtin/index.d.ts +19 -0
- package/dist/internal/providers/builtin/llamacpp.d.ts +1 -0
- package/dist/internal/providers/builtin/lmstudio.d.ts +1 -0
- package/dist/internal/providers/builtin/ollama.d.ts +17 -0
- package/dist/internal/providers/builtin/openai.d.ts +2 -0
- package/dist/internal/providers/builtin/openrouter.d.ts +2 -0
- package/dist/internal/providers/builtin/vertex.d.ts +27 -0
- package/dist/internal/providers/discovery.d.ts +14 -0
- package/dist/internal/providers/index.d.ts +8 -0
- package/dist/internal/providers/registry.d.ts +12 -0
- package/dist/internal/providers/types.d.ts +27 -0
- package/dist/internal/runtime/abort-utils.d.ts +21 -0
- package/dist/internal/runtime/agent-factory-registry.d.ts +16 -0
- package/dist/internal/runtime/agent-registry-store.d.ts +61 -0
- package/dist/internal/runtime/agent-registry.d.ts +34 -0
- package/dist/internal/runtime/agent-session-store.d.ts +3 -0
- package/dist/internal/runtime/agent-session.d.ts +2 -0
- package/dist/internal/runtime/async-local-storage.d.ts +20 -0
- package/dist/internal/runtime/async-semaphore.d.ts +24 -0
- package/dist/internal/runtime/budget.d.ts +36 -0
- package/dist/internal/runtime/cloud-agent.d.ts +1 -0
- package/dist/internal/runtime/cloud-config-serializer.d.ts +3 -0
- package/dist/internal/runtime/cloud-payload-types.d.ts +56 -0
- package/dist/internal/runtime/cloud-run.d.ts +1 -0
- package/dist/internal/runtime/cloud-tool-parity.d.ts +1 -0
- package/dist/internal/runtime/context-aggregator.d.ts +26 -0
- package/dist/internal/runtime/context-discovery-runner.d.ts +27 -0
- package/dist/internal/runtime/context-discovery.d.ts +21 -0
- package/dist/internal/runtime/context-frontmatter.d.ts +16 -0
- package/dist/internal/runtime/context-import-resolver.d.ts +24 -0
- package/dist/internal/runtime/context-loaders.d.ts +42 -0
- package/dist/internal/runtime/context-manager.d.ts +11 -0
- package/dist/internal/runtime/context-mdc-parser.d.ts +24 -0
- package/dist/internal/runtime/default-model.d.ts +1 -0
- package/dist/internal/runtime/fixture-events.d.ts +12 -0
- package/dist/internal/runtime/fixture-responder.d.ts +1 -0
- package/dist/internal/runtime/fixture-run-base.d.ts +45 -0
- package/dist/internal/runtime/fixture-scripts.d.ts +21 -0
- package/dist/internal/runtime/fixture-types.d.ts +1 -0
- package/dist/internal/runtime/fork-agent.d.ts +15 -0
- package/dist/internal/runtime/hooks-executor.d.ts +35 -0
- package/dist/internal/runtime/hooks-frontmatter.d.ts +26 -0
- package/dist/internal/runtime/hooks-source.d.ts +22 -0
- package/dist/internal/runtime/live-agent-registry.d.ts +87 -0
- package/dist/internal/runtime/local-agent-bootstrap.d.ts +37 -0
- package/dist/internal/runtime/local-agent-dispatch.d.ts +57 -0
- package/dist/internal/runtime/local-agent-invalidate.d.ts +8 -0
- package/dist/internal/runtime/local-agent-memory-direct.d.ts +12 -0
- package/dist/internal/runtime/local-agent-memory-hooks.d.ts +41 -0
- package/dist/internal/runtime/local-agent-memory.d.ts +1 -0
- package/dist/internal/runtime/local-agent-personality-extensions.d.ts +19 -0
- package/dist/internal/runtime/local-agent-plugins.d.ts +13 -0
- package/dist/internal/runtime/local-agent-runtime-extensions.d.ts +13 -0
- package/dist/internal/runtime/local-agent-task-wrap.d.ts +11 -0
- package/dist/internal/runtime/local-agent.d.ts +1 -0
- package/dist/internal/runtime/local-run.d.ts +1 -0
- package/dist/internal/runtime/memory-store.d.ts +4 -0
- package/dist/internal/runtime/plugin-frontmatter.d.ts +17 -0
- package/dist/internal/runtime/plugins-manager.d.ts +1 -0
- package/dist/internal/runtime/post-run-lifecycle.d.ts +1 -0
- package/dist/internal/runtime/providers-manager.d.ts +1 -0
- package/dist/internal/runtime/real-cloud-run.d.ts +2 -0
- package/dist/internal/runtime/real-local-run.d.ts +2 -0
- package/dist/internal/runtime/run-registry.d.ts +5 -0
- package/dist/internal/runtime/run-until.d.ts +22 -0
- package/dist/internal/runtime/shell-tool.d.ts +7 -0
- package/dist/internal/runtime/skill-frontmatter.d.ts +1 -0
- package/dist/internal/runtime/skills-manager.d.ts +1 -0
- package/dist/internal/runtime/spawn-collect.d.ts +8 -0
- package/dist/internal/runtime/subagents-loader.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/escape.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/local-assembly.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/pipeline.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/providers/active-memory-provider.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/providers/base-provider.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/providers/context-provider.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/providers/memory-provider.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/providers/skills-provider.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/safe-call.d.ts +1 -0
- package/dist/internal/runtime/system-prompt/types.d.ts +5 -0
- package/dist/internal/runtime/system-prompt.d.ts +1 -0
- package/dist/internal/runtime/validate-agent-options.d.ts +1 -0
- package/dist/internal/runtime/workspace-dir.d.ts +9 -0
- package/dist/internal/runtime/yaml-frontmatter.d.ts +20 -0
- package/dist/internal/scorers/llm-judge.d.ts +24 -0
- package/dist/internal/security/index.d.ts +11 -0
- package/dist/internal/security/path-guard.d.ts +56 -0
- package/dist/internal/security/redact.d.ts +21 -0
- package/dist/internal/structured-output-helpers.d.ts +54 -0
- package/dist/internal/task/registry.d.ts +61 -0
- package/dist/internal/task/ring-buffer.d.ts +10 -0
- package/dist/internal/task/store.d.ts +59 -0
- package/dist/internal/task/subscribe.d.ts +15 -0
- package/dist/internal/task/telemetry.d.ts +27 -0
- package/dist/internal/telemetry/adapter-registry.d.ts +2 -0
- package/dist/internal/telemetry/adapters/langfuse.d.ts +2 -0
- package/dist/internal/telemetry/adapters/posthog.d.ts +2 -0
- package/dist/internal/telemetry/adapters/sentry.d.ts +2 -0
- package/dist/internal/telemetry/safe-require.d.ts +1 -0
- package/dist/internal/telemetry/tracer.d.ts +18 -0
- package/dist/internal/tool-dispatch/repair-middleware.d.ts +34 -0
- package/dist/internal/tool-dispatch/strip-think.d.ts +22 -0
- package/dist/internal/tool-registry/personality-filter.d.ts +37 -0
- package/dist/internal/workflow/ctx.d.ts +19 -0
- package/dist/internal/workflow/error-shape.d.ts +7 -0
- package/dist/internal/workflow/executor.d.ts +15 -0
- package/dist/internal/workflow/index.d.ts +12 -0
- package/dist/internal/workflow/retry-policy.d.ts +14 -0
- package/dist/internal/workflow/run-id.d.ts +9 -0
- package/dist/internal/workflow/single-flight.d.ts +18 -0
- package/dist/internal/workflow/snapshot-store.d.ts +23 -0
- package/dist/internal/workflow/step-agent.d.ts +12 -0
- package/dist/internal/workflow/step-branch.d.ts +10 -0
- package/dist/internal/workflow/step-dowhile.d.ts +8 -0
- package/dist/internal/workflow/step-fn.d.ts +10 -0
- package/dist/internal/workflow/step-foreach.d.ts +11 -0
- package/dist/internal/workflow/step-parallel.d.ts +17 -0
- package/dist/internal/workflow/step-sleep.d.ts +7 -0
- package/dist/internal/workflow/telemetry.d.ts +23 -0
- package/dist/internal/zod/to-json-schema.d.ts +21 -0
- package/dist/memory-adapter-helpers.d.ts +28 -0
- package/dist/memory.d.ts +123 -0
- package/dist/migrate.d.ts +33 -0
- package/dist/path-safety.cjs +126 -0
- package/dist/path-safety.cjs.map +1 -0
- package/dist/path-safety.d.cts +15 -0
- package/dist/path-safety.d.ts +15 -0
- package/dist/path-safety.js +120 -0
- package/dist/path-safety.js.map +1 -0
- package/dist/run-DkCD5DeO.d.cts +2181 -0
- package/dist/run-DkCD5DeO.d.ts +2181 -0
- package/dist/scorers.d.ts +75 -0
- package/dist/security.d.ts +67 -0
- package/dist/stream-object.d.ts +74 -0
- package/dist/task-store.cjs +237 -0
- package/dist/task-store.cjs.map +1 -0
- package/dist/task-store.d.cts +8 -0
- package/dist/task-store.d.ts +8 -0
- package/dist/task-store.js +233 -0
- package/dist/task-store.js.map +1 -0
- package/dist/task.d.ts +87 -0
- package/dist/theokit.d.ts +84 -0
- package/dist/tools/_path-scope.d.cts +8 -0
- package/dist/tools/_path-scope.d.ts +8 -0
- package/dist/tools/_subprocess.d.cts +28 -0
- package/dist/tools/_subprocess.d.ts +28 -0
- package/dist/tools/git-diff.d.cts +22 -0
- package/dist/tools/git-diff.d.ts +22 -0
- package/dist/tools/index.d.cts +29 -0
- package/dist/tools/index.d.ts +29 -0
- package/dist/tools/list-dir.d.cts +26 -0
- package/dist/tools/list-dir.d.ts +26 -0
- package/dist/tools/read-file.d.cts +31 -0
- package/dist/tools/read-file.d.ts +31 -0
- package/dist/tools/run-vitest.d.cts +46 -0
- package/dist/tools/run-vitest.d.ts +46 -0
- package/dist/tools/search-text.d.cts +32 -0
- package/dist/tools/search-text.d.ts +32 -0
- package/dist/tools.cjs +690 -0
- package/dist/tools.cjs.map +1 -0
- package/dist/tools.js +683 -0
- package/dist/tools.js.map +1 -0
- package/dist/trajectory-helpers.d.ts +31 -0
- package/dist/types/agent.d.ts +771 -0
- package/dist/types/batch.d.ts +112 -0
- package/dist/types/budget.d.ts +88 -0
- package/dist/types/cache.d.ts +76 -0
- package/dist/types/context.d.ts +93 -0
- package/dist/types/conversation-storage.d.ts +76 -0
- package/dist/types/conversation.d.ts +90 -0
- package/dist/types/cron.d.ts +150 -0
- package/dist/types/eval.d.ts +132 -0
- package/dist/types/goal-events.d.ts +95 -0
- package/dist/types/handoff.d.ts +135 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/mcp.d.ts +64 -0
- package/dist/types/memory-adapter.d.ts +175 -0
- package/dist/types/messages.d.ts +154 -0
- package/dist/types/providers.d.ts +102 -0
- package/dist/types/run.d.ts +215 -0
- package/dist/types/task.d.ts +131 -0
- package/dist/types/theokit.d.ts +61 -0
- package/dist/types/trajectory.d.ts +49 -0
- package/dist/types/updates.d.ts +148 -0
- package/dist/types/usage.d.ts +61 -0
- package/dist/types/workflow.d.ts +217 -0
- package/dist/workflow.cjs +2405 -0
- package/dist/workflow.cjs.map +1 -0
- package/dist/workflow.d.cts +97 -0
- package/dist/workflow.d.ts +97 -0
- package/dist/workflow.js +2398 -0
- package/dist/workflow.js.map +1 -0
- package/package.json +183 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/internal/zod/to-json-schema.ts","../src/define-tool.ts","../src/errors.ts","../src/internal/security/path-guard.ts","../src/tools/_path-scope.ts","../src/tools/_subprocess.ts","../src/tools/git-diff.ts","../src/tools/list-dir.ts","../src/tools/read-file.ts","../src/tools/run-vitest.ts","../src/tools/search-text.ts"],"names":["z","resolve","DEFAULT_TIMEOUT_MS","DEFAULT_MAX_STDOUT_BYTES","spawn","BINARY_PROBE_BYTES","join","relativePath","readdir"],"mappings":";;;;;;;;AA8BA,IAAM,UAAA,GAAa,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AAEhD,IAAI,qBAA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IAAA,IAAQ,MAAA,CAAO,MAAA,GAAS,MAAM,WAAA,EAAa;AAC1D,EAAA,IAAI,cAAA,CAAe,MAAM,CAAA,EAAG;AAC5B,EAAA,MAAM,QAAQ,MAAA,CAAO,QAAA,CAAS,OAAO,CAAA,CAAE,MAAM,IAAI,CAAA;AACjD,EAAA,KAAA,IAAS,IAAI,CAAA,EAAG,CAAA,GAAI,KAAA,CAAM,MAAA,EAAQ,KAAK,CAAA,EAAG;AACxC,IAAA,MAAM,IAAA,GAAO,MAAM,CAAC,CAAA;AACpB,IAAA,IAAI,CAAC,IAAA,CAAK,QAAA,CAAS,KAAA,CAAM,KAAK,CAAA,EAAG;AACjC,IAAA,IAAI,CAAC,WAAA,CAAY,KAAA,EAAO,SAAS,CAAA,GAAI,CAAA,EAAG,IAAI,CAAA,EAAG;AAAA,EACjD;AACF","file":"tools.js","sourcesContent":["/**\n * Zod → JSON Schema universal adapter (FAANG-grade, supports Zod 3 + Zod 4).\n *\n * The SDK declares `zod: \"^3.25.0 || ^4.0.0\"` as optional peer. Implementation\n * MUST work on both versions or the peer-range claim is false.\n *\n * Strategy:\n * 1. Feature-detect Zod 4's native `z.toJSONSchema` (preferred — zero extra\n * dep, ships with Zod 4 core).\n * 2. Fall back to the universal `zod-to-json-schema` library (works for both\n * v3 and v4; ~5KB gzipped, optional peer dep).\n * 3. If neither path resolves, throw an actionable error explaining the\n * install command for the user's Zod major.\n *\n * Output shape is identical across paths: a `Record<string, unknown>` JSON\n * Schema document with `type: \"object\"` root that the LLM tool-use spec\n * accepts unchanged.\n *\n * @internal\n */\n\nimport { createRequire } from \"node:module\";\n\ntype AnyZodSchema = unknown;\n\ninterface ToJsonSchemaOptions {\n /** Zod 4 option: `\"any\"` keeps transforms/refinements as `{}` (loose). */\n unrepresentable?: \"any\" | \"throw\";\n}\n\nconst requireSdk = createRequire(import.meta.url);\n\nlet cachedZodHasNativeApi: boolean | undefined;\nlet cachedFallbackLib: ((schema: AnyZodSchema) => unknown) | undefined;\nlet triedFallback = false;\n\n/**\n * Convert any Zod schema (v3 or v4) to a JSON Schema object. Feature-detects\n * the native Zod 4 API first; falls back to `zod-to-json-schema` lib on v3.\n *\n * @internal\n */\nexport function toJsonSchema(\n schema: AnyZodSchema,\n options: ToJsonSchemaOptions = { unrepresentable: \"any\" },\n): Record<string, unknown> {\n const native = tryNativeZod4(schema, options);\n if (native !== undefined) return native;\n const fallback = tryFallbackLib(schema);\n if (fallback !== undefined) return fallback;\n throw new Error(\n \"Zod → JSON Schema conversion failed: neither Zod 4's native `z.toJSONSchema` \" +\n \"nor the `zod-to-json-schema` peer dep are available. \" +\n \"On Zod 4: ensure `zod >= 4.0.0` is installed. \" +\n 'On Zod 3: add `\"zod-to-json-schema\": \"^3.24.0\"` to your package.json.',\n );\n}\n\nfunction tryNativeZod4(\n schema: AnyZodSchema,\n options: ToJsonSchemaOptions,\n): Record<string, unknown> | undefined {\n if (cachedZodHasNativeApi === false) return undefined;\n let z: { toJSONSchema?: (s: unknown, o?: unknown) => unknown };\n try {\n z = requireSdk(\"zod\") as typeof z;\n } catch {\n cachedZodHasNativeApi = false;\n return undefined;\n }\n if (typeof z.toJSONSchema !== \"function\") {\n cachedZodHasNativeApi = false;\n return undefined;\n }\n // Cross-version safety net: when the SDK source runs under a dev-server\n // (Vite SSR), `requireSdk(\"zod\")` resolves to the SDK's OWN node_modules\n // (zod 4 in our devDeps), while the schema was built by the CONSUMER's\n // zod (often v3 — see dogfood-app pinned to ^3.25.0). Calling zod 4's\n // `toJSONSchema` with a zod 3 schema throws. Catch + fall through to\n // `zod-to-json-schema` (which understands both v3 and v4 schemas).\n try {\n return z.toJSONSchema(schema, options) as Record<string, unknown>;\n } catch {\n cachedZodHasNativeApi = false;\n return undefined;\n }\n}\n\nfunction tryFallbackLib(schema: AnyZodSchema): Record<string, unknown> | undefined {\n if (cachedFallbackLib !== undefined) {\n return cachedFallbackLib(schema) as Record<string, unknown>;\n }\n if (triedFallback) return undefined;\n triedFallback = true;\n try {\n // `zod-to-json-schema` exports the converter as default OR as named export\n // `zodToJsonSchema` depending on module shape. Probe both.\n const mod = requireSdk(\"zod-to-json-schema\") as {\n default?: (s: unknown) => unknown;\n zodToJsonSchema?: (s: unknown) => unknown;\n };\n const fn =\n typeof mod.zodToJsonSchema === \"function\"\n ? mod.zodToJsonSchema\n : typeof mod.default === \"function\"\n ? mod.default\n : undefined;\n if (fn === undefined) return undefined;\n cachedFallbackLib = fn as (s: AnyZodSchema) => unknown;\n return fn(schema) as Record<string, unknown>;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Test-only reset (clears the version-detection cache so tests can simulate\n * a different Zod major).\n *\n * @internal\n */\nexport function _resetZodToJsonSchemaCache(): void {\n cachedZodHasNativeApi = undefined;\n cachedFallbackLib = undefined;\n triedFallback = false;\n}\n","// `zod` referenced only as a TYPE — `import type` is erased by tsc/tsup, so\n// the compiled `dist/index.js` does NOT have a top-level `import \"zod\"`.\n// Consumers who don't call `defineTool` don't need `zod` installed (the peer\n// dependency stays truly optional per ADR D24). The runtime JSON-Schema\n// conversion is delegated to `zodToJsonSchema` (internal/zod/to-json-schema)\n// which feature-detects zod 4 native `toJSONSchema` vs zod 3 +\n// `zod-to-json-schema` peer dep — supporting the SDK's declared peer range\n// `zod: \"^3.25.0 || ^4.0.0\"`.\nimport type { z as ZodNamespace, ZodType } from \"zod\";\n\nimport { toJsonSchema } from \"./internal/zod/to-json-schema.js\";\nimport type { CustomTool } from \"./types/agent.js\";\n\n/**\n * Spec accepted by {@link defineTool}. `inputSchema` is a Zod schema; the\n * `handler` argument type is inferred via `z.infer<T>` — no `as` casts.\n *\n * @public\n */\nexport interface DefineToolSpec<T extends ZodType> {\n /** Tool name surfaced to the LLM. Same constraints as {@link CustomTool.name}. */\n name: string;\n /** Description surfaced to the LLM. */\n description: string;\n /** Zod schema describing the input. Must be `z.object(...)` at the root for the LLM tool contract. */\n inputSchema: T;\n /** Handler invoked with the parsed input. Type is inferred via `z.infer<T>`. */\n handler: (input: ZodNamespace.infer<T>) => string | Promise<string>;\n}\n\n/**\n * Type-safe builder for {@link CustomTool}. Converts a Zod schema to JSON\n * Schema (for the LLM-facing `inputSchema` field), wraps the handler with a\n * runtime `schema.parse` step, and preserves type inference.\n *\n * Behaviour (ADR D24):\n * - JSON Schema conversion uses Zod 4's native `z.toJSONSchema` with\n * `unrepresentable: \"any\"` so transforms/refinements round-trip.\n * - Runtime parse failures throw `ZodError`; the SDK's tool-dispatch converts\n * them to `tool_result(isError)` with the Zod message.\n * - Handler signature is `(input: z.infer<T>)`, not `Record<string, unknown>`.\n * - `zod` loads lazily via `createRequire` — consumers who don't call\n * `defineTool` don't need `zod` installed.\n *\n * @public\n */\nexport function defineTool<T extends ZodType>(spec: DefineToolSpec<T>): CustomTool {\n // Universal Zod → JSON Schema converter (feature-detects zod 4 native\n // `z.toJSONSchema` vs zod 3 + `zod-to-json-schema` peer). Fixes the bug\n // where consumers pinned to `zod@^3.25.0` (no native `toJSONSchema`) hit\n // `z.toJSONSchema is not a function` at runtime. The SDK declares\n // peer `zod: \"^3.25.0 || ^4.0.0\"` — both must work.\n //\n // `unrepresentable: \"any\"` lets transforms / refinements / branded types\n // round-trip to JSON Schema as `{}` (effectively `any`). The runtime parse\n // still enforces the full Zod contract; the LLM just sees a looser hint.\n const inputSchema = toJsonSchema(spec.inputSchema, {\n unrepresentable: \"any\",\n });\n return {\n name: spec.name,\n description: spec.description,\n inputSchema,\n handler: async (input: Record<string, unknown>): Promise<string> => {\n const parsed = spec.inputSchema.parse(input) as ZodNamespace.infer<T>;\n return await spec.handler(parsed);\n },\n };\n}\n","import type { RunOperation } from \"./types/run.js\";\n\n/**\n * Finite, machine-readable error codes for provider-originated errors\n * (ADR D66). Consumers can `switch (err.metadata?.code)` exhaustively\n * — adding a new variant is an explicit decision + test coverage.\n *\n * @public\n */\nexport type ErrorCode =\n | \"rate_limit\"\n | \"auth_failed\"\n | \"invalid_request\"\n | \"timeout\"\n | \"server_error\"\n | \"context_too_long\"\n | \"content_filtered\"\n | \"model_unavailable\"\n | \"network\"\n | \"unknown\";\n\n/**\n * Codes used by {@link AgentRunError} (Production-Readiness #3, ADR D311).\n *\n * Superset of {@link ErrorCode} extended with codes that do NOT originate\n * from a provider HTTP response:\n *\n * - `quota_exceeded` — billing limit hit (provider 402 or signalled error)\n * - `tool_runtime_error` — custom tool handler threw inside dispatch\n * - `aborted` — caller's `AbortSignal` fired (Phase 4)\n * - `invalid_model` — model id rejected by provider (400 \"model not found\")\n * - `safety_blocked` — provider safety filter blocked req or resp\n * - `provider_unreachable` — DNS/TCP/timeout/5xx at transport boundary\n *\n * The `& {}` tail keeps the literal-union ergonomics (autocomplete) while\n * accepting any string for forward compatibility with constructor calls\n * that pass arbitrary code values (legacy callers).\n *\n * @public\n */\nexport type AgentRunErrorCode =\n | ErrorCode\n | \"quota_exceeded\"\n | \"tool_runtime_error\"\n | \"aborted\"\n | \"invalid_model\"\n | \"safety_blocked\"\n | \"provider_unreachable\"\n | (string & {});\n\n/**\n * Structured context for errors that originated from a provider HTTP\n * call (ADR D65). Lets callers retry with the right backoff (`retryAfter`),\n * surface actionable diagnostics (`provider`, `endpoint`), and inspect the\n * raw response body when needed (`raw`, capped at ~2KB by the mapper).\n *\n * @public\n */\nexport interface ErrorMetadata {\n /** Provider canonical name (e.g., `\"anthropic\"`, `\"openai\"`, `\"openrouter\"`, `\"gemini\"`). */\n provider: string;\n /** HTTP endpoint that failed (e.g., `\"/v1/messages\"`, `\"/v1/chat/completions\"`). */\n endpoint: string;\n /** Machine-readable error code (finite enum). */\n code: ErrorCode;\n /** HTTP status code if applicable. */\n statusCode?: number;\n /** Seconds to wait before retry, per provider's `retry-after` header (numeric form only). */\n retryAfter?: number;\n /** Raw response body for debugging (truncated to ~2KB by the mapper). */\n raw?: unknown;\n}\n\n/**\n * Base class for all errors thrown by `@theokit/sdk`.\n *\n * Use `isRetryable` to drive retry/backoff logic. `code` and `protoErrorCode`\n * are populated for server-originated errors when available. `metadata`\n * (ADR D65) carries structured `{ provider, endpoint, code, ... }` when\n * the error originated from a provider HTTP call.\n *\n * @public\n */\nexport class TheokitAgentError extends Error {\n override readonly name: string = \"TheokitAgentError\";\n readonly isRetryable: boolean;\n readonly code?: string;\n readonly protoErrorCode?: string;\n readonly metadata?: ErrorMetadata;\n\n constructor(\n message: string,\n options: {\n isRetryable?: boolean;\n code?: string;\n protoErrorCode?: string;\n cause?: unknown;\n metadata?: ErrorMetadata;\n } = {},\n ) {\n super(message, options.cause !== undefined ? { cause: options.cause } : undefined);\n this.isRetryable = options.isRetryable ?? false;\n if (options.code !== undefined) this.code = options.code;\n if (options.protoErrorCode !== undefined) this.protoErrorCode = options.protoErrorCode;\n if (options.metadata !== undefined) this.metadata = options.metadata;\n }\n}\n\n/**\n * Invalid API key, not logged in, insufficient permissions.\n *\n * @public\n */\nexport class AuthenticationError extends TheokitAgentError {\n override readonly name: string = \"AuthenticationError\";\n\n constructor(\n message: string,\n options: { code?: string; cause?: unknown; metadata?: ErrorMetadata } = {},\n ) {\n super(message, { ...options, isRetryable: false });\n }\n}\n\n/**\n * Too many requests or usage limits exceeded.\n *\n * @public\n */\nexport class RateLimitError extends TheokitAgentError {\n override readonly name: string = \"RateLimitError\";\n\n constructor(\n message: string,\n options: { code?: string; cause?: unknown; metadata?: ErrorMetadata } = {},\n ) {\n super(message, { ...options, isRetryable: true });\n }\n}\n\n/**\n * Invalid model, bad request parameters, malformed options.\n *\n * @public\n */\nexport class ConfigurationError extends TheokitAgentError {\n override readonly name: string = \"ConfigurationError\";\n\n constructor(\n message: string,\n options: { code?: string; cause?: unknown; metadata?: ErrorMetadata } = {},\n ) {\n super(message, { ...options, isRetryable: false });\n }\n}\n\n/**\n * Thrown when creating a cloud agent for a repo whose SCM provider is not\n * connected. Use `helpUrl` to point the user at the right reconnect flow.\n *\n * @public\n */\nexport class IntegrationNotConnectedError extends ConfigurationError {\n override readonly name: string = \"IntegrationNotConnectedError\";\n readonly provider: string;\n readonly helpUrl: string;\n\n constructor(\n message: string,\n options: {\n provider: string;\n helpUrl: string;\n code?: string;\n cause?: unknown;\n metadata?: ErrorMetadata;\n },\n ) {\n super(message, options);\n this.provider = options.provider;\n this.helpUrl = options.helpUrl;\n }\n}\n\n/**\n * Service unavailable, timeout, transport-level failure.\n *\n * @public\n */\nexport class NetworkError extends TheokitAgentError {\n override readonly name: string = \"NetworkError\";\n\n constructor(\n message: string,\n options: { code?: string; cause?: unknown; metadata?: ErrorMetadata } = {},\n ) {\n super(message, { ...options, isRetryable: true });\n }\n}\n\n/**\n * Catch-all for unclassified server or runtime errors.\n *\n * @public\n */\nexport class UnknownAgentError extends TheokitAgentError {\n override readonly name: string = \"UnknownAgentError\";\n\n constructor(\n message: string,\n options: { code?: string; cause?: unknown; metadata?: ErrorMetadata } = {},\n ) {\n super(message, { ...options, isRetryable: false });\n }\n}\n\n/**\n * Thrown by `Agent.prompt` (and helpers that go through `run.wait()`) when\n * the option `{ throwOnError: true }` is set and the run terminates with\n * `status: 'error'`. Carries the structured `RunResult.error` fields so\n * callers can `catch` once and branch on `code` / `provider` instead of\n * unwrapping the run.\n *\n * Extends {@link TheokitAgentError} per ADR D65 — no new hierarchy.\n *\n * @example\n * try {\n * await Agent.prompt(msg, { apiKey, model, throwOnError: true });\n * } catch (err) {\n * if (err instanceof AgentRunError && err.code === 'auth_failed') {\n * // bad key\n * }\n * }\n *\n * @public\n */\nexport class AgentRunError extends TheokitAgentError {\n override readonly name: string = \"AgentRunError\";\n readonly provider?: string;\n readonly raw?: string;\n /** Provider's request id (`x-request-id` / `request-id` header). Useful for support tickets. */\n readonly requestId?: string;\n /** SDK conversation id this error was raised inside. */\n readonly conversationId?: string;\n\n constructor(\n message: string,\n options: {\n code: AgentRunErrorCode;\n provider?: string;\n raw?: string;\n requestId?: string;\n conversationId?: string;\n retriable?: boolean;\n cause?: unknown;\n metadata?: ErrorMetadata;\n },\n ) {\n super(message, {\n code: options.code,\n cause: options.cause,\n metadata: options.metadata,\n // D311: most AgentRunErrors are not retriable (auth, validation, abort).\n // Provider mappers (D314) override per-status — explicit `retriable` wins\n // over the implicit default when supplied.\n isRetryable: options.retriable ?? defaultRetriableForCode(options.code),\n });\n if (options.provider !== undefined) this.provider = options.provider;\n if (options.raw !== undefined) this.raw = options.raw;\n if (options.requestId !== undefined) this.requestId = options.requestId;\n if (options.conversationId !== undefined) this.conversationId = options.conversationId;\n }\n\n /**\n * Production-Readiness #3 (ADR D311): alias for `isRetryable` exposed as\n * `retriable` to match the handoff contract. Future v2 will deprecate\n * `isRetryable` in favor of this.\n */\n get retriable(): boolean {\n return this.isRetryable;\n }\n\n /**\n * D312: provider's `Retry-After` header in **milliseconds**. Mappers store\n * the header value (seconds) in `metadata.retryAfter`; this getter\n * multiplies by 1000 so the result composes with `Date.now()`/`setTimeout`.\n *\n * Returns `undefined` when no hint was provided. `0` is a legitimate value\n * — use `=== undefined` check rather than truthy check.\n */\n get retryAfterMs(): number | undefined {\n if (this.metadata?.retryAfter === undefined) return undefined;\n return this.metadata.retryAfter * 1000;\n }\n\n /**\n * D313: alias for `metadata.raw`. Provider response body for debugging.\n * Available but NEVER serialized into `.message` (anti-leak invariant).\n */\n get providerError(): unknown {\n return this.metadata?.raw;\n }\n}\n\n/**\n * D311 helper: choose a sensible default `isRetryable` value when the\n * caller did not supply `retriable` explicitly. Conservative defaults —\n * provider mappers override per-status when they know better.\n *\n * @internal\n */\nfunction defaultRetriableForCode(code: AgentRunErrorCode): boolean {\n switch (code) {\n case \"rate_limit\":\n case \"timeout\":\n case \"server_error\":\n case \"network\":\n case \"provider_unreachable\":\n return true;\n default:\n return false;\n }\n}\n\n/**\n * Thrown when a {@link Run} or agent operation is not available on the current\n * runtime. Check first with `run.supports(operation)`.\n *\n * Extends {@link TheokitAgentError} (so error-catching code that branches on\n * `instanceof TheokitAgentError` continues to work) but is never retryable —\n * an unsupported operation will not become supported on retry.\n *\n * @public\n */\nexport class UnsupportedRunOperationError extends TheokitAgentError {\n override readonly name: string = \"UnsupportedRunOperationError\";\n readonly operation: RunOperation;\n\n constructor(\n message: string,\n operation: RunOperation,\n options: { code?: string; cause?: unknown } = {},\n ) {\n super(message, {\n ...options,\n isRetryable: false,\n code: options.code ?? \"unsupported_run_operation\",\n });\n this.operation = operation;\n }\n}\n\n/**\n * Thrown when every credential in a per-provider pool is in cooldown\n * and no healthy key is available (ADR D133). The caller's\n * {@link import(\"./internal/llm/fallback-client.js\").FallbackLlmClient}\n * catches this and tries the next provider in the fallback chain.\n *\n * `metadata.nextRetryAt` (epoch ms) tells callers when the soonest\n * pool entry resumes — useful for manual retry scheduling.\n *\n * @public\n */\nexport class CredentialPoolExhaustedError extends TheokitAgentError {\n override readonly name: string = \"CredentialPoolExhaustedError\";\n readonly provider: string;\n readonly nextRetryAt: number | undefined;\n\n constructor(\n message: string,\n options: {\n provider: string;\n nextRetryAt?: number;\n code?: string;\n cause?: unknown;\n metadata?: ErrorMetadata;\n },\n ) {\n super(message, {\n ...options,\n isRetryable: true,\n code: options.code ?? \"credential_pool_exhausted\",\n });\n this.provider = options.provider;\n this.nextRetryAt = options.nextRetryAt;\n }\n}\n\n/**\n * Finite error codes specific to memory adapter operations (ADR D141).\n *\n * @public\n */\nexport type MemoryAdapterErrorCode =\n | \"auth_failed\"\n | \"rate_limited\"\n | \"not_found\"\n | \"network\"\n | \"invalid_input\"\n | \"unknown\";\n\n/**\n * Error raised by `@theokit-memory-*` adapters. Carries `adapterId`\n * so callers can branch on which provider failed (ADR D141).\n *\n * @public\n */\nexport class MemoryAdapterError extends TheokitAgentError {\n override readonly name: string = \"MemoryAdapterError\";\n readonly adapterId: string;\n\n constructor(\n message: string,\n options: {\n adapterId: string;\n code: MemoryAdapterErrorCode;\n cause?: unknown;\n metadata?: ErrorMetadata;\n },\n ) {\n super(message, {\n isRetryable: options.code === \"rate_limited\" || options.code === \"network\",\n code: options.code,\n ...(options.cause !== undefined ? { cause: options.cause } : {}),\n ...(options.metadata !== undefined ? { metadata: options.metadata } : {}),\n });\n this.adapterId = options.adapterId;\n }\n}\n\n/**\n * Thrown when a user-supplied task ID violates the grammar\n * `^[a-z0-9][a-z0-9_-]*$` (D368) OR starts with a reserved adapter\n * prefix (`wf-` / `b-` / `cron-`, EC-5).\n *\n * @public\n */\nexport class InvalidTaskIdError extends TheokitAgentError {\n override readonly name: string = \"InvalidTaskIdError\";\n readonly taskId: string;\n\n constructor(message: string, taskId: string, options: { cause?: unknown } = {}) {\n super(message, {\n ...options,\n isRetryable: false,\n code: \"invalid_task_id\",\n });\n this.taskId = taskId;\n }\n}\n\n/**\n * Thrown when `Task.subscribe(id)` is called for a task that has been\n * evicted, never submitted, or evicted after retention (D373).\n *\n * @public\n */\nexport class TaskNotFoundError extends TheokitAgentError {\n override readonly name: string = \"TaskNotFoundError\";\n readonly taskId: string;\n\n constructor(taskId: string, options: { cause?: unknown } = {}) {\n super(`Task not found: ${taskId}`, {\n ...options,\n isRetryable: false,\n code: \"task_not_found\",\n });\n this.taskId = taskId;\n }\n}\n\n/**\n * Thrown when `CloudAgent` is asked to wrap a task (D370). Cloud\n * task observability is deferred until Theo PaaS GA.\n *\n * @public\n */\nexport class UnsupportedTaskOperationError extends TheokitAgentError {\n override readonly name: string = \"UnsupportedTaskOperationError\";\n readonly operation: string;\n\n constructor(operation: string, options: { cause?: unknown } = {}) {\n super(\n `Task operation \"${operation}\" is not supported on CloudAgent (pre-release; see ADR D370)`,\n {\n ...options,\n isRetryable: false,\n code: \"task_op_unsupported\",\n },\n );\n this.operation = operation;\n }\n}\n\n/**\n * Thrown by `Budget` enforcement (ADR D386) when a `mode: \"block\"`\n * budget would be exceeded by the upcoming LLM call. Caller pega\n * tipado para retry-after-window-reset or surface to the user.\n *\n * @public\n */\nexport class BudgetExceededError extends TheokitAgentError {\n override readonly name: string = \"BudgetExceededError\";\n readonly budgetName: string;\n readonly window: import(\"./types/budget.js\").BudgetWindow;\n readonly spentUsd: number;\n readonly limitUsd: number;\n readonly mode: import(\"./types/budget.js\").BudgetMode;\n\n constructor(args: {\n budgetName: string;\n window: import(\"./types/budget.js\").BudgetWindow;\n spentUsd: number;\n limitUsd: number;\n mode: import(\"./types/budget.js\").BudgetMode;\n cause?: unknown;\n }) {\n super(\n `Budget \"${args.budgetName}\" exceeded for window ${args.window}: spent $${args.spentUsd.toFixed(4)} > limit $${args.limitUsd.toFixed(4)}`,\n {\n ...(args.cause !== undefined ? { cause: args.cause } : {}),\n isRetryable: false,\n code: \"budget_exceeded\",\n },\n );\n this.budgetName = args.budgetName;\n this.window = args.window;\n this.spentUsd = args.spentUsd;\n this.limitUsd = args.limitUsd;\n this.mode = args.mode;\n }\n}\n\n/**\n * Thrown when `CloudAgent.send({ budget })` is invoked (D388). Cloud\n * budget surface waits for Theo PaaS GA.\n *\n * @public\n */\nexport class UnsupportedBudgetOperationError extends TheokitAgentError {\n override readonly name: string = \"UnsupportedBudgetOperationError\";\n readonly operation: string;\n\n constructor(operation: string, options: { cause?: unknown } = {}) {\n super(\n `Budget operation \"${operation}\" is not supported on CloudAgent (pre-release; see ADR D388)`,\n {\n ...options,\n isRetryable: false,\n code: \"budget_op_unsupported\",\n },\n );\n this.operation = operation;\n }\n}\n","/**\n * Canonical path-guard module (ADRs D79-D81).\n *\n * Three primitives + one typed error:\n * - `safePathJoin(base, ...parts)` — resolve THEN prefix-check (ADR D80).\n * - `assertNoSymlinkEscape(path, base)` — `realpathSync` resolves entire\n * symlink chain (EC-1 fix; Hermes v0.2 #386, #61).\n * - `sanitizeIdentifier(input, { maxLen })` — strict grammar\n * `^[a-z0-9][a-z0-9-_]*$` (ADR D81; case-insensitive on input,\n * lowercase on output).\n * - `PathTraversalError` — extends ConfigurationError with code\n * `path_traversal` (ADR D65: no new hierarchy).\n *\n * Wire at all sites where user input becomes a path. CI lint gate\n * `tests/lint/no-unguarded-path-input.test.ts` prevents regression\n * (ADR D85).\n *\n * @internal\n */\n\nimport { lstatSync, readlinkSync, realpathSync, type Stats } from \"node:fs\";\nimport { dirname, resolve, sep } from \"node:path\";\n\nimport { ConfigurationError } from \"../../errors.js\";\n\n/**\n * Thrown when a path operation would escape its allowed base directory.\n * Extends `ConfigurationError` (no new error hierarchy per ADR D65).\n *\n * @internal\n */\nexport class PathTraversalError extends ConfigurationError {\n override readonly name: string = \"PathTraversalError\";\n\n constructor(input: string, resolvedPath: string) {\n super(`Path traversal attempt: ${input} → ${resolvedPath}`, {\n code: \"path_traversal\",\n });\n }\n}\n\n/**\n * Thrown when an agent tool is asked to read or write a sensitive path\n * that the blocklist forbids (`.env`, `.git/`, `node_modules/`, `.theo/`,\n * lock files). Distinct from `PathTraversalError` because the path is\n * lexically inside the project — it is just sensitive.\n *\n * Extends `ConfigurationError` (no new error hierarchy per ADR D65).\n *\n * @public\n */\nexport class ForbiddenPathError extends ConfigurationError {\n override readonly name: string = \"ForbiddenPathError\";\n\n constructor(path: string) {\n super(\n `Path '${path}' is in the sensitive-file blocklist (.env, .git/, node_modules/, .theo/, lock files)`,\n {\n code: \"forbidden_path\",\n },\n );\n }\n}\n\n/**\n * Join `base` with `...parts` and ensure the resolved absolute path stays\n * under `base`. Resolves FIRST, then prefix-checks (ADR D80) — prevents\n * normalized-escape bypasses like `subdir/.\\\\./bar`.\n *\n * Returns the safe absolute path. Throws `PathTraversalError` if escape.\n *\n * @internal\n */\nexport function safePathJoin(base: string, ...parts: string[]): string {\n if (base === \"\") {\n throw new Error(\"safePathJoin: base must be non-empty\");\n }\n const baseResolved = resolve(base);\n const target = resolve(base, ...parts);\n if (target !== baseResolved && !target.startsWith(baseResolved + sep)) {\n throw new PathTraversalError(parts.join(\"/\"), target);\n }\n return target;\n}\n\n/**\n * Assert that `path` — including every directory component in the chain —\n * stays under `base` after symlink resolution. No-op when nothing on the\n * path exists yet.\n *\n * Two-bug history:\n * 1. **EC-1** (original fix, kept): a multi-level symlink chain A → B → C\n * must be resolved end-to-end. `realpathSync` does this in 1 syscall.\n * 2. **Defence-in-depth** (added v1.x): the previous implementation only\n * called `lstatSync(path)` on the terminal component. If an INTERMEDIATE\n * directory was a symlink (`base/inner-symlink → /outside`), `lstat` on\n * `base/inner-symlink/file.txt` followed the symlink and reported the\n * regular file — escape went undetected. Fix: walk up to the nearest\n * existing ancestor and `realpath` THAT, then re-attach the suffix and\n * check the result against the canonical base.\n *\n * @internal\n */\nexport function assertNoSymlinkEscape(path: string, base: string): void {\n // Canonical base — symlinks in the base path itself are absorbed once here.\n let baseResolved: string;\n try {\n baseResolved = realpathSync(base);\n } catch {\n // base doesn't exist as a real directory yet — fall back to lexical resolve.\n baseResolved = resolve(base);\n }\n\n // Find the deepest ancestor of `path` that exists, then realpath it.\n // Anything from there onward is \"not yet on disk\" and contributes only\n // its lexical suffix. This covers three cases:\n // - path exists (regular file or symlink at any depth) → realpath the full path\n // - path doesn't exist but intermediate dir is a symlink → realpath the ancestor\n // - nothing on the path exists → no escape risk (return)\n const resolved = realpathOfDeepestExisting(path);\n if (resolved === undefined) return; // path has no existing prefix — nothing to attack\n\n if (resolved !== baseResolved && !resolved.startsWith(baseResolved + sep)) {\n throw new PathTraversalError(`symlink ${path}`, resolved);\n }\n}\n\n/**\n * Find the deepest ancestor of `path` that exists on disk, resolve all\n * symlinks in that ancestor via `realpathSync`, and re-attach the\n * lexical suffix. Returns `undefined` when no ancestor exists.\n *\n * Handles dangling symlinks: if the terminal IS a symlink but its target\n * is missing, we still detect escape via `readlinkSync` + parent resolve.\n */\nfunction realpathOfDeepestExisting(path: string): string | undefined {\n // First try the full path — the common case.\n try {\n return realpathSync(path);\n } catch {\n // Not resolvable. Two sub-cases.\n }\n\n // Sub-case A: terminal is a dangling symlink.\n try {\n const stat: Stats = lstatSync(path);\n if (stat.isSymbolicLink()) {\n const target = readlinkSync(path);\n // Resolve target relative to the REAL parent dir, so intermediate\n // symlinks in the parent chain are absorbed.\n const parentReal = realpathOfDeepestExisting(dirname(path));\n const parentBase = parentReal ?? dirname(path);\n return resolve(parentBase, target);\n }\n } catch {\n // lstat failed too — terminal doesn't exist at all.\n }\n\n // Sub-case B: walk up to the nearest existing ancestor, then re-attach\n // the suffix lexically.\n let cursor = dirname(path);\n let suffix = path.slice(cursor.length);\n while (cursor !== dirname(cursor)) {\n try {\n const real = realpathSync(cursor);\n // Reconstruct: ancestor's realpath + remaining (still-lexical) suffix\n return resolve(real, `.${suffix}`);\n } catch {\n suffix = path.slice(dirname(cursor).length);\n cursor = dirname(cursor);\n }\n }\n // Reached filesystem root without finding any existing ancestor.\n return undefined;\n}\n\nconst LOCK_FILES = new Set([\"pnpm-lock.yaml\", \"package-lock.json\", \"yarn.lock\", \"bun.lockb\"]);\n\n/**\n * Decide whether a project-relative path points to a known-sensitive file\n * that a coding agent must not read or write.\n *\n * Universal blocklist (works for any agent operating on a project tree):\n *\n * - `.env`, `.env.<anything>` — except `.env.example` (template safe to read)\n * - `.git/` — version control internals\n * - `node_modules/` — dependency cache (changes don't belong to the user)\n * - `.theo/` — TheoKit build artefacts / state\n * - Lock files at any depth: `pnpm-lock.yaml`, `package-lock.json`,\n * `yarn.lock`, `bun.lockb`\n *\n * Operates on path segments (forward-slash normalized). Cross-platform safe.\n *\n * Use together with `safePathJoin` + `assertNoSymlinkEscape`: the former two\n * defeat traversal, this one defeats reading a file that is lexically inside\n * the project but should not be agent-visible.\n *\n * @public\n */\nexport function isForbiddenPath(input: string): boolean {\n // Normalize: forward slashes only, strip leading \"./\"\n const normalized = input.replace(/\\\\/g, \"/\").replace(/^\\.\\//, \"\");\n if (normalized.length === 0) return false;\n\n const segments = normalized.split(\"/\").filter((s) => s.length > 0);\n if (segments.length === 0) return false;\n\n const first = segments[0]!;\n // .env.example is explicitly allowlisted (template safe to read)\n if (first === \".env.example\") return false;\n if (first === \".env\") return true;\n if (/^\\.env\\./.test(first)) return true;\n\n if (first === \".git\") return true;\n if (first === \"node_modules\") return true;\n if (first === \".theo\") return true;\n\n const basename = segments[segments.length - 1]!;\n if (LOCK_FILES.has(basename)) return true;\n\n return false;\n}\n\nconst IDENTIFIER_PATTERN = /^[a-z0-9][a-z0-9\\-_]*$/i;\n\n/**\n * Validate that `input` is a safe path component (skill name, agent ID,\n * namespace, etc.) and return its lowercase form. Strict grammar\n * `^[a-z0-9][a-z0-9-_]*$` rejects path separators, dots, null bytes,\n * whitespace, unicode invisible chars, and any leading `-`/`_`.\n *\n * @param input - User-supplied identifier candidate.\n * @param options.maxLen - Maximum allowed length (default 64).\n * @returns Lowercase form of `input`.\n * @throws `ConfigurationError` with code `invalid_identifier` on rejection.\n *\n * @internal\n */\nexport function sanitizeIdentifier(input: string, options?: { maxLen?: number }): string {\n const maxLen = options?.maxLen ?? 64;\n if (input.length === 0 || input.length > maxLen) {\n throw new ConfigurationError(`Identifier length out of range (1-${maxLen}): \"${input}\"`, {\n code: \"invalid_identifier\",\n });\n }\n if (!IDENTIFIER_PATTERN.test(input)) {\n throw new ConfigurationError(`Identifier contains invalid characters: \"${input}\"`, {\n code: \"invalid_identifier\",\n });\n }\n return input.toLowerCase();\n}\n","/**\n * Shared `safePathJoin + assertNoSymlinkEscape` helper for built-in coding\n * tools (git-diff, run-vitest, list-dir, read-file, search-text). Returns a\n * pre-formatted `path_traversal` JSON string on failure or `null` on pass.\n *\n * @internal\n */\n\nimport {\n assertNoSymlinkEscape,\n ForbiddenPathError,\n PathTraversalError,\n safePathJoin,\n} from \"../internal/security/path-guard.js\";\n\nexport function checkPathScope(path: string | undefined, projectRoot: string): string | null {\n if (path === undefined || path === \"\") return null;\n try {\n const abs = safePathJoin(projectRoot, path);\n assertNoSymlinkEscape(abs, projectRoot);\n return null;\n } catch (err) {\n if (err instanceof PathTraversalError || err instanceof ForbiddenPathError) {\n return JSON.stringify({ ok: false, error: \"path_traversal\", path });\n }\n throw err;\n }\n}\n","/**\n * Shared subprocess-watch helpers for built-in coding tools (git-diff,\n * run-vitest). Wires the on(close)/on(error) settle pattern in a single\n * place to eliminate the cross-file clone flagged by jscpd.\n *\n * @internal\n */\n\nimport type { ChildProcess } from \"node:child_process\";\n\n/**\n * Settle gate — guarantees the supplied callback fires exactly once across\n * the close/error/timeout race. Clears the timer on settle.\n */\ninterface SettleGate {\n /** True after first settle; subsequent calls are no-ops. */\n settled: () => boolean;\n /** Settle the gate, clear the timer, and call `onSettle()`. */\n fire: (onSettle: () => void) => void;\n}\n\nfunction createSettleGate(timer: NodeJS.Timeout): SettleGate {\n let done = false;\n return {\n settled: () => done,\n fire: (onSettle) => {\n if (done) return;\n done = true;\n clearTimeout(timer);\n onSettle();\n },\n };\n}\n\n/**\n * Wire SIGKILL-on-timeout for a detached process group. Returns the settle\n * gate so caller listeners can short-circuit when the timeout already fired.\n */\nexport function armTimeoutKill<T>(\n child: ChildProcess,\n timeoutMs: number,\n onTimeout: () => T,\n resolve: (value: T) => void,\n): SettleGate {\n const timer = setTimeout(() => {\n gate.fire(() => {\n try {\n process.kill(-(child.pid ?? 0), \"SIGKILL\");\n } catch {\n /* already dead */\n }\n resolve(onTimeout());\n });\n }, timeoutMs);\n const gate = createSettleGate(timer);\n return gate;\n}\n\n/**\n * Attach a close+error pair of listeners that resolve via the supplied\n * callbacks. Honors the gate so timeout-vs-close races settle exactly once.\n */\nexport function attachChildSettlers<T>(\n child: ChildProcess,\n gate: SettleGate,\n onClose: (code: number | null) => T,\n onError: (err: Error) => T,\n resolve: (value: T) => void,\n): void {\n child.on(\"close\", (code) => {\n gate.fire(() => resolve(onClose(code)));\n });\n child.on(\"error\", (err) => {\n gate.fire(() => resolve(onError(err)));\n });\n}\n","/**\n * `git_diff` — built-in tool for coding agents.\n *\n * Returns the unified diff of the working tree (or staged changes when\n * `cached=true`). Implemented as a thin `git diff` subprocess wrapper\n * with a couple of hard limits:\n *\n * - 30s wall clock timeout (kills the process group on expiry)\n * - 5 MB stdout cap (truncate + flag `truncated=true`)\n * - Path scope validated through `safePathJoin` + `assertNoSymlinkEscape`\n *\n * Result shape (always a JSON string):\n * - `{ ok: true, diff: string, truncated?: boolean }`\n * - `{ ok: false, error: 'not_a_repo' | 'path_traversal' | 'timeout' }`\n */\n\nimport { spawn } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { z } from \"zod\";\n\nimport { defineTool } from \"../define-tool.js\";\nimport type { CustomTool } from \"../types/agent.js\";\nimport { checkPathScope } from \"./_path-scope.js\";\nimport { armTimeoutKill, attachChildSettlers } from \"./_subprocess.js\";\n\nconst DEFAULT_TIMEOUT_MS = 30_000;\nconst DEFAULT_MAX_STDOUT_BYTES = 5 * 1024 * 1024;\n\nexport interface CreateGitDiffToolOptions {\n projectRoot: string;\n timeoutMs?: number;\n maxStdoutBytes?: number;\n}\n\nexport function createGitDiffTool(opts: CreateGitDiffToolOptions): CustomTool {\n const {\n projectRoot,\n timeoutMs = DEFAULT_TIMEOUT_MS,\n maxStdoutBytes = DEFAULT_MAX_STDOUT_BYTES,\n } = opts;\n\n return defineTool({\n name: \"git_diff\",\n description:\n \"Return the unified diff of the project's working tree (or staged \" +\n \"changes when cached=true). Scoped to a single file when 'path' is \" +\n \"provided. Requires the project to be a git repository. Returns \" +\n \"{ ok, diff, truncated? } or { ok: false, error }.\",\n inputSchema: z.object({\n path: z.string().optional().describe(\"Optional project-relative file or dir scope.\"),\n cached: z\n .boolean()\n .optional()\n .describe(\"If true, show staged changes (git diff --cached). Default false.\"),\n }),\n handler: async ({ path, cached }) => {\n if (!existsSync(join(projectRoot, \".git\"))) {\n return JSON.stringify({ ok: false, error: \"not_a_repo\" });\n }\n\n const scopeCheck = checkPathScope(path, projectRoot);\n if (scopeCheck !== null) return scopeCheck;\n\n const args = buildDiffArgs(cached, path);\n const result = await runGitProcess(projectRoot, args, timeoutMs, maxStdoutBytes);\n return formatGitResult(result, timeoutMs);\n },\n });\n}\n\nfunction buildDiffArgs(cached: boolean | undefined, path: string | undefined): string[] {\n const args = [\"diff\", \"--no-color\"];\n if (cached === true) args.push(\"--cached\");\n if (path !== undefined && path !== \"\") args.push(\"--\", path);\n return args;\n}\n\nfunction formatGitResult(result: GitProcessResult, timeoutMs: number): string {\n if (result.kind === \"timeout\") {\n return JSON.stringify({ ok: false, error: \"timeout\", timeoutMs });\n }\n if (result.kind === \"error\") {\n return JSON.stringify({ ok: false, error: \"git_failed\", stderr: result.stderr });\n }\n return JSON.stringify({ ok: true, diff: result.stdout, truncated: result.truncated });\n}\n\ntype GitProcessResult =\n | { kind: \"ok\"; stdout: string; truncated: boolean }\n | { kind: \"error\"; stderr: string }\n | { kind: \"timeout\" };\n\nfunction runGitProcess(\n cwd: string,\n args: string[],\n timeoutMs: number,\n maxStdoutBytes: number,\n): Promise<GitProcessResult> {\n return new Promise((resolve) => {\n // Detached process group so we can kill the whole tree on timeout (EC-7).\n const child = spawn(\"git\", args, { cwd, detached: true, stdio: [\"ignore\", \"pipe\", \"pipe\"] });\n const stdoutChunks: Buffer[] = [];\n const stderrChunks: Buffer[] = [];\n let stdoutBytes = 0;\n let truncated = false;\n\n const gate = armTimeoutKill<GitProcessResult>(\n child,\n timeoutMs,\n () => ({ kind: \"timeout\" }),\n resolve,\n );\n\n child.stdout.on(\"data\", (chunk: Buffer) => {\n if (gate.settled()) return;\n if (stdoutBytes >= maxStdoutBytes) {\n truncated = true;\n return;\n }\n const remaining = maxStdoutBytes - stdoutBytes;\n if (chunk.length > remaining) {\n stdoutChunks.push(chunk.subarray(0, remaining));\n stdoutBytes = maxStdoutBytes;\n truncated = true;\n } else {\n stdoutChunks.push(chunk);\n stdoutBytes += chunk.length;\n }\n });\n\n child.stderr.on(\"data\", (chunk: Buffer) => {\n stderrChunks.push(chunk);\n });\n\n attachChildSettlers<GitProcessResult>(\n child,\n gate,\n (code) => {\n const stdout = Buffer.concat(stdoutChunks).toString(\"utf-8\");\n const stderr = Buffer.concat(stderrChunks).toString(\"utf-8\");\n return code === 0 ? { kind: \"ok\", stdout, truncated } : { kind: \"error\", stderr };\n },\n (err) => ({ kind: \"error\", stderr: err.message }),\n resolve,\n );\n });\n}\n","/**\n * `list_dir` — built-in tool for coding agents.\n *\n * Returns the direct entries of a project-relative directory. Hardened\n * against the same four bug families as `read_file` plus the\n * **EC-6 unbounded output** failure mode: in a project with 10k files,\n * a naive listing returns a 5 MB JSON payload that freezes the browser\n * and (more importantly) blows past the LLM context window.\n *\n * Defaults:\n * - `max = 500` entries (override via factory option `{ max }`)\n * - Result includes `{ truncated: boolean, totalCount: number }` so the\n * agent can decide whether to drill deeper or call `search_text` instead\n *\n * Result shape (always a JSON string):\n * - `{ ok: true, entries: Array<{ name, type }>, truncated, totalCount }`\n * - `{ ok: false, error: 'path_traversal' | 'forbidden_path' | 'not_found' }`\n */\n\nimport type { Dirent } from \"node:fs\";\nimport { readdir } from \"node:fs/promises\";\nimport { z } from \"zod\";\n\nimport { defineTool } from \"../define-tool.js\";\nimport {\n assertNoSymlinkEscape,\n ForbiddenPathError,\n isForbiddenPath,\n PathTraversalError,\n safePathJoin,\n} from \"../internal/security/path-guard.js\";\nimport type { CustomTool } from \"../types/agent.js\";\n\nconst DEFAULT_MAX_ENTRIES = 500;\n\nexport interface CreateListDirToolOptions {\n /** Absolute path to the project root. Every listing is gated against this boundary. */\n projectRoot: string;\n /** Maximum number of entries returned per call. Default 500. */\n max?: number;\n}\n\nexport function createListDirTool(opts: CreateListDirToolOptions): CustomTool {\n const { projectRoot, max = DEFAULT_MAX_ENTRIES } = opts;\n\n return defineTool({\n name: \"list_dir\",\n description:\n `Return the direct entries of a project-relative directory. ` +\n `Refuses paths outside the project root or in the sensitive-file ` +\n `blocklist (.env, .git/, node_modules/, .theo/, lock files). Caps ` +\n `at ${String(max)} entries by default; result carries truncated + totalCount.`,\n inputSchema: z.object({\n path: z.string().min(1).describe(\"Project-relative directory path. Use '.' for root.\"),\n }),\n handler: async ({ path }) => {\n const relative = path === \"\" || path === \".\" ? \".\" : path;\n if (relative !== \".\" && isForbiddenPath(relative)) {\n return JSON.stringify({ ok: false, error: \"forbidden_path\", path });\n }\n const boundary = resolveDirBoundary(relative, projectRoot, path);\n if (\"error\" in boundary) return boundary.error;\n const readResult = await readDirSafe(boundary.absolutePath, path);\n if (\"error\" in readResult) return readResult.error;\n return formatListing(readResult.dirents, max);\n },\n });\n}\n\nfunction resolveDirBoundary(\n relative: string,\n projectRoot: string,\n originalPath: string,\n): { absolutePath: string } | { error: string } {\n try {\n const absolutePath = relative === \".\" ? projectRoot : safePathJoin(projectRoot, relative);\n assertNoSymlinkEscape(absolutePath, projectRoot);\n return { absolutePath };\n } catch (err) {\n if (err instanceof PathTraversalError || err instanceof ForbiddenPathError) {\n return { error: JSON.stringify({ ok: false, error: \"path_traversal\", path: originalPath }) };\n }\n throw err;\n }\n}\n\nasync function readDirSafe(\n absolutePath: string,\n originalPath: string,\n): Promise<{ dirents: Dirent[] } | { error: string }> {\n try {\n const dirents = await readdir(absolutePath, { withFileTypes: true });\n return { dirents };\n } catch (err) {\n const e = err as { code?: string };\n if (e.code === \"ENOENT\" || e.code === \"ENOTDIR\") {\n return { error: JSON.stringify({ ok: false, error: \"not_found\", path: originalPath }) };\n }\n throw err;\n }\n}\n\nfunction formatListing(dirents: Dirent[], max: number): string {\n const totalCount = dirents.length;\n const truncated = totalCount > max;\n const entries = dirents.slice(0, max).map((d) => ({\n name: d.name,\n type: d.isDirectory() ? (\"directory\" as const) : (\"file\" as const),\n }));\n return JSON.stringify({ ok: true, entries, truncated, totalCount });\n}\n","/**\n * `read_file` — built-in tool for coding agents.\n *\n * Reads a project-relative file as UTF-8 and returns its contents.\n * Hardened against the four bug families a coding agent normally hits:\n *\n * 1. **Path traversal** — `safePathJoin` rejects literal `..`,\n * normalised escape, absolute segments, null-byte injection.\n * 2. **Symlink escape** — `assertNoSymlinkEscape` follows the full\n * chain (and any intermediate symlinks; defence-in-depth fix v1.x).\n * 3. **Sensitive files** — `isForbiddenPath` blocks `.env*` (except\n * `.env.example`), `.git/`, `node_modules/`, `.theo/`, lock files.\n * 4. **Binary files** — null-byte check on the first 8 KB. PNG/JPEG/\n * compiled binaries return a structured `binary_file` error\n * instead of garbled UTF-8 (EC-5 from the TheoKit Studio review).\n *\n * Return shape (always a JSON string the LLM consumes):\n * - `{ ok: true, content: string }` on success\n * - `{ ok: false, error: 'path_traversal' | 'forbidden_path' |\n * 'binary_file' | 'not_found' | 'too_large' }` on refusal\n *\n * The handler intentionally never throws on a \"user mistake\"\n * (traversal / forbidden / not found). Throwing reserved for SDK-side\n * mistakes that should crash the agent loop (input parse errors).\n */\n\nimport { type FileHandle, open } from \"node:fs/promises\";\nimport { z } from \"zod\";\n\nimport { defineTool } from \"../define-tool.js\";\nimport {\n assertNoSymlinkEscape,\n ForbiddenPathError,\n isForbiddenPath,\n PathTraversalError,\n safePathJoin,\n} from \"../internal/security/path-guard.js\";\nimport type { CustomTool } from \"../types/agent.js\";\n\n/** Max single-file read size, in bytes. 5 MB ceiling — enough for any source file. */\nconst MAX_FILE_SIZE = 5 * 1024 * 1024;\n\n/** Byte window inspected for null bytes when deciding binary vs text. */\nconst BINARY_PROBE_BYTES = 8 * 1024;\n\nexport interface CreateReadFileToolOptions {\n /** Absolute path to the project root. Every read is gated against this boundary. */\n projectRoot: string;\n}\n\nexport function createReadFileTool(opts: CreateReadFileToolOptions): CustomTool {\n const { projectRoot } = opts;\n\n return defineTool({\n name: \"read_file\",\n description:\n \"Read a single project-relative text file as UTF-8. Refuses paths \" +\n \"that escape the project root, are in the sensitive-file blocklist \" +\n \"(.env, .git/, node_modules/, .theo/, lock files), or contain a null \" +\n \"byte in the first 8 KB (binary file). Returns { ok, content } or \" +\n \"{ ok: false, error }.\",\n inputSchema: z.object({\n path: z.string().min(1).describe(\"Project-relative file path.\"),\n }),\n handler: async ({ path }) => {\n if (isForbiddenPath(path)) {\n return JSON.stringify({ ok: false, error: \"forbidden_path\", path });\n }\n const boundary = resolveBoundary(path, projectRoot);\n if (\"error\" in boundary) return boundary.error;\n const opened = await openHandleSafe(boundary.absolutePath, path);\n if (\"error\" in opened) return opened.error;\n try {\n return await readContent(opened.handle, path);\n } finally {\n await opened.handle.close();\n }\n },\n });\n}\n\nfunction resolveBoundary(\n path: string,\n projectRoot: string,\n): { absolutePath: string } | { error: string } {\n try {\n const absolutePath = safePathJoin(projectRoot, path);\n assertNoSymlinkEscape(absolutePath, projectRoot);\n return { absolutePath };\n } catch (err) {\n if (err instanceof PathTraversalError || err instanceof ForbiddenPathError) {\n return { error: JSON.stringify({ ok: false, error: \"path_traversal\", path }) };\n }\n throw err;\n }\n}\n\nasync function openHandleSafe(\n absolutePath: string,\n path: string,\n): Promise<{ handle: FileHandle } | { error: string }> {\n try {\n const handle = await open(absolutePath, \"r\");\n return { handle };\n } catch (err) {\n const e = err as { code?: string };\n if (e.code === \"ENOENT\") {\n return { error: JSON.stringify({ ok: false, error: \"not_found\", path }) };\n }\n throw err;\n }\n}\n\nasync function readContent(handle: FileHandle, path: string): Promise<string> {\n const stat = await handle.stat();\n if (stat.size > MAX_FILE_SIZE) {\n return JSON.stringify({\n ok: false,\n error: \"too_large\",\n path,\n size: stat.size,\n limit: MAX_FILE_SIZE,\n });\n }\n if (await isBinaryProbe(handle, Number(stat.size))) {\n return JSON.stringify({ ok: false, error: \"binary_file\", path, size: stat.size });\n }\n const content = await handle.readFile({ encoding: \"utf-8\" });\n return JSON.stringify({ ok: true, content, size: stat.size });\n}\n\nasync function isBinaryProbe(handle: FileHandle, size: number): Promise<boolean> {\n const probeLen = Math.min(BINARY_PROBE_BYTES, size);\n if (probeLen <= 0) return false;\n const probe = Buffer.alloc(probeLen);\n const { bytesRead } = await handle.read(probe, 0, probeLen, 0);\n for (let i = 0; i < bytesRead; i += 1) {\n if (probe[i] === 0) return true;\n }\n return false;\n}\n","/**\n * `run_vitest` — built-in tool for coding agents.\n *\n * Runs vitest against an optional file/pattern scope and returns the\n * parsed JSON report. Hardened against the same subprocess failure\n * modes as `git_diff`:\n *\n * - 120s wall clock timeout (vitest can be slow on first run)\n * - Process group kill on timeout (EC-7 — defeats vitest workers as\n * grandchildren of the spawned shell)\n * - **EC-12**: vitest stdout may contain deprecation warnings BEFORE\n * the JSON payload. The parser scans line-by-line and extracts the\n * LAST valid JSON object, not the first.\n *\n * Result shape (always a JSON string):\n * - `{ ok: true, summary: { numTotalTests, numPassedTests, numFailedTests, success } }`\n * - `{ ok: false, error: 'path_traversal' | 'forbidden_path' | 'timeout' |\n * 'no_vitest' | 'unparseable_output' }`\n *\n * Implementation note: invokes vitest via `npx --no-install vitest`. The\n * `--no-install` avoids the agent triggering a multi-megabyte download\n * mid-turn if vitest is missing — the tool fails cleanly with\n * `no_vitest` instead.\n */\n\nimport { spawn } from \"node:child_process\";\nimport { z } from \"zod\";\n\nimport { defineTool } from \"../define-tool.js\";\nimport { isForbiddenPath } from \"../internal/security/path-guard.js\";\nimport type { CustomTool } from \"../types/agent.js\";\nimport { checkPathScope } from \"./_path-scope.js\";\nimport { armTimeoutKill, attachChildSettlers } from \"./_subprocess.js\";\n\nconst DEFAULT_TIMEOUT_MS = 120_000;\nconst DEFAULT_MAX_STDOUT_BYTES = 10 * 1024 * 1024;\n\nexport interface CreateRunVitestToolOptions {\n projectRoot: string;\n timeoutMs?: number;\n maxStdoutBytes?: number;\n}\n\nexport interface VitestSummary {\n numTotalTests?: number;\n numPassedTests?: number;\n numFailedTests?: number;\n success?: boolean;\n}\n\nexport function createRunVitestTool(opts: CreateRunVitestToolOptions): CustomTool {\n const {\n projectRoot,\n timeoutMs = DEFAULT_TIMEOUT_MS,\n maxStdoutBytes = DEFAULT_MAX_STDOUT_BYTES,\n } = opts;\n\n return defineTool({\n name: \"run_vitest\",\n description:\n \"Run the project's vitest suite, optionally scoped to a file or \" +\n \"pattern via 'path'. Returns parsed { ok, summary } or { ok: false, \" +\n \"error }. Vitest stdout warnings are stripped — the parser extracts \" +\n \"the trailing JSON report.\",\n inputSchema: z.object({\n path: z\n .string()\n .optional()\n .describe(\"Optional vitest pattern or file path (project-relative).\"),\n }),\n handler: async ({ path }) => {\n const scopeError = validateVitestScope(path, projectRoot);\n if (scopeError !== null) return scopeError;\n\n const args = [\"--no-install\", \"vitest\", \"run\", \"--reporter=json\"];\n if (path !== undefined && path !== \"\") args.push(path);\n\n const result = await runProcess(projectRoot, \"npx\", args, timeoutMs, maxStdoutBytes);\n return formatVitestResult(result, timeoutMs);\n },\n });\n}\n\nfunction validateVitestScope(path: string | undefined, projectRoot: string): string | null {\n if (path !== undefined && path !== \"\" && isForbiddenPath(path)) {\n return JSON.stringify({ ok: false, error: \"forbidden_path\", path });\n }\n return checkPathScope(path, projectRoot);\n}\n\nfunction formatVitestResult(result: ProcessResult, timeoutMs: number): string {\n if (result.kind === \"timeout\") {\n return JSON.stringify({ ok: false, error: \"timeout\", timeoutMs });\n }\n if (result.kind === \"spawn_error\") {\n return JSON.stringify({ ok: false, error: \"no_vitest\", detail: result.message });\n }\n const summary = extractTrailingJson(result.stdout) as VitestSummary | null;\n if (summary === null) {\n return JSON.stringify({\n ok: false,\n error: \"unparseable_output\",\n stderrPreview: result.stderr.slice(0, 500),\n });\n }\n return JSON.stringify({ ok: true, summary });\n}\n\n/**\n * Find the LAST line in `stdout` that parses as a JSON object. Vitest\n * prepends node deprecation warnings to its JSON reporter output — if\n * we naively `JSON.parse(stdout)` we get a SyntaxError. Workaround: walk\n * lines bottom-up and return the first one that parses.\n *\n * Exported for direct unit testing without spawning vitest.\n */\nexport function extractTrailingJson(stdout: string): unknown {\n const lines = stdout.split(/\\r?\\n/);\n for (let i = lines.length - 1; i >= 0; i -= 1) {\n const line = lines[i]!.trim();\n if (line.length === 0) continue;\n if (line[0] !== \"{\" && line[0] !== \"[\") continue;\n try {\n return JSON.parse(line) as unknown;\n } catch {\n // not valid JSON — keep looking\n }\n }\n return null;\n}\n\nfunction appendCapped(chunks: Buffer[], chunk: Buffer, current: number, cap: number): number {\n if (current >= cap) return current;\n const remaining = cap - current;\n if (chunk.length > remaining) {\n chunks.push(chunk.subarray(0, remaining));\n return cap;\n }\n chunks.push(chunk);\n return current + chunk.length;\n}\n\ntype ProcessResult =\n | { kind: \"ok\"; stdout: string; stderr: string; exitCode: number }\n | { kind: \"timeout\" }\n | { kind: \"spawn_error\"; message: string };\n\nfunction runProcess(\n cwd: string,\n command: string,\n args: string[],\n timeoutMs: number,\n maxStdoutBytes: number,\n): Promise<ProcessResult> {\n return new Promise((resolve) => {\n const child = spawn(command, args, {\n cwd,\n detached: true,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n const stdoutChunks: Buffer[] = [];\n const stderrChunks: Buffer[] = [];\n let stdoutBytes = 0;\n\n const gate = armTimeoutKill<ProcessResult>(\n child,\n timeoutMs,\n () => ({ kind: \"timeout\" }),\n resolve,\n );\n\n child.stdout.on(\"data\", (chunk: Buffer) => {\n if (gate.settled()) return;\n stdoutBytes = appendCapped(stdoutChunks, chunk, stdoutBytes, maxStdoutBytes);\n });\n\n child.stderr.on(\"data\", (chunk: Buffer) => {\n stderrChunks.push(chunk);\n });\n\n attachChildSettlers<ProcessResult>(\n child,\n gate,\n (code) => ({\n kind: \"ok\",\n stdout: Buffer.concat(stdoutChunks).toString(\"utf-8\"),\n stderr: Buffer.concat(stderrChunks).toString(\"utf-8\"),\n exitCode: code ?? 0,\n }),\n (err) => ({ kind: \"spawn_error\", message: err.message }),\n resolve,\n );\n });\n}\n","/**\n * `search_text` — built-in tool for coding agents.\n *\n * Literal text search across the project tree (recursive). Sensible\n * defaults:\n *\n * - Skips forbidden directories (`.env`, `.git/`, `node_modules/`,\n * `.theo/`) so the agent never wastes context on dependency soup\n * or VCS internals.\n * - Skips files larger than `maxFileSize` (default 1 MB) and binary\n * files (null-byte detection on first 8 KB) so a megabyte of\n * minified JS never blows up the result.\n * - Caps total matches at `maxMatches` (default 100) — the agent\n * should refine the query if it gets close to the cap.\n *\n * Result shape (always a JSON string):\n * - `{ ok: true, matches: Array<{ file, line, preview }>, truncated, totalMatches }`\n * - `{ ok: false, error: 'path_traversal' | 'forbidden_path' | 'not_found' }`\n *\n * Implementation note: this is a plain JS recursive walk. For very\n * large repos a future iteration can shell out to `rg` (ripgrep) when\n * present, but the JS path stays as the dependency-free fallback.\n */\n\nimport type { Dirent } from \"node:fs\";\nimport { readdir, readFile } from \"node:fs/promises\";\nimport { join, relative as relativePath } from \"node:path\";\nimport { z } from \"zod\";\n\nimport { defineTool } from \"../define-tool.js\";\nimport {\n assertNoSymlinkEscape,\n ForbiddenPathError,\n isForbiddenPath,\n PathTraversalError,\n safePathJoin,\n} from \"../internal/security/path-guard.js\";\nimport type { CustomTool } from \"../types/agent.js\";\n\nconst DEFAULT_MAX_MATCHES = 100;\nconst DEFAULT_MAX_FILE_SIZE = 1024 * 1024; // 1 MB\nconst BINARY_PROBE_BYTES = 8 * 1024;\nconst PREVIEW_MAX = 200;\n\nexport interface CreateSearchTextToolOptions {\n projectRoot: string;\n /** Cap on total matches returned. Default 100. */\n maxMatches?: number;\n /** Skip files larger than this (bytes). Default 1 MB. */\n maxFileSize?: number;\n}\n\ninterface Match {\n file: string;\n line: number;\n preview: string;\n}\n\nexport function createSearchTextTool(opts: CreateSearchTextToolOptions): CustomTool {\n const {\n projectRoot,\n maxMatches = DEFAULT_MAX_MATCHES,\n maxFileSize = DEFAULT_MAX_FILE_SIZE,\n } = opts;\n\n return defineTool({\n name: \"search_text\",\n description:\n `Search the project tree for a literal text query. Skips sensitive ` +\n `dirs (.env/.git/node_modules/.theo), binary files, and files over ` +\n `1 MB. Returns up to ${String(maxMatches)} matches as { file, line, preview }. ` +\n `Use 'path' to scope the search to a subdirectory.`,\n inputSchema: z.object({\n query: z.string().min(1).describe(\"Literal text to search for. Case-sensitive.\"),\n path: z\n .string()\n .optional()\n .describe(\"Optional project-relative directory to scope the search.\"),\n }),\n handler: async ({ query, path }) => {\n const scope = resolveSearchScope(path, projectRoot);\n if (\"error\" in scope) return scope.error;\n const state: SearchState = {\n matches: [],\n totalMatches: 0,\n truncated: false,\n query,\n maxMatches,\n maxFileSize,\n projectRoot,\n };\n await walk(scope.scopeAbs, state);\n return JSON.stringify({\n ok: true,\n matches: state.matches,\n truncated: state.truncated,\n totalMatches: state.totalMatches,\n });\n },\n });\n}\n\ninterface SearchState {\n matches: Match[];\n totalMatches: number;\n truncated: boolean;\n query: string;\n maxMatches: number;\n maxFileSize: number;\n projectRoot: string;\n}\n\nfunction resolveSearchScope(\n path: string | undefined,\n projectRoot: string,\n): { scopeAbs: string } | { error: string } {\n const scopeRel = path === undefined || path === \"\" || path === \".\" ? \".\" : path;\n try {\n const scopeAbs = scopeRel === \".\" ? projectRoot : safePathJoin(projectRoot, scopeRel);\n assertNoSymlinkEscape(scopeAbs, projectRoot);\n return { scopeAbs };\n } catch (err) {\n if (err instanceof PathTraversalError || err instanceof ForbiddenPathError) {\n return { error: JSON.stringify({ ok: false, error: \"path_traversal\", path }) };\n }\n throw err;\n }\n}\n\nasync function handleEntry(entry: Dirent, absDir: string, state: SearchState): Promise<void> {\n const entryAbs = join(absDir, entry.name);\n const entryRel = relativePath(state.projectRoot, entryAbs);\n if (isForbiddenPath(entryRel)) return;\n if (entry.isDirectory()) {\n await walk(entryAbs, state);\n return;\n }\n if (entry.isFile()) await scanFile(entryAbs, entryRel, state);\n}\n\nasync function walk(absDir: string, state: SearchState): Promise<void> {\n if (state.truncated) return;\n const entries = await readEntriesQuiet(absDir);\n if (entries === null) return;\n for (const entry of entries) {\n if (state.truncated) return;\n await handleEntry(entry, absDir, state);\n }\n}\n\nasync function readEntriesQuiet(absDir: string): Promise<Dirent[] | null> {\n try {\n return await readdir(absDir, { withFileTypes: true });\n } catch {\n return null;\n }\n}\n\nasync function readBufferQuiet(absPath: string): Promise<Buffer | null> {\n try {\n return await readFile(absPath);\n } catch {\n return null;\n }\n}\n\nfunction isBinaryBuffer(buffer: Buffer): boolean {\n const probeEnd = Math.min(buffer.length, BINARY_PROBE_BYTES);\n for (let i = 0; i < probeEnd; i += 1) {\n if (buffer[i] === 0) return true;\n }\n return false;\n}\n\nfunction recordMatch(state: SearchState, file: string, line: number, lineText: string): boolean {\n state.totalMatches += 1;\n if (state.matches.length < state.maxMatches) {\n state.matches.push({\n file,\n line,\n preview: lineText.length > PREVIEW_MAX ? `${lineText.slice(0, PREVIEW_MAX)}…` : lineText,\n });\n return true;\n }\n state.truncated = true;\n return false;\n}\n\nasync function scanFile(absPath: string, relPath: string, state: SearchState): Promise<void> {\n const buffer = await readBufferQuiet(absPath);\n if (buffer === null || buffer.length > state.maxFileSize) return;\n if (isBinaryBuffer(buffer)) return;\n const lines = buffer.toString(\"utf-8\").split(\"\\n\");\n for (let i = 0; i < lines.length; i += 1) {\n const line = lines[i]!;\n if (!line.includes(state.query)) continue;\n if (!recordMatch(state, relPath, i + 1, line)) return;\n }\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `toShareGptTrajectory` — opt-in BatchResult → ShareGPT converter (ADR D139).
|
|
3
|
+
*
|
|
4
|
+
* Pure transformation. Returns `null` for failed results so callers can
|
|
5
|
+
* filter via `.map(toShareGptTrajectory).filter(Boolean)`. Tool calls and
|
|
6
|
+
* tool results are preserved when an SDKMessage trace is provided; otherwise
|
|
7
|
+
* a minimal `human → gpt` trajectory is emitted from the final text.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
import type { BatchResult } from "./types/batch.js";
|
|
12
|
+
import type { SDKMessage } from "./types/messages.js";
|
|
13
|
+
import type { ShareGptTrajectory } from "./types/trajectory.js";
|
|
14
|
+
/**
|
|
15
|
+
* Convert a successful `BatchResult` to ShareGPT-format trajectory.
|
|
16
|
+
*
|
|
17
|
+
* Behavior:
|
|
18
|
+
* - `result.ok === false` → returns `null` (EC-11).
|
|
19
|
+
* - First entry is always `{from: "human", value: result.prompt}`.
|
|
20
|
+
* - When `options.messages` is supplied, each SDKMessage maps to one or
|
|
21
|
+
* more ShareGPT entries (assistant text → gpt, tool_use → gpt + tool).
|
|
22
|
+
* - Without `options.messages`, fall back to a single `{from: "gpt"}`
|
|
23
|
+
* entry carrying `result.result.result` (the final text) when present.
|
|
24
|
+
* - Malformed message entries are silently skipped (EC-F / EC-14).
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare function toShareGptTrajectory(result: BatchResult, options?: {
|
|
29
|
+
messages?: SDKMessage[];
|
|
30
|
+
model?: string;
|
|
31
|
+
}): ShareGptTrajectory | null;
|