@adonis-agora/agent 0.49.0 → 0.51.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 +32 -0
- package/dist/providers/agent_provider.d.ts +16 -0
- package/dist/providers/agent_provider.d.ts.map +1 -1
- package/dist/providers/agent_provider.js +187 -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 +6 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -4
- 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-governance-queries.d.ts +2 -0
- package/dist/src/stores/lucid-governance-queries.d.ts.map +1 -1
- package/dist/src/stores/lucid-governance-queries.js +4 -0
- package/dist/src/stores/lucid-governance-queries.js.map +1 -1
- package/dist/src/stores/lucid-pricing.d.ts +2 -0
- package/dist/src/stores/lucid-pricing.d.ts.map +1 -1
- package/dist/src/stores/lucid-pricing.js +4 -0
- package/dist/src/stores/lucid-pricing.js.map +1 -1
- package/dist/src/stores/lucid-schema.d.ts +36 -9
- package/dist/src/stores/lucid-schema.d.ts.map +1 -1
- package/dist/src/stores/lucid-schema.js +173 -23
- package/dist/src/stores/lucid-schema.js.map +1 -1
- package/dist/src/stores/lucid.d.ts +33 -3
- package/dist/src/stores/lucid.d.ts.map +1 -1
- package/dist/src/stores/lucid.js +208 -1
- 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 +2 -1
- package/skills/agent-setup/SKILL.md +6 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-agent-runner.d.ts","sourceRoot":"","sources":["../../../src/runners/inline-agent-runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"inline-agent-runner.d.ts","sourceRoot":"","sources":["../../../src/runners/inline-agent-runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAQjE,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAEL,KAAK,UAAU,EAGhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,KAAK,EAAS,aAAa,EAAY,MAAM,aAAa,CAAC;AAclE;;;;;;;;;;;;GAYG;AACH,qBAAa,iBAAkB,YAAW,WAAW;IAWjD,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,oFAAoF;IACpF,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;IAbzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IACzD;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAoC;IACzD,+EAA+E;IAC/E,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAE/C,YACmB,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,UAAU;IAClC,oFAAoF;IACnE,KAAK,CAAC,EAAE,gBAAgB,YAAA,EACvC;IAEJ;;;OAGG;IACG,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAEjD;IAEK,KAAK,CACT,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAuE5B;IAED;;;;;;;OAOG;YACW,WAAW;IAoCzB;;;;;;;;;;OAUG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAWhF;IAEK,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BzC;IAED,OAAO,CAAC,aAAa;IAkDrB;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAWlB,kGAAkG;IAClG;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAkBpB,OAAO,CAAC,IAAI;IAMZ,qFAAqF;YACvE,SAAS;CAkExB"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { utcDay } from '../agent-deps.js';
|
|
2
|
-
import { runAgentLoop, settleAll, streamErrorFrame } from '../agent-loop.js';
|
|
2
|
+
import { RunCancelledError, runAgentLoop, settleAll, streamErrorFrame, } from '../agent-loop.js';
|
|
3
|
+
import { isThreadTurn, } from '../chat-queue-service.js';
|
|
3
4
|
import { spannedAgent } from '../diagnostics.js';
|
|
4
5
|
import { HumanReplyMismatchError, isHumanDecision, } from '../elicitation.js';
|
|
5
|
-
import {
|
|
6
|
+
import { releaseThreadRun } from '../spi/chat-queue.js';
|
|
6
7
|
import { childSinkWriter } from '../spi/token-stream-sink.js';
|
|
7
8
|
/**
|
|
8
9
|
* Runs the agent turn in-process — the default runner (`durable: false`). A HITL wait resolves a
|
|
@@ -20,19 +21,36 @@ import { childSinkWriter } from '../spi/token-stream-sink.js';
|
|
|
20
21
|
export class InlineAgentRunner {
|
|
21
22
|
factory;
|
|
22
23
|
store;
|
|
24
|
+
queue;
|
|
23
25
|
pending = new Map();
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The input of each top-level run this process is running — what {@link isRunActive} answers
|
|
28
|
+
* from, and what a cancel settles the thread (and its queue) of.
|
|
29
|
+
*/
|
|
30
|
+
live = new Map();
|
|
31
|
+
/** Runs someone asked to stop; the loop observes it at its next safe point. */
|
|
32
|
+
cancelled = new Set();
|
|
33
|
+
constructor(factory, store,
|
|
34
|
+
/** The thread message queue this runner drains when a thread's own turn settles. */
|
|
35
|
+
queue) {
|
|
27
36
|
this.factory = factory;
|
|
28
37
|
this.store = store;
|
|
38
|
+
this.queue = queue;
|
|
29
39
|
}
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
/**
|
|
41
|
+
* In-process, so exact: a run this process is not running is not running anywhere — the process
|
|
42
|
+
* that was running it is gone (a restart), and a thread it still holds is a stale claim.
|
|
43
|
+
*/
|
|
44
|
+
async isRunActive(runId) {
|
|
45
|
+
return this.live.has(runId);
|
|
46
|
+
}
|
|
47
|
+
async start(input, options = {}) {
|
|
48
|
+
const runId = options.runId ?? crypto.randomUUID();
|
|
32
49
|
const day = input.day ?? utcDay();
|
|
33
50
|
const deps = this.factory.forAgent(input.agentName);
|
|
34
51
|
const hooks = this.topLevelHooks({
|
|
35
52
|
runId,
|
|
53
|
+
input,
|
|
36
54
|
deps,
|
|
37
55
|
actor: input.actor,
|
|
38
56
|
day,
|
|
@@ -50,26 +68,73 @@ export class InlineAgentRunner {
|
|
|
50
68
|
// when unobserved.
|
|
51
69
|
// The thread's active run is set BEFORE the loop starts — a fast turn could otherwise end (and
|
|
52
70
|
// clear it) before it was ever set — and cleared when the turn ends, however it ends.
|
|
71
|
+
// (A run the queue claimed the thread for already holds it under this id; setting it again is a
|
|
72
|
+
// no-op.)
|
|
53
73
|
await this.store.setActiveStream(input.threadId, runId);
|
|
54
|
-
this.
|
|
74
|
+
this.live.set(runId, input);
|
|
55
75
|
void spannedAgent('turn', runId, { runId }, () => runAgentLoop({ ...deps, day }, input, hooks), (result) => ({ textLength: result.text.length }))
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
})
|
|
76
|
+
// The drain already moved the thread on (or released it) before the stream ended; this only
|
|
77
|
+
// catches a turn that ended without one. Conditional, so it never clears a successor's claim.
|
|
78
|
+
.then(() => releaseThreadRun(this.store, input.threadId, runId))
|
|
60
79
|
.catch(async (error) => {
|
|
80
|
+
if (error instanceof RunCancelledError) {
|
|
81
|
+
// `cancel` already settled the run, its thread and its stream; the loop only had to stop.
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
61
84
|
const message = error instanceof Error ? error.message : String(error);
|
|
62
85
|
console.error(`[@adonis-agora/agent] run ${runId} failed: ${message}`);
|
|
63
86
|
// Settle the run's persisted outcome — the loop only records completions (it can't catch its
|
|
64
87
|
// own crash). First-terminal, so this can't clobber a completion that already landed.
|
|
65
88
|
await this.store.recordRunEnd({ runId, status: 'failed', error: message });
|
|
66
|
-
// Surface the failure on the live stream and close it, so a subscriber isn't left hanging.
|
|
67
89
|
const writer = await deps.sink.open(runId);
|
|
90
|
+
// The queue behind it pauses (a failed turn's next message would likely fail the same way),
|
|
91
|
+
// told to the reader before the error frame.
|
|
92
|
+
await this.settleQueue(writer, input, runId, 'failed', message);
|
|
93
|
+
await releaseThreadRun(this.store, input.threadId, runId);
|
|
94
|
+
// Surface the failure on the live stream and close it, so a subscriber isn't left hanging.
|
|
68
95
|
await writer.write(streamErrorFrame(error));
|
|
69
96
|
await writer.end();
|
|
97
|
+
})
|
|
98
|
+
.catch((error) => {
|
|
99
|
+
console.error(`[@adonis-agora/agent] run ${runId} could not be settled: ${error instanceof Error ? error.message : String(error)}`);
|
|
100
|
+
})
|
|
101
|
+
.finally(() => {
|
|
102
|
+
this.live.delete(runId);
|
|
103
|
+
this.cancelled.delete(runId);
|
|
70
104
|
});
|
|
71
105
|
return { runId };
|
|
72
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Move the thread past a settling TOP-LEVEL run — to the next queued message, which starts here,
|
|
109
|
+
* or to a paused/empty queue — and write the resulting `queue` frame into this run's stream. A
|
|
110
|
+
* no-op without a queue-capable store, and for a run that is not a thread's own turn.
|
|
111
|
+
*
|
|
112
|
+
* Never throws: the run is settling either way, and a queue that could not be advanced is picked
|
|
113
|
+
* up by the next send or resume on the thread.
|
|
114
|
+
*/
|
|
115
|
+
async settleQueue(writer, input, runId, outcome, error) {
|
|
116
|
+
const queue = this.queue;
|
|
117
|
+
if (queue === undefined || !queue.supported || !isThreadTurn(input)) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
// A Stop that arrived too late to interrupt anything (the turn's last model call was already
|
|
121
|
+
// answering) still means stop: the queue behind it pauses as it would after a cancel.
|
|
122
|
+
const settled = outcome === 'completed' && this.cancelled.has(runId) ? 'cancelled' : outcome;
|
|
123
|
+
try {
|
|
124
|
+
const frame = await queue.handoff({
|
|
125
|
+
threadId: input.threadId,
|
|
126
|
+
runId,
|
|
127
|
+
outcome: settled,
|
|
128
|
+
...(error !== undefined ? { error } : {}),
|
|
129
|
+
}, (next, nextRunId) => this.start(next, { runId: nextRunId }));
|
|
130
|
+
if (frame !== undefined) {
|
|
131
|
+
await writer.write({ t: 'event', event: frame });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch (failure) {
|
|
135
|
+
console.error(`[@adonis-agora/agent] could not advance the queue of thread ${input.threadId} after run ${runId}: ${failure instanceof Error ? failure.message : String(failure)}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
73
138
|
/**
|
|
74
139
|
* Deliver a human's reply to whichever wait this run is parked on.
|
|
75
140
|
*
|
|
@@ -94,26 +159,55 @@ export class InlineAgentRunner {
|
|
|
94
159
|
parked.resolve(reply);
|
|
95
160
|
}
|
|
96
161
|
async cancel(runId) {
|
|
162
|
+
// The loop stops at its next safe point (between steps, or once the model call it is in has
|
|
163
|
+
// answered); a turn parked on a human is unwound now.
|
|
164
|
+
this.cancelled.add(runId);
|
|
165
|
+
for (const [key, parked] of this.pending) {
|
|
166
|
+
if (key.startsWith(`${runId}:`)) {
|
|
167
|
+
this.pending.delete(key);
|
|
168
|
+
parked.reject(new RunCancelledError());
|
|
169
|
+
}
|
|
170
|
+
}
|
|
97
171
|
// Best-effort: settle the run `cancelled` (first-terminal, so a completed run stays completed),
|
|
98
172
|
// then close the live stream so a subscriber isn't left hanging.
|
|
99
173
|
await this.store.recordRunEnd({ runId, status: 'cancelled' });
|
|
100
|
-
const threadId = this.threadOfRun.get(runId);
|
|
101
|
-
if (threadId !== undefined) {
|
|
102
|
-
await clearActiveRun(this.store, threadId, runId);
|
|
103
|
-
}
|
|
104
174
|
const deps = this.factory.forAgent();
|
|
105
175
|
const writer = await deps.sink.open(runId);
|
|
176
|
+
const input = this.live.get(runId);
|
|
177
|
+
if (input !== undefined) {
|
|
178
|
+
// An interrupt's message starts now; anything else queued pauses behind the Stop.
|
|
179
|
+
await this.settleQueue(writer, input, runId, 'cancelled');
|
|
180
|
+
await releaseThreadRun(this.store, input.threadId, runId);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
this.cancelled.delete(runId);
|
|
184
|
+
}
|
|
106
185
|
// The last frame before a normal end: without it a reader cannot tell a truncated answer from
|
|
107
186
|
// a complete one. Not an error — a client that retries a failed stream must not retry this.
|
|
108
187
|
await writer.write({ t: 'event', event: { kind: 'cancelled' } });
|
|
109
188
|
await writer.end();
|
|
110
189
|
}
|
|
111
190
|
topLevelHooks(args) {
|
|
112
|
-
const { runId, deps, actor, day, chainBelow, depth } = args;
|
|
191
|
+
const { runId, input, deps, actor, day, chainBelow, depth } = args;
|
|
113
192
|
return {
|
|
114
193
|
runId,
|
|
115
194
|
durable: false,
|
|
116
|
-
|
|
195
|
+
// The loop ends the stream when the turn completes. Just before, the thread passes to the next
|
|
196
|
+
// queued message (or is released), and the reader is told which — so by the time a client sees
|
|
197
|
+
// the run end, the thread is already free or already running what it queued.
|
|
198
|
+
openSink: async () => {
|
|
199
|
+
const writer = await deps.sink.open(runId);
|
|
200
|
+
return this.queue === undefined
|
|
201
|
+
? writer
|
|
202
|
+
: {
|
|
203
|
+
write: (frame) => writer.write(frame),
|
|
204
|
+
end: async () => {
|
|
205
|
+
await this.settleQueue(writer, input, runId, 'completed');
|
|
206
|
+
await writer.end();
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
},
|
|
210
|
+
cancelled: async () => this.cancelled.has(runId),
|
|
117
211
|
...this.humanHooks(runId),
|
|
118
212
|
step: (_name, fn) => fn(),
|
|
119
213
|
// Nothing here records a position, so a turn's read tools can simply overlap.
|
|
@@ -170,8 +264,8 @@ export class InlineAgentRunner {
|
|
|
170
264
|
return Promise.race([waiting, lapse]).finally(() => clearTimeout(timer));
|
|
171
265
|
}
|
|
172
266
|
park(key, on) {
|
|
173
|
-
return new Promise((resolve) => {
|
|
174
|
-
this.pending.set(key, { on, resolve });
|
|
267
|
+
return new Promise((resolve, reject) => {
|
|
268
|
+
this.pending.set(key, { on, resolve, reject });
|
|
175
269
|
});
|
|
176
270
|
}
|
|
177
271
|
/** Delegate to another agent as a nested in-process run (a transient sub-thread). */
|
|
@@ -189,6 +283,8 @@ export class InlineAgentRunner {
|
|
|
189
283
|
// A delegated run parks on a human like any other, keyed by ITS OWN runId — which is the id
|
|
190
284
|
// its pending row and its forwarded frames both carry, so the wait can be answered.
|
|
191
285
|
...this.humanHooks(runId),
|
|
286
|
+
// A child stops when the run a human is actually watching is stopped.
|
|
287
|
+
cancelled: async () => this.cancelled.has(sinkRunId),
|
|
192
288
|
step: (_name, fn) => fn(),
|
|
193
289
|
parallel: settleAll,
|
|
194
290
|
runAgent: (childName, childTask) => this.runNested({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-agent-runner.js","sourceRoot":"","sources":["../../../src/runners/inline-agent-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,
|
|
1
|
+
{"version":3,"file":"inline-agent-runner.js","sourceRoot":"","sources":["../../../src/runners/inline-agent-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAEL,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,YAAY,GAEb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAGL,uBAAuB,EACvB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAmB,MAAM,6BAA6B,CAAC;AAe/E;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,iBAAiB;IAWT,OAAO;IACP,KAAK;IAEL,KAAK;IAbP,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IACzD;;;OAGG;IACc,IAAI,GAAG,IAAI,GAAG,EAAyB,CAAC;IACzD,+EAA+E;IAC9D,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/C,YACmB,OAAyB,EACzB,KAAiB;IAClC,oFAAoF;IACnE,KAAwB;uBAHxB,OAAO;qBACP,KAAK;qBAEL,KAAK;IACrB,CAAC;IAEJ;;;OAGG;IACH,KAAK,CAAC,WAAW,CAAC,KAAa;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAA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BACpB,IAAI,EAAE,SAAS;gBACf,KAAK;gBACL,GAAG;gBACH,KAAK,EAAE,KAAK,GAAG,CAAC;gBAChB,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,SAAS,CAAC;gBAC1B,WAAW,EAAE,KAAK;gBAClB,SAAS;aACV,CAAC;SACL,CAAC;QACF,yFAAyF;QACzF,OAAO,YAAY,CACjB,MAAM,EACN,KAAK,EACL,EAAE,KAAK,EAAE,EACT,GAAG,EAAE,CACH,YAAY,CACV,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,EAChB;YACE,QAAQ,EAAE,SAAS,CAAC,EAAE;YACtB,KAAK;YACL,QAAQ,EAAE,IAAI;YACd,SAAS;YACT,GAAG;YACH,WAAW;YACX,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,IAAI;SACrB,EACD,KAAK,CACN,EACH,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CACjD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -11,10 +11,29 @@ import type { AgentRunInput } from '../types.js';
|
|
|
11
11
|
* `start` ENQUEUES and returns immediately with the runId — the live tokens flow on the
|
|
12
12
|
* TokenStreamSink, not through this call.
|
|
13
13
|
*/
|
|
14
|
+
/** How {@link AgentRunner.start} starts a run. */
|
|
15
|
+
export interface AgentRunStartOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Use this id for the run instead of minting one. The chat queue claims the thread for a run
|
|
18
|
+
* BEFORE starting it (so no second turn can slip in between), which needs the id up front; a
|
|
19
|
+
* queued message's run id is the message's own id, which also makes a retried start idempotent.
|
|
20
|
+
* A runner that ignores it still works — the service then re-points the thread at the id it
|
|
21
|
+
* returned.
|
|
22
|
+
*/
|
|
23
|
+
runId?: string;
|
|
24
|
+
}
|
|
14
25
|
export interface AgentRunner {
|
|
15
|
-
start(input: AgentRunInput): Promise<{
|
|
26
|
+
start(input: AgentRunInput, options?: AgentRunStartOptions): Promise<{
|
|
16
27
|
runId: string;
|
|
17
28
|
}>;
|
|
29
|
+
/**
|
|
30
|
+
* OPTIONAL: whether `runId` is still running (or parked, or about to start) as far as this runner
|
|
31
|
+
* can tell. Asked when a thread's admission is held by a run, to tell a live holder from a stale
|
|
32
|
+
* one a crashed process left behind — a stale holder is replaced instead of queueing behind it
|
|
33
|
+
* for ever. Answer `true` when unsure: a wrong `false` starts a second turn on the thread. Absent
|
|
34
|
+
* → every holder is treated as live.
|
|
35
|
+
*/
|
|
36
|
+
isRunActive?(runId: string): Promise<boolean>;
|
|
18
37
|
/**
|
|
19
38
|
* Deliver a human's reply to a parked tool call — an approve/reject {@link import('../types.js').Decision}
|
|
20
39
|
* for an `action`, or an {@link import('../elicitation.js').ElicitationReply} for a question set.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-runner.d.ts","sourceRoot":"","sources":["../../../src/spi/agent-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-runner.d.ts","sourceRoot":"","sources":["../../../src/spi/agent-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,kDAAkD;AAClD,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxF;;;;;;OAMG;IACH,WAAW,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9C;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { Actor, MessageAttachment, PageContext } from '../types.js';
|
|
2
|
+
import { type AgentStore } from './agent-store.js';
|
|
3
|
+
/**
|
|
4
|
+
* Why a thread's queue stopped draining. A paused queue keeps its messages; nothing starts until
|
|
5
|
+
* someone resumes it (`POST <base>/threads/:id/queue/resume`, `chat.queue.resume()`).
|
|
6
|
+
*
|
|
7
|
+
* - `run_failed` the turn before it failed — the next message would likely fail the same way,
|
|
8
|
+
* and the person should see the error before more of their messages are spent.
|
|
9
|
+
* - `cancelled` someone pressed Stop. Stop means stop: the queue does not start behind it.
|
|
10
|
+
* An interrupt (`mode: 'interrupt'`) is the exception — its message starts.
|
|
11
|
+
* - `quota_exceeded` the next message's actor is over budget; resuming later retries the check.
|
|
12
|
+
* - `start_failed` the next message could not be started (the runner refused it).
|
|
13
|
+
*/
|
|
14
|
+
export type QueuePauseReason = 'run_failed' | 'cancelled' | 'quota_exceeded' | 'start_failed';
|
|
15
|
+
export interface QueuePause {
|
|
16
|
+
reason: QueuePauseReason;
|
|
17
|
+
/** Human-facing detail (the failure, the quota window), when there is one. */
|
|
18
|
+
message?: string;
|
|
19
|
+
/** ISO-8601 instant the queue paused. */
|
|
20
|
+
at: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A message a person sent while a turn was still running on the thread, waiting its turn. It is not
|
|
24
|
+
* part of the transcript until it starts: the loop appends it as the turn's user message, exactly as
|
|
25
|
+
* if it had been sent then. Everything a send carries is captured at enqueue time, resolved and
|
|
26
|
+
* checked there (agent, model, attachments), so a queued message starts with no request around it.
|
|
27
|
+
*/
|
|
28
|
+
export interface QueuedMessage {
|
|
29
|
+
id: string;
|
|
30
|
+
threadId: string;
|
|
31
|
+
/** Who queued it. The turn it starts runs as this actor. */
|
|
32
|
+
actor: Actor;
|
|
33
|
+
content: string;
|
|
34
|
+
attachments?: MessageAttachment[];
|
|
35
|
+
agentName?: string;
|
|
36
|
+
model?: string;
|
|
37
|
+
pageContext?: PageContext;
|
|
38
|
+
/**
|
|
39
|
+
* Queued by an interrupt (`POST chat { mode: 'interrupt' }`): the running turn was cancelled to
|
|
40
|
+
* make room for it, so the cancel starts it instead of pausing the queue.
|
|
41
|
+
*/
|
|
42
|
+
interrupt?: boolean;
|
|
43
|
+
createdAt: string;
|
|
44
|
+
updatedAt: string;
|
|
45
|
+
}
|
|
46
|
+
/** A queued message as the wire shows it — {@link QueuedMessage} without the actor or thread. */
|
|
47
|
+
export interface QueuedMessageView {
|
|
48
|
+
id: string;
|
|
49
|
+
content: string;
|
|
50
|
+
attachments?: MessageAttachment[];
|
|
51
|
+
agentName?: string;
|
|
52
|
+
model?: string;
|
|
53
|
+
interrupt?: boolean;
|
|
54
|
+
createdAt: string;
|
|
55
|
+
updatedAt: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A thread's queue: its waiting messages in the order they will run, and whether it is draining.
|
|
59
|
+
* What `GET <base>/threads/:id/queue` answers, what `ThreadDetail.queue` carries, and what every
|
|
60
|
+
* `queue` stream frame snapshots.
|
|
61
|
+
*/
|
|
62
|
+
export interface ChatQueueState {
|
|
63
|
+
items: QueuedMessageView[];
|
|
64
|
+
paused: QueuePause | null;
|
|
65
|
+
}
|
|
66
|
+
export interface EnqueueMessageInput {
|
|
67
|
+
threadId: string;
|
|
68
|
+
actor: Actor;
|
|
69
|
+
content: string;
|
|
70
|
+
attachments?: MessageAttachment[];
|
|
71
|
+
agentName?: string;
|
|
72
|
+
model?: string;
|
|
73
|
+
pageContext?: PageContext;
|
|
74
|
+
interrupt?: boolean;
|
|
75
|
+
/** `'tail'` (default) runs it after everything already waiting; `'head'` runs it next. */
|
|
76
|
+
at?: 'tail' | 'head';
|
|
77
|
+
}
|
|
78
|
+
/** What `PATCH <base>/queue/:messageId` may change. An omitted key leaves the field as it is. */
|
|
79
|
+
export interface QueuedMessagePatch {
|
|
80
|
+
content?: string;
|
|
81
|
+
/** `null` drops every attachment. */
|
|
82
|
+
attachments?: MessageAttachment[] | null;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A store that can hold a thread's queue of waiting messages, and admit ONE run per thread at a time.
|
|
86
|
+
*
|
|
87
|
+
* Probed STRUCTURALLY ({@link isChatQueueStore}), like `ThreadTurnReader`: a store that predates it
|
|
88
|
+
* keeps the old behaviour (a send on a busy thread starts a second, concurrent run). All members or
|
|
89
|
+
* none — a queue without the admission primitives cannot be drained safely across processes.
|
|
90
|
+
*
|
|
91
|
+
* Admission is the thread's active run (`activeRunId` on a thread read), compare-and-set:
|
|
92
|
+
* - {@link claimActiveStream} sets it to `runId` only when it is free, already `runId` (a retried
|
|
93
|
+
* claim is idempotent), or held by `replacing` (a handoff from the run that is settling, or a
|
|
94
|
+
* takeover from a holder the runner reports dead). Exactly one of two racing claims wins.
|
|
95
|
+
* - {@link releaseActiveStream} clears it only when `runId` still holds it — so a run that settles
|
|
96
|
+
* after it handed the thread to the next one cannot clear the next one's claim.
|
|
97
|
+
*/
|
|
98
|
+
export interface ChatQueueStore {
|
|
99
|
+
enqueueMessage(input: EnqueueMessageInput): Promise<QueuedMessage>;
|
|
100
|
+
/** The thread's waiting messages, in run order (the head first). */
|
|
101
|
+
listQueue(threadId: string): Promise<QueuedMessage[]>;
|
|
102
|
+
getQueuedMessage(id: string): Promise<QueuedMessage | null>;
|
|
103
|
+
/** `null` when there is no such message (it started, or was removed). */
|
|
104
|
+
updateQueuedMessage(id: string, patch: QueuedMessagePatch): Promise<QueuedMessage | null>;
|
|
105
|
+
/** Move a message to `index` (clamped) in its thread's run order. `false` when it is gone. */
|
|
106
|
+
moveQueuedMessage(id: string, index: number): Promise<boolean>;
|
|
107
|
+
/**
|
|
108
|
+
* Remove a message. `false` when it was already gone — which is also how a drain learns that the
|
|
109
|
+
* head it was about to start was deleted under it, so it must be a real conditional delete.
|
|
110
|
+
*/
|
|
111
|
+
removeQueuedMessage(id: string): Promise<boolean>;
|
|
112
|
+
/** Remove every waiting message on the thread; answers how many there were. */
|
|
113
|
+
clearQueue(threadId: string): Promise<number>;
|
|
114
|
+
queuePause(threadId: string): Promise<QueuePause | null>;
|
|
115
|
+
setQueuePause(threadId: string, pause: QueuePause | null): Promise<void>;
|
|
116
|
+
/** The run currently holding the thread, or `null`. */
|
|
117
|
+
activeRunForThread(threadId: string): Promise<string | null>;
|
|
118
|
+
claimActiveStream(threadId: string, runId: string, options?: {
|
|
119
|
+
replacing?: string;
|
|
120
|
+
}): Promise<boolean>;
|
|
121
|
+
releaseActiveStream(threadId: string, runId: string): Promise<boolean>;
|
|
122
|
+
}
|
|
123
|
+
/** Whether `store` implements every {@link ChatQueueStore} member. */
|
|
124
|
+
export declare function isChatQueueStore(store: AgentStore): store is AgentStore & ChatQueueStore;
|
|
125
|
+
/**
|
|
126
|
+
* Release the thread `runId` was streaming — conditionally when the store can compare, so a run
|
|
127
|
+
* that already handed the thread to the next queued turn does not clear that turn's claim; the old
|
|
128
|
+
* unconditional clear on a store that cannot.
|
|
129
|
+
*/
|
|
130
|
+
export declare function releaseThreadRun(store: AgentStore, threadId: string, runId: string): Promise<void>;
|
|
131
|
+
/** The wire view of a queued message. */
|
|
132
|
+
export declare function queuedMessageView(message: QueuedMessage): QueuedMessageView;
|
|
133
|
+
//# sourceMapp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queueMessage',
|
|
4
|
+
'listQueue',
|
|
5
|
+
'getQueuedMessage',
|
|
6
|
+
'updateQueuedMessage',
|
|
7
|
+
'moveQueuedMessage',
|
|
8
|
+
'removeQueuedMessage',
|
|
9
|
+
'clearQueue',
|
|
10
|
+
'queuePause',
|
|
11
|
+
'setQueuePause',
|
|
12
|
+
'activeRunForThread',
|
|
13
|
+
'claimActiveStream',
|
|
14
|
+
'releaseActiveStream',
|
|
15
|
+
];
|
|
16
|
+
/** Whether `store` implements every {@link ChatQueueStore} member. */
|
|
17
|
+
export function isChatQueueStore(store) {
|
|
18
|
+
const candidate = store;
|
|
19
|
+
return CHAT_QUEUE_METHODS.every((method) => typeof candidate[method] === 'function');
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Release the thread `runId` was streaming — conditionally when the store can compare, so a run
|
|
23
|
+
* that already handed the thread to the next queued turn does not clear that turn's claim; the old
|
|
24
|
+
* unconditional clear on a store that cannot.
|
|
25
|
+
*/
|
|
26
|
+
export async function releaseThreadRun(store, threadId, runId) {
|
|
27
|
+
if (isChatQueueStore(store)) {
|
|
28
|
+
await store.releaseActiveStream(threadId, runId);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
await clearActiveRun(store, threadId, runId);
|
|
32
|
+
}
|
|
33
|
+
/** The wire view of a queued message. */
|
|
34
|
+
export function queuedMessageView(message) {
|
|
35
|
+
return {
|
|
36
|
+
id: message.id,
|
|
37
|
+
content: message.content,
|
|
38
|
+
...(message.attachments !== undefined && message.attachments.length > 0
|
|
39
|
+
? { attachments: message.attachments }
|
|
40
|
+
: {}),
|
|
41
|
+
...(message.agentName !== undefined ? { agentName: message.agentName } : {}),
|
|
42
|
+
...(message.model !== undefined ? { model: message.model } : {}),
|
|
43
|
+
...(message.interrupt === true ? { interrupt: true } : {}),
|
|
44
|
+
createdAt: message.createdAt,
|
|
45
|
+
updatedAt: message.updatedAt,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=chat-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-queue.js","sourceRoot":"","sources":["../../../src/spi/chat-queue.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAuInE,MAAM,kBAAkB,GAAG;IACzB,gBAAgB;IAChB,WAAW;IACX,kBAAkB;IAClB,qBAAqB;IACrB,mBAAmB;IACnB,qBAAqB;IACrB,YAAY;IACZ,YAAY;IACZ,eAAe;IACf,oBAAoB;IACpB,mBAAmB;IACnB,qBAAqB;CAC+B,CAAC;AAEvD,sEAAsE;AACtE,MAAM,UAAU,gBAAgB,CAAC,KAAiB;IAChD,MAAM,SAAS,GAAG,KAA2C,CAAC;IAC9D,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,UAAU,CAAC,CAAC;AACvF,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAiB,EACjB,QAAgB,EAChB,KAAa;IAEb,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,KAAK,CAAC,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACjD,OAAO;IACT,CAAC;IACD,MAAM,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC;AAED,yCAAyC;AACzC,MAAM,UAAU,iBAAiB,CAAC,OAAsB;IACtD,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;YACrE,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE;YACtC,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5E,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChE,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1D,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC;AACJ,CAAC"}
|
|
@@ -31,6 +31,8 @@ export declare class LucidGovernanceQueries implements AgentGovernanceQueries {
|
|
|
31
31
|
constructor(db: LucidDatabaseLike, pricingStore?: AgentPricingStore | undefined, options?: LucidGovernanceQueriesOptions);
|
|
32
32
|
/** Provision the shared schema on first use (no-op when disabled), memoized across the stores. */
|
|
33
33
|
private ready;
|
|
34
|
+
/** Provision the shared schema now (what the agent provider calls at app start). Idempotent. */
|
|
35
|
+
ensureSchema(): Promise<void>;
|
|
34
36
|
private loadPricing;
|
|
35
37
|
/** Provider-reported cost wins per row; otherwise the cache-aware token estimate (0 when unpriced). */
|
|
36
38
|
private rowCost;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lucid-governance-queries.d.ts","sourceRoot":"","sources":["../../../src/stores/lucid-governance-queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,EAEd,SAAS,EAET,cAAc,EAKd,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,eAAe,EAChB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,yBAAyB,CAAC;AAEpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA+DpD,kDAAkD;AAClD,MAAM,WAAW,6BAA6B;IAC5C;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AA8DD;;;;;;;;;;;;;GAaG;AACH,qBAAa,sBAAuB,YAAW,sBAAsB;IAIjE,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAJhC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAU;IAE3C,YACmB,EAAE,EAAE,iBAAiB,EACrB,YAAY,CAAC,EAAE,iBAAiB,YAAA,EACjD,OAAO,GAAE,6BAAkC,EAG5C;IAED,kGAAkG;IAClG,OAAO,CAAC,KAAK;
|
|
1
|
+
{"version":3,"file":"lucid-governance-queries.d.ts","sourceRoot":"","sources":["../../../src/stores/lucid-governance-queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,EAEd,SAAS,EAET,cAAc,EAKd,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,eAAe,EAChB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,yBAAyB,CAAC;AAEpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA+DpD,kDAAkD;AAClD,MAAM,WAAW,6BAA6B;IAC5C;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AA8DD;;;;;;;;;;;;;GAaG;AACH,qBAAa,sBAAuB,YAAW,sBAAsB;IAI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xE;IAED;;;;OAIG;IACG,cAAc,CAAC,KAAK,GAAE,cAAmB,GAAG,OAAO,CAAC,cAAc,CAAC,CAwExE;IAED;;;;;OAKG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAyD3E;CACF"}
|
|
@@ -125,6 +125,10 @@ export class LucidGovernanceQueries {
|
|
|
125
125
|
ready() {
|
|
126
126
|
return this.autoCreateTables ? ensureAgentTables(this.db) : Promise.resolve();
|
|
127
127
|
}
|
|
128
|
+
/** Provision the shared schema now (what the agent provider calls at app start). Idempotent. */
|
|
129
|
+
ensureSchema() {
|
|
130
|
+
return this.ready();
|
|
131
|
+
}
|
|
128
132
|
async loadPricing() {
|
|
129
133
|
const pricing = new Map();
|
|
130
134
|
if (this.pricingStore === undefined)
|