lody 0.88.1 → 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,25 +16,25 @@ 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
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";
@@ -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.1";
4328
+ const version$9 = "0.89.0";
4329
4329
  const type$2 = "module";
4330
4330
  const scripts = {
4331
4331
  "dev": "node dev.mjs",
@@ -11054,6 +11054,20 @@ Requirements:
11054
11054
  status
11055
11055
  };
11056
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
+ }
11057
11071
  const sessionSchema = schema.LoroMap({
11058
11072
  id: schema.String()
11059
11073
  });
@@ -11102,6 +11116,22 @@ Requirements:
11102
11116
  }, {
11103
11117
  required: false
11104
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
+ });
11105
11135
  const sessionDocSchema = schema({
11106
11136
  session: sessionSchema,
11107
11137
  history: schema.LoroList(sessionHistorySchema, (item) => item.id),
@@ -11110,7 +11140,8 @@ Requirements:
11110
11140
  }),
11111
11141
  forkOperation: sessionForkOperationDocSchema,
11112
11142
  preview: sessionPreviewDocSchema,
11113
- externalHistoryCursor: sessionExternalHistoryCursorDocSchema
11143
+ externalHistoryCursor: sessionExternalHistoryCursorDocSchema,
11144
+ acpRuntimeConfig: sessionAcpRuntimeConfigDocSchema
11114
11145
  });
11115
11146
  const resolveActiveAssistantTurnId = (history) => {
11116
11147
  if (!history?.length) {
@@ -11345,7 +11376,7 @@ Requirements:
11345
11376
  command: LocalPathLauncherStringSchema,
11346
11377
  args: array$2(LocalPathLauncherStringSchema).max(64).optional()
11347
11378
  }).strict();
