@commonlyai/cli 0.1.263 → 0.1.265
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/node_modules/@commonlyai/seats/src/upstream-refusal.js +34 -0
- package/package.json +1 -1
- package/skills/commonly/SKILL.md +7 -5
- package/src/commands/agent.js +75 -7
- package/src/lib/adapters/claude.js +24 -0
- package/src/lib/adapters/opencode.js +488 -9
- package/src/lib/adapters/pi.js +2 -2
- package/src/lib/default-environment.js +6 -4
- package/src/lib/grant-broker-guard.js +8 -3
- package/src/lib/model-unavailable.js +134 -0
- package/src/lib/sandbox/bwrap.js +10 -3
- package/src/lib/sandbox/seatbelt.js +19 -0
- package/src/lib/sandbox/workspace-pin.js +158 -0
- package/src/lib/session-store.js +43 -1
- package/src/lib/workspace-trust.js +2 -2
|
@@ -327,12 +327,46 @@ export const scrubAdapterFailure = (text, { credentials = [], limit = MAX_REFUSA
|
|
|
327
327
|
* spawn-retry.js). The message still names the status so a human log says the
|
|
328
328
|
* same thing as the classifier's decision.
|
|
329
329
|
*/
|
|
330
|
+
/**
|
|
331
|
+
* The provider's own error code (`error.code`, then a top-level `code`), read
|
|
332
|
+
* from the body a tail carries: the structured body after a status, else the
|
|
333
|
+
* one JSON object embedded in prose (`unexpected status 404 Not Found: {…}`).
|
|
334
|
+
* It is a keep-list of one more named field, and narrower than the message:
|
|
335
|
+
* only a short identifier is kept, and one that echoes a credential this spawn
|
|
336
|
+
* was handed is dropped. Null when there is none (F178: the keep-list reduced
|
|
337
|
+
* `{"code":"model_not_found"}` to its message, so the code was lost).
|
|
338
|
+
*/
|
|
339
|
+
const PROVIDER_CODE_RE = /^[A-Za-z][\w.-]{0,63}$/;
|
|
340
|
+
export const providerCodeFrom = (text, { credentials = [] } = {}) => {
|
|
341
|
+
const raw = String(text ?? '');
|
|
342
|
+
const { body } = readStatusAndBody(raw.trim());
|
|
343
|
+
const candidates = [body];
|
|
344
|
+
const start = raw.indexOf('{');
|
|
345
|
+
const end = raw.lastIndexOf('}');
|
|
346
|
+
if (start >= 0 && end > start) candidates.push(raw.slice(start, end + 1));
|
|
347
|
+
for (const candidate of candidates) {
|
|
348
|
+
let parsed;
|
|
349
|
+
try {
|
|
350
|
+
parsed = JSON.parse(candidate);
|
|
351
|
+
} catch {
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) continue;
|
|
355
|
+
const code = parsed.error?.code ?? parsed.code;
|
|
356
|
+
if (typeof code !== 'string' || !PROVIDER_CODE_RE.test(code)) return null;
|
|
357
|
+
return redactKnownCredentials(code, credentials) === code ? code : null;
|
|
358
|
+
}
|
|
359
|
+
return null;
|
|
360
|
+
};
|
|
361
|
+
|
|
330
362
|
export const adapterFailure = (label, text, { credentials = [], exitCode = null, limit } = {}) => {
|
|
331
363
|
const { status, detail } = scrubAdapterFailure(text, { credentials, limit });
|
|
332
364
|
const code = exitCode === null ? '' : ` exited with code ${exitCode}`;
|
|
333
365
|
const named = status === null ? '' : ` (upstream ${status})`;
|
|
334
366
|
const error = new Error(`${label}${code}${named}${detail ? `: ${detail}` : ''}`);
|
|
335
367
|
if (status !== null) error.status = status;
|
|
368
|
+
const providerCode = providerCodeFrom(text, { credentials });
|
|
369
|
+
if (providerCode !== null) error.providerCode = providerCode;
|
|
336
370
|
return error;
|
|
337
371
|
};
|
|
338
372
|
|
package/package.json
CHANGED
package/skills/commonly/SKILL.md
CHANGED
|
@@ -71,11 +71,13 @@ mention text tells you what's being asked; read the surrounding context first.
|
|
|
71
71
|
- **`commonly_post_message(podId, content)`** posts to pod chat.
|
|
72
72
|
**`commonly_post_thread_comment`** replies under a specific post.
|
|
73
73
|
- **Say nothing when you have nothing to add.** If a message doesn't need you,
|
|
74
|
-
don't reply.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
don't reply. The exception is a person who addressed you directly: answer
|
|
75
|
+
them. When you stay silent, return the literal string `NO_REPLY` and nothing
|
|
76
|
+
else. Keep it out of real content: a reply that opens with it posts nothing,
|
|
77
|
+
and anywhere else it's stripped and the rest posts.
|
|
78
|
+
- **In a 1:1 DM** you're talking to one peer. With a person, reply to every
|
|
79
|
+
message. With another agent, stop when the exchange concludes. Talk directly,
|
|
80
|
+
and surface any shareable result to a team pod when you're done.
|
|
79
81
|
|
|
80
82
|
## Memory is the whole point — use it
|
|
81
83
|
|
package/src/commands/agent.js
CHANGED
|
@@ -45,7 +45,14 @@ import {
|
|
|
45
45
|
clearSessions,
|
|
46
46
|
wasEventHandled,
|
|
47
47
|
recordHandledEvent,
|
|
48
|
+
noticeDue,
|
|
49
|
+
recordNotice,
|
|
48
50
|
} from '../lib/session-store.js';
|
|
51
|
+
import {
|
|
52
|
+
MODEL_UNAVAILABLE_HINT_WINDOW_MS,
|
|
53
|
+
modelUnavailableFailure,
|
|
54
|
+
modelUnavailableHint,
|
|
55
|
+
} from '../lib/model-unavailable.js';
|
|
49
56
|
import {
|
|
50
57
|
buildRecycleBriefing,
|
|
51
58
|
idleMinutesSince,
|
|
@@ -1539,6 +1546,25 @@ export const answersInChannel = (entry) => {
|
|
|
1539
1546
|
&& payload.source !== 'dm' && !payload.dmKind;
|
|
1540
1547
|
};
|
|
1541
1548
|
|
|
1549
|
+
// Growth's wake-mode walk, 2026-11-06: a person's direct @ ended in NO_REPLY in
|
|
1550
|
+
// 5 of 12 runs, some after the seat had read the answer, and the batch's closing
|
|
1551
|
+
// line offered silence on every turn. A turn that answers a person drops that
|
|
1552
|
+
// exit: NO_REPLY stays only as the way to end after a reply posted through a
|
|
1553
|
+
// tool, so the wrapper doesn't post a second one. It needs the sender known to
|
|
1554
|
+
// be human, so an agent's @ and a message off the snapshot keep the old line. A
|
|
1555
|
+
// seat whose peer holds the claim keeps it too: the peer is answering them. So
|
|
1556
|
+
// do two chat.mention wakes where nobody typed the seat's name: an adjacent
|
|
1557
|
+
// reply and a new member's welcome, whose kernel frames offer NO_REPLY.
|
|
1558
|
+
const PERSON_ADDRESSED = '[A person addressed this to you directly: answer them in this turn, even if the answer '
|
|
1559
|
+
+ 'is short, is that you can\'t help, or repeats what another agent said. Do not leave them without a reply.]';
|
|
1560
|
+
const FINAL_TEXT_ANSWERS_A_PERSON = 'Your final text is posted to the pod unless it is exactly NO_REPLY. '
|
|
1561
|
+
+ 'Use NO_REPLY alone only after you posted your answer through a tool, with no summary.';
|
|
1562
|
+
|
|
1563
|
+
export const answersAPerson = (entry) => (
|
|
1564
|
+
entry?.trigger === 'human' && ADDRESSED_EVENT_TYPES.has(entry.event?.type) && !entry.peerFrame
|
|
1565
|
+
&& !entry.event.payload?.adjacentReply && !entry.event.payload?.welcomeWake
|
|
1566
|
+
);
|
|
1567
|
+
|
|
1542
1568
|
const extractPrompt = (event) => {
|
|
1543
1569
|
const p = event.payload || {};
|
|
1544
1570
|
if (PROMPT_EVENT_TYPES.has(event.type)) {
|
|
@@ -2268,6 +2294,35 @@ export const performRun = ({
|
|
|
2268
2294
|
}
|
|
2269
2295
|
};
|
|
2270
2296
|
|
|
2297
|
+
// F178: a provider that will not run this seat's model fails every turn the
|
|
2298
|
+
// same way, and until now only the seat log said so. Post one plain line in
|
|
2299
|
+
// the pod naming the model and where to change it, at most once per model
|
|
2300
|
+
// per seat per hour (persisted, so a restart does not re-post). The failure
|
|
2301
|
+
// itself is rethrown by the caller unchanged, so retry and ack behave as
|
|
2302
|
+
// before. A notice that fails to post is logged and tried on a later turn.
|
|
2303
|
+
const postModelUnavailableHint = async (error, hintPodId, configuredModel) => {
|
|
2304
|
+
const failure = modelUnavailableFailure(error, { fallbackModel: configuredModel });
|
|
2305
|
+
if (!failure || !hintPodId) return;
|
|
2306
|
+
const key = `model-unavailable:${failure.model || 'unknown'}`;
|
|
2307
|
+
try {
|
|
2308
|
+
if (!noticeDue(agentName, key, MODEL_UNAVAILABLE_HINT_WINDOW_MS)) return;
|
|
2309
|
+
const delivery = await deliverChatReply({
|
|
2310
|
+
client,
|
|
2311
|
+
podId: hintPodId,
|
|
2312
|
+
text: modelUnavailableHint(failure.model),
|
|
2313
|
+
limit: chatCharLimit,
|
|
2314
|
+
maxChunks: maxChatChunks,
|
|
2315
|
+
log,
|
|
2316
|
+
});
|
|
2317
|
+
if (!delivery.skipped && !delivery.refused) {
|
|
2318
|
+
recordNotice(agentName, key);
|
|
2319
|
+
log(`model unavailable hint posted (${failure.model || 'model not named'})`);
|
|
2320
|
+
}
|
|
2321
|
+
} catch (noticeError) {
|
|
2322
|
+
log(`model unavailable hint could not be posted: ${noticeError.message}`);
|
|
2323
|
+
}
|
|
2324
|
+
};
|
|
2325
|
+
|
|
2271
2326
|
const runTurnBody = async ({
|
|
2272
2327
|
event, eventPodId, prompt, preSpawnIds, snapshotMessages, claimKeeper, trigger, turn,
|
|
2273
2328
|
}) => {
|
|
@@ -2544,7 +2599,12 @@ export const performRun = ({
|
|
|
2544
2599
|
// Supervised or plain, a failure is thrown exactly as the adapter's own
|
|
2545
2600
|
// would be, so the run loop's classification and retry apply unchanged.
|
|
2546
2601
|
const spawnStartedAt = Date.now();
|
|
2547
|
-
|
|
2602
|
+
try {
|
|
2603
|
+
result = await turn.run(adapter, spawnPrompt, spawnCtx);
|
|
2604
|
+
} catch (spawnError) {
|
|
2605
|
+
await postModelUnavailableHint(spawnError, eventPodId, seatEnvironment?.model);
|
|
2606
|
+
throw spawnError;
|
|
2607
|
+
}
|
|
2548
2608
|
spawnDurationMs = Date.now() - spawnStartedAt;
|
|
2549
2609
|
spawnCompleted = true;
|
|
2550
2610
|
} finally {
|
|
@@ -2889,7 +2949,9 @@ export const performRun = ({
|
|
|
2889
2949
|
const BODY_LIMIT = batchLimit;
|
|
2890
2950
|
const wakeEntries = entries.filter((entry) => entry.event.deliveryMode !== 'digest');
|
|
2891
2951
|
const digestEntries = entries.filter((entry) => entry.event.deliveryMode === 'digest');
|
|
2892
|
-
const
|
|
2952
|
+
const shownEntries = wakeEntries.slice(0, BODY_LIMIT);
|
|
2953
|
+
const answersPerson = shownEntries.some(answersAPerson);
|
|
2954
|
+
const bodies = shownEntries.map((entry, index) => {
|
|
2893
2955
|
const messageId = entry.event.payload?.messageId;
|
|
2894
2956
|
const prefix = [
|
|
2895
2957
|
`Event ${index + 1}/${wakeEntries.length}: ${entry.event.type}`,
|
|
@@ -2900,14 +2962,15 @@ export const performRun = ({
|
|
|
2900
2962
|
+ '[This item is read-only context: a peer won its binding claim. Do not act on it.]\n'
|
|
2901
2963
|
: (entry.peerFrame ? `${entry.peerFrame}\n` : '');
|
|
2902
2964
|
const body = entry.prompt || '[No usable prompt was delivered for this item.]';
|
|
2965
|
+
const personLine = answersAPerson(entry) ? `\n${PERSON_ADDRESSED}` : '';
|
|
2903
2966
|
const channelLine = answersInChannel(entry) ? `\n${ANSWER_IN_CHANNEL}` : '';
|
|
2904
2967
|
const deliveryId = entry.event.payload?.deliveryId;
|
|
2905
2968
|
const checkpoint = typeof deliveryId === 'string' && deliveryId
|
|
2906
|
-
? `\n[After completed tool-side work or intentional NO_REPLY for only this item, call commonly_checkpoint_event(${JSON.stringify({
|
|
2969
|
+
? `\n[After ${answersAPerson(entry) ? 'your answer is posted through a tool' : 'completed tool-side work or intentional NO_REPLY'} for only this item, call commonly_checkpoint_event(${JSON.stringify({
|
|
2907
2970
|
eventId: String(entry.event._id), deliveryId,
|
|
2908
2971
|
})}). Checkpoint metadata is private runtime data; never post it in chat.]`
|
|
2909
2972
|
: '';
|
|
2910
|
-
return `${prefix}\n${claimContext}${body}${channelLine}${checkpoint}`;
|
|
2973
|
+
return `${prefix}\n${claimContext}${body}${personLine}${channelLine}${checkpoint}`;
|
|
2911
2974
|
});
|
|
2912
2975
|
const rollup = wakeEntries.find((entry) => entry.event.payload?.digestRollup)?.event.payload?.digestRollup;
|
|
2913
2976
|
const digestFrame = formatDigestFrame(digestEntries.map((entry) => entry.event), rollup);
|
|
@@ -2915,7 +2978,7 @@ export const performRun = ({
|
|
|
2915
2978
|
return [
|
|
2916
2979
|
`[Inbox batch: ${inboxCount} new event${inboxCount === 1 ? '' : 's'} in this pod. `
|
|
2917
2980
|
+ 'This is one turn: read the included items together, then decide what needs YOU.]',
|
|
2918
|
-
|
|
2981
|
+
`After tool-side work is committed (including any reply posted through a tool)${answersPerson ? ',' : ', or an intentional NO_REPLY,'} checkpoint that item with its supplied IDs. `
|
|
2919
2982
|
+ 'Release any held message claim first with the correct completed/declined outcome. '
|
|
2920
2983
|
+ 'Do not checkpoint a reply you are holding for final CLI output: the wrapper must post it before acknowledging that item. '
|
|
2921
2984
|
+ 'Never checkpoint unfinished work. Only a successful checkpoint prevents replay after timeout. '
|
|
@@ -2925,8 +2988,12 @@ export const performRun = ({
|
|
|
2925
2988
|
...(omitted > 0
|
|
2926
2989
|
? [`[${omitted} more event${omitted === 1 ? '' : 's'} arrived. Their count is real; pull pod context if needed.]`]
|
|
2927
2990
|
: []),
|
|
2928
|
-
|
|
2929
|
-
|
|
2991
|
+
answersPerson
|
|
2992
|
+
? 'Do not narrate the inbox. Answer every item marked as a person addressing you directly. '
|
|
2993
|
+
+ 'For anything else here, post only an action or a materially useful response. '
|
|
2994
|
+
+ FINAL_TEXT_ANSWERS_A_PERSON
|
|
2995
|
+
: 'Do not narrate the inbox. Post only an action or a materially useful response; otherwise return NO_REPLY. '
|
|
2996
|
+
+ FINAL_TEXT_IS_POSTED,
|
|
2930
2997
|
].join('\n\n');
|
|
2931
2998
|
};
|
|
2932
2999
|
|
|
@@ -3212,6 +3279,7 @@ export const performRun = ({
|
|
|
3212
3279
|
// determine its admission or count as the trigger that woke the seat.
|
|
3213
3280
|
const wakingEntries = activeEntries.filter((entry) => entry.event.deliveryMode !== 'digest');
|
|
3214
3281
|
const triggers = wakingEntries.map((entry) => classifyTrigger(entry.event, preSpawn));
|
|
3282
|
+
wakingEntries.forEach((entry, index) => { entry.trigger = triggers[index]; });
|
|
3215
3283
|
const trigger = triggers.includes('human') ? 'human'
|
|
3216
3284
|
: (triggers.includes('agent') ? 'agent' : 'unknown');
|
|
3217
3285
|
if (trigger === 'human') cascadeGovernor.record(eventPodId, trigger);
|
|
@@ -85,6 +85,7 @@ import {
|
|
|
85
85
|
normalizeSandboxTrust,
|
|
86
86
|
} from '../environment.js';
|
|
87
87
|
import { detectBwrap, wrapArgvWithBwrap } from '../sandbox/bwrap.js';
|
|
88
|
+
import { holdWorkspaceRealpath, workspacePinDir } from '../sandbox/workspace-pin.js';
|
|
88
89
|
import { PUBLIC_SANDBOX_MODES, resolvePublicSandboxMode } from '../sandbox/mode.js';
|
|
89
90
|
import { UNSANDBOXED_FLAG } from '../sandbox/host-check.js';
|
|
90
91
|
import {
|
|
@@ -1458,6 +1459,10 @@ const prepareArgv = async (innerArgv, ctx) => {
|
|
|
1458
1459
|
// link refuses the turn (fail-closed). A workspace seat's folder is the
|
|
1459
1460
|
// operator's own choice, which may be a link, and keeps following it.
|
|
1460
1461
|
pinWorkspace: sandboxTrust === 'public',
|
|
1462
|
+
// F200: a workspace seat's folder is held to the realpath recorded on
|
|
1463
|
+
// its first turn, and that record is never writable from the jail.
|
|
1464
|
+
expectedWorkspaceRealpath: ctx.workspaceRealpath || null,
|
|
1465
|
+
denyWritePaths: ctx.workspacePinDirs || [],
|
|
1461
1466
|
executablePath: claudeBin,
|
|
1462
1467
|
statePath: ctx.publicClaudeState.statePath,
|
|
1463
1468
|
mcpConfigDir: ctx.mcpConfigDir,
|
|
@@ -1524,6 +1529,10 @@ const prepareArgv = async (innerArgv, ctx) => {
|
|
|
1524
1529
|
const { statePath } = ctx.publicClaudeState;
|
|
1525
1530
|
const wrapped = wrapArgvWithBwrap([claudeBin, ...innerArgv], env, {
|
|
1526
1531
|
workspacePath: ctx.cwd,
|
|
1532
|
+
// F200: bwrap resolves a bind source when the jail starts, after the
|
|
1533
|
+
// check, so the checked realpath is the source, mounted at the path the
|
|
1534
|
+
// seat was given.
|
|
1535
|
+
workspaceSource: ctx.workspaceRealpath || ctx.cwd,
|
|
1527
1536
|
workspaceReadOnly: !grants.includes('write'),
|
|
1528
1537
|
readOnlyWorkspaceEntries: ['.git'],
|
|
1529
1538
|
homePath: statePath,
|
|
@@ -1720,6 +1729,14 @@ export default {
|
|
|
1720
1729
|
&& resolvePublicSandboxMode(ctx.environment?.sandbox) === 'bwrap';
|
|
1721
1730
|
const workspaceBwrapSandbox = jailed && ctx.environment?.sandbox?.trust === 'workspace'
|
|
1722
1731
|
&& resolvePublicSandboxMode(ctx.environment?.sandbox) === 'bwrap';
|
|
1732
|
+
// F200: a jailed workspace seat's folder must still resolve where it did
|
|
1733
|
+
// on the seat's first turn, or a link the seat left in its place would
|
|
1734
|
+
// carry this turn's grant elsewhere. The record sits beside the seat's
|
|
1735
|
+
// state folder, the one bwrapClaudeStatePath names for both jails.
|
|
1736
|
+
const heldWorkspace = ctx.environment?.sandbox?.trust === 'workspace' && Boolean(ctx.cwd)
|
|
1737
|
+
&& (publicNativeSandbox || workspaceBwrapSandbox);
|
|
1738
|
+
const workspacePinDirs = heldWorkspace ? [workspacePinDir(bwrapClaudeStatePath(ctx))] : [];
|
|
1739
|
+
let workspaceRealpath = null;
|
|
1723
1740
|
// The proxy's address and per-turn token, never the host's key.
|
|
1724
1741
|
const withProvider = (env) => {
|
|
1725
1742
|
if (providerProxy) {
|
|
@@ -1733,6 +1750,11 @@ export default {
|
|
|
1733
1750
|
...spawnCredentials(spawnContext), providerProxy?.token,
|
|
1734
1751
|
].filter(Boolean);
|
|
1735
1752
|
try {
|
|
1753
|
+
// Checked (and recorded, the first time) before the state is prepared
|
|
1754
|
+
// or anything is spawned.
|
|
1755
|
+
if (heldWorkspace) {
|
|
1756
|
+
workspaceRealpath = await holdWorkspaceRealpath({ cwd: ctx.cwd, statePath: bwrapClaudeStatePath(ctx) });
|
|
1757
|
+
}
|
|
1736
1758
|
// Trust is normalized at entry (legacy `internal` reads as public). The
|
|
1737
1759
|
// MCP policy follows trust alone, whatever confines the seat: a public
|
|
1738
1760
|
// bwrap seat needs a host-prepared build exactly as a Seatbelt one does
|
|
@@ -1854,6 +1876,8 @@ export default {
|
|
|
1854
1876
|
publicClaudeState,
|
|
1855
1877
|
publicSkillArgs,
|
|
1856
1878
|
providerProxyPort: proxyPort(providerProxy),
|
|
1879
|
+
workspaceRealpath,
|
|
1880
|
+
workspacePinDirs,
|
|
1857
1881
|
claudeEnv,
|
|
1858
1882
|
};
|
|
1859
1883
|
const { cmd, args, env, childHome } = await prepareArgv(baseArgs, spawnCtx);
|