@genesislcap/ai-assistant 15.82.0 → 15.84.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.
- package/dist/ai-assistant.api.json +2811 -233
- package/dist/ai-assistant.d.ts +835 -93
- package/dist/chat-driver.cjs +452 -99
- package/dist/chat-driver.cjs.map +4 -4
- package/dist/chat-driver.mjs +452 -99
- package/dist/chat-driver.mjs.map +4 -4
- package/dist/custom-elements.json +1903 -907
- package/dist/dts/autopilot/autopilot-driver.d.ts +117 -11
- package/dist/dts/autopilot/autopilot-driver.d.ts.map +1 -1
- package/dist/dts/autopilot/autopilot-session.d.ts +55 -7
- package/dist/dts/autopilot/autopilot-session.d.ts.map +1 -1
- package/dist/dts/autopilot/autopilot-tools.d.ts +3 -2
- package/dist/dts/autopilot/autopilot-tools.d.ts.map +1 -1
- package/dist/dts/autopilot/decision-message.d.ts +35 -3
- package/dist/dts/autopilot/decision-message.d.ts.map +1 -1
- package/dist/dts/autopilot/hand-back/hand-back.controller.d.ts +2 -2
- package/dist/dts/autopilot/hand-back/hand-back.controller.d.ts.map +1 -1
- package/dist/dts/autopilot/hand-back/hand-back.d.ts +2 -2
- package/dist/dts/autopilot/hand-back/hand-back.d.ts.map +1 -1
- package/dist/dts/autopilot/index.d.ts +1 -0
- package/dist/dts/autopilot/index.d.ts.map +1 -1
- package/dist/dts/autopilot/widget-tools.d.ts +95 -0
- package/dist/dts/autopilot/widget-tools.d.ts.map +1 -0
- package/dist/dts/channel/ai-activity-channel.d.ts +10 -0
- package/dist/dts/channel/ai-activity-channel.d.ts.map +1 -1
- package/dist/dts/components/ai-driver/ai-driver.d.ts +25 -6
- package/dist/dts/components/ai-driver/ai-driver.d.ts.map +1 -1
- package/dist/dts/components/ai-driver/base-driver-decorator.d.ts +2 -0
- package/dist/dts/components/ai-driver/base-driver-decorator.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/chat-driver.d.ts +14 -2
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/interaction-controller.d.ts +61 -17
- package/dist/dts/components/chat-driver/interaction-controller.d.ts.map +1 -1
- package/dist/dts/config/config.d.ts +31 -6
- package/dist/dts/config/config.d.ts.map +1 -1
- package/dist/dts/config/define-stateful-agent.d.ts +5 -1
- package/dist/dts/config/define-stateful-agent.d.ts.map +1 -1
- package/dist/dts/genesis/write-outcome.d.ts.map +1 -1
- package/dist/dts/index.d.ts +4 -2
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/main/main.d.ts +11 -0
- package/dist/dts/main/main.d.ts.map +1 -1
- package/dist/dts/main/main.template.d.ts.map +1 -1
- package/dist/dts/notifications/agent-notifications.d.ts +6 -2
- package/dist/dts/notifications/agent-notifications.d.ts.map +1 -1
- package/dist/dts/notifications/agent-notifier.d.ts +26 -4
- package/dist/dts/notifications/agent-notifier.d.ts.map +1 -1
- package/dist/dts/state/decision-surface.d.ts +22 -4
- package/dist/dts/state/decision-surface.d.ts.map +1 -1
- package/dist/dts/state/interaction-context.d.ts +23 -4
- package/dist/dts/state/interaction-context.d.ts.map +1 -1
- package/dist/dts/state/interaction-registry.d.ts +55 -6
- package/dist/dts/state/interaction-registry.d.ts.map +1 -1
- package/dist/dts/state/live-interactions.d.ts +28 -0
- package/dist/dts/state/live-interactions.d.ts.map +1 -0
- package/dist/dts/state/persistence/session-persister.d.ts.map +1 -1
- package/dist/dts/state/persistence/session-snapshot.d.ts +16 -5
- package/dist/dts/state/persistence/session-snapshot.d.ts.map +1 -1
- package/dist/dts/state/test-interaction-context.d.ts +93 -0
- package/dist/dts/state/test-interaction-context.d.ts.map +1 -0
- package/dist/dts/types/ai-chat-widget.d.ts +7 -6
- package/dist/dts/types/ai-chat-widget.d.ts.map +1 -1
- package/dist/dts/types/interaction-context.d.ts +128 -17
- package/dist/dts/types/interaction-context.d.ts.map +1 -1
- package/dist/dts/types/interaction-interceptor.d.ts +48 -6
- package/dist/dts/types/interaction-interceptor.d.ts.map +1 -1
- package/dist/dts/types/interaction-surface.d.ts +145 -23
- package/dist/dts/types/interaction-surface.d.ts.map +1 -1
- package/dist/esm/autopilot/autopilot-driver.js +313 -60
- package/dist/esm/autopilot/autopilot-session.js +219 -40
- package/dist/esm/autopilot/autopilot-tools.js +11 -7
- package/dist/esm/autopilot/decision-message.js +105 -26
- package/dist/esm/autopilot/hand-back/hand-back.controller.js +2 -1
- package/dist/esm/autopilot/index.js +1 -0
- package/dist/esm/autopilot/widget-tools.js +39 -0
- package/dist/esm/components/ai-driver/base-driver-decorator.js +17 -0
- package/dist/esm/components/chat-driver/chat-driver.js +18 -2
- package/dist/esm/components/chat-driver/interaction-controller.js +232 -71
- package/dist/esm/components/settings-modal/settings-modal.template.js +2 -2
- package/dist/esm/config/define-stateful-agent.js +22 -1
- package/dist/esm/genesis/write-outcome.js +8 -4
- package/dist/esm/index.js +2 -0
- package/dist/esm/main/main.js +39 -3
- package/dist/esm/main/main.template.js +4 -1
- package/dist/esm/notifications/agent-notifications.js +11 -1
- package/dist/esm/notifications/agent-notifier.js +41 -7
- package/dist/esm/state/debug-event-log.js +5 -5
- package/dist/esm/state/decision-surface.js +137 -54
- package/dist/esm/state/interaction-context.js +41 -8
- package/dist/esm/state/interaction-registry.js +11 -0
- package/dist/esm/state/live-interactions.js +36 -0
- package/dist/esm/state/persistence/session-persister.js +44 -17
- package/dist/esm/state/persistence/session-snapshot.js +2 -2
- package/dist/esm/state/test-interaction-context.js +99 -0
- package/docs/notifications.md +55 -5
- package/docs/styling.md +33 -0
- package/package.json +19 -19
- package/sandbox/README.md +3 -2
- package/sandbox/autopilot.ts +26 -6
- package/sandbox/sandbox.ts +2 -0
- /package/dist/{tsdoc-metadata.json → dts/tsdoc-metadata.json} +0 -0
|
@@ -7,12 +7,23 @@ const registry = new Map();
|
|
|
7
7
|
*
|
|
8
8
|
* Registering is optional and additive: an unregistered widget works exactly as before.
|
|
9
9
|
*
|
|
10
|
+
* Generic over the controller its factory builds, which types `ctx.controller` for the factory and
|
|
11
|
+
* for anything that reads the context with the same type argument (a view, a widget tool):
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* registerInteraction<ReviewController>('review', {
|
|
15
|
+
* controller: (data, ctx) => new ReviewController(data as ReviewData, ctx),
|
|
16
|
+
* asText: reviewAsText,
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
10
20
|
* @beta
|
|
11
21
|
*/
|
|
12
22
|
export function registerInteraction(name, registration) {
|
|
13
23
|
if (registry.has(name)) {
|
|
14
24
|
logger.warn(`registerInteraction: "${name}" was already registered; replacing it.`);
|
|
15
25
|
}
|
|
26
|
+
// Stored untyped: the registry holds every widget's, and its readers do not know the type.
|
|
16
27
|
registry.set(name, registration);
|
|
17
28
|
}
|
|
18
29
|
/**
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Every pending interaction's live context, by id, across the drivers in this window. */
|
|
2
|
+
const live = new Map();
|
|
3
|
+
/**
|
|
4
|
+
* Make a driver-owned context findable by {@link getInteractionContext} until it is disposed. Returns
|
|
5
|
+
* the untrack, which the driver passes to the context's own `onDispose`.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export function trackInteractionContext(context) {
|
|
10
|
+
live.set(context.interactionId, context);
|
|
11
|
+
return () => {
|
|
12
|
+
if (live.get(context.interactionId) === context)
|
|
13
|
+
live.delete(context.interactionId);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The live context of a pending interaction, by its id (GENC-1660), for UI that the chat does not
|
|
18
|
+
* render and so is never handed one: a layout side panel that shows a widget's detail, say. It can
|
|
19
|
+
* subscribe, read `heldBy` and reach the controller directly, rather than through a channel of its
|
|
20
|
+
* own. `undefined` once the interaction has resolved (its context is disposed then) and for an id
|
|
21
|
+
* that never opened.
|
|
22
|
+
*
|
|
23
|
+
* `TController` types `controller`, as it was registered (`registerInteraction<TController>()`).
|
|
24
|
+
* Unchecked: the caller says what it expects.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const ctx = getInteractionContext<ReviewController>(interactionId);
|
|
29
|
+
* const unsubscribe = ctx?.subscribe(() => this.render(ctx.controller?.view(), ctx.heldBy));
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @beta
|
|
33
|
+
*/
|
|
34
|
+
export function getInteractionContext(interactionId) {
|
|
35
|
+
return live.get(interactionId);
|
|
36
|
+
}
|
|
@@ -11,6 +11,33 @@ import { buildResumeNote, createPersistedSession, interruptedPromptFiles, isRest
|
|
|
11
11
|
const autopilotOf = (driver) => driver && typeof driver.getPersistedMode === 'function'
|
|
12
12
|
? driver
|
|
13
13
|
: undefined;
|
|
14
|
+
/**
|
|
15
|
+
* The checkpoints to save (GENC-1660 §4.12): every one the driver holds, or, from a third-party
|
|
16
|
+
* driver with only the older single form, its one.
|
|
17
|
+
*/
|
|
18
|
+
function checkpointsOf(driver) {
|
|
19
|
+
var _a;
|
|
20
|
+
if (driver === null || driver === void 0 ? void 0 : driver.getInteractionCheckpoints)
|
|
21
|
+
return [...driver.getInteractionCheckpoints()];
|
|
22
|
+
const one = (_a = driver === null || driver === void 0 ? void 0 : driver.getInteractionCheckpoint) === null || _a === void 0 ? void 0 : _a.call(driver);
|
|
23
|
+
return one ? [one] : [];
|
|
24
|
+
}
|
|
25
|
+
/** The checkpoints a snapshot holds: `checkpoints`, or the one an older snapshot wrote. */
|
|
26
|
+
function savedCheckpoints(snapshot) {
|
|
27
|
+
if (snapshot.checkpoints)
|
|
28
|
+
return snapshot.checkpoints;
|
|
29
|
+
return snapshot.checkpoint ? [snapshot.checkpoint] : [];
|
|
30
|
+
}
|
|
31
|
+
/** Hand restored checkpoints back to the driver: none clears what it holds. */
|
|
32
|
+
function restoreCheckpoints(driver, saved) {
|
|
33
|
+
var _a;
|
|
34
|
+
if (driver === null || driver === void 0 ? void 0 : driver.restoreInteractionCheckpoints) {
|
|
35
|
+
driver.restoreInteractionCheckpoints(saved);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
(_a = driver === null || driver === void 0 ? void 0 : driver.restoreInteractionCheckpoint) === null || _a === void 0 ? void 0 : _a.call(driver, saved[saved.length - 1]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
14
41
|
/**
|
|
15
42
|
* Backstop for a slow/hung persistence provider on startup restore (GENC-1351
|
|
16
43
|
* §6). Deliberately long: silently losing a restorable session is a far worse
|
|
@@ -303,7 +330,7 @@ export class SessionPersister {
|
|
|
303
330
|
*/
|
|
304
331
|
persistSession() {
|
|
305
332
|
return __awaiter(this, void 0, void 0, function* () {
|
|
306
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m
|
|
333
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
307
334
|
const { provider, enabled } = this.deps.getPersistence();
|
|
308
335
|
if (!enabled || !provider)
|
|
309
336
|
return;
|
|
@@ -468,7 +495,7 @@ export class SessionPersister {
|
|
|
468
495
|
agentSnapshots,
|
|
469
496
|
condensePolicies: this.condensePoliciesToPersist(driver, messages),
|
|
470
497
|
autopilot: (_h = autopilotOf(driver)) === null || _h === void 0 ? void 0 : _h.getPersistedMode(),
|
|
471
|
-
|
|
498
|
+
checkpoints: checkpointsOf(driver),
|
|
472
499
|
});
|
|
473
500
|
// Observability (GENC-1351): record what each autosave captured for stateful
|
|
474
501
|
// agents — `agents: []` here means no machine snapshot was taken (the bug to
|
|
@@ -484,7 +511,7 @@ export class SessionPersister {
|
|
|
484
511
|
const captured = {
|
|
485
512
|
messages: messages.length,
|
|
486
513
|
agents: Object.keys(agentSnapshots),
|
|
487
|
-
active: (
|
|
514
|
+
active: (_j = liveActive === null || liveActive === void 0 ? void 0 : liveActive.name) !== null && _j !== void 0 ? _j : null,
|
|
488
515
|
hasSerialize: !!(liveActive === null || liveActive === void 0 ? void 0 : liveActive.serialize),
|
|
489
516
|
agentSnapshots,
|
|
490
517
|
};
|
|
@@ -503,7 +530,7 @@ export class SessionPersister {
|
|
|
503
530
|
// means the body never reached the wire at all, because a provider builds its
|
|
504
531
|
// request body inside the `fetch` init, so a throw while serialising creates no
|
|
505
532
|
// request and leaves no server-side trace.
|
|
506
|
-
this.recordSaveOutcome(false, (
|
|
533
|
+
this.recordSaveOutcome(false, (_k = e === null || e === void 0 ? void 0 : e.message) !== null && _k !== void 0 ? _k : String(e));
|
|
507
534
|
// Report straight away rather than waiting for the next attempt: we are on the resumable
|
|
508
535
|
// path, so a reload is safe NOW, and a one-cycle delay is a second of extra exposure for
|
|
509
536
|
// no benefit.
|
|
@@ -520,8 +547,8 @@ export class SessionPersister {
|
|
|
520
547
|
agents: captured.agents,
|
|
521
548
|
active: captured.active,
|
|
522
549
|
hasSerialize: captured.hasSerialize,
|
|
523
|
-
error: (
|
|
524
|
-
message: (
|
|
550
|
+
error: (_l = e === null || e === void 0 ? void 0 : e.name) !== null && _l !== void 0 ? _l : typeof e,
|
|
551
|
+
message: (_m = e === null || e === void 0 ? void 0 : e.message) !== null && _m !== void 0 ? _m : String(e),
|
|
525
552
|
});
|
|
526
553
|
logger.error('Session save failed:', e);
|
|
527
554
|
}
|
|
@@ -540,7 +567,7 @@ export class SessionPersister {
|
|
|
540
567
|
*/
|
|
541
568
|
restore() {
|
|
542
569
|
return __awaiter(this, void 0, void 0, function* () {
|
|
543
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j
|
|
570
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
544
571
|
const { provider } = this.deps.getPersistence();
|
|
545
572
|
if (!provider)
|
|
546
573
|
return undefined;
|
|
@@ -600,11 +627,11 @@ export class SessionPersister {
|
|
|
600
627
|
driver === null || driver === void 0 ? void 0 : driver.primeRestoredAgentState(snapshot.agentSnapshots);
|
|
601
628
|
// The autopilot's mode waits for its flow to re-activate; restoring it starts nothing.
|
|
602
629
|
(_d = autopilotOf(driver)) === null || _d === void 0 ? void 0 : _d.restorePersistedMode(snapshot.autopilot);
|
|
603
|
-
//
|
|
604
|
-
//
|
|
605
|
-
//
|
|
606
|
-
//
|
|
607
|
-
(
|
|
630
|
+
// Long actions the reload cut wait for requests of their widget types (§4.12) — but only when
|
|
631
|
+
// their flow is re-activated above. A flow left behind (interrupted, or an owner this driver
|
|
632
|
+
// does not know) never ends, so nothing would clear its checkpoints, and the next request of
|
|
633
|
+
// such a widget type would take over the abandoned run's work.
|
|
634
|
+
restoreCheckpoints(driver, flowOwner ? savedCheckpoints(snapshot) : []);
|
|
608
635
|
// Seed the carry-forward cache so the immediate post-restore autosave (fired
|
|
609
636
|
// by the history change below, before any agent re-activates) preserves the
|
|
610
637
|
// machine snapshot instead of overwriting it with an empty one (GENC-1351).
|
|
@@ -677,14 +704,14 @@ export class SessionPersister {
|
|
|
677
704
|
}
|
|
678
705
|
const messages = [...trimmed, ...trailers];
|
|
679
706
|
ref.actions.aiAssistant.loadSession(toLoadSessionPayload(Object.assign(Object.assign({}, snapshot), { messages })));
|
|
680
|
-
(
|
|
707
|
+
(_e = driver === null || driver === void 0 ? void 0 : driver.loadHistory) === null || _e === void 0 ? void 0 : _e.call(driver, [...messages]);
|
|
681
708
|
// Re-arm the condense policies that had not fired at save time (GENC-1632) — AFTER
|
|
682
709
|
// `loadHistory`, because the driver keeps only entries whose tool call is in the history it
|
|
683
710
|
// now holds, which is how an entry for a call `trimToRestorableBoundary` cut away is dropped
|
|
684
711
|
// rather than resurrected. A snapshot from before the field existed has none, so this is a
|
|
685
712
|
// no-op and the restore is exactly what it was. Timing against the agent's re-activation is
|
|
686
713
|
// the driver's problem, not ours: it defers the activation stamp to the next `installAgent`.
|
|
687
|
-
const condenseRestore = (
|
|
714
|
+
const condenseRestore = (_f = driver === null || driver === void 0 ? void 0 : driver.restoreCondensePolicies) === null || _f === void 0 ? void 0 : _f.call(driver, snapshot.condensePolicies);
|
|
688
715
|
// Observability (GENC-1351, counts refined for GENC-1632 review): record exactly what the
|
|
689
716
|
// restore primed, so a post-reload debug-log export shows whether a stateful agent's snapshot
|
|
690
717
|
// actually came back (meta events reset on reload, so this is the only window onto the
|
|
@@ -696,7 +723,7 @@ export class SessionPersister {
|
|
|
696
723
|
// are left OFF the object (not zeroed) when there is no driver or it predates this method, so
|
|
697
724
|
// that case can't be misread as "re-armed none" either.
|
|
698
725
|
this.logMeta('persistence.restored', {
|
|
699
|
-
agents: Object.keys((
|
|
726
|
+
agents: Object.keys((_g = snapshot.agentSnapshots) !== null && _g !== void 0 ? _g : {}),
|
|
700
727
|
condensePolicies: Object.assign({ stored: Array.isArray(snapshot.condensePolicies) ? snapshot.condensePolicies.length : 0 }, condenseRestore),
|
|
701
728
|
agentSnapshots: snapshot.agentSnapshots,
|
|
702
729
|
pinnedAgentName: snapshot.pinnedAgentName,
|
|
@@ -726,8 +753,8 @@ export class SessionPersister {
|
|
|
726
753
|
//
|
|
727
754
|
// On the driver itself, not a narrowed orchestrator (GENC-1660): both members are on
|
|
728
755
|
// `AiDriver` and every decorator forwards them, so this reaches the routing whatever wraps it.
|
|
729
|
-
driver === null || driver === void 0 ? void 0 : driver.setPinnedAgent((
|
|
730
|
-
driver === null || driver === void 0 ? void 0 : driver.setFlowOwner((
|
|
756
|
+
driver === null || driver === void 0 ? void 0 : driver.setPinnedAgent((_h = snapshot.pinnedAgentName) !== null && _h !== void 0 ? _h : null);
|
|
757
|
+
driver === null || driver === void 0 ? void 0 : driver.setFlowOwner((_j = snapshot.flowOwnerAgentName) !== null && _j !== void 0 ? _j : null);
|
|
731
758
|
if (flowOwner) {
|
|
732
759
|
this.logMeta('persistence.resume-planned', {
|
|
733
760
|
flowOwner,
|
|
@@ -13,8 +13,8 @@ export const PERSISTED_SESSION_VERSION = 1;
|
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
15
15
|
export function createPersistedSession(input) {
|
|
16
|
-
var _a, _b;
|
|
17
|
-
return Object.assign(Object.assign(Object.assign({ version: PERSISTED_SESSION_VERSION, savedAt: new Date().toISOString(), host: input.host, sessionKey: input.sessionKey, messages: input.messages, activeAgentName: input.activeAgentName, pinnedAgentName: input.pinnedAgentName, flowOwnerAgentName: input.flowOwnerAgentName, sessionCostUsd: input.sessionCostUsd, contextTokens: input.contextTokens, contextLimit: input.contextLimit, activeModel: input.activeModel, activeProviderName: input.activeProviderName, agentSnapshots: (_a = input.agentSnapshots) !== null && _a !== void 0 ? _a : {} }, (((_b = input.condensePolicies) === null || _b === void 0 ? void 0 : _b.length) ? { condensePolicies: input.condensePolicies } : {})), (input.autopilot ? { autopilot: input.autopilot } : {})), (input.
|
|
16
|
+
var _a, _b, _c;
|
|
17
|
+
return Object.assign(Object.assign(Object.assign({ version: PERSISTED_SESSION_VERSION, savedAt: new Date().toISOString(), host: input.host, sessionKey: input.sessionKey, messages: input.messages, activeAgentName: input.activeAgentName, pinnedAgentName: input.pinnedAgentName, flowOwnerAgentName: input.flowOwnerAgentName, sessionCostUsd: input.sessionCostUsd, contextTokens: input.contextTokens, contextLimit: input.contextLimit, activeModel: input.activeModel, activeProviderName: input.activeProviderName, agentSnapshots: (_a = input.agentSnapshots) !== null && _a !== void 0 ? _a : {} }, (((_b = input.condensePolicies) === null || _b === void 0 ? void 0 : _b.length) ? { condensePolicies: input.condensePolicies } : {})), (input.autopilot ? { autopilot: input.autopilot } : {})), (((_c = input.checkpoints) === null || _c === void 0 ? void 0 : _c.length) ? { checkpoints: input.checkpoints } : {}));
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Resolve the notice text + pre-fill prompt for an interrupted (non-resumable) flow
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { createInteractionContext } from './interaction-context';
|
|
3
|
+
/**
|
|
4
|
+
* Build a real interaction context for a controller test (GENC-1660), so the test exercises the
|
|
5
|
+
* platform's own context — its `state`, `once`, `notify`, surfaces and their checks — rather than a
|
|
6
|
+
* hand-built fake that can drift from it. Nothing renders, nothing is persisted, and no driver is
|
|
7
|
+
* involved: resolving records the result, and the interaction is disposed as it would be.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const t = createTestInteractionContext<ReviewController, ReviewResult>({
|
|
12
|
+
* data: { round: 1 },
|
|
13
|
+
* controller: (data, ctx) => new ReviewController(data as ReviewData, ctx),
|
|
14
|
+
* });
|
|
15
|
+
* t.setHeldBy('autopilot');
|
|
16
|
+
* await t.act('regenerate', { text: 'amounts in EUR' });
|
|
17
|
+
* assert.equal(t.result?.payload, { action: 'regenerate', instructions: 'amounts in EUR' });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @beta
|
|
21
|
+
*/
|
|
22
|
+
export function createTestInteractionContext(options = {}) {
|
|
23
|
+
var _a;
|
|
24
|
+
let result;
|
|
25
|
+
let resolvedItself = false;
|
|
26
|
+
let notifications = 0;
|
|
27
|
+
const attention = [];
|
|
28
|
+
// Settled through the platform's own `resolve`, which settles once; disposed as the driver would.
|
|
29
|
+
const live = createInteractionContext((_a = options.interactionId) !== null && _a !== void 0 ? _a : 'test-interaction', {
|
|
30
|
+
resolve: (value, how) => {
|
|
31
|
+
result = value;
|
|
32
|
+
resolvedItself = (how === null || how === void 0 ? void 0 : how.resolvedItself) === true;
|
|
33
|
+
live.dispose();
|
|
34
|
+
},
|
|
35
|
+
checkpoint: options.checkpoint,
|
|
36
|
+
saveCheckpoint: () => undefined,
|
|
37
|
+
requestAttention: (message) => {
|
|
38
|
+
attention.push(message === undefined ? {} : { message });
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
const context = live.context;
|
|
42
|
+
live.context.subscribe(() => {
|
|
43
|
+
notifications += 1;
|
|
44
|
+
});
|
|
45
|
+
let controller;
|
|
46
|
+
if (options.controller) {
|
|
47
|
+
controller = options.controller(options.data, context);
|
|
48
|
+
live.setController(controller);
|
|
49
|
+
}
|
|
50
|
+
// Offered to nobody: the person holds it, as with no claimant, so attention can report.
|
|
51
|
+
live.markOffered();
|
|
52
|
+
return {
|
|
53
|
+
context,
|
|
54
|
+
get controller() {
|
|
55
|
+
return controller;
|
|
56
|
+
},
|
|
57
|
+
get result() {
|
|
58
|
+
return result;
|
|
59
|
+
},
|
|
60
|
+
get resolvedItself() {
|
|
61
|
+
return resolvedItself;
|
|
62
|
+
},
|
|
63
|
+
get notifications() {
|
|
64
|
+
return notifications;
|
|
65
|
+
},
|
|
66
|
+
get attention() {
|
|
67
|
+
return attention;
|
|
68
|
+
},
|
|
69
|
+
get surface() {
|
|
70
|
+
return live.surface;
|
|
71
|
+
},
|
|
72
|
+
setHeldBy(holder) {
|
|
73
|
+
live.setHeldBy(holder);
|
|
74
|
+
},
|
|
75
|
+
act(action, args) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const surface = live.surface;
|
|
78
|
+
if (!surface)
|
|
79
|
+
return { ok: false, error: 'no-surface', message: 'Nothing exposed yet.' };
|
|
80
|
+
const prepared = surface.prepare(action, args);
|
|
81
|
+
if ('error' in prepared)
|
|
82
|
+
return Object.assign({ ok: false }, prepared);
|
|
83
|
+
const before = result;
|
|
84
|
+
let output;
|
|
85
|
+
try {
|
|
86
|
+
output = yield prepared.run();
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
return { ok: false, error: 'threw', message: e instanceof Error ? e.message : String(e) };
|
|
90
|
+
}
|
|
91
|
+
const finished = before === undefined && result !== undefined;
|
|
92
|
+
return Object.assign({ ok: true, finished }, (output !== undefined && !finished ? { output } : {}));
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
dispose() {
|
|
96
|
+
live.dispose();
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
package/docs/notifications.md
CHANGED
|
@@ -18,12 +18,40 @@ The person picks one level. Each includes the one before it.
|
|
|
18
18
|
|---|---|---|
|
|
19
19
|
| `'off'` | Off | Never. The default. |
|
|
20
20
|
| `'autopilot'` | Autopilot | The autopilot hands something back to the person, or stops working. |
|
|
21
|
-
| `'needs-input'` | Always (On, without the autopilot level) | Every `'autopilot'` case, plus any widget that asks for the person's attention. |
|
|
21
|
+
| `'needs-input'` | Always (On, without the autopilot level) | Every `'autopilot'` case, plus any widget that asks for the person's attention, and every turn that ends with the assistant waiting for the person to type. |
|
|
22
22
|
|
|
23
23
|
"Stops working" means anything that leaves the autopilot idle without the person having paused it: its flow ending, a turn ending with nothing left for it to answer, or a wall such as the budget. A pause the person makes themselves never notifies.
|
|
24
24
|
|
|
25
|
+
"Waiting for the person to type" means a turn ended, and the composer is theirs again:
|
|
26
|
+
|
|
27
|
+
- The turn ran to its end, a failed turn included. A turn the person stopped themselves never notifies.
|
|
28
|
+
- Nothing else waits on them: no interaction is open. An open one reports itself, when its widget asks for attention or the autopilot hands it back, so one moment never notifies twice.
|
|
29
|
+
- No autopilot is running for the flow. A running one answers, hands back or reports its own stop. A paused or unavailable autopilot, or none, does not stop the report.
|
|
30
|
+
|
|
31
|
+
Sub-agents' turns never count: they run inside a turn of the agent that called them.
|
|
32
|
+
|
|
25
33
|
The type is `AgentNotificationLevel`.
|
|
26
34
|
|
|
35
|
+
### When a hand-back notifies
|
|
36
|
+
|
|
37
|
+
The autopilot hands a widget to the person in two ways: it may not answer the widget (its policy keeps it for the person, it is `userOnly`, or it has no controller), or it took the widget and then gave it back.
|
|
38
|
+
|
|
39
|
+
A widget it may not answer notifies only once the widget is waiting on the person. The first three rules are the ones the status line uses for "Waiting for your answer":
|
|
40
|
+
|
|
41
|
+
- A widget whose controller says it is working (`ctx.setWorking(true)`) is not waiting.
|
|
42
|
+
- A widget registered `resolvesItself` is not waiting, unless its controller says it is asking (`ctx.setWorking(false)`).
|
|
43
|
+
- Any other widget is waiting.
|
|
44
|
+
- A widget that asks for attention (`requestAttention`) is waiting, whatever the rules above say.
|
|
45
|
+
|
|
46
|
+
The notification comes a quarter of a second after the widget starts waiting, if it is still waiting then and the person still holds it. So:
|
|
47
|
+
|
|
48
|
+
- A widget that settles by itself as it mounts never notifies. Register such a widget `resolvesItself`, because a hidden tab does not render it until the person comes back.
|
|
49
|
+
- A widget that works first, such as a review that runs its steps and then asks, notifies when it starts asking, with its own message. It can call `setWorking(false)` and `requestAttention(message)` in either order.
|
|
50
|
+
- A widget that settles while it is still working never notifies. Neither does one that a claimant takes first.
|
|
51
|
+
- A widget that asked for attention while the autopilot was paused was reported then. When Resume leaves it with the person, it does not notify again.
|
|
52
|
+
|
|
53
|
+
A widget the autopilot took and then gave back notifies at once. The autopilot gave it back because it needs the person, so the "needs you" badge shows too.
|
|
54
|
+
|
|
27
55
|
---
|
|
28
56
|
|
|
29
57
|
## App configuration
|
|
@@ -67,16 +95,20 @@ registerInteraction('pick-template', {
|
|
|
67
95
|
});
|
|
68
96
|
```
|
|
69
97
|
|
|
70
|
-
Call it at the moment the widget starts waiting on the person. A widget that has work to do first (loading data, running steps) calls it when its question is ready, not when it opens.
|
|
98
|
+
Call it at the moment the widget starts waiting on the person. A widget that has work to do first (loading data, running steps) calls it when its question is ready, not when it opens. A controller typed against `ControllerHost` rather than the full `InteractionContext` calls it on its host, the same way: `host.requestAttention?.('Your functional tests are ready to review')`. It is optional there because a stand-in host has none.
|
|
71
99
|
|
|
72
100
|
The widget never has to check who holds the interaction. The platform handles that:
|
|
73
101
|
|
|
74
102
|
- The call is reported only once the platform has decided who holds the interaction, so calling it from the controller's constructor is safe, even though the autopilot has not been offered the interaction yet.
|
|
75
|
-
- If the autopilot holds the interaction, at that point or when the widget calls, nothing is reported. If the autopilot hands it back, the hand-back notifies instead, so the person gets one notification.
|
|
103
|
+
- If the autopilot holds the interaction, at that point or when the widget calls, nothing is reported. If the autopilot hands it back, the hand-back notifies instead, with the widget's message, so the person gets one notification in the widget's words.
|
|
104
|
+
- If the autopilot may not answer the interaction, the hand-back is its only notification, whenever the widget calls. The call only tells the autopilot that the widget is asking, and gives the hand-back its message (see [When a hand-back notifies](#when-a-hand-back-notifies)). A widget that has said nothing about working counts as asking from the start, so a message it asks with later than a quarter of a second after it opens comes too late to be used. If it has work to do first, it calls `setWorking(true)` until its question is ready.
|
|
105
|
+
- If the widget calls only after the autopilot took it and then handed it back, its call is reported as usual. The hand-back's notification keeps its tag, and only its text changes to the widget's message (see [Duplicates](#duplicates)).
|
|
76
106
|
- Only the first call counts, whatever happened to it. A widget gets at most one notification for its whole life.
|
|
77
107
|
|
|
78
108
|
The text is the first of: the argument, `chatConfig.ui.notifications.message`, the default. Only the `'needs-input'` level shows these.
|
|
79
109
|
|
|
110
|
+
In a controller test, `createTestInteractionContext(...).attention` lists the calls that were reported, by the same rules: the first call only, and none while a claimant holds the interaction (`setHeldBy('autopilot')`). The test context has no claimant at the start, so a call made while the controller is built is reported as the person's.
|
|
111
|
+
|
|
80
112
|
---
|
|
81
113
|
|
|
82
114
|
## Inviting the person to switch notifications on
|
|
@@ -151,19 +183,37 @@ Every report is published as `agent-attention` on the activity bus, whatever the
|
|
|
151
183
|
```ts
|
|
152
184
|
agenticActivityBus.subscribe('agent-attention', (detail) => {
|
|
153
185
|
// detail: { sessionKey, kind, interactionId?, message? }
|
|
154
|
-
// kind: 'widget-needs-input' | 'autopilot-handed-back' | 'autopilot-stopped'
|
|
186
|
+
// kind: 'widget-needs-input' | 'autopilot-handed-back' | 'autopilot-stopped' | 'turn-ended'
|
|
155
187
|
});
|
|
156
188
|
```
|
|
157
189
|
|
|
190
|
+
| Kind | Reported when | Shown at |
|
|
191
|
+
|---|---|---|
|
|
192
|
+
| `'widget-needs-input'` | A widget asked for the person's attention, while the person holds it. | `'needs-input'` |
|
|
193
|
+
| `'autopilot-handed-back'` | The autopilot handed an interaction to the person, or a turn of its own. For a widget it may not answer, only once the widget waits on the person (see [When a hand-back notifies](#when-a-hand-back-notifies)). Carries the widget's message when it asked with one. | `'autopilot'` and above |
|
|
194
|
+
| `'autopilot-stopped'` | The autopilot stopped working without the person pausing it. | `'autopilot'` and above |
|
|
195
|
+
| `'turn-ended'` | A turn ended with the assistant waiting for the person to type (see [Levels](#levels)). | `'needs-input'` |
|
|
196
|
+
|
|
158
197
|
The assistant for that session decides whether to show a notification. An app can listen to the same event to drive its own UI. The event is tab-local: it comes from the window that owns the session's driver.
|
|
159
198
|
|
|
160
199
|
Clicking a notification focuses the window and publishes `autopilot-show-waiting` for the session: a closed chat bubble holding that assistant opens, and the assistant brings what waits on the person into view.
|
|
161
200
|
|
|
201
|
+
When an interaction stops waiting on the person, `agent-attention-ended` is published, whether a notification was shown for it or not:
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
agenticActivityBus.subscribe('agent-attention-ended', ({ sessionKey, interactionId }) => {
|
|
205
|
+
// The interaction settled, or a claimant (such as the autopilot, on Resume) took it.
|
|
206
|
+
});
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
The assistant for that session closes the interaction's notification, if it is still showing. The event is tab-local too.
|
|
210
|
+
|
|
162
211
|
---
|
|
163
212
|
|
|
164
213
|
## Duplicates
|
|
165
214
|
|
|
166
215
|
- Each notification carries a tag. The browser replaces a notification with the same tag rather than stacking copies.
|
|
167
216
|
- One interaction gets one tag, whichever report it came from: the autopilot handing it back, or the widget asking for attention.
|
|
168
|
-
-
|
|
217
|
+
- Every report without an interaction shares one tag per session: the autopilot's stop, and a turn ending. The turn that ends a flow can make both at once, and the person gets one notification.
|
|
169
218
|
- The same tag is not shown again within a few seconds.
|
|
219
|
+
- A notification for an interaction closes when the interaction stops waiting on the person: it settles, or a claimant takes it. Its tag is then forgotten, so if the claimant hands the interaction back, that notifies again. A notification without an interaction (a stop, or a turn ending) is not closed this way.
|
package/docs/styling.md
CHANGED
|
@@ -292,6 +292,39 @@ Styling `::part(send-button)` alone will **not** achieve this: the design-system
|
|
|
292
292
|
button paints its own background over any gradient set on it, so the gradient has
|
|
293
293
|
to come from behind. The shell is that behind.
|
|
294
294
|
|
|
295
|
+
### The autopilot
|
|
296
|
+
|
|
297
|
+
While an agent's autopilot is available (GENC-1660), the composer gains an
|
|
298
|
+
**Autopilot** pill, and while it runs and something is happening a slim bar takes
|
|
299
|
+
the composer's place. A widget the autopilot hands back carries a banner in its
|
|
300
|
+
own bubble.
|
|
301
|
+
|
|
302
|
+
| Part | Element |
|
|
303
|
+
| --- | --- |
|
|
304
|
+
| `autopilot-bar` | The slim bar that stands in for the composer |
|
|
305
|
+
| `autopilot-status` | Its one-line status, e.g. "Building from your plan…", or "Waiting for your answer" while the person holds an open question |
|
|
306
|
+
| `autopilot-bar-end` | The trailing cluster: the pill, and Stop while a turn runs |
|
|
307
|
+
| `autopilot-toggle` | The Autopilot pill, on or off, in the composer or the slim bar |
|
|
308
|
+
| `autopilot-toggle-on` | That pill, only while it is on (running, and not waiting on an answer it handed back) |
|
|
309
|
+
| `autopilot-banner` | The hand-back banner at the top of a handed-back widget's bubble |
|
|
310
|
+
| `autopilot-banner-text` | Its text: the lead and the reason |
|
|
311
|
+
| `autopilot-keep-paused` | Its **Keep paused** button |
|
|
312
|
+
| `autopilot-announcer` | The visually hidden status region that announces changes |
|
|
313
|
+
| `delegate-mark` | The autopilot mark beside the sender of anything done on the person's behalf |
|
|
314
|
+
|
|
315
|
+
**Use `autopilot-toggle-on` for the on state.** Its default fill is the accent
|
|
316
|
+
gradient, the same as the person's own bubble. `::part()` cannot select a class
|
|
317
|
+
or an attribute, so `autopilot-toggle` alone reaches the pill whether on or
|
|
318
|
+
off; the second name is how the on state is reached. To keep it matching a
|
|
319
|
+
restyled user bubble:
|
|
320
|
+
|
|
321
|
+
```css
|
|
322
|
+
foundation-ai-assistant::part(message-user),
|
|
323
|
+
foundation-ai-assistant::part(autopilot-toggle-on) {
|
|
324
|
+
background: var(--user-msg-bubble);
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
295
328
|
### The settings-modal budget meter
|
|
296
329
|
|
|
297
330
|
The per-vendor AI budget meter (GENC-1464) renders in the settings modal's
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/ai-assistant",
|
|
3
3
|
"description": "Genesis AI Assistant micro-frontend",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.84.0",
|
|
5
5
|
"license": "SEE LICENSE IN license.txt",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
7
|
-
"types": "dist/
|
|
7
|
+
"types": "dist/dts/index.d.ts",
|
|
8
8
|
"config": {
|
|
9
9
|
"PORT": 5099
|
|
10
10
|
},
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
|
-
"types": "./dist/
|
|
23
|
+
"types": "./dist/dts/index.d.ts",
|
|
24
24
|
"default": "./dist/esm/index.js"
|
|
25
25
|
},
|
|
26
26
|
"./config": {
|
|
@@ -92,31 +92,31 @@
|
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
|
-
"@genesislcap/foundation-comms": "15.
|
|
96
|
-
"@genesislcap/foundation-testing": "15.
|
|
97
|
-
"@genesislcap/genx": "15.
|
|
98
|
-
"@genesislcap/ts-builder": "15.
|
|
99
|
-
"@genesislcap/uvu-playwright-builder": "15.
|
|
100
|
-
"@genesislcap/vite-builder": "15.
|
|
101
|
-
"@genesislcap/webpack-builder": "15.
|
|
95
|
+
"@genesislcap/foundation-comms": "15.84.0",
|
|
96
|
+
"@genesislcap/foundation-testing": "15.84.0",
|
|
97
|
+
"@genesislcap/genx": "15.84.0",
|
|
98
|
+
"@genesislcap/ts-builder": "15.84.0",
|
|
99
|
+
"@genesislcap/uvu-playwright-builder": "15.84.0",
|
|
100
|
+
"@genesislcap/vite-builder": "15.84.0",
|
|
101
|
+
"@genesislcap/webpack-builder": "15.84.0",
|
|
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.
|
|
108
|
-
"@genesislcap/foundation-logger": "15.
|
|
109
|
-
"@genesislcap/foundation-notifications": "15.
|
|
110
|
-
"@genesislcap/foundation-redux": "15.
|
|
111
|
-
"@genesislcap/foundation-ui": "15.
|
|
112
|
-
"@genesislcap/foundation-utils": "15.
|
|
113
|
-
"@genesislcap/rapid-design-system": "15.
|
|
114
|
-
"@genesislcap/web-core": "15.
|
|
107
|
+
"@genesislcap/foundation-ai": "15.84.0",
|
|
108
|
+
"@genesislcap/foundation-logger": "15.84.0",
|
|
109
|
+
"@genesislcap/foundation-notifications": "15.84.0",
|
|
110
|
+
"@genesislcap/foundation-redux": "15.84.0",
|
|
111
|
+
"@genesislcap/foundation-ui": "15.84.0",
|
|
112
|
+
"@genesislcap/foundation-utils": "15.84.0",
|
|
113
|
+
"@genesislcap/rapid-design-system": "15.84.0",
|
|
114
|
+
"@genesislcap/web-core": "15.84.0",
|
|
115
115
|
"dompurify": "^3.3.1",
|
|
116
116
|
"marked": "^17.0.3"
|
|
117
117
|
},
|
|
118
118
|
"peerDependencies": {
|
|
119
|
-
"@genesislcap/foundation-comms": "^15.
|
|
119
|
+
"@genesislcap/foundation-comms": "^15.84.0"
|
|
120
120
|
},
|
|
121
121
|
"peerDependenciesMeta": {
|
|
122
122
|
"@genesislcap/foundation-comms": {
|
package/sandbox/README.md
CHANGED
|
@@ -187,13 +187,14 @@ Two stand-ins, both in `autopilot.ts`, and both reaching the element through its
|
|
|
187
187
|
| Control | What to look for |
|
|
188
188
|
| --- | --- |
|
|
189
189
|
| **Mode: Unavailable** | Today's UI, unchanged. Nothing autopilot-shaped anywhere. |
|
|
190
|
-
| **Mode: Running** | While something is happening — **Simulated state: Busy**, or the demo widget open and held by the autopilot — the slim bar replaces the composer: the status, then the **Autopilot** pill on the right — filled like your own bubble while it is on, with the mark as its glyph and "Pause autopilot: …" as its tooltip — and **Stop** while busy. No text box, so nothing can be typed by accident. Idle (the state as it is after a wall such as the budget), the normal composer comes back with the pill filled among its pills, and no status. |
|
|
190
|
+
| **Mode: Running** | While something is happening — **Simulated state: Busy**, or the demo widget open and held by the autopilot — the slim bar replaces the composer: the status, then the **Autopilot** pill on the right — filled like your own bubble while it is on (and answering to the extra part name `autopilot-toggle-on`), with the mark as its glyph and "Pause autopilot: …" as its tooltip — and **Stop** while busy. No text box, so nothing can be typed by accident. Idle (the state as it is after a wall such as the budget), the normal composer comes back with the pill filled among its pills, and no status. |
|
|
191
191
|
| **Mode: Paused** | With **Agent hides the composer while working** on and the state Busy, the slim bar again, reading "Paused" with the pill unfilled. Turn the toggle off (or go idle) and the normal composer comes back with the pill after the agent picker, among the other pills — the autopilot never forces the composer open. |
|
|
192
192
|
| **Hide composer** + **Mode: Running** or **Paused** | A host with no composer has no pills to put the **Autopilot** pill among, so the slim bar stays up whenever the autopilot is available — idle or not, running or paused — with its status and the pill, so the person can always see it is on and pause or resume it. |
|
|
193
193
|
| **Mode: Self-paused** | With the state Busy, the slim bar reads "Waiting for your answer…" with the pill unfilled; its tooltip leads with "Resume autopilot and force it to decide this one". Open the demo widget: its bubble carries the banner, "I need your input on this one: …", with **Keep paused**. |
|
|
194
194
|
| **Open the demo widget**, held by the autopilot | **Hidden** registration: no bubble at all, just the working indicator. **Visible**: the bubble stays and only its button goes, with a line saying the claimant holds it. |
|
|
195
195
|
| **Held by: The person** | The widget comes back with its button, exactly as today. Press it to see the answered state. |
|
|
196
|
-
| **
|
|
196
|
+
| **Mode: Running** + **Simulated state: Busy** + the demo widget open, **Held by: The person** | The slim bar reads "Waiting for your answer" (`waitingForUser`) rather than the running status: the working agent is parked on a question the autopilot never took, so the person is the one being waited on. The pill stays on, since nothing paused, and no "needs you" badge, since the autopilot did not stop. Press the button, or hand it back to the autopilot, and the running status returns. |
|
|
197
|
+
| **Seed: Autopilot: delegated messages** | Narration before an answered widget (with no echo after it: the narration already said what was chosen), the "I chose" echo after a widget answered without narration, and a written answer given on the user's behalf — every one on the assistant's side, with the mark beside the sender. **Delegated mark: None** removes the mark and nothing else. |
|
|
197
198
|
| **Needs you** + **Show the collapsed bubble** | A badge on the orb, bottom right. Self-paused raises it too. |
|
|
198
199
|
|
|
199
200
|
The **Element** readout is read off the element, not the panel: who holds the trailing interaction,
|
package/sandbox/autopilot.ts
CHANGED
|
@@ -29,6 +29,7 @@ const COPY: AutopilotCopy = {
|
|
|
29
29
|
running: 'Building from your plan…',
|
|
30
30
|
paused: 'Paused',
|
|
31
31
|
selfPaused: "Waiting for your answer: I'll carry on after this",
|
|
32
|
+
waitingForUser: 'Waiting for your answer',
|
|
32
33
|
handBackLead: 'I need your input on this one:',
|
|
33
34
|
toggleLabel: 'Autopilot',
|
|
34
35
|
description: "Answers the assistant's questions on your behalf, so the work keeps going.",
|
|
@@ -72,6 +73,11 @@ export class SandboxAutopilotHost implements AutopilotHost {
|
|
|
72
73
|
* simulated state and the demo widget. Running and idle, the composer comes back.
|
|
73
74
|
*/
|
|
74
75
|
private readonly working: () => boolean,
|
|
76
|
+
/**
|
|
77
|
+
* Whether the person holds an open question, as the real driver tracks it: the demo widget open
|
|
78
|
+
* and held by the person. Running, the status then says so.
|
|
79
|
+
*/
|
|
80
|
+
private readonly waitingOnUser: () => boolean,
|
|
75
81
|
) {}
|
|
76
82
|
|
|
77
83
|
get state(): AutopilotHostState {
|
|
@@ -85,9 +91,11 @@ export class SandboxAutopilotHost implements AutopilotHost {
|
|
|
85
91
|
'self-paused': 'running',
|
|
86
92
|
} as const
|
|
87
93
|
)[this.mode];
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
let status = COPY.paused;
|
|
95
|
+
if (selfPaused) status = COPY.selfPaused;
|
|
96
|
+
else if (this.mode === 'running') {
|
|
97
|
+
status = this.waitingOnUser() ? COPY.waitingForUser : COPY.running;
|
|
98
|
+
}
|
|
91
99
|
return {
|
|
92
100
|
mode,
|
|
93
101
|
...(selfPaused
|
|
@@ -101,7 +109,7 @@ export class SandboxAutopilotHost implements AutopilotHost {
|
|
|
101
109
|
: this.mode === 'paused'
|
|
102
110
|
? { pause: { scope: 'until-resumed' as const } }
|
|
103
111
|
: {}),
|
|
104
|
-
status: this.mode === 'off' ? '' : status,
|
|
112
|
+
status: this.mode === 'off' ? '' : this.status || status,
|
|
105
113
|
needsUser: this.needsUser || selfPaused,
|
|
106
114
|
working: this.mode !== 'off' && this.working(),
|
|
107
115
|
};
|
|
@@ -319,8 +327,9 @@ export const openDemoWidget = (driver: AiDriver): void => {
|
|
|
319
327
|
|
|
320
328
|
/**
|
|
321
329
|
* Each kind of delegated message: narration before a widget the autopilot answered, the "I chose"
|
|
322
|
-
* echo, and a written answer given on the user's behalf.
|
|
323
|
-
*
|
|
330
|
+
* echo after one it answered without narration, and a written answer given on the user's behalf.
|
|
331
|
+
* All render as the assistant, with the mark. A widget answered with narration has no echo: the
|
|
332
|
+
* narration already said what was chosen. Unstamped: the fixtures stamp it like every other seed.
|
|
324
333
|
*/
|
|
325
334
|
export const autopilotTranscript = (): ChatMessage[] => [
|
|
326
335
|
{ role: 'user', content: 'Build me a trade blotter from my plan.' },
|
|
@@ -341,6 +350,17 @@ export const autopilotTranscript = (): ChatMessage[] => [
|
|
|
341
350
|
answeredBy: 'autopilot',
|
|
342
351
|
},
|
|
343
352
|
},
|
|
353
|
+
{
|
|
354
|
+
role: 'assistant',
|
|
355
|
+
content: '',
|
|
356
|
+
interaction: {
|
|
357
|
+
interactionId: 'sandbox-answered-quietly',
|
|
358
|
+
componentName: DEMO_WIDGET,
|
|
359
|
+
data: { question: 'Which actions should the blotter offer?', label: 'Approve, Reject' },
|
|
360
|
+
resolved: { status: 'approved', payload: { pressed: true } },
|
|
361
|
+
answeredBy: 'autopilot',
|
|
362
|
+
},
|
|
363
|
+
},
|
|
344
364
|
{
|
|
345
365
|
role: 'assistant',
|
|
346
366
|
content: 'I chose: Approve trade, Reject trade',
|