oui-spec 0.6.0 → 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 +28 -20
  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 +35 -41
  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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/spec/types.ts","../src/spec/approval.ts","../src/spec/surfaces-hash.ts","../src/spec/index-form.ts","../src/spec/fit.ts"],"names":[],"mappings":";;;AAkeO,IAAM,mBAAA,GAAsB;AAAA,EACjC,gBAAA,EAAkB,kBAAA;AAAA,EAClB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,cAAA,EAAgB,gBAAA;AAAA,EAChB,aAAA,EAAe,eAAA;AAAA,EACf,kBAAA,EAAoB;AACtB;;;AC/bO,IAAM,gBAAA,GAA6C;AAAA,EACxD,MAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF;AAGO,IAAM,iBAAA,GAET;AAAA,EACF,IAAA,EAAM,MAAA;AAAA,EACN,SAAA,EAAW,MAAA;AAAA,EACX,QAAA,EAAU,MAAA;AAAA,EACV,IAAA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AQ,CAAA,EAAE;AAC1D","file":"chunk-2CPOHQGI.cjs","sourcesContent":["import type { OUIActionApproval, OUIEffectKind } from \"./approval.js\";\n\n/**\n * OUI — Open UI Specification\n *\n * The machine-readable contract for agent-controllable user interfaces.\n * Any UI application that implements this interface can be controlled by\n * any OUI-compatible agent runtime.\n */\n\n/** JSON Schema type (subset used by OUI) */\nexport type JSONSchema = {\n type?: string | string[];\n properties?: Record<string, JSONSchema>;\n items?: JSONSchema;\n required?: string[];\n enum?: (string | number | boolean)[];\n description?: string;\n default?: unknown;\n oneOf?: JSONSchema[];\n anyOf?: JSONSchema[];\n allOf?: JSONSchema[];\n const?: unknown;\n minimum?: number;\n maximum?: number;\n minLength?: number;\n maxLength?: number;\n pattern?: string;\n format?: string;\n additionalProperties?: boolean | JSONSchema;\n title?: string;\n /** Annotations (`x-unit`, `x-rows`, …) a product's contract adds; OUI carries them unread. */\n [annotation: `x-${string}`]: unknown;\n};\n\n/**\n * A Surface is a controllable boundary within an application.\n * It declares what an agent can do (actions), what it can observe (state),\n * and when it's available (activation conditions).\n *\n * Think of it as \"one page\" or \"one feature\" of an application, described\n * in a way that an agent can understand and operate.\n */\nexport interface OUISurface {\n /** Unique identifier for this surface (e.g., 'dataviz-wizard', 'document-editor') */\n id: string;\n\n /** Human-readable name */\n name: string;\n\n /** Description of what this surface does — included in agent context */\n description: string;\n\n /** Version of this surface's contract (semver) */\n version?: string;\n\n /** Actions the agent can invoke on this surface */\n actions: OUIAction[];\n\n /** Observable state the agent can read */\n observations?: OUIObservation[];\n\n /** When this surface is active/available */\n activation?: OUIActivation;\n\n /** Additional metadata for agent context */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Declarative polling configuration for async actions.\n * The OUI runtime in the browser manages the polling lifecycle automatically\n * after the action handler returns its dispatch result.\n */\nexport interface OUIActionPolling {\n /** How often to check (milliseconds) */\n intervalMs: number;\n\n /** Max poll attempts before giving up (optional) */\n maxAttempts?: number;\n\n /** Max total duration before giving up in ms (alternative to maxAttempts) */\n maxDurationMs?: number;\n\n /**\n * Subscribe to a realtime event instead of polling.\n * If provided, the runtime listens for this event instead of using setInterval.\n * More efficient when realtime infrastructure exists.\n */\n subscribe?: {\n /** Event name to listen for */\n event: string;\n /**\n * Filter to match the event. Values prefixed with '$dispatchResult.'\n * are resolved from the handler's return value.\n * Example: { jobId: '$dispatchResult.jobId' }\n */\n filter?: Record<string, unknown>;\n };\n}\n\n/**\n * An Action is a single operation an agent can perform on a surface.\n * Each action becomes a \"tool\" that the LLM can call.\n *\n * The action's handler executes in the UI (or API) and returns a result\n * that the agent sees as the tool's output.\n */\nexport interface OUIAction {\n /** Unique action identifier (becomes the tool name) */\n id: string;\n\n /** Human-readable description — this is what the LLM reads to decide when to use it */\n description: string;\n\n /** The action's name as a person reads it, for a confirmation the user approves. */\n title?: string;\n\n /**\n * What using the action does. A `transaction` runs only on the user's\n * approval of the exact request (see `requiresApproval`). Undeclared counts\n * as a write.\n */\n effect?: OUIEffectKind;\n\n /** JSON Schema for the action's input parameters */\n input: JSONSchema;\n\n /** JSON Schema for the action's return value (optional — agent still gets the result) */\n output?: JSONSchema;\n\n /**\n * Destructive: the action removes or replaces something the person made.\n * Unless its effect only reads, it runs only on the user's approval of the\n * exact request, which the surface runtime checks before it runs.\n */\n confirm?: boolean;\n\n /** If true, the action is async — returns immediately with a job/tracking ID */\n async?: boolean;\n\n /** Declarative polling configuration — runtime manages the polling lifecycle after dispatch */\n polling?: OUIActionPolling;\n\n /** Human-readable hint about when this action is appropriate to use */\n usage?: string;\n\n /**\n * Preconditions that should be met before this action is called.\n * Expressed as a description (for the LLM) not as executable logic.\n */\n preconditions?: string;\n\n /** Estimated duration hint (e.g., \"instant\", \"2-5s\", \"30-120s\") */\n estimatedDuration?: string;\n\n /** Tags for categorization */\n tags?: string[];\n}\n\n/**\n * An Observation is a piece of application state that the agent can read.\n * Observations are pushed to the agent in real-time as the app state changes,\n * giving it situational awareness without needing screenshots.\n */\nexport interface OUIObservation {\n /** Unique identifier for this observation */\n id: string;\n\n /** Description of what this observation represents */\n description: string;\n\n /** JSON Schema for the observation's value */\n schema: JSONSchema;\n\n /** How frequently this observation updates */\n updateFrequency?: \"realtime\" | \"on-change\" | \"polling\";\n}\n\n/**\n * Activation conditions — when a surface is available to the agent.\n * A surface might only be active on a specific page, when certain\n * entities are loaded, or under specific application states.\n */\nexport interface OUIActivation {\n /** URL path(s) where this surface is active */\n routes?: string | string[];\n\n /** Entity type/ID that must be present for this surface to activate */\n entity?: {\n type: string;\n id?: string;\n };\n\n /** Custom predicate description (for documentation, not execution) */\n condition?: string;\n}\n\n// ─── Index form (§7.3.8) ───────────────────────────────────────────────────────\n\n/**\n * One action as a snapshot and an answer carry it: enough to choose it and to\n * know what it takes in outline, without its definition. A page's actions\n * weigh what its whole catalogue weighs (on a studio page, several hundred\n * KB), and an agent runtime that received every definition could neither be\n * sent them in one frame nor give them all to its model. The definition of an\n * action is fetched when it is needed (`oui.describe`, §7.3.10).\n */\nexport interface OUIActionIndexEntry {\n /** The action's id. */\n id: string;\n /** Its name as a person reads it. */\n title?: string;\n /** The first sentence of its description, at most `INDEX_DESCRIPTION_CHARS` characters. */\n description: string;\n effect?: OUIEffectKind;\n confirm?: boolean;\n async?: boolean;\n estimatedDuration?: string;\n /** For an async action: how long its work is followed before it is reported as not finished. */\n maxDurationMs?: number;\n /** What it takes, in one line (`summarizeInput`): \"none\", \"value: number 0–100\", \"clipId, start?, +4 more\". */\n input: string;\n /** A hash of the full definition: a fetched definition is good until this changes. */\n definitionHash: string;\n /** The full definition's size in bytes of JSON, so a reader knows to ask for it in outline. */\n definitionBytes: number;\n}\n\n/** A surface as a snapshot and an answer carry it in index form: its actions as index entries. */\nexport interface OUISurfaceIndex {\n id: string;\n name: string;\n description: string;\n version?: string;\n /** Observation definitions travel whole: they are small, and say how to read the values that follow. */\n observations?: OUIObservation[];\n index: OUIActionIndexEntry[];\n}\n\n/**\n * One place where a snapshot's or an answer's observations were shortened to\n * fit its byte budget (§7.3.9): a list cut to its first rows, a long text cut,\n * or a value left out. The rest is read with `oui.read` (§7.3.10), by this\n * surface, observation and path.\n */\nexport interface OUIFitCut {\n surface: string;\n observation: string;\n /** JSON Pointer (RFC 6901) into the observation's value; \"\" is the value itself. */\n path: string;\n kind: \"list\" | \"text\" | \"value\";\n /** Rows of a list, characters of a text, bytes of a value. */\n total: number;\n /** How many of them this frame keeps. */\n kept: number;\n}\n\n/** What was shortened or left out to fit a frame's byte budget (§7.3.9). */\nexport interface OUIFit {\n observations?: OUIFitCut[];\n /** The action's `data` was left out: its size, and the most a frame could carry. */\n data?: { bytes: number; limit: number };\n}\n\n// ─── Protocol Types ──────────────────────────────────────────────────────────\n\n/**\n * A request from the agent runtime to execute an action on a surface.\n */\nexport interface OUIActionRequest {\n /** Unique request ID for correlation */\n requestId: string;\n\n /** Which surface this request targets */\n surfaceId: string;\n\n /** Which action to invoke */\n actionId: string;\n\n /** The action's input parameters (validated against the action's input schema) */\n params: Record<string, unknown>;\n\n /** Timestamp of the request */\n timestamp: number;\n\n /**\n * The user's approval this request runs on, for an action that needs one.\n * The surface runtime runs such an action only when this matches a grant\n * the tab received from the user's own confirmation, for exactly `params`.\n */\n approval?: OUIActionApproval;\n\n /**\n * The `surfacesHash` of the surfaces the agent runtime already holds for\n * this client: from its snapshot, or from an earlier result. A client whose\n * surfaces still hash to this answers without `surfaces`, so a result\n * carries the client's surfaces only when they changed (§7.3.4).\n */\n knownSurfaces?: string;\n}\n\n/**\n * Why a client's answer is shorter than the result it produced: the receiving\n * side refused the full answer (too large, or otherwise not accepted), so the\n * client sent it again without the parts named in `omitted`. The action's own\n * outcome — `success`, `error`, and `data` unless omitted — is still the one\n * that happened (§7.3.6).\n */\nexport interface OUIResultDelivery {\n trimmed: true;\n /** What the receiving side said when it refused the full answer. */\n reason: string;\n /** The fields left out of this answer. */\n omitted: Array<\"surfaces\" | \"index\" | \"observations\" | \"data\">;\n}\n\n/**\n * The result of an action execution, returned from the surface to the agent.\n */\nexport interface OUIActionResult {\n /** Correlates to the request */\n requestId: string;\n\n /** Whether the action succeeded */\n success: boolean;\n\n /** The action's return data (if successful) */\n data?: unknown;\n\n /** Error information (if failed) */\n error?: {\n code: string;\n message: string;\n details?: unknown;\n };\n\n /** Progress indicator for interim polling results (0-100) */\n progress?: number;\n\n /** Whether this is an interim update (polling still in progress) or final */\n interim?: boolean;\n\n /** Duration of execution in milliseconds */\n durationMs?: number;\n\n /** Timestamp of the result */\n timestamp: number;\n\n /**\n * The surfaces active on the client once the action's effects settled.\n *\n * An action can change what the agent is able to do next: navigating\n * unmounts one page's surfaces and mounts another's. Without this, the agent\n * would act on the capability set it had before the action, which is the\n * set the action just replaced.\n */\n surfaces?: OUISurface[];\n\n /**\n * The same, in index form (§7.3.8): what a client sends in place of\n * `surfaces` unless it was made to send definitions.\n */\n index?: OUISurfaceIndex[];\n\n /** Latest observation values per surface once the action's effects settled. */\n observations?: OUIObservationSnapshot;\n\n /** What was shortened or left out so this answer fits its byte budget (§7.3.9). */\n fit?: OUIFit;\n\n /**\n * The hash of the client's surfaces once the action's effects settled\n * (`surfacesHash`). Always present from a client that sends it; `surfaces`\n * is then present only when this differs from the request's\n * `knownSurfaces`, and an agent runtime that holds surfaces with this hash\n * keeps using them.\n */\n surfacesHash?: string;\n\n /** Present when this answer was trimmed to be delivered (§7.3.6). */\n delivery?: OUIResultDelivery;\n\n /**\n * False when the client's deadline passed before its UI settled, so\n * `surfaces` and `observations` may still be changing. Absent or true\n * otherwise.\n */\n settled?: boolean;\n}\n\n/** Latest observation values, keyed by surface id and then observation id. */\nexport type OUIObservationSnapshot = Record<string, Record<string, unknown>>;\n\n/**\n * What a client can do right now: the surfaces it has mounted and their latest\n * observation values. A client sends this to its agent runtime (for example,\n * with each turn), and returns it on every action result.\n *\n * This is the full form: every action with its definition. A client made in\n * index form (§7.3.8) sends an `OUIIndexSnapshot` instead.\n */\nexport interface OUISurfaceSnapshot {\n surfaces: OUISurface[];\n observations: OUIObservationSnapshot;\n /**\n * `surfacesHash(surfaces)`: what an agent runtime sends back as a request's\n * `knownSurfaces`, so the client's answer need not repeat surfaces the\n * runtime already holds.\n */\n surfacesHash?: string;\n /** What was shortened so the snapshot fits its byte budget (§7.3.9). */\n fit?: OUIFit;\n}\n\n/** A client's snapshot in index form (§7.3.8): each action as an index entry, not its definition. */\nexport interface OUIIndexSnapshot {\n index: OUISurfaceIndex[];\n observations: OUIObservationSnapshot;\n /** `surfacesHash(index)`. */\n surfacesHash?: string;\n /** What was shortened so the snapshot fits its byte budget (§7.3.9). */\n fit?: OUIFit;\n}\n\n/** A snapshot as an agent runtime receives it: in either form. */\nexport type OUIClientSnapshot = OUISurfaceSnapshot | OUIIndexSnapshot;\n\n/**\n * An observation update pushed from the surface to the agent.\n */\nexport interface OUIObservationUpdate {\n /** Which surface this observation belongs to */\n surfaceId: string;\n\n /** Which observation updated */\n observationId: string;\n\n /** The new value */\n value: unknown;\n\n /** Timestamp of the update */\n timestamp: number;\n}\n\n/**\n * Surface registration event — sent when a surface becomes active.\n */\nexport interface OUISurfaceRegistration {\n /** The full surface manifest */\n surface: OUISurface;\n\n /** Timestamp of registration */\n timestamp: number;\n}\n\n/**\n * Surface deregistration event — sent when a surface becomes inactive.\n */\nexport interface OUISurfaceDeregistration {\n /** Which surface is being deregistered */\n surfaceId: string;\n\n /** Timestamp */\n timestamp: number;\n}\n\n// ─── Transport Protocol Events ───────────────────────────────────────────────\n\n/**\n * All protocol events exchanged between agent runtime and surfaces.\n */\nexport type OUIProtocolEvent =\n | { type: \"surface:register\"; payload: OUISurfaceRegistration }\n | { type: \"surface:deregister\"; payload: OUISurfaceDeregistration }\n | { type: \"action:request\"; payload: OUIActionRequest }\n | { type: \"action:result\"; payload: OUIActionResult }\n | { type: \"observation:update\"; payload: OUIObservationUpdate };\n\n/**\n * Protocol event type strings (for type guards and routing).\n */\nexport const OUI_PROTOCOL_EVENTS = {\n SURFACE_REGISTER: \"surface:register\",\n SURFACE_DEREGISTER: \"surface:deregister\",\n ACTION_REQUEST: \"action:request\",\n ACTION_RESULT: \"action:result\",\n OBSERVATION_UPDATE: \"observation:update\",\n} as const;\n","/**\n * Approvals: an irreversible action runs only on an approval the user gave,\n * bound to the exact request.\n *\n * An agent runtime stops at an action that needs approval and shows the user\n * a confirmation. Its approval store issues a single-use grant when the user\n * confirms, and the request that then reaches the tab carries `approval:\n * { approvalId, argsHash }`. The surface runtime runs the action only when\n * that matches a grant this tab received from the user's own confirmation.\n *\n * Everything that checks a request computes the same args hash: SHA-256 over\n * the RFC 8785 (JCS) canonical JSON of its params, lowercase hex. The\n * published vectors (`oui-spec/approval-vectors.json`) hold every\n * implementation, in any language, to it.\n */\n\n/**\n * What using an action does. One vocabulary for every kind of action, so an\n * action is told apart by what it changes:\n *\n * | Effect | What it changes | Access |\n * |---|---|---|\n * | `view`, `selection`, `navigate`, `open` | What is shown | read |\n * | `edit` | The document, one undo step | write |\n * | `file` | Imports or exports a file | write |\n * | `mutate` | Backend data, through an API operation | write |\n * | `job` | Starts work that outlives the call | write |\n * | `transaction` | An irreversible external act: an order, a payment, a send, a publish | write, approved |\n */\nexport type OUIEffectKind =\n | \"view\"\n | \"selection\"\n | \"navigate\"\n | \"open\"\n | \"edit\"\n | \"file\"\n | \"mutate\"\n | \"job\"\n | \"transaction\";\n\n/** Every effect, in the order of the table above. */\nexport const OUI_EFFECT_KINDS: readonly OUIEffectKind[] = [\n \"view\",\n \"selection\",\n \"navigate\",\n \"open\",\n \"edit\",\n \"file\",\n \"mutate\",\n \"job\",\n \"transaction\",\n];\n\n/** Whether an effect only changes what is shown, or changes something. */\nexport const OUI_EFFECT_ACCESS: Readonly<\n Record<OUIEffectKind, \"read\" | \"write\">\n> = {\n view: \"read\",\n selection: \"read\",\n navigate: \"read\",\n open: \"read\",\n edit: \"write\",\n file: \"write\",\n mutate: \"write\",\n job: \"write\",\n transaction: \"write\",\n};\n\n/** `read` or `write`. An action that declares no effect is a `write`: nothing says it only shows. */\nexport function effectAccess(\n effect: OUIEffectKind | undefined,\n): \"read\" | \"write\" {\n return effect === undefined ? \"write\" : OUI_EFFECT_ACCESS[effect];\n}\n\n/**\n * Whether running an action needs the user's approval of the exact request: a\n * `transaction` always, and a `write` declared destructive. An agent\n * runtime's policy may require it of more; nothing waives these.\n */\nexport function requiresApproval(\n effect: OUIEffectKind | undefined,\n destructive?: boolean,\n): boolean {\n if (effect === \"transaction\") return true;\n return !!destructive && effectAccess(effect) === \"write\";\n}\n\n/** What a request for an approved action carries. */\nexport interface OUIActionApproval {\n approvalId: string;\n /** `argsHash(params)` of the request the user approved. */\n argsHash: string;\n}\n\n/** A grant this tab holds: the user approved this request here. */\nexport interface OUIApprovalGrant extends OUIActionApproval {\n /** Epoch ms after which the grant no longer admits anything. */\n expiresAt: number;\n}\n\n/** An args hash: 64 lowercase hex digits. */\nexport const ARGS_HASH_PATTERN = /^[0-9a-f]{64}$/;\n\n/**\n * The RFC 8785 canonical form of a JSON value:\n * - object members sorted by their names' UTF-16 code units, with no\n * whitespace;\n * - numbers in ECMAScript's shortest round-trip form (`-0` is `0`);\n * - strings escaped as ECMAScript's `JSON.stringify` escapes them.\n *\n * The value must be I-JSON (RFC 7493): anything JSON cannot carry — `NaN`,\n * infinities, `undefined` outside an object member, a bigint, a function, a\n * symbol, a class instance, or a string with a lone surrogate — is refused\n * rather than hashed as something the other end never receives. An object\n * member whose value is `undefined` is left out, as it is on the wire.\n */\nexport function canonicalJson(value: unknown): string {\n return serialize(value, \"$\");\n}\n\n/** SHA-256 of the canonical JSON of a request's params, lowercase hex. Runs wherever WebCrypto does. */\nexport async function argsHash(params: unknown): Promise<string> {\n const canonical = canonicalJson(params);\n const subtle = await webCrypto();\n const digest = await subtle.digest(\n \"SHA-256\",\n new TextEncoder().encode(canonical),\n );\n let hex = \"\";\n for (const byte of new Uint8Array(digest))\n hex += byte.toString(16).padStart(2, \"0\");\n return hex;\n}\n\n/**\n * WebCrypto: global in browsers and Node 19+; Node 18 has it only on\n * `node:crypto`, imported here by a specifier bundlers leave alone.\n */\nasync function webCrypto(): Promise<SubtleCrypto> {\n const global = globalThis.crypto?.subtle;\n if (global) return global;\n const nodeCrypto = \"node:crypto\";\n try {\n const mod = (await import(/* @vite-ignore */ nodeCrypto)) as {\n webcrypto?: { subtle?: SubtleCrypto };\n };\n if (mod.webcrypto?.subtle) return mod.webcrypto.subtle;\n } catch {\n // Not Node: fall through to the error below.\n }\n throw new Error(\n \"[OUI] argsHash needs WebCrypto (crypto.subtle), which this runtime does not provide\",\n );\n}\n\nfunction refuse(path: string, what: string): never {\n throw new TypeError(`[OUI] ${path} is not I-JSON: ${what}`);\n}\n\nfunction serialize(value: unknown, path: string): string {\n switch (typeof value) {\n case \"string\":\n return quote(value, path);\n case \"number\":\n if (!Number.isFinite(value)) refuse(path, String(value));\n // ECMAScript's Number-to-string is RFC 8785's number form, and prints -0 as 0.\n return JSON.stringify(value);\n case \"boolean\":\n return value ? \"true\" : \"false\";\n case \"object\": {\n if (value === null) return \"null\";\n if (Array.isArray(value)) {\n return `[${value.map((item, i) => serialize(item, `${path}[${i}]`)).join(\",\")}]`;\n }\n const proto = Object.getPrototypeOf(value);\n if (proto !== Object.prototype && proto !== null) {\n refuse(path, `a ${proto?.constructor?.name ?? \"non-plain\"} object`);\n }\n const record = value as Record<string, unknown>;\n // Default string order compares UTF-16 code units, which is RFC 8785's order.\n const keys = Object.keys(record)\n .filter((k) => record[k] !== undefined)\n .sort();\n return `{${keys\n .map(\n (k) =>\n `${quote(k, `${path} key`)}:${serialize(record[k], `${path}.${k}`)}`,\n )\n .join(\",\")}}`;\n }\n default:\n return refuse(path, typeof value);\n }\n}\n\nfunction quote(text: string, path: string): string {\n // I-JSON strings are well-formed Unicode: a lone surrogate has no UTF-8 form.\n for (let i = 0; i < text.length; i++) {\n const unit = text.charCodeAt(i);\n if (unit >= 0xd800 && unit <= 0xdbff) {\n const next = text.charCodeAt(i + 1);\n if (next >= 0xdc00 && next <= 0xdfff) {\n i++;\n continue;\n }\n refuse(path, `a lone surrogate at ${i}`);\n }\n if (unit >= 0xdc00 && unit <= 0xdfff)\n refuse(path, `a lone surrogate at ${i}`);\n }\n return JSON.stringify(text);\n}\n","/**\n * The identity of a set of surfaces, for an answer that need not repeat them\n * (§7.3.4).\n *\n * A client's surfaces are what an agent may do; every result used to carry\n * them all, so each answer weighed what the page's whole manifest weighs —\n * on a studio page with a hundred and fifty actions, about 265 KB for a click.\n * A relay that caps a frame then drops whole answers, and the agent hears\n * nothing. With this hash the agent runtime says which surfaces it holds\n * (`knownSurfaces`), and the client sends its surfaces only when they differ.\n *\n * The hash is of the surfaces' canonical JSON (object keys sorted), so it does\n * not depend on the order a manifest's fields were written in, and is the\n * same wherever it is computed. It is a 64-bit FNV-1a over the JSON's UTF-16\n * code units, kept as two 32-bit halves: not a security measure — the agent\n * runtime is told the surfaces by the same client that hashes them — but\n * collision-resistant enough that two different capability sets of one page\n * never share one.\n */\nimport type { OUISurface, OUISurfaceIndex } from \"./types.js\";\n\n/** The prefix names the algorithm, so a different one is a different hash rather than a false match. */\nconst PREFIX = \"fnv1a64:\";\n\n/** `surfaces`' hash, as a result's `surfacesHash` and a request's `knownSurfaces` carry it. */\nexport function surfacesHash(\n surfaces: readonly OUISurface[] | readonly OUISurfaceIndex[],\n): string {\n return PREFIX + fnv1a64(sortedJson(surfaces));\n}\n\n/**\n * JSON with every object's keys sorted, and what JSON cannot carry dropped as\n * JSON.stringify drops it. Not approval.ts's `canonicalJson`, which refuses\n * such values on purpose (an approval must hash exactly what crosses the\n * wire): a snapshot is taken on every answer, and must never throw on a\n * manifest that carries, say, an `undefined` in an array.\n */\nexport function sortedJson(value: unknown): string {\n return JSON.stringify(sortKeys(value)) ?? \"null\";\n}\n\nfunction sortKeys(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(sortKeys);\n if (value && typeof value === \"object\") {\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(value as Record<string, unknown>).sort()) {\n const member = (value as Record<string, unknown>)[key];\n if (member !== undefined) out[key] = sortKeys(member);\n }\n return out;\n }\n return value;\n}\n\n/**\n * 64-bit FNV-1a (offset 0xcbf29ce484222325, prime 0x100000001b3) in two 32-bit\n * halves, so it runs without BigInt and stays fast on a few hundred KB.\n */\nexport function fnv1a64(text: string): string {\n // The 64-bit offset basis, as high and low 32-bit halves.\n let hi = 0xcbf29ce4;\n let lo = 0x84222325;\n for (let i = 0; i < text.length; i++) {\n lo = (lo ^ text.charCodeAt(i)) >>> 0;\n // Multiply (hi:lo) by the prime 0x00000100_000001b3, keeping 64 bits:\n // lo*0x1b3, and hi*0x1b3 + lo*0x100 carried into the high half.\n const loProduct = lo * 0x1b3;\n const carry = Math.floor(loProduct / 0x100000000);\n const newLo = loProduct >>> 0;\n hi = (Math.imul(hi, 0x1b3) + Math.imul(lo, 0x100) + carry) >>> 0;\n lo = newLo;\n }\n return hex32(hi) + hex32(lo);\n}\n\nfunction hex32(n: number): string {\n return (n >>> 0).toString(16).padStart(8, \"0\");\n}\n","/**\n * The index form of a surface (§7.3.8): each action as one entry that says what\n * it is and what it takes in outline, in place of its definition.\n *\n * Everything here is derived from the action's own definition, by rule, so two\n * clients with the same definition produce the same entry and the same hash.\n */\nimport { fnv1a64, sortedJson } from \"./surfaces-hash.js\";\nimport type {\n JSONSchema,\n OUIAction,\n OUIActionIndexEntry,\n OUISurface,\n OUISurfaceIndex,\n} from \"./types.js\";\n\n/** The longest description an index entry carries. */\nexport const INDEX_DESCRIPTION_CHARS = 160;\n/** The longest input line an index entry carries. */\nexport const INDEX_INPUT_CHARS = 120;\n/** How many of an input's properties its line names before \"+N more\". */\nexport const INDEX_INPUT_PROPERTIES = 6;\n/** How many of an enum's values a line shows before it says how many there are. */\nconst INDEX_ENUM_VALUES = 4;\n\n/** The surface id the runtime itself answers (§7.3.10). No surface may be defined with it. */\nexport const OUI_RUNTIME_SURFACE = \"oui\";\n/** `oui.describe`: the full definitions of the actions asked for. */\nexport const OUI_DESCRIBE_ACTION = \"describe\";\n/** `oui.read`: part of an observation's value, by path, a page of a list at a time. */\nexport const OUI_READ_ACTION = \"read\";\n\n/** The bytes `text` takes as UTF-8, which is what a frame's size limit counts. */\nexport function utf8Length(text: string): number {\n let bytes = 0;\n for (let i = 0; i < text.length; i++) {\n const code = text.charCodeAt(i);\n if (code < 0x80) bytes += 1;\n else if (code < 0x800) bytes += 2;\n else if (code >= 0xd800 && code <= 0xdbff) {\n // A surrogate pair is one code point of four bytes.\n bytes += 4;\n i++;\n } else bytes += 3;\n }\n return bytes;\n}\n\n/** The bytes `value` takes as JSON on the wire; 0 for what JSON drops. */\nexport function jsonBytes(value: unknown): number {\n const json = JSON.stringify(value);\n return json === undefined ? 0 : utf8Length(json);\n}\n\n/** `text` cut to `max` characters, ending in \"…\" when it was cut. */\nfunction clip(text: string, max: number): string {\n return text.length <= max ? text : `${text.slice(0, max - 1).trimEnd()}…`;\n}\n\n/** A description's first sentence, on one line, at most `INDEX_DESCRIPTION_CHARS` characters. */\nexport function firstSentence(text: string): string {\n const line = text.replace(/\\s+/g, \" \").trim();\n // A sentence ends at \". \", \"! \" or \"? \": a full stop inside \"0.5\" or \"e.g.\" followed by a letter is not one.\n const end = line.search(/[.!?](?= [A-Z0-9\"'([])/);\n return clip(\n end >= 0 ? line.slice(0, end + 1) : line,\n INDEX_DESCRIPTION_CHARS,\n );\n}\n\nfunction typeOf(schema: JSONSchema): string {\n const t = schema.type;\n return Array.isArray(t) ? t.join(\"|\") : (t ?? \"\");\n}\n\nfunction unitOf(schema: JSONSchema): string {\n const unit = schema[\"x-unit\"];\n return typeof unit === \"string\" && unit ? ` ${unit}` : \"\";\n}\n\n/** The members of a schema's union, when it is one. */\nfunction unionOf(schema: JSONSchema): JSONSchema[] | null {\n const members = schema.oneOf ?? schema.anyOf;\n return members && members.length > 0 ? members : null;\n}\n\n/**\n * The property every member of a union fixes to its own constant, which is\n * what tells the members apart: `effect` in `{ effect: \"glow\", … } | { effect:\n * \"blur\", … }`. Null when the members share no such property.\n */\nexport function discriminatorOf(members: readonly JSONSchema[]): string | null {\n const first = members[0]?.properties;\n if (!first) return null;\n for (const name of Object.keys(first)) {\n const constants = members.map((m) => constantOf(m.properties?.[name]));\n if (\n constants.every((c) => c !== undefined) &&\n new Set(constants).size === members.length\n )\n return name;\n }\n return null;\n}\n\n/** The one value a schema allows, when it allows one. */\nexport function constantOf(\n schema: JSONSchema | undefined,\n): string | number | boolean | undefined {\n if (!schema) return undefined;\n if (\n typeof schema.const === \"string\" ||\n typeof schema.const === \"number\" ||\n typeof schema.const === \"boolean\"\n ) {\n return schema.const;\n }\n return schema.enum?.length === 1 ? schema.enum[0] : undefined;\n}\n\n/** A value's type in a few words: \"number 0–100 px\", \"a|b|c|d|…(12)\", \"list of string\". */\nfunction valueSummary(schema: JSONSchema): string {\n const constant = constantOf(schema);\n if (constant !== undefined && !schema.enum) return JSON.stringify(constant);\n if (schema.enum) {\n const shown = schema.enum.slice(0, INDEX_ENUM_VALUES).map(String).join(\"|\");\n return schema.enum.length > INDEX_ENUM_VALUES\n ? `${shown}|…(${schema.enum.length})`\n : shown;\n }\n const union = unionOf(schema);\n if (union) return `one of ${union.length}`;\n const type = typeOf(schema);\n if (type === \"number\" || type === \"integer\") {\n const { minimum: min, maximum: max } = schema;\n const range =\n min !== undefined && max !== undefined\n ? ` ${min}–${max}`\n : min !== undefined\n ? ` ≥${min}`\n : max !== undefined\n ? ` ≤${max}`\n : \"\";\n return `${type}${range}${unitOf(schema)}`;\n }\n if (type === \"string\")\n return schema.format ? `string(${schema.format})` : \"string\";\n if (type === \"array\")\n return schema.items ? `list of ${valueSummary(schema.items)}` : \"list\";\n if (type === \"object\") {\n const n = Object.keys(schema.properties ?? {}).length;\n return n > 0 ? `object(${n})` : \"object\";\n }\n return type || \"any\";\n}\n\n/**\n * What an action takes, in one line of at most `INDEX_INPUT_CHARS` characters:\n * - \"none\" for an action that takes nothing;\n * - each property with its type, required ones first, optional ones marked\n * \"?\", the first `INDEX_INPUT_PROPERTIES` of them, then \"+N more\";\n * - \"one of N shapes by <property>\" for a union.\n */\nexport function summarizeInput(schema: JSONSchema | undefined): string {\n if (!schema) return \"none\";\n const union = unionOf(schema);\n if (union) {\n const by = discriminatorOf(union);\n return clip(\n `one of ${union.length} shapes${by ? ` by ${by}` : \"\"}`,\n INDEX_INPUT_CHARS,\n );\n }\n const properties = schema.properties ?? {};\n const names = Object.keys(properties);\n if (names.length === 0)\n return typeOf(schema) && typeOf(schema) !== \"object\"\n ? valueSummary(schema)\n : \"none\";\n const required = new Set(schema.required ?? []);\n const ordered = [\n ...names.filter((n) => required.has(n)),\n ...names.filter((n) => !required.has(n)),\n ];\n const shown = ordered.slice(0, INDEX_INPUT_PROPERTIES);\n const more = ordered.length - shown.length;\n const parts = shown.map(\n (n) => `${n}${required.has(n) ? \"\" : \"?\"}: ${valueSummary(properties[n])}`,\n );\n if (more > 0) parts.push(`+${more} more`);\n return clip(parts.join(\", \"), INDEX_INPUT_CHARS);\n}\n\n/** The hash of an action's definition, as an index entry's `definitionHash` carries it. */\nexport function definitionHash(action: OUIAction): string {\n return fnv1a64(sortedJson(action));\n}\n\n/** An action's index entry (§7.3.8). */\nexport function indexEntry(action: OUIAction): OUIActionIndexEntry {\n return {\n id: action.id,\n ...(action.title ? { title: action.title } : {}),\n description: firstSentence(action.description),\n ...(action.effect !== undefined ? { effect: action.effect } : {}),\n ...(action.confirm ? { confirm: true } : {}),\n ...(action.async ? { async: true } : {}),\n ...(action.estimatedDuration\n ? { estimatedDuration: action.estimatedDuration }\n : {}),\n ...(action.polling?.maxDurationMs !== undefined\n ? { maxDurationMs: action.polling.maxDurationMs }\n : {}),\n input: summarizeInput(action.input),\n definitionHash: definitionHash(action),\n definitionBytes: jsonBytes(action),\n };\n}\n\n/** A surface in index form (§7.3.8). */\nexport function surfaceIndex(surface: OUISurface): OUISurfaceIndex {\n return {\n id: surface.id,\n name: surface.name,\n description: surface.description,\n ...(surface.version !== undefined ? { version: surface.version } : {}),\n ...(surface.observations ? { observations: surface.observations } : {}),\n index: surface.actions.map(indexEntry),\n };\n}\n","/**\n * Fitting what a client sends to a byte budget (§7.3.9).\n *\n * A frame larger than its receiver accepts is refused whole, and the agent\n * then knows nothing of the page. So the client shortens what it sends before\n * it sends it: the longest lists first, then long texts, then whole values,\n * and it says where it cut, so the rest can be read (`oui.read`, §7.3.10).\n *\n * The cuts are made by rule, in a fixed order, so the same state under the\n * same budget is always shortened the same way.\n */\nimport { jsonBytes } from \"./index-form.js\";\nimport type { OUIFitCut, OUIObservationSnapshot } from \"./types.js\";\n\n/** Rows a list keeps at each step of fitting, until the whole fits. */\nexport const FIT_LIST_STEPS = [200, 50, 20, 5, 0] as const;\n/** Characters a text keeps once lists alone did not make the whole fit. */\nexport const FIT_TEXT_CHARS = 2_000;\n\n/** One step into a JSON Pointer (RFC 6901). */\nexport function pointerStep(pointer: string, key: string | number): string {\n return `${pointer}/${String(key).replace(/~/g, \"~0\").replace(/\\//g, \"~1\")}`;\n}\n\n/** The steps of a JSON Pointer; \"\" is no steps. Throws on a pointer that does not start with \"/\". */\nexport function pointerSteps(pointer: string): string[] {\n if (pointer === \"\") return [];\n if (!pointer.startsWith(\"/\"))\n throw new Error(\n `\"${pointer}\" is not a JSON Pointer: it must be \"\" or start with \"/\"`,\n );\n return pointer\n .slice(1)\n .split(\"/\")\n .map((s) => s.replace(/~1/g, \"/\").replace(/~0/g, \"~\"));\n}\n\n/** The value a pointer names inside `value`, or `undefined` when nothing is there. */\nexport function atPointer(value: unknown, pointer: string): unknown {\n let at: unknown = value;\n for (const step of pointerSteps(pointer)) {\n if (Array.isArray(at)) {\n at = /^(0|[1-9]\\d*)$/.test(step) ? at[Number(step)] : undefined;\n } else if (at && typeof at === \"object\") {\n at = Object.prototype.hasOwnProperty.call(at, step)\n ? (at as Record<string, unknown>)[step]\n : undefined;\n } else return undefined;\n if (at === undefined) return undefined;\n }\n return at;\n}\n\ninterface Slot {\n /** The object or array holding the value. */\n holder: Record<string, unknown> | unknown[];\n key: string | number;\n surface: string;\n observation: string;\n path: string;\n}\n\n/** Every array and string inside the observations, each with where it sits. */\nfunction slots(\n observations: OUIObservationSnapshot,\n want: \"list\" | \"text\",\n): Slot[] {\n const found: Slot[] = [];\n const walk = (\n holder: Slot[\"holder\"],\n key: string | number,\n surface: string,\n observation: string,\n path: string,\n ) => {\n const value = (holder as Record<string | number, unknown>)[key];\n if (Array.isArray(value)) {\n if (want === \"list\")\n found.push({ holder, key, surface, observation, path });\n value.forEach((_, i) =>\n walk(value, i, surface, observation, pointerStep(path, i)),\n );\n } else if (value && typeof value === \"object\") {\n for (const k of Object.keys(value))\n walk(\n value as Record<string, unknown>,\n k,\n surface,\n observation,\n pointerStep(path, k),\n );\n } else if (typeof value === \"string\" && want === \"text\") {\n found.push({ holder, key, surface, observation, path });\n }\n };\n for (const surface of Object.keys(observations)) {\n for (const observation of Object.keys(observations[surface])) {\n walk(observations[surface], observation, surface, observation, \"\");\n }\n }\n return found;\n}\n\n/**\n * `observations` within `budget` bytes of JSON, and where they were cut.\n * Returned as they are when they already fit; otherwise a copy is shortened:\n * 1. every list longer than a step of `FIT_LIST_STEPS` is cut to it, a step at\n * a time, until the whole fits;\n * 2. then every text longer than `FIT_TEXT_CHARS` is cut to that;\n * 3. then whole observation values are left out, the largest first.\n */\nexport function fitObservations(\n observations: OUIObservationSnapshot,\n budget: number,\n): { observations: OUIObservationSnapshot; cuts: OUIFitCut[] } {\n if (jsonBytes(observations) <= budget) return { observations, cuts: [] };\n\n const fitted = JSON.parse(\n JSON.stringify(observations),\n ) as OUIObservationSnapshot;\n // One cut per place: a list cut twice is reported once, with its first length.\n const cuts = new Map<string, OUIFitCut>();\n const note = (\n slot: Slot,\n kind: OUIFitCut[\"kind\"],\n total: number,\n kept: number,\n ) => {\n const id = `${slot.surface}\\u0000${slot.observation}\\u0000${slot.path}`;\n const prior = cuts.get(id);\n cuts.set(id, {\n surface: slot.surface,\n observation: slot.observation,\n path: slot.path,\n kind,\n total: prior ? prior.total : total,\n kept,\n });\n };\n const fits = () => jsonBytes(fitted) <= budget;\n\n for (const rows of FIT_LIST_STEPS) {\n for (const slot of slots(fitted, \"list\")) {\n const list = (slot.holder as Record<string | number, unknown>)[\n slot.key\n ] as unknown[];\n if (list.length <= rows) continue;\n note(slot, \"list\", list.length, rows);\n list.length = rows;\n }\n // A cut inside a row that an outer list then dropped is no longer there to read.\n for (const [id, cut] of cuts) {\n if (\n cut.kind === \"list\" &&\n atPointer(fitted[cut.surface]?.[cut.observation], cut.path) ===\n undefined\n )\n cuts.delete(id);\n }\n if (fits()) return { observations: fitted, cuts: [...cuts.values()] };\n }\n\n for (const slot of slots(fitted, \"text\")) {\n const text = (slot.holder as Record<string | number, unknown>)[\n slot.key\n ] as string;\n if (text.length <= FIT_TEXT_CHARS) continue;\n note(slot, \"text\", text.length, FIT_TEXT_CHARS);\n (slot.holder as Record<string | number, unknown>)[slot.key] = text.slice(\n 0,\n FIT_TEXT_CHARS,\n );\n }\n if (fits()) return { observations: fitted, cuts: [...cuts.values()] };\n\n const values = Object.keys(fitted)\n .flatMap((surface) =>\n Object.keys(fitted[surface]).map((observation) => ({\n surface,\n observation,\n bytes: jsonBytes(fitted[surface][observation]),\n })),\n )\n .sort(\n (a, b) =>\n b.bytes - a.bytes ||\n a.surface.localeCompare(b.surface) ||\n a.observation.localeCompare(b.observation),\n );\n for (const { surface, observation, bytes } of values) {\n if (fits()) break;\n for (const [id, cut] of cuts) {\n if (cut.surface === surface && cut.observation === observation)\n cuts.delete(id);\n }\n fitted[surface][observation] = null;\n cuts.set(`${surface}\\u0000${observation}\\u0000`, {\n surface,\n observation,\n path: \"\",\n kind: \"value\",\n total: bytes,\n kept: 0,\n });\n }\n return { observations: fitted, cuts: [...cuts.values()] };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { ARGS_HASH_PATTERN, surfacesHash, requiresApproval, argsHash } from './chunk-B2EFZMGY.js';
