@ouispec/agent-worker 0.25.2 → 0.27.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/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 +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/live-call/handler.d.ts +18 -1
- package/dist/live-call/handler.d.ts.map +1 -1
- package/dist/live-call/handler.js +52 -6
- package/dist/live-call/handler.js.map +1 -1
- package/dist/live-call/protocol.d.ts +51 -7
- package/dist/live-call/protocol.d.ts.map +1 -1
- package/dist/live-call/protocol.js +68 -13
- package/dist/live-call/protocol.js.map +1 -1
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +13 -1
- package/dist/orchestrator.js.map +1 -1
- package/dist/prompt/vision.d.ts +85 -0
- package/dist/prompt/vision.d.ts.map +1 -0
- package/dist/prompt/vision.js +151 -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/step-messages.d.ts +6 -2
- package/dist/step-messages.d.ts.map +1 -1
- package/dist/step-messages.js +7 -3
- package/dist/step-messages.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -5
|
@@ -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,25 @@
|
|
|
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 can see the caller, is
|
|
27
|
+
*
|
|
28
|
+
* { seeing, remarks, frame: { mediaType, data, width, height, capturedAt } | null,
|
|
29
|
+
* absent: 'camera_off' | 'turned_off' | 'stale' | null }
|
|
30
|
+
*
|
|
31
|
+
* `seeing`: the character receives the caller's camera; `remarks`: it may
|
|
32
|
+
* bring up what it sees unprompted. `frame` is the caller's latest camera
|
|
33
|
+
* frame (JPEG, PNG or WebP, base64, at most 256 KiB), given to the model as a
|
|
34
|
+
* picture with this turn only; `absent` says why none came. The model is told
|
|
35
|
+
* what it may do with the picture (answer about it, remark on it only when
|
|
36
|
+
* `remarks`), or that it cannot see the caller and why. The frame is never
|
|
37
|
+
* logged, emitted or stored, and the next turn does not send it again.
|
|
38
|
+
*
|
|
39
|
+
* A `glance` turn is the call service's look between turns: nobody has spoken
|
|
40
|
+
* for a while and the picture changed. `text` is empty, `client.vision` has a
|
|
41
|
+
* frame and `remarks` is on. The model says one short remark if something in
|
|
42
|
+
* the picture is worth one, and otherwise nothing: an empty answer is `done`
|
|
43
|
+
* with no `text`, and the call stays silent.
|
|
44
|
+
*
|
|
26
45
|
* and the answer is `200 text/event-stream`:
|
|
27
46
|
*
|
|
28
47
|
* event: text data: { "text": "…" } the reply, piece by piece
|
|
@@ -33,8 +52,14 @@
|
|
|
33
52
|
* with `: keep-alive` comments while nothing else is sent.
|
|
34
53
|
*/
|
|
35
54
|
import { readMessageInput, readReplyOutput } from '@ouispec/agent-core';
|
|
36
|
-
|
|
37
|
-
|
|
55
|
+
import { VISION_LIMITS, readTurnVision } from '../prompt/vision.js';
|
|
56
|
+
/**
|
|
57
|
+
* `message`: the person said `text`. `opening`: the call has just connected;
|
|
58
|
+
* nothing has been said, and the agent greets. `glance`: nobody has spoken for
|
|
59
|
+
* a while and the caller's picture changed; the agent remarks on it, or says
|
|
60
|
+
* nothing.
|
|
61
|
+
*/
|
|
62
|
+
export const LIVE_CALL_TURN_KINDS = ['message', 'opening', 'glance'];
|
|
38
63
|
/**
|
|
39
64
|
* The person's message for an `opening` turn: an instruction to greet, which
|
|
40
65
|
* the model reads where the person's words would be. A host that stores the
|
|
@@ -59,6 +84,18 @@ export function liveCallOpeningMessage(request) {
|
|
|
59
84
|
'Greet them in a sentence or two, following on from that without repeating it, and ask what they would like help with. ' +
|
|
60
85
|
'This is not a message from the user.</call_opening>');
|
|
61
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* The person's message for a `glance` turn, as the model reads it: an
|
|
89
|
+
* instruction to remark on the picture only if something in it is worth a
|
|
90
|
+
* remark, and otherwise to say nothing, so the call stays silent. A host that
|
|
91
|
+
* stores the person's messages stores this for the glance turn, as it stores
|
|
92
|
+
* the opening's.
|
|
93
|
+
*/
|
|
94
|
+
export const LIVE_CALL_GLANCE_MESSAGE = '<call_glance>Nobody has spoken for a few seconds, and the picture from the user’s camera has changed. This is not a message from the user. ' +
|
|
95
|
+
'If, and only if, something in the picture is worth remarking on (they hold something up, put something on, someone else appears), ' +
|
|
96
|
+
'say one short remark about it, in a sentence, and call no tools. ' +
|
|
97
|
+
'Otherwise answer with nothing at all, not a word or a mark, and the call stays silent. ' +
|
|
98
|
+
'Never repeat a remark you have already made in this call.</call_glance>';
|
|
62
99
|
/**
|
|
63
100
|
* The `input` mode of a message the person typed during the call. It is read
|
|
64
101
|
* as typed: the turn's context carries no `input`, as for a message typed in
|
|
@@ -79,6 +116,8 @@ export const LIVE_CALL_LIMITS = {
|
|
|
79
116
|
disclosureLineChars: 1_000,
|
|
80
117
|
/** The most `client.ui` may weigh, as UTF-8 JSON: the bound the page and the call service hold it to. */
|
|
81
118
|
clientUiBytes: 64 * 1024,
|
|
119
|
+
/** The longest `client.vision.frame.data`, in base64 characters (`VISION_LIMITS.frameDataChars`). */
|
|
120
|
+
visionFrameChars: VISION_LIMITS.frameDataChars,
|
|
82
121
|
};
|
|
83
122
|
/** An id: letters, digits and `.` `_` `:` `-`, starting with a letter or digit. */
|
|
84
123
|
const ID = new RegExp(`^[A-Za-z0-9][A-Za-z0-9._:-]{0,${LIVE_CALL_LIMITS.idChars - 1}}$`);
|
|
@@ -104,15 +143,15 @@ export function readLiveCallTurnRequest(body) {
|
|
|
104
143
|
return refuse(`kind must be one of ${LIVE_CALL_TURN_KINDS.join(', ')}`);
|
|
105
144
|
}
|
|
106
145
|
const kind = b.kind;
|
|
107
|
-
const text = b.text === undefined && kind
|
|
146
|
+
const text = b.text === undefined && kind !== 'message' ? '' : b.text;
|
|
108
147
|
if (typeof text !== 'string')
|
|
109
148
|
return refuse('text must be a string');
|
|
110
149
|
if (text.length > LIVE_CALL_LIMITS.textChars)
|
|
111
150
|
return refuse(`text is longer than ${LIVE_CALL_LIMITS.textChars} characters`);
|
|
112
151
|
if (kind === 'message' && !text.trim())
|
|
113
152
|
return refuse('a message turn needs the text the person said');
|
|
114
|
-
if (kind
|
|
115
|
-
return refuse('an opening turn carries no text
|
|
153
|
+
if (kind !== 'message' && text.trim())
|
|
154
|
+
return refuse(`${kind === 'opening' ? 'an opening' : 'a glance'} turn carries no text`);
|
|
116
155
|
for (const field of ['input', 'output']) {
|
|
117
156
|
const value = b[field];
|
|
118
157
|
if (value !== undefined && value !== null && (typeof value !== 'object' || Array.isArray(value)))
|
|
@@ -132,6 +171,13 @@ export function readLiveCallTurnRequest(body) {
|
|
|
132
171
|
const client = readClient(b.client);
|
|
133
172
|
if (typeof client === 'string')
|
|
134
173
|
return refuse(client);
|
|
174
|
+
if (kind === 'glance') {
|
|
175
|
+
// A glance is a look at the picture: without one, or without leave to remark on it, there is nothing to run.
|
|
176
|
+
if (!client?.vision?.frame)
|
|
177
|
+
return refuse('a glance turn needs client.vision.frame');
|
|
178
|
+
if (!client.vision.remarks)
|
|
179
|
+
return refuse('a glance turn needs client.vision.remarks on');
|
|
180
|
+
}
|
|
135
181
|
return {
|
|
136
182
|
ok: true,
|
|
137
183
|
request: {
|
|
@@ -139,9 +185,9 @@ export function readLiveCallTurnRequest(body) {
|
|
|
139
185
|
clientRef,
|
|
140
186
|
turnId: b.turnId,
|
|
141
187
|
kind,
|
|
142
|
-
text: kind === '
|
|
143
|
-
// Nothing was said on an opening
|
|
144
|
-
input: kind
|
|
188
|
+
text: kind === 'message' ? text : '',
|
|
189
|
+
// Nothing was said on an opening or a glance, so nothing was entered; a typed message is read as typed.
|
|
190
|
+
input: kind !== 'message' || isTyped(b.input) ? null : readMessageInput(b.input),
|
|
145
191
|
output: readReplyOutput(b.output),
|
|
146
192
|
supersedes: [...new Set(supersedes)].filter((id) => id !== b.turnId),
|
|
147
193
|
// Said before the greeting: an opening turn's alone.
|
|
@@ -156,16 +202,25 @@ function isPlainObject(value) {
|
|
|
156
202
|
/**
|
|
157
203
|
* The request's `client`, or why it is not one. Fields it does not know are
|
|
158
204
|
* left out, so a newer call service is read past; a known field of the wrong
|
|
159
|
-
* type is refused, naming it.
|
|
205
|
+
* type is refused, naming it. A refusal never repeats a frame's data.
|
|
160
206
|
*/
|
|
161
207
|
function readClient(value) {
|
|
162
208
|
if (value === undefined || value === null)
|
|
163
209
|
return null;
|
|
164
210
|
if (!isPlainObject(value))
|
|
165
211
|
return 'client must be an object';
|
|
166
|
-
const
|
|
212
|
+
const vision = readTurnVision(value.vision, 'client.vision');
|
|
213
|
+
if (typeof vision === 'string')
|
|
214
|
+
return vision;
|
|
215
|
+
const ui = readClientUi(value.ui);
|
|
216
|
+
if (typeof ui === 'string')
|
|
217
|
+
return ui;
|
|
218
|
+
return { ui, vision };
|
|
219
|
+
}
|
|
220
|
+
/** The request's `client.ui`, or why it is not one. */
|
|
221
|
+
function readClientUi(raw) {
|
|
167
222
|
if (raw === undefined || raw === null)
|
|
168
|
-
return
|
|
223
|
+
return null;
|
|
169
224
|
if (!isPlainObject(raw))
|
|
170
225
|
return 'client.ui must be an object';
|
|
171
226
|
const bytes = Buffer.byteLength(JSON.stringify(raw));
|
|
@@ -188,7 +243,7 @@ function readClient(value) {
|
|
|
188
243
|
return `client.ui.${field} must be an object`;
|
|
189
244
|
ui[field] = v;
|
|
190
245
|
}
|
|
191
|
-
return
|
|
246
|
+
return ui;
|
|
192
247
|
}
|
|
193
248
|
/** Whether `input` says the message was typed during the call. */
|
|
194
249
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;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,EAAE,QAAQ,CAAU,CAAC;AAyG9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GACpC,mGAAmG;IACnG,8HAA8H,CAAC;AAEjI;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAoD;IACzF,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC;IAClD,IAAI,CAAC,UAAU;QAAE,OAAO,yBAAyB,CAAC;IAClD,OAAO,CACL,mGAAmG;QACnG,sDAAsD,UAAU,IAAI;QACpE,wHAAwH;QACxH,qDAAqD,CACtD,CAAC;AACJ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AAI,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;AA0FtH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,yEAA0E,CAAC;AAExG,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,oBAAoB,CAAC;AAEtD,kFAAkF;AAClF,eAAO,MAAM,yBAAyB,QAE+D,CAAC;AAwCtG;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,eAAe,CAAC,CAw2E1B;AAED,gGAAgG;AAChG,eAAO,MAAM,cAAc,QAIzB,CAAC;AAEH;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,kBAAkB,EAAE,EAC7B,cAAc,EAAE,MAAM;AACtB,iGAAiG;AACjG,aAAa,GAAE,MAAM,GAAG,IAAW,GAClC,YAAY,EAAE,CAkLhB;AAED;;;;GAIG;AACH,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,aAAa,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACpH,kIAAkI;IAClI,OAAO,CAAC,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACjF;AASD;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE;IAAE,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,CAAA;CAAE,EACjD,mBAAmB,EAAE,KAAK,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GACnF,WAAW,EAAE,CAoCf"}
|
package/dist/orchestrator.js
CHANGED
|
@@ -36,6 +36,7 @@ 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 { visionImagePart, visionText } from './prompt/vision.js';
|
|
39
40
|
import { AttachmentGuard } from './attachments/guard.js';
|
|
40
41
|
import { ATTACHMENT_DATA_NOTE, turnAttachmentParts, withReferenceLines, withTurnAttachments, withoutLeftOut } from './attachments/content.js';
|
|
41
42
|
import { attachmentTools } from './attachments/tools.js';
|
|
@@ -1670,6 +1671,10 @@ export async function runAgentTurn(config, input) {
|
|
|
1670
1671
|
const turnSpoken = input.approval || input.resume ? null : readClientMessageInput(input.context ?? null);
|
|
1671
1672
|
// The reply is spoken on every turn of a call, the turn an approval continues included.
|
|
1672
1673
|
const turnSpokenReply = readClientReplyOutput(input.context ?? null);
|
|
1674
|
+
// What the person's camera shows now (prompt/vision.ts): its picture and its line, after the conversation.
|
|
1675
|
+
const turnVisionText = visionText(input.vision);
|
|
1676
|
+
const turnVisionPicture = visionImagePart(input.vision);
|
|
1677
|
+
const turnPictures = turnVisionPicture ? [turnVisionPicture] : [];
|
|
1673
1678
|
const turnPageValues = client && client.page.length > 0
|
|
1674
1679
|
? [
|
|
1675
1680
|
observationsText(client.observations, config.ui?.maxObservationChars ?? DEFAULT_PAGE_STATE_CHARS, {
|
|
@@ -1702,6 +1707,8 @@ export async function runAgentTurn(config, input) {
|
|
|
1702
1707
|
...(turnSpoken ? [spokenInputText(turnSpoken)] : []),
|
|
1703
1708
|
// A reply a voice will read out is written for the ear (prompt/spoken-reply.ts).
|
|
1704
1709
|
...(turnSpokenReply ? [spokenReplyText(turnSpokenReply)] : []),
|
|
1710
|
+
// What the model may do with the picture of the person, or that it cannot see them and why.
|
|
1711
|
+
...(turnVisionText ? [turnVisionText] : []),
|
|
1705
1712
|
...(expired.outcomes.length > 0 ? [expiredNote(expired)] : []),
|
|
1706
1713
|
...(input.stepContext?.trim() ? [input.stepContext.trim()] : []),
|
|
1707
1714
|
...(notes.length > 0 ? [[STEP_NOTE_OPEN, ...notes, STEP_NOTE_CLOSE].join('\n')] : []),
|
|
@@ -1880,7 +1887,7 @@ export async function runAgentTurn(config, input) {
|
|
|
1880
1887
|
const stepMessages = leftOut.length > 0 && messages ? withoutLeftOut(trimmed?.messages ?? messages, leftOut) : trimmed?.messages ?? messages;
|
|
1881
1888
|
return {
|
|
1882
1889
|
...constraints,
|
|
1883
|
-
...(stepMessages ? { messages: forStep(stepMessages, stepTail(notes), cachePoint) } : {}),
|
|
1890
|
+
...(stepMessages ? { messages: forStep(stepMessages, stepTail(notes), cachePoint, turnPictures) } : {}),
|
|
1884
1891
|
instructions,
|
|
1885
1892
|
};
|
|
1886
1893
|
},
|
|
@@ -2414,6 +2421,11 @@ turnMessageAt = null) {
|
|
|
2414
2421
|
continue;
|
|
2415
2422
|
}
|
|
2416
2423
|
if (msg.role === 'user') {
|
|
2424
|
+
// A blank message with no files says nothing, and a model provider refuses an empty text block: a host
|
|
2425
|
+
// that stored a live call's glance as the empty words it carried (`request.text`) is read past, and
|
|
2426
|
+
// the turn's own message is then the one it was given (`currentContent`, below).
|
|
2427
|
+
if (!(typeof msg.content === 'string' && msg.content.trim()) && !msg.attachments?.length)
|
|
2428
|
+
continue;
|
|
2417
2429
|
// A message's files are in history as their reference lines, never their content.
|
|
2418
2430
|
messages.push({ role: 'user', content: idx === turnMessageAt ? msg.content : withReferenceLines(msg.content, msg.attachments ?? undefined) });
|
|
2419
2431
|
}
|