lody 0.83.0 → 0.85.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/chunks/{index-CbTnvx5t.js → index-ddMw90Gr.js} +5396 -4189
- package/dist/chunks/{package-Ce-NgzCA.js → package-CNW89xCh.js} +2 -2
- package/dist/chunks/{profile-RfMzWliN.js → profile-Cxxl5hCq.js} +18 -7
- package/dist/chunks/{review-viewer-BPTYS7b4.js → review-viewer-oYzxdgq4.js} +4 -4
- package/dist/claude-acp.js +56197 -48759
- package/dist/codex-acp.js +1 -1
- package/dist/deepseek-acp.js +183 -44
- package/dist/deepseek-agent-presets/code/agent.cordis.yml +4 -3
- package/dist/deepseek-agent-presets/cordis/agent.cordis.yml +4 -3
- package/dist/deepseek-agent-presets/cordis/skills/editing-cordis-compositions/SKILL.md +13 -2
- package/dist/deepseek-agent-presets/minimal/agent.cordis.yml +27 -1
- package/dist/deepseek-agent-presets/standard/agent.cordis.yml +4 -3
- package/dist/grok-acp.js +48 -2
- package/dist/index.js +1389 -1268
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as path$1 from "path";
|
|
3
3
|
import path__default$1, { posix, dirname, sep, isAbsolute as isAbsolute$1, relative, parse as parse$4, resolve as resolve$2 } from "path";
|
|
4
|
-
import * as fs$
|
|
4
|
+
import * as fs$1 from "node:fs";
|
|
5
5
|
import fs__default$1, { createReadStream, createWriteStream, existsSync, rmSync, readdirSync, readFileSync, mkdirSync as mkdirSync$2, chmodSync, watch, promises as promises$1, realpathSync, unlinkSync as unlinkSync$1, accessSync as accessSync$1, constants as constants$9, writeSync } from "node:fs";
|
|
6
6
|
import * as readline$1 from "node:readline";
|
|
7
7
|
import readline__default, { createInterface } from "node:readline";
|
|
@@ -16,36 +16,36 @@ 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
|
|
19
|
+
import LE__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
|
-
import
|
|
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
|
|
26
|
+
import Zr, { 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
|
|
30
|
-
import
|
|
31
|
-
import require$$1$
|
|
32
|
-
import require$$1$
|
|
29
|
+
import * as $s from "zlib";
|
|
30
|
+
import $s__default from "zlib";
|
|
31
|
+
import require$$1$2 from "tty";
|
|
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
|
|
37
|
-
import
|
|
36
|
+
import * as jt from "node:fs/promises";
|
|
37
|
+
import jt__default, { mkdir as mkdir$1, realpath, symlink, mkdtemp, chmod, writeFile, rm, rename, stat, lstat, readdir, readFile, unlink, open, opendir } from "node:fs/promises";
|
|
38
38
|
import zlib__default, { gzip, gunzip as gunzip$1, gunzipSync, brotliDecompressSync } from "node:zlib";
|
|
39
|
-
import require$$1$
|
|
39
|
+
import require$$1$8, { exec, execFile as execFile$1, spawn as spawn$2 } from "child_process";
|
|
40
|
+
import { i as imports, _ as __wbg_set_wasm$1, r as rawWasm, L as LoroDoc, E as EphemeralStoreWasm, U as UndoManager, c as callPendingEvents$3, a as LoroTree, b as LoroText, d as LoroMovableList, e as LoroList, f as LoroMap, V as VersionVector, g as __vite__initWasm, h as decodeImportBlobMeta, __tla as __tla_0 } from "./chunks/loro_wasm_bg-BPNKba8n.js";
|
|
40
41
|
import { performance as performance$1 } from "perf_hooks";
|
|
41
42
|
import require$$0$9 from "net";
|
|
42
43
|
import require$$4$2 from "tls";
|
|
43
44
|
import require$$7$2, { fileURLToPath as fileURLToPath$1, pathToFileURL as pathToFileURL$1 } from "url";
|
|
44
|
-
import {
|
|
45
|
-
import { D as DEEPSEEK_HARNESS_PERMISSION_MODES, a as DEEPSEEK_HARNESS_AGENT_PRESETS, b as DEEPSEEK_HARNESS_MODELS, c as DEEPSEEK_HARNESS_REASONING_OPTIONS, A as ACP_EXTENSION_DSH_CAPABILITY_SOURCE_VERSION, d as createDeepSeekHarnessCordisConfig, e as ACP_EXTENSION_DSH_VERSION, f as ACP_EXTENSION_DSH_PROFILE_REVISION, g as ACP_EXTENSION_DSH_QUERY_PATH_ENV, h as ACP_EXTENSION_DSH_SESSION_ROOT_ENV, i as DEEPSEEK_HARNESS_NPX_PACKAGES, j as DEEPSEEK_HARNESS_VERSION, k as DEEPSEEK_HARNESS_DEFAULT_SESSION_COMPRESSION } from "./chunks/profile-RfMzWliN.js";
|
|
45
|
+
import { D as DEEPSEEK_HARNESS_PERMISSION_MODES, a as DEEPSEEK_HARNESS_AGENT_PRESETS, b as DEEPSEEK_HARNESS_MODELS, c as DEEPSEEK_HARNESS_REASONING_OPTIONS, A as ACP_EXTENSION_DSH_CAPABILITY_SOURCE_VERSION, d as createDeepSeekHarnessCordisConfig, e as ACP_EXTENSION_DSH_VERSION, f as ACP_EXTENSION_DSH_PROFILE_REVISION, g as ACP_EXTENSION_DSH_QUERY_PATH_ENV, h as ACP_EXTENSION_DSH_SESSION_ROOT_ENV, i as DEEPSEEK_HARNESS_NPX_PACKAGES, j as DEEPSEEK_HARNESS_VERSION, k as DEEPSEEK_HARNESS_DEFAULT_SESSION_COMPRESSION } from "./chunks/profile-Cxxl5hCq.js";
|
|
46
46
|
import assert from "assert";
|
|
47
|
-
import * as fs$
|
|
48
|
-
import fs__default$
|
|
47
|
+
import * as fs$2 from "fs/promises";
|
|
48
|
+
import fs__default$2 from "fs/promises";
|
|
49
49
|
import Database from "better-sqlite3";
|
|
50
50
|
import require$$0$d, { channel } from "node:diagnostics_channel";
|
|
51
51
|
import require$$0$b from "node:assert";
|
|
@@ -57,15 +57,15 @@ import require$$7$3 from "node:querystring";
|
|
|
57
57
|
import require$$5$2 from "node:tls";
|
|
58
58
|
import require$$5$3, { performance as performance$2 } from "node:perf_hooks";
|
|
59
59
|
import require$$8 from "node:util/types";
|
|
60
|
-
import require$$1$
|
|
61
|
-
import require$$1$
|
|
62
|
-
import require$$1$
|
|
63
|
-
import require$$1$
|
|
60
|
+
import require$$1$4, { Worker as Worker$1 } from "node:worker_threads";
|
|
61
|
+
import require$$1$5, { fileURLToPath, pathToFileURL } from "node:url";
|
|
62
|
+
import require$$1$6 from "node:console";
|
|
63
|
+
import require$$1$7 from "node:dns";
|
|
64
64
|
import { C as CodeCollabV2OpenTextRequestSchema, a as CodeCollabV2RefreshTextRequestSchema, b as CodeCollabV2SaveTextRequestSchema, c as CodeCollabV2OpenCurrentDiffRequestSchema, d as CodeCollabV2OpenAllChangesDiffRequestSchema, e as CodeCollabV2OpenTurnDiffRequestSchema, f as CodeCollabV2InitDirectoryRequestSchema, g as CodeCollabV2OpenTextOkSchema, h as CodeCollabV2RefreshTextResponseSchema, i as CodeCollabV2SaveTextResponseSchema, j as CodeCollabV2OpenCurrentDiffResponseSchema, k as CodeCollabV2OpenAllChangesDiffResponseSchema, l as CodeCollabV2OpenTurnDiffResponseSchema, m as CodeCollabV2InitDirectoryOkSchema, n as CodeCollabV2LspUnsupportedSchema, o as CodeCollabV2ErrorSchema, p as CodeCollabV2RpcContentEnvelopeSchema, q as deriveCodeCollabV2ContentKeyId, r as CodeCollabV2ErrorCodeSchema, s as CodeCollabV2RpcResponseSchema, t as deriveCodeCollabV2ContentKeyBytes, u as readCodeCollabFileIndexSignalFromFlock, w as writeCodeCollabFileIndexSignalToFlock, v as writeCodeCollabFileIndexToFlock, x as buildCodeCollabFileIndexState, y as CODE_COLLAB_V2_TEXT_LIMITS, z as CODE_COLLAB_V2_ALL_CHANGES_DIFF_LIMITS, A as computeAllChanges, B as codeCollabFileIndexStatesEqual, D as scanGitDirectoryEntries, E as closeDirectoryQuietly } from "./chunks/directory-handle-OPjjCl3O.js";
|
|
65
65
|
import { C as ClientSideConnection, P as PROTOCOL_VERSION, n as ndJsonStream } from "./chunks/acp-CrvzLY5A.js";
|
|
66
66
|
import { StringDecoder } from "node:string_decoder";
|
|
67
67
|
import { pipeline, finished } from "node:stream/promises";
|
|
68
|
-
import { p as packageJson } from "./chunks/package-
|
|
68
|
+
import { p as packageJson } from "./chunks/package-CNW89xCh.js";
|
|
69
69
|
import { r as runtimeManifest } from "./chunks/runtime-manifest-Fr5DEH54.js";
|
|
70
70
|
import { AsyncLocalStorage as AsyncLocalStorage$1 } from "async_hooks";
|
|
71
71
|
import { createRequire } from "module";
|
|
@@ -2296,7 +2296,7 @@ Upgrade Node, then re-run: npx lody@latest`;
|
|
|
2296
2296
|
return frames;
|
|
2297
2297
|
};
|
|
2298
2298
|
}
|
|
2299
|
-
const version$
|
|
2299
|
+
const version$a = "5.38.8";
|
|
2300
2300
|
const FeatureFlagError = {
|
|
2301
2301
|
ERRORS_WHILE_COMPUTING: "errors_while_computing_flags",
|
|
2302
2302
|
FLAG_MISSING: "flag_missing",
|
|
@@ -3474,7 +3474,7 @@ Upgrade Node, then re-run: npx lody@latest`;
|
|
|
3474
3474
|
return this.options.fetch ? this.options.fetch(url, options) : fetch(url, options);
|
|
3475
3475
|
}
|
|
3476
3476
|
getLibraryVersion() {
|
|
3477
|
-
return version$
|
|
3477
|
+
return version$a;
|
|
3478
3478
|
}
|
|
3479
3479
|
getCustomUserAgent() {
|
|
3480
3480
|
return `${this.getLibraryId()}/${this.getLibraryVersion()}`;
|
|
@@ -4324,7 +4324,7 @@ Upgrade Node, then re-run: npx lody@latest`;
|
|
|
4324
4324
|
}
|
|
4325
4325
|
const name$2 = "lody";
|
|
4326
4326
|
const name$1 = "@lody/cli-cloud";
|
|
4327
|
-
const version$
|
|
4327
|
+
const version$9 = "0.85.0";
|
|
4328
4328
|
const type$2 = "module";
|
|
4329
4329
|
const scripts = {
|
|
4330
4330
|
"dev": "node dev.mjs",
|
|
@@ -4341,7 +4341,7 @@ Upgrade Node, then re-run: npx lody@latest`;
|
|
|
4341
4341
|
};
|
|
4342
4342
|
const pkg = {
|
|
4343
4343
|
name: name$1,
|
|
4344
|
-
version: version$
|
|
4344
|
+
version: version$9,
|
|
4345
4345
|
"private": true,
|
|
4346
4346
|
type: type$2,
|
|
4347
4347
|
scripts,
|
|
@@ -14362,6 +14362,43 @@ Requirements:
|
|
|
14362
14362
|
}
|
|
14363
14363
|
}
|
|
14364
14364
|
},
|
|
14365
|
+
{
|
|
14366
|
+
id: "antigravity-acp",
|
|
14367
|
+
name: "Google Antigravity",
|
|
14368
|
+
version: "1.0.0",
|
|
14369
|
+
description: "Google\u2019s AI coding agent",
|
|
14370
|
+
icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/antigravity-acp.svg",
|
|
14371
|
+
distribution: {
|
|
14372
|
+
binary: {
|
|
14373
|
+
"darwin-aarch64": {
|
|
14374
|
+
archive: "https://dl.google.com/agy-extensions/releases/macos/agy-acp-server-agy_acp_server_20260818_01_RC01-darwin-arm64.zip",
|
|
14375
|
+
cmd: "./agy_acp_server.par"
|
|
14376
|
+
},
|
|
14377
|
+
"linux-x86_64": {
|
|
14378
|
+
archive: "https://dl.google.com/agy-extensions/releases/linux/agy-acp-server-agy_acp_server_20260818_01_RC01-linux-x86_64.zip",
|
|
14379
|
+
cmd: "./agy_acp_server.par",
|
|
14380
|
+
args: [
|
|
14381
|
+
"--uid="
|
|
14382
|
+
]
|
|
14383
|
+
},
|
|
14384
|
+
"linux-aarch64": {
|
|
14385
|
+
archive: "https://dl.google.com/agy-extensions/releases/linux/agy-acp-server-agy_acp_server_20260818_01_RC01-linux-arm64.zip",
|
|
14386
|
+
cmd: "./agy_acp_server.par",
|
|
14387
|
+
args: [
|
|
14388
|
+
"--uid="
|
|
14389
|
+
]
|
|
14390
|
+
},
|
|
14391
|
+
"windows-x86_64": {
|
|
14392
|
+
archive: "https://dl.google.com/agy-extensions/releases/windows/agy-acp-server-agy_acp_server_20260818_01_RC01-windows-x86_64.zip",
|
|
14393
|
+
cmd: "./agy_acp_server.exe"
|
|
14394
|
+
},
|
|
14395
|
+
"windows-aarch64": {
|
|
14396
|
+
archive: "https://dl.google.com/agy-extensions/releases/windows/agy-acp-server-agy_acp_server_20260818_01_RC01-windows-arm64.zip",
|
|
14397
|
+
cmd: "./agy_acp_server.exe"
|
|
14398
|
+
}
|
|
14399
|
+
}
|
|
14400
|
+
}
|
|
14401
|
+
},
|
|
14365
14402
|
{
|
|
14366
14403
|
id: "auggie",
|
|
14367
14404
|
name: "Auggie CLI",
|
|
@@ -14410,12 +14447,12 @@ Requirements:
|
|
|
14410
14447
|
{
|
|
14411
14448
|
id: "codebuddy-code",
|
|
14412
14449
|
name: "Codebuddy Code",
|
|
14413
|
-
version: "2.
|
|
14450
|
+
version: "2.137.1",
|
|
14414
14451
|
description: "Tencent Cloud's official intelligent coding tool",
|
|
14415
14452
|
icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/codebuddy-code.svg",
|
|
14416
14453
|
distribution: {
|
|
14417
14454
|
npx: {
|
|
14418
|
-
package: "@tencent-ai/codebuddy-code@2.
|
|
14455
|
+
package: "@tencent-ai/codebuddy-code@2.137.1",
|
|
14419
14456
|
args: [
|
|
14420
14457
|
"--acp"
|
|
14421
14458
|
]
|
|
@@ -14640,12 +14677,12 @@ Requirements:
|
|
|
14640
14677
|
{
|
|
14641
14678
|
id: "dimcode",
|
|
14642
14679
|
name: "DimCode",
|
|
14643
|
-
version: "0.3.
|
|
14680
|
+
version: "0.3.17",
|
|
14644
14681
|
description: "A coding agent that puts leading models at your command.",
|
|
14645
14682
|
icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/dimcode.svg",
|
|
14646
14683
|
distribution: {
|
|
14647
14684
|
npx: {
|
|
14648
|
-
package: "dimcode@0.3.
|
|
14685
|
+
package: "dimcode@0.3.17",
|
|
14649
14686
|
args: [
|
|
14650
14687
|
"acp"
|
|
14651
14688
|
]
|
|
@@ -14670,12 +14707,12 @@ Requirements:
|
|
|
14670
14707
|
{
|
|
14671
14708
|
id: "factory-droid",
|
|
14672
14709
|
name: "Factory Droid",
|
|
14673
|
-
version: "0.
|
|
14710
|
+
version: "0.200.0",
|
|
14674
14711
|
description: "Factory Droid - AI coding agent powered by Factory AI",
|
|
14675
14712
|
icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/factory-droid.svg",
|
|
14676
14713
|
distribution: {
|
|
14677
14714
|
npx: {
|
|
14678
|
-
package: "droid@0.
|
|
14715
|
+
package: "droid@0.200.0",
|
|
14679
14716
|
args: [
|
|
14680
14717
|
"exec",
|
|
14681
14718
|
"--output-format",
|
|
@@ -14709,12 +14746,12 @@ Requirements:
|
|
|
14709
14746
|
{
|
|
14710
14747
|
id: "gemini",
|
|
14711
14748
|
name: "Gemini CLI",
|
|
14712
|
-
version: "0.
|
|
14749
|
+
version: "0.56.0",
|
|
14713
14750
|
description: "Google's official CLI for Gemini",
|
|
14714
14751
|
icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/gemini.svg",
|
|
14715
14752
|
distribution: {
|
|
14716
14753
|
npx: {
|
|
14717
|
-
package: "@google/gemini-cli@0.
|
|
14754
|
+
package: "@google/gemini-cli@0.56.0",
|
|
14718
14755
|
args: [
|
|
14719
14756
|
"--acp"
|
|
14720
14757
|
]
|
|
@@ -14739,12 +14776,12 @@ Requirements:
|
|
|
14739
14776
|
{
|
|
14740
14777
|
id: "glm-acp-agent",
|
|
14741
14778
|
name: "GLM Agent",
|
|
14742
|
-
version: "1.
|
|
14779
|
+
version: "1.6.0",
|
|
14743
14780
|
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.",
|
|
14744
14781
|
icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/glm-acp-agent.svg",
|
|
14745
14782
|
distribution: {
|
|
14746
14783
|
npx: {
|
|
14747
|
-
package: "glm-acp-agent@1.
|
|
14784
|
+
package: "glm-acp-agent@1.6.0"
|
|
14748
14785
|
}
|
|
14749
14786
|
}
|
|
14750
14787
|
},
|
|
@@ -14769,13 +14806,13 @@ Requirements:
|
|
|
14769
14806
|
{
|
|
14770
14807
|
id: "harn",
|
|
14771
14808
|
name: "Harn",
|
|
14772
|
-
version: "0.10.
|
|
14809
|
+
version: "0.10.108",
|
|
14773
14810
|
description: "Harn runs .harn agent pipelines as a native ACP coding agent over stdio.",
|
|
14774
14811
|
icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/harn.svg",
|
|
14775
14812
|
distribution: {
|
|
14776
14813
|
binary: {
|
|
14777
14814
|
"darwin-aarch64": {
|
|
14778
|
-
archive: "https://github.com/burin-labs/harn/releases/download/v0.10.
|
|
14815
|
+
archive: "https://github.com/burin-labs/harn/releases/download/v0.10.108/harn-aarch64-apple-darwin.tar.gz",
|
|
14779
14816
|
cmd: "./harn",
|
|
14780
14817
|
args: [
|
|
14781
14818
|
"serve",
|
|
@@ -14783,7 +14820,7 @@ Requirements:
|
|
|
14783
14820
|
]
|
|
14784
14821
|
},
|
|
14785
14822
|
"darwin-x86_64": {
|
|
14786
|
-
archive: "https://github.com/burin-labs/harn/releases/download/v0.10.
|
|
14823
|
+
archive: "https://github.com/burin-labs/harn/releases/download/v0.10.108/harn-x86_64-apple-darwin.tar.gz",
|
|
14787
14824
|
cmd: "./harn",
|
|
14788
14825
|
args: [
|
|
14789
14826
|
"serve",
|
|
@@ -14791,7 +14828,7 @@ Requirements:
|
|
|
14791
14828
|
]
|
|
14792
14829
|
},
|
|
14793
14830
|
"linux-aarch64": {
|
|
14794
|
-
archive: "https://github.com/burin-labs/harn/releases/download/v0.10.
|
|
14831
|
+
archive: "https://github.com/burin-labs/harn/releases/download/v0.10.108/harn-aarch64-unknown-linux-gnu.tar.gz",
|
|
14795
14832
|
cmd: "./harn",
|
|
14796
14833
|
args: [
|
|
14797
14834
|
"serve",
|
|
@@ -14799,7 +14836,7 @@ Requirements:
|
|
|
14799
14836
|
]
|
|
14800
14837
|
},
|
|
14801
14838
|
"linux-x86_64": {
|
|
14802
|
-
archive: "https://github.com/burin-labs/harn/releases/download/v0.10.
|
|
14839
|
+
archive: "https://github.com/burin-labs/harn/releases/download/v0.10.108/harn-x86_64-unknown-linux-gnu.tar.gz",
|
|
14803
14840
|
cmd: "./harn",
|
|
14804
14841
|
args: [
|
|
14805
14842
|
"serve",
|
|
@@ -14807,7 +14844,7 @@ Requirements:
|
|
|
14807
14844
|
]
|
|
14808
14845
|
},
|
|
14809
14846
|
"windows-x86_64": {
|
|
14810
|
-
archive: "https://github.com/burin-labs/harn/releases/download/v0.10.
|
|
14847
|
+
archive: "https://github.com/burin-labs/harn/releases/download/v0.10.108/harn-x86_64-pc-windows-msvc.zip",
|
|
14811
14848
|
cmd: "harn.exe",
|
|
14812
14849
|
args: [
|
|
14813
14850
|
"serve",
|
|
@@ -14820,7 +14857,7 @@ Requirements:
|
|
|
14820
14857
|
{
|
|
14821
14858
|
id: "junie",
|
|
14822
14859
|
name: "Junie",
|
|
14823
|
-
version: "
|
|
14860
|
+
version: "2913.6.0",
|
|
14824
14861
|
description: "AI Coding Agent by JetBrains",
|
|
14825
14862
|
icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/junie.svg",
|
|
14826
14863
|
distribution: {
|
|
@@ -14838,47 +14875,47 @@ Requirements:
|
|
|
14838
14875
|
{
|
|
14839
14876
|
id: "kilo",
|
|
14840
14877
|
name: "Kilo",
|
|
14841
|
-
version: "7.4.
|
|
14878
|
+
version: "7.4.23",
|
|
14842
14879
|
description: "The open source coding agent",
|
|
14843
14880
|
icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/kilo.svg",
|
|
14844
14881
|
distribution: {
|
|
14845
14882
|
npx: {
|
|
14846
|
-
package: "@kilocode/cli@7.4.
|
|
14883
|
+
package: "@kilocode/cli@7.4.23",
|
|
14847
14884
|
args: [
|
|
14848
14885
|
"acp"
|
|
14849
14886
|
]
|
|
14850
14887
|
},
|
|
14851
14888
|
binary: {
|
|
14852
14889
|
"darwin-aarch64": {
|
|
14853
|
-
archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.4.
|
|
14890
|
+
archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.4.23/kilo-darwin-arm64.zip",
|
|
14854
14891
|
cmd: "./kilo",
|
|
14855
14892
|
args: [
|
|
14856
14893
|
"acp"
|
|
14857
14894
|
]
|
|
14858
14895
|
},
|
|
14859
14896
|
"darwin-x86_64": {
|
|
14860
|
-
archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.4.
|
|
14897
|
+
archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.4.23/kilo-darwin-x64.zip",
|
|
14861
14898
|
cmd: "./kilo",
|
|
14862
14899
|
args: [
|
|
14863
14900
|
"acp"
|
|
14864
14901
|
]
|
|
14865
14902
|
},
|
|
14866
14903
|
"linux-aarch64": {
|
|
14867
|
-
archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.4.
|
|
14904
|
+
archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.4.23/kilo-linux-arm64.tar.gz",
|
|
14868
14905
|
cmd: "./kilo",
|
|
14869
14906
|
args: [
|
|
14870
14907
|
"acp"
|
|
14871
14908
|
]
|
|
14872
14909
|
},
|
|
14873
14910
|
"linux-x86_64": {
|
|
14874
|
-
archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.4.
|
|
14911
|
+
archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.4.23/kilo-linux-x64.tar.gz",
|
|
14875
14912
|
cmd: "./kilo",
|
|
14876
14913
|
args: [
|
|
14877
14914
|
"acp"
|
|
14878
14915
|
]
|
|
14879
14916
|
},
|
|
14880
14917
|
"windows-x86_64": {
|
|
14881
|
-
archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.4.
|
|
14918
|
+
archive: "https://github.com/Kilo-Org/kilocode/releases/download/v7.4.23/kilo-windows-x64.zip",
|
|
14882
14919
|
cmd: "./kilo.exe",
|
|
14883
14920
|
args: [
|
|
14884
14921
|
"acp"
|
|
@@ -14975,7 +15012,7 @@ Requirements:
|
|
|
14975
15012
|
{
|
|
14976
15013
|
id: "opencode",
|
|
14977
15014
|
name: "OpenCode",
|
|
14978
|
-
version: "1.18.
|
|
15015
|
+
version: "1.18.19",
|
|
14979
15016
|
description: "The open source coding agent",
|
|
14980
15017
|
icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/opencode.svg",
|
|
14981
15018
|
distribution: {
|
|
@@ -15073,12 +15110,12 @@ Requirements:
|
|
|
15073
15110
|
{
|
|
15074
15111
|
id: "qwen-code",
|
|
15075
15112
|
name: "Qwen Code",
|
|
15076
|
-
version: "0.21.
|
|
15113
|
+
version: "0.21.15",
|
|
15077
15114
|
description: "Alibaba's Qwen coding assistant",
|
|
15078
15115
|
icon: "https://cdn.agentclientprotocol.com/registry/v1/latest/qwen-code.svg",
|
|
15079
15116
|
distribution: {
|
|
15080
15117
|
npx: {
|
|
15081
|
-
package: "@qwen-code/qwen-code@0.21.
|
|
15118
|
+
package: "@qwen-code/qwen-code@0.21.15",
|
|
15082
15119
|
args: [
|
|
15083
15120
|
"--acp",
|
|
15084
15121
|
"--experimental-skills"
|
|
@@ -24068,907 +24105,6 @@ ${context2.authorReply.trim()}
|
|
|
24068
24105
|
}
|
|
24069
24106
|
return bytes;
|
|
24070
24107
|
}
|
|
24071
|
-
const scheduleDataWorkNextTurn = (work) => {
|
|
24072
|
-
const handle = setTimeout(work, 0);
|
|
24073
|
-
return () => clearTimeout(handle);
|
|
24074
|
-
};
|
|
24075
|
-
const createLocalLoroDataPlaneScheduler = (scheduleTurn = scheduleDataWorkNextTurn) => {
|
|
24076
|
-
const queue2 = [];
|
|
24077
|
-
let running2 = false;
|
|
24078
|
-
let cancelScheduledTurn = null;
|
|
24079
|
-
const takeNext = () => {
|
|
24080
|
-
for (; ; ) {
|
|
24081
|
-
const work = queue2.shift();
|
|
24082
|
-
if (!work) return null;
|
|
24083
|
-
if (!work.cancelled) return work;
|
|
24084
|
-
}
|
|
24085
|
-
};
|
|
24086
|
-
const requestRun = () => {
|
|
24087
|
-
if (running2 || cancelScheduledTurn || queue2.length === 0) return;
|
|
24088
|
-
cancelScheduledTurn = scheduleTurn(() => {
|
|
24089
|
-
cancelScheduledTurn = null;
|
|
24090
|
-
const work = takeNext();
|
|
24091
|
-
if (!work) {
|
|
24092
|
-
return;
|
|
24093
|
-
}
|
|
24094
|
-
running2 = true;
|
|
24095
|
-
void Promise.resolve().then(work.run).finally(() => {
|
|
24096
|
-
running2 = false;
|
|
24097
|
-
requestRun();
|
|
24098
|
-
});
|
|
24099
|
-
});
|
|
24100
|
-
};
|
|
24101
|
-
return {
|
|
24102
|
-
scheduleDataWork: (run2) => {
|
|
24103
|
-
const work = {
|
|
24104
|
-
run: run2,
|
|
24105
|
-
cancelled: false
|
|
24106
|
-
};
|
|
24107
|
-
queue2.push(work);
|
|
24108
|
-
requestRun();
|
|
24109
|
-
return () => {
|
|
24110
|
-
work.cancelled = true;
|
|
24111
|
-
};
|
|
24112
|
-
}
|
|
24113
|
-
};
|
|
24114
|
-
};
|
|
24115
|
-
function syncTaskKey(key2, peerId) {
|
|
24116
|
-
return `${key2}
|
|
24117
|
-
${peerId}`;
|
|
24118
|
-
}
|
|
24119
|
-
class LocalLoroDataPlaneServer {
|
|
24120
|
-
constructor(options) {
|
|
24121
|
-
this.options = options;
|
|
24122
|
-
this.scheduler = options.scheduler ?? createLocalLoroDataPlaneScheduler();
|
|
24123
|
-
this.docRoomJoinHandler = options.onDocRoomJoin ?? null;
|
|
24124
|
-
this.docRoomLeaveHandler = options.onDocRoomLeave ?? null;
|
|
24125
|
-
this.flockRoomJoinHandler = options.onFlockRoomJoin ?? null;
|
|
24126
|
-
this.flockRoomLeaveHandler = options.onFlockRoomLeave ?? null;
|
|
24127
|
-
if (options.presenceSource) {
|
|
24128
|
-
this.presenceUnsubscribe = options.presenceSource.subscribeLocalOrigin(() => this.broadcastPresence());
|
|
24129
|
-
}
|
|
24130
|
-
if (options.machineMonitorSource) {
|
|
24131
|
-
this.machineMonitorUnsubscribe = options.machineMonitorSource.subscribe(() => this.broadcastMachineMonitor());
|
|
24132
|
-
}
|
|
24133
|
-
}
|
|
24134
|
-
rooms = /* @__PURE__ */ new Map();
|
|
24135
|
-
resolveInFlight = /* @__PURE__ */ new Map();
|
|
24136
|
-
roomGenerations = /* @__PURE__ */ new Map();
|
|
24137
|
-
presenceReceivers = /* @__PURE__ */ new Map();
|
|
24138
|
-
machineMonitorReceivers = /* @__PURE__ */ new Map();
|
|
24139
|
-
writers = /* @__PURE__ */ new Map();
|
|
24140
|
-
presenceUnsubscribe = null;
|
|
24141
|
-
machineMonitorUnsubscribe = null;
|
|
24142
|
-
docRoomJoinHandler = null;
|
|
24143
|
-
docRoomLeaveHandler = null;
|
|
24144
|
-
flockRoomJoinHandler = null;
|
|
24145
|
-
flockRoomLeaveHandler = null;
|
|
24146
|
-
scheduler;
|
|
24147
|
-
disposed = false;
|
|
24148
|
-
setDocRoomJoinHandler(handler) {
|
|
24149
|
-
this.docRoomJoinHandler = handler;
|
|
24150
|
-
}
|
|
24151
|
-
setDocRoomLeaveHandler(handler) {
|
|
24152
|
-
this.docRoomLeaveHandler = handler;
|
|
24153
|
-
}
|
|
24154
|
-
setFlockRoomJoinHandler(handler) {
|
|
24155
|
-
this.flockRoomJoinHandler = handler;
|
|
24156
|
-
}
|
|
24157
|
-
setFlockRoomLeaveHandler(handler) {
|
|
24158
|
-
this.flockRoomLeaveHandler = handler;
|
|
24159
|
-
}
|
|
24160
|
-
publishRoomStatus(room, status) {
|
|
24161
|
-
const entry = this.rooms.get(roomKey(room));
|
|
24162
|
-
if (!entry) {
|
|
24163
|
-
return;
|
|
24164
|
-
}
|
|
24165
|
-
for (const subscriber of entry.subscribers.values()) {
|
|
24166
|
-
this.enqueueMessage(subscriber.connection, {
|
|
24167
|
-
type: "room-status",
|
|
24168
|
-
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
24169
|
-
workspaceId: this.options.workspaceId,
|
|
24170
|
-
peerId: subscriber.peerId,
|
|
24171
|
-
room,
|
|
24172
|
-
status
|
|
24173
|
-
});
|
|
24174
|
-
}
|
|
24175
|
-
}
|
|
24176
|
-
invalidateDocRoom(docId) {
|
|
24177
|
-
const room = {
|
|
24178
|
-
scope: "doc",
|
|
24179
|
-
docId
|
|
24180
|
-
};
|
|
24181
|
-
const key2 = roomKey(room);
|
|
24182
|
-
this.roomGenerations.set(key2, (this.roomGenerations.get(key2) ?? 0) + 1);
|
|
24183
|
-
const entry = this.rooms.get(key2);
|
|
24184
|
-
if (!entry || entry.scope !== "doc") {
|
|
24185
|
-
return;
|
|
24186
|
-
}
|
|
24187
|
-
this.dropQueuedRoomWork(key2);
|
|
24188
|
-
this.publishRoomStatus(room, "disconnected");
|
|
24189
|
-
entry.unsubscribe();
|
|
24190
|
-
entry.subscribers.clear();
|
|
24191
|
-
entry.uploadAssemblers.clear();
|
|
24192
|
-
this.rooms.delete(key2);
|
|
24193
|
-
}
|
|
24194
|
-
dropQueuedRoomWork(key2) {
|
|
24195
|
-
for (const writer of this.writers.values()) {
|
|
24196
|
-
writer.queue = writer.queue.filter((task) => !((task.kind === "sync" || task.kind === "join-reply") && task.roomKey === key2));
|
|
24197
|
-
for (const taskKey of [
|
|
24198
|
-
...writer.queuedSyncKeys
|
|
24199
|
-
]) {
|
|
24200
|
-
if (taskKey.startsWith(`${key2}
|
|
24201
|
-
`)) {
|
|
24202
|
-
writer.queuedSyncKeys.delete(taskKey);
|
|
24203
|
-
}
|
|
24204
|
-
}
|
|
24205
|
-
}
|
|
24206
|
-
}
|
|
24207
|
-
get maxPayloadBytes() {
|
|
24208
|
-
return this.options.maxPayloadBytes ?? LOCAL_LORO_DATA_PLANE_MAX_PAYLOAD_BYTES;
|
|
24209
|
-
}
|
|
24210
|
-
async handleMessage(connection2, message) {
|
|
24211
|
-
if (this.disposed) {
|
|
24212
|
-
this.sendError(connection2, {
|
|
24213
|
-
code: "workspace_runtime_unavailable",
|
|
24214
|
-
peerId: message.peerId,
|
|
24215
|
-
requestId: message.type === "join" ? message.requestId : void 0
|
|
24216
|
-
});
|
|
24217
|
-
return;
|
|
24218
|
-
}
|
|
24219
|
-
if (message.workspaceId !== this.options.workspaceId) {
|
|
24220
|
-
this.sendError(connection2, {
|
|
24221
|
-
code: "workspace_mismatch",
|
|
24222
|
-
peerId: message.peerId,
|
|
24223
|
-
requestId: message.type === "join" ? message.requestId : void 0
|
|
24224
|
-
});
|
|
24225
|
-
return;
|
|
24226
|
-
}
|
|
24227
|
-
try {
|
|
24228
|
-
this.registerPresenceReceiver(connection2);
|
|
24229
|
-
switch (message.type) {
|
|
24230
|
-
case "join":
|
|
24231
|
-
await this.handleJoin(connection2, message);
|
|
24232
|
-
return;
|
|
24233
|
-
case "update":
|
|
24234
|
-
await this.handleUpdate(connection2, message);
|
|
24235
|
-
return;
|
|
24236
|
-
case "leave":
|
|
24237
|
-
this.unsubscribePeer(message.peerId, roomKey(message.room));
|
|
24238
|
-
return;
|
|
24239
|
-
case "detach":
|
|
24240
|
-
this.detachPeer(message.peerId);
|
|
24241
|
-
return;
|
|
24242
|
-
case "machine-monitor":
|
|
24243
|
-
this.registerMachineMonitorReceiver(connection2);
|
|
24244
|
-
this.options.machineMonitorSource?.apply(base64ToBytes(message.dataBase64));
|
|
24245
|
-
return;
|
|
24246
|
-
}
|
|
24247
|
-
} catch (error2) {
|
|
24248
|
-
this.options.onError?.(error2, `handleMessage:${message.type}`);
|
|
24249
|
-
this.sendError(connection2, {
|
|
24250
|
-
code: "data_plane_error",
|
|
24251
|
-
message: errorMessage(error2),
|
|
24252
|
-
peerId: message.peerId,
|
|
24253
|
-
requestId: message.type === "join" ? message.requestId : void 0,
|
|
24254
|
-
room: "room" in message ? message.room : void 0
|
|
24255
|
-
});
|
|
24256
|
-
}
|
|
24257
|
-
}
|
|
24258
|
-
registerPresenceReceiver(connection2) {
|
|
24259
|
-
if (!this.options.presenceSource || this.presenceReceivers.has(connection2.id)) {
|
|
24260
|
-
return;
|
|
24261
|
-
}
|
|
24262
|
-
this.presenceReceivers.set(connection2.id, connection2);
|
|
24263
|
-
this.enqueuePresence(connection2);
|
|
24264
|
-
}
|
|
24265
|
-
broadcastPresence() {
|
|
24266
|
-
if (this.disposed) {
|
|
24267
|
-
return;
|
|
24268
|
-
}
|
|
24269
|
-
for (const connection2 of this.presenceReceivers.values()) {
|
|
24270
|
-
this.enqueuePresence(connection2);
|
|
24271
|
-
}
|
|
24272
|
-
}
|
|
24273
|
-
registerMachineMonitorReceiver(connection2) {
|
|
24274
|
-
if (!this.options.machineMonitorSource || this.machineMonitorReceivers.has(connection2.id)) {
|
|
24275
|
-
return;
|
|
24276
|
-
}
|
|
24277
|
-
this.machineMonitorReceivers.set(connection2.id, connection2);
|
|
24278
|
-
this.enqueueMachineMonitor(connection2);
|
|
24279
|
-
}
|
|
24280
|
-
broadcastMachineMonitor() {
|
|
24281
|
-
if (this.disposed) return;
|
|
24282
|
-
for (const connection2 of this.machineMonitorReceivers.values()) {
|
|
24283
|
-
this.enqueueMachineMonitor(connection2);
|
|
24284
|
-
}
|
|
24285
|
-
}
|
|
24286
|
-
dispose() {
|
|
24287
|
-
this.disposed = true;
|
|
24288
|
-
this.presenceUnsubscribe?.();
|
|
24289
|
-
this.presenceUnsubscribe = null;
|
|
24290
|
-
this.machineMonitorUnsubscribe?.();
|
|
24291
|
-
this.machineMonitorUnsubscribe = null;
|
|
24292
|
-
this.presenceReceivers.clear();
|
|
24293
|
-
this.machineMonitorReceivers.clear();
|
|
24294
|
-
for (const entry of this.rooms.values()) {
|
|
24295
|
-
entry.unsubscribe();
|
|
24296
|
-
this.notifyDocRoomLeave(entry.room);
|
|
24297
|
-
this.notifyFlockRoomLeave(entry.room);
|
|
24298
|
-
entry.subscribers.clear();
|
|
24299
|
-
}
|
|
24300
|
-
this.rooms.clear();
|
|
24301
|
-
this.roomGenerations.clear();
|
|
24302
|
-
for (const writer of this.writers.values()) {
|
|
24303
|
-
this.cancelScheduledDataPump(writer);
|
|
24304
|
-
writer.unsubscribeDrain?.();
|
|
24305
|
-
writer.queue.length = 0;
|
|
24306
|
-
writer.pendingFrames.length = 0;
|
|
24307
|
-
}
|
|
24308
|
-
this.writers.clear();
|
|
24309
|
-
}
|
|
24310
|
-
handleDisconnect(connectionId) {
|
|
24311
|
-
this.presenceReceivers.delete(connectionId);
|
|
24312
|
-
this.machineMonitorReceivers.delete(connectionId);
|
|
24313
|
-
const writer = this.writers.get(connectionId);
|
|
24314
|
-
if (writer) {
|
|
24315
|
-
this.cancelScheduledDataPump(writer);
|
|
24316
|
-
writer.unsubscribeDrain?.();
|
|
24317
|
-
writer.queue.length = 0;
|
|
24318
|
-
writer.pendingFrames.length = 0;
|
|
24319
|
-
this.writers.delete(connectionId);
|
|
24320
|
-
}
|
|
24321
|
-
for (const key2 of [
|
|
24322
|
-
...this.rooms.keys()
|
|
24323
|
-
]) {
|
|
24324
|
-
const entry = this.rooms.get(key2);
|
|
24325
|
-
if (!entry) {
|
|
24326
|
-
continue;
|
|
24327
|
-
}
|
|
24328
|
-
for (const [peerId, subscriber] of [
|
|
24329
|
-
...entry.subscribers
|
|
24330
|
-
]) {
|
|
24331
|
-
if (subscriber.connection.id === connectionId) {
|
|
24332
|
-
entry.subscribers.delete(peerId);
|
|
24333
|
-
if (entry.scope === "doc") {
|
|
24334
|
-
entry.uploadAssemblers.delete(peerId);
|
|
24335
|
-
}
|
|
24336
|
-
}
|
|
24337
|
-
}
|
|
24338
|
-
this.releaseRoomIfEmpty(key2, entry);
|
|
24339
|
-
}
|
|
24340
|
-
}
|
|
24341
|
-
detachPeer(peerId) {
|
|
24342
|
-
for (const key2 of [
|
|
24343
|
-
...this.rooms.keys()
|
|
24344
|
-
]) {
|
|
24345
|
-
this.unsubscribePeer(peerId, key2);
|
|
24346
|
-
}
|
|
24347
|
-
}
|
|
24348
|
-
async handleJoin(connection2, message) {
|
|
24349
|
-
const key2 = roomKey(message.room);
|
|
24350
|
-
for (; ; ) {
|
|
24351
|
-
const entry = await this.ensureRoom(message.room);
|
|
24352
|
-
if (this.rooms.get(key2) !== entry) {
|
|
24353
|
-
continue;
|
|
24354
|
-
}
|
|
24355
|
-
if (entry.scope === "doc") {
|
|
24356
|
-
entry.subscribers.set(message.peerId, {
|
|
24357
|
-
peerId: message.peerId,
|
|
24358
|
-
connection: connection2,
|
|
24359
|
-
latestJoinRequestId: message.requestId,
|
|
24360
|
-
lastSentVV: decodeVersion(message.haveVersion)
|
|
24361
|
-
});
|
|
24362
|
-
} else {
|
|
24363
|
-
entry.subscribers.set(message.peerId, {
|
|
24364
|
-
peerId: message.peerId,
|
|
24365
|
-
connection: connection2,
|
|
24366
|
-
latestJoinRequestId: message.requestId,
|
|
24367
|
-
lastSentVersion: decodeFlockVersion(message.haveVersion)
|
|
24368
|
-
});
|
|
24369
|
-
}
|
|
24370
|
-
this.enqueueJoinReply(connection2, key2, message.peerId, message.requestId);
|
|
24371
|
-
if (message.room.scope === "doc") {
|
|
24372
|
-
this.notifyDocRoomJoin(message.room.docId);
|
|
24373
|
-
} else if (message.room.scope === "flock-doc") {
|
|
24374
|
-
this.notifyFlockRoomJoin(message.room.flockDocId);
|
|
24375
|
-
}
|
|
24376
|
-
return;
|
|
24377
|
-
}
|
|
24378
|
-
}
|
|
24379
|
-
notifyDocRoomJoin(docId) {
|
|
24380
|
-
if (!this.docRoomJoinHandler) {
|
|
24381
|
-
return;
|
|
24382
|
-
}
|
|
24383
|
-
void Promise.resolve(this.docRoomJoinHandler(docId)).catch((error2) => {
|
|
24384
|
-
this.options.onError?.(error2, "onDocRoomJoin");
|
|
24385
|
-
});
|
|
24386
|
-
}
|
|
24387
|
-
notifyFlockRoomJoin(flockDocId) {
|
|
24388
|
-
if (!this.flockRoomJoinHandler) {
|
|
24389
|
-
return;
|
|
24390
|
-
}
|
|
24391
|
-
void Promise.resolve(this.flockRoomJoinHandler(flockDocId)).catch((error2) => {
|
|
24392
|
-
this.options.onError?.(error2, "onFlockRoomJoin");
|
|
24393
|
-
});
|
|
24394
|
-
}
|
|
24395
|
-
notifyDocRoomLeave(room) {
|
|
24396
|
-
if (room.scope !== "doc" || !this.docRoomLeaveHandler) {
|
|
24397
|
-
return;
|
|
24398
|
-
}
|
|
24399
|
-
void Promise.resolve(this.docRoomLeaveHandler(room.docId)).catch((error2) => {
|
|
24400
|
-
this.options.onError?.(error2, "onDocRoomLeave");
|
|
24401
|
-
});
|
|
24402
|
-
}
|
|
24403
|
-
notifyFlockRoomLeave(room) {
|
|
24404
|
-
if (room.scope !== "flock-doc" || !this.flockRoomLeaveHandler) {
|
|
24405
|
-
return;
|
|
24406
|
-
}
|
|
24407
|
-
void Promise.resolve(this.flockRoomLeaveHandler(room.flockDocId)).catch((error2) => {
|
|
24408
|
-
this.options.onError?.(error2, "onFlockRoomLeave");
|
|
24409
|
-
});
|
|
24410
|
-
}
|
|
24411
|
-
async handleUpdate(connection2, message) {
|
|
24412
|
-
const key2 = roomKey(message.room);
|
|
24413
|
-
let entry = await this.ensureRoom(message.room);
|
|
24414
|
-
while (this.rooms.get(key2) !== entry) {
|
|
24415
|
-
entry = await this.ensureRoom(message.room);
|
|
24416
|
-
}
|
|
24417
|
-
if (entry.scope === "doc") {
|
|
24418
|
-
if (message.payload.kind === "flock-json") {
|
|
24419
|
-
this.sendError(connection2, {
|
|
24420
|
-
code: "payload_kind_mismatch",
|
|
24421
|
-
message: "expected doc-update",
|
|
24422
|
-
peerId: message.peerId,
|
|
24423
|
-
room: message.room
|
|
24424
|
-
});
|
|
24425
|
-
return;
|
|
24426
|
-
}
|
|
24427
|
-
let dataBase64;
|
|
24428
|
-
if (message.payload.kind === "doc-update") {
|
|
24429
|
-
entry.uploadAssemblers.delete(message.peerId);
|
|
24430
|
-
dataBase64 = message.payload.dataBase64;
|
|
24431
|
-
} else {
|
|
24432
|
-
let assembler = entry.uploadAssemblers.get(message.peerId);
|
|
24433
|
-
if (!assembler) {
|
|
24434
|
-
assembler = new DocUpdateChunkAssembler();
|
|
24435
|
-
entry.uploadAssemblers.set(message.peerId, assembler);
|
|
24436
|
-
}
|
|
24437
|
-
dataBase64 = assembler.push(message.payload);
|
|
24438
|
-
if (dataBase64 === null) {
|
|
24439
|
-
return;
|
|
24440
|
-
}
|
|
24441
|
-
entry.uploadAssemblers.delete(message.peerId);
|
|
24442
|
-
}
|
|
24443
|
-
const subscriber2 = entry.subscribers.get(message.peerId);
|
|
24444
|
-
if (subscriber2) {
|
|
24445
|
-
subscriber2.lastSentVV = decodeVersion(message.haveVersion);
|
|
24446
|
-
}
|
|
24447
|
-
entry.doc.import(base64ToBytes(dataBase64));
|
|
24448
|
-
return;
|
|
24449
|
-
}
|
|
24450
|
-
if (message.payload.kind !== "flock-json") {
|
|
24451
|
-
this.sendError(connection2, {
|
|
24452
|
-
code: "payload_kind_mismatch",
|
|
24453
|
-
message: "expected flock-json",
|
|
24454
|
-
peerId: message.peerId,
|
|
24455
|
-
room: message.room
|
|
24456
|
-
});
|
|
24457
|
-
return;
|
|
24458
|
-
}
|
|
24459
|
-
const subscriber = entry.subscribers.get(message.peerId);
|
|
24460
|
-
if (subscriber) {
|
|
24461
|
-
subscriber.lastSentVersion = mergeFlockVersions(subscriber.lastSentVersion, decodeFlockVersion(message.haveVersion));
|
|
24462
|
-
}
|
|
24463
|
-
await entry.flock.importJson(message.payload.bundle);
|
|
24464
|
-
entry.flock.commit?.();
|
|
24465
|
-
}
|
|
24466
|
-
async ensureRoom(room) {
|
|
24467
|
-
const key2 = roomKey(room);
|
|
24468
|
-
for (; ; ) {
|
|
24469
|
-
const existing = this.rooms.get(key2);
|
|
24470
|
-
if (existing) {
|
|
24471
|
-
return existing;
|
|
24472
|
-
}
|
|
24473
|
-
const inFlight = this.resolveInFlight.get(key2);
|
|
24474
|
-
if (inFlight) {
|
|
24475
|
-
const shared = await inFlight;
|
|
24476
|
-
if (shared) {
|
|
24477
|
-
return shared;
|
|
24478
|
-
}
|
|
24479
|
-
continue;
|
|
24480
|
-
}
|
|
24481
|
-
const generation = this.roomGenerations.get(key2) ?? 0;
|
|
24482
|
-
const build = (async () => {
|
|
24483
|
-
const entry = room.scope === "doc" ? await this.buildDocRoom(room, room.docId) : await this.buildFlockRoom(room, await this.resolveFlockForRoom(room));
|
|
24484
|
-
if (this.disposed) {
|
|
24485
|
-
entry.unsubscribe();
|
|
24486
|
-
throw new Error("data_plane_engine_disposed");
|
|
24487
|
-
}
|
|
24488
|
-
if ((this.roomGenerations.get(key2) ?? 0) !== generation) {
|
|
24489
|
-
entry.unsubscribe();
|
|
24490
|
-
return null;
|
|
24491
|
-
}
|
|
24492
|
-
this.rooms.set(key2, entry);
|
|
24493
|
-
return entry;
|
|
24494
|
-
})().finally(() => this.resolveInFlight.delete(key2));
|
|
24495
|
-
this.resolveInFlight.set(key2, build);
|
|
24496
|
-
const resolved = await build;
|
|
24497
|
-
if (resolved) {
|
|
24498
|
-
return resolved;
|
|
24499
|
-
}
|
|
24500
|
-
}
|
|
24501
|
-
}
|
|
24502
|
-
async buildDocRoom(room, docId) {
|
|
24503
|
-
const doc = await this.options.resolveDoc(docId);
|
|
24504
|
-
const entry = {
|
|
24505
|
-
scope: "doc",
|
|
24506
|
-
room,
|
|
24507
|
-
doc,
|
|
24508
|
-
unsubscribe: () => {
|
|
24509
|
-
},
|
|
24510
|
-
subscribers: /* @__PURE__ */ new Map(),
|
|
24511
|
-
uploadAssemblers: /* @__PURE__ */ new Map()
|
|
24512
|
-
};
|
|
24513
|
-
entry.unsubscribe = doc.subscribe(() => this.markRoomDirty(entry));
|
|
24514
|
-
return entry;
|
|
24515
|
-
}
|
|
24516
|
-
resolveFlockForRoom(room) {
|
|
24517
|
-
if (room.scope === "flock-doc") {
|
|
24518
|
-
return this.options.resolveFlockDoc(room.flockDocId);
|
|
24519
|
-
}
|
|
24520
|
-
return this.options.resolveMetaFlock ? this.options.resolveMetaFlock() : this.options.resolveFlockDoc("meta");
|
|
24521
|
-
}
|
|
24522
|
-
async buildFlockRoom(room, flock) {
|
|
24523
|
-
const entry = {
|
|
24524
|
-
scope: "flock",
|
|
24525
|
-
room,
|
|
24526
|
-
flock,
|
|
24527
|
-
unsubscribe: () => {
|
|
24528
|
-
},
|
|
24529
|
-
subscribers: /* @__PURE__ */ new Map()
|
|
24530
|
-
};
|
|
24531
|
-
entry.unsubscribe = flock.subscribe(() => this.markRoomDirty(entry));
|
|
24532
|
-
return entry;
|
|
24533
|
-
}
|
|
24534
|
-
markRoomDirty(entry) {
|
|
24535
|
-
if (this.disposed) {
|
|
24536
|
-
return;
|
|
24537
|
-
}
|
|
24538
|
-
const key2 = roomKey(entry.room);
|
|
24539
|
-
for (const subscriber of entry.subscribers.values()) {
|
|
24540
|
-
this.enqueueSync(subscriber.connection, key2, subscriber.peerId);
|
|
24541
|
-
}
|
|
24542
|
-
this.releaseRoomIfEmpty(key2, entry);
|
|
24543
|
-
}
|
|
24544
|
-
writerFor(connection2) {
|
|
24545
|
-
const existing = this.writers.get(connection2.id);
|
|
24546
|
-
if (existing) {
|
|
24547
|
-
return existing;
|
|
24548
|
-
}
|
|
24549
|
-
const writer = {
|
|
24550
|
-
connection: connection2,
|
|
24551
|
-
queue: [],
|
|
24552
|
-
queuedSyncKeys: /* @__PURE__ */ new Set(),
|
|
24553
|
-
presenceQueued: false,
|
|
24554
|
-
machineMonitorQueued: false,
|
|
24555
|
-
pendingFrames: [],
|
|
24556
|
-
pumping: false,
|
|
24557
|
-
pumpScheduled: false,
|
|
24558
|
-
cancelScheduledPump: null,
|
|
24559
|
-
blocked: false,
|
|
24560
|
-
unsubscribeDrain: null
|
|
24561
|
-
};
|
|
24562
|
-
writer.unsubscribeDrain = connection2.onDrain?.(() => {
|
|
24563
|
-
writer.blocked = false;
|
|
24564
|
-
this.scheduleDataPump(writer);
|
|
24565
|
-
}) ?? null;
|
|
24566
|
-
this.writers.set(connection2.id, writer);
|
|
24567
|
-
return writer;
|
|
24568
|
-
}
|
|
24569
|
-
enqueueMessage(connection2, message) {
|
|
24570
|
-
const writer = this.writerFor(connection2);
|
|
24571
|
-
writer.queue.push({
|
|
24572
|
-
kind: "message",
|
|
24573
|
-
message
|
|
24574
|
-
});
|
|
24575
|
-
this.scheduleDataPump(writer);
|
|
24576
|
-
}
|
|
24577
|
-
enqueueJoinReply(connection2, key2, peerId, requestId) {
|
|
24578
|
-
const writer = this.writerFor(connection2);
|
|
24579
|
-
writer.queue.push({
|
|
24580
|
-
kind: "join-reply",
|
|
24581
|
-
roomKey: key2,
|
|
24582
|
-
peerId,
|
|
24583
|
-
requestId
|
|
24584
|
-
});
|
|
24585
|
-
this.scheduleDataPump(writer);
|
|
24586
|
-
}
|
|
24587
|
-
enqueueSync(connection2, key2, peerId) {
|
|
24588
|
-
const writer = this.writerFor(connection2);
|
|
24589
|
-
const taskKey = syncTaskKey(key2, peerId);
|
|
24590
|
-
if (writer.queuedSyncKeys.has(taskKey)) {
|
|
24591
|
-
return;
|
|
24592
|
-
}
|
|
24593
|
-
writer.queuedSyncKeys.add(taskKey);
|
|
24594
|
-
writer.queue.push({
|
|
24595
|
-
kind: "sync",
|
|
24596
|
-
roomKey: key2,
|
|
24597
|
-
peerId
|
|
24598
|
-
});
|
|
24599
|
-
this.scheduleDataPump(writer);
|
|
24600
|
-
}
|
|
24601
|
-
enqueuePresence(connection2) {
|
|
24602
|
-
const writer = this.writerFor(connection2);
|
|
24603
|
-
if (writer.presenceQueued) {
|
|
24604
|
-
return;
|
|
24605
|
-
}
|
|
24606
|
-
writer.presenceQueued = true;
|
|
24607
|
-
writer.queue.push({
|
|
24608
|
-
kind: "presence"
|
|
24609
|
-
});
|
|
24610
|
-
this.scheduleDataPump(writer);
|
|
24611
|
-
}
|
|
24612
|
-
enqueueMachineMonitor(connection2) {
|
|
24613
|
-
const writer = this.writerFor(connection2);
|
|
24614
|
-
if (writer.machineMonitorQueued) return;
|
|
24615
|
-
writer.machineMonitorQueued = true;
|
|
24616
|
-
writer.queue.push({
|
|
24617
|
-
kind: "machine-monitor"
|
|
24618
|
-
});
|
|
24619
|
-
this.scheduleDataPump(writer);
|
|
24620
|
-
}
|
|
24621
|
-
isWriterActive(writer) {
|
|
24622
|
-
return !this.disposed && this.writers.get(writer.connection.id) === writer;
|
|
24623
|
-
}
|
|
24624
|
-
cancelScheduledDataPump(writer) {
|
|
24625
|
-
writer.cancelScheduledPump?.();
|
|
24626
|
-
writer.cancelScheduledPump = null;
|
|
24627
|
-
writer.pumpScheduled = false;
|
|
24628
|
-
}
|
|
24629
|
-
hasPendingDataWork(writer) {
|
|
24630
|
-
return writer.pendingFrames.length > 0 || writer.queue.length > 0;
|
|
24631
|
-
}
|
|
24632
|
-
scheduleDataPump(writer) {
|
|
24633
|
-
if (!this.isWriterActive(writer) || writer.blocked || writer.pumping || writer.pumpScheduled || !this.hasPendingDataWork(writer)) {
|
|
24634
|
-
return;
|
|
24635
|
-
}
|
|
24636
|
-
writer.pumpScheduled = true;
|
|
24637
|
-
writer.cancelScheduledPump = this.scheduler.scheduleDataWork(() => {
|
|
24638
|
-
writer.pumpScheduled = false;
|
|
24639
|
-
writer.cancelScheduledPump = null;
|
|
24640
|
-
return this.pumpWriter(writer).catch((error2) => {
|
|
24641
|
-
this.options.onError?.(error2, "pumpWriter");
|
|
24642
|
-
});
|
|
24643
|
-
});
|
|
24644
|
-
}
|
|
24645
|
-
async pumpWriter(writer) {
|
|
24646
|
-
if (!this.isWriterActive(writer) || writer.pumping || writer.blocked) {
|
|
24647
|
-
return;
|
|
24648
|
-
}
|
|
24649
|
-
writer.pumping = true;
|
|
24650
|
-
try {
|
|
24651
|
-
const pendingFrame = writer.pendingFrames.shift();
|
|
24652
|
-
if (pendingFrame) {
|
|
24653
|
-
this.writeFrame(writer, pendingFrame);
|
|
24654
|
-
return;
|
|
24655
|
-
}
|
|
24656
|
-
const task = writer.queue.shift();
|
|
24657
|
-
if (!task) {
|
|
24658
|
-
return;
|
|
24659
|
-
}
|
|
24660
|
-
if (task.kind === "sync") {
|
|
24661
|
-
writer.queuedSyncKeys.delete(syncTaskKey(task.roomKey, task.peerId));
|
|
24662
|
-
} else if (task.kind === "presence") {
|
|
24663
|
-
writer.presenceQueued = false;
|
|
24664
|
-
} else if (task.kind === "machine-monitor") {
|
|
24665
|
-
writer.machineMonitorQueued = false;
|
|
24666
|
-
}
|
|
24667
|
-
try {
|
|
24668
|
-
const frames = await this.buildFrames(writer, task);
|
|
24669
|
-
if (!this.isWriterActive(writer)) return;
|
|
24670
|
-
writer.pendingFrames.push(...frames);
|
|
24671
|
-
} catch (error2) {
|
|
24672
|
-
this.options.onError?.(error2, `buildFrames:${task.kind}`);
|
|
24673
|
-
}
|
|
24674
|
-
if (!this.isWriterActive(writer) || writer.blocked) {
|
|
24675
|
-
return;
|
|
24676
|
-
}
|
|
24677
|
-
const firstFrame = writer.pendingFrames.shift();
|
|
24678
|
-
if (firstFrame) {
|
|
24679
|
-
this.writeFrame(writer, firstFrame);
|
|
24680
|
-
}
|
|
24681
|
-
} finally {
|
|
24682
|
-
writer.pumping = false;
|
|
24683
|
-
if (this.isWriterActive(writer)) {
|
|
24684
|
-
this.scheduleDataPump(writer);
|
|
24685
|
-
}
|
|
24686
|
-
}
|
|
24687
|
-
}
|
|
24688
|
-
writeFrame(writer, frame2) {
|
|
24689
|
-
const accepted = writer.connection.send(frame2);
|
|
24690
|
-
if (accepted === false && writer.unsubscribeDrain) {
|
|
24691
|
-
writer.blocked = true;
|
|
24692
|
-
}
|
|
24693
|
-
}
|
|
24694
|
-
async buildFrames(writer, task) {
|
|
24695
|
-
switch (task.kind) {
|
|
24696
|
-
case "message":
|
|
24697
|
-
return [
|
|
24698
|
-
task.message
|
|
24699
|
-
];
|
|
24700
|
-
case "presence": {
|
|
24701
|
-
const source = this.options.presenceSource;
|
|
24702
|
-
if (!source) {
|
|
24703
|
-
return [];
|
|
24704
|
-
}
|
|
24705
|
-
const encoded = source.encodeLocalOrigin();
|
|
24706
|
-
if (encoded.length === 0) {
|
|
24707
|
-
return [];
|
|
24708
|
-
}
|
|
24709
|
-
return [
|
|
24710
|
-
{
|
|
24711
|
-
type: "presence",
|
|
24712
|
-
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
24713
|
-
workspaceId: this.options.workspaceId,
|
|
24714
|
-
dataBase64: bytesToBase64(encoded)
|
|
24715
|
-
}
|
|
24716
|
-
];
|
|
24717
|
-
}
|
|
24718
|
-
case "machine-monitor": {
|
|
24719
|
-
const source = this.options.machineMonitorSource;
|
|
24720
|
-
if (!source) return [];
|
|
24721
|
-
const encoded = source.encodeAll();
|
|
24722
|
-
if (encoded.length === 0) return [];
|
|
24723
|
-
return [
|
|
24724
|
-
{
|
|
24725
|
-
type: "machine-monitor",
|
|
24726
|
-
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
24727
|
-
workspaceId: this.options.workspaceId,
|
|
24728
|
-
dataBase64: bytesToBase64(encoded)
|
|
24729
|
-
}
|
|
24730
|
-
];
|
|
24731
|
-
}
|
|
24732
|
-
case "join-reply":
|
|
24733
|
-
return await this.buildJoinReplyFrames(writer, task);
|
|
24734
|
-
case "sync":
|
|
24735
|
-
return await this.buildSyncFrames(writer, task.roomKey, task.peerId, null);
|
|
24736
|
-
}
|
|
24737
|
-
const exhaustive = task;
|
|
24738
|
-
throw new Error(`Unsupported local data-plane writer task: ${String(exhaustive)}`);
|
|
24739
|
-
}
|
|
24740
|
-
async buildJoinReplyFrames(writer, task) {
|
|
24741
|
-
const entry = this.rooms.get(task.roomKey);
|
|
24742
|
-
if (!entry) {
|
|
24743
|
-
return [];
|
|
24744
|
-
}
|
|
24745
|
-
const subscriber = entry.subscribers.get(task.peerId);
|
|
24746
|
-
if (!subscriber || subscriber.connection.id !== writer.connection.id) {
|
|
24747
|
-
return [];
|
|
24748
|
-
}
|
|
24749
|
-
if (subscriber.latestJoinRequestId !== task.requestId) {
|
|
24750
|
-
return [];
|
|
24751
|
-
}
|
|
24752
|
-
return await this.buildSyncFrames(writer, task.roomKey, task.peerId, task.requestId);
|
|
24753
|
-
}
|
|
24754
|
-
async buildSyncFrames(writer, key2, peerId, joinRequestId) {
|
|
24755
|
-
const entry = this.rooms.get(key2);
|
|
24756
|
-
if (!entry) {
|
|
24757
|
-
return [];
|
|
24758
|
-
}
|
|
24759
|
-
const subscriber = entry.subscribers.get(peerId);
|
|
24760
|
-
if (!subscriber || subscriber.connection.id !== writer.connection.id) {
|
|
24761
|
-
return [];
|
|
24762
|
-
}
|
|
24763
|
-
if (entry.scope === "doc") {
|
|
24764
|
-
const docSubscriber = subscriber;
|
|
24765
|
-
const serverVV = entry.doc.oplogVersion();
|
|
24766
|
-
const delta = entry.doc.export({
|
|
24767
|
-
mode: "update",
|
|
24768
|
-
from: docSubscriber.lastSentVV
|
|
24769
|
-
});
|
|
24770
|
-
const serverVersion2 = bytesToBase64(serverVV.encode());
|
|
24771
|
-
const dataBase64 = delta.length > 0 ? bytesToBase64(delta) : null;
|
|
24772
|
-
docSubscriber.lastSentVV = serverVV;
|
|
24773
|
-
if (dataBase64 && dataBase64.length > this.maxPayloadBytes) {
|
|
24774
|
-
const chunkPayloads = buildDocUpdateChunkPayloads(dataBase64, this.maxPayloadBytes, createDocUpdateTransferId());
|
|
24775
|
-
const frames2 = [];
|
|
24776
|
-
if (joinRequestId !== null) {
|
|
24777
|
-
frames2.push({
|
|
24778
|
-
type: "joined",
|
|
24779
|
-
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
24780
|
-
workspaceId: this.options.workspaceId,
|
|
24781
|
-
peerId,
|
|
24782
|
-
requestId: joinRequestId,
|
|
24783
|
-
room: entry.room,
|
|
24784
|
-
serverVersion: serverVersion2
|
|
24785
|
-
});
|
|
24786
|
-
}
|
|
24787
|
-
for (const payload of chunkPayloads) {
|
|
24788
|
-
frames2.push({
|
|
24789
|
-
type: "update",
|
|
24790
|
-
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
24791
|
-
workspaceId: this.options.workspaceId,
|
|
24792
|
-
peerId,
|
|
24793
|
-
room: entry.room,
|
|
24794
|
-
serverVersion: serverVersion2,
|
|
24795
|
-
payload
|
|
24796
|
-
});
|
|
24797
|
-
}
|
|
24798
|
-
return frames2;
|
|
24799
|
-
}
|
|
24800
|
-
if (joinRequestId !== null) {
|
|
24801
|
-
return [
|
|
24802
|
-
{
|
|
24803
|
-
type: "joined",
|
|
24804
|
-
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
24805
|
-
workspaceId: this.options.workspaceId,
|
|
24806
|
-
peerId,
|
|
24807
|
-
requestId: joinRequestId,
|
|
24808
|
-
room: entry.room,
|
|
24809
|
-
serverVersion: serverVersion2,
|
|
24810
|
-
...dataBase64 ? {
|
|
24811
|
-
payload: {
|
|
24812
|
-
kind: "doc-update",
|
|
24813
|
-
dataBase64
|
|
24814
|
-
}
|
|
24815
|
-
} : {}
|
|
24816
|
-
}
|
|
24817
|
-
];
|
|
24818
|
-
}
|
|
24819
|
-
if (!dataBase64) {
|
|
24820
|
-
return [];
|
|
24821
|
-
}
|
|
24822
|
-
return [
|
|
24823
|
-
{
|
|
24824
|
-
type: "update",
|
|
24825
|
-
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
24826
|
-
workspaceId: this.options.workspaceId,
|
|
24827
|
-
peerId,
|
|
24828
|
-
room: entry.room,
|
|
24829
|
-
serverVersion: serverVersion2,
|
|
24830
|
-
payload: {
|
|
24831
|
-
kind: "doc-update",
|
|
24832
|
-
dataBase64
|
|
24833
|
-
}
|
|
24834
|
-
}
|
|
24835
|
-
];
|
|
24836
|
-
}
|
|
24837
|
-
const flockSubscriber = subscriber;
|
|
24838
|
-
const have = entry.flock.version();
|
|
24839
|
-
const bundle = await entry.flock.exportJson(flockSubscriber.lastSentVersion);
|
|
24840
|
-
const currentEntry = this.rooms.get(key2);
|
|
24841
|
-
const currentSubscriber = currentEntry?.scope === "flock" ? currentEntry.subscribers.get(peerId) : void 0;
|
|
24842
|
-
if (currentEntry !== entry || currentSubscriber !== flockSubscriber || currentSubscriber.connection.id !== writer.connection.id || joinRequestId !== null && currentSubscriber.latestJoinRequestId !== joinRequestId) {
|
|
24843
|
-
return [];
|
|
24844
|
-
}
|
|
24845
|
-
flockSubscriber.lastSentVersion = mergeFlockVersions(flockSubscriber.lastSentVersion, have);
|
|
24846
|
-
const serverVersion = encodeFlockVersion(have);
|
|
24847
|
-
if (isEmptyFlockBundle(bundle)) {
|
|
24848
|
-
if (joinRequestId !== null) {
|
|
24849
|
-
return [
|
|
24850
|
-
{
|
|
24851
|
-
type: "joined",
|
|
24852
|
-
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
24853
|
-
workspaceId: this.options.workspaceId,
|
|
24854
|
-
peerId,
|
|
24855
|
-
requestId: joinRequestId,
|
|
24856
|
-
room: entry.room,
|
|
24857
|
-
serverVersion
|
|
24858
|
-
}
|
|
24859
|
-
];
|
|
24860
|
-
}
|
|
24861
|
-
return [];
|
|
24862
|
-
}
|
|
24863
|
-
const chunks = chunkFlockBundle(bundle, this.maxPayloadBytes);
|
|
24864
|
-
if (!chunks) {
|
|
24865
|
-
entry.subscribers.delete(peerId);
|
|
24866
|
-
this.releaseRoomIfEmpty(key2, entry);
|
|
24867
|
-
return [
|
|
24868
|
-
this.payloadTooLargeError(peerId, entry.room, joinRequestId ?? void 0)
|
|
24869
|
-
];
|
|
24870
|
-
}
|
|
24871
|
-
const frames = [];
|
|
24872
|
-
for (const [index, chunk] of chunks.entries()) {
|
|
24873
|
-
if (joinRequestId !== null && index === 0) {
|
|
24874
|
-
frames.push({
|
|
24875
|
-
type: "joined",
|
|
24876
|
-
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
24877
|
-
workspaceId: this.options.workspaceId,
|
|
24878
|
-
peerId,
|
|
24879
|
-
requestId: joinRequestId,
|
|
24880
|
-
room: entry.room,
|
|
24881
|
-
serverVersion,
|
|
24882
|
-
payload: {
|
|
24883
|
-
kind: "flock-json",
|
|
24884
|
-
bundle: chunk
|
|
24885
|
-
}
|
|
24886
|
-
});
|
|
24887
|
-
continue;
|
|
24888
|
-
}
|
|
24889
|
-
frames.push({
|
|
24890
|
-
type: "update",
|
|
24891
|
-
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
24892
|
-
workspaceId: this.options.workspaceId,
|
|
24893
|
-
peerId,
|
|
24894
|
-
room: entry.room,
|
|
24895
|
-
serverVersion,
|
|
24896
|
-
payload: {
|
|
24897
|
-
kind: "flock-json",
|
|
24898
|
-
bundle: chunk
|
|
24899
|
-
}
|
|
24900
|
-
});
|
|
24901
|
-
}
|
|
24902
|
-
return frames;
|
|
24903
|
-
}
|
|
24904
|
-
payloadTooLargeError(peerId, room, requestId) {
|
|
24905
|
-
return {
|
|
24906
|
-
type: "error",
|
|
24907
|
-
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
24908
|
-
workspaceId: this.options.workspaceId,
|
|
24909
|
-
code: LOCAL_LORO_DATA_PLANE_PAYLOAD_TOO_LARGE,
|
|
24910
|
-
message: "sync payload exceeds the local data-plane frame budget",
|
|
24911
|
-
peerId,
|
|
24912
|
-
room,
|
|
24913
|
-
...requestId ? {
|
|
24914
|
-
requestId
|
|
24915
|
-
} : {},
|
|
24916
|
-
terminal: true
|
|
24917
|
-
};
|
|
24918
|
-
}
|
|
24919
|
-
unsubscribePeer(peerId, key2) {
|
|
24920
|
-
const entry = this.rooms.get(key2);
|
|
24921
|
-
if (!entry) {
|
|
24922
|
-
return;
|
|
24923
|
-
}
|
|
24924
|
-
entry.subscribers.delete(peerId);
|
|
24925
|
-
if (entry.scope === "doc") {
|
|
24926
|
-
entry.uploadAssemblers.delete(peerId);
|
|
24927
|
-
}
|
|
24928
|
-
this.releaseRoomIfEmpty(key2, entry);
|
|
24929
|
-
}
|
|
24930
|
-
releaseRoomIfEmpty(key2, entry) {
|
|
24931
|
-
if (entry.subscribers.size > 0 || this.rooms.get(key2) !== entry) {
|
|
24932
|
-
return;
|
|
24933
|
-
}
|
|
24934
|
-
entry.unsubscribe();
|
|
24935
|
-
this.rooms.delete(key2);
|
|
24936
|
-
this.notifyDocRoomLeave(entry.room);
|
|
24937
|
-
this.notifyFlockRoomLeave(entry.room);
|
|
24938
|
-
}
|
|
24939
|
-
sendError(connection2, error2) {
|
|
24940
|
-
this.enqueueMessage(connection2, {
|
|
24941
|
-
type: "error",
|
|
24942
|
-
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
24943
|
-
workspaceId: this.options.workspaceId,
|
|
24944
|
-
code: error2.code,
|
|
24945
|
-
...error2.message ? {
|
|
24946
|
-
message: error2.message
|
|
24947
|
-
} : {},
|
|
24948
|
-
...error2.peerId ? {
|
|
24949
|
-
peerId: error2.peerId
|
|
24950
|
-
} : {},
|
|
24951
|
-
...error2.requestId ? {
|
|
24952
|
-
requestId: error2.requestId
|
|
24953
|
-
} : {},
|
|
24954
|
-
...error2.room ? {
|
|
24955
|
-
room: error2.room
|
|
24956
|
-
} : {},
|
|
24957
|
-
...error2.terminal ? {
|
|
24958
|
-
terminal: true
|
|
24959
|
-
} : {}
|
|
24960
|
-
});
|
|
24961
|
-
}
|
|
24962
|
-
}
|
|
24963
|
-
function decodeVersion(encoded) {
|
|
24964
|
-
if (!encoded) {
|
|
24965
|
-
return new VersionVector(null);
|
|
24966
|
-
}
|
|
24967
|
-
return VersionVector.decode(base64ToBytes(encoded));
|
|
24968
|
-
}
|
|
24969
|
-
function errorMessage(error2) {
|
|
24970
|
-
return error2 instanceof Error ? error2.message : String(error2);
|
|
24971
|
-
}
|
|
24972
24108
|
const DEFAULT_SAMPLE_RATES = {
|
|
24973
24109
|
A: 1,
|
|
24974
24110
|
B: 1,
|
|
@@ -25608,7 +24744,7 @@ ${peerId}`;
|
|
|
25608
24744
|
}
|
|
25609
24745
|
const runtimeEnv = getRuntimeEnv();
|
|
25610
24746
|
const apiKey = resolveApiKey();
|
|
25611
|
-
const release = `${name$2}@${version$
|
|
24747
|
+
const release = `${name$2}@${version$9}`;
|
|
25612
24748
|
const distinctId = resolveDistinctId();
|
|
25613
24749
|
const errorReportingEnabled = runtimeEnv !== "dev" && !!apiKey;
|
|
25614
24750
|
let client$1 = null;
|
|
@@ -25620,9 +24756,9 @@ ${peerId}`;
|
|
|
25620
24756
|
}
|
|
25621
24757
|
const baseExceptionProps = {
|
|
25622
24758
|
$lib: "lody-cli",
|
|
25623
|
-
$lib_version: version$
|
|
24759
|
+
$lib_version: version$9,
|
|
25624
24760
|
platform: "cli",
|
|
25625
|
-
app_version: version$
|
|
24761
|
+
app_version: version$9,
|
|
25626
24762
|
env: runtimeEnv,
|
|
25627
24763
|
release,
|
|
25628
24764
|
machine_id: distinctId
|
|
@@ -26314,7 +25450,7 @@ ${peerId}`;
|
|
|
26314
25450
|
if (hasRequiredCommand$1) return command$1;
|
|
26315
25451
|
hasRequiredCommand$1 = 1;
|
|
26316
25452
|
const EventEmitter2 = require$$0$4.EventEmitter;
|
|
26317
|
-
const childProcess =
|
|
25453
|
+
const childProcess = LE__default;
|
|
26318
25454
|
const path2 = path__default;
|
|
26319
25455
|
const fs2 = fs__default$1;
|
|
26320
25456
|
const process2 = process$2;
|
|
@@ -31232,9 +30368,9 @@ ${originalIndentation}`;
|
|
|
31232
30368
|
})(common$2);
|
|
31233
30369
|
return common$2;
|
|
31234
30370
|
}
|
|
31235
|
-
const version$
|
|
30371
|
+
const version$8 = "3.19.0";
|
|
31236
30372
|
const require$$2$3 = {
|
|
31237
|
-
version: version$
|
|
30373
|
+
version: version$8
|
|
31238
30374
|
};
|
|
31239
30375
|
var transports = {};
|
|
31240
30376
|
var winstonTransport = {
|
|
@@ -31256,7 +30392,7 @@ ${originalIndentation}`;
|
|
|
31256
30392
|
function requireStream$3() {
|
|
31257
30393
|
if (hasRequiredStream$3) return stream$3;
|
|
31258
30394
|
hasRequiredStream$3 = 1;
|
|
31259
|
-
stream$3 =
|
|
30395
|
+
stream$3 = Zr;
|
|
31260
30396
|
return stream$3;
|
|
31261
30397
|
}
|
|
31262
30398
|
var destroy_1;
|
|
@@ -34847,7 +33983,7 @@ ${originalIndentation}`;
|
|
|
34847
33983
|
if (hasRequiredReadable$1) return readable$1.exports;
|
|
34848
33984
|
hasRequiredReadable$1 = 1;
|
|
34849
33985
|
(function(module2, exports$1) {
|
|
34850
|
-
var Stream =
|
|
33986
|
+
var Stream = Zr;
|
|
34851
33987
|
if (process.env.READABLE_STREAM === "disable" && Stream) {
|
|
34852
33988
|
module2.exports = Stream.Readable;
|
|
34853
33989
|
Object.assign(module2.exports, Stream);
|
|
@@ -37621,7 +36757,7 @@ ${originalIndentation}`;
|
|
|
37621
36757
|
if (hasRequiredDevelopment) return development;
|
|
37622
36758
|
hasRequiredDevelopment = 1;
|
|
37623
36759
|
var create = requireDiagnostics$1();
|
|
37624
|
-
var tty2 = require$$1$
|
|
36760
|
+
var tty2 = require$$1$2.isatty(1);
|
|
37625
36761
|
var diagnostics2 = create(function dev(namespace, options) {
|
|
37626
36762
|
options = options || {};
|
|
37627
36763
|
options.colors = "colors" in options ? options.colors : tty2;
|
|
@@ -37656,7 +36792,7 @@ ${originalIndentation}`;
|
|
|
37656
36792
|
if (hasRequiredTailFile) return tailFile;
|
|
37657
36793
|
hasRequiredTailFile = 1;
|
|
37658
36794
|
const fs2 = fs__default;
|
|
37659
|
-
const { StringDecoder: StringDecoder2 } = require$$1$
|
|
36795
|
+
const { StringDecoder: StringDecoder2 } = require$$1$3;
|
|
37660
36796
|
const { Stream } = requireReadable$1();
|
|
37661
36797
|
function noop2() {
|
|
37662
36798
|
}
|
|
@@ -37753,7 +36889,7 @@ ${originalIndentation}`;
|
|
|
37753
36889
|
const fs2 = fs__default;
|
|
37754
36890
|
const path2 = path__default$1;
|
|
37755
36891
|
const asyncSeries = requireSeries();
|
|
37756
|
-
const zlib =
|
|
36892
|
+
const zlib = $s__default;
|
|
37757
36893
|
const { MESSAGE } = requireTripleBeam();
|
|
37758
36894
|
const { Stream, PassThrough: PassThrough2 } = requireReadable$1();
|
|
37759
36895
|
const TransportStream = requireWinstonTransport();
|
|
@@ -44690,10 +43826,10 @@ ${originalIndentation}`;
|
|
|
44690
43826
|
const os2 = os__default$1;
|
|
44691
43827
|
const path2 = path__default$1;
|
|
44692
43828
|
const util2 = require$$0$5;
|
|
44693
|
-
const zlib =
|
|
43829
|
+
const zlib = $s__default;
|
|
44694
43830
|
const hash2 = requireObjectHash();
|
|
44695
43831
|
const MESSAGE = requireTripleBeam().MESSAGE;
|
|
44696
|
-
const PassThrough2 =
|
|
43832
|
+
const PassThrough2 = Zr.PassThrough;
|
|
44697
43833
|
const Transport = requireWinstonTransport();
|
|
44698
43834
|
const loggerDefaults = {
|
|
44699
43835
|
json: false,
|
|
@@ -45145,7 +44281,7 @@ ${value.slice(value.length - safeTailChars)}`;
|
|
|
45145
44281
|
return files;
|
|
45146
44282
|
}
|
|
45147
44283
|
async function readDailyLogFile(file2) {
|
|
45148
|
-
const raw2 = await
|
|
44284
|
+
const raw2 = await jt__default.readFile(file2.path);
|
|
45149
44285
|
if (!file2.compressed) return raw2.toString("utf8");
|
|
45150
44286
|
return (await gunzip(raw2)).toString("utf8");
|
|
45151
44287
|
}
|
|
@@ -63849,6 +62985,907 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
|
|
|
63849
62985
|
function getDisableValidationMakeOption(options) {
|
|
63850
62986
|
return isBoolean(options) ? options : options?.disableValidation ?? false;
|
|
63851
62987
|
}
|
|
62988
|
+
const scheduleDataWorkNextTurn = (work) => {
|
|
62989
|
+
const handle = setTimeout(work, 0);
|
|
62990
|
+
return () => clearTimeout(handle);
|
|
62991
|
+
};
|
|
62992
|
+
const createLocalLoroDataPlaneScheduler = (scheduleTurn = scheduleDataWorkNextTurn) => {
|
|
62993
|
+
const queue2 = [];
|
|
62994
|
+
let running2 = false;
|
|
62995
|
+
let cancelScheduledTurn = null;
|
|
62996
|
+
const takeNext = () => {
|
|
62997
|
+
for (; ; ) {
|
|
62998
|
+
const work = queue2.shift();
|
|
62999
|
+
if (!work) return null;
|
|
63000
|
+
if (!work.cancelled) return work;
|
|
63001
|
+
}
|
|
63002
|
+
};
|
|
63003
|
+
const requestRun = () => {
|
|
63004
|
+
if (running2 || cancelScheduledTurn || queue2.length === 0) return;
|
|
63005
|
+
cancelScheduledTurn = scheduleTurn(() => {
|
|
63006
|
+
cancelScheduledTurn = null;
|
|
63007
|
+
const work = takeNext();
|
|
63008
|
+
if (!work) {
|
|
63009
|
+
return;
|
|
63010
|
+
}
|
|
63011
|
+
running2 = true;
|
|
63012
|
+
void Promise.resolve().then(work.run).finally(() => {
|
|
63013
|
+
running2 = false;
|
|
63014
|
+
requestRun();
|
|
63015
|
+
});
|
|
63016
|
+
});
|
|
63017
|
+
};
|
|
63018
|
+
return {
|
|
63019
|
+
scheduleDataWork: (run2) => {
|
|
63020
|
+
const work = {
|
|
63021
|
+
run: run2,
|
|
63022
|
+
cancelled: false
|
|
63023
|
+
};
|
|
63024
|
+
queue2.push(work);
|
|
63025
|
+
requestRun();
|
|
63026
|
+
return () => {
|
|
63027
|
+
work.cancelled = true;
|
|
63028
|
+
};
|
|
63029
|
+
}
|
|
63030
|
+
};
|
|
63031
|
+
};
|
|
63032
|
+
function syncTaskKey(key2, peerId) {
|
|
63033
|
+
return `${key2}
|
|
63034
|
+
${peerId}`;
|
|
63035
|
+
}
|
|
63036
|
+
class LocalLoroDataPlaneServer {
|
|
63037
|
+
constructor(options) {
|
|
63038
|
+
this.options = options;
|
|
63039
|
+
this.scheduler = options.scheduler ?? createLocalLoroDataPlaneScheduler();
|
|
63040
|
+
this.docRoomJoinHandler = options.onDocRoomJoin ?? null;
|
|
63041
|
+
this.docRoomLeaveHandler = options.onDocRoomLeave ?? null;
|
|
63042
|
+
this.flockRoomJoinHandler = options.onFlockRoomJoin ?? null;
|
|
63043
|
+
this.flockRoomLeaveHandler = options.onFlockRoomLeave ?? null;
|
|
63044
|
+
if (options.presenceSource) {
|
|
63045
|
+
this.presenceUnsubscribe = options.presenceSource.subscribeLocalOrigin(() => this.broadcastPresence());
|
|
63046
|
+
}
|
|
63047
|
+
if (options.machineMonitorSource) {
|
|
63048
|
+
this.machineMonitorUnsubscribe = options.machineMonitorSource.subscribe(() => this.broadcastMachineMonitor());
|
|
63049
|
+
}
|
|
63050
|
+
}
|
|
63051
|
+
rooms = /* @__PURE__ */ new Map();
|
|
63052
|
+
resolveInFlight = /* @__PURE__ */ new Map();
|
|
63053
|
+
roomGenerations = /* @__PURE__ */ new Map();
|
|
63054
|
+
presenceReceivers = /* @__PURE__ */ new Map();
|
|
63055
|
+
machineMonitorReceivers = /* @__PURE__ */ new Map();
|
|
63056
|
+
writers = /* @__PURE__ */ new Map();
|
|
63057
|
+
presenceUnsubscribe = null;
|
|
63058
|
+
machineMonitorUnsubscribe = null;
|
|
63059
|
+
docRoomJoinHandler = null;
|
|
63060
|
+
docRoomLeaveHandler = null;
|
|
63061
|
+
flockRoomJoinHandler = null;
|
|
63062
|
+
flockRoomLeaveHandler = null;
|
|
63063
|
+
scheduler;
|
|
63064
|
+
disposed = false;
|
|
63065
|
+
setDocRoomJoinHandler(handler) {
|
|
63066
|
+
this.docRoomJoinHandler = handler;
|
|
63067
|
+
}
|
|
63068
|
+
setDocRoomLeaveHandler(handler) {
|
|
63069
|
+
this.docRoomLeaveHandler = handler;
|
|
63070
|
+
}
|
|
63071
|
+
setFlockRoomJoinHandler(handler) {
|
|
63072
|
+
this.flockRoomJoinHandler = handler;
|
|
63073
|
+
}
|
|
63074
|
+
setFlockRoomLeaveHandler(handler) {
|
|
63075
|
+
this.flockRoomLeaveHandler = handler;
|
|
63076
|
+
}
|
|
63077
|
+
publishRoomStatus(room, status) {
|
|
63078
|
+
const entry = this.rooms.get(roomKey(room));
|
|
63079
|
+
if (!entry) {
|
|
63080
|
+
return;
|
|
63081
|
+
}
|
|
63082
|
+
for (const subscriber of entry.subscribers.values()) {
|
|
63083
|
+
this.enqueueMessage(subscriber.connection, {
|
|
63084
|
+
type: "room-status",
|
|
63085
|
+
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
63086
|
+
workspaceId: this.options.workspaceId,
|
|
63087
|
+
peerId: subscriber.peerId,
|
|
63088
|
+
room,
|
|
63089
|
+
status
|
|
63090
|
+
});
|
|
63091
|
+
}
|
|
63092
|
+
}
|
|
63093
|
+
invalidateDocRoom(docId) {
|
|
63094
|
+
const room = {
|
|
63095
|
+
scope: "doc",
|
|
63096
|
+
docId
|
|
63097
|
+
};
|
|
63098
|
+
const key2 = roomKey(room);
|
|
63099
|
+
this.roomGenerations.set(key2, (this.roomGenerations.get(key2) ?? 0) + 1);
|
|
63100
|
+
const entry = this.rooms.get(key2);
|
|
63101
|
+
if (!entry || entry.scope !== "doc") {
|
|
63102
|
+
return;
|
|
63103
|
+
}
|
|
63104
|
+
this.dropQueuedRoomWork(key2);
|
|
63105
|
+
this.publishRoomStatus(room, "disconnected");
|
|
63106
|
+
entry.unsubscribe();
|
|
63107
|
+
entry.subscribers.clear();
|
|
63108
|
+
entry.uploadAssemblers.clear();
|
|
63109
|
+
this.rooms.delete(key2);
|
|
63110
|
+
}
|
|
63111
|
+
dropQueuedRoomWork(key2) {
|
|
63112
|
+
for (const writer of this.writers.values()) {
|
|
63113
|
+
writer.queue = writer.queue.filter((task) => !((task.kind === "sync" || task.kind === "join-reply") && task.roomKey === key2));
|
|
63114
|
+
for (const taskKey of [
|
|
63115
|
+
...writer.queuedSyncKeys
|
|
63116
|
+
]) {
|
|
63117
|
+
if (taskKey.startsWith(`${key2}
|
|
63118
|
+
`)) {
|
|
63119
|
+
writer.queuedSyncKeys.delete(taskKey);
|
|
63120
|
+
}
|
|
63121
|
+
}
|
|
63122
|
+
}
|
|
63123
|
+
}
|
|
63124
|
+
get maxPayloadBytes() {
|
|
63125
|
+
return this.options.maxPayloadBytes ?? LOCAL_LORO_DATA_PLANE_MAX_PAYLOAD_BYTES;
|
|
63126
|
+
}
|
|
63127
|
+
async handleMessage(connection2, message) {
|
|
63128
|
+
if (this.disposed) {
|
|
63129
|
+
this.sendError(connection2, {
|
|
63130
|
+
code: "workspace_runtime_unavailable",
|
|
63131
|
+
peerId: message.peerId,
|
|
63132
|
+
requestId: message.type === "join" ? message.requestId : void 0
|
|
63133
|
+
});
|
|
63134
|
+
return;
|
|
63135
|
+
}
|
|
63136
|
+
if (message.workspaceId !== this.options.workspaceId) {
|
|
63137
|
+
this.sendError(connection2, {
|
|
63138
|
+
code: "workspace_mismatch",
|
|
63139
|
+
peerId: message.peerId,
|
|
63140
|
+
requestId: message.type === "join" ? message.requestId : void 0
|
|
63141
|
+
});
|
|
63142
|
+
return;
|
|
63143
|
+
}
|
|
63144
|
+
try {
|
|
63145
|
+
this.registerPresenceReceiver(connection2);
|
|
63146
|
+
switch (message.type) {
|
|
63147
|
+
case "join":
|
|
63148
|
+
await this.handleJoin(connection2, message);
|
|
63149
|
+
return;
|
|
63150
|
+
case "update":
|
|
63151
|
+
await this.handleUpdate(connection2, message);
|
|
63152
|
+
return;
|
|
63153
|
+
case "leave":
|
|
63154
|
+
this.unsubscribePeer(message.peerId, roomKey(message.room));
|
|
63155
|
+
return;
|
|
63156
|
+
case "detach":
|
|
63157
|
+
this.detachPeer(message.peerId);
|
|
63158
|
+
return;
|
|
63159
|
+
case "machine-monitor":
|
|
63160
|
+
this.registerMachineMonitorReceiver(connection2);
|
|
63161
|
+
this.options.machineMonitorSource?.apply(base64ToBytes(message.dataBase64));
|
|
63162
|
+
return;
|
|
63163
|
+
}
|
|
63164
|
+
} catch (error2) {
|
|
63165
|
+
this.options.onError?.(error2, `handleMessage:${message.type}`);
|
|
63166
|
+
this.sendError(connection2, {
|
|
63167
|
+
code: "data_plane_error",
|
|
63168
|
+
message: errorMessage(error2),
|
|
63169
|
+
peerId: message.peerId,
|
|
63170
|
+
requestId: message.type === "join" ? message.requestId : void 0,
|
|
63171
|
+
room: "room" in message ? message.room : void 0
|
|
63172
|
+
});
|
|
63173
|
+
}
|
|
63174
|
+
}
|
|
63175
|
+
registerPresenceReceiver(connection2) {
|
|
63176
|
+
if (!this.options.presenceSource || this.presenceReceivers.has(connection2.id)) {
|
|
63177
|
+
return;
|
|
63178
|
+
}
|
|
63179
|
+
this.presenceReceivers.set(connection2.id, connection2);
|
|
63180
|
+
this.enqueuePresence(connection2);
|
|
63181
|
+
}
|
|
63182
|
+
broadcastPresence() {
|
|
63183
|
+
if (this.disposed) {
|
|
63184
|
+
return;
|
|
63185
|
+
}
|
|
63186
|
+
for (const connection2 of this.presenceReceivers.values()) {
|
|
63187
|
+
this.enqueuePresence(connection2);
|
|
63188
|
+
}
|
|
63189
|
+
}
|
|
63190
|
+
registerMachineMonitorReceiver(connection2) {
|
|
63191
|
+
if (!this.options.machineMonitorSource || this.machineMonitorReceivers.has(connection2.id)) {
|
|
63192
|
+
return;
|
|
63193
|
+
}
|
|
63194
|
+
this.machineMonitorReceivers.set(connection2.id, connection2);
|
|
63195
|
+
this.enqueueMachineMonitor(connection2);
|
|
63196
|
+
}
|
|
63197
|
+
broadcastMachineMonitor() {
|
|
63198
|
+
if (this.disposed) return;
|
|
63199
|
+
for (const connection2 of this.machineMonitorReceivers.values()) {
|
|
63200
|
+
this.enqueueMachineMonitor(connection2);
|
|
63201
|
+
}
|
|
63202
|
+
}
|
|
63203
|
+
dispose() {
|
|
63204
|
+
this.disposed = true;
|
|
63205
|
+
this.presenceUnsubscribe?.();
|
|
63206
|
+
this.presenceUnsubscribe = null;
|
|
63207
|
+
this.machineMonitorUnsubscribe?.();
|
|
63208
|
+
this.machineMonitorUnsubscribe = null;
|
|
63209
|
+
this.presenceReceivers.clear();
|
|
63210
|
+
this.machineMonitorReceivers.clear();
|
|
63211
|
+
for (const entry of this.rooms.values()) {
|
|
63212
|
+
entry.unsubscribe();
|
|
63213
|
+
this.notifyDocRoomLeave(entry.room);
|
|
63214
|
+
this.notifyFlockRoomLeave(entry.room);
|
|
63215
|
+
entry.subscribers.clear();
|
|
63216
|
+
}
|
|
63217
|
+
this.rooms.clear();
|
|
63218
|
+
this.roomGenerations.clear();
|
|
63219
|
+
for (const writer of this.writers.values()) {
|
|
63220
|
+
this.cancelScheduledDataPump(writer);
|
|
63221
|
+
writer.unsubscribeDrain?.();
|
|
63222
|
+
writer.queue.length = 0;
|
|
63223
|
+
writer.pendingFrames.length = 0;
|
|
63224
|
+
}
|
|
63225
|
+
this.writers.clear();
|
|
63226
|
+
}
|
|
63227
|
+
handleDisconnect(connectionId) {
|
|
63228
|
+
this.presenceReceivers.delete(connectionId);
|
|
63229
|
+
this.machineMonitorReceivers.delete(connectionId);
|
|
63230
|
+
const writer = this.writers.get(connectionId);
|
|
63231
|
+
if (writer) {
|
|
63232
|
+
this.cancelScheduledDataPump(writer);
|
|
63233
|
+
writer.unsubscribeDrain?.();
|
|
63234
|
+
writer.queue.length = 0;
|
|
63235
|
+
writer.pendingFrames.length = 0;
|
|
63236
|
+
this.writers.delete(connectionId);
|
|
63237
|
+
}
|
|
63238
|
+
for (const key2 of [
|
|
63239
|
+
...this.rooms.keys()
|
|
63240
|
+
]) {
|
|
63241
|
+
const entry = this.rooms.get(key2);
|
|
63242
|
+
if (!entry) {
|
|
63243
|
+
continue;
|
|
63244
|
+
}
|
|
63245
|
+
for (const [peerId, subscriber] of [
|
|
63246
|
+
...entry.subscribers
|
|
63247
|
+
]) {
|
|
63248
|
+
if (subscriber.connection.id === connectionId) {
|
|
63249
|
+
entry.subscribers.delete(peerId);
|
|
63250
|
+
if (entry.scope === "doc") {
|
|
63251
|
+
entry.uploadAssemblers.delete(peerId);
|
|
63252
|
+
}
|
|
63253
|
+
}
|
|
63254
|
+
}
|
|
63255
|
+
this.releaseRoomIfEmpty(key2, entry);
|
|
63256
|
+
}
|
|
63257
|
+
}
|
|
63258
|
+
detachPeer(peerId) {
|
|
63259
|
+
for (const key2 of [
|
|
63260
|
+
...this.rooms.keys()
|
|
63261
|
+
]) {
|
|
63262
|
+
this.unsubscribePeer(peerId, key2);
|
|
63263
|
+
}
|
|
63264
|
+
}
|
|
63265
|
+
async handleJoin(connection2, message) {
|
|
63266
|
+
const key2 = roomKey(message.room);
|
|
63267
|
+
for (; ; ) {
|
|
63268
|
+
const entry = await this.ensureRoom(message.room);
|
|
63269
|
+
if (this.rooms.get(key2) !== entry) {
|
|
63270
|
+
continue;
|
|
63271
|
+
}
|
|
63272
|
+
if (entry.scope === "doc") {
|
|
63273
|
+
entry.subscribers.set(message.peerId, {
|
|
63274
|
+
peerId: message.peerId,
|
|
63275
|
+
connection: connection2,
|
|
63276
|
+
latestJoinRequestId: message.requestId,
|
|
63277
|
+
lastSentVV: decodeVersion(message.haveVersion)
|
|
63278
|
+
});
|
|
63279
|
+
} else {
|
|
63280
|
+
entry.subscribers.set(message.peerId, {
|
|
63281
|
+
peerId: message.peerId,
|
|
63282
|
+
connection: connection2,
|
|
63283
|
+
latestJoinRequestId: message.requestId,
|
|
63284
|
+
lastSentVersion: decodeFlockVersion(message.haveVersion)
|
|
63285
|
+
});
|
|
63286
|
+
}
|
|
63287
|
+
this.enqueueJoinReply(connection2, key2, message.peerId, message.requestId);
|
|
63288
|
+
if (message.room.scope === "doc") {
|
|
63289
|
+
this.notifyDocRoomJoin(message.room.docId);
|
|
63290
|
+
} else if (message.room.scope === "flock-doc") {
|
|
63291
|
+
this.notifyFlockRoomJoin(message.room.flockDocId);
|
|
63292
|
+
}
|
|
63293
|
+
return;
|
|
63294
|
+
}
|
|
63295
|
+
}
|
|
63296
|
+
notifyDocRoomJoin(docId) {
|
|
63297
|
+
if (!this.docRoomJoinHandler) {
|
|
63298
|
+
return;
|
|
63299
|
+
}
|
|
63300
|
+
void Promise.resolve(this.docRoomJoinHandler(docId)).catch((error2) => {
|
|
63301
|
+
this.options.onError?.(error2, "onDocRoomJoin");
|
|
63302
|
+
});
|
|
63303
|
+
}
|
|
63304
|
+
notifyFlockRoomJoin(flockDocId) {
|
|
63305
|
+
if (!this.flockRoomJoinHandler) {
|
|
63306
|
+
return;
|
|
63307
|
+
}
|
|
63308
|
+
void Promise.resolve(this.flockRoomJoinHandler(flockDocId)).catch((error2) => {
|
|
63309
|
+
this.options.onError?.(error2, "onFlockRoomJoin");
|
|
63310
|
+
});
|
|
63311
|
+
}
|
|
63312
|
+
notifyDocRoomLeave(room) {
|
|
63313
|
+
if (room.scope !== "doc" || !this.docRoomLeaveHandler) {
|
|
63314
|
+
return;
|
|
63315
|
+
}
|
|
63316
|
+
void Promise.resolve(this.docRoomLeaveHandler(room.docId)).catch((error2) => {
|
|
63317
|
+
this.options.onError?.(error2, "onDocRoomLeave");
|
|
63318
|
+
});
|
|
63319
|
+
}
|
|
63320
|
+
notifyFlockRoomLeave(room) {
|
|
63321
|
+
if (room.scope !== "flock-doc" || !this.flockRoomLeaveHandler) {
|
|
63322
|
+
return;
|
|
63323
|
+
}
|
|
63324
|
+
void Promise.resolve(this.flockRoomLeaveHandler(room.flockDocId)).catch((error2) => {
|
|
63325
|
+
this.options.onError?.(error2, "onFlockRoomLeave");
|
|
63326
|
+
});
|
|
63327
|
+
}
|
|
63328
|
+
async handleUpdate(connection2, message) {
|
|
63329
|
+
const key2 = roomKey(message.room);
|
|
63330
|
+
let entry = await this.ensureRoom(message.room);
|
|
63331
|
+
while (this.rooms.get(key2) !== entry) {
|
|
63332
|
+
entry = await this.ensureRoom(message.room);
|
|
63333
|
+
}
|
|
63334
|
+
if (entry.scope === "doc") {
|
|
63335
|
+
if (message.payload.kind === "flock-json") {
|
|
63336
|
+
this.sendError(connection2, {
|
|
63337
|
+
code: "payload_kind_mismatch",
|
|
63338
|
+
message: "expected doc-update",
|
|
63339
|
+
peerId: message.peerId,
|
|
63340
|
+
room: message.room
|
|
63341
|
+
});
|
|
63342
|
+
return;
|
|
63343
|
+
}
|
|
63344
|
+
let dataBase64;
|
|
63345
|
+
if (message.payload.kind === "doc-update") {
|
|
63346
|
+
entry.uploadAssemblers.delete(message.peerId);
|
|
63347
|
+
dataBase64 = message.payload.dataBase64;
|
|
63348
|
+
} else {
|
|
63349
|
+
let assembler = entry.uploadAssemblers.get(message.peerId);
|
|
63350
|
+
if (!assembler) {
|
|
63351
|
+
assembler = new DocUpdateChunkAssembler();
|
|
63352
|
+
entry.uploadAssemblers.set(message.peerId, assembler);
|
|
63353
|
+
}
|
|
63354
|
+
dataBase64 = assembler.push(message.payload);
|
|
63355
|
+
if (dataBase64 === null) {
|
|
63356
|
+
return;
|
|
63357
|
+
}
|
|
63358
|
+
entry.uploadAssemblers.delete(message.peerId);
|
|
63359
|
+
}
|
|
63360
|
+
const subscriber2 = entry.subscribers.get(message.peerId);
|
|
63361
|
+
if (subscriber2) {
|
|
63362
|
+
subscriber2.lastSentVV = decodeVersion(message.haveVersion);
|
|
63363
|
+
}
|
|
63364
|
+
entry.doc.import(base64ToBytes(dataBase64));
|
|
63365
|
+
return;
|
|
63366
|
+
}
|
|
63367
|
+
if (message.payload.kind !== "flock-json") {
|
|
63368
|
+
this.sendError(connection2, {
|
|
63369
|
+
code: "payload_kind_mismatch",
|
|
63370
|
+
message: "expected flock-json",
|
|
63371
|
+
peerId: message.peerId,
|
|
63372
|
+
room: message.room
|
|
63373
|
+
});
|
|
63374
|
+
return;
|
|
63375
|
+
}
|
|
63376
|
+
const subscriber = entry.subscribers.get(message.peerId);
|
|
63377
|
+
if (subscriber) {
|
|
63378
|
+
subscriber.lastSentVersion = mergeFlockVersions(subscriber.lastSentVersion, decodeFlockVersion(message.haveVersion));
|
|
63379
|
+
}
|
|
63380
|
+
await entry.flock.importJson(message.payload.bundle);
|
|
63381
|
+
entry.flock.commit?.();
|
|
63382
|
+
}
|
|
63383
|
+
async ensureRoom(room) {
|
|
63384
|
+
const key2 = roomKey(room);
|
|
63385
|
+
for (; ; ) {
|
|
63386
|
+
const existing = this.rooms.get(key2);
|
|
63387
|
+
if (existing) {
|
|
63388
|
+
return existing;
|
|
63389
|
+
}
|
|
63390
|
+
const inFlight = this.resolveInFlight.get(key2);
|
|
63391
|
+
if (inFlight) {
|
|
63392
|
+
const shared = await inFlight;
|
|
63393
|
+
if (shared) {
|
|
63394
|
+
return shared;
|
|
63395
|
+
}
|
|
63396
|
+
continue;
|
|
63397
|
+
}
|
|
63398
|
+
const generation = this.roomGenerations.get(key2) ?? 0;
|
|
63399
|
+
const build = (async () => {
|
|
63400
|
+
const entry = room.scope === "doc" ? await this.buildDocRoom(room, room.docId) : await this.buildFlockRoom(room, await this.resolveFlockForRoom(room));
|
|
63401
|
+
if (this.disposed) {
|
|
63402
|
+
entry.unsubscribe();
|
|
63403
|
+
throw new Error("data_plane_engine_disposed");
|
|
63404
|
+
}
|
|
63405
|
+
if ((this.roomGenerations.get(key2) ?? 0) !== generation) {
|
|
63406
|
+
entry.unsubscribe();
|
|
63407
|
+
return null;
|
|
63408
|
+
}
|
|
63409
|
+
this.rooms.set(key2, entry);
|
|
63410
|
+
return entry;
|
|
63411
|
+
})().finally(() => this.resolveInFlight.delete(key2));
|
|
63412
|
+
this.resolveInFlight.set(key2, build);
|
|
63413
|
+
const resolved = await build;
|
|
63414
|
+
if (resolved) {
|
|
63415
|
+
return resolved;
|
|
63416
|
+
}
|
|
63417
|
+
}
|
|
63418
|
+
}
|
|
63419
|
+
async buildDocRoom(room, docId) {
|
|
63420
|
+
const doc = await this.options.resolveDoc(docId);
|
|
63421
|
+
const entry = {
|
|
63422
|
+
scope: "doc",
|
|
63423
|
+
room,
|
|
63424
|
+
doc,
|
|
63425
|
+
unsubscribe: () => {
|
|
63426
|
+
},
|
|
63427
|
+
subscribers: /* @__PURE__ */ new Map(),
|
|
63428
|
+
uploadAssemblers: /* @__PURE__ */ new Map()
|
|
63429
|
+
};
|
|
63430
|
+
entry.unsubscribe = doc.subscribe(() => this.markRoomDirty(entry));
|
|
63431
|
+
return entry;
|
|
63432
|
+
}
|
|
63433
|
+
resolveFlockForRoom(room) {
|
|
63434
|
+
if (room.scope === "flock-doc") {
|
|
63435
|
+
return this.options.resolveFlockDoc(room.flockDocId);
|
|
63436
|
+
}
|
|
63437
|
+
return this.options.resolveMetaFlock ? this.options.resolveMetaFlock() : this.options.resolveFlockDoc("meta");
|
|
63438
|
+
}
|
|
63439
|
+
async buildFlockRoom(room, flock) {
|
|
63440
|
+
const entry = {
|
|
63441
|
+
scope: "flock",
|
|
63442
|
+
room,
|
|
63443
|
+
flock,
|
|
63444
|
+
unsubscribe: () => {
|
|
63445
|
+
},
|
|
63446
|
+
subscribers: /* @__PURE__ */ new Map()
|
|
63447
|
+
};
|
|
63448
|
+
entry.unsubscribe = flock.subscribe(() => this.markRoomDirty(entry));
|
|
63449
|
+
return entry;
|
|
63450
|
+
}
|
|
63451
|
+
markRoomDirty(entry) {
|
|
63452
|
+
if (this.disposed) {
|
|
63453
|
+
return;
|
|
63454
|
+
}
|
|
63455
|
+
const key2 = roomKey(entry.room);
|
|
63456
|
+
for (const subscriber of entry.subscribers.values()) {
|
|
63457
|
+
this.enqueueSync(subscriber.connection, key2, subscriber.peerId);
|
|
63458
|
+
}
|
|
63459
|
+
this.releaseRoomIfEmpty(key2, entry);
|
|
63460
|
+
}
|
|
63461
|
+
writerFor(connection2) {
|
|
63462
|
+
const existing = this.writers.get(connection2.id);
|
|
63463
|
+
if (existing) {
|
|
63464
|
+
return existing;
|
|
63465
|
+
}
|
|
63466
|
+
const writer = {
|
|
63467
|
+
connection: connection2,
|
|
63468
|
+
queue: [],
|
|
63469
|
+
queuedSyncKeys: /* @__PURE__ */ new Set(),
|
|
63470
|
+
presenceQueued: false,
|
|
63471
|
+
machineMonitorQueued: false,
|
|
63472
|
+
pendingFrames: [],
|
|
63473
|
+
pumping: false,
|
|
63474
|
+
pumpScheduled: false,
|
|
63475
|
+
cancelScheduledPump: null,
|
|
63476
|
+
blocked: false,
|
|
63477
|
+
unsubscribeDrain: null
|
|
63478
|
+
};
|
|
63479
|
+
writer.unsubscribeDrain = connection2.onDrain?.(() => {
|
|
63480
|
+
writer.blocked = false;
|
|
63481
|
+
this.scheduleDataPump(writer);
|
|
63482
|
+
}) ?? null;
|
|
63483
|
+
this.writers.set(connection2.id, writer);
|
|
63484
|
+
return writer;
|
|
63485
|
+
}
|
|
63486
|
+
enqueueMessage(connection2, message) {
|
|
63487
|
+
const writer = this.writerFor(connection2);
|
|
63488
|
+
writer.queue.push({
|
|
63489
|
+
kind: "message",
|
|
63490
|
+
message
|
|
63491
|
+
});
|
|
63492
|
+
this.scheduleDataPump(writer);
|
|
63493
|
+
}
|
|
63494
|
+
enqueueJoinReply(connection2, key2, peerId, requestId) {
|
|
63495
|
+
const writer = this.writerFor(connection2);
|
|
63496
|
+
writer.queue.push({
|
|
63497
|
+
kind: "join-reply",
|
|
63498
|
+
roomKey: key2,
|
|
63499
|
+
peerId,
|
|
63500
|
+
requestId
|
|
63501
|
+
});
|
|
63502
|
+
this.scheduleDataPump(writer);
|
|
63503
|
+
}
|
|
63504
|
+
enqueueSync(connection2, key2, peerId) {
|
|
63505
|
+
const writer = this.writerFor(connection2);
|
|
63506
|
+
const taskKey = syncTaskKey(key2, peerId);
|
|
63507
|
+
if (writer.queuedSyncKeys.has(taskKey)) {
|
|
63508
|
+
return;
|
|
63509
|
+
}
|
|
63510
|
+
writer.queuedSyncKeys.add(taskKey);
|
|
63511
|
+
writer.queue.push({
|
|
63512
|
+
kind: "sync",
|
|
63513
|
+
roomKey: key2,
|
|
63514
|
+
peerId
|
|
63515
|
+
});
|
|
63516
|
+
this.scheduleDataPump(writer);
|
|
63517
|
+
}
|
|
63518
|
+
enqueuePresence(connection2) {
|
|
63519
|
+
const writer = this.writerFor(connection2);
|
|
63520
|
+
if (writer.presenceQueued) {
|
|
63521
|
+
return;
|
|
63522
|
+
}
|
|
63523
|
+
writer.presenceQueued = true;
|
|
63524
|
+
writer.queue.push({
|
|
63525
|
+
kind: "presence"
|
|
63526
|
+
});
|
|
63527
|
+
this.scheduleDataPump(writer);
|
|
63528
|
+
}
|
|
63529
|
+
enqueueMachineMonitor(connection2) {
|
|
63530
|
+
const writer = this.writerFor(connection2);
|
|
63531
|
+
if (writer.machineMonitorQueued) return;
|
|
63532
|
+
writer.machineMonitorQueued = true;
|
|
63533
|
+
writer.queue.push({
|
|
63534
|
+
kind: "machine-monitor"
|
|
63535
|
+
});
|
|
63536
|
+
this.scheduleDataPump(writer);
|
|
63537
|
+
}
|
|
63538
|
+
isWriterActive(writer) {
|
|
63539
|
+
return !this.disposed && this.writers.get(writer.connection.id) === writer;
|
|
63540
|
+
}
|
|
63541
|
+
cancelScheduledDataPump(writer) {
|
|
63542
|
+
writer.cancelScheduledPump?.();
|
|
63543
|
+
writer.cancelScheduledPump = null;
|
|
63544
|
+
writer.pumpScheduled = false;
|
|
63545
|
+
}
|
|
63546
|
+
hasPendingDataWork(writer) {
|
|
63547
|
+
return writer.pendingFrames.length > 0 || writer.queue.length > 0;
|
|
63548
|
+
}
|
|
63549
|
+
scheduleDataPump(writer) {
|
|
63550
|
+
if (!this.isWriterActive(writer) || writer.blocked || writer.pumping || writer.pumpScheduled || !this.hasPendingDataWork(writer)) {
|
|
63551
|
+
return;
|
|
63552
|
+
}
|
|
63553
|
+
writer.pumpScheduled = true;
|
|
63554
|
+
writer.cancelScheduledPump = this.scheduler.scheduleDataWork(() => {
|
|
63555
|
+
writer.pumpScheduled = false;
|
|
63556
|
+
writer.cancelScheduledPump = null;
|
|
63557
|
+
return this.pumpWriter(writer).catch((error2) => {
|
|
63558
|
+
this.options.onError?.(error2, "pumpWriter");
|
|
63559
|
+
});
|
|
63560
|
+
});
|
|
63561
|
+
}
|
|
63562
|
+
async pumpWriter(writer) {
|
|
63563
|
+
if (!this.isWriterActive(writer) || writer.pumping || writer.blocked) {
|
|
63564
|
+
return;
|
|
63565
|
+
}
|
|
63566
|
+
writer.pumping = true;
|
|
63567
|
+
try {
|
|
63568
|
+
const pendingFrame = writer.pendingFrames.shift();
|
|
63569
|
+
if (pendingFrame) {
|
|
63570
|
+
this.writeFrame(writer, pendingFrame);
|
|
63571
|
+
return;
|
|
63572
|
+
}
|
|
63573
|
+
const task = writer.queue.shift();
|
|
63574
|
+
if (!task) {
|
|
63575
|
+
return;
|
|
63576
|
+
}
|
|
63577
|
+
if (task.kind === "sync") {
|
|
63578
|
+
writer.queuedSyncKeys.delete(syncTaskKey(task.roomKey, task.peerId));
|
|
63579
|
+
} else if (task.kind === "presence") {
|
|
63580
|
+
writer.presenceQueued = false;
|
|
63581
|
+
} else if (task.kind === "machine-monitor") {
|
|
63582
|
+
writer.machineMonitorQueued = false;
|
|
63583
|
+
}
|
|
63584
|
+
try {
|
|
63585
|
+
const frames = await this.buildFrames(writer, task);
|
|
63586
|
+
if (!this.isWriterActive(writer)) return;
|
|
63587
|
+
writer.pendingFrames.push(...frames);
|
|
63588
|
+
} catch (error2) {
|
|
63589
|
+
this.options.onError?.(error2, `buildFrames:${task.kind}`);
|
|
63590
|
+
}
|
|
63591
|
+
if (!this.isWriterActive(writer) || writer.blocked) {
|
|
63592
|
+
return;
|
|
63593
|
+
}
|
|
63594
|
+
const firstFrame = writer.pendingFrames.shift();
|
|
63595
|
+
if (firstFrame) {
|
|
63596
|
+
this.writeFrame(writer, firstFrame);
|
|
63597
|
+
}
|
|
63598
|
+
} finally {
|
|
63599
|
+
writer.pumping = false;
|
|
63600
|
+
if (this.isWriterActive(writer)) {
|
|
63601
|
+
this.scheduleDataPump(writer);
|
|
63602
|
+
}
|
|
63603
|
+
}
|
|
63604
|
+
}
|
|
63605
|
+
writeFrame(writer, frame2) {
|
|
63606
|
+
const accepted = writer.connection.send(frame2);
|
|
63607
|
+
if (accepted === false && writer.unsubscribeDrain) {
|
|
63608
|
+
writer.blocked = true;
|
|
63609
|
+
}
|
|
63610
|
+
}
|
|
63611
|
+
async buildFrames(writer, task) {
|
|
63612
|
+
switch (task.kind) {
|
|
63613
|
+
case "message":
|
|
63614
|
+
return [
|
|
63615
|
+
task.message
|
|
63616
|
+
];
|
|
63617
|
+
case "presence": {
|
|
63618
|
+
const source = this.options.presenceSource;
|
|
63619
|
+
if (!source) {
|
|
63620
|
+
return [];
|
|
63621
|
+
}
|
|
63622
|
+
const encoded = source.encodeLocalOrigin();
|
|
63623
|
+
if (encoded.length === 0) {
|
|
63624
|
+
return [];
|
|
63625
|
+
}
|
|
63626
|
+
return [
|
|
63627
|
+
{
|
|
63628
|
+
type: "presence",
|
|
63629
|
+
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
63630
|
+
workspaceId: this.options.workspaceId,
|
|
63631
|
+
dataBase64: bytesToBase64(encoded)
|
|
63632
|
+
}
|
|
63633
|
+
];
|
|
63634
|
+
}
|
|
63635
|
+
case "machine-monitor": {
|
|
63636
|
+
const source = this.options.machineMonitorSource;
|
|
63637
|
+
if (!source) return [];
|
|
63638
|
+
const encoded = source.encodeAll();
|
|
63639
|
+
if (encoded.length === 0) return [];
|
|
63640
|
+
return [
|
|
63641
|
+
{
|
|
63642
|
+
type: "machine-monitor",
|
|
63643
|
+
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
63644
|
+
workspaceId: this.options.workspaceId,
|
|
63645
|
+
dataBase64: bytesToBase64(encoded)
|
|
63646
|
+
}
|
|
63647
|
+
];
|
|
63648
|
+
}
|
|
63649
|
+
case "join-reply":
|
|
63650
|
+
return await this.buildJoinReplyFrames(writer, task);
|
|
63651
|
+
case "sync":
|
|
63652
|
+
return await this.buildSyncFrames(writer, task.roomKey, task.peerId, null);
|
|
63653
|
+
}
|
|
63654
|
+
const exhaustive = task;
|
|
63655
|
+
throw new Error(`Unsupported local data-plane writer task: ${String(exhaustive)}`);
|
|
63656
|
+
}
|
|
63657
|
+
async buildJoinReplyFrames(writer, task) {
|
|
63658
|
+
const entry = this.rooms.get(task.roomKey);
|
|
63659
|
+
if (!entry) {
|
|
63660
|
+
return [];
|
|
63661
|
+
}
|
|
63662
|
+
const subscriber = entry.subscribers.get(task.peerId);
|
|
63663
|
+
if (!subscriber || subscriber.connection.id !== writer.connection.id) {
|
|
63664
|
+
return [];
|
|
63665
|
+
}
|
|
63666
|
+
if (subscriber.latestJoinRequestId !== task.requestId) {
|
|
63667
|
+
return [];
|
|
63668
|
+
}
|
|
63669
|
+
return await this.buildSyncFrames(writer, task.roomKey, task.peerId, task.requestId);
|
|
63670
|
+
}
|
|
63671
|
+
async buildSyncFrames(writer, key2, peerId, joinRequestId) {
|
|
63672
|
+
const entry = this.rooms.get(key2);
|
|
63673
|
+
if (!entry) {
|
|
63674
|
+
return [];
|
|
63675
|
+
}
|
|
63676
|
+
const subscriber = entry.subscribers.get(peerId);
|
|
63677
|
+
if (!subscriber || subscriber.connection.id !== writer.connection.id) {
|
|
63678
|
+
return [];
|
|
63679
|
+
}
|
|
63680
|
+
if (entry.scope === "doc") {
|
|
63681
|
+
const docSubscriber = subscriber;
|
|
63682
|
+
const serverVV = entry.doc.oplogVersion();
|
|
63683
|
+
const delta = entry.doc.export({
|
|
63684
|
+
mode: "update",
|
|
63685
|
+
from: docSubscriber.lastSentVV
|
|
63686
|
+
});
|
|
63687
|
+
const serverVersion2 = bytesToBase64(serverVV.encode());
|
|
63688
|
+
const dataBase64 = delta.length > 0 ? bytesToBase64(delta) : null;
|
|
63689
|
+
docSubscriber.lastSentVV = serverVV;
|
|
63690
|
+
if (dataBase64 && dataBase64.length > this.maxPayloadBytes) {
|
|
63691
|
+
const chunkPayloads = buildDocUpdateChunkPayloads(dataBase64, this.maxPayloadBytes, createDocUpdateTransferId());
|
|
63692
|
+
const frames2 = [];
|
|
63693
|
+
if (joinRequestId !== null) {
|
|
63694
|
+
frames2.push({
|
|
63695
|
+
type: "joined",
|
|
63696
|
+
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
63697
|
+
workspaceId: this.options.workspaceId,
|
|
63698
|
+
peerId,
|
|
63699
|
+
requestId: joinRequestId,
|
|
63700
|
+
room: entry.room,
|
|
63701
|
+
serverVersion: serverVersion2
|
|
63702
|
+
});
|
|
63703
|
+
}
|
|
63704
|
+
for (const payload of chunkPayloads) {
|
|
63705
|
+
frames2.push({
|
|
63706
|
+
type: "update",
|
|
63707
|
+
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
63708
|
+
workspaceId: this.options.workspaceId,
|
|
63709
|
+
peerId,
|
|
63710
|
+
room: entry.room,
|
|
63711
|
+
serverVersion: serverVersion2,
|
|
63712
|
+
payload
|
|
63713
|
+
});
|
|
63714
|
+
}
|
|
63715
|
+
return frames2;
|
|
63716
|
+
}
|
|
63717
|
+
if (joinRequestId !== null) {
|
|
63718
|
+
return [
|
|
63719
|
+
{
|
|
63720
|
+
type: "joined",
|
|
63721
|
+
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
63722
|
+
workspaceId: this.options.workspaceId,
|
|
63723
|
+
peerId,
|
|
63724
|
+
requestId: joinRequestId,
|
|
63725
|
+
room: entry.room,
|
|
63726
|
+
serverVersion: serverVersion2,
|
|
63727
|
+
...dataBase64 ? {
|
|
63728
|
+
payload: {
|
|
63729
|
+
kind: "doc-update",
|
|
63730
|
+
dataBase64
|
|
63731
|
+
}
|
|
63732
|
+
} : {}
|
|
63733
|
+
}
|
|
63734
|
+
];
|
|
63735
|
+
}
|
|
63736
|
+
if (!dataBase64) {
|
|
63737
|
+
return [];
|
|
63738
|
+
}
|
|
63739
|
+
return [
|
|
63740
|
+
{
|
|
63741
|
+
type: "update",
|
|
63742
|
+
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
63743
|
+
workspaceId: this.options.workspaceId,
|
|
63744
|
+
peerId,
|
|
63745
|
+
room: entry.room,
|
|
63746
|
+
serverVersion: serverVersion2,
|
|
63747
|
+
payload: {
|
|
63748
|
+
kind: "doc-update",
|
|
63749
|
+
dataBase64
|
|
63750
|
+
}
|
|
63751
|
+
}
|
|
63752
|
+
];
|
|
63753
|
+
}
|
|
63754
|
+
const flockSubscriber = subscriber;
|
|
63755
|
+
const have = entry.flock.version();
|
|
63756
|
+
const bundle = await entry.flock.exportJson(flockSubscriber.lastSentVersion);
|
|
63757
|
+
const currentEntry = this.rooms.get(key2);
|
|
63758
|
+
const currentSubscriber = currentEntry?.scope === "flock" ? currentEntry.subscribers.get(peerId) : void 0;
|
|
63759
|
+
if (currentEntry !== entry || currentSubscriber !== flockSubscriber || currentSubscriber.connection.id !== writer.connection.id || joinRequestId !== null && currentSubscriber.latestJoinRequestId !== joinRequestId) {
|
|
63760
|
+
return [];
|
|
63761
|
+
}
|
|
63762
|
+
flockSubscriber.lastSentVersion = mergeFlockVersions(flockSubscriber.lastSentVersion, have);
|
|
63763
|
+
const serverVersion = encodeFlockVersion(have);
|
|
63764
|
+
if (isEmptyFlockBundle(bundle)) {
|
|
63765
|
+
if (joinRequestId !== null) {
|
|
63766
|
+
return [
|
|
63767
|
+
{
|
|
63768
|
+
type: "joined",
|
|
63769
|
+
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
63770
|
+
workspaceId: this.options.workspaceId,
|
|
63771
|
+
peerId,
|
|
63772
|
+
requestId: joinRequestId,
|
|
63773
|
+
room: entry.room,
|
|
63774
|
+
serverVersion
|
|
63775
|
+
}
|
|
63776
|
+
];
|
|
63777
|
+
}
|
|
63778
|
+
return [];
|
|
63779
|
+
}
|
|
63780
|
+
const chunks = chunkFlockBundle(bundle, this.maxPayloadBytes);
|
|
63781
|
+
if (!chunks) {
|
|
63782
|
+
entry.subscribers.delete(peerId);
|
|
63783
|
+
this.releaseRoomIfEmpty(key2, entry);
|
|
63784
|
+
return [
|
|
63785
|
+
this.payloadTooLargeError(peerId, entry.room, joinRequestId ?? void 0)
|
|
63786
|
+
];
|
|
63787
|
+
}
|
|
63788
|
+
const frames = [];
|
|
63789
|
+
for (const [index, chunk] of chunks.entries()) {
|
|
63790
|
+
if (joinRequestId !== null && index === 0) {
|
|
63791
|
+
frames.push({
|
|
63792
|
+
type: "joined",
|
|
63793
|
+
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
63794
|
+
workspaceId: this.options.workspaceId,
|
|
63795
|
+
peerId,
|
|
63796
|
+
requestId: joinRequestId,
|
|
63797
|
+
room: entry.room,
|
|
63798
|
+
serverVersion,
|
|
63799
|
+
payload: {
|
|
63800
|
+
kind: "flock-json",
|
|
63801
|
+
bundle: chunk
|
|
63802
|
+
}
|
|
63803
|
+
});
|
|
63804
|
+
continue;
|
|
63805
|
+
}
|
|
63806
|
+
frames.push({
|
|
63807
|
+
type: "update",
|
|
63808
|
+
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
63809
|
+
workspaceId: this.options.workspaceId,
|
|
63810
|
+
peerId,
|
|
63811
|
+
room: entry.room,
|
|
63812
|
+
serverVersion,
|
|
63813
|
+
payload: {
|
|
63814
|
+
kind: "flock-json",
|
|
63815
|
+
bundle: chunk
|
|
63816
|
+
}
|
|
63817
|
+
});
|
|
63818
|
+
}
|
|
63819
|
+
return frames;
|
|
63820
|
+
}
|
|
63821
|
+
payloadTooLargeError(peerId, room, requestId) {
|
|
63822
|
+
return {
|
|
63823
|
+
type: "error",
|
|
63824
|
+
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
63825
|
+
workspaceId: this.options.workspaceId,
|
|
63826
|
+
code: LOCAL_LORO_DATA_PLANE_PAYLOAD_TOO_LARGE,
|
|
63827
|
+
message: "sync payload exceeds the local data-plane frame budget",
|
|
63828
|
+
peerId,
|
|
63829
|
+
room,
|
|
63830
|
+
...requestId ? {
|
|
63831
|
+
requestId
|
|
63832
|
+
} : {},
|
|
63833
|
+
terminal: true
|
|
63834
|
+
};
|
|
63835
|
+
}
|
|
63836
|
+
unsubscribePeer(peerId, key2) {
|
|
63837
|
+
const entry = this.rooms.get(key2);
|
|
63838
|
+
if (!entry) {
|
|
63839
|
+
return;
|
|
63840
|
+
}
|
|
63841
|
+
entry.subscribers.delete(peerId);
|
|
63842
|
+
if (entry.scope === "doc") {
|
|
63843
|
+
entry.uploadAssemblers.delete(peerId);
|
|
63844
|
+
}
|
|
63845
|
+
this.releaseRoomIfEmpty(key2, entry);
|
|
63846
|
+
}
|
|
63847
|
+
releaseRoomIfEmpty(key2, entry) {
|
|
63848
|
+
if (entry.subscribers.size > 0 || this.rooms.get(key2) !== entry) {
|
|
63849
|
+
return;
|
|
63850
|
+
}
|
|
63851
|
+
entry.unsubscribe();
|
|
63852
|
+
this.rooms.delete(key2);
|
|
63853
|
+
this.notifyDocRoomLeave(entry.room);
|
|
63854
|
+
this.notifyFlockRoomLeave(entry.room);
|
|
63855
|
+
}
|
|
63856
|
+
sendError(connection2, error2) {
|
|
63857
|
+
this.enqueueMessage(connection2, {
|
|
63858
|
+
type: "error",
|
|
63859
|
+
protocolVersion: LOCAL_LORO_DATA_PLANE_PROTOCOL_VERSION,
|
|
63860
|
+
workspaceId: this.options.workspaceId,
|
|
63861
|
+
code: error2.code,
|
|
63862
|
+
...error2.message ? {
|
|
63863
|
+
message: error2.message
|
|
63864
|
+
} : {},
|
|
63865
|
+
...error2.peerId ? {
|
|
63866
|
+
peerId: error2.peerId
|
|
63867
|
+
} : {},
|
|
63868
|
+
...error2.requestId ? {
|
|
63869
|
+
requestId: error2.requestId
|
|
63870
|
+
} : {},
|
|
63871
|
+
...error2.room ? {
|
|
63872
|
+
room: error2.room
|
|
63873
|
+
} : {},
|
|
63874
|
+
...error2.terminal ? {
|
|
63875
|
+
terminal: true
|
|
63876
|
+
} : {}
|
|
63877
|
+
});
|
|
63878
|
+
}
|
|
63879
|
+
}
|
|
63880
|
+
function decodeVersion(encoded) {
|
|
63881
|
+
if (!encoded) {
|
|
63882
|
+
return new VersionVector(null);
|
|
63883
|
+
}
|
|
63884
|
+
return VersionVector.decode(base64ToBytes(encoded));
|
|
63885
|
+
}
|
|
63886
|
+
function errorMessage(error2) {
|
|
63887
|
+
return error2 instanceof Error ? error2.message : String(error2);
|
|
63888
|
+
}
|
|
63852
63889
|
const byteToHex = [];
|
|
63853
63890
|
for (let i2 = 0; i2 < 256; ++i2) {
|
|
63854
63891
|
byteToHex.push((i2 + 256).toString(16).slice(1));
|
|
@@ -64159,7 +64196,7 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
|
|
|
64159
64196
|
function requirePermessageDeflate$1() {
|
|
64160
64197
|
if (hasRequiredPermessageDeflate$1) return permessageDeflate$1;
|
|
64161
64198
|
hasRequiredPermessageDeflate$1 = 1;
|
|
64162
|
-
const zlib =
|
|
64199
|
+
const zlib = $s__default;
|
|
64163
64200
|
const bufferUtil2 = requireBufferUtil();
|
|
64164
64201
|
const Limiter = requireLimiter();
|
|
64165
64202
|
const { kStatusCode } = requireConstants$5();
|
|
@@ -64614,7 +64651,7 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
|
|
|
64614
64651
|
function requireReceiver$1() {
|
|
64615
64652
|
if (hasRequiredReceiver$1) return receiver$1;
|
|
64616
64653
|
hasRequiredReceiver$1 = 1;
|
|
64617
|
-
const { Writable } =
|
|
64654
|
+
const { Writable } = Zr;
|
|
64618
64655
|
const PerMessageDeflate = requirePermessageDeflate$1();
|
|
64619
64656
|
const { BINARY_TYPES, EMPTY_BUFFER, kStatusCode, kWebSocket } = requireConstants$5();
|
|
64620
64657
|
const { concat: concat2, toArrayBuffer: toArrayBuffer2, unmask } = requireBufferUtil();
|
|
@@ -64981,7 +65018,7 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
|
|
|
64981
65018
|
function requireSender$1() {
|
|
64982
65019
|
if (hasRequiredSender$1) return sender$1;
|
|
64983
65020
|
hasRequiredSender$1 = 1;
|
|
64984
|
-
const { Duplex } =
|
|
65021
|
+
const { Duplex } = Zr;
|
|
64985
65022
|
const { randomFillSync: randomFillSync2 } = crypto__default;
|
|
64986
65023
|
const PerMessageDeflate = requirePermessageDeflate$1();
|
|
64987
65024
|
const { EMPTY_BUFFER, kWebSocket, NOOP } = requireConstants$5();
|
|
@@ -65718,7 +65755,7 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
|
|
|
65718
65755
|
const net2 = require$$0$9;
|
|
65719
65756
|
const tls = require$$4$2;
|
|
65720
65757
|
const { randomBytes: randomBytes2, createHash: createHash2 } = crypto__default;
|
|
65721
|
-
const { Duplex, Readable: Readable2 } =
|
|
65758
|
+
const { Duplex, Readable: Readable2 } = Zr;
|
|
65722
65759
|
const { URL: URL2 } = require$$7$2;
|
|
65723
65760
|
const PerMessageDeflate = requirePermessageDeflate$1();
|
|
65724
65761
|
const Receiver = requireReceiver$1();
|
|
@@ -66456,7 +66493,7 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
|
|
|
66456
66493
|
if (hasRequiredStream$1) return stream$1;
|
|
66457
66494
|
hasRequiredStream$1 = 1;
|
|
66458
66495
|
requireWebsocket$1();
|
|
66459
|
-
const { Duplex } =
|
|
66496
|
+
const { Duplex } = Zr;
|
|
66460
66497
|
function emitClose(stream2) {
|
|
66461
66498
|
stream2.emit("close");
|
|
66462
66499
|
}
|
|
@@ -66607,7 +66644,7 @@ ${this.stack.split("\n").slice(1).join("\n")}` : this.toString();
|
|
|
66607
66644
|
hasRequiredWebsocketServer = 1;
|
|
66608
66645
|
const EventEmitter2 = require$$0$7;
|
|
66609
66646
|
const http$12 = http;
|
|
66610
|
-
const { Duplex } =
|
|
66647
|
+
const { Duplex } = Zr;
|
|
66611
66648
|
const { createHash: createHash2 } = crypto__default;
|
|
66612
66649
|
const extension2 = requireExtension();
|
|
66613
66650
|
const PerMessageDeflate = requirePermessageDeflate$1();
|
|
@@ -81391,7 +81428,7 @@ ${val.stack}`;
|
|
|
81391
81428
|
if (hasRequiredSupportsColor) return supportsColor_1;
|
|
81392
81429
|
hasRequiredSupportsColor = 1;
|
|
81393
81430
|
const os2 = os__default$1;
|
|
81394
|
-
const tty2 = require$$1$
|
|
81431
|
+
const tty2 = require$$1$2;
|
|
81395
81432
|
const hasFlag2 = requireHasFlag$1();
|
|
81396
81433
|
const { env: env2 } = process;
|
|
81397
81434
|
let forceColor;
|
|
@@ -81499,7 +81536,7 @@ ${val.stack}`;
|
|
|
81499
81536
|
if (hasRequiredNode) return node.exports;
|
|
81500
81537
|
hasRequiredNode = 1;
|
|
81501
81538
|
(function(module2, exports$1) {
|
|
81502
|
-
const tty2 = require$$1$
|
|
81539
|
+
const tty2 = require$$1$2;
|
|
81503
81540
|
const util2 = require$$0$5;
|
|
81504
81541
|
exports$1.init = init2;
|
|
81505
81542
|
exports$1.log = log;
|
|
@@ -82669,7 +82706,7 @@ ${val.stack}`;
|
|
|
82669
82706
|
}
|
|
82670
82707
|
const createCliSqliteRepoStore = async (workspaceId) => {
|
|
82671
82708
|
const baseDir = getLoroRepoStorageBaseDir(workspaceId);
|
|
82672
|
-
await fs__default$
|
|
82709
|
+
await fs__default$2.mkdir(baseDir, {
|
|
82673
82710
|
recursive: true
|
|
82674
82711
|
});
|
|
82675
82712
|
const dbPath = getLoroRepoSqliteDbPath(workspaceId);
|
|
@@ -85963,7 +86000,7 @@ ${val.stack}`;
|
|
|
85963
86000
|
if (hasRequiredWebidl) return webidl_1;
|
|
85964
86001
|
hasRequiredWebidl = 1;
|
|
85965
86002
|
const { types: types2, inspect: inspect2 } = require$$0$8;
|
|
85966
|
-
const { markAsUncloneable } = require$$1$
|
|
86003
|
+
const { markAsUncloneable } = require$$1$4;
|
|
85967
86004
|
const { toUSVString } = requireUtil$8();
|
|
85968
86005
|
const webidl = {};
|
|
85969
86006
|
webidl.converters = {};
|
|
@@ -90750,7 +90787,7 @@ ${len2.toString(16)}\r
|
|
|
90750
90787
|
if (hasRequiredProxyAgent) return proxyAgent;
|
|
90751
90788
|
hasRequiredProxyAgent = 1;
|
|
90752
90789
|
const { kProxy, kClose, kDestroy, kDispatch, kInterceptors } = requireSymbols$4();
|
|
90753
|
-
const { URL: URL2 } = require$$1$
|
|
90790
|
+
const { URL: URL2 } = require$$1$5;
|
|
90754
90791
|
const Agent = requireAgent();
|
|
90755
90792
|
const Pool = requirePool();
|
|
90756
90793
|
const DispatcherBase = requireDispatcherBase();
|
|
@@ -93252,7 +93289,7 @@ ${len2.toString(16)}\r
|
|
|
93252
93289
|
if (hasRequiredPendingInterceptorsFormatter) return pendingInterceptorsFormatter;
|
|
93253
93290
|
hasRequiredPendingInterceptorsFormatter = 1;
|
|
93254
93291
|
const { Transform: Transform2 } = require$$0$c;
|
|
93255
|
-
const { Console } = require$$1$
|
|
93292
|
+
const { Console } = require$$1$6;
|
|
93256
93293
|
const PERSISTENT = process.versions.icu ? "\u2705" : "Y ";
|
|
93257
93294
|
const NOT_PERSISTENT = process.versions.icu ? "\u274C" : "N ";
|
|
93258
93295
|
pendingInterceptorsFormatter = class PendingInterceptorsFormatter {
|
|
@@ -93621,7 +93658,7 @@ ${pendingInterceptorsFormatter2.format(pending2)}
|
|
|
93621
93658
|
if (hasRequiredDns) return dns;
|
|
93622
93659
|
hasRequiredDns = 1;
|
|
93623
93660
|
const { isIP } = net;
|
|
93624
|
-
const { lookup: lookup2 } = require$$1$
|
|
93661
|
+
const { lookup: lookup2 } = require$$1$7;
|
|
93625
93662
|
const DecoratorHandler = requireDecoratorHandler();
|
|
93626
93663
|
const { InvalidArgumentError: InvalidArgumentError2, InformationalError } = requireErrors$1();
|
|
93627
93664
|
const maxInt = Math.pow(2, 31) - 1;
|
|
@@ -96720,7 +96757,7 @@ ${pendingInterceptorsFormatter2.format(pending2)}
|
|
|
96720
96757
|
const { getEncoding } = requireEncoding();
|
|
96721
96758
|
const { serializeAMimeType, parseMIMEType } = requireDataUrl();
|
|
96722
96759
|
const { types: types2 } = require$$0$8;
|
|
96723
|
-
const { StringDecoder: StringDecoder2 } = require$$1$
|
|
96760
|
+
const { StringDecoder: StringDecoder2 } = require$$1$3;
|
|
96724
96761
|
const { btoa: btoa2 } = require$$0$a;
|
|
96725
96762
|
const staticPropertyDescriptors = {
|
|
96726
96763
|
enumerable: true,
|
|
@@ -98209,7 +98246,7 @@ ${pendingInterceptorsFormatter2.format(pending2)}
|
|
|
98209
98246
|
const { webidl } = requireWebidl();
|
|
98210
98247
|
const { kEnumerableProperty } = requireUtil$8();
|
|
98211
98248
|
const { kConstruct } = requireSymbols$4();
|
|
98212
|
-
const { MessagePort } = require$$1$
|
|
98249
|
+
const { MessagePort } = require$$1$4;
|
|
98213
98250
|
class MessageEvent extends Event {
|
|
98214
98251
|
#eventInit;
|
|
98215
98252
|
constructor(type2, eventInitDict = {}) {
|
|
@@ -108772,20 +108809,20 @@ ${value}`;
|
|
|
108772
108809
|
};
|
|
108773
108810
|
const parsed = DaemonUpgradeIntentSchema.parse(value);
|
|
108774
108811
|
const dir = path.dirname(DAEMON_UPGRADE_INTENT_FILE);
|
|
108775
|
-
await
|
|
108812
|
+
await jt.mkdir(dir, {
|
|
108776
108813
|
recursive: true
|
|
108777
108814
|
});
|
|
108778
108815
|
const tmpPath = path.join(dir, `.${path.basename(DAEMON_UPGRADE_INTENT_FILE)}.${process.pid}.tmp`);
|
|
108779
|
-
await
|
|
108816
|
+
await jt.writeFile(tmpPath, `${JSON.stringify(parsed, null, 2)}
|
|
108780
108817
|
`, {
|
|
108781
108818
|
encoding: "utf8",
|
|
108782
108819
|
mode: 384
|
|
108783
108820
|
});
|
|
108784
|
-
await
|
|
108821
|
+
await jt.rename(tmpPath, DAEMON_UPGRADE_INTENT_FILE);
|
|
108785
108822
|
};
|
|
108786
108823
|
const readDaemonUpgradeIntent = async () => {
|
|
108787
108824
|
try {
|
|
108788
|
-
const raw2 = await
|
|
108825
|
+
const raw2 = await jt.readFile(DAEMON_UPGRADE_INTENT_FILE, "utf8");
|
|
108789
108826
|
const parsed = DaemonUpgradeIntentSchema.safeParse(JSON.parse(raw2));
|
|
108790
108827
|
return parsed.success ? parsed.data : null;
|
|
108791
108828
|
} catch {
|
|
@@ -108794,7 +108831,7 @@ ${value}`;
|
|
|
108794
108831
|
};
|
|
108795
108832
|
const clearDaemonUpgradeIntent = async () => {
|
|
108796
108833
|
try {
|
|
108797
|
-
await
|
|
108834
|
+
await jt.unlink(DAEMON_UPGRADE_INTENT_FILE);
|
|
108798
108835
|
} catch {
|
|
108799
108836
|
}
|
|
108800
108837
|
};
|
|
@@ -111636,7 +111673,7 @@ ${incoming}`).output;
|
|
|
111636
111673
|
function requireCrossSpawn() {
|
|
111637
111674
|
if (hasRequiredCrossSpawn) return crossSpawn.exports;
|
|
111638
111675
|
hasRequiredCrossSpawn = 1;
|
|
111639
|
-
const cp = require$$1$
|
|
111676
|
+
const cp = require$$1$8;
|
|
111640
111677
|
const parse2 = requireParse();
|
|
111641
111678
|
const enoent2 = requireEnoent();
|
|
111642
111679
|
function spawn2(command2, args2, options) {
|
|
@@ -111728,7 +111765,7 @@ ${incoming}`).output;
|
|
|
111728
111765
|
return String(process.getuid());
|
|
111729
111766
|
}
|
|
111730
111767
|
const userInfo2 = os__default.userInfo();
|
|
111731
|
-
return
|
|
111768
|
+
return crypto__default$1.createHash("sha256").update(`${userInfo2.uid}:${userInfo2.username}:${os__default.homedir()}`).digest("hex").slice(0, 16);
|
|
111732
111769
|
}
|
|
111733
111770
|
const MAX_UNIX_SOCKET_PATH_BYTES = 103;
|
|
111734
111771
|
function getLocalDaemonSocketPath(basename2, platform2) {
|
|
@@ -111822,7 +111859,7 @@ ${incoming}`).output;
|
|
|
111822
111859
|
function writeLocalDaemonRunFile(runFile, runFilePath = getLocalDaemonRunFilePath()) {
|
|
111823
111860
|
const parsed = LocalDaemonRunFileSchema.parse(runFile);
|
|
111824
111861
|
ensureLocalDaemonRunDir(path__default.dirname(runFilePath));
|
|
111825
|
-
const tempPath = `${runFilePath}.${process.pid}.${
|
|
111862
|
+
const tempPath = `${runFilePath}.${process.pid}.${crypto__default$1.randomUUID()}.tmp`;
|
|
111826
111863
|
fs__default$1.writeFileSync(tempPath, `${JSON.stringify(parsed, null, 2)}
|
|
111827
111864
|
`, {
|
|
111828
111865
|
mode: 384
|
|
@@ -113490,6 +113527,9 @@ ${incoming}`).output;
|
|
|
113490
113527
|
this.logger = options.logger;
|
|
113491
113528
|
this.terminalManager = options.terminalManager;
|
|
113492
113529
|
this.terminalEnabled = options.terminalEnabled ?? true;
|
|
113530
|
+
this.configOptionValues = {
|
|
113531
|
+
...options.configOptionValues ?? {}
|
|
113532
|
+
};
|
|
113493
113533
|
}
|
|
113494
113534
|
connection = null;
|
|
113495
113535
|
lastSessionUpdateAtMs = Date.now();
|
|
@@ -113513,6 +113553,7 @@ ${incoming}`).output;
|
|
|
113513
113553
|
sessionWorkdir = null;
|
|
113514
113554
|
agentMcpCapabilities;
|
|
113515
113555
|
configOptions = [];
|
|
113556
|
+
configOptionValues;
|
|
113516
113557
|
legacySessionModelState = null;
|
|
113517
113558
|
currentModel;
|
|
113518
113559
|
codexImageGenerationToolCallIds = /* @__PURE__ */ new Set();
|
|
@@ -114217,13 +114258,35 @@ ${incoming}`).output;
|
|
|
114217
114258
|
getGrokClientIdentifier() {
|
|
114218
114259
|
return this.options.agentConfig?.cliType === "builtin" && this.options.agentConfig.agentType === "grok" ? `lody:${this.options.sessionId}` : void 0;
|
|
114219
114260
|
}
|
|
114220
|
-
|
|
114261
|
+
getSessionStartMeta(forkSessionTurnId) {
|
|
114221
114262
|
const clientIdentifier = this.getGrokClientIdentifier();
|
|
114222
|
-
|
|
114263
|
+
const lody = {
|
|
114264
|
+
...forkSessionTurnId !== void 0 ? {
|
|
114265
|
+
forkAtTurn: {
|
|
114266
|
+
version: 1,
|
|
114267
|
+
turnId: forkSessionTurnId
|
|
114268
|
+
}
|
|
114269
|
+
} : {},
|
|
114270
|
+
...Object.keys(this.configOptionValues).length > 0 ? {
|
|
114271
|
+
sessionConfig: {
|
|
114272
|
+
version: 1,
|
|
114273
|
+
configOptionValues: {
|
|
114274
|
+
...this.configOptionValues
|
|
114275
|
+
}
|
|
114276
|
+
}
|
|
114277
|
+
} : {}
|
|
114278
|
+
};
|
|
114279
|
+
if (clientIdentifier === void 0 && Object.keys(lody).length === 0) return {};
|
|
114280
|
+
return {
|
|
114223
114281
|
_meta: {
|
|
114224
|
-
clientIdentifier
|
|
114282
|
+
...clientIdentifier !== void 0 ? {
|
|
114283
|
+
clientIdentifier
|
|
114284
|
+
} : {},
|
|
114285
|
+
...Object.keys(lody).length > 0 ? {
|
|
114286
|
+
lody
|
|
114287
|
+
} : {}
|
|
114225
114288
|
}
|
|
114226
|
-
}
|
|
114289
|
+
};
|
|
114227
114290
|
}
|
|
114228
114291
|
isCurrentAcpSession(acpSessionId) {
|
|
114229
114292
|
return this.acpSessionId !== null && acpSessionId === this.acpSessionId;
|
|
@@ -114243,7 +114306,7 @@ ${incoming}`).output;
|
|
|
114243
114306
|
const connection2 = new ClientSideConnection(() => this, stream2);
|
|
114244
114307
|
this.connection = connection2;
|
|
114245
114308
|
const grokClientIdentifier = this.getGrokClientIdentifier();
|
|
114246
|
-
const
|
|
114309
|
+
const sessionStartMeta = this.getSessionStartMeta();
|
|
114247
114310
|
this.logger.debug(`[${this.options.sessionId}] Starting ACP client (workdir=${workdir} resumeSessionId=${resumeSessionId ?? "none"} forkSessionId=${forkSessionId ?? "none"})`);
|
|
114248
114311
|
if (resumeSessionId && forkSessionId) {
|
|
114249
114312
|
throw new Error("[ACP_SESSION_START_INVALID] resumeSessionId and forkSessionId are exclusive");
|
|
@@ -114439,16 +114502,7 @@ ${incoming}`).output;
|
|
|
114439
114502
|
sessionId: forkSessionId,
|
|
114440
114503
|
cwd: workdir,
|
|
114441
114504
|
mcpServers,
|
|
114442
|
-
...forkSessionTurnId
|
|
114443
|
-
_meta: {
|
|
114444
|
-
lody: {
|
|
114445
|
-
forkAtTurn: {
|
|
114446
|
-
version: 1,
|
|
114447
|
-
turnId: forkSessionTurnId
|
|
114448
|
-
}
|
|
114449
|
-
}
|
|
114450
|
-
}
|
|
114451
|
-
} : {}
|
|
114505
|
+
...this.getSessionStartMeta(forkSessionTurnId)
|
|
114452
114506
|
}), startupAbort), this.logger, "connection.unstable_forkSession", this.options.sessionId, ACP_FORK_SESSION_TIMEOUT_MS);
|
|
114453
114507
|
this.logger.debug(`[${this.options.sessionId}] ACP fork succeeded in ${Math.round(performance$1.now() - forkStart)}ms (sourceAcpSessionId=${forkSessionId}, acpSessionId=${sessionResponse.sessionId})`);
|
|
114454
114508
|
} catch (error2) {
|
|
@@ -114483,7 +114537,7 @@ ${incoming}`).output;
|
|
|
114483
114537
|
sessionId: resumeSessionId,
|
|
114484
114538
|
cwd: workdir,
|
|
114485
114539
|
mcpServers,
|
|
114486
|
-
...
|
|
114540
|
+
...sessionStartMeta
|
|
114487
114541
|
}), startupAbort), this.logger, "connection.loadSession", this.options.sessionId, ACP_LOAD_SESSION_TIMEOUT_MS);
|
|
114488
114542
|
const loadDurationMs = performance$1.now() - loadStart;
|
|
114489
114543
|
sessionResponse = {
|
|
@@ -114525,7 +114579,7 @@ ${incoming}`).output;
|
|
|
114525
114579
|
sessionId: resumeSessionId,
|
|
114526
114580
|
cwd: workdir,
|
|
114527
114581
|
mcpServers,
|
|
114528
|
-
...
|
|
114582
|
+
...sessionStartMeta
|
|
114529
114583
|
}), startupAbort), this.logger, "connection.resumeSession", this.options.sessionId, ACP_RESUME_SESSION_TIMEOUT_MS);
|
|
114530
114584
|
const resumeDurationMs = performance$1.now() - resumeStart;
|
|
114531
114585
|
sessionResponse = {
|
|
@@ -114565,7 +114619,7 @@ ${incoming}`).output;
|
|
|
114565
114619
|
sessionResponse = await withTimeout$2(withAbort(connection2.newSession({
|
|
114566
114620
|
cwd: workdir,
|
|
114567
114621
|
mcpServers,
|
|
114568
|
-
...
|
|
114622
|
+
...sessionStartMeta
|
|
114569
114623
|
}), startupAbort), this.logger, "connection.newSession", this.options.sessionId, ACP_NEW_SESSION_TIMEOUT_MS);
|
|
114570
114624
|
} catch (error2) {
|
|
114571
114625
|
if (isAcpAuthenticationRequired(error2)) {
|
|
@@ -114632,7 +114686,7 @@ ${incoming}`).output;
|
|
|
114632
114686
|
return await withTimeout$2(connection2.newSession({
|
|
114633
114687
|
cwd: workdir,
|
|
114634
114688
|
mcpServers,
|
|
114635
|
-
...this.
|
|
114689
|
+
...this.getSessionStartMeta()
|
|
114636
114690
|
}), this.logger, "connection.newSession.editAndResend", this.options.sessionId, timeoutMs);
|
|
114637
114691
|
} catch (error2) {
|
|
114638
114692
|
throw new Error(`[ACP_SESSION_PREPARE_FAILED] ${formatErrorMessage(error2)}`, {
|
|
@@ -114648,14 +114702,7 @@ ${incoming}`).output;
|
|
|
114648
114702
|
sessionId: sourceSessionId,
|
|
114649
114703
|
cwd: workdir,
|
|
114650
114704
|
mcpServers,
|
|
114651
|
-
|
|
114652
|
-
lody: {
|
|
114653
|
-
forkAtTurn: {
|
|
114654
|
-
version: 1,
|
|
114655
|
-
turnId: forkSessionTurnId
|
|
114656
|
-
}
|
|
114657
|
-
}
|
|
114658
|
-
}
|
|
114705
|
+
...this.getSessionStartMeta(forkSessionTurnId)
|
|
114659
114706
|
}), this.logger, "connection.unstable_forkSession.editAndResend", this.options.sessionId, timeoutMs);
|
|
114660
114707
|
} catch (error2) {
|
|
114661
114708
|
throw new Error(`[ACP_FORK_FAILED] ${formatErrorMessage(error2)}`, {
|
|
@@ -114917,6 +114964,7 @@ ${incoming}`).output;
|
|
|
114917
114964
|
this.currentModel = this.resolveModelInfo(this.currentModel.modelId);
|
|
114918
114965
|
}
|
|
114919
114966
|
}
|
|
114967
|
+
if (result) this.configOptionValues[configId] = value;
|
|
114920
114968
|
this.logger.debug(`[${this.options.sessionId}] ACP session config option set: ${configId}=${value}`);
|
|
114921
114969
|
return result?.configOptions;
|
|
114922
114970
|
}
|
|
@@ -116013,7 +116061,7 @@ ${error2.message}` : execaMessage;
|
|
|
116013
116061
|
function requireBufferStream() {
|
|
116014
116062
|
if (hasRequiredBufferStream) return bufferStream;
|
|
116015
116063
|
hasRequiredBufferStream = 1;
|
|
116016
|
-
const { PassThrough: PassThroughStream } =
|
|
116064
|
+
const { PassThrough: PassThroughStream } = Zr;
|
|
116017
116065
|
bufferStream = (options) => {
|
|
116018
116066
|
options = {
|
|
116019
116067
|
...options
|
|
@@ -116062,7 +116110,7 @@ ${error2.message}` : execaMessage;
|
|
|
116062
116110
|
if (hasRequiredGetStream) return getStream.exports;
|
|
116063
116111
|
hasRequiredGetStream = 1;
|
|
116064
116112
|
const { constants: BufferConstants } = require$$0$6;
|
|
116065
|
-
const stream2 =
|
|
116113
|
+
const stream2 = Zr;
|
|
116066
116114
|
const { promisify: promisify2 } = require$$0$5;
|
|
116067
116115
|
const bufferStream2 = requireBufferStream();
|
|
116068
116116
|
const streamPipelinePromisified = promisify2(stream2.pipeline);
|
|
@@ -116122,7 +116170,7 @@ ${error2.message}` : execaMessage;
|
|
|
116122
116170
|
function requireMergeStream() {
|
|
116123
116171
|
if (hasRequiredMergeStream) return mergeStream;
|
|
116124
116172
|
hasRequiredMergeStream = 1;
|
|
116125
|
-
const { PassThrough: PassThrough2 } =
|
|
116173
|
+
const { PassThrough: PassThrough2 } = Zr;
|
|
116126
116174
|
mergeStream = function() {
|
|
116127
116175
|
var sources = [];
|
|
116128
116176
|
var output = new PassThrough2({
|
|
@@ -116370,7 +116418,7 @@ ${error2.message}` : execaMessage;
|
|
|
116370
116418
|
if (hasRequiredExeca) return execa$1.exports;
|
|
116371
116419
|
hasRequiredExeca = 1;
|
|
116372
116420
|
const path2 = path__default$1;
|
|
116373
|
-
const childProcess = require$$1$
|
|
116421
|
+
const childProcess = require$$1$8;
|
|
116374
116422
|
const crossSpawn2 = requireCrossSpawn();
|
|
116375
116423
|
const stripFinalNewline2 = requireStripFinalNewline();
|
|
116376
116424
|
const npmRunPath2 = requireNpmRunPath();
|
|
@@ -117853,7 +117901,7 @@ ${error2.message}` : execaMessage;
|
|
|
117853
117901
|
validate: validate2
|
|
117854
117902
|
});
|
|
117855
117903
|
};
|
|
117856
|
-
const realZlibConstants =
|
|
117904
|
+
const realZlibConstants = $s__default.constants || {
|
|
117857
117905
|
ZLIB_VERNUM: 4736
|
|
117858
117906
|
};
|
|
117859
117907
|
const constants = Object.freeze(Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
@@ -118013,11 +118061,11 @@ ${error2.message}` : execaMessage;
|
|
|
118013
118061
|
this.#flushFlag = opts.flush ?? 0;
|
|
118014
118062
|
this.#finishFlushFlag = opts.finishFlush ?? 0;
|
|
118015
118063
|
this.#fullFlushFlag = opts.fullFlushFlag ?? 0;
|
|
118016
|
-
if (typeof
|
|
118064
|
+
if (typeof $s[mode2] !== "function") {
|
|
118017
118065
|
throw new TypeError("Compression method not supported: " + mode2);
|
|
118018
118066
|
}
|
|
118019
118067
|
try {
|
|
118020
|
-
this.#handle = new
|
|
118068
|
+
this.#handle = new $s[mode2](opts);
|
|
118021
118069
|
} catch (er) {
|
|
118022
118070
|
throw new ZlibError(er, this.constructor);
|
|
118023
118071
|
}
|
|
@@ -121032,7 +121080,7 @@ ${error2.message}` : execaMessage;
|
|
|
121032
121080
|
return checkCwd(dir, done2);
|
|
121033
121081
|
}
|
|
121034
121082
|
if (preserve) {
|
|
121035
|
-
return
|
|
121083
|
+
return jt__default.mkdir(dir, {
|
|
121036
121084
|
mode: mode2,
|
|
121037
121085
|
recursive: true
|
|
121038
121086
|
}).then((made) => done2(null, made ?? void 0), done2);
|
|
@@ -122282,7 +122330,7 @@ ${error2.message}` : execaMessage;
|
|
|
122282
122330
|
hasRequiredFdSlicer = 1;
|
|
122283
122331
|
var fs2 = fs__default;
|
|
122284
122332
|
var util2 = require$$0$5;
|
|
122285
|
-
var stream2 =
|
|
122333
|
+
var stream2 = Zr;
|
|
122286
122334
|
var Readable2 = stream2.Readable;
|
|
122287
122335
|
var Writable = stream2.Writable;
|
|
122288
122336
|
var PassThrough2 = stream2.PassThrough;
|
|
@@ -122848,14 +122896,14 @@ ${error2.message}` : execaMessage;
|
|
|
122848
122896
|
if (hasRequiredYauzl) return yauzl;
|
|
122849
122897
|
hasRequiredYauzl = 1;
|
|
122850
122898
|
var fs2 = fs__default;
|
|
122851
|
-
var zlib =
|
|
122899
|
+
var zlib = $s__default;
|
|
122852
122900
|
var fd_slicer = requireFdSlicer();
|
|
122853
122901
|
var crc322 = requireBufferCrc32();
|
|
122854
122902
|
var util2 = require$$0$5;
|
|
122855
122903
|
var EventEmitter2 = require$$0$7.EventEmitter;
|
|
122856
|
-
var Transform2 =
|
|
122857
|
-
var PassThrough2 =
|
|
122858
|
-
var Writable =
|
|
122904
|
+
var Transform2 = Zr.Transform;
|
|
122905
|
+
var PassThrough2 = Zr.PassThrough;
|
|
122906
|
+
var Writable = Zr.Writable;
|
|
122859
122907
|
yauzl.open = open2;
|
|
122860
122908
|
yauzl.fromFd = fromFd;
|
|
122861
122909
|
yauzl.fromBuffer = fromBuffer;
|
|
@@ -124284,60 +124332,154 @@ ${error2.message}` : execaMessage;
|
|
|
124284
124332
|
highWaterMark
|
|
124285
124333
|
}));
|
|
124286
124334
|
}
|
|
124287
|
-
const version$
|
|
124335
|
+
const version$7 = "1.6.2";
|
|
124288
124336
|
const dependencies$1 = {
|
|
124289
|
-
"@openai/codex": "^0.
|
|
124337
|
+
"@openai/codex": "^0.148.0"
|
|
124290
124338
|
};
|
|
124291
124339
|
const codexPackageJson = {
|
|
124292
|
-
version: version$
|
|
124340
|
+
version: version$7,
|
|
124293
124341
|
dependencies: dependencies$1
|
|
124294
124342
|
};
|
|
124295
|
-
const version$
|
|
124343
|
+
const version$6 = "0.1.0";
|
|
124296
124344
|
const grokPackageJson = {
|
|
124297
|
-
version: version$
|
|
124345
|
+
version: version$6
|
|
124298
124346
|
};
|
|
124299
|
-
const version$
|
|
124347
|
+
const version$5 = "2.1.232";
|
|
124300
124348
|
const platforms = {
|
|
124301
124349
|
"darwin-arm64": {
|
|
124302
|
-
"
|
|
124303
|
-
"
|
|
124350
|
+
"binary": "claude",
|
|
124351
|
+
"checksum": "7b39c1588df919d001dea3ffd5651adb682f2451b5a0e18d42d4233296b53cc7",
|
|
124352
|
+
"size": 306111312
|
|
124304
124353
|
},
|
|
124305
124354
|
"darwin-x64": {
|
|
124306
|
-
"
|
|
124307
|
-
"
|
|
124355
|
+
"binary": "claude",
|
|
124356
|
+
"checksum": "aa3d606d7bf0ea9739a6d0de11810e72a662e7a4e5061d67ee7f8bc47c8890f9",
|
|
124357
|
+
"size": 314779248
|
|
124308
124358
|
},
|
|
124309
124359
|
"linux-arm64": {
|
|
124310
|
-
"
|
|
124311
|
-
"
|
|
124360
|
+
"binary": "claude",
|
|
124361
|
+
"checksum": "20797ebc644dfc47a69865c46d5cf702c7dbedd48d4268063b8828ebd55b39d0",
|
|
124362
|
+
"size": 320133352
|
|
124312
124363
|
},
|
|
124313
124364
|
"linux-x64": {
|
|
124314
|
-
"
|
|
124315
|
-
"
|
|
124365
|
+
"binary": "claude",
|
|
124366
|
+
"checksum": "61d23f8749136907d586d5b11831ea8a5234d4c1dea40a5e55c33b52e204c6d1",
|
|
124367
|
+
"size": 323021104
|
|
124316
124368
|
},
|
|
124317
124369
|
"linux-arm64-musl": {
|
|
124318
|
-
"
|
|
124319
|
-
"
|
|
124370
|
+
"binary": "claude",
|
|
124371
|
+
"checksum": "bf6481aa98b84d3e51460f7cf07fe54cb8d116882b72cee7bff941a2776ac91e",
|
|
124372
|
+
"size": 313278016
|
|
124320
124373
|
},
|
|
124321
124374
|
"linux-x64-musl": {
|
|
124322
|
-
"
|
|
124323
|
-
"
|
|
124375
|
+
"binary": "claude",
|
|
124376
|
+
"checksum": "93c8a9ef90adfa5bb8a34dfd5f32fc4e820532ca1e1ec5e6bb2049a5069a03b4",
|
|
124377
|
+
"size": 317165312
|
|
124324
124378
|
},
|
|
124325
124379
|
"win32-x64": {
|
|
124326
|
-
"
|
|
124327
|
-
"
|
|
124380
|
+
"binary": "claude.exe",
|
|
124381
|
+
"checksum": "ec9e32479bc887809003c91384c6c3a26e7691856d1916f72f6f6d21800f3bd6",
|
|
124382
|
+
"size": 319026336
|
|
124328
124383
|
},
|
|
124329
124384
|
"win32-arm64": {
|
|
124330
|
-
"
|
|
124331
|
-
"
|
|
124385
|
+
"binary": "claude.exe",
|
|
124386
|
+
"checksum": "301bfd5a624d6280d4d4e4ba7523fafdfa439a33e9530478719eeb6efec51d52",
|
|
124387
|
+
"size": 306950304
|
|
124332
124388
|
}
|
|
124333
124389
|
};
|
|
124334
124390
|
const claudeSdkManifestJson = {
|
|
124335
|
-
version: version$
|
|
124391
|
+
version: version$5,
|
|
124336
124392
|
platforms
|
|
124337
124393
|
};
|
|
124338
|
-
const version$
|
|
124394
|
+
const version$4 = "0.3.232";
|
|
124339
124395
|
const claudeSdkPackageJson = {
|
|
124340
|
-
version: version$
|
|
124396
|
+
version: version$4
|
|
124397
|
+
};
|
|
124398
|
+
const sdkVersion = "0.3.232";
|
|
124399
|
+
const version$3 = "2.1.232";
|
|
124400
|
+
const artifacts$1 = {
|
|
124401
|
+
"darwin-arm64": {
|
|
124402
|
+
"fileName": "anthropic-ai-claude-agent-sdk-darwin-arm64-0.3.232.tar.zst",
|
|
124403
|
+
"sha256": "09c775adf243d27a5c13e6724b3960409612b0da483c38fa108a1c03be515a5a",
|
|
124404
|
+
"size": 70030420
|
|
124405
|
+
},
|
|
124406
|
+
"darwin-x64": {
|
|
124407
|
+
"fileName": "anthropic-ai-claude-agent-sdk-darwin-x64-0.3.232.tar.zst",
|
|
124408
|
+
"sha256": "68f687528e5d610e14a379ff7ad1e6a60aa7d600b4dc20dc31b4af96fffda570",
|
|
124409
|
+
"size": 74349877
|
|
124410
|
+
},
|
|
124411
|
+
"linux-arm64": {
|
|
124412
|
+
"fileName": "anthropic-ai-claude-agent-sdk-linux-arm64-0.3.232.tar.zst",
|
|
124413
|
+
"sha256": "8c7c75910f5d29c3cf3fe15e4c17abfb05db616db2838b3a764f6b243ad78165",
|
|
124414
|
+
"size": 79104443
|
|
124415
|
+
},
|
|
124416
|
+
"linux-x64": {
|
|
124417
|
+
"fileName": "anthropic-ai-claude-agent-sdk-linux-x64-0.3.232.tar.zst",
|
|
124418
|
+
"sha256": "e0303ad6167b82fad98a80dd6dc3fd23d82562de5181094775c388118951d999",
|
|
124419
|
+
"size": 79732583
|
|
124420
|
+
},
|
|
124421
|
+
"linux-arm64-musl": {
|
|
124422
|
+
"fileName": "anthropic-ai-claude-agent-sdk-linux-arm64-musl-0.3.232.tar.zst",
|
|
124423
|
+
"sha256": "b0dd9da5095baf314160e3a3f6ac1c85a1ef4b4e326c4bde662f92fe8783840b",
|
|
124424
|
+
"size": 77411461
|
|
124425
|
+
},
|
|
124426
|
+
"linux-x64-musl": {
|
|
124427
|
+
"fileName": "anthropic-ai-claude-agent-sdk-linux-x64-musl-0.3.232.tar.zst",
|
|
124428
|
+
"sha256": "989e8148bb5944d038f4ea11595742084ec3b38837e08e5af25229ada27c3730",
|
|
124429
|
+
"size": 77995010
|
|
124430
|
+
},
|
|
124431
|
+
"win32-arm64": {
|
|
124432
|
+
"fileName": "anthropic-ai-claude-agent-sdk-win32-arm64-0.3.232.tar.zst",
|
|
124433
|
+
"sha256": "7cc4f6f2a23fa43993da830e00e3e2ca46b90864a2d38e1f3678f70de9e2f440",
|
|
124434
|
+
"size": 78979373
|
|
124435
|
+
},
|
|
124436
|
+
"win32-x64": {
|
|
124437
|
+
"fileName": "anthropic-ai-claude-agent-sdk-win32-x64-0.3.232.tar.zst",
|
|
124438
|
+
"sha256": "ed09d440d4cf7881439850287485d3198384538c79d8d3e5f0740b1e40b10db3",
|
|
124439
|
+
"size": 82535283
|
|
124440
|
+
}
|
|
124441
|
+
};
|
|
124442
|
+
const claudeRuntimeManifestJson = {
|
|
124443
|
+
sdkVersion,
|
|
124444
|
+
version: version$3,
|
|
124445
|
+
artifacts: artifacts$1
|
|
124446
|
+
};
|
|
124447
|
+
const version$2 = "0.148.0";
|
|
124448
|
+
const artifacts = {
|
|
124449
|
+
"darwin-arm64": {
|
|
124450
|
+
"fileName": "codex-package-aarch64-apple-darwin.tar.zst",
|
|
124451
|
+
"sha256": "dba92ada12f223751f30a9535c81c6a3ac6a2c1b2469d628c92b3e6be38eff66",
|
|
124452
|
+
"size": 76351891
|
|
124453
|
+
},
|
|
124454
|
+
"darwin-x64": {
|
|
124455
|
+
"fileName": "codex-package-x86_64-apple-darwin.tar.zst",
|
|
124456
|
+
"sha256": "ea8a14bca1cfc5a80d2a90e532617cc3c089cb69d2a114a61db645de6d051916",
|
|
124457
|
+
"size": 83818234
|
|
124458
|
+
},
|
|
124459
|
+
"linux-arm64": {
|
|
124460
|
+
"fileName": "codex-package-aarch64-unknown-linux-musl.tar.zst",
|
|
124461
|
+
"sha256": "084e6261fd68bd2a869f319375a022b2294d7d0f4044cbb113b8fa0755b01af9",
|
|
124462
|
+
"size": 79728248
|
|
124463
|
+
},
|
|
124464
|
+
"linux-x64": {
|
|
124465
|
+
"fileName": "codex-package-x86_64-unknown-linux-musl.tar.zst",
|
|
124466
|
+
"sha256": "257701de0d625d46e0e1c0c69db1a8a3fc1265c646a190e9fb965d1f66d54cd2",
|
|
124467
|
+
"size": 85609844
|
|
124468
|
+
},
|
|
124469
|
+
"win32-arm64": {
|
|
124470
|
+
"fileName": "codex-package-aarch64-pc-windows-msvc.tar.zst",
|
|
124471
|
+
"sha256": "e043d518a6ad64271616bf4408737672e2e48b5ce472d2f0a69149434ad0d189",
|
|
124472
|
+
"size": 87165328
|
|
124473
|
+
},
|
|
124474
|
+
"win32-x64": {
|
|
124475
|
+
"fileName": "codex-package-x86_64-pc-windows-msvc.tar.zst",
|
|
124476
|
+
"sha256": "a9fc1afe438a326aa25b11c31ec7586c176f3713d7ee2a0bfd17b869283bd6ff",
|
|
124477
|
+
"size": 93722309
|
|
124478
|
+
}
|
|
124479
|
+
};
|
|
124480
|
+
const codexRuntimeManifestJson = {
|
|
124481
|
+
version: version$2,
|
|
124482
|
+
artifacts
|
|
124341
124483
|
};
|
|
124342
124484
|
const version$1 = "0.37.0-lody.753c83056944";
|
|
124343
124485
|
const minNodeVersion = "22.19.0";
|
|
@@ -124443,14 +124585,19 @@ ${error2.message}` : execaMessage;
|
|
|
124443
124585
|
}
|
|
124444
124586
|
return true;
|
|
124445
124587
|
}
|
|
124446
|
-
const
|
|
124447
|
-
const
|
|
124448
|
-
if (
|
|
124449
|
-
throw new Error(`
|
|
124588
|
+
const CODEX_DEPENDENCY_VERSION = resolveSingleDependencyVersion("@openai/codex", codexPackageJson.dependencies["@openai/codex"]);
|
|
124589
|
+
const CODEX_RUNTIME_VERSION = codexRuntimeManifestJson.version;
|
|
124590
|
+
if (CODEX_RUNTIME_VERSION !== CODEX_DEPENDENCY_VERSION) {
|
|
124591
|
+
throw new Error(`Codex runtime manifest ${CODEX_RUNTIME_VERSION} does not match @openai/codex ${CODEX_DEPENDENCY_VERSION}. Run pnpm mirror:agent-runtimes -- --runtime codex to refresh it.`);
|
|
124592
|
+
}
|
|
124593
|
+
const CLAUDE_DEPENDENCY_VERSION = resolveSingleDependencyVersion("@anthropic-ai/claude-agent-sdk", packageJson.dependencies["@anthropic-ai/claude-agent-sdk"]);
|
|
124594
|
+
const CLAUDE_AGENT_SDK_VERSION = claudeRuntimeManifestJson.sdkVersion;
|
|
124595
|
+
const CLAUDE_CODE_RUNTIME_VERSION = claudeRuntimeManifestJson.version;
|
|
124596
|
+
if (claudeSdkPackageJson.version !== CLAUDE_DEPENDENCY_VERSION || CLAUDE_AGENT_SDK_VERSION !== CLAUDE_DEPENDENCY_VERSION || CLAUDE_CODE_RUNTIME_VERSION !== claudeSdkManifestJson.version) {
|
|
124597
|
+
throw new Error(`Claude runtime manifest ${CLAUDE_AGENT_SDK_VERSION}/${CLAUDE_CODE_RUNTIME_VERSION} does not match @anthropic-ai/claude-agent-sdk ${CLAUDE_DEPENDENCY_VERSION}/${claudeSdkManifestJson.version}. Run pnpm mirror:agent-runtimes -- --runtime claude-code to refresh it.`);
|
|
124450
124598
|
}
|
|
124451
124599
|
const CODEX_ACP_ADAPTER_VERSION = codexPackageJson.version;
|
|
124452
124600
|
const CLAUDE_ACP_ADAPTER_VERSION = packageJson.version;
|
|
124453
|
-
const CLAUDE_CODE_RUNTIME_VERSION = claudeSdkManifestJson.version;
|
|
124454
124601
|
const KIMI_CODE_VERSION = kimiRuntimeManifestJson.version;
|
|
124455
124602
|
const GROK_ACP_ADAPTER_VERSION = grokPackageJson.version;
|
|
124456
124603
|
const GROK_BUILD_RUNTIME_VERSION = runtimeManifest.officialRuntime.version;
|
|
@@ -124459,139 +124606,55 @@ ${error2.message}` : execaMessage;
|
|
|
124459
124606
|
const BUILTIN_CLAUDE_CAPABILITY_SOURCE_VERSION = `builtin-claude-acp:${CLAUDE_ACP_ADAPTER_VERSION}+agent-sdk:${CLAUDE_AGENT_SDK_VERSION}+claude-code:${CLAUDE_CODE_RUNTIME_VERSION}`;
|
|
124460
124607
|
const BUILTIN_KIMI_CAPABILITY_SOURCE_VERSION = `builtin-kimi:${KIMI_CODE_VERSION}`;
|
|
124461
124608
|
const BUILTIN_GROK_CAPABILITY_SOURCE_VERSION = `builtin-grok-acp:${GROK_ACP_ADAPTER_VERSION}+official-grok:${GROK_BUILD_RUNTIME_VERSION}`;
|
|
124609
|
+
function createCodexRuntimeArchive(platform2) {
|
|
124610
|
+
const artifact2 = codexRuntimeManifestJson.artifacts[platform2];
|
|
124611
|
+
return {
|
|
124612
|
+
fileName: artifact2.fileName,
|
|
124613
|
+
sha256: artifact2.sha256,
|
|
124614
|
+
size: artifact2.size,
|
|
124615
|
+
compression: "zstd",
|
|
124616
|
+
cmd: platform2.startsWith("win32-") ? "bin/codex.exe" : "bin/codex"
|
|
124617
|
+
};
|
|
124618
|
+
}
|
|
124619
|
+
function createClaudeRuntimeArchive(platform2) {
|
|
124620
|
+
const artifact2 = claudeRuntimeManifestJson.artifacts[platform2];
|
|
124621
|
+
const executable = claudeSdkManifestJson.platforms[platform2];
|
|
124622
|
+
return {
|
|
124623
|
+
fileName: artifact2.fileName,
|
|
124624
|
+
sha256: artifact2.sha256,
|
|
124625
|
+
size: artifact2.size,
|
|
124626
|
+
compression: "zstd",
|
|
124627
|
+
cmd: platform2.startsWith("win32-") ? "claude.exe" : "claude",
|
|
124628
|
+
stripComponents: 1,
|
|
124629
|
+
executableSha256: executable.checksum,
|
|
124630
|
+
executableSize: executable.size
|
|
124631
|
+
};
|
|
124632
|
+
}
|
|
124462
124633
|
const RUNTIMES = {
|
|
124463
124634
|
codex: {
|
|
124464
124635
|
name: "codex",
|
|
124465
124636
|
version: CODEX_RUNTIME_VERSION,
|
|
124466
124637
|
platforms: {
|
|
124467
|
-
"darwin-arm64":
|
|
124468
|
-
|
|
124469
|
-
|
|
124470
|
-
|
|
124471
|
-
|
|
124472
|
-
|
|
124473
|
-
},
|
|
124474
|
-
"darwin-x64": {
|
|
124475
|
-
fileName: "codex-package-x86_64-apple-darwin.tar.zst",
|
|
124476
|
-
sha256: "373c728c0912b7c65af742bb649f0ff056300f8e8a33a619be0bab62f2afc6ba",
|
|
124477
|
-
size: 85008508,
|
|
124478
|
-
compression: "zstd",
|
|
124479
|
-
cmd: "bin/codex"
|
|
124480
|
-
},
|
|
124481
|
-
"linux-arm64": {
|
|
124482
|
-
fileName: "codex-package-aarch64-unknown-linux-musl.tar.zst",
|
|
124483
|
-
sha256: "692ff5c5d9eb86774c0448d930895e46659eee6a2c12f46b97399da458c1e8b7",
|
|
124484
|
-
size: 80608473,
|
|
124485
|
-
compression: "zstd",
|
|
124486
|
-
cmd: "bin/codex"
|
|
124487
|
-
},
|
|
124488
|
-
"linux-x64": {
|
|
124489
|
-
fileName: "codex-package-x86_64-unknown-linux-musl.tar.zst",
|
|
124490
|
-
sha256: "494368127e27ab625b2a5e759f83447e1d7d00b6ae49a5e2c17df5fd7c4aac1d",
|
|
124491
|
-
size: 86804357,
|
|
124492
|
-
compression: "zstd",
|
|
124493
|
-
cmd: "bin/codex"
|
|
124494
|
-
},
|
|
124495
|
-
"win32-arm64": {
|
|
124496
|
-
fileName: "codex-package-aarch64-pc-windows-msvc.tar.zst",
|
|
124497
|
-
sha256: "0c9d43e1ce013900850c82ab558cbafae9e8b05363689ab68cc0b4c87ac2b267",
|
|
124498
|
-
size: 88080469,
|
|
124499
|
-
compression: "zstd",
|
|
124500
|
-
cmd: "bin/codex.exe"
|
|
124501
|
-
},
|
|
124502
|
-
"win32-x64": {
|
|
124503
|
-
fileName: "codex-package-x86_64-pc-windows-msvc.tar.zst",
|
|
124504
|
-
sha256: "5931e080440a0bff1413d55b62921e26238f5410d82d79e5327202bfef1833a4",
|
|
124505
|
-
size: 95093149,
|
|
124506
|
-
compression: "zstd",
|
|
124507
|
-
cmd: "bin/codex.exe"
|
|
124508
|
-
}
|
|
124638
|
+
"darwin-arm64": createCodexRuntimeArchive("darwin-arm64"),
|
|
124639
|
+
"darwin-x64": createCodexRuntimeArchive("darwin-x64"),
|
|
124640
|
+
"linux-arm64": createCodexRuntimeArchive("linux-arm64"),
|
|
124641
|
+
"linux-x64": createCodexRuntimeArchive("linux-x64"),
|
|
124642
|
+
"win32-arm64": createCodexRuntimeArchive("win32-arm64"),
|
|
124643
|
+
"win32-x64": createCodexRuntimeArchive("win32-x64")
|
|
124509
124644
|
}
|
|
124510
124645
|
},
|
|
124511
124646
|
"claude-code": {
|
|
124512
124647
|
name: "claude-code",
|
|
124513
124648
|
version: CLAUDE_CODE_RUNTIME_VERSION,
|
|
124514
124649
|
platforms: {
|
|
124515
|
-
"darwin-arm64":
|
|
124516
|
-
|
|
124517
|
-
|
|
124518
|
-
|
|
124519
|
-
|
|
124520
|
-
|
|
124521
|
-
|
|
124522
|
-
|
|
124523
|
-
executableSize: claudeSdkManifestJson.platforms["darwin-arm64"].size
|
|
124524
|
-
},
|
|
124525
|
-
"darwin-x64": {
|
|
124526
|
-
fileName: `anthropic-ai-claude-agent-sdk-darwin-x64-${CLAUDE_AGENT_SDK_VERSION}.tar.zst`,
|
|
124527
|
-
sha256: "5c74a294444e69f9b13f4e103247b6b51a7b10c555cfbce9f5434c37e662e9bb",
|
|
124528
|
-
size: 64691464,
|
|
124529
|
-
compression: "zstd",
|
|
124530
|
-
cmd: "claude",
|
|
124531
|
-
stripComponents: 1,
|
|
124532
|
-
executableSha256: claudeSdkManifestJson.platforms["darwin-x64"].checksum,
|
|
124533
|
-
executableSize: claudeSdkManifestJson.platforms["darwin-x64"].size
|
|
124534
|
-
},
|
|
124535
|
-
"linux-arm64": {
|
|
124536
|
-
fileName: `anthropic-ai-claude-agent-sdk-linux-arm64-${CLAUDE_AGENT_SDK_VERSION}.tar.zst`,
|
|
124537
|
-
sha256: "bc41781f1003c2856e3ce0044da3fa752ef279a1cc29a8e23e3ce13c8033650e",
|
|
124538
|
-
size: 69763140,
|
|
124539
|
-
compression: "zstd",
|
|
124540
|
-
cmd: "claude",
|
|
124541
|
-
stripComponents: 1,
|
|
124542
|
-
executableSha256: claudeSdkManifestJson.platforms["linux-arm64"].checksum,
|
|
124543
|
-
executableSize: claudeSdkManifestJson.platforms["linux-arm64"].size
|
|
124544
|
-
},
|
|
124545
|
-
"linux-x64": {
|
|
124546
|
-
fileName: `anthropic-ai-claude-agent-sdk-linux-x64-${CLAUDE_AGENT_SDK_VERSION}.tar.zst`,
|
|
124547
|
-
sha256: "076972a61402e14afffb5d64a40e50ab5074a3a7f3740fed44d64b6cb7839c84",
|
|
124548
|
-
size: 70585519,
|
|
124549
|
-
compression: "zstd",
|
|
124550
|
-
cmd: "claude",
|
|
124551
|
-
stripComponents: 1,
|
|
124552
|
-
executableSha256: claudeSdkManifestJson.platforms["linux-x64"].checksum,
|
|
124553
|
-
executableSize: claudeSdkManifestJson.platforms["linux-x64"].size
|
|
124554
|
-
},
|
|
124555
|
-
"linux-arm64-musl": {
|
|
124556
|
-
fileName: `anthropic-ai-claude-agent-sdk-linux-arm64-musl-${CLAUDE_AGENT_SDK_VERSION}.tar.zst`,
|
|
124557
|
-
sha256: "e9282b3ab96cb89aeb1eecba2bf7ab354486dbd48546ca8c8b0ace0844d88f75",
|
|
124558
|
-
size: 68233742,
|
|
124559
|
-
compression: "zstd",
|
|
124560
|
-
cmd: "claude",
|
|
124561
|
-
stripComponents: 1,
|
|
124562
|
-
executableSha256: claudeSdkManifestJson.platforms["linux-arm64-musl"].checksum,
|
|
124563
|
-
executableSize: claudeSdkManifestJson.platforms["linux-arm64-musl"].size
|
|
124564
|
-
},
|
|
124565
|
-
"linux-x64-musl": {
|
|
124566
|
-
fileName: `anthropic-ai-claude-agent-sdk-linux-x64-musl-${CLAUDE_AGENT_SDK_VERSION}.tar.zst`,
|
|
124567
|
-
sha256: "331f1470a4234ac1636971b7c586f41ae8c76ff987fe8d7e5736214186a93e86",
|
|
124568
|
-
size: 69249229,
|
|
124569
|
-
compression: "zstd",
|
|
124570
|
-
cmd: "claude",
|
|
124571
|
-
stripComponents: 1,
|
|
124572
|
-
executableSha256: claudeSdkManifestJson.platforms["linux-x64-musl"].checksum,
|
|
124573
|
-
executableSize: claudeSdkManifestJson.platforms["linux-x64-musl"].size
|
|
124574
|
-
},
|
|
124575
|
-
"win32-arm64": {
|
|
124576
|
-
fileName: `anthropic-ai-claude-agent-sdk-win32-arm64-${CLAUDE_AGENT_SDK_VERSION}.tar.zst`,
|
|
124577
|
-
sha256: "483e1285703ba75050055cc305a5b47526ac449bc223c2e30acaa3a7ac87560e",
|
|
124578
|
-
size: 69235703,
|
|
124579
|
-
compression: "zstd",
|
|
124580
|
-
cmd: "claude.exe",
|
|
124581
|
-
stripComponents: 1,
|
|
124582
|
-
executableSha256: claudeSdkManifestJson.platforms["win32-arm64"].checksum,
|
|
124583
|
-
executableSize: claudeSdkManifestJson.platforms["win32-arm64"].size
|
|
124584
|
-
},
|
|
124585
|
-
"win32-x64": {
|
|
124586
|
-
fileName: `anthropic-ai-claude-agent-sdk-win32-x64-${CLAUDE_AGENT_SDK_VERSION}.tar.zst`,
|
|
124587
|
-
sha256: "961eeabb2eaf9b3027fdc3caf10417ea738fb3ea64132307a7ae3a1d9f2309b8",
|
|
124588
|
-
size: 71046598,
|
|
124589
|
-
compression: "zstd",
|
|
124590
|
-
cmd: "claude.exe",
|
|
124591
|
-
stripComponents: 1,
|
|
124592
|
-
executableSha256: claudeSdkManifestJson.platforms["win32-x64"].checksum,
|
|
124593
|
-
executableSize: claudeSdkManifestJson.platforms["win32-x64"].size
|
|
124594
|
-
}
|
|
124650
|
+
"darwin-arm64": createClaudeRuntimeArchive("darwin-arm64"),
|
|
124651
|
+
"darwin-x64": createClaudeRuntimeArchive("darwin-x64"),
|
|
124652
|
+
"linux-arm64": createClaudeRuntimeArchive("linux-arm64"),
|
|
124653
|
+
"linux-x64": createClaudeRuntimeArchive("linux-x64"),
|
|
124654
|
+
"linux-arm64-musl": createClaudeRuntimeArchive("linux-arm64-musl"),
|
|
124655
|
+
"linux-x64-musl": createClaudeRuntimeArchive("linux-x64-musl"),
|
|
124656
|
+
"win32-arm64": createClaudeRuntimeArchive("win32-arm64"),
|
|
124657
|
+
"win32-x64": createClaudeRuntimeArchive("win32-x64")
|
|
124595
124658
|
}
|
|
124596
124659
|
},
|
|
124597
124660
|
"kimi-code": {
|
|
@@ -125441,6 +125504,7 @@ ${error2.message}` : execaMessage;
|
|
|
125441
125504
|
return {
|
|
125442
125505
|
command: "npx",
|
|
125443
125506
|
args: [
|
|
125507
|
+
"--force",
|
|
125444
125508
|
"--prefer-offline",
|
|
125445
125509
|
"-y",
|
|
125446
125510
|
...DEEPSEEK_HARNESS_NPX_PACKAGES.flatMap((packageName) => [
|
|
@@ -126857,6 +126921,7 @@ ${fallbackStderrTail}` : errorMessage2;
|
|
|
126857
126921
|
machineId: options.machineId,
|
|
126858
126922
|
terminalManager: options.terminalManager,
|
|
126859
126923
|
agentConfig: options.agentConfig,
|
|
126924
|
+
configOptionValues: options.configOptionValues,
|
|
126860
126925
|
launcher: options.launcher,
|
|
126861
126926
|
terminalEnabled: options.terminalEnabled,
|
|
126862
126927
|
onStartupStage: options.onStartupStage,
|
|
@@ -128923,7 +128988,7 @@ main().catch(() => {});
|
|
|
128923
128988
|
}
|
|
128924
128989
|
const readErrorCode = (error2) => error2 && typeof error2 === "object" ? error2.code : void 0;
|
|
128925
128990
|
function mapGitSpawnError(error2, cwd) {
|
|
128926
|
-
if (readErrorCode(error2) === "ENOENT" && fs$
|
|
128991
|
+
if (readErrorCode(error2) === "ENOENT" && fs$1.existsSync(cwd)) {
|
|
128927
128992
|
return new GitExecutableNotFoundError(error2);
|
|
128928
128993
|
}
|
|
128929
128994
|
return error2;
|
|
@@ -133928,6 +133993,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
|
|
|
133928
133993
|
workspaceId: message.workspaceId,
|
|
133929
133994
|
agentCliType: acpSessionConfig.cliType,
|
|
133930
133995
|
agentType: acpSessionConfig.agentType,
|
|
133996
|
+
configOptionValues: acpSessionConfig.configOptionValues,
|
|
133931
133997
|
mcpServerIds: acpSessionConfig.mcpServerIds ?? [],
|
|
133932
133998
|
customAcp: resumeCustomAcp,
|
|
133933
133999
|
runtimeOverrides: resumeRuntimeOverrides,
|
|
@@ -134425,6 +134491,7 @@ The postId is ${normalizedFeedbackPostId}. Use the feedback-progress-reporter sk
|
|
|
134425
134491
|
workspaceId,
|
|
134426
134492
|
agentCliType: acpSessionConfig.cliType,
|
|
134427
134493
|
agentType: acpSessionConfig.agentType,
|
|
134494
|
+
configOptionValues: acpSessionConfig.configOptionValues,
|
|
134428
134495
|
mcpServerIds: acpSessionConfig.mcpServerIds ?? [],
|
|
134429
134496
|
agentConfigId: existingMeta?.agentConfigId,
|
|
134430
134497
|
customAcp: acpSessionConfig.customAcp,
|
|
@@ -154681,11 +154748,11 @@ ${entry.text}`).join("\n\n");
|
|
|
154681
154748
|
return null;
|
|
154682
154749
|
}
|
|
154683
154750
|
try {
|
|
154684
|
-
const stat2 = await
|
|
154751
|
+
const stat2 = await jt.stat(absolutePath);
|
|
154685
154752
|
if (!stat2.isFile() || stat2.size > (options?.maxBytes ?? defaultMaxTextFileBytes)) {
|
|
154686
154753
|
return null;
|
|
154687
154754
|
}
|
|
154688
|
-
const content = await
|
|
154755
|
+
const content = await jt.readFile(absolutePath);
|
|
154689
154756
|
if (content.includes(0)) {
|
|
154690
154757
|
return null;
|
|
154691
154758
|
}
|
|
@@ -160519,18 +160586,18 @@ ${entry.text}`).join("\n\n");
|
|
|
160519
160586
|
};
|
|
160520
160587
|
async function ensureCatalogDir(filePath) {
|
|
160521
160588
|
const dir = path__default$1.dirname(filePath);
|
|
160522
|
-
await fs__default$
|
|
160589
|
+
await fs__default$2.mkdir(dir, {
|
|
160523
160590
|
recursive: true,
|
|
160524
160591
|
mode: 448
|
|
160525
160592
|
});
|
|
160526
160593
|
if (process.platform !== "win32") {
|
|
160527
|
-
await fs__default$
|
|
160594
|
+
await fs__default$2.chmod(dir, 448);
|
|
160528
160595
|
}
|
|
160529
160596
|
}
|
|
160530
160597
|
async function readCatalogFile(filePath) {
|
|
160531
160598
|
let raw2;
|
|
160532
160599
|
try {
|
|
160533
|
-
raw2 = await fs__default$
|
|
160600
|
+
raw2 = await fs__default$2.readFile(filePath, "utf8");
|
|
160534
160601
|
} catch (error2) {
|
|
160535
160602
|
throw mapReadError(filePath, error2);
|
|
160536
160603
|
}
|
|
@@ -160556,21 +160623,21 @@ ${entry.text}`).join("\n\n");
|
|
|
160556
160623
|
const parsed = CatalogSnapshotSchema.parse(snapshot);
|
|
160557
160624
|
await ensureCatalogDir(filePath);
|
|
160558
160625
|
const tempPath = `${filePath}.${process.pid}.${crypto__default.randomUUID()}.tmp`;
|
|
160559
|
-
await fs__default$
|
|
160626
|
+
await fs__default$2.writeFile(tempPath, `${JSON.stringify(parsed, null, 2)}
|
|
160560
160627
|
`, {
|
|
160561
160628
|
mode: 384
|
|
160562
160629
|
});
|
|
160563
160630
|
if (process.platform !== "win32") {
|
|
160564
|
-
await fs__default$
|
|
160631
|
+
await fs__default$2.chmod(tempPath, 384);
|
|
160565
160632
|
}
|
|
160566
|
-
await fs__default$
|
|
160633
|
+
await fs__default$2.rename(tempPath, filePath);
|
|
160567
160634
|
if (process.platform !== "win32") {
|
|
160568
|
-
await fs__default$
|
|
160635
|
+
await fs__default$2.chmod(filePath, 384);
|
|
160569
160636
|
}
|
|
160570
160637
|
}
|
|
160571
160638
|
async function backupCorruptCatalog(filePath) {
|
|
160572
160639
|
const backupPath = `${filePath}.corrupt-${process.pid}-${getServerNow()}`;
|
|
160573
|
-
await fs__default$
|
|
160640
|
+
await fs__default$2.rename(filePath, backupPath);
|
|
160574
160641
|
}
|
|
160575
160642
|
function makeLocalWorkspaceCatalog(options = {}) {
|
|
160576
160643
|
const filePath = options.filePath ?? getLocalWorkspaceCatalogPath();
|
|
@@ -162624,7 +162691,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
|
|
|
162624
162691
|
const isPreviewRegistryEntry = (value) => typeof value === "object" && value !== null && typeof value.key === "string" && Number.isInteger(value.pid) && typeof value.workspaceId === "string" && typeof value.machineId === "string" && typeof value.sessionId === "string" && typeof value.grantId === "string" && Number.isInteger(value.updatedAt);
|
|
162625
162692
|
const readPreviewRegistryEntries = async () => {
|
|
162626
162693
|
try {
|
|
162627
|
-
const raw2 = await fs__default$
|
|
162694
|
+
const raw2 = await fs__default$2.readFile(PREVIEW_REGISTRY_FILE, "utf8");
|
|
162628
162695
|
const parsed = JSON.parse(raw2);
|
|
162629
162696
|
if (!Array.isArray(parsed)) {
|
|
162630
162697
|
return [];
|
|
@@ -162635,13 +162702,13 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
|
|
|
162635
162702
|
}
|
|
162636
162703
|
};
|
|
162637
162704
|
const writePreviewRegistryEntries = async (entries) => {
|
|
162638
|
-
await fs__default$
|
|
162705
|
+
await fs__default$2.mkdir(path__default$1.dirname(PREVIEW_REGISTRY_FILE), {
|
|
162639
162706
|
recursive: true
|
|
162640
162707
|
});
|
|
162641
162708
|
const tmpPath = `${PREVIEW_REGISTRY_FILE}.${process.pid}.tmp`;
|
|
162642
|
-
await fs__default$
|
|
162709
|
+
await fs__default$2.writeFile(tmpPath, `${JSON.stringify(entries)}
|
|
162643
162710
|
`, "utf8");
|
|
162644
|
-
await fs__default$
|
|
162711
|
+
await fs__default$2.rename(tmpPath, PREVIEW_REGISTRY_FILE);
|
|
162645
162712
|
};
|
|
162646
162713
|
const filterLivePreviewRegistryEntries = (entries, now2) => entries.filter((entry) => isProcessAlive$1(entry.pid) && entry.updatedAt <= now2 + PREVIEW_REGISTRY_FUTURE_SKEW_MS);
|
|
162647
162714
|
const classifyPreviewTunnelCloseError = (error2) => {
|
|
@@ -163413,6 +163480,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
|
|
|
163413
163480
|
}
|
|
163414
163481
|
const ACP_OPERATION_TIMEOUT_MS = 12e4;
|
|
163415
163482
|
const ACP_PROCESS_EXIT_TIMEOUT_MS = 3e3;
|
|
163483
|
+
const LODY_READ_SESSION_HISTORY_METHOD = "_lody/session/history/read";
|
|
163416
163484
|
const MAX_LOCAL_PROJECT_HISTORY_CATALOG_SESSIONS = 100;
|
|
163417
163485
|
function waitForChildProcessExit(child, timeoutMs) {
|
|
163418
163486
|
if (child.exitCode !== null) {
|
|
@@ -163553,7 +163621,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
|
|
|
163553
163621
|
const resolved = path__default$1.resolve(rootPath);
|
|
163554
163622
|
let real = null;
|
|
163555
163623
|
try {
|
|
163556
|
-
real = await fs$
|
|
163624
|
+
real = await fs$2.realpath(resolved);
|
|
163557
163625
|
} catch {
|
|
163558
163626
|
real = null;
|
|
163559
163627
|
}
|
|
@@ -163565,6 +163633,36 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
|
|
|
163565
163633
|
}
|
|
163566
163634
|
return paths;
|
|
163567
163635
|
}
|
|
163636
|
+
function getLodyReadSessionHistoryMethod(initResponse) {
|
|
163637
|
+
const meta = initResponse.agentCapabilities?._meta;
|
|
163638
|
+
if (!meta || typeof meta !== "object" || Array.isArray(meta)) return null;
|
|
163639
|
+
const lody = meta.lody;
|
|
163640
|
+
if (!lody || typeof lody !== "object" || Array.isArray(lody)) return null;
|
|
163641
|
+
const capability = lody.readSessionHistory;
|
|
163642
|
+
if (!capability || typeof capability !== "object" || Array.isArray(capability)) return null;
|
|
163643
|
+
const record2 = capability;
|
|
163644
|
+
return record2.version === 1 && record2.method === LODY_READ_SESSION_HISTORY_METHOD ? LODY_READ_SESSION_HISTORY_METHOD : null;
|
|
163645
|
+
}
|
|
163646
|
+
async function requestHistorySessionReplay(args2) {
|
|
163647
|
+
if (args2.provider.cliType === "builtin" && args2.provider.agentType === "codex") {
|
|
163648
|
+
const method = getLodyReadSessionHistoryMethod(args2.initResponse);
|
|
163649
|
+
if (!method) {
|
|
163650
|
+
throw new Error(`${getProviderLabel$1(args2.provider)} ACP agent does not advertise agentCapabilities._meta.lody.readSessionHistory version 1`);
|
|
163651
|
+
}
|
|
163652
|
+
await withTimeout(args2.connection.request(method, {
|
|
163653
|
+
sessionId: args2.acpSessionId
|
|
163654
|
+
}), `${getProviderLabel$1(args2.provider)} ACP readSessionHistory (${args2.acpSessionId})`);
|
|
163655
|
+
return;
|
|
163656
|
+
}
|
|
163657
|
+
if (!args2.initResponse.agentCapabilities?.loadSession) {
|
|
163658
|
+
throw new Error(`${getProviderLabel$1(args2.provider)} ACP agent does not advertise loadSession`);
|
|
163659
|
+
}
|
|
163660
|
+
await withTimeout(args2.connection.loadSession({
|
|
163661
|
+
sessionId: args2.acpSessionId,
|
|
163662
|
+
cwd: args2.cwd,
|
|
163663
|
+
mcpServers: []
|
|
163664
|
+
}), `${getProviderLabel$1(args2.provider)} ACP loadSession (${args2.acpSessionId})`);
|
|
163665
|
+
}
|
|
163568
163666
|
async function listPaginatedHistorySessions(cwd, listPage, options = {}) {
|
|
163569
163667
|
const sessions = [];
|
|
163570
163668
|
const maxSessions = options.maxSessions ?? Number.POSITIVE_INFINITY;
|
|
@@ -163634,14 +163732,13 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
|
|
|
163634
163732
|
logger: args2.logger
|
|
163635
163733
|
});
|
|
163636
163734
|
try {
|
|
163637
|
-
|
|
163638
|
-
|
|
163639
|
-
|
|
163640
|
-
await withTimeout(connection2.loadSession({
|
|
163641
|
-
sessionId: args2.acpSessionId,
|
|
163735
|
+
await requestHistorySessionReplay({
|
|
163736
|
+
provider: args2.provider,
|
|
163737
|
+
acpSessionId: args2.acpSessionId,
|
|
163642
163738
|
cwd,
|
|
163643
|
-
|
|
163644
|
-
|
|
163739
|
+
connection: connection2,
|
|
163740
|
+
initResponse
|
|
163741
|
+
});
|
|
163645
163742
|
return collector.notifications;
|
|
163646
163743
|
} catch (error2) {
|
|
163647
163744
|
const message = `Failed to load ${getProviderLabel$1(args2.provider)} session ${args2.acpSessionId}: ${formatErrorMessage(error2)}`;
|
|
@@ -163982,6 +164079,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
|
|
|
163982
164079
|
}
|
|
163983
164080
|
function getHistoryCatalogStatus(existing) {
|
|
163984
164081
|
if (!existing) return "available";
|
|
164082
|
+
if (existing.meta.externalHistory?.status === "metadata_only") return "available";
|
|
163985
164083
|
return existing.meta.externalHistory?.status === "sync_conflict" ? "sync_conflict" : "imported";
|
|
163986
164084
|
}
|
|
163987
164085
|
function buildCatalogItem(provider, info, existing) {
|
|
@@ -164025,17 +164123,6 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
|
|
|
164025
164123
|
conflictReason: args2.conflictReason
|
|
164026
164124
|
};
|
|
164027
164125
|
}
|
|
164028
|
-
function buildMetadataOnlyExternalHistoryMeta(args2) {
|
|
164029
|
-
return {
|
|
164030
|
-
provider: args2.provider,
|
|
164031
|
-
source: "local-acp-history",
|
|
164032
|
-
sourceAcpSessionId: args2.sourceAcpSessionId,
|
|
164033
|
-
sourceUpdatedAt: args2.sourceUpdatedAt ?? void 0,
|
|
164034
|
-
importedTurnCount: 0,
|
|
164035
|
-
lastSyncAt: getServerNow(),
|
|
164036
|
-
status: "metadata_only"
|
|
164037
|
-
};
|
|
164038
|
-
}
|
|
164039
164126
|
class LocalProjectHistorySyncService {
|
|
164040
164127
|
constructor(manager, logger2, context2, provider) {
|
|
164041
164128
|
this.manager = manager;
|
|
@@ -164123,10 +164210,23 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
|
|
|
164123
164210
|
});
|
|
164124
164211
|
const existing = await this.findExistingHistorySession(args2.localProjectId, selectedId) ?? snapshot.existingByImportKey.get(importKey);
|
|
164125
164212
|
if (!existing) {
|
|
164213
|
+
const replayNotifications = await loadHistorySessionReplay({
|
|
164214
|
+
provider: this.provider,
|
|
164215
|
+
rootPath: args2.rootPath,
|
|
164216
|
+
acpSessionId,
|
|
164217
|
+
logger: this.logger
|
|
164218
|
+
});
|
|
164219
|
+
const materialized = materializeReplay({
|
|
164220
|
+
provider: this.provider,
|
|
164221
|
+
acpSessionId,
|
|
164222
|
+
replayNotifications,
|
|
164223
|
+
userId: this.context.userId
|
|
164224
|
+
});
|
|
164126
164225
|
const importedSession = await this.importNewSession({
|
|
164127
164226
|
info,
|
|
164128
164227
|
acpSessionId,
|
|
164129
|
-
project
|
|
164228
|
+
project,
|
|
164229
|
+
materialized
|
|
164130
164230
|
});
|
|
164131
164231
|
snapshot.existingByImportKey.set(importKey, importedSession);
|
|
164132
164232
|
summary2.imported += 1;
|
|
@@ -164146,7 +164246,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
|
|
|
164146
164246
|
acpSessionId,
|
|
164147
164247
|
message: formatErrorMessage(error2)
|
|
164148
164248
|
});
|
|
164149
|
-
this.logger.
|
|
164249
|
+
this.logger.warn(`[${this.providerKey}-history-sync] Failed to import ${getProviderLabel(this.provider)} session ${acpSessionId}: ${formatErrorMessage(error2)}`);
|
|
164150
164250
|
}
|
|
164151
164251
|
}
|
|
164152
164252
|
const catalog = await this.writeCatalogResult({
|
|
@@ -164401,13 +164501,38 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
|
|
|
164401
164501
|
title: resolveSessionTitle(args2.info, this.provider),
|
|
164402
164502
|
titleSource: "draft",
|
|
164403
164503
|
lastMessageAt,
|
|
164404
|
-
externalHistory:
|
|
164504
|
+
externalHistory: buildExternalHistoryMeta({
|
|
164405
164505
|
provider: this.provider,
|
|
164406
164506
|
sourceAcpSessionId: args2.acpSessionId,
|
|
164407
|
-
sourceUpdatedAt: args2.info.updatedAt
|
|
164507
|
+
sourceUpdatedAt: args2.info.updatedAt,
|
|
164508
|
+
materialized: args2.materialized
|
|
164408
164509
|
})
|
|
164409
164510
|
};
|
|
164410
|
-
|
|
164511
|
+
try {
|
|
164512
|
+
const sessionDoc = await this.manager.getOrCreateSessionDoc(sessionId);
|
|
164513
|
+
await sessionDoc.updateHistory(() => args2.materialized.history);
|
|
164514
|
+
await writeSessionImportedTurnHashes(sessionDoc, args2.materialized.turnHashes);
|
|
164515
|
+
await this.manager.repo.upsertDocMeta(roomId, meta);
|
|
164516
|
+
const synced = await sessionDoc.waitUntilSynced();
|
|
164517
|
+
if (!synced) {
|
|
164518
|
+
this.logger.warn(`[${this.providerKey}-history-sync] Imported history for ${sessionId} did not confirm remote sync before unload; it remains locally durable and will retry sync.`);
|
|
164519
|
+
}
|
|
164520
|
+
} catch (error2) {
|
|
164521
|
+
await this.manager.repo.deleteDoc(roomId).catch((cleanupError) => {
|
|
164522
|
+
this.logger.warn(`[${this.providerKey}-history-sync] Failed to delete incomplete imported session ${sessionId}: ${formatErrorMessage(cleanupError)}`);
|
|
164523
|
+
});
|
|
164524
|
+
await this.manager.cleanSessionDoc(sessionId, {
|
|
164525
|
+
preserveStatus: true
|
|
164526
|
+
}).catch((cleanupError) => {
|
|
164527
|
+
this.logger.warn(`[${this.providerKey}-history-sync] Failed to unload incomplete imported session ${sessionId}: ${formatErrorMessage(cleanupError)}`);
|
|
164528
|
+
});
|
|
164529
|
+
throw error2;
|
|
164530
|
+
}
|
|
164531
|
+
await this.manager.cleanSessionDoc(sessionId, {
|
|
164532
|
+
preserveStatus: true
|
|
164533
|
+
}).catch((cleanupError) => {
|
|
164534
|
+
this.logger.warn(`[${this.providerKey}-history-sync] Failed to unload imported session ${sessionId}: ${formatErrorMessage(cleanupError)}`);
|
|
164535
|
+
});
|
|
164411
164536
|
return {
|
|
164412
164537
|
sessionId,
|
|
164413
164538
|
meta
|
|
@@ -164500,7 +164625,7 @@ ${escapeHtmlScriptContent(VISUAL_ANNOTATION_INSPECTOR_BROWSER_SCRIPT)}
|
|
|
164500
164625
|
await this.manager.cleanSessionDoc(args2.existing.sessionId, {
|
|
164501
164626
|
preserveStatus: true
|
|
164502
164627
|
});
|
|
164503
|
-
return suffix.length > 0 ? "refreshed" : "skipped";
|
|
164628
|
+
return externalHistory.status === "metadata_only" || suffix.length > 0 ? "refreshed" : "skipped";
|
|
164504
164629
|
}
|
|
164505
164630
|
async markConflict(sessionId, info, materialized, reason) {
|
|
164506
164631
|
await this.manager.repo.upsertDocMeta(getSessionRoomId(sessionId), {
|
|
@@ -175094,7 +175219,7 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
175094
175219
|
}
|
|
175095
175220
|
InternalCodec.prototype.encoder = InternalEncoder;
|
|
175096
175221
|
InternalCodec.prototype.decoder = InternalDecoder;
|
|
175097
|
-
var StringDecoder2 = require$$1$
|
|
175222
|
+
var StringDecoder2 = require$$1$3.StringDecoder;
|
|
175098
175223
|
if (!StringDecoder2.prototype.end) StringDecoder2.prototype.end = function() {
|
|
175099
175224
|
};
|
|
175100
175225
|
function InternalDecoder(options, codec) {
|
|
@@ -179203,11 +179328,7 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
179203
179328
|
async startProcess(params, hooks2) {
|
|
179204
179329
|
const workdir = this.resolveWorkdir(params.cwd);
|
|
179205
179330
|
const env2 = this.buildEnv(params.env);
|
|
179206
|
-
const
|
|
179207
|
-
const processHandle = await this.sandbox.spawn("bash", [
|
|
179208
|
-
"-lc",
|
|
179209
|
-
formattedCommand
|
|
179210
|
-
], {
|
|
179331
|
+
const processHandle = await this.sandbox.spawn(params.command, params.args, {
|
|
179211
179332
|
cwd: workdir,
|
|
179212
179333
|
env: env2,
|
|
179213
179334
|
stdio: [
|
|
@@ -179256,13 +179377,6 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
179256
179377
|
state2.handle.dispose();
|
|
179257
179378
|
}
|
|
179258
179379
|
}
|
|
179259
|
-
function formatCommand(command2, args2) {
|
|
179260
|
-
if (!args2.length) {
|
|
179261
|
-
return command2;
|
|
179262
|
-
}
|
|
179263
|
-
const serializedArgs = args2.map((arg) => `'${arg.replace(/'/g, `'"'"'`)}'`).join(" ");
|
|
179264
|
-
return `${command2} ${serializedArgs}`;
|
|
179265
|
-
}
|
|
179266
179380
|
function truncateBuffer(buffer2, limit2) {
|
|
179267
179381
|
if (buffer2.length <= limit2) {
|
|
179268
179382
|
return buffer2;
|
|
@@ -179305,7 +179419,7 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
179305
179419
|
const deps = {
|
|
179306
179420
|
platform: process.platform,
|
|
179307
179421
|
setPriority: os__default$1.setPriority,
|
|
179308
|
-
writeFile: fs$
|
|
179422
|
+
writeFile: fs$2.writeFile,
|
|
179309
179423
|
...options.deps ?? {}
|
|
179310
179424
|
};
|
|
179311
179425
|
if (deps.platform !== "linux") {
|
|
@@ -179357,10 +179471,10 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
179357
179471
|
const defaultSandboxDeps = () => ({
|
|
179358
179472
|
platform: process.platform,
|
|
179359
179473
|
cgroupMount: DEFAULT_CGROUP_MOUNT,
|
|
179360
|
-
fs: fs$
|
|
179474
|
+
fs: fs$2,
|
|
179361
179475
|
spawnProcess: spawn,
|
|
179362
179476
|
readSelfCgroupPath: async () => {
|
|
179363
|
-
const content = await fs$
|
|
179477
|
+
const content = await fs$2.readFile("/proc/self/cgroup", "utf8");
|
|
179364
179478
|
const line3 = content.split("\n").map((item) => item.trim()).find((item) => item.startsWith("0::"));
|
|
179365
179479
|
if (!line3) {
|
|
179366
179480
|
throw new Error("Unable to determine current cgroup path from /proc/self/cgroup");
|
|
@@ -180458,6 +180572,7 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
180458
180572
|
cliType: callbacks.cliType,
|
|
180459
180573
|
agentType: callbacks.agentType
|
|
180460
180574
|
},
|
|
180575
|
+
configOptionValues: this.config.configOptionValues,
|
|
180461
180576
|
launcher,
|
|
180462
180577
|
workspaceId: this.config.workspaceId,
|
|
180463
180578
|
machineId: this.config.machineId,
|
|
@@ -181187,14 +181302,19 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
181187
181302
|
}
|
|
181188
181303
|
};
|
|
181189
181304
|
}
|
|
181190
|
-
function buildSessionPreparationCompatibility(launchSource, mcpServerIds) {
|
|
181305
|
+
function buildSessionPreparationCompatibility(launchSource, mcpServerIds, configOptionValues) {
|
|
181191
181306
|
return {
|
|
181192
181307
|
launch: buildSessionLaunchConfig({
|
|
181193
181308
|
customAcp: launchSource?.customAcp,
|
|
181194
181309
|
runtimeOverrides: launchSource?.runtimeOverrides,
|
|
181195
181310
|
env: launchSource?.env
|
|
181196
181311
|
}),
|
|
181197
|
-
|
|
181312
|
+
runConfig: normalizeSessionPreparationRunConfigForDedup({
|
|
181313
|
+
mcpServerIds: mcpServerIds ? [
|
|
181314
|
+
...mcpServerIds
|
|
181315
|
+
] : void 0,
|
|
181316
|
+
configOptionValues
|
|
181317
|
+
})
|
|
181198
181318
|
};
|
|
181199
181319
|
}
|
|
181200
181320
|
function agentConfigMatchesPreparation(agentConfig, spec, machineId) {
|
|
@@ -181309,7 +181429,7 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
181309
181429
|
return null;
|
|
181310
181430
|
}
|
|
181311
181431
|
const current2 = resource.readCurrentLaunchConfig(sessionMeta);
|
|
181312
|
-
if (!current2 || !isDeepStrictEqual(resource.compatibility, buildSessionPreparationCompatibility(current2.config, resource.config.mcpServerIds))) {
|
|
181432
|
+
if (!current2 || !isDeepStrictEqual(resource.compatibility, buildSessionPreparationCompatibility(current2.config, resource.config.mcpServerIds, resource.config.configOptionValues))) {
|
|
181313
181433
|
return null;
|
|
181314
181434
|
}
|
|
181315
181435
|
return {
|
|
@@ -181350,7 +181470,7 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
181350
181470
|
await this.preparationService.discard(sessionId);
|
|
181351
181471
|
return await this.createSessionInnerWithAgent(config2, agentStart);
|
|
181352
181472
|
}
|
|
181353
|
-
const compatibility = buildSessionPreparationCompatibility(config2, config2.mcpServerIds);
|
|
181473
|
+
const compatibility = buildSessionPreparationCompatibility(config2, config2.mcpServerIds, config2.configOptionValues);
|
|
181354
181474
|
const claim = this.preparationService.claim({
|
|
181355
181475
|
sessionId,
|
|
181356
181476
|
requesterUserId: config2.requesterUserId,
|
|
@@ -181369,7 +181489,7 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
181369
181489
|
cliType: config2.agentCliType,
|
|
181370
181490
|
agentType: config2.agentType
|
|
181371
181491
|
});
|
|
181372
|
-
return current2 !== null && isDeepStrictEqual(resource.compatibility, buildSessionPreparationCompatibility(current2.config, config2.mcpServerIds));
|
|
181492
|
+
return current2 !== null && isDeepStrictEqual(resource.compatibility, buildSessionPreparationCompatibility(current2.config, config2.mcpServerIds, config2.configOptionValues));
|
|
181373
181493
|
}
|
|
181374
181494
|
});
|
|
181375
181495
|
if (claim.status === "miss") {
|
|
@@ -181525,6 +181645,7 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
181525
181645
|
agentConfigId: spec.agentConfigId,
|
|
181526
181646
|
agentCliType: spec.cliType,
|
|
181527
181647
|
agentType: spec.agentType,
|
|
181648
|
+
configOptionValues: spec.runConfig?.configOptionValues,
|
|
181528
181649
|
mcpServerIds: spec.runConfig?.mcpServerIds ?? [],
|
|
181529
181650
|
customAcp: agentConfig.customAcp,
|
|
181530
181651
|
runtimeOverrides: agentConfig.runtimeOverrides,
|
|
@@ -181539,7 +181660,7 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
181539
181660
|
userName: user.name,
|
|
181540
181661
|
userEmail: user.email
|
|
181541
181662
|
};
|
|
181542
|
-
const compatibility = buildSessionPreparationCompatibility(config2, config2.mcpServerIds);
|
|
181663
|
+
const compatibility = buildSessionPreparationCompatibility(config2, config2.mcpServerIds, config2.configOptionValues);
|
|
181543
181664
|
const ghTokenInjected = await this.prepareGitHubRepoSessionConfig(config2);
|
|
181544
181665
|
signal.throwIfAborted();
|
|
181545
181666
|
const launch = await resolveACPProcessLaunchAsync({
|
|
@@ -184389,7 +184510,7 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
184389
184510
|
async function loadOrCreateLocalIdentity(logger2, options = {}) {
|
|
184390
184511
|
const identityPath = options.filePath ?? getLocalIdentityPath();
|
|
184391
184512
|
try {
|
|
184392
|
-
const raw2 = await fs__default$
|
|
184513
|
+
const raw2 = await fs__default$2.readFile(identityPath, "utf-8");
|
|
184393
184514
|
const parsed = JSON.parse(raw2);
|
|
184394
184515
|
if (typeof parsed.userId === "string" && parsed.userId.startsWith(LOCAL_USER_ID_PREFIX) && typeof parsed.createdAt === "string") {
|
|
184395
184516
|
return {
|
|
@@ -184404,11 +184525,11 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
|
|
|
184404
184525
|
userId: `${LOCAL_USER_ID_PREFIX}${crypto__default.randomUUID().replaceAll("-", "")}`,
|
|
184405
184526
|
createdAt: new Date(getServerNow()).toISOString()
|
|
184406
184527
|
};
|
|
184407
|
-
await fs__default$
|
|
184528
|
+
await fs__default$2.mkdir(path__default$1.dirname(identityPath), {
|
|
184408
184529
|
recursive: true,
|
|
184409
184530
|
mode: 448
|
|
184410
184531
|
});
|
|
184411
|
-
await fs__default$
|
|
184532
|
+
await fs__default$2.writeFile(identityPath, `${JSON.stringify(identity2, null, 2)}
|
|
184412
184533
|
`, {
|
|
184413
184534
|
mode: 384
|
|
184414
184535
|
});
|
|
@@ -190667,7 +190788,7 @@ Shutting down gracefully${reason}...`);
|
|
|
190667
190788
|
function getUserPipeSuffix() {
|
|
190668
190789
|
if (typeof process.getuid === "function") return String(process.getuid());
|
|
190669
190790
|
const userInfo2 = os__default.userInfo();
|
|
190670
|
-
return
|
|
190791
|
+
return crypto__default$1.createHash("sha256").update(`${userInfo2.uid}:${userInfo2.username}:${os__default.homedir()}`).digest("hex").slice(0, 16);
|
|
190671
190792
|
}
|
|
190672
190793
|
function getLocalCliHostEndpoint(platform2) {
|
|
190673
190794
|
const profile = getInstallationProfile(platform2);
|
|
@@ -190745,7 +190866,7 @@ Shutting down gracefully${reason}...`);
|
|
|
190745
190866
|
function tokensEqual(actual, expected) {
|
|
190746
190867
|
const actualBytes = Buffer.from(actual);
|
|
190747
190868
|
const expectedBytes = Buffer.from(expected);
|
|
190748
|
-
return actualBytes.length === expectedBytes.length &&
|
|
190869
|
+
return actualBytes.length === expectedBytes.length && crypto__default$1.timingSafeEqual(actualBytes, expectedBytes);
|
|
190749
190870
|
}
|
|
190750
190871
|
async function createListeningHost(endpoint, record2, shutdownControl) {
|
|
190751
190872
|
const sockets = /* @__PURE__ */ new Set();
|
|
@@ -191027,7 +191148,7 @@ Shutting down gracefully${reason}...`);
|
|
|
191027
191148
|
});
|
|
191028
191149
|
scrubLocalSupervisorCapabilityEnv();
|
|
191029
191150
|
await traceAsync(logger2, "startup.process_resource_profile", void 0, async () => normalizeCurrentProcessResourceProfile(logger2));
|
|
191030
|
-
for (const diagnostic of getRuntimeDiagnostics(version$
|
|
191151
|
+
for (const diagnostic of getRuntimeDiagnostics(version$9)) {
|
|
191031
191152
|
logger2.info(diagnostic);
|
|
191032
191153
|
}
|
|
191033
191154
|
if (options.heartbeatLog) {
|
|
@@ -192153,7 +192274,7 @@ Shutting down gracefully${reason}...`);
|
|
|
192153
192274
|
const defaultOpts = {
|
|
192154
192275
|
defaultWidth: 0,
|
|
192155
192276
|
output: process.stdout,
|
|
192156
|
-
tty: require$$1$
|
|
192277
|
+
tty: require$$1$2
|
|
192157
192278
|
};
|
|
192158
192279
|
if (!options) {
|
|
192159
192280
|
return defaultOpts;
|
|
@@ -194507,7 +194628,7 @@ Shutting down gracefully${reason}...`);
|
|
|
194507
194628
|
function requireLib$1() {
|
|
194508
194629
|
if (hasRequiredLib$1) return lib$1;
|
|
194509
194630
|
hasRequiredLib$1 = 1;
|
|
194510
|
-
const Stream =
|
|
194631
|
+
const Stream = Zr;
|
|
194511
194632
|
class MuteStream2 extends Stream {
|
|
194512
194633
|
#isTTY = null;
|
|
194513
194634
|
constructor(opts = {}) {
|
|
@@ -200709,7 +200830,7 @@ ${page}${helpTipBottom}${choiceDescription}${error2}${ansiEscapes.cursorHide}`;
|
|
|
200709
200830
|
}
|
|
200710
200831
|
InternalCodec.prototype.encoder = InternalEncoder;
|
|
200711
200832
|
InternalCodec.prototype.decoder = InternalDecoder;
|
|
200712
|
-
var StringDecoder2 = require$$1$
|
|
200833
|
+
var StringDecoder2 = require$$1$3.StringDecoder;
|
|
200713
200834
|
if (!StringDecoder2.prototype.end) StringDecoder2.prototype.end = function() {
|
|
200714
200835
|
};
|
|
200715
200836
|
function InternalDecoder(options, codec) {
|
|
@@ -203985,7 +204106,7 @@ ${page}${helpTipBottom}${choiceDescription}${error2}${ansiEscapes.cursorHide}`;
|
|
|
203985
204106
|
function requireStreams() {
|
|
203986
204107
|
if (hasRequiredStreams) return streams;
|
|
203987
204108
|
hasRequiredStreams = 1;
|
|
203988
|
-
var Buffer2 = require$$0$6.Buffer, Transform2 =
|
|
204109
|
+
var Buffer2 = require$$0$6.Buffer, Transform2 = Zr.Transform;
|
|
203989
204110
|
streams = function(iconv2) {
|
|
203990
204111
|
iconv2.encodeStream = function encodeStream(encoding2, options) {
|
|
203991
204112
|
return new IconvLiteEncoderStream(iconv2.getEncoder(encoding2, options), options);
|
|
@@ -204205,7 +204326,7 @@ ${page}${helpTipBottom}${choiceDescription}${error2}${ansiEscapes.cursorHide}`;
|
|
|
204205
204326
|
return length2;
|
|
204206
204327
|
};
|
|
204207
204328
|
if (iconv2.supportsStreams) {
|
|
204208
|
-
var Readable2 =
|
|
204329
|
+
var Readable2 = Zr.Readable;
|
|
204209
204330
|
original.ReadableSetEncoding = Readable2.prototype.setEncoding;
|
|
204210
204331
|
Readable2.prototype.setEncoding = function setEncoding(enc, options) {
|
|
204211
204332
|
this._readableState.decoder = iconv2.getDecoder(enc, options);
|
|
@@ -204226,7 +204347,7 @@ ${page}${helpTipBottom}${choiceDescription}${error2}${ansiEscapes.cursorHide}`;
|
|
|
204226
204347
|
Buffer2.prototype.toString = original.BufferToString;
|
|
204227
204348
|
Buffer2.prototype.write = original.BufferWrite;
|
|
204228
204349
|
if (iconv2.supportsStreams) {
|
|
204229
|
-
var Readable2 =
|
|
204350
|
+
var Readable2 = Zr.Readable;
|
|
204230
204351
|
Readable2.prototype.setEncoding = original.ReadableSetEncoding;
|
|
204231
204352
|
delete Readable2.prototype.collect;
|
|
204232
204353
|
}
|
|
@@ -204815,7 +204936,7 @@ ${page}${helpTipBottom}${choiceDescription}${error2}${ansiEscapes.cursorHide}`;
|
|
|
204815
204936
|
value: true
|
|
204816
204937
|
});
|
|
204817
204938
|
var chardet_1 = requireChardet();
|
|
204818
|
-
var child_process_1 = require$$1$
|
|
204939
|
+
var child_process_1 = require$$1$8;
|
|
204819
204940
|
var fs_1 = fs__default;
|
|
204820
204941
|
var iconv_lite_1 = requireLib();
|
|
204821
204942
|
var tmp_1 = requireTmp();
|
|
@@ -218628,8 +218749,8 @@ ${page}${helpTipBottom}${choiceDescription}${ansiEscapes.cursorHide}`;
|
|
|
218628
218749
|
const sessionDir = joinExportPath(args2.outputDir, "sessions", sessionDirName);
|
|
218629
218750
|
const summary2 = toExportSessionSummary(args2.session, args2.workspaceId);
|
|
218630
218751
|
const history = await args2.manager.getSessionHistorySnapshot(args2.session.id);
|
|
218631
|
-
const
|
|
218632
|
-
let attachments =
|
|
218752
|
+
const artifacts2 = buildSessionArtifacts(history);
|
|
218753
|
+
let attachments = artifacts2.attachments;
|
|
218633
218754
|
if (args2.downloadImages) {
|
|
218634
218755
|
attachments = await mapWithConcurrency$1(attachments, ATTACHMENT_EXPORT_CONCURRENCY, async (attachment) => {
|
|
218635
218756
|
const downloaded = await downloadSessionAttachment({
|
|
@@ -218652,11 +218773,11 @@ ${page}${helpTipBottom}${choiceDescription}${ansiEscapes.cursorHide}`;
|
|
|
218652
218773
|
}
|
|
218653
218774
|
await writeJson(path__default.join(sessionDir, "transcript.json"), {
|
|
218654
218775
|
session: summary2,
|
|
218655
|
-
turns:
|
|
218776
|
+
turns: artifacts2.transcript
|
|
218656
218777
|
});
|
|
218657
218778
|
await writeText(path__default.join(sessionDir, "transcript.md"), buildTranscriptMarkdown({
|
|
218658
218779
|
session: summary2,
|
|
218659
|
-
turns:
|
|
218780
|
+
turns: artifacts2.transcript,
|
|
218660
218781
|
attachments
|
|
218661
218782
|
}));
|
|
218662
218783
|
await writeJson(path__default.join(sessionDir, "artifacts", "attachments", "index.json"), attachments);
|
|
@@ -218904,7 +219025,7 @@ ${page}${helpTipBottom}${choiceDescription}${ansiEscapes.cursorHide}`;
|
|
|
218904
219025
|
data = createReviewBundleSnapshot(bundle);
|
|
218905
219026
|
}
|
|
218906
219027
|
const { injectReviewSnapshot } = await import("./chunks/index-VoI6Ds2-.js");
|
|
218907
|
-
const { resolveReviewViewerTemplate } = await import("./chunks/review-viewer-
|
|
219028
|
+
const { resolveReviewViewerTemplate } = await import("./chunks/review-viewer-oYzxdgq4.js").then(async (m) => {
|
|
218908
219029
|
await m.__tla;
|
|
218909
219030
|
return m;
|
|
218910
219031
|
});
|
|
@@ -220590,9 +220711,9 @@ ${result.stdout ?? ""}`;
|
|
|
220590
220711
|
const passthroughArgs = cmd.args;
|
|
220591
220712
|
captureDaemonEvent("daemon_restart_requested");
|
|
220592
220713
|
const runningProbeHealth = await fetchLocalProbeHealth();
|
|
220593
|
-
const versionMismatchHealth = runningProbeHealth && runningProbeHealth.cliVersion !== version$
|
|
220714
|
+
const versionMismatchHealth = runningProbeHealth && runningProbeHealth.cliVersion !== version$9 ? runningProbeHealth : null;
|
|
220594
220715
|
if (versionMismatchHealth) {
|
|
220595
|
-
console.log(`Running daemon uses lody v${versionMismatchHealth.cliVersion}; current CLI is v${version$
|
|
220716
|
+
console.log(`Running daemon uses lody v${versionMismatchHealth.cliVersion}; current CLI is v${version$9}. Restarting with current CLI.`);
|
|
220596
220717
|
}
|
|
220597
220718
|
const stopResult = await stopDaemonProcess();
|
|
220598
220719
|
captureDaemonEvent("daemon_stop_result", {
|
|
@@ -220799,7 +220920,7 @@ ${result.stdout ?? ""}`;
|
|
|
220799
220920
|
});
|
|
220800
220921
|
logger2.info(`Daemon watchdog started (PID ${process.pid})`);
|
|
220801
220922
|
await normalizeCurrentProcessResourceProfile(logger2);
|
|
220802
|
-
for (const diagnostic of getRuntimeDiagnostics(version$
|
|
220923
|
+
for (const diagnostic of getRuntimeDiagnostics(version$9)) {
|
|
220803
220924
|
logger2.info(diagnostic);
|
|
220804
220925
|
}
|
|
220805
220926
|
const passthroughArgs = cmd.args;
|
|
@@ -239432,7 +239553,7 @@ ${result.stdout ?? ""}`;
|
|
|
239432
239553
|
cliToken: auth.token,
|
|
239433
239554
|
source: "mcp",
|
|
239434
239555
|
feedback: args2.feedback,
|
|
239435
|
-
cliVersion: version$
|
|
239556
|
+
cliVersion: version$9
|
|
239436
239557
|
}));
|
|
239437
239558
|
} catch (error2) {
|
|
239438
239559
|
return mcpErrorResult(error2);
|
|
@@ -241823,7 +241944,7 @@ data:
|
|
|
241823
241944
|
cliToken: auth.token,
|
|
241824
241945
|
source: "cli",
|
|
241825
241946
|
feedback,
|
|
241826
|
-
cliVersion: version$
|
|
241947
|
+
cliVersion: version$9
|
|
241827
241948
|
});
|
|
241828
241949
|
if (options.json) {
|
|
241829
241950
|
printJson(result);
|
|
@@ -242153,7 +242274,7 @@ Other machines will not see it until this machine syncs.`);
|
|
|
242153
242274
|
logger2.warn(`[dns] invalid LODY_DNS_RESULT_ORDER value; expected ipv4first|ipv6first|verbatim|node \u2014 falling back to ipv4first`);
|
|
242154
242275
|
}
|
|
242155
242276
|
try {
|
|
242156
|
-
require$$1$
|
|
242277
|
+
require$$1$7.setDefaultResultOrder(resolution.order);
|
|
242157
242278
|
logger2.debug(`[dns] default DNS result order set to ${resolution.order} (${resolution.reason})`);
|
|
242158
242279
|
} catch (error2) {
|
|
242159
242280
|
logger2.debug(`[dns] failed to set DNS result order: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
@@ -242168,7 +242289,7 @@ Other machines will not see it until this machine syncs.`);
|
|
|
242168
242289
|
logger: getLogger("http-transport")
|
|
242169
242290
|
});
|
|
242170
242291
|
program = new Command();
|
|
242171
|
-
program.name("lody").description("Lody Agent CLI tool for managing remote command execution").version(version$
|
|
242292
|
+
program.name("lody").description("Lody Agent CLI tool for managing remote command execution").version(version$9, "-v, --version", "display version number").enablePositionalOptions();
|
|
242172
242293
|
program.addCommand(loginCommand);
|
|
242173
242294
|
program.addCommand(logoutCommand);
|
|
242174
242295
|
program.addCommand(startCommand);
|