@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/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,18 @@ 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
+ if ("data" in img) {
12081
+ content.push({
12082
+ type: "image",
12083
+ source: { type: "base64", media_type: img.mimeType, data: img.data }
12084
+ });
12085
+ }
12086
+ }
12087
+ return content;
12088
+ }
12076
12089
  function buildAgentRef(inputs) {
12077
12090
  return {
12078
12091
  agentId: inputs.agentId,
@@ -12160,7 +12173,7 @@ async function initLoopContext(inputs) {
12160
12173
  conversation: [],
12161
12174
  messages: [
12162
12175
  ...priorMessages,
12163
- { role: "user", content: [{ type: "text", text: inputs.userMessage }] }
12176
+ { role: "user", content: buildUserContent(inputs.userMessage, inputs.userImages) }
12164
12177
  ],
12165
12178
  tools,
12166
12179
  finalText: "",
@@ -14196,6 +14209,9 @@ function toAnthropicWireMessage(message) {
14196
14209
  if (part.type === "tool_use") {
14197
14210
  return { type: "tool_use", id: part.id, name: part.name, input: part.input };
14198
14211
  }
14212
+ if (part.type === "image") {
14213
+ return { type: "image", source: part.source };
14214
+ }
14199
14215
  return {
14200
14216
  type: "tool_result",
14201
14217
  tool_use_id: part.toolUseId,
@@ -15497,7 +15513,20 @@ function userOrToolMessages(message) {
15497
15513
  }
15498
15514
  }
15499
15515
  const userText = joinTextParts2(message);
15500
- if (userText.length > 0) out.push({ role: "user", content: userText });
15516
+ const imageParts = message.content.filter((p) => p.type === "image");
15517
+ if (imageParts.length > 0) {
15518
+ const content = [];
15519
+ if (userText.length > 0) content.push({ type: "text", text: userText });
15520
+ for (const img of imageParts) {
15521
+ content.push({
15522
+ type: "image_url",
15523
+ image_url: { url: `data:${img.source.media_type};base64,${img.source.data}` }
15524
+ });
15525
+ }
15526
+ out.push({ role: "user", content });
15527
+ } else if (userText.length > 0) {
15528
+ out.push({ role: "user", content: userText });
15529
+ }
15501
15530
  return out;
15502
15531
  }
15503
15532
  function assistantMessage(message) {
@@ -16684,7 +16713,7 @@ function buildCustomToolsInput(agentOptions, sendOptions, pluginManager, persona
16684
16713
 
16685
16714
  // src/internal/local-agent/real-local-run.ts
16686
16715
  function createRealLocalRun(options) {
16687
- const { userText, id, startTime } = prepareRunContext(options.message);
16716
+ const { userText, userImages, id, startTime } = prepareRunContext(options.message);
16688
16717
  const supported = /* @__PURE__ */ new Set(["stream", "wait", "cancel", "conversation"]);
16689
16718
  const runScript = {
16690
16719
  events: [],
@@ -16703,7 +16732,7 @@ function createRealLocalRun(options) {
16703
16732
  supportedOps: supported,
16704
16733
  startTime
16705
16734
  },
16706
- () => buildLoopInputs(options, id, userText)
16735
+ () => buildLoopInputs(options, id, userText, userImages)
16707
16736
  );
16708
16737
  handle.bootstrap();
16709
16738
  registerRun(handle);
@@ -16736,7 +16765,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
16736
16765
  if (existing !== void 0 && existing.length > 0) return pools;
16737
16766
  return { ...pools ?? {}, [primary]: [apiKey] };
16738
16767
  }
16739
- function buildLoopInputs(options, runId, userText) {
16768
+ function buildLoopInputs(options, runId, userText, userImages) {
16740
16769
  const maxIterations = options.sendOptions.maxIterations;
16741
16770
  if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
16742
16771
  throw new exports.ConfigurationError(
@@ -16775,6 +16804,7 @@ function buildLoopInputs(options, runId, userText) {
16775
16804
  ...options.model?.params !== void 0 ? { params: options.model.params } : {}
16776
16805
  },
16777
16806
  userMessage: userText,
16807
+ ...userImages !== void 0 ? { userImages } : {},
16778
16808
  llm,
16779
16809
  mcp: buildMcpMap(options),
16780
16810
  hooks: options.hooks,