11348
- discriminatedUnion("kind", [
11379
+ const LaunchLocalPathInputSchema = discriminatedUnion("kind", [
11349
11380
  object$1({
11350
11381
  kind: literal$1("url"),
11351
11382
  url: LocalPathLauncherStringSchema,
@@ -11361,6 +11392,12 @@ Requirements:
11361
11392
  label: string$1().trim().min(1).max(80).optional()
11362
11393
  }).strict()
11363
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();
11364
11401
  const CliRuntimePhaseSchema = _enum$1([
11365
11402
  "starting",
11366
11403
  "running",
@@ -12695,6 +12732,7 @@ Requirements:
12695
12732
  ]),
12696
12733
  authenticationRequestId: string$1().trim().min(1).optional(),
12697
12734
  authorizationCode: string$1().trim().min(1).max(4096).optional(),
12735
+ methodId: string$1().trim().min(1).max(256).optional(),
12698
12736
  configId: AgentConfigIdSchema.optional(),
12699
12737
  cliType: AgentConfigCliTypeSchema,
12700
12738
  agentType: string$1().trim().min(1),
@@ -12739,6 +12777,7 @@ Requirements:
12739
12777
  "cancelled",
12740
12778
  "not-running",
12741
12779
  "input-accepted",
12780
+ "method-required",
12742
12781
  "error"
12743
12782
  ]),
12744
12783
  capabilitiesRefreshed: boolean().optional(),
@@ -14598,12 +14637,12 @@ Requirements:
14598
14637
  {
14599
14638
  id: "codebuddy-code",
14600
14639
  name: "Codebuddy Code",
14601
- version: "2.140.0",
14640
+ version: "2.142.0",
14602
14641
  description: "Tencent Cloud's official intelligent coding tool",
14603
14642
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/codebuddy-code.svg",
14604
14643
  distribution: {
14605
14644
  npx: {
14606
- package: "@tencent-ai/codebuddy-code@2.140.0",
14645
+ package: "@tencent-ai/codebuddy-code@2.142.0",
14607
14646
  args: [
14608
14647
  "--acp"
14609
14648
  ]
@@ -14775,48 +14814,48 @@ Requirements:
14775
14814
  {
14776
14815
  id: "devin",
14777
14816
  name: "Devin",
14778
- version: "3000.6.2",
14817
+ version: "3000.6.7",
14779
14818
  description: "Devin CLI coding agent by Cognition",
14780
14819
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/devin.svg",
14781
14820
  distribution: {
14782
14821
  binary: {
14783
14822
  "darwin-aarch64": {
14784
- 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",
14785
14824
  cmd: "./bin/devin",
14786
14825
  args: [
14787
14826
  "acp"
14788
14827
  ]
14789
14828
  },
14790
14829
  "darwin-x86_64": {
14791
- 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",
14792
14831
  cmd: "./bin/devin",
14793
14832
  args: [
14794
14833
  "acp"
14795
14834
  ]
14796
14835
  },
14797
14836
  "linux-aarch64": {
14798
- 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",
14799
14838
  cmd: "./bin/devin",
14800
14839
  args: [
14801
14840
  "acp"
14802
14841
  ]
14803
14842
  },
14804
14843
  "linux-x86_64": {
14805
- 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",
14806
14845
  cmd: "./bin/devin",
14807
14846
  args: [
14808
14847
  "acp"
14809
14848
  ]
14810
14849
  },
14811
14850
  "windows-aarch64": {
14812
- 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",
14813
14852
  cmd: "./bin\\devin.exe",
14814
14853
  args: [
14815
14854
  "acp"
14816
14855
  ]
14817
14856
  },
14818
14857
  "windows-x86_64": {
14819
- 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",
14820
14859
  cmd: "./bin\\devin.exe",
14821
14860
  args: [
14822
14861
  "acp"
@@ -14828,12 +14867,12 @@ Requirements:
14828
14867
  {
14829
14868
  id: "dimcode",
14830
14869
  name: "DimCode",
14831
- version: "0.3.21",
14870
+ version: "0.3.22",
14832
14871
  description: "A coding agent that puts leading models at your command.",
14833
14872
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/dimcode.svg",
14834
14873
  distribution: {
14835
14874
  npx: {
14836
- package: "dimcode@0.3.21",
14875
+ package: "dimcode@0.3.22",
14837
14876
  args: [
14838
14877
  "acp"
14839
14878
  ]
@@ -14843,12 +14882,12 @@ Requirements:
14843
14882
  {
14844
14883
  id: "dirac",
14845
14884
  name: "Dirac",
14846
- version: "0.5.1",
14885
+ version: "0.5.2",
14847
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.",
14848
14887
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/dirac.svg",
14849
14888
  distribution: {
14850
14889
  npx: {
14851
- package: "dirac-cli@0.5.1",
14890
+ package: "dirac-cli@0.5.2",
14852
14891
  args: [
14853
14892
  "--acp"
14854
14893
  ]
@@ -14858,12 +14897,12 @@ Requirements:
14858
14897
  {
14859
14898
  id: "factory-droid",
14860
14899
  name: "Factory Droid",
14861
- version: "0.205.1",
14900
+ version: "0.208.2",
14862
14901
  description: "Factory Droid - AI coding agent powered by Factory AI",
14863
14902
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/factory-droid.svg",
14864
14903
  distribution: {
14865
14904
  npx: {
14866
- package: "droid@0.205.1",
14905
+ package: "droid@0.208.2",
14867
14906
  args: [
14868
14907
  "exec",
14869
14908
  "--output-format",
@@ -14912,12 +14951,12 @@ Requirements:
14912
14951
  {
14913
14952
  id: "github-copilot-cli",
14914
14953
  name: "GitHub Copilot",
14915
- version: "1.0.81",
14954
+ version: "1.0.82",
14916
14955
  description: "GitHub's AI pair programmer",
14917
14956
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/github-copilot-cli.svg",
14918
14957
  distribution: {
14919
14958
  npx: {
14920
- package: "@github/copilot@1.0.81",
14959
+ package: "@github/copilot@1.0.82",
14921
14960
  args: [
14922
14961
  "--acp"
14923
14962
  ]
@@ -14927,12 +14966,12 @@ Requirements:
14927
14966
  {
14928
14967
  id: "glm-acp-agent",
14929
14968
  name: "GLM Agent",
14930
- version: "1.6.1",
14969
+ version: "1.7.0",
14931
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.",
14932
14971
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/glm-acp-agent.svg",
14933
14972
  distribution: {
14934
14973
  npx: {
14935
- package: "glm-acp-agent@1.6.1"
14974
+ package: "glm-acp-agent@1.7.0"
14936
14975
  }
14937
14976
  }
14938
14977
  },
@@ -14957,13 +14996,13 @@ Requirements:
14957
14996
  {
14958
14997
  id: "harn",
14959
14998
  name: "Harn",
14960
- version: "0.10.118",
14999
+ version: "0.10.124",
14961
15000
  description: "Harn runs .harn agent pipelines as a native ACP coding agent over stdio.",
14962
15001
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/harn.svg",
14963
15002
  distribution: {
14964
15003
  binary: {
14965
15004
  "darwin-aarch64": {
14966
- 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",
14967
15006
  cmd: "./harn",
14968
15007
  args: [
14969
15008
  "serve",
@@ -14971,7 +15010,7 @@ Requirements:
14971
15010
  ]
14972
15011
  },
14973
15012
  "darwin-x86_64": {
14974
- 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",
14975
15014
  cmd: "./harn",
14976
15015
  args: [
14977
15016
  "serve",
@@ -14979,7 +15018,7 @@ Requirements:
14979
15018
  ]
14980
15019
  },
14981
15020
  "linux-aarch64": {
14982
- 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",
14983
15022
  cmd: "./harn",
14984
15023
  args: [
14985
15024
  "serve",
@@ -14987,7 +15026,7 @@ Requirements:
14987
15026
  ]
14988
15027
  },
14989
15028
  "linux-x86_64": {
14990
- 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",
14991
15030
  cmd: "./harn",
14992
15031
  args: [
14993
15032
  "serve",
@@ -14995,7 +15034,7 @@ Requirements:
14995
15034
  ]
14996
15035
  },
14997
15036
  "windows-x86_64": {
14998
- 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",
14999
15038
  cmd: "harn.exe",
15000
15039
  args: [
15001
15040
  "serve",
@@ -15026,47 +15065,47 @@ Requirements:
15026
15065
  {
15027
15066
  id: "kilo",
15028
15067
  name: "Kilo",
15029
- version: "7.5.5",
15068
+ version: "7.5.6",
15030
15069
  description: "The open source coding agent",
15031
15070
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/kilo.svg",
15032
15071
  distribution: {
15033
15072
  npx: {
15034
- package: "@kilocode/cli@7.5.5",
15073
+ package: "@kilocode/cli@7.5.6",
15035
15074
  args: [
15036
15075
  "acp"
15037
15076
  ]
15038
15077
  },
15039
15078
  binary: {
15040
15079
  "darwin-aarch64": {
15041
- 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",
15042
15081
  cmd: "./kilo",
15043
15082
  args: [
15044
15083
  "acp"
15045
15084
  ]
15046
15085
  },
15047
15086
  "darwin-x86_64": {
15048
- 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",
15049
15088
  cmd: "./kilo",
15050
15089
  args: [
15051
15090
  "acp"
15052
15091
  ]
15053
15092
  },
15054
15093
  "linux-aarch64": {
15055
- 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",
15056
15095
  cmd: "./kilo",
15057
15096
  args: [
15058
15097
  "acp"
15059
15098
  ]
15060
15099
  },
15061
15100
  "linux-x86_64": {
15062
- 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",
15063
15102
  cmd: "./kilo",
15064
15103
  args: [
15065
15104
  "acp"
15066
15105
  ]
15067
15106
  },
15068
15107
  "windows-x86_64": {
15069
- 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",
15070
15109
  cmd: "./kilo.exe",
15071
15110
  args: [
15072
15111
  "acp"
@@ -15163,7 +15202,7 @@ Requirements:
15163
15202
  {
15164
15203
  id: "opencode",
15165
15204
  name: "OpenCode",
15166
- version: "1.18.23",
15205
+ version: "1.18.25",
15167
15206
  description: "The open source coding agent",
15168
15207
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/opencode.svg",
15169
15208
  distribution: {
@@ -15261,12 +15300,12 @@ Requirements:
15261
15300
  {
15262
15301
  id: "qwen-code",
15263
15302
  name: "Qwen Code",
15264
- version: "0.22.2",
15303
+ version: "0.22.3",
15265
15304
  description: "Alibaba's Qwen coding assistant",
15266
15305
  icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/qwen-code.svg",
15267
15306
  distribution: {
15268
15307
  npx: {
15269
- package: "@qwen-code/qwen-code@0.22.2",
15308
+ package: "@qwen-code/qwen-code@0.22.3",
15270
15309
  args: [
15271
15310
  "--acp",
15272
15311
  "--experimental-skills"
@@ -20647,13 +20686,16 @@ ${tailedOutput}` : null;
20647
20686
  };
20648
20687
  const MACHINE_PROTOCOL_CAPABILITIES = {
20649
20688
  localProjectRemoval: "localProjectRemoval",
20650
- providerSetup: "providerSetup"
20689
+ providerSetup: "providerSetup",
20690
+ acpProtocolAuthentication: "acpProtocolAuthentication"
20651
20691
  };
20652
20692
  const LOCAL_PROJECT_REMOVAL_PROTOCOL_VERSION = 1;
20653
20693
  const PROVIDER_SETUP_PROTOCOL_VERSION = 1;
20694
+ const ACP_PROTOCOL_AUTHENTICATION_VERSION = 1;
20654
20695
  const CURRENT_MACHINE_PROTOCOL_CAPABILITIES = {
20655
20696
  [MACHINE_PROTOCOL_CAPABILITIES.localProjectRemoval]: LOCAL_PROJECT_REMOVAL_PROTOCOL_VERSION,
20656
- [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
20657
20699
  };
20658
20700
  const isLoroRepoDocDeleted = (value) => {
20659
20701
  if (!value || typeof value !== "object") {
@@ -23312,6 +23354,10 @@ ${context2.authorReply.trim()}
23312
23354
  cliType,
23313
23355
  limitId
23314
23356
  ],
23357
+ builtinAgentOptOut: (agentType) => [
23358
+ "builtinAgentOptOut",
23359
+ agentType
23360
+ ],
23315
23361
  sessionLaunchConfig: (sessionId) => [
23316
23362
  "sessionLaunchConfig",
23317
23363
  sessionId
@@ -23404,6 +23450,13 @@ ${context2.authorReply.trim()}
23404
23450
  limitId: key2[2]
23405
23451
  };
23406
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
+ }
23407
23460
  if (key2.length === 2 && key2[0] === "sessionLaunchConfig" && isNonEmptyString$2(key2[1])) {
23408
23461
  const sessionId = key2[1];
23409
23462
  return {
@@ -23452,6 +23505,9 @@ ${context2.authorReply.trim()}
23452
23505
  rateLimit: [
23453
23506
  "rateLimit"
23454
23507
  ],
23508
+ builtinAgentOptOut: [
23509
+ "builtinAgentOptOut"
23510
+ ],
23455
23511
  sessionLaunchConfig: [
23456
23512
  "sessionLaunchConfig"
23457
23513
  ]
@@ -23496,6 +23552,7 @@ ${context2.authorReply.trim()}
23496
23552
  const isMachineFlockProviderSetupRow = (row) => row.key[0] === "providerSetup";
23497
23553
  const isMachineFlockProviderSetupCancellationRow = (row) => row.key[0] === "providerSetupCancellation";
23498
23554
  const isMachineFlockRateLimitRow = (row) => row.key[0] === "rateLimit";
23555
+ const isMachineFlockBuiltinAgentOptOutRow = (row) => row.key[0] === "builtinAgentOptOut";
23499
23556
  const isMachineFlockSessionLaunchConfigRow = (row) => row.key[0] === "sessionLaunchConfig";
23500
23557
  const getMachineFlockRateLimitEntryKey = (cliType, limitId) => `${cliType}::${limitId.trim() || cliType}`;
23501
23558
  function getMachineFlockLocalProjects(rows) {
@@ -23565,8 +23622,11 @@ ${context2.authorReply.trim()}
23565
23622
  const rows = readMachineFlockRowsFromFlock(flock, {
23566
23623
  prefixes: [
23567
23624
  machineFlockKeys.providerSetupCancellation(cancellation.id),
23568
- machineFlockKeys.providerSetup(cancellation.id),
23569
- machineFlockKeys.agentConfig(cancellation.id)
23625
+ machineFlockKeys.providerSetup(cancellation.id)
23626
+ ],
23627
+ families: [
23628
+ "agentConfig",
23629
+ "builtinAgentOptOut"
23570
23630
  ]
23571
23631
  });
23572
23632
  const existingCancellation = getMachineFlockProviderSetupCancellations(rows)[cancellation.id];
@@ -23582,6 +23642,10 @@ ${context2.authorReply.trim()}
23582
23642
  flock.delete(machineFlockKeys.providerSetup(cancellation.id), nowMs2);
23583
23643
  }
23584
23644
  if (config2) {
23645
+ const optOut = planBuiltinAgentOptOutForDeletedConfig(rows, config2, nowMs2);
23646
+ if (optOut) {
23647
+ flock.set(optOut.key, optOut.value, nowMs2);
23648
+ }
23585
23649
  flock.delete(machineFlockKeys.agentConfig(cancellation.id), nowMs2);
23586
23650
  }
23587
23651
  flock.commit();
@@ -23597,6 +23661,101 @@ ${context2.authorReply.trim()}
23597
23661
  }
23598
23662
  return rateLimits;
23599
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
+ }
23600
23759
  function getMachineFlockSessionLaunchConfig(rows, sessionId) {
23601
23760
  const row = rows[serializeMachineFlockKey(machineFlockKeys.sessionLaunchConfig(sessionId))];
23602
23761
  if (!row || !isMachineFlockSessionLaunchConfigRow(row)) {
@@ -23746,6 +23905,13 @@ ${context2.authorReply.trim()}
23746
23905
  key: parsedKey.key,
23747
23906
  value
23748
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
+ }
23749
23915
  case "sessionLaunchConfig": {
23750
23916
  const config2 = normalizeSessionLaunchConfig(value);
23751
23917
  return config2 ? {
@@ -24070,6 +24236,15 @@ ${context2.authorReply.trim()}
24070
24236
  cancelledAt: value.cancelledAt
24071
24237
  };
24072
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
+ };
24073
24248
  const normalizeAgentConfigListSummary = (value) => {
24074
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") {
24075
24250
  return void 0;
@@ -26231,7 +26406,7 @@ ${context2.authorReply.trim()}
26231
26406
  if (hasRequiredCommand$1) return command$1;
26232
26407
  hasRequiredCommand$1 = 1;
26233
26408
  const EventEmitter2 = require$$0$4.EventEmitter;
26234
- const childProcess = LE__default;
26409
+ const childProcess = Gx__default;
26235
26410
  const path2 = path__default;
26236
26411
  const fs2 = fs__default$1;
26237
26412
  const process2 = process$2;
@@ -31173,7 +31348,7 @@ ${originalIndentation}`;
31173
31348
  function requireStream$3() {
31174
31349
  if (hasRequiredStream$3) return stream$3;
31175
31350
  hasRequiredStream$3 = 1;
31176
- stream$3 = Zr;
31351
+ stream$3 = So;
31177
31352
  return stream$3;
31178
31353
  }
31179
31354
  var destroy_1;
@@ -34764,7 +34939,7 @@ ${originalIndentation}`;
34764
34939
  if (hasRequiredReadable$1) return readable$1.exports;
34765
34940
  hasRequiredReadable$1 = 1;
34766
34941
  (function(module2, exports$1) {
34767
- var Stream = Zr;
34942
+ var Stream = So;
34768
34943
  if (process.env.READABLE_STREAM === "disable" && Stream) {
34769
34944
  module2.exports = Stream.Readable;
34770
34945
  Object.assign(module2.exports, Stream);
@@ -37670,7 +37845,7 @@ ${originalIndentation}`;
37670
37845
  const fs2 = fs__default;
37671
37846
  const path2 = path__default$1;
37672
37847
  const asyncSeries = requireSeries();
37673
- const zlib = $s__default;
37848
+ const zlib = Ei__default;
37674
37849
  const { MESSAGE } = requireTripleBeam();
37675
37850
  const { Stream, PassThrough: PassThrough2 } = requireReadable$1();
37676
37851
  const TransportStream = requireWinstonTransport();
@@ -44607,10 +44782,10 @@ ${originalIndentation}`;
44607
44782
  const os2 = os__default$1;
44608
44783
  const path2 = path__default$1;
44609
44784
  const util2 = require$$0$5;
44610
- const zlib = $s__default;
44785
+ const zlib = Ei__default;
44611
44786
  const hash2 = requireObjectHash();
44612
44787
  const MESSAGE = requireTripleBeam().MESSAGE;
44613
- const PassThrough2 = Zr.PassThrough;
44788
+ const PassThrough2 = So.PassThrough;
44614
44789
  const Transport = requireWinstonTransport();
44615
44790
  const loggerDefaults = {
44616
44791
  json: false,
@@ -45062,7 +45237,7 @@ ${value.slice(value.length - safeTailChars)}`;
45062
45237
  return files;
45063
45238
  }
45064
45239
  async function readDailyLogFile(file2) {
45065
- const raw2 = await jt__default.readFile(file2.path);
45240
+ const raw2 = await Yt__default.readFile(file2.path);
45066
45241
  if (!file2.compressed) return raw2.toString("utf8");
45067
45242
  return (await gunzip(raw2)).toString("utf8");
45068
45243
  }
@@ -64977,7 +65152,7 @@ ${peerId}`;
64977
65152
  function requirePermessageDeflate$1() {
64978
65153
  if (hasRequiredPermessageDeflate$1) return permessageDeflate$1;
64979
65154
  hasRequiredPermessageDeflate$1 = 1;
64980
- const zlib = $s__default;
65155
+ const zlib = Ei__default;
64981
65156
  const bufferUtil2 = requireBufferUtil();
64982
65157
  const Limiter = requireLimiter();
64983
65158
  const { kStatusCode } = requireConstants$5();
@@ -65432,7 +65607,7 @@ ${peerId}`;
65432
65607
  function requireReceiver$1() {
65433
65608
  if (hasRequiredReceiver$1) return receiver$1;
65434
65609
  hasRequiredReceiver$1 = 1;
65435
- const { Writable } = Zr;
65610
+ const { Writable } = So;
65436
65611
  const PerMessageDeflate = requirePermessageDeflate$1();
65437
65612
  const { BINARY_TYPES, EMPTY_BUFFER, kStatusCode, kWebSocket } = requireConstants$5();
65438
65613
  const { concat: concat2, toArrayBuffer: toArrayBuffer2, unmask } = requireBufferUtil();
@@ -65799,7 +65974,7 @@ ${peerId}`;
65799
65974
  function requireSender$1() {
65800
65975
  if (hasRequiredSender$1) return sender$1;
65801
65976
  hasRequiredSender$1 = 1;
65802
- const { Duplex } = Zr;
65977
+ const { Duplex } = So;
65803
65978
  const { randomFillSync: randomFillSync2 } = crypto__default;
65804
65979
  const PerMessageDeflate = requirePermessageDeflate$1();
65805
65980
  const { EMPTY_BUFFER, kWebSocket, NOOP } = requireConstants$5();
@@ -66536,7 +66711,7 @@ ${peerId}`;
66536
66711
  const net2 = require$$0$9;
66537
66712
  const tls = require$$4$2;
66538
66713
  const { randomBytes: randomBytes2, createHash: createHash2 } = crypto__default;
66539
- const { Duplex, Readable: Readable2 } = Zr;
66714
+ const { Duplex, Readable: Readable2 } = So;
66540
66715
  const { URL: URL2 } = require$$7$2;
66541
66716
  const PerMessageDeflate = requirePermessageDeflate$1();
66542
66717
  const Receiver = requireReceiver$1();
@@ -67274,7 +67449,7 @@ ${peerId}`;
67274
67449
  if (hasRequiredStream$1) return stream$1;
67275
67450
  hasRequiredStream$1 = 1;
67276
67451
  requireWebsocket$1();
67277
- const { Duplex } = Zr;
67452
+ const { Duplex } = So;
67278
67453
  function emitClose(stream2) {
67279
67454
  stream2.emit("close");
67280
67455
  }
@@ -67425,7 +67600,7 @@ ${peerId}`;
67425
67600
  hasRequiredWebsocketServer = 1;
67426
67601
  const EventEmitter2 = require$$0$7;
67427
67602
  const http$12 = http;
67428
- const { Duplex } = Zr;
67603
+ const { Duplex } = So;
67429
67604
  const { createHash: createHash2 } = crypto__default;
67430
67605
  const extension2 = requireExtension();
67431
67606
  const PerMessageDeflate = requirePermessageDeflate$1();
@@ -83503,6 +83678,14 @@ ${val.stack}`;
83503
83678
  baseDir
83504
83679
  };
83505
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
+ }
83506
83689
  async function readMachineAgentConfigs(repo, workspaceId, machineId) {
83507
83690
  const handle = await repo.openFlockDoc(getMachineFlockDocId(workspaceId, machineId));
83508
83691
  return getMachineFlockAgentConfigs(readMachineFlockRowsFromFlock(handle.flock, {
@@ -83562,10 +83745,7 @@ ${val.stack}`;
83562
83745
  }
83563
83746
  async function upsertMachineAgentConfig(repo, workspaceId, config2, options = {}) {
83564
83747
  const handle = await repo.openFlockDoc(getMachineFlockDocId(workspaceId, config2.machineId));
83565
- const changed = writeMachineFlockRowToFlock(handle.flock, {
83566
- key: machineFlockKeys.agentConfig(config2.id),
83567
- value: config2
83568
- });
83748
+ const changed = writeAgentConfigToFlock(handle.flock, config2);
83569
83749
  if (!changed) {
83570
83750
  await deleteLoroRepoMetaAgentConfigIfPresent(repo, config2.id);
83571
83751
  return;
@@ -83582,7 +83762,7 @@ ${val.stack}`;
83582
83762
  }
83583
83763
  async function deleteMachineAgentConfig(repo, workspaceId, config2, options = {}) {
83584
83764
  const handle = await repo.openFlockDoc(getMachineFlockDocId(workspaceId, config2.machineId));
83585
- const changed = deleteMachineFlockRowFromFlock(handle.flock, machineFlockKeys.agentConfig(config2.id));
83765
+ const changed = deleteAgentConfigFromFlock(handle.flock, config2, getServerNow());
83586
83766
  if (!changed) {
83587
83767
  await deleteLoroRepoMetaAgentConfigIfPresent(repo, config2.id);
83588
83768
  return;
@@ -101750,7 +101930,7 @@ ${value}`;
101750
101930
  return "internal";
101751
101931
  }
101752
101932
  }
101753
- async function withDeadline(operation, options) {
101933
+ async function withDeadline$1(operation, options) {
101754
101934
  const { timeoutMs, signal } = options;
101755
101935
  if (timeoutMs === void 0 && !signal) return operation;
101756
101936
  if (signal?.aborted) options.onAbort();
@@ -102082,7 +102262,7 @@ ${value}`;
102082
102262
  });
102083
102263
  }
102084
102264
  awaitWithDeadline(operation, options, ctx) {
102085
- return withDeadline(operation, {
102265
+ return withDeadline$1(operation, {
102086
102266
  timeoutMs: options?.timeout,
102087
102267
  signal: options?.signal,
102088
102268
  onTimeout: () => {
@@ -104269,6 +104449,9 @@ ${value}`;
104269
104449
  }
104270
104450
  return false;
104271
104451
  }
104452
+ async getBuiltinAgentOptOuts(machineId) {
104453
+ return await readMachineBuiltinAgentOptOuts(this.repo, this.workspaceId, machineId);
104454
+ }
104272
104455
  async getAgentConfigById(agentConfigId, machineId) {
104273
104456
  if (machineId) {
104274
104457
  return (await readMergedAgentConfigById(this.repo, this.workspaceId, machineId, agentConfigId)).config;
@@ -104451,6 +104634,13 @@ ${value}`;
104451
104634
  }
104452
104635
  }
104453
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);
104454
104644
  const EDITING_LEASE_MS = 5 * 60 * 1e3;
104455
104645
  class SessionDocument {
104456
104646
  constructor(repo, sessionId, unloadDocRoom, logger2 = getLogger("loro")) {
@@ -104746,7 +104936,8 @@ ${value}`;
104746
104936
  mq: state2.mq,
104747
104937
  forkOperation: state2.forkOperation,
104748
104938
  preview: state2.preview,
104749
- externalHistoryCursor: state2.externalHistoryCursor
104939
+ externalHistoryCursor: state2.externalHistoryCursor,
104940
+ acpRuntimeConfig: state2.acpRuntimeConfig
104750
104941
  };
104751
104942
  }
104752
104943
  async waitUntilSynced(options = {}) {
@@ -104792,6 +104983,60 @@ ${value}`;
104792
104983
  return prev;
104793
104984
  });
104794
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
+ }
104795
105040
  async markHistoryAsSeen(turnId) {
104796
105041
  if (!this.mirror) {
104797
105042
  throw new Error("SessionDocument not initialized");
@@ -105135,6 +105380,18 @@ ${value}`;
105135
105380
  throw error2;
105136
105381
  }
105137
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
+ }
105138
105395
  summarizeHistoryTailForDiagnostics(history) {
105139
105396
  const last2 = history.length > 0 ? history[history.length - 1] : void 0;
105140
105397
  const lastItems = last2 && Array.isArray(last2.items) ? last2.items : [];
@@ -105802,6 +106059,7 @@ ${value}`;
105802
106059
  ]),
105803
106060
  authenticationRequestId: string$1().trim().min(1).optional(),
105804
106061
  authorizationCodeEnvelope: RpcSecretEnvelopeSchema.optional(),
106062
+ methodId: string$1().trim().min(1).max(256).optional(),
105805
106063
  configId: AgentConfigIdSchema.optional(),
105806
106064
  cliType: AgentConfigCliTypeSchema,
105807
106065
  agentType: string$1().trim().min(1),
@@ -107176,6 +107434,9 @@ ${value}`;
107176
107434
  action: options.action,
107177
107435
  authenticationRequestId,
107178
107436
  authorizationCodeEnvelope,
107437
+ ...options.methodId ? {
107438
+ methodId: options.methodId
107439
+ } : {},
107179
107440
  configId: options.configId,
107180
107441
  cliType: options.cliType,
107181
107442
  agentType: options.agentType,
@@ -108418,6 +108679,7 @@ ${value}`;
108418
108679
  action: request2.params.action,
108419
108680
  authenticationRequestId: request2.params.authenticationRequestId,
108420
108681
  authorizationCode,
108682
+ methodId: request2.params.methodId,
108421
108683
  configId: request2.params.configId,
108422
108684
  cliType: request2.params.cliType,
108423
108685
  agentType: request2.params.agentType,
@@ -109289,6 +109551,9 @@ ${value}`;
109289
109551
  machineFlockKeys.providerSetup(setupId),
109290
109552
  machineFlockKeys.providerSetupCancellation(setupId),
109291
109553
  machineFlockKeys.agentConfig(setupId)
109554
+ ],
109555
+ families: [
109556
+ "builtinAgentOptOut"
109292
109557
  ]
109293
109558
  });
109294
109559
  const cancellation = getMachineFlockProviderSetupCancellations(rows)[setupId];
@@ -109313,6 +109578,10 @@ ${value}`;
109313
109578
  const now2 = getServerNow();
109314
109579
  const flock = handle.flock;
109315
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
+ }
109316
109585
  flock.delete(machineFlockKeys.providerSetup(setupId), now2);
109317
109586
  flock.commit();
109318
109587
  await this.repo.flush();
@@ -109594,20 +109863,20 @@ ${value}`;
109594
109863
  };
109595
109864
  const parsed = DaemonUpgradeIntentSchema.parse(value);
109596
109865
  const dir = path.dirname(DAEMON_UPGRADE_INTENT_FILE);
109597
- await jt.mkdir(dir, {
109866
+ await Yt.mkdir(dir, {
109598
109867
  recursive: true
109599
109868
  });
109600
109869
  const tmpPath = path.join(dir, `.${path.basename(DAEMON_UPGRADE_INTENT_FILE)}.${process.pid}.tmp`);
109601
- await jt.writeFile(tmpPath, `${JSON.stringify(parsed, null, 2)}
109870
+ await Yt.writeFile(tmpPath, `${JSON.stringify(parsed, null, 2)}
109602
109871
  `, {
109603
109872
  encoding: "utf8",
109604
109873
  mode: 384
109605
109874
  });
109606
- await jt.rename(tmpPath, DAEMON_UPGRADE_INTENT_FILE);
109875
+ await Yt.rename(tmpPath, DAEMON_UPGRADE_INTENT_FILE);
109607
109876
  };
109608
109877
  const readDaemonUpgradeIntent = async () => {
109609
109878
  try {
109610
- const raw2 = await jt.readFile(DAEMON_UPGRADE_INTENT_FILE, "utf8");
109879
+ const raw2 = await Yt.readFile(DAEMON_UPGRADE_INTENT_FILE, "utf8");
109611
109880
  const parsed = DaemonUpgradeIntentSchema.safeParse(JSON.parse(raw2));
109612
109881
  return parsed.success ? parsed.data : null;
109613
109882
  } catch {
@@ -109616,7 +109885,7 @@ ${value}`;
109616
109885
  };
109617
109886
  const clearDaemonUpgradeIntent = async () => {
109618
109887
  try {
109619
- await jt.unlink(DAEMON_UPGRADE_INTENT_FILE);
109888
+ await Yt.unlink(DAEMON_UPGRADE_INTENT_FILE);
109620
109889
  } catch {
109621
109890
  }
109622
109891
  };
@@ -111967,6 +112236,80 @@ ${incoming}`).output;
111967
112236
  }
111968
112237
  return void 0;
111969
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
+ };
111970
112313
  var crossSpawn = {
111971
112314
  exports: {}
111972
112315
  };
@@ -113523,12 +113866,6 @@ ${incoming}`).output;
113523
113866
  tier: "A"
113524
113867
  });
113525
113868
  }
113526
- const FILTERED_ACP_CONFIG_OPTION_IDS = /* @__PURE__ */ new Set([
113527
- "agent"
113528
- ]);
113529
- function filterAcpConfigOptions(options) {
113530
- return options.filter((opt) => !FILTERED_ACP_CONFIG_OPTION_IDS.has(opt.id));
113531
- }
113532
113869
  function isSelectGroup$1(item) {
113533
113870
  return typeof item === "object" && item !== null && "group" in item;
113534
113871
  }
@@ -114828,6 +115165,9 @@ ${incoming}`).output;
114828
115165
  return;
114829
115166
  }
114830
115167
  const notification = parseSessionNotification(params);
115168
+ if (notification.update.sessionUpdate === "config_option_update") {
115169
+ this.applyConfigOptionsState(notification.update.configOptions, true);
115170
+ }
114831
115171
  this.handleGoalSessionInfoUpdate(notification);
114832
115172
  this.handleCodexWarningSessionInfoUpdate(notification);
114833
115173
  this.handleAgentSessionTitleUpdate(notification);
@@ -115399,9 +115739,9 @@ ${incoming}`).output;
115399
115739
  return this.acpSessionId !== null && acpSessionId === this.acpSessionId;
115400
115740
  }
115401
115741
  applySessionResponseState(sessionResponse) {
115402
- this.configOptions = filterAcpConfigOptions(sessionResponse.configOptions ?? []);
115403
- this.legacySessionModelState = readLegacySessionModelState(sessionResponse) ?? null;
115404
115742
  this.currentModel = void 0;
115743
+ this.applyConfigOptionsState(sessionResponse.configOptions ?? [], sessionResponse.configOptions !== void 0);
115744
+ this.legacySessionModelState = readLegacySessionModelState(sessionResponse) ?? null;
115405
115745
  const initialModelOption = this.findConfigOptionByCategory("model");
115406
115746
  if (initialModelOption?.type === "select" && typeof initialModelOption.currentValue === "string") {
115407
115747
  this.currentModel = this.resolveModelInfo(initialModelOption.currentValue);
@@ -115409,6 +115749,46 @@ ${incoming}`).output;
115409
115749
  this.currentModel = this.resolveModelInfo(this.legacySessionModelState.currentModelId);
115410
115750
  }
115411
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
+ }
115412
115792
  async startSession(stream2, workdir, resumeSessionId, timeoutOptions = {}, startupAbort, resolveSessionStart, forkSessionId, forkSessionTurnId) {
115413
115793
  const connection2 = new ClientSideConnection(() => this, stream2);
115414
115794
  this.connection = connection2;
@@ -116041,13 +116421,11 @@ ${incoming}`).output;
116041
116421
  }
116042
116422
  return void 0;
116043
116423
  }, this.logger, "setSessionConfigOption", this.options.sessionId);
116044
- if (result?.configOptions) {
116045
- this.configOptions = filterAcpConfigOptions(result.configOptions);
116046
- if (this.currentModel) {
116047
- this.currentModel = this.resolveModelInfo(this.currentModel.modelId);
116048
- }
116424
+ if (result?.configOptions !== void 0) {
116425
+ this.applyConfigOptionsState(result.configOptions, true);
116426
+ } else if (result) {
116427
+ this.retainLegacyConfigOptionValue(configId, value);
116049
116428
  }
116050
- if (result) this.configOptionValues[configId] = value;
116051
116429
  this.logger.debug(`[${this.options.sessionId}] ACP session config option set: ${configId}=${value}`);
116052
116430
  return result?.configOptions;
116053
116431
  }
@@ -117144,7 +117522,7 @@ ${error2.message}` : execaMessage;
117144
117522
  function requireBufferStream() {
117145
117523
  if (hasRequiredBufferStream) return bufferStream;
117146
117524
  hasRequiredBufferStream = 1;
117147
- const { PassThrough: PassThroughStream } = Zr;
117525
+ const { PassThrough: PassThroughStream } = So;
117148
117526
  bufferStream = (options) => {
117149
117527
  options = {
117150
117528
  ...options
@@ -117193,7 +117571,7 @@ ${error2.message}` : execaMessage;
117193
117571
  if (hasRequiredGetStream) return getStream.exports;
117194
117572
  hasRequiredGetStream = 1;
117195
117573
  const { constants: BufferConstants } = require$$0$6;
117196
- const stream2 = Zr;
117574
+ const stream2 = So;
117197
117575
  const { promisify: promisify2 } = require$$0$5;
117198
117576
  const bufferStream2 = requireBufferStream();
117199
117577
  const streamPipelinePromisified = promisify2(stream2.pipeline);
@@ -117253,7 +117631,7 @@ ${error2.message}` : execaMessage;
117253
117631
  function requireMergeStream() {
117254
117632
  if (hasRequiredMergeStream) return mergeStream;
117255
117633
  hasRequiredMergeStream = 1;
117256
- const { PassThrough: PassThrough2 } = Zr;
117634
+ const { PassThrough: PassThrough2 } = So;
117257
117635
  mergeStream = function() {
117258
117636
  var sources = [];
117259
117637
  var output = new PassThrough2({
@@ -118984,7 +119362,7 @@ ${error2.message}` : execaMessage;
118984
119362
  validate: validate2
118985
119363
  });
118986
119364
  };
118987
- const realZlibConstants = $s__default.constants || {
119365
+ const realZlibConstants = Ei__default.constants || {
118988
119366
  ZLIB_VERNUM: 4736
118989
119367
  };
118990
119368
  const constants = Object.freeze(Object.assign(/* @__PURE__ */ Object.create(null), {
@@ -119144,11 +119522,11 @@ ${error2.message}` : execaMessage;
119144
119522
  this.#flushFlag = opts.flush ?? 0;
119145
119523
  this.#finishFlushFlag = opts.finishFlush ?? 0;
119146
119524
  this.#fullFlushFlag = opts.fullFlushFlag ?? 0;
119147
- if (typeof $s[mode2] !== "function") {
119525
+ if (typeof Ei[mode2] !== "function") {
119148
119526
  throw new TypeError("Compression method not supported: " + mode2);
119149
119527
  }
119150
119528
  try {
119151
- this.#handle = new $s[mode2](opts);
119529
+ this.#handle = new Ei[mode2](opts);
119152
119530
  } catch (er) {
119153
119531
  throw new ZlibError(er, this.constructor);
119154
119532
  }
@@ -122163,7 +122541,7 @@ ${error2.message}` : execaMessage;
122163
122541
  return checkCwd(dir, done2);
122164
122542
  }
122165
122543
  if (preserve) {
122166
- return jt__default.mkdir(dir, {
122544
+ return Yt__default.mkdir(dir, {
122167
122545
  mode: mode2,
122168
122546
  recursive: true
122169
122547
  }).then((made) => done2(null, made ?? void 0), done2);
@@ -123413,7 +123791,7 @@ ${error2.message}` : execaMessage;
123413
123791
  hasRequiredFdSlicer = 1;
123414
123792
  var fs2 = fs__default;
123415
123793
  var util2 = require$$0$5;
123416
- var stream2 = Zr;
123794
+ var stream2 = So;
123417
123795
  var Readable2 = stream2.Readable;
123418
123796
  var Writable = stream2.Writable;
123419
123797
  var PassThrough2 = stream2.PassThrough;
@@ -123979,14 +124357,14 @@ ${error2.message}` : execaMessage;
123979
124357
  if (hasRequiredYauzl) return yauzl;
123980
124358
  hasRequiredYauzl = 1;
123981
124359
  var fs2 = fs__default;
123982
- var zlib = $s__default;
124360
+ var zlib = Ei__default;
123983
124361
  var fd_slicer = requireFdSlicer();
123984
124362
  var crc322 = requireBufferCrc32();
123985
124363
  var util2 = require$$0$5;
123986
124364
  var EventEmitter2 = require$$0$7.EventEmitter;
123987
- var Transform2 = Zr.Transform;
123988
- var PassThrough2 = Zr.PassThrough;
123989
- var Writable = Zr.Writable;
124365
+ var Transform2 = So.Transform;
124366
+ var PassThrough2 = So.PassThrough;
124367
+ var Writable = So.Writable;
123990
124368
  yauzl.open = open2;
123991
124369
  yauzl.fromFd = fromFd;
123992
124370
  yauzl.fromBuffer = fromBuffer;
@@ -125417,7 +125795,7 @@ ${error2.message}` : execaMessage;
125417
125795
  }
125418
125796
  const version$7 = "1.6.2";
125419
125797
  const dependencies$1 = {
125420
- "@openai/codex": "^0.148.0"
125798
+ "@openai/codex": "^0.151.0"
125421
125799
  };
125422
125800
  const codexPackageJson = {
125423
125801
  version: version$7,
@@ -125427,99 +125805,99 @@ ${error2.message}` : execaMessage;
125427
125805
  const grokPackageJson = {
125428
125806
  version: version$6
125429
125807
  };
125430
- const version$5 = "2.1.232";
125808
+ const version$5 = "2.1.251";
125431
125809
  const platforms = {
125432
125810
  "darwin-arm64": {
125433
125811
  "binary": "claude",
125434
- "checksum": "7b39c1588df919d001dea3ffd5651adb682f2451b5a0e18d42d4233296b53cc7",
125435
- "size": 306111312
125812
+ "checksum": "625869b01e0050f260b2980fac248fd9cef9e462612bded4ec9d3d49ff8969a5",
125813
+ "size": 197171680
125436
125814
  },
125437
125815
  "darwin-x64": {
125438
125816
  "binary": "claude",
125439
- "checksum": "aa3d606d7bf0ea9739a6d0de11810e72a662e7a4e5061d67ee7f8bc47c8890f9",
125440
- "size": 314779248
125817
+ "checksum": "44221d72a3f35772faa85ad9a36a678084a516f720e64b45e26eb9015315500b",
125818
+ "size": 205778256
125441
125819
  },
125442
125820
  "linux-arm64": {
125443
125821
  "binary": "claude",
125444
- "checksum": "20797ebc644dfc47a69865c46d5cf702c7dbedd48d4268063b8828ebd55b39d0",
125445
- "size": 320133352
125822
+ "checksum": "65445bd4dd042079cc3fa43791b561370a05c8599e8ec47580e25a81050abbdd",
125823
+ "size": 213835016
125446
125824
  },
125447
125825
  "linux-x64": {
125448
125826
  "binary": "claude",
125449
- "checksum": "61d23f8749136907d586d5b11831ea8a5234d4c1dea40a5e55c33b52e204c6d1",
125450
- "size": 323021104
125827
+ "checksum": "fd5f10ff0eb58daec04900466b143ea98aab50abf208a422bc008eaec13f61f7",
125828
+ "size": 214326616
125451
125829
  },
125452
125830
  "linux-arm64-musl": {
125453
125831
  "binary": "claude",
125454
- "checksum": "bf6481aa98b84d3e51460f7cf07fe54cb8d116882b72cee7bff941a2776ac91e",
125455
- "size": 313278016
125832
+ "checksum": "165f6236abf5b0c42892b164c2299c82023421805e0c3eaddf925a3195513f84",
125833
+ "size": 206648896
125456
125834
  },
125457
125835
  "linux-x64-musl": {
125458
125836
  "binary": "claude",
125459
- "checksum": "93c8a9ef90adfa5bb8a34dfd5f32fc4e820532ca1e1ec5e6bb2049a5069a03b4",
125460
- "size": 317165312
125837
+ "checksum": "5056970c13f46dd2bff2c44dd2a7f766553a63392615412d5711278264730e07",
125838
+ "size": 208301944
125461
125839
  },
125462
125840
  "win32-x64": {
125463
125841
  "binary": "claude.exe",
125464
- "checksum": "ec9e32479bc887809003c91384c6c3a26e7691856d1916f72f6f6d21800f3bd6",
125465
- "size": 319026336
125842
+ "checksum": "8d1229a281281b98fd2dee72b3253a704be4fce4d45207200cd32a9bb5a6c909",
125843
+ "size": 217360032
125466
125844
  },
125467
125845
  "win32-arm64": {
125468
125846
  "binary": "claude.exe",
125469
- "checksum": "301bfd5a624d6280d4d4e4ba7523fafdfa439a33e9530478719eeb6efec51d52",
125470
- "size": 306950304
125847
+ "checksum": "89e91fed2dc6f6278fa1e179e6401c0a1c252fe80c57ee47f17f10f7f7b4e99c",
125848
+ "size": 208465056
125471
125849
  }
125472
125850
  };
125473
125851
  const claudeSdkManifestJson = {
125474
125852
  version: version$5,
125475
125853
  platforms
125476
125854
  };
125477
- const version$4 = "0.3.232";
125855
+ const version$4 = "0.3.251";
125478
125856
  const claudeSdkPackageJson = {
125479
125857
  version: version$4
125480
125858
  };
125481
- const sdkVersion = "0.3.232";
125482
- const version$3 = "2.1.232";
125859
+ const sdkVersion = "0.3.251";
125860
+ const version$3 = "2.1.251";
125483
125861
  const artifacts$1 = {
125484
125862
  "darwin-arm64": {
125485
- "fileName": "anthropic-ai-claude-agent-sdk-darwin-arm64-0.3.232.tar.zst",
125486
- "sha256": "09c775adf243d27a5c13e6724b3960409612b0da483c38fa108a1c03be515a5a",
125487
- "size": 70030420
125863
+ "fileName": "anthropic-ai-claude-agent-sdk-darwin-arm64-0.3.251.tar.zst",
125864
+ "sha256": "536a3755844d168b87250af3ee6e3dd103391305514f28abe564f91a5aa856ee",
125865
+ "size": 71945899
125488
125866
  },
125489
125867
  "darwin-x64": {
125490
- "fileName": "anthropic-ai-claude-agent-sdk-darwin-x64-0.3.232.tar.zst",
125491
- "sha256": "68f687528e5d610e14a379ff7ad1e6a60aa7d600b4dc20dc31b4af96fffda570",
125492
- "size": 74349877
125868
+ "fileName": "anthropic-ai-claude-agent-sdk-darwin-x64-0.3.251.tar.zst",
125869
+ "sha256": "68e88be76d4399d1dea054d9dbbf7106c393578fa1fa5714c9a8890b6ff3213c",
125870
+ "size": 75692035
125493
125871
  },
125494
125872
  "linux-arm64": {
125495
- "fileName": "anthropic-ai-claude-agent-sdk-linux-arm64-0.3.232.tar.zst",
125496
- "sha256": "8c7c75910f5d29c3cf3fe15e4c17abfb05db616db2838b3a764f6b243ad78165",
125497
- "size": 79104443
125873
+ "fileName": "anthropic-ai-claude-agent-sdk-linux-arm64-0.3.251.tar.zst",
125874
+ "sha256": "92e61ffb31b8beae919beb6a9458f4a376067bf25d4df7e5c8fe29b84ed1edaa",
125875
+ "size": 81951594
125498
125876
  },
125499
125877
  "linux-x64": {
125500
- "fileName": "anthropic-ai-claude-agent-sdk-linux-x64-0.3.232.tar.zst",
125501
- "sha256": "e0303ad6167b82fad98a80dd6dc3fd23d82562de5181094775c388118951d999",
125502
- "size": 79732583
125878
+ "fileName": "anthropic-ai-claude-agent-sdk-linux-x64-0.3.251.tar.zst",
125879
+ "sha256": "9e51358bb06885a29c0cdcaff6ffbbed47718e3210b8e92ae074802440a46dd3",
125880
+ "size": 81994218
125503
125881
  },
125504
125882
  "linux-arm64-musl": {
125505
- "fileName": "anthropic-ai-claude-agent-sdk-linux-arm64-musl-0.3.232.tar.zst",
125506
- "sha256": "b0dd9da5095baf314160e3a3f6ac1c85a1ef4b4e326c4bde662f92fe8783840b",
125507
- "size": 77411461
125883
+ "fileName": "anthropic-ai-claude-agent-sdk-linux-arm64-musl-0.3.251.tar.zst",
125884
+ "sha256": "bfad7556c20b01776c2205898c7f76a31448e42b7c2e7254476d25aac9c0d84c",
125885
+ "size": 80166022
125508
125886
  },
125509
125887
  "linux-x64-musl": {
125510
- "fileName": "anthropic-ai-claude-agent-sdk-linux-x64-musl-0.3.232.tar.zst",
125511
- "sha256": "989e8148bb5944d038f4ea11595742084ec3b38837e08e5af25229ada27c3730",
125512
- "size": 77995010
125888
+ "fileName": "anthropic-ai-claude-agent-sdk-linux-x64-musl-0.3.251.tar.zst",
125889
+ "sha256": "143efe291c6cd6501681fff2930c58c9eeeef5f924dded6b340e84a9e069e1d1",
125890
+ "size": 80324347
125513
125891
  },
125514
125892
  "win32-arm64": {
125515
- "fileName": "anthropic-ai-claude-agent-sdk-win32-arm64-0.3.232.tar.zst",
125516
- "sha256": "7cc4f6f2a23fa43993da830e00e3e2ca46b90864a2d38e1f3678f70de9e2f440",
125517
- "size": 78979373
125893
+ "fileName": "anthropic-ai-claude-agent-sdk-win32-arm64-0.3.251.tar.zst",
125894
+ "sha256": "0d70dd262d40b39fe354e3b7c0e5a1b3a4895beef2692509a3830511ff184023",
125895
+ "size": 81916953
125518
125896
  },
125519
125897
  "win32-x64": {
125520
- "fileName": "anthropic-ai-claude-agent-sdk-win32-x64-0.3.232.tar.zst",
125521
- "sha256": "ed09d440d4cf7881439850287485d3198384538c79d8d3e5f0740b1e40b10db3",
125522
- "size": 82535283
125898
+ "fileName": "anthropic-ai-claude-agent-sdk-win32-x64-0.3.251.tar.zst",
125899
+ "sha256": "db8bcee96e0f0bc42b01977c1897977c204d5cee07464656ec49fa44d31014aa",
125900
+ "size": 84974808
125523
125901
  }
125524
125902
  };
125525
125903
  const claudeRuntimeManifestJson = {
@@ -125527,49 +125905,49 @@ ${error2.message}` : execaMessage;
125527
125905
  version: version$3,
125528
125906
  artifacts: artifacts$1
125529
125907
  };
125530
- const version$2 = "0.148.0";
125908
+ const version$2 = "0.151.0";
125531
125909
  const artifacts = {
125532
125910
  "darwin-arm64": {
125533
125911
  "fileName": "codex-package-aarch64-apple-darwin.tar.zst",
125534
- "sha256": "dba92ada12f223751f30a9535c81c6a3ac6a2c1b2469d628c92b3e6be38eff66",
125535
- "size": 76351891
125912
+ "sha256": "c7414e579bb36eba0c8f6cb45fe0ce4cd2724deeb0c3ec3a08c1babfb59ec6e6",
125913
+ "size": 84213361
125536
125914
  },
125537
125915
  "darwin-x64": {
125538
125916
  "fileName": "codex-package-x86_64-apple-darwin.tar.zst",
125539
- "sha256": "ea8a14bca1cfc5a80d2a90e532617cc3c089cb69d2a114a61db645de6d051916",
125540
- "size": 83818234
125917
+ "sha256": "41cd66b0ba1279213d2d1e17fef0fc30421e524406cb5954d84d568688c8b118",
125918
+ "size": 92568101
125541
125919
  },
125542
125920
  "linux-arm64": {
125543
125921
  "fileName": "codex-package-aarch64-unknown-linux-musl.tar.zst",
125544
- "sha256": "084e6261fd68bd2a869f319375a022b2294d7d0f4044cbb113b8fa0755b01af9",
125545
- "size": 79728248
125922
+ "sha256": "3ae57da8bc5f8fd065f0352cc14cb10e02be779186bdac989ad0e2622d8cacbb",
125923
+ "size": 89411447
125546
125924
  },
125547
125925
  "linux-x64": {
125548
125926
  "fileName": "codex-package-x86_64-unknown-linux-musl.tar.zst",
125549
- "sha256": "257701de0d625d46e0e1c0c69db1a8a3fc1265c646a190e9fb965d1f66d54cd2",
125550
- "size": 85609844
125927
+ "sha256": "e2dbacd77547f2d3afb3b1864f92926d936c12d8b822bbac98a766d943656494",
125928
+ "size": 95540316
125551
125929
  },
125552
125930
  "win32-arm64": {
125553
125931
  "fileName": "codex-package-aarch64-pc-windows-msvc.tar.zst",
125554
- "sha256": "e043d518a6ad64271616bf4408737672e2e48b5ce472d2f0a69149434ad0d189",
125555
- "size": 87165328
125932
+ "sha256": "bfd73f646fe3c3335049617e35a85e04ecf42609fc591e2b4a246e312fd41cfd",
125933
+ "size": 98552597
125556
125934
  },
125557
125935
  "win32-x64": {
125558
125936
  "fileName": "codex-package-x86_64-pc-windows-msvc.tar.zst",
125559
- "sha256": "a9fc1afe438a326aa25b11c31ec7586c176f3713d7ee2a0bfd17b869283bd6ff",
125560
- "size": 93722309
125937
+ "sha256": "02338bb9b9c9d991fed3d0446cfcb4d54ce9a271e70097e9f4c1e099ba304f3c",
125938
+ "size": 106201360
125561
125939
  }
125562
125940
  };
125563
125941
  const codexRuntimeManifestJson = {
125564
125942
  version: version$2,
125565
125943
  artifacts
125566
125944
  };
125567
- const version$1 = "0.37.0-lody.753c83056944";
125945
+ const version$1 = "0.39.1-lody.f255222661c9";
125568
125946
  const minNodeVersion = "22.19.0";
125569
125947
  const artifact = {
125570
- "fileName": "lody-kimi-code-0.37.0-lody.753c83056944-037255b0bcbb3afe.tar.zst",
125571
- "sha256": "037255b0bcbb3afe2ce0456b8a9fa419b18ada24f8d90049696efe11d311b00b",
125572
- "size": 3253568,
125948
+ "fileName": "lody-kimi-code-0.39.1-lody.f255222661c9-a4bfb622023ceaf2.tar.zst",
125949
+ "sha256": "a4bfb622023ceaf249faecf8da8508ee400af242de2d4590b72d64e95a0bbbb8",
125950
+ "size": 3335953,
125573
125951
  "compression": "zstd",
125574
125952
  "cmd": "package/dist/main.mjs"
125575
125953
  };
@@ -125789,57 +126167,57 @@ ${error2.message}` : execaMessage;
125789
126167
  platforms: {
125790
126168
  "darwin-arm64": {
125791
126169
  fileName: `xai-official-grok-darwin-arm64-${GROK_BUILD_RUNTIME_VERSION}.tar.zst`,
125792
- sha256: "63aa0a0a95e7a555a372f1a501dcf59151376d7e4d900e24e1c591ff6cc8f818",
125793
- size: 46222120,
126170
+ sha256: "82ffbd254fb76ae5e6be651342e902184a024f78bbe1cf6c8f48854d9f9b1594",
126171
+ size: 46850248,
125794
126172
  compression: "zstd",
125795
126173
  cmd: "grok",
125796
- executableSha256: "13c7f4f0b9abb00bf38216302ea4bab31f03e13555e3576620eca1de572a8d21",
125797
- executableSize: 131817232
126174
+ executableSha256: "8669e0fdadceec25b8c159c355f427ffbd82583525d774b6ab1522197ea83b80",
126175
+ executableSize: 133486016
125798
126176
  },
125799
126177
  "darwin-x64": {
125800
126178
  fileName: `xai-official-grok-darwin-x64-${GROK_BUILD_RUNTIME_VERSION}.tar.zst`,
125801
- sha256: "7bf0af43ba1f3dc8e860e7f887b75966ece7bb6102cc7a3b2fb5af275f757c8a",
125802
- size: 50590131,
126179
+ sha256: "4f48fbc4280a033da3e763e4c19585014917677d9e5c4c8405d2f80f9d21ed7a",
126180
+ size: 51374009,
125803
126181
  compression: "zstd",
125804
126182
  cmd: "grok",
125805
- executableSha256: "a82210a961deac9f0cb72ec6c334196abf76a587be4593bc59db2deab85ee6dc",
125806
- executableSize: 147358e3
126183
+ executableSha256: "8eacec87f5ecdb9259c6d812d12ce9e2d405b1526e36ae9d7fc81ec31dbd74d6",
126184
+ executableSize: 149694528
125807
126185
  },
125808
126186
  "linux-arm64": {
125809
126187
  fileName: `xai-official-grok-linux-arm64-${GROK_BUILD_RUNTIME_VERSION}.tar.zst`,
125810
- sha256: "c888d404ad218caa251cbdbbd0da5836c807957be5a83fd8ab21b69de93469d9",
125811
- size: 49704069,
126188
+ sha256: "676d6795d6e558adb9749f002d9dadc950acc2c5effee839cb9e1f47f8480b03",
126189
+ size: 50397485,
125812
126190
  compression: "zstd",
125813
126191
  cmd: "grok",
125814
- executableSha256: "bb7c51116564a2219f6a49850815060f416918ac407f1f2ba82c53c0b0d4383f",
125815
- executableSize: 133745832
126192
+ executableSha256: "b926fc5308374396e260e7efbd6107231a8dae13c084ddaf0fe89b7ebb3edd25",
126193
+ executableSize: 135641288
125816
126194
  },
125817
126195
  "linux-x64": {
125818
126196
  fileName: `xai-official-grok-linux-x64-${GROK_BUILD_RUNTIME_VERSION}.tar.zst`,
125819
- sha256: "7d0bb4309e634e0ecb63403f35fa468120f5ecf2173feb6518371be1633ecd99",
125820
- size: 53264623,
126197
+ sha256: "358061308ca5c06832d62c079644f51ef355d820d94a9ca11513c09fb4160049",
126198
+ size: 54001005,
125821
126199
  compression: "zstd",
125822
126200
  cmd: "grok",
125823
- executableSha256: "28dbc967a5843dae2374b6834dadbab95354e685c7e5c8dc750b92a4e5fc7c3e",
125824
- executableSize: 163676672
126201
+ executableSha256: "edf79521581bb5e6b95abef848491a6a742e860da3e237ebe86a280d30dce4c1",
126202
+ executableSize: 166079904
125825
126203
  },
125826
126204
  "win32-arm64": {
125827
126205
  fileName: `xai-official-grok-win32-arm64-${GROK_BUILD_RUNTIME_VERSION}.tar.zst`,
125828
- sha256: "c821de276cb1fa835567bd6c5589709e6ba29182d6b0c9ad7c160cc3df91145c",
125829
- size: 45241480,
126206
+ sha256: "243aaca666d4375980905c30b5a33e5b0c9a82e9e2c9bc3fd5b6cdf47819e9ad",
126207
+ size: 45479753,
125830
126208
  compression: "zstd",
125831
126209
  cmd: "grok.exe",
125832
- executableSha256: "9d41447b6eee77cfb7359b7f50935ae64b4e7b7e7ef56c40e6d203f5660317e1",
125833
- executableSize: 121471488
126210
+ executableSha256: "7325ad53988f9c5ca2a35e79b83280441e64d132a9046a947fd14ebb22f48db0",
126211
+ executableSize: 121991168
125834
126212
  },
125835
126213
  "win32-x64": {
125836
126214
  fileName: `xai-official-grok-win32-x64-${GROK_BUILD_RUNTIME_VERSION}.tar.zst`,
125837
- sha256: "5d66d3e0c1e54b050c76b77dfc1dadefbf3e909459a31b4361d8307a671c179c",
125838
- size: 48124303,
126215
+ sha256: "e5a50bceb2caba7bef83ef7581b50c4f4db480174a2ed44c4785f77dd9520214",
126216
+ size: 48377036,
125839
126217
  compression: "zstd",
125840
126218
  cmd: "grok.exe",
125841
- executableSha256: "d546dbc995c2ce9ba97c044d6af6b53f8c11c414a6355bf006802d07c572f406",
125842
- executableSize: 139903488
126219
+ executableSha256: "6caf906d6ef968004b5ff33422c84e33d51a1cd7b4ee5acd19ff695aaa92672e",
126220
+ executableSize: 140801024
125843
126221
  }
125844
126222
  }
125845
126223
  }
@@ -128755,12 +129133,17 @@ ${fallbackStderrTail}` : errorMessage2;
128755
129133
  }
128756
129134
  return hasDomain(url.hostname, "kimi.com") && url.pathname.startsWith("/code/authorize_device");
128757
129135
  }
128758
- 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) {
128759
129142
  for (const match5 of output.matchAll(AUTHORIZATION_URL_PATTERN)) {
128760
129143
  const candidate = match5[0].replace(/[),.;]+$/u, "");
128761
129144
  try {
128762
129145
  const url = new URL(candidate);
128763
- if (isTrustedAuthorizationUrl(agentType, url)) return url;
129146
+ if (isAuthorizationUrl(url)) return url;
128764
129147
  } catch {
128765
129148
  }
128766
129149
  }
@@ -128773,8 +129156,8 @@ ${fallbackStderrTail}` : errorMessage2;
128773
129156
  if (minutes2) return Number.parseInt(minutes2, 10) * 60;
128774
129157
  return void 0;
128775
129158
  }
128776
- function parseAuthorization(agentType, output) {
128777
- const authorizationUrl = findAuthorizationUrl(agentType, output);
129159
+ function parseAuthorization(isAuthorizationUrl, acceptsAuthorizationCode, output) {
129160
+ const authorizationUrl = findAuthorizationUrl(isAuthorizationUrl, output);
128778
129161
  if (!authorizationUrl) return void 0;
128779
129162
  const userCode = authorizationUrl.searchParams.get("user_code") ?? DEVICE_USER_CODE_PATTERN.exec(output)?.[0];
128780
129163
  const expiresInSeconds = parseExpiresInSeconds(output);
@@ -128783,7 +129166,7 @@ ${fallbackStderrTail}` : errorMessage2;
128783
129166
  ...userCode ? {
128784
129167
  userCode
128785
129168
  } : {},
128786
- ...agentType === "claude" ? {
129169
+ ...acceptsAuthorizationCode ? {
128787
129170
  acceptsAuthorizationCode: true
128788
129171
  } : {},
128789
129172
  ...expiresInSeconds !== void 0 ? {
@@ -128791,15 +129174,16 @@ ${fallbackStderrTail}` : errorMessage2;
128791
129174
  } : {}
128792
129175
  };
128793
129176
  }
128794
- class BuiltinAuthenticationOutputParser {
128795
- constructor(agentType) {
128796
- this.agentType = agentType;
129177
+ class AuthorizationOutputParser {
129178
+ constructor(isAuthorizationUrl, acceptsAuthorizationCode) {
129179
+ this.isAuthorizationUrl = isAuthorizationUrl;
129180
+ this.acceptsAuthorizationCode = acceptsAuthorizationCode;
128797
129181
  }
128798
129182
  output = "";
128799
129183
  lastAuthorization = "";
128800
129184
  push(chunk) {
128801
129185
  this.output = `${this.output}${stripVTControlCharacters(chunk)}`.slice(-32768);
128802
- const authorization = parseAuthorization(this.agentType, this.output);
129186
+ const authorization = parseAuthorization(this.isAuthorizationUrl, this.acceptsAuthorizationCode, this.output);
128803
129187
  if (!authorization) return void 0;
128804
129188
  const fingerprint = JSON.stringify(authorization);
128805
129189
  if (fingerprint === this.lastAuthorization) return void 0;
@@ -128807,6 +129191,227 @@ ${fallbackStderrTail}` : errorMessage2;
128807
129191
  return authorization;
128808
129192
  }
128809
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
+ }
128810
129415
  const DEFAULT_AUTHENTICATION_TIMEOUT_MS = 285e3;
128811
129416
  const DEFAULT_TERMINATION_GRACE_MS$1 = 3e3;
128812
129417
  const DEFAULT_STATUS_PROBE_TIMEOUT_MS = 15e3;
@@ -128995,15 +129600,8 @@ ${fallbackStderrTail}` : errorMessage2;
128995
129600
  spawnProcess;
128996
129601
  resolveLoginShellEnv;
128997
129602
  async authenticate(options) {
128998
- if (options.cliType !== "builtin" || !isManagedBuiltinAgentType(options.agentType)) {
128999
- return {
129000
- success: false,
129001
- disposition: "error",
129002
- error: `Authentication is not supported for ${options.agentType}`
129003
- };
129004
- }
129005
- const displayName = getBuiltinDisplayName(options.agentType);
129006
- const agentType = options.agentType;
129603
+ const managedBuiltinAgentType = options.cliType === "builtin" && isManagedBuiltinAgentType(options.agentType) ? options.agentType : null;
129604
+ const displayName = managedBuiltinAgentType ? getBuiltinDisplayName(managedBuiltinAgentType) : options.agentType;
129007
129605
  if (this.runningByAgentType.has(options.agentType)) {
129008
129606
  return {
129009
129607
  success: false,
@@ -129017,7 +129615,8 @@ ${fallbackStderrTail}` : errorMessage2;
129017
129615
  timedOut: false,
129018
129616
  terminating: false,
129019
129617
  acceptsAuthorizationCode: false,
129020
- authorizationCodeSubmitted: false
129618
+ authorizationCodeSubmitted: false,
129619
+ abort: new AbortController()
129021
129620
  };
129022
129621
  this.runningByAgentType.set(options.agentType, running2);
129023
129622
  let timeoutHandle;
@@ -129055,99 +129654,18 @@ ${fallbackStderrTail}` : errorMessage2;
129055
129654
  }, this.authenticationTimeoutMs);
129056
129655
  timeoutHandle.unref?.();
129057
129656
  try {
129058
- const launch = await resolveBuiltinAuthenticationProcessLaunch({
129059
- cliType: options.cliType,
129060
- agentType: options.agentType,
129061
- runtimeOverrides: options.runtimeOverrides,
129062
- action: "login"
129063
- });
129064
- if (!launch) {
129065
- throw new Error(`${displayName} authentication is unavailable`);
129066
- }
129067
- const launchInterruption = interruptedResult();
129068
- if (launchInterruption) return launchInterruption;
129069
- const env2 = await buildAuthenticationProcessEnv({
129070
- launch,
129071
- agentType: options.agentType,
129072
- env: options.env,
129073
- resolveLoginShellEnv: this.resolveLoginShellEnv
129074
- });
129075
- const preparationInterruption = interruptedResult();
129076
- if (preparationInterruption) return preparationInterruption;
129077
- options.onProgress?.({
129078
- status: "starting"
129079
- });
129080
- const child = this.spawnProcess(launch.command, launch.args, {
129081
- cwd: os__default$1.homedir(),
129082
- env: env2,
129083
- stdio: [
129084
- "pipe",
129085
- "pipe",
129086
- "pipe"
129087
- ],
129088
- detached: process.platform !== "win32",
129089
- windowsHide: true
129090
- });
129091
- running2.child = child;
129092
- child.stdin?.on("error", (error2) => {
129093
- this.logger.debug(`[acp-auth] ${displayName} authorization input failed: ${formatErrorMessage(error2)}`);
129094
- });
129095
- const outputParser = new BuiltinAuthenticationOutputParser(agentType);
129096
- const emitOutput = (stream2, chunk) => {
129097
- const output = String(chunk);
129098
- if (output.length === 0) return;
129099
- const authorization = outputParser.push(output);
129100
- if (authorization) {
129101
- running2.acceptsAuthorizationCode = authorization.acceptsAuthorizationCode === true;
129102
- options.onProgress?.({
129103
- status: "authorization",
129104
- ...authorization
129105
- });
129106
- }
129107
- options.onProgress?.({
129108
- status: "output",
129109
- stream: stream2,
129110
- output: output.slice(0, 16384)
129111
- });
129112
- };
129113
- child.stdout?.on("data", (chunk) => emitOutput("stdout", chunk));
129114
- child.stderr?.on("data", (chunk) => emitOutput("stderr", chunk));
129115
- const exit2 = await new Promise((resolve2) => {
129116
- let settled = false;
129117
- const finish = (result) => {
129118
- if (settled) return;
129119
- settled = true;
129120
- resolve2(result);
129121
- };
129122
- child.once("error", (error2) => finish({
129123
- code: null,
129124
- error: error2
129125
- }));
129126
- child.once("exit", (code2) => finish({
129127
- code: code2
129128
- }));
129129
- });
129130
- const processInterruption = interruptedResult();
129131
- if (processInterruption) return processInterruption;
129132
- if (exit2.error !== void 0 || exit2.code !== 0) {
129133
- const error2 = exit2.error !== void 0 ? formatErrorMessage(exit2.error) : formatAuthenticationExitError(agentType, displayName, exit2.code);
129134
- options.onProgress?.({
129135
- status: "error",
129136
- error: error2
129137
- });
129138
- return {
129139
- success: false,
129140
- disposition: "error",
129141
- error: error2
129142
- };
129143
- }
129144
- options.onProgress?.({
129145
- status: "authenticated"
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
129146
129667
  });
129147
- return {
129148
- success: true,
129149
- disposition: "authenticated"
129150
- };
129668
+ return result;
129151
129669
  } catch (error2) {
129152
129670
  const interruption2 = interruptedResult();
129153
129671
  if (interruption2) return interruption2;
@@ -129170,6 +129688,241 @@ ${fallbackStderrTail}` : errorMessage2;
129170
129688
  }
129171
129689
  }
129172
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
+ }
129173
129926
  cancel(agentType, requestId) {
129174
129927
  const running2 = this.runningByAgentType.get(agentType);
129175
129928
  if (!running2 || running2.requestId !== requestId) {
@@ -129244,6 +129997,7 @@ ${fallbackStderrTail}` : errorMessage2;
129244
129997
  }
129245
129998
  }
129246
129999
  terminateAuthentication(agentType, running2, reason) {
130000
+ running2.abort.abort();
129247
130001
  if (running2.terminating || !running2.child) return;
129248
130002
  running2.terminating = true;
129249
130003
  void shutdownLocalAcpAgent({
@@ -133184,18 +133938,13 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
133184
133938
  await withAbortSignal(sleep2(retryDelayMs), options.signal);
133185
133939
  }
133186
133940
  }
133187
- function getPendingUserTurnActivationId(meta) {
133188
- const missingUserTurnId = meta.lastMissingHistoryUserMsgId;
133189
- if (typeof meta.processingUserMsgId === "string" && meta.processingUserMsgId.length > 0 && meta.processingUserMsgId !== missingUserTurnId) {
133190
- return meta.processingUserMsgId;
133191
- }
133192
- if (typeof meta.latestUserMsgId === "string" && meta.latestUserMsgId.length > 0 && meta.latestUserMsgId !== meta.lastHandledUserMsgId && meta.latestUserMsgId !== missingUserTurnId) {
133193
- 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;
133194
133945
  }
133195
- return void 0;
133196
- }
133197
- function hasPendingUserTurnActivation(meta) {
133198
- return getPendingUserTurnActivationId(meta) !== void 0;
133946
+ const status = resolveSessionHistoryStatus(entry);
133947
+ return status !== "handled" && status !== "failed" && status !== "canceled";
133199
133948
  }
133200
133949
  function shouldWatchSession(snapshot) {
133201
133950
  const { meta, hasUnprocessedCancelRequest, hasRpcTurnOffer, hasAccessRetry } = snapshot;
@@ -134134,7 +134883,10 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
134134
134883
  return preConfigRejection;
134135
134884
  }
134136
134885
  if (steerCapability.configPolicy === "apply") {
134137
- await this.deps.applyAcpModeAndModel(runtime.session, options.inputConfig);
134886
+ await this.deps.applyAcpModeAndModel(runtime.session, options.inputConfig, {
134887
+ sessionDoc,
134888
+ basedOnUserTurnId: options.userTurnId
134889
+ });
134138
134890
  }
134139
134891
  const preSubmitRejection = await rejectBeforeProviderSubmission();
134140
134892
  if (preSubmitRejection) {
@@ -134529,7 +135281,9 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
134529
135281
  }
134530
135282
  runtime.prePromptFailureRecorded = true;
134531
135283
  const message = formatErrorMessage(error2);
134532
- if (isGitExecutableNotFoundError(error2)) {
135284
+ if (error2 instanceof AcpAuthenticationRequiredError) {
135285
+ await this.deps.recordChatFailure(sessionDoc, "acp_auth_required", message);
135286
+ } else if (isGitExecutableNotFoundError(error2)) {
134533
135287
  await this.deps.recordChatFailure(sessionDoc, "turn_pre_prompt_failed", message, GIT_EXECUTABLE_NOT_FOUND_CODE);
134534
135288
  } else {
134535
135289
  await this.deps.recordChatFailure(sessionDoc, "turn_pre_prompt_failed", message);
@@ -135653,6 +136407,9 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
135653
136407
  }, async () => await self2.deps.applyAcpModeAndModel(targetSession, {
135654
136408
  ...acpSessionConfig,
135655
136409
  configOptionValues: acpSessionConfig.configOptionValues
136410
+ }, {
136411
+ sessionDoc,
136412
+ basedOnUserTurnId: executionUserTurnId
135656
136413
  })));
135657
136414
  const refreshPromptGitHubToken = (targetSession, triggerReason) => gen(function* () {
135658
136415
  if (!project) {
@@ -136157,6 +136914,9 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
136157
136914
  }, async () => await self2.deps.applyAcpModeAndModel(session2, {
136158
136915
  ...agentConfig,
136159
136916
  configOptionValues: agentConfig.configOptionValues
136917
+ }, {
136918
+ sessionDoc,
136919
+ basedOnUserTurnId: userTurnId
136160
136920
  })));
136161
136921
  yield* abortIfCancelled();
136162
136922
  const containerWorkdir = session2.getWorkdir();
@@ -136472,8 +137232,20 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
136472
137232
  customAcp: message.customAcp,
136473
137233
  runtimeOverrides: message.runtimeOverrides,
136474
137234
  env: message.env,
137235
+ methodId: message.methodId,
136475
137236
  onProgress
136476
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
+ }
136477
137249
  if (result.success && result.disposition === "authenticated" && message.configId) {
136478
137250
  const refresh = await this.refreshMachineAcpCapabilities({
136479
137251
  type: "machine/acp-capabilities-refresh",
@@ -137419,7 +138191,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
137419
138191
  }
137420
138192
  const now2 = Date.now();
137421
138193
  for (const [userTurnId, stashed] of stash) {
137422
- 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);
137423
138195
  if (stashed.expiresAtMs <= now2 || isTerminal2) {
137424
138196
  stash.delete(userTurnId);
137425
138197
  continue;
@@ -137825,7 +138597,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
137825
138597
  return;
137826
138598
  }
137827
138599
  if (!nextUserTurn) {
137828
- if (this.hasPendingUserTurnSignal(meta)) {
138600
+ if (hasPendingUserTurnActivation(meta)) {
137829
138601
  outcome = "missing-history";
137830
138602
  await this.markMissingUserTurnRecovery(sessionId, sessionDoc, meta);
137831
138603
  } else {
@@ -138329,10 +139101,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
138329
139101
  ...pendingEntry,
138330
139102
  id: queuedTurnId
138331
139103
  };
138332
- await sessionDoc.updateHistory((prevHistory) => [
138333
- ...prevHistory,
138334
- entry
138335
- ]);
139104
+ await sessionDoc.appendUserTurn(entry);
138336
139105
  return entry;
138337
139106
  } finally {
138338
139107
  releaseQueueMutation();
@@ -138363,20 +139132,50 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
138363
139132
  }
138364
139133
  async findOrAwaitDispatchableTurn(sessionId, sessionDoc, meta, lifecycleGeneration) {
138365
139134
  const isActive = () => this.isLifecycleActive(lifecycleGeneration);
138366
- const turn = await this.checkHistoryAndQueue(sessionDoc, meta, isActive);
139135
+ const { turn, history } = await this.checkHistoryAndQueue(sessionDoc, meta, isActive);
138367
139136
  if (!isActive()) {
138368
139137
  return null;
138369
139138
  }
138370
139139
  if (turn) {
138371
139140
  return turn;
138372
139141
  }
138373
- if (this.hasPendingUserTurnSignal(meta)) {
138374
- return await this.waitForPendingUserTurnHistorySync(sessionId, sessionDoc, meta, lifecycleGeneration);
139142
+ const pendingUserTurnId = getPendingUserTurnActivationId(meta);
139143
+ if (!pendingUserTurnId) {
139144
+ return null;
139145
+ }
139146
+ if (!isActivationAwaitingHistory(history, pendingUserTurnId)) {
139147
+ if (await this.settleTerminalActivation(sessionId, pendingUserTurnId)) {
139148
+ return null;
139149
+ }
138375
139150
  }
138376
- return null;
139151
+ return await this.waitForPendingUserTurnHistorySync(sessionId, sessionDoc, meta, lifecycleGeneration);
138377
139152
  }
138378
- hasPendingUserTurnSignal(meta) {
138379
- 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
+ });
138380
139179
  }
138381
139180
  async waitForPendingUserTurnHistorySync(sessionId, sessionDoc, meta, lifecycleGeneration) {
138382
139181
  const isActive = () => this.isLifecycleActive(lifecycleGeneration);
@@ -138384,7 +139183,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
138384
139183
  return null;
138385
139184
  }
138386
139185
  const pendingUserTurnId = getPendingUserTurnActivationId(meta);
138387
- 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`);
138388
139187
  return await new Promise((resolve2) => {
138389
139188
  let settled = false;
138390
139189
  let currentMeta = meta;
@@ -138437,7 +139236,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
138437
139236
  try {
138438
139237
  while (checkRequested) {
138439
139238
  checkRequested = false;
138440
- const turn = await this.checkHistoryAndQueue(sessionDoc, currentMeta, isActive);
139239
+ const { turn } = await this.checkHistoryAndQueue(sessionDoc, currentMeta, isActive);
138441
139240
  if (settled || !isActive()) {
138442
139241
  finish(null);
138443
139242
  return;
@@ -138568,7 +139367,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
138568
139367
  finish(null);
138569
139368
  return;
138570
139369
  }
138571
- if (!this.hasPendingUserTurnSignal(currentMeta)) {
139370
+ if (!hasPendingUserTurnActivation(currentMeta)) {
138572
139371
  this.deps.logger.debug(`[${sessionId}] Pending user turn pointer cleared during pre-wait sync; exiting wait`);
138573
139372
  exitWhenCheckIsEmpty = true;
138574
139373
  }
@@ -138592,7 +139391,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
138592
139391
  } catch (error2) {
138593
139392
  this.deps.logger.debug(`[${sessionId}] Failed to refresh metadata before dispatch recovery: ${formatErrorMessage(error2)}`);
138594
139393
  }
138595
- if (meta.machineId !== this.deps.machineId || meta.isArchived || !this.hasPendingUserTurnSignal(meta)) {
139394
+ if (meta.machineId !== this.deps.machineId || meta.isArchived || !hasPendingUserTurnActivation(meta)) {
138596
139395
  return;
138597
139396
  }
138598
139397
  const pendingUserMsgId = getPendingUserTurnActivationId(meta);
@@ -138622,7 +139421,10 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
138622
139421
  async checkHistoryAndQueue(sessionDoc, meta, isActive = () => true) {
138623
139422
  const history = await sessionDoc.getHistory();
138624
139423
  if (!isActive()) {
138625
- return null;
139424
+ return {
139425
+ turn: null,
139426
+ history
139427
+ };
138626
139428
  }
138627
139429
  const turn = findNextDispatchableUserTurn(history, meta);
138628
139430
  if (turn) {
@@ -138631,20 +139433,35 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
138631
139433
  return await this.checkHistoryAndQueue(sessionDoc, meta, isActive);
138632
139434
  }
138633
139435
  this.consumeStashedRpcTurn(meta.id, turn.id);
138634
- return turn;
139436
+ return {
139437
+ turn,
139438
+ history
139439
+ };
138635
139440
  }
138636
139441
  if (!isActive()) {
138637
- return null;
139442
+ return {
139443
+ turn: null,
139444
+ history
139445
+ };
138638
139446
  }
138639
139447
  const promoted = await this.promoteNextQueuedMessage(sessionDoc, meta, history);
138640
139448
  if (!isActive()) {
138641
- return null;
139449
+ return {
139450
+ turn: null,
139451
+ history
139452
+ };
138642
139453
  }
138643
139454
  if (promoted) {
138644
139455
  this.turnSourceHints.set(`${meta.id}:${promoted.id}`, "queue");
138645
- return promoted;
139456
+ return {
139457
+ turn: promoted,
139458
+ history
139459
+ };
138646
139460
  }
138647
- return this.peekStashedRpcTurn(meta.id, meta, history);
139461
+ return {
139462
+ turn: this.peekStashedRpcTurn(meta.id, meta, history),
139463
+ history
139464
+ };
138648
139465
  }
138649
139466
  async maybeRepairAlreadyHandledTurn(sessionDoc, meta, turn, history) {
138650
139467
  const sessionId = meta.id;
@@ -140270,14 +141087,14 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
140270
141087
  return serialized;
140271
141088
  };
140272
141089
  const fingerprintLodyCommand = (kind, canonical) => createHash("sha256").update(kind).update("\0").update(canonical).digest("hex");
140273
- 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()) => {
140274
141091
  const machineKey = createHash("sha256").update(machineId).digest("hex").slice(0, 24);
140275
141092
  return path__default.join(getLodyDataDir(void 0, homeDir), "orchestration", machineKey, "operations.sqlite3");
140276
141093
  };
140277
141094
  const getOperationDeliveryId = (requesterSessionId, operationId) => `operation:${requesterSessionId}:${operationId}:completion`;
140278
141095
  const getOperationCompletionTurnId = (requesterSessionId, operationId) => `operation-completion:${requesterSessionId}:${operationId}`;
140279
141096
  class LodyOperationStore {
140280
- constructor(dbPath = getLodyOperationStorePath(), now2 = Date.now, options = {}) {
141097
+ constructor(dbPath, now2 = Date.now, options = {}) {
140281
141098
  this.now = now2;
140282
141099
  const storeDirectory = path__default.dirname(dbPath);
140283
141100
  mkdirSync$2(storeDirectory, {
@@ -140702,6 +141519,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
140702
141519
  const TARGET_OUTPUT_PREVIEW_MAX_BYTES = 8 * 1024;
140703
141520
  const MATERIALIZATION_RETRY_MIN_MS = 1e3;
140704
141521
  const MATERIALIZATION_RETRY_MAX_MS = 3e4;
141522
+ const DELIVERY_EXPIRY_GRACE_MS = 8 * 60 * 60 * 1e3;
140705
141523
  const truncateTargetOutput = (text) => {
140706
141524
  const originalBytes = Buffer.byteLength(text, "utf8");
140707
141525
  if (originalBytes <= TARGET_OUTPUT_PREVIEW_MAX_BYTES) return {
@@ -141229,9 +142047,13 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
141229
142047
  this.consumeDelivery(delivery, reason, continuationEvidence);
141230
142048
  return;
141231
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
+ }
141232
142055
  if (execution.hasActiveTurn) return;
141233
142056
  if (this.options.dispatchWatcher.hasPendingDispatch(delivery.requesterSessionId)) return;
141234
- const operation = this.withStore((store) => store.get(delivery.requesterSessionId, delivery.operationId));
141235
142057
  const configuration = await this.resolveFrozenConfiguration(operation, delivery, reason);
141236
142058
  if (configuration === "unknown") {
141237
142059
  this.armConfigurationRetry(delivery.requesterSessionId);
@@ -154465,45 +155287,84 @@ ${entry.text}`).join("\n\n");
154465
155287
  }
154466
155288
  return response2;
154467
155289
  }
154468
- async function resolveLocalProjectBranchOnMachine(args2) {
154469
- if (!args2.requestedBranch?.trim() && args2.useWorktree !== true) {
154470
- return void 0;
154471
- }
154472
- const response2 = await readLocalProjectGitStateOnMachine(args2);
154473
- if (!response2.success) {
154474
- if (args2.requestedBranch || args2.useWorktree === true) {
154475
- throw new Error(response2.message ?? response2.error);
154476
- }
155290
+ function selectWorkspaceRepoFullName(githubRepoFullName, workspaceRepositories) {
155291
+ const repoFullName = normalizeCliValue(githubRepoFullName);
155292
+ if (!repoFullName) {
154477
155293
  return void 0;
154478
155294
  }
154479
- 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) {
154480
155301
  if (args2.useWorktree === true) {
154481
155302
  throw new Error("Cannot use --worktree with a local project that is not a git repository.");
154482
155303
  }
154483
- if (args2.requestedBranch) {
155304
+ if (requestedBranch) {
154484
155305
  throw new Error("Cannot use --branch with a local project that is not a git repository.");
154485
155306
  }
154486
- return void 0;
155307
+ return {};
154487
155308
  }
154488
- if (response2.state.branches.length === 0) {
154489
- if (args2.requestedBranch?.trim()) {
154490
- throw new Error(`Local project branch not found: ${args2.requestedBranch.trim()}`);
154491
- }
154492
- if (args2.useWorktree === true) {
154493
- 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}`);
154494
155319
  }
154495
- return void 0;
155320
+ throw new Error("The local project does not have a branch to use as a worktree base.");
154496
155321
  }
154497
155322
  const branch = resolveBaseBranchPreference({
154498
- preferredBranch: args2.requestedBranch,
154499
- baseBranch: response2.state.currentBranch,
154500
- 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]
154501
155326
  });
154502
- const selected = selectLocalProjectBranchSelector(response2.state.branches, branch);
155327
+ const selected = selectLocalProjectBranchSelector(args2.gitState.branches, branch);
154503
155328
  if (!selected) {
154504
155329
  throw new Error(`Local project branch not found: ${branch}`);
154505
155330
  }
154506
- 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
+ });
154507
155368
  }
154508
155369
  async function resolveLocalProjectRefOnMachineOrThrow(manager, workspaceId, auth, machineId, selector, requesterUserId, requestedBranch, useWorktree) {
154509
155370
  await syncMachineFlockDocsForRead(manager, workspaceId, [
@@ -154535,7 +155396,7 @@ ${entry.text}`).join("\n\n");
154535
155396
  throw new Error(`Local project selector is ambiguous on ${machineId}: ${normalizedSelector}. Use a project id instead.`);
154536
155397
  }
154537
155398
  const project = matches[0];
154538
- const branch = await resolveLocalProjectBranchOnMachine({
155399
+ const { branch, githubRepoFullName } = await resolveLocalProjectCreateGitContextOnMachine({
154539
155400
  auth,
154540
155401
  workspaceId,
154541
155402
  machineId,
@@ -154551,6 +155412,9 @@ ${entry.text}`).join("\n\n");
154551
155412
  ...branch ? {
154552
155413
  branch
154553
155414
  } : {},
155415
+ ...githubRepoFullName ? {
155416
+ githubRepoFullName
155417
+ } : {},
154554
155418
  ...useWorktree === true ? {
154555
155419
  useWorktree: true
154556
155420
  } : {}
@@ -156108,6 +156972,7 @@ ${entry.text}`).join("\n\n");
156108
156972
  resolveCreateAgentSelector,
156109
156973
  resolveCreateCurrentSessionId,
156110
156974
  resolveLocalProjectBranchForCreate,
156975
+ resolveLocalProjectCreateGitContext,
156111
156976
  resolveLocalProjectRefOrThrow,
156112
156977
  resolveOpenedBySessionRelation,
156113
156978
  resolvePromptCandidate,
@@ -156253,11 +157118,11 @@ ${entry.text}`).join("\n\n");
156253
157118
  return null;
156254
157119
  }
156255
157120
  try {
156256
- const stat2 = await jt.stat(absolutePath);
157121
+ const stat2 = await Yt.stat(absolutePath);
156257
157122
  if (!stat2.isFile() || stat2.size > (options?.maxBytes ?? defaultMaxTextFileBytes)) {
156258
157123
  return null;
156259
157124
  }
156260
- const content = await jt.readFile(absolutePath);
157125
+ const content = await Yt.readFile(absolutePath);
156261
157126
  if (content.includes(0)) {
156262
157127
  return null;
156263
157128
  }
@@ -156676,11 +157541,14 @@ ${entry.text}`).join("\n\n");
156676
157541
  logger2.debug(`[${sessionId}] applyAcpSessionRunConfig skipped (agentClient not ready)`);
156677
157542
  return {
156678
157543
  rejectedSelections: [],
156679
- warningSelections: []
157544
+ warningSelections: [],
157545
+ runtimeConfigPatch: null
156680
157546
  };
156681
157547
  }
156682
157548
  const rejectedSelections = [];
156683
157549
  const warningSelections = [];
157550
+ let confirmedLegacyModeId;
157551
+ let confirmedLegacyModelId;
156684
157552
  const agentConfigOptions = agentClient.getConfigOptions?.() ?? [];
156685
157553
  const suppressKnownRunConfigWarnings = isCodexOrClaudeRunConfig(config2);
156686
157554
  const recordRejection = (selection, suppressWarning) => {
@@ -156696,6 +157564,7 @@ ${entry.text}`).join("\n\n");
156696
157564
  if (config2.modeId) {
156697
157565
  try {
156698
157566
  await agentClient.setSessionMode?.(acpSessionId, config2.modeId);
157567
+ confirmedLegacyModeId = config2.modeId;
156699
157568
  } catch (error2) {
156700
157569
  recordRejection(`mode=${JSON.stringify(config2.modeId)}`, suppressKnownRunConfigWarnings && config2.modeId === ACP_PLAN_PERMISSION_MODE_ID);
156701
157570
  logger2.debug(`[${sessionId}] Failed to set ACP mode ${JSON.stringify(config2.modeId)}: ${String(error2)}`);
@@ -156704,6 +157573,7 @@ ${entry.text}`).join("\n\n");
156704
157573
  if (config2.modelId) {
156705
157574
  try {
156706
157575
  await agentClient.unstable_setSessionModel?.(acpSessionId, config2.modelId);
157576
+ confirmedLegacyModelId = config2.modelId;
156707
157577
  } catch (error2) {
156708
157578
  recordRejection(`model=${JSON.stringify(config2.modelId)}`, suppressKnownRunConfigWarnings);
156709
157579
  logger2.debug(`[${sessionId}] Failed to set ACP model ${JSON.stringify(config2.modelId)}: ${String(error2)}`);
@@ -156714,6 +157584,7 @@ ${entry.text}`).join("\n\n");
156714
157584
  if (!config2.modeId && typeof value === "string") {
156715
157585
  try {
156716
157586
  await agentClient.setSessionMode?.(acpSessionId, value);
157587
+ confirmedLegacyModeId = value;
156717
157588
  } catch (error2) {
156718
157589
  logger2.debug(`[${sessionId}] Failed to set ACP mode option ${configId}=${formatAcpConfigValueForLog(configId, value)}: ${String(error2)}`);
156719
157590
  }
@@ -156724,6 +157595,7 @@ ${entry.text}`).join("\n\n");
156724
157595
  if (!config2.modelId && typeof value === "string") {
156725
157596
  try {
156726
157597
  await agentClient.unstable_setSessionModel?.(acpSessionId, value);
157598
+ confirmedLegacyModelId = value;
156727
157599
  } catch (error2) {
156728
157600
  logger2.debug(`[${sessionId}] Failed to set ACP model option ${configId}=${formatAcpConfigValueForLog(configId, value)}: ${String(error2)}`);
156729
157601
  }
@@ -156745,9 +157617,23 @@ ${entry.text}`).join("\n\n");
156745
157617
  }
156746
157618
  }
156747
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
+ }
156748
157633
  return {
156749
157634
  rejectedSelections,
156750
- warningSelections
157635
+ warningSelections,
157636
+ runtimeConfigPatch
156751
157637
  };
156752
157638
  }
156753
157639
  function trimmed(value) {
@@ -163691,6 +164577,27 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
163691
164577
  if (value instanceof ArrayBuffer) return Buffer$1.from(new Uint8Array(value));
163692
164578
  return Buffer$1.from(value.buffer, value.byteOffset, value.byteLength);
163693
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
+ };
163694
164601
  class LocalPreviewProxyManager {
163695
164602
  constructor(deps) {
163696
164603
  this.deps = deps;
@@ -163891,9 +164798,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
163891
164798
  }
163892
164799
  });
163893
164800
  browserSocket.on("close", (code2, reason) => {
163894
- if (localSocket.readyState === LocalWebSocket.OPEN || localSocket.readyState === LocalWebSocket.CONNECTING) {
163895
- localSocket.close(code2, reason.toString("utf8"));
163896
- }
164801
+ mirrorWebSocketClose(localSocket, code2, reason);
163897
164802
  });
163898
164803
  browserSocket.on("error", () => {
163899
164804
  localSocket.terminate();
@@ -163914,12 +164819,13 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
163914
164819
  }
163915
164820
  });
163916
164821
  localSocket.on("close", (code2, reason) => {
163917
- if (browserSocket.readyState === LocalWebSocket.OPEN) {
163918
- browserSocket.close(code2, reason.toString("utf8"));
163919
- }
164822
+ mirrorWebSocketClose(browserSocket, code2, reason);
163920
164823
  });
163921
164824
  localSocket.on("error", (error2) => {
163922
164825
  this.deps.logger.debug(`Local preview WebSocket failed: ${formatErrorMessage(error2)}`);
164826
+ if (localOpen) {
164827
+ return;
164828
+ }
163923
164829
  if (browserSocket.readyState === LocalWebSocket.OPEN) {
163924
164830
  browserSocket.close(1011, "Local preview WebSocket failed");
163925
164831
  }
@@ -166873,7 +167779,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
166873
167779
  hasPromptOutputForTurn: (sessionId, turnId) => this.hasPromptOutputForTurn(sessionId, turnId),
166874
167780
  observePromptOutputForTurn: (sessionId, turnId) => this.observePromptOutputForTurn(sessionId, turnId),
166875
167781
  buildAcpPromptBlocks: async (args2) => await this.buildAcpPromptBlocks(args2),
166876
- applyAcpModeAndModel: async (session2, acpConfig) => await this.applyAcpModeAndModel(session2, acpConfig),
167782
+ applyAcpModeAndModel: async (session2, acpConfig, context2) => await this.applyAcpModeAndModel(session2, acpConfig, context2),
166877
167783
  createAssistantEntryForTurn: async (sessionId, sessionDoc, turnId, modelInfo, userTurnId) => await this.createAssistantEntryForTurn(sessionId, sessionDoc, turnId, modelInfo, userTurnId),
166878
167784
  turnFinalization: {
166879
167785
  finalizeACPState: async (sessionId, turnId) => await this.finalizeACPState(sessionId, turnId),
@@ -166995,7 +167901,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
166995
167901
  onAcpBinaryProgress,
166996
167902
  signal
166997
167903
  }),
166998
- 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({
166999
167905
  type: "machine/acp-authenticate",
167000
167906
  machineId: this.machineId,
167001
167907
  workspaceId: this.workspaceId,
@@ -167003,6 +167909,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
167003
167909
  action,
167004
167910
  authenticationRequestId,
167005
167911
  authorizationCode,
167912
+ methodId,
167006
167913
  configId,
167007
167914
  cliType,
167008
167915
  agentType,
@@ -167851,12 +168758,22 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
167851
168758
  ];
167852
168759
  });
167853
168760
  }
167854
- async applyAcpModeAndModel(session2, config2) {
167855
- const { warningSelections } = await applyAcpSessionRunConfig({
168761
+ async applyAcpModeAndModel(session2, config2, context2) {
168762
+ const { runtimeConfigPatch, warningSelections } = await applyAcpSessionRunConfig({
167856
168763
  session: session2,
167857
168764
  config: config2,
167858
168765
  logger: this.logger
167859
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
+ }
167860
168777
  if (warningSelections.length > 0) {
167861
168778
  void this.recordAgentWarning(session2.sessionId, {
167862
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.`,
@@ -170010,6 +170927,12 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
170010
170927
  persistedNotifications: 0
170011
170928
  };
170012
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
+ }
170013
170936
  await this.appendACPUpdatesToAssistantEntry({
170014
170937
  sessionId,
170015
170938
  sessionDoc,
@@ -173327,10 +174250,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
173327
174250
  if (!meta) {
173328
174251
  return false;
173329
174252
  }
173330
- if (meta.processingUserMsgId) {
173331
- return true;
173332
- }
173333
- return Boolean(meta.latestUserMsgId && meta.latestUserMsgId !== meta.lastHandledUserMsgId);
174253
+ return hasPendingUserTurnActivation(meta);
173334
174254
  }
173335
174255
  async hasActiveGoal(sessionId) {
173336
174256
  const sessionDoc = await this.workspaceDocument.getOrCreateSessionDoc(sessionId);
@@ -184389,11 +185309,16 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
184389
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`);
184390
185310
  return false;
184391
185311
  }
185312
+ const optedOut = await this.documentManager.getBuiltinAgentOptOuts(this.machineId);
184392
185313
  for (const cliType of cliTypes) {
184393
185314
  const builtinRuntime = getManagedBuiltinRuntimeByAgentType(cliType);
184394
185315
  if (!builtinRuntime) {
184395
185316
  continue;
184396
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
+ }
184397
185322
  const has2 = await this.documentManager.hasAgentConfig("builtin", cliType, this.machineId);
184398
185323
  if (!has2) {
184399
185324
  await this.documentManager.createAgentConfig("builtin", cliType, this.machineId, builtinRuntime.displayName);
@@ -189625,12 +190550,12 @@ ${trimmed2}${closing}`;
189625
190550
  }
189626
190551
  const MAX_AUTHOR_REPLY_CHARS = 4e3;
189627
190552
  const entryText = (entry) => (entry?.items ?? []).map((item) => item.text ?? "").filter(Boolean).join("\n").trim();
189628
- const isSessionBusy = (facts) => {
189629
- const type2 = facts.status?.type;
190553
+ const isSessionBusy = (meta) => {
190554
+ const type2 = meta.status?.type;
189630
190555
  if (type2 === "running" || type2 === "initializing" || type2 === "requestPermission") {
189631
190556
  return true;
189632
190557
  }
189633
- return Boolean(facts.latestUserMsgId) && facts.latestUserMsgId !== facts.lastHandledUserMsgId;
190558
+ return hasPendingUserTurnActivation(meta);
189634
190559
  };
189635
190560
  const createReviewAutomation = (options) => {
189636
190561
  const { documentManager, workspaceId, machineId, logger: logger2 } = options;
@@ -196232,7 +197157,7 @@ Shutting down gracefully${reason}...`);
196232
197157
  function requireLib$1() {
196233
197158
  if (hasRequiredLib$1) return lib$1;
196234
197159
  hasRequiredLib$1 = 1;
196235
- const Stream = Zr;
197160
+ const Stream = So;
196236
197161
  class MuteStream2 extends Stream {
196237
197162
  #isTTY = null;
196238
197163
  constructor(opts = {}) {
@@ -205710,7 +206635,7 @@ ${page}${helpTipBottom}${choiceDescription}${error2}${ansiEscapes.cursorHide}`;
205710
206635
  function requireStreams() {
205711
206636
  if (hasRequiredStreams) return streams;
205712
206637
  hasRequiredStreams = 1;
205713
- var Buffer2 = require$$0$6.Buffer, Transform2 = Zr.Transform;
206638
+ var Buffer2 = require$$0$6.Buffer, Transform2 = So.Transform;
205714
206639
  streams = function(iconv2) {
205715
206640
  iconv2.encodeStream = function encodeStream(encoding2, options) {
205716
206641
  return new IconvLiteEncoderStream(iconv2.getEncoder(encoding2, options), options);
@@ -205930,7 +206855,7 @@ ${page}${helpTipBottom}${choiceDescription}${error2}${ansiEscapes.cursorHide}`;
205930
206855
  return length2;
205931
206856
  };
205932
206857
  if (iconv2.supportsStreams) {
205933
- var Readable2 = Zr.Readable;
206858
+ var Readable2 = So.Readable;
205934
206859
  original.ReadableSetEncoding = Readable2.prototype.setEncoding;
205935
206860
  Readable2.prototype.setEncoding = function setEncoding(enc, options) {
205936
206861
  this._readableState.decoder = iconv2.getDecoder(enc, options);
@@ -205951,7 +206876,7 @@ ${page}${helpTipBottom}${choiceDescription}${error2}${ansiEscapes.cursorHide}`;
205951
206876
  Buffer2.prototype.toString = original.BufferToString;
205952
206877
  Buffer2.prototype.write = original.BufferWrite;
205953
206878
  if (iconv2.supportsStreams) {
205954
- var Readable2 = Zr.Readable;
206879
+ var Readable2 = So.Readable;
205955
206880
  Readable2.prototype.setEncoding = original.ReadableSetEncoding;
205956
206881
  delete Readable2.prototype.collect;
205957
206882
  }
@@ -220629,7 +221554,7 @@ ${page}${helpTipBottom}${choiceDescription}${ansiEscapes.cursorHide}`;
220629
221554
  data = createReviewBundleSnapshot(bundle);
220630
221555
  }
220631
221556
  const { injectReviewSnapshot } = await import("./chunks/index-VoI6Ds2-.js");
220632
- const { resolveReviewViewerTemplate } = await import("./chunks/review-viewer-GDxDN5px.js").then(async (m) => {
221557
+ const { resolveReviewViewerTemplate } = await import("./chunks/review-viewer-Ce9GBF8u.js").then(async (m) => {
220633
221558
  await m.__tla;
220634
221559
  return m;
220635
221560
  });
@@ -239335,12 +240260,18 @@ ${result.stdout ?? ""}`;
239335
240260
  workdir: readOptionalEnv("LODY_MCP_WORKDIR", "LODY_PREVIEW_MCP_WORKDIR") ?? process.cwd(),
239336
240261
  taskToolsEnabled: readOptionalEnv("LODY_MCP_TASK_TOOLS_ENABLED") === "1"
239337
240262
  };
239338
- let sharedOperationStore;
240263
+ const sharedOperationStores = /* @__PURE__ */ new Map();
240264
+ const resolveOperationStorePathForContext = () => getLodyOperationStorePath(getSessionContext().machineId);
239339
240265
  const getSharedOperationStore = () => {
239340
- sharedOperationStore ??= new LodyOperationStore(void 0, void 0, {
239341
- maintenance: false
239342
- });
239343
- 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;
239344
240275
  };
239345
240276
  const withOperationStore = (fn) => runWithOperationStoreBusyRetry(() => fn(getSharedOperationStore()));
239346
240277
  const assertBatchSize = (length2, maximum) => {
@@ -239733,7 +240664,7 @@ ${prompt2}` : prompt2;
239733
240664
  sessionDoc.getDocState()
239734
240665
  ]);
239735
240666
  const activeTurnId = resolveActiveAssistantTurnId(history);
239736
- const queuedTurnCount = docState?.mq?.length ?? (hasPendingDispatchPointer(session2) && !activeTurnId ? 1 : 0);
240667
+ const queuedTurnCount = docState?.mq?.length ?? (hasPendingUserTurnActivation(session2) && !activeTurnId ? 1 : 0);
239737
240668
  return resolveSessionExecutionSnapshot({
239738
240669
  live,
239739
240670
  ...activeTurnId ? {
@@ -239742,7 +240673,6 @@ ${prompt2}` : prompt2;
239742
240673
  queuedTurnCount
239743
240674
  });
239744
240675
  };
239745
- const hasPendingDispatchPointer = (session2) => Boolean(session2.processingUserMsgId || session2.latestUserMsgId && session2.latestUserMsgId !== session2.lastHandledUserMsgId);
239746
240676
  const resolveSessionLiveWorking = (session2, opts) => {
239747
240677
  const viewedField = opts.viewed ? {
239748
240678
  viewed: true
@@ -239769,7 +240699,7 @@ ${prompt2}` : prompt2;
239769
240699
  ...viewedField
239770
240700
  };
239771
240701
  }
239772
- if (hasPendingDispatchPointer(session2)) {
240702
+ if (hasPendingUserTurnActivation(session2)) {
239773
240703
  const dispatchedAtMs = session2.lastMessageAt ?? Date.parse(session2.createdAt);
239774
240704
  if (Number.isFinite(dispatchedAtMs) && opts.nowMs - dispatchedAtMs < MCP_PRE_START_WINDOW_MS) {
239775
240705
  return {
@@ -240337,6 +241267,7 @@ ${prompt2}` : prompt2;
240337
241267
  });
240338
241268
  const localProjects = await readMachineLocalProjects(manager.repo, workspaceId, session2.machineId);
240339
241269
  const localProject = localProjects[project.localProjectId];
241270
+ const githubRepo = resolveProjectGitHubRepo(project);
240340
241271
  return {
240341
241272
  kind: "local",
240342
241273
  projectId: project.localProjectId,
@@ -240346,6 +241277,9 @@ ${prompt2}` : prompt2;
240346
241277
  ...localProject?.rootPath ? {
240347
241278
  rootPath: localProject.rootPath
240348
241279
  } : {},
241280
+ ...githubRepo ? {
241281
+ githubRepo
241282
+ } : {},
240349
241283
  ...project.useWorktree === true || session2.isWorktree === true ? {
240350
241284
  worktree: true
240351
241285
  } : {}