@commonlyai/cli 0.1.346 → 0.1.348
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 +36 -5
- package/src/commands/daemon.js +26 -1
- package/src/lib/adapters/goose.js +11 -2
- package/src/lib/adapters/qwen.js +11 -2
package/package.json
CHANGED
package/src/commands/agent.js
CHANGED
|
@@ -90,6 +90,7 @@ import {
|
|
|
90
90
|
ADAPTERS_WITH_PUBLIC_ONLY_GRANT,
|
|
91
91
|
ADAPTERS_WITH_DEFAULT_SANDBOX,
|
|
92
92
|
ADAPTERS_WITH_SANDBOX_ENFORCEMENT,
|
|
93
|
+
COMMONLY_MCP_SERVER_NAME,
|
|
93
94
|
defaultMcpServers,
|
|
94
95
|
seatBaseline,
|
|
95
96
|
withDefaultMcpServer,
|
|
@@ -1823,6 +1824,19 @@ const FINAL_TEXT_IS_POSTED = 'Your final text is posted to the pod unless it is
|
|
|
1823
1824
|
+ 'If you did nothing, or already posted through a tool, end with NO_REPLY alone, with no summary. '
|
|
1824
1825
|
+ FAILURE_IN_PLAIN_WORDS;
|
|
1825
1826
|
|
|
1827
|
+
// F192: the one place the wrapper does drop final text by kind. On a heartbeat
|
|
1828
|
+
// nobody asked anything, and a seat with the commonly MCP posts for itself, so
|
|
1829
|
+
// its final text is narration of the checklist; two of three narration cases in
|
|
1830
|
+
// a 7-day count were such seats, with no sentinel to catch. TASK-293's rule still
|
|
1831
|
+
// holds: the turn is told, in its own closing line, that its final text goes
|
|
1832
|
+
// nowhere and the tool is how it speaks. runTurn and the prompt read the same
|
|
1833
|
+
// predicate, so the line and the drop can't disagree.
|
|
1834
|
+
const seatPostsForItself = (environment) => (environment?.mcp || [])
|
|
1835
|
+
.some((server) => server?.name === COMMONLY_MCP_SERVER_NAME);
|
|
1836
|
+
const HEARTBEAT_TEXT_IS_NOT_POSTED = 'This turn is only a heartbeat: nobody asked you anything, and your final text is not posted. '
|
|
1837
|
+
+ 'If something needs saying, post it with commonly_post_message, then end with NO_REPLY. '
|
|
1838
|
+
+ 'Otherwise end with NO_REPLY alone, with no summary.';
|
|
1839
|
+
|
|
1826
1840
|
// Who owes an open question an answer depends on who else is here. Walked 11-06:
|
|
1827
1841
|
// "can anyone…" drew an "I can't" from a seat nobody addressed. With another
|
|
1828
1842
|
// agent here, that seat should step aside, and a person's message it declines
|
|
@@ -3296,7 +3310,14 @@ export const performRun = ({
|
|
|
3296
3310
|
&& /^(HEARTBEAT_OK|HEARTBEAT_NOOP)$/i.test(replyText);
|
|
3297
3311
|
const declinedInText = event.type !== 'agent.ask' && !someoneIsWaiting(event)
|
|
3298
3312
|
&& CLOSES_ON_BARE_SENTINEL.test(replyText);
|
|
3299
|
-
|
|
3313
|
+
// F192: a heartbeat turn on a seat that has the commonly MCP. Its prompt
|
|
3314
|
+
// said the final text is not posted (HEARTBEAT_TEXT_IS_NOT_POSTED), so that
|
|
3315
|
+
// text is narration ("Checked the board, nothing new"), not a message. A
|
|
3316
|
+
// bare CLI with no posting tool still speaks through its output.
|
|
3317
|
+
const heartbeatNarration = Boolean(replyText) && seatPostsForItself(placement.environment) && !someoneIsWaiting(event)
|
|
3318
|
+
&& (event.type === 'heartbeat' || event.payload?.onlyHeartbeat === true);
|
|
3319
|
+
const silentReply = !replyText || replyText === 'NO_REPLY' || heartbeatControlReply || declinedInText
|
|
3320
|
+
|| heartbeatNarration;
|
|
3300
3321
|
// A refused model route is not a silent turn. pi reports the refusal on its
|
|
3301
3322
|
// own JSON stream and exits 0 with no text, so before this the seat log read
|
|
3302
3323
|
// `no wrapper-post (empty output)` and the cause — a 429 budget message — was
|
|
@@ -3342,7 +3363,9 @@ export const performRun = ({
|
|
|
3342
3363
|
}
|
|
3343
3364
|
} else if (silentReply) {
|
|
3344
3365
|
const reason = heartbeatControlReply ? replyText
|
|
3345
|
-
: declinedInText ? 'NO_REPLY'
|
|
3366
|
+
: declinedInText ? 'NO_REPLY'
|
|
3367
|
+
: heartbeatNarration ? 'heartbeat narration; this seat posts with commonly_post_message'
|
|
3368
|
+
: (replyText || 'empty output');
|
|
3346
3369
|
// A turn that posted via tool and THEN ended with the sentinel is not the
|
|
3347
3370
|
// same event as a turn that produced nothing — but this branch reported
|
|
3348
3371
|
// both as `no wrapper-post (NO_REPLY)`, because it is evaluated before
|
|
@@ -3578,6 +3601,9 @@ export const performRun = ({
|
|
|
3578
3601
|
const contextShown = new Set(context.slice(0, Math.max(0, BODY_LIMIT - wakeEntries.length + context.length)));
|
|
3579
3602
|
const shownEntries = wakeEntries.filter((entry) => !entry.result || contextShown.has(entry));
|
|
3580
3603
|
const heldBack = entries.filter((entry) => entry.pastCap).length;
|
|
3604
|
+
// The same set the batch's onlyHeartbeat reads, so the closing line matches the drop.
|
|
3605
|
+
const inTurn = entries.filter((entry) => !entry.pastCap);
|
|
3606
|
+
const heartbeatOnly = inTurn.length > 0 && inTurn.every((entry) => entry.event.type === 'heartbeat');
|
|
3581
3607
|
const answersPerson = shownEntries.some(answersAPerson);
|
|
3582
3608
|
const bodies = shownEntries.map((entry, index) => {
|
|
3583
3609
|
const messageId = entry.event.payload?.messageId;
|
|
@@ -3644,9 +3670,11 @@ export const performRun = ({
|
|
|
3644
3670
|
? 'Do not narrate the inbox. Answer every item marked as a person addressing you directly. '
|
|
3645
3671
|
+ 'For anything else here, post only an action or a materially useful response. '
|
|
3646
3672
|
+ FINAL_TEXT_ANSWERS_A_PERSON
|
|
3647
|
-
:
|
|
3648
|
-
|
|
3649
|
-
|
|
3673
|
+
: heartbeatOnly && seatPostsForItself(seatEnvironment)
|
|
3674
|
+
? `Do not narrate the inbox. ${HEARTBEAT_TEXT_IS_NOT_POSTED}`
|
|
3675
|
+
: 'Do not narrate the inbox. Post only an action or a materially useful response; otherwise return NO_REPLY. '
|
|
3676
|
+
+ FINAL_TEXT_IS_POSTED
|
|
3677
|
+
+ roomQuestionLine(pod, shownEntries)),
|
|
3650
3678
|
].join('\n\n');
|
|
3651
3679
|
};
|
|
3652
3680
|
|
|
@@ -4223,6 +4251,8 @@ export const performRun = ({
|
|
|
4223
4251
|
...actionEntries[0].event.payload,
|
|
4224
4252
|
batchEventIds: entries.filter((entry) => !entry.pastCap).map((entry) => String(entry.event._id)),
|
|
4225
4253
|
hasHeartbeat: entries.some((entry) => !entry.pastCap && entry.event.type === 'heartbeat'),
|
|
4254
|
+
onlyHeartbeat: entries.filter((entry) => !entry.pastCap)
|
|
4255
|
+
.every((entry) => entry.event.type === 'heartbeat'),
|
|
4226
4256
|
someoneWaiting: entries.some((entry) => !entry.pastCap && someoneIsWaiting(entry.event)),
|
|
4227
4257
|
},
|
|
4228
4258
|
};
|
|
@@ -4240,6 +4270,7 @@ export const performRun = ({
|
|
|
4240
4270
|
...entry.event.payload,
|
|
4241
4271
|
batchEventIds: [String(entry.event._id)],
|
|
4242
4272
|
hasHeartbeat: entry.event.type === 'heartbeat',
|
|
4273
|
+
onlyHeartbeat: entry.event.type === 'heartbeat',
|
|
4243
4274
|
someoneWaiting: someoneIsWaiting(entry.event),
|
|
4244
4275
|
},
|
|
4245
4276
|
},
|
package/src/commands/daemon.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
chmodSync, closeSync, existsSync, mkdirSync, openSync, rmSync, watch,
|
|
14
14
|
} from 'fs';
|
|
15
15
|
import { createClient } from '../lib/api.js';
|
|
16
|
-
import { getToken, resolveInstanceUrl } from '../lib/config.js';
|
|
16
|
+
import { getToken, resolveInstance, resolveInstanceUrl } from '../lib/config.js';
|
|
17
17
|
import {
|
|
18
18
|
clearDaemonStop, loadDaemonRecord, loadDaemonStop, removeDaemonRecord,
|
|
19
19
|
saveDaemonRecord, saveDaemonStop,
|
|
@@ -63,6 +63,24 @@ import { CLI } from '../lib/cli-hint.js';
|
|
|
63
63
|
// Set on the steps `daemon setup` runs, so a step can leave a line to setup.
|
|
64
64
|
const SETUP_CHILD_ENV = 'COMMONLY_DAEMON_SETUP_STEP';
|
|
65
65
|
|
|
66
|
+
// F459: login and register take --instance, so the first-timer walk tried it
|
|
67
|
+
// on run too and got "unknown option". Run serves the one registration this
|
|
68
|
+
// computer has, so --instance only confirms it: the same instance runs, any
|
|
69
|
+
// other (or an unknown saved key) is refused with the register line instead of
|
|
70
|
+
// quietly serving the registered one.
|
|
71
|
+
const instanceKey = (url) => String(url || '').replace(/\/+$/, '').toLowerCase();
|
|
72
|
+
export const daemonRunInstanceRefusal = (record, instanceArg, resolve = resolveInstance) => {
|
|
73
|
+
if (!instanceArg) return null;
|
|
74
|
+
const wanted = resolve(instanceArg)?.url;
|
|
75
|
+
if (wanted && instanceKey(wanted) === instanceKey(record?.instanceUrl)) return null;
|
|
76
|
+
if (!wanted) {
|
|
77
|
+
return `This computer is registered with ${record?.instanceUrl}, and no saved instance is named ${instanceArg}. `
|
|
78
|
+
+ `To use another instance, sign in to it first (${CLI} login --instance <url>), then ${CLI} daemon register --instance <url>`;
|
|
79
|
+
}
|
|
80
|
+
return `This computer is registered with ${record?.instanceUrl}, not ${instanceArg}. To run it for that instance instead: `
|
|
81
|
+
+ `${CLI} daemon register --instance ${instanceArg}`;
|
|
82
|
+
};
|
|
83
|
+
|
|
66
84
|
// launchd, systemd and Task Scheduler hold one Commonly daemon per computer
|
|
67
85
|
// account. Install refuses to stop another HOME's; this flag takes it over.
|
|
68
86
|
const REPLACE_FLAG = '--replace';
|
|
@@ -681,6 +699,7 @@ Examples:
|
|
|
681
699
|
.option('--poll <ms>', 'Work-list poll interval in ms', String(DEFAULT_POLL_MS))
|
|
682
700
|
.option('--heartbeat <ms>', 'Heartbeat interval in ms', String(DEFAULT_HEARTBEAT_MS))
|
|
683
701
|
.option('--foreground', 'Keep the supervisor attached to this terminal (default for direct invocation)')
|
|
702
|
+
.option('--instance <url-or-key>', 'Confirm the instance this computer is registered with')
|
|
684
703
|
.action(async (opts) => {
|
|
685
704
|
let record;
|
|
686
705
|
try {
|
|
@@ -691,6 +710,12 @@ Examples:
|
|
|
691
710
|
return;
|
|
692
711
|
}
|
|
693
712
|
record = requireDaemonRecord();
|
|
713
|
+
const instanceRefusal = daemonRunInstanceRefusal(record, opts.instance);
|
|
714
|
+
if (instanceRefusal) {
|
|
715
|
+
console.error(instanceRefusal);
|
|
716
|
+
process.exitCode = 1;
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
694
719
|
const stopped = loadDaemonStop(record);
|
|
695
720
|
if (stopped) {
|
|
696
721
|
console.error(`Daemon stopped: this computer's key was revoked. Run: ${CLI} daemon register`);
|
|
@@ -371,6 +371,8 @@ export default {
|
|
|
371
371
|
const home = await mkdtemp(join(tmpdir(), 'commonly-goose-home-'));
|
|
372
372
|
let proxy;
|
|
373
373
|
let credentialRelease = null;
|
|
374
|
+
let reply = null;
|
|
375
|
+
let cleanupFailure = null;
|
|
374
376
|
try {
|
|
375
377
|
const credential = writeCredentialFile(ctx.runtimeToken, {
|
|
376
378
|
root: tempDir, agentName: ctx.agentName || 'agent',
|
|
@@ -490,12 +492,19 @@ export default {
|
|
|
490
492
|
spawnImpl,
|
|
491
493
|
}).catch((err) => { throw releaseFailure || err; });
|
|
492
494
|
if (releaseFailure) throw releaseFailure;
|
|
493
|
-
|
|
495
|
+
reply = { text, newSessionId: null };
|
|
494
496
|
} finally {
|
|
495
497
|
credentialRelease?.stop();
|
|
496
498
|
try { await proxy?.close(); } finally {
|
|
497
|
-
await Promise.
|
|
499
|
+
const removed = await Promise.allSettled([tempDir, home].map((path) => rm(path, { recursive: true, force: true })));
|
|
500
|
+
cleanupFailure = removed.find((outcome) => outcome.status === 'rejected')?.reason || null;
|
|
498
501
|
}
|
|
499
502
|
}
|
|
503
|
+
// Reached only when the turn worked. A cleanup failure is then the turn's
|
|
504
|
+
// error: on a private seat that rm is the one delete of the credential, so
|
|
505
|
+
// the turn must not report success over it. When another error ended the
|
|
506
|
+
// turn (a failed release, say), it propagates past this and is kept.
|
|
507
|
+
if (cleanupFailure) throw cleanupFailure;
|
|
508
|
+
return reply;
|
|
500
509
|
},
|
|
501
510
|
};
|
package/src/lib/adapters/qwen.js
CHANGED
|
@@ -367,6 +367,8 @@ export default {
|
|
|
367
367
|
const mcpPath = join(tempDir, 'mcp.json');
|
|
368
368
|
let proxy;
|
|
369
369
|
let credentialRelease = null;
|
|
370
|
+
let reply = null;
|
|
371
|
+
let cleanupFailure = null;
|
|
370
372
|
try {
|
|
371
373
|
const credential = writeCredentialFile(ctx.runtimeToken, {
|
|
372
374
|
agentName: ctx.agentName || 'agent', root: tempDir,
|
|
@@ -502,12 +504,19 @@ export default {
|
|
|
502
504
|
credentials: [...spawnCredentials(ctx, []), proxyWithBearer.bearer],
|
|
503
505
|
}).catch((err) => { throw releaseFailure || err; });
|
|
504
506
|
if (releaseFailure) throw releaseFailure;
|
|
505
|
-
|
|
507
|
+
reply = { text: result.text, newSessionId: null };
|
|
506
508
|
} finally {
|
|
507
509
|
credentialRelease?.stop();
|
|
508
510
|
try { await proxy?.close(); } catch { /* best effort */ }
|
|
509
|
-
await Promise.
|
|
511
|
+
const removed = await Promise.allSettled([tempDir, home].map((path) => rm(path, { recursive: true, force: true })));
|
|
512
|
+
cleanupFailure = removed.find((outcome) => outcome.status === 'rejected')?.reason || null;
|
|
510
513
|
}
|
|
514
|
+
// Reached only when the turn worked. A cleanup failure is then the turn's
|
|
515
|
+
// error: on a private seat that rm is the one delete of the credential, so
|
|
516
|
+
// the turn must not report success over it. When another error ended the
|
|
517
|
+
// turn (a failed release, say), it propagates past this and is kept.
|
|
518
|
+
if (cleanupFailure) throw cleanupFailure;
|
|
519
|
+
return reply;
|
|
511
520
|
},
|
|
512
521
|
};
|
|
513
522
|
|