@commonlyai/cli 0.1.86 → 0.1.87
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 +33 -1
package/package.json
CHANGED
package/src/commands/agent.js
CHANGED
|
@@ -127,6 +127,30 @@ export const deleteAgentToken = (name) => {
|
|
|
127
127
|
// falls back to the attach hint).
|
|
128
128
|
export const BOOTSTRAP_ADAPTER_DETECT_ORDER = ['claude', 'codex', 'pi'];
|
|
129
129
|
|
|
130
|
+
// ── `agent run --adapter` against an existing token file (#2098) ────────────
|
|
131
|
+
// The flag picks the CLI once, at first-run bootstrap; after that the token
|
|
132
|
+
// file's adapter is what runs. A different `--adapter` used to be dropped
|
|
133
|
+
// without a word, so "switch this agent to Codex" kept running Claude and read
|
|
134
|
+
// as Codex misbehaving. Refuse instead, and name the way out for each path:
|
|
135
|
+
// a foreground run re-bootstraps from the Connect page's env exports after the
|
|
136
|
+
// local record is removed; a daemon-managed seat is switched through the
|
|
137
|
+
// registry, which the daemon applies on its next pass.
|
|
138
|
+
export const checkRunAdapterRequest = ({ record, requestedAdapter, tokenPath }) => {
|
|
139
|
+
const requested = String(requestedAdapter || '').trim().toLowerCase();
|
|
140
|
+
if (!requested) return { ok: true };
|
|
141
|
+
const bound = String(record?.adapter || '').trim().toLowerCase();
|
|
142
|
+
if (!bound || bound === requested) return { ok: true };
|
|
143
|
+
const name = record.agentName;
|
|
144
|
+
return {
|
|
145
|
+
ok: false,
|
|
146
|
+
message: [
|
|
147
|
+
`'${name}' is bound to the ${bound} adapter by its token file (${tokenPath}); --adapter ${requested} was not applied.`,
|
|
148
|
+
`To run it with ${requested} here: commonly agent detach ${name} --force, then re-run with the Connect-page env exports and --adapter ${requested}.`,
|
|
149
|
+
`A daemon-managed seat switches with: commonly agent config ${name} --adapter ${requested}`,
|
|
150
|
+
].join('\n'),
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
|
|
130
154
|
export const bootstrapAgentRecordFromEnv = async ({
|
|
131
155
|
name,
|
|
132
156
|
env = process.env,
|
|
@@ -2690,7 +2714,7 @@ Docs:
|
|
|
2690
2714
|
.command('run <name>')
|
|
2691
2715
|
.description('Run the local-CLI wrapper loop for an attached agent')
|
|
2692
2716
|
.option('--interval <ms>', 'Poll interval in ms', '5000')
|
|
2693
|
-
.option('--adapter <name>', 'CLI to wrap on first-run bootstrap (claude|codex);
|
|
2717
|
+
.option('--adapter <name>', 'CLI to wrap on first-run bootstrap (claude|codex); an existing token file bound to a different adapter stops the run')
|
|
2694
2718
|
.option('--cascade-cap <n>', `Consecutive agent-triggered turns allowed per pod (env ${CASCADE_ENV_VARS.cap}, default ${CASCADE_DEFAULTS.cap})`)
|
|
2695
2719
|
.option('--cascade-grace <n>', `Extra turns allowed when this seat was directly addressed; 0 disables the grace (env ${CASCADE_ENV_VARS.addressedGrace}, default ${CASCADE_DEFAULTS.addressedGrace})`)
|
|
2696
2720
|
.option('--cascade-reset <ms>', `Silence window that clears the streak (env ${CASCADE_ENV_VARS.resetMs}, default ${CASCADE_DEFAULTS.resetMs})`)
|
|
@@ -2722,6 +2746,14 @@ Docs:
|
|
|
2722
2746
|
}
|
|
2723
2747
|
}
|
|
2724
2748
|
|
|
2749
|
+
const adapterRequest = checkRunAdapterRequest({
|
|
2750
|
+
record, requestedAdapter: opts.adapter, tokenPath: tokenFile(name),
|
|
2751
|
+
});
|
|
2752
|
+
if (!adapterRequest.ok) {
|
|
2753
|
+
console.error(`${stamp()} [${name}] ${adapterRequest.message}`);
|
|
2754
|
+
process.exit(1);
|
|
2755
|
+
}
|
|
2756
|
+
|
|
2725
2757
|
const adapter = getAdapter(record.adapter);
|
|
2726
2758
|
if (!adapter) {
|
|
2727
2759
|
console.error(`Unknown adapter '${record.adapter}' in token file. Known: ${listAdapterNames().join(', ')}`);
|