lody 0.70.2 → 0.71.1

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.
@@ -1,4 +1,4 @@
1
- import { o as object, s as string, l as literal, c as boolean, d as discriminatedUnion, n as number, a as _enum, b as array, u as union, r as record, G as tuple, f as unknown } from "./schemas-Dq_X20sw.js";
1
+ import { o as object, s as string, l as literal, b as boolean, a as _enum, u as union, n as number, d as discriminatedUnion, c as array, r as record, G as tuple, e as unknown } from "./schemas-CRNtikkJ.js";
2
2
  import { execFile } from "node:child_process";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import path__default from "node:path";
@@ -149,6 +149,9 @@ const CodeCollabV2OpenTextOkSchema = object({
149
149
  format: CodeCollabV2TextFormatSchema.optional(),
150
150
  readonly: boolean().optional()
151
151
  }).strict();
152
+ object({
153
+ sessionId: string().trim().min(1)
154
+ }).strict();
152
155
  const CodeCollabV2RefreshTextRequestSchema = object({
153
156
  sessionId: string().trim().min(1),
154
157
  path: string().min(1),
@@ -369,10 +372,17 @@ const CodeCollabV2FileIndexValueSchema = union([
369
372
  reason: string().min(1)
370
373
  }).strict()
371
374
  ]);
372
- record(
375
+ const CodeCollabV2FileIndexStateSchema = record(
373
376
  string().min(1),
374
377
  CodeCollabV2FileIndexValueSchema
375
378
  );
379
+ const CodeCollabV2FileIndexSnapshotSchema = object({
380
+ status: literal("ok"),
381
+ ownerSessionId: string().trim().min(1),
382
+ fileIndex: CodeCollabV2FileIndexStateSchema,
383
+ updatedAtMs: number().finite().nonnegative()
384
+ }).strict();
385
+ const CODE_COLLAB_FILE_INDEX_SIGNAL_KEY = ["s"];
376
386
  const codeCollabFileIndexKeyForWorkspacePath = (workspacePath) => [workspacePath];
377
387
  const isCodeCollabRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
378
388
  const isCodeCollabMissing = (value) => value === void 0 || value === null;
@@ -470,6 +480,13 @@ const normalizeCodeCollabFileIndexValue = (value) => {
470
480
  return void 0;
471
481
  }
472
482
  };
