@theokit/sdk 1.8.1 → 2.0.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.
Files changed (83) hide show
  1. package/CHANGELOG.md +70 -22
  2. package/bin/init-claude.mjs +0 -0
  3. package/dist/a2a/index.cjs +12592 -12884
  4. package/dist/a2a/index.cjs.map +1 -1
  5. package/dist/a2a/index.js +12592 -12884
  6. package/dist/a2a/index.js.map +1 -1
  7. package/dist/{cron-BnywDYLq.d.cts → cron-Bse1MbaE.d.cts} +52 -2
  8. package/dist/{cron-CtZvJD9J.d.ts → cron-Ci_NUkUj.d.ts} +52 -2
  9. package/dist/cron.cjs +8763 -9062
  10. package/dist/cron.cjs.map +1 -1
  11. package/dist/cron.d.cts +1 -1
  12. package/dist/cron.d.ts +1 -1
  13. package/dist/cron.js +8763 -9062
  14. package/dist/cron.js.map +1 -1
  15. package/dist/eval.cjs +8776 -9075
  16. package/dist/eval.cjs.map +1 -1
  17. package/dist/eval.js +8776 -9075
  18. package/dist/eval.js.map +1 -1
  19. package/dist/index.cjs +11217 -10037
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +174 -3
  22. package/dist/index.d.ts +174 -3
  23. package/dist/index.js +11217 -10038
  24. package/dist/index.js.map +1 -1
  25. package/dist/internal/runtime/{cloud-config-serializer.d.ts → cloud/cloud-config-serializer.d.ts} +1 -1
  26. package/dist/internal/runtime/{real-cloud-run.d.ts → cloud/real-cloud-run.d.ts} +1 -1
  27. package/dist/internal/runtime/fixtures/fixture-scripts.d.ts +1 -1
  28. package/dist/internal/runtime/fork-agent.d.ts +1 -1
  29. package/dist/internal/runtime/{local-agent-bootstrap.d.ts → local-agent/local-agent-bootstrap.d.ts} +4 -4
  30. package/dist/internal/runtime/{local-agent-dispatch.d.ts → local-agent/local-agent-dispatch.d.ts} +7 -7
  31. package/dist/internal/runtime/{local-agent-memory-hooks.d.ts → local-agent/local-agent-memory-hooks.d.ts} +2 -2
  32. package/dist/internal/runtime/{local-agent-memory-provider.d.ts → local-agent/local-agent-memory-provider.d.ts} +2 -2
  33. package/dist/internal/runtime/{real-local-run.d.ts → local-agent/real-local-run.d.ts} +1 -1
  34. package/dist/internal/runtime/{memory-path-selector.d.ts → memory/memory-path-selector.d.ts} +1 -1
  35. package/dist/internal/runtime/{memory-provider.d.ts → memory/memory-provider.d.ts} +2 -2
  36. package/dist/internal/runtime/{memory-store.d.ts → memory/memory-store.d.ts} +1 -1
  37. package/dist/internal/runtime/skills/subagents-loader.d.ts +1 -0
  38. package/dist/types/agent.d.ts +3 -3
  39. package/dist/types/fork.d.ts +49 -0
  40. package/dist/types/goal-events.d.ts +1 -1
  41. package/package.json +15 -26
  42. package/dist/rag/index.cjs +0 -136
  43. package/dist/rag/index.cjs.map +0 -1
  44. package/dist/rag/index.d.cts +0 -11
  45. package/dist/rag/index.d.ts +0 -11
  46. package/dist/rag/index.js +0 -129
  47. package/dist/rag/index.js.map +0 -1
  48. package/dist/rag/reranker.d.cts +0 -26
  49. package/dist/rag/reranker.d.ts +0 -26
  50. package/dist/rag/retriever.d.cts +0 -25
  51. package/dist/rag/retriever.d.ts +0 -25
  52. package/dist/rag/text-splitter.d.cts +0 -12
  53. package/dist/rag/text-splitter.d.ts +0 -12
  54. package/dist/rag/types.d.cts +0 -37
  55. package/dist/rag/types.d.ts +0 -37
  56. package/dist/voice/index.d.ts +0 -7
  57. package/dist/voice/openai-realtime.d.ts +0 -21
  58. package/dist/voice/types.d.ts +0 -35
  59. /package/dist/internal/{runtime/cloud-agent.d.ts → agent-loop/budget-gate.d.ts} +0 -0
  60. /package/dist/internal/runtime/{budget-tracker.d.ts → budget/budget-tracker.d.ts} +0 -0
  61. /package/dist/internal/runtime/{budget.d.ts → budget/budget.d.ts} +0 -0
  62. /package/dist/internal/runtime/{cloud-run.d.ts → cloud/cloud-agent.d.ts} +0 -0
  63. /package/dist/internal/runtime/{cloud-payload-types.d.ts → cloud/cloud-payload-types.d.ts} +0 -0
  64. /package/dist/internal/runtime/{cloud-tool-parity.d.ts → cloud/cloud-run.d.ts} +0 -0
  65. /package/dist/internal/runtime/{local-agent-memory.d.ts → cloud/cloud-tool-parity.d.ts} +0 -0
  66. /package/dist/internal/runtime/{hooks-executor.d.ts → hooks/hooks-executor.d.ts} +0 -0
  67. /package/dist/internal/runtime/{hooks-frontmatter.d.ts → hooks/hooks-frontmatter.d.ts} +0 -0
  68. /package/dist/internal/runtime/{hooks-source.d.ts → hooks/hooks-source.d.ts} +0 -0
  69. /package/dist/internal/runtime/{local-agent-invalidate.d.ts → local-agent/local-agent-invalidate.d.ts} +0 -0
  70. /package/dist/internal/runtime/{local-agent-memory-direct.d.ts → local-agent/local-agent-memory-direct.d.ts} +0 -0
  71. /package/dist/internal/runtime/{local-agent-send.d.ts → local-agent/local-agent-memory.d.ts} +0 -0
  72. /package/dist/internal/runtime/{local-agent-personality-extensions.d.ts → local-agent/local-agent-personality-extensions.d.ts} +0 -0
  73. /package/dist/internal/runtime/{local-agent-plugins.d.ts → local-agent/local-agent-plugins.d.ts} +0 -0
  74. /package/dist/internal/runtime/{local-agent-runtime-extensions.d.ts → local-agent/local-agent-runtime-extensions.d.ts} +0 -0
  75. /package/dist/internal/runtime/{local-agent.d.ts → local-agent/local-agent-send.d.ts} +0 -0
  76. /package/dist/internal/runtime/{local-agent-task-wrap.d.ts → local-agent/local-agent-task-wrap.d.ts} +0 -0
  77. /package/dist/internal/runtime/{local-run.d.ts → local-agent/local-agent.d.ts} +0 -0
  78. /package/dist/internal/runtime/{skills-manager.d.ts → local-agent/local-run.d.ts} +0 -0
  79. /package/dist/internal/runtime/{agent-session-store.d.ts → session/agent-session-store.d.ts} +0 -0
  80. /package/dist/internal/runtime/{agent-session.d.ts → session/agent-session.d.ts} +0 -0
  81. /package/dist/internal/runtime/{session-types.d.ts → session/session-types.d.ts} +0 -0
  82. /package/dist/internal/runtime/{skill-frontmatter.d.ts → skills/skill-frontmatter.d.ts} +0 -0
  83. /package/dist/internal/runtime/{subagents-loader.d.ts → skills/skills-manager.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,7 +1,48 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - b9f30a6: Carve the non-Harness surface out of `@theokit/sdk` (plan `monorepo-cohesion-split`). The SDK now ships only the Agent-AI Harness.
8
+
9
+ BREAKING (no retro-compat, authorized):
10
+
11
+ - Removed the `@theokit/sdk/rag` sub-path export and the embedded `voice` module — they moved to standalone `@theokit/rag` / `@theokit/voice` packages (repos `theokit-rag` / `theokit-voice`). Import those packages instead.
12
+ - Decorator-first DX is no longer required of Harness features (ADR D431). `@theokit/di` / `@theokit/di-agent` / `@theokit/orm` moved to `theokit-backend-dx`, the gateway packages to `theokit-gateways`, `@theokit/react` to `theokit-react`, and `@theokit/skills-google-workspace` to the Skills pillar. Decorators remain available as an optional layer via the externally-published `@theokit/di`.
13
+
14
+ The surviving `@theokit/sdk-*` extension peer specifiers stay as semver ranges (`>=1.7.0`), satisfying the publish-readiness gate.
15
+
16
+ ## 1.9.0
17
+
18
+ ### Minor Changes
19
+
20
+ - 461c020: `createSquad` sequential agent-team convenience + `Agent.batch` boundary validation — first real npm publish.
21
+
22
+ - **`createSquad(options)`** — composes `Workflow.create()` + `agentStep` into a sequential agent team (own identity; not a framework copy). Throws `ConfigurationError` (`invalid_squad` for empty agents, `squad_process_unsupported` for hierarchical). Cross-validation Gap 1.
23
+ - **`Agent.batch`** now fail-fast validates `concurrency` + prompt items at the public boundary (`ConfigurationError` with `invalid_concurrency` / `invalid_batch_item`) before any side effect. Cross-validation Gap 3.
24
+
25
+ Note: these features were tagged as `v1.8.0` but that version's npm publish failed (CI build cycle, fixed in `turbo.json`); `1.8.0` / `1.8.1` on npm predate them. They are published to npm for the first time in `1.9.0`. The `[1.8.0]` CHANGELOG section is retained as the GitHub-released record and is not rewritten.
26
+
3
27
  ## [Unreleased]
4
28
 
29
+ ### Added
30
+
31
+ - `createSquad({ agents })` — a thin convenience for sequential agent teams. Runs agents in order, threading each output into the next agent's prompt; returns `{ result, status, steps }`. Composes `Workflow` + `agentStep` internally (no new orchestration engine). `process: "hierarchical"` throws a guiding `ConfigurationError` (use subagents / `@theokit/sdk-handoff`); empty `agents` → `ConfigurationError(code: "invalid_squad")`.
32
+
33
+ ### Fixed
34
+
35
+ - `Agent.batch` now validates its inputs at the boundary (fail-fast). Invalid `concurrency` (not a positive integer) throws `ConfigurationError(code: "invalid_concurrency")` with a user-facing message, and an empty/non-string prompt item throws `ConfigurationError(code: "invalid_batch_item")` — both BEFORE any credential pool is built or Task is registered. Previously invalid `concurrency` surfaced only deep inside the semaphore with a leaky "permits" message AND after task registration (a dangling Task could be registered with `task: true`), and empty-string prompts flowed silently to `agent.send`. New `validateBatchInput` pre-flight; whitespace-only prompts are intentionally still accepted (non-empty strings; the validator does not judge content). (arch-review cross-validation Gap 3)
36
+
37
+ ### Changed
38
+
39
+ - Reorganized the flat 62-file `src/internal/runtime/` god folder into sub-concern folders (arch-review M4): `local-agent/` (15), `cloud/` (6), `compression/` (6), `hooks/` (4), `budget/` (3), `memory/` (4), `session/` (3), `skills/` (3) — alongside the pre-existing `registry/`, `system-prompt/`, `context/`, `fixtures/`, `plugins/`. 18 cross-cutting singletons (abort-utils, async-_, default-model, fork-agent, run-until, system-prompt, validate-_, etc.) remain at the `runtime/` root (down from 62). Pure file moves + import-path updates (44 files moved, ~100 import sites rewritten incl. 2 lint-allowlist path updates); `internal/runtime` is not an exported subpath and has no tsup entry, so the change is fully internal — no API/behavior change. Full SDK suite GREEN (2629 tests); `madge --circular` unchanged (1 intentional type-only `memory/memory-provider` cycle).
40
+ - Broke 2 of 3 type-only dependency cycles in the public type barrel (arch-review ADR 0001). `ForkOptions`/`ForkResult` moved to a leaf `types/fork.ts`, so `types/agent.ts` no longer imports the `internal/runtime/fork-agent.ts` implementation (`fork-agent.ts` re-exports them for back-compat). Eliminates the `types/agent.ts → fork-agent.ts → {plugins/types,(self)}` cycles. No behavior/API change; `madge --circular` drops from 3 to 1 (the remaining `memory-provider` cycle is a genuine bidirectional type relationship, runtime-safe, left intentionally).
41
+
42
+ ### Fixed
43
+
44
+ - Budget pre-flight gate now **fails closed**: if a custom `budgetTracker.check()` throws (a contract violation — `check()` must return a decision), the agent loop denies the next iteration instead of silently proceeding past budget. Previously a throwing tracker defaulted to `allowed: true` (fail-open), letting a broken cost guard run unbounded. Extracted to a unit-tested `evaluateBudgetGate` helper. (arch-review L1)
45
+
5
46
  ## [1.8.1] - 2026-06-12
6
47
 
7
48
  ### Changed
@@ -25,7 +66,7 @@
25
66
 
26
67
  - **Compression config resolution module (T2.2 step 2/N of plan `sdk-superiority-2026-06-07`, ADR D440)**: `resolveCompressionConfig(agentModel, config): ResolvedCompressionConfig` bridges the compression-model-registry (step 1) with the `Agent.create({compression})` override surface. Resolves: (a) compression model — registry default OR explicit `config.model` override; (b) API key — first-match chain: explicit `config.apiKey` → `THEOKIT_COMPRESSION_API_KEY` env var → undefined (signals aux-LLM client to use agent's main CredentialPool); (c) maxAttempts (default 3) + grace (default 1). Pure config resolution — no I/O. 11 new tests at `tests/internal/runtime/compression-config.test.ts`. Foundation for step 3 (aux-llm-client with OTel span) and step 4 (agent-loop wire).
27
68
 
28
- - **Model capabilities introspection registry (T3.10c step 1 of plan `sdk-superiority-2026-06-07`, DR3 #17)**: pre-T3.10c the SDK had no way to query a model's capability flags before sending a request — consumers who sent vision content to a text-only model or structured-output requests to a model without json_schema support got an opaque 400 from the provider. T3.10c step 1 adds the foundation pure-function registry `resolveModelCapabilities(modelId): ModelCapabilities` with typed per-model flags: `supportsVision`, `supportsStructuredOutput`, `supportsToolUse`, `supportsCacheControl`, `maxContextTokens`, `maxOutputTokens`. Resolution algorithm: strip routing prefixes (openrouter/, vertex/, bedrock/), exact-match against the vendor-model registry, then infer vendor from model name (claude-* → anthropic/, gpt-* → openai/, gemini-* → google/) for routing-prefixed lookups. Unknown models return conservative defaults (all false, 4096/4096 token counts) — never optimistic assumptions. Initial registry covers OpenAI (gpt-4o/4o-mini/4-turbo/o1/o3) and Anthropic (claude-opus-4/sonnet-4/3-5-sonnet/3-haiku/3-opus) families. 9 new tests at `tests/internal/llm/model-capabilities.test.ts`. Foundation for step 2 (public `Theokit.models.capabilities()` API) and step 3 (Agent.create boundary gate + `CapabilityNotSupportedError`).
69
+ - **Model capabilities introspection registry (T3.10c step 1 of plan `sdk-superiority-2026-06-07`, DR3 #17)**: pre-T3.10c the SDK had no way to query a model's capability flags before sending a request — consumers who sent vision content to a text-only model or structured-output requests to a model without json*schema support got an opaque 400 from the provider. T3.10c step 1 adds the foundation pure-function registry `resolveModelCapabilities(modelId): ModelCapabilities` with typed per-model flags: `supportsVision`, `supportsStructuredOutput`, `supportsToolUse`, `supportsCacheControl`, `maxContextTokens`, `maxOutputTokens`. Resolution algorithm: strip routing prefixes (openrouter/, vertex/, bedrock/), exact-match against the vendor-model registry, then infer vendor from model name (claude-* → anthropic/, gpt-\_ → openai/, gemini-\* → google/) for routing-prefixed lookups. Unknown models return conservative defaults (all false, 4096/4096 token counts) — never optimistic assumptions. Initial registry covers OpenAI (gpt-4o/4o-mini/4-turbo/o1/o3) and Anthropic (claude-opus-4/sonnet-4/3-5-sonnet/3-haiku/3-opus) families. 9 new tests at `tests/internal/llm/model-capabilities.test.ts`. Foundation for step 2 (public `Theokit.models.capabilities()` API) and step 3 (Agent.create boundary gate + `CapabilityNotSupportedError`).
29
70
 
30
71
  ### Fixed
31
72
 
@@ -70,11 +111,11 @@
70
111
  ### Refactored
71
112
 
72
113
  - **Cycle #4 closed via `types/handoff-descriptor.ts` leaf with TAgent generic (iter-20)**: `HandoffDescriptor` + `HandoffOptions` + `HandoffContext` + `HandoffHistory` + `HandoffResult` moved to a new leaf file. The leaf has `HandoffDescriptor<TInput, TAgent>` parameterized over the target agent shape — no dependency on `SDKAgent` or any other agent.ts type. `types/handoff.ts` re-exports the leaf types with `TAgent = SDKAgent` pinned for back-compat callers. `types/agent.ts` now imports `HandoffDescriptor` from the leaf, breaking the bidirectional `types/agent.ts ↔ types/handoff.ts` edge. madge final state: **2 cycles** (only D428-acknowledged rollup-dts subscribe-at-sub-path remain). Cycle gate threshold tightened ≤ 2.
73
- - **`internal/runtime/plugins/` sub-folder promotion + T5.1 complete (4 of 4, FO#1)**: 2 plugin-* files moved from `internal/runtime/` to `internal/runtime/plugins/` via `git mv`. Direct file count: 50 → 48. **T5.1 complete across 4 iterations (15-18)**: cumulative 21 files moved across fixtures/ (5) + context/ (8) + registry/ (6) + plugins/ (2). `internal/runtime/` direct file count dropped 69 → 48. Audit ideal heuristic is 25; remaining 23-file gap is documented as out-of-scope (no further cohesive 5+ file cluster remains). 254/254 runtime + architecture tests GREEN.
74
- - **`internal/runtime/registry/` sub-folder promotion (T5.1 partial 3 of 4, FO#1)**: 6 *-registry* files moved from `internal/runtime/` to `internal/runtime/registry/` via `git mv`. Direct file count: 56 → 50. T5.1 status PARTIAL — 3 of 4 clusters done (fixtures + context + registry). Remaining: plugins/. Cross-package caller surgery covered: `src/agent.ts`, `src/index.ts`, 5 runtime siblings, 4 test files, 1 dynamic `import("./agent-factory-registry.js")` in `local-agent-runtime-extensions.ts`. 253/253 runtime + architecture tests GREEN; madge unchanged.
75
- - **`internal/runtime/context/` sub-folder promotion (T5.1 partial 2 of 4, FO#1)**: 8 context-* files moved from `internal/runtime/` to `internal/runtime/context/` via `git mv`. Direct file count: 64 → 56. T5.1 status PARTIAL — 2 of 4 clusters done (fixtures + context). Remaining: registry/, plugins/. Sibling callers (`local-agent`, `local-agent-bootstrap`, `system-prompt/local-assembly`) had their imports rewritten to `./context/context-X.js` (or `../context/context-X.js` from system-prompt/). 8 test files updated. 252/252 runtime + architecture tests GREEN.
76
- - **`internal/runtime/fixtures/` sub-folder promotion (T5.1 partial, FO#1)**: 5 fixture-* files moved from `internal/runtime/` to `internal/runtime/fixtures/` via `git mv`. Direct file count: 69 → 64. T5.1 status PARTIAL — fixtures is 1 of 4 clusters (context/registry/plugins remain for follow-up iterations). Internal-only refactor; sibling callers (`cloud-run`, `local-run`, `real-local-run`, `real-cloud-run`) had their imports rewritten to `./fixtures/fixture-X.js`. 251/251 runtime + architecture tests GREEN; madge cycle count unchanged.
77
- - **`internal/memory/storage/` sub-folder promotion (T10.1, FO#3)**: 7 storage-primitive files moved from `internal/memory/` to `internal/memory/storage/` via `git mv` — `markdown-store.ts`, `transcript-store.ts`, `session-loader.ts`, `session-summary-writer.ts`, `reader.ts`, `wiki-loader.ts`, `chunk-markdown.ts`. Direct file count in `internal/memory/`: 28 → 22 (under the 25-file god-folder heuristic). Internal-only refactor; zero public API surface change. All sibling imports, runtime/* callers, and test paths updated in the same slice. Architecture guard `tests/architecture/memory-folder-budget.test.ts` (NEW) asserts the budget. 140/140 architecture + memory tests GREEN; madge cycle count unchanged.
114
+ - **`internal/runtime/plugins/` sub-folder promotion + T5.1 complete (4 of 4, FO#1)**: 2 plugin-\* files moved from `internal/runtime/` to `internal/runtime/plugins/` via `git mv`. Direct file count: 50 → 48. **T5.1 complete across 4 iterations (15-18)**: cumulative 21 files moved across fixtures/ (5) + context/ (8) + registry/ (6) + plugins/ (2). `internal/runtime/` direct file count dropped 69 → 48. Audit ideal heuristic is 25; remaining 23-file gap is documented as out-of-scope (no further cohesive 5+ file cluster remains). 254/254 runtime + architecture tests GREEN.
115
+ - **`internal/runtime/registry/` sub-folder promotion (T5.1 partial 3 of 4, FO#1)**: 6 _-registry_ files moved from `internal/runtime/` to `internal/runtime/registry/` via `git mv`. Direct file count: 56 → 50. T5.1 status PARTIAL — 3 of 4 clusters done (fixtures + context + registry). Remaining: plugins/. Cross-package caller surgery covered: `src/agent.ts`, `src/index.ts`, 5 runtime siblings, 4 test files, 1 dynamic `import("./agent-factory-registry.js")` in `local-agent-runtime-extensions.ts`. 253/253 runtime + architecture tests GREEN; madge unchanged.
116
+ - **`internal/runtime/context/` sub-folder promotion (T5.1 partial 2 of 4, FO#1)**: 8 context-\* files moved from `internal/runtime/` to `internal/runtime/context/` via `git mv`. Direct file count: 64 → 56. T5.1 status PARTIAL — 2 of 4 clusters done (fixtures + context). Remaining: registry/, plugins/. Sibling callers (`local-agent`, `local-agent-bootstrap`, `system-prompt/local-assembly`) had their imports rewritten to `./context/context-X.js` (or `../context/context-X.js` from system-prompt/). 8 test files updated. 252/252 runtime + architecture tests GREEN.
117
+ - **`internal/runtime/fixtures/` sub-folder promotion (T5.1 partial, FO#1)**: 5 fixture-\* files moved from `internal/runtime/` to `internal/runtime/fixtures/` via `git mv`. Direct file count: 69 → 64. T5.1 status PARTIAL — fixtures is 1 of 4 clusters (context/registry/plugins remain for follow-up iterations). Internal-only refactor; sibling callers (`cloud-run`, `local-run`, `real-local-run`, `real-cloud-run`) had their imports rewritten to `./fixtures/fixture-X.js`. 251/251 runtime + architecture tests GREEN; madge cycle count unchanged.
118
+ - **`internal/memory/storage/` sub-folder promotion (T10.1, FO#3)**: 7 storage-primitive files moved from `internal/memory/` to `internal/memory/storage/` via `git mv` — `markdown-store.ts`, `transcript-store.ts`, `session-loader.ts`, `session-summary-writer.ts`, `reader.ts`, `wiki-loader.ts`, `chunk-markdown.ts`. Direct file count in `internal/memory/`: 28 → 22 (under the 25-file god-folder heuristic). Internal-only refactor; zero public API surface change. All sibling imports, runtime/\* callers, and test paths updated in the same slice. Architecture guard `tests/architecture/memory-folder-budget.test.ts` (NEW) asserts the budget. 140/140 architecture + memory tests GREEN; madge cycle count unchanged.
78
119
  - **`dispatchSingleCall` orchestrator split (T10.4, PV#2)**: the 158 LOC body in `internal/agent-loop/tool-dispatch.ts` was decomposed into 7 named single-concern helpers (`applyRepairAndExtractCall`, `vetoFromForkWhitelist`, `startToolCallSpan`, `vetoFromPluginPreHook`, `vetoFromFileHookPreDecision`, `runToolWithLifecycle`, `finalizeSpanAndPostHook`). The orchestrator now reads as a ~28 LOC sequence; the previous complexity-suppression `biome-ignore` directive is removed. Zero public-API surface change; 51/51 regression tests (tool-dispatch + hooks + golden custom-tools) continue to pass.
79
120
 
80
121
  ### Fixed
@@ -126,12 +167,12 @@
126
167
 
127
168
  - **Load + chaos suite scaffold (T0.3 of plan `sdk-superiority-2026-06-07`)**: 6 new test files at `tests/load/{1000-concurrent-sse,leaky-generators,slow-consumer-backpressure}.test.ts` and `tests/chaos/{kill-mid-stream,partition-fs,oom-recovery}.test.ts`. Three harness modules ship alongside: `tests/load/_harness/sse-driver.ts` (in-process SSE driver — NOT autocannon — per SEPA brief § E; tracks p50/p95/p99 latencies + SSE event count via `\n\n` terminators per HTML LS § 9.2.6), `tests/load/_harness/socket-monitor.ts` (Linux-only `ss -tnp` probe with no-op fallback for Mac/Win; CI asserts `closeWaitCount ≤ threshold`), `tests/chaos/_harness/process-control.ts` (child-process spawn + SIGKILL injection per ADR D37 methodology). Today's scaffold uses 100 concurrent SSE (override via `T0_3_CONCURRENCY=1000`); T6.2 ratchets to the full 1000-conn p95 < 200ms perf gate, T6.3 wires the kill-mid-stream chaos against the SDK's real streaming surface, T6.4 wires partition-fs against persistence paths, T6.5 wires OOM against the memory subsystem.
128
169
  - **Real-LLM CI matrix scaffold (T0.2 of plan `sdk-superiority-2026-06-07`)**: 15 env-gated integration test files at `tests/integration/real-llm/{openai,anthropic,openrouter}-{tools,vision,stream,cache,structured}.test.ts`. Each file uses `describe.skipIf(...)` so the suite is silent when the relevant API key is absent. `tests/integration/real-llm/_helpers/real-llm-env.ts` centralizes the provider-key resolver with OpenRouter fallback for non-native scenarios (Anthropic cache stays native-only per SEPA initial brief § C). With keys set the matrix validates the happy path for tool use, streaming, vision content parts, prompt caching, and structured outputs across the 3 routes — expanded depth (cache_read_input_tokens > 0 assertion, parallel tool dispatch, error-retry) lands in T3.5 / T3.8 / T6.1. Default model `openai/gpt-4o-mini` per cost budget. Today: 15/15 files skip cleanly.
129
- - **OTel hot-path wiring foundation (T0.1 of plan `sdk-superiority-2026-06-07`)**: emit canonical spans `agent.create`, `agent.send` (parent), and `memory.recall` when `telemetry.enabled: true`. New closed-enum `internal/telemetry/span-names.ts` (14 names + `SpanName` literal type) anticipates the no-`(string & {})` discipline of T1.1. `TelemetryHandle` interface extended with `recordHistogram(name, valueMs, attrs)` and the OTel `metrics` namespace is lazy-loaded the same way `trace` is (graceful no-op when missing). First histogram name registered: `theokit_memory_recall_duration_ms` (recorded with `userId/namespace/scope/status` dimensions). Integration tests use a real `@opentelemetry/sdk-trace-base` `InMemorySpanExporter` (NOT module mocks) — added as devDep alongside `@opentelemetry/api` and `@opentelemetry/sdk-metrics`. Wiring triad: pillar (a) callers are `Agent.create` (production), `LocalAgent.send` (production), `runActiveMemory` (production); pillar (b) covered by `tests/telemetry/*.test.ts` (8 tests). Remaining acceptance items — `agent.send.<step>` 8 child spans, `tool.call`, `llm.call` spans — deferred to T1.7 / T2.4 / T3.* per SEPA brief (zero plan-deviation).
170
+ - **OTel hot-path wiring foundation (T0.1 of plan `sdk-superiority-2026-06-07`)**: emit canonical spans `agent.create`, `agent.send` (parent), and `memory.recall` when `telemetry.enabled: true`. New closed-enum `internal/telemetry/span-names.ts` (14 names + `SpanName` literal type) anticipates the no-`(string & {})` discipline of T1.1. `TelemetryHandle` interface extended with `recordHistogram(name, valueMs, attrs)` and the OTel `metrics` namespace is lazy-loaded the same way `trace` is (graceful no-op when missing). First histogram name registered: `theokit_memory_recall_duration_ms` (recorded with `userId/namespace/scope/status` dimensions). Integration tests use a real `@opentelemetry/sdk-trace-base` `InMemorySpanExporter` (NOT module mocks) — added as devDep alongside `@opentelemetry/api` and `@opentelemetry/sdk-metrics`. Wiring triad: pillar (a) callers are `Agent.create` (production), `LocalAgent.send` (production), `runActiveMemory` (production); pillar (b) covered by `tests/telemetry/*.test.ts` (8 tests). Remaining acceptance items — `agent.send.<step>` 8 child spans, `tool.call`, `llm.call` spans — deferred to T1.7 / T2.4 / T3.\* per SEPA brief (zero plan-deviation).
130
171
  - **`SecretRedactor` interface** at `internal/security/secret-redactor.ts` (T9.1 of plan `arch-review-fixes-2026-06-06`, ADR D437). Types-only — no runtime exports; canonical `redactSecrets` from `redact.ts` satisfies the interface structurally. Closes AF#16 (Martin Zone of Pain D=0.923) from the 2026-06-06 architecture audit through documentation + minimal abstraction without violating D68/D69/D70/D71/D73 (security primitives stay concrete + stable). Rationale + coupling metrics at `internal/security/README.md`.
131
172
 
132
173
  ### Changed
133
174
 
134
- - **Renamed `internal/runtime/system-prompt/providers/` → `internal/runtime/system-prompt/sources/`** (FO#6, plan `arch-review-fixes-2026-06-06` T10.3). The directory previously shared its basename with `internal/providers/` (LLM provider profiles per ADR D105-D107) — auditor flagged the duplicate folder name as a findability hazard. `sources/` better describes the semantic: these 5 modules are system-prompt *sources* (ActiveMemoryPromptProvider, BasePromptProvider, ContextPromptProvider, MemoryPromptProvider, SkillsPromptProvider), not LLM provider profiles. Internal-only rename; no public API touched. Git-rename detection preserved (5/5 files moved with `git mv`); import paths in `pipeline.ts` + 5 golden tests updated atomically.
175
+ - **Renamed `internal/runtime/system-prompt/providers/` → `internal/runtime/system-prompt/sources/`** (FO#6, plan `arch-review-fixes-2026-06-06` T10.3). The directory previously shared its basename with `internal/providers/` (LLM provider profiles per ADR D105-D107) — auditor flagged the duplicate folder name as a findability hazard. `sources/` better describes the semantic: these 5 modules are system-prompt _sources_ (ActiveMemoryPromptProvider, BasePromptProvider, ContextPromptProvider, MemoryPromptProvider, SkillsPromptProvider), not LLM provider profiles. Internal-only rename; no public API touched. Git-rename detection preserved (5/5 files moved with `git mv`); import paths in `pipeline.ts` + 5 golden tests updated atomically.
135
176
 
136
177
  ### Fixed
137
178
 
@@ -175,23 +216,23 @@
175
216
 
176
217
  ### Security threats addressed
177
218
 
178
- | Threat | Mitigation |
179
- |---|---|
180
- | Resume token replay | Consumer SHOULD bind token to session + rotate per reconnect; SDK ships TTL knob via custom `tracked()` envelope semantics |
181
- | WS connection hijacking | Auth at HTTP upgrade — `WsAdapter.upgrade(ctx, raw)` exposes the `request` so consumer middleware (G11 `defineAuth`) runs BEFORE upgrade. Rejected upgrade returns null → caller responds 401 |
182
- | Subscription input tampering | Zod schema validation BEFORE handler invocation; throws `SubscriptionInputError` carrying issues |
183
- | Resource exhaustion | Per-subscription `AbortSignal`; `SubscriptionRuntime.getActiveConnectionCount()` for ops visibility; consumer wires rate-limit middleware (P#10) at upgrade boundary |
184
- | Sensitive data in logs | Telemetry seam (D34) captures metadata only (`subscriptionName`, `lastEventId`, `connectionId`); never payloads (per D73 redact at output boundaries) |
185
- | Long-lived WS survives token expiry | `ctx.disconnect(code, reason)` lets consumer's auth middleware force-close when session revoked |
219
+ | Threat | Mitigation |
220
+ | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
221
+ | Resume token replay | Consumer SHOULD bind token to session + rotate per reconnect; SDK ships TTL knob via custom `tracked()` envelope semantics |
222
+ | WS connection hijacking | Auth at HTTP upgrade — `WsAdapter.upgrade(ctx, raw)` exposes the `request` so consumer middleware (G11 `defineAuth`) runs BEFORE upgrade. Rejected upgrade returns null → caller responds 401 |
223
+ | Subscription input tampering | Zod schema validation BEFORE handler invocation; throws `SubscriptionInputError` carrying issues |
224
+ | Resource exhaustion | Per-subscription `AbortSignal`; `SubscriptionRuntime.getActiveConnectionCount()` for ops visibility; consumer wires rate-limit middleware (P#10) at upgrade boundary |
225
+ | Sensitive data in logs | Telemetry seam (D34) captures metadata only (`subscriptionName`, `lastEventId`, `connectionId`); never payloads (per D73 redact at output boundaries) |
226
+ | Long-lived WS survives token expiry | `ctx.disconnect(code, reason)` lets consumer's auth middleware force-close when session revoked |
186
227
 
187
228
  ### Multi-runtime compatibility matrix
188
229
 
189
- | Runtime | v1.7.0 | v1.8.x (planned) |
190
- |---|---|---|
191
- | Node 22+ | yes (canonical `ws` peer) | yes |
192
- | Cloudflare Workers | consumer adapter only | yes (`@theokit/sdk-ws-cloudflare`) |
193
- | Bun | consumer adapter only | yes (`@theokit/sdk-ws-bun`) |
194
- | Deno | consumer adapter only | yes (`@theokit/sdk-ws-deno`) |
230
+ | Runtime | v1.7.0 | v1.8.x (planned) |
231
+ | ------------------ | ------------------------- | ---------------------------------- |
232
+ | Node 22+ | yes (canonical `ws` peer) | yes |
233
+ | Cloudflare Workers | consumer adapter only | yes (`@theokit/sdk-ws-cloudflare`) |
234
+ | Bun | consumer adapter only | yes (`@theokit/sdk-ws-bun`) |
235
+ | Deno | consumer adapter only | yes (`@theokit/sdk-ws-deno`) |
195
236
 
196
237
  ### Notes
197
238
 
@@ -237,6 +278,7 @@
237
278
  ### Breaking Changes
238
279
 
239
280
  - **`Workflow` and `Eval` moved out of the main barrel into dedicated sub-paths.** The migration is mechanical (rewrite the `from` string); no behavior changes. `@theokit/sdk` main barrel no longer exports:
281
+
240
282
  - From workflow: `Workflow`, `WorkflowBuilder`, `agentStep`, `fn`, `WorkflowAlreadyRunningError`, `WorkflowCompensateNotImplementedError`, `WorkflowDuplicateStepIdError`, `WorkflowMaxIterationsExceededError`, `WorkflowNotSerializableError`, `WorkflowParallelError`, `WorkflowResumeStepNotFoundError`, `WorkflowSnapshotNotFoundError` — **import from `@theokit/sdk/workflow` instead**.
241
283
  - From eval: `Eval`, `EvalAlreadyRunningError`, `Scorers` — **import from `@theokit/sdk/eval` instead**.
242
284
  - From `types/*`: type aliases for workflow + eval (e.g., `EvalRun`, `Scorer`, `Score`, `EvalOptions`, `EvalAggregate`, `Step`, `FnStep`, etc.) no longer reach the main barrel via `types/index.ts`; surface only through the new sub-paths.
@@ -244,6 +286,7 @@
244
286
  Rationale: Interface Segregation. The barrel exported 17+ feature areas, forcing consumers to pay the DTS cost of `Workflow`+`Eval` even if they only used `Agent`+`Memory`. Sub-paths reduce DTS surface and align with the existing pattern (`@theokit/sdk/cron`, `/tools`, `/path-safety`, `/task-store`, `/errors`).
245
287
 
246
288
  **Migration:**
289
+
247
290
  ```ts
248
291
  // Before
249
292
  import { Workflow, Eval, Scorers } from "@theokit/sdk";
@@ -277,18 +320,22 @@
277
320
  - **`Memory.create({ index: { backend: "lance" } })` is now wired end-to-end.** The `LanceIndex` implementation existed since 2026-05-17 (ADR D43) but `IndexManager.open` did not dispatch — public API accepted `backend: "lance"` silently and always fell through to SQLite. Fix: factory dispatcher in `IndexManager.open` + new portable `MemoryIndex` interface + new `LanceMemoryAdapter` wrapper + `@lancedb/lancedb` declared as optional `peerDependency` (`^0.30.0`).
278
321
 
279
322
  **Migration path:** consumer that wants Lance:
323
+
280
324
  ```bash
281
325
  pnpm add @lancedb/lancedb apache-arrow@^18.1.0
282
326
  ```
327
+
283
328
  ```ts
284
329
  await Memory.create({
285
330
  index: { backend: "lance" },
286
331
  embedding: { provider: "openai", apiKey: process.env.OPENAI_API_KEY },
287
332
  });
288
333
  ```
334
+
289
335
  Default keeps SQLite (zero added deps, zero breaking change vs 1.3.0).
290
336
 
291
337
  **When to opt-in (benchmark evidence — `.claude/knowledge-base/benchmarks/memory-backends-2026-05-31.md`):**
338
+
292
339
  - Lance wins **43x** ingest throughput at 100k facts (59849 ops/s vs SQLite-vec 1875 ops/s).
293
340
  - Lance uses **65% less disk** at 100k (33.8 MB vs 93.5 MB).
294
341
  - SQLite-vec recall p95 stays competitive up to 100k (~25 ms). Use Lance when ingest velocity or disk pressure matters; SQLite handles latency well below 1M facts.
@@ -296,6 +343,7 @@
296
343
  **EC-1 hardening:** new `ConfigurationError({code:"invalid_memory_backend"})` for typo-protection — `backend: "lancedb"` (typo) now throws instead of silently falling back to SQLite. Same hardening for `lance_requires_embedding` and `lance_backend_unavailable` typed errors.
297
344
 
298
345
  **Gotchas:**
346
+
299
347
  - `@lancedb/lancedb` ships prebuilds for linux-x64-gnu, darwin-arm64, darwin-x64, win32-x64-msvc. Alpine/musl/ARM-Linux require `node-gyp` toolchain. SQLite default covers those cases.
300
348
  - Bundlers (Next.js/Vite/webpack/rollup) must externalize `@lancedb/lancedb`:
301
349
  - Next.js: `experimental.serverComponentsExternalPackages: ["@lancedb/lancedb"]`
File without changes