@ouispec/agent-worker 0.27.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 +13 -13
- package/dist/authz/tool-policy.d.ts +5 -5
- package/dist/authz/tool-policy.d.ts.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/live-call/handler.d.ts +6 -5
- package/dist/live-call/handler.d.ts.map +1 -1
- package/dist/live-call/handler.js +15 -13
- package/dist/live-call/handler.js.map +1 -1
- package/dist/live-call/protocol.d.ts +30 -27
- package/dist/live-call/protocol.d.ts.map +1 -1
- package/dist/live-call/protocol.js +37 -31
- package/dist/live-call/protocol.js.map +1 -1
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +19 -14
- package/dist/orchestrator.js.map +1 -1
- package/dist/prompt/vision.d.ts +62 -55
- package/dist/prompt/vision.d.ts.map +1 -1
- package/dist/prompt/vision.js +106 -80
- package/dist/prompt/vision.js.map +1 -1
- package/dist/runtime/turn-runner.js +1 -1
- package/dist/runtime/turn-runner.js.map +1 -1
- package/dist/runtime/types.d.ts +6 -6
- package/dist/step-messages.d.ts +2 -6
- package/dist/step-messages.d.ts.map +1 -1
- package/dist/step-messages.js +3 -7
- package/dist/step-messages.js.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 +4 -4
- 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 +1 -1
|
@@ -23,24 +23,26 @@
|
|
|
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
|
|
26
|
+
* `client.vision`, when the character may see the caller, is
|
|
27
27
|
*
|
|
28
|
-
* { seeing, remarks,
|
|
29
|
-
*
|
|
28
|
+
* { seeing, remarks, canLook, absent: 'camera_off' | 'turned_off' | null,
|
|
29
|
+
* look: { url, token, expiresAt } | null, observation: '<one sentence>' | null }
|
|
30
30
|
*
|
|
31
|
-
*
|
|
32
|
-
* bring up what it sees unprompted.
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
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.
|
|
38
39
|
*
|
|
39
40
|
* A `glance` turn is the call service's look between turns: nobody has spoken
|
|
40
|
-
* for a while and
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* with no `text`, and the
|
|
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.
|
|
44
46
|
*
|
|
45
47
|
* and the answer is `200 text/event-stream`:
|
|
46
48
|
*
|
|
@@ -86,14 +88,16 @@ export function liveCallOpeningMessage(request) {
|
|
|
86
88
|
}
|
|
87
89
|
/**
|
|
88
90
|
* The person's message for a `glance` turn, as the model reads it: an
|
|
89
|
-
* instruction to
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* the opening's
|
|
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.
|
|
93
96
|
*/
|
|
94
|
-
export const LIVE_CALL_GLANCE_MESSAGE = '<call_glance>Nobody has spoken for a few seconds, and
|
|
95
|
-
'
|
|
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. ' +
|
|
97
101
|
'Otherwise answer with nothing at all, not a word or a mark, and the call stays silent. ' +
|
|
98
102
|
'Never repeat a remark you have already made in this call.</call_glance>';
|
|
99
103
|
/**
|
|
@@ -116,8 +120,8 @@ export const LIVE_CALL_LIMITS = {
|
|
|
116
120
|
disclosureLineChars: 1_000,
|
|
117
121
|
/** The most `client.ui` may weigh, as UTF-8 JSON: the bound the page and the call service hold it to. */
|
|
118
122
|
clientUiBytes: 64 * 1024,
|
|
119
|
-
/** The longest `client.vision.
|
|
120
|
-
|
|
123
|
+
/** The longest `client.vision.observation` (`VISION_LIMITS.observationChars`). */
|
|
124
|
+
visionObservationChars: VISION_LIMITS.observationChars,
|
|
121
125
|
};
|
|
122
126
|
/** An id: letters, digits and `.` `_` `:` `-`, starting with a letter or digit. */
|
|
123
127
|
const ID = new RegExp(`^[A-Za-z0-9][A-Za-z0-9._:-]{0,${LIVE_CALL_LIMITS.idChars - 1}}$`);
|
|
@@ -168,16 +172,18 @@ export function readLiveCallTurnRequest(body) {
|
|
|
168
172
|
(typeof disclosureLine !== 'string' || disclosureLine.length > LIVE_CALL_LIMITS.disclosureLineChars || CONTROL.test(disclosureLine))) {
|
|
169
173
|
return refuse(`disclosureLine must be a string of at most ${LIVE_CALL_LIMITS.disclosureLineChars} characters with no control characters`);
|
|
170
174
|
}
|
|
171
|
-
const
|
|
172
|
-
if (typeof
|
|
173
|
-
return refuse(
|
|
175
|
+
const read = readClient(b.client);
|
|
176
|
+
if (typeof read === 'string')
|
|
177
|
+
return refuse(read);
|
|
174
178
|
if (kind === 'glance') {
|
|
175
|
-
// A glance
|
|
176
|
-
if (!
|
|
177
|
-
return refuse('a glance turn needs client.vision.frame');
|
|
178
|
-
if (!client.vision.remarks)
|
|
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)
|
|
179
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');
|
|
180
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;
|
|
181
187
|
return {
|
|
182
188
|
ok: true,
|
|
183
189
|
request: {
|
|
@@ -202,7 +208,7 @@ function isPlainObject(value) {
|
|
|
202
208
|
/**
|
|
203
209
|
* The request's `client`, or why it is not one. Fields it does not know are
|
|
204
210
|
* left out, so a newer call service is read past; a known field of the wrong
|
|
205
|
-
* type is refused, naming it. A refusal never repeats a
|
|
211
|
+
* type is refused, naming it. A refusal never repeats a look's token.
|
|
206
212
|
*/
|
|
207
213
|
function readClient(value) {
|
|
208
214
|
if (value === undefined || value === null)
|
|
@@ -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;;;;;;;;;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jF;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,7 +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 {
|
|
39
|
+
import { visionText } from './prompt/vision.js';
|
|
40
|
+
import { lookTool } from './vision/look-tool.js';
|
|
40
41
|
import { AttachmentGuard } from './attachments/guard.js';
|
|
41
42
|
import { ATTACHMENT_DATA_NOTE, turnAttachmentParts, withReferenceLines, withTurnAttachments, withoutLeftOut } from './attachments/content.js';
|
|
42
43
|
import { attachmentTools } from './attachments/tools.js';
|
|
@@ -214,6 +215,10 @@ export async function runAgentTurn(config, input) {
|
|
|
214
215
|
conversationUsed: conversationFileTokens,
|
|
215
216
|
});
|
|
216
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];
|
|
217
222
|
log('info', 'agent:ui', 'UI surfaces for this turn', {
|
|
218
223
|
turnId,
|
|
219
224
|
clientSentSnapshot: client !== null,
|
|
@@ -455,6 +460,8 @@ export async function runAgentTurn(config, input) {
|
|
|
455
460
|
const executeCall = async (t, rawArgs, toolUseId, uiSlot, approved) => {
|
|
456
461
|
const startMs = Date.now();
|
|
457
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);
|
|
458
465
|
// A stopped turn starts nothing more.
|
|
459
466
|
if (stopState.reason())
|
|
460
467
|
return { text: resultText(stoppedNotRun(t.name)), ran: false };
|
|
@@ -471,7 +478,7 @@ export async function runAgentTurn(config, input) {
|
|
|
471
478
|
turnId,
|
|
472
479
|
toolUseId,
|
|
473
480
|
name: t.name,
|
|
474
|
-
input: given,
|
|
481
|
+
input: shownInput(given),
|
|
475
482
|
timestamp: now,
|
|
476
483
|
});
|
|
477
484
|
await emitAfterText(AGENT_SOCKET_EVENTS.TOOL_CALL_COMPLETE, {
|
|
@@ -756,7 +763,7 @@ export async function runAgentTurn(config, input) {
|
|
|
756
763
|
turnId,
|
|
757
764
|
toolName: t.name,
|
|
758
765
|
kind: t.kind ?? 'backend',
|
|
759
|
-
input: args,
|
|
766
|
+
...(t.inputPrivate ? { inputPrivate: true } : { input: args }),
|
|
760
767
|
...(approved ? { approvalId: approved.approvalId } : {}),
|
|
761
768
|
});
|
|
762
769
|
// Emit tool call started BEFORE execution
|
|
@@ -764,7 +771,7 @@ export async function runAgentTurn(config, input) {
|
|
|
764
771
|
turnId,
|
|
765
772
|
toolUseId,
|
|
766
773
|
name: t.name,
|
|
767
|
-
input: callArgs,
|
|
774
|
+
input: shownInput(callArgs),
|
|
768
775
|
timestamp: startMs,
|
|
769
776
|
});
|
|
770
777
|
// Execute with timeout
|
|
@@ -1073,9 +1080,9 @@ export async function runAgentTurn(config, input) {
|
|
|
1073
1080
|
// with the id of an action of the page, is withheld: for a
|
|
1074
1081
|
// UI-only agent, the page is the authority.
|
|
1075
1082
|
function hostTools(ui) {
|
|
1076
|
-
const sdkOwned = new Set(
|
|
1083
|
+
const sdkOwned = new Set(sdkTools.map((t) => t.name));
|
|
1077
1084
|
if (!ui)
|
|
1078
|
-
return [...config.tools.tools.filter((t) => !sdkOwned.has(t.name)), ...
|
|
1085
|
+
return [...config.tools.tools.filter((t) => !sdkOwned.has(t.name)), ...sdkTools];
|
|
1079
1086
|
const taken = (name) => sdkOwned.has(name) || ui.actions.has(name) || UI_TOOL_NAMES.has(name);
|
|
1080
1087
|
const withheld = config.tools.tools.filter((t) => taken(t.name)).map((t) => t.name);
|
|
1081
1088
|
if (withheld.length > 0) {
|
|
@@ -1084,7 +1091,7 @@ export async function runAgentTurn(config, input) {
|
|
|
1084
1091
|
withheld,
|
|
1085
1092
|
});
|
|
1086
1093
|
}
|
|
1087
|
-
return [...config.tools.tools.filter((t) => !taken(t.name)), ...
|
|
1094
|
+
return [...config.tools.tools.filter((t) => !taken(t.name)), ...sdkTools];
|
|
1088
1095
|
}
|
|
1089
1096
|
/** Every tool a call can name: the host's, and the page's actions. What an approved call is looked up in. */
|
|
1090
1097
|
function callableTools() {
|
|
@@ -1158,8 +1165,8 @@ export async function runAgentTurn(config, input) {
|
|
|
1158
1165
|
function describeStepTool(name) {
|
|
1159
1166
|
if (UI_TOOL_NAMES.has(name))
|
|
1160
1167
|
return { name, kind: 'ui' };
|
|
1161
|
-
// The SDK's own
|
|
1162
|
-
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);
|
|
1163
1170
|
if (!registered)
|
|
1164
1171
|
return { name, kind: 'builtin' };
|
|
1165
1172
|
return { name, kind: registered.kind === 'ui' ? 'ui' : 'backend', ...(registered.toolClass ? { toolClass: registered.toolClass } : {}) };
|
|
@@ -1671,10 +1678,8 @@ export async function runAgentTurn(config, input) {
|
|
|
1671
1678
|
const turnSpoken = input.approval || input.resume ? null : readClientMessageInput(input.context ?? null);
|
|
1672
1679
|
// The reply is spoken on every turn of a call, the turn an approval continues included.
|
|
1673
1680
|
const turnSpokenReply = readClientReplyOutput(input.context ?? null);
|
|
1674
|
-
//
|
|
1681
|
+
// Whether the model may look at the person, and how, or why it cannot (prompt/vision.ts): a line after the conversation.
|
|
1675
1682
|
const turnVisionText = visionText(input.vision);
|
|
1676
|
-
const turnVisionPicture = visionImagePart(input.vision);
|
|
1677
|
-
const turnPictures = turnVisionPicture ? [turnVisionPicture] : [];
|
|
1678
1683
|
const turnPageValues = client && client.page.length > 0
|
|
1679
1684
|
? [
|
|
1680
1685
|
observationsText(client.observations, config.ui?.maxObservationChars ?? DEFAULT_PAGE_STATE_CHARS, {
|
|
@@ -1707,7 +1712,7 @@ export async function runAgentTurn(config, input) {
|
|
|
1707
1712
|
...(turnSpoken ? [spokenInputText(turnSpoken)] : []),
|
|
1708
1713
|
// A reply a voice will read out is written for the ear (prompt/spoken-reply.ts).
|
|
1709
1714
|
...(turnSpokenReply ? [spokenReplyText(turnSpokenReply)] : []),
|
|
1710
|
-
//
|
|
1715
|
+
// When the model may look at the person, or that it cannot see them and why.
|
|
1711
1716
|
...(turnVisionText ? [turnVisionText] : []),
|
|
1712
1717
|
...(expired.outcomes.length > 0 ? [expiredNote(expired)] : []),
|
|
1713
1718
|
...(input.stepContext?.trim() ? [input.stepContext.trim()] : []),
|
|
@@ -1887,7 +1892,7 @@ export async function runAgentTurn(config, input) {
|
|
|
1887
1892
|
const stepMessages = leftOut.length > 0 && messages ? withoutLeftOut(trimmed?.messages ?? messages, leftOut) : trimmed?.messages ?? messages;
|
|
1888
1893
|
return {
|
|
1889
1894
|
...constraints,
|
|
1890
|
-
...(stepMessages ? { messages: forStep(stepMessages, stepTail(notes), cachePoint
|
|
1895
|
+
...(stepMessages ? { messages: forStep(stepMessages, stepTail(notes), cachePoint) } : {}),
|
|
1891
1896
|
instructions,
|
|
1892
1897
|
};
|
|
1893
1898
|
},
|