@dynamicagents/core 0.9.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 (168) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +522 -0
  3. package/dist/a2a/agent-stub.d.ts +60 -0
  4. package/dist/a2a/agent-stub.js +1 -0
  5. package/dist/a2a/caller-token.d.ts +44 -0
  6. package/dist/a2a/caller-token.js +61 -0
  7. package/dist/a2a/caller.d.ts +23 -0
  8. package/dist/a2a/caller.js +33 -0
  9. package/dist/a2a/card.d.ts +158 -0
  10. package/dist/a2a/card.js +163 -0
  11. package/dist/a2a/context.d.ts +19 -0
  12. package/dist/a2a/context.js +61 -0
  13. package/dist/a2a/deliver.d.ts +159 -0
  14. package/dist/a2a/deliver.js +185 -0
  15. package/dist/a2a/executor.d.ts +84 -0
  16. package/dist/a2a/executor.js +106 -0
  17. package/dist/a2a/index.d.ts +35 -0
  18. package/dist/a2a/index.js +34 -0
  19. package/dist/a2a/notify.d.ts +106 -0
  20. package/dist/a2a/notify.js +180 -0
  21. package/dist/a2a/parts.d.ts +45 -0
  22. package/dist/a2a/parts.js +94 -0
  23. package/dist/a2a/push.d.ts +70 -0
  24. package/dist/a2a/push.js +53 -0
  25. package/dist/a2a/self-origin.d.ts +91 -0
  26. package/dist/a2a/self-origin.js +114 -0
  27. package/dist/a2a/task-store.d.ts +44 -0
  28. package/dist/a2a/task-store.js +99 -0
  29. package/dist/a2a/task.d.ts +85 -0
  30. package/dist/a2a/task.js +15 -0
  31. package/dist/a2a/verify.d.ts +80 -0
  32. package/dist/a2a/verify.js +143 -0
  33. package/dist/agent/budget.d.ts +46 -0
  34. package/dist/agent/budget.js +42 -0
  35. package/dist/agent/control.d.ts +109 -0
  36. package/dist/agent/control.js +115 -0
  37. package/dist/agent/errors.d.ts +85 -0
  38. package/dist/agent/errors.js +64 -0
  39. package/dist/agent/final-reply.d.ts +49 -0
  40. package/dist/agent/final-reply.js +68 -0
  41. package/dist/agent/history.d.ts +97 -0
  42. package/dist/agent/history.js +133 -0
  43. package/dist/agent/index.d.ts +29 -0
  44. package/dist/agent/index.js +29 -0
  45. package/dist/agent/inference.d.ts +110 -0
  46. package/dist/agent/inference.js +120 -0
  47. package/dist/agent/model.d.ts +90 -0
  48. package/dist/agent/model.js +1 -0
  49. package/dist/agent/session.d.ts +100 -0
  50. package/dist/agent/session.js +82 -0
  51. package/dist/agent/workers-ai/index.d.ts +23 -0
  52. package/dist/agent/workers-ai/index.js +23 -0
  53. package/dist/agent/workers-ai/runtime.d.ts +42 -0
  54. package/dist/agent/workers-ai/runtime.js +63 -0
  55. package/dist/alarm/index.d.ts +77 -0
  56. package/dist/alarm/index.js +116 -0
  57. package/dist/config.d.ts +202 -0
  58. package/dist/config.js +135 -0
  59. package/dist/contract/index.d.ts +9 -0
  60. package/dist/contract/index.js +8 -0
  61. package/dist/contract/plugin.d.ts +324 -0
  62. package/dist/contract/plugin.js +114 -0
  63. package/dist/contract/recipe.d.ts +180 -0
  64. package/dist/contract/recipe.js +1 -0
  65. package/dist/contract/validation.d.ts +91 -0
  66. package/dist/contract/validation.js +84 -0
  67. package/dist/db/db.d.ts +147 -0
  68. package/dist/db/db.js +90 -0
  69. package/dist/db/index.d.ts +8 -0
  70. package/dist/db/index.js +8 -0
  71. package/dist/db/migrations/index.d.ts +20 -0
  72. package/dist/db/migrations/index.js +60 -0
  73. package/dist/db/models/subtasks.d.ts +100 -0
  74. package/dist/db/models/subtasks.js +241 -0
  75. package/dist/db/models/tasks.d.ts +118 -0
  76. package/dist/db/models/tasks.js +274 -0
  77. package/dist/db/schema.d.ts +468 -0
  78. package/dist/db/schema.js +88 -0
  79. package/dist/env.d.ts +53 -0
  80. package/dist/env.js +47 -0
  81. package/dist/host/agent.d.ts +305 -0
  82. package/dist/host/agent.js +400 -0
  83. package/dist/host/index.d.ts +20 -0
  84. package/dist/host/index.js +19 -0
  85. package/dist/host/plugin-host.d.ts +42 -0
  86. package/dist/host/plugin-host.js +1 -0
  87. package/dist/index.d.ts +19 -0
  88. package/dist/index.js +17 -0
  89. package/dist/job/index.d.ts +21 -0
  90. package/dist/job/index.js +21 -0
  91. package/dist/job/lifecycle.d.ts +176 -0
  92. package/dist/job/lifecycle.js +230 -0
  93. package/dist/job/state.d.ts +92 -0
  94. package/dist/job/state.js +40 -0
  95. package/dist/platform.d.ts +138 -0
  96. package/dist/platform.js +140 -0
  97. package/dist/round/agent.d.ts +271 -0
  98. package/dist/round/agent.js +678 -0
  99. package/dist/round/index.d.ts +25 -0
  100. package/dist/round/index.js +23 -0
  101. package/dist/round/policy.d.ts +98 -0
  102. package/dist/round/policy.js +1 -0
  103. package/dist/round/subagent.d.ts +87 -0
  104. package/dist/round/subagent.js +108 -0
  105. package/dist/round/turn.d.ts +249 -0
  106. package/dist/round/turn.js +564 -0
  107. package/dist/round/workflow.d.ts +147 -0
  108. package/dist/round/workflow.js +387 -0
  109. package/dist/runtime/index.d.ts +127 -0
  110. package/dist/runtime/index.js +186 -0
  111. package/dist/runtime/tool-families.d.ts +32 -0
  112. package/dist/runtime/tool-families.js +61 -0
  113. package/dist/subagent/fingerprint.d.ts +37 -0
  114. package/dist/subagent/fingerprint.js +92 -0
  115. package/dist/subagent/index.d.ts +169 -0
  116. package/dist/subagent/index.js +330 -0
  117. package/dist/subagent/prompt.d.ts +32 -0
  118. package/dist/subagent/prompt.js +37 -0
  119. package/dist/subagent/run.d.ts +157 -0
  120. package/dist/subagent/run.js +540 -0
  121. package/dist/subagent/workspace.d.ts +85 -0
  122. package/dist/subagent/workspace.js +127 -0
  123. package/dist/subtasks/catalog.d.ts +40 -0
  124. package/dist/subtasks/catalog.js +36 -0
  125. package/dist/subtasks/decomposition.d.ts +85 -0
  126. package/dist/subtasks/decomposition.js +156 -0
  127. package/dist/subtasks/delegate.d.ts +120 -0
  128. package/dist/subtasks/delegate.js +131 -0
  129. package/dist/subtasks/index.d.ts +9 -0
  130. package/dist/subtasks/index.js +9 -0
  131. package/dist/subtasks/subtask-types.d.ts +91 -0
  132. package/dist/subtasks/subtask-types.js +103 -0
  133. package/dist/subtasks/types.d.ts +295 -0
  134. package/dist/subtasks/types.js +15 -0
  135. package/dist/testing/auth.d.ts +34 -0
  136. package/dist/testing/auth.js +35 -0
  137. package/dist/testing/do.d.ts +29 -0
  138. package/dist/testing/do.js +25 -0
  139. package/dist/testing/fake-session.d.ts +26 -0
  140. package/dist/testing/fake-session.js +37 -0
  141. package/dist/testing/fixtures.d.ts +64 -0
  142. package/dist/testing/fixtures.js +104 -0
  143. package/dist/testing/harness.d.ts +97 -0
  144. package/dist/testing/harness.js +138 -0
  145. package/dist/testing/index.d.ts +31 -0
  146. package/dist/testing/index.js +35 -0
  147. package/dist/testing/mock-model.d.ts +77 -0
  148. package/dist/testing/mock-model.js +136 -0
  149. package/dist/testing/node.d.ts +56 -0
  150. package/dist/testing/node.js +56 -0
  151. package/dist/testing/vcr-global-setup.d.ts +12 -0
  152. package/dist/testing/vcr-global-setup.js +15 -0
  153. package/dist/testing/vcr-shared.d.ts +38 -0
  154. package/dist/testing/vcr-shared.js +33 -0
  155. package/dist/testing/vcr-spec.d.ts +25 -0
  156. package/dist/testing/vcr-spec.js +124 -0
  157. package/dist/testing/vcr-store.d.ts +86 -0
  158. package/dist/testing/vcr-store.js +191 -0
  159. package/dist/testing/vcr.d.ts +117 -0
  160. package/dist/testing/vcr.js +275 -0
  161. package/dist/worker/define-agent.d.ts +123 -0
  162. package/dist/worker/define-agent.js +20 -0
  163. package/dist/worker/index.d.ts +218 -0
  164. package/dist/worker/index.js +369 -0
  165. package/eslint-rules/index.js +31 -0
  166. package/eslint-rules/no-deprecated-object-properties.js +81 -0
  167. package/package.json +178 -0
  168. package/scripts/generate-keys.mjs +48 -0
