@ouispec/contract 0.11.0 → 0.12.3
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/INTEGRATOR-GUIDE.md +15 -3
- package/package.json +1 -1
package/INTEGRATOR-GUIDE.md
CHANGED
|
@@ -621,7 +621,7 @@ connectBindings({
|
|
|
621
621
|
});
|
|
622
622
|
```
|
|
623
623
|
|
|
624
|
-
Wrap the app in `<AgentBindingProvider registry={registry}>` (from `@ouispec/bindings/react`) so every bound control registers into it. Send `runtime.snapshot()` as the message context with every turn,
|
|
624
|
+
Wrap the app in `<AgentBindingProvider registry={registry}>` (from `@ouispec/bindings/react`) so every bound control registers into it. Send `runtime.snapshot()` as the message context with every turn, pass `runtime.grantApproval` to the agent client as `grantApproval` (see approvals), and `{ subscribe: (listener) => runtime.onSettled(listener) }` as `settledWork` (see resuming after work, below).
|
|
625
625
|
|
|
626
626
|
- `form: 'index'` sends the page's actions as an index and not as definitions (below). It needs an agent worker that reads the index (`agent-sdk-worker` 9 or later). Leave it out for an older worker.
|
|
627
627
|
- `accept` refuses any action request that arrives while the assistant has no turn in progress in this tab.
|
|
@@ -634,12 +634,13 @@ A page's action definitions weigh what its whole catalogue weighs. On a studio p
|
|
|
634
634
|
|
|
635
635
|
- **The snapshot and every answer carry an index of the page's actions.** Each entry has the action's id, title, the first sentence of its description, its effect, and one line saying what it takes ("none", "value: number 0–100 px", "one of 60 shapes by effect"). The line is derived from the action's input schema by rule.
|
|
636
636
|
- **The assistant fetches a definition when it needs one.** The surface runtime answers `oui.describe` itself, with the action's live definition, including options the page loaded at run time.
|
|
637
|
-
- **The assistant has
|
|
637
|
+
- **The assistant has four UI tools, whatever the page offers:**
|
|
638
638
|
- `ui_act` runs one action by its id.
|
|
639
639
|
- `ui_describe` says what actions take. A large input comes back as an outline, and one part of it is opened by path.
|
|
640
640
|
- `ui_read` reads part of the page's state.
|
|
641
|
+
- `ui_wait` waits for work an action started (a job, an export) that was still running when the action's call answered. A call waits for its work's outcome only briefly (20 s by default, `jobWaitMs`), so a turn is never held by a job queued for minutes. Work still going then is reported running, never done. When the rest of the request needs the outcome (to check what was made, or to act on it), the assistant calls `ui_wait`: it waits until the work ends, its own `timeoutMs` passes, or the turn must answer, whichever is first, and answers as the action's call would have, with the outcome and the page after it. A stop ends the wait; the time spent in it does not count as a step's length when the turn decides whether to hand back. Work that ends after the turn is reported by a resumed turn (below).
|
|
641
642
|
|
|
642
|
-
When the client sends knowledge, a
|
|
643
|
+
When the client sends knowledge, a fifth: `ui_guide` reads what the prompt leaves out of it. The knowledge is bounded in the prompt (12,000 characters): small entries whole, a large one cut at a line with how much is left, and workflows by name; `ui_guide` reads the rest of an entry a page at a time, or one workflow with its steps.
|
|
643
644
|
- **The page's index is in the page state the model reads,** with its own budget, so the assistant's context stays about the same size however many actions the app has.
|
|
644
645
|
- **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.
|
|
645
646
|
- **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.
|
|
@@ -649,6 +650,17 @@ A page's action definitions weigh what its whole catalogue weighs. On a studio p
|
|
|
649
650
|
|
|
650
651
|
Nothing here is written per feature: the index, the outlines and the fitting are computed from the declarations.
|
|
651
652
|
|
|
653
|
+
### Resuming after work that outlived its turn
|
|
654
|
+
|
|
655
|
+
When work the assistant started (a job, an export) finishes after the turn that started it has ended, the assistant comes back by itself and reports the outcome in the same chat, as long as the person's window is open. Nobody writes anything; the tab starts the turn.
|
|
656
|
+
|
|
657
|
+
1. **The tab's runtime says the work ended.** `runtime.onSettled(listener)` is called once for each request that was first answered `interim: true`, when its final answer (done, failed, timed out, or abandoned because its surface left the page) has been sent and the realtime server has acknowledged it, so the outcome is in the server's result store (kept 35 minutes). The event names the request, the turn that sent it, the surface and action, and whether the work succeeded (`OUISettledWork`).
|
|
658
|
+
2. **The agent provider decides** (`config.settledWork`, agent-react). It resumes only for a turn of the open conversation that this tab ran and that has ended by itself: answered, handed back for time, failed, or out of time. It never resumes for a turn the person stopped (a stop means stop), one their newer message superseded (the newer turn read the page), one a person on the staff took over, or one that ended waiting for an approval. It does not resume while a turn runs or starts (that turn's page state, or its `ui_wait`, carries the outcome), while a conversation loads, while an approval card or a choice waits on the person, or while a person on the staff holds the conversation. Switching conversations or starting a new one forgets the turns before. Work that ends within 1.5 s of the last goes in one turn (`RESUME_GATHER_MS`, up to 8 requests), and at most 3 turns are started this way in a row before the person writes again (`RESUME_MAX_IN_A_ROW`): a resumed turn may start more work, bounded. Every decision is in the provider's debug log.
|
|
659
|
+
3. **The turn goes through `sendMessage`**, like the turn after an approval: `content` is empty, no message of the person's is shown, the context is what a message carries (so the host attaches the fresh snapshot), and `resume: { requestIds }` (`ResumeContinuation`) names the requests. The platform passes it unchanged to the worker as the turn payload's `resume`, and stores no user message for the empty content. A payload with `resume` takes 1 to 8 non-empty request ids of at most 200 characters, and never also `approval` (`resumeRefusal`).
|
|
660
|
+
4. **The worker reports it.** A request is taken only when this conversation's history holds the tool call with its id (a UI action's request id is its call's id) and that call's latest result still says it is running; any other is left out and logged, so a client never reads another conversation's results, and an outcome is never reported twice. Each one's final answer is read from the realtime server and becomes that call's result, in the words `ui_wait` gives once work ends, in place of "still running": the model reads one call with one result, and the result is stored under the call's own id, so every later turn reads the outcome. In place of a message the model is told that nobody wrote anything, that the turn started because work it started in an earlier turn finished after that turn ended (each named by its declared title), that the outcome is now the call's result, and to tell the person briefly what came of it, checking the page before claiming anything, and to go on with their earlier request if it needed this outcome. A final answer that can no longer be read is said so, with the advice to check the page, and nothing is stored for it. When nothing is left to report, the turn ends at once without calling the model. The turn is marked `resumed` in the worker's logs, its usage line, its result and `recordTurnComplete`.
|
|
661
|
+
|
|
662
|
+
Without `settledWork`, or with the window closed, the outcome reaches the assistant in the page state of the person's next message.
|
|
663
|
+
|
|
652
664
|
## Going to a page, already filtered
|
|
653
665
|
|
|
654
666
|
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.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouispec/contract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.3",
|
|
4
4
|
"description": "The OUI integrator contract: versioned JSON Schemas for the control table, control-kind registration, tier 2 mapping, binding, action effect, room catalog, manifest, knowledge, oui.config.json, approvals and event declarations; the TypeScript types generated from them; a validator; and the integrator guide",
|
|
5
5
|
"homepage": "https://github.com/wesreid/oui/tree/main/packages/contract#readme",
|
|
6
6
|
"bugs": {
|