@genesislcap/ai-assistant 14.437.0 → 14.437.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.
@@ -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,EAIX,gBAAgB,EAChB,yBAAyB,EAE1B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EACV,WAAW,EAEX,iBAAiB,EACjB,oBAAoB,EACrB,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,gGAAgG;IAChG,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAQD;;;;;;;;;GASG;AACH,qBAAa,UAAW,SAAQ,WAAY,YAAW,QAAQ;IAyF3D,OAAO,CAAC,QAAQ,CAAC,UAAU;IAK3B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IA7FpC,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,mBAAmB,CAQ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,2BAA2B,CAChC,EAAE,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,yBAAyB,KAAK,OAAO,CAAC,CAAC,CAAC,GAC3F,IAAI;IAIP;;;;;;;;;;;;;;;;OAgBG;IACU,kBAAkB,CAAC,CAAC,EAC/B,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,GAAG,EACT,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"}
@@ -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
- * Display name shown in the chat header when this agent is active.
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?: ChatToolHandlers;
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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eAAe;IAC1D;;OAEG;IACH,QAAQ,EAAE,IAAI,CAAC;IACf,WAAW,CAAC,EAAE,KAAK,CAAC;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: SystemPromptContext & {
51
- state: S;
52
- }) => string | Promise<string>;
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: SystemPromptContext & {
65
- state: S;
66
- }) => ChatToolDefinition[] | Promise<ChatToolDefinition[]>);
82
+ toolDefinitions?: ChatToolDefinition[] | ((ctx: StatefulAgentContext<S>) => ChatToolDefinition[] | Promise<ChatToolDefinition[]>);
67
83
  /**
68
- * Factory returning the tool handler map. Called with the live `state` at
69
- * `onActivate` time; the handlers it returns are cached for the lifetime of
70
- * this activation. Each handler closes over `state` and any other deps you
71
- * captured.
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
- * The handler set returned must be the **union** of every tool name your
74
- * agent might advertise across all states `toolDefinitions` filters which
75
- * are visible to the LLM per turn, but every name still needs an entry here.
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,EAEpB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;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,gFAAgF;IAChF,SAAS,CAAC,EAAE,WAAW,EAAE,CAAC;IAC1B,oDAAoD;IACpD,eAAe,CAAC,EAAE,qBAAqB,CAAC;IACxC,qEAAqE;IACrE,wBAAwB,CAAC,EAAE,4BAA4B,CAAC;IAExD;;;OAGG;IACH,IAAI,EAAE,CAAC,GAAG,EAAE,qBAAqB,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAErD;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,qBAAqB,GAAG;QAAE,KAAK,EAAE,CAAC,CAAA;KAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9E;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,mBAAmB,GAAG;QAAE,KAAK,EAAE,CAAC,CAAA;KAAE,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAErF;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EACZ,kBAAkB,EAAE,GACpB,CAAC,CACC,GAAG,EAAE,mBAAmB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qE;IACrE,wBAAwB,CAAC,EAAE,4BAA4B,CAAC;IAExD;;;OAGG;IACH,IAAI,EAAE,CAAC,GAAG,EAAE,qBAAqB,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAErD;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,qBAAqB,GAAG;QAAE,KAAK,EAAE,CAAC,CAAA;KAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9E;;;;OAIG;IACH,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1E;;;;;OAKG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzE;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EACZ,kBAAkB,EAAE,GACpB,CAAC,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,kBAAkB,EAAE,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;IAE7F;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAE1E;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;CAC1C;AAsCD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,WAAW,CAoH9E"}
@@ -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("../utils/tool-fold").ToolTreeNode[];
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("../utils/tool-fold").ToolTreeNode[];
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[];
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/main/main.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,4BAA4B,EAC5B,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAGL,cAAc,EAIf,MAAM,uBAAuB,CAAC;AAW/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAgBpD,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EACjB,MAAM,cAAc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/** Monotonic counter that survives agent swaps — useful for cross-referencing with history. */
60
60
  this.globalTurnIndex = 0;
