@theokit/sdk 2.21.0 → 2.23.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/eval.js CHANGED
@@ -9446,21 +9446,21 @@ async function executeTool(inputs, resolved, call) {
9446
9446
  if (resolved.origin === "shell") return runShellTool(inputs, call);
9447
9447
  if (resolved.origin === "memory") return runMemoryTool(resolved, call, inputs.context);
9448
9448
  if (resolved.origin === "custom")
9449
- return runCustomTool(resolved, call, inputs.signal, inputs.context);
9449
+ return runCustomTool(resolved, call, inputs.signal, inputs.context, inputs.messages);
9450
9450
  return runMcpTool(inputs, resolved, call);
9451
9451
  }
9452
9452
  async function runMemoryTool(resolved, call, context) {
9453
9453
  return runHandlerTool("memory", resolved.memoryHandler, call, void 0, context);
9454
9454
  }
9455
- async function runCustomTool(resolved, call, signal, context) {
9456
- return runHandlerTool("custom", resolved.customHandler, call, signal, context);
9455
+ async function runCustomTool(resolved, call, signal, context, messages) {
9456
+ return runHandlerTool("custom", resolved.customHandler, call, signal, context, messages);
9457
9457
  }
9458
- async function runHandlerTool(kind, handler, call, signal, context) {
9458
+ async function runHandlerTool(kind, handler, call, signal, context, messages) {
9459
9459
  if (handler === void 0) {
9460
9460
  return { stdout: "", stderr: `${kind} tool ${call.name} has no handler`, exitCode: 127 };
9461
9461
  }
9462
9462
  try {
9463
- const out = await handler(call.input, { signal, context });
9463
+ const out = await handler(call.input, { signal, context, messages });
9464
9464
  if (typeof out !== "string") return { stdout: "", stderr: "", exitCode: 0, content: out };
9465
9465
  return { stdout: out, stderr: "", exitCode: 0 };
9466
9466
  } catch (cause) {
@@ -10220,6 +10220,14 @@ function computeUsageCost(inputs, usage) {
10220
10220
  }
10221
10221
 
10222
10222
  // src/internal/agent-loop/loop.ts
10223
+ function projectToolContextMessages(messages) {
10224
+ const projected = [];
10225
+ for (const m of messages) {
10226
+ const content = m.content.flatMap((p) => p.type === "text" ? [p.text] : []).join("");
10227
+ if (content !== "") projected.push({ role: m.role, content });
10228
+ }
10229
+ return projected;
10230
+ }
10223
10231
  var MAX_NUDGE_ATTEMPTS = 2;
10224
10232
  var MAX_STOP_FEEDBACK_ATTEMPTS = 2;
10225
10233
  async function runAgentLoop(inputs) {
@@ -10462,7 +10470,9 @@ async function continueOrTerminate(inputs, ctx, llmOutput) {
10462
10470
  const outText = await transformLlmOutputText(inputs, llmOutput.text, tCtx);
10463
10471
  ctx.messages.push(buildAssistantTurn(outText, llmOutput.toolCalls));
10464
10472
  const rawResults = await dispatchTools(
10465
- inputs,
10473
+ // SE12 — forward a read-only text projection of the transcript-so-far to tool
10474
+ // handlers via `ctx.messages` (consumed by defineSubAgent's messageFilter).
10475
+ { ...inputs, messages: projectToolContextMessages(ctx.messages) },
10466
10476
  ctx.tools,
10467
10477
  llmOutput.toolCalls,
10468
10478
  ctx.events,