@parall/daemon 1.65.0 → 1.67.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.
@@ -174,25 +174,25 @@ var init_runtime_observation = __esm({
174
174
  }
175
175
  });
176
176
 
177
- // ts/agent-core/dist/fork-prefix.js
177
+ // ts/agent-core/dist/gateway/fork-prefix.js
178
178
  var init_fork_prefix = __esm({
179
- "ts/agent-core/dist/fork-prefix.js"() {
179
+ "ts/agent-core/dist/gateway/fork-prefix.js"() {
180
180
  "use strict";
181
181
  }
182
182
  });
183
183
 
184
- // ts/agent-core/dist/gateway-runtime-step.js
185
- var init_gateway_runtime_step = __esm({
186
- "ts/agent-core/dist/gateway-runtime-step.js"() {
184
+ // ts/agent-core/dist/gateway/runtime-step.js
185
+ var init_runtime_step = __esm({
186
+ "ts/agent-core/dist/gateway/runtime-step.js"() {
187
187
  "use strict";
188
188
  init_dispatch_adapter();
189
189
  init_runtime_observation();
190
190
  }
191
191
  });
192
192
 
193
- // ts/agent-core/dist/dispatch-recovery.js
194
- var init_dispatch_recovery = __esm({
195
- "ts/agent-core/dist/dispatch-recovery.js"() {
193
+ // ts/agent-core/dist/gateway/recovery.js
194
+ var init_recovery = __esm({
195
+ "ts/agent-core/dist/gateway/recovery.js"() {
196
196
  "use strict";
197
197
  }
198
198
  });
@@ -204,20 +204,17 @@ var init_change_source = __esm({
204
204
  }
205
205
  });
206
206
 
207
- // ts/sdk/dist/browser-viewer.js
208
- function browserViewerRequestOptions(command, opts) {
209
- if (command !== "stream.answer" && command !== "stream.switch")
210
- return opts;
211
- return {
212
- ...opts,
213
- timeoutMs: Math.max(opts?.timeoutMs ?? 0, BROWSER_VIEWER_READINESS_TIMEOUT_MS)
214
- };
215
- }
216
- var BROWSER_VIEWER_READINESS_TIMEOUT_MS;
217
- var init_browser_viewer = __esm({
218
- "ts/sdk/dist/browser-viewer.js"() {
207
+ // ts/sdk/dist/attachment-types.js
208
+ var init_attachment_types = __esm({
209
+ "ts/sdk/dist/attachment-types.js"() {
210
+ "use strict";
211
+ }
212
+ });
213
+
214
+ // ts/sdk/dist/attention-types.js
215
+ var init_attention_types = __esm({
216
+ "ts/sdk/dist/attention-types.js"() {
219
217
  "use strict";
220
- BROWSER_VIEWER_READINESS_TIMEOUT_MS = 6e4;
221
218
  }
222
219
  });
223
220
 
@@ -233,57 +230,351 @@ var init_browser_use = __esm({
233
230
  }
234
231
  });
235
232
 
236
- // ts/sdk/dist/attachment-types.js
237
- var init_attachment_types = __esm({
238
- "ts/sdk/dist/attachment-types.js"() {
233
+ // ts/sdk/dist/browser-use-contract.generated.js
234
+ var browserUseContract;
235
+ var init_browser_use_contract_generated = __esm({
236
+ "ts/sdk/dist/browser-use-contract.generated.js"() {
239
237
  "use strict";
238
+ browserUseContract = { "actions": { "read": { "grant": "browser.read", "target": "optional_tab", "params": { "required": [], "properties": { "url": { "type": "string", "min_length": 1, "max_length": 8192, "schemes": ["http", "https", "about:blank"] } }, "rules": ["exactly one of params.url or target is required", "params.url creates a hidden Profile-bound tab and closes it before terminal success or failure"], "additional_properties": false }, "success": { "base": null, "fields": { "profile_id": "ebp_identifier", "url": "string", "title": "string", "article": "nullable_article" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "tabs": { "grant": "browser.read", "target": "none", "params": { "required": [], "properties": {}, "additional_properties": false }, "success": { "base": null, "fields": { "tabs": "tab_summary_array" } }, "errors": ["TAB_GONE"] }, "wait": { "grant": "browser.read", "target": "tab", "params": { "required": [], "properties": { "selector": { "type": "string", "min_length": 1, "max_length": 4096 }, "state": { "enum": ["attached", "detached", "visible", "hidden", "load"], "default": "attached" }, "timeout_ms": { "type": "integer", "minimum": 1, "maximum": 3e4, "default": 1e4 } }, "rules": ["selector is required unless state=load", "state=load forbids selector"], "additional_properties": false }, "success": { "base": "tab_state", "fields": { "matched": { "const": true } } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "snapshot": { "grant": "browser.read", "target": "tab", "params": { "required": [], "properties": { "interactive": { "type": "boolean", "default": false }, "compact": { "type": "boolean", "default": false }, "depth": { "type": "integer", "minimum": 0, "maximum": 64 } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "snapshot": "string", "snapshot_id": "identifier" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "get": { "grant": "browser.read", "target": "tab_or_ref", "params": { "required": ["prop"], "properties": { "selector": { "type": "string", "min_length": 1, "max_length": 4096 }, "prop": { "enum": ["text", "html", "value", "attr", "title", "url"] }, "name": { "type": "string", "min_length": 1, "max_length": 256 } }, "rules": ["title/url forbid locator and name", "text/html/value require exactly one locator", "attr requires exactly one locator and name"], "additional_properties": false }, "success": { "base": "tab_state", "fields": { "value": "nullable_string" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "STALE_REF", "PAGE_LOAD_FAILED"] }, "screenshot": { "grant": "browser.read", "target": "tab", "params": { "required": [], "properties": {}, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "format": { "const": "png" }, "base64": "canonical_base64" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "open": { "grant": "browser.interact", "target": "none", "params": { "required": ["url"], "properties": { "url": { "type": "string", "min_length": 1, "max_length": 8192, "schemes": ["http", "https", "about:blank"] }, "hidden": { "type": "boolean", "default": false }, "viewport": { "type": "viewport" } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": {} }, "errors": ["PAGE_LOAD_FAILED"] }, "navigate": { "grant": "browser.interact", "target": "tab", "params": { "required": ["url"], "properties": { "url": { "type": "string", "min_length": 1, "max_length": 8192, "schemes": ["http", "https", "about:blank"] } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": {} }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "viewport": { "grant": "browser.interact", "target": "tab", "params": { "required": ["width", "height"], "properties": { "width": { "type": "integer", "minimum": 320, "maximum": 3840 }, "height": { "type": "integer", "minimum": 240, "maximum": 2160 } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "viewport": "viewport" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE"] }, "click": { "grant": "browser.interact", "target": "tab_or_ref", "params": { "required": [], "properties": { "selector": "selector" }, "rules": ["exactly one of params.selector or target.ref"], "additional_properties": false }, "success": { "base": "tab_state", "fields": { "clicked": { "const": true } } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "STALE_REF", "PAGE_LOAD_FAILED"] }, "fill": { "grant": "browser.interact", "target": "tab_or_ref", "params": { "required": ["text"], "properties": { "selector": "selector", "text": { "type": "string", "allow_empty": true } }, "rules": ["exactly one of params.selector or target.ref"], "additional_properties": false }, "success": { "base": "tab_state", "fields": { "filled": { "const": true }, "characters": "non_negative_integer" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "STALE_REF", "PAGE_LOAD_FAILED"] }, "type": { "grant": "browser.interact", "target": "tab_or_ref", "params": { "required": ["text"], "properties": { "selector": "selector", "text": { "type": "string", "min_length": 1 } }, "rules": ["exactly one of params.selector or target.ref"], "additional_properties": false }, "success": { "base": "tab_state", "fields": { "typed": { "const": true }, "characters": "non_negative_integer" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "STALE_REF", "PAGE_LOAD_FAILED"] }, "press": { "grant": "browser.interact", "target": "tab", "params": { "required": ["key"], "properties": { "key": "single_unicode_character_or_named_key" }, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "pressed": { "const": true } } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "scroll": { "grant": "browser.interact", "target": "tab", "params": { "required": [], "properties": { "direction": { "enum": ["up", "down", "left", "right"], "default": "down" }, "pixels": { "type": "integer", "minimum": 1, "maximum": 1e5, "default": 500 } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "scrolled": { "const": true } } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "close": { "grant": "browser.interact", "target": "tab", "params": { "required": [], "properties": {}, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "closed": { "const": true } } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE"] }, "recover": { "grant": "browser.interact", "target": "tab", "params": { "required": [], "properties": {}, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "recovered_from_tab_id": "identifier" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "eval": { "grant": "browser.advanced", "target": "tab", "params": { "required": ["expression"], "properties": { "expression": { "type": "string", "min_length": 1 }, "timeout_ms": { "type": "integer", "minimum": 1, "maximum": 15e3, "default": 15e3 } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "value": "json_value_max_256_kib" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] } }, "successShapes": { "tab_state": { "required": ["tab_id", "profile_id", "browser_generation", "document_generation", "url", "title"], "fields": { "tab_id": "identifier", "profile_id": "ebp_identifier", "browser_generation": "positive_integer", "document_generation": "positive_integer", "url": "string", "title": "string" }, "additional_properties": false }, "tab_summary": { "base": "tab_state", "required_additions": ["loading"], "fields": { "loading": "boolean" }, "additional_properties": false }, "article": { "required": ["title", "byline", "excerpt", "text", "published_time", "site_name", "length"], "fields": { "title": "nullable_string", "byline": "nullable_string", "excerpt": "nullable_string", "text": "string", "published_time": "nullable_string", "site_name": "nullable_string", "length": "non_negative_integer" }, "additional_properties": false } } };
240
239
  }
241
240
  });
242
241
 
243
- // ts/sdk/dist/attention-types.js
244
- var init_attention_types = __esm({
245
- "ts/sdk/dist/attention-types.js"() {
242
+ // ts/sdk/dist/browser-use-validation.js
243
+ function browserUseObject(value) {
244
+ if (!value || typeof value !== "object" || Array.isArray(value))
245
+ throw new BrowserUseValidationError("Expected an object.");
246
+ return value;
247
+ }
248
+ function browserUseIdentifier(value, prefix) {
249
+ if (typeof value !== "string" || !value.startsWith(prefix) || value.length <= prefix.length || value.length > 128 || !/^[A-Za-z0-9_-]+$/.test(value) || ["__proto__", "constructor", "prototype"].includes(value))
250
+ throw new BrowserUseValidationError(`Expected a ${prefix} identifier.`);
251
+ return value;
252
+ }
253
+ function requireValid(condition, label) {
254
+ if (!condition)
255
+ throw new BrowserUseValidationError(`Invalid ${label}.`);
256
+ }
257
+ function exact(value, allowed, required = []) {
258
+ requireValid(Object.keys(value).every((k) => allowed.includes(k)) && required.every((k) => Object.hasOwn(value, k)), "object fields");
259
+ }
260
+ function validateBrowserUseField(value, field, label) {
261
+ if (typeof field === "string") {
262
+ switch (field) {
263
+ case "selector":
264
+ return validateBrowserUseField(value, { type: "string", min_length: 1, max_length: 4096 }, label);
265
+ case "single_unicode_character_or_named_key":
266
+ requireValid(typeof value === "string" && ([...value].length === 1 || [
267
+ "Enter",
268
+ "Tab",
269
+ "Escape",
270
+ "Backspace",
271
+ "Delete",
272
+ "ArrowUp",
273
+ "ArrowDown",
274
+ "ArrowLeft",
275
+ "ArrowRight",
276
+ "Home",
277
+ "End",
278
+ "PageUp",
279
+ "PageDown"
280
+ ].includes(value)), label);
281
+ return;
282
+ case "viewport": {
283
+ const obj = browserUseObject(value);
284
+ exact(obj, ["width", "height"], ["width", "height"]);
285
+ validateBrowserUseField(obj.width, { type: "integer", minimum: 320, maximum: 3840 }, label);
286
+ validateBrowserUseField(obj.height, { type: "integer", minimum: 240, maximum: 2160 }, label);
287
+ return;
288
+ }
289
+ case "identifier":
290
+ browserUseIdentifier(value, label.includes("snapshot") ? "bsn_" : "btab_");
291
+ return;
292
+ case "ebp_identifier":
293
+ browserUseIdentifier(value, "ebp_");
294
+ return;
295
+ case "positive_integer":
296
+ return validateBrowserUseField(value, { type: "integer", minimum: 1 }, label);
297
+ case "non_negative_integer":
298
+ return validateBrowserUseField(value, { type: "integer", minimum: 0 }, label);
299
+ case "nullable_string":
300
+ if (value === null)
301
+ return;
302
+ return validateBrowserUseField(value, { type: "string", allow_empty: true }, label);
303
+ case "string":
304
+ return validateBrowserUseField(value, { type: "string", allow_empty: true }, label);
305
+ case "boolean":
306
+ requireValid(typeof value === "boolean", label);
307
+ return;
308
+ case "canonical_base64":
309
+ requireValid(typeof value === "string" && value.length > 0 && /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value) && btoa(atob(value)) === value, label);
310
+ return;
311
+ case "nullable_article":
312
+ if (value === null)
313
+ return;
314
+ return validateShape(value, browserUseContract.successShapes.article.fields);
315
+ case "tab_summary_array":
316
+ requireValid(Array.isArray(value), label);
317
+ for (const tab of value)
318
+ validateShape(tab, {
319
+ ...browserUseContract.successShapes.tab_state.fields,
320
+ loading: "boolean"
321
+ });
322
+ return;
323
+ case "json_value_max_256_kib":
324
+ requireValid(new TextEncoder().encode(canonicalBrowserUseJson(value)).length <= 256 * 1024, label);
325
+ return;
326
+ default:
327
+ throw new BrowserUseValidationError(`Unknown contract field ${field}.`);
328
+ }
329
+ }
330
+ if ("const" in field) {
331
+ requireValid(value === field.const, label);
332
+ return;
333
+ }
334
+ if (field.enum) {
335
+ requireValid(field.enum.includes(value), label);
336
+ return;
337
+ }
338
+ if (field.type === "viewport")
339
+ return validateBrowserUseField(value, "viewport", label);
340
+ if (field.type === "boolean") {
341
+ requireValid(typeof value === "boolean", label);
342
+ return;
343
+ }
344
+ if (field.type === "integer") {
345
+ requireValid(typeof value === "number" && Number.isSafeInteger(value) && value >= (field.minimum ?? 0) && value <= (field.maximum ?? Number.MAX_SAFE_INTEGER), label);
346
+ return;
347
+ }
348
+ requireValid(typeof value === "string" && [...value].length >= (field.allow_empty ? 0 : field.min_length ?? 1) && [...value].length <= (field.max_length ?? 1 << 20), label);
349
+ if (field.schemes) {
350
+ if (value === "about:blank")
351
+ return;
352
+ let url;
353
+ try {
354
+ url = new URL(value);
355
+ } catch {
356
+ throw new BrowserUseValidationError(`Invalid ${label} URL.`);
357
+ }
358
+ requireValid(url.protocol === "https:" || url.protocol === "http:", label);
359
+ }
360
+ }
361
+ function validateShape(value, fields) {
362
+ const obj = browserUseObject(value);
363
+ exact(obj, Object.keys(fields), Object.keys(fields));
364
+ for (const [key, field] of Object.entries(fields))
365
+ validateBrowserUseField(obj[key], field, key);
366
+ }
367
+ function validateBrowserUseActionRequest(value) {
368
+ const obj = browserUseObject(value);
369
+ exact(obj, ["action", "target", "params"], ["action", "params"]);
370
+ requireValid(typeof obj.action === "string", "action");
371
+ if (!Object.hasOwn(BROWSER_USE_ACTION_SCHEMAS, obj.action))
372
+ throw new BrowserUseValidationError(`Browser Use v1 does not support ${obj.action}.`, "UNSUPPORTED_ACTION");
373
+ const action = obj.action;
374
+ const schema = BROWSER_USE_ACTION_SCHEMAS[action];
375
+ const params = browserUseObject(obj.params);
376
+ exact(params, Object.keys(schema.params.properties), [...schema.params.required]);
377
+ for (const [key, val] of Object.entries(params))
378
+ validateBrowserUseField(val, schema.params.properties[key], key);
379
+ let target;
380
+ if (obj.target !== void 0) {
381
+ requireValid(schema.target !== "none", "target");
382
+ target = browserUseObject(obj.target);
383
+ const base = ["tab_id", "browser_generation"];
384
+ const refs = ["document_generation", "snapshot_id", "ref"];
385
+ exact(target, schema.target === "tab_or_ref" ? [...base, ...refs] : base, base);
386
+ browserUseIdentifier(target.tab_id, "btab_");
387
+ validateBrowserUseField(target.browser_generation, "positive_integer", "browser_generation");
388
+ if (refs.some((k) => Object.hasOwn(target, k))) {
389
+ requireValid(refs.every((k) => Object.hasOwn(target, k)), "complete ref binding");
390
+ validateBrowserUseField(target.document_generation, "positive_integer", "document_generation");
391
+ browserUseIdentifier(target.snapshot_id, "bsn_");
392
+ browserUseIdentifier(target.ref, "");
393
+ }
394
+ } else
395
+ requireValid(schema.target === "none" || schema.target === "optional_tab", "required target");
396
+ const locatorCount = Number(params.selector !== void 0) + Number(target?.ref !== void 0);
397
+ if (action === "read")
398
+ requireValid(params.url !== void 0 !== Boolean(target), "read URL or target");
399
+ if (action === "wait")
400
+ requireValid(params.state === "load" === (params.selector === void 0), "wait selector/state");
401
+ if (["click", "fill", "type"].includes(action))
402
+ requireValid(locatorCount === 1, "exactly one locator");
403
+ if (action === "get") {
404
+ const page = params.prop === "title" || params.prop === "url";
405
+ requireValid(locatorCount === (page ? 0 : 1), "get locator");
406
+ requireValid(params.prop === "attr" === (params.name !== void 0), "get attribute name");
407
+ }
408
+ requireValid(new TextEncoder().encode(JSON.stringify(obj)).length <= 1 << 20, "request size");
409
+ return obj;
410
+ }
411
+ function validateBrowserUseSuccessData(action, value) {
412
+ const schema = BROWSER_USE_ACTION_SCHEMAS[action].success;
413
+ validateShape(value, {
414
+ ...schema.base === "tab_state" ? browserUseContract.successShapes.tab_state.fields : {},
415
+ ...schema.fields
416
+ });
417
+ }
418
+ function canonicalBrowserUseJson(value, seen = /* @__PURE__ */ new Set()) {
419
+ if (value === null || typeof value === "boolean" || typeof value === "string")
420
+ return JSON.stringify(value);
421
+ if (typeof value === "number" && Number.isFinite(value))
422
+ return JSON.stringify(value);
423
+ if (!value || typeof value !== "object" || seen.has(value))
424
+ throw new BrowserUseValidationError("Invalid JSON result.");
425
+ seen.add(value);
426
+ const result = Array.isArray(value) ? `[${value.map((v) => canonicalBrowserUseJson(v, seen)).join(",")}]` : `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${canonicalBrowserUseJson(value[k], seen)}`).join(",")}}`;
427
+ seen.delete(value);
428
+ return result;
429
+ }
430
+ var BrowserUseValidationError, BROWSER_USE_ACTION_SCHEMAS, BROWSER_USE_ACTIONS;
431
+ var init_browser_use_validation = __esm({
432
+ "ts/sdk/dist/browser-use-validation.js"() {
246
433
  "use strict";
434
+ init_browser_use_contract_generated();
435
+ BrowserUseValidationError = class extends Error {
436
+ code;
437
+ constructor(message, code = "INVALID_ARGUMENT") {
438
+ super(message);
439
+ this.code = code;
440
+ }
441
+ };
442
+ BROWSER_USE_ACTION_SCHEMAS = browserUseContract.actions;
443
+ BROWSER_USE_ACTIONS = Object.freeze(Object.keys(BROWSER_USE_ACTION_SCHEMAS));
247
444
  }
248
445
  });
249
446
 
250
- // ts/sdk/dist/channel-types.js
251
- var init_channel_types = __esm({
252
- "ts/sdk/dist/channel-types.js"() {
447
+ // ts/sdk/dist/browser-use-receipt.js
448
+ function isBrowserUseTimestamp(value) {
449
+ if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/.test(value))
450
+ return false;
451
+ const [year, month, day, hour, minute, second] = value.slice(0, 19).split(/[-T:]/).map(Number);
452
+ return year >= 1 && month >= 1 && month <= 12 && day >= 1 && day <= new Date(Date.UTC(year, month, 0)).getUTCDate() && hour < 24 && minute < 60 && second < 60 && Number.isFinite(Date.parse(value));
453
+ }
454
+ async function browserUseResultDigest(value, maxBytes = 1 << 20, subtle = globalThis.crypto.subtle) {
455
+ const bytes = new TextEncoder().encode(canonicalBrowserUseJson(value));
456
+ if (bytes.length > maxBytes)
457
+ throw new BrowserUseValidationError("Browser Use result exceeds contract size.");
458
+ const digest = await subtle.digest("SHA-256", bytes);
459
+ return `sha256:${Array.from(new Uint8Array(digest), (n) => n.toString(16).padStart(2, "0")).join("")}`;
460
+ }
461
+ function proof(condition) {
462
+ if (!condition)
463
+ throw new BrowserUseValidationError("The Browser Use response did not contain valid public status proof.", "INVALID_SERVER_RESPONSE");
464
+ }
465
+ async function validateBrowserUseReceipt(value, expected, subtle) {
466
+ try {
467
+ const r = browserUseObject(value);
468
+ proof(Object.keys(r).every((k) => KEYS.includes(k)));
469
+ proof(r.contract_version === "browser-use-operation-v1");
470
+ browserUseIdentifier(r.operation_id, "buo_");
471
+ browserUseIdentifier(r.request_id, "burq_");
472
+ browserUseIdentifier(r.profile_id, "ebp_");
473
+ proof(r.profile_id === expected.profileId && (!expected.operationId || r.operation_id === expected.operationId) && (!expected.requestId || r.request_id === expected.requestId) && (!expected.action || r.action === expected.action));
474
+ proof(typeof r.action === "string" && Object.hasOwn(BROWSER_USE_ACTION_SCHEMAS, r.action));
475
+ const action = r.action;
476
+ proof(r.required_grant === BROWSER_USE_ACTION_SCHEMAS[action].grant);
477
+ proof(positive(r.profile_version) && positive(r.profile_config_revision));
478
+ proof(typeof r.phase === "string" && ["accepted", "started", ...terminal].includes(r.phase));
479
+ proof(typeof r.result_available === "boolean");
480
+ for (const k of ["deadline", "accepted_at", "updated_at"])
481
+ proof(isBrowserUseTimestamp(r[k]));
482
+ for (const k of ["occurred_at", "result_expires_at", "started_at", "terminal_at"])
483
+ if (k in r)
484
+ proof(isBrowserUseTimestamp(r[k]));
485
+ if ("duration_ms" in r)
486
+ proof(typeof r.duration_ms === "number" && Number.isSafeInteger(r.duration_ms) && r.duration_ms >= 0);
487
+ if ("dispatched" in r)
488
+ proof(typeof r.dispatched === "boolean");
489
+ proof("tab_id" in r === "browser_generation" in r);
490
+ if ("tab_id" in r) {
491
+ browserUseIdentifier(r.tab_id, "btab_");
492
+ proof(positive(r.browser_generation));
493
+ }
494
+ const isTerminal = terminal.has(r.phase);
495
+ if (isTerminal) {
496
+ browserUseIdentifier(r.receipt_id, "bur_");
497
+ proof(hash(r.receipt_digest) && isBrowserUseTimestamp(r.occurred_at) && isBrowserUseTimestamp(r.terminal_at));
498
+ } else {
499
+ proof(!("terminal_at" in r));
500
+ if ("receipt_id" in r || "receipt_digest" in r || "occurred_at" in r) {
501
+ proof(r.phase === "started");
502
+ browserUseIdentifier(r.receipt_id, "bur_");
503
+ proof(hash(r.receipt_digest) && isBrowserUseTimestamp(r.occurred_at));
504
+ }
505
+ }
506
+ const hasData = Object.hasOwn(r, "data");
507
+ proof(r.result_available === hasData);
508
+ if (r.phase === "succeeded")
509
+ proof(!("error" in r) && hash(r.result_digest));
510
+ else {
511
+ proof(!hasData && !r.result_available);
512
+ if (isTerminal) {
513
+ const e = browserUseObject(r.error);
514
+ proof(Object.keys(e).every((k) => ["code", "message", "hint"].includes(k)) && typeof e.code === "string" && /^[A-Z][A-Z0-9_]{0,127}$/.test(e.code));
515
+ for (const k of ["message", "hint"])
516
+ if (k in e)
517
+ proof(typeof e[k] === "string" && e[k].length <= 1024);
518
+ if (r.phase === "outcome_unknown")
519
+ proof(e.code === "UNKNOWN_OUTCOME");
520
+ } else
521
+ proof(!("error" in r));
522
+ }
523
+ if (hasData) {
524
+ validateBrowserUseSuccessData(action, r.data);
525
+ proof(r.result_digest === await browserUseResultDigest(r.data, action === "eval" ? 256 * 1024 : 1 << 20, subtle));
526
+ const data = browserUseObject(r.data);
527
+ if (action === "tabs")
528
+ proof(data.tabs.every((t) => t.profile_id === r.profile_id));
529
+ else
530
+ proof(data.profile_id === r.profile_id);
531
+ if (!["read", "tabs"].includes(action))
532
+ proof(data.tab_id === r.tab_id && data.browser_generation === r.browser_generation);
533
+ if (expected.target) {
534
+ if (action === "recover")
535
+ proof(data.recovered_from_tab_id === expected.target.tab_id);
536
+ else if (action !== "read")
537
+ proof(data.tab_id === expected.target.tab_id && data.browser_generation === expected.target.browser_generation);
538
+ }
539
+ }
540
+ return r;
541
+ } catch {
542
+ throw new BrowserUseValidationError("The Browser Use response did not contain valid public status proof.", "INVALID_SERVER_RESPONSE");
543
+ }
544
+ }
545
+ var KEYS, terminal, hash, positive;
546
+ var init_browser_use_receipt = __esm({
547
+ "ts/sdk/dist/browser-use-receipt.js"() {
253
548
  "use strict";
549
+ init_browser_use_validation();
550
+ KEYS = "contract_version operation_id request_id profile_id profile_version profile_config_revision action required_grant phase dispatched receipt_id receipt_digest occurred_at tab_id browser_generation duration_ms result_digest result_available result_expires_at data error deadline accepted_at started_at terminal_at updated_at".split(" ");
551
+ terminal = /* @__PURE__ */ new Set(["succeeded", "failed", "outcome_unknown"]);
552
+ hash = (value) => typeof value === "string" && /^sha256:[0-9a-f]{64}$/.test(value);
553
+ positive = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0;
254
554
  }
255
555
  });
256
556
 
257
- // ts/sdk/dist/slack-endpoints.js
258
- function slackEndpoints(apiBase) {
557
+ // ts/sdk/dist/browser-viewer.js
558
+ function browserViewerRequestOptions(command, opts) {
559
+ if (command !== "stream.answer" && command !== "stream.switch")
560
+ return opts;
259
561
  return {
260
- SLACK_CHANNELS: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/channels`,
261
- SLACK_USERS: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/users`,
262
- SLACK_REPLIES: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/replies`,
263
- SLACK_HISTORY: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/history`,
264
- SLACK_MEMBERS: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/members`,
265
- SLACK_STATUS: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/status`,
266
- SLACK_FILE: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/file`,
267
- SLACK_FILES: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/files`
562
+ ...opts,
563
+ timeoutMs: Math.max(opts?.timeoutMs ?? 0, BROWSER_VIEWER_READINESS_TIMEOUT_MS)
268
564
  };
269
565
  }
270
- var init_slack_endpoints = __esm({
271
- "ts/sdk/dist/slack-endpoints.js"() {
566
+ var BROWSER_VIEWER_READINESS_TIMEOUT_MS;
567
+ var init_browser_viewer = __esm({
568
+ "ts/sdk/dist/browser-viewer.js"() {
272
569
  "use strict";
570
+ BROWSER_VIEWER_READINESS_TIMEOUT_MS = 6e4;
273
571
  }
274
572
  });
275
573
 
276
- // ts/sdk/dist/clip-connection-endpoints.js
277
- var clipConnectionEndpoints;
278
- var init_clip_connection_endpoints = __esm({
279
- "ts/sdk/dist/clip-connection-endpoints.js"() {
574
+ // ts/sdk/dist/channel-types.js
575
+ var init_channel_types = __esm({
576
+ "ts/sdk/dist/channel-types.js"() {
280
577
  "use strict";
281
- clipConnectionEndpoints = {
282
- ORG_CLIP_MCP_OAUTH_ATTEMPT: (orgId, clipId, attemptId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/mcp-oauth-attempts/${attemptId}`,
283
- CLIP_CONNECTIONS: (orgId, clipId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/connections`,
284
- CLIP_CONNECTION_ACCESS: (orgId, connId) => `/api/v1/orgs/${orgId}/clip-connections/${connId}/access`,
285
- CLIP_CONNECTION: (orgId, connId) => `/api/v1/orgs/${orgId}/clip-connections/${connId}`
286
- };
287
578
  }
288
579
  });
289
580
 
@@ -302,6 +593,20 @@ var init_attachment_endpoints = __esm({
302
593
  }
303
594
  });
304
595
 
596
+ // ts/sdk/dist/clip-connection-endpoints.js
597
+ var clipConnectionEndpoints;
598
+ var init_clip_connection_endpoints = __esm({
599
+ "ts/sdk/dist/clip-connection-endpoints.js"() {
600
+ "use strict";
601
+ clipConnectionEndpoints = {
602
+ ORG_CLIP_MCP_OAUTH_ATTEMPT: (orgId, clipId, attemptId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/mcp-oauth-attempts/${attemptId}`,
603
+ CLIP_CONNECTIONS: (orgId, clipId) => `/api/v1/orgs/${orgId}/clip-registry/${clipId}/connections`,
604
+ CLIP_CONNECTION_ACCESS: (orgId, connId) => `/api/v1/orgs/${orgId}/clip-connections/${connId}/access`,
605
+ CLIP_CONNECTION: (orgId, connId) => `/api/v1/orgs/${orgId}/clip-connections/${connId}`
606
+ };
607
+ }
608
+ });
609
+
305
610
  // ts/sdk/dist/edge-endpoints.js
306
611
  var API_BASE, edgeEndpoints;
307
612
  var init_edge_endpoints = __esm({
@@ -324,6 +629,25 @@ var init_edge_endpoints = __esm({
324
629
  }
325
630
  });
326
631
 
632
+ // ts/sdk/dist/slack-endpoints.js
633
+ function slackEndpoints(apiBase) {
634
+ return {
635
+ SLACK_CHANNELS: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/channels`,
636
+ SLACK_USERS: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/users`,
637
+ SLACK_REPLIES: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/replies`,
638
+ SLACK_HISTORY: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/history`,
639
+ SLACK_MEMBERS: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/members`,
640
+ SLACK_STATUS: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/status`,
641
+ SLACK_FILE: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/file`,
642
+ SLACK_FILES: (orgId) => `${apiBase}/orgs/${orgId}/agents/me/slack/files`
643
+ };
644
+ }
645
+ var init_slack_endpoints = __esm({
646
+ "ts/sdk/dist/slack-endpoints.js"() {
647
+ "use strict";
648
+ }
649
+ });
650
+
327
651
  // ts/sdk/dist/wechat-endpoints.js
328
652
  function wechatEndpoints(apiBase) {
329
653
  const agentBase = (orgId) => `${apiBase}/orgs/${orgId}/agents/me/wechat`;
@@ -390,10 +714,10 @@ var API_BASE2, WIKI_BASE, CLIP_BASE, PLATFORM_MODELS, PLATFORM_LEGACY_MODELS, PL
390
714
  var init_constants = __esm({
391
715
  "ts/sdk/dist/constants.js"() {
392
716
  "use strict";
393
- init_slack_endpoints();
394
- init_clip_connection_endpoints();
395
717
  init_attachment_endpoints();
718
+ init_clip_connection_endpoints();
396
719
  init_edge_endpoints();
720
+ init_slack_endpoints();
397
721
  init_wechat_endpoints();
398
722
  API_BASE2 = "/api/v1";
399
723
  WIKI_BASE = "/wiki/v1";
@@ -863,6 +1187,7 @@ var init_constants = __esm({
863
1187
  TASK_RELATIONS: (orgId, taskId) => `${API_BASE2}/orgs/${orgId}/tasks/${taskId}/relations`,
864
1188
  TASK_RELATION: (orgId, taskId, relId) => `${API_BASE2}/orgs/${orgId}/tasks/${taskId}/relations/${relId}`,
865
1189
  TASK_RELATIONS_BY_TARGET: (orgId) => `${API_BASE2}/orgs/${orgId}/task-relations`,
1190
+ TASK_DEPENDENCIES: (orgId, taskId) => `${API_BASE2}/orgs/${orgId}/tasks/${taskId}/dependencies`,
866
1191
  TASK_COMMENTS: (orgId, taskId) => `${API_BASE2}/orgs/${orgId}/tasks/${taskId}/comments`,
867
1192
  TASK_COMMENT: (orgId, taskId, commentId) => `${API_BASE2}/orgs/${orgId}/tasks/${taskId}/comments/${commentId}`,
868
1193
  TASK_ACTIVITIES: (orgId, taskId) => `${API_BASE2}/orgs/${orgId}/tasks/${taskId}/activities`,
@@ -871,6 +1196,13 @@ var init_constants = __esm({
871
1196
  // Labels (org-scoped vocabulary; writes are admin-gated)
872
1197
  LABELS: (orgId) => `${API_BASE2}/orgs/${orgId}/labels`,
873
1198
  LABEL: (orgId, labelId) => `${API_BASE2}/orgs/${orgId}/labels/${labelId}`,
1199
+ // Mini Apps (project-scoped entity; routes exist only under cap:mini-apps)
1200
+ MINI_APPS: (orgId) => `${API_BASE2}/orgs/${orgId}/apps`,
1201
+ MINI_APP: (orgId, appId) => `${API_BASE2}/orgs/${orgId}/apps/${appId}`,
1202
+ MINI_APP_ARCHIVE: (orgId, appId) => `${API_BASE2}/orgs/${orgId}/apps/${appId}/archive`,
1203
+ MINI_APP_RESTORE: (orgId, appId) => `${API_BASE2}/orgs/${orgId}/apps/${appId}/restore`,
1204
+ MINI_APP_AUTHORS: (orgId, appId) => `${API_BASE2}/orgs/${orgId}/apps/${appId}/authors`,
1205
+ MINI_APP_AUTHOR: (orgId, appId, userId) => `${API_BASE2}/orgs/${orgId}/apps/${appId}/authors/${userId}`,
874
1206
  // Projects (org-scoped)
875
1207
  PROJECTS: (orgId) => `${API_BASE2}/orgs/${orgId}/projects`,
876
1208
  PROJECT_TASK_SUMMARY: (orgId) => `${API_BASE2}/orgs/${orgId}/projects/task-summary`,
@@ -981,6 +1313,11 @@ var init_constants = __esm({
981
1313
  WIKI_TREE: (orgId, wikiId) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/tree`,
982
1314
  WIKI_TREE_LAST_COMMITS: (orgId, wikiId) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/tree/last-commits`,
983
1315
  WIKI_BLOB: (orgId, wikiId) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/blob`,
1316
+ // Wiki shared-draft room control plane (wiki-shared-draft-design.md §7).
1317
+ // Mounted only when cap:wiki-shared-drafts is on; absent otherwise.
1318
+ WIKI_DRAFT_OPEN: (orgId, wikiId) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/drafts/open`,
1319
+ WIKI_DRAFT_STATUS: (orgId, wikiId, draftId) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/drafts/${draftId}/status`,
1320
+ WIKI_DRAFT_SOCKET: (orgId, wikiId, draftId) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/drafts/${draftId}/socket`,
984
1321
  WIKI_COPY: (orgId, wikiId) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/copy`,
985
1322
  WIKI_NODE_SECTIONS: (orgId, wikiId) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/node-sections`,
986
1323
  WIKI_SEARCH: (orgId, wikiId) => `${WIKI_BASE}/orgs/${orgId}/wikis/${wikiId}/search`,
@@ -1389,6 +1726,13 @@ var init_project_task_client = __esm({
1389
1726
  async deleteTaskRelation(orgId, taskId, relationId) {
1390
1727
  return this.request("DELETE", ENDPOINTS.TASK_RELATION(orgId, taskId, relationId));
1391
1728
  }
1729
+ async getTaskDependencies(orgId, taskId) {
1730
+ const res = await this.request("GET", ENDPOINTS.TASK_DEPENDENCIES(orgId, taskId));
1731
+ return {
1732
+ blocked_by: res.blocked_by ?? [],
1733
+ blocking: res.blocking ?? []
1734
+ };
1735
+ }
1392
1736
  async getTaskComments(orgId, taskId, params) {
1393
1737
  return this.request("GET", ENDPOINTS.TASK_COMMENTS(orgId, taskId), void 0, params);
1394
1738
  }
@@ -1447,8 +1791,9 @@ var init_project_task_client = __esm({
1447
1791
  return res.data;
1448
1792
  }
1449
1793
  /** Public-tier self-admission: writes the caller's own member row.
1450
- * Other tiers answer `404 PROJECT_NOT_FOUND`; a duplicate answers
1451
- * `409 MEMBER_EXISTS`. */
1794
+ * Other tiers answer `403 PERMISSION_DENIED` with `details.project`
1795
+ * (its `visibility` tells whether to request-join or ask for an invite);
1796
+ * a duplicate answers `409 MEMBER_EXISTS`. */
1452
1797
  async joinProject(orgId, projectId) {
1453
1798
  return this.request("POST", ENDPOINTS.PROJECT_JOIN(orgId, projectId));
1454
1799
  }
@@ -1556,14 +1901,62 @@ var init_wechat_client = __esm({
1556
1901
  }
1557
1902
  });
1558
1903
 
1904
+ // ts/sdk/dist/mini-app-client.js
1905
+ var MiniAppClient;
1906
+ var init_mini_app_client = __esm({
1907
+ "ts/sdk/dist/mini-app-client.js"() {
1908
+ "use strict";
1909
+ init_constants();
1910
+ init_wechat_client();
1911
+ MiniAppClient = class extends WechatClient {
1912
+ async getMiniApps(orgId, query = {}) {
1913
+ const response = await this.request("GET", ENDPOINTS.MINI_APPS(orgId), void 0, {
1914
+ project_id: query.project_id,
1915
+ include_archived: query.include_archived ? "true" : void 0
1916
+ });
1917
+ return response.data;
1918
+ }
1919
+ async getMiniApp(orgId, appId) {
1920
+ return this.request("GET", ENDPOINTS.MINI_APP(orgId, appId));
1921
+ }
1922
+ async createMiniApp(orgId, data) {
1923
+ return this.request("POST", ENDPOINTS.MINI_APPS(orgId), data);
1924
+ }
1925
+ async updateMiniApp(orgId, appId, data) {
1926
+ return this.request("PATCH", ENDPOINTS.MINI_APP(orgId, appId), data);
1927
+ }
1928
+ async archiveMiniApp(orgId, appId) {
1929
+ return this.request("POST", ENDPOINTS.MINI_APP_ARCHIVE(orgId, appId));
1930
+ }
1931
+ async restoreMiniApp(orgId, appId) {
1932
+ return this.request("POST", ENDPOINTS.MINI_APP_RESTORE(orgId, appId));
1933
+ }
1934
+ async getMiniAppAuthors(orgId, appId) {
1935
+ const response = await this.request("GET", ENDPOINTS.MINI_APP_AUTHORS(orgId, appId));
1936
+ return response.data;
1937
+ }
1938
+ /** Idempotent: re-adding an existing author returns the roster unchanged. */
1939
+ async addMiniAppAuthor(orgId, appId, userId) {
1940
+ const response = await this.request("POST", ENDPOINTS.MINI_APP_AUTHORS(orgId, appId), {
1941
+ user_id: userId
1942
+ });
1943
+ return response.data;
1944
+ }
1945
+ async removeMiniAppAuthor(orgId, appId, userId) {
1946
+ return this.request("DELETE", ENDPOINTS.MINI_APP_AUTHOR(orgId, appId, userId));
1947
+ }
1948
+ };
1949
+ }
1950
+ });
1951
+
1559
1952
  // ts/sdk/dist/llm-provider-client.js
1560
1953
  var LLMProviderClient;
1561
1954
  var init_llm_provider_client = __esm({
1562
1955
  "ts/sdk/dist/llm-provider-client.js"() {
1563
1956
  "use strict";
1564
1957
  init_constants();
1565
- init_wechat_client();
1566
- LLMProviderClient = class extends WechatClient {
1958
+ init_mini_app_client();
1959
+ LLMProviderClient = class extends MiniAppClient {
1567
1960
  async getLLMProviders(orgId) {
1568
1961
  const response = await this.request("GET", ENDPOINTS.LLM_PROVIDERS(orgId));
1569
1962
  return response.data;
@@ -1882,6 +2275,209 @@ var init_browser_profile_client = __esm({
1882
2275
  }
1883
2276
  });
1884
2277
 
2278
+ // ts/sdk/dist/wiki-draft-types.js
2279
+ function isWikiDraftScope(value) {
2280
+ if (!value || typeof value !== "object")
2281
+ return false;
2282
+ const scope = value;
2283
+ return ["lane", "org_id", "wiki_id", "draft_id", "incarnation"].every((key) => typeof scope[key] === "string" && IDENTIFIER.test(scope[key])) && Number.isSafeInteger(scope.generation) && scope.generation >= 1;
2284
+ }
2285
+ function sameWikiDraftScope(left, right) {
2286
+ return left.lane === right.lane && left.org_id === right.org_id && left.wiki_id === right.wiki_id && left.draft_id === right.draft_id && left.incarnation === right.incarnation && left.generation === right.generation;
2287
+ }
2288
+ function isWireTimestamp(value) {
2289
+ if (typeof value !== "string")
2290
+ return false;
2291
+ const m = WIRE_TIMESTAMP.exec(value);
2292
+ if (!m)
2293
+ return false;
2294
+ const [year, month, day, hour, minute, second] = m.slice(1, 7).map(Number);
2295
+ if (month < 1 || month > 12)
2296
+ return false;
2297
+ const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
2298
+ const daysInMonth = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1];
2299
+ if (day < 1 || day > daysInMonth)
2300
+ return false;
2301
+ if (hour > 23 || minute > 59 || second > 59)
2302
+ return false;
2303
+ if (m[7] !== void 0 && (Number(m[7]) > 23 || Number(m[8]) > 59))
2304
+ return false;
2305
+ return true;
2306
+ }
2307
+ function isSequence(value, min) {
2308
+ return Number.isSafeInteger(value) && value >= min;
2309
+ }
2310
+ function isWikiDraftConnection(value) {
2311
+ if (!value || typeof value !== "object")
2312
+ return false;
2313
+ const c = value;
2314
+ return isWikiDraftScope(c.scope) && c.schema_version === WIKI_DRAFT_SCHEMA_VERSION && Number.isSafeInteger(c.seq) && c.seq >= 0 && typeof c.actor_id === "string" && c.actor_id.length > 0 && typeof c.actor_token === "string" && c.actor_token.length > 0 && typeof c.websocket_url === "string" && c.websocket_url.startsWith("/") && isWireTimestamp(c.issued_at) && isWireTimestamp(c.expires_at);
2315
+ }
2316
+ function isWikiDraftStatus(value) {
2317
+ if (!value || typeof value !== "object")
2318
+ return false;
2319
+ const s = value;
2320
+ const owner = s.owner;
2321
+ return isWikiDraftScope(s.scope) && typeof s.path === "string" && s.schema_version === WIKI_DRAFT_SCHEMA_VERSION && Number.isSafeInteger(s.seq) && s.seq >= 0 && typeof s.base_commit === "string" && typeof s.base_blob === "string" && (s.state === "active" || s.state === "conflicted" || s.state === "retired") && (owner === null || !!owner && typeof owner === "object" && typeof owner.instance === "string" && Number.isSafeInteger(owner.epoch) && isWireTimestamp(owner.lease_deadline)) && isWireTimestamp(s.updated_at);
2322
+ }
2323
+ function isWikiDraftReceipt(value) {
2324
+ if (!value || typeof value !== "object")
2325
+ return false;
2326
+ const r = value;
2327
+ return typeof r.draft_id === "string" && r.draft_id.length > 0 && isSequence(r.generation, 1) && // seq 0 is the initial checkpoint; every persisted operation is >= 1.
2328
+ isSequence(r.seq, 1) && typeof r.operation_id === "string" && r.operation_id.length > 0 && typeof r.actor_id === "string" && typeof r.request_digest === "string" && typeof r.update_digest === "string" && isWireTimestamp(r.created_at);
2329
+ }
2330
+ function isWikiDraftAck(value) {
2331
+ if (!value || typeof value !== "object")
2332
+ return false;
2333
+ const a = value;
2334
+ return a.version === WIKI_DRAFT_PROTOCOL_VERSION && isWikiDraftScope(a.scope) && Array.isArray(a.receipts) && a.receipts.every(isWikiDraftReceipt);
2335
+ }
2336
+ function isWikiDraftErrorFrame(value) {
2337
+ if (!value || typeof value !== "object")
2338
+ return false;
2339
+ const e = value;
2340
+ return e.version === WIKI_DRAFT_PROTOCOL_VERSION && typeof e.code === "string" && WIKI_DRAFT_ERROR_CODES.includes(e.code) && (e.operation_ids === void 0 || Array.isArray(e.operation_ids) && e.operation_ids.every((id) => typeof id === "string")) && typeof e.retryable === "boolean";
2341
+ }
2342
+ function isWikiDraftBackpressure(value) {
2343
+ if (!value || typeof value !== "object")
2344
+ return false;
2345
+ const b = value;
2346
+ return b.version === WIKI_DRAFT_PROTOCOL_VERSION && typeof b.paused === "boolean" && isSequence(b.pending_seq, 0) && (b.reason === void 0 || typeof b.reason === "string");
2347
+ }
2348
+ function isWikiDraftWelcome(value) {
2349
+ if (!value || typeof value !== "object")
2350
+ return false;
2351
+ const w = value;
2352
+ return w.version === WIKI_DRAFT_PROTOCOL_VERSION && isWikiDraftScope(w.scope) && w.schema_version === WIKI_DRAFT_SCHEMA_VERSION && isSequence(w.seq, 0) && typeof w.actor_id === "string" && w.actor_id.length > 0 && typeof w.display_name === "string" && isSequence(w.owner_epoch, 1);
2353
+ }
2354
+ function isWikiDraftHello(value) {
2355
+ if (!value || typeof value !== "object")
2356
+ return false;
2357
+ const h = value;
2358
+ return h.version === WIKI_DRAFT_PROTOCOL_VERSION && isWikiDraftScope(h.scope) && h.schema_version === WIKI_DRAFT_SCHEMA_VERSION && // Yjs clientID is an unsigned 32-bit integer.
2359
+ isSequence(h.client_id, 0) && h.client_id <= 4294967295 && typeof h.actor_token === "string" && h.actor_token.length > 0;
2360
+ }
2361
+ function isWikiDraftAuthorize(value) {
2362
+ if (!value || typeof value !== "object")
2363
+ return false;
2364
+ const a = value;
2365
+ return a.version === WIKI_DRAFT_PROTOCOL_VERSION && typeof a.actor_token === "string" && a.actor_token.length > 0;
2366
+ }
2367
+ function isWikiDraftOperationInput(value) {
2368
+ if (!value || typeof value !== "object")
2369
+ return false;
2370
+ const o = value;
2371
+ if (o.version !== WIKI_DRAFT_PROTOCOL_VERSION)
2372
+ return false;
2373
+ const keys = Object.keys(o).sort();
2374
+ if (o.kind === "native") {
2375
+ return keys.join(",") === "kind,update,version" && typeof o.update === "string" && o.update.length > 0 && BASE64.test(o.update);
2376
+ }
2377
+ if (o.kind === "markdown") {
2378
+ return keys.join(",") === "edit_base,kind,markdown,version" && typeof o.edit_base === "string" && IDENTIFIER.test(o.edit_base) && typeof o.markdown === "string" && !o.markdown.includes("\0");
2379
+ }
2380
+ return false;
2381
+ }
2382
+ var WIKI_DRAFT_PROTOCOL_VERSION, WIKI_DRAFT_SCHEMA_VERSION, WIKI_DRAFT_SOCKET_SUBPROTOCOL, WIKI_DRAFT_TICKET_SUBPROTOCOL_PREFIX, WIKI_DRAFT_MESSAGE, WIKI_DRAFT_ERROR_CODES, IDENTIFIER, WIRE_TIMESTAMP, BASE64;
2383
+ var init_wiki_draft_types = __esm({
2384
+ "ts/sdk/dist/wiki-draft-types.js"() {
2385
+ "use strict";
2386
+ WIKI_DRAFT_PROTOCOL_VERSION = 1;
2387
+ WIKI_DRAFT_SCHEMA_VERSION = 1;
2388
+ WIKI_DRAFT_SOCKET_SUBPROTOCOL = "parall.wiki.v1";
2389
+ WIKI_DRAFT_TICKET_SUBPROTOCOL_PREFIX = "ticket.";
2390
+ WIKI_DRAFT_MESSAGE = {
2391
+ sync: 0,
2392
+ awareness: 1,
2393
+ ack: 2,
2394
+ hello: 3,
2395
+ error: 4,
2396
+ backpressure: 5,
2397
+ authorize: 6
2398
+ };
2399
+ WIKI_DRAFT_ERROR_CODES = [
2400
+ "DRAFT_INVALID",
2401
+ "DRAFT_SCHEMA",
2402
+ "DRAFT_SCOPE",
2403
+ "DRAFT_FORBIDDEN",
2404
+ "DRAFT_ACTOR_EXPIRED",
2405
+ "DRAFT_NOT_FOUND",
2406
+ "DRAFT_WRITES_DISABLED",
2407
+ "DRAFT_BASE_MOVED",
2408
+ "DRAFT_IDENTITY_CHANGED",
2409
+ "DRAFT_INACTIVE",
2410
+ "DRAFT_LEASE_EXPIRED",
2411
+ "DRAFT_OWNED",
2412
+ "DRAFT_OWNER_UNAVAILABLE",
2413
+ "DRAFT_REVISION_CHANGED",
2414
+ "DRAFT_OPERATION_REUSED",
2415
+ "DRAFT_UNINITIALIZED",
2416
+ "DRAFT_EDIT_BASE_EXPIRED",
2417
+ "DRAFT_CORRUPT",
2418
+ "DRAFT_VALIDATION",
2419
+ "DRAFT_BACKPRESSURE",
2420
+ "DRAFT_BUSY",
2421
+ "DRAFT_LIMIT",
2422
+ "DRAFT_UNAVAILABLE",
2423
+ "DRAFT_SERVICE_UNAUTHORIZED",
2424
+ "DRAFT_RPC_NOT_FOUND",
2425
+ "DRAFT_RPC_FAILED"
2426
+ ];
2427
+ IDENTIFIER = /^[A-Za-z0-9_.:-]{1,128}$/;
2428
+ WIRE_TIMESTAMP = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d{1,9})?(?:Z|[+-](\d{2}):(\d{2}))$/;
2429
+ BASE64 = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
2430
+ }
2431
+ });
2432
+
2433
+ // ts/sdk/dist/wiki-draft-client.js
2434
+ var WikiDraftClient;
2435
+ var init_wiki_draft_client = __esm({
2436
+ "ts/sdk/dist/wiki-draft-client.js"() {
2437
+ "use strict";
2438
+ init_browser_profile_client();
2439
+ init_constants();
2440
+ init_wiki_draft_types();
2441
+ WikiDraftClient = class extends BrowserProfileClient {
2442
+ /**
2443
+ * Open (or rejoin) the shared draft of an existing formal Markdown path.
2444
+ * No content is uploaded; the server pins the Git baseline itself.
2445
+ * Only call this when `cap:wiki-shared-drafts` and the org flag are on —
2446
+ * the routes do not exist otherwise.
2447
+ */
2448
+ async openWikiDraft(orgId, wikiId, path27, opts) {
2449
+ const connection = await this.request("POST", ENDPOINTS.WIKI_DRAFT_OPEN(orgId, wikiId), { path: path27 }, void 0, false, opts);
2450
+ if (!isWikiDraftConnection(connection) || connection.scope.org_id !== orgId || connection.scope.wiki_id !== wikiId) {
2451
+ throw new Error("DRAFT_SCOPE");
2452
+ }
2453
+ const socketPath = ENDPOINTS.WIKI_DRAFT_SOCKET(orgId, wikiId, connection.scope.draft_id);
2454
+ if (connection.websocket_url !== socketPath)
2455
+ throw new Error("DRAFT_SCOPE");
2456
+ const base = this.baseUrlFor(socketPath);
2457
+ const locationOrigin = typeof globalThis.location === "undefined" ? void 0 : globalThis.location.origin;
2458
+ const socket = new URL(`${base}${socketPath}`, locationOrigin);
2459
+ if (!["http:", "https:"].includes(socket.protocol) || socket.username || socket.password || socket.search || socket.hash) {
2460
+ throw new Error("DRAFT_SCOPE");
2461
+ }
2462
+ socket.protocol = socket.protocol === "https:" ? "wss:" : "ws:";
2463
+ return { ...connection, websocket_url: socket.href };
2464
+ }
2465
+ /** Durable draft metadata under the caller's current read permission. Never uploads content. */
2466
+ async getWikiDraftStatus(scope, opts) {
2467
+ const status = await this.request("GET", ENDPOINTS.WIKI_DRAFT_STATUS(scope.org_id, scope.wiki_id, scope.draft_id), void 0, { lane: scope.lane, incarnation: scope.incarnation, generation: String(scope.generation) }, false, opts);
2468
+ if (!isWikiDraftStatus(status) || !sameWikiDraftScope(status.scope, scope)) {
2469
+ throw new Error("DRAFT_SCOPE");
2470
+ }
2471
+ return status;
2472
+ }
2473
+ /** Subprotocol tokens for the room WebSocket handshake: protocol + ticket. */
2474
+ wikiDraftSocketProtocols(connection) {
2475
+ return ["parall.wiki.v1", `ticket.${connection.actor_token}`];
2476
+ }
2477
+ };
2478
+ }
2479
+ });
2480
+
1885
2481
  // ts/sdk/dist/wiki-upload.js
1886
2482
  function createWikiUploadFormData(params) {
1887
2483
  const form = new FormData();
@@ -2069,12 +2665,12 @@ var init_client = __esm({
2069
2665
  "ts/sdk/dist/client.js"() {
2070
2666
  "use strict";
2071
2667
  init_browser_viewer();
2072
- init_browser_profile_client();
2668
+ init_wiki_draft_client();
2073
2669
  init_wiki_upload();
2074
2670
  init_fetch_cause();
2075
2671
  init_wiki_changeset();
2076
2672
  init_constants();
2077
- ParallClient = class _ParallClient extends BrowserProfileClient {
2673
+ ParallClient = class _ParallClient extends WikiDraftClient {
2078
2674
  baseUrl;
2079
2675
  wikiBaseUrl;
2080
2676
  token;
@@ -4743,6 +5339,45 @@ var init_llm_provider_types = __esm({
4743
5339
  }
4744
5340
  });
4745
5341
 
5342
+ // ts/sdk/dist/mini-app-types.js
5343
+ var init_mini_app_types = __esm({
5344
+ "ts/sdk/dist/mini-app-types.js"() {
5345
+ "use strict";
5346
+ }
5347
+ });
5348
+
5349
+ // ts/sdk/dist/runtime-observation.js
5350
+ var RUNTIME_OBSERVATION_EVENTS, RUNTIME_OBSERVATION_STATUSES;
5351
+ var init_runtime_observation2 = __esm({
5352
+ "ts/sdk/dist/runtime-observation.js"() {
5353
+ "use strict";
5354
+ RUNTIME_OBSERVATION_EVENTS = [
5355
+ "turn_started",
5356
+ "turn_completed",
5357
+ "thread_status",
5358
+ "hook_started",
5359
+ "hook_completed",
5360
+ "session_initialized",
5361
+ "request_completed",
5362
+ "session_status"
5363
+ ];
5364
+ RUNTIME_OBSERVATION_STATUSES = [
5365
+ "running",
5366
+ "completed",
5367
+ "failed",
5368
+ "blocked",
5369
+ "stopped",
5370
+ "interrupted",
5371
+ "idle",
5372
+ "not_loaded",
5373
+ "system_error",
5374
+ "initialized",
5375
+ "compacting",
5376
+ "unknown"
5377
+ ];
5378
+ }
5379
+ });
5380
+
4746
5381
  // ts/sdk/dist/subject.js
4747
5382
  function isTeamSubject(token) {
4748
5383
  return token.startsWith(TEAM_ID_PREFIX);
@@ -4811,38 +5446,6 @@ var init_types = __esm({
4811
5446
  }
4812
5447
  });
4813
5448
 
4814
- // ts/sdk/dist/runtime-observation.js
4815
- var RUNTIME_OBSERVATION_EVENTS, RUNTIME_OBSERVATION_STATUSES;
4816
- var init_runtime_observation2 = __esm({
4817
- "ts/sdk/dist/runtime-observation.js"() {
4818
- "use strict";
4819
- RUNTIME_OBSERVATION_EVENTS = [
4820
- "turn_started",
4821
- "turn_completed",
4822
- "thread_status",
4823
- "hook_started",
4824
- "hook_completed",
4825
- "session_initialized",
4826
- "request_completed",
4827
- "session_status"
4828
- ];
4829
- RUNTIME_OBSERVATION_STATUSES = [
4830
- "running",
4831
- "completed",
4832
- "failed",
4833
- "blocked",
4834
- "stopped",
4835
- "interrupted",
4836
- "idle",
4837
- "not_loaded",
4838
- "system_error",
4839
- "initialized",
4840
- "compacting",
4841
- "unknown"
4842
- ];
4843
- }
4844
- });
4845
-
4846
5449
  // ts/sdk/dist/wechat-types.js
4847
5450
  var init_wechat_types = __esm({
4848
5451
  "ts/sdk/dist/wechat-types.js"() {
@@ -5264,330 +5867,6 @@ var init_ws = __esm({
5264
5867
  }
5265
5868
  });
5266
5869
 
5267
- // ts/sdk/dist/browser-use-contract.generated.js
5268
- var browserUseContract;
5269
- var init_browser_use_contract_generated = __esm({
5270
- "ts/sdk/dist/browser-use-contract.generated.js"() {
5271
- "use strict";
5272
- browserUseContract = { "actions": { "read": { "grant": "browser.read", "target": "optional_tab", "params": { "required": [], "properties": { "url": { "type": "string", "min_length": 1, "max_length": 8192, "schemes": ["http", "https", "about:blank"] } }, "rules": ["exactly one of params.url or target is required", "params.url creates a hidden Profile-bound tab and closes it before terminal success or failure"], "additional_properties": false }, "success": { "base": null, "fields": { "profile_id": "ebp_identifier", "url": "string", "title": "string", "article": "nullable_article" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "tabs": { "grant": "browser.read", "target": "none", "params": { "required": [], "properties": {}, "additional_properties": false }, "success": { "base": null, "fields": { "tabs": "tab_summary_array" } }, "errors": ["TAB_GONE"] }, "wait": { "grant": "browser.read", "target": "tab", "params": { "required": [], "properties": { "selector": { "type": "string", "min_length": 1, "max_length": 4096 }, "state": { "enum": ["attached", "detached", "visible", "hidden", "load"], "default": "attached" }, "timeout_ms": { "type": "integer", "minimum": 1, "maximum": 3e4, "default": 1e4 } }, "rules": ["selector is required unless state=load", "state=load forbids selector"], "additional_properties": false }, "success": { "base": "tab_state", "fields": { "matched": { "const": true } } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "snapshot": { "grant": "browser.read", "target": "tab", "params": { "required": [], "properties": { "interactive": { "type": "boolean", "default": false }, "compact": { "type": "boolean", "default": false }, "depth": { "type": "integer", "minimum": 0, "maximum": 64 } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "snapshot": "string", "snapshot_id": "identifier" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "get": { "grant": "browser.read", "target": "tab_or_ref", "params": { "required": ["prop"], "properties": { "selector": { "type": "string", "min_length": 1, "max_length": 4096 }, "prop": { "enum": ["text", "html", "value", "attr", "title", "url"] }, "name": { "type": "string", "min_length": 1, "max_length": 256 } }, "rules": ["title/url forbid locator and name", "text/html/value require exactly one locator", "attr requires exactly one locator and name"], "additional_properties": false }, "success": { "base": "tab_state", "fields": { "value": "nullable_string" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "STALE_REF", "PAGE_LOAD_FAILED"] }, "screenshot": { "grant": "browser.read", "target": "tab", "params": { "required": [], "properties": {}, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "format": { "const": "png" }, "base64": "canonical_base64" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "open": { "grant": "browser.interact", "target": "none", "params": { "required": ["url"], "properties": { "url": { "type": "string", "min_length": 1, "max_length": 8192, "schemes": ["http", "https", "about:blank"] }, "hidden": { "type": "boolean", "default": false }, "viewport": { "type": "viewport" } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": {} }, "errors": ["PAGE_LOAD_FAILED"] }, "navigate": { "grant": "browser.interact", "target": "tab", "params": { "required": ["url"], "properties": { "url": { "type": "string", "min_length": 1, "max_length": 8192, "schemes": ["http", "https", "about:blank"] } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": {} }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "viewport": { "grant": "browser.interact", "target": "tab", "params": { "required": ["width", "height"], "properties": { "width": { "type": "integer", "minimum": 320, "maximum": 3840 }, "height": { "type": "integer", "minimum": 240, "maximum": 2160 } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "viewport": "viewport" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE"] }, "click": { "grant": "browser.interact", "target": "tab_or_ref", "params": { "required": [], "properties": { "selector": "selector" }, "rules": ["exactly one of params.selector or target.ref"], "additional_properties": false }, "success": { "base": "tab_state", "fields": { "clicked": { "const": true } } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "STALE_REF", "PAGE_LOAD_FAILED"] }, "fill": { "grant": "browser.interact", "target": "tab_or_ref", "params": { "required": ["text"], "properties": { "selector": "selector", "text": { "type": "string", "allow_empty": true } }, "rules": ["exactly one of params.selector or target.ref"], "additional_properties": false }, "success": { "base": "tab_state", "fields": { "filled": { "const": true }, "characters": "non_negative_integer" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "STALE_REF", "PAGE_LOAD_FAILED"] }, "type": { "grant": "browser.interact", "target": "tab_or_ref", "params": { "required": ["text"], "properties": { "selector": "selector", "text": { "type": "string", "min_length": 1 } }, "rules": ["exactly one of params.selector or target.ref"], "additional_properties": false }, "success": { "base": "tab_state", "fields": { "typed": { "const": true }, "characters": "non_negative_integer" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "STALE_REF", "PAGE_LOAD_FAILED"] }, "press": { "grant": "browser.interact", "target": "tab", "params": { "required": ["key"], "properties": { "key": "single_unicode_character_or_named_key" }, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "pressed": { "const": true } } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "scroll": { "grant": "browser.interact", "target": "tab", "params": { "required": [], "properties": { "direction": { "enum": ["up", "down", "left", "right"], "default": "down" }, "pixels": { "type": "integer", "minimum": 1, "maximum": 1e5, "default": 500 } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "scrolled": { "const": true } } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "close": { "grant": "browser.interact", "target": "tab", "params": { "required": [], "properties": {}, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "closed": { "const": true } } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE"] }, "recover": { "grant": "browser.interact", "target": "tab", "params": { "required": [], "properties": {}, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "recovered_from_tab_id": "identifier" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] }, "eval": { "grant": "browser.advanced", "target": "tab", "params": { "required": ["expression"], "properties": { "expression": { "type": "string", "min_length": 1 }, "timeout_ms": { "type": "integer", "minimum": 1, "maximum": 15e3, "default": 15e3 } }, "additional_properties": false }, "success": { "base": "tab_state", "fields": { "value": "json_value_max_256_kib" } }, "errors": ["TAB_NOT_FOUND", "TAB_GONE", "PAGE_LOAD_FAILED"] } }, "successShapes": { "tab_state": { "required": ["tab_id", "profile_id", "browser_generation", "document_generation", "url", "title"], "fields": { "tab_id": "identifier", "profile_id": "ebp_identifier", "browser_generation": "positive_integer", "document_generation": "positive_integer", "url": "string", "title": "string" }, "additional_properties": false }, "tab_summary": { "base": "tab_state", "required_additions": ["loading"], "fields": { "loading": "boolean" }, "additional_properties": false }, "article": { "required": ["title", "byline", "excerpt", "text", "published_time", "site_name", "length"], "fields": { "title": "nullable_string", "byline": "nullable_string", "excerpt": "nullable_string", "text": "string", "published_time": "nullable_string", "site_name": "nullable_string", "length": "non_negative_integer" }, "additional_properties": false } } };
5273
- }
5274
- });
5275
-
5276
- // ts/sdk/dist/browser-use-validation.js
5277
- function browserUseObject(value) {
5278
- if (!value || typeof value !== "object" || Array.isArray(value))
5279
- throw new BrowserUseValidationError("Expected an object.");
5280
- return value;
5281
- }
5282
- function browserUseIdentifier(value, prefix) {
5283
- if (typeof value !== "string" || !value.startsWith(prefix) || value.length <= prefix.length || value.length > 128 || !/^[A-Za-z0-9_-]+$/.test(value) || ["__proto__", "constructor", "prototype"].includes(value))
5284
- throw new BrowserUseValidationError(`Expected a ${prefix} identifier.`);
5285
- return value;
5286
- }
5287
- function requireValid(condition, label) {
5288
- if (!condition)
5289
- throw new BrowserUseValidationError(`Invalid ${label}.`);
5290
- }
5291
- function exact(value, allowed, required = []) {
5292
- requireValid(Object.keys(value).every((k) => allowed.includes(k)) && required.every((k) => Object.hasOwn(value, k)), "object fields");
5293
- }
5294
- function validateBrowserUseField(value, field, label) {
5295
- if (typeof field === "string") {
5296
- switch (field) {
5297
- case "selector":
5298
- return validateBrowserUseField(value, { type: "string", min_length: 1, max_length: 4096 }, label);
5299
- case "single_unicode_character_or_named_key":
5300
- requireValid(typeof value === "string" && ([...value].length === 1 || [
5301
- "Enter",
5302
- "Tab",
5303
- "Escape",
5304
- "Backspace",
5305
- "Delete",
5306
- "ArrowUp",
5307
- "ArrowDown",
5308
- "ArrowLeft",
5309
- "ArrowRight",
5310
- "Home",
5311
- "End",
5312
- "PageUp",
5313
- "PageDown"
5314
- ].includes(value)), label);
5315
- return;
5316
- case "viewport": {
5317
- const obj = browserUseObject(value);
5318
- exact(obj, ["width", "height"], ["width", "height"]);
5319
- validateBrowserUseField(obj.width, { type: "integer", minimum: 320, maximum: 3840 }, label);
5320
- validateBrowserUseField(obj.height, { type: "integer", minimum: 240, maximum: 2160 }, label);
5321
- return;
5322
- }
5323
- case "identifier":
5324
- browserUseIdentifier(value, label.includes("snapshot") ? "bsn_" : "btab_");
5325
- return;
5326
- case "ebp_identifier":
5327
- browserUseIdentifier(value, "ebp_");
5328
- return;
5329
- case "positive_integer":
5330
- return validateBrowserUseField(value, { type: "integer", minimum: 1 }, label);
5331
- case "non_negative_integer":
5332
- return validateBrowserUseField(value, { type: "integer", minimum: 0 }, label);
5333
- case "nullable_string":
5334
- if (value === null)
5335
- return;
5336
- return validateBrowserUseField(value, { type: "string", allow_empty: true }, label);
5337
- case "string":
5338
- return validateBrowserUseField(value, { type: "string", allow_empty: true }, label);
5339
- case "boolean":
5340
- requireValid(typeof value === "boolean", label);
5341
- return;
5342
- case "canonical_base64":
5343
- requireValid(typeof value === "string" && value.length > 0 && /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value) && btoa(atob(value)) === value, label);
5344
- return;
5345
- case "nullable_article":
5346
- if (value === null)
5347
- return;
5348
- return validateShape(value, browserUseContract.successShapes.article.fields);
5349
- case "tab_summary_array":
5350
- requireValid(Array.isArray(value), label);
5351
- for (const tab of value)
5352
- validateShape(tab, {
5353
- ...browserUseContract.successShapes.tab_state.fields,
5354
- loading: "boolean"
5355
- });
5356
- return;
5357
- case "json_value_max_256_kib":
5358
- requireValid(new TextEncoder().encode(canonicalBrowserUseJson(value)).length <= 256 * 1024, label);
5359
- return;
5360
- default:
5361
- throw new BrowserUseValidationError(`Unknown contract field ${field}.`);
5362
- }
5363
- }
5364
- if ("const" in field) {
5365
- requireValid(value === field.const, label);
5366
- return;
5367
- }
5368
- if (field.enum) {
5369
- requireValid(field.enum.includes(value), label);
5370
- return;
5371
- }
5372
- if (field.type === "viewport")
5373
- return validateBrowserUseField(value, "viewport", label);
5374
- if (field.type === "boolean") {
5375
- requireValid(typeof value === "boolean", label);
5376
- return;
5377
- }
5378
- if (field.type === "integer") {
5379
- requireValid(typeof value === "number" && Number.isSafeInteger(value) && value >= (field.minimum ?? 0) && value <= (field.maximum ?? Number.MAX_SAFE_INTEGER), label);
5380
- return;
5381
- }
5382
- requireValid(typeof value === "string" && [...value].length >= (field.allow_empty ? 0 : field.min_length ?? 1) && [...value].length <= (field.max_length ?? 1 << 20), label);
5383
- if (field.schemes) {
5384
- if (value === "about:blank")
5385
- return;
5386
- let url;
5387
- try {
5388
- url = new URL(value);
5389
- } catch {
5390
- throw new BrowserUseValidationError(`Invalid ${label} URL.`);
5391
- }
5392
- requireValid(url.protocol === "https:" || url.protocol === "http:", label);
5393
- }
5394
- }
5395
- function validateShape(value, fields) {
5396
- const obj = browserUseObject(value);
5397
- exact(obj, Object.keys(fields), Object.keys(fields));
5398
- for (const [key, field] of Object.entries(fields))
5399
- validateBrowserUseField(obj[key], field, key);
5400
- }
5401
- function validateBrowserUseActionRequest(value) {
5402
- const obj = browserUseObject(value);
5403
- exact(obj, ["action", "target", "params"], ["action", "params"]);
5404
- requireValid(typeof obj.action === "string", "action");
5405
- if (!Object.hasOwn(BROWSER_USE_ACTION_SCHEMAS, obj.action))
5406
- throw new BrowserUseValidationError(`Browser Use v1 does not support ${obj.action}.`, "UNSUPPORTED_ACTION");
5407
- const action = obj.action;
5408
- const schema = BROWSER_USE_ACTION_SCHEMAS[action];
5409
- const params = browserUseObject(obj.params);
5410
- exact(params, Object.keys(schema.params.properties), [...schema.params.required]);
5411
- for (const [key, val] of Object.entries(params))
5412
- validateBrowserUseField(val, schema.params.properties[key], key);
5413
- let target;
5414
- if (obj.target !== void 0) {
5415
- requireValid(schema.target !== "none", "target");
5416
- target = browserUseObject(obj.target);
5417
- const base = ["tab_id", "browser_generation"];
5418
- const refs = ["document_generation", "snapshot_id", "ref"];
5419
- exact(target, schema.target === "tab_or_ref" ? [...base, ...refs] : base, base);
5420
- browserUseIdentifier(target.tab_id, "btab_");
5421
- validateBrowserUseField(target.browser_generation, "positive_integer", "browser_generation");
5422
- if (refs.some((k) => Object.hasOwn(target, k))) {
5423
- requireValid(refs.every((k) => Object.hasOwn(target, k)), "complete ref binding");
5424
- validateBrowserUseField(target.document_generation, "positive_integer", "document_generation");
5425
- browserUseIdentifier(target.snapshot_id, "bsn_");
5426
- browserUseIdentifier(target.ref, "");
5427
- }
5428
- } else
5429
- requireValid(schema.target === "none" || schema.target === "optional_tab", "required target");
5430
- const locatorCount = Number(params.selector !== void 0) + Number(target?.ref !== void 0);
5431
- if (action === "read")
5432
- requireValid(params.url !== void 0 !== Boolean(target), "read URL or target");
5433
- if (action === "wait")
5434
- requireValid(params.state === "load" === (params.selector === void 0), "wait selector/state");
5435
- if (["click", "fill", "type"].includes(action))
5436
- requireValid(locatorCount === 1, "exactly one locator");
5437
- if (action === "get") {
5438
- const page = params.prop === "title" || params.prop === "url";
5439
- requireValid(locatorCount === (page ? 0 : 1), "get locator");
5440
- requireValid(params.prop === "attr" === (params.name !== void 0), "get attribute name");
5441
- }
5442
- requireValid(new TextEncoder().encode(JSON.stringify(obj)).length <= 1 << 20, "request size");
5443
- return obj;
5444
- }
5445
- function validateBrowserUseSuccessData(action, value) {
5446
- const schema = BROWSER_USE_ACTION_SCHEMAS[action].success;
5447
- validateShape(value, {
5448
- ...schema.base === "tab_state" ? browserUseContract.successShapes.tab_state.fields : {},
5449
- ...schema.fields
5450
- });
5451
- }
5452
- function canonicalBrowserUseJson(value, seen = /* @__PURE__ */ new Set()) {
5453
- if (value === null || typeof value === "boolean" || typeof value === "string")
5454
- return JSON.stringify(value);
5455
- if (typeof value === "number" && Number.isFinite(value))
5456
- return JSON.stringify(value);
5457
- if (!value || typeof value !== "object" || seen.has(value))
5458
- throw new BrowserUseValidationError("Invalid JSON result.");
5459
- seen.add(value);
5460
- const result = Array.isArray(value) ? `[${value.map((v) => canonicalBrowserUseJson(v, seen)).join(",")}]` : `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${canonicalBrowserUseJson(value[k], seen)}`).join(",")}}`;
5461
- seen.delete(value);
5462
- return result;
5463
- }
5464
- var BrowserUseValidationError, BROWSER_USE_ACTION_SCHEMAS, BROWSER_USE_ACTIONS;
5465
- var init_browser_use_validation = __esm({
5466
- "ts/sdk/dist/browser-use-validation.js"() {
5467
- "use strict";
5468
- init_browser_use_contract_generated();
5469
- BrowserUseValidationError = class extends Error {
5470
- code;
5471
- constructor(message, code = "INVALID_ARGUMENT") {
5472
- super(message);
5473
- this.code = code;
5474
- }
5475
- };
5476
- BROWSER_USE_ACTION_SCHEMAS = browserUseContract.actions;
5477
- BROWSER_USE_ACTIONS = Object.freeze(Object.keys(BROWSER_USE_ACTION_SCHEMAS));
5478
- }
5479
- });
5480
-
5481
- // ts/sdk/dist/browser-use-receipt.js
5482
- function isBrowserUseTimestamp(value) {
5483
- if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/.test(value))
5484
- return false;
5485
- const [year, month, day, hour, minute, second] = value.slice(0, 19).split(/[-T:]/).map(Number);
5486
- return year >= 1 && month >= 1 && month <= 12 && day >= 1 && day <= new Date(Date.UTC(year, month, 0)).getUTCDate() && hour < 24 && minute < 60 && second < 60 && Number.isFinite(Date.parse(value));
5487
- }
5488
- async function browserUseResultDigest(value, maxBytes = 1 << 20, subtle = globalThis.crypto.subtle) {
5489
- const bytes = new TextEncoder().encode(canonicalBrowserUseJson(value));
5490
- if (bytes.length > maxBytes)
5491
- throw new BrowserUseValidationError("Browser Use result exceeds contract size.");
5492
- const digest = await subtle.digest("SHA-256", bytes);
5493
- return `sha256:${Array.from(new Uint8Array(digest), (n) => n.toString(16).padStart(2, "0")).join("")}`;
5494
- }
5495
- function proof(condition) {
5496
- if (!condition)
5497
- throw new BrowserUseValidationError("The Browser Use response did not contain valid public status proof.", "INVALID_SERVER_RESPONSE");
5498
- }
5499
- async function validateBrowserUseReceipt(value, expected, subtle) {
5500
- try {
5501
- const r = browserUseObject(value);
5502
- proof(Object.keys(r).every((k) => KEYS.includes(k)));
5503
- proof(r.contract_version === "browser-use-operation-v1");
5504
- browserUseIdentifier(r.operation_id, "buo_");
5505
- browserUseIdentifier(r.request_id, "burq_");
5506
- browserUseIdentifier(r.profile_id, "ebp_");
5507
- proof(r.profile_id === expected.profileId && (!expected.operationId || r.operation_id === expected.operationId) && (!expected.requestId || r.request_id === expected.requestId) && (!expected.action || r.action === expected.action));
5508
- proof(typeof r.action === "string" && Object.hasOwn(BROWSER_USE_ACTION_SCHEMAS, r.action));
5509
- const action = r.action;
5510
- proof(r.required_grant === BROWSER_USE_ACTION_SCHEMAS[action].grant);
5511
- proof(positive(r.profile_version) && positive(r.profile_config_revision));
5512
- proof(typeof r.phase === "string" && ["accepted", "started", ...terminal].includes(r.phase));
5513
- proof(typeof r.result_available === "boolean");
5514
- for (const k of ["deadline", "accepted_at", "updated_at"])
5515
- proof(isBrowserUseTimestamp(r[k]));
5516
- for (const k of ["occurred_at", "result_expires_at", "started_at", "terminal_at"])
5517
- if (k in r)
5518
- proof(isBrowserUseTimestamp(r[k]));
5519
- if ("duration_ms" in r)
5520
- proof(typeof r.duration_ms === "number" && Number.isSafeInteger(r.duration_ms) && r.duration_ms >= 0);
5521
- if ("dispatched" in r)
5522
- proof(typeof r.dispatched === "boolean");
5523
- proof("tab_id" in r === "browser_generation" in r);
5524
- if ("tab_id" in r) {
5525
- browserUseIdentifier(r.tab_id, "btab_");
5526
- proof(positive(r.browser_generation));
5527
- }
5528
- const isTerminal = terminal.has(r.phase);
5529
- if (isTerminal) {
5530
- browserUseIdentifier(r.receipt_id, "bur_");
5531
- proof(hash(r.receipt_digest) && isBrowserUseTimestamp(r.occurred_at) && isBrowserUseTimestamp(r.terminal_at));
5532
- } else {
5533
- proof(!("terminal_at" in r));
5534
- if ("receipt_id" in r || "receipt_digest" in r || "occurred_at" in r) {
5535
- proof(r.phase === "started");
5536
- browserUseIdentifier(r.receipt_id, "bur_");
5537
- proof(hash(r.receipt_digest) && isBrowserUseTimestamp(r.occurred_at));
5538
- }
5539
- }
5540
- const hasData = Object.hasOwn(r, "data");
5541
- proof(r.result_available === hasData);
5542
- if (r.phase === "succeeded")
5543
- proof(!("error" in r) && hash(r.result_digest));
5544
- else {
5545
- proof(!hasData && !r.result_available);
5546
- if (isTerminal) {
5547
- const e = browserUseObject(r.error);
5548
- proof(Object.keys(e).every((k) => ["code", "message", "hint"].includes(k)) && typeof e.code === "string" && /^[A-Z][A-Z0-9_]{0,127}$/.test(e.code));
5549
- for (const k of ["message", "hint"])
5550
- if (k in e)
5551
- proof(typeof e[k] === "string" && e[k].length <= 1024);
5552
- if (r.phase === "outcome_unknown")
5553
- proof(e.code === "UNKNOWN_OUTCOME");
5554
- } else
5555
- proof(!("error" in r));
5556
- }
5557
- if (hasData) {
5558
- validateBrowserUseSuccessData(action, r.data);
5559
- proof(r.result_digest === await browserUseResultDigest(r.data, action === "eval" ? 256 * 1024 : 1 << 20, subtle));
5560
- const data = browserUseObject(r.data);
5561
- if (action === "tabs")
5562
- proof(data.tabs.every((t) => t.profile_id === r.profile_id));
5563
- else
5564
- proof(data.profile_id === r.profile_id);
5565
- if (!["read", "tabs"].includes(action))
5566
- proof(data.tab_id === r.tab_id && data.browser_generation === r.browser_generation);
5567
- if (expected.target) {
5568
- if (action === "recover")
5569
- proof(data.recovered_from_tab_id === expected.target.tab_id);
5570
- else if (action !== "read")
5571
- proof(data.tab_id === expected.target.tab_id && data.browser_generation === expected.target.browser_generation);
5572
- }
5573
- }
5574
- return r;
5575
- } catch {
5576
- throw new BrowserUseValidationError("The Browser Use response did not contain valid public status proof.", "INVALID_SERVER_RESPONSE");
5577
- }
5578
- }
5579
- var KEYS, terminal, hash, positive;
5580
- var init_browser_use_receipt = __esm({
5581
- "ts/sdk/dist/browser-use-receipt.js"() {
5582
- "use strict";
5583
- init_browser_use_validation();
5584
- KEYS = "contract_version operation_id request_id profile_id profile_version profile_config_revision action required_grant phase dispatched receipt_id receipt_digest occurred_at tab_id browser_generation duration_ms result_digest result_available result_expires_at data error deadline accepted_at started_at terminal_at updated_at".split(" ");
5585
- terminal = /* @__PURE__ */ new Set(["succeeded", "failed", "outcome_unknown"]);
5586
- hash = (value) => typeof value === "string" && /^sha256:[0-9a-f]{64}$/.test(value);
5587
- positive = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0;
5588
- }
5589
- });
5590
-
5591
5870
  // ts/sdk/dist/index.js
5592
5871
  var dist_exports = {};
5593
5872
  __export(dist_exports, {
@@ -5614,6 +5893,12 @@ __export(dist_exports, {
5614
5893
  RUNTIME_OBSERVATION_EVENTS: () => RUNTIME_OBSERVATION_EVENTS,
5615
5894
  RUNTIME_OBSERVATION_STATUSES: () => RUNTIME_OBSERVATION_STATUSES,
5616
5895
  WIKI_BASE: () => WIKI_BASE,
5896
+ WIKI_DRAFT_ERROR_CODES: () => WIKI_DRAFT_ERROR_CODES,
5897
+ WIKI_DRAFT_MESSAGE: () => WIKI_DRAFT_MESSAGE,
5898
+ WIKI_DRAFT_PROTOCOL_VERSION: () => WIKI_DRAFT_PROTOCOL_VERSION,
5899
+ WIKI_DRAFT_SCHEMA_VERSION: () => WIKI_DRAFT_SCHEMA_VERSION,
5900
+ WIKI_DRAFT_SOCKET_SUBPROTOCOL: () => WIKI_DRAFT_SOCKET_SUBPROTOCOL,
5901
+ WIKI_DRAFT_TICKET_SUBPROTOCOL_PREFIX: () => WIKI_DRAFT_TICKET_SUBPROTOCOL_PREFIX,
5617
5902
  WS_EVENTS: () => WS_EVENTS,
5618
5903
  authRejectionFrom: () => authRejectionFrom,
5619
5904
  browserUseIdentifier: () => browserUseIdentifier,
@@ -5629,10 +5914,22 @@ __export(dist_exports, {
5629
5914
  isInWikiPersonalNamespace: () => isInWikiPersonalNamespace,
5630
5915
  isPlatformModelSelectableForRuntime: () => isPlatformModelSelectableForRuntime,
5631
5916
  isTeamSubject: () => isTeamSubject,
5917
+ isWikiDraftAck: () => isWikiDraftAck,
5918
+ isWikiDraftAuthorize: () => isWikiDraftAuthorize,
5919
+ isWikiDraftBackpressure: () => isWikiDraftBackpressure,
5920
+ isWikiDraftConnection: () => isWikiDraftConnection,
5921
+ isWikiDraftErrorFrame: () => isWikiDraftErrorFrame,
5922
+ isWikiDraftHello: () => isWikiDraftHello,
5923
+ isWikiDraftOperationInput: () => isWikiDraftOperationInput,
5924
+ isWikiDraftReceipt: () => isWikiDraftReceipt,
5925
+ isWikiDraftScope: () => isWikiDraftScope,
5926
+ isWikiDraftStatus: () => isWikiDraftStatus,
5927
+ isWikiDraftWelcome: () => isWikiDraftWelcome,
5632
5928
  isWikiPersonalNamespacePath: () => isWikiPersonalNamespacePath,
5633
5929
  mentionTargetsUser: () => mentionTargetsUser,
5634
5930
  parseSubjectToken: () => parseSubjectToken,
5635
5931
  platformDefaultModelForRuntime: () => platformDefaultModelForRuntime,
5932
+ sameWikiDraftScope: () => sameWikiDraftScope,
5636
5933
  teamIdsFromSubjects: () => teamIdsFromSubjects,
5637
5934
  validateBrowserUseActionRequest: () => validateBrowserUseActionRequest,
5638
5935
  validateBrowserUseField: () => validateBrowserUseField,
@@ -5643,107 +5940,36 @@ __export(dist_exports, {
5643
5940
  var init_dist = __esm({
5644
5941
  "ts/sdk/dist/index.js"() {
5645
5942
  "use strict";
5646
- init_browser_viewer();
5647
- init_browser_use();
5648
5943
  init_attachment_types();
5649
5944
  init_attention_types();
5945
+ init_browser_use();
5946
+ init_browser_use_receipt();
5947
+ init_browser_use_validation();
5948
+ init_browser_viewer();
5650
5949
  init_channel_types();
5651
5950
  init_client();
5652
- init_fetch_cause();
5653
5951
  init_constants();
5952
+ init_fetch_cause();
5654
5953
  init_llm_provider_types();
5954
+ init_mini_app_types();
5955
+ init_runtime_observation2();
5655
5956
  init_subject();
5656
5957
  init_task_label_types();
5657
5958
  init_types();
5658
- init_runtime_observation2();
5659
5959
  init_wechat_types();
5960
+ init_wiki_draft_types();
5660
5961
  init_ws();
5661
- init_browser_use_validation();
5662
- init_browser_use_receipt();
5663
- }
5664
- });
5665
-
5666
- // ts/agent-core/dist/fork-state.js
5667
- var init_fork_state = __esm({
5668
- "ts/agent-core/dist/fork-state.js"() {
5669
- "use strict";
5670
- init_fork_prefix();
5671
5962
  }
5672
5963
  });
5673
5964
 
5674
- // ts/agent-core/dist/gateway-steer.js
5675
- var init_gateway_steer = __esm({
5676
- "ts/agent-core/dist/gateway-steer.js"() {
5965
+ // ts/agent-core/dist/gateway/steer.js
5966
+ var init_steer = __esm({
5967
+ "ts/agent-core/dist/gateway/steer.js"() {
5677
5968
  "use strict";
5678
5969
  init_fork_prefix();
5679
5970
  }
5680
5971
  });
5681
5972
 
5682
- // ts/agent-core/dist/lane-key.js
5683
- var init_lane_key = __esm({
5684
- "ts/agent-core/dist/lane-key.js"() {
5685
- "use strict";
5686
- }
5687
- });
5688
-
5689
- // ts/agent-core/dist/lane-target.js
5690
- var PRLL_SCHEME, CHANNEL_LANE_PREFIX;
5691
- var init_lane_target = __esm({
5692
- "ts/agent-core/dist/lane-target.js"() {
5693
- "use strict";
5694
- PRLL_SCHEME = "prll://";
5695
- CHANNEL_LANE_PREFIX = `${PRLL_SCHEME}chv_`;
5696
- }
5697
- });
5698
-
5699
- // ts/agent-core/dist/lane-outcome.js
5700
- var init_lane_outcome = __esm({
5701
- "ts/agent-core/dist/lane-outcome.js"() {
5702
- "use strict";
5703
- }
5704
- });
5705
-
5706
- // ts/agent-core/dist/runtime-instance.js
5707
- var init_runtime_instance = __esm({
5708
- "ts/agent-core/dist/runtime-instance.js"() {
5709
- "use strict";
5710
- }
5711
- });
5712
-
5713
- // ts/agent-core/dist/lane-input-receipts.js
5714
- var init_lane_input_receipts = __esm({
5715
- "ts/agent-core/dist/lane-input-receipts.js"() {
5716
- "use strict";
5717
- init_dist();
5718
- init_lane_outcome();
5719
- init_redact();
5720
- init_runtime_instance();
5721
- }
5722
- });
5723
-
5724
- // ts/agent-core/dist/lane-confirmations.js
5725
- var init_lane_confirmations = __esm({
5726
- "ts/agent-core/dist/lane-confirmations.js"() {
5727
- "use strict";
5728
- init_dist();
5729
- }
5730
- });
5731
-
5732
- // ts/agent-core/dist/lane-ledger.js
5733
- var init_lane_ledger = __esm({
5734
- "ts/agent-core/dist/lane-ledger.js"() {
5735
- "use strict";
5736
- init_dist();
5737
- init_lane_key();
5738
- init_lane_target();
5739
- init_redact();
5740
- init_lane_input_receipts();
5741
- init_lane_outcome();
5742
- init_lane_confirmations();
5743
- init_runtime_instance();
5744
- }
5745
- });
5746
-
5747
5973
  // ts/node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/esm/version.js
5748
5974
  var VERSION;
5749
5975
  var init_version = __esm({
@@ -32820,34 +33046,110 @@ var init_telemetry = __esm({
32820
33046
  }
32821
33047
  });
32822
33048
 
32823
- // ts/agent-core/dist/gateway-lane-flow.js
33049
+ // ts/agent-core/dist/gateway/lane-settle.js
33050
+ var init_lane_settle = __esm({
33051
+ "ts/agent-core/dist/gateway/lane-settle.js"() {
33052
+ "use strict";
33053
+ init_fork_prefix();
33054
+ init_steer();
33055
+ init_telemetry();
33056
+ }
33057
+ });
33058
+
33059
+ // ts/agent-core/dist/lane/key.js
33060
+ var init_key = __esm({
33061
+ "ts/agent-core/dist/lane/key.js"() {
33062
+ "use strict";
33063
+ }
33064
+ });
33065
+
33066
+ // ts/agent-core/dist/lane/target.js
33067
+ var PRLL_SCHEME, CHANNEL_LANE_PREFIX;
33068
+ var init_target = __esm({
33069
+ "ts/agent-core/dist/lane/target.js"() {
33070
+ "use strict";
33071
+ PRLL_SCHEME = "prll://";
33072
+ CHANNEL_LANE_PREFIX = `${PRLL_SCHEME}chv_`;
33073
+ }
33074
+ });
33075
+
33076
+ // ts/agent-core/dist/lane/outcome.js
33077
+ var init_outcome = __esm({
33078
+ "ts/agent-core/dist/lane/outcome.js"() {
33079
+ "use strict";
33080
+ }
33081
+ });
33082
+
33083
+ // ts/agent-core/dist/runtime-instance.js
33084
+ var init_runtime_instance = __esm({
33085
+ "ts/agent-core/dist/runtime-instance.js"() {
33086
+ "use strict";
33087
+ }
33088
+ });
33089
+
33090
+ // ts/agent-core/dist/lane/input-receipts.js
33091
+ var init_input_receipts = __esm({
33092
+ "ts/agent-core/dist/lane/input-receipts.js"() {
33093
+ "use strict";
33094
+ init_dist();
33095
+ init_outcome();
33096
+ init_redact();
33097
+ init_runtime_instance();
33098
+ }
33099
+ });
33100
+
33101
+ // ts/agent-core/dist/lane/confirmations.js
33102
+ var init_confirmations = __esm({
33103
+ "ts/agent-core/dist/lane/confirmations.js"() {
33104
+ "use strict";
33105
+ init_dist();
33106
+ }
33107
+ });
33108
+
33109
+ // ts/agent-core/dist/lane/ledger.js
33110
+ var init_ledger = __esm({
33111
+ "ts/agent-core/dist/lane/ledger.js"() {
33112
+ "use strict";
33113
+ init_dist();
33114
+ init_key();
33115
+ init_target();
33116
+ init_redact();
33117
+ init_input_receipts();
33118
+ init_outcome();
33119
+ init_confirmations();
33120
+ init_runtime_instance();
33121
+ }
33122
+ });
33123
+
33124
+ // ts/agent-core/dist/gateway/lane-flow.js
32824
33125
  var TYPED_BACKOFF_CAP_MS;
32825
- var init_gateway_lane_flow = __esm({
32826
- "ts/agent-core/dist/gateway-lane-flow.js"() {
33126
+ var init_lane_flow = __esm({
33127
+ "ts/agent-core/dist/gateway/lane-flow.js"() {
32827
33128
  "use strict";
32828
33129
  init_redact();
32829
33130
  init_dist();
32830
33131
  init_change_source();
32831
33132
  init_fork_prefix();
32832
- init_gateway_steer();
32833
- init_lane_ledger();
32834
- init_lane_target();
33133
+ init_lane_settle();
33134
+ init_steer();
33135
+ init_ledger();
33136
+ init_target();
32835
33137
  init_telemetry();
32836
- init_gateway_steer();
33138
+ init_steer();
32837
33139
  TYPED_BACKOFF_CAP_MS = 5 * 6e4;
32838
33140
  }
32839
33141
  });
32840
33142
 
32841
- // ts/agent-core/dist/gateway-idle-compact.js
32842
- var init_gateway_idle_compact = __esm({
32843
- "ts/agent-core/dist/gateway-idle-compact.js"() {
33143
+ // ts/agent-core/dist/gateway/idle-compact.js
33144
+ var init_idle_compact = __esm({
33145
+ "ts/agent-core/dist/gateway/idle-compact.js"() {
32844
33146
  "use strict";
32845
33147
  }
32846
33148
  });
32847
33149
 
32848
- // ts/agent-core/dist/gateway-runtime-turns.js
32849
- var init_gateway_runtime_turns = __esm({
32850
- "ts/agent-core/dist/gateway-runtime-turns.js"() {
33150
+ // ts/agent-core/dist/gateway/runtime-turns.js
33151
+ var init_runtime_turns = __esm({
33152
+ "ts/agent-core/dist/gateway/runtime-turns.js"() {
32851
33153
  "use strict";
32852
33154
  init_dispatch_adapter();
32853
33155
  init_redact();
@@ -32856,34 +33158,114 @@ var init_gateway_runtime_turns = __esm({
32856
33158
  }
32857
33159
  });
32858
33160
 
32859
- // ts/agent-core/dist/gateway-drain.js
32860
- var init_gateway_drain = __esm({
32861
- "ts/agent-core/dist/gateway-drain.js"() {
33161
+ // ts/agent-core/dist/gateway/drain.js
33162
+ var init_drain = __esm({
33163
+ "ts/agent-core/dist/gateway/drain.js"() {
32862
33164
  "use strict";
32863
33165
  }
32864
33166
  });
32865
33167
 
32866
- // ts/agent-core/dist/gateway-session-binding.js
32867
- var init_gateway_session_binding = __esm({
32868
- "ts/agent-core/dist/gateway-session-binding.js"() {
33168
+ // ts/agent-core/dist/gateway/session-binding.js
33169
+ var init_session_binding = __esm({
33170
+ "ts/agent-core/dist/gateway/session-binding.js"() {
32869
33171
  "use strict";
32870
33172
  }
32871
33173
  });
32872
33174
 
32873
- // ts/agent-core/dist/runtime-declaration.js
32874
- var init_runtime_declaration = __esm({
32875
- "ts/agent-core/dist/runtime-declaration.js"() {
33175
+ // ts/agent-core/dist/gateway/inactivity-deadline.js
33176
+ var init_inactivity_deadline = __esm({
33177
+ "ts/agent-core/dist/gateway/inactivity-deadline.js"() {
32876
33178
  "use strict";
32877
33179
  }
32878
33180
  });
32879
33181
 
32880
- // ts/agent-core/dist/dispatch-inactivity-deadline.js
32881
- var init_dispatch_inactivity_deadline = __esm({
32882
- "ts/agent-core/dist/dispatch-inactivity-deadline.js"() {
33182
+ // ts/agent-core/dist/session/step-retry-queue.js
33183
+ var init_step_retry_queue = __esm({
33184
+ "ts/agent-core/dist/session/step-retry-queue.js"() {
32883
33185
  "use strict";
32884
33186
  }
32885
33187
  });
32886
33188
 
33189
+ // ts/agent-core/dist/session/step-persister.js
33190
+ var init_step_persister = __esm({
33191
+ "ts/agent-core/dist/session/step-persister.js"() {
33192
+ "use strict";
33193
+ init_dist();
33194
+ init_step_retry_queue();
33195
+ }
33196
+ });
33197
+
33198
+ // ts/agent-core/dist/session/lifecycle.js
33199
+ var init_lifecycle = __esm({
33200
+ "ts/agent-core/dist/session/lifecycle.js"() {
33201
+ "use strict";
33202
+ }
33203
+ });
33204
+
33205
+ // ts/agent-core/dist/session/fork-finalizer.js
33206
+ var init_fork_finalizer = __esm({
33207
+ "ts/agent-core/dist/session/fork-finalizer.js"() {
33208
+ "use strict";
33209
+ }
33210
+ });
33211
+
33212
+ // ts/agent-core/dist/session/state.js
33213
+ var init_state = __esm({
33214
+ "ts/agent-core/dist/session/state.js"() {
33215
+ "use strict";
33216
+ }
33217
+ });
33218
+
33219
+ // ts/agent-core/dist/gateway/input-steps.js
33220
+ var init_input_steps = __esm({
33221
+ "ts/agent-core/dist/gateway/input-steps.js"() {
33222
+ "use strict";
33223
+ init_change_source();
33224
+ }
33225
+ });
33226
+
33227
+ // ts/agent-core/dist/gateway/run-dispatch.js
33228
+ var init_run_dispatch = __esm({
33229
+ "ts/agent-core/dist/gateway/run-dispatch.js"() {
33230
+ "use strict";
33231
+ init_ledger();
33232
+ init_redact();
33233
+ init_state();
33234
+ init_bridge_workspace();
33235
+ init_telemetry();
33236
+ init_input_steps();
33237
+ }
33238
+ });
33239
+
33240
+ // ts/agent-core/dist/gateway/fork-state.js
33241
+ var init_fork_state = __esm({
33242
+ "ts/agent-core/dist/gateway/fork-state.js"() {
33243
+ "use strict";
33244
+ init_fork_prefix();
33245
+ }
33246
+ });
33247
+
33248
+ // ts/agent-core/dist/gateway/fork-drain.js
33249
+ var init_fork_drain = __esm({
33250
+ "ts/agent-core/dist/gateway/fork-drain.js"() {
33251
+ "use strict";
33252
+ init_fork_prefix();
33253
+ init_fork_state();
33254
+ init_telemetry();
33255
+ }
33256
+ });
33257
+
33258
+ // ts/agent-core/dist/gateway/main-drain.js
33259
+ var init_main_drain = __esm({
33260
+ "ts/agent-core/dist/gateway/main-drain.js"() {
33261
+ "use strict";
33262
+ init_fork_prefix();
33263
+ init_lane_flow();
33264
+ init_target();
33265
+ init_steer();
33266
+ }
33267
+ });
33268
+
32887
33269
  // ts/agent-core/dist/routing.js
32888
33270
  var init_routing = __esm({
32889
33271
  "ts/agent-core/dist/routing.js"() {
@@ -32891,72 +33273,83 @@ var init_routing = __esm({
32891
33273
  }
32892
33274
  });
32893
33275
 
32894
- // ts/agent-core/dist/step-retry-queue.js
32895
- var init_step_retry_queue = __esm({
32896
- "ts/agent-core/dist/step-retry-queue.js"() {
33276
+ // ts/agent-core/dist/gateway/inbound.js
33277
+ var init_inbound = __esm({
33278
+ "ts/agent-core/dist/gateway/inbound.js"() {
32897
33279
  "use strict";
33280
+ init_fork_prefix();
33281
+ init_fork_state();
33282
+ init_lane_flow();
33283
+ init_target();
33284
+ init_routing();
32898
33285
  }
32899
33286
  });
32900
33287
 
32901
- // ts/agent-core/dist/step-persister.js
32902
- var init_step_persister = __esm({
32903
- "ts/agent-core/dist/step-persister.js"() {
33288
+ // ts/agent-core/dist/gateway/work-items.js
33289
+ var init_work_items = __esm({
33290
+ "ts/agent-core/dist/gateway/work-items.js"() {
32904
33291
  "use strict";
32905
- init_dist();
32906
- init_step_retry_queue();
33292
+ init_lane_flow();
33293
+ init_target();
32907
33294
  }
32908
33295
  });
32909
33296
 
32910
- // ts/agent-core/dist/session-lifecycle.js
32911
- var init_session_lifecycle = __esm({
32912
- "ts/agent-core/dist/session-lifecycle.js"() {
33297
+ // ts/agent-core/dist/gateway/catch-up.js
33298
+ var init_catch_up = __esm({
33299
+ "ts/agent-core/dist/gateway/catch-up.js"() {
32913
33300
  "use strict";
32914
33301
  }
32915
33302
  });
32916
33303
 
32917
- // ts/agent-core/dist/fork-session-finalizer.js
32918
- var init_fork_session_finalizer = __esm({
32919
- "ts/agent-core/dist/fork-session-finalizer.js"() {
33304
+ // ts/agent-core/dist/runtime-declaration.js
33305
+ var init_runtime_declaration = __esm({
33306
+ "ts/agent-core/dist/runtime-declaration.js"() {
32920
33307
  "use strict";
32921
33308
  }
32922
33309
  });
32923
33310
 
32924
- // ts/agent-core/dist/session-state.js
32925
- var init_session_state = __esm({
32926
- "ts/agent-core/dist/session-state.js"() {
33311
+ // ts/agent-core/dist/gateway/connection.js
33312
+ var init_connection = __esm({
33313
+ "ts/agent-core/dist/gateway/connection.js"() {
32927
33314
  "use strict";
33315
+ init_dist();
33316
+ init_runtime_declaration();
32928
33317
  }
32929
33318
  });
32930
33319
 
32931
- // ts/agent-core/dist/gateway-base.js
33320
+ // ts/agent-core/dist/gateway/base.js
32932
33321
  var AUTH_INVALID_EXIT_CODE;
32933
- var init_gateway_base = __esm({
32934
- "ts/agent-core/dist/gateway-base.js"() {
33322
+ var init_base = __esm({
33323
+ "ts/agent-core/dist/gateway/base.js"() {
32935
33324
  "use strict";
32936
- init_gateway_runtime_step();
32937
- init_dispatch_recovery();
33325
+ init_runtime_step();
33326
+ init_recovery();
32938
33327
  init_change_source();
32939
33328
  init_dist();
32940
33329
  init_fork_prefix();
32941
- init_fork_state();
32942
- init_gateway_lane_flow();
32943
- init_gateway_idle_compact();
32944
- init_gateway_runtime_turns();
32945
- init_gateway_drain();
32946
- init_gateway_session_binding();
32947
- init_lane_ledger();
32948
- init_runtime_declaration();
32949
- init_lane_target();
32950
- init_dispatch_inactivity_deadline();
32951
- init_routing();
33330
+ init_lane_flow();
33331
+ init_idle_compact();
33332
+ init_runtime_turns();
33333
+ init_drain();
33334
+ init_session_binding();
33335
+ init_ledger();
33336
+ init_target();
33337
+ init_inactivity_deadline();
32952
33338
  init_redact();
32953
33339
  init_step_persister();
32954
- init_session_lifecycle();
32955
- init_fork_session_finalizer();
32956
- init_session_state();
32957
- init_bridge_workspace();
33340
+ init_lifecycle();
33341
+ init_fork_finalizer();
32958
33342
  init_telemetry();
32959
- init_gateway_steer();
33343
+ init_steer();
33344
+ init_run_dispatch();
33345
+ init_fork_drain();
33346
+ init_main_drain();
33347
+ init_inbound();
33348
+ init_work_items();
33349
+ init_catch_up();
33350
+ init_connection();
33351
+ init_input_steps();
33352
+ init_input_steps();
32960
33353
  AUTH_INVALID_EXIT_CODE = 86;
32961
33354
  }
32962
33355
  });
@@ -58735,12 +59128,12 @@ var init_dist2 = __esm({
58735
59128
  init_dispatch_adapter();
58736
59129
  init_runtime_observation();
58737
59130
  init_fork_prefix();
58738
- init_gateway_base();
58739
- init_gateway_idle_compact();
58740
- init_gateway_lane_flow();
59131
+ init_base();
59132
+ init_idle_compact();
59133
+ init_lane_flow();
58741
59134
  init_http_keepalive();
58742
- init_lane_key();
58743
- init_lane_ledger();
59135
+ init_key();
59136
+ init_ledger();
58744
59137
  init_logger();
58745
59138
  init_platform_config();
58746
59139
  init_platform_instructions2();
@@ -58751,7 +59144,7 @@ var init_dist2 = __esm({
58751
59144
  init_runtime_instance();
58752
59145
  init_runtime_activity_port();
58753
59146
  init_runtime_turn_base();
58754
- init_session_state();
59147
+ init_state();
58755
59148
  init_skills();
58756
59149
  init_telemetry();
58757
59150
  init_types4();