@genesislcap/ai-assistant 14.419.2 → 14.421.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/ai-assistant.api.json +4061 -1416
  2. package/dist/ai-assistant.d.ts +594 -81
  3. package/dist/dts/channel/ai-activity-channel.d.ts +4 -22
  4. package/dist/dts/channel/ai-activity-channel.d.ts.map +1 -1
  5. package/dist/dts/components/ai-driver/ai-driver.d.ts +52 -0
  6. package/dist/dts/components/ai-driver/ai-driver.d.ts.map +1 -0
  7. package/dist/dts/components/ai-driver/index.d.ts +2 -0
  8. package/dist/dts/components/ai-driver/index.d.ts.map +1 -0
  9. package/dist/dts/components/chat-driver/chat-driver.d.ts +63 -8
  10. package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
  11. package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts +3 -3
  12. package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts.map +1 -1
  13. package/dist/dts/components/chat-markdown/chat-markdown.d.ts +1 -1
  14. package/dist/dts/components/chat-markdown/chat-markdown.d.ts.map +1 -1
  15. package/dist/dts/components/halo-overlay.d.ts +13 -1
  16. package/dist/dts/components/halo-overlay.d.ts.map +1 -1
  17. package/dist/dts/components/orchestrating-driver/index.d.ts +2 -0
  18. package/dist/dts/components/orchestrating-driver/index.d.ts.map +1 -0
  19. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts +39 -0
  20. package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts.map +1 -0
  21. package/dist/dts/components/popout-manager/index.d.ts +2 -0
  22. package/dist/dts/components/popout-manager/index.d.ts.map +1 -0
  23. package/dist/dts/components/popout-manager/popout-manager.d.ts +72 -0
  24. package/dist/dts/components/popout-manager/popout-manager.d.ts.map +1 -0
  25. package/dist/dts/config/config.d.ts +43 -15
  26. package/dist/dts/config/config.d.ts.map +1 -1
  27. package/dist/dts/config/fallback-agents.d.ts +20 -0
  28. package/dist/dts/config/fallback-agents.d.ts.map +1 -0
  29. package/dist/dts/config/index.d.ts +1 -0
  30. package/dist/dts/config/index.d.ts.map +1 -1
  31. package/dist/dts/index.d.ts +6 -0
  32. package/dist/dts/index.d.ts.map +1 -1
  33. package/dist/dts/main/main.d.ts +122 -21
  34. package/dist/dts/main/main.d.ts.map +1 -1
  35. package/dist/dts/main/main.styles.d.ts.map +1 -1
  36. package/dist/dts/main/main.template.d.ts.map +1 -1
  37. package/dist/dts/main/main.types.d.ts +16 -0
  38. package/dist/dts/main/main.types.d.ts.map +1 -1
  39. package/dist/dts/state/ai-assistant-slice.d.ts +38 -0
  40. package/dist/dts/state/ai-assistant-slice.d.ts.map +1 -0
  41. package/dist/dts/state/driver-registry.d.ts +22 -0
  42. package/dist/dts/state/driver-registry.d.ts.map +1 -0
  43. package/dist/dts/state/session-store.d.ts +37 -0
  44. package/dist/dts/state/session-store.d.ts.map +1 -0
  45. package/dist/dts/suggestions/chat-suggestions.d.ts +7 -0
  46. package/dist/dts/suggestions/chat-suggestions.d.ts.map +1 -0
  47. package/dist/dts/types/ai-chat-widget.d.ts +3 -2
  48. package/dist/dts/types/ai-chat-widget.d.ts.map +1 -1
  49. package/dist/dts/utils/index.d.ts +1 -0
  50. package/dist/dts/utils/index.d.ts.map +1 -1
  51. package/dist/dts/utils/tool-fold.d.ts +133 -0
  52. package/dist/dts/utils/tool-fold.d.ts.map +1 -0
  53. package/dist/esm/components/ai-driver/ai-driver.js +1 -0
  54. package/dist/esm/components/ai-driver/index.js +1 -0
  55. package/dist/esm/components/chat-driver/chat-driver.js +499 -67
  56. package/dist/esm/components/chat-interaction-wrapper/chat-interaction-wrapper.js +2 -2
  57. package/dist/esm/components/chat-markdown/chat-markdown.js +1 -1
  58. package/dist/esm/components/halo-overlay.js +53 -7
  59. package/dist/esm/components/orchestrating-driver/index.js +1 -0
  60. package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +247 -0
  61. package/dist/esm/components/popout-manager/index.js +1 -0
  62. package/dist/esm/components/popout-manager/popout-manager.js +126 -0
  63. package/dist/esm/config/fallback-agents.js +26 -0
  64. package/dist/esm/config/index.js +1 -0
  65. package/dist/esm/index.js +6 -0
  66. package/dist/esm/main/main.js +546 -112
  67. package/dist/esm/main/main.styles.js +200 -4
  68. package/dist/esm/main/main.template.js +163 -63
  69. package/dist/esm/state/ai-assistant-slice.js +54 -0
  70. package/dist/esm/state/driver-registry.js +46 -0
  71. package/dist/esm/state/session-store.js +39 -0
  72. package/dist/esm/suggestions/chat-suggestions.js +147 -0
  73. package/dist/esm/utils/index.js +1 -0
  74. package/dist/esm/utils/tool-fold.js +92 -0
  75. package/dist/tsconfig.tsbuildinfo +1 -1
  76. package/docs/migration-FUI-2495.md +339 -0
  77. package/docs/sub_agent.md +310 -0
  78. package/package.json +16 -15
  79. package/src/channel/ai-activity-channel.ts +4 -20
  80. package/src/components/ai-driver/ai-driver.ts +69 -0
  81. package/src/components/ai-driver/index.ts +1 -0
  82. package/src/components/chat-driver/chat-driver.ts +600 -73
  83. package/src/components/chat-interaction-wrapper/chat-interaction-wrapper.ts +3 -3
  84. package/src/components/chat-markdown/chat-markdown.ts +1 -1
  85. package/src/components/halo-overlay.ts +45 -7
  86. package/src/components/orchestrating-driver/index.ts +1 -0
  87. package/src/components/orchestrating-driver/orchestrating-driver.ts +328 -0
  88. package/src/components/popout-manager/index.ts +1 -0
  89. package/src/components/popout-manager/popout-manager.ts +147 -0
  90. package/src/config/config.ts +45 -15
  91. package/src/config/fallback-agents.ts +29 -0
  92. package/src/config/index.ts +1 -0
  93. package/src/index.ts +6 -0
  94. package/src/main/main.styles.ts +200 -4
  95. package/src/main/main.template.ts +200 -80
  96. package/src/main/main.ts +567 -94
  97. package/src/main/main.types.ts +11 -0
  98. package/src/state/ai-assistant-slice.ts +80 -0
  99. package/src/state/driver-registry.ts +51 -0
  100. package/src/state/session-store.ts +56 -0
  101. package/src/suggestions/chat-suggestions.ts +158 -0
  102. package/src/types/ai-chat-widget.ts +4 -2
  103. package/src/utils/index.ts +1 -0
  104. package/src/utils/tool-fold.ts +181 -0
  105. package/docs/multi-agent-architecture.md +0 -198
