@commonlyai/cli 0.1.342 → 0.1.343
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 +9 -3
- package/src/lib/missing-harness.js +31 -0
package/package.json
CHANGED
package/src/commands/agent.js
CHANGED
|
@@ -154,6 +154,7 @@ import {
|
|
|
154
154
|
isClaudeSignedOut,
|
|
155
155
|
spawnFailureReason,
|
|
156
156
|
} from '../lib/turn-failure-notice.js';
|
|
157
|
+
import { missingHarnessHint, reportMissingHarness } from '../lib/missing-harness.js';
|
|
157
158
|
import {
|
|
158
159
|
ADDRESSED_EVENT_TYPES,
|
|
159
160
|
isPersonMention,
|
|
@@ -557,9 +558,10 @@ export const bootstrapAgentRecordFromEnv = async ({
|
|
|
557
558
|
const instanceUrl = (env.COMMONLY_API_URL || '').trim() || resolveInstanceUrl(undefined);
|
|
558
559
|
|
|
559
560
|
let identity;
|
|
561
|
+
let client;
|
|
560
562
|
try {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
+
client = clientFactory({ instance: instanceUrl, token: runtimeToken });
|
|
564
|
+
identity = await client.get('/api/agents/runtime/installations');
|
|
563
565
|
} catch (err) {
|
|
564
566
|
throw new Error(
|
|
565
567
|
`Could not resolve the agent behind COMMONLY_AGENT_TOKEN against ${instanceUrl}: ${err.message}. `
|
|
@@ -580,7 +582,10 @@ export const bootstrapAgentRecordFromEnv = async ({
|
|
|
580
582
|
throw new Error(`Unknown adapter '${adapterOverride}'. Known: ${(adapterRegistry.listPublicAdapterNames || adapterRegistry.listAdapterNames)().join(', ')}`);
|
|
581
583
|
}
|
|
582
584
|
if (!await adapter.detect()) {
|
|
583
|
-
|
|
585
|
+
// F457: this run exits before it checks in, so the page would wait for
|
|
586
|
+
// it forever. Say what was missing there, and how to get it here.
|
|
587
|
+
await reportMissingHarness(client, adapterOverride);
|
|
588
|
+
throw new Error(`Adapter '${adapterOverride}' not found on PATH. ${missingHarnessHint(adapterOverride)}`);
|
|
584
589
|
}
|
|
585
590
|
} else {
|
|
586
591
|
const missing = [];
|
|
@@ -591,6 +596,7 @@ export const bootstrapAgentRecordFromEnv = async ({
|
|
|
591
596
|
missing.push(candidate);
|
|
592
597
|
}
|
|
593
598
|
if (!adapterName) {
|
|
599
|
+
await reportMissingHarness(client, null);
|
|
594
600
|
const err = new Error(
|
|
595
601
|
`No supported agent CLI found on PATH (looked for: ${BOOTSTRAP_ADAPTER_DETECT_ORDER.join(', ')}). `
|
|
596
602
|
+ 'Install one, or pass --adapter <name>.',
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// F457: what a quick-try run says when the harness it needs isn't on PATH, and
|
|
2
|
+
// the report it leaves first. The run exits before it ever checks in, so
|
|
3
|
+
// without the report the connect page waits for it forever.
|
|
4
|
+
|
|
5
|
+
import { NPM } from './cli-hint.js';
|
|
6
|
+
|
|
7
|
+
// Only harnesses whose install command we have run ourselves get one here.
|
|
8
|
+
const INSTALL = {
|
|
9
|
+
claude: { label: 'Claude Code', command: `${NPM} i -g @anthropic-ai/claude-code`, signIn: 'claude' },
|
|
10
|
+
codex: { label: 'Codex', command: `${NPM} i -g @openai/codex`, signIn: 'codex' },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/** One sentence on how to get the named harness, ending with "run this line again". */
|
|
14
|
+
export const missingHarnessHint = (name) => {
|
|
15
|
+
const known = INSTALL[name];
|
|
16
|
+
if (!known) return `Install ${name}, then run this line again.`;
|
|
17
|
+
return `Install ${known.label} (${known.command}), sign in once by running ${known.signIn}, then run this line again.`;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Tell the instance what this run looked for (a harness id, or null for none
|
|
22
|
+
* of the ones it probes). Best effort: an older instance without the route, or
|
|
23
|
+
* a failed call, must not hide the message the person needs in the terminal.
|
|
24
|
+
*/
|
|
25
|
+
export const reportMissingHarness = async (client, harness) => {
|
|
26
|
+
try {
|
|
27
|
+
await client?.post?.('/api/agents/runtime/harness-missing', { harness });
|
|
28
|
+
} catch {
|
|
29
|
+
// The terminal message below is the answer either way.
|
|
30
|
+
}
|
|
31
|
+
};
|