oui-spec 0.6.1 → 0.7.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 (47) hide show
  1. package/README.md +22 -9
  2. package/dist/chunk-2CPOHQGI.cjs +463 -0
  3. package/dist/chunk-2CPOHQGI.cjs.map +1 -0
  4. package/dist/{chunk-VQETSIY5.js → chunk-4MEYE6XZ.js} +244 -37
  5. package/dist/chunk-4MEYE6XZ.js.map +1 -0
  6. package/dist/{chunk-AFNWLRKV.cjs → chunk-DOJXITEZ.cjs} +248 -41
  7. package/dist/chunk-DOJXITEZ.cjs.map +1 -0
  8. package/dist/{chunk-F3SKRAGU.cjs → chunk-FSGB5JNJ.cjs} +5 -3
  9. package/dist/chunk-FSGB5JNJ.cjs.map +1 -0
  10. package/dist/chunk-RZUYWZFK.js +431 -0
  11. package/dist/chunk-RZUYWZFK.js.map +1 -0
  12. package/dist/{chunk-NYCJZQSP.js → chunk-UOTAHGIV.js} +5 -3
  13. package/dist/chunk-UOTAHGIV.js.map +1 -0
  14. package/dist/core/index.cjs +6 -6
  15. package/dist/core/index.d.cts +5 -5
  16. package/dist/core/index.d.ts +5 -5
  17. package/dist/core/index.js +2 -2
  18. package/dist/index.cjs +108 -20
  19. package/dist/index.d.cts +4 -4
  20. package/dist/index.d.ts +4 -4
  21. package/dist/index.js +3 -3
  22. package/dist/react/index.cjs +6 -6
  23. package/dist/react/index.d.cts +7 -6
  24. package/dist/react/index.d.ts +7 -6
  25. package/dist/react/index.js +1 -1
  26. package/dist/spec/index.cjs +98 -10
  27. package/dist/spec/index.d.cts +76 -4
  28. package/dist/spec/index.d.ts +76 -4
  29. package/dist/spec/index.js +1 -1
  30. package/dist/{surface-runtime-D5nINY4b.d.ts → surface-runtime-BPEtT3LZ.d.ts} +30 -6
  31. package/dist/{surface-runtime-CSZ9UtBO.d.cts → surface-runtime-CexHqUn-.d.cts} +30 -6
  32. package/dist/transport/index.d.cts +3 -3
  33. package/dist/transport/index.d.ts +3 -3
  34. package/dist/{types-CmJb1BQ8.d.cts → types-CnlVRPFL.d.cts} +92 -2
  35. package/dist/{types-CmJb1BQ8.d.ts → types-CnlVRPFL.d.ts} +92 -2
  36. package/dist/{websocket-Ce3tDSsJ.d.ts → websocket-DKL9qoO-.d.ts} +1 -1
  37. package/dist/{websocket-Ds2Rh_jL.d.cts → websocket-HnzPlfk6.d.cts} +1 -1
  38. package/package.json +1 -1
  39. package/spec/OUI-SPEC-v0.1.md +116 -7
  40. package/dist/chunk-AFNWLRKV.cjs.map +0 -1
  41. package/dist/chunk-B2EFZMGY.js +0 -159
  42. package/dist/chunk-B2EFZMGY.js.map +0 -1
  43. package/dist/chunk-F3SKRAGU.cjs.map +0 -1
  44. package/dist/chunk-LDECTDPU.cjs +0 -169
  45. package/dist/chunk-LDECTDPU.cjs.map +0 -1
  46. package/dist/chunk-NYCJZQSP.js.map +0 -1
  47. package/dist/chunk-VQETSIY5.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { m as OUISurface } from '../types-CmJb1BQ8.js';
2
- export { A as ARGS_HASH_PATTERN, J as JSONSchema, O as OUIAction, a as OUIActionApproval, b as OUIActionPolling, c as OUIActionRequest, d as OUIActionResult, e as OUIActivation, f as OUIApprovalGrant, g as OUIEffectKind, h as OUIObservation, i as OUIObservationSnapshot, j as OUIObservationUpdate, k as OUIProtocolEvent, l as OUIResultDelivery, n as OUISurfaceDeregistration, o as OUISurfaceRegistration, p as OUISurfaceSnapshot, q as OUI_EFFECT_ACCESS, r as OUI_EFFECT_KINDS, s as OUI_PROTOCOL_EVENTS, t as argsHash, u as canonicalJson, v as effectAccess, w as requiresApproval } from '../types-CmJb1BQ8.js';
1
+ import { r as OUISurface, t as OUISurfaceIndex, J as JSONSchema, O as OUIAction, b as OUIActionIndexEntry, n as OUIObservationSnapshot, k as OUIFitCut } from '../types-CnlVRPFL.js';
2
+ export { A as ARGS_HASH_PATTERN, a as OUIActionApproval, c as OUIActionPolling, d as OUIActionRequest, e as OUIActionResult, f as OUIActivation, g as OUIApprovalGrant, h as OUIClientSnapshot, i as OUIEffectKind, j as OUIFit, l as OUIIndexSnapshot, m as OUIObservation, o as OUIObservationUpdate, p as OUIProtocolEvent, q as OUIResultDelivery, s as OUISurfaceDeregistration, u as OUISurfaceRegistration, v as OUISurfaceSnapshot, w as OUI_EFFECT_ACCESS, x as OUI_EFFECT_KINDS, y as OUI_PROTOCOL_EVENTS, z as argsHash, B as canonicalJson, C as effectAccess, D as requiresApproval } from '../types-CnlVRPFL.js';
3
3
 
