@holon-run/agentinbox 0.7.0 → 1.0.0-beta.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/dist/src/http.js CHANGED
@@ -41,6 +41,28 @@ const deliveryHandleSchema = {
41
41
  replyMode: { type: "string" },
42
42
  },
43
43
  };
44
+ const deliveryTargetByHandleSchema = {
45
+ type: "object",
46
+ additionalProperties: false,
47
+ required: ["deliveryHandle"],
48
+ properties: {
49
+ sourceId: { type: "string", minLength: 1 },
50
+ deliveryHandle: deliveryHandleSchema,
51
+ },
52
+ };
53
+ const deliveryTargetByFieldsSchema = {
54
+ type: "object",
55
+ additionalProperties: false,
56
+ required: ["provider", "surface", "targetRef"],
57
+ properties: {
58
+ sourceId: { type: "string", minLength: 1 },
59
+ provider: { type: "string", minLength: 1 },
60
+ surface: { type: "string", minLength: 1 },
61
+ targetRef: { type: "string", minLength: 1 },
62
+ threadRef: { type: "string" },
63
+ replyMode: { type: "string" },
64
+ },
65
+ };
44
66
  function buildFastifyServer(service) {
45
67
  const app = (0, fastify_1.default)({
46
68
  logger: false,
@@ -96,6 +118,153 @@ function buildFastifyServer(service) {
96
118
  },
97
119
  },
98
120
  }, async () => service.gc());
