theokit 0.1.0-alpha.8 → 0.2.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 (62) hide show
  1. package/dist/add-2ZFFGGE4.js +0 -0
  2. package/dist/aws-lambda-PONVF3UX.js +0 -0
  3. package/dist/broadcast-QOQGUNNK.js +0 -0
  4. package/dist/build-IQQYCA3B.js +0 -0
  5. package/dist/bun-DITMZMKL.js +0 -0
  6. package/dist/check-PZR67OY5.js +0 -0
  7. package/dist/chunk-3Q36SEDK.js +0 -0
  8. package/dist/chunk-5ODOE6EF.js +0 -0
  9. package/dist/chunk-GQSTRXXB.js +0 -0
  10. package/dist/{chunk-MCP6Y5BA.js → chunk-JBC7PFV4.js} +25 -1
  11. package/dist/chunk-JBC7PFV4.js.map +1 -0
  12. package/dist/chunk-JZ5WEG3S.js +0 -0
  13. package/dist/chunk-KT3MWNZG.js +0 -0
  14. package/dist/chunk-O7335ZGH.js +0 -0
  15. package/dist/chunk-OK2PJOLK.js +105 -0
  16. package/dist/chunk-OK2PJOLK.js.map +1 -0
  17. package/dist/chunk-S3JBIFKS.js +0 -0
  18. package/dist/chunk-WQCPKA2L.js +0 -0
  19. package/dist/chunk-WZ7CPVQB.js +0 -0
  20. package/dist/chunk-XMS5VRIK.js +0 -0
  21. package/dist/chunk-Y5KE6YFP.js +0 -0
  22. package/dist/chunk-ZK5JCE5J.js +0 -0
  23. package/dist/cli/index.js +1 -1
  24. package/dist/cloudflare-RBANU3SE.js +0 -0
  25. package/dist/configure-agent-registry-6YGTJYBC.js +0 -0
  26. package/dist/deno-deploy-J7LI6HNL.js +0 -0
  27. package/dist/dev-VN6WS3CM.js +0 -0
  28. package/dist/devtools/entry.js +249 -203
  29. package/dist/devtools/entry.js.map +1 -1
  30. package/dist/dispatcher-IK3FVMX5.js +8 -0
  31. package/dist/dispatcher-IK3FVMX5.js.map +1 -0
  32. package/dist/{dist-UZV7J3YI.js → dist-Q5VBFWVL.js} +251 -89
  33. package/dist/dist-Q5VBFWVL.js.map +1 -0
  34. package/dist/docker-EZDA5FT7.js +0 -0
  35. package/dist/generate-SIO4JSKJ.js +0 -0
  36. package/dist/info-B3UOXFUF.js +0 -0
  37. package/dist/lib-NST3PNZX.js +0 -0
  38. package/dist/netlify-IFY6ZGFV.js +0 -0
  39. package/dist/node-KWZI3CKV.js +0 -0
  40. package/dist/proper-lockfile-MVKMQGFK.js +0 -0
  41. package/dist/registry-BB3UYAOG.js +0 -0
  42. package/dist/routes-CAGFZKUK.js +0 -0
  43. package/dist/scan-C2BOKLSY.js +0 -0
  44. package/dist/schema-MVB2FVK6.js +0 -0
  45. package/dist/server/cost/index.d.ts +7 -0
  46. package/dist/server/cost/index.js +1 -1
  47. package/dist/server/index.js +70 -2
  48. package/dist/server/index.js.map +1 -1
  49. package/dist/services-typed-client-ZX5JUHH3.js +0 -0
  50. package/dist/sqlite-vec-54KB4RD3.js +0 -0
  51. package/dist/{start-CSLJQXV3.js → start-ZGWW5MOL.js} +3 -3
  52. package/dist/static-BH6JQNM2.js +0 -0
  53. package/dist/storage-manager-D5KBXXKB.js +0 -0
  54. package/dist/theo-cloud-3K4DGB3S.js +0 -0
  55. package/dist/upgrade-readiness-OHL36FQL.js +0 -0
  56. package/dist/vercel-RHADE5IP.js +0 -0
  57. package/dist/vite-plugin-WA3G45YY.js +0 -0
  58. package/package.json +7 -7
  59. package/LICENSE +0 -201
  60. package/dist/chunk-MCP6Y5BA.js.map +0 -1
  61. package/dist/dist-UZV7J3YI.js.map +0 -1
  62. /package/dist/{start-CSLJQXV3.js.map → start-ZGWW5MOL.js.map} +0 -0