4
4
  /**
5
5
  * The identity of a set of surfaces, for an answer that need not repeat them
@@ -22,6 +22,78 @@ export { A as ARGS_HASH_PATTERN, J as JSONSchema, O as OUIAction, a as OUIAction
22
22
  */
23
23
 
24
24
  /** `surfaces`' hash, as a result's `surfacesHash` and a request's `knownSurfaces` carry it. */
25
- declare function surfacesHash(surfaces: readonly OUISurface[]): string;
25
+ declare function surfacesHash(surfaces: readonly OUISurface[] | readonly OUISurfaceIndex[]): string;
26
+ /**
27
+ * JSON with every object's keys sorted, and what JSON cannot carry dropped as
28
+ * JSON.stringify drops it. Not approval.ts's `canonicalJson`, which refuses
29
+ * such values on purpose (an approval must hash exactly what crosses the
30
+ * wire): a snapshot is taken on every answer, and must never throw on a
31
+ * manifest that carries, say, an `undefined` in an array.
32
+ */
33
+ declare function sortedJson(value: unknown): string;
34
+
35
+ /** The longest description an index entry carries. */
36
+ declare const INDEX_DESCRIPTION_CHARS = 160;
37
+ /** The longest input line an index entry carries. */
38
+ declare const INDEX_INPUT_CHARS = 120;
39
+ /** How many of an input's properties its line names before "+N more". */
40
+ declare const INDEX_INPUT_PROPERTIES = 6;
41
+ /** The surface id the runtime itself answers (§7.3.10). No surface may be defined with it. */
42
+ declare const OUI_RUNTIME_SURFACE = "oui";
43
+ /** `oui.describe`: the full definitions of the actions asked for. */
44
+ declare const OUI_DESCRIBE_ACTION = "describe";
45
+ /** `oui.read`: part of an observation's value, by path, a page of a list at a time. */
46
+ declare const OUI_READ_ACTION = "read";
47
+ /** The bytes `text` takes as UTF-8, which is what a frame's size limit counts. */
48
+ declare function utf8Length(text: string): number;
49
+ /** The bytes `value` takes as JSON on the wire; 0 for what JSON drops. */
50
+ declare function jsonBytes(value: unknown): number;
51
+ /** A description's first sentence, on one line, at most `INDEX_DESCRIPTION_CHARS` characters. */
52
+ declare function firstSentence(text: string): string;
53
+ /**
54
+ * The property every member of a union fixes to its own constant, which is
55
+ * what tells the members apart: `effect` in `{ effect: "glow", … } | { effect:
56
+ * "blur", … }`. Null when the members share no such property.
57
+ */
58
+ declare function discriminatorOf(members: readonly JSONSchema[]): string | null;
59
+ /** The one value a schema allows, when it allows one. */
60
+ declare function constantOf(schema: JSONSchema | undefined): string | number | boolean | undefined;
61
+ /**
62
+ * What an action takes, in one line of at most `INDEX_INPUT_CHARS` characters:
63
+ * - "none" for an action that takes nothing;
64
+ * - each property with its type, required ones first, optional ones marked
65
+ * "?", the first `INDEX_INPUT_PROPERTIES` of them, then "+N more";
66
+ * - "one of N shapes by <property>" for a union.
67
+ */
68
+ declare function summarizeInput(schema: JSONSchema | undefined): string;
69
+ /** The hash of an action's definition, as an index entry's `definitionHash` carries it. */
70
+ declare function definitionHash(action: OUIAction): string;
71
+ /** An action's index entry (§7.3.8). */
72
+ declare function indexEntry(action: OUIAction): OUIActionIndexEntry;
73
+ /** A surface in index form (§7.3.8). */
74
+ declare function surfaceIndex(surface: OUISurface): OUISurfaceIndex;
75
+
76
+ /** Rows a list keeps at each step of fitting, until the whole fits. */
77
+ declare const FIT_LIST_STEPS: readonly [200, 50, 20, 5, 0];
78
+ /** Characters a text keeps once lists alone did not make the whole fit. */
79
+ declare const FIT_TEXT_CHARS = 2000;
80
+ /** One step into a JSON Pointer (RFC 6901). */
81
+ declare function pointerStep(pointer: string, key: string | number): string;
82
+ /** The steps of a JSON Pointer; "" is no steps. Throws on a pointer that does not start with "/". */
83
+ declare function pointerSteps(pointer: string): string[];
84
+ /** The value a pointer names inside `value`, or `undefined` when nothing is there. */
85
+ declare function atPointer(value: unknown, pointer: string): unknown;
86
+ /**
87
+ * `observations` within `budget` bytes of JSON, and where they were cut.
88
+ * Returned as they are when they already fit; otherwise a copy is shortened:
89
+ * 1. every list longer than a step of `FIT_LIST_STEPS` is cut to it, a step at
90
+ * a time, until the whole fits;
91
+ * 2. then every text longer than `FIT_TEXT_CHARS` is cut to that;
92
+ * 3. then whole observation values are left out, the largest first.
93
+ */
94
+ declare function fitObservations(observations: OUIObservationSnapshot, budget: number): {
95
+ observations: OUIObservationSnapshot;
96
+ cuts: OUIFitCut[];
97
+ };
26
98
 
