dsh-edge 0.18.0 → 0.19.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +8 -8
  3. package/README.zh.md +8 -8
  4. package/THIRD_PARTY_NOTICES.md +2011 -449
  5. package/dist/assets/fonts/Montserrat-OFL.txt +93 -0
  6. package/dist/assets/fonts/montserrat-light-Cvd2VjE_.woff2 +0 -0
  7. package/dist/assets/fonts/montserrat-medium-B4OyO9CN.woff2 +0 -0
  8. package/dist/assets/fonts/montserrat-regular-DYep38cA.woff2 +0 -0
  9. package/dist/assets/index-Cq6ljTv2.css +1 -0
  10. package/dist/assets/index-Dy0OhsZ5.js +127 -0
  11. package/dist/assets/langs/asciidoc-Ve4PFQV2.js +2 -0
  12. package/dist/assets/langs/bat-BkioyH1T.js +2 -0
  13. package/dist/assets/langs/bibtex-CHM0blh-.js +2 -0
  14. package/dist/assets/langs/clojure-P80f7IUj.js +2 -0
  15. package/dist/assets/langs/cmake-D1j8_8rp.js +2 -0
  16. package/dist/assets/langs/csv-fuZLfV_i.js +2 -0
  17. package/dist/assets/langs/dart-bE4Kk8sk.js +2 -0
  18. package/dist/assets/langs/diff-D97Zzqfu.js +2 -0
  19. package/dist/assets/langs/dotenv-Da5cRb03.js +2 -0
  20. package/dist/assets/langs/elixir-CvYZzuDY.js +2 -0
  21. package/dist/assets/langs/erlang-DsQrWhSR.js +2 -0
  22. package/dist/assets/langs/fish-BvzEVeQv.js +2 -0
  23. package/dist/assets/langs/fsharp-CXgrBDvD.js +2 -0
  24. package/dist/assets/langs/graphql-DujV8YkJ.js +2 -0
  25. package/dist/assets/langs/groovy-gcz8RCvz.js +2 -0
  26. package/dist/assets/langs/haskell-Df6bDoY_.js +2 -0
  27. package/dist/assets/langs/hcl-BWvSN4gD.js +2 -0
  28. package/dist/assets/langs/html-derivative-DOyKdj44.js +2 -0
  29. package/dist/assets/langs/html-fwsONPVS.js +2 -0
  30. package/dist/assets/langs/http-DcV90OkR.js +2 -0
  31. package/dist/assets/langs/javascript-DI5JR1nB.js +2 -0
  32. package/dist/assets/langs/julia-BpJ6DjL_.js +2 -0
  33. package/dist/assets/langs/latex-B4C7GdlO.js +2 -0
  34. package/dist/assets/langs/log-2UxHyX5q.js +2 -0
  35. package/dist/assets/langs/make-CHLpvVh8.js +2 -0
  36. package/dist/assets/langs/nix-CwoSXNpI.js +2 -0
  37. package/dist/assets/langs/perl-DsWkoyyU.js +2 -0
  38. package/dist/assets/langs/php-LEPfNACG.js +2 -0
  39. package/dist/assets/langs/powershell-Dpen1YoG.js +2 -0
  40. package/dist/assets/langs/proto-C7zT0LnQ.js +2 -0
  41. package/dist/assets/langs/r-Dspwwk_N.js +2 -0
  42. package/dist/assets/langs/rst-BbocfKWr.js +2 -0
  43. package/dist/assets/langs/ruby-R292Iif0.js +2 -0
  44. package/dist/assets/langs/scala-C151Ov-r.js +2 -0
  45. package/dist/assets/langs/svelte-DNMY6jOf.js +2 -0
  46. package/dist/assets/langs/system-verilog-CnnmHF94.js +2 -0
  47. package/dist/assets/langs/vb-D17OF-Vu.js +2 -0
  48. package/dist/assets/langs/verilog-BQ8w6xss.js +2 -0
  49. package/dist/assets/langs/vue-Dq2x6432.js +2 -0
  50. package/dist/favicon-dark.svg +3 -0
  51. package/dist/favicon.svg +0 -5
  52. package/dist/index.html +5 -4
  53. package/dist/manifest.webmanifest +3 -4
  54. package/dist/plugins/@deepseek-ai/dsh-api-gateway/client.js +353 -101
  55. package/dist/plugins/@deepseek-ai/dsh-api-job-controller/client.js +367 -0
  56. package/dist/plugins/@deepseek-ai/dsh-api-remotes/client.js +7223 -3584
  57. package/dist/plugins/@deepseek-ai/dsh-api-session-controller/client.js +1107 -991
  58. package/dist/plugins/@deepseek-ai/dsh-api-workspace-controller/client.js +119 -6
  59. package/dist/plugins/@deepseek-ai/dsh-api-workspace-files/client.js +41 -35
  60. package/dist/plugins/@deepseek-ai/dsh-client-connection/client.js +354 -5279
  61. package/dist/plugins/@deepseek-ai/dsh-client-file-upload/client.js +10 -23
  62. package/dist/plugins/@deepseek-ai/dsh-client-locale/client.js +234 -80
  63. package/dist/plugins/@deepseek-ai/dsh-client-modules/client.js +554 -46
  64. package/dist/plugins/@deepseek-ai/dsh-client-shortcuts/client.js +2006 -0
  65. package/dist/plugins/@deepseek-ai/dsh-client-ui-agent-preset/client.js +1090 -914
  66. package/dist/plugins/@deepseek-ai/dsh-client-ui-approval/client.js +79 -6
  67. package/dist/plugins/@deepseek-ai/dsh-client-ui-attachment/client.js +126 -155
  68. package/dist/plugins/@deepseek-ai/dsh-client-ui-chat/client.js +5776 -1593
  69. package/dist/plugins/@deepseek-ai/dsh-client-ui-commands/client.js +375 -121
  70. package/dist/plugins/@deepseek-ai/dsh-client-ui-conversation/client.js +3524 -1923
  71. package/dist/plugins/@deepseek-ai/dsh-client-ui-deliverables/client.js +1615 -258
  72. package/dist/plugins/@deepseek-ai/dsh-client-ui-directory-picker-browse/client.js +9 -9
  73. package/dist/plugins/@deepseek-ai/dsh-client-ui-goal/client.js +25 -10
  74. package/dist/plugins/@deepseek-ai/dsh-client-ui-input-trigger/client.js +169 -24
  75. package/dist/plugins/@deepseek-ai/dsh-client-ui-jobs/client.js +413 -63
  76. package/dist/plugins/@deepseek-ai/dsh-client-ui-layout/client.js +131 -14
  77. package/dist/plugins/@deepseek-ai/dsh-client-ui-message-feedback/client.js +24 -22
  78. package/dist/plugins/@deepseek-ai/dsh-client-ui-model-selection/client.js +281 -128
  79. package/dist/plugins/@deepseek-ai/dsh-client-ui-open-in-app/client.js +674 -223
  80. package/dist/plugins/@deepseek-ai/dsh-client-ui-plan/client.js +596 -18
  81. package/dist/plugins/@deepseek-ai/dsh-client-ui-reference/client.js +92 -9
  82. package/dist/plugins/@deepseek-ai/dsh-client-ui-renderer/client.js +467 -59
  83. package/dist/plugins/@deepseek-ai/dsh-client-ui-session/client.js +231 -72
  84. package/dist/plugins/@deepseek-ai/dsh-client-ui-settings/client.js +281 -117
  85. package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-general/client.js +642 -122
  86. package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-models/client.js +1565 -438
  87. package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-plugin-inventory/client.js +201 -75
  88. package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-plugins/client.js +30 -1628
  89. package/dist/plugins/@deepseek-ai/dsh-client-ui-shortcuts/client.js +1163 -0
  90. package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar/client.js +165 -39
  91. package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-browser/client.js +1648 -0
  92. package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/client.js +5515 -25622
  93. package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-files/client.js +419 -118
  94. package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-right/client.js +5692 -260
  95. package/dist/plugins/@deepseek-ai/dsh-client-ui-skill/client.js +156 -41
  96. package/dist/plugins/@deepseek-ai/dsh-client-ui-subagent/client.js +386 -263
  97. package/dist/plugins/@deepseek-ai/dsh-client-ui-theme/client.js +183 -73
  98. package/dist/plugins/@deepseek-ai/dsh-client-ui-tool/client.js +2367 -429
  99. package/dist/plugins/@deepseek-ai/dsh-client-ui-trajectory/client.js +788 -270
  100. package/dist/plugins/@deepseek-ai/dsh-client-ui-user-questions/client.js +87 -79
  101. package/dist/plugins/@deepseek-ai/dsh-client-ui-workflow-run/client.js +28 -14
  102. package/dist/plugins/@deepseek-ai/dsh-client-ui-workspace/client.js +2647 -1044
  103. package/dist/plugins/@deepseek-ai/dsh-typert-registry/client.js +22 -7
  104. package/dist/plugins/dsh-edge-client-ui/client.js +1 -10
  105. package/package.json +96 -86
  106. package/scripts/cli.mjs +16 -4
  107. package/scripts/install.d.mts +12 -2
  108. package/scripts/install.mjs +36 -9
  109. package/scripts/legal-files.mjs +15 -0
  110. package/worker/direct/index.js +2564 -1822
  111. package/worker/isolated/index.js +2144 -1402
  112. package/dist/assets/index-BKQ_L1z6.js +0 -117
  113. package/dist/assets/index-DPX2bQLO.css +0 -1
  114. package/dist/assets/langs/html-CfGypltT.js +0 -2
  115. package/dist/assets/langs/php-DJl5gRdb.js +0 -2
  116. package/dist/assets/langs/ruby-5eNB0pDK.js +0 -2
  117. package/dist/plugins/@deepseek-ai/dsh-client-ui-permission-presets/client.js +0 -505
  118. package/dist/plugins/@deepseek-ai/dsh-client-ui-schedule/client.js +0 -307
