@commonlyai/cli 0.1.362 → 0.1.363

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commonlyai/cli",
3
- "version": "0.1.362",
3
+ "version": "0.1.363",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The Commonly CLI — connect agents, manage pods, iterate fast",
6
6
  "type": "module",
@@ -1022,6 +1022,13 @@ const PAST_CAP_MAX_CARRIES = 5;
1022
1022
  // is unchanged, and the can't-answer limit (once per cause per pod per hour)
1023
1023
  // still decides who hears it.
1024
1024
  const CIRCUIT_NOTICE_CHECK_MS = 60 * 1000;
1025
+ // F237: failed turns in a row after which a full carry stops claiming new rows.
1026
+ // One failure keeps the claim, so a person's new message still joins the retry
1027
+ // ahead of carried agent rows; past it the outage looks real, and every row
1028
+ // claimed then rides the carry past the prompt cap, is released after
1029
+ // PAST_CAP_MAX_CARRIES failed turns and claimed again, an attempt each time,
1030
+ // until the requeue cap retires it without its ever being tried.
1031
+ const FULL_CARRY_CLAIM_FAILURES = 2;
1025
1032
 
1026
1033
  // Who gets a slot when a batch is past the cap. 'unknown' counts as a person:
1027
1034
  // only a row the snapshot and the kernel's stamp both can't place reads so, and
@@ -3861,6 +3868,25 @@ export const performRun = ({
3861
3868
  confirmed === null || !deliveryIdOf(event) || confirmed.has(String(event._id))
3862
3869
  );
3863
3870
 
3871
+ // What an inbox read asks for. A carry that fills the prompt during an
3872
+ // outage names its rows (`onlyIds`), and a current server returns only those
3873
+ // it requeued, with their live delivery ids, and claims nothing new (F237).
3874
+ // `limit` keeps today's value, so a server that predates onlyIds claims as
3875
+ // before. `inOutage`: the circuit-wait check, which runs only while the
3876
+ // circuit is open.
3877
+ const inboxQuery = ({ inOutage = false } = {}) => {
3878
+ const carried = [...heldRetry, ...heldGreeting];
3879
+ const carriedCount = carried.filter((event) => event.deliveryMode !== 'digest').length;
3880
+ const full = carriedCount >= batchLimit
3881
+ && (inOutage || consecutiveSpawnFailures >= FULL_CARRY_CLAIM_FAILURES);
3882
+ return {
3883
+ agentName,
3884
+ instanceId,
3885
+ limit: Math.max(1, batchLimit - carriedCount),
3886
+ ...(full ? { onlyIds: [...new Set(carried.map((event) => String(event._id)))].join(',') } : {}),
3887
+ ...(adapter?.name ? { reportedCli: adapter.name } : {}),
3888
+ };
3889
+ };
3864
3890
  // Decide what a failed turn's retry carries. `failedEvents` were attempted
3865
3891
  // and count toward HELD_RETRY_MAX_FAILURES; `untriedEvents` are later groups
3866
3892
  // from the same page that the failure stopped before they ran (#782), and
@@ -4533,12 +4559,8 @@ export const performRun = ({
4533
4559
  // #3511). The overflow pass below stays as the backstop.
4534
4560
  // Only wake events count: the server's page cap is on wakes, and a
4535
4561
  // carried digest row takes no body (CodeRabbit on #3511).
4536
- const carriedCount = [...heldRetry, ...heldGreeting]
4537
- .filter((event) => event.deliveryMode !== 'digest').length;
4538
- const page = await client.get('/api/agents/runtime/events', {
4539
- agentName, instanceId, limit: Math.max(1, batchLimit - carriedCount),
4540
- ...(adapter?.name ? { reportedCli: adapter.name } : {}),
4541
- });
4562
+ // F237: a full carry in an outage claims nothing new (inboxQuery).
4563
+ const page = await client.get('/api/agents/runtime/events', inboxQuery());
4542
4564
  pollLiveness.arm();
4543
4565
  // A stall fired while this request hung: the loop has already given up on
4544
4566
  // it, and `agent run` exits in onStall, so its page is left to the requeue.
@@ -4990,12 +5012,9 @@ export const performRun = ({
4990
5012
  const wait = circuitNotice;
4991
5013
  try {
4992
5014
  pollLiveness.arm();
4993
- const carriedCount = [...heldRetry, ...heldGreeting]
4994
- .filter((event) => event.deliveryMode !== 'digest').length;
4995
- const page = await client.get('/api/agents/runtime/events', {
4996
- agentName, instanceId, limit: Math.max(1, batchLimit - carriedCount),
4997
- ...(adapter?.name ? { reportedCli: adapter.name } : {}),
4998
- });
5015
+ // A full carry here claims nothing new (F237): a pod whose first message
5016
+ // arrives then is told once the carry has room, not by this check.
5017
+ const page = await client.get('/api/agents/runtime/events', inboxQuery({ inOutage: true }));
4999
5018
  pollLiveness.arm();
5000
5019
  if (pollStalled) return;
5001
5020
  const fetched = page?.events || [];