27
- export { OUISurface, surfacesHash };
99
+ export { FIT_LIST_STEPS, FIT_TEXT_CHARS, INDEX_DESCRIPTION_CHARS, INDEX_INPUT_CHARS, INDEX_INPUT_PROPERTIES, JSONSchema, OUIAction, OUIActionIndexEntry, OUIFitCut, OUIObservationSnapshot, OUISurface, OUISurfaceIndex, OUI_DESCRIBE_ACTION, OUI_READ_ACTION, OUI_RUNTIME_SURFACE, atPointer, constantOf, definitionHash, discriminatorOf, firstSentence, fitObservations, indexEntry, jsonBytes, pointerStep, pointerSteps, sortedJson, summarizeInput, surfaceIndex, surfacesHash, utf8Length };
@@ -1,3 +1,3 @@
1
- export { ARGS_HASH_PATTERN, OUI_EFFECT_ACCESS, OUI_EFFECT_KINDS, OUI_PROTOCOL_EVENTS, argsHash, canonicalJson, effectAccess, requiresApproval, surfacesHash } from '../chunk-B2EFZMGY.js';
1
+ export { ARGS_HASH_PATTERN, FIT_LIST_STEPS, FIT_TEXT_CHARS, INDEX_DESCRIPTION_CHARS, INDEX_INPUT_CHARS, INDEX_INPUT_PROPERTIES, OUI_DESCRIBE_ACTION, OUI_EFFECT_ACCESS, OUI_EFFECT_KINDS, OUI_PROTOCOL_EVENTS, OUI_READ_ACTION, OUI_RUNTIME_SURFACE, argsHash, atPointer, canonicalJson, constantOf, definitionHash, discriminatorOf, effectAccess, firstSentence, fitObservations, indexEntry, jsonBytes, pointerStep, pointerSteps, requiresApproval, sortedJson, summarizeInput, surfaceIndex, surfacesHash, utf8Length } from '../chunk-RZUYWZFK.js';
2
2
  //# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
- import { g as OUIEffectKind, J as JSONSchema, b as OUIActionPolling, e as OUIActivation, m as OUISurface, p as OUISurfaceSnapshot, c as OUIActionRequest, d as OUIActionResult, f as OUIApprovalGrant } from './types-CmJb1BQ8.js';
2
- import { S as SocketLike, e as OUITransportConfig } from './websocket-Ce3tDSsJ.js';
1
+ import { i as OUIEffectKind, J as JSONSchema, c as OUIActionPolling, f as OUIActivation, r as OUISurface, l as OUIIndexSnapshot, v as OUISurfaceSnapshot, d as OUIActionRequest, e as OUIActionResult, g as OUIApprovalGrant } from './types-CnlVRPFL.js';
2
+ import { S as SocketLike, e as OUITransportConfig } from './websocket-DKL9qoO-.js';
3
3
 
4
4
  /**
5
5
  * Nominal branding for values OUI must construct itself.
@@ -214,6 +214,23 @@ interface SurfaceRuntimeOptions {
214
214
  * not checked; they come from the application itself.
215
215
  */
216
216
  accept?: (request: OUIActionRequest) => boolean;
217
+ /**
218
+ * What a snapshot and an answer say of the mounted surfaces (§7.3.8):
219
+ * - `"index"`: each action as an index entry. The agent runtime fetches a
220
+ * definition when it needs one (`oui.describe`). Use it with an agent
221
+ * runtime that reads the index form.
222
+ * - `"full"` (the default until 1.0): each action's whole definition, as
223
+ * every earlier version sent. A page's definitions can outweigh what a
224
+ * frame may carry; then its answers are refused and arrive trimmed.
225
+ */
226
+ form?: "index" | "full";
227
+ /** The most bytes of JSON a frame carries; what does not fit is shortened and said so (§7.3.9). */
228
+ budgets?: {
229
+ /** One answer. Default 480 KB: under the 512 KB a relay commonly caps a frame at. */
230
+ answerBytes?: number;
231
+ /** One snapshot, as sent with a turn. Default 256 KB. */
232
+ snapshotBytes?: number;
233
+ };
217
234
  /**
218
235
  * A request sent again while its answer is on the way is not answered again
219
236
  * (§7.3.7): every copy of a large answer queues on the one socket, ahead of
@@ -230,7 +247,9 @@ interface MountedSurface {
230
247
  /** Remove this mount. Other mounts of the same surface id are unaffected. */
231
248
  unmount(): void;
232
249
  }
