@kenkaiiii/gg-agent 5.93.0 → 5.95.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 +9 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -12
- package/dist/index.d.ts +17 -12
- package/dist/index.js +5 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Message, StreamOptions, Tool, ToolResultContent, ServerToolDefinition, Usage, StopReason, AssistantMessage } from '@kenkaiiii/gg-ai';
|
|
1
|
+
import { Message, StreamOptions, Tool, ToolResultContent, ServerToolDefinition, Usage, StopReason, AssistantMessage, ToolResult } from '@kenkaiiii/gg-ai';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -348,27 +348,23 @@ interface AgentOptions {
|
|
|
348
348
|
* turn fails with an authentication error. Returning the current credential
|
|
349
349
|
* here keeps a long run alive across rotations.
|
|
350
350
|
*
|
|
351
|
-
* Falls back to `apiKey`/`accountId
|
|
351
|
+
* Falls back to `apiKey`/`accountId` when omitted or when the
|
|
352
352
|
* resolver throws (the provider call then surfaces the real auth error).
|
|
353
353
|
*/
|
|
354
354
|
resolveCredentials?: () => Promise<{
|
|
355
355
|
apiKey: string;
|
|
356
356
|
accountId?: string;
|
|
357
|
-
projectId?: string;
|
|
358
357
|
}>;
|
|
359
358
|
baseUrl?: string;
|
|
360
359
|
signal?: AbortSignal;
|
|
361
360
|
accountId?: string;
|
|
362
361
|
transportSessionId?: StreamOptions["transportSessionId"];
|
|
363
|
-
projectId?: StreamOptions["projectId"];
|
|
364
362
|
cacheRetention?: StreamOptions["cacheRetention"];
|
|
365
363
|
onContextPrepared?: StreamOptions["onContextPrepared"];
|
|
366
364
|
/** Stable per-session cache routing key for providers that support it. */
|
|
367
365
|
promptCacheKey?: StreamOptions["promptCacheKey"];
|
|
368
|
-
/**
|
|
369
|
-
|
|
370
|
-
/** Extra HTTP headers attached to every model request (e.g. Kimi For Coding
|
|
371
|
-
* client-identity headers). Merged into the underlying SDK default headers. */
|
|
366
|
+
/** Extra HTTP headers attached to every model request. Merged into the
|
|
367
|
+
* underlying SDK default headers. */
|
|
372
368
|
defaultHeaders?: StreamOptions["defaultHeaders"];
|
|
373
369
|
/** Provider-specific request-body fields forwarded to every model request
|
|
374
370
|
* (e.g. OpenRouter `provider: { zdr: true }`). See gg-ai `ProviderOptions`. */
|
|
@@ -377,9 +373,7 @@ interface AgentOptions {
|
|
|
377
373
|
fetch?: StreamOptions["fetch"];
|
|
378
374
|
/** OpenAI service tier for latency-sensitive first-party API requests. */
|
|
379
375
|
serviceTier?: StreamOptions["serviceTier"];
|
|
380
|
-
/**
|
|
381
|
-
responsesLite?: StreamOptions["responsesLite"];
|
|
382
|
-
/** Codex strict tool schema override (see StreamOptions). */
|
|
376
|
+
/** OpenAI strict tool schema override (see StreamOptions). */
|
|
383
377
|
strictTools?: StreamOptions["strictTools"];
|
|
384
378
|
/** Whether the target model supports image input. When false, image blocks
|
|
385
379
|
* in messages/tool_results are downgraded to text placeholders. Default: true. */
|
|
@@ -579,6 +573,7 @@ declare function cancelledBeforeStartText(name: string): string;
|
|
|
579
573
|
* something never ran when it did.
|
|
580
574
|
*/
|
|
581
575
|
declare function indeterminateOutcomeText(name: string): string;
|
|
576
|
+
declare function capToolResults(toolResults: ToolResult[], maxToolResultChars: number | undefined): void;
|
|
582
577
|
declare function repairToolPairingAdjacent(messages: Message[]): void;
|
|
583
578
|
|
|
584
579
|
/**
|
|
@@ -590,4 +585,14 @@ declare function repairToolPairingAdjacent(messages: Message[]): void;
|
|
|
590
585
|
*/
|
|
591
586
|
declare function isLocalBackendUrl(baseUrl?: string): boolean;
|
|
592
587
|
|
|
593
|
-
|
|
588
|
+
/** Result text for a call naming a tool that is not registered. */
|
|
589
|
+
declare function unknownToolMessage(name: string, available: readonly string[]): string;
|
|
590
|
+
/**
|
|
591
|
+
* Repair hints appended to an invalid-arguments error: the expected shape
|
|
592
|
+
* (`{ file_path: string, limit?: number }`) and, for each unrecognised key the
|
|
593
|
+
* model sent, the field it most likely meant. Empty when the schema has no
|
|
594
|
+
* object shape to describe.
|
|
595
|
+
*/
|
|
596
|
+
declare function argumentHints(tool: AgentTool, args: unknown): string;
|
|
597
|
+
|
|
598
|
+
export { Agent, type AgentDoneEvent, type AgentErrorEvent, type AgentEvent, type AgentFollowUpMessageEvent, type AgentOptions, type AgentResult, type AgentRetryEvent, type AgentServerToolCallEvent, type AgentServerToolResultEvent, type AgentSteeringMessageEvent, AgentStream, type AgentStreamRuleTriggeredEvent, type AgentTextDeltaEvent, type AgentThinkingDeltaEvent, type AgentTool, type AgentToolCallDeltaEvent, type AgentToolCallEndEvent, type AgentToolCallStartEvent, type AgentToolCallUpdateEvent, type AgentTurnEndEvent, type AgentTurnTiming, DEFAULT_STREAM_RULE_MAX_RETRIES, DEFAULT_STREAM_RULE_WINDOW_CHARS, JsonEscapeDecoder, type StreamDiagnosticFn, type StreamRule, type StreamRuleMatch, StreamRuleMonitor, type StreamRuleScope, type StreamRuleSource, type StreamRulesConfig, type StructuredToolResult, type ToolContext, type ToolExecuteResult, type ToolExecutionMode, type TransformContextOptions, agentLoop, argumentHints, buildStreamRuleReminder, cancelledBeforeStartText, capToolResults, indeterminateOutcomeText, isAbortError, isBillingError, isContextOverflow, isLocalBackendUrl, isUsageLimitError, repairToolPairingAdjacent, setStreamDiagnostic, unknownToolMessage };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Message, StreamOptions, Tool, ToolResultContent, ServerToolDefinition, Usage, StopReason, AssistantMessage } from '@kenkaiiii/gg-ai';
|
|
1
|
+
import { Message, StreamOptions, Tool, ToolResultContent, ServerToolDefinition, Usage, StopReason, AssistantMessage, ToolResult } from '@kenkaiiii/gg-ai';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -348,27 +348,23 @@ interface AgentOptions {
|
|
|
348
348
|
* turn fails with an authentication error. Returning the current credential
|
|
349
349
|
* here keeps a long run alive across rotations.
|
|
350
350
|
*
|
|
351
|
-
* Falls back to `apiKey`/`accountId
|
|
351
|
+
* Falls back to `apiKey`/`accountId` when omitted or when the
|
|
352
352
|
* resolver throws (the provider call then surfaces the real auth error).
|
|
353
353
|
*/
|
|
354
354
|
resolveCredentials?: () => Promise<{
|
|
355
355
|
apiKey: string;
|
|
356
356
|
accountId?: string;
|
|
357
|
-
projectId?: string;
|
|
358
357
|
}>;
|
|
359
358
|
baseUrl?: string;
|
|
360
359
|
signal?: AbortSignal;
|
|
361
360
|
accountId?: string;
|
|
362
361
|
transportSessionId?: StreamOptions["transportSessionId"];
|
|
363
|
-
projectId?: StreamOptions["projectId"];
|
|
364
362
|
cacheRetention?: StreamOptions["cacheRetention"];
|
|
365
363
|
onContextPrepared?: StreamOptions["onContextPrepared"];
|
|
366
364
|
/** Stable per-session cache routing key for providers that support it. */
|
|
367
365
|
promptCacheKey?: StreamOptions["promptCacheKey"];
|
|
368
|
-
/**
|
|
369
|
-
|
|
370
|
-
/** Extra HTTP headers attached to every model request (e.g. Kimi For Coding
|
|
371
|
-
* client-identity headers). Merged into the underlying SDK default headers. */
|
|
366
|
+
/** Extra HTTP headers attached to every model request. Merged into the
|
|
367
|
+
* underlying SDK default headers. */
|
|
372
368
|
defaultHeaders?: StreamOptions["defaultHeaders"];
|
|
373
369
|
/** Provider-specific request-body fields forwarded to every model request
|
|
374
370
|
* (e.g. OpenRouter `provider: { zdr: true }`). See gg-ai `ProviderOptions`. */
|
|
@@ -377,9 +373,7 @@ interface AgentOptions {
|
|
|
377
373
|
fetch?: StreamOptions["fetch"];
|
|
378
374
|
/** OpenAI service tier for latency-sensitive first-party API requests. */
|
|
379
375
|
serviceTier?: StreamOptions["serviceTier"];
|
|
380
|
-
/**
|
|
381
|
-
responsesLite?: StreamOptions["responsesLite"];
|
|
382
|
-
/** Codex strict tool schema override (see StreamOptions). */
|
|
376
|
+
/** OpenAI strict tool schema override (see StreamOptions). */
|
|
383
377
|
strictTools?: StreamOptions["strictTools"];
|
|
384
378
|
/** Whether the target model supports image input. When false, image blocks
|
|
385
379
|
* in messages/tool_results are downgraded to text placeholders. Default: true. */
|
|
@@ -579,6 +573,7 @@ declare function cancelledBeforeStartText(name: string): string;
|
|
|
579
573
|
* something never ran when it did.
|
|
580
574
|
*/
|
|
581
575
|
declare function indeterminateOutcomeText(name: string): string;
|
|
576
|
+
declare function capToolResults(toolResults: ToolResult[], maxToolResultChars: number | undefined): void;
|
|
582
577
|
declare function repairToolPairingAdjacent(messages: Message[]): void;
|
|
583
578
|
|
|
584
579
|
/**
|
|
@@ -590,4 +585,14 @@ declare function repairToolPairingAdjacent(messages: Message[]): void;
|
|
|
590
585
|
*/
|
|
591
586
|
declare function isLocalBackendUrl(baseUrl?: string): boolean;
|
|
592
587
|
|
|
593
|
-
|
|
588
|
+
/** Result text for a call naming a tool that is not registered. */
|
|
589
|
+
declare function unknownToolMessage(name: string, available: readonly string[]): string;
|
|
590
|
+
/**
|
|
591
|
+
* Repair hints appended to an invalid-arguments error: the expected shape
|
|
592
|
+
* (`{ file_path: string, limit?: number }`) and, for each unrecognised key the
|
|
593
|
+
* model sent, the field it most likely meant. Empty when the schema has no
|
|
594
|
+
* object shape to describe.
|
|
595
|
+
*/
|
|
596
|
+
declare function argumentHints(tool: AgentTool, args: unknown): string;
|
|
597
|
+
|
|
598
|
+
export { Agent, type AgentDoneEvent, type AgentErrorEvent, type AgentEvent, type AgentFollowUpMessageEvent, type AgentOptions, type AgentResult, type AgentRetryEvent, type AgentServerToolCallEvent, type AgentServerToolResultEvent, type AgentSteeringMessageEvent, AgentStream, type AgentStreamRuleTriggeredEvent, type AgentTextDeltaEvent, type AgentThinkingDeltaEvent, type AgentTool, type AgentToolCallDeltaEvent, type AgentToolCallEndEvent, type AgentToolCallStartEvent, type AgentToolCallUpdateEvent, type AgentTurnEndEvent, type AgentTurnTiming, DEFAULT_STREAM_RULE_MAX_RETRIES, DEFAULT_STREAM_RULE_WINDOW_CHARS, JsonEscapeDecoder, type StreamDiagnosticFn, type StreamRule, type StreamRuleMatch, StreamRuleMonitor, type StreamRuleScope, type StreamRuleSource, type StreamRulesConfig, type StructuredToolResult, type ToolContext, type ToolExecuteResult, type ToolExecutionMode, type TransformContextOptions, agentLoop, argumentHints, buildStreamRuleReminder, cancelledBeforeStartText, capToolResults, indeterminateOutcomeText, isAbortError, isBillingError, isContextOverflow, isLocalBackendUrl, isUsageLimitError, repairToolPairingAdjacent, setStreamDiagnostic, unknownToolMessage };
|
package/dist/index.js
CHANGED
|
@@ -899,13 +899,11 @@ async function* agentLoop(messages, options) {
|
|
|
899
899
|
providerAttemptStartedAt = streamCallStart;
|
|
900
900
|
let liveApiKey = options.apiKey;
|
|
901
901
|
let liveAccountId = options.accountId;
|
|
902
|
-
let liveProjectId = options.projectId;
|
|
903
902
|
if (options.resolveCredentials) {
|
|
904
903
|
try {
|
|
905
904
|
const fresh = await options.resolveCredentials();
|
|
906
905
|
liveApiKey = fresh.apiKey;
|
|
907
|
-
|
|
908
|
-
if (fresh.projectId !== void 0) liveProjectId = fresh.projectId;
|
|
906
|
+
liveAccountId = fresh.accountId;
|
|
909
907
|
} catch (credErr) {
|
|
910
908
|
diag("credential_refresh_failed", {
|
|
911
909
|
error: (credErr instanceof Error ? credErr.message : String(credErr)).slice(0, 200)
|
|
@@ -965,19 +963,16 @@ async function* agentLoop(messages, options) {
|
|
|
965
963
|
signal,
|
|
966
964
|
accountId: liveAccountId,
|
|
967
965
|
transportSessionId: options.transportSessionId,
|
|
968
|
-
projectId: liveProjectId,
|
|
969
966
|
cacheRetention: options.cacheRetention,
|
|
970
967
|
// A hedge duplicates an already-observed request; observe it once.
|
|
971
968
|
onContextPrepared: arm === "primary" ? options.onContextPrepared : void 0,
|
|
972
969
|
promptCacheKey: options.promptCacheKey,
|
|
973
970
|
serviceTier: options.serviceTier,
|
|
974
|
-
responsesLite: options.responsesLite,
|
|
975
971
|
strictTools: options.strictTools,
|
|
976
972
|
supportsImages: options.supportsImages,
|
|
977
973
|
supportsVideo: options.supportsVideo,
|
|
978
974
|
compaction: options.compaction,
|
|
979
975
|
clearToolUses: options.clearToolUses,
|
|
980
|
-
userAgent: options.userAgent,
|
|
981
976
|
defaultHeaders: options.defaultHeaders,
|
|
982
977
|
providerOptions: options.providerOptions,
|
|
983
978
|
fetch: options.fetch,
|
|
@@ -2542,8 +2537,10 @@ export {
|
|
|
2542
2537
|
JsonEscapeDecoder,
|
|
2543
2538
|
StreamRuleMonitor,
|
|
2544
2539
|
agentLoop,
|
|
2540
|
+
argumentHints,
|
|
2545
2541
|
buildStreamRuleReminder,
|
|
2546
2542
|
cancelledBeforeStartText,
|
|
2543
|
+
capToolResults,
|
|
2547
2544
|
indeterminateOutcomeText,
|
|
2548
2545
|
isAbortError,
|
|
2549
2546
|
isBillingError,
|
|
@@ -2551,6 +2548,7 @@ export {
|
|
|
2551
2548
|
isLocalBackendUrl,
|
|
2552
2549
|
isUsageLimitError,
|
|
2553
2550
|
repairToolPairingAdjacent,
|
|
2554
|
-
setStreamDiagnostic
|
|
2551
|
+
setStreamDiagnostic,
|
|
2552
|
+
unknownToolMessage
|
|
2555
2553
|
};
|
|
2556
2554
|
//# sourceMappingURL=index.js.map
|