121
+ app.get("/hosts", {
122
+ schema: {
123
+ tags: ["sources"],
124
+ response: {
125
+ 200: {
126
+ type: "object",
127
+ required: ["hosts"],
128
+ properties: {
129
+ hosts: { type: "array", items: jsonObjectSchema },
130
+ },
131
+ },
132
+ },
133
+ },
134
+ }, async () => ({ hosts: service.listHosts() }));
135
+ app.post("/hosts", {
136
+ schema: {
137
+ tags: ["sources"],
138
+ body: {
139
+ type: "object",
140
+ additionalProperties: false,
141
+ required: ["hostType", "hostKey"],
142
+ properties: {
143
+ hostType: { type: "string", minLength: 1 },
144
+ hostKey: { type: "string", minLength: 1 },
145
+ configRef: { anyOf: [{ type: "string" }, { type: "null" }] },
146
+ config: jsonObjectSchema,
147
+ },
148
+ },
149
+ response: {
150
+ 200: jsonObjectSchema,
151
+ 400: errorResponseSchema,
152
+ },
153
+ },
154
+ }, async (request) => service.registerHost(request.body));
155
+ app.get("/hosts/:hostId", {
156
+ schema: {
157
+ tags: ["sources"],
158
+ params: {
159
+ type: "object",
160
+ required: ["hostId"],
161
+ properties: {
162
+ hostId: { type: "string", minLength: 1 },
163
+ },
164
+ },
165
+ response: {
166
+ 200: jsonObjectSchema,
167
+ 404: errorResponseSchema,
168
+ },
169
+ },
170
+ }, async (request) => {
171
+ const params = request.params;
172
+ return service.getHostDetails(decodeURIComponent(params.hostId));
173
+ });
174
+ app.get("/hosts/:hostId/schema", {
175
+ schema: {
176
+ tags: ["sources"],
177
+ params: {
178
+ type: "object",
179
+ required: ["hostId"],
180
+ properties: {
181
+ hostId: { type: "string", minLength: 1 },
182
+ },
183
+ },
184
+ response: {
185
+ 200: jsonObjectSchema,
186
+ 404: errorResponseSchema,
187
+ },
188
+ },
189
+ }, async (request) => {
190
+ const params = request.params;
191
+ const host = service.getHost(decodeURIComponent(params.hostId));
192
+ return service.getHostSchema(host.hostType);
193
+ });
194
+ app.get("/streams", {
195
+ schema: {
196
+ tags: ["sources"],
197
+ response: {
198
+ 200: {
199
+ type: "object",
200
+ required: ["streams"],
201
+ properties: {
202
+ streams: { type: "array", items: jsonObjectSchema },
203
+ },
204
+ },
205
+ },
206
+ },
207
+ }, async () => ({ streams: service.listStreams() }));
208
+ app.post("/streams", {
209
+ schema: {
210
+ tags: ["sources"],
211
+ body: {
212
+ type: "object",
213
+ additionalProperties: false,
214
+ required: ["hostId", "streamKind", "streamKey"],
215
+ properties: {
216
+ hostId: { type: "string", minLength: 1 },
217
+ streamKind: { type: "string", minLength: 1 },
218
+ streamKey: { type: "string", minLength: 1 },
219
+ configRef: { anyOf: [{ type: "string" }, { type: "null" }] },
220
+ config: jsonObjectSchema,
221
+ },
222
+ },
223
+ response: {
224
+ 200: jsonObjectSchema,
225
+ 400: errorResponseSchema,
226
+ },
227
+ },
228
+ }, async (request) => service.registerStream(request.body));
229
+ app.get("/streams/:streamId", {
230
+ schema: {
231
+ tags: ["sources"],
232
+ params: {
233
+ type: "object",
234
+ required: ["streamId"],
235
+ properties: {
236
+ streamId: { type: "string", minLength: 1 },
237
+ },
238
+ },
239
+ response: {
240
+ 200: jsonObjectSchema,
241
+ 404: errorResponseSchema,
242
+ },
243
+ },
244
+ }, async (request) => {
245
+ const params = request.params;
246
+ return service.getStreamDetails(decodeURIComponent(params.streamId));
247
+ });
248
+ app.get("/streams/:streamId/schema", {
249
+ schema: {
250
+ tags: ["sources"],
251
+ params: {
252
+ type: "object",
253
+ required: ["streamId"],
254
+ properties: {
255
+ streamId: { type: "string", minLength: 1 },
256
+ },
257
+ },
258
+ response: {
259
+ 200: jsonObjectSchema,
260
+ 400: errorResponseSchema,
261
+ 404: errorResponseSchema,
262
+ },
263
+ },
264
+ }, async (request) => {
265
+ const params = request.params;
266
+ return service.getResolvedSourceSchema(decodeURIComponent(params.streamId));
267
+ });
99
268
  app.get("/sources", {
100
269
  schema: {
101
270
  tags: ["sources"],
@@ -116,10 +285,11 @@ function buildFastifyServer(service) {
116
285
  body: {
117
286
  type: "object",
118
287
  additionalProperties: false,
119
- required: ["sourceType", "sourceKey"],
288
+ required: ["hostId", "streamKind", "streamKey"],
120
289
  properties: {
121
- sourceType: { type: "string", minLength: 1 },
122
- sourceKey: { type: "string", minLength: 1 },
290
+ hostId: { type: "string", minLength: 1 },
291
+ streamKind: { type: "string", minLength: 1 },
292
+ streamKey: { type: "string", minLength: 1 },
123
293
  configRef: { anyOf: [{ type: "string" }, { type: "null" }] },
124
294
  config: jsonObjectSchema,
125
295
  },
@@ -129,7 +299,7 @@ function buildFastifyServer(service) {
129
299
  400: errorResponseSchema,
130
300
  },
131
301
  },
132
- }, async (request) => service.registerSource(request.body));
302
+ }, async (request) => service.registerStream(request.body));
133
303
  app.get("/sources/:sourceId", {
134
304
  schema: {
135
305
  tags: ["sources"],
@@ -169,14 +339,42 @@ function buildFastifyServer(service) {
169
339
  const params = request.params;
170
340
  return service.getResolvedSourceSchema(decodeURIComponent(params.sourceId));
171
341
  });
172
- app.delete("/sources/:sourceId", {
342
+ app.patch("/streams/:streamId", {
173
343
  schema: {
174
344
  tags: ["sources"],
175
345
  params: {
176
346
  type: "object",
177
- required: ["sourceId"],
347
+ required: ["streamId"],
178
348
  properties: {
179
- sourceId: { type: "string", minLength: 1 },
349
+ streamId: { type: "string", minLength: 1 },
350
+ },
351
+ },
352
+ body: {
353
+ type: "object",
354
+ additionalProperties: false,
355
+ minProperties: 1,
356
+ properties: {
357
+ configRef: { anyOf: [{ type: "string" }, { type: "null" }] },
358
+ config: jsonObjectSchema,
359
+ },
360
+ },
361
+ response: {
362
+ 200: jsonObjectSchema,
363
+ 400: errorResponseSchema,
364
+ },
365
+ },
366
+ }, async (request) => {
367
+ const params = request.params;
368
+ return service.updateSource(decodeURIComponent(params.streamId), request.body);
369
+ });
370
+ app.delete("/streams/:streamId", {
371
+ schema: {
372
+ tags: ["sources"],
373
+ params: {
374
+ type: "object",
375
+ required: ["streamId"],
376
+ properties: {
377
+ streamId: { type: "string", minLength: 1 },
180
378
  },
181
379
  },
182
380
  querystring: {
@@ -199,25 +397,55 @@ function buildFastifyServer(service) {
199
397
  }, async (request) => {
200
398
  const params = request.params;
201
399
  const query = request.query;
202
- return service.removeSource(decodeURIComponent(params.sourceId), {
400
+ return service.removeSource(decodeURIComponent(params.streamId), {
203
401
  withSubscriptions: query.with_subscriptions === true || query.with_subscriptions === "true" || query.with_subscriptions === "1",
204
402
  });
205
403
  });
206
- app.patch("/sources/:sourceId", {
404
+ app.post("/streams/:streamId/pause", {
207
405
  schema: {
208
406
  tags: ["sources"],
209
407
  params: {
210
408
  type: "object",
211
- required: ["sourceId"],
409
+ required: ["streamId"],
212
410
  properties: {
213
- sourceId: { type: "string", minLength: 1 },
411
+ streamId: { type: "string", minLength: 1 },
214
412
  },
215
413
  },
414
+ response: {
415
+ 200: jsonObjectSchema,
416
+ },
417
+ },
418
+ }, async (request) => {
419
+ const params = request.params;
420
+ return service.pauseSource(decodeURIComponent(params.streamId));
421
+ });
422
+ app.post("/streams/:streamId/resume", {
423
+ schema: {
424
+ tags: ["sources"],
425
+ params: {
426
+ type: "object",
427
+ required: ["streamId"],
428
+ properties: {
429
+ streamId: { type: "string", minLength: 1 },
430
+ },
431
+ },
432
+ response: {
433
+ 200: jsonObjectSchema,
434
+ },
435
+ },
436
+ }, async (request) => {
437
+ const params = request.params;
438
+ return service.resumeSource(decodeURIComponent(params.streamId));
439
+ });
440
+ app.post("/streams/schema-preview", {
441
+ schema: {
442
+ tags: ["sources"],
216
443
  body: {
217
444
  type: "object",
218
445
  additionalProperties: false,
219
- minProperties: 1,
446
+ required: ["sourceRef"],
220
447
  properties: {
448
+ sourceRef: { type: "string", minLength: 1 },
221
449
  configRef: { anyOf: [{ type: "string" }, { type: "null" }] },
222
450
  config: jsonObjectSchema,
223
451
  },
@@ -227,11 +455,64 @@ function buildFastifyServer(service) {
227
455
  400: errorResponseSchema,
228
456
  },
229
457
  },
458
+ }, async (request) => service.previewSourceSchema(request.body));
459
+ app.post("/streams/:streamId/poll", {
460
+ schema: {
461
+ tags: ["sources"],
462
+ params: {
463
+ type: "object",
464
+ required: ["streamId"],
465
+ properties: {
466
+ streamId: { type: "string", minLength: 1 },
467
+ },
468
+ },
469
+ response: {
470
+ 200: jsonObjectSchema,
471
+ },
472
+ },
230
473
  }, async (request) => {
231
474
  const params = request.params;
232
- return service.updateSource(decodeURIComponent(params.sourceId), request.body);
475
+ return service.pollSource(decodeURIComponent(params.streamId));
233
476
  });
234
- app.post("/sources/:sourceId/pause", {
477
+ app.post("/streams/:streamId/events", {
478
+ schema: {
479
+ tags: ["sources"],
480
+ params: {
481
+ type: "object",
482
+ required: ["streamId"],
483
+ properties: {
484
+ streamId: { type: "string", minLength: 1 },
485
+ },
486
+ },
487
+ body: {
488
+ type: "object",
489
+ additionalProperties: false,
490
+ required: ["sourceNativeId", "eventVariant"],
491
+ properties: {
492
+ sourceNativeId: { type: "string", minLength: 1 },
493
+ eventVariant: { type: "string", minLength: 1 },
494
+ occurredAt: { type: "string", minLength: 1 },
495
+ metadata: jsonObjectSchema,
496
+ rawPayload: jsonObjectSchema,
497
+ },
498
+ },
499
+ response: {
500
+ 200: jsonObjectSchema,
501
+ },
502
+ },
503
+ }, async (request) => {
504
+ const params = request.params;
505
+ const body = request.body;
506
+ return service.appendSourceEvent({
507
+ sourceId: decodeURIComponent(params.streamId),
508
+ sourceNativeId: body.sourceNativeId,
509
+ eventVariant: body.eventVariant,
510
+ occurredAt: body.occurredAt,
511
+ metadata: body.metadata ?? {},
512
+ rawPayload: body.rawPayload ?? {},
513
+ });
514
+ });
515
+ app.delete("/sources/:sourceId", {
235
516
  schema: {
236
517
  tags: ["sources"],
237
518
  params: {
@@ -241,15 +522,31 @@ function buildFastifyServer(service) {
241
522
  sourceId: { type: "string", minLength: 1 },
242
523
  },
243
524
  },
525
+ querystring: {
526
+ type: "object",
527
+ additionalProperties: false,
528
+ properties: {
529
+ with_subscriptions: {
530
+ anyOf: [
531
+ { type: "boolean" },
532
+ { type: "string", enum: ["true", "false", "1", "0"] },
533
+ ],
534
+ },
535
+ },
536
+ },
244
537
  response: {
245
538
  200: jsonObjectSchema,
539
+ 400: errorResponseSchema,
246
540
  },
247
541
  },
248
542
  }, async (request) => {
249
543
  const params = request.params;
250
- return service.pauseSource(decodeURIComponent(params.sourceId));
544
+ const query = request.query;
545
+ return service.removeSource(decodeURIComponent(params.sourceId), {
546
+ withSubscriptions: query.with_subscriptions === true || query.with_subscriptions === "true" || query.with_subscriptions === "1",
547
+ });
251
548
  });
252
- app.post("/sources/:sourceId/resume", {
549
+ app.patch("/sources/:sourceId", {
253
550
  schema: {
254
551
  tags: ["sources"],
255
552
  params: {
@@ -259,22 +556,32 @@ function buildFastifyServer(service) {
259
556
  sourceId: { type: "string", minLength: 1 },
260
557
  },
261
558
  },
559
+ body: {
560
+ type: "object",
561
+ additionalProperties: false,
562
+ minProperties: 1,
563
+ properties: {
564
+ configRef: { anyOf: [{ type: "string" }, { type: "null" }] },
565
+ config: jsonObjectSchema,
566
+ },
567
+ },
262
568
  response: {
263
569
  200: jsonObjectSchema,
570
+ 400: errorResponseSchema,
264
571
  },
265
572
  },
266
573
  }, async (request) => {
267
574
  const params = request.params;
268
- return service.resumeSource(decodeURIComponent(params.sourceId));
575
+ return service.updateSource(decodeURIComponent(params.sourceId), request.body);
269
576
  });
270
- app.get("/source-types/:sourceType/schema", {
577
+ app.post("/sources/:sourceId/pause", {
271
578
  schema: {
272
579
  tags: ["sources"],
273
580
  params: {
274
581
  type: "object",
275
- required: ["sourceType"],
582
+ required: ["sourceId"],
276
583
  properties: {
277
- sourceType: { type: "string", minLength: 1 },
584
+ sourceId: { type: "string", minLength: 1 },
278
585
  },
279
586
  },
280
587
  response: {
@@ -283,27 +590,26 @@ function buildFastifyServer(service) {
283
590
  },
284
591
  }, async (request) => {
285
592
  const params = request.params;
286
- return service.getSourceSchema(decodeURIComponent(params.sourceType));
593
+ return service.pauseSource(decodeURIComponent(params.sourceId));
287
594
  });
288
- app.post("/sources/schema-preview", {
595
+ app.post("/sources/:sourceId/resume", {
289
596
  schema: {
290
597
  tags: ["sources"],
291
- body: {
598
+ params: {
292
599
  type: "object",
293
- additionalProperties: false,
294
- required: ["sourceRef"],
600
+ required: ["sourceId"],
295
601
  properties: {
296
- sourceRef: { type: "string", minLength: 1 },
297
- configRef: { anyOf: [{ type: "string" }, { type: "null" }] },
298
- config: jsonObjectSchema,
602
+ sourceId: { type: "string", minLength: 1 },
299
603
  },
300
604
  },
301
605
  response: {
302
606
  200: jsonObjectSchema,
303
- 400: errorResponseSchema,
304
607
  },
305
608
  },
306
- }, async (request) => service.previewSourceSchema(request.body));
609
+ }, async (request) => {
610
+ const params = request.params;
611
+ return service.resumeSource(decodeURIComponent(params.sourceId));
612
+ });
307
613
  app.post("/sources/:sourceId/poll", {
308
614
  schema: {
309
615
  tags: ["sources"],
@@ -425,6 +731,7 @@ function buildFastifyServer(service) {
425
731
  termProgram: { type: "string" },
426
732
  itermSessionId: { type: "string" },
427
733
  notifyLeaseMs: { type: "integer", minimum: 1 },
734
+ minUnackedItems: { type: "integer", minimum: 1 },
428
735
  },
429
736
  },
430
737
  response: {
@@ -447,6 +754,7 @@ function buildFastifyServer(service) {
447
754
  termProgram: optionalString(body.termProgram),
448
755
  itermSessionId: optionalString(body.itermSessionId),
449
756
  notifyLeaseMs: typeof body.notifyLeaseMs === "number" ? body.notifyLeaseMs : null,
757
+ minUnackedItems: typeof body.minUnackedItems === "number" ? body.minUnackedItems : null,
450
758
  });
451
759
  });
452
760
  app.get("/agents/:agentId", {
@@ -548,6 +856,7 @@ function buildFastifyServer(service) {
548
856
  url: { type: "string", minLength: 1 },
549
857
  activationMode: { type: "string" },
550
858
  notifyLeaseMs: { type: "integer", minimum: 1 },
859
+ minUnackedItems: { type: "integer", minimum: 1 },
551
860
  },
552
861
  },
553
862
  response: {
@@ -562,6 +871,7 @@ function buildFastifyServer(service) {
562
871
  url: body.url,
563
872
  activationMode: body.activationMode,
564
873
  notifyLeaseMs: body.notifyLeaseMs ?? null,
874
+ minUnackedItems: body.minUnackedItems ?? null,
565
875
  });
566
876
  });
567
877
  app.delete("/agents/:agentId/targets/:targetId", {
@@ -930,7 +1240,7 @@ function buildFastifyServer(service) {
930
1240
  const params = request.params;
931
1241
  return service.getInboxDetailsByAgent(decodeURIComponent(params.agentId));
932
1242
  });
933
- app.get("/agents/:agentId/inbox/items", {
1243
+ app.get("/agents/:agentId/inbox/entries", {
934
1244
  schema: {
935
1245
  tags: ["inbox"],
936
1246
  params: {
@@ -944,16 +1254,16 @@ function buildFastifyServer(service) {
944
1254
  type: "object",
945
1255
  additionalProperties: false,
946
1256
  properties: {
947
- after_item_id: { type: "string" },
1257
+ after_entry_id: { type: "string" },
948
1258
  include_acked: { type: "string", enum: ["true", "false"] },
949
1259
  },
950
1260
  },
951
1261
  response: {
952
1262
  200: {
953
1263
  type: "object",
954
- required: ["items"],
1264
+ required: ["entries"],
955
1265
  properties: {
956
- items: { type: "array", items: jsonObjectSchema },
1266
+ entries: { type: "array", items: jsonObjectSchema },
957
1267
  },
958
1268
  },
959
1269
  },
@@ -962,8 +1272,8 @@ function buildFastifyServer(service) {
962
1272
  const params = request.params;
963
1273
  const query = request.query;
964
1274
  return {
965
- items: service.listInboxItems(decodeURIComponent(params.agentId), {
966
- afterItemId: query.after_item_id,
1275
+ entries: service.listInboxItems(decodeURIComponent(params.agentId), {
1276
+ afterEntryId: query.after_entry_id,
967
1277
  includeAcked: query.include_acked ? query.include_acked === "true" : undefined,
968
1278
  }),
969
1279
  };
@@ -1015,7 +1325,7 @@ function buildFastifyServer(service) {
1015
1325
  type: "object",
1016
1326
  additionalProperties: false,
1017
1327
  properties: {
1018
- after_item_id: { type: "string" },
1328
+ after_entry_id: { type: "string" },
1019
1329
  include_acked: { type: "string", enum: ["true", "false"] },
1020
1330
  heartbeat_ms: { type: "string", pattern: "^[1-9][0-9]*$" },
1021
1331
  },
@@ -1029,7 +1339,7 @@ function buildFastifyServer(service) {
1029
1339
  const query = request.query;
1030
1340
  const agentId = decodeURIComponent(params.agentId);
1031
1341
  const watchOptions = {
1032
- afterItemId: query.after_item_id,
1342
+ afterEntryId: query.after_entry_id,
1033
1343
  includeAcked: query.include_acked ? query.include_acked === "true" : undefined,
1034
1344
  heartbeatMs: query.heartbeat_ms ? Number(query.heartbeat_ms) : undefined,
1035
1345
  };
@@ -1046,7 +1356,7 @@ function buildFastifyServer(service) {
1046
1356
  sendSse(raw, "items", {
1047
1357
  event: "items",
1048
1358
  agentId,
1049
- items: session.initialItems,
1359
+ entries: session.initialItems,
1050
1360
  });
1051
1361
  session.start();
1052
1362
  const heartbeatMs = watchOptions.heartbeatMs ?? 15_000;
@@ -1098,9 +1408,9 @@ function buildFastifyServer(service) {
1098
1408
  {
1099
1409
  type: "object",
1100
1410
  additionalProperties: false,
1101
- required: ["itemIds"],
1411
+ required: ["entryIds"],
1102
1412
  properties: {
1103
- itemIds: {
1413
+ entryIds: {
1104
1414
  type: "array",
1105
1415
  minItems: 1,
1106
1416
  items: { type: "string", minLength: 1 },
@@ -1110,9 +1420,9 @@ function buildFastifyServer(service) {
1110
1420
  {
1111
1421
  type: "object",
1112
1422
  additionalProperties: false,
1113
- required: ["throughItemId"],
1423
+ required: ["throughEntryId"],
1114
1424
  properties: {
1115
- throughItemId: { type: "string", minLength: 1 },
1425
+ throughEntryId: { type: "string", minLength: 1 },
1116
1426
  },
1117
1427
  },
1118
1428
  {
@@ -1134,11 +1444,58 @@ function buildFastifyServer(service) {
1134
1444
  const params = request.params;
1135
1445
  const body = request.body;
1136
1446
  return service.ackInbox(decodeURIComponent(params.agentId), {
1137
- itemIds: body.itemIds ?? [],
1138
- throughItemId: body.throughItemId ?? null,
1447
+ entryIds: body.entryIds ?? [],
1448
+ throughEntryId: body.throughEntryId ?? null,
1139
1449
  all: body.all ?? false,
1140
1450
  });
1141
1451
  });
1452
+ app.get("/agents/:agentId/inbox/policy", {
1453
+ schema: {
1454
+ tags: ["inbox"],
1455
+ params: {
1456
+ type: "object",
1457
+ required: ["agentId"],
1458
+ properties: {
1459
+ agentId: { type: "string", minLength: 1 },
1460
+ },
1461
+ },
1462
+ response: {
1463
+ 200: jsonObjectSchema,
1464
+ },
1465
+ },
1466
+ }, async (request) => {
1467
+ const params = request.params;
1468
+ return service.getInboxAggregationPolicy(decodeURIComponent(params.agentId));
1469
+ });
1470
+ app.post("/agents/:agentId/inbox/policy", {
1471
+ schema: {
1472
+ tags: ["inbox"],
1473
+ params: {
1474
+ type: "object",
1475
+ required: ["agentId"],
1476
+ properties: {
1477
+ agentId: { type: "string", minLength: 1 },
1478
+ },
1479
+ },
1480
+ body: {
1481
+ type: "object",
1482
+ additionalProperties: false,
1483
+ properties: {
1484
+ enabled: { type: "boolean" },
1485
+ windowMs: { type: "integer", minimum: 1 },
1486
+ maxItems: { type: "integer", minimum: 1 },
1487
+ maxThreadAgeMs: { type: "integer", minimum: 1 },
1488
+ },
1489
+ },
1490
+ response: {
1491
+ 200: jsonObjectSchema,
1492
+ },
1493
+ },
1494
+ }, async (request) => {
1495
+ const params = request.params;
1496
+ const body = request.body;
1497
+ return service.updateInboxAggregationPolicy(decodeURIComponent(params.agentId), body);
1498
+ });
1142
1499
  app.post("/deliveries/send", {
1143
1500
  schema: {
1144
1501
  tags: ["deliveries"],
@@ -1149,6 +1506,7 @@ function buildFastifyServer(service) {
1149
1506
  additionalProperties: false,
1150
1507
  required: ["kind", "payload", "deliveryHandle"],
1151
1508
  properties: {
1509
+ sourceId: { type: "string", minLength: 1 },
1152
1510
  kind: { type: "string", minLength: 1 },
1153
1511
  payload: jsonObjectSchema,
1154
1512
  deliveryHandle: deliveryHandleSchema,
@@ -1159,6 +1517,7 @@ function buildFastifyServer(service) {
1159
1517
  additionalProperties: false,
1160
1518
  required: ["kind", "payload", "provider", "surface", "targetRef"],
1161
1519
  properties: {
1520
+ sourceId: { type: "string", minLength: 1 },
1162
1521
  kind: { type: "string", minLength: 1 },
1163
1522
  payload: jsonObjectSchema,
1164
1523
  provider: { type: "string", minLength: 1 },
@@ -1176,6 +1535,57 @@ function buildFastifyServer(service) {
1176
1535
  },
1177
1536
  },
1178
1537
  }, async (request) => service.sendDelivery(request.body));
1538
+ app.post("/deliveries/actions", {
1539
+ schema: {
1540
+ tags: ["deliveries"],
1541
+ body: {
1542
+ oneOf: [deliveryTargetByHandleSchema, deliveryTargetByFieldsSchema],
1543
+ },
1544
+ response: {
1545
+ 200: jsonObjectSchema,
1546
+ 400: errorResponseSchema,
1547
+ },
1548
+ },
1549
+ }, async (request) => service.listDeliveryActions(request.body));
1550
+ app.post("/deliveries/invoke", {
1551
+ schema: {
1552
+ tags: ["deliveries"],
1553
+ body: {
1554
+ oneOf: [
1555
+ {
1556
+ type: "object",
1557
+ additionalProperties: false,
1558
+ required: ["deliveryHandle", "operation", "input"],
1559
+ properties: {
1560
+ sourceId: { type: "string", minLength: 1 },
1561
+ deliveryHandle: deliveryHandleSchema,
1562
+ operation: { type: "string", minLength: 1 },
1563
+ input: jsonObjectSchema,
1564
+ },
1565
+ },
1566
+ {
1567
+ type: "object",
1568
+ additionalProperties: false,
1569
+ required: ["provider", "surface", "targetRef", "operation", "input"],
1570
+ properties: {
1571
+ sourceId: { type: "string", minLength: 1 },
1572
+ provider: { type: "string", minLength: 1 },
1573
+ surface: { type: "string", minLength: 1 },
1574
+ targetRef: { type: "string", minLength: 1 },
1575
+ threadRef: { type: "string" },
1576
+ replyMode: { type: "string" },
1577
+ operation: { type: "string", minLength: 1 },
1578
+ input: jsonObjectSchema,
1579
+ },
1580
+ },
1581
+ ],
1582
+ },
1583
+ response: {
1584
+ 200: jsonObjectSchema,
1585
+ 400: errorResponseSchema,
1586
+ },
1587
+ },
1588
+ }, async (request) => service.invokeDelivery(request.body));
1179
1589
  app.setNotFoundHandler((_request, reply) => {
1180
1590
  void reply.code(404).send({ error: "not found" });
1181
1591
  });
@@ -1256,7 +1666,15 @@ function isBadRequestError(message) {
1256
1666
  message.startsWith("manual append is not supported") ||
1257
1667
  message.startsWith("sources/events requires") ||
1258
1668
  message.startsWith("source remove requires") ||
1669
+ message.startsWith("delivery requires") ||
1670
+ message.startsWith("deliver send is not supported") ||
1259
1671
  message.startsWith("deliveryHandle requires") ||
1672
+ message.startsWith("delivery operations are not supported") ||
1673
+ message.startsWith("unknown GitHub delivery operation") ||
1674
+ message.startsWith("unknown Feishu delivery operation") ||
1675
+ message.startsWith("invalid GitHub targetRef") ||
1676
+ message.includes("requires input.text") ||
1677
+ message.includes("requires input.body") ||
1260
1678
  message.startsWith("subscriptions/reset requires") ||
1261
1679
  message.startsWith("agents requires") ||
1262
1680
  message.startsWith("agents/targets requires") ||
@@ -1277,10 +1695,13 @@ function isBadRequestError(message) {
1277
1695
  message.startsWith("expected integer") ||
1278
1696
  message.startsWith("expected positive integer") ||
1279
1697
  message.startsWith("notifyLeaseMs must be a positive integer") ||
1698
+ message.startsWith("minUnackedItems must be a positive integer") ||
1280
1699
  message.startsWith("invalid webhook activation target") ||
1281
1700
  message.startsWith("remote_source requires") ||
1282
1701
  message.startsWith("remote_source profile") ||
1283
1702
  message.startsWith("remote_source module") ||
1703
+ message.startsWith("reply_in_review_thread requires") ||
1704
+ message.includes("does not match delivery provider") ||
1284
1705
  message.includes("requires tmuxPaneId") ||
1285
1706
  message.includes("requires iTerm2 session identity") ||
1286
1707
  message.includes("requires a supported terminal context") ||