@commonlyai/cli 0.1.411 → 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
CHANGED
package/src/commands/agent.js
CHANGED
|
@@ -53,6 +53,7 @@ import {
|
|
|
53
53
|
wasEventHandled,
|
|
54
54
|
recordHandledEvent,
|
|
55
55
|
noticeDue,
|
|
56
|
+
noticeRecordedAt,
|
|
56
57
|
recordNotice,
|
|
57
58
|
} from '../lib/session-store.js';
|
|
58
59
|
import {
|
|
@@ -181,11 +182,12 @@ import {
|
|
|
181
182
|
} from '../lib/content-refusal.js';
|
|
182
183
|
import {
|
|
183
184
|
CANT_ANSWER_NOTICE_WINDOW_MS,
|
|
184
|
-
CLAUDE_SIGNED_OUT_FIX,
|
|
185
185
|
CUT_OFF_NOTICE,
|
|
186
186
|
cantAnswerNotice,
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
cantAnswerNoticeDue,
|
|
188
|
+
newestMessageAt,
|
|
189
|
+
claudeSetupFault,
|
|
190
|
+
claudeSetupFaultResult,
|
|
189
191
|
spawnFailureReason,
|
|
190
192
|
} from '../lib/turn-failure-notice.js';
|
|
191
193
|
import { missingHarnessHint, reportMissingHarness } from '../lib/missing-harness.js';
|
|
@@ -3075,23 +3077,34 @@ export const performRun = ({
|
|
|
3075
3077
|
|
|
3076
3078
|
// A failure only a person can fix, or only time can, leaves a mention
|
|
3077
3079
|
// unanswered for as long as it lasts, so each pod with someone waiting is told
|
|
3078
|
-
// why,
|
|
3079
|
-
//
|
|
3080
|
-
//
|
|
3081
|
-
//
|
|
3082
|
-
//
|
|
3080
|
+
// why, once per cause per pod per hour (persisted, so a restart does not
|
|
3081
|
+
// re-post), and again when a person writes after the last line (F689: one
|
|
3082
|
+
// "retry" met with silence was the end of a first try). A later pod the
|
|
3083
|
+
// failed turn stopped before reaching is told too: a key or an allowance
|
|
3084
|
+
// fails every pod alike, and its own turn could be 45 minutes away. A notice
|
|
3085
|
+
// that fails to post is logged and tried at the next failure; the retry goes
|
|
3086
|
+
// ahead either way.
|
|
3083
3087
|
const noticeCantAnswer = async (error, waitingEvents) => {
|
|
3084
3088
|
const notice = cantAnswerNotice(error);
|
|
3085
3089
|
if (!notice || modelUnavailableFailure(error)) return;
|
|
3086
|
-
const
|
|
3087
|
-
|
|
3090
|
+
const waiting = waitingEvents.filter(someoneIsWaiting);
|
|
3091
|
+
const waitingPods = new Set(waiting
|
|
3088
3092
|
.map((event) => event.podId || podId)
|
|
3089
3093
|
.filter(Boolean));
|
|
3090
3094
|
for (const waitingPod of waitingPods) {
|
|
3091
3095
|
const key = `cant-answer:${notice.cause}:${waitingPod}`;
|
|
3096
|
+
const seenKey = `${key}:seen`;
|
|
3097
|
+
const inPod = waiting.filter((event) => (event.podId || podId) === waitingPod);
|
|
3092
3098
|
try {
|
|
3099
|
+
// Only an agent's or the kernel's own event is left out of the repeat:
|
|
3100
|
+
// an author the seat can't place may be a person (F689).
|
|
3101
|
+
const due = cantAnswerNoticeDue({
|
|
3102
|
+
lastNoticeAt: noticeRecordedAt(stateKey, key),
|
|
3103
|
+
seenThrough: noticeRecordedAt(stateKey, seenKey),
|
|
3104
|
+
waiting: inPod.filter((event) => !['agent', 'kernel'].includes(classifyTrigger(event))),
|
|
3105
|
+
});
|
|
3093
3106
|
// eslint-disable-next-line no-continue
|
|
3094
|
-
if (!
|
|
3107
|
+
if (!due) continue;
|
|
3095
3108
|
// eslint-disable-next-line no-await-in-loop
|
|
3096
3109
|
const delivery = await deliverChatReply({
|
|
3097
3110
|
client,
|
|
@@ -3107,6 +3120,10 @@ export const performRun = ({
|
|
|
3107
3120
|
+ `${delivery.reason || 'the notice was not posted'}`);
|
|
3108
3121
|
} else {
|
|
3109
3122
|
recordNotice(stateKey, key);
|
|
3123
|
+
// The newest message this line was posted over, on the server's
|
|
3124
|
+
// clock, so the next "is anything new" never mixes the two clocks.
|
|
3125
|
+
const seenThrough = Math.max(...inPod.map(newestMessageAt).filter(Number.isFinite));
|
|
3126
|
+
if (Number.isFinite(seenThrough)) recordNotice(stateKey, seenKey, seenThrough);
|
|
3110
3127
|
log(`[inbox.batch] told pod ${waitingPod} why this agent can't answer (${notice.cause})`);
|
|
3111
3128
|
}
|
|
3112
3129
|
} catch (noticeError) {
|
|
@@ -3884,7 +3901,7 @@ export const performRun = ({
|
|
|
3884
3901
|
// log and the event ack; the kernel records the class.
|
|
3885
3902
|
if (!delivered && upstream) {
|
|
3886
3903
|
// pi exits 0 on a refused route, so no failure reaches the retry path.
|
|
3887
|
-
await noticeCantAnswer(new Error(describeUpstreamRefusal(upstream)), [event]);
|
|
3904
|
+
await noticeCantAnswer(new Error(describeUpstreamRefusal(upstream)), event.turnEvents || [event]);
|
|
3888
3905
|
return {
|
|
3889
3906
|
outcome: 'no_action',
|
|
3890
3907
|
refused: {
|
|
@@ -4752,6 +4769,9 @@ export const performRun = ({
|
|
|
4752
4769
|
_id: `batch-${actionEntries[0].event._id}`,
|
|
4753
4770
|
type: 'inbox.batch',
|
|
4754
4771
|
commentTarget: commentTargetOf(actionEntries[0].event),
|
|
4772
|
+
// The events this turn carries, for a line that must judge each one: the
|
|
4773
|
+
// batch row borrows its first item's time (F689).
|
|
4774
|
+
turnEvents: entries.filter(inThisTurn).map((entry) => entry.event),
|
|
4755
4775
|
payload: {
|
|
4756
4776
|
...actionEntries[0].event.payload,
|
|
4757
4777
|
batchEventIds: entries.filter(inThisTurn).map((entry) => String(entry.event._id)),
|
|
@@ -4831,9 +4851,11 @@ export const performRun = ({
|
|
|
4831
4851
|
// F436: a signed-out Claude Code fails every turn the same way until
|
|
4832
4852
|
// someone signs in. Held, the event sat behind the 15-minute circuit;
|
|
4833
4853
|
// acked, the pod hears why now and the next event is the re-probe.
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
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}`);
|
|
4837
4859
|
await noticeCantAnswer(err, actionEntries.map((entry) => entry.event));
|
|
4838
4860
|
return { entries };
|
|
4839
4861
|
}
|
|
@@ -5400,11 +5422,12 @@ export const performRun = ({
|
|
|
5400
5422
|
// pod to post into, and its sender's ask expires on its own.
|
|
5401
5423
|
result = contentRefusedResult();
|
|
5402
5424
|
log(`[${event.type}] the model provider refused the content of event ${event._id} (content_refused) — acked as refused, not retried`);
|
|
5403
|
-
} else if (
|
|
5404
|
-
// F436, as in the batch path. A pod-less or private item
|
|
5405
|
-
// pod to tell, so the log line is the whole notice.
|
|
5406
|
-
|
|
5407
|
-
|
|
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}`);
|
|
5408
5431
|
} else {
|
|
5409
5432
|
// Do not record or ack: the kernel must retain the event for
|
|
5410
5433
|
// at-least-once delivery. Stop this fetched batch immediately —
|
|
@@ -6425,12 +6448,17 @@ Docs:
|
|
|
6425
6448
|
// (and reported a missing one); it stops on a signed-out one too, and the
|
|
6426
6449
|
// instance hears why, so the page and the pod can say it. A seat with a
|
|
6427
6450
|
// saved record only warns: a probe that reads it wrong must not stop it.
|
|
6451
|
+
// F689: a first run also stops on a harness below the version its turns
|
|
6452
|
+
// need, which it used to start, then refuse every turn. A saved seat's
|
|
6453
|
+
// adapter warns at start instead, and its turns say so in the pod.
|
|
6428
6454
|
const harnessProblems = await harnessFindings({
|
|
6429
6455
|
adapterName: record.adapter,
|
|
6430
6456
|
adapter: getAdapter(record.adapter),
|
|
6431
6457
|
environment: record.environment,
|
|
6432
6458
|
agentName: record.agentName,
|
|
6433
6459
|
checkInstalled: !bootstrapped,
|
|
6460
|
+
checkVersion: bootstrapped,
|
|
6461
|
+
unconfined: opts.unsandboxed === true,
|
|
6434
6462
|
});
|
|
6435
6463
|
const harnessOutcome = preflightOutcome(harnessProblems, { firstRun: bootstrapped });
|
|
6436
6464
|
for (const line of harnessOutcome.lines) console.error(`${stamp()} [${name}] ${line}`);
|
|
@@ -99,7 +99,7 @@ import {
|
|
|
99
99
|
} from '../sandbox/guest-home.js';
|
|
100
100
|
import {
|
|
101
101
|
GUEST_CODEX, GUEST_HOME, GUEST_PATH, GUEST_WORKSPACE, buildMicrovmRunArgs, checkMicrovmAttach,
|
|
102
|
-
ensureNoSeatVm, guestProxyBaseUrl, microvmSeatHome, microvmSeatLabel, msbHostEnv, prepareMicrovmHost,
|
|
102
|
+
ensureNoSeatVm, guestProxyBaseUrl, microvmFlagOn, microvmSeatHome, microvmSeatLabel, msbHostEnv, prepareMicrovmHost,
|
|
103
103
|
refuseMicrovmMcpDeclarations,
|
|
104
104
|
probeWhp, startMicrovmTurn, stopOrphanSeatMsb, withSeatLock, writeMicrovmTurn,
|
|
105
105
|
} from '../sandbox/microsandbox.js';
|
|
@@ -2090,6 +2090,28 @@ export default {
|
|
|
2090
2090
|
// exactly as spawn does. A Codex that can't be launched gives no notice here;
|
|
2091
2091
|
// the run's detect() has already refused that. The probe is cached, so the
|
|
2092
2092
|
// first turn doesn't ask again. `opts` carries spawn's version test seams.
|
|
2093
|
+
// F689: the version a first run's preflight stops on: one it read, below the
|
|
2094
|
+
// floor, for a seat the turn would refuse. Null for a tested version, for no
|
|
2095
|
+
// Codex at all (detect() refuses that run), and for a version it couldn't
|
|
2096
|
+
// read, which is left to the turn: a Codex that prints its version some new
|
|
2097
|
+
// way must not stop every first run before it starts. A Windows computer with
|
|
2098
|
+
// the microVM on runs a public seat on the guest's own Codex, and the first
|
|
2099
|
+
// run doesn't know yet whether its pod is public, so it isn't floored there.
|
|
2100
|
+
async versionShortfall({
|
|
2101
|
+
env = process.env, unconfined = false, platform = process.platform, ...opts
|
|
2102
|
+
} = {}) {
|
|
2103
|
+
if (unconfined || codexTrustedPerimeter(env)) return null;
|
|
2104
|
+
if (platform === 'win32' && microvmFlagOn(env)) return null;
|
|
2105
|
+
let version;
|
|
2106
|
+
try {
|
|
2107
|
+
version = await readCodexVersion(opts, env);
|
|
2108
|
+
} catch {
|
|
2109
|
+
return null;
|
|
2110
|
+
}
|
|
2111
|
+
if (!version || meetsMinimumVersion(version, PUBLIC_CODEX_MIN_VERSION)) return null;
|
|
2112
|
+
return { found: version, required: PUBLIC_CODEX_MIN_VERSION };
|
|
2113
|
+
},
|
|
2114
|
+
|
|
2093
2115
|
async startNotice({ env = process.env, unconfined = false, ...opts } = {}) {
|
|
2094
2116
|
if (unconfined || codexTrustedPerimeter(env)) return null;
|
|
2095
2117
|
let version;
|
|
@@ -17,6 +17,9 @@ export const missingHarnessHint = (name) => {
|
|
|
17
17
|
return `Install ${known.label} (${known.command}), sign in once by running ${known.signIn}, then run this line again.`;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
/** The install command, which also updates an installed harness; null when we have none. */
|
|
21
|
+
export const harnessUpdateCommand = (name) => INSTALL[name]?.command || null;
|
|
22
|
+
|
|
20
23
|
/**
|
|
21
24
|
* Tell the instance what this run looked for (a harness id, or null for none
|
|
22
25
|
* of the ones it probes). Best effort: an older instance without the route, or
|
package/src/lib/run-preflight.js
CHANGED
|
@@ -14,14 +14,14 @@ import { readFileSync } from 'fs';
|
|
|
14
14
|
|
|
15
15
|
import { checkNode, FAIL } from './doctor.js';
|
|
16
16
|
import { loginState } from './adapter-login.js';
|
|
17
|
-
import { missingHarnessHint } from './missing-harness.js';
|
|
17
|
+
import { harnessUpdateCommand, missingHarnessHint } from './missing-harness.js';
|
|
18
18
|
import { claudeLoginProbeLaunch, withClaudePath } from './adapters/claude.js';
|
|
19
19
|
import { resolveWindowsCommandWithReason } from './windows-command.js';
|
|
20
20
|
|
|
21
21
|
// The reason codes the instance accepts (POST /api/agents/runtime/listen-blocked).
|
|
22
22
|
// A code, never text: nothing from this computer but the code is sent.
|
|
23
23
|
export const LISTEN_BLOCKED_REASONS = [
|
|
24
|
-
'node-too-old', 'harness-signed-out', 'sandbox-unavailable', 'unsandboxed-refused',
|
|
24
|
+
'node-too-old', 'harness-signed-out', 'sandbox-unavailable', 'unsandboxed-refused', 'harness-too-old',
|
|
25
25
|
];
|
|
26
26
|
|
|
27
27
|
// F571: the two sandbox stops `agent run` makes once it has read the record,
|
|
@@ -119,11 +119,17 @@ export const runHarnessLoginStatus = async (name, args, {
|
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
|
-
* The harness findings for one adapter: not installed,
|
|
123
|
-
* signed in. `checkInstalled` is false where
|
|
124
|
-
* first run's bootstrap does, and reports it
|
|
125
|
-
*
|
|
126
|
-
* environment is skipped by loginState itself.
|
|
122
|
+
* The harness findings for one adapter: not installed, below the version its
|
|
123
|
+
* turns need, or installed and not signed in. `checkInstalled` is false where
|
|
124
|
+
* the caller has already looked (a first run's bootstrap does, and reports it
|
|
125
|
+
* on its own route). A seat that runs on its own provider block needs no
|
|
126
|
+
* harness login, and a key in the environment is skipped by loginState itself.
|
|
127
|
+
*
|
|
128
|
+
* F689: a version floor binds every seat the turn would refuse, provider block
|
|
129
|
+
* or not, so it is read first. `unconfined` is a run typed --unsandboxed, which
|
|
130
|
+
* the adapter may not floor; it decides, and a probe that throws is no verdict.
|
|
131
|
+
* `checkVersion` is false for a seat with a saved record, whose adapter already
|
|
132
|
+
* warns at start (startNotice), so the warning isn't printed twice.
|
|
127
133
|
*/
|
|
128
134
|
export const harnessFindings = async ({
|
|
129
135
|
adapterName,
|
|
@@ -133,6 +139,8 @@ export const harnessFindings = async ({
|
|
|
133
139
|
agentName = null,
|
|
134
140
|
checkInstalled = true,
|
|
135
141
|
env = process.env,
|
|
142
|
+
unconfined = false,
|
|
143
|
+
checkVersion = true,
|
|
136
144
|
runStatus = (name, args) => runHarnessLoginStatus(name, args, { env, environment, agentName }),
|
|
137
145
|
}) => {
|
|
138
146
|
if (!adapter || !adapterName) return [];
|
|
@@ -147,10 +155,29 @@ export const harnessFindings = async ({
|
|
|
147
155
|
}];
|
|
148
156
|
}
|
|
149
157
|
}
|
|
150
|
-
|
|
158
|
+
const findings = [];
|
|
159
|
+
let shortfall = null;
|
|
160
|
+
try {
|
|
161
|
+
shortfall = checkVersion && typeof adapter.versionShortfall === 'function'
|
|
162
|
+
? await adapter.versionShortfall({ env, unconfined })
|
|
163
|
+
: null;
|
|
164
|
+
} catch {
|
|
165
|
+
shortfall = null;
|
|
166
|
+
}
|
|
167
|
+
if (shortfall?.found && shortfall?.required) {
|
|
168
|
+
const label = LABEL[adapterName] || adapterName;
|
|
169
|
+
const update = harnessUpdateCommand(adapterName);
|
|
170
|
+
findings.push({
|
|
171
|
+
reason: 'harness-too-old',
|
|
172
|
+
harness: adapterName,
|
|
173
|
+
line: `This computer has ${label} ${shortfall.found}, and this agent needs ${label} ${shortfall.required} or later. `
|
|
174
|
+
+ `Update it${update ? ` (${update})` : ''}, then run this line again.`,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
if (environment?.provider !== undefined || !LABEL[adapterName]) return findings;
|
|
151
178
|
const signedIn = await loginState(adapterName, { runStatus, env });
|
|
152
|
-
if (signedIn !== false) return
|
|
153
|
-
return [{
|
|
179
|
+
if (signedIn !== false) return findings;
|
|
180
|
+
return [...findings, {
|
|
154
181
|
reason: 'harness-signed-out',
|
|
155
182
|
harness: adapterName,
|
|
156
183
|
line: `${LABEL[adapterName]} is installed but not signed in on this computer. `
|
package/src/lib/session-store.js
CHANGED
|
@@ -186,6 +186,12 @@ export const noticeDue = (agentName, key, windowMs, now = Date.now()) => {
|
|
|
186
186
|
return !Number.isFinite(last) || now - last >= windowMs || last > now;
|
|
187
187
|
};
|
|
188
188
|
|
|
189
|
+
/** When `key` was last recorded, in ms; NaN when never. */
|
|
190
|
+
export const noticeRecordedAt = (agentName, key) => {
|
|
191
|
+
if (!agentName || !key) return NaN;
|
|
192
|
+
return Date.parse(readNotices(agentName)[key]);
|
|
193
|
+
};
|
|
194
|
+
|
|
189
195
|
export const recordNotice = (agentName, key, now = Date.now()) => {
|
|
190
196
|
if (!agentName || !key) return;
|
|
191
197
|
const state = readNotices(agentName);
|
|
@@ -23,6 +23,46 @@ import { modelUnavailableFailure } from './model-unavailable.js';
|
|
|
23
23
|
/** How long one cause stays posted in a pod before the seat may post it again. */
|
|
24
24
|
export const CANT_ANSWER_NOTICE_WINDOW_MS = 60 * 60 * 1000;
|
|
25
25
|
|
|
26
|
+
/** Inside that hour, the least time between two posts for people who wrote again. */
|
|
27
|
+
export const CANT_ANSWER_REPEAT_MIN_MS = 2 * 60 * 1000;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The newest message an event carries, in ms on the server's clock: the row's
|
|
31
|
+
* own time, its message's, and any message the kernel joined to it later
|
|
32
|
+
* (`payload.coalesced`), which leaves the row's time alone. NaN when none reads.
|
|
33
|
+
*/
|
|
34
|
+
export const newestMessageAt = (event) => {
|
|
35
|
+
const times = [event?.createdAt, event?.payload?.createdAt]
|
|
36
|
+
.concat((Array.isArray(event?.payload?.coalesced) ? event.payload.coalesced : []).map((entry) => entry?.createdAt))
|
|
37
|
+
.map((value) => Date.parse(value))
|
|
38
|
+
.filter(Number.isFinite);
|
|
39
|
+
return times.length ? Math.max(...times) : NaN;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* F689: whether a pod is owed the can't-answer line now. Once an hour as
|
|
44
|
+
* before, and also when a person wrote again after the last line (`waiting`
|
|
45
|
+
* is that pod's events a person may have written), so a "retry" isn't met
|
|
46
|
+
* with silence. A retry of the same held messages isn't new, and a burst
|
|
47
|
+
* right after the line waits out the spacing, which runs on the seat's clock.
|
|
48
|
+
* "New" runs on the server's: after `seenThrough`, the newest message the
|
|
49
|
+
* last line was posted over, or after the line's own time on a record from
|
|
50
|
+
* before that was kept. An event whose time can't be read counts as new.
|
|
51
|
+
* `lastNoticeAt` is NaN when never told.
|
|
52
|
+
*/
|
|
53
|
+
export const cantAnswerNoticeDue = ({
|
|
54
|
+
lastNoticeAt, seenThrough = NaN, now = Date.now(), waiting = [],
|
|
55
|
+
}) => {
|
|
56
|
+
if (!Number.isFinite(lastNoticeAt) || lastNoticeAt > now) return true;
|
|
57
|
+
if (now - lastNoticeAt >= CANT_ANSWER_NOTICE_WINDOW_MS) return true;
|
|
58
|
+
if (now - lastNoticeAt < CANT_ANSWER_REPEAT_MIN_MS) return false;
|
|
59
|
+
const boundary = Number.isFinite(seenThrough) ? seenThrough : lastNoticeAt;
|
|
60
|
+
return waiting.some((event) => {
|
|
61
|
+
const at = newestMessageAt(event);
|
|
62
|
+
return !Number.isFinite(at) || at > boundary;
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
26
66
|
const LOGIN_FAILED_WORDINGS = [
|
|
27
67
|
// Not `(upstream 401)` alone: adapterFailure writes that for any "status 401"
|
|
28
68
|
// in a tail, including a tool's stderr. A failed Codex turn is its own report.
|
|
@@ -52,6 +92,18 @@ const LOGIN_FAILED_WORDINGS = [
|
|
|
52
92
|
const CLAUDE_SIGNED_OUT_WORDINGS = [
|
|
53
93
|
/^claude exited(?: with code)? \d+: (?:[^\n]*? \| )?Not logged in · Please run \/login/,
|
|
54
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
|
+
];
|
|
55
107
|
const WONT_START_WORDINGS = [
|
|
56
108
|
/^spawn \S+ ENOENT/,
|
|
57
109
|
// windows-command.js resolveLaunch: not on PATH, or a .cmd/.ps1 that only a
|
|
@@ -100,6 +152,12 @@ export const CLAUDE_SIGNED_OUT_NOTICE = 'I can’t answer right now: Claude Code
|
|
|
100
152
|
// What the seat's own log says, for whoever runs it.
|
|
101
153
|
export const CLAUDE_SIGNED_OUT_FIX = 'Claude Code is not signed in on this computer: open Claude Code here and sign in '
|
|
102
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.';
|
|
103
161
|
export const WONT_START_NOTICE = 'I can’t answer right now: the tool I run on wouldn’t start on my computer. '
|
|
104
162
|
+ `Whoever runs me needs to fix that and start me again. ${AGAIN}`;
|
|
105
163
|
export const OUT_OF_ALLOWANCE_NOTICE = 'I can’t answer right now: the AI account I run on has used up its allowance. '
|
|
@@ -140,6 +198,7 @@ export const cantAnswerNotice = (error) => {
|
|
|
140
198
|
const text = String(error?.message ?? '').split(/(?:^|: | \| |\n)\{"type":/)[0];
|
|
141
199
|
// Before the general login line: this one names its own fix.
|
|
142
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 };
|
|
143
202
|
// Before the allowance check: a 401 is settled, whatever else its body says.
|
|
144
203
|
if (matches(LOGIN_FAILED_WORDINGS, text)) return { cause: 'login', text: LOGIN_NOTICE };
|
|
145
204
|
if (matches(WONT_START_WORDINGS, text)) return { cause: 'wont-start', text: WONT_START_NOTICE };
|
|
@@ -151,7 +210,9 @@ export const cantAnswerNotice = (error) => {
|
|
|
151
210
|
|
|
152
211
|
// F370 rough spot #11: Settings said "spawn failed" and nothing more; the cause
|
|
153
212
|
// was only in the seat's log. The runner reports one of these fixed codes with
|
|
154
|
-
// 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).
|
|
155
216
|
export const SPAWN_FAILURE_REASONS = [
|
|
156
217
|
'claude-signed-out', 'login', 'wont-start', 'out-of-allowance', 'tools-unavailable', 'codex-version', 'model-unavailable',
|
|
157
218
|
];
|
|
@@ -178,9 +239,26 @@ export const isClaudeSignedOut = (error) => cantAnswerNotice(error)?.cause === '
|
|
|
178
239
|
|
|
179
240
|
/** The turn result a signed-out turn is acked with: a person's message is handed to another listener. */
|
|
180
241
|
export const CLAUDE_SIGNED_OUT_REASON = 'claude-signed-out';
|
|
181
|
-
|
|
242
|
+
const setupFaultResult = (reason) => ({
|
|
182
243
|
outcome: 'error',
|
|
183
244
|
refused: { reason: 'delivery-refused' },
|
|
184
|
-
reason
|
|
245
|
+
reason,
|
|
185
246
|
details: { failureClass: 'configuration' },
|
|
186
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);
|