@introspection-ai/recipes 0.57.0 → 0.58.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 (79) hide show
  1. package/dist/batch/index.d.ts +2 -0
  2. package/dist/batch/index.d.ts.map +1 -1
  3. package/dist/batch/index.js +2 -1
  4. package/dist/batch/index.js.map +1 -1
  5. package/dist/batch/runner.d.ts +5 -0
  6. package/dist/batch/runner.d.ts.map +1 -1
  7. package/dist/batch/runner.js +6 -0
  8. package/dist/batch/runner.js.map +1 -1
  9. package/dist/judges/classifier.d.ts +8 -0
  10. package/dist/judges/classifier.d.ts.map +1 -0
  11. package/dist/judges/classifier.js +30 -0
  12. package/dist/judges/classifier.js.map +1 -0
  13. package/dist/judges/cli-main.d.ts +41 -0
  14. package/dist/judges/cli-main.d.ts.map +1 -0
  15. package/dist/judges/cli-main.js +182 -0
  16. package/dist/judges/cli-main.js.map +1 -0
  17. package/dist/judges/cli.d.ts +2 -0
  18. package/dist/judges/cli.d.ts.map +1 -0
  19. package/dist/judges/cli.js +43 -0
  20. package/dist/judges/cli.js.map +1 -0
  21. package/dist/judges/controller.d.ts +78 -0
  22. package/dist/judges/controller.d.ts.map +1 -0
  23. package/dist/judges/controller.js +243 -0
  24. package/dist/judges/controller.js.map +1 -0
  25. package/dist/judges/definition.d.ts +86 -0
  26. package/dist/judges/definition.d.ts.map +1 -0
  27. package/dist/judges/definition.js +100 -0
  28. package/dist/judges/definition.js.map +1 -0
  29. package/dist/judges/gate.d.ts +46 -0
  30. package/dist/judges/gate.d.ts.map +1 -0
  31. package/dist/judges/gate.js +256 -0
  32. package/dist/judges/gate.js.map +1 -0
  33. package/dist/judges/identity.d.ts +21 -0
  34. package/dist/judges/identity.d.ts.map +1 -0
  35. package/dist/judges/identity.js +48 -0
  36. package/dist/judges/identity.js.map +1 -0
  37. package/dist/judges/index.d.ts +10 -0
  38. package/dist/judges/index.d.ts.map +1 -0
  39. package/dist/judges/index.js +10 -0
  40. package/dist/judges/index.js.map +1 -0
  41. package/dist/judges/resolve-hooks.d.ts +10 -0
  42. package/dist/judges/resolve-hooks.d.ts.map +1 -0
  43. package/dist/judges/resolve-hooks.js +25 -0
  44. package/dist/judges/resolve-hooks.js.map +1 -0
  45. package/dist/judges/run.d.ts +123 -0
  46. package/dist/judges/run.d.ts.map +1 -0
  47. package/dist/judges/run.js +319 -0
  48. package/dist/judges/run.js.map +1 -0
  49. package/dist/judges/session.d.ts +9 -0
  50. package/dist/judges/session.d.ts.map +1 -0
  51. package/dist/judges/session.js +109 -0
  52. package/dist/judges/session.js.map +1 -0
  53. package/dist/judges/trajectory.d.ts +91 -0
  54. package/dist/judges/trajectory.d.ts.map +1 -0
  55. package/dist/judges/trajectory.js +223 -0
  56. package/dist/judges/trajectory.js.map +1 -0
  57. package/dist/judges/verdict.d.ts +31 -0
  58. package/dist/judges/verdict.d.ts.map +1 -0
  59. package/dist/judges/verdict.js +121 -0
  60. package/dist/judges/verdict.js.map +1 -0
  61. package/dist/model-binding.d.ts +10 -0
  62. package/dist/model-binding.d.ts.map +1 -1
  63. package/dist/model-binding.js +27 -6
  64. package/dist/model-binding.js.map +1 -1
  65. package/dist/recipe/manifest.generated.d.ts +1 -1
  66. package/dist/recipe/manifest.generated.js +1 -1
  67. package/dist/recipe/model.d.ts +5 -12
  68. package/dist/recipe/model.d.ts.map +1 -1
  69. package/dist/recipe/model.js +197 -263
  70. package/dist/recipe/model.js.map +1 -1
  71. package/dist/session.d.ts +6 -0
  72. package/dist/session.d.ts.map +1 -1
  73. package/dist/session.js +4 -2
  74. package/dist/session.js.map +1 -1
  75. package/docs/README.md +1 -0
  76. package/docs/judges.md +269 -0
  77. package/docs/recipe-format.md +9 -9
  78. package/docs/recipe-judges.md +119 -59
  79. package/package.json +10 -6
@@ -1,6 +1,6 @@
1
1
  # Recipe judge definitions
