@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/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,15 @@ 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
+ content.push(
9496
+ "data" in img ? { type: "image", source: { type: "base64", media_type: img.mimeType, data: img.data } } : { type: "image", source: { type: "url", url: img.url } }
9497
+ );
9498
+ }
9499
+ return content;
9500
+ }
9491
9501
  function buildAgentRef(inputs) {
9492
9502
  return {
9493
9503
  agentId: inputs.agentId,
@@ -9575,7 +9585,7 @@ async function initLoopContext(inputs) {
9575
9585
  conversation: [],
9576
9586
  messages: [
9577
9587
  ...priorMessages,
9578
- { role: "user", content: [{ type: "text", text: inputs.userMessage }] }
9588
+ { role: "user", content: buildUserContent(inputs.userMessage, inputs.userImages) }
9579
9589
  ],
9580
9590
  tools,
9581
9591
  finalText: "",
@@ -11596,6 +11606,9 @@ function toAnthropicWireMessage(message) {
11596
11606
  if (part.type === "tool_use") {
11597
11607
  return { type: "tool_use", id: part.id, name: part.name, input: part.input };
11598
11608
  }
11609
+ if (part.type === "image") {
11610
+ return { type: "image", source: part.source };
11611
+ }
11599
11612
  return {
11600
11613
  type: "tool_result",
11601
11614
  tool_use_id: part.toolUseId,
@@ -12139,6 +12152,9 @@ function readOpenAiContent(body) {
12139
12152
  return void 0;
12140
12153
  }
12141
12154
 
12155
+ // src/internal/llm/ollama-native.ts
12156
+ init_errors();
12157
+
12142
12158
  // src/internal/error-mappers/ollama.ts
12143
12159
  init_errors();
12144
12160
  function mapOllamaTransportError(args) {
@@ -12406,6 +12422,12 @@ function toOllamaMessages(message) {
12406
12422
  return [{ role: "system", content: joinTextParts(message) }];
12407
12423
  }
12408
12424
  if (message.role === "user") {
12425
+ if (message.content.some((p) => p.type === "image")) {
12426
+ throw new ConfigurationError(
12427
+ "image input is not supported on the ollama-native provider; use an OpenAI/OpenRouter model for multimodal turns",
12428
+ { code: "ollama_image_unsupported" }
12429
+ );
12430
+ }
12409
12431
  const out = [];
12410
12432
  for (const part of message.content) {
12411
12433
  if (part.type === "tool_result") {
@@ -12897,7 +12919,20 @@ function userOrToolMessages(message) {
12897
12919
  }
12898
12920
  }
12899
12921
  const userText = joinTextParts2(message);
12900
- if (userText.length > 0) out.push({ role: "user", content: userText });
12922
+ const imageParts = message.content.filter(
12923
+ (p) => p.type === "image"
12924
+ );
12925
+ if (imageParts.length > 0) {
12926
+ const content = [];
12927
+ if (userText.length > 0) content.push({ type: "text", text: userText });
12928
+ for (const img of imageParts) {
12929
+ const url = img.source.type === "base64" ? `data:${img.source.media_type};base64,${img.source.data}` : img.source.url;
12930
+ content.push({ type: "image_url", image_url: { url } });
12931
+ }
12932
+ out.push({ role: "user", content });
12933
+ } else if (userText.length > 0) {
12934
+ out.push({ role: "user", content: userText });
12935
+ }
12901
12936
  return out;
12902
12937
  }
12903
12938
  function assistantMessage(message) {
@@ -14083,7 +14118,7 @@ function buildCustomToolsInput(agentOptions, sendOptions, pluginManager, persona
14083
14118
 
14084
14119
  // src/internal/local-agent/real-local-run.ts
14085
14120
  function createRealLocalRun(options) {
14086
- const { userText, id, startTime } = prepareRunContext(options.message);
14121
+ const { userText, userImages, id, startTime } = prepareRunContext(options.message);
14087
14122
  const supported = /* @__PURE__ */ new Set(["stream", "wait", "cancel", "conversation"]);
14088
14123
  const runScript = {
14089
14124
  events: [],
@@ -14102,7 +14137,7 @@ function createRealLocalRun(options) {
14102
14137
  supportedOps: supported,
14103
14138
  startTime
14104
14139
  },
14105
- () => buildLoopInputs(options, id, userText)
14140
+ () => buildLoopInputs(options, id, userText, userImages)
14106
14141
  );
14107
14142
  handle.bootstrap();
14108
14143
  registerRun(handle);
@@ -14135,7 +14170,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
14135
14170
  if (existing !== void 0 && existing.length > 0) return pools;
14136
14171
  return { ...pools ?? {}, [primary]: [apiKey] };
14137
14172
  }
14138
- function buildLoopInputs(options, runId, userText) {
14173
+ function buildLoopInputs(options, runId, userText, userImages) {
14139
14174
  const maxIterations = options.sendOptions.maxIterations;
14140
14175
  if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
14141
14176
  throw new ConfigurationError(
@@ -14174,6 +14209,7 @@ function buildLoopInputs(options, runId, userText) {
14174
14209
  ...options.model?.params !== void 0 ? { params: options.model.params } : {}
14175
14210
  },
14176
14211
  userMessage: userText,
14212
+ ...userImages !== void 0 ? { userImages } : {},
14177
14213
  llm,
14178
14214
  mcp: buildMcpMap(options),
14179
14215
  hooks: options.hooks,