@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.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,15 @@ 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
+ content.push(
9494
+ "data" in img ? { type: "image", source: { type: "base64", media_type: img.mimeType, data: img.data } } : { type: "image", source: { type: "url", url: img.url } }
9495
+ );
9496
+ }
9497
+ return content;
9498
+ }
9489
9499
  function buildAgentRef(inputs) {
9490
9500
  return {
9491
9501
  agentId: inputs.agentId,
@@ -9573,7 +9583,7 @@ async function initLoopContext(inputs) {
9573
9583
  conversation: [],
9574
9584
  messages: [
9575
9585
  ...priorMessages,
9576
- { role: "user", content: [{ type: "text", text: inputs.userMessage }] }
9586
+ { role: "user", content: buildUserContent(inputs.userMessage, inputs.userImages) }
9577
9587
  ],
9578
9588
  tools,
9579
9589
  finalText: "",
@@ -11594,6 +11604,9 @@ function toAnthropicWireMessage(message) {
11594
11604
  if (part.type === "tool_use") {
11595
11605
  return { type: "tool_use", id: part.id, name: part.name, input: part.input };
11596
11606
  }
11607
+ if (part.type === "image") {
11608
+ return { type: "image", source: part.source };
11609
+ }
11597
11610
  return {
11598
11611
  type: "tool_result",
11599
11612
  tool_use_id: part.toolUseId,
@@ -12137,6 +12150,9 @@ function readOpenAiContent(body) {
12137
12150
  return void 0;
12138
12151
  }
12139
12152
 
12153
+ // src/internal/llm/ollama-native.ts
12154
+ init_errors();
12155
+
12140
12156
  // src/internal/error-mappers/ollama.ts
12141
12157
  init_errors();
12142
12158
  function mapOllamaTransportError(args) {
@@ -12404,6 +12420,12 @@ function toOllamaMessages(message) {
12404
12420
  return [{ role: "system", content: joinTextParts(message) }];
12405
12421
  }
12406
12422
  if (message.role === "user") {
12423
+ if (message.content.some((p) => p.type === "image")) {
12424
+ throw new ConfigurationError(
12425
+ "image input is not supported on the ollama-native provider; use an OpenAI/OpenRouter model for multimodal turns",
12426
+ { code: "ollama_image_unsupported" }
12427
+ );
12428
+ }
12407
12429
  const out = [];
12408
12430
  for (const part of message.content) {
12409
12431
  if (part.type === "tool_result") {
@@ -12895,7 +12917,20 @@ function userOrToolMessages(message) {
12895
12917
  }
12896
12918
  }
12897
12919
  const userText = joinTextParts2(message);
12898
- if (userText.length > 0) out.push({ role: "user", content: userText });
12920
+ const imageParts = message.content.filter(
12921
+ (p) => p.type === "image"
12922
+ );
12923
+ if (imageParts.length > 0) {
12924
+ const content = [];
12925
+ if (userText.length > 0) content.push({ type: "text", text: userText });
12926
+ for (const img of imageParts) {
12927
+ const url = img.source.type === "base64" ? `data:${img.source.media_type};base64,${img.source.data}` : img.source.url;
12928
+ content.push({ type: "image_url", image_url: { url } });
12929
+ }
12930
+ out.push({ role: "user", content });
12931
+ } else if (userText.length > 0) {
12932
+ out.push({ role: "user", content: userText });
12933
+ }
12899
12934
  return out;
12900
12935
  }
12901
12936
  function assistantMessage(message) {
@@ -14081,7 +14116,7 @@ function buildCustomToolsInput(agentOptions, sendOptions, pluginManager, persona
14081
14116
 
14082
14117
  // src/internal/local-agent/real-local-run.ts
14083
14118
  function createRealLocalRun(options) {
14084
- const { userText, id, startTime } = prepareRunContext(options.message);
14119
+ const { userText, userImages, id, startTime } = prepareRunContext(options.message);
14085
14120
  const supported = /* @__PURE__ */ new Set(["stream", "wait", "cancel", "conversation"]);
14086
14121
  const runScript = {
14087
14122
  events: [],
@@ -14100,7 +14135,7 @@ function createRealLocalRun(options) {
14100
14135
  supportedOps: supported,
14101
14136
  startTime
14102
14137
  },
14103
- () => buildLoopInputs(options, id, userText)
14138
+ () => buildLoopInputs(options, id, userText, userImages)
14104
14139
  );
14105
14140
  handle.bootstrap();
14106
14141
  registerRun(handle);
@@ -14133,7 +14168,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
14133
14168
  if (existing !== void 0 && existing.length > 0) return pools;
14134
14169
  return { ...pools ?? {}, [primary]: [apiKey] };
14135
14170
  }
14136
- function buildLoopInputs(options, runId, userText) {
14171
+ function buildLoopInputs(options, runId, userText, userImages) {
14137
14172
  const maxIterations = options.sendOptions.maxIterations;
14138
14173
  if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
14139
14174
  throw new ConfigurationError(
@@ -14172,6 +14207,7 @@ function buildLoopInputs(options, runId, userText) {
14172
14207
  ...options.model?.params !== void 0 ? { params: options.model.params } : {}
14173
14208
  },
14174
14209
  userMessage: userText,
14210
+ ...userImages !== void 0 ? { userImages } : {},
14175
14211
  llm,
14176
14212
  mcp: buildMcpMap(options),
14177
14213
  hooks: options.hooks,