233
- interface SurfaceRuntime {
250
+ /** The form a runtime sends its surfaces in (§7.3.8). */
251
+ type SurfaceForm = "full" | "index";
252
+ interface SurfaceRuntime<F extends SurfaceForm = "full"> {
234
253
  /**
235
254
  * Mount a surface. `getContext` is read when an action runs, so handlers see
236
255
  * the latest state rather than the state at mount time.
@@ -242,7 +261,7 @@ interface SurfaceRuntime {
242
261
  /** Answer requests arriving on this socket (null detaches). */
243
262
  attach(socket: SocketLike | null): void;
244
263
  /** What the client can do right now. */
245
- snapshot(): OUISurfaceSnapshot;
264
+ snapshot(): F extends "index" ? OUIIndexSnapshot : OUISurfaceSnapshot;
246
265
  /**
247
266
  * Run a request once and resolve with its result. A request id seen before
248
267
  * resolves with the first result instead of running again.
@@ -267,6 +286,11 @@ interface SurfaceRuntime {
267
286
  /** Stop polling, detach from the socket and forget every mount. */
268
287
  dispose(): void;
269
288
  }
270
- declare function createSurfaceRuntime(options?: SurfaceRuntimeOptions): SurfaceRuntime;
289
+ declare function createSurfaceRuntime(options: SurfaceRuntimeOptions & {
290
+ form: "index";
291
+ }): SurfaceRuntime<"index">;
292
+ declare function createSurfaceRuntime(options?: SurfaceRuntimeOptions & {
293
+ form?: "full";
294
+ }): SurfaceRuntime<"full">;
271
295
 
272
- export { type ActionDefinition as A, type DefinedSurface as D, type MountedSurface as M, type OUIBranded as O, type SettleOptions as S, type ActionHandlerResult as a, type ActionPollingConfig as b, type ObservationDefinition as c, type SurfaceDefinition as d, type SurfaceRuntime as e, type SurfaceRuntimeOptions as f, createSurfaceRuntime as g, defineSurface as h };
296
+ export { type ActionDefinition as A, type DefinedSurface as D, type MountedSurface as M, type OUIBranded as O, type SettleOptions as S, type ActionHandlerResult as a, type ActionPollingConfig as b, type ObservationDefinition as c, type SurfaceDefinition as d, type SurfaceForm as e, type SurfaceRuntime as f, type SurfaceRuntimeOptions as g, createSurfaceRuntime as h, defineSurface as i };
@@ -1,5 +1,5 @@
1
- import { g as OUIEffectKind, J as JSONSchema, b as OUIActionPolling, e as OUIActivation, m as OUISurface, p as OUISurfaceSnapshot, c as OUIActionRequest, d as OUIActionResult, f as OUIApprovalGrant } from './types-CmJb1BQ8.cjs';
2
- import { S as SocketLike, e as OUITransportConfig } from './websocket-Ds2Rh_jL.cjs';
1
+ import { i as OUIEffectKind, J as JSONSchema, c as OUIActionPolling, f as OUIActivation, r as OUISurface, l as OUIIndexSnapshot, v as OUISurfaceSnapshot, d as OUIActionRequest, e as OUIActionResult, g as OUIApprovalGrant } from './types-CnlVRPFL.cjs';
2
+ import { S as SocketLike, e as OUITransportConfig } from './websocket-HnzPlfk6.cjs';
3
3
 
4
4
  /**
5
5
  * Nominal branding for values OUI must construct itself.
@@ -214,6 +214,23 @@ interface SurfaceRuntimeOptions {
214
214
  * not checked; they come from the application itself.
215
215
  */
216
216
  accept?: (request: OUIActionRequest) => boolean;
217
+ /**
218
+ * What a snapshot and an answer say of the mounted surfaces (§7.3.8):
219
+ * - `"index"`: each action as an index entry. The agent runtime fetches a
220
+ * definition when it needs one (`oui.describe`). Use it with an agent
221
+ * runtime that reads the index form.
222
+ * - `"full"` (the default until 1.0): each action's whole definition, as
223
+ * every earlier version sent. A page's definitions can outweigh what a
224
+ * frame may carry; then its answers are refused and arrive trimmed.
225
+ */
226
+ form?: "index" | "full";
227
+ /** The most bytes of JSON a frame carries; what does not fit is shortened and said so (§7.3.9). */
228
+ budgets?: {
229
+ /** One answer. Default 480 KB: under the 512 KB a relay commonly caps a frame at. */
230
+ answerBytes?: number;
231
+ /** One snapshot, as sent with a turn. Default 256 KB. */
232
+ snapshotBytes?: number;
233
+ };
217
234
  /**
218
235
  * A request sent again while its answer is on the way is not answered again
219
236
  * (§7.3.7): every copy of a large answer queues on the one socket, ahead of
@@ -230,7 +247,9 @@ interface MountedSurface {
230
247
  /** Remove this mount. Other mounts of the same surface id are unaffected. */
231
248
  unmount(): void;
232
249
  }
