mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
The folder is becoming the home of one-doc-per-subsystem pages (intro + data structures + cordis services/events), so the name must describe the whole contract, not just the type-vocabulary third of it. Mechanical rename rebuilt on current master: every inbound Markdown link, generator constant, website route, type-equiv manifest path, and spec expectation moves together; the zh sides of the notes whose prose names the folder are aligned (子系统) in the same change; touched bilingual pairs re-recorded; translation-prompt snapshot re-recorded (its example embeds development.md). Historical Agent Note slugs keep their dated filenames.
51 lines
2.7 KiB
Markdown
51 lines
2.7 KiB
Markdown
# 用户凭据
|
||
|
||
[English](credentials.md) | 中文
|
||
|
||
[dsh-credentials](../../packages/credentials/credentials) 的凭据 seam 把机密挡在配置之外:settings 分节与 `cordis.yml` 条目携带的是*引用*(环境变量名),值归 [dsh-credentials-local](../../packages/credentials/credentials-local) 这类 provider 所有,消费方每个操作解析一次引用——LLM 适配器每次模型请求解析一次,因此轮换后的凭据无需任何重启即可作用于紧随其后的下一次请求。一条 seam 级规则约束每个 provider:空的存储值在任何地方都视为不存在。
|
||
|
||
Source: [`packages/credentials/credentials/src/index.ts`](../../packages/credentials/credentials/src/index.ts)
|
||
|
||
## 标识
|
||
|
||
引用以 POSIX 风格环境变量名命名一条凭据。brand 使引用不与其他跨边界字符串混用;构造时校验 shell 标识符形态。
|
||
|
||
```ts type-equiv
|
||
/** Nominal reference to one credential: a POSIX-style environment-variable name. */
|
||
type CredentialRef = Branded<'CredentialRef'>
|
||
```
|
||
|
||
## 解析
|
||
|
||
`resolve(ref)` 返回值,连同供出该值、由 provider 定义的来源层;未配置期间返回 `undefined`。消费方在每个操作中重新解析,绝不跨操作缓存——这次按操作进行的读取正是热更新机制。
|
||
|
||
```ts type-equiv
|
||
/** One resolved credential value and the source layer that supplied it. */
|
||
interface ResolvedCredential {
|
||
/** The non-empty secret value. */
|
||
value: string
|
||
/** Provider-defined source layer id (the local provider uses `env`, `file`, `project-env`, and `user-env`). */
|
||
source: string
|
||
}
|
||
```
|
||
|
||
## 描述
|
||
|
||
`describe(ref)` 在绝不暴露值的前提下回应配置界面:引用当前是否可解析、来自哪一层、`set` 当前能否成功。本地 provider 把由活跃进程环境供值的引用报告为 `writable: false`——那样的写入会表面成功而解析持续返回遮蔽值,因此 seam 直接拒绝,界面也得以提前把该引用渲染为只读。
|
||
|
||
```ts type-equiv
|
||
/** Source and writability facts for one reference, safe for configuration UIs — never the value. */
|
||
interface CredentialInfo {
|
||
/** Whether {@link Credentials.resolve} would currently return a value. */
|
||
configured: boolean
|
||
/** Source layer currently supplying the value; absent while unconfigured. */
|
||
source?: string
|
||
/** Whether {@link Credentials.set} would currently succeed for this reference. */
|
||
writable: boolean
|
||
}
|
||
```
|
||
|
||
## 变更提交
|
||
|
||
`credentials/updated (ref)` 在 provider 管理的来源发生已提交变更后触发——`set`、`unset` 或在存储中观察到的外部编辑。进程环境自身的变化不可观测,永不发出事件。消费方不需要该事件(它们按操作重新解析);它服务于配置界面刷新「已配置」徽标。
|