@kenkaiiii/gg-agent 5.87.3 → 5.88.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
@@ -982,6 +982,7 @@ async function* agentLoop(messages, options) {
982
982
  model: options.model,
983
983
  messages: requestMessages,
984
984
  tools: options.tools,
985
+ deferredTools: options.deferredTools,
985
986
  serverTools: options.serverTools,
986
987
  toolChoice: options.toolChoice,
987
988
  webSearch: typeof options.webSearch === "function" ? options.webSearch() : options.webSearch,
@@ -1890,10 +1891,14 @@ async function executeSingleToolCall(toolCall, options, pushEvent) {
1890
1891
  let isError = false;
1891
1892
  let endRun = false;
1892
1893
  let invalidArgAttempt;
1894
+ const loadedTools = /* @__PURE__ */ new Set();
1893
1895
  let tool = options.toolMap.get(toolCall.name);
1894
1896
  if (!tool && options.resolveTool) {
1895
1897
  tool = options.resolveTool(toolCall.name);
1896
- if (tool) options.toolMap.set(tool.name, tool);
1898
+ if (tool) {
1899
+ options.toolMap.set(tool.name, tool);
1900
+ loadedTools.add(tool.name);
1901
+ }
1897
1902
  }
1898
1903
  if (tool) {
1899
1904
  const signature = JSON.stringify([toolCall.name, canonicalToolArgs(toolCall.args)]);
@@ -1946,6 +1951,7 @@ async function executeSingleToolCall(toolCall, options, pushEvent) {
1946
1951
  const raw = await tool.execute(parsed, ctx);
1947
1952
  const normalized = normalizeToolResult(raw);
1948
1953
  endRun = normalized.endRun === true;
1954
+ for (const name of normalized.loadedTools ?? []) loadedTools.add(name);
1949
1955
  resultContent = (0, import_gg_ai2.redactValue)(normalized.content, toolRedactionOptions());
1950
1956
  details = (0, import_gg_ai2.redactValue)(normalized.details, toolRedactionOptions());
1951
1957
  if (options.transformToolResult) {
@@ -2017,7 +2023,13 @@ ${hints}` : "") + "\nRe-issue the call with each field as the correct type.";
2017
2023
  durationMs,
2018
2024
  ...invalidArgAttempt === void 0 ? {} : { invalidArgAttempt }
2019
2025
  });
2020
- return { toolCallId: toolCall.id, content: resultContent, isError, endRun: endRun && !isError };
2026
+ return {
2027
+ toolCallId: toolCall.id,
2028
+ content: resultContent,
2029
+ isError,
2030
+ endRun: endRun && !isError,
2031
+ ...loadedTools.size > 0 ? { loadedTools: [...loadedTools].sort() } : {}
2032
+ };
2021
2033
  }
2022
2034
  function createPreemptTracker(options, eventStream, state, resultsById, dispatchedIds) {
2023
2035
  const running = /* @__PURE__ */ new Map();
@@ -2200,7 +2212,8 @@ function buildToolResults(initialToolResults, toolCalls, resultsById, dispatched
2200
2212
  type: "tool_result",
2201
2213
  toolCallId: toolCall.id,
2202
2214
  content: result.content,
2203
- isError: result.isError || void 0
2215
+ isError: result.isError || void 0,
2216
+ ...result.loadedTools?.length ? { loadedTools: result.loadedTools } : {}
2204
2217
  });
2205
2218
  } else {
2206
2219
  const dispatched = dispatchedIds?.has(toolCall.id) ?? true;