@commonlyai/cli 0.1.335 → 0.1.336
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 +5 -0
- package/src/lib/adapters/codex.js +44 -2
package/package.json
CHANGED
package/src/commands/agent.js
CHANGED
|
@@ -3199,6 +3199,11 @@ export const performRun = ({
|
|
|
3199
3199
|
runtimeToken: opened.token,
|
|
3200
3200
|
instanceUrl,
|
|
3201
3201
|
agentName,
|
|
3202
|
+
// The seat's local key (F306), which a Codex seat's own home is keyed
|
|
3203
|
+
// on (F450): `name@instance` for a second instance, the bare name for
|
|
3204
|
+
// every other seat, including one saved under its name that runs a
|
|
3205
|
+
// non-default instance, so no existing seat moves to a new home.
|
|
3206
|
+
seatKey: stateKey,
|
|
3202
3207
|
metadata: { event },
|
|
3203
3208
|
};
|
|
3204
3209
|
// Supervised or plain, a failure is thrown exactly as the adapter's own
|
|
@@ -422,10 +422,19 @@ const privateSourceCodexHome = (ctx, env) => pathResolve(
|
|
|
422
422
|
env?.CODEX_HOME || join(env?.HOME || homedir(), '.codex'),
|
|
423
423
|
);
|
|
424
424
|
|
|
425
|
+
/**
|
|
426
|
+
* Who a seat's own Codex home belongs to (F450): the seat's local key, as the
|
|
427
|
+
* run loop names its sessions and state (F306). A second instance's is
|
|
428
|
+
* `name@instance`, so it gets a home of its own; every other seat's is its
|
|
429
|
+
* bare name, so every home made before this keeps its seat, including a seat
|
|
430
|
+
* saved under its name that runs a non-default instance.
|
|
431
|
+
*/
|
|
432
|
+
export const codexHomeIdentity = (ctx) => ctx.seatKey || ctx.agentName || ctx.cwd || 'anonymous';
|
|
433
|
+
|
|
425
434
|
/** Where this private seat's own Codex home is, or null where it has none. */
|
|
426
435
|
export const privateCodexHomePath = (ctx) => {
|
|
427
436
|
if (ctx._privateCodexHome) return ctx._privateCodexHome;
|
|
428
|
-
const identity = ctx
|
|
437
|
+
const identity = codexHomeIdentity(ctx);
|
|
429
438
|
const hash = createHash('sha256').update(`private:${identity}`).digest('hex').slice(0, 20);
|
|
430
439
|
let publicRoot;
|
|
431
440
|
try {
|
|
@@ -437,6 +446,26 @@ export const privateCodexHomePath = (ctx) => {
|
|
|
437
446
|
return join(dirname(publicRoot), PRIVATE_CODEX_HOMES, hash);
|
|
438
447
|
};
|
|
439
448
|
|
|
449
|
+
// F450: a login Codex keeps in the keyring is filed under the Codex home's own
|
|
450
|
+
// path and leaves no auth.json, so a seat in a home of its own can't reach it.
|
|
451
|
+
// Said once per process per home, at the first turn.
|
|
452
|
+
const keyringLoginNoted = new Set();
|
|
453
|
+
const KEYRING_STORE = /^\s*cli_auth_credentials_store\s*=\s*["'](keyring|auto)["']/m;
|
|
454
|
+
// Only the keys above the first table header are the top level.
|
|
455
|
+
const topLevelToml = (text) => text.split(/^\s*\[/m)[0];
|
|
456
|
+
const noteKeyringLogin = async (source, home) => {
|
|
457
|
+
if (keyringLoginNoted.has(home)) return;
|
|
458
|
+
keyringLoginNoted.add(home);
|
|
459
|
+
if (await statOrNull(join(source, 'auth.json'))) return;
|
|
460
|
+
const config = await readFile(join(source, 'config.toml'), 'utf8').catch(() => '');
|
|
461
|
+
const store = topLevelToml(config).match(KEYRING_STORE)?.[1];
|
|
462
|
+
if (!store) return;
|
|
463
|
+
process.stderr.write(`[codex] this agent runs from a Codex home of its own (${home}). Your config.toml `
|
|
464
|
+
+ `sets cli_auth_credentials_store = "${store}" and there is no auth.json to link, so a login kept in `
|
|
465
|
+
+ 'the keyring can\'t reach it. '
|
|
466
|
+
+ 'To fix it, set cli_auth_credentials_store = "file" in your config.toml and run `codex login`.\n');
|
|
467
|
+
};
|
|
468
|
+
|
|
440
469
|
const preparePrivateCodexHome = async (ctx, childEnv) => {
|
|
441
470
|
const source = privateSourceCodexHome(ctx, childEnv);
|
|
442
471
|
const home = privateCodexHomePath(ctx);
|
|
@@ -484,6 +513,7 @@ const preparePrivateCodexHome = async (ctx, childEnv) => {
|
|
|
484
513
|
await symlink(from, to).catch((error) => { if (error?.code !== 'EEXIST') throw error; });
|
|
485
514
|
}
|
|
486
515
|
}
|
|
516
|
+
await noteKeyringLogin(source, home);
|
|
487
517
|
await mkdir(join(home, 'tmp', 'arg0-linux'), { recursive: true, mode: 0o700 });
|
|
488
518
|
// Every other private seat's home, as it stands now. One created during this
|
|
489
519
|
// turn is denied from the next turn on: until then, what that seat's first
|
|
@@ -504,7 +534,7 @@ const preparePrivateCodexHome = async (ctx, childEnv) => {
|
|
|
504
534
|
// and a link an earlier turn left is removed.
|
|
505
535
|
const preparePublicCodexHome = async (ctx, childEnv, { login = true } = {}) => {
|
|
506
536
|
const operatorHome = operatorCodexHome(ctx);
|
|
507
|
-
const identity = ctx
|
|
537
|
+
const identity = codexHomeIdentity(ctx);
|
|
508
538
|
const identityHash = createHash('sha256').update(identity).digest('hex').slice(0, 20);
|
|
509
539
|
const homesRoot = publicCodexHomesRoot(ctx);
|
|
510
540
|
const publicHome = ctx._publicCodexHome || join(homesRoot, identityHash);
|
|
@@ -1176,6 +1206,7 @@ const buildArgs = ({
|
|
|
1176
1206
|
privateHome = homedir(),
|
|
1177
1207
|
privateOtherCodexHomes = [],
|
|
1178
1208
|
privateCodexHomeLinks = [],
|
|
1209
|
+
loginFileStore = false,
|
|
1179
1210
|
}) => {
|
|
1180
1211
|
const publicSandbox = publicSandboxMode !== null;
|
|
1181
1212
|
// F387: a private seat keeps the flag below only in a cloud-codex pod, or
|
|
@@ -1246,6 +1277,7 @@ const buildArgs = ({
|
|
|
1246
1277
|
...(publicSandbox && modelBaseUrl ? ['-c', `openai_base_url=${toml(modelBaseUrl)}`] : []),
|
|
1247
1278
|
...(model ? ['--model', String(model)] : []),
|
|
1248
1279
|
...(effort ? ['-c', 'model_reasoning_effort=' + toml(effort)] : []),
|
|
1280
|
+
...(loginFileStore ? ['-c', 'cli_auth_credentials_store="file"'] : []),
|
|
1249
1281
|
...mcpFlags,
|
|
1250
1282
|
'-o',
|
|
1251
1283
|
outputFile,
|
|
@@ -1675,6 +1707,16 @@ export default {
|
|
|
1675
1707
|
])]
|
|
1676
1708
|
: [],
|
|
1677
1709
|
privateCodexHomeLinks: privateCodexHome?.links || [],
|
|
1710
|
+
// F450: a seat with a home of its own keeps the person's login in
|
|
1711
|
+
// auth.json, linked to theirs. Codex's file store writes a refreshed
|
|
1712
|
+
// login through that link (open + truncate, codex-rs login
|
|
1713
|
+
// auth/storage.rs at rust-v0.164.0), so the person's file gets the new
|
|
1714
|
+
// tokens. Its keyring and auto stores save to the keyring under the
|
|
1715
|
+
// seat home's own path and delete the seat's auth.json, which would
|
|
1716
|
+
// leave the person's file holding the refresh token the refresh just
|
|
1717
|
+
// rotated. config.toml is linked in, so the seat would inherit those
|
|
1718
|
+
// modes; this keeps it on the file store.
|
|
1719
|
+
loginFileStore: Boolean(privateCodexHome),
|
|
1678
1720
|
});
|
|
1679
1721
|
// childEnv is derived from the process environment, so the bootstrap export has to be
|
|
1680
1722
|
// taken back out: the declaration above moved our server onto the file,
|