@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/index.cjs CHANGED
@@ -6127,7 +6127,9 @@ function serializeAgents(agents2) {
6127
6127
  out[name] = {
6128
6128
  description: def.description,
6129
6129
  prompt: def.prompt,
6130
- ...def.model !== void 0 ? { model: def.model } : {}
6130
+ ...def.model !== void 0 ? { model: def.model } : {},
6131
+ ...def.tools !== void 0 ? { tools: def.tools } : {},
6132
+ ...def.sandbox !== void 0 ? { sandbox: def.sandbox } : {}
6131
6133
  };
6132
6134
  }
6133
6135
  return out;
@@ -6984,7 +6986,8 @@ function applyExtraRunFields(base, script) {
6984
6986
  // src/internal/runtime/fixtures/fixture-run-base.ts
6985
6987
  function prepareRunContext(message) {
6986
6988
  const userText = typeof message === "string" ? message : message.text;
6987
- return { userText, id: generateRunId(), startTime: Date.now() };
6989
+ const userImages = typeof message === "string" ? void 0 : message.images;
6990
+ return { userText, userImages, id: generateRunId(), startTime: Date.now() };
6988
6991
  }
6989
6992
  var FixtureRunBase = class {
6990
6993
  id;
@@ -9335,9 +9338,9 @@ function rejectMcp(fields, filename) {
9335
9338
  function resolveModel(fields, filename) {
9336
9339
  const modelId = asString(fields.model);
9337
9340
  const effort = asString(fields.reasoning_effort);
9338
- if (effort !== void 0 && modelId === void 0) {
9341
+ if (effort !== void 0 && (modelId === void 0 || modelId === "inherit")) {
9339
9342
  throw new exports.ConfigurationError(
9340
- `Subagent ${filename}: reasoning_effort requires a model (effort is a model parameter)`,
9343
+ `Subagent ${filename}: reasoning_effort requires a concrete model (effort is a model parameter; an absent model or "inherit" cannot carry it)`,
9341
9344
  { code: "subagent_reasoning_effort_without_model" }
9342
9345
  );
9343
9346
  }
@@ -9356,7 +9359,9 @@ function resolveSandbox(fields, filename) {
9356
9359
  return fields.sandbox;
9357
9360
  }
9358
9361
  function asString(v) {
9359
- return typeof v === "string" ? v : void 0;
9362
+ if (typeof v !== "string") return void 0;
9363
+ const m = /^(["'])(.*)\1$/.exec(v);
9364
+ return m ? m[2] : v;
9360
9365
  }
9361
9366
  function toStringList(v) {
9362
9367
  if (Array.isArray(v)) return v.map((t) => t.trim()).filter((t) => t.length > 0);
@@ -12069,6 +12074,18 @@ function buildAssistantTurn(text, toolCalls) {
12069
12074
  }
12070
12075
 
12071
12076
  // src/internal/agent-loop/loop-context-init.ts
12077
+ function buildUserContent(text, images) {
12078
+ const content = [{ type: "text", text }];
12079
+ for (const img of images ?? []) {
12080
+ if ("data" in img) {
12081
+ content.push({
12082
+ type: "image",
12083
+ source: { type: "base64", media_type: img.mimeType, data: img.data }
12084
+ });
12085
+ }
12086
+ }
12087
+ return content;
12088
+ }
12072
12089
  function buildAgentRef(inputs) {
12073
12090
  return {
12074
12091
  agentId: inputs.agentId,
@@ -12156,7 +12173,7 @@ async function initLoopContext(inputs) {
12156
12173
  conversation: [],
12157
12174
  messages: [
12158
12175
  ...priorMessages,
12159
- { role: "user", content: [{ type: "text", text: inputs.userMessage }] }
12176
+ { role: "user", content: buildUserContent(inputs.userMessage, inputs.userImages) }
12160
12177
  ],
12161
12178
  tools,
12162
12179
  finalText: "",
@@ -14192,6 +14209,9 @@ function toAnthropicWireMessage(message) {
14192
14209
  if (part.type === "tool_use") {
14193
14210
  return { type: "tool_use", id: part.id, name: part.name, input: part.input };
14194
14211
  }
14212
+ if (part.type === "image") {
14213
+ return { type: "image", source: part.source };
14214
+ }
14195
14215
  return {
14196
14216
  type: "tool_result",
14197
14217
  tool_use_id: part.toolUseId,
@@ -15493,7 +15513,20 @@ function userOrToolMessages(message) {
15493
15513
  }
15494
15514
  }
15495
15515
  const userText = joinTextParts2(message);
15496
- if (userText.length > 0) out.push({ role: "user", content: userText });
15516
+ const imageParts = message.content.filter((p) => p.type === "image");
15517
+ if (imageParts.length > 0) {
15518
+ const content = [];
15519
+ if (userText.length > 0) content.push({ type: "text", text: userText });
15520
+ for (const img of imageParts) {
15521
+ content.push({
15522
+ type: "image_url",
15523
+ image_url: { url: `data:${img.source.media_type};base64,${img.source.data}` }
15524
+ });
15525
+ }
15526
+ out.push({ role: "user", content });
15527
+ } else if (userText.length > 0) {
15528
+ out.push({ role: "user", content: userText });
15529
+ }
15497
15530
  return out;
15498
15531
  }
15499
15532
  function assistantMessage(message) {
@@ -16464,10 +16497,11 @@ ${lines.join("\n")}
16464
16497
  }
16465
16498
  function buildChildCreateOptions(spec, inherited) {
16466
16499
  const model = spec.model !== void 0 ? typeof spec.model === "string" ? { id: spec.model } : spec.model : inherited?.model;
16500
+ const sandbox = spec.sandbox ?? inherited?.sandbox;
16467
16501
  return {
16468
16502
  ...inherited?.apiKey !== void 0 ? { apiKey: inherited.apiKey } : {},
16469
16503
  ...model !== void 0 ? { model } : {},
16470
- ...spec.sandbox === true ? { local: { sandboxOptions: { enabled: true } } } : {},
16504
+ ...sandbox !== void 0 ? { local: { sandboxOptions: { enabled: sandbox } } } : {},
16471
16505
  ...inherited?.plugins !== void 0 ? { plugins: inherited.plugins } : {},
16472
16506
  systemPrompt: spec.instructions,
16473
16507
  tools: spec.tools ?? []
@@ -16643,10 +16677,12 @@ function declarativeSubagentTools(agents2, parentTools) {
16643
16677
  }
16644
16678
  function bindParentCredentials(tools, agentOptions) {
16645
16679
  const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
16680
+ const parentSandbox = agentOptions.local?.sandboxOptions?.enabled;
16646
16681
  const credentials = {
16647
16682
  ...agentOptions.apiKey !== void 0 ? { apiKey: agentOptions.apiKey } : {},
16648
16683
  ...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {},
16649
- ...parentPlugins !== void 0 ? { plugins: parentPlugins } : {}
16684
+ ...parentPlugins !== void 0 ? { plugins: parentPlugins } : {},
16685
+ ...parentSandbox !== void 0 ? { sandbox: parentSandbox } : {}
16650
16686
  };
16651
16687
  for (const tool of tools) inheritSubAgentCredentials(tool, credentials);
16652
16688
  }
@@ -16677,7 +16713,7 @@ function buildCustomToolsInput(agentOptions, sendOptions, pluginManager, persona
16677
16713
 
16678
16714
  // src/internal/local-agent/real-local-run.ts
16679
16715
  function createRealLocalRun(options) {
16680
- const { userText, id, startTime } = prepareRunContext(options.message);
16716
+ const { userText, userImages, id, startTime } = prepareRunContext(options.message);
16681
16717
  const supported = /* @__PURE__ */ new Set(["stream", "wait", "cancel", "conversation"]);
16682
16718
  const runScript = {
16683
16719
  events: [],
@@ -16696,7 +16732,7 @@ function createRealLocalRun(options) {
16696
16732
  supportedOps: supported,
16697
16733
  startTime
16698
16734
  },
16699
- () => buildLoopInputs(options, id, userText)
16735
+ () => buildLoopInputs(options, id, userText, userImages)
16700
16736
  );
16701
16737
  handle.bootstrap();
16702
16738
  registerRun(handle);
@@ -16729,7 +16765,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
16729
16765
  if (existing !== void 0 && existing.length > 0) return pools;
16730
16766
  return { ...pools ?? {}, [primary]: [apiKey] };
16731
16767
  }
16732
- function buildLoopInputs(options, runId, userText) {
16768
+ function buildLoopInputs(options, runId, userText, userImages) {
16733
16769
  const maxIterations = options.sendOptions.maxIterations;
16734
16770
  if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
16735
16771
  throw new exports.ConfigurationError(
@@ -16768,6 +16804,7 @@ function buildLoopInputs(options, runId, userText) {
16768
16804
  ...options.model?.params !== void 0 ? { params: options.model.params } : {}
16769
16805
  },
16770
16806
  userMessage: userText,
16807
+ ...userImages !== void 0 ? { userImages } : {},
16771
16808
  llm,
16772
16809
  mcp: buildMcpMap(options),
16773
16810
  hooks: options.hooks,