car-runtime 0.52.1 → 0.54.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/index.js CHANGED
@@ -35,4 +35,49 @@ try {
35
35
  );
36
36
  }
37
37
 
38
+ const { HostClient, installDaemonWrappers } = require('./daemon-wrappers.js');
39
+ installDaemonWrappers(nativeModule.CarRuntime);
40
+ nativeModule.HostClient = HostClient;
41
+
42
+ // A tool callback throws this class when retrying cannot recover the failure.
43
+ // The wrapper catches the distinguished type before napi-rs flattens rejected
44
+ // Promises to strings, then hands the native bridge a private non-JSON carrier.
45
+ // Ordinary Error/string throws are rethrown unchanged and remain ordinary.
46
+ class TerminalToolError extends Error {
47
+ constructor(message) {
48
+ super(message);
49
+ this.name = 'TerminalToolError';
50
+ }
51
+ }
52
+
53
+ const TERMINAL_TOOL_ERROR_BRIDGE_PREFIX = '\u001ecar-terminal-tool-error:';
54
+
55
+ function terminalAwareToolHandler(handler) {
56
+ return async (...args) => {
57
+ try {
58
+ return await handler(...args);
59
+ } catch (error) {
60
+ if (error instanceof TerminalToolError) {
61
+ return TERMINAL_TOOL_ERROR_BRIDGE_PREFIX + JSON.stringify(error.message);
62
+ }
63
+ throw error;
64
+ }
65
+ };
66
+ }
67
+
68
+ const nativeRegisterToolHandler = nativeModule.registerToolHandler;
69
+ nativeModule.registerToolHandler = (handler) =>
70
+ nativeRegisterToolHandler(terminalAwareToolHandler(handler));
71
+
72
+ const nativeExecuteProposal = nativeModule.executeProposal;
73
+ nativeModule.executeProposal = (runtime, proposalJson, toolFn, sessionId, scopeJson) =>
74
+ nativeExecuteProposal(
75
+ runtime,
76
+ proposalJson,
77
+ terminalAwareToolHandler(toolFn),
78
+ sessionId,
79
+ scopeJson,
80
+ );
81
+
82
+ nativeModule.TerminalToolError = TerminalToolError;
38
83
  module.exports = nativeModule;
package/install.js CHANGED
@@ -145,6 +145,22 @@ async function main() {
145
145
  try {
146
146
  await downloadAsset(name, dest, { executable });
147
147
  } catch (err) {
148
+ // Windows assets are attached to the release AFTER the registry
149
+ // publish: the Windows CI build is the slowest job by over an hour, so
150
+ // the release (and this npm package) no longer waits for it. In that
151
+ // gap a win32 install finds the package on npm but 404s on the asset.
152
+ // Say exactly that, rather than looking like a broken release.
153
+ if (process.platform === 'win32' && /HTTP 404/.test(err.message)) {
154
+ console.error(
155
+ `[car-runtime] The Windows build for v${pkgVersion()} is not ready yet.\n` +
156
+ `This version was just published and its Windows binaries are still\n` +
157
+ `building; they attach to the release when the Windows CI job\n` +
158
+ `finishes (typically within ~3 hours of publish). Re-run the\n` +
159
+ `install then, or install the previous version in the meantime.\n` +
160
+ `(missing asset: ${name})`,
161
+ );
162
+ process.exit(1);
163
+ }
148
164
  console.error(
149
165
  `[car-runtime] ${kind} download failed: ${err.message}\n` +
150
166
  `Place ${name} manually in ${__dirname} or set CAR_RUNTIME_SKIP_DOWNLOAD=1 ` +
package/package.json CHANGED
@@ -1,9 +1,23 @@
1
1
  {
2
2
  "name": "car-runtime",
3
- "version": "0.52.1",
3
+ "version": "0.54.0",
4
4
  "description": "Common Agent Runtime — a deterministic execution layer for AI agents",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./index.d.ts",
10
+ "require": "./index.js",
11
+ "default": "./index.js"
12
+ },
13
+ "./agent-loop": {
14
+ "types": "./agent-loop.d.ts",
15
+ "import": "./agent-loop.mjs",
16
+ "require": "./agent-loop.js",
17
+ "default": "./agent-loop.js"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
7
21
  "bin": {
8
22
  "car-server": "bin/car-server"
9
23
  },
@@ -36,6 +50,10 @@
36
50
  "files": [
37
51
  "index.js",
38
52
  "index.d.ts",
53
+ "daemon-wrappers.js",
54
+ "agent-loop.js",
55
+ "agent-loop.mjs",
56
+ "agent-loop.d.ts",
39
57
  "install.js",
40
58
  "assets.json",
41
59
  "bin/car-server",
@@ -45,7 +63,8 @@
45
63
  ],
46
64
  "scripts": {
47
65
  "install": "node install.js",
48
- "prepack": "node sync-docs.js"
66
+ "prepack": "node sync-docs.js",
67
+ "test": "node --test test/*.test.js"
49
68
  },
50
69
  "license": "SEE LICENSE IN LICENSE",
51
70
  "private": false