@deepseek-ai/dsh-client-connection 0.1.2-alpha.2 → 0.1.2-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/client/connection/README.md
5
- README.md: ee0566bf811a0bad32f7d59b4c8849e26efea613
6
- README.zh.md: 48425a428247b7749bf0dd75f592b5f7e4088ef2
5
+ README.md: 54acac0ed815ea24a4a30a80d0b13eb6ceda6b47
6
+ README.zh.md: 46c7d0b20e3b7a27db963866949d01f1ee96781a
package/README.md CHANGED
@@ -72,3 +72,5 @@ None; this package neither assembles nor sends a provider request.
72
72
  None.
73
73
 
74
74
  </details>
75
+
76
+ **Runtime invariant:** No companion is published. Browser-session verification reads the credential record asynchronously at the request that authorizes work, while the credentials companion owns record commit-event lifetime. Stream/reconnect sequencing and rpcId round-trip discipline are exercised directly by behavior specs, and route register/dispose symmetry is audited by the webserver companion.
package/README.zh.md CHANGED
@@ -72,3 +72,5 @@ API Gateway Client 把内部 `$events` logical stream 注册为唯一 generation
72
72
  无。
73
73
 
74
74
  </details>
75
+
76
+ **运行时不变式:** 不发布伴生入口。授权请求会异步读取 credential 权威记录,commit-event 生命周期由 credentials 伴生入口负责;流、重连、rpcId 与路由释放关系由行为测试及 webserver 不变式覆盖。
package/lib/client.js CHANGED
@@ -205,9 +205,7 @@ window.__ModuleLoader__.load({
205
205
  if (this.isGenerationActive(ac)) this.callSink(() => {
206
206
  this.sinks.onConnected?.(host);
207
207
  });
208
- } catch {
209
- if (!ac.signal.aborted) ac.abort();
210
- }
208
+ } catch {}
211
209
  await failed;
212
210
  if (!this.isRunning()) return;
213
211
  if (manualAttempt) this.attempt = 0;
@@ -229,12 +227,12 @@ window.__ModuleLoader__.load({
229
227
  }
230
228
  }
231
229
  };