233
- interface SurfaceRuntime {
250
+ /** The form a runtime sends its surfaces in (§7.3.8). */
251
+ type SurfaceForm = "full" | "index";
252
+ interface SurfaceRuntime<F extends SurfaceForm = "full"> {
234
253
  /**
235
254
  * Mount a surface. `getContext` is read when an action runs, so handlers see
236
255
  * the latest state rather than the state at mount time.
@@ -242,7 +261,7 @@ interface SurfaceRuntime {
242
261
  /** Answer requests arriving on this socket (null detaches). */
243
262
  attach(socket: SocketLike | null): void;
244
263
  /** What the client can do right now. */
245
- snapshot(): OUISurfaceSnapshot;
264
+ snapshot(): F extends "index" ? OUIIndexSnapshot : OUISurfaceSnapshot;
246
265
  /**
247
266
  * Run a request once and resolve with its result. A request id seen before
248
267
  * resolves with the first result instead of running again.
@@ -267,6 +286,11 @@ interface SurfaceRuntime {
267
286
  /** Stop polling, detach from the socket and forget every mount. */
268
287
  dispose(): void;
269
288
  }
270
- declare function createSurfaceRuntime(options?: SurfaceRuntimeOptions): SurfaceRuntime;
289
+ declare function createSurfaceRuntime(options: SurfaceRuntimeOptions & {
290
+ form: "index";
291
+ }): SurfaceRuntime<"index">;
292
+ declare function createSurfaceRuntime(options?: SurfaceRuntimeOptions & {
293
+ form?: "full";
294
+ }): SurfaceRuntime<"full">;
271
295
 
272
- export { type ActionDefinition as A, type DefinedSurface as D, type MountedSurface as M, type OUIBranded as O, type SettleOptions as S, type ActionHandlerResult as a, type ActionPollingConfig as b, type ObservationDefinition as c, type SurfaceDefinition as d, type SurfaceRuntime as e, type SurfaceRuntimeOptions as f, createSurfaceRuntime as g, defineSurface as h };
296
+ export { type ActionDefinition as A, type DefinedSurface as D, type MountedSurface as M, type OUIBranded as O, type SettleOptions as S, type ActionHandlerResult as a, type ActionPollingConfig as b, type ObservationDefinition as c, type SurfaceDefinition as d, type SurfaceForm as e, type SurfaceRuntime as f, type SurfaceRuntimeOptions as g, createSurfaceRuntime as h, defineSurface as i };
@@ -1,6 +1,6 @@
1
- import { d as OUITransport } from '../websocket-Ds2Rh_jL.cjs';
2
- export { O as OUIAcknowledgment, a as OUIActionHandler, b as OUIObservationHandler, c as OUIResultHandler, e as OUITransportConfig, S as SocketLike, f as createWebSocketTransport } from '../websocket-Ds2Rh_jL.cjs';
3
- import '../types-CmJb1BQ8.cjs';
1
+ import { d as OUITransport } from '../websocket-HnzPlfk6.cjs';
2
+ export { O as OUIAcknowledgment, a as OUIActionHandler, b as OUIObservationHandler, c as OUIResultHandler, e as OUITransportConfig, S as SocketLike, f as createWebSocketTransport } from '../websocket-HnzPlfk6.cjs';
3
+ import '../types-CnlVRPFL.cjs';
4
4
 
5
5
  /**
6
6
  * Direct transport — for same-process communication.
@@ -1,6 +1,6 @@
1
- import { d as OUITransport } from '../websocket-Ce3tDSsJ.js';
2
- export { O as OUIAcknowledgment, a as OUIActionHandler, b as OUIObservationHandler, c as OUIResultHandler, e as OUITransportConfig, S as SocketLike, f as createWebSocketTransport } from '../websocket-Ce3tDSsJ.js';
3
- import '../types-CmJb1BQ8.js';
1
+ import { d as OUITransport } from '../websocket-DKL9qoO-.js';
2
+ export { O as OUIAcknowledgment, a as OUIActionHandler, b as OUIObservationHandler, c as OUIResultHandler, e as OUITransportConfig, S as SocketLike, f as createWebSocketTransport } from '../websocket-DKL9qoO-.js';
3
+ import '../types-CnlVRPFL.js';
4
4
 
5
5
  /**
6
6
  * Direct transport — for same-process communication.
@@ -96,6 +96,9 @@ type JSONSchema = {
96
96
  pattern?: string;
97
97
  format?: string;
98
98
  additionalProperties?: boolean | JSONSchema;
99
+ title?: string;
100
+ /** Annotations (`x-unit`, `x-rows`, …) a product's contract adds; OUI carries them unread. */
101
+ [annotation: `x-${string}`]: unknown;
99
102
  };
100
103
  /**
101
104
  * A Surface is a controllable boundary within an application.
@@ -228,6 +231,70 @@ interface OUIActivation {
228
231
  /** Custom predicate description (for documentation, not execution) */
229
232
  condition?: string;
230
233
  }
234
+ /**
235
+ * One action as a snapshot and an answer carry it: enough to choose it and to
236
+ * know what it takes in outline, without its definition. A page's actions
237
+ * weigh what its whole catalogue weighs (on a studio page, several hundred
238
+ * KB), and an agent runtime that received every definition could neither be
239
+ * sent them in one frame nor give them all to its model. The definition of an
240
+ * action is fetched when it is needed (`oui.describe`, §7.3.10).
241
+ */
242
+ interface OUIActionIndexEntry {
243
+ /** The action's id. */
244
+ id: string;
245
+ /** Its name as a person reads it. */
246
+ title?: string;
247
+ /** The first sentence of its description, at most `INDEX_DESCRIPTION_CHARS` characters. */
248
+ description: string;
249
+ effect?: OUIEffectKind;
250
+ confirm?: boolean;
251
+ async?: boolean;
252
+ estimatedDuration?: string;
253
+ /** For an async action: how long its work is followed before it is reported as not finished. */
254
+ maxDurationMs?: number;
255
+ /** What it takes, in one line (`summarizeInput`): "none", "value: number 0–100", "clipId, start?, +4 more". */
256
+ input: string;
257
+ /** A hash of the full definition: a fetched definition is good until this changes. */
258
+ definitionHash: string;
259
+ /** The full definition's size in bytes of JSON, so a reader knows to ask for it in outline. */
260
+ definitionBytes: number;
261
+ }
262
+ /** A surface as a snapshot and an answer carry it in index form: its actions as index entries. */
263
+ interface OUISurfaceIndex {
264
+ id: string;
265
+ name: string;
266
+ description: string;
267
+ version?: string;
268
+ /** Observation definitions travel whole: they are small, and say how to read the values that follow. */
269
+ observations?: OUIObservation[];
270
+ index: OUIActionIndexEntry[];
271
+ }
272
+ /**
273
+ * One place where a snapshot's or an answer's observations were shortened to
274
+ * fit its byte budget (§7.3.9): a list cut to its first rows, a long text cut,
275
+ * or a value left out. The rest is read with `oui.read` (§7.3.10), by this
276
+ * surface, observation and path.
277
+ */
278
+ interface OUIFitCut {
279
+ surface: string;
280
+ observation: string;
281
+ /** JSON Pointer (RFC 6901) into the observation's value; "" is the value itself. */
282
+ path: string;
283
+ kind: "list" | "text" | "value";
284
+ /** Rows of a list, characters of a text, bytes of a value. */
285
+ total: number;
286
+ /** How many of them this frame keeps. */
287
+ kept: number;
288
+ }
289
+ /** What was shortened or left out to fit a frame's byte budget (§7.3.9). */
290
+ interface OUIFit {
291
+ observations?: OUIFitCut[];
292
+ /** The action's `data` was left out: its size, and the most a frame could carry. */
293
+ data?: {
294
+ bytes: number;
295
+ limit: number;
296
+ };
297
+ }
231
298
  /**
232
299
  * A request from the agent runtime to execute an action on a surface.
233
300
  */
