@theokit/sdk 2.18.0 → 2.19.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 CHANGED
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.19.0
4
+
5
+ ### Minor Changes
6
+
7
+ - `GenerateObjectOptions.errorStrategy` (`"throw" | "return-partial" | "return-raw"`, default `"throw"`) — controls what `Agent.generateObject` does when the model's output still fails schema validation after all retries. `"return-raw"` resolves with the raw unvalidated input; `"return-partial"` salvages best-effort (object schemas keep only fields that individually validate). Additive + backward-compatible (M14).
8
+
9
+ ## 2.18.1
10
+
11
+ ### Patch Changes
12
+
13
+ - fc09700: Label the cloud-only surfaces as pre-release in `docs.md` (M7). The README already
14
+ carried a "Cloud runtime — pre-release" banner; `docs.md` (the canonical API
15
+ contract) only labeled artifacts. It now carries an explicit cloud pre-release
16
+ banner in the Overview and inline "cloud-only, pre-release" labels on `cloud.envVars`,
17
+ `cloud.autoCreatePR`, and `result.git` — matching the SDK's pre-release-honesty
18
+ contract (cloud depends on Theo PaaS, currently pre-release; every cloud API
19
+ describes the contract for when PaaS reaches GA, validated by the SDK's cloud
20
+ contract/golden tests against a stub, not a live endpoint). No API or behavior
21
+ change; no GA claim. Also fixed a teardown race in the cloud runtime contract test
22
+ (dispose flushes the fire-and-forget session appends before the temp workspace is
23
+ removed, so `rm(recursive)` no longer races an in-flight write into `ENOTEMPTY`).
24
+ - e132c2d: Strengthen the README cross-pillar front door (M8 GA-readiness): the "Where this
25
+ fits" section now explains the 4-pillar OPEN-STACK composition (UI · Harness ·
26
+ Skills · Runtime), how they compose end-to-end (local agent + tools/plugins +
27
+ `useAgentStream` render, zero Theo-backend dependency), the honest per-pillar status
28
+ (Runtime/cloud pre-release), and the validated cross-pillar wiring (Skills↔Harness +
29
+ UI↔Harness green vs SDK 2.18.0; Runtime↔Harness contract-only). Also fixes a stale
30
+ reference to the removed `referencia/` directory (study peers are cloned on demand
31
+ under `.claude/knowledge-base/reference/`). Docs-only; no API/behavior change; no GA
32
+ claim.
33
+
3
34
  ## 2.18.0
4
35
 
5
36
  ### Minor Changes
@@ -7863,22 +7863,23 @@ async function executeTool(inputs, resolved, call) {
7863
7863
  return { stdout: "", stderr: `Unknown tool ${call.name}`, exitCode: 127 };
7864
7864
  }
7865
7865
  if (resolved.origin === "shell") return runShellTool(inputs, call);
7866
- if (resolved.origin === "memory") return runMemoryTool(resolved, call);
7867
- if (resolved.origin === "custom") return runCustomTool(resolved, call, inputs.signal);
7866
+ if (resolved.origin === "memory") return runMemoryTool(resolved, call, inputs.context);
7867
+ if (resolved.origin === "custom")
7868
+ return runCustomTool(resolved, call, inputs.signal, inputs.context);
7868
7869
  return runMcpTool(inputs, resolved, call);
7869
7870
  }
7870
- async function runMemoryTool(resolved, call) {
7871
- return runHandlerTool("memory", resolved.memoryHandler, call);
7871
+ async function runMemoryTool(resolved, call, context) {
7872
+ return runHandlerTool("memory", resolved.memoryHandler, call, void 0, context);
7872
7873
  }
7873
- async function runCustomTool(resolved, call, signal) {
7874
- return runHandlerTool("custom", resolved.customHandler, call, signal);
7874
+ async function runCustomTool(resolved, call, signal, context) {
7875
+ return runHandlerTool("custom", resolved.customHandler, call, signal, context);
7875
7876
  }
7876
- async function runHandlerTool(kind, handler, call, signal) {
7877
+ async function runHandlerTool(kind, handler, call, signal, context) {
7877
7878
  if (handler === void 0) {
7878
7879
  return { stdout: "", stderr: `${kind} tool ${call.name} has no handler`, exitCode: 127 };
7879
7880
  }
7880
7881
  try {
7881
- const stdout = await handler(call.input, { signal });
7882
+ const stdout = await handler(call.input, { signal, context });
7882
7883
  return { stdout, stderr: "", exitCode: 0 };
7883
7884
  } catch (cause) {
7884
7885
  const message = cause instanceof Error ? cause.message : String(cause);
@@ -12383,6 +12384,9 @@ function buildLoopInputs(options, runId, userText) {
12383
12384
  // D318 — forward SendOptions.signal to the agent loop so streamLlmTurn
12384
12385
  // can attach it to the LLM `fetch({ signal })` call.
12385
12386
  ...options.sendOptions.signal !== void 0 ? { signal: options.sendOptions.signal } : {},
12387
+ // M7 — forward SendOptions.context to the loop so every tool handler receives
12388
+ // it on `ctx.context` (shared run config set once, e.g. projectRoot).
12389
+ ...options.sendOptions.context !== void 0 ? { context: options.sendOptions.context } : {},
12386
12390
  // #58 / #57 — forward the per-tool timeout + tool-result guard so a consumer
12387
12391
  // can enable them via SendOptions (not only internal AgentLoopInputs).
12388
12392
  ...options.sendOptions.perToolTimeoutMs !== void 0 ? { perToolTimeoutMs: options.sendOptions.perToolTimeoutMs } : {},
@@ -17153,6 +17157,19 @@ __export(generate_object_exports, {
17153
17157
  GenerateObjectError: () => GenerateObjectError,
17154
17158
  generateObjectImpl: () => generateObjectImpl
17155
17159
  });
17160
+ function salvagePartial(schema, raw) {
17161
+ if (typeof raw !== "object" || raw === null) return raw;
17162
+ const shape = schema.shape;
17163
+ if (shape === void 0 || typeof shape !== "object") return raw;
17164
+ const rawObj = raw;
17165
+ const out = {};
17166
+ for (const [key, fieldSchema] of Object.entries(shape)) {
17167
+ if (typeof fieldSchema?.safeParse !== "function") continue;
17168
+ const parsed = fieldSchema.safeParse(rawObj[key]);
17169
+ if (parsed.success) out[key] = parsed.data;
17170
+ }
17171
+ return out;
17172
+ }
17156
17173
  async function generateObjectImpl(options, deps) {
17157
17174
  const { jsonSchema, maxRetries, initialUsage } = setupStructuredOutput(
17158
17175
  options.schema,
@@ -17219,6 +17236,22 @@ async function generateObjectImpl(options, deps) {
17219
17236
  }
17220
17237
  lastParseError = parsed.error;
17221
17238
  }
17239
+ if (options.errorStrategy === "return-raw") {
17240
+ return {
17241
+ object: capturedRaw,
17242
+ raw: capturedRaw,
17243
+ usage: lastUsage,
17244
+ finishReason: "tool_use"
17245
+ };
17246
+ }
17247
+ if (options.errorStrategy === "return-partial") {
17248
+ return {
17249
+ object: salvagePartial(options.schema, capturedRaw),
17250
+ raw: capturedRaw,
17251
+ usage: lastUsage,
17252
+ finishReason: "tool_use"
17253
+ };
17254
+ }
17222
17255
  throw new GenerateObjectError(
17223
17256
  "parse_failed",
17224
17257
  "Schema parse failed after all retries.",