@proteos/component-sdk 0.60.0 → 0.75.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/{chunk-HODSL6ER.js → chunk-IYXDPNMJ.js} +2 -2
- package/dist/chunk-IYXDPNMJ.js.map +1 -0
- package/dist/{chunk-3VUWWDED.cjs → chunk-Q7PTW7DD.cjs} +2 -2
- package/dist/chunk-Q7PTW7DD.cjs.map +1 -0
- package/dist/index.cjs +78 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -7
- package/dist/index.d.ts +92 -7
- package/dist/index.js +69 -15
- package/dist/index.js.map +1 -1
- package/dist/protocol.cjs +5 -5
- package/dist/protocol.d.cts +181 -3
- package/dist/protocol.d.ts +181 -3
- package/dist/protocol.js +1 -1
- package/package.json +2 -2
- package/src/context.tsx +116 -16
- package/src/hooks.test.tsx +116 -3
- package/src/hooks.ts +69 -4
- package/src/index.ts +13 -0
- package/src/protocol.ts +178 -0
- package/dist/chunk-3VUWWDED.cjs.map +0 -1
- package/dist/chunk-HODSL6ER.js.map +0 -1
package/dist/protocol.d.cts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { PageAction } from '@proteos/sdk';
|
|
2
|
+
|
|
1
3
|
declare const MESSAGE_SOURCE: "proteos-component-runtime";
|
|
2
4
|
/**
|
|
3
5
|
* z-index the component iframe is promoted to while one of its own overlays
|
|
@@ -28,6 +30,34 @@ interface OverlayRect {
|
|
|
28
30
|
width: number;
|
|
29
31
|
height: number;
|
|
30
32
|
}
|
|
33
|
+
/** What the viewer is doing with the record on the host page.
|
|
34
|
+
*
|
|
35
|
+
* - `view` — a read-only record page, or a page without a record
|
|
36
|
+
* (platform, kiosk, public, previews).
|
|
37
|
+
* - `create` — the form for a record that is not saved yet (`record` holds
|
|
38
|
+
* the seed values only, no `id`).
|
|
39
|
+
* - `edit` — the form over an existing record (`record` is the SAVED row;
|
|
40
|
+
* in-flight edits are not reflected).
|
|
41
|
+
*
|
|
42
|
+
* Inside an action's / workflow's invoke dialog (a trigger page) `mode` is
|
|
43
|
+
* `create` while the person fills the params and `view` once the run is on
|
|
44
|
+
* its way; `phase` says where the run is.
|
|
45
|
+
*
|
|
46
|
+
* A snapshot like `record`: the host remounts the frame when the page
|
|
47
|
+
* switches between view and edit, so a new INIT carries the new mode. Also
|
|
48
|
+
* the Liquid scope key `mode` when props are resolved. */
|
|
49
|
+
type PageMode = 'view' | 'create' | 'edit';
|
|
50
|
+
/** Where an invocation is in the invoke dialog's lifecycle — set only on a
|
|
51
|
+
* trigger page (the dialog of an action / workflow); absent everywhere else.
|
|
52
|
+
*
|
|
53
|
+
* - `input` — the form over the params (`record` = the seeded params).
|
|
54
|
+
* - `running` — the run is in flight (`record` = the submitted params;
|
|
55
|
+
* `params.execution` for a workflow).
|
|
56
|
+
* - `result` — the run ended (`record` = the params plus the action's
|
|
57
|
+
* returns; `params.result` / `params.execution`).
|
|
58
|
+
*
|
|
59
|
+
* Also the Liquid scope key `phase`. */
|
|
60
|
+
type TriggerPhase = 'input' | 'running' | 'result';
|
|
31
61
|
interface PageContext {
|
|
32
62
|
record?: Record<string, unknown>;
|
|
33
63
|
entity?: {
|
|
@@ -35,6 +65,8 @@ interface PageContext {
|
|
|
35
65
|
[key: string]: unknown;
|
|
36
66
|
};
|
|
37
67
|
params?: Record<string, unknown>;
|
|
68
|
+
mode: PageMode;
|
|
69
|
+
phase?: TriggerPhase;
|
|
38
70
|
/** The signed-in viewer (absent on public pages and offline previews). The
|
|
39
71
|
* host resolves `{{ current_user.* }}` and the bare `current_user` prop
|
|
40
72
|
* sentinel against it before posting props. */
|
|
@@ -55,6 +87,21 @@ interface InitMessage {
|
|
|
55
87
|
authToken: string;
|
|
56
88
|
/** API origin the bundle endpoint + SDK calls resolve against. */
|
|
57
89
|
apiBaseUrl: string;
|
|
90
|
+
/** Content hash (hex SHA-256) of the component's deployed bundle, from the
|
|
91
|
+
* component's `bundle_checksum`. The runtime appends it as `?v=` to the
|
|
92
|
+
* bundle request so the server can mark the response immutable — the
|
|
93
|
+
* browser then serves every later mount from its cache without a round
|
|
94
|
+
* trip. Absent when the host does not know it yet (metadata still
|
|
95
|
+
* loading, or a row deployed before checksum stamping); the bundle then
|
|
96
|
+
* revalidates as before. */
|
|
97
|
+
bundleVersion?: string;
|
|
98
|
+
/** Key under which the runtime shares its query cache with sibling and
|
|
99
|
+
* successor frames of the same component through the host (same
|
|
100
|
+
* origin): the host warms a new frame from the last state a frame with
|
|
101
|
+
* this key left behind. Covers the slug AND the resolved props, so two
|
|
102
|
+
* placements configured differently never share. Absent on hosts that
|
|
103
|
+
* do not keep a store (previews, public pages). */
|
|
104
|
+
cacheKey?: string;
|
|
58
105
|
/** Resolved props for the component (Liquid templating happens host-side). */
|
|
59
106
|
props: Record<string, unknown>;
|
|
60
107
|
pageCtx: PageContext;
|
|
@@ -96,7 +143,58 @@ interface ModalClosedMessage {
|
|
|
96
143
|
requestId: string;
|
|
97
144
|
result?: unknown;
|
|
98
145
|
}
|
|
99
|
-
|
|
146
|
+
/** How a RUN_PAGE_ACTION ended, by what the button did:
|
|
147
|
+
*
|
|
148
|
+
* - `done` — the run went through: an action's `returns` (null when it
|
|
149
|
+
* returned none), a workflow's accepted `executionId`, the
|
|
150
|
+
* record an intent created / updated.
|
|
151
|
+
* - `failed` — the invocation failed and the person closed the error.
|
|
152
|
+
* - `cancelled` — the person stepped out before anything ran or saved.
|
|
153
|
+
* - `handed_over` — an `agent` / `link` button: the chat or the tab is open;
|
|
154
|
+
* what happens there is not reported back.
|
|
155
|
+
* - `unavailable` — nothing was opened: `invalid` (the action does not parse),
|
|
156
|
+
* `hidden` (its `visible_when` does not match, an intent
|
|
157
|
+
* has no record to act on, a link no address to open),
|
|
158
|
+
* `busy` (another page action is still open), `unsupported`
|
|
159
|
+
* (a public page, a host without page actions — a preview —
|
|
160
|
+
* or an agent button where there is no agent window). */
|
|
161
|
+
type PageActionOutcome = {
|
|
162
|
+
status: 'done';
|
|
163
|
+
kind: 'action';
|
|
164
|
+
returns: Record<string, unknown> | null;
|
|
165
|
+
} | {
|
|
166
|
+
status: 'done';
|
|
167
|
+
kind: 'workflow';
|
|
168
|
+
executionId: string;
|
|
169
|
+
} | {
|
|
170
|
+
status: 'done';
|
|
171
|
+
kind: 'intent';
|
|
172
|
+
mode: 'create' | 'update';
|
|
173
|
+
entitySlug: string;
|
|
174
|
+
recordId: string;
|
|
175
|
+
title: string;
|
|
176
|
+
} | {
|
|
177
|
+
status: 'failed';
|
|
178
|
+
error: {
|
|
179
|
+
code: string;
|
|
180
|
+
message: string;
|
|
181
|
+
};
|
|
182
|
+
} | {
|
|
183
|
+
status: 'cancelled';
|
|
184
|
+
} | {
|
|
185
|
+
status: 'handed_over';
|
|
186
|
+
kind: 'agent' | 'link';
|
|
187
|
+
} | {
|
|
188
|
+
status: 'unavailable';
|
|
189
|
+
reason: 'invalid' | 'hidden' | 'busy' | 'unsupported';
|
|
190
|
+
};
|
|
191
|
+
/** Resolution of a RUN_PAGE_ACTION request, once the run's flow is over. */
|
|
192
|
+
interface PageActionSettledMessage {
|
|
193
|
+
type: 'PAGE_ACTION_SETTLED';
|
|
194
|
+
requestId: string;
|
|
195
|
+
outcome: PageActionOutcome;
|
|
196
|
+
}
|
|
197
|
+
type HostMessage = InitMessage | AuthRefreshMessage | DataInvalidateMessage | OverlayRectMessage | ModalClosedMessage | PageActionSettledMessage;
|
|
100
198
|
interface ReadyMessage {
|
|
101
199
|
type: 'READY';
|
|
102
200
|
}
|
|
@@ -190,16 +288,96 @@ interface ModalResultMessage {
|
|
|
190
288
|
requestId: string;
|
|
191
289
|
result?: unknown;
|
|
192
290
|
}
|
|
291
|
+
/** Ask the host to open its agent session window (the floating assistant).
|
|
292
|
+
*
|
|
293
|
+
* - `sessionId` set: the window resumes THAT session (its agent is read from
|
|
294
|
+
* the session). A `prompt` is sent into it.
|
|
295
|
+
* - no `sessionId`: a fresh session with `agentKey` (or the agent currently
|
|
296
|
+
* selected in the window); a `prompt` is sent as its first message. With
|
|
297
|
+
* neither field the window just opens as it is.
|
|
298
|
+
*
|
|
299
|
+
* Ignored on public pages (there is no signed-in user to run an agent as). */
|
|
300
|
+
interface OpenAgentWindowMessage {
|
|
301
|
+
type: 'OPEN_AGENT_WINDOW';
|
|
302
|
+
sessionId?: string;
|
|
303
|
+
agentKey?: string;
|
|
304
|
+
prompt?: string;
|
|
305
|
+
/** Model-only context sent with `prompt`; never rendered. */
|
|
306
|
+
context?: string;
|
|
307
|
+
}
|
|
308
|
+
/** Ask the host to minimize its agent session window. The active session and
|
|
309
|
+
* its stream stay alive — reopening resumes it. */
|
|
310
|
+
interface CloseAgentWindowMessage {
|
|
311
|
+
type: 'CLOSE_AGENT_WINDOW';
|
|
312
|
+
}
|
|
313
|
+
/** A record write the component made through its sdk (`data.records.*`)
|
|
314
|
+
* succeeded. Posted by the runtime shell — not by component code — so the
|
|
315
|
+
* host can refresh what it shows of that entity and, when the component
|
|
316
|
+
* sits in a surface that reports edits (the Ava workspace), tell the agent.
|
|
317
|
+
* `patch` is what was submitted, `record` what the server returned. */
|
|
318
|
+
interface RecordWrittenMessage {
|
|
319
|
+
type: 'RECORD_WRITTEN';
|
|
320
|
+
entitySlug: string;
|
|
321
|
+
operation: 'create' | 'update' | 'delete' | 'batch_upsert';
|
|
322
|
+
recordId?: string;
|
|
323
|
+
patch?: Record<string, unknown>;
|
|
324
|
+
record?: Record<string, unknown>;
|
|
325
|
+
/** Rows in a batch upsert. */
|
|
326
|
+
count?: number;
|
|
327
|
+
}
|
|
328
|
+
/** A record a page action acts on, as the component names it. */
|
|
329
|
+
interface PageActionRecord {
|
|
330
|
+
entitySlug: string;
|
|
331
|
+
recordId: string;
|
|
332
|
+
/** Shown when the person picks among several records for an intent. */
|
|
333
|
+
title?: string;
|
|
334
|
+
/** The entity's display name, shown beside `title` in that pick. */
|
|
335
|
+
entityName?: string;
|
|
336
|
+
}
|
|
337
|
+
/** What the component knows that the button needs — layered over what the
|
|
338
|
+
* host already knows about the page. */
|
|
339
|
+
interface PageActionContext {
|
|
340
|
+
/** Merged over the page scope (`record`, `entity`, `params`, `mode`,
|
|
341
|
+
* `current_user`) the action's Liquid templates render against — `params`
|
|
342
|
+
* / `inputs` prefill, `prompt`, `context`, `entity`, `record`, `url`.
|
|
343
|
+
* Shallow: a key given here replaces the page's. `current_user` is always
|
|
344
|
+
* the host's. */
|
|
345
|
+
scope?: Record<string, unknown>;
|
|
346
|
+
/** The records the button acts on. Default: the page record (none on a page
|
|
347
|
+
* without one).
|
|
348
|
+
*
|
|
349
|
+
* - `action` with entity scope — the one record it is invoked on.
|
|
350
|
+
* - `action` with entity_batch scope — every record, in ONE invocation.
|
|
351
|
+
* - `intent` `update_record` without a `record` — the records of the
|
|
352
|
+
* intent's entity it may update: one is updated, several are offered
|
|
353
|
+
* to pick from. */
|
|
354
|
+
records?: PageActionRecord[];
|
|
355
|
+
}
|
|
356
|
+
/** Ask the host to run a page action — the same button a page or list toolbar
|
|
357
|
+
* carries, defined inline by the component. The host dispatches it exactly
|
|
358
|
+
* as a toolbar press (invoke dialog, record proposal review, agent window,
|
|
359
|
+
* new tab) and answers PAGE_ACTION_SETTLED with the same `requestId` once
|
|
360
|
+
* the flow is over.
|
|
361
|
+
*
|
|
362
|
+
* One page action at a time: while one is open (from any component) the
|
|
363
|
+
* host answers further requests `unavailable: busy`. */
|
|
364
|
+
interface RunPageActionMessage {
|
|
365
|
+
type: 'RUN_PAGE_ACTION';
|
|
366
|
+
/** Correlates the eventual PAGE_ACTION_SETTLED. Generated by the runtime. */
|
|
367
|
+
requestId: string;
|
|
368
|
+
action: PageAction;
|
|
369
|
+
context?: PageActionContext;
|
|
370
|
+
}
|
|
193
371
|
interface ErrorMessage {
|
|
194
372
|
type: 'ERROR';
|
|
195
373
|
message: string;
|
|
196
374
|
stack?: string;
|
|
197
375
|
}
|
|
198
|
-
type RuntimeMessage = ReadyMessage | ResizeMessage | NavigateMessage | OpenPeekMessage | OpenCallMessage | OverlayStateMessage | OpenModalMessage | ModalResultMessage | EscapePressedMessage | ErrorMessage;
|
|
376
|
+
type RuntimeMessage = ReadyMessage | ResizeMessage | NavigateMessage | OpenPeekMessage | OpenCallMessage | OverlayStateMessage | OpenModalMessage | ModalResultMessage | EscapePressedMessage | OpenAgentWindowMessage | CloseAgentWindowMessage | RecordWrittenMessage | RunPageActionMessage | ErrorMessage;
|
|
199
377
|
type Envelope<T> = T & {
|
|
200
378
|
source: typeof MESSAGE_SOURCE;
|
|
201
379
|
};
|
|
202
380
|
declare function isHostMessage(data: unknown): data is Envelope<HostMessage>;
|
|
203
381
|
declare function isRuntimeMessage(data: unknown): data is Envelope<RuntimeMessage>;
|
|
204
382
|
|
|
205
|
-
export { type AuthRefreshMessage, COMPONENT_OVERLAY_Z_INDEX, type DataInvalidateMessage, type Envelope, type ErrorMessage, type EscapePressedMessage, type HostMessage, type InitMessage, MESSAGE_SOURCE, type ModalClosedMessage, type ModalResultMessage, type ModalWidth, type NavigateMessage, type OpenCallMessage, type OpenModalMessage, type OpenPeekMessage, type OverlayRect, type OverlayRectMessage, type OverlayStateMessage, type PageContext, type ReadyMessage, type ResizeMessage, type RuntimeMessage, isHostMessage, isRuntimeMessage };
|
|
383
|
+
export { type AuthRefreshMessage, COMPONENT_OVERLAY_Z_INDEX, type CloseAgentWindowMessage, type DataInvalidateMessage, type Envelope, type ErrorMessage, type EscapePressedMessage, type HostMessage, type InitMessage, MESSAGE_SOURCE, type ModalClosedMessage, type ModalResultMessage, type ModalWidth, type NavigateMessage, type OpenAgentWindowMessage, type OpenCallMessage, type OpenModalMessage, type OpenPeekMessage, type OverlayRect, type OverlayRectMessage, type OverlayStateMessage, type PageActionContext, type PageActionOutcome, type PageActionRecord, type PageActionSettledMessage, type PageContext, type PageMode, type ReadyMessage, type RecordWrittenMessage, type ResizeMessage, type RunPageActionMessage, type RuntimeMessage, type TriggerPhase, isHostMessage, isRuntimeMessage };
|
package/dist/protocol.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { PageAction } from '@proteos/sdk';
|
|
2
|
+
|
|
1
3
|
declare const MESSAGE_SOURCE: "proteos-component-runtime";
|
|
2
4
|
/**
|
|
3
5
|
* z-index the component iframe is promoted to while one of its own overlays
|
|
@@ -28,6 +30,34 @@ interface OverlayRect {
|
|
|
28
30
|
width: number;
|
|
29
31
|
height: number;
|
|
30
32
|
}
|
|
33
|
+
/** What the viewer is doing with the record on the host page.
|
|
34
|
+
*
|
|
35
|
+
* - `view` — a read-only record page, or a page without a record
|
|
36
|
+
* (platform, kiosk, public, previews).
|
|
37
|
+
* - `create` — the form for a record that is not saved yet (`record` holds
|
|
38
|
+
* the seed values only, no `id`).
|
|
39
|
+
* - `edit` — the form over an existing record (`record` is the SAVED row;
|
|
40
|
+
* in-flight edits are not reflected).
|
|
41
|
+
*
|
|
42
|
+
* Inside an action's / workflow's invoke dialog (a trigger page) `mode` is
|
|
43
|
+
* `create` while the person fills the params and `view` once the run is on
|
|
44
|
+
* its way; `phase` says where the run is.
|
|
45
|
+
*
|
|
46
|
+
* A snapshot like `record`: the host remounts the frame when the page
|
|
47
|
+
* switches between view and edit, so a new INIT carries the new mode. Also
|
|
48
|
+
* the Liquid scope key `mode` when props are resolved. */
|
|
49
|
+
type PageMode = 'view' | 'create' | 'edit';
|
|
50
|
+
/** Where an invocation is in the invoke dialog's lifecycle — set only on a
|
|
51
|
+
* trigger page (the dialog of an action / workflow); absent everywhere else.
|
|
52
|
+
*
|
|
53
|
+
* - `input` — the form over the params (`record` = the seeded params).
|
|
54
|
+
* - `running` — the run is in flight (`record` = the submitted params;
|
|
55
|
+
* `params.execution` for a workflow).
|
|
56
|
+
* - `result` — the run ended (`record` = the params plus the action's
|
|
57
|
+
* returns; `params.result` / `params.execution`).
|
|
58
|
+
*
|
|
59
|
+
* Also the Liquid scope key `phase`. */
|
|
60
|
+
type TriggerPhase = 'input' | 'running' | 'result';
|
|
31
61
|
interface PageContext {
|
|
32
62
|
record?: Record<string, unknown>;
|
|
33
63
|
entity?: {
|
|
@@ -35,6 +65,8 @@ interface PageContext {
|
|
|
35
65
|
[key: string]: unknown;
|
|
36
66
|
};
|
|
37
67
|
params?: Record<string, unknown>;
|
|
68
|
+
mode: PageMode;
|
|
69
|
+
phase?: TriggerPhase;
|
|
38
70
|
/** The signed-in viewer (absent on public pages and offline previews). The
|
|
39
71
|
* host resolves `{{ current_user.* }}` and the bare `current_user` prop
|
|
40
72
|
* sentinel against it before posting props. */
|
|
@@ -55,6 +87,21 @@ interface InitMessage {
|
|
|
55
87
|
authToken: string;
|
|
56
88
|
/** API origin the bundle endpoint + SDK calls resolve against. */
|
|
57
89
|
apiBaseUrl: string;
|
|
90
|
+
/** Content hash (hex SHA-256) of the component's deployed bundle, from the
|
|
91
|
+
* component's `bundle_checksum`. The runtime appends it as `?v=` to the
|
|
92
|
+
* bundle request so the server can mark the response immutable — the
|
|
93
|
+
* browser then serves every later mount from its cache without a round
|
|
94
|
+
* trip. Absent when the host does not know it yet (metadata still
|
|
95
|
+
* loading, or a row deployed before checksum stamping); the bundle then
|
|
96
|
+
* revalidates as before. */
|
|
97
|
+
bundleVersion?: string;
|
|
98
|
+
/** Key under which the runtime shares its query cache with sibling and
|
|
99
|
+
* successor frames of the same component through the host (same
|
|
100
|
+
* origin): the host warms a new frame from the last state a frame with
|
|
101
|
+
* this key left behind. Covers the slug AND the resolved props, so two
|
|
102
|
+
* placements configured differently never share. Absent on hosts that
|
|
103
|
+
* do not keep a store (previews, public pages). */
|
|
104
|
+
cacheKey?: string;
|
|
58
105
|
/** Resolved props for the component (Liquid templating happens host-side). */
|
|
59
106
|
props: Record<string, unknown>;
|
|
60
107
|
pageCtx: PageContext;
|
|
@@ -96,7 +143,58 @@ interface ModalClosedMessage {
|
|
|
96
143
|
requestId: string;
|
|
97
144
|
result?: unknown;
|
|
98
145
|
}
|
|
99
|
-
|
|
146
|
+
/** How a RUN_PAGE_ACTION ended, by what the button did:
|
|
147
|
+
*
|
|
148
|
+
* - `done` — the run went through: an action's `returns` (null when it
|
|
149
|
+
* returned none), a workflow's accepted `executionId`, the
|
|
150
|
+
* record an intent created / updated.
|
|
151
|
+
* - `failed` — the invocation failed and the person closed the error.
|
|
152
|
+
* - `cancelled` — the person stepped out before anything ran or saved.
|
|
153
|
+
* - `handed_over` — an `agent` / `link` button: the chat or the tab is open;
|
|
154
|
+
* what happens there is not reported back.
|
|
155
|
+
* - `unavailable` — nothing was opened: `invalid` (the action does not parse),
|
|
156
|
+
* `hidden` (its `visible_when` does not match, an intent
|
|
157
|
+
* has no record to act on, a link no address to open),
|
|
158
|
+
* `busy` (another page action is still open), `unsupported`
|
|
159
|
+
* (a public page, a host without page actions — a preview —
|
|
160
|
+
* or an agent button where there is no agent window). */
|
|
161
|
+
type PageActionOutcome = {
|
|
162
|
+
status: 'done';
|
|
163
|
+
kind: 'action';
|
|
164
|
+
returns: Record<string, unknown> | null;
|
|
165
|
+
} | {
|
|
166
|
+
status: 'done';
|
|
167
|
+
kind: 'workflow';
|
|
168
|
+
executionId: string;
|
|
169
|
+
} | {
|
|
170
|
+
status: 'done';
|
|
171
|
+
kind: 'intent';
|
|
172
|
+
mode: 'create' | 'update';
|
|
173
|
+
entitySlug: string;
|
|
174
|
+
recordId: string;
|
|
175
|
+
title: string;
|
|
176
|
+
} | {
|
|
177
|
+
status: 'failed';
|
|
178
|
+
error: {
|
|
179
|
+
code: string;
|
|
180
|
+
message: string;
|
|
181
|
+
};
|
|
182
|
+
} | {
|
|
183
|
+
status: 'cancelled';
|
|
184
|
+
} | {
|
|
185
|
+
status: 'handed_over';
|
|
186
|
+
kind: 'agent' | 'link';
|
|
187
|
+
} | {
|
|
188
|
+
status: 'unavailable';
|
|
189
|
+
reason: 'invalid' | 'hidden' | 'busy' | 'unsupported';
|
|
190
|
+
};
|
|
191
|
+
/** Resolution of a RUN_PAGE_ACTION request, once the run's flow is over. */
|
|
192
|
+
interface PageActionSettledMessage {
|
|
193
|
+
type: 'PAGE_ACTION_SETTLED';
|
|
194
|
+
requestId: string;
|
|
195
|
+
outcome: PageActionOutcome;
|
|
196
|
+
}
|
|
197
|
+
type HostMessage = InitMessage | AuthRefreshMessage | DataInvalidateMessage | OverlayRectMessage | ModalClosedMessage | PageActionSettledMessage;
|
|
100
198
|
interface ReadyMessage {
|
|
101
199
|
type: 'READY';
|
|
102
200
|
}
|
|
@@ -190,16 +288,96 @@ interface ModalResultMessage {
|
|
|
190
288
|
requestId: string;
|
|
191
289
|
result?: unknown;
|
|
192
290
|
}
|
|
291
|
+
/** Ask the host to open its agent session window (the floating assistant).
|
|
292
|
+
*
|
|
293
|
+
* - `sessionId` set: the window resumes THAT session (its agent is read from
|
|
294
|
+
* the session). A `prompt` is sent into it.
|
|
295
|
+
* - no `sessionId`: a fresh session with `agentKey` (or the agent currently
|
|
296
|
+
* selected in the window); a `prompt` is sent as its first message. With
|
|
297
|
+
* neither field the window just opens as it is.
|
|
298
|
+
*
|
|
299
|
+
* Ignored on public pages (there is no signed-in user to run an agent as). */
|
|
300
|
+
interface OpenAgentWindowMessage {
|
|
301
|
+
type: 'OPEN_AGENT_WINDOW';
|
|
302
|
+
sessionId?: string;
|
|
303
|
+
agentKey?: string;
|
|
304
|
+
prompt?: string;
|
|
305
|
+
/** Model-only context sent with `prompt`; never rendered. */
|
|
306
|
+
context?: string;
|
|
307
|
+
}
|
|
308
|
+
/** Ask the host to minimize its agent session window. The active session and
|
|
309
|
+
* its stream stay alive — reopening resumes it. */
|
|
310
|
+
interface CloseAgentWindowMessage {
|
|
311
|
+
type: 'CLOSE_AGENT_WINDOW';
|
|
312
|
+
}
|
|
313
|
+
/** A record write the component made through its sdk (`data.records.*`)
|
|
314
|
+
* succeeded. Posted by the runtime shell — not by component code — so the
|
|
315
|
+
* host can refresh what it shows of that entity and, when the component
|
|
316
|
+
* sits in a surface that reports edits (the Ava workspace), tell the agent.
|
|
317
|
+
* `patch` is what was submitted, `record` what the server returned. */
|
|
318
|
+
interface RecordWrittenMessage {
|
|
319
|
+
type: 'RECORD_WRITTEN';
|
|
320
|
+
entitySlug: string;
|
|
321
|
+
operation: 'create' | 'update' | 'delete' | 'batch_upsert';
|
|
322
|
+
recordId?: string;
|
|
323
|
+
patch?: Record<string, unknown>;
|
|
324
|
+
record?: Record<string, unknown>;
|
|
325
|
+
/** Rows in a batch upsert. */
|
|
326
|
+
count?: number;
|
|
327
|
+
}
|
|
328
|
+
/** A record a page action acts on, as the component names it. */
|
|
329
|
+
interface PageActionRecord {
|
|
330
|
+
entitySlug: string;
|
|
331
|
+
recordId: string;
|
|
332
|
+
/** Shown when the person picks among several records for an intent. */
|
|
333
|
+
title?: string;
|
|
334
|
+
/** The entity's display name, shown beside `title` in that pick. */
|
|
335
|
+
entityName?: string;
|
|
336
|
+
}
|
|
337
|
+
/** What the component knows that the button needs — layered over what the
|
|
338
|
+
* host already knows about the page. */
|
|
339
|
+
interface PageActionContext {
|
|
340
|
+
/** Merged over the page scope (`record`, `entity`, `params`, `mode`,
|
|
341
|
+
* `current_user`) the action's Liquid templates render against — `params`
|
|
342
|
+
* / `inputs` prefill, `prompt`, `context`, `entity`, `record`, `url`.
|
|
343
|
+
* Shallow: a key given here replaces the page's. `current_user` is always
|
|
344
|
+
* the host's. */
|
|
345
|
+
scope?: Record<string, unknown>;
|
|
346
|
+
/** The records the button acts on. Default: the page record (none on a page
|
|
347
|
+
* without one).
|
|
348
|
+
*
|
|
349
|
+
* - `action` with entity scope — the one record it is invoked on.
|
|
350
|
+
* - `action` with entity_batch scope — every record, in ONE invocation.
|
|
351
|
+
* - `intent` `update_record` without a `record` — the records of the
|
|
352
|
+
* intent's entity it may update: one is updated, several are offered
|
|
353
|
+
* to pick from. */
|
|
354
|
+
records?: PageActionRecord[];
|
|
355
|
+
}
|
|
356
|
+
/** Ask the host to run a page action — the same button a page or list toolbar
|
|
357
|
+
* carries, defined inline by the component. The host dispatches it exactly
|
|
358
|
+
* as a toolbar press (invoke dialog, record proposal review, agent window,
|
|
359
|
+
* new tab) and answers PAGE_ACTION_SETTLED with the same `requestId` once
|
|
360
|
+
* the flow is over.
|
|
361
|
+
*
|
|
362
|
+
* One page action at a time: while one is open (from any component) the
|
|
363
|
+
* host answers further requests `unavailable: busy`. */
|
|
364
|
+
interface RunPageActionMessage {
|
|
365
|
+
type: 'RUN_PAGE_ACTION';
|
|
366
|
+
/** Correlates the eventual PAGE_ACTION_SETTLED. Generated by the runtime. */
|
|
367
|
+
requestId: string;
|
|
368
|
+
action: PageAction;
|
|
369
|
+
context?: PageActionContext;
|
|
370
|
+
}
|
|
193
371
|
interface ErrorMessage {
|
|
194
372
|
type: 'ERROR';
|
|
195
373
|
message: string;
|
|
196
374
|
stack?: string;
|
|
197
375
|
}
|
|
198
|
-
type RuntimeMessage = ReadyMessage | ResizeMessage | NavigateMessage | OpenPeekMessage | OpenCallMessage | OverlayStateMessage | OpenModalMessage | ModalResultMessage | EscapePressedMessage | ErrorMessage;
|
|
376
|
+
type RuntimeMessage = ReadyMessage | ResizeMessage | NavigateMessage | OpenPeekMessage | OpenCallMessage | OverlayStateMessage | OpenModalMessage | ModalResultMessage | EscapePressedMessage | OpenAgentWindowMessage | CloseAgentWindowMessage | RecordWrittenMessage | RunPageActionMessage | ErrorMessage;
|
|
199
377
|
type Envelope<T> = T & {
|
|
200
378
|
source: typeof MESSAGE_SOURCE;
|
|
201
379
|
};
|
|
202
380
|
declare function isHostMessage(data: unknown): data is Envelope<HostMessage>;
|
|
203
381
|
declare function isRuntimeMessage(data: unknown): data is Envelope<RuntimeMessage>;
|
|
204
382
|
|
|
205
|
-
export { type AuthRefreshMessage, COMPONENT_OVERLAY_Z_INDEX, type DataInvalidateMessage, type Envelope, type ErrorMessage, type EscapePressedMessage, type HostMessage, type InitMessage, MESSAGE_SOURCE, type ModalClosedMessage, type ModalResultMessage, type ModalWidth, type NavigateMessage, type OpenCallMessage, type OpenModalMessage, type OpenPeekMessage, type OverlayRect, type OverlayRectMessage, type OverlayStateMessage, type PageContext, type ReadyMessage, type ResizeMessage, type RuntimeMessage, isHostMessage, isRuntimeMessage };
|
|
383
|
+
export { type AuthRefreshMessage, COMPONENT_OVERLAY_Z_INDEX, type CloseAgentWindowMessage, type DataInvalidateMessage, type Envelope, type ErrorMessage, type EscapePressedMessage, type HostMessage, type InitMessage, MESSAGE_SOURCE, type ModalClosedMessage, type ModalResultMessage, type ModalWidth, type NavigateMessage, type OpenAgentWindowMessage, type OpenCallMessage, type OpenModalMessage, type OpenPeekMessage, type OverlayRect, type OverlayRectMessage, type OverlayStateMessage, type PageActionContext, type PageActionOutcome, type PageActionRecord, type PageActionSettledMessage, type PageContext, type PageMode, type ReadyMessage, type RecordWrittenMessage, type ResizeMessage, type RunPageActionMessage, type RuntimeMessage, type TriggerPhase, isHostMessage, isRuntimeMessage };
|
package/dist/protocol.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { COMPONENT_OVERLAY_Z_INDEX, MESSAGE_SOURCE, isHostMessage, isRuntimeMessage } from './chunk-
|
|
1
|
+
export { COMPONENT_OVERLAY_Z_INDEX, MESSAGE_SOURCE, isHostMessage, isRuntimeMessage } from './chunk-IYXDPNMJ.js';
|
|
2
2
|
//# sourceMappingURL=protocol.js.map
|
|
3
3
|
//# sourceMappingURL=protocol.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proteos/component-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.75.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Typed runtime hooks for authoring Proteos custom components — the SDK you import inside a component bundle.",
|
|
6
6
|
"repository": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"src"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@proteos/sdk": "^0.
|
|
45
|
+
"@proteos/sdk": "^0.75.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@tanstack/react-query": ">=5.0.0",
|