@holon-run/agentinbox 0.1.4 → 0.3.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
@@ -149,6 +149,26 @@ function buildFastifyServer(service) {
149
149
  const params = request.params;
150
150
  return service.getSourceDetails(decodeURIComponent(params.sourceId));
151
151
  });
152
+ app.get("/sources/:sourceId/schema", {
153
+ schema: {
154
+ tags: ["sources"],
155
+ params: {
156
+ type: "object",
157
+ required: ["sourceId"],
158
+ properties: {
159
+ sourceId: { type: "string", minLength: 1 },
160
+ },
161
+ },
162
+ response: {
163
+ 200: jsonObjectSchema,
164
+ 400: errorResponseSchema,
165
+ 404: errorResponseSchema,
166
+ },
167
+ },
168
+ }, async (request) => {
169
+ const params = request.params;
170
+ return service.getResolvedSourceSchema(decodeURIComponent(params.sourceId));
171
+ });
152
172
  app.delete("/sources/:sourceId", {
153
173
  schema: {
154
174
  tags: ["sources"],
@@ -159,6 +179,18 @@ function buildFastifyServer(service) {
159
179
  sourceId: { type: "string", minLength: 1 },
160
180
  },
161
181
  },
182
+ querystring: {
183
+ type: "object",
184
+ additionalProperties: false,
185
+ properties: {
186
+ with_subscriptions: {
187
+ anyOf: [
188
+ { type: "boolean" },
189
+ { type: "string", enum: ["true", "false", "1", "0"] },
190
+ ],
191
+ },
192
+ },
193
+ },
162
194
  response: {
163
195
  200: jsonObjectSchema,
164
196
  400: errorResponseSchema,
@@ -166,7 +198,10 @@ function buildFastifyServer(service) {
166
198
  },
167
199
  }, async (request) => {
168
200
  const params = request.params;
169
- return service.removeSource(decodeURIComponent(params.sourceId));
201
+ const query = request.query;
202
+ return service.removeSource(decodeURIComponent(params.sourceId), {
203
+ withSubscriptions: query.with_subscriptions === true || query.with_subscriptions === "true" || query.with_subscriptions === "1",
204
+ });
170
205
  });
171
206
  app.patch("/sources/:sourceId", {
172
207
  schema: {
@@ -250,6 +285,25 @@ function buildFastifyServer(service) {
250
285
  const params = request.params;
251
286
  return service.getSourceSchema(decodeURIComponent(params.sourceType));
252
287
  });
288
+ app.post("/sources/schema-preview", {
289
+ schema: {
290
+ tags: ["sources"],
291
+ body: {
292
+ type: "object",
293
+ additionalProperties: false,
294
+ required: ["sourceRef"],
295
+ properties: {
296
+ sourceRef: { type: "string", minLength: 1 },
297
+ configRef: { anyOf: [{ type: "string" }, { type: "null" }] },
298
+ config: jsonObjectSchema,
299
+ },
300
+ },
301
+ response: {
302
+ 200: jsonObjectSchema,
303
+ 400: errorResponseSchema,
304
+ },
305
+ },
306
+ }, async (request) => service.previewSourceSchema(request.body));
253
307
  app.post("/sources/:sourceId/poll", {
254
308
  schema: {
255
309
  tags: ["sources"],
@@ -365,6 +419,7 @@ function buildFastifyServer(service) {
365
419
  backend: { type: "string", minLength: 1 },
366
420
  runtimeKind: { type: "string" },
367
421
  runtimeSessionId: { type: "string" },
422
+ runtimePid: { type: "integer", minimum: 1 },
368
423
  tmuxPaneId: { type: "string" },
369
424
  tty: { type: "string" },
370
425
  termProgram: { type: "string" },
@@ -385,6 +440,7 @@ function buildFastifyServer(service) {
385
440
  backend: String(body.backend),
386
441
  runtimeKind: optionalString(body.runtimeKind),
387
442
  runtimeSessionId: optionalString(body.runtimeSessionId),
443
+ runtimePid: typeof body.runtimePid === "number" ? body.runtimePid : null,
388
444
  mode: "agent_prompt",
389
445
  tmuxPaneId: optionalString(body.tmuxPaneId),
390
446
  tty: optionalString(body.tty),
@@ -509,6 +565,123 @@ function buildFastifyServer(service) {
509
565
  const params = request.params;
510
566
  return service.removeActivationTarget(decodeURIComponent(params.agentId), decodeURIComponent(params.targetId));
511
567
  });
568
+ app.get("/timers", {
569
+ schema: {
570
+ tags: ["timers"],
571
+ querystring: {
572
+ type: "object",
573
+ additionalProperties: false,
574
+ properties: {
575
+ agent_id: { type: "string" },
576
+ },
577
+ },
578
+ response: {
579
+ 200: {
580
+ type: "object",
581
+ required: ["timers"],
582
+ properties: {
583
+ timers: { type: "array", items: jsonObjectSchema },
584
+ },
585
+ },
586
+ },
587
+ },
588
+ }, async (request) => {
589
+ const query = request.query;
590
+ return { timers: service.listTimers(query.agent_id) };
591
+ });
592
+ app.post("/timers", {
593
+ schema: {
594
+ tags: ["timers"],
595
+ body: {
596
+ type: "object",
597
+ additionalProperties: false,
598
+ required: ["agentId", "message"],
599
+ properties: {
600
+ agentId: { type: "string", minLength: 1 },
601
+ at: { type: "string", minLength: 1 },
602
+ every: { type: "integer", minimum: 60000 },
603
+ cron: { type: "string", minLength: 1 },
604
+ timezone: { type: "string", minLength: 1 },
605
+ message: { type: "string", minLength: 1 },
606
+ sender: { type: "string", minLength: 1 },
607
+ },
608
+ },
609
+ response: {
610
+ 200: jsonObjectSchema,
611
+ 400: errorResponseSchema,
612
+ },
613
+ },
614
+ }, async (request) => {
615
+ const body = request.body;
616
+ return service.registerTimer({
617
+ agentId: String(body.agentId),
618
+ at: optionalString(body.at) ?? null,
619
+ every: typeof body.every === "number" ? body.every : null,
620
+ cron: optionalString(body.cron) ?? null,
621
+ timezone: optionalString(body.timezone) ?? null,
622
+ message: String(body.message),
623
+ sender: optionalString(body.sender) ?? null,
624
+ });
625
+ });
626
+ app.post("/timers/:scheduleId/pause", {
627
+ schema: {
628
+ tags: ["timers"],
629
+ params: {
630
+ type: "object",
631
+ required: ["scheduleId"],
632
+ properties: {
633
+ scheduleId: { type: "string", minLength: 1 },
634
+ },
635
+ },
636
+ response: {
637
+ 200: jsonObjectSchema,
638
+ 400: errorResponseSchema,
639
+ 404: errorResponseSchema,
640
+ },
641
+ },
642
+ }, async (request) => {
643
+ const params = request.params;
644
+ return service.pauseTimer(decodeURIComponent(params.scheduleId));
645
+ });
646
+ app.post("/timers/:scheduleId/resume", {
647
+ schema: {
648
+ tags: ["timers"],
649
+ params: {
650
+ type: "object",
651
+ required: ["scheduleId"],
652
+ properties: {
653
+ scheduleId: { type: "string", minLength: 1 },
654
+ },
655
+ },
656
+ response: {
657
+ 200: jsonObjectSchema,
658
+ 400: errorResponseSchema,
659
+ 404: errorResponseSchema,
660
+ },
661
+ },
662
+ }, async (request) => {
663
+ const params = request.params;
664
+ return service.resumeTimer(decodeURIComponent(params.scheduleId));
665
+ });
666
+ app.delete("/timers/:scheduleId", {
667
+ schema: {
668
+ tags: ["timers"],
669
+ params: {
670
+ type: "object",
671
+ required: ["scheduleId"],
672
+ properties: {
673
+ scheduleId: { type: "string", minLength: 1 },
674
+ },
675
+ },
676
+ response: {
677
+ 200: jsonObjectSchema,
678
+ 404: errorResponseSchema,
679
+ },
680
+ },
681
+ }, async (request) => {
682
+ const params = request.params;
683
+ return service.removeTimer(decodeURIComponent(params.scheduleId));
684
+ });
512
685
  app.get("/subscriptions", {
513
686
  schema: {
514
687
  tags: ["subscriptions"],
@@ -549,9 +722,18 @@ function buildFastifyServer(service) {
549
722
  properties: {
550
723
  agentId: { type: "string", minLength: 1 },
551
724
  sourceId: { type: "string", minLength: 1 },
725
+ shortcut: {
726
+ type: "object",
727
+ additionalProperties: false,
728
+ required: ["name"],
729
+ properties: {
730
+ name: { type: "string", minLength: 1 },
731
+ args: jsonObjectSchema,
732
+ },
733
+ },
552
734
  filter: jsonObjectSchema,
553
- lifecycleMode: { type: "string" },
554
- expiresAt: { type: "string" },
735
+ trackedResourceRef: { type: "string" },
736
+ cleanupPolicy: jsonObjectSchema,
555
737
  startPolicy: { type: "string" },
556
738
  startOffset: { type: "integer" },
557
739
  startTime: { type: "string" },
@@ -567,9 +749,17 @@ function buildFastifyServer(service) {
567
749
  return service.registerSubscription({
568
750
  agentId: String(body.agentId),
569
751
  sourceId: String(body.sourceId),
570
- filter: body.filter ?? {},
571
- lifecycleMode: optionalString(body.lifecycleMode),
572
- expiresAt: optionalString(body.expiresAt) ?? null,
752
+ shortcut: body.shortcut && typeof body.shortcut === "object"
753
+ ? {
754
+ name: String(body.shortcut.name),
755
+ args: body.shortcut.args ?? undefined,
756
+ }
757
+ : undefined,
758
+ filter: body.filter && typeof body.filter === "object"
759
+ ? body.filter
760
+ : undefined,
761
+ trackedResourceRef: optionalString(body.trackedResourceRef) ?? null,
762
+ cleanupPolicy: body.cleanupPolicy,
573
763
  startPolicy: optionalString(body.startPolicy),
574
764
  startOffset: typeof body.startOffset === "number" ? body.startOffset : undefined,
575
765
  startTime: optionalString(body.startTime) ?? undefined,
@@ -741,6 +931,39 @@ function buildFastifyServer(service) {
741
931
  }),
742
932
  };
743
933
  });
934
+ app.post("/agents/:agentId/inbox/items", {
935
+ schema: {
936
+ tags: ["inbox"],
937
+ params: {
938
+ type: "object",
939
+ required: ["agentId"],
940
+ properties: {
941
+ agentId: { type: "string", minLength: 1 },
942
+ },
943
+ },
944
+ body: {
945
+ type: "object",
946
+ additionalProperties: false,
947
+ required: ["message"],
948
+ properties: {
949
+ message: { type: "string", minLength: 1 },
950
+ sender: { type: "string", minLength: 1 },
951
+ },
952
+ },
953
+ response: {
954
+ 200: jsonObjectSchema,
955
+ 400: errorResponseSchema,
956
+ 404: errorResponseSchema,
957
+ },
958
+ },
959
+ }, async (request) => {
960
+ const params = request.params;
961
+ const body = request.body;
962
+ return service.addDirectInboxTextMessage(decodeURIComponent(params.agentId), {
963
+ message: body.message,
964
+ sender: body.sender ?? null,
965
+ });
966
+ });
744
967
  app.get("/agents/:agentId/inbox/watch", {
745
968
  schema: {
746
969
  tags: ["inbox"],
@@ -989,7 +1212,11 @@ function normalizeValidationMessage(message) {
989
1212
  return message;
990
1213
  }
991
1214
  function isBadRequestError(message) {
992
- return (message.startsWith("manual append is not supported") ||
1215
+ return (message.startsWith("direct inbox ") ||
1216
+ message.startsWith("timers require ") ||
1217
+ message.startsWith("timer ") ||
1218
+ message.startsWith("invalid timezone: ") ||
1219
+ message.startsWith("manual append is not supported") ||
993
1220
  message.startsWith("sources/events requires") ||
994
1221
  message.startsWith("source remove requires") ||
995
1222
  message.startsWith("deliveryHandle requires") ||
@@ -999,9 +1226,16 @@ function isBadRequestError(message) {
999
1226
  message.startsWith("subscriptions requires") ||
1000
1227
  message.startsWith("agent register conflict") ||
1001
1228
  message.startsWith("unsupported activation target kind") ||
1002
- message.startsWith("unsupported lifecycle mode") ||
1229
+ message.startsWith("unsupported cleanup policy mode") ||
1003
1230
  message.startsWith("unsupported start policy") ||
1004
1231
  message.startsWith("unsupported terminal") ||
1232
+ message.startsWith("cleanupPolicy ") ||
1233
+ message.startsWith("trackedResourceRef ") ||
1234
+ message.startsWith("preview failed: ") ||
1235
+ message.startsWith("unknown source kind or type for preview") ||
1236
+ message.startsWith("preview source kind ") ||
1237
+ message.startsWith("subscription add shortcut") ||
1238
+ message.startsWith("unknown subscription shortcut ") ||
1005
1239
  message.startsWith("expected boolean") ||
1006
1240
  message.startsWith("expected integer") ||
1007
1241
  message.startsWith("expected positive integer") ||