@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/cli.js CHANGED
@@ -53,7 +53,11 @@ async function main() {
53
53
  await runDaemon(normalized.slice(1));
54
54
  return;
55
55
  }
56
- const client = await createClient(normalized);
56
+ if (hasHelpFlag(normalized.slice(1))) {
57
+ printHelp([command]);
58
+ return;
59
+ }
60
+ const client = await createClient(clientArgsForCommand(normalized));
57
61
  if (command === "host" && normalized[1] === "add") {
58
62
  const [hostType, hostKey] = normalized.slice(2, 4);
59
63
  if (!hostType || !hostKey) {
@@ -68,7 +72,10 @@ async function main() {
68
72
  return;
69
73
  }
70
74
  if (command === "host" && normalized[1] === "list") {
71
- await printRemote(client, "/hosts", undefined, "GET");
75
+ const query = buildQuery({
76
+ limit: parseOptionalLimitArg(normalized),
77
+ });
78
+ await printRemote(client, `/hosts${query}`, undefined, "GET");
72
79
  return;
73
80
  }
74
81
  if (command === "host" && normalized[1] === "show") {
@@ -102,7 +109,10 @@ async function main() {
102
109
  return;
103
110
  }
104
111
  if (command === "stream" && normalized[1] === "list") {
105
- await printRemote(client, "/streams", undefined, "GET");
112
+ const query = buildQuery({
113
+ limit: parseOptionalLimitArg(normalized),
114
+ });
115
+ await printRemote(client, `/streams${query}`, undefined, "GET");
106
116
  return;
107
117
  }
108
118
  if (command === "stream" && normalized[1] === "show") {
@@ -262,7 +272,10 @@ async function main() {
262
272
  return;
263
273
  }
264
274
  if (command === "source" && normalized[1] === "list") {
265
- await printRemote(client, "/sources", undefined, "GET");
275
+ const query = buildQuery({
276
+ limit: parseOptionalLimitArg(normalized),
277
+ });
278
+ await printRemote(client, `/sources${query}`, undefined, "GET");
266
279
  return;
267
280
  }
268
281
  if (command === "source" && normalized[1] === "show") {
@@ -359,15 +372,18 @@ async function main() {
359
372
  const notifyLeaseMs = parseOptionalNumber(takeFlagValue(normalized, "--notify-lease-ms")) ?? undefined;
360
373
  const minUnackedItems = parseOptionalNumber(takeFlagValue(normalized, "--min-unacked-items")) ?? undefined;
361
374
  const webhookUrl = takeFlagValue(normalized, "--webhook-url");
375
+ const holonContext = (0, current_agent_1.detectHolonRuntimeContext)(process.env);
362
376
  if (webhookUrl) {
363
- if (!agentId) {
364
- throw new Error("usage: agentinbox agent register --agent-id ID --webhook-url URL [--webhook-activation-mode MODE] [--webhook-notify-lease-ms N] [--webhook-min-unacked-items N]");
377
+ const resolvedAgentId = agentId ?? holonContext?.agentId;
378
+ if (!resolvedAgentId) {
379
+ throw new Error("usage: agentinbox agent register --agent-id ID --webhook-url URL [--webhook-activation-mode MODE] [--webhook-notify-lease-ms N] [--webhook-min-unacked-items N] (or set HOLON_AGENT_ID in Holon)");
365
380
  }
366
381
  const webhookNotifyLeaseMs = parseOptionalNumber(takeFlagValue(normalized, "--webhook-notify-lease-ms")) ?? notifyLeaseMs;
367
382
  const webhookMinUnackedItems = parseOptionalNumber(takeFlagValue(normalized, "--webhook-min-unacked-items")) ?? minUnackedItems;
368
383
  await printRemote(client, "/agents", {
369
- agentId,
384
+ agentId: resolvedAgentId,
370
385
  forceRebind: normalized.includes("--force-rebind"),
386
+ ...(holonContext ? { runtimeKind: holonContext.runtimeKind } : {}),
371
387
  webhook: {
372
388
  url: webhookUrl,
373
389
  activationMode: takeFlagValue(normalized, "--webhook-activation-mode") ?? undefined,
@@ -377,6 +393,28 @@ async function main() {
377
393
  });
378
394
  return;
379
395
  }
396
+ if ((0, current_agent_1.isHolonRuntimeEnv)(process.env)) {
397
+ if (!holonContext) {
398
+ throw new Error("agent register in Holon requires HOLON_AGENT_ID");
399
+ }
400
+ if (!holonContext.externalTriggerUrl) {
401
+ throw new Error("agent register in Holon requires --webhook-url or HOLON_EXTERNAL_TRIGGER_URL");
402
+ }
403
+ const webhookNotifyLeaseMs = parseOptionalNumber(takeFlagValue(normalized, "--webhook-notify-lease-ms")) ?? notifyLeaseMs;
404
+ const webhookMinUnackedItems = parseOptionalNumber(takeFlagValue(normalized, "--webhook-min-unacked-items")) ?? minUnackedItems;
405
+ await printRemote(client, "/agents", {
406
+ agentId: agentId ?? holonContext.agentId,
407
+ forceRebind: normalized.includes("--force-rebind"),
408
+ runtimeKind: holonContext.runtimeKind,
409
+ webhook: {
410
+ url: holonContext.externalTriggerUrl,
411
+ activationMode: takeFlagValue(normalized, "--webhook-activation-mode") ?? undefined,
412
+ notifyLeaseMs: webhookNotifyLeaseMs,
413
+ minUnackedItems: webhookMinUnackedItems,
414
+ },
415
+ });
416
+ return;
417
+ }
380
418
  const detected = (0, terminal_1.detectTerminalContext)(process.env);
381
419
  await printRemote(client, "/agents", {
382
420
  agentId,
@@ -395,7 +433,7 @@ async function main() {
395
433
  return;
396
434
  }
397
435
  if (command === "agent" && normalized[1] === "list") {
398
- await printAgentList(client);
436
+ await printAgentList(client, parseOptionalLimitArg(normalized));
399
437
  return;
400
438
  }
401
439
  if (command === "agent" && normalized[1] === "current") {
@@ -444,9 +482,12 @@ async function main() {
444
482
  if (command === "agent" && normalized[1] === "target" && normalized[2] === "list") {
445
483
  const agentId = normalized[3];
446
484
  if (!agentId) {
447
- throw new Error("usage: agentinbox agent target list <agentId>");
485
+ throw new Error("usage: agentinbox agent target list <agentId> [--limit N]");
448
486
  }
449
- await printRemote(client, `/agents/${encodeURIComponent(agentId)}/targets`, undefined, "GET");
487
+ const query = buildQuery({
488
+ limit: parseOptionalLimitArg(normalized),
489
+ });
490
+ await printRemote(client, `/agents/${encodeURIComponent(agentId)}/targets${query}`, undefined, "GET");
450
491
  return;
451
492
  }
452
493
  if (command === "agent" && normalized[1] === "target" && normalized[2] === "remove") {
@@ -518,6 +559,7 @@ async function main() {
518
559
  const query = buildQuery({
519
560
  source_id: takeFlagValue(normalized, "--source-id"),
520
561
  agent_id: takeFlagValue(normalized, "--agent-id"),
562
+ limit: parseOptionalLimitArg(normalized),
521
563
  });
522
564
  await printRemote(client, `/subscriptions${query}`, undefined, "GET");
523
565
  return;
@@ -595,6 +637,7 @@ async function main() {
595
637
  if (command === "timer" && normalized[1] === "list") {
596
638
  const query = buildQuery({
597
639
  agent_id: takeFlagValue(normalized, "--agent-id"),
640
+ limit: parseOptionalLimitArg(normalized),
598
641
  });
599
642
  await printRemote(client, `/timers${query}`, undefined, "GET");
600
643
  return;
@@ -624,7 +667,10 @@ async function main() {
624
667
  return;
625
668
  }
626
669
  if (command === "inbox" && normalized[1] === "list") {
627
- await printRemote(client, "/agents", undefined, "GET");
670
+ const query = buildQuery({
671
+ limit: parseOptionalLimitArg(normalized),
672
+ });
673
+ await printRemote(client, `/agents${query}`, undefined, "GET");
628
674
  return;
629
675
  }
630
676
  if (command === "inbox" && normalized[1] === "show") {
@@ -637,9 +683,9 @@ async function main() {
637
683
  }
638
684
  if (command === "inbox" && normalized[1] === "read") {
639
685
  const args = normalized.slice(2);
640
- const allowedFlags = ["--agent-id", "--after-entry", "--include-acked"];
641
- if (positionalArgs(args, ["--agent-id", "--after-entry"]).length > 0 || unexpectedFlags(args, allowedFlags).length > 0) {
642
- throw new Error("usage: agentinbox inbox read [--agent-id ID] [--after-entry ID] [--include-acked]");
686
+ const allowedFlags = ["--agent-id", "--after-entry", "--include-acked", "--limit"];
687
+ if (positionalArgs(args, ["--agent-id", "--after-entry", "--limit"]).length > 0 || unexpectedFlags(args, allowedFlags).length > 0) {
688
+ throw new Error("usage: agentinbox inbox read [--agent-id ID] [--after-entry ID] [--include-acked] [--limit N]");
643
689
  }
644
690
  const selection = await selectAgentForCommand(client, {
645
691
  explicitAgentId: takeFlagValue(normalized, "--agent-id"),
@@ -648,6 +694,7 @@ async function main() {
648
694
  const query = buildQuery({
649
695
  after_entry_id: takeFlagValue(normalized, "--after-entry"),
650
696
  include_acked: hasFlag(normalized, "--include-acked") ? "true" : undefined,
697
+ limit: parseOptionalLimitArg(normalized),
651
698
  });
652
699
  const response = await requestRemote(client, `/agents/${encodeURIComponent(selection.agentId)}/inbox/entries${query}`, undefined, "GET");
653
700
  console.log((0, util_1.jsonResponse)(withCommandMetadata(response.data, selection)));
@@ -829,10 +876,6 @@ async function main() {
829
876
  await printRemote(client, "/gc", {});
830
877
  return;
831
878
  }
832
- if (hasHelpFlag(normalized.slice(1))) {
833
- printHelp([command]);
834
- return;
835
- }
836
879
  throw new Error(`unknown command: ${normalized.join(" ")}`);
837
880
  }
838
881
  async function runServe(args) {
@@ -925,12 +968,12 @@ async function createClient(args) {
925
968
  });
926
969
  return new client_1.AgentInboxClient(transport);
927
970
  }
928
- async function printAgentList(client) {
929
- const records = await listAgentsWithTargets(client);
930
- console.log((0, util_1.jsonResponse)((0, current_agent_1.annotateAgents)(records, tryDetectTerminalContext())));
971
+ async function printAgentList(client, limit) {
972
+ const records = await listAgentsWithTargets(client, limit);
973
+ console.log((0, util_1.jsonResponse)((0, current_agent_1.annotateAgents)(records, tryDetectCurrentAgentContext())));
931
974
  }
932
975
  async function printCurrentAgent(client) {
933
- const context = getRequiredTerminalContext();
976
+ const context = getRequiredCurrentAgentContext();
934
977
  const records = await listAgentsWithTargets(client);
935
978
  const current = (0, current_agent_1.resolveCurrentAgent)(records, context);
936
979
  if (!current) {
@@ -940,7 +983,7 @@ async function printCurrentAgent(client) {
940
983
  }
941
984
  async function selectAgentForCommand(client, options) {
942
985
  const records = await listAgentsWithTargets(client);
943
- const context = tryDetectTerminalContext();
986
+ const context = tryDetectCurrentAgentContext();
944
987
  if (options.explicitAgentId) {
945
988
  const current = context ? (0, current_agent_1.resolveCurrentAgent)(records, context) : null;
946
989
  const requested = records.find((entry) => entry.agent.agentId === options.explicitAgentId);
@@ -960,7 +1003,7 @@ async function selectAgentForCommand(client, options) {
960
1003
  warnings,
961
1004
  };
962
1005
  }
963
- const contextForCurrent = getRequiredTerminalContext();
1006
+ const contextForCurrent = getRequiredCurrentAgentContext();
964
1007
  const current = (0, current_agent_1.resolveCurrentAgent)(records, contextForCurrent);
965
1008
  if (current) {
966
1009
  return {
@@ -972,17 +1015,7 @@ async function selectAgentForCommand(client, options) {
972
1015
  if (!options.autoRegister) {
973
1016
  throw new Error(noCurrentAgentMessage());
974
1017
  }
975
- await requestRemote(client, "/agents", {
976
- backend: contextForCurrent.backend,
977
- runtimeKind: contextForCurrent.runtimeKind,
978
- runtimeSessionId: contextForCurrent.runtimeSessionId ?? undefined,
979
- runtimePid: contextForCurrent.runtimePid ?? undefined,
980
- tmuxPaneId: contextForCurrent.tmuxPaneId ?? undefined,
981
- tty: contextForCurrent.tty ?? undefined,
982
- termProgram: contextForCurrent.termProgram ?? undefined,
983
- itermSessionId: contextForCurrent.itermSessionId ?? undefined,
984
- notifyLeaseMs: undefined,
985
- });
1018
+ await requestRemote(client, "/agents", registrationInputForCurrentContext(contextForCurrent));
986
1019
  const refreshed = await listAgentsWithTargets(client);
987
1020
  const registered = (0, current_agent_1.resolveCurrentAgent)(refreshed, contextForCurrent);
988
1021
  if (!registered) {
@@ -994,8 +1027,38 @@ async function selectAgentForCommand(client, options) {
994
1027
  warnings: [],
995
1028
  };
996
1029
  }
997
- async function listAgentsWithTargets(client) {
998
- const response = await requestRemote(client, "/agents?include_targets=true", undefined, "GET");
1030
+ function registrationInputForCurrentContext(context) {
1031
+ if ((0, current_agent_1.isHolonRuntimeContext)(context)) {
1032
+ if (!context.externalTriggerUrl) {
1033
+ throw new Error("unable to auto-register current Holon agent: HOLON_EXTERNAL_TRIGGER_URL is not set");
1034
+ }
1035
+ return {
1036
+ agentId: context.agentId,
1037
+ runtimeKind: context.runtimeKind,
1038
+ webhook: {
1039
+ url: context.externalTriggerUrl,
1040
+ notifyLeaseMs: undefined,
1041
+ },
1042
+ };
1043
+ }
1044
+ return {
1045
+ backend: context.backend,
1046
+ runtimeKind: context.runtimeKind,
1047
+ runtimeSessionId: context.runtimeSessionId ?? undefined,
1048
+ runtimePid: context.runtimePid ?? undefined,
1049
+ tmuxPaneId: context.tmuxPaneId ?? undefined,
1050
+ tty: context.tty ?? undefined,
1051
+ termProgram: context.termProgram ?? undefined,
1052
+ itermSessionId: context.itermSessionId ?? undefined,
1053
+ notifyLeaseMs: undefined,
1054
+ };
1055
+ }
1056
+ async function listAgentsWithTargets(client, limit) {
1057
+ const query = buildQuery({
1058
+ include_targets: "true",
1059
+ limit,
1060
+ });
1061
+ const response = await requestRemote(client, `/agents${query}`, undefined, "GET");
999
1062
  return response.data.agents;
1000
1063
  }
1001
1064
  async function printRemote(client, endpoint, body, method = "POST") {
@@ -1005,13 +1068,38 @@ async function printRemote(client, endpoint, body, method = "POST") {
1005
1068
  async function requestRemote(client, endpoint, body, method = "POST") {
1006
1069
  const response = await client.request(endpoint, body, method);
1007
1070
  if (response.statusCode < 200 || response.statusCode >= 300) {
1008
- throw new Error((0, util_1.jsonResponse)(response.data));
1071
+ const bodyText = (0, util_1.jsonResponse)(response.data);
1072
+ throw new Error(`request ${method} ${endpoint} failed with HTTP ${response.statusCode}: ${bodyText}`);
1009
1073
  }
1010
1074
  return { data: response.data };
1011
1075
  }
1012
1076
  function noCurrentAgentMessage() {
1013
1077
  return "no current agent is registered for this terminal/runtime context; run `agentinbox agent list` to inspect offline agents, then `agentinbox agent register` or `agentinbox agent register --force-rebind --agent-id <agentId>` to rebind one";
1014
1078
  }
1079
+ function clientArgsForCommand(args) {
1080
+ if (isAgentTargetAddWebhookCommand(args)) {
1081
+ return withoutFlagValues(args, "--url");
1082
+ }
1083
+ return args;
1084
+ }
1085
+ function isAgentTargetAddWebhookCommand(args) {
1086
+ return args[0] === "agent" && args[1] === "target" && args[2] === "add" && args[3] === "webhook";
1087
+ }
1088
+ function withoutFlagValues(args, flag) {
1089
+ const filtered = [];
1090
+ for (let index = 0; index < args.length; index += 1) {
1091
+ const value = args[index];
1092
+ if (value !== flag) {
1093
+ filtered.push(value);
1094
+ continue;
1095
+ }
1096
+ const nextIndex = index + 1;
1097
+ if (nextIndex < args.length && !args[nextIndex].startsWith("--")) {
1098
+ index = nextIndex;
1099
+ }
1100
+ }
1101
+ return filtered;
1102
+ }
1015
1103
  function takeFlagValue(args, flag) {
1016
1104
  const index = args.indexOf(flag);
1017
1105
  if (index === -1) {
@@ -1102,6 +1190,17 @@ function buildQuery(params) {
1102
1190
  const query = search.toString();
1103
1191
  return query ? `?${query}` : "";
1104
1192
  }
1193
+ function parseOptionalLimitArg(args) {
1194
+ const raw = takeFlagValue(args, "--limit");
1195
+ if (raw === undefined) {
1196
+ return undefined;
1197
+ }
1198
+ const parsed = Number.parseInt(raw, 10);
1199
+ if (!Number.isFinite(parsed) || parsed < 1 || String(parsed) !== raw) {
1200
+ throw new Error("`--limit` must be a positive integer");
1201
+ }
1202
+ return String(parsed);
1203
+ }
1105
1204
  function readSubscriptionFilter(args) {
1106
1205
  const filterJson = takeFlagValue(args, "--filter-json");
1107
1206
  const filterFile = takeFlagValue(args, "--filter-file");
@@ -1193,7 +1292,14 @@ function normalizeSubscriptionAddOutput(data, shortcutUsed) {
1193
1292
  }
1194
1293
  return data;
1195
1294
  }
1196
- function getRequiredTerminalContext() {
1295
+ function getRequiredCurrentAgentContext() {
1296
+ const holonContext = (0, current_agent_1.detectHolonRuntimeContext)(process.env);
1297
+ if (holonContext) {
1298
+ return holonContext;
1299
+ }
1300
+ if ((0, current_agent_1.isHolonRuntimeEnv)(process.env)) {
1301
+ throw new Error("unable to detect current Holon agent: HOLON_AGENT_ID is not set");
1302
+ }
1197
1303
  try {
1198
1304
  return (0, terminal_1.detectTerminalContext)(process.env);
1199
1305
  }
@@ -1202,7 +1308,11 @@ function getRequiredTerminalContext() {
1202
1308
  throw new Error(`unable to resolve current agent: ${message}`);
1203
1309
  }
1204
1310
  }
1205
- function tryDetectTerminalContext() {
1311
+ function tryDetectCurrentAgentContext() {
1312
+ const holonContext = (0, current_agent_1.detectHolonRuntimeContext)(process.env);
1313
+ if (holonContext || (0, current_agent_1.isHolonRuntimeEnv)(process.env)) {
1314
+ return holonContext;
1315
+ }
1206
1316
  try {
1207
1317
  return (0, terminal_1.detectTerminalContext)(process.env);
1208
1318
  }
@@ -1277,7 +1387,7 @@ Usage:
1277
1387
 
1278
1388
  Usage:
1279
1389
  agentinbox host add <hostType> <hostKey> [--config-json JSON] [--config-ref REF]
1280
- agentinbox host list
1390
+ agentinbox host list [--limit N]
1281
1391
  agentinbox host show <hostId>
1282
1392
  agentinbox host schema <hostId>
1283
1393
  `,
@@ -1285,7 +1395,7 @@ Usage:
1285
1395
 
1286
1396
  Usage:
1287
1397
  agentinbox stream add <hostId> <streamKind> <streamKey> [--config-json JSON] [--config-ref REF]
1288
- agentinbox stream list
1398
+ agentinbox stream list [--limit N]
1289
1399
  agentinbox stream show <streamId>
1290
1400
  agentinbox stream update <streamId> [--config-json JSON] [--config-ref REF | --clear-config-ref]
1291
1401
  agentinbox stream remove <streamId> [--with-subscriptions]
@@ -1300,12 +1410,17 @@ Usage:
1300
1410
 
1301
1411
  Usage:
1302
1412
  agentinbox follow <providerOrKind> <template> [--agent-id ID] [--args-json JSON | --arg KEY=VALUE ...] [--config-json JSON] [--config-ref REF] [--start-policy POLICY] [--start-offset N] [--start-time ISO8601]
1413
+
1414
+ Examples:
1415
+ agentinbox follow github repo --agent-id <agentId> --arg owner=holon-run --arg repo=agentinbox
1416
+ agentinbox follow github pr --agent-id <agentId> --arg owner=holon-run --arg repo=agentinbox --arg number=87 --arg withCi=true
1417
+ agentinbox follow github issue --agent-id <agentId> --arg owner=holon-run --arg repo=agentinbox --arg number=180
1303
1418
  `,
1304
1419
  source: `agentinbox source
1305
1420
 
1306
1421
  Usage:
1307
1422
  agentinbox source add <hostId> <streamKind> <streamKey> [--config-json JSON] [--config-ref REF]
1308
- agentinbox source list
1423
+ agentinbox source list [--limit N]
1309
1424
  agentinbox source show <sourceId>
1310
1425
  agentinbox source update <sourceId> [--config-json JSON] [--config-ref REF | --clear-config-ref]
1311
1426
  agentinbox source remove <sourceId> [--with-subscriptions]
@@ -1320,13 +1435,13 @@ Usage:
1320
1435
  Usage:
1321
1436
  agentinbox agent register [--agent-id ID] [--force-rebind] [--notify-lease-ms N] [--min-unacked-items N]
1322
1437
  agentinbox agent register --agent-id ID --webhook-url URL [--webhook-activation-mode MODE] [--webhook-notify-lease-ms N] [--webhook-min-unacked-items N]
1323
- agentinbox agent list
1438
+ agentinbox agent list [--limit N]
1324
1439
  agentinbox agent current
1325
1440
  agentinbox agent show <agentId>
1326
1441
  agentinbox agent remove <agentId>
1327
1442
  agentinbox agent resume <agentId>
1328
1443
  agentinbox agent target add webhook <agentId> --url URL [--activation-mode MODE] [--notify-lease-ms N] [--min-unacked-items N]
1329
- agentinbox agent target list <agentId>
1444
+ agentinbox agent target list <agentId> [--limit N]
1330
1445
  agentinbox agent target remove <agentId> <targetId>
1331
1446
  agentinbox agent target resume <agentId> <targetId>
1332
1447
  `,
@@ -1334,7 +1449,7 @@ Usage:
1334
1449
 
1335
1450
  Usage:
1336
1451
  agentinbox timer add --agent-id ID (--at ISO8601 | --every DURATION | --cron EXPR) --message TEXT [--timezone TZ] [--sender SENDER]
1337
- agentinbox timer list [--agent-id ID]
1452
+ agentinbox timer list [--agent-id ID] [--limit N]
1338
1453
  agentinbox timer pause <scheduleId>
1339
1454
  agentinbox timer resume <scheduleId>
1340
1455
  agentinbox timer remove <scheduleId>
@@ -1343,7 +1458,7 @@ Usage:
1343
1458
 
1344
1459
  Usage:
1345
1460
  agentinbox subscription add <sourceId> [--agent-id ID] [--shortcut NAME --shortcut-args-json JSON] [--filter-json JSON | --filter-file PATH | --filter-stdin] [--tracked-resource-ref REF] [--cleanup-policy-json JSON] [--start-policy POLICY] [--start-offset N] [--start-time ISO8601]
1346
- agentinbox subscription list [--source-id ID] [--agent-id ID]
1461
+ agentinbox subscription list [--source-id ID] [--agent-id ID] [--limit N]
1347
1462
  agentinbox subscription show <subscriptionId>
1348
1463
  agentinbox subscription remove <subscriptionId>
1349
1464
  agentinbox subscription poll <subscriptionId>
@@ -1353,9 +1468,9 @@ Usage:
1353
1468
  inbox: `agentinbox inbox
1354
1469
 
1355
1470
  Usage:
1356
- agentinbox inbox list
1471
+ agentinbox inbox list [--limit N]
1357
1472
  agentinbox inbox show <agentId>
1358
- agentinbox inbox read [--agent-id ID] [--after-entry ID] [--include-acked]
1473
+ agentinbox inbox read [--agent-id ID] [--after-entry ID] [--include-acked] [--limit N]
1359
1474
  agentinbox inbox send --agent-id ID --message TEXT [--sender SENDER]
1360
1475
  agentinbox inbox watch [--agent-id ID] [--after-entry ID] [--include-acked] [--heartbeat-ms N]
1361
1476
  agentinbox inbox ack [--agent-id ID] (--through <entryId> | --entry <entryId> | --all)
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.summarizeActivationTarget = summarizeActivationTarget;
4
+ exports.isHolonRuntimeEnv = isHolonRuntimeEnv;
5
+ exports.detectHolonRuntimeContext = detectHolonRuntimeContext;
4
6
  exports.resolveCurrentAgent = resolveCurrentAgent;
5
7
  exports.annotateAgents = annotateAgents;
8
+ exports.isHolonRuntimeContext = isHolonRuntimeContext;
6
9
  function summarizeActivationTarget(target) {
7
10
  if (target.kind === "terminal") {
8
11
  return {
@@ -25,6 +28,19 @@ function summarizeActivationTarget(target) {
25
28
  status: target.status,
26
29
  };
27
30
  }
31
+ function isHolonRuntimeEnv(env = process.env) {
32
+ return normalizeOptionalString(env.HOLON_RUNTIME) === "1";
33
+ }
34
+ function detectHolonRuntimeContext(env = process.env) {
35
+ if (!isHolonRuntimeEnv(env)) {
36
+ return null;
37
+ }
38
+ const agentId = normalizeOptionalString(env.HOLON_AGENT_ID);
39
+ if (!agentId) {
40
+ return null;
41
+ }
42
+ return { runtimeKind: "holon", agentId, externalTriggerUrl: normalizeOptionalString(env.HOLON_EXTERNAL_TRIGGER_URL) };
43
+ }
28
44
  function resolveCurrentAgent(agents, context) {
29
45
  if (!context) {
30
46
  return null;
@@ -62,6 +78,9 @@ function annotateAgents(agents, context) {
62
78
  };
63
79
  }
64
80
  function resolveAgentRecord(agents, context) {
81
+ if (isHolonRuntimeContext(context)) {
82
+ return agents.find((agent) => agent.agent.status === "active" && agent.agent.agentId === context.agentId) ?? null;
83
+ }
65
84
  if (context.tmuxPaneId) {
66
85
  const match = agents.find((agent) => terminalTargetsForCurrentMatch(agent).some((target) => target.backend === "tmux" && target.tmuxPaneId === context.tmuxPaneId));
67
86
  if (match) {
@@ -129,6 +148,9 @@ function terminalIdentityForAgent(agent) {
129
148
  return null;
130
149
  }
131
150
  function matchesCurrentTerminal(agent, context) {
151
+ if (isHolonRuntimeContext(context)) {
152
+ return false;
153
+ }
132
154
  return terminalTargetsForCurrentMatch(agent).some((target) => (context.tmuxPaneId != null && target.tmuxPaneId === context.tmuxPaneId)
133
155
  || (context.itermSessionId != null && target.itermSessionId === context.itermSessionId)
134
156
  || (context.tty != null && target.tty === context.tty));
@@ -137,9 +159,18 @@ function matchesCurrentRuntime(agent, context) {
137
159
  if (agent.agent.status !== "active") {
138
160
  return false;
139
161
  }
162
+ if (isHolonRuntimeContext(context)) {
163
+ return agent.agent.agentId === context.agentId;
164
+ }
140
165
  if (!context.runtimeSessionId) {
141
166
  return false;
142
167
  }
143
168
  return activeTerminalTargets(agent).some((target) => target.runtimeKind === context.runtimeKind && target.runtimeSessionId === context.runtimeSessionId) || (agent.agent.runtimeKind === context.runtimeKind
144
169
  && agent.agent.runtimeSessionId === context.runtimeSessionId);
145
170
  }
171
+ function isHolonRuntimeContext(context) {
172
+ return context.runtimeKind === "holon" && "agentId" in context;
173
+ }
174
+ function normalizeOptionalString(value) {
175
+ return value?.trim() || null;
176
+ }