@commonlyai/cli 0.1.330 → 0.1.332

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.330",
3
+ "version": "0.1.332",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The Commonly CLI — connect agents, manage pods, iterate fast",
6
6
  "type": "module",
@@ -145,7 +145,14 @@ import {
145
145
  refusedItemRef,
146
146
  sanitizeHandoffAgent,
147
147
  } from '../lib/content-refusal.js';
148
- import { CANT_ANSWER_NOTICE_WINDOW_MS, CUT_OFF_NOTICE, cantAnswerNotice } from '../lib/turn-failure-notice.js';
148
+ import {
149
+ CANT_ANSWER_NOTICE_WINDOW_MS,
150
+ CLAUDE_SIGNED_OUT_FIX,
151
+ CUT_OFF_NOTICE,
152
+ cantAnswerNotice,
153
+ claudeSignedOutResult,
154
+ isClaudeSignedOut,
155
+ } from '../lib/turn-failure-notice.js';
149
156
  import {
150
157
  ADDRESSED_EVENT_TYPES,
151
158
  isPersonMention,
@@ -906,7 +913,10 @@ const findOwnPost = (messages, earlierIds) => {
906
913
  // With `self`, only THIS agent's own post counts. Without it (an older
907
914
  // server), fall back to the legacy any-bot test — which drops this agent's
908
915
  // reply whenever another agent answers first (#757).
909
- if (!earlierIds.has(String(m._id || m.id)) && m.isBot && (serverKnowsSelf ? m.self === true : true)) {
916
+ // A system line is stored under the agent it is about; it is never this
917
+ // agent's post, even from a server that predates F434's `self` fix.
918
+ if (!earlierIds.has(String(m._id || m.id)) && m.isBot && m.messageType !== 'system'
919
+ && (serverKnowsSelf ? m.self === true : true)) {
910
920
  return {
911
921
  id: String(m._id || m.id),
912
922
  author: m.username || 'unknown',
@@ -4251,6 +4261,15 @@ export const performRun = ({
4251
4261
  }
4252
4262
  }
4253
4263
  } catch (err) {
4264
+ // F436: a signed-out Claude Code fails every turn the same way until
4265
+ // someone signs in. Held, the event sat behind the 15-minute circuit;
4266
+ // acked, the pod hears why now and the next event is the re-probe.
4267
+ if (isClaudeSignedOut(err)) {
4268
+ for (const entry of actionEntries) entry.result = claudeSignedOutResult();
4269
+ log(`[inbox.batch] ${CLAUDE_SIGNED_OUT_FIX}`);
4270
+ await noticeCantAnswer(err, actionEntries.map((entry) => entry.event));
4271
+ return { entries };
4272
+ }
4254
4273
  if (!isContentRefusal(err)) throw err;
4255
4274
  // Ambient text anyone wrote can draw the refusal, and no waking item
4256
4275
  // should pay for that. So the same items run once more with counts
@@ -4699,6 +4718,11 @@ export const performRun = ({
4699
4718
  // pod to post into, and its sender's ask expires on its own.
4700
4719
  result = contentRefusedResult();
4701
4720
  log(`[${event.type}] the model provider refused the content of event ${event._id} (content_refused) — acked as refused, not retried`);
4721
+ } else if (isClaudeSignedOut(err)) {
4722
+ // F436, as in the batch path. A pod-less or private item has no
4723
+ // pod to tell, so the log line is the whole notice.
4724
+ result = claudeSignedOutResult();
4725
+ log(`[${event.type}] ${CLAUDE_SIGNED_OUT_FIX}`);
4702
4726
  } else {
4703
4727
  // Do not record or ack: the kernel must retain the event for
4704
4728
  // at-least-once delivery. Stop this fetched batch immediately —
@@ -29,12 +29,22 @@ const LOGIN_FAILED_WORDINGS = [
29
29
  /\bupstream refused 401\b/, // the same refusal, read from pi's stream
30
30
  /^\w+ exited(?: with code)? \d+: 401\b/, // pi's text, which names no upstream
31
31
  /workspace routing discovery unauthorized/,
32
+ // Any other text carrying Claude Code's wording keeps this general line.
32
33
  /(?:^|: | \| )Not logged in · Please run \/login/,
33
34
  /API Error: 400 This API key is not scoped to a workspace/,
34
35
  // The wrapper's own refusals of a Claude login (adapters/claude.js).
35
36
  /the Claude login on this machine expires in/,
36
37
  /refusing a Claude login/,
37
38
  ];
39
+ // F436: what Claude Code prints, and exits 1 on, when it has no login on the
40
+ // computer (2.1.318, walked on windows-latest). No key is wrong and no allowance
41
+ // is spent: someone signs in to Claude Code there, and the next turn works.
42
+ // Anchored on the claude adapter's own exit line, first in its tail or after
43
+ // the stderr | stdout join, because this match acks the message unanswered:
44
+ // the same words from another adapter or a tool keep the general login line.
45
+ const CLAUDE_SIGNED_OUT_WORDINGS = [
46
+ /^claude exited(?: with code)? \d+: (?:[^\n]*? \| )?Not logged in · Please run \/login/,
47
+ ];
38
48
  const WONT_START_WORDINGS = [
39
49
  /^spawn \S+ ENOENT/,
40
50
  /^\w+ adapter: \S+ (?:is not set|is missing)/, // the seat has no provider key
@@ -75,6 +85,11 @@ const AGAIN = 'After that, send your message again if I still haven’t answered
75
85
 
76
86
  export const LOGIN_NOTICE = 'I can’t answer right now: the key or login on the computer I run on isn’t working. '
77
87
  + `Whoever runs me needs to fix it and start me again. ${AGAIN}`;
88
+ export const CLAUDE_SIGNED_OUT_NOTICE = 'I can’t answer right now: Claude Code isn’t signed in on the computer I run on. '
89
+ + `Whoever runs me needs to open Claude Code there and sign in. ${AGAIN}`;
90
+ // What the seat's own log says, for whoever runs it.
91
+ export const CLAUDE_SIGNED_OUT_FIX = 'Claude Code is not signed in on this computer: open Claude Code here and sign in '
92
+ + '(/login). The waiting message was acked, not held, so the next message starts a turn at once.';
78
93
  export const WONT_START_NOTICE = 'I can’t answer right now: the tool I run on wouldn’t start on my computer. '
79
94
  + `Whoever runs me needs to fix that and start me again. ${AGAIN}`;
80
95
  export const OUT_OF_ALLOWANCE_NOTICE = 'I can’t answer right now: the AI account I run on has used up its allowance. '
@@ -113,6 +128,8 @@ export const cantAnswerNotice = (error) => {
113
128
  // claudeFailureTail drops tool and assistant JSON. This cut is for what can
114
129
  // still arrive: a torn stream line, or an error event after stderr.
115
130
  const text = String(error?.message ?? '').split(/(?:^|: | \| |\n)\{"type":/)[0];
131
+ // Before the general login line: this one names its own fix.
132
+ if (matches(CLAUDE_SIGNED_OUT_WORDINGS, text)) return { cause: 'claude-signed-out', text: CLAUDE_SIGNED_OUT_NOTICE };
116
133
  // Before the allowance check: a 401 is settled, whatever else its body says.
117
134
  if (matches(LOGIN_FAILED_WORDINGS, text)) return { cause: 'login', text: LOGIN_NOTICE };
118
135
  if (matches(WONT_START_WORDINGS, text)) return { cause: 'wont-start', text: WONT_START_NOTICE };
@@ -121,3 +138,21 @@ export const cantAnswerNotice = (error) => {
121
138
  }
122
139
  return null;
123
140
  };
141
+
142
+ /**
143
+ * A turn that failed because Claude Code is signed out on this computer (F436).
144
+ * It is a setup fault, not an outage: retrying cannot fix it, and holding the
145
+ * event behind the 15-minute circuit kept the person waiting with no answer.
146
+ * The run loop acks it instead and posts CLAUDE_SIGNED_OUT_NOTICE, and the
147
+ * next event spawns at once, which is the re-probe.
148
+ */
149
+ export const isClaudeSignedOut = (error) => cantAnswerNotice(error)?.cause === 'claude-signed-out';
150
+
151
+ /** The turn result a signed-out turn is acked with: a person's message is handed to another listener. */
152
+ export const CLAUDE_SIGNED_OUT_REASON = 'claude-signed-out';
153
+ export const claudeSignedOutResult = () => ({
154
+ outcome: 'error',
155
+ refused: { reason: 'delivery-refused' },
156
+ reason: CLAUDE_SIGNED_OUT_REASON,
157
+ details: { failureClass: 'configuration' },
158
+ });