@theokit/sdk 4.6.0 → 4.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/dist/cron.js CHANGED
@@ -3274,7 +3274,9 @@ function serializeAgents(agents2) {
3274
3274
  out[name] = {
3275
3275
  description: def.description,
3276
3276
  prompt: def.prompt,
3277
- ...def.model !== void 0 ? { model: def.model } : {}
3277
+ ...def.model !== void 0 ? { model: def.model } : {},
3278
+ ...def.tools !== void 0 ? { tools: def.tools } : {},
3279
+ ...def.sandbox !== void 0 ? { sandbox: def.sandbox } : {}
3278
3280
  };
3279
3281
  }
3280
3282
  return out;
@@ -4365,7 +4367,8 @@ function applyExtraRunFields(base, script) {
4365
4367
  // src/internal/runtime/fixtures/fixture-run-base.ts
4366
4368
  function prepareRunContext(message) {
4367
4369
  const userText = typeof message === "string" ? message : message.text;
4368
- return { userText, id: generateRunId(), startTime: Date.now() };
4370
+ const userImages = typeof message === "string" ? void 0 : message.images;
4371
+ return { userText, userImages, id: generateRunId(), startTime: Date.now() };
4369
4372
  }
4370
4373
  var FixtureRunBase = class {
4371
4374
  id;
@@ -6755,9 +6758,9 @@ function rejectMcp(fields, filename) {
6755
6758
  function resolveModel(fields, filename) {
6756
6759
  const modelId = asString(fields.model);
6757
6760
  const effort = asString(fields.reasoning_effort);
6758
- if (effort !== void 0 && modelId === void 0) {
6761
+ if (effort !== void 0 && (modelId === void 0 || modelId === "inherit")) {
6759
6762
  throw new ConfigurationError(
6760
- `Subagent ${filename}: reasoning_effort requires a model (effort is a model parameter)`,
6763
+ `Subagent ${filename}: reasoning_effort requires a concrete model (effort is a model parameter; an absent model or "inherit" cannot carry it)`,
6761
6764
  { code: "subagent_reasoning_effort_without_model" }
6762
6765
  );
6763
6766
  }
@@ -6776,7 +6779,9 @@ function resolveSandbox(fields, filename) {
6776
6779
  return fields.sandbox;
6777
6780
  }
6778
6781
  function asString(v) {
6779
- return typeof v === "string" ? v : void 0;
6782
+ if (typeof v !== "string") return void 0;
6783
+ const m = /^(["'])(.*)\1$/.exec(v);
6784
+ return m ? m[2] : v;
6780
6785
  }
6781
6786
  function toStringList(v) {
6782
6787
  if (Array.isArray(v)) return v.map((t) => t.trim()).filter((t) => t.length > 0);
@@ -9484,6 +9489,18 @@ function buildAssistantTurn(text, toolCalls) {
9484
9489
  }
9485
9490
 
9486
9491
  // src/internal/agent-loop/loop-context-init.ts
9492
+ function buildUserContent(text, images) {
9493
+ const content = [{ type: "text", text }];
9494
+ for (const img of images ?? []) {
9495
+ if ("data" in img) {
9496
+ content.push({
9497
+ type: "image",
9498
+ source: { type: "base64", media_type: img.mimeType, data: img.data }
9499
+ });
9500
+ }
9501
+ }
9502
+ return content;
9503
+ }
9487
9504
  function buildAgentRef(inputs) {
9488
9505
  return {
9489
9506
  agentId: inputs.agentId,
@@ -9571,7 +9588,7 @@ async function initLoopContext(inputs) {
9571
9588
  conversation: [],
9572
9589
  messages: [
9573
9590
  ...priorMessages,
9574
- { role: "user", content: [{ type: "text", text: inputs.userMessage }] }
9591
+ { role: "user", content: buildUserContent(inputs.userMessage, inputs.userImages) }
9575
9592
  ],
9576
9593
  tools,
9577
9594
  finalText: "",
@@ -11592,6 +11609,9 @@ function toAnthropicWireMessage(message) {
11592
11609
  if (part.type === "tool_use") {
11593
11610
  return { type: "tool_use", id: part.id, name: part.name, input: part.input };
11594
11611
  }
11612
+ if (part.type === "image") {
11613
+ return { type: "image", source: part.source };
11614
+ }
11595
11615
  return {
11596
11616
  type: "tool_result",
11597
11617
  tool_use_id: part.toolUseId,
@@ -12893,7 +12913,20 @@ function userOrToolMessages(message) {
12893
12913
  }
12894
12914
  }
12895
12915
  const userText = joinTextParts2(message);
12896
- if (userText.length > 0) out.push({ role: "user", content: userText });
12916
+ const imageParts = message.content.filter((p) => p.type === "image");
12917
+ if (imageParts.length > 0) {
12918
+ const content = [];
12919
+ if (userText.length > 0) content.push({ type: "text", text: userText });
12920
+ for (const img of imageParts) {
12921
+ content.push({
12922
+ type: "image_url",
12923
+ image_url: { url: `data:${img.source.media_type};base64,${img.source.data}` }
12924
+ });
12925
+ }
12926
+ out.push({ role: "user", content });
12927
+ } else if (userText.length > 0) {
12928
+ out.push({ role: "user", content: userText });
12929
+ }
12897
12930
  return out;
12898
12931
  }
12899
12932
  function assistantMessage(message) {
@@ -13863,10 +13896,11 @@ ${lines.join("\n")}
13863
13896
  }
13864
13897
  function buildChildCreateOptions(spec, inherited) {
13865
13898
  const model = spec.model !== void 0 ? typeof spec.model === "string" ? { id: spec.model } : spec.model : inherited?.model;
13899
+ const sandbox = spec.sandbox ?? inherited?.sandbox;
13866
13900
  return {
13867
13901
  ...inherited?.apiKey !== void 0 ? { apiKey: inherited.apiKey } : {},
13868
13902
  ...model !== void 0 ? { model } : {},
13869
- ...spec.sandbox === true ? { local: { sandboxOptions: { enabled: true } } } : {},
13903
+ ...sandbox !== void 0 ? { local: { sandboxOptions: { enabled: sandbox } } } : {},
13870
13904
  ...inherited?.plugins !== void 0 ? { plugins: inherited.plugins } : {},
13871
13905
  systemPrompt: spec.instructions,
13872
13906
  tools: spec.tools ?? []
@@ -14042,10 +14076,12 @@ function declarativeSubagentTools(agents2, parentTools) {
14042
14076
  }
14043
14077
  function bindParentCredentials(tools, agentOptions) {
14044
14078
  const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
14079
+ const parentSandbox = agentOptions.local?.sandboxOptions?.enabled;
14045
14080
  const credentials = {
14046
14081
  ...agentOptions.apiKey !== void 0 ? { apiKey: agentOptions.apiKey } : {},
14047
14082
  ...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {},
14048
- ...parentPlugins !== void 0 ? { plugins: parentPlugins } : {}
14083
+ ...parentPlugins !== void 0 ? { plugins: parentPlugins } : {},
14084
+ ...parentSandbox !== void 0 ? { sandbox: parentSandbox } : {}
14049
14085
  };
14050
14086
  for (const tool of tools) inheritSubAgentCredentials(tool, credentials);
14051
14087
  }
@@ -14076,7 +14112,7 @@ function buildCustomToolsInput(agentOptions, sendOptions, pluginManager, persona
14076
14112
 
14077
14113
  // src/internal/local-agent/real-local-run.ts
14078
14114
  function createRealLocalRun(options) {
14079
- const { userText, id, startTime } = prepareRunContext(options.message);
14115
+ const { userText, userImages, id, startTime } = prepareRunContext(options.message);
14080
14116
  const supported = /* @__PURE__ */ new Set(["stream", "wait", "cancel", "conversation"]);
14081
14117
  const runScript = {
14082
14118
  events: [],
@@ -14095,7 +14131,7 @@ function createRealLocalRun(options) {
14095
14131
  supportedOps: supported,
14096
14132
  startTime
14097
14133
  },
14098
- () => buildLoopInputs(options, id, userText)
14134
+ () => buildLoopInputs(options, id, userText, userImages)
14099
14135
  );
14100
14136
  handle.bootstrap();
14101
14137
  registerRun(handle);
@@ -14128,7 +14164,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
14128
14164
  if (existing !== void 0 && existing.length > 0) return pools;
14129
14165
  return { ...pools ?? {}, [primary]: [apiKey] };
14130
14166
  }
14131
- function buildLoopInputs(options, runId, userText) {
14167
+ function buildLoopInputs(options, runId, userText, userImages) {
14132
14168
  const maxIterations = options.sendOptions.maxIterations;
14133
14169
  if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
14134
14170
  throw new ConfigurationError(
@@ -14167,6 +14203,7 @@ function buildLoopInputs(options, runId, userText) {
14167
14203
  ...options.model?.params !== void 0 ? { params: options.model.params } : {}
14168
14204
  },
14169
14205
  userMessage: userText,
14206
+ ...userImages !== void 0 ? { userImages } : {},
14170
14207
  llm,
14171
14208
  mcp: buildMcpMap(options),
14172
14209
  hooks: options.hooks,