lody 0.88.0 → 0.89.0

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/dist/index.js CHANGED
@@ -16,28 +16,28 @@ import * as path from "node:path";
16
16
  import path__default, { posix as posix$1, basename, win32, join as join$2, resolve as resolve$1, dirname as dirname$1, relative as relative$1, isAbsolute as isAbsolute$2, sep as sep$1, delimiter, normalize } from "node:path";
17
17
  import { _ as _coercedNumber, Z as ZodNumber$1, o as object$1, s as string$1, l as literal$1, n as number$4, b as boolean, a as _enum$1, c as array$2, d as discriminatedUnion, e as _instanceof, r as record$1, u as unknown, f as union$7, p as preprocess, g as ZodError$1, h as _null, i as normalizeParams, $ as $constructor, j as $ZodObject, k as defineLazy, m as $ZodType, q as parse$5, t as safeParse$1, v as parseAsync, w as safeParseAsync$1, x as clone$2, y as looseObject, z as intersection, A as optional$1, B as datetime, C as custom$1, D as toJSONSchema, E as ZodOptional$1, F as never$1, G as xor } from "./chunks/schemas-Du3qLZPS.js";
18
18
  import require$$0$4, { once as once$1, EventEmitter as EventEmitter$1 } from "node:events";
19
- import LE__default, { execFile, spawn as spawn$1, execFileSync } from "node:child_process";
19
+ import Gx__default, { execFile, spawn as spawn$1, execFileSync } from "node:child_process";
20
20
  import process$2 from "node:process";
21
21
  import tty from "node:tty";
22
22
  import * as os from "os";
23
23
  import os__default$1 from "os";
24
24
  import crypto__default$1, { randomFillSync, randomUUID, createHash, randomBytes, timingSafeEqual } from "node:crypto";
25
25
  import require$$0$5, { promisify as promisify$1 } from "util";
26
- import Zr, { Transform as Transform$1, Readable as Readable$1 } from "stream";
26
+ import So, { Transform as Transform$1, Readable as Readable$1 } from "stream";
27
27
  import require$$0$6, { Buffer as Buffer$1 } from "buffer";
28
28
  import require$$0$7, { EventEmitter as EventEmitter$2 } from "events";
29
- import * as $s from "zlib";
30
- import $s__default from "zlib";
29
+ import * as Ei from "zlib";
30
+ import Ei__default from "zlib";
31
31
  import require$$1$2 from "tty";
32
32
  import require$$1$3 from "string_decoder";
33
33
  import http from "http";
34
34
  import require$$1__default from "https";
35
35
  import require$$0$8, { promisify, inspect as inspect$1, stripVTControlCharacters, isDeepStrictEqual } from "node:util";
36
- import * as jt from "node:fs/promises";
37
- import jt__default, { mkdir as mkdir$1, realpath, symlink, mkdtemp, chmod, writeFile, rm, rename, readFile, readdir, stat, lstat, unlink, open, opendir } from "node:fs/promises";
36
+ import * as Yt from "node:fs/promises";
37
+ import Yt__default, { mkdir as mkdir$1, realpath, symlink, mkdtemp, chmod, writeFile, rm, rename, readFile, readdir, stat, lstat, unlink, open, opendir } from "node:fs/promises";
38
38
  import zlib__default, { gzip, gunzip as gunzip$1, gunzipSync, brotliDecompressSync } from "node:zlib";
39
39
  import require$$1$8, { exec, execFile as execFile$1, spawn as spawn$2 } from "child_process";
40
- import { i as imports, _ as __wbg_set_wasm$1, r as rawWasm, L as LoroDoc, E as EphemeralStoreWasm, U as UndoManager, c as callPendingEvents$3, a as LoroTree, b as LoroText, d as LoroMovableList, e as LoroList, f as LoroMap, V as VersionVector, g as __vite__initWasm, h as decodeImportBlobMeta, __tla as __tla_0 } from "./chunks/loro_wasm_bg-BPNKba8n.js";
40
+ import { i as imports, _ as __wbg_set_wasm$1, r as rawWasm, L as LoroDoc, E as EphemeralStoreWasm, U as UndoManager, a as isValidContainerId, c as callPendingEvents$3, b as LoroTree, d as LoroText, e as LoroMovableList, f as LoroList, g as LoroMap, V as VersionVector, h as __vite__initWasm, j as decodeImportBlobMeta, __tla as __tla_0 } from "./chunks/loro_wasm_bg-Br-Fa9wV.js";
41
41
  import { performance as performance$1 } from "perf_hooks";
42
42
  import require$$0$9 from "net";
43
43
  import require$$4$2 from "tls";
@@ -66,8 +66,8 @@ import { C as ClientSideConnection, P as PROTOCOL_VERSION, n as ndJsonStream } f
66
66
  import { StringDecoder } from "node:string_decoder";
67
67
  import { L as LODY_EXTENSION_METHODS, n as normalizeLodyExtensionMethod } from "./chunks/methods-CvEDMahD.js";
68
68
  import { pipeline, finished } from "node:stream/promises";
69
- import { p as packageJson } from "./chunks/package-CNW89xCh.js";
70
- import { r as runtimeManifest } from "./chunks/runtime-manifest-ByWJfM07.js";
69
+ import { p as packageJson } from "./chunks/package-4KuPYsnp.js";
70
+ import { r as runtimeManifest } from "./chunks/runtime-manifest-DnyvD_EC.js";
71
71
  import { AsyncLocalStorage as AsyncLocalStorage$1 } from "async_hooks";
72
72
  import { createRequire } from "module";
73
73
  import { c as computeLineCounts, a as countTextLines } from "./chunks/diff-line-counts-bmGB_T-n.js";
@@ -4325,7 +4325,7 @@ Upgrade Node, then re-run: npx lody@latest`;
4325
4325
  }
4326
4326
  const name$2 = "lody";
4327
4327
  const name$1 = "@lody/cli-cloud";
4328
- const version$9 = "0.88.0";
4328
+ const version$9 = "0.89.0";
4329
4329
  const type$2 = "module";
4330
4330
  const scripts = {
4331
4331
  "dev": "node dev.mjs",
@@ -7540,7 +7540,7 @@ Requirements:
7540
7540
  }
7541
7541
  finalize$1(instance.exports);
7542
7542
  } else {
7543
- const wkmod = wasmModuleOrExports instanceof WebAssembly.Module ? wasmModuleOrExports : await import("./chunks/loro_wasm_bg-BPNKba8n.js").then(async (m) => {
7543
+ const wkmod = wasmModuleOrExports instanceof WebAssembly.Module ? wasmModuleOrExports : await import("./chunks/loro_wasm_bg-Br-Fa9wV.js").then(async (m) => {
7544
7544
  await m.__tla;
7545
7545
  return m;
7546
7546
  }).then((n) => n.r);
@@ -7578,7 +7578,7 @@ Requirements:
7578
7578
  "Counter"
7579
7579
  ];
7580
7580
  function isContainerId(s) {
7581
- return s.startsWith("cid:");
7581
+ return isValidContainerId(s);
7582
7582
  }
7583
7583
  function isContainer(value) {
7584
7584
  if (typeof value !== "object" || value == null) {
@@ -10659,12 +10659,16 @@ Requirements:
10659
10659
  }
10660
10660
  }
10661
10661
  if (this.options.ignoreUnknownProperties) {
10662
- const fullDocState = toNormalizedJson(this.doc);
10663
- for (const key2 of Object.keys(fullDocState)) {
10662
+ const shallowDocState = this.doc.getShallowValue();
10663
+ for (const [key2, containerId] of Object.entries(shallowDocState)) {
10664
10664
  if (Object.prototype.hasOwnProperty.call(rootSchema.definition, key2)) {
10665
10665
  continue;
10666
10666
  }
10667
- root[key2] = fullDocState[key2];
10667
+ const container2 = this.doc.getContainerById(containerId);
10668
+ if (!container2) {
10669
+ throw new Error(`ContainerID not found: ${containerId}`);
10670
+ }
10671
+ root[key2] = normalizeContainerForJson(container2);
10668
10672
  }
10669
10673
  }
10670
10674
  return root;
@@ -10718,15 +10722,16 @@ Requirements:
10718
10722
  return Array.from(this.containerRegistry.keys());
10719
10723
  }
10720
10724
  }
10721
- const CID_PLACEHOLDER_PREFIX = "\0mirror:cid\0";
10722
10725
  function toNormalizedJson(doc) {
10723
- const withEnumerableCid = doc.toJsonWithReplacer((_k, v) => {
10724
- if (isContainer(v)) {
10725
- return normalizeContainerForJson(v);
10726
+ const root = {};
10727
+ for (const [key2, id2] of Object.entries(doc.getShallowValue())) {
10728
+ const container2 = doc.getContainerById(id2);
10729
+ if (!container2) {
10730
+ throw new Error(`ContainerID not found: ${id2}`);
10726
10731
  }
10727
- return v;
10728
- });
10729
- return restoreCidDescriptors(withEnumerableCid);
10732
+ root[key2] = normalizeContainerForJson(container2);
10733
+ }
10734
+ return root;
10730
10735
  }
10731
10736
  function normalizeContainerForJson(c) {
10732
10737
  const kind = c.kind();
@@ -10740,10 +10745,11 @@ Requirements:
10740
10745
  const m = c;
10741
10746
  const obj = {};
10742
10747
  for (const key2 of m.keys()) {
10748
+ if (key2 === CID_KEY) continue;
10743
10749
  const child = m.get(key2);
10744
10750
  obj[key2] = isContainer(child) ? normalizeContainerForJson(child) : child;
10745
10751
  }
10746
- obj[CID_KEY] = CID_PLACEHOLDER_PREFIX + m.id;
10752
+ defineCidProperty(obj, m.id);
10747
10753
  return obj;
10748
10754
  }
10749
10755
  if (kind === "List" || kind === "MovableList") {
@@ -10757,33 +10763,6 @@ Requirements:
10757
10763
  }
10758
10764
  return c.toJSON();
10759
10765
  }
10760
- function restoreCidDescriptors(value) {
10761
- if (Array.isArray(value)) {
10762
- for (let i2 = 0; i2 < value.length; i2++) {
10763
- value[i2] = restoreCidDescriptors(value[i2]);
10764
- }
10765
- return value;
10766
- }
10767
- if (isObject$3(value)) {
10768
- const obj = value;
10769
- for (const key2 of Object.keys(obj)) {
10770
- obj[key2] = restoreCidDescriptors(obj[key2]);
10771
- }
10772
- if (Object.prototype.hasOwnProperty.call(obj, CID_KEY)) {
10773
- const descriptor = Object.getOwnPropertyDescriptor(obj, CID_KEY);
10774
- if (!descriptor || descriptor.enumerable) {
10775
- const rawCid = obj[CID_KEY];
10776
- const cidValue = typeof rawCid === "string" && rawCid.startsWith(CID_PLACEHOLDER_PREFIX) ? rawCid.slice(CID_PLACEHOLDER_PREFIX.length) : rawCid;
10777
- delete obj[CID_KEY];
10778
- Object.defineProperty(obj, CID_KEY, {
10779
- value: cidValue
10780
- });
10781
- }
10782
- }
10783
- return obj;
10784
- }
10785
- return value;
10786
- }
10787
10766
  function normalizeInitialShapeShallow(input2) {
10788
10767
  const out = {};
10789
10768
  for (const [key2, value] of Object.entries(input2)) {
@@ -11075,6 +11054,20 @@ Requirements:
11075
11054
  status
11076
11055
  };
11077
11056
  }
11057
+ function getPendingUserTurnActivationId(meta) {
11058
+ const missingUserTurnId = meta.lastMissingHistoryUserMsgId;
11059
+ const settledUserTurnId = meta.settledActivationUserMsgId;
11060
+ if (typeof meta.processingUserMsgId === "string" && meta.processingUserMsgId.length > 0 && meta.processingUserMsgId !== missingUserTurnId && meta.processingUserMsgId !== settledUserTurnId) {
11061
+ return meta.processingUserMsgId;
11062
+ }
11063
+ if (typeof meta.latestUserMsgId === "string" && meta.latestUserMsgId.length > 0 && meta.latestUserMsgId !== meta.lastHandledUserMsgId && meta.latestUserMsgId !== missingUserTurnId && meta.latestUserMsgId !== settledUserTurnId) {
11064
+ return meta.latestUserMsgId;
11065
+ }
11066
+ return void 0;
11067
+ }
11068
+ function hasPendingUserTurnActivation(meta) {
11069
+ return getPendingUserTurnActivationId(meta) !== void 0;
11070
+ }
11078
11071
  const sessionSchema = schema.LoroMap({
11079
11072
  id: schema.String()
11080
11073
  });
@@ -11123,6 +11116,22 @@ Requirements:
11123
11116
  }, {
11124
11117
  required: false
11125
11118
  });
11119
+ const sessionAcpRuntimeConfigDocSchema = schema.LoroMap({
11120
+ acpSessionId: schema.String(),
11121
+ basedOnUserTurnId: schema.String(),
11122
+ revision: schema.Number(),
11123
+ modeId: schema.String({
11124
+ required: false
11125
+ }),
11126
+ modelId: schema.String({
11127
+ required: false
11128
+ }),
11129
+ configOptionValues: schema.Any({
11130
+ required: false
11131
+ })
11132
+ }, {
11133
+ required: false
11134
+ });
11126
11135
  const sessionDocSchema = schema({
11127
11136
  session: sessionSchema,
11128
11137
  history: schema.LoroList(sessionHistorySchema, (item) => item.id),
@@ -11131,7 +11140,8 @@ Requirements:
11131
11140
  }),
11132
11141
  forkOperation: sessionForkOperationDocSchema,
11133
11142
  preview: sessionPreviewDocSchema,
11134
- externalHistoryCursor: sessionExternalHistoryCursorDocSchema
11143
+ externalHistoryCursor: sessionExternalHistoryCursorDocSchema,
11144
+ acpRuntimeConfig: sessionAcpRuntimeConfigDocSchema
11135
11145
  });
11136
11146
  const resolveActiveAssistantTurnId = (history) => {
11137
11147
  if (!history?.length) {
@@ -11366,7 +11376,7 @@ Requirements:
11366
11376
  command: LocalPathLauncherStringSchema,
11367
11377
  args: array$2(LocalPathLauncherStringSchema).max(64).optional()
11368
11378
  }).strict();
11369
- discriminatedUnion("kind", [
11379
+ const LaunchLocalPathInputSchema = discriminatedUnion("kind", [
11370
11380
  object$1({
11371
11381
  kind: literal$1("url"),
11372
11382
  url: LocalPathLauncherStringSchema,
@@ -11382,6 +11392,12 @@ Requirements:
11382
11392
  label: string$1().trim().min(1).max(80).optional()
11383
11393
  }).strict()
11384
11394
  ]);
11395
+ object$1({
11396
+ launchers: array$2(object$1({
11397
+ launcherId: string$1().trim().min(1).max(200),
11398
+ input: LaunchLocalPathInputSchema
11399
+ }).strict()).max(30)
11400
+ }).strict();
11385
11401
  const CliRuntimePhaseSchema = _enum$1([
11386
11402
  "starting",
11387
11403
  "running",
@@ -12716,6 +12732,7 @@ Requirements:
12716
12732
  ]),
12717
12733
  authenticationRequestId: string$1().trim().min(1).optional(),
12718
12734
  authorizationCode: string$1().trim().min(1).max(4096).optional(),
12735
+ methodId: string$1().trim().min(1).max(256).optional(),
12719
12736
  configId: AgentConfigIdSchema.optional(),
12720
12737
  cliType: AgentConfigCliTypeSchema,
12721
12738
  agentType: string$1().trim().min(1),
@@ -12760,6 +12777,7 @@ Requirements:
12760
12777
  "cancelled",
12761
12778
  "not-running",
12762
12779
  "input-accepted",
12780
+ "method-required",
12763
12781
  "error"
12764
12782
  ]),
12765
12783
  capabilitiesRefreshed: boolean().optional(),
@@ -14619,12 +14637,12 @@ Requirements:
14619
14637
  {
14620
14638
  id: "codebuddy-code",
14621
14639
  name: "Codebuddy Code",
14622
- version: "2.140.0",
14640
+ version: "2.142.0",
14623
14641
  description: "Tencent Cloud's official intelligent coding tool",
14624
14642
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/codebuddy-code.svg",
14625
14643
  distribution: {
14626
14644
  npx: {
14627
- package: "@tencent-ai/codebuddy-code@2.140.0",
14645
+ package: "@tencent-ai/codebuddy-code@2.142.0",
14628
14646
  args: [
14629
14647
  "--acp"
14630
14648
  ]
@@ -14796,48 +14814,48 @@ Requirements:
14796
14814
  {
14797
14815
  id: "devin",
14798
14816
  name: "Devin",
14799
- version: "3000.6.2",
14817
+ version: "3000.6.7",
14800
14818
  description: "Devin CLI coding agent by Cognition",
14801
14819
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/devin.svg",
14802
14820
  distribution: {
14803
14821
  binary: {
14804
14822
  "darwin-aarch64": {
14805
- archive: "https://static.devin.ai/cli/3000.6.2/devin-3000.6.2-aarch64-apple-darwin.tar.gz",
14823
+ archive: "https://static.devin.ai/cli/3000.6.7/devin-3000.6.7-aarch64-apple-darwin.tar.gz",
14806
14824
  cmd: "./bin/devin",
14807
14825
  args: [
14808
14826
  "acp"
14809
14827
  ]
14810
14828
  },
14811
14829
  "darwin-x86_64": {
14812
- archive: "https://static.devin.ai/cli/3000.6.2/devin-3000.6.2-x86_64-apple-darwin.tar.gz",
14830
+ archive: "https://static.devin.ai/cli/3000.6.7/devin-3000.6.7-x86_64-apple-darwin.tar.gz",
14813
14831
  cmd: "./bin/devin",
14814
14832
  args: [
14815
14833
  "acp"
14816
14834
  ]
14817
14835
  },
14818
14836
  "linux-aarch64": {
14819
- archive: "https://static.devin.ai/cli/3000.6.2/devin-3000.6.2-aarch64-unknown-linux.tar.gz",
14837
+ archive: "https://static.devin.ai/cli/3000.6.7/devin-3000.6.7-aarch64-unknown-linux.tar.gz",
14820
14838
  cmd: "./bin/devin",
14821
14839
  args: [
14822
14840
  "acp"
14823
14841
  ]
14824
14842
  },
14825
14843
  "linux-x86_64": {
14826
- archive: "https://static.devin.ai/cli/3000.6.2/devin-3000.6.2-x86_64-unknown-linux.tar.gz",
14844
+ archive: "https://static.devin.ai/cli/3000.6.7/devin-3000.6.7-x86_64-unknown-linux.tar.gz",
14827
14845
  cmd: "./bin/devin",
14828
14846
  args: [
14829
14847
  "acp"
14830
14848
  ]
14831
14849
  },
14832
14850
  "windows-aarch64": {
14833
- archive: "https://static.devin.ai/cli/3000.6.2/devin-3000.6.2-aarch64-pc-windows.zip",
14851
+ archive: "https://static.devin.ai/cli/3000.6.7/devin-3000.6.7-aarch64-pc-windows.zip",
14834
14852
  cmd: "./bin\\devin.exe",
14835
14853
  args: [
14836
14854
  "acp"
14837
14855
  ]
14838
14856
  },
14839
14857
  "windows-x86_64": {
14840
- archive: "https://static.devin.ai/cli/3000.6.2/devin-3000.6.2-x86_64-pc-windows.zip",
14858
+ archive: "https://static.devin.ai/cli/3000.6.7/devin-3000.6.7-x86_64-pc-windows.zip",
14841
14859
  cmd: "./bin\\devin.exe",
14842
14860
  args: [
14843
14861
  "acp"
@@ -14849,12 +14867,12 @@ Requirements:
14849
14867
  {
14850
14868
  id: "dimcode",
14851
14869
  name: "DimCode",
14852
- version: "0.3.21",
14870
+ version: "0.3.22",
14853
14871
  description: "A coding agent that puts leading models at your command.",
14854
14872
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/dimcode.svg",
14855
14873
  distribution: {
14856
14874
  npx: {
14857
- package: "dimcode@0.3.21",
14875
+ package: "dimcode@0.3.22",
14858
14876
  args: [
14859
14877
  "acp"
14860
14878
  ]
@@ -14864,12 +14882,12 @@ Requirements:
14864
14882
  {
14865
14883
  id: "dirac",
14866
14884
  name: "Dirac",
14867
- version: "0.5.1",
14885
+ version: "0.5.2",
14868
14886
  description: "Reduces API costs by more than 50%, produces better and faster work. Uses Hash anchored parallel edits, AST manipulation and a whole lot of neat optimizations. Fully Open Source.",
14869
14887
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/dirac.svg",
14870
14888
  distribution: {
14871
14889
  npx: {
14872
- package: "dirac-cli@0.5.1",
14890
+ package: "dirac-cli@0.5.2",
14873
14891
  args: [
14874
14892
  "--acp"
14875
14893
  ]
@@ -14879,12 +14897,12 @@ Requirements:
14879
14897
  {
14880
14898
  id: "factory-droid",
14881
14899
  name: "Factory Droid",
14882
- version: "0.205.1",
14900
+ version: "0.208.2",
14883
14901
  description: "Factory Droid - AI coding agent powered by Factory AI",
14884
14902
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/factory-droid.svg",
14885
14903
  distribution: {
14886
14904
  npx: {
14887
- package: "droid@0.205.1",
14905
+ package: "droid@0.208.2",
14888
14906
  args: [
14889
14907
  "exec",
14890
14908
  "--output-format",
@@ -14933,12 +14951,12 @@ Requirements:
14933
14951
  {
14934
14952
  id: "github-copilot-cli",
14935
14953
  name: "GitHub Copilot",
14936
- version: "1.0.81",
14954
+ version: "1.0.82",
14937
14955
  description: "GitHub's AI pair programmer",
14938
14956
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/github-copilot-cli.svg",
14939
14957
  distribution: {
14940
14958
  npx: {
14941
- package: "@github/copilot@1.0.81",
14959
+ package: "@github/copilot@1.0.82",
14942
14960
  args: [
14943
14961
  "--acp"
14944
14962
  ]
@@ -14948,12 +14966,12 @@ Requirements:
14948
14966
  {
14949
14967
  id: "glm-acp-agent",
14950
14968
  name: "GLM Agent",
14951
- version: "1.6.1",
14969
+ version: "1.7.0",
14952
14970
  description: "ACP agent powered by Zhipu AI's GLM Coding Plan models (glm-5.1, glm-5-turbo, glm-4.7, glm-4.5-air). Supports streaming, tool calls, mid-session model switching, image input via Z.AI Coding Plan Vision MCP, and session load/fork/resume with on-disk persistence.",
14953
14971
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/glm-acp-agent.svg",
14954
14972
  distribution: {
14955
14973
  npx: {
14956
- package: "glm-acp-agent@1.6.1"
14974
+ package: "glm-acp-agent@1.7.0"
14957
14975
  }
14958
14976
  }
14959
14977
  },
@@ -14978,13 +14996,13 @@ Requirements:
14978
14996
  {
14979
14997
  id: "harn",
14980
14998
  name: "Harn",
14981
- version: "0.10.118",
14999
+ version: "0.10.124",
14982
15000
  description: "Harn runs .harn agent pipelines as a native ACP coding agent over stdio.",
14983
15001
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/harn.svg",
14984
15002
  distribution: {
14985
15003
  binary: {
14986
15004
  "darwin-aarch64": {
14987
- archive: "https://github.com/burin-labs/harn/releases/download/v0.10.118/harn-aarch64-apple-darwin.tar.gz",
15005
+ archive: "https://github.com/burin-labs/harn/releases/download/v0.10.124/harn-aarch64-apple-darwin.tar.gz",
14988
15006
  cmd: "./harn",
14989
15007
  args: [
14990
15008
  "serve",
@@ -14992,7 +15010,7 @@ Requirements:
14992
15010
  ]
14993
15011
  },
14994
15012
  "darwin-x86_64": {
14995
- archive: "https://github.com/burin-labs/harn/releases/download/v0.10.118/harn-x86_64-apple-darwin.tar.gz",
15013
+ archive: "https://github.com/burin-labs/harn/releases/download/v0.10.124/harn-x86_64-apple-darwin.tar.gz",
14996
15014
  cmd: "./harn",
14997
15015
  args: [
14998
15016
  "serve",
@@ -15000,7 +15018,7 @@ Requirements:
15000
15018
  ]
15001
15019
  },
15002
15020
  "linux-aarch64": {
15003
- archive: "https://github.com/burin-labs/harn/releases/download/v0.10.118/harn-aarch64-unknown-linux-gnu.tar.gz",
15021
+ archive: "https://github.com/burin-labs/harn/releases/download/v0.10.124/harn-aarch64-unknown-linux-gnu.tar.gz",
15004
15022
  cmd: "./harn",
15005
15023
  args: [
15006
15024
  "serve",
@@ -15008,7 +15026,7 @@ Requirements:
15008
15026
  ]
15009
15027
  },
15010
15028
  "linux-x86_64": {
15011
- archive: "https://github.com/burin-labs/harn/releases/download/v0.10.118/harn-x86_64-unknown-linux-gnu.tar.gz",
15029
+ archive: "https://github.com/burin-labs/harn/releases/download/v0.10.124/harn-x86_64-unknown-linux-gnu.tar.gz",
15012
15030
  cmd: "./harn",
15013
15031
  args: [
15014
15032
  "serve",
@@ -15016,7 +15034,7 @@ Requirements:
15016
15034
  ]
15017
15035
  },
15018
15036
  "windows-x86_64": {
15019
- archive: "https://github.com/burin-labs/harn/releases/download/v0.10.118/harn-x86_64-pc-windows-msvc.zip",
15037
+ archive: "https://github.com/burin-labs/harn/releases/download/v0.10.124/harn-x86_64-pc-windows-msvc.zip",
15020
15038
  cmd: "harn.exe",
15021
15039
  args: [
15022
15040
  "serve",
@@ -15047,47 +15065,47 @@ Requirements:
15047
15065
  {
15048
15066
  id: "kilo",
15049
15067
  name: "Kilo",
15050
- version: "7.5.5",
15068
+ version: "7.5.6",
15051
15069
  description: "The open source coding agent",
15052
15070
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/kilo.svg",
15053
15071
  distribution: {
15054
15072
  npx: {
15055
- package: "@kilocode/cli@7.5.5",
15073
+ package: "@kilocode/cli@7.5.6",
15056
15074
  args: [
15057
15075
  "acp"
15058
15076
  ]
15059
15077
  },
15060
15078
  binary: {
15061
15079
  "darwin-aarch64": {
15062
- archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.5.5/kilo-darwin-arm64.zip",
15080
+ archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.5.6/kilo-darwin-arm64.zip",
15063
15081
  cmd: "./kilo",
15064
15082
  args: [
15065
15083
  "acp"
15066
15084
  ]
15067
15085
  },
15068
15086
  "darwin-x86_64": {
15069
- archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.5.5/kilo-darwin-x64.zip",
15087
+ archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.5.6/kilo-darwin-x64.zip",
15070
15088
  cmd: "./kilo",
15071
15089
  args: [
15072
15090
  "acp"
15073
15091
  ]
15074
15092
  },
15075
15093
  "linux-aarch64": {
15076
- archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.5.5/kilo-linux-arm64.tar.gz",
15094
+ archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.5.6/kilo-linux-arm64.tar.gz",
15077
15095
  cmd: "./kilo",
15078
15096
  args: [
15079
15097
  "acp"
15080
15098
  ]
15081
15099
  },
15082
15100
  "linux-x86_64": {
15083
- archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.5.5/kilo-linux-x64.tar.gz",
15101
+ archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.5.6/kilo-linux-x64.tar.gz",
15084
15102
  cmd: "./kilo",
15085
15103
  args: [
15086
15104
  "acp"
15087
15105
  ]
15088
15106
  },
15089
15107
  "windows-x86_64": {
15090
- archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.5.5/kilo-windows-x64.zip",
15108
+ archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.5.6/kilo-windows-x64.zip",
15091
15109
  cmd: "./kilo.exe",
15092
15110
  args: [
15093
15111
  "acp"
@@ -15184,7 +15202,7 @@ Requirements:
15184
15202
  {
15185
15203
  id: "opencode",
15186
15204
  name: "OpenCode",
15187
- version: "1.18.23",
15205
+ version: "1.18.25",
15188
15206
  description: "The open source coding agent",
15189
15207
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/opencode.svg",
15190
15208
  distribution: {
@@ -15282,12 +15300,12 @@ Requirements:
15282
15300
  {
15283
15301
  id: "qwen-code",
15284
15302
  name: "Qwen Code",
15285
- version: "0.22.2",
15303
+ version: "0.22.3",
15286
15304
  description: "Alibaba's Qwen coding assistant",
15287
15305
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/qwen-code.svg",
15288
15306
  distribution: {
15289
15307
  npx: {
15290
- package: "@qwen-code/qwen-code@0.22.2",
15308
+ package: "@qwen-code/qwen-code@0.22.3",
15291
15309
  args: [
15292
15310
  "--acp",
15293
15311
  "--experimental-skills"
@@ -20668,13 +20686,16 @@ ${tailedOutput}` : null;
20668
20686
  };
