@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.js CHANGED
@@ -6983,7 +6983,8 @@ function applyExtraRunFields(base, script) {
6983
6983
  // src/internal/runtime/fixtures/fixture-run-base.ts
6984
6984
  function prepareRunContext(message) {
6985
6985
  const userText = typeof message === "string" ? message : message.text;
6986
- return { userText, id: generateRunId(), startTime: Date.now() };
6986
+ const userImages = typeof message === "string" ? void 0 : message.images;
6987
+ return { userText, userImages, id: generateRunId(), startTime: Date.now() };
6987
6988
  }
6988
6989
  var FixtureRunBase = class {
6989
6990
  id;
@@ -12070,6 +12071,18 @@ function buildAssistantTurn(text, toolCalls) {
12070
12071
  }
12071
12072
 
12072
12073
  // src/internal/agent-loop/loop-context-init.ts
12074
+ function buildUserContent(text, images) {
12075
+ const content = [{ type: "text", text }];
12076
+ for (const img of images ?? []) {
12077
+ if ("data" in img) {
12078
+ content.push({
12079
+ type: "image",
12080
+ source: { type: "base64", media_type: img.mimeType, data: img.data }
12081
+ });
12082
+ }
12083
+ }
12084
+ return content;
12085
+ }
12073
12086
  function buildAgentRef(inputs) {
12074
12087
  return {
12075
12088
  agentId: inputs.agentId,
@@ -12157,7 +12170,7 @@ async function initLoopContext(inputs) {
12157
12170
  conversation: [],
12158
12171
  messages: [
12159
12172
  ...priorMessages,
12160
- { role: "user", content: [{ type: "text", text: inputs.userMessage }] }
12173
+ { role: "user", content: buildUserContent(inputs.userMessage, inputs.userImages) }
12161
12174
  ],
12162
12175
  tools,
12163
12176
  finalText: "",
@@ -14193,6 +14206,9 @@ function toAnthropicWireMessage(message) {
14193
14206
  if (part.type === "tool_use") {
14194
14207
  return { type: "tool_use", id: part.id, name: part.name, input: part.input };
14195
14208
  }
14209
+ if (part.type === "image") {
14210
+ return { type: "image", source: part.source };
14211
+ }
14196
14212
  return {
14197
14213
  type: "tool_result",
14198
14214
  tool_use_id: part.toolUseId,
@@ -15494,7 +15510,20 @@ function userOrToolMessages(message) {
15494
15510
  }
15495
15511
  }
15496
15512
  const userText = joinTextParts2(message);
15497
- if (userText.length > 0) out.push({ role: "user", content: userText });
15513
+ const imageParts = message.content.filter((p) => p.type === "image");
15514
+ if (imageParts.length > 0) {
15515
+ const content = [];
15516
+ if (userText.length > 0) content.push({ type: "text", text: userText });
15517
+ for (const img of imageParts) {
15518
+ content.push({
15519
+ type: "image_url",
15520
+ image_url: { url: `data:${img.source.media_type};base64,${img.source.data}` }
15521
+ });
15522
+ }
15523
+ out.push({ role: "user", content });
15524
+ } else if (userText.length > 0) {
15525
+ out.push({ role: "user", content: userText });
15526
+ }
15498
15527
  return out;
15499
15528
  }
15500
15529
  function assistantMessage(message) {
@@ -16681,7 +16710,7 @@ function buildCustomToolsInput(agentOptions, sendOptions, pluginManager, persona
16681
16710
 
16682
16711
  // src/internal/local-agent/real-local-run.ts
16683
16712
  function createRealLocalRun(options) {
16684
- const { userText, id, startTime } = prepareRunContext(options.message);
16713
+ const { userText, userImages, id, startTime } = prepareRunContext(options.message);
16685
16714
  const supported = /* @__PURE__ */ new Set(["stream", "wait", "cancel", "conversation"]);
16686
16715
  const runScript = {
16687
16716
  events: [],
@@ -16700,7 +16729,7 @@ function createRealLocalRun(options) {
16700
16729
  supportedOps: supported,
16701
16730
  startTime
16702
16731
  },
16703
- () => buildLoopInputs(options, id, userText)
16732
+ () => buildLoopInputs(options, id, userText, userImages)
16704
16733
  );
16705
16734
  handle.bootstrap();
16706
16735
  registerRun(handle);
@@ -16733,7 +16762,7 @@ function mergeExplicitApiKey(pools, primary, apiKey) {
16733
16762
  if (existing !== void 0 && existing.length > 0) return pools;
16734
16763
  return { ...pools ?? {}, [primary]: [apiKey] };
16735
16764
  }
16736
- function buildLoopInputs(options, runId, userText) {
16765
+ function buildLoopInputs(options, runId, userText, userImages) {
16737
16766
  const maxIterations = options.sendOptions.maxIterations;
16738
16767
  if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
16739
16768
  throw new ConfigurationError(
@@ -16772,6 +16801,7 @@ function buildLoopInputs(options, runId, userText) {
16772
16801
  ...options.model?.params !== void 0 ? { params: options.model.params } : {}
16773
16802
  },
16774
16803
  userMessage: userText,
16804
+ ...userImages !== void 0 ? { userImages } : {},
16775
16805
  llm,
16776
16806
  mcp: buildMcpMap(options),
16777
16807
  hooks: options.hooks,