orkestrator 2.36.5-beta → 2.36.6-beta
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/client.js +72 -20
- package/dist/main.js +64254 -62158
- package/package.json +3 -3
- package/resources/acp-bridge/dist/index.js +365 -78
- package/resources/claude-bridge/dist/index.js +411 -96
- package/resources/codex-bridge/dist/index.js +541 -148
- package/resources/cursor-bridge/dist/index.js +344 -61
- package/resources/cursor-bridge/runtime/install.json +1 -1
- package/resources/pi-bridge/dist/index.js +885 -350
- package/resources/pi-bridge/runtime/install.json +1 -1
|
@@ -1,8 +1,80 @@
|
|
|
1
|
+
// ../protocol/src/node/bridge-launch-environment.ts
|
|
2
|
+
import { closeSync, fstatSync, openSync, readSync, rmSync, constants } from "node:fs";
|
|
3
|
+
var BRIDGE_LAUNCH_ENVIRONMENT_ENV = "ORKESTRATOR_BRIDGE_LAUNCH_ENVIRONMENT";
|
|
4
|
+
var BRIDGE_LAUNCH_KEYS_ENV = "ORKESTRATOR_BRIDGE_LAUNCH_KEYS";
|
|
5
|
+
var BRIDGE_LAUNCH_WORKDIR_ENV = "ORKESTRATOR_BRIDGE_LAUNCH_WORKDIR";
|
|
6
|
+
var MAX_SNAPSHOT_BYTES = 1024 * 1024;
|
|
7
|
+
var MAX_SNAPSHOT_ENTRIES = 4096;
|
|
8
|
+
var NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_%.-]*$/;
|
|
9
|
+
var LAUNCH_ONLY = /(?:_BRIDGE_TOKEN|_TOKEN_SHA256|_AUTHORITY_KEY)$|^ORKESTRATOR_BRIDGE_(?:LAUNCH_|EXECUTION_POLICY$)|^ORKESTRATOR_COORDINATOR_/;
|
|
10
|
+
var NOT_APPLIED = new Set(["PWD", "OLDPWD", "SHLVL", "_", "NODE_PATH"]);
|
|
11
|
+
function readSnapshot(file) {
|
|
12
|
+
let fd;
|
|
13
|
+
try {
|
|
14
|
+
fd = openSync(file, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
15
|
+
} catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const stat = fstatSync(fd);
|
|
20
|
+
if (!stat.isFile() || stat.size > MAX_SNAPSHOT_BYTES)
|
|
21
|
+
return null;
|
|
22
|
+
const buffer = Buffer.alloc(stat.size);
|
|
23
|
+
let offset = 0;
|
|
24
|
+
while (offset < buffer.length) {
|
|
25
|
+
const read = readSync(fd, buffer, offset, buffer.length - offset, offset);
|
|
26
|
+
if (read === 0)
|
|
27
|
+
break;
|
|
28
|
+
offset += read;
|
|
29
|
+
}
|
|
30
|
+
return buffer.subarray(0, offset);
|
|
31
|
+
} finally {
|
|
32
|
+
closeSync(fd);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function applyBridgeLaunchEnvironment(env = process.env, chdir = (directory) => process.chdir(directory)) {
|
|
36
|
+
const file = env[BRIDGE_LAUNCH_ENVIRONMENT_ENV];
|
|
37
|
+
if (!file)
|
|
38
|
+
return null;
|
|
39
|
+
const trusted = new Set((env[BRIDGE_LAUNCH_KEYS_ENV] ?? "").split(",").map((name) => name.trim()).filter(Boolean));
|
|
40
|
+
const workdir = env[BRIDGE_LAUNCH_WORKDIR_ENV];
|
|
41
|
+
delete env[BRIDGE_LAUNCH_ENVIRONMENT_ENV];
|
|
42
|
+
delete env[BRIDGE_LAUNCH_KEYS_ENV];
|
|
43
|
+
delete env[BRIDGE_LAUNCH_WORKDIR_ENV];
|
|
44
|
+
const result = { applied: 0, refused: 0 };
|
|
45
|
+
const snapshot = readSnapshot(file);
|
|
46
|
+
rmSync(file, { force: true });
|
|
47
|
+
if (snapshot) {
|
|
48
|
+
const entries = snapshot.toString("utf8").split("\x00").slice(0, MAX_SNAPSHOT_ENTRIES);
|
|
49
|
+
for (const entry of entries) {
|
|
50
|
+
const separator = entry.indexOf("=");
|
|
51
|
+
if (separator <= 0)
|
|
52
|
+
continue;
|
|
53
|
+
const name = entry.slice(0, separator);
|
|
54
|
+
if (!NAME_PATTERN.test(name) || NOT_APPLIED.has(name))
|
|
55
|
+
continue;
|
|
56
|
+
if (trusted.has(name) || LAUNCH_ONLY.test(name)) {
|
|
57
|
+
result.refused += 1;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
env[name] = entry.slice(separator + 1);
|
|
61
|
+
result.applied += 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (workdir) {
|
|
65
|
+
try {
|
|
66
|
+
chdir(workdir);
|
|
67
|
+
} catch {}
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
applyBridgeLaunchEnvironment();
|
|
72
|
+
|
|
1
73
|
// ../../bridges/cursor-bridge/src/config.ts
|
|
2
74
|
import { resolve } from "node:path";
|
|
3
75
|
|
|
4
76
|
// ../protocol/src/node/bridge-credential.ts
|
|
5
|
-
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
77
|
+
import { createHash as createHash2, randomBytes as randomBytes2, timingSafeEqual } from "node:crypto";
|
|
6
78
|
import { createRequire } from "node:module";
|
|
7
79
|
|
|
8
80
|
// ../protocol/src/secret-redaction.ts
|
|
@@ -48,7 +120,7 @@ var MAX_FRAME_CHARS = 240;
|
|
|
48
120
|
var MAX_RAW_FRAME_CHARS = 1024;
|
|
49
121
|
var MAX_CAUSE_DEPTH = 2;
|
|
50
122
|
var TRUNCATED_MARKER = "...[truncated]";
|
|
51
|
-
var
|
|
123
|
+
var NAME_PATTERN2 = /^[A-Za-z_$][\w$.-]{0,63}$/;
|
|
52
124
|
var CODE_PATTERN = /^[\w.:-]{1,64}$/;
|
|
53
125
|
var SYSCALL_PATTERN = /^[\w./ -]{1,128}$/;
|
|
54
126
|
var COMMAND_OUTPUT_FIELDS = ["stdout", "stderr", "cmd", "spawnargs"];
|
|
@@ -126,7 +198,7 @@ function describe(error, includeStack, includeMessage, depth) {
|
|
|
126
198
|
if (!(error instanceof Error) && typeof rawMessage !== "string") {
|
|
127
199
|
return { name: "NonError", message: "[object]" };
|
|
128
200
|
}
|
|
129
|
-
const name = matching(read(error, "name"),
|
|
201
|
+
const name = matching(read(error, "name"), NAME_PATTERN2) ?? "Error";
|
|
130
202
|
const message = typeof rawMessage === "string" ? rawMessage : undefined;
|
|
131
203
|
const commandFailure = isCommandFailure(error, name, message);
|
|
132
204
|
const stackHoldsMessage = message !== undefined && String(read(error, "stack") ?? "").includes(message);
|
|
@@ -181,7 +253,7 @@ function logErrorKind(error) {
|
|
|
181
253
|
const safeCode = finite(code) ?? matching(code, CODE_PATTERN);
|
|
182
254
|
if (safeCode !== undefined)
|
|
183
255
|
return String(safeCode);
|
|
184
|
-
return matching(read(error, "name"),
|
|
256
|
+
return matching(read(error, "name"), NAME_PATTERN2) ?? "Error";
|
|
185
257
|
}
|
|
186
258
|
|
|
187
259
|
// ../protocol/src/log-vocabulary/define.ts
|
|
@@ -602,6 +674,7 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
|
|
|
602
674
|
events: {
|
|
603
675
|
"attention-failed": "A dialog could not ask for the user's attention.",
|
|
604
676
|
closed: "A native dialog closed.",
|
|
677
|
+
"hidden-cancelled": "A hidden profile cancelled a dialog without opening native UI.",
|
|
605
678
|
"open-failed": "A dialog could not open; it was answered as cancelled.",
|
|
606
679
|
opening: "A native dialog is opening.",
|
|
607
680
|
"preview-beforeunload-ignored": "A browser preview's beforeunload handler was ignored.",
|
|
@@ -687,6 +760,7 @@ var ENVIRONMENT_LOG_AREAS = defineLogAreas({
|
|
|
687
760
|
"orphan-session.reaped": "A native session no tab references was torn down.",
|
|
688
761
|
"handoff-sweep.failed": "Sweeping transferred transcripts no tab references failed.",
|
|
689
762
|
"delete.terminals-survived": "Terminal process trees outlived termination, so the deletion stops.",
|
|
763
|
+
"delete.step-deadline": "A deletion step that runs child processes passed its deadline; they are stopped and the deletion fails once they have.",
|
|
690
764
|
"delete.artifacts-left": "Graph run artifact directories were not removed.",
|
|
691
765
|
"delete.worktrees-kept": "Graph runs kept branch worktrees.",
|
|
692
766
|
"delete.step-failed": "One best-effort part of deleting an environment failed; `step` says which, and the rest goes on.",
|
|
@@ -721,6 +795,7 @@ var GATEWAY_LOG_AREAS = defineLogAreas({
|
|
|
721
795
|
"host.refused": "A request named a host this gateway does not answer to. Logged once per name, up to a limit.",
|
|
722
796
|
"port.fallback": "The preferred port was taken, so a nearby one is used.",
|
|
723
797
|
"port.fallback-distant": "The preferred port and those nearby were taken, so another is used.",
|
|
798
|
+
"request-auth.fallback": "A desktop request-auth hook failed closed. Phase only; no request or error content.",
|
|
724
799
|
"request.failed": "A gateway request failed. Throttled: repeats are counted, not written.",
|
|
725
800
|
"websocket.upgrade-failed": "A WebSocket upgrade failed.",
|
|
726
801
|
"events.client-dropped": "An event-stream client buffered too much and was dropped; it reconnects and refetches.",
|
|
@@ -779,6 +854,11 @@ var LOCAL_SERVER_LOG_AREAS = defineLogAreas({
|
|
|
779
854
|
requested: "boolean"
|
|
780
855
|
}
|
|
781
856
|
},
|
|
857
|
+
"bridge.orphans-reaped": {
|
|
858
|
+
description: "Processes a bridge left in its process group after exiting on its own (its agent CLI, mid-turn) were stopped. `warn` when they left; `error` when one survived SIGKILL.",
|
|
859
|
+
essential: true,
|
|
860
|
+
fields: { key: "label", pid: "number", result: "label" }
|
|
861
|
+
},
|
|
782
862
|
"reaper.tmux-list-failed": "Orphaned claude-tmux sessions could not be listed.",
|
|
783
863
|
"reaper.tmux-kill-failed": "An orphaned tmux session could not be killed.",
|
|
784
864
|
"reaper.tmux-reaped": "Orphaned claude-tmux sessions of a deleted environment were killed.",
|
|
@@ -1612,7 +1692,11 @@ var DOCKER_LOG_AREAS = defineLogAreas({
|
|
|
1612
1692
|
"network.list-failed": "Docker networks could not be listed.",
|
|
1613
1693
|
"network.inspect-failed": "A Docker network could not be inspected.",
|
|
1614
1694
|
"stale-containers.removing": "Stale probe containers are being removed.",
|
|
1615
|
-
"stale-networks.removing": "Stale probe networks are being removed."
|
|
1695
|
+
"stale-networks.removing": "Stale probe networks are being removed.",
|
|
1696
|
+
"peers.refused": "The agent tools server closed connections from addresses outside loopback and this backend's Docker networks (at most one entry a minute, with a count).",
|
|
1697
|
+
"peers.subnets-loaded": "The Docker subnets the agent tools server admits were reloaded.",
|
|
1698
|
+
"port.loopback-taken": "The agent tools server gave up a port because another process holds it on 127.0.0.1, where host agents call; it moves to a free port.",
|
|
1699
|
+
"peers.subnets-load-failed": "The Docker subnets the agent tools server admits could not be read; cached permissions are cleared and only loopback is admitted until a successful retry."
|
|
1616
1700
|
}
|
|
1617
1701
|
}
|
|
1618
1702
|
});
|
|
@@ -2856,33 +2940,198 @@ function createLogger(area) {
|
|
|
2856
2940
|
};
|
|
2857
2941
|
}
|
|
2858
2942
|
|
|
2943
|
+
// ../protocol/src/node/bridge-authority.ts
|
|
2944
|
+
import {
|
|
2945
|
+
createHash,
|
|
2946
|
+
createPrivateKey,
|
|
2947
|
+
createPublicKey,
|
|
2948
|
+
generateKeyPairSync,
|
|
2949
|
+
randomBytes,
|
|
2950
|
+
sign,
|
|
2951
|
+
verify
|
|
2952
|
+
} from "node:crypto";
|
|
2953
|
+
var BRIDGE_AUTHORITY_HEADER = "x-orkestrator-authority";
|
|
2954
|
+
var BRIDGE_AUTHORITY_REFUSED_CODE = "authority-signature-required";
|
|
2955
|
+
var BRIDGE_AUTHORITY_WINDOW_MS = 5 * 60000;
|
|
2956
|
+
var BRIDGE_AUTHORITY_MAX_NONCES = 8192;
|
|
2957
|
+
var BRIDGE_AUTHORITY_MAX_BODY_BYTES = 64 * 1024 * 1024;
|
|
2958
|
+
var SCHEME = "orkestrator-bridge-authority-v1";
|
|
2959
|
+
var KEY_PATTERN = /^[A-Za-z0-9_-]{40,200}$/;
|
|
2960
|
+
var HEADER_PATTERN = /^v1 t=(\d{1,16}) n=([A-Za-z0-9_-]{22}) s=([A-Za-z0-9_-]{86})$/;
|
|
2961
|
+
var READ_METHODS = new Set(["GET", "HEAD", "OPTIONS"]);
|
|
2962
|
+
var UNSIGNED_ROUTES = [
|
|
2963
|
+
/^\/session\/[^/]+\/close$/,
|
|
2964
|
+
/^\/sessions\/activity$/,
|
|
2965
|
+
/^\/debug\/log-policy$/
|
|
2966
|
+
];
|
|
2967
|
+
function bridgeAuthorityKeyEnv(tokenEnv) {
|
|
2968
|
+
return `${tokenEnv}_AUTHORITY_KEY`;
|
|
2969
|
+
}
|
|
2970
|
+
function isBridgeAuthorityKey(value) {
|
|
2971
|
+
return typeof value === "string" && KEY_PATTERN.test(value);
|
|
2972
|
+
}
|
|
2973
|
+
function publicKeyFrom(encoded) {
|
|
2974
|
+
if (!isBridgeAuthorityKey(encoded))
|
|
2975
|
+
return null;
|
|
2976
|
+
try {
|
|
2977
|
+
const key = createPublicKey({
|
|
2978
|
+
key: Buffer.from(encoded, "base64url"),
|
|
2979
|
+
format: "der",
|
|
2980
|
+
type: "spki"
|
|
2981
|
+
});
|
|
2982
|
+
return key.asymmetricKeyType === "ed25519" ? key : null;
|
|
2983
|
+
} catch {
|
|
2984
|
+
return null;
|
|
2985
|
+
}
|
|
2986
|
+
}
|
|
2987
|
+
function bridgeAuthorityTarget(url) {
|
|
2988
|
+
const parsed = new URL(url, "http://bridge.invalid");
|
|
2989
|
+
return `${parsed.pathname}${parsed.search}`;
|
|
2990
|
+
}
|
|
2991
|
+
function bridgeRequestNeedsAuthority(method, target) {
|
|
2992
|
+
if (READ_METHODS.has(method.toUpperCase()))
|
|
2993
|
+
return false;
|
|
2994
|
+
const pathname = bridgeAuthorityTarget(target).split("?", 1)[0];
|
|
2995
|
+
return !UNSIGNED_ROUTES.some((pattern) => pattern.test(pathname));
|
|
2996
|
+
}
|
|
2997
|
+
function bodyDigest(body) {
|
|
2998
|
+
return createHash("sha256").update(body ?? "").digest("hex");
|
|
2999
|
+
}
|
|
3000
|
+
function signedMessage(method, target, issuedAt, nonce, digest) {
|
|
3001
|
+
return Buffer.from([SCHEME, method.toUpperCase(), target, String(issuedAt), nonce, digest].join(`
|
|
3002
|
+
`));
|
|
3003
|
+
}
|
|
3004
|
+
var UNENFORCED = {
|
|
3005
|
+
enforced: false,
|
|
3006
|
+
requires: () => false,
|
|
3007
|
+
check: () => ({ ok: true })
|
|
3008
|
+
};
|
|
3009
|
+
function bridgeAuthorityFromPublicKey(publicKey, options = {}) {
|
|
3010
|
+
if (publicKey === undefined)
|
|
3011
|
+
return UNENFORCED;
|
|
3012
|
+
const key = publicKeyFrom(publicKey);
|
|
3013
|
+
const now = options.now ?? Date.now;
|
|
3014
|
+
const maxNonces = options.maxNonces ?? BRIDGE_AUTHORITY_MAX_NONCES;
|
|
3015
|
+
const seen = new Map;
|
|
3016
|
+
let floor = -Infinity;
|
|
3017
|
+
const remember = (nonce, issuedAt, current) => {
|
|
3018
|
+
for (const [oldNonce, oldIssuedAt] of seen) {
|
|
3019
|
+
if (seen.size < maxNonces && oldIssuedAt >= current - BRIDGE_AUTHORITY_WINDOW_MS)
|
|
3020
|
+
break;
|
|
3021
|
+
seen.delete(oldNonce);
|
|
3022
|
+
floor = Math.max(floor, oldIssuedAt);
|
|
3023
|
+
}
|
|
3024
|
+
seen.set(nonce, issuedAt);
|
|
3025
|
+
};
|
|
3026
|
+
return {
|
|
3027
|
+
enforced: true,
|
|
3028
|
+
requires: bridgeRequestNeedsAuthority,
|
|
3029
|
+
check(request) {
|
|
3030
|
+
if (!request.header)
|
|
3031
|
+
return { ok: false, reason: "missing" };
|
|
3032
|
+
const match = HEADER_PATTERN.exec(request.header.trim());
|
|
3033
|
+
if (!match)
|
|
3034
|
+
return { ok: false, reason: "malformed" };
|
|
3035
|
+
const issuedAt = Number(match[1]);
|
|
3036
|
+
const nonce = match[2];
|
|
3037
|
+
const current = now();
|
|
3038
|
+
if (Math.abs(current - issuedAt) > BRIDGE_AUTHORITY_WINDOW_MS || issuedAt <= floor) {
|
|
3039
|
+
return { ok: false, reason: "stale" };
|
|
3040
|
+
}
|
|
3041
|
+
if (!key)
|
|
3042
|
+
return { ok: false, reason: "invalid" };
|
|
3043
|
+
const valid = verify(null, signedMessage(request.method, bridgeAuthorityTarget(request.url), issuedAt, nonce, bodyDigest(request.body)), key, Buffer.from(match[3], "base64url"));
|
|
3044
|
+
if (!valid)
|
|
3045
|
+
return { ok: false, reason: "invalid" };
|
|
3046
|
+
if (seen.has(nonce))
|
|
3047
|
+
return { ok: false, reason: "replayed" };
|
|
3048
|
+
remember(nonce, issuedAt, current);
|
|
3049
|
+
return { ok: true };
|
|
3050
|
+
}
|
|
3051
|
+
};
|
|
3052
|
+
}
|
|
3053
|
+
function loadBridgeAuthority(tokenEnv, options = {}) {
|
|
3054
|
+
const env = options.env ?? process.env;
|
|
3055
|
+
const name = bridgeAuthorityKeyEnv(tokenEnv);
|
|
3056
|
+
const value = env[name]?.trim();
|
|
3057
|
+
delete env[name];
|
|
3058
|
+
return bridgeAuthorityFromPublicKey(value || undefined, { now: options.now });
|
|
3059
|
+
}
|
|
3060
|
+
function refusal(reason) {
|
|
3061
|
+
return {
|
|
3062
|
+
status: 403,
|
|
3063
|
+
body: {
|
|
3064
|
+
error: "This request changes an agent's authority and needs the backend's signature",
|
|
3065
|
+
code: BRIDGE_AUTHORITY_REFUSED_CODE,
|
|
3066
|
+
reason
|
|
3067
|
+
}
|
|
3068
|
+
};
|
|
3069
|
+
}
|
|
3070
|
+
var TOO_LARGE = {
|
|
3071
|
+
status: 413,
|
|
3072
|
+
body: { error: "Request body is too large" }
|
|
3073
|
+
};
|
|
3074
|
+
var admittedBodies = new WeakMap;
|
|
3075
|
+
async function admitNodeBridgeRequest(authority, request, maxBodyBytes) {
|
|
3076
|
+
const method = request.method ?? "GET";
|
|
3077
|
+
const url = request.url ?? "/";
|
|
3078
|
+
if (!authority.requires(method, url))
|
|
3079
|
+
return null;
|
|
3080
|
+
const header = request.headers[BRIDGE_AUTHORITY_HEADER];
|
|
3081
|
+
const value = Array.isArray(header) ? header[0] : header;
|
|
3082
|
+
if (!value)
|
|
3083
|
+
return refusal("missing");
|
|
3084
|
+
const chunks = [];
|
|
3085
|
+
let total = 0;
|
|
3086
|
+
for await (const chunk of request) {
|
|
3087
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
3088
|
+
total += buffer.length;
|
|
3089
|
+
if (total > maxBodyBytes)
|
|
3090
|
+
return TOO_LARGE;
|
|
3091
|
+
chunks.push(buffer);
|
|
3092
|
+
}
|
|
3093
|
+
const body = Buffer.concat(chunks);
|
|
3094
|
+
const result = authority.check({ method, url, header: value, body });
|
|
3095
|
+
if (!result.ok)
|
|
3096
|
+
return refusal(result.reason);
|
|
3097
|
+
admittedBodies.set(request, body);
|
|
3098
|
+
return null;
|
|
3099
|
+
}
|
|
3100
|
+
function takeAdmittedBody(request) {
|
|
3101
|
+
const body = admittedBodies.get(request);
|
|
3102
|
+
admittedBodies.delete(request);
|
|
3103
|
+
return body;
|
|
3104
|
+
}
|
|
3105
|
+
|
|
2859
3106
|
// ../protocol/src/node/bridge-credential.ts
|
|
2860
3107
|
var BRIDGE_TOKEN_PREFIX = "okb_";
|
|
2861
3108
|
var PR_SET_DUMPABLE = 4;
|
|
2862
3109
|
var VERIFIER_PATTERN = /^[0-9a-f]{64}$/;
|
|
2863
3110
|
var log = createLogger("bridge.lifecycle");
|
|
2864
3111
|
function mintBridgeToken() {
|
|
2865
|
-
return `${BRIDGE_TOKEN_PREFIX}${
|
|
3112
|
+
return `${BRIDGE_TOKEN_PREFIX}${randomBytes2(32).toString("base64url")}`;
|
|
2866
3113
|
}
|
|
2867
3114
|
function bridgeTokenVerifier(token) {
|
|
2868
|
-
return
|
|
3115
|
+
return createHash2("sha256").update(token).digest("hex");
|
|
2869
3116
|
}
|
|
2870
3117
|
function bridgeTokenVerifierEnv(tokenEnv) {
|
|
2871
3118
|
return `${tokenEnv}_SHA256`;
|
|
2872
3119
|
}
|
|
2873
|
-
function credentialFromVerifier(verifier, plainToken) {
|
|
3120
|
+
function credentialFromVerifier(verifier, plainToken, authority = UNENFORCED_AUTHORITY) {
|
|
2874
3121
|
const expected = Buffer.from(verifier, "hex");
|
|
2875
3122
|
return {
|
|
2876
3123
|
plainToken,
|
|
3124
|
+
authority,
|
|
2877
3125
|
matches(candidate) {
|
|
2878
3126
|
if (!candidate)
|
|
2879
3127
|
return false;
|
|
2880
|
-
return timingSafeEqual(expected,
|
|
3128
|
+
return timingSafeEqual(expected, createHash2("sha256").update(candidate).digest());
|
|
2881
3129
|
}
|
|
2882
3130
|
};
|
|
2883
3131
|
}
|
|
2884
|
-
|
|
2885
|
-
|
|
3132
|
+
var UNENFORCED_AUTHORITY = loadBridgeAuthority("", { env: {} });
|
|
3133
|
+
function bridgeCredentialFromToken(token, authority = UNENFORCED_AUTHORITY) {
|
|
3134
|
+
return credentialFromVerifier(bridgeTokenVerifier(token), token, authority);
|
|
2886
3135
|
}
|
|
2887
3136
|
function markProcessNonDumpable(loadFfi = () => createRequire(import.meta.url)("bun:ffi")) {
|
|
2888
3137
|
if (process.platform !== "linux" || !process.versions.bun)
|
|
@@ -2914,11 +3163,12 @@ function loadBridgeCredential(tokenEnv, options = {}) {
|
|
|
2914
3163
|
const token = env[tokenEnv]?.trim();
|
|
2915
3164
|
delete env[verifierEnv];
|
|
2916
3165
|
delete env[tokenEnv];
|
|
3166
|
+
const authority = loadBridgeAuthority(tokenEnv, { env });
|
|
2917
3167
|
if (verifier) {
|
|
2918
3168
|
(options.harden ?? markProcessNonDumpable)();
|
|
2919
|
-
return VERIFIER_PATTERN.test(verifier) ? credentialFromVerifier(verifier, undefined) : bridgeCredentialFromToken(mintBridgeToken());
|
|
3169
|
+
return VERIFIER_PATTERN.test(verifier) ? credentialFromVerifier(verifier, undefined, authority) : bridgeCredentialFromToken(mintBridgeToken(), authority);
|
|
2920
3170
|
}
|
|
2921
|
-
return bridgeCredentialFromToken(token || mintBridgeToken());
|
|
3171
|
+
return bridgeCredentialFromToken(token || mintBridgeToken(), authority);
|
|
2922
3172
|
}
|
|
2923
3173
|
|
|
2924
3174
|
// ../../bridges/cursor-bridge/src/config.ts
|
|
@@ -2928,6 +3178,7 @@ var hostname = process.env.HOSTNAME?.trim() || "127.0.0.1";
|
|
|
2928
3178
|
var workingDirectory = resolve(process.env.CWD?.trim() || process.cwd());
|
|
2929
3179
|
var bridgeCredential = loadBridgeCredential("CURSOR_BRIDGE_TOKEN");
|
|
2930
3180
|
var authToken = bridgeCredential.plainToken ?? "";
|
|
3181
|
+
var bridgeAuthority = bridgeCredential.authority;
|
|
2931
3182
|
function applyWorkingDirectory(directory = workingDirectory) {
|
|
2932
3183
|
const target = resolve(directory);
|
|
2933
3184
|
if (process.cwd() === target)
|
|
@@ -27722,7 +27973,7 @@ ${read.text}` : read.text);
|
|
|
27722
27973
|
}
|
|
27723
27974
|
|
|
27724
27975
|
// ../protocol/src/node/revised-rows.ts
|
|
27725
|
-
import { createHash as
|
|
27976
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
27726
27977
|
var RECENTLY_REVISED_ROWS_MAX = 128;
|
|
27727
27978
|
|
|
27728
27979
|
class RecentlyRevisedRows {
|
|
@@ -27760,7 +28011,7 @@ class RecentlyRevisedRows {
|
|
|
27760
28011
|
function revisedRowsReconciliationToken(overflowVersion, omitted) {
|
|
27761
28012
|
if (overflowVersion === 0 && omitted.length === 0)
|
|
27762
28013
|
return;
|
|
27763
|
-
const digest =
|
|
28014
|
+
const digest = createHash3("sha256").update(String(overflowVersion));
|
|
27764
28015
|
for (const row of omitted)
|
|
27765
28016
|
digest.update(JSON.stringify(row) ?? "null");
|
|
27766
28017
|
return digest.digest("hex");
|
|
@@ -29821,7 +30072,7 @@ function stringify(value) {
|
|
|
29821
30072
|
}
|
|
29822
30073
|
}
|
|
29823
30074
|
// ../../bridges/cursor-bridge/src/translate.ts
|
|
29824
|
-
import { randomBytes as
|
|
30075
|
+
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
29825
30076
|
|
|
29826
30077
|
// ../protocol/src/transcript-part-ids.ts
|
|
29827
30078
|
var MAX_ORDINAL_DIGITS = 15;
|
|
@@ -30323,7 +30574,7 @@ function applyAppendedUserMessage(state, update) {
|
|
|
30323
30574
|
const text = update.userMessage.text;
|
|
30324
30575
|
if (!text)
|
|
30325
30576
|
return;
|
|
30326
|
-
const messageId = `appended-${
|
|
30577
|
+
const messageId = `appended-${randomBytes3(8).toString("hex")}`;
|
|
30327
30578
|
const part = {
|
|
30328
30579
|
type: "text",
|
|
30329
30580
|
content: boundText(text, MAX_MESSAGE_TEXT_BYTES),
|
|
@@ -30434,7 +30685,7 @@ function currentAssistantMessage(state) {
|
|
|
30434
30685
|
if (last?.role === "assistant" && last.id === state.currentAssistantMessageId)
|
|
30435
30686
|
return last;
|
|
30436
30687
|
const message = {
|
|
30437
|
-
id:
|
|
30688
|
+
id: randomBytes3(12).toString("hex"),
|
|
30438
30689
|
role: "assistant",
|
|
30439
30690
|
content: "",
|
|
30440
30691
|
parts: [],
|
|
@@ -30459,7 +30710,7 @@ var RESUME_FELL_BACK_NOTICE = "Could not resume the previous Cursor conversation
|
|
|
30459
30710
|
function appendResumeFallbackNotice(state) {
|
|
30460
30711
|
closeTextParts(state, undefined);
|
|
30461
30712
|
state.currentAssistantMessageId = undefined;
|
|
30462
|
-
const messageId =
|
|
30713
|
+
const messageId = randomBytes3(12).toString("hex");
|
|
30463
30714
|
const createdAt = new Date().toISOString();
|
|
30464
30715
|
const part = {
|
|
30465
30716
|
type: "status",
|
|
@@ -30804,13 +31055,13 @@ function cursorAppliedPolicy(state) {
|
|
|
30804
31055
|
}
|
|
30805
31056
|
|
|
30806
31057
|
// ../../bridges/cursor-bridge/src/agent-session.ts
|
|
30807
|
-
import { createHash as
|
|
31058
|
+
import { createHash as createHash7, randomBytes as randomBytes6 } from "node:crypto";
|
|
30808
31059
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
30809
31060
|
import { homedir as homedir3 } from "node:os";
|
|
30810
31061
|
import { join as join6 } from "node:path";
|
|
30811
31062
|
|
|
30812
31063
|
// ../../bridges/cursor-bridge/src/persistence.ts
|
|
30813
|
-
import { randomBytes as
|
|
31064
|
+
import { randomBytes as randomBytes5 } from "node:crypto";
|
|
30814
31065
|
import { mkdir, open as open2, readdir, readFile, rename, stat, unlink, writeFile } from "node:fs/promises";
|
|
30815
31066
|
import { basename, dirname, join as join3 } from "node:path";
|
|
30816
31067
|
|
|
@@ -31216,7 +31467,7 @@ function encodedBytes(requestId, value) {
|
|
|
31216
31467
|
}
|
|
31217
31468
|
|
|
31218
31469
|
// ../../bridges/cursor-bridge/src/session-factory.ts
|
|
31219
|
-
import { randomBytes as
|
|
31470
|
+
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
31220
31471
|
|
|
31221
31472
|
// ../protocol/src/runtime-health.ts
|
|
31222
31473
|
var MAX_RUNTIME_NOTICE_MESSAGE_LENGTH = 1000;
|
|
@@ -31306,7 +31557,7 @@ function emptyRuntimeHealth() {
|
|
|
31306
31557
|
// ../../bridges/cursor-bridge/src/session-factory.ts
|
|
31307
31558
|
function newSessionState(clientSessionKey, policy) {
|
|
31308
31559
|
return {
|
|
31309
|
-
id:
|
|
31560
|
+
id: randomBytes4(16).toString("hex"),
|
|
31310
31561
|
...policy ? { policy } : {},
|
|
31311
31562
|
...clientSessionKey ? { clientSessionKey } : {},
|
|
31312
31563
|
status: "idle",
|
|
@@ -31378,7 +31629,7 @@ var UNSUPPORTED_DIRECTORY_SYNC = new Set(["EISDIR", "EPERM", "EINVAL", "ENOTSUP"
|
|
|
31378
31629
|
var temporarySequence = 0;
|
|
31379
31630
|
function temporaryPath(stateFile) {
|
|
31380
31631
|
temporarySequence += 1;
|
|
31381
|
-
return `${stateFile}.${process.pid}.${temporarySequence}.${
|
|
31632
|
+
return `${stateFile}.${process.pid}.${temporarySequence}.${randomBytes5(4).toString("hex")}.tmp`;
|
|
31382
31633
|
}
|
|
31383
31634
|
var TEMPORARY_NAME = /^(\d+)\.\d+\.[0-9a-f]+$/;
|
|
31384
31635
|
var TEMPORARY_SWEEP_INTERVAL_MS = 10 * 60 * 1000;
|
|
@@ -32234,7 +32485,7 @@ import {
|
|
|
32234
32485
|
} from "@cursor/sdk";
|
|
32235
32486
|
|
|
32236
32487
|
// ../protocol/src/node/bridge-diagnostics.ts
|
|
32237
|
-
import { createHash as
|
|
32488
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
32238
32489
|
|
|
32239
32490
|
// ../protocol/src/event-loop-stall-monitor.ts
|
|
32240
32491
|
var log4 = createLogger("event-loop");
|
|
@@ -32333,7 +32584,7 @@ function sameSet(a, b) {
|
|
|
32333
32584
|
function identity(value) {
|
|
32334
32585
|
if (typeof value !== "string" || !value || value.length > MAX_ID_LENGTH)
|
|
32335
32586
|
return;
|
|
32336
|
-
return
|
|
32587
|
+
return createHash4("sha256").update(value).digest("hex").slice(0, 16);
|
|
32337
32588
|
}
|
|
32338
32589
|
function readBridgeDebugFlag(value) {
|
|
32339
32590
|
return value?.trim() === "1";
|
|
@@ -32733,7 +32984,7 @@ var bufferedFlushes = new Set;
|
|
|
32733
32984
|
|
|
32734
32985
|
// ../../bridges/cursor-bridge/src/sdk-diagnostics.ts
|
|
32735
32986
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
32736
|
-
import { createHash as
|
|
32987
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
32737
32988
|
import * as sdk from "@cursor/sdk";
|
|
32738
32989
|
var MAX_TRANSPORTS = 16;
|
|
32739
32990
|
var MAX_EXECUTIONS = 128;
|
|
@@ -32831,7 +33082,7 @@ function object2(value) {
|
|
|
32831
33082
|
function hash(value) {
|
|
32832
33083
|
if (typeof value !== "string" || !value || value.length > 1024)
|
|
32833
33084
|
return;
|
|
32834
|
-
return
|
|
33085
|
+
return createHash5("sha256").update(value).digest("hex").slice(0, 16);
|
|
32835
33086
|
}
|
|
32836
33087
|
function age(now, value) {
|
|
32837
33088
|
return typeof value === "number" && Number.isFinite(value) ? Math.max(0, now - value) : null;
|
|
@@ -33711,7 +33962,7 @@ function workspaceObservationReportIssues(value) {
|
|
|
33711
33962
|
}
|
|
33712
33963
|
|
|
33713
33964
|
// ../protocol/src/node/change-tracking/evidence-spool.ts
|
|
33714
|
-
import { createHash as
|
|
33965
|
+
import { createHash as createHash6, randomUUID } from "node:crypto";
|
|
33715
33966
|
import { readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
33716
33967
|
import { appendFile, mkdir as mkdir2, rename as rename2, rm, writeFile as writeFile2 } from "node:fs/promises";
|
|
33717
33968
|
import { join as join4 } from "node:path";
|
|
@@ -33727,10 +33978,10 @@ var DEFAULT_EVIDENCE_SPOOL_LIMITS = {
|
|
|
33727
33978
|
var ENTRIES_FILE = "entries.jsonl";
|
|
33728
33979
|
var BODY_DIRECTORY = "bodies";
|
|
33729
33980
|
function evidenceBodyId(bytes) {
|
|
33730
|
-
return `sha256:${
|
|
33981
|
+
return `sha256:${createHash6("sha256").update(bytes).digest("hex")}`;
|
|
33731
33982
|
}
|
|
33732
33983
|
function stableEvidenceId(...parts) {
|
|
33733
|
-
const hash =
|
|
33984
|
+
const hash = createHash6("sha256");
|
|
33734
33985
|
for (const part of parts)
|
|
33735
33986
|
hash.update(`${part ?? ""}\x00`);
|
|
33736
33987
|
return hash.digest("hex").slice(0, 40);
|
|
@@ -35199,7 +35450,7 @@ function markConfigResumePending(state, pending) {
|
|
|
35199
35450
|
}
|
|
35200
35451
|
async function fileDigest(file) {
|
|
35201
35452
|
try {
|
|
35202
|
-
return `sha256:${
|
|
35453
|
+
return `sha256:${createHash7("sha256").update(await readFile2(file)).digest("base64url")}`;
|
|
35203
35454
|
} catch {
|
|
35204
35455
|
return "absent";
|
|
35205
35456
|
}
|
|
@@ -35214,7 +35465,7 @@ async function cursorMcpConfigRevision(state) {
|
|
|
35214
35465
|
policy.projectResources ? fileDigest(join6(workingDirectory, ".cursor", "mcp.json")) : Promise.resolve("excluded")
|
|
35215
35466
|
]);
|
|
35216
35467
|
return {
|
|
35217
|
-
fingerprint:
|
|
35468
|
+
fingerprint: createHash7("sha256").update(`user=${user}\x00project=${project}`).digest("base64url"),
|
|
35218
35469
|
sources: { user, project }
|
|
35219
35470
|
};
|
|
35220
35471
|
}
|
|
@@ -35884,7 +36135,7 @@ function appendHistoricTurn(state, turn, runId) {
|
|
|
35884
36135
|
pushHistoricRow(state, row, planned);
|
|
35885
36136
|
}
|
|
35886
36137
|
function newHistoricRow() {
|
|
35887
|
-
return { messageId:
|
|
36138
|
+
return { messageId: randomBytes6(12).toString("hex"), parts: [], content: "" };
|
|
35888
36139
|
}
|
|
35889
36140
|
function pushHistoricRow(state, row, planned) {
|
|
35890
36141
|
if (row.parts.length === 0)
|
|
@@ -35949,7 +36200,7 @@ function appendHistoricShellTurn(state, body) {
|
|
|
35949
36200
|
args: body.shellCommand,
|
|
35950
36201
|
...isObject(body.shellOutput) ? { result: { status: "success", value: body.shellOutput } } : {}
|
|
35951
36202
|
});
|
|
35952
|
-
const messageId =
|
|
36203
|
+
const messageId = randomBytes6(12).toString("hex");
|
|
35953
36204
|
pushMessage(state, "assistant", "", [
|
|
35954
36205
|
{
|
|
35955
36206
|
type: "tool-invocation",
|
|
@@ -35966,7 +36217,7 @@ function appendHistoricShellTurn(state, body) {
|
|
|
35966
36217
|
}
|
|
35967
36218
|
], messageId);
|
|
35968
36219
|
}
|
|
35969
|
-
function pushMessage(state, role, content, parts, messageId =
|
|
36220
|
+
function pushMessage(state, role, content, parts, messageId = randomBytes6(12).toString("hex"), extras) {
|
|
35970
36221
|
const message = {
|
|
35971
36222
|
id: messageId,
|
|
35972
36223
|
role,
|
|
@@ -36414,7 +36665,7 @@ function isFileEditToolName(toolName) {
|
|
|
36414
36665
|
|
|
36415
36666
|
// ../protocol/src/node/workspace-change-probe.ts
|
|
36416
36667
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
36417
|
-
import { rmSync } from "node:fs";
|
|
36668
|
+
import { rmSync as rmSync2 } from "node:fs";
|
|
36418
36669
|
import { copyFile, lstat, mkdtemp, rm as rm2 } from "node:fs/promises";
|
|
36419
36670
|
import { tmpdir } from "node:os";
|
|
36420
36671
|
import { delimiter, isAbsolute as isAbsolute4, join as join8, resolve as resolve4 } from "node:path";
|
|
@@ -36627,6 +36878,7 @@ function classifyCommandFailure(error, options = {}) {
|
|
|
36627
36878
|
import { createRequire as createRequire2 } from "node:module";
|
|
36628
36879
|
|
|
36629
36880
|
// ../protocol/src/node/shell-process-state.ts
|
|
36881
|
+
import { spawnSync } from "node:child_process";
|
|
36630
36882
|
import { readdirSync as readdirSync3, readFileSync as readFileSync3 } from "node:fs";
|
|
36631
36883
|
import { constants as osConstants } from "node:os";
|
|
36632
36884
|
var PROCESS_INSPECTION_OPTIONS = {
|
|
@@ -36696,8 +36948,11 @@ function linuxGroupHasLiveMember(pgid) {
|
|
|
36696
36948
|
return false;
|
|
36697
36949
|
}
|
|
36698
36950
|
function psGroupHasLiveMember(pgid) {
|
|
36699
|
-
const
|
|
36700
|
-
|
|
36951
|
+
const argv = ["-A", "-o", "pgid=,stat="];
|
|
36952
|
+
const bun = bunRuntime();
|
|
36953
|
+
const result = bun ? bun.spawnSync(["/bin/ps", ...argv], PROCESS_INSPECTION_OPTIONS) : spawnSync("/bin/ps", argv, PROCESS_INSPECTION_OPTIONS);
|
|
36954
|
+
const succeeded = "success" in result ? result.success : result.status === 0 && !result.error;
|
|
36955
|
+
if (!succeeded)
|
|
36701
36956
|
return true;
|
|
36702
36957
|
return result.stdout.toString().split(`
|
|
36703
36958
|
`).some((line) => {
|
|
@@ -37059,6 +37314,7 @@ function executeCommandBytes(command, args, options, timeoutMs, outputLimit, std
|
|
|
37059
37314
|
let limitTimer;
|
|
37060
37315
|
let stopExitWatch = () => {};
|
|
37061
37316
|
let commandExit;
|
|
37317
|
+
let pendingFailure;
|
|
37062
37318
|
const finishCapture = () => {
|
|
37063
37319
|
settled = true;
|
|
37064
37320
|
clearTimeout(timeoutTimer);
|
|
@@ -37080,13 +37336,33 @@ function executeCommandBytes(command, args, options, timeoutMs, outputLimit, std
|
|
|
37080
37336
|
releaseCaptureFds();
|
|
37081
37337
|
}
|
|
37082
37338
|
};
|
|
37083
|
-
const
|
|
37084
|
-
if (settled)
|
|
37085
|
-
return;
|
|
37339
|
+
const rejectFailure = (error) => {
|
|
37086
37340
|
const output = finishCapture();
|
|
37087
37341
|
if (output)
|
|
37088
37342
|
reject(Object.assign(error, { ...output, killed: timedOut }));
|
|
37089
37343
|
};
|
|
37344
|
+
const awaitTermination = (delayMs) => {
|
|
37345
|
+
clearTimeout(groupTimer);
|
|
37346
|
+
if (settled)
|
|
37347
|
+
return;
|
|
37348
|
+
if ((commandExit || exitReported(child)) && !commandGroupAlive(child)) {
|
|
37349
|
+
rejectFailure(pendingFailure);
|
|
37350
|
+
return;
|
|
37351
|
+
}
|
|
37352
|
+
groupTimer = setTimeout(awaitTermination, delayMs, Math.min(delayMs * 2, COMMAND_GROUP_POLL_MAX_MS));
|
|
37353
|
+
};
|
|
37354
|
+
const fail = (error) => {
|
|
37355
|
+
if (settled || pendingFailure)
|
|
37356
|
+
return;
|
|
37357
|
+
if (options.waitForTermination && child.pid !== undefined) {
|
|
37358
|
+
pendingFailure = error;
|
|
37359
|
+
signalCommand(child, "SIGKILL");
|
|
37360
|
+
clearTimeout(timeoutTimer);
|
|
37361
|
+
clearInterval(limitTimer);
|
|
37362
|
+
awaitTermination(COMMAND_GROUP_POLL_MS);
|
|
37363
|
+
} else
|
|
37364
|
+
rejectFailure(error);
|
|
37365
|
+
};
|
|
37090
37366
|
const abort = () => {
|
|
37091
37367
|
timedOut = true;
|
|
37092
37368
|
signalCommand(child, "SIGKILL");
|
|
@@ -37113,11 +37389,11 @@ function executeCommandBytes(command, args, options, timeoutMs, outputLimit, std
|
|
|
37113
37389
|
}
|
|
37114
37390
|
};
|
|
37115
37391
|
limitTimer = setInterval(() => {
|
|
37116
|
-
if (!settled && !timedOut)
|
|
37392
|
+
if (!settled && !timedOut && !pendingFailure)
|
|
37117
37393
|
failIfOverLimit();
|
|
37118
37394
|
}, COMMAND_OUTPUT_CHECK_MS);
|
|
37119
37395
|
const settleOnExit = () => {
|
|
37120
|
-
if (settled || timedOut || failIfOverLimit())
|
|
37396
|
+
if (settled || timedOut || pendingFailure || failIfOverLimit())
|
|
37121
37397
|
return;
|
|
37122
37398
|
if (commandExit?.code !== 0 || commandExit.signal !== null) {
|
|
37123
37399
|
fail(Object.assign(new Error(`Command failed: ${[command, ...args].join(" ")}`), {
|
|
@@ -37131,7 +37407,7 @@ function executeCommandBytes(command, args, options, timeoutMs, outputLimit, std
|
|
|
37131
37407
|
resolve(output);
|
|
37132
37408
|
};
|
|
37133
37409
|
const awaitGroupExit = (delayMs) => {
|
|
37134
|
-
if (settled || timedOut)
|
|
37410
|
+
if (settled || timedOut || pendingFailure)
|
|
37135
37411
|
return;
|
|
37136
37412
|
if (commandGroupAlive(child)) {
|
|
37137
37413
|
groupTimer = setTimeout(awaitGroupExit, delayMs, Math.min(delayMs * 2, COMMAND_GROUP_POLL_MAX_MS));
|
|
@@ -37144,14 +37420,16 @@ function executeCommandBytes(command, args, options, timeoutMs, outputLimit, std
|
|
|
37144
37420
|
return;
|
|
37145
37421
|
commandExit = exit;
|
|
37146
37422
|
stopExitWatch();
|
|
37147
|
-
if (
|
|
37423
|
+
if (pendingFailure)
|
|
37424
|
+
awaitTermination(COMMAND_GROUP_POLL_MS);
|
|
37425
|
+
else if (options.waitForDescendants)
|
|
37148
37426
|
awaitGroupExit(COMMAND_GROUP_POLL_MS);
|
|
37149
37427
|
else
|
|
37150
37428
|
settleOnExit();
|
|
37151
37429
|
};
|
|
37152
37430
|
child.exited.then(onCommandExit, (error) => fail(error instanceof Error ? error : new Error(String(error))));
|
|
37153
37431
|
stopExitWatch = watchForLostExit(child.pid, (exit) => {
|
|
37154
|
-
if (!settled
|
|
37432
|
+
if (!settled)
|
|
37155
37433
|
onCommandExit(exit);
|
|
37156
37434
|
});
|
|
37157
37435
|
if (timeoutMs > 0) {
|
|
@@ -37243,7 +37521,7 @@ var temporaryObjectDirectories = new Set;
|
|
|
37243
37521
|
process.once("exit", () => {
|
|
37244
37522
|
for (const directory of temporaryObjectDirectories) {
|
|
37245
37523
|
try {
|
|
37246
|
-
|
|
37524
|
+
rmSync2(directory, { recursive: true, force: true });
|
|
37247
37525
|
} catch {}
|
|
37248
37526
|
}
|
|
37249
37527
|
});
|
|
@@ -38441,7 +38719,7 @@ async function withTimeout3(work, timeoutMs) {
|
|
|
38441
38719
|
}
|
|
38442
38720
|
}
|
|
38443
38721
|
// ../../bridges/cursor-bridge/src/prompt-attachments.ts
|
|
38444
|
-
import { constants } from "node:fs";
|
|
38722
|
+
import { constants as constants2 } from "node:fs";
|
|
38445
38723
|
import { lstat as lstat2, open as open4, realpath as realpath2 } from "node:fs/promises";
|
|
38446
38724
|
import { isAbsolute as isAbsolute5, join as join9, relative as relative4, resolve as resolve6, sep as sep3 } from "node:path";
|
|
38447
38725
|
|
|
@@ -38592,8 +38870,8 @@ async function readWorkspaceImage(filePath, workspaceRoot) {
|
|
|
38592
38870
|
if (!isPathWithin(canonicalRoot, canonicalTarget)) {
|
|
38593
38871
|
throw new PromptAttachmentError("attachment_outside_workspace", "Image attachment must be contained in the current workspace");
|
|
38594
38872
|
}
|
|
38595
|
-
const noFollow =
|
|
38596
|
-
const handle = await open4(targetPath,
|
|
38873
|
+
const noFollow = constants2.O_NOFOLLOW ?? 0;
|
|
38874
|
+
const handle = await open4(targetPath, constants2.O_RDONLY | noFollow).catch((error) => {
|
|
38597
38875
|
throw attachmentErrorForFsFailure(error);
|
|
38598
38876
|
});
|
|
38599
38877
|
try {
|
|
@@ -39071,7 +39349,7 @@ function humanPromptObservation(messages, tasks) {
|
|
|
39071
39349
|
}
|
|
39072
39350
|
|
|
39073
39351
|
// ../../bridges/cursor-bridge/src/http.ts
|
|
39074
|
-
import { createHash as
|
|
39352
|
+
import { createHash as createHash9, randomBytes as randomBytes7 } from "node:crypto";
|
|
39075
39353
|
import { pathToFileURL } from "node:url";
|
|
39076
39354
|
import { gzip } from "node:zlib";
|
|
39077
39355
|
|
|
@@ -39200,7 +39478,7 @@ var DEFAULT_MCP_MANAGEMENT_ROLLOUT = Object.freeze({
|
|
|
39200
39478
|
|
|
39201
39479
|
// ../protocol/src/node/bridge-transcript-summary.ts
|
|
39202
39480
|
import { Buffer as Buffer6 } from "node:buffer";
|
|
39203
|
-
import { createHash as
|
|
39481
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
39204
39482
|
|
|
39205
39483
|
// ../protocol/src/node/progressive-transcript.ts
|
|
39206
39484
|
var BRIDGE_TRANSCRIPT_MAX_MESSAGES = 100;
|
|
@@ -39366,7 +39644,7 @@ function digestPayload(payload) {
|
|
|
39366
39644
|
const serialized = JSON.stringify(payload);
|
|
39367
39645
|
return {
|
|
39368
39646
|
bytes: Buffer6.byteLength(serialized),
|
|
39369
|
-
digest:
|
|
39647
|
+
digest: createHash8("sha256").update(serialized).digest("base64url").slice(0, 32)
|
|
39370
39648
|
};
|
|
39371
39649
|
}
|
|
39372
39650
|
function topLevelKey(part, index) {
|
|
@@ -40111,6 +40389,9 @@ async function route(request, response, clientSignal) {
|
|
|
40111
40389
|
})) {
|
|
40112
40390
|
return json(response, 401, { error: "Unauthorized" });
|
|
40113
40391
|
}
|
|
40392
|
+
const refused = await admitNodeBridgeRequest(bridgeAuthority, request, MAX_BODY_BYTES);
|
|
40393
|
+
if (refused)
|
|
40394
|
+
return json(response, refused.status, refused.body);
|
|
40114
40395
|
try {
|
|
40115
40396
|
if (url.pathname === SESSION_ACTIVITY_BATCH_PATH && request.method === "POST") {
|
|
40116
40397
|
const answer = await answerSessionActivityBatch(request, sessionActivityObservation, {
|
|
@@ -40297,7 +40578,7 @@ async function startLogin(response) {
|
|
|
40297
40578
|
});
|
|
40298
40579
|
json(response, 200, { url: loginUrl, loginUrl });
|
|
40299
40580
|
}
|
|
40300
|
-
var TRANSCRIPT_GENERATION =
|
|
40581
|
+
var TRANSCRIPT_GENERATION = randomBytes7(16).toString("hex");
|
|
40301
40582
|
var SESSION_ROUTE = /^\/session\/([^/]+)(?:\/(messages|transcript|status|usage|activity|human-prompts|prompt|attach|dispatch|cancel|abort|hard-abort|steer|structured-output|interactions|config|approvals|runtime-health|commands|mcp|rewind-messages|compact|close))?(?:\/([^/]+))?$/;
|
|
40302
40583
|
async function routeSession(request, response, url, clientSignal) {
|
|
40303
40584
|
const match = SESSION_ROUTE.exec(url.pathname);
|
|
@@ -40503,7 +40784,7 @@ async function handleSteer(request, response, state) {
|
|
|
40503
40784
|
const expectedRunId = readBoundedString(body.expectedRunId, MAX_STEER_ID_BYTES, "expectedRunId");
|
|
40504
40785
|
if (!text)
|
|
40505
40786
|
throw new HttpError(400, "input is required");
|
|
40506
|
-
const inputDigest =
|
|
40787
|
+
const inputDigest = createHash9("sha256").update(text).digest("hex");
|
|
40507
40788
|
if (requestId && expectedRunId) {
|
|
40508
40789
|
const previous = state.steerJournal.get(requestId);
|
|
40509
40790
|
if (previous) {
|
|
@@ -40982,7 +41263,7 @@ function appendLocalExchange(state, prompt, reply, requestId) {
|
|
|
40982
41263
|
if (userId && state.messages.some((message) => message.id === userId))
|
|
40983
41264
|
return;
|
|
40984
41265
|
const userMessageId = appendUserMessage(state, prompt, [], userId);
|
|
40985
|
-
const messageId = requestId ? `idle-steer-reply:${requestId}` :
|
|
41266
|
+
const messageId = requestId ? `idle-steer-reply:${requestId}` : randomBytes7(12).toString("hex");
|
|
40986
41267
|
state.messages.push({
|
|
40987
41268
|
id: messageId,
|
|
40988
41269
|
role: "assistant",
|
|
@@ -40999,7 +41280,7 @@ function appendLocalExchange(state, prompt, reply, requestId) {
|
|
|
40999
41280
|
});
|
|
41000
41281
|
chargeTranscript(state, Buffer.byteLength(reply));
|
|
41001
41282
|
}
|
|
41002
|
-
function appendUserMessage(state, prompt, images, messageId =
|
|
41283
|
+
function appendUserMessage(state, prompt, images, messageId = randomBytes7(12).toString("hex")) {
|
|
41003
41284
|
state.messages.push({
|
|
41004
41285
|
id: messageId,
|
|
41005
41286
|
role: "user",
|
|
@@ -41035,9 +41316,10 @@ function readBoundedString(value, limit, field) {
|
|
|
41035
41316
|
return trimmed;
|
|
41036
41317
|
}
|
|
41037
41318
|
async function readJson(request) {
|
|
41038
|
-
const
|
|
41039
|
-
|
|
41040
|
-
|
|
41319
|
+
const admitted = takeAdmittedBody(request);
|
|
41320
|
+
const chunks = admitted ? [admitted] : [];
|
|
41321
|
+
let total = admitted?.length ?? 0;
|
|
41322
|
+
for await (const chunk of admitted ? [] : request) {
|
|
41041
41323
|
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
41042
41324
|
total += buffer.length;
|
|
41043
41325
|
if (total > MAX_BODY_BYTES)
|
|
@@ -41630,6 +41912,7 @@ export {
|
|
|
41630
41912
|
boundTranscript,
|
|
41631
41913
|
boundTranscriptDuringStreaming,
|
|
41632
41914
|
boundTranscriptForRead,
|
|
41915
|
+
bridgeAuthority,
|
|
41633
41916
|
cancelSurvivingRuns,
|
|
41634
41917
|
chargeTranscript,
|
|
41635
41918
|
childTrimNoticePartId,
|