@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/index.cjs CHANGED
@@ -11919,21 +11919,21 @@ async function executeTool(inputs, resolved, call) {
11919
11919
  if (resolved.origin === "shell") return runShellTool(inputs, call);
11920
11920
  if (resolved.origin === "memory") return runMemoryTool(resolved, call, inputs.context);
11921
11921
  if (resolved.origin === "custom")
11922
- return runCustomTool(resolved, call, inputs.signal, inputs.context);
11922
+ return runCustomTool(resolved, call, inputs.signal, inputs.context, inputs.messages);
11923
11923
  return runMcpTool(inputs, resolved, call);
11924
11924
  }
11925
11925
  async function runMemoryTool(resolved, call, context) {
11926
11926
  return runHandlerTool("memory", resolved.memoryHandler, call, void 0, context);
11927
11927
  }
11928
- async function runCustomTool(resolved, call, signal, context) {
11929
- return runHandlerTool("custom", resolved.customHandler, call, signal, context);
11928
+ async function runCustomTool(resolved, call, signal, context, messages) {
11929
+ return runHandlerTool("custom", resolved.customHandler, call, signal, context, messages);
11930
11930
  }
11931
- async function runHandlerTool(kind, handler, call, signal, context) {
11931
+ async function runHandlerTool(kind, handler, call, signal, context, messages) {
11932
11932
  if (handler === void 0) {
11933
11933
  return { stdout: "", stderr: `${kind} tool ${call.name} has no handler`, exitCode: 127 };
11934
11934
  }
11935
11935
  try {
11936
- const out = await handler(call.input, { signal, context });
11936
+ const out = await handler(call.input, { signal, context, messages });
11937
11937
  if (typeof out !== "string") return { stdout: "", stderr: "", exitCode: 0, content: out };
11938
11938
  return { stdout: out, stderr: "", exitCode: 0 };
11939
11939
  } catch (cause) {
@@ -12693,6 +12693,14 @@ function computeUsageCost(inputs, usage) {
12693
12693
  }
12694
12694
 
12695
12695
  // src/internal/agent-loop/loop.ts
12696
+ function projectToolContextMessages(messages) {
12697
+ const projected = [];
12698
+ for (const m of messages) {
12699
+ const content = m.content.flatMap((p) => p.type === "text" ? [p.text] : []).join("");
12700
+ if (content !== "") projected.push({ role: m.role, content });
12701
+ }
12702
+ return projected;
12703
+ }
12696
12704
  var MAX_NUDGE_ATTEMPTS = 2;
12697
12705
  var MAX_STOP_FEEDBACK_ATTEMPTS = 2;
12698
12706
  async function runAgentLoop(inputs) {
@@ -12935,7 +12943,9 @@ async function continueOrTerminate(inputs, ctx, llmOutput) {
12935
12943
  const outText = await transformLlmOutputText(inputs, llmOutput.text, tCtx);
12936
12944
  ctx.messages.push(buildAssistantTurn(outText, llmOutput.toolCalls));
12937
12945
  const rawResults = await dispatchTools(
12938
- inputs,
12946
+ // SE12 — forward a read-only text projection of the transcript-so-far to tool
12947
+ // handlers via `ctx.messages` (consumed by defineSubAgent's messageFilter).
12948
+ { ...inputs, messages: projectToolContextMessages(ctx.messages) },
12939
12949
  ctx.tools,
12940
12950
  llmOutput.toolCalls,
12941
12951
  ctx.events,