@pingroom/sdk 0.1.0 → 0.3.1

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.
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Live Activity template builders for the PingRoom agent SDK.
3
+ *
4
+ * IMPORTANT — these builders do NOT start an activity. The server starts,
5
+ * updates, and ends Live Activities only from a **live-status stream**: a
6
+ * `live_status` object sent either to a room's incoming webhook or to the agent
7
+ * route (see https://pingroom.io/liveactivities.md). A `live_activity` block
8
+ * placed in a `broadcast()` / `ping()` `data` object is carried as opaque
9
+ * structured data — clients only honor the server-built, top-level
10
+ * `live_activity` push block.
11
+ *
12
+ * These builders produce that `{ attributes, content_state }` block in the
13
+ * frozen native shape (mobile/modules/live-activity/src/LiveActivity.types.ts,
14
+ * LIVE_ACTIVITY_TEMPLATES.md). Use them when you need the native contract —
15
+ * e.g. constructing expected payloads in tests or tooling that speaks the
16
+ * push-layer shape.
17
+ *
18
+ * To actually drive a Live Activity, use `liveStatus.*` + `pr.live.push()`
19
+ * (agent credential, `pingroom:live:write`) or `sendIncomingWebhook()`.
20
+ */
21
+ function build(template, id, state) {
22
+ const { title, message, status, accentOverride, ...rest } = state;
23
+ return {
24
+ live_activity: {
25
+ attributes: {
26
+ kind: id.kind ?? 'agent',
27
+ template,
28
+ roomCode: id.roomCode,
29
+ roomName: id.roomName,
30
+ roomColor: id.roomColor,
31
+ ...(id.roomIconSvg ? { roomIconSvg: id.roomIconSvg } : {}),
32
+ ...(id.correlationId ? { correlationId: id.correlationId } : {}),
33
+ ...(id.agentId ? { agentId: id.agentId } : {}),
34
+ },
35
+ content_state: {
36
+ status: status ?? 'open',
37
+ title,
38
+ message: message ?? '',
39
+ ...(accentOverride ? { accentOverride } : {}),
40
+ ...rest,
41
+ updatedAt: Math.floor(Date.now() / 1000),
42
+ },
43
+ },
44
+ };
45
+ }
46
+ export const liveActivity = {
47
+ /** Single hero line + status dot; optional live ETA (`etaAt`, epoch seconds). */
48
+ status(input) {
49
+ const { roomCode, roomName, roomColor, roomIconSvg, correlationId, agentId, kind, ...state } = input;
50
+ return build('status', { roomCode, roomName, roomColor, roomIconSvg, correlationId, agentId, kind }, state);
51
+ },
52
+ /** Checkpoint rail — the understand → plan → doc pattern. */
53
+ steps(input) {
54
+ const { roomCode, roomName, roomColor, roomIconSvg, correlationId, agentId, kind, ...state } = input;
55
+ return build('steps', { roomCode, roomName, roomColor, roomIconSvg, correlationId, agentId, kind }, state);
56
+ },
57
+ /** Determinate progress bar (0..1), optional `etaAt` countdown. */
58
+ progress(input) {
59
+ const { roomCode, roomName, roomColor, roomIconSvg, correlationId, agentId, kind, ...state } = input;
60
+ return build('progress', { roomCode, roomName, roomColor, roomIconSvg, correlationId, agentId, kind }, state);
61
+ },
62
+ /** Up to 3 live counters. */
63
+ metrics(input) {
64
+ const { roomCode, roomName, roomColor, roomIconSvg, correlationId, agentId, kind, ...state } = input;
65
+ return build('metrics', { roomCode, roomName, roomColor, roomIconSvg, correlationId, agentId, kind }, state);
66
+ },
67
+ /** Big timer counting down to `deadlineAt` (epoch seconds). */
68
+ countdown(input) {
69
+ const { roomCode, roomName, roomColor, roomIconSvg, correlationId, agentId, kind, ...state } = input;
70
+ return build('countdown', { roomCode, roomName, roomColor, roomIconSvg, correlationId, agentId, kind }, state);
71
+ },
72
+ /** Lock-screen ask: prompt + up to 4 options; `deadlineAt` shows time-left. */
73
+ question(input) {
74
+ const { roomCode, roomName, roomColor, roomIconSvg, correlationId, agentId, kind, ...state } = input;
75
+ return build('question', { roomCode, roomName, roomColor, roomIconSvg, correlationId, agentId, kind }, state);
76
+ },
77
+ /** Head-to-head: left · center · right. */
78
+ matchup(input) {
79
+ const { roomCode, roomName, roomColor, roomIconSvg, correlationId, agentId, kind, ...state } = input;
80
+ return build('matchup', { roomCode, roomName, roomColor, roomIconSvg, correlationId, agentId, kind }, state);
81
+ },
82
+ };
83
+ //# sourceMappingURL=liveActivity.js.map
@@ -0,0 +1 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-0,0 +1,168 @@
1
+ /**
2
+ * Live-status streams — the wire contract for driving a Live Activity.
3
+ *
4
+ * A stream is keyed by `correlation_id`: the first ping starts a live card on
5
+ * every room member's lock screen (one alert), further `running` pings move it
6
+ * silently, and the first `done`/`failed` sends one completion alert and ends
7
+ * it. See https://pingroom.io/liveactivities.md.
8
+ *
9
+ * Three producers speak this contract. This SDK reaches the two machine ones:
10
+ * - a room's **incoming webhook** (Pro) — `sendIncomingWebhook()`
11
+ * - an **agent credential** — `pr.live.*` (needs `pingroom:live:write`)
12
+ *
13
+ * The third is a signed-in person driving a stream from the app composer over
14
+ * `POST /api/rooms/{inviteCode}/live` with their own Human JWT. It sends this
15
+ * same body minus `live_status.agent_id` (stripped server-side), so these
16
+ * builders describe it too — but it is not an agent route and has no client
17
+ * here.
18
+ *
19
+ * Not to be confused with `liveActivity.*` in ./liveActivity.ts, which builds
20
+ * the frozen *native* `{ attributes, content_state }` push shape for tests and
21
+ * tooling. These builders produce the `live_status` object you actually send.
22
+ */
23
+ import type { LiveActivityTemplate } from './liveActivity.js';
24
+ export type LiveStatusState = 'running' | 'done' | 'failed';
25
+ /** Legacy rendering category. Prefer `template`; `alert` selects urgent styling. */
26
+ export type LiveStatusCategory = 'status' | 'steps' | 'alert';
27
+ export interface LiveStatusMetric {
28
+ label: string;
29
+ value: string;
30
+ }
31
+ export interface LiveStatusOption {
32
+ value: string;
33
+ label: string;
34
+ }
35
+ export interface LiveStatusSide {
36
+ label: string;
37
+ value: string;
38
+ iconSvg?: string;
39
+ }
40
+ /**
41
+ * The `live_status` object. Only `state` is required; every other field is read
42
+ * by the template you selected.
43
+ *
44
+ * `template` and `steps` are fixed at stream creation — a later ping cannot
45
+ * re-template a running card. Content set at creation is sticky, so a sparse
46
+ * update carrying just `progress` keeps rendering the full template. The
47
+ * terminal leg is sticky too: `{ state: 'done' }` alone keeps the scoreboard,
48
+ * metrics grid, deadline and accent on the final frame.
49
+ */
50
+ export interface LiveStatus {
51
+ state: LiveStatusState;
52
+ template?: LiveActivityTemplate;
53
+ category?: LiveStatusCategory;
54
+ message?: string;
55
+ /** 0..1 — the progress bar / Dynamic Island gauge. */
56
+ progress?: number;
57
+ /** 2–8 labels. Required on the first ping of a `steps` stream; immutable after. */
58
+ steps?: string[];
59
+ /** Index into `steps`; the only mutable steps field. */
60
+ current_step?: number;
61
+ /** Up to 3 counters, for the `metrics` template. */
62
+ metrics?: LiveStatusMetric[];
63
+ /** Epoch seconds the `countdown` template counts down to. */
64
+ deadline_at?: number;
65
+ /** Epoch seconds; renders a live ETA on `status`/`progress`. */
66
+ eta_at?: number;
67
+ /** The ask, for the `question` template. */
68
+ prompt?: string;
69
+ /** Up to 4 choices, for the `question` template. */
70
+ options?: LiveStatusOption[];
71
+ left?: LiveStatusSide;
72
+ right?: LiveStatusSide;
73
+ center?: string;
74
+ /** Hex `#rrggbb` — a semantic accent for one frame (e.g. deadline red). */
75
+ accent_override?: string;
76
+ agent_id?: string;
77
+ }
78
+ /** The full body of a live-status ping. */
79
+ export interface LiveStatusPing {
80
+ correlation_id: string;
81
+ live_status: LiveStatus;
82
+ title?: string;
83
+ /** Quick-action slot 1–4 supplying the icon and sound. */
84
+ action?: number;
85
+ data?: Record<string, unknown>;
86
+ requires_ack?: boolean;
87
+ ack_timeout_seconds?: number;
88
+ }
89
+ export interface LiveStatusResult {
90
+ notification_id: string;
91
+ correlation_id: string;
92
+ /** `started` on creation, then `running` / `done` / `failed`. */
93
+ state: string;
94
+ idempotent: boolean;
95
+ action_state?: unknown;
96
+ }
97
+ /**
98
+ * The read-back shape from `GET .../live/{correlationId}`.
99
+ *
100
+ * EVERY stored `live_status` field is returned, not a step/progress subset — a
101
+ * `matchup` / `metrics` / `countdown` / `question` stream would otherwise be
102
+ * unresumable after a producer restart. Fields you never set come back as
103
+ * `null` rather than being omitted, so read them defensively.
104
+ *
105
+ * The server-side ownership stamps (`_webhook` / `_agent` / `_user`) are
106
+ * deliberately NOT returned — they are the authorization record, not client
107
+ * state.
108
+ */
109
+ export interface LiveStatusSnapshot {
110
+ notification_id: string;
111
+ correlation_id: string;
112
+ state: string | null;
113
+ progress: number | null;
114
+ message: string | null;
115
+ category: LiveStatusCategory | null;
116
+ template: LiveActivityTemplate | null;
117
+ agent_id: string | null;
118
+ accent_override: string | null;
119
+ eta_at: number | null;
120
+ deadline_at: number | null;
121
+ metrics: LiveStatusMetric[] | null;
122
+ prompt: string | null;
123
+ options: LiveStatusOption[] | null;
124
+ left: LiveStatusSide | null;
125
+ right: LiveStatusSide | null;
126
+ center: string | null;
127
+ steps: string[] | null;
128
+ current_step: number | null;
129
+ action_state?: unknown;
130
+ updated_at: string | null;
131
+ }
132
+ type Rest = Omit<LiveStatusPing, 'correlation_id' | 'live_status'>;
133
+ /**
134
+ * Builders for the common stream shapes. Each returns a body you can hand to
135
+ * `pr.live.push()` or `sendIncomingWebhook()`.
136
+ */
137
+ export declare const liveStatus: {
138
+ /** Default template: a title line plus a status dot, with optional progress. */
139
+ status(correlationId: string, live: Omit<LiveStatus, "template">, rest?: Rest): LiveStatusPing;
140
+ /** A segmented step tracker. `steps` is required on the first ping. */
141
+ steps(correlationId: string, live: Omit<LiveStatus, "template">, rest?: Rest): LiveStatusPing;
142
+ /** A determinate progress bar with an optional live ETA. */
143
+ progress(correlationId: string, live: Omit<LiveStatus, "template">, rest?: Rest): LiveStatusPing;
144
+ /** Up to 3 labelled counters. */
145
+ metrics(correlationId: string, live: Omit<LiveStatus, "template">, rest?: Rest): LiveStatusPing;
146
+ /** A large live timer counting down to `deadline_at`. */
147
+ countdown(correlationId: string, live: Omit<LiveStatus, "template">, rest?: Rest): LiveStatusPing;
148
+ /** A prompt with up to 4 options shown on the lock screen. */
149
+ question(correlationId: string, live: Omit<LiveStatus, "template">, rest?: Rest): LiveStatusPing;
150
+ /** Two sides plus a center score/clock. */
151
+ matchup(correlationId: string, live: Omit<LiveStatus, "template">, rest?: Rest): LiveStatusPing;
152
+ /**
153
+ * An urgent stream, delivered time-sensitive from the start so it breaks
154
+ * through Focus.
155
+ *
156
+ * This is a `category`, not a `template`: `alert` has no template equivalent,
157
+ * and it is the only way to start time-sensitive WITHOUT also setting
158
+ * `requires_ack` (which demands somebody tap). Fixed at creation, like
159
+ * `template`.
160
+ */
161
+ alert(correlationId: string, live: Omit<LiveStatus, "template" | "category">, rest?: Rest): LiveStatusPing;
162
+ /** Finish a stream. The one alert your stream earns. */
163
+ done(correlationId: string, message?: string, rest?: Rest): LiveStatusPing;
164
+ /** Finish a stream unsuccessfully. */
165
+ failed(correlationId: string, message?: string, rest?: Rest): LiveStatusPing;
166
+ };
167
+ export {};
168
+ //# sourceMappingURL=liveStatus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liveStatus.d.ts","sourceRoot":"","sources":["../src/liveStatus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE5D,oFAAoF;AACpF,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;AAE9D,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAChC,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,OAAO,CAA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A4D;4BACpC,MAAM,QAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,SAAS,IAAI,GAAG,cAAc;IAIhG,iCAAiC;2BACV,MAAM,QAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,SAAS,IAAI,GAAG,cAAc;IAI/F,yDAAyD;6BAChC,MAAM,QAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,SAAS,IAAI,GAAG,cAAc;IAIjG,8DAA8D;4BACtC,MAAM,QAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,SAAS,IAAI,GAAG,cAAc;IAIhG,2CAA2C;2BACpB,MAAM,QAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,SAAS,IAAI,GAAG,cAAc;IAI/F;;;;;;;;OAQG;yBACkB,MAAM,QAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC,SAAS,IAAI,GAAG,cAAc;IAI1G,wDAAwD;wBACpC,MAAM,YAAY,MAAM,SAAS,IAAI,GAAG,cAAc;IAI1E,sCAAsC;0BAChB,MAAM,YAAY,MAAM,SAAS,IAAI,GAAG,cAAc;CAG7E,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Live-status streams — the wire contract for driving a Live Activity.
3
+ *
4
+ * A stream is keyed by `correlation_id`: the first ping starts a live card on
5
+ * every room member's lock screen (one alert), further `running` pings move it
6
+ * silently, and the first `done`/`failed` sends one completion alert and ends
7
+ * it. See https://pingroom.io/liveactivities.md.
8
+ *
9
+ * Three producers speak this contract. This SDK reaches the two machine ones:
10
+ * - a room's **incoming webhook** (Pro) — `sendIncomingWebhook()`
11
+ * - an **agent credential** — `pr.live.*` (needs `pingroom:live:write`)
12
+ *
13
+ * The third is a signed-in person driving a stream from the app composer over
14
+ * `POST /api/rooms/{inviteCode}/live` with their own Human JWT. It sends this
15
+ * same body minus `live_status.agent_id` (stripped server-side), so these
16
+ * builders describe it too — but it is not an agent route and has no client
17
+ * here.
18
+ *
19
+ * Not to be confused with `liveActivity.*` in ./liveActivity.ts, which builds
20
+ * the frozen *native* `{ attributes, content_state }` push shape for tests and
21
+ * tooling. These builders produce the `live_status` object you actually send.
22
+ */
23
+ const ping = (correlationId, live, rest = {}) => ({
24
+ correlation_id: correlationId,
25
+ live_status: live,
26
+ ...rest,
27
+ });
28
+ /**
29
+ * Builders for the common stream shapes. Each returns a body you can hand to
30
+ * `pr.live.push()` or `sendIncomingWebhook()`.
31
+ */
32
+ export const liveStatus = {
33
+ /** Default template: a title line plus a status dot, with optional progress. */
34
+ status(correlationId, live, rest) {
35
+ return ping(correlationId, { template: 'status', ...live }, rest);
36
+ },
37
+ /** A segmented step tracker. `steps` is required on the first ping. */
38
+ steps(correlationId, live, rest) {
39
+ return ping(correlationId, { template: 'steps', ...live }, rest);
40
+ },
41
+ /** A determinate progress bar with an optional live ETA. */
42
+ progress(correlationId, live, rest) {
43
+ return ping(correlationId, { template: 'progress', ...live }, rest);
44
+ },
45
+ /** Up to 3 labelled counters. */
46
+ metrics(correlationId, live, rest) {
47
+ return ping(correlationId, { template: 'metrics', ...live }, rest);
48
+ },
49
+ /** A large live timer counting down to `deadline_at`. */
50
+ countdown(correlationId, live, rest) {
51
+ return ping(correlationId, { template: 'countdown', ...live }, rest);
52
+ },
53
+ /** A prompt with up to 4 options shown on the lock screen. */
54
+ question(correlationId, live, rest) {
55
+ return ping(correlationId, { template: 'question', ...live }, rest);
56
+ },
57
+ /** Two sides plus a center score/clock. */
58
+ matchup(correlationId, live, rest) {
59
+ return ping(correlationId, { template: 'matchup', ...live }, rest);
60
+ },
61
+ /**
62
+ * An urgent stream, delivered time-sensitive from the start so it breaks
63
+ * through Focus.
64
+ *
65
+ * This is a `category`, not a `template`: `alert` has no template equivalent,
66
+ * and it is the only way to start time-sensitive WITHOUT also setting
67
+ * `requires_ack` (which demands somebody tap). Fixed at creation, like
68
+ * `template`.
69
+ */
70
+ alert(correlationId, live, rest) {
71
+ return ping(correlationId, { category: 'alert', ...live }, rest);
72
+ },
73
+ /** Finish a stream. The one alert your stream earns. */
74
+ done(correlationId, message, rest) {
75
+ return ping(correlationId, { state: 'done', ...(message ? { message } : {}) }, rest);
76
+ },
77
+ /** Finish a stream unsuccessfully. */
78
+ failed(correlationId, message, rest) {
79
+ return ping(correlationId, { state: 'failed', ...(message ? { message } : {}) }, rest);
80
+ },
81
+ };
82
+ //# sourceMappingURL=liveStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liveStatus.js","sourceRoot":"","sources":["../src/liveStatus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AA2HH,MAAM,IAAI,GAAG,CAAC,aAAqB,EAAE,IAAgB,EAAE,OAAa,EAAE,EAAkB,EAAE,CAAC,CAAC;IAC1F,cAAc,EAAE,aAAa;IAC7B,WAAW,EAAE,IAAI;IACjB,GAAG,IAAI;CACR,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,gFAAgF;IAChF,MAAM,CAAC,aAAqB,EAAE,IAAkC,EAAE,IAAW;QAC3E,OAAO,IAAI,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC;IAED,uEAAuE;IACvE,KAAK,CAAC,aAAqB,EAAE,IAAkC,EAAE,IAAW;QAC1E,OAAO,IAAI,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC;IAED,4DAA4D;IAC5D,QAAQ,CAAC,aAAqB,EAAE,IAAkC,EAAE,IAAW;QAC7E,OAAO,IAAI,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;IACtE,CAAC;IAED,iCAAiC;IACjC,OAAO,CAAC,aAAqB,EAAE,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