@theokit/sdk 1.6.1 → 1.7.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 +187 -0
- package/dist/a2a/agent-mailbox.d.cts +27 -0
- package/dist/a2a/agent-mailbox.d.ts +27 -0
- package/dist/a2a/index.cjs +16850 -0
- package/dist/a2a/index.cjs.map +1 -0
- package/dist/a2a/index.d.cts +9 -0
- package/dist/a2a/index.d.ts +9 -0
- package/dist/a2a/index.js +16844 -0
- package/dist/a2a/index.js.map +1 -0
- package/dist/a2a/message-bus.d.cts +27 -0
- package/dist/a2a/message-bus.d.ts +27 -0
- package/dist/a2a/subagent.d.cts +25 -0
- package/dist/a2a/subagent.d.ts +25 -0
- package/dist/a2a/types.d.cts +12 -0
- package/dist/a2a/types.d.ts +12 -0
- package/dist/agent.d.ts +1 -1
- package/dist/client/index.cjs +73 -0
- package/dist/client/index.cjs.map +1 -0
- package/dist/client/index.d.cts +7 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/index.js +71 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/theokit-client.d.cts +18 -0
- package/dist/client/theokit-client.d.ts +18 -0
- package/dist/client/types.d.cts +19 -0
- package/dist/client/types.d.ts +19 -0
- package/dist/{run-DkCD5DeO.d.cts → cron-BnywDYLq.d.cts} +496 -910
- package/dist/{run-DkCD5DeO.d.ts → cron-CtZvJD9J.d.ts} +496 -910
- package/dist/cron.cjs +4285 -2893
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +2 -3
- package/dist/cron.d.ts +2 -71
- package/dist/cron.js +4289 -2897
- package/dist/cron.js.map +1 -1
- package/dist/{errors-CvAeEWgE.d.ts → errors-ChqOmFH1.d.cts} +52 -6
- package/dist/{errors-CK8brCJ1.d.cts → errors-DV9e0rcp.d.ts} +52 -6
- package/dist/errors.cjs +218 -3
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +2 -3
- package/dist/errors.d.ts +50 -4
- package/dist/errors.js +217 -4
- package/dist/errors.js.map +1 -1
- package/dist/eval.cjs +4285 -2893
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.d.cts +35 -0
- package/dist/eval.js +4289 -2897
- package/dist/eval.js.map +1 -1
- package/dist/event-bus.d.ts +23 -0
- package/dist/index.cjs +5132 -4200
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +298 -278
- package/dist/index.d.ts +1898 -24
- package/dist/index.js +6441 -5509
- package/dist/index.js.map +1 -1
- package/dist/internal/agent-loop/loop-context-init.d.ts +2 -0
- package/dist/internal/agent-loop/tool-dispatch.d.ts +22 -1
- package/dist/internal/auth/api-key-validator.d.ts +46 -0
- package/dist/internal/llm/anthropic-shared.d.ts +8 -1
- package/dist/internal/llm/retry.d.ts +22 -0
- package/dist/internal/llm/types.d.ts +47 -1
- package/dist/internal/memory/active-memory-cache.d.ts +3 -3
- package/dist/internal/memory/active-memory-types.d.ts +8 -0
- package/dist/internal/memory/active-memory.d.ts +24 -20
- package/dist/internal/memory/adapters/azure-openai-embedding.d.ts +2 -0
- package/dist/internal/memory/adapters/cohere-embedding.d.ts +2 -0
- package/dist/internal/memory/adapters/gemini-embedding.d.ts +2 -0
- package/dist/internal/memory/adapters/jina-embedding.d.ts +2 -0
- package/dist/internal/memory/index-manager-contract.d.ts +26 -0
- package/dist/internal/memory/index-manager-dispatch.d.ts +1 -1
- package/dist/internal/memory/index-manager.d.ts +8 -26
- package/dist/internal/memory/{chunk-markdown.d.ts → storage/chunk-markdown.d.ts} +1 -1
- package/dist/internal/memory/{markdown-store.d.ts → storage/markdown-store.d.ts} +1 -1
- package/dist/internal/memory/{reader.d.ts → storage/reader.d.ts} +1 -1
- package/dist/internal/observability/context.d.cts +23 -0
- package/dist/internal/observability/context.d.ts +23 -0
- package/dist/internal/observability/index.cjs +38 -0
- package/dist/internal/observability/index.cjs.map +1 -0
- package/dist/internal/observability/index.d.cts +8 -0
- package/dist/internal/observability/index.d.ts +8 -0
- package/dist/internal/observability/index.js +33 -0
- package/dist/internal/observability/index.js.map +1 -0
- package/dist/internal/observability/tracer-loader.d.cts +20 -0
- package/dist/internal/persistence/conversation-storage-fs.d.cts +37 -0
- package/dist/internal/persistence/conversation-storage-memory.d.cts +24 -0
- package/dist/internal/persistence/credential-pool-store.d.cts +32 -0
- package/dist/internal/persistence/credential-pool-store.d.ts +32 -0
- package/dist/internal/persistence/cwd-mutex.d.cts +1 -0
- package/dist/internal/persistence/exclusive-create.d.cts +22 -0
- package/dist/internal/persistence/exclusive-create.d.ts +22 -0
- package/dist/internal/persistence/file-lock.d.cts +14 -0
- package/dist/internal/persistence/fts5-sanitize.d.cts +16 -0
- package/dist/internal/persistence/index.cjs +359 -0
- package/dist/internal/persistence/index.cjs.map +1 -0
- package/dist/internal/persistence/index.d.cts +20 -0
- package/dist/internal/persistence/index.d.ts +20 -0
- package/dist/internal/persistence/index.js +341 -0
- package/dist/internal/persistence/index.js.map +1 -0
- package/dist/internal/persistence/markdown-config-loader.d.cts +35 -0
- package/dist/internal/persistence/paths.d.cts +19 -0
- package/dist/internal/persistence/persistence-schema.d.cts +21 -0
- package/dist/internal/persistence/persistence-schema.d.ts +4 -0
- package/dist/internal/persistence/schema-version.d.cts +13 -0
- package/dist/internal/persistence/sqlite-cas.d.cts +25 -0
- package/dist/internal/persistence/sqlite-cas.d.ts +25 -0
- package/dist/internal/persistence/sqlite-wal.d.cts +10 -0
- package/dist/internal/plugins/context.d.cts +31 -0
- package/dist/internal/plugins/index.cjs +228 -0
- package/dist/internal/plugins/index.cjs.map +1 -0
- package/dist/internal/plugins/index.d.cts +8 -0
- package/dist/internal/plugins/index.d.ts +8 -0
- package/dist/internal/plugins/index.js +222 -0
- package/dist/internal/plugins/index.js.map +1 -0
- package/dist/internal/plugins/lifecycle.d.cts +14 -0
- package/dist/internal/plugins/lifecycle.d.ts +14 -0
- package/dist/internal/plugins/manager.d.cts +37 -0
- package/dist/internal/plugins/types.d.cts +102 -0
- package/dist/internal/providers/catalog-loader.d.ts +39 -0
- package/dist/internal/runtime/agent-session-store.d.ts +1 -1
- package/dist/internal/runtime/agent-session.d.ts +1 -0
- package/dist/internal/runtime/budget-tracker.d.ts +73 -0
- package/dist/internal/runtime/{context-manager.d.ts → context/context-manager.d.ts} +1 -1
- package/dist/internal/runtime/{fixture-events.d.ts → fixtures/fixture-events.d.ts} +1 -1
- package/dist/internal/runtime/{fixture-run-base.d.ts → fixtures/fixture-run-base.d.ts} +4 -4
- package/dist/internal/runtime/{fixture-scripts.d.ts → fixtures/fixture-scripts.d.ts} +1 -1
- package/dist/internal/runtime/local-agent-bootstrap.d.ts +2 -2
- package/dist/internal/runtime/local-agent-memory-provider.d.ts +57 -0
- package/dist/internal/runtime/memory-path-selector.d.ts +73 -0
- package/dist/internal/runtime/memory-provider.d.ts +165 -0
- package/dist/internal/runtime/{agent-registry.d.ts → registry/agent-registry-contract.d.ts} +15 -9
- package/dist/internal/runtime/registry/agent-registry.d.ts +7 -0
- package/dist/internal/runtime/{live-agent-registry.d.ts → registry/live-agent-registry.d.ts} +1 -1
- package/dist/internal/runtime/{run-registry.d.ts → registry/run-registry.d.ts} +1 -1
- package/dist/internal/runtime/session-types.d.ts +35 -0
- package/dist/internal/runtime/system-prompt/sources/skills-provider.d.ts +1 -0
- package/dist/internal/runtime/validate-response.d.ts +18 -0
- package/dist/internal/security/index.cjs +361 -0
- package/dist/internal/security/index.cjs.map +1 -0
- package/dist/internal/security/index.d.cts +11 -0
- package/dist/internal/security/index.js +350 -0
- package/dist/internal/security/index.js.map +1 -0
- package/dist/internal/security/path-guard.d.cts +59 -0
- package/dist/internal/security/path-guard.d.ts +3 -0
- package/dist/internal/security/redact.d.cts +21 -0
- package/dist/internal/security/secret-redactor.d.cts +1 -0
- package/dist/internal/security/secret-redactor.d.ts +1 -0
- package/dist/internal/security/test-reset.d.cts +10 -0
- package/dist/internal/security/test-reset.d.ts +10 -0
- package/dist/internal/telemetry/adapters/arize.d.ts +2 -0
- package/dist/internal/telemetry/adapters/braintrust.d.ts +2 -0
- package/dist/internal/telemetry/adapters/datadog.d.ts +2 -0
- package/dist/internal/telemetry/adapters/langsmith.d.ts +2 -0
- package/dist/internal/telemetry/span-names.d.ts +6 -0
- package/dist/internal/telemetry/tracer.d.ts +1 -0
- package/dist/internal/workflow/evented-executor.d.ts +42 -0
- package/dist/internal/workflow/scheduler.d.ts +23 -0
- package/dist/internal/zod/to-json-schema.d.ts +5 -15
- package/dist/job-queue.d.ts +28 -0
- package/dist/path-safety.cjs +67 -6
- package/dist/path-safety.cjs.map +1 -1
- package/dist/path-safety.d.cts +15 -0
- package/dist/path-safety.d.ts +1 -1
- package/dist/path-safety.js +67 -7
- package/dist/path-safety.js.map +1 -1
- package/dist/permission-engine.d.ts +21 -0
- package/dist/provider-catalog.json +702 -0
- package/dist/rag/index.cjs +136 -0
- package/dist/rag/index.cjs.map +1 -0
- package/dist/rag/index.d.cts +11 -0
- package/dist/rag/index.d.ts +11 -0
- package/dist/rag/index.js +129 -0
- package/dist/rag/index.js.map +1 -0
- package/dist/rag/reranker.d.cts +26 -0
- package/dist/rag/reranker.d.ts +26 -0
- package/dist/rag/retriever.d.cts +25 -0
- package/dist/rag/retriever.d.ts +25 -0
- package/dist/rag/text-splitter.d.cts +12 -0
- package/dist/rag/text-splitter.d.ts +12 -0
- package/dist/rag/types.d.cts +37 -0
- package/dist/rag/types.d.ts +37 -0
- package/dist/run-DrwUpFxZ.d.cts +823 -0
- package/dist/run-DrwUpFxZ.d.ts +823 -0
- package/dist/sandbox/index.cjs +133 -0
- package/dist/sandbox/index.cjs.map +1 -0
- package/dist/sandbox/index.d.cts +2 -0
- package/dist/sandbox/index.d.ts +2 -0
- package/dist/sandbox/index.js +128 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/sandbox/local-sandbox.d.cts +17 -0
- package/dist/sandbox/local-sandbox.d.ts +17 -0
- package/dist/sandbox/types.d.cts +44 -0
- package/dist/sandbox/types.d.ts +44 -0
- package/dist/server/adapter/express.d.cts +9 -0
- package/dist/server/adapter/express.d.ts +9 -0
- package/dist/server/adapter/fastify.d.cts +9 -0
- package/dist/server/adapter/fastify.d.ts +9 -0
- package/dist/server/adapter/hono.d.cts +9 -0
- package/dist/server/adapter/hono.d.ts +9 -0
- package/dist/server/adapter/index.d.cts +8 -0
- package/dist/server/adapter/index.d.ts +8 -0
- package/dist/server/adapter/shared-handler.d.cts +9 -0
- package/dist/server/adapter/shared-handler.d.ts +9 -0
- package/dist/server/adapter/types.d.cts +33 -0
- package/dist/server/adapter/types.d.ts +33 -0
- package/dist/server/auth/errors.d.cts +53 -0
- package/dist/server/auth/errors.d.ts +53 -0
- package/dist/server/auth/index.cjs +48 -42
- package/dist/server/auth/index.cjs.map +1 -1
- package/dist/server/auth/index.d.cts +11 -172
- package/dist/server/auth/index.d.ts +11 -172
- package/dist/server/auth/index.js +49 -43
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/auth/oauth-transaction-store.d.cts +39 -0
- package/dist/server/auth/oauth-transaction-store.d.ts +39 -0
- package/dist/server/auth/orchestrator.d.cts +8 -0
- package/dist/server/auth/orchestrator.d.ts +8 -0
- package/dist/server/auth/types.d.cts +91 -0
- package/dist/server/auth/types.d.ts +91 -0
- package/dist/server/auth/validate-return-to.d.cts +17 -0
- package/dist/server/auth/validate-return-to.d.ts +17 -0
- package/dist/server/errors-envelope.cjs +409 -0
- package/dist/server/errors-envelope.cjs.map +1 -0
- package/dist/server/errors-envelope.d.cts +61 -0
- package/dist/server/errors-envelope.d.ts +61 -0
- package/dist/server/errors-envelope.js +405 -0
- package/dist/server/errors-envelope.js.map +1 -0
- package/dist/subscription/define-subscription.d.cts +63 -0
- package/dist/subscription/define-subscription.d.ts +63 -0
- package/dist/subscription/index.cjs +402 -0
- package/dist/subscription/index.cjs.map +1 -0
- package/dist/subscription/index.d.cts +18 -0
- package/dist/subscription/index.d.ts +18 -0
- package/dist/subscription/index.js +394 -0
- package/dist/subscription/index.js.map +1 -0
- package/dist/subscription/internal/adapter-types.d.cts +11 -0
- package/dist/subscription/internal/adapter-types.d.ts +11 -0
- package/dist/subscription/internal/backpressure.d.cts +24 -0
- package/dist/subscription/internal/backpressure.d.ts +24 -0
- package/dist/subscription/internal/server-integration.d.cts +17 -0
- package/dist/subscription/internal/server-integration.d.ts +17 -0
- package/dist/subscription/internal/sse-encoder.d.cts +13 -0
- package/dist/subscription/internal/sse-encoder.d.ts +13 -0
- package/dist/subscription/internal/sse-parser.d.cts +15 -0
- package/dist/subscription/internal/sse-parser.d.ts +15 -0
- package/dist/subscription/internal/subscription-runtime.d.cts +9 -0
- package/dist/subscription/internal/subscription-runtime.d.ts +9 -0
- package/dist/subscription/internal/ws-adapter-node.d.cts +10 -0
- package/dist/subscription/internal/ws-adapter-node.d.ts +10 -0
- package/dist/subscription/theokit-subscribe.d.cts +41 -0
- package/dist/subscription/theokit-subscribe.d.ts +41 -0
- package/dist/subscription/types.d.cts +140 -0
- package/dist/subscription/types.d.ts +140 -0
- package/dist/task-store.cjs +30 -2
- package/dist/task-store.cjs.map +1 -1
- package/dist/task-store.d.cts +8 -0
- package/dist/task-store.js +31 -3
- package/dist/task-store.js.map +1 -1
- package/dist/types/agent-prims.d.ts +61 -0
- package/dist/types/agent.d.ts +48 -53
- package/dist/types/conversation.d.ts +20 -8
- package/dist/types/index.d.ts +0 -2
- package/dist/types/messages-base.d.ts +20 -0
- package/dist/types/messages.d.ts +1 -1
- package/dist/types/run.d.ts +1 -1
- package/dist/types/updates.d.ts +1 -1
- package/dist/voice/index.d.ts +7 -0
- package/dist/voice/openai-realtime.d.ts +21 -0
- package/dist/voice/types.d.ts +35 -0
- package/dist/workflow.cjs +179 -88
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +97 -0
- package/dist/workflow.js +180 -89
- package/dist/workflow.js.map +1 -1
- package/package.json +126 -25
- package/dist/budget.d.ts +0 -48
- package/dist/cache.d.ts +0 -74
- package/dist/cron-1yxL3K2S.d.cts +0 -221
- package/dist/cron-BYVdYzob.d.ts +0 -221
- package/dist/handoff.d.ts +0 -55
- package/dist/internal/budget/calendar-window.d.ts +0 -19
- package/dist/internal/budget/enforcement.d.ts +0 -32
- package/dist/internal/budget/ledger.d.ts +0 -25
- package/dist/internal/budget/normalize-usage.d.ts +0 -27
- package/dist/internal/budget/registry.d.ts +0 -16
- package/dist/internal/cache/cosine.d.ts +0 -14
- package/dist/internal/cache/embed-helper.d.ts +0 -15
- package/dist/internal/cache/key.d.ts +0 -15
- package/dist/internal/cache/lookup.d.ts +0 -28
- package/dist/internal/cache/store-handler.d.ts +0 -24
- package/dist/internal/cache/store-json.d.ts +0 -48
- package/dist/internal/cache/store.d.ts +0 -54
- package/dist/internal/cache/telemetry.d.ts +0 -20
- package/dist/internal/cache/ttl.d.ts +0 -11
- package/dist/internal/catalog/fixtures.d.ts +0 -16
- package/dist/internal/catalog/local-models.d.ts +0 -24
- package/dist/internal/handoff/dispatcher.d.ts +0 -29
- package/dist/internal/handoff/registry.d.ts +0 -23
- package/dist/internal/handoff/telemetry.d.ts +0 -18
- package/dist/internal/handoff/tool-injector.d.ts +0 -34
- package/dist/internal/memory/atomic-write.d.ts +0 -7
- package/dist/internal/memory/dreaming/diary.d.ts +0 -4
- package/dist/internal/memory/dreaming/phases.d.ts +0 -15
- package/dist/internal/memory/dreaming/run.d.ts +0 -10
- package/dist/internal/memory/migrate-sqlite-to-lance.d.ts +0 -15
- package/dist/memory-adapter-helpers.d.ts +0 -28
- package/dist/memory.d.ts +0 -123
- package/dist/migrate.d.ts +0 -33
- package/dist/security.d.ts +0 -67
- package/dist/task.d.ts +0 -87
- package/dist/theokit.d.ts +0 -84
- package/dist/tools/_path-scope.d.ts +0 -8
- package/dist/tools/_subprocess.d.ts +0 -28
- package/dist/tools/git-diff.d.ts +0 -22
- package/dist/tools/index.d.ts +0 -29
- package/dist/tools/list-dir.d.ts +0 -26
- package/dist/tools/read-file.d.ts +0 -31
- package/dist/tools/run-vitest.d.ts +0 -46
- package/dist/tools/search-text.d.ts +0 -32
- package/dist/tools.cjs +0 -690
- package/dist/tools.cjs.map +0 -1
- package/dist/tools.js +0 -683
- package/dist/tools.js.map +0 -1
- package/dist/trajectory-helpers.d.ts +0 -31
- package/dist/types/cache.d.ts +0 -76
- package/dist/types/handoff.d.ts +0 -135
- /package/dist/{internal/cron/run-job.d.ts → agent-helpers.d.ts} +0 -0
- /package/dist/internal/{cron/scheduler.d.ts → agent-loop/loop-llm-stream.d.ts} +0 -0
- /package/dist/internal/{cron/store.d.ts → agent-loop/tool-executors.d.ts} +0 -0
- /package/dist/internal/{cron/validate.d.ts → memory/index-manager-helpers.d.ts} +0 -0
- /package/dist/internal/memory/{session-loader.d.ts → storage/session-loader.d.ts} +0 -0
- /package/dist/internal/memory/{session-summary-writer.d.ts → storage/session-summary-writer.d.ts} +0 -0
- /package/dist/internal/memory/{transcript-store.d.ts → storage/transcript-store.d.ts} +0 -0
- /package/dist/internal/memory/{wiki-loader.d.ts → storage/wiki-loader.d.ts} +0 -0
- /package/dist/internal/{memory/cwd-mutex.d.ts → persistence/atomic-write.d.cts} +0 -0
- /package/dist/internal/runtime/{context-aggregator.d.ts → context/context-aggregator.d.ts} +0 -0
- /package/dist/internal/runtime/{context-discovery-runner.d.ts → context/context-discovery-runner.d.ts} +0 -0
- /package/dist/internal/runtime/{context-discovery.d.ts → context/context-discovery.d.ts} +0 -0
- /package/dist/internal/runtime/{context-frontmatter.d.ts → context/context-frontmatter.d.ts} +0 -0
- /package/dist/internal/runtime/{context-import-resolver.d.ts → context/context-import-resolver.d.ts} +0 -0
- /package/dist/internal/runtime/{context-loaders.d.ts → context/context-loaders.d.ts} +0 -0
- /package/dist/internal/runtime/{context-mdc-parser.d.ts → context/context-mdc-parser.d.ts} +0 -0
- /package/dist/internal/runtime/{fixture-responder.d.ts → fixtures/fixture-responder.d.ts} +0 -0
- /package/dist/internal/runtime/{fixture-types.d.ts → fixtures/fixture-types.d.ts} +0 -0
- /package/dist/internal/runtime/{plugins-manager.d.ts → local-agent-send.d.ts} +0 -0
- /package/dist/internal/runtime/{plugin-frontmatter.d.ts → plugins/plugin-frontmatter.d.ts} +0 -0
- /package/dist/internal/runtime/{system-prompt/providers/active-memory-provider.d.ts → plugins/plugins-manager.d.ts} +0 -0
- /package/dist/internal/runtime/{agent-factory-registry.d.ts → registry/agent-factory-registry.d.ts} +0 -0
- /package/dist/internal/runtime/{agent-registry-store.d.ts → registry/agent-registry-store.d.ts} +0 -0
- /package/dist/internal/runtime/system-prompt/{providers/base-provider.d.ts → sources/active-memory-provider.d.ts} +0 -0
- /package/dist/internal/runtime/system-prompt/{providers/context-provider.d.ts → sources/base-provider.d.ts} +0 -0
- /package/dist/internal/runtime/system-prompt/{providers/memory-provider.d.ts → sources/context-provider.d.ts} +0 -0
- /package/dist/internal/runtime/system-prompt/{providers/skills-provider.d.ts → sources/memory-provider.d.ts} +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public `Workflow` class — declarative multi-step orchestration over
|
|
3
|
+
* `Agent.send`, `Handoff`, `Agent.batch` and friends (Adoption Roadmap #5;
|
|
4
|
+
* ADRs D230-D248).
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
*
|
|
8
|
+
* import { Agent } from "@theokit/sdk";
|
|
9
|
+
* import { Workflow, fn, agentStep } from "@theokit/sdk/workflow";
|
|
10
|
+
*
|
|
11
|
+
* const classifier = await Agent.create({ ... });
|
|
12
|
+
* const wf = Workflow.create({ name: "demo" })
|
|
13
|
+
* .then(fn("validate", (input: { id: string }) => {
|
|
14
|
+
* if (!input.id) throw new Error("missing id");
|
|
15
|
+
* return input;
|
|
16
|
+
* }))
|
|
17
|
+
* .then(agentStep("classify", classifier, (i) => `Classify: ${JSON.stringify(i)}`))
|
|
18
|
+
* .commit();
|
|
19
|
+
*
|
|
20
|
+
* const run = await wf.run({ id: "x" });
|
|
21
|
+
* console.log(run.status, run.output);
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
import type { ZodType } from "zod";
|
|
26
|
+
import type { SDKAgent } from "./types/agent.js";
|
|
27
|
+
import type { AgentStep, BranchStep, DowhileStep, FnStep, RetryPolicy, Step, StepContext, WorkflowOptions, WorkflowResumeOptions, WorkflowRun, WorkflowRunOptions } from "./types/workflow.js";
|
|
28
|
+
export declare class WorkflowBuilder<TInput = unknown, TOutput = unknown> {
|
|
29
|
+
private readonly options;
|
|
30
|
+
private readonly _steps;
|
|
31
|
+
private _committed;
|
|
32
|
+
then<TO = unknown>(step: Step): WorkflowBuilder<TInput, TO>;
|
|
33
|
+
parallel(branches: ReadonlyArray<ReadonlyArray<Step>>, opts?: {
|
|
34
|
+
id?: string;
|
|
35
|
+
concurrency?: number;
|
|
36
|
+
errorPolicy?: "fail-fast" | "collect";
|
|
37
|
+
}): WorkflowBuilder<TInput, unknown[]>;
|
|
38
|
+
branch(predicates: BranchStep["predicates"], opts?: {
|
|
39
|
+
id?: string;
|
|
40
|
+
fallback?: ReadonlyArray<Step>;
|
|
41
|
+
}): WorkflowBuilder<TInput, unknown>;
|
|
42
|
+
foreach(iterableFrom: string, step: Step, opts?: {
|
|
43
|
+
id?: string;
|
|
44
|
+
concurrency?: number;
|
|
45
|
+
}): WorkflowBuilder<TInput, unknown[]>;
|
|
46
|
+
dowhile(step: Step, condFn: DowhileStep["condFn"], opts?: {
|
|
47
|
+
id?: string;
|
|
48
|
+
maxIterations?: number;
|
|
49
|
+
}): WorkflowBuilder<TInput, unknown>;
|
|
50
|
+
sleep(durationMs: number, id?: string): WorkflowBuilder<TInput, TOutput>;
|
|
51
|
+
suspend(opts?: {
|
|
52
|
+
id?: string;
|
|
53
|
+
payloadSchema?: ZodType;
|
|
54
|
+
}): WorkflowBuilder<TInput, unknown>;
|
|
55
|
+
commit(): Workflow<TInput, TOutput>;
|
|
56
|
+
private validateUniqueIds;
|
|
57
|
+
private assertNotCommitted;
|
|
58
|
+
}
|
|
59
|
+
export declare class Workflow<TInput = unknown, TOutput = unknown> {
|
|
60
|
+
private readonly _options;
|
|
61
|
+
private readonly _steps;
|
|
62
|
+
/**
|
|
63
|
+
* Construct a workflow builder. Validate options via Zod and return a
|
|
64
|
+
* `WorkflowBuilder` for fluent chaining. Call `.commit()` to obtain the
|
|
65
|
+
* immutable `Workflow`.
|
|
66
|
+
*/
|
|
67
|
+
static create<TI = unknown, TO = unknown>(options: WorkflowOptions): WorkflowBuilder<TI, TO>;
|
|
68
|
+
/**
|
|
69
|
+
* Run this workflow with the given input. Returns a populated
|
|
70
|
+
* `WorkflowRun`. Errors inside a step DO NOT throw — they propagate via
|
|
71
|
+
* `run.status === "failed"`.
|
|
72
|
+
*/
|
|
73
|
+
run(input: TInput, opts?: WorkflowRunOptions): Promise<WorkflowRun<TOutput>>;
|
|
74
|
+
/**
|
|
75
|
+
* Resume a suspended workflow from its snapshot. Throws
|
|
76
|
+
* `WorkflowSnapshotNotFoundError` if `runId` is unknown.
|
|
77
|
+
*/
|
|
78
|
+
static resume<TO = unknown>(opts: WorkflowResumeOptions): Promise<WorkflowRun<TO>>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Build a `FnStep`. `id` must match `^[a-z0-9][a-z0-9_-]*$`.
|
|
82
|
+
*/
|
|
83
|
+
export declare function fn<I = unknown, O = unknown>(id: string, step: (input: I, ctx: StepContext) => Promise<O> | O, opts?: {
|
|
84
|
+
inputSchema?: ZodType;
|
|
85
|
+
outputSchema?: ZodType;
|
|
86
|
+
retry?: RetryPolicy;
|
|
87
|
+
}): FnStep;
|
|
88
|
+
/**
|
|
89
|
+
* Build an `AgentStep`. The `promptTemplate` can be a static string or a
|
|
90
|
+
* function that receives the input and returns the prompt.
|
|
91
|
+
*/
|
|
92
|
+
export declare function agentStep(id: string, agent: SDKAgent, promptTemplate: string | ((input: unknown) => string), opts?: {
|
|
93
|
+
retry?: RetryPolicy;
|
|
94
|
+
}): AgentStep;
|
|
95
|
+
export { __resetSnapshotStoresForTests } from "./internal/workflow/snapshot-store.js";
|
|
96
|
+
export type * from "./types/workflow.js";
|
|
97
|
+
export { WorkflowAlreadyRunningError, WorkflowCompensateNotImplementedError, WorkflowDuplicateStepIdError, WorkflowMaxIterationsExceededError, WorkflowNotSerializableError, WorkflowParallelError, WorkflowResumeStepNotFoundError, WorkflowSnapshotNotFoundError, } from "./types/workflow.js";
|
package/dist/workflow.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { randomUUID, randomBytes } from 'crypto';
|
|
2
|
+
import { readFile, unlink, mkdir, open, rename, statfs, readdir } from 'fs/promises';
|
|
2
3
|
import { join, dirname } from 'path';
|
|
3
4
|
import { createRequire } from 'module';
|
|
4
5
|
import { mkdirSync, readdirSync } from 'fs';
|
|
5
6
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
6
|
-
import { randomUUID } from 'crypto';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
|
|
9
9
|
var __defProp = Object.defineProperty;
|
|
@@ -16,6 +16,136 @@ var __export = (target, all) => {
|
|
|
16
16
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
// src/internal/security/redact.ts
|
|
20
|
+
function readEnvOnce() {
|
|
21
|
+
const raw = process.env.THEOKIT_REDACT_SECRETS;
|
|
22
|
+
if (raw === void 0) return true;
|
|
23
|
+
return ["1", "true", "yes", "on"].includes(raw.toLowerCase());
|
|
24
|
+
}
|
|
25
|
+
function maskToken(token) {
|
|
26
|
+
if (token.length < 18) return "***";
|
|
27
|
+
return `${token.slice(0, 6)}...${token.slice(-4)}`;
|
|
28
|
+
}
|
|
29
|
+
function coerceToString(value) {
|
|
30
|
+
if (typeof value === "string") return value;
|
|
31
|
+
if (value === null || value === void 0) return null;
|
|
32
|
+
if (typeof value === "object") {
|
|
33
|
+
try {
|
|
34
|
+
const s = JSON.stringify(value);
|
|
35
|
+
return s === void 0 ? null : s;
|
|
36
|
+
} catch {
|
|
37
|
+
return "[unredactable: circular]";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return String(value);
|
|
41
|
+
}
|
|
42
|
+
function redactSecrets(text, opts) {
|
|
43
|
+
const coerced = coerceToString(text);
|
|
44
|
+
if (coerced === null) return "";
|
|
45
|
+
if (!REDACT_ENABLED) return coerced;
|
|
46
|
+
let s = coerced;
|
|
47
|
+
for (const re of BUILTIN_PATTERNS) {
|
|
48
|
+
s = s.replace(re, (m) => maskToken(m));
|
|
49
|
+
}
|
|
50
|
+
for (const re of _extraPatterns) {
|
|
51
|
+
s = s.replace(re, (m) => maskToken(m));
|
|
52
|
+
}
|
|
53
|
+
{
|
|
54
|
+
s = s.replace(BEARER_PATTERN, (_, prefix) => `${prefix}***`);
|
|
55
|
+
s = s.replace(PARAM_PATTERN, (whole, prefix, value) => {
|
|
56
|
+
if (value.includes("...")) return whole;
|
|
57
|
+
return `${prefix}***`;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return s;
|
|
61
|
+
}
|
|
62
|
+
var REDACT_ENABLED, warnedOptOut, BUILTIN_PATTERNS, BEARER_PATTERN, PARAM_PATTERN, _extraPatterns;
|
|
63
|
+
var init_redact = __esm({
|
|
64
|
+
"src/internal/security/redact.ts"() {
|
|
65
|
+
REDACT_ENABLED = readEnvOnce();
|
|
66
|
+
warnedOptOut = false;
|
|
67
|
+
if (!REDACT_ENABLED && !warnedOptOut) {
|
|
68
|
+
process.stderr.write(
|
|
69
|
+
"[theokit-sdk] Secret redaction is DISABLED via THEOKIT_REDACT_SECRETS. Credentials may leak into errors, telemetry, logs, transcripts.\n"
|
|
70
|
+
);
|
|
71
|
+
warnedOptOut = true;
|
|
72
|
+
}
|
|
73
|
+
BUILTIN_PATTERNS = [
|
|
74
|
+
// T5.4: 30+ vendor prefixes (was 12 pre-T5.4). Order matters — more
|
|
75
|
+
// specific prefixes precede generic ones (e.g., sk-ant-admin01 before
|
|
76
|
+
// sk-ant-, sk-proj- before sk-). PEM block deliberately first so its
|
|
77
|
+
// multi-line span runs before any per-line patterns can fire.
|
|
78
|
+
/-----BEGIN[ ]+(?:RSA |EC |DSA |OPENSSH |ENCRYPTED |)PRIVATE KEY-----[\s\S]+?-----END[ ]+(?:RSA |EC |DSA |OPENSSH |ENCRYPTED |)PRIVATE KEY-----/g,
|
|
79
|
+
// JWT — exact 3-segment base64url. Dotted; the body floor of 4 chars per
|
|
80
|
+
// segment matches the minimum legal payload while skipping `a.b.c` noise.
|
|
81
|
+
/eyJ[A-Za-z0-9_-]{4,}\.eyJ[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]{4,}/g,
|
|
82
|
+
// Azure Storage SAS — match the sig= component (URL-encoded base64).
|
|
83
|
+
/(?<=[?&]sig=)[A-Za-z0-9%+/]{20,}/g,
|
|
84
|
+
// Anthropic
|
|
85
|
+
/sk-ant-admin01-[A-Za-z0-9_-]{10,}/g,
|
|
86
|
+
// Anthropic admin keys (must precede sk-ant-)
|
|
87
|
+
/sk-ant-[A-Za-z0-9_-]{10,}/g,
|
|
88
|
+
// Anthropic regular
|
|
89
|
+
// OpenAI family + clones (sk- generic must come AFTER all sk-foo- variants)
|
|
90
|
+
/sk-proj-[A-Za-z0-9_-]{10,}/g,
|
|
91
|
+
// OpenAI project key (must precede sk- generic)
|
|
92
|
+
/sk-[A-Za-z0-9_-]{10,}/g,
|
|
93
|
+
// OpenAI / OpenRouter / DeepInfra / Together / DeepSeek
|
|
94
|
+
// Provider prefixes (alphabetized for maintainability)
|
|
95
|
+
/AIza[A-Za-z0-9_-]{35}/g,
|
|
96
|
+
// Google API key
|
|
97
|
+
/AKIA[A-Z0-9]{16}/g,
|
|
98
|
+
// AWS access key
|
|
99
|
+
/fw_[A-Za-z0-9]{20,}/g,
|
|
100
|
+
// Fireworks
|
|
101
|
+
/glpat-[A-Za-z0-9_-]{20}/g,
|
|
102
|
+
// GitLab PAT
|
|
103
|
+
/ghp_[A-Za-z0-9]{36}/g,
|
|
104
|
+
// GitHub PAT classic
|
|
105
|
+
/github_pat_[A-Za-z0-9_]{82}/g,
|
|
106
|
+
// GitHub PAT fine-grained
|
|
107
|
+
/gsk_[A-Za-z0-9]{20,}/g,
|
|
108
|
+
// Groq
|
|
109
|
+
/hf_[A-Za-z0-9]{20,}/g,
|
|
110
|
+
// HuggingFace
|
|
111
|
+
/\bpa-[A-Za-z0-9_-]{20,}/g,
|
|
112
|
+
// Voyage AI (word-boundary to skip CSS / kebab IDs)
|
|
113
|
+
/pcsk_[A-Za-z0-9_-]{20,}/g,
|
|
114
|
+
// Pinecone
|
|
115
|
+
/pplx-[A-Za-z0-9_-]{20,}/g,
|
|
116
|
+
// Perplexity
|
|
117
|
+
/r8_[A-Za-z0-9_-]{20,}/g,
|
|
118
|
+
// Replicate
|
|
119
|
+
/rk_live_[A-Za-z0-9]{20,}/g,
|
|
120
|
+
// Stripe restricted
|
|
121
|
+
/sk_live_[A-Za-z0-9]{20,}/g,
|
|
122
|
+
// Stripe secret
|
|
123
|
+
/sntrys_[A-Za-z0-9]{40,}/g,
|
|
124
|
+
// Sentry user auth
|
|
125
|
+
/xai-[A-Za-z0-9_-]{20,}/g,
|
|
126
|
+
// xAI (Grok)
|
|
127
|
+
/xox[bpasr]-[A-Za-z0-9-]{10,}/g,
|
|
128
|
+
//Slack tokens
|
|
129
|
+
// Additional unique-prefix tokens with low false-positive risk
|
|
130
|
+
/npm_[A-Za-z0-9]{36}/g,
|
|
131
|
+
// npm access token
|
|
132
|
+
/SG\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}/g,
|
|
133
|
+
// SendGrid
|
|
134
|
+
/\bSK[A-Za-z0-9]{32}\b/g,
|
|
135
|
+
// Twilio API SID (word-boundary to skip CSS class noise)
|
|
136
|
+
/\bkey-[a-f0-9]{32}\b/g,
|
|
137
|
+
// Mailgun (hex-only narrows false positives)
|
|
138
|
+
/MT[A-Za-z0-9_-]{23}\.[A-Za-z0-9_-]{6}\.[A-Za-z0-9_-]{27}/g,
|
|
139
|
+
// Discord bot
|
|
140
|
+
/\b(?:sdk|mob)-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\b/g
|
|
141
|
+
// LaunchDarkly
|
|
142
|
+
];
|
|
143
|
+
BEARER_PATTERN = /\b(Bearer\s+)([A-Za-z0-9_\-.+/=]{8,})/g;
|
|
144
|
+
PARAM_PATTERN = /(\b(?:access_token|api_key|api-key|client_secret|credential|credentials|id_token|jwt|password|private_key|refresh_token|secret|service_account|session_token|token|x-api-key)\b["']?\s*[:=]\s*["']?)([A-Za-z0-9_\-.+/]+)/gi;
|
|
145
|
+
_extraPatterns = [];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
19
149
|
// src/errors.ts
|
|
20
150
|
var TheokitAgentError, ConfigurationError, UnsupportedRunOperationError, InvalidTaskIdError, TaskNotFoundError;
|
|
21
151
|
var init_errors = __esm({
|
|
@@ -163,9 +293,29 @@ var init_workflow = __esm({
|
|
|
163
293
|
};
|
|
164
294
|
}
|
|
165
295
|
});
|
|
296
|
+
function detectNetworkFsName(typeMagic) {
|
|
297
|
+
return NETWORK_FS_MAGIC.get(typeMagic) ?? null;
|
|
298
|
+
}
|
|
299
|
+
async function warnOnNetworkFsOnce(dirPath, label) {
|
|
300
|
+
const key2 = `${dirPath}\0${label}`;
|
|
301
|
+
if (warnedNfsDirs.has(key2)) return;
|
|
302
|
+
warnedNfsDirs.add(key2);
|
|
303
|
+
try {
|
|
304
|
+
const info = await statfs(dirPath);
|
|
305
|
+
const fsName = detectNetworkFsName(info.type);
|
|
306
|
+
if (fsName === null) return;
|
|
307
|
+
process.stderr.write(
|
|
308
|
+
`[theokit-sdk] ${label}: detected network fs (${fsName}) at ${dirPath} \u2014 rename() atomicity guarantees may be weaker than expected.
|
|
309
|
+
`
|
|
310
|
+
);
|
|
311
|
+
} catch {
|
|
312
|
+
}
|
|
313
|
+
}
|
|
166
314
|
async function replaceFileAtomic(filePath, content) {
|
|
167
|
-
|
|
168
|
-
const
|
|
315
|
+
await warnOnNetworkFsOnce(dirname(filePath), "atomic-write");
|
|
316
|
+
const suffix = randomBytes(8).toString("hex");
|
|
317
|
+
const tmp = `${filePath}.${process.pid}.${suffix}.tmp`;
|
|
318
|
+
const handle = await open(tmp, "w", 384);
|
|
169
319
|
try {
|
|
170
320
|
await handle.writeFile(content, "utf8");
|
|
171
321
|
await handle.sync();
|
|
@@ -183,8 +333,16 @@ async function atomicWriteText(filePath, content) {
|
|
|
183
333
|
await mkdir(dirname(filePath), { recursive: true });
|
|
184
334
|
await replaceFileAtomic(filePath, content);
|
|
185
335
|
}
|
|
336
|
+
var NETWORK_FS_MAGIC, warnedNfsDirs;
|
|
186
337
|
var init_atomic_write = __esm({
|
|
187
338
|
"src/internal/persistence/atomic-write.ts"() {
|
|
339
|
+
NETWORK_FS_MAGIC = /* @__PURE__ */ new Map([
|
|
340
|
+
[26985, "nfs"],
|
|
341
|
+
[20859, "smb"],
|
|
342
|
+
[4283649346, "cifs"],
|
|
343
|
+
[1702057286, "fuse"]
|
|
344
|
+
]);
|
|
345
|
+
warnedNfsDirs = /* @__PURE__ */ new Set();
|
|
188
346
|
}
|
|
189
347
|
});
|
|
190
348
|
function getSnapshotStoreFor(options) {
|
|
@@ -561,91 +719,6 @@ var init_step_agent = __esm({
|
|
|
561
719
|
}
|
|
562
720
|
});
|
|
563
721
|
|
|
564
|
-
// src/internal/security/redact.ts
|
|
565
|
-
function readEnvOnce() {
|
|
566
|
-
const raw = process.env.THEOKIT_REDACT_SECRETS;
|
|
567
|
-
if (raw === void 0) return true;
|
|
568
|
-
return ["1", "true", "yes", "on"].includes(raw.toLowerCase());
|
|
569
|
-
}
|
|
570
|
-
function maskToken(token) {
|
|
571
|
-
if (token.length < 18) return "***";
|
|
572
|
-
return `${token.slice(0, 6)}...${token.slice(-4)}`;
|
|
573
|
-
}
|
|
574
|
-
function coerceToString(value) {
|
|
575
|
-
if (typeof value === "string") return value;
|
|
576
|
-
if (value === null || value === void 0) return null;
|
|
577
|
-
if (typeof value === "object") {
|
|
578
|
-
try {
|
|
579
|
-
const s = JSON.stringify(value);
|
|
580
|
-
return s === void 0 ? null : s;
|
|
581
|
-
} catch {
|
|
582
|
-
return "[unredactable: circular]";
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
return String(value);
|
|
586
|
-
}
|
|
587
|
-
function redactSecrets(text, opts) {
|
|
588
|
-
const coerced = coerceToString(text);
|
|
589
|
-
if (coerced === null) return "";
|
|
590
|
-
if (!REDACT_ENABLED) return coerced;
|
|
591
|
-
let s = coerced;
|
|
592
|
-
for (const re of BUILTIN_PATTERNS) {
|
|
593
|
-
s = s.replace(re, (m) => maskToken(m));
|
|
594
|
-
}
|
|
595
|
-
for (const re of _extraPatterns) {
|
|
596
|
-
s = s.replace(re, (m) => maskToken(m));
|
|
597
|
-
}
|
|
598
|
-
{
|
|
599
|
-
s = s.replace(BEARER_PATTERN, (_, prefix) => `${prefix}***`);
|
|
600
|
-
s = s.replace(PARAM_PATTERN, (_, prefix) => `${prefix}***`);
|
|
601
|
-
}
|
|
602
|
-
return s;
|
|
603
|
-
}
|
|
604
|
-
var REDACT_ENABLED, warnedOptOut, BUILTIN_PATTERNS, BEARER_PATTERN, PARAM_PATTERN, _extraPatterns;
|
|
605
|
-
var init_redact = __esm({
|
|
606
|
-
"src/internal/security/redact.ts"() {
|
|
607
|
-
REDACT_ENABLED = readEnvOnce();
|
|
608
|
-
warnedOptOut = false;
|
|
609
|
-
if (!REDACT_ENABLED && !warnedOptOut) {
|
|
610
|
-
process.stderr.write(
|
|
611
|
-
"[theokit-sdk] Secret redaction is DISABLED via THEOKIT_REDACT_SECRETS. Credentials may leak into errors, telemetry, logs, transcripts.\n"
|
|
612
|
-
);
|
|
613
|
-
warnedOptOut = true;
|
|
614
|
-
}
|
|
615
|
-
BUILTIN_PATTERNS = [
|
|
616
|
-
/sk-ant-[A-Za-z0-9_-]{10,}/g,
|
|
617
|
-
// Anthropic
|
|
618
|
-
/sk-proj-[A-Za-z0-9_-]{10,}/g,
|
|
619
|
-
// OpenAI project key (must precede sk- generic)
|
|
620
|
-
/sk-[A-Za-z0-9_-]{10,}/g,
|
|
621
|
-
// OpenAI / OpenRouter / DeepInfra. {10,} body floor —
|
|
622
|
-
// real keys are 40+ chars; 10-char floor still skips `sk-test` (4) and
|
|
623
|
-
// `sk-test-key` (8). codeFile mode protects placeholders/examples.
|
|
624
|
-
/ghp_[A-Za-z0-9]{36}/g,
|
|
625
|
-
// GitHub PAT classic (exact length)
|
|
626
|
-
/github_pat_[A-Za-z0-9_]{82}/g,
|
|
627
|
-
// GitHub PAT fine-grained
|
|
628
|
-
/glpat-[A-Za-z0-9_-]{20}/g,
|
|
629
|
-
// GitLab PAT
|
|
630
|
-
/AKIA[A-Z0-9]{16}/g,
|
|
631
|
-
// AWS access key
|
|
632
|
-
/AIza[A-Za-z0-9_-]{35}/g,
|
|
633
|
-
// Google API key
|
|
634
|
-
/xox[bpasr]-[A-Za-z0-9-]{10,}/g,
|
|
635
|
-
//Slack tokens
|
|
636
|
-
/sntrys_[A-Za-z0-9]{40,}/g,
|
|
637
|
-
// Sentry user auth
|
|
638
|
-
/sk_live_[A-Za-z0-9]{20,}/g,
|
|
639
|
-
// Stripe secret
|
|
640
|
-
/rk_live_[A-Za-z0-9]{20,}/g
|
|
641
|
-
// Stripe restricted
|
|
642
|
-
];
|
|
643
|
-
BEARER_PATTERN = /\b(Bearer\s+)([A-Za-z0-9_\-.+/=]{8,})/g;
|
|
644
|
-
PARAM_PATTERN = /(\b(?:access_token|api_key|api-key|password|secret|x-api-key)\b["']?\s*[:=]\s*["']?)([A-Za-z0-9_\-.+/]+)/gi;
|
|
645
|
-
_extraPatterns = [];
|
|
646
|
-
}
|
|
647
|
-
});
|
|
648
|
-
|
|
649
722
|
// src/internal/workflow/step-branch.ts
|
|
650
723
|
async function runBranchStep(step, input, ctx, options, prevStepResults, dispatch) {
|
|
651
724
|
const startedAt = Date.now();
|
|
@@ -2129,6 +2202,23 @@ var PersistenceSchema = z.object({
|
|
|
2129
2202
|
|
|
2130
2203
|
// src/internal/security/path-guard.ts
|
|
2131
2204
|
init_errors();
|
|
2205
|
+
var PathTraversalError = class extends ConfigurationError {
|
|
2206
|
+
name = "PathTraversalError";
|
|
2207
|
+
constructor(input, resolvedPath) {
|
|
2208
|
+
super(`Path traversal attempt: ${input} \u2192 ${resolvedPath}`, {
|
|
2209
|
+
code: "path_traversal"
|
|
2210
|
+
});
|
|
2211
|
+
}
|
|
2212
|
+
};
|
|
2213
|
+
function rejectNulAndControlChars(input, role) {
|
|
2214
|
+
for (let i = 0; i < input.length; i++) {
|
|
2215
|
+
const code = input.charCodeAt(i);
|
|
2216
|
+
if (code === 0 || code >= 1 && code <= 31 || code === 127) {
|
|
2217
|
+
const label = code === 0 ? "<nul-byte>" : `<control-char-0x${code.toString(16)}>`;
|
|
2218
|
+
throw new PathTraversalError(`${role}: ${input}`, label);
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2132
2222
|
var IDENTIFIER_PATTERN = /^[a-z0-9][a-z0-9\-_]*$/i;
|
|
2133
2223
|
function sanitizeIdentifier(input, options) {
|
|
2134
2224
|
const maxLen = options?.maxLen;
|
|
@@ -2137,6 +2227,7 @@ function sanitizeIdentifier(input, options) {
|
|
|
2137
2227
|
code: "invalid_identifier"
|
|
2138
2228
|
});
|
|
2139
2229
|
}
|
|
2230
|
+
rejectNulAndControlChars(input, "identifier");
|
|
2140
2231
|
if (!IDENTIFIER_PATTERN.test(input)) {
|
|
2141
2232
|
throw new ConfigurationError(`Identifier contains invalid characters: "${input}"`, {
|
|
2142
2233
|
code: "invalid_identifier"
|