@@ -0,0 +1,8 @@
1
+ import {
2
+ dispatcher
3
+ } from "./chunk-OK2PJOLK.js";
4
+ import "./chunk-DGUM43GV.js";
5
+ export {
6
+ dispatcher
7
+ };
8
+ //# sourceMappingURL=dispatcher-IK3FVMX5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -2319,6 +2319,57 @@ var init_registry = __esm({
2319
2319
  });
2320
2320
  }
2321
2321
  });
2322
+ function toJsonSchema(schema, options = { unrepresentable: "any" }) {
2323
+ const native = tryNativeZod4(schema, options);
2324
+ if (native !== void 0) return native;
2325
+ const fallback = tryFallbackLib(schema);
2326
+ if (fallback !== void 0) return fallback;
2327
+ throw new Error(
2328
+ 'Zod \u2192 JSON Schema conversion failed: neither Zod 4\'s native `z.toJSONSchema` nor the `zod-to-json-schema` peer dep are available. On Zod 4: ensure `zod >= 4.0.0` is installed. On Zod 3: add `"zod-to-json-schema": "^3.24.0"` to your package.json.'
2329
+ );
2330
+ }
2331
+ function tryNativeZod4(schema, options) {
2332
+ if (cachedZodHasNativeApi === false) return void 0;
2333
+ let z12;
2334
+ try {
2335
+ z12 = requireSdk("zod");
2336
+ } catch {
2337
+ cachedZodHasNativeApi = false;
2338
+ return void 0;
2339
+ }
2340
+ if (typeof z12.toJSONSchema !== "function") {
2341
+ cachedZodHasNativeApi = false;
2342
+ return void 0;
2343
+ }
2344
+ cachedZodHasNativeApi = true;
2345
+ return z12.toJSONSchema(schema, options);
2346
+ }
2347
+ function tryFallbackLib(schema) {
2348
+ if (cachedFallbackLib !== void 0) {
2349
+ return cachedFallbackLib(schema);
2350
+ }
2351
+ if (triedFallback) return void 0;
2352
+ triedFallback = true;
2353
+ try {
2354
+ const mod = requireSdk("zod-to-json-schema");
2355
+ const fn2 = typeof mod.zodToJsonSchema === "function" ? mod.zodToJsonSchema : typeof mod.default === "function" ? mod.default : void 0;
2356
+ if (fn2 === void 0) return void 0;
2357
+ cachedFallbackLib = fn2;
2358
+ return fn2(schema);
2359
+ } catch {
2360
+ return void 0;
2361
+ }
2362
+ }
2363
+ var requireSdk;
2364
+ var cachedZodHasNativeApi;
2365
+ var cachedFallbackLib;
2366
+ var triedFallback;
2367
+ var init_to_json_schema = __esm({
2368
+ "src/internal/zod/to-json-schema.ts"() {
2369
+ requireSdk = createRequire(import.meta.url);
2370
+ triedFallback = false;
2371
+ }
2372
+ });
2322
2373
  function requireZod() {
2323
2374
  if (cachedZ !== void 0) return cachedZ;
2324
2375
  const r = createRequire(import.meta.url);
@@ -2369,9 +2420,7 @@ Respond by calling the \`output\` tool with the structured answer that matches t
2369
2420
  }
2370
2421
  function setupStructuredOutput(schema, maxRetries) {
2371
2422
  const z12 = requireZod();
2372
- const jsonSchema = z12.toJSONSchema(schema, {
2373
- unrepresentable: "any"
2374
- });
2423
+ const jsonSchema = toJsonSchema(schema, { unrepresentable: "any" });
2375
2424
  return {
2376
2425
  z: z12,
2377
2426
  jsonSchema,
@@ -2390,6 +2439,7 @@ var cachedZ;
2390
2439
  var init_structured_output_helpers = __esm({
2391
2440
  "src/internal/structured-output-helpers.ts"() {
2392
2441
  init_errors();
2442
+ init_to_json_schema();
2393
2443
  }
2394
2444
  });
2395
2445
  var generate_object_exports = {};
@@ -3169,7 +3219,7 @@ function buildHandoffTool(parentAgentId, descriptor, maxHandoffDepth) {
3169
3219
  const inputZod = descriptor.options.inputType ?? z.object({
3170
3220
  reason: z.string().optional().describe("Brief reason for the transfer (one short sentence).")
3171
3221
  });
3172
- const inputSchema = z.toJSONSchema(inputZod);
3222
+ const inputSchema = toJsonSchema(inputZod);
3173
3223
  return {
3174
3224
  name: descriptor.resolvedToolName,
3175
3225
  description,
@@ -3204,6 +3254,7 @@ function buildHandoffTool(parentAgentId, descriptor, maxHandoffDepth) {
3204
3254
  var init_tool_injector = __esm({
3205
3255
  "src/internal/handoff/tool-injector.ts"() {
3206
3256
  init_handoff();
3257
+ init_to_json_schema();
3207
3258
  init_dispatcher();
3208
3259
  init_registry2();
3209
3260
  }
@@ -9361,7 +9412,10 @@ async function runAgentLoop(inputs) {
9361
9412
  result: ctx.finalText,
9362
9413
  conversation: ctx.conversation,
9363
9414
  ...usage !== void 0 ? { usage } : {},
9364
- ...cost !== void 0 ? { cost } : {}
9415
+ ...cost !== void 0 ? { cost } : {},
9416
+ // Finding-B fix: surface structured error so runtime can package
9417
+ // it as RunResult.error instead of leaking it as assistant content.
9418
+ ...ctx.error !== void 0 ? { error: ctx.error } : {}
9365
9419
  };
9366
9420
  } finally {
9367
9421
  sendSpan?.end();
@@ -9517,13 +9571,25 @@ async function collectLlmEvents(generator, inputs, ctx) {
9517
9571
  errored = result.errored;
9518
9572
  finishValue = result.finishValue;
9519
9573
  } catch (cause) {
9520
- const text = inputs.signal?.aborted === true ? "[aborted]" : cause instanceof Error ? cause.message : String(cause);
9521
- ctx.finalText = text;
9522
- ctx.events.push(buildAssistantEvent(inputs, text));
9574
+ if (inputs.signal?.aborted === true) {
9575
+ ctx.finalText = "[aborted]";
9576
+ ctx.events.push(buildAssistantEvent(inputs, "[aborted]"));
9577
+ } else {
9578
+ registerLoopError(ctx, cause);
9579
+ ctx.finalText = "";
9580
+ }
9523
9581
  errored = true;
9524
9582
  }
9525
9583
  return { accumulatedText, errored, finishValue };
9526
9584
  }
9585
+ function registerLoopError(ctx, cause) {
9586
+ if (ctx.error !== void 0) return;
9587
+ const rawMessage = cause?.message;
9588
+ const message = typeof rawMessage === "string" ? rawMessage : cause instanceof Error ? cause.message : String(cause);
9589
+ const rawCode = cause?.code;
9590
+ const code = typeof rawCode === "string" ? rawCode : void 0;
9591
+ ctx.error = code !== void 0 ? { message, code, cause } : { message, cause };
9592
+ }
9527
9593
  async function runCollectorLoop(generator, inputs, ctx) {
9528
9594
  let accumulatedText = "";
9529
9595
  let errored = false;
@@ -9539,8 +9605,8 @@ async function runCollectorLoop(generator, inputs, ctx) {
9539
9605
  await emitTextDeltaCallback(inputs, next.value.text);
9540
9606
  }
9541
9607
  if (next.value.type === "error") {
9542
- ctx.finalText = next.value.message;
9543
- ctx.events.push(buildAssistantEvent(inputs, next.value.message));
9608
+ registerLoopError(ctx, next.value);
9609
+ ctx.finalText = "";
9544
9610
  errored = true;
9545
9611
  break;
9546
9612
  }
@@ -10316,6 +10382,167 @@ function buildBedrockBody(request) {
10316
10382
  init_credential_pool();
10317
10383
  init_credential_pool_context();
10318
10384
  init_errors();
10385
+ function mapOpenAICompatibleError(args) {
10386
+ const { providerId, status, body, headers, endpoint } = args;
10387
+ const code = mapOpenAiStatusToCode(status, body);
10388
+ const message = formatMessage2(providerId, status, code);
10389
+ const metadata = buildErrorMetadata({
10390
+ provider: providerId,
10391
+ endpoint,
10392
+ code,
10393
+ status,
10394
+ headers,
10395
+ body
10396
+ });
10397
+ if (status === 401 || status === 403) {
10398
+ return new AuthenticationError(message, { code: `${providerId}_auth_failed`, metadata });
10399
+ }
10400
+ if (status === 429) {
10401
+ return new RateLimitError(message, { code: `${providerId}_rate_limit`, metadata });
10402
+ }
10403
+ if (status === 400) {
10404
+ return new ConfigurationError(message, { code: `${providerId}_${code}`, metadata });
10405
+ }
10406
+ if (status === 408) {
10407
+ return new NetworkError(message, { code: `${providerId}_timeout`, metadata });
10408
+ }
10409
+ if (status >= 500 && status < 600) {
10410
+ return new NetworkError(message, { code: `${providerId}_server_error`, metadata });
10411
+ }
10412
+ return new UnknownAgentError(message, { code: `${providerId}_unknown`, metadata });
10413
+ }
10414
+ function extractOpenAiErrorCode(body) {
10415
+ if (body === null || typeof body !== "object") return void 0;
10416
+ const err = body.error;
10417
+ if (err === void 0 || err === null) return void 0;
10418
+ if (typeof err.code === "string") return err.code;
10419
+ if (typeof err.type === "string") return err.type;
10420
+ return void 0;
10421
+ }
10422
+ function mapOpenAiStatusToCode(status, body) {
10423
+ const rawCode = extractOpenAiErrorCode(body)?.toLowerCase() ?? "";
10424
+ if (rawCode.includes("context_length") || rawCode.includes("context_window") || rawCode.includes("too_many_tokens") || rawCode.includes("max_tokens")) {
10425
+ return "context_too_long";
10426
+ }
10427
+ if (rawCode.includes("content_filter") || rawCode.includes("content_policy") || rawCode.includes("safety")) {
10428
+ return "content_filtered";
10429
+ }
10430
+ if (rawCode.includes("model_not_found") || rawCode.includes("model_unavailable") || rawCode.includes("invalid_model")) {
10431
+ return "model_unavailable";
10432
+ }
10433
+ if (status === 402 || rawCode.includes("insufficient_quota") || rawCode.includes("quota_exceeded")) {
10434
+ return "invalid_request";
10435
+ }
10436
+ if (status === 401 || status === 403) return "auth_failed";
10437
+ if (status === 429) return "rate_limit";
10438
+ if (status === 408) return "timeout";
10439
+ if (status === 400) return "invalid_request";
10440
+ if (status >= 500 && status < 600) return "server_error";
10441
+ return "unknown";
10442
+ }
10443
+ function formatMessage2(providerId, status, code) {
10444
+ return `${providerId} API error: ${code} (HTTP ${status})`;
10445
+ }
10446
+ var ENV_GATE_KEY = "NODE_ENV";
10447
+ var ENV_GATE_VALUE = "test";
10448
+ var ENV_OVERRIDE_KEY = "THEOKIT_TEST_RESPONSE_OVERRIDE";
10449
+ function maybeWrapWithFaultInjection(client) {
10450
+ if (!isGateOn()) return client;
10451
+ return new FaultInjectingLlmClient(client);
10452
+ }
10453
+ var FaultInjectingLlmClient = class {
10454
+ name;
10455
+ /**
10456
+ * Inner (real) client. Exposed so layered transport assertions (router
10457
+ * pool-wiring tests, telemetry inspectors) can walk one level deep —
10458
+ * same pattern PoolAwareLlmClient uses for its inner transport.
10459
+ */
10460
+ inner;
10461
+ constructor(inner) {
10462
+ this.inner = inner;
10463
+ this.name = inner.name;
10464
+ }
10465
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: explicit gate → parse → branch is clearer than splitting
10466
+ async *stream(request, signal) {
10467
+ if (!isGateOn()) {
10468
+ return yield* this.inner.stream(request, signal);
10469
+ }
10470
+ const parsed = parseOverrideOrWarnOnce();
10471
+ if (parsed === void 0) {
10472
+ return yield* this.inner.stream(request, signal);
10473
+ }
10474
+ if (parsed.status >= 400) {
10475
+ throw mapOpenAICompatibleError({
10476
+ providerId: this.name,
10477
+ status: parsed.status,
10478
+ body: parsed.body,
10479
+ headers: void 0,
10480
+ endpoint: "/v1/chat/completions"
10481
+ });
10482
+ }
10483
+ const text = extractText(parsed.body);
10484
+ yield { type: "text_delta", text };
10485
+ yield { type: "stop", reason: "end_turn" };
10486
+ return {
10487
+ stopReason: "end_turn",
10488
+ text,
10489
+ toolCalls: [],
10490
+ inputTokens: 0,
10491
+ outputTokens: 0
10492
+ };
10493
+ }
10494
+ };
10495
+ function isGateOn() {
10496
+ return process.env[ENV_GATE_KEY] === ENV_GATE_VALUE;
10497
+ }
10498
+ var warnedInvalidJson = false;
10499
+ function parseOverrideOrWarnOnce() {
10500
+ const raw = process.env[ENV_OVERRIDE_KEY];
10501
+ if (raw === void 0 || raw.length === 0) return void 0;
10502
+ let candidate;
10503
+ try {
10504
+ candidate = JSON.parse(raw);
10505
+ } catch (_err) {
10506
+ warnInvalidJsonOnce();
10507
+ return void 0;
10508
+ }
10509
+ if (candidate === null || typeof candidate !== "object") {
10510
+ warnInvalidJsonOnce();
10511
+ return void 0;
10512
+ }
10513
+ const obj = candidate;
10514
+ if (typeof obj.status !== "number" || !Number.isFinite(obj.status)) {
10515
+ warnInvalidJsonOnce();
10516
+ return void 0;
10517
+ }
10518
+ return { status: obj.status, body: obj.body };
10519
+ }
10520
+ function warnInvalidJsonOnce(_raw) {
10521
+ if (warnedInvalidJson) return;
10522
+ warnedInvalidJson = true;
10523
+ process.stderr.write(
10524
+ `[theokit-sdk] ${ENV_OVERRIDE_KEY} is set but value is not valid JSON of shape \`{"status": number, "body": object | string}\`. Falling back to real LLM call. This warning is shown once per process.
10525
+ `
10526
+ );
10527
+ }
10528
+ function extractText(body) {
10529
+ if (typeof body === "string") return body;
10530
+ if (body === null || typeof body !== "object") return "";
10531
+ const fromOpenAi = readOpenAiContent(body);
10532
+ if (fromOpenAi !== void 0) return fromOpenAi;
10533
+ const obj = body;
10534
+ if (typeof obj.text === "string") return obj.text;
10535
+ return "";
10536
+ }
10537
+ function readOpenAiContent(body) {
10538
+ const obj = body;
10539
+ if (!Array.isArray(obj.choices) || obj.choices.length === 0) return void 0;
10540
+ const first = obj.choices[0];
10541
+ const content = first?.message?.content;
10542
+ if (typeof content === "string") return content;
10543
+ return void 0;
10544
+ }
10545
+ init_errors();
10319
10546
  function mapOllamaTransportError(args) {
10320
10547
  if (args.providerId !== "ollama") return void 0;
10321
10548
  const causeCode = extractCauseCode(args.cause);
@@ -10614,68 +10841,6 @@ function toOllamaTools(tools) {
10614
10841
  }
10615
10842
  }));
