@commonlyai/cli 0.1.391 → 0.1.392
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 +32 -2
- package/src/lib/run-preflight.js +13 -1
package/package.json
CHANGED
package/src/commands/agent.js
CHANGED
|
@@ -41,7 +41,7 @@ import { formatDigestFrame, formatUnreadMessagesFrame } from '../lib/digest-fram
|
|
|
41
41
|
import { startWebhookServer, forwardToLocalWebhook, logOnlyHandler } from '../lib/webhook-server.js';
|
|
42
42
|
import { getAdapter, listAdapterNames, listPublicAdapterNames } from '../lib/adapters/index.js';
|
|
43
43
|
import {
|
|
44
|
-
harnessFindings, nodeFinding, preflightOutcome, reportListenBlocked,
|
|
44
|
+
harnessFindings, nodeFinding, preflightOutcome, reportListenBlocked, SANDBOX_STOPS,
|
|
45
45
|
} from '../lib/run-preflight.js';
|
|
46
46
|
import {
|
|
47
47
|
getSession,
|
|
@@ -296,6 +296,9 @@ export const deleteAgentToken = (name) => {
|
|
|
296
296
|
// just because its binary happens to be installed on the operator's machine.
|
|
297
297
|
export const BOOTSTRAP_ADAPTER_DETECT_ORDER = ['claude', 'codex', 'pi'];
|
|
298
298
|
export const NO_AGENT_CLI_CODE = 'no_agent_cli';
|
|
299
|
+
// F571: the instance answered 401 to the first-run key, so the run can't sign
|
|
300
|
+
// in to say why it stopped, and reports without a key instead.
|
|
301
|
+
export const TOKEN_REFUSED_CODE = 'token_refused';
|
|
299
302
|
|
|
300
303
|
/**
|
|
301
304
|
* What `agent run` says when no token is set. On Windows the page's lines are
|
|
@@ -596,10 +599,14 @@ export const bootstrapAgentRecordFromEnv = async ({
|
|
|
596
599
|
client = clientFactory({ instance: instanceUrl, token: runtimeToken });
|
|
597
600
|
identity = await client.get('/api/agents/runtime/installations');
|
|
598
601
|
} catch (err) {
|
|
599
|
-
|
|
602
|
+
const resolveErr = new Error(
|
|
600
603
|
`Could not resolve the agent behind COMMONLY_AGENT_TOKEN against ${instanceUrl}: ${err.message}. `
|
|
601
604
|
+ 'Check the token was copied whole and the URL matches the instance that issued it.',
|
|
602
605
|
);
|
|
606
|
+
// 401 alone, as adoptEnvToken reads it: a 403 comes from something in
|
|
607
|
+
// front of the app, and a network failure means nothing reached it.
|
|
608
|
+
if (err?.status === 401) resolveErr.code = TOKEN_REFUSED_CODE;
|
|
609
|
+
throw resolveErr;
|
|
603
610
|
}
|
|
604
611
|
|
|
605
612
|
const installs = Array.isArray(identity?.installations) ? identity.installations : [];
|
|
@@ -6020,6 +6027,12 @@ Docs:
|
|
|
6020
6027
|
if (err.code === NO_AGENT_CLI_CODE && process.platform === 'win32') {
|
|
6021
6028
|
console.error(windowsSandboxMessage('claude'));
|
|
6022
6029
|
}
|
|
6030
|
+
// F571: a refused key can't sign the listen-blocked report, so this
|
|
6031
|
+
// one goes keyless, by name and code only. An unreachable instance
|
|
6032
|
+
// hears nothing either way, so nothing is sent for it.
|
|
6033
|
+
if (err.code === TOKEN_REFUSED_CODE) {
|
|
6034
|
+
await reportRunStopped({ agentName: agentArg, reason: 'token-refused' });
|
|
6035
|
+
}
|
|
6023
6036
|
process.exit(1);
|
|
6024
6037
|
}
|
|
6025
6038
|
if (!record) {
|
|
@@ -6068,6 +6081,15 @@ Docs:
|
|
|
6068
6081
|
const flagRefusal = unsandboxedFlagRefusal(process.platform, { adapterName: record.adapter });
|
|
6069
6082
|
if (flagRefusal) {
|
|
6070
6083
|
console.error(`${stamp()} [${name}] ${flagRefusal}`);
|
|
6084
|
+
// F571: the record's token still works here, so the page hears why.
|
|
6085
|
+
// Only a first run: the page waits on nothing else, and a saved seat's
|
|
6086
|
+
// respawn must not wait on a black-holed instance.
|
|
6087
|
+
if (bootstrapped) {
|
|
6088
|
+
await reportListenBlocked(
|
|
6089
|
+
createClient({ instance: record.instanceUrl, token: record.runtimeToken }),
|
|
6090
|
+
SANDBOX_STOPS.flagRefused,
|
|
6091
|
+
);
|
|
6092
|
+
}
|
|
6071
6093
|
process.exit(1);
|
|
6072
6094
|
}
|
|
6073
6095
|
}
|
|
@@ -6126,6 +6148,14 @@ Docs:
|
|
|
6126
6148
|
});
|
|
6127
6149
|
if (hostRefusal) {
|
|
6128
6150
|
console.error(`${stamp()} [${name}] ${hostRefusal}`);
|
|
6151
|
+
// F571: by code only; the refusal text can name a path on this computer.
|
|
6152
|
+
// First run only, as above.
|
|
6153
|
+
if (bootstrapped) {
|
|
6154
|
+
await reportListenBlocked(
|
|
6155
|
+
createClient({ instance: record.instanceUrl, token: record.runtimeToken }),
|
|
6156
|
+
SANDBOX_STOPS.hostRefused,
|
|
6157
|
+
);
|
|
6158
|
+
}
|
|
6129
6159
|
process.exit(1);
|
|
6130
6160
|
}
|
|
6131
6161
|
// F444: on Linux a private Codex seat has a sandbox, so a flag its pods
|
package/src/lib/run-preflight.js
CHANGED
|
@@ -20,7 +20,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
|
-
export const LISTEN_BLOCKED_REASONS = [
|
|
23
|
+
export const LISTEN_BLOCKED_REASONS = [
|
|
24
|
+
'node-too-old', 'harness-signed-out', 'sandbox-unavailable', 'unsandboxed-refused',
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
// F571: the two sandbox stops `agent run` makes once it has read the record,
|
|
28
|
+
// and so holds a token the instance accepts. Neither names a harness, and the
|
|
29
|
+
// refusal text stays in the terminal: it can carry a path.
|
|
30
|
+
export const SANDBOX_STOPS = Object.freeze({
|
|
31
|
+
// This computer can't start the sandbox the seat runs in.
|
|
32
|
+
hostRefused: Object.freeze({ reason: 'sandbox-unavailable', harness: null }),
|
|
33
|
+
// --unsandboxed was typed where it doesn't apply to this agent.
|
|
34
|
+
flagRefused: Object.freeze({ reason: 'unsandboxed-refused', harness: null }),
|
|
35
|
+
});
|
|
24
36
|
|
|
25
37
|
// The floor the CLI declares, read as `commonly doctor` reads it.
|
|
26
38
|
const CLI_ENGINES_NODE = (() => {
|