@theokit/sdk 4.6.1 → 4.7.1

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,15 @@ 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
+ content.push(
9491
+ "data" in img ? { type: "image", source: { type: "base64", media_type: img.mimeType, data: img.data } } : { type: "image", source: { type: "url", url: img.url } }
9492
+ );
9493
+ }
9494
+ return content;
9495
+ }
9486
9496
  function buildAgentRef(inputs) {
9487
9497
  return {
9488
9498
  agentId: inputs.agentId,
@@ -9570,7 +9580,7 @@ async function initLoopContext(inputs) {
9570
9580
  conversation: [],
9571
9581
  messages: [
9572
9582
  ...priorMessages,
9573
- { role: "user", content: [{ type: "text", text: inputs.userMessage }] }
9583
+ { role: "user", content: buildUserContent(inputs.userMessage, inputs.userImages) }
9574
9584
  ],
9575
9585
  tools,
9576
9586
  finalText: "",
@@ -11591,6 +11601,9 @@ function toAnthropicWireMessage(message) {
11591
11601
  if (part.type === "tool_use") {
11592
11602
  return { type: "tool_use", id: part.id, name: part.name, input: part.input };
11593
11603
  }
11604
+ if (part.type === "image") {
11605
+ return { type: "image", source: part.source };
11606
+ }
11594
11607
  return {
11595
11608
  type: "tool_result",
11596
11609
  tool_use_id: part.toolUseId,
@@ -12134,6 +12147,9 @@ function readOpenAiContent(body) {
12134
12147
  return void 0;
12135
12148
  }
12136
12149
 
12150
+ // src/internal/llm/ollama-native.ts
12151
+ init_errors();
12152
+
12137
12153
  // src/internal/error-mappers/ollama.ts
12138
12154
  init_errors();
12139
12155
  function mapOllamaTransportError(args) {
@@ -12401,6 +12417,12 @@ function toOllamaMessages(message) {
12401
12417
  return [{ role: "system", content: joinTextParts(message) }];
12402
12418
  }
12403
12419
  if (message.role === "user") {
12420
+ if (message.content.some((p) => p.type === "image")) {
12421
+ throw new ConfigurationError(
12422
+ "image input is not supported on the ollama-native provider; use an OpenAI/OpenRouter model for multimodal turns",
12423
+ { code: "ollama_image_unsupported" }
12424
+ );
12425
+ }
12404
12426
  const out = [];
12405
12427
  for (const part of message.content) {
12406
12428
  if (part.type === "tool_result") {
@@ -12892,7 +12914,20 @@ function userOrToolMessages(message) {
12892
12914
  }
12893
12915
  }
12894
12916
  const userText = joinTextParts2(message);
12895
- if (userText.length > 0) out.push({ role: "user", content: userText });
12917
+ const imageParts = message.content.filter(
12918
+ (p) => p.type === "image"
12919
+ );
12920
+ if (imageParts.length > 0) {
12921
+ const content = [];
12922
+ if (userText.length > 0) content.push({ type: "text", text: userText });
12923
+ for (const img of imageParts) {
12924
+ const url = img.source.type === "base64" ? `data:${img.source.media_type};base64,${img.source.data}` : img.source.url;
12925
+ content.push({ type: "image_url", image_url: { url } });
12926
+ }
12927
+ out.push({ role: "user", content });
12928
+ } else if (userText.length > 0) {
12929
+ out.push({ role: "user", content: userText });
12930
+ }
12896
12931
  return out;
12897
12932
  }
12898
12933
  function assistantMessage(message) {
@@ -14078,7 +14113,7 @@ function buildCustomToolsInput(agentOptions, sendOptions, pluginManager, persona
14078
14113
 
14079
14114
  // src/internal/local-agent/real-local-run.ts
14080
14115
  function createRealLocalRun(options) {
14081
- const { userText, id, startTime } = prepareRunContext(options.message);
14116
+ const { userText, userImages, id, startTime } = prepareRunContext(options.message);
14082
14117
  const supported = /* @__PURE__ */ new Set(["stream", "wait", "cancel", "conversation"]);
14083
14118
  const runScript = {
14084
14119
  events: [],
@@ -14097,7 +14132,7 @@ function createRealLocalRun(options) {
14097
14132
  supportedOps: supported,
14098
14133
  startTime
14099
14134
  },
14100
- () => buildLoopInputs(options, id, userText)
14135
+ () => buildLoopInputs(options, id, userText, userImages)
14101
14136
  );
14102
14137
  handle.bootstrap();
14103
14138
  registerRun(handle);
@@ -14130,7 +14165,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
14130
14165
  if (existing !== void 0 && existing.length > 0) return pools;
14131
14166
  return { ...pools ?? {}, [primary]: [apiKey] };
14132
14167
  }
14133
- function buildLoopInputs(options, runId, userText) {
14168
+ function buildLoopInputs(options, runId, userText, userImages) {
14134
14169
  const maxIterations = options.sendOptions.maxIterations;
14135
14170
  if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
14136
14171
  throw new ConfigurationError(
@@ -14169,6 +14204,7 @@ function buildLoopInputs(options, runId, userText) {
14169
14204
  ...options.model?.params !== void 0 ? { params: options.model.params } : {}
14170
14205
  },
14171
14206
  userMessage: userText,
14207
+ ...userImages !== void 0 ? { userImages } : {},
14172
14208
  llm,
14173
14209
  mcp: buildMcpMap(options),
14174
14210
  hooks: options.hooks,