10616
10843
  }
10617
- init_errors();
10618
- function mapOpenAICompatibleError(args) {
10619
- const { providerId, status, body, headers, endpoint } = args;
10620
- const code = mapOpenAiStatusToCode(status, body);
10621
- const message = formatMessage2(providerId, status, code);
10622
- const metadata = buildErrorMetadata({
10623
- provider: providerId,
10624
- endpoint,
10625
- code,
10626
- status,
10627
- headers,
10628
- body
10629
- });
10630
- if (status === 401 || status === 403) {
10631
- return new AuthenticationError(message, { code: `${providerId}_auth_failed`, metadata });
10632
- }
10633
- if (status === 429) {
10634
- return new RateLimitError(message, { code: `${providerId}_rate_limit`, metadata });
10635
- }
10636
- if (status === 400) {
10637
- return new ConfigurationError(message, { code: `${providerId}_${code}`, metadata });
10638
- }
10639
- if (status === 408) {
10640
- return new NetworkError(message, { code: `${providerId}_timeout`, metadata });
10641
- }
10642
- if (status >= 500 && status < 600) {
10643
- return new NetworkError(message, { code: `${providerId}_server_error`, metadata });
10644
- }
10645
- return new UnknownAgentError(message, { code: `${providerId}_unknown`, metadata });
10646
- }
10647
- function extractOpenAiErrorCode(body) {
10648
- if (body === null || typeof body !== "object") return void 0;
10649
- const err = body.error;
10650
- if (err === void 0 || err === null) return void 0;
10651
- if (typeof err.code === "string") return err.code;
10652
- if (typeof err.type === "string") return err.type;
10653
- return void 0;
10654
- }
10655
- function mapOpenAiStatusToCode(status, body) {
10656
- const rawCode = extractOpenAiErrorCode(body)?.toLowerCase() ?? "";
10657
- if (rawCode.includes("context_length") || rawCode.includes("context_window") || rawCode.includes("too_many_tokens") || rawCode.includes("max_tokens")) {
10658
- return "context_too_long";
10659
- }
10660
- if (rawCode.includes("content_filter") || rawCode.includes("content_policy") || rawCode.includes("safety")) {
10661
- return "content_filtered";
10662
- }
10663
- if (rawCode.includes("model_not_found") || rawCode.includes("model_unavailable") || rawCode.includes("invalid_model")) {
10664
- return "model_unavailable";
10665
- }
10666
- if (status === 402 || rawCode.includes("insufficient_quota") || rawCode.includes("quota_exceeded")) {
10667
- return "invalid_request";
10668
- }
10669
- if (status === 401 || status === 403) return "auth_failed";
10670
- if (status === 429) return "rate_limit";
10671
- if (status === 408) return "timeout";
10672
- if (status === 400) return "invalid_request";
10673
- if (status >= 500 && status < 600) return "server_error";
10674
- return "unknown";
10675
- }
10676
- function formatMessage2(providerId, status, code) {
10677
- return `${providerId} API error: ${code} (HTTP ${status})`;
10678
- }
10679
10844
  var OpenAIClient = class {
10680
10845
  constructor(options) {
10681
10846
  this.options = options;
@@ -11217,7 +11382,7 @@ function buildChain(options) {
11217
11382
  if (seen.has(lowered)) return;
11218
11383
  seen.add(lowered);
11219
11384
  const client = buildClient(lowered, options);
11220
- if (client !== void 0) clients.push(client);
11385
+ if (client !== void 0) clients.push(maybeWrapWithFaultInjection(client));
11221
11386
  };
11222
11387
  addClient(options.primary);
11223
11388
  for (const fallback of options.fallback ?? []) addClient(fallback);
@@ -11988,6 +12153,13 @@ var RealLocalRun = class extends FixtureRunBase {
11988
12153
  if (output.result.length > 0) this.script.result = output.result;
11989
12154
  if (output.usage !== void 0) this.script.usage = output.usage;
11990
12155
  if (output.cost !== void 0) this.script.cost = output.cost;
12156
+ if (output.error !== void 0 && this.script.errorDetail === void 0) {
12157
+ this.script.errorDetail = {
12158
+ message: output.error.message,
12159
+ ...output.error.code !== void 0 ? { code: output.error.code } : {},
12160
+ cause: output.error.cause
12161
+ };
12162
+ }
11991
12163
  this.transitionTo(output.finalStatus);
11992
12164
  } catch (cause) {
11993
12165
  this.emitErrorEvent(cause, "Agent loop failed", "", "agent_loop_failed");
@@ -11999,24 +12171,15 @@ var RealLocalRun = class extends FixtureRunBase {
11999
12171
  }
12000
12172
  }
12001
12173
  emitErrorEvent(cause, fallback, prefix = "", code) {
12002
- const message = cause instanceof Error ? cause.message : String(cause);
12003
- const display = prefix.length > 0 ? `${prefix}${message}` : message || fallback;
12004
12174
  if (this.script.errorDetail === void 0) {
12175
+ const message = cause instanceof Error ? cause.message : String(cause);
12176
+ const display = prefix.length > 0 ? `${prefix}${message}` : message || fallback;
12005
12177
  this.script.errorDetail = {
12006
12178
  message: display,
12007
12179
  ...code !== void 0 ? { code } : {},
12008
12180
  cause
12009
12181
  };
12010
12182
  }
12011
- this.script.events.push({
12012
- type: "assistant",
12013
- agent_id: this.agentId,
12014
- run_id: this.id,
12015
- message: {
12016
- role: "assistant",
12017
- content: [{ type: "text", text: display }]
12018
- }
12019
- });
12020
12183
  this.notifyNewEvents();
12021
12184
  }
12022
12185
  };
@@ -16679,6 +16842,7 @@ async function updateJobStatus(jobId, enabled) {
16679
16842
  }
16680
16843
  return updated;
16681
16844
  }
16845
+ init_to_json_schema();
16682
16846
  var cachedZ2;
16683
16847
  function requireZod2() {
16684
16848
  if (cachedZ2 !== void 0) return cachedZ2;
@@ -16695,10 +16859,8 @@ function requireZod2() {
16695
16859
  return cachedZ2;
16696
16860
  }
16697
16861
  function defineTool(spec) {
16698
- const z12 = requireZod2();
16699
- const inputSchema = z12.toJSONSchema(spec.inputSchema, {
16700
- unrepresentable: "any"
16701
- });
16862
+ requireZod2();
16863
+ const inputSchema = toJsonSchema(spec.inputSchema, { unrepresentable: "any" });
16702
16864
  return {
16703
16865
  name: spec.name,
16704
16866
  description: spec.description,
@@ -18634,4 +18796,4 @@ export {
18634
18796
  preflightCheck,
18635
18797
  toShareGptTrajectory
18636
18798
  };
18637
- //# sourceMappingURL=dist-UZV7J3YI.js.map
18799
+ //# sourceMappingURL=dist-Q5VBFWVL.js.map