1
+ import { OUI_RUNTIME_SURFACE, ARGS_HASH_PATTERN, jsonBytes, fitObservations, requiresApproval, surfacesHash, OUI_DESCRIBE_ACTION, OUI_READ_ACTION, atPointer, argsHash, surfaceIndex } from './chunk-RZUYWZFK.js';
2
2
  import { createWebSocketTransport } from './chunk-R3SGP2UY.js';
3
3
 
4
4
  // src/core/brand.ts
@@ -8,6 +8,11 @@ function brand(value) {
8
8
 
9
9
  // src/core/define-surface.ts
10
10
  function defineSurface(definition) {
11
+ if (definition.id === OUI_RUNTIME_SURFACE) {
12
+ throw new Error(
13
+ `[OUI] "${OUI_RUNTIME_SURFACE}" is the surface runtime's own id: give the surface another`
14
+ );
15
+ }
11
16
  const actionIds = /* @__PURE__ */ new Set();
12
17
  for (const action of definition.actions) {
13
18
  if (actionIds.has(action.id)) {
@@ -158,12 +163,36 @@ var DEFAULT_SETTLE_TIMEOUT_MS = 5e3;
158
163
  var DEFAULT_DEDUPE_WINDOW = 500;
159
164
  var DEFAULT_REANSWER_AFTER_MS = 8e3;
160
165
  var SETTLE_TICK_MS = 50;
166
+ var DEFAULT_ANSWER_BYTES = 480 * 1024;
167
+ var DEFAULT_SNAPSHOT_BYTES = 256 * 1024;
168
+ var OBSERVATION_FLOOR_BYTES = 16 * 1024;
169
+ var DEFAULT_READ_ROWS = 50;
161
170
  function createSurfaceRuntime(options = {}) {
162
171
  const announce = options.announce ?? true;
163
172
  const quietMs = options.settle?.quietMs ?? DEFAULT_QUIET_MS;
164
173
  const settleTimeoutMs = options.settle?.timeoutMs ?? DEFAULT_SETTLE_TIMEOUT_MS;
165
174
  const dedupeWindow = options.dedupeWindow ?? DEFAULT_DEDUPE_WINDOW;
166
175
  const reanswerAfterMs = options.reanswerAfterMs ?? DEFAULT_REANSWER_AFTER_MS;
176
+ const form = options.form ?? "full";
177
+ const answerBytes = options.budgets?.answerBytes ?? DEFAULT_ANSWER_BYTES;
178
+ const snapshotBytes = options.budgets?.snapshotBytes ?? DEFAULT_SNAPSHOT_BYTES;
179
+ const manifests = /* @__PURE__ */ new WeakMap();
180
+ const indexes = /* @__PURE__ */ new WeakMap();
181
+ const manifestOf = (surface) => {
182
+ let manifest = manifests.get(surface);
183
+ if (!manifest)
184
+ manifests.set(
185
+ surface,
186
+ manifest = toJsonSafe(surface.toManifest())
187
+ );
188
+ return manifest;
189
+ };
190
+ const indexOf = (surface) => {
191
+ let index = indexes.get(surface);
192
+ if (!index)
193
+ indexes.set(surface, index = surfaceIndex(manifestOf(surface)));
194
+ return index;
195
+ };
167
196
  let nextKey = 1;
168
197
  const entries = [];
169
198
  const observations = /* @__PURE__ */ new Map();
@@ -302,19 +331,19 @@ function createSurfaceRuntime(options = {}) {
302
331
  function startPolling(requestId, surfaceId, actionId, polling, dispatchResult) {
303
332
  const finish = async (success, data, error) => {
304
333
  await acknowledged(requestId);
305
- const snap = snapshot();
306
- const known = answeredHash.get(requestId);
307
- answer({
308
- requestId,
309
- success,
310
- ...data !== void 0 ? { data: toJsonSafe(data) } : {},
311
- ...error ? { error } : {},
312
- interim: false,
313
- timestamp: Date.now(),
314
- ...snap.surfacesHash !== known ? { surfaces: snap.surfaces } : {},
315
- observations: snap.observations,
316
- surfacesHash: snap.surfacesHash
317
- });
334
+ answer(
335
+ frame(
336
+ {
337
+ requestId,
338
+ success,
339
+ ...data !== void 0 ? { data: toJsonSafe(data) } : {},
340
+ ...error ? { error } : {},
341
+ interim: false,
342
+ timestamp: Date.now()
343
+ },
344
+ answeredHash.get(requestId)
345
+ )
346
+ );
318
347
  acks.delete(requestId);
319
348
  answeredHash.delete(requestId);
320
349
  };
@@ -432,6 +461,8 @@ function createSurfaceRuntime(options = {}) {
432
461
  }
433
462
  async function run(request) {
434
463
  const startedAt = Date.now();
464
+ if (request.surfaceId === OUI_RUNTIME_SURFACE)
465
+ return builtin(request, startedAt);
435
466
  const entry = activeFor(request.surfaceId);
436
467
  let result;
437
468
  let interim = false;
@@ -477,30 +508,187 @@ function createSurfaceRuntime(options = {}) {
477
508
  }
478
509
  }
479
510
  const settled = await waitUntilSettled(startedAt);
480
- const snap = snapshot();
481
- if (interim) answeredHash.set(request.requestId, snap.surfacesHash);
482
- return {
511
+ const answered = frame(
512
+ {
513
+ requestId: request.requestId,
514
+ success: result.success,
515
+ ...result.data !== void 0 ? { data: toJsonSafe(result.data) } : {},
516
+ ...result.error ? { error: toJsonSafe(result.error) } : {},
517
+ ...interim ? { interim: true } : {},
518
+ durationMs: Date.now() - startedAt,
519
+ timestamp: Date.now(),
520
+ settled
521
+ },
522
+ request.knownSurfaces
523
+ );
524
+ if (interim) answeredHash.set(request.requestId, answered.surfacesHash);
525
+ return answered;
526
+ }
527
+ function frame(outcome, knownSurfaces) {
528
+ const page = capture();
529
+ const out = {
530
+ ...outcome,
531
+ ...page.surfacesHash !== knownSurfaces ? form === "index" ? { index: page.index } : { surfaces: page.surfaces } : {},
532
+ surfacesHash: page.surfacesHash
533
+ };
534
+ const fit = {};
535
+ const carried = jsonBytes(out.index ?? out.surfaces) >= answerBytes ? { ...out, index: void 0, surfaces: void 0 } : out;
536
+ const dataLimit = answerBytes - jsonBytes({ ...carried, data: void 0 }) - OBSERVATION_FLOOR_BYTES;
537
+ const dataBytes = jsonBytes(out.data);
538
+ if (dataBytes > Math.max(0, dataLimit)) {
539
+ delete out.data;
540
+ fit.data = { bytes: dataBytes, limit: Math.max(0, dataLimit) };
541
+ }
542
+ const fitted = fitObservations(
543
+ page.observations,
544
+ Math.max(
545
+ 0,
546
+ answerBytes - jsonBytes(
547
+ out.data === void 0 ? { ...carried, data: void 0 } : carried
548
+ )
549
+ )
550
+ );
551
+ out.observations = fitted.observations;
552
+ if (fitted.cuts.length) fit.observations = fitted.cuts;
553
+ if (fit.data || fit.observations) out.fit = fit;
554
+ return out;
555
+ }
556
+ function builtin(request, startedAt) {
557
+ const done = (body) => ({
483
558
  requestId: request.requestId,
484
- success: result.success,
485
- ...result.data !== void 0 ? { data: toJsonSafe(result.data) } : {},
486
- ...result.error ? { error: toJsonSafe(result.error) } : {},
487
- ...interim ? { interim: true } : {},
559
+ ...body,
488
560
  durationMs: Date.now() - startedAt,
489
561
  timestamp: Date.now(),
490
- // Only what the agent runtime does not already hold (§7.3.4).
491
- ...snap.surfacesHash !== request.knownSurfaces ? { surfaces: snap.surfaces } : {},
492
- observations: snap.observations,
493
- surfacesHash: snap.surfacesHash,
494
- settled
495
- };
562
+ surfacesHash: capture().surfacesHash,
563
+ settled: true
564
+ });
565
+ const refuse = (code, message) => done({ success: false, error: { code, message } });
566
+ const params = request.params ?? {};
567
+ if (request.actionId === OUI_DESCRIBE_ACTION) {
568
+ const asked = params.actions;
569
+ if (!Array.isArray(asked) || asked.length === 0 || !asked.every(
570
+ (a) => a && typeof a === "object" && typeof a.surface === "string" && typeof a.action === "string"
571
+ )) {
572
+ return refuse(
573
+ "INVALID_PARAMS",
574
+ '"describe" takes actions: [{ surface, action }], at least one'
575
+ );
576
+ }
577
+ const definitions = [];
578
+ const missing = [];
579
+ const deferred = [];
580
+ let bytes = 0;
581
+ for (const { surface, action } of asked) {
582
+ const entry = activeFor(surface);
583
+ const definition = entry && manifestOf(entry.surface).actions.find((a) => a.id === action);
584
+ if (!definition) {
585
+ missing.push({ surface, action });
586
+ continue;
587
+ }
588
+ const size = jsonBytes(definition);
589
+ if (definitions.length > 0 && bytes + size > answerBytes - OBSERVATION_FLOOR_BYTES) {
590
+ deferred.push({ surface, action });
591
+ continue;
592
+ }
593
+ bytes += size;
594
+ definitions.push({ surface, action: definition });
595
+ }
596
+ return done({
597
+ success: true,
598
+ data: {
599
+ definitions,
600
+ ...missing.length ? { missing } : {},
601
+ ...deferred.length ? { deferred } : {}
602
+ }
603
+ });
604
+ }
605
+ if (request.actionId === OUI_READ_ACTION) {
606
+ const { surface, observation } = params;
607
+ const path = params.path === void 0 ? "" : params.path;
608
+ const offset = params.offset === void 0 ? 0 : params.offset;
609
+ const limit = params.limit === void 0 ? DEFAULT_READ_ROWS : params.limit;
610
+ if (typeof surface !== "string" || typeof observation !== "string" || typeof path !== "string") {
611
+ return refuse(
612
+ "INVALID_PARAMS",
613
+ '"read" takes surface, observation and, to read part of the value, path'
614
+ );
615
+ }
616
+ if (!Number.isInteger(offset) || offset < 0 || !Number.isInteger(limit) || limit < 1) {
617
+ return refuse(
618
+ "INVALID_PARAMS",
619
+ '"read" takes offset (0 or more) and limit (1 or more) as whole numbers'
620
+ );
621
+ }
622
+ const values = observations.get(surface);
623
+ if (!values || !values.has(observation)) {
624
+ const known = values ? [...values.keys()] : [];
625
+ return refuse(
626
+ "NOT_FOUND",
627
+ values ? `Surface "${surface}" reports no observation "${observation}". It reports: ${known.join(", ") || "none"}.` : `Surface "${surface}" is not on screen, or reports nothing.`
628
+ );
629
+ }
630
+ let value;
631
+ try {
632
+ value = atPointer(values.get(observation), path);
633
+ } catch (err) {
634
+ return refuse(
635
+ "INVALID_PARAMS",
636
+ err instanceof Error ? err.message : String(err)
637
+ );
638
+ }
639
+ if (value === void 0) {
640
+ return refuse(
641
+ "NOT_FOUND",
642
+ `Nothing is at "${path}" in ${surface}.${observation}.`
643
+ );
644
+ }
645
+ const room = answerBytes - OBSERVATION_FLOOR_BYTES;
646
+ if (Array.isArray(value)) {
647
+ const total = value.length;
648
+ let rows = value.slice(
649
+ offset,
650
+ offset + limit
651
+ );
652
+ while (rows.length > 1 && jsonBytes(rows) > room)
653
+ rows = rows.slice(0, Math.ceil(rows.length / 2));
654
+ const next = offset + rows.length;
655
+ return done({
656
+ success: true,
657
+ data: {
658
+ rows,
659
+ total,
660
+ offset,
661
+ ...next < total ? { more: true, next } : {}
662
+ }
663
+ });
664
+ }
665
+ const fitted = fitObservations(
666
+ { [surface]: { [observation]: value } },
667
+ room
668
+ );
669
+ const cuts = fitted.cuts.map((c) => ({ ...c, path: `${path}${c.path}` }));
670
+ return done({
671
+ success: true,
672
+ data: {
673
+ value: fitted.observations[surface][observation],
674
+ ...cuts.length ? { fit: { observations: cuts } } : {}
675
+ }
676
+ });
677
+ }
678
+ return refuse(
679
+ "ACTION_NOT_FOUND",
680
+ `The runtime answers "${OUI_DESCRIBE_ACTION}" and "${OUI_READ_ACTION}"; it has no "${request.actionId}".`
681
+ );
496
682
  }
497
683
  function answer(result, onReceived) {
684
+ const offered = form === "index" ? "index" : "surfaces";
498
685
  const steps = [
499
- ["surfaces", "observations"],
500
- ["surfaces", "observations", "data"]
686
+ [offered],
687
+ [offered, "observations"],
688
+ [offered, "observations", "data"]
501
689
  ];
502
- const send = (frame, step) => {
503
- transport?.sendResult(frame, (ack) => {
690
+ const send = (frame2, step) => {
691
+ transport?.sendResult(frame2, (ack) => {
504
692
  if (ack.ok) {
505
693
  onReceived?.();
506
694
  return;
@@ -532,21 +720,40 @@ function createSurfaceRuntime(options = {}) {
532
720
  }
533
721
  return pending;
534
722
  }
535
- function snapshot() {
536
- const surfaces = [];
723
+ function capture() {
724
+ const active = activeEntries();
537
725
  const obs = {};
538
- for (const e of activeEntries()) {
539
- surfaces.push(e.surface.toManifest());
726
+ for (const e of active) {
540
727
  const values = observations.get(e.surface.id);
541
728
  if (values && values.size > 0)
542
729
  obs[e.surface.id] = Object.fromEntries(values);
543
730
  }
731
+ if (form === "index") {
732
+ const index = active.map((e) => indexOf(e.surface));
733
+ return { index, observations: obs, surfacesHash: surfacesHash(index) };
734
+ }
735
+ const surfaces = active.map((e) => manifestOf(e.surface));
544
736
  return {
545
737
  surfaces,
546
738
  observations: obs,
547
739
  surfacesHash: surfacesHash(surfaces)
548
740
  };
549
741
  }
742
+ function snapshot() {
743
+ const page = capture();
744
+ const offered = form === "index" ? { index: page.index } : { surfaces: page.surfaces };
745
+ const offeredBytes = jsonBytes(offered);
746
+ const fitted = fitObservations(
747
+ page.observations,
748
+ offeredBytes >= snapshotBytes ? snapshotBytes : snapshotBytes - offeredBytes
749
+ );
750
+ return {
751
+ ...offered,
752
+ observations: fitted.observations,
753
+ surfacesHash: page.surfacesHash,
754
+ ...fitted.cuts.length ? { fit: { observations: fitted.cuts } } : {}
755
+ };
756
+ }
550
757
  function attach(next) {
551
758
  if (next === socket) return;
552
759
  for (const off of detachTransport) off();
@@ -699,5 +906,5 @@ function toJsonSafe(value) {
699
906
  }
700
907
 
701
908
  export { createOUI, createSurfaceRuntime, defineSurface };
702
- //# sourceMappingURL=chunk-VQETSIY5.js.map
703
- //# sourceMappingURL=chunk-VQETSIY5.js.map
909
+ //# sourceMappingURL=chunk-4MEYE6XZ.js.map
910
+ //# sourceMappingURL=chunk-4MEYE6XZ.js.map