@ai-ecoverse/slicc-kernel 1.179.0 → 1.181.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/README.md +41 -2
- package/dist/driver-worker.js +67 -1
- package/dist/driver-worker.js.map +2 -2
- package/dist/index.js +78 -1
- package/dist/index.js.map +3 -3
- package/dist/kernel-worker.js +553 -93
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-driver-worker.js +67 -1
- package/dist/node-driver-worker.js.map +2 -2
- package/dist/node-process-worker.cjs +1 -1
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +619 -90
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +1 -1
- package/dist/types/client/attach.d.ts +27 -3
- package/dist/types/client/protocol.d.ts +29 -4
- package/dist/types/index.d.ts +5 -3
- package/dist/types/kernel/children.d.ts +2 -1
- package/dist/types/kernel/jobs.d.ts +2 -1
- package/dist/types/kernel/trace.d.ts +59 -0
- package/dist/types/launcher.d.ts +31 -0
- package/dist/types/node.d.ts +5 -3
- package/dist/types/serve.d.ts +11 -1
- package/dist/types/sudo.d.ts +15 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1958,7 +1958,7 @@ var RemoteTransport = class {
|
|
|
1958
1958
|
};
|
|
1959
1959
|
|
|
1960
1960
|
// src/client/protocol.ts
|
|
1961
|
-
var PROTOCOL = [1,
|
|
1961
|
+
var PROTOCOL = [1, 16];
|
|
1962
1962
|
function locksOf(scope = globalThis) {
|
|
1963
1963
|
const locks = scope.navigator?.locks;
|
|
1964
1964
|
return typeof locks?.request === "function" ? locks : void 0;
|
|
@@ -2023,6 +2023,7 @@ var Channel = class {
|
|
|
2023
2023
|
failure;
|
|
2024
2024
|
pending = /* @__PURE__ */ new Map();
|
|
2025
2025
|
watching = /* @__PURE__ */ new Map();
|
|
2026
|
+
tracing = /* @__PURE__ */ new Map();
|
|
2026
2027
|
cdpHooks = /* @__PURE__ */ new Map();
|
|
2027
2028
|
cdpOpen = /* @__PURE__ */ new Set();
|
|
2028
2029
|
facadeHooks = /* @__PURE__ */ new Map();
|
|
@@ -2090,6 +2091,10 @@ var Channel = class {
|
|
|
2090
2091
|
this.watching.get(data.watch)?.(data.change);
|
|
2091
2092
|
return;
|
|
2092
2093
|
}
|
|
2094
|
+
if (data.trace !== void 0 && data.id === void 0) {
|
|
2095
|
+
this.traced(data.trace, data.events ?? [], data.dropped ?? 0);
|
|
2096
|
+
return;
|
|
2097
|
+
}
|
|
2093
2098
|
if (data.bye !== void 0) {
|
|
2094
2099
|
this.end(new KernelGoneError(data.bye));
|
|
2095
2100
|
return;
|
|
@@ -2118,6 +2123,23 @@ var Channel = class {
|
|
|
2118
2123
|
if (reply.error !== void 0) call.reject(new KernelCallError(reply.error, reply.code));
|
|
2119
2124
|
else call.resolve(reply.result);
|
|
2120
2125
|
}
|
|
2126
|
+
traced(trace, events, dropped) {
|
|
2127
|
+
const listener = this.tracing.get(trace);
|
|
2128
|
+
if (!listener) return;
|
|
2129
|
+
const ack = () => {
|
|
2130
|
+
if (this.tracing.has(trace)) this.post({ traceAck: trace });
|
|
2131
|
+
};
|
|
2132
|
+
let consumed;
|
|
2133
|
+
try {
|
|
2134
|
+
consumed = listener({ events, dropped });
|
|
2135
|
+
} finally {
|
|
2136
|
+
if (typeof consumed?.then === "function") {
|
|
2137
|
+
void Promise.resolve(consumed).then(ack, ack);
|
|
2138
|
+
} else {
|
|
2139
|
+
ack();
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2121
2143
|
openCdp({ cdpOpen: { registration, ...request }, port }) {
|
|
2122
2144
|
const hook = registration === void 0 ? void 0 : this.cdpHooks.get(registration);
|
|
2123
2145
|
if (!hook || this.failure) {
|
|
@@ -2180,6 +2202,29 @@ async function serveCdpOn(channel, hook, options) {
|
|
|
2180
2202
|
}
|
|
2181
2203
|
};
|
|
2182
2204
|
}
|
|
2205
|
+
async function traceOn(channel, tag, onEvents, options) {
|
|
2206
|
+
if (typeof onEvents !== "function") throw new TypeError("trace: onEvents must be a function");
|
|
2207
|
+
await since(channel, 15, "trace", async () => {
|
|
2208
|
+
});
|
|
2209
|
+
const { id, done } = channel.request({
|
|
2210
|
+
op: "trace",
|
|
2211
|
+
tag,
|
|
2212
|
+
...options.limit !== void 0 ? { limit: options.limit } : {}
|
|
2213
|
+
});
|
|
2214
|
+
channel.tracing.set(id, onEvents);
|
|
2215
|
+
try {
|
|
2216
|
+
await done;
|
|
2217
|
+
} catch (error) {
|
|
2218
|
+
channel.tracing.delete(id);
|
|
2219
|
+
throw error;
|
|
2220
|
+
}
|
|
2221
|
+
return {
|
|
2222
|
+
close: () => {
|
|
2223
|
+
if (!channel.tracing.delete(id)) return;
|
|
2224
|
+
void channel.call({ op: "untrace", trace: id }).catch(() => void 0);
|
|
2225
|
+
}
|
|
2226
|
+
};
|
|
2227
|
+
}
|
|
2183
2228
|
async function dialOn(channel, { port, host }) {
|
|
2184
2229
|
const req = { op: "dial", port, ...host ? { host } : {} };
|
|
2185
2230
|
return dialStream(await since(channel, 4, "dial", () => channel.call(req)));
|
|
@@ -2193,6 +2238,8 @@ async function spawnOn(channel, argv, opts) {
|
|
|
2193
2238
|
});
|
|
2194
2239
|
if (opts.tag !== void 0) await since(channel, 12, "a tag per spawn", async () => {
|
|
2195
2240
|
});
|
|
2241
|
+
if (Array.isArray(opts.tag)) await since(channel, 15, "several tags per spawn", async () => {
|
|
2242
|
+
});
|
|
2196
2243
|
if (opts.cwdMissing === "error") await since(channel, 14, "cwdMissing: 'error'", async () => {
|
|
2197
2244
|
});
|
|
2198
2245
|
const started = Promise.withResolvers();
|
|
@@ -2217,6 +2264,19 @@ async function spawnOn(channel, argv, opts) {
|
|
|
2217
2264
|
signal: async (name = "SIGTERM") => void await channel.call({ op: "kill", pid: -pgid, signal: name })
|
|
2218
2265
|
};
|
|
2219
2266
|
}
|
|
2267
|
+
async function sudoRunOn(channel, replay, { stdout, stderr, tag }) {
|
|
2268
|
+
await since(channel, 16, "sudoRun", async () => {
|
|
2269
|
+
});
|
|
2270
|
+
const started = Promise.withResolvers();
|
|
2271
|
+
let endedBy;
|
|
2272
|
+
const { done } = channel.request(
|
|
2273
|
+
{ op: "sudo-run", replay, options: { stdout, stderr, tag } },
|
|
2274
|
+
{ started: started.resolve, ended: (signal) => endedBy = signal }
|
|
2275
|
+
);
|
|
2276
|
+
done.catch(started.reject);
|
|
2277
|
+
const pid = await started.promise;
|
|
2278
|
+
return { pid, pgid: pid, ended: endedOf(done, () => endedBy) };
|
|
2279
|
+
}
|
|
2220
2280
|
function endedOf(done, signal) {
|
|
2221
2281
|
return quiet(
|
|
2222
2282
|
done.then((status) => {
|
|
@@ -2254,6 +2314,10 @@ async function terminalOn(channel, argv, opts) {
|
|
|
2254
2314
|
});
|
|
2255
2315
|
if (opts.tag !== void 0) await since(channel, 12, "a tag per terminal", async () => {
|
|
2256
2316
|
});
|
|
2317
|
+
if (Array.isArray(opts.tag)) {
|
|
2318
|
+
await since(channel, 15, "several tags per terminal", async () => {
|
|
2319
|
+
});
|
|
2320
|
+
}
|
|
2257
2321
|
if (opts.cwdMissing === "error") await since(channel, 14, "cwdMissing: 'error'", async () => {
|
|
2258
2322
|
});
|
|
2259
2323
|
let listener = onData ?? null;
|
|
@@ -2413,6 +2477,8 @@ async function attachKernel(port, options = {}) {
|
|
|
2413
2477
|
channel.traitsListeners.add(listener);
|
|
2414
2478
|
return () => channel.traitsListeners.delete(listener);
|
|
2415
2479
|
},
|
|
2480
|
+
trace: (tag, onEvents, options2 = {}) => traceOn(channel, tag, onEvents, options2),
|
|
2481
|
+
sudoRun: (replay, options2 = {}) => sudoRunOn(channel, replay, options2),
|
|
2416
2482
|
async close(o = {}) {
|
|
2417
2483
|
if (channel.failure) return;
|
|
2418
2484
|
await channel.call({ op: "detach", ...o.kill ? { kill: true } : {} }).catch(() => void 0);
|
|
@@ -2801,6 +2867,16 @@ function decodedRun(result) {
|
|
|
2801
2867
|
stderr: decoder2.decode(result.stderr)
|
|
2802
2868
|
};
|
|
2803
2869
|
}
|
|
2870
|
+
async function sudoRunOn2(request, replay, { stdout, stderr, tag }) {
|
|
2871
|
+
const started = Promise.withResolvers();
|
|
2872
|
+
const { done } = request(
|
|
2873
|
+
{ op: "sudo-run", replay, options: { stdout, stderr, tag } },
|
|
2874
|
+
{ started: started.resolve }
|
|
2875
|
+
);
|
|
2876
|
+
done.catch(started.reject);
|
|
2877
|
+
const pid = await started.promise;
|
|
2878
|
+
return { pid, pgid: pid, ended: quiet(done.then(endedOf2)) };
|
|
2879
|
+
}
|
|
2804
2880
|
function endedOf2(r) {
|
|
2805
2881
|
if (typeof r === "number") return { status: r };
|
|
2806
2882
|
const { status, signal } = r;
|
|
@@ -2966,6 +3042,7 @@ async function createKernel(options = {}) {
|
|
|
2966
3042
|
return decodedRun(result);
|
|
2967
3043
|
},
|
|
2968
3044
|
openTerminal,
|
|
3045
|
+
sudoRun: (replay, sudoOptions = {}) => sudoRunOn2(request, replay, sudoOptions),
|
|
2969
3046
|
connect: connector(call, bound),
|
|
2970
3047
|
...accounts(call, options.users === void 0 ? DEFAULT_USERS : options.users),
|
|
2971
3048
|
setRoutes: async (routes) => void await call({ op: "routes", routes }),
|