@adonis-agora/agent 0.49.0 → 0.50.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/CHANGELOG.md +14 -0
- package/dist/providers/agent_provider.d.ts.map +1 -1
- package/dist/providers/agent_provider.js +151 -8
- package/dist/providers/agent_provider.js.map +1 -1
- package/dist/src/agent-loop.d.ts +18 -0
- package/dist/src/agent-loop.d.ts.map +1 -1
- package/dist/src/agent-loop.js +22 -0
- package/dist/src/agent-loop.js.map +1 -1
- package/dist/src/agent-service.d.ts +96 -0
- package/dist/src/agent-service.d.ts.map +1 -1
- package/dist/src/agent-service.js +226 -4
- package/dist/src/agent-service.js.map +1 -1
- package/dist/src/chat-queue-service.d.ts +153 -0
- package/dist/src/chat-queue-service.d.ts.map +1 -0
- package/dist/src/chat-queue-service.js +360 -0
- package/dist/src/chat-queue-service.js.map +1 -0
- package/dist/src/client/chat-client.d.ts +32 -0
- package/dist/src/client/chat-client.d.ts.map +1 -1
- package/dist/src/client/chat-client.js +13 -0
- package/dist/src/client/chat-client.js.map +1 -1
- package/dist/src/client/index.d.ts +1 -1
- package/dist/src/client/index.d.ts.map +1 -1
- package/dist/src/client/index.js.map +1 -1
- package/dist/src/durable/agent-run-context.d.ts +6 -0
- package/dist/src/durable/agent-run-context.d.ts.map +1 -1
- package/dist/src/durable/agent-run-context.js.map +1 -1
- package/dist/src/durable/agent-run-workflow.d.ts.map +1 -1
- package/dist/src/durable/agent-run-workflow.js +94 -6
- package/dist/src/durable/agent-run-workflow.js.map +1 -1
- package/dist/src/durable/durable-agent-runner.d.ts +19 -3
- package/dist/src/durable/durable-agent-runner.d.ts.map +1 -1
- package/dist/src/durable/durable-agent-runner.js +62 -3
- package/dist/src/durable/durable-agent-runner.js.map +1 -1
- package/dist/src/index.d.ts +5 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/react/use-agent-chat.d.ts.map +1 -1
- package/dist/src/react/use-agent-chat.js +15 -1
- package/dist/src/react/use-agent-chat.js.map +1 -1
- package/dist/src/runners/inline-agent-runner.d.ts +30 -6
- package/dist/src/runners/inline-agent-runner.d.ts.map +1 -1
- package/dist/src/runners/inline-agent-runner.js +117 -21
- package/dist/src/runners/inline-agent-runner.js.map +1 -1
- package/dist/src/spi/agent-runner.d.ts +20 -1
- package/dist/src/spi/agent-runner.d.ts.map +1 -1
- package/dist/src/spi/chat-queue.d.ts +133 -0
- package/dist/src/spi/chat-queue.d.ts.map +1 -0
- package/dist/src/spi/chat-queue.js +48 -0
- package/dist/src/spi/chat-queue.js.map +1 -0
- package/dist/src/stores/lucid-schema.d.ts +8 -6
- package/dist/src/stores/lucid-schema.d.ts.map +1 -1
- package/dist/src/stores/lucid-schema.js +34 -7
- package/dist/src/stores/lucid-schema.js.map +1 -1
- package/dist/src/stores/lucid.d.ts +23 -1
- package/dist/src/stores/lucid.d.ts.map +1 -1
- package/dist/src/stores/lucid.js +192 -0
- package/dist/src/stores/lucid.js.map +1 -1
- package/dist/src/stream-events.d.ts +17 -0
- package/dist/src/stream-events.d.ts.map +1 -1
- package/dist/src/testing/chat-queue-store-contract.d.ts +26 -0
- package/dist/src/testing/chat-queue-store-contract.d.ts.map +1 -0
- package/dist/src/testing/chat-queue-store-contract.js +162 -0
- package/dist/src/testing/chat-queue-store-contract.js.map +1 -0
- package/dist/src/testing/in-memory-store.d.ts +20 -1
- package/dist/src/testing/in-memory-store.d.ts.map +1 -1
- package/dist/src/testing/in-memory-store.js +125 -0
- package/dist/src/testing/in-memory-store.js.map +1 -1
- package/dist/src/testing/index.d.ts +1 -0
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/index.js +1 -0
- package/dist/src/testing/index.js.map +1 -1
- package/dist/src/types.d.ts +6 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/stubs/database/migrations/create_agent_tables.stub +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import { utcDay } from './agent-deps.js';
|
|
2
|
+
import { isChatQueueStore, queuedMessageView, } from './spi/chat-queue.js';
|
|
3
|
+
/** How many times a drain retries when the head it picked is removed under it. */
|
|
4
|
+
const MAX_DRAIN_ATTEMPTS = 8;
|
|
5
|
+
/**
|
|
6
|
+
* The thread-level message queue: messages a person sends while a turn is running wait here, and
|
|
7
|
+
* the next one starts as soon as the running turn settles. A port of `@dudousxd/nestjs-agent`'s
|
|
8
|
+
* `ChatQueueService`; the wire is its `docs/stream-protocol.md`, *Message queue*.
|
|
9
|
+
*
|
|
10
|
+
* Everything that decides WHICH run holds a thread goes through the store's compare-and-set
|
|
11
|
+
* admission (`claimActiveStream` / `releaseActiveStream`), so two processes that both try to start
|
|
12
|
+
* the next turn — a settling run on a worker and a send on a web pod — cannot both win. The next
|
|
13
|
+
* run's id is the queued message's own id, which makes every step here idempotent: a retried claim
|
|
14
|
+
* for the same message succeeds again, and a durable start under the same id is a no-op.
|
|
15
|
+
*
|
|
16
|
+
* Policy, per outcome of the run that held the thread:
|
|
17
|
+
* - `completed` → the head starts.
|
|
18
|
+
* - `failed` → the queue pauses (`run_failed`), keeping every message.
|
|
19
|
+
* - `cancelled` → the queue pauses (`cancelled`), unless the head was queued by an interrupt — the
|
|
20
|
+
* cancel was made for it, so it starts.
|
|
21
|
+
* A paused queue starts nothing until it is resumed. A head whose actor is over quota pauses it
|
|
22
|
+
* (`quota_exceeded`) instead of starting.
|
|
23
|
+
*/
|
|
24
|
+
export class ChatQueueService {
|
|
25
|
+
store;
|
|
26
|
+
sink;
|
|
27
|
+
options;
|
|
28
|
+
/**
|
|
29
|
+
* Runs this process claimed a thread for and has not handed to a runner yet. A holder in here is
|
|
30
|
+
* alive whatever the runner says — it simply has not registered the run yet.
|
|
31
|
+
*/
|
|
32
|
+
starting = new Set();
|
|
33
|
+
constructor(store, sink, options = {}) {
|
|
34
|
+
this.store = store;
|
|
35
|
+
this.sink = sink;
|
|
36
|
+
this.options = options;
|
|
37
|
+
}
|
|
38
|
+
/** Whether the bound store can hold a queue. Without one, a busy thread is not queued. */
|
|
39
|
+
get supported() {
|
|
40
|
+
return isChatQueueStore(this.store);
|
|
41
|
+
}
|
|
42
|
+
/** The bound store as a queue store; throws when it is not one (check {@link supported} first). */
|
|
43
|
+
queueStore() {
|
|
44
|
+
if (!isChatQueueStore(this.store)) {
|
|
45
|
+
throw new Error('Queueing messages requires an AgentStore that implements ChatQueueStore (enqueueMessage, ' +
|
|
46
|
+
'listQueue, …, claimActiveStream, releaseActiveStream); the bound store does not.');
|
|
47
|
+
}
|
|
48
|
+
return this.store;
|
|
49
|
+
}
|
|
50
|
+
async state(threadId) {
|
|
51
|
+
const store = this.queueStore();
|
|
52
|
+
const [items, paused] = await Promise.all([
|
|
53
|
+
store.listQueue(threadId),
|
|
54
|
+
store.queuePause(threadId),
|
|
55
|
+
]);
|
|
56
|
+
return { items: items.map(queuedMessageView), paused };
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Whether `holder` is still running. A run this process is about to start is; otherwise the
|
|
60
|
+
* runner decides, and a runner that cannot tell says yes.
|
|
61
|
+
*/
|
|
62
|
+
async isAlive(holder, runner) {
|
|
63
|
+
if (this.starting.has(holder)) {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
if (typeof runner.isRunActive !== 'function') {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
return await runner.isRunActive(holder);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The run holding `threadId`, or `null` when it is free — a holder the runner reports dead counts
|
|
78
|
+
* as free, and is returned as `stale` so the caller can claim over it.
|
|
79
|
+
*/
|
|
80
|
+
async holder(threadId, runner) {
|
|
81
|
+
const holder = await this.queueStore().activeRunForThread(threadId);
|
|
82
|
+
if (holder === null) {
|
|
83
|
+
return { live: null, stale: null };
|
|
84
|
+
}
|
|
85
|
+
return (await this.isAlive(holder, runner))
|
|
86
|
+
? { live: holder, stale: null }
|
|
87
|
+
: { live: null, stale: holder };
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Decide what follows a TOP-LEVEL run that is settling on `threadId`, and move the thread there:
|
|
91
|
+
* hand it to the next queued message (claimed and popped here, started by the caller), or pause
|
|
92
|
+
* the queue, or release the thread. Call it BEFORE the run's terminal frame, so a client reading
|
|
93
|
+
* the stream learns what comes next from the `queue` frame, and so the thread is already free
|
|
94
|
+
* when the client sees the run end.
|
|
95
|
+
*
|
|
96
|
+
* A no-op returning `{}` on a store without a queue.
|
|
97
|
+
*/
|
|
98
|
+
async plan(args) {
|
|
99
|
+
if (!isChatQueueStore(this.store)) {
|
|
100
|
+
return {};
|
|
101
|
+
}
|
|
102
|
+
const store = this.store;
|
|
103
|
+
const { threadId, outcome } = args;
|
|
104
|
+
// Only the run holding the thread moves it on. One that already handed it over (a durable
|
|
105
|
+
// cancel settles from outside the body, and the body may still settle after it) has nothing
|
|
106
|
+
// left to decide — deciding again would pause a queue the handover just started.
|
|
107
|
+
if ((await store.activeRunForThread(threadId)) !== args.runId) {
|
|
108
|
+
return {};
|
|
109
|
+
}
|
|
110
|
+
// The id holding the thread right now, as far as this drain knows: the settling run, until it
|
|
111
|
+
// is released, then nobody.
|
|
112
|
+
let holding = args.runId;
|
|
113
|
+
for (let attempt = 0; attempt < MAX_DRAIN_ATTEMPTS; attempt += 1) {
|
|
114
|
+
const items = await store.listQueue(threadId);
|
|
115
|
+
const head = items[0];
|
|
116
|
+
if (head === undefined) {
|
|
117
|
+
if (holding !== null) {
|
|
118
|
+
await store.releaseActiveStream(threadId, holding);
|
|
119
|
+
holding = null;
|
|
120
|
+
// An enqueue that landed between the read above and this release saw the thread held and
|
|
121
|
+
// left its message for this drain — read once more now that the thread is free.
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
return {};
|
|
125
|
+
}
|
|
126
|
+
let pause = await store.queuePause(threadId);
|
|
127
|
+
if (pause === null) {
|
|
128
|
+
const reason = pauseReasonFor(outcome, head);
|
|
129
|
+
if (reason !== null) {
|
|
130
|
+
pause = {
|
|
131
|
+
reason,
|
|
132
|
+
...(outcome === 'failed' && args.error !== undefined ? { message: args.error } : {}),
|
|
133
|
+
at: new Date().toISOString(),
|
|
134
|
+
};
|
|
135
|
+
await store.setQueuePause(threadId, pause);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (pause === null) {
|
|
139
|
+
const blocked = await this.quotaBlock(head.actor);
|
|
140
|
+
if (blocked !== null) {
|
|
141
|
+
pause = { reason: 'quota_exceeded', message: blocked, at: new Date().toISOString() };
|
|
142
|
+
await store.setQueuePause(threadId, pause);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (pause !== null) {
|
|
146
|
+
if (holding !== null) {
|
|
147
|
+
await store.releaseActiveStream(threadId, holding);
|
|
148
|
+
}
|
|
149
|
+
return { frame: queueFrame(items, pause) };
|
|
150
|
+
}
|
|
151
|
+
const claimed = await store.claimActiveStream(threadId, head.id, holding !== null ? { replacing: holding } : {});
|
|
152
|
+
if (!claimed) {
|
|
153
|
+
// Someone else holds the thread now (a send that got in first); its own settle drains.
|
|
154
|
+
return {};
|
|
155
|
+
}
|
|
156
|
+
holding = head.id;
|
|
157
|
+
if (!(await store.removeQueuedMessage(head.id))) {
|
|
158
|
+
// Removed (or started) under us between the read and the claim: give the claim back and
|
|
159
|
+
// look at the new head.
|
|
160
|
+
await store.releaseActiveStream(threadId, head.id);
|
|
161
|
+
holding = null;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
const next = {
|
|
165
|
+
runId: head.id,
|
|
166
|
+
messageId: head.id,
|
|
167
|
+
input: await this.inputFor(head),
|
|
168
|
+
};
|
|
169
|
+
return {
|
|
170
|
+
next,
|
|
171
|
+
frame: queueFrame(items.slice(1), null, { messageId: head.id, runId: head.id }),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
// Pathological churn (every head removed under us): leave the thread free rather than spin.
|
|
175
|
+
if (holding !== null) {
|
|
176
|
+
await store.releaseActiveStream(threadId, holding);
|
|
177
|
+
}
|
|
178
|
+
return {};
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* {@link plan}, then start what it picked with `start`. What an in-process settle (the inline
|
|
182
|
+
* runner, a durable cancel issued outside a workflow) calls; answers the frame to write.
|
|
183
|
+
*/
|
|
184
|
+
async handoff(args, start) {
|
|
185
|
+
const plan = await this.plan(args);
|
|
186
|
+
if (plan.next === undefined) {
|
|
187
|
+
return plan.frame;
|
|
188
|
+
}
|
|
189
|
+
return (await this.launch(args.threadId, plan.next, start))
|
|
190
|
+
? plan.frame
|
|
191
|
+
: this.pausedFrame(args.threadId);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Start the head of an IDLE thread's queue — after a send queued behind a run that turned out to
|
|
195
|
+
* be gone, after a resume, after a stale holder. Does nothing while a live run holds the thread
|
|
196
|
+
* (its settle drains) or while the queue is paused. Answers the started run's id, if any.
|
|
197
|
+
*/
|
|
198
|
+
async kick(threadId, runner) {
|
|
199
|
+
if (!isChatQueueStore(this.store)) {
|
|
200
|
+
return undefined;
|
|
201
|
+
}
|
|
202
|
+
const { live, stale } = await this.holder(threadId, runner);
|
|
203
|
+
if (live !== null) {
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
if (stale !== null) {
|
|
207
|
+
console.warn(`[@adonis-agora/agent] thread ${threadId} was held by run ${stale}, which is no longer running`);
|
|
208
|
+
}
|
|
209
|
+
// Planned as if the stale holder completed: nothing it did pauses the queue.
|
|
210
|
+
const plan = await this.plan({ threadId, runId: stale, outcome: 'completed' });
|
|
211
|
+
if (plan.next === undefined) {
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
const started = await this.launch(threadId, plan.next, (input, runId) => runner.start(input, { runId }));
|
|
215
|
+
if (started && plan.frame !== undefined) {
|
|
216
|
+
// The new run's own stream is where a client attached to nothing yet learns about it.
|
|
217
|
+
await this.write(plan.next.runId, plan.frame);
|
|
218
|
+
}
|
|
219
|
+
return started ? plan.next.runId : undefined;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Start a turn the thread is already claimed for. On failure the message goes back to the head of
|
|
223
|
+
* the queue, the queue pauses (`start_failed`), and the claim is released — nothing is lost and
|
|
224
|
+
* nothing is left holding the thread.
|
|
225
|
+
*/
|
|
226
|
+
async launch(threadId, next, start) {
|
|
227
|
+
this.starting.add(next.runId);
|
|
228
|
+
try {
|
|
229
|
+
await start(next.input, next.runId);
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
234
|
+
console.error(`[@adonis-agora/agent] queued message ${next.messageId} could not start: ${message}`);
|
|
235
|
+
await this.restore(threadId, next, 'start_failed', message);
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
finally {
|
|
239
|
+
this.starting.delete(next.runId);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/** Put a turn that never started back at the head of its queue, paused, and free the thread. */
|
|
243
|
+
async restore(threadId, next, reason, message) {
|
|
244
|
+
const store = this.queueStore();
|
|
245
|
+
const { input } = next;
|
|
246
|
+
await store.enqueueMessage({
|
|
247
|
+
threadId,
|
|
248
|
+
actor: input.actor,
|
|
249
|
+
content: input.userText,
|
|
250
|
+
at: 'head',
|
|
251
|
+
...(input.attachments !== undefined ? { attachments: input.attachments } : {}),
|
|
252
|
+
...(input.agentName !== undefined ? { agentName: input.agentName } : {}),
|
|
253
|
+
...(input.model !== undefined ? { model: input.model } : {}),
|
|
254
|
+
...(input.pageContext !== undefined ? { pageContext: input.pageContext } : {}),
|
|
255
|
+
});
|
|
256
|
+
await store.setQueuePause(threadId, { reason, message, at: new Date().toISOString() });
|
|
257
|
+
await store.releaseActiveStream(threadId, next.runId);
|
|
258
|
+
}
|
|
259
|
+
/** A `queue` frame with the thread's current state. */
|
|
260
|
+
async pausedFrame(threadId) {
|
|
261
|
+
return { kind: 'queue', queue: await this.state(threadId) };
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Tell whoever is watching the thread that its queue changed: a `queue` frame into the stream of
|
|
265
|
+
* the run holding it. Best-effort — a thread nobody is streaming has no one to tell, and the next
|
|
266
|
+
* read of the thread carries the queue anyway.
|
|
267
|
+
*/
|
|
268
|
+
async publish(threadId) {
|
|
269
|
+
const state = await this.state(threadId);
|
|
270
|
+
const holder = await this.queueStore().activeRunForThread(threadId);
|
|
271
|
+
if (holder !== null) {
|
|
272
|
+
await this.write(holder, { kind: 'queue', queue: state }).catch((error) => {
|
|
273
|
+
console.warn(`[@adonis-agora/agent] could not publish the queue of thread ${threadId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
return state;
|
|
277
|
+
}
|
|
278
|
+
/** Write one agent-protocol event into `runId`'s stream. */
|
|
279
|
+
async write(runId, frame) {
|
|
280
|
+
const writer = await this.sink.open(runId);
|
|
281
|
+
await writer.write({ t: 'event', event: frame });
|
|
282
|
+
}
|
|
283
|
+
/** Why `actor` may not start a turn now (the quota message), or `null`. */
|
|
284
|
+
async quotaBlock(actor) {
|
|
285
|
+
const quota = this.options.quota;
|
|
286
|
+
if (quota === undefined) {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
try {
|
|
290
|
+
const { blocked } = await quota.report({ actor });
|
|
291
|
+
if (blocked === undefined) {
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
return (blocked.reason ?? `The ${blocked.period === 'day' ? 'daily' : 'monthly'} quota is used up`);
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
// Failing to ask is not a verdict; the send path's own quota gate still runs.
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* The turn a queued message starts: everything it was queued with, today's date, and its
|
|
303
|
+
* attachments' urls minted afresh — the ones stored at enqueue time may have expired while it
|
|
304
|
+
* waited. An attachment the store no longer resolves keeps its stored url.
|
|
305
|
+
*/
|
|
306
|
+
async inputFor(message) {
|
|
307
|
+
const attachments = await this.freshAttachments(message.actor, message.attachments ?? []);
|
|
308
|
+
const persona = this.options.personaFor?.(message.agentName);
|
|
309
|
+
return {
|
|
310
|
+
threadId: message.threadId,
|
|
311
|
+
actor: message.actor,
|
|
312
|
+
userText: message.content,
|
|
313
|
+
day: utcDay(),
|
|
314
|
+
...(message.agentName !== undefined ? { agentName: message.agentName } : {}),
|
|
315
|
+
...(persona !== undefined ? { persona } : {}),
|
|
316
|
+
...(attachments.length > 0 ? { attachments } : {}),
|
|
317
|
+
...(message.pageContext !== undefined ? { pageContext: message.pageContext } : {}),
|
|
318
|
+
...(message.model !== undefined ? { model: message.model } : {}),
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
async freshAttachments(actor, attachments) {
|
|
322
|
+
const staging = this.options.attachments;
|
|
323
|
+
if (attachments.length === 0 || staging === undefined) {
|
|
324
|
+
return attachments;
|
|
325
|
+
}
|
|
326
|
+
return Promise.all(attachments.map(async (attachment) => {
|
|
327
|
+
try {
|
|
328
|
+
return (await staging.resolve({ mediaId: attachment.mediaId, actor })) ?? attachment;
|
|
329
|
+
}
|
|
330
|
+
catch {
|
|
331
|
+
return attachment;
|
|
332
|
+
}
|
|
333
|
+
}));
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/** The pause a settling run's outcome imposes on a non-empty queue, or `null` to keep draining. */
|
|
337
|
+
function pauseReasonFor(outcome, head) {
|
|
338
|
+
if (outcome === 'failed') {
|
|
339
|
+
return 'run_failed';
|
|
340
|
+
}
|
|
341
|
+
if (outcome === 'cancelled' && head.interrupt !== true) {
|
|
342
|
+
return 'cancelled';
|
|
343
|
+
}
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
function queueFrame(items, paused, started) {
|
|
347
|
+
return {
|
|
348
|
+
kind: 'queue',
|
|
349
|
+
queue: { items: items.map(queuedMessageView), paused },
|
|
350
|
+
...(started !== undefined ? { started } : {}),
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* A thread's own turn — not a sub-agent's run on a subthread, which neither holds its thread's
|
|
355
|
+
* queue nor answers to it.
|
|
356
|
+
*/
|
|
357
|
+
export function isThreadTurn(input) {
|
|
358
|
+
return input.sinkRunId === undefined && input.parentRunId === undefined;
|
|
359
|
+
}
|
|
360
|
+
//# sourceMappingURL=chat-queue-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-queue-service.js","sourceRoot":"","sources":["../../src/chat-queue-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAIzC,OAAO,EAGL,gBAAgB,EAIhB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAwC7B,kFAAkF;AAClF,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,gBAAgB;IAQR,KAAK;IACL,IAAI;IACJ,OAAO;IAT1B;;;OAGG;IACc,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IAE9C,YACmB,KAAiB,EACjB,IAAqB,EACrB,OAAO,GAA4B,EAAE;qBAFrC,KAAK;oBACL,IAAI;uBACJ,OAAO;IACvB,CAAC;IAEJ,0FAA0F;IAC1F,IAAI,SAAS;QACX,OAAO,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,mGAAmG;IACnG,UAAU;QACR,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CACb,2FAA2F;gBACzF,kFAAkF,CACrF,CAAC;QACJ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AAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9C,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAqD;IAChF,OAAO,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS,CAAC;AAC1E,CAAC"}
|
|
@@ -22,6 +22,36 @@ export interface AgentChatRequestBody {
|
|
|
22
22
|
* server drops the old answer and streams a new one under a new run.
|
|
23
23
|
*/
|
|
24
24
|
regenerate?: true;
|
|
25
|
+
/**
|
|
26
|
+
* What to do when the thread already has a turn running: `'auto'` (default — run now, else wait
|
|
27
|
+
* in the thread's queue), `'queue'` (always queue), `'interrupt'` (cancel the running turn and run
|
|
28
|
+
* this next). A queued send answers `202` — see {@link AgentChatQueued}.
|
|
29
|
+
*/
|
|
30
|
+
mode?: 'auto' | 'queue' | 'interrupt';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* What `POST {basePath}/chat` answers (`202`) when the message waits in its thread's queue instead
|
|
34
|
+
* of running: nothing streams. `runId` is present when it started straight away (attach with
|
|
35
|
+
* {@link AgentChatClient.resume}); otherwise it runs — under `messageId` as its run id — once the
|
|
36
|
+
* turn ahead of it settles, announced by a `queue` event with `started` in that turn's stream.
|
|
37
|
+
*/
|
|
38
|
+
export interface AgentChatQueued {
|
|
39
|
+
queued: true;
|
|
40
|
+
threadId: string;
|
|
41
|
+
messageId: string;
|
|
42
|
+
/** 0-based place in the queue (`0` → runs next). */
|
|
43
|
+
position: number;
|
|
44
|
+
queue: {
|
|
45
|
+
items: {
|
|
46
|
+
id: string;
|
|
47
|
+
content: string;
|
|
48
|
+
[key: string]: unknown;
|
|
49
|
+
}[];
|
|
50
|
+
paused: unknown;
|
|
51
|
+
};
|
|
52
|
+
runId?: string;
|
|
53
|
+
/** The run an interrupt cancelled to make room for it. */
|
|
54
|
+
interrupting?: string;
|
|
25
55
|
}
|
|
26
56
|
/** Options for {@link createAgentChatClient}. */
|
|
27
57
|
export interface AgentChatClientOptions {
|
|
@@ -68,6 +98,8 @@ export interface AgentChatResult {
|
|
|
68
98
|
runId?: string;
|
|
69
99
|
threadId?: string;
|
|
70
100
|
parts: ChatPart[];
|
|
101
|
+
/** Present when the server queued the message instead of streaming a reply (`202`). */
|
|
102
|
+
queued?: AgentChatQueued;
|
|
71
103
|
}
|
|
72
104
|
/**
|
|
73
105
|
* Thrown when a run's stream dropped and could not be resumed within the retry budget. Carries the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-client.d.ts","sourceRoot":"","sources":["../../../src/client/chat-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAwC,MAAM,UAAU,CAAC;AAE/F;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IACxD,2EAA2E;IAC3E,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC;IACxB,2FAA2F;IAC3F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"chat-client.d.ts","sourceRoot":"","sources":["../../../src/client/chat-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAwC,MAAM,UAAU,CAAC;AAE/F;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EA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AAK;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,YAAY,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,OAAO,EAMnF;CACF;AA0BD;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAIxC;CACF;AAiCD;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC9D,sGAAsG;IACtG,MAAM,CACJ,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,iBAAiB,GAAG;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GACrD,OAAO,CAAC,eAAe,CAAC,CAAC;CAC7B;AAED,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B,GAAG,eAAe,CAsM3F"}
|
|
@@ -190,6 +190,19 @@ export function createAgentChatClient(options = {}) {
|
|
|
190
190
|
if (!response.ok) {
|
|
191
191
|
throw await httpError(response);
|
|
192
192
|
}
|
|
193
|
+
if (response.status === 202) {
|
|
194
|
+
// The thread already has a turn running: the message waits in its queue, and nothing streams.
|
|
195
|
+
const queued = (await response.json());
|
|
196
|
+
if (typeof queued.threadId === 'string') {
|
|
197
|
+
sendOptions.onThreadId?.(queued.threadId);
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
parts: [],
|
|
201
|
+
queued,
|
|
202
|
+
...(typeof queued.threadId === 'string' ? { threadId: queued.threadId } : {}),
|
|
203
|
+
...(typeof queued.runId === 'string' ? { runId: queued.runId } : {}),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
193
206
|
if (!response.body) {
|
|
194
207
|
throw new Error(`Failed to start agent chat (HTTP ${response.status}): no response body.`);
|
|
195
208
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-client.js","sourceRoot":"","sources":["../../../src/client/chat-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"chat-client.js","sourceRoot":"","sources":["../../../src/client/chat-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAqG/F;;;;GAIG;AACH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAC1C,KAAK,CAAqB;IAC1B,QAAQ,CAAqB;IAC7B,KAAK,CAAa;IAC3B,YAAY,KAAyB,EAAE,QAA4B,EAAE,KAAiB;QACpF,KAAK,CAAC,oDAAoD,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,MAAM,CAAS;IACf,IAAI,CAAqB;IACzB,IAAI,CAAU;IACvB,YAAY,MAAc,EAAE,OAAe,EAAE,IAAwB,EAAE,IAAa;QAClF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAA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M,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;QACnF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,0BAA0B,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QACnE,CAAC;QACD,OAAO;YACL,KAAK;YACL,KAAK,EAAE,SAAS;YAChB,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChD,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { type AgentChatClient, type AgentChatClientOptions, AgentChatDisconnectedError, type AgentChatHandlers, AgentChatHttpError, type AgentChatRequestBody, type AgentChatResult, type AgentChatResumeOptions, type AgentChatSendOptions, AgentChatStreamError, createAgentChatClient, } from './chat-client.js';
|
|
1
|
+
export { type AgentChatClient, type AgentChatClientOptions, AgentChatDisconnectedError, type AgentChatHandlers, AgentChatHttpError, type AgentChatQueued, type AgentChatRequestBody, type AgentChatResult, type AgentChatResumeOptions, type AgentChatSendOptions, AgentChatStreamError, createAgentChatClient, } from './chat-client.js';
|
|
2
2
|
export { type ChatFrame, type ChatPart, decodeFrame, foldPart, parseSseEvent, readSseStream, type SseEvent, } from './sse.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,0BAA0B,EAC1B,KAAK,iBAAiB,EACtB,kBAAkB,EAClB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,WAAW,EACX,QAAQ,EACR,aAAa,EACb,aAAa,EACb,KAAK,QAAQ,GACd,MAAM,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,0BAA0B,EAC1B,KAAK,iBAAiB,EACtB,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,WAAW,EACX,QAAQ,EACR,aAAa,EACb,aAAa,EACb,KAAK,QAAQ,GACd,MAAM,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,0BAA0B,EAE1B,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,0BAA0B,EAE1B,kBAAkB,EAMlB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,WAAW,EACX,QAAQ,EACR,aAAa,EACb,aAAa,GAEd,MAAM,UAAU,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AgentDepsFactory } from '../agent-deps-factory.js';
|
|
2
|
+
import type { ChatQueueService } from '../chat-queue-service.js';
|
|
2
3
|
import type { AgentStore } from '../spi/agent-store.js';
|
|
3
4
|
/**
|
|
4
5
|
* The runtime graph the durable {@link import('./agent-run-workflow.js').AgentRunWorkflow} body needs.
|
|
@@ -13,6 +14,11 @@ import type { AgentStore } from '../spi/agent-store.js';
|
|
|
13
14
|
export interface DurableAgentContext {
|
|
14
15
|
factory: AgentDepsFactory;
|
|
15
16
|
store: AgentStore;
|
|
17
|
+
/**
|
|
18
|
+
* The thread message queue a settling turn hands its thread to. Set on every pod of a deployment
|
|
19
|
+
* or on none: whether a turn writes the queue checkpoints must not depend on which pod replays it.
|
|
20
|
+
*/
|
|
21
|
+
queue?: ChatQueueService;
|
|
16
22
|
}
|
|
17
23
|
/** Install (or clear, with `undefined`) the durable agent context. Called by the provider at boot. */
|
|
18
24
|
export declare function setDurableAgentContext(context: DurableAgentContext | undefined): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-run-context.d.ts","sourceRoot":"","sources":["../../../src/durable/agent-run-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;;;;;;;GASG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,gBAAgB,CAAC;IAC1B,KAAK,EAAE,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-run-context.d.ts","sourceRoot":"","sources":["../../../src/durable/agent-run-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;;;;;;;GASG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,gBAAgB,CAAC;IAC1B,KAAK,EAAE,UAAU,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B;AAID,sGAAsG;AACtG,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS,GAAG,IAAI,CAErF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,mBAAmB,CAQ5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-run-context.js","sourceRoot":"","sources":["../../../src/durable/agent-run-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent-run-context.js","sourceRoot":"","sources":["../../../src/durable/agent-run-context.ts"],"names":[],"mappings":"AAwBA,IAAI,OAAwC,CAAC;AAE7C,sGAAsG;AACtG,MAAM,UAAU,sBAAsB,CAAC,OAAwC;IAC7E,OAAO,GAAG,OAAO,CAAC;AACpB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB;IACpC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,8FAA8F;YAC5F,kEAAkE,CACrE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-run-workflow.d.ts","sourceRoot":"","sources":["../../../src/durable/agent-run-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,KAAK,WAAW,EAEjB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-run-workflow.d.ts","sourceRoot":"","sources":["../../../src/durable/agent-run-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,KAAK,WAAW,EAEjB,MAAM,uBAAuB,CAAC;AAe/B,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,aAAa,CAAC;AAG3D;;;;;GAKG;AACH,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAyBD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;IAChD,OAAgB,QAAQ;QAAK,IAAI;QAAqB,OAAO;MAAQ;IAE/D,GAAG,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAuNlF;CACF"}
|