oui-spec 0.4.0 → 0.5.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.
- package/README.md +23 -0
- package/dist/{chunk-DGMKSJTY.cjs → chunk-27CBVTA4.cjs} +83 -13
- package/dist/chunk-27CBVTA4.cjs.map +1 -0
- package/dist/chunk-2AISUNMW.cjs +131 -0
- package/dist/chunk-2AISUNMW.cjs.map +1 -0
- package/dist/{chunk-GXTNZ44I.js → chunk-6ZIKO7MG.js} +81 -11
- package/dist/chunk-6ZIKO7MG.js.map +1 -0
- package/dist/chunk-BNGJJM3T.js +122 -0
- package/dist/chunk-BNGJJM3T.js.map +1 -0
- package/dist/{chunk-F3WKIRAU.js → chunk-UKKITNZK.js} +13 -3
- package/dist/chunk-UKKITNZK.js.map +1 -0
- package/dist/{chunk-DCVVTP3V.cjs → chunk-XUX4XVP3.cjs} +13 -3
- package/dist/chunk-XUX4XVP3.cjs.map +1 -0
- package/dist/core/index.cjs +7 -7
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +3 -3
- package/dist/index.cjs +36 -8
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/spec/index.cjs +30 -2
- package/dist/spec/index.d.cts +91 -2
- package/dist/spec/index.d.ts +91 -2
- package/dist/spec/index.js +1 -1
- package/dist/{surface-runtime-DeByfbKg.d.ts → surface-runtime-CS0rByFQ.d.ts} +14 -1
- package/dist/{surface-runtime-BzIKgL_I.d.cts → surface-runtime-lqXn221P.d.cts} +14 -1
- package/dist/transport/index.cjs +2 -2
- package/dist/transport/index.js +1 -1
- package/package.json +4 -3
- package/spec/approval-vectors.json +88 -0
- package/dist/chunk-BMCL2K74.js +0 -12
- package/dist/chunk-BMCL2K74.js.map +0 -1
- package/dist/chunk-DCVVTP3V.cjs.map +0 -1
- package/dist/chunk-DGMKSJTY.cjs.map +0 -1
- package/dist/chunk-F3WKIRAU.js.map +0 -1
- package/dist/chunk-GXTNZ44I.js.map +0 -1
- package/dist/chunk-ZKM4XWAB.cjs +0 -14
- package/dist/chunk-ZKM4XWAB.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/transport/websocket.ts"],"names":[],"mappings":";;;AA0BO,SAAS,wBAAA,CACd,QACA,MAAA,EACc;AACd,EAAA,MAAM,EAAA,GAAK,QAAQ,SAAA,IAAa,KAAA;AAChC,EAAA,MAAM,SAAkD,EAAC;AACzD,EAAA,MAAM,SAAA,GAAY,QAAQ,aAAA,IAAiB,GAAA;AAC3C,EAAA,MAAM,YAAA,GAAe,QAAQ,uBAAA,IAA2B,IAAA;AAExD,EAAA,IAAI,SAAA,GAAY,OAAO,SAAA,IAAa,KAAA;AACpC,EAAA,MAAM,qBAAkD,EAAC;AAIzD,EAAA,MAAM,WACJ,EAAC;AACH,EAAA,SAAS,MAAA,CACP,OACA,OAAA,EACY;AACZ,IAAA,MAAA,CAAO,EAAA,CAAG,OAAO,OAAO,CAAA;AACxB,IAAA,MAAM,KAAA,GAAQ,EAAE,KAAA,EAAO,OAAA,EAAQ;AAC/B,IAAA,QAAA,CAAS,KAAK,KAAK,CAAA;AACnB,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,GAAA,CAAI,OAAO,OAAO,CAAA;AACzB,MAAA,MAAM,CAAA,GAAI,QAAA,CAAS,OAAA,CAAQ,KAAK,CAAA;AAChC,MAAA,IAAI,CAAA,IAAK,CAAA,EAAG,QAAA,CAAS,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,IAClC,CAAA;AAAA,EACF;AAEA,EAAA,MAAA,CAAO,WAAW,MAAM;AACtB,IAAA,SAAA,GAAY,IAAA;AAGZ,IAAA,IAAI,YAAA,EAAc;AAChB,MAAA,OAAO,MAAA,CAAO,SAAS,CAAA,EAAG;AACxB,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ig,\n OUIActionHandler,\n OUIObservationHandler,\n OUIResultHandler,\n} from \"./types.js\";\nimport type {\n OUISurface,\n OUIObservationUpdate,\n OUIActionRequest,\n OUIActionResult,\n OUIActionApproval,\n} from \"../spec/index.js\";\n\n/**\n * WebSocket transport using Socket.IO.\n * Maps OUI protocol events to socket events with a configurable namespace prefix.\n *\n * Events:\n * {ns}:dispatch — action request (runtime → client)\n * {ns}:action:result — action result (client → runtime)\n * {ns}:observation — observation (client → runtime)\n * {ns}:surface:register — registration (client → runtime)\n * {ns}:surface:deregister — deregistration (client → runtime)\n */\nexport function createWebSocketTransport(\n socket: SocketLike,\n config?: OUITransportConfig,\n): OUITransport {\n const ns = config?.namespace ?? \"oui\";\n const buffer: Array<{ event: string; data: unknown }> = [];\n const maxBuffer = config?.maxBufferSize ?? 100;\n const shouldBuffer = config?.bufferWhileDisconnected ?? true;\n\n let connected = socket.connected ?? false;\n const connectionHandlers: Array<(c: boolean) => void> = [];\n\n // Every listener this transport attaches, so dispose() can remove exactly\n // these and nothing the integrator attached to the same socket.\n const attached: Array<{ event: string; handler: (...args: any[]) => void }> =\n [];\n function listen(\n event: string,\n handler: (...args: any[]) => void,\n ): () => void {\n socket.on(event, handler);\n const entry = { event, handler };\n attached.push(entry);\n return () => {\n socket.off(event, handler);\n const i = attached.indexOf(entry);\n if (i >= 0) attached.splice(i, 1);\n };\n }\n\n listen(\"connect\", () => {\n connected = true;\n // Flush before announcing: anything queued while offline was sent earlier\n // than whatever a connection handler is about to send.\n if (shouldBuffer) {\n while (buffer.length > 0) {\n const msg = buffer.shift()!;\n socket.emit(msg.event, msg.data);\n }\n }\n connectionHandlers.forEach((h) => h(true));\n });\n\n listen(\"disconnect\", () => {\n connected = false;\n connectionHandlers.forEach((h) => h(false));\n });\n\n function emit(event: string, data: unknown) {\n if (connected) {\n socket.emit(event, data);\n } else if (shouldBuffer && buffer.length < maxBuffer) {\n buffer.push({ event, data });\n }\n }\n\n return {\n // ─── Dispatch ───────────────────────────────────────────────\n dispatch(request: OUIActionRequest) {\n emit(`${ns}:dispatch`, request);\n },\n\n onAction(handler: OUIActionHandler) {\n return listen(\n `${ns}:dispatch`,\n (data: Partial<OUIActionRequest> | undefined) => {\n // A request without a requestId cannot be answered, and answering is\n // the contract. Refuse it loudly rather than run an action whose\n // result has nowhere to go.\n if (\n !data ||\n typeof data.requestId !== \"string\" ||\n !data.requestId ||\n typeof data.surfaceId !== \"string\" ||\n typeof data.actionId !== \"string\"\n ) {\n console.warn(\n \"[OUI] Dropped a dispatch without requestId/surfaceId/actionId\",\n data,\n );\n return;\n }\n handler({\n requestId: data.requestId,\n surfaceId: data.surfaceId,\n actionId: data.actionId,\n params: data.params ?? {},\n timestamp: data.timestamp ?? Date.now(),\n ...(isApproval(data.approval)\n ? {\n approval: {\n approvalId: data.approval.approvalId,\n argsHash: data.approval.argsHash,\n },\n }\n : {}),\n });\n },\n );\n },\n\n // ─── Result ─────────────────────────────────────────────────\n sendResult(result: OUIActionResult) {\n emit(`${ns}:action:result`, result);\n },\n\n onResult(handler: OUIResultHandler) {\n return listen(`${ns}:action:result`, (data: OUIActionResult) =>\n handler(data),\n );\n },\n\n // ─── Observation Channel ────────────────────────────────────\n pushObservation(update: OUIObservationUpdate) {\n emit(`${ns}:observation`, update);\n },\n\n onObservation(handler: OUIObservationHandler) {\n return listen(`${ns}:observation`, (data: OUIObservationUpdate) =>\n handler(data),\n );\n },\n\n // ─── Surface Lifecycle ──────────────────────────────────────\n registerSurface(surface: OUISurface) {\n emit(`${ns}:surface:register`, { surface, timestamp: Date.now() });\n },\n\n deregisterSurface(surfaceId: string) {\n emit(`${ns}:surface:deregister`, { surfaceId, timestamp: Date.now() });\n },\n\n onSurfaceRegister(handler: (surface: OUISurface) => void) {\n return listen(`${ns}:surface:register`, (data: { surface: OUISurface }) =>\n handler(data.surface),\n );\n },\n\n onSurfaceDeregister(handler: (surfaceId: string) => void) {\n return listen(`${ns}:surface:deregister`, (data: { surfaceId: string }) =>\n handler(data.surfaceId),\n );\n },\n\n // ─── Connection ─────────────────────────────────────────────\n get connected() {\n return connected;\n },\n\n async connect() {\n if (connected) return;\n return new Promise<void>((resolve, reject) => {\n const timeout = setTimeout(() => {\n reject(\n new Error(\n `OUI transport connect timeout (${config?.connectTimeoutMs ?? 10000}ms)`,\n ),\n );\n }, config?.connectTimeoutMs ?? 10000);\n\n socket.once(\"connect\", () => {\n clearTimeout(timeout);\n resolve();\n });\n\n if (typeof socket.connect === \"function\") {\n socket.connect();\n }\n });\n },\n\n disconnect() {\n if (typeof socket.disconnect === \"function\") {\n socket.disconnect();\n }\n },\n\n onConnectionChange(handler: (c: boolean) => void) {\n connectionHandlers.push(handler);\n return () => {\n const idx = connectionHandlers.indexOf(handler);\n if (idx >= 0) connectionHandlers.splice(idx, 1);\n };\n },\n\n dispose() {\n for (const { event, handler } of attached.splice(0)) {\n socket.off(event, handler);\n }\n connectionHandlers.length = 0;\n buffer.length = 0;\n },\n };\n}\n\n/**\n * Minimal socket interface — compatible with Socket.IO client or server socket.\n * Only the methods OUI actually uses.\n */\nexport interface SocketLike {\n readonly connected?: boolean;\n emit(event: string, data: unknown): void;\n on(event: string, handler: (...args: any[]) => void): void;\n off(event: string, handler: (...args: any[]) => void): void;\n once(event: string, handler: (...args: any[]) => void): void;\n connect?(): void;\n disconnect?(): void;\n}\n\n/** An approval as the wire carries it; anything else is dropped, so the runtime treats the request as unapproved. */\nfunction isApproval(value: unknown): value is OUIActionApproval {\n const a = value as Partial<OUIActionApproval> | null | undefined;\n return (\n !!a &&\n typeof a.approvalId === \"string\" &&\n !!a.approvalId &&\n typeof a.argsHash === \"string\"\n );\n}\n"]}
|
package/dist/core/index.cjs
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
require('../chunk-
|
|
3
|
+
var chunk27CBVTA4_cjs = require('../chunk-27CBVTA4.cjs');
|
|
4
|
+
var chunk2AISUNMW_cjs = require('../chunk-2AISUNMW.cjs');
|
|
5
|
+
require('../chunk-XUX4XVP3.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, "createOUI", {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunk27CBVTA4_cjs.createOUI; }
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "createSurfaceRuntime", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunk27CBVTA4_cjs.createSurfaceRuntime; }
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "defineSurface", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunk27CBVTA4_cjs.defineSurface; }
|
|
20
20
|
});
|
|
21
21
|
Object.defineProperty(exports, "OUI_PROTOCOL_EVENTS", {
|
|
22
22
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunk2AISUNMW_cjs.OUI_PROTOCOL_EVENTS; }
|
|
24
24
|
});
|
|
25
25
|
//# sourceMappingURL=index.cjs.map
|
|
26
26
|
//# sourceMappingURL=index.cjs.map
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OUISurface } from '../spec/index.cjs';
|
|
2
2
|
export { JSONSchema, OUIAction, OUIActionPolling, OUIActionRequest, OUIActionResult, OUIActivation, OUIObservation, OUIObservationSnapshot, OUIObservationUpdate, OUIProtocolEvent, OUISurfaceDeregistration, OUISurfaceRegistration, OUISurfaceSnapshot, OUI_PROTOCOL_EVENTS } from '../spec/index.cjs';
|
|
3
|
-
import { D as DefinedSurface, O as OUIBranded } from '../surface-runtime-
|
|
4
|
-
export { A as ActionDefinition, a as ActionHandlerResult, b as ActionPollingConfig, M as MountedSurface, c as ObservationDefinition, S as SettleOptions, d as SurfaceDefinition, e as SurfaceRuntime, f as SurfaceRuntimeOptions, g as createSurfaceRuntime, h as defineSurface } from '../surface-runtime-
|
|
3
|
+
import { D as DefinedSurface, O as OUIBranded } from '../surface-runtime-lqXn221P.cjs';
|
|
4
|
+
export { A as ActionDefinition, a as ActionHandlerResult, b as ActionPollingConfig, M as MountedSurface, c as ObservationDefinition, S as SettleOptions, d as SurfaceDefinition, e as SurfaceRuntime, f as SurfaceRuntimeOptions, g as createSurfaceRuntime, h as defineSurface } from '../surface-runtime-lqXn221P.cjs';
|
|
5
5
|
import { S as SocketLike, d as OUITransportConfig, c as OUITransport } from '../websocket-YfWILdZ4.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OUISurface } from '../spec/index.js';
|
|
2
2
|
export { JSONSchema, OUIAction, OUIActionPolling, OUIActionRequest, OUIActionResult, OUIActivation, OUIObservation, OUIObservationSnapshot, OUIObservationUpdate, OUIProtocolEvent, OUISurfaceDeregistration, OUISurfaceRegistration, OUISurfaceSnapshot, OUI_PROTOCOL_EVENTS } from '../spec/index.js';
|
|
3
|
-
import { D as DefinedSurface, O as OUIBranded } from '../surface-runtime-
|
|
4
|
-
export { A as ActionDefinition, a as ActionHandlerResult, b as ActionPollingConfig, M as MountedSurface, c as ObservationDefinition, S as SettleOptions, d as SurfaceDefinition, e as SurfaceRuntime, f as SurfaceRuntimeOptions, g as createSurfaceRuntime, h as defineSurface } from '../surface-runtime-
|
|
3
|
+
import { D as DefinedSurface, O as OUIBranded } from '../surface-runtime-CS0rByFQ.js';
|
|
4
|
+
export { A as ActionDefinition, a as ActionHandlerResult, b as ActionPollingConfig, M as MountedSurface, c as ObservationDefinition, S as SettleOptions, d as SurfaceDefinition, e as SurfaceRuntime, f as SurfaceRuntimeOptions, g as createSurfaceRuntime, h as defineSurface } from '../surface-runtime-CS0rByFQ.js';
|
|
5
5
|
import { S as SocketLike, d as OUITransportConfig, c as OUITransport } from '../websocket-c5tIUWY5.js';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/core/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { createOUI, createSurfaceRuntime, defineSurface } from '../chunk-
|
|
2
|
-
export { OUI_PROTOCOL_EVENTS } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { createOUI, createSurfaceRuntime, defineSurface } from '../chunk-6ZIKO7MG.js';
|
|
2
|
+
export { OUI_PROTOCOL_EVENTS } from '../chunk-BNGJJM3T.js';
|
|
3
|
+
import '../chunk-UKKITNZK.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,28 +1,56 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk27CBVTA4_cjs = require('./chunk-27CBVTA4.cjs');
|
|
4
|
+
var chunk2AISUNMW_cjs = require('./chunk-2AISUNMW.cjs');
|
|
5
5
|
var chunkF3SKRAGU_cjs = require('./chunk-F3SKRAGU.cjs');
|
|
6
6
|
var chunkROGKEMLL_cjs = require('./chunk-ROGKEMLL.cjs');
|
|
7
|
-
var
|
|
7
|
+
var chunkXUX4XVP3_cjs = require('./chunk-XUX4XVP3.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
Object.defineProperty(exports, "createOUI", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunk27CBVTA4_cjs.createOUI; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "createSurfaceRuntime", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunk27CBVTA4_cjs.createSurfaceRuntime; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "defineSurface", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunk27CBVTA4_cjs.defineSurface; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "ARGS_HASH_PATTERN", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunk2AISUNMW_cjs.ARGS_HASH_PATTERN; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "OUI_EFFECT_ACCESS", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return chunk2AISUNMW_cjs.OUI_EFFECT_ACCESS; }
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "OUI_EFFECT_KINDS", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return chunk2AISUNMW_cjs.OUI_EFFECT_KINDS; }
|
|
22
34
|
});
|
|
23
35
|
Object.defineProperty(exports, "OUI_PROTOCOL_EVENTS", {
|
|
24
36
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunk2AISUNMW_cjs.OUI_PROTOCOL_EVENTS; }
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, "argsHash", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () { return chunk2AISUNMW_cjs.argsHash; }
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "canonicalJson", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () { return chunk2AISUNMW_cjs.canonicalJson; }
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(exports, "effectAccess", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function () { return chunk2AISUNMW_cjs.effectAccess; }
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(exports, "requiresApproval", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () { return chunk2AISUNMW_cjs.requiresApproval; }
|
|
26
54
|
});
|
|
27
55
|
Object.defineProperty(exports, "SurfaceRuntimeProvider", {
|
|
28
56
|
enumerable: true,
|
|
@@ -50,7 +78,7 @@ Object.defineProperty(exports, "createDirectTransportPair", {
|
|
|
50
78
|
});
|
|
51
79
|
Object.defineProperty(exports, "createWebSocketTransport", {
|
|
52
80
|
enumerable: true,
|
|
53
|
-
get: function () { return
|
|
81
|
+
get: function () { return chunkXUX4XVP3_cjs.createWebSocketTransport; }
|
|
54
82
|
});
|
|
55
83
|
//# sourceMappingURL=index.cjs.map
|
|
56
84
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { JSONSchema, OUIAction, OUIActionPolling, OUIActionRequest, OUIActionResult, OUIActivation, OUIObservation, OUIObservationSnapshot, OUIObservationUpdate, OUIProtocolEvent, OUISurface, OUISurfaceDeregistration, OUISurfaceRegistration, OUISurfaceSnapshot, OUI_PROTOCOL_EVENTS } from './spec/index.cjs';
|
|
2
|
-
export { A as ActionDefinition, a as ActionHandlerResult, b as ActionPollingConfig, D as DefinedSurface, M as MountedSurface, O as OUIBranded, c as ObservationDefinition, S as SettleOptions, d as SurfaceDefinition, e as SurfaceRuntime, f as SurfaceRuntimeOptions, g as createSurfaceRuntime, h as defineSurface } from './surface-runtime-
|
|
1
|
+
export { ARGS_HASH_PATTERN, JSONSchema, OUIAction, OUIActionApproval, OUIActionPolling, OUIActionRequest, OUIActionResult, OUIActivation, OUIApprovalGrant, OUIEffectKind, OUIObservation, OUIObservationSnapshot, OUIObservationUpdate, OUIProtocolEvent, OUISurface, OUISurfaceDeregistration, OUISurfaceRegistration, OUISurfaceSnapshot, OUI_EFFECT_ACCESS, OUI_EFFECT_KINDS, OUI_PROTOCOL_EVENTS, argsHash, canonicalJson, effectAccess, requiresApproval } from './spec/index.cjs';
|
|
2
|
+
export { A as ActionDefinition, a as ActionHandlerResult, b as ActionPollingConfig, D as DefinedSurface, M as MountedSurface, O as OUIBranded, c as ObservationDefinition, S as SettleOptions, d as SurfaceDefinition, e as SurfaceRuntime, f as SurfaceRuntimeOptions, g as createSurfaceRuntime, h as defineSurface } from './surface-runtime-lqXn221P.cjs';
|
|
3
3
|
export { DuplicateIds, OUIConfig, OUIConfigError, OUIInstance, OwnedTransport, ValidateSurfaceIds, createOUI } from './core/index.cjs';
|
|
4
4
|
export { SurfaceRuntimeProvider, SurfaceRuntimeProviderProps, UseSurfaceOptions, UseSurfaceResult, useObservation, useSurface, useSurfaceHold, useSurfaceRuntime } from './react/index.cjs';
|
|
5
5
|
export { O as OUIActionHandler, a as OUIObservationHandler, b as OUIResultHandler, c as OUITransport, d as OUITransportConfig, S as SocketLike, e as createWebSocketTransport } from './websocket-YfWILdZ4.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { JSONSchema, OUIAction, OUIActionPolling, OUIActionRequest, OUIActionResult, OUIActivation, OUIObservation, OUIObservationSnapshot, OUIObservationUpdate, OUIProtocolEvent, OUISurface, OUISurfaceDeregistration, OUISurfaceRegistration, OUISurfaceSnapshot, OUI_PROTOCOL_EVENTS } from './spec/index.js';
|
|
2
|
-
export { A as ActionDefinition, a as ActionHandlerResult, b as ActionPollingConfig, D as DefinedSurface, M as MountedSurface, O as OUIBranded, c as ObservationDefinition, S as SettleOptions, d as SurfaceDefinition, e as SurfaceRuntime, f as SurfaceRuntimeOptions, g as createSurfaceRuntime, h as defineSurface } from './surface-runtime-
|
|
1
|
+
export { ARGS_HASH_PATTERN, JSONSchema, OUIAction, OUIActionApproval, OUIActionPolling, OUIActionRequest, OUIActionResult, OUIActivation, OUIApprovalGrant, OUIEffectKind, OUIObservation, OUIObservationSnapshot, OUIObservationUpdate, OUIProtocolEvent, OUISurface, OUISurfaceDeregistration, OUISurfaceRegistration, OUISurfaceSnapshot, OUI_EFFECT_ACCESS, OUI_EFFECT_KINDS, OUI_PROTOCOL_EVENTS, argsHash, canonicalJson, effectAccess, requiresApproval } from './spec/index.js';
|
|
2
|
+
export { A as ActionDefinition, a as ActionHandlerResult, b as ActionPollingConfig, D as DefinedSurface, M as MountedSurface, O as OUIBranded, c as ObservationDefinition, S as SettleOptions, d as SurfaceDefinition, e as SurfaceRuntime, f as SurfaceRuntimeOptions, g as createSurfaceRuntime, h as defineSurface } from './surface-runtime-CS0rByFQ.js';
|
|
3
3
|
export { DuplicateIds, OUIConfig, OUIConfigError, OUIInstance, OwnedTransport, ValidateSurfaceIds, createOUI } from './core/index.js';
|
|
4
4
|
export { SurfaceRuntimeProvider, SurfaceRuntimeProviderProps, UseSurfaceOptions, UseSurfaceResult, useObservation, useSurface, useSurfaceHold, useSurfaceRuntime } from './react/index.js';
|
|
5
5
|
export { O as OUIActionHandler, a as OUIObservationHandler, b as OUIResultHandler, c as OUITransport, d as OUITransportConfig, S as SocketLike, e as createWebSocketTransport } from './websocket-c5tIUWY5.js';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { createOUI, createSurfaceRuntime, defineSurface } from './chunk-
|
|
2
|
-
export { OUI_PROTOCOL_EVENTS } from './chunk-
|
|
1
|
+
export { createOUI, createSurfaceRuntime, defineSurface } from './chunk-6ZIKO7MG.js';
|
|
2
|
+
export { ARGS_HASH_PATTERN, OUI_EFFECT_ACCESS, OUI_EFFECT_KINDS, OUI_PROTOCOL_EVENTS, argsHash, canonicalJson, effectAccess, requiresApproval } from './chunk-BNGJJM3T.js';
|
|
3
3
|
export { SurfaceRuntimeProvider, useObservation, useSurface, useSurfaceHold, useSurfaceRuntime } from './chunk-NYCJZQSP.js';
|
|
4
4
|
export { createDirectTransportPair } from './chunk-IIZ6HL2L.js';
|
|
5
|
-
export { createWebSocketTransport } from './chunk-
|
|
5
|
+
export { createWebSocketTransport } from './chunk-UKKITNZK.js';
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist/react/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { OUIActionResult } from '../spec/index.cjs';
|
|
4
|
-
import { e as SurfaceRuntime, D as DefinedSurface } from '../surface-runtime-
|
|
4
|
+
import { e as SurfaceRuntime, D as DefinedSurface } from '../surface-runtime-lqXn221P.cjs';
|
|
5
5
|
import '../websocket-YfWILdZ4.cjs';
|
|
6
6
|
|
|
7
7
|
interface SurfaceRuntimeProviderProps {
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { OUIActionResult } from '../spec/index.js';
|
|
4
|
-
import { e as SurfaceRuntime, D as DefinedSurface } from '../surface-runtime-
|
|
4
|
+
import { e as SurfaceRuntime, D as DefinedSurface } from '../surface-runtime-CS0rByFQ.js';
|
|
5
5
|
import '../websocket-c5tIUWY5.js';
|
|
6
6
|
|
|
7
7
|
interface SurfaceRuntimeProviderProps {
|
package/dist/spec/index.cjs
CHANGED
|
@@ -1,12 +1,40 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk2AISUNMW_cjs = require('../chunk-2AISUNMW.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
Object.defineProperty(exports, "ARGS_HASH_PATTERN", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunk2AISUNMW_cjs.ARGS_HASH_PATTERN; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "OUI_EFFECT_ACCESS", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunk2AISUNMW_cjs.OUI_EFFECT_ACCESS; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "OUI_EFFECT_KINDS", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunk2AISUNMW_cjs.OUI_EFFECT_KINDS; }
|
|
18
|
+
});
|
|
7
19
|
Object.defineProperty(exports, "OUI_PROTOCOL_EVENTS", {
|
|
8
20
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunk2AISUNMW_cjs.OUI_PROTOCOL_EVENTS; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "argsHash", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunk2AISUNMW_cjs.argsHash; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "canonicalJson", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return chunk2AISUNMW_cjs.canonicalJson; }
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "effectAccess", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return chunk2AISUNMW_cjs.effectAccess; }
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, "requiresApproval", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () { return chunk2AISUNMW_cjs.requiresApproval; }
|
|
10
38
|
});
|
|
11
39
|
//# sourceMappingURL=index.cjs.map
|
|
12
40
|
//# sourceMappingURL=index.cjs.map
|
package/dist/spec/index.d.cts
CHANGED
|
@@ -1,3 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Approvals: an irreversible action runs only on an approval the user gave,
|
|
3
|
+
* bound to the exact request.
|
|
4
|
+
*
|
|
5
|
+
* An agent runtime stops at an action that needs approval and shows the user
|
|
6
|
+
* a confirmation. Its approval store issues a single-use grant when the user
|
|
7
|
+
* confirms, and the request that then reaches the tab carries `approval:
|
|
8
|
+
* { approvalId, argsHash }`. The surface runtime runs the action only when
|
|
9
|
+
* that matches a grant this tab received from the user's own confirmation.
|
|
10
|
+
*
|
|
11
|
+
* Everything that checks a request computes the same args hash: SHA-256 over
|
|
12
|
+
* the RFC 8785 (JCS) canonical JSON of its params, lowercase hex. The
|
|
13
|
+
* published vectors (`oui-spec/approval-vectors.json`) hold every
|
|
14
|
+
* implementation, in any language, to it.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* What using an action does. One vocabulary for every kind of action, so an
|
|
18
|
+
* action is told apart by what it changes:
|
|
19
|
+
*
|
|
20
|
+
* | Effect | What it changes | Access |
|
|
21
|
+
* |---|---|---|
|
|
22
|
+
* | `view`, `selection`, `navigate`, `open` | What is shown | read |
|
|
23
|
+
* | `edit` | The document, one undo step | write |
|
|
24
|
+
* | `file` | Imports or exports a file | write |
|
|
25
|
+
* | `mutate` | Backend data, through an API operation | write |
|
|
26
|
+
* | `job` | Starts work that outlives the call | write |
|
|
27
|
+
* | `transaction` | An irreversible external act: an order, a payment, a send, a publish | write, approved |
|
|
28
|
+
*/
|
|
29
|
+
type OUIEffectKind = "view" | "selection" | "navigate" | "open" | "edit" | "file" | "mutate" | "job" | "transaction";
|
|
30
|
+
/** Every effect, in the order of the table above. */
|
|
31
|
+
declare const OUI_EFFECT_KINDS: readonly OUIEffectKind[];
|
|
32
|
+
/** Whether an effect only changes what is shown, or changes something. */
|
|
33
|
+
declare const OUI_EFFECT_ACCESS: Readonly<Record<OUIEffectKind, "read" | "write">>;
|
|
34
|
+
/** `read` or `write`. An action that declares no effect is a `write`: nothing says it only shows. */
|
|
35
|
+
declare function effectAccess(effect: OUIEffectKind | undefined): "read" | "write";
|
|
36
|
+
/**
|
|
37
|
+
* Whether running an action needs the user's approval of the exact request: a
|
|
38
|
+
* `transaction` always, and a `write` declared destructive. An agent
|
|
39
|
+
* runtime's policy may require it of more; nothing waives these.
|
|
40
|
+
*/
|
|
41
|
+
declare function requiresApproval(effect: OUIEffectKind | undefined, destructive?: boolean): boolean;
|
|
42
|
+
/** What a request for an approved action carries. */
|
|
43
|
+
interface OUIActionApproval {
|
|
44
|
+
approvalId: string;
|
|
45
|
+
/** `argsHash(params)` of the request the user approved. */
|
|
46
|
+
argsHash: string;
|
|
47
|
+
}
|
|
48
|
+
/** A grant this tab holds: the user approved this request here. */
|
|
49
|
+
interface OUIApprovalGrant extends OUIActionApproval {
|
|
50
|
+
/** Epoch ms after which the grant no longer admits anything. */
|
|
51
|
+
expiresAt: number;
|
|
52
|
+
}
|
|
53
|
+
/** An args hash: 64 lowercase hex digits. */
|
|
54
|
+
declare const ARGS_HASH_PATTERN: RegExp;
|
|
55
|
+
/**
|
|
56
|
+
* The RFC 8785 canonical form of a JSON value:
|
|
57
|
+
* - object members sorted by their names' UTF-16 code units, with no
|
|
58
|
+
* whitespace;
|
|
59
|
+
* - numbers in ECMAScript's shortest round-trip form (`-0` is `0`);
|
|
60
|
+
* - strings escaped as ECMAScript's `JSON.stringify` escapes them.
|
|
61
|
+
*
|
|
62
|
+
* The value must be I-JSON (RFC 7493): anything JSON cannot carry — `NaN`,
|
|
63
|
+
* infinities, `undefined` outside an object member, a bigint, a function, a
|
|
64
|
+
* symbol, a class instance, or a string with a lone surrogate — is refused
|
|
65
|
+
* rather than hashed as something the other end never receives. An object
|
|
66
|
+
* member whose value is `undefined` is left out, as it is on the wire.
|
|
67
|
+
*/
|
|
68
|
+
declare function canonicalJson(value: unknown): string;
|
|
69
|
+
/** SHA-256 of the canonical JSON of a request's params, lowercase hex. Runs wherever WebCrypto does. */
|
|
70
|
+
declare function argsHash(params: unknown): Promise<string>;
|
|
71
|
+
|
|
1
72
|
/**
|
|
2
73
|
* OUI — Open UI Specification
|
|
3
74
|
*
|
|
@@ -92,11 +163,23 @@ interface OUIAction {
|
|
|
92
163
|
id: string;
|
|
93
164
|
/** Human-readable description — this is what the LLM reads to decide when to use it */
|
|
94
165
|
description: string;
|
|
166
|
+
/** The action's name as a person reads it, for a confirmation the user approves. */
|
|
167
|
+
title?: string;
|
|
168
|
+
/**
|
|
169
|
+
* What using the action does. A `transaction` runs only on the user's
|
|
170
|
+
* approval of the exact request (see `requiresApproval`). Undeclared counts
|
|
171
|
+
* as a write.
|
|
172
|
+
*/
|
|
173
|
+
effect?: OUIEffectKind;
|
|
95
174
|
/** JSON Schema for the action's input parameters */
|
|
96
175
|
input: JSONSchema;
|
|
97
176
|
/** JSON Schema for the action's return value (optional — agent still gets the result) */
|
|
98
177
|
output?: JSONSchema;
|
|
99
|
-
/**
|
|
178
|
+
/**
|
|
179
|
+
* Destructive: the action removes or replaces something the person made.
|
|
180
|
+
* Unless its effect only reads, it runs only on the user's approval of the
|
|
181
|
+
* exact request, which the surface runtime checks before it runs.
|
|
182
|
+
*/
|
|
100
183
|
confirm?: boolean;
|
|
101
184
|
/** If true, the action is async — returns immediately with a job/tracking ID */
|
|
102
185
|
async?: boolean;
|
|
@@ -159,6 +242,12 @@ interface OUIActionRequest {
|
|
|
159
242
|
params: Record<string, unknown>;
|
|
160
243
|
/** Timestamp of the request */
|
|
161
244
|
timestamp: number;
|
|
245
|
+
/**
|
|
246
|
+
* The user's approval this request runs on, for an action that needs one.
|
|
247
|
+
* The surface runtime runs such an action only when this matches a grant
|
|
248
|
+
* the tab received from the user's own confirmation, for exactly `params`.
|
|
249
|
+
*/
|
|
250
|
+
approval?: OUIActionApproval;
|
|
162
251
|
}
|
|
163
252
|
/**
|
|
164
253
|
* The result of an action execution, returned from the surface to the agent.
|
|
@@ -274,4 +363,4 @@ declare const OUI_PROTOCOL_EVENTS: {
|
|
|
274
363
|
readonly OBSERVATION_UPDATE: "observation:update";
|
|
275
364
|
};
|
|
276
365
|
|
|
277
|
-
export { type JSONSchema, type OUIAction, type OUIActionPolling, type OUIActionRequest, type OUIActionResult, type OUIActivation, type OUIObservation, type OUIObservationSnapshot, type OUIObservationUpdate, type OUIProtocolEvent, type OUISurface, type OUISurfaceDeregistration, type OUISurfaceRegistration, type OUISurfaceSnapshot, OUI_PROTOCOL_EVENTS };
|
|
366
|
+
export { ARGS_HASH_PATTERN, type JSONSchema, type OUIAction, type OUIActionApproval, type OUIActionPolling, type OUIActionRequest, type OUIActionResult, type OUIActivation, type OUIApprovalGrant, type OUIEffectKind, type OUIObservation, type OUIObservationSnapshot, type OUIObservationUpdate, type OUIProtocolEvent, type OUISurface, type OUISurfaceDeregistration, type OUISurfaceRegistration, type OUISurfaceSnapshot, OUI_EFFECT_ACCESS, OUI_EFFECT_KINDS, OUI_PROTOCOL_EVENTS, argsHash, canonicalJson, effectAccess, requiresApproval };
|
package/dist/spec/index.d.ts
CHANGED
|
@@ -1,3 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Approvals: an irreversible action runs only on an approval the user gave,
|
|
3
|
+
* bound to the exact request.
|
|
4
|
+
*
|
|
5
|
+
* An agent runtime stops at an action that needs approval and shows the user
|
|
6
|
+
* a confirmation. Its approval store issues a single-use grant when the user
|
|
7
|
+
* confirms, and the request that then reaches the tab carries `approval:
|
|
8
|
+
* { approvalId, argsHash }`. The surface runtime runs the action only when
|
|
9
|
+
* that matches a grant this tab received from the user's own confirmation.
|
|
10
|
+
*
|
|
11
|
+
* Everything that checks a request computes the same args hash: SHA-256 over
|
|
12
|
+
* the RFC 8785 (JCS) canonical JSON of its params, lowercase hex. The
|
|
13
|
+
* published vectors (`oui-spec/approval-vectors.json`) hold every
|
|
14
|
+
* implementation, in any language, to it.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* What using an action does. One vocabulary for every kind of action, so an
|
|
18
|
+
* action is told apart by what it changes:
|
|
19
|
+
*
|
|
20
|
+
* | Effect | What it changes | Access |
|
|
21
|
+
* |---|---|---|
|
|
22
|
+
* | `view`, `selection`, `navigate`, `open` | What is shown | read |
|
|
23
|
+
* | `edit` | The document, one undo step | write |
|
|
24
|
+
* | `file` | Imports or exports a file | write |
|
|
25
|
+
* | `mutate` | Backend data, through an API operation | write |
|
|
26
|
+
* | `job` | Starts work that outlives the call | write |
|
|
27
|
+
* | `transaction` | An irreversible external act: an order, a payment, a send, a publish | write, approved |
|
|
28
|
+
*/
|
|
29
|
+
type OUIEffectKind = "view" | "selection" | "navigate" | "open" | "edit" | "file" | "mutate" | "job" | "transaction";
|
|
30
|
+
/** Every effect, in the order of the table above. */
|
|
31
|
+
declare const OUI_EFFECT_KINDS: readonly OUIEffectKind[];
|
|
32
|
+
/** Whether an effect only changes what is shown, or changes something. */
|
|
33
|
+
declare const OUI_EFFECT_ACCESS: Readonly<Record<OUIEffectKind, "read" | "write">>;
|
|
34
|
+
/** `read` or `write`. An action that declares no effect is a `write`: nothing says it only shows. */
|
|
35
|
+
declare function effectAccess(effect: OUIEffectKind | undefined): "read" | "write";
|
|
36
|
+
/**
|
|
37
|
+
* Whether running an action needs the user's approval of the exact request: a
|
|
38
|
+
* `transaction` always, and a `write` declared destructive. An agent
|
|
39
|
+
* runtime's policy may require it of more; nothing waives these.
|
|
40
|
+
*/
|
|
41
|
+
declare function requiresApproval(effect: OUIEffectKind | undefined, destructive?: boolean): boolean;
|
|
42
|
+
/** What a request for an approved action carries. */
|
|
43
|
+
interface OUIActionApproval {
|
|
44
|
+
approvalId: string;
|
|
45
|
+
/** `argsHash(params)` of the request the user approved. */
|
|
46
|
+
argsHash: string;
|
|
47
|
+
}
|
|
48
|
+
/** A grant this tab holds: the user approved this request here. */
|
|
49
|
+
interface OUIApprovalGrant extends OUIActionApproval {
|
|
50
|
+
/** Epoch ms after which the grant no longer admits anything. */
|
|
51
|
+
expiresAt: number;
|
|
52
|
+
}
|
|
53
|
+
/** An args hash: 64 lowercase hex digits. */
|
|
54
|
+
declare const ARGS_HASH_PATTERN: RegExp;
|
|
55
|
+
/**
|
|
56
|
+
* The RFC 8785 canonical form of a JSON value:
|
|
57
|
+
* - object members sorted by their names' UTF-16 code units, with no
|
|
58
|
+
* whitespace;
|
|
59
|
+
* - numbers in ECMAScript's shortest round-trip form (`-0` is `0`);
|
|
60
|
+
* - strings escaped as ECMAScript's `JSON.stringify` escapes them.
|
|
61
|
+
*
|
|
62
|
+
* The value must be I-JSON (RFC 7493): anything JSON cannot carry — `NaN`,
|
|
63
|
+
* infinities, `undefined` outside an object member, a bigint, a function, a
|
|
64
|
+
* symbol, a class instance, or a string with a lone surrogate — is refused
|
|
65
|
+
* rather than hashed as something the other end never receives. An object
|
|
66
|
+
* member whose value is `undefined` is left out, as it is on the wire.
|
|
67
|
+
*/
|
|
68
|
+
declare function canonicalJson(value: unknown): string;
|
|
69
|
+
/** SHA-256 of the canonical JSON of a request's params, lowercase hex. Runs wherever WebCrypto does. */
|
|
70
|
+
declare function argsHash(params: unknown): Promise<string>;
|
|
71
|
+
|
|
1
72
|
/**
|
|
2
73
|
* OUI — Open UI Specification
|
|
3
74
|
*
|
|
@@ -92,11 +163,23 @@ interface OUIAction {
|
|
|
92
163
|
id: string;
|
|
93
164
|
/** Human-readable description — this is what the LLM reads to decide when to use it */
|
|
94
165
|
description: string;
|
|
166
|
+
/** The action's name as a person reads it, for a confirmation the user approves. */
|
|
167
|
+
title?: string;
|
|
168
|
+
/**
|
|
169
|
+
* What using the action does. A `transaction` runs only on the user's
|
|
170
|
+
* approval of the exact request (see `requiresApproval`). Undeclared counts
|
|
171
|
+
* as a write.
|
|
172
|
+
*/
|
|
173
|
+
effect?: OUIEffectKind;
|
|
95
174
|
/** JSON Schema for the action's input parameters */
|
|
96
175
|
input: JSONSchema;
|
|
97
176
|
/** JSON Schema for the action's return value (optional — agent still gets the result) */
|
|
98
177
|
output?: JSONSchema;
|
|
99
|
-
/**
|
|
178
|
+
/**
|
|
179
|
+
* Destructive: the action removes or replaces something the person made.
|
|
180
|
+
* Unless its effect only reads, it runs only on the user's approval of the
|
|
181
|
+
* exact request, which the surface runtime checks before it runs.
|
|
182
|
+
*/
|
|
100
183
|
confirm?: boolean;
|
|
101
184
|
/** If true, the action is async — returns immediately with a job/tracking ID */
|
|
102
185
|
async?: boolean;
|
|
@@ -159,6 +242,12 @@ interface OUIActionRequest {
|
|
|
159
242
|
params: Record<string, unknown>;
|
|
160
243
|
/** Timestamp of the request */
|
|
161
244
|
timestamp: number;
|
|
245
|
+
/**
|
|
246
|
+
* The user's approval this request runs on, for an action that needs one.
|
|
247
|
+
* The surface runtime runs such an action only when this matches a grant
|
|
248
|
+
* the tab received from the user's own confirmation, for exactly `params`.
|
|
249
|
+
*/
|
|
250
|
+
approval?: OUIActionApproval;
|
|
162
251
|
}
|
|
163
252
|
/**
|
|
164
253
|
* The result of an action execution, returned from the surface to the agent.
|
|
@@ -274,4 +363,4 @@ declare const OUI_PROTOCOL_EVENTS: {
|
|
|
274
363
|
readonly OBSERVATION_UPDATE: "observation:update";
|
|
275
364
|
};
|
|
276
365
|
|
|
277
|
-
export { type JSONSchema, type OUIAction, type OUIActionPolling, type OUIActionRequest, type OUIActionResult, type OUIActivation, type OUIObservation, type OUIObservationSnapshot, type OUIObservationUpdate, type OUIProtocolEvent, type OUISurface, type OUISurfaceDeregistration, type OUISurfaceRegistration, type OUISurfaceSnapshot, OUI_PROTOCOL_EVENTS };
|
|
366
|
+
export { ARGS_HASH_PATTERN, type JSONSchema, type OUIAction, type OUIActionApproval, type OUIActionPolling, type OUIActionRequest, type OUIActionResult, type OUIActivation, type OUIApprovalGrant, type OUIEffectKind, type OUIObservation, type OUIObservationSnapshot, type OUIObservationUpdate, type OUIProtocolEvent, type OUISurface, type OUISurfaceDeregistration, type OUISurfaceRegistration, type OUISurfaceSnapshot, OUI_EFFECT_ACCESS, OUI_EFFECT_KINDS, OUI_PROTOCOL_EVENTS, argsHash, canonicalJson, effectAccess, requiresApproval };
|
package/dist/spec/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { OUI_PROTOCOL_EVENTS } from '../chunk-
|
|
1
|
+
export { ARGS_HASH_PATTERN, OUI_EFFECT_ACCESS, OUI_EFFECT_KINDS, OUI_PROTOCOL_EVENTS, argsHash, canonicalJson, effectAccess, requiresApproval } from '../chunk-BNGJJM3T.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JSONSchema, OUIActionPolling, OUIActivation, OUISurface, OUISurfaceSnapshot, OUIActionRequest, OUIActionResult } from './spec/index.js';
|
|
1
|
+
import { OUIEffectKind, JSONSchema, OUIActionPolling, OUIActivation, OUISurface, OUISurfaceSnapshot, OUIActionRequest, OUIActionResult, OUIApprovalGrant } from './spec/index.js';
|
|
2
2
|
import { S as SocketLike, d as OUITransportConfig } from './websocket-c5tIUWY5.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -61,8 +61,13 @@ interface ActionPollingConfig<TContext = unknown> extends OUIActionPolling {
|
|
|
61
61
|
interface ActionDefinition<TContext = unknown> {
|
|
62
62
|
id: string;
|
|
63
63
|
description: string;
|
|
64
|
+
/** Its name as a person reads it, for a confirmation the user approves. */
|
|
65
|
+
title?: string;
|
|
66
|
+
/** What using it does; a `transaction` runs only on the user's approval of the exact request. */
|
|
67
|
+
effect?: OUIEffectKind;
|
|
64
68
|
input: JSONSchema;
|
|
65
69
|
output?: JSONSchema;
|
|
70
|
+
/** Destructive: it runs only on the user's approval of the exact request, unless it only reads. */
|
|
66
71
|
confirm?: boolean;
|
|
67
72
|
async?: boolean;
|
|
68
73
|
/**
|
|
@@ -241,6 +246,14 @@ interface SurfaceRuntime {
|
|
|
241
246
|
* code still loading or a page fetching the data it will display.
|
|
242
247
|
*/
|
|
243
248
|
hold(): () => void;
|
|
249
|
+
/**
|
|
250
|
+
* Record that the user approved one request, here, through their own
|
|
251
|
+
* confirmation (the agent runtime's approval store answered it to this tab).
|
|
252
|
+
* An action that needs approval — a `transaction`, or a destructive write —
|
|
253
|
+
* runs only on a request whose `approval` matches an unused, unexpired grant
|
|
254
|
+
* for exactly its params. Each grant admits one request.
|
|
255
|
+
*/
|
|
256
|
+
grantApproval(grant: OUIApprovalGrant): void;
|
|
244
257
|
/** Called whenever the snapshot changes. */
|
|
245
258
|
subscribe(listener: () => void): () => void;
|
|
246
259
|
/** Stop polling, detach from the socket and forget every mount. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JSONSchema, OUIActionPolling, OUIActivation, OUISurface, OUISurfaceSnapshot, OUIActionRequest, OUIActionResult } from './spec/index.cjs';
|
|
1
|
+
import { OUIEffectKind, JSONSchema, OUIActionPolling, OUIActivation, OUISurface, OUISurfaceSnapshot, OUIActionRequest, OUIActionResult, OUIApprovalGrant } from './spec/index.cjs';
|
|
2
2
|
import { S as SocketLike, d as OUITransportConfig } from './websocket-YfWILdZ4.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -61,8 +61,13 @@ interface ActionPollingConfig<TContext = unknown> extends OUIActionPolling {
|
|
|
61
61
|
interface ActionDefinition<TContext = unknown> {
|
|
62
62
|
id: string;
|
|
63
63
|
description: string;
|
|
64
|
+
/** Its name as a person reads it, for a confirmation the user approves. */
|
|
65
|
+
title?: string;
|
|
66
|
+
/** What using it does; a `transaction` runs only on the user's approval of the exact request. */
|
|
67
|
+
effect?: OUIEffectKind;
|
|
64
68
|
input: JSONSchema;
|
|
65
69
|
output?: JSONSchema;
|
|
70
|
+
/** Destructive: it runs only on the user's approval of the exact request, unless it only reads. */
|
|
66
71
|
confirm?: boolean;
|
|
67
72
|
async?: boolean;
|
|
68
73
|
/**
|
|
@@ -241,6 +246,14 @@ interface SurfaceRuntime {
|
|
|
241
246
|
* code still loading or a page fetching the data it will display.
|
|
242
247
|
*/
|
|
243
248
|
hold(): () => void;
|
|
249
|
+
/**
|
|
250
|
+
* Record that the user approved one request, here, through their own
|
|
251
|
+
* confirmation (the agent runtime's approval store answered it to this tab).
|
|
252
|
+
* An action that needs approval — a `transaction`, or a destructive write —
|
|
253
|
+
* runs only on a request whose `approval` matches an unused, unexpired grant
|
|
254
|
+
* for exactly its params. Each grant admits one request.
|
|
255
|
+
*/
|
|
256
|
+
grantApproval(grant: OUIApprovalGrant): void;
|
|
244
257
|
/** Called whenever the snapshot changes. */
|
|
245
258
|
subscribe(listener: () => void): () => void;
|
|
246
259
|
/** Stop polling, detach from the socket and forget every mount. */
|
package/dist/transport/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkROGKEMLL_cjs = require('../chunk-ROGKEMLL.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkXUX4XVP3_cjs = require('../chunk-XUX4XVP3.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "createDirectTransportPair", {
|
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "createWebSocketTransport", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkXUX4XVP3_cjs.createWebSocketTransport; }
|
|
15
15
|
});
|
|
16
16
|
//# sourceMappingURL=index.cjs.map
|
|
17
17
|
//# sourceMappingURL=index.cjs.map
|
package/dist/transport/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oui-spec",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "OUI
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "OUI \u2014 The OpenUI Specification. A machine-readable contract for agent-controllable user interfaces.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"types": "./dist/transport/index.d.ts",
|
|
31
31
|
"import": "./dist/transport/index.js",
|
|
32
32
|
"require": "./dist/transport/index.cjs"
|
|
33
|
-
}
|
|
33
|
+
},
|
|
34
|
+
"./approval-vectors.json": "./spec/approval-vectors.json"
|
|
34
35
|
},
|
|
35
36
|
"typesVersions": {
|
|
36
37
|
"*": {
|