@deepseek-ai/dsh-brand 0.0.1-rc.1

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/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, DeepSeek
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,6 @@
1
+ # Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
2
+ # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
+ # after editing either side, bring the other along and re-record with:
4
+ # pnpm run verify-translation-pairing --write packages/util/brand/README.md
5
+ README.md: 68401d95a31ed2122386794ad5256a5cd93bb2a6
6
+ README.zh.md: 0eeb2c8afb5fe1b279f49c839e769b8d0eea0a5a
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # dsh-brand
2
+
3
+ English | [中文](README.zh.md)
4
+
5
+ The `Branded<B>` nominal-typing primitive — a tiny, **type-only** package (no runtime code, no harness-package dependency) shared by every package that owns a cross-boundary id.
6
+
7
+ ## What `Branded` is
8
+
9
+ A brand makes structurally-identical strings non-interchangeable at the type level: a `SessionId` cannot be passed where a `CallId` is expected, even though both are plain `string`s at runtime.
10
+
11
+ ```ts
12
+ import type { Branded } from '@deepseek-ai/dsh-brand'
13
+
14
+ export type SessionId = Branded<'SessionId'>
15
+
16
+ /** Brand a string as a SessionId (a plain cast — zero runtime cost). */
17
+ export function SessionId(id: string): SessionId {
18
+ return id as SessionId
19
+ }
20
+ ```
21
+
22
+ Construction goes through the per-id factory in the owning package. Comparison, logging, JSON serialization, and the wire format behave as for an ordinary string; the brand is erased at compile time.
23
+
24
+ ## Policy: brand ids that cross package boundaries
25
+
26
+ A package brands the ids it owns — `CallId` in `dsh-llm`, the shared agent/session `SessionId` in `dsh-session`, and `TaskId` in `dsh-tasks`. Brand cross-package ids that could plausibly be confused; not every string needs one.
27
+
28
+ This package owns only the primitive. Keeping it dependency-free lets `dsh-tasks`, for example, brand `TaskId` without importing an unrelated capability package merely to reach `Branded`.
package/README.zh.md ADDED
@@ -0,0 +1,28 @@
1
+ # dsh-brand
2
+
3
+ [English](README.md) | 中文
4
+
5
+ `Branded<B>` 名义类型原语:一个微小的**仅类型**包,无运行时代码,也不依赖其他 harness 包;所有负责跨边界 id 的包都会共享它。
6
+
7
+ ## `Branded` 是什么
8
+
9
+ 品牌使 `SessionId` 和 `CallId` 这样结构相同的字符串在类型层面不可互换,尽管两者在运行时都是普通 `string`。
10
+
11
+ ```ts
12
+ import type { Branded } from '@deepseek-ai/dsh-brand'
13
+
14
+ export type SessionId = Branded<'SessionId'>
15
+
16
+ /** Brand a string as a SessionId (a plain cast — zero runtime cost). */
17
+ export function SessionId(id: string): SessionId {
18
+ return id as SessionId
19
+ }
20
+ ```
21
+
22
+ 构造操作通过所属包中各 id 专用的工厂完成。比较、日志记录、JSON 序列化和协议格式(wire format)的行为与普通字符串相同;品牌信息会在编译时被擦除。
23
+
24
+ ## 策略:为跨包边界的 id 添加品牌
25
+
26
+ 包为自己拥有的 id 添加品牌:`CallId` 位于 `dsh-llm`,共享的 agent/会话 `SessionId` 位于 `dsh-session`,`TaskId` 位于 `dsh-tasks`。为可能被混淆的跨包 id 添加品牌,但无需为每个字符串都添加。
27
+
28
+ 该包只负责这一原语。保持无依赖意味着,例如 `dsh-tasks` 可以为 `TaskId` 使用品牌类型,而无需仅为使用 `Branded` 而导入不相关的功能包。
package/lib/index.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ //#region lib/types/invariant.js
2
+ /**
3
+ * Package-owned invariant companion for `@deepseek-ai/dsh-brand`.
4
+ * @module @deepseek-ai/dsh-brand/invariant
5
+ */
6
+ const PACKAGE_NAME = "@deepseek-ai/dsh-brand";
7
+ /** Cordis companion plugin name. */
8
+ const name = "brand-invariant";
9
+ /** Service required before the companion can reserve package ownership. */
10
+ const inject = ["invariants"];
11
+ /**
12
+ * No runtime invariant: this pure utility owns no event stream or mutable runtime data; its value
13
+ * algebra is enforced by unit tests.
14
+ */
15
+ const install = () => {};
16
+ /**
17
+ * Register this package's invariant companion.
18
+ * @param ctx - Cordis context carrying the invariant service.
19
+ * @returns the installed registration's disposer after setup succeeds.
20
+ */
21
+ const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
22
+ //#endregion
23
+ export { apply, inject, name };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The `Branded<B>` nominal-typing primitive — a type-only utility (no runtime
3
+ * code, no harness-package dependency) shared by every package that owns a
4
+ * cross-boundary id.
5
+ *
6
+ * A brand makes structurally-identical strings non-interchangeable at the type
7
+ * level: a `SessionId` cannot be passed where a `CallId` is expected, even
8
+ * though both are plain strings at runtime. Construction goes through a per-id
9
+ * factory in the OWNING package (a plain cast inside — zero runtime cost);
10
+ * comparison, logging, and serialization all behave as ordinary strings.
11
+ *
12
+ * Policy: a package brands the ids it owns — `CallId` in dsh-llm (tool-call
13
+ * correlation), the shared agent/session `SessionId` in dsh-session, and
14
+ * `TaskId` in dsh-tasks. Branding is for ids that cross package boundaries and
15
+ * could plausibly be confused; not every string needs a brand.
16
+ * This package owns ONLY the primitive — no concrete id, no runtime code beyond
17
+ * the (erased) type — so the brand vocabulary stays dependency-free and a
18
+ * package can brand its ids without depending on an unrelated capability
19
+ * package.
20
+ *
21
+ * @module @deepseek-ai/dsh-brand
22
+ */
23
+ declare const BRAND: unique symbol;
24
+ /** A string carrying a compile-time-only brand `B`. */
25
+ export type Branded<B extends string> = string & {
26
+ readonly [BRAND]: B;
27
+ };
28
+ export {};
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Package-owned invariant companion for `@deepseek-ai/dsh-brand`.
3
+ * @module @deepseek-ai/dsh-brand/invariant
4
+ */
5
+ import type { Context } from '@deepseek-ai/cordis';
6
+ /** Cordis companion plugin name. */
7
+ export declare const name = "brand-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
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@deepseek-ai/dsh-brand",
3
+ "description": "Type-only Branded<B> nominal-typing primitive for the DeepSeek Harness",
4
+ "version": "0.0.1-rc.1",
5
+ "publishConfig": {
6
+ "access": "restricted"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
11
+ "directory": "packages/util/brand"
12
+ },
13
+ "type": "module",
14
+ "main": "lib/index.js",
15
+ "types": "lib/types/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./lib/types/index.d.ts",
19
+ "default": "./lib/index.js"
20
+ },
21
+ "./invariant": {
22
+ "types": "./lib/types/invariant.d.ts",
23
+ "default": "./lib/invariant.js"
24
+ },
25
+ "./src/*": "./src/*",
26
+ "./package.json": "./package.json"
27
+ },
28
+ "files": [
29
+ "lib/index.js",
30
+ "lib/invariant.js",
31
+ "lib/types/**/*.d.ts"
32
+ ],
33
+ "license": "BSD-3-Clause",
34
+ "peerDependencies": {
35
+ "@deepseek-ai/dsh-invariants": "^0.0.1-rc.1",
36
+ "@deepseek-ai/cordis": "^4.0.1-rc.1"
37
+ },
38
+ "devDependencies": {
39
+ "@deepseek-ai/dsh-invariants": "^0.0.1-rc.1",
40
+ "@deepseek-ai/cordis": "^4.0.1-rc.1"
41
+ }
42
+ }