@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
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { InteractionResult } from '@genesislcap/foundation-ai';
|
|
2
|
+
import type { InteractionContext, InteractionHolder } from '../types/interaction-context';
|
|
3
|
+
import type { InteractionSurface } from '../types/interaction-surface';
|
|
4
|
+
import type { InteractionControllerFactory } from './interaction-registry';
|
|
5
|
+
/**
|
|
6
|
+
* What a claimant's action came to in a test: as `InteractionHold.invoke` reports it, less the
|
|
7
|
+
* holding (a test context has no claimant to check).
|
|
8
|
+
*
|
|
9
|
+
* @beta
|
|
10
|
+
*/
|
|
11
|
+
export type TestActResult = {
|
|
12
|
+
readonly ok: true;
|
|
13
|
+
readonly finished: boolean;
|
|
14
|
+
readonly output?: unknown;
|
|
15
|
+
} | {
|
|
16
|
+
readonly ok: false;
|
|
17
|
+
readonly error: 'no-surface' | 'unknown-action' | 'disabled' | 'invalid-args' | 'threw';
|
|
18
|
+
readonly message: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* A real {@link InteractionContext} for a controller test, with the handles a test needs
|
|
22
|
+
* (GENC-1660). See {@link createTestInteractionContext}.
|
|
23
|
+
*
|
|
24
|
+
* @beta
|
|
25
|
+
*/
|
|
26
|
+
export interface TestInteractionContext<TController = unknown, TResult = unknown> {
|
|
27
|
+
/** The context, as the platform builds it: pass it to the controller as its host. */
|
|
28
|
+
readonly context: InteractionContext<Record<string, unknown>, unknown, TController>;
|
|
29
|
+
/** The controller, when built through `options.controller`; otherwise `undefined`. */
|
|
30
|
+
readonly controller: TController | undefined;
|
|
31
|
+
/** What the controller resolved with, or `undefined` while it has not. Only the first counts. */
|
|
32
|
+
readonly result: InteractionResult<TResult> | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the controller said its outcome settled by itself
|
|
35
|
+
* (`ctx.resolve(result, { resolvedItself: true })`), which the platform then stamps as answered
|
|
36
|
+
* by nobody. `false` while it has not resolved.
|
|
37
|
+
*/
|
|
38
|
+
readonly resolvedItself: boolean;
|
|
39
|
+
/** How many times `notify()` has been called. */
|
|
40
|
+
readonly notifications: number;
|
|
41
|
+
/**
|
|
42
|
+
* The widget's `requestAttention` calls that were reported, as the platform would report them
|
|
43
|
+
* (GENC-1660): only the first call counts, none after the interaction ends, and none while a
|
|
44
|
+
* claimant holds it. The test context offers the interaction straight after building the
|
|
45
|
+
* controller, with nobody claiming it, so a call made while being built is reported as the
|
|
46
|
+
* person's; one made after `setHeldBy('autopilot')` is held back for the claimant's hand-back.
|
|
47
|
+
*/
|
|
48
|
+
readonly attention: ReadonlyArray<{
|
|
49
|
+
readonly message?: string;
|
|
50
|
+
}>;
|
|
51
|
+
/** The surface the controller exposed, as a claimant reads it; `undefined` until it exposes one. */
|
|
52
|
+
readonly surface: InteractionSurface | undefined;
|
|
53
|
+
/** Move the interaction to `holder` (`'user'`, or a claimant's id such as `'autopilot'`). */
|
|
54
|
+
setHeldBy(holder: InteractionHolder): void;
|
|
55
|
+
/**
|
|
56
|
+
* Run one of the surface's actions as a claimant would, through the platform's own checks (the
|
|
57
|
+
* action exists, its guard allows it, its arguments fit) and then its `run`: an option by id,
|
|
58
|
+
* `select` with `{ options }`, `reply` or a text action with `{ text }`, a form with its fields.
|
|
59
|
+
*/
|
|
60
|
+
act(action: string, args?: unknown): Promise<TestActResult>;
|
|
61
|
+
/** End the interaction, running its `onDispose` callbacks, as settling it would. */
|
|
62
|
+
dispose(): void;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Build a real interaction context for a controller test (GENC-1660), so the test exercises the
|
|
66
|
+
* platform's own context — its `state`, `once`, `notify`, surfaces and their checks — rather than a
|
|
67
|
+
* hand-built fake that can drift from it. Nothing renders, nothing is persisted, and no driver is
|
|
68
|
+
* involved: resolving records the result, and the interaction is disposed as it would be.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const t = createTestInteractionContext<ReviewController, ReviewResult>({
|
|
73
|
+
* data: { round: 1 },
|
|
74
|
+
* controller: (data, ctx) => new ReviewController(data as ReviewData, ctx),
|
|
75
|
+
* });
|
|
76
|
+
* t.setHeldBy('autopilot');
|
|
77
|
+
* await t.act('regenerate', { text: 'amounts in EUR' });
|
|
78
|
+
* assert.equal(t.result?.payload, { action: 'regenerate', instructions: 'amounts in EUR' });
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @beta
|
|
82
|
+
*/
|
|
83
|
+
export declare function createTestInteractionContext<TController = unknown, TResult = unknown>(options?: {
|
|
84
|
+
/** Defaults to `'test-interaction'`. */
|
|
85
|
+
readonly interactionId?: string;
|
|
86
|
+
/** The `data` handed to `controller`. */
|
|
87
|
+
readonly data?: unknown;
|
|
88
|
+
/** Build the controller as the platform would, and install it as `context.controller`. */
|
|
89
|
+
readonly controller?: InteractionControllerFactory<TController>;
|
|
90
|
+
/** A checkpoint the platform handed over, as after a reload (`ctx.checkpoint`). */
|
|
91
|
+
readonly checkpoint?: unknown;
|
|
92
|
+
}): TestInteractionContext<TController, TResult>;
|
|
93
|
+
//# sourceMappingURL=test-interaction-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-interaction-context.d.ts","sourceRoot":"","sources":["../../../src/state/test-interaction-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAC5E;IACE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,gBAAgB,GAAG,UAAU,GAAG,cAAc,GAAG,OAAO,CAAC;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E,OAAO,CAAC;IACxB,0FAA0F;IAC1F,QAAQ,CAAC,UAAU,CAAC,EAAE,4BAA4B,CAAC,WAAW,CAAC,CAAC;IAChE,mFAAmF;IACnF,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC1B,GACL,sBAAsB,CAAC,WAAW,EAAE,OAAO,CAAC,CAuE9C"}
|
|
@@ -7,11 +7,11 @@ import type { InteractionContext } from './interaction-context';
|
|
|
7
7
|
* a `shouldAutoFocus`, and a pending widget cannot be read for a `result`.
|
|
8
8
|
*
|
|
9
9
|
* The host sets the widget's `interaction` on mount and REPLACES it (pending →
|
|
10
|
-
* resolved) on completion.
|
|
10
|
+
* resolved) on completion. `TController` types the pending context's `controller` (GENC-1660).
|
|
11
11
|
*
|
|
12
12
|
* @beta
|
|
13
13
|
*/
|
|
14
|
-
export type AiChatInteraction<TData = unknown, TResult = unknown> = {
|
|
14
|
+
export type AiChatInteraction<TData = unknown, TResult = unknown, TController = unknown> = {
|
|
15
15
|
status: 'pending';
|
|
16
16
|
/** Immutable inputs for the interaction. */
|
|
17
17
|
data: TData;
|
|
@@ -22,9 +22,10 @@ export type AiChatInteraction<TData = unknown, TResult = unknown> = {
|
|
|
22
22
|
shouldAutoFocus: boolean;
|
|
23
23
|
/**
|
|
24
24
|
* Live, remount-surviving scratch for this interaction. Present ONLY while
|
|
25
|
-
* pending — the host disposes it on resolve. See {@link InteractionContext}.
|
|
25
|
+
* pending — the host disposes it on resolve. See {@link InteractionContext}. Its
|
|
26
|
+
* `controller` is typed `TController`, as the widget was registered.
|
|
26
27
|
*/
|
|
27
|
-
interactionContext: InteractionContext
|
|
28
|
+
interactionContext: InteractionContext<Record<string, unknown>, unknown, TController>;
|
|
28
29
|
} | {
|
|
29
30
|
status: 'resolved';
|
|
30
31
|
/** Same inputs — the resolved view still reads them. */
|
|
@@ -67,10 +68,10 @@ export type AiChatInteraction<TData = unknown, TResult = unknown> = {
|
|
|
67
68
|
*
|
|
68
69
|
* @beta
|
|
69
70
|
*/
|
|
70
|
-
export interface AiChatWidget<TData = unknown, TResult = unknown> {
|
|
71
|
+
export interface AiChatWidget<TData = unknown, TResult = unknown, TController = unknown> {
|
|
71
72
|
/** Stable per-interaction UUID; constant across remounts, present in both states. */
|
|
72
73
|
interactionId: string;
|
|
73
74
|
/** The current interaction state (pending or resolved). */
|
|
74
|
-
interaction: AiChatInteraction<TData, TResult>;
|
|
75
|
+
interaction: AiChatInteraction<TData, TResult, TController>;
|
|
75
76
|
}
|
|
76
77
|
//# sourceMappingURL=ai-chat-widget.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-chat-widget.d.ts","sourceRoot":"","sources":["../../../src/types/ai-chat-widget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,CAAC,KAAK,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"ai-chat-widget.d.ts","sourceRoot":"","sources":["../../../src/types/ai-chat-widget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,CAAC,KAAK,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,WAAW,GAAG,OAAO,IACnF;IACE,MAAM,EAAE,SAAS,CAAC;IAClB,4CAA4C;IAC5C,IAAI,EAAE,KAAK,CAAC;IACZ;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,kBAAkB,EAAE,kBAAkB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;CACvF,GACD;IACE,MAAM,EAAE,UAAU,CAAC;IACnB,wDAAwD;IACxD,IAAI,EAAE,KAAK,CAAC;IACZ,+BAA+B;IAC/B,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACnC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;CACpC,CAAC;AAEN;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,YAAY,CAAC,KAAK,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,WAAW,GAAG,OAAO;IACrF,qFAAqF;IACrF,aAAa,EAAE,MAAM,CAAC;IAEtB,2DAA2D;IAC3D,WAAW,EAAE,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;CAC7D"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { InteractionResult } from '@genesislcap/foundation-ai';
|
|
1
2
|
import type { DecisionSpec, InteractionSurface, SurfaceSpec } from './interaction-surface';
|
|
2
3
|
/**
|
|
3
4
|
* Who holds a pending interaction: the person, or the id of the interceptor that claimed it
|
|
@@ -6,6 +7,26 @@ import type { DecisionSpec, InteractionSurface, SurfaceSpec } from './interactio
|
|
|
6
7
|
* @beta
|
|
7
8
|
*/
|
|
8
9
|
export type InteractionHolder = 'user' | (string & {});
|
|
10
|
+
/**
|
|
11
|
+
* How a controller settles its interaction, beside the result (GENC-1660). See
|
|
12
|
+
* {@link InteractionContext.resolve}.
|
|
13
|
+
*
|
|
14
|
+
* @beta
|
|
15
|
+
*/
|
|
16
|
+
export interface InteractionResolveOptions {
|
|
17
|
+
/**
|
|
18
|
+
* This outcome settled by itself and nobody answered it — a generation that failed outright, say
|
|
19
|
+
* — though the widget is not registered `resolvesItself` because at other times it asks (a review
|
|
20
|
+
* gate). It is then treated exactly as a `resolvesItself` widget's settle: no `answeredBy` on the
|
|
21
|
+
* message, the asking tool's result or the `interaction-settled` event, and `resolvedItself: true`
|
|
22
|
+
* on the message, the event and the `interaction.resolved` debug event, so neither the working
|
|
23
|
+
* agent nor a claimant is told the person decided it.
|
|
24
|
+
*
|
|
25
|
+
* Ignored when a claimant settles it through its hold (a finishing action that ends up resolving
|
|
26
|
+
* here is the claimant's answer), and on a timeout or a stop, which nobody answered anyway.
|
|
27
|
+
*/
|
|
28
|
+
readonly resolvedItself?: boolean;
|
|
29
|
+
}
|
|
9
30
|
/**
|
|
10
31
|
* A long action's checkpoint as persisted with the session (GENC-1660 §4.12): the widget type it
|
|
11
32
|
* belongs to, and the value its controller saved.
|
|
@@ -45,7 +66,7 @@ export interface PersistedInteractionCheckpoint {
|
|
|
45
66
|
*
|
|
46
67
|
* @beta
|
|
47
68
|
*/
|
|
48
|
-
export interface InteractionContext<TState extends object = Record<string, unknown>, TCheckpoint = unknown> {
|
|
69
|
+
export interface InteractionContext<TState extends object = Record<string, unknown>, TCheckpoint = unknown, TController = unknown> {
|
|
49
70
|
/** Stable id of the interaction this context belongs to. */
|
|
50
71
|
readonly interactionId: string;
|
|
51
72
|
/**
|
|
@@ -88,6 +109,10 @@ export interface InteractionContext<TState extends object = Record<string, unkno
|
|
|
88
109
|
* live resource here must guard on the resolved state and stop touching `once`
|
|
89
110
|
* when the interaction completes — a stray late call (e.g. an async callback
|
|
90
111
|
* landing after a `timeoutMs` timeout) gets `null` rather than a leaked resource.
|
|
112
|
+
*
|
|
113
|
+
* Once means once for the interaction's whole life, so it cannot fire twice: anything a
|
|
114
|
+
* claimant's hand-back must do again (reopening a side panel it shut while it held the
|
|
115
|
+
* interaction, say) needs a flag on `state` instead, cleared when it is undone.
|
|
91
116
|
*/
|
|
92
117
|
once<T>(key: string, factory: () => T): T | null;
|
|
93
118
|
/**
|
|
@@ -110,16 +135,53 @@ export interface InteractionContext<TState extends object = Record<string, unkno
|
|
|
110
135
|
onDispose(fn: () => void): void;
|
|
111
136
|
/**
|
|
112
137
|
* The widget's controller, built by the platform from its registration when the interaction was
|
|
113
|
-
* requested, before anything rendered. `undefined` for an unregistered widget
|
|
114
|
-
* interaction for its whole life, so a
|
|
138
|
+
* requested, before anything rendered. `undefined` for an unregistered widget, and inside the
|
|
139
|
+
* registration's own factory, which is building it. One per interaction for its whole life, so a
|
|
140
|
+
* remounted view picks up the same one. Typed by `TController`: a registration made with
|
|
141
|
+
* `registerInteraction<TController>()` builds one, and a view reads it typed through
|
|
142
|
+
* `AiChatInteraction`'s third type argument.
|
|
115
143
|
*/
|
|
116
|
-
readonly controller:
|
|
144
|
+
readonly controller: TController | undefined;
|
|
117
145
|
/**
|
|
118
146
|
* Settle the interaction with `result` — the controller's way to resolve, in place of an element
|
|
119
147
|
* emitting `interaction-completed`, so resolving needs no mounted view. Goes through the same
|
|
120
148
|
* path, so cost and diagnostics fold in as before. Settles once: later calls do nothing.
|
|
149
|
+
*
|
|
150
|
+
* Pass `{ resolvedItself: true }` when this outcome settled by itself and asked nobody, for a
|
|
151
|
+
* widget that sometimes works on its own and sometimes asks (see
|
|
152
|
+
* {@link InteractionResolveOptions.resolvedItself}).
|
|
153
|
+
*/
|
|
154
|
+
resolve(result: unknown, options?: InteractionResolveOptions): void;
|
|
155
|
+
/**
|
|
156
|
+
* What the controller last said it is doing (GENC-1660), through {@link InteractionContext.setWorking}:
|
|
157
|
+
* `true` working on its own (generating, running tests), `false` asking (what it has exposed is
|
|
158
|
+
* the decision to make now), `undefined` until it says either.
|
|
159
|
+
*/
|
|
160
|
+
readonly working: boolean | undefined;
|
|
161
|
+
/**
|
|
162
|
+
* Say whether the controller is working on its own or asking (GENC-1660), for a widget that does
|
|
163
|
+
* both — e.g. it generates, then opens a review gate. Optional: a controller that never calls it
|
|
164
|
+
* behaves exactly as before. Notifies when it changes.
|
|
165
|
+
*
|
|
166
|
+
* - **Status.** While it is working the person is not being asked anything, so an autopilot's
|
|
167
|
+
* status reads running rather than waiting for the user, even while the person holds it. Said
|
|
168
|
+
* either way, it overrides the registration's `resolvesItself` for this interaction.
|
|
169
|
+
* - **Readiness** (see {@link InteractionSurface.isReady}). While it is working, nothing it
|
|
170
|
+
* exposed is a decision yet, so a claimant is never sent one mid-work, even with actions
|
|
171
|
+
* enabled. Once it says it is asking, what it exposed is the decision to make now, even with
|
|
172
|
+
* every action unavailable — a failed gate the claimant may not cancel, say: the claimant is
|
|
173
|
+
* then sent it with the actions marked unavailable, and can only hand it back. Never said, a
|
|
174
|
+
* decision is due once something is enabled, as before.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* ctx.setWorking(true);
|
|
179
|
+
* const code = await generate();
|
|
180
|
+
* ctx.exposeDecision({ options: [...], choose });
|
|
181
|
+
* ctx.setWorking(false); // the gate is open: decide it, even if nothing can be chosen
|
|
182
|
+
* ```
|
|
121
183
|
*/
|
|
122
|
-
|
|
184
|
+
setWorking(working: boolean): void;
|
|
123
185
|
/**
|
|
124
186
|
* Expose what can be decided here (the short form). Called by the controller: in its constructor
|
|
125
187
|
* for a pure question, or when its gate opens for a widget that works first. Calling again
|
|
@@ -135,9 +197,10 @@ export interface InteractionContext<TState extends object = Record<string, unkno
|
|
|
135
197
|
/** The surface the controller exposed, or `undefined` until it exposes one. */
|
|
136
198
|
readonly surface: InteractionSurface | undefined;
|
|
137
199
|
/**
|
|
138
|
-
* Run `fn` once the surface is ready (see `InteractionSurface.isReady
|
|
139
|
-
* it already is. Readiness is re-checked on
|
|
140
|
-
*
|
|
200
|
+
* Run `fn` once the surface is ready (see `InteractionSurface.isReady`, which honours
|
|
201
|
+
* {@link InteractionContext.setWorking}) — or now if it already is. Readiness is re-checked on
|
|
202
|
+
* every `notify()` (which `setWorking` and both `expose` calls make), so a gate whose guard turns
|
|
203
|
+
* true later fires it then. Never runs after the interaction ends. Returns an unsubscribe.
|
|
141
204
|
*/
|
|
142
205
|
onSurfaceReady(fn: () => void): () => void;
|
|
143
206
|
/**
|
|
@@ -155,10 +218,12 @@ export interface InteractionContext<TState extends object = Record<string, unkno
|
|
|
155
218
|
* widget that only shows information never calls it.
|
|
156
219
|
*
|
|
157
220
|
* Safe to call from anywhere, the controller's constructor included: the platform reports it
|
|
158
|
-
* only once it has decided who holds the interaction, and
|
|
159
|
-
* holds it then or when it is called — the claimant's own hand-back notifies instead
|
|
160
|
-
*
|
|
161
|
-
*
|
|
221
|
+
* only once it has decided who holds the interaction, and holds it back if a claimant (the
|
|
222
|
+
* autopilot) holds it then or when it is called — the claimant's own hand-back notifies instead,
|
|
223
|
+
* with `message` (GENC-1660). An autopilot that may not answer the interaction reports the
|
|
224
|
+
* hand-back in its place too, once the widget waits on the person: the call then only says it
|
|
225
|
+
* does, and gives that one notification its text. Only the first call counts, whatever happened
|
|
226
|
+
* to it; later ones do nothing, as do calls after the interaction ends.
|
|
162
227
|
*
|
|
163
228
|
* @param message - The notification's text for this case. Defaults to the app's
|
|
164
229
|
* `chatConfig.ui.notifications.message`, then to "The assistant is ready for your next input".
|
|
@@ -166,17 +231,63 @@ export interface InteractionContext<TState extends object = Record<string, unkno
|
|
|
166
231
|
requestAttention(message?: string): void;
|
|
167
232
|
/**
|
|
168
233
|
* What is already done, for long work that should survive a reload: the last checkpoint saved,
|
|
169
|
-
* or the one the platform handed over
|
|
170
|
-
*
|
|
171
|
-
*
|
|
234
|
+
* or the one the platform handed over. After a restore, a checkpoint the reload cut waits for a
|
|
235
|
+
* request of the same widget type that the registration's `sameWork` agrees is the same work —
|
|
236
|
+
* offered to each such request in turn, however many other interactions come first, and kept
|
|
237
|
+
* through every refusal — and is handed to the first that agrees. `undefined` for fresh work. See
|
|
238
|
+
* `runSteps`, which reads and writes it for you.
|
|
172
239
|
*/
|
|
173
240
|
readonly checkpoint: TCheckpoint | undefined;
|
|
174
241
|
/**
|
|
175
242
|
* Save a checkpoint into the session snapshot, so a reload does not lose it. Kept as JSON, so it
|
|
176
243
|
* must be storable as JSON; keep it small and hold anything large by reference (a job id, a store
|
|
177
|
-
* key). One per interaction: each save replaces the last.
|
|
178
|
-
*
|
|
244
|
+
* key). One per interaction: each save replaces the last. Never replaces a checkpoint a reload cut
|
|
245
|
+
* that is still waiting for its own widget. Cleared when the interaction settles, and when its
|
|
246
|
+
* flow ends.
|
|
179
247
|
*/
|
|
180
248
|
saveCheckpoint(checkpoint: TCheckpoint): void;
|
|
181
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* What a widget controller needs from whatever hosts it (GENC-1660): the slice of
|
|
252
|
+
* {@link InteractionContext} a controller uses, so it can be built and tested without the rest. An
|
|
253
|
+
* `InteractionContext` is one, so a registration passes its `ctx` straight through:
|
|
254
|
+
*
|
|
255
|
+
* ```ts
|
|
256
|
+
* class ReviewController {
|
|
257
|
+
* constructor(data: ReviewData, private readonly host: ControllerHost<ReviewResult>) {
|
|
258
|
+
* host.exposeSurface?.({ … });
|
|
259
|
+
* }
|
|
260
|
+
* }
|
|
261
|
+
* registerInteraction<ReviewController>('review', {
|
|
262
|
+
* controller: (data, ctx) => new ReviewController(data as ReviewData, ctx),
|
|
263
|
+
* });
|
|
264
|
+
* ```
|
|
265
|
+
*
|
|
266
|
+
* `heldBy`, `exposeDecision` and `exposeSurface` are optional so a view can build the same
|
|
267
|
+
* controller over a stand-in host for a card with no live context (a resolved one in the
|
|
268
|
+
* transcript, a gallery): nobody can claim it, so it has nothing to expose and only the person
|
|
269
|
+
* holds it. Read an absent `heldBy` as `'user'`.
|
|
270
|
+
*
|
|
271
|
+
* `TResult` is the payload type the controller resolves with; `TState` what it keeps on `state`.
|
|
272
|
+
*
|
|
273
|
+
* @beta
|
|
274
|
+
*/
|
|
275
|
+
export interface ControllerHost<TResult = unknown, TState extends object = object> {
|
|
276
|
+
/** Survives a remount; where a controller keeps anything the person has started. */
|
|
277
|
+
readonly state: TState;
|
|
278
|
+
/** Settle the interaction. See {@link InteractionContext.resolve}. */
|
|
279
|
+
resolve(result: InteractionResult<TResult>, options?: InteractionResolveOptions): void;
|
|
280
|
+
/** Something in the controller's state or view model changed. See {@link InteractionContext.notify}. */
|
|
281
|
+
notify(): void;
|
|
282
|
+
/** Who holds the interaction right now: `'user'`, or the claimant's id. Absent means the person. */
|
|
283
|
+
readonly heldBy?: InteractionHolder;
|
|
284
|
+
/** See {@link InteractionContext.exposeDecision}. Absent on a stand-in host. */
|
|
285
|
+
exposeDecision?(decision: DecisionSpec): void;
|
|
286
|
+
/** See {@link InteractionContext.exposeSurface}. Absent on a stand-in host. */
|
|
287
|
+
exposeSurface?(surface: SurfaceSpec): void;
|
|
288
|
+
/** See {@link InteractionContext.setWorking}. Absent on a stand-in host. */
|
|
289
|
+
setWorking?(working: boolean): void;
|
|
290
|
+
/** See {@link InteractionContext.requestAttention}. Absent on a stand-in host. */
|
|
291
|
+
requestAttention?(message?: string): void;
|
|
292
|
+
}
|
|
182
293
|
//# sourceMappingURL=interaction-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interaction-context.d.ts","sourceRoot":"","sources":["../../../src/types/interaction-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE3F;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,kBAAkB,CACjC,MAAM,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/C,WAAW,GAAG,OAAO;IAErB,4DAA4D;IAC5D,QAAQ,CAAC,aAAa,EAAE,MAA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C,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;IAE7C;;;;;;OAMG;IACH,cAAc,CAAC,UAAU,EAAE,WAAW,GAAG,IAAI,CAAC;CAC/C;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,cAAc,CAAC,OAAO,GAAG,OAAO,EAAE,MAAM,SAAS,MAAM,GAAG,MAAM;IAC/E,oFAAoF;IACpF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,sEAAsE;IACtE,OAAO,CAAC,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAC;IACvF,wGAAwG;IACxG,MAAM,IAAI,IAAI,CAAC;IACf,oGAAoG;IACpG,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC;IACpC,gFAAgF;IAChF,cAAc,CAAC,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9C,+EAA+E;IAC/E,aAAa,CAAC,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C,4EAA4E;IAC5E,UAAU,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACpC,kFAAkF;IAClF,gBAAgB,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C"}
|
|
@@ -7,12 +7,26 @@ import type { InvokeResult } from './interaction-surface';
|
|
|
7
7
|
* Every interceptor is offered one, but only the claimant's works: on any other interceptor's
|
|
8
8
|
* handle, and after the interaction ends, its members do nothing and return `false`. A claim is
|
|
9
9
|
* granted only once `onInteractionOpened` has returned `'claim'` (it may yet be refused), so the
|
|
10
|
-
* claimant's own handle does nothing until then either: act on it afterwards.
|
|
10
|
+
* claimant's own handle does nothing until then either: act on it afterwards. An interceptor that
|
|
11
|
+
* declined can still become the claimant later with `claim`, while nobody else is. Views read the
|
|
11
12
|
* result as `ctx.heldBy`; they never change it.
|
|
12
13
|
*
|
|
13
14
|
* @beta
|
|
14
15
|
*/
|
|
15
16
|
export interface InteractionHold {
|
|
17
|
+
/**
|
|
18
|
+
* Claim the interaction after declining it when it opened, as if it had claimed it then: it
|
|
19
|
+
* moves to this interceptor, and the other members work for it from here on. For an interceptor
|
|
20
|
+
* whose reason to decline has gone while the interaction is still open, such as an autopilot
|
|
21
|
+
* that was paused when it opened and has since been resumed.
|
|
22
|
+
*
|
|
23
|
+
* Refused, returning `false` with nothing changed, while the interceptors are still being asked
|
|
24
|
+
* (a claim at open is made by returning `'claim'`), once any interceptor has claimed it — this
|
|
25
|
+
* one included, even if it has since given it to the person, which `set('claimant')` undoes —
|
|
26
|
+
* when it is `userOnly`, and after it has ended. Notifies the context's subscribers and records
|
|
27
|
+
* `interaction.held`, marked `late`.
|
|
28
|
+
*/
|
|
29
|
+
claim(): boolean;
|
|
16
30
|
/**
|
|
17
31
|
* Give the interaction to the person (`'user'`) or back to the claimant (`'claimant'`). Notifies
|
|
18
32
|
* the context's subscribers and records `interaction.held`. Returns whether it applied.
|
|
@@ -35,7 +49,8 @@ export interface InteractionHold {
|
|
|
35
49
|
* Settle the interaction AS the claimant (GENC-1660). The only route that stamps the claimant as
|
|
36
50
|
* `answeredBy`: an answer through the host's `resolveInteraction` — a click — is the person's,
|
|
37
51
|
* whoever held the interaction at the time, so attribution never depends on a view honouring
|
|
38
|
-
* `heldBy`.
|
|
52
|
+
* `heldBy`. The result's `userMessage` is ignored: the person did not say it. Returns `false`,
|
|
53
|
+
* settling nothing, unless this interceptor holds it right now.
|
|
39
54
|
*/
|
|
40
55
|
resolve(result: unknown): boolean;
|
|
41
56
|
/**
|
|
@@ -45,7 +60,8 @@ export interface InteractionHold {
|
|
|
45
60
|
* and `note`, verbatim, as what they were shown about it — so `recordDecision` is not needed.
|
|
46
61
|
*
|
|
47
62
|
* A finishing action settles the interaction AS the claimant, as {@link InteractionHold.resolve}
|
|
48
|
-
* does, so it is stamped `answeredBy` the claimant.
|
|
63
|
+
* does, so it is stamped `answeredBy` the claimant. Its `note` is what the person is shown about
|
|
64
|
+
* the choice; the widget's `userMessage` echo is never shown for a claimant's answer, note or not.
|
|
49
65
|
*
|
|
50
66
|
* Refused, with nothing run, unless this interceptor holds the interaction right now, the
|
|
51
67
|
* surface has that action, it is enabled and `args` fit it. One action runs at a time: a call
|
|
@@ -60,6 +76,28 @@ export interface InteractionHold {
|
|
|
60
76
|
invoke(action: string, args?: unknown, options?: {
|
|
61
77
|
note?: string;
|
|
62
78
|
}): Promise<InvokeResult>;
|
|
79
|
+
/**
|
|
80
|
+
* The message the widget passed to `InteractionContext.requestAttention`, once it has asked with
|
|
81
|
+
* one (GENC-1660). A widget's request is not reported while a claimant holds the interaction, so
|
|
82
|
+
* a claimant that hands it to the person reports with this, and the person reads the widget's
|
|
83
|
+
* own words. Readable by every interceptor, claimant or not: one that declines the interaction
|
|
84
|
+
* reports the hand-back too.
|
|
85
|
+
*/
|
|
86
|
+
attentionMessage(): string | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Report the widget's request for the person's attention in its place (GENC-1660), for an
|
|
89
|
+
* interceptor that leaves the interaction with the person and reports that itself, such as an
|
|
90
|
+
* autopilot handing a widget it may not answer to the person. The widget's
|
|
91
|
+
* `InteractionContext.requestAttention` is then not reported on its own: `onRequest` is called
|
|
92
|
+
* instead, when it would have been, so the interceptor knows the widget is asking and the person
|
|
93
|
+
* gets one notification for the interaction. `attentionMessage` still returns the widget's words.
|
|
94
|
+
*
|
|
95
|
+
* Works for every interceptor, claimant or not, while the interaction is open. Returns the undo,
|
|
96
|
+
* for an interceptor that ends up not reporting after all, or `undefined` when there is nothing to
|
|
97
|
+
* take: the widget's request already counted, the interaction has ended, or another interceptor
|
|
98
|
+
* took it first.
|
|
99
|
+
*/
|
|
100
|
+
takeAttention(onRequest: (message?: string) => void): (() => void) | undefined;
|
|
63
101
|
}
|
|
64
102
|
/**
|
|
65
103
|
* What the working agent is told about an interaction an interceptor answered (GENC-1660): added
|
|
@@ -130,7 +168,10 @@ export interface InteractionOpened {
|
|
|
130
168
|
readonly userOnly: boolean;
|
|
131
169
|
/** The interaction's live context, the same object its widget is handed. */
|
|
132
170
|
readonly ctx: InteractionContext;
|
|
133
|
-
/**
|
|
171
|
+
/**
|
|
172
|
+
* See {@link InteractionHold}. Works only for the interceptor whose claim was granted, at open or
|
|
173
|
+
* later through `claim`.
|
|
174
|
+
*/
|
|
134
175
|
readonly hold: InteractionHold;
|
|
135
176
|
}
|
|
136
177
|
/**
|
|
@@ -139,8 +180,9 @@ export interface InteractionOpened {
|
|
|
139
180
|
* decorator such as an autopilot or a test harness.
|
|
140
181
|
*
|
|
141
182
|
* Interceptors are asked outermost first. The first to claim an interaction holds it; the rest
|
|
142
|
-
* observe — they see the same context but their `hold` does nothing.
|
|
143
|
-
*
|
|
183
|
+
* observe — they see the same context but their `hold` does nothing. When none claims it, any of
|
|
184
|
+
* them may claim it later with `hold.claim`, the first to do so winning. Nobody can claim a
|
|
185
|
+
* `userOnly` interaction. A throwing interceptor is logged and treated as abstaining.
|
|
144
186
|
*
|
|
145
187
|
* @beta
|
|
146
188
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interaction-interceptor.d.ts","sourceRoot":"","sources":["../../../src/types/interaction-interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D
|
|
1
|
+
{"version":3,"file":"interaction-interceptor.d.ts","sourceRoot":"","sources":["../../../src/types/interaction-interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;;;OAWG;I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