@@ -0,0 +1,468 @@
1
+ /**
2
+ * Core's two tables. Both live in the caller's agent DO SQLite
3
+ * (`this.ctx.storage`), so a row is unreachable from any other caller by
4
+ * construction.
5
+ *
6
+ * A plugin's tables are **not** here and never will be: drizzle's durable-sqlite
7
+ * migrator keeps one flat integer journal and one global `__drizzle_migrations`
8
+ * table, which independently-versioned packages cannot share. Plugins own their
9
+ * storage through `PluginStore` — idempotent `CREATE TABLE IF NOT EXISTS` plus
10
+ * their own version bookkeeping, outside this journal entirely. See
11
+ * {@link file://./db.ts}.
12
+ *
13
+ * Indexes are declared in each table's config callback rather than as standalone
14
+ * `index(...)` exports: only the callback form is recorded in the drizzle-kit
15
+ * snapshot, so the standalone form makes every later `generate` diff propose
16
+ * dropping the index it can no longer see.
17
+ */
18
+ /**
19
+ * Durable state for async A2A tasks (the accept + notify lifecycle).
20
+ *
21
+ * One row per task: written by the Worker's accept path (`beginTask`, keyed by
22
+ * `message_id` for gatekeeper dedupe) and mutated by the turn workflow via DO RPC
23
+ * (`markWorking`, `saveTask`, `cancelTask`). `GetTask` / `ListTasks` read it
24
+ * through `DurableTaskStore`.
25
+ */
26
+ export declare const notifyTasks: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
27
+ name: "notify_tasks";
28
+ schema: undefined;
29
+ columns: {
30
+ taskId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
31
+ name: "task_id";
32
+ tableName: "notify_tasks";
33
+ dataType: "string";
34
+ columnType: "SQLiteText";
35
+ data: string;
36
+ driverParam: string;
37
+ notNull: true;
38
+ hasDefault: false;
39
+ isPrimaryKey: true;
40
+ isAutoincrement: false;
41
+ hasRuntimeDefault: false;
42
+ enumValues: [string, ...string[]];
43
+ baseColumn: never;
44
+ identity: undefined;
45
+ generated: undefined;
46
+ }, {}, {
47
+ length: number | undefined;
48
+ }>;
49
+ messageId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
50
+ name: "message_id";
51
+ tableName: "notify_tasks";
52
+ dataType: "string";
53
+ columnType: "SQLiteText";
54
+ data: string;
55
+ driverParam: string;
56
+ notNull: false;
57
+ hasDefault: false;
58
+ isPrimaryKey: false;
59
+ isAutoincrement: false;
60
+ hasRuntimeDefault: false;
61
+ enumValues: [string, ...string[]];
62
+ baseColumn: never;
63
+ identity: undefined;
64
+ generated: undefined;
65
+ }, {}, {
66
+ length: number | undefined;
67
+ }>;
68
+ contextId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
69
+ name: "context_id";
70
+ tableName: "notify_tasks";
71
+ dataType: "string";
72
+ columnType: "SQLiteText";
73
+ data: string;
74
+ driverParam: string;
75
+ notNull: true;
76
+ hasDefault: true;
77
+ isPrimaryKey: false;
78
+ isAutoincrement: false;
79
+ hasRuntimeDefault: false;
80
+ enumValues: [string, ...string[]];
81
+ baseColumn: never;
82
+ identity: undefined;
83
+ generated: undefined;
84
+ }, {}, {
85
+ length: number | undefined;
86
+ }>;
87
+ state: import("drizzle-orm/sqlite-core").SQLiteColumn<{
88
+ name: "state";
89
+ tableName: "notify_tasks";
90
+ dataType: "string";
91
+ columnType: "SQLiteText";
92
+ data: string;
93
+ driverParam: string;
94
+ notNull: true;
95
+ hasDefault: false;
96
+ isPrimaryKey: false;
97
+ isAutoincrement: false;
98
+ hasRuntimeDefault: false;
99
+ enumValues: [string, ...string[]];
100
+ baseColumn: never;
101
+ identity: undefined;
102
+ generated: undefined;
103
+ }, {}, {
104
+ length: number | undefined;
105
+ }>;
106
+ taskJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
107
+ name: "task_json";
108
+ tableName: "notify_tasks";
109
+ dataType: "string";
110
+ columnType: "SQLiteText";
111
+ data: string;
112
+ driverParam: string;
113
+ notNull: true;
114
+ hasDefault: false;
115
+ isPrimaryKey: false;
116
+ isAutoincrement: false;
117
+ hasRuntimeDefault: false;
118
+ enumValues: [string, ...string[]];
119
+ baseColumn: never;
120
+ identity: undefined;
121
+ generated: undefined;
122
+ }, {}, {
123
+ length: number | undefined;
124
+ }>;
125
+ createdAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
126
+ name: "created_at";
127
+ tableName: "notify_tasks";
128
+ dataType: "number";
129
+ columnType: "SQLiteInteger";
130
+ data: number;
131
+ driverParam: number;
132
+ notNull: true;
133
+ hasDefault: false;
134
+ isPrimaryKey: false;
135
+ isAutoincrement: false;
136
+ hasRuntimeDefault: false;
137
+ enumValues: undefined;
138
+ baseColumn: never;
139
+ identity: undefined;
140
+ generated: undefined;
141
+ }, {}, {}>;
142
+ updatedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
143
+ name: "updated_at";
144
+ tableName: "notify_tasks";
145
+ dataType: "number";
146
+ columnType: "SQLiteInteger";
147
+ data: number;
148
+ driverParam: number;
149
+ notNull: true;
150
+ hasDefault: false;
151
+ isPrimaryKey: false;
152
+ isAutoincrement: false;
153
+ hasRuntimeDefault: false;
154
+ enumValues: undefined;
155
+ baseColumn: never;
156
+ identity: undefined;
157
+ generated: undefined;
158
+ }, {}, {}>;
159
+ };
160
+ dialect: "sqlite";
161
+ }>;
162
+ /**
163
+ * Durable subtasks: the units a parent A2A task is decomposed into.
164
+ *
165
+ * The integer primary key assigns a caller-local, monotonically increasing
166
+ * `SubtaskId` (autoincrement, so ids are never reused after cleanup deletes
167
+ * rows). References and result parts are stored as JSON text and parsed back
168
+ * into the `Subtask` contract by `models/subtasks.ts`.
169
+ * `recipe_id`/`recipe_version` are null until execution starts, then record the
170
+ * resolved recipe after the fact.
171
+ */
172
+ export declare const subtasks: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
173
+ name: "subtasks";
174
+ schema: undefined;
175
+ columns: {
176
+ id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
177
+ name: "id";
178
+ tableName: "subtasks";
179
+ dataType: "number";
180
+ columnType: "SQLiteInteger";
181
+ data: number;
182
+ driverParam: number;
183
+ notNull: true;
184
+ hasDefault: true;
185
+ isPrimaryKey: true;
186
+ isAutoincrement: false;
187
+ hasRuntimeDefault: false;
188
+ enumValues: undefined;
189
+ baseColumn: never;
190
+ identity: undefined;
191
+ generated: undefined;
192
+ }, {}, {}>;
193
+ taskId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
194
+ name: "task_id";
195
+ tableName: "subtasks";
196
+ dataType: "string";
197
+ columnType: "SQLiteText";
198
+ data: string;
199
+ driverParam: string;
200
+ notNull: true;
201
+ hasDefault: false;
202
+ isPrimaryKey: false;
203
+ isAutoincrement: false;
204
+ hasRuntimeDefault: false;
205
+ enumValues: [string, ...string[]];
206
+ baseColumn: never;
207
+ identity: undefined;
208
+ generated: undefined;
209
+ }, {}, {
210
+ length: number | undefined;
211
+ }>;
212
+ round: import("drizzle-orm/sqlite-core").SQLiteColumn<{
213
+ name: "round";
214
+ tableName: "subtasks";
215
+ dataType: "number";
216
+ columnType: "SQLiteInteger";
217
+ data: number;
218
+ driverParam: number;
219
+ notNull: true;
220
+ hasDefault: false;
221
+ isPrimaryKey: false;
222
+ isAutoincrement: false;
223
+ hasRuntimeDefault: false;
224
+ enumValues: undefined;
225
+ baseColumn: never;
226
+ identity: undefined;
227
+ generated: undefined;
228
+ }, {}, {}>;
229
+ ordinal: import("drizzle-orm/sqlite-core").SQLiteColumn<{
230
+ name: "ordinal";
231
+ tableName: "subtasks";
232
+ dataType: "number";
233
+ columnType: "SQLiteInteger";
234
+ data: number;
235
+ driverParam: number;
236
+ notNull: true;
237
+ hasDefault: false;
238
+ isPrimaryKey: false;
239
+ isAutoincrement: false;
240
+ hasRuntimeDefault: false;
241
+ enumValues: undefined;
242
+ baseColumn: never;
243
+ identity: undefined;
244
+ generated: undefined;
245
+ }, {}, {}>;
246
+ type: import("drizzle-orm/sqlite-core").SQLiteColumn<{
247
+ name: "type";
248
+ tableName: "subtasks";
249
+ dataType: "string";
250
+ columnType: "SQLiteText";
251
+ data: string;
252
+ driverParam: string;
253
+ notNull: true;
254
+ hasDefault: false;
255
+ isPrimaryKey: false;
256
+ isAutoincrement: false;
257
+ hasRuntimeDefault: false;
258
+ enumValues: [string, ...string[]];
259
+ baseColumn: never;
260
+ identity: undefined;
261
+ generated: undefined;
262
+ }, {}, {
263
+ length: number | undefined;
264
+ }>;
265
+ recipeId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
266
+ name: "recipe_id";
267
+ tableName: "subtasks";
268
+ dataType: "string";
269
+ columnType: "SQLiteText";
270
+ data: string;
271
+ driverParam: string;
272
+ notNull: false;
273
+ hasDefault: false;
274
+ isPrimaryKey: false;
275
+ isAutoincrement: false;
276
+ hasRuntimeDefault: false;
277
+ enumValues: [string, ...string[]];
278
+ baseColumn: never;
279
+ identity: undefined;
280
+ generated: undefined;
281
+ }, {}, {
282
+ length: number | undefined;
283
+ }>;
284
+ recipeVersion: import("drizzle-orm/sqlite-core").SQLiteColumn<{
285
+ name: "recipe_version";
286
+ tableName: "subtasks";
287
+ dataType: "number";
288
+ columnType: "SQLiteInteger";
289
+ data: number;
290
+ driverParam: number;
291
+ notNull: false;
292
+ hasDefault: false;
293
+ isPrimaryKey: false;
294
+ isAutoincrement: false;
295
+ hasRuntimeDefault: false;
296
+ enumValues: undefined;
297
+ baseColumn: never;
298
+ identity: undefined;
299
+ generated: undefined;
300
+ }, {}, {}>;
301
+ prompt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
302
+ name: "prompt";
303
+ tableName: "subtasks";
304
+ dataType: "string";
305
+ columnType: "SQLiteText";
306
+ data: string;
307
+ driverParam: string;
308
+ notNull: true;
309
+ hasDefault: false;
310
+ isPrimaryKey: false;
311
+ isAutoincrement: false;
312
+ hasRuntimeDefault: false;
313
+ enumValues: [string, ...string[]];
314
+ baseColumn: never;
315
+ identity: undefined;
316
+ generated: undefined;
317
+ }, {}, {
318
+ length: number | undefined;
319
+ }>;
320
+ referencesJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
321
+ name: "references_json";
322
+ tableName: "subtasks";
323
+ dataType: "string";
324
+ columnType: "SQLiteText";
325
+ data: string;
326
+ driverParam: string;
327
+ notNull: true;
328
+ hasDefault: false;
329
+ isPrimaryKey: false;
330
+ isAutoincrement: false;
331
+ hasRuntimeDefault: false;
332
+ enumValues: [string, ...string[]];
333
+ baseColumn: never;
334
+ identity: undefined;
335
+ generated: undefined;
336
+ }, {}, {
337
+ length: number | undefined;
338
+ }>;
339
+ paramsJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
340
+ name: "params_json";
341
+ tableName: "subtasks";
342
+ dataType: "string";
343
+ columnType: "SQLiteText";
344
+ data: string;
345
+ driverParam: string;
346
+ notNull: true;
347
+ hasDefault: true;
348
+ isPrimaryKey: false;
349
+ isAutoincrement: false;
350
+ hasRuntimeDefault: false;
351
+ enumValues: [string, ...string[]];
352
+ baseColumn: never;
353
+ identity: undefined;
354
+ generated: undefined;
355
+ }, {}, {
356
+ length: number | undefined;
357
+ }>;
358
+ status: import("drizzle-orm/sqlite-core").SQLiteColumn<{
359
+ name: "status";
360
+ tableName: "subtasks";
361
+ dataType: "string";
362
+ columnType: "SQLiteText";
363
+ data: string;
364
+ driverParam: string;
365
+ notNull: true;
366
+ hasDefault: false;
367
+ isPrimaryKey: false;
368
+ isAutoincrement: false;
369
+ hasRuntimeDefault: false;
370
+ enumValues: [string, ...string[]];
371
+ baseColumn: never;
372
+ identity: undefined;
373
+ generated: undefined;
374
+ }, {}, {
375
+ length: number | undefined;
376
+ }>;
377
+ resultPartsJson: import("drizzle-orm/sqlite-core").SQLiteColumn<{
378
+ name: "result_parts_json";
379
+ tableName: "subtasks";
380
+ dataType: "string";
381
+ columnType: "SQLiteText";
382
+ data: string;
383
+ driverParam: string;
384
+ notNull: false;
385
+ hasDefault: false;
386
+ isPrimaryKey: false;
387
+ isAutoincrement: false;
388
+ hasRuntimeDefault: false;
389
+ enumValues: [string, ...string[]];
390
+ baseColumn: never;
391
+ identity: undefined;
392
+ generated: undefined;
393
+ }, {}, {
394
+ length: number | undefined;
395
+ }>;
396
+ error: import("drizzle-orm/sqlite-core").SQLiteColumn<{
397
+ name: "error";
398
+ tableName: "subtasks";
399
+ dataType: "string";
400
+ columnType: "SQLiteText";
401
+ data: string;
402
+ driverParam: string;
403
+ notNull: false;
404
+ hasDefault: false;
405
+ isPrimaryKey: false;
406
+ isAutoincrement: false;
407
+ hasRuntimeDefault: false;
408
+ enumValues: [string, ...string[]];
409
+ baseColumn: never;
410
+ identity: undefined;
411
+ generated: undefined;
412
+ }, {}, {
413
+ length: number | undefined;
414
+ }>;
415
+ createdAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
416
+ name: "created_at";
417
+ tableName: "subtasks";
418
+ dataType: "number";
419
+ columnType: "SQLiteInteger";
420
+ data: number;
421
+ driverParam: number;
422
+ notNull: true;
423
+ hasDefault: false;
424
+ isPrimaryKey: false;
425
+ isAutoincrement: false;
426
+ hasRuntimeDefault: false;
427
+ enumValues: undefined;
428
+ baseColumn: never;
429
+ identity: undefined;
430
+ generated: undefined;
431
+ }, {}, {}>;
432
+ updatedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
433
+ name: "updated_at";
434
+ tableName: "subtasks";
435
+ dataType: "number";
436
+ columnType: "SQLiteInteger";
437
+ data: number;
438
+ driverParam: number;
439
+ notNull: true;
440
+ hasDefault: false;
441
+ isPrimaryKey: false;
442
+ isAutoincrement: false;
443
+ hasRuntimeDefault: false;
444
+ enumValues: undefined;
445
+ baseColumn: never;
446
+ identity: undefined;
447
+ generated: undefined;
448
+ }, {}, {}>;
449
+ completedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
450
+ name: "completed_at";
451
+ tableName: "subtasks";
452
+ dataType: "number";
453
+ columnType: "SQLiteInteger";
454
+ data: number;
455
+ driverParam: number;
456
+ notNull: false;
457
+ hasDefault: false;
458
+ isPrimaryKey: false;
459
+ isAutoincrement: false;
460
+ hasRuntimeDefault: false;
461
+ enumValues: undefined;
462
+ baseColumn: never;
463
+ identity: undefined;
464
+ generated: undefined;
465
+ }, {}, {}>;
466
+ };
467
+ dialect: "sqlite";
468
+ }>;
@@ -0,0 +1,88 @@
1
+ import { sqliteTable, text, integer, index, uniqueIndex } from "drizzle-orm/sqlite-core";
2
+ /**
3
+ * Core's two tables. Both live in the caller's agent DO SQLite
4
+ * (`this.ctx.storage`), so a row is unreachable from any other caller by
5
+ * construction.
6
+ *
7
+ * A plugin's tables are **not** here and never will be: drizzle's durable-sqlite
8
+ * migrator keeps one flat integer journal and one global `__drizzle_migrations`
9
+ * table, which independently-versioned packages cannot share. Plugins own their
10
+ * storage through `PluginStore` — idempotent `CREATE TABLE IF NOT EXISTS` plus
11
+ * their own version bookkeeping, outside this journal entirely. See
12
+ * {@link file://./db.ts}.
13
+ *
14
+ * Indexes are declared in each table's config callback rather than as standalone
15
+ * `index(...)` exports: only the callback form is recorded in the drizzle-kit
16
+ * snapshot, so the standalone form makes every later `generate` diff propose
17
+ * dropping the index it can no longer see.
18
+ */
19
+ /**
20
+ * Durable state for async A2A tasks (the accept + notify lifecycle).
21
+ *
22
+ * One row per task: written by the Worker's accept path (`beginTask`, keyed by
23
+ * `message_id` for gatekeeper dedupe) and mutated by the turn workflow via DO RPC
24
+ * (`markWorking`, `saveTask`, `cancelTask`). `GetTask` / `ListTasks` read it
25
+ * through `DurableTaskStore`.
26
+ */
27
+ export const notifyTasks = sqliteTable("notify_tasks", {
28
+ taskId: text("task_id").primaryKey(),
29
+ /** Gatekeeper-assigned dedupe key — null for tasks created outside `beginTask`. */
30
+ messageId: text("message_id").unique(),
31
+ /** A2A context id, denormalized out of `task_json` so `ListTasks` can filter on it. */
32
+ contextId: text("context_id").notNull().default(""),
33
+ /** Human-readable `TaskState` (`working`, `input-required`, …) — see `taskStateLabel`. */
34
+ state: text("state").notNull(),
35
+ /**
36
+ * The task in its **A2A wire form** (`Task.toJSON`), not the in-memory proto
37
+ * object. Storing the wire form means what is on disk is exactly what goes
38
+ * on the wire, and both survive a change to the SDK's class shape;
39
+ * `JSON.stringify(task)` would persist in-memory internals instead.
40
+ */
41
+ taskJson: text("task_json").notNull(),
42
+ createdAt: integer("created_at").notNull(),
43
+ updatedAt: integer("updated_at").notNull()
44
+ }, (table) => [
45
+ index("idx_notify_tasks_created_at").on(table.createdAt),
46
+ index("idx_notify_tasks_context").on(table.contextId),
47
+ index("idx_notify_tasks_state").on(table.state)
48
+ ]);
49
+ /**
50
+ * Durable subtasks: the units a parent A2A task is decomposed into.
51
+ *
52
+ * The integer primary key assigns a caller-local, monotonically increasing
53
+ * `SubtaskId` (autoincrement, so ids are never reused after cleanup deletes
54
+ * rows). References and result parts are stored as JSON text and parsed back
55
+ * into the `Subtask` contract by `models/subtasks.ts`.
56
+ * `recipe_id`/`recipe_version` are null until execution starts, then record the
57
+ * resolved recipe after the fact.
58
+ */
59
+ export const subtasks = sqliteTable("subtasks", {
60
+ id: integer("id").primaryKey({ autoIncrement: true }),
61
+ taskId: text("task_id").notNull(),
62
+ /** Main-agent round that delegated this subtask (0-based). */
63
+ round: integer("round").notNull(),
64
+ /** Position within the parent task, increasing across every round. */
65
+ ordinal: integer("ordinal").notNull(),
66
+ type: text("type").notNull(),
67
+ /** Resolved recipe key, written only at execution start. */
68
+ recipeId: text("recipe_id"),
69
+ /** Resolved recipe version, written only at execution start. */
70
+ recipeVersion: integer("recipe_version"),
71
+ prompt: text("prompt").notNull(),
72
+ /** JSON `SubtaskReference[]` — verbatim role+text snapshots from decomposition. */
73
+ referencesJson: text("references_json").notNull(),
74
+ /** JSON `SubtaskParams` — the type's required inputs, validated at delegation. */
75
+ paramsJson: text("params_json").notNull().default("{}"),
76
+ status: text("status").notNull(),
77
+ /** JSON `SubtaskResultPart[]` — text-only terminal output; null until complete. */
78
+ resultPartsJson: text("result_parts_json"),
79
+ error: text("error"),
80
+ createdAt: integer("created_at").notNull(),
81
+ updatedAt: integer("updated_at").notNull(),
82
+ completedAt: integer("completed_at")
83
+ }, (table) => [
84
+ uniqueIndex("idx_subtasks_task_ordinal").on(table.taskId, table.ordinal),
85
+ index("idx_subtasks_task_round").on(table.taskId, table.round),
86
+ index("idx_subtasks_status").on(table.status),
87
+ index("idx_subtasks_created_at").on(table.createdAt)
88
+ ]);
package/dist/env.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The Worker `env` slices core reads, declared structurally.
3
+ *
4
+ * A published package cannot reference the ambient `Env` that `wrangler types`
5
+ * generates into a consumer's `worker-configuration.d.ts` — that interface only
6
+ * exists inside the app. So core never names `Env`. Every function that needs a
7
+ * binding either takes it as a parameter, or takes an object satisfying one of
8
+ * the slices below, and a consumer's generated `Env` satisfies them structurally
9
+ * with no cast.
10
+ *
11
+ * The two secrets are the zero-trust contract and are the only names core
12
+ * insists on; everything else is passed in. Even these are only a *default*:
13
+ * `createA2AWorker`'s `secrets` option reads them from wherever a consumer keeps
14
+ * them, so a Worker whose bindings are already named something else does not
15
+ * have to rename them.
16
+ *
17
+ * That is *all* it does. The secrets are read once per request and belong to the
18
+ * deployment, not to an agent: several agents share one Worker as tenants of one
19
+ * origin, and they share this one signing identity with it. What separates them
20
+ * is the tenant claim on the gatekeeper token, not a key apiece. See
21
+ * {@link file://./worker/index.ts}.
22
+ */
23
+ /** Workers AI, backing the chat loop (and whatever a plugin runs on it). */
24
+ export interface AiEnv {
25
+ AI: Ai;
26
+ }
27
+ /**
28
+ * The two secrets every Dynamic Agents agent must carry.
29
+ *
30
+ * - `A2A_SIGNING_KEY` — Ed25519 private JWK (JSON, **must** include `kid`). Signs
31
+ * the AgentCard and every push-notification callback JWT. Its public half is
32
+ * served at the agent's JWKS path and pinned by the gatekeeper on first
33
+ * registration (Trust-On-First-Use).
34
+ * - `GATEKEEPER_ORIGINS` — JSON array of origins allowed to call this agent. The
35
+ * allowlist a gatekeeper JWT's `jku` and `iss` are checked against; see
36
+ * {@link file://./a2a/verify.ts}.
37
+ *
38
+ * No shared secret ever crosses the boundary in either direction: the agent
39
+ * verifies the gatekeeper with the gatekeeper's public JWKS, and the gatekeeper verifies
40
+ * the agent with the agent's.
41
+ */
42
+ export interface A2ASecretsEnv {
43
+ A2A_SIGNING_KEY: string;
44
+ GATEKEEPER_ORIGINS: string;
45
+ }
46
+ /** The minimum an agent Worker must bind for core to function. */
47
+ export type CoreEnv = AiEnv & A2ASecretsEnv;
48
+ /**
49
+ * Parse `GATEKEEPER_ORIGINS`. Accepts a JSON array (the documented form) or a
50
+ * single bare origin, so a misconfigured secret fails with a readable message
51
+ * rather than as an empty allowlist that rejects every caller identically.
52
+ */
53
+ export declare function parseGatekeeperOrigins(raw: string): string[];
package/dist/env.js ADDED
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The Worker `env` slices core reads, declared structurally.
3
+ *
4
+ * A published package cannot reference the ambient `Env` that `wrangler types`
5
+ * generates into a consumer's `worker-configuration.d.ts` — that interface only
6
+ * exists inside the app. So core never names `Env`. Every function that needs a
7
+ * binding either takes it as a parameter, or takes an object satisfying one of
8
+ * the slices below, and a consumer's generated `Env` satisfies them structurally
9
+ * with no cast.
10
+ *
11
+ * The two secrets are the zero-trust contract and are the only names core
12
+ * insists on; everything else is passed in. Even these are only a *default*:
13
+ * `createA2AWorker`'s `secrets` option reads them from wherever a consumer keeps
14
+ * them, so a Worker whose bindings are already named something else does not
15
+ * have to rename them.
16
+ *
17
+ * That is *all* it does. The secrets are read once per request and belong to the
18
+ * deployment, not to an agent: several agents share one Worker as tenants of one
19
+ * origin, and they share this one signing identity with it. What separates them
20
+ * is the tenant claim on the gatekeeper token, not a key apiece. See
21
+ * {@link file://./worker/index.ts}.
22
+ */
23
+ /**
24
+ * Parse `GATEKEEPER_ORIGINS`. Accepts a JSON array (the documented form) or a
25
+ * single bare origin, so a misconfigured secret fails with a readable message
26
+ * rather than as an empty allowlist that rejects every caller identically.
27
+ */
28
+ export function parseGatekeeperOrigins(raw) {
29
+ const trimmed = raw.trim();
30
+ if (!trimmed)
31
+ throw new Error("GATEKEEPER_ORIGINS is empty");
32
+ if (!trimmed.startsWith("["))
33
+ return [trimmed];
34
+ let parsed;
35
+ try {
36
+ parsed = JSON.parse(trimmed);
37
+ }
38
+ catch (err) {
39
+ throw new Error(`GATEKEEPER_ORIGINS is not valid JSON: ${err.message}`);
40
+ }
41
+ if (!Array.isArray(parsed) || parsed.some((o) => typeof o !== "string")) {
42
+ throw new Error("GATEKEEPER_ORIGINS must be a JSON array of origin strings");
43
+ }
44
+ if (parsed.length === 0)
45
+ throw new Error("GATEKEEPER_ORIGINS is empty");
46
+ return parsed;
47
+ }