@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.d.cts CHANGED
@@ -85,6 +85,10 @@ interface StructuredToolResult {
85
85
  * calls in the same batch from running (e.g. a pending plan-review handoff).
86
86
  * Host control metadata only: never serialized into provider tool results. */
87
87
  endRun?: boolean;
88
+ /** Deferred tools this call made callable (e.g. a tool_search promotion).
89
+ * Copied onto the provider ToolResult so transports with transcript tool
90
+ * loading keep the cached tools block unchanged. */
91
+ loadedTools?: string[];
88
92
  }
89
93
  type ToolExecuteResult = string | StructuredToolResult;
90
94
  interface ToolContext {
@@ -319,6 +323,8 @@ interface AgentOptions {
319
323
  priorMessages?: Message[];
320
324
  tools?: AgentTool[];
321
325
  serverTools?: ServerToolDefinition[];
326
+ /** Stable on-demand tool catalog (see gg-ai `StreamOptions.deferredTools`). */
327
+ deferredTools?: StreamOptions["deferredTools"];
322
328
  /** Control whether tools may/must be called, or select a named tool when supported. */
323
329
  toolChoice?: StreamOptions["toolChoice"];
324
330
  maxTurns?: number;
package/dist/index.d.ts CHANGED
@@ -85,6 +85,10 @@ interface StructuredToolResult {
85
85
  * calls in the same batch from running (e.g. a pending plan-review handoff).
86
86
  * Host control metadata only: never serialized into provider tool results. */
87
87
  endRun?: boolean;
88
+ /** Deferred tools this call made callable (e.g. a tool_search promotion).
89
+ * Copied onto the provider ToolResult so transports with transcript tool
90
+ * loading keep the cached tools block unchanged. */
91
+ loadedTools?: string[];
88
92
  }
89
93
  type ToolExecuteResult = string | StructuredToolResult;
90
94
  interface ToolContext {
@@ -319,6 +323,8 @@ interface AgentOptions {
319
323
  priorMessages?: Message[];
320
324
  tools?: AgentTool[];
321
325
  serverTools?: ServerToolDefinition[];
326
+ /** Stable on-demand tool catalog (see gg-ai `StreamOptions.deferredTools`). */
327
+ deferredTools?: StreamOptions["deferredTools"];
322
328
  /** Control whether tools may/must be called, or select a named tool when supported. */
323
329
  toolChoice?: StreamOptions["toolChoice"];
324
330
  maxTurns?: number;
package/dist/index.js CHANGED
@@ -950,6 +950,7 @@ async function* agentLoop(messages, options) {
950
950
  model: options.model,
951
951
  messages: requestMessages,
952
952
  tools: options.tools,
953
+ deferredTools: options.deferredTools,
953
954
  serverTools: options.serverTools,
954
955
  toolChoice: options.toolChoice,
955
956
  webSearch: typeof options.webSearch === "function" ? options.webSearch() : options.webSearch,
@@ -1858,10 +1859,14 @@ async function executeSingleToolCall(toolCall, options, pushEvent) {
1858
1859
  let isError = false;
1859
1860
  let endRun = false;
1860
1861
  let invalidArgAttempt;
1862
+ const loadedTools = /* @__PURE__ */ new Set();
1861
1863
  let tool = options.toolMap.get(toolCall.name);
1862
1864
  if (!tool && options.resolveTool) {
1863
1865
  tool = options.resolveTool(toolCall.name);
1864
- if (tool) options.toolMap.set(tool.name, tool);
1866
+ if (tool) {
1867
+ options.toolMap.set(tool.name, tool);
1868
+ loadedTools.add(tool.name);
1869
+ }
1865
1870
  }
1866
1871
  if (tool) {
1867
1872
  const signature = JSON.stringify([toolCall.name, canonicalToolArgs(toolCall.args)]);
@@ -1914,6 +1919,7 @@ async function executeSingleToolCall(toolCall, options, pushEvent) {
1914
1919
  const raw = await tool.execute(parsed, ctx);
1915
1920
  const normalized = normalizeToolResult(raw);
1916
1921
  endRun = normalized.endRun === true;
1922
+ for (const name of normalized.loadedTools ?? []) loadedTools.add(name);
1917
1923
  resultContent = redactValue(normalized.content, toolRedactionOptions());
1918
1924
  details = redactValue(normalized.details, toolRedactionOptions());
1919
1925
  if (options.transformToolResult) {
@@ -1985,7 +1991,13 @@ ${hints}` : "") + "\nRe-issue the call with each field as the correct type.";
1985
1991
  durationMs,
1986
1992
  ...invalidArgAttempt === void 0 ? {} : { invalidArgAttempt }
1987
1993
  });
1988
- return { toolCallId: toolCall.id, content: resultContent, isError, endRun: endRun && !isError };
1994
+ return {
1995
+ toolCallId: toolCall.id,
1996
+ content: resultContent,
1997
+ isError,
1998
+ endRun: endRun && !isError,
1999
+ ...loadedTools.size > 0 ? { loadedTools: [...loadedTools].sort() } : {}
2000
+ };
1989
2001
  }
1990
2002
  function createPreemptTracker(options, eventStream, state, resultsById, dispatchedIds) {
1991
2003
  const running = /* @__PURE__ */ new Map();
@@ -2168,7 +2180,8 @@ function buildToolResults(initialToolResults, toolCalls, resultsById, dispatched
2168
2180
  type: "tool_result",
2169
2181
  toolCallId: toolCall.id,
2170
2182
  content: result.content,
2171
- isError: result.isError || void 0
2183
+ isError: result.isError || void 0,
2184
+ ...result.loadedTools?.length ? { loadedTools: result.loadedTools } : {}
2172
2185
  });
2173
2186
  } else {
2174
2187
  const dispatched = dispatchedIds?.has(toolCall.id) ?? true;