@genesislcap/ai-assistant 15.78.0 → 15.78.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 +64 -4
- package/dist/ai-assistant.d.ts +32 -9
- package/dist/chat-driver.cjs +24 -8
- package/dist/chat-driver.cjs.map +2 -2
- package/dist/chat-driver.mjs +24 -8
- package/dist/chat-driver.mjs.map +2 -2
- package/dist/custom-elements.json +568 -440
- package/dist/dts/components/orchestrating-driver/orchestrating-driver.d.ts.map +1 -1
- package/dist/dts/config/config.d.ts +2 -2
- package/dist/dts/config/define-stateful-agent.d.ts +1 -1
- package/dist/dts/main/main.d.ts +23 -5
- package/dist/dts/main/main.d.ts.map +1 -1
- package/dist/dts/state/ai-assistant-slice.d.ts +4 -5
- package/dist/dts/state/ai-assistant-slice.d.ts.map +1 -1
- package/dist/dts/state/persistence/session-persister.d.ts.map +1 -1
- package/dist/dts/state/persistence/session-snapshot.d.ts +19 -6
- package/dist/dts/state/persistence/session-snapshot.d.ts.map +1 -1
- package/dist/dts/state/session-store.d.ts.map +1 -1
- package/dist/dts/utils/attachment-note.d.ts +18 -0
- package/dist/dts/utils/attachment-note.d.ts.map +1 -0
- package/dist/esm/components/orchestrating-driver/orchestrating-driver.js +40 -3
- package/dist/esm/main/main.js +58 -15
- package/dist/esm/main/main.template.js +2 -2
- package/dist/esm/state/persistence/session-persister.js +24 -21
- package/dist/esm/state/persistence/session-snapshot.js +20 -7
- package/dist/esm/utils/attachment-note.js +19 -0
- package/docs/styling.md +1 -1
- package/package.json +17 -17
- package/sandbox/fixtures.ts +3 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
+
import { withoutAttachmentNote } from '../../utils/attachment-note';
|
|
2
3
|
import { flattenSubAgentMessages } from '../../utils/flatten-sub-agent-messages';
|
|
3
4
|
import { logger } from '../../utils/logger';
|
|
4
5
|
import { isSessionNoticeMarker, SESSION_RESTORE_FAILED_LABEL, SESSION_RESTORED_LABEL, SESSION_RESUMED_LABEL, } from '../../utils/message-partition';
|
|
@@ -6,7 +7,7 @@ import { withTimeout } from '../../utils/with-timeout';
|
|
|
6
7
|
import { recordMetaEvent } from '../debug-event-log';
|
|
7
8
|
import { diagnosticsMessageKey } from './diagnostics';
|
|
8
9
|
import { getDiagnosticsCursors } from './diagnostics-cursors';
|
|
9
|
-
import { buildResumeNote, createPersistedSession, isRestorableSession, keepThroughLastUserMessage, reconcileAgentSnapshots, resolveNonResumableNotice, toLoadSessionPayload, trimToRestorableBoundary, unknownAgentSnapshots, } from './session-snapshot';
|
|
10
|
+
import { buildResumeNote, createPersistedSession, interruptedPromptFiles, isRestorableSession, keepThroughLastUserMessage, lastUserMessageIndex, reconcileAgentSnapshots, resolveNonResumableNotice, toLoadSessionPayload, trimToRestorableBoundary, unknownAgentSnapshots, } from './session-snapshot';
|
|
10
11
|
const autopilotOf = (driver) => driver && typeof driver.getPersistedMode === 'function'
|
|
11
12
|
? driver
|
|
12
13
|
: undefined;
|
|
@@ -28,7 +29,7 @@ const DEFAULT_DIAGNOSTICS_DEBOUNCE_MS = 4000;
|
|
|
28
29
|
/**
|
|
29
30
|
* Fallback notice shown on return when an agent declared its state non-resumable
|
|
30
31
|
* (GENC-1351 §5.9) and set no `notResumableMessage`. Paired with the composer
|
|
31
|
-
* pre-filled with the
|
|
32
|
+
* pre-filled with the user's last message, so "send it again" is one keystroke.
|
|
32
33
|
*/
|
|
33
34
|
/**
|
|
34
35
|
* Consecutive failed saves before persistence is declared broken (GENC-1511). Two, not one: a
|
|
@@ -351,7 +352,7 @@ export class SessionPersister {
|
|
|
351
352
|
// snapshot from three hours earlier.
|
|
352
353
|
//
|
|
353
354
|
// So the freeze target is now ALWAYS the live transcript through the last user
|
|
354
|
-
// message — the conversation plus the
|
|
355
|
+
// message — the conversation plus the user's latest request, with the
|
|
355
356
|
// agent's in-flight turns and flow-state dropped. Advancing on each new boundary
|
|
356
357
|
// means a long-running flow can no longer cost the user the work that preceded it.
|
|
357
358
|
const { resumeMessage, resumePrompt } = resolveNonResumableNotice({
|
|
@@ -627,23 +628,24 @@ export class SessionPersister {
|
|
|
627
628
|
// display-only and stripped again on the next save.
|
|
628
629
|
const trailerTs = new Date().toISOString();
|
|
629
630
|
let trailers;
|
|
631
|
+
let prefill;
|
|
630
632
|
if (snapshot.interrupted) {
|
|
631
633
|
trailers = [];
|
|
632
|
-
|
|
633
|
-
//
|
|
634
|
-
|
|
635
|
-
// the
|
|
636
|
-
// message
|
|
637
|
-
//
|
|
638
|
-
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
content: snapshot.interrupted.prompt,
|
|
644
|
-
timestamp: trailerTs,
|
|
645
|
-
});
|
|
634
|
+
const { prompt } = snapshot.interrupted;
|
|
635
|
+
// Looked up untrimmed: the restorable-boundary trim can cut back past the message.
|
|
636
|
+
const files = interruptedPromptFiles(snapshot.messages, prompt);
|
|
637
|
+
// Re-append the triggering user message UNLESS it is already the transcript's last
|
|
638
|
+
// user message. The freeze keeps the transcript through that message, sometimes with
|
|
639
|
+
// replies already saved after it, so only an older snapshot frozen before its trigger
|
|
640
|
+
// lacks it — re-appending otherwise duplicates the bubble (GENC-1351 §5.9).
|
|
641
|
+
const lastUser = trimmed[lastUserMessageIndex(trimmed)];
|
|
642
|
+
const promptAlreadyPresent = (lastUser === null || lastUser === void 0 ? void 0 : lastUser.content) === prompt;
|
|
643
|
+
if (prompt && !promptAlreadyPresent) {
|
|
644
|
+
trailers.push(Object.assign(Object.assign({ role: 'user', content: prompt }, (files ? { attachments: files } : {})), { timestamp: trailerTs }));
|
|
646
645
|
}
|
|
646
|
+
// The files stay on the transcript message and aren't put back in the composer, so it
|
|
647
|
+
// gets only what was typed.
|
|
648
|
+
prefill = prompt ? withoutAttachmentNote(prompt, files) : prompt;
|
|
647
649
|
trailers.push({
|
|
648
650
|
role: 'assistant',
|
|
649
651
|
content: snapshot.interrupted.message,
|
|
@@ -690,11 +692,12 @@ export class SessionPersister {
|
|
|
690
692
|
pinnedAgentName: snapshot.pinnedAgentName,
|
|
691
693
|
flowOwnerAgentName: snapshot.flowOwnerAgentName,
|
|
692
694
|
});
|
|
693
|
-
// Interrupted flow (§5.9): pre-fill the composer with the
|
|
694
|
-
//
|
|
695
|
+
// Interrupted flow (§5.9): pre-fill the composer with the user's last message so
|
|
696
|
+
// "send it again" is one keystroke, and record it for observability.
|
|
695
697
|
if (snapshot.interrupted) {
|
|
696
|
-
|
|
697
|
-
|
|
698
|
+
// Empty for a message that was only files: nothing typed to send again.
|
|
699
|
+
if (prefill) {
|
|
700
|
+
ref.actions.aiAssistant.setInputValue(prefill);
|
|
698
701
|
}
|
|
699
702
|
this.logMeta('persistence.not-resumable', {
|
|
700
703
|
hadPrompt: !!snapshot.interrupted.prompt,
|
|
@@ -22,24 +22,26 @@ export function createPersistedSession(input) {
|
|
|
22
22
|
* unit-testable independent of the save path:
|
|
23
23
|
* - `resumeMessage`: the agent's `notResumableMessage` when non-blank, else the
|
|
24
24
|
* passed default.
|
|
25
|
-
* - `resumePrompt`: the
|
|
26
|
-
*
|
|
27
|
-
*
|
|
25
|
+
* - `resumePrompt`: the last user message in the transcript — the request that was
|
|
26
|
+
* in flight — falling back to the captured flow-activating prompt when there is
|
|
27
|
+
* none; `undefined` when neither exists.
|
|
28
28
|
*
|
|
29
29
|
* @internal
|
|
30
30
|
*/
|
|
31
31
|
export function resolveNonResumableNotice(input) {
|
|
32
|
-
var _a, _b;
|
|
32
|
+
var _a, _b, _c;
|
|
33
33
|
const custom = input.notResumableMessage;
|
|
34
34
|
const resumeMessage = custom && custom.trim() ? custom : input.defaultMessage;
|
|
35
|
-
|
|
35
|
+
// Not the activation prompt first: a flow lock can outlive the turn that took it, and the
|
|
36
|
+
// freeze keeps the transcript through this message, so restore finds it already there.
|
|
37
|
+
const resumePrompt = (_c = (_b = (_a = input.messages[lastUserMessageIndex(input.messages)]) === null || _a === void 0 ? void 0 : _a.content) !== null && _b !== void 0 ? _b : input.flowActivationPrompt) !== null && _c !== void 0 ? _c : undefined;
|
|
36
38
|
return { resumeMessage, resumePrompt };
|
|
37
39
|
}
|
|
38
40
|
/**
|
|
39
41
|
* Index of the last `user`-role message in `messages`, or `-1` when there is none.
|
|
40
42
|
* The single backward scan behind "what did the user last say" — used to slice the
|
|
41
|
-
* transcript to a clean boundary (`keepThroughLastUserMessage`) and to
|
|
42
|
-
* flow
|
|
43
|
+
* transcript to a clean boundary (`keepThroughLastUserMessage`) and to pick the
|
|
44
|
+
* prompt an interrupted flow hands back. Allocation-free (no reversed copy).
|
|
43
45
|
*
|
|
44
46
|
* @internal
|
|
45
47
|
*/
|
|
@@ -51,6 +53,17 @@ export function lastUserMessageIndex(messages) {
|
|
|
51
53
|
}
|
|
52
54
|
return -1;
|
|
53
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* The files of the message an interrupted `prompt` came from: the last user message in
|
|
58
|
+
* `messages`, when its text is the prompt. An older snapshot's prompt can be another text, and
|
|
59
|
+
* that message's files are not its own.
|
|
60
|
+
*
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export function interruptedPromptFiles(messages, prompt) {
|
|
64
|
+
const sent = messages[lastUserMessageIndex(messages)];
|
|
65
|
+
return prompt && (sent === null || sent === void 0 ? void 0 : sent.content) === prompt ? sent.attachments : undefined;
|
|
66
|
+
}
|
|
54
67
|
/**
|
|
55
68
|
* Type guard: is `value` a {@link PersistedSession} we can safely restore?
|
|
56
69
|
* Gates on matching schema version, same host, and a messages array — the
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The line naming the files under a message sent with attachments. Built and taken off only
|
|
3
|
+
* here, so the two can't drift.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
const attachmentNote = (files) => (files === null || files === void 0 ? void 0 : files.length) ? `\n\n*Attached: ${files.map((f) => f.name).join(', ')}*` : '';
|
|
8
|
+
/** What a message sent with `files` is stored and shown as: the typed text, then the line. */
|
|
9
|
+
export function withAttachmentNote(typed, files) {
|
|
10
|
+
return typed + attachmentNote(files);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The typed text of a message stored with `files`. Takes off only the line those files add, so
|
|
14
|
+
* nothing the user typed is cut.
|
|
15
|
+
*/
|
|
16
|
+
export function withoutAttachmentNote(text, files) {
|
|
17
|
+
const note = attachmentNote(files);
|
|
18
|
+
return note && text.endsWith(note) ? text.slice(0, -note.length) : text;
|
|
19
|
+
}
|
package/docs/styling.md
CHANGED
|
@@ -266,7 +266,7 @@ one round-icon-button shape; the agent one additionally carries a label.
|
|
|
266
266
|
| `composer-bar` | The control bar under the textarea |
|
|
267
267
|
| `composer-bar-start` / `composer-bar-end` | The leading (agent / attach / ⋮) and trailing (Stop, Send) clusters |
|
|
268
268
|
| `input` | The textarea |
|
|
269
|
-
| `agent-toggle-button` | Agent button — a `sitemap` glyph under orchestration, the pinned agent's tinted pin otherwise |
|
|
269
|
+
| `agent-toggle-button` | Agent button — a `sitemap` glyph under orchestration, the pinned agent's tinted pin otherwise (the flow owner's while a guided flow holds the picker) |
|
|
270
270
|
| `attach-button` | Attach (paperclip) |
|
|
271
271
|
| `session-menu-button` | Session options (⋮) |
|
|
272
272
|
| `stop-button` | Stop, shown only while a turn runs |
|
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": "15.78.
|
|
4
|
+
"version": "15.78.2",
|
|
5
5
|
"license": "SEE LICENSE IN license.txt",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/ai-assistant.d.ts",
|
|
@@ -92,31 +92,31 @@
|
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
|
-
"@genesislcap/foundation-comms": "15.78.
|
|
96
|
-
"@genesislcap/foundation-testing": "15.78.
|
|
97
|
-
"@genesislcap/genx": "15.78.
|
|
98
|
-
"@genesislcap/ts-builder": "15.78.
|
|
99
|
-
"@genesislcap/uvu-playwright-builder": "15.78.
|
|
100
|
-
"@genesislcap/vite-builder": "15.78.
|
|
101
|
-
"@genesislcap/webpack-builder": "15.78.
|
|
95
|
+
"@genesislcap/foundation-comms": "15.78.2",
|
|
96
|
+
"@genesislcap/foundation-testing": "15.78.2",
|
|
97
|
+
"@genesislcap/genx": "15.78.2",
|
|
98
|
+
"@genesislcap/ts-builder": "15.78.2",
|
|
99
|
+
"@genesislcap/uvu-playwright-builder": "15.78.2",
|
|
100
|
+
"@genesislcap/vite-builder": "15.78.2",
|
|
101
|
+
"@genesislcap/webpack-builder": "15.78.2",
|
|
102
102
|
"@types/dompurify": "^3.0.5",
|
|
103
103
|
"@types/marked": "^5.0.2",
|
|
104
104
|
"esbuild": "0.25.12"
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
|
-
"@genesislcap/foundation-ai": "15.78.
|
|
108
|
-
"@genesislcap/foundation-logger": "15.78.
|
|
109
|
-
"@genesislcap/foundation-notifications": "15.78.
|
|
110
|
-
"@genesislcap/foundation-redux": "15.78.
|
|
111
|
-
"@genesislcap/foundation-ui": "15.78.
|
|
112
|
-
"@genesislcap/foundation-utils": "15.78.
|
|
113
|
-
"@genesislcap/rapid-design-system": "15.78.
|
|
114
|
-
"@genesislcap/web-core": "15.78.
|
|
107
|
+
"@genesislcap/foundation-ai": "15.78.2",
|
|
108
|
+
"@genesislcap/foundation-logger": "15.78.2",
|
|
109
|
+
"@genesislcap/foundation-notifications": "15.78.2",
|
|
110
|
+
"@genesislcap/foundation-redux": "15.78.2",
|
|
111
|
+
"@genesislcap/foundation-ui": "15.78.2",
|
|
112
|
+
"@genesislcap/foundation-utils": "15.78.2",
|
|
113
|
+
"@genesislcap/rapid-design-system": "15.78.2",
|
|
114
|
+
"@genesislcap/web-core": "15.78.2",
|
|
115
115
|
"dompurify": "^3.3.1",
|
|
116
116
|
"marked": "^17.0.3"
|
|
117
117
|
},
|
|
118
118
|
"peerDependencies": {
|
|
119
|
-
"@genesislcap/foundation-comms": "^15.78.
|
|
119
|
+
"@genesislcap/foundation-comms": "^15.78.2"
|
|
120
120
|
},
|
|
121
121
|
"peerDependenciesMeta": {
|
|
122
122
|
"@genesislcap/foundation-comms": {
|
package/sandbox/fixtures.ts
CHANGED
|
@@ -20,9 +20,9 @@ const STUB_PROMPT = 'Sandbox stub. Replies are canned.';
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Six specialists plus a fallback. The sandbox slices this list, so ordering is
|
|
23
|
-
* load-bearing in one place:
|
|
24
|
-
*
|
|
25
|
-
* changes.
|
|
23
|
+
* load-bearing in one place: pin colours are picked by index (the chip's
|
|
24
|
+
* `agentButtonColour` and the picker's dots), so slicing from the front keeps a
|
|
25
|
+
* given agent's pin colour stable as the count changes.
|
|
26
26
|
*/
|
|
27
27
|
const SPECIALISTS: AgentConfig[] = [
|
|
28
28
|
{
|