@commonlyai/cli 0.1.412 → 0.1.413
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 +1 -1
- package/src/commands/agent.js +13 -11
- package/src/lib/turn-failure-notice.js +41 -3
package/package.json
CHANGED
package/src/commands/agent.js
CHANGED
|
@@ -182,13 +182,12 @@ import {
|
|
|
182
182
|
} from '../lib/content-refusal.js';
|
|
183
183
|
import {
|
|
184
184
|
CANT_ANSWER_NOTICE_WINDOW_MS,
|
|
185
|
-
CLAUDE_SIGNED_OUT_FIX,
|
|
186
185
|
CUT_OFF_NOTICE,
|
|
187
186
|
cantAnswerNotice,
|
|
188
187
|
cantAnswerNoticeDue,
|
|
189
188
|
newestMessageAt,
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
claudeSetupFault,
|
|
190
|
+
claudeSetupFaultResult,
|
|
192
191
|
spawnFailureReason,
|
|
193
192
|
} from '../lib/turn-failure-notice.js';
|
|
194
193
|
import { missingHarnessHint, reportMissingHarness } from '../lib/missing-harness.js';
|
|
@@ -4852,9 +4851,11 @@ export const performRun = ({
|
|
|
4852
4851
|
// F436: a signed-out Claude Code fails every turn the same way until
|
|
4853
4852
|
// someone signs in. Held, the event sat behind the 15-minute circuit;
|
|
4854
4853
|
// acked, the pod hears why now and the next event is the re-probe.
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4854
|
+
// F694: terms waiting to be accepted are the same kind of fault.
|
|
4855
|
+
const setupFault = claudeSetupFault(err);
|
|
4856
|
+
if (setupFault) {
|
|
4857
|
+
for (const entry of actionEntries) entry.result = claudeSetupFaultResult(setupFault);
|
|
4858
|
+
log(`[inbox.batch] ${setupFault.fix}`);
|
|
4858
4859
|
await noticeCantAnswer(err, actionEntries.map((entry) => entry.event));
|
|
4859
4860
|
return { entries };
|
|
4860
4861
|
}
|
|
@@ -5421,11 +5422,12 @@ export const performRun = ({
|
|
|
5421
5422
|
// pod to post into, and its sender's ask expires on its own.
|
|
5422
5423
|
result = contentRefusedResult();
|
|
5423
5424
|
log(`[${event.type}] the model provider refused the content of event ${event._id} (content_refused) — acked as refused, not retried`);
|
|
5424
|
-
} else if (
|
|
5425
|
-
// F436, as in the batch path. A pod-less or private item
|
|
5426
|
-
// pod to tell, so the log line is the whole notice.
|
|
5427
|
-
|
|
5428
|
-
|
|
5425
|
+
} else if (claudeSetupFault(err)) {
|
|
5426
|
+
// F436 and F694, as in the batch path. A pod-less or private item
|
|
5427
|
+
// has no pod to tell, so the log line is the whole notice.
|
|
5428
|
+
const setupFault = claudeSetupFault(err);
|
|
5429
|
+
result = claudeSetupFaultResult(setupFault);
|
|
5430
|
+
log(`[${event.type}] ${setupFault.fix}`);
|
|
5429
5431
|
} else {
|
|
5430
5432
|
// Do not record or ack: the kernel must retain the event for
|
|
5431
5433
|
// at-least-once delivery. Stop this fetched batch immediately —
|
|
@@ -92,6 +92,18 @@ const LOGIN_FAILED_WORDINGS = [
|
|
|
92
92
|
const CLAUDE_SIGNED_OUT_WORDINGS = [
|
|
93
93
|
/^claude exited(?: with code)? \d+: (?:[^\n]*? \| )?Not logged in · Please run \/login/,
|
|
94
94
|
];
|
|
95
|
+
// F694: what Claude Code prints at a -p start, and exits 1 on, while updated
|
|
96
|
+
// Consumer Terms wait to be accepted (2.1.337, read from the binary). Three
|
|
97
|
+
// wordings: run `claude` to review them, accept them on claude.ai (this one can
|
|
98
|
+
// name the signed-in account, so it is never quoted), and the dated 2025 one.
|
|
99
|
+
// The login works and nothing is spent: someone opens Claude Code there once and
|
|
100
|
+
// accepts. Anchored as the signed-out line, for the same reason.
|
|
101
|
+
const CLAUDE_TERMS_WORDINGS = [
|
|
102
|
+
// The line opens the message, a line of stderr, or the stdout tail after the
|
|
103
|
+
// ` | ` join, behind any number of stderr lines. Never mid-line: there it is
|
|
104
|
+
// quoted text, not Claude Code's own notice.
|
|
105
|
+
/^claude exited(?: with code)? \d+: (?:[\s\S]*?(?: \| |\n))?\[ACTION REQUIRED\] (?:We['’]ve updated our|An update to our) Consumer Terms and Privacy Policy\b/,
|
|
106
|
+
];
|
|
95
107
|
const WONT_START_WORDINGS = [
|
|
96
108
|
/^spawn \S+ ENOENT/,
|
|
97
109
|
// windows-command.js resolveLaunch: not on PATH, or a .cmd/.ps1 that only a
|
|
@@ -140,6 +152,12 @@ export const CLAUDE_SIGNED_OUT_NOTICE = 'I can’t answer right now: Claude Code
|
|
|
140
152
|
// What the seat's own log says, for whoever runs it.
|
|
141
153
|
export const CLAUDE_SIGNED_OUT_FIX = 'Claude Code is not signed in on this computer: open Claude Code here and sign in '
|
|
142
154
|
+ '(/login). The waiting message was acked, not held, so the next message starts a turn at once.';
|
|
155
|
+
export const CLAUDE_TERMS_NOTICE = 'I can’t answer right now: Claude Code on the computer I run on is waiting for '
|
|
156
|
+
+ 'someone to accept Anthropic’s updated terms. Whoever runs me needs to open Claude Code there once and accept them. '
|
|
157
|
+
+ AGAIN;
|
|
158
|
+
export const CLAUDE_TERMS_FIX = 'Claude Code is waiting for its updated Consumer Terms to be accepted on this computer: '
|
|
159
|
+
+ 'run `claude` here once and accept them, or accept them at https://claude.ai/settings/data-privacy-controls. '
|
|
160
|
+
+ 'The waiting message was acked, not held, so the next message starts a turn at once.';
|
|
143
161
|
export const WONT_START_NOTICE = 'I can’t answer right now: the tool I run on wouldn’t start on my computer. '
|
|
144
162
|
+ `Whoever runs me needs to fix that and start me again. ${AGAIN}`;
|
|
145
163
|
export const OUT_OF_ALLOWANCE_NOTICE = 'I can’t answer right now: the AI account I run on has used up its allowance. '
|
|
@@ -180,6 +198,7 @@ export const cantAnswerNotice = (error) => {
|
|
|
180
198
|
const text = String(error?.message ?? '').split(/(?:^|: | \| |\n)\{"type":/)[0];
|
|
181
199
|
// Before the general login line: this one names its own fix.
|
|
182
200
|
if (matches(CLAUDE_SIGNED_OUT_WORDINGS, text)) return { cause: 'claude-signed-out', text: CLAUDE_SIGNED_OUT_NOTICE };
|
|
201
|
+
if (matches(CLAUDE_TERMS_WORDINGS, text)) return { cause: 'claude-terms', text: CLAUDE_TERMS_NOTICE };
|
|
183
202
|
// Before the allowance check: a 401 is settled, whatever else its body says.
|
|
184
203
|
if (matches(LOGIN_FAILED_WORDINGS, text)) return { cause: 'login', text: LOGIN_NOTICE };
|
|
185
204
|
if (matches(WONT_START_WORDINGS, text)) return { cause: 'wont-start', text: WONT_START_NOTICE };
|
|
@@ -191,7 +210,9 @@ export const cantAnswerNotice = (error) => {
|
|
|
191
210
|
|
|
192
211
|
// F370 rough spot #11: Settings said "spawn failed" and nothing more; the cause
|
|
193
212
|
// was only in the seat's log. The runner reports one of these fixed codes with
|
|
194
|
-
// a failed outcome, never the error text. The server stores the code alone
|
|
213
|
+
// a failed outcome, never the error text. The server stores the code alone, and
|
|
214
|
+
// refuses the whole report when it doesn't know the code, so a new cause joins
|
|
215
|
+
// this list only once a server that takes it is live (claude-terms isn't yet).
|
|
195
216
|
export const SPAWN_FAILURE_REASONS = [
|
|
196
217
|
'claude-signed-out', 'login', 'wont-start', 'out-of-allowance', 'tools-unavailable', 'codex-version', 'model-unavailable',
|
|
197
218
|
];
|
|
@@ -218,9 +239,26 @@ export const isClaudeSignedOut = (error) => cantAnswerNotice(error)?.cause === '
|
|
|
218
239
|
|
|
219
240
|
/** The turn result a signed-out turn is acked with: a person's message is handed to another listener. */
|
|
220
241
|
export const CLAUDE_SIGNED_OUT_REASON = 'claude-signed-out';
|
|
221
|
-
|
|
242
|
+
const setupFaultResult = (reason) => ({
|
|
222
243
|
outcome: 'error',
|
|
223
244
|
refused: { reason: 'delivery-refused' },
|
|
224
|
-
reason
|
|
245
|
+
reason,
|
|
225
246
|
details: { failureClass: 'configuration' },
|
|
226
247
|
});
|
|
248
|
+
export const claudeSignedOutResult = () => setupFaultResult(CLAUDE_SIGNED_OUT_REASON);
|
|
249
|
+
|
|
250
|
+
// The Claude Code faults acked as F436 is: retrying can't clear one, someone at
|
|
251
|
+
// the computer can. Each carries the reason its ack names and its seat-log line.
|
|
252
|
+
const CLAUDE_SETUP_FAULTS = {
|
|
253
|
+
'claude-signed-out': CLAUDE_SIGNED_OUT_FIX,
|
|
254
|
+
'claude-terms': CLAUDE_TERMS_FIX,
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
/** The Claude Code setup fault behind a failed turn, as { reason, fix }, or null. */
|
|
258
|
+
export const claudeSetupFault = (error) => {
|
|
259
|
+
const cause = cantAnswerNotice(error)?.cause;
|
|
260
|
+
return Object.hasOwn(CLAUDE_SETUP_FAULTS, cause) ? { reason: cause, fix: CLAUDE_SETUP_FAULTS[cause] } : null;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
/** The turn result a setup-fault turn is acked with, as claudeSignedOutResult. */
|
|
264
|
+
export const claudeSetupFaultResult = (fault) => setupFaultResult(fault.reason);
|