prefix-safe-json 0.6.1 → 0.6.2

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/README.md CHANGED
@@ -4,24 +4,56 @@
4
4
  [![CI](https://github.com/canblmz1/prefix-safe-json/actions/workflows/ci.yml/badge.svg)](https://github.com/canblmz1/prefix-safe-json/actions/workflows/ci.yml)
5
5
  [![License: MIT OR Apache-2.0](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue.svg)](#license)
6
6
 
7
- Check original streamed arguments and terminal evidence **before your application
8
- runs a tool**. `prefix-safe-json` refuses authority for incomplete input,
9
- conflicting call identity, invalid schemas, or unsafe termination, even when a
10
- parsed tool-call object looks usable.
11
-
12
- Your application consumes a decision once and performs the side effect itself.
13
- PSJ never executes tools. Provider signals must accurately describe completion;
7
+ Keep an incomplete or ambiguously identified LLM tool call from reaching your
8
+ application's tools. `prefix-safe-json` checks the original argument stream,
9
+ completion signals and schema **before your application runs a tool**, even
10
+ when the SDK's parsed arguments look usable.
11
+
12
+ The core package returns one-shot decisions; your application performs the
13
+ side effect. The separate integration below keeps tool execution in the SDK.
14
+ Provider signals must accurately describe completion;
14
15
  see the [provider-honesty limit](examples/openai-consumer/README.md).
15
16
 
16
- ```bash
17
- pnpm add prefix-safe-json ai zod
18
- # or: npm install prefix-safe-json ai zod
17
+ For AI SDK 7 with OpenAI-compatible Chat Completions, the experimental
18
+ [guarded chat integration](packages/ai-sdk/README.md) keeps your ordinary
19
+ `execute` callbacks and the SDK's automatic tool-result continuation:
20
+
21
+ For a new application, install the separately versioned companion and a tested SDK/provider
22
+ pair together. In an existing application, keep your supported locked peer
23
+ versions; see the integration's installation instructions.
24
+
25
+ ```sh
26
+ npm install --save-exact psj-ai-sdk@0.3.2 prefix-safe-json@0.6.2 ai@7.0.143 @ai-sdk/openai-compatible@3.0.71
27
+ ```
28
+
29
+ ```typescript
30
+ import { createGuardedChat } from "psj-ai-sdk";
31
+ import { stepCountIs } from "ai";
32
+
33
+ const chat = createGuardedChat({ name: "provider", baseURL, apiKey });
34
+ const result = chat({ model: modelId, tools, prompt, stopWhen: stepCountIs(5) });
19
35
  ```
20
36
 
21
- Try a runnable comparison first: [download the six-SDK trial ZIP](https://github.com/canblmz1/prefix-safe-json/releases/download/v0.5.4/prefix-safe-json-0.5.4-trials.zip),
22
- extract it, then run `node scripts/try-npm-demo.mjs tanstack` with Node 22+.
23
- It uses published packages, authored streams and harmless counters; no API key
24
- or repository build is needed. [Choose another SDK](examples/README.md).
37
+ Text/reasoning can stream while tool calls wait for the entire response and
38
+ batch validation. Optional local recording saves refused responses for
39
+ offline wire-policy replay and explicit CI expectations. See the integration's
40
+ supported policies and provisional-text limits. Run the [offline example](examples/guarded-chat/)
41
+ without a key. The core runtime gains no AI SDK dependency.
42
+
43
+ For prepublication review, use the two packed
44
+ artifacts described in the [evaluation kit](docs/COMPANION_EVALUATION.md).
45
+ The [whole-batch contract](docs/BATCH_CONTRACT.md) distinguishes the fixed
46
+ 0.3.2 policy from older previews. The kit also compares identical responses
47
+ through the current native SDK, a small native check and the companion.
48
+
49
+ For caller-owned dispatch, install `prefix-safe-json` from npm and use the
50
+ [complete TypeScript agent-loop example](examples/typed-agent-loop/):
51
+ [download its ZIP](https://github.com/canblmz1/prefix-safe-json/releases/download/v0.6.1/prefix-safe-json-0.6.1-typed-loop.zip),
52
+ extract it, then run `npm install --engine-strict --no-audit --no-fund` and
53
+ `npm start` with Node 22+. It uses published PSJ `0.6.1`, runs tools, sends
54
+ their matched results back to the model, and returns a final answer. Five
55
+ authored scenarios use memory counters; no API key or repository build is needed.
56
+ [Choose another SDK](examples/README.md).
25
57
 
26
58
  ## Safe execution example
27
59
 
@@ -83,27 +115,37 @@ key. The caller owns dispatch and continuation. Schema transformations,
83
115
  defaults and removed keys are refused; [validation details](docs/VALIDATION.md#typed-raw-input-guard).
84
116
 
85
117
  To try the published version without cloning this repository, download the
86
- [0.6.0 typed-loop example ZIP](https://github.com/canblmz1/prefix-safe-json/releases/download/v0.6.0/prefix-safe-json-0.6.0-typed-loop.zip),
118
+ [0.6.1 typed-loop example ZIP](https://github.com/canblmz1/prefix-safe-json/releases/download/v0.6.1/prefix-safe-json-0.6.1-typed-loop.zip),
87
119
  extract it, then run `npm install --engine-strict --no-audit --no-fund` and
88
120
  `npm start` inside the extracted directory. Node 22+ is required. The example
89
121
  uses authored model responses and memory counters; no API key is needed.
90
122
 
91
123
  ## When this adds value
92
124
 
93
- Use PSJ when your application owns tool dispatch and needs original-stream
94
- evidence to govern it. If your SDK already blocks unsafe termination, first
95
- check whether that existing behavior meets your need. PSJ does not provide
96
- UI recovery, automatic continuation, or domain validation such as XML
97
- completeness. The [external fit audit](docs/EXTERNAL_FIT_AUDIT.md) records
98
- both useful integrations and cases where no additional benefit was shown.
125
+ PSJ fits applications that can retain original stream evidence and own tool
126
+ dispatch, especially when they need the same completion and identity policy
127
+ across providers. Check your integration before adding it:
128
+
129
+ | Your current boundary | First step |
130
+ | --- | --- |
131
+ | You retain argument deltas and control dispatch | Compare a harmless tool with and without the guard |
132
+ | Your SDK already refuses the failure you care about | Test that native behavior first; an extra dependency may add no value |
133
+ | Your framework runs tools before exposing raw events | Find a pre-execution hook or keep the native path; observing later cannot prevent an earlier effect |
134
+ | You want partial JSON for a UI or recovery of truncated XML | Use a preview/recovery tool; PSJ's execution policy does not provide that behavior |
135
+
136
+ The [integration guide](docs/TRY_IN_YOUR_PROJECT.md) explains the migration
137
+ steps and [external fit audit](docs/EXTERNAL_FIT_AUDIT.md) records useful
138
+ integrations and cases where no additional benefit was shown.
139
+ The [usability audit](docs/USABILITY_AUDIT.md) separates reproduced integration
140
+ blockers, fixes and the limits that still need evaluation.
99
141
 
100
142
  For a concrete difference beyond unsafe termination, the
101
143
  [identity comparison](docs/IDENTITY_TRIAL.md) feeds complete, schema-valid
102
144
  calls through real `streamText()`: native execution records both calls when
103
145
  they reuse an ID; the locked PSJ path refuses that ambiguous identity. With
104
146
  distinct IDs, both paths record both calls. These are authored fixtures,
105
- not live-provider or WorkflowAgent certification. The existing launcher
106
- includes this comparison, or run `npm run identity` in the installed consumer.
147
+ not live-provider or WorkflowAgent certification. Select `ai-sdk` in the
148
+ launcher for this comparison, or run `npm run identity` in that installed consumer.
107
149
 
108
150
  ## Replay an incident and keep it as a regression test
109
151
 
@@ -112,104 +154,53 @@ Have a recorded Anthropic or AI SDK tool stream? The experimental
112
154
  and compares it with reviewed expectations in CI. It runs from a repository
113
155
  checkout without model requests or tool dispatch.
114
156
 
115
- ## Run a standalone npm demo
116
-
117
- To try it without cloning this repository, download the
118
- [six-SDK trial ZIP](https://github.com/canblmz1/prefix-safe-json/releases/download/v0.5.4/prefix-safe-json-0.5.4-trials.zip)
119
- and extract it. With Node 22+ and npm, run this from the extracted directory:
157
+ To test an SDK upgrade with original HTTP/SSE bytes, use the separate
158
+ [experimental regression development package](packages/regression/README.md).
159
+ It checks actual installed SDK inputs, harmless effects and paired results
160
+ in CI. Install its [experimental preview tarball](https://github.com/canblmz1/prefix-safe-json/releases/tag/psj-regression-v0.1.0)
161
+ as a development dependency; it is distributed separately from the PSJ
162
+ runtime package.
120
163
 
121
- ```bash
122
- node scripts/try-npm-demo.mjs tanstack
123
- ```
124
-
125
- Choose `ai-sdk`, `openai`, `anthropic`, `langchain`, `openrouter` or `tanstack`.
126
- Every example installs published PSJ `0.5.4`; no API key or repository build
127
- is needed. The ZIP contains example sources, the launcher and licenses;
128
- dependencies are downloaded from npm. See the [trial index](examples/README.md)
129
- for the SDK versions and checks. The earlier dated downloads remain unchanged.
164
+ ## Run a standalone npm demo
130
165
 
131
- With Node 22+ and npm, you can run the published-package demo from this checkout
132
- without installing the repository's development dependencies:
166
+ From this checkout, with Node 22+ and npm:
133
167
 
134
168
  ```bash
135
169
  node scripts/try-npm-demo.mjs
136
170
  ```
137
171
 
138
- The launcher creates a separate temporary npm project and leaves it available
139
- for editing. To connect the guard to your own stream and share a result, follow
140
- the [integration trial guide](docs/TRY_IN_YOUR_PROJECT.md).
141
-
142
- Copy [`examples/npm-consumer/`](examples/npm-consumer/) into an empty directory
143
- outside this checkout, then run these commands there with **Node 22+**:
144
-
145
- ```bash
146
- npm install --engine-strict --no-audit --no-fund
147
- npm ls prefix-safe-json ai zod
148
- npm start
149
- ```
150
-
151
- The current checkout pins `prefix-safe-json@0.5.4`, `ai@7.0.77`, and `zod@4.4.3`.
152
- It needs no repository build, workspace aliases, or API key. It drives real
153
- `streamText().fullStream` using the SDK's official `MockLanguageModelV4` and
154
- imports the installed package's public entry point and `standard-schema`
155
- subpath. Its only side effect is a harmless in-memory counter: complete input
156
- executes once; truncated and schema-invalid input execute zero times. A
157
- complete, schema-valid call that ends at the token limit also executes zero
158
- times: parse success cannot override unsafe termination. A
159
- projection-mismatch case executes the raw `authority.value`, never the SDK
160
- projection. Every attached SDK callback stays at zero, and a second
161
- `takeDecision()` returns `undefined`.
162
-
163
- This is a deterministic mock-provider check, not a live-provider call or
164
- independent adoption evidence. CI runs the same demo against a freshly packed
165
- candidate tarball in a separate, isolated npm consumer directory.
166
-
167
- The launcher also runs `npm run batch`: two interleaved calls execute twice
168
- after complete termination, while a token-limited step with one complete call
169
- and one truncated call executes neither. Both cases keep SDK callbacks at
170
- zero. The installed-consumer check also passes with `ai@7.0.137`, matching the
171
- version in [the parallel-call truncation report](https://github.com/vercel/ai/issues/22914).
172
- It does not implement UI state changes or continuation after a truncated step.
173
-
174
- The launcher then runs `npm run identity`, including an unlocked native
175
- control with harmless SDK-executed counters. Expected native / PSJ effects
176
- are **2 / 2** for distinct IDs and **2 / 0** for duplicate IDs. The PSJ path
177
- keeps every SDK callback at zero and uses one-shot caller dispatch. CI checks
178
- all three examples with `ai@7.0.77`, `7.0.128`, `7.0.137` and `7.0.140`.
179
- See the [identity trial](docs/IDENTITY_TRIAL.md) for the original-event
180
- boundary and the distinction from WorkflowAgent's result-pairing report.
181
-
182
- Using LangChain? The [standalone SDK comparison](examples/langchain-consumer/README.md)
183
- feeds the same original OpenAI-compatible fixture to `ChatOpenAI.stream()` and
184
- PSJ, checking that token-limit calls produce zero effects. It is a mock-transport
185
- comparison; your application still needs access to original provider evidence.
186
-
187
- Using the official Anthropic SDK? Run `node scripts/try-npm-demo.mjs anthropic`
188
- for the [installed-package terminal-boundary trial](examples/anthropic-consumer/README.md).
189
- It checks complete, token-limited, missing-`message_stop`, and post-terminal
190
- argument cases through the SDK's actual SSE parser. The LangChain comparison
191
- can also be launched with `node scripts/try-npm-demo.mjs langchain`.
192
-
193
- Using the official OpenAI SDK? Run `node scripts/try-npm-demo.mjs openai` for
194
- the [installed-package Chat Completions trial](examples/openai-consumer/README.md).
195
- It checks complete and interrupted calls, duplicate IDs and late argument
196
- evidence through `openai@7.34.0`. It also demonstrates a limit: PSJ cannot detect
197
- upstream truncation when the provider supplies complete JSON and falsely
198
- reports successful termination. These are mock-transport checks, not live
199
- OpenAI or vLLM certification.
200
-
201
- Using OpenRouter Agent? Run `node scripts/try-npm-demo.mjs openrouter` for the
202
- [manual dispatch and continuation trial](examples/openrouter-consumer/README.md).
203
- It checks that accepted tool results reach the next model request with matching
204
- call IDs, while invalid batches cause zero effects and no continuation request.
205
- It uses authored SSE through the installed SDK; no live model call is made.
206
-
207
- Using TanStack AI with OpenRouter? Run `node scripts/try-npm-demo.mjs tanstack`
208
- for the [installed-package comparison](examples/tanstack-consumer/README.md).
209
- It checks raw native finish reasons, usage trailers and paired results using
210
- published PSJ `0.5.4`, harmless counters and authored SSE. The
211
- [native-first standalone trial](https://gist.github.com/canblmz1/ba1e62d792da37d3f420c328f56d81be)
212
- also offers a PSJ-free baseline and an optional comparison from npm or source.
172
+ The default `guarded` trial installs companion `0.3.2`, core
173
+ PSJ `0.6.2`, AI SDK `7.0.143` and OpenAI-compatible provider `3.0.71`.
174
+ It uses ordinary SDK callbacks and automatic result continuation. The
175
+ explicit `typed` trial installs published PSJ `0.6.1`, AI SDK `7.0.143`
176
+ and Zod `4.4.3` in a separate temporary project. It checks a complete
177
+ tool → result → model loop, token limits, duplicate IDs, cancellation and a
178
+ tool error. The complete control returns a final answer; refused batches do
179
+ not continue. The directory stays available for editing and rerunning.
180
+
181
+ Choose another boundary by passing one of these names:
182
+
183
+ | Choice | PSJ pin | What to inspect |
184
+ | --- | --- | --- |
185
+ | `guarded` (default) | core `0.6.2` + companion `0.3.2` | [Native callbacks and automatic continuation](examples/guarded-chat/) |
186
+ | `typed` | `0.6.1` | [Typed inputs and caller-owned continuation](examples/typed-agent-loop/) |
187
+ | `ai-sdk` | `0.5.4` | [Termination, interleaved calls and native/PSJ identity comparison](docs/IDENTITY_TRIAL.md) |
188
+ | `openai` | `0.5.4` | [Original Chat Completions evidence and provider-honesty limit](examples/openai-consumer/README.md) |
189
+ | `anthropic` | `0.5.4` | [Final message termination and interrupted streams](examples/anthropic-consumer/README.md) |
190
+ | `langchain` | `0.5.4` | [Parsed candidates versus original provider evidence](examples/langchain-consumer/README.md) |
191
+ | `openrouter` | `0.5.4` | [Raw events, manual dispatch and paired results](examples/openrouter-consumer/README.md) |
192
+ | `tanstack` | `0.5.4` | [Native finish reasons, usage trailers and server-tool results](examples/tanstack-consumer/README.md) |
193
+
194
+ All trials use authored fixtures and harmless counters; they need no API key,
195
+ model server or repository build. Installation requires npm registry access.
196
+ A passing fixture is not a live-provider or own-project integration result.
197
+ The older [six-SDK ZIP](https://github.com/canblmz1/prefix-safe-json/releases/download/v0.5.4/prefix-safe-json-0.5.4-trials.zip)
198
+ retains its original six choices and `0.5.4` pins; `typed` is available in
199
+ the current checkout and the separate `0.6.1` ZIP linked above.
200
+
201
+ To connect a real application, follow the [integration guide](docs/TRY_IN_YOUR_PROJECT.md).
202
+ Your application must retain original evidence, stop automatic execution and
203
+ send accepted tool results into its own continuation loop.
213
204
 
214
205
  ## Why parse success is not enough
215
206
 
@@ -378,24 +369,7 @@ const result = parser.finish({ reason: "complete" });
378
369
  console.log(result.executable);
379
370
  ```
380
371
 
381
- ## Product experiment: Devam
382
-
383
- [Devam](https://github.com/canblmz1/devam-prototype) is a separate browser prototype for
384
- carrying the current request, completion claims, manual reviews and unfinished
385
- work between AI conversations. It includes examples for everyday users,
386
- people coding with AI, and AI application developers.
387
- [Try the live prototype](https://canblmz1.github.io/devam-prototype/).
388
- Development continues in its own repository; it is not part of the PSJ npm
389
- package and does not currently depend on PSJ. The original experiment remains
390
- here as a tested snapshot. Run that snapshot without dependencies or API keys:
391
-
392
- ```bash
393
- node experiments/devam/server.mjs
394
- ```
395
372
 
396
- Open `http://127.0.0.1:4317`. The prototype is experimental; its
397
- [research notes](experiments/devam/RESEARCH.md) distinguish reported pain,
398
- existing alternatives and unvalidated product demand.
399
373
 
400
374
  ## Development
401
375
 
@@ -1 +1 @@
1
- {"version":3,"file":"standard-schema-validator.d.ts","sourceRoot":"","sources":["../../src/validation/standard-schema-validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAwB,MAAM,YAAY,CAAC;AAE3E;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,WAAW,EAAE;QACpB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;KAChD,CAAC;CACH;AA6FD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,oBAAoB,GAAG,kBAAkB,CAEnF;AAED,4EAA4E;AAC5E,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,oBAAoB,EAAE,eAAe,UAAQ,GAAG,kBAAkB,CAuDvH"}
1
+ {"version":3,"file":"standard-schema-validator.d.ts","sourceRoot":"","sources":["../../src/validation/standard-schema-validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAwB,MAAM,YAAY,CAAC;AAE3E;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,WAAW,EAAE;QACpB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;KAChD,CAAC;CACH;AAgGD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,oBAAoB,GAAG,kBAAkB,CAEnF;AAED,4EAA4E;AAC5E,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,oBAAoB,EAAE,eAAe,UAAQ,GAAG,kBAAkB,CAuDvH"}
@@ -43,8 +43,11 @@ function formatIssue(issue) {
43
43
  * than refusing it here, synchronously, with a clear, specific reason.
44
44
  */
45
45
  function assertStandardSchemaV1(schema) {
46
- if (!isRecord(schema) || !("~standard" in schema)) {
47
- throw new Error('prefix-safe-json: fromStandardSchema() requires an object with a "~standard" property ' +
46
+ // ArkType and other callable schemas expose the same interface on a
47
+ // function. Only the schema container may be callable; metadata and
48
+ // validation results still have to be ordinary object-shaped values.
49
+ if ((!isRecord(schema) && typeof schema !== "function") || !("~standard" in schema)) {
50
+ throw new Error('prefix-safe-json: fromStandardSchema() requires an object or function with a "~standard" property ' +
48
51
  "(the Standard Schema v1 interface - see https://standardschema.dev). Received: " +
49
52
  describeForError(schema));
50
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"standard-schema-validator.js","sourceRoot":"","sources":["../../src/validation/standard-schema-validator.ts"],"names":[],"mappings":"AAyBA,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,OAAQ,KAA4B,CAAC,IAAI,KAAK,UAAU,CAAC;AACjH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,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3
+ "version": "0.6.2",
4
4
  "description": "Fail-closed execution integrity for streamed LLM tool calls — reject truncated or unconfirmed arguments before side effects",
5
5
  "keywords": [
6
6
  "json",
@@ -104,6 +104,7 @@
104
104
  "ai-v5": "npm:ai@5.0.244",
105
105
  "ai-v6": "npm:ai@6.0.264",
106
106
  "ai-v7": "npm:ai@7.0.77",
107
+ "arktype": "2.2.8",
107
108
  "clarinet": "^0.12.6",
108
109
  "eslint": "^9.8.0",
109
110
  "fast-check": "^4.9.0",