@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.js CHANGED
@@ -6124,7 +6124,9 @@ function serializeAgents(agents2) {
6124
6124
  out[name] = {
6125
6125
  description: def.description,
6126
6126
  prompt: def.prompt,
6127
- ...def.model !== void 0 ? { model: def.model } : {}
6127
+ ...def.model !== void 0 ? { model: def.model } : {},
6128
+ ...def.tools !== void 0 ? { tools: def.tools } : {},
6129
+ ...def.sandbox !== void 0 ? { sandbox: def.sandbox } : {}
6128
6130
  };
6129
6131
  }
6130
6132
  return out;
@@ -6981,7 +6983,8 @@ function applyExtraRunFields(base, script) {
6981
6983
  // src/internal/runtime/fixtures/fixture-run-base.ts
6982
6984
  function prepareRunContext(message) {
6983
6985
  const userText = typeof message === "string" ? message : message.text;
6984
- return { userText, id: generateRunId(), startTime: Date.now() };
6986
+ const userImages = typeof message === "string" ? void 0 : message.images;
6987
+ return { userText, userImages, id: generateRunId(), startTime: Date.now() };
6985
6988
  }
6986
6989
  var FixtureRunBase = class {
6987
6990
  id;
@@ -9332,9 +9335,9 @@ function rejectMcp(fields, filename) {
9332
9335
  function resolveModel(fields, filename) {
9333
9336
  const modelId = asString(fields.model);
9334
9337
  const effort = asString(fields.reasoning_effort);
9335
- if (effort !== void 0 && modelId === void 0) {
9338
+ if (effort !== void 0 && (modelId === void 0 || modelId === "inherit")) {
9336
9339
  throw new ConfigurationError(
9337
- `Subagent ${filename}: reasoning_effort requires a model (effort is a model parameter)`,
9340
+ `Subagent ${filename}: reasoning_effort requires a concrete model (effort is a model parameter; an absent model or "inherit" cannot carry it)`,
9338
9341
  { code: "subagent_reasoning_effort_without_model" }
9339
9342
  );
9340
9343
  }
@@ -9353,7 +9356,9 @@ function resolveSandbox(fields, filename) {
9353
9356
  return fields.sandbox;
9354
9357
  }
9355
9358
  function asString(v) {
9356
- return typeof v === "string" ? v : void 0;
9359
+ if (typeof v !== "string") return void 0;
9360
+ const m = /^(["'])(.*)\1$/.exec(v);
9361
+ return m ? m[2] : v;
9357
9362
  }
9358
9363
  function toStringList(v) {
9359
9364
  if (Array.isArray(v)) return v.map((t) => t.trim()).filter((t) => t.length > 0);
@@ -12066,6 +12071,18 @@ function buildAssistantTurn(text, toolCalls) {
12066
12071
  }
12067
12072
 
12068
12073
  // src/internal/agent-loop/loop-context-init.ts
12074
+ function buildUserContent(text, images) {
12075
+ const content = [{ type: "text", text }];
12076
+ for (const img of images ?? []) {
12077
+ if ("data" in img) {
12078
+ content.push({
12079
+ type: "image",
12080
+ source: { type: "base64", media_type: img.mimeType, data: img.data }
12081
+ });
12082
+ }
12083
+ }
12084
+ return content;
12085
+ }
12069
12086
  function buildAgentRef(inputs) {
12070
12087
  return {
12071
12088
  agentId: inputs.agentId,
@@ -12153,7 +12170,7 @@ async function initLoopContext(inputs) {
12153
12170
  conversation: [],
12154
12171
  messages: [
12155
12172
  ...priorMessages,
12156
- { role: "user", content: [{ type: "text", text: inputs.userMessage }] }
12173
+ { role: "user", content: buildUserContent(inputs.userMessage, inputs.userImages) }
12157
12174
  ],
12158
12175
  tools,
12159
12176
  finalText: "",
@@ -14189,6 +14206,9 @@ function toAnthropicWireMessage(message) {
14189
14206
  if (part.type === "tool_use") {
14190
14207
  return { type: "tool_use", id: part.id, name: part.name, input: part.input };
14191
14208
  }
14209
+ if (part.type === "image") {
14210
+ return { type: "image", source: part.source };
14211
+ }
14192
14212
  return {
14193
14213
  type: "tool_result",
14194
14214
  tool_use_id: part.toolUseId,
@@ -15490,7 +15510,20 @@ function userOrToolMessages(message) {
15490
15510
  }
15491
15511
  }
15492
15512
  const userText = joinTextParts2(message);
15493
- if (userText.length > 0) out.push({ role: "user", content: userText });
15513
+ const imageParts = message.content.filter((p) => p.type === "image");
15514
+ if (imageParts.length > 0) {
15515
+ const content = [];
15516
+ if (userText.length > 0) content.push({ type: "text", text: userText });
15517
+ for (const img of imageParts) {
15518
+ content.push({
15519
+ type: "image_url",
15520
+ image_url: { url: `data:${img.source.media_type};base64,${img.source.data}` }
15521
+ });
15522
+ }
15523
+ out.push({ role: "user", content });
15524
+ } else if (userText.length > 0) {
15525
+ out.push({ role: "user", content: userText });
15526
+ }
15494
15527
  return out;
15495
15528
  }
15496
15529
  function assistantMessage(message) {
@@ -16461,10 +16494,11 @@ ${lines.join("\n")}
16461
16494
  }
16462
16495
  function buildChildCreateOptions(spec, inherited) {
16463
16496
  const model = spec.model !== void 0 ? typeof spec.model === "string" ? { id: spec.model } : spec.model : inherited?.model;
16497
+ const sandbox = spec.sandbox ?? inherited?.sandbox;
16464
16498
  return {
16465
16499
  ...inherited?.apiKey !== void 0 ? { apiKey: inherited.apiKey } : {},
16466
16500
  ...model !== void 0 ? { model } : {},
16467
- ...spec.sandbox === true ? { local: { sandboxOptions: { enabled: true } } } : {},
16501
+ ...sandbox !== void 0 ? { local: { sandboxOptions: { enabled: sandbox } } } : {},
16468
16502
  ...inherited?.plugins !== void 0 ? { plugins: inherited.plugins } : {},
16469
16503
  systemPrompt: spec.instructions,
16470
16504
  tools: spec.tools ?? []
@@ -16640,10 +16674,12 @@ function declarativeSubagentTools(agents2, parentTools) {
16640
16674
  }
16641
16675
  function bindParentCredentials(tools, agentOptions) {
16642
16676
  const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
16677
+ const parentSandbox = agentOptions.local?.sandboxOptions?.enabled;
16643
16678
  const credentials = {
16644
16679
  ...agentOptions.apiKey !== void 0 ? { apiKey: agentOptions.apiKey } : {},
16645
16680
  ...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {},
16646
- ...parentPlugins !== void 0 ? { plugins: parentPlugins } : {}
16681
+ ...parentPlugins !== void 0 ? { plugins: parentPlugins } : {},
16682
+ ...parentSandbox !== void 0 ? { sandbox: parentSandbox } : {}
16647
16683
  };
16648
16684
  for (const tool of tools) inheritSubAgentCredentials(tool, credentials);
16649
16685
  }
@@ -16674,7 +16710,7 @@ function buildCustomToolsInput(agentOptions, sendOptions, pluginManager, persona
16674
16710
 
16675
16711
  // src/internal/local-agent/real-local-run.ts
16676
16712
  function createRealLocalRun(options) {
16677
- const { userText, id, startTime } = prepareRunContext(options.message);
16713
+ const { userText, userImages, id, startTime } = prepareRunContext(options.message);
16678
16714
  const supported = /* @__PURE__ */ new Set(["stream", "wait", "cancel", "conversation"]);
16679
16715
  const runScript = {
16680
16716
  events: [],
@@ -16693,7 +16729,7 @@ function createRealLocalRun(options) {
16693
16729
  supportedOps: supported,
16694
16730
  startTime
16695
16731
  },
16696
- () => buildLoopInputs(options, id, userText)
16732
+ () => buildLoopInputs(options, id, userText, userImages)
16697
16733
  );
16698
16734
  handle.bootstrap();
16699
16735
  registerRun(handle);
@@ -16726,7 +16762,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
16726
16762
  if (existing !== void 0 && existing.length > 0) return pools;
16727
16763
  return { ...pools ?? {}, [primary]: [apiKey] };
16728
16764
  }
16729
- function buildLoopInputs(options, runId, userText) {
16765
+ function buildLoopInputs(options, runId, userText, userImages) {
16730
16766
  const maxIterations = options.sendOptions.maxIterations;
16731
16767
  if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
16732
16768
  throw new ConfigurationError(
@@ -16765,6 +16801,7 @@ function buildLoopInputs(options, runId, userText) {
16765
16801
  ...options.model?.params !== void 0 ? { params: options.model.params } : {}
16766
16802
  },
16767
16803
  userMessage: userText,
16804
+ ...userImages !== void 0 ? { userImages } : {},
16768
16805
  llm,
16769
16806
  mcp: buildMcpMap(options),
16770
16807
  hooks: options.hooks,