@@ -42,6 +42,63 @@ window.__ModuleLoader__.load({
42
42
  function remoteErrorOf(value) {
43
43
  if (typeof value === "object" && value !== null && value.isDSHRemoteError === true && typeof value.code === "string") return value;
44
44
  }
45
+ /** Generic invocation-owned values returned by synchronous Client Context resolvers. */
46
+ /** Shared identity across independently bundled Context providers and Gateway. */
47
+ const TYPERT_OWNED_VALUE = Symbol.for("dsh.typert.owned-value");
48
+ /**
49
+ * Identify invocation-owned values using the shared marker.
50
+ * @param value - borrowed or owned resolver result.
51
+ * @returns whether the result carries invocation cleanup.
52
+ */
53
+ function isTypertOwnedValue(value) {
54
+ return typeof value === "object" && value !== null && TYPERT_OWNED_VALUE in value && value[TYPERT_OWNED_VALUE] === true;
55
+ }
56
+ /**
57
+ * Lossless JSON checks every Remote carrier shares: the Client handle before it
58
+ * queues an uplink item, the Gateway at its wire and codec-less uplink
59
+ * boundaries, and the in-process mock.
60
+ */
61
+ /**
62
+ * Test whether a value crosses JSON transport without coercion or omission.
63
+ * @param value - candidate boundary value.
64
+ * @returns whether the value is losslessly JSON-compatible.
65
+ */
66
+ function isRemoteJsonValue(value) {
67
+ return visitJsonValue(value, /* @__PURE__ */ new Set());
68
+ }
69
+ /**
70
+ * Test whether a value may travel as one uplink item: a lossless JSON value, or
71
+ * a top-level `undefined`, which the wire carries as an `item` frame without
72
+ * `value`. Nested `undefined`, `NaN`, and infinities stay rejected.
73
+ * @param value - candidate uplink item.
74
+ * @returns whether the item crosses every carrier unchanged.
75
+ */
76
+ function isRemoteUplinkItem(value) {
77
+ return value === void 0 || isRemoteJsonValue(value);
78
+ }
79
+ function visitJsonValue(value, ancestors) {
80
+ if (value === null || typeof value === "string" || typeof value === "boolean") return true;
81
+ if (typeof value === "number") return Number.isFinite(value) && !Object.is(value, -0);
82
+ if (typeof value !== "object") return false;
83
+ if (ancestors.has(value)) return false;
84
+ ancestors.add(value);
85
+ try {
86
+ if (Array.isArray(value)) {
87
+ if (Object.getPrototypeOf(value) !== Array.prototype || Reflect.ownKeys(value).length !== value.length + 1) return false;
88
+ for (let index = 0; index < value.length; index++) if (!Object.hasOwn(value, index) || !visitJsonValue(value[index], ancestors)) return false;
89
+ return true;
90
+ }
91
+ const prototype = Object.getPrototypeOf(value);
92
+ if (prototype !== Object.prototype && prototype !== null) return false;
93
+ for (const key of Reflect.ownKeys(value)) {
94
+ if (typeof key !== "string") return false;
95
+ if (Object.getOwnPropertyDescriptor(value, key)?.enumerable !== true || !visitJsonValue(Reflect.get(value, key), ancestors)) return false;
96
+ }
97
+ return true;
98
+ } finally {
99
+ ancestors.delete(value);
100
+ }
101
+ }
45
102
  //#endregion
46
103
  //#region lib/types/stream-protocol.js
47
104
  /** Wire messages for Gateway-owned Remote streams and event-result RPCs. */
@@ -72,14 +129,6 @@ window.__ModuleLoader__.load({
72
129
  };
73
130
  }
74
131
  /**
75
- * Test whether a value crosses JSON transport without coercion or omission.
76
- * @param value - candidate boundary value.
77
- * @returns whether the value is losslessly JSON-compatible.
78
- */
79
- function isRemoteJsonValue(value) {
80
- return visitJsonValue(value, /* @__PURE__ */ new Set());
81
- }
82
- /**
83
132
  * Recognize a non-empty Remote Event correlation id at a wire boundary.
84
133
  * @param value - untrusted wire value.
85
134
  * @returns whether the value is a valid Remote Event id.
@@ -152,29 +201,6 @@ window.__ModuleLoader__.load({
152
201
  const candidate = Reflect.get(value, key);
153
202
  return typeof candidate === "string" ? candidate : void 0;
154
203
  }
155
- function visitJsonValue(value, ancestors) {
156
- if (value === null || typeof value === "string" || typeof value === "boolean") return true;
157
- if (typeof value === "number") return Number.isFinite(value) && !Object.is(value, -0);
158
- if (typeof value !== "object") return false;
159
- if (ancestors.has(value)) return false;
160
- ancestors.add(value);
161
- try {
162
- if (Array.isArray(value)) {
163
- if (Object.getPrototypeOf(value) !== Array.prototype || Reflect.ownKeys(value).length !== value.length + 1) return false;
164
- for (let index = 0; index < value.length; index++) if (!Object.hasOwn(value, index) || !visitJsonValue(value[index], ancestors)) return false;
165
- return true;
166
- }
167
- const prototype = Object.getPrototypeOf(value);
168
- if (prototype !== Object.prototype && prototype !== null) return false;
169
- for (const key of Reflect.ownKeys(value)) {
170
- if (typeof key !== "string") return false;
171
- if (Object.getOwnPropertyDescriptor(value, key)?.enumerable !== true || !visitJsonValue(Reflect.get(value, key), ancestors)) return false;
172
- }
173
- return true;
174
- } finally {
175
- ancestors.delete(value);
176
- }
177
- }
178
204
  //#endregion
179
205
  //#region ../../util/deque/lib/index.js
180
206
  /**
@@ -276,7 +302,6 @@ window.__ModuleLoader__.load({
276
302
  //#endregion
277
303
  //#region lib/types/client/stream-client.js
278
304
  /** Browser owner for the Gateway multiplexed Remote stream socket. */
279
- const INTERNAL_BASE = "http://dsh.internal";
280
305
  /** Physical Remote stream socket failure that may be retried by a domain transport. */
281
306
  var RemoteStreamCarrierError = class extends Error {
282
307
  /**
@@ -288,7 +313,15 @@ window.__ModuleLoader__.load({
288
313
  this.name = "RemoteStreamCarrierError";
289
314
  }
290
315
  };
291
- /** Keep one physical WebSocket and share it among independently cancellable Remote streams. */
316
+ const UPLINK_DONE = {
317
+ value: void 0,
318
+ done: true
319
+ };
320
+ /**
321
+ * Keep one physical WebSocket and share it among independently cancellable
322
+ * Remote streams. A carrier that supplies an in-process stream opener never
323
+ * starts one.
324
+ */
292
325
  var RemoteStreamMuxClient = class {
293
326
  socket;
294
327
  cancelCandidate;
@@ -334,12 +367,18 @@ window.__ModuleLoader__.load({
334
367
  * @param endpoint - Typert Remote stream endpoint.
335
368
  * @param payload - endpoint request encoded on the wire.
336
369
  * @param signal - cancellation for this logical stream.
370
+ * @param uplink - the Client's items: each is sent as an `item` frame, its end as `end`; its `return()`
371
+ * runs when the stream finishes, and its failure cancels the stream and fails the downlink.
337
372
  * @returns Host items until completion, cancellation, or failure.
338
373
  */
339
- async *open(endpoint, payload, signal) {
374
+ async *open(endpoint, payload, signal, uplink) {
340
375
  signal.throwIfAborted();
341
376
  const streamId = randomUUID();
342
377
  const inbox = new StreamInbox();
378
+ const stream = {
379
+ inbox,
380
+ pump: void 0
381
+ };
343
382
  let carrier;
344
383
  let opened = false;
345
384
  let terminal = false;
@@ -351,7 +390,7 @@ window.__ModuleLoader__.load({
351
390
  const socket = await this.waitForSocket(signal);
352
391
  signal.throwIfAborted();
353
392
  carrier = socket;
354
- this.streams.set(streamId, inbox);
393
+ this.streams.set(streamId, stream);
355
394
  this.send(socket, {
356
395
  type: "open",
357
396
  streamId,
@@ -359,6 +398,7 @@ window.__ModuleLoader__.load({
359
398
  payload
360
399
  });
361
400
  opened = true;
401
+ if (uplink !== void 0) stream.pump = this.pumpUplink(socket, streamId, uplink, signal, inbox);
362
402
  while (true) {
363
403
  const frame = await inbox.next();
364
404
  signal.throwIfAborted();
@@ -373,13 +413,78 @@ window.__ModuleLoader__.load({
373
413
  } finally {
374
414
  signal.removeEventListener("abort", abort);
375
415
  this.streams.delete(streamId);
416
+ stream.pump?.stop();
376
417
  if (opened && !terminal && carrier?.readyState === WebSocket.OPEN) this.send(carrier, {
377
418
  type: "cancel",
378
419
  streamId
379
420
  });
421
+ if (stream.pump !== void 0) await stream.pump.done;
380
422
  }
381
423
  }
382
424
  /**
425
+ * Send the caller's uplink items on this generation's socket. `stop()`
426
+ * interrupts a pump blocked on `uplink.next()` and releases the iterator: a
427
+ * handle's queue closes at once, so `send()` throws from then on, and any
428
+ * other iterator's `return()` is invoked without being awaited because a
429
+ * generator blocked in `next()` only completes it once it yields.
430
+ */
431
+ pumpUplink(socket, streamId, uplink, signal, inbox) {
432
+ let stopped;
433
+ const interruption = {
434
+ value: void 0,
435
+ done: true
436
+ };
437
+ const uplinkIterator = uplink[Symbol.asyncIterator]();
438
+ const state = {
439
+ stopping: false,
440
+ exhausted: false,
441
+ released: false
442
+ };
443
+ const release = () => {
444
+ if (state.released || state.exhausted) return;
445
+ state.released = true;
446
+ if (uplink instanceof ClientUplinkQueue) uplink.close();
447
+ Promise.resolve().then(() => uplinkIterator.return?.()).catch(() => void 0);
448
+ };
449
+ return {
450
+ done: (async () => {
451
+ try {
452
+ while (true) {
453
+ if (state.stopping) return;
454
+ stopped = Promise.withResolvers();
455
+ const next = await Promise.race([uplinkIterator.next(), stopped.promise]);
456
+ stopped = void 0;
457
+ if (state.stopping || next === interruption || signal.aborted || this.socket !== socket) return;
458
+ if (next.done === true) {
459
+ state.exhausted = true;
460
+ break;
461
+ }
462
+ this.send(socket, {
463
+ type: "item",
464
+ streamId,
465
+ value: next.value
466
+ });
467
+ }
468
+ this.send(socket, {
469
+ type: "end",
470
+ streamId
471
+ });
472
+ } catch (error) {
473
+ inbox.fail(error);
474
+ } finally {
475
+ stopped = void 0;
476
+ release();
477
+ }
478
+ })(),
479
+ stop: () => {
480
+ if (state.stopping) return;
481
+ state.stopping = true;
482
+ stopped?.resolve(interruption);
483
+ release();
484
+ }
485
+ };
486
+ }
487
+ /**
383
488
  * Permanently stop the carrier, close the physical socket, and fail every
384
489
  * active logical stream.
385
490
  * @returns once the active connection attempt has stopped.
@@ -478,7 +583,10 @@ window.__ModuleLoader__.load({
478
583
  try {
479
584
  if (typeof data !== "string") throw new Error("api gateway: Remote stream WebSocket requires text messages");
480
585
  const frame = parseRemoteStreamServerMessage(data);
481
- this.streams.get(frame.streamId)?.push(frame);
586
+ const stream = this.streams.get(frame.streamId);
587
+ if (stream === void 0) return;
588
+ stream.inbox.push(frame);
589
+ if (frame.type !== "item") stream.pump?.stop();
482
590
  } catch (error) {
483
591
  const failure = new RemoteStreamCarrierError("api gateway: invalid Remote stream frame", { cause: error });
484
592
  this.failAll(failure);
@@ -505,7 +613,10 @@ window.__ModuleLoader__.load({
505
613
  });
506
614
  }
507
615
  failAll(error) {
508
- for (const stream of this.streams.values()) stream.fail(error);
616
+ for (const stream of this.streams.values()) {
617
+ stream.inbox.fail(error);
618
+ stream.pump?.stop();
619
+ }
509
620
  }
510
621
  send(socket, message) {
511
622
  socket.send(JSON.stringify(message));
@@ -538,10 +649,85 @@ window.__ModuleLoader__.load({
538
649
  return this.frames.popFront();
539
650
  }
540
651
  };
652
+ /**
653
+ * Uplink items a stream handle queues for its carrier: the mux pump or the
654
+ * in-process Host decoder iterates it as the stream's uplink. `end()` is the
655
+ * Client half-close; `close()` marks the stream terminated, after which
656
+ * `push()` throws. One consumer reads it, one read at a time.
657
+ */
658
+ var ClientUplinkQueue = class {
659
+ endpoint;
660
+ items = new Deque();
661
+ ended = false;
662
+ closed = false;
663
+ wake;
664
+ /** @param endpoint - canonical Remote endpoint named by failures. */
665
+ constructor(endpoint) {
666
+ this.endpoint = endpoint;
667
+ }
668
+ /**
669
+ * Queue one item for the carrier.
670
+ * @param item - item the Host validates against the method's uplink codec.
671
+ * @throws {Error} after `end()` or once the stream has terminated.
672
+ */
673
+ push(item) {
674
+ if (this.closed) throw new Error(`client api: ${this.endpoint} stream has terminated`);
675
+ if (this.ended) throw new Error(`client api: ${this.endpoint} uplink was ended`);
676
+ this.items.pushBack(item);
677
+ this.signal();
678
+ }
679
+ /** Half-close: the carrier reads the queued items, then `end`. Idempotent; ignored after termination. */
680
+ end() {
681
+ if (this.ended || this.closed) return;
682
+ this.ended = true;
683
+ this.signal();
684
+ }
685
+ /** The carrier stopped reading: the logical stream terminated or was disposed. Idempotent. */
686
+ close() {
687
+ if (this.closed) return;
688
+ this.closed = true;
689
+ this.items.clear();
690
+ this.signal();
691
+ }
692
+ [Symbol.asyncIterator]() {
693
+ return this;
694
+ }
695
+ /**
696
+ * Take the next queued item, waiting for one; ends after `end()` or `close()`.
697
+ * @returns the next item, or the end of the uplink.
698
+ * @throws {Error} when a read is already pending.
699
+ */
700
+ async next() {
701
+ while (true) {
702
+ if (this.closed) return UPLINK_DONE;
703
+ if (this.items.size > 0) return {
704
+ value: this.items.popFront(),
705
+ done: false
706
+ };
707
+ if (this.ended) return UPLINK_DONE;
708
+ if (this.wake !== void 0) throw new Error(`client api: ${this.endpoint} uplink has one pending read`);
709
+ await new Promise((resolve) => {
710
+ this.wake = resolve;
711
+ });
712
+ }
713
+ }
714
+ /**
715
+ * The carrier is done with the uplink: close it.
716
+ * @returns the end of the uplink.
717
+ */
718
+ return() {
719
+ this.close();
720
+ return Promise.resolve(UPLINK_DONE);
721
+ }
722
+ signal() {
723
+ const wake = this.wake;
724
+ this.wake = void 0;
725
+ wake?.();
726
+ }
727
+ };
541
728
  function remoteStreamUrl() {
542
- const location = globalThis.location;
543
- const base = location?.origin !== void 0 && location.origin !== "null" ? location.origin : INTERNAL_BASE;
544
- const url = new URL(REMOTE_STREAM_MUX_PATH, base);
729
+ const globals = globalThis;
730
+ const url = new URL(REMOTE_STREAM_MUX_PATH.slice(1), globals.__DSH_TRANSPORT__?.streamBaseUrl ?? document.baseURI);
545
731
  url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
546
732
  return url.href;
547
733
  }
@@ -653,30 +839,36 @@ window.__ModuleLoader__.load({
653
839
  }
654
840
  async answer(frame, clientId, signal) {
655
841
  const adapter = this.ownerCtx.typert.contexts.getClient("agent");
656
- let target;
842
+ let resolved;
657
843
  try {
658
- target = adapter?.resolve(frame.agentId);
844
+ resolved = adapter?.resolve(frame.agentId);
659
845
  } catch (error) {
660
846
  this.reportError(frame.event, error);
661
847
  }
662
- let outcome = { kind: "next" };
663
- if (target !== void 0) try {
664
- outcome = await this.dispatchWaterfall(target, frame, signal);
665
- } catch (error) {
848
+ const owned = isTypertOwnedValue(resolved) ? resolved : void 0;
849
+ try {
850
+ const target = isTypertOwnedValue(resolved) ? resolved.value : resolved;
851
+ let outcome = { kind: "next" };
852
+ if (target !== void 0) try {
853
+ outcome = await this.dispatchWaterfall(target, frame, signal);
854
+ } catch (error) {
855
+ if (signal.aborted) return;
856
+ outcome = {
857
+ kind: "rejected",
858
+ error: projectRemoteEventRejection(error)
859
+ };
860
+ }
666
861
  if (signal.aborted) return;
667
- outcome = {
668
- kind: "rejected",
669
- error: projectRemoteEventRejection(error)
862
+ const result = {
863
+ clientId,
864
+ eventId: frame.eventId,
865
+ outcome: outcome.kind === "result" && outcome.value === void 0 ? { kind: "result" } : outcome
670
866
  };
867
+ const response = await this.connection.rpc.call("/api", REMOTE_EVENT_RESULT_ENDPOINT, { args: result }, signal);
868
+ if (!response.ok) throw new Error(response.error.message);
869
+ } finally {
870
+ owned?.[Symbol.dispose]();
671
871
  }
672
- if (signal.aborted) return;
673
- const result = {
674
- clientId,
675
- eventId: frame.eventId,
676
- outcome: outcome.kind === "result" && outcome.value === void 0 ? { kind: "result" } : outcome
677
- };
678
- const response = await this.connection.rpc.call("/api", REMOTE_EVENT_RESULT_ENDPOINT, { args: result }, signal);
679
- if (!response.ok) throw new Error(response.error.message);
680
872
  }
681
873
  async dispatchWaterfall(target, frame, signal) {
682
874
  const request = {
@@ -684,7 +876,7 @@ window.__ModuleLoader__.load({
684
876
  agent: target,
685
877
  signal
686
878
  };
687
- const value = await abortable(Promise.resolve(privateEvents(target).waterfall(target, this.eventKey(frame.event), request, () => Promise.resolve(REMOTE_EVENT_NEXT))), signal);
879
+ const value = await privateEvents(target).waterfall(target, this.eventKey(frame.event), request, () => Promise.resolve(REMOTE_EVENT_NEXT));
688
880
  if (value !== REMOTE_EVENT_NEXT && value !== void 0 && !isRemoteJsonValue(value)) throw new TypeError("Remote event listener result is not lossless JSON data");
689
881
  return value === REMOTE_EVENT_NEXT ? { kind: "next" } : {
690
882
  kind: "result",
@@ -755,23 +947,6 @@ window.__ModuleLoader__.load({
755
947
  function invalidRemoteEventFrame() {
756
948
  throw new TypeError("client api: invalid forwarded Remote event frame");
757
949
  }
758
- /** Race listener completion against its delivery lifetime. */
759
- async function abortable(value, signal) {
760
- signal.throwIfAborted();
761
- let rejectAbort;
762
- const aborted = new Promise((_resolve, reject) => {
763
- rejectAbort = reject;
764
- });
765
- const onAbort = () => {
766
- rejectAbort?.(signal.reason);
767
- };
768
- signal.addEventListener("abort", onAbort, { once: true });
769
- try {
770
- return await Promise.race([Promise.resolve(value), aborted]);
771
- } finally {
772
- signal.removeEventListener("abort", onAbort);
773
- }
774
- }
775
950
  function privateEvents(ctx) {
776
951
  return ctx;
777
952
  }
@@ -1473,11 +1648,11 @@ window.__ModuleLoader__.load({
1473
1648
  return this.events.subscribe(this.ctx, event, listener);
1474
1649
  }
1475
1650
  /** Open one Remote stream and normalize a worker-local carrier's structural failures. */
1476
- openRemoteStream(endpoint, payload, signal, noConnection = `client api: ${endpoint} has no active Connection`) {
1651
+ openRemoteStream(endpoint, payload, signal, uplink, noConnection = `client api: ${endpoint} has no active Connection`) {
1477
1652
  const connection = this.ownerCtx.get("connection");
1478
1653
  if (connection === void 0) throw new Error(noConnection);
1479
- const local = connection.rpc.open?.("/api", endpoint, payload, signal);
1480
- return local === void 0 ? this.streams.open(endpoint, payload, signal) : normalizeConnectionStream(local);
1654
+ const local = connection.rpc.open?.("/api", endpoint, payload, signal, uplink);
1655
+ return local === void 0 ? this.streams.open(endpoint, payload, signal, uplink) : normalizeConnectionStream(local);
1481
1656
  }
1482
1657
  enqueue(operation) {
1483
1658
  const result = this.mutations.then(operation, operation);
@@ -1517,7 +1692,7 @@ window.__ModuleLoader__.load({
1517
1692
  if ((this.namespaces.get(descriptor.namespace)?.service)?.has(kind, descriptor.method) === true) throw new Error(`client api: ${kind} method ${endpointOf(descriptor)} is already mounted`);
1518
1693
  };
1519
1694
  for (const descriptor of contribution.descriptors) {
1520
- requireStrictDescriptor(descriptor);
1695
+ requireStrictInputs(descriptor);
1521
1696
  if (descriptor.invocation.kind === "direct") add(direct, descriptor, "direct");
1522
1697
  if (scopedProjection(descriptor) !== void 0) add(scoped, descriptor, "scoped");
1523
1698
  }
@@ -1604,7 +1779,7 @@ window.__ModuleLoader__.load({
1604
1779
  throw new Error("client api: Remote method is no longer mounted");
1605
1780
  }
1606
1781
  invokeSelected(descriptor, projection, token, callerCtx, values, boundIdentity) {
1607
- if (descriptor.mode === "stream") return this.invokeStream(descriptor, projection, token, callerCtx, values, boundIdentity);
1782
+ if (descriptor.mode !== void 0) return this.invokeStream(descriptor, projection, token, callerCtx, values, boundIdentity);
1608
1783
  return this.invoke(descriptor, projection, token, callerCtx, values, boundIdentity);
1609
1784
  }
1610
1785
  async invoke(descriptor, projection, token, callerCtx, values, boundIdentity) {
@@ -1616,28 +1791,28 @@ window.__ModuleLoader__.load({
1616
1791
  try {
1617
1792
  const result = await connection.rpc.call("/api", endpoint, { args: prepared.args }, prepared.signal);
1618
1793
  if (!mountActive(token)) return withdrawn(endpoint);
1794
+ prepared.signal.throwIfAborted();
1619
1795
  if (!result.ok) return {
1620
1796
  ok: false,
1621
1797
  error: rebuiltFailure(result.error)
1622
1798
  };
1623
1799
  return {
1624
1800
  ok: true,
1625
- value: result.value
1801
+ value: descriptor.result.mode === "strict" && descriptor.result.decode !== void 0 ? descriptor.result.decode(result.value) : result.value
1626
1802
  };
1627
1803
  } catch (error) {
1628
1804
  if (prepared.signal.aborted) return cancelledFailure(endpoint, error);
1629
1805
  return carrierFailure(endpoint, error);
1630
1806
  }
1631
1807
  }
1632
- async *invokeStream(descriptor, projection, token, callerCtx, values, boundIdentity) {
1808
+ /** Open the logical stream now and hand back its handle; `send()` before the first read queues behind the `open` frame. */
1809
+ invokeStream(descriptor, projection, token, callerCtx, values, boundIdentity) {
1633
1810
  const endpoint = endpointOf(descriptor);
1634
1811
  if (!token.active) throw new Error(withdrawn(endpoint).error.message);
1635
1812
  const prepared = this.prepareInvocation(descriptor, projection, token, callerCtx, values, boundIdentity);
1636
- const stream = this.openRemoteStream(endpoint, { args: prepared.args }, prepared.signal);
1637
- for await (const value of stream) {
1638
- if (!mountActive(token)) throw new Error(withdrawn(endpoint).error.message);
1639
- yield value;
1640
- }
1813
+ const generation = new AbortController();
1814
+ const uplink = new ClientUplinkQueue(endpoint);
1815
+ return new ClientStreamHandle(endpoint, this.openRemoteStream(endpoint, { args: prepared.args }, AbortSignal.any([prepared.signal, generation.signal]), uplink), uplink, generation, token);
1641
1816
  }
1642
1817
  prepareInvocation(descriptor, projection, token, callerCtx, values, boundIdentity) {
1643
1818
  const endpoint = endpointOf(descriptor);
@@ -1653,12 +1828,12 @@ window.__ModuleLoader__.load({
1653
1828
  if (boundIdentity === void 0 && adapter === void 0) throw new Error(`client api: ${endpoint} has no Client Context adapter for ${JSON.stringify(projection.context)}`);
1654
1829
  const identity = boundIdentity === void 0 ? adapter?.identity(callerCtx) : boundIdentity.value;
1655
1830
  if (identity === void 0) throw new Error(`client api: ${endpoint} requires a ${JSON.stringify(projection.context)} Context`);
1656
- args[projection.wire] = parseInput(projection.codec, identity, endpoint, projection.wire);
1831
+ args[projection.wire] = identity;
1657
1832
  }
1658
1833
  let valueIndex = 0;
1659
1834
  descriptor.parameters.forEach((parameter, parameterIndex) => {
1660
1835
  if (parameterIndex === projection?.parameterIndex) return;
1661
- const value = parseInput(parameter.codec, values[valueIndex], endpoint, parameter.wire);
1836
+ const value = values[valueIndex];
1662
1837
  if (value !== void 0) args[parameter.wire] = value;
1663
1838
  valueIndex += 1;
1664
1839
  });
@@ -1670,6 +1845,77 @@ window.__ModuleLoader__.load({
1670
1845
  };
1671
1846
  }
1672
1847
  };
1848
+ /**
1849
+ * The handle a generated stream method returns: one generation of one logical
1850
+ * stream. The downlink is iterated once; `send`/`end` feed the uplink queue the
1851
+ * carrier pump drains; `dispose` aborts the generation and returns the carrier
1852
+ * iterator, which sends `cancel` unless a terminal frame arrived, drops what was
1853
+ * buffered, and ends the iteration quietly.
1854
+ */
1855
+ var ClientStreamHandle = class {
1856
+ endpoint;
1857
+ uplink;
1858
+ generation;
1859
+ token;
1860
+ downlink;
1861
+ primed;
1862
+ consumed = false;
1863
+ disposed = false;
1864
+ constructor(endpoint, downlink, uplink, generation, token) {
1865
+ this.endpoint = endpoint;
1866
+ this.uplink = uplink;
1867
+ this.generation = generation;
1868
+ this.token = token;
1869
+ this.downlink = downlink[Symbol.asyncIterator]();
1870
+ this.primed = this.downlink.next();
1871
+ this.primed.catch(() => {
1872
+ this.uplink.close();
1873
+ });
1874
+ }
1875
+ send(item) {
1876
+ if (!isRemoteUplinkItem(item)) throw new Error(`client api: ${this.endpoint} uplink item is not a lossless JSON value`);
1877
+ this.uplink.push(item);
1878
+ }
1879
+ end() {
1880
+ this.uplink.end();
1881
+ }
1882
+ dispose() {
1883
+ if (this.disposed) return;
1884
+ this.disposed = true;
1885
+ this.uplink.close();
1886
+ this.generation.abort(/* @__PURE__ */ new Error(`client api: ${this.endpoint} stream disposed`));
1887
+ Promise.resolve(this.downlink.return?.()).catch(() => void 0);
1888
+ }
1889
+ [Symbol.asyncIterator]() {
1890
+ if (this.consumed) throw new Error(`client api: ${this.endpoint} stream has one consumer`);
1891
+ this.consumed = true;
1892
+ const iteration = this.iterate();
1893
+ return {
1894
+ next: () => iteration.next(),
1895
+ return: (value) => {
1896
+ this.dispose();
1897
+ return iteration.return(value);
1898
+ }
1899
+ };
1900
+ }
1901
+ async *iterate() {
1902
+ try {
1903
+ while (true) {
1904
+ const next = await (this.primed ?? this.downlink.next());
1905
+ this.primed = void 0;
1906
+ if (this.disposed || next.done === true) return;
1907
+ if (!mountActive(this.token)) throw new Error(withdrawn(this.endpoint).error.message);
1908
+ yield next.value;
1909
+ }
1910
+ } catch (error) {
1911
+ if (this.disposed) return;
1912
+ throw error;
1913
+ } finally {
1914
+ this.dispose();
1915
+ await this.downlink.return?.();
1916
+ }
1917
+ }
1918
+ };
1673
1919
  var RemoteNamespaceService = class RemoteNamespaceService extends _deepseek_ai_cordis.Service {
1674
1920
  invokeRemote;
1675
1921
  methods = /* @__PURE__ */ new Map();
@@ -1803,8 +2049,7 @@ window.__ModuleLoader__.load({
1803
2049
  function scopedProjection(descriptor) {
1804
2050
  if (descriptor.invocation.kind === "context") return {
1805
2051
  context: descriptor.invocation.context,
1806
- wire: descriptor.invocation.wire,
1807
- codec: descriptor.invocation.codec
2052
+ wire: descriptor.invocation.wire
1808
2053
  };
1809
2054
  if (descriptor.scope === void 0) return void 0;
1810
2055
  const lookupParameters = descriptor.parameters.map((parameter, index) => ({
@@ -1816,33 +2061,38 @@ window.__ModuleLoader__.load({
1816
2061
  return {
1817
2062
  context: descriptor.scope.context,
1818
2063
  wire: descriptor.scope.wire,
1819
- codec: selected.parameter.codec,
1820
2064
  parameterIndex: selected.index
1821
2065
  };
1822
2066
  }
1823
- function requireStrictDescriptor(descriptor) {
2067
+ function requireStrictInputs(descriptor) {
1824
2068
  const endpoint = endpointOf(descriptor);
1825
2069
  for (const parameter of descriptor.parameters) requireStrictCodec(parameter.codec, endpoint, parameter.wire);
2070
+ if (descriptor.uplink !== void 0) requireStrictCodec(descriptor.uplink.codec, endpoint, "uplink");
1826
2071
  if (descriptor.invocation.kind === "context") requireStrictCodec(descriptor.invocation.codec, endpoint, descriptor.invocation.wire);
1827
2072
  }
1828
2073
  function requireStrictCodec(codec, endpoint, field) {
1829
2074
  if (codec.mode !== "strict") throw new Error(`client api: generated Remote ${endpoint} field ${JSON.stringify(field)} has no strict codec`);
1830
2075
  }
1831
- function parseInput(codec, value, endpoint, field) {
1832
- if (codec.mode !== "strict") throw new Error(`client api: generated Remote ${endpoint} field ${JSON.stringify(field)} has no strict codec`);
1833
- try {
1834
- return codec.schema.parse(value);
1835
- } catch (cause) {
1836
- throw new Error(`client api: ${endpoint} rejected ${JSON.stringify(field)}`, { cause });
1837
- }
1838
- }
1839
2076
  /** The namespace retired before or during the call, so no request outcome exists. */
1840
2077
  function withdrawn(endpoint) {
1841
2078
  return internalFailure(`client api: Remote method ${endpoint} is no longer mounted`);
1842
2079
  }
2080
+ /**
2081
+ * The error branch a carrier throw (offline, transport fault) folds into: `gateway/internal` naming the endpoint and
2082
+ * the thrown message. Exported so a stand-in for this face folds identically.
2083
+ * @param endpoint - `<namespace>/<method>` that was called.
2084
+ * @param error - what the carrier threw.
2085
+ * @returns the failed result.
2086
+ */
1843
2087
  function carrierFailure(endpoint, error) {
1844
2088
  return internalFailure(`client api: ${endpoint} failed: ${error instanceof Error ? error.message : String(error)}`);
1845
2089
  }
2090
+ /**
2091
+ * The error branch a call aborted by its caller folds into: `gateway/cancelled` with the carrier's throw as `cause`.
2092
+ * @param endpoint - `<namespace>/<method>` that was called.
2093
+ * @param cause - what the carrier threw when the signal aborted.
2094
+ * @returns the failed result.
2095
+ */
1846
2096
  function cancelledFailure(endpoint, cause) {
1847
2097
  return {
1848
2098
  ok: false,
@@ -1892,6 +2142,8 @@ window.__ModuleLoader__.load({
1892
2142
  exports.RemoteStream = RemoteStream;
1893
2143
  exports.RemoteStreamCarrierError = RemoteStreamCarrierError;
1894
2144
  exports.apply = apply;
2145
+ exports.cancelledFailure = cancelledFailure;
2146
+ exports.carrierFailure = carrierFailure;
1895
2147
  exports.inject = inject;
1896
2148
  exports.isRemoteFailure = isRemoteFailure;
1897
2149
  return module.exports;