@ouispec/agent-worker 0.30.0 → 0.32.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.
- package/README.md +59 -12
- package/dist/authz/tool-policy.d.ts +2 -1
- package/dist/authz/tool-policy.d.ts.map +1 -1
- package/dist/authz/tool-policy.js.map +1 -1
- package/dist/handoff/handoff-tool.d.ts +51 -0
- package/dist/handoff/handoff-tool.d.ts.map +1 -0
- package/dist/handoff/handoff-tool.js +146 -0
- package/dist/handoff/handoff-tool.js.map +1 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/live-call/handler.d.ts +11 -4
- package/dist/live-call/handler.d.ts.map +1 -1
- package/dist/live-call/handler.js +34 -7
- package/dist/live-call/handler.js.map +1 -1
- package/dist/live-call/protocol.d.ts +52 -6
- package/dist/live-call/protocol.d.ts.map +1 -1
- package/dist/live-call/protocol.js +55 -7
- package/dist/live-call/protocol.js.map +1 -1
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +40 -20
- package/dist/orchestrator.js.map +1 -1
- package/dist/prompt/capture.d.ts +11 -2
- package/dist/prompt/capture.d.ts.map +1 -1
- package/dist/prompt/capture.js +22 -4
- package/dist/prompt/capture.js.map +1 -1
- package/dist/prompt/clock.d.ts +4 -4
- package/dist/prompt/clock.js +4 -4
- package/dist/prompt/handoff.d.ts +140 -0
- package/dist/prompt/handoff.d.ts.map +1 -0
- package/dist/prompt/handoff.js +218 -0
- package/dist/prompt/handoff.js.map +1 -0
- package/dist/prompt/spoken-input.d.ts +2 -2
- package/dist/prompt/spoken-input.js +2 -2
- package/dist/prompt/spoken-reply.d.ts +2 -2
- package/dist/prompt/spoken-reply.js +2 -2
- package/dist/prompt/vision.d.ts +3 -3
- package/dist/prompt/vision.js +3 -3
- package/dist/runtime/config.d.ts.map +1 -1
- package/dist/runtime/config.js +3 -0
- package/dist/runtime/config.js.map +1 -1
- package/dist/runtime/turn-runner.d.ts.map +1 -1
- package/dist/runtime/turn-runner.js +14 -0
- package/dist/runtime/turn-runner.js.map +1 -1
- package/dist/runtime/types.d.ts +25 -5
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/step-messages.d.ts +46 -9
- package/dist/step-messages.d.ts.map +1 -1
- package/dist/step-messages.js +43 -23
- package/dist/step-messages.js.map +1 -1
- package/dist/testing/scripted.d.ts +6 -4
- package/dist/testing/scripted.d.ts.map +1 -1
- package/dist/testing/scripted.js +7 -5
- package/dist/testing/scripted.js.map +1 -1
- package/dist/tools/types.d.ts +5 -4
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js.map +1 -1
- package/dist/types.d.ts +34 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/snapshot.d.ts +1 -1
- package/dist/ui/snapshot.js +1 -1
- package/package.json +2 -2
package/dist/prompt/capture.d.ts
CHANGED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
* `client.vision`; a refusal names the field and never repeats the token.
|
|
21
21
|
* Fields it does not know are read past.
|
|
22
22
|
* - **Where it goes:** the tools (capture/capture-tools.ts) while there are
|
|
23
|
-
* plans and a control route, and one line
|
|
24
|
-
*
|
|
23
|
+
* plans and a control route, and one line in the turn's context, straight
|
|
24
|
+
* after the turn's message (`captureText`): the clause, the plans,
|
|
25
25
|
* where the running capture stands, and an update that rode a message turn.
|
|
26
26
|
* - **What is never done with it:** the control token is never logged or
|
|
27
27
|
* emitted, and neither are the update's words (a VIN, a mileage). Logs
|
|
@@ -37,6 +37,9 @@ export type CaptureOutcome = (typeof CAPTURE_OUTCOMES)[number];
|
|
|
37
37
|
/** Why a capture ended. */
|
|
38
38
|
export declare const CAPTURE_END_REASONS: readonly ["all_steps_done", "caller_stopped", "brain_stopped", "api_stopped", "caller_declined", "consent_timeout", "camera_denied", "no_camera", "no_rear_camera", "idle_timeout", "max_duration", "call_ended", "call_unsupported", "agent_unavailable", "verifier_unavailable"];
|
|
39
39
|
export type CaptureEndReason = (typeof CAPTURE_END_REASONS)[number];
|
|
40
|
+
/** Why a capture is `blocked` (Closure's capture contract). */
|
|
41
|
+
export declare const CAPTURE_BLOCKED_REASONS: readonly ["camera_denied", "no_rear_camera"];
|
|
42
|
+
export type CaptureBlockedReason = (typeof CAPTURE_BLOCKED_REASONS)[number];
|
|
40
43
|
/**
|
|
41
44
|
* What a brain update reports. The call service passes updates on as words
|
|
42
45
|
* (`client.capture.update`); the kinds are what those words can be about.
|
|
@@ -104,6 +107,12 @@ export interface CaptureActive {
|
|
|
104
107
|
status: CaptureStatus;
|
|
105
108
|
/** The step it is on; null before the first, and between steps. */
|
|
106
109
|
step: CaptureActiveStep | null;
|
|
110
|
+
/**
|
|
111
|
+
* Why it is `blocked`, when the call service says: the browser refused the
|
|
112
|
+
* camera, or this device has no rear camera for the step (it carries on once the call moves to their
|
|
113
|
+
* phone).
|
|
114
|
+
*/
|
|
115
|
+
blockedReason?: CaptureBlockedReason;
|
|
107
116
|
}
|
|
108
117
|
/** What the turn carries of the session's photo captures. */
|
|
109
118
|
export interface TurnCapture {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../src/prompt/capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAQtE,0BAA0B;AAC1B,eAAO,MAAM,gBAAgB,mFAAoF,CAAC;AAClH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D,2BAA2B;AAC3B,eAAO,MAAM,gBAAgB,4FAA6F,CAAC;AAC3H,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,2BAA2B;AAC3B,eAAO,MAAM,mBAAmB,oRA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,CAAC;AAmBzH;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAsClF;AAED,iGAAiG;AACjG,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAUpG"}
|
package/dist/prompt/capture.js
CHANGED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
* `client.vision`; a refusal names the field and never repeats the token.
|
|
21
21
|
* Fields it does not know are read past.
|
|
22
22
|
* - **Where it goes:** the tools (capture/capture-tools.ts) while there are
|
|
23
|
-
* plans and a control route, and one line
|
|
24
|
-
*
|
|
23
|
+
* plans and a control route, and one line in the turn's context, straight
|
|
24
|
+
* after the turn's message (`captureText`): the clause, the plans,
|
|
25
25
|
* where the running capture stands, and an update that rode a message turn.
|
|
26
26
|
* - **What is never done with it:** the control token is never logged or
|
|
27
27
|
* emitted, and neither are the update's words (a VIN, a mileage). Logs
|
|
@@ -55,6 +55,8 @@ export const CAPTURE_END_REASONS = [
|
|
|
55
55
|
'agent_unavailable',
|
|
56
56
|
'verifier_unavailable',
|
|
57
57
|
];
|
|
58
|
+
/** Why a capture is `blocked` (Closure's capture contract). */
|
|
59
|
+
export const CAPTURE_BLOCKED_REASONS = ['camera_denied', 'no_rear_camera'];
|
|
58
60
|
/**
|
|
59
61
|
* What a brain update reports. The call service passes updates on as words
|
|
60
62
|
* (`client.capture.update`); the kinds are what those words can be about.
|
|
@@ -196,7 +198,17 @@ function readActive(value, field) {
|
|
|
196
198
|
return `${field}.step.index must be a whole number from 1 to step.of`;
|
|
197
199
|
step = { id: raw.id, label, index, of };
|
|
198
200
|
}
|
|
199
|
-
|
|
201
|
+
const blockedReason = value.blockedReason;
|
|
202
|
+
if (blockedReason !== undefined && blockedReason !== null && !CAPTURE_BLOCKED_REASONS.includes(blockedReason)) {
|
|
203
|
+
return `${field}.blockedReason must be one of ${CAPTURE_BLOCKED_REASONS.join(', ')}`;
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
captureId: value.captureId,
|
|
207
|
+
plan: value.plan,
|
|
208
|
+
status: value.status,
|
|
209
|
+
step,
|
|
210
|
+
...(typeof blockedReason === 'string' && value.status === 'blocked' ? { blockedReason: blockedReason } : {}),
|
|
211
|
+
};
|
|
200
212
|
}
|
|
201
213
|
/** Whether the turn can start, read and stop captures: there are plans, and a route to call. */
|
|
202
214
|
export function canCapture(capture) {
|
|
@@ -218,10 +230,16 @@ const STATUS_WORDS = {
|
|
|
218
230
|
starting: 'starting',
|
|
219
231
|
awaiting_consent: 'waiting for the caller to agree on their screen',
|
|
220
232
|
active: 'in progress',
|
|
233
|
+
// Before call hand-offs a capture was blocked for the camera permission alone.
|
|
221
234
|
blocked: 'blocked: their browser has not allowed the camera',
|
|
222
235
|
ending: 'finishing',
|
|
223
236
|
ended: 'over',
|
|
224
237
|
};
|
|
238
|
+
/** How a blocked capture's reason is said. */
|
|
239
|
+
const BLOCKED_WORDS = {
|
|
240
|
+
camera_denied: 'blocked: their browser has not allowed the camera',
|
|
241
|
+
no_rear_camera: 'blocked: this device has no rear camera for the next photo, so it waits for the call to move to their phone',
|
|
242
|
+
};
|
|
225
243
|
/**
|
|
226
244
|
* What the model is told about photo captures on this turn: one line, after
|
|
227
245
|
* the conversation. With plans and a route, the clause (`CAPTURE_WHEN`), when
|
|
@@ -246,7 +264,7 @@ export function captureText(capture) {
|
|
|
246
264
|
if (capture.active) {
|
|
247
265
|
const a = capture.active;
|
|
248
266
|
const step = a.step ? `, on step ${a.step.index} of ${a.step.of}, ${escapeTagText(a.step.label)}` : '';
|
|
249
|
-
parts.push(`A photo capture is running now: plan "${a.plan}", capture ${a.captureId}, ${STATUS_WORDS[a.status]}${step}. ` +
|
|
267
|
+
parts.push(`A photo capture is running now: plan "${a.plan}", capture ${a.captureId}, ${a.blockedReason ? BLOCKED_WORDS[a.blockedReason] : STATUS_WORDS[a.status]}${step}. ` +
|
|
250
268
|
(canCapture(capture) ? 'Use `capture_status` to ask where it stands; use `capture_stop` only when the caller wants to stop.' : ''));
|
|
251
269
|
}
|
|
252
270
|
else if (canCapture(capture)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture.js","sourceRoot":"","sources":["../../src/prompt/capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,eAAe,EAAoB,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,+EAA+E;AAC/E,mFAAmF;AACnF,+EAA+E;AAC/E,mEAAmE;AAEnE,0BAA0B;AAC1B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,UAAU,EAAE,kBAAkB,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAU,CAAC;AAGlH,2BAA2B;AAC3B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,oBAAoB,EAAE,WAAW,EAAE,QAAQ,CAAU,CAAC;AAG3H,2BAA2B;AAC3B,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,gBAAgB;IAChB,gBAAgB;IAChB,eAAe;IACf,aAAa;IACb,iBAAiB;IACjB,iBAAiB;IACjB,eAAe;IACf,WAAW;IACX,gBAAgB;IAChB,cAAc;IACd,cAAc;IACd,YAAY;IACZ,kBAAkB;IAClB,mBAAmB;IACnB,sBAAsB;CACd,CAAC;AAGX;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,QAAQ;IACR,WAAW;IACX,UAAU;IACV,QAAQ;IACR,MAAM;IACN,MAAM;IACN,UAAU;IACV,UAAU;IACV,SAAS;IACT,QAAQ;IACR,OAAO;CACC,CAAC;AAGX,8GAA8G;AAC9G,MA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,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5C,CAAC;AACJ,CAAC"}
|
package/dist/prompt/clock.d.ts
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
* (`context.timeZone`, an IANA name), so "today" and "yesterday" are the
|
|
11
11
|
* days their wall clock shows, not the server's. An unknown or missing zone
|
|
12
12
|
* is UTC, and the note says so.
|
|
13
|
-
* - **Where it goes:**
|
|
14
|
-
*
|
|
15
|
-
* minute would invalidate the cached prefix on every turn, and
|
|
16
|
-
* user's message, which the
|
|
13
|
+
* - **Where it goes:** first in the turn's context, straight after the
|
|
14
|
+
* turn's message (step-messages.ts). Never in the system prompt, where one
|
|
15
|
+
* changing minute would invalidate the cached prefix on every turn, and
|
|
16
|
+
* never in the user's message, which the host stores as they wrote it.
|
|
17
17
|
*/
|
|
18
18
|
/** The key under a turn's context that carries the user's IANA time zone. */
|
|
19
19
|
export declare const CLIENT_TIME_ZONE_KEY = "timeZone";
|
package/dist/prompt/clock.js
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
* (`context.timeZone`, an IANA name), so "today" and "yesterday" are the
|
|
11
11
|
* days their wall clock shows, not the server's. An unknown or missing zone
|
|
12
12
|
* is UTC, and the note says so.
|
|
13
|
-
* - **Where it goes:**
|
|
14
|
-
*
|
|
15
|
-
* minute would invalidate the cached prefix on every turn, and
|
|
16
|
-
* user's message, which the
|
|
13
|
+
* - **Where it goes:** first in the turn's context, straight after the
|
|
14
|
+
* turn's message (step-messages.ts). Never in the system prompt, where one
|
|
15
|
+
* changing minute would invalidate the cached prefix on every turn, and
|
|
16
|
+
* never in the user's message, which the host stores as they wrote it.
|
|
17
17
|
*/
|
|
18
18
|
/** The key under a turn's context that carries the user's IANA time zone. */
|
|
19
19
|
export const CLIENT_TIME_ZONE_KEY = 'timeZone';
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the character may know of a call moving between the caller's devices,
|
|
3
|
+
* as the turn sees it
|
|
4
|
+
*
|
|
5
|
+
* A caller on a laptop can carry the same call on to their phone: the brain
|
|
6
|
+
* offers it with `call_handoff`, a QR code appears on the laptop's screen,
|
|
7
|
+
* the phone opens the link, and the same conversation carries on there while
|
|
8
|
+
* the laptop pauses. The brain never sees a device, a screen or a code:
|
|
9
|
+
* everything it learns of a move is words.
|
|
10
|
+
*
|
|
11
|
+
* Each turn of a session that can move carries `client.handoff` (`handoff` on
|
|
12
|
+
* any turn payload):
|
|
13
|
+
*
|
|
14
|
+
* { control: { url, token, expiresAt },
|
|
15
|
+
* device: { formFactor: 'phone' | 'tablet' | 'desktop' | 'unknown', switches } | null,
|
|
16
|
+
* offer: { handoffId, purpose, expiresAt } | null,
|
|
17
|
+
* update: '<words>' | null }
|
|
18
|
+
*
|
|
19
|
+
* - **What is read:** `readTurnHandoff` checks every field, as strictly as
|
|
20
|
+
* `client.capture`; a refusal names the field and never repeats the token.
|
|
21
|
+
* Fields it does not know are read past.
|
|
22
|
+
* - **Where it goes:** the tool (handoff/handoff-tool.ts) while there is a
|
|
23
|
+
* control route, and one line in the turn's context, straight after the
|
|
24
|
+
* turn's message (`handoffText`): the clause, the device the call is on, an
|
|
25
|
+
* open offer, and an update that rode a message turn.
|
|
26
|
+
* - **What is never done with it:** the control token is never logged or
|
|
27
|
+
* emitted, and neither are the update's words. Logs record facts only
|
|
28
|
+
* (`handoffFacts`).
|
|
29
|
+
*/
|
|
30
|
+
import { type BearerRoute } from './bearer-route.js';
|
|
31
|
+
/** Why the call moves (`CallHandoffPurpose`): the tool's `purpose`. */
|
|
32
|
+
export declare const CALL_HANDOFF_PURPOSES: readonly ["photos", "caller_asked", "other"];
|
|
33
|
+
export type CallHandoffPurpose = (typeof CALL_HANDOFF_PURPOSES)[number];
|
|
34
|
+
/** What kind of device the caller is on (`CallFormFactor`), as their LiveCall stated it. */
|
|
35
|
+
export declare const CALL_FORM_FACTORS: readonly ["phone", "tablet", "desktop", "unknown"];
|
|
36
|
+
export type CallFormFactor = (typeof CALL_FORM_FACTORS)[number];
|
|
37
|
+
/** A hand-off's status (`CallHandoff.status`). */
|
|
38
|
+
export declare const CALL_HANDOFF_STATUSES: readonly ["offered", "redeemed", "expired", "cancelled"];
|
|
39
|
+
export type CallHandoffStatus = (typeof CALL_HANDOFF_STATUSES)[number];
|
|
40
|
+
/**
|
|
41
|
+
* What a device update reports. The call service passes updates on as words
|
|
42
|
+
* (`client.handoff.update`); the kinds are what those words can be about.
|
|
43
|
+
*/
|
|
44
|
+
export declare const CALL_DEVICE_UPDATE_KINDS: readonly ["offered", "switched", "brought_back", "revoked", "expired", "active_lost"];
|
|
45
|
+
export type CallDeviceUpdateKind = (typeof CALL_DEVICE_UPDATE_KINDS)[number];
|
|
46
|
+
/**
|
|
47
|
+
* The longest text of one device update: the contract's `device_update` frame
|
|
48
|
+
* and `device.update` message hold `text` to 600 characters. A turn's `update`
|
|
49
|
+
* joins the updates pending since the brain last heard.
|
|
50
|
+
*/
|
|
51
|
+
export declare const DEVICE_UPDATE_TEXT_MAX = 600;
|
|
52
|
+
/** A code's life, in seconds (`HANDOFF_CODE_TTL_S`). */
|
|
53
|
+
export declare const HANDOFF_CODE_TTL_S = 600;
|
|
54
|
+
/** Limits on what a turn's hand-off may carry. */
|
|
55
|
+
export declare const HANDOFF_LIMITS: {
|
|
56
|
+
/** The longest `control.url`. */
|
|
57
|
+
readonly controlUrlChars: 2048;
|
|
58
|
+
/** The longest `control.token`. */
|
|
59
|
+
readonly controlTokenChars: 4096;
|
|
60
|
+
/** The longest `control.expiresAt` and `offer.expiresAt`. */
|
|
61
|
+
readonly expiresAtChars: 64;
|
|
62
|
+
/** The longest `offer.handoffId`. */
|
|
63
|
+
readonly handoffIdChars: 128;
|
|
64
|
+
/** The most `device.switches` a session can count. */
|
|
65
|
+
readonly switches: 10000;
|
|
66
|
+
/**
|
|
67
|
+
* The longest `update`: the updates pending since the brain last heard,
|
|
68
|
+
* joined in order, each at most `DEVICE_UPDATE_TEXT_MAX` (600) characters.
|
|
69
|
+
*/
|
|
70
|
+
readonly updateChars: 8000;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Where the brain offers the move: studio-api's
|
|
74
|
+
* `POST /sessions/{sessionId}/handoffs` (H1), and an `lhb1` token for this
|
|
75
|
+
* session.
|
|
76
|
+
*/
|
|
77
|
+
export type HandoffControl = BearerRoute;
|
|
78
|
+
/** The device the call is live on now. */
|
|
79
|
+
export interface HandoffDevice {
|
|
80
|
+
/** `phone`, `tablet`, `desktop` or `unknown`, as its LiveCall stated it. */
|
|
81
|
+
formFactor: CallFormFactor;
|
|
82
|
+
/** How many times the call has switched devices. */
|
|
83
|
+
switches: number;
|
|
84
|
+
}
|
|
85
|
+
/** The offer open on the session: a QR code on the active device's screen. */
|
|
86
|
+
export interface HandoffOffer {
|
|
87
|
+
handoffId: string;
|
|
88
|
+
purpose: CallHandoffPurpose;
|
|
89
|
+
/** When its code stops working: ISO 8601, as sent. */
|
|
90
|
+
expiresAt: string;
|
|
91
|
+
}
|
|
92
|
+
/** What the turn carries of the call's devices. */
|
|
93
|
+
export interface TurnHandoff {
|
|
94
|
+
/** The route and token the tool calls; null when the call service gave none (the tool is then not offered). */
|
|
95
|
+
control: HandoffControl | null;
|
|
96
|
+
/** The active device; null while none is (the active device lost the call). */
|
|
97
|
+
device: HandoffDevice | null;
|
|
98
|
+
/** The offer open now, if any. */
|
|
99
|
+
offer: HandoffOffer | null;
|
|
100
|
+
/**
|
|
101
|
+
* What happened to the caller's devices since the brain last heard, in
|
|
102
|
+
* Closure's words: one or more updates (each at most
|
|
103
|
+
* `DEVICE_UPDATE_TEXT_MAX`), joined in order. On a `device` turn, the reason
|
|
104
|
+
* it runs; on another turn, what rode it. Null otherwise. Never logged or
|
|
105
|
+
* emitted.
|
|
106
|
+
*/
|
|
107
|
+
update: string | null;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Reads a turn's hand-off, or says why it is not one, naming the field under
|
|
111
|
+
* `field` (`client.handoff` on a live call, `handoff` on a payload). Null when
|
|
112
|
+
* nothing was said of it. Fields it does not know are read past; a known field
|
|
113
|
+
* of the wrong type is refused. No refusal repeats the token or the update.
|
|
114
|
+
*/
|
|
115
|
+
export declare function readTurnHandoff(value: unknown, field?: string): TurnHandoff | null | string;
|
|
116
|
+
/** Whether the turn can offer the move: there is a route to call. */
|
|
117
|
+
export declare function canHandoff(handoff: TurnHandoff | null | undefined): handoff is TurnHandoff & {
|
|
118
|
+
control: HandoffControl;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* The clause every brain that can move a call is given, word for word:
|
|
122
|
+
* Closure's brain in its spoken-reply contract, and a
|
|
123
|
+
* client's brain here.
|
|
124
|
+
*/
|
|
125
|
+
export declare const HANDOFF_WHEN: string;
|
|
126
|
+
/** What the model is told never to claim about the caller's devices. */
|
|
127
|
+
export declare const HANDOFF_NEVER = "You never see the caller\u2019s devices, their screen or the QR code: never claim to see one, and say only what the device updates tell you.";
|
|
128
|
+
/** How a form factor is said: a desktop is their computer. */
|
|
129
|
+
export declare const FORM_FACTOR_WORDS: Readonly<Record<CallFormFactor, string>>;
|
|
130
|
+
/**
|
|
131
|
+
* What the model is told about moving the call on this turn: one line, after
|
|
132
|
+
* the turn's message. With a route, the clause (`HANDOFF_WHEN`), and that it
|
|
133
|
+
* never sees a device or a code; the device the call is on and how often it
|
|
134
|
+
* has moved; an open offer; and an update that rode this turn, as data. Null
|
|
135
|
+
* when the turn says nothing of hand-offs.
|
|
136
|
+
*/
|
|
137
|
+
export declare function handoffText(handoff: TurnHandoff | null | undefined): string | null;
|
|
138
|
+
/** What a log line may say of a turn's hand-off: facts, never the token or the update's words. */
|
|
139
|
+
export declare function handoffFacts(handoff: TurnHandoff | null | undefined): Record<string, unknown> | null;
|
|
140
|
+
//# sourceMappingURL=handoff.d.ts.map
|
|
@@ -0,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moving between the caller's devices,
|
|
3
|
+
* as the turn sees it
|
|
4
|
+
*
|
|
5
|
+
* A caller on a laptop can carry the same call on to their phone: the brain
|
|
6
|
+
* offers it with `call_handoff`, a QR code appears on the laptop's screen,
|
|
7
|
+
* the phone opens the link, and the same conversation carries on there while
|
|
8
|
+
* the laptop pauses. The brain never sees a device, a screen or a code:
|
|
9
|
+
* everything it learns of a move is words.
|
|
10
|
+
*
|
|
11
|
+
* Each turn of a session that can move carries `client.handoff` (`handoff` on
|
|
12
|
+
* any turn payload):
|
|
13
|
+
*
|
|
14
|
+
* { control: { url, token, expiresAt },
|
|
15
|
+
* device: { formFactor: 'phone' | 'tablet' | 'desktop' | 'unknown', switches } | null,
|
|
16
|
+
* offer: { handoffId, purpose, expiresAt } | null,
|
|
17
|
+
* update: '<words>' | null }
|
|
18
|
+
*
|
|
19
|
+
* - **What is read:** `readTurnHandoff` checks every field, as strictly as
|
|
20
|
+
* `client.capture`; a refusal names the field and never repeats the token.
|
|
21
|
+
* Fields it does not know are read past.
|
|
22
|
+
* - **Where it goes:** the tool (handoff/handoff-tool.ts) while there is a
|
|
23
|
+
* control route, and one line in the turn's context, straight after the
|
|
24
|
+
* turn's message (`handoffText`): the clause, the device the call is on, an
|
|
25
|
+
* open offer, and an update that rode a message turn.
|
|
26
|
+
* - **What is never done with it:** the control token is never logged or
|
|
27
|
+
* emitted, and neither are the update's words. Logs record facts only
|
|
28
|
+
* (`handoffFacts`).
|
|
29
|
+
*/
|
|
30
|
+
import { readBearerRoute } from './bearer-route.js';
|
|
31
|
+
import { escapeTagText } from './escape.js';
|
|
32
|
+
// ─── The hand-off contract's names and values ───────────────────────────────
|
|
33
|
+
// Closure's hand-off contract (`@closurestudio/realtime-contracts` 0.28.0, `live-call-devices`)
|
|
34
|
+
// declares these. This package does not depend on it, so it keeps its own copy
|
|
35
|
+
// under the same names with the same values, and a test pins them.
|
|
36
|
+
/** Why the call moves (`CallHandoffPurpose`): the tool's `purpose`. */
|
|
37
|
+
export const CALL_HANDOFF_PURPOSES = ['photos', 'caller_asked', 'other'];
|
|
38
|
+
/** What kind of device the caller is on (`CallFormFactor`), as their LiveCall stated it. */
|
|
39
|
+
export const CALL_FORM_FACTORS = ['phone', 'tablet', 'desktop', 'unknown'];
|
|
40
|
+
/** A hand-off's status (`CallHandoff.status`). */
|
|
41
|
+
export const CALL_HANDOFF_STATUSES = ['offered', 'redeemed', 'expired', 'cancelled'];
|
|
42
|
+
/**
|
|
43
|
+
* What a device update reports. The call service passes updates on as words
|
|
44
|
+
* (`client.handoff.update`); the kinds are what those words can be about.
|
|
45
|
+
*/
|
|
46
|
+
export const CALL_DEVICE_UPDATE_KINDS = ['offered', 'switched', 'brought_back', 'revoked', 'expired', 'active_lost'];
|
|
47
|
+
/**
|
|
48
|
+
* The longest text of one device update: the contract's `device_update` frame
|
|
49
|
+
* and `device.update` message hold `text` to 600 characters. A turn's `update`
|
|
50
|
+
* joins the updates pending since the brain last heard.
|
|
51
|
+
*/
|
|
52
|
+
export const DEVICE_UPDATE_TEXT_MAX = 600;
|
|
53
|
+
/** A code's life, in seconds (`HANDOFF_CODE_TTL_S`). */
|
|
54
|
+
export const HANDOFF_CODE_TTL_S = 600;
|
|
55
|
+
/** Limits on what a turn's hand-off may carry. */
|
|
56
|
+
export const HANDOFF_LIMITS = {
|
|
57
|
+
/** The longest `control.url`. */
|
|
58
|
+
controlUrlChars: 2_048,
|
|
59
|
+
/** The longest `control.token`. */
|
|
60
|
+
controlTokenChars: 4_096,
|
|
61
|
+
/** The longest `control.expiresAt` and `offer.expiresAt`. */
|
|
62
|
+
expiresAtChars: 64,
|
|
63
|
+
/** The longest `offer.handoffId`. */
|
|
64
|
+
handoffIdChars: 128,
|
|
65
|
+
/** The most `device.switches` a session can count. */
|
|
66
|
+
switches: 10_000,
|
|
67
|
+
/**
|
|
68
|
+
* The longest `update`: the updates pending since the brain last heard,
|
|
69
|
+
* joined in order, each at most `DEVICE_UPDATE_TEXT_MAX` (600) characters.
|
|
70
|
+
*/
|
|
71
|
+
updateChars: 8_000,
|
|
72
|
+
};
|
|
73
|
+
/** An id: letters, digits and `.` `_` `:` `-`, starting with a letter or digit. */
|
|
74
|
+
const HANDOFF_ID = new RegExp(`^[A-Za-z0-9][A-Za-z0-9._:-]{0,${HANDOFF_LIMITS.handoffIdChars - 1}}$`);
|
|
75
|
+
/** An ISO 8601 date and time, with a zone. */
|
|
76
|
+
const ISO_DATE_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?(Z|[+-]\d{2}:?\d{2})$/;
|
|
77
|
+
function isPlainObject(value) {
|
|
78
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Reads a turn's hand-off, or says why it is not one, naming the field under
|
|
82
|
+
* `field` (`client.handoff` on a live call, `handoff` on a payload). Null when
|
|
83
|
+
* nothing was said of it. Fields it does not know are read past; a known field
|
|
84
|
+
* of the wrong type is refused. No refusal repeats the token or the update.
|
|
85
|
+
*/
|
|
86
|
+
export function readTurnHandoff(value, field = 'handoff') {
|
|
87
|
+
if (value === undefined || value === null)
|
|
88
|
+
return null;
|
|
89
|
+
if (!isPlainObject(value))
|
|
90
|
+
return `${field} must be an object or null`;
|
|
91
|
+
const control = readBearerRoute(value.control, `${field}.control`, { urlChars: HANDOFF_LIMITS.controlUrlChars, tokenChars: HANDOFF_LIMITS.controlTokenChars, expiresAtChars: HANDOFF_LIMITS.expiresAtChars }, { base: true });
|
|
92
|
+
if (typeof control === 'string')
|
|
93
|
+
return control;
|
|
94
|
+
const device = readDevice(value.device, `${field}.device`);
|
|
95
|
+
if (typeof device === 'string')
|
|
96
|
+
return device;
|
|
97
|
+
const offer = readOffer(value.offer, `${field}.offer`);
|
|
98
|
+
if (typeof offer === 'string')
|
|
99
|
+
return offer;
|
|
100
|
+
const update = value.update;
|
|
101
|
+
if (update !== undefined && update !== null && typeof update !== 'string')
|
|
102
|
+
return `${field}.update must be a string or null`;
|
|
103
|
+
if (typeof update === 'string' && update.length > HANDOFF_LIMITS.updateChars)
|
|
104
|
+
return `${field}.update is longer than ${HANDOFF_LIMITS.updateChars} characters`;
|
|
105
|
+
return {
|
|
106
|
+
control: control ? { ...control, url: control.url.replace(/\/+$/, '') } : null,
|
|
107
|
+
device,
|
|
108
|
+
offer,
|
|
109
|
+
update: typeof update === 'string' && update.trim() ? update.trim() : null,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function readDevice(value, field) {
|
|
113
|
+
if (value === undefined || value === null)
|
|
114
|
+
return null;
|
|
115
|
+
if (!isPlainObject(value))
|
|
116
|
+
return `${field} must be an object or null`;
|
|
117
|
+
if (!CALL_FORM_FACTORS.includes(value.formFactor))
|
|
118
|
+
return `${field}.formFactor must be one of ${CALL_FORM_FACTORS.join(', ')}`;
|
|
119
|
+
const switches = value.switches ?? 0;
|
|
120
|
+
if (!(typeof switches === 'number' && Number.isInteger(switches) && switches >= 0 && switches <= HANDOFF_LIMITS.switches)) {
|
|
121
|
+
return `${field}.switches must be a whole number from 0 to ${HANDOFF_LIMITS.switches}`;
|
|
122
|
+
}
|
|
123
|
+
return { formFactor: value.formFactor, switches };
|
|
124
|
+
}
|
|
125
|
+
function readOffer(value, field) {
|
|
126
|
+
if (value === undefined || value === null)
|
|
127
|
+
return null;
|
|
128
|
+
if (!isPlainObject(value))
|
|
129
|
+
return `${field} must be an object or null`;
|
|
130
|
+
if (typeof value.handoffId !== 'string' || !HANDOFF_ID.test(value.handoffId))
|
|
131
|
+
return `${field}.handoffId must be a hand-off id`;
|
|
132
|
+
if (!CALL_HANDOFF_PURPOSES.includes(value.purpose))
|
|
133
|
+
return `${field}.purpose must be one of ${CALL_HANDOFF_PURPOSES.join(', ')}`;
|
|
134
|
+
const expiresAt = value.expiresAt;
|
|
135
|
+
if (typeof expiresAt !== 'string' ||
|
|
136
|
+
expiresAt.length > HANDOFF_LIMITS.expiresAtChars ||
|
|
137
|
+
!ISO_DATE_TIME.test(expiresAt) ||
|
|
138
|
+
!Number.isFinite(Date.parse(expiresAt))) {
|
|
139
|
+
return `${field}.expiresAt must be an ISO 8601 date and time`;
|
|
140
|
+
}
|
|
141
|
+
return { handoffId: value.handoffId, purpose: value.purpose, expiresAt };
|
|
142
|
+
}
|
|
143
|
+
/** Whether the turn can offer the move: there is a route to call. */
|
|
144
|
+
export function canHandoff(handoff) {
|
|
145
|
+
return !!handoff && handoff.control !== null;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The clause every brain that can move a call is given, word for word:
|
|
149
|
+
* Closure's brain in its spoken-reply contract, and a
|
|
150
|
+
* client's brain here.
|
|
151
|
+
*/
|
|
152
|
+
export const HANDOFF_WHEN = "You can move this call to the caller's phone with `call_handoff`. " +
|
|
153
|
+
'Offer it when photos need a rear camera this device lacks, or when the caller would be better off on their phone, and call it once they agree. ' +
|
|
154
|
+
'A QR code then appears on their screen. Never read out a code or a link. ' +
|
|
155
|
+
'While the call moves you receive device updates: answer each with one short sentence, or with nothing.';
|
|
156
|
+
/** What the model is told never to claim about the caller's devices. */
|
|
157
|
+
export const HANDOFF_NEVER = 'You never see the caller’s devices, their screen or the QR code: never claim to see one, and say only what the device updates tell you.';
|
|
158
|
+
/** How a form factor is said: a desktop is their computer. */
|
|
159
|
+
export const FORM_FACTOR_WORDS = {
|
|
160
|
+
phone: 'phone',
|
|
161
|
+
tablet: 'tablet',
|
|
162
|
+
desktop: 'computer',
|
|
163
|
+
unknown: 'other device',
|
|
164
|
+
};
|
|
165
|
+
/** What an open offer is for, as said. */
|
|
166
|
+
const PURPOSE_WORDS = {
|
|
167
|
+
photos: 'to take the photos there',
|
|
168
|
+
caller_asked: 'because they asked to',
|
|
169
|
+
other: 'to carry on there',
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* What the model is told about moving the call on this turn: one line, after
|
|
173
|
+
* the turn's message. With a route, the clause (`HANDOFF_WHEN`), and that it
|
|
174
|
+
* never sees a device or a code; the device the call is on and how often it
|
|
175
|
+
* has moved; an open offer; and an update that rode this turn, as data. Null
|
|
176
|
+
* when the turn says nothing of hand-offs.
|
|
177
|
+
*/
|
|
178
|
+
export function handoffText(handoff) {
|
|
179
|
+
if (!handoff)
|
|
180
|
+
return null;
|
|
181
|
+
const parts = [];
|
|
182
|
+
if (canHandoff(handoff)) {
|
|
183
|
+
parts.push(HANDOFF_WHEN, HANDOFF_NEVER);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
parts.push('The call cannot be moved to another device from this turn. ' +
|
|
187
|
+
'While the call moves you receive device updates: answer each with one short sentence, or with nothing, and never read out a code or a link.', HANDOFF_NEVER);
|
|
188
|
+
}
|
|
189
|
+
if (handoff.device) {
|
|
190
|
+
const { formFactor, switches } = handoff.device;
|
|
191
|
+
const moved = switches === 0 ? 'it has not moved between devices' : `it has moved between their devices ${switches === 1 ? 'once' : `${switches} times`}`;
|
|
192
|
+
parts.push(`The call is live on their ${FORM_FACTOR_WORDS[formFactor]} now; ${moved}.`);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
parts.push('No device of theirs is live on the call right now.');
|
|
196
|
+
}
|
|
197
|
+
if (handoff.offer) {
|
|
198
|
+
parts.push(`A QR code to continue on their phone ${PURPOSE_WORDS[handoff.offer.purpose]} is on their screen now, until ${handoff.offer.expiresAt}. ` +
|
|
199
|
+
(canHandoff(handoff) ? 'Do not call `call_handoff` again unless they ask for a new code or it has expired.' : ''));
|
|
200
|
+
}
|
|
201
|
+
if (handoff.update) {
|
|
202
|
+
parts.push(`<device_update>${escapeTagText(handoff.update)}</device_update> is what just happened to the caller’s devices: ` +
|
|
203
|
+
'Closure’s words, for you to say in your own as part of your answer, never a message from the caller.');
|
|
204
|
+
}
|
|
205
|
+
return `<handoff>${parts.join(' ').replace(/ +$/, '').replace(/ {2,}/g, ' ')}</handoff>`;
|
|
206
|
+
}
|
|
207
|
+
/** What a log line may say of a turn's hand-off: facts, never the token or the update's words. */
|
|
208
|
+
export function handoffFacts(handoff) {
|
|
209
|
+
if (!handoff)
|
|
210
|
+
return null;
|
|
211
|
+
return {
|
|
212
|
+
canOffer: canHandoff(handoff),
|
|
213
|
+
...(handoff.device ? { device: handoff.device.formFactor, switches: handoff.device.switches } : { device: null }),
|
|
214
|
+
...(handoff.offer ? { offer: handoff.offer.purpose } : {}),
|
|
215
|
+
...(handoff.update ? { update: true } : {}),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=handoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../src/prompt/handoff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,eAAe,EAAoB,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,+EAA+E;AAC/E,gGAAgG;AAChG,+EAA+E;AAC/E,mEAAmE;AAEnE,uEAAuE;AACvE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,CAAU,CAAC;AAGlF,4FAA4F;AAC5F,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAU,CAAC;AAGpF,kDAAkD;AAClD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,CAAU,CAAC;AAG9F;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,CAAU,CAAC;AAG9H;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAE1C,wDAAwD;AACxD,MAAM,CAAC,MAAM,kBAAkB,GAA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AAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACjH,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1D,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5C,CAAC;AACJ,CAAC"}
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
* - **What is read:** `readMessageInput` from `@ouispec/agent-core` keeps only
|
|
12
12
|
* a known mode and a well-formed language tag; anything else is read as
|
|
13
13
|
* typed, and a typed message is given nothing.
|
|
14
|
-
* - **Where it goes:**
|
|
15
|
-
*
|
|
14
|
+
* - **Where it goes:** in the turn's context, straight after the turn's
|
|
15
|
+
* message (step-messages.ts), never in the system prompt or in the
|
|
16
16
|
* message itself. The system prompt and the tools are a cached prefix, and
|
|
17
17
|
* the next turn sends the message as the host stored it, without this line:
|
|
18
18
|
* on the message, it made that turn write the conversation from there to the
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
* - **What is read:** `readMessageInput` from `@ouispec/agent-core` keeps only
|
|
12
12
|
* a known mode and a well-formed language tag; anything else is read as
|
|
13
13
|
* typed, and a typed message is given nothing.
|
|
14
|
-
* - **Where it goes:**
|
|
15
|
-
*
|
|
14
|
+
* - **Where it goes:** in the turn's context, straight after the turn's
|
|
15
|
+
* message (step-messages.ts), never in the system prompt or in the
|
|
16
16
|
* message itself. The system prompt and the tools are a cached prefix, and
|
|
17
17
|
* the next turn sends the message as the host stored it, without this line:
|
|
18
18
|
* on the message, it made that turn write the conversation from there to the
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* - **What is read:** `readReplyOutput` from `@ouispec/agent-core` keeps only
|
|
13
13
|
* a known mode; anything else is a reply shown as text, which is given
|
|
14
14
|
* nothing.
|
|
15
|
-
* - **Where it goes:**
|
|
16
|
-
*
|
|
15
|
+
* - **Where it goes:** in the turn's context, straight after the turn's
|
|
16
|
+
* message (step-messages.ts), as the line for a spoken message does
|
|
17
17
|
* (spoken-input.ts), never in the system prompt or on the message. The system
|
|
18
18
|
* prompt and the tools are a cached prefix, shared by the conversation's
|
|
19
19
|
* chat turns and its call turns: the rule there would make every switch
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* - **What is read:** `readReplyOutput` from `@ouispec/agent-core` keeps only
|
|
13
13
|
* a known mode; anything else is a reply shown as text, which is given
|
|
14
14
|
* nothing.
|
|
15
|
-
* - **Where it goes:**
|
|
16
|
-
*
|
|
15
|
+
* - **Where it goes:** in the turn's context, straight after the turn's
|
|
16
|
+
* message (step-messages.ts), as the line for a spoken message does
|
|
17
17
|
* (spoken-input.ts), never in the system prompt or on the message. The system
|
|
18
18
|
* prompt and the tools are a cached prefix, shared by the conversation's
|
|
19
19
|
* chat turns and its call turns: the rule there would make every switch
|