61
- this.toolHandlers = toolHandlers;
61
+ if (typeof toolHandlers === 'function') {
62
+ this.toolHandlersFactory = toolHandlers;
63
+ this.toolHandlers = {};
64
+ }
65
+ else {
66
+ this.toolHandlersFactory = undefined;
67
+ this.toolHandlers = toolHandlers;
68
+ }
62
69
  if (typeof toolDefinitions === 'function') {
63
70
  this.toolDefinitionsFactory = toolDefinitions;
64
71
  this.toolDefinitions = [];
@@ -89,9 +96,24 @@ export class ChatDriver extends EventTarget {
89
96
  this.toolDefinitionsFactory = undefined;
90
97
  this.toolDefinitions = (_a = config.toolDefinitions) !== null && _a !== void 0 ? _a : [];
91
98
  }
92
- this.toolHandlers = (_b = config.toolHandlers) !== null && _b !== void 0 ? _b : {};
99
+ if (typeof config.toolHandlers === 'function') {
100
+ this.toolHandlersFactory = config.toolHandlers;
101
+ // Cleared each turn by the factory in runToolLoop; empty is safe in the
102
+ // meantime (no LLM call happens before resolution).
103
+ this.toolHandlers = {};
104
+ }
105
+ else {
106
+ this.toolHandlersFactory = undefined;
107
+ this.toolHandlers = (_b = config.toolHandlers) !== null && _b !== void 0 ? _b : {};
108
+ }
93
109
  this.primerHistory = config.primerHistory;
94
110
  this.activeAgentName = config.name;
111
+ this.displayName = config.displayName;
112
+ // Static string form resolves to a stable label up-front; the function
113
+ // form gets re-resolved each tool-loop iteration. Falls back to the
114
+ // canonical name when displayName is unset.
115
+ this.activeAgentLabel =
116
+ typeof config.displayName === 'string' ? config.displayName : config.name;
95
117
  this.debugSnapshotter = config.getDebugSnapshot;
96
118
  this.subAgentsMap = new Map(((_c = config.subAgents) !== null && _c !== void 0 ? _c : []).map((s) => [s.name, s]));
97
119
  // Reset fold state when agent changes — each specialist starts fresh
@@ -146,6 +168,7 @@ export class ChatDriver extends EventTarget {
146
168
  turnIndex,
147
169
  timestamp: new Date().toISOString(),
148
170
  agentName: this.activeAgentName,
171
+ agentLabel: this.activeAgentLabel,
149
172
  systemPrompt: resolvedSystemPrompt,
150
173
  toolNames: this.toolDefinitions.map((t) => t.name),
151
174
  agentSnapshot,
@@ -624,6 +647,7 @@ export class ChatDriver extends EventTarget {
624
647
  // ---------------------------------------------------------------------------
625
648
  // Tool loop
626
649
  // ---------------------------------------------------------------------------
650
+ // eslint-disable-next-line complexity
627
651
  runToolLoop(userInput, attachments, transientPrimer) {
628
652
  return __awaiter(this, void 0, void 0, function* () {
629
653
  var _a, _b, _c, _d, _e, _f, _g;
@@ -658,10 +682,26 @@ export class ChatDriver extends EventTarget {
658
682
  // eslint-disable-next-line no-await-in-loop
659
683
  this.toolDefinitions = yield this.toolDefinitionsFactory(promptCtx);
660
684
  }
685
+ // Same story for the handler-map factory: re-resolve so dispatch sees
686
+ // only the handlers valid for the current state, in lockstep with the
687
+ // tool definitions exposed above. Folds are forbidden when this is set,
688
+ // so the fold-mutation paths on `this.toolHandlers` are unreachable.
689
+ if (this.toolHandlersFactory) {
690
+ // eslint-disable-next-line no-await-in-loop
691
+ this.toolHandlers = yield this.toolHandlersFactory(promptCtx);
692
+ }
661
693
  const resolvedSystemPrompt = typeof this.systemPrompt === 'function'
662
694
  ? // eslint-disable-next-line no-await-in-loop
663
695
  yield this.systemPrompt(promptCtx)
664
696
  : this.systemPrompt;
697
+ // Re-resolve the per-turn display label. Falls back to the canonical
698
+ // agent name when displayName is unset. Stamped onto outgoing messages
699
+ // and turn snapshots for UX only; routing/history-transform continues
700
+ // to read `activeAgentName`.
701
+ if (typeof this.displayName === 'function') {
702
+ // eslint-disable-next-line no-await-in-loop
703
+ this.activeAgentLabel = yield this.displayName(promptCtx);
704
+ }
665
705
  const foldSuffix = this.buildFoldSystemPromptSuffix();
666
706
  const baseSystemPrompt = resolvedSystemPrompt
667
707
  ? `${resolvedSystemPrompt}${foldSuffix}`
@@ -926,7 +966,9 @@ export class ChatDriver extends EventTarget {
926
966
  }
927
967
  appendToHistory(message) {
928
968
  const tagged = this.activeAgentName
929
- ? Object.assign(Object.assign({}, message), { agentName: this.activeAgentName }) : message;
969
+ ? Object.assign(Object.assign({}, message), { agentName: this.activeAgentName,
970
+ // Display-only — falls back to agentName in renderers when unset.
971
+ agentLabel: this.activeAgentLabel }) : message;
930
972
  this.history = [...this.history, tagged];
931
973
  this.dispatchEvent(new CustomEvent('history-updated', {
932
974
  detail: this.history,
@@ -59,7 +59,6 @@ function defaultStatefulDebugSnapshot(state) {
59
59
  */
60
60
  export function defineStatefulAgent(opts) {
61
61
  let state;
62
- let cachedHandlers;
63
62
  const assertNoFolds = (handlers) => {
64
63
  for (const [name, handler] of Object.entries(handlers)) {
65
64
  if (handler[TOOL_FOLD_SYMBOL]) {
@@ -85,59 +84,48 @@ export function defineStatefulAgent(opts) {
85
84
  }
86
85
  return td;
87
86
  })();
88
- // Each proxy entry calls into `cachedHandlers`, which is populated eagerly
89
- // inside `onActivate` (see below). Eager population means the no-folds
90
- // assertion fires at activation time not on first tool call — so a
91
- // misconfigured agent fails loud and immediately instead of silently
92
- // appearing to work until the LLM happens to invoke a tool.
93
- const buildHandlerProxy = (names) => {
94
- const out = {};
95
- for (const name of names) {
96
- out[name] = (args, ctx) => __awaiter(this, void 0, void 0, function* () {
97
- if (!state || !cachedHandlers) {
98
- throw new Error(`Stateful agent "${opts.name}" handler called before init`);
99
- }
100
- const handler = cachedHandlers[name];
101
- if (!handler) {
102
- throw new Error(`Tool "${name}" has no handler on stateful agent "${opts.name}"`);
103
- }
104
- return handler(args, ctx);
105
- });
106
- }
107
- return out;
108
- };
109
- // Static-tools case: handler names are knowable from the definitions array.
110
- // Dynamic-tools case: we discover names from a sample of `toolHandlers(state)`
111
- // taken inside onActivate. Until then, the handler dict is empty — fine
112
- // because no tool call can happen before activation completes.
113
- const staticHandlerProxy = Array.isArray(opts.toolDefinitions) && opts.toolHandlers
114
- ? buildHandlerProxy(opts.toolDefinitions.map((d) => d.name))
87
+ // Wrap the handler factory into the ctx-shaped form the driver expects, and
88
+ // validate folds on each resolve. The driver re-resolves this per tool-loop
89
+ // iteration, so the handler set the driver dispatches against always
90
+ // matches the LLM-visible tools for the current state — handlers don't need
91
+ // defensive `if (!machine.matches(...))` guards.
92
+ const wrappedHandlers = opts.toolHandlers
93
+ ? () => __awaiter(this, void 0, void 0, function* () {
94
+ if (!state) {
95
+ throw new Error(`Stateful agent "${opts.name}" handlers called before init`);
96
+ }
97
+ const handlers = yield opts.toolHandlers(state);
98
+ assertNoFolds(handlers);
99
+ return handlers;
100
+ })
101
+ : undefined;
102
+ const wrappedDisplayName = opts.displayName
103
+ ? (ctx) => __awaiter(this, void 0, void 0, function* () {
104
+ if (!state) {
105
+ throw new Error(`Stateful agent "${opts.name}" displayName called before init`);
106
+ }
107
+ return opts.displayName(Object.assign(Object.assign({}, ctx), { state }));
108
+ })
115
109
  : undefined;
116
- // For the dynamic case we patch this object in place on activation. The
117
- // driver reads `toolHandlers` by reference, so mutating in place is enough.
118
- const resolvedHandlers = staticHandlerProxy !== null && staticHandlerProxy !== void 0 ? staticHandlerProxy : {};
119
110
  const base = {
120
111
  name: opts.name,
112
+ displayName: wrappedDisplayName,
121
113
  primerHistory: opts.primerHistory,
122
114
  subAgents: opts.subAgents,
123
115
  manualSelection: opts.manualSelection,
124
116
  chatInputDuringExecution: opts.chatInputDuringExecution,
125
117
  toolDefinitions: wrappedTools,
126
- toolHandlers: opts.toolHandlers ? resolvedHandlers : undefined,
118
+ toolHandlers: wrappedHandlers,
127
119
  onActivate: (ctx) => __awaiter(this, void 0, void 0, function* () {
128
- var _a, _b;
129
120
  state = yield opts.init(ctx);
130
- // Sample handlers eagerly and validate up-front. Throws here are visible
131
- // at the agent-switch boundary instead of buried inside a future tool
132
- // dispatch.
133
- cachedHandlers = (_b = (_a = opts.toolHandlers) === null || _a === void 0 ? void 0 : _a.call(opts, state)) !== null && _b !== void 0 ? _b : {};
134
- assertNoFolds(cachedHandlers);
135
- // Dynamic-tools path: handler names are discovered from the sample.
136
- if (!staticHandlerProxy && opts.toolHandlers) {
137
- const dynamicProxy = buildHandlerProxy(Object.keys(cachedHandlers));
138
- for (const key of Object.keys(resolvedHandlers))
139
- delete resolvedHandlers[key];
140
- Object.assign(resolvedHandlers, dynamicProxy);
121
+ // Sample once with the init state to fail loud on fold misuse at the
122
+ // agent-switch boundary instead of waiting for the first tool call.
123
+ // The driver re-resolves the factory each iteration, so misuse on
124
+ // handlers gated behind a non-init state surfaces when that state is
125
+ // reached — same loud failure mode, narrower coverage.
126
+ if (opts.toolHandlers) {
127
+ const sampled = yield opts.toolHandlers(state);
128
+ assertNoFolds(sampled);
141
129
  }
142
130
  }),
143
131
  onDeactivate: (ctx) => __awaiter(this, void 0, void 0, function* () {
@@ -148,7 +136,6 @@ export function defineStatefulAgent(opts) {
148
136
  // cannot interleave the read-then-write of `state`.
149
137
  // eslint-disable-next-line require-atomic-updates
150
138
  state = undefined;
151
- cachedHandlers = undefined;
152
139
  }),
153
140
  systemPrompt: opts.systemPrompt
154
141
  ? (ctx) => __awaiter(this, void 0, void 0, function* () {
@@ -73,13 +73,14 @@ avoidTreeShaking(AiChatMarkdown, AiChatInteractionWrapper, AiHaloOverlay, AiChat
73
73
  * Recursively strips non-serializable fields from an agent before storing in Redux:
74
74
  * - `toolHandlers` (functions),
75
75
  * - `onActivate` / `onDeactivate` (lifecycle hooks, functions),
76
- * - function-form `systemPrompt` / `toolDefinitions` (downgraded to `undefined`
77
- * in the snapshot the live config on the driver is still the source of
78
- * truth; the slice only stores a serializable projection).
76
+ * - `getDebugSnapshot` (function),
77
+ * - function-form `systemPrompt` / `toolDefinitions` / `displayName` (downgraded
78
+ * to `undefined` in the snapshot the live config on the driver is still
79
+ * the source of truth; the slice only stores a serializable projection).
79
80
  */
80
81
  function stripHandlers(agent) {
81
- const { toolHandlers: _h, onActivate: _on, onDeactivate: _off, getDebugSnapshot: _g, subAgents, systemPrompt, toolDefinitions } = agent, rest = __rest(agent, ["toolHandlers", "onActivate", "onDeactivate", "getDebugSnapshot", "subAgents", "systemPrompt", "toolDefinitions"]);
82
- const stripped = Object.assign(Object.assign({}, rest), { systemPrompt: typeof systemPrompt === 'function' ? undefined : systemPrompt, toolDefinitions: typeof toolDefinitions === 'function' ? undefined : toolDefinitions });
82
+ const { toolHandlers: _h, onActivate: _on, onDeactivate: _off, getDebugSnapshot: _g, subAgents, systemPrompt, toolDefinitions, displayName } = agent, rest = __rest(agent, ["toolHandlers", "onActivate", "onDeactivate", "getDebugSnapshot", "subAgents", "systemPrompt", "toolDefinitions", "displayName"]);
83
+ const stripped = Object.assign(Object.assign({}, rest), { systemPrompt: typeof systemPrompt === 'function' ? undefined : systemPrompt, toolDefinitions: typeof toolDefinitions === 'function' ? undefined : toolDefinitions, displayName: typeof displayName === 'function' ? undefined : displayName });
83
84
  return (subAgents === null || subAgents === void 0 ? void 0 : subAgents.length)
84
85
  ? Object.assign(Object.assign({}, stripped), { subAgents: subAgents.map(stripHandlers) }) : stripped;
85
86
  }
@@ -472,9 +473,15 @@ let FoundationAiAssistant = FoundationAiAssistant_1 = class FoundationAiAssistan
472
473
  return agents
473
474
  .map((a) => {
474
475
  var _a;
475
- const toolNames = Object.keys((_a = a.toolHandlers) !== null && _a !== void 0 ? _a : {})
476
- .sort()
477
- .join('+');
476
+ // Function-form handlers are resolved per turn their full key set
477
+ // isn't knowable at fingerprint time. A constant marker still
478
+ // distinguishes static-vs-dynamic shape changes; finer-grained
479
+ // detection isn't load-bearing here.
480
+ const toolNames = typeof a.toolHandlers === 'function'
481
+ ? '<fn>'
482
+ : Object.keys((_a = a.toolHandlers) !== null && _a !== void 0 ? _a : {})
483
+ .sort()
484
+ .join('+');
478
485
  return `${a.name}[${toolNames}]`;
479
486
  })
480
487
  .join(',');
@@ -1048,7 +1055,11 @@ let FoundationAiAssistant = FoundationAiAssistant_1 = class FoundationAiAssistan
1048
1055
  agentSummary: (_f = this.agents) === null || _f === void 0 ? void 0 : _f.map((a) => {
1049
1056
  var _a;
1050
1057
  return (Object.assign(Object.assign({}, a), { toolDefinitions: Array.isArray(a.toolDefinitions)
1051
- ? expandToolTree(a.toolDefinitions, (_a = a.toolHandlers) !== null && _a !== void 0 ? _a : {})
1058
+ ? typeof a.toolHandlers === 'function'
1059
+ ? // Static defs + dynamic handlers — can't walk fold tree
1060
+ // because the handler map isn't materialized at log time.
1061
+ a.toolDefinitions
1062
+ : expandToolTree(a.toolDefinitions, (_a = a.toolHandlers) !== null && _a !== void 0 ? _a : {})
1052
1063
  : typeof a.toolDefinitions === 'function'
1053
1064
  ? '<dynamic — resolved per turn>'
1054
1065
  : [], toolHandlers: undefined, onActivate: undefined, onDeactivate: undefined, getDebugSnapshot: undefined }));
@@ -163,11 +163,14 @@ ${(tc) => { var _a; return (((_a = tc.foldPath) === null || _a === void 0 ? void
163
163
  `)}
164
164
  <div class="message ${(m) => messageType(m)}">
165
165
  <div class="sender">
166
- ${(m, c) => messageType(m) === 'ai-function' &&
167
- m.agentName &&
168
- c.parent.showAgentSwitchIndicator
169
- ? `Tool Call · ${m.agentName}`
170
- : senderLabel[messageType(m)]}
166
+ ${(m, c) => {
167
+ var _a;
168
+ return messageType(m) === 'ai-function' &&
169
+ m.agentName &&
170
+ c.parent.showAgentSwitchIndicator
171
+ ? `Tool Call · ${(_a = m.agentLabel) !== null && _a !== void 0 ? _a : m.agentName}`
172
+ : senderLabel[messageType(m)];
173
+ }}
171
174
  </div>
172
175
  <div class="content">
173
176
  ${when((m) => m.content, html `
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/ai-assistant",
3
3
  "description": "Genesis AI Assistant micro-frontend",
4
- "version": "14.437.0",
4
+ "version": "14.437.2",
5
5
  "license": "SEE LICENSE IN license.txt",
6
6
  "main": "dist/esm/index.js",
7
7
  "types": "dist/ai-assistant.d.ts",
@@ -64,24 +64,24 @@
64
64
  }
65
65
  },
66
66
  "devDependencies": {
67
- "@genesislcap/foundation-testing": "14.437.0",
68
- "@genesislcap/genx": "14.437.0",
69
- "@genesislcap/rollup-builder": "14.437.0",
70
- "@genesislcap/ts-builder": "14.437.0",
71
- "@genesislcap/uvu-playwright-builder": "14.437.0",
72
- "@genesislcap/vite-builder": "14.437.0",
73
- "@genesislcap/webpack-builder": "14.437.0",
67
+ "@genesislcap/foundation-testing": "14.437.2",
68
+ "@genesislcap/genx": "14.437.2",
69
+ "@genesislcap/rollup-builder": "14.437.2",
70
+ "@genesislcap/ts-builder": "14.437.2",
71
+ "@genesislcap/uvu-playwright-builder": "14.437.2",
72
+ "@genesislcap/vite-builder": "14.437.2",
73
+ "@genesislcap/webpack-builder": "14.437.2",
74
74
  "@types/dompurify": "^3.0.5",
75
75
  "@types/marked": "^5.0.2"
76
76
  },
77
77
  "dependencies": {
78
- "@genesislcap/foundation-ai": "14.437.0",
79
- "@genesislcap/foundation-logger": "14.437.0",
80
- "@genesislcap/foundation-redux": "14.437.0",
81
- "@genesislcap/foundation-ui": "14.437.0",
82
- "@genesislcap/foundation-utils": "14.437.0",
83
- "@genesislcap/rapid-design-system": "14.437.0",
84
- "@genesislcap/web-core": "14.437.0",
78
+ "@genesislcap/foundation-ai": "14.437.2",
79
+ "@genesislcap/foundation-logger": "14.437.2",
80
+ "@genesislcap/foundation-redux": "14.437.2",
81
+ "@genesislcap/foundation-ui": "14.437.2",
82
+ "@genesislcap/foundation-utils": "14.437.2",
83
+ "@genesislcap/rapid-design-system": "14.437.2",
84
+ "@genesislcap/web-core": "14.437.2",
85
85
  "dompurify": "^3.3.1",
86
86
  "marked": "^17.0.3"
87
87
  },
@@ -93,5 +93,5 @@
93
93
  "publishConfig": {
94
94
  "access": "public"
95
95
  },
96
- "gitHead": "c30c777f0ab5e45f4e931a9cc1200ac85bcace35"
96
+ "gitHead": "36f8207d71cefd6bf6506c2689a5d0afd32db082"
97
97
  }