@genesislcap/ai-assistant 14.498.0 → 14.500.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/ai-assistant.api.json +132 -0
- package/dist/ai-assistant.d.ts +35 -0
- package/dist/chat-driver.cjs +157 -0
- package/dist/chat-driver.cjs.map +3 -3
- package/dist/chat-driver.mjs +151 -0
- package/dist/chat-driver.mjs.map +3 -3
- 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 +103 -0
- package/dist/esm/components/chat-driver/chat-driver.test.js +165 -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 +215 -0
- package/src/components/chat-driver/chat-driver.ts +109 -0
- 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,38 @@ 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 raw of harvestedDiagnostics) {
|
|
3854
|
+
if (!raw || typeof raw !== "object" || typeof raw.kind !== "string") {
|
|
3855
|
+
continue;
|
|
3856
|
+
}
|
|
3857
|
+
const entry = raw;
|
|
3858
|
+
if (entry.kind === "event") {
|
|
3859
|
+
const { kind: _kind, ...event } = entry;
|
|
3860
|
+
externalEvents.push(event);
|
|
3861
|
+
} else if (entry.kind === "turn") {
|
|
3862
|
+
this.externalDiagnostics.push({
|
|
3863
|
+
...entry,
|
|
3864
|
+
turnIndex: `server-generation.${batch}:${turnCount}`
|
|
3865
|
+
});
|
|
3866
|
+
turnCount += 1;
|
|
3867
|
+
} else if (entry.kind === "message") {
|
|
3868
|
+
messageCount += 1;
|
|
3869
|
+
this.externalDiagnostics.push(entry);
|
|
3870
|
+
}
|
|
3871
|
+
}
|
|
3872
|
+
if (externalEvents.length) mergeMetaEvents(this.sessionKey, externalEvents);
|
|
3873
|
+
recordMetaEvent(this.sessionKey, "external-diagnostics.folded", {
|
|
3874
|
+
interactionId,
|
|
3875
|
+
batch,
|
|
3876
|
+
counts: { turn: turnCount, event: externalEvents.length, message: messageCount }
|
|
3877
|
+
});
|
|
3878
|
+
}
|
|
3812
3879
|
const idx = this.history.findIndex((m) => m.interaction?.interactionId === interactionId);
|
|
3813
3880
|
if (idx !== -1) {
|
|
3814
3881
|
const costUsd = typeof result?.costUsd === "number" && Number.isFinite(result.costUsd) && result.costUsd > 0 ? result.costUsd : void 0;
|
|
@@ -5076,6 +5143,10 @@ var OrchestratingDriver = class extends EventTarget {
|
|
|
5076
5143
|
getTurnSnapshots() {
|
|
5077
5144
|
return this.chatDriver.getTurnSnapshots();
|
|
5078
5145
|
}
|
|
5146
|
+
/** Delegates to the inner {@link ChatDriver} — interactions resolve there, so it holds the buffer. */
|
|
5147
|
+
getExternalDiagnostics() {
|
|
5148
|
+
return this.chatDriver.getExternalDiagnostics();
|
|
5149
|
+
}
|
|
5079
5150
|
async getSuggestions(history, prompt2, count, allAgentInfo) {
|
|
5080
5151
|
const pinned = this.resolvePinnedAgent();
|
|
5081
5152
|
const candidates = pinned && isSpecialist(pinned) ? [pinned] : this.specialists;
|
|
@@ -5589,6 +5660,86 @@ var strictFallbackAgent = {
|
|
|
5589
5660
|
fallback: true,
|
|
5590
5661
|
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}}.`
|
|
5591
5662
|
};
|
|
5663
|
+
|
|
5664
|
+
// src/utils/flatten-sub-agent-messages.ts
|
|
5665
|
+
function flattenSubAgentMessages(messages, prefix = "", depth = 0, subAgentOf) {
|
|
5666
|
+
return messages.flatMap((m) => {
|
|
5667
|
+
const breadcrumb = prefix ? `${prefix} \u203A ${m.agentName ?? "?"}` : m.agentName;
|
|
5668
|
+
const traceCalls = m.toolCalls?.filter((tc) => tc.subAgentTrace?.length) ?? [];
|
|
5669
|
+
const entry = {
|
|
5670
|
+
kind: "message",
|
|
5671
|
+
...m,
|
|
5672
|
+
// Move the (about-to-be-hoisted) child conversations out of the emitted tool
|
|
5673
|
+
// calls. Setting it to `undefined` drops the key from the serialized export.
|
|
5674
|
+
...traceCalls.length > 0 && {
|
|
5675
|
+
toolCalls: m.toolCalls.map(
|
|
5676
|
+
(tc) => tc.subAgentTrace ? { ...tc, subAgentTrace: void 0 } : tc
|
|
5677
|
+
)
|
|
5678
|
+
},
|
|
5679
|
+
// Mark + breadcrumb hoisted sub-agent messages; top-level (depth 0) stays as-is.
|
|
5680
|
+
...depth > 0 && {
|
|
5681
|
+
agentName: breadcrumb,
|
|
5682
|
+
subAgentName: m.agentName,
|
|
5683
|
+
subAgentDepth: depth,
|
|
5684
|
+
subAgentOf
|
|
5685
|
+
}
|
|
5686
|
+
};
|
|
5687
|
+
if (traceCalls.length === 0) return [entry];
|
|
5688
|
+
const hoisted = traceCalls.flatMap(
|
|
5689
|
+
(tc) => flattenSubAgentMessages(tc.subAgentTrace, breadcrumb ?? "", depth + 1, tc.id)
|
|
5690
|
+
);
|
|
5691
|
+
return [entry, ...hoisted];
|
|
5692
|
+
});
|
|
5693
|
+
}
|
|
5694
|
+
|
|
5695
|
+
// src/state/persistence/build-timeline-entries.ts
|
|
5696
|
+
function buildTimelineEntries(input) {
|
|
5697
|
+
const { turnSnapshots, messages, metaEvents } = input;
|
|
5698
|
+
let lastFullPrompt;
|
|
5699
|
+
let lastFullIndex = "";
|
|
5700
|
+
const turns = turnSnapshots.map((t) => {
|
|
5701
|
+
let { systemPrompt } = t;
|
|
5702
|
+
if (systemPrompt != null && systemPrompt === lastFullPrompt) {
|
|
5703
|
+
systemPrompt = `<repeated \u2014 identical to turn ${lastFullIndex}>`;
|
|
5704
|
+
} else if (systemPrompt != null) {
|
|
5705
|
+
lastFullPrompt = systemPrompt;
|
|
5706
|
+
lastFullIndex = t.turnIndex;
|
|
5707
|
+
}
|
|
5708
|
+
return { kind: "turn", ...t, systemPrompt };
|
|
5709
|
+
});
|
|
5710
|
+
const messageEntries = flattenSubAgentMessages(messages);
|
|
5711
|
+
const eventEntries = metaEvents.map((e) => ({ kind: "event", ...e }));
|
|
5712
|
+
return [...messageEntries, ...turns, ...eventEntries];
|
|
5713
|
+
}
|
|
5714
|
+
|
|
5715
|
+
// src/state/persistence/diagnostics.ts
|
|
5716
|
+
var KIND_RANK = { event: 0, turn: 1, message: 2 };
|
|
5717
|
+
var UNKNOWN_KIND_RANK = 99;
|
|
5718
|
+
function assembleDebugLog(entries, readme) {
|
|
5719
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5720
|
+
let latestMeta;
|
|
5721
|
+
const timeline = [];
|
|
5722
|
+
for (const entry of entries) {
|
|
5723
|
+
const id = JSON.stringify(entry);
|
|
5724
|
+
if (seen.has(id)) continue;
|
|
5725
|
+
seen.add(id);
|
|
5726
|
+
if (entry.kind === "meta-snapshot") {
|
|
5727
|
+
if (!latestMeta || (entry.timestamp ?? "") >= (latestMeta.timestamp ?? "")) {
|
|
5728
|
+
latestMeta = entry;
|
|
5729
|
+
}
|
|
5730
|
+
} else {
|
|
5731
|
+
timeline.push(entry);
|
|
5732
|
+
}
|
|
5733
|
+
}
|
|
5734
|
+
timeline.sort((a, b) => {
|
|
5735
|
+
const ta = a.timestamp ?? "";
|
|
5736
|
+
const tb = b.timestamp ?? "";
|
|
5737
|
+
if (ta < tb) return -1;
|
|
5738
|
+
if (ta > tb) return 1;
|
|
5739
|
+
return (KIND_RANK[a.kind] ?? UNKNOWN_KIND_RANK) - (KIND_RANK[b.kind] ?? UNKNOWN_KIND_RANK);
|
|
5740
|
+
});
|
|
5741
|
+
return { readme, timeline, meta: latestMeta?.meta };
|
|
5742
|
+
}
|
|
5592
5743
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5593
5744
|
0 && (module.exports = {
|
|
5594
5745
|
AgenticActivityBus,
|
|
@@ -5601,10 +5752,16 @@ var strictFallbackAgent = {
|
|
|
5601
5752
|
NOOP_ACTIVITY_BUS,
|
|
5602
5753
|
OrchestratingDriver,
|
|
5603
5754
|
REQUEST_CONTINUATION_TOOL,
|
|
5755
|
+
SUPPORTED_ANTHROPIC_MODEL_IDS,
|
|
5756
|
+
SUPPORTED_GEMINI_MODEL_IDS,
|
|
5604
5757
|
agenticActivityBus,
|
|
5758
|
+
assembleDebugLog,
|
|
5759
|
+
buildTimelineEntries,
|
|
5760
|
+
clearSession,
|
|
5605
5761
|
defineAgent,
|
|
5606
5762
|
defineStatefulAgent,
|
|
5607
5763
|
friendlyFallbackAgent,
|
|
5764
|
+
getMetaEvents,
|
|
5608
5765
|
isObservableAIProviderRegistry,
|
|
5609
5766
|
restoreMachine,
|
|
5610
5767
|
strictFallbackAgent
|