@commonlyai/cli 0.1.249 → 0.1.251
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 +43 -4
- package/src/lib/adapters/codex.js +7 -1
- package/src/lib/adapters/goose.js +3 -2
- package/src/lib/native-runtime-inventory.js +1 -1
- package/src/lib/public-withheld-tools.js +4 -0
- package/src/lib/reply-receipt.js +2 -0
- package/src/lib/seat-runtime-controls.js +61 -0
package/package.json
CHANGED
package/src/commands/agent.js
CHANGED
|
@@ -138,6 +138,7 @@ import {
|
|
|
138
138
|
resolveCascadeSettings,
|
|
139
139
|
} from '../lib/enforcement.js';
|
|
140
140
|
import { buildReplyReceipt } from '../lib/reply-receipt.js';
|
|
141
|
+
import { savedRuntimeControls, withSavedRuntimeControls, effortRefusedByDevice } from '../lib/seat-runtime-controls.js';
|
|
141
142
|
|
|
142
143
|
const isPodFocusDiagnostic = (error) => (
|
|
143
144
|
typeof error?.code === 'string'
|
|
@@ -1662,6 +1663,10 @@ export const performRun = ({
|
|
|
1662
1663
|
// The agent to @mention when the model provider refuses a request's content
|
|
1663
1664
|
// (lib/content-refusal.js). Null: the refusal notice names no one.
|
|
1664
1665
|
reportRuntime = false,
|
|
1666
|
+
// D247: a listener seat (no daemon) reads the model and effort its owner
|
|
1667
|
+
// saved on the server before each turn. Off for daemon seats, whose daemon
|
|
1668
|
+
// projects the same values into `environment`.
|
|
1669
|
+
readSavedControls = false,
|
|
1665
1670
|
resolveOwnProviderKey = null,
|
|
1666
1671
|
runtimeReportClient = null,
|
|
1667
1672
|
refusalHandoff = null,
|
|
@@ -1765,6 +1770,7 @@ export const performRun = ({
|
|
|
1765
1770
|
const runtimeInventoryPromise = reportRuntime ? Promise.resolve(adapter.inventory?.()).then((value) => value || { models: null, efforts: [] })
|
|
1766
1771
|
.catch(() => ({ models: null, efforts: [] })) : Promise.resolve(null);
|
|
1767
1772
|
let seatEnvironment = requestedSeatEnvironment;
|
|
1773
|
+
let lastSavedControls = null;
|
|
1768
1774
|
// OpenCode retains tool-call IDs in its resumed history. A Gemini proxy
|
|
1769
1775
|
// marks those IDs with signature references, so changing providers must
|
|
1770
1776
|
// start a fresh session before another upstream can receive them.
|
|
@@ -1848,7 +1854,43 @@ export const performRun = ({
|
|
|
1848
1854
|
// a conversation that read the workspace, whatever claude's resume would
|
|
1849
1855
|
// find from another folder.
|
|
1850
1856
|
let lastPlacementReason = null;
|
|
1857
|
+
// D247: the model and effort this turn spawns with. A listener seat reads
|
|
1858
|
+
// its saved controls first; then an effort is dropped only when the device
|
|
1859
|
+
// listed its levels and this one is not among them.
|
|
1860
|
+
let savedControlsNoticeShown = false;
|
|
1861
|
+
const refreshSeatEnvironment = async () => {
|
|
1862
|
+
const inventory = await runtimeInventoryPromise;
|
|
1863
|
+
let desiredEnvironment = requestedSeatEnvironment;
|
|
1864
|
+
if (readSavedControls) {
|
|
1865
|
+
try {
|
|
1866
|
+
const identity = await client.get('/api/agents/runtime/installations', {}, {
|
|
1867
|
+
signal: AbortSignal.timeout(5000),
|
|
1868
|
+
});
|
|
1869
|
+
lastSavedControls = savedRuntimeControls({
|
|
1870
|
+
installations: identity?.installations, podId, instanceId,
|
|
1871
|
+
...(identity && 'runtimeSourcePodId' in identity ? { runtimeSourcePodId: identity.runtimeSourcePodId } : {}),
|
|
1872
|
+
});
|
|
1873
|
+
} catch { /* keep the last controls read; a failed read changes nothing */ }
|
|
1874
|
+
desiredEnvironment = withSavedRuntimeControls(requestedSeatEnvironment, lastSavedControls);
|
|
1875
|
+
// A record with no environment (from before attach wrote one) isn't
|
|
1876
|
+
// given one silently. `agent config` writes one to the record, and from
|
|
1877
|
+
// then on saved controls apply. Say so once, with the command.
|
|
1878
|
+
if (!requestedSeatEnvironment && lastSavedControls && !savedControlsNoticeShown) {
|
|
1879
|
+
savedControlsNoticeShown = true;
|
|
1880
|
+
const flag = (name, value) => (value && /^[A-Za-z0-9._:/-]+$/.test(value) ? ` --${name} ${value}` : '');
|
|
1881
|
+
const flags = `${flag('model', lastSavedControls.model)}${flag('effort', lastSavedControls.effort)}` || ' --model <model>';
|
|
1882
|
+
log(`${agentName} has no saved environment on this computer, so the model and effort saved in Commonly `
|
|
1883
|
+
+ `don't apply to it yet. Run once: commonly agent config ${agentName}${flags}`);
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
// Dropped only when the device listed its levels and this one is not
|
|
1887
|
+
// among them; with nothing reported the harness decides (D247).
|
|
1888
|
+
seatEnvironment = reportRuntime && desiredEnvironment
|
|
1889
|
+
&& effortRefusedByDevice(inventory, desiredEnvironment.effort)
|
|
1890
|
+
? { ...desiredEnvironment, effort: undefined } : desiredEnvironment;
|
|
1891
|
+
};
|
|
1851
1892
|
const placeTurn = async () => {
|
|
1893
|
+
await refreshSeatEnvironment();
|
|
1852
1894
|
if (seatEnvironment?.sandbox?.trust !== 'workspace') {
|
|
1853
1895
|
return { environment: seatEnvironment, cwd: agentCwd, binding: sessionBinding };
|
|
1854
1896
|
}
|
|
@@ -1879,10 +1921,6 @@ export const performRun = ({
|
|
|
1879
1921
|
const batchLimit = Math.min(50, Math.max(1, Number(inboxBatchLimit) || 10));
|
|
1880
1922
|
|
|
1881
1923
|
const processEvent = async (event) => {
|
|
1882
|
-
const inventory = await runtimeInventoryPromise;
|
|
1883
|
-
if (reportRuntime && requestedSeatEnvironment && !inventory?.efforts.includes(requestedSeatEnvironment.effort)) {
|
|
1884
|
-
seatEnvironment = { ...requestedSeatEnvironment, effort: undefined };
|
|
1885
|
-
}
|
|
1886
1924
|
const eventPodId = event.podId || podId;
|
|
1887
1925
|
const prompt = extractPrompt(event);
|
|
1888
1926
|
if (!prompt || !eventPodId) {
|
|
@@ -4451,6 +4489,7 @@ Docs:
|
|
|
4451
4489
|
resolveOwnProviderKey: createOwnKeyResolver({ instanceUrl: record.instanceUrl,
|
|
4452
4490
|
machineId: record.machineId, agentName: record.agentName, instanceId: record.instanceId }),
|
|
4453
4491
|
reportRuntime: Boolean(record.machineId || process.env.COMMONLY_MANAGED_RUNNER === '1'),
|
|
4492
|
+
readSavedControls: !record.machineId && process.env.COMMONLY_MANAGED_RUNNER !== '1',
|
|
4454
4493
|
spawnCredentialTtlSeconds: resolveSpawnTtlSeconds(process.env),
|
|
4455
4494
|
refusalHandoff: opts.refusalHandoff || null,
|
|
4456
4495
|
log: (line) => console.log(`${stamp()} [${name}] ${line}`),
|
|
@@ -968,7 +968,13 @@ export default {
|
|
|
968
968
|
// came in with > null. The wrapper persists whichever non-null value
|
|
969
969
|
// we return so subsequent turns hit `codex exec resume <id>`.
|
|
970
970
|
const newSessionId = threadId || ctx.sessionId || null;
|
|
971
|
-
|
|
971
|
+
// D247: the reply receipt names the model and effort this spawn passed
|
|
972
|
+
// (`--model`, `model_reasoning_effort`); codex's own stream does not
|
|
973
|
+
// restate them.
|
|
974
|
+
const effort = ctx.environment?.effort;
|
|
975
|
+
const stats = { ...(seatModel ? { model: String(seatModel) } : {}),
|
|
976
|
+
...(typeof effort === 'string' && effort ? { effort } : {}) };
|
|
977
|
+
return { text, newSessionId, ...(Object.keys(stats).length ? { stats } : {}) };
|
|
972
978
|
} finally {
|
|
973
979
|
try { await rm(dir, { recursive: true, force: true }); } catch { /* ignore */ }
|
|
974
980
|
}
|
|
@@ -43,8 +43,9 @@ const templateLiteral = (value) => {
|
|
|
43
43
|
// attach_file reads this process's filesystem, including its credential file.
|
|
44
44
|
// catch_up is left out too: it moves the read cursor past history unread, so a
|
|
45
45
|
// public seat past 50 unseen falls back to continueAnyway, which it keeps.
|
|
46
|
-
// Self-install
|
|
47
|
-
// public seat (F118, PUBLIC_ONLY_WITHHELD_TOOLS);
|
|
46
|
+
// Self-install, the memory writes (log_cycle included) and delete_message are
|
|
47
|
+
// left out on every public seat (F118, F141, PUBLIC_ONLY_WITHHELD_TOOLS);
|
|
48
|
+
// reading memory stays.
|
|
48
49
|
export const PUBLIC_GOOSE_TOOLS = Object.freeze([
|
|
49
50
|
'commonly_get_started', 'commonly_post_message', 'commonly_claim_message',
|
|
50
51
|
'commonly_release_claim', 'commonly_get_messages', 'commonly_get_context',
|
|
@@ -11,7 +11,7 @@ export const claudeEffortsFromHelp = (help) => {
|
|
|
11
11
|
};
|
|
12
12
|
export const codexModelsFromCache = (cache) => {
|
|
13
13
|
const models = Array.isArray(cache?.models) ? cache.models.filter((row) => typeof row.slug === 'string'
|
|
14
|
-
&& row.slug.length > 0 && row.slug.length <= 256 && row.visibility !== 'hidden') : [];
|
|
14
|
+
&& row.slug.length > 0 && row.slug.length <= 256 && row.visibility !== 'hidden' && row.visibility !== 'hide') : [];
|
|
15
15
|
const levels = models.map((row) => (Array.isArray(row.supported_reasoning_levels)
|
|
16
16
|
? row.supported_reasoning_levels.flatMap((level) => typeof level.effort === 'string' ? [level.effort] : []) : []));
|
|
17
17
|
return { models: models.length ? models.map((row) => row.slug) : null,
|
|
@@ -15,11 +15,15 @@ export const PUBLIC_WITHHELD_TOOLS = Object.freeze(['commonly_attach_file', 'com
|
|
|
15
15
|
// `cycles[]` through POST /api/agents/runtime/memory/sync. Reading memory
|
|
16
16
|
// (commonly_read_agent_memory, and the long_term the wrapper puts in the
|
|
17
17
|
// prompt) stays offered.
|
|
18
|
+
// commonly_delete_message (F141): a stranger-steered seat could delete its own
|
|
19
|
+
// replies to an injection, which are the evidence of what the attack achieved.
|
|
20
|
+
// A workspace seat keeps it.
|
|
18
21
|
export const PUBLIC_ONLY_WITHHELD_TOOLS = Object.freeze([
|
|
19
22
|
'commonly_self_install_into_pod',
|
|
20
23
|
'commonly_write_agent_memory',
|
|
21
24
|
'commonly_save_my_memory',
|
|
22
25
|
'commonly_log_cycle',
|
|
26
|
+
'commonly_delete_message',
|
|
23
27
|
]);
|
|
24
28
|
|
|
25
29
|
// Everything a public seat is not offered. Codex, OpenCode, Qwen and Goose
|
package/src/lib/reply-receipt.js
CHANGED
|
@@ -43,6 +43,8 @@ export const buildReplyReceipt = ({ adapterName, stats = {}, durationMs } = {})
|
|
|
43
43
|
// carries the account or project it runs in; that is not this reply's to
|
|
44
44
|
// publish, so such a model id is left out.
|
|
45
45
|
if (isName(stats?.model) && !/^arn:|(^|\/)projects\//i.test(stats.model)) receipt.model = stats.model;
|
|
46
|
+
// D247: the effort level the adapter passed, as a bare level name.
|
|
47
|
+
if (isName(stats?.effort) && /^[a-z0-9][a-z0-9._-]{0,19}$/i.test(stats.effort)) receipt.effort = stats.effort;
|
|
46
48
|
if (isCount(stats?.turns)) receipt.turns = stats.turns;
|
|
47
49
|
if (Array.isArray(stats?.tools)) {
|
|
48
50
|
const tools = stats.tools.filter(isName);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// D247: the model and effort a seat spawns with.
|
|
2
|
+
//
|
|
3
|
+
// Two rules live here so the run loop and its tests share them:
|
|
4
|
+
//
|
|
5
|
+
// 1. A listener seat (`agent run` with no daemon behind it) reads the model and
|
|
6
|
+
// effort its owner saved in Settings or on the add page from
|
|
7
|
+
// GET /api/agents/runtime/installations before each turn. A saved value
|
|
8
|
+
// replaces the one in the local record; an absent one leaves it alone, so an
|
|
9
|
+
// older server changes nothing.
|
|
10
|
+
// 2. An effort is dropped only when the device reported a NON-EMPTY list of
|
|
11
|
+
// levels that leaves it out. A device that reported nothing says nothing
|
|
12
|
+
// about the level, so the level is passed through and the harness decides.
|
|
13
|
+
|
|
14
|
+
const isControl = (value) => typeof value === 'string' && value.length > 0 && value.length <= 256;
|
|
15
|
+
|
|
16
|
+
const controlsOf = (row) => {
|
|
17
|
+
const controls = {};
|
|
18
|
+
if (isControl(row.runtimeControls.model)) controls.model = row.runtimeControls.model;
|
|
19
|
+
if (isControl(row.runtimeControls.effort)) controls.effort = row.runtimeControls.effort;
|
|
20
|
+
return Object.keys(controls).length ? controls : null;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The saved controls for this seat, or null when none are reported.
|
|
25
|
+
*
|
|
26
|
+
* A server that names `runtimeSourcePodId` (the installation Settings reads)
|
|
27
|
+
* is followed exactly: that row's controls, or null when it has none or the
|
|
28
|
+
* server names no source. An older server names none, and the seat reads its
|
|
29
|
+
* own pod's row, then any row of this instance that has controls.
|
|
30
|
+
*/
|
|
31
|
+
export const savedRuntimeControls = ({ installations, podId, instanceId, runtimeSourcePodId } = {}) => {
|
|
32
|
+
if (!Array.isArray(installations)) return null;
|
|
33
|
+
const rows = installations.filter((row) => row?.type === 'installation'
|
|
34
|
+
&& row.runtimeControls && typeof row.runtimeControls === 'object');
|
|
35
|
+
const wantedInstance = String(instanceId || 'default');
|
|
36
|
+
if (runtimeSourcePodId !== undefined) {
|
|
37
|
+
const source = runtimeSourcePodId === null ? null
|
|
38
|
+
: rows.find((entry) => String(entry.podId || '') === String(runtimeSourcePodId)
|
|
39
|
+
&& String(entry.instanceId || 'default') === wantedInstance);
|
|
40
|
+
return source ? controlsOf(source) : null;
|
|
41
|
+
}
|
|
42
|
+
// /installations returns runtimeControls on every row, `{}` when nothing is
|
|
43
|
+
// saved, so both matches require a value: an empty row in this pod must not
|
|
44
|
+
// hide the controls saved on the identity's other installation.
|
|
45
|
+
const hasControls = (entry) => isControl(entry.runtimeControls.model) || isControl(entry.runtimeControls.effort);
|
|
46
|
+
const row = rows.find((entry) => String(entry.podId || '') === String(podId || '')
|
|
47
|
+
&& String(entry.instanceId || 'default') === wantedInstance && hasControls(entry))
|
|
48
|
+
|| rows.find((entry) => String(entry.instanceId || 'default') === wantedInstance && hasControls(entry));
|
|
49
|
+
return row ? controlsOf(row) : null;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** The environment with saved controls laid over it. A null environment stays null. */
|
|
53
|
+
export const withSavedRuntimeControls = (environment, controls) => {
|
|
54
|
+
if (!environment || typeof environment !== 'object' || !controls) return environment;
|
|
55
|
+
return { ...environment, ...controls };
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** True only when the device listed its effort levels and this one is not among them. */
|
|
59
|
+
export const effortRefusedByDevice = (inventory, effort) => Boolean(effort)
|
|
60
|
+
&& Array.isArray(inventory?.efforts) && inventory.efforts.length > 0
|
|
61
|
+
&& !inventory.efforts.includes(effort);
|