@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/dist/cron.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import './run-pE-34AAo.cjs';
2
- export { K as Cron } from './cron-ZLSKbDbB.cjs';
1
+ import './run-BgfBWX-z.cjs';
2
+ export { K as Cron } from './cron-D_wK1S-0.cjs';
package/dist/cron.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import './run-pE-34AAo.js';
2
- export { K as Cron } from './cron-Bbg0mBOv.js';
1
+ import './run-BgfBWX-z.js';
2
+ export { K as Cron } from './cron-Cep07kTz.js';
package/dist/cron.js CHANGED
@@ -2253,6 +2253,19 @@ __export(generate_object_exports, {
2253
2253
  GenerateObjectError: () => GenerateObjectError,
2254
2254
  generateObjectImpl: () => generateObjectImpl
2255
2255
  });
2256
+ function salvagePartial(schema, raw) {
2257
+ if (typeof raw !== "object" || raw === null) return raw;
2258
+ const shape = schema.shape;
2259
+ if (shape === void 0 || typeof shape !== "object") return raw;
2260
+ const rawObj = raw;
2261
+ const out = {};
2262
+ for (const [key, fieldSchema] of Object.entries(shape)) {
2263
+ if (typeof fieldSchema?.safeParse !== "function") continue;
2264
+ const parsed = fieldSchema.safeParse(rawObj[key]);
2265
+ if (parsed.success) out[key] = parsed.data;
2266
+ }
2267
+ return out;
2268
+ }
2256
2269
  async function generateObjectImpl(options, deps) {
2257
2270
  const { jsonSchema, maxRetries, initialUsage } = setupStructuredOutput(
2258
2271
  options.schema,
@@ -2319,6 +2332,22 @@ async function generateObjectImpl(options, deps) {
2319
2332
  }
2320
2333
  lastParseError = parsed.error;
2321
2334
  }
2335
+ if (options.errorStrategy === "return-raw") {
2336
+ return {
2337
+ object: capturedRaw,
2338
+ raw: capturedRaw,
2339
+ usage: lastUsage,
2340
+ finishReason: "tool_use"
2341
+ };
2342
+ }
2343
+ if (options.errorStrategy === "return-partial") {
2344
+ return {
2345
+ object: salvagePartial(options.schema, capturedRaw),
2346
+ raw: capturedRaw,
2347
+ usage: lastUsage,
2348
+ finishReason: "tool_use"
2349
+ };
2350
+ }
2322
2351
  throw new GenerateObjectError(
2323
2352
  "parse_failed",
2324
2353
  "Schema parse failed after all retries.",
@@ -9217,22 +9246,23 @@ async function executeTool(inputs, resolved, call) {
9217
9246
  return { stdout: "", stderr: `Unknown tool ${call.name}`, exitCode: 127 };
9218
9247
  }
9219
9248
  if (resolved.origin === "shell") return runShellTool(inputs, call);
9220
- if (resolved.origin === "memory") return runMemoryTool(resolved, call);
9221
- if (resolved.origin === "custom") return runCustomTool(resolved, call, inputs.signal);
9249
+ if (resolved.origin === "memory") return runMemoryTool(resolved, call, inputs.context);
9250
+ if (resolved.origin === "custom")
9251
+ return runCustomTool(resolved, call, inputs.signal, inputs.context);
9222
9252
  return runMcpTool(inputs, resolved, call);
9223
9253
  }
9224
- async function runMemoryTool(resolved, call) {
9225
- return runHandlerTool("memory", resolved.memoryHandler, call);
9254
+ async function runMemoryTool(resolved, call, context) {
9255
+ return runHandlerTool("memory", resolved.memoryHandler, call, void 0, context);
9226
9256
  }
9227
- async function runCustomTool(resolved, call, signal) {
9228
- return runHandlerTool("custom", resolved.customHandler, call, signal);
9257
+ async function runCustomTool(resolved, call, signal, context) {
9258
+ return runHandlerTool("custom", resolved.customHandler, call, signal, context);
9229
9259
  }
9230
- async function runHandlerTool(kind, handler, call, signal) {
9260
+ async function runHandlerTool(kind, handler, call, signal, context) {
9231
9261
  if (handler === void 0) {
9232
9262
  return { stdout: "", stderr: `${kind} tool ${call.name} has no handler`, exitCode: 127 };
9233
9263
  }
9234
9264
  try {
9235
- const stdout = await handler(call.input, { signal });
9265
+ const stdout = await handler(call.input, { signal, context });
9236
9266
  return { stdout, stderr: "", exitCode: 0 };
9237
9267
  } catch (cause) {
9238
9268
  const message = cause instanceof Error ? cause.message : String(cause);
@@ -13115,6 +13145,9 @@ function buildLoopInputs(options, runId, userText) {
13115
13145
  // D318 — forward SendOptions.signal to the agent loop so streamLlmTurn
13116
13146
  // can attach it to the LLM `fetch({ signal })` call.
13117
13147
  ...options.sendOptions.signal !== void 0 ? { signal: options.sendOptions.signal } : {},
13148
+ // M7 — forward SendOptions.context to the loop so every tool handler receives
13149
+ // it on `ctx.context` (shared run config set once, e.g. projectRoot).
13150
+ ...options.sendOptions.context !== void 0 ? { context: options.sendOptions.context } : {},
13118
13151
  // #58 / #57 — forward the per-tool timeout + tool-result guard so a consumer
13119
13152
  // can enable them via SendOptions (not only internal AgentLoopInputs).
13120
13153
  ...options.sendOptions.perToolTimeoutMs !== void 0 ? { perToolTimeoutMs: options.sendOptions.perToolTimeoutMs } : {},