oui-spec 0.2.0 → 0.3.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 +94 -122
- package/dist/{chunk-CVUUSPF4.js → chunk-BMCL2K74.js} +2 -2
- package/dist/chunk-BMCL2K74.js.map +1 -0
- package/dist/{chunk-MTMEW6MM.cjs → chunk-DCVVTP3V.cjs} +72 -23
- package/dist/chunk-DCVVTP3V.cjs.map +1 -0
- package/dist/chunk-F3SKRAGU.cjs +98 -0
- package/dist/chunk-F3SKRAGU.cjs.map +1 -0
- package/dist/{chunk-YDMGV72W.js → chunk-F3WKIRAU.js} +72 -23
- package/dist/chunk-F3WKIRAU.js.map +1 -0
- package/dist/chunk-IIZ6HL2L.js +89 -0
- package/dist/chunk-IIZ6HL2L.js.map +1 -0
- package/dist/chunk-KNWGQRXL.cjs +567 -0
- package/dist/chunk-KNWGQRXL.cjs.map +1 -0
- package/dist/chunk-NYCJZQSP.js +92 -0
- package/dist/chunk-NYCJZQSP.js.map +1 -0
- package/dist/chunk-ROGKEMLL.cjs +91 -0
- package/dist/chunk-ROGKEMLL.cjs.map +1 -0
- package/dist/chunk-TRNVXAB5.js +563 -0
- package/dist/chunk-TRNVXAB5.js.map +1 -0
- package/dist/{chunk-3DCIL4FV.cjs → chunk-ZKM4XWAB.cjs} +2 -2
- package/dist/chunk-ZKM4XWAB.cjs.map +1 -0
- package/dist/core/index.cjs +10 -6
- package/dist/core/index.d.cts +15 -8
- package/dist/core/index.d.ts +15 -8
- package/dist/core/index.js +3 -3
- package/dist/index.cjs +28 -12
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +5 -5
- package/dist/react/index.cjs +15 -3
- package/dist/react/index.d.cts +33 -50
- package/dist/react/index.d.ts +33 -50
- package/dist/react/index.js +1 -1
- package/dist/spec/index.cjs +2 -2
- package/dist/spec/index.d.cts +35 -7
- package/dist/spec/index.d.ts +35 -7
- package/dist/spec/index.js +1 -1
- package/dist/{define-surface-D6XPtoqu.d.cts → surface-runtime--2lZGB7Z.d.cts} +92 -2
- package/dist/{define-surface-DXBop-uB.d.ts → surface-runtime-Dj_nhd7r.d.ts} +92 -2
- package/dist/transport/index.cjs +4 -4
- package/dist/transport/index.d.cts +2 -2
- package/dist/transport/index.d.ts +2 -2
- package/dist/transport/index.js +2 -2
- package/dist/{websocket-CrI0yRNo.d.cts → websocket-YfWILdZ4.d.cts} +36 -18
- package/dist/{websocket-CiWvkaz_.d.ts → websocket-c5tIUWY5.d.ts} +36 -18
- package/package.json +5 -1
- package/spec/OUI-SPEC-v0.1.md +229 -155
- package/dist/chunk-2ON5IEXB.cjs +0 -167
- package/dist/chunk-2ON5IEXB.cjs.map +0 -1
- package/dist/chunk-3DCIL4FV.cjs.map +0 -1
- package/dist/chunk-5TQ6AVQH.cjs +0 -108
- package/dist/chunk-5TQ6AVQH.cjs.map +0 -1
- package/dist/chunk-CVUUSPF4.js.map +0 -1
- package/dist/chunk-HK7OXB2W.cjs +0 -157
- package/dist/chunk-HK7OXB2W.cjs.map +0 -1
- package/dist/chunk-ILUTAHUJ.js +0 -154
- package/dist/chunk-ILUTAHUJ.js.map +0 -1
- package/dist/chunk-MTMEW6MM.cjs.map +0 -1
- package/dist/chunk-O6EI77LD.js +0 -106
- package/dist/chunk-O6EI77LD.js.map +0 -1
- package/dist/chunk-UIGRLZOX.js +0 -164
- package/dist/chunk-UIGRLZOX.js.map +0 -1
- package/dist/chunk-YDMGV72W.js.map +0 -1
package/dist/spec/index.d.ts
CHANGED
|
@@ -127,7 +127,7 @@ interface OUIObservation {
|
|
|
127
127
|
/** JSON Schema for the observation's value */
|
|
128
128
|
schema: JSONSchema;
|
|
129
129
|
/** How frequently this observation updates */
|
|
130
|
-
updateFrequency?:
|
|
130
|
+
updateFrequency?: "realtime" | "on-change" | "polling";
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
133
|
* Activation conditions — when a surface is available to the agent.
|
|
@@ -184,6 +184,34 @@ interface OUIActionResult {
|
|
|
184
184
|
durationMs?: number;
|
|
185
185
|
/** Timestamp of the result */
|
|
186
186
|
timestamp: number;
|
|
187
|
+
/**
|
|
188
|
+
* The surfaces active on the client once the action's effects settled.
|
|
189
|
+
*
|
|
190
|
+
* An action can change what the agent is able to do next: navigating
|
|
191
|
+
* unmounts one page's surfaces and mounts another's. Without this, the agent
|
|
192
|
+
* would act on the capability set it had before the action, which is the
|
|
193
|
+
* set the action just replaced.
|
|
194
|
+
*/
|
|
195
|
+
surfaces?: OUISurface[];
|
|
196
|
+
/** Latest observation values per surface once the action's effects settled. */
|
|
197
|
+
observations?: OUIObservationSnapshot;
|
|
198
|
+
/**
|
|
199
|
+
* False when the client's deadline passed before its UI settled, so
|
|
200
|
+
* `surfaces` and `observations` may still be changing. Absent or true
|
|
201
|
+
* otherwise.
|
|
202
|
+
*/
|
|
203
|
+
settled?: boolean;
|
|
204
|
+
}
|
|
205
|
+
/** Latest observation values, keyed by surface id and then observation id. */
|
|
206
|
+
type OUIObservationSnapshot = Record<string, Record<string, unknown>>;
|
|
207
|
+
/**
|
|
208
|
+
* What a client can do right now: the surfaces it has mounted and their latest
|
|
209
|
+
* observation values. A client sends this to its agent runtime (for example,
|
|
210
|
+
* with each turn), and returns it on every action result.
|
|
211
|
+
*/
|
|
212
|
+
interface OUISurfaceSnapshot {
|
|
213
|
+
surfaces: OUISurface[];
|
|
214
|
+
observations: OUIObservationSnapshot;
|
|
187
215
|
}
|
|
188
216
|
/**
|
|
189
217
|
* An observation update pushed from the surface to the agent.
|
|
@@ -220,19 +248,19 @@ interface OUISurfaceDeregistration {
|
|
|
220
248
|
* All protocol events exchanged between agent runtime and surfaces.
|
|
221
249
|
*/
|
|
222
250
|
type OUIProtocolEvent = {
|
|
223
|
-
type:
|
|
251
|
+
type: "surface:register";
|
|
224
252
|
payload: OUISurfaceRegistration;
|
|
225
253
|
} | {
|
|
226
|
-
type:
|
|
254
|
+
type: "surface:deregister";
|
|
227
255
|
payload: OUISurfaceDeregistration;
|
|
228
256
|
} | {
|
|
229
|
-
type:
|
|
257
|
+
type: "action:request";
|
|
230
258
|
payload: OUIActionRequest;
|
|
231
259
|
} | {
|
|
232
|
-
type:
|
|
260
|
+
type: "action:result";
|
|
233
261
|
payload: OUIActionResult;
|
|
234
262
|
} | {
|
|
235
|
-
type:
|
|
263
|
+
type: "observation:update";
|
|
236
264
|
payload: OUIObservationUpdate;
|
|
237
265
|
};
|
|
238
266
|
/**
|
|
@@ -246,4 +274,4 @@ declare const OUI_PROTOCOL_EVENTS: {
|
|
|
246
274
|
readonly OBSERVATION_UPDATE: "observation:update";
|
|
247
275
|
};
|
|
248
276
|
|
|
249
|
-
export { type JSONSchema, type OUIAction, type OUIActionPolling, type OUIActionRequest, type OUIActionResult, type OUIActivation, type OUIObservation, type OUIObservationUpdate, type OUIProtocolEvent, type OUISurface, type OUISurfaceDeregistration, type OUISurfaceRegistration, OUI_PROTOCOL_EVENTS };
|
|
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 };
|
package/dist/spec/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { JSONSchema, OUIActionPolling, OUIActivation, OUISurface } from './spec/index.cjs';
|
|
1
|
+
import { JSONSchema, OUIActionPolling, OUIActivation, OUISurface, OUISurfaceSnapshot, OUIActionRequest, OUIActionResult } from './spec/index.cjs';
|
|
2
|
+
import { S as SocketLike, d as OUITransportConfig } from './websocket-YfWILdZ4.cjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Nominal branding for values OUI must construct itself.
|
|
@@ -148,4 +149,93 @@ interface DefinedSurface<TContext = unknown> extends SurfaceDefinition<TContext>
|
|
|
148
149
|
getPollingConfig(actionId: string): OUIActionPolling | undefined;
|
|
149
150
|
}
|
|
150
151
|
|
|
151
|
-
|
|
152
|
+
/**
|
|
153
|
+
* The client-side surface runtime.
|
|
154
|
+
*
|
|
155
|
+
* Holds the surfaces a client has mounted, answers every action request with a
|
|
156
|
+
* result, and produces the snapshot an agent runtime works from.
|
|
157
|
+
*
|
|
158
|
+
* WHY THIS EXISTS
|
|
159
|
+
*
|
|
160
|
+
* The first integration kept no client-side record of what was mounted. Each
|
|
161
|
+
* surface hook registered itself with a server-side registry and listened for
|
|
162
|
+
* dispatches on its own. Three things followed:
|
|
163
|
+
*
|
|
164
|
+
* - The registry was the only record of what the client could do, and it lost
|
|
165
|
+
* entries: a dead socket's cleanup removed a live tab's registration, and the
|
|
166
|
+
* browser never registered again. The agent then had no UI tools at all.
|
|
167
|
+
* - Nothing answered a dispatch. The agent was told an action succeeded before
|
|
168
|
+
* the client had run it, and never saw the page an action led to.
|
|
169
|
+
* - Every hook listened independently, through two paths, so one dispatch ran
|
|
170
|
+
* twice and nothing de-duplicated it.
|
|
171
|
+
*
|
|
172
|
+
* Here the client is the record. `snapshot()` is what the client can do right
|
|
173
|
+
* now, and every request is run once, waited on until the UI settles, and
|
|
174
|
+
* answered with its result and the snapshot after it.
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
interface SettleOptions {
|
|
178
|
+
/**
|
|
179
|
+
* The UI counts as settled once nothing has mounted, unmounted or changed an
|
|
180
|
+
* observation for this long, and no hold is open. Default 250 ms.
|
|
181
|
+
*/
|
|
182
|
+
quietMs?: number;
|
|
183
|
+
/** Give up waiting after this long and answer with `settled: false`. Default 5000 ms. */
|
|
184
|
+
timeoutMs?: number;
|
|
185
|
+
}
|
|
186
|
+
interface SurfaceRuntimeOptions {
|
|
187
|
+
/** The socket to answer requests on. Can be set or replaced later with `attach`. */
|
|
188
|
+
socket?: SocketLike | null;
|
|
189
|
+
/** Wire configuration for the transport the runtime builds on the socket. */
|
|
190
|
+
transport?: OUITransportConfig;
|
|
191
|
+
/**
|
|
192
|
+
* Also announce registrations and observations over the transport, for agent
|
|
193
|
+
* runtimes that keep a server-side registry. Default true.
|
|
194
|
+
*
|
|
195
|
+
* An agent runtime that takes the client's snapshot instead (sent with each
|
|
196
|
+
* turn, and returned on every result) has no use for them: set false.
|
|
197
|
+
*/
|
|
198
|
+
announce?: boolean;
|
|
199
|
+
settle?: SettleOptions;
|
|
200
|
+
/** How many answered request ids to remember, for de-duplication. Default 500. */
|
|
201
|
+
dedupeWindow?: number;
|
|
202
|
+
}
|
|
203
|
+
interface MountedSurface {
|
|
204
|
+
readonly surfaceId: string;
|
|
205
|
+
/** Record an observation value. A no-op once unmounted. */
|
|
206
|
+
pushObservation(observationId: string, value: unknown): void;
|
|
207
|
+
/** Remove this mount. Other mounts of the same surface id are unaffected. */
|
|
208
|
+
unmount(): void;
|
|
209
|
+
}
|
|
210
|
+
interface SurfaceRuntime {
|
|
211
|
+
/**
|
|
212
|
+
* Mount a surface. `getContext` is read when an action runs, so handlers see
|
|
213
|
+
* the latest state rather than the state at mount time.
|
|
214
|
+
*
|
|
215
|
+
* Mounting the same surface id twice is allowed (React StrictMode does it on
|
|
216
|
+
* every mount); the most recent mount serves its actions.
|
|
217
|
+
*/
|
|
218
|
+
mount<TContext>(surface: DefinedSurface<TContext>, getContext: () => TContext): MountedSurface;
|
|
219
|
+
/** Answer requests arriving on this socket (null detaches). */
|
|
220
|
+
attach(socket: SocketLike | null): void;
|
|
221
|
+
/** What the client can do right now. */
|
|
222
|
+
snapshot(): OUISurfaceSnapshot;
|
|
223
|
+
/**
|
|
224
|
+
* Run a request once and resolve with its result. A request id seen before
|
|
225
|
+
* resolves with the first result instead of running again.
|
|
226
|
+
*/
|
|
227
|
+
execute(request: OUIActionRequest): Promise<OUIActionResult>;
|
|
228
|
+
/**
|
|
229
|
+
* Keep the UI unsettled until the returned function is called. For work an
|
|
230
|
+
* action starts that mounting and unmounting cannot show, such as a route's
|
|
231
|
+
* code still loading or a page fetching the data it will display.
|
|
232
|
+
*/
|
|
233
|
+
hold(): () => void;
|
|
234
|
+
/** Called whenever the snapshot changes. */
|
|
235
|
+
subscribe(listener: () => void): () => void;
|
|
236
|
+
/** Stop polling, detach from the socket and forget every mount. */
|
|
237
|
+
dispose(): void;
|
|
238
|
+
}
|
|
239
|
+
declare function createSurfaceRuntime(options?: SurfaceRuntimeOptions): SurfaceRuntime;
|
|
240
|
+
|
|
241
|
+
export { type ActionDefinition as A, type DefinedSurface as D, type MountedSurface as M, type OUIBranded as O, type SettleOptions as S, type ActionHandlerResult as a, type ActionPollingConfig as b, type ObservationDefinition as c, type SurfaceDefinition as d, type SurfaceRuntime as e, type SurfaceRuntimeOptions as f, createSurfaceRuntime as g, defineSurface as h };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { JSONSchema, OUIActionPolling, OUIActivation, OUISurface } from './spec/index.js';
|
|
1
|
+
import { JSONSchema, OUIActionPolling, OUIActivation, OUISurface, OUISurfaceSnapshot, OUIActionRequest, OUIActionResult } from './spec/index.js';
|
|
2
|
+
import { S as SocketLike, d as OUITransportConfig } from './websocket-c5tIUWY5.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Nominal branding for values OUI must construct itself.
|
|
@@ -148,4 +149,93 @@ interface DefinedSurface<TContext = unknown> extends SurfaceDefinition<TContext>
|
|
|
148
149
|
getPollingConfig(actionId: string): OUIActionPolling | undefined;
|
|
149
150
|
}
|
|
150
151
|
|
|
151
|
-
|
|
152
|
+
/**
|
|
153
|
+
* The client-side surface runtime.
|
|
154
|
+
*
|
|
155
|
+
* Holds the surfaces a client has mounted, answers every action request with a
|
|
156
|
+
* result, and produces the snapshot an agent runtime works from.
|
|
157
|
+
*
|
|
158
|
+
* WHY THIS EXISTS
|
|
159
|
+
*
|
|
160
|
+
* The first integration kept no client-side record of what was mounted. Each
|
|
161
|
+
* surface hook registered itself with a server-side registry and listened for
|
|
162
|
+
* dispatches on its own. Three things followed:
|
|
163
|
+
*
|
|
164
|
+
* - The registry was the only record of what the client could do, and it lost
|
|
165
|
+
* entries: a dead socket's cleanup removed a live tab's registration, and the
|
|
166
|
+
* browser never registered again. The agent then had no UI tools at all.
|
|
167
|
+
* - Nothing answered a dispatch. The agent was told an action succeeded before
|
|
168
|
+
* the client had run it, and never saw the page an action led to.
|
|
169
|
+
* - Every hook listened independently, through two paths, so one dispatch ran
|
|
170
|
+
* twice and nothing de-duplicated it.
|
|
171
|
+
*
|
|
172
|
+
* Here the client is the record. `snapshot()` is what the client can do right
|
|
173
|
+
* now, and every request is run once, waited on until the UI settles, and
|
|
174
|
+
* answered with its result and the snapshot after it.
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
interface SettleOptions {
|
|
178
|
+
/**
|
|
179
|
+
* The UI counts as settled once nothing has mounted, unmounted or changed an
|
|
180
|
+
* observation for this long, and no hold is open. Default 250 ms.
|
|
181
|
+
*/
|
|
182
|
+
quietMs?: number;
|
|
183
|
+
/** Give up waiting after this long and answer with `settled: false`. Default 5000 ms. */
|
|
184
|
+
timeoutMs?: number;
|
|
185
|
+
}
|
|
186
|
+
interface SurfaceRuntimeOptions {
|
|
187
|
+
/** The socket to answer requests on. Can be set or replaced later with `attach`. */
|
|
188
|
+
socket?: SocketLike | null;
|
|
189
|
+
/** Wire configuration for the transport the runtime builds on the socket. */
|
|
190
|
+
transport?: OUITransportConfig;
|
|
191
|
+
/**
|
|
192
|
+
* Also announce registrations and observations over the transport, for agent
|
|
193
|
+
* runtimes that keep a server-side registry. Default true.
|
|
194
|
+
*
|
|
195
|
+
* An agent runtime that takes the client's snapshot instead (sent with each
|
|
196
|
+
* turn, and returned on every result) has no use for them: set false.
|
|
197
|
+
*/
|
|
198
|
+
announce?: boolean;
|
|
199
|
+
settle?: SettleOptions;
|
|
200
|
+
/** How many answered request ids to remember, for de-duplication. Default 500. */
|
|
201
|
+
dedupeWindow?: number;
|
|
202
|
+
}
|
|
203
|
+
interface MountedSurface {
|
|
204
|
+
readonly surfaceId: string;
|
|
205
|
+
/** Record an observation value. A no-op once unmounted. */
|
|
206
|
+
pushObservation(observationId: string, value: unknown): void;
|
|
207
|
+
/** Remove this mount. Other mounts of the same surface id are unaffected. */
|
|
208
|
+
unmount(): void;
|
|
209
|
+
}
|
|
210
|
+
interface SurfaceRuntime {
|
|
211
|
+
/**
|
|
212
|
+
* Mount a surface. `getContext` is read when an action runs, so handlers see
|
|
213
|
+
* the latest state rather than the state at mount time.
|
|
214
|
+
*
|
|
215
|
+
* Mounting the same surface id twice is allowed (React StrictMode does it on
|
|
216
|
+
* every mount); the most recent mount serves its actions.
|
|
217
|
+
*/
|
|
218
|
+
mount<TContext>(surface: DefinedSurface<TContext>, getContext: () => TContext): MountedSurface;
|
|
219
|
+
/** Answer requests arriving on this socket (null detaches). */
|
|
220
|
+
attach(socket: SocketLike | null): void;
|
|
221
|
+
/** What the client can do right now. */
|
|
222
|
+
snapshot(): OUISurfaceSnapshot;
|
|
223
|
+
/**
|
|
224
|
+
* Run a request once and resolve with its result. A request id seen before
|
|
225
|
+
* resolves with the first result instead of running again.
|
|
226
|
+
*/
|
|
227
|
+
execute(request: OUIActionRequest): Promise<OUIActionResult>;
|
|
228
|
+
/**
|
|
229
|
+
* Keep the UI unsettled until the returned function is called. For work an
|
|
230
|
+
* action starts that mounting and unmounting cannot show, such as a route's
|
|
231
|
+
* code still loading or a page fetching the data it will display.
|
|
232
|
+
*/
|
|
233
|
+
hold(): () => void;
|
|
234
|
+
/** Called whenever the snapshot changes. */
|
|
235
|
+
subscribe(listener: () => void): () => void;
|
|
236
|
+
/** Stop polling, detach from the socket and forget every mount. */
|
|
237
|
+
dispose(): void;
|
|
238
|
+
}
|
|
239
|
+
declare function createSurfaceRuntime(options?: SurfaceRuntimeOptions): SurfaceRuntime;
|
|
240
|
+
|
|
241
|
+
export { type ActionDefinition as A, type DefinedSurface as D, type MountedSurface as M, type OUIBranded as O, type SettleOptions as S, type ActionHandlerResult as a, type ActionPollingConfig as b, type ObservationDefinition as c, type SurfaceDefinition as d, type SurfaceRuntime as e, type SurfaceRuntimeOptions as f, createSurfaceRuntime as g, defineSurface as h };
|
package/dist/transport/index.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkROGKEMLL_cjs = require('../chunk-ROGKEMLL.cjs');
|
|
4
|
+
var chunkDCVVTP3V_cjs = require('../chunk-DCVVTP3V.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "createDirectTransportPair", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkROGKEMLL_cjs.createDirectTransportPair; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "createWebSocketTransport", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkDCVVTP3V_cjs.createWebSocketTransport; }
|
|
15
15
|
});
|
|
16
16
|
//# sourceMappingURL=index.cjs.map
|
|
17
17
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { O as OUIActionHandler, a as OUIObservationHandler,
|
|
1
|
+
import { c as OUITransport } from '../websocket-YfWILdZ4.cjs';
|
|
2
|
+
export { O as OUIActionHandler, a as OUIObservationHandler, b as OUIResultHandler, d as OUITransportConfig, S as SocketLike, e as createWebSocketTransport } from '../websocket-YfWILdZ4.cjs';
|
|
3
3
|
import '../spec/index.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { O as OUIActionHandler, a as OUIObservationHandler,
|
|
1
|
+
import { c as OUITransport } from '../websocket-c5tIUWY5.js';
|
|
2
|
+
export { O as OUIActionHandler, a as OUIObservationHandler, b as OUIResultHandler, d as OUITransportConfig, S as SocketLike, e as createWebSocketTransport } from '../websocket-c5tIUWY5.js';
|
|
3
3
|
import '../spec/index.js';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/transport/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createDirectTransportPair } from '../chunk-
|
|
2
|
-
export { createWebSocketTransport } from '../chunk-
|
|
1
|
+
export { createDirectTransportPair } from '../chunk-IIZ6HL2L.js';
|
|
2
|
+
export { createWebSocketTransport } from '../chunk-F3WKIRAU.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
import { OUIObservationUpdate, OUISurface } from './spec/index.cjs';
|
|
1
|
+
import { OUIActionRequest, OUIActionResult, OUIObservationUpdate, OUISurface } from './spec/index.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* OUI Transport — the wire protocol between agent runtime and surfaces.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
6
|
+
* - Dispatch (runtime → client): an `OUIActionRequest`, carrying a `requestId`.
|
|
7
|
+
* - Result (client → runtime): the `OUIActionResult` for that `requestId`.
|
|
8
|
+
* - Observations (client → runtime): state updates pushed as they happen.
|
|
9
|
+
* - Surface lifecycle (client → runtime): registration, for runtimes that keep
|
|
10
|
+
* a server-side registry. A runtime can instead take the client's snapshot.
|
|
9
11
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
+
* Every dispatch is answered by exactly one result. An earlier version of this
|
|
13
|
+
* transport had no correlation id and no result channel, so an agent could
|
|
14
|
+
* never learn whether its action ran, and was told it succeeded before the
|
|
15
|
+
* client had done anything.
|
|
12
16
|
*/
|
|
13
17
|
interface OUITransport {
|
|
14
|
-
/**
|
|
15
|
-
dispatch(
|
|
16
|
-
/** Receive
|
|
18
|
+
/** Send an action request to the client. */
|
|
19
|
+
dispatch(request: OUIActionRequest): void;
|
|
20
|
+
/** Receive action requests (client side). */
|
|
17
21
|
onAction(handler: OUIActionHandler): () => void;
|
|
22
|
+
/** Answer an action request (client side). */
|
|
23
|
+
sendResult(result: OUIActionResult): void;
|
|
24
|
+
/** Receive action results (runtime side). */
|
|
25
|
+
onResult(handler: OUIResultHandler): () => void;
|
|
18
26
|
/** Push an observation update from the surface to the agent runtime */
|
|
19
27
|
pushObservation(update: OUIObservationUpdate): void;
|
|
20
28
|
/** Receive observation updates (runtime/server side) */
|
|
@@ -29,11 +37,20 @@ interface OUITransport {
|
|
|
29
37
|
onSurfaceDeregister(handler: (surfaceId: string) => void): () => void;
|
|
30
38
|
readonly connected: boolean;
|
|
31
39
|
connect(): Promise<void>;
|
|
40
|
+
/** Disconnect the underlying socket. The integrator owns the socket: prefer `dispose`. */
|
|
32
41
|
disconnect(): void;
|
|
33
42
|
onConnectionChange(handler: (connected: boolean) => void): () => void;
|
|
43
|
+
/**
|
|
44
|
+
* Detach every listener this transport attached to its socket, and leave the
|
|
45
|
+
* socket connected. A socket outlives the transports built on it; without
|
|
46
|
+
* this, each one leaked its connection listeners onto the shared socket.
|
|
47
|
+
*/
|
|
48
|
+
dispose(): void;
|
|
34
49
|
}
|
|
35
|
-
/** Handler for incoming action
|
|
36
|
-
type OUIActionHandler = (
|
|
50
|
+
/** Handler for incoming action requests (client side) */
|
|
51
|
+
type OUIActionHandler = (request: OUIActionRequest) => void;
|
|
52
|
+
/** Handler for incoming action results (runtime side) */
|
|
53
|
+
type OUIResultHandler = (result: OUIActionResult) => void;
|
|
37
54
|
/** Handler for incoming observation updates (server side) */
|
|
38
55
|
type OUIObservationHandler = (update: OUIObservationUpdate) => void;
|
|
39
56
|
/**
|
|
@@ -44,7 +61,7 @@ interface OUITransportConfig {
|
|
|
44
61
|
namespace?: string;
|
|
45
62
|
/** Connection timeout in ms */
|
|
46
63
|
connectTimeoutMs?: number;
|
|
47
|
-
/** Whether to buffer
|
|
64
|
+
/** Whether to buffer outbound messages while disconnected */
|
|
48
65
|
bufferWhileDisconnected?: boolean;
|
|
49
66
|
/** Max buffer size (messages dropped after this) */
|
|
50
67
|
maxBufferSize?: number;
|
|
@@ -54,11 +71,12 @@ interface OUITransportConfig {
|
|
|
54
71
|
* WebSocket transport using Socket.IO.
|
|
55
72
|
* Maps OUI protocol events to socket events with a configurable namespace prefix.
|
|
56
73
|
*
|
|
57
|
-
* Events
|
|
58
|
-
* {ns}:dispatch
|
|
59
|
-
* {ns}:
|
|
60
|
-
* {ns}:
|
|
61
|
-
* {ns}:surface:
|
|
74
|
+
* Events:
|
|
75
|
+
* {ns}:dispatch — action request (runtime → client)
|
|
76
|
+
* {ns}:action:result — action result (client → runtime)
|
|
77
|
+
* {ns}:observation — observation (client → runtime)
|
|
78
|
+
* {ns}:surface:register — registration (client → runtime)
|
|
79
|
+
* {ns}:surface:deregister — deregistration (client → runtime)
|
|
62
80
|
*/
|
|
63
81
|
declare function createWebSocketTransport(socket: SocketLike, config?: OUITransportConfig): OUITransport;
|
|
64
82
|
/**
|
|
@@ -75,4 +93,4 @@ interface SocketLike {
|
|
|
75
93
|
disconnect?(): void;
|
|
76
94
|
}
|
|
77
95
|
|
|
78
|
-
export { type OUIActionHandler as O, type SocketLike as S, type OUIObservationHandler as a, type
|
|
96
|
+
export { type OUIActionHandler as O, type SocketLike as S, type OUIObservationHandler as a, type OUIResultHandler as b, type OUITransport as c, type OUITransportConfig as d, createWebSocketTransport as e };
|
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
import { OUIObservationUpdate, OUISurface } from './spec/index.js';
|
|
1
|
+
import { OUIActionRequest, OUIActionResult, OUIObservationUpdate, OUISurface } from './spec/index.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* OUI Transport — the wire protocol between agent runtime and surfaces.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
6
|
+
* - Dispatch (runtime → client): an `OUIActionRequest`, carrying a `requestId`.
|
|
7
|
+
* - Result (client → runtime): the `OUIActionResult` for that `requestId`.
|
|
8
|
+
* - Observations (client → runtime): state updates pushed as they happen.
|
|
9
|
+
* - Surface lifecycle (client → runtime): registration, for runtimes that keep
|
|
10
|
+
* a server-side registry. A runtime can instead take the client's snapshot.
|
|
9
11
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
+
* Every dispatch is answered by exactly one result. An earlier version of this
|
|
13
|
+
* transport had no correlation id and no result channel, so an agent could
|
|
14
|
+
* never learn whether its action ran, and was told it succeeded before the
|
|
15
|
+
* client had done anything.
|
|
12
16
|
*/
|
|
13
17
|
interface OUITransport {
|
|
14
|
-
/**
|
|
15
|
-
dispatch(
|
|
16
|
-
/** Receive
|
|
18
|
+
/** Send an action request to the client. */
|
|
19
|
+
dispatch(request: OUIActionRequest): void;
|
|
20
|
+
/** Receive action requests (client side). */
|
|
17
21
|
onAction(handler: OUIActionHandler): () => void;
|
|
22
|
+
/** Answer an action request (client side). */
|
|
23
|
+
sendResult(result: OUIActionResult): void;
|
|
24
|
+
/** Receive action results (runtime side). */
|
|
25
|
+
onResult(handler: OUIResultHandler): () => void;
|
|
18
26
|
/** Push an observation update from the surface to the agent runtime */
|
|
19
27
|
pushObservation(update: OUIObservationUpdate): void;
|
|
20
28
|
/** Receive observation updates (runtime/server side) */
|
|
@@ -29,11 +37,20 @@ interface OUITransport {
|
|
|
29
37
|
onSurfaceDeregister(handler: (surfaceId: string) => void): () => void;
|
|
30
38
|
readonly connected: boolean;
|
|
31
39
|
connect(): Promise<void>;
|
|
40
|
+
/** Disconnect the underlying socket. The integrator owns the socket: prefer `dispose`. */
|
|
32
41
|
disconnect(): void;
|
|
33
42
|
onConnectionChange(handler: (connected: boolean) => void): () => void;
|
|
43
|
+
/**
|
|
44
|
+
* Detach every listener this transport attached to its socket, and leave the
|
|
45
|
+
* socket connected. A socket outlives the transports built on it; without
|
|
46
|
+
* this, each one leaked its connection listeners onto the shared socket.
|
|
47
|
+
*/
|
|
48
|
+
dispose(): void;
|
|
34
49
|
}
|
|
35
|
-
/** Handler for incoming action
|
|
36
|
-
type OUIActionHandler = (
|
|
50
|
+
/** Handler for incoming action requests (client side) */
|
|
51
|
+
type OUIActionHandler = (request: OUIActionRequest) => void;
|
|
52
|
+
/** Handler for incoming action results (runtime side) */
|
|
53
|
+
type OUIResultHandler = (result: OUIActionResult) => void;
|
|
37
54
|
/** Handler for incoming observation updates (server side) */
|
|
38
55
|
type OUIObservationHandler = (update: OUIObservationUpdate) => void;
|
|
39
56
|
/**
|
|
@@ -44,7 +61,7 @@ interface OUITransportConfig {
|
|
|
44
61
|
namespace?: string;
|
|
45
62
|
/** Connection timeout in ms */
|
|
46
63
|
connectTimeoutMs?: number;
|
|
47
|
-
/** Whether to buffer
|
|
64
|
+
/** Whether to buffer outbound messages while disconnected */
|
|
48
65
|
bufferWhileDisconnected?: boolean;
|
|
49
66
|
/** Max buffer size (messages dropped after this) */
|
|
50
67
|
maxBufferSize?: number;
|
|
@@ -54,11 +71,12 @@ interface OUITransportConfig {
|
|
|
54
71
|
* WebSocket transport using Socket.IO.
|
|
55
72
|
* Maps OUI protocol events to socket events with a configurable namespace prefix.
|
|
56
73
|
*
|
|
57
|
-
* Events
|
|
58
|
-
* {ns}:dispatch
|
|
59
|
-
* {ns}:
|
|
60
|
-
* {ns}:
|
|
61
|
-
* {ns}:surface:
|
|
74
|
+
* Events:
|
|
75
|
+
* {ns}:dispatch — action request (runtime → client)
|
|
76
|
+
* {ns}:action:result — action result (client → runtime)
|
|
77
|
+
* {ns}:observation — observation (client → runtime)
|
|
78
|
+
* {ns}:surface:register — registration (client → runtime)
|
|
79
|
+
* {ns}:surface:deregister — deregistration (client → runtime)
|
|
62
80
|
*/
|
|
63
81
|
declare function createWebSocketTransport(socket: SocketLike, config?: OUITransportConfig): OUITransport;
|
|
64
82
|
/**
|
|
@@ -75,4 +93,4 @@ interface SocketLike {
|
|
|
75
93
|
disconnect?(): void;
|
|
76
94
|
}
|
|
77
95
|
|
|
78
|
-
export { type OUIActionHandler as O, type SocketLike as S, type OUIObservationHandler as a, type
|
|
96
|
+
export { type OUIActionHandler as O, type SocketLike as S, type OUIObservationHandler as a, type OUIResultHandler as b, type OUITransport as c, type OUITransportConfig as d, createWebSocketTransport as e };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oui-spec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "OUI — The OpenUI Specification. A machine-readable contract for agent-controllable user interfaces.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -86,14 +86,18 @@
|
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
+
"@testing-library/react": "^16.3.3",
|
|
89
90
|
"@types/react": "^19.0.0",
|
|
91
|
+
"@types/react-dom": "^19.3.0",
|
|
90
92
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
91
93
|
"@typescript-eslint/parser": "^8.0.0",
|
|
92
94
|
"eslint": "^9.0.0",
|
|
93
95
|
"husky": "^9.1.7",
|
|
96
|
+
"jsdom": "^26.1.0",
|
|
94
97
|
"lint-staged": "^16.4.0",
|
|
95
98
|
"prettier": "^3.9.6",
|
|
96
99
|
"react": "^19.0.0",
|
|
100
|
+
"react-dom": "^19.3.0",
|
|
97
101
|
"tsup": "^8.4.0",
|
|
98
102
|
"typescript": "^5.8.0",
|
|
99
103
|
"vitest": "^3.0.0"
|