@holon-run/agentinbox 1.0.2 → 1.0.4

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
@@ -133,6 +133,13 @@ function buildFastifyServer(service) {
133
133
  app.get("/hosts", {
134
134
  schema: {
135
135
  tags: ["sources"],
136
+ querystring: {
137
+ type: "object",
138
+ additionalProperties: false,
139
+ properties: {
140
+ limit: { type: "string", pattern: "^[1-9][0-9]*$" },
141
+ },
142
+ },
136
143
  response: {
137
144
  200: {
138
145
  type: "object",
@@ -143,7 +150,10 @@ function buildFastifyServer(service) {
143
150
  },
144
151
  },
145
152
  },
146
- }, async () => ({ hosts: service.listHosts() }));
153
+ }, async (request) => {
154
+ const query = request.query;
155
+ return { hosts: service.listHosts(parseOptionalPositiveInteger(query.limit)) };
156
+ });
147
157
  app.post("/hosts", {
148
158
  schema: {
149
159
  tags: ["sources"],
@@ -206,6 +216,13 @@ function buildFastifyServer(service) {
206
216
  app.get("/streams", {
207
217
  schema: {
208
218
  tags: ["sources"],
219
+ querystring: {
220
+ type: "object",
221
+ additionalProperties: false,
222
+ properties: {
223
+ limit: { type: "string", pattern: "^[1-9][0-9]*$" },
224
+ },
225
+ },
209
226
  response: {
210
227
  200: {
211
228
  type: "object",
@@ -216,7 +233,10 @@ function buildFastifyServer(service) {
216
233
  },
217
234
  },
218
235
  },
219
- }, async () => ({ streams: service.listStreams() }));
236
+ }, async (request) => {
237
+ const query = request.query;
238
+ return { streams: service.listStreams(parseOptionalPositiveInteger(query.limit)) };
239
+ });
220
240
  app.post("/streams", {
221
241
  schema: {
222
242
  tags: ["sources"],
@@ -280,6 +300,13 @@ function buildFastifyServer(service) {
280
300
  app.get("/sources", {
281
301
  schema: {
282
302
  tags: ["sources"],
303
+ querystring: {
304
+ type: "object",
305
+ additionalProperties: false,
306
+ properties: {
307
+ limit: { type: "string", pattern: "^[1-9][0-9]*$" },
308
+ },
309
+ },
283
310
  response: {
284
311
  200: {
285
312
  type: "object",
@@ -290,7 +317,10 @@ function buildFastifyServer(service) {
290
317
  },
291
318
  },
292
319
  },
293
- }, async () => ({ sources: await service.listSourceViews() }));
320
+ }, async (request) => {
321
+ const query = request.query;
322
+ return { sources: await service.listSourceViews(parseOptionalPositiveInteger(query.limit)) };
323
+ });
294
324
  app.post("/sources", {
295
325
  schema: {
296
326
  tags: ["sources"],
@@ -548,6 +578,7 @@ function buildFastifyServer(service) {
548
578
  occurredAt: { type: "string", minLength: 1 },
549
579
  metadata: jsonObjectSchema,
550
580
  rawPayload: jsonObjectSchema,
581
+ providerRawPayload: jsonObjectSchema,
551
582
  },
552
583
  },
553
584
  response: {
@@ -564,6 +595,7 @@ function buildFastifyServer(service) {
564
595
  occurredAt: body.occurredAt,
565
596
  metadata: body.metadata ?? {},
566
597
  rawPayload: body.rawPayload ?? {},
598
+ providerRawPayload: body.providerRawPayload,
567
599
  });
568
600
  });
569
601
  app.delete("/sources/:sourceId", {
@@ -702,6 +734,7 @@ function buildFastifyServer(service) {
702
734
  occurredAt: { type: "string", minLength: 1 },
703
735
  metadata: jsonObjectSchema,
704
736
  rawPayload: jsonObjectSchema,
737
+ providerRawPayload: jsonObjectSchema,
705
738
  deliveryHandle: deliveryHandleSchema,
706
739
  },
707
740
  },
@@ -719,6 +752,7 @@ function buildFastifyServer(service) {
719
752
  occurredAt: optionalString(body.occurredAt),
720
753
  metadata: body.metadata ?? {},
721
754
  rawPayload: body.rawPayload ?? {},
755
+ providerRawPayload: body.providerRawPayload,
722
756
  deliveryHandle: body.deliveryHandle ?? null,
723
757
  });
724
758
  });
@@ -730,6 +764,7 @@ function buildFastifyServer(service) {
730
764
  additionalProperties: false,
731
765
  properties: {
732
766
  include_targets: { type: "string", enum: ["true", "false"] },
767
+ limit: { type: "string", pattern: "^[1-9][0-9]*$" },
733
768
  },
734
769
  },
735
770
  response: {
@@ -744,17 +779,10 @@ function buildFastifyServer(service) {
744
779
  },
745
780
  }, async (request) => {
746
781
  const query = request.query;
747
- const agents = service.listAgents();
782
+ const agents = service.listAgents(parseOptionalPositiveInteger(query.limit));
748
783
  if (query.include_targets === "true") {
749
- const activationTargetsByAgentId = service.listActivationTargets().reduce((grouped, target) => {
750
- const targets = grouped.get(target.agentId);
751
- const summarized = (0, current_agent_1.summarizeActivationTarget)(target);
752
- if (targets) {
753
- targets.push(summarized);
754
- }
755
- else {
756
- grouped.set(target.agentId, [summarized]);
757
- }
784
+ const activationTargetsByAgentId = agents.reduce((grouped, agent) => {
785
+ grouped.set(agent.agentId, service.listActivationTargets(agent.agentId).map((target) => (0, current_agent_1.summarizeActivationTarget)(target)));
758
786
  return grouped;
759
787
  }, new Map());
760
788
  return {
@@ -920,6 +948,13 @@ function buildFastifyServer(service) {
920
948
  agentId: { type: "string", minLength: 1 },
921
949
  },
922
950
  },
951
+ querystring: {
952
+ type: "object",
953
+ additionalProperties: false,
954
+ properties: {
955
+ limit: { type: "string", pattern: "^[1-9][0-9]*$" },
956
+ },
957
+ },
923
958
  response: {
924
959
  200: {
925
960
  type: "object",
@@ -932,7 +967,8 @@ function buildFastifyServer(service) {
932
967
  },
933
968
  }, async (request) => {
934
969
  const params = request.params;
935
- return { targets: service.listActivationTargets(decodeURIComponent(params.agentId)) };
970
+ const query = request.query;
971
+ return { targets: service.listActivationTargets(decodeURIComponent(params.agentId), parseOptionalPositiveInteger(query.limit)) };
936
972
  });
937
973
  app.post("/agents/:agentId/targets", {
938
974
  schema: {
@@ -1017,6 +1053,7 @@ function buildFastifyServer(service) {
1017
1053
  additionalProperties: false,
1018
1054
  properties: {
1019
1055
  agent_id: { type: "string" },
1056
+ limit: { type: "string", pattern: "^[1-9][0-9]*$" },
1020
1057
  },
1021
1058
  },
1022
1059
  response: {
@@ -1031,7 +1068,7 @@ function buildFastifyServer(service) {
1031
1068
  },
1032
1069
  }, async (request) => {
1033
1070
  const query = request.query;
1034
- return { timers: service.listTimers(query.agent_id) };
1071
+ return { timers: service.listTimers(query.agent_id, parseOptionalPositiveInteger(query.limit)) };
1035
1072
  });
1036
1073
  app.post("/timers", {
1037
1074
  schema: {
@@ -1135,6 +1172,7 @@ function buildFastifyServer(service) {
1135
1172
  properties: {
1136
1173
  source_id: { type: "string" },
1137
1174
  agent_id: { type: "string" },
1175
+ limit: { type: "string", pattern: "^[1-9][0-9]*$" },
1138
1176
  },
1139
1177
  },
1140
1178
  response: {
@@ -1147,6 +1185,7 @@ function buildFastifyServer(service) {
1147
1185
  subscriptions: service.listSubscriptions({
1148
1186
  sourceId: query.source_id,
1149
1187
  agentId: query.agent_id,
1188
+ limit: parseOptionalPositiveInteger(query.limit),
1150
1189
  }),
1151
1190
  };
1152
1191
  });
@@ -1348,6 +1387,7 @@ function buildFastifyServer(service) {
1348
1387
  properties: {
1349
1388
  after_entry_id: { type: "string" },
1350
1389
  include_acked: { type: "string", enum: ["true", "false"] },
1390
+ limit: { type: "string", pattern: "^[1-9][0-9]*$" },
1351
1391
  },
1352
1392
  },
1353
1393
  response: {
@@ -1367,6 +1407,7 @@ function buildFastifyServer(service) {
1367
1407
  entries: service.listInboxItems(decodeURIComponent(params.agentId), {
1368
1408
  afterEntryId: query.after_entry_id,
1369
1409
  includeAcked: query.include_acked ? query.include_acked === "true" : undefined,
1410
+ limit: parseOptionalPositiveInteger(query.limit),
1370
1411
  }),
1371
1412
  };
1372
1413
  });
@@ -1738,6 +1779,19 @@ function optionalString(value) {
1738
1779
  const trimmed = value.trim();
1739
1780
  return trimmed.length > 0 ? trimmed : undefined;
1740
1781
  }
1782
+ function parseOptionalPositiveInteger(value) {
1783
+ if (value === undefined) {
1784
+ return undefined;
1785
+ }
1786
+ if (!/^[1-9]\d*$/.test(value)) {
1787
+ throw new Error("expected positive integer");
1788
+ }
1789
+ const parsed = Number.parseInt(value, 10);
1790
+ if (!Number.isSafeInteger(parsed)) {
1791
+ throw new Error("expected positive integer within safe range");
1792
+ }
1793
+ return parsed;
1794
+ }
1741
1795
  function normalizeValidationMessage(message) {
1742
1796
  if (message.includes("must be boolean")) {
1743
1797
  return "expected boolean";
@@ -144,14 +144,14 @@ class AgentInboxService {
144
144
  await this.adapters.sourceAdapterFor(source.sourceType).ensureSource(source);
145
145
  return source;
146
146
  }
147
- listSources() {
148
- return this.store.listSources();
147
+ listSources(limit) {
148
+ return this.store.listSources(limit);
149
149
  }
150
- async listSourceViews() {
151
- return this.attachSourceRuntimes(this.store.listSources());
150
+ async listSourceViews(limit) {
151
+ return this.attachSourceRuntimes(this.store.listSources(limit));
152
152
  }
153
- listHosts() {
154
- return this.store.listSourceHosts();
153
+ listHosts(limit) {
154
+ return this.store.listSourceHosts(limit);
155
155
  }
156
156
  getHost(hostId) {
157
157
  const host = this.store.getSourceHost(hostId);
@@ -269,8 +269,8 @@ class AgentInboxService {
269
269
  return this.getStream(stream.sourceId);
270
270
  });
271
271
  }
272
- listStreams() {
273
- return this.listSources();
272
+ listStreams(limit) {
273
+ return this.listSources(limit);
274
274
  }
275
275
  getStream(streamId) {
276
276
  return this.getSource(streamId);
@@ -590,8 +590,8 @@ class AgentInboxService {
590
590
  notifyLeaseMs: notifyLeaseMs ?? null,
591
591
  });
592
592
  }
593
- listAgents() {
594
- return this.store.listAgents();
593
+ listAgents(limit) {
594
+ return this.store.listAgents(limit);
595
595
  }
596
596
  getAgent(agentId) {
597
597
  const agent = this.store.getAgent(agentId);
@@ -666,12 +666,12 @@ class AgentInboxService {
666
666
  this.rescheduleTimerSync();
667
667
  return timer;
668
668
  }
669
- listTimers(agentId) {
669
+ listTimers(agentId, limit) {
670
670
  if (agentId) {
671
671
  this.getAgent(agentId);
672
- return this.store.listTimersForAgent(agentId);
672
+ return this.store.listTimersForAgent(agentId, limit);
673
673
  }
674
- return this.store.listTimers();
674
+ return this.store.listTimers(limit);
675
675
  }
676
676
  getTimer(scheduleId) {
677
677
  const timer = this.store.getTimer(scheduleId);
@@ -758,12 +758,12 @@ class AgentInboxService {
758
758
  this.markAgentActive(agentId);
759
759
  return target;
760
760
  }
761
- listActivationTargets(agentId) {
761
+ listActivationTargets(agentId, limit) {
762
762
  if (agentId) {
763
763
  this.getAgent(agentId);
764
- return this.store.listActivationTargetsForAgent(agentId);
764
+ return this.store.listActivationTargetsForAgent(agentId, limit);
765
765
  }
766
- return this.store.listActivationTargets();
766
+ return this.store.listActivationTargets(limit);
767
767
  }
768
768
  getActivationTarget(targetId) {
769
769
  const target = this.store.getActivationTarget(targetId);
@@ -1024,15 +1024,7 @@ class AgentInboxService {
1024
1024
  return { removed: true, subscriptionId };
1025
1025
  }
1026
1026
  listSubscriptions(filters) {
1027
- return this.store.listSubscriptions().filter((subscription) => {
1028
- if (filters?.sourceId && subscription.sourceId !== filters.sourceId) {
1029
- return false;
1030
- }
1031
- if (filters?.agentId && subscription.agentId !== filters.agentId) {
1032
- return false;
1033
- }
1034
- return true;
1035
- });
1027
+ return this.store.listSubscriptionsFiltered(filters);
1036
1028
  }
1037
1029
  getSubscription(subscriptionId) {
1038
1030
  const subscription = this.store.getSubscription(subscriptionId);
@@ -1098,8 +1090,8 @@ class AgentInboxService {
1098
1090
  }
1099
1091
  return this.appendSourceEvent({ ...input, sourceId });
1100
1092
  }
1101
- listInboxAgentIds() {
1102
- return this.store.listInboxes().map((inbox) => inbox.ownerAgentId);
1093
+ listInboxAgentIds(limit) {
1094
+ return this.store.listInboxes(limit).map((inbox) => inbox.ownerAgentId);
1103
1095
  }
1104
1096
  getInboxDetailsByAgent(agentId) {
1105
1097
  const inbox = this.ensureInboxForAgent(agentId);
@@ -1193,6 +1185,7 @@ class AgentInboxService {
1193
1185
  occurredAt,
1194
1186
  metadata: {},
1195
1187
  rawPayload: input.rawPayload,
1188
+ providerRawPayload: undefined,
1196
1189
  deliveryHandle: null,
1197
1190
  ackedAt: null,
1198
1191
  };
@@ -1516,6 +1509,7 @@ class AgentInboxService {
1516
1509
  subscriptionId: subscription.subscriptionId,
1517
1510
  },
1518
1511
  rawPayload: event.rawPayload,
1512
+ providerRawPayload: event.providerRawPayload,
1519
1513
  deliveryHandle: event.deliveryHandle,
1520
1514
  ackedAt: null,
1521
1515
  };
@@ -3406,6 +3400,7 @@ function activationItemFromInboxItem(item) {
3406
3400
  occurredAt: item.occurredAt,
3407
3401
  metadata: item.metadata,
3408
3402
  rawPayload: item.rawPayload,
3403
+ providerRawPayload: item.providerRawPayload,
3409
3404
  deliveryHandle: item.deliveryHandle,
3410
3405
  };
3411
3406
  }
@@ -46,7 +46,7 @@ class GithubUxcClient {
46
46
  issue_number: input.issueNumber,
47
47
  body: input.body,
48
48
  },
49
- options: { auth: input.auth },
49
+ options: githubAuthOptions(input.auth),
50
50
  });
51
51
  }
52
52
  async replyToReviewComment(input) {
@@ -60,7 +60,7 @@ class GithubUxcClient {
60
60
  comment_id: input.commentId,
61
61
  body: input.body,
62
62
  },
63
- options: { auth: input.auth },
63
+ options: githubAuthOptions(input.auth),
64
64
  });
65
65
  }
66
66
  async updateIssueState(input) {
@@ -73,7 +73,7 @@ class GithubUxcClient {
73
73
  issue_number: input.issueNumber,
74
74
  state: input.state,
75
75
  },
76
- options: { auth: input.auth },
76
+ options: githubAuthOptions(input.auth),
77
77
  });
78
78
  }
79
79
  async mergePullRequest(input) {
@@ -88,7 +88,7 @@ class GithubUxcClient {
88
88
  commit_title: input.commitTitle ?? null,
89
89
  commit_message: input.commitMessage ?? null,
90
90
  },
91
- options: { auth: input.auth },
91
+ options: githubAuthOptions(input.auth),
92
92
  });
93
93
  }
94
94
  async getPullRequestDetails(input) {
@@ -100,7 +100,7 @@ class GithubUxcClient {
100
100
  repo: input.repo,
101
101
  pull_number: input.pullNumber,
102
102
  },
103
- options: { auth: input.auth },
103
+ options: githubReadOptions(input.auth),
104
104
  });
105
105
  const data = asRecord(response.data);
106
106
  const head = asRecord(data.head);
@@ -333,7 +333,7 @@ async function hydrateGithubRepoEventIfNeeded(config, raw, client = DEFAULT_GITH
333
333
  per_page: perPage,
334
334
  page,
335
335
  },
336
- options: { auth: config.uxcAuth },
336
+ options: githubReadOptions(config.uxcAuth),
337
337
  });
338
338
  }
339
339
  catch {
@@ -705,6 +705,15 @@ function computeGithubHydrationPerPage(perPage) {
705
705
  : GITHUB_EVENT_HYDRATION_MIN_PER_PAGE;
706
706
  return Math.min(GITHUB_EVENT_HYDRATION_MAX_PER_PAGE, Math.max(GITHUB_EVENT_HYDRATION_MIN_PER_PAGE, configured));
707
707
  }
708
+ function githubAuthOptions(auth) {
709
+ return { auth };
710
+ }
711
+ function githubReadOptions(auth) {
712
+ return {
713
+ auth,
714
+ artifact_compaction: false,
715
+ };
716
+ }
708
717
  function extractGithubRepoEventUrl(event, issue, pullRequest, review, comment) {
709
718
  return (asString(comment.html_url)
710
719
  ?? asString(review.html_url)
@@ -391,6 +391,7 @@ class RemoteSourceRuntime {
391
391
  occurredAt: mapped.occurredAt,
392
392
  metadata: mapped.metadata,
393
393
  rawPayload: mapped.rawPayload,
394
+ providerRawPayload: mapped.providerRawPayload,
394
395
  deliveryHandle: mapped.deliveryHandle ?? null,
395
396
  });
396
397
  appended += result.appended;
@@ -297,7 +297,10 @@ function createGithubRepoRemoteModule(options) {
297
297
  seen_window: 1024,
298
298
  },
299
299
  },
300
- options: { auth: config.uxcAuth },
300
+ options: {
301
+ auth: config.uxcAuth,
302
+ artifact_compaction: false,
303
+ },
301
304
  };
302
305
  },
303
306
  async mapRawEvent(rawPayload, source) {
@@ -312,6 +315,7 @@ function createGithubRepoRemoteModule(options) {
312
315
  eventVariant: normalized.eventVariant,
313
316
  metadata: normalized.metadata ?? {},
314
317
  rawPayload: normalized.rawPayload ?? hydratedPayload,
318
+ providerRawPayload: hydratedPayload,
315
319
  occurredAt: normalized.occurredAt,
316
320
  deliveryHandle: normalized.deliveryHandle,
317
321
  };
@@ -434,7 +438,10 @@ const GITHUB_REPO_CI_MODULE = {
434
438
  seen_window: 1024,
435
439
  },
436
440
  },
437
- options: { auth: config.uxcAuth },
441
+ options: {
442
+ auth: config.uxcAuth,
443
+ artifact_compaction: false,
444
+ },
438
445
  };
439
446
  },
440
447
  mapRawEvent(rawPayload, source) {
@@ -448,6 +455,7 @@ const GITHUB_REPO_CI_MODULE = {
448
455
  eventVariant: normalized.eventVariant,
449
456
  metadata: normalized.metadata ?? {},
450
457
  rawPayload: normalized.rawPayload ?? rawPayload,
458
+ providerRawPayload: rawPayload,
451
459
  occurredAt: normalized.occurredAt,
452
460
  deliveryHandle: normalized.deliveryHandle,
453
461
  };
@@ -500,7 +508,10 @@ const FEISHU_BOT_MODULE = {
500
508
  endpoint: config.endpoint ?? feishu_1.FEISHU_OPENAPI_ENDPOINT,
501
509
  mode: "stream",
502
510
  transport_hint: "feishu_long_connection",
503
- options: { auth: config.uxcAuth },
511
+ options: {
512
+ auth: config.uxcAuth,
513
+ artifact_compaction: false,
514
+ },
504
515
  };
505
516
  },
506
517
  mapRawEvent(rawPayload, source) {
@@ -514,6 +525,7 @@ const FEISHU_BOT_MODULE = {
514
525
  eventVariant: normalized.eventVariant,
515
526
  metadata: normalized.metadata ?? {},
516
527
  rawPayload: normalized.rawPayload ?? rawPayload,
528
+ providerRawPayload: rawPayload,
517
529
  occurredAt: normalized.occurredAt,
518
530
  deliveryHandle: normalized.deliveryHandle,
519
531
  };