@cotal-ai/seat 0.47.0 → 0.48.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/client.d.ts +55 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +202 -0
- package/dist/client.js.map +1 -0
- package/dist/custodian.d.ts +15 -0
- package/dist/custodian.d.ts.map +1 -0
- package/dist/custodian.js +353 -0
- package/dist/custodian.js.map +1 -0
- package/dist/handle.d.ts +36 -0
- package/dist/handle.d.ts.map +1 -0
- package/dist/handle.js +158 -0
- package/dist/handle.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/launcher.d.ts +17 -0
- package/dist/launcher.d.ts.map +1 -0
- package/dist/launcher.js +102 -0
- package/dist/launcher.js.map +1 -0
- package/dist/peercred.d.ts +12 -0
- package/dist/peercred.d.ts.map +1 -0
- package/dist/peercred.js +49 -0
- package/dist/peercred.js.map +1 -0
- package/dist/protocol.d.ts +137 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +55 -0
- package/dist/protocol.js.map +1 -0
- package/dist/record.d.ts +17 -0
- package/dist/record.d.ts.map +1 -0
- package/dist/record.js +49 -0
- package/dist/record.js.map +1 -0
- package/package.json +1 -1
package/dist/handle.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { SeatRecord } from "./record.js";
|
|
2
|
+
export interface SeatAttachSession {
|
|
3
|
+
readonly cols: number;
|
|
4
|
+
readonly rows: number;
|
|
5
|
+
backlog(): Promise<Buffer>;
|
|
6
|
+
onData(fn: (chunk: Buffer) => void): () => void;
|
|
7
|
+
onExit(fn: () => void): () => void;
|
|
8
|
+
write(data: string): void;
|
|
9
|
+
resize(cols: number, rows: number): void;
|
|
10
|
+
}
|
|
11
|
+
export interface SeatHandle {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly kind: "pty";
|
|
14
|
+
readonly reference: {
|
|
15
|
+
kind: "pty";
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
readonly pid: number;
|
|
19
|
+
readonly record: SeatRecord;
|
|
20
|
+
status(): "running" | "exited";
|
|
21
|
+
exitInfo(): {
|
|
22
|
+
code?: number;
|
|
23
|
+
signal?: number;
|
|
24
|
+
} | undefined;
|
|
25
|
+
stop(opts?: {
|
|
26
|
+
graceful?: boolean;
|
|
27
|
+
}): void;
|
|
28
|
+
waitForExit(): Promise<void>;
|
|
29
|
+
interrupt(): void;
|
|
30
|
+
write(data: string): void;
|
|
31
|
+
attach(): SeatAttachSession;
|
|
32
|
+
close(): void;
|
|
33
|
+
}
|
|
34
|
+
export declare function adoptSeatSync(record: SeatRecord): SeatHandle;
|
|
35
|
+
export declare function adoptSeat(record: SeatRecord): Promise<SeatHandle>;
|
|
36
|
+
//# sourceMappingURL=handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3B,MAAM,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAChD,MAAM,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IACnC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE;QAAE,IAAI,EAAE,KAAK,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,MAAM,IAAI,SAAS,GAAG,QAAQ,CAAC;IAC/B,QAAQ,IAAI;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAC3D,IAAI,CAAC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC1C,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,SAAS,IAAI,IAAI,CAAC;IAClB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,IAAI,iBAAiB,CAAC;IAC5B,KAAK,IAAI,IAAI,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAoJ5D;AAED,wBAAsB,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAIvE"}
|
package/dist/handle.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { SeatClient } from "./client.js";
|
|
2
|
+
export function adoptSeatSync(record) {
|
|
3
|
+
const client = new SeatClient(record);
|
|
4
|
+
const ready = client.connect();
|
|
5
|
+
let status = "running";
|
|
6
|
+
let exit;
|
|
7
|
+
let cols = 120;
|
|
8
|
+
let rows = 32;
|
|
9
|
+
let helloGeometryApplied = false;
|
|
10
|
+
const liveUnsubs = new Set();
|
|
11
|
+
const whenReady = () => ready.then((hello) => {
|
|
12
|
+
// Hello reports spawn size. Re-applying it on every later() overwrites a
|
|
13
|
+
// resize that already updated these fields (mesh-attach-plane resize cell).
|
|
14
|
+
if (!helloGeometryApplied) {
|
|
15
|
+
cols = hello.cols;
|
|
16
|
+
rows = hello.rows;
|
|
17
|
+
helloGeometryApplied = true;
|
|
18
|
+
}
|
|
19
|
+
status = hello.status;
|
|
20
|
+
exit = hello.exit;
|
|
21
|
+
return client;
|
|
22
|
+
});
|
|
23
|
+
const later = (fn) => {
|
|
24
|
+
void whenReady()
|
|
25
|
+
.then(fn)
|
|
26
|
+
.catch(() => undefined);
|
|
27
|
+
};
|
|
28
|
+
later((c) => {
|
|
29
|
+
c.onExit(() => {
|
|
30
|
+
status = "exited";
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
name: record.name,
|
|
35
|
+
kind: "pty",
|
|
36
|
+
reference: { kind: "pty", id: record.id },
|
|
37
|
+
pid: record.childPid,
|
|
38
|
+
record,
|
|
39
|
+
status: () => status,
|
|
40
|
+
exitInfo: () => exit,
|
|
41
|
+
stop: (opts) => {
|
|
42
|
+
later((c) => c.stop(opts?.graceful === false ? "hard" : "graceful"));
|
|
43
|
+
},
|
|
44
|
+
waitForExit: async () => {
|
|
45
|
+
try {
|
|
46
|
+
const c = await whenReady();
|
|
47
|
+
if (status !== "exited") {
|
|
48
|
+
const info = await c.waitExit();
|
|
49
|
+
status = "exited";
|
|
50
|
+
if (info)
|
|
51
|
+
exit = info;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
client.close();
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
interrupt: () => {
|
|
59
|
+
later((c) => c.interrupt());
|
|
60
|
+
},
|
|
61
|
+
write: (data) => {
|
|
62
|
+
later((c) => c.write(data));
|
|
63
|
+
},
|
|
64
|
+
attach: () => {
|
|
65
|
+
const sessionUnsubs = new Set();
|
|
66
|
+
// Fast-exit children print and die before hello. onData must replay the
|
|
67
|
+
// screen, and onExit must wait for that replay so a dump-then-exit spawn
|
|
68
|
+
// is not observed as an empty attach (env-isolate printenv).
|
|
69
|
+
let pendingOutput = Promise.resolve();
|
|
70
|
+
return {
|
|
71
|
+
get cols() {
|
|
72
|
+
return cols;
|
|
73
|
+
},
|
|
74
|
+
get rows() {
|
|
75
|
+
return rows;
|
|
76
|
+
},
|
|
77
|
+
backlog: async () => {
|
|
78
|
+
const c = await whenReady();
|
|
79
|
+
const snap = await c.snapshot();
|
|
80
|
+
cols = snap.cols;
|
|
81
|
+
rows = snap.rows;
|
|
82
|
+
return Buffer.from(snap.data, "utf8");
|
|
83
|
+
},
|
|
84
|
+
onData: (fn) => {
|
|
85
|
+
let unsub = () => { };
|
|
86
|
+
let cancelled = false;
|
|
87
|
+
let releaseOutput = () => { };
|
|
88
|
+
const outputReady = new Promise((resolve) => {
|
|
89
|
+
releaseOutput = resolve;
|
|
90
|
+
});
|
|
91
|
+
pendingOutput = pendingOutput.then(() => outputReady);
|
|
92
|
+
later(async (c) => {
|
|
93
|
+
try {
|
|
94
|
+
const u = await c.subscribeOutput(fn);
|
|
95
|
+
unsub = u;
|
|
96
|
+
if (cancelled) {
|
|
97
|
+
u();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
sessionUnsubs.add(u);
|
|
101
|
+
liveUnsubs.add(u);
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
releaseOutput();
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
return () => {
|
|
108
|
+
cancelled = true;
|
|
109
|
+
unsub();
|
|
110
|
+
sessionUnsubs.delete(unsub);
|
|
111
|
+
liveUnsubs.delete(unsub);
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
onExit: (fn) => {
|
|
115
|
+
let unsub = () => { };
|
|
116
|
+
let cancelled = false;
|
|
117
|
+
later(async (c) => {
|
|
118
|
+
await pendingOutput;
|
|
119
|
+
if (cancelled)
|
|
120
|
+
return;
|
|
121
|
+
unsub = c.onExit(fn);
|
|
122
|
+
sessionUnsubs.add(unsub);
|
|
123
|
+
liveUnsubs.add(unsub);
|
|
124
|
+
});
|
|
125
|
+
return () => {
|
|
126
|
+
cancelled = true;
|
|
127
|
+
unsub();
|
|
128
|
+
sessionUnsubs.delete(unsub);
|
|
129
|
+
liveUnsubs.delete(unsub);
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
write: (data) => {
|
|
133
|
+
later((c) => c.write(data));
|
|
134
|
+
},
|
|
135
|
+
resize: (c, r) => {
|
|
136
|
+
if (c <= 0 || r <= 0)
|
|
137
|
+
return;
|
|
138
|
+
cols = c;
|
|
139
|
+
rows = r;
|
|
140
|
+
helloGeometryApplied = true;
|
|
141
|
+
later((cli) => cli.resize(c, r));
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
close: () => {
|
|
146
|
+
for (const u of liveUnsubs)
|
|
147
|
+
u();
|
|
148
|
+
liveUnsubs.clear();
|
|
149
|
+
client.close();
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
export async function adoptSeat(record) {
|
|
154
|
+
const handle = adoptSeatSync(record);
|
|
155
|
+
await handle.attach().backlog();
|
|
156
|
+
return handle;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=handle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA6BzC,MAAM,UAAU,aAAa,CAAC,MAAkB;IAC9C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAC/B,IAAI,MAAM,GAAyB,SAAS,CAAC;IAC7C,IAAI,IAAoD,CAAC;IACzD,IAAI,IAAI,GAAG,GAAG,CAAC;IACf,IAAI,IAAI,GA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C,EAAE,CAAC;YAChC,UAAU,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAkB;IAChD,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC;IAChC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { PROTOCOL_VERSION, unsupportedTransport } from "./protocol.js";
|
|
2
|
+
export { launchSeat, loadSeat, type LaunchSeatOpts, type SeatLaunchSpec } from "./launcher.js";
|
|
3
|
+
export { adoptSeat, adoptSeatSync, type SeatHandle, type SeatAttachSession } from "./handle.js";
|
|
4
|
+
export { readRecord, recordPath, socketPath, type SeatRecord } from "./record.js";
|
|
5
|
+
export { SeatClient } from "./client.js";
|
|
6
|
+
export { runCustodian, type CustodianLaunch } from "./custodian.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { PROTOCOL_VERSION, unsupportedTransport } from "./protocol.js";
|
|
2
|
+
export { launchSeat, loadSeat } from "./launcher.js";
|
|
3
|
+
export { adoptSeat, adoptSeatSync } from "./handle.js";
|
|
4
|
+
export { readRecord, recordPath, socketPath } from "./record.js";
|
|
5
|
+
export { SeatClient } from "./client.js";
|
|
6
|
+
export { runCustodian } from "./custodian.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAA4C,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,SAAS,EAAE,aAAa,EAA2C,MAAM,aAAa,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAmB,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAwB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type SeatRecord } from "./record.js";
|
|
2
|
+
export interface SeatLaunchSpec {
|
|
3
|
+
command: string;
|
|
4
|
+
args: string[];
|
|
5
|
+
env?: Record<string, string>;
|
|
6
|
+
confirm?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface LaunchSeatOpts {
|
|
9
|
+
root: string;
|
|
10
|
+
name: string;
|
|
11
|
+
spec: SeatLaunchSpec;
|
|
12
|
+
cwd: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function launchSeat(opts: LaunchSeatOpts): SeatRecord;
|
|
15
|
+
export declare function loadSeat(root: string, id: string): SeatRecord;
|
|
16
|
+
export declare function readSeatFile(path: string): SeatRecord;
|
|
17
|
+
//# sourceMappingURL=launcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmD,KAAK,UAAU,EAAc,MAAM,aAAa,CAAC;AAG3G,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACb;AAwBD,wBAAgB,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,UAAU,CA8D3D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAE7D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAErD"}
|
package/dist/launcher.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
2
|
+
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { capabilityToken, recordPath, seatId, socketPath, readRecord } from "./record.js";
|
|
6
|
+
import { unsupportedTransport } from "./protocol.js";
|
|
7
|
+
function packageRoot() {
|
|
8
|
+
return dirname(dirname(fileURLToPath(import.meta.url)));
|
|
9
|
+
}
|
|
10
|
+
/** Always the compiled entry. tsx loading `src/` must not spawn a missing `src/custodian.js`. */
|
|
11
|
+
function custodianEntry() {
|
|
12
|
+
const path = join(packageRoot(), "dist", "custodian.js");
|
|
13
|
+
if (!existsSync(path))
|
|
14
|
+
throw new Error(`custodian entry missing at ${path}; build @cotal-ai/seat first`);
|
|
15
|
+
return path;
|
|
16
|
+
}
|
|
17
|
+
function pidLive(pid) {
|
|
18
|
+
if (typeof pid !== "number" || pid <= 0)
|
|
19
|
+
return false;
|
|
20
|
+
try {
|
|
21
|
+
const stat = readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
22
|
+
const state = stat.slice(stat.lastIndexOf(") ") + 2).split(" ")[0];
|
|
23
|
+
return state !== "Z";
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function launchSeat(opts) {
|
|
30
|
+
if (process.platform !== "linux")
|
|
31
|
+
throw unsupportedTransport();
|
|
32
|
+
mkdirSync(opts.root, { recursive: true, mode: 0o700 });
|
|
33
|
+
const id = seatId();
|
|
34
|
+
const token = capabilityToken();
|
|
35
|
+
const socket = socketPath(opts.root, id);
|
|
36
|
+
const recPath = recordPath(opts.root, id);
|
|
37
|
+
mkdirSync(dirname(recPath), { recursive: true, mode: 0o700 });
|
|
38
|
+
const logPath = join(dirname(recPath), "custodian.log");
|
|
39
|
+
const payload = JSON.stringify({
|
|
40
|
+
id,
|
|
41
|
+
name: opts.name,
|
|
42
|
+
command: opts.spec.command,
|
|
43
|
+
args: opts.spec.args,
|
|
44
|
+
env: opts.spec.env ?? {},
|
|
45
|
+
cwd: opts.cwd,
|
|
46
|
+
socket,
|
|
47
|
+
token,
|
|
48
|
+
recordPath: recPath,
|
|
49
|
+
logPath,
|
|
50
|
+
confirm: Boolean(opts.spec.confirm),
|
|
51
|
+
});
|
|
52
|
+
// Payload carries spec.env (provider keys) and the capability token.
|
|
53
|
+
// argv is world-readable via /proc/<pid>/cmdline (0444). Inherit a 0600
|
|
54
|
+
// file as stdin so the JSON never appears on argv.
|
|
55
|
+
const launchPath = join(dirname(recPath), "launch.json");
|
|
56
|
+
writeFileSync(launchPath, payload, { mode: 0o600 });
|
|
57
|
+
const launchFd = openSync(launchPath, "r");
|
|
58
|
+
const child = spawn(process.execPath, [custodianEntry()], {
|
|
59
|
+
detached: true,
|
|
60
|
+
stdio: [launchFd, "ignore", "ignore"],
|
|
61
|
+
env: { PATH: process.env.PATH ?? "" },
|
|
62
|
+
});
|
|
63
|
+
closeSync(launchFd);
|
|
64
|
+
try {
|
|
65
|
+
unlinkSync(launchPath);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
/* child still holds the fd */
|
|
69
|
+
}
|
|
70
|
+
child.unref();
|
|
71
|
+
const deadline = Date.now() + 10_000;
|
|
72
|
+
while (Date.now() < deadline) {
|
|
73
|
+
try {
|
|
74
|
+
const rec = readRecord(recPath);
|
|
75
|
+
if (rec.custodianPid > 0 && rec.childPid > 0) {
|
|
76
|
+
return rec;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
/* record not written yet */
|
|
81
|
+
}
|
|
82
|
+
if (!pidLive(child.pid)) {
|
|
83
|
+
let err = "";
|
|
84
|
+
try {
|
|
85
|
+
err = readFileSync(logPath, "utf8").trim();
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
/* no log */
|
|
89
|
+
}
|
|
90
|
+
throw new Error(`custodian exited before ready: ${err || `pid ${String(child.pid)} gone`}`);
|
|
91
|
+
}
|
|
92
|
+
spawnSync("sleep", ["0.025"], { stdio: "ignore" });
|
|
93
|
+
}
|
|
94
|
+
throw new Error(`custodian did not write a seat record at ${recPath}`);
|
|
95
|
+
}
|
|
96
|
+
export function loadSeat(root, id) {
|
|
97
|
+
return readRecord(recordPath(root, id));
|
|
98
|
+
}
|
|
99
|
+
export function readSeatFile(path) {
|
|
100
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|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O,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,IAAI,GAAG,GAAG,EAAE,CAAC;YACb,IAAI,CAAC;gBACH,GAAG,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;YAC7C,CAAC;YAAC,MAAM,CAAC;gBACP,YAAY;YACd,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,kCAAkC,GAAG,IAAI,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9F,CAAC;QACD,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,4CAA4C,OAAO,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,EAAU;IAC/C,OAAO,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAe,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Socket } from "node:net";
|
|
2
|
+
export interface PeerCredentials {
|
|
3
|
+
pid: number;
|
|
4
|
+
uid: number;
|
|
5
|
+
gid: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const LINUX_NATIVE_ARCHES: readonly ["x64", "arm64"];
|
|
8
|
+
export declare function nativeHelperPath(arch?: string): string;
|
|
9
|
+
export declare function unsupportedNativeArch(platform: string, arch: string): Error;
|
|
10
|
+
export declare function socketFd(sock: Socket): number;
|
|
11
|
+
export declare function peerCredentials(sock: Socket): PeerCredentials;
|
|
12
|
+
//# sourceMappingURL=peercred.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peercred.d.ts","sourceRoot":"","sources":["../src/peercred.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAID,eAAO,MAAM,mBAAmB,2BAA4B,CAAC;AAI7D,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,MAAqB,GAAG,MAAM,CAGpE;AAMD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,CAI3E;AAqBD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK7C;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAE7D"}
|
package/dist/peercred.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { unsupportedTransport } from "./protocol.js";
|
|
6
|
+
export const LINUX_NATIVE_ARCHES = ["x64", "arm64"];
|
|
7
|
+
let loaded;
|
|
8
|
+
export function nativeHelperPath(arch = process.arch) {
|
|
9
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
return join(here, "..", "build", "Release", `linux-${arch}`, "peercred.node");
|
|
11
|
+
}
|
|
12
|
+
function isLinuxNativeArch(arch) {
|
|
13
|
+
return LINUX_NATIVE_ARCHES.includes(arch);
|
|
14
|
+
}
|
|
15
|
+
export function unsupportedNativeArch(platform, arch) {
|
|
16
|
+
return new Error(`@cotal-ai/seat: SO_PEERCRED native helper unsupported on ${platform}-${arch} (supported: linux-x64, linux-arm64)`);
|
|
17
|
+
}
|
|
18
|
+
function loadNative() {
|
|
19
|
+
if (loaded)
|
|
20
|
+
return loaded;
|
|
21
|
+
if (process.platform !== "linux")
|
|
22
|
+
throw unsupportedTransport();
|
|
23
|
+
const platformArch = `${process.platform}-${process.arch}`;
|
|
24
|
+
if (!isLinuxNativeArch(process.arch))
|
|
25
|
+
throw unsupportedNativeArch(process.platform, process.arch);
|
|
26
|
+
const path = nativeHelperPath(process.arch);
|
|
27
|
+
if (!existsSync(path))
|
|
28
|
+
throw new Error(`@cotal-ai/seat: SO_PEERCRED native helper missing at ${path}`);
|
|
29
|
+
const require = createRequire(import.meta.url);
|
|
30
|
+
try {
|
|
31
|
+
loaded = require(path);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
35
|
+
throw new Error(`@cotal-ai/seat: SO_PEERCRED native helper failed to load at ${path} for ${platformArch}: ${detail}`);
|
|
36
|
+
}
|
|
37
|
+
return loaded;
|
|
38
|
+
}
|
|
39
|
+
export function socketFd(sock) {
|
|
40
|
+
const handle = sock._handle;
|
|
41
|
+
const fd = handle?.fd;
|
|
42
|
+
if (typeof fd !== "number" || fd < 0)
|
|
43
|
+
throw new Error("unix socket has no file descriptor");
|
|
44
|
+
return fd;
|
|
45
|
+
}
|
|
46
|
+
export function peerCredentials(sock) {
|
|
47
|
+
return loadNative().peercred(socketFd(sock));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=peercred.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peercred.js","sourceRoot":"","sources":["../src/peercred.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC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,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,CAAC;QACH,MAAM,GAAG,OAAO,CAAC,IAAI,CAAmB,CAAC;IAC3C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,MAAM,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChE,MAAM,IAAI,KAAK,CACb,+DAA+D,IAAI,QAAQ,YAAY,KAAK,MAAM,EAAE,CACrG,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,MAAM,MAAM,GAAI,IAAiD,CAAC,OAAO,CAAC;IAC1E,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC;IACtB,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IAC5F,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,UAAU,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/** Protocol version this process speaks. Additive later; M2 is a single implicit controller. */
|
|
2
|
+
export declare const PROTOCOL_VERSION = 1;
|
|
3
|
+
export declare const DEFAULT_COLS = 120;
|
|
4
|
+
export declare const DEFAULT_ROWS = 32;
|
|
5
|
+
export declare const SCROLLBACK_ROWS = 1000;
|
|
6
|
+
export declare const CONFIRM_INTERVAL_MS = 1000;
|
|
7
|
+
export declare const MAX_CONFIRMS = 5;
|
|
8
|
+
export declare const GRACE_MS = 3000;
|
|
9
|
+
/**
|
|
10
|
+
* Max JSON body the local protocol accepts in one frame.
|
|
11
|
+
* A 1000-row, 120-col 16-color serialize is ~744 KiB, and JSON-escaping that
|
|
12
|
+
* snapshot is 1_365_109 bytes. Truecolor fg+bg per cell is 4_876_998. 8 MiB
|
|
13
|
+
* covers both so adopt can return scrollback; a 500 MiB claimed length still
|
|
14
|
+
* fails the per-frame check.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MAX_FRAME_SIZE: number;
|
|
17
|
+
/** Max undecoded residual AFTER complete frames have been drained. */
|
|
18
|
+
export declare const MAX_BUFFER_SIZE: number;
|
|
19
|
+
export type StopMode = "graceful" | "hard";
|
|
20
|
+
export type ClientRequest = {
|
|
21
|
+
id: number;
|
|
22
|
+
op: "hello";
|
|
23
|
+
token: string;
|
|
24
|
+
} | {
|
|
25
|
+
id: number;
|
|
26
|
+
op: "snapshot";
|
|
27
|
+
} | {
|
|
28
|
+
id: number;
|
|
29
|
+
op: "subscribe-output";
|
|
30
|
+
} | {
|
|
31
|
+
id: number;
|
|
32
|
+
op: "unsubscribe-output";
|
|
33
|
+
sub: number;
|
|
34
|
+
} | {
|
|
35
|
+
id: number;
|
|
36
|
+
op: "write";
|
|
37
|
+
data: string;
|
|
38
|
+
} | {
|
|
39
|
+
id: number;
|
|
40
|
+
op: "resize";
|
|
41
|
+
cols: number;
|
|
42
|
+
rows: number;
|
|
43
|
+
} | {
|
|
44
|
+
id: number;
|
|
45
|
+
op: "interrupt";
|
|
46
|
+
} | {
|
|
47
|
+
id: number;
|
|
48
|
+
op: "stop";
|
|
49
|
+
mode: StopMode;
|
|
50
|
+
} | {
|
|
51
|
+
id: number;
|
|
52
|
+
op: "wait-exit";
|
|
53
|
+
} | {
|
|
54
|
+
id: number;
|
|
55
|
+
op: "health";
|
|
56
|
+
};
|
|
57
|
+
export type ServerEvent = {
|
|
58
|
+
event: "output";
|
|
59
|
+
sub: number;
|
|
60
|
+
data: string;
|
|
61
|
+
} | {
|
|
62
|
+
event: "exit";
|
|
63
|
+
sub?: number;
|
|
64
|
+
};
|
|
65
|
+
export type ServerReply = {
|
|
66
|
+
id: number;
|
|
67
|
+
ok: true;
|
|
68
|
+
op: "hello";
|
|
69
|
+
name: string;
|
|
70
|
+
pid: number;
|
|
71
|
+
cols: number;
|
|
72
|
+
rows: number;
|
|
73
|
+
status: "running" | "exited";
|
|
74
|
+
exit?: {
|
|
75
|
+
code?: number;
|
|
76
|
+
signal?: number;
|
|
77
|
+
};
|
|
78
|
+
} | {
|
|
79
|
+
id: number;
|
|
80
|
+
ok: true;
|
|
81
|
+
op: "snapshot";
|
|
82
|
+
data: string;
|
|
83
|
+
cols: number;
|
|
84
|
+
rows: number;
|
|
85
|
+
} | {
|
|
86
|
+
id: number;
|
|
87
|
+
ok: true;
|
|
88
|
+
op: "subscribe-output";
|
|
89
|
+
sub: number;
|
|
90
|
+
} | {
|
|
91
|
+
id: number;
|
|
92
|
+
ok: true;
|
|
93
|
+
op: "unsubscribe-output";
|
|
94
|
+
} | {
|
|
95
|
+
id: number;
|
|
96
|
+
ok: true;
|
|
97
|
+
op: "write";
|
|
98
|
+
} | {
|
|
99
|
+
id: number;
|
|
100
|
+
ok: true;
|
|
101
|
+
op: "resize";
|
|
102
|
+
} | {
|
|
103
|
+
id: number;
|
|
104
|
+
ok: true;
|
|
105
|
+
op: "interrupt";
|
|
106
|
+
} | {
|
|
107
|
+
id: number;
|
|
108
|
+
ok: true;
|
|
109
|
+
op: "stop";
|
|
110
|
+
} | {
|
|
111
|
+
id: number;
|
|
112
|
+
ok: true;
|
|
113
|
+
op: "wait-exit";
|
|
114
|
+
exit?: {
|
|
115
|
+
code?: number;
|
|
116
|
+
signal?: number;
|
|
117
|
+
};
|
|
118
|
+
} | {
|
|
119
|
+
id: number;
|
|
120
|
+
ok: true;
|
|
121
|
+
op: "health";
|
|
122
|
+
pid: number;
|
|
123
|
+
status: "running" | "exited";
|
|
124
|
+
protocol: number;
|
|
125
|
+
} | {
|
|
126
|
+
id: number;
|
|
127
|
+
ok: false;
|
|
128
|
+
error: string;
|
|
129
|
+
};
|
|
130
|
+
export type ServerMessage = ServerReply | ServerEvent;
|
|
131
|
+
export declare function encodeFrame(value: unknown): Buffer;
|
|
132
|
+
export declare class FrameReader {
|
|
133
|
+
private buf;
|
|
134
|
+
push(chunk: Buffer): unknown[];
|
|
135
|
+
}
|
|
136
|
+
export declare function unsupportedTransport(platform?: string): Error;
|
|
137
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,eAAO,MAAM,YAAY,MAAM,CAAC;AAChC,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,eAAO,MAAM,eAAe,OAAO,CAAC;AACpC,eAAO,MAAM,mBAAmB,OAAQ,CAAC;AACzC,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,eAAO,MAAM,QAAQ,OAAQ,CAAC;AAC9B;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,QAAkB,CAAC;AAC9C,sEAAsE;AACtE,eAAO,MAAM,eAAe,QAAqB,CAAC;AAElD,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;AAE3C,MAAM,MAAM,aAAa,GACrB;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,UAAU,CAAA;CAAE,GAC9B;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,kBAAkB,CAAA;CAAE,GACtC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,oBAAoB,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAA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EAAE,MAAM,CAAA;CAAE,CAAC;AAE7C,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,WAAW,CAAC;AAEtD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQlD;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,GAAG,CAA2B;IAEtC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,EAAE;CAoB/B;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,GAAE,MAAyB,GAAG,KAAK,CAE/E"}
|
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** Protocol version this process speaks. Additive later; M2 is a single implicit controller. */
|
|
2
|
+
export const PROTOCOL_VERSION = 1;
|
|
3
|
+
export const DEFAULT_COLS = 120;
|
|
4
|
+
export const DEFAULT_ROWS = 32;
|
|
5
|
+
export const SCROLLBACK_ROWS = 1000;
|
|
6
|
+
export const CONFIRM_INTERVAL_MS = 1_000;
|
|
7
|
+
export const MAX_CONFIRMS = 5;
|
|
8
|
+
export const GRACE_MS = 3_000;
|
|
9
|
+
/**
|
|
10
|
+
* Max JSON body the local protocol accepts in one frame.
|
|
11
|
+
* A 1000-row, 120-col 16-color serialize is ~744 KiB, and JSON-escaping that
|
|
12
|
+
* snapshot is 1_365_109 bytes. Truecolor fg+bg per cell is 4_876_998. 8 MiB
|
|
13
|
+
* covers both so adopt can return scrollback; a 500 MiB claimed length still
|
|
14
|
+
* fails the per-frame check.
|
|
15
|
+
*/
|
|
16
|
+
export const MAX_FRAME_SIZE = 8 * 1024 * 1024;
|
|
17
|
+
/** Max undecoded residual AFTER complete frames have been drained. */
|
|
18
|
+
export const MAX_BUFFER_SIZE = MAX_FRAME_SIZE + 4;
|
|
19
|
+
export function encodeFrame(value) {
|
|
20
|
+
const body = Buffer.from(JSON.stringify(value), "utf8");
|
|
21
|
+
if (body.length > MAX_FRAME_SIZE) {
|
|
22
|
+
throw new Error(`frame length ${body.length} exceeds ${MAX_FRAME_SIZE} bytes`);
|
|
23
|
+
}
|
|
24
|
+
const header = Buffer.allocUnsafe(4);
|
|
25
|
+
header.writeUInt32BE(body.length, 0);
|
|
26
|
+
return Buffer.concat([header, body]);
|
|
27
|
+
}
|
|
28
|
+
export class FrameReader {
|
|
29
|
+
buf = Buffer.alloc(0);
|
|
30
|
+
push(chunk) {
|
|
31
|
+
this.buf = Buffer.concat([this.buf, chunk]);
|
|
32
|
+
const out = [];
|
|
33
|
+
while (this.buf.length >= 4) {
|
|
34
|
+
const size = this.buf.readUInt32BE(0);
|
|
35
|
+
if (size > MAX_FRAME_SIZE) {
|
|
36
|
+
this.buf = Buffer.alloc(0);
|
|
37
|
+
throw new Error(`frame length ${size} exceeds ${MAX_FRAME_SIZE} bytes`);
|
|
38
|
+
}
|
|
39
|
+
if (this.buf.length < 4 + size)
|
|
40
|
+
break;
|
|
41
|
+
const body = this.buf.subarray(4, 4 + size);
|
|
42
|
+
this.buf = this.buf.subarray(4 + size);
|
|
43
|
+
out.push(JSON.parse(body.toString("utf8")));
|
|
44
|
+
}
|
|
45
|
+
if (this.buf.length > MAX_BUFFER_SIZE) {
|
|
46
|
+
this.buf = Buffer.alloc(0);
|
|
47
|
+
throw new Error(`frame buffer exceeds ${MAX_BUFFER_SIZE} bytes`);
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function unsupportedTransport(platform = process.platform) {
|
|
53
|
+
return new Error(`custody transport unsupported on ${platform}`);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAChC,MAAM,CAAC,MAAM,YAAY,GA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