{"_id":"@buckeyestudio/toh-brand","name":"@buckeyestudio/toh-brand","dist-tags":{"next":"0.1.1-rc.2","latest":"0.1.1-rc.2"},"versions":{"0.1.1-rc.2":{"name":"@buckeyestudio/toh-brand","description":"Type-only Branded<B> nominal-typing primitive for the TheOpen Harness","version":"0.1.1-rc.2","publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/dustinwloring1988/theopen-harness.git","directory":"packages/util/brand"},"type":"module","main":"lib/index.js","types":"lib/types/index.d.ts","exports":{".":{"types":"./lib/types/index.d.ts","default":"./lib/index.js"},"./invariant":{"types":"./lib/types/invariant.d.ts","default":"./lib/invariant.js"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","author":{"name":"buckeyestudio"},"peerDependencies":{"@buckeyestudio/toh-invariants":"^0.1.1-rc.2","@buckeyestudio/cordis":"^4.0.1"},"devDependencies":{"@buckeyestudio/toh-invariants":"^0.1.1-rc.2","@buckeyestudio/cordis":"^4.0.1"},"_id":"@buckeyestudio/toh-brand@0.1.1-rc.2","bugs":{"url":"https://github.com/dustinwloring1988/theopen-harness/issues"},"homepage":"https://github.com/dustinwloring1988/theopen-harness#readme","_integrity":"sha512-KF5ZfhcGw8l4bDTVbock133u1cRF2OjhJlVJlck0s7JurFQiyaycbi8BDsgg2ehBcZvX4D8ij1LrLhvTPOKABw==","_resolved":"/home/runner/work/theopen-harness/theopen-harness/dist/npm/buckeyestudio-toh-brand-0.1.1-rc.2.tgz","_from":"file:/home/runner/work/theopen-harness/theopen-harness/dist/npm/buckeyestudio-toh-brand-0.1.1-rc.2.tgz","_nodeVersion":"24.19.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-KF5ZfhcGw8l4bDTVbock133u1cRF2OjhJlVJlck0s7JurFQiyaycbi8BDsgg2ehBcZvX4D8ij1LrLhvTPOKABw==","shasum":"329e6dfe474cb690d6c2ea5d8d9c594bc34ae919","tarball":"https://registry.npmjs.org/@buckeyestudio/toh-brand/-/toh-brand-0.1.1-rc.2.tgz","fileCount":9,"unpackedSize":8238,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIB0srGS3wYYroKMypf+62v9jHpeUm7OnfcL6wBK9am1iAiBWtVo2kQTb0pPKDJNNcHf/hRz2cSNxmJmqB/UHdcP0Ug=="}]},"_npmUser":{"name":"buckeyestudio","email":"dustinwloring1988@gmail.com"},"directories":{},"maintainers":[{"name":"buckeyestudio","email":"dustinwloring1988@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/toh-brand_0.1.1-rc.2_1787488915922_0.940323712378252"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-23T12:41:55.760Z","0.1.1-rc.2":"2026-08-23T12:41:56.050Z","modified":"2026-08-23T12:41:56.267Z"},"maintainers":[{"name":"buckeyestudio","email":"dustinwloring1988@gmail.com"}],"description":"Type-only Branded<B> nominal-typing primitive for the TheOpen Harness","homepage":"https://github.com/dustinwloring1988/theopen-harness#readme","repository":{"type":"git","url":"git+https://github.com/dustinwloring1988/theopen-harness.git","directory":"packages/util/brand"},"author":{"name":"buckeyestudio"},"bugs":{"url":"https://github.com/dustinwloring1988/theopen-harness/issues"},"license":"MIT","readme":"# toh-brand\n\n[English](README.md) | 中文\n\n`Branded<B>` 名义类型原语：一个微小的**仅类型**包，无运行时代码，也不依赖其他 harness 包；所有负责跨边界 id 的包都会共享它。\n\n## `Branded` 是什么\n\n品牌使 `SessionId` 和 `CallId` 这样结构相同的字符串在类型层面不可互换，尽管两者在运行时都是普通 `string`。\n\n```ts\nimport type { Branded } from '@buckeyestudio/toh-brand'\n\nexport type SessionId = Branded<'SessionId'>\n\n/** Brand a string as a SessionId (a plain cast — zero runtime cost). */\nexport function SessionId(id: string): SessionId {\n  return id as SessionId\n}\n```\n\n构造操作通过所属包中各 id 专用的工厂完成。比较、日志记录、JSON 序列化和协议格式（wire format）的行为与普通字符串相同；品牌信息会在编译时被擦除。\n\n## 策略：为跨包边界的 id 添加品牌\n\n包为自己拥有的 id 添加品牌：`CallId` 位于 `toh-llm`，共享的 agent/会话 `SessionId` 位于 `toh-session`，`JobId` 位于 `toh-jobs`。为可能被混淆的跨包 id 添加品牌，但无需为每个字符串都添加。\n\n该包只负责这一原语。保持无依赖意味着，例如 `toh-jobs` 可以为 `JobId` 使用品牌类型，而无需仅为使用 `Branded` 而导入不相关的功能包。\n","readmeFilename":"README.zh.md","_rev":"1-ef72711320d800af1d3b4b3150f98880"}