@ouispec/contract 0.7.0 → 0.9.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.
@@ -41,6 +41,7 @@ Every schema of the contract is versioned together by `MANIFEST_VERSION`, and th
41
41
  | [`json-schema.json`](schemas/json-schema.json) | `JsonSchema` | `https://schemas.closurestudio.ai/oui/v1/json-schema.json` |
42
42
  | [`action-effect.json`](schemas/action-effect.json) | `ActionEffect` | `https://schemas.closurestudio.ai/oui/v1/action-effect.json` |
43
43
  | [`agent-binding.json`](schemas/agent-binding.json) | `AgentBinding` | `https://schemas.closurestudio.ai/oui/v1/agent-binding.json` |
44
+ | [`page-query.json`](schemas/page-query.json) | `PageQuery` | `https://schemas.closurestudio.ai/oui/v1/page-query.json` |
44
45
  | [`control-kind-registration.json`](schemas/control-kind-registration.json) | `ControlKindRegistration` | `https://schemas.closurestudio.ai/oui/v1/control-kind-registration.json` |
45
46
  | [`control-table.json`](schemas/control-table.json) | `ControlTableFile` | `https://schemas.closurestudio.ai/oui/v1/control-table.json` |
46
47
  | [`tier2-mapping.json`](schemas/tier2-mapping.json) | `Tier2Mapping` | `https://schemas.closurestudio.ai/oui/v1/tier2-mapping.json` |
@@ -411,7 +412,7 @@ const catalog: RoomCatalog<LedgerContext> = {
411
412
  };
412
413
  ```
413
414
 
414
- - **`x-rows`** on the list in the observation's schema says how a row is addressed (`ref`), what a person calls it (`title`), and what an index row keeps. A list too long for the page state is cut to index rows, never to a count; the selected rows, and the rows an action just changed, stay whole.
415
+ - **`x-rows`** on the list in the observation's schema says how a row is addressed (`ref`), what a person calls it (`title`), and what an index row keeps, each a property of the row or a dotted path into it (`item.key`). A list too long for the page state is cut to index rows, never to a count; the selected rows, and the rows an action just changed, stay whole.
415
416
  - **`roomReaders`** makes the room's `inspect` (everything about the rows named) and `query` (a list's rows, narrowed by an indexed property or by name, a page at a time). Both only read.
416
417
  - **`x-ref`** on an input that takes a row (`{ type: 'string', ...refTo(POSITIONS) }`) names the list it addresses. The runtime then takes a row's exact name where its id is expected, when one row has it, and refuses an ambiguous one with the ids it could mean.
417
418
  - **`changed`** on an action's result reports the rows it changed, added or removed, each as `inspect` would return it now (`changedRows(lists, ctx, refs)`), so the assistant checks an edit against what the room holds, not against what it meant to do.
@@ -422,9 +423,9 @@ The generator refuses a catalog whose observation lists things with an `id` and
422
423
  >
423
424
  > | Field | Type | Required | What it is |
424
425
  > |---|---|---|---|
425
- > | `ref` | string | yes | The property of a row that actions address it by (`id`). |
426
- > | `title` | string | yes | The property of a row a person calls it by (`name`). |
427
- > | `index` | string[] | | The other properties an index row keeps: the few that tell rows apart (a layer's kind, the artboard it is on). |
426
+ > | `ref` | string | yes | The property of a row that actions address it by (`id`), or a dotted path to it (`item.key`). |
427
+ > | `title` | string | yes | The property of a row a person calls it by (`name`), or a dotted path to it (`item.title`). |
428
+ > | `index` | string[] | | The other properties an index row keeps, each a property or a dotted path: the few that tell rows apart (a layer's kind, the artboard it is on, the display a fact row belongs to). |
428
429
  > | `selection` | string | | The property beside the list, in the same object, that holds the refs of the rows the person has selected. |
429
430
 
430
431
  > **Schema:** [`room-catalog-data.json#/$defs/RoomChangedRow`](schemas/room-catalog-data.json) · `https://schemas.closurestudio.ai/oui/v1/room-catalog-data.json#/$defs/RoomChangedRow` · TypeScript: `RoomChangedRow` from `@ouispec/contract`
