@theokit/sdk 4.6.1 → 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
@@ -4367,7 +4367,8 @@ function applyExtraRunFields(base, script) {
4367
4367
  // src/internal/runtime/fixtures/fixture-run-base.ts
4368
4368
  function prepareRunContext(message) {
4369
4369
  const userText = typeof message === "string" ? message : message.text;
4370
- 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() };
4371
4372
  }
4372
4373
  var FixtureRunBase = class {
4373
4374
  id;
@@ -9488,6 +9489,18 @@ function buildAssistantTurn(text, toolCalls) {
9488
9489
  }
9489
9490
 
9490
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
+ }
9491
9504
  function buildAgentRef(inputs) {
9492
9505
  return {
9493
9506
  agentId: inputs.agentId,
@@ -9575,7 +9588,7 @@ async function initLoopContext(inputs) {
9575
9588
  conversation: [],
9576
9589
  messages: [
9577
9590
  ...priorMessages,
9578
- { role: "user", content: [{ type: "text", text: inputs.userMessage }] }
9591
+ { role: "user", content: buildUserContent(inputs.userMessage, inputs.userImages) }
9579
9592
  ],
9580
9593
  tools,
9581
9594
  finalText: "",
@@ -11596,6 +11609,9 @@ function toAnthropicWireMessage(message) {
11596
11609
  if (part.type === "tool_use") {
11597
11610
  return { type: "tool_use", id: part.id, name: part.name, input: part.input };
11598
11611
  }
11612
+ if (part.type === "image") {
11613
+ return { type: "image", source: part.source };
11614
+ }
11599
11615
  return {
11600
11616
  type: "tool_result",
11601
11617
  tool_use_id: part.toolUseId,
@@ -12897,7 +12913,20 @@ function userOrToolMessages(message) {
12897
12913
  }
12898
12914
  }
12899
12915
  const userText = joinTextParts2(message);
12900
- 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
+ }
12901
12930
  return out;
12902
12931
  }
12903
12932
  function assistantMessage(message) {
@@ -14083,7 +14112,7 @@ function buildCustomToolsInput(agentOptions, sendOptions, pluginManager, persona
14083
14112
 
14084
14113
  // src/internal/local-agent/real-local-run.ts
14085
14114
  function createRealLocalRun(options) {
14086
- const { userText, id, startTime } = prepareRunContext(options.message);
14115
+ const { userText, userImages, id, startTime } = prepareRunContext(options.message);
14087
14116
  const supported = /* @__PURE__ */ new Set(["stream", "wait", "cancel", "conversation"]);
14088
14117
  const runScript = {
14089
14118
  events: [],
@@ -14102,7 +14131,7 @@ function createRealLocalRun(options) {
14102
14131
  supportedOps: supported,
14103
14132
  startTime
14104
14133
  },
14105
- () => buildLoopInputs(options, id, userText)
14134
+ () => buildLoopInputs(options, id, userText, userImages)
14106
14135
  );
14107
14136
  handle.bootstrap();
14108
14137
  registerRun(handle);
@@ -14135,7 +14164,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
14135
14164
  if (existing !== void 0 && existing.length > 0) return pools;
14136
14165
  return { ...pools ?? {}, [primary]: [apiKey] };
14137
14166
  }
14138
- function buildLoopInputs(options, runId, userText) {
14167
+ function buildLoopInputs(options, runId, userText, userImages) {
14139
14168
  const maxIterations = options.sendOptions.maxIterations;
14140
14169
  if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
14141
14170
  throw new ConfigurationError(
@@ -14174,6 +14203,7 @@ function buildLoopInputs(options, runId, userText) {
14174
14203
  ...options.model?.params !== void 0 ? { params: options.model.params } : {}
14175
14204
  },
14176
14205
  userMessage: userText,
14206
+ ...userImages !== void 0 ? { userImages } : {},
14177
14207
  llm,
14178
14208
  mcp: buildMcpMap(options),
14179
14209
  hooks: options.hooks,