@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/eval.js CHANGED
@@ -4362,7 +4362,8 @@ function applyExtraRunFields(base, script) {
4362
4362
  // src/internal/runtime/fixtures/fixture-run-base.ts
4363
4363
  function prepareRunContext(message) {
4364
4364
  const userText = typeof message === "string" ? message : message.text;
4365
- return { userText, id: generateRunId(), startTime: Date.now() };
4365
+ const userImages = typeof message === "string" ? void 0 : message.images;
4366
+ return { userText, userImages, id: generateRunId(), startTime: Date.now() };
4366
4367
  }
4367
4368
  var FixtureRunBase = class {
4368
4369
  id;
@@ -9483,6 +9484,18 @@ function buildAssistantTurn(text, toolCalls) {
9483
9484
  }
9484
9485
 
9485
9486
  // src/internal/agent-loop/loop-context-init.ts
9487
+ function buildUserContent(text, images) {
9488
+ const content = [{ type: "text", text }];
9489
+ for (const img of images ?? []) {
9490
+ if ("data" in img) {
9491
+ content.push({
9492
+ type: "image",
9493
+ source: { type: "base64", media_type: img.mimeType, data: img.data }
9494
+ });
9495
+ }
9496
+ }
9497
+ return content;
9498
+ }
9486
9499
  function buildAgentRef(inputs) {
9487
9500
  return {
9488
9501
  agentId: inputs.agentId,
@@ -9570,7 +9583,7 @@ async function initLoopContext(inputs) {
9570
9583
  conversation: [],
9571
9584
  messages: [
9572
9585
  ...priorMessages,
9573
- { role: "user", content: [{ type: "text", text: inputs.userMessage }] }
9586
+ { role: "user", content: buildUserContent(inputs.userMessage, inputs.userImages) }
9574
9587
  ],
9575
9588
  tools,
9576
9589
  finalText: "",
@@ -11591,6 +11604,9 @@ function toAnthropicWireMessage(message) {
11591
11604
  if (part.type === "tool_use") {
11592
11605
  return { type: "tool_use", id: part.id, name: part.name, input: part.input };
11593
11606
  }
11607
+ if (part.type === "image") {
11608
+ return { type: "image", source: part.source };
11609
+ }
11594
11610
  return {
11595
11611
  type: "tool_result",
11596
11612
  tool_use_id: part.toolUseId,
@@ -12892,7 +12908,20 @@ function userOrToolMessages(message) {
12892
12908
  }
12893
12909
  }
12894
12910
  const userText = joinTextParts2(message);
12895
- if (userText.length > 0) out.push({ role: "user", content: userText });
12911
+ const imageParts = message.content.filter((p) => p.type === "image");
12912
+ if (imageParts.length > 0) {
12913
+ const content = [];
12914
+ if (userText.length > 0) content.push({ type: "text", text: userText });
12915
+ for (const img of imageParts) {
12916
+ content.push({
12917
+ type: "image_url",
12918
+ image_url: { url: `data:${img.source.media_type};base64,${img.source.data}` }
12919
+ });
12920
+ }
12921
+ out.push({ role: "user", content });
12922
+ } else if (userText.length > 0) {
12923
+ out.push({ role: "user", content: userText });
12924
+ }
12896
12925
  return out;
12897
12926
  }
12898
12927
  function assistantMessage(message) {
@@ -14078,7 +14107,7 @@ function buildCustomToolsInput(agentOptions, sendOptions, pluginManager, persona
14078
14107
 
14079
14108
  // src/internal/local-agent/real-local-run.ts
14080
14109
  function createRealLocalRun(options) {
14081
- const { userText, id, startTime } = prepareRunContext(options.message);
14110
+ const { userText, userImages, id, startTime } = prepareRunContext(options.message);
14082
14111
  const supported = /* @__PURE__ */ new Set(["stream", "wait", "cancel", "conversation"]);
14083
14112
  const runScript = {
14084
14113
  events: [],
@@ -14097,7 +14126,7 @@ function createRealLocalRun(options) {
14097
14126
  supportedOps: supported,
14098
14127
  startTime
14099
14128
  },
14100
- () => buildLoopInputs(options, id, userText)
14129
+ () => buildLoopInputs(options, id, userText, userImages)
14101
14130
  );
14102
14131
  handle.bootstrap();
14103
14132
  registerRun(handle);
@@ -14130,7 +14159,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
14130
14159
  if (existing !== void 0 && existing.length > 0) return pools;
14131
14160
  return { ...pools ?? {}, [primary]: [apiKey] };
14132
14161
  }
14133
- function buildLoopInputs(options, runId, userText) {
14162
+ function buildLoopInputs(options, runId, userText, userImages) {
14134
14163
  const maxIterations = options.sendOptions.maxIterations;
14135
14164
  if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
14136
14165
  throw new ConfigurationError(
@@ -14169,6 +14198,7 @@ function buildLoopInputs(options, runId, userText) {
14169
14198
  ...options.model?.params !== void 0 ? { params: options.model.params } : {}
14170
14199
  },
14171
14200
  userMessage: userText,
14201
+ ...userImages !== void 0 ? { userImages } : {},
14172
14202
  llm,
14173
14203
  mcp: buildMcpMap(options),
14174
14204
  hooks: options.hooks,