@kenkaiiii/gg-agent 5.74.2 → 5.75.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.d.cts CHANGED
@@ -386,6 +386,11 @@ interface AgentOptions {
386
386
  * against parallel fan-outs injecting huge uncached context in one turn;
387
387
  * the largest results are trimmed (water-filling) with a re-run notice. */
388
388
  maxTurnToolResultChars?: number;
389
+ /** Load a tool the model called by name that is not in `tools` yet (e.g. a
390
+ * deferred tool it saw advertised). Return it to run the call normally, or
391
+ * undefined for the usual "Unknown tool" result. Must append the tool to the
392
+ * live `tools` array itself so later turns see its schema. */
393
+ resolveTool?: (name: string) => AgentTool | undefined;
389
394
  /** Optional post-processing of a SUCCESSFUL tool result (after redaction,
390
395
  * before the tool_call_end event and the provider context). Return the
391
396
  * content unchanged to leave it alone. A throw is ignored (original kept).
package/dist/index.d.ts CHANGED
@@ -386,6 +386,11 @@ interface AgentOptions {
386
386
  * against parallel fan-outs injecting huge uncached context in one turn;
387
387
  * the largest results are trimmed (water-filling) with a re-run notice. */
388
388
  maxTurnToolResultChars?: number;
389
+ /** Load a tool the model called by name that is not in `tools` yet (e.g. a
390
+ * deferred tool it saw advertised). Return it to run the call normally, or
391
+ * undefined for the usual "Unknown tool" result. Must append the tool to the
392
+ * live `tools` array itself so later turns see its schema. */
393
+ resolveTool?: (name: string) => AgentTool | undefined;
389
394
  /** Optional post-processing of a SUCCESSFUL tool result (after redaction,
390
395
  * before the tool_call_end event and the provider context). Return the
391
396
  * content unchanged to leave it alone. A throw is ignored (original kept).
package/dist/index.js CHANGED
@@ -1504,6 +1504,7 @@ async function* agentLoop(messages, options) {
1504
1504
  maxToolResultChars: options.maxToolResultChars,
1505
1505
  maxTurnToolResultChars: options.maxTurnToolResultChars,
1506
1506
  transformToolResult: options.transformToolResult,
1507
+ resolveTool: options.resolveTool,
1507
1508
  toolMap,
1508
1509
  invalidToolArgumentCounts,
1509
1510
  markFatalToolArgumentError,
@@ -1662,7 +1663,11 @@ async function executeSingleToolCall(toolCall, options, pushEvent) {
1662
1663
  let isError = false;
1663
1664
  let endRun = false;
1664
1665
  let invalidArgAttempt;
1665
- const tool = options.toolMap.get(toolCall.name);
1666
+ let tool = options.toolMap.get(toolCall.name);
1667
+ if (!tool && options.resolveTool) {
1668
+ tool = options.resolveTool(toolCall.name);
1669
+ if (tool) options.toolMap.set(tool.name, tool);
1670
+ }
1666
1671
  if (tool) {
1667
1672
  const signature = JSON.stringify([toolCall.name, canonicalToolArgs(toolCall.args)]);
1668
1673
  if (options.seenToolCalls.has(signature)) {