dsh-brand/packages/util/brand官方

175.3kStar19.0kFork0Issue752Watching

仅类型定义的 Branded 原语,为跨包边界的 ID(如 SessionId、JobId)提供nominal-typing,防止结构相同但语义不同的字符串在类型层面误用

机审证据安装命令仓库已核验dsh-plugin Topic许可证READMEAI 百科

此插件是大仓库 deepseek-ai/deepseek-harness 的子包,星数与活跃度统计的是整个仓库。

语言
TypeScript
License
MIT
分支
master
ai-agentscordisdshdsh-plugin

安装

$ dsh plugin --profile web add npm:@deepseek-ai/dsh-brand

在终端中运行以上命令,通过 dsh CLI 安装此插件。可在右上角切换 Profile。 第一次用 dsh?看这篇新手教程

对话式安装

帮我安装 DeepSeek Harness 插件 deepseek-ai/deepseek-harness/packages/util/brand:先查看仓库 https://github.com/deepseek-ai/deepseek-harness 确认安全性,然后执行安装命令并验证插件加载成功。

把这段指令粘贴给 DSH Web GUI 里的助手,由它代你完成安装与验证。

English | 中文

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.

What Branded is

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 strings at runtime.

import type { Branded } from '@deepseek-ai/dsh-brand'

export type SessionId = Branded<'SessionId'>

/** Brand a string as a SessionId (a plain cast — zero runtime cost). */
export function SessionId(id: string): SessionId {
  return id as SessionId
}

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.

Policy: brand ids that cross package boundaries

A package brands the ids it owns — CallId in dsh-llm, the shared agent/session SessionId in dsh-session, and JobId in dsh-jobs. Brand cross-package ids that could plausibly be confused; not every string needs one.

This package owns only the primitive. Keeping it dependency-free lets dsh-jobs, for example, brand JobId without importing an unrelated capability package merely to reach Branded.

收录徽章

Listed on deepseek-plugin.org
[![Listed on deepseek-plugin.org](https://img.shields.io/badge/listed_on-deepseek--plugin.org-007EC6)](https://deepseek-plugin.org/plugins/deepseek-ai/deepseek-harness/packages/util/brand)

把这段 markdown 粘贴到你的 GitHub README,链接回本插件详情页。徽章只声明已被本站收录,不代表安全认证。

返回插件目录
dsh-brand/packages/util/brand — DeepSeek Harness 插件 | deepseek-plugin.org