@genesislcap/ai-assistant 14.467.1 → 14.467.2-GENC-1369.2
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 +39 -53
- package/dist/ai-assistant.d.ts +59 -26
- package/dist/dts/components/chat-driver/chat-driver.d.ts +38 -0
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
- package/dist/dts/index.d.ts +1 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/main/main.d.ts +1 -20
- package/dist/dts/main/main.d.ts.map +1 -1
- package/dist/dts/state/debug-event-log.d.ts +17 -1
- package/dist/dts/state/debug-event-log.d.ts.map +1 -1
- package/dist/dts/state/debug-event-log.test.d.ts +2 -0
- package/dist/dts/state/debug-event-log.test.d.ts.map +1 -0
- package/dist/dts/utils/condense-history.d.ts +115 -0
- package/dist/dts/utils/condense-history.d.ts.map +1 -0
- package/dist/dts/utils/condense-history.test.d.ts +2 -0
- package/dist/dts/utils/condense-history.test.d.ts.map +1 -0
- package/dist/dts/utils/flatten-sub-agent-messages.d.ts +51 -0
- package/dist/dts/utils/flatten-sub-agent-messages.d.ts.map +1 -0
- package/dist/dts/utils/flatten-sub-agent-messages.test.d.ts +2 -0
- package/dist/dts/utils/flatten-sub-agent-messages.test.d.ts.map +1 -0
- package/dist/dts/utils/strip-agent-handlers.d.ts +29 -0
- package/dist/dts/utils/strip-agent-handlers.d.ts.map +1 -0
- package/dist/dts/utils/strip-agent-handlers.test.d.ts +2 -0
- package/dist/dts/utils/strip-agent-handlers.test.d.ts.map +1 -0
- package/dist/esm/components/chat-driver/chat-driver.js +156 -19
- package/dist/esm/components/chat-driver/chat-driver.test.js +225 -1
- package/dist/esm/main/main.js +14 -38
- package/dist/esm/state/debug-event-log.js +50 -2
- package/dist/esm/state/debug-event-log.test.js +67 -0
- package/dist/esm/utils/condense-history.js +218 -0
- package/dist/esm/utils/condense-history.test.js +297 -0
- package/dist/esm/utils/flatten-sub-agent-messages.js +49 -0
- package/dist/esm/utils/flatten-sub-agent-messages.test.js +139 -0
- package/dist/esm/utils/strip-agent-handlers.js +51 -0
- package/dist/esm/utils/strip-agent-handlers.test.js +81 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -16
- package/src/components/chat-driver/chat-driver.test.ts +276 -1
- package/src/components/chat-driver/chat-driver.ts +184 -16
- package/src/index.ts +1 -0
- package/src/main/main.ts +16 -37
- package/src/state/debug-event-log.test.ts +89 -0
- package/src/state/debug-event-log.ts +52 -2
- package/src/utils/condense-history.test.ts +373 -0
- package/src/utils/condense-history.ts +306 -0
- package/src/utils/flatten-sub-agent-messages.test.ts +163 -0
- package/src/utils/flatten-sub-agent-messages.ts +88 -0
- package/src/utils/strip-agent-handlers.test.ts +99 -0
- package/src/utils/strip-agent-handlers.ts +52 -0
|
@@ -5385,70 +5385,25 @@
|
|
|
5385
5385
|
},
|
|
5386
5386
|
{
|
|
5387
5387
|
"kind": "Content",
|
|
5388
|
-
"text": "{\n readme: readonly string[];\n timeline: (
|
|
5388
|
+
"text": "{\n readme: readonly string[];\n timeline: (import(\"../utils/flatten-sub-agent-messages\")."
|
|
5389
5389
|
},
|
|
5390
5390
|
{
|
|
5391
5391
|
"kind": "Reference",
|
|
5392
|
-
"text": "
|
|
5393
|
-
"canonicalReference": "@genesislcap/
|
|
5394
|
-
},
|
|
5395
|
-
{
|
|
5396
|
-
"kind": "Content",
|
|
5397
|
-
"text": ";\n agentLabel?: string;\n agentSnapshot?: unknown;\n kind: \"turn\";\n } | {\n role: import(\"@genesislcap/foundation-ai\")."
|
|
5398
|
-
},
|
|
5399
|
-
{
|
|
5400
|
-
"kind": "Reference",
|
|
5401
|
-
"text": "ChatRole",
|
|
5402
|
-
"canonicalReference": "@genesislcap/foundation-ai!ChatRole:type"
|
|
5392
|
+
"text": "TimelineMessage",
|
|
5393
|
+
"canonicalReference": "@genesislcap/ai-assistant!TimelineMessage:type"
|
|
5403
5394
|
},
|
|
5404
5395
|
{
|
|
5405
5396
|
"kind": "Content",
|
|
5406
|
-
"text": ";\n
|
|
5397
|
+
"text": " | {\n systemPrompt: string;\n turnIndex: string;\n timestamp: string;\n agentName?: string;\n toolNames: string[];\n temperature?: number;\n toolChoice?: import(\"@genesislcap/foundation-ai\")."
|
|
5407
5398
|
},
|
|
5408
5399
|
{
|
|
5409
5400
|
"kind": "Reference",
|
|
5410
|
-
"text": "
|
|
5411
|
-
"canonicalReference": "@genesislcap/foundation-ai!
|
|
5412
|
-
},
|
|
5413
|
-
{
|
|
5414
|
-
"kind": "Content",
|
|
5415
|
-
"text": "[];\n toolResult?: import(\"@genesislcap/foundation-ai\")."
|
|
5416
|
-
},
|
|
5417
|
-
{
|
|
5418
|
-
"kind": "Reference",
|
|
5419
|
-
"text": "ChatToolResult",
|
|
5420
|
-
"canonicalReference": "@genesislcap/foundation-ai!ChatToolResult:interface"
|
|
5421
|
-
},
|
|
5422
|
-
{
|
|
5423
|
-
"kind": "Content",
|
|
5424
|
-
"text": ";\n attachments?: "
|
|
5425
|
-
},
|
|
5426
|
-
{
|
|
5427
|
-
"kind": "Reference",
|
|
5428
|
-
"text": "ChatAttachment",
|
|
5429
|
-
"canonicalReference": "@genesislcap/foundation-ai!ChatAttachment:interface"
|
|
5430
|
-
},
|
|
5431
|
-
{
|
|
5432
|
-
"kind": "Content",
|
|
5433
|
-
"text": "[];\n interaction?: import(\"@genesislcap/foundation-ai\")."
|
|
5434
|
-
},
|
|
5435
|
-
{
|
|
5436
|
-
"kind": "Reference",
|
|
5437
|
-
"text": "ChatInteraction",
|
|
5438
|
-
"canonicalReference": "@genesislcap/foundation-ai!ChatInteraction:interface"
|
|
5439
|
-
},
|
|
5440
|
-
{
|
|
5441
|
-
"kind": "Content",
|
|
5442
|
-
"text": ";\n thinking?: boolean;\n agentName?: string;\n agentLabel?: string;\n inputTokens?: number;\n outputTokens?: number;\n cost?: number;\n externalCostUsd?: number;\n responseMeta?: import(\"@genesislcap/foundation-ai\")."
|
|
5443
|
-
},
|
|
5444
|
-
{
|
|
5445
|
-
"kind": "Reference",
|
|
5446
|
-
"text": "ChatResponseMeta",
|
|
5447
|
-
"canonicalReference": "@genesislcap/foundation-ai!ChatResponseMeta:interface"
|
|
5401
|
+
"text": "ChatToolChoice",
|
|
5402
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatToolChoice:type"
|
|
5448
5403
|
},
|
|
5449
5404
|
{
|
|
5450
5405
|
"kind": "Content",
|
|
5451
|
-
"text": ";\n
|
|
5406
|
+
"text": ";\n agentLabel?: string;\n agentSnapshot?: unknown;\n kind: \"turn\";\n } | {\n index: number;\n timestamp: string;\n type: "
|
|
5452
5407
|
},
|
|
5453
5408
|
{
|
|
5454
5409
|
"kind": "Reference",
|
|
@@ -5629,7 +5584,7 @@
|
|
|
5629
5584
|
"isStatic": false,
|
|
5630
5585
|
"returnTypeTokenRange": {
|
|
5631
5586
|
"startIndex": 1,
|
|
5632
|
-
"endIndex":
|
|
5587
|
+
"endIndex": 44
|
|
5633
5588
|
},
|
|
5634
5589
|
"releaseTag": "Beta",
|
|
5635
5590
|
"isProtected": false,
|
|
@@ -10373,6 +10328,37 @@
|
|
|
10373
10328
|
"endIndex": 6
|
|
10374
10329
|
}
|
|
10375
10330
|
},
|
|
10331
|
+
{
|
|
10332
|
+
"kind": "TypeAlias",
|
|
10333
|
+
"canonicalReference": "@genesislcap/ai-assistant!TimelineMessage:type",
|
|
10334
|
+
"docComment": "/**\n * A chat message lifted into the debug-log timeline as a `kind: 'message'` entry.\n *\n * @beta\n */\n",
|
|
10335
|
+
"excerptTokens": [
|
|
10336
|
+
{
|
|
10337
|
+
"kind": "Content",
|
|
10338
|
+
"text": "export type TimelineMessage = "
|
|
10339
|
+
},
|
|
10340
|
+
{
|
|
10341
|
+
"kind": "Reference",
|
|
10342
|
+
"text": "ChatMessage",
|
|
10343
|
+
"canonicalReference": "@genesislcap/foundation-ai!ChatMessage:interface"
|
|
10344
|
+
},
|
|
10345
|
+
{
|
|
10346
|
+
"kind": "Content",
|
|
10347
|
+
"text": " & {\n kind: 'message';\n subAgentName?: string;\n subAgentDepth?: number;\n subAgentOf?: string;\n}"
|
|
10348
|
+
},
|
|
10349
|
+
{
|
|
10350
|
+
"kind": "Content",
|
|
10351
|
+
"text": ";"
|
|
10352
|
+
}
|
|
10353
|
+
],
|
|
10354
|
+
"fileUrlPath": "src/utils/flatten-sub-agent-messages.ts",
|
|
10355
|
+
"releaseTag": "Beta",
|
|
10356
|
+
"name": "TimelineMessage",
|
|
10357
|
+
"typeTokenRange": {
|
|
10358
|
+
"startIndex": 1,
|
|
10359
|
+
"endIndex": 3
|
|
10360
|
+
}
|
|
10361
|
+
},
|
|
10376
10362
|
{
|
|
10377
10363
|
"kind": "TypeAlias",
|
|
10378
10364
|
"canonicalReference": "@genesislcap/ai-assistant!ToolChoiceInput:type",
|
package/dist/ai-assistant.d.ts
CHANGED
|
@@ -5,15 +5,10 @@ import type { ChatAttachment } from '@genesislcap/foundation-ai';
|
|
|
5
5
|
import type { ChatConfig } from '@genesislcap/foundation-ai';
|
|
6
6
|
import type { ChatDriverResult } from '@genesislcap/foundation-ai';
|
|
7
7
|
import type { ChatInputDuringExecutionMode } from '@genesislcap/foundation-ai';
|
|
8
|
-
import { ChatInteraction } from '@genesislcap/foundation-ai';
|
|
9
8
|
import type { ChatMessage } from '@genesislcap/foundation-ai';
|
|
10
|
-
import { ChatResponseMeta } from '@genesislcap/foundation-ai';
|
|
11
|
-
import { ChatRole } from '@genesislcap/foundation-ai';
|
|
12
|
-
import { ChatToolCall } from '@genesislcap/foundation-ai';
|
|
13
9
|
import { ChatToolChoice } from '@genesislcap/foundation-ai';
|
|
14
10
|
import { ChatToolDefinition } from '@genesislcap/foundation-ai';
|
|
15
11
|
import type { ChatToolHandlers } from '@genesislcap/foundation-ai';
|
|
16
|
-
import { ChatToolResult } from '@genesislcap/foundation-ai';
|
|
17
12
|
import { GenesisElement } from '@genesislcap/web-core';
|
|
18
13
|
import type { InteractionRequestOptions } from '@genesislcap/foundation-ai';
|
|
19
14
|
import type { InteractionResult } from '@genesislcap/foundation-ai';
|
|
@@ -717,6 +712,40 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
717
712
|
* sent to the model — stored `history` stays unchanged for UI and logging.
|
|
718
713
|
*/
|
|
719
714
|
private providerHistoryTransform?;
|
|
715
|
+
/**
|
|
716
|
+
* Tool-declared condensation policies, keyed by tool-call id. Populated by
|
|
717
|
+
* `condenseWhen` (first-wins per call); read by `applyCondensation` before each
|
|
718
|
+
* provider call to collapse stale payloads from the model-bound history only.
|
|
719
|
+
* Accumulates across agents on a shared driver (a superseded read collapses no
|
|
720
|
+
* matter which agent made it) and is never cleared — it dies with the driver.
|
|
721
|
+
*/
|
|
722
|
+
private readonly condensePolicies;
|
|
723
|
+
/**
|
|
724
|
+
* Monotonic model-call counter for the driver's whole lifetime — the age clock
|
|
725
|
+
* for `condenseWhen({ on: { kind: 'age' } })`. The per-`sendMessage` `iterations`
|
|
726
|
+
* loop counter resets to 0 every turn, so it can only measure age WITHIN a
|
|
727
|
+
* single turn; this never resets, so `age` counts model-calls since the result
|
|
728
|
+
* appeared across turn boundaries (each short turn still advances it ≥ 1).
|
|
729
|
+
* Bumped once per tool-loop iteration (provider call).
|
|
730
|
+
*/
|
|
731
|
+
private modelCallSeq;
|
|
732
|
+
/**
|
|
733
|
+
* Monotonic turn counter — the `turnEnd` clock. Bumped once per `sendMessage`
|
|
734
|
+
* (a user turn; NOT per handoff continuation, which is the same request), never
|
|
735
|
+
* reset. `turnEnd` collapses a payload once `turnSeq` exceeds the turn it was
|
|
736
|
+
* created in.
|
|
737
|
+
*/
|
|
738
|
+
private turnSeq;
|
|
739
|
+
/**
|
|
740
|
+
* Monotonic agent-activation counter — the `agentEnd` clock. Advances when the
|
|
741
|
+
* active flow ends: a swap to a different-named agent (`applyAgent`) OR an
|
|
742
|
+
* explicit `releaseAgent` / `completeSubAgent`. A stateful agent re-resolving
|
|
743
|
+
* the same name across turns keeps one activation. `agentEnd` fires for a
|
|
744
|
+
* payload once a LATER activation is current (`callActivation < currentActivation`)
|
|
745
|
+
* — so a re-run of a released agent gets a fresh activation and is NOT
|
|
746
|
+
* collapsed until IT ends.
|
|
747
|
+
*/
|
|
748
|
+
private currentActivation;
|
|
720
749
|
/** Stack of fold frames — grows when a fold opens, shrinks when it closes. */
|
|
721
750
|
private foldStack;
|
|
722
751
|
/** Consecutive fold open/close ops without a real tool call. Reset on real tool execution. */
|
|
@@ -1073,6 +1102,10 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
1073
1102
|
* Centralised here so fold shortcut dispatch and the main tool loop use the
|
|
1074
1103
|
* same context without duplication.
|
|
1075
1104
|
*
|
|
1105
|
+
* @param activeToolCallId - The id of the tool call this context belongs to, so
|
|
1106
|
+
* `condenseWhen` can register against the right call (it stamps the clocks
|
|
1107
|
+
* straight off the driver). Absent for dispatch paths with no addressable tool
|
|
1108
|
+
* call (e.g. the fold-close handler), where `condenseWhen` is a no-op.
|
|
1076
1109
|
* @param traceCapture - Optional per-invocation slot. When provided, the trace
|
|
1077
1110
|
* from any sub-agent call is written here rather than to shared instance state,
|
|
1078
1111
|
* so parallel tool calls each capture their own trace independently.
|
|
@@ -1680,7 +1713,7 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
1680
1713
|
setEnabledAnimations(animations: AiAssistantAnimation[]): void;
|
|
1681
1714
|
getDebugLog(): {
|
|
1682
1715
|
readme: readonly string[];
|
|
1683
|
-
timeline: ({
|
|
1716
|
+
timeline: (TimelineMessage | {
|
|
1684
1717
|
systemPrompt: string;
|
|
1685
1718
|
turnIndex: string;
|
|
1686
1719
|
timestamp: string;
|
|
@@ -1691,25 +1724,6 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
1691
1724
|
agentLabel?: string;
|
|
1692
1725
|
agentSnapshot?: unknown;
|
|
1693
1726
|
kind: "turn";
|
|
1694
|
-
} | {
|
|
1695
|
-
role: ChatRole;
|
|
1696
|
-
content: string;
|
|
1697
|
-
timestamp?: string;
|
|
1698
|
-
toolCalls?: ChatToolCall[];
|
|
1699
|
-
toolResult?: ChatToolResult;
|
|
1700
|
-
attachments?: ChatAttachment[];
|
|
1701
|
-
interaction?: ChatInteraction;
|
|
1702
|
-
thinking?: boolean;
|
|
1703
|
-
agentName?: string;
|
|
1704
|
-
agentLabel?: string;
|
|
1705
|
-
inputTokens?: number;
|
|
1706
|
-
outputTokens?: number;
|
|
1707
|
-
cost?: number;
|
|
1708
|
-
externalCostUsd?: number;
|
|
1709
|
-
responseMeta?: ChatResponseMeta;
|
|
1710
|
-
model?: string;
|
|
1711
|
-
providerName?: string;
|
|
1712
|
-
kind: "message";
|
|
1713
1727
|
} | {
|
|
1714
1728
|
index: number;
|
|
1715
1729
|
timestamp: string;
|
|
@@ -1967,7 +1981,7 @@ declare type MetaEventImportance = 'high' | 'normal' | 'low';
|
|
|
1967
1981
|
* Catalogue of meta event names. This is the documented surface — extend it as
|
|
1968
1982
|
* new events are wired in (Tier 2/3 lifecycle, interaction, provider events).
|
|
1969
1983
|
*/
|
|
1970
|
-
declare type MetaEventType = 'assistant.connected' | 'assistant.disconnected' | 'assistant.popout' | 'assistant.popin' | 'driver.created' | 'driver.wired' | 'driver.unwired' | 'state.changed' | 'turn.start' | 'turn.end' | 'turn.retry' | 'turn.error' | 'tool.failed' | 'tool.unresolved' | 'subagent.started' | 'subagent.completed' | 'subagent.failed' | 'agent.handoff' | 'agent.pinned' | 'agent.unpinned' | 'provider.selected' | 'interaction.requested' | 'interaction.resolved' | 'context.updated' | 'context.threshold-crossed' | 'panel.toggled' | 'attachment.added' | 'file.read-failed' | 'suggestions.failed';
|
|
1984
|
+
declare type MetaEventType = 'assistant.connected' | 'assistant.disconnected' | 'assistant.popout' | 'assistant.popin' | 'driver.created' | 'driver.wired' | 'driver.unwired' | 'state.changed' | 'turn.start' | 'turn.end' | 'turn.retry' | 'turn.error' | 'tool.failed' | 'tool.unresolved' | 'subagent.started' | 'subagent.completed' | 'subagent.failed' | 'agent.handoff' | 'agent.pinned' | 'agent.unpinned' | 'provider.selected' | 'interaction.requested' | 'interaction.resolved' | 'context.updated' | 'context.threshold-crossed' | 'context.condensed' | 'panel.toggled' | 'attachment.added' | 'file.read-failed' | 'suggestions.failed';
|
|
1971
1985
|
|
|
1972
1986
|
/**
|
|
1973
1987
|
* Orchestrates multiple specialist agents. Sits between `FoundationAiAssistant`
|
|
@@ -2373,6 +2387,25 @@ export declare type SystemPromptInput = string | ((ctx: SystemPromptContext) =>
|
|
|
2373
2387
|
*/
|
|
2374
2388
|
export declare type TemperatureInput = number | ((ctx: SystemPromptContext) => number | Promise<number>);
|
|
2375
2389
|
|
|
2390
|
+
/**
|
|
2391
|
+
* A chat message lifted into the debug-log timeline as a `kind: 'message'` entry.
|
|
2392
|
+
*
|
|
2393
|
+
* @beta
|
|
2394
|
+
*/
|
|
2395
|
+
export declare type TimelineMessage = ChatMessage & {
|
|
2396
|
+
kind: 'message';
|
|
2397
|
+
/**
|
|
2398
|
+
* Set only on entries hoisted out of a `subAgentTrace`: the sub-agent's own
|
|
2399
|
+
* (un-breadcrumbed) `agentName`, kept for filtering since the displayed
|
|
2400
|
+
* `agentName` is rewritten to a `"<parent> › <sub-agent>"` breadcrumb.
|
|
2401
|
+
*/
|
|
2402
|
+
subAgentName?: string;
|
|
2403
|
+
/** Delegation depth — absent/0 for top-level, 1 for a sub-agent, 2 for a sub-agent's sub-agent, … */
|
|
2404
|
+
subAgentDepth?: number;
|
|
2405
|
+
/** Id of the parent tool call that spawned this run — correlates a hoisted message back to its delegation. */
|
|
2406
|
+
subAgentOf?: string;
|
|
2407
|
+
};
|
|
2408
|
+
|
|
2376
2409
|
/**
|
|
2377
2410
|
* Symbol used to attach ToolFold metadata to a facade handler function.
|
|
2378
2411
|
* The ChatDriver inspects this to detect fold facades at runtime.
|
|
@@ -129,6 +129,40 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
129
129
|
* sent to the model — stored `history` stays unchanged for UI and logging.
|
|
130
130
|
*/
|
|
131
131
|
private providerHistoryTransform?;
|
|
132
|
+
/**
|
|
133
|
+
* Tool-declared condensation policies, keyed by tool-call id. Populated by
|
|
134
|
+
* `condenseWhen` (first-wins per call); read by `applyCondensation` before each
|
|
135
|
+
* provider call to collapse stale payloads from the model-bound history only.
|
|
136
|
+
* Accumulates across agents on a shared driver (a superseded read collapses no
|
|
137
|
+
* matter which agent made it) and is never cleared — it dies with the driver.
|
|
138
|
+
*/
|
|
139
|
+
private readonly condensePolicies;
|
|
140
|
+
/**
|
|
141
|
+
* Monotonic model-call counter for the driver's whole lifetime — the age clock
|
|
142
|
+
* for `condenseWhen({ on: { kind: 'age' } })`. The per-`sendMessage` `iterations`
|
|
143
|
+
* loop counter resets to 0 every turn, so it can only measure age WITHIN a
|
|
144
|
+
* single turn; this never resets, so `age` counts model-calls since the result
|
|
145
|
+
* appeared across turn boundaries (each short turn still advances it ≥ 1).
|
|
146
|
+
* Bumped once per tool-loop iteration (provider call).
|
|
147
|
+
*/
|
|
148
|
+
private modelCallSeq;
|
|
149
|
+
/**
|
|
150
|
+
* Monotonic turn counter — the `turnEnd` clock. Bumped once per `sendMessage`
|
|
151
|
+
* (a user turn; NOT per handoff continuation, which is the same request), never
|
|
152
|
+
* reset. `turnEnd` collapses a payload once `turnSeq` exceeds the turn it was
|
|
153
|
+
* created in.
|
|
154
|
+
*/
|
|
155
|
+
private turnSeq;
|
|
156
|
+
/**
|
|
157
|
+
* Monotonic agent-activation counter — the `agentEnd` clock. Advances when the
|
|
158
|
+
* active flow ends: a swap to a different-named agent (`applyAgent`) OR an
|
|
159
|
+
* explicit `releaseAgent` / `completeSubAgent`. A stateful agent re-resolving
|
|
160
|
+
* the same name across turns keeps one activation. `agentEnd` fires for a
|
|
161
|
+
* payload once a LATER activation is current (`callActivation < currentActivation`)
|
|
162
|
+
* — so a re-run of a released agent gets a fresh activation and is NOT
|
|
163
|
+
* collapsed until IT ends.
|
|
164
|
+
*/
|
|
165
|
+
private currentActivation;
|
|
132
166
|
/** Stack of fold frames — grows when a fold opens, shrinks when it closes. */
|
|
133
167
|
private foldStack;
|
|
134
168
|
/** Consecutive fold open/close ops without a real tool call. Reset on real tool execution. */
|
|
@@ -485,6 +519,10 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
485
519
|
* Centralised here so fold shortcut dispatch and the main tool loop use the
|
|
486
520
|
* same context without duplication.
|
|
487
521
|
*
|
|
522
|
+
* @param activeToolCallId - The id of the tool call this context belongs to, so
|
|
523
|
+
* `condenseWhen` can register against the right call (it stamps the clocks
|
|
524
|
+
* straight off the driver). Absent for dispatch paths with no addressable tool
|
|
525
|
+
* call (e.g. the fold-close handler), where `condenseWhen` is a no-op.
|
|
488
526
|
* @param traceCapture - Optional per-invocation slot. When provided, the trace
|
|
489
527
|
* from any sub-agent call is written here rather than to shared instance state,
|
|
490
528
|
* so parallel tool calls each capture their own trace independently.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-driver.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-driver/chat-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,WAAW,EAGX,cAAc,
|
|
1
|
+
{"version":3,"file":"chat-driver.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-driver/chat-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,WAAW,EAGX,cAAc,EAKd,yBAAyB,EAEzB,qBAAqB,EAEtB,MAAM,4BAA4B,CAAC;AAMpC,OAAO,KAAK,EACV,WAAW,EAGX,iBAAiB,EAGjB,oBAAoB,EACpB,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAe7B,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AA8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ist/dts/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from './config/config';
|
|
|
12
12
|
export * from './config/define-stateful-agent';
|
|
13
13
|
export * from './config/fallback-agents';
|
|
14
14
|
export * from './utils/tool-fold';
|
|
15
|
+
export type { TimelineMessage } from './utils/flatten-sub-agent-messages';
|
|
15
16
|
export type { AiChatWidget } from './types/ai-chat-widget';
|
|
16
17
|
export { AiChatMarkdown } from './components/chat-markdown/chat-markdown';
|
|
17
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/dts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,YAAY,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC"}
|
package/dist/dts/main/main.d.ts
CHANGED
|
@@ -412,7 +412,7 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
412
412
|
setEnabledAnimations(animations: AiAssistantAnimation[]): void;
|
|
413
413
|
getDebugLog(): {
|
|
414
414
|
readme: readonly string[];
|
|
415
|
-
timeline: ({
|
|
415
|
+
timeline: (import("../utils/flatten-sub-agent-messages").TimelineMessage | {
|
|
416
416
|
systemPrompt: string;
|
|
417
417
|
turnIndex: string;
|
|
418
418
|
timestamp: string;
|
|
@@ -423,25 +423,6 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
423
423
|
agentLabel?: string;
|
|
424
424
|
agentSnapshot?: unknown;
|
|
425
425
|
kind: "turn";
|
|
426
|
-
} | {
|
|
427
|
-
role: import("@genesislcap/foundation-ai").ChatRole;
|
|
428
|
-
content: string;
|
|
429
|
-
timestamp?: string;
|
|
430
|
-
toolCalls?: import("@genesislcap/foundation-ai").ChatToolCall[];
|
|
431
|
-
toolResult?: import("@genesislcap/foundation-ai").ChatToolResult;
|
|
432
|
-
attachments?: ChatAttachment[];
|
|
433
|
-
interaction?: import("@genesislcap/foundation-ai").ChatInteraction;
|
|
434
|
-
thinking?: boolean;
|
|
435
|
-
agentName?: string;
|
|
436
|
-
agentLabel?: string;
|
|
437
|
-
inputTokens?: number;
|
|
438
|
-
outputTokens?: number;
|
|
439
|
-
cost?: number;
|
|
440
|
-
externalCostUsd?: number;
|
|
441
|
-
responseMeta?: import("@genesislcap/foundation-ai").ChatResponseMeta;
|
|
442
|
-
model?: string;
|
|
443
|
-
providerName?: string;
|
|
444
|
-
kind: "message";
|
|
445
426
|
} | {
|
|
446
427
|
index: number;
|
|
447
428
|
timestamp: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/main/main.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EACV,6BAA6B,EAC7B,cAAc,EACd,UAAU,EACV,4BAA4B,EAC5B,WAAW,EACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAkC,MAAM,4BAA4B,CAAC;AAEhG,OAAO,EAGL,cAAc,EAIf,MAAM,uBAAuB,CAAC;AAe/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/main/main.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EACV,6BAA6B,EAC7B,cAAc,EACd,UAAU,EACV,4BAA4B,EAC5B,WAAW,EACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAkC,MAAM,4BAA4B,CAAC;AAEhG,OAAO,EAGL,cAAc,EAIf,MAAM,uBAAuB,CAAC;AAe/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAoBlC,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAiBtB,8FAA8F;AAC9F,eAAO,MAAM,cAAc,ugBAAqf,CAAC;AAEjhB,+CAA+C;AAC/C,eAAO,MAAM,WAAW,0OAAgO,CAAC;AAEzP,sFAAsF;AACtF,eAAO,M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7B,IAAI,mBAAmB,IAAI,MAAM,CAIhC;IAED;iEAC6D;IAC7D,qBAAqB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;IAoB5C;;;qDAGiD;IACjD,oBAAoB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;IAS3C,yDAAyD;IACzD,mBAAmB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;CAI3C"}
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* Catalogue of meta event names. This is the documented surface — extend it as
|
|
28
28
|
* new events are wired in (Tier 2/3 lifecycle, interaction, provider events).
|
|
29
29
|
*/
|
|
30
|
-
export type MetaEventType = 'assistant.connected' | 'assistant.disconnected' | 'assistant.popout' | 'assistant.popin' | 'driver.created' | 'driver.wired' | 'driver.unwired' | 'state.changed' | 'turn.start' | 'turn.end' | 'turn.retry' | 'turn.error' | 'tool.failed' | 'tool.unresolved' | 'subagent.started' | 'subagent.completed' | 'subagent.failed' | 'agent.handoff' | 'agent.pinned' | 'agent.unpinned' | 'provider.selected' | 'interaction.requested' | 'interaction.resolved' | 'context.updated' | 'context.threshold-crossed' | 'panel.toggled' | 'attachment.added' | 'file.read-failed' | 'suggestions.failed';
|
|
30
|
+
export type MetaEventType = 'assistant.connected' | 'assistant.disconnected' | 'assistant.popout' | 'assistant.popin' | 'driver.created' | 'driver.wired' | 'driver.unwired' | 'state.changed' | 'turn.start' | 'turn.end' | 'turn.retry' | 'turn.error' | 'tool.failed' | 'tool.unresolved' | 'subagent.started' | 'subagent.completed' | 'subagent.failed' | 'agent.handoff' | 'agent.pinned' | 'agent.unpinned' | 'provider.selected' | 'interaction.requested' | 'interaction.resolved' | 'context.updated' | 'context.threshold-crossed' | 'context.condensed' | 'panel.toggled' | 'attachment.added' | 'file.read-failed' | 'suggestions.failed';
|
|
31
31
|
/**
|
|
32
32
|
* How much a reader should care about an event — lets a consumer (or an AI
|
|
33
33
|
* agent) filter the timeline: skip `low` UI/bookkeeping noise, skim `normal`
|
|
@@ -94,6 +94,22 @@ export declare function recordTurnError(key: string, reason: TurnFailureReason,
|
|
|
94
94
|
export declare function recordTurnRetry(key: string, reason: TurnFailureReason, detail?: Record<string, unknown>): void;
|
|
95
95
|
/** Returns the meta-event timeline for `key`, or an empty array if none recorded. */
|
|
96
96
|
export declare function getMetaEvents(key: string): ReadonlyArray<MetaEvent>;
|
|
97
|
+
/**
|
|
98
|
+
* Merge pre-built meta events into the timeline for `targetKey`, **preserving each
|
|
99
|
+
* event's original `timestamp`** (so it interleaves chronologically on export)
|
|
100
|
+
* while re-indexing onto the target buffer's monotonic counter. Used to fold a
|
|
101
|
+
* sub-agent's harvested events into the parent session — see
|
|
102
|
+
* `ChatDriver.invokeSubAgent`. Unlike {@link recordMetaEvent} it does not stamp a
|
|
103
|
+
* fresh timestamp; the same non-`high` eviction policy is applied once after the
|
|
104
|
+
* batch so the buffer stays bounded.
|
|
105
|
+
*/
|
|
106
|
+
export declare function mergeMetaEvents(targetKey: string, events: readonly MetaEvent[]): void;
|
|
107
|
+
/**
|
|
108
|
+
* Drop the entire timeline for `key`. Used to discard a sub-agent's transient
|
|
109
|
+
* per-invocation session once its events have been harvested into the parent, so
|
|
110
|
+
* the module registry doesn't accumulate one orphaned bucket per sub-agent run.
|
|
111
|
+
*/
|
|
112
|
+
export declare function clearSession(key: string): void;
|
|
97
113
|
/**
|
|
98
114
|
* Human/agent-facing guide emitted as the first key of the exported debug log,
|
|
99
115
|
* so whoever opens the JSON (often an AI agent) knows how to read it without
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug-event-log.d.ts","sourceRoot":"","sources":["../../../src/state/debug-event-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;GAGG;AACH,MAAM,MAAM,aAAa,GAErB,qBAAqB,GACrB,wBAAwB,GACxB,kBAAkB,GAClB,iBAAiB,GAEjB,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAEhB,eAAe,GACf,YAAY,GACZ,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,iBAAiB,GACjB,kBAAkB,GAClB,oBAAoB,GACpB,iBAAiB,GAEjB,eAAe,GACf,cAAc,GACd,gBAAgB,GAChB,mBAAmB,GAEnB,uBAAuB,GACvB,sBAAsB,GAEtB,iBAAiB,GACjB,2BAA2B,
|
|
1
|
+
{"version":3,"file":"debug-event-log.d.ts","sourceRoot":"","sources":["../../../src/state/debug-event-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;GAGG;AACH,MAAM,MAAM,aAAa,GAErB,qBAAqB,GACrB,wBAAwB,GACxB,kBAAkB,GAClB,iBAAiB,GAEjB,gBAAgB,GAChB,cAAc,GACd,gBAAgB,GAEhB,eAAe,GACf,YAAY,GACZ,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,iBAAiB,GACjB,kBAAkB,GAClB,oBAAoB,GACpB,iBAAiB,GAEjB,eAAe,GACf,cAAc,GACd,gBAAgB,GAChB,mBAAmB,GAEnB,uBAAuB,GACvB,sBAAsB,GAEtB,iBAAiB,GACjB,2BAA2B,GAC3B,mBAAmB,GAEnB,eAAe,GACf,kBAAkB,GAClB,kBAAkB,GAClB,oBAAoB,CAAC;AAEzB;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE5D;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,aAAa,EAAE,mBAAmB,CAiC5E,CAAC;AAEF,4CAA4C;AAC5C,MAAM,WAAW,SAAS;IACxB,0FAA0F;IAC1F,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,IAAI,EAAE,aAAa,CAAC;IACpB,6EAA6E;IAC7E,UAAU,EAAE,mBAAmB,CAAC;IAChC,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAmBD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,aAAa,EACnB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,IAAI,CAyBN;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,iBAAiB,GACzB,WAAW,GACX,yBAAyB,GACzB,gBAAgB,GAChB,oBAAoB,GACpB,gBAAgB,CAAC;AAErB;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,iBAAiB,EACzB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,IAAI,CAEN;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,iBAAiB,EACzB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,IAAI,CAEN;AAED,qFAAqF;AACrF,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,CAEnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,IAAI,CA0BrF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAc7C,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug-event-log.test.d.ts","sourceRoot":"","sources":["../../../src/state/debug-event-log.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { ChatMessage, CondensePolicy } from '@genesislcap/foundation-ai';
|
|
2
|
+
/**
|
|
3
|
+
* Tool-context condensation: collapse stale tool payloads out of the history
|
|
4
|
+
* sent to the model, while leaving stored history untouched.
|
|
5
|
+
*
|
|
6
|
+
* The driver owns the registry (tool handlers populate it via `condenseWhen`)
|
|
7
|
+
* and the cadence (this runs before every provider call). This module owns the
|
|
8
|
+
* pure application: given the registry + the current loop iteration, produce a
|
|
9
|
+
* rewritten copy of the history with stale args/results replaced by stubs. Kept
|
|
10
|
+
* pure (no driver/session state, no logging) so it unit-tests in isolation —
|
|
11
|
+
* the one-time `context.condensed` signal is delivered via an `onCondensed`
|
|
12
|
+
* callback rather than reaching into the debug-event log directly.
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Below this serialized size a tool payload isn't worth condensing — the stub
|
|
18
|
+
* would save little and cost a breadcrumb. A driver-level floor so the public
|
|
19
|
+
* `condenseWhen` API needs no per-policy threshold field.
|
|
20
|
+
*/
|
|
21
|
+
export declare const CONDENSE_MIN_CHARS = 1000;
|
|
22
|
+
/** Key the collapsed args are stored under — a tool-call's args must stay a Record. */
|
|
23
|
+
export declare const CONDENSED_ARGS_KEY = "condensed";
|
|
24
|
+
/**
|
|
25
|
+
* A `condenseWhen` policy registered against a tool-call id, with its age clock
|
|
26
|
+
* and report-once flags. The driver holds these in a `Map<toolCallId, …>`;
|
|
27
|
+
* {@link applyCondensation} reads them and flips the `reported*` flags so the
|
|
28
|
+
* `context.condensed` signal fires once per payload, not once per provider call.
|
|
29
|
+
*/
|
|
30
|
+
export interface RegisteredCondensePolicy {
|
|
31
|
+
policy: CondensePolicy;
|
|
32
|
+
/**
|
|
33
|
+
* Monotonic model-call sequence (`modelCallSeq`) when `condenseWhen` was called
|
|
34
|
+
* — the origin of the age clock. Driver-lifetime and NOT reset per turn, so age
|
|
35
|
+
* is measured consistently across turn boundaries (the field name is historical;
|
|
36
|
+
* it is not the per-turn loop iteration).
|
|
37
|
+
*/
|
|
38
|
+
iteration: number;
|
|
39
|
+
/** Turn (`sendMessage`) sequence when the call was made — the `turnEnd` clock. */
|
|
40
|
+
turn: number;
|
|
41
|
+
/** Agent-activation sequence when the call was made — the `agentEnd` clock. */
|
|
42
|
+
activation: number;
|
|
43
|
+
/** `context.condensed` already emitted for the args payload (fire-once). */
|
|
44
|
+
reportedArgs?: boolean;
|
|
45
|
+
/** `context.condensed` already emitted for the response payload (fire-once). */
|
|
46
|
+
reportedResponse?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The driver's live state at the moment of a provider call — the clocks every
|
|
50
|
+
* trigger is evaluated against. Passed by the driver; kept as an interface so the
|
|
51
|
+
* transform stays a pure function of (history, policies, clocks).
|
|
52
|
+
*/
|
|
53
|
+
export interface CondenseContext {
|
|
54
|
+
/** Monotonic model-call sequence now — the `age` clock. */
|
|
55
|
+
modelCall: number;
|
|
56
|
+
/** Monotonic turn (`sendMessage`) sequence now — the `turnEnd` clock. */
|
|
57
|
+
turn: number;
|
|
58
|
+
/** Whether the agent activation that made a call has since ended — the `agentEnd` clock. */
|
|
59
|
+
activationEnded: (activation: number) => boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Structured detail for a `context.condensed` meta-event. The index signature
|
|
63
|
+
* lets it satisfy `recordMetaEvent`'s `Record<string, unknown>` detail param
|
|
64
|
+
* while the named fields stay strictly typed.
|
|
65
|
+
*/
|
|
66
|
+
export interface CondensedEventDetail {
|
|
67
|
+
[key: string]: unknown;
|
|
68
|
+
/** Tool-loop iteration the collapsed call was made on. */
|
|
69
|
+
turn: number;
|
|
70
|
+
toolCallId: string;
|
|
71
|
+
tool: string;
|
|
72
|
+
target: 'args' | 'response';
|
|
73
|
+
/** Human-readable trigger, e.g. `superseded:Foo.tsx` or `age:3`. */
|
|
74
|
+
trigger: string;
|
|
75
|
+
/** Length of the replacement stub. */
|
|
76
|
+
stubLen: number;
|
|
77
|
+
/** Estimated input tokens saved this collapse (char/4 — no tokenizer in-stack). */
|
|
78
|
+
tokensSaved: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Collapse stale tool payloads (declared via `condenseWhen`) out of the
|
|
82
|
+
* model-bound history. Pure over the `history` array — it emits new message
|
|
83
|
+
* objects and never mutates the input messages (mirroring the agent-masking
|
|
84
|
+
* transform). It DOES, however, flip the `reported*` flag on the matching
|
|
85
|
+
* `policies` entry the first time a payload collapses — the report-once gate that
|
|
86
|
+
* keeps `onCondensed` firing once per (tool call, payload) even though the
|
|
87
|
+
* collapse itself re-runs before every provider call.
|
|
88
|
+
*
|
|
89
|
+
* Triggers (a policy may list several via `on: Trigger[]` — the FIRST to fire
|
|
90
|
+
* collapses the payload; all are monotonic, so the collapse never reverts):
|
|
91
|
+
* - `superseded` — among all registered calls sharing a `by` key, the LAST in
|
|
92
|
+
* history order survives; every earlier one's targeted payload collapses. A
|
|
93
|
+
* re-call with the same key becomes the new survivor and re-arms the rest.
|
|
94
|
+
* - `age` — the result is first visible one model-call after the call, so `turns`
|
|
95
|
+
* is how many model-calls may see the full result before it collapses
|
|
96
|
+
* (fires when `modelCall − callModelCall > turns`): `turns: 1` is seen once,
|
|
97
|
+
* then collapses. The clock is monotonic across turns.
|
|
98
|
+
* - `turnEnd` — collapses once the turn (`sendMessage`) that made the call has
|
|
99
|
+
* ended (fires when `turn > callTurn`): full for the rest of that request,
|
|
100
|
+
* gone on every later one.
|
|
101
|
+
* - `agentEnd` — collapses once the agent activation that made the call has ended
|
|
102
|
+
* (a swap to another agent, or `releaseAgent`/`completeSubAgent`): kept across
|
|
103
|
+
* all of the agent's turns, dropped when its flow finishes.
|
|
104
|
+
*
|
|
105
|
+
* The tool-call/result envelope is never removed (providers reject orphaned
|
|
106
|
+
* calls/results) — only the args object or the result content is replaced.
|
|
107
|
+
*
|
|
108
|
+
* @param history - The to-model history copy to rewrite (not mutated).
|
|
109
|
+
* @param policies - The driver's registry, keyed by tool-call id. Its entries'
|
|
110
|
+
* `reported*` flags are flipped as payloads first collapse.
|
|
111
|
+
* @param ctx - The driver's live clocks (model-call / turn / agent-activation).
|
|
112
|
+
* @param onCondensed - Invoked once per payload at its full→stub transition.
|
|
113
|
+
*/
|
|
114
|
+
export declare function applyCondensation(history: ChatMessage[], policies: Map<string, RegisteredCondensePolicy>, ctx: CondenseContext, onCondensed: (detail: CondensedEventDetail) => void): ChatMessage[];
|
|
115
|
+
//# sourceMappingURL=condense-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condense-history.d.ts","sourceRoot":"","sources":["../../../src/utils/condense-history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAmB,MAAM,4BAA4B,CAAC;AAE/F;;;;;;;;;;;;;GAaG;AAEH;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAEvC,uFAAuF;AACvF,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAQ9C;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,cAAc,CAAC;IACvB;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,UAAU,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gFAAgF;IAChF,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,4FAA4F;IAC5F,eAAe,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;CAClD;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5B,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,WAAW,EAAE,MAAM,CAAC;CACrB;AA4CD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,WAAW,EAAE,EACtB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,EAC/C,GAAG,EAAE,eAAe,EACpB,WAAW,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,GAClD,WAAW,EAAE,CAoIf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condense-history.test.d.ts","sourceRoot":"","sources":["../../../src/utils/condense-history.test.ts"],"names":[],"mappings":""}
|