negotium 0.4.5 → 0.4.8
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/agent-helpers.js +13 -15
- package/dist/agent-helpers.js.map +5 -5
- package/dist/background-bash.js +1 -2
- package/dist/background-bash.js.map +3 -3
- package/dist/browser-runtime.js +1 -2
- package/dist/browser-runtime.js.map +3 -3
- package/dist/{chunk-dttcv3n7.js → chunk-y35zxjtx.js} +11 -12
- package/dist/{chunk-dttcv3n7.js.map → chunk-y35zxjtx.js.map} +4 -4
- package/dist/hosted-agent.js +12 -13
- package/dist/hosted-agent.js.map +5 -5
- package/dist/main.js +79 -39
- package/dist/main.js.map +6 -6
- package/dist/mcp-factories.js +13 -15
- package/dist/mcp-factories.js.map +5 -5
- package/dist/prompts.js +1 -2
- package/dist/prompts.js.map +3 -3
- package/dist/query-runtime.js +1 -2
- package/dist/query-runtime.js.map +3 -3
- package/dist/registry.js +3 -3
- package/dist/registry.js.map +2 -2
- package/dist/rollout.js +1 -1
- package/dist/runtime/src/platform/config.ts +0 -4
- package/dist/runtime/src/platform/mcp-config.ts +22 -15
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-helpers.js +1 -2
- package/dist/runtime-helpers.js.map +3 -3
- package/dist/types/packages/core/src/platform/config.d.ts +0 -1
- package/dist/types/packages/core/src/platform/mcp-config.d.ts +1 -1
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/dist/vault.js +1 -2
- package/dist/vault.js.map +3 -3
- package/package.json +2 -2
- package/dist/runtime/src/mcp/browser-sse-proxy-server.ts +0 -48
package/dist/main.js
CHANGED
|
@@ -273,7 +273,7 @@ function resolveDefaultModel(agent, registryDefaultModel) {
|
|
|
273
273
|
function codexAuthFilePath() {
|
|
274
274
|
return process.env.NEGOTIUM_CODEX_AUTH_FILE || join(process.env.CODEX_HOME || join(homedir(), ".codex"), "auth.json");
|
|
275
275
|
}
|
|
276
|
-
var HOME, PROJECT_ROOT, STATE_DIR_ENV, STATE_DIR, WORKSPACE_DIR, TOPIC_WORKSPACE_DIR, SHARED_WIKI_DIR, CRON_WORKSPACE_DIR, BROWSER_DIR, BROWSER_PROFILES_DIR, BINARIES_DIR, SECRETS_DIR, DM_WORKSPACE_DIR, SESSION_WORKSPACE_DIR, CLAUDE_EXECUTABLE_ENV, CLAUDE_EXECUTABLE, DEFAULT_OUTPUT_LANGUAGE = "English", BROWSER_RS_VERSION = "v0.1.22", BROWSER_RS_MIN_SECURE_VERSION = "0.1.15", BROWSER_RS_VERSION_PROBE_TIMEOUT_MS = 15000, SNIPPETS_API_URL, BROWSER_RS_BIN, BASH_RS_VERSION = "v0.1.7", BASH_RS_BIN, PLAYWRIGHT_MCP_BIN, TSX_BIN, TSX_LOADER, TSCONFIG_PATH, SESSION_COMM_SERVER, TASK_SERVER, DECISION_SERVER,
|
|
276
|
+
var HOME, PROJECT_ROOT, STATE_DIR_ENV, STATE_DIR, WORKSPACE_DIR, TOPIC_WORKSPACE_DIR, SHARED_WIKI_DIR, CRON_WORKSPACE_DIR, BROWSER_DIR, BROWSER_PROFILES_DIR, BINARIES_DIR, SECRETS_DIR, DM_WORKSPACE_DIR, SESSION_WORKSPACE_DIR, CLAUDE_EXECUTABLE_ENV, CLAUDE_EXECUTABLE, DEFAULT_OUTPUT_LANGUAGE = "English", BROWSER_RS_VERSION = "v0.1.22", BROWSER_RS_MIN_SECURE_VERSION = "0.1.15", BROWSER_RS_VERSION_PROBE_TIMEOUT_MS = 15000, SNIPPETS_API_URL, BROWSER_RS_BIN, BASH_RS_VERSION = "v0.1.7", BASH_RS_BIN, PLAYWRIGHT_MCP_BIN, TSX_BIN, TSX_LOADER, TSCONFIG_PATH, SESSION_COMM_SERVER, TASK_SERVER, DECISION_SERVER, CANONICAL_MCP_PROXY_SERVER, WIKI_SERVER, TOKEN_STATS_SERVER, COMPACTION_LOG_SERVER, SYSTEM_HEALTH_SERVER, AGENT_HEALTH_SERVER, VAULT_SERVER, BG_BASH_BASE_PORT, BG_BASH_MAX_PORT, RUNTIME_MCP_SECRET, NODE_CONTROL_TOKEN, NODE_ID, VAULT_MASTER_KEY, NEGOTIUM_PORT, hostname, DATA_DIR, LOG_DIR, UPLOADS_DIR, VAULT_DIR, SESSIONS_DB, DEBUG_FILE, USERS_LOG_DIR, RUN_DIR, PROGRESS_DIR, DM_CMD_DIR, DM_RESP_DIR, SESSION_INBOX_DIR, SESSION_ASKS_DIR, BASHRS_SPILL_ROOT, PLAYWRIGHT_BASE_PORT, PLAYWRIGHT_MAX_PORT, PLAYWRIGHT_PORTS_DIR, ACTIVE_QUERY_STALE_MS, AGENTS_PROMPTS_DIR, RESOURCES_DIR, FILE_TAG_REGEX, MODEL_SONNET = "claude-sonnet-5", MODEL_OPUS = "claude-opus-5", MODEL_FABLE = "claude-fable-5", FALLBACK_AGENT, SESSION_AGENT, GATEWAY_AGENT, FALLBACK_MODEL, SESSION_MODEL, GATEWAY_MODEL, FFMPEG_BIN, FFPROBE_BIN, PYTHON_BIN, FASTER_WHISPER_WRAPPER, WHISPER_MODEL, TESSERACT_BIN, PDFTOTEXT_BIN, _envMaxTellDepth, MAX_TELL_DEPTH;
|
|
277
277
|
var init_config = __esm(() => {
|
|
278
278
|
init_config_helpers();
|
|
279
279
|
init_logger();
|
|
@@ -304,7 +304,6 @@ var init_config = __esm(() => {
|
|
|
304
304
|
SESSION_COMM_SERVER = resolve(PROJECT_ROOT, "src/mcp/session-comm/server.ts");
|
|
305
305
|
TASK_SERVER = resolve(PROJECT_ROOT, "src/mcp/task-server.ts");
|
|
306
306
|
DECISION_SERVER = resolve(PROJECT_ROOT, "src/mcp/decision-server.ts");
|
|
307
|
-
BROWSER_MCP_SSE_PROXY_SERVER = resolve(PROJECT_ROOT, "src/mcp/browser-sse-proxy-server.ts");
|
|
308
307
|
CANONICAL_MCP_PROXY_SERVER = resolve(PROJECT_ROOT, "src/mcp/canonical-proxy-server.ts");
|
|
309
308
|
WIKI_SERVER = resolve(PROJECT_ROOT, "src/mcp/wiki-server.ts");
|
|
310
309
|
TOKEN_STATS_SERVER = resolve(PROJECT_ROOT, "src/mcp/token-stats-server.ts");
|
|
@@ -1869,7 +1868,7 @@ var exports_version = {};
|
|
|
1869
1868
|
__export(exports_version, {
|
|
1870
1869
|
NEGOTIUM_VERSION: () => NEGOTIUM_VERSION
|
|
1871
1870
|
});
|
|
1872
|
-
var NEGOTIUM_VERSION = "0.4.
|
|
1871
|
+
var NEGOTIUM_VERSION = "0.4.8";
|
|
1873
1872
|
|
|
1874
1873
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
1875
1874
|
import { spawn } from "child_process";
|
|
@@ -2755,12 +2754,6 @@ function playwrightTransport(port, owner, capability, agent) {
|
|
|
2755
2754
|
};
|
|
2756
2755
|
}
|
|
2757
2756
|
const query = new URLSearchParams({ owner });
|
|
2758
|
-
if (agent === "maestro") {
|
|
2759
|
-
return buildStdioMcpServer("maestro", BROWSER_MCP_SSE_PROXY_SERVER, [], {
|
|
2760
|
-
NEGOTIUM_BROWSER_SSE_URL: `http://127.0.0.1:${port}/sse?${query}`,
|
|
2761
|
-
NEGOTIUM_BROWSER_OWNER_CAPABILITY: ownerCapability
|
|
2762
|
-
});
|
|
2763
|
-
}
|
|
2764
2757
|
return {
|
|
2765
2758
|
type: "sse",
|
|
2766
2759
|
url: `http://127.0.0.1:${port}/sse?${query}`,
|
|
@@ -2770,14 +2763,20 @@ function playwrightTransport(port, owner, capability, agent) {
|
|
|
2770
2763
|
function longLivedHttpMcp(agent, port) {
|
|
2771
2764
|
return agent === "codex" ? { url: `http://127.0.0.1:${port}/mcp` } : { type: "sse", url: `http://127.0.0.1:${port}/sse` };
|
|
2772
2765
|
}
|
|
2773
|
-
function setCuaRsMcpPort(port) {
|
|
2766
|
+
function setCuaRsMcpPort(port, token) {
|
|
2774
2767
|
if (port !== undefined && (!Number.isInteger(port) || port < 1 || port > 65535)) {
|
|
2775
2768
|
throw new Error(`invalid cua-rs MCP port: ${port}`);
|
|
2776
2769
|
}
|
|
2777
2770
|
cuaRsMcpPort = port;
|
|
2771
|
+
cuaRsMcpToken = port === undefined ? undefined : token;
|
|
2778
2772
|
}
|
|
2779
|
-
function cuaRsHttpMcp(port) {
|
|
2780
|
-
|
|
2773
|
+
function cuaRsHttpMcp(agent, port, token) {
|
|
2774
|
+
const url = `http://127.0.0.1:${port}/mcp`;
|
|
2775
|
+
const headers = token ? { Authorization: `Bearer ${token}` } : undefined;
|
|
2776
|
+
const base = { type: "http", url };
|
|
2777
|
+
if (!headers)
|
|
2778
|
+
return base;
|
|
2779
|
+
return agent === "codex" ? { ...base, http_headers: headers } : { ...base, headers };
|
|
2781
2780
|
}
|
|
2782
2781
|
function backgroundBashTransport(agent, port, userId, topic) {
|
|
2783
2782
|
const capability = bgBashContextCapability(userId, topic);
|
|
@@ -3054,7 +3053,7 @@ function getMcpServersForQuery(opts) {
|
|
|
3054
3053
|
peerBridge: opts.peerBridge
|
|
3055
3054
|
});
|
|
3056
3055
|
}
|
|
3057
|
-
var _playwrightUnavailableNotifier, _playwrightUnavailableLastNotifiedAt, _PLAYWRIGHT_UNAVAILABLE_COOLDOWN_MS, _playwrightUnavailableThisTurn, CODEX_BROWSER_CAPABILITY_ENV = "NEGOTIUM_BROWSER_CAPABILITY", cuaRsMcpPort, MCP_CATALOG, allForumMcpServerNames, requiredForumMcpServers, REQUIRED_FORUM_MCP_SERVERS, optionalForumMcpServers, OPTIONAL_FORUM_MCP_SERVERS, nodeMcpEntries;
|
|
3056
|
+
var _playwrightUnavailableNotifier, _playwrightUnavailableLastNotifiedAt, _PLAYWRIGHT_UNAVAILABLE_COOLDOWN_MS, _playwrightUnavailableThisTurn, CODEX_BROWSER_CAPABILITY_ENV = "NEGOTIUM_BROWSER_CAPABILITY", cuaRsMcpPort, cuaRsMcpToken, MCP_CATALOG, allForumMcpServerNames, requiredForumMcpServers, REQUIRED_FORUM_MCP_SERVERS, optionalForumMcpServers, OPTIONAL_FORUM_MCP_SERVERS, nodeMcpEntries;
|
|
3058
3057
|
var init_mcp_config = __esm(() => {
|
|
3059
3058
|
init_canonical_bridge_config();
|
|
3060
3059
|
init_runtime_spec();
|
|
@@ -3272,8 +3271,8 @@ var init_mcp_config = __esm(() => {
|
|
|
3272
3271
|
},
|
|
3273
3272
|
"cua-rs": {
|
|
3274
3273
|
...commonRuntimeMcpPolicy("cua-rs"),
|
|
3275
|
-
build() {
|
|
3276
|
-
return cuaRsMcpPort ? cuaRsHttpMcp(cuaRsMcpPort) : null;
|
|
3274
|
+
build({ agent }) {
|
|
3275
|
+
return cuaRsMcpPort ? cuaRsHttpMcp(agent, cuaRsMcpPort, cuaRsMcpToken) : null;
|
|
3277
3276
|
}
|
|
3278
3277
|
}
|
|
3279
3278
|
};
|
|
@@ -32618,7 +32617,8 @@ __export(exports_src3, {
|
|
|
32618
32617
|
NODE_CONTROL_PROTOCOL_VERSION: () => NODE_CONTROL_PROTOCOL_VERSION,
|
|
32619
32618
|
NODE_CONTROL_BASE_PATH: () => NODE_CONTROL_BASE_PATH
|
|
32620
32619
|
});
|
|
32621
|
-
import {
|
|
32620
|
+
import { randomBytes as randomBytes8 } from "crypto";
|
|
32621
|
+
import { readFileSync as readFileSync29, rmSync as rmSync10, writeFileSync as writeFileSync25 } from "fs";
|
|
32622
32622
|
import { createServer as createServer5 } from "net";
|
|
32623
32623
|
import { join as join43 } from "path";
|
|
32624
32624
|
async function availableLoopbackPort() {
|
|
@@ -32676,6 +32676,34 @@ async function wireNodeMcps(host2, manifest) {
|
|
|
32676
32676
|
logger.info({ keys: entries.map((e) => e.key) }, "node mcp: manifest servers installed");
|
|
32677
32677
|
}
|
|
32678
32678
|
}
|
|
32679
|
+
function cuaRsToken() {
|
|
32680
|
+
const file = join43(RUN_DIR, CUA_RS_MCP_TOKEN_FILE);
|
|
32681
|
+
try {
|
|
32682
|
+
const existing = readFileSync29(file, "utf8").trim();
|
|
32683
|
+
if (/^[0-9a-f]{64}$/.test(existing))
|
|
32684
|
+
return existing;
|
|
32685
|
+
} catch {}
|
|
32686
|
+
const token = randomBytes8(32).toString("hex");
|
|
32687
|
+
writeFileSync25(file, token, { mode: 384 });
|
|
32688
|
+
return token;
|
|
32689
|
+
}
|
|
32690
|
+
async function cuaRsAuthOk(port, token) {
|
|
32691
|
+
try {
|
|
32692
|
+
const res = await fetch(`http://127.0.0.1:${port}/mcp`, {
|
|
32693
|
+
method: "POST",
|
|
32694
|
+
headers: {
|
|
32695
|
+
Authorization: `Bearer ${token}`,
|
|
32696
|
+
"Content-Type": "application/json",
|
|
32697
|
+
Accept: "application/json, text/event-stream"
|
|
32698
|
+
},
|
|
32699
|
+
body: "{}",
|
|
32700
|
+
signal: AbortSignal.timeout(2000)
|
|
32701
|
+
});
|
|
32702
|
+
return res.status !== 401;
|
|
32703
|
+
} catch {
|
|
32704
|
+
return true;
|
|
32705
|
+
}
|
|
32706
|
+
}
|
|
32679
32707
|
async function wireCuaRsMcp() {
|
|
32680
32708
|
setCuaRsMcpPort(undefined);
|
|
32681
32709
|
const binary = resolveCuaRsBinary();
|
|
@@ -32684,11 +32712,13 @@ async function wireCuaRsMcp() {
|
|
|
32684
32712
|
const manifestFile = join43(RUN_DIR, CUA_RS_MCP_MANIFEST_FILE);
|
|
32685
32713
|
rmSync10(manifestFile, { force: true });
|
|
32686
32714
|
const manifest = new McpManifest({ file: manifestFile });
|
|
32715
|
+
const token = cuaRsToken();
|
|
32687
32716
|
const spec = {
|
|
32688
32717
|
key: CUA_RS_MCP_KEY,
|
|
32689
32718
|
transport: "http",
|
|
32690
32719
|
command: binary,
|
|
32691
32720
|
args: ["{port}"],
|
|
32721
|
+
env: { CUA_HTTP_TOKEN: token },
|
|
32692
32722
|
portRange: CUA_RS_MCP_PORT_RANGE,
|
|
32693
32723
|
scope: "node",
|
|
32694
32724
|
healthIntervalMs: 15000
|
|
@@ -32697,10 +32727,20 @@ async function wireCuaRsMcp() {
|
|
|
32697
32727
|
const host2 = new McpHost({ manifest });
|
|
32698
32728
|
const stopSweeper = host2.startSweeper();
|
|
32699
32729
|
try {
|
|
32700
|
-
|
|
32730
|
+
let instance = await host2.ensure(CUA_RS_MCP_KEY);
|
|
32701
32731
|
if (!instance.port)
|
|
32702
32732
|
throw new Error("cua-rs started without an HTTP port");
|
|
32703
|
-
|
|
32733
|
+
if (!await cuaRsAuthOk(instance.port, token)) {
|
|
32734
|
+
logger.warn({ port: instance.port }, "cua-rs rejected the node's token; restarting it");
|
|
32735
|
+
await host2.stop(CUA_RS_MCP_KEY);
|
|
32736
|
+
instance = await host2.ensure(CUA_RS_MCP_KEY);
|
|
32737
|
+
if (!instance.port)
|
|
32738
|
+
throw new Error("cua-rs restarted without an HTTP port");
|
|
32739
|
+
if (!await cuaRsAuthOk(instance.port, token)) {
|
|
32740
|
+
throw new Error("cua-rs will not accept the node's bearer token");
|
|
32741
|
+
}
|
|
32742
|
+
}
|
|
32743
|
+
setCuaRsMcpPort(instance.port, token);
|
|
32704
32744
|
logger.info({ pid: instance.pid, port: instance.port }, "cua-rs MCP server ready");
|
|
32705
32745
|
return { host: host2, stopSweeper };
|
|
32706
32746
|
} catch (error2) {
|
|
@@ -32909,7 +32949,7 @@ async function runNodeDaemon(opts = {}) {
|
|
|
32909
32949
|
await new Promise((resolve24) => setImmediate(resolve24));
|
|
32910
32950
|
process.exit(0);
|
|
32911
32951
|
}
|
|
32912
|
-
var CUA_RS_MCP_KEY = "cua-rs", CUA_RS_MCP_MANIFEST_FILE = "cua-rs-mcp-manifest.json", CUA_RS_MCP_PORT_RANGE;
|
|
32952
|
+
var CUA_RS_MCP_KEY = "cua-rs", CUA_RS_MCP_MANIFEST_FILE = "cua-rs-mcp-manifest.json", CUA_RS_MCP_TOKEN_FILE = "cua-rs-mcp.token", CUA_RS_MCP_PORT_RANGE;
|
|
32913
32953
|
var init_src5 = __esm(async () => {
|
|
32914
32954
|
await init_conversation_migration();
|
|
32915
32955
|
await init_node_host();
|
|
@@ -43108,12 +43148,12 @@ import {
|
|
|
43108
43148
|
lstatSync,
|
|
43109
43149
|
mkdirSync as mkdirSync33,
|
|
43110
43150
|
openSync as openSync5,
|
|
43111
|
-
readFileSync as
|
|
43151
|
+
readFileSync as readFileSync30,
|
|
43112
43152
|
renameSync as renameSync17,
|
|
43113
43153
|
rmSync as rmSync11,
|
|
43114
43154
|
statSync as statSync20,
|
|
43115
43155
|
unlinkSync as unlinkSync23,
|
|
43116
|
-
writeFileSync as
|
|
43156
|
+
writeFileSync as writeFileSync26
|
|
43117
43157
|
} from "fs";
|
|
43118
43158
|
import { dirname as dirname23, resolve as resolve25 } from "path";
|
|
43119
43159
|
function joinFilePath() {
|
|
@@ -43194,7 +43234,7 @@ function withJoinCredentialLock(operation) {
|
|
|
43194
43234
|
try {
|
|
43195
43235
|
mkdirSync33(lockPath, { mode: 448 });
|
|
43196
43236
|
created = true;
|
|
43197
|
-
|
|
43237
|
+
writeFileSync26(ownerPath, `${JSON.stringify(owner)}
|
|
43198
43238
|
`, { mode: 384 });
|
|
43199
43239
|
const ownerFd = openSync5(ownerPath, "r");
|
|
43200
43240
|
try {
|
|
@@ -43212,7 +43252,7 @@ function withJoinCredentialLock(operation) {
|
|
|
43212
43252
|
throw error2;
|
|
43213
43253
|
let current3 = null;
|
|
43214
43254
|
try {
|
|
43215
|
-
current3 = JSON.parse(
|
|
43255
|
+
current3 = JSON.parse(readFileSync30(ownerPath, "utf8"));
|
|
43216
43256
|
} catch {}
|
|
43217
43257
|
let ageMs;
|
|
43218
43258
|
try {
|
|
@@ -43242,7 +43282,7 @@ function withJoinCredentialLock(operation) {
|
|
|
43242
43282
|
return operation();
|
|
43243
43283
|
} finally {
|
|
43244
43284
|
try {
|
|
43245
|
-
const current3 = JSON.parse(
|
|
43285
|
+
const current3 = JSON.parse(readFileSync30(ownerPath, "utf8"));
|
|
43246
43286
|
if (current3.pid === owner.pid && current3.token === owner.token) {
|
|
43247
43287
|
rmSync11(lockPath, { recursive: true, force: true });
|
|
43248
43288
|
}
|
|
@@ -43267,7 +43307,7 @@ function joinCredentialDigest(join46) {
|
|
|
43267
43307
|
function readPersistedJoins(path = joinFilePath()) {
|
|
43268
43308
|
if (!existsSync39(path))
|
|
43269
43309
|
return [];
|
|
43270
|
-
const parsed = JSON.parse(
|
|
43310
|
+
const parsed = JSON.parse(readFileSync30(path, "utf-8"));
|
|
43271
43311
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
43272
43312
|
throw new Error("persisted join credentials are not a JSON object");
|
|
43273
43313
|
}
|
|
@@ -43305,7 +43345,7 @@ function writeJoins(joins, allowOverwrite) {
|
|
|
43305
43345
|
let fd;
|
|
43306
43346
|
try {
|
|
43307
43347
|
fd = openSync5(temporaryPath, "wx", 384);
|
|
43308
|
-
|
|
43348
|
+
writeFileSync26(fd, `${JSON.stringify(payload, null, 2)}
|
|
43309
43349
|
`, "utf8");
|
|
43310
43350
|
fsyncSync2(fd);
|
|
43311
43351
|
closeSync5(fd);
|
|
@@ -43931,7 +43971,7 @@ var init_store2 = __esm(async () => {
|
|
|
43931
43971
|
|
|
43932
43972
|
// ../../adapters/otium/src/workspace-scope.ts
|
|
43933
43973
|
import { createHash as createHash13 } from "crypto";
|
|
43934
|
-
import { mkdirSync as mkdirSync35, readFileSync as
|
|
43974
|
+
import { mkdirSync as mkdirSync35, readFileSync as readFileSync31, writeFileSync as writeFileSync27 } from "fs";
|
|
43935
43975
|
import { dirname as dirname24, resolve as resolve26 } from "path";
|
|
43936
43976
|
function surfaceScopeFor(central, workspaceId) {
|
|
43937
43977
|
const digest = createHash13("sha256").update(`${central.trim().replace(/\/+$/, "")}
|
|
@@ -43943,7 +43983,7 @@ function scopeCachePath() {
|
|
|
43943
43983
|
}
|
|
43944
43984
|
function readCache() {
|
|
43945
43985
|
try {
|
|
43946
|
-
const parsed = JSON.parse(
|
|
43986
|
+
const parsed = JSON.parse(readFileSync31(scopeCachePath(), "utf-8"));
|
|
43947
43987
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
43948
43988
|
return {};
|
|
43949
43989
|
return parsed;
|
|
@@ -43964,7 +44004,7 @@ function cacheSurfaceScope(join47, workspaceId) {
|
|
|
43964
44004
|
mkdirSync35(dirname24(path), { recursive: true });
|
|
43965
44005
|
const cache = readCache();
|
|
43966
44006
|
cache[join47.cellId] = { central: join47.central, workspaceId, scope };
|
|
43967
|
-
|
|
44007
|
+
writeFileSync27(path, `${JSON.stringify(cache, null, 2)}
|
|
43968
44008
|
`, { mode: 384 });
|
|
43969
44009
|
} catch (err2) {
|
|
43970
44010
|
logger.warn({ err: err2, path }, "otium: could not cache the workspace scope");
|
|
@@ -45005,10 +45045,10 @@ import {
|
|
|
45005
45045
|
linkSync as linkSync2,
|
|
45006
45046
|
mkdirSync as mkdirSync36,
|
|
45007
45047
|
openSync as openSync6,
|
|
45008
|
-
readFileSync as
|
|
45048
|
+
readFileSync as readFileSync32,
|
|
45009
45049
|
renameSync as renameSync18,
|
|
45010
45050
|
unlinkSync as unlinkSync24,
|
|
45011
|
-
writeFileSync as
|
|
45051
|
+
writeFileSync as writeFileSync28
|
|
45012
45052
|
} from "fs";
|
|
45013
45053
|
import { dirname as dirname25, resolve as resolve27 } from "path";
|
|
45014
45054
|
function parseEnrollmentInvite(code) {
|
|
@@ -45038,7 +45078,7 @@ function isEnrollmentPending(invite) {
|
|
|
45038
45078
|
if (!existsSync40(path))
|
|
45039
45079
|
return false;
|
|
45040
45080
|
try {
|
|
45041
|
-
const saved = JSON.parse(
|
|
45081
|
+
const saved = JSON.parse(readFileSync32(path, "utf8"));
|
|
45042
45082
|
return saved.central === invite.central && saved.token === invite.token;
|
|
45043
45083
|
} catch {
|
|
45044
45084
|
return false;
|
|
@@ -45047,7 +45087,7 @@ function isEnrollmentPending(invite) {
|
|
|
45047
45087
|
function loadOrCreatePending(invite, nodeName) {
|
|
45048
45088
|
const path = pendingEnrollmentPath();
|
|
45049
45089
|
if (existsSync40(path)) {
|
|
45050
|
-
const saved = JSON.parse(
|
|
45090
|
+
const saved = JSON.parse(readFileSync32(path, "utf8"));
|
|
45051
45091
|
if (saved.central === invite.central && saved.token === invite.token)
|
|
45052
45092
|
return saved;
|
|
45053
45093
|
throw new Error(`another Otium enrollment is pending at ${path}`);
|
|
@@ -45065,7 +45105,7 @@ function loadOrCreatePending(invite, nodeName) {
|
|
|
45065
45105
|
let fd;
|
|
45066
45106
|
try {
|
|
45067
45107
|
fd = openSync6(temporaryPath, "wx", 384);
|
|
45068
|
-
|
|
45108
|
+
writeFileSync28(fd, `${JSON.stringify(pending2, null, 2)}
|
|
45069
45109
|
`, "utf8");
|
|
45070
45110
|
fsyncSync3(fd);
|
|
45071
45111
|
closeSync6(fd);
|
|
@@ -45085,7 +45125,7 @@ function loadOrCreatePending(invite, nodeName) {
|
|
|
45085
45125
|
if (existsSync40(temporaryPath))
|
|
45086
45126
|
unlinkSync24(temporaryPath);
|
|
45087
45127
|
if (error2.code === "EEXIST" && existsSync40(path)) {
|
|
45088
|
-
const saved = JSON.parse(
|
|
45128
|
+
const saved = JSON.parse(readFileSync32(path, "utf8"));
|
|
45089
45129
|
if (saved.central === invite.central && saved.token === invite.token)
|
|
45090
45130
|
return saved;
|
|
45091
45131
|
}
|
|
@@ -45100,7 +45140,7 @@ function replacePendingEnrollment(pending2) {
|
|
|
45100
45140
|
let fd;
|
|
45101
45141
|
try {
|
|
45102
45142
|
fd = openSync6(temporaryPath, "wx", 384);
|
|
45103
|
-
|
|
45143
|
+
writeFileSync28(fd, `${JSON.stringify(pending2, null, 2)}
|
|
45104
45144
|
`, "utf8");
|
|
45105
45145
|
fsyncSync3(fd);
|
|
45106
45146
|
closeSync6(fd);
|
|
@@ -45122,7 +45162,7 @@ function replacePendingEnrollment(pending2) {
|
|
|
45122
45162
|
}
|
|
45123
45163
|
function recordClaimedCredential(pending2, join47) {
|
|
45124
45164
|
withJoinCredentialLock(() => {
|
|
45125
|
-
const current3 = JSON.parse(
|
|
45165
|
+
const current3 = JSON.parse(readFileSync32(pendingEnrollmentPath(), "utf8"));
|
|
45126
45166
|
if (current3.central !== pending2.central || current3.token !== pending2.token || current3.idempotencyKey !== pending2.idempotencyKey || current3.publicKey !== pending2.publicKey) {
|
|
45127
45167
|
throw new Error("pending Otium enrollment changed while its claim was in flight");
|
|
45128
45168
|
}
|
|
@@ -45201,7 +45241,7 @@ async function claimEnrollment(invite, nodeName) {
|
|
|
45201
45241
|
function commitEnrollment(join47, options = {}) {
|
|
45202
45242
|
return withJoinCredentialLock(() => {
|
|
45203
45243
|
const pendingPath = pendingEnrollmentPath();
|
|
45204
|
-
const pending2 = existsSync40(pendingPath) ? JSON.parse(
|
|
45244
|
+
const pending2 = existsSync40(pendingPath) ? JSON.parse(readFileSync32(pendingPath, "utf8")) : null;
|
|
45205
45245
|
const digest = joinCredentialDigest(join47);
|
|
45206
45246
|
if (pending2 && (!pending2.claimed || pending2.claimed.digest !== digest || pending2.claimed.cellId !== join47.cellId)) {
|
|
45207
45247
|
throw new Error(`pending Otium enrollment at ${pendingPath} does not match these credentials`);
|
|
@@ -47292,4 +47332,4 @@ switch (command) {
|
|
|
47292
47332
|
}
|
|
47293
47333
|
}
|
|
47294
47334
|
|
|
47295
|
-
//# debugId=
|
|
47335
|
+
//# debugId=F3E282057E27AACC64756E2164756E21
|