20669
20687
  const MACHINE_PROTOCOL_CAPABILITIES = {
20670
20688
  localProjectRemoval: "localProjectRemoval",
20671
- providerSetup: "providerSetup"
20689
+ providerSetup: "providerSetup",
20690
+ acpProtocolAuthentication: "acpProtocolAuthentication"
20672
20691
  };
20673
20692
  const LOCAL_PROJECT_REMOVAL_PROTOCOL_VERSION = 1;
20674
20693
  const PROVIDER_SETUP_PROTOCOL_VERSION = 1;
20694
+ const ACP_PROTOCOL_AUTHENTICATION_VERSION = 1;
20675
20695
  const CURRENT_MACHINE_PROTOCOL_CAPABILITIES = {
20676
20696
  [MACHINE_PROTOCOL_CAPABILITIES.localProjectRemoval]: LOCAL_PROJECT_REMOVAL_PROTOCOL_VERSION,
20677
- [MACHINE_PROTOCOL_CAPABILITIES.providerSetup]: PROVIDER_SETUP_PROTOCOL_VERSION
20697
+ [MACHINE_PROTOCOL_CAPABILITIES.providerSetup]: PROVIDER_SETUP_PROTOCOL_VERSION,
20698
+ [MACHINE_PROTOCOL_CAPABILITIES.acpProtocolAuthentication]: ACP_PROTOCOL_AUTHENTICATION_VERSION
20678
20699
  };
20679
20700
  const isLoroRepoDocDeleted = (value) => {
20680
20701
  if (!value || typeof value !== "object") {
@@ -23333,6 +23354,10 @@ ${context2.authorReply.trim()}
23333
23354
  cliType,
23334
23355
  limitId
23335
23356
  ],
23357
+ builtinAgentOptOut: (agentType) => [
23358
+ "builtinAgentOptOut",
23359
+ agentType
23360
+ ],
23336
23361
  sessionLaunchConfig: (sessionId) => [
23337
23362
  "sessionLaunchConfig",
23338
23363
  sessionId
@@ -23425,6 +23450,13 @@ ${context2.authorReply.trim()}
23425
23450
  limitId: key2[2]
23426
23451
  };
23427
23452
  }
23453
+ if (key2.length === 2 && key2[0] === "builtinAgentOptOut" && typeof key2[1] === "string" && isManagedBuiltinAgentType(key2[1])) {
23454
+ return {
23455
+ kind: "builtinAgentOptOut",
23456
+ key: machineFlockKeys.builtinAgentOptOut(key2[1]),
23457
+ agentType: key2[1]
23458
+ };
23459
+ }
23428
23460
  if (key2.length === 2 && key2[0] === "sessionLaunchConfig" && isNonEmptyString$2(key2[1])) {
23429
23461
  const sessionId = key2[1];
23430
23462
  return {
@@ -23473,6 +23505,9 @@ ${context2.authorReply.trim()}
23473
23505
  rateLimit: [
23474
23506
  "rateLimit"
23475
23507
  ],
23508
+ builtinAgentOptOut: [
23509
+ "builtinAgentOptOut"
23510
+ ],
23476
23511
  sessionLaunchConfig: [
23477
23512
  "sessionLaunchConfig"
23478
23513
  ]
@@ -23517,6 +23552,7 @@ ${context2.authorReply.trim()}
23517
23552
  const isMachineFlockProviderSetupRow = (row) => row.key[0] === "providerSetup";
23518
23553
  const isMachineFlockProviderSetupCancellationRow = (row) => row.key[0] === "providerSetupCancellation";
23519
23554
  const isMachineFlockRateLimitRow = (row) => row.key[0] === "rateLimit";
23555
+ const isMachineFlockBuiltinAgentOptOutRow = (row) => row.key[0] === "builtinAgentOptOut";
23520
23556
  const isMachineFlockSessionLaunchConfigRow = (row) => row.key[0] === "sessionLaunchConfig";
23521
23557
  const getMachineFlockRateLimitEntryKey = (cliType, limitId) => `${cliType}::${limitId.trim() || cliType}`;
23522
23558
  function getMachineFlockLocalProjects(rows) {
@@ -23586,8 +23622,11 @@ ${context2.authorReply.trim()}
23586
23622
  const rows = readMachineFlockRowsFromFlock(flock, {
23587
23623
  prefixes: [
23588
23624
  machineFlockKeys.providerSetupCancellation(cancellation.id),
23589
- machineFlockKeys.providerSetup(cancellation.id),
23590
- machineFlockKeys.agentConfig(cancellation.id)
23625
+ machineFlockKeys.providerSetup(cancellation.id)
23626
+ ],
23627
+ families: [
23628
+ "agentConfig",
23629
+ "builtinAgentOptOut"
23591
23630
  ]
23592
23631
  });
23593
23632
  const existingCancellation = getMachineFlockProviderSetupCancellations(rows)[cancellation.id];
@@ -23603,6 +23642,10 @@ ${context2.authorReply.trim()}
23603
23642
  flock.delete(machineFlockKeys.providerSetup(cancellation.id), nowMs2);
23604
23643
  }
23605
23644
  if (config2) {
23645
+ const optOut = planBuiltinAgentOptOutForDeletedConfig(rows, config2, nowMs2);
23646
+ if (optOut) {
23647
+ flock.set(optOut.key, optOut.value, nowMs2);
23648
+ }
23606
23649
  flock.delete(machineFlockKeys.agentConfig(cancellation.id), nowMs2);
23607
23650
  }
23608
23651
  flock.commit();
@@ -23618,6 +23661,101 @@ ${context2.authorReply.trim()}
23618
23661
  }
23619
23662
  return rateLimits;
23620
23663
  }
