@oh-my-pi/pi-ai 18.3.4 → 18.4.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/CHANGELOG.md +35 -48
- package/dist/types/auth/blocks.d.ts +10 -19
- package/dist/types/auth/cascade.d.ts +1 -1
- package/dist/types/auth/rotation.d.ts +6 -3
- package/dist/types/auth/types.d.ts +23 -3
- package/dist/types/auth/usage-cache.d.ts +14 -2
- package/dist/types/auth/usage.d.ts +2 -2
- package/dist/types/auth-broker/client.d.ts +2 -1
- package/dist/types/auth-broker/remote-store.d.ts +5 -6
- package/dist/types/auth-broker/types.d.ts +3 -1
- package/dist/types/auth-broker/wire-schemas.d.ts +2 -1
- package/dist/types/auth-retry.d.ts +22 -13
- package/dist/types/images/types.d.ts +9 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/judgment/types.d.ts +3 -2
- package/dist/types/providers/cursor/exec-modern.d.ts +1 -1
- package/dist/types/providers/cursor-pi-args.d.ts +10 -0
- package/dist/types/providers/cursor.d.ts +6 -2
- package/dist/types/providers/google-shared.d.ts +13 -2
- package/dist/types/types.d.ts +0 -10
- package/dist/types/usage/claude-reset.d.ts +6 -0
- package/dist/types/usage/claude.d.ts +6 -0
- package/dist/types/usage.d.ts +2 -0
- package/dist/types/utils/proxy.d.ts +2 -2
- package/package.json +6 -6
- package/src/auth/blocks.ts +79 -37
- package/src/auth/cascade.ts +5 -4
- package/src/auth/resets.ts +104 -40
- package/src/auth/rotation.ts +62 -21
- package/src/auth/select.ts +9 -2
- package/src/auth/types.ts +28 -3
- package/src/auth/usage-cache.ts +45 -2
- package/src/auth/usage.ts +52 -25
- package/src/auth-broker/client.ts +13 -0
- package/src/auth-broker/remote-store.ts +128 -27
- package/src/auth-broker/server.ts +20 -0
- package/src/auth-broker/types.ts +4 -1
- package/src/auth-broker/wire-schemas.ts +7 -0
- package/src/auth-retry.ts +50 -28
- package/src/images/openai-hosted.ts +18 -3
- package/src/images/types.ts +9 -0
- package/src/index.ts +1 -0
- package/src/judgment/types.ts +10 -6
- package/src/judgment/typesafe.ts +2 -2
- package/src/providers/anthropic.ts +54 -123
- package/src/providers/cursor/exec-modern.ts +1 -0
- package/src/providers/cursor/proto/agent.proto +5 -0
- package/src/providers/cursor-pi-args.ts +14 -0
- package/src/providers/cursor.ts +66 -28
- package/src/providers/google-gemini-cli.ts +2 -19
- package/src/providers/google-shared.ts +30 -22
- package/src/providers/ollama.ts +2 -0
- package/src/registry/oauth/oauth.html +206 -185
- package/src/stream.ts +2 -284
- package/src/types.ts +0 -10
- package/src/usage/claude-reset.ts +45 -11
- package/src/usage/claude.ts +79 -49
- package/src/usage.ts +2 -0
- package/src/utils/proxy.ts +3 -3
- package/src/utils/schema/CONSTRAINTS.md +30 -28
- package/src/utils/schema/normalize.ts +1 -1
- package/src/utils/schema/wire.ts +3 -3
|
@@ -5,10 +5,11 @@ This document is the operational contract for schema normalization/strictness in
|
|
|
5
5
|
## Scope
|
|
6
6
|
|
|
7
7
|
- Applies to provider-facing tool schemas produced by:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
- `normalize.ts` — Google, CCA, MCP, OpenAI Responses, and OpenAI strict-mode (sanitize + enforce) sanitization. All schema walkers live here.
|
|
9
|
+
- `adapt.ts` — thin composer wrapping `tryEnforceStrictSchema` for provider call sites, plus the `PI_NO_STRICT` env flag callers consult to opt out of strict mode.
|
|
10
|
+
- `fields.ts` — keyword classification sets used by the walkers.
|
|
11
11
|
- Covers OpenAI-style strict mode, OpenAI Responses `oneOf` rejection, Google schema constraints, and Cloud Code Assist Claude constraints.
|
|
12
|
+
|
|
12
13
|
---
|
|
13
14
|
|
|
14
15
|
## 1) OpenAI-style strict mode (`adaptSchemaForStrict` / `tryEnforceStrictSchema`)
|
|
@@ -18,17 +19,17 @@ When strict mode is requested (`strict=true` at call site), the schema MUST sati
|
|
|
18
19
|
1. **Non-structural keywords are removed before strict enforcement**
|
|
19
20
|
- Sanitization uses `sanitizeSchemaForStrictMode`.
|
|
20
21
|
- Removed keys include formatting/validation/decorative keywords and unsupported structural extras:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
- `format`, `pattern`, `minLength`, `maxLength`, `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum`
|
|
23
|
+
- `minItems`, `maxItems`, `uniqueItems`, `multipleOf`
|
|
24
|
+
- `$schema`, `examples`, `default`, `title`, `$comment`
|
|
25
|
+
- `if`, `then`, `else`, `not`
|
|
26
|
+
- `unevaluatedProperties`, `unevaluatedItems`, `patternProperties`
|
|
27
|
+
- `propertyNames`, `contains`, `minContains`, `maxContains`
|
|
28
|
+
- `dependentRequired`, `dependentSchemas`
|
|
29
|
+
- `contentEncoding`, `contentMediaType`, `contentSchema`
|
|
30
|
+
- `deprecated`, `readOnly`, `writeOnly`
|
|
31
|
+
- `minProperties`, `maxProperties`
|
|
32
|
+
- `$dynamicRef`, `$dynamicAnchor`
|
|
32
33
|
- Before stripping `default`, its value is inlined into the sibling `description` as ` (default: X)` so that strict-mode providers retain the default hint in free-form text. Inlining is skipped when `description` already contains `(default:` or when no sibling `description` is present.
|
|
33
34
|
|
|
34
35
|
2. **`const` is normalized to `enum`**
|
|
@@ -38,8 +39,8 @@ When strict mode is requested (`strict=true` at call site), the schema MUST sati
|
|
|
38
39
|
- Every object node gets `additionalProperties: false`.
|
|
39
40
|
- Every property key is included in `required`.
|
|
40
41
|
- Optional properties are made nullable:
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
- Pure union nodes (only `anyOf` plus optional `description`) get a `{ "type": "null" }` branch appended in place — never a nested wrapper.
|
|
43
|
+
- All other nodes are wrapped as `anyOf: [<original schema>, { "type": "null" }]`. Nodes with constraining siblings next to `anyOf` MUST keep the wrapper: sibling keywords are conjunctive with `anyOf`, so appending a null branch would not make the node nullable.
|
|
43
44
|
- Nested pure unions are spliced into the parent `anyOf` (`(A ∨ B) ∨ C` → `A ∨ B ∨ C`); an inner `description` is hoisted to the parent when the parent has none. Strict output MUST NOT contain an `anyOf` branch that is itself a pure union — some upstream validators (OpenRouter DeepSeek) reject branches without `type`.
|
|
44
45
|
- Tuple entries in `prefixItems` are strictified recursively.
|
|
45
46
|
|
|
@@ -63,14 +64,14 @@ Schemas sent on the Google JSON Schema path MUST follow:
|
|
|
63
64
|
|
|
64
65
|
1. **Unsupported JSON Schema keywords are stripped (except property names under `properties`)**
|
|
65
66
|
- Unsupported keys (`UNSUPPORTED_SCHEMA_FIELDS`):
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
- `$schema`, `$ref`, `$defs`, `$dynamicRef`, `$dynamicAnchor`
|
|
68
|
+
- `examples`, `prefixItems`, `unevaluatedProperties`, `unevaluatedItems`
|
|
69
|
+
- `patternProperties`, `additionalProperties`
|
|
70
|
+
- `minItems`, `maxItems`, `minLength`, `maxLength`
|
|
71
|
+
- `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum`
|
|
72
|
+
- `pattern`, `format`
|
|
73
|
+
- `dependencies`, `dependentSchemas`, `dependentRequired`
|
|
74
|
+
- `deprecated`, `readOnly`, `writeOnly`, `$comment`
|
|
74
75
|
- Important: keys inside a `properties` object are treated as property names and MUST NOT be stripped by keyword match.
|
|
75
76
|
- Human-meaningful stripped keys (`pattern`, `format`, min/max constraints, `default`, `examples`, etc.) are appended to the sibling `description` as an Anthropic-style spill block: `{pattern: "^foo$", minimum: 0}`. Structural/meta keys such as `$ref`, `$defs`, and `additionalProperties` are not spilled.
|
|
76
77
|
|
|
@@ -83,6 +84,7 @@ Schemas sent on the Google JSON Schema path MUST follow:
|
|
|
83
84
|
|
|
84
85
|
4. **Object schemas get an explicit properties map**
|
|
85
86
|
- `{ "type": "object" }` becomes `{ "type": "object", "properties": {} }`.
|
|
87
|
+
|
|
86
88
|
---
|
|
87
89
|
|
|
88
90
|
## 3) Claude via Cloud Code Assist (`normalizeSchemaForCCA`)
|
|
@@ -144,14 +146,14 @@ If any remain, schema is incompatible.
|
|
|
144
146
|
## 4) Practical provider mapping
|
|
145
147
|
|
|
146
148
|
- **OpenAI-compatible strict paths** (`openai-completions`, `openai-responses`, `openai-codex-responses`):
|
|
147
|
-
|
|
148
|
-
|
|
149
|
+
- Use `adaptSchemaForStrict`.
|
|
150
|
+
- Emit `strict: true` only when effective strict enforcement succeeded.
|
|
149
151
|
|
|
150
152
|
- **Google Gemini/Vertex/Gemini CLI (non-CCA Claude)**:
|
|
151
|
-
|
|
153
|
+
- Use `normalizeSchemaForGoogle` and send schema on `parametersJsonSchema` path.
|
|
152
154
|
|
|
153
155
|
- **Cloud Code Assist Claude models (`model.id` starts with `claude-`)**:
|
|
154
|
-
|
|
156
|
+
- Use `normalizeSchemaForCCA` and send sanitized normalized schema in `parameters`.
|
|
155
157
|
|
|
156
158
|
---
|
|
157
159
|
|
|
@@ -1882,7 +1882,7 @@ function inferStrictPrimitiveTypeFromEnumOrConst(node: Record<string, unknown>):
|
|
|
1882
1882
|
* repeated calls (different providers, retries, batching) reuse the same
|
|
1883
1883
|
* computed pair without re-walking the tree.
|
|
1884
1884
|
*/
|
|
1885
|
-
const kStrictSchema = Symbol("
|
|
1885
|
+
const kStrictSchema = Symbol("omp.schema.strict");
|
|
1886
1886
|
|
|
1887
1887
|
/**
|
|
1888
1888
|
* A boolean schema (`true`/`false`) or the empty object schema `{}`: an
|
package/src/utils/schema/wire.ts
CHANGED
|
@@ -109,9 +109,9 @@ function arkJsonAstToWire(value: unknown): unknown {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/** `stamp` cache keys; the entries themselves live in a weak side table keyed by schema identity. */
|
|
112
|
-
const kJsonWireSchema = Symbol("
|
|
113
|
-
const kArkWireSchema = Symbol("
|
|
114
|
-
const kStrippedSchema = Symbol("
|
|
112
|
+
const kJsonWireSchema = Symbol("omp.schema.json.wire");
|
|
113
|
+
const kArkWireSchema = Symbol("omp.schema.ark.wire");
|
|
114
|
+
const kStrippedSchema = Symbol("omp.schema.descriptions.stripped");
|
|
115
115
|
|
|
116
116
|
function postProcessJsonSchema(schema: Record<string, unknown>): Record<string, unknown> {
|
|
117
117
|
walk(schema);
|