2
2
 
3
- Recipe judges are optional, recipe-owned LLM grading definitions. Author them
3
+ Recipe judges are optional, recipe-owned grading definitions. Author them
4
4
  as direct children of `judges/` using a lowercase `.yaml` or `.yml` extension:
5
5
 
6
6
  ```text
@@ -18,19 +18,20 @@ sources have no judge diagnostics.
18
18
  The validator behind `introspection check` owns the portable authored YAML
19
19
  specification and its static, file-oriented diagnostics.
20
20
 
21
- Evaluation systems own execution: applicability checks, conversation assembly,
22
- transcript protection, model requests, retries, verdict normalization, and
23
- evaluation identity. Implementations should consume or remain explicitly
24
- compatible with the authored specification defined here. New authored fields
25
- must land in this checker and its contract tests rather than appearing in only
26
- one evaluator.
21
+ `@introspection-ai/recipes/judges` owns execution: applicability checks,
22
+ transcript assembly and protection, model requests, verdict normalization and
23
+ evaluation identity. See [Running judges](judges.md). New authored fields must
24
+ land in the checker and its contract tests as well as in the runner.
27
25
 
28
26
  Validation reports do not contain normalized judge definitions or
29
27
  host-specific registry data.
30
28
 
31
29
  ## Definition shape
32
30
 
33
- The minimal definition is:
31
+ A judge is answered either by a chat model reading `instructions`, or by a
32
+ classifier answering yes-or-no `questions`. It declares exactly one of the two.
33
+
34
+ The minimal LLM judge is:
34
35
 
35
36
  ```yaml
36
37
  name: helpful
@@ -38,19 +39,18 @@ name: helpful
38
39
  instructions: |
39
40
  Determine whether the assistant answered the user correctly.
40
41
 