232
- /** Await source readiness without letting a stalled carrier wedge startup forever. */
230
+ /** Await source readiness while reporting, but not cancelling, a slow Host. */
233
231
  function waitForReady(ready, timeoutMs, signal) {
234
232
  return new Promise((resolve, reject) => {
235
233
  let settled = false;
236
234
  const timeout = setTimeout(() => {
237
- finish({ error: /* @__PURE__ */ new Error(`connection generation was not ready within ${String(timeoutMs)}ms`) });
235
+ console.warn(`[connection] generation is still not ready after ${String(timeoutMs)}ms`);
238
236
  }, timeoutMs);
239
237
  const aborted = () => {
240
238
  finish({ error: new Error("connection generation aborted", { cause: signal.reason }) });
@@ -271,14 +269,14 @@ window.__ModuleLoader__.load({
271
269
  //#endregion
272
270
  //#region ../../util/brand/lib/index.js
273
271
  /**
274
- * Duplicate-install-safe nominal string helpers.
272
+ * Duplicate-install-safe nominal primitive helpers.
275
273
  *
276
- * A brand makes structurally-identical strings non-interchangeable at the type
277
- * level: a `SessionId` cannot be passed where a `ToolCallId` is expected, even
278
- * though both are plain strings at runtime. Comparison, logging, and
279
- * serialization all behave as ordinary strings.
274
+ * A brand makes structurally identical strings or numbers non-interchangeable
275
+ * at the type level: a `SessionId` cannot be passed where a `ToolCallId` is
276
+ * expected, and an event sequence cannot be passed as a log offset. Comparison,
277
+ * logging, and serialization retain the underlying primitive behavior.
280
278
  *
281
- * This package owns no concrete id and keeps no runtime identity or mutable
279
+ * This package owns no concrete domain value and keeps no runtime identity or mutable
282
280
  * state, so independently installed copies produce interchangeable values.
283
281
  *
284
282
  * @module @deepseek-ai/dsh-brand
@@ -291,6 +289,14 @@ window.__ModuleLoader__.load({
291
289
  function brandString(value) {
292
290
  return value;
293
291
  }
292
+ /**
293
+ * Apply a compile-time number brand without changing the value.
294
+ * @param value - number admitted by the domain that owns the target brand.
295
+ * @returns the same number with the requested compile-time brand.
296
+ */
297
+ function brandNumber(value) {
298
+ return value;
299
+ }
294
300
  //#endregion
295
301
  //#region ../../util/values/lib/index.js
296
302
  /**
@@ -403,6 +409,26 @@ window.__ModuleLoader__.load({
403
409
  });
404
410
  }
405
411
  //#endregion
412
+ //#region ../../core/session/lib/types/types.js
413
+ /**
414
+ * Admit a numeric value as an existing Session event position.
415
+ * @param value - non-negative safe integer admitted by the owning log operation.
416
+ * @returns the same number with the Session-sequence brand.
417
+ */
418
+ function SessionSeq(value) {
419
+ if (!Number.isSafeInteger(value) || value < 0 || Object.is(value, -0)) throw new TypeError(`SessionSeq must be a non-negative safe integer, got ${String(value)}`);
420
+ return brandNumber(value);
421
+ }
422
+ /**
423
+ * Admit a numeric value as a Session log offset.
424
+ * @param value - non-negative safe integer used as a gap or prefix length.
425
+ * @returns the same number with the Session-log-offset brand.
426
+ */
427
+ function SessionLogOffset(value) {
428
+ if (!Number.isSafeInteger(value) || value < 0 || Object.is(value, -0)) throw new TypeError(`SessionLogOffset must be a non-negative safe integer, got ${String(value)}`);
429
+ return brandNumber(value);
430
+ }
431
+ //#endregion
406
432
  //#region ../../core/session/lib/types/chunk-rows.js
407
433
  /**
408
434
  * Lossless row packing for `assistant/chunk` delta runs. Providers stream
@@ -413,7 +439,7 @@ window.__ModuleLoader__.load({
413
439
  * `tool-call-chunks` — and expands rows back to the exact original events.
414
440
  *
415
441
  * Packed rows are an encoding vocabulary, NOT session events: they never enter
416
- * `Session.events`, have no `SessionEventMap` entry, and use bare (slash-less)
442
+ * `Session.snapshotEvents()`, have no `SessionEventMap` entry, and use bare (slash-less)
417
443
  * type tags so a reader cannot confuse them with the event taxonomy
418
444
  * (precedent: the JSONL header line's `session` tag). Persistence and bounded
419
445
  * history transport both use the codec. The encoder whitelists exact shapes —
@@ -461,7 +487,7 @@ window.__ModuleLoader__.load({
461
487
  "time",
462
488
  "data"
463
489
  ])) return void 0;
464
- if (!Number.isSafeInteger(event.seq) || event.seq < 0 || !Number.isSafeInteger(event.time)) return void 0;
490
+ if (!Number.isSafeInteger(event.seq) || event.seq < 0 || Object.is(event.seq, -0) || !Number.isSafeInteger(event.time)) return void 0;
465
491
  const data = event.data;
466
492
  if (!isRecord$1(data) || !hasExactKeys(data, [
467
493
  "turn",
@@ -649,7 +675,7 @@ window.__ModuleLoader__.load({
649
675
  }
650
676
  /** Whether a runtime value is a non-negative safe event sequence. */
651
677
  function isEventSeq(value) {
652
- return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
678
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 && !Object.is(value, -0);
653
679
  }
654
680
  /** Whether a runtime value is the exact positional-replacement shape. */
655
681
  function isReplaceOp(value) {
@@ -800,7 +826,7 @@ window.__ModuleLoader__.load({
800
826
  const state = createFoldState();
801
827
  const replacements = [];
802
828
  for (const [index, event] of events.entries()) {
803
- const replacement = applySurfaceEvent(state, event, index, events, 0);
829
+ const replacement = applySurfaceEvent(state, event, SessionSeq(index), events, SessionLogOffset(0));
804
830
  if (replacement !== void 0) replacements.push(replacement);
805
831
  }
806
832
  return {
@@ -2630,7 +2656,7 @@ window.__ModuleLoader__.load({
2630
2656
  const append = (id, e) => {
2631
2657
  const log = logOf(id);
2632
2658
  const event = {
2633
- seq: log.length,
2659
+ seq: SessionSeq(log.length),
2634
2660
  time: Date.now(),
2635
2661
  ...e
2636
2662
  };
@@ -3565,7 +3591,7 @@ window.__ModuleLoader__.load({
3565
3591
  log.push({
3566
3592
  type: "user/message",
3567
3593
  surfaceOp: "append",
3568
- seq: log.length,
3594
+ seq: SessionSeq(log.length),
3569
3595
  time: Date.now(),
3570
3596
  data: userMessage(text(msg))
3571
3597
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-client-connection",
3
3
  "description": "Authenticated RPC transport, generation lifecycle, and browser fixture",
4
- "version": "0.1.2-alpha.2",
4
+ "version": "0.1.2-alpha.4",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -18,10 +18,6 @@
18
18
  "types": "./lib/types/index.d.ts",
19
19
  "default": "./lib/index.js"
20
20
  },
21
- "./invariant": {
22
- "types": "./lib/types/invariant.d.ts",
23
- "default": "./lib/invariant.js"
24
- },
25
21
  "./client": {
26
22
  "types": "./lib/types/client/index.d.ts",
27
23
  "default": "./lib/client.js"
@@ -39,12 +35,11 @@
39
35
  "license": "MIT",
40
36
  "dependencies": {
41
37
  "zod": "^4.4.3",
42
- "@deepseek-ai/schemastery": "^3.18.2",
43
- "@deepseek-ai/dsh-credentials": "^0.1.2-alpha.2"
38
+ "@deepseek-ai/dsh-credentials": "^0.1.2-alpha.4",
39
+ "@deepseek-ai/schemastery": "^3.18.2"
44
40
  },
45
41
  "files": [
46
42
  "lib/index.js",
47
- "lib/invariant.js",
48
43
  "lib/client.js",
49
44
  "lib/types/**/*.d.ts"
50
45
  ],
@@ -53,16 +48,15 @@
53
48
  },
54
49
  "devDependencies": {
55
50
  "@deepseek-ai/cordis": "^4.0.2",
56
- "@deepseek-ai/dsh-attachment": "^0.1.2-alpha.2",
57
- "@deepseek-ai/dsh-brand": "^0.1.2-alpha.2",
58
- "@deepseek-ai/dsh-commands": "^0.1.2-alpha.2",
59
- "@deepseek-ai/dsh-host-directory-picker": "^0.1.2-alpha.2",
60
- "@deepseek-ai/dsh-host-webserver": "^0.1.2-alpha.2",
61
- "@deepseek-ai/dsh-llm": "^0.1.2-alpha.2",
62
- "@deepseek-ai/dsh-settings": "^0.1.2-alpha.2",
63
- "@deepseek-ai/dsh-session": "^0.1.2-alpha.2",
64
- "@deepseek-ai/dsh-invariants": "^0.1.2-alpha.2",
65
- "@deepseek-ai/dsh-tool-todo": "^0.1.2-alpha.2",
66
- "@deepseek-ai/dsh-util-values": "^0.1.2-alpha.2"
51
+ "@deepseek-ai/dsh-attachment": "^0.1.2-alpha.4",
52
+ "@deepseek-ai/dsh-brand": "^0.1.2-alpha.4",
53
+ "@deepseek-ai/dsh-commands": "^0.1.2-alpha.4",
54
+ "@deepseek-ai/dsh-host-directory-picker": "^0.1.2-alpha.4",
55
+ "@deepseek-ai/dsh-host-webserver": "^0.1.2-alpha.4",
56
+ "@deepseek-ai/dsh-llm": "^0.1.2-alpha.4",
57
+ "@deepseek-ai/dsh-session": "^0.1.2-alpha.4",
58
+ "@deepseek-ai/dsh-settings": "^0.1.2-alpha.4",
59
+ "@deepseek-ai/dsh-tool-todo": "^0.1.2-alpha.4",
60
+ "@deepseek-ai/dsh-util-values": "^0.1.2-alpha.4"
67
61
  }
68
62
  }
package/lib/invariant.js DELETED
@@ -1,27 +0,0 @@
1
- //#region lib/types/invariant.js
2
- /**
3
- * Package-owned invariant companion for `@deepseek-ai/dsh-client-connection`.
4
- * @module @deepseek-ai/dsh-client-connection/invariant
5
- */
6
- const PACKAGE_NAME = "@deepseek-ai/dsh-client-connection";
7
- /** Cordis companion plugin name. */
8
- const name = "client-connection-invariant";
9
- /** Service required before the companion can reserve package ownership. */
10
- const inject = ["invariants"];
11
- /**
12
- * No runtime invariant: browser-session verification reads the credential
13
- * record asynchronously at the request that authorizes work, while the
14
- * credentials companion owns record commit-event lifetime. Stream/reconnect
15
- * sequencing and rpcId round-trip discipline are exercised directly by
16
- * behavior specs, and route register/dispose symmetry is
17
- * audited by the webserver companion.
18
- */
19
- const install = () => {};
20
- /**
21
- * Register this package's invariant companion.
22
- * @param ctx - Cordis context carrying the invariant service.
23
- * @returns the installed registration's disposer after setup succeeds.
24
- */
25
- const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
26
- //#endregion
27
- export { apply, inject, name };
@@ -1,16 +0,0 @@
1
- /**
2
- * Package-owned invariant companion for `@deepseek-ai/dsh-client-connection`.
3
- * @module @deepseek-ai/dsh-client-connection/invariant
4
- */
5
- import type { Context } from '@deepseek-ai/cordis';
6
- /** Cordis companion plugin name. */
7
- export declare const name = "client-connection-invariant";
8
- /** Service required before the companion can reserve package ownership. */
9
- export declare const inject: string[];
10
- /**
11
- * Register this package's invariant companion.
12
- * @param ctx - Cordis context carrying the invariant service.
13
- * @returns the installed registration's disposer after setup succeeds.
14
- */
15
- export declare const apply: (ctx: Context) => Promise<() => void>;
16
- //# sourceMappingURL=invariant.d.ts.map