@commonlyai/cli 0.1.261 → 0.1.263
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 +75 -10
- package/src/lib/adapters/codex.js +7 -2
package/package.json
CHANGED
package/src/commands/agent.js
CHANGED
|
@@ -736,6 +736,16 @@ const PROMPT_EVENT_TYPES = new Set([
|
|
|
736
736
|
// is the only one worth holding back.
|
|
737
737
|
const DEFERRABLE_SOLO_EVENT_TYPES = new Set(['first_contact']);
|
|
738
738
|
|
|
739
|
+
// How long a fresh seat's greeting waits for a person before it runs alone.
|
|
740
|
+
// One poll lost the race on the 0.1.257 walk (2026-11-05): the mention landed
|
|
741
|
+
// just after the hold, the greeting took the next turn alone, and the answer
|
|
742
|
+
// came 50.5 s after the mention instead of 25.7 s. A person who has just
|
|
743
|
+
// connected an agent usually mentions it within its first minute, and the
|
|
744
|
+
// kernel posts the seat's own join line at once, so a quiet connect loses
|
|
745
|
+
// nothing by greeting a minute later. Counted in polls (at least one), so a
|
|
746
|
+
// shorter --interval holds for more polls, not for less time.
|
|
747
|
+
const GREETING_HOLD_MS = 60_000;
|
|
748
|
+
|
|
739
749
|
// Inside one batch the person's item leads the prompt; the greeting follows it.
|
|
740
750
|
const PERSON_WAITING_EVENT_TYPES = new Set(['chat.mention', 'message.posted', 'dm.message']);
|
|
741
751
|
|
|
@@ -1507,8 +1517,16 @@ const FINAL_TEXT_IS_POSTED = 'Your final text is posted to the pod unless it is
|
|
|
1507
1517
|
// with no message at all. Only a message with no thread, outside a DM, gets it.
|
|
1508
1518
|
// The line still allows the overflow rule (post the point, continue under your
|
|
1509
1519
|
// own root): only threading under the person's message is ruled out.
|
|
1520
|
+
//
|
|
1521
|
+
// The same walk on 0.1.258, with the mention sharing a turn with the greeting:
|
|
1522
|
+
// the seat obeyed that line about threadRootId and passed replyToMessageId
|
|
1523
|
+
// instead. The kernel files a reply in its parent's thread
|
|
1524
|
+
// (COALESCE(parent.thread_root_id, parent.id) in models/pg/Message.ts), so
|
|
1525
|
+
// that threads it too. The line names both fields.
|
|
1510
1526
|
const ANSWER_IN_CHANNEL = '[This message is top-level in the channel, not in a thread: post your answer top-level. '
|
|
1511
|
-
+ '
|
|
1527
|
+
+ 'Do not pass this message\'s id as threadRootId or as replyToMessageId: a reply is filed in the thread of '
|
|
1528
|
+
+ 'the message it replies to, so either one hides your answer under it. '
|
|
1529
|
+
+ 'A long answer may continue under your own top-level post.]';
|
|
1512
1530
|
|
|
1513
1531
|
export const answersInChannel = (entry) => {
|
|
1514
1532
|
const payload = entry?.event?.payload || {};
|
|
@@ -2988,6 +3006,10 @@ export const performRun = ({
|
|
|
2988
3006
|
// Spent at most once per run. (CTO review 5623358693.)
|
|
2989
3007
|
let heldGreeting = [];
|
|
2990
3008
|
let greetingHoldSpent = false;
|
|
3009
|
+
// Polls the connect-time greeting has been carried, against the window.
|
|
3010
|
+
let greetingHeldPolls = 0;
|
|
3011
|
+
let greetingHoldStartedAt = null;
|
|
3012
|
+
const greetingHoldPolls = Math.max(1, Math.ceil(GREETING_HOLD_MS / Math.max(1, Number(intervalMs) || 1)));
|
|
2991
3013
|
|
|
2992
3014
|
// The same is true of a batch whose turn FAILED: its events are claimed, so
|
|
2993
3015
|
// scheduling a later poll retries nothing — the next poll cannot return
|
|
@@ -3463,8 +3485,16 @@ export const performRun = ({
|
|
|
3463
3485
|
// The liveness clock runs from here until the next scheduled wait, paused
|
|
3464
3486
|
// only while a model turn runs (lib/poll-liveness.js).
|
|
3465
3487
|
pollLiveness.arm();
|
|
3488
|
+
// Leave room for what this loop carries (a held greeting, a failed
|
|
3489
|
+
// batch), so a carried event never pushes a full page past the prompt's
|
|
3490
|
+
// body cap and a busy pod can't keep the greeting out (CodeRabbit on
|
|
3491
|
+
// #3511). The overflow pass below stays as the backstop.
|
|
3492
|
+
// Only wake events count: the server's page cap is on wakes, and a
|
|
3493
|
+
// carried digest row takes no body (CodeRabbit on #3511).
|
|
3494
|
+
const carriedCount = [...heldRetry, ...heldGreeting]
|
|
3495
|
+
.filter((event) => event.deliveryMode !== 'digest').length;
|
|
3466
3496
|
const page = await client.get('/api/agents/runtime/events', {
|
|
3467
|
-
agentName, instanceId, limit: batchLimit,
|
|
3497
|
+
agentName, instanceId, limit: Math.max(1, batchLimit - carriedCount),
|
|
3468
3498
|
...(adapter?.name ? { reportedCli: adapter.name } : {}),
|
|
3469
3499
|
});
|
|
3470
3500
|
pollLiveness.arm();
|
|
@@ -3512,7 +3542,22 @@ export const performRun = ({
|
|
|
3512
3542
|
group.push(event);
|
|
3513
3543
|
eventGroups.set(key, group);
|
|
3514
3544
|
}
|
|
3515
|
-
|
|
3545
|
+
// A carried greeting must not push a full page past the prompt's body
|
|
3546
|
+
// cap: an event past the cap gets no body yet is acked with the batch
|
|
3547
|
+
// (CodeRabbit on #3511). Carry the greeting again instead.
|
|
3548
|
+
for (const [key, group] of eventGroups) {
|
|
3549
|
+
const wakeCount = group.filter((event) => event.deliveryMode !== 'digest').length;
|
|
3550
|
+
if (wakeCount <= batchLimit) continue;
|
|
3551
|
+
const overflow = group.filter((event) => carriedIds.has(String(event._id))
|
|
3552
|
+
&& DEFERRABLE_SOLO_EVENT_TYPES.has(event.type));
|
|
3553
|
+
if (!overflow.length) continue;
|
|
3554
|
+
heldGreeting = [...heldGreeting, ...overflow];
|
|
3555
|
+
eventGroups.set(key, group.filter((event) => !overflow.includes(event)));
|
|
3556
|
+
}
|
|
3557
|
+
const groups = [...eventGroups.values()].filter((group) => group.length > 0);
|
|
3558
|
+
// The greeting window is counted once per poll, however many pods'
|
|
3559
|
+
// greetings this page carries (gate review of #3511).
|
|
3560
|
+
let greetingCarriedThisPoll = false;
|
|
3516
3561
|
// The claimed events a failure at `groupIndex` stops before they run.
|
|
3517
3562
|
// A digest-only group was never claimed, so it is not carried.
|
|
3518
3563
|
const untriedAfter = (groupIndex) => groups.slice(groupIndex + 1)
|
|
@@ -3529,15 +3574,35 @@ export const performRun = ({
|
|
|
3529
3574
|
}
|
|
3530
3575
|
if ((group[0].podId || podId) && !PRIVATE_RESPONSE_EVENT_TYPES.has(group[0].type)) {
|
|
3531
3576
|
// Nothing in this batch but the seat introducing itself: leave it
|
|
3532
|
-
// unacked for
|
|
3533
|
-
// window is answered in the same turn instead
|
|
3534
|
-
//
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3577
|
+
// unacked for up to GREETING_HOLD_MS, so a person who mentions the
|
|
3578
|
+
// agent in that window is answered first, in the same turn, instead
|
|
3579
|
+
// of behind a greeting. Only the connect-time greeting is held: once
|
|
3580
|
+
// a turn has carried one, later greetings run as they arrive.
|
|
3581
|
+
// Digest rows ride along with a greeting without counting as a
|
|
3582
|
+
// person waiting (CodeRabbit on #3511). The window is bounded by the
|
|
3583
|
+
// clock too, so turns run for other pods between polls can't stretch
|
|
3584
|
+
// the carry past its delivery lease (CodeRabbit on #3511).
|
|
3585
|
+
if (!greetingHoldSpent
|
|
3586
|
+
&& (greetingCarriedThisPoll || (greetingHeldPolls < greetingHoldPolls
|
|
3587
|
+
&& (greetingHoldStartedAt === null || Date.now() - greetingHoldStartedAt < GREETING_HOLD_MS)))
|
|
3588
|
+
&& group.some((event) => DEFERRABLE_SOLO_EVENT_TYPES.has(event.type))
|
|
3589
|
+
&& group.every((event) => DEFERRABLE_SOLO_EVENT_TYPES.has(event.type) || event.deliveryMode === 'digest')) {
|
|
3590
|
+
if (greetingHeldPolls === 0 && !greetingCarriedThisPoll) {
|
|
3591
|
+
log(`[inbox.batch] carrying ${group.length} greeting event(s) for up to `
|
|
3592
|
+
+ `${Math.round(GREETING_HOLD_MS / 1000)} s, so a person who mentions this agent is answered first`);
|
|
3593
|
+
}
|
|
3594
|
+
if (!greetingCarriedThisPoll) {
|
|
3595
|
+
greetingCarriedThisPoll = true;
|
|
3596
|
+
greetingHeldPolls += 1;
|
|
3597
|
+
if (greetingHoldStartedAt === null) greetingHoldStartedAt = Date.now();
|
|
3598
|
+
}
|
|
3599
|
+
// Appended, never assigned: two pods' greetings can be carried in
|
|
3600
|
+
// the same window, and an overwrite left the first unacked until
|
|
3601
|
+
// the server's requeue, 10 to 20 minutes later.
|
|
3602
|
+
heldGreeting = [...heldGreeting, ...group];
|
|
3539
3603
|
continue;
|
|
3540
3604
|
}
|
|
3605
|
+
if (group.some((event) => DEFERRABLE_SOLO_EVENT_TYPES.has(event.type))) greetingHoldSpent = true;
|
|
3541
3606
|
// One failure report for a batch whose items stay unacked, whether
|
|
3542
3607
|
// the composite turn threw or an isolated item did after a refusal.
|
|
3543
3608
|
// The unacked items are carried to the retry, not left to the
|
|
@@ -900,7 +900,7 @@ const CODEX_PROVIDER_KEY_ENVS = [
|
|
|
900
900
|
// `ownGroup`: see runClaude in claude.js.
|
|
901
901
|
const runCodex = ({
|
|
902
902
|
args, cwd, env, timeoutMs, credentials = [], spawnImpl = childSpawn, onSpawn, controls = {}, ownGroup = false,
|
|
903
|
-
turnReap = turnReapEnabled(), commandResolution = {},
|
|
903
|
+
turnReap = turnReapEnabled(), commandResolution = {}, confined = false,
|
|
904
904
|
}) => new Promise((resolve, reject) => { // stdio: ['ignore', 'pipe', 'pipe'] — without this, child_process.spawn
|
|
905
905
|
// defaults stdin to a fresh pipe. Codex 0.125.0's `exec` then blocks on
|
|
906
906
|
// `Reading additional input from stdin...` because it sees an open pipe
|
|
@@ -909,7 +909,8 @@ const runCodex = ({
|
|
|
909
909
|
// `'ignore'` gives codex /dev/null → immediate EOF → it falls back to the
|
|
910
910
|
// argv prompt as intended. Surfaced live during ADR-005 Phase 2 smoke.
|
|
911
911
|
// What the turn leaves running is stopped once it has closed (see claude.js).
|
|
912
|
-
|
|
912
|
+
// A confined turn's leftovers are stopped whatever the keep setting says.
|
|
913
|
+
const turn = markTurn(env ?? process.env, { enabled: turnReap, confined });
|
|
913
914
|
// On Windows `npm i -g @openai/codex` leaves a `codex.cmd`; it is read and
|
|
914
915
|
// its target spawned directly, never through cmd.exe, because the prompt is
|
|
915
916
|
// the last argv element and is pod content (#2141). Identity elsewhere.
|
|
@@ -1120,6 +1121,10 @@ export default {
|
|
|
1120
1121
|
spawnImpl: ctx._spawnImpl, onSpawn: ctx.onSpawn, controls: controlsFromArguments(args.slice(args.indexOf('exec') + (args[args.indexOf('exec') + 1] === 'resume' ? 3 : 1), -1), { modelFlag: '--model', valueFlags: ['-c', '-o', '--permission-profile'], codex: true }), // test seam only — do not use in production
|
|
1121
1122
|
ownGroup: wantsOwnProcessGroup(ctx),
|
|
1122
1123
|
turnReap: ctx._turnReap,
|
|
1124
|
+
// A public seat keeps nothing a turn leaves running, whatever the turn
|
|
1125
|
+
// set (F201, as claude.js does for F197). `publicSandboxMode` is set
|
|
1126
|
+
// exactly when trust is `public`; workspace trust is refused above.
|
|
1127
|
+
confined: publicSandboxMode !== null,
|
|
1123
1128
|
commandResolution: ctx._commandResolution, // test seam only
|
|
1124
1129
|
});
|
|
1125
1130
|
|