@agent-device/proxy 0.21.41 → 0.21.42-nightly.20261121.218
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/errors.mjs +24 -1
- package/dist/process-executable-path.mjs +46 -11
- package/dist/process.mjs +2 -2
- package/package.json +2 -2
package/dist/errors.mjs
CHANGED
|
@@ -107,6 +107,29 @@ function redactUrl(value) {
|
|
|
107
107
|
return null;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
+
/** C0 except newline and tab, DEL, and C1. Newline and tab are layout; every other one is escaped. */
|
|
111
|
+
function isEscapedControl(code) {
|
|
112
|
+
return code < 32 && code !== 10 && code !== 9 || code >= 127 && code <= 159;
|
|
113
|
+
}
|
|
114
|
+
/** Replaces each character `escape` matches with its `render`ing, returning the input itself when none does. */
|
|
115
|
+
function replaceCodes(text, escape, render) {
|
|
116
|
+
let out = "";
|
|
117
|
+
let start = 0;
|
|
118
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
119
|
+
const code = text.charCodeAt(index);
|
|
120
|
+
if (!escape(code)) continue;
|
|
121
|
+
out += text.slice(start, index) + render(code);
|
|
122
|
+
start = index + 1;
|
|
123
|
+
}
|
|
124
|
+
return start === 0 ? text : out + text.slice(start);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Text with C0 (except newline and tab), DEL and C1 characters shown as `\u00NN`. That is a JSON string escape too, so
|
|
128
|
+
* JSON text written through it still parses to the exact values. Text with nothing to escape is returned as is.
|
|
129
|
+
*/
|
|
130
|
+
function escapeTerminalText(text) {
|
|
131
|
+
return replaceCodes(text, isEscapedControl, (code) => `\\u${code.toString(16).padStart(4, "0")}`);
|
|
132
|
+
}
|
|
110
133
|
//#endregion
|
|
111
134
|
//#region ../kernel/src/errors.ts
|
|
112
135
|
/**
|
|
@@ -328,4 +351,4 @@ function codeRecoveryHint(code) {
|
|
|
328
351
|
}
|
|
329
352
|
}
|
|
330
353
|
//#endregion
|
|
331
|
-
export { redactDiagnosticData as i, createRequestCanceledError as n, normalizeError as r, AppError as t };
|
|
354
|
+
export { redactDiagnosticData as a, escapeTerminalText as i, createRequestCanceledError as n, normalizeError as r, AppError as t };
|
|
@@ -1,7 +1,49 @@
|
|
|
1
1
|
import { hostPlatform, n as runCmd, r as withoutCommandExecutorOverride, uniquePositivePids } from "./process.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { readlink } from "node:fs/promises";
|
|
4
|
-
|
|
4
|
+
//#region ../host-kit/src/settle-within.ts
|
|
5
|
+
/**
|
|
6
|
+
* Settles `work` within `timeoutMs` and reports which happened: `{ kind: 'settled', value }` when
|
|
7
|
+
* the work finished first, `{ kind: 'deadline' }` when the budget elapsed first. The deadline
|
|
8
|
+
* timer is cleared on every path, so it never outlives this call. This does not cancel the work:
|
|
9
|
+
* when the deadline wins, `work` keeps running to its own end and a rejection arriving after the
|
|
10
|
+
* deadline is swallowed here — the outcome is already `{ kind: 'deadline' }`, and the rejection
|
|
11
|
+
* stays observed, so it never reaches the unhandled-rejection path. A rejection that beats the
|
|
12
|
+
* deadline propagates to the caller. With a spent (zero) budget the deadline is already eligible
|
|
13
|
+
* to win before the work's first continuation runs, so a caller that must see the work's own
|
|
14
|
+
* failure, even at budget zero, has to await the work, not this wrapper.
|
|
15
|
+
*
|
|
16
|
+
* With `options.keepAlive: false` the deadline timer is also unref'd, so a deadline awaited by a
|
|
17
|
+
* background sweep does not hold the event loop open while it waits (a hung sweep must not keep a
|
|
18
|
+
* process with no other ref'd handles alive until the budget elapses). The default keeps the
|
|
19
|
+
* timer ref'd, for shutdown callers where an unref'd timer could let the process exit mid-report.
|
|
20
|
+
*/
|
|
21
|
+
function settleWithin(work, timeoutMs, options) {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
let settled = false;
|
|
24
|
+
const timer = setTimeout(() => {
|
|
25
|
+
if (settled) return;
|
|
26
|
+
settled = true;
|
|
27
|
+
resolve({ kind: "deadline" });
|
|
28
|
+
}, Math.max(0, timeoutMs));
|
|
29
|
+
if (options?.keepAlive === false) timer.unref?.();
|
|
30
|
+
Promise.resolve().then(work).then((value) => {
|
|
31
|
+
if (settled) return;
|
|
32
|
+
settled = true;
|
|
33
|
+
clearTimeout(timer);
|
|
34
|
+
resolve({
|
|
35
|
+
kind: "settled",
|
|
36
|
+
value
|
|
37
|
+
});
|
|
38
|
+
}, (error) => {
|
|
39
|
+
if (settled) return;
|
|
40
|
+
settled = true;
|
|
41
|
+
clearTimeout(timer);
|
|
42
|
+
reject(error);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
5
47
|
//#region ../host-kit/src/internal/process-executable-path.ts
|
|
6
48
|
const DEFAULT_TIMEOUT_MS = 1e3;
|
|
7
49
|
const WINDOWS_TIMEOUT_FLOOR_MS = 2e3;
|
|
@@ -44,16 +86,9 @@ async function readLinuxPaths(pids, timeoutMs) {
|
|
|
44
86
|
return;
|
|
45
87
|
}
|
|
46
88
|
}));
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const timer = setTimeout(resolve, timeoutMs);
|
|
51
|
-
cancelTimeout = () => clearTimeout(timer);
|
|
52
|
-
})]);
|
|
53
|
-
return new Map(rows?.filter((row) => row !== void 0) ?? []);
|
|
54
|
-
} finally {
|
|
55
|
-
cancelTimeout();
|
|
56
|
-
}
|
|
89
|
+
const outcome = await settleWithin(() => observations, timeoutMs);
|
|
90
|
+
const rows = outcome.kind === "settled" ? outcome.value : [];
|
|
91
|
+
return new Map(rows.filter((row) => row !== void 0));
|
|
57
92
|
}
|
|
58
93
|
function darwinArgs(pids) {
|
|
59
94
|
return [
|
package/dist/process.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as redactDiagnosticData, i as escapeTerminalText, n as createRequestCanceledError, t as AppError } from "./errors.mjs";
|
|
2
2
|
import crypto, { randomUUID } from "node:crypto";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -97,7 +97,7 @@ function emitDiagnostic(event) {
|
|
|
97
97
|
scope.liveWrittenEventCount = scope.events.length;
|
|
98
98
|
}
|
|
99
99
|
if (scope.traceLogPath) appendDiagnosticLine(scope, scope.traceLogPath, fileLine);
|
|
100
|
-
if (scope.debug && !scope.logPath && !scope.traceLogPath) process.stderr.write(`${DIAGNOSTIC_STDERR_PREFIX}${fileLine}`);
|
|
100
|
+
if (scope.debug && !scope.logPath && !scope.traceLogPath) process.stderr.write(`${DIAGNOSTIC_STDERR_PREFIX}${escapeTerminalText(fileLine)}`);
|
|
101
101
|
} catch {}
|
|
102
102
|
}
|
|
103
103
|
function flushDiagnosticsToSessionFile(options = {}) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-device/proxy",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.42-nightly.20261121.218",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Transport-neutral authenticating proxy in front of an agent-device daemon.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@agent-device/host-kit": "0.0.0",
|
|
29
28
|
"@agent-device/contracts": "0.0.0",
|
|
29
|
+
"@agent-device/host-kit": "0.0.0",
|
|
30
30
|
"@agent-device/kernel": "0.0.0"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|