@@ -1,198 +0,0 @@
1
- # Multi-Agent Architecture Plan
2
-
3
- ## Overview
4
-
5
- As more flows are added to a single AI assistant, two things degrade:
6
-
7
- - **Tool overload** — tool selection accuracy drops significantly beyond ~15–20 tools
8
- - **Prompt dilution** — longer system prompts cause attention to dilute; instructions buried deep get followed less reliably
9
-
10
- The solution is an orchestrating layer that sits between `FoundationAiAssistant` and `ChatDriver`, classifying each user message and routing it to the right specialist — each with its own focused system prompt, tools, and primer. The user sees one chat interface; multiple specialists run underneath.
11
-
12
- ---
13
-
14
- ## Architecture
15
-
16
- ```
17
- User message
18
-
19
- FoundationAiAssistant
20
-
21
- OrchestratingDriver (new)
22
- ├─ Classifier → picks active AgentConfig
23
- └─ ChatDriver ← swaps in systemPrompt, tools, primerHistory per turn
24
- ```
25
-
26
- ### Key design decisions
27
-
28
- - **Shared history** — all specialists read and write to the same message array. The settlement specialist can see what the allocations specialist did three turns ago; it just won't try to act like it.
29
- - **Classification fires once per user turn**, before the tool loop starts. Once a specialist is picked, its config runs for the entire tool loop (which may be many iterations). Specialists do not swap mid-loop.
30
- - **Primer as context switch** — the primer is already designed to be invisible and prepended to every call. Each specialist has its own primer encoding its identity and behavioral rules. The model gets the right identity injected fresh every turn.
31
- - **`ChatDriver` unchanged** — the orchestrator updates the driver's config before delegating. No changes required to the existing tool loop, interaction system, or history management.
32
-
33
- ---
34
-
35
- ## API
36
-
37
- ### `AgentConfig`
38
-
39
- ```typescript
40
- interface AgentConfig {
41
- /** Display name shown in the chat header when this agent is active. */
42
- name: string;
43
-
44
- /**
45
- * Plain-language description of what this agent handles.
46
- * Used by the classifier to auto-generate its routing prompt — no manual
47
- * classifier prompt authoring needed.
48
- */
49
- description: string;
50
-
51
- systemPrompt?: string;
52
- toolDefinitions?: ChatToolDefinition[];
53
- toolHandlers?: ChatToolHandlers;
54
- primerHistory?: ChatMessage[];
55
- }
56
- ```
57
-
58
- ### Component usage
59
-
60
- ```html
61
- <foundation-ai-assistant
62
- :agents="${(x) => x.agents}"
63
- :chatConfig="${() => ({ ... })}"
64
- >
65
- ```
66
-
67
- ### Example configuration
68
-
69
- ```typescript
70
- agents: AgentConfig[] = [
71
- {
72
- name: 'Trades Assistant',
73
- description: 'Handles trade search, entry, and amendment',
74
- systemPrompt: TRADES_SYSTEM_PROMPT,
75
- toolDefinitions: createTradesToolDefinitions(),
76
- toolHandlers: createTradesToolHandlers(this.connect),
77
- primerHistory: tradesAssistantPrimer,
78
- },
79
- {
80
- name: 'Allocations Assistant',
81
- description: 'Handles trade allocation across sub-accounts',
82
- systemPrompt: ALLOCATIONS_SYSTEM_PROMPT,
83
- toolDefinitions: createAllocationsToolDefinitions(),
84
- toolHandlers: createAllocationsToolHandlers(this.connect),
85
- primerHistory: allocationsAssistantPrimer,
86
- },
87
- ];
88
- ```
89
-
90
- ---
91
-
92
- ## `OrchestratingDriver` (next PR)
93
-
94
- Sits between `FoundationAiAssistant` and `ChatDriver`. Implements the same external interface as `ChatDriver` so the component needs no changes.
95
-
96
- ```
97
- OrchestratingDriver
98
- ├─ agents: AgentConfig[]
99
- ├─ chatDriver: ChatDriver (one shared instance)
100
- ├─ activeAgent: AgentConfig (last classified specialist)
101
-
102
- ├─ sendMessage(input, attachments)
103
- │ 1. Classify input → pick AgentConfig
104
- │ 2. Swap systemPrompt, toolDefinitions, toolHandlers, primerHistory on chatDriver
105
- │ 3. Update activeAgent (triggers header name update if changed)
106
- │ 4. Delegate to chatDriver.sendMessage(input, attachments)
107
-
108
- └─ classify(input): Promise<AgentConfig>
109
- - Builds a minimal prompt: agent names + descriptions + user message
110
- - Single non-tool LLM call (no history needed — cheap and fast)
111
- - Returns matched AgentConfig
112
- ```
113
-
114
- ### Classifier prompt shape
115
-
116
- Auto-generated from `AgentConfig.description`. No manual authoring required:
117
-
118
- ```
119
- You are a routing classifier. Given a user message, respond with exactly one of the
120
- following agent names and nothing else.
121
-
122
- Agents:
123
- - Trades Assistant: Handles trade search, entry, and amendment
124
- - Allocations Assistant: Handles trade allocation across sub-accounts
125
- - Settlement Assistant: Handles settlement status queries and instructions
126
-
127
- User message: "{{userInput}}"
128
- ```
129
-
130
- The classifier uses the same `aiProvider` but with minimal context — just the user's message. It is a fraction of the cost of a specialist call.
131
-
132
- ---
133
-
134
- ## Chat header: active agent name
135
-
136
- When multiple agents are configured, the active `AgentConfig.name` drives the displayed title and updates when the specialist changes. `header-title` is a fallback for when no agents are configured.
137
-
138
- ---
139
-
140
- ## Agent switch indicator
141
-
142
- When the active specialist changes mid-conversation, an optional inline system divider can be injected into the message history:
143
-
144
- ```
145
- ─────────── Allocations Assistant ───────────
146
- ```
147
-
148
- Visually distinct from chat bubbles — a small centred metadata marker, not a conversation message.
149
-
150
- ### Configuration
151
-
152
- ```typescript
153
- chatConfig: {
154
- showAgentSwitchIndicator?: boolean // default: false
155
- }
156
- ```
157
-
158
- Also shown automatically when `showToolCalls` is true, on the assumption that users who want to see tool calls also want to see routing decisions.
159
-
160
- ### Implementation
161
-
162
- `OrchestratingDriver` compares the newly classified agent against `activeAgent` after each classification. On a switch, it appends a synthetic message (`role: 'system-event'`, `content: agentConfig.name`) before delegating to `ChatDriver`. The template renders this type as the divider element rather than a chat bubble.
163
-
164
- ---
165
-
166
- ## Mid-flow handoffs
167
-
168
- Classification fires once per turn, before the tool loop. The tricky case: user is halfway through an allocation and asks a cross-domain question before the flow completes.
169
-
170
- Options (in order of complexity):
171
-
172
- 1. **Suppress re-routing while a flow is active** — `OrchestratingDriver` tracks whether the previous turn ended with a pending interaction. If so, hold the current specialist regardless of classification.
173
- 2. **Give the active specialist a narrow fallback tool** — e.g. the allocations specialist has a read-only `get_settlement_status` tool to handle common cross-domain queries without a handoff.
174
- 3. **Ask the user to clarify** — simplest but blunt. Acceptable as a v1 fallback.
175
-
176
- Option 1 + 2 together cover most real cases without requiring suspend/resume infrastructure.
177
-
178
- ---
179
-
180
- ## Status
181
-
182
- ### Done (this PR)
183
-
184
- - [x] `AgentConfig` interface defined in `config/config.ts` and exported from the package
185
- - [x] `agents?: AgentConfig[]` observable added to `FoundationAiAssistant`
186
- - [x] Flat props (`systemPrompt`, `toolDefinitions`, `toolHandlers`, `primerHistory`) removed from `FoundationAiAssistant`
187
- - [x] `connectedCallback` reads from `agents[0]` to feed `ChatDriver` (TODO comment marks where orchestration slots in)
188
- - [x] `downloadHistory` reads agent name and config from `agents[0]` (TODO comment marks where active agent tracking slots in)
189
- - [x] Showcase `trades-assistant` template migrated to `:agents` binding
190
-
191
- ### Next PR
192
-
193
- - [ ] Implement `OrchestratingDriver` with classifier and delegation logic
194
- - [ ] Wire `FoundationAiAssistant` to use `OrchestratingDriver` when `agents.length > 1`
195
- - [ ] Bind header title to `activeAgent.name` when in multi-agent mode
196
- - [ ] Add `showAgentSwitchIndicator` to `ChatConfig` and implement the system-event message type + divider template
197
- - [ ] Write specialist configs for each new domain (allocations, settlement, etc.)
198
- - [ ] Decide on mid-flow handoff strategy (suppress re-routing vs. fallback tools vs. clarify)