@commonlyai/cli 0.1.205 → 0.1.207
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 +7 -1
- package/src/lib/daemon-hint.js +6 -0
- package/src/lib/poller.js +4 -1
package/package.json
CHANGED
package/src/commands/agent.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { createOwnKeyResolver, createMachineReportClient } from '../lib/own-key-launch.js';
|
|
2
|
+
import { foregroundDaemonHint } from '../lib/daemon-hint.js';
|
|
3
|
+
import { loadDaemonRecord } from '../lib/daemon-store.js';
|
|
2
4
|
import { WALKED_HARNESSES } from '../lib/runtime-inventory.js';
|
|
3
5
|
import { createRuntimeReporter } from '../lib/runtime-observation.js';
|
|
4
6
|
/**
|
|
@@ -3551,6 +3553,9 @@ export const performDetach = async ({
|
|
|
3551
3553
|
* kernel's own timestamps without conversion.
|
|
3552
3554
|
*/
|
|
3553
3555
|
const stamp = () => new Date().toISOString();
|
|
3556
|
+
// An unreadable daemon record still means a daemon was registered here; the
|
|
3557
|
+
// hint only chooses between the two steps, so it must not throw on it.
|
|
3558
|
+
const hasDaemonRecord = () => { try { return Boolean(loadDaemonRecord()); } catch { return true; } };
|
|
3554
3559
|
|
|
3555
3560
|
/**
|
|
3556
3561
|
* Map `agent run`'s cascade flags onto resolveCascadeSettings' override keys.
|
|
@@ -3708,6 +3713,7 @@ Docs:
|
|
|
3708
3713
|
agentName: opts.name,
|
|
3709
3714
|
instanceId: opts.instanceId,
|
|
3710
3715
|
intervalMs: parseInt(opts.interval, 10),
|
|
3716
|
+
loginInstance: opts.instance,
|
|
3711
3717
|
onEvent: async (event) => {
|
|
3712
3718
|
const ts = new Date().toTimeString().slice(0, 8);
|
|
3713
3719
|
process.stdout.write(`[${ts}] ${event.type.padEnd(18)}`);
|
|
@@ -4044,7 +4050,7 @@ Docs:
|
|
|
4044
4050
|
});
|
|
4045
4051
|
|
|
4046
4052
|
console.log(`${stamp()} [${name}] polling ${record.instanceUrl} for events (ctrl+c to stop)`);
|
|
4047
|
-
console.log(`${stamp()} [${name}]
|
|
4053
|
+
console.log(`${stamp()} [${name}] ${foregroundDaemonHint({ daemonRegistered: hasDaemonRecord() })}`);
|
|
4048
4054
|
|
|
4049
4055
|
const { stop } = performRun({
|
|
4050
4056
|
instanceUrl: record.instanceUrl,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// The hint a foreground `commonly agent run` prints for keeping the agent
|
|
2
|
+
// running. The daemon supervises only the agents placed on this computer, so
|
|
3
|
+
// the hint depends on whether a daemon is registered here at all.
|
|
4
|
+
export const foregroundDaemonHint = ({ daemonRegistered }) => (daemonRegistered
|
|
5
|
+
? 'foreground mode; this stops when the terminal closes. To keep it running, add the agent to this computer in the web app: Agents → Bring your own → On my computer'
|
|
6
|
+
: 'foreground mode; this stops when the terminal closes. To keep it running, add this computer with: commonly daemon register && commonly daemon install, then add the agent to it in the web app: Agents → Bring your own → On my computer');
|
package/src/lib/poller.js
CHANGED
|
@@ -36,6 +36,7 @@ export const startPoller = ({
|
|
|
36
36
|
agentName,
|
|
37
37
|
instanceId = 'default',
|
|
38
38
|
intervalMs = 5000,
|
|
39
|
+
loginInstance, // the --instance the connect ran with, so the login hint names it
|
|
39
40
|
onEvent, // async (event) => { outcome, content? }
|
|
40
41
|
onError, // (err) => void
|
|
41
42
|
}) => {
|
|
@@ -139,7 +140,9 @@ export const startPoller = ({
|
|
|
139
140
|
if (consecutiveAuthErrors >= MAX_AUTH_ERRORS) {
|
|
140
141
|
onError?.(new Error(
|
|
141
142
|
`Runtime token rejected ${consecutiveAuthErrors} times in a row — stopping poller. `
|
|
142
|
-
+ `
|
|
143
|
+
+ `This connection takes its key from --token, then COMMONLY_TOKEN, then your saved login. `
|
|
144
|
+
+ `If the key was rotated or revoked, re-run with the new key in --token or COMMONLY_TOKEN; `
|
|
145
|
+
+ `with neither set, run commonly login${loginInstance ? ` --instance ${loginInstance}` : ''}.`,
|
|
143
146
|
));
|
|
144
147
|
running = false;
|
|
145
148
|
return;
|