@@ -268,7 +335,7 @@ interface OUIResultDelivery {
268
335
  /** What the receiving side said when it refused the full answer. */
269
336
  reason: string;
270
337
  /** The fields left out of this answer. */
271
- omitted: Array<"surfaces" | "observations" | "data">;
338
+ omitted: Array<"surfaces" | "index" | "observations" | "data">;
272
339
  }
273
340
  /**
274
341
  * The result of an action execution, returned from the surface to the agent.
@@ -303,8 +370,15 @@ interface OUIActionResult {
303
370
  * set the action just replaced.
304
371
  */
305
372
  surfaces?: OUISurface[];
373
+ /**
374
+ * The same, in index form (§7.3.8): what a client sends in place of
375
+ * `surfaces` unless it was made to send definitions.
376
+ */
377
+ index?: OUISurfaceIndex[];
306
378
  /** Latest observation values per surface once the action's effects settled. */
307
379
  observations?: OUIObservationSnapshot;
380
+ /** What was shortened or left out so this answer fits its byte budget (§7.3.9). */
381
+ fit?: OUIFit;
308
382
  /**
309
383
  * The hash of the client's surfaces once the action's effects settled
310
384
  * (`surfacesHash`). Always present from a client that sends it; `surfaces`
@@ -328,6 +402,9 @@ type OUIObservationSnapshot = Record<string, Record<string, unknown>>;
328
402
  * What a client can do right now: the surfaces it has mounted and their latest
329
403
  * observation values. A client sends this to its agent runtime (for example,
330
404
  * with each turn), and returns it on every action result.
405
+ *
406
+ * This is the full form: every action with its definition. A client made in
407
+ * index form (§7.3.8) sends an `OUIIndexSnapshot` instead.
331
408
  */
332
409
  interface OUISurfaceSnapshot {
333
410
  surfaces: OUISurface[];
@@ -338,7 +415,20 @@ interface OUISurfaceSnapshot {
338
415
  * runtime already holds.
339
416
  */
340
417
  surfacesHash?: string;
418
+ /** What was shortened so the snapshot fits its byte budget (§7.3.9). */
419
+ fit?: OUIFit;
420
+ }
421
+ /** A client's snapshot in index form (§7.3.8): each action as an index entry, not its definition. */
422
+ interface OUIIndexSnapshot {
423
+ index: OUISurfaceIndex[];
424
+ observations: OUIObservationSnapshot;
425
+ /** `surfacesHash(index)`. */
426
+ surfacesHash?: string;
427
+ /** What was shortened so the snapshot fits its byte budget (§7.3.9). */
428
+ fit?: OUIFit;
341
429
  }
430
+ /** A snapshot as an agent runtime receives it: in either form. */
431
+ type OUIClientSnapshot = OUISurfaceSnapshot | OUIIndexSnapshot;
342
432
  /**
343
433
  * An observation update pushed from the surface to the agent.
344
434
  */
@@ -400,4 +490,4 @@ declare const OUI_PROTOCOL_EVENTS: {
400
490
  readonly OBSERVATION_UPDATE: "observation:update";
401
491
  };
402
492
 
403
- export { ARGS_HASH_PATTERN as A, type JSONSchema as J, type OUIAction as O, type OUIActionApproval as a, type OUIActionPolling as b, type OUIActionRequest as c, type OUIActionResult as d, type OUIActivation as e, type OUIApprovalGrant as f, type OUIEffectKind as g, type OUIObservation as h, type OUIObservationSnapshot as i, type OUIObservationUpdate as j, type OUIProtocolEvent as k, type OUIResultDelivery as l, type OUISurface as m, type OUISurfaceDeregistration as n, type OUISurfaceRegistration as o, type OUISurfaceSnapshot as p, OUI_EFFECT_ACCESS as q, OUI_EFFECT_KINDS as r, OUI_PROTOCOL_EVENTS as s, argsHash as t, canonicalJson as u, effectAccess as v, requiresApproval as w };
493
+ export { ARGS_HASH_PATTERN as A, canonicalJson as B, effectAccess as C, requiresApproval as D, type JSONSchema as J, type OUIAction as O, type OUIActionApproval as a, type OUIActionIndexEntry as b, type OUIActionPolling as c, type OUIActionRequest as d, type OUIActionResult as e, type OUIActivation as f, type OUIApprovalGrant as g, type OUIClientSnapshot as h, type OUIEffectKind as i, type OUIFit as j, type OUIFitCut as k, type OUIIndexSnapshot as l, type OUIObservation as m, type OUIObservationSnapshot as n, type OUIObservationUpdate as o, type OUIProtocolEvent as p, type OUIResultDelivery as q, type OUISurface as r, type OUISurfaceDeregistration as s, type OUISurfaceIndex as t, type OUISurfaceRegistration as u, type OUISurfaceSnapshot as v, OUI_EFFECT_ACCESS as w, OUI_EFFECT_KINDS as x, OUI_PROTOCOL_EVENTS as y, argsHash as z };
@@ -96,6 +96,9 @@ type JSONSchema = {
96
96
  pattern?: string;
97
97
  format?: string;
98
98
  additionalProperties?: boolean | JSONSchema;
99
+ title?: string;
100
+ /** Annotations (`x-unit`, `x-rows`, …) a product's contract adds; OUI carries them unread. */
101
+ [annotation: `x-${string}`]: unknown;
99
102
  };
100
103
  /**
101
104
  * A Surface is a controllable boundary within an application.
@@ -228,6 +231,70 @@ interface OUIActivation {
228
231
  /** Custom predicate description (for documentation, not execution) */
229
232
  condition?: string;
230
233
  }