483
+ const normalizeCodeCollabFileIndexSignalValue = (value) => {
484
+ if (!isCodeCollabRecord(value) || !hasOnlyCodeCollabKeys(value, ["v", "r"])) {
485
+ return void 0;
486
+ }
487
+ return value.v === 1 && isNonNegativeInteger(value.r) ? { v: 1, r: value.r } : void 0;
488
+ };
489
+ const isCodeCollabFileIndexSignalKey = (key) => key.length === 1 && key[0] === CODE_COLLAB_FILE_INDEX_SIGNAL_KEY[0];
473
490
  function readCodeCollabFileIndexFromFlock(flock) {
474
491
  const fileIndex = {};
475
492
  for (const row of flock.scan()) {
@@ -488,6 +505,31 @@ function readCodeCollabFileIndexFromFlock(flock) {
488
505
  }
489
506
  return fileIndex;
490
507
  }
508
+ function readCodeCollabFileIndexSignalFromFlock(flock) {
509
+ for (const row of flock.scan()) {
510
+ if (row.value === void 0 || !isCodeCollabFileIndexSignalKey(row.key)) {
511
+ continue;
512
+ }
513
+ const parsed = normalizeCodeCollabFileIndexSignalValue(row.value);
514
+ if (!parsed) {
515
+ throw new Error("Invalid Code Collab file-index signal Flock value.");
516
+ }
517
+ return parsed;
518
+ }
519
+ return null;
520
+ }
521
+ function writeCodeCollabFileIndexSignalToFlock(flock, revision, nowMs) {
522
+ if (!isNonNegativeInteger(revision)) {
523
+ throw new Error("Code Collab file-index signal revision must be a non-negative integer.");
524
+ }
525
+ const previous = readCodeCollabFileIndexSignalFromFlock(flock);
526
+ if (previous?.r === revision) {
527
+ return false;
528
+ }
529
+ flock.set(CODE_COLLAB_FILE_INDEX_SIGNAL_KEY, { v: 1, r: revision }, nowMs);
530
+ flock.commit();
531
+ return true;
532
+ }
491
533
  function writeCodeCollabFileIndexToFlock(flock, next, nowMs) {
492
534
  const previous = readCodeCollabFileIndexFromFlock(flock);
493
535
  let changed = false;
@@ -594,8 +636,9 @@ const CodeCollabV2RpcContentEnvelopeSchema = object({
594
636
  iv: string().trim().min(1),
595
637
  ciphertext: string().trim().min(1)
596
638
  }).strict();
597
- union([
639
+ const CodeCollabV2RpcResponseSchema = union([
598
640
  CodeCollabV2OpenTextOkSchema,
641
+ CodeCollabV2FileIndexSnapshotSchema,
599
642
  CodeCollabV2RefreshTextResponseSchema,
600
643
  CodeCollabV2SaveTextResponseSchema,
601
644
  CodeCollabV2OpenCurrentDiffResponseSchema,
@@ -1088,11 +1131,14 @@ async function closeDirectoryQuietly(directory) {
1088
1131
  }
1089
1132
  }
1090
1133
  export {
1091
- writeCodeCollabFileIndexToFlock as A,
1092
- joinWorkspacePath as B,
1134
+ closeDirectoryQuietly as A,
1135
+ readCodeCollabFileIndexSignalFromFlock as B,
1093
1136
  CodeCollabV2OpenTextRequestSchema as C,
1094
- isInsideGitWorktree as D,
1095
- pathSegmentComparisonKey as E,
1137
+ writeCodeCollabFileIndexSignalToFlock as D,
1138
+ writeCodeCollabFileIndexToFlock as E,
1139
+ joinWorkspacePath as F,
1140
+ isInsideGitWorktree as G,
1141
+ pathSegmentComparisonKey as H,
1096
1142
  CodeCollabV2RefreshTextRequestSchema as a,
1097
1143
  CodeCollabV2SaveTextRequestSchema as b,
1098
1144
  CodeCollabV2OpenCurrentDiffRequestSchema as c,
@@ -1110,13 +1156,13 @@ export {
1110
1156
  CodeCollabV2ErrorSchema as o,
1111
1157
  CodeCollabV2RpcContentEnvelopeSchema as p,
1112
1158
  deriveCodeCollabV2ContentKeyId as q,
1113
- deriveCodeCollabV2ContentKeyBytes as r,
1114
- CodeCollabV2ErrorCodeSchema as s,
1115
- CODE_COLLAB_V2_TEXT_LIMITS as t,
1116
- CODE_COLLAB_V2_ALL_CHANGES_DIFF_LIMITS as u,
1117
- computeAllChanges as v,
1118
- buildCodeCollabFileIndexState as w,
1119
- codeCollabFileIndexStatesEqual as x,
1120
- scanGitDirectoryEntries as y,
1121
- closeDirectoryQuietly as z
1159
+ CodeCollabV2ErrorCodeSchema as r,
1160
+ CodeCollabV2RpcResponseSchema as s,
1161
+ deriveCodeCollabV2ContentKeyBytes as t,
1162
+ buildCodeCollabFileIndexState as u,
1163
+ CODE_COLLAB_V2_TEXT_LIMITS as v,
1164
+ CODE_COLLAB_V2_ALL_CHANGES_DIFF_LIMITS as w,
1165
+ computeAllChanges as x,
1166
+ codeCollabFileIndexStatesEqual as y,
1167
+ scanGitDirectoryEntries as z
1122
1168
  };
@@ -24487,13 +24487,15 @@ var AgentMode = class _AgentMode {
24487
24487
  approvalPolicy;
24488
24488
  sandboxPolicy;
24489
24489
  sandboxMode;
24490
- constructor(id, name, description, approval, sandbox, sandboxMode) {
24490
+ approvalsReviewer;
24491
+ constructor(id, name, description, approval, sandbox, sandboxMode, approvalsReviewer = "user") {
24491
24492
  this.id = id;
24492
24493
  this.name = name;
24493
24494
  this.description = description;
24494
24495
  this.approvalPolicy = approval;
24495
24496
  this.sandboxPolicy = sandbox;
24496
24497
  this.sandboxMode = sandboxMode;
24498
+ this.approvalsReviewer = approvalsReviewer;
24497
24499
  }
24498
24500
  static ReadOnly = new _AgentMode(
24499
24501
  "read-only",
@@ -24520,6 +24522,21 @@ var AgentMode = class _AgentMode {
24520
24522
  },
24521
24523
  "workspace-write"
24522
24524
  );
24525
+ static AgentAutoReview = new _AgentMode(
24526
+ "agent-auto-review",
24527
+ "Agent (auto review)",
24528
+ "Read and edit files, and run commands. Approval requests are reviewed automatically by a Codex subagent.",
24529
+ "on-request",
24530
+ {
24531
+ type: "workspaceWrite",
24532
+ writableRoots: [],
24533
+ networkAccess: false,
24534
+ excludeTmpdirEnvVar: false,
24535
+ excludeSlashTmp: false
24536
+ },
24537
+ "workspace-write",
24538
+ "auto_review"
24539
+ );
24523
24540
  static AgentFullAccess = new _AgentMode(
24524
24541
  "agent-full-access",
24525
24542
  "Agent (full access)",
@@ -24558,7 +24575,7 @@ var AgentMode = class _AgentMode {
24558
24575
  };
24559
24576
  }
24560
24577
  static all() {
24561
- return [_AgentMode.ReadOnly, _AgentMode.Agent, _AgentMode.AgentFullAccess];
24578
+ return [_AgentMode.ReadOnly, _AgentMode.Agent, _AgentMode.AgentAutoReview, _AgentMode.AgentFullAccess];
24562
24579
  }
24563
24580
  static find(modeId) {
24564
24581
  const match = _AgentMode.all().find((m) => m.id === modeId);
@@ -25163,6 +25180,7 @@ var CodexAcpClient = class {
25163
25180
  threadId: request.sessionId,
25164
25181
  input,
25165
25182
  approvalPolicy: agentMode.approvalPolicy,
25183
+ approvalsReviewer: agentMode.approvalsReviewer,
25166
25184
  sandboxPolicy: addAdditionalDirectoriesToSandboxPolicy(agentMode.sandboxPolicy, additionalDirectories),
25167
25185
  summary: disableSummary ? "none" : "auto",
25168
25186
  effort,
@@ -25531,22 +25549,31 @@ var CodexCommands = class {
25531
25549
  this.runWithProcessCheck = runWithProcessCheck;
25532
25550
  this.onLogout = onLogout;
25533
25551
  }
25534
- async publish(sessionState) {
25552
+ async publish(sessionState, availableCommands) {
25535
25553
  try {
25536
- const skillsResponse = await this.runWithProcessCheck(() => this.codexAcpClient.listSkills(this.createSkillsListParams(sessionState)));
25537
- const availableCommands = this.buildAvailableCommands(skillsResponse?.data ?? []);
25538
- if (availableCommands.length === 0) {
25554
+ const commands = availableCommands ?? await this.getAvailableCommands(sessionState);
25555
+ if (commands.length === 0) {
25539
25556
  return;
25540
25557
  }
25541
25558
  const session = new ACPSessionConnection(this.connection, sessionState.sessionId);
25542
25559
  await session.update({
25543
25560
  sessionUpdate: "available_commands_update",
25544
- availableCommands
25561
+ availableCommands: commands
25545
25562
  });
25546
25563
  } catch (err) {
25547
25564
  logger.error(`Failed to publish available commands for session ${sessionState.sessionId}`, err);
25548
25565
  }
25549
25566
  }
25567
+ async getAvailableCommands(sessionState) {
25568
+ let skillsEntries = [];
25569
+ try {
25570
+ const skillsResponse = await this.runWithProcessCheck(() => this.codexAcpClient.listSkills(this.createSkillsListParams(sessionState)));
25571
+ skillsEntries = skillsResponse?.data ?? [];
25572
+ } catch (err) {
25573
+ logger.error(`Failed to resolve available commands for session ${sessionState.sessionId}`, err);
25574
+ }
25575
+ return this.buildAvailableCommands(skillsEntries);
25576
+ }
25550
25577
  createSkillsListParams(sessionState) {
25551
25578
  return {
25552
25579
  cwds: [sessionState.cwd, ...sessionState.additionalDirectories]
@@ -27244,10 +27271,10 @@ You have been logged out. Please try again.`);
27244
27271
  });
27245
27272
  this.publishMcpStartupStatusAsync(sessionId);
27246
27273
  }
27247
- this.publishAvailableCommandsAsync(sessionState);
27274
+ const availableCommands = await this.availableCommands.getAvailableCommands(sessionState);
27248
27275
  const sessionModelState = this.createModelState(models, currentModelId);
27249
27276
  const sessionModeState = sessionState.agentMode.toSessionModeState();
27250
- return [sessionId, sessionModelState, sessionModeState];
27277
+ return [sessionId, sessionModelState, sessionModeState, availableCommands];
27251
27278
  }
27252
27279
  async getAuthStateForProvider(authProvider) {
27253
27280
  if (!this.authProviderUsesOpenAiAccount(authProvider)) {
@@ -27304,9 +27331,11 @@ You have been logged out. Please try again.`);
27304
27331
  sessionId,
27305
27332
  modelState,
27306
27333
  modeState,
27307
- thread
27334
+ thread,
27335
+ availableCommands
27308
27336
  } = await this.getOrCreateSessionWithHistory(params);
27309
27337
  await this.streamThreadHistory(sessionId, thread);
27338
+ this.publishAvailableCommandsAsync(sessionId, availableCommands);
27310
27339
  logger.log("Session loaded", {
27311
27340
  sessionId,
27312
27341
  modelId: modelState.currentModelId,
@@ -27315,12 +27344,14 @@ You have been logged out. Please try again.`);
27315
27344
  return {
27316
27345
  models: modelState,
27317
27346
  modes: modeState,
27347
+ availableCommands,
27318
27348
  ...this.createSessionConfigOptionsResponse(this.getSessionState(sessionId))
27319
27349
  };
27320
27350
  }
27321
27351
  async resumeSession(params) {
27322
27352
  logger.log("Resuming session...", { sessionId: params.sessionId });
27323
- const [sessionId, modelState, modeState] = await this.getOrCreateSession(params);
27353
+ const [sessionId, modelState, modeState, availableCommands] = await this.getOrCreateSession(params);
27354
+ this.publishAvailableCommandsAsync(sessionId, availableCommands);
27324
27355
  logger.log("Session resumed", {
27325
27356
  sessionId,
27326
27357
  modelId: modelState.currentModelId,
@@ -27329,6 +27360,7 @@ You have been logged out. Please try again.`);
27329
27360
  return {
27330
27361
  models: modelState,
27331
27362
  modes: modeState,
27363
+ availableCommands,
27332
27364
  ...this.createSessionConfigOptionsResponse(this.getSessionState(sessionId))
27333
27365
  };
27334
27366
  }
@@ -27405,7 +27437,8 @@ You have been logged out. Please try again.`);
27405
27437
  }
27406
27438
  async newSession(params) {
27407
27439
  logger.log("Starting new session...");
27408
- const [sessionId, modelState, modeState] = await this.getOrCreateSession(params);
27440
+ const [sessionId, modelState, modeState, availableCommands] = await this.getOrCreateSession(params);
27441
+ this.publishAvailableCommandsAsync(sessionId, availableCommands);
27409
27442
  logger.log("New session created", {
27410
27443
  sessionId,
27411
27444
  modelId: modelState.currentModelId,
@@ -27415,9 +27448,19 @@ You have been logged out. Please try again.`);
27415
27448
  sessionId,
27416
27449
  models: modelState,
27417
27450
  modes: modeState,
27451
+ availableCommands,
27418
27452
  ...this.createSessionConfigOptionsResponse(this.getSessionState(sessionId))
27419
27453
  };
27420
27454
  }
27455
+ publishAvailableCommandsAsync(sessionId, availableCommands) {
27456
+ setTimeout(() => {
27457
+ const sessionState = this.sessions.get(sessionId);
27458
+ if (!sessionState) return;
27459
+ void this.availableCommands.publish(sessionState, availableCommands).catch((err) => {
27460
+ logger.error(`Failed to publish available commands for session ${sessionId}`, err);
27461
+ });
27462
+ }, 0);
27463
+ }
27421
27464
  async authenticate(_params) {
27422
27465
  logger.log("Authenticate request received");
27423
27466
  const isAuthenticated = await this.runWithProcessCheck(() => this.codexAcpClient.authenticate(_params));
@@ -27635,9 +27678,6 @@ You have been logged out. Please try again.`);
27635
27678
  }
27636
27679
  };
27637
27680
  }
27638
- publishAvailableCommandsAsync(sessionState) {
27639
- void this.availableCommands.publish(sessionState);
27640
- }
27641
27681
  findCurrentModel(models, currentModelId) {
27642
27682
  const modelId = ModelId.fromString(currentModelId);
27643
27683
  return models.find((m) => m.id === modelId.model);
@@ -27732,14 +27772,15 @@ You have been logged out. Please try again.`);
27732
27772
  });
27733
27773
  this.publishMcpStartupStatusAsync(sessionId);
27734
27774
  }
27735
- await this.availableCommands.publish(sessionState);
27775
+ const availableCommands = await this.availableCommands.getAvailableCommands(sessionState);
27736
27776
  const sessionModelState = this.createModelState(models, currentModelId);
27737
27777
  const sessionModeState = sessionState.agentMode.toSessionModeState();
27738
27778
  return {
27739
27779
  sessionId,
27740
27780
  modelState: sessionModelState,
27741
27781
  modeState: sessionModeState,
27742
- thread
27782
+ thread,
27783
+ availableCommands
27743
27784
  };
27744
27785
  }
27745
27786
  async streamThreadHistory(sessionId, thread) {