@adonis-agora/agent 0.52.1 → 0.53.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/dist/providers/agent_provider.d.ts +2 -2
  3. package/dist/providers/agent_provider.d.ts.map +1 -1
  4. package/dist/providers/agent_provider.js +6 -4
  5. package/dist/providers/agent_provider.js.map +1 -1
  6. package/dist/providers/mcp_provider.d.ts.map +1 -1
  7. package/dist/providers/mcp_provider.js +2 -1
  8. package/dist/providers/mcp_provider.js.map +1 -1
  9. package/dist/src/agent-deps-factory.d.ts.map +1 -1
  10. package/dist/src/agent-deps-factory.js +4 -0
  11. package/dist/src/agent-deps-factory.js.map +1 -1
  12. package/dist/src/agent-deps.d.ts +5 -0
  13. package/dist/src/agent-deps.d.ts.map +1 -1
  14. package/dist/src/agent-deps.js.map +1 -1
  15. package/dist/src/authorizer.d.ts +11 -3
  16. package/dist/src/authorizer.d.ts.map +1 -1
  17. package/dist/src/authorizer.js +13 -3
  18. package/dist/src/authorizer.js.map +1 -1
  19. package/dist/src/confirm-token.d.ts +52 -0
  20. package/dist/src/confirm-token.d.ts.map +1 -0
  21. package/dist/src/confirm-token.js +103 -0
  22. package/dist/src/confirm-token.js.map +1 -0
  23. package/dist/src/confirmed-tool.d.ts +139 -0
  24. package/dist/src/confirmed-tool.d.ts.map +1 -0
  25. package/dist/src/confirmed-tool.js +203 -0
  26. package/dist/src/confirmed-tool.js.map +1 -0
  27. package/dist/src/define_config.d.ts +11 -2
  28. package/dist/src/define_config.d.ts.map +1 -1
  29. package/dist/src/define_config.js.map +1 -1
  30. package/dist/src/index.d.ts +13 -5
  31. package/dist/src/index.d.ts.map +1 -1
  32. package/dist/src/index.js +9 -4
  33. package/dist/src/index.js.map +1 -1
  34. package/dist/src/lucid-token-stream-sink.d.ts +124 -0
  35. package/dist/src/lucid-token-stream-sink.d.ts.map +1 -0
  36. package/dist/src/lucid-token-stream-sink.js +324 -0
  37. package/dist/src/lucid-token-stream-sink.js.map +1 -0
  38. package/dist/src/mcp/define_config.d.ts +7 -0
  39. package/dist/src/mcp/define_config.d.ts.map +1 -1
  40. package/dist/src/mcp/define_config.js.map +1 -1
  41. package/dist/src/spi/confirm-token-store.d.ts +30 -0
  42. package/dist/src/spi/confirm-token-store.d.ts.map +1 -0
  43. package/dist/src/spi/confirm-token-store.js +2 -0
  44. package/dist/src/spi/confirm-token-store.js.map +1 -0
  45. package/dist/src/spi/token-stream-sink.d.ts +9 -1
  46. package/dist/src/spi/token-stream-sink.d.ts.map +1 -1
  47. package/dist/src/spi/token-stream-sink.js +5 -4
  48. package/dist/src/spi/token-stream-sink.js.map +1 -1
  49. package/dist/src/stores/factory.d.ts +60 -1
  50. package/dist/src/stores/factory.d.ts.map +1 -1
  51. package/dist/src/stores/factory.js +21 -1
  52. package/dist/src/stores/factory.js.map +1 -1
  53. package/dist/src/stores/lucid-confirm-tokens.d.ts +38 -0
  54. package/dist/src/stores/lucid-confirm-tokens.d.ts.map +1 -0
  55. package/dist/src/stores/lucid-confirm-tokens.js +81 -0
  56. package/dist/src/stores/lucid-confirm-tokens.js.map +1 -0
  57. package/dist/src/stores/lucid-schema.d.ts +26 -6
  58. package/dist/src/stores/lucid-schema.d.ts.map +1 -1
  59. package/dist/src/stores/lucid-schema.js +50 -7
  60. package/dist/src/stores/lucid-schema.js.map +1 -1
  61. package/dist/src/testing/index.d.ts +1 -0
  62. package/dist/src/testing/index.d.ts.map +1 -1
  63. package/dist/src/testing/index.js +1 -0
  64. package/dist/src/testing/index.js.map +1 -1
  65. package/dist/src/tool-registry.d.ts +20 -1
  66. package/dist/src/tool-registry.d.ts.map +1 -1
  67. package/dist/src/tool-registry.js +15 -2
  68. package/dist/src/tool-registry.js.map +1 -1
  69. package/dist/src/types.d.ts +16 -0
  70. package/dist/src/types.d.ts.map +1 -1
  71. package/dist/stubs/config/agent.stub +1 -0
  72. package/dist/stubs/config/mcp.stub +5 -0
  73. package/dist/stubs/database/migrations/create_agent_tables.stub +3 -2
  74. package/package.json +1 -1
  75. package/skills/agent-governance/SKILL.md +1 -0
  76. package/skills/agent-setup/SKILL.md +22 -1
  77. package/skills/agent-tools/SKILL.md +37 -1