23664
+ function getMachineFlockBuiltinAgentOptOuts(rows) {
23665
+ const optedOut = /* @__PURE__ */ new Set();
23666
+ for (const row of Object.values(rows)) {
23667
+ if (!isMachineFlockBuiltinAgentOptOutRow(row)) {
23668
+ continue;
23669
+ }
23670
+ optedOut.add(row.key[1]);
23671
+ }
23672
+ return optedOut;
23673
+ }
23674
+ function getBuiltinAgentOptOutAgentType(config2) {
23675
+ if (config2.cliType !== "builtin" || !isManagedBuiltinAgentType(config2.agentType)) {
23676
+ return null;
23677
+ }
23678
+ return config2.agentType;
23679
+ }
23680
+ function planBuiltinAgentOptOutForDeletedConfig(rows, config2, nowMs2) {
23681
+ const agentType = getBuiltinAgentOptOutAgentType(config2);
23682
+ if (agentType === null) {
23683
+ return null;
23684
+ }
23685
+ const key2 = machineFlockKeys.builtinAgentOptOut(agentType);
23686
+ if (serializeMachineFlockKey(key2) in rows) {
23687
+ return null;
23688
+ }
23689
+ const remaining = Object.values(getMachineFlockAgentConfigs(rows)).some((other) => other.id !== config2.id && getBuiltinAgentOptOutAgentType(other) === agentType);
23690
+ if (remaining) {
23691
+ return null;
23692
+ }
23693
+ return {
23694
+ key: key2,
23695
+ value: {
23696
+ v: 1,
23697
+ removedAt: nowMs2
23698
+ }
23699
+ };
23700
+ }
23701
+ function findBuiltinAgentOptOutToRetract(rows, config2) {
23702
+ const agentType = getBuiltinAgentOptOutAgentType(config2);
23703
+ if (agentType === null) {
23704
+ return null;
23705
+ }
23706
+ const key2 = machineFlockKeys.builtinAgentOptOut(agentType);
23707
+ return serializeMachineFlockKey(key2) in rows ? key2 : null;
23708
+ }
23709
+ function writeAgentConfigToFlock(flock, config2, nowMs2) {
23710
+ const rows = readMachineFlockRowsFromFlock(flock, {
23711
+ prefixes: [
23712
+ machineFlockKeys.agentConfig(config2.id),
23713
+ ...getBuiltinAgentOptOutAgentType(config2) === null ? [] : [
23714
+ MACHINE_FLOCK_ROW_FAMILY_PREFIXES.builtinAgentOptOut
23715
+ ]
23716
+ ]
23717
+ });
23718
+ const key2 = machineFlockKeys.agentConfig(config2.id);
23719
+ const normalized = parseMachineFlockRow(key2, config2);
23720
+ if (!normalized) {
23721
+ return false;
23722
+ }
23723
+ const rowChanged = !machineFlockRowsEqual(rows[serializeMachineFlockKey(key2)], normalized);
23724
+ const retractKey = findBuiltinAgentOptOutToRetract(rows, config2);
23725
+ if (!rowChanged && !retractKey) {
23726
+ return false;
23727
+ }
23728
+ if (rowChanged) {
23729
+ flock.set(normalized.key, normalized.value, nowMs2);
23730
+ }
23731
+ if (retractKey) {
23732
+ flock.delete(retractKey, nowMs2);
23733
+ }
23734
+ flock.commit();
23735
+ return true;
23736
+ }
23737
+ function deleteAgentConfigFromFlock(flock, config2, nowMs2) {
23738
+ const rows = readMachineFlockRowsFromFlock(flock, {
23739
+ families: [
23740
+ "agentConfig",
23741
+ "builtinAgentOptOut"
23742
+ ]
23743
+ });
23744
+ const key2 = machineFlockKeys.agentConfig(config2.id);
23745
+ const rowExists = serializeMachineFlockKey(key2) in rows;
23746
+ const optOut = planBuiltinAgentOptOutForDeletedConfig(rows, config2, nowMs2);
23747
+ if (!rowExists && !optOut) {
23748
+ return false;
23749
+ }
23750
+ if (optOut) {
23751
+ flock.set(optOut.key, optOut.value, nowMs2);
23752
+ }
23753
+ if (rowExists) {
23754
+ flock.delete(key2, nowMs2);
23755
+ }
23756
+ flock.commit();
23757
+ return true;
23758
+ }
23621
23759
  function getMachineFlockSessionLaunchConfig(rows, sessionId) {
23622
23760
  const row = rows[serializeMachineFlockKey(machineFlockKeys.sessionLaunchConfig(sessionId))];
23623
23761
  if (!row || !isMachineFlockSessionLaunchConfigRow(row)) {
@@ -23767,6 +23905,13 @@ ${context2.authorReply.trim()}
23767
23905
  key: parsedKey.key,
23768
23906
  value
23769
23907
  } : void 0;
23908
+ case "builtinAgentOptOut": {
23909
+ const optOut = normalizeBuiltinAgentOptOut(value);
23910
+ return optOut ? {
23911
+ key: parsedKey.key,
23912
+ value: optOut
23913
+ } : void 0;
23914
+ }
23770
23915
  case "sessionLaunchConfig": {
23771
23916
  const config2 = normalizeSessionLaunchConfig(value);
23772
23917
  return config2 ? {
@@ -24091,6 +24236,15 @@ ${context2.authorReply.trim()}
24091
24236
  cancelledAt: value.cancelledAt
24092
24237
  };
24093
24238
  };
24239
+ const normalizeBuiltinAgentOptOut = (value) => {
24240
+ if (!isRecord$8(value) || value.v !== 1 || typeof value.removedAt !== "number" || !Number.isFinite(value.removedAt)) {
24241
+ return void 0;
24242
+ }
24243
+ return {
24244
+ v: 1,
24245
+ removedAt: value.removedAt
24246
+ };
24247
+ };
24094
24248
  const normalizeAgentConfigListSummary = (value) => {
24095
24249
  if (!isRecord$8(value) || !isNonEmptyString$2(value.id) || !isNonEmptyString$2(value.machineId) || !isNonEmptyString$2(value.name) || !isMissing(value.description) && typeof value.description !== "string" || !isAgentConfigCliType$1(value.cliType) || !isNonEmptyString$2(value.agentType) || !isMissing(value.brandId) && typeof value.brandId !== "string") {
24096
24250
  return void 0;
@@ -26252,7 +26406,7 @@ ${context2.authorReply.trim()}
26252
26406
  if (hasRequiredCommand$1) return command$1;
26253
26407
  hasRequiredCommand$1 = 1;
26254
26408
  const EventEmitter2 = require$$0$4.EventEmitter;
26255
- const childProcess = LE__default;
26409
+ const childProcess = Gx__default;
26256
26410
  const path2 = path__default;
26257
26411
  const fs2 = fs__default$1;
26258
26412
  const process2 = process$2;
@@ -31194,7 +31348,7 @@ ${originalIndentation}`;
31194
31348
  function requireStream$3() {
31195
31349
  if (hasRequiredStream$3) return stream$3;
31196
31350
  hasRequiredStream$3 = 1;
31197
- stream$3 = Zr;
31351
+ stream$3 = So;
31198
31352
  return stream$3;
31199
31353
  }
31200
31354
  var destroy_1;
@@ -34785,7 +34939,7 @@ ${originalIndentation}`;
34785
34939
  if (hasRequiredReadable$1) return readable$1.exports;
34786
34940
  hasRequiredReadable$1 = 1;
34787
34941
  (function(module2, exports$1) {
34788
- var Stream = Zr;
34942
+ var Stream = So;
34789
34943
  if (process.env.READABLE_STREAM === "disable" && Stream) {
34790
34944
  module2.exports = Stream.Readable;
34791
34945
  Object.assign(module2.exports, Stream);
@@ -37691,7 +37845,7 @@ ${originalIndentation}`;
37691
37845
  const fs2 = fs__default;
37692
37846
  const path2 = path__default$1;
37693
37847
  const asyncSeries = requireSeries();
37694
- const zlib = $s__default;
37848
+ const zlib = Ei__default;
37695
37849
  const { MESSAGE } = requireTripleBeam();
37696
37850
  const { Stream, PassThrough: PassThrough2 } = requireReadable$1();
37697
37851
  const TransportStream = requireWinstonTransport();
@@ -44628,10 +44782,10 @@ ${originalIndentation}`;
44628
44782
  const os2 = os__default$1;
44629
44783
  const path2 = path__default$1;
44630
44784
  const util2 = require$$0$5;
44631
- const zlib = $s__default;
44785
+ const zlib = Ei__default;
44632
44786
  const hash2 = requireObjectHash();
44633
44787
  const MESSAGE = requireTripleBeam().MESSAGE;
44634
- const PassThrough2 = Zr.PassThrough;
44788
+ const PassThrough2 = So.PassThrough;
44635
44789
  const Transport = requireWinstonTransport();
44636
44790
  const loggerDefaults = {
44637
44791
  json: false,
@@ -45083,7 +45237,7 @@ ${value.slice(value.length - safeTailChars)}`;
45083
45237
  return files;
45084
45238
  }
45085
45239
  async function readDailyLogFile(file2) {
45086
- const raw2 = await jt__default.readFile(file2.path);
45240
+ const raw2 = await Yt__default.readFile(file2.path);
45087
45241
  if (!file2.compressed) return raw2.toString("utf8");
45088
45242
  return (await gunzip(raw2)).toString("utf8");
45089
45243
  }
@@ -64998,7 +65152,7 @@ ${peerId}`;
64998
65152
  function requirePermessageDeflate$1() {
64999
65153
  if (hasRequiredPermessageDeflate$1) return permessageDeflate$1;
65000
65154
  hasRequiredPermessageDeflate$1 = 1;
65001
- const zlib = $s__default;
65155
+ const zlib = Ei__default;
65002
65156
  const bufferUtil2 = requireBufferUtil();
65003
65157
  const Limiter = requireLimiter();
65004
65158
  const { kStatusCode } = requireConstants$5();
@@ -65453,7 +65607,7 @@ ${peerId}`;
65453
65607
  function requireReceiver$1() {
65454
65608
  if (hasRequiredReceiver$1) return receiver$1;
65455
65609
  hasRequiredReceiver$1 = 1;
65456
- const { Writable } = Zr;
65610
+ const { Writable } = So;
65457
65611
  const PerMessageDeflate = requirePermessageDeflate$1();
65458
65612
  const { BINARY_TYPES, EMPTY_BUFFER, kStatusCode, kWebSocket } = requireConstants$5();
65459
65613
  const { concat: concat2, toArrayBuffer: toArrayBuffer2, unmask } = requireBufferUtil();
@@ -65820,7 +65974,7 @@ ${peerId}`;
65820
65974
  function requireSender$1() {
65821
65975
  if (hasRequiredSender$1) return sender$1;
65822
65976
  hasRequiredSender$1 = 1;
65823
- const { Duplex } = Zr;
65977
+ const { Duplex } = So;
65824
65978
  const { randomFillSync: randomFillSync2 } = crypto__default;
65825
65979
  const PerMessageDeflate = requirePermessageDeflate$1();
65826
65980
  const { EMPTY_BUFFER, kWebSocket, NOOP } = requireConstants$5();
@@ -66557,7 +66711,7 @@ ${peerId}`;
66557
66711
  const net2 = require$$0$9;
66558
66712
  const tls = require$$4$2;
66559
66713
  const { randomBytes: randomBytes2, createHash: createHash2 } = crypto__default;
66560
- const { Duplex, Readable: Readable2 } = Zr;
66714
+ const { Duplex, Readable: Readable2 } = So;
66561
66715
  const { URL: URL2 } = require$$7$2;
66562
66716
  const PerMessageDeflate = requirePermessageDeflate$1();
66563
66717
  const Receiver = requireReceiver$1();
@@ -67295,7 +67449,7 @@ ${peerId}`;
67295
67449
  if (hasRequiredStream$1) return stream$1;
67296
67450
  hasRequiredStream$1 = 1;
67297
67451
  requireWebsocket$1();
67298
- const { Duplex } = Zr;
67452
+ const { Duplex } = So;
67299
67453
  function emitClose(stream2) {
67300
67454
  stream2.emit("close");
67301
67455
  }
@@ -67446,7 +67600,7 @@ ${peerId}`;
67446
67600
  hasRequiredWebsocketServer = 1;
67447
67601
  const EventEmitter2 = require$$0$7;
67448
67602
  const http$12 = http;
67449
- const { Duplex } = Zr;
67603
+ const { Duplex } = So;
67450
67604
  const { createHash: createHash2 } = crypto__default;
67451
67605
  const extension2 = requireExtension();
67452
67606
  const PerMessageDeflate = requirePermessageDeflate$1();
@@ -83524,6 +83678,14 @@ ${val.stack}`;
83524
83678
  baseDir
83525
83679
  };
83526
83680
  };
83681
+ async function readMachineBuiltinAgentOptOuts(repo, workspaceId, machineId) {
83682
+ const handle = await repo.openFlockDoc(getMachineFlockDocId(workspaceId, machineId));
83683
+ return getMachineFlockBuiltinAgentOptOuts(readMachineFlockRowsFromFlock(handle.flock, {
83684
+ families: [
83685
+ "builtinAgentOptOut"
83686
+ ]
83687
+ }));
83688
+ }
83527
83689
  async function readMachineAgentConfigs(repo, workspaceId, machineId) {
83528
83690
  const handle = await repo.openFlockDoc(getMachineFlockDocId(workspaceId, machineId));
83529
83691
  return getMachineFlockAgentConfigs(readMachineFlockRowsFromFlock(handle.flock, {
@@ -83583,10 +83745,7 @@ ${val.stack}`;
83583
83745
  }
83584
83746
  async function upsertMachineAgentConfig(repo, workspaceId, config2, options = {}) {
83585
83747
  const handle = await repo.openFlockDoc(getMachineFlockDocId(workspaceId, config2.machineId));
83586
- const changed = writeMachineFlockRowToFlock(handle.flock, {
83587
- key: machineFlockKeys.agentConfig(config2.id),
83588
- value: config2
83589
- });
83748
+ const changed = writeAgentConfigToFlock(handle.flock, config2);
83590
83749
  if (!changed) {
83591
83750
  await deleteLoroRepoMetaAgentConfigIfPresent(repo, config2.id);
83592
83751
  return;
@@ -83603,7 +83762,7 @@ ${val.stack}`;
83603
83762
  }
83604
83763
  async function deleteMachineAgentConfig(repo, workspaceId, config2, options = {}) {
83605
83764
  const handle = await repo.openFlockDoc(getMachineFlockDocId(workspaceId, config2.machineId));
83606
- const changed = deleteMachineFlockRowFromFlock(handle.flock, machineFlockKeys.agentConfig(config2.id));
83765
+ const changed = deleteAgentConfigFromFlock(handle.flock, config2, getServerNow());
83607
83766
  if (!changed) {
83608
83767
  await deleteLoroRepoMetaAgentConfigIfPresent(repo, config2.id);
83609
83768
  return;
@@ -101771,7 +101930,7 @@ ${value}`;
101771
101930
  return "internal";
101772
101931
  }
101773
101932
  }
101774
- async function withDeadline(operation, options) {
101933
+ async function withDeadline$1(operation, options) {
101775
101934
  const { timeoutMs, signal } = options;
101776
101935
  if (timeoutMs === void 0 && !signal) return operation;
101777
101936
  if (signal?.aborted) options.onAbort();
@@ -102103,7 +102262,7 @@ ${value}`;
102103
102262
  });
102104
102263
  }
102105
102264
  awaitWithDeadline(operation, options, ctx) {
102106
- return withDeadline(operation, {
102265
+ return withDeadline$1(operation, {
102107
102266
  timeoutMs: options?.timeout,
102108
102267
  signal: options?.signal,
102109
102268
  onTimeout: () => {
@@ -104290,6 +104449,9 @@ ${value}`;
104290
104449
  }
104291
104450
  return false;
104292
104451
  }
104452
+ async getBuiltinAgentOptOuts(machineId) {
104453
+ return await readMachineBuiltinAgentOptOuts(this.repo, this.workspaceId, machineId);
104454
+ }
104293
104455
  async getAgentConfigById(agentConfigId, machineId) {
104294
104456
  if (machineId) {
104295
104457
  return (await readMergedAgentConfigById(this.repo, this.workspaceId, machineId, agentConfigId)).config;
@@ -104472,6 +104634,13 @@ ${value}`;
104472
104634
  }
104473
104635
  }
104474
104636
  }
104637
+ const configOptionValuesEqual = (left2, right2) => {
104638
+ if (left2 === right2) return true;
104639
+ if (!left2 || !right2) return false;
104640
+ const leftKeys = Object.keys(left2);
104641
+ return leftKeys.length === Object.keys(right2).length && leftKeys.every((key2) => left2[key2] === right2[key2]);
104642
+ };
104643
+ const acpRuntimeConfigEqual = (left2, right2) => left2.acpSessionId === right2.acpSessionId && left2.basedOnUserTurnId === right2.basedOnUserTurnId && left2.modeId === right2.modeId && left2.modelId === right2.modelId && configOptionValuesEqual(left2.configOptionValues, right2.configOptionValues);
104475
104644
  const EDITING_LEASE_MS = 5 * 60 * 1e3;
104476
104645
  class SessionDocument {
104477
104646
  constructor(repo, sessionId, unloadDocRoom, logger2 = getLogger("loro")) {
@@ -104767,7 +104936,8 @@ ${value}`;
104767
104936
  mq: state2.mq,
104768
104937
  forkOperation: state2.forkOperation,
104769
104938
  preview: state2.preview,
104770
- externalHistoryCursor: state2.externalHistoryCursor
104939
+ externalHistoryCursor: state2.externalHistoryCursor,
104940
+ acpRuntimeConfig: state2.acpRuntimeConfig
104771
104941
  };
104772
104942
  }
104773
104943
  async waitUntilSynced(options = {}) {
@@ -104813,6 +104983,60 @@ ${value}`;
104813
104983
  return prev;
104814
104984
  });
104815
104985
  }
104986
+ applyAcpRuntimeConfigPatch(basedOnUserTurnId, patch2) {
104987
+ if (!this.mirror) {
104988
+ throw new Error("SessionDocument not initialized");
104989
+ }
104990
+ const durablePatch = patch2.configOptionValues === void 0 ? patch2 : {
104991
+ ...patch2,
104992
+ configOptionValues: Object.fromEntries(Object.entries(patch2.configOptionValues).filter(([configId]) => !isSensitiveAcpConfigOptionId(configId)))
104993
+ };
104994
+ const state2 = this.mirror.getState();
104995
+ const incomingTurnIndex = state2.history.findIndex((entry) => entry.role === "user" && entry.id === basedOnUserTurnId);
104996
+ let latestUserTurnIndex = -1;
104997
+ for (let index = state2.history.length - 1; index >= 0; index -= 1) {
104998
+ if (state2.history[index]?.role === "user") {
104999
+ latestUserTurnIndex = index;
105000
+ break;
105001
+ }
105002
+ }
105003
+ if (incomingTurnIndex < 0 || incomingTurnIndex !== latestUserTurnIndex) {
105004
+ return false;
105005
+ }
105006
+ const current2 = state2.acpRuntimeConfig;
105007
+ const currentTurnIndex = current2 ? state2.history.findIndex((entry) => entry.role === "user" && entry.id === current2.basedOnUserTurnId) : -1;
105008
+ if (currentTurnIndex > incomingTurnIndex) {
105009
+ return false;
105010
+ }
105011
+ const continuesCurrentSnapshot = current2?.acpSessionId === durablePatch.acpSessionId && current2.basedOnUserTurnId === basedOnUserTurnId;
105012
+ const nextWithoutRevision = {
105013
+ ...continuesCurrentSnapshot ? {
105014
+ ...current2.modeId !== void 0 ? {
105015
+ modeId: current2.modeId
105016
+ } : {},
105017
+ ...current2.modelId !== void 0 ? {
105018
+ modelId: current2.modelId
105019
+ } : {},
105020
+ ...current2.configOptionValues !== void 0 ? {
105021
+ configOptionValues: current2.configOptionValues
105022
+ } : {}
105023
+ } : {},
105024
+ ...durablePatch,
105025
+ basedOnUserTurnId
105026
+ };
105027
+ if (current2 && acpRuntimeConfigEqual(current2, nextWithoutRevision)) {
105028
+ return false;
105029
+ }
105030
+ const next2 = {
105031
+ ...nextWithoutRevision,
105032
+ revision: (current2?.revision ?? 0) + 1
105033
+ };
105034
+ this.mirror.setState((prev) => {
105035
+ prev.acpRuntimeConfig = next2;
105036
+ return prev;
105037
+ });
105038
+ return true;
105039
+ }
104816
105040
  async markHistoryAsSeen(turnId) {
104817
105041
  if (!this.mirror) {
104818
105042
  throw new Error("SessionDocument not initialized");
@@ -105156,6 +105380,18 @@ ${value}`;
105156
105380
  throw error2;
105157
105381
  }
105158
105382
  }
105383
+ async appendUserTurn(entry) {
105384
+ if (entry.role !== "user") {
105385
+ throw new Error(`appendUserTurn requires a user entry, received role "${entry.role}" for ${entry.id}`);
105386
+ }
105387
+ await this.updateHistory((history) => [
105388
+ ...history,
105389
+ entry
105390
+ ]);
105391
+ await this.repo.upsertDocMeta(this.roomId, {
105392
+ latestUserMsgId: entry.id
105393
+ });
105394
+ }
105159
105395
  summarizeHistoryTailForDiagnostics(history) {
105160
105396
  const last2 = history.length > 0 ? history[history.length - 1] : void 0;
105161
105397
  const lastItems = last2 && Array.isArray(last2.items) ? last2.items : [];
@@ -105823,6 +106059,7 @@ ${value}`;
105823
106059
  ]),
105824
106060
  authenticationRequestId: string$1().trim().min(1).optional(),
105825
106061
  authorizationCodeEnvelope: RpcSecretEnvelopeSchema.optional(),
106062
+ methodId: string$1().trim().min(1).max(256).optional(),
105826
106063
  configId: AgentConfigIdSchema.optional(),
105827
106064
  cliType: AgentConfigCliTypeSchema,
105828
106065
  agentType: string$1().trim().min(1),
@@ -107197,6 +107434,9 @@ ${value}`;
107197
107434
  action: options.action,
107198
107435
  authenticationRequestId,
107199
107436
  authorizationCodeEnvelope,
107437
+ ...options.methodId ? {
107438
+ methodId: options.methodId
107439
+ } : {},
107200
107440
  configId: options.configId,
107201
107441
  cliType: options.cliType,
107202
107442
  agentType: options.agentType,
@@ -108439,6 +108679,7 @@ ${value}`;
108439
108679
  action: request2.params.action,
108440
108680
  authenticationRequestId: request2.params.authenticationRequestId,
108441
108681
  authorizationCode,
108682
+ methodId: request2.params.methodId,
108442
108683
  configId: request2.params.configId,
108443
108684
  cliType: request2.params.cliType,
108444
108685
  agentType: request2.params.agentType,
@@ -109310,6 +109551,9 @@ ${value}`;
109310
109551
  machineFlockKeys.providerSetup(setupId),
109311
109552
  machineFlockKeys.providerSetupCancellation(setupId),
109312
109553
  machineFlockKeys.agentConfig(setupId)
109554
+ ],
109555
+ families: [
109556
+ "builtinAgentOptOut"
109313
109557
  ]
109314
109558
  });
109315
109559
  const cancellation = getMachineFlockProviderSetupCancellations(rows)[setupId];
@@ -109334,6 +109578,10 @@ ${value}`;
109334
109578
  const now2 = getServerNow();
109335
109579
  const flock = handle.flock;
109336
109580
  flock.set(machineFlockKeys.agentConfig(setupId), setup.config, now2);
109581
+ const optOutKey = findBuiltinAgentOptOutToRetract(rows, setup.config);
109582
+ if (optOutKey) {
109583
+ flock.delete(optOutKey, now2);
109584
+ }
109337
109585
  flock.delete(machineFlockKeys.providerSetup(setupId), now2);
109338
109586
  flock.commit();
109339
109587
  await this.repo.flush();
@@ -109615,20 +109863,20 @@ ${value}`;
109615
109863
  };
109616
109864
  const parsed = DaemonUpgradeIntentSchema.parse(value);
109617
109865
  const dir = path.dirname(DAEMON_UPGRADE_INTENT_FILE);
109618
- await jt.mkdir(dir, {
109866
+ await Yt.mkdir(dir, {
109619
109867
  recursive: true
109620
109868
  });
109621
109869
  const tmpPath = path.join(dir, `.${path.basename(DAEMON_UPGRADE_INTENT_FILE)}.${process.pid}.tmp`);
109622
- await jt.writeFile(tmpPath, `${JSON.stringify(parsed, null, 2)}
109870
+ await Yt.writeFile(tmpPath, `${JSON.stringify(parsed, null, 2)}
109623
109871
  `, {
109624
109872
  encoding: "utf8",
109625
109873
  mode: 384
109626
109874
  });
109627
- await jt.rename(tmpPath, DAEMON_UPGRADE_INTENT_FILE);
109875
+ await Yt.rename(tmpPath, DAEMON_UPGRADE_INTENT_FILE);
109628
109876
  };
109629
109877
  const readDaemonUpgradeIntent = async () => {
109630
109878
  try {
109631
- const raw2 = await jt.readFile(DAEMON_UPGRADE_INTENT_FILE, "utf8");
109879
+ const raw2 = await Yt.readFile(DAEMON_UPGRADE_INTENT_FILE, "utf8");
109632
109880
  const parsed = DaemonUpgradeIntentSchema.safeParse(JSON.parse(raw2));
109633
109881
  return parsed.success ? parsed.data : null;
109634
109882
  } catch {
@@ -109637,7 +109885,7 @@ ${value}`;
109637
109885
  };
109638
109886
  const clearDaemonUpgradeIntent = async () => {
109639
109887
  try {
109640
- await jt.unlink(DAEMON_UPGRADE_INTENT_FILE);
109888
+ await Yt.unlink(DAEMON_UPGRADE_INTENT_FILE);
109641
109889
  } catch {
109642
109890
  }
109643
109891
  };
@@ -111988,6 +112236,80 @@ ${incoming}`).output;
111988
112236
  }
111989
112237
  return void 0;
111990
112238
  };
112239
+ const FILTERED_ACP_CONFIG_OPTION_IDS = /* @__PURE__ */ new Set([
112240
+ "agent"
112241
+ ]);
112242
+ function filterAcpConfigOptions(options) {
112243
+ return options.filter((opt) => !FILTERED_ACP_CONFIG_OPTION_IDS.has(opt.id));
112244
+ }
112245
+ const readConfigOption = (value) => {
112246
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
112247
+ return null;
112248
+ }
112249
+ const option2 = value;
112250
+ if (typeof option2.id !== "string" || isSensitiveAcpConfigOptionId(option2.id)) {
112251
+ return null;
112252
+ }
112253
+ if ((option2.type !== "select" || typeof option2.currentValue !== "string") && (option2.type !== "boolean" || typeof option2.currentValue !== "boolean")) {
112254
+ return null;
112255
+ }
112256
+ return {
112257
+ id: option2.id,
112258
+ ...typeof option2.category === "string" ? {
112259
+ category: option2.category
112260
+ } : {},
112261
+ currentValue: option2.currentValue
112262
+ };
112263
+ };
112264
+ const getAcpRuntimeConfigPatchFromOptions = (acpSessionId, configOptions) => {
112265
+ const options = filterAcpConfigOptions(configOptions.map(readConfigOption).filter((option2) => option2 !== null));
112266
+ const configOptionValues = Object.fromEntries(options.map((option2) => [
112267
+ option2.id,
112268
+ option2.currentValue
112269
+ ]));
112270
+ const mode2 = options.find((option2) => option2.category === "mode");
112271
+ const model = options.find((option2) => option2.category === "model");
112272
+ return {
112273
+ acpSessionId,
112274
+ configOptionValues,
112275
+ ...typeof mode2?.currentValue === "string" ? {
112276
+ modeId: mode2.currentValue
112277
+ } : {},
112278
+ ...typeof model?.currentValue === "string" ? {
112279
+ modelId: model.currentValue
112280
+ } : {}
112281
+ };
112282
+ };
112283
+ const getAcpRuntimeConfigPatch = (notification) => {
112284
+ const update2 = notification.update;
112285
+ if (update2.sessionUpdate === "current_mode_update") {
112286
+ return {
112287
+ acpSessionId: notification.sessionId,
112288
+ modeId: update2.currentModeId
112289
+ };
112290
+ }
112291
+ if (update2.sessionUpdate !== "config_option_update") {
112292
+ return null;
112293
+ }
112294
+ return getAcpRuntimeConfigPatchFromOptions(notification.sessionId, update2.configOptions);
112295
+ };
112296
+ const mergeAcpRuntimeConfigUpdates = (notifications) => {
112297
+ let merged = null;
112298
+ for (const notification of notifications) {
112299
+ const patch2 = getAcpRuntimeConfigPatch(notification);
112300
+ if (!patch2) continue;
112301
+ if (merged && merged.acpSessionId === patch2.acpSessionId) {
112302
+ const previous = merged;
112303
+ merged = {
112304
+ ...previous,
112305
+ ...patch2
112306
+ };
112307
+ } else {
112308
+ merged = patch2;
112309
+ }
112310
+ }
112311
+ return merged;
112312
+ };
111991
112313
  var crossSpawn = {
111992
112314
  exports: {}
111993
112315
  };
@@ -113544,12 +113866,6 @@ ${incoming}`).output;
113544
113866
  tier: "A"
113545
113867
  });
113546
113868
  }
113547
- const FILTERED_ACP_CONFIG_OPTION_IDS = /* @__PURE__ */ new Set([
113548
- "agent"
113549
- ]);
113550
- function filterAcpConfigOptions(options) {
113551
- return options.filter((opt) => !FILTERED_ACP_CONFIG_OPTION_IDS.has(opt.id));
113552
- }
113553
113869
  function isSelectGroup$1(item) {
113554
113870
  return typeof item === "object" && item !== null && "group" in item;
113555
113871
  }
@@ -114849,6 +115165,9 @@ ${incoming}`).output;
114849
115165
  return;
114850
115166
  }
114851
115167
  const notification = parseSessionNotification(params);
115168
+ if (notification.update.sessionUpdate === "config_option_update") {
115169
+ this.applyConfigOptionsState(notification.update.configOptions, true);
115170
+ }
114852
115171
  this.handleGoalSessionInfoUpdate(notification);
114853
115172
  this.handleCodexWarningSessionInfoUpdate(notification);
114854
115173
  this.handleAgentSessionTitleUpdate(notification);
@@ -115420,9 +115739,9 @@ ${incoming}`).output;
115420
115739
  return this.acpSessionId !== null && acpSessionId === this.acpSessionId;
115421
115740
  }
115422
115741
  applySessionResponseState(sessionResponse) {
115423
- this.configOptions = filterAcpConfigOptions(sessionResponse.configOptions ?? []);
115424
- this.legacySessionModelState = readLegacySessionModelState(sessionResponse) ?? null;
115425
115742
  this.currentModel = void 0;
115743
+ this.applyConfigOptionsState(sessionResponse.configOptions ?? [], sessionResponse.configOptions !== void 0);
115744
+ this.legacySessionModelState = readLegacySessionModelState(sessionResponse) ?? null;
115426
115745
  const initialModelOption = this.findConfigOptionByCategory("model");
115427
115746
  if (initialModelOption?.type === "select" && typeof initialModelOption.currentValue === "string") {
115428
115747
  this.currentModel = this.resolveModelInfo(initialModelOption.currentValue);
@@ -115430,6 +115749,46 @@ ${incoming}`).output;
115430
115749
  this.currentModel = this.resolveModelInfo(this.legacySessionModelState.currentModelId);
115431
115750
  }
115432
115751
  }
115752
+ applyConfigOptionsState(configOptions, replaceConfigOptionValues) {
115753
+ this.configOptions = filterAcpConfigOptions(configOptions);
115754
+ if (replaceConfigOptionValues) {
115755
+ for (const configId of Object.keys(this.configOptionValues)) {
115756
+ delete this.configOptionValues[configId];
115757
+ }
115758
+ for (const option2 of this.configOptions) {
115759
+ if (typeof option2.currentValue === "string" || typeof option2.currentValue === "boolean") {
115760
+ this.configOptionValues[option2.id] = option2.currentValue;
115761
+ }
115762
+ }
115763
+ }
115764
+ const modelOption = this.findConfigOptionByCategory("model");
115765
+ if (modelOption?.type === "select" && typeof modelOption.currentValue === "string") {
115766
+ this.currentModel = this.resolveModelInfo(modelOption.currentValue);
115767
+ } else if (this.currentModel) {
115768
+ this.currentModel = this.resolveModelInfo(this.currentModel.modelId);
115769
+ } else {
115770
+ this.currentModel = void 0;
115771
+ }
115772
+ }
115773
+ retainLegacyConfigOptionValue(configId, value) {
115774
+ this.configOptionValues[configId] = value;
115775
+ this.configOptions = this.configOptions.map((option2) => {
115776
+ if (option2.id !== configId) return option2;
115777
+ if (option2.type === "select" && typeof value === "string") {
115778
+ return {
115779
+ ...option2,
115780
+ currentValue: value
115781
+ };
115782
+ }
115783
+ if (option2.type === "boolean" && typeof value === "boolean") {
115784
+ return {
115785
+ ...option2,
115786
+ currentValue: value
115787
+ };
115788
+ }
115789
+ return option2;
115790
+ });
115791
+ }
115433
115792
  async startSession(stream2, workdir, resumeSessionId, timeoutOptions = {}, startupAbort, resolveSessionStart, forkSessionId, forkSessionTurnId) {
115434
115793
  const connection2 = new ClientSideConnection(() => this, stream2);
115435
115794
  this.connection = connection2;
@@ -116062,13 +116421,11 @@ ${incoming}`).output;
116062
116421
  }
116063
116422
  return void 0;
116064
116423
  }, this.logger, "setSessionConfigOption", this.options.sessionId);
116065
- if (result?.configOptions) {
116066
- this.configOptions = filterAcpConfigOptions(result.configOptions);
116067
- if (this.currentModel) {
116068
- this.currentModel = this.resolveModelInfo(this.currentModel.modelId);
116069
- }
116424
+ if (result?.configOptions !== void 0) {
116425
+ this.applyConfigOptionsState(result.configOptions, true);
116426
+ } else if (result) {
116427
+ this.retainLegacyConfigOptionValue(configId, value);
116070
116428
  }
116071
- if (result) this.configOptionValues[configId] = value;
116072
116429
  this.logger.debug(`[${this.options.sessionId}] ACP session config option set: ${configId}=${value}`);
116073
116430
  return result?.configOptions;
116074
116431
  }
@@ -117165,7 +117522,7 @@ ${error2.message}` : execaMessage;
117165
117522
  function requireBufferStream() {
117166
117523
  if (hasRequiredBufferStream) return bufferStream;
117167
117524
  hasRequiredBufferStream = 1;
117168
- const { PassThrough: PassThroughStream } = Zr;
117525
+ const { PassThrough: PassThroughStream } = So;
117169
117526
  bufferStream = (options) => {
117170
117527
  options = {
117171
117528
  ...options
@@ -117214,7 +117571,7 @@ ${error2.message}` : execaMessage;
117214
117571
  if (hasRequiredGetStream) return getStream.exports;
117215
117572
  hasRequiredGetStream = 1;
117216
117573
  const { constants: BufferConstants } = require$$0$6;
117217
- const stream2 = Zr;
117574
+ const stream2 = So;
117218
117575
  const { promisify: promisify2 } = require$$0$5;
117219
117576
  const bufferStream2 = requireBufferStream();
117220
117577
  const streamPipelinePromisified = promisify2(stream2.pipeline);
@@ -117274,7 +117631,7 @@ ${error2.message}` : execaMessage;
117274
117631
  function requireMergeStream() {
117275
117632
  if (hasRequiredMergeStream) return mergeStream;
117276
117633
  hasRequiredMergeStream = 1;
117277
- const { PassThrough: PassThrough2 } = Zr;
117634
+ const { PassThrough: PassThrough2 } = So;
117278
117635
  mergeStream = function() {
117279
117636
  var sources = [];
117280
117637
  var output = new PassThrough2({
@@ -119005,7 +119362,7 @@ ${error2.message}` : execaMessage;
119005
119362
  validate: validate2
119006
119363
  });
119007
119364
  };
119008
- const realZlibConstants = $s__default.constants || {
119365
+ const realZlibConstants = Ei__default.constants || {
119009
119366
  ZLIB_VERNUM: 4736
119010
119367
  };
119011
119368
  const constants = Object.freeze(Object.assign(/* @__PURE__ */ Object.create(null), {
@@ -119165,11 +119522,11 @@ ${error2.message}` : execaMessage;
119165
119522
  this.#flushFlag = opts.flush ?? 0;
119166
119523
  this.#finishFlushFlag = opts.finishFlush ?? 0;
119167
119524
  this.#fullFlushFlag = opts.fullFlushFlag ?? 0;
119168
- if (typeof $s[mode2] !== "function") {
119525
+ if (typeof Ei[mode2] !== "function") {
119169
119526
  throw new TypeError("Compression method not supported: " + mode2);
119170
119527
  }
119171
119528
  try {
119172
- this.#handle = new $s[mode2](opts);
119529
+ this.#handle = new Ei[mode2](opts);
119173
119530
  } catch (er) {
119174
119531
  throw new ZlibError(er, this.constructor);
119175
119532
  }
@@ -122184,7 +122541,7 @@ ${error2.message}` : execaMessage;
122184
122541
  return checkCwd(dir, done2);
122185
122542
  }
122186
122543
  if (preserve) {
122187
- return jt__default.mkdir(dir, {
122544
+ return Yt__default.mkdir(dir, {
122188
122545
  mode: mode2,
122189
122546
  recursive: true
122190
122547
  }).then((made) => done2(null, made ?? void 0), done2);
@@ -123434,7 +123791,7 @@ ${error2.message}` : execaMessage;
123434
123791
  hasRequiredFdSlicer = 1;
123435
123792
  var fs2 = fs__default;
123436
123793
  var util2 = require$$0$5;
123437
- var stream2 = Zr;
123794
+ var stream2 = So;
123438
123795
  var Readable2 = stream2.Readable;
123439
123796
  var Writable = stream2.Writable;
123440
123797
  var PassThrough2 = stream2.PassThrough;
@@ -124000,14 +124357,14 @@ ${error2.message}` : execaMessage;
124000
124357
  if (hasRequiredYauzl) return yauzl;
124001
124358
  hasRequiredYauzl = 1;
124002
124359
  var fs2 = fs__default;
124003
- var zlib = $s__default;
124360
+ var zlib = Ei__default;
124004
124361
  var fd_slicer = requireFdSlicer();
124005
124362
  var crc322 = requireBufferCrc32();
124006
124363
  var util2 = require$$0$5;
124007
124364
  var EventEmitter2 = require$$0$7.EventEmitter;
124008
- var Transform2 = Zr.Transform;
124009
- var PassThrough2 = Zr.PassThrough;
124010
- var Writable = Zr.Writable;
124365
+ var Transform2 = So.Transform;
124366
+ var PassThrough2 = So.PassThrough;
124367
+ var Writable = So.Writable;
124011
124368
  yauzl.open = open2;
124012
124369
  yauzl.fromFd = fromFd;
124013
124370
  yauzl.fromBuffer = fromBuffer;
@@ -125438,7 +125795,7 @@ ${error2.message}` : execaMessage;
125438
125795
  }
125439
125796
  const version$7 = "1.6.2";
125440
125797
  const dependencies$1 = {
125441
- "@openai/codex": "^0.148.0"
125798
+ "@openai/codex": "^0.151.0"
125442
125799
  };
125443
125800
  const codexPackageJson = {
125444
125801
  version: version$7,
@@ -125448,99 +125805,99 @@ ${error2.message}` : execaMessage;
125448
125805
  const grokPackageJson = {
125449
125806
  version: version$6
125450
125807
  };
125451
- const version$5 = "2.1.232";
125808
+ const version$5 = "2.1.251";
125452
125809
  const platforms = {
125453
125810
  "darwin-arm64": {
125454
125811
  "binary": "claude",
125455
- "checksum": "7b39c1588df919d001dea3ffd5651adb682f2451b5a0e18d42d4233296b53cc7",
125456
- "size": 306111312
125812
+ "checksum": "625869b01e0050f260b2980fac248fd9cef9e462612bded4ec9d3d49ff8969a5",
125813
+ "size": 197171680
125457
125814
  },
125458
125815
  "darwin-x64": {
125459
125816
  "binary": "claude",
125460
- "checksum": "aa3d606d7bf0ea9739a6d0de11810e72a662e7a4e5061d67ee7f8bc47c8890f9",
125461
- "size": 314779248
125817
+ "checksum": "44221d72a3f35772faa85ad9a36a678084a516f720e64b45e26eb9015315500b",
125818
+ "size": 205778256
125462
125819
  },
125463
125820
  "linux-arm64": {
125464
125821
  "binary": "claude",
125465
- "checksum": "20797ebc644dfc47a69865c46d5cf702c7dbedd48d4268063b8828ebd55b39d0",
125466
- "size": 320133352
125822
+ "checksum": "65445bd4dd042079cc3fa43791b561370a05c8599e8ec47580e25a81050abbdd",
125823
+ "size": 213835016
125467
125824
  },
125468
125825
  "linux-x64": {
125469
125826
  "binary": "claude",
125470
- "checksum": "61d23f8749136907d586d5b11831ea8a5234d4c1dea40a5e55c33b52e204c6d1",
125471
- "size": 323021104
125827
+ "checksum": "fd5f10ff0eb58daec04900466b143ea98aab50abf208a422bc008eaec13f61f7",
125828
+ "size": 214326616
125472
125829
  },
125473
125830
  "linux-arm64-musl": {
125474
125831
  "binary": "claude",
125475
- "checksum": "bf6481aa98b84d3e51460f7cf07fe54cb8d116882b72cee7bff941a2776ac91e",
125476
- "size": 313278016
125832
+ "checksum": "165f6236abf5b0c42892b164c2299c82023421805e0c3eaddf925a3195513f84",
125833
+ "size": 206648896
125477
125834
  },
125478
125835
  "linux-x64-musl": {
125479
125836
  "binary": "claude",
125480
- "checksum": "93c8a9ef90adfa5bb8a34dfd5f32fc4e820532ca1e1ec5e6bb2049a5069a03b4",
125481
- "size": 317165312
125837
+ "checksum": "5056970c13f46dd2bff2c44dd2a7f766553a63392615412d5711278264730e07",
125838
+ "size": 208301944
125482
125839
  },
125483
125840
  "win32-x64": {
125484
125841
  "binary": "claude.exe",
125485
- "checksum": "ec9e32479bc887809003c91384c6c3a26e7691856d1916f72f6f6d21800f3bd6",
125486
- "size": 319026336
125842
+ "checksum": "8d1229a281281b98fd2dee72b3253a704be4fce4d45207200cd32a9bb5a6c909",
125843
+ "size": 217360032
125487
125844
  },
125488
125845
  "win32-arm64": {
125489
125846
  "binary": "claude.exe",
125490
- "checksum": "301bfd5a624d6280d4d4e4ba7523fafdfa439a33e9530478719eeb6efec51d52",
125491
- "size": 306950304
125847
+ "checksum": "89e91fed2dc6f6278fa1e179e6401c0a1c252fe80c57ee47f17f10f7f7b4e99c",
125848
+ "size": 208465056
125492
125849
  }
125493
125850
  };
125494
125851
  const claudeSdkManifestJson = {
125495
125852
  version: version$5,
125496
125853
  platforms
125497
125854
  };
125498
- const version$4 = "0.3.232";
125855
+ const version$4 = "0.3.251";
125499
125856
  const claudeSdkPackageJson = {
125500
125857
  version: version$4
125501
125858
  };
125502
- const sdkVersion = "0.3.232";
125503
- const version$3 = "2.1.232";
125859
+ const sdkVersion = "0.3.251";
125860
+ const version$3 = "2.1.251";
125504
125861
  const artifacts$1 = {
125505
125862
  "darwin-arm64": {
125506
- "fileName": "anthropic-ai-claude-agent-sdk-darwin-arm64-0.3.232.tar.zst",
125507
- "sha256": "09c775adf243d27a5c13e6724b3960409612b0da483c38fa108a1c03be515a5a",
125508
- "size": 70030420
125863
+ "fileName": "anthropic-ai-claude-agent-sdk-darwin-arm64-0.3.251.tar.zst",
125864
+ "sha256": "536a3755844d168b87250af3ee6e3dd103391305514f28abe564f91a5aa856ee",
125865
+ "size": 71945899
125509
125866
  },
125510
125867
  "darwin-x64": {
125511
- "fileName": "anthropic-ai-claude-agent-sdk-darwin-x64-0.3.232.tar.zst",
125512
- "sha256": "68f687528e5d610e14a379ff7ad1e6a60aa7d600b4dc20dc31b4af96fffda570",
125513
- "size": 74349877
125868
+ "fileName": "anthropic-ai-claude-agent-sdk-darwin-x64-0.3.251.tar.zst",
125869
+ "sha256": "68e88be76d4399d1dea054d9dbbf7106c393578fa1fa5714c9a8890b6ff3213c",
125870
+ "size": 75692035
125514
125871
  },
125515
125872
  "linux-arm64": {
125516
- "fileName": "anthropic-ai-claude-agent-sdk-linux-arm64-0.3.232.tar.zst",
125517
- "sha256": "8c7c75910f5d29c3cf3fe15e4c17abfb05db616db2838b3a764f6b243ad78165",
125518
- "size": 79104443
125873
+ "fileName": "anthropic-ai-claude-agent-sdk-linux-arm64-0.3.251.tar.zst",
125874
+ "sha256": "92e61ffb31b8beae919beb6a9458f4a376067bf25d4df7e5c8fe29b84ed1edaa",
125875
+ "size": 81951594
125519
125876
  },
125520
125877
  "linux-x64": {
125521
- "fileName": "anthropic-ai-claude-agent-sdk-linux-x64-0.3.232.tar.zst",
125522
- "sha256": "e0303ad6167b82fad98a80dd6dc3fd23d82562de5181094775c388118951d999",
125523
- "size": 79732583
125878
+ "fileName": "anthropic-ai-claude-agent-sdk-linux-x64-0.3.251.tar.zst",
125879
+ "sha256": "9e51358bb06885a29c0cdcaff6ffbbed47718e3210b8e92ae074802440a46dd3",
125880
+ "size": 81994218
125524
125881
  },
125525
125882
  "linux-arm64-musl": {
125526
- "fileName": "anthropic-ai-claude-agent-sdk-linux-arm64-musl-0.3.232.tar.zst",
125527
- "sha256": "b0dd9da5095baf314160e3a3f6ac1c85a1ef4b4e326c4bde662f92fe8783840b",
125528
- "size": 77411461
125883
+ "fileName": "anthropic-ai-claude-agent-sdk-linux-arm64-musl-0.3.251.tar.zst",
125884
+ "sha256": "bfad7556c20b01776c2205898c7f76a31448e42b7c2e7254476d25aac9c0d84c",
125885
+ "size": 80166022
125529
125886
  },
125530
125887
  "linux-x64-musl": {
125531
- "fileName": "anthropic-ai-claude-agent-sdk-linux-x64-musl-0.3.232.tar.zst",
125532
- "sha256": "989e8148bb5944d038f4ea11595742084ec3b38837e08e5af25229ada27c3730",
125533
- "size": 77995010
125888
+ "fileName": "anthropic-ai-claude-agent-sdk-linux-x64-musl-0.3.251.tar.zst",
125889
+ "sha256": "143efe291c6cd6501681fff2930c58c9eeeef5f924dded6b340e84a9e069e1d1",
125890
+ "size": 80324347
125534
125891
  },
125535
125892
  "win32-arm64": {
125536
- "fileName": "anthropic-ai-claude-agent-sdk-win32-arm64-0.3.232.tar.zst",
125537
- "sha256": "7cc4f6f2a23fa43993da830e00e3e2ca46b90864a2d38e1f3678f70de9e2f440",
125538
- "size": 78979373
125893
+ "fileName": "anthropic-ai-claude-agent-sdk-win32-arm64-0.3.251.tar.zst",
125894
+ "sha256": "0d70dd262d40b39fe354e3b7c0e5a1b3a4895beef2692509a3830511ff184023",
125895
+ "size": 81916953
125539
125896
  },
125540
125897
  "win32-x64": {
125541
- "fileName": "anthropic-ai-claude-agent-sdk-win32-x64-0.3.232.tar.zst",
125542
- "sha256": "ed09d440d4cf7881439850287485d3198384538c79d8d3e5f0740b1e40b10db3",
125543
- "size": 82535283
125898
+ "fileName": "anthropic-ai-claude-agent-sdk-win32-x64-0.3.251.tar.zst",
125899
+ "sha256": "db8bcee96e0f0bc42b01977c1897977c204d5cee07464656ec49fa44d31014aa",
125900
+ "size": 84974808
125544
125901
  }
125545
125902
  };
125546
125903
  const claudeRuntimeManifestJson = {
@@ -125548,49 +125905,49 @@ ${error2.message}` : execaMessage;
125548
125905
  version: version$3,
125549
125906
  artifacts: artifacts$1
125550
125907
  };
125551
- const version$2 = "0.148.0";
125908
+ const version$2 = "0.151.0";
125552
125909
  const artifacts = {
125553
125910
  "darwin-arm64": {
125554
125911
  "fileName": "codex-package-aarch64-apple-darwin.tar.zst",
125555
- "sha256": "dba92ada12f223751f30a9535c81c6a3ac6a2c1b2469d628c92b3e6be38eff66",
125556
- "size": 76351891
125912
+ "sha256": "c7414e579bb36eba0c8f6cb45fe0ce4cd2724deeb0c3ec3a08c1babfb59ec6e6",
125913
+ "size": 84213361
125557
125914
  },
125558
125915
  "darwin-x64": {
125559
125916
  "fileName": "codex-package-x86_64-apple-darwin.tar.zst",
125560
- "sha256": "ea8a14bca1cfc5a80d2a90e532617cc3c089cb69d2a114a61db645de6d051916",
125561
- "size": 83818234
125917
+ "sha256": "41cd66b0ba1279213d2d1e17fef0fc30421e524406cb5954d84d568688c8b118",
125918
+ "size": 92568101
125562
125919
  },
125563
125920
  "linux-arm64": {
125564
125921
  "fileName": "codex-package-aarch64-unknown-linux-musl.tar.zst",
125565
- "sha256": "084e6261fd68bd2a869f319375a022b2294d7d0f4044cbb113b8fa0755b01af9",
125566
- "size": 79728248
125922
+ "sha256": "3ae57da8bc5f8fd065f0352cc14cb10e02be779186bdac989ad0e2622d8cacbb",
125923
+ "size": 89411447
125567
125924
  },
125568
125925
  "linux-x64": {
125569
125926
  "fileName": "codex-package-x86_64-unknown-linux-musl.tar.zst",
125570
- "sha256": "257701de0d625d46e0e1c0c69db1a8a3fc1265c646a190e9fb965d1f66d54cd2",
125571
- "size": 85609844
125927
+ "sha256": "e2dbacd77547f2d3afb3b1864f92926d936c12d8b822bbac98a766d943656494",
125928
+ "size": 95540316
125572
125929
  },
125573
125930
  "win32-arm64": {
125574
125931
  "fileName": "codex-package-aarch64-pc-windows-msvc.tar.zst",
125575
- "sha256": "e043d518a6ad64271616bf4408737672e2e48b5ce472d2f0a69149434ad0d189",
125576
- "size": 87165328
125932
+ "sha256": "bfd73f646fe3c3335049617e35a85e04ecf42609fc591e2b4a246e312fd41cfd",
125933
+ "size": 98552597
125577
125934
  },
125578
125935
  "win32-x64": {
125579
125936
  "fileName": "codex-package-x86_64-pc-windows-msvc.tar.zst",
125580
- "sha256": "a9fc1afe438a326aa25b11c31ec7586c176f3713d7ee2a0bfd17b869283bd6ff",
125581
- "size": 93722309
125937
+ "sha256": "02338bb9b9c9d991fed3d0446cfcb4d54ce9a271e70097e9f4c1e099ba304f3c",
125938
+ "size": 106201360
125582
125939
  }
125583
125940
  };
125584
125941
  const codexRuntimeManifestJson = {
125585
125942
  version: version$2,
125586
125943
  artifacts
125587
125944
  };
125588
- const version$1 = "0.37.0-lody.753c83056944";
125945
+ const version$1 = "0.39.1-lody.f255222661c9";
125589
125946
  const minNodeVersion = "22.19.0";
125590
125947
  const artifact = {
125591
- "fileName": "lody-kimi-code-0.37.0-lody.753c83056944-037255b0bcbb3afe.tar.zst",
125592
- "sha256": "037255b0bcbb3afe2ce0456b8a9fa419b18ada24f8d90049696efe11d311b00b",
125593
- "size": 3253568,
125948
+ "fileName": "lody-kimi-code-0.39.1-lody.f255222661c9-a4bfb622023ceaf2.tar.zst",
125949
+ "sha256": "a4bfb622023ceaf249faecf8da8508ee400af242de2d4590b72d64e95a0bbbb8",
125950
+ "size": 3335953,
125594
125951
  "compression": "zstd",
125595
125952
  "cmd": "package/dist/main.mjs"
125596
125953
  };
@@ -125810,57 +126167,57 @@ ${error2.message}` : execaMessage;
125810
126167
  platforms: {
125811
126168
  "darwin-arm64": {
125812
126169
  fileName: `xai-official-grok-darwin-arm64-${GROK_BUILD_RUNTIME_VERSION}.tar.zst`,
125813
- sha256: "63aa0a0a95e7a555a372f1a501dcf59151376d7e4d900e24e1c591ff6cc8f818",
125814
- size: 46222120,
126170
+ sha256: "82ffbd254fb76ae5e6be651342e902184a024f78bbe1cf6c8f48854d9f9b1594",
126171
+ size: 46850248,
125815
126172
  compression: "zstd",
125816
126173
  cmd: "grok",
125817
- executableSha256: "13c7f4f0b9abb00bf38216302ea4bab31f03e13555e3576620eca1de572a8d21",
125818
- executableSize: 131817232
126174
+ executableSha256: "8669e0fdadceec25b8c159c355f427ffbd82583525d774b6ab1522197ea83b80",
126175
+ executableSize: 133486016
125819
126176
  },
125820
126177
  "darwin-x64": {
125821
126178
  fileName: `xai-official-grok-darwin-x64-${GROK_BUILD_RUNTIME_VERSION}.tar.zst`,
125822
- sha256: "7bf0af43ba1f3dc8e860e7f887b75966ece7bb6102cc7a3b2fb5af275f757c8a",
125823
- size: 50590131,
126179
+ sha256: "4f48fbc4280a033da3e763e4c19585014917677d9e5c4c8405d2f80f9d21ed7a",
126180
+ size: 51374009,
125824
126181
  compression: "zstd",
125825
126182
  cmd: "grok",
125826
- executableSha256: "a82210a961deac9f0cb72ec6c334196abf76a587be4593bc59db2deab85ee6dc",
125827
- executableSize: 147358e3
126183
+ executableSha256: "8eacec87f5ecdb9259c6d812d12ce9e2d405b1526e36ae9d7fc81ec31dbd74d6",
126184
+ executableSize: 149694528
125828
126185
  },
125829
126186
  "linux-arm64": {
125830
126187
  fileName: `xai-official-grok-linux-arm64-${GROK_BUILD_RUNTIME_VERSION}.tar.zst`,
125831
- sha256: "c888d404ad218caa251cbdbbd0da5836c807957be5a83fd8ab21b69de93469d9",
125832
- size: 49704069,
126188
+ sha256: "676d6795d6e558adb9749f002d9dadc950acc2c5effee839cb9e1f47f8480b03",
126189
+ size: 50397485,
125833
126190
  compression: "zstd",
125834
126191
  cmd: "grok",
125835
- executableSha256: "bb7c51116564a2219f6a49850815060f416918ac407f1f2ba82c53c0b0d4383f",
125836
- executableSize: 133745832
126192
+ executableSha256: "b926fc5308374396e260e7efbd6107231a8dae13c084ddaf0fe89b7ebb3edd25",
126193
+ executableSize: 135641288
125837
126194
  },
125838
126195
  "linux-x64": {
125839
126196
  fileName: `xai-official-grok-linux-x64-${GROK_BUILD_RUNTIME_VERSION}.tar.zst`,
125840
- sha256: "7d0bb4309e634e0ecb63403f35fa468120f5ecf2173feb6518371be1633ecd99",
125841
- size: 53264623,
126197
+ sha256: "358061308ca5c06832d62c079644f51ef355d820d94a9ca11513c09fb4160049",
126198
+ size: 54001005,
125842
126199
  compression: "zstd",
125843
126200
  cmd: "grok",
125844
- executableSha256: "28dbc967a5843dae2374b6834dadbab95354e685c7e5c8dc750b92a4e5fc7c3e",
125845
- executableSize: 163676672
126201
+ executableSha256: "edf79521581bb5e6b95abef848491a6a742e860da3e237ebe86a280d30dce4c1",
126202
+ executableSize: 166079904
125846
126203
  },
125847
126204
  "win32-arm64": {
125848
126205
  fileName: `xai-official-grok-win32-arm64-${GROK_BUILD_RUNTIME_VERSION}.tar.zst`,
125849
- sha256: "c821de276cb1fa835567bd6c5589709e6ba29182d6b0c9ad7c160cc3df91145c",
125850
- size: 45241480,
126206
+ sha256: "243aaca666d4375980905c30b5a33e5b0c9a82e9e2c9bc3fd5b6cdf47819e9ad",
126207
+ size: 45479753,
125851
126208
  compression: "zstd",
125852
126209
  cmd: "grok.exe",
125853
- executableSha256: "9d41447b6eee77cfb7359b7f50935ae64b4e7b7e7ef56c40e6d203f5660317e1",
125854
- executableSize: 121471488
126210
+ executableSha256: "7325ad53988f9c5ca2a35e79b83280441e64d132a9046a947fd14ebb22f48db0",
126211
+ executableSize: 121991168
125855
126212
  },
125856
126213
  "win32-x64": {
125857
126214
  fileName: `xai-official-grok-win32-x64-${GROK_BUILD_RUNTIME_VERSION}.tar.zst`,
125858
- sha256: "5d66d3e0c1e54b050c76b77dfc1dadefbf3e909459a31b4361d8307a671c179c",
125859
- size: 48124303,
126215
+ sha256: "e5a50bceb2caba7bef83ef7581b50c4f4db480174a2ed44c4785f77dd9520214",
126216
+ size: 48377036,
125860
126217
  compression: "zstd",
125861
126218
  cmd: "grok.exe",
125862
- executableSha256: "d546dbc995c2ce9ba97c044d6af6b53f8c11c414a6355bf006802d07c572f406",
125863
- executableSize: 139903488
126219
+ executableSha256: "6caf906d6ef968004b5ff33422c84e33d51a1cd7b4ee5acd19ff695aaa92672e",
126220
+ executableSize: 140801024
125864
126221
  }
125865
126222
  }
125866
126223
  }
@@ -128776,12 +129133,17 @@ ${fallbackStderrTail}` : errorMessage2;
128776
129133
  }
128777
129134
  return hasDomain(url.hostname, "kimi.com") && url.pathname.startsWith("/code/authorize_device");
128778
129135
  }
128779
- function findAuthorizationUrl(agentType, output) {
129136
+ const AUTHORIZATION_URL_HINT_PATTERN = /(^|[/?&=_-])(oauth|oauth2|authorize|authorization|device|signin|sign-in|login)([/?&=_-]|$)/iu;
129137
+ function isLikelyAuthorizationUrl(url) {
129138
+ if (url.protocol !== "https:") return false;
129139
+ return AUTHORIZATION_URL_HINT_PATTERN.test(url.pathname) || AUTHORIZATION_URL_HINT_PATTERN.test(url.search);
129140
+ }
129141
+ function findAuthorizationUrl(isAuthorizationUrl, output) {
128780
129142
  for (const match5 of output.matchAll(AUTHORIZATION_URL_PATTERN)) {
128781
129143
  const candidate = match5[0].replace(/[),.;]+$/u, "");
128782
129144
  try {
128783
129145
  const url = new URL(candidate);
128784
- if (isTrustedAuthorizationUrl(agentType, url)) return url;
129146
+ if (isAuthorizationUrl(url)) return url;
128785
129147
  } catch {
128786
129148
  }
128787
129149
  }
@@ -128794,8 +129156,8 @@ ${fallbackStderrTail}` : errorMessage2;
128794
129156
  if (minutes2) return Number.parseInt(minutes2, 10) * 60;
128795
129157
  return void 0;
128796
129158
  }
128797
- function parseAuthorization(agentType, output) {
128798
- const authorizationUrl = findAuthorizationUrl(agentType, output);
129159
+ function parseAuthorization(isAuthorizationUrl, acceptsAuthorizationCode, output) {
129160
+ const authorizationUrl = findAuthorizationUrl(isAuthorizationUrl, output);
128799
129161
  if (!authorizationUrl) return void 0;
128800
129162
  const userCode = authorizationUrl.searchParams.get("user_code") ?? DEVICE_USER_CODE_PATTERN.exec(output)?.[0];
128801
129163
  const expiresInSeconds = parseExpiresInSeconds(output);
@@ -128804,7 +129166,7 @@ ${fallbackStderrTail}` : errorMessage2;
128804
129166
  ...userCode ? {
128805
129167
  userCode
128806
129168
  } : {},
128807
- ...agentType === "claude" ? {
129169
+ ...acceptsAuthorizationCode ? {
128808
129170
  acceptsAuthorizationCode: true
128809
129171
  } : {},
128810
129172
  ...expiresInSeconds !== void 0 ? {
@@ -128812,15 +129174,16 @@ ${fallbackStderrTail}` : errorMessage2;
128812
129174
  } : {}
128813
129175
  };
128814
129176
  }
128815
- class BuiltinAuthenticationOutputParser {
128816
- constructor(agentType) {
128817
- this.agentType = agentType;
129177
+ class AuthorizationOutputParser {
129178
+ constructor(isAuthorizationUrl, acceptsAuthorizationCode) {
129179
+ this.isAuthorizationUrl = isAuthorizationUrl;
129180
+ this.acceptsAuthorizationCode = acceptsAuthorizationCode;
128818
129181
  }
128819
129182
  output = "";
128820
129183
  lastAuthorization = "";
128821
129184
  push(chunk) {
128822
129185
  this.output = `${this.output}${stripVTControlCharacters(chunk)}`.slice(-32768);
128823
- const authorization = parseAuthorization(this.agentType, this.output);
129186
+ const authorization = parseAuthorization(this.isAuthorizationUrl, this.acceptsAuthorizationCode, this.output);
128824
129187
  if (!authorization) return void 0;
128825
129188
  const fingerprint = JSON.stringify(authorization);
128826
129189
  if (fingerprint === this.lastAuthorization) return void 0;
@@ -128828,6 +129191,227 @@ ${fallbackStderrTail}` : errorMessage2;
128828
129191
  return authorization;
128829
129192
  }
128830
129193
  }
129194
+ class BuiltinAuthenticationOutputParser extends AuthorizationOutputParser {
129195
+ constructor(agentType) {
129196
+ super((url) => isTrustedAuthorizationUrl(agentType, url), agentType === "claude");
129197
+ }
129198
+ }
129199
+ class AcpAgentAuthorizationOutputParser extends AuthorizationOutputParser {
129200
+ constructor() {
129201
+ super(isLikelyAuthorizationUrl, false);
129202
+ }
129203
+ }
129204
+ const ACP_AUTHENTICATION_INITIALIZE_TIMEOUT_MS = 6e4;
129205
+ const AUTHENTICATION_TERMINATION_GRACE_MS = 3e3;
129206
+ function normalizeAcpAuthMethod(method) {
129207
+ const record2 = method;
129208
+ const id2 = typeof record2.id === "string" ? record2.id.trim() : "";
129209
+ if (!id2) return null;
129210
+ const type2 = record2.type === "terminal" || record2.type === "env_var" ? record2.type : "agent";
129211
+ const args2 = Array.isArray(record2.args) && record2.args.every((arg) => typeof arg === "string") ? record2.args : void 0;
129212
+ const env2 = typeof record2.env === "object" && record2.env !== null ? Object.fromEntries(Object.entries(record2.env).filter((entry) => typeof entry[1] === "string")) : void 0;
129213
+ return {
129214
+ type: type2,
129215
+ id: id2,
129216
+ ...typeof record2.name === "string" ? {
129217
+ name: record2.name
129218
+ } : {},
129219
+ ...typeof record2.description === "string" ? {
129220
+ description: record2.description
129221
+ } : {},
129222
+ ...args2 ? {
129223
+ args: args2
129224
+ } : {},
129225
+ ...env2 && Object.keys(env2).length > 0 ? {
129226
+ env: env2
129227
+ } : {}
129228
+ };
129229
+ }
129230
+ function describeAcpAuthMethod(method) {
129231
+ return method.name?.trim() ? method.name : method.id;
129232
+ }
129233
+ function formatEnvVarAuthMethodError(method, normalized) {
129234
+ const vars = method.vars;
129235
+ const names2 = Array.isArray(vars) ? vars.map((entry) => typeof entry === "object" && entry !== null && typeof entry.name === "string" ? entry.name : null).filter((name2) => Boolean(name2)) : [];
129236
+ const suffix = names2.length > 0 ? `: ${names2.join(", ")}` : "";
129237
+ return `${describeAcpAuthMethod(normalized)} authenticates through environment variables. Add them to this agent's environment in its settings${suffix}.`;
129238
+ }
129239
+ function selectAuthMethod(methods2, methodId) {
129240
+ for (const method of methods2) {
129241
+ const normalized = normalizeAcpAuthMethod(method);
129242
+ if (!normalized) continue;
129243
+ if (methodId === void 0 || normalized.id === methodId) {
129244
+ return {
129245
+ method,
129246
+ normalized
129247
+ };
129248
+ }
129249
+ }
129250
+ return null;
129251
+ }
129252
+ function withDeadline(promise2, timeoutMs, label2) {
129253
+ let timeoutHandle;
129254
+ const timeout2 = new Promise((_resolve, reject2) => {
129255
+ timeoutHandle = setTimeout(() => reject2(new Error(`${label2} timed out after ${Math.round(timeoutMs / 1e3)}s`)), timeoutMs);
129256
+ timeoutHandle.unref?.();
129257
+ });
129258
+ return Promise.race([
129259
+ promise2,
129260
+ timeout2
129261
+ ]).finally(() => {
129262
+ if (timeoutHandle) clearTimeout(timeoutHandle);
129263
+ });
129264
+ }
129265
+ async function runAcpProtocolAuthentication(options) {
129266
+ options.signal?.throwIfAborted();
129267
+ const child = spawnAcpProcess({
129268
+ cliType: options.cliType,
129269
+ agentType: options.agentType,
129270
+ workdir: options.workdir,
129271
+ env: options.env,
129272
+ command: options.launch.command,
129273
+ args: options.launch.args,
129274
+ spawnImpl: options.spawnProcess
129275
+ });
129276
+ options.attachProcess?.(child);
129277
+ let stderrTail = "";
129278
+ const parser = new AcpAgentAuthorizationOutputParser();
129279
+ child.stderr?.setEncoding("utf8");
129280
+ child.stderr?.on("data", (chunk) => {
129281
+ if (!chunk) return;
129282
+ stderrTail = appendStderrTail(stderrTail, chunk);
129283
+ const authorization = parser.push(chunk);
129284
+ if (authorization) {
129285
+ options.onProgress?.({
129286
+ status: "authorization",
129287
+ ...authorization
129288
+ });
129289
+ }
129290
+ });
129291
+ let rejectProcessFailure;
129292
+ const processFailure = new Promise((_resolve, reject2) => {
129293
+ rejectProcessFailure = reject2;
129294
+ });
129295
+ const handleExit = (code2, signal) => {
129296
+ rejectProcessFailure?.(new Error(`${options.agentType} exited during authentication (code ${code2 ?? "null"}${signal ? `, signal ${signal}` : ""})${stderrTail ? `: ${stderrTail}` : ""}`));
129297
+ };
129298
+ const handleError2 = (error2) => {
129299
+ rejectProcessFailure?.(new Error(`${options.agentType} failed to start: ${error2.message}`));
129300
+ };
129301
+ child.once("exit", handleExit);
129302
+ child.once("error", handleError2);
129303
+ processFailure.catch(() => void 0);
129304
+ const handleAbort = () => {
129305
+ rejectProcessFailure?.(new DOMException("ACP authentication was cancelled", "AbortError"));
129306
+ };
129307
+ options.signal?.addEventListener("abort", handleAbort, {
129308
+ once: true
129309
+ });
129310
+ const terminate = () => {
129311
+ child.off("exit", handleExit);
129312
+ child.off("error", handleError2);
129313
+ options.signal?.removeEventListener("abort", handleAbort);
129314
+ void shutdownLocalAcpAgent({
129315
+ agentProcess: child,
129316
+ logger: options.logger,
129317
+ sessionLabel: `acp-auth-protocol:${options.agentType}`,
129318
+ exitTimeoutMs: AUTHENTICATION_TERMINATION_GRACE_MS
129319
+ }).catch((error2) => {
129320
+ options.logger.debug(`[acp-auth] Failed to stop ${options.agentType} after authentication: ${formatErrorMessage(error2)}`);
129321
+ });
129322
+ };
129323
+ try {
129324
+ if (!child.stdout || !child.stdin) {
129325
+ throw new Error("Agent process stdio is not available");
129326
+ }
129327
+ const stream2 = ndJsonStream(createStdinWritableStream(child.stdin), createStdoutReadableStream(child.stdout));
129328
+ const connection2 = new ClientSideConnection(() => ({
129329
+ requestPermission: async () => ({
129330
+ outcome: {
129331
+ outcome: "cancelled"
129332
+ }
129333
+ }),
129334
+ sessionUpdate: () => {
129335
+ }
129336
+ }), stream2);
129337
+ const initializeResponse = await Promise.race([
129338
+ withDeadline(connection2.initialize({
129339
+ protocolVersion: PROTOCOL_VERSION,
129340
+ clientCapabilities: {
129341
+ terminal: false,
129342
+ fs: {
129343
+ readTextFile: false,
129344
+ writeTextFile: false
129345
+ },
129346
+ auth: {
129347
+ terminal: true
129348
+ }
129349
+ }
129350
+ }), Math.max(1, options.initializeTimeoutMs ?? ACP_AUTHENTICATION_INITIALIZE_TIMEOUT_MS), `${options.agentType} initialize`),
129351
+ processFailure
129352
+ ]);
129353
+ options.signal?.throwIfAborted();
129354
+ const advertised = initializeResponse.authMethods ?? [];
129355
+ if (advertised.length === 0) {
129356
+ return {
129357
+ kind: "error",
129358
+ error: `${options.agentType} does not advertise an authentication method. Check the agent's own setup instructions or configure its credentials in this agent's environment.`
129359
+ };
129360
+ }
129361
+ const selected = selectAuthMethod(advertised, options.methodId);
129362
+ if (!selected) {
129363
+ if (options.methodId !== void 0) {
129364
+ return {
129365
+ kind: "error",
129366
+ error: `${options.agentType} no longer advertises the authentication method "${options.methodId}"`
129367
+ };
129368
+ }
129369
+ return {
129370
+ kind: "error",
129371
+ error: `${options.agentType} advertised no usable authentication method`
129372
+ };
129373
+ }
129374
+ const normalizedMethods = advertised.map(normalizeAcpAuthMethod).filter((method) => method !== null);
129375
+ if (options.methodId === void 0 && normalizedMethods.length > 1) {
129376
+ return {
129377
+ kind: "method-required",
129378
+ authMethods: normalizedMethods
129379
+ };
129380
+ }
129381
+ if (selected.normalized.type === "env_var") {
129382
+ return {
129383
+ kind: "error",
129384
+ error: formatEnvVarAuthMethodError(selected.method, selected.normalized)
129385
+ };
129386
+ }
129387
+ if (selected.normalized.type === "terminal") {
129388
+ return {
129389
+ kind: "terminal-method",
129390
+ method: selected.normalized
129391
+ };
129392
+ }
129393
+ options.logger.debug(`[acp-auth] ${options.agentType} authenticate methodId=${selected.normalized.id}`);
129394
+ await Promise.race([
129395
+ connection2.authenticate({
129396
+ methodId: selected.normalized.id
129397
+ }),
129398
+ processFailure
129399
+ ]);
129400
+ return {
129401
+ kind: "authenticated"
129402
+ };
129403
+ } catch (error2) {
129404
+ if (error2 instanceof DOMException && error2.name === "AbortError") {
129405
+ throw error2;
129406
+ }
129407
+ return {
129408
+ kind: "error",
129409
+ error: formatErrorMessage(error2)
129410
+ };
129411
+ } finally {
129412
+ terminate();
129413
+ }
129414
+ }
128831
129415
  const DEFAULT_AUTHENTICATION_TIMEOUT_MS = 285e3;
128832
129416
  const DEFAULT_TERMINATION_GRACE_MS$1 = 3e3;
128833
129417
  const DEFAULT_STATUS_PROBE_TIMEOUT_MS = 15e3;
@@ -129016,15 +129600,8 @@ ${fallbackStderrTail}` : errorMessage2;
129016
129600
  spawnProcess;
129017
129601
  resolveLoginShellEnv;
129018
129602
  async authenticate(options) {
129019
- if (options.cliType !== "builtin" || !isManagedBuiltinAgentType(options.agentType)) {
129020
- return {
129021
- success: false,
129022
- disposition: "error",
129023
- error: `Authentication is not supported for ${options.agentType}`
129024
- };
129025
- }
129026
- const displayName = getBuiltinDisplayName(options.agentType);
129027
- const agentType = options.agentType;
129603
+ const managedBuiltinAgentType = options.cliType === "builtin" && isManagedBuiltinAgentType(options.agentType) ? options.agentType : null;
129604
+ const displayName = managedBuiltinAgentType ? getBuiltinDisplayName(managedBuiltinAgentType) : options.agentType;
129028
129605
  if (this.runningByAgentType.has(options.agentType)) {
129029
129606
  return {
129030
129607
  success: false,
@@ -129038,7 +129615,8 @@ ${fallbackStderrTail}` : errorMessage2;
129038
129615
  timedOut: false,
129039
129616
  terminating: false,
129040
129617
  acceptsAuthorizationCode: false,
129041
- authorizationCodeSubmitted: false
129618
+ authorizationCodeSubmitted: false,
129619
+ abort: new AbortController()
129042
129620
  };
129043
129621
  this.runningByAgentType.set(options.agentType, running2);
129044
129622
  let timeoutHandle;
@@ -129076,99 +129654,18 @@ ${fallbackStderrTail}` : errorMessage2;
129076
129654
  }, this.authenticationTimeoutMs);
129077
129655
  timeoutHandle.unref?.();
129078
129656
  try {
129079
- const launch = await resolveBuiltinAuthenticationProcessLaunch({
129080
- cliType: options.cliType,
129081
- agentType: options.agentType,
129082
- runtimeOverrides: options.runtimeOverrides,
129083
- action: "login"
129084
- });
129085
- if (!launch) {
129086
- throw new Error(`${displayName} authentication is unavailable`);
129087
- }
129088
- const launchInterruption = interruptedResult();
129089
- if (launchInterruption) return launchInterruption;
129090
- const env2 = await buildAuthenticationProcessEnv({
129091
- launch,
129092
- agentType: options.agentType,
129093
- env: options.env,
129094
- resolveLoginShellEnv: this.resolveLoginShellEnv
129095
- });
129096
- const preparationInterruption = interruptedResult();
129097
- if (preparationInterruption) return preparationInterruption;
129098
- options.onProgress?.({
129099
- status: "starting"
129100
- });
129101
- const child = this.spawnProcess(launch.command, launch.args, {
129102
- cwd: os__default$1.homedir(),
129103
- env: env2,
129104
- stdio: [
129105
- "pipe",
129106
- "pipe",
129107
- "pipe"
129108
- ],
129109
- detached: process.platform !== "win32",
129110
- windowsHide: true
129111
- });
129112
- running2.child = child;
129113
- child.stdin?.on("error", (error2) => {
129114
- this.logger.debug(`[acp-auth] ${displayName} authorization input failed: ${formatErrorMessage(error2)}`);
129115
- });
129116
- const outputParser = new BuiltinAuthenticationOutputParser(agentType);
129117
- const emitOutput = (stream2, chunk) => {
129118
- const output = String(chunk);
129119
- if (output.length === 0) return;
129120
- const authorization = outputParser.push(output);
129121
- if (authorization) {
129122
- running2.acceptsAuthorizationCode = authorization.acceptsAuthorizationCode === true;
129123
- options.onProgress?.({
129124
- status: "authorization",
129125
- ...authorization
129126
- });
129127
- }
129128
- options.onProgress?.({
129129
- status: "output",
129130
- stream: stream2,
129131
- output: output.slice(0, 16384)
129132
- });
129133
- };
129134
- child.stdout?.on("data", (chunk) => emitOutput("stdout", chunk));
129135
- child.stderr?.on("data", (chunk) => emitOutput("stderr", chunk));
129136
- const exit2 = await new Promise((resolve2) => {
129137
- let settled = false;
129138
- const finish = (result) => {
129139
- if (settled) return;
129140
- settled = true;
129141
- resolve2(result);
129142
- };
129143
- child.once("error", (error2) => finish({
129144
- code: null,
129145
- error: error2
129146
- }));
129147
- child.once("exit", (code2) => finish({
129148
- code: code2
129149
- }));
129657
+ const result = managedBuiltinAgentType ? await this.runBuiltinLogin({
129658
+ options,
129659
+ running: running2,
129660
+ interruptedResult,
129661
+ agentType: managedBuiltinAgentType,
129662
+ displayName
129663
+ }) : await this.runProtocolAuthentication({
129664
+ options,
129665
+ running: running2,
129666
+ interruptedResult
129150
129667
  });
129151
- const processInterruption = interruptedResult();
129152
- if (processInterruption) return processInterruption;
129153
- if (exit2.error !== void 0 || exit2.code !== 0) {
129154
- const error2 = exit2.error !== void 0 ? formatErrorMessage(exit2.error) : formatAuthenticationExitError(agentType, displayName, exit2.code);
129155
- options.onProgress?.({
129156
- status: "error",
129157
- error: error2
129158
- });
129159
- return {
129160
- success: false,
129161
- disposition: "error",
129162
- error: error2
129163
- };
129164
- }
129165
- options.onProgress?.({
129166
- status: "authenticated"
129167
- });
129168
- return {
129169
- success: true,
129170
- disposition: "authenticated"
129171
- };
129668
+ return result;
129172
129669
  } catch (error2) {
129173
129670
  const interruption2 = interruptedResult();
129174
129671
  if (interruption2) return interruption2;
@@ -129191,6 +129688,241 @@ ${fallbackStderrTail}` : errorMessage2;
129191
129688
  }
129192
129689
  }
129193
129690
  }
129691
+ async runBuiltinLogin(ctx) {
129692
+ const { options, interruptedResult, agentType, displayName } = ctx;
129693
+ const launch = await resolveBuiltinAuthenticationProcessLaunch({
129694
+ cliType: options.cliType,
129695
+ agentType: options.agentType,
129696
+ runtimeOverrides: options.runtimeOverrides,
129697
+ action: "login"
129698
+ });
129699
+ if (!launch) {
129700
+ throw new Error(`${displayName} authentication is unavailable`);
129701
+ }
129702
+ const launchInterruption = interruptedResult();
129703
+ if (launchInterruption) return launchInterruption;
129704
+ const env2 = await buildAuthenticationProcessEnv({
129705
+ launch,
129706
+ agentType: options.agentType,
129707
+ env: options.env,
129708
+ resolveLoginShellEnv: this.resolveLoginShellEnv
129709
+ });
129710
+ const preparationInterruption = interruptedResult();
129711
+ if (preparationInterruption) return preparationInterruption;
129712
+ options.onProgress?.({
129713
+ status: "starting"
129714
+ });
129715
+ return await this.runLoginProcess({
129716
+ ...ctx,
129717
+ displayName,
129718
+ command: launch.command,
129719
+ args: launch.args,
129720
+ env: env2,
129721
+ parser: new BuiltinAuthenticationOutputParser(agentType),
129722
+ formatExitError: (code2) => formatAuthenticationExitError(agentType, displayName, code2),
129723
+ acceptsAuthorizationCodeOnStdin: true
129724
+ });
129725
+ }
129726
+ async runProtocolAuthentication(ctx) {
129727
+ const { options, running: running2, interruptedResult } = ctx;
129728
+ const launch = await resolveACPProcessLaunchAsync({
129729
+ cliType: options.cliType,
129730
+ agentType: options.agentType,
129731
+ customAcp: options.customAcp,
129732
+ runtimeOverrides: options.runtimeOverrides,
129733
+ signal: running2.abort.signal
129734
+ });
129735
+ const launchInterruption = interruptedResult();
129736
+ if (launchInterruption) return launchInterruption;
129737
+ const env2 = await this.buildAcpAuthenticationProcessEnv(launch, options, {
129738
+ protocolStdio: true
129739
+ });
129740
+ const preparationInterruption = interruptedResult();
129741
+ if (preparationInterruption) return preparationInterruption;
129742
+ options.onProgress?.({
129743
+ status: "starting"
129744
+ });
129745
+ const outcome = await runAcpProtocolAuthentication({
129746
+ launch: {
129747
+ command: launch.command,
129748
+ args: launch.args
129749
+ },
129750
+ cliType: options.cliType,
129751
+ agentType: options.agentType,
129752
+ workdir: os__default$1.homedir(),
129753
+ env: env2,
129754
+ methodId: options.methodId,
129755
+ logger: this.logger,
129756
+ signal: running2.abort.signal,
129757
+ onProgress: options.onProgress,
129758
+ attachProcess: (child) => {
129759
+ running2.child = child;
129760
+ },
129761
+ spawnProcess: this.spawnProcess
129762
+ });
129763
+ const outcomeInterruption = interruptedResult();
129764
+ if (outcomeInterruption) return outcomeInterruption;
129765
+ if (outcome.kind === "authenticated") {
129766
+ options.onProgress?.({
129767
+ status: "authenticated"
129768
+ });
129769
+ return {
129770
+ success: true,
129771
+ disposition: "authenticated"
129772
+ };
129773
+ }
129774
+ if (outcome.kind === "method-required") {
129775
+ return {
129776
+ success: true,
129777
+ disposition: "method-required",
129778
+ authMethods: outcome.authMethods.map((method) => ({
129779
+ type: method.type,
129780
+ id: method.id,
129781
+ ...method.name ? {
129782
+ name: method.name
129783
+ } : {},
129784
+ ...method.description ? {
129785
+ description: method.description
129786
+ } : {}
129787
+ }))
129788
+ };
129789
+ }
129790
+ if (outcome.kind === "terminal-method") {
129791
+ running2.child = void 0;
129792
+ return await this.runTerminalAuthMethod(ctx, outcome.method);
129793
+ }
129794
+ options.onProgress?.({
129795
+ status: "error",
129796
+ error: outcome.error
129797
+ });
129798
+ return {
129799
+ success: false,
129800
+ disposition: "error",
129801
+ error: outcome.error
129802
+ };
129803
+ }
129804
+ async runTerminalAuthMethod(ctx, method) {
129805
+ const { options, interruptedResult } = ctx;
129806
+ const displayName = describeAcpAuthMethod(method);
129807
+ const launch = await resolveACPProcessLaunchAsync({
129808
+ cliType: options.cliType,
129809
+ agentType: options.agentType,
129810
+ customAcp: options.customAcp,
129811
+ runtimeOverrides: options.runtimeOverrides,
129812
+ extraArgs: [
129813
+ ...method.args ?? []
129814
+ ],
129815
+ signal: ctx.running.abort.signal
129816
+ });
129817
+ const launchInterruption = interruptedResult();
129818
+ if (launchInterruption) return launchInterruption;
129819
+ const env2 = await this.buildAcpAuthenticationProcessEnv(launch, options, {
129820
+ methodEnv: method.env
129821
+ });
129822
+ const preparationInterruption = interruptedResult();
129823
+ if (preparationInterruption) return preparationInterruption;
129824
+ return await this.runLoginProcess({
129825
+ ...ctx,
129826
+ displayName,
129827
+ command: launch.command,
129828
+ args: launch.args,
129829
+ env: env2,
129830
+ parser: new AcpAgentAuthorizationOutputParser(),
129831
+ formatExitError: (code2) => `${options.agentType} authentication exited with code ${code2 ?? "unknown"}`,
129832
+ acceptsAuthorizationCodeOnStdin: false
129833
+ });
129834
+ }
129835
+ async buildAcpAuthenticationProcessEnv(launch, options, settings = {}) {
129836
+ const env2 = await buildAuthenticationProcessEnv({
129837
+ launch,
129838
+ agentType: options.agentType,
129839
+ env: settings.methodEnv ? {
129840
+ ...options.env,
129841
+ ...settings.methodEnv
129842
+ } : options.env,
129843
+ resolveLoginShellEnv: this.resolveLoginShellEnv
129844
+ });
129845
+ if (settings.protocolStdio) {
129846
+ delete env2.TERM;
129847
+ }
129848
+ return withLodyNpmCacheForNpx(launch.command, env2);
129849
+ }
129850
+ async runLoginProcess(ctx) {
129851
+ const { options, running: running2, interruptedResult, displayName } = ctx;
129852
+ const child = this.spawnProcess(ctx.command, ctx.args, {
129853
+ cwd: os__default$1.homedir(),
129854
+ env: ctx.env,
129855
+ stdio: [
129856
+ "pipe",
129857
+ "pipe",
129858
+ "pipe"
129859
+ ],
129860
+ detached: process.platform !== "win32",
129861
+ windowsHide: true
129862
+ });
129863
+ running2.child = child;
129864
+ if (running2.cancelled || running2.timedOut) {
129865
+ this.terminateAuthentication(options.agentType, running2, running2.cancelled ? "cancelled" : "timed out");
129866
+ }
129867
+ child.stdin?.on("error", (error2) => {
129868
+ this.logger.debug(`[acp-auth] ${displayName} authorization input failed: ${formatErrorMessage(error2)}`);
129869
+ });
129870
+ const emitOutput = (stream2, chunk) => {
129871
+ const output = String(chunk);
129872
+ if (output.length === 0) return;
129873
+ const authorization = ctx.parser.push(output);
129874
+ if (authorization) {
129875
+ running2.acceptsAuthorizationCode = ctx.acceptsAuthorizationCodeOnStdin && authorization.acceptsAuthorizationCode === true;
129876
+ options.onProgress?.({
129877
+ status: "authorization",
129878
+ ...authorization
129879
+ });
129880
+ }
129881
+ options.onProgress?.({
129882
+ status: "output",
129883
+ stream: stream2,
129884
+ output: output.slice(0, 16384)
129885
+ });
129886
+ };
129887
+ child.stdout?.on("data", (chunk) => emitOutput("stdout", chunk));
129888
+ child.stderr?.on("data", (chunk) => emitOutput("stderr", chunk));
129889
+ const exit2 = await new Promise((resolve2) => {
129890
+ let settled = false;
129891
+ const finish = (result) => {
129892
+ if (settled) return;
129893
+ settled = true;
129894
+ resolve2(result);
129895
+ };
129896
+ child.once("error", (error2) => finish({
129897
+ code: null,
129898
+ error: error2
129899
+ }));
129900
+ child.once("exit", (code2) => finish({
129901
+ code: code2
129902
+ }));
129903
+ });
129904
+ const processInterruption = interruptedResult();
129905
+ if (processInterruption) return processInterruption;
129906
+ if (exit2.error !== void 0 || exit2.code !== 0) {
129907
+ const error2 = exit2.error !== void 0 ? formatErrorMessage(exit2.error) : ctx.formatExitError(exit2.code);
129908
+ options.onProgress?.({
129909
+ status: "error",
129910
+ error: error2
129911
+ });
129912
+ return {
129913
+ success: false,
129914
+ disposition: "error",
129915
+ error: error2
129916
+ };
129917
+ }
129918
+ options.onProgress?.({
129919
+ status: "authenticated"
129920
+ });
129921
+ return {
129922
+ success: true,
129923
+ disposition: "authenticated"
129924
+ };
129925
+ }
129194
129926
  cancel(agentType, requestId) {
129195
129927
  const running2 = this.runningByAgentType.get(agentType);
129196
129928
  if (!running2 || running2.requestId !== requestId) {
@@ -129265,6 +129997,7 @@ ${fallbackStderrTail}` : errorMessage2;
129265
129997
  }
129266
129998
  }
129267
129999
  terminateAuthentication(agentType, running2, reason) {
130000
+ running2.abort.abort();
129268
130001
  if (running2.terminating || !running2.child) return;
129269
130002
  running2.terminating = true;
129270
130003
  void shutdownLocalAcpAgent({
@@ -133205,18 +133938,13 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
133205
133938
  await withAbortSignal(sleep2(retryDelayMs), options.signal);
133206
133939
  }
133207
133940
  }
133208
- function getPendingUserTurnActivationId(meta) {
133209
- const missingUserTurnId = meta.lastMissingHistoryUserMsgId;
133210
- if (typeof meta.processingUserMsgId === "string" && meta.processingUserMsgId.length > 0 && meta.processingUserMsgId !== missingUserTurnId) {
133211
- return meta.processingUserMsgId;
133212
- }
133213
- if (typeof meta.latestUserMsgId === "string" && meta.latestUserMsgId.length > 0 && meta.latestUserMsgId !== meta.lastHandledUserMsgId && meta.latestUserMsgId !== missingUserTurnId) {
133214
- return meta.latestUserMsgId;
133941
+ function isActivationAwaitingHistory(history, pendingUserTurnId) {
133942
+ const entry = history.find((item) => item.role === "user" && item.id === pendingUserTurnId);
133943
+ if (!entry) {
133944
+ return true;
133215
133945
  }
133216
- return void 0;
133217
- }
133218
- function hasPendingUserTurnActivation(meta) {
133219
- return getPendingUserTurnActivationId(meta) !== void 0;
133946
+ const status = resolveSessionHistoryStatus(entry);
133947
+ return status !== "handled" && status !== "failed" && status !== "canceled";
133220
133948
  }
133221
133949
  function shouldWatchSession(snapshot) {
133222
133950
  const { meta, hasUnprocessedCancelRequest, hasRpcTurnOffer, hasAccessRetry } = snapshot;
@@ -134155,7 +134883,10 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
134155
134883
  return preConfigRejection;
134156
134884
  }
134157
134885
  if (steerCapability.configPolicy === "apply") {
134158
- await this.deps.applyAcpModeAndModel(runtime.session, options.inputConfig);
134886
+ await this.deps.applyAcpModeAndModel(runtime.session, options.inputConfig, {
134887
+ sessionDoc,
134888
+ basedOnUserTurnId: options.userTurnId
134889
+ });
134159
134890
  }
134160
134891
  const preSubmitRejection = await rejectBeforeProviderSubmission();
134161
134892
  if (preSubmitRejection) {
@@ -134550,7 +135281,9 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
134550
135281
  }
134551
135282
  runtime.prePromptFailureRecorded = true;
134552
135283
  const message = formatErrorMessage(error2);
134553
- if (isGitExecutableNotFoundError(error2)) {
135284
+ if (error2 instanceof AcpAuthenticationRequiredError) {
135285
+ await this.deps.recordChatFailure(sessionDoc, "acp_auth_required", message);
135286
+ } else if (isGitExecutableNotFoundError(error2)) {
134554
135287
  await this.deps.recordChatFailure(sessionDoc, "turn_pre_prompt_failed", message, GIT_EXECUTABLE_NOT_FOUND_CODE);
134555
135288
  } else {
134556
135289
  await this.deps.recordChatFailure(sessionDoc, "turn_pre_prompt_failed", message);
@@ -135674,6 +136407,9 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
135674
136407
  }, async () => await self2.deps.applyAcpModeAndModel(targetSession, {
135675
136408
  ...acpSessionConfig,
135676
136409
  configOptionValues: acpSessionConfig.configOptionValues
136410
+ }, {
136411
+ sessionDoc,
136412
+ basedOnUserTurnId: executionUserTurnId
135677
136413
  })));
135678
136414
  const refreshPromptGitHubToken = (targetSession, triggerReason) => gen(function* () {
135679
136415
  if (!project) {
@@ -136178,6 +136914,9 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
136178
136914
  }, async () => await self2.deps.applyAcpModeAndModel(session2, {
136179
136915
  ...agentConfig,
136180
136916
  configOptionValues: agentConfig.configOptionValues
136917
+ }, {
136918
+ sessionDoc,
136919
+ basedOnUserTurnId: userTurnId
136181
136920
  })));
136182
136921
  yield* abortIfCancelled();
136183
136922
  const containerWorkdir = session2.getWorkdir();
@@ -136493,8 +137232,20 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
136493
137232
  customAcp: message.customAcp,
136494
137233
  runtimeOverrides: message.runtimeOverrides,
136495
137234
  env: message.env,
137235
+ methodId: message.methodId,
136496
137236
  onProgress
136497
137237
  });
137238
+ if (result.disposition === "method-required") {
137239
+ return {
137240
+ ...base,
137241
+ success: true,
137242
+ disposition: "method-required",
137243
+ authRequired: true,
137244
+ authMethods: result.authMethods.map((method) => ({
137245
+ ...method
137246
+ }))
137247
+ };
137248
+ }
136498
137249
  if (result.success && result.disposition === "authenticated" && message.configId) {
136499
137250
  const refresh = await this.refreshMachineAcpCapabilities({
136500
137251
  type: "machine/acp-capabilities-refresh",
@@ -137440,7 +138191,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
137440
138191
  }
137441
138192
  const now2 = Date.now();
137442
138193
  for (const [userTurnId, stashed] of stash) {
137443
- const isTerminal2 = meta.lastHandledUserMsgId === userTurnId || this.deps.executionService.getTerminalUserTurnStatusWithoutEntry?.(sessionId, userTurnId) !== void 0 || history.some((entry) => entry.id === userTurnId && entry.role === "user" && (entry.status === "handled" || entry.status === "failed" || entry.status === "canceled"));
138194
+ const isTerminal2 = meta.lastHandledUserMsgId === userTurnId || this.deps.executionService.getTerminalUserTurnStatusWithoutEntry?.(sessionId, userTurnId) !== void 0 || !isActivationAwaitingHistory(history, userTurnId);
137444
138195
  if (stashed.expiresAtMs <= now2 || isTerminal2) {
137445
138196
  stash.delete(userTurnId);
137446
138197
  continue;
@@ -137690,7 +138441,8 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
137690
138441
  if (!isActive()) {
137691
138442
  return;
137692
138443
  }
137693
- const meta = isLoroRepoDocDeleted(record2) ? void 0 : record2?.meta;
138444
+ const docDeleted = isLoroRepoDocDeleted(record2);
138445
+ const meta = docDeleted ? void 0 : record2?.meta;
137694
138446
  phase = "evaluate-ownership";
137695
138447
  const isOwned = meta?.machineId === this.deps.machineId && !meta?.isArchived;
137696
138448
  if (!isOwned) {
@@ -137699,7 +138451,9 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
137699
138451
  this.watchedSessions.delete(sessionId);
137700
138452
  this.cancelCheckChains.delete(sessionId);
137701
138453
  this.cancelSeenTurn.delete(sessionId);
137702
- this.rpcTurnStash.delete(sessionId);
138454
+ if (meta || docDeleted) {
138455
+ this.rpcTurnStash.delete(sessionId);
138456
+ }
137703
138457
  this.interruptAccessRetry(sessionId);
137704
138458
  return;
137705
138459
  }
@@ -137843,7 +138597,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
137843
138597
  return;
137844
138598
  }
137845
138599
  if (!nextUserTurn) {
137846
- if (this.hasPendingUserTurnSignal(meta)) {
138600
+ if (hasPendingUserTurnActivation(meta)) {
137847
138601
  outcome = "missing-history";
137848
138602
  await this.markMissingUserTurnRecovery(sessionId, sessionDoc, meta);
137849
138603
  } else {
@@ -138347,10 +139101,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
138347
139101
  ...pendingEntry,
138348
139102
  id: queuedTurnId
138349
139103
  };
138350
- await sessionDoc.updateHistory((prevHistory) => [
138351
- ...prevHistory,
138352
- entry
138353
- ]);
139104
+ await sessionDoc.appendUserTurn(entry);
138354
139105
  return entry;
138355
139106
  } finally {
138356
139107
  releaseQueueMutation();
@@ -138381,20 +139132,50 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
138381
139132
  }
138382
139133
  async findOrAwaitDispatchableTurn(sessionId, sessionDoc, meta, lifecycleGeneration) {
138383
139134
  const isActive = () => this.isLifecycleActive(lifecycleGeneration);
138384
- const turn = await this.checkHistoryAndQueue(sessionDoc, meta, isActive);
139135
+ const { turn, history } = await this.checkHistoryAndQueue(sessionDoc, meta, isActive);
138385
139136
  if (!isActive()) {
138386
139137
  return null;
138387
139138
  }
138388
139139
  if (turn) {
138389
139140
  return turn;
138390
139141
  }
138391
- if (this.hasPendingUserTurnSignal(meta)) {
138392
- return await this.waitForPendingUserTurnHistorySync(sessionId, sessionDoc, meta, lifecycleGeneration);
139142
+ const pendingUserTurnId = getPendingUserTurnActivationId(meta);
139143
+ if (!pendingUserTurnId) {
139144
+ return null;
138393
139145
  }
138394
- return null;
139146
+ if (!isActivationAwaitingHistory(history, pendingUserTurnId)) {
139147
+ if (await this.settleTerminalActivation(sessionId, pendingUserTurnId)) {
139148
+ return null;
139149
+ }
139150
+ }
139151
+ return await this.waitForPendingUserTurnHistorySync(sessionId, sessionDoc, meta, lifecycleGeneration);
138395
139152
  }
138396
- hasPendingUserTurnSignal(meta) {
138397
- return hasPendingUserTurnActivation(meta);
139153
+ async settleTerminalActivation(sessionId, terminalUserTurnId) {
139154
+ const roomId = getSessionRoomId(sessionId);
139155
+ const record2 = await this.deps.workspaceDocument.repo.getDocMeta(roomId);
139156
+ const meta = isLoroRepoDocDeleted(record2) ? void 0 : record2?.meta;
139157
+ if (!meta) {
139158
+ return false;
139159
+ }
139160
+ const clearsProcessing = meta.processingUserMsgId === terminalUserTurnId;
139161
+ const retiresLatest = meta.latestUserMsgId === terminalUserTurnId;
139162
+ const patch2 = {
139163
+ ...clearsProcessing ? {
139164
+ processingUserMsgId: void 0
139165
+ } : {},
139166
+ ...retiresLatest ? {
139167
+ settledActivationUserMsgId: terminalUserTurnId
139168
+ } : {}
139169
+ };
139170
+ if (!clearsProcessing && !retiresLatest) {
139171
+ return false;
139172
+ }
139173
+ this.deps.logger.debug(`[${sessionId}] Settling stale activation ${terminalUserTurnId}; its history entry is already terminal`);
139174
+ await this.deps.workspaceDocument.repo.upsertDocMeta?.(roomId, patch2);
139175
+ return !hasPendingUserTurnActivation({
139176
+ ...meta,
139177
+ ...patch2
139178
+ });
138398
139179
  }
138399
139180
  async waitForPendingUserTurnHistorySync(sessionId, sessionDoc, meta, lifecycleGeneration) {
138400
139181
  const isActive = () => this.isLifecycleActive(lifecycleGeneration);
@@ -138402,7 +139183,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
138402
139183
  return null;
138403
139184
  }
138404
139185
  const pendingUserTurnId = getPendingUserTurnActivationId(meta);
138405
- this.deps.logger.debug(`[${sessionId}] Pending user turn ${getPendingUserTurnActivationId(meta) ?? "unknown"} metadata is visible but history is missing it; waiting up to ${SessionDispatchWatcher.HISTORY_SYNC_WAIT_TIMEOUT_MS / 1e3}s for history CRDT sync (pendingUserMsgId=${pendingUserTurnId ?? "unknown"})`);
139186
+ this.deps.logger.debug(`[${sessionId}] Pending user turn ${pendingUserTurnId ?? "unknown"} has no history entry yet; waiting up to ${SessionDispatchWatcher.HISTORY_SYNC_WAIT_TIMEOUT_MS / 1e3}s for history CRDT sync`);
138406
139187
  return await new Promise((resolve2) => {
138407
139188
  let settled = false;
138408
139189
  let currentMeta = meta;
@@ -138455,7 +139236,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
138455
139236
  try {
138456
139237
  while (checkRequested) {
138457
139238
  checkRequested = false;
138458
- const turn = await this.checkHistoryAndQueue(sessionDoc, currentMeta, isActive);
139239
+ const { turn } = await this.checkHistoryAndQueue(sessionDoc, currentMeta, isActive);
138459
139240
  if (settled || !isActive()) {
138460
139241
  finish(null);
138461
139242
  return;
@@ -138586,7 +139367,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
138586
139367
  finish(null);
138587
139368
  return;
138588
139369
  }
138589
- if (!this.hasPendingUserTurnSignal(currentMeta)) {
139370
+ if (!hasPendingUserTurnActivation(currentMeta)) {
138590
139371
  this.deps.logger.debug(`[${sessionId}] Pending user turn pointer cleared during pre-wait sync; exiting wait`);
138591
139372
  exitWhenCheckIsEmpty = true;
138592
139373
  }
@@ -138610,7 +139391,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
138610
139391
  } catch (error2) {
138611
139392
  this.deps.logger.debug(`[${sessionId}] Failed to refresh metadata before dispatch recovery: ${formatErrorMessage(error2)}`);
138612
139393
  }
138613
- if (meta.machineId !== this.deps.machineId || meta.isArchived || !this.hasPendingUserTurnSignal(meta)) {
139394
+ if (meta.machineId !== this.deps.machineId || meta.isArchived || !hasPendingUserTurnActivation(meta)) {
138614
139395
  return;
138615
139396
  }
138616
139397
  const pendingUserMsgId = getPendingUserTurnActivationId(meta);
@@ -138640,7 +139421,10 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
138640
139421
  async checkHistoryAndQueue(sessionDoc, meta, isActive = () => true) {
138641
139422
  const history = await sessionDoc.getHistory();
138642
139423
  if (!isActive()) {
138643
- return null;
139424
+ return {
139425
+ turn: null,
139426
+ history
139427
+ };
138644
139428
  }
138645
139429
  const turn = findNextDispatchableUserTurn(history, meta);
138646
139430
  if (turn) {
@@ -138649,20 +139433,35 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
138649
139433
  return await this.checkHistoryAndQueue(sessionDoc, meta, isActive);
138650
139434
  }
138651
139435
  this.consumeStashedRpcTurn(meta.id, turn.id);
138652
- return turn;
139436
+ return {
139437
+ turn,
139438
+ history
139439
+ };
138653
139440
  }
138654
139441
  if (!isActive()) {
138655
- return null;
139442
+ return {
139443
+ turn: null,
139444
+ history
139445
+ };
138656
139446
  }
138657
139447
  const promoted = await this.promoteNextQueuedMessage(sessionDoc, meta, history);
138658
139448
  if (!isActive()) {
138659
- return null;
139449
+ return {
139450
+ turn: null,
139451
+ history
139452
+ };
138660
139453
  }
138661
139454
  if (promoted) {
138662
139455
  this.turnSourceHints.set(`${meta.id}:${promoted.id}`, "queue");
138663
- return promoted;
139456
+ return {
139457
+ turn: promoted,
139458
+ history
139459
+ };
138664
139460
  }
138665
- return this.peekStashedRpcTurn(meta.id, meta, history);
139461
+ return {
139462
+ turn: this.peekStashedRpcTurn(meta.id, meta, history),
139463
+ history
139464
+ };
138666
139465
  }
138667
139466
  async maybeRepairAlreadyHandledTurn(sessionDoc, meta, turn, history) {
138668
139467
  const sessionId = meta.id;
@@ -140288,14 +141087,14 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
140288
141087
  return serialized;
140289
141088
  };
140290
141089
  const fingerprintLodyCommand = (kind, canonical) => createHash("sha256").update(kind).update("\0").update(canonical).digest("hex");
140291
- const getLodyOperationStorePath = (machineId = process.env.LODY_MCP_MACHINE_ID ?? process.env.LODY_PREVIEW_MCP_MACHINE_ID ?? "local", homeDir = os__default.homedir()) => {
141090
+ const getLodyOperationStorePath = (machineId, homeDir = os__default.homedir()) => {
140292
141091
  const machineKey = createHash("sha256").update(machineId).digest("hex").slice(0, 24);
140293
141092
  return path__default.join(getLodyDataDir(void 0, homeDir), "orchestration", machineKey, "operations.sqlite3");
140294
141093
  };
140295
141094
  const getOperationDeliveryId = (requesterSessionId, operationId) => `operation:${requesterSessionId}:${operationId}:completion`;
140296
141095
  const getOperationCompletionTurnId = (requesterSessionId, operationId) => `operation-completion:${requesterSessionId}:${operationId}`;
140297
141096
  class LodyOperationStore {
140298
- constructor(dbPath = getLodyOperationStorePath(), now2 = Date.now, options = {}) {
141097
+ constructor(dbPath, now2 = Date.now, options = {}) {
140299
141098
  this.now = now2;
140300
141099
  const storeDirectory = path__default.dirname(dbPath);
140301
141100
  mkdirSync$2(storeDirectory, {
@@ -140720,6 +141519,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
140720
141519
  const TARGET_OUTPUT_PREVIEW_MAX_BYTES = 8 * 1024;
140721
141520
  const MATERIALIZATION_RETRY_MIN_MS = 1e3;
140722
141521
  const MATERIALIZATION_RETRY_MAX_MS = 3e4;
141522
+ const DELIVERY_EXPIRY_GRACE_MS = 8 * 60 * 60 * 1e3;
140723
141523
  const truncateTargetOutput = (text) => {
140724
141524
  const originalBytes = Buffer.byteLength(text, "utf8");
140725
141525
  if (originalBytes <= TARGET_OUTPUT_PREVIEW_MAX_BYTES) return {
@@ -141247,9 +142047,13 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
141247
142047
  this.consumeDelivery(delivery, reason, continuationEvidence);
141248
142048
  return;
141249
142049
  }
142050
+ const operation = this.withStore((store) => store.get(delivery.requesterSessionId, delivery.operationId));
142051
+ if (this.now() >= Date.parse(operation.deadlineAt) + DELIVERY_EXPIRY_GRACE_MS) {
142052
+ this.consumeDelivery(delivery, reason, "expired_stale");
142053
+ return;
142054
+ }
141250
142055
  if (execution.hasActiveTurn) return;
141251
142056
  if (this.options.dispatchWatcher.hasPendingDispatch(delivery.requesterSessionId)) return;
141252
- const operation = this.withStore((store) => store.get(delivery.requesterSessionId, delivery.operationId));
141253
142057
  const configuration = await this.resolveFrozenConfiguration(operation, delivery, reason);
141254
142058
  if (configuration === "unknown") {
141255
142059
  this.armConfigurationRetry(delivery.requesterSessionId);
@@ -154483,45 +155287,84 @@ ${entry.text}`).join("\n\n");
154483
155287
  }
154484
155288
  return response2;
154485
155289
  }
154486
- async function resolveLocalProjectBranchOnMachine(args2) {
154487
- if (!args2.requestedBranch?.trim() && args2.useWorktree !== true) {
154488
- return void 0;
154489
- }
154490
- const response2 = await readLocalProjectGitStateOnMachine(args2);
154491
- if (!response2.success) {
154492
- if (args2.requestedBranch || args2.useWorktree === true) {
154493
- throw new Error(response2.message ?? response2.error);
154494
- }
155290
+ function selectWorkspaceRepoFullName(githubRepoFullName, workspaceRepositories) {
155291
+ const repoFullName = normalizeCliValue(githubRepoFullName);
155292
+ if (!repoFullName) {
154495
155293
  return void 0;
154496
155294
  }
154497
- if (!response2.state.git) {
155295
+ const normalized = repoFullName.toLowerCase();
155296
+ return workspaceRepositories.find((repo) => repo.fullName.toLowerCase() === normalized)?.fullName;
155297
+ }
155298
+ function resolveLocalProjectCreateGitContext(args2) {
155299
+ const requestedBranch = normalizeCliValue(args2.requestedBranch);
155300
+ if (!args2.gitState.git) {
154498
155301
  if (args2.useWorktree === true) {
154499
155302
  throw new Error("Cannot use --worktree with a local project that is not a git repository.");
154500
155303
  }
154501
- if (args2.requestedBranch) {
155304
+ if (requestedBranch) {
154502
155305
  throw new Error("Cannot use --branch with a local project that is not a git repository.");
154503
155306
  }
154504
- return void 0;
155307
+ return {};
154505
155308
  }
154506
- if (response2.state.branches.length === 0) {
154507
- if (args2.requestedBranch?.trim()) {
154508
- throw new Error(`Local project branch not found: ${args2.requestedBranch.trim()}`);
154509
- }
154510
- if (args2.useWorktree === true) {
154511
- throw new Error("The local project does not have a branch to use as a worktree base.");
155309
+ const githubRepoFullName = selectWorkspaceRepoFullName(args2.gitState.githubRepoFullName, args2.workspaceRepositories);
155310
+ const identity2 = githubRepoFullName ? {
155311
+ githubRepoFullName
155312
+ } : {};
155313
+ if (!requestedBranch && args2.useWorktree !== true) {
155314
+ return identity2;
155315
+ }
155316
+ if (args2.gitState.branches.length === 0) {
155317
+ if (requestedBranch) {
155318
+ throw new Error(`Local project branch not found: ${requestedBranch}`);
154512
155319
  }
154513
- return void 0;
155320
+ throw new Error("The local project does not have a branch to use as a worktree base.");
154514
155321
  }
154515
155322
  const branch = resolveBaseBranchPreference({
154516
- preferredBranch: args2.requestedBranch,
154517
- baseBranch: response2.state.currentBranch,
154518
- fallbackBranch: response2.state.defaultBranch ?? response2.state.branches[0]
155323
+ preferredBranch: requestedBranch,
155324
+ baseBranch: args2.gitState.currentBranch,
155325
+ fallbackBranch: args2.gitState.defaultBranch ?? args2.gitState.branches[0]
154519
155326
  });
154520
- const selected = selectLocalProjectBranchSelector(response2.state.branches, branch);
155327
+ const selected = selectLocalProjectBranchSelector(args2.gitState.branches, branch);
154521
155328
  if (!selected) {
154522
155329
  throw new Error(`Local project branch not found: ${branch}`);
154523
155330
  }
154524
- return selected;
155331
+ return {
155332
+ branch: selected,
155333
+ ...identity2
155334
+ };
155335
+ }
155336
+ async function listWorkspaceGitHubRepositoriesBestEffort(args2) {
155337
+ try {
155338
+ return await listWorkspaceGitHubRepositoriesForCliToken({
155339
+ token: args2.auth.token,
155340
+ workspaceId: args2.workspaceId,
155341
+ requesterUserId: resolveSessionCommandRequesterUserId(args2.auth, args2.requesterUserId),
155342
+ enabledOnly: true
155343
+ });
155344
+ } catch (error2) {
155345
+ getLogger("session").warn(`Workspace GitHub repositories unavailable; creating the local session without repository identity: ${formatErrorMessage(error2)}`);
155346
+ return [];
155347
+ }
155348
+ }
155349
+ async function resolveLocalProjectCreateGitContextOnMachine(args2) {
155350
+ const response2 = await readLocalProjectGitStateOnMachine(args2);
155351
+ if (!response2.success) {
155352
+ if (normalizeCliValue(args2.requestedBranch) || args2.useWorktree === true) {
155353
+ throw new Error(response2.message ?? response2.error);
155354
+ }
155355
+ return {};
155356
+ }
155357
+ const workspaceRepositories = response2.state.git && normalizeCliValue(response2.state.githubRepoFullName) ? await listWorkspaceGitHubRepositoriesBestEffort(args2) : [];
155358
+ return resolveLocalProjectCreateGitContext({
155359
+ gitState: response2.state,
155360
+ workspaceRepositories,
155361
+ ...args2.requestedBranch ? {
155362
+ requestedBranch: args2.requestedBranch
155363
+ } : {},
155364
+ ...args2.useWorktree !== void 0 ? {
155365
+ useWorktree: args2.useWorktree
155366
+ } : {}
155367
+ });
154525
155368
  }
154526
155369
  async function resolveLocalProjectRefOnMachineOrThrow(manager, workspaceId, auth, machineId, selector, requesterUserId, requestedBranch, useWorktree) {
154527
155370
  await syncMachineFlockDocsForRead(manager, workspaceId, [
@@ -154553,7 +155396,7 @@ ${entry.text}`).join("\n\n");
154553
155396
  throw new Error(`Local project selector is ambiguous on ${machineId}: ${normalizedSelector}. Use a project id instead.`);
154554
155397
  }
154555
155398
  const project = matches[0];
154556
- const branch = await resolveLocalProjectBranchOnMachine({
155399
+ const { branch, githubRepoFullName } = await resolveLocalProjectCreateGitContextOnMachine({
154557
155400
  auth,
154558
155401
  workspaceId,
154559
155402
  machineId,
@@ -154569,6 +155412,9 @@ ${entry.text}`).join("\n\n");
154569
155412
  ...branch ? {
154570
155413
  branch
154571
155414
  } : {},
155415
+ ...githubRepoFullName ? {
155416
+ githubRepoFullName
155417
+ } : {},
154572
155418
  ...useWorktree === true ? {
154573
155419
  useWorktree: true
154574
155420
  } : {}
@@ -156126,6 +156972,7 @@ ${entry.text}`).join("\n\n");
156126
156972
  resolveCreateAgentSelector,
156127
156973
  resolveCreateCurrentSessionId,
156128
156974
  resolveLocalProjectBranchForCreate,
156975
+ resolveLocalProjectCreateGitContext,
156129
156976
  resolveLocalProjectRefOrThrow,
156130
156977
  resolveOpenedBySessionRelation,
156131
156978
  resolvePromptCandidate,
@@ -156271,11 +157118,11 @@ ${entry.text}`).join("\n\n");
156271
157118
  return null;
156272
157119
  }
156273
157120
  try {
156274
- const stat2 = await jt.stat(absolutePath);
157121
+ const stat2 = await Yt.stat(absolutePath);
156275
157122
  if (!stat2.isFile() || stat2.size > (options?.maxBytes ?? defaultMaxTextFileBytes)) {
156276
157123
  return null;
156277
157124
  }
156278
- const content = await jt.readFile(absolutePath);
157125
+ const content = await Yt.readFile(absolutePath);
156279
157126
  if (content.includes(0)) {
156280
157127
  return null;
156281
157128
  }
@@ -156694,11 +157541,14 @@ ${entry.text}`).join("\n\n");
156694
157541
  logger2.debug(`[${sessionId}] applyAcpSessionRunConfig skipped (agentClient not ready)`);
156695
157542
  return {
156696
157543
  rejectedSelections: [],
156697
- warningSelections: []
157544
+ warningSelections: [],
157545
+ runtimeConfigPatch: null
156698
157546
  };
156699
157547
  }
156700
157548
  const rejectedSelections = [];
156701
157549
  const warningSelections = [];
157550
+ let confirmedLegacyModeId;
157551
+ let confirmedLegacyModelId;
156702
157552
  const agentConfigOptions = agentClient.getConfigOptions?.() ?? [];
156703
157553
  const suppressKnownRunConfigWarnings = isCodexOrClaudeRunConfig(config2);
156704
157554
  const recordRejection = (selection, suppressWarning) => {
@@ -156714,6 +157564,7 @@ ${entry.text}`).join("\n\n");
156714
157564
  if (config2.modeId) {
156715
157565
  try {
156716
157566
  await agentClient.setSessionMode?.(acpSessionId, config2.modeId);
157567
+ confirmedLegacyModeId = config2.modeId;
156717
157568
  } catch (error2) {
156718
157569
  recordRejection(`mode=${JSON.stringify(config2.modeId)}`, suppressKnownRunConfigWarnings && config2.modeId === ACP_PLAN_PERMISSION_MODE_ID);
156719
157570
  logger2.debug(`[${sessionId}] Failed to set ACP mode ${JSON.stringify(config2.modeId)}: ${String(error2)}`);
@@ -156722,6 +157573,7 @@ ${entry.text}`).join("\n\n");
156722
157573
  if (config2.modelId) {
156723
157574
  try {
156724
157575
  await agentClient.unstable_setSessionModel?.(acpSessionId, config2.modelId);
157576
+ confirmedLegacyModelId = config2.modelId;
156725
157577
  } catch (error2) {
156726
157578
  recordRejection(`model=${JSON.stringify(config2.modelId)}`, suppressKnownRunConfigWarnings);
156727
157579
  logger2.debug(`[${sessionId}] Failed to set ACP model ${JSON.stringify(config2.modelId)}: ${String(error2)}`);
@@ -156732,6 +157584,7 @@ ${entry.text}`).join("\n\n");
156732
157584
  if (!config2.modeId && typeof value === "string") {
156733
157585
  try {
156734
157586
  await agentClient.setSessionMode?.(acpSessionId, value);
157587
+ confirmedLegacyModeId = value;
156735
157588
  } catch (error2) {
156736
157589
  logger2.debug(`[${sessionId}] Failed to set ACP mode option ${configId}=${formatAcpConfigValueForLog(configId, value)}: ${String(error2)}`);
156737
157590
  }
@@ -156742,6 +157595,7 @@ ${entry.text}`).join("\n\n");
156742
157595
  if (!config2.modelId && typeof value === "string") {
156743
157596
  try {
156744
157597
  await agentClient.unstable_setSessionModel?.(acpSessionId, value);
157598
+ confirmedLegacyModelId = value;
156745
157599
  } catch (error2) {
156746
157600
  logger2.debug(`[${sessionId}] Failed to set ACP model option ${configId}=${formatAcpConfigValueForLog(configId, value)}: ${String(error2)}`);
156747
157601
  }
@@ -156763,9 +157617,23 @@ ${entry.text}`).join("\n\n");
156763
157617
  }
156764
157618
  }
156765
157619
  logger2.debug(`[${sessionId}] applyAcpSessionRunConfig completed`);
157620
+ const runtimeConfigPatch = getAcpRuntimeConfigPatchFromOptions(acpSessionId, agentClient.getConfigOptions());
157621
+ if (confirmedLegacyModeId) {
157622
+ runtimeConfigPatch.modeId = confirmedLegacyModeId;
157623
+ if (!isSensitiveAcpConfigOptionId(modeConfigId) && agentConfigOptions.some((option2) => option2.id === modeConfigId)) {
157624
+ runtimeConfigPatch.configOptionValues = {
157625
+ ...runtimeConfigPatch.configOptionValues,
157626
+ [modeConfigId]: confirmedLegacyModeId
157627
+ };
157628
+ }
157629
+ }
157630
+ if (confirmedLegacyModelId && !runtimeConfigPatch.modelId) {
157631
+ runtimeConfigPatch.modelId = confirmedLegacyModelId;
157632
+ }
156766
157633
  return {
156767
157634
  rejectedSelections,
156768
- warningSelections
157635
+ warningSelections,
157636
+ runtimeConfigPatch
156769
157637
  };
156770
157638
  }
156771
157639
  function trimmed(value) {
@@ -163709,6 +164577,27 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
163709
164577
  if (value instanceof ArrayBuffer) return Buffer$1.from(new Uint8Array(value));
163710
164578
  return Buffer$1.from(value.buffer, value.byteOffset, value.byteLength);
163711
164579
  };
164580
+ const WEBSOCKET_CLOSE_CODE_NO_STATUS = 1005;
164581
+ const WEBSOCKET_CLOSE_CODE_ABNORMAL = 1006;
164582
+ const isSendableWebSocketCloseCode = (code2) => code2 >= 1e3 && code2 <= 1014 && code2 !== 1004 && code2 !== WEBSOCKET_CLOSE_CODE_NO_STATUS && code2 !== WEBSOCKET_CLOSE_CODE_ABNORMAL || code2 >= 3e3 && code2 <= 4999;
164583
+ const mirrorWebSocketClose = (peer, code2, reason) => {
164584
+ if (peer.readyState === LocalWebSocket.CLOSING || peer.readyState === LocalWebSocket.CLOSED) {
164585
+ return;
164586
+ }
164587
+ if (code2 === WEBSOCKET_CLOSE_CODE_ABNORMAL) {
164588
+ peer.terminate();
164589
+ return;
164590
+ }
164591
+ if (code2 === WEBSOCKET_CLOSE_CODE_NO_STATUS) {
164592
+ peer.close();
164593
+ return;
164594
+ }
164595
+ if (!isSendableWebSocketCloseCode(code2)) {
164596
+ peer.close(1011, "Local preview WebSocket closed with an unsendable status code");
164597
+ return;
164598
+ }
164599
+ peer.close(code2, reason.toString("utf8"));
164600
+ };
163712
164601
  class LocalPreviewProxyManager {
163713
164602
  constructor(deps) {
163714
164603
  this.deps = deps;
@@ -163909,9 +164798,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
163909
164798
  }
163910
164799
  });
163911
164800
  browserSocket.on("close", (code2, reason) => {
163912
- if (localSocket.readyState === LocalWebSocket.OPEN || localSocket.readyState === LocalWebSocket.CONNECTING) {
163913
- localSocket.close(code2, reason.toString("utf8"));
163914
- }
164801
+ mirrorWebSocketClose(localSocket, code2, reason);
163915
164802
  });
163916
164803
  browserSocket.on("error", () => {
163917
164804
  localSocket.terminate();
@@ -163932,12 +164819,13 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
163932
164819
  }
163933
164820
  });
163934
164821
  localSocket.on("close", (code2, reason) => {
163935
- if (browserSocket.readyState === LocalWebSocket.OPEN) {
163936
- browserSocket.close(code2, reason.toString("utf8"));
163937
- }
164822
+ mirrorWebSocketClose(browserSocket, code2, reason);
163938
164823
  });
163939
164824
  localSocket.on("error", (error2) => {
163940
164825
  this.deps.logger.debug(`Local preview WebSocket failed: ${formatErrorMessage(error2)}`);
164826
+ if (localOpen) {
164827
+ return;
164828
+ }
163941
164829
  if (browserSocket.readyState === LocalWebSocket.OPEN) {
163942
164830
  browserSocket.close(1011, "Local preview WebSocket failed");
163943
164831
  }
@@ -166891,7 +167779,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
166891
167779
  hasPromptOutputForTurn: (sessionId, turnId) => this.hasPromptOutputForTurn(sessionId, turnId),
166892
167780
  observePromptOutputForTurn: (sessionId, turnId) => this.observePromptOutputForTurn(sessionId, turnId),
166893
167781
  buildAcpPromptBlocks: async (args2) => await this.buildAcpPromptBlocks(args2),
166894
- applyAcpModeAndModel: async (session2, acpConfig) => await this.applyAcpModeAndModel(session2, acpConfig),
167782
+ applyAcpModeAndModel: async (session2, acpConfig, context2) => await this.applyAcpModeAndModel(session2, acpConfig, context2),
166895
167783
  createAssistantEntryForTurn: async (sessionId, sessionDoc, turnId, modelInfo, userTurnId) => await this.createAssistantEntryForTurn(sessionId, sessionDoc, turnId, modelInfo, userTurnId),
166896
167784
  turnFinalization: {
166897
167785
  finalizeACPState: async (sessionId, turnId) => await this.finalizeACPState(sessionId, turnId),
@@ -167013,7 +167901,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
167013
167901
  onAcpBinaryProgress,
167014
167902
  signal
167015
167903
  }),
167016
- authenticateMachineAcp: async ({ requestId, action, authenticationRequestId, authorizationCode, configId, cliType, agentType, customAcp, runtimeOverrides, env: env2, onProgress }) => await this.authenticateMachineAcpAndResumeSetup({
167904
+ authenticateMachineAcp: async ({ requestId, action, authenticationRequestId, authorizationCode, methodId, configId, cliType, agentType, customAcp, runtimeOverrides, env: env2, onProgress }) => await this.authenticateMachineAcpAndResumeSetup({
167017
167905
  type: "machine/acp-authenticate",
167018
167906
  machineId: this.machineId,
167019
167907
  workspaceId: this.workspaceId,
@@ -167021,6 +167909,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
167021
167909
  action,
167022
167910
  authenticationRequestId,
167023
167911
  authorizationCode,
167912
+ methodId,
167024
167913
  configId,
167025
167914
  cliType,
167026
167915
  agentType,
@@ -167869,12 +168758,22 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
167869
168758
  ];
167870
168759
  });
167871
168760
  }
167872
- async applyAcpModeAndModel(session2, config2) {
167873
- const { warningSelections } = await applyAcpSessionRunConfig({
168761
+ async applyAcpModeAndModel(session2, config2, context2) {
168762
+ const { runtimeConfigPatch, warningSelections } = await applyAcpSessionRunConfig({
167874
168763
  session: session2,
167875
168764
  config: config2,
167876
168765
  logger: this.logger
167877
168766
  });
168767
+ if (runtimeConfigPatch && context2.basedOnUserTurnId) {
168768
+ const basedOnUserTurnId = context2.basedOnUserTurnId;
168769
+ const persistRuntimeConfig = async () => {
168770
+ await this.awaitTurnHistoryGate(session2.sessionId);
168771
+ context2.sessionDoc.applyAcpRuntimeConfigPatch(basedOnUserTurnId, runtimeConfigPatch);
168772
+ };
168773
+ void persistRuntimeConfig().catch((error2) => {
168774
+ this.logger.warn(`[${session2.sessionId}] Failed to persist ACP runtime config: ${formatErrorMessage(error2)}`);
168775
+ });
168776
+ }
167878
168777
  if (warningSelections.length > 0) {
167879
168778
  void this.recordAgentWarning(session2.sessionId, {
167880
168779
  message: `The agent rejected part of the requested run configuration (${warningSelections.join(", ")}) and is using its own values instead. Reasoning effort and fast mode depend on the selected model.`,
@@ -170028,6 +170927,12 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
170028
170927
  persistedNotifications: 0
170029
170928
  };
170030
170929
  try {
170930
+ const runtimeConfigPatch = mergeAcpRuntimeConfigUpdates(group.updates.map((update2) => update2.notification));
170931
+ if (runtimeConfigPatch && group.target.userTurnId) {
170932
+ sessionDoc.applyAcpRuntimeConfigPatch(group.target.userTurnId, runtimeConfigPatch);
170933
+ } else if (runtimeConfigPatch) {
170934
+ this.logger.debug(`[${sessionId}] Ignoring ACP runtime config update without a driving user turn`);
170935
+ }
170031
170936
  await this.appendACPUpdatesToAssistantEntry({
170032
170937
  sessionId,
170033
170938
  sessionDoc,
@@ -173345,10 +174250,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
173345
174250
  if (!meta) {
173346
174251
  return false;
173347
174252
  }
173348
- if (meta.processingUserMsgId) {
173349
- return true;
173350
- }
173351
- return Boolean(meta.latestUserMsgId && meta.latestUserMsgId !== meta.lastHandledUserMsgId);
174253
+ return hasPendingUserTurnActivation(meta);
173352
174254
  }
173353
174255
  async hasActiveGoal(sessionId) {
173354
174256
  const sessionDoc = await this.workspaceDocument.getOrCreateSessionDoc(sessionId);
@@ -184407,11 +185309,16 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
184407
185309
  this.logger.debug(`[agent-config] Machine Flock sync is not complete for workspace ${this.workspaceId} machine ${this.machineId}; skipping builtin agent registration for this attempt`);
184408
185310
  return false;
184409
185311
  }
185312
+ const optedOut = await this.documentManager.getBuiltinAgentOptOuts(this.machineId);
184410
185313
  for (const cliType of cliTypes) {
184411
185314
  const builtinRuntime = getManagedBuiltinRuntimeByAgentType(cliType);
184412
185315
  if (!builtinRuntime) {
184413
185316
  continue;
184414
185317
  }
185318
+ if (optedOut.has(cliType)) {
185319
+ this.logger.debug(`[agent-config] Skipping builtin agent registration for ${cliType} on machine ${this.machineId}; the user removed it on this machine`);
185320
+ continue;
185321
+ }
184415
185322
  const has2 = await this.documentManager.hasAgentConfig("builtin", cliType, this.machineId);
184416
185323
  if (!has2) {
184417
185324
  await this.documentManager.createAgentConfig("builtin", cliType, this.machineId, builtinRuntime.displayName);
@@ -185716,9 +186623,13 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
185716
186623
  const BEL = String.fromCharCode(7);
185717
186624
  const OSC_TITLE_REGEX = new RegExp(`${ESC}\\](?:0|2);([^${BEL}${ESC}]*)(?:${BEL}|${ESC}\\\\)`, "g");
185718
186625
  const TERMINAL_ENV_BLOCKLIST = /* @__PURE__ */ new Set([
186626
+ "ELECTRON_RUN_AS_NODE",
185719
186627
  "LODY_CLI_TOKEN",
186628
+ "LODY_ELECTRON_BOOTSTRAP",
185720
186629
  "LODY_ELECTRON_SESSION_TOKEN",
186630
+ "LODY_GIT_CRED_BROKER_STATE_FILE",
185721
186631
  "LODY_GIT_CRED_BROKER_TOKEN",
186632
+ "LODY_GIT_CRED_BROKER_URL",
185722
186633
  LODY_GIT_CRED_CONTEXT_TOKEN_ENV,
185723
186634
  LODY_MANAGED_GH_TOKEN_SHA256_ENV
185724
186635
  ]);
@@ -189639,12 +190550,12 @@ ${trimmed2}${closing}`;
189639
190550
  }
189640
190551
  const MAX_AUTHOR_REPLY_CHARS = 4e3;
189641
190552
  const entryText = (entry) => (entry?.items ?? []).map((item) => item.text ?? "").filter(Boolean).join("\n").trim();
189642
- const isSessionBusy = (facts) => {
189643
- const type2 = facts.status?.type;
190553
+ const isSessionBusy = (meta) => {
190554
+ const type2 = meta.status?.type;
189644
190555
  if (type2 === "running" || type2 === "initializing" || type2 === "requestPermission") {
189645
190556
  return true;
189646
190557
  }
189647
- return Boolean(facts.latestUserMsgId) && facts.latestUserMsgId !== facts.lastHandledUserMsgId;
190558
+ return hasPendingUserTurnActivation(meta);
189648
190559
  };
189649
190560
  const createReviewAutomation = (options) => {
189650
190561
  const { documentManager, workspaceId, machineId, logger: logger2 } = options;
@@ -196246,7 +197157,7 @@ Shutting down gracefully${reason}...`);
196246
197157
  function requireLib$1() {
196247
197158
  if (hasRequiredLib$1) return lib$1;
196248
197159
  hasRequiredLib$1 = 1;
196249
- const Stream = Zr;
197160
+ const Stream = So;
196250
197161
  class MuteStream2 extends Stream {
196251
197162
  #isTTY = null;
196252
197163
  constructor(opts = {}) {
@@ -205724,7 +206635,7 @@ ${page}${helpTipBottom}${choiceDescription}${error2}${ansiEscapes.cursorHide}`;
205724
206635
  function requireStreams() {
205725
206636
  if (hasRequiredStreams) return streams;
205726
206637
  hasRequiredStreams = 1;
205727
- var Buffer2 = require$$0$6.Buffer, Transform2 = Zr.Transform;
206638
+ var Buffer2 = require$$0$6.Buffer, Transform2 = So.Transform;
205728
206639
  streams = function(iconv2) {
205729
206640
  iconv2.encodeStream = function encodeStream(encoding2, options) {
205730
206641
  return new IconvLiteEncoderStream(iconv2.getEncoder(encoding2, options), options);
@@ -205944,7 +206855,7 @@ ${page}${helpTipBottom}${choiceDescription}${error2}${ansiEscapes.cursorHide}`;
205944
206855
  return length2;
205945
206856
  };
205946
206857
  if (iconv2.supportsStreams) {
205947
- var Readable2 = Zr.Readable;
206858
+ var Readable2 = So.Readable;
205948
206859
  original.ReadableSetEncoding = Readable2.prototype.setEncoding;
205949
206860
  Readable2.prototype.setEncoding = function setEncoding(enc, options) {
205950
206861
  this._readableState.decoder = iconv2.getDecoder(enc, options);
@@ -205965,7 +206876,7 @@ ${page}${helpTipBottom}${choiceDescription}${error2}${ansiEscapes.cursorHide}`;
205965
206876
  Buffer2.prototype.toString = original.BufferToString;
205966
206877
  Buffer2.prototype.write = original.BufferWrite;
205967
206878
  if (iconv2.supportsStreams) {
205968
- var Readable2 = Zr.Readable;
206879
+ var Readable2 = So.Readable;
205969
206880
  Readable2.prototype.setEncoding = original.ReadableSetEncoding;
205970
206881
  delete Readable2.prototype.collect;
205971
206882
  }
@@ -220643,7 +221554,7 @@ ${page}${helpTipBottom}${choiceDescription}${ansiEscapes.cursorHide}`;
220643
221554
  data = createReviewBundleSnapshot(bundle);
220644
221555
  }
220645
221556
  const { injectReviewSnapshot } = await import("./chunks/index-VoI6Ds2-.js");
220646
- const { resolveReviewViewerTemplate } = await import("./chunks/review-viewer-D1hRLw2L.js").then(async (m) => {
221557
+ const { resolveReviewViewerTemplate } = await import("./chunks/review-viewer-Ce9GBF8u.js").then(async (m) => {
220647
221558
  await m.__tla;
220648
221559
  return m;
220649
221560
  });
@@ -239349,12 +240260,18 @@ ${result.stdout ?? ""}`;
239349
240260
  workdir: readOptionalEnv("LODY_MCP_WORKDIR", "LODY_PREVIEW_MCP_WORKDIR") ?? process.cwd(),
239350
240261
  taskToolsEnabled: readOptionalEnv("LODY_MCP_TASK_TOOLS_ENABLED") === "1"
239351
240262
  };
239352
- let sharedOperationStore;
240263
+ const sharedOperationStores = /* @__PURE__ */ new Map();
240264
+ const resolveOperationStorePathForContext = () => getLodyOperationStorePath(getSessionContext().machineId);
239353
240265
  const getSharedOperationStore = () => {
239354
- sharedOperationStore ??= new LodyOperationStore(void 0, void 0, {
239355
- maintenance: false
239356
- });
239357
- return sharedOperationStore;
240266
+ const storePath = resolveOperationStorePathForContext();
240267
+ let store = sharedOperationStores.get(storePath);
240268
+ if (!store) {
240269
+ store = new LodyOperationStore(storePath, void 0, {
240270
+ maintenance: false
240271
+ });
240272
+ sharedOperationStores.set(storePath, store);
240273
+ }
240274
+ return store;
239358
240275
  };
239359
240276
  const withOperationStore = (fn) => runWithOperationStoreBusyRetry(() => fn(getSharedOperationStore()));
239360
240277
  const assertBatchSize = (length2, maximum) => {
@@ -239747,7 +240664,7 @@ ${prompt2}` : prompt2;
239747
240664
  sessionDoc.getDocState()
239748
240665
  ]);
239749
240666
  const activeTurnId = resolveActiveAssistantTurnId(history);
239750
- const queuedTurnCount = docState?.mq?.length ?? (hasPendingDispatchPointer(session2) && !activeTurnId ? 1 : 0);
240667
+ const queuedTurnCount = docState?.mq?.length ?? (hasPendingUserTurnActivation(session2) && !activeTurnId ? 1 : 0);
239751
240668
  return resolveSessionExecutionSnapshot({
239752
240669
  live,
239753
240670
  ...activeTurnId ? {
@@ -239756,7 +240673,6 @@ ${prompt2}` : prompt2;
239756
240673
  queuedTurnCount
239757
240674
  });
239758
240675
  };
239759
- const hasPendingDispatchPointer = (session2) => Boolean(session2.processingUserMsgId || session2.latestUserMsgId && session2.latestUserMsgId !== session2.lastHandledUserMsgId);
239760
240676
  const resolveSessionLiveWorking = (session2, opts) => {
239761
240677
  const viewedField = opts.viewed ? {
239762
240678
  viewed: true
@@ -239783,7 +240699,7 @@ ${prompt2}` : prompt2;
239783
240699
  ...viewedField
239784
240700
  };
239785
240701
  }
239786
- if (hasPendingDispatchPointer(session2)) {
240702
+ if (hasPendingUserTurnActivation(session2)) {
239787
240703
  const dispatchedAtMs = session2.lastMessageAt ?? Date.parse(session2.createdAt);
239788
240704
  if (Number.isFinite(dispatchedAtMs) && opts.nowMs - dispatchedAtMs < MCP_PRE_START_WINDOW_MS) {
239789
240705
  return {
@@ -240351,6 +241267,7 @@ ${prompt2}` : prompt2;
240351
241267
  });
240352
241268
  const localProjects = await readMachineLocalProjects(manager.repo, workspaceId, session2.machineId);
240353
241269
  const localProject = localProjects[project.localProjectId];
241270
+ const githubRepo = resolveProjectGitHubRepo(project);
240354
241271
  return {
240355
241272
  kind: "local",
240356
241273
  projectId: project.localProjectId,
@@ -240360,6 +241277,9 @@ ${prompt2}` : prompt2;
240360
241277
  ...localProject?.rootPath ? {
240361
241278
  rootPath: localProject.rootPath
240362
241279
  } : {},
241280
+ ...githubRepo ? {
241281
+ githubRepo
241282
+ } : {},
240363
241283
  ...project.useWorktree === true || session2.isWorktree === true ? {
240364
241284
  worktree: true
240365
241285
  } : {}