@myagentroam/node 0.13.10 → 0.13.11
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/marctl/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"0.13.
|
|
1
|
+
{"type":"module","version":"0.13.11"}
|
|
@@ -2,14 +2,30 @@ const MAX_RUNNER_ERROR_MESSAGE = 1000;
|
|
|
2
2
|
const MAX_RUNNER_ERROR_CODE = 80;
|
|
3
3
|
export function runnerErrorProjection(error, fallbackCode) {
|
|
4
4
|
const httpStatus = findHttpStatus(error);
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const publicError = findPublicError(error);
|
|
6
|
+
const providerCode = publicError?.code ?? findCode(error);
|
|
7
|
+
const message = publicError?.message ?? findMessage(error) ?? fallbackCode;
|
|
7
8
|
return {
|
|
8
9
|
code: providerCode ?? (httpStatus === null ? fallbackCode : `HTTP_${httpStatus}`),
|
|
9
10
|
message: message.slice(0, MAX_RUNNER_ERROR_MESSAGE),
|
|
10
11
|
httpStatus
|
|
11
12
|
};
|
|
12
13
|
}
|
|
14
|
+
function findPublicError(value, depth = 0) {
|
|
15
|
+
if (depth > 3 || value === null || typeof value !== 'object')
|
|
16
|
+
return undefined;
|
|
17
|
+
const record = value;
|
|
18
|
+
const code = normalizeCode(record.code);
|
|
19
|
+
const message = record.publicMessage;
|
|
20
|
+
if (code !== undefined && typeof message === 'string' && message.trim())
|
|
21
|
+
return { code, message: message.trim() };
|
|
22
|
+
for (const key of ['error', 'data', 'response', 'cause']) {
|
|
23
|
+
const nested = findPublicError(record[key], depth + 1);
|
|
24
|
+
if (nested !== undefined)
|
|
25
|
+
return nested;
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
13
29
|
function findCode(value, depth = 0) {
|
|
14
30
|
if (depth > 3 || value === null || typeof value !== 'object')
|
|
15
31
|
return undefined;
|
|
@@ -20,14 +36,19 @@ function findCode(value, depth = 0) {
|
|
|
20
36
|
return nested;
|
|
21
37
|
}
|
|
22
38
|
for (const key of ['code', 'errorCode', 'error_code']) {
|
|
23
|
-
const candidate = record[key];
|
|
24
|
-
if (
|
|
25
|
-
return
|
|
26
|
-
if (typeof candidate === 'number' && Number.isFinite(candidate))
|
|
27
|
-
return String(candidate);
|
|
39
|
+
const candidate = normalizeCode(record[key]);
|
|
40
|
+
if (candidate !== undefined)
|
|
41
|
+
return candidate;
|
|
28
42
|
}
|
|
29
43
|
return undefined;
|
|
30
44
|
}
|
|
45
|
+
function normalizeCode(candidate) {
|
|
46
|
+
if (typeof candidate === 'string' && candidate.trim())
|
|
47
|
+
return [...candidate.trim()].slice(0, MAX_RUNNER_ERROR_CODE).join('');
|
|
48
|
+
if (typeof candidate === 'number' && Number.isFinite(candidate))
|
|
49
|
+
return String(candidate);
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
31
52
|
function findHttpStatus(value, depth = 0) {
|
|
32
53
|
if (depth > 3 || value === null || typeof value !== 'object')
|
|
33
54
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myagentroam/node",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.11",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/myagentroam/mar.git",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"turndown-plugin-gfm": "^1.0.2",
|
|
50
50
|
"ws": "^8.21.3",
|
|
51
51
|
"zod": "4.4.3",
|
|
52
|
-
"@myagentroam/
|
|
53
|
-
"@myagentroam/
|
|
52
|
+
"@myagentroam/agent": "0.13.11",
|
|
53
|
+
"@myagentroam/protocol": "0.13.11"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/turndown": "^5.0.6",
|
|
57
57
|
"@types/ws": "^8.18.1",
|
|
58
|
-
"@myagentroam/marctl": "0.13.
|
|
58
|
+
"@myagentroam/marctl": "0.13.11",
|
|
59
59
|
"@myagentroam/code-navigation": "0.11.1"
|
|
60
60
|
},
|
|
61
61
|
"exports": {
|