@alan-ai-hq/agent-manager-linux-arm64 0.1.135 → 0.1.136

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.
Files changed (3) hide show
  1. package/alan-agent.cjs +426 -216
  2. package/alan-holder.cjs +310 -145
  3. package/package.json +1 -1
package/alan-holder.cjs CHANGED
@@ -20376,10 +20376,13 @@ var init_desired_state = __esm({
20376
20376
  function runProviderCredentialPath(runId) {
20377
20377
  return `/public/machines/me/runs/${encodeURIComponent(runId)}/provider-credential`;
20378
20378
  }
20379
+ function runCodexCredentialRefreshPath(runId) {
20380
+ return `${runProviderCredentialPath(runId)}/refresh`;
20381
+ }
20379
20382
  function runAttachmentPath(runId, attachmentId) {
20380
20383
  return `/public/machines/me/runs/${encodeURIComponent(runId)}/attachments/${encodeURIComponent(attachmentId)}`;
20381
20384
  }
20382
- var machineEndpointsSchema, machineCredentialGrantSchema, MACHINE_PATHS, machinePlatformSchema, machineRegisterRequestSchema, machineEnrollRequestSchema, machineRenewRequestSchema, machineRenewReusedSchema, deviceAuthorizationSchema, machineDeviceAuthorizationRequestSchema, machineDeviceTokenRequestSchema, machineDeviceTokenSchema, DEVICE_TOKEN_ERRORS, machineDeviceTokenErrorSchema, machineMcpCredentialRequestSchema, machineMcpCredentialSchema, runtimeReleaseSchema, machineSiblingSchema, MACHINE_SIBLINGS_LIMIT, machineSiblingsResponseSchema, runProviderCredentialSchema;
20385
+ var machineEndpointsSchema, machineCredentialGrantSchema, MACHINE_PATHS, machinePlatformSchema, machineRegisterRequestSchema, machineEnrollRequestSchema, machineRenewRequestSchema, machineRenewReusedSchema, deviceAuthorizationSchema, machineDeviceAuthorizationRequestSchema, machineDeviceTokenRequestSchema, machineDeviceTokenSchema, DEVICE_TOKEN_ERRORS, machineDeviceTokenErrorSchema, machineMcpCredentialRequestSchema, machineMcpCredentialSchema, runtimeReleaseSchema, machineSiblingSchema, MACHINE_SIBLINGS_LIMIT, machineSiblingsResponseSchema, runCodexCredentialSchema, runCodexCredentialRefreshRequestSchema, runProviderCredentialSchema;
20383
20386
  var init_machine_identity = __esm({
20384
20387
  "../shared/dist/runtime-v2/machine-identity.js"() {
20385
20388
  "use strict";
@@ -20494,9 +20497,20 @@ var init_machine_identity = __esm({
20494
20497
  machineSiblingsResponseSchema = external_exports.object({
20495
20498
  machines: external_exports.array(machineSiblingSchema).max(MACHINE_SIBLINGS_LIMIT)
20496
20499
  });
20500
+ runCodexCredentialSchema = external_exports.object({
20501
+ accessToken: external_exports.string().min(1),
20502
+ chatgptAccountId: external_exports.string().min(1),
20503
+ chatgptPlanType: external_exports.string().nullable()
20504
+ });
20505
+ runCodexCredentialRefreshRequestSchema = external_exports.object({
20506
+ /** sha256 hex of the access token Codex was refused with; a newer stored token is returned instead of rotating. */
20507
+ rejectedAccessTokenSha256: external_exports.string().regex(/^[0-9a-f]{64}$/).optional()
20508
+ });
20497
20509
  runProviderCredentialSchema = external_exports.object({
20498
20510
  /** Environment variables for the agent CLI, e.g. ANTHROPIC_API_KEY; empty when the CLI's own login is used. */
20499
- env: external_exports.record(external_exports.string(), external_exports.string())
20511
+ env: external_exports.record(external_exports.string(), external_exports.string()),
20512
+ /** The team's Codex login for a cloud sandbox; absent where the CLI's own login is used. */
20513
+ codex: runCodexCredentialSchema.optional()
20500
20514
  });
20501
20515
  }
20502
20516
  });
@@ -24102,11 +24116,20 @@ var init_chunk_DALFHI4B = __esm({
24102
24116
  }
24103
24117
  });
24104
24118
 
24105
- // ../agent-core/dist/chunk-R6R6ORR2.js
24119
+ // ../agent-core/dist/chunk-54ZRJOQP.js
24106
24120
  function specForErrorKind(errorKind) {
24107
24121
  const spec = ERROR_SPECS[errorKind];
24108
24122
  return { message: spec.message, errorKind, recoveryClass: spec.recoveryClass };
24109
24123
  }
24124
+ function withAgentSignIn(classified, harness) {
24125
+ const agent = AGENT_SIGN_IN_BY_HARNESS.get(harness);
24126
+ if (!agent || classified.message !== ERROR_SPECS.not_logged_in.message) return classified;
24127
+ const local = agent.localSignIn ?? "sign in to it";
24128
+ return {
24129
+ ...classified,
24130
+ message: `${agent.name} isn't signed in: for cloud runs connect it in Team settings \u2192 Integrations \u2192 Coding agents; on your computer ${local}; then retry.`
24131
+ };
24132
+ }
24110
24133
  function embeddedJson(text2) {
24111
24134
  const start = text2.indexOf("{");
24112
24135
  if (start === -1) return void 0;
@@ -24265,7 +24288,8 @@ function retryOwnerFor(classified, harnessOwnsRetry, safe) {
24265
24288
  if (!safe) return "none";
24266
24289
  return classified.errorKind === "resume_failed" || classified.errorKind === "history_rejected" ? "alan_resume" : "user_confirmed_fresh_run";
24267
24290
  }
24268
- function createCliProblem(classified, options) {
24291
+ function createCliProblem(observed, options) {
24292
+ const classified = withAgentSignIn(observed, options.harness);
24269
24293
  const automatic = classified.recoveryClass === "auto_recovering";
24270
24294
  const harnessOwnsRetry = options.finality === "observation" && automatic;
24271
24295
  const safe = options.outcomeCertainty === "no_effect" || harnessOwnsRetry;
@@ -24295,9 +24319,9 @@ function createCliProblem(classified, options) {
24295
24319
  ...classified.resetsAt ? { resetsAt: classified.resetsAt } : {}
24296
24320
  });
24297
24321
  }
24298
- var import_crypto2, ERROR_SPECS, AGENT_ERROR_KINDS, STATUS_PREFIX, TEXT_RULES, CODEX_TIMEOUT_MESSAGE, CODEX_EXPIRED_MESSAGE, EPOCH_RESET, WORDED_RESET, COMMAND_NOT_FOUND, CODE_RULES, TEXT_REFINES, STATUS_LEAD, CLI_PROBLEM_CODE_BY_ERROR_KIND, KEY_REJECTION_KINDS;
24299
- var init_chunk_R6R6ORR2 = __esm({
24300
- "../agent-core/dist/chunk-R6R6ORR2.js"() {
24322
+ var import_crypto2, ERROR_SPECS, AGENT_ERROR_KINDS, AGENT_SIGN_IN_BY_HARNESS, STATUS_PREFIX, TEXT_RULES, CODEX_TIMEOUT_MESSAGE, CODEX_EXPIRED_MESSAGE, EPOCH_RESET, WORDED_RESET, COMMAND_NOT_FOUND, CODE_RULES, TEXT_REFINES, STATUS_LEAD, CLI_PROBLEM_CODE_BY_ERROR_KIND, KEY_REJECTION_KINDS;
24323
+ var init_chunk_54ZRJOQP = __esm({
24324
+ "../agent-core/dist/chunk-54ZRJOQP.js"() {
24301
24325
  "use strict";
24302
24326
  init_chunk_YXWJW7I5();
24303
24327
  import_crypto2 = require("crypto");
@@ -24316,7 +24340,7 @@ var init_chunk_R6R6ORR2 = __esm({
24316
24340
  recoveryClass: "user_fixable"
24317
24341
  },
24318
24342
  not_logged_in: {
24319
- message: "Not logged in to the agent CLI on this computer. Sign in to it there (for Claude Code, run `claude` then `/login`), then retry.",
24343
+ message: "The agent CLI isn't signed in: for cloud runs connect it in Team settings \u2192 Integrations \u2192 Coding agents; on your computer sign in to the CLI; then retry.",
24320
24344
  recoveryClass: "user_fixable"
24321
24345
  },
24322
24346
  not_authenticated: {
@@ -24407,6 +24431,19 @@ var init_chunk_R6R6ORR2 = __esm({
24407
24431
  AGENT_ERROR_KINDS = Object.keys(ERROR_SPECS).filter(
24408
24432
  (key) => key in ERROR_SPECS
24409
24433
  );
24434
+ AGENT_SIGN_IN_BY_HARNESS = /* @__PURE__ */ new Map([
24435
+ ["claude_cli", { name: "Claude Code", localSignIn: "run `claude` then `/login`" }],
24436
+ ["codex_app_server", { name: "Codex", localSignIn: "run `codex login`" }],
24437
+ ["codex_exec", { name: "Codex", localSignIn: "run `codex login`" }],
24438
+ ["cursor_agent_cli", { name: "Cursor Agent", localSignIn: "run `cursor-agent login`" }],
24439
+ ["copilot_cli", { name: "GitHub Copilot CLI", localSignIn: "run `copilot` then `/login`" }],
24440
+ ["opencode_serve", { name: "OpenCode", localSignIn: "run `opencode auth login`" }],
24441
+ ["droid_cli", { name: "Droid" }],
24442
+ ["antigravity_cli", { name: "Antigravity" }],
24443
+ ["grok_cli", { name: "Grok CLI" }],
24444
+ ["kimi_cli", { name: "Kimi CLI" }],
24445
+ ["command_code_cli", { name: "Command Code" }]
24446
+ ]);
24410
24447
  STATUS_PREFIX = /\b(?:api error|status|http)[:\s]+(\d{3})\b/i;
24411
24448
  TEXT_RULES = [
24412
24449
  { kind: "auth_expired", pattern: /\bcodex cli connection expired\b|\breconnect openai codex\b/ },
@@ -24547,7 +24584,7 @@ var init_chunk_R6R6ORR2 = __esm({
24547
24584
  }
24548
24585
  });
24549
24586
 
24550
- // ../agent-core/dist/chunk-W3QH4J4A.js
24587
+ // ../agent-core/dist/chunk-YPYC4VBL.js
24551
24588
  function collectStrings(value, out) {
24552
24589
  if (typeof value === "string") out.push(value);
24553
24590
  else if (Array.isArray(value)) for (const item of value) collectStrings(item, out);
@@ -24917,11 +24954,11 @@ function silentStartError(name, timeoutMs) {
24917
24954
  };
24918
24955
  }
24919
24956
  var import_crypto3, import_fs4, import_path3, IMAGE_MIME_BY_EXT, VIDEO_MIME_BY_EXT, IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, MAX_IMAGE_BYTES, MAX_VIDEO_BYTES, AGENT_BROWSER_MENTION, LocalMediaReader, SessionOpenRefusal, JsonRpcError, ACP_PROTOCOL_VERSION, ACP_ERROR, STDERR_TAIL_LINES, RESULT_EXIT_GRACE_MS, PerTurnSession;
24920
- var init_chunk_W3QH4J4A = __esm({
24921
- "../agent-core/dist/chunk-W3QH4J4A.js"() {
24957
+ var init_chunk_YPYC4VBL = __esm({
24958
+ "../agent-core/dist/chunk-YPYC4VBL.js"() {
24922
24959
  "use strict";
24923
24960
  init_chunk_UGRKZTAD();
24924
- init_chunk_R6R6ORR2();
24961
+ init_chunk_54ZRJOQP();
24925
24962
  init_chunk_J4T6L5LX();
24926
24963
  init_chunk_YXWJW7I5();
24927
24964
  import_crypto3 = require("crypto");
@@ -26785,9 +26822,9 @@ var init_claude = __esm({
26785
26822
  "../agent-core/dist/providers/claude.js"() {
26786
26823
  "use strict";
26787
26824
  init_chunk_DALFHI4B();
26788
- init_chunk_W3QH4J4A();
26825
+ init_chunk_YPYC4VBL();
26789
26826
  init_chunk_UGRKZTAD();
26790
- init_chunk_R6R6ORR2();
26827
+ init_chunk_54ZRJOQP();
26791
26828
  init_chunk_J2KTV5FP();
26792
26829
  init_chunk_J4T6L5LX();
26793
26830
  init_chunk_6WN2R725();
@@ -28553,11 +28590,12 @@ async function withDeadline(work, clock, ms, what) {
28553
28590
  `codex app-server did not answer ${what} within ${ms} ms`
28554
28591
  );
28555
28592
  }
28556
- async function handshake(session, log) {
28593
+ async function handshake(session, spec, log) {
28594
+ const experimentalApi = spec.externalAuth !== void 0;
28557
28595
  const init = asRecord(
28558
28596
  await session.rpc.request("initialize", {
28559
28597
  clientInfo: CLIENT_INFO,
28560
- capabilities: { experimentalApi: false, requestAttestation: false }
28598
+ capabilities: { experimentalApi, requestAttestation: false }
28561
28599
  })
28562
28600
  );
28563
28601
  const userAgent = asString(init?.userAgent);
@@ -28650,7 +28688,7 @@ function createCodexDriver(options = {}) {
28650
28688
  await started;
28651
28689
  try {
28652
28690
  const opening = (async () => {
28653
- await handshake(session, resolved.log);
28691
+ await handshake(session, spec, resolved.log);
28654
28692
  await preflight(session, spec);
28655
28693
  return openThread(session, spec, resolved.log);
28656
28694
  })();
@@ -28917,9 +28955,9 @@ var init_codex = __esm({
28917
28955
  "../agent-core/dist/providers/codex.js"() {
28918
28956
  "use strict";
28919
28957
  init_chunk_DALFHI4B();
28920
- init_chunk_W3QH4J4A();
28958
+ init_chunk_YPYC4VBL();
28921
28959
  init_chunk_UGRKZTAD();
28922
- init_chunk_R6R6ORR2();
28960
+ init_chunk_54ZRJOQP();
28923
28961
  init_chunk_J2KTV5FP();
28924
28962
  init_chunk_J4T6L5LX();
28925
28963
  init_chunk_6WN2R725();
@@ -37686,9 +37724,9 @@ var require_dist = __commonJS({
37686
37724
  var init_dist = __esm({
37687
37725
  "../agent-core/dist/index.js"() {
37688
37726
  "use strict";
37689
- init_chunk_W3QH4J4A();
37727
+ init_chunk_YPYC4VBL();
37690
37728
  init_chunk_UGRKZTAD();
37691
- init_chunk_R6R6ORR2();
37729
+ init_chunk_54ZRJOQP();
37692
37730
  init_chunk_J4T6L5LX();
37693
37731
  init_chunk_YXWJW7I5();
37694
37732
  }
@@ -38433,9 +38471,9 @@ var import_promises22, import_path9, import_crypto12, import_promises23, CURSOR_
38433
38471
  var init_acp3 = __esm({
38434
38472
  "../agent-core/dist/providers/acp.js"() {
38435
38473
  "use strict";
38436
- init_chunk_W3QH4J4A();
38474
+ init_chunk_YPYC4VBL();
38437
38475
  init_chunk_UGRKZTAD();
38438
- init_chunk_R6R6ORR2();
38476
+ init_chunk_54ZRJOQP();
38439
38477
  init_chunk_J2KTV5FP();
38440
38478
  init_chunk_J4T6L5LX();
38441
38479
  init_chunk_6WN2R725();
@@ -39250,7 +39288,7 @@ var init_acp3 = __esm({
39250
39288
  var init_classify = __esm({
39251
39289
  "../agent-core/dist/classify.js"() {
39252
39290
  "use strict";
39253
- init_chunk_R6R6ORR2();
39291
+ init_chunk_54ZRJOQP();
39254
39292
  init_chunk_YXWJW7I5();
39255
39293
  }
39256
39294
  });
@@ -39280,38 +39318,31 @@ function toTurnResult(harness, outcome2, spec, providerSessionId, clock, apiKeyS
39280
39318
  return { outcome: "aborted", ...session };
39281
39319
  case "interrupted":
39282
39320
  return { outcome: "interrupted", message: outcome2.reason, ...session };
39283
- case "failed":
39284
- return {
39285
- outcome: "failed",
39286
- message: outcome2.error.message,
39287
- problem: createCliProblem(outcome2.error, {
39288
- harness,
39289
- phase: "stream",
39290
- finality: "terminal",
39291
- outcomeCertainty: "effect_unknown",
39292
- occurredAt: new Date(clock.now()).toISOString(),
39293
- scope: { runId: spec.runId, conversationId: spec.conversationId },
39294
- apiKeySupplied
39295
- }),
39296
- ...session
39297
- };
39321
+ case "failed": {
39322
+ const problem = createCliProblem(outcome2.error, {
39323
+ harness,
39324
+ phase: "stream",
39325
+ finality: "terminal",
39326
+ outcomeCertainty: "effect_unknown",
39327
+ occurredAt: new Date(clock.now()).toISOString(),
39328
+ scope: { runId: spec.runId, conversationId: spec.conversationId },
39329
+ apiKeySupplied
39330
+ });
39331
+ return { outcome: "failed", message: problem.detail, problem, ...session };
39332
+ }
39298
39333
  }
39299
39334
  }
39300
39335
  function refusalResult(harness, refusal2, spec, clock, apiKeySupplied) {
39301
- const error61 = refusal2.classified ?? specForErrorKind("not_authenticated");
39302
- return {
39303
- outcome: "failed",
39304
- message: error61.message,
39305
- problem: createCliProblem(error61, {
39306
- harness,
39307
- phase: "preflight",
39308
- finality: "terminal",
39309
- outcomeCertainty: "no_effect",
39310
- occurredAt: new Date(clock.now()).toISOString(),
39311
- scope: { runId: spec.runId, conversationId: spec.conversationId },
39312
- apiKeySupplied
39313
- })
39314
- };
39336
+ const problem = createCliProblem(refusal2.classified ?? specForErrorKind("not_authenticated"), {
39337
+ harness,
39338
+ phase: "preflight",
39339
+ finality: "terminal",
39340
+ outcomeCertainty: "no_effect",
39341
+ occurredAt: new Date(clock.now()).toISOString(),
39342
+ scope: { runId: spec.runId, conversationId: spec.conversationId },
39343
+ apiKeySupplied
39344
+ });
39345
+ return { outcome: "failed", message: problem.detail, problem };
39315
39346
  }
39316
39347
  function createPersistentDriver(provider4, options) {
39317
39348
  const { log, clock } = options;
@@ -40144,9 +40175,9 @@ var import_http4, import_crypto13, import_promises24, import_path10, import_path
40144
40175
  var init_opencode = __esm({
40145
40176
  "../agent-core/dist/providers/opencode.js"() {
40146
40177
  "use strict";
40147
- init_chunk_W3QH4J4A();
40178
+ init_chunk_YPYC4VBL();
40148
40179
  init_chunk_UGRKZTAD();
40149
- init_chunk_R6R6ORR2();
40180
+ init_chunk_54ZRJOQP();
40150
40181
  init_chunk_J2KTV5FP();
40151
40182
  init_chunk_J4T6L5LX();
40152
40183
  init_chunk_6WN2R725();
@@ -41420,21 +41451,63 @@ var codex_exports = {};
41420
41451
  __export(codex_exports, {
41421
41452
  createCodexHolderDriver: () => createCodexHolderDriver
41422
41453
  });
41454
+ function sha2562(value) {
41455
+ return (0, import_node_crypto12.createHash)("sha256").update(value).digest("hex");
41456
+ }
41457
+ function createCodexLogin(broker) {
41458
+ const state = {};
41459
+ return {
41460
+ forTurn: (runId, tokens2) => {
41461
+ state.runId = runId;
41462
+ state.latest = tokens2;
41463
+ },
41464
+ externalAuth: {
41465
+ current: async () => {
41466
+ if (state.latest === void 0) throw new Error("No Codex sign-in for this turn");
41467
+ state.given = state.latest;
41468
+ return state.given;
41469
+ },
41470
+ refresh: async () => {
41471
+ if (broker === void 0 || state.runId === void 0) {
41472
+ throw new Error("Codex sign-in cannot be refreshed on this machine");
41473
+ }
41474
+ const rejected2 = state.given === void 0 ? void 0 : sha2562(state.given.accessToken);
41475
+ const fresh = await broker.refresh(state.runId, rejected2);
41476
+ state.latest = fresh;
41477
+ state.given = fresh;
41478
+ return fresh;
41479
+ }
41480
+ }
41481
+ };
41482
+ }
41483
+ function withLogin(planned, externalAuth, accountId) {
41484
+ return {
41485
+ ...planned,
41486
+ spec: { ...planned.spec, externalAuth },
41487
+ key: JSON.stringify([planned.key, accountId])
41488
+ };
41489
+ }
41423
41490
  function createCodexHolderDriver(options) {
41424
41491
  const clock = options.clock ?? systemClock2;
41425
41492
  const sessions = options.sessions ?? createCodexDriver({ ...options.timings, clock, log: options.log });
41493
+ const login = createCodexLogin(options.codexCredentials);
41426
41494
  return createPersistentDriver(
41427
41495
  {
41428
41496
  harness: "codex_app_server",
41429
41497
  displayName: "Codex app-server",
41430
- plan: (spec, inputs, resumeId, managedMcp) => planCodexSession(spec, {
41431
- command: options.command ?? "codex",
41432
- cwd: spec.projectPath ?? options.defaultCwd,
41433
- cliEnv: options.cliEnvironment,
41434
- providerEnv: inputs.providerEnv,
41435
- ...managedMcp === void 0 ? {} : { managedMcp },
41436
- ...resumeId === void 0 ? {} : { resumeThreadId: resumeId }
41437
- }),
41498
+ plan: (spec, inputs, resumeId, managedMcp) => {
41499
+ const planned = planCodexSession(spec, {
41500
+ command: options.command ?? "codex",
41501
+ cwd: spec.projectPath ?? options.defaultCwd,
41502
+ cliEnv: options.cliEnvironment,
41503
+ providerEnv: inputs.providerEnv,
41504
+ ...managedMcp === void 0 ? {} : { managedMcp },
41505
+ ...resumeId === void 0 ? {} : { resumeThreadId: resumeId }
41506
+ });
41507
+ if (inputs.codex === void 0) return planned;
41508
+ login.forTurn(spec.runId, inputs.codex);
41509
+ return withLogin(planned, login.externalAuth, inputs.codex.chatgptAccountId);
41510
+ },
41438
41511
  canResume: () => true,
41439
41512
  open: async (spec) => {
41440
41513
  const session = await sessions.open(spec);
@@ -41454,9 +41527,11 @@ function createCodexHolderDriver(options) {
41454
41527
  }
41455
41528
  );
41456
41529
  }
41530
+ var import_node_crypto12;
41457
41531
  var init_codex2 = __esm({
41458
41532
  "src/holder/drivers/codex.ts"() {
41459
41533
  "use strict";
41534
+ import_node_crypto12 = require("crypto");
41460
41535
  init_dist();
41461
41536
  init_codex();
41462
41537
  init_persistent();
@@ -41908,9 +41983,9 @@ var import_crypto15, import_promises25, FACTORY_API_VERSION, FACTORY_PROTOCOL_VE
41908
41983
  var init_droid = __esm({
41909
41984
  "../agent-core/dist/providers/droid.js"() {
41910
41985
  "use strict";
41911
- init_chunk_W3QH4J4A();
41986
+ init_chunk_YPYC4VBL();
41912
41987
  init_chunk_UGRKZTAD();
41913
- init_chunk_R6R6ORR2();
41988
+ init_chunk_54ZRJOQP();
41914
41989
  init_chunk_J2KTV5FP();
41915
41990
  init_chunk_J4T6L5LX();
41916
41991
  init_chunk_6WN2R725();
@@ -42381,6 +42456,35 @@ var init_opencode2 = __esm({
42381
42456
  });
42382
42457
 
42383
42458
  // ../agent-core/dist/providers/antigravity.js
42459
+ function settingsPath(env) {
42460
+ const home = env.HOME?.trim() || env.USERPROFILE?.trim();
42461
+ return home ? (0, import_path12.resolve)(home, ".gemini", "antigravity-cli", "settings.json") : void 0;
42462
+ }
42463
+ async function readSettings(path) {
42464
+ let raw;
42465
+ try {
42466
+ raw = (await (0, import_promises26.readFile)(path, "utf8")).trim();
42467
+ } catch {
42468
+ return {};
42469
+ }
42470
+ if (!raw) return {};
42471
+ try {
42472
+ const parsed = JSON.parse(raw);
42473
+ return isRecord(parsed) ? parsed : "malformed";
42474
+ } catch {
42475
+ return "malformed";
42476
+ }
42477
+ }
42478
+ async function selectAntigravityApiKeyMode(env) {
42479
+ const path = settingsPath(env);
42480
+ if (!env.GEMINI_API_KEY?.trim() || path === void 0) return "no_key";
42481
+ const settings2 = await readSettings(path);
42482
+ if (settings2 === "malformed") return "malformed";
42483
+ if (settings2.modelProvider === "gemini") return "already_selected";
42484
+ await (0, import_promises26.mkdir)((0, import_path12.dirname)(path), { recursive: true });
42485
+ await (0, import_promises26.writeFile)(path, JSON.stringify({ ...settings2, modelProvider: "gemini" }), { mode: 384 });
42486
+ return "selected";
42487
+ }
42384
42488
  function readAntigravityCapabilities(version2, help) {
42385
42489
  const text2 = help.toLowerCase().replace(/\s+/g, " ");
42386
42490
  const structured = /\bstream-json\b/.test(text2) || /\bjsonl\b/.test(text2) || /\bjson\b/.test(text2);
@@ -42421,21 +42525,21 @@ function antigravityArgs(input2, capabilities, prompt) {
42421
42525
  ];
42422
42526
  }
42423
42527
  function workspaceRoot(cwd) {
42424
- for (let current = (0, import_path12.resolve)(cwd); ; current = (0, import_path12.dirname)(current)) {
42425
- if ((0, import_fs8.existsSync)((0, import_path12.join)(current, ".git"))) return current;
42426
- if ((0, import_path12.dirname)(current) === current) return (0, import_path12.resolve)(cwd);
42528
+ for (let current = (0, import_path13.resolve)(cwd); ; current = (0, import_path13.dirname)(current)) {
42529
+ if ((0, import_fs8.existsSync)((0, import_path13.join)(current, ".git"))) return current;
42530
+ if ((0, import_path13.dirname)(current) === current) return (0, import_path13.resolve)(cwd);
42427
42531
  }
42428
42532
  }
42429
42533
  function instructionPaths(cwd) {
42430
42534
  const root = workspaceRoot(cwd);
42431
42535
  const paths = [];
42432
- for (let current = (0, import_path12.resolve)(cwd); ; current = (0, import_path12.dirname)(current)) {
42433
- const path = (0, import_path12.join)(current, INSTRUCTIONS_FILE);
42536
+ for (let current = (0, import_path13.resolve)(cwd); ; current = (0, import_path13.dirname)(current)) {
42537
+ const path = (0, import_path13.join)(current, INSTRUCTIONS_FILE);
42434
42538
  try {
42435
42539
  if ((0, import_fs8.existsSync)(path) && (0, import_fs8.statSync)(path).isFile()) paths.unshift(path);
42436
42540
  } catch {
42437
42541
  }
42438
- if (current === root || (0, import_path12.dirname)(current) === current) return paths;
42542
+ if (current === root || (0, import_path13.dirname)(current) === current) return paths;
42439
42543
  }
42440
42544
  }
42441
42545
  function antigravityWorkspaceInstructions(cwd, maxChars = MAX_INSTRUCTION_CHARS) {
@@ -42689,7 +42793,7 @@ function normalizeAntigravityFrame(event) {
42689
42793
  }
42690
42794
  function antigravityBrainRoot(env) {
42691
42795
  const home = env.HOME?.trim() || env.USERPROFILE?.trim();
42692
- return home ? (0, import_path13.resolve)(home, ".gemini", "antigravity-cli", "brain") : void 0;
42796
+ return home ? (0, import_path14.resolve)(home, ".gemini", "antigravity-cli", "brain") : void 0;
42693
42797
  }
42694
42798
  function parseEntry(text2) {
42695
42799
  try {
@@ -42727,14 +42831,14 @@ function childTranscriptPath(root, frame) {
42727
42831
  try {
42728
42832
  const url2 = new URL(logUri);
42729
42833
  if (url2.protocol !== "file:") return void 0;
42730
- path = (0, import_path13.resolve)((0, import_url3.fileURLToPath)(url2));
42834
+ path = (0, import_path14.resolve)((0, import_url3.fileURLToPath)(url2));
42731
42835
  } catch {
42732
42836
  return void 0;
42733
42837
  }
42734
- const fromRoot = (0, import_path13.relative)(root, path);
42735
- if (!fromRoot || (0, import_path13.isAbsolute)(fromRoot) || fromRoot.split(import_path13.sep).includes("..")) return void 0;
42838
+ const fromRoot = (0, import_path14.relative)(root, path);
42839
+ if (!fromRoot || (0, import_path14.isAbsolute)(fromRoot) || fromRoot.split(import_path14.sep).includes("..")) return void 0;
42736
42840
  const expected = [conversationId, ...LOG_DIRS, TRANSCRIPT_FILE];
42737
- const segments = fromRoot.split(import_path13.sep);
42841
+ const segments = fromRoot.split(import_path14.sep);
42738
42842
  const matches = segments.length === expected.length && segments.every((segment, index) => segment === expected[index]);
42739
42843
  return matches ? path : void 0;
42740
42844
  }
@@ -42912,11 +43016,15 @@ ${output2.stderr}`).join("\n")
42912
43016
  name: "antigravity_cli",
42913
43017
  capabilities,
42914
43018
  open: async (spec) => {
42915
- const found = await capabilities(spec.command, spec.env);
43019
+ const [found, apiKeyMode] = await Promise.all([
43020
+ capabilities(spec.command, spec.env),
43021
+ selectAntigravityApiKeyMode(spec.env).catch(() => "unwritable")
43022
+ ]);
42916
43023
  session.log.info("antigravity.opened", {
42917
43024
  version: found.version,
42918
43025
  structured: found.structuredPrint,
42919
- resumeId: spec.resumeSessionId
43026
+ resumeId: spec.resumeSessionId,
43027
+ apiKeyMode
42920
43028
  });
42921
43029
  return new AntigravitySession(
42922
43030
  provider2(spec, found, options.platform ?? process.platform),
@@ -42973,21 +43081,24 @@ function antigravityTurnInput(run, context) {
42973
43081
  });
42974
43082
  return { turnId: run.runId, text: appendImagePathReferences(text2, images) };
42975
43083
  }
42976
- var import_fs8, import_path12, import_path13, import_url3, import_crypto16, NO_ANTIGRAVITY_CAPABILITIES, INSTRUCTIONS_FILE, MAX_INSTRUCTION_CHARS, SHORTENED_NOTE, DIFF_BLOCK_START, DIFF_BLOCK_END, HUNK_HEADER, TRANSCRIPT_FILE, FULL_TRANSCRIPT_FILE, LOG_DIRS, TOOL_RESULT_TYPES, BrainTranscript, AntigravityTranscripts, ANTIGRAVITY_GRAMMAR_NAME, AntigravityGrammar, ignored, HANDLERS, SUCCESSFUL_STATUSES, SESSION_START_TYPES, RESULT_TYPES, SUBAGENT_START_TYPES, RESUME_FORKED, EXITED_WITHOUT_RESULT, AntigravityTurn, DEFAULTS6, AntigravitySession, WINDOWS_LINE_MARGIN;
43084
+ var import_promises26, import_path12, import_fs8, import_path13, import_path14, import_url3, import_crypto16, NO_ANTIGRAVITY_CAPABILITIES, INSTRUCTIONS_FILE, MAX_INSTRUCTION_CHARS, SHORTENED_NOTE, DIFF_BLOCK_START, DIFF_BLOCK_END, HUNK_HEADER, TRANSCRIPT_FILE, FULL_TRANSCRIPT_FILE, LOG_DIRS, TOOL_RESULT_TYPES, BrainTranscript, AntigravityTranscripts, ANTIGRAVITY_GRAMMAR_NAME, AntigravityGrammar, ignored, HANDLERS, SUCCESSFUL_STATUSES, SESSION_START_TYPES, RESULT_TYPES, SUBAGENT_START_TYPES, RESUME_FORKED, EXITED_WITHOUT_RESULT, AntigravityTurn, DEFAULTS6, AntigravitySession, WINDOWS_LINE_MARGIN;
42977
43085
  var init_antigravity = __esm({
42978
43086
  "../agent-core/dist/providers/antigravity.js"() {
42979
43087
  "use strict";
42980
43088
  init_chunk_DALFHI4B();
42981
- init_chunk_W3QH4J4A();
43089
+ init_chunk_YPYC4VBL();
42982
43090
  init_chunk_UGRKZTAD();
42983
- init_chunk_R6R6ORR2();
43091
+ init_chunk_54ZRJOQP();
42984
43092
  init_chunk_J4T6L5LX();
42985
43093
  init_chunk_6WN2R725();
42986
43094
  init_chunk_YXWJW7I5();
42987
- import_fs8 = require("fs");
43095
+ import_promises26 = require("fs/promises");
42988
43096
  import_path12 = require("path");
42989
- init_effort();
43097
+ init_type_guards();
43098
+ import_fs8 = require("fs");
42990
43099
  import_path13 = require("path");
43100
+ init_effort();
43101
+ import_path14 = require("path");
42991
43102
  import_url3 = require("url");
42992
43103
  import_crypto16 = require("crypto");
42993
43104
  init_agent2();
@@ -43027,7 +43138,7 @@ var init_antigravity = __esm({
43027
43138
  #full;
43028
43139
  constructor(path) {
43029
43140
  this.#cursor = new TranscriptCursor(path);
43030
- this.#fullPath = (0, import_path13.resolve)((0, import_path13.dirname)(path), FULL_TRANSCRIPT_FILE);
43141
+ this.#fullPath = (0, import_path14.resolve)((0, import_path14.dirname)(path), FULL_TRANSCRIPT_FILE);
43031
43142
  }
43032
43143
  skipExisting() {
43033
43144
  this.#cursor.read();
@@ -43075,7 +43186,7 @@ var init_antigravity = __esm({
43075
43186
  /** A conversation this turn did not resume was created by it, so it is read whole. */
43076
43187
  trackParent(conversationId) {
43077
43188
  if (this.#parent?.conversationId === conversationId) return;
43078
- const path = (0, import_path13.resolve)(this.#root, conversationId, ...LOG_DIRS, TRANSCRIPT_FILE);
43189
+ const path = (0, import_path14.resolve)(this.#root, conversationId, ...LOG_DIRS, TRANSCRIPT_FILE);
43079
43190
  this.#parent = { conversationId, transcript: new BrainTranscript(path) };
43080
43191
  }
43081
43192
  /** A launcher keeps the first valid transcript it names; later frames change nothing. */
@@ -43480,8 +43591,8 @@ function parseConfig(raw) {
43480
43591
  }
43481
43592
  }
43482
43593
  async function writeCommandCodeProjectMcp(cwd, mcp) {
43483
- const path = (0, import_path14.join)(cwd, ".mcp.json");
43484
- const original = await (0, import_promises26.readFile)(path, "utf8").catch(() => null);
43594
+ const path = (0, import_path15.join)(cwd, ".mcp.json");
43595
+ const original = await (0, import_promises27.readFile)(path, "utf8").catch(() => null);
43485
43596
  const config2 = parseConfig(original);
43486
43597
  const next = {
43487
43598
  ...config2,
@@ -43498,12 +43609,12 @@ async function writeCommandCodeProjectMcp(cwd, mcp) {
43498
43609
  }
43499
43610
  }
43500
43611
  };
43501
- await (0, import_promises26.mkdir)(cwd, { recursive: true });
43502
- await (0, import_promises26.writeFile)(path, `${JSON.stringify(next, null, 2)}
43612
+ await (0, import_promises27.mkdir)(cwd, { recursive: true });
43613
+ await (0, import_promises27.writeFile)(path, `${JSON.stringify(next, null, 2)}
43503
43614
  `);
43504
43615
  return async () => {
43505
- if (original === null) await (0, import_promises26.rm)(path, { force: true });
43506
- else await (0, import_promises26.writeFile)(path, original);
43616
+ if (original === null) await (0, import_promises27.rm)(path, { force: true });
43617
+ else await (0, import_promises27.writeFile)(path, original);
43507
43618
  };
43508
43619
  }
43509
43620
  function commandCodeString(value) {
@@ -43675,19 +43786,19 @@ function commandCodeTurnInput(run, context) {
43675
43786
  });
43676
43787
  return { turnId: run.runId, text: appendImagePathReferences(text2, images) };
43677
43788
  }
43678
- var import_promises26, import_path14, import_crypto17, COMMAND_CODE_GRAMMAR_NAME, SILENT3, CommandCodeGrammar, SHELL_TOOL, STOP_TOOLS, REPORTED_STATUS, SHELL_STATUS, SWEEP_INTERVAL_MS, CommandCodeBackgroundTasks, EXITED_WITHOUT_RESULT2, CommandCodeTurn, COMMAND_CODE_MAX_TURNS, DEFAULTS7, CommandCodeSession;
43789
+ var import_promises27, import_path15, import_crypto17, COMMAND_CODE_GRAMMAR_NAME, SILENT3, CommandCodeGrammar, SHELL_TOOL, STOP_TOOLS, REPORTED_STATUS, SHELL_STATUS, SWEEP_INTERVAL_MS, CommandCodeBackgroundTasks, EXITED_WITHOUT_RESULT2, CommandCodeTurn, COMMAND_CODE_MAX_TURNS, DEFAULTS7, CommandCodeSession;
43679
43790
  var init_command_code = __esm({
43680
43791
  "../agent-core/dist/providers/command-code.js"() {
43681
43792
  "use strict";
43682
- init_chunk_W3QH4J4A();
43793
+ init_chunk_YPYC4VBL();
43683
43794
  init_chunk_UGRKZTAD();
43684
- init_chunk_R6R6ORR2();
43795
+ init_chunk_54ZRJOQP();
43685
43796
  init_chunk_J2KTV5FP();
43686
43797
  init_chunk_J4T6L5LX();
43687
43798
  init_chunk_6WN2R725();
43688
43799
  init_chunk_YXWJW7I5();
43689
- import_promises26 = require("fs/promises");
43690
- import_path14 = require("path");
43800
+ import_promises27 = require("fs/promises");
43801
+ import_path15 = require("path");
43691
43802
  init_agent2();
43692
43803
  init_runtime_v2();
43693
43804
  init_acp();
@@ -44720,6 +44831,13 @@ function createHolderApiClient({
44720
44831
  }
44721
44832
  return runProviderCredentialSchema.parse(jsonBody(response));
44722
44833
  },
44834
+ refreshCodexCredential: async (runId, body, signal) => {
44835
+ const response = await request2("POST", runCodexCredentialRefreshPath(runId), signal, body);
44836
+ if (!isOk(response)) {
44837
+ throw new RuntimeFault("io_failed", `Codex sign-in refresh failed: ${response.status}`);
44838
+ }
44839
+ return runCodexCredentialSchema.parse(jsonBody(response));
44840
+ },
44723
44841
  mintMcpCredential: async (conversationId, signal) => {
44724
44842
  const response = await request2("POST", MACHINE_PATHS.mcpCredential, signal, {
44725
44843
  conversationId
@@ -45952,16 +46070,33 @@ function uint642(value) {
45952
46070
  // src/capabilities/skills/store.ts
45953
46071
  var import_promises19 = require("fs/promises");
45954
46072
  var import_node_path11 = require("path");
46073
+
46074
+ // ../shared/dist/node/alan-skill-identity.js
46075
+ var import_node_crypto9 = require("crypto");
46076
+ var ALAN_SKILL_NAMESPACE = "ec71d99b-d207-4ca2-a9eb-3a7bed4a73fd";
46077
+ function uuidV5(name, namespace) {
46078
+ const bytes = (0, import_node_crypto9.createHash)("sha1").update(Buffer.from(namespace.replaceAll("-", ""), "hex")).update(name, "utf8").digest().subarray(0, 16);
46079
+ bytes[6] = bytes[6] & 15 | 80;
46080
+ bytes[8] = bytes[8] & 63 | 128;
46081
+ const hex3 = bytes.toString("hex");
46082
+ return `${hex3.slice(0, 8)}-${hex3.slice(8, 12)}-${hex3.slice(12, 16)}-${hex3.slice(16, 20)}-${hex3.slice(20)}`;
46083
+ }
46084
+ function alanSkillId(slug) {
46085
+ return uuidV5(`alan:${slug}`, ALAN_SKILL_NAMESPACE);
46086
+ }
46087
+
46088
+ // src/capabilities/skills/store.ts
45955
46089
  init_runtime_v2();
45956
46090
  init_zod();
45957
- function skillsLayout(stateDir) {
46091
+ function skillsLayout(stateDir, home) {
45958
46092
  const root = (0, import_node_path11.join)(stateDir, "skills");
45959
46093
  return {
45960
46094
  root,
45961
46095
  installedFile: (0, import_node_path11.join)(root, "installed.json"),
45962
46096
  localFile: (0, import_node_path11.join)(root, "local.json"),
45963
46097
  versionsDir: (0, import_node_path11.join)(root, "versions"),
45964
- tmpDir: (0, import_node_path11.join)(root, "tmp")
46098
+ tmpDir: (0, import_node_path11.join)(root, "tmp"),
46099
+ nativeDir: home === void 0 || home === "" ? null : (0, import_node_path11.join)(home, ".agents", "skills")
45965
46100
  };
45966
46101
  }
45967
46102
  function packageDirectory(layout, versionId) {
@@ -46022,6 +46157,17 @@ async function isIntact(layout, skill) {
46022
46157
  return false;
46023
46158
  }
46024
46159
  }
46160
+ async function resolveNativeBuiltIn(layout, invocation) {
46161
+ const slug = invocation.displayName;
46162
+ if (layout.nativeDir === null || invocation.skillId !== alanSkillId(slug)) return null;
46163
+ const directory = (0, import_node_path11.join)(layout.nativeDir, slug);
46164
+ try {
46165
+ await inspectSkillPackage(directory, { expectedName: slug });
46166
+ return { packageDirectory: directory };
46167
+ } catch {
46168
+ return null;
46169
+ }
46170
+ }
46025
46171
  async function resolveSkillInvocations(layout, invocations) {
46026
46172
  if (invocations.length === 0) return { kind: "resolved", skills: [] };
46027
46173
  const installed = await readInstalledSkills(layout);
@@ -46040,9 +46186,11 @@ async function resolveSkillInvocations(layout, invocations) {
46040
46186
  );
46041
46187
  if (skill !== void 0 && await isIntact(layout, skill)) {
46042
46188
  resolved.push({ packageDirectory: packageDirectory(layout, skill.versionId) });
46043
- } else {
46044
- missing.push(invocation.displayName);
46189
+ continue;
46045
46190
  }
46191
+ const native = await resolveNativeBuiltIn(layout, invocation);
46192
+ if (native === null) missing.push(invocation.displayName);
46193
+ else resolved.push(native);
46046
46194
  }
46047
46195
  return missing.length === 0 ? { kind: "resolved", skills: resolved } : { kind: "missing", names: missing };
46048
46196
  }
@@ -46148,7 +46296,7 @@ async function openApprovedPaths(options) {
46148
46296
  }
46149
46297
 
46150
46298
  // src/capabilities/workspace/locks.ts
46151
- var import_node_crypto9 = require("crypto");
46299
+ var import_node_crypto10 = require("crypto");
46152
46300
  var import_promises21 = require("fs/promises");
46153
46301
  var import_node_path13 = require("path");
46154
46302
  init_zod();
@@ -46165,7 +46313,7 @@ var ownerSchema = external_exports.object({
46165
46313
  since: external_exports.number().int().nonnegative()
46166
46314
  });
46167
46315
  function repositoryLockKey(commonDir, platform) {
46168
- return (0, import_node_crypto9.createHash)("sha256").update(comparablePath(commonDir, platform)).digest("hex").slice(0, 32);
46316
+ return (0, import_node_crypto10.createHash)("sha256").update(comparablePath(commonDir, platform)).digest("hex").slice(0, 32);
46169
46317
  }
46170
46318
  async function readOwner(path) {
46171
46319
  let text2;
@@ -46278,7 +46426,7 @@ function openRepositoryLocks(options) {
46278
46426
  },
46279
46427
  tryShared: async (commonDir, runId) => {
46280
46428
  const { key, dir } = await folder(commonDir);
46281
- const file2 = `${RUN_FILE_PREFIX}${(0, import_node_crypto9.createHash)("sha256").update(runId).digest("hex").slice(0, 32)}.json`;
46429
+ const file2 = `${RUN_FILE_PREFIX}${(0, import_node_crypto10.createHash)("sha256").update(runId).digest("hex").slice(0, 32)}.json`;
46282
46430
  const path = (0, import_node_path13.join)(dir, file2);
46283
46431
  const owner = await self(runId);
46284
46432
  await writeJsonFileAtomic(path, owner);
@@ -46314,13 +46462,13 @@ function defaultInstallDir({ platform, home, env }) {
46314
46462
  }
46315
46463
 
46316
46464
  // src/sessions/index.ts
46317
- var import_node_crypto13 = require("crypto");
46318
- var import_promises34 = require("fs/promises");
46465
+ var import_node_crypto15 = require("crypto");
46466
+ var import_promises35 = require("fs/promises");
46319
46467
  var import_node_os6 = require("os");
46320
46468
  var import_node_path26 = require("path");
46321
46469
 
46322
46470
  // src/holder/control-client.ts
46323
- var import_node_crypto10 = require("crypto");
46471
+ var import_node_crypto11 = require("crypto");
46324
46472
  var import_node_net = require("net");
46325
46473
 
46326
46474
  // src/holder/ndjson.ts
@@ -46549,7 +46697,7 @@ function createConversationMcpAuthorization(options) {
46549
46697
  }
46550
46698
 
46551
46699
  // src/holder/run-inputs.ts
46552
- var import_promises27 = require("fs/promises");
46700
+ var import_promises28 = require("fs/promises");
46553
46701
  var import_node_path17 = require("path");
46554
46702
  var NO_RUN_INPUTS = {
46555
46703
  attachments: [],
@@ -46565,16 +46713,16 @@ function safeFilename(filename) {
46565
46713
  async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
46566
46714
  const dir = (0, import_node_path17.join)(tmpDir, "runs", spec.runId);
46567
46715
  const cleanup = async () => {
46568
- await (0, import_promises27.rm)(dir, { recursive: true, force: true });
46716
+ await (0, import_promises28.rm)(dir, { recursive: true, force: true });
46569
46717
  };
46570
46718
  try {
46571
46719
  const credential = await source.fetchProviderCredential(spec.runId, signal);
46572
46720
  const attachments = [];
46573
- if (spec.attachments?.length) await (0, import_promises27.mkdir)(dir, { recursive: true, mode: 448 });
46721
+ if (spec.attachments?.length) await (0, import_promises28.mkdir)(dir, { recursive: true, mode: 448 });
46574
46722
  for (const [index, attachment] of (spec.attachments ?? []).entries()) {
46575
46723
  const bytes = await source.downloadAttachment(spec.runId, attachment.id, signal);
46576
46724
  const path = (0, import_node_path17.join)(dir, `${index}-${safeFilename(attachment.filename)}`);
46577
- await (0, import_promises27.writeFile)(path, bytes, { mode: 384 });
46725
+ await (0, import_promises28.writeFile)(path, bytes, { mode: 384 });
46578
46726
  attachments.push({
46579
46727
  id: attachment.id,
46580
46728
  kind: attachment.kind,
@@ -46587,7 +46735,13 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
46587
46735
  ...attachment.height === void 0 ? {} : { height: attachment.height }
46588
46736
  });
46589
46737
  }
46590
- return { attachments, providerEnv: credential.env, skills, [Symbol.asyncDispose]: cleanup };
46738
+ return {
46739
+ attachments,
46740
+ providerEnv: credential.env,
46741
+ ...credential.codex === void 0 ? {} : { codex: credential.codex },
46742
+ skills,
46743
+ [Symbol.asyncDispose]: cleanup
46744
+ };
46591
46745
  } catch (error61) {
46592
46746
  await cleanup();
46593
46747
  throw error61;
@@ -46595,7 +46749,7 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [] }) {
46595
46749
  }
46596
46750
 
46597
46751
  // src/holder/serve.ts
46598
- var import_node_crypto12 = require("crypto");
46752
+ var import_node_crypto14 = require("crypto");
46599
46753
  var import_node_fs10 = require("fs");
46600
46754
  var import_node_net2 = require("net");
46601
46755
  var import_node_path25 = require("path");
@@ -46603,7 +46757,7 @@ init_runtime_v2();
46603
46757
 
46604
46758
  // src/holder/admission.ts
46605
46759
  var import_node_fs8 = require("fs");
46606
- var import_promises31 = require("fs/promises");
46760
+ var import_promises32 = require("fs/promises");
46607
46761
  var import_node_os5 = require("os");
46608
46762
  var import_node_path22 = require("path");
46609
46763
  init_constants();
@@ -46617,7 +46771,7 @@ function resolveAlanDefaultWorkspacePath(homeDirectory = (0, import_node_os4.hom
46617
46771
  }
46618
46772
 
46619
46773
  // src/holder/admission-relocation.ts
46620
- var import_promises28 = require("fs/promises");
46774
+ var import_promises29 = require("fs/promises");
46621
46775
  var import_node_path19 = require("path");
46622
46776
  var MAX_RELOCATION_CANDIDATES = 200;
46623
46777
  var RELOCATION_BUDGET_MS = 2e4;
@@ -46653,7 +46807,7 @@ async function originIdentity(git, path, signal) {
46653
46807
  }
46654
46808
  async function childDirectories(parent, limit) {
46655
46809
  try {
46656
- const entries = await (0, import_promises28.readdir)(parent, { withFileTypes: true });
46810
+ const entries = await (0, import_promises29.readdir)(parent, { withFileTypes: true });
46657
46811
  return entries.filter((entry) => entry.isDirectory()).slice(0, limit).map((entry) => (0, import_node_path19.join)(parent, entry.name));
46658
46812
  } catch {
46659
46813
  return [];
@@ -46689,8 +46843,8 @@ async function discoverRelocatedWorkspace(search) {
46689
46843
  }
46690
46844
 
46691
46845
  // src/holder/checkout-refresh.ts
46692
- var import_node_crypto11 = require("crypto");
46693
- var import_promises29 = require("fs/promises");
46846
+ var import_node_crypto13 = require("crypto");
46847
+ var import_promises30 = require("fs/promises");
46694
46848
  var import_node_path20 = require("path");
46695
46849
  function short(sha) {
46696
46850
  return sha.slice(0, 12);
@@ -46703,8 +46857,8 @@ function staleLine(path, snapshot2, tip) {
46703
46857
  }
46704
46858
  async function claimOnce(dir, name) {
46705
46859
  try {
46706
- await (0, import_promises29.mkdir)(dir, { recursive: true, mode: 448 });
46707
- await (await (0, import_promises29.open)((0, import_node_path20.join)(dir, name), "wx")).close();
46860
+ await (0, import_promises30.mkdir)(dir, { recursive: true, mode: 448 });
46861
+ await (await (0, import_promises30.open)((0, import_node_path20.join)(dir, name), "wx")).close();
46708
46862
  return true;
46709
46863
  } catch {
46710
46864
  return false;
@@ -46736,7 +46890,7 @@ async function fastForward(freshness, operationId, deps, signal) {
46736
46890
  async function atFirstLease(freshness, spec, deps, signal) {
46737
46891
  const first = await claimOnce(
46738
46892
  (0, import_node_path20.join)(deps.dir, "leased"),
46739
- (0, import_node_crypto11.createHash)("sha256").update(freshness.path).digest("hex")
46893
+ (0, import_node_crypto13.createHash)("sha256").update(freshness.path).digest("hex")
46740
46894
  );
46741
46895
  switch (freshness.state) {
46742
46896
  case "current":
@@ -46787,7 +46941,7 @@ function createCheckoutRefresh(deps) {
46787
46941
  }
46788
46942
 
46789
46943
  // src/holder/lease.ts
46790
- var import_promises30 = require("fs/promises");
46944
+ var import_promises31 = require("fs/promises");
46791
46945
  var import_node_path21 = require("path");
46792
46946
  var LEASE_CHECK_EVERY_MS = 5e3;
46793
46947
  var MAX_TRANSIENT_FAILURES = 3;
@@ -46802,8 +46956,8 @@ function identityFailure(code, workspacePath) {
46802
46956
  return { code, problemCode: "app.workspace.missing", message: MESSAGES[code], workspacePath };
46803
46957
  }
46804
46958
  async function fileIdentity(path) {
46805
- const canonical = await (0, import_promises30.realpath)(path);
46806
- const info = await (0, import_promises30.stat)(canonical, { bigint: true });
46959
+ const canonical = await (0, import_promises31.realpath)(path);
46960
+ const info = await (0, import_promises31.stat)(canonical, { bigint: true });
46807
46961
  return `${canonical}:${info.dev}:${info.ino}`;
46808
46962
  }
46809
46963
  async function snapshot(git, path, signal) {
@@ -46822,7 +46976,7 @@ async function snapshot(git, path, signal) {
46822
46976
  workspace: await fileIdentity(path),
46823
46977
  repository: await fileIdentity(commonDir),
46824
46978
  worktree: await fileIdentity(gitDir),
46825
- commonDir: await (0, import_promises30.realpath)(commonDir)
46979
+ commonDir: await (0, import_promises31.realpath)(commonDir)
46826
46980
  };
46827
46981
  } catch {
46828
46982
  return null;
@@ -46835,7 +46989,7 @@ async function gitValue(git, path, args, signal) {
46835
46989
  }
46836
46990
  async function pathExists(path) {
46837
46991
  try {
46838
- await (0, import_promises30.stat)(path);
46992
+ await (0, import_promises31.stat)(path);
46839
46993
  return true;
46840
46994
  } catch (error61) {
46841
46995
  return errnoCode(error61) !== "ENOENT" && errnoCode(error61) !== "ENOTDIR";
@@ -46844,13 +46998,13 @@ async function pathExists(path) {
46844
46998
  async function hasGitMarker(path) {
46845
46999
  let directory;
46846
47000
  try {
46847
- directory = await (0, import_promises30.realpath)(path);
47001
+ directory = await (0, import_promises31.realpath)(path);
46848
47002
  } catch {
46849
47003
  return true;
46850
47004
  }
46851
47005
  for (; ; ) {
46852
47006
  try {
46853
- await (0, import_promises30.stat)((0, import_node_path21.join)(directory, ".git"));
47007
+ await (0, import_promises31.stat)((0, import_node_path21.join)(directory, ".git"));
46854
47008
  return true;
46855
47009
  } catch (error61) {
46856
47010
  const code = errnoCode(error61);
@@ -47020,7 +47174,7 @@ function volumeRoot(path) {
47020
47174
  }
47021
47175
  async function exists(path) {
47022
47176
  try {
47023
- await (0, import_promises31.stat)(path);
47177
+ await (0, import_promises32.stat)(path);
47024
47178
  return true;
47025
47179
  } catch {
47026
47180
  return false;
@@ -47028,10 +47182,10 @@ async function exists(path) {
47028
47182
  }
47029
47183
  async function inspectReadiness(path) {
47030
47184
  try {
47031
- if (!(await (0, import_promises31.stat)(path)).isDirectory()) {
47185
+ if (!(await (0, import_promises32.stat)(path)).isDirectory()) {
47032
47186
  return { ready: false, missing: true, message: MESSAGES2.missing };
47033
47187
  }
47034
- await (0, import_promises31.access)(path, import_node_fs8.constants.R_OK | import_node_fs8.constants.W_OK | import_node_fs8.constants.X_OK);
47188
+ await (0, import_promises32.access)(path, import_node_fs8.constants.R_OK | import_node_fs8.constants.W_OK | import_node_fs8.constants.X_OK);
47035
47189
  return { ready: true };
47036
47190
  } catch (error61) {
47037
47191
  const code = errnoCode(error61) ?? "";
@@ -47109,8 +47263,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
47109
47263
  const { env } = context;
47110
47264
  const path = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os5.homedir)());
47111
47265
  try {
47112
- await (0, import_promises31.mkdir)(path, { recursive: true, mode: 448 });
47113
- await (0, import_promises31.access)(path, import_node_fs8.constants.R_OK | import_node_fs8.constants.W_OK | import_node_fs8.constants.X_OK);
47266
+ await (0, import_promises32.mkdir)(path, { recursive: true, mode: 448 });
47267
+ await (0, import_promises32.access)(path, import_node_fs8.constants.R_OK | import_node_fs8.constants.W_OK | import_node_fs8.constants.X_OK);
47114
47268
  return {
47115
47269
  kind: "admitted",
47116
47270
  spec: { ...spec, projectPath: path },
@@ -47181,7 +47335,10 @@ function createHolderWorkspace(machine, clock, log) {
47181
47335
  env: machine.env,
47182
47336
  git,
47183
47337
  platform,
47184
- skills: skillsLayout(machine.stateDir),
47338
+ skills: skillsLayout(
47339
+ machine.stateDir,
47340
+ machine.env.HOME || machine.env.USERPROFILE || (0, import_node_os5.homedir)()
47341
+ ),
47185
47342
  approvedRoots: async () => {
47186
47343
  const approved = await openApprovedPaths({
47187
47344
  file: (0, import_node_path22.join)(machine.stateDir, "workspaces.json"),
@@ -47225,7 +47382,7 @@ async function respondToTurn(runningRunId, gate, driver, request2) {
47225
47382
  }
47226
47383
 
47227
47384
  // src/holder/session-facts.ts
47228
- var import_promises32 = require("fs/promises");
47385
+ var import_promises33 = require("fs/promises");
47229
47386
  var CLI_RSS_CACHE_MS = 1e4;
47230
47387
  var LOGIN_PROBLEM_PREFIX = "cli.auth.";
47231
47388
  function isLoginFailure(result) {
@@ -47251,8 +47408,8 @@ function createSessionFacts(options) {
47251
47408
  const path = await resolveCommandOnPath(command, env, platform);
47252
47409
  if (path === null) return null;
47253
47410
  try {
47254
- const real = await (0, import_promises32.realpath)(path);
47255
- const info = await (0, import_promises32.stat)(real);
47411
+ const real = await (0, import_promises33.realpath)(path);
47412
+ const info = await (0, import_promises33.stat)(real);
47256
47413
  return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
47257
47414
  } catch {
47258
47415
  return null;
@@ -47339,7 +47496,7 @@ function createSessionFacts(options) {
47339
47496
  init_acp2();
47340
47497
 
47341
47498
  // src/run-log/directory.ts
47342
- var import_promises33 = require("fs/promises");
47499
+ var import_promises34 = require("fs/promises");
47343
47500
  var import_node_path23 = require("path");
47344
47501
  init_runtime_v2();
47345
47502
  init_zod();
@@ -47355,7 +47512,7 @@ function runDirectory(runsDir, runId) {
47355
47512
  }
47356
47513
  async function isRunClaimed(runsDir, runId) {
47357
47514
  try {
47358
- return (await (0, import_promises33.stat)(runDirectory(runsDir, runId).log)).size > 0;
47515
+ return (await (0, import_promises34.stat)(runDirectory(runsDir, runId).log)).size > 0;
47359
47516
  } catch (error61) {
47360
47517
  if (errnoCode(error61) === "ENOENT") return false;
47361
47518
  throw error61;
@@ -47703,13 +47860,13 @@ var TASK_UNSUPPORTED = {
47703
47860
  reason: "unsupported",
47704
47861
  message: "This agent cannot stop one background task."
47705
47862
  };
47706
- function sha2562(value) {
47707
- return (0, import_node_crypto12.createHash)("sha256").update(value).digest("hex");
47863
+ function sha2563(value) {
47864
+ return (0, import_node_crypto14.createHash)("sha256").update(value).digest("hex");
47708
47865
  }
47709
47866
  function tokenMatches(expected, presented) {
47710
- const a = Buffer.from(sha2562(expected), "hex");
47711
- const b = Buffer.from(sha2562(presented), "hex");
47712
- return (0, import_node_crypto12.timingSafeEqual)(a, b);
47867
+ const a = Buffer.from(sha2563(expected), "hex");
47868
+ const b = Buffer.from(sha2563(presented), "hex");
47869
+ return (0, import_node_crypto14.timingSafeEqual)(a, b);
47713
47870
  }
47714
47871
  async function runHolder({
47715
47872
  launch,
@@ -47746,7 +47903,7 @@ async function runHolder({
47746
47903
  startedAt: identity.startedAt,
47747
47904
  ...identity.command === void 0 ? {} : { command: identity.command },
47748
47905
  endpoint: launch.endpoint,
47749
- tokenSha256: sha2562(launch.token),
47906
+ tokenSha256: sha2563(launch.token),
47750
47907
  state: holder.state,
47751
47908
  runId: holder.runId,
47752
47909
  updatedAt: clock.now()
@@ -48210,7 +48367,14 @@ async function machineAccess(paths, log, conversationId, transport) {
48210
48367
  return (await api()).fetchProviderCredential(runId, signal);
48211
48368
  }
48212
48369
  };
48213
- return { source, managedMcp };
48370
+ const codexCredentials = {
48371
+ refresh: async (runId, rejectedAccessTokenSha256) => (await api()).refreshCodexCredential(
48372
+ runId,
48373
+ rejectedAccessTokenSha256 === void 0 ? {} : { rejectedAccessTokenSha256 },
48374
+ new AbortController().signal
48375
+ )
48376
+ };
48377
+ return { source, managedMcp, codexCredentials };
48214
48378
  }
48215
48379
  async function runHold(argv) {
48216
48380
  var _stack = [];
@@ -48245,6 +48409,7 @@ async function runHold(argv) {
48245
48409
  defaultCwd: process.cwd(),
48246
48410
  timings: config2.sessionTimings,
48247
48411
  log,
48412
+ codexCredentials: access3.codexCredentials,
48248
48413
  ...access3.managedMcp === void 0 ? {} : { managedMcp: access3.managedMcp }
48249
48414
  }),
48250
48415
  clock: systemClock,