Files
deepseek-harness/packages/util/brand/src/index.ts
Tianyi Cui 6143537d4e Merge branch 'codex/simp-agent-entry-state' into codex/simp-unify-agent-session-id
# Conflicts:
#	docs/cordis-catalog/events.md
#	docs/cordis-catalog/services.md
#	docs/core-data-structures/bash.md
#	docs/core-data-structures/core.md
#	docs/event-producer-consumer.md
#	docs/module-graph.md
#	packages/bash/bash/src/types.ts
#	packages/bash/tool-bash/README.md
#	packages/bash/tool-bash/src/index.ts
#	packages/bash/tool-bash/tests/tools.spec.ts
#	packages/examples/agent-spine-demo/README.md
#	packages/examples/agent-spine-demo/tests/agent-core.spec.ts
#	packages/subagent/tool-subagent/tests/tool-subagent.spec.ts
#	packages/util/brand/README.md
#	packages/util/brand/src/index.ts
2026-07-15 23:29:47 +08:00

28 lines
1.3 KiB
TypeScript

/**
* The `Branded<B>` nominal-typing primitive — a type-only utility (no runtime
* code, no harness-package dependency) shared by every package that owns a
* cross-boundary id.
*
* 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. Construction goes through a per-id
* factory in the OWNING package (a plain cast inside — zero runtime cost);
* comparison, logging, and serialization all behave as ordinary strings.
*
* Policy: a package brands the ids it owns — `CallId` in dsh-llm (tool-call
* correlation), the shared agent/session `SessionId` in dsh-session, and
* `TaskId` in dsh-tasks. Branding is for ids that cross package boundaries and
* could plausibly be confused; not every string needs a brand.
* This package owns ONLY the primitive — no concrete id, no runtime code beyond
* the (erased) type — so the brand vocabulary stays dependency-free and a
* package can brand its ids without depending on an unrelated capability
* package.
*
* @module @deepseek-ai/dsh-brand
*/
declare const BRAND: unique symbol
/** A string carrying a compile-time-only brand `B`. */
export type Branded<B extends string> = string & { readonly [BRAND]: B }