@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.cjs CHANGED
@@ -4365,7 +4365,8 @@ function applyExtraRunFields(base, script) {
4365
4365
  // src/internal/runtime/fixtures/fixture-run-base.ts
4366
4366
  function prepareRunContext(message) {
4367
4367
  const userText = typeof message === "string" ? message : message.text;
4368
- return { userText, id: generateRunId(), startTime: Date.now() };
4368
+ const userImages = typeof message === "string" ? void 0 : message.images;
4369
+ return { userText, userImages, id: generateRunId(), startTime: Date.now() };
4369
4370
  }
4370
4371
  var FixtureRunBase = class {
4371
4372
  id;
@@ -9486,6 +9487,18 @@ function buildAssistantTurn(text, toolCalls) {
9486
9487
  }
9487
9488
 
9488
9489
  // src/internal/agent-loop/loop-context-init.ts
9490
+ function buildUserContent(text, images) {
9491
+ const content = [{ type: "text", text }];
9492
+ for (const img of images ?? []) {
9493
+ if ("data" in img) {
9494
+ content.push({
9495
+ type: "image",
9496
+ source: { type: "base64", media_type: img.mimeType, data: img.data }
9497
+ });
9498
+ }
9499
+ }
9500
+ return content;
9501
+ }
9489
9502
  function buildAgentRef(inputs) {
9490
9503
  return {
9491
9504
  agentId: inputs.agentId,
@@ -9573,7 +9586,7 @@ async function initLoopContext(inputs) {
9573
9586
  conversation: [],
9574
9587
  messages: [
9575
9588
  ...priorMessages,
9576
- { role: "user", content: [{ type: "text", text: inputs.userMessage }] }
9589
+ { role: "user", content: buildUserContent(inputs.userMessage, inputs.userImages) }
9577
9590
  ],
9578
9591
  tools,
9579
9592
  finalText: "",
@@ -11594,6 +11607,9 @@ function toAnthropicWireMessage(message) {
11594
11607
  if (part.type === "tool_use") {
11595
11608
  return { type: "tool_use", id: part.id, name: part.name, input: part.input };
11596
11609
  }
11610
+ if (part.type === "image") {
11611
+ return { type: "image", source: part.source };
11612
+ }
11597
11613
  return {
11598
11614
  type: "tool_result",
11599
11615
  tool_use_id: part.toolUseId,
@@ -12895,7 +12911,20 @@ function userOrToolMessages(message) {
12895
12911
  }
12896
12912
  }
12897
12913
  const userText = joinTextParts2(message);
12898
- if (userText.length > 0) out.push({ role: "user", content: userText });
12914
+ const imageParts = message.content.filter((p) => p.type === "image");
12915
+ if (imageParts.length > 0) {
12916
+ const content = [];
12917
+ if (userText.length > 0) content.push({ type: "text", text: userText });
12918
+ for (const img of imageParts) {
12919
+ content.push({
12920
+ type: "image_url",
12921
+ image_url: { url: `data:${img.source.media_type};base64,${img.source.data}` }
12922
+ });
12923
+ }
12924
+ out.push({ role: "user", content });
12925
+ } else if (userText.length > 0) {
12926
+ out.push({ role: "user", content: userText });
12927
+ }
12899
12928
  return out;
12900
12929
  }
12901
12930
  function assistantMessage(message) {
@@ -14081,7 +14110,7 @@ function buildCustomToolsInput(agentOptions, sendOptions, pluginManager, persona
14081
14110
 
14082
14111
  // src/internal/local-agent/real-local-run.ts
14083
14112
  function createRealLocalRun(options) {
14084
- const { userText, id, startTime } = prepareRunContext(options.message);
14113
+ const { userText, userImages, id, startTime } = prepareRunContext(options.message);
14085
14114
  const supported = /* @__PURE__ */ new Set(["stream", "wait", "cancel", "conversation"]);
14086
14115
  const runScript = {
14087
14116
  events: [],
@@ -14100,7 +14129,7 @@ function createRealLocalRun(options) {
14100
14129
  supportedOps: supported,
14101
14130
  startTime
14102
14131
  },
14103
- () => buildLoopInputs(options, id, userText)
14132
+ () => buildLoopInputs(options, id, userText, userImages)
14104
14133
  );
14105
14134
  handle.bootstrap();
14106
14135
  registerRun(handle);
@@ -14133,7 +14162,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
14133
14162
  if (existing !== void 0 && existing.length > 0) return pools;
14134
14163
  return { ...pools ?? {}, [primary]: [apiKey] };
14135
14164
  }
14136
- function buildLoopInputs(options, runId, userText) {
14165
+ function buildLoopInputs(options, runId, userText, userImages) {
14137
14166
  const maxIterations = options.sendOptions.maxIterations;
14138
14167
  if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
14139
14168
  throw new ConfigurationError(
@@ -14172,6 +14201,7 @@ function buildLoopInputs(options, runId, userText) {
14172
14201
  ...options.model?.params !== void 0 ? { params: options.model.params } : {}
14173
14202
  },
14174
14203
  userMessage: userText,
14204
+ ...userImages !== void 0 ? { userImages } : {},
14175
14205
  llm,
14176
14206
  mcp: buildMcpMap(options),
14177
14207
  hooks: options.hooks,