car-runtime 0.16.1 → 0.18.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 +55 -41
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -242,10 +242,19 @@ export class CarRuntime {
242
242
  *
243
243
  * **Note:** intent is not exposed on the tracked path until the
244
244
  * positional argument list is converted to an options object —
245
- * this method already takes 8 positional parameters and adding a
246
- * 9th would push call sites past readability. For new code, use
247
- * {@link inferTrackedWithRequest} which takes a JSON-stringified
248
- * `GenerateRequest` and exposes every field including `intent`.
245
+ * this method already takes 9 positional parameters and adding
246
+ * intent would push call sites past readability. For new code,
247
+ * use {@link inferTrackedWithRequest} which takes a JSON-
248
+ * stringified `GenerateRequest` and exposes every field
249
+ * including `intent`.
250
+ *
251
+ * `imagesJson` is a JSON-encoded array of `ContentBlock` image
252
+ * variants — either
253
+ * `{ "type": "image_base64", "data": "<b64>", "media_type": "image/png" }`
254
+ * or `{ "type": "image_url", "url": "https://…", "detail": "auto" }`.
255
+ * Vision-capable hosted models (Claude 3.5+/4.x, GPT-4o, Gemini)
256
+ * accept these directly; non-vision providers reject the request
257
+ * via a structured error from the daemon. See #230.
249
258
  */
250
259
  inferTracked(
251
260
  prompt: string,
@@ -256,6 +265,7 @@ export class CarRuntime {
256
265
  messagesJson?: string | null,
257
266
  toolChoice?: string | null,
258
267
  parallelToolCalls?: boolean | null,
268
+ imagesJson?: string | null,
259
269
  ): Promise<string>;
260
270
 
261
271
  /**
@@ -895,6 +905,26 @@ export function transcribeStreamPush(
895
905
 
896
906
  export function listVoiceSessions(rt: CarRuntime): string;
897
907
 
908
+ /**
909
+ * Start a streaming TTS synthesis.
910
+ *
911
+ * Stub: not exposed in the FFI bindings. Connect to the daemon's
912
+ * WebSocket and use `voice.tts_stream.start`; chunks arrive as
913
+ * `voice.event` notifications with `type = "tts_chunk"`.
914
+ */
915
+ export function ttsStreamStart(
916
+ rt: CarRuntime,
917
+ streamId: string,
918
+ text: string,
919
+ optionsJson?: string | null,
920
+ ): Promise<string>;
921
+
922
+ /** Cancel an in-flight TTS stream. Idempotent. */
923
+ export function ttsStreamCancel(rt: CarRuntime, streamId: string): Promise<string>;
924
+
925
+ /** List the ids of all in-flight TTS streams. */
926
+ export function listTtsStreams(rt: CarRuntime): string;
927
+
898
928
  // --- Voice turn dispatch (two-track sidecar pattern) ---
899
929
 
900
930
  export interface DispatchVoiceTurnRequest {
@@ -1174,11 +1204,23 @@ export function a2aServerStatus(): string;
1174
1204
 
1175
1205
  // --- Verification (stateless) ---
1176
1206
 
1207
+ /**
1208
+ * Statically verify a proposal.
1209
+ *
1210
+ * `toolNames` checks tool existence only. To also validate each
1211
+ * `tool_call`'s parameters against the tool's JSON Schema — catching
1212
+ * type mismatches (`{path: 42}` for a `string`) and missing required
1213
+ * fields — pass `toolSchemasJson`: a JSON array of tool schemas, e.g.
1214
+ * `JSON.stringify([{ name: "echo", parameters: { type: "object",
1215
+ * properties: { msg: { type: "string" } }, required: ["msg"] } }])`.
1216
+ * When both are given, `toolSchemasJson` takes precedence.
1217
+ */
1177
1218
  export function verify(
1178
1219
  proposalJson: string,
1179
1220
  initialStateJson?: string | null,
1180
1221
  toolNames?: string[] | null,
1181
1222
  maxActions?: number | null,
1223
+ toolSchemasJson?: string | null,
1182
1224
  ): string;
1183
1225
 
1184
1226
  export function simulate(
@@ -1202,43 +1244,15 @@ export function registerAgentRunner(
1202
1244
  agentFn: (specJson: string, taskJson: string) => Promise<string>,
1203
1245
  ): Promise<void>;
1204
1246
 
1205
- /**
1206
- * Register the inference runner callback. Closes
1207
- * Parslee-ai/car-releases#24 when a model schema declares
1208
- * `source: { type: "delegated", ... }`, CAR routes the request through
1209
- * this callback. The host owns the wire format (Anthropic, OpenAI,
1210
- * Vercel AI SDK, GitHub Models, etc.); CAR observes events and stays
1211
- * in the policy / replay path.
1212
- *
1213
- * The runner emits stream events for every chunk it receives from its
1214
- * provider via `inferenceRunnerEmitEvent(callId, eventJson)`, then
1215
- * resolves the promise with the final aggregated result JSON
1216
- * (`{text: string, tool_calls: ToolCall[]}`).
1217
- *
1218
- * Idempotent — re-calling overwrites the previous runner. Only one
1219
- * runner can be registered per process (matches `registerAgentRunner`).
1220
- *
1221
- * Event JSON shapes match `inferStream`'s event taxonomy:
1222
- * `{type: "text", data: string}`
1223
- * `{type: "tool_start", name: string, index: number, id?: string}`
1224
- * `{type: "tool_delta", index: number, data: string}`
1225
- * `{type: "usage", input_tokens: number, output_tokens: number}`
1226
- * `{type: "done", text: string, tool_calls: ToolCall[]}`
1227
- */
1228
- export function registerInferenceRunner(
1229
- runnerFn: (requestJson: string, callId: string) => Promise<string>,
1230
- ): void;
1231
-
1232
- /**
1233
- * Emit a stream event from inside the inference runner callback.
1234
- * `callId` is the second argument the runner received; `eventJson`
1235
- * is one of the shapes documented on `registerInferenceRunner`.
1236
- *
1237
- * Silently no-ops if `callId` is unknown (call already completed or
1238
- * the runner emitted after returning) — racing the normal completion
1239
- * path shouldn't error.
1240
- */
1241
- export function inferenceRunnerEmitEvent(callId: string, eventJson: string): void;
1247
+ // --- Inference runner (delegated inference, closes car-releases#24) ---
1248
+ //
1249
+ // In-process registration is not exposed in the FFI bindings (car-releases#55).
1250
+ // The v0.8+ daemon-only architecture moves delegated inference to the
1251
+ // WebSocket protocol: a runner client connects to car-server and calls
1252
+ // `inference.register_runner`; the daemon then sends
1253
+ // `inference.runner.invoke` notifications for every delegated call.
1254
+ // See docs/websocket-protocol.md §"Inference runner" for the wire shape.
1255
+ // `car-server` is shipped as a binary in this npm package (`bin/car-server`).
1242
1256
 
1243
1257
  /** Run a Swarm pattern. `mode` is "parallel", "sequential", or "debate". */
1244
1258
  export function runSwarm(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "car-runtime",
3
- "version": "0.16.1",
3
+ "version": "0.18.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",