@agent-native/core 0.58.2 → 0.58.3
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/agent/engine/translate-ai-sdk.d.ts.map +1 -1
- package/dist/agent/engine/translate-ai-sdk.js +1 -0
- package/dist/agent/engine/translate-ai-sdk.js.map +1 -1
- package/dist/agent/production-agent.d.ts +2 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +88 -7
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/tool-error-redaction.d.ts +4 -0
- package/dist/agent/tool-error-redaction.d.ts.map +1 -0
- package/dist/agent/tool-error-redaction.js +43 -0
- package/dist/agent/tool-error-redaction.js.map +1 -0
- package/dist/agent/types.d.ts +23 -6
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/scripts/db/tool-schemas.d.ts +3 -0
- package/dist/scripts/db/tool-schemas.d.ts.map +1 -0
- package/dist/scripts/db/tool-schemas.js +27 -0
- package/dist/scripts/db/tool-schemas.js.map +1 -0
- package/dist/scripts/dev/index.d.ts.map +1 -1
- package/dist/scripts/dev/index.js +2 -22
- package/dist/scripts/dev/index.js.map +1 -1
- package/dist/scripts/parse-args.js +1 -1
- package/dist/scripts/parse-args.js.map +1 -1
- package/dist/scripts/runner.js +1 -1
- package/dist/scripts/runner.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +2 -22
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/cli-capture.d.ts.map +1 -1
- package/dist/server/cli-capture.js +2 -1
- package/dist/server/cli-capture.js.map +1 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-capture.d.ts","sourceRoot":"","sources":["../../src/server/cli-capture.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-capture.d.ts","sourceRoot":"","sources":["../../src/server/cli-capture.ts"],"names":[],"mappings":"AAyBA,gEAAgE;AAChE,qBAAa,eAAgB,SAAQ,KAAK;IACxC,IAAI,EAAE,MAAM,CAAC;gBACD,IAAI,EAAE,MAAM;CAIzB;AA0DD,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,EAAE,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EAC1B,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAiBjB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAGpD"}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* idempotent and safe under any number of concurrent runs.
|
|
16
16
|
*/
|
|
17
17
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
18
|
+
import { sanitizeToolErrorText } from "../agent/tool-error-redaction.js";
|
|
18
19
|
const captureStore = new AsyncLocalStorage();
|
|
19
20
|
/** Sentinel thrown when an action calls `process.exit(...)`. */
|
|
20
21
|
export class ExitIntercepted extends Error {
|
|
@@ -99,7 +100,7 @@ export async function captureCliOutput(fn, options = {}) {
|
|
|
99
100
|
}
|
|
100
101
|
else if (swallowErrors) {
|
|
101
102
|
const msg = err?.message ?? String(err);
|
|
102
|
-
store.logs.push(`Error: ${msg}`);
|
|
103
|
+
store.logs.push(sanitizeToolErrorText(`Error: ${msg}`));
|
|
103
104
|
}
|
|
104
105
|
else {
|
|
105
106
|
throw err;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-capture.js","sourceRoot":"","sources":["../../src/server/cli-capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-capture.js","sourceRoot":"","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AAK;QAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC","sourcesContent":["/**\n * Capture stdout/stderr/console output from CLI-style action handlers\n * without globally swapping `console.log` / `process.stdout.write` /\n * `process.exit` per-call.\n *\n * The previous pattern (save → swap → restore in finally) corrupts the\n * globals when two CLI tool calls run concurrently — request B saves the\n * already-swapped function, then both finally-blocks restore in interleaved\n * order, leaving an arbitrary capture function permanently installed and\n * silently swallowing all subsequent server logs.\n *\n * This module installs the global interceptors ONCE at module load. Each\n * call dispatches to either the captured logs (when an AsyncLocalStorage\n * store is active) or the original implementation. The wrappers are\n * idempotent and safe under any number of concurrent runs.\n */\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { sanitizeToolErrorText } from \"../agent/tool-error-redaction.js\";\n\ninterface CaptureStore {\n logs: string[];\n}\n\nconst captureStore = new AsyncLocalStorage<CaptureStore>();\n\n/** Sentinel thrown when an action calls `process.exit(...)`. */\nexport class ExitIntercepted extends Error {\n code: number;\n constructor(code: number) {\n super(`process.exit(${code})`);\n this.code = code;\n }\n}\n\nlet installed = false;\n\nfunction installInterceptorsOnce(): void {\n if (installed) return;\n installed = true;\n\n const origLog = console.log.bind(console);\n const origError = console.error.bind(console);\n const origStdoutWrite = process.stdout.write.bind(process.stdout);\n const origExit = process.exit.bind(process);\n\n console.log = (...args: unknown[]): void => {\n const store = captureStore.getStore();\n if (store) {\n store.logs.push(args.map((a) => String(a)).join(\" \"));\n return;\n }\n origLog(...(args as []));\n };\n\n console.error = (...args: unknown[]): void => {\n const store = captureStore.getStore();\n if (store) {\n store.logs.push(args.map((a) => String(a)).join(\" \"));\n return;\n }\n origError(...(args as []));\n };\n\n // process.stdout.write has a complex signature (string | Uint8Array, encoding?, callback?)\n // We only need to capture chunks; preserve return value semantics by returning true.\n process.stdout.write = ((chunk: any, ...rest: any[]) => {\n const store = captureStore.getStore();\n if (store) {\n if (typeof chunk === \"string\") {\n store.logs.push(chunk);\n } else if (chunk && typeof (chunk as Buffer).toString === \"function\") {\n store.logs.push((chunk as Buffer).toString());\n }\n // Honor the optional callback that streams expect.\n const cb = rest.find((r) => typeof r === \"function\");\n if (cb) (cb as (err?: Error | null) => void)(null);\n return true;\n }\n return origStdoutWrite(chunk, ...rest);\n }) as typeof process.stdout.write;\n\n process.exit = ((code?: number) => {\n const store = captureStore.getStore();\n if (store) {\n throw new ExitIntercepted(code ?? 0);\n }\n return origExit(code);\n }) as typeof process.exit;\n}\n\nexport interface CaptureCliOptions {\n /**\n * If `true` (default), errors thrown by `fn` (other than\n * `ExitIntercepted`) are appended to the capture buffer as `\"Error: ...\"`\n * and the resolved logs are returned. If `false`, errors propagate.\n */\n swallowErrors?: boolean;\n}\n\n/**\n * Run `fn` with a fresh capture buffer. All console.log / console.error /\n * process.stdout.write calls inside `fn` (including async descendants)\n * append to the buffer instead of going to the server's stdout/stderr.\n * Returns the joined logs (or `\"(no output)\"` if nothing was captured).\n *\n * `process.exit(code)` inside `fn` throws `ExitIntercepted` internally; it\n * is caught here so the captured output (including any final logs the\n * action wrote before exiting) is preserved.\n */\nexport async function captureCliOutput(\n fn: () => Promise<unknown>,\n options: CaptureCliOptions = {},\n): Promise<string> {\n installInterceptorsOnce();\n const store: CaptureStore = { logs: [] };\n const swallowErrors = options.swallowErrors !== false;\n try {\n await captureStore.run(store, fn);\n } catch (err) {\n if (err instanceof ExitIntercepted) {\n // process.exit() is treated as a clean termination of the CLI action.\n } else if (swallowErrors) {\n const msg = (err as Error)?.message ?? String(err);\n store.logs.push(sanitizeToolErrorText(`Error: ${msg}`));\n } else {\n throw err;\n }\n }\n return store.logs.join(\"\\n\") || \"(no output)\";\n}\n\n/**\n * Append a string to the active capture buffer. No-op outside of a\n * `captureCliOutput` scope — used by callers that catch errors from\n * `fn` themselves and want to emit the message into the captured logs.\n */\nexport function appendCapturedLog(text: string): void {\n const store = captureStore.getStore();\n if (store) store.logs.push(text);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.58.
|
|
3
|
+
"version": "0.58.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22"
|
|
@@ -202,6 +202,7 @@
|
|
|
202
202
|
"@tiptap/starter-kit": "^3.26.0",
|
|
203
203
|
"@tiptap/y-tiptap": "^3.0.4",
|
|
204
204
|
"@uiw/react-codemirror": "^4.25.10",
|
|
205
|
+
"ajv": "^8.20.0",
|
|
205
206
|
"better-auth": "1.6.16",
|
|
206
207
|
"better-sqlite3": "^12.8.0",
|
|
207
208
|
"clsx": "^2.1.1",
|