@ouispec/agent-worker 0.23.2 → 0.25.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 +6 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +146 -53
- package/dist/orchestrator.js.map +1 -1
- package/dist/resume/resumed-calls.d.ts +78 -0
- package/dist/resume/resumed-calls.d.ts.map +1 -0
- package/dist/resume/resumed-calls.js +129 -0
- package/dist/resume/resumed-calls.js.map +1 -0
- package/dist/runtime/turn-runner.d.ts.map +1 -1
- package/dist/runtime/turn-runner.js +19 -3
- package/dist/runtime/turn-runner.js.map +1 -1
- package/dist/runtime/types.d.ts +12 -1
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/stop/results.d.ts +2 -0
- package/dist/stop/results.d.ts.map +1 -1
- package/dist/stop/results.js +8 -0
- package/dist/stop/results.js.map +1 -1
- package/dist/time-hand-back.d.ts +9 -1
- package/dist/time-hand-back.d.ts.map +1 -1
- package/dist/time-hand-back.js +8 -2
- package/dist/time-hand-back.js.map +1 -1
- package/dist/types.d.ts +12 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/action-as-tool.d.ts +1 -1
- package/dist/ui/action-as-tool.js +1 -1
- package/dist/ui/ui-tools.d.ts +60 -8
- package/dist/ui/ui-tools.d.ts.map +1 -1
- package/dist/ui/ui-tools.js +169 -14
- package/dist/ui/ui-tools.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -168,6 +168,12 @@ For a message sent while a turn is running (a barge-in), your API stops the runn
|
|
|
168
168
|
|
|
169
169
|
Every UI action request names its turn (`turnId`). Give the tab's OUI runtime `accept: acceptCurrentTurn(agent.acceptedTurnId)` (`oui-spec`, `@ouispec/agent-react`), and a request a stopped or superseded turn sends late is refused by the tab and stored as not run.
|
|
170
170
|
|
|
171
|
+
## Work that ends after its turn
|
|
172
|
+
|
|
173
|
+
A UI action that starts work (a job, an export) answers "started", and the call waits for its outcome only briefly (`uiActions.jobWaitMs`, 20 s). Work still going then is reported running; the model may wait for it with `ui_wait`. When it ends after the turn, the person's tab resumes the conversation by itself (`settledWork` in `@ouispec/agent-react`'s client config, wired to oui-spec's `runtime.onSettled`): your `sendMessage` callback receives `resume: { requestIds }` beside an empty `content`. Pass it unchanged to the worker as the turn payload's `resume`, and store no user message for it, as for an approval's continuation. `payloadRefusal` refuses `resume` with anything but 1 to 8 non-empty request ids of at most 200 characters, and `resume` together with `approval`.
|
|
174
|
+
|
|
175
|
+
The resumed turn takes each request only when the conversation's history holds the tool call with its id and that call's latest result still says it is running, so a client never reads another conversation's results and an outcome is never reported twice. It reads each final answer from the realtime server (kept 35 minutes after the work ended), gives it to the model as that call's result in the words `ui_wait` uses, in place of "still running", and stores it under the call's own id (the first of `newMessages`), so every later turn reads the outcome. In place of a message, the model is told that nobody wrote, why the turn started, and to tell the person what came of the work after checking the page. A final answer that can no longer be read is said so, and nothing is stored for it. When nothing is left to report, the turn completes at once without calling the model. The turn's logs, its usage line, its result (`AgentTurnResult.resumed`) and `recordTurnComplete` (`resumed`) say which requests it reported, could not read, and left out (`ResumedTurn`).
|
|
176
|
+
|
|
171
177
|
## Files the person attaches
|
|
172
178
|
|
|
173
179
|
A file is uploaded to your storage first, and a message carries its reference (`AttachmentRef`: id, name, checked media type, kind, size, and an image's size in pixels). Put the turn's files on its payload as `attachments`, and the earlier messages' files on their history messages (`TurnHistoryMessage.attachments`). Then give the runtime your file area:
|
package/dist/index.d.ts
CHANGED
|
@@ -55,7 +55,9 @@ export { DEFAULT_INDEX_CHARS, indexDiff, indexLine, indexText, pageActions, page
|
|
|
55
55
|
export { liftAnswerImage, ANSWER_IMAGE_MEDIA_TYPES, MAX_ANSWER_IMAGE_BASE64_CHARS, type AnswerImage } from './ui/answer-image.js';
|
|
56
56
|
export { describeSchema, schemaAt, WHOLE_SCHEMA_CHARS, type SchemaView } from './ui/outline.js';
|
|
57
57
|
export { readClientKnowledge, renderClientKnowledge, withClientKnowledge, CLIENT_KNOWLEDGE_KEY, type ClientKnowledge } from './ui/knowledge.js';
|
|
58
|
-
export { BLIND_REFUSALS_BEFORE_STOP, buildUITools, createPageSight, fitNotes, UI_ACT_TOOL, UI_DESCRIBE_TOOL, UI_READ_TOOL } from './ui/ui-tools.js';
|
|
58
|
+
export { BLIND_REFUSALS_BEFORE_STOP, buildUITools, createPageSight, fitNotes, UI_ACT_TOOL, UI_DESCRIBE_TOOL, UI_READ_TOOL, UI_WAIT_TOOL } from './ui/ui-tools.js';
|
|
59
|
+
export type { RunningWork, RunningWorkLog } from './ui/ui-tools.js';
|
|
60
|
+
export type { ResumedTurn, ResumeIgnoredReason } from './resume/resumed-calls.js';
|
|
59
61
|
export type { PageSight, UIToolDependencies, UIToolCollision } from './ui/ui-tools.js';
|
|
60
62
|
export { createUISequence } from './ui/ui-sequence.js';
|
|
61
63
|
export type { UISequence } from './ui/ui-sequence.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,kBAAkB,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACxJ,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,kB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B,EACvB,aAAa,EACb,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,cAAc,EACd,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,qBAAqB,IAAI,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAG/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,YAAY,EACV,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -47,7 +47,7 @@ export { DEFAULT_INDEX_CHARS, indexDiff, indexLine, indexText, pageActions, page
|
|
|
47
47
|
export { liftAnswerImage, ANSWER_IMAGE_MEDIA_TYPES, MAX_ANSWER_IMAGE_BASE64_CHARS } from './ui/answer-image.js';
|
|
48
48
|
export { describeSchema, schemaAt, WHOLE_SCHEMA_CHARS } from './ui/outline.js';
|
|
49
49
|
export { readClientKnowledge, renderClientKnowledge, withClientKnowledge, CLIENT_KNOWLEDGE_KEY } from './ui/knowledge.js';
|
|
50
|
-
export { BLIND_REFUSALS_BEFORE_STOP, buildUITools, createPageSight, fitNotes, UI_ACT_TOOL, UI_DESCRIBE_TOOL, UI_READ_TOOL } from './ui/ui-tools.js';
|
|
50
|
+
export { BLIND_REFUSALS_BEFORE_STOP, buildUITools, createPageSight, fitNotes, UI_ACT_TOOL, UI_DESCRIBE_TOOL, UI_READ_TOOL, UI_WAIT_TOOL } from './ui/ui-tools.js';
|
|
51
51
|
export { createUISequence } from './ui/ui-sequence.js';
|
|
52
52
|
export { runAgentTurn } from './orchestrator.js';
|
|
53
53
|
// The model seam: any `ai` library model; the worker imports no provider.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,oDAAoD;AACpD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAGvE,oEAAoE;AACpE,iEAAiE;AACjE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAkB/F,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEnF,iEAAiE;AACjE,8EAA8E;AAC9E,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,2BAA2B,EAC3B,8BAA8B,EAC9B,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,4BAA4B,CAAC;AAEpC,O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uBAAuB,CAAC;AAG1F,+EAA+E;AAC/E,mFAAmF;AACnF,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAUrI,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AAUjC,OAAO,EAAE,qBAAqB,IAAI,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE/F,mBAAmB;AACnB,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAU3D,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,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;
|
|
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;AAyFtH;;;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,CAk2E1B;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,CA8KhB;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
|
@@ -41,8 +41,9 @@ import { ATTACHMENT_DATA_NOTE, turnAttachmentParts, withReferenceLines, withTurn
|
|
|
41
41
|
import { attachmentTools } from './attachments/tools.js';
|
|
42
42
|
import { acceptsMediaType, attachmentIdsIn, attachmentNameForModel, misplacedAttachmentInputs } from '@ouispec/agent-core';
|
|
43
43
|
const ATTACHMENT_LIST_HINT = 'attachment_list lists the files that can.';
|
|
44
|
-
import { buildUITools, createPageSight, DefinitionUnavailable, fitNotes, jobWaitOf, UI_ACT_TOOL, UI_DESCRIBE_TOOL, UI_READ_TOOL, } from './ui/ui-tools.js';
|
|
45
|
-
import { DEFAULT_INDEX_CHARS, indexText, pageFingerprint } from './ui/page-index.js';
|
|
44
|
+
import { buildUITools, createPageSight, DefinitionUnavailable, fitNotes, jobWaitOf, laterAnswerFor, UI_ACT_TOOL, UI_DESCRIBE_TOOL, UI_READ_TOOL, UI_WAIT_TOOL, } from './ui/ui-tools.js';
|
|
45
|
+
import { DEFAULT_INDEX_CHARS, indexText, pageActions, pageFingerprint } from './ui/page-index.js';
|
|
46
|
+
import { RESUME_READ_WAIT_MS, resumedCalls, resumeNote, storedToolCall } from './resume/resumed-calls.js';
|
|
46
47
|
import { describeSchema } from './ui/outline.js';
|
|
47
48
|
import { createUISequence } from './ui/ui-sequence.js';
|
|
48
49
|
import { actionCallAsUiAct } from './ui/action-as-tool.js';
|
|
@@ -77,6 +78,8 @@ const DEFAULT_TOOL_TIMEOUT_MS = 30_000;
|
|
|
77
78
|
const DEFAULT_UI_RESULT_TIMEOUT_MS = 20_000;
|
|
78
79
|
/** Time left, before the turn's deadline, for the model to answer after waiting on a UI action's work. */
|
|
79
80
|
const UI_ANSWER_MARGIN_MS = 45_000;
|
|
81
|
+
/** The tools the model works the page with: a host tool of one of these names is withheld. */
|
|
82
|
+
const UI_TOOL_NAMES = new Set([UI_ACT_TOOL, UI_DESCRIBE_TOOL, UI_READ_TOOL, UI_WAIT_TOOL]);
|
|
80
83
|
/**
|
|
81
84
|
* Tools that hand the turn back to the user. The turn stops after any of them:
|
|
82
85
|
* the model must not carry on as if the user had already answered.
|
|
@@ -98,6 +101,21 @@ function log(level, ns, message, data) {
|
|
|
98
101
|
}
|
|
99
102
|
/** A call refused before its tool ran. */
|
|
100
103
|
const notRun = (payload) => ({ text: JSON.stringify(payload), ran: false });
|
|
104
|
+
/**
|
|
105
|
+
* What the model is given of a tool's result, and whether it succeeded.
|
|
106
|
+
* Built-in tools (present_options, etc.) return the raw payload directly,
|
|
107
|
+
* while schema and UI tools return `{ success, data, error }`. A failed call
|
|
108
|
+
* that still carries data (a UI action's page state) keeps its error message
|
|
109
|
+
* beside the data on the way to the model.
|
|
110
|
+
*/
|
|
111
|
+
function callResultPayload(result) {
|
|
112
|
+
const wrapped = !!result && typeof result === 'object' && 'success' in result;
|
|
113
|
+
if (!wrapped)
|
|
114
|
+
return { payload: result, success: true, wrapped };
|
|
115
|
+
const r = result;
|
|
116
|
+
const payload = !r.success && r.data !== undefined && r.error ? { error: r.error, ...r.data } : (r.data ?? r.error ?? null);
|
|
117
|
+
return { payload, success: r.success, wrapped };
|
|
118
|
+
}
|
|
101
119
|
/**
|
|
102
120
|
* Run a complete agent turn using the Vercel AI SDK.
|
|
103
121
|
*
|
|
@@ -120,6 +138,9 @@ export async function runAgentTurn(config, input) {
|
|
|
120
138
|
if (!config.model) {
|
|
121
139
|
throw new Error('[agent-sdk] config.model is required: pass an `ai` library model');
|
|
122
140
|
}
|
|
141
|
+
if (input.resume && input.approval) {
|
|
142
|
+
throw new Error('[agent-sdk] A turn carries resume or approval, never both: it continues one thing.');
|
|
143
|
+
}
|
|
123
144
|
const { turnId, socketRoom } = input;
|
|
124
145
|
// The turn as every host hook is told of it: its id, its channel, how its message was entered.
|
|
125
146
|
const turnInfo = turnInfoOf(input, input.channel, input.approvalChannel);
|
|
@@ -140,6 +161,7 @@ export async function runAgentTurn(config, input) {
|
|
|
140
161
|
maxRounds,
|
|
141
162
|
maxTokens,
|
|
142
163
|
temperature,
|
|
164
|
+
...(input.resume ? { resumed: { requestIds: input.resume.requestIds } } : {}),
|
|
143
165
|
});
|
|
144
166
|
// ─── The client's UI ─────────────────────────────────────────
|
|
145
167
|
// The turn carries the surfaces of the client that sent it. They are the only
|
|
@@ -160,7 +182,9 @@ export async function runAgentTurn(config, input) {
|
|
|
160
182
|
const heldDefinitions = client?.held ?? new Map();
|
|
161
183
|
// Whether the page can be seen: nothing that changes it runs while it cannot.
|
|
162
184
|
const sight = createPageSight();
|
|
163
|
-
const uiCounts = { describes: 0, reads: 0, acts: 0, guides: 0 };
|
|
185
|
+
const uiCounts = { describes: 0, reads: 0, acts: 0, guides: 0, waits: 0 };
|
|
186
|
+
// Work the turn's actions started that was still running when their calls answered: what ui_wait waits for.
|
|
187
|
+
const runningWork = new Map();
|
|
164
188
|
// Answers whose page state was moved to the end of what the model reads, summed over the turn's steps.
|
|
165
189
|
let pageStatesMoved = 0;
|
|
166
190
|
// The knowledge the client sent for its page goes after the host's prompt.
|
|
@@ -462,10 +486,13 @@ export async function runAgentTurn(config, input) {
|
|
|
462
486
|
};
|
|
463
487
|
// A UI tool waits for the client's answer, which has its own deadline, and
|
|
464
488
|
// then for the outcome of work it started: for uiJobWaitMs at most, and
|
|
465
|
-
// never past uiWaitDeadline.
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
489
|
+
// never past uiWaitDeadline. ui_wait waits for started work alone, up to
|
|
490
|
+
// uiWaitDeadline.
|
|
491
|
+
const timeoutMs = t.name === UI_WAIT_TOOL
|
|
492
|
+
? Math.max(toolTimeoutMs, Math.max(0, uiWaitDeadline() - Date.now()) + 5_000)
|
|
493
|
+
: isUI
|
|
494
|
+
? Math.max(toolTimeoutMs, uiResultTimeoutMs + 5_000, Math.min(uiJobWaitMs, Math.max(0, uiWaitDeadline() - Date.now())) + uiResultTimeoutMs + 5_000)
|
|
495
|
+
: toolTimeoutMs;
|
|
469
496
|
// ── No changes while blind ──
|
|
470
497
|
// After an answer that came without the page's state, or no answer, only
|
|
471
498
|
// reading runs until a read shows the page again. A change called then is
|
|
@@ -717,6 +744,8 @@ export async function runAgentTurn(config, input) {
|
|
|
717
744
|
uiCounts.describes++;
|
|
718
745
|
else if (t.name === UI_READ_TOOL)
|
|
719
746
|
uiCounts.reads++;
|
|
747
|
+
else if (t.name === UI_WAIT_TOOL)
|
|
748
|
+
uiCounts.waits++;
|
|
720
749
|
// It reads what the client sent, and touches no page.
|
|
721
750
|
else if (t.name === KNOWLEDGE_TOOL)
|
|
722
751
|
uiCounts.guides++;
|
|
@@ -769,16 +798,10 @@ export async function runAgentTurn(config, input) {
|
|
|
769
798
|
result = stoppedWhileRunning(t.name);
|
|
770
799
|
}
|
|
771
800
|
const durationMs = Date.now() - startMs;
|
|
772
|
-
//
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
const
|
|
776
|
-
const resultSuccess = isWrapped ? result.success : true;
|
|
777
|
-
// A failed call that still carries data (a UI action's page state) must
|
|
778
|
-
// not lose its error message on the way to the model.
|
|
779
|
-
const payload = isWrapped && !result.success && result.data !== undefined && result.error
|
|
780
|
-
? { error: result.error, ...result.data }
|
|
781
|
-
: resultData;
|
|
801
|
+
// Waiting for started work, at the model's choice, is not a measure of the turn's steps (time-hand-back.ts).
|
|
802
|
+
if (t.name === UI_WAIT_TOOL)
|
|
803
|
+
stepClock.waited(durationMs);
|
|
804
|
+
const { payload, success: resultSuccess, wrapped: isWrapped } = callResultPayload(result);
|
|
782
805
|
const modelPayload = readFromText.length > 0 && payload && typeof payload === 'object' && !Array.isArray(payload)
|
|
783
806
|
? {
|
|
784
807
|
...payload,
|
|
@@ -1014,6 +1037,7 @@ export async function runAgentTurn(config, input) {
|
|
|
1014
1037
|
currentPage: () => currentPage,
|
|
1015
1038
|
sequence: uiSequence,
|
|
1016
1039
|
held: heldDefinitions,
|
|
1040
|
+
running: runningWork,
|
|
1017
1041
|
sight,
|
|
1018
1042
|
log: (level, message, data) => log(level, 'agent:ui', message, { turnId, ...data }),
|
|
1019
1043
|
onResult: (_answer, page) => {
|
|
@@ -1040,6 +1064,7 @@ export async function runAgentTurn(config, input) {
|
|
|
1040
1064
|
actions: new Map(built.tools.map((t) => [t.name, t])),
|
|
1041
1065
|
describe: built.describe,
|
|
1042
1066
|
read: built.read,
|
|
1067
|
+
wait: built.wait,
|
|
1043
1068
|
};
|
|
1044
1069
|
return builtUI;
|
|
1045
1070
|
}
|
|
@@ -1050,7 +1075,7 @@ export async function runAgentTurn(config, input) {
|
|
|
1050
1075
|
const sdkOwned = new Set(fileTools.map((t) => t.name));
|
|
1051
1076
|
if (!ui)
|
|
1052
1077
|
return [...config.tools.tools.filter((t) => !sdkOwned.has(t.name)), ...fileTools];
|
|
1053
|
-
const taken = (name) => sdkOwned.has(name) || ui.actions.has(name) || name
|
|
1078
|
+
const taken = (name) => sdkOwned.has(name) || ui.actions.has(name) || UI_TOOL_NAMES.has(name);
|
|
1054
1079
|
const withheld = config.tools.tools.filter((t) => taken(t.name)).map((t) => t.name);
|
|
1055
1080
|
if (withheld.length > 0) {
|
|
1056
1081
|
log('error', 'agent:ui', 'Host tools collide with UI tools or action ids; the host tools are withheld this turn', {
|
|
@@ -1130,7 +1155,7 @@ export async function runAgentTurn(config, input) {
|
|
|
1130
1155
|
}
|
|
1131
1156
|
/** A tool the model is given, as a turn policy sees it: its name, kind and class. */
|
|
1132
1157
|
function describeStepTool(name) {
|
|
1133
|
-
if (name
|
|
1158
|
+
if (UI_TOOL_NAMES.has(name))
|
|
1134
1159
|
return { name, kind: 'ui' };
|
|
1135
1160
|
// The SDK's own file tools take their names before the host's (hostTools).
|
|
1136
1161
|
const registered = fileTools.find((t) => t.name === name) ?? config.tools.tools.find((t) => t.name === name);
|
|
@@ -1147,6 +1172,7 @@ export async function runAgentTurn(config, input) {
|
|
|
1147
1172
|
tools[UI_ACT_TOOL] = actAiTool();
|
|
1148
1173
|
tools[UI_DESCRIBE_TOOL] = toAiTool(ui.describe);
|
|
1149
1174
|
tools[UI_READ_TOOL] = toAiTool(ui.read);
|
|
1175
|
+
tools[UI_WAIT_TOOL] = toAiTool(ui.wait);
|
|
1150
1176
|
}
|
|
1151
1177
|
// What the prompt leaves out of the client's knowledge, read when it is needed.
|
|
1152
1178
|
if (knowledge && !tools[KNOWLEDGE_TOOL])
|
|
@@ -1247,6 +1273,86 @@ export async function runAgentTurn(config, input) {
|
|
|
1247
1273
|
],
|
|
1248
1274
|
};
|
|
1249
1275
|
}
|
|
1276
|
+
/**
|
|
1277
|
+
* The turn the person's tab started by itself, because work the assistant
|
|
1278
|
+
* started in an earlier turn finished after that turn had ended (the
|
|
1279
|
+
* payload's `resume`, resume/resumed-calls.ts).
|
|
1280
|
+
*
|
|
1281
|
+
* Each request whose call this conversation holds, still "running", has its
|
|
1282
|
+
* final answer read from the realtime server (kept 35 minutes). It becomes
|
|
1283
|
+
* that call's result in the words `ui_wait` gives once work ends
|
|
1284
|
+
* (`laterAnswerFor`), and, like an approved call's outcome
|
|
1285
|
+
* (continueApproval), it is a later result of the call already in the
|
|
1286
|
+
* history: it takes the call's place in what the model is given, and is
|
|
1287
|
+
* persisted under the call's own id, so every later turn reads the outcome
|
|
1288
|
+
* instead of "still running". A final answer that cannot be read is said in
|
|
1289
|
+
* the note, and nothing is stored for it. `note` is null when nothing is
|
|
1290
|
+
* left to report: the turn then calls no model.
|
|
1291
|
+
*/
|
|
1292
|
+
async function resumeAfterWork(resume) {
|
|
1293
|
+
const { calls, ignored } = resumedCalls(input.history ?? [], resume.requestIds);
|
|
1294
|
+
for (const left of ignored) {
|
|
1295
|
+
log('info', 'agent:turn', 'A resumed turn left a request out', { turnId, requestId: left.requestId, reason: left.reason });
|
|
1296
|
+
}
|
|
1297
|
+
const channel = config.ui?.channel;
|
|
1298
|
+
const finals = await Promise.all(calls.map(async (call) => {
|
|
1299
|
+
if (!channel)
|
|
1300
|
+
return null;
|
|
1301
|
+
try {
|
|
1302
|
+
return await channel.awaitResult(call.requestId, {
|
|
1303
|
+
userId: input.userId,
|
|
1304
|
+
timeoutMs: RESUME_READ_WAIT_MS,
|
|
1305
|
+
signal: abortController.signal,
|
|
1306
|
+
final: true,
|
|
1307
|
+
});
|
|
1308
|
+
}
|
|
1309
|
+
catch (err) {
|
|
1310
|
+
log('warn', 'agent:turn', 'Could not read the final answer of work a resumed turn reports', {
|
|
1311
|
+
turnId,
|
|
1312
|
+
requestId: call.requestId,
|
|
1313
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1314
|
+
});
|
|
1315
|
+
return null;
|
|
1316
|
+
}
|
|
1317
|
+
}));
|
|
1318
|
+
const page = client?.page ?? [];
|
|
1319
|
+
const reported = [];
|
|
1320
|
+
const unreadable = [];
|
|
1321
|
+
const outcomes = [];
|
|
1322
|
+
const persisted = [];
|
|
1323
|
+
calls.forEach((call, i) => {
|
|
1324
|
+
const final = finals[i];
|
|
1325
|
+
// None kept (expired, or never received), or a relay that keeps only first answers handing back the acknowledgment.
|
|
1326
|
+
if (!final || final.interim) {
|
|
1327
|
+
unreadable.push(call);
|
|
1328
|
+
return;
|
|
1329
|
+
}
|
|
1330
|
+
const answer = laterAnswerFor(final, call, page, {
|
|
1331
|
+
maxObservationChars: config.ui?.maxObservationChars,
|
|
1332
|
+
maxAnswerDataChars: config.ui?.maxAnswerDataChars,
|
|
1333
|
+
});
|
|
1334
|
+
const text = JSON.stringify(callResultPayload(answer).payload ?? { error: 'no result' });
|
|
1335
|
+
// Stored as the model is sent it; an approved call keeps saying it was approved and run once.
|
|
1336
|
+
const content = answerWithoutState(call.approval !== undefined ? markedResult(text, call.approval) : text);
|
|
1337
|
+
outcomes.push({ role: 'tool', content, tool_call_id: call.callId, name: call.name });
|
|
1338
|
+
persisted.push({ role: 'tool', content, toolCallId: call.callId, name: call.name });
|
|
1339
|
+
reported.push(call);
|
|
1340
|
+
});
|
|
1341
|
+
const record = {
|
|
1342
|
+
requestIds: [...resume.requestIds],
|
|
1343
|
+
reported: reported.map((c) => c.requestId),
|
|
1344
|
+
unreadable: unreadable.map((c) => c.requestId),
|
|
1345
|
+
ignored,
|
|
1346
|
+
};
|
|
1347
|
+
log('info', 'agent:turn', 'Turn resumed after work that finished after its turn ended', { turnId, resumed: record });
|
|
1348
|
+
const titles = new Map(pageActions(page).actions.map((a) => [a.entry.id, a.entry.title]));
|
|
1349
|
+
return {
|
|
1350
|
+
note: reported.length + unreadable.length > 0 ? resumeNote(reported, unreadable, (id) => titles.get(id)) : null,
|
|
1351
|
+
outcomes,
|
|
1352
|
+
persisted,
|
|
1353
|
+
record,
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1250
1356
|
// Track cumulative text length emitted this turn.
|
|
1251
1357
|
let totalTextEmitted = 0;
|
|
1252
1358
|
// ─── Rounds are paragraphs ─────────────────────────────────────────────────
|
|
@@ -1397,9 +1503,11 @@ export async function runAgentTurn(config, input) {
|
|
|
1397
1503
|
await stopWatch.checked();
|
|
1398
1504
|
const stoppedBeforeStart = stopOf(abortController.signal);
|
|
1399
1505
|
if (stoppedBeforeStart)
|
|
1400
|
-
return await finishStopped(stoppedBeforeStart, { expired: null, continued: null });
|
|
1506
|
+
return await finishStopped(stoppedBeforeStart, { expired: null, continued: null, resumed: null });
|
|
1401
1507
|
// ─── The turn after an approval decision ────────────────
|
|
1402
1508
|
const continued = input.approval ? await continueApproval(input.approval) : null;
|
|
1509
|
+
// ─── The turn resumed after work that finished after its turn ────────────
|
|
1510
|
+
const resumed = input.resume ? await resumeAfterWork(input.resume) : null;
|
|
1403
1511
|
// ─── Calls still stored as waiting, whose approval expired undecided ──────
|
|
1404
1512
|
//
|
|
1405
1513
|
// A card that expires with nobody clicking it sends nothing, so no turn ever
|
|
@@ -1470,7 +1578,7 @@ export async function runAgentTurn(config, input) {
|
|
|
1470
1578
|
// Stopped while the approved call ran, or while the store was asked: the model is not called.
|
|
1471
1579
|
const stoppedBeforeModel = stopOf(abortController.signal);
|
|
1472
1580
|
if (stoppedBeforeModel)
|
|
1473
|
-
return await finishStopped(stoppedBeforeModel, { expired, continued });
|
|
1581
|
+
return await finishStopped(stoppedBeforeModel, { expired, continued, resumed });
|
|
1474
1582
|
// Convert history to AI SDK CoreMessage format. Everything before the end
|
|
1475
1583
|
// of the conversation is sent exactly as it was sent before, so the prompt
|
|
1476
1584
|
// cache reads it (step-messages.ts). What is true only now — the page's
|
|
@@ -1484,9 +1592,9 @@ export async function runAgentTurn(config, input) {
|
|
|
1484
1592
|
const turnFilesGiven = !!fileArea && (input.attachments?.length ?? 0) > 0;
|
|
1485
1593
|
const messages = [
|
|
1486
1594
|
...convertHistoryToCoreMessages(
|
|
1487
|
-
// An approved call's outcome,
|
|
1488
|
-
// history: it takes that call's place.
|
|
1489
|
-
[...(input.history ?? []), ...expired.outcomes, ...(continued?.outcome ? [continued.outcome] : [])], [input.content, continued?.note].filter(Boolean).join('\n\n'),
|
|
1595
|
+
// An approved call's outcome, an expired one's, and work's that ended after its turn, is a later
|
|
1596
|
+
// result of the call already in the history: it takes that call's place.
|
|
1597
|
+
[...(input.history ?? []), ...expired.outcomes, ...(continued?.outcome ? [continued.outcome] : []), ...(resumed?.outcomes ?? [])], [input.content, continued?.note, resumed?.note].filter(Boolean).join('\n\n'),
|
|
1490
1598
|
// The turn's own message, when the history already holds it: its files are given below,
|
|
1491
1599
|
// each with its line, so the history's copy of the message does not name them again.
|
|
1492
1600
|
turnFilesGiven && input.history?.at(-1)?.role === 'user' ? input.history.length - 1 : null),
|
|
@@ -1559,7 +1667,7 @@ export async function runAgentTurn(config, input) {
|
|
|
1559
1667
|
// are newer than the page the turn began on.
|
|
1560
1668
|
const turnMessageAt = messages.map((m) => m.role).lastIndexOf('user');
|
|
1561
1669
|
const turnClock = clockText(new Date(), readClientTimeZone(input.context ?? null));
|
|
1562
|
-
const turnSpoken = input.approval ? null : readClientMessageInput(input.context ?? null);
|
|
1670
|
+
const turnSpoken = input.approval || input.resume ? null : readClientMessageInput(input.context ?? null);
|
|
1563
1671
|
// The reply is spoken on every turn of a call, the turn an approval continues included.
|
|
1564
1672
|
const turnSpokenReply = readClientReplyOutput(input.context ?? null);
|
|
1565
1673
|
const turnPageValues = client && client.page.length > 0
|
|
@@ -1590,7 +1698,7 @@ export async function runAgentTurn(config, input) {
|
|
|
1590
1698
|
: []),
|
|
1591
1699
|
turnClock,
|
|
1592
1700
|
// A message the person spoke may hold a mis-heard word (prompt/spoken-input.ts). A click on an
|
|
1593
|
-
// approval card
|
|
1701
|
+
// approval card, and a resume after work, are not messages, so they say nothing.
|
|
1594
1702
|
...(turnSpoken ? [spokenInputText(turnSpoken)] : []),
|
|
1595
1703
|
// A reply a voice will read out is written for the ear (prompt/spoken-reply.ts).
|
|
1596
1704
|
...(turnSpokenReply ? [spokenReplyText(turnSpokenReply)] : []),
|
|
@@ -1614,7 +1722,10 @@ export async function runAgentTurn(config, input) {
|
|
|
1614
1722
|
let outputLimitRetries = 0;
|
|
1615
1723
|
let outputLimitNote = null;
|
|
1616
1724
|
let outputLimited = false;
|
|
1617
|
-
|
|
1725
|
+
// A resumed turn with nothing left to report (every request it named left out) calls no model: it
|
|
1726
|
+
// ends at once, complete, having stored nothing of its own.
|
|
1727
|
+
const modelCalled = !(resumed && resumed.note === null);
|
|
1728
|
+
while (modelCalled) {
|
|
1618
1729
|
segments++;
|
|
1619
1730
|
const aiTools = assembleTools();
|
|
1620
1731
|
const previousSteps = [...allSteps];
|
|
@@ -1898,7 +2009,7 @@ export async function runAgentTurn(config, input) {
|
|
|
1898
2009
|
// closed, so it cannot abort the store or cause a second announcement.
|
|
1899
2010
|
const stop = stopOf(abortController.signal);
|
|
1900
2011
|
if (stop)
|
|
1901
|
-
return await finishStopped(stop, { expired, continued });
|
|
2012
|
+
return await finishStopped(stop, { expired, continued, resumed });
|
|
1902
2013
|
ending = true;
|
|
1903
2014
|
stopWatch.close();
|
|
1904
2015
|
// ─── Finalize ──────────────────────────────────────────────────────────────
|
|
@@ -1977,6 +2088,7 @@ export async function runAgentTurn(config, input) {
|
|
|
1977
2088
|
}
|
|
1978
2089
|
: {}),
|
|
1979
2090
|
...(fileArea ? { attachments: fileGuard.usage() } : {}),
|
|
2091
|
+
...(resumed ? { resumed: resumed.record } : {}),
|
|
1980
2092
|
});
|
|
1981
2093
|
/** A step whose choice's card said the reply stores it as the step's text, as the person read it. */
|
|
1982
2094
|
function withRepliesFromCards(all) {
|
|
@@ -1992,6 +2104,7 @@ export async function runAgentTurn(config, input) {
|
|
|
1992
2104
|
const newMessages = [
|
|
1993
2105
|
...expired.persisted,
|
|
1994
2106
|
...(continued?.persisted ?? []),
|
|
2107
|
+
...(resumed?.persisted ?? []),
|
|
1995
2108
|
...convertResponseToTurnMessages({ steps: withRepliesFromCards(outputLimited ? [...steps, { text: OUTPUT_LIMIT_REPLY, toolCalls: [] }] : steps) }, executedToolResults),
|
|
1996
2109
|
];
|
|
1997
2110
|
// On a conversation channel there is no card: the readback is what the customer is sent, verbatim, as the turn's
|
|
@@ -2045,6 +2158,7 @@ export async function runAgentTurn(config, input) {
|
|
|
2045
2158
|
maxRoundsReached: steps.length >= maxRounds,
|
|
2046
2159
|
stopReason,
|
|
2047
2160
|
...(fileArea ? { attachments: fileGuard.usage() } : {}),
|
|
2161
|
+
...(resumed ? { resumed: resumed.record } : {}),
|
|
2048
2162
|
};
|
|
2049
2163
|
}
|
|
2050
2164
|
finally {
|
|
@@ -2107,6 +2221,7 @@ export async function runAgentTurn(config, input) {
|
|
|
2107
2221
|
const newMessages = [
|
|
2108
2222
|
...(earlier.expired?.persisted ?? []),
|
|
2109
2223
|
...(earlier.continued?.persisted ?? []),
|
|
2224
|
+
...(earlier.resumed?.persisted ?? []),
|
|
2110
2225
|
...stoppedTurnMessages({ steps: recordedSteps, calls: [...recordedCalls.values()], streamedText, marker }),
|
|
2111
2226
|
];
|
|
2112
2227
|
const unsettled = [...recordedCalls.values()].filter((call) => call.text === null).map((call) => call.toolName);
|
|
@@ -2135,6 +2250,7 @@ export async function runAgentTurn(config, input) {
|
|
|
2135
2250
|
...(unsettled.length > 0 ? { unsettledCalls: unsettled } : {}),
|
|
2136
2251
|
...(client ? { ui: { ...uiCounts, blindRefusals: sight.refusals(), stopped: sight.stopped() } } : {}),
|
|
2137
2252
|
...(fileArea ? { attachments: fileGuard.usage() } : {}),
|
|
2253
|
+
...(earlier.resumed ? { resumed: earlier.resumed.record } : {}),
|
|
2138
2254
|
});
|
|
2139
2255
|
// The store and the announcement each get a limit of their own when the host says how long
|
|
2140
2256
|
// the process has left: a slow store must not run it to its hard end with nothing announced.
|
|
@@ -2213,6 +2329,7 @@ export async function runAgentTurn(config, input) {
|
|
|
2213
2329
|
stopped: marker,
|
|
2214
2330
|
...(stored ? {} : { stored: false }),
|
|
2215
2331
|
...(fileArea ? { attachments: fileGuard.usage() } : {}),
|
|
2332
|
+
...(earlier.resumed ? { resumed: earlier.resumed.record } : {}),
|
|
2216
2333
|
};
|
|
2217
2334
|
}
|
|
2218
2335
|
}
|
|
@@ -2314,31 +2431,7 @@ turnMessageAt = null) {
|
|
|
2314
2431
|
}
|
|
2315
2432
|
if (msg.tool_calls?.length) {
|
|
2316
2433
|
for (const tc of msg.tool_calls) {
|
|
2317
|
-
|
|
2318
|
-
let args;
|
|
2319
|
-
if (tc.function && typeof tc.function === 'object') {
|
|
2320
|
-
toolName = tc.function.name;
|
|
2321
|
-
try {
|
|
2322
|
-
args = typeof tc.function.arguments === 'string'
|
|
2323
|
-
? JSON.parse(tc.function.arguments)
|
|
2324
|
-
: tc.function.arguments;
|
|
2325
|
-
}
|
|
2326
|
-
catch {
|
|
2327
|
-
args = {};
|
|
2328
|
-
}
|
|
2329
|
-
}
|
|
2330
|
-
else {
|
|
2331
|
-
const flat = tc;
|
|
2332
|
-
toolName = flat.name;
|
|
2333
|
-
try {
|
|
2334
|
-
args = typeof flat.arguments === 'string'
|
|
2335
|
-
? JSON.parse(flat.arguments)
|
|
2336
|
-
: flat.arguments ?? {};
|
|
2337
|
-
}
|
|
2338
|
-
catch {
|
|
2339
|
-
args = {};
|
|
2340
|
-
}
|
|
2341
|
-
}
|
|
2434
|
+
const { name: toolName, args } = storedToolCall(tc);
|
|
2342
2435
|
parts.push({ type: 'tool-call', toolCallId: tc.id, toolName, input: args });
|
|
2343
2436
|
}
|
|
2344
2437
|
}
|