@@ -0,0 +1,324 @@
1
+ import { AGENT_TABLES, ensureStreamFrameTable, rowsOf } from './stores/lucid-schema.js';
2
+ /** Default TTL (seconds) for a run's rows: 1h past its last write, the same window the Redis sink keeps. */
3
+ const DEFAULT_TTL_SECONDS = 3600;
4
+ /** Default gap (ms) between two reads of a run a subscriber is following. */
5
+ const DEFAULT_POLL_INTERVAL_MS = 250;
6
+ /** Default gap (ms) between two reads once a run has been quiet for {@link IDLE_AFTER_MS}. */
7
+ const DEFAULT_IDLE_POLL_INTERVAL_MS = 1000;
8
+ /** How long a run has to write nothing before its subscribers slow down to the idle interval. */
9
+ const IDLE_AFTER_MS = 5000;
10
+ /** Default window (ms) consecutive `text` frames are gathered over before they are written as one row. */
11
+ const DEFAULT_FLUSH_MS = 50;
12
+ /** Rows read per query, so a long run's replay is paged rather than loaded whole. */
13
+ const READ_PAGE = 500;
14
+ /** Run ids deleted per statement by {@link LucidTokenStreamSink.purgeExpired}. */
15
+ const PURGE_CHUNK = 200;
16
+ /** The least time between two purges an instance starts on its own (see `autoPurge`). */
17
+ const AUTO_PURGE_EVERY_MS = 60_000;
18
+ /** Attempts at one append before a sequence-number collision is reported instead of retried. */
19
+ const APPEND_ATTEMPTS = 8;
20
+ function toInt(value) {
21
+ if (typeof value === 'number')
22
+ return value;
23
+ if (typeof value === 'bigint')
24
+ return Number(value);
25
+ if (typeof value === 'string')
26
+ return Number.parseInt(value, 10) || 0;
27
+ return 0;
28
+ }
29
+ /**
30
+ * Did this insert lose the race for a `(run_id, seq)`? Read off the driver's own code — Postgres
31
+ * `23505`, SQLite `SQLITE_CONSTRAINT_*`, MySQL `ER_DUP_ENTRY`/1062, SQL Server 2627 — so nothing
32
+ * else (a missing table, a lost connection) is ever retried as though it were one.
33
+ */
34
+ function isUniqueViolation(error) {
35
+ const e = error;
36
+ if (e === null || typeof e !== 'object')
37
+ return false;
38
+ if (e.code === '23505' || e.code === 'ER_DUP_ENTRY')
39
+ return true;
40
+ if (typeof e.code === 'string' && e.code.startsWith('SQLITE_CONSTRAINT'))
41
+ return true;
42
+ return e.errno === 1062 || e.number === 2627;
43
+ }
44
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
45
+ /**
46
+ * A multi-replica {@link TokenStreamSink} over the app's SQL database (through `@adonisjs/lucid`) —
47
+ * for a deployment with several replicas and NO Redis. The replica running the model turn appends
48
+ * each frame as a row of `agent_stream_frame`; any replica serves the run's SSE by reading the rows
49
+ * past its cursor, in order, until it meets the end marker. A subscriber that attaches late, or
50
+ * after the run ended, replays from the first row — the same guarantee the in-process and Redis
51
+ * sinks give.
52
+ *
53
+ * Two things differ from the Redis sink, and both are the price of having no broker:
54
+ *
55
+ * - **Delivery is polled.** There is no publish to wake a subscriber, so a frame waits up to
56
+ * `pollIntervalMs` (250 ms) before a browser sees it.
57
+ * - **Text is coalesced on the way in.** Consecutive `text` frames written within `flushMs`
58
+ * (50 ms) are stored as ONE `text` frame holding their concatenation. The stored rows are the
59
+ * run's stream: every subscriber, on every replica, reads the same rows in the same order, so
60
+ * the SSE event ids `AgentSseEncoder` counts from them — and an `after` cursor — stay exact. They
61
+ * are NOT the ids the in-process sink would have produced for the same run (it numbers every
62
+ * token), which only matters to a cursor carried across a change of sink.
63
+ *
64
+ * Sequence numbers are per run, start at 1 and have no gaps: each append takes `MAX(seq) + 1` for
65
+ * its run in the same statement that inserts it, and the `(run_id, seq)` primary key turns a
66
+ * collision into a retry. A run normally has ONE writer, and then no append ever collides; the
67
+ * retry exists for a parent whose delegated children (each forwarding into its stream, possibly
68
+ * from another replica) write at once. Nothing depends on ordering across runs.
69
+ *
70
+ * Text a writer is still gathering lives in the process for at most `flushMs`; a process that dies
71
+ * in that window loses it from the LIVE stream (the persisted message is unaffected).
72
+ *
73
+ * Wire it with `defineConfig({ sink: tokenSinks.lucid() })`.
74
+ */
75
+ export class LucidTokenStreamSink {
76
+ db;
77
+ table;
78
+ pollIntervalMs;
79
+ idlePollIntervalMs;
80
+ flushMs;
81
+ ttlSeconds;
82
+ autoPurge;
83
+ autoCreateTables;
84
+ writes = new Map();
85
+ provisioned;
86
+ lastAutoPurge = 0;
87
+ constructor(db, options = {}) {
88
+ this.db = db;
89
+ const table = options.tableName ?? AGENT_TABLES.streamFrames;
90
+ // The name is spliced into SQL (DDL takes no bindings), so it has to be a plain identifier.
91
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(table)) {
92
+ throw new Error(`LucidTokenStreamSink: "${table}" is not a valid table name`);
93
+ }
94
+ this.table = table;
95
+ this.pollIntervalMs = Math.max(1, options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS);
96
+ this.idlePollIntervalMs = Math.max(this.pollIntervalMs, options.idlePollIntervalMs ?? DEFAULT_IDLE_POLL_INTERVAL_MS);
97
+ this.flushMs = Math.max(0, options.flushMs ?? DEFAULT_FLUSH_MS);
98
+ this.ttlSeconds = options.ttlSeconds ?? DEFAULT_TTL_SECONDS;
99
+ this.autoPurge = options.autoPurge ?? true;
100
+ this.autoCreateTables = options.autoCreateTables ?? true;
101
+ }
102
+ /**
103
+ * Create the frame table if it is missing. The agent provider calls this once as the app starts;
104
+ * a sink built by hand falls back to it on first use. A no-op under `autoCreateTables: false`.
105
+ */
106
+ ensureSchema() {
107
+ if (!this.autoCreateTables)
108
+ return Promise.resolve();
109
+ if (this.provisioned === undefined) {
110
+ this.provisioned = ensureStreamFrameTable(this.db, this.table).catch((error) => {
111
+ this.provisioned = undefined;
112
+ throw error;
113
+ });
114
+ }
115
+ return this.provisioned;
116
+ }
117
+ runWrites(runId) {
118
+ let state = this.writes.get(runId);
119
+ if (state === undefined) {
120
+ state = {
121
+ text: null,
122
+ timer: undefined,
123
+ tail: Promise.resolve(),
124
+ pending: 0,
125
+ failure: undefined,
126
+ };
127
+ this.writes.set(runId, state);
128
+ }
129
+ return state;
130
+ }
131
+ /** Forget a run's write state once nothing is gathered, queued or left to report. */
132
+ release(runId, state) {
133
+ if (state.pending === 0 &&
134
+ state.text === null &&
135
+ state.failure === undefined &&
136
+ this.writes.get(runId) === state) {
137
+ this.writes.delete(runId);
138
+ }
139
+ }
140
+ /** Queue `work` behind every write already queued for the run, so rows land in call order. */
141
+ enqueue(runId, state, work) {
142
+ state.pending += 1;
143
+ const next = state.tail.then(work);
144
+ state.tail = next
145
+ .then(() => undefined, () => undefined)
146
+ .then(() => {
147
+ state.pending -= 1;
148
+ this.release(runId, state);
149
+ });
150
+ return next;
151
+ }
152
+ /** Queue the gathered text (if any) as one `text` row. */
153
+ flushText(runId, state) {
154
+ if (state.timer !== undefined) {
155
+ clearTimeout(state.timer);
156
+ state.timer = undefined;
157
+ }
158
+ if (state.text === null)
159
+ return Promise.resolve();
160
+ const frame = { t: 'text', v: state.text };
161
+ state.text = null;
162
+ return this.enqueue(runId, state, () => this.append(runId, JSON.stringify(frame)));
163
+ }
164
+ /** Raise, once, a gathered write that failed with nobody awaiting it. */
165
+ raiseFailure(state) {
166
+ const failure = state.failure;
167
+ if (failure !== undefined) {
168
+ state.failure = undefined;
169
+ throw failure.error;
170
+ }
171
+ }
172
+ /** Append one row to the run — a frame, or the end marker (`null`). */
173
+ async append(runId, frame) {
174
+ await this.ensureSchema();
175
+ for (let attempt = 1;; attempt += 1) {
176
+ try {
177
+ // The next number and the insert are one statement; see the class comment for why the
178
+ // primary key, not a lock, is what settles two writers asking at once.
179
+ await this.db.rawQuery(`INSERT INTO "${this.table}" ("run_id", "seq", "frame", "created_at") ` +
180
+ `SELECT ?, COALESCE(MAX("seq"), 0) + 1, ?, ? FROM "${this.table}" WHERE "run_id" = ?`, [runId, frame, Date.now(), runId]);
181
+ return;
182
+ }
183
+ catch (error) {
184
+ if (attempt >= APPEND_ATTEMPTS || !isUniqueViolation(error))
185
+ throw error;
186
+ }
187
+ }
188
+ }
189
+ /**
190
+ * The run's writer. Writers opened for the same run in one process share what they are gathering,
191
+ * so a delegated run's text (forwarded through a {@link childSinkWriter}) and its parent's next
192
+ * frame keep the order they were written in.
193
+ */
194
+ open(runId) {
195
+ return {
196
+ write: async (frame) => {
197
+ const state = this.runWrites(runId);
198
+ this.raiseFailure(state);
199
+ if (frame.t === 'text' && this.flushMs > 0) {
200
+ state.text = (state.text ?? '') + frame.v;
201
+ // Counted from the FIRST gathered token, not the last: a steady stream still reaches the
202
+ // table every `flushMs`, instead of being held for as long as the model keeps talking.
203
+ if (state.timer === undefined) {
204
+ state.timer = setTimeout(() => {
205
+ state.timer = undefined;
206
+ this.flushText(runId, state).catch((error) => {
207
+ state.failure = { error };
208
+ });
209
+ }, this.flushMs);
210
+ }
211
+ return;
212
+ }
213
+ const flushed = this.flushText(runId, state);
214
+ const appended = this.enqueue(runId, state, () => this.append(runId, JSON.stringify(frame)));
215
+ await Promise.all([flushed, appended]);
216
+ },
217
+ flush: async () => {
218
+ const state = this.runWrites(runId);
219
+ const flushed = this.flushText(runId, state);
220
+ await Promise.all([flushed, state.tail]);
221
+ this.raiseFailure(state);
222
+ this.release(runId, state);
223
+ },
224
+ end: async () => {
225
+ const state = this.runWrites(runId);
226
+ const flushed = this.flushText(runId, state);
227
+ const ended = this.enqueue(runId, state, () => this.append(runId, null));
228
+ await Promise.all([flushed, ended]);
229
+ this.raiseFailure(state);
230
+ this.release(runId, state);
231
+ this.purgeInBackground();
232
+ },
233
+ };
234
+ }
235
+ async *subscribe(runId) {
236
+ await this.ensureSchema();
237
+ let cursor = 0;
238
+ let quietSince = Date.now();
239
+ while (true) {
240
+ const rows = await this.db
241
+ .from(this.table)
242
+ .where('run_id', runId)
243
+ .where('seq', '>', cursor)
244
+ .orderBy('seq', 'asc')
245
+ .limit(READ_PAGE)
246
+ .select('seq', 'frame');
247
+ let ended = false;
248
+ for (const row of rows) {
249
+ cursor = toInt(row.seq);
250
+ if (row.frame === null || row.frame === undefined) {
251
+ ended = true;
252
+ continue;
253
+ }
254
+ yield JSON.parse(String(row.frame));
255
+ }
256
+ if (ended) {
257
+ return;
258
+ }
259
+ if (rows.length > 0) {
260
+ quietSince = Date.now();
261
+ // A full page means there may be more already written: read on without waiting.
262
+ if (rows.length >= READ_PAGE)
263
+ continue;
264
+ }
265
+ await sleep(Date.now() - quietSince >= IDLE_AFTER_MS ? this.idlePollIntervalMs : this.pollIntervalMs);
266
+ }
267
+ }
268
+ async has(runId) {
269
+ await this.ensureSchema();
270
+ return (await this.db.from(this.table).where('run_id', runId).first()) !== null;
271
+ }
272
+ async close(runId) {
273
+ const state = this.writes.get(runId);
274
+ if (state !== undefined) {
275
+ if (state.timer !== undefined)
276
+ clearTimeout(state.timer);
277
+ state.timer = undefined;
278
+ state.text = null;
279
+ state.failure = undefined;
280
+ await state.tail;
281
+ this.writes.delete(runId);
282
+ }
283
+ await this.ensureSchema();
284
+ await this.db.from(this.table).where('run_id', runId).delete();
285
+ }
286
+ /**
287
+ * Delete every run whose last write is older than `ttlSeconds` at `now` (epoch ms) — ended runs
288
+ * past their replay window and runs that crashed without ending alike. Returns how many runs went.
289
+ * Safe to call from any replica, and from several at once. A no-op under `ttlSeconds: 0`.
290
+ *
291
+ * An instance already calls it after a run ends (at most once a minute; `autoPurge`), which keeps
292
+ * the table bounded on a replica that streams. Call it from a schedule as well if a quiet
293
+ * deployment must not keep the last hour's streams around indefinitely.
294
+ */
295
+ async purgeExpired(now = Date.now()) {
296
+ if (this.ttlSeconds <= 0)
297
+ return 0;
298
+ await this.ensureSchema();
299
+ const cutoff = now - this.ttlSeconds * 1000;
300
+ // Two steps rather than one `DELETE … WHERE run_id IN (SELECT … FROM the same table)`, which
301
+ // MySQL refuses. A run that writes between the two was idle for the whole TTL a moment ago.
302
+ const lapsed = rowsOf(await this.db.rawQuery(`SELECT "run_id" AS run_id FROM "${this.table}" GROUP BY "run_id" HAVING MAX("created_at") < ?`, [cutoff])).map((row) => String(row.run_id));
303
+ for (let index = 0; index < lapsed.length; index += PURGE_CHUNK) {
304
+ await this.db
305
+ .from(this.table)
306
+ .whereIn('run_id', lapsed.slice(index, index + PURGE_CHUNK))
307
+ .delete();
308
+ }
309
+ return lapsed.length;
310
+ }
311
+ /** {@link purgeExpired}, unawaited and at most once a minute. Its failure is not the run's. */
312
+ purgeInBackground() {
313
+ if (!this.autoPurge || this.ttlSeconds <= 0)
314
+ return;
315
+ const now = Date.now();
316
+ if (now - this.lastAutoPurge < AUTO_PURGE_EVERY_MS)
317
+ return;
318
+ this.lastAutoPurge = now;
319
+ this.purgeExpired(now).catch(() => {
320
+ // Retried after the next run to end; a purge that cannot run must not fail a finished turn.
321
+ });
322
+ }
323
+ }
324
+ //# sourceMappingURL=lucid-token-stream-sink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lucid-token-stream-sink.js","sourceRoot":"","sources":["../../src/lucid-token-stream-sink.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAExF,4GAA4G;AAC5G,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,6EAA6E;AAC7E,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAErC,8FAA8F;AAC9F,MAAM,6BAA6B,GAAG,IAAI,CAAC;AAE3C,iGAAiG;AACjG,MAAM,aAAa,GAAG,IAAI,CAAC;AAE3B,0GAA0G;AAC1G,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,qFAAqF;AACrF,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB,kFAAkF;AAClF,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,yFAAyF;AACzF,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEnC,gGAAgG;AAChG,MAAM,eAAe,GAAG,CAAC,CAAC;AAsD1B,SAAS,KAAK,CAAC,KAAc;IAC3B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,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-1,4 +1,5 @@
1
1
  import type { RolesPolicy } from '../spi/roles-policy.js';