41
- llm:
42
- model: gpt-5
42
+ ai:
43
+ model: anthropic/claude-sonnet-5-5
43
44
  ```
44
45
 
45
- `name`, `instructions`, and `llm.model` are required and non-empty. Names use
46
- lowercase kebab-case and must be unique across all judge files in one Recipe.
47
- As with `agents/*.yaml`, the filename has no semantic meaning. Evaluators default
48
- `llm.provider` to `openai`.
46
+ `name`, `ai.model` and one of `instructions` and `questions` are required.
47
+ Names use lowercase kebab-case and must be unique across all judge files in one
48
+ Recipe. As with `agents/*.yaml`, the filename has no semantic meaning.
49
49
 
50
50
  Legacy definitions using `judge:` remain accepted as a deprecated input alias.
51
51
  Parsers normalize that field to `name`; a definition cannot declare both.
52
52
 
53
- The canonical expanded definition is:
53
+ The expanded definition is:
54
54
 
55
55
  ```yaml
56
56
  name: helpful
@@ -64,24 +64,95 @@ on:
64
64
  instructions: |
65
65
  Determine whether the assistant answered the user correctly.
66
66
 
67
+ ai:
68
+ model: anthropic/claude-sonnet-5-5
69
+ fallbacks:
70
+ - openai/gpt-6-luna
71
+ thinking_level: low
72
+ options:
73
+ temperature: 0
74
+ ```
75
+
76
+ Unknown fields are errors at every level.
77
+
78
+ ### The older `llm:` block
79
+
80
+ A judge declares its model under `ai:`. The `llm:` block that earlier versions
81
+ read is still accepted in its place, but never beside it: a judge with both, or
82
+ with neither, reports `judge.kind_invalid`. Every reader of the judge
83
+ (the checker, the runner and the hosted platform) sees the `ai:` block it maps
84
+ to:
85
+
86
+ | `llm:` | `ai:` |
87
+ | -------------------------- | ------------------------------------------------------------ |
88
+ | `provider` and `model` | `model: <provider>/<model>`; `provider` defaults to `openai` |
89
+ | `request.max_tokens` | `options.max_tokens` |
90
+ | `request.temperature` | `options.temperature`, unless it is 0 (the model's default) |
91
+ | `request.reasoning_effort` | `thinking_level`; `none` is `off` |
92
+ | `transport` | dropped: the host owns timeouts and retries |
93
+ | `local` | dropped with the warning `judge.llm.local_ignored` |
94
+
95
+ `ai:` cannot name a local endpoint, so a judge that declared `llm.local` runs on
96
+ its provider's hosted model. A `reasoning_effort` that names no thinking level
97
+ is an error.
98
+
99
+ ```yaml
100
+ # Read as ai: { model: anthropic/claude-sonnet-5-5, thinking_level: low }
67
101
  llm:
68
- provider: openai
69
- model: gpt-5
102
+ provider: anthropic
103
+ model: claude-sonnet-5-5
70
104
  request:
71
- temperature: 0
72
- max_tokens: 1024
73
- reasoning_effort: medium
74
- transport:
75
- timeout_ms: 60000
76
- max_retries: 2
77
- max_retry_delay_ms: 5000
78
- local:
79
- base_url: https://api.openai.com/v1
80
- api_key_env: OPENAI_API_KEY
105
+ reasoning_effort: low
106
+ ```
107
+
108
+ ### Model settings
109
+
110
+ `ai:` is the block an agent declares, with the same keys and the same rules:
111
+ `model`, `fallbacks`, `thinking_level`, `options` and `providers`. See
112
+ [Agents](recipe-format.md#agents). A judge has no `session:` block; the host's
113
+ retry settings apply.
114
+
115
+ An LLM judge returns `pass`, `fail` or `not_applicable` with a short reason.
116
+ That contract is the runner's and cannot be authored.
117
+
118
+ ### Classifier judges
119
+
120
+ A classifier judge asks a decision model yes-or-no questions and reads a
121
+ probability for each:
122
+
123
+ ```yaml
124
+ name: polite
125
+
126
+ ai:
127
+ model: typesafe/jev-latest
128
+ fallbacks:
129
+ - openai/gpt-6-luna
130
+
131
+ questions:
132
+ greeted:
133
+ instructions: Did the assistant greet the user?
134
+ criteria:
135
+ "true": The first reply opens with a greeting.
136
+ "false": It does not.
137
+ threshold: 0.8
138
+ apologised:
139
+ instructions: Did the assistant apologise for the delay?
140
+ criteria:
141
+ "true": It says sorry for the wait.
142
+ "false": It does not mention the wait.
81
143
  ```
82
144
 
83
- Unknown fields are errors at every level. The obsolete top-level `model:`
84
- block is rejected.
145
+ - `questions` maps between one and eight lowercase snake_case names to
146
+ questions.
147
+ - `instructions` is non-empty text, and `criteria` describes both `true` and
148
+ `false`.
149
+ - `threshold` is the probability of yes, above 0 and at most 1, that the
150
+ question must reach. It defaults to 0.5.
151
+ - The judge is `pass` when every question reaches its own threshold, and `fail`
152
+ otherwise. A classifier cannot abstain: `not_applicable` comes only from
153
+ `on`.
154
+ - `ai.model` names a classifier model. `thinking_level` and `options` do not
155
+ apply to one.
85
156
 
86
157
  ## Judge types
87
158
 
@@ -123,33 +194,8 @@ questions:
123
194
  describes both `true` and `false` in non-empty text.
124
195
  - `attributes` lists the request attributes the judge sees, and is empty to show
125
196
  them all.
126
- - `on` and `llm` belong to `online` judges and are rejected on a mission
127
- judge; `questions` and `attributes` are rejected on online judges.
128
-
129
- ### LLM settings
130
-
131
- - `provider` is a 1-64 byte lowercase slug containing ASCII letters, digits,
132
- and hyphens. The portable checker does not restrict it to managed platform
133
- providers because custom slugs can be used with an explicit local endpoint.
134
- - `model` is a trimmed, non-empty string of at most 255 bytes.
135
- - `request.temperature` is a finite number from 0 through 2 and defaults to 0.
136
- - `request.max_tokens` is an integer from 1 through 131072 when present;
137
- explicit `null` is treated as omitted.
138
- - `request.reasoning_effort` is a 1-64 byte lowercase slug containing ASCII
139
- letters and hyphens; explicit `null` is treated as omitted.
140
- - `transport.timeout_ms` is an integer from 1 through 600000 and defaults to
141
- 60000.
142
- - `transport.max_retries` is an integer from 0 through 10 and defaults to 0.
143
- - `transport.max_retry_delay_ms` is an integer from 0 through 60000 and
144
- defaults to 5000.
145
- - `local` requires both `base_url` and `api_key_env`. The URL must be HTTP(S),
146
- have a host, contain no embedded credentials, query, or fragment, and use
147
- HTTPS unless it targets `localhost`, `127.0.0.1`, or `::1`. `api_key_env` is
148
- an environment-variable name, not a credential value.
149
-
150
- Transport and local settings affect execution but not authored grading
151
- identity. The evaluator remains responsible for applying defaults, building
152
- requests, and routing execution.
197
+ - `on` and `ai` belong to `online` judges and are rejected on a mission
198
+ judge; `attributes` is rejected on online judges.
153
199
 
154
200
  ## Applicability
155
201
 
@@ -173,10 +219,24 @@ on:
173
219
  sentiment: negative
174
220
  ```
175
221
 
176
- Match keys are non-empty field paths. Regex literals use Rust regex syntax and
177
- support unique `i`, `m`, `s`, and `u` flags. `environment`, `runtime_group`, and
222
+ Match keys are non-empty field paths. Regex literals support unique `i`, `m`,
223
+ `s`, and `u` flags. A pattern must compile both as a Rust regex, which the
224
+ hosted platform evaluates, and as a JavaScript `RegExp`, which the runner
225
+ evaluates. The runner compiles a pattern with the `v` flag and, when that
226
+ refuses it, with the `u` flag, so `[\w-]+` (which only `u` compiles) and
227
+ `[\w--\d]+` (which only `v` compiles) are both valid. The checker reports
228
+ `judge.on.regex_invalid` for a pattern either engine refuses, such as a
229
+ lookahead (`(?=…)`, which Rust refuses) or a Rust named group (`(?P<name>…)`,
230
+ which JavaScript refuses under both flags). `environment`, `runtime_group`, and
178
231
  paths ending in `pattern_id` are platform-owned and cannot appear as authored
179
- match fields. The evaluator owns dotted-path traversal and gate evaluation.
232
+ match fields. The runner owns dotted-path traversal and gate evaluation.
233
+
234
+ The checker compiles the JavaScript side with a Rust implementation of the
235
+ `RegExp` grammar, not with the runner's own engine, and the two differ at the
236
+ edges: the checker accepts `\Afoo\z`, `\-` and `\#`, which the runner refuses,
237
+ and `[[:alpha:]]` is a POSIX class to Rust and a nested class to JavaScript. A
238
+ pattern the checker accepts can therefore still be refused by the runner at
239
+ run time, where it records an error for that judgement.
180
240
 
181
241
  ## Diagnostics
182
242
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@introspection-ai/recipes",
3
- "version": "0.57.0",
3
+ "version": "0.58.0",
4
4
  "description": "The open format for vertical agents, built on Pi.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -65,6 +65,10 @@
65
65
  "types": "./dist/batch/index.d.ts",
66
66
  "import": "./dist/batch/index.js"
67
67
  },
68
+ "./judges": {
69
+ "types": "./dist/judges/index.d.ts",
70
+ "import": "./dist/judges/index.js"
71
+ },
68
72
  "./recipe": {
69
73
  "types": "./dist/recipe/resolve.d.ts",
70
74
  "import": "./dist/recipe/resolve.js"
@@ -142,10 +146,10 @@
142
146
  "@introspection-ai/recipe-productivity-microsoft": ">=0.1.0",
143
147
  "@introspection-ai/recipe-search": ">=0.1.0",
144
148
  "@introspection-ai/recipe-signature": ">=0.1.0",
145
- "@introspection-ai/mcp-client-linux-x64": "0.57.0",
146
- "@introspection-ai/mcp-client-linux-arm64": "0.57.0",
147
- "@introspection-ai/mcp-client-darwin-arm64": "0.57.0",
148
- "@introspection-ai/mcp-client-darwin-x64": "0.57.0"
149
+ "@introspection-ai/mcp-client-linux-x64": "0.58.0",
150
+ "@introspection-ai/mcp-client-linux-arm64": "0.58.0",
151
+ "@introspection-ai/mcp-client-darwin-arm64": "0.58.0",
152
+ "@introspection-ai/mcp-client-darwin-x64": "0.58.0"
149
153
  },
150
154
  "peerDependencies": {
151
155
  "@earendil-works/pi-agent-core": ">=1.1.0 <2.0.0",
@@ -193,7 +197,7 @@
193
197
  "format": "prettier --write \"{src,test,packages,examples}/**/*.{ts,mjs,md}\" \"*.{ts,mjs}\"",
194
198
  "format:check": "prettier --check \"{src,test,packages,examples}/**/*.{ts,mjs,md}\" \"*.{ts,mjs}\"",
195
199
  "knip": "pnpm manifest && pnpm schemas && knip --no-gitignore",
196
- "test": "pnpm build:ts && cargo test -p pi-mcp-client -p introspection-recipe-check && cargo build -p pi-mcp-client && MCP_CLIENT_BIN=target/debug/mcp-client node scripts/package-mcp-client.mjs && vitest run && pnpm --filter './examples' test",
200
+ "test": "pnpm build:ts && cargo test -p pi-mcp-client -p introspection-recipe-check && cargo build -p pi-mcp-client -p introspection-recipe-check && MCP_CLIENT_BIN=target/debug/mcp-client node scripts/package-mcp-client.mjs && vitest run && pnpm --filter './examples' test",
197
201
  "pack:check": "pnpm pack --dry-run --json | node scripts/check-npm-pack.mjs && pnpm --filter './packages/**' pack:check",
198
202
  "clean": "rm -rf dist .turbo node_modules target vendor/mcp-client",
199
203
  "report:tool-modes": "node scripts/tool-modes-report.mjs && prettier --write test/recordings/tool-modes/report.md"