@genesislcap/ai-assistant 14.496.0 → 14.496.1-GENC-1461.3
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 +24 -0
- package/dist/chat-driver.cjs +127 -6
- package/dist/chat-driver.cjs.map +4 -4
- package/dist/chat-driver.mjs +121 -6
- package/dist/chat-driver.mjs.map +4 -4
- package/dist/custom-elements.json +218 -73
- 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 +16 -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/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 +52 -11
- package/dist/esm/components/chat-driver/chat-driver.test.js +34 -0
- package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +4 -0
- package/dist/esm/main/main.js +18 -28
- 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 +41 -0
- package/src/components/chat-driver/chat-driver.ts +52 -7
- package/src/components/orchestrating-driver/orchestrating-driver.ts +6 -0
- package/src/main/main.ts +17 -30
- 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 * 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. Opaque, chronologically sorted by the host at assemble time. (GENC-1461 unified diagnostics.)\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,14 @@ 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
|
+
* Diagnostic-log entries harvested from an out-of-band source (a resolved interaction whose
|
|
1202
|
+
* widget returned `InteractionResult.diagnostics` — e.g. a server-side ChatDriver's debug log).
|
|
1203
|
+
* Append-only; the host folds these into its debug log alongside this driver's own timeline. Not
|
|
1204
|
+
* cleared here — it lives with the driver instance, like `turnSnapshots`, so a new chat
|
|
1205
|
+
* (fresh driver) starts empty while a compaction (same instance) keeps it. (GENC-1461.)
|
|
1206
|
+
*/
|
|
1207
|
+
private readonly externalDiagnostics;
|
|
1193
1208
|
/** Monotonic counter that survives agent swaps — useful for cross-referencing with history. */
|
|
1194
1209
|
private globalTurnIndex;
|
|
1195
1210
|
/** Captured from `applyAgent` so we don't store the whole `AgentConfig`. */
|
|
@@ -1444,6 +1459,13 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
1444
1459
|
* Ring-buffered at `MAX_TURN_SNAPSHOTS`; older entries are dropped.
|
|
1445
1460
|
*/
|
|
1446
1461
|
getTurnSnapshots(): ReadonlyArray<TurnSnapshot>;
|
|
1462
|
+
/**
|
|
1463
|
+
* Diagnostic-log entries harvested from resolved interactions' `InteractionResult.diagnostics`
|
|
1464
|
+
* (e.g. a server-side ChatDriver's collated debug log). The host concatenates these into its own
|
|
1465
|
+
* debug log so `downloadDebugLog`/the persisted diagnostics stream include external-engine logs.
|
|
1466
|
+
* Opaque, chronologically sorted by the host at assemble time. (GENC-1461 unified diagnostics.)
|
|
1467
|
+
*/
|
|
1468
|
+
getExternalDiagnostics(): ReadonlyArray<DiagnosticEntry>;
|
|
1447
1469
|
/**
|
|
1448
1470
|
* Merge a sub-agent's turn snapshots into this driver's buffer so they surface
|
|
1449
1471
|
* as `kind:'turn'` entries in the exported debug log. The child runs as a
|
|
@@ -3079,6 +3101,8 @@ export declare class OrchestratingDriver extends EventTarget implements AiDriver
|
|
|
3079
3101
|
canCompact(): boolean;
|
|
3080
3102
|
/** Delegates to the inner {@link ChatDriver} — turns are captured there. */
|
|
3081
3103
|
getTurnSnapshots(): ReadonlyArray<TurnSnapshot>;
|
|
3104
|
+
/** Delegates to the inner {@link ChatDriver} — interactions resolve there, so it holds the buffer. */
|
|
3105
|
+
getExternalDiagnostics(): ReadonlyArray<DiagnosticEntry>;
|
|
3082
3106
|
getSuggestions(history: ChatMessage[], prompt: string, count: number, allAgentInfo?: AllAgentSummary[]): Promise<string[]>;
|
|
3083
3107
|
sendMessage(input: string, attachments?: ChatAttachment[]): Promise<ChatDriverResult>;
|
|
3084
3108
|
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
|
|
@@ -3126,6 +3132,14 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
3126
3132
|
* arrive. See {@link TurnSnapshot} for the captured shape.
|
|
3127
3133
|
*/
|
|
3128
3134
|
this.turnSnapshots = [];
|
|
3135
|
+
/**
|
|
3136
|
+
* Diagnostic-log entries harvested from an out-of-band source (a resolved interaction whose
|
|
3137
|
+
* widget returned `InteractionResult.diagnostics` — e.g. a server-side ChatDriver's debug log).
|
|
3138
|
+
* Append-only; the host folds these into its debug log alongside this driver's own timeline. Not
|
|
3139
|
+
* cleared here — it lives with the driver instance, like `turnSnapshots`, so a new chat
|
|
3140
|
+
* (fresh driver) starts empty while a compaction (same instance) keeps it. (GENC-1461.)
|
|
3141
|
+
*/
|
|
3142
|
+
this.externalDiagnostics = [];
|
|
3129
3143
|
/** Monotonic counter that survives agent swaps — useful for cross-referencing with history. */
|
|
3130
3144
|
this.globalTurnIndex = 0;
|
|
3131
3145
|
/**
|
|
@@ -3500,6 +3514,15 @@ var ChatDriver = class _ChatDriver extends EventTarget {
|
|
|
3500
3514
|
getTurnSnapshots() {
|
|
3501
3515
|
return this.turnSnapshots;
|
|
3502
3516
|
}
|
|
3517
|
+
/**
|
|
3518
|
+
* Diagnostic-log entries harvested from resolved interactions' `InteractionResult.diagnostics`
|
|
3519
|
+
* (e.g. a server-side ChatDriver's collated debug log). The host concatenates these into its own
|
|
3520
|
+
* debug log so `downloadDebugLog`/the persisted diagnostics stream include external-engine logs.
|
|
3521
|
+
* Opaque, chronologically sorted by the host at assemble time. (GENC-1461 unified diagnostics.)
|
|
3522
|
+
*/
|
|
3523
|
+
getExternalDiagnostics() {
|
|
3524
|
+
return this.externalDiagnostics;
|
|
3525
|
+
}
|
|
3503
3526
|
/**
|
|
3504
3527
|
* Merge a sub-agent's turn snapshots into this driver's buffer so they surface
|
|
3505
3528
|
* as `kind:'turn'` entries in the exported debug log. The child runs as a
|
|
@@ -3809,6 +3832,10 @@ Output format (strict):
|
|
|
3809
3832
|
const interaction = this.pendingInteractions.get(interactionId);
|
|
3810
3833
|
if (interaction) {
|
|
3811
3834
|
if (interaction.timeoutHandle) clearTimeout(interaction.timeoutHandle);
|
|
3835
|
+
const harvestedDiagnostics = result?.diagnostics;
|
|
3836
|
+
if (Array.isArray(harvestedDiagnostics) && harvestedDiagnostics.length) {
|
|
3837
|
+
this.externalDiagnostics.push(...harvestedDiagnostics);
|
|
3838
|
+
}
|
|
3812
3839
|
const idx = this.history.findIndex((m) => m.interaction?.interactionId === interactionId);
|
|
3813
3840
|
if (idx !== -1) {
|
|
3814
3841
|
const costUsd = typeof result?.costUsd === "number" && Number.isFinite(result.costUsd) && result.costUsd > 0 ? result.costUsd : void 0;
|
|
@@ -4518,9 +4545,10 @@ ${tailBody}
|
|
|
4518
4545
|
}
|
|
4519
4546
|
const isThinkingStep = response.content && response.toolCalls?.length;
|
|
4520
4547
|
const isEmptyResponse = !response.content?.trim() && !response.toolCalls?.length;
|
|
4548
|
+
const isRefusal = response.responseMeta?.finishReason === "refusal";
|
|
4521
4549
|
if (isEmptyResponse) {
|
|
4522
4550
|
emptyResponseAttempts += 1;
|
|
4523
|
-
if (emptyResponseAttempts < MAX_EMPTY_RESPONSE_RETRIES) {
|
|
4551
|
+
if (!isRefusal && emptyResponseAttempts < MAX_EMPTY_RESPONSE_RETRIES) {
|
|
4524
4552
|
logger2.warn(
|
|
4525
4553
|
`ChatDriver: empty model response, retrying (${emptyResponseAttempts}/${MAX_EMPTY_RESPONSE_RETRIES})`
|
|
4526
4554
|
);
|
|
@@ -4538,8 +4566,11 @@ ${tailBody}
|
|
|
4538
4566
|
iterations -= 1;
|
|
4539
4567
|
continue;
|
|
4540
4568
|
}
|
|
4541
|
-
|
|
4542
|
-
|
|
4569
|
+
const failureReason2 = isRefusal ? "refusal" : "empty-response";
|
|
4570
|
+
logger2.error(
|
|
4571
|
+
isRefusal ? "ChatDriver: model refused the request (safety decline) \u2014 not retrying" : "ChatDriver: empty model response after all retries"
|
|
4572
|
+
);
|
|
4573
|
+
recordTurnError(this.sessionKey, failureReason2, {
|
|
4543
4574
|
agent: this.activeAgentName,
|
|
4544
4575
|
provider: this.lastResolvedProviderName,
|
|
4545
4576
|
attempts: emptyResponseAttempts,
|
|
@@ -4547,14 +4578,14 @@ ${tailBody}
|
|
|
4547
4578
|
...response.responseMeta
|
|
4548
4579
|
});
|
|
4549
4580
|
if (this.isSubAgent) {
|
|
4550
|
-
this.failSubAgent("empty_response");
|
|
4581
|
+
this.failSubAgent(isRefusal ? "refusal" : "empty_response");
|
|
4551
4582
|
} else {
|
|
4552
4583
|
this.appendToHistory({
|
|
4553
4584
|
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."
|
|
4585
|
+
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
4586
|
});
|
|
4556
4587
|
}
|
|
4557
|
-
return this.turnDone(
|
|
4588
|
+
return this.turnDone(failureReason2);
|
|
4558
4589
|
} else {
|
|
4559
4590
|
const { reasoning, ...rest } = response;
|
|
4560
4591
|
const displayOnly = { cost: void 0, inputTokens: void 0, outputTokens: void 0 };
|
|
@@ -5072,6 +5103,10 @@ var OrchestratingDriver = class extends EventTarget {
|
|
|
5072
5103
|
getTurnSnapshots() {
|
|
5073
5104
|
return this.chatDriver.getTurnSnapshots();
|
|
5074
5105
|
}
|
|
5106
|
+
/** Delegates to the inner {@link ChatDriver} — interactions resolve there, so it holds the buffer. */
|
|
5107
|
+
getExternalDiagnostics() {
|
|
5108
|
+
return this.chatDriver.getExternalDiagnostics();
|
|
5109
|
+
}
|
|
5075
5110
|
async getSuggestions(history, prompt2, count, allAgentInfo) {
|
|
5076
5111
|
const pinned = this.resolvePinnedAgent();
|
|
5077
5112
|
const candidates = pinned && isSpecialist(pinned) ? [pinned] : this.specialists;
|
|
@@ -5585,6 +5620,86 @@ var strictFallbackAgent = {
|
|
|
5585
5620
|
fallback: true,
|
|
5586
5621
|
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
5622
|
};
|
|
5623
|
+
|
|
5624
|
+
// src/utils/flatten-sub-agent-messages.ts
|
|
5625
|
+
function flattenSubAgentMessages(messages, prefix = "", depth = 0, subAgentOf) {
|
|
5626
|
+
return messages.flatMap((m) => {
|
|
5627
|
+
const breadcrumb = prefix ? `${prefix} \u203A ${m.agentName ?? "?"}` : m.agentName;
|
|
5628
|
+
const traceCalls = m.toolCalls?.filter((tc) => tc.subAgentTrace?.length) ?? [];
|
|
5629
|
+
const entry = {
|
|
5630
|
+
kind: "message",
|
|
5631
|
+
...m,
|
|
5632
|
+
// Move the (about-to-be-hoisted) child conversations out of the emitted tool
|
|
5633
|
+
// calls. Setting it to `undefined` drops the key from the serialized export.
|
|
5634
|
+
...traceCalls.length > 0 && {
|
|
5635
|
+
toolCalls: m.toolCalls.map(
|
|
5636
|
+
(tc) => tc.subAgentTrace ? { ...tc, subAgentTrace: void 0 } : tc
|
|
5637
|
+
)
|
|
5638
|
+
},
|
|
5639
|
+
// Mark + breadcrumb hoisted sub-agent messages; top-level (depth 0) stays as-is.
|
|
5640
|
+
...depth > 0 && {
|
|
5641
|
+
agentName: breadcrumb,
|
|
5642
|
+
subAgentName: m.agentName,
|
|
5643
|
+
subAgentDepth: depth,
|
|
5644
|
+
subAgentOf
|
|
5645
|
+
}
|
|
5646
|
+
};
|
|
5647
|
+
if (traceCalls.length === 0) return [entry];
|
|
5648
|
+
const hoisted = traceCalls.flatMap(
|
|
5649
|
+
(tc) => flattenSubAgentMessages(tc.subAgentTrace, breadcrumb ?? "", depth + 1, tc.id)
|
|
5650
|
+
);
|
|
5651
|
+
return [entry, ...hoisted];
|
|
5652
|
+
});
|
|
5653
|
+
}
|
|
5654
|
+
|
|
5655
|
+
// src/state/persistence/build-timeline-entries.ts
|
|
5656
|
+
function buildTimelineEntries(input) {
|
|
5657
|
+
const { turnSnapshots, messages, metaEvents } = input;
|
|
5658
|
+
let lastFullPrompt;
|
|
5659
|
+
let lastFullIndex = "";
|
|
5660
|
+
const turns = turnSnapshots.map((t) => {
|
|
5661
|
+
let { systemPrompt } = t;
|
|
5662
|
+
if (systemPrompt != null && systemPrompt === lastFullPrompt) {
|
|
5663
|
+
systemPrompt = `<repeated \u2014 identical to turn ${lastFullIndex}>`;
|
|
5664
|
+
} else if (systemPrompt != null) {
|
|
5665
|
+
lastFullPrompt = systemPrompt;
|
|
5666
|
+
lastFullIndex = t.turnIndex;
|
|
5667
|
+
}
|
|
5668
|
+
return { kind: "turn", ...t, systemPrompt };
|
|
5669
|
+
});
|
|
5670
|
+
const messageEntries = flattenSubAgentMessages(messages);
|
|
5671
|
+
const eventEntries = metaEvents.map((e) => ({ kind: "event", ...e }));
|
|
5672
|
+
return [...messageEntries, ...turns, ...eventEntries];
|
|
5673
|
+
}
|
|
5674
|
+
|
|
5675
|
+
// src/state/persistence/diagnostics.ts
|
|
5676
|
+
var KIND_RANK = { event: 0, turn: 1, message: 2 };
|
|
5677
|
+
var UNKNOWN_KIND_RANK = 99;
|
|
5678
|
+
function assembleDebugLog(entries, readme) {
|
|
5679
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5680
|
+
let latestMeta;
|
|
5681
|
+
const timeline = [];
|
|
5682
|
+
for (const entry of entries) {
|
|
5683
|
+
const id = JSON.stringify(entry);
|
|
5684
|
+
if (seen.has(id)) continue;
|
|
5685
|
+
seen.add(id);
|
|
5686
|
+
if (entry.kind === "meta-snapshot") {
|
|
5687
|
+
if (!latestMeta || (entry.timestamp ?? "") >= (latestMeta.timestamp ?? "")) {
|
|
5688
|
+
latestMeta = entry;
|
|
5689
|
+
}
|
|
5690
|
+
} else {
|
|
5691
|
+
timeline.push(entry);
|
|
5692
|
+
}
|
|
5693
|
+
}
|
|
5694
|
+
timeline.sort((a, b) => {
|
|
5695
|
+
const ta = a.timestamp ?? "";
|
|
5696
|
+
const tb = b.timestamp ?? "";
|
|
5697
|
+
if (ta < tb) return -1;
|
|
5698
|
+
if (ta > tb) return 1;
|
|
5699
|
+
return (KIND_RANK[a.kind] ?? UNKNOWN_KIND_RANK) - (KIND_RANK[b.kind] ?? UNKNOWN_KIND_RANK);
|
|
5700
|
+
});
|
|
5701
|
+
return { readme, timeline, meta: latestMeta?.meta };
|
|
5702
|
+
}
|
|
5588
5703
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5589
5704
|
0 && (module.exports = {
|
|
5590
5705
|
AgenticActivityBus,
|
|
@@ -5597,10 +5712,16 @@ var strictFallbackAgent = {
|
|
|
5597
5712
|
NOOP_ACTIVITY_BUS,
|
|
5598
5713
|
OrchestratingDriver,
|
|
5599
5714
|
REQUEST_CONTINUATION_TOOL,
|
|
5715
|
+
SUPPORTED_ANTHROPIC_MODEL_IDS,
|
|
5716
|
+
SUPPORTED_GEMINI_MODEL_IDS,
|
|
5600
5717
|
agenticActivityBus,
|
|
5718
|
+
assembleDebugLog,
|
|
5719
|
+
buildTimelineEntries,
|
|
5720
|
+
clearSession,
|
|
5601
5721
|
defineAgent,
|
|
5602
5722
|
defineStatefulAgent,
|
|
5603
5723
|
friendlyFallbackAgent,
|
|
5724
|
+
getMetaEvents,
|
|
5604
5725
|
isObservableAIProviderRegistry,
|
|
5605
5726
|
restoreMachine,
|
|
5606
5727
|
strictFallbackAgent
|