@commonlyai/cli 0.1.283 → 0.1.285
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 +38 -2
- package/src/commands/daemon.js +1 -1
- package/src/lib/adapters/pi-shell-env.mjs +1 -1
- package/src/lib/adapters/pi.js +112 -12
- package/src/lib/daemon-service.js +1 -1
- package/src/lib/environment.js +5 -1
- package/src/lib/sandbox/windows-unsandboxed.js +8 -0
package/package.json
CHANGED
package/src/commands/agent.js
CHANGED
|
@@ -105,7 +105,7 @@ import { detectBwrap } from '../lib/sandbox/bwrap.js';
|
|
|
105
105
|
import { resolvePublicSandboxMode } from '../lib/sandbox/mode.js';
|
|
106
106
|
import { UNSANDBOXED_FLAG, hostSandboxRefusal, windowsSandboxMessage } from '../lib/sandbox/host-check.js';
|
|
107
107
|
import {
|
|
108
|
-
CODEX_UNSANDBOXED_NOTICE, UNSANDBOXED_NOTICE, codexUnconfinedForRun, hostUnconfinedForRun, runOptedInUnsandboxed,
|
|
108
|
+
CODEX_UNSANDBOXED_NOTICE, UNSANDBOXED_NOTICE, codexUnconfinedForRun, hostReportFailureMessage, hostUnconfinedForRun, runOptedInUnsandboxed,
|
|
109
109
|
unsandboxedFlagRefusal,
|
|
110
110
|
} from '../lib/sandbox/windows-unsandboxed.js';
|
|
111
111
|
import { prepareMcpBeforeFirstPoll } from '../lib/mcp-first-run.js';
|
|
@@ -1093,6 +1093,17 @@ export const setWakeOnMessage = async ({ client, record, enabled }) => {
|
|
|
1093
1093
|
return { agentName: record.agentName, podId: record.podId, instanceId, enabled: Boolean(enabled) };
|
|
1094
1094
|
};
|
|
1095
1095
|
|
|
1096
|
+
/** Lift the mark an unsandboxed run left on the seat. Only its owner's login can. */
|
|
1097
|
+
export const clearUnsandboxedMark = async ({ client, record }) => {
|
|
1098
|
+
if (!record?.podId || !record?.agentName) {
|
|
1099
|
+
throw new Error('token record is missing podId/agentName — re-attach the agent');
|
|
1100
|
+
}
|
|
1101
|
+
const instanceId = record.instanceId || 'default';
|
|
1102
|
+
const path = `/api/registry/pods/${encodeURIComponent(record.podId)}/agents/${encodeURIComponent(record.agentName)}/host-unconfined`;
|
|
1103
|
+
const result = await client.del(`${path}?instanceId=${encodeURIComponent(instanceId)}`);
|
|
1104
|
+
return { agentName: record.agentName, machineUnconfined: result?.machineUnconfined === true };
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1096
1107
|
/**
|
|
1097
1108
|
* Update the server-side configuration for an existing local agent. The
|
|
1098
1109
|
* registry PATCH route already fans this change out to accessible pod peers;
|
|
@@ -5252,7 +5263,7 @@ Docs:
|
|
|
5252
5263
|
try {
|
|
5253
5264
|
await seatClient.post('/api/agents/runtime/host-unconfined', {});
|
|
5254
5265
|
} catch (err) {
|
|
5255
|
-
console.error(`${stamp()} [${name}]
|
|
5266
|
+
console.error(`${stamp()} [${name}] ${hostReportFailureMessage(err)}`);
|
|
5256
5267
|
process.exit(1);
|
|
5257
5268
|
}
|
|
5258
5269
|
}
|
|
@@ -5706,6 +5717,31 @@ Use --local to find the name you'd pass to 'agent run' or 'agent detach'.
|
|
|
5706
5717
|
}
|
|
5707
5718
|
});
|
|
5708
5719
|
|
|
5720
|
+
// ── clear-unsandboxed ─────────────────────────────────────────────────────
|
|
5721
|
+
agent
|
|
5722
|
+
.command('clear-unsandboxed <name>')
|
|
5723
|
+
.description('After moving an agent to a sandboxed host, let it use grants again (needs your login, not its token)')
|
|
5724
|
+
.option('--instance <url>', 'Target Commonly instance')
|
|
5725
|
+
.action(async (name, opts) => {
|
|
5726
|
+
const record = loadAgentToken(name);
|
|
5727
|
+
if (!record) {
|
|
5728
|
+
console.error(`No token file for '${name}' — is it attached on this machine? (commonly agent list --local)`);
|
|
5729
|
+
process.exit(1);
|
|
5730
|
+
}
|
|
5731
|
+
const instanceUrl = resolveInstanceUrl(opts.instance || record.instanceUrl);
|
|
5732
|
+
const token = getToken(opts.instance || record.instanceUrl);
|
|
5733
|
+
if (!token) { console.error('Not logged in. Run: commonly login'); process.exit(1); }
|
|
5734
|
+
const client = createClient({ instance: instanceUrl, token });
|
|
5735
|
+
try {
|
|
5736
|
+
const result = await clearUnsandboxedMark({ client, record });
|
|
5737
|
+
console.log(`✓ Cleared for ${result.agentName}. Running it with --unsandboxed marks it again.`);
|
|
5738
|
+
if (result.machineUnconfined) console.log(' Its machine reports no sandbox, so grants stay refused while it runs there.');
|
|
5739
|
+
} catch (err) {
|
|
5740
|
+
console.error(`Failed: ${err.message}`);
|
|
5741
|
+
process.exit(1);
|
|
5742
|
+
}
|
|
5743
|
+
});
|
|
5744
|
+
|
|
5709
5745
|
// ── heartbeat ─────────────────────────────────────────────────────────────
|
|
5710
5746
|
agent
|
|
5711
5747
|
.command('heartbeat <name>')
|
package/src/commands/daemon.js
CHANGED
|
@@ -604,7 +604,7 @@ Examples:
|
|
|
604
604
|
// unaffected, and refusing to start would turn one missing key into a
|
|
605
605
|
// whole-machine outage.
|
|
606
606
|
for (const name of missingProviderKeys({ names: providerKeyEnvNames() })) {
|
|
607
|
-
stampLog(`WARNING: ${name} is not set in this environment — a seat
|
|
607
|
+
stampLog(`WARNING: ${name} is not set in this environment — a seat that relies on it will fail to start (one with its own provider.keyFile won't). Export it and re-run: commonly daemon install (docs/agents/daemon-service-environment.md)`);
|
|
608
608
|
}
|
|
609
609
|
// TASK-660: the daemon outlives many publishes, so say once at start-up
|
|
610
610
|
// when it is stale. Not awaited: supervision never waits on the registry.
|
|
@@ -9,7 +9,7 @@ export default function commonlyShellEnvironment(pi) {
|
|
|
9
9
|
const providerKey = process.env.COMMONLY_PI_PROVIDER_KEY_ENV;
|
|
10
10
|
if (!providerKey) throw new Error('pi adapter: missing provider key environment name');
|
|
11
11
|
const excluded = new Set([
|
|
12
|
-
providerKey, 'COMMONLY_LITELLM_KEY', 'COMMONLY_PI_PROVIDER_KEY_ENV',
|
|
12
|
+
providerKey, 'COMMONLY_LITELLM_KEY', 'COMMONLY_PI_PROVIDER_KEY', 'COMMONLY_PI_PROVIDER_KEY_ENV',
|
|
13
13
|
].map((key) => key.toUpperCase()));
|
|
14
14
|
const cleanEnv = (env) => {
|
|
15
15
|
const clean = { ...env };
|
package/src/lib/adapters/pi.js
CHANGED
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
* - Provider config is a per-seat models.json under
|
|
24
24
|
* `~/.commonly/pi-homes/<hash>/agent`, pointed at by
|
|
25
25
|
* PI_CODING_AGENT_DIR — never the operator's ~/.pi. The API key is an
|
|
26
|
-
* env reference (`$COMMONLY_LITELLM_KEY
|
|
26
|
+
* env reference (`$COMMONLY_LITELLM_KEY`, or `$COMMONLY_PI_PROVIDER_KEY`
|
|
27
|
+
* for a seat with its own provider.keyFile), so it never lands on disk.
|
|
27
28
|
* - Commonly's tools reach pi through pi-commonly-mcp.mjs, an extension
|
|
28
29
|
* that speaks MCP over stdio to every server in `environment.mcp` and
|
|
29
30
|
* registers each tool. The token rides through the child env, never argv
|
|
@@ -47,9 +48,11 @@ import { resolveOnPath } from '../resolve-on-path.js';
|
|
|
47
48
|
import { spawn as childSpawn, spawnSync } from 'child_process';
|
|
48
49
|
import { createHash, randomUUID } from 'crypto';
|
|
49
50
|
import { existsSync, readFileSync, realpathSync, rmSync } from 'fs';
|
|
50
|
-
import { mkdir, readdir, writeFile } from 'fs/promises';
|
|
51
|
+
import { mkdir, readdir, readFile, writeFile } from 'fs/promises';
|
|
51
52
|
import { homedir } from 'os';
|
|
52
|
-
import {
|
|
53
|
+
import {
|
|
54
|
+
dirname, isAbsolute, join, relative, sep,
|
|
55
|
+
} from 'path';
|
|
53
56
|
import { fileURLToPath } from 'url';
|
|
54
57
|
import {
|
|
55
58
|
adapterFailure,
|
|
@@ -57,14 +60,16 @@ import {
|
|
|
57
60
|
spawnCredentials,
|
|
58
61
|
} from '../upstream-refusal.js';
|
|
59
62
|
import { buildMemoryPreamble } from '../memory-bridge.js';
|
|
60
|
-
import {
|
|
63
|
+
import {
|
|
64
|
+
effectiveSandboxTrust, normalizeSandboxTrust, refuseWorkspaceTrust, validateEnvironmentSpec,
|
|
65
|
+
} from '../environment.js';
|
|
61
66
|
import { GRANT_BROKER_PUBLIC_ONLY_REFUSAL, isGrantBrokerUrl } from './pi-mcp-client.mjs';
|
|
62
67
|
import { deliverSeatCredential, withholdRuntimeCredential } from '../mcp-credential-delivery.js';
|
|
63
68
|
import { prepareMcpSpawn, publicMcpUnavailableError, selectedMcpVersionDir } from '../mcp-home.js';
|
|
64
69
|
import { removeCredentialFile, writeCredentialFile } from '../credential-file.js';
|
|
65
70
|
import { resolvePublicSandboxMode } from '../sandbox/mode.js';
|
|
66
71
|
import { wrapArgvWithSeatbelt } from '../sandbox/seatbelt.js';
|
|
67
|
-
import { startProviderProxy } from '../provider-proxy.js';
|
|
72
|
+
import { resolveProviderKeyFile, startProviderProxy } from '../provider-proxy.js';
|
|
68
73
|
import { PUBLIC_SEAT_WITHHELD_TOOLS } from '../public-withheld-tools.js';
|
|
69
74
|
|
|
70
75
|
const DEFAULT_TIMEOUT_MS = (() => {
|
|
@@ -84,6 +89,21 @@ export const DEFAULT_PROVIDER = Object.freeze({
|
|
|
84
89
|
apiKeyEnv: 'COMMONLY_LITELLM_KEY',
|
|
85
90
|
});
|
|
86
91
|
|
|
92
|
+
// What a seat with its own `provider.keyFile` calls its key inside pi. A private
|
|
93
|
+
// turn holds the key here, and pi-shell-env.mjs keeps it out of pi's shells. A
|
|
94
|
+
// public turn holds the proxy's token here. models.json holds only `$` + this.
|
|
95
|
+
const OWN_KEY_ENV = 'COMMONLY_PI_PROVIDER_KEY';
|
|
96
|
+
|
|
97
|
+
// The shared provider shape's `api` (environment.js PROVIDER_APIS) in pi's own
|
|
98
|
+
// words. Both measured on pi 0.84.1 against a local stub: `openai-completions`
|
|
99
|
+
// calls `<baseURL>/chat/completions` with a Bearer, `anthropic-messages` calls
|
|
100
|
+
// `<baseURL>/v1/messages` with x-api-key, so an Anthropic baseURL is the host,
|
|
101
|
+
// as it is for OpenCode and for the provider proxy.
|
|
102
|
+
const PI_PROVIDER_APIS = Object.freeze({
|
|
103
|
+
'openai-chat': 'openai-completions',
|
|
104
|
+
'anthropic-messages': 'anthropic-messages',
|
|
105
|
+
});
|
|
106
|
+
|
|
87
107
|
// ADR-008 `effort` → pi `--thinking`. pi's ladder is off/minimal/low/medium/high/xhigh/max.
|
|
88
108
|
const THINKING = { none: 'off', off: 'off', minimal: 'minimal', low: 'low', medium: 'medium', high: 'high', xhigh: 'xhigh', max: 'max' };
|
|
89
109
|
export const thinkingFor = (effort) => (effort ? THINKING[String(effort).toLowerCase()] || null : null);
|
|
@@ -117,8 +137,10 @@ export const PUBLIC_EXCLUDED_TOOLS = Object.freeze([...PI_BUILTIN_TOOLS, ...PUBL
|
|
|
117
137
|
const PUBLIC_SAFE_ENV = /^(?:PATH|LANG|LC_[A-Z_]+|TERM|USER|LOGNAME|NO_COLOR|CI|SSL_CERT_FILE|SSL_CERT_DIR)$/;
|
|
118
138
|
const safeEnv = (env) => Object.fromEntries(Object.entries(env).filter(([name]) => PUBLIC_SAFE_ENV.test(name)));
|
|
119
139
|
|
|
120
|
-
// The one provider API the loopback proxy carries for pi.
|
|
140
|
+
// The one provider API the loopback proxy carries for pi. The proxy's model pin
|
|
141
|
+
// checks chat completions only, and a public turn must not run unpinned.
|
|
121
142
|
const PUBLIC_PROVIDER_API = 'openai-completions';
|
|
143
|
+
const publicApiRefusal = (api) => `pi adapter: a public seat reaches its provider through a loopback proxy that carries the ${PUBLIC_PROVIDER_API} API only, not ${api}`;
|
|
122
144
|
|
|
123
145
|
// Same substitution contract as claude.js / codex.js: ${COMMONLY_*}
|
|
124
146
|
// placeholders in the declared MCP env are the wrapper's per-(agent, pod)
|
|
@@ -298,9 +320,59 @@ export const resolveMcpServers = (mcpServers, ctx = {}) => {
|
|
|
298
320
|
return carried;
|
|
299
321
|
};
|
|
300
322
|
|
|
323
|
+
/**
|
|
324
|
+
* Two provider shapes reach this adapter. The shared one, `{ id, baseURL,
|
|
325
|
+
* keyFile, models, api }`, is what `--env` accepts and validateEnvironmentSpec
|
|
326
|
+
* checks. pi's own, `{ name, baseUrl, api, apiKeyEnv }`, is a token-file
|
|
327
|
+
* override older than that validation, and its `api` is pi's word for it. A key
|
|
328
|
+
* only the shared shape has decides; a block with keys from both is then judged
|
|
329
|
+
* as shared, and validation refuses it rather than reading half of each.
|
|
330
|
+
*/
|
|
331
|
+
const SHARED_PROVIDER_KEYS = ['id', 'baseURL', 'keyFile', 'models'];
|
|
332
|
+
const isSharedProvider = (spec) => Boolean(spec) && SHARED_PROVIDER_KEYS.some((key) => spec[key] !== undefined);
|
|
333
|
+
|
|
334
|
+
/** The real key file of a shared provider, validated without reading it; null for any other seat. */
|
|
335
|
+
const sharedProviderKeyFile = async (environment, workspacePath) => {
|
|
336
|
+
if (!isSharedProvider(environment?.provider)) return null;
|
|
337
|
+
const validation = validateEnvironmentSpec(environment);
|
|
338
|
+
if (!validation.ok) throw new Error(validation.errors.join('; '));
|
|
339
|
+
return resolveProviderKeyFile(environment.provider, workspacePath, 'pi');
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* The proxy reads a public seat's key file from this process, so the file stays
|
|
344
|
+
* out of the jail, and nothing here admits it. The jail does admit these
|
|
345
|
+
* directories, and the seat home is a stable path a key file could be put in,
|
|
346
|
+
* so a key under one of them would be readable from inside.
|
|
347
|
+
*/
|
|
348
|
+
const refuseKeyFileInJail = (keyFile, readableDirectories) => {
|
|
349
|
+
for (const directory of readableDirectories) {
|
|
350
|
+
const fromDirectory = relative(realpathSync(directory), keyFile);
|
|
351
|
+
if (fromDirectory !== '..' && !fromDirectory.startsWith(`..${sep}`) && !isAbsolute(fromDirectory)) {
|
|
352
|
+
throw new Error(`pi adapter: provider.keyFile ${keyFile} is inside the sandbox of a public seat; move it outside ${directory}`);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
/** The private turn's key, read the way goose reads it, refused if empty. */
|
|
358
|
+
const readOwnKey = async (keyFile) => {
|
|
359
|
+
const key = (await readFile(keyFile, 'utf8')).trim();
|
|
360
|
+
if (!key) throw new Error('pi adapter: provider.keyFile must not be empty');
|
|
361
|
+
return key;
|
|
362
|
+
};
|
|
363
|
+
|
|
301
364
|
/** The provider block for models.json: the env spec's `provider` over the LiteLLM default. */
|
|
302
365
|
export const resolveProvider = (environment = {}) => {
|
|
303
366
|
const spec = environment?.provider || {};
|
|
367
|
+
if (isSharedProvider(spec)) {
|
|
368
|
+
return {
|
|
369
|
+
name: spec.id,
|
|
370
|
+
baseUrl: spec.baseURL,
|
|
371
|
+
api: PI_PROVIDER_APIS[spec.api || 'openai-chat'],
|
|
372
|
+
apiKeyEnv: OWN_KEY_ENV,
|
|
373
|
+
reasoning: spec.models?.[environment.model]?.reasoning !== false,
|
|
374
|
+
};
|
|
375
|
+
}
|
|
304
376
|
return {
|
|
305
377
|
name: spec.name || DEFAULT_PROVIDER.name,
|
|
306
378
|
baseUrl: spec.baseUrl || DEFAULT_PROVIDER.baseUrl,
|
|
@@ -320,7 +392,7 @@ export const buildModelsJson = (provider, model) => ({
|
|
|
320
392
|
models: [{
|
|
321
393
|
id: model,
|
|
322
394
|
name: model,
|
|
323
|
-
reasoning: true,
|
|
395
|
+
reasoning: provider.reasoning ?? true,
|
|
324
396
|
input: ['text'],
|
|
325
397
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
326
398
|
contextWindow: 128000,
|
|
@@ -607,12 +679,29 @@ export default {
|
|
|
607
679
|
// into its login service and fail loudly at bind when it is absent, instead
|
|
608
680
|
// of the seat dying at line ~406 with nothing naming the missing variable at
|
|
609
681
|
// daemon level.
|
|
682
|
+
// A seat with its own provider.keyFile doesn't need it; spawn doesn't ask.
|
|
610
683
|
providerKeyEnv: DEFAULT_PROVIDER.apiKeyEnv,
|
|
611
684
|
|
|
685
|
+
supportsProvider: true,
|
|
686
|
+
providerApis: Object.keys(PI_PROVIDER_APIS),
|
|
687
|
+
|
|
688
|
+
// The rule pi adds to the shared provider check. Its own shape names pi's
|
|
689
|
+
// api, which the shared list doesn't hold. A public seat can't take a wire
|
|
690
|
+
// the proxy doesn't pin. Anything else goes to the shared check (undefined).
|
|
691
|
+
providerVerdict(environment) {
|
|
692
|
+
const spec = environment?.provider;
|
|
693
|
+
if (!isSharedProvider(spec)) return null;
|
|
694
|
+
if (effectiveSandboxTrust(environment?.sandbox?.trust) !== 'public') return undefined;
|
|
695
|
+
const api = PI_PROVIDER_APIS[spec.api || 'openai-chat'];
|
|
696
|
+
return api && api !== PUBLIC_PROVIDER_API ? publicApiRefusal(api) : undefined;
|
|
697
|
+
},
|
|
698
|
+
|
|
612
699
|
// Attach runs this before anything is published, so a public pi seat this
|
|
613
|
-
// host cannot confine is refused there rather than at its first turn
|
|
614
|
-
|
|
700
|
+
// host cannot confine is refused there rather than at its first turn, and so
|
|
701
|
+
// is a provider block or key file that couldn't be used.
|
|
702
|
+
async validateEnvironment(environment, workspacePath) {
|
|
615
703
|
assertSandboxSupported(environment);
|
|
704
|
+
return sharedProviderKeyFile(environment, workspacePath);
|
|
616
705
|
},
|
|
617
706
|
|
|
618
707
|
async detect() {
|
|
@@ -631,11 +720,15 @@ export default {
|
|
|
631
720
|
assertSandboxSupported(ctx.environment, platform);
|
|
632
721
|
const sandbox = normalizeSandboxTrust(ctx.environment?.sandbox);
|
|
633
722
|
const isPublic = effectiveSandboxTrust(sandbox?.trust) === 'public';
|
|
723
|
+
const keyFile = await sharedProviderKeyFile(ctx.environment, ctx.cwd);
|
|
634
724
|
const provider = resolveProvider(ctx.environment);
|
|
635
725
|
const model = seatModel;
|
|
636
726
|
const thinking = thinkingFor(ctx.environment?.effort);
|
|
637
727
|
const baseEnv = ctx.env || process.env;
|
|
638
|
-
|
|
728
|
+
// A public turn leaves the key file to the proxy, so this process holds the
|
|
729
|
+
// value only for a private pi, which is the one that is handed it.
|
|
730
|
+
const ownKey = keyFile && !isPublic ? await readOwnKey(keyFile) : null;
|
|
731
|
+
if (!keyFile && !baseEnv[provider.apiKeyEnv]) {
|
|
639
732
|
throw new Error(`pi adapter: ${provider.apiKeyEnv} is not set — the seat's environment must carry the provider key (LiteLLM virtual key)`);
|
|
640
733
|
}
|
|
641
734
|
|
|
@@ -646,7 +739,7 @@ export default {
|
|
|
646
739
|
let nodePath = null;
|
|
647
740
|
if (isPublic) {
|
|
648
741
|
if (provider.api !== PUBLIC_PROVIDER_API) {
|
|
649
|
-
throw new Error(
|
|
742
|
+
throw new Error(publicApiRefusal(provider.api));
|
|
650
743
|
}
|
|
651
744
|
if (!ctx.cwd || !isAbsolute(ctx.cwd)) {
|
|
652
745
|
throw new Error('pi adapter: a public seat needs an absolute workspace path');
|
|
@@ -676,6 +769,7 @@ export default {
|
|
|
676
769
|
// the token from the child copy below, and after that there is nothing left
|
|
677
770
|
// to compare a refusal against.
|
|
678
771
|
const credentials = spawnCredentials(ctx, [provider.apiKeyEnv]);
|
|
772
|
+
if (ownKey) credentials.push(ownKey);
|
|
679
773
|
|
|
680
774
|
// Per-seat pi home: models.json holds the provider by env reference.
|
|
681
775
|
const home = seatHome(ctx, { publicSeat: isPublic });
|
|
@@ -712,7 +806,7 @@ export default {
|
|
|
712
806
|
if (isPublic) {
|
|
713
807
|
proxy = await (ctx._startProviderProxy || startProviderProxy)({
|
|
714
808
|
provider: { baseURL: provider.baseUrl },
|
|
715
|
-
keyMaterial: baseEnv[provider.apiKeyEnv],
|
|
809
|
+
...(keyFile ? { keyFile } : { keyMaterial: baseEnv[provider.apiKeyEnv] }),
|
|
716
810
|
adapterLabel: 'pi',
|
|
717
811
|
pinnedModel: model,
|
|
718
812
|
});
|
|
@@ -734,6 +828,9 @@ export default {
|
|
|
734
828
|
grantBrokers,
|
|
735
829
|
});
|
|
736
830
|
if (unavailableMcp.length) throw publicMcpUnavailableError(unavailableMcp);
|
|
831
|
+
if (keyFile && isPublic) {
|
|
832
|
+
refuseKeyFileInJail(keyFile, [home, packageRoot, EXTENSION_CODE_ROOT, ...mcpReadDirectories]);
|
|
833
|
+
}
|
|
737
834
|
const childEnv = isPublic ? {
|
|
738
835
|
// A scrubbed environment: nothing of the operator's crosses into the
|
|
739
836
|
// jail, and the provider variable holds the proxy's token, not the key.
|
|
@@ -751,7 +848,10 @@ export default {
|
|
|
751
848
|
// A variable NAME, never its value. The always-loaded extension uses
|
|
752
849
|
// this to scrub custom provider keys as well as the default LiteLLM key.
|
|
753
850
|
COMMONLY_PI_PROVIDER_KEY_ENV: provider.apiKeyEnv,
|
|
851
|
+
...(ownKey ? { [provider.apiKeyEnv]: ownKey } : {}),
|
|
754
852
|
};
|
|
853
|
+
// This seat brought its own key, so it has no use for ours.
|
|
854
|
+
if (ownKey) delete childEnv[DEFAULT_PROVIDER.apiKeyEnv];
|
|
755
855
|
// `baseEnv` is normally the process environment, which carries the
|
|
756
856
|
// bootstrap export. Nothing below this process needs the value: the bridge
|
|
757
857
|
// is handed the servers, their resolved values included, over fd 3. It has
|
|
@@ -335,7 +335,7 @@ export const installDaemonService = async ({
|
|
|
335
335
|
if (lingerUser) startsAtBoot = await ensureLinger({ username: lingerUser, existsFile, execCmd, warn });
|
|
336
336
|
}
|
|
337
337
|
for (const name of missing) {
|
|
338
|
-
warn(`${name} is not set in this shell, so it is NOT in the service file. A seat
|
|
338
|
+
warn(`${name} is not set in this shell, so it is NOT in the service file. A seat that relies on it will fail to start (one with its own provider.keyFile won't); export it and re-run: commonly daemon install (docs/agents/daemon-service-environment.md)`);
|
|
339
339
|
}
|
|
340
340
|
log(`Installed ${target.kind} service (${target.file}). Logs: ${daemonLogPath(home)}`);
|
|
341
341
|
return { ...target, startsAtBoot };
|
package/src/lib/environment.js
CHANGED
|
@@ -196,10 +196,14 @@ export const environmentForServer = (environment) => {
|
|
|
196
196
|
export const PROVIDER_APIS = Object.freeze(['openai-chat', 'anthropic-messages']);
|
|
197
197
|
|
|
198
198
|
// One provider check for config, attach, run and the daemon's adapter swap: the adapter must take a
|
|
199
|
-
// provider block at all, and speak its `provider.api` (default openai-chat).
|
|
199
|
+
// provider block at all, and speak its `provider.api` (default openai-chat). An adapter's
|
|
200
|
+
// `providerVerdict(environment)` answers first when it returns a refusal or null (accepted);
|
|
201
|
+
// undefined leaves the seat to this check.
|
|
200
202
|
export const providerRefusal = (environment, adapter) => {
|
|
201
203
|
if (environment?.provider === undefined) return null;
|
|
202
204
|
if (!adapter?.supportsProvider) return 'environment.provider requires a provider-capable adapter';
|
|
205
|
+
const verdict = adapter.providerVerdict?.(environment);
|
|
206
|
+
if (verdict !== undefined) return verdict;
|
|
203
207
|
const api = environment.provider?.api || 'openai-chat';
|
|
204
208
|
const apis = adapter.providerApis || ['openai-chat'];
|
|
205
209
|
return apis.includes(api) ? null
|
|
@@ -142,6 +142,14 @@ export const UNSANDBOXED_NOTICE = 'unsandboxed (opted in): Windows has no sandbo
|
|
|
142
142
|
/** Codex has no restricted tool settings to keep, so its line says what it costs instead. */
|
|
143
143
|
export const CODEX_UNSANDBOXED_NOTICE = 'unsandboxed (opted in): Windows has no sandbox Codex can use here, so nothing confines this agent. It runs with your own access to files and commands, and anyone in its pods, people invited later included, can direct it. It gets no connector grants, and a turn is refused if a pod stops being invite-only.';
|
|
144
144
|
|
|
145
|
+
// A 404 here is a server from before this route, which reads like a missing agent.
|
|
146
|
+
export const hostReportFailureMessage = (err) => {
|
|
147
|
+
const hint = err?.status === 404
|
|
148
|
+
? '. This server is older than this CLI: update the server, or run the agent in a sandbox.'
|
|
149
|
+
: '';
|
|
150
|
+
return `could not tell the server this agent has no sandbox, so it did not start: ${err?.message}${hint}`;
|
|
151
|
+
};
|
|
152
|
+
|
|
145
153
|
export default {
|
|
146
154
|
CODEX_UNSANDBOXED_NOTICE,
|
|
147
155
|
UNSANDBOXED_FLAG,
|