@genesislcap/ai-assistant 14.496.0 → 14.496.1-GENC-1461.4
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/ai-assistant.api.json +132 -0
- package/dist/ai-assistant.d.ts +35 -0
- package/dist/chat-driver.cjs +163 -6
- package/dist/chat-driver.cjs.map +4 -4
- package/dist/chat-driver.mjs +157 -6
- package/dist/chat-driver.mjs.map +4 -4
- package/dist/custom-elements.json +156 -1
- package/dist/dts/chat-driver-node.d.ts +7 -1
- package/dist/dts/chat-driver-node.d.ts.map +1 -1
- package/dist/dts/components/ai-driver/ai-driver.d.ts +8 -0
- package/dist/dts/components/ai-driver/ai-driver.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/chat-driver.d.ts +27 -0
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts +3 -0
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts.map +1 -1
- package/dist/dts/main/main.d.ts.map +1 -1
- package/dist/dts/state/debug-event-log.d.ts +1 -1
- package/dist/dts/state/debug-event-log.d.ts.map +1 -1
- package/dist/dts/state/persistence/build-timeline-entries.d.ts +37 -0
- package/dist/dts/state/persistence/build-timeline-entries.d.ts.map +1 -0
- package/dist/esm/chat-driver-node.js +16 -1
- package/dist/esm/components/chat-driver/chat-driver.js +108 -14
- package/dist/esm/components/chat-driver/chat-driver.test.js +119 -0
- package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +4 -0
- package/dist/esm/main/main.js +18 -28
- package/dist/esm/state/debug-event-log.js +1 -0
- package/dist/esm/state/persistence/build-timeline-entries.js +46 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/src/chat-driver-node.ts +20 -0
- package/src/components/ai-driver/ai-driver.ts +9 -0
- package/src/components/chat-driver/chat-driver.test.ts +160 -0
- package/src/components/chat-driver/chat-driver.ts +106 -7
- package/src/components/orchestrating-driver/orchestrating-driver.ts +6 -0
- package/src/main/main.ts +17 -30
- package/src/state/debug-event-log.ts +3 -0
- package/src/state/persistence/build-timeline-entries.ts +66 -0
|
@@ -2780,6 +2780,48 @@
|
|
|
2780
2780
|
"parameters": [],
|
|
2781
2781
|
"name": "getActiveProviderName"
|
|
2782
2782
|
},
|
|
2783
|
+
{
|
|
2784
|
+
"kind": "MethodSignature",
|
|
2785
|
+
"canonicalReference": "@genesislcap/ai-assistant!AiDriver#getExternalDiagnostics:member(1)",
|
|
2786
|
+
"docComment": "/**\n * Diagnostic-log entries harvested from resolved interactions (e.g. a server-side ChatDriver's collated debug log, returned on `InteractionResult.diagnostics`). The host folds these into its debug log. Optional for the same leaf/orchestrator reason as `getTurnSnapshots`. (GENC-1461 unified diagnostics.)\n */\n",
|
|
2787
|
+
"excerptTokens": [
|
|
2788
|
+
{
|
|
2789
|
+
"kind": "Content",
|
|
2790
|
+
"text": "getExternalDiagnostics?(): "
|
|
2791
|
+
},
|
|
2792
|
+
{
|
|
2793
|
+
"kind": "Reference",
|
|
2794
|
+
"text": "ReadonlyArray",
|
|
2795
|
+
"canonicalReference": "!ReadonlyArray:interface"
|
|
2796
|
+
},
|
|
2797
|
+
{
|
|
2798
|
+
"kind": "Content",
|
|
2799
|
+
"text": "<"
|
|
2800
|
+
},
|
|
2801
|
+
{
|
|
2802
|
+
"kind": "Reference",
|
|
2803
|
+
"text": "DiagnosticEntry",
|
|
2804
|
+
"canonicalReference": "@genesislcap/ai-assistant!DiagnosticEntry:interface"
|
|
2805
|
+
},
|
|
2806
|
+
{
|
|
2807
|
+
"kind": "Content",
|
|
2808
|
+
"text": ">"
|
|
2809
|
+
},
|
|
2810
|
+
{
|
|
2811
|
+
"kind": "Content",
|
|
2812
|
+
"text": ";"
|
|
2813
|
+
}
|
|
2814
|
+
],
|
|
2815
|
+
"isOptional": true,
|
|
2816
|
+
"returnTypeTokenRange": {
|
|
2817
|
+
"startIndex": 1,
|
|
2818
|
+
"endIndex": 5
|
|
2819
|
+
},
|
|
2820
|
+
"releaseTag": "Beta",
|
|
2821
|
+
"overloadIndex": 1,
|
|
2822
|
+
"parameters": [],
|
|
2823
|
+
"name": "getExternalDiagnostics"
|
|
2824
|
+
},
|
|
2783
2825
|
{
|
|
2784
2826
|
"kind": "MethodSignature",
|
|
2785
2827
|
"canonicalReference": "@genesislcap/ai-assistant!AiDriver#getInteractionContext:member(1)",
|
|
@@ -4565,6 +4607,51 @@
|
|
|
4565
4607
|
"isAbstract": false,
|
|
4566
4608
|
"name": "getAgentReleaseRequested"
|
|
4567
4609
|
},
|
|
4610
|
+
{
|
|
4611
|
+
"kind": "Method",
|
|
4612
|
+
"canonicalReference": "@genesislcap/ai-assistant!ChatDriver#getExternalDiagnostics:member(1)",
|
|
4613
|
+
"docComment": "/**\n * The `turn` + `message` diagnostic-log entries harvested from resolved interactions' `InteractionResult.diagnostics` (e.g. a server-side ChatDriver's collated debug log). The host concatenates these into its own debug log so `downloadDebugLog`/the persisted diagnostics stream include external-engine logs; `event` entries are excluded here because they're merged into the session's meta-event registry instead (see `resolveInteraction`) and reach the log via `getMetaEvents`. Opaque, chronologically sorted by the host at assemble time. (GENC-1461.)\n */\n",
|
|
4614
|
+
"excerptTokens": [
|
|
4615
|
+
{
|
|
4616
|
+
"kind": "Content",
|
|
4617
|
+
"text": "getExternalDiagnostics(): "
|
|
4618
|
+
},
|
|
4619
|
+
{
|
|
4620
|
+
"kind": "Reference",
|
|
4621
|
+
"text": "ReadonlyArray",
|
|
4622
|
+
"canonicalReference": "!ReadonlyArray:interface"
|
|
4623
|
+
},
|
|
4624
|
+
{
|
|
4625
|
+
"kind": "Content",
|
|
4626
|
+
"text": "<"
|
|
4627
|
+
},
|
|
4628
|
+
{
|
|
4629
|
+
"kind": "Reference",
|
|
4630
|
+
"text": "DiagnosticEntry",
|
|
4631
|
+
"canonicalReference": "@genesislcap/ai-assistant!DiagnosticEntry:interface"
|
|
4632
|
+
},
|
|
4633
|
+
{
|
|
4634
|
+
"kind": "Content",
|
|
4635
|
+
"text": ">"
|
|
4636
|
+
},
|
|
4637
|
+
{
|
|
4638
|
+
"kind": "Content",
|
|
4639
|
+
"text": ";"
|
|
4640
|
+
}
|
|
4641
|
+
],
|
|
4642
|
+
"isStatic": false,
|
|
4643
|
+
"returnTypeTokenRange": {
|
|
4644
|
+
"startIndex": 1,
|
|
4645
|
+
"endIndex": 5
|
|
4646
|
+
},
|
|
4647
|
+
"releaseTag": "Beta",
|
|
4648
|
+
"isProtected": false,
|
|
4649
|
+
"overloadIndex": 1,
|
|
4650
|
+
"parameters": [],
|
|
4651
|
+
"isOptional": false,
|
|
4652
|
+
"isAbstract": false,
|
|
4653
|
+
"name": "getExternalDiagnostics"
|
|
4654
|
+
},
|
|
4568
4655
|
{
|
|
4569
4656
|
"kind": "Method",
|
|
4570
4657
|
"canonicalReference": "@genesislcap/ai-assistant!ChatDriver#getHistory:member(1)",
|
|
@@ -13282,6 +13369,51 @@
|
|
|
13282
13369
|
"isAbstract": false,
|
|
13283
13370
|
"name": "getActiveProviderName"
|
|
13284
13371
|
},
|
|
13372
|
+
{
|
|
13373
|
+
"kind": "Method",
|
|
13374
|
+
"canonicalReference": "@genesislcap/ai-assistant!OrchestratingDriver#getExternalDiagnostics:member(1)",
|
|
13375
|
+
"docComment": "/**\n * Delegates to the inner {@link ChatDriver} — interactions resolve there, so it holds the buffer.\n */\n",
|
|
13376
|
+
"excerptTokens": [
|
|
13377
|
+
{
|
|
13378
|
+
"kind": "Content",
|
|
13379
|
+
"text": "getExternalDiagnostics(): "
|
|
13380
|
+
},
|
|
13381
|
+
{
|
|
13382
|
+
"kind": "Reference",
|
|
13383
|
+
"text": "ReadonlyArray",
|
|
13384
|
+
"canonicalReference": "!ReadonlyArray:interface"
|
|
13385
|
+
},
|
|
13386
|
+
{
|
|
13387
|
+
"kind": "Content",
|
|
13388
|
+
"text": "<"
|
|
13389
|
+
},
|
|
13390
|
+
{
|
|
13391
|
+
"kind": "Reference",
|
|
13392
|
+
"text": "DiagnosticEntry",
|
|
13393
|
+
"canonicalReference": "@genesislcap/ai-assistant!DiagnosticEntry:interface"
|
|
13394
|
+
},
|
|
13395
|
+
{
|
|
13396
|
+
"kind": "Content",
|
|
13397
|
+
"text": ">"
|
|
13398
|
+
},
|
|
13399
|
+
{
|
|
13400
|
+
"kind": "Content",
|
|
13401
|
+
"text": ";"
|
|
13402
|
+
}
|
|
13403
|
+
],
|
|
13404
|
+
"isStatic": false,
|
|
13405
|
+
"returnTypeTokenRange": {
|
|
13406
|
+
"startIndex": 1,
|
|
13407
|
+
"endIndex": 5
|
|
13408
|
+
},
|
|
13409
|
+
"releaseTag": "Beta",
|
|
13410
|
+
"isProtected": false,
|
|
13411
|
+
"overloadIndex": 1,
|
|
13412
|
+
"parameters": [],
|
|
13413
|
+
"isOptional": false,
|
|
13414
|
+
"isAbstract": false,
|
|
13415
|
+
"name": "getExternalDiagnostics"
|
|
13416
|
+
},
|
|
13285
13417
|
{
|
|
13286
13418
|
"kind": "Method",
|
|
13287
13419
|
"canonicalReference": "@genesislcap/ai-assistant!OrchestratingDriver#getInteractionContext:member(1)",
|
package/dist/ai-assistant.d.ts
CHANGED
|
@@ -604,6 +604,13 @@ export declare interface AiDriver extends EventTarget {
|
|
|
604
604
|
* orchestrator just delegates to its inner `ChatDriver`.
|
|
605
605
|
*/
|
|
606
606
|
getTurnSnapshots?(): ReadonlyArray<TurnSnapshot>;
|
|
607
|
+
/**
|
|
608
|
+
* Diagnostic-log entries harvested from resolved interactions (e.g. a server-side ChatDriver's
|
|
609
|
+
* collated debug log, returned on `InteractionResult.diagnostics`). The host folds these into its
|
|
610
|
+
* debug log. Optional for the same leaf/orchestrator reason as `getTurnSnapshots`.
|
|
611
|
+
* (GENC-1461 unified diagnostics.)
|
|
612
|
+
*/
|
|
613
|
+
getExternalDiagnostics?(): ReadonlyArray<DiagnosticEntry>;
|
|
607
614
|
/**
|
|
608
615
|
* Name of the AI provider used on the most recent turn. Falls back to the
|
|
609
616
|
* registry's default name when no turn has run yet.
|
|
@@ -1190,6 +1197,23 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
1190
1197
|
* arrive. See {@link TurnSnapshot} for the captured shape.
|
|
1191
1198
|
*/
|
|
1192
1199
|
private turnSnapshots;
|
|
1200
|
+
/**
|
|
1201
|
+
* `turn` + `message` diagnostic-log entries harvested from an out-of-band source (a resolved
|
|
1202
|
+
* interaction whose widget returned `InteractionResult.diagnostics` — e.g. a server-side
|
|
1203
|
+
* ChatDriver's debug log). `event` entries are NOT kept here — they're folded into the session's
|
|
1204
|
+
* meta-event registry via `mergeMetaEvents` (see `resolveInteraction`) so they inherit fresh host
|
|
1205
|
+
* indices, and reach the log through `getMetaEvents`. Append-only; the host folds these into its
|
|
1206
|
+
* debug log alongside this driver's own timeline. Not cleared here — it lives with the driver
|
|
1207
|
+
* instance, like `turnSnapshots`, so a new chat (fresh driver) starts empty while a compaction
|
|
1208
|
+
* (same instance) keeps it. (GENC-1461.)
|
|
1209
|
+
*/
|
|
1210
|
+
private readonly externalDiagnostics;
|
|
1211
|
+
/**
|
|
1212
|
+
* Monotonic count of external-diagnostics batches harvested this driver-lifetime. Namespaces each
|
|
1213
|
+
* batch's re-keyed `turn` entries so distinct server generations in one chat session can't collide
|
|
1214
|
+
* on `turnIndex` in the forward-capture persister (which dedups turns by that key). (GENC-1461.)
|
|
1215
|
+
*/
|
|
1216
|
+
private externalDiagnosticsBatches;
|
|
1193
1217
|
/** Monotonic counter that survives agent swaps — useful for cross-referencing with history. */
|
|
1194
1218
|
private globalTurnIndex;
|
|
1195
1219
|
/** Captured from `applyAgent` so we don't store the whole `AgentConfig`. */
|
|
@@ -1444,6 +1468,15 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
1444
1468
|
* Ring-buffered at `MAX_TURN_SNAPSHOTS`; older entries are dropped.
|
|
1445
1469
|
*/
|
|
1446
1470
|
getTurnSnapshots(): ReadonlyArray<TurnSnapshot>;
|
|
1471
|
+
/**
|
|
1472
|
+
* The `turn` + `message` diagnostic-log entries harvested from resolved interactions'
|
|
1473
|
+
* `InteractionResult.diagnostics` (e.g. a server-side ChatDriver's collated debug log). The host
|
|
1474
|
+
* concatenates these into its own debug log so `downloadDebugLog`/the persisted diagnostics stream
|
|
1475
|
+
* include external-engine logs; `event` entries are excluded here because they're merged into the
|
|
1476
|
+
* session's meta-event registry instead (see `resolveInteraction`) and reach the log via
|
|
1477
|
+
* `getMetaEvents`. Opaque, chronologically sorted by the host at assemble time. (GENC-1461.)
|
|
1478
|
+
*/
|
|
1479
|
+
getExternalDiagnostics(): ReadonlyArray<DiagnosticEntry>;
|
|
1447
1480
|
/**
|
|
1448
1481
|
* Merge a sub-agent's turn snapshots into this driver's buffer so they surface
|
|
1449
1482
|
* as `kind:'turn'` entries in the exported debug log. The child runs as a
|
|
@@ -3079,6 +3112,8 @@ export declare class OrchestratingDriver extends EventTarget implements AiDriver
|
|
|
3079
3112
|
canCompact(): boolean;
|
|
3080
3113
|
/** Delegates to the inner {@link ChatDriver} — turns are captured there. */
|
|
3081
3114
|
getTurnSnapshots(): ReadonlyArray<TurnSnapshot>;
|
|
3115
|
+
/** Delegates to the inner {@link ChatDriver} — interactions resolve there, so it holds the buffer. */
|
|
3116
|
+
getExternalDiagnostics(): ReadonlyArray<DiagnosticEntry>;
|
|
3082
3117
|
getSuggestions(history: ChatMessage[], prompt: string, count: number, allAgentInfo?: AllAgentSummary[]): Promise<string[]>;
|
|
3083
3118
|
sendMessage(input: string, attachments?: ChatAttachment[]): Promise<ChatDriverResult>;
|
|
3084
3119
|
continueFromHistory(transientPrimer?: ChatMessage[]): Promise<ChatDriverResult>;
|
package/dist/chat-driver.cjs
CHANGED
|
@@ -29,10 +29,16 @@ __export(chat_driver_node_exports, {
|
|
|
29
29
|
NOOP_ACTIVITY_BUS: () => NOOP_ACTIVITY_BUS,
|
|
30
30
|
OrchestratingDriver: () => OrchestratingDriver,
|
|
31
31
|
REQUEST_CONTINUATION_TOOL: () => REQUEST_CONTINUATION_TOOL,
|
|
32
|
+
SUPPORTED_ANTHROPIC_MODEL_IDS: () => SUPPORTED_ANTHROPIC_MODEL_IDS,
|
|
33
|
+
SUPPORTED_GEMINI_MODEL_IDS: () => SUPPORTED_GEMINI_MODEL_IDS,
|
|
32
34
|
agenticActivityBus: () => agenticActivityBus,
|
|
35
|
+
assembleDebugLog: () => assembleDebugLog,
|
|
36
|
+
buildTimelineEntries: () => buildTimelineEntries,
|
|
37
|
+
clearSession: () => clearSession,
|
|
33
38
|
defineAgent: () => defineAgent,
|
|
34
39
|
defineStatefulAgent: () => defineStatefulAgent,
|
|
35
40
|
friendlyFallbackAgent: () => friendlyFallbackAgent,
|
|
41
|
+
getMetaEvents: () => getMetaEvents,
|
|
36
42
|
isObservableAIProviderRegistry: () => isObservableAIProviderRegistry,
|
|
37
43
|
restoreMachine: () => restoreMachine,
|
|
38
44
|
strictFallbackAgent: () => strictFallbackAgent
|
|
@@ -2630,6 +2636,7 @@ var META_EVENT_IMPORTANCE = {
|
|
|
2630
2636
|
"provider.selected": "normal",
|
|
2631
2637
|
"interaction.requested": "normal",
|
|
2632
2638
|
"interaction.resolved": "normal",
|
|
2639
|
+
"external-diagnostics.folded": "normal",
|
|
2633
2640
|
"session.cleared": "normal",
|
|
2634
2641
|
"session.switched": "low",
|
|
2635
2642
|
"session.switch-deferred": "low",
|
|
@@ -3126,6 +3133,23 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
3126
3133
|
* arrive. See {@link TurnSnapshot} for the captured shape.
|
|
3127
3134
|
*/
|
|
3128
3135
|
this.turnSnapshots = [];
|
|
3136
|
+
/**
|
|
3137
|
+
* `turn` + `message` diagnostic-log entries harvested from an out-of-band source (a resolved
|
|
3138
|
+
* interaction whose widget returned `InteractionResult.diagnostics` — e.g. a server-side
|
|
3139
|
+
* ChatDriver's debug log). `event` entries are NOT kept here — they're folded into the session's
|
|
3140
|
+
* meta-event registry via `mergeMetaEvents` (see `resolveInteraction`) so they inherit fresh host
|
|
3141
|
+
* indices, and reach the log through `getMetaEvents`. Append-only; the host folds these into its
|
|
3142
|
+
* debug log alongside this driver's own timeline. Not cleared here — it lives with the driver
|
|
3143
|
+
* instance, like `turnSnapshots`, so a new chat (fresh driver) starts empty while a compaction
|
|
3144
|
+
* (same instance) keeps it. (GENC-1461.)
|
|
3145
|
+
*/
|
|
3146
|
+
this.externalDiagnostics = [];
|
|
3147
|
+
/**
|
|
3148
|
+
* Monotonic count of external-diagnostics batches harvested this driver-lifetime. Namespaces each
|
|
3149
|
+
* batch's re-keyed `turn` entries so distinct server generations in one chat session can't collide
|
|
3150
|
+
* on `turnIndex` in the forward-capture persister (which dedups turns by that key). (GENC-1461.)
|
|
3151
|
+
*/
|
|
3152
|
+
this.externalDiagnosticsBatches = 0;
|
|
3129
3153
|
/** Monotonic counter that survives agent swaps — useful for cross-referencing with history. */
|
|
3130
3154
|
this.globalTurnIndex = 0;
|
|
3131
3155
|
/**
|
|
@@ -3500,6 +3524,17 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
3500
3524
|
getTurnSnapshots() {
|
|
3501
3525
|
return this.turnSnapshots;
|
|
3502
3526
|
}
|
|
3527
|
+
/**
|
|
3528
|
+
* The `turn` + `message` diagnostic-log entries harvested from resolved interactions'
|
|
3529
|
+
* `InteractionResult.diagnostics` (e.g. a server-side ChatDriver's collated debug log). The host
|
|
3530
|
+
* concatenates these into its own debug log so `downloadDebugLog`/the persisted diagnostics stream
|
|
3531
|
+
* include external-engine logs; `event` entries are excluded here because they're merged into the
|
|
3532
|
+
* session's meta-event registry instead (see `resolveInteraction`) and reach the log via
|
|
3533
|
+
* `getMetaEvents`. Opaque, chronologically sorted by the host at assemble time. (GENC-1461.)
|
|
3534
|
+
*/
|
|
3535
|
+
getExternalDiagnostics() {
|
|
3536
|
+
return this.externalDiagnostics;
|
|
3537
|
+
}
|
|
3503
3538
|
/**
|
|
3504
3539
|
* Merge a sub-agent's turn snapshots into this driver's buffer so they surface
|
|
3505
3540
|
* as `kind:'turn'` entries in the exported debug log. The child runs as a
|
|
@@ -3809,6 +3844,34 @@ Output format (strict):
|
|
|
3809
3844
|
const interaction = this.pendingInteractions.get(interactionId);
|
|
3810
3845
|
if (interaction) {
|
|
3811
3846
|
if (interaction.timeoutHandle) clearTimeout(interaction.timeoutHandle);
|
|
3847
|
+
const harvestedDiagnostics = result?.diagnostics;
|
|
3848
|
+
if (Array.isArray(harvestedDiagnostics) && harvestedDiagnostics.length) {
|
|
3849
|
+
const batch = this.externalDiagnosticsBatches += 1;
|
|
3850
|
+
const externalEvents = [];
|
|
3851
|
+
let turnCount = 0;
|
|
3852
|
+
let messageCount = 0;
|
|
3853
|
+
for (const entry of harvestedDiagnostics) {
|
|
3854
|
+
if (entry.kind === "event") {
|
|
3855
|
+
const { kind: _kind, ...event } = entry;
|
|
3856
|
+
externalEvents.push(event);
|
|
3857
|
+
} else if (entry.kind === "turn") {
|
|
3858
|
+
turnCount += 1;
|
|
3859
|
+
this.externalDiagnostics.push({
|
|
3860
|
+
...entry,
|
|
3861
|
+
turnIndex: `server-generation.${batch}:${String(entry.turnIndex ?? "")}`
|
|
3862
|
+
});
|
|
3863
|
+
} else {
|
|
3864
|
+
messageCount += 1;
|
|
3865
|
+
this.externalDiagnostics.push(entry);
|
|
3866
|
+
}
|
|
3867
|
+
}
|
|
3868
|
+
if (externalEvents.length) mergeMetaEvents(this.sessionKey, externalEvents);
|
|
3869
|
+
recordMetaEvent(this.sessionKey, "external-diagnostics.folded", {
|
|
3870
|
+
interactionId,
|
|
3871
|
+
batch,
|
|
3872
|
+
counts: { turn: turnCount, event: externalEvents.length, message: messageCount }
|
|
3873
|
+
});
|
|
3874
|
+
}
|
|
3812
3875
|
const idx = this.history.findIndex((m) => m.interaction?.interactionId === interactionId);
|
|
3813
3876
|
if (idx !== -1) {
|
|
3814
3877
|
const costUsd = typeof result?.costUsd === "number" && Number.isFinite(result.costUsd) && result.costUsd > 0 ? result.costUsd : void 0;
|
|
@@ -4518,9 +4581,10 @@ ${tailBody}
|
|
|
4518
4581
|
}
|
|
4519
4582
|
const isThinkingStep = response.content && response.toolCalls?.length;
|
|
4520
4583
|
const isEmptyResponse = !response.content?.trim() && !response.toolCalls?.length;
|
|
4584
|
+
const isRefusal = response.responseMeta?.finishReason === "refusal";
|
|
4521
4585
|
if (isEmptyResponse) {
|
|
4522
4586
|
emptyResponseAttempts += 1;
|
|
4523
|
-
if (emptyResponseAttempts < MAX_EMPTY_RESPONSE_RETRIES) {
|
|
4587
|
+
if (!isRefusal && emptyResponseAttempts < MAX_EMPTY_RESPONSE_RETRIES) {
|
|
4524
4588
|
logger2.warn(
|
|
4525
4589
|
`ChatDriver: empty model response, retrying (${emptyResponseAttempts}/${MAX_EMPTY_RESPONSE_RETRIES})`
|
|
4526
4590
|
);
|
|
@@ -4538,8 +4602,11 @@ ${tailBody}
|
|
|
4538
4602
|
iterations -= 1;
|
|
4539
4603
|
continue;
|
|
4540
4604
|
}
|
|
4541
|
-
|
|
4542
|
-
|
|
4605
|
+
const failureReason2 = isRefusal ? "refusal" : "empty-response";
|
|
4606
|
+
logger2.error(
|
|
4607
|
+
isRefusal ? "ChatDriver: model refused the request (safety decline) \u2014 not retrying" : "ChatDriver: empty model response after all retries"
|
|
4608
|
+
);
|
|
4609
|
+
recordTurnError(this.sessionKey, failureReason2, {
|
|
4543
4610
|
agent: this.activeAgentName,
|
|
4544
4611
|
provider: this.lastResolvedProviderName,
|
|
4545
4612
|
attempts: emptyResponseAttempts,
|
|
@@ -4547,14 +4614,14 @@ ${tailBody}
|
|
|
4547
4614
|
...response.responseMeta
|
|
4548
4615
|
});
|
|
4549
4616
|
if (this.isSubAgent) {
|
|
4550
|
-
this.failSubAgent("empty_response");
|
|
4617
|
+
this.failSubAgent(isRefusal ? "refusal" : "empty_response");
|
|
4551
4618
|
} else {
|
|
4552
4619
|
this.appendToHistory({
|
|
4553
4620
|
role: "assistant",
|
|
4554
|
-
content: "While working on your request, I repeatedly generated a blank response. This often works on a second try \u2014 would you like me to try again? If it happens again, try breaking your request into smaller steps."
|
|
4621
|
+
content: isRefusal ? "This request was declined. Try rephrasing it, or breaking it into smaller steps." : "While working on your request, I repeatedly generated a blank response. This often works on a second try \u2014 would you like me to try again? If it happens again, try breaking your request into smaller steps."
|
|
4555
4622
|
});
|
|
4556
4623
|
}
|
|
4557
|
-
return this.turnDone(
|
|
4624
|
+
return this.turnDone(failureReason2);
|
|
4558
4625
|
} else {
|
|
4559
4626
|
const { reasoning, ...rest } = response;
|
|
4560
4627
|
const displayOnly = { cost: void 0, inputTokens: void 0, outputTokens: void 0 };
|
|
@@ -5072,6 +5139,10 @@ var OrchestratingDriver = class extends EventTarget {
|
|
|
5072
5139
|
getTurnSnapshots() {
|
|
5073
5140
|
return this.chatDriver.getTurnSnapshots();
|
|
5074
5141
|
}
|
|
5142
|
+
/** Delegates to the inner {@link ChatDriver} — interactions resolve there, so it holds the buffer. */
|
|
5143
|
+
getExternalDiagnostics() {
|
|
5144
|
+
return this.chatDriver.getExternalDiagnostics();
|
|
5145
|
+
}
|
|
5075
5146
|
async getSuggestions(history, prompt2, count, allAgentInfo) {
|
|
5076
5147
|
const pinned = this.resolvePinnedAgent();
|
|
5077
5148
|
const candidates = pinned && isSpecialist(pinned) ? [pinned] : this.specialists;
|
|
@@ -5585,6 +5656,86 @@ var strictFallbackAgent = {
|
|
|
5585
5656
|
fallback: true,
|
|
5586
5657
|
systemPrompt: `You are a concise assistant. The user's request is outside your scope. Respond with a single short sentence stating what you can assist with. Do not elaborate. The available specialists are: {{agents}}.`
|
|
5587
5658
|
};
|
|
5659
|
+
|
|
5660
|
+
// src/utils/flatten-sub-agent-messages.ts
|
|
5661
|
+
function flattenSubAgentMessages(messages, prefix = "", depth = 0, subAgentOf) {
|
|
5662
|
+
return messages.flatMap((m) => {
|
|
5663
|
+
const breadcrumb = prefix ? `${prefix} \u203A ${m.agentName ?? "?"}` : m.agentName;
|
|
5664
|
+
const traceCalls = m.toolCalls?.filter((tc) => tc.subAgentTrace?.length) ?? [];
|
|
5665
|
+
const entry = {
|
|
5666
|
+
kind: "message",
|
|
5667
|
+
...m,
|
|
5668
|
+
// Move the (about-to-be-hoisted) child conversations out of the emitted tool
|
|
5669
|
+
// calls. Setting it to `undefined` drops the key from the serialized export.
|
|
5670
|
+
...traceCalls.length > 0 && {
|
|
5671
|
+
toolCalls: m.toolCalls.map(
|
|
5672
|
+
(tc) => tc.subAgentTrace ? { ...tc, subAgentTrace: void 0 } : tc
|
|
5673
|
+
)
|
|
5674
|
+
},
|
|
5675
|
+
// Mark + breadcrumb hoisted sub-agent messages; top-level (depth 0) stays as-is.
|
|
5676
|
+
...depth > 0 && {
|
|
5677
|
+
agentName: breadcrumb,
|
|
5678
|
+
subAgentName: m.agentName,
|
|
5679
|
+
subAgentDepth: depth,
|
|
5680
|
+
subAgentOf
|
|
5681
|
+
}
|
|
5682
|
+
};
|
|
5683
|
+
if (traceCalls.length === 0) return [entry];
|
|
5684
|
+
const hoisted = traceCalls.flatMap(
|
|
5685
|
+
(tc) => flattenSubAgentMessages(tc.subAgentTrace, breadcrumb ?? "", depth + 1, tc.id)
|
|
5686
|
+
);
|
|
5687
|
+
return [entry, ...hoisted];
|
|
5688
|
+
});
|
|
5689
|
+
}
|
|
5690
|
+
|
|
5691
|
+
// src/state/persistence/build-timeline-entries.ts
|
|
5692
|
+
function buildTimelineEntries(input) {
|
|
5693
|
+
const { turnSnapshots, messages, metaEvents } = input;
|
|
5694
|
+
let lastFullPrompt;
|
|
5695
|
+
let lastFullIndex = "";
|
|
5696
|
+
const turns = turnSnapshots.map((t) => {
|
|
5697
|
+
let { systemPrompt } = t;
|
|
5698
|
+
if (systemPrompt != null && systemPrompt === lastFullPrompt) {
|
|
5699
|
+
systemPrompt = `<repeated \u2014 identical to turn ${lastFullIndex}>`;
|
|
5700
|
+
} else if (systemPrompt != null) {
|
|
5701
|
+
lastFullPrompt = systemPrompt;
|
|
5702
|
+
lastFullIndex = t.turnIndex;
|
|
5703
|
+
}
|
|
5704
|
+
return { kind: "turn", ...t, systemPrompt };
|
|
5705
|
+
});
|
|
5706
|
+
const messageEntries = flattenSubAgentMessages(messages);
|
|
5707
|
+
const eventEntries = metaEvents.map((e) => ({ kind: "event", ...e }));
|
|
5708
|
+
return [...messageEntries, ...turns, ...eventEntries];
|
|
5709
|
+
}
|
|
5710
|
+
|
|
5711
|
+
// src/state/persistence/diagnostics.ts
|
|
5712
|
+
var KIND_RANK = { event: 0, turn: 1, message: 2 };
|
|
5713
|
+
var UNKNOWN_KIND_RANK = 99;
|
|
5714
|
+
function assembleDebugLog(entries, readme) {
|
|
5715
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5716
|
+
let latestMeta;
|
|
5717
|
+
const timeline = [];
|
|
5718
|
+
for (const entry of entries) {
|
|
5719
|
+
const id = JSON.stringify(entry);
|
|
5720
|
+
if (seen.has(id)) continue;
|
|
5721
|
+
seen.add(id);
|
|
5722
|
+
if (entry.kind === "meta-snapshot") {
|
|
5723
|
+
if (!latestMeta || (entry.timestamp ?? "") >= (latestMeta.timestamp ?? "")) {
|
|
5724
|
+
latestMeta = entry;
|
|
5725
|
+
}
|
|
5726
|
+
} else {
|
|
5727
|
+
timeline.push(entry);
|
|
5728
|
+
}
|
|
5729
|
+
}
|
|
5730
|
+
timeline.sort((a, b) => {
|
|
5731
|
+
const ta = a.timestamp ?? "";
|
|
5732
|
+
const tb = b.timestamp ?? "";
|
|
5733
|
+
if (ta < tb) return -1;
|
|
5734
|
+
if (ta > tb) return 1;
|
|
5735
|
+
return (KIND_RANK[a.kind] ?? UNKNOWN_KIND_RANK) - (KIND_RANK[b.kind] ?? UNKNOWN_KIND_RANK);
|
|
5736
|
+
});
|
|
5737
|
+
return { readme, timeline, meta: latestMeta?.meta };
|
|
5738
|
+
}
|
|
5588
5739
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5589
5740
|
0 && (module.exports = {
|
|
5590
5741
|
AgenticActivityBus,
|
|
@@ -5597,10 +5748,16 @@ var strictFallbackAgent = {
|
|
|
5597
5748
|
NOOP_ACTIVITY_BUS,
|
|
5598
5749
|
OrchestratingDriver,
|
|
5599
5750
|
REQUEST_CONTINUATION_TOOL,
|
|
5751
|
+
SUPPORTED_ANTHROPIC_MODEL_IDS,
|
|
5752
|
+
SUPPORTED_GEMINI_MODEL_IDS,
|
|
5600
5753
|
agenticActivityBus,
|
|
5754
|
+
assembleDebugLog,
|
|
5755
|
+
buildTimelineEntries,
|
|
5756
|
+
clearSession,
|
|
5601
5757
|
defineAgent,
|
|
5602
5758
|
defineStatefulAgent,
|
|
5603
5759
|
friendlyFallbackAgent,
|
|
5760
|
+
getMetaEvents,
|
|
5604
5761
|
isObservableAIProviderRegistry,
|
|
5605
5762
|
restoreMachine,
|
|
5606
5763
|
strictFallbackAgent
|