car-runtime 0.44.0 → 0.46.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 +108 -2
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -73,6 +73,14 @@ export class CarRuntime {
73
73
  * 2026-05 audit boundary). Relative paths land under the base;
74
74
  * absolute paths must already be under the base; `..` segments and
75
75
  * symlinks pointing out of the sandbox are rejected.
76
+ *
77
+ * **`path` names a file, not a namespace.** This REPLACES the graph the
78
+ * connection is bound to — and by default that is the daemon's SHARED graph,
79
+ * common to every unbound session and to facts ingested over MCP. So on a
80
+ * multi-project host this both discards other projects' in-memory facts and
81
+ * leaves the loaded ones visible to them. Set `CAR_MEMORY_NAMESPACE` in the host process to bind a private graph
82
+ * (car-releases#79/#80); the shared daemon transport puts it on the
83
+ * `session.auth` handshake for you.
76
84
  */
77
85
  loadMemory(path: string): Promise<number>;
78
86
 
@@ -94,6 +102,12 @@ export class CarRuntime {
94
102
  * Returns the number of records written.
95
103
  *
96
104
  * Daemon-side write: same `~/.car/memory/` sandbox as `loadMemory`.
105
+ *
106
+ * **Writes the whole graph, not a subset.** `path` chooses the destination
107
+ * file; it does not select the contents. On an unbound session that graph is
108
+ * the daemon-wide shared one, so per-project files each end up holding every
109
+ * project's facts. Set `CAR_MEMORY_NAMESPACE` for a file that contains only one project's
110
+ * facts (car-releases#79/#80).
97
111
  */
98
112
  persistMemory(path: string): Promise<number>;
99
113
 
@@ -609,6 +623,14 @@ export class CarRuntime {
609
623
  * field optional except `prompt`). Exposes every field on the
610
624
  * Rust struct including `intent`. Same pattern as
611
625
  * {@link verifyProposal}. Closes #107.
626
+ *
627
+ * `client_ref` is an opaque correlation token echoed verbatim in the
628
+ * `inference.runner.invoke` payload and otherwise ignored by CAR. A
629
+ * delegated-inference host with several calls in flight uses it to map an
630
+ * invoke back to its own request state — `call_id` is minted by the daemon
631
+ * only after this call, so it cannot serve that purpose. Hosts previously
632
+ * had to smuggle an id through `prompt`, which worked only because
633
+ * delegated models ignore it (car-releases#78).
612
634
  */
613
635
  inferTrackedWithRequest(requestJson: string): Promise<string>;
614
636
 
@@ -753,12 +775,25 @@ export class CarRuntime {
753
775
  * Unified registry (local + remote). Returns JSON array of
754
776
  * `{ id, name, provider, capabilities, param_count, size_mb,
755
777
  * context_length, available, is_local, max_output_tokens,
756
- * public_benchmarks }`. `max_output_tokens` is the registry-declared
778
+ * public_benchmarks, cost }`. `max_output_tokens` is the registry-declared
757
779
  * per-model output ceiling (`null` when the entry omits it; callers
758
780
  * then fall back to a fraction of `context_length`).
759
781
  * `public_benchmarks` is `[{ name, score, harness?, source_url?,
760
782
  * measured_at? }]` with score on a 0.0–1.0 scale; ships empty in
761
783
  * the built-in catalog and is populated via curated registry data.
784
+ * `cost` is the model's declared prices — `{ input_per_mtok,
785
+ * output_per_mtok, cache_read_input_per_mtok, cache_write_input_per_mtok,
786
+ * pricing_tiers, size_mb, ram_mb }` — in USD per 1M tokens, with
787
+ * `pricing_tiers` as `[{ min_prompt_tokens, ...prices }]` prompt-size
788
+ * overrides (highest threshold not above the prompt wins). Every price is
789
+ * nullable and `null` means **unpriced, not free**: a local model declares
790
+ * no prices, and a caller that reads that as `0` publishes a fabricated
791
+ * cost. The managed `parslee/…` alias rows carry the same prices as the
792
+ * upstream row they front, and this response carries no upstream
793
+ * identifier for them. That holds for this catalog view; `models.search`
794
+ * additionally exposes a `family` field which does name the upstream
795
+ * model family. Older daemons omit
796
+ * `cost` entirely; it deserializes to all-`null` rather than failing.
762
797
  */
763
798
  listModelsUnified(): string;
764
799
 
@@ -2128,6 +2163,50 @@ export function simulate(
2128
2163
  initialStateJson?: string | null,
2129
2164
  ): string;
2130
2165
 
2166
+ /**
2167
+ * Sample N rollouts of a proposal with tools allowed to fail.
2168
+ *
2169
+ * `simulate` answers "what state does this plan leave behind, assuming every
2170
+ * dispatched tool succeeds?" This answers "how often does it actually work,
2171
+ * and when it doesn't, what breaks first?" Each `tool_call` succeeds with the
2172
+ * probability given in `toolSuccessRatesJson` (a JSON object mapping tool name
2173
+ * to a rate in `0.0..=1.0` — the shape produced by the planner's per-tool
2174
+ * trajectory feedback). Failures cascade through the dependency graph exactly
2175
+ * as they would at runtime: an action whose dependency never landed is
2176
+ * rejected before dispatch, not retried.
2177
+ *
2178
+ * `goalJson` is an optional `GoalCondition` evaluated against each trial's
2179
+ * final state. Conditions a simulation cannot decide — tool receipts, command
2180
+ * exits, model judges — fail closed and are named in
2181
+ * `goal_underivable_conditions`, so a `p_goal_reached` of 0 is never silently
2182
+ * mistaken for "this plan cannot work".
2183
+ *
2184
+ * `configJson` is an optional `{ trials?, seed?, defaultSuccessRate?,
2185
+ * retryAttempts? }` — note these are **snake_case** on the wire
2186
+ * (`default_success_rate`, `retry_attempts`), since the payload is serde JSON
2187
+ * rather than a napi-converted object. Defaults: 1000 trials, a fixed seed,
2188
+ * 0.5 for tools with no recorded history, no retries. The seed is fixed rather
2189
+ * than time-derived so runs are reproducible, and is echoed back in the result.
2190
+ *
2191
+ * Returns JSON:
2192
+ * `{ trials, seed, p_goal_reached, goal_underivable_conditions,
2193
+ * p_all_effects_landed, tool_calls: {mean, min, p50, p95, max},
2194
+ * actions_executed: {...}, state_distribution: [{key, p_present,
2195
+ * values: [{value, probability}]}], action_outcomes: [{action_id, p_rejected,
2196
+ * p_failed, p_effects_landed, mean_blast_radius}] }`.
2197
+ *
2198
+ * Independence caveat: draws are uncorrelated, so a plan that calls one flaky
2199
+ * tool repeatedly reads more optimistically here than it will behave when that
2200
+ * tool's backing service is down.
2201
+ */
2202
+ export function simulateMonteCarlo(
2203
+ proposalJson: string,
2204
+ initialStateJson?: string | null,
2205
+ toolSuccessRatesJson?: string | null,
2206
+ goalJson?: string | null,
2207
+ configJson?: string | null,
2208
+ ): string;
2209
+
2131
2210
  export function optimize(proposalJson: string): string;
2132
2211
 
2133
2212
  export function equivalent(proposal1Json: string, proposal2Json: string): boolean;
@@ -2306,7 +2385,16 @@ export function enforceInformationFlow(
2306
2385
  * `{ level: "l0" | "l1" | "l2" | "l3" | "l4", serializable, anomalies: [{
2307
2386
  * anomaly: "stale_generation" | "phantom_tool" | "causal_cascade" |
2308
2387
  * "tool_effect_reorder", key, ops, explanation }] }` — `level` is set by the
2309
- * most severe anomaly present (causal-cascade → l0 … none → l4 serializable).
2388
+ * most severe *named* anomaly present (causal-cascade → l0 … none → l4).
2389
+ *
2390
+ * `serializable` is a separate, real conflict-serializability decision: the
2391
+ * schedule's serialization graph (write-write, write-read, anti-dependency, and
2392
+ * declared `depends_on` edges) is tested for a cycle. It is NOT `level === "l4"`.
2393
+ * The two deliberately disagree on write skew — concurrent ops reading
2394
+ * overlapping state and writing disjoint keys match no named anomaly, so such a
2395
+ * schedule reports `level: "l4"` with `serializable: false`. Read `level` for
2396
+ * which anomaly to remediate, `serializable` for whether an equivalent serial
2397
+ * order exists.
2310
2398
  */
2311
2399
  export function analyzeConcurrency(opsJson: string): string;
2312
2400
 
@@ -3042,6 +3130,24 @@ export function rankProposals(
3042
3130
  */
3043
3131
  export function runApplescript(argsJson: string): Promise<string>;
3044
3132
 
3133
+ /**
3134
+ * Run a Windows PowerShell script via `powershell.exe` — the Windows analog
3135
+ * of `runApplescript`. Drives the host desktop and its apps (toast, clipboard,
3136
+ * COM, UI Automation).
3137
+ *
3138
+ * `argsJson` shape:
3139
+ * ```jsonc
3140
+ * {
3141
+ * "script": "Get-Date",
3142
+ * "timeout_ms": 5000 // optional
3143
+ * }
3144
+ * ```
3145
+ *
3146
+ * Returns JSON `{stdout, stderr, exit_code}`. Rejects with a
3147
+ * PlatformUnsupported error on non-Windows hosts.
3148
+ */
3149
+ export function runPowershell(argsJson: string): Promise<string>;
3150
+
3045
3151
  /**
3046
3152
  * Enumerate Shortcuts (user-authored *and* AppShortcuts donated by
3047
3153
  * apps via the App Intents framework). Returns an array of
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "car-runtime",
3
- "version": "0.44.0",
3
+ "version": "0.46.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",