@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/index.cjs CHANGED
@@ -6986,7 +6986,8 @@ function applyExtraRunFields(base, script) {
6986
6986
  // src/internal/runtime/fixtures/fixture-run-base.ts
6987
6987
  function prepareRunContext(message) {
6988
6988
  const userText = typeof message === "string" ? message : message.text;
6989
- return { userText, id: generateRunId(), startTime: Date.now() };
6989
+ const userImages = typeof message === "string" ? void 0 : message.images;
6990
+ return { userText, userImages, id: generateRunId(), startTime: Date.now() };
6990
6991
  }
6991
6992
  var FixtureRunBase = class {
6992
6993
  id;
@@ -12073,6 +12074,15 @@ function buildAssistantTurn(text, toolCalls) {
12073
12074
  }
12074
12075
 
12075
12076
  // src/internal/agent-loop/loop-context-init.ts
12077
+ function buildUserContent(text, images) {
12078
+ const content = [{ type: "text", text }];
12079
+ for (const img of images ?? []) {
12080
+ content.push(
12081
+ "data" in img ? { type: "image", source: { type: "base64", media_type: img.mimeType, data: img.data } } : { type: "image", source: { type: "url", url: img.url } }
12082
+ );
12083
+ }
12084
+ return content;
12085
+ }
12076
12086
  function buildAgentRef(inputs) {
12077
12087
  return {
12078
12088
  agentId: inputs.agentId,
@@ -12160,7 +12170,7 @@ async function initLoopContext(inputs) {
12160
12170
  conversation: [],
12161
12171
  messages: [
12162
12172
  ...priorMessages,
12163
- { role: "user", content: [{ type: "text", text: inputs.userMessage }] }
12173
+ { role: "user", content: buildUserContent(inputs.userMessage, inputs.userImages) }
12164
12174
  ],
12165
12175
  tools,
12166
12176
  finalText: "",
@@ -14196,6 +14206,9 @@ function toAnthropicWireMessage(message) {
14196
14206
  if (part.type === "tool_use") {
14197
14207
  return { type: "tool_use", id: part.id, name: part.name, input: part.input };
14198
14208
  }
14209
+ if (part.type === "image") {
14210
+ return { type: "image", source: part.source };
14211
+ }
14199
14212
  return {
14200
14213
  type: "tool_result",
14201
14214
  tool_use_id: part.toolUseId,
@@ -14739,6 +14752,9 @@ function readOpenAiContent(body) {
14739
14752
  return void 0;
14740
14753
  }
14741
14754
 
14755
+ // src/internal/llm/ollama-native.ts
14756
+ init_errors();
14757
+
14742
14758
  // src/internal/error-mappers/ollama.ts
14743
14759
  init_errors();
14744
14760
  function mapOllamaTransportError(args) {
@@ -15006,6 +15022,12 @@ function toOllamaMessages(message) {
15006
15022
  return [{ role: "system", content: joinTextParts(message) }];
15007
15023
  }
15008
15024
  if (message.role === "user") {
15025
+ if (message.content.some((p) => p.type === "image")) {
15026
+ throw new exports.ConfigurationError(
15027
+ "image input is not supported on the ollama-native provider; use an OpenAI/OpenRouter model for multimodal turns",
15028
+ { code: "ollama_image_unsupported" }
15029
+ );
15030
+ }
15009
15031
  const out = [];
15010
15032
  for (const part of message.content) {
15011
15033
  if (part.type === "tool_result") {
@@ -15497,7 +15519,20 @@ function userOrToolMessages(message) {
15497
15519
  }
15498
15520
  }
15499
15521
  const userText = joinTextParts2(message);
15500
- if (userText.length > 0) out.push({ role: "user", content: userText });
15522
+ const imageParts = message.content.filter(
15523
+ (p) => p.type === "image"
15524
+ );
15525
+ if (imageParts.length > 0) {
15526
+ const content = [];
15527
+ if (userText.length > 0) content.push({ type: "text", text: userText });
15528
+ for (const img of imageParts) {
15529
+ const url = img.source.type === "base64" ? `data:${img.source.media_type};base64,${img.source.data}` : img.source.url;
15530
+ content.push({ type: "image_url", image_url: { url } });
15531
+ }
15532
+ out.push({ role: "user", content });
15533
+ } else if (userText.length > 0) {
15534
+ out.push({ role: "user", content: userText });
15535
+ }
15501
15536
  return out;
15502
15537
  }
15503
15538
  function assistantMessage(message) {
@@ -16684,7 +16719,7 @@ function buildCustomToolsInput(agentOptions, sendOptions, pluginManager, persona
16684
16719
 
16685
16720
  // src/internal/local-agent/real-local-run.ts
16686
16721
  function createRealLocalRun(options) {
16687
- const { userText, id, startTime } = prepareRunContext(options.message);
16722
+ const { userText, userImages, id, startTime } = prepareRunContext(options.message);
16688
16723
  const supported = /* @__PURE__ */ new Set(["stream", "wait", "cancel", "conversation"]);
16689
16724
  const runScript = {
16690
16725
  events: [],
@@ -16703,7 +16738,7 @@ function createRealLocalRun(options) {
16703
16738
  supportedOps: supported,
16704
16739
  startTime
16705
16740
  },
16706
- () => buildLoopInputs(options, id, userText)
16741
+ () => buildLoopInputs(options, id, userText, userImages)
16707
16742
  );
16708
16743
  handle.bootstrap();
16709
16744
  registerRun(handle);
@@ -16736,7 +16771,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
16736
16771
  if (existing !== void 0 && existing.length > 0) return pools;
16737
16772
  return { ...pools ?? {}, [primary]: [apiKey] };
16738
16773
  }
16739
- function buildLoopInputs(options, runId, userText) {
16774
+ function buildLoopInputs(options, runId, userText, userImages) {
16740
16775
  const maxIterations = options.sendOptions.maxIterations;
16741
16776
  if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
16742
16777
  throw new exports.ConfigurationError(
@@ -16775,6 +16810,7 @@ function buildLoopInputs(options, runId, userText) {
16775
16810
  ...options.model?.params !== void 0 ? { params: options.model.params } : {}
16776
16811
  },
16777
16812
  userMessage: userText,
16813
+ ...userImages !== void 0 ? { userImages } : {},
16778
16814
  llm,
16779
16815
  mcp: buildMcpMap(options),
16780
16816
  hooks: options.hooks,