234
+ /**
235
+ * One action as a snapshot and an answer carry it: enough to choose it and to
236
+ * know what it takes in outline, without its definition. A page's actions
237
+ * weigh what its whole catalogue weighs (on a studio page, several hundred
238
+ * KB), and an agent runtime that received every definition could neither be
239
+ * sent them in one frame nor give them all to its model. The definition of an
240
+ * action is fetched when it is needed (`oui.describe`, §7.3.10).
241
+ */
242
+ interface OUIActionIndexEntry {
243
+ /** The action's id. */
244
+ id: string;
245
+ /** Its name as a person reads it. */
246
+ title?: string;
247
+ /** The first sentence of its description, at most `INDEX_DESCRIPTION_CHARS` characters. */
248
+ description: string;
249
+ effect?: OUIEffectKind;
250
+ confirm?: boolean;
251
+ async?: boolean;
252
+ estimatedDuration?: string;
253
+ /** For an async action: how long its work is followed before it is reported as not finished. */
254
+ maxDurationMs?: number;
255
+ /** What it takes, in one line (`summarizeInput`): "none", "value: number 0–100", "clipId, start?, +4 more". */
256
+ input: string;
257
+ /** A hash of the full definition: a fetched definition is good until this changes. */
258
+ definitionHash: string;
259
+ /** The full definition's size in bytes of JSON, so a reader knows to ask for it in outline. */
260
+ definitionBytes: number;
261
+ }
262
+ /** A surface as a snapshot and an answer carry it in index form: its actions as index entries. */
263
+ interface OUISurfaceIndex {
264
+ id: string;
265
+ name: string;
266
+ description: string;
267
+ version?: string;
268
+ /** Observation definitions travel whole: they are small, and say how to read the values that follow. */
269
+ observations?: OUIObservation[];
270
+ index: OUIActionIndexEntry[];
271
+ }
272
+ /**
273
+ * One place where a snapshot's or an answer's observations were shortened to
274
+ * fit its byte budget (§7.3.9): a list cut to its first rows, a long text cut,
275
+ * or a value left out. The rest is read with `oui.read` (§7.3.10), by this
276
+ * surface, observation and path.
277
+ */
278
+ interface OUIFitCut {
279
+ surface: string;
280
+ observation: string;
281
+ /** JSON Pointer (RFC 6901) into the observation's value; "" is the value itself. */
282
+ path: string;
283
+ kind: "list" | "text" | "value";
284
+ /** Rows of a list, characters of a text, bytes of a value. */
285
+ total: number;
286
+ /** How many of them this frame keeps. */
287
+ kept: number;
288
+ }
289
+ /** What was shortened or left out to fit a frame's byte budget (§7.3.9). */
290
+ interface OUIFit {
291
+ observations?: OUIFitCut[];
292
+ /** The action's `data` was left out: its size, and the most a frame could carry. */
293
+ data?: {
294
+ bytes: number;
295
+ limit: number;
296
+ };
297
+ }
231
298
  /**
232
299
  * A request from the agent runtime to execute an action on a surface.
233
300
  */
@@ -268,7 +335,7 @@ interface OUIResultDelivery {
268
335
  /** What the receiving side said when it refused the full answer. */
269
336
  reason: string;
270
337
  /** The fields left out of this answer. */
271
- omitted: Array<"surfaces" | "observations" | "data">;
338
+ omitted: Array<"surfaces" | "index" | "observations" | "data">;
272
339
  }
273
340
  /**
274
341
  * The result of an action execution, returned from the surface to the agent.
@@ -303,8 +370,15 @@ interface OUIActionResult {
303
370
  * set the action just replaced.
304
371
  */
305
372
  surfaces?: OUISurface[];
