car-runtime 0.26.0 → 0.27.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.
Files changed (2) hide show
  1. package/index.d.ts +56 -2
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -49,6 +49,19 @@ export class CarRuntime {
49
49
  */
50
50
  loadMemory(path: string): Promise<number>;
51
51
 
52
+ /**
53
+ * Stream one delta of a chat turn back to the daemon as an
54
+ * `agent.chat.event` notification (the agent-chat surface). Called from an
55
+ * `agent.chat` handler (see `registerChatHandler`) to emit the reply
56
+ * incrementally; the daemon rewrites each event to `agents.chat.event` for
57
+ * the host that issued `agents.chat`, keyed by `sessionId`.
58
+ *
59
+ * `kind` is one of `token` | `tool_call` | `done` | `error`. `delta` carries
60
+ * the text for `token` (and the final text/status for `done`/`error`); omit
61
+ * it for a bare signal.
62
+ */
63
+ chatEvent(sessionId: string, kind: string, delta?: string | undefined | null): Promise<void>;
64
+
52
65
  /**
53
66
  * Persist memory graph to a JSON file (backward-compatible flat format).
54
67
  * Returns the number of records written.
@@ -674,7 +687,7 @@ export class CarRuntime {
674
687
  * why a model won and what the alternatives cost in reliability terms. Empty
675
688
  * on explicit-model and cold-start paths where no ranking occurred.
676
689
  */
677
- routeModel(prompt: string): Promise<string>;
690
+ routeModel(prompt: string, intentJson?: string | null): Promise<string>;
678
691
 
679
692
  /** Per-model performance profiles. Returns JSON. */
680
693
  modelStats(): Promise<string>;
@@ -1182,6 +1195,32 @@ export function registerVoiceEventHandler(
1182
1195
  onEvent: (sessionId: string, eventJson: string) => void,
1183
1196
  ): void;
1184
1197
 
1198
+ /**
1199
+ * Register the JS handler that serves daemon-initiated `agent.chat`
1200
+ * reverse-calls — the agent-chat surface. A supervised agent (running in
1201
+ * `--serve` mode, attached via `session.auth`) calls this once; the daemon
1202
+ * reverse-calls `agent.chat` for every host `agents.chat`, the bridge acks
1203
+ * `{accepted:true}` immediately, and fires this handler.
1204
+ *
1205
+ * `handlerFn(paramsJson)` receives `{"session_id":"...","prompt":"...",
1206
+ * "attachments":[...]?,"context":{...}?}` as a JSON string. Run one
1207
+ * conversational turn — keep a per-`session_id` message thread, run the
1208
+ * agent loop, and stream the reply back via `CarRuntime.chatEvent` — then
1209
+ * return. It is fire-and-forget (the ack already went back), so a rejected
1210
+ * Promise is logged, not surfaced to the host. Process-wide setter,
1211
+ * symmetric to `registerVoiceEventHandler`; pair with
1212
+ * `unregisterChatHandler` to clear.
1213
+ */
1214
+ export function registerChatHandler(
1215
+ handlerFn: (paramsJson: string) => void,
1216
+ ): void;
1217
+
1218
+ /**
1219
+ * Clear the registered `agent.chat` handler. Subsequent reverse-calls are
1220
+ * refused so the daemon learns this agent is no longer conversational.
1221
+ */
1222
+ export function unregisterChatHandler(): void;
1223
+
1185
1224
  /**
1186
1225
  * Register the JS `tools.execute` handler for `submitProposal`
1187
1226
  * (Parslee-ai/car-releases#38). When the daemon dispatches a
@@ -2301,12 +2340,26 @@ export function agentsHealthExternal(
2301
2340
  * "allowed_tools"?: string[], // tool allowlist; [] denies all
2302
2341
  * "max_turns"?: number, // turn cap
2303
2342
  * "timeout_secs"?: number, // hard deadline (default 300s)
2304
- * "mcp_endpoint"?: string // MCP server URL passed via
2343
+ * "mcp_endpoint"?: string, // MCP server URL passed via
2305
2344
  * // --mcp-config; daemon callers
2306
2345
  * // auto-fill from car-server's
2307
2346
  * // bound /mcp URL. "" opts out.
2347
+ * "attachments"?: [ // images attached to the prompt
2348
+ * { "path": string, // abs path on the daemon's fs
2349
+ * "media_type"?: string } // advisory; the runner derives
2350
+ * ] // the real type from content
2308
2351
  * }
2309
2352
  *
2353
+ * `attachments` are image files the runner hands to the CLI in its
2354
+ * native form: Claude Code reads + inlines a base64 image block on
2355
+ * stdin, Codex passes each via `--image`, Gemini references it with
2356
+ * `@path`. Paths must be readable by the daemon process. The runner
2357
+ * caps reads at 32 MB and (on the read/stage paths) verifies the bytes
2358
+ * are a real image by magic signature, deriving `media_type` from
2359
+ * content — non-image / oversized / unreadable paths are skipped, so a
2360
+ * file that isn't an image is never inlined. Adapters whose CLI lacks
2361
+ * image input ignore them.
2362
+ *
2310
2363
  * Returns JSON `InvokeResult`:
2311
2364
  *
2312
2365
  * {
@@ -2316,6 +2369,7 @@ export function agentsHealthExternal(
2316
2369
  * "tool_calls": number, // tool_use blocks observed
2317
2370
  * "duration_ms": number,
2318
2371
  * "total_cost_usd"?: number, // would-be API cost (subscription users don't pay)
2372
+ * "dropped_attachments"?: number, // images dropped (unreadable/oversized/not an image); omitted when 0
2319
2373
  * "is_error": boolean,
2320
2374
  * "error"?: string
2321
2375
  * }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "car-runtime",
3
- "version": "0.26.0",
3
+ "version": "0.27.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",