@gajae-code/agent-core 0.15.6 → 0.16.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/CHANGELOG.md +2 -0
- package/package.json +4 -4
- package/src/agent.ts +26 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@gajae-code/agent-core",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.16.0",
|
|
5
5
|
"description": "General-purpose agent with transport abstraction, state management, and attachment support",
|
|
6
6
|
"homepage": "https://gajae-code.com",
|
|
7
7
|
"author": "Yeachan-Heo and Gajae Code Contributors",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"fmt": "biome format --write ."
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@gajae-code/ai": "0.
|
|
36
|
-
"@gajae-code/natives": "0.
|
|
37
|
-
"@gajae-code/utils": "0.
|
|
35
|
+
"@gajae-code/ai": "0.16.0",
|
|
36
|
+
"@gajae-code/natives": "0.16.0",
|
|
37
|
+
"@gajae-code/utils": "0.16.0",
|
|
38
38
|
"@opentelemetry/api": "^1.9.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
package/src/agent.ts
CHANGED
|
@@ -117,6 +117,27 @@ function sanitizeAgentFailure(error: unknown, runtimeClassifiedCode?: string): {
|
|
|
117
117
|
return { code, message: "Agent run failed." };
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
/** Only runtime-authenticated built-in constructors may contribute a name. */
|
|
121
|
+
const TRUSTED_ERROR_CONSTRUCTORS = new Map<Function, string>([
|
|
122
|
+
[Error, "Error"],
|
|
123
|
+
[TypeError, "TypeError"],
|
|
124
|
+
[RangeError, "RangeError"],
|
|
125
|
+
[SyntaxError, "SyntaxError"],
|
|
126
|
+
[ReferenceError, "ReferenceError"],
|
|
127
|
+
[URIError, "URIError"],
|
|
128
|
+
[EvalError, "EvalError"],
|
|
129
|
+
[AggregateError, "AggregateError"],
|
|
130
|
+
]);
|
|
131
|
+
|
|
132
|
+
function safeErrorName(error: unknown): string | undefined {
|
|
133
|
+
try {
|
|
134
|
+
if (!(error instanceof Error)) return undefined;
|
|
135
|
+
return TRUSTED_ERROR_CONSTRUCTORS.get(error.constructor);
|
|
136
|
+
} catch {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
120
141
|
/** Guarded HTTP-status extraction for untrusted provider errors: a throwing
|
|
121
142
|
* getter must never escape the failure handler and suppress terminalization
|
|
122
143
|
* (exact-head review P1). */
|
|
@@ -2128,6 +2149,8 @@ export class Agent {
|
|
|
2128
2149
|
const runtimeFailureCode = abortController.signal.aborted
|
|
2129
2150
|
? "aborted"
|
|
2130
2151
|
: (managedLocalErrorDiagnostic(err)?.errorKind ?? providerCode);
|
|
2152
|
+
const sanitized = sanitizeAgentFailure(err, runtimeFailureCode);
|
|
2153
|
+
const errorName = safeErrorName(err);
|
|
2131
2154
|
|
|
2132
2155
|
const errorMsg: AgentMessage = {
|
|
2133
2156
|
role: "assistant",
|
|
@@ -2144,7 +2167,9 @@ export class Agent {
|
|
|
2144
2167
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
2145
2168
|
},
|
|
2146
2169
|
stopReason: abortController.signal.aborted ? "aborted" : "error",
|
|
2147
|
-
errorMessage:
|
|
2170
|
+
errorMessage: sanitized.message,
|
|
2171
|
+
errorCode: sanitized.code,
|
|
2172
|
+
...(errorName ? { errorName } : {}),
|
|
2148
2173
|
errorStatus: safeErrorStatus(err),
|
|
2149
2174
|
// Local-diagnostic authority (`errorKind` + structured
|
|
2150
2175
|
// `bufferOverflow`) comes from ONE identity check: a foreign error
|