@yielded/agent-platform-cloudflare 0.1.0-beta.182 → 0.1.0-beta.185
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/dist/{BrowserCredentials-C5IWfi7f.d.mts → BrowserCredentials-C2rBhlUI.d.mts} +30 -5
- package/dist/BrowserCredentials.d.mts +2 -2
- package/dist/BrowserCredentials.mjs +28 -8
- package/dist/BrowserCredentials.mjs.map +1 -1
- package/dist/{BrowserSession-aovMjfL4.mjs → BrowserSession-CfivQ5JY.mjs} +150 -65
- package/dist/BrowserSession-CfivQ5JY.mjs.map +1 -0
- package/dist/{BrowserSession-Cojp7nth.d.mts → BrowserSession-mKnLSc3p.d.mts} +8 -2
- package/dist/BrowserSession.d.mts +1 -1
- package/dist/BrowserSession.mjs +2 -2
- package/dist/BrowserUse.d.mts +1 -1
- package/dist/BrowserUse.mjs +31 -4
- package/dist/BrowserUse.mjs.map +1 -1
- package/dist/CloudflareBindings.d.mts +6 -2
- package/dist/CloudflareBindings.mjs.map +1 -1
- package/dist/CloudflareScheduling.mjs +2 -2
- package/dist/CloudflareSubscriptions.mjs +2 -2
- package/dist/{CloudflareThreadClient-B9ODixhk.d.mts → CloudflareThreadClient-CmlojpjC.d.mts} +205 -199
- package/dist/{CloudflareThreadClient-CEUjVwis.mjs → CloudflareThreadClient-CnvMXPmV.mjs} +17 -6
- package/dist/CloudflareThreadClient-CnvMXPmV.mjs.map +1 -0
- package/dist/CloudflareThreadClient.d.mts +1 -1
- package/dist/CloudflareThreadClient.mjs +1 -1
- package/dist/{InteractiveBrowser-BHNlwjZL.mjs → InteractiveBrowser-nukKxc87.mjs} +4 -45
- package/dist/InteractiveBrowser-nukKxc87.mjs.map +1 -0
- package/dist/InteractiveBrowser.mjs +1 -1
- package/dist/{ThreadObject-vmc0jRTS.mjs → ThreadObject-Cr1CFWXb.mjs} +98 -60
- package/dist/ThreadObject-Cr1CFWXb.mjs.map +1 -0
- package/dist/{ThreadObject-wS46Yxq3.d.mts → ThreadObject-Osn-FmcF.d.mts} +3 -3
- package/dist/ThreadObject.d.mts +1 -1
- package/dist/ThreadObject.mjs +1 -1
- package/dist/browser-failure-DECzRY3H.mjs +50 -0
- package/dist/browser-failure-DECzRY3H.mjs.map +1 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +3 -3
- package/dist/{prepared-admission-C3uBqIz0.mjs → prepared-admission-w2Kq32_k.mjs} +2 -2
- package/dist/{prepared-admission-C3uBqIz0.mjs.map → prepared-admission-w2Kq32_k.mjs.map} +1 -1
- package/package.json +1 -1
- package/src/BrowserCredentials.ts +42 -9
- package/src/BrowserSession.ts +88 -8
- package/src/BrowserUse.ts +51 -4
- package/src/CloudflareBindings.ts +6 -2
- package/src/CloudflareThreadClient.ts +18 -4
- package/src/internal/browser-credentials.ts +205 -98
- package/src/internal/browser-failure.ts +3 -0
- package/src/internal/live-text-protocol.ts +7 -0
- package/src/internal/live-text.ts +129 -91
- package/dist/BrowserSession-aovMjfL4.mjs.map +0 -1
- package/dist/CloudflareThreadClient-CEUjVwis.mjs.map +0 -1
- package/dist/InteractiveBrowser-BHNlwjZL.mjs.map +0 -1
- package/dist/ThreadObject-vmc0jRTS.mjs.map +0 -1
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
BrowserCredentialAccess,
|
|
6
6
|
type BrowserCredentialMaterial,
|
|
7
7
|
CardCredential,
|
|
8
|
+
CredentialBinding,
|
|
9
|
+
CredentialForm,
|
|
8
10
|
type CredentialDispatch,
|
|
9
11
|
type CredentialFieldRole,
|
|
10
12
|
CredentialFillError,
|
|
@@ -26,7 +28,10 @@ export class BrowserSessionPage extends Context.Service<
|
|
|
26
28
|
>()("@effect-agent/platform-cloudflare/internal/BrowserSessionPage") {}
|
|
27
29
|
|
|
28
30
|
const TargetReply = Schema.Union([
|
|
29
|
-
Schema.Struct({
|
|
31
|
+
Schema.Struct({
|
|
32
|
+
action: Schema.String.check(Schema.isMaxLength(2048)),
|
|
33
|
+
shape: Schema.String.check(Schema.isMaxLength(128 * 1024)),
|
|
34
|
+
}),
|
|
30
35
|
Schema.Struct({ reason: Schema.Literals(["stale-target", "unsupported"]) }),
|
|
31
36
|
]);
|
|
32
37
|
|
|
@@ -37,7 +42,7 @@ const WriteReply = Schema.Literals([
|
|
|
37
42
|
"unsupported",
|
|
38
43
|
]);
|
|
39
44
|
|
|
40
|
-
// One invocation-local isolated-world handle.
|
|
45
|
+
// One invocation-local isolated-world handle. Values never leave the page through this handle.
|
|
41
46
|
// This program neither discovers controls nor classifies roles nor observes page content.
|
|
42
47
|
const prepareFields = `(() => {
|
|
43
48
|
const doc = document;
|
|
@@ -57,7 +62,7 @@ const prepareFields = `(() => {
|
|
|
57
62
|
const validate = () => fields.length > 0 && fields.every((el, index) =>
|
|
58
63
|
el.form === form && describe(el) !== null && describe(el) === snapshots[index]);
|
|
59
64
|
return {
|
|
60
|
-
prepare(selectors) {
|
|
65
|
+
prepare(selectors, roles) {
|
|
61
66
|
try {
|
|
62
67
|
fields = selectors.map(selector => {
|
|
63
68
|
const matches = doc.querySelectorAll(selector);
|
|
@@ -65,12 +70,14 @@ const prepareFields = `(() => {
|
|
|
65
70
|
});
|
|
66
71
|
} catch { return {reason: 'stale-target'}; }
|
|
67
72
|
if (fields.some(el => !el) || new Set(fields).size !== fields.length) return {reason: 'stale-target'};
|
|
73
|
+
if (fields.some((el, index) => roles[index] === 'password' && el.type !== 'password')) return {reason: 'unsupported'};
|
|
68
74
|
snapshots = fields.map(describe);
|
|
69
75
|
form = fields[0].form;
|
|
70
76
|
if (!form || snapshots.some(value => value === null) || fields.some(el => el.form !== form)) return {reason: 'unsupported'};
|
|
71
|
-
return {action: form.action};
|
|
77
|
+
return {action: form.action, shape: JSON.stringify(snapshots)};
|
|
72
78
|
},
|
|
73
|
-
target() { return validate() ? {action: form.action} : {reason: 'stale-target'}; },
|
|
79
|
+
target() { return validate() ? {action: form.action, shape: JSON.stringify(snapshots)} : {reason: 'stale-target'}; },
|
|
80
|
+
node(index) { return index === 0 ? doc.documentElement : index === 1 ? form : fields[index - 2]; },
|
|
74
81
|
fill(index, value) {
|
|
75
82
|
if (!validate()) return 'stale-target';
|
|
76
83
|
const el = fields[index];
|
|
@@ -117,40 +124,20 @@ const secretFor = (material: BrowserCredentialMaterial, role: typeof CredentialF
|
|
|
117
124
|
}
|
|
118
125
|
};
|
|
119
126
|
|
|
120
|
-
/**
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
* only its local handles. Ordinary native observations remain available, including credential echoes.
|
|
124
|
-
*/
|
|
125
|
-
export const fillCredential = Effect.fnUntraced(function* (
|
|
126
|
-
input: FillCredentialRequest,
|
|
127
|
-
): Effect.fn.Return<
|
|
128
|
-
CredentialFillResult,
|
|
129
|
-
CredentialFillError,
|
|
130
|
-
BrowserCredentialAccess | BrowserSessionPage
|
|
131
|
-
> {
|
|
132
|
-
const { page, commandTimeoutMillis } = yield* BrowserSessionPage;
|
|
133
|
-
let dispatch: typeof CredentialDispatch.Type = "not-dispatched";
|
|
134
|
-
let filled = 0;
|
|
127
|
+
/** Acquire exact native controls for this Scope; no credential material is resolved. */
|
|
128
|
+
const openForm = Effect.fnUntraced(function* (input: CredentialForm) {
|
|
129
|
+
const { page } = yield* BrowserSessionPage;
|
|
135
130
|
|
|
136
131
|
const fail = (reason: CredentialFillError["reason"]) =>
|
|
137
|
-
CredentialFillError.make({
|
|
132
|
+
CredentialFillError.make({
|
|
133
|
+
reason,
|
|
134
|
+
dispatch: "not-dispatched",
|
|
135
|
+
filled: 0,
|
|
136
|
+
cleanup: "not-requested",
|
|
137
|
+
});
|
|
138
138
|
|
|
139
139
|
const remote = <A>(run: (signal: AbortSignal) => Promise<A>) =>
|
|
140
|
-
Effect.tryPromise({
|
|
141
|
-
try: async (signal) => {
|
|
142
|
-
try {
|
|
143
|
-
return { ok: true as const, value: await run(signal) };
|
|
144
|
-
} catch {
|
|
145
|
-
return { ok: false as const };
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
catch: () => fail("provider"),
|
|
149
|
-
}).pipe(
|
|
150
|
-
Effect.flatMap((result) =>
|
|
151
|
-
result.ok ? Effect.succeed(result.value) : Effect.fail(fail("provider")),
|
|
152
|
-
),
|
|
153
|
-
);
|
|
140
|
+
Effect.tryPromise({ try: run, catch: () => fail("provider") });
|
|
154
141
|
|
|
155
142
|
const release = (handles: ReadonlyArray<{ dispose(): Promise<void> }>) =>
|
|
156
143
|
Effect.promise(async () => {
|
|
@@ -192,66 +179,205 @@ export const fillCredential = Effect.fnUntraced(function* (
|
|
|
192
179
|
);
|
|
193
180
|
});
|
|
194
181
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
})(input).pipe(Effect.mapError(() => fail("denied")));
|
|
182
|
+
const request = yield* Schema.decodeEffect(CredentialForm, {
|
|
183
|
+
onExcessProperty: "error",
|
|
184
|
+
})(input).pipe(Effect.mapError(() => fail("denied")));
|
|
199
185
|
|
|
200
|
-
|
|
186
|
+
const roles = request.fields.map((field) => field.role);
|
|
187
|
+
|
|
188
|
+
if (
|
|
189
|
+
new Set(roles).size !== roles.length ||
|
|
190
|
+
roles.some(
|
|
191
|
+
(role) => (request.kind === "login") !== (role === "username" || role === "password"),
|
|
192
|
+
)
|
|
193
|
+
)
|
|
194
|
+
return yield* fail("denied");
|
|
195
|
+
let frame: Frame = page.mainFrame();
|
|
196
|
+
|
|
197
|
+
for (const selector of request.frame ?? []) {
|
|
198
|
+
const matches = yield* acquire(() => frame.$$(selector));
|
|
199
|
+
const element = matches[0];
|
|
200
|
+
|
|
201
|
+
if (matches.length !== 1 || element === undefined) return yield* fail("stale-target");
|
|
202
|
+
const child = yield* remote(() => element.contentFrame());
|
|
203
|
+
|
|
204
|
+
if (child === null) return yield* fail("unsupported");
|
|
205
|
+
frame = child;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const handles = yield* acquire(async () => [
|
|
209
|
+
await frame.isolatedRealm().evaluateHandle(prepareFields),
|
|
210
|
+
]);
|
|
201
211
|
|
|
212
|
+
const held = handles[0];
|
|
213
|
+
|
|
214
|
+
if (held === undefined) return yield* fail("provider");
|
|
215
|
+
|
|
216
|
+
const inspect = (raw: unknown) =>
|
|
217
|
+
Schema.decodeUnknownEffect(TargetReply)(raw).pipe(
|
|
218
|
+
Effect.mapError(() => fail("provider")),
|
|
219
|
+
Effect.filterOrFail(
|
|
220
|
+
(reply) => "action" in reply,
|
|
221
|
+
(reply) => fail("reason" in reply ? reply.reason : "provider"),
|
|
222
|
+
),
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
const prepared = yield* remote(() =>
|
|
226
|
+
held.evaluate(
|
|
227
|
+
(state, selectors, roles) => {
|
|
228
|
+
if (typeof state !== "object" || state === null) return null;
|
|
229
|
+
|
|
230
|
+
return Reflect.apply(Reflect.get(state, "prepare"), state, [selectors, roles]);
|
|
231
|
+
},
|
|
232
|
+
request.fields.map((field) => field.selector),
|
|
233
|
+
roles,
|
|
234
|
+
),
|
|
235
|
+
).pipe(Effect.flatMap(inspect));
|
|
236
|
+
|
|
237
|
+
const target = CredentialTarget.make({
|
|
238
|
+
topOrigin: yield* origin(page.url()),
|
|
239
|
+
frameOrigin: yield* origin(frame.url()),
|
|
240
|
+
recipientOrigin: yield* origin(prepared.action),
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const validate = Effect.gen(function* () {
|
|
202
244
|
if (
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
)
|
|
245
|
+
frame.detached ||
|
|
246
|
+
(yield* origin(page.url())) !== target.topOrigin ||
|
|
247
|
+
(yield* origin(frame.url())) !== target.frameOrigin
|
|
207
248
|
)
|
|
208
|
-
return yield* fail("
|
|
209
|
-
|
|
210
|
-
|
|
249
|
+
return yield* fail("stale-target");
|
|
250
|
+
|
|
251
|
+
const current = yield* remote(() =>
|
|
252
|
+
held.evaluate((state) => {
|
|
253
|
+
if (typeof state !== "object" || state === null) return null;
|
|
254
|
+
|
|
255
|
+
return Reflect.apply(Reflect.get(state, "target"), state, []);
|
|
256
|
+
}),
|
|
257
|
+
).pipe(Effect.flatMap(inspect));
|
|
211
258
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
259
|
+
if ((yield* origin(current.action)) !== target.recipientOrigin)
|
|
260
|
+
return yield* fail("stale-target");
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
const binding = Effect.gen(function* () {
|
|
264
|
+
const nodes: Array<number> = [];
|
|
265
|
+
|
|
266
|
+
for (let index = 0; index <= request.fields.length + 1; index++) {
|
|
267
|
+
const handles = yield* acquire(async () => [
|
|
268
|
+
await held.evaluateHandle((state, index) => {
|
|
269
|
+
if (typeof state !== "object" || state === null) return null;
|
|
215
270
|
|
|
216
|
-
|
|
217
|
-
|
|
271
|
+
return Reflect.apply(Reflect.get(state, "node"), state, [index]);
|
|
272
|
+
}, index),
|
|
273
|
+
]);
|
|
218
274
|
|
|
219
|
-
|
|
220
|
-
|
|
275
|
+
const element = handles[0]?.asElement();
|
|
276
|
+
|
|
277
|
+
if (element === null || element === undefined) return yield* fail("stale-target");
|
|
278
|
+
nodes.push(yield* remote(() => element.backendNodeId()));
|
|
221
279
|
}
|
|
280
|
+
yield* validate;
|
|
281
|
+
|
|
282
|
+
const digest = yield* remote(() =>
|
|
283
|
+
crypto.subtle.digest("SHA-256", new TextEncoder().encode(prepared.shape)),
|
|
284
|
+
);
|
|
222
285
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
286
|
+
return CredentialBinding.make({
|
|
287
|
+
version: 1,
|
|
288
|
+
pageId: page.mainFrame()._id,
|
|
289
|
+
frameId: frame._id,
|
|
290
|
+
target,
|
|
291
|
+
nodes,
|
|
292
|
+
shape: Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join(
|
|
293
|
+
"",
|
|
294
|
+
),
|
|
295
|
+
});
|
|
296
|
+
});
|
|
226
297
|
|
|
227
|
-
|
|
298
|
+
return { held, target, validate, binding };
|
|
299
|
+
});
|
|
228
300
|
|
|
229
|
-
|
|
301
|
+
/** Bind a host-owned request to this exact document and fields without reading their values. */
|
|
302
|
+
export const prepareCredential = Effect.fnUntraced(
|
|
303
|
+
function* (input: CredentialForm) {
|
|
304
|
+
const form = yield* openForm(input);
|
|
230
305
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
),
|
|
237
|
-
);
|
|
306
|
+
return yield* form.binding;
|
|
307
|
+
},
|
|
308
|
+
Effect.scoped,
|
|
309
|
+
Effect.withTracerEnabled(false),
|
|
310
|
+
);
|
|
238
311
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
312
|
+
/**
|
|
313
|
+
* Fill explicit native fields on an existing page without submitting. The owning browser session
|
|
314
|
+
* serializes operations and closes on timeout, interruption or uncertain dispatch; this function releases
|
|
315
|
+
* only its local handles. Ordinary native observations remain available, including credential echoes.
|
|
316
|
+
*/
|
|
317
|
+
export const fillCredential = Effect.fnUntraced(function* (
|
|
318
|
+
input: FillCredentialRequest,
|
|
319
|
+
): Effect.fn.Return<
|
|
320
|
+
CredentialFillResult,
|
|
321
|
+
CredentialFillError,
|
|
322
|
+
BrowserCredentialAccess | BrowserSessionPage
|
|
323
|
+
> {
|
|
324
|
+
const { commandTimeoutMillis } = yield* BrowserSessionPage;
|
|
325
|
+
let dispatch: typeof CredentialDispatch.Type = "not-dispatched";
|
|
326
|
+
let filled = 0;
|
|
327
|
+
|
|
328
|
+
const fail = (reason: CredentialFillError["reason"]) =>
|
|
329
|
+
CredentialFillError.make({ reason, dispatch, filled, cleanup: "not-requested" });
|
|
243
330
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
331
|
+
const remote = <A>(run: (signal: AbortSignal) => Promise<A>) =>
|
|
332
|
+
Effect.tryPromise({
|
|
333
|
+
try: async (signal) => {
|
|
334
|
+
try {
|
|
335
|
+
return { ok: true as const, value: await run(signal) };
|
|
336
|
+
} catch {
|
|
337
|
+
return { ok: false as const };
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
catch: () => fail("provider"),
|
|
341
|
+
}).pipe(
|
|
342
|
+
Effect.flatMap((result) =>
|
|
343
|
+
result.ok ? Effect.succeed(result.value) : Effect.fail(fail("provider")),
|
|
247
344
|
),
|
|
248
|
-
)
|
|
345
|
+
);
|
|
249
346
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
347
|
+
return yield* Effect.gen(function* () {
|
|
348
|
+
const request = yield* Schema.decodeEffect(FillCredentialRequest, {
|
|
349
|
+
onExcessProperty: "error",
|
|
350
|
+
})(input).pipe(Effect.mapError(() => fail("denied")));
|
|
351
|
+
|
|
352
|
+
const form = yield* openForm(
|
|
353
|
+
CredentialForm.make({
|
|
354
|
+
kind: request.kind,
|
|
355
|
+
fields: request.fields,
|
|
356
|
+
...(request.frame === undefined ? {} : { frame: request.frame }),
|
|
357
|
+
}),
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
const { held, target } = form;
|
|
361
|
+
const validate = form.validate.pipe(Effect.mapError((error) => fail(error.reason)));
|
|
362
|
+
const roles = request.fields.map((field) => field.role);
|
|
363
|
+
|
|
364
|
+
if (request.binding !== undefined) {
|
|
365
|
+
const actual = yield* form.binding;
|
|
366
|
+
const expected = request.binding;
|
|
367
|
+
|
|
368
|
+
if (
|
|
369
|
+
actual.pageId !== expected.pageId ||
|
|
370
|
+
actual.frameId !== expected.frameId ||
|
|
371
|
+
actual.shape !== expected.shape ||
|
|
372
|
+
actual.nodes.length !== expected.nodes.length ||
|
|
373
|
+
actual.nodes.some((node, index) => node !== expected.nodes[index]) ||
|
|
374
|
+
actual.target.topOrigin !== expected.target.topOrigin ||
|
|
375
|
+
actual.target.frameOrigin !== expected.target.frameOrigin ||
|
|
376
|
+
actual.target.recipientOrigin !== expected.target.recipientOrigin
|
|
377
|
+
)
|
|
378
|
+
return yield* fail("stale-target");
|
|
379
|
+
}
|
|
380
|
+
const access = yield* BrowserCredentialAccess;
|
|
255
381
|
|
|
256
382
|
const authorization: CredentialAccessRequest = {
|
|
257
383
|
credential: request.credential,
|
|
@@ -264,25 +390,6 @@ export const fillCredential = Effect.fnUntraced(function* (
|
|
|
264
390
|
Effect.mapError((error) => fail(error.reason)),
|
|
265
391
|
);
|
|
266
392
|
|
|
267
|
-
const validate = Effect.gen(function* () {
|
|
268
|
-
if (
|
|
269
|
-
frame.detached ||
|
|
270
|
-
(yield* origin(page.url())) !== target.topOrigin ||
|
|
271
|
-
(yield* origin(frame.url())) !== target.frameOrigin
|
|
272
|
-
)
|
|
273
|
-
return yield* fail("stale-target");
|
|
274
|
-
|
|
275
|
-
const current = yield* remote(() =>
|
|
276
|
-
held.evaluate((state) => {
|
|
277
|
-
if (typeof state !== "object" || state === null) return null;
|
|
278
|
-
|
|
279
|
-
return Reflect.apply(Reflect.get(state, "target"), state, []);
|
|
280
|
-
}),
|
|
281
|
-
).pipe(Effect.flatMap(inspect));
|
|
282
|
-
|
|
283
|
-
if ((yield* origin(current)) !== target.recipientOrigin) return yield* fail("stale-target");
|
|
284
|
-
});
|
|
285
|
-
|
|
286
393
|
yield* authorize;
|
|
287
394
|
yield* validate;
|
|
288
395
|
|
|
@@ -43,6 +43,9 @@ const failureNames = new Set([
|
|
|
43
43
|
"SyntaxError",
|
|
44
44
|
"TimeoutError",
|
|
45
45
|
"SchemaError",
|
|
46
|
+
"ProtocolError",
|
|
47
|
+
"TargetCloseError",
|
|
48
|
+
"ConnectionClosedError",
|
|
46
49
|
]);
|
|
47
50
|
|
|
48
51
|
export const browserFailure = (operation: string, cause?: unknown): BrowserRunFailure =>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ThreadId } from "@yielded/agent/identifiers";
|
|
2
2
|
import { Event } from "@yielded/agent/provisional-text";
|
|
3
3
|
import { Schema } from "effect";
|
|
4
|
+
import { Rpc } from "effect-cf";
|
|
4
5
|
|
|
5
6
|
export const MAX_FRAME_BYTES = 32 * 1_024;
|
|
6
7
|
export const MAX_ID_LENGTH = 256;
|
|
@@ -14,6 +15,12 @@ const streamId = Schema.NonEmptyString.check(Schema.isMaxLength(MAX_ID_LENGTH));
|
|
|
14
15
|
|
|
15
16
|
export const Request = Schema.Struct({ schemaVersion: Schema.Literal(1) });
|
|
16
17
|
|
|
18
|
+
/** The RPC lifetime survives an idle byte stream and is disposed on caller disconnect. */
|
|
19
|
+
export const Observation = Schema.Struct({
|
|
20
|
+
stream: Schema.instanceOf(ReadableStream<Uint8Array>),
|
|
21
|
+
lifetime: Schema.declare(Rpc.isDisposable),
|
|
22
|
+
});
|
|
23
|
+
|
|
17
24
|
/**
|
|
18
25
|
* Reset replaces all drafts with a snapshot, streamed as native Text parts before live deltas.
|
|
19
26
|
* Each snapshot starts a fresh streamId. Its sequences are unrelated to canonical sequences.
|