373
+ /**
374
+ * The same, in index form (§7.3.8): what a client sends in place of
375
+ * `surfaces` unless it was made to send definitions.
376
+ */
377
+ index?: OUISurfaceIndex[];
306
378
  /** Latest observation values per surface once the action's effects settled. */
307
379
  observations?: OUIObservationSnapshot;
380
+ /** What was shortened or left out so this answer fits its byte budget (§7.3.9). */
381
+ fit?: OUIFit;
308
382
  /**
309
383
  * The hash of the client's surfaces once the action's effects settled
310
384
  * (`surfacesHash`). Always present from a client that sends it; `surfaces`
@@ -328,6 +402,9 @@ type OUIObservationSnapshot = Record<string, Record<string, unknown>>;
328
402
  * What a client can do right now: the surfaces it has mounted and their latest
329
403
  * observation values. A client sends this to its agent runtime (for example,
330
404
  * with each turn), and returns it on every action result.
405
+ *
406
+ * This is the full form: every action with its definition. A client made in
407
+ * index form (§7.3.8) sends an `OUIIndexSnapshot` instead.
331
408
  */
332
409
  interface OUISurfaceSnapshot {
333
410
  surfaces: OUISurface[];
@@ -338,7 +415,20 @@ interface OUISurfaceSnapshot {
338
415
  * runtime already holds.
339
416
  */
340
417
  surfacesHash?: string;
418
+ /** What was shortened so the snapshot fits its byte budget (§7.3.9). */
419
+ fit?: OUIFit;
420
+ }
421
+ /** A client's snapshot in index form (§7.3.8): each action as an index entry, not its definition. */
422
+ interface OUIIndexSnapshot {
423
+ index: OUISurfaceIndex[];
424
+ observations: OUIObservationSnapshot;
425
+ /** `surfacesHash(index)`. */
426
+ surfacesHash?: string;
427
+ /** What was shortened so the snapshot fits its byte budget (§7.3.9). */
428
+ fit?: OUIFit;
341
429
  }
430
+ /** A snapshot as an agent runtime receives it: in either form. */
431
+ type OUIClientSnapshot = OUISurfaceSnapshot | OUIIndexSnapshot;
342
432
  /**
343
433
  * An observation update pushed from the surface to the agent.
344
434
  */
@@ -400,4 +490,4 @@ declare const OUI_PROTOCOL_EVENTS: {
400
490
  readonly OBSERVATION_UPDATE: "observation:update";
401
491
  };
402
492
 
403
- export { ARGS_HASH_PATTERN as A, type JSONSchema as J, type OUIAction as O, type OUIActionApproval as a, type OUIActionPolling as b, type OUIActionRequest as c, type OUIActionResult as d, type OUIActivation as e, type OUIApprovalGrant as f, type OUIEffectKind as g, type OUIObservation as h, type OUIObservationSnapshot as i, type OUIObservationUpdate as j, type OUIProtocolEvent as k, type OUIResultDelivery as l, type OUISurface as m, type OUISurfaceDeregistration as n, type OUISurfaceRegistration as o, type OUISurfaceSnapshot as p, OUI_EFFECT_ACCESS as q, OUI_EFFECT_KINDS as r, OUI_PROTOCOL_EVENTS as s, argsHash as t, canonicalJson as u, effectAccess as v, requiresApproval as w };
493
+ export { ARGS_HASH_PATTERN as A, canonicalJson as B, effectAccess as C, requiresApproval as D, type JSONSchema as J, type OUIAction as O, type OUIActionApproval as a, type OUIActionIndexEntry as b, type OUIActionPolling as c, type OUIActionRequest as d, type OUIActionResult as e, type OUIActivation as f, type OUIApprovalGrant as g, type OUIClientSnapshot as h, type OUIEffectKind as i, type OUIFit as j, type OUIFitCut as k, type OUIIndexSnapshot as l, type OUIObservation as m, type OUIObservationSnapshot as n, type OUIObservationUpdate as o, type OUIProtocolEvent as p, type OUIResultDelivery as q, type OUISurface as r, type OUISurfaceDeregistration as s, type OUISurfaceIndex as t, type OUISurfaceRegistration as u, type OUISurfaceSnapshot as v, OUI_EFFECT_ACCESS as w, OUI_EFFECT_KINDS as x, OUI_PROTOCOL_EVENTS as y, argsHash as z };
@@ -1,4 +1,4 @@
1
- import { c as OUIActionRequest, d as OUIActionResult, j as OUIObservationUpdate, m as OUISurface } from './types-CmJb1BQ8.js';
1
+ import { d as OUIActionRequest, e as OUIActionResult, o as OUIObservationUpdate, r as OUISurface } from './types-CnlVRPFL.js';
2
2
 
3
3
  /**
4
4
  * OUI Transport — the wire protocol between agent runtime and surfaces.
@@ -1,4 +1,4 @@
1
- import { c as OUIActionRequest, d as OUIActionResult, j as OUIObservationUpdate, m as OUISurface } from './types-CmJb1BQ8.cjs';
1
+ import { d as OUIActionRequest, e as OUIActionResult, o as OUIObservationUpdate, r as OUISurface } from './types-CnlVRPFL.cjs';
2
2
 
3
3
  /**
4
4
  * OUI Transport — the wire protocol between agent runtime and surfaces.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oui-spec",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "OUI — The OpenUI Specification. A machine-readable contract for agent-controllable user interfaces.",
5
5
  "keywords": [
6
6
  "oui",