@@ -471,6 +472,7 @@ Every input, value and observation schema, here and in tier 1, is written in the
471
472
  > | `x-space` | string | | The frame a length, a point or a fraction is measured in, in the room's own words: `artboard` (from its top left), `canvas`, `layer` (the layer's own content), `artboard-fraction` (0–1 of the artboard's width and height). |
472
473
  > | `x-rows` | RowList | | On an array of objects in an observation: the list is a collection the assistant addresses rows of (a document's layers, its artboards). |
473
474
  > | `x-ref` | string[] | | On a string (or the items of an array of strings) in an action's input: the value addresses a row of one of the surface's `x-rows` lists, each named `<observation id>/<list property>`, or `<observation id>` when the observation itself is the list. |
475
+ > | `x-routes` | string[] | | On one alternative of the generated `app.navigate` action's `query`: the routes whose page takes that query (`/dashboard/service-lane`). |
474
476
  > | `x-enum-omitted` | number | | How many allowed values a shortened `enum` leaves out. |
475
477
  > | `x-oui-attachment` | { as: "file" \| "text", mediaTypes?: string[] } | | On a string with `format: oui-attachment`: what the action takes once the client resolves the attachment's id. |
476
478
 
@@ -636,10 +638,57 @@ A page's action definitions weigh what its whole catalogue weighs. On a studio p
636
638
  - **Only the newest answer carries the page's state to the model.** Every earlier answer of the turn keeps what its action did (its result, the rows it changed, what the page offers since) and says where the state is, so a turn of many actions costs about what one does, plus what each did.
637
639
  - **UI actions are not counted against a per-tool quota:** they run as the person, bounded by the turn's steps and deadline. What is refused is a loop: the same call with the same input, once it has changed nothing three times in a row. Undo five times is five undos.
638
640
  - **Every answer is fitted to a byte budget before it is sent** (480 KB by default, 256 KB for a snapshot). The action's own result is kept whole. Long lists in the page's state are cut first, and the answer says where, so the assistant can read the rest with `ui_read` or a room's `query`.
641
+ - **What a page shows keeps an index too.** A page reports its displays' facts under `shown` in its state, and a display that describes one row of a list (a card each) carries the row as `item`. The page state declares `x-rows` on `shown` (`ref: item.key`, `title: item.title`, `index: [id]`), and the bindings report each display's rows together. Over budget, the page's own facts stay whole, and a long list of cards keeps its first rows whole and the rest as index rows (the display, the row's key and title), the rows an action just changed whole. When even the index does not fit, the list says how many rows are left out and the `ui_read` call (`path: /shown`, `offset`, `limit`) that returns exactly them, one display at a time.
639
642
  - **The assistant never changes a page it cannot see.** After an answer that arrived without the page's state, or no answer, the worker runs only reads until one succeeds. After two refused changes in a row, the assistant stops and tells the person what it could not confirm.
640
643
 
641
644
  Nothing here is written per feature: the index, the outlines and the fitting are computed from the declarations.
642
645
 
646
+ ## Going to a page, already filtered
647
+
648
+ The generator gives every build one navigation surface, `app:navigation`, with one action, `app.navigate` (tool `app_navigate`): go to a page by its address, as following a link does. Its `path` lists every page's route with its title. `connectBindings({ navigation })` runs it with the app's router.
649
+
650
+ A list page that keeps its filters in its address (`/dashboard/service-lane?view=declined&period=this_month`) can be opened by the assistant exactly as the person asked, in one call, when the page declares the query it reads. The page declares it once, where it reads it:
651
+
652
+ ```ts
653
+ import { defineQuery, readQuery, writeQuery } from '@ouispec/bindings';
654
+
655
+ export const LANE_QUERY = defineQuery({
656
+ view: { values: LANE_VIEWS, default: 'lane', description: 'The open lane, or closed repair orders with declined work' },
657
+ period: { values: DECLINED_PERIODS, default: 'this_month', description: 'The declined list’s period' },
658
+ advisor: { type: 'string', description: 'A service advisor, by name as the lane shows it' },
659
+ page: { type: 'integer', minimum: 1, default: 1, description: 'The page of the list' },
660
+ });
661
+
662
+ function ServiceLanePage() {
663
+ const [searchParams, setSearchParams] = useSearchParams();
664
+ const query = readQuery(LANE_QUERY, searchParams); // { view: 'lane' | 'declined', period, advisor?: string, page: number }
665
+ const setView = (view: string) => setSearchParams(writeQuery(LANE_QUERY, searchParams, { view, page: undefined }));
666
+ // …
667
+ }
668
+ ```
669
+
670
+ - `values` is the option list the page's select or tabs already render: strings, or `{ value, label, description }`. Other kinds are `type: 'string'` (free text), `'integer'` or `'number'` (with `minimum`, `maximum`, `unit`), `'boolean'` (`1` on, `0` off) and `'date'` (`YYYY-MM-DD`). `multiple: true` takes several, comma-separated.
671
+ - `readQuery` reads the address as the declaration says: a value the page does not take falls back to its `default` (or is left out), so a hand-edited address never breaks the page. `writeQuery` writes changes back and leaves out a default or empty value, so the plain address stays plain.
672
+ - The generator finds `readQuery(<a defineQuery constant>, …)` in the page, in a component it renders, or in an app hook they call, and fails the build when the declaration is not a build-time constant or does not match the schema below, or when two declarations on one page give the same parameter different meanings.
673
+
674
+ What the build then offers:
675
+
676
+ - `app.navigate` takes `query` beside `path`: one alternative per page that declares one, each with `x-routes` naming its routes and a property per parameter (`enum` and meanings, range, default). `path` names the parameters beside each such page (`/dashboard/service-lane (Service lane; ?view, ?period, ?advisor, ?page)`), and the page's knowledge lists them.
677
+ - `params` fills a route's `:parameters` when `path` is written as its route (`{ "path": "/dashboard/inventory/:unitId", "params": { "unitId": "u 7" } }` goes to `/dashboard/inventory/u%207`).
678
+ - The runtime builds the address from the path, `params` and `query`, encoding each part. It refuses a path that is not one of the build's routes, one that could leave the app (`//host`, a backslash, a scheme, `.` or `..` segments), a query parameter a declaring page does not take, and a value it does not accept, naming what the page takes. A query in `path` itself (`?view=declined`) is read the same way. A page that declares no query takes its address as before.
679
+ - Going to the address the person is already on does nothing, and says so (`alreadyThere`).
680
+
681
+ > **Schema:** [`page-query.json`](schemas/page-query.json) · `https://schemas.closurestudio.ai/oui/v1/page-query.json` · TypeScript: `PageQuery` from `@ouispec/contract`
682
+
683
+ > **Schema:** [`page-query.json#/$defs/QueryChoice`](schemas/page-query.json) · `https://schemas.closurestudio.ai/oui/v1/page-query.json#/$defs/QueryChoice` · TypeScript: `QueryChoice` from `@ouispec/contract`
684
+ >
685
+ > | Field | Type | Required | What it is |
686
+ > |---|---|---|---|
687
+ > | `values` | QueryValue[] | yes | Every value the page takes, each a string or `{ value, label, description }`: the same option list its control renders. |
688
+ > | `description` | string | yes | |
689
+ > | `default` | string | | One of `values`: what the page shows when the address leaves it out. |
690
+ > | `multiple` | boolean | | It takes several of the values, comma-separated in the address (`?signals=a,b`). |
691
+
643
692
  ## Work that outlives the call: the job effect
644
693
 
645
694
  A binding or room action whose work finishes later — a render, an export, an order that fills — declares `effect: { kind: 'job', estimatedDuration?, timeoutMs? }`, and its handler returns `{ ok: true, pending: { jobId } }`. The action is reported `started` at once, then settles on the job's outcome: `complete` when its completion arrives, `failed` when its failure does, and after `timeoutMs` (default five minutes) a `timeout` failure, never a late success. With no tracker, or no job id, it is `unverified`: started, but not confirmable from the page. Three rules make this hold, and the kit checks the first: every `run` returns its callback's result; a job is tracked at dispatch, not at the first poll; a disabled job control is still followed.
@@ -1025,6 +1074,10 @@ A person on the product's staff can take a live conversation from the agent, ans
1025
1074
  | `refusal` | the reply declines (`true`: the usual phrasing; or a matcher) |
1026
1075
  | `doesNotStore` | the matchers appear nowhere the turn stored: its text, its tool arguments, its tool results |
1027
1076
  | `held` | the turn ran no model call, because a person held the conversation |
1077
+ | `calls` | each tool (`tool`), or each of the page's actions run through `ui_act` (`action`, by its id or its index name), was called exactly `times`, or `min` to `max` times (none given: at least once), counting only calls whose arguments or input hold `args` |
1078
+ | `usage` | the turn's model calls stayed within each bound: `modelCalls`, `firstCallInputTokens`, `callInputTokens` (every call), `inputTokens` and `outputTokens` (all of them), and `cachedShare` (the share of its input read from the prompt cache, 0 to 1), as the provider reported them |
1079
+ | `choices` | the turn offered choice buttons (`present_options`) with an option matching each of `options`, a question matching each of `question`, and a `count` of options within its bound (`false`: it offered none) |
1080
+ | `page` | the page is `at` that path after the turn (with a query string, those parameters too), each of `ran` ran on it with input holding `input`, and none of `notRan` did (`*`: nothing) |
1028
1081
 
1029
1082
  ```yaml
1030
1083
  version: 1
@@ -1044,7 +1097,32 @@ scenarios:
1044
1097
  mustNotSay: [{ pattern: "per month|/mo|APR", flags: i }]
1045
1098
  ```
1046
1099
 
1047
- **Every tool is stubbed.** A stub is data in the suite or the scenario (`when`, a subset of the call's arguments; `result`), first match wins, the scenario's first; or a function in the configuration. A call to a tool with no stub fails the scenario: an eval never reaches your backend.
1100
+ **Every tool is stubbed.** A stub is data in the suite or the scenario (`when`, a subset of the call's arguments; `result`), first match wins, the scenario's first; or a function in the configuration. A call to a tool with no stub fails the scenario: an eval never reaches your backend. The SDK's own interaction tools (`present_options`, `confirm_action`, `request_user_decision`) reach no backend, so with no stub they run as they are, and the choices they offer are read from the turn.
1101
+
1102
+ **The person's page.** A suite, or a scenario in its place (`page: false` for none), declares the page its turns are sent from (`AgentEvalPage`). The harness runs it on a real oui-spec surface runtime in index form, sends every turn from wherever the page is, with its snapshot and its address (`oui`, `currentPath`, and `uiKnowledge` when the configuration gives your knowledge), and answers the agent's `ui_act`, `ui_describe` and `ui_read` from it, as the person's tab would. Its surfaces are either declared in the suite (`surfaces`: each one's `routes`, its observations as `state`, and its actions, each with the `result` it answers, the `state` it leaves and the address it goes to, by `cases` on its input), or are your own: give the configuration your generated manifest (`page: { manifest, knowledge }`) and name your controls by binding id (`controls`: each one's value, rows and what it does; `allControls` mounts the rest of a surface's, empty). They are registered with a real binding registry and connected with `connectBindings`, as your tab does, so the agent is offered exactly what your build declares. Going to a page (`app.navigate`) mounts what is at the new address; the next turn is sent from there.
1103
+
1104
+ ```yaml
1105
+ page:
1106
+ at: /dashboard
1107
+ controls:
1108
+ service-lane.view: { value: open }
1109
+ service-lane.declined.advisor: {}
1110
+ scenarios:
1111
+ - id: declined-work-opens-the-lane
1112
+ title: Opens the service lane once, on its declined work, and pastes nothing
1113
+ turns:
1114
+ - user: Show me the declined work
1115
+ expect:
1116
+ page: { at: /dashboard/service-lane, ran: [{ action: service-lane.view, input: { value: declined } }] }
1117
+ calls: [{ action: app.navigate, times: 1 }, { tool: listRepairOrders, times: 0 }]
1118
+ usage: { firstCallInputTokens: { max: 20000 }, callInputTokens: { max: 40000 } }
1119
+ ```
1120
+
1121
+ **Your conversation store.** By default the harness keeps the whole conversation. To run later turns on what your worker really reads (a window that cuts old tool results, a summary, a step context), give the configuration `history`: your store as `EvalHistory` (`append`, `getHistory`, `persistMessages`), or `createMemoryHistory({ window })` with your window over the whole conversation.
1122
+
1123
+ **Your agent's settings.** `agent` returns what your worker runs with, `modelProviderOptions`, `forcedToolChoice` and `uiActions` (its waits and how much of the page the model reads; the channel is the page's) included.
1124
+
1125
+ **The judge.** A rubric's verdict is asked for as structured output, which the provider gives its own way (a JSON schema, a forced tool, or instructions for a model that refuses one); an answer that is still no verdict is read as text, then asked for again (`judgeOptions: { retries, maxOutputTokens }`). A judge that never gives one is reported apart: the case is `unjudged`, not failed (`JUDGE` in the report, an `error` in JUnit, exit 3 when nothing failed).
1048
1126
 
1049
1127
  **Channels.** Your configuration names them, and what each changes: `approvals` (the card, `ui`, or a conversation channel, `chat`, `sms`, `voice`, `phone`, where the readback is sent and the next message confirms it), `input` (what each customer message carries as `context.input`, so a voice channel marks it spoken), and `context`. The turn carries its channel, and the worker tells the model about approvals in that channel's terms. Every scenario runs on every channel of its suite unless it names fewer, so a change that breaks SMS and not web chat fails.
1050
1128
 
@@ -1073,9 +1151,9 @@ export default defineEvals({
1073
1151
  });
1074
1152
  ```
1075
1153
 
1076
- **Run it.** `agent-evals` (in CI: replays the recordings), `agent-evals --record` (runs the live model and writes them), `agent-evals --live` (runs it and writes nothing). `--channel` and `--scenario` narrow a run; `--json` and `--junit` write reports. It exits 1 when any case fails, listing each failed assertion with its turn, channel and the reply. In a test runner, `evalCases(config)` gives one case per scenario and channel, each throwing with every failure.
1154
+ **Run it.** `agent-evals` (in CI: replays the recordings), `agent-evals --record` (runs the live model and writes them), `agent-evals --live` (runs it and writes nothing). `--channel` and `--scenario` narrow a run; `--json` and `--junit` write reports. It exits 1 when any case fails, listing each failed assertion with its turn, channel and the reply, and 3 when none failed but a rubric could not be judged. In a test runner, `evalCases(config)` gives one case per scenario and channel, each throwing with every failure.
1077
1155
 
1078
- **A recording knows what it was recorded against**: your system prompt, your tools' names, descriptions and schemas, the scenario's turns and the channel. Change any of them and its replay fails until you record it again, rather than passing on answers to a question no longer asked.
1156
+ **A recording knows what it was recorded against**: your system prompt, your tools' names, descriptions and schemas, the scenario's turns, its page and the channel. Change any of them and its replay fails until you record it again, rather than passing on answers to a question no longer asked.
1079
1157
 
1080
1158
  The package ships an example: a fake dealer tool set, with scenarios for disclosure, price and no payments, an injected instruction, an SSN refused and not stored, a request for a person, a booking that runs only after its readback is confirmed, and a take-over and hand-back, on web chat, SMS and voice.
1081
1159
 
@@ -1089,6 +1167,7 @@ The package ships an example: a fake dealer tool set, with scenarios for disclos
1089
1167
  > | `channels` | AgentEvalChannelList | | The channels every scenario runs on, as the eval configuration names them (`web_chat`, `sms`, `voice`). |
1090
1168
  > | `context` | object | | What every turn of every scenario carries as its context, before the channel's and the scenario's own. |
1091
1169
  > | `stubs` | AgentEvalStubs | | What each tool returns, for every scenario; a scenario's own stubs come first. |
1170
+ > | `page` | AgentEvalPage | | The person's page, scripted, for every scenario: what it offers at each address and what its actions do. |
1092
1171
  > | `scenarios` | AgentEvalScenario[] | yes | |
1093
1172
 
1094
1173
  > **Schema:** [`agent-evals.json#/$defs/AgentEvalExpectation`](schemas/agent-evals.json) · `https://schemas.closurestudio.ai/oui/v1/agent-evals.json#/$defs/AgentEvalExpectation` · TypeScript: `AgentEvalExpectation` from `@ouispec/contract`
@@ -1103,6 +1182,10 @@ The package ships an example: a fake dealer tool set, with scenarios for disclos
1103
1182
  > | `refusal` | true \| AgentEvalTextMatcher | | The reply declines: `true` for the usual phrasing of a refusal (can't, cannot, unable, not able, won't, not allowed), or a matcher for the agent's own words. |
1104
1183
  > | `doesNotStore` | AgentEvalTextMatcher[] | | None of these appears in anything the turn stored: its text, its tool calls' arguments, its tool results. |
1105
1184
  > | `held` | boolean | | `true`: the turn ran no model call, because a person held the conversation. |
1185
+ > | `calls` | AgentEvalCallCount[] | | How many times each tool, or each of the page's actions, was called in the turn. |
1186
+ > | `usage` | AgentEvalUsage | | What the turn's model calls used, as the provider reported it. |
1187
+ > | `choices` | false \| AgentEvalChoicesExpectation | | The turn offered the person choice buttons (`present_options`) that match; `false`: it offered none. |
1188
+ > | `page` | AgentEvalPageExpectation | | What the page did in the turn, read from the page itself. |
1106
1189
 
1107
1190
  > **Schema:** [`agent-evals.json#/$defs/AgentEvalStubCase`](schemas/agent-evals.json) · `https://schemas.closurestudio.ai/oui/v1/agent-evals.json#/$defs/AgentEvalStubCase` · TypeScript: `AgentEvalStubCase` from `@ouispec/contract`
1108
1191
  >
@@ -1110,3 +1193,43 @@ The package ships an example: a fake dealer tool set, with scenarios for disclos
1110
1193
  > |---|---|---|---|
1111
1194
  > | `when` | object | | |
1112
1195
  > | `result` | { success: boolean, data?: any, error?: string } | yes | |
1196
+
1197
+ > **Schema:** [`agent-evals.json#/$defs/AgentEvalPage`](schemas/agent-evals.json) · `https://schemas.closurestudio.ai/oui/v1/agent-evals.json#/$defs/AgentEvalPage` · TypeScript: `AgentEvalPage` from `@ouispec/contract`
1198
+ >
1199
+ > | Field | Type | Required | What it is |
1200
+ > |---|---|---|---|
1201
+ > | `at` | string | yes | The address the first turn is sent from. |
1202
+ > | `routes` | string[] | | The addresses going to a page accepts, as route patterns (`/leads/:id`), when the manifest declares no navigation surface of its own. |
1203
+ > | `navigation` | boolean | | Whether the page offers going to a page by its address (`app.navigate`), as a generated app does: the manifest's navigation surface, or one made from `routes`, run by the bindings as the product's tab runs it. |
1204
+ > | `surfaces` | AgentEvalPageSurface[] | | Surfaces declared here, each mounted while the page is at one of its routes. |
1205
+ > | `controls` | map of AgentEvalPageControl | | The product's own controls, by binding id in the configuration's manifest: each is mounted while the page is on its surface, with what it shows and what it does. |
1206
+ > | `allControls` | boolean | | Also mount every other control the manifest declares on a surface that is mounted, with no value, as an empty form shows them. |
1207
+
1208
+ > **Schema:** [`agent-evals.json#/$defs/AgentEvalPageAction`](schemas/agent-evals.json) · `https://schemas.closurestudio.ai/oui/v1/agent-evals.json#/$defs/AgentEvalPageAction` · TypeScript: `AgentEvalPageAction` from `@ouispec/contract`
1209
+ >
1210
+ > | Field | Type | Required | What it is |
1211
+ > |---|---|---|---|
1212
+ > | `id` | string | yes | As the page's index names it, and `ui_act` takes it. |
1213
+ > | `title` | string | | |
1214
+ > | `description` | string | yes | |
1215
+ > | `effect` | "view" \| "selection" \| "navigate" \| "open" \| "edit" \| "file" \| … | | What it changes (oui-spec's effect kinds). |
1216
+ > | `confirm` | boolean | | It asks the person to approve it first. |
1217
+ > | `input` | object | | What it takes, as a JSON Schema. |
1218
+ > | `result` | { success: boolean, data?: any, error?: string } | | What it answers. |
1219
+ > | `state` | object | | Its surface's observations once it has run, by observation id: each given replaces the one before. |
1220
+ > | `navigate` | string | | The address the page goes to once it has run. |
1221
+ > | `cases` | { when?: object, result?: { success: boolean, data?: any, error?: string }, state?: object, navigate?: string }[] | | What it does for a call whose input holds `when`, the first that matches; a call none matches gets the defaults beside them. |
1222
+
1223
+ > **Schema:** [`agent-evals.json#/$defs/AgentEvalPageControl`](schemas/agent-evals.json) · `https://schemas.closurestudio.ai/oui/v1/agent-evals.json#/$defs/AgentEvalPageControl` · TypeScript: `AgentEvalPageControl` from `@ouispec/contract`
1224
+ >
1225
+ > | Field | Type | Required | What it is |
1226
+ > |---|---|---|---|
1227
+ > | `value` | any | | What it shows when the page opens. |
1228
+ > | `title` | string | | What it is called on screen. |
1229
+ > | `valueSchema` | object | | Its live value schema (its options, its range), within the manifest's. |
1230
+ > | `disabled` | boolean | | It cannot be used: it is not offered. |
1231
+ > | `rows` | { key: string, title: string, description?: string, value?: any }[] | | For a list's control: one per row shown. |
1232
+ > | `routes` | string[] | | Where it is mounted, when not wherever its surface is. |
1233
+ > | `result` | { success: boolean, data?: any, error?: string } | | What it answers. |
1234
+ > | `navigate` | string | | The address the page goes to once it has run. |
1235
+ > | `cases` | { when?: object, result?: { success: boolean, data?: any, error?: string }, navigate?: string }[] | | What it does for a call whose input holds `when`, the first that matches; a call none matches gets the defaults beside them. |
@@ -12,7 +12,7 @@ export declare const CONTRACT_SCHEMA_BASE = "https://schemas.closurestudio.ai/ou
12
12
  * It is what assistant tool inputs are written in, so a declared or derived schema is used as
13
13
  * is. `x-unit` names the unit a number is in: `px`, `%`, `°`; `x-space` names the frame it is
14
14
  * measured in; `x-rows` and `x-ref` say which lists hold addressable rows and which inputs
15
- * address them.
15
+ * address them; `x-routes` says which pages a navigation query belongs to.
16
16
  */
17
17
  export interface JsonSchema {
18
18
  type?: JsonSchemaType | readonly JsonSchemaType[];
@@ -66,6 +66,12 @@ export interface JsonSchema {
66
66
  * its exact title when one row has it.
67
67
  */
68
68
  'x-ref'?: readonly string[];
69
+ /**
70
+ * On one alternative of the generated `app.navigate` action's `query`: the routes whose page
71
+ * takes that query (`/dashboard/service-lane`). The page declares it (`page-query.json`); the
72
+ * navigation runtime checks a call's query against the alternative of the route it goes to.
73
+ */
74
+ 'x-routes'?: readonly string[];
69
75
  /**
70
76
  * How many allowed values a shortened `enum` leaves out. Only in the page state, where a
71
77
  * row's options are summarised; a tool's input schema always lists every value.
@@ -84,13 +90,18 @@ export interface JsonSchema {
84
90
  }
85
91
  /** How the rows of a list are addressed and indexed. */
86
92
  export interface RowList {
87
- /** The property of a row that actions address it by (`id`). */
93
+ /**
94
+ * The property of a row that actions address it by (`id`), or a dotted path to it
95
+ * (`item.key`).
96
+ */
88
97
  ref: string;
89
- /** The property of a row a person calls it by (`name`). */
98
+ /**
99
+ * The property of a row a person calls it by (`name`), or a dotted path to it (`item.title`).
100
+ */
90
101
  title: string;
91
102
  /**
92
- * The other properties an index row keeps: the few that tell rows apart (a layer's kind, the
93
- * artboard it is on).
103
+ * The other properties an index row keeps, each a property or a dotted path: the few that
104
+ * tell rows apart (a layer's kind, the artboard it is on, the display a fact row belongs to).
94
105
  */
95
106
  index?: readonly string[];
96
107
  /**
@@ -253,6 +264,89 @@ export interface NonAgentBinding {
253
264
  }
254
265
  /** The `agent` prop of a single-purpose control. */
255
266
  export type AgentProp = AgentBinding | NonAgentBinding;
267
+ /**
268
+ * The query parameters a page reads from its address (`?view=declined&period=this_month`), each
269
+ * by name, declared once with `defineQuery` and read with `readQuery` (`@ouispec/bindings`).
270
+ * The generator reads the declaration where the page, a component it renders or an app hook
271
+ * they call reads it, and the generated `app.navigate` takes it, so the assistant opens the
272
+ * page already filtered to a question, in one call. A page that declares none takes its address
273
+ * as before.
274
+ *
275
+ * **Every value is a build-time constant**, as a binding's are: a literal, a `const` it can
276
+ * follow (an imported option list too), a property of a constant object, or a template literal
277
+ * or `+` over those.
278
+ */
279
+ export type PageQuery = Readonly<Record<string, QueryParam>>;
280
+ /**
281
+ * One query parameter: free text, a number, an on/off flag, a day, or one of a list of values.
282
+ */
283
+ export type QueryParam = QueryText | QueryNumber | QueryFlag | QueryDate | QueryChoice;
284
+ /** Free text: a name as the page shows it, a search. */
285
+ export interface QueryText {
286
+ type: 'string';
287
+ /**
288
+ * What the value picks, for someone who cannot see the screen: what to pass and where it
289
+ * comes from.
290
+ */
291
+ description: string;
292
+ /** What the page shows when the address leaves it out. */
293
+ default?: string;
294
+ maxLength?: number;
295
+ /**
296
+ * It takes several values, written comma-separated in the address (`?tags=a,b`). A value
297
+ * cannot hold a comma.
298
+ */
299
+ multiple?: boolean;
300
+ }
301
+ /** A number: a page of a list (`integer`, from 1), a minimum score. */
302
+ export interface QueryNumber {
303
+ type: 'integer' | 'number';
304
+ description: string;
305
+ default?: number;
306
+ minimum?: number;
307
+ maximum?: number;
308
+ /** The unit the number is in (`%`, `days`, `$`), as `x-unit` names it. */
309
+ unit?: string;
310
+ }
311
+ /** On or off: `1` in the address is on, `0` or nothing is off (unless its default is on). */
312
+ export interface QueryFlag {
313
+ type: 'boolean';
314
+ description: string;
315
+ default?: boolean;
316
+ }
317
+ /** A day, `YYYY-MM-DD`. */
318
+ export interface QueryDate {
319
+ type: 'date';
320
+ description: string;
321
+ /** `YYYY-MM-DD`. */
322
+ default?: string;
323
+ }
324
+ /**
325
+ * One of a list of values (a view, a period, a status): the list a select or tabs already show,
326
+ * by value and label.
327
+ */
328
+ export interface QueryChoice {
329
+ /**
330
+ * Every value the page takes, each a string or `{ value, label, description }`: the same
331
+ * option list its control renders.
332
+ */
333
+ values: readonly QueryValue[];
334
+ description: string;
335
+ /** One of `values`: what the page shows when the address leaves it out. */
336
+ default?: string;
337
+ /** It takes several of the values, comma-separated in the address (`?signals=a,b`). */
338
+ multiple?: boolean;
339
+ }
340
+ /**
341
+ * One value of a choice: the value, or the value with what a person calls it and what it means.
342
+ */
343
+ export type QueryValue = string | {
344
+ value: string;
345
+ /** What a person calls it (`Declined work`). */
346
+ label?: string;
347
+ /** What it means, when its label does not say. */
348
+ description?: string;
349
+ };
256
350
  /**
257
351
  * A control kind a design system adds. `ControlKind` is closed: a design system adds a kind
258
352
  * only by registering it, under an `x-` name. The registration ships in the design system's
@@ -1733,6 +1827,12 @@ export interface AgentEvalSuite {
1733
1827
  context?: Readonly<Record<string, unknown>>;
1734
1828
  /** What each tool returns, for every scenario; a scenario's own stubs come first. */
1735
1829
  stubs?: AgentEvalStubs;
1830
+ /**
1831
+ * The person's page, scripted, for every scenario: what it offers at each address and what
1832
+ * its actions do. Each turn is sent from it, and the agent's page actions are answered by it.
1833
+ * A scenario's own `page` replaces it.
1834
+ */
1835
+ page?: AgentEvalPage;
1736
1836
  scenarios: readonly AgentEvalScenario[];
1737
1837
  }
1738
1838
  /** Channel names, as the eval configuration names them. */
@@ -1750,6 +1850,10 @@ export interface AgentEvalScenario {
1750
1850
  context?: Readonly<Record<string, unknown>>;
1751
1851
  /** What each tool returns in this scenario, before the suite's stubs. */
1752
1852
  stubs?: AgentEvalStubs;
1853
+ /**
1854
+ * The page this scenario's turns are sent from, in place of the suite's; `false`: no page.
1855
+ */
1856
+ page?: false | AgentEvalPage;
1753
1857
  turns: readonly AgentEvalTurn[];
1754
1858
  }
1755
1859
  /**
@@ -1846,6 +1950,17 @@ export interface AgentEvalExpectation {
1846
1950
  doesNotStore?: readonly AgentEvalTextMatcher[];
1847
1951
  /** `true`: the turn ran no model call, because a person held the conversation. */
1848
1952
  held?: boolean;
1953
+ /** How many times each tool, or each of the page's actions, was called in the turn. */
1954
+ calls?: readonly AgentEvalCallCount[];
1955
+ /** What the turn's model calls used, as the provider reported it. */
1956
+ usage?: AgentEvalUsage;
1957
+ /**
1958
+ * The turn offered the person choice buttons (`present_options`) that match; `false`: it
1959
+ * offered none.
1960
+ */
1961
+ choices?: false | AgentEvalChoicesExpectation;
1962
+ /** What the page did in the turn, read from the page itself. */
1963
+ page?: AgentEvalPageExpectation;
1849
1964
  }
1850
1965
  /** What must also hold on one channel, by its name. */
1851
1966
  export type AgentEvalExpectationsByChannel = Readonly<Record<string, AgentEvalExpectation>>;
@@ -1867,4 +1982,228 @@ export interface AgentEvalStubCase {
1867
1982
  * backend.
1868
1983
  */
1869
1984
  export type AgentEvalStubs = Readonly<Record<string, readonly AgentEvalStubCase[]>>;
1985
+ /**
1986
+ * The person's page, scripted. The harness runs it on a real oui-spec surface runtime in index
1987
+ * form, sends each turn from where it is (its address and its snapshot, as the person's tab
1988
+ * sends them), and answers the agent's page actions (`ui_act`, `ui_describe`, `ui_read`) from
1989
+ * it. Its surfaces are declared here, or are the product's own: the controls of its generated
1990
+ * manifest, given to the configuration (`page.manifest`), mounted as its tab mounts them.
1991
+ */
1992
+ export interface AgentEvalPage {
1993
+ /**
1994
+ * The address the first turn is sent from. Each later turn is sent from wherever the page is
1995
+ * by then.
1996
+ */
1997
+ at: string;
1998
+ /**
1999
+ * The addresses going to a page accepts, as route patterns (`/leads/:id`), when the manifest
2000
+ * declares no navigation surface of its own. Default: every surface's routes, the manifest's
2001
+ * pages, and `at`.
2002
+ */
2003
+ routes?: readonly string[];
2004
+ /**
2005
+ * Whether the page offers going to a page by its address (`app.navigate`), as a generated app
2006
+ * does: the manifest's navigation surface, or one made from `routes`, run by the bindings as
2007
+ * the product's tab runs it. Default: true.
2008
+ */
2009
+ navigation?: boolean;
2010
+ /** Surfaces declared here, each mounted while the page is at one of its routes. */
2011
+ surfaces?: readonly AgentEvalPageSurface[];
2012
+ /**
2013
+ * The product's own controls, by binding id in the configuration's manifest: each is mounted
2014
+ * while the page is on its surface, with what it shows and what it does.
2015
+ */
2016
+ controls?: Readonly<Record<string, AgentEvalPageControl>>;
2017
+ /**
2018
+ * Also mount every other control the manifest declares on a surface that is mounted, with no
2019
+ * value, as an empty form shows them. A list's per-row controls are not: no row is rendered.
2020
+ * Default: false.
2021
+ */
2022
+ allControls?: boolean;
2023
+ }
2024
+ /** A surface of the page: its actions, and what it reports. */
2025
+ export interface AgentEvalPageSurface {
2026
+ id: string;
2027
+ name: string;
2028
+ description: string;
2029
+ /** Where it is mounted, as route patterns. Absent: on every page, as a shell is. */
2030
+ routes?: readonly string[];
2031
+ /** What it reports when the page opens, by observation id. */
2032
+ state?: Readonly<Record<string, unknown>>;
2033
+ actions: readonly AgentEvalPageAction[];
2034
+ }
2035
+ /** An action of a declared surface, and what it does when it runs. */
2036
+ export interface AgentEvalPageAction {
2037
+ /** As the page's index names it, and `ui_act` takes it. */
2038
+ id: string;
2039
+ title?: string;
2040
+ description: string;
2041
+ /** What it changes (oui-spec's effect kinds). */
2042
+ effect?: 'view' | 'selection' | 'navigate' | 'open' | 'edit' | 'file' | 'mutate' | 'job' | 'transaction';
2043
+ /** It asks the person to approve it first. */
2044
+ confirm?: boolean;
2045
+ /** What it takes, as a JSON Schema. Default: nothing. */
2046
+ input?: Record<string, unknown>;
2047
+ /** What it answers. Default: it succeeds, returning nothing. */
2048
+ result?: {
2049
+ success: boolean;
2050
+ data?: unknown;
2051
+ error?: string;
2052
+ };
2053
+ /**
2054
+ * Its surface's observations once it has run, by observation id: each given replaces the one
2055
+ * before.
2056
+ */
2057
+ state?: Readonly<Record<string, unknown>>;
2058
+ /** The address the page goes to once it has run. */
2059
+ navigate?: string;
2060
+ /**
2061
+ * What it does for a call whose input holds `when`, the first that matches; a call none
2062
+ * matches gets the defaults beside them.
2063
+ */
2064
+ cases?: readonly {
2065
+ /** A subset of its input; absent: any call. */
2066
+ when?: Readonly<Record<string, unknown>>;
2067
+ /** What it answers. Default: it succeeds, returning nothing. */
2068
+ result?: {
2069
+ success: boolean;
2070
+ data?: unknown;
2071
+ error?: string;
2072
+ };
2073
+ /**
2074
+ * Its surface's observations once it has run, by observation id: each given replaces the
2075
+ * one before.
2076
+ */
2077
+ state?: Readonly<Record<string, unknown>>;
2078
+ /** The address the page goes to once it has run. */
2079
+ navigate?: string;
2080
+ }[];
2081
+ }
2082
+ /**
2083
+ * One of the product's controls, as the page shows it, and what it does when it runs (default:
2084
+ * it takes the value it is given, and succeeds).
2085
+ */
2086
+ export interface AgentEvalPageControl {
2087
+ /** What it shows when the page opens. A run sets it to the value it was given. */
2088
+ value?: unknown;
2089
+ /** What it is called on screen. Default: the manifest's title. */
2090
+ title?: string;
2091
+ /** Its live value schema (its options, its range), within the manifest's. */
2092
+ valueSchema?: Record<string, unknown>;
2093
+ /** It cannot be used: it is not offered. */
2094
+ disabled?: boolean;
2095
+ /** For a list's control: one per row shown. */
2096
+ rows?: readonly {
2097
+ key: string;
2098
+ title: string;
2099
+ description?: string;
2100
+ value?: unknown;
2101
+ }[];
2102
+ /** Where it is mounted, when not wherever its surface is. */
2103
+ routes?: readonly string[];
2104
+ /** What it answers. Default: it succeeds, returning nothing. */
2105
+ result?: {
2106
+ success: boolean;
2107
+ data?: unknown;
2108
+ error?: string;
2109
+ };
2110
+ /** The address the page goes to once it has run. */
2111
+ navigate?: string;
2112
+ /**
2113
+ * What it does for a call whose input holds `when`, the first that matches; a call none
2114
+ * matches gets the defaults beside them.
2115
+ */
2116
+ cases?: readonly {
2117
+ /** A subset of its input; absent: any call. */
2118
+ when?: Readonly<Record<string, unknown>>;
2119
+ /** What it answers. Default: it succeeds, returning nothing. */
2120
+ result?: {
2121
+ success: boolean;
2122
+ data?: unknown;
2123
+ error?: string;
2124
+ };
2125
+ /** The address the page goes to once it has run. */
2126
+ navigate?: string;
2127
+ }[];
2128
+ }
2129
+ /** A number at least `min` and at most `max`. */
2130
+ export interface AgentEvalBound {
2131
+ min?: number;
2132
+ max?: number;
2133
+ }
2134
+ /** A share, from 0 to 1, at least `min` and at most `max`. */
2135
+ export interface AgentEvalShareBound {
2136
+ min?: number;
2137
+ max?: number;
2138
+ }
2139
+ /**
2140
+ * The calls of one tool (`tool`), or of one of the page's actions run through `ui_act`
2141
+ * (`action`, by its id or the name the page's index gives it), whose arguments (a tool's) or
2142
+ * input (an action's) hold `args` as a subset, counted: exactly `times`, or at least `min` and
2143
+ * at most `max`. With none of the three: at least once.
2144
+ */
2145
+ export type AgentEvalCallCount = {
2146
+ tool: string;
2147
+ args?: Readonly<Record<string, unknown>>;
2148
+ times?: number;
2149
+ min?: number;
2150
+ max?: number;
2151
+ } | {
2152
+ action: string;
2153
+ args?: Readonly<Record<string, unknown>>;
2154
+ times?: number;
2155
+ min?: number;
2156
+ max?: number;
2157
+ };
2158
+ /**
2159
+ * Bounds on what the turn's model calls used, as the provider reported it. Every bound given
2160
+ * must hold.
2161
+ */
2162
+ export interface AgentEvalUsage {
2163
+ /** How many model calls the turn made. */
2164
+ modelCalls?: AgentEvalBound;
2165
+ /**
2166
+ * The input tokens of the turn's first model call: what the turn costs before it has done
2167
+ * anything.
2168
+ */
2169
+ firstCallInputTokens?: AgentEvalBound;
2170
+ /**
2171
+ * The input tokens of every one of the turn's model calls: `max` holds the largest, `min` the
2172
+ * smallest.
2173
+ */
2174
+ callInputTokens?: AgentEvalBound;
2175
+ /** The input tokens of all the turn's model calls together. */
2176
+ inputTokens?: AgentEvalBound;
2177
+ /** The output tokens of all the turn's model calls together. */
2178
+ outputTokens?: AgentEvalBound;
2179
+ /** The share of the turn's input tokens read from the prompt cache. */
2180
+ cachedShare?: AgentEvalShareBound;
2181
+ }
2182
+ /** The choice buttons the turn offered (`present_options`). */
2183
+ export interface AgentEvalChoicesExpectation {
2184
+ /** Each matches one option offered: its label, or its label and description. */
2185
+ options?: readonly AgentEvalTextMatcher[];
2186
+ /** Each matches what is asked with them: the question, and what it says before it. */
2187
+ question?: readonly AgentEvalTextMatcher[];
2188
+ /** How many options were offered. */
2189
+ count?: AgentEvalBound;
2190
+ }
2191
+ /** What the page did in the turn: where it is, and what ran on it. */
2192
+ export interface AgentEvalPageExpectation {
2193
+ /**
2194
+ * Where the page is after the turn: this path, and each query parameter given with the value
2195
+ * given.
2196
+ */
2197
+ at?: string;
2198
+ /**
2199
+ * Each ran on the page in the turn (by its id or its index name), its input holding `input`
2200
+ * as a subset.
2201
+ */
2202
+ ran?: readonly {
2203
+ action: string;
2204
+ input?: Readonly<Record<string, unknown>>;
2205
+ }[];
2206
+ /** None of these ran on the page in the turn; `*`: nothing did. */
2207
+ notRan?: readonly string[];
2208
+ }
1870
2209
  //# sourceMappingURL=contract.d.ts.map