@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,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in tools for `@theokit/sdk` agents (`@theokit/sdk/tools`).
|
|
3
|
+
*
|
|
4
|
+
* Each factory returns a `CustomTool` ready to drop into `Agent.create`
|
|
5
|
+
* or `createAgentFactory({ tools: [...] })`. All five share three
|
|
6
|
+
* design rules:
|
|
7
|
+
*
|
|
8
|
+
* 1. **Project-scoped**. Every factory takes `{ projectRoot }` and
|
|
9
|
+
* gates every I/O call against that boundary via the SDK's
|
|
10
|
+
* `safePathJoin` + `assertNoSymlinkEscape` primitives.
|
|
11
|
+
*
|
|
12
|
+
* 2. **Sensitive files refused**. `.env*` (except `.env.example`),
|
|
13
|
+
* `.git/`, `node_modules/`, `.theo/`, and lock files are blocked
|
|
14
|
+
* via `isForbiddenPath`.
|
|
15
|
+
*
|
|
16
|
+
* 3. **JSON returns, never throws on user mistakes**. Handlers return
|
|
17
|
+
* `{ ok: true, ... }` or `{ ok: false, error: '...' }`. Real
|
|
18
|
+
* exceptions are reserved for SDK-side bugs (input parse errors,
|
|
19
|
+
* unexpected fs failures).
|
|
20
|
+
*
|
|
21
|
+
* Consumers: TheoKit Studio (the embedded coding agent), `cli-bot`
|
|
22
|
+
* (the SDK's reference example), and any future coding-agent built on
|
|
23
|
+
* `@theokit/sdk`.
|
|
24
|
+
*/
|
|
25
|
+
export { type CreateGitDiffToolOptions, createGitDiffTool } from "./git-diff.js";
|
|
26
|
+
export { type CreateListDirToolOptions, createListDirTool } from "./list-dir.js";
|
|
27
|
+
export { type CreateReadFileToolOptions, createReadFileTool } from "./read-file.js";
|
|
28
|
+
export { type CreateRunVitestToolOptions, createRunVitestTool, type VitestSummary, } from "./run-vitest.js";
|
|
29
|
+
export { type CreateSearchTextToolOptions, createSearchTextTool } from "./search-text.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `list_dir` — built-in tool for coding agents.
|
|
3
|
+
*
|
|
4
|
+
* Returns the direct entries of a project-relative directory. Hardened
|
|
5
|
+
* against the same four bug families as `read_file` plus the
|
|
6
|
+
* **EC-6 unbounded output** failure mode: in a project with 10k files,
|
|
7
|
+
* a naive listing returns a 5 MB JSON payload that freezes the browser
|
|
8
|
+
* and (more importantly) blows past the LLM context window.
|
|
9
|
+
*
|
|
10
|
+
* Defaults:
|
|
11
|
+
* - `max = 500` entries (override via factory option `{ max }`)
|
|
12
|
+
* - Result includes `{ truncated: boolean, totalCount: number }` so the
|
|
13
|
+
* agent can decide whether to drill deeper or call `search_text` instead
|
|
14
|
+
*
|
|
15
|
+
* Result shape (always a JSON string):
|
|
16
|
+
* - `{ ok: true, entries: Array<{ name, type }>, truncated, totalCount }`
|
|
17
|
+
* - `{ ok: false, error: 'path_traversal' | 'forbidden_path' | 'not_found' }`
|
|
18
|
+
*/
|
|
19
|
+
import type { CustomTool } from "../types/agent.js";
|
|
20
|
+
export interface CreateListDirToolOptions {
|
|
21
|
+
/** Absolute path to the project root. Every listing is gated against this boundary. */
|
|
22
|
+
projectRoot: string;
|
|
23
|
+
/** Maximum number of entries returned per call. Default 500. */
|
|
24
|
+
max?: number;
|
|
25
|
+
}
|
|
26
|
+
export declare function createListDirTool(opts: CreateListDirToolOptions): CustomTool;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `list_dir` — built-in tool for coding agents.
|
|
3
|
+
*
|
|
4
|
+
* Returns the direct entries of a project-relative directory. Hardened
|
|
5
|
+
* against the same four bug families as `read_file` plus the
|
|
6
|
+
* **EC-6 unbounded output** failure mode: in a project with 10k files,
|
|
7
|
+
* a naive listing returns a 5 MB JSON payload that freezes the browser
|
|
8
|
+
* and (more importantly) blows past the LLM context window.
|
|
9
|
+
*
|
|
10
|
+
* Defaults:
|
|
11
|
+
* - `max = 500` entries (override via factory option `{ max }`)
|
|
12
|
+
* - Result includes `{ truncated: boolean, totalCount: number }` so the
|
|
13
|
+
* agent can decide whether to drill deeper or call `search_text` instead
|
|
14
|
+
*
|
|
15
|
+
* Result shape (always a JSON string):
|
|
16
|
+
* - `{ ok: true, entries: Array<{ name, type }>, truncated, totalCount }`
|
|
17
|
+
* - `{ ok: false, error: 'path_traversal' | 'forbidden_path' | 'not_found' }`
|
|
18
|
+
*/
|
|
19
|
+
import type { CustomTool } from "../types/agent.js";
|
|
20
|
+
export interface CreateListDirToolOptions {
|
|
21
|
+
/** Absolute path to the project root. Every listing is gated against this boundary. */
|
|
22
|
+
projectRoot: string;
|
|
23
|
+
/** Maximum number of entries returned per call. Default 500. */
|
|
24
|
+
max?: number;
|
|
25
|
+
}
|
|
26
|
+
export declare function createListDirTool(opts: CreateListDirToolOptions): CustomTool;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `read_file` — built-in tool for coding agents.
|
|
3
|
+
*
|
|
4
|
+
* Reads a project-relative file as UTF-8 and returns its contents.
|
|
5
|
+
* Hardened against the four bug families a coding agent normally hits:
|
|
6
|
+
*
|
|
7
|
+
* 1. **Path traversal** — `safePathJoin` rejects literal `..`,
|
|
8
|
+
* normalised escape, absolute segments, null-byte injection.
|
|
9
|
+
* 2. **Symlink escape** — `assertNoSymlinkEscape` follows the full
|
|
10
|
+
* chain (and any intermediate symlinks; defence-in-depth fix v1.x).
|
|
11
|
+
* 3. **Sensitive files** — `isForbiddenPath` blocks `.env*` (except
|
|
12
|
+
* `.env.example`), `.git/`, `node_modules/`, `.theo/`, lock files.
|
|
13
|
+
* 4. **Binary files** — null-byte check on the first 8 KB. PNG/JPEG/
|
|
14
|
+
* compiled binaries return a structured `binary_file` error
|
|
15
|
+
* instead of garbled UTF-8 (EC-5 from the TheoKit Studio review).
|
|
16
|
+
*
|
|
17
|
+
* Return shape (always a JSON string the LLM consumes):
|
|
18
|
+
* - `{ ok: true, content: string }` on success
|
|
19
|
+
* - `{ ok: false, error: 'path_traversal' | 'forbidden_path' |
|
|
20
|
+
* 'binary_file' | 'not_found' | 'too_large' }` on refusal
|
|
21
|
+
*
|
|
22
|
+
* The handler intentionally never throws on a "user mistake"
|
|
23
|
+
* (traversal / forbidden / not found). Throwing reserved for SDK-side
|
|
24
|
+
* mistakes that should crash the agent loop (input parse errors).
|
|
25
|
+
*/
|
|
26
|
+
import type { CustomTool } from "../types/agent.js";
|
|
27
|
+
export interface CreateReadFileToolOptions {
|
|
28
|
+
/** Absolute path to the project root. Every read is gated against this boundary. */
|
|
29
|
+
projectRoot: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function createReadFileTool(opts: CreateReadFileToolOptions): CustomTool;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `read_file` — built-in tool for coding agents.
|
|
3
|
+
*
|
|
4
|
+
* Reads a project-relative file as UTF-8 and returns its contents.
|
|
5
|
+
* Hardened against the four bug families a coding agent normally hits:
|
|
6
|
+
*
|
|
7
|
+
* 1. **Path traversal** — `safePathJoin` rejects literal `..`,
|
|
8
|
+
* normalised escape, absolute segments, null-byte injection.
|
|
9
|
+
* 2. **Symlink escape** — `assertNoSymlinkEscape` follows the full
|
|
10
|
+
* chain (and any intermediate symlinks; defence-in-depth fix v1.x).
|
|
11
|
+
* 3. **Sensitive files** — `isForbiddenPath` blocks `.env*` (except
|
|
12
|
+
* `.env.example`), `.git/`, `node_modules/`, `.theo/`, lock files.
|
|
13
|
+
* 4. **Binary files** — null-byte check on the first 8 KB. PNG/JPEG/
|
|
14
|
+
* compiled binaries return a structured `binary_file` error
|
|
15
|
+
* instead of garbled UTF-8 (EC-5 from the TheoKit Studio review).
|
|
16
|
+
*
|
|
17
|
+
* Return shape (always a JSON string the LLM consumes):
|
|
18
|
+
* - `{ ok: true, content: string }` on success
|
|
19
|
+
* - `{ ok: false, error: 'path_traversal' | 'forbidden_path' |
|
|
20
|
+
* 'binary_file' | 'not_found' | 'too_large' }` on refusal
|
|
21
|
+
*
|
|
22
|
+
* The handler intentionally never throws on a "user mistake"
|
|
23
|
+
* (traversal / forbidden / not found). Throwing reserved for SDK-side
|
|
24
|
+
* mistakes that should crash the agent loop (input parse errors).
|
|
25
|
+
*/
|
|
26
|
+
import type { CustomTool } from "../types/agent.js";
|
|
27
|
+
export interface CreateReadFileToolOptions {
|
|
28
|
+
/** Absolute path to the project root. Every read is gated against this boundary. */
|
|
29
|
+
projectRoot: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function createReadFileTool(opts: CreateReadFileToolOptions): CustomTool;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `run_vitest` — built-in tool for coding agents.
|
|
3
|
+
*
|
|
4
|
+
* Runs vitest against an optional file/pattern scope and returns the
|
|
5
|
+
* parsed JSON report. Hardened against the same subprocess failure
|
|
6
|
+
* modes as `git_diff`:
|
|
7
|
+
*
|
|
8
|
+
* - 120s wall clock timeout (vitest can be slow on first run)
|
|
9
|
+
* - Process group kill on timeout (EC-7 — defeats vitest workers as
|
|
10
|
+
* grandchildren of the spawned shell)
|
|
11
|
+
* - **EC-12**: vitest stdout may contain deprecation warnings BEFORE
|
|
12
|
+
* the JSON payload. The parser scans line-by-line and extracts the
|
|
13
|
+
* LAST valid JSON object, not the first.
|
|
14
|
+
*
|
|
15
|
+
* Result shape (always a JSON string):
|
|
16
|
+
* - `{ ok: true, summary: { numTotalTests, numPassedTests, numFailedTests, success } }`
|
|
17
|
+
* - `{ ok: false, error: 'path_traversal' | 'forbidden_path' | 'timeout' |
|
|
18
|
+
* 'no_vitest' | 'unparseable_output' }`
|
|
19
|
+
*
|
|
20
|
+
* Implementation note: invokes vitest via `npx --no-install vitest`. The
|
|
21
|
+
* `--no-install` avoids the agent triggering a multi-megabyte download
|
|
22
|
+
* mid-turn if vitest is missing — the tool fails cleanly with
|
|
23
|
+
* `no_vitest` instead.
|
|
24
|
+
*/
|
|
25
|
+
import type { CustomTool } from "../types/agent.js";
|
|
26
|
+
export interface CreateRunVitestToolOptions {
|
|
27
|
+
projectRoot: string;
|
|
28
|
+
timeoutMs?: number;
|
|
29
|
+
maxStdoutBytes?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface VitestSummary {
|
|
32
|
+
numTotalTests?: number;
|
|
33
|
+
numPassedTests?: number;
|
|
34
|
+
numFailedTests?: number;
|
|
35
|
+
success?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare function createRunVitestTool(opts: CreateRunVitestToolOptions): CustomTool;
|
|
38
|
+
/**
|
|
39
|
+
* Find the LAST line in `stdout` that parses as a JSON object. Vitest
|
|
40
|
+
* prepends node deprecation warnings to its JSON reporter output — if
|
|
41
|
+
* we naively `JSON.parse(stdout)` we get a SyntaxError. Workaround: walk
|
|
42
|
+
* lines bottom-up and return the first one that parses.
|
|
43
|
+
*
|
|
44
|
+
* Exported for direct unit testing without spawning vitest.
|
|
45
|
+
*/
|
|
46
|
+
export declare function extractTrailingJson(stdout: string): unknown;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `run_vitest` — built-in tool for coding agents.
|
|
3
|
+
*
|
|
4
|
+
* Runs vitest against an optional file/pattern scope and returns the
|
|
5
|
+
* parsed JSON report. Hardened against the same subprocess failure
|
|
6
|
+
* modes as `git_diff`:
|
|
7
|
+
*
|
|
8
|
+
* - 120s wall clock timeout (vitest can be slow on first run)
|
|
9
|
+
* - Process group kill on timeout (EC-7 — defeats vitest workers as
|
|
10
|
+
* grandchildren of the spawned shell)
|
|
11
|
+
* - **EC-12**: vitest stdout may contain deprecation warnings BEFORE
|
|
12
|
+
* the JSON payload. The parser scans line-by-line and extracts the
|
|
13
|
+
* LAST valid JSON object, not the first.
|
|
14
|
+
*
|
|
15
|
+
* Result shape (always a JSON string):
|
|
16
|
+
* - `{ ok: true, summary: { numTotalTests, numPassedTests, numFailedTests, success } }`
|
|
17
|
+
* - `{ ok: false, error: 'path_traversal' | 'forbidden_path' | 'timeout' |
|
|
18
|
+
* 'no_vitest' | 'unparseable_output' }`
|
|
19
|
+
*
|
|
20
|
+
* Implementation note: invokes vitest via `npx --no-install vitest`. The
|
|
21
|
+
* `--no-install` avoids the agent triggering a multi-megabyte download
|
|
22
|
+
* mid-turn if vitest is missing — the tool fails cleanly with
|
|
23
|
+
* `no_vitest` instead.
|
|
24
|
+
*/
|
|
25
|
+
import type { CustomTool } from "../types/agent.js";
|
|
26
|
+
export interface CreateRunVitestToolOptions {
|
|
27
|
+
projectRoot: string;
|
|
28
|
+
timeoutMs?: number;
|
|
29
|
+
maxStdoutBytes?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface VitestSummary {
|
|
32
|
+
numTotalTests?: number;
|
|
33
|
+
numPassedTests?: number;
|
|
34
|
+
numFailedTests?: number;
|
|
35
|
+
success?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare function createRunVitestTool(opts: CreateRunVitestToolOptions): CustomTool;
|
|
38
|
+
/**
|
|
39
|
+
* Find the LAST line in `stdout` that parses as a JSON object. Vitest
|
|
40
|
+
* prepends node deprecation warnings to its JSON reporter output — if
|
|
41
|
+
* we naively `JSON.parse(stdout)` we get a SyntaxError. Workaround: walk
|
|
42
|
+
* lines bottom-up and return the first one that parses.
|
|
43
|
+
*
|
|
44
|
+
* Exported for direct unit testing without spawning vitest.
|
|
45
|
+
*/
|
|
46
|
+
export declare function extractTrailingJson(stdout: string): unknown;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `search_text` — built-in tool for coding agents.
|
|
3
|
+
*
|
|
4
|
+
* Literal text search across the project tree (recursive). Sensible
|
|
5
|
+
* defaults:
|
|
6
|
+
*
|
|
7
|
+
* - Skips forbidden directories (`.env`, `.git/`, `node_modules/`,
|
|
8
|
+
* `.theo/`) so the agent never wastes context on dependency soup
|
|
9
|
+
* or VCS internals.
|
|
10
|
+
* - Skips files larger than `maxFileSize` (default 1 MB) and binary
|
|
11
|
+
* files (null-byte detection on first 8 KB) so a megabyte of
|
|
12
|
+
* minified JS never blows up the result.
|
|
13
|
+
* - Caps total matches at `maxMatches` (default 100) — the agent
|
|
14
|
+
* should refine the query if it gets close to the cap.
|
|
15
|
+
*
|
|
16
|
+
* Result shape (always a JSON string):
|
|
17
|
+
* - `{ ok: true, matches: Array<{ file, line, preview }>, truncated, totalMatches }`
|
|
18
|
+
* - `{ ok: false, error: 'path_traversal' | 'forbidden_path' | 'not_found' }`
|
|
19
|
+
*
|
|
20
|
+
* Implementation note: this is a plain JS recursive walk. For very
|
|
21
|
+
* large repos a future iteration can shell out to `rg` (ripgrep) when
|
|
22
|
+
* present, but the JS path stays as the dependency-free fallback.
|
|
23
|
+
*/
|
|
24
|
+
import type { CustomTool } from "../types/agent.js";
|
|
25
|
+
export interface CreateSearchTextToolOptions {
|
|
26
|
+
projectRoot: string;
|
|
27
|
+
/** Cap on total matches returned. Default 100. */
|
|
28
|
+
maxMatches?: number;
|
|
29
|
+
/** Skip files larger than this (bytes). Default 1 MB. */
|
|
30
|
+
maxFileSize?: number;
|
|
31
|
+
}
|
|
32
|
+
export declare function createSearchTextTool(opts: CreateSearchTextToolOptions): CustomTool;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `search_text` — built-in tool for coding agents.
|
|
3
|
+
*
|
|
4
|
+
* Literal text search across the project tree (recursive). Sensible
|
|
5
|
+
* defaults:
|
|
6
|
+
*
|
|
7
|
+
* - Skips forbidden directories (`.env`, `.git/`, `node_modules/`,
|
|
8
|
+
* `.theo/`) so the agent never wastes context on dependency soup
|
|
9
|
+
* or VCS internals.
|
|
10
|
+
* - Skips files larger than `maxFileSize` (default 1 MB) and binary
|
|
11
|
+
* files (null-byte detection on first 8 KB) so a megabyte of
|
|
12
|
+
* minified JS never blows up the result.
|
|
13
|
+
* - Caps total matches at `maxMatches` (default 100) — the agent
|
|
14
|
+
* should refine the query if it gets close to the cap.
|
|
15
|
+
*
|
|
16
|
+
* Result shape (always a JSON string):
|
|
17
|
+
* - `{ ok: true, matches: Array<{ file, line, preview }>, truncated, totalMatches }`
|
|
18
|
+
* - `{ ok: false, error: 'path_traversal' | 'forbidden_path' | 'not_found' }`
|
|
19
|
+
*
|
|
20
|
+
* Implementation note: this is a plain JS recursive walk. For very
|
|
21
|
+
* large repos a future iteration can shell out to `rg` (ripgrep) when
|
|
22
|
+
* present, but the JS path stays as the dependency-free fallback.
|
|
23
|
+
*/
|
|
24
|
+
import type { CustomTool } from "../types/agent.js";
|
|
25
|
+
export interface CreateSearchTextToolOptions {
|
|
26
|
+
projectRoot: string;
|
|
27
|
+
/** Cap on total matches returned. Default 100. */
|
|
28
|
+
maxMatches?: number;
|
|
29
|
+
/** Skip files larger than this (bytes). Default 1 MB. */
|
|
30
|
+
maxFileSize?: number;
|
|
31
|
+
}
|
|
32
|
+
export declare function createSearchTextTool(opts: CreateSearchTextToolOptions): CustomTool;
|