@ouispec/agent-worker 0.26.0 → 0.28.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/README.md +25 -6
- package/dist/authz/tool-policy.d.ts +5 -5
- package/dist/authz/tool-policy.d.ts.map +1 -1
- package/dist/container/server.d.ts.map +1 -1
- package/dist/container/server.js +2 -2
- package/dist/container/server.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/live-call/handler.d.ts +19 -1
- package/dist/live-call/handler.d.ts.map +1 -1
- package/dist/live-call/handler.js +54 -6
- package/dist/live-call/handler.js.map +1 -1
- package/dist/live-call/protocol.d.ts +54 -7
- package/dist/live-call/protocol.d.ts.map +1 -1
- package/dist/live-call/protocol.js +77 -16
- package/dist/live-call/protocol.js.map +1 -1
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +25 -8
- package/dist/orchestrator.js.map +1 -1
- package/dist/prompt/vision.d.ts +92 -0
- package/dist/prompt/vision.d.ts.map +1 -0
- package/dist/prompt/vision.js +177 -0
- package/dist/prompt/vision.js.map +1 -0
- 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 +10 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/tools/types.d.ts +12 -3
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/vision/look-tool.d.ts +43 -0
- package/dist/vision/look-tool.d.ts.map +1 -0
- package/dist/vision/look-tool.js +145 -0
- package/dist/vision/look-tool.js.map +1 -0
- package/package.json +2 -1
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* Content-Type: application/json
|
|
13
13
|
* Accept: text/event-stream
|
|
14
14
|
*
|
|
15
|
-
* { sessionId, clientRef, turnId, kind, text, input?, output?, supersedes?, disclosureLine?, client? }
|
|
15
|
+
* { sessionId, clientRef, turnId, kind, text, input?, output?, supersedes?, disclosureLine?, client?: { ui?, vision? } }
|
|
16
16
|
*
|
|
17
17
|
* `input` is `{ mode: 'voice', language? }` for what the person said and
|
|
18
18
|
* `{ mode: 'text' }` for what they typed during the call. `output` is
|
|
@@ -23,6 +23,27 @@
|
|
|
23
23
|
* `client.ui`, when the person's page sent its UI into the call, is that page
|
|
24
24
|
* as its typed turns carry it: `{ buildId?, currentPath?, oui?, uiKnowledge? }`.
|
|
25
25
|
*
|
|
26
|
+
* `client.vision`, when the character may see the caller, is
|
|
27
|
+
*
|
|
28
|
+
* { seeing, remarks, canLook, absent: 'camera_off' | 'turned_off' | null,
|
|
29
|
+
* look: { url, token, expiresAt } | null, observation: '<one sentence>' | null }
|
|
30
|
+
*
|
|
31
|
+
* No turn carries a picture. `seeing`: the character may see
|
|
32
|
+
* the caller; `remarks`: it may bring up what it sees unprompted. With
|
|
33
|
+
* `canLook`, the model is given the `look` tool, which asks the call service's
|
|
34
|
+
* `look.url` a question about the caller's camera with `look.token` and is
|
|
35
|
+
* answered in words; it is told to look only when the conversation calls for
|
|
36
|
+
* it. Without, it is told it cannot see the caller, and why (`absent`). The
|
|
37
|
+
* token, a look's question and answer, and the observation are never logged
|
|
38
|
+
* or emitted.
|
|
39
|
+
*
|
|
40
|
+
* A `glance` turn is the call service's look between turns: nobody has spoken
|
|
41
|
+
* for a while, and its own look noticed something worth a remark. `text` is
|
|
42
|
+
* empty, `client.vision.remarks` is on and `client.vision.observation` says
|
|
43
|
+
* what was noticed. The model phrases one short remark on it (and may look for
|
|
44
|
+
* more), or says nothing: an empty answer is `done` with no `text`, and the
|
|
45
|
+
* call stays silent. `observation` is read on a glance only.
|
|
46
|
+
*
|
|
26
47
|
* and the answer is `200 text/event-stream`:
|
|
27
48
|
*
|
|
28
49
|
* event: text data: { "text": "…" } the reply, piece by piece
|
|
@@ -33,8 +54,14 @@
|
|
|
33
54
|
* with `: keep-alive` comments while nothing else is sent.
|
|
34
55
|
*/
|
|
35
56
|
import { type MessageInput, type ReplyOutput } from '@ouispec/agent-core';
|
|
36
|
-
|
|
37
|
-
|
|
57
|
+
import { type TurnVision } from '../prompt/vision.js';
|
|
58
|
+
/**
|
|
59
|
+
* `message`: the person said `text`. `opening`: the call has just connected;
|
|
60
|
+
* nothing has been said, and the agent greets. `glance`: nobody has spoken for
|
|
61
|
+
* a while and the caller's picture changed; the agent remarks on it, or says
|
|
62
|
+
* nothing.
|
|
63
|
+
*/
|
|
64
|
+
export declare const LIVE_CALL_TURN_KINDS: readonly ["message", "opening", "glance"];
|
|
38
65
|
export type LiveCallTurnKind = (typeof LIVE_CALL_TURN_KINDS)[number];
|
|
39
66
|
/**
|
|
40
67
|
* The person's page, as it sent its UI into the call: the same context a typed
|
|
@@ -56,6 +83,13 @@ export interface LiveCallClientUi {
|
|
|
56
83
|
export interface LiveCallClient {
|
|
57
84
|
/** Their page's latest UI, when it sent one into the call. */
|
|
58
85
|
ui: LiveCallClientUi | null;
|
|
86
|
+
/**
|
|
87
|
+
* Whether and how the character may look at their camera, when the call
|
|
88
|
+
* service said (`client.vision`); null when it said nothing (vision is off
|
|
89
|
+
* for the session, the brain does not take it, or the call service predates
|
|
90
|
+
* it). Set as the turn payload's `vision`.
|
|
91
|
+
*/
|
|
92
|
+
vision: TurnVision | null;
|
|
59
93
|
}
|
|
60
94
|
/** A live-call turn request, as read: every field checked, `input` and `output` kept only as far as they are known. */
|
|
61
95
|
export interface LiveCallTurnRequest {
|
|
@@ -66,12 +100,12 @@ export interface LiveCallTurnRequest {
|
|
|
66
100
|
/** Unique per turn; the turn runs under this id. */
|
|
67
101
|
turnId: string;
|
|
68
102
|
kind: LiveCallTurnKind;
|
|
69
|
-
/** What the person said, as transcribed. Empty for `opening`. */
|
|
103
|
+
/** What the person said, as transcribed. Empty for `opening` and `glance`. */
|
|
70
104
|
text: string;
|
|
71
105
|
/**
|
|
72
106
|
* How `text` was entered: `{ mode: 'voice', language? }` for what the person
|
|
73
107
|
* said. Null for a message they typed during the call (`{ mode: 'text' }` on
|
|
74
|
-
* the wire), for `opening`, and when not said: a typed message is read as
|
|
108
|
+
* the wire), for `opening` and `glance`, and when not said: a typed message is read as
|
|
75
109
|
* typed, with no spoken-input line.
|
|
76
110
|
*/
|
|
77
111
|
input: MessageInput | null;
|
|
@@ -93,8 +127,10 @@ export interface LiveCallTurnRequest {
|
|
|
93
127
|
disclosureLine: string | null;
|
|
94
128
|
/**
|
|
95
129
|
* The person's own side of the call: their page's latest UI, when the page
|
|
96
|
-
* sent it into the call (`client.ui`)
|
|
97
|
-
*
|
|
130
|
+
* sent it into the call (`client.ui`), and whether the character may look
|
|
131
|
+
* at their camera (`client.vision`). Null when the call service said nothing of either, as
|
|
132
|
+
* for a call with no page (a phone call). A `glance` always has
|
|
133
|
+
* `client.vision` with `remarks` on and an `observation`.
|
|
98
134
|
*/
|
|
99
135
|
client: LiveCallClient | null;
|
|
100
136
|
}
|
|
@@ -149,6 +185,15 @@ export declare const LIVE_CALL_OPENING_MESSAGE: string;
|
|
|
149
185
|
* stores the person's messages stores this for the opening turn.
|
|
150
186
|
*/
|
|
151
187
|
export declare function liveCallOpeningMessage(request: Pick<LiveCallTurnRequest, 'disclosureLine'>): string;
|
|
188
|
+
/**
|
|
189
|
+
* The person's message for a `glance` turn, as the model reads it: an
|
|
190
|
+
* instruction to phrase one short remark on what a look at the camera just
|
|
191
|
+
* noticed (the turn's `observation`, in its vision note), or to say nothing,
|
|
192
|
+
* so the call stays silent. A host that stores the person's messages stores
|
|
193
|
+
* this for the glance turn, as it stores the opening's: the observation is
|
|
194
|
+
* never in it.
|
|
195
|
+
*/
|
|
196
|
+
export declare const LIVE_CALL_GLANCE_MESSAGE: string;
|
|
152
197
|
/**
|
|
153
198
|
* The `input` mode of a message the person typed during the call. It is read
|
|
154
199
|
* as typed: the turn's context carries no `input`, as for a message typed in
|
|
@@ -169,6 +214,8 @@ export declare const LIVE_CALL_LIMITS: {
|
|
|
169
214
|
readonly disclosureLineChars: 1000;
|
|
170
215
|
/** The most `client.ui` may weigh, as UTF-8 JSON: the bound the page and the call service hold it to. */
|
|
171
216
|
readonly clientUiBytes: number;
|
|
217
|
+
/** The longest `client.vision.observation` (`VISION_LIMITS.observationChars`). */
|
|
218
|
+
readonly visionObservationChars: 1000;
|
|
172
219
|
};
|
|
173
220
|
/** A request read, or why it is not one. */
|
|
174
221
|
export type LiveCallRequestReading = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/live-call/protocol.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/live-call/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,OAAO,EAAqC,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC7G,OAAO,EAAiC,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAErF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,2CAA4C,CAAC;AAE9E,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAErE;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wFAAwF;IACxF,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,2GAA2G;IAC3G,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,uEAAuE;AACvE,M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,QAE0F,CAAC;AAEjI;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,GAAG,MAAM,CASnG;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,QAMsC,CAAC;AAE5E;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,SAAS,CAAC;AAEjD,2BAA2B;AAC3B,eAAO,MAAM,gBAAgB;IAC3B,qEAAqE;;IAErE,+BAA+B;;IAE/B,0BAA0B;;IAE1B,yCAAyC;;IAEzC,oCAAoC;;IAEpC,yGAAyG;;IAEzG,kFAAkF;;CAE1E,CAAC;AAQX,4CAA4C;AAC5C,MAAM,MAAM,sBAAsB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,mBAAmB,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/G,4EAA4E;AAC5E,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,OAAO,GAAG,sBAAsB,CAsE7E;AAgDD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASrE,CAAC;AAEF,4CAA4C;AAC5C,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAEzE"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* Content-Type: application/json
|
|
13
13
|
* Accept: text/event-stream
|
|
14
14
|
*
|
|
15
|
-
* { sessionId, clientRef, turnId, kind, text, input?, output?, supersedes?, disclosureLine?, client? }
|
|
15
|
+
* { sessionId, clientRef, turnId, kind, text, input?, output?, supersedes?, disclosureLine?, client?: { ui?, vision? } }
|
|
16
16
|
*
|
|
17
17
|
* `input` is `{ mode: 'voice', language? }` for what the person said and
|
|
18
18
|
* `{ mode: 'text' }` for what they typed during the call. `output` is
|
|
@@ -23,6 +23,27 @@
|
|
|
23
23
|
* `client.ui`, when the person's page sent its UI into the call, is that page
|
|
24
24
|
* as its typed turns carry it: `{ buildId?, currentPath?, oui?, uiKnowledge? }`.
|
|
25
25
|
*
|
|
26
|
+
* `client.vision`, when the character may see the caller, is
|
|
27
|
+
*
|
|
28
|
+
* { seeing, remarks, canLook, absent: 'camera_off' | 'turned_off' | null,
|
|
29
|
+
* look: { url, token, expiresAt } | null, observation: '<one sentence>' | null }
|
|
30
|
+
*
|
|
31
|
+
* No turn carries a picture. `seeing`: the character may see
|
|
32
|
+
* the caller; `remarks`: it may bring up what it sees unprompted. With
|
|
33
|
+
* `canLook`, the model is given the `look` tool, which asks the call service's
|
|
34
|
+
* `look.url` a question about the caller's camera with `look.token` and is
|
|
35
|
+
* answered in words; it is told to look only when the conversation calls for
|
|
36
|
+
* it. Without, it is told it cannot see the caller, and why (`absent`). The
|
|
37
|
+
* token, a look's question and answer, and the observation are never logged
|
|
38
|
+
* or emitted.
|
|
39
|
+
*
|
|
40
|
+
* A `glance` turn is the call service's look between turns: nobody has spoken
|
|
41
|
+
* for a while, and its own look noticed something worth a remark. `text` is
|
|
42
|
+
* empty, `client.vision.remarks` is on and `client.vision.observation` says
|
|
43
|
+
* what was noticed. The model phrases one short remark on it (and may look for
|
|
44
|
+
* more), or says nothing: an empty answer is `done` with no `text`, and the
|
|
45
|
+
* call stays silent. `observation` is read on a glance only.
|
|
46
|
+
*
|
|
26
47
|
* and the answer is `200 text/event-stream`:
|
|
27
48
|
*
|
|
28
49
|
* event: text data: { "text": "…" } the reply, piece by piece
|
|
@@ -33,8 +54,14 @@
|
|
|
33
54
|
* with `: keep-alive` comments while nothing else is sent.
|
|
34
55
|
*/
|
|
35
56
|
import { readMessageInput, readReplyOutput } from '@ouispec/agent-core';
|
|
36
|
-
|
|
37
|
-
|
|
57
|
+
import { VISION_LIMITS, readTurnVision } from '../prompt/vision.js';
|
|
58
|
+
/**
|
|
59
|
+
* `message`: the person said `text`. `opening`: the call has just connected;
|
|
60
|
+
* nothing has been said, and the agent greets. `glance`: nobody has spoken for
|
|
61
|
+
* a while and the caller's picture changed; the agent remarks on it, or says
|
|
62
|
+
* nothing.
|
|
63
|
+
*/
|
|
64
|
+
export const LIVE_CALL_TURN_KINDS = ['message', 'opening', 'glance'];
|
|
38
65
|
/**
|
|
39
66
|
* The person's message for an `opening` turn: an instruction to greet, which
|
|
40
67
|
* the model reads where the person's words would be. A host that stores the
|
|
@@ -59,6 +86,20 @@ export function liveCallOpeningMessage(request) {
|
|
|
59
86
|
'Greet them in a sentence or two, following on from that without repeating it, and ask what they would like help with. ' +
|
|
60
87
|
'This is not a message from the user.</call_opening>');
|
|
61
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* The person's message for a `glance` turn, as the model reads it: an
|
|
91
|
+
* instruction to phrase one short remark on what a look at the camera just
|
|
92
|
+
* noticed (the turn's `observation`, in its vision note), or to say nothing,
|
|
93
|
+
* so the call stays silent. A host that stores the person's messages stores
|
|
94
|
+
* this for the glance turn, as it stores the opening's: the observation is
|
|
95
|
+
* never in it.
|
|
96
|
+
*/
|
|
97
|
+
export const LIVE_CALL_GLANCE_MESSAGE = '<call_glance>Nobody has spoken for a few seconds, and a look at the user’s camera noticed something; what it noticed is in the vision note. ' +
|
|
98
|
+
'This is not a message from the user. ' +
|
|
99
|
+
'If it is worth one brief, friendly remark (they hold something up, put something on, someone else appears), say that remark, in one short sentence; ' +
|
|
100
|
+
'you may look first if you need to see more. ' +
|
|
101
|
+
'Otherwise answer with nothing at all, not a word or a mark, and the call stays silent. ' +
|
|
102
|
+
'Never repeat a remark you have already made in this call.</call_glance>';
|
|
62
103
|
/**
|
|
63
104
|
* The `input` mode of a message the person typed during the call. It is read
|
|
64
105
|
* as typed: the turn's context carries no `input`, as for a message typed in
|
|
@@ -79,6 +120,8 @@ export const LIVE_CALL_LIMITS = {
|
|
|
79
120
|
disclosureLineChars: 1_000,
|
|
80
121
|
/** The most `client.ui` may weigh, as UTF-8 JSON: the bound the page and the call service hold it to. */
|
|
81
122
|
clientUiBytes: 64 * 1024,
|
|
123
|
+
/** The longest `client.vision.observation` (`VISION_LIMITS.observationChars`). */
|
|
124
|
+
visionObservationChars: VISION_LIMITS.observationChars,
|
|
82
125
|
};
|
|
83
126
|
/** An id: letters, digits and `.` `_` `:` `-`, starting with a letter or digit. */
|
|
84
127
|
const ID = new RegExp(`^[A-Za-z0-9][A-Za-z0-9._:-]{0,${LIVE_CALL_LIMITS.idChars - 1}}$`);
|
|
@@ -104,15 +147,15 @@ export function readLiveCallTurnRequest(body) {
|
|
|
104
147
|
return refuse(`kind must be one of ${LIVE_CALL_TURN_KINDS.join(', ')}`);
|
|
105
148
|
}
|
|
106
149
|
const kind = b.kind;
|
|
107
|
-
const text = b.text === undefined && kind
|
|
150
|
+
const text = b.text === undefined && kind !== 'message' ? '' : b.text;
|
|
108
151
|
if (typeof text !== 'string')
|
|
109
152
|
return refuse('text must be a string');
|
|
110
153
|
if (text.length > LIVE_CALL_LIMITS.textChars)
|
|
111
154
|
return refuse(`text is longer than ${LIVE_CALL_LIMITS.textChars} characters`);
|
|
112
155
|
if (kind === 'message' && !text.trim())
|
|
113
156
|
return refuse('a message turn needs the text the person said');
|
|
114
|
-
if (kind
|
|
115
|
-
return refuse('an opening turn carries no text
|
|
157
|
+
if (kind !== 'message' && text.trim())
|
|
158
|
+
return refuse(`${kind === 'opening' ? 'an opening' : 'a glance'} turn carries no text`);
|
|
116
159
|
for (const field of ['input', 'output']) {
|
|
117
160
|
const value = b[field];
|
|
118
161
|
if (value !== undefined && value !== null && (typeof value !== 'object' || Array.isArray(value)))
|
|
@@ -129,9 +172,18 @@ export function readLiveCallTurnRequest(body) {
|
|
|
129
172
|
(typeof disclosureLine !== 'string' || disclosureLine.length > LIVE_CALL_LIMITS.disclosureLineChars || CONTROL.test(disclosureLine))) {
|
|
130
173
|
return refuse(`disclosureLine must be a string of at most ${LIVE_CALL_LIMITS.disclosureLineChars} characters with no control characters`);
|
|
131
174
|
}
|
|
132
|
-
const
|
|
133
|
-
if (typeof
|
|
134
|
-
return refuse(
|
|
175
|
+
const read = readClient(b.client);
|
|
176
|
+
if (typeof read === 'string')
|
|
177
|
+
return refuse(read);
|
|
178
|
+
if (kind === 'glance') {
|
|
179
|
+
// A glance offers a remark on what was noticed: without leave to remark, or with nothing noticed, there is nothing to run.
|
|
180
|
+
if (!read?.vision?.remarks)
|
|
181
|
+
return refuse('a glance turn needs client.vision.remarks on');
|
|
182
|
+
if (!read.vision.observation)
|
|
183
|
+
return refuse('a glance turn needs client.vision.observation');
|
|
184
|
+
}
|
|
185
|
+
// What a look noticed belongs to its glance alone.
|
|
186
|
+
const client = read?.vision?.observation && kind !== 'glance' ? { ...read, vision: { ...read.vision, observation: null } } : read;
|
|
135
187
|
return {
|
|
136
188
|
ok: true,
|
|
137
189
|
request: {
|
|
@@ -139,9 +191,9 @@ export function readLiveCallTurnRequest(body) {
|
|
|
139
191
|
clientRef,
|
|
140
192
|
turnId: b.turnId,
|
|
141
193
|
kind,
|
|
142
|
-
text: kind === '
|
|
143
|
-
// Nothing was said on an opening
|
|
144
|
-
input: kind
|
|
194
|
+
text: kind === 'message' ? text : '',
|
|
195
|
+
// Nothing was said on an opening or a glance, so nothing was entered; a typed message is read as typed.
|
|
196
|
+
input: kind !== 'message' || isTyped(b.input) ? null : readMessageInput(b.input),
|
|
145
197
|
output: readReplyOutput(b.output),
|
|
146
198
|
supersedes: [...new Set(supersedes)].filter((id) => id !== b.turnId),
|
|
147
199
|
// Said before the greeting: an opening turn's alone.
|
|
@@ -156,16 +208,25 @@ function isPlainObject(value) {
|
|
|
156
208
|
/**
|
|
157
209
|
* The request's `client`, or why it is not one. Fields it does not know are
|
|
158
210
|
* left out, so a newer call service is read past; a known field of the wrong
|
|
159
|
-
* type is refused, naming it.
|
|
211
|
+
* type is refused, naming it. A refusal never repeats a look's token.
|
|
160
212
|
*/
|
|
161
213
|
function readClient(value) {
|
|
162
214
|
if (value === undefined || value === null)
|
|
163
215
|
return null;
|
|
164
216
|
if (!isPlainObject(value))
|
|
165
217
|
return 'client must be an object';
|
|
166
|
-
const
|
|
218
|
+
const vision = readTurnVision(value.vision, 'client.vision');
|
|
219
|
+
if (typeof vision === 'string')
|
|
220
|
+
return vision;
|
|
221
|
+
const ui = readClientUi(value.ui);
|
|
222
|
+
if (typeof ui === 'string')
|
|
223
|
+
return ui;
|
|
224
|
+
return { ui, vision };
|
|
225
|
+
}
|
|
226
|
+
/** The request's `client.ui`, or why it is not one. */
|
|
227
|
+
function readClientUi(raw) {
|
|
167
228
|
if (raw === undefined || raw === null)
|
|
168
|
-
return
|
|
229
|
+
return null;
|
|
169
230
|
if (!isPlainObject(raw))
|
|
170
231
|
return 'client.ui must be an object';
|
|
171
232
|
const bytes = Buffer.byteLength(JSON.stringify(raw));
|
|
@@ -188,7 +249,7 @@ function readClient(value) {
|
|
|
188
249
|
return `client.ui.${field} must be an object`;
|
|
189
250
|
ui[field] = v;
|
|
190
251
|
}
|
|
191
|
-
return
|
|
252
|
+
return ui;
|
|
192
253
|
}
|
|
193
254
|
/** Whether `input` says the message was typed during the call. */
|
|
194
255
|
function isTyped(input) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/live-call/protocol.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/live-call/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAuC,MAAM,qBAAqB,CAAC;AAC7G,OAAO,EAAE,aAAa,EAAE,cAAc,EAAmB,MAAM,qBAAqB,CAAC;AAErF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,SAAS,EAAE,SAAS,EAA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C,KAAK,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,kEAAkE;AAClE,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAK,KAA4B,CAAC,IAAI,KAAK,0BAA0B,CAAC;AACnH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAqC;IACxE,UAAU,EAAE,+CAA+C;IAC3D,mBAAmB,EAAE,oCAAoC;IACzD,aAAa,EAAE,sBAAsB;IACrC,YAAY,EAAE,qBAAqB;IACnC,sBAAsB,EAAE,2BAA2B;IACnD,YAAY,EAAE,0EAA0E;IACxF,aAAa,EAAE,uCAAuC;IACtD,YAAY,EAAE,kBAAkB;CACjC,CAAC;AAEF,4CAA4C;AAC5C,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,wBAAwB,CAAC,IAAI,CAAC,IAAI,wBAAwB,CAAC,YAAY,EAAE,CAAC;AACpG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,YAAY,EAAmE,MAAM,IAAI,CAAC;AAmBxG,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,YAAY,EAAmE,MAAM,IAAI,CAAC;AAmBxG,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AA2FtH;;;GAG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AoCf"}
|
package/dist/orchestrator.js
CHANGED
|
@@ -36,6 +36,8 @@ import { stepMessages as forStep, STEP_NOTE_CLOSE, STEP_NOTE_OPEN } from './step
|
|
|
36
36
|
import { clockText, readClientTimeZone } from './prompt/clock.js';
|
|
37
37
|
import { readClientMessageInput, spokenInputText } from './prompt/spoken-input.js';
|
|
38
38
|
import { readClientReplyOutput, spokenReplyText } from './prompt/spoken-reply.js';
|
|
39
|
+
import { visionText } from './prompt/vision.js';
|
|
40
|
+
import { lookTool } from './vision/look-tool.js';
|
|
39
41
|
import { AttachmentGuard } from './attachments/guard.js';
|
|
40
42
|
import { ATTACHMENT_DATA_NOTE, turnAttachmentParts, withReferenceLines, withTurnAttachments, withoutLeftOut } from './attachments/content.js';
|
|
41
43
|
import { attachmentTools } from './attachments/tools.js';
|
|
@@ -213,6 +215,10 @@ export async function runAgentTurn(config, input) {
|
|
|
213
215
|
conversationUsed: conversationFileTokens,
|
|
214
216
|
});
|
|
215
217
|
const fileTools = fileArea ? attachmentTools({ store: fileArea.store, owner: fileOwner, guard: fileGuard }) : [];
|
|
218
|
+
// The caller's camera is looked at only when the model chooses to (vision/look-tool.ts): no turn carries a picture.
|
|
219
|
+
const visionTools = input.vision?.canLook && input.vision.look ? [lookTool(input.vision.look)] : [];
|
|
220
|
+
// The SDK's own tools: they take their names before the host's.
|
|
221
|
+
const sdkTools = [...fileTools, ...visionTools];
|
|
216
222
|
log('info', 'agent:ui', 'UI surfaces for this turn', {
|
|
217
223
|
turnId,
|
|
218
224
|
clientSentSnapshot: client !== null,
|
|
@@ -454,6 +460,8 @@ export async function runAgentTurn(config, input) {
|
|
|
454
460
|
const executeCall = async (t, rawArgs, toolUseId, uiSlot, approved) => {
|
|
455
461
|
const startMs = Date.now();
|
|
456
462
|
const isUI = t.kind === 'ui';
|
|
463
|
+
// A tool whose input speaks of the person (a look's question) is said to have been called, and no more.
|
|
464
|
+
const shownInput = (value) => (t.inputPrivate ? {} : value);
|
|
457
465
|
// A stopped turn starts nothing more.
|
|
458
466
|
if (stopState.reason())
|
|
459
467
|
return { text: resultText(stoppedNotRun(t.name)), ran: false };
|
|
@@ -470,7 +478,7 @@ export async function runAgentTurn(config, input) {
|
|
|
470
478
|
turnId,
|
|
471
479
|
toolUseId,
|
|
472
480
|
name: t.name,
|
|
473
|
-
input: given,
|
|
481
|
+
input: shownInput(given),
|
|
474
482
|
timestamp: now,
|
|
475
483
|
});
|
|
476
484
|
await emitAfterText(AGENT_SOCKET_EVENTS.TOOL_CALL_COMPLETE, {
|
|
@@ -755,7 +763,7 @@ export async function runAgentTurn(config, input) {
|
|
|
755
763
|
turnId,
|
|
756
764
|
toolName: t.name,
|
|
757
765
|
kind: t.kind ?? 'backend',
|
|
758
|
-
input: args,
|
|
766
|
+
...(t.inputPrivate ? { inputPrivate: true } : { input: args }),
|
|
759
767
|
...(approved ? { approvalId: approved.approvalId } : {}),
|
|
760
768
|
});
|
|
761
769
|
// Emit tool call started BEFORE execution
|
|
@@ -763,7 +771,7 @@ export async function runAgentTurn(config, input) {
|
|
|
763
771
|
turnId,
|
|
764
772
|
toolUseId,
|
|
765
773
|
name: t.name,
|
|
766
|
-
input: callArgs,
|
|
774
|
+
input: shownInput(callArgs),
|
|
767
775
|
timestamp: startMs,
|
|
768
776
|
});
|
|
769
777
|
// Execute with timeout
|
|
@@ -1072,9 +1080,9 @@ export async function runAgentTurn(config, input) {
|
|
|
1072
1080
|
// with the id of an action of the page, is withheld: for a
|
|
1073
1081
|
// UI-only agent, the page is the authority.
|
|
1074
1082
|
function hostTools(ui) {
|
|
1075
|
-
const sdkOwned = new Set(
|
|
1083
|
+
const sdkOwned = new Set(sdkTools.map((t) => t.name));
|
|
1076
1084
|
if (!ui)
|
|
1077
|
-
return [...config.tools.tools.filter((t) => !sdkOwned.has(t.name)), ...
|
|
1085
|
+
return [...config.tools.tools.filter((t) => !sdkOwned.has(t.name)), ...sdkTools];
|
|
1078
1086
|
const taken = (name) => sdkOwned.has(name) || ui.actions.has(name) || UI_TOOL_NAMES.has(name);
|
|
1079
1087
|
const withheld = config.tools.tools.filter((t) => taken(t.name)).map((t) => t.name);
|
|
1080
1088
|
if (withheld.length > 0) {
|
|
@@ -1083,7 +1091,7 @@ export async function runAgentTurn(config, input) {
|
|
|
1083
1091
|
withheld,
|
|
1084
1092
|
});
|
|
1085
1093
|
}
|
|
1086
|
-
return [...config.tools.tools.filter((t) => !taken(t.name)), ...
|
|
1094
|
+
return [...config.tools.tools.filter((t) => !taken(t.name)), ...sdkTools];
|
|
1087
1095
|
}
|
|
1088
1096
|
/** Every tool a call can name: the host's, and the page's actions. What an approved call is looked up in. */
|
|
1089
1097
|
function callableTools() {
|
|
@@ -1157,8 +1165,8 @@ export async function runAgentTurn(config, input) {
|
|
|
1157
1165
|
function describeStepTool(name) {
|
|
1158
1166
|
if (UI_TOOL_NAMES.has(name))
|
|
1159
1167
|
return { name, kind: 'ui' };
|
|
1160
|
-
// The SDK's own
|
|
1161
|
-
const registered =
|
|
1168
|
+
// The SDK's own tools take their names before the host's (hostTools).
|
|
1169
|
+
const registered = sdkTools.find((t) => t.name === name) ?? config.tools.tools.find((t) => t.name === name);
|
|
1162
1170
|
if (!registered)
|
|
1163
1171
|
return { name, kind: 'builtin' };
|
|
1164
1172
|
return { name, kind: registered.kind === 'ui' ? 'ui' : 'backend', ...(registered.toolClass ? { toolClass: registered.toolClass } : {}) };
|
|
@@ -1670,6 +1678,8 @@ export async function runAgentTurn(config, input) {
|
|
|
1670
1678
|
const turnSpoken = input.approval || input.resume ? null : readClientMessageInput(input.context ?? null);
|
|
1671
1679
|
// The reply is spoken on every turn of a call, the turn an approval continues included.
|
|
1672
1680
|
const turnSpokenReply = readClientReplyOutput(input.context ?? null);
|
|
1681
|
+
// Whether the model may look at the person, and how, or why it cannot (prompt/vision.ts): a line after the conversation.
|
|
1682
|
+
const turnVisionText = visionText(input.vision);
|
|
1673
1683
|
const turnPageValues = client && client.page.length > 0
|
|
1674
1684
|
? [
|
|
1675
1685
|
observationsText(client.observations, config.ui?.maxObservationChars ?? DEFAULT_PAGE_STATE_CHARS, {
|
|
@@ -1702,6 +1712,8 @@ export async function runAgentTurn(config, input) {
|
|
|
1702
1712
|
...(turnSpoken ? [spokenInputText(turnSpoken)] : []),
|
|
1703
1713
|
// A reply a voice will read out is written for the ear (prompt/spoken-reply.ts).
|
|
1704
1714
|
...(turnSpokenReply ? [spokenReplyText(turnSpokenReply)] : []),
|
|
1715
|
+
// When the model may look at the person, or that it cannot see them and why.
|
|
1716
|
+
...(turnVisionText ? [turnVisionText] : []),
|
|
1705
1717
|
...(expired.outcomes.length > 0 ? [expiredNote(expired)] : []),
|
|
1706
1718
|
...(input.stepContext?.trim() ? [input.stepContext.trim()] : []),
|
|
1707
1719
|
...(notes.length > 0 ? [[STEP_NOTE_OPEN, ...notes, STEP_NOTE_CLOSE].join('\n')] : []),
|
|
@@ -2414,6 +2426,11 @@ turnMessageAt = null) {
|
|
|
2414
2426
|
continue;
|
|
2415
2427
|
}
|
|
2416
2428
|
if (msg.role === 'user') {
|
|
2429
|
+
// A blank message with no files says nothing, and a model provider refuses an empty text block: a host
|
|
2430
|
+
// that stored a live call's glance as the empty words it carried (`request.text`) is read past, and
|
|
2431
|
+
// the turn's own message is then the one it was given (`currentContent`, below).
|
|
2432
|
+
if (!(typeof msg.content === 'string' && msg.content.trim()) && !msg.attachments?.length)
|
|
2433
|
+
continue;
|
|
2417
2434
|
// A message's files are in history as their reference lines, never their content.
|
|
2418
2435
|
messages.push({ role: 'user', content: idx === turnMessageAt ? msg.content : withReferenceLines(msg.content, msg.attachments ?? undefined) });
|
|
2419
2436
|
}
|