@genesislcap/ai-assistant 14.436.0 → 14.437.1
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 +315 -66
- package/dist/ai-assistant.d.ts +130 -41
- package/dist/dts/components/chat-driver/chat-driver.d.ts +36 -5
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts.map +1 -1
- package/dist/dts/config/config.d.ts +30 -2
- package/dist/dts/config/config.d.ts.map +1 -1
- package/dist/dts/config/define-stateful-agent.d.ts +38 -14
- package/dist/dts/config/define-stateful-agent.d.ts.map +1 -1
- package/dist/dts/main/main.d.ts +8 -6
- package/dist/dts/main/main.d.ts.map +1 -1
- package/dist/dts/state/ai-assistant-slice.d.ts +12 -10
- package/dist/dts/state/ai-assistant-slice.d.ts.map +1 -1
- package/dist/dts/state/session-store.d.ts +2 -2
- package/dist/esm/components/chat-driver/chat-driver.js +66 -8
- package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +6 -0
- package/dist/esm/config/define-stateful-agent.js +32 -45
- package/dist/esm/main/main.js +43 -12
- package/dist/esm/main/main.template.js +8 -5
- package/dist/esm/state/ai-assistant-slice.js +5 -5
- package/package.json +16 -16
- package/src/components/chat-driver/chat-driver.ts +124 -14
- package/src/components/orchestrating-driver/orchestrating-driver.ts +10 -0
- package/src/config/config.ts +33 -2
- package/src/config/define-stateful-agent.ts +72 -57
- package/src/main/main.template.ts +1 -1
- package/src/main/main.ts +44 -12
- package/src/state/ai-assistant-slice.ts +15 -15
package/dist/ai-assistant.d.ts
CHANGED
|
@@ -5,9 +5,10 @@ import type { ChatConfig } from '@genesislcap/foundation-ai';
|
|
|
5
5
|
import type { ChatDriverResult } from '@genesislcap/foundation-ai';
|
|
6
6
|
import type { ChatInputDuringExecutionMode } from '@genesislcap/foundation-ai';
|
|
7
7
|
import type { ChatMessage } from '@genesislcap/foundation-ai';
|
|
8
|
-
import
|
|
8
|
+
import { ChatToolDefinition } from '@genesislcap/foundation-ai';
|
|
9
9
|
import type { ChatToolHandlers } from '@genesislcap/foundation-ai';
|
|
10
10
|
import { GenesisElement } from '@genesislcap/web-core';
|
|
11
|
+
import type { InteractionRequestOptions } from '@genesislcap/foundation-ai';
|
|
11
12
|
import type { InteractionResult } from '@genesislcap/foundation-ai';
|
|
12
13
|
import { ViewTemplate } from '@genesislcap/web-core';
|
|
13
14
|
|
|
@@ -375,9 +376,21 @@ export declare const ANIMATION_DEFS: {
|
|
|
375
376
|
|
|
376
377
|
declare interface BaseAgentConfig {
|
|
377
378
|
/**
|
|
378
|
-
*
|
|
379
|
+
* Stable identity for this agent. Used for classifier routing, manual
|
|
380
|
+
* pinning, and history filtering — must not vary per turn. For a per-turn
|
|
381
|
+
* display label (e.g. "Guided Booking (Counterparties)"), supply
|
|
382
|
+
* {@link BaseAgentConfig.displayName}.
|
|
379
383
|
*/
|
|
380
384
|
name: string;
|
|
385
|
+
/**
|
|
386
|
+
* Optional per-turn display label. Resolved each tool-loop iteration and
|
|
387
|
+
* stamped onto outgoing messages (`agentLabel`) and the debug-log timeline.
|
|
388
|
+
* Renderers fall back to `name` when this is unset. Use the function form
|
|
389
|
+
* to vary the label by current state (e.g. a state machine's step).
|
|
390
|
+
*
|
|
391
|
+
* Identity stays on `name` — this is for UX only.
|
|
392
|
+
*/
|
|
393
|
+
displayName?: SystemPromptInput;
|
|
381
394
|
/**
|
|
382
395
|
* System prompt injected into every conversation turn for this agent.
|
|
383
396
|
*
|
|
@@ -397,8 +410,13 @@ declare interface BaseAgentConfig {
|
|
|
397
410
|
toolDefinitions?: ToolDefinitionsInput;
|
|
398
411
|
/**
|
|
399
412
|
* Tool handler implementations for this agent.
|
|
413
|
+
*
|
|
414
|
+
* Either a static map or a function resolved each tool-loop iteration —
|
|
415
|
+
* pick the function form to narrow the dispatchable handler set per turn,
|
|
416
|
+
* matching the function form of `toolDefinitions`.
|
|
417
|
+
* See {@link ToolHandlersInput}.
|
|
400
418
|
*/
|
|
401
|
-
toolHandlers?:
|
|
419
|
+
toolHandlers?: ToolHandlersInput;
|
|
402
420
|
/**
|
|
403
421
|
* Optional primer history prepended to every call (not visible to the user).
|
|
404
422
|
* Used to establish agent identity and behavioural rules.
|
|
@@ -485,9 +503,31 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
485
503
|
* in that case.
|
|
486
504
|
*/
|
|
487
505
|
private toolDefinitionsFactory?;
|
|
506
|
+
/**
|
|
507
|
+
* Resolved tool handler map used for dispatch. When `toolHandlersFactory` is
|
|
508
|
+
* set, this is overwritten each tool-loop iteration with the factory's output
|
|
509
|
+
* — keeping it in lockstep with `toolDefinitions` so handlers don't have to
|
|
510
|
+
* defend themselves against being dispatched in states where their tool
|
|
511
|
+
* isn't advertised. Folds mutate this in place; `defineStatefulAgent`
|
|
512
|
+
* forbids folds when a factory is set, so the fold-mutation path is
|
|
513
|
+
* unreachable in that case.
|
|
514
|
+
*/
|
|
488
515
|
private toolHandlers;
|
|
516
|
+
/**
|
|
517
|
+
* Optional per-turn handler-map source. Mirrors `toolDefinitionsFactory` so
|
|
518
|
+
* the LLM-visible tools and the dispatchable handlers can be narrowed in
|
|
519
|
+
* lockstep. Resolved each tool-loop iteration before the LLM call.
|
|
520
|
+
*/
|
|
521
|
+
private toolHandlersFactory?;
|
|
489
522
|
private primerHistory?;
|
|
490
523
|
private activeAgentName?;
|
|
524
|
+
/**
|
|
525
|
+
* Per-turn display label resolved from the agent's `displayName`. Stamped
|
|
526
|
+
* onto outgoing messages and turn snapshots for UX; `activeAgentName` stays
|
|
527
|
+
* stable for routing/history-transform identity matching.
|
|
528
|
+
*/
|
|
529
|
+
private activeAgentLabel?;
|
|
530
|
+
private displayName?;
|
|
491
531
|
/**
|
|
492
532
|
* When set, `requestInteraction` delegates to this callback instead of using
|
|
493
533
|
* this driver's own pending map. Wired by `invokeSubAgent` so a sub-agent's
|
|
@@ -537,7 +577,7 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
537
577
|
/** Captured from `applyAgent` so we don't store the whole `AgentConfig`. */
|
|
538
578
|
private debugSnapshotter?;
|
|
539
579
|
private readonly maxTurnSnapshots;
|
|
540
|
-
constructor(aiProvider: AIProvider, toolHandlers?:
|
|
580
|
+
constructor(aiProvider: AIProvider, toolHandlers?: ToolHandlersInput, toolDefinitions?: ToolDefinitionsInput, systemPrompt?: SystemPromptInput, primerHistory?: ChatMessage[], maxToolIterations?: number, maxFoldOperations?: number, maxTurnSnapshots?: number);
|
|
541
581
|
/**
|
|
542
582
|
* Swap in a new agent's configuration. Called by OrchestratingDriver before
|
|
543
583
|
* each specialist turn so the shared driver runs with the right tools and prompt.
|
|
@@ -586,7 +626,7 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
586
626
|
* resolves through) the parent's history and pending map. Calls chain
|
|
587
627
|
* naturally: a grandchild → child → root.
|
|
588
628
|
*/
|
|
589
|
-
setHostInteractionRequester(fn: <T>(componentName: string, data: any) => Promise<T>): void;
|
|
629
|
+
setHostInteractionRequester(fn: <T>(componentName: string, data: any, options?: InteractionRequestOptions) => Promise<T>): void;
|
|
590
630
|
/**
|
|
591
631
|
* Request a custom UI interaction. Emits a new message with the interaction.
|
|
592
632
|
* Tool handlers can call this to pause execution until the user completes the UI interaction.
|
|
@@ -600,8 +640,11 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
600
640
|
*
|
|
601
641
|
* @param componentName - The custom element name to render.
|
|
602
642
|
* @param data - Data to pass to the component.
|
|
643
|
+
* @param options - Optional per-call overrides, including
|
|
644
|
+
* `chatInputDuringExecution` to hide or disable the main chat input while
|
|
645
|
+
* the widget is awaiting user input. Reverts when the interaction resolves.
|
|
603
646
|
*/
|
|
604
|
-
requestInteraction<T>(componentName: string, data: any): Promise<T>;
|
|
647
|
+
requestInteraction<T>(componentName: string, data: any, options?: InteractionRequestOptions): Promise<T>;
|
|
605
648
|
/**
|
|
606
649
|
* Resolve a pending interaction. The wrapper component calls this on completion.
|
|
607
650
|
* Marks the interaction message as resolved so it renders read-only on re-render.
|
|
@@ -891,13 +934,13 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
891
934
|
get liveSubAgentName(): string | null;
|
|
892
935
|
set liveSubAgentName(value: string | null);
|
|
893
936
|
/**
|
|
894
|
-
* In-flight per-call chat-input overrides pushed by `requestSubAgent`
|
|
895
|
-
*
|
|
937
|
+
* In-flight per-call chat-input overrides pushed by `requestSubAgent` or
|
|
938
|
+
* `requestInteraction` calls. Empty means no override is active.
|
|
896
939
|
*/
|
|
897
|
-
get
|
|
940
|
+
get inputOverrides(): InputOverride[];
|
|
898
941
|
/**
|
|
899
942
|
* Resolves the effective chat-input behaviour while the assistant is
|
|
900
|
-
* executing.
|
|
943
|
+
* executing. Per-call overrides take precedence over the agent-level
|
|
901
944
|
* config; among overrides the most restrictive wins (`'hidden'` >
|
|
902
945
|
* `'disabled'`). Falls back to the active agent's config, then `'disabled'`.
|
|
903
946
|
*/
|
|
@@ -1080,7 +1123,7 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
1080
1123
|
timestamp: string;
|
|
1081
1124
|
host: string;
|
|
1082
1125
|
agentSummary: ({
|
|
1083
|
-
toolDefinitions: string |
|
|
1126
|
+
toolDefinitions: string | ChatToolDefinition[];
|
|
1084
1127
|
toolHandlers: any;
|
|
1085
1128
|
onActivate: any;
|
|
1086
1129
|
onDeactivate: any;
|
|
@@ -1089,13 +1132,14 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
1089
1132
|
fallback?: never;
|
|
1090
1133
|
excludeFromClassifier?: boolean;
|
|
1091
1134
|
name: string;
|
|
1135
|
+
displayName?: SystemPromptInput;
|
|
1092
1136
|
systemPrompt?: SystemPromptInput;
|
|
1093
1137
|
primerHistory?: ChatMessage[];
|
|
1094
1138
|
subAgents?: AgentConfig[];
|
|
1095
1139
|
chatInputDuringExecution?: ChatInputDuringExecutionMode;
|
|
1096
1140
|
manualSelection?: ManualSelectionConfig;
|
|
1097
1141
|
} | {
|
|
1098
|
-
toolDefinitions: string |
|
|
1142
|
+
toolDefinitions: string | ChatToolDefinition[];
|
|
1099
1143
|
toolHandlers: any;
|
|
1100
1144
|
onActivate: any;
|
|
1101
1145
|
onDeactivate: any;
|
|
@@ -1103,6 +1147,7 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
1103
1147
|
fallback: true;
|
|
1104
1148
|
description?: never;
|
|
1105
1149
|
name: string;
|
|
1150
|
+
displayName?: SystemPromptInput;
|
|
1106
1151
|
systemPrompt?: SystemPromptInput;
|
|
1107
1152
|
primerHistory?: ChatMessage[];
|
|
1108
1153
|
subAgents?: AgentConfig[];
|
|
@@ -1197,6 +1242,22 @@ export declare const friendlyFallbackAgent: FallbackAgentConfig;
|
|
|
1197
1242
|
*/
|
|
1198
1243
|
export declare function getAiPopoutManager(): FoundationAiPopoutManager | undefined;
|
|
1199
1244
|
|
|
1245
|
+
/**
|
|
1246
|
+
* A single in-flight per-call chat-input override pushed by a `requestSubAgent`
|
|
1247
|
+
* or `requestInteraction` call. Tracked as an array (not a counter) so the
|
|
1248
|
+
* slice can survive pop-in/pop-out and so a listener that connects
|
|
1249
|
+
* mid-execution can compute the effective mode without having seen the start
|
|
1250
|
+
* event.
|
|
1251
|
+
*
|
|
1252
|
+
* @internal
|
|
1253
|
+
*/
|
|
1254
|
+
declare interface InputOverride {
|
|
1255
|
+
/** Unique per-invocation id, paired with the start/stop events. */
|
|
1256
|
+
id: string;
|
|
1257
|
+
/** The mode requested for this invocation. */
|
|
1258
|
+
mode: ChatInputDuringExecutionMode;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1200
1261
|
/**
|
|
1201
1262
|
* Opts an agent in to manual selection from the assistant's agent picker.
|
|
1202
1263
|
*
|
|
@@ -1332,6 +1393,20 @@ export declare interface SpecialistAgentConfig extends BaseAgentConfig {
|
|
|
1332
1393
|
excludeFromClassifier?: boolean;
|
|
1333
1394
|
}
|
|
1334
1395
|
|
|
1396
|
+
/**
|
|
1397
|
+
* Context passed to per-turn resolvers on a stateful agent — the standard
|
|
1398
|
+
* {@link SystemPromptContext} plus the live `state` value. Used by
|
|
1399
|
+
* `systemPrompt`, `displayName`, and the function form of `toolDefinitions`.
|
|
1400
|
+
*
|
|
1401
|
+
* Exported so consumers can lift resolvers into separate files without
|
|
1402
|
+
* re-deriving the shape.
|
|
1403
|
+
*
|
|
1404
|
+
* @beta
|
|
1405
|
+
*/
|
|
1406
|
+
export declare type StatefulAgentContext<S> = SystemPromptContext & {
|
|
1407
|
+
state: S;
|
|
1408
|
+
};
|
|
1409
|
+
|
|
1335
1410
|
/**
|
|
1336
1411
|
* Init options for {@link defineStatefulAgent}. Generic over the state shape `S`
|
|
1337
1412
|
* the agent owns (a state machine, an observable controller, anything).
|
|
@@ -1379,9 +1454,14 @@ export declare interface StatefulAgentInit<S> {
|
|
|
1379
1454
|
* iteration. Use this to feed the LLM whatever the current state implies
|
|
1380
1455
|
* (e.g. a state machine's `meta.systemPrompt` plus captured context).
|
|
1381
1456
|
*/
|
|
1382
|
-
systemPrompt?: (ctx:
|
|
1383
|
-
|
|
1384
|
-
|
|
1457
|
+
systemPrompt?: (ctx: StatefulAgentContext<S>) => string | Promise<string>;
|
|
1458
|
+
/**
|
|
1459
|
+
* Per-turn display label, e.g. "Guided Booking (Counterparties)". Resolved
|
|
1460
|
+
* each tool-loop iteration and stamped onto outgoing messages and the
|
|
1461
|
+
* debug-log timeline — display only. The agent's `name` stays as the
|
|
1462
|
+
* canonical identity used for routing/history filtering.
|
|
1463
|
+
*/
|
|
1464
|
+
displayName?: (ctx: StatefulAgentContext<S>) => string | Promise<string>;
|
|
1385
1465
|
/**
|
|
1386
1466
|
* Tool definitions the LLM sees. Either a static array (resolved once) or a
|
|
1387
1467
|
* function resolved each tool-loop iteration. The function form is how a
|
|
@@ -1393,20 +1473,26 @@ export declare interface StatefulAgentInit<S> {
|
|
|
1393
1473
|
* has to be in charge. Helper throws at init time if a fold-tagged handler
|
|
1394
1474
|
* is detected.
|
|
1395
1475
|
*/
|
|
1396
|
-
toolDefinitions?: ChatToolDefinition[] | ((ctx:
|
|
1397
|
-
state: S;
|
|
1398
|
-
}) => ChatToolDefinition[] | Promise<ChatToolDefinition[]>);
|
|
1476
|
+
toolDefinitions?: ChatToolDefinition[] | ((ctx: StatefulAgentContext<S>) => ChatToolDefinition[] | Promise<ChatToolDefinition[]>);
|
|
1399
1477
|
/**
|
|
1400
|
-
* Factory returning the
|
|
1401
|
-
*
|
|
1402
|
-
*
|
|
1403
|
-
*
|
|
1478
|
+
* Factory returning the handler map for the **current state**. Called each
|
|
1479
|
+
* tool-loop iteration with the live `state` value, so the handler set the
|
|
1480
|
+
* driver dispatches against matches what `toolDefinitions` exposes to the
|
|
1481
|
+
* LLM that turn. Return only the handlers valid right now — no need to
|
|
1482
|
+
* advertise every handler the agent might ever expose, and no defensive
|
|
1483
|
+
* `if (!machine.matches(...))` guards inside each handler.
|
|
1484
|
+
*
|
|
1485
|
+
* Pair with the function form of `toolDefinitions` so the visible tools and
|
|
1486
|
+
* the dispatchable handlers stay in lockstep.
|
|
1404
1487
|
*
|
|
1405
|
-
*
|
|
1406
|
-
*
|
|
1407
|
-
*
|
|
1488
|
+
* **Constraint:** resolved handlers must not include fold facades. Folds and
|
|
1489
|
+
* state-machine-driven tool filtering both try to control the LLM's tool
|
|
1490
|
+
* view — pick one. Helper samples once on activation (init state) and
|
|
1491
|
+
* throws if a fold-tagged handler is detected; subsequent resolves also
|
|
1492
|
+
* validate, so misuse on a non-init state surfaces when that state is
|
|
1493
|
+
* reached.
|
|
1408
1494
|
*/
|
|
1409
|
-
toolHandlers?: (state: S) => ChatToolHandlers
|
|
1495
|
+
toolHandlers?: (state: S) => ChatToolHandlers | Promise<ChatToolHandlers>;
|
|
1410
1496
|
/**
|
|
1411
1497
|
* Optional getter for the debug-log snapshot. Defaults to auto-snapshotting
|
|
1412
1498
|
* any property on `state` that looks like a foundation-state-machine
|
|
@@ -1428,21 +1514,6 @@ export declare interface StatefulAgentInit<S> {
|
|
|
1428
1514
|
*/
|
|
1429
1515
|
export declare const strictFallbackAgent: FallbackAgentConfig;
|
|
1430
1516
|
|
|
1431
|
-
/**
|
|
1432
|
-
* A single in-flight per-call chat-input override pushed by a `requestSubAgent`
|
|
1433
|
-
* invocation. Tracked as an array (not a counter) so the slice can survive
|
|
1434
|
-
* pop-in/pop-out and so a listener that connects mid-execution can compute the
|
|
1435
|
-
* effective mode without having seen the start event.
|
|
1436
|
-
*
|
|
1437
|
-
* @internal
|
|
1438
|
-
*/
|
|
1439
|
-
declare interface SubAgentInputOverride {
|
|
1440
|
-
/** Unique per-invocation id, paired with the start/stop events. */
|
|
1441
|
-
id: string;
|
|
1442
|
-
/** The mode requested for this invocation. */
|
|
1443
|
-
mode: ChatInputDuringExecutionMode;
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
1517
|
/**
|
|
1447
1518
|
* State of the chat suggestions feature.
|
|
1448
1519
|
*
|
|
@@ -1548,6 +1619,18 @@ export declare interface ToolFoldResult {
|
|
|
1548
1619
|
handler: ChatToolHandlers;
|
|
1549
1620
|
}
|
|
1550
1621
|
|
|
1622
|
+
/**
|
|
1623
|
+
* Tool handlers for an agent. Either a static map (the conventional shape) or a
|
|
1624
|
+
* function resolved each tool-loop iteration. The function form lets the agent
|
|
1625
|
+
* narrow the dispatchable handler set per turn — pair it with the function form
|
|
1626
|
+
* of `toolDefinitions` so the LLM-visible tools and the dispatchable handlers
|
|
1627
|
+
* stay in lockstep, and handlers don't have to defend themselves against being
|
|
1628
|
+
* dispatched in states where their tool isn't advertised.
|
|
1629
|
+
*
|
|
1630
|
+
* @beta
|
|
1631
|
+
*/
|
|
1632
|
+
export declare type ToolHandlersInput = ChatToolHandlers | ((ctx: SystemPromptContext) => ChatToolHandlers | Promise<ChatToolHandlers>);
|
|
1633
|
+
|
|
1551
1634
|
/**
|
|
1552
1635
|
* A tool entry in the expanded debug tree.
|
|
1553
1636
|
* Folds are represented as nodes with a `tools` array; regular tools have none.
|
|
@@ -1580,6 +1663,12 @@ export declare interface TurnSnapshot {
|
|
|
1580
1663
|
systemPrompt?: string;
|
|
1581
1664
|
/** Tool names sent to the LLM, in order — definitions are static per name so names alone suffice. */
|
|
1582
1665
|
toolNames: string[];
|
|
1666
|
+
/**
|
|
1667
|
+
* Per-turn display label resolved from the agent's `displayName`, e.g.
|
|
1668
|
+
* "Guided Booking (Counterparties)". `agentName` stays as the canonical
|
|
1669
|
+
* identity used for routing/filtering.
|
|
1670
|
+
*/
|
|
1671
|
+
agentLabel?: string;
|
|
1583
1672
|
/** Agent-supplied snapshot — machine state/context for stateful agents, undefined otherwise. */
|
|
1584
1673
|
agentSnapshot?: unknown;
|
|
1585
1674
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AIProvider, ChatAttachment, ChatDriverResult, ChatMessage,
|
|
2
|
-
import type { AgentConfig, SystemPromptInput, ToolDefinitionsInput } from '../../config/config';
|
|
1
|
+
import type { AIProvider, ChatAttachment, ChatDriverResult, ChatMessage, InteractionRequestOptions } from '@genesislcap/foundation-ai';
|
|
2
|
+
import type { AgentConfig, SystemPromptInput, ToolDefinitionsInput, ToolHandlersInput } from '../../config/config';
|
|
3
3
|
import type { AiDriver, AllAgentSummary } from '../ai-driver/ai-driver';
|
|
4
4
|
/** Name reserved for the cross-agent handoff tool — injected by OrchestratingDriver. */
|
|
5
5
|
export declare const REQUEST_CONTINUATION_TOOL = "request_continuation";
|
|
@@ -30,6 +30,12 @@ export interface TurnSnapshot {
|
|
|
30
30
|
systemPrompt?: string;
|
|
31
31
|
/** Tool names sent to the LLM, in order — definitions are static per name so names alone suffice. */
|
|
32
32
|
toolNames: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Per-turn display label resolved from the agent's `displayName`, e.g.
|
|
35
|
+
* "Guided Booking (Counterparties)". `agentName` stays as the canonical
|
|
36
|
+
* identity used for routing/filtering.
|
|
37
|
+
*/
|
|
38
|
+
agentLabel?: string;
|
|
33
39
|
/** Agent-supplied snapshot — machine state/context for stateful agents, undefined otherwise. */
|
|
34
40
|
agentSnapshot?: unknown;
|
|
35
41
|
}
|
|
@@ -63,9 +69,31 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
63
69
|
* in that case.
|
|
64
70
|
*/
|
|
65
71
|
private toolDefinitionsFactory?;
|
|
72
|
+
/**
|
|
73
|
+
* Resolved tool handler map used for dispatch. When `toolHandlersFactory` is
|
|
74
|
+
* set, this is overwritten each tool-loop iteration with the factory's output
|
|
75
|
+
* — keeping it in lockstep with `toolDefinitions` so handlers don't have to
|
|
76
|
+
* defend themselves against being dispatched in states where their tool
|
|
77
|
+
* isn't advertised. Folds mutate this in place; `defineStatefulAgent`
|
|
78
|
+
* forbids folds when a factory is set, so the fold-mutation path is
|
|
79
|
+
* unreachable in that case.
|
|
80
|
+
*/
|
|
66
81
|
private toolHandlers;
|
|
82
|
+
/**
|
|
83
|
+
* Optional per-turn handler-map source. Mirrors `toolDefinitionsFactory` so
|
|
84
|
+
* the LLM-visible tools and the dispatchable handlers can be narrowed in
|
|
85
|
+
* lockstep. Resolved each tool-loop iteration before the LLM call.
|
|
86
|
+
*/
|
|
87
|
+
private toolHandlersFactory?;
|
|
67
88
|
private primerHistory?;
|
|
68
89
|
private activeAgentName?;
|
|
90
|
+
/**
|
|
91
|
+
* Per-turn display label resolved from the agent's `displayName`. Stamped
|
|
92
|
+
* onto outgoing messages and turn snapshots for UX; `activeAgentName` stays
|
|
93
|
+
* stable for routing/history-transform identity matching.
|
|
94
|
+
*/
|
|
95
|
+
private activeAgentLabel?;
|
|
96
|
+
private displayName?;
|
|
69
97
|
/**
|
|
70
98
|
* When set, `requestInteraction` delegates to this callback instead of using
|
|
71
99
|
* this driver's own pending map. Wired by `invokeSubAgent` so a sub-agent's
|
|
@@ -115,7 +143,7 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
115
143
|
/** Captured from `applyAgent` so we don't store the whole `AgentConfig`. */
|
|
116
144
|
private debugSnapshotter?;
|
|
117
145
|
private readonly maxTurnSnapshots;
|
|
118
|
-
constructor(aiProvider: AIProvider, toolHandlers?:
|
|
146
|
+
constructor(aiProvider: AIProvider, toolHandlers?: ToolHandlersInput, toolDefinitions?: ToolDefinitionsInput, systemPrompt?: SystemPromptInput, primerHistory?: ChatMessage[], maxToolIterations?: number, maxFoldOperations?: number, maxTurnSnapshots?: number);
|
|
119
147
|
/**
|
|
120
148
|
* Swap in a new agent's configuration. Called by OrchestratingDriver before
|
|
121
149
|
* each specialist turn so the shared driver runs with the right tools and prompt.
|
|
@@ -164,7 +192,7 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
164
192
|
* resolves through) the parent's history and pending map. Calls chain
|
|
165
193
|
* naturally: a grandchild → child → root.
|
|
166
194
|
*/
|
|
167
|
-
setHostInteractionRequester(fn: <T>(componentName: string, data: any) => Promise<T>): void;
|
|
195
|
+
setHostInteractionRequester(fn: <T>(componentName: string, data: any, options?: InteractionRequestOptions) => Promise<T>): void;
|
|
168
196
|
/**
|
|
169
197
|
* Request a custom UI interaction. Emits a new message with the interaction.
|
|
170
198
|
* Tool handlers can call this to pause execution until the user completes the UI interaction.
|
|
@@ -178,8 +206,11 @@ export declare class ChatDriver extends EventTarget implements AiDriver {
|
|
|
178
206
|
*
|
|
179
207
|
* @param componentName - The custom element name to render.
|
|
180
208
|
* @param data - Data to pass to the component.
|
|
209
|
+
* @param options - Optional per-call overrides, including
|
|
210
|
+
* `chatInputDuringExecution` to hide or disable the main chat input while
|
|
211
|
+
* the widget is awaiting user input. Reverts when the interaction resolves.
|
|
181
212
|
*/
|
|
182
|
-
requestInteraction<T>(componentName: string, data: any): Promise<T>;
|
|
213
|
+
requestInteraction<T>(componentName: string, data: any, options?: InteractionRequestOptions): Promise<T>;
|
|
183
214
|
/**
|
|
184
215
|
* Resolve a pending interaction. The wrapper component calls this on completion.
|
|
185
216
|
* Marks the interaction message as resolved so it renders read-only on re-render.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-driver.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-driver/chat-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,WAAW,
|
|
1
|
+
{"version":3,"file":"chat-driver.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-driver/chat-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,WAAW,EAKX,yBAAyB,EAE1B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EACV,WAAW,EAEX,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAUxE,wFAAwF;AACxF,eAAO,MAAM,yBAAyB,yBAAyB,CAAC;AAMhE;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC;AAE9E;;;;;;;;;GASG;AACH,MAAM,WAAW,YAAY;IAC3B,qFAAqF;IACrF,SAAS,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qGAAqG;IACrG,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gGAAgG;IAChG,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAQD;;;;;;;;;GASG;AACH,qBAAa,UAAW,SAAQ,WAAY,YAAW,QAAQ;IAiH3D,OAAO,CAAC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T,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,CAAC,CAAC;IAkCb;;;OAGG;IACI,kBAAkB,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,IAAI;IAyBnE;;;OAGG;IACI,WAAW,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI;IAS3C,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAuB/F;;;;;;;;OAQG;IACH,OAAO,CAAC,mBAAmB;IAsC3B;;;;;OAKG;YACW,cAAc;IAmF5B;;;OAGG;IACG,mBAAmB,CAAC,eAAe,CAAC,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAwBrF,wFAAwF;IACxF,OAAO,CAAC,OAAO;IAKf;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAc1B;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IA+BxB,uFAAuF;IACvF,OAAO,CAAC,QAAQ;IAqChB,OAAO,CAAC,aAAa;IAQrB,8EAA8E;IAC9E,OAAO,CAAC,SAAS;IAWjB,mFAAmF;IACnF,OAAO,CAAC,2BAA2B;YAkCrB,WAAW;IA0XzB,OAAO,CAAC,eAAe;CAgBxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrating-driver.d.ts","sourceRoot":"","sources":["../../../../src/components/orchestrating-driver/orchestrating-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,WAAW,EAEZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACV,WAAW,EAKZ,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,4BAA4B,CAAC;AA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AAQ,EAAE,WAAW,EAAE,GAAG,IAAI;IAI1C,aAAa,IAAI,SAAS,WAAW,EAAE;IAIvC,4EAA4E;IAC5E,gBAAgB,IAAI,aAAa,CAAC,YAAY,CAAC;IAIzC,cAAc,CAClB,OAAO,EAAE,WAAW,EAAE,EACtB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,eAAe,EAAE,GAC/B,OAAO,CAAC,MAAM,EAAE,CAAC;IAgBd,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAwErF,mBAAmB,CAAC,eAAe,CAAC,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;YAIvE,UAAU;IAgFxB;;;;OAIG;YACW,kBAAkB;IAuBhC;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAiBhB,QAAQ;IA+FtB;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,mBAAmB;CAO5B"}
|
|
@@ -48,6 +48,17 @@ export type SystemPromptInput = string | ((ctx: SystemPromptContext) => string |
|
|
|
48
48
|
* @beta
|
|
49
49
|
*/
|
|
50
50
|
export type ToolDefinitionsInput = ChatToolDefinition[] | ((ctx: SystemPromptContext) => ChatToolDefinition[] | Promise<ChatToolDefinition[]>);
|
|
51
|
+
/**
|
|
52
|
+
* Tool handlers for an agent. Either a static map (the conventional shape) or a
|
|
53
|
+
* function resolved each tool-loop iteration. The function form lets the agent
|
|
54
|
+
* narrow the dispatchable handler set per turn — pair it with the function form
|
|
55
|
+
* of `toolDefinitions` so the LLM-visible tools and the dispatchable handlers
|
|
56
|
+
* stay in lockstep, and handlers don't have to defend themselves against being
|
|
57
|
+
* dispatched in states where their tool isn't advertised.
|
|
58
|
+
*
|
|
59
|
+
* @beta
|
|
60
|
+
*/
|
|
61
|
+
export type ToolHandlersInput = ChatToolHandlers | ((ctx: SystemPromptContext) => ChatToolHandlers | Promise<ChatToolHandlers>);
|
|
51
62
|
/**
|
|
52
63
|
* Opts an agent in to manual selection from the assistant's agent picker.
|
|
53
64
|
*
|
|
@@ -69,9 +80,21 @@ export interface ManualSelectionConfig {
|
|
|
69
80
|
}
|
|
70
81
|
interface BaseAgentConfig {
|
|
71
82
|
/**
|
|
72
|
-
*
|
|
83
|
+
* Stable identity for this agent. Used for classifier routing, manual
|
|
84
|
+
* pinning, and history filtering — must not vary per turn. For a per-turn
|
|
85
|
+
* display label (e.g. "Guided Booking (Counterparties)"), supply
|
|
86
|
+
* {@link BaseAgentConfig.displayName}.
|
|
73
87
|
*/
|
|
74
88
|
name: string;
|
|
89
|
+
/**
|
|
90
|
+
* Optional per-turn display label. Resolved each tool-loop iteration and
|
|
91
|
+
* stamped onto outgoing messages (`agentLabel`) and the debug-log timeline.
|
|
92
|
+
* Renderers fall back to `name` when this is unset. Use the function form
|
|
93
|
+
* to vary the label by current state (e.g. a state machine's step).
|
|
94
|
+
*
|
|
95
|
+
* Identity stays on `name` — this is for UX only.
|
|
96
|
+
*/
|
|
97
|
+
displayName?: SystemPromptInput;
|
|
75
98
|
/**
|
|
76
99
|
* System prompt injected into every conversation turn for this agent.
|
|
77
100
|
*
|
|
@@ -91,8 +114,13 @@ interface BaseAgentConfig {
|
|
|
91
114
|
toolDefinitions?: ToolDefinitionsInput;
|
|
92
115
|
/**
|
|
93
116
|
* Tool handler implementations for this agent.
|
|
117
|
+
*
|
|
118
|
+
* Either a static map or a function resolved each tool-loop iteration —
|
|
119
|
+
* pick the function form to narrow the dispatchable handler set per turn,
|
|
120
|
+
* matching the function form of `toolDefinitions`.
|
|
121
|
+
* See {@link ToolHandlersInput}.
|
|
94
122
|
*/
|
|
95
|
-
toolHandlers?:
|
|
123
|
+
toolHandlers?: ToolHandlersInput;
|
|
96
124
|
/**
|
|
97
125
|
* Optional primer history prepended to every call (not visible to the user).
|
|
98
126
|
* Used to establish agent identity and behavioural rules.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EAAE,4BAA4B,EAAE,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,wFAAwF;IACxF,UAAU,EAAE,MAAM,CAAC;IACnB,+FAA+F;IAC/F,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,yDAAyD;IACzD,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,uFAAuF;IACvF,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACpC,mFAAmF;IACnF,SAAS,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,mBAAmB,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAElG;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAC5B,kBAAkB,EAAE,GACpB,CAAC,CAAC,GAAG,EAAE,mBAAmB,KAAK,kBAAkB,EAAE,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;AAEzF;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,eAAe;IACvB
|
|
1
|
+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AC;CACrB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,qBAAqB,GAAG,mBAAmB,CAAC;AAEtE;;;;;;;;;;;;;;GAcG;AAEH,wBAAgB,WAAW,CAAC,KAAK,CAAC,CAAC,SAAS,WAAW,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAErE"}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import type { ChatMessage, ChatToolDefinition, ChatToolHandlers } from '@genesislcap/foundation-ai';
|
|
2
2
|
import type { AgentConfig, AgentLifecycleContext, ChatInputDuringExecutionMode, ManualSelectionConfig, SystemPromptContext } from './config';
|
|
3
|
+
/**
|
|
4
|
+
* Context passed to per-turn resolvers on a stateful agent — the standard
|
|
5
|
+
* {@link SystemPromptContext} plus the live `state` value. Used by
|
|
6
|
+
* `systemPrompt`, `displayName`, and the function form of `toolDefinitions`.
|
|
7
|
+
*
|
|
8
|
+
* Exported so consumers can lift resolvers into separate files without
|
|
9
|
+
* re-deriving the shape.
|
|
10
|
+
*
|
|
11
|
+
* @beta
|
|
12
|
+
*/
|
|
13
|
+
export type StatefulAgentContext<S> = SystemPromptContext & {
|
|
14
|
+
state: S;
|
|
15
|
+
};
|
|
3
16
|
/**
|
|
4
17
|
* Init options for {@link defineStatefulAgent}. Generic over the state shape `S`
|
|
5
18
|
* the agent owns (a state machine, an observable controller, anything).
|
|
@@ -47,9 +60,14 @@ export interface StatefulAgentInit<S> {
|
|
|
47
60
|
* iteration. Use this to feed the LLM whatever the current state implies
|
|
48
61
|
* (e.g. a state machine's `meta.systemPrompt` plus captured context).
|
|
49
62
|
*/
|
|
50
|
-
systemPrompt?: (ctx:
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
systemPrompt?: (ctx: StatefulAgentContext<S>) => string | Promise<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Per-turn display label, e.g. "Guided Booking (Counterparties)". Resolved
|
|
66
|
+
* each tool-loop iteration and stamped onto outgoing messages and the
|
|
67
|
+
* debug-log timeline — display only. The agent's `name` stays as the
|
|
68
|
+
* canonical identity used for routing/history filtering.
|
|
69
|
+
*/
|
|
70
|
+
displayName?: (ctx: StatefulAgentContext<S>) => string | Promise<string>;
|
|
53
71
|
/**
|
|
54
72
|
* Tool definitions the LLM sees. Either a static array (resolved once) or a
|
|
55
73
|
* function resolved each tool-loop iteration. The function form is how a
|
|
@@ -61,20 +79,26 @@ export interface StatefulAgentInit<S> {
|
|
|
61
79
|
* has to be in charge. Helper throws at init time if a fold-tagged handler
|
|
62
80
|
* is detected.
|
|
63
81
|
*/
|
|
64
|
-
toolDefinitions?: ChatToolDefinition[] | ((ctx:
|
|
65
|
-
state: S;
|
|
66
|
-
}) => ChatToolDefinition[] | Promise<ChatToolDefinition[]>);
|
|
82
|
+
toolDefinitions?: ChatToolDefinition[] | ((ctx: StatefulAgentContext<S>) => ChatToolDefinition[] | Promise<ChatToolDefinition[]>);
|
|
67
83
|
/**
|
|
68
|
-
* Factory returning the
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
84
|
+
* Factory returning the handler map for the **current state**. Called each
|
|
85
|
+
* tool-loop iteration with the live `state` value, so the handler set the
|
|
86
|
+
* driver dispatches against matches what `toolDefinitions` exposes to the
|
|
87
|
+
* LLM that turn. Return only the handlers valid right now — no need to
|
|
88
|
+
* advertise every handler the agent might ever expose, and no defensive
|
|
89
|
+
* `if (!machine.matches(...))` guards inside each handler.
|
|
90
|
+
*
|
|
91
|
+
* Pair with the function form of `toolDefinitions` so the visible tools and
|
|
92
|
+
* the dispatchable handlers stay in lockstep.
|
|
72
93
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
94
|
+
* **Constraint:** resolved handlers must not include fold facades. Folds and
|
|
95
|
+
* state-machine-driven tool filtering both try to control the LLM's tool
|
|
96
|
+
* view — pick one. Helper samples once on activation (init state) and
|
|
97
|
+
* throws if a fold-tagged handler is detected; subsequent resolves also
|
|
98
|
+
* validate, so misuse on a non-init state surfaces when that state is
|
|
99
|
+
* reached.
|
|
76
100
|
*/
|
|
77
|
-
toolHandlers?: (state: S) => ChatToolHandlers
|
|
101
|
+
toolHandlers?: (state: S) => ChatToolHandlers | Promise<ChatToolHandlers>;
|
|
78
102
|
/**
|
|
79
103
|
* Optional getter for the debug-log snapshot. Defaults to auto-snapshotting
|
|
80
104
|
* any property on `state` that looks like a foundation-state-machine
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-stateful-agent.d.ts","sourceRoot":"","sources":["../../../src/config/define-stateful-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEpG,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EACrB,4BAA4B,EAC5B,qBAAqB,EACrB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"define-stateful-agent.d.ts","sourceRoot":"","sources":["../../../src/config/define-stateful-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEpG,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EACrB,4BAA4B,EAC5B,qBAAqB,EACrB,mBAAmB,EAIpB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;GASG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,mBAAmB,GAAG;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAEzE;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,2GAA2G;IAC3G,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,+EAA+E;IAC/E,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;IAC9B,gFAA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CAoH9E"}
|
package/dist/dts/main/main.d.ts
CHANGED
|
@@ -93,13 +93,13 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
93
93
|
get liveSubAgentName(): string | null;
|
|
94
94
|
set liveSubAgentName(value: string | null);
|
|
95
95
|
/**
|
|
96
|
-
* In-flight per-call chat-input overrides pushed by `requestSubAgent`
|
|
97
|
-
*
|
|
96
|
+
* In-flight per-call chat-input overrides pushed by `requestSubAgent` or
|
|
97
|
+
* `requestInteraction` calls. Empty means no override is active.
|
|
98
98
|
*/
|
|
99
|
-
get
|
|
99
|
+
get inputOverrides(): import("../state/ai-assistant-slice").InputOverride[];
|
|
100
100
|
/**
|
|
101
101
|
* Resolves the effective chat-input behaviour while the assistant is
|
|
102
|
-
* executing.
|
|
102
|
+
* executing. Per-call overrides take precedence over the agent-level
|
|
103
103
|
* config; among overrides the most restrictive wins (`'hidden'` >
|
|
104
104
|
* `'disabled'`). Falls back to the active agent's config, then `'disabled'`.
|
|
105
105
|
*/
|
|
@@ -282,7 +282,7 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
282
282
|
timestamp: string;
|
|
283
283
|
host: string;
|
|
284
284
|
agentSummary: ({
|
|
285
|
-
toolDefinitions: string | import("
|
|
285
|
+
toolDefinitions: string | import("@genesislcap/foundation-ai").ChatToolDefinition[];
|
|
286
286
|
toolHandlers: any;
|
|
287
287
|
onActivate: any;
|
|
288
288
|
onDeactivate: any;
|
|
@@ -291,13 +291,14 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
291
291
|
fallback?: never;
|
|
292
292
|
excludeFromClassifier?: boolean;
|
|
293
293
|
name: string;
|
|
294
|
+
displayName?: import("../config/config").SystemPromptInput;
|
|
294
295
|
systemPrompt?: import("../config/config").SystemPromptInput;
|
|
295
296
|
primerHistory?: ChatMessage[];
|
|
296
297
|
subAgents?: AgentConfig[];
|
|
297
298
|
chatInputDuringExecution?: ChatInputDuringExecutionMode;
|
|
298
299
|
manualSelection?: import("../config/config").ManualSelectionConfig;
|
|
299
300
|
} | {
|
|
300
|
-
toolDefinitions: string | import("
|
|
301
|
+
toolDefinitions: string | import("@genesislcap/foundation-ai").ChatToolDefinition[];
|
|
301
302
|
toolHandlers: any;
|
|
302
303
|
onActivate: any;
|
|
303
304
|
onDeactivate: any;
|
|
@@ -305,6 +306,7 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
305
306
|
fallback: true;
|
|
306
307
|
description?: never;
|
|
307
308
|
name: string;
|
|
309
|
+
displayName?: import("../config/config").SystemPromptInput;
|
|
308
310
|
systemPrompt?: import("../config/config").SystemPromptInput;
|
|
309
311
|
primerHistory?: ChatMessage[];
|
|
310
312
|
subAgents?: AgentConfig[];
|