2
+ import type { EmptyRoles } from '../tool-registry.js';
2
3
  import type { McpAuth, McpAuthFactory } from './auth.js';
3
4
  import { anyOf, apiKeyAuth, authKitAuth, McpAuthError } from './auth.js';
4
5
  /**
@@ -58,6 +59,12 @@ export interface McpConfig {
58
59
  authorizer?: RolesPolicy;
59
60
  /** Roles a tool requires when it declares none. Defaults to `['ADMIN']`. */
60
61
  defaultRoles?: string[];
62
+ /**
63
+ * What an empty roles list means to the default authorizer: `'allow'` (default) — no restriction;
64
+ * `'deny'` — nobody, so a tool needs `roles` (or a non-empty `defaultRoles`) to be reachable. Only
65
+ * consulted when no `authorizer` is set.
66
+ */
67
+ emptyRoles?: EmptyRoles;
61
68
  /**
62
69
  * Restrict the exposed tools to this allow-list of names. Omit → all tools the acting actor's roles
63
70
  * permit are exposed.
@@ -1 +1 @@
1
- {"version":3,"file":"define_config.d.ts","sourceRoot":"","sources":["../../../src/mcp/define_config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,SAAS;IACxB,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IAChC;;;;OAIG;IACH,KAAK,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,K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;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IAChC;;;;OAIG;IACH,KAAK,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7D;;;OAGG;IACH,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;;;;OAIG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,iEAAiE;AACjE,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAE5D;AAED,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,qBAAqB,EACrB,OAAO,EACP,cAAc,EACd,cAAc,EACd,gBAAgB,GACjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"define_config.js","sourceRoot":"","sources":["../../../src/mcp/define_config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AA8DzE,iEAAiE;AACjE,MAAM,UAAU,eAAe,CAAC,MAAiB;IAC/C,OAAO,MAAM,CAAC;AAChB,CAAC;AAeD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"define_config.js","sourceRoot":"","sources":["../../../src/mcp/define_config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAoEzE,iEAAiE;AACjE,MAAM,UAAU,eAAe,CAAC,MAAiB;IAC/C,OAAO,MAAM,CAAC;AAChB,CAAC;AAeD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,30 @@
1
+ /** One confirmation being spent — what {@link ConfirmTokenStore.claim} records. */
2
+ export interface ConfirmTokenClaim {
3
+ /** SHA-256 (hex) of the token. The token itself is never stored. */
4
+ hash: string;
5
+ /** `ctx.actor.id` of the confirming actor. */
6
+ actorRef: string;
7
+ /** The tool the token was issued for. */
8
+ tool: string;
9
+ /** Epoch-ms the token stops being valid — after it the mark is dead weight and can be purged. */
10
+ expiresAt: number;
11
+ }
12
+ /**
13
+ * Makes a confirm token single use (see `defineConfirmedTool`). A signed token is stateless, so on
14
+ * its own it stays valid until it expires: a double tap, a network retry or a model repeating the
15
+ * call would commit twice inside that window. The store remembers which tokens were spent.
16
+ *
17
+ * Only the token's hash, the actor and the tool name are kept — never an argument or a value.
18
+ */
19
+ export interface ConfirmTokenStore {
20
+ /**
21
+ * Spend the token. `true` = this caller holds it and may commit; `false` = it was already spent.
22
+ * MUST be atomic: of two concurrent claims for one hash, exactly one gets `true`.
23
+ */
24
+ claim(input: ConfirmTokenClaim): Promise<boolean>;
25
+ /** Give the token back — the commit failed after the claim, so the caller may try again. */
26
+ release(hash: string): Promise<void>;
27
+ /** Drop the marks of tokens that expired before `now` (epoch-ms, default the clock). Returns how many. */
28
+ purgeExpired?(now?: number): Promise<number>;
29
+ }
30
+ //# sourceMappingURL=confirm-token-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirm-token-store.d.ts","sourceRoot":"","sources":["../../../src/spi/confirm-token-store.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IAChC,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,iGAAiG;IACjG,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,KAAK,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAClD,4FAA4F;IAC5F,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,0GAA0G;IAC1G,YAAY,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=confirm-token-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirm-token-store.js","sourceRoot":"","sources":["../../../src/spi/confirm-token-store.ts"],"names":[],"mappings":""}
@@ -83,6 +83,12 @@ export interface SinkWriter {
83
83
  write(frame: StreamFrame): void | Promise<void>;
84
84
  /** Mark the run's stream finished (no more frames). */
85
85
  end(): void | Promise<void>;
86
+ /**
87
+ * OPTIONAL: write out anything this writer is still holding back, without ending the stream. Only
88
+ * a sink that gathers frames before writing them (the Lucid sink coalesces text) has anything to
89
+ * do here; {@link childSinkWriter} calls it where a delegated run would have ended the stream.
90
+ */
91
+ flush?(): void | Promise<void>;
86
92
  }
87
93
  export interface TokenStreamSink {
88
94
  /** Open (or reopen) the writer for a run. */
@@ -106,7 +112,9 @@ export interface TokenStreamSink {
106
112
  * Forwarding is what makes a sub-agent visible at all: its own runId is not a stream anyone
107
113
  * subscribed to, so a question set it parks on would otherwise be written where nobody reads it.
108
114
  * The ancestor owns the stream's lifecycle across however many delegations it spans, so the child's
109
- * `end()` is a no-op — ending the shared stream mid-parent-run would cut the human off.
115
+ * `end()` is a no-op — ending the shared stream mid-parent-run would cut the human off. It does
116
+ * {@link SinkWriter.flush} what the child wrote, so nothing of the delegate's is still held back when
117
+ * its parent (possibly on another replica) writes the next frame.
110
118
  */
111
119
  export declare function childSinkWriter(inner: SinkWriter): SinkWriter;
112
120
  //# sourceMappingURL=token-stream-sink.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"token-stream-sink.d.ts","sourceRoot":"","sources":["../../../src/spi/token-stream-sink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAElF;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE;AAC1B;;;;GAIG;GACD;IACE,CAAC,EAAE,WAAW,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AACH;;;;GAIG;GACD;IAAE,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,gBAAgB,CAAA;CAAE;AACzC;;GAEG;GACD;IAAE,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,oBAAoB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE;AAC7D;;;;;;;;;GASG;GACD;IAAE,CAAC,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,kBAAkB,CAAA;CAAE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CAAC;CAChC;AAED,MAAM,WAAW,eAAe;IAC9B,6CAA6C;IAC7C,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACtD,8EAA8E;IAC9E,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;IACrD,6CAA6C;IAC7C,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C;;;;;OAKG;IACH,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACjD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAM7D"}
@@ -5,14 +5,15 @@
5
5
  * Forwarding is what makes a sub-agent visible at all: its own runId is not a stream anyone
6
6
  * subscribed to, so a question set it parks on would otherwise be written where nobody reads it.
7
7
  * The ancestor owns the stream's lifecycle across however many delegations it spans, so the child's
8
- * `end()` is a no-op — ending the shared stream mid-parent-run would cut the human off.
8
+ * `end()` is a no-op — ending the shared stream mid-parent-run would cut the human off. It does
9
+ * {@link SinkWriter.flush} what the child wrote, so nothing of the delegate's is still held back when
10
+ * its parent (possibly on another replica) writes the next frame.
9
11
  */
10
12
  export function childSinkWriter(inner) {
11
13
  return {
12
14
  write: (chunk) => inner.write(chunk),
13
- end: () => {
14
- /* the top-level run owns end() */
15
- },
15
+ // The top-level run owns end().
16
+ end: () => inner.flush?.(),
16
17
  };
17
18
  }
18
19
  //# sourceMappingURL=token-stream-sink.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"token-stream-sink.js","sourceRoot":"","sources":["../../../src/spi/token-stream-sink.ts"],"names":[],"mappings":"AA2FA;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,KAAiB;IAC/C,OAAO;QACL,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;QACpC,GAAG,EAAE,GAAG,EAAE;YACR,kCAAkC;QACpC,CAAC;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"token-stream-sink.js","sourceRoot":"","sources":["../../../src/spi/token-stream-sink.ts"],"names":[],"mappings":"AAiGA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,KAAiB;IAC/C,OAAO;QACL,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;QACpC,gCAAgC;QAChC,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE;KAC3B,CAAC;AACJ,CAAC"}
@@ -336,6 +336,48 @@ export interface RedisTokenSinkConfig {
336
336
  */
337
337
  client?: RedisStreamClient;
338
338
  }
339
+ /** Options for the Lucid (SQL) multi-replica token-stream sink — several replicas, no Redis. */
340
+ export interface LucidTokenSinkConfig {
341
+ /** Lucid connection name to use. Defaults to the `Database` default connection. */
342
+ connection?: string;
343
+ /** The frame table. Defaults to `agent_stream_frame`. */
344
+ tableName?: string;
345
+ /**
346
+ * Gap (ms) between two reads of a run a subscriber is following — the most a frame waits before a
347
+ * browser sees it. Defaults to 250.
348
+ */
349
+ pollIntervalMs?: number;
350
+ /**
351
+ * Gap (ms) between two reads once the run has been quiet for five seconds (parked on a human, a
352
+ * slow tool). Defaults to 1000.
353
+ */
354
+ idlePollIntervalMs?: number;
355
+ /**
356
+ * Window (ms) consecutive `text` frames are gathered over and written as one row, so a streamed
357
+ * answer is a handful of inserts rather than one per token. Defaults to 50; `0` writes every frame.
358
+ */
359
+ flushMs?: number;
360
+ /**
361
+ * TTL (seconds) of a run's rows, counted from its last write; `purgeExpired()` deletes what has
362
+ * lapsed. Defaults to 3600 (1h). Set `0` to retain until manual cleanup.
363
+ */
364
+ ttlSeconds?: number;
365
+ /**
366
+ * Purge lapsed runs as a side effect of ending a run, at most once a minute per replica. Default
367
+ * `true`. Set `false` to purge only from your own schedule (`sink.purgeExpired()`).
368
+ */
369
+ autoPurge?: boolean;
370
+ /**
371
+ * Create the frame table when the app starts. Default `true`. Set `false` to run the published
372
+ * migration (`createAgentTables`, which creates it too) instead.
373
+ */
374
+ autoCreateTables?: boolean;
375
+ /**
376
+ * Bring-your-own Lucid database (or any {@link LucidDatabaseLike}). When set, `'lucid.db'` is NOT
377
+ * resolved from the container and `connection` is ignored. Handy for tests and scripts.
378
+ */
379
+ db?: LucidDatabaseLike;
380
+ }
339
381
  /**
340
382
  * The token-sink factory namespace used in `config/agent.ts`, mirroring {@link stores}. Also exported as
341
383
  * `streamTransports` (an alias — pick whichever name reads better):
@@ -352,7 +394,8 @@ export interface RedisTokenSinkConfig {
352
394
  * Omitting `sink` entirely keeps the in-process sink (single replica); `tokenSinks.memory()` selects it
353
395
  * explicitly. `tokenSinks.redis()` fans a run's tokens across replicas over Redis pub/sub + a replayable
354
396
  * list, keeping the SSE envelope byte-identical. The `@adonisjs/redis` peer is imported ONLY inside the
355
- * `redis` thunk, so it stays fully optional.
397
+ * `redis` thunk, so it stays fully optional. `tokenSinks.lucid()` is the multi-replica sink for a
398
+ * deployment WITHOUT Redis: frames are rows in the app's SQL database, read by polling.
356
399
  */
357
400
  export declare const tokenSinks: {
358
401
  /** The in-process sink — per-run in-memory buffers, single replica. The default when `sink` is omitted. */
@@ -364,6 +407,14 @@ export declare const tokenSinks: {
364
407
  * passed.
365
408
  */
366
409
  redis(config?: RedisTokenSinkConfig): TokenSinkFactory;
410
+ /**
411
+ * The Lucid (SQL) multi-replica sink: any pod can serve any run's SSE stream, with no Redis — a
412
+ * run's frames are rows of `agent_stream_frame` on the app's database, which subscribers poll.
413
+ * Slower to deliver than Redis (up to `pollIntervalMs`) and it writes to your database on every
414
+ * streamed answer; pick {@link tokenSinks.redis} when Redis is already there. Requires
415
+ * `@adonisjs/lucid` installed + configured unless a `db` is passed.
416
+ */
417
+ lucid(config?: LucidTokenSinkConfig): TokenSinkFactory;
367
418
  };
368
419
  /** Alias of {@link tokenSinks}. */
369
420
  export declare const streamTransports: {
@@ -376,6 +427,14 @@ export declare const streamTransports: {
376
427
  * passed.
377
428
  */
378
429
  redis(config?: RedisTokenSinkConfig): TokenSinkFactory;
430
+ /**
431
+ * The Lucid (SQL) multi-replica sink: any pod can serve any run's SSE stream, with no Redis — a
432
+ * run's frames are rows of `agent_stream_frame` on the app's database, which subscribers poll.
433
+ * Slower to deliver than Redis (up to `pollIntervalMs`) and it writes to your database on every
434
+ * streamed answer; pick {@link tokenSinks.redis} when Redis is already there. Requires
435
+ * `@adonisjs/lucid` installed + configured unless a `db` is passed.
436
+ */
437
+ lucid(config?: LucidTokenSinkConfig): TokenSinkFactory;
379
438
  };
380
439
  /**
381
440
  * A configured {@link ActorDirectory}: a lazy thunk the agent provider calls at boot to build the
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/stores/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EACV,uBAAuB,EAGxB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,O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O,CAAC;IACpB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,EAAE,CAAC,EAAE,iBAAiB,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,UAAU;IACrB,2GAA2G;IAC3G,MAAM,IAAI,gBAAgB;IAO1B;;;;;OAKG;IACH,KAAK,UAAS,oBAAoB,GAAQ,gBAAgB;IAW1D;;;;;;OAMG;IACH,KAAK,UAAS,oBAAoB,GAAQ,gBAAgB;CAgB3D,CAAC;AAEF,mCAAmC;AACnC,eAAO,MAAM,gBAAgB;IAnD3B,2GAA2G;cACjG,gBAAgB;IAO1B;;;;;OAKG;mBACW,oBAAoB,GAAQ,gBAAgB;IAW1D;;;;;;OAMG;mBACW,oBAAoB,GAAQ,gBAAgB;CAmBlB,CAAC;AAsF3C;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,YAAY,KAAK,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAEpG,iDAAiD;AACjD,MAAM,WAAW,0BAA0B;IACzC,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB;IAC3B,uFAAuF;IACvF,MAAM,UAAS,0BAA0B,GAAQ,qBAAqB;CAMvE,CAAC"}
@@ -318,7 +318,8 @@ export const attachmentStores = {
318
318
  * Omitting `sink` entirely keeps the in-process sink (single replica); `tokenSinks.memory()` selects it
319
319
  * explicitly. `tokenSinks.redis()` fans a run's tokens across replicas over Redis pub/sub + a replayable
320
320
  * list, keeping the SSE envelope byte-identical. The `@adonisjs/redis` peer is imported ONLY inside the
321
- * `redis` thunk, so it stays fully optional.
321
+ * `redis` thunk, so it stays fully optional. `tokenSinks.lucid()` is the multi-replica sink for a
322
+ * deployment WITHOUT Redis: frames are rows in the app's SQL database, read by polling.
322
323
  */
323
324
  export const tokenSinks = {
324
325
  /** The in-process sink — per-run in-memory buffers, single replica. The default when `sink` is omitted. */
@@ -344,6 +345,25 @@ export const tokenSinks = {
344
345
  });
345
346
  };
346
347
  },
348
+ /**
349
+ * The Lucid (SQL) multi-replica sink: any pod can serve any run's SSE stream, with no Redis — a
350
+ * run's frames are rows of `agent_stream_frame` on the app's database, which subscribers poll.
351
+ * Slower to deliver than Redis (up to `pollIntervalMs`) and it writes to your database on every
352
+ * streamed answer; pick {@link tokenSinks.redis} when Redis is already there. Requires
353
+ * `@adonisjs/lucid` installed + configured unless a `db` is passed.
354
+ */
355
+ lucid(config = {}) {
356
+ return async (ctx) => {
357
+ const { LucidTokenStreamSink } = await import('../lucid-token-stream-sink.js');
358
+ const { connection, db: ownDb, ...options } = config;
359
+ const manager = ownDb === undefined ? await resolveLucidDatabase(ctx.app) : undefined;
360
+ const db = ownDb ??
361
+ (connection !== undefined
362
+ ? manager?.connection(connection)
363
+ : manager);
364
+ return new LucidTokenStreamSink(db, Object.fromEntries(Object.entries(options).filter(([, value]) => value !== undefined)));
365
+ };
366
+ },
347
367
  };
348
368
  /** Alias of {@link tokenSinks}. */
349
369
  export const streamTransports = tokenSinks;