better-dsh 0.2.3-e → 0.2.3-g
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/docs/50_test-reports/2026-09-13-preact-ui-shell/345/256/236/346/265/213/346/212/245/345/221/212.md +1 -1
- package/docs/50_test-reports/2026-09-14-4999-skill/346/270/205/345/215/225/344/270/216lsp-gate/345/256/236/346/265/213/346/212/245/345/221/212.md +54 -0
- package/docs/specs/agent/spec.md +54 -0
- package/docs/specs/ast/spec.md +34 -0
- package/docs/specs/compaction-recall/spec.md +46 -0
- package/docs/specs/ctx/spec.md +107 -0
- package/docs/specs/dsh/spec.md +47 -0
- package/docs/specs/dvc/spec.md +87 -0
- package/docs/specs/escalation-guidance/spec.md +44 -0
- package/docs/specs/fs-scheme-resolution/spec.md +37 -0
- package/docs/specs/hash-edit/spec.md +41 -0
- package/docs/specs/http-read/spec.md +73 -0
- package/docs/specs/kernel-provisioning/spec.md +53 -0
- package/docs/specs/lsp/spec.md +121 -0
- package/docs/specs/mobile-layout/spec.md +108 -0
- package/docs/specs/model-failover/spec.md +20 -0
- package/docs/specs/preact-ui-shell/spec.md +22 -0
- package/docs/specs/repl-dispatch-resilience/spec.md +21 -0
- package/docs/specs/skill/spec.md +58 -0
- package/docs/specs/tool-surface/spec.md +222 -0
- package/docs/specs/url-schema/spec.md +148 -0
- package/docs/specs/web-trust-fence/spec.md +43 -0
- package/dsh-docs/AGENTS.md +75 -0
- package/dsh-docs/agent-lifecycle.md +84 -0
- package/dsh-docs/agent-lifecycle.zh.md +86 -0
- package/dsh-docs/api-gateway.md +164 -0
- package/dsh-docs/api-gateway.zh.md +164 -0
- package/dsh-docs/architecture.md +150 -0
- package/dsh-docs/architecture.zh.md +154 -0
- package/dsh-docs/capability-seams.md +543 -0
- package/dsh-docs/capability-seams.zh.md +545 -0
- package/dsh-docs/config-catalog.md +3473 -0
- package/dsh-docs/config-catalog.zh.md +3474 -0
- package/dsh-docs/cookbook/adding-a-package.md +117 -0
- package/dsh-docs/cookbook/adding-a-package.zh.md +119 -0
- package/dsh-docs/cookbook/adding-a-remote-api.md +197 -0
- package/dsh-docs/cookbook/adding-a-remote-api.zh.md +197 -0
- package/dsh-docs/cookbook/adding-a-settings-card.md +102 -0
- package/dsh-docs/cookbook/adding-a-settings-card.zh.md +102 -0
- package/dsh-docs/cookbook/adding-a-tool.md +101 -0
- package/dsh-docs/cookbook/adding-a-tool.zh.md +103 -0
- package/dsh-docs/cookbook/adding-a-vendored-package.md +59 -0
- package/dsh-docs/cookbook/adding-a-vendored-package.zh.md +59 -0
- package/dsh-docs/cookbook/adding-an-llm-adapter.md +43 -0
- package/dsh-docs/cookbook/adding-an-llm-adapter.zh.md +43 -0
- package/dsh-docs/cookbook/extension-cookbook.md +132 -0
- package/dsh-docs/cookbook/extension-cookbook.zh.md +136 -0
- package/dsh-docs/cookbook/maintaining-dsh-code-review.md +64 -0
- package/dsh-docs/cookbook/maintaining-dsh-code-review.zh.md +64 -0
- package/dsh-docs/cookbook/responding-to-pr-review-on-a-stack.md +32 -0
- package/dsh-docs/cookbook/responding-to-pr-review-on-a-stack.zh.md +32 -0
- package/dsh-docs/cordis-api/context.md +364 -0
- package/dsh-docs/cordis-api/context.zh.md +366 -0
- package/dsh-docs/cordis-api/events.md +207 -0
- package/dsh-docs/cordis-api/events.zh.md +209 -0
- package/dsh-docs/cordis-api/fiber.md +375 -0
- package/dsh-docs/cordis-api/fiber.zh.md +377 -0
- package/dsh-docs/cordis-api/inherited.md +39 -0
- package/dsh-docs/cordis-api/registry.md +152 -0
- package/dsh-docs/cordis-api/registry.zh.md +154 -0
- package/dsh-docs/cordis-api/service.md +102 -0
- package/dsh-docs/cordis-api/service.zh.md +104 -0
- package/dsh-docs/cordis-primer.md +45 -0
- package/dsh-docs/cordis-primer.zh.md +51 -0
- package/dsh-docs/cordis-tutorial/01-first-plugin.md +95 -0
- package/dsh-docs/cordis-tutorial/01-first-plugin.zh.md +95 -0
- package/dsh-docs/cordis-tutorial/02-lifecycle-and-effects.md +98 -0
- package/dsh-docs/cordis-tutorial/02-lifecycle-and-effects.zh.md +98 -0
- package/dsh-docs/cordis-tutorial/03-services.md +98 -0
- package/dsh-docs/cordis-tutorial/03-services.zh.md +98 -0
- package/dsh-docs/cordis-tutorial/04-events.md +144 -0
- package/dsh-docs/cordis-tutorial/04-events.zh.md +144 -0
- package/dsh-docs/cordis-tutorial/05-config.md +84 -0
- package/dsh-docs/cordis-tutorial/05-config.zh.md +84 -0
- package/dsh-docs/cordis-tutorial/06-composition-and-hmr.md +113 -0
- package/dsh-docs/cordis-tutorial/06-composition-and-hmr.zh.md +113 -0
- package/dsh-docs/cordis-tutorial/07-into-the-harness.md +108 -0
- package/dsh-docs/cordis-tutorial/07-into-the-harness.zh.md +108 -0
- package/dsh-docs/cordis-tutorial/index.md +60 -0
- package/dsh-docs/cordis-tutorial/index.zh.md +62 -0
- package/dsh-docs/deepseek-llm-api-wire-extensions.md +163 -0
- package/dsh-docs/deepseek-llm-api-wire-extensions.zh.md +163 -0
- package/dsh-docs/defensive-patterns.md +33 -0
- package/dsh-docs/defensive-patterns.zh.md +35 -0
- package/dsh-docs/development.md +167 -0
- package/dsh-docs/development.zh.md +173 -0
- package/dsh-docs/event-producer-consumer.md +86 -0
- package/dsh-docs/event-producer-consumer.zh.md +88 -0
- package/dsh-docs/glossary.md +45 -0
- package/dsh-docs/glossary.zh.md +45 -0
- package/dsh-docs/graph-atlas.md +22 -0
- package/dsh-docs/graph-atlas.zh.md +24 -0
- package/dsh-docs/i18n/README.md +60 -0
- package/dsh-docs/i18n/README.zh.md +62 -0
- package/dsh-docs/i18n/style-samples.md +87 -0
- package/dsh-docs/i18n/terminology.md +214 -0
- package/dsh-docs/i18n/translation-prompt.md +263 -0
- package/dsh-docs/i18n/translation-rules.md +69 -0
- package/dsh-docs/i18n/translation-rules.zh.md +69 -0
- package/dsh-docs/module-graph.md +1411 -0
- package/dsh-docs/module-graph.zh.md +1413 -0
- package/dsh-docs/persistence-catalog.md +1075 -0
- package/dsh-docs/persistence-catalog.zh.md +1077 -0
- package/dsh-docs/postmortem/0001-acp-default-export-drops-inject.md +113 -0
- package/dsh-docs/postmortem/0001-acp-default-export-drops-inject.zh.md +113 -0
- package/dsh-docs/postmortem/0002-js-expression-disabled-filesystem-tools.md +47 -0
- package/dsh-docs/postmortem/0002-js-expression-disabled-filesystem-tools.zh.md +47 -0
- package/dsh-docs/postmortem/0003-web-agent-gui-feedback-loop.md +53 -0
- package/dsh-docs/postmortem/0003-web-agent-gui-feedback-loop.zh.md +53 -0
- package/dsh-docs/postmortem/0004-landlock-partial-notice-misclassified-child-failures.md +55 -0
- package/dsh-docs/postmortem/0004-landlock-partial-notice-misclassified-child-failures.zh.md +55 -0
- package/dsh-docs/postmortem/README.md +18 -0
- package/dsh-docs/postmortem/README.zh.md +18 -0
- package/dsh-docs/rescope.md +53 -0
- package/dsh-docs/rescope.zh.md +53 -0
- package/dsh-docs/subsystems/README.md +61 -0
- package/dsh-docs/subsystems/README.zh.md +61 -0
- package/dsh-docs/subsystems/agent-team.md +207 -0
- package/dsh-docs/subsystems/agent-team.zh.md +207 -0
- package/dsh-docs/subsystems/approval.md +170 -0
- package/dsh-docs/subsystems/approval.zh.md +170 -0
- package/dsh-docs/subsystems/attachment.md +351 -0
- package/dsh-docs/subsystems/attachment.zh.md +351 -0
- package/dsh-docs/subsystems/client-modules.md +168 -0
- package/dsh-docs/subsystems/client-modules.zh.md +168 -0
- package/dsh-docs/subsystems/code-runtime.md +195 -0
- package/dsh-docs/subsystems/code-runtime.zh.md +195 -0
- package/dsh-docs/subsystems/commands.md +219 -0
- package/dsh-docs/subsystems/commands.zh.md +219 -0
- package/dsh-docs/subsystems/compaction.md +238 -0
- package/dsh-docs/subsystems/compaction.zh.md +238 -0
- package/dsh-docs/subsystems/conversation.md +258 -0
- package/dsh-docs/subsystems/conversation.zh.md +258 -0
- package/dsh-docs/subsystems/core.md +1209 -0
- package/dsh-docs/subsystems/core.zh.md +1219 -0
- package/dsh-docs/subsystems/credentials.md +329 -0
- package/dsh-docs/subsystems/credentials.zh.md +329 -0
- package/dsh-docs/subsystems/extensions.md +382 -0
- package/dsh-docs/subsystems/extensions.zh.md +382 -0
- package/dsh-docs/subsystems/feedback.md +266 -0
- package/dsh-docs/subsystems/feedback.zh.md +266 -0
- package/dsh-docs/subsystems/filesystem.md +505 -0
- package/dsh-docs/subsystems/filesystem.zh.md +505 -0
- package/dsh-docs/subsystems/goal.md +277 -0
- package/dsh-docs/subsystems/goal.zh.md +277 -0
- package/dsh-docs/subsystems/invariants.md +88 -0
- package/dsh-docs/subsystems/invariants.zh.md +88 -0
- package/dsh-docs/subsystems/jobs.md +290 -0
- package/dsh-docs/subsystems/jobs.zh.md +290 -0
- package/dsh-docs/subsystems/llm-streaming.md +1080 -0
- package/dsh-docs/subsystems/llm-streaming.zh.md +1086 -0
- package/dsh-docs/subsystems/lsp.md +202 -0
- package/dsh-docs/subsystems/lsp.zh.md +202 -0
- package/dsh-docs/subsystems/permission-presets.md +131 -0
- package/dsh-docs/subsystems/permission-presets.zh.md +131 -0
- package/dsh-docs/subsystems/persistence.md +395 -0
- package/dsh-docs/subsystems/persistence.zh.md +395 -0
- package/dsh-docs/subsystems/plan.md +87 -0
- package/dsh-docs/subsystems/plan.zh.md +87 -0
- package/dsh-docs/subsystems/sandbox.md +220 -0
- package/dsh-docs/subsystems/sandbox.zh.md +220 -0
- package/dsh-docs/subsystems/schedule.md +192 -0
- package/dsh-docs/subsystems/schedule.zh.md +192 -0
- package/dsh-docs/subsystems/scope.md +59 -0
- package/dsh-docs/subsystems/scope.zh.md +59 -0
- package/dsh-docs/subsystems/session-projection.md +354 -0
- package/dsh-docs/subsystems/session-projection.zh.md +354 -0
- package/dsh-docs/subsystems/session-query.md +509 -0
- package/dsh-docs/subsystems/session-query.zh.md +509 -0
- package/dsh-docs/subsystems/session-reference.md +219 -0
- package/dsh-docs/subsystems/session-reference.zh.md +219 -0
- package/dsh-docs/subsystems/session-telemetry.md +194 -0
- package/dsh-docs/subsystems/session-telemetry.zh.md +194 -0
- package/dsh-docs/subsystems/session-title.md +204 -0
- package/dsh-docs/subsystems/session-title.zh.md +204 -0
- package/dsh-docs/subsystems/session.md +1155 -0
- package/dsh-docs/subsystems/session.zh.md +1159 -0
- package/dsh-docs/subsystems/settings.md +405 -0
- package/dsh-docs/subsystems/settings.zh.md +405 -0
- package/dsh-docs/subsystems/shell.md +303 -0
- package/dsh-docs/subsystems/shell.zh.md +303 -0
- package/dsh-docs/subsystems/skills.md +354 -0
- package/dsh-docs/subsystems/skills.zh.md +354 -0
- package/dsh-docs/subsystems/slots.md +175 -0
- package/dsh-docs/subsystems/slots.zh.md +175 -0
- package/dsh-docs/subsystems/spill.md +117 -0
- package/dsh-docs/subsystems/spill.zh.md +117 -0
- package/dsh-docs/subsystems/storage.md +260 -0
- package/dsh-docs/subsystems/storage.zh.md +260 -0
- package/dsh-docs/subsystems/subagent.md +766 -0
- package/dsh-docs/subsystems/subagent.zh.md +770 -0
- package/dsh-docs/subsystems/subprocess.md +324 -0
- package/dsh-docs/subsystems/subprocess.zh.md +324 -0
- package/dsh-docs/subsystems/system-prompt.md +220 -0
- package/dsh-docs/subsystems/system-prompt.zh.md +220 -0
- package/dsh-docs/subsystems/terminal.md +184 -0
- package/dsh-docs/subsystems/terminal.zh.md +184 -0
- package/dsh-docs/subsystems/todo.md +32 -0
- package/dsh-docs/subsystems/todo.zh.md +32 -0
- package/dsh-docs/subsystems/token-meter.md +105 -0
- package/dsh-docs/subsystems/token-meter.zh.md +105 -0
- package/dsh-docs/subsystems/tools.md +720 -0
- package/dsh-docs/subsystems/tools.zh.md +720 -0
- package/dsh-docs/subsystems/typert.md +343 -0
- package/dsh-docs/subsystems/typert.zh.md +343 -0
- package/dsh-docs/subsystems/user-questions.md +178 -0
- package/dsh-docs/subsystems/user-questions.zh.md +178 -0
- package/dsh-docs/subsystems/web-client.md +95 -0
- package/dsh-docs/subsystems/web-client.zh.md +95 -0
- package/dsh-docs/subsystems/web-server.md +154 -0
- package/dsh-docs/subsystems/web-server.zh.md +154 -0
- package/dsh-docs/subsystems/web.md +206 -0
- package/dsh-docs/subsystems/web.zh.md +206 -0
- package/dsh-docs/subsystems/webhook.md +70 -0
- package/dsh-docs/subsystems/webhook.zh.md +70 -0
- package/dsh-docs/subsystems/workflow.md +278 -0
- package/dsh-docs/subsystems/workflow.zh.md +278 -0
- package/dsh-docs/subsystems/workspace.md +321 -0
- package/dsh-docs/subsystems/workspace.zh.md +321 -0
- package/dsh-docs/testing.md +54 -0
- package/dsh-docs/testing.zh.md +54 -0
- package/dsh-docs/tool-catalog.md +2225 -0
- package/dsh-docs/tool-catalog.zh.md +2233 -0
- package/dsh-docs/tool-execution-pipeline.md +62 -0
- package/dsh-docs/tool-execution-pipeline.zh.md +64 -0
- package/dsh-docs/user/develop/basic/config.md +106 -0
- package/dsh-docs/user/develop/basic/config.zh.md +106 -0
- package/dsh-docs/user/develop/basic/index.md +144 -0
- package/dsh-docs/user/develop/basic/index.zh.md +144 -0
- package/dsh-docs/user/develop/basic/publish.md +183 -0
- package/dsh-docs/user/develop/basic/publish.zh.md +183 -0
- package/dsh-docs/user/develop/basic/tool.md +52 -0
- package/dsh-docs/user/develop/basic/tool.zh.md +52 -0
- package/dsh-docs/user/develop/framework/events.md +143 -0
- package/dsh-docs/user/develop/framework/events.zh.md +143 -0
- package/dsh-docs/user/develop/framework/index.md +137 -0
- package/dsh-docs/user/develop/framework/index.zh.md +137 -0
- package/dsh-docs/user/develop/framework/service.md +148 -0
- package/dsh-docs/user/develop/framework/service.zh.md +150 -0
- package/dsh-docs/user/develop/practice/dynamic-cordis.md +15 -0
- package/dsh-docs/user/develop/practice/dynamic-cordis.zh.md +15 -0
- package/dsh-docs/user/develop/practice/index.md +155 -0
- package/dsh-docs/user/develop/practice/index.zh.md +155 -0
- package/dsh-docs/user/develop/practice/llm-adapter.md +189 -0
- package/dsh-docs/user/develop/practice/llm-adapter.zh.md +189 -0
- package/dsh-docs/user/guide/github-review.md +102 -0
- package/dsh-docs/user/guide/github-review.zh.md +102 -0
- package/dsh-docs/user/guide/index.md +30 -0
- package/dsh-docs/user/guide/index.zh.md +30 -0
- package/dsh-docs/user/guide/mcp-memory.md +101 -0
- package/dsh-docs/user/guide/mcp-memory.zh.md +101 -0
- package/dsh-docs/user/guide/network-proxy.md +85 -0
- package/dsh-docs/user/guide/network-proxy.zh.md +85 -0
- package/dsh-docs/user/guide/providers.md +190 -0
- package/dsh-docs/user/guide/providers.zh.md +190 -0
- package/dsh-docs/user/guide/python-sdk.md +150 -0
- package/dsh-docs/user/guide/python-sdk.zh.md +150 -0
- package/dsh-docs/user/guide/schedule.md +21 -0
- package/dsh-docs/user/guide/schedule.zh.md +21 -0
- package/dsh-docs/user/index.md +11 -0
- package/dsh-docs/user/index.zh.md +11 -0
- package/dsh-docs/web-styling.md +29 -0
- package/dsh-docs/web-styling.zh.md +29 -0
- package/lib/client/index.js +268 -38
- package/lib/fs-aware/sandbox-plugin.js +1 -1
- package/lib/index.js +1112 -1261
- package/lib/lsp-server-registry-B8DNonhS.js +3 -0
- package/lib/lsp-server-registry-BexQagaK.js +943 -0
- package/lib/{wrap-DC8O3SYz.js → wrap-JFjcWwZf.js} +42 -16
- package/package.json +2 -1
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
# User Settings
|
|
2
|
+
|
|
3
|
+
English | [中文](settings.zh.md)
|
|
4
|
+
|
|
5
|
+
The user-settings seam of [dsh-settings](../../packages/settings/settings) holds one user-owned document of per-namespace sections and resolves each registered namespace as schema defaults, then the registrant's composition `base`, then the user section. Providers such as [dsh-settings-file](../../packages/settings/settings-file) store the raw document and push external edits; consumer plugins register a schema and read or observe the resolved value. Composition config stays in `cordis.yml` — a namespace carries only the user-editable subset.
|
|
6
|
+
|
|
7
|
+
Source: [`packages/settings/settings/src/index.ts`](../../packages/settings/settings/src/index.ts)
|
|
8
|
+
|
|
9
|
+
## Identity
|
|
10
|
+
|
|
11
|
+
A namespace names one plugin-owned section of the user document. The brand prevents callers from mixing settings namespaces with other ids passed between packages or processes; construction validates lowercase kebab-case syntax.
|
|
12
|
+
|
|
13
|
+
```ts type-equiv
|
|
14
|
+
/** Nominal id of one registered settings namespace. */
|
|
15
|
+
type SettingsNamespace = Branded<'SettingsNamespace'>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Registration
|
|
19
|
+
|
|
20
|
+
Registration binds a schemastery schema to a namespace on the calling plugin's fiber — disposing that fiber removes the namespace and its observers. The options carry the composition layer, the owner's effect timing, and an optional check for what the schema cannot express.
|
|
21
|
+
|
|
22
|
+
```ts type-equiv
|
|
23
|
+
/** Registration options beyond the namespace schema. */
|
|
24
|
+
interface SettingsRegisterOptions<T> {
|
|
25
|
+
/** Composition-layer values resolved below the user layer (entry-config subset). */
|
|
26
|
+
base?: Partial<T>
|
|
27
|
+
/** Owner's effect timing, surfaced to configuration UIs; defaults to `live`. */
|
|
28
|
+
applies?: SettingsApplies
|
|
29
|
+
/**
|
|
30
|
+
* Reject a resolved section the owner could not act on, for constraints its
|
|
31
|
+
* schema cannot express — a cross-field requirement, or one field's validity
|
|
32
|
+
* depending on another's. Throwing here refuses the *write* that produced the
|
|
33
|
+
* value, so a caller learns at `update`/`replace`/`mutate` instead of storing
|
|
34
|
+
* something that would silently disable the owner.
|
|
35
|
+
*
|
|
36
|
+
* Kept separate from the schema because the schema is also what a
|
|
37
|
+
* configuration surface renders and what an absent section resolves through;
|
|
38
|
+
* folding a cross-field check into it would change both.
|
|
39
|
+
*
|
|
40
|
+
* Once the owner is registered, a stored section that fails this keeps the
|
|
41
|
+
* namespace's last good value and warns, exactly as a schema failure does,
|
|
42
|
+
* so an externally edited document cannot strand a running owner. At
|
|
43
|
+
* registration there is no last good value yet, so a stored section that
|
|
44
|
+
* already fails rejects the registration itself — again exactly as a schema
|
|
45
|
+
* failure does.
|
|
46
|
+
* @param value - the resolved section, schema-valid by construction.
|
|
47
|
+
*/
|
|
48
|
+
validate?: (value: T) => void
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`validate` runs after the schema admits a value, so it sees defaults and the composition base exactly as the owner will. `dsh-llm-pi-ai` uses it to refuse a provider profile it could not serve at the write that produced it, rather than storing one that would disable every route in its namespace.
|
|
53
|
+
|
|
54
|
+
`applies` is a UI hint, not a mechanism: a `restart` owner never watches, so its value is read once at construction and configuration surfaces can badge the pending change.
|
|
55
|
+
|
|
56
|
+
```ts type-equiv
|
|
57
|
+
/** When a namespace's changes take effect for its owner. */
|
|
58
|
+
type SettingsApplies = 'live' | 'restart'
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Owner scope
|
|
62
|
+
|
|
63
|
+
The scope is the owner-facing handle. `update` merges a sparse patch over the user section only (never into `base`); `replace` sets the section wholesale, which is the removal/reset path — keys absent from the replacement re-inherit `base` and schema defaults. Writes to one namespace are serialized in call order, and resolved values are deep-frozen snapshots.
|
|
64
|
+
|
|
65
|
+
```ts type-equiv
|
|
66
|
+
/** Owner-facing handle for one registered namespace. */
|
|
67
|
+
interface SettingsScope<T> {
|
|
68
|
+
/** Current resolved value: schema defaults, then `base`, then the user layer. */
|
|
69
|
+
get(): T
|
|
70
|
+
/**
|
|
71
|
+
* Observe committed changes to this namespace's resolved value. Invocations
|
|
72
|
+
* of one callback run asynchronously, one at a time, in commit order; a
|
|
73
|
+
* rejection is contained and logged like a sync throw. After the disposer
|
|
74
|
+
* returns, no further invocation starts — one already queued is skipped;
|
|
75
|
+
* one already started still settles, and service disposal waits for it.
|
|
76
|
+
* @param callback - invoked after each commit with the next and previous values.
|
|
77
|
+
* @returns the disposer removing this observer.
|
|
78
|
+
*/
|
|
79
|
+
watch(callback: (next: T, prev: T) => void | Promise<void>): () => void
|
|
80
|
+
/**
|
|
81
|
+
* Merge a partial patch into this namespace's user layer and persist it.
|
|
82
|
+
* @param patch - plain-object patch over the user section; JSON-compatible data
|
|
83
|
+
* only (non-JSON values reject with their path before anything persists).
|
|
84
|
+
*/
|
|
85
|
+
update(patch: object): Promise<void>
|
|
86
|
+
/**
|
|
87
|
+
* Replace this namespace's user section wholesale; absent keys re-inherit
|
|
88
|
+
* the composition `base` and schema defaults (`replace({})` resets all).
|
|
89
|
+
* @param section - the complete next user section; JSON-compatible data only,
|
|
90
|
+
* as for {@link update}.
|
|
91
|
+
*/
|
|
92
|
+
replace(section: object): Promise<void>
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Descriptors
|
|
97
|
+
|
|
98
|
+
`describe()` serializes every registered namespace for configuration surfaces: the schemastery `toJSON()` envelope drives schema-rendered forms, the resolved value fills them, and the detached `base`/`user` layers let a form mark user-overridden fields by presence. `describe({ redactSecrets: true })` — mandatory on every wire surface — strips `role('secret')` fields from all three layers and enumerates their `{path, set}` slots so a page can render write-only inputs without ever receiving a secret.
|
|
99
|
+
|
|
100
|
+
```ts type-equiv
|
|
101
|
+
/** One registered namespace as surfaced to configuration UIs. */
|
|
102
|
+
interface SettingsDescriptor {
|
|
103
|
+
/** The registered namespace. */
|
|
104
|
+
ns: SettingsNamespace
|
|
105
|
+
/** Serialized schemastery schema (`schema.toJSON()`). */
|
|
106
|
+
schema: unknown
|
|
107
|
+
/** Current resolved value. */
|
|
108
|
+
value: unknown
|
|
109
|
+
/**
|
|
110
|
+
* Monotonic revision of the raw user section this descriptor was read at.
|
|
111
|
+
* Send it back as `expectedRevision` on a write to refuse a stale one.
|
|
112
|
+
*/
|
|
113
|
+
revision: number
|
|
114
|
+
/** Registrant's composition `base` layer (detached), when one was declared. */
|
|
115
|
+
base?: unknown
|
|
116
|
+
/**
|
|
117
|
+
* Raw user section from the stored document (detached), when one exists and
|
|
118
|
+
* is well-formed; a field's presence here is what marks it user-overridden.
|
|
119
|
+
*/
|
|
120
|
+
user?: unknown
|
|
121
|
+
/** Owner's declared effect timing. */
|
|
122
|
+
applies: SettingsApplies
|
|
123
|
+
/** Schema-declared secret positions; present only under `redactSecrets`. */
|
|
124
|
+
secrets?: RedactedSecret[]
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
A caller that holds only the redacted descriptor cannot safely rebuild a section, so removals travel as path ops instead. Each descriptor also carries a `revision` over the raw section; a write may send it back as `expectedRevision`, and one that no longer matches is refused rather than applied over the writer that landed first.
|
|
129
|
+
```ts type-equiv
|
|
130
|
+
/**
|
|
131
|
+
* One path-addressed edit to a namespace's user section. Path mutation exists
|
|
132
|
+
* for a caller holding an INCOMPLETE view of the section — a configuration UI
|
|
133
|
+
* reads the redacted descriptor, which by construction never received the
|
|
134
|
+
* `role('secret')` fields. Such a caller can name the field it means without
|
|
135
|
+
* restating the section: a wholesale `replace` rebuilt from a redacted
|
|
136
|
+
* document silently deletes every secret the wire never returned.
|
|
137
|
+
*/
|
|
138
|
+
type SettingsPathOp =
|
|
139
|
+
| { op: 'set'; path: readonly string[]; value: unknown }
|
|
140
|
+
| { op: 'unset'; path: readonly string[] }
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
```ts type-equiv
|
|
144
|
+
/** Options for {@link SettingsProvider.describe}. */
|
|
145
|
+
interface SettingsDescribeOptions {
|
|
146
|
+
/**
|
|
147
|
+
* Strip `role('secret')` fields from `value`/`base`/`user` and enumerate
|
|
148
|
+
* them in each descriptor's `secrets`. Every wire surface MUST pass this;
|
|
149
|
+
* the verbatim default exists for same-process configuration UIs only.
|
|
150
|
+
*/
|
|
151
|
+
redactSecrets?: boolean
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Change commits
|
|
156
|
+
|
|
157
|
+
Every committed change — an in-process write or an externally observed provider edit — emits `settings/updated (ns, next, prev, source)` after the new value is authoritative, and never when the resolved value is deep-equal. The source tag separates the two entry paths.
|
|
158
|
+
|
|
159
|
+
```ts type-equiv
|
|
160
|
+
/** Origin of one committed settings change. */
|
|
161
|
+
type SettingsUpdateSource = 'update' | 'provider'
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Native document operations
|
|
165
|
+
|
|
166
|
+
`SettingsDocumentOpenValue` confirms that `settings/openSettingsDocument` prepared the provider-owned document and handed it to the native text editor. `AgentPresetDirectoryOpenValue` reports either a completed native handoff or the resolved user-preset directory when desktop opening is unavailable. Neither operation accepts a browser-selected Host path.
|
|
167
|
+
|
|
168
|
+
<!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
|
|
169
|
+
|
|
170
|
+
<a id="cordis-surface"></a>
|
|
171
|
+
|
|
172
|
+
## Cordis API
|
|
173
|
+
|
|
174
|
+
Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnpm run verify-cordis-catalog` in doc-sync; regenerate with `pnpm run gen-cordis-catalog`) — the language sides differ only in locale-specific paired document paths. Signature blocks use a `ts cordis-catalog` fence and keep the original source JSDoc; dispatch modes are defined in the [primer](../cordis-primer.md#dispatch-modes), and the framework-inherited `ctx` API lives in [cordis-api/inherited.md](../cordis-api/inherited.md).
|
|
175
|
+
|
|
176
|
+
<a id="ctxsettings--settingsprovider-abstract-seam"></a>
|
|
177
|
+
|
|
178
|
+
### `ctx.settings` — `SettingsProvider` (abstract seam)
|
|
179
|
+
|
|
180
|
+
Abstract settings service. Providers implement raw-document storage (`load`/`persist`) and push external changes through Settings.publish; the base class owns namespace registration, resolution, validation, change detection, and the `settings/updated` commit event.
|
|
181
|
+
|
|
182
|
+
```ts cordis-catalog
|
|
183
|
+
/**
|
|
184
|
+
* Prepare the provider's user-editable document for a native editor. File
|
|
185
|
+
* providers may materialize an absent document before returning its path;
|
|
186
|
+
* non-file providers return undefined.
|
|
187
|
+
* @returns the absolute local document path, or undefined for non-file storage.
|
|
188
|
+
*/
|
|
189
|
+
prepareDocument(): Promise<string | undefined>
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Register a namespace schema and receive its owner scope. The registration
|
|
193
|
+
* is an effect on the calling plugin's fiber: disposing that fiber removes
|
|
194
|
+
* the namespace and its observers. An invalid stored section fails the
|
|
195
|
+
* registration itself — the earliest point where the schema can judge it.
|
|
196
|
+
* @param ns - unique namespace; duplicate registration fails loud.
|
|
197
|
+
* @param schema - schemastery schema resolving this namespace's value.
|
|
198
|
+
* @param options - composition `base` layer and effect timing.
|
|
199
|
+
* @returns the owner scope for reads, observation, and updates.
|
|
200
|
+
* @throws {TypeError} when `ns` is not a lowercase hyphenated identifier.
|
|
201
|
+
*/
|
|
202
|
+
register<const Namespace extends string, T>( ns: Namespace & SettingsNamespaceInput<Namespace>, schema: z<T>, options?: SettingsRegisterOptions<T>, ): SettingsScope<T>
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Attach one optional-settings consumer to this provider. The consumer
|
|
206
|
+
* registers its composition entry as the base layer while this provider is
|
|
207
|
+
* present, then falls back to that entry if the provider detaches.
|
|
208
|
+
* @param owner - consumer context whose unload suppresses fallback work.
|
|
209
|
+
* @param ns - consumer-owned settings namespace.
|
|
210
|
+
* @param schema - schema resolving the namespace.
|
|
211
|
+
* @param entry - composition entry used as the base and fallback value.
|
|
212
|
+
* @param hooks - source sink, change notification, and optional validation.
|
|
213
|
+
* @throws {TypeError} when `ns` is not a lowercase hyphenated identifier.
|
|
214
|
+
*/
|
|
215
|
+
installSection<const Namespace extends string, T>( owner: Context, ns: Namespace & SettingsNamespaceInput<Namespace>, schema: z<T>, entry: T, hooks: SettingsSectionHooks<T>, ): void
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Describe every registered namespace for configuration surfaces, including
|
|
219
|
+
* the composition `base` and raw user layers so a form can mark which fields
|
|
220
|
+
* the user overrode (presence in `user`) and what a reset returns to.
|
|
221
|
+
* @param options - redaction switch; wire surfaces must redact.
|
|
222
|
+
* @returns one descriptor per registered namespace, in registration order.
|
|
223
|
+
*/
|
|
224
|
+
describe(options?: SettingsDescribeOptions): SettingsDescriptor[]
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Read one registered namespace's resolved value.
|
|
228
|
+
* @param ns - the namespace to read.
|
|
229
|
+
* @returns the resolved value, or `undefined` while unregistered.
|
|
230
|
+
* @throws {TypeError} when `ns` is not a lowercase hyphenated identifier.
|
|
231
|
+
*/
|
|
232
|
+
get<const Namespace extends string>(ns: Namespace & SettingsNamespaceInput<Namespace>): unknown
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Merge a patch into one registered namespace's user layer, validate the
|
|
236
|
+
* resolved candidate, persist through the provider, then commit and emit.
|
|
237
|
+
* A validation failure rejects before anything is persisted. Writes to one
|
|
238
|
+
* namespace are serialized: concurrent updates apply in call order, each
|
|
239
|
+
* merging over the previous write's committed section.
|
|
240
|
+
* @param ns - the registered namespace to update.
|
|
241
|
+
* @param patch - plain-object patch over the user section.
|
|
242
|
+
* @param expectedRevision - the descriptor `revision` the caller read; a
|
|
243
|
+
* namespace that moved past it rejects with {@link SettingsConflictError}.
|
|
244
|
+
* @throws {TypeError} when `ns` is not a lowercase hyphenated identifier.
|
|
245
|
+
*/
|
|
246
|
+
async update<const Namespace extends string>( ns: Namespace & SettingsNamespaceInput<Namespace>, patch: object, expectedRevision?: number, ): Promise<void>
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Replace one registered namespace's user section wholesale, validate,
|
|
250
|
+
* persist, then commit and emit. Keys absent from `section` fall back to the
|
|
251
|
+
* composition `base` and schema defaults — this is the removal/reset path a
|
|
252
|
+
* merge-only patch cannot express (`replace({})` re-inherits everything).
|
|
253
|
+
* @param ns - the registered namespace to replace.
|
|
254
|
+
* @param section - the complete next user section.
|
|
255
|
+
* @param expectedRevision - the descriptor `revision` the caller read; a
|
|
256
|
+
* namespace that moved past it rejects with {@link SettingsConflictError}.
|
|
257
|
+
* @throws {TypeError} when `ns` is not a lowercase hyphenated identifier.
|
|
258
|
+
*/
|
|
259
|
+
async replace<const Namespace extends string>( ns: Namespace & SettingsNamespaceInput<Namespace>, section: object, expectedRevision?: number, ): Promise<void>
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Apply path-addressed edits to one registered namespace's user section,
|
|
263
|
+
* validate, persist, then commit and emit. The ops are applied to the
|
|
264
|
+
* section as it stands when the write reaches the front of the queue, so a
|
|
265
|
+
* caller never has to restate fields it did not touch — and, crucially,
|
|
266
|
+
* cannot delete fields it never saw. This is the write path for any caller
|
|
267
|
+
* holding a redacted view; `replace` remains the wholesale reset.
|
|
268
|
+
* @param ns - the registered namespace to edit.
|
|
269
|
+
* @param ops - ordered path edits; later ops observe earlier ones.
|
|
270
|
+
* @param expectedRevision - the descriptor `revision` the caller read; a
|
|
271
|
+
* namespace that moved past it rejects with {@link SettingsConflictError}.
|
|
272
|
+
* @throws {TypeError} when `ns` is not a lowercase hyphenated identifier.
|
|
273
|
+
*/
|
|
274
|
+
async mutate<const Namespace extends string>( ns: Namespace & SettingsNamespaceInput<Namespace>, ops: readonly SettingsPathOp[], expectedRevision?: number, ): Promise<void>
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Source: [`packages/settings/settings/src/index.ts`](../../packages/settings/settings/src/index.ts)
|
|
278
|
+
|
|
279
|
+
<a id="ctxsettingscontroller--settingscontroller"></a>
|
|
280
|
+
|
|
281
|
+
### `ctx.settingsController` — `SettingsController`
|
|
282
|
+
|
|
283
|
+
Host service backing the generated `ctx.remote.settings` namespace. Every remote read uses `redactSecrets: true`, so a `role('secret')` field cannot ride a response. Writes expose the settings service's merge, replacement, and path-addressed operations, and classify every provider refusal as `settings/conflict` or `settings/rejected` with the service's message.
|
|
284
|
+
|
|
285
|
+
```ts cordis-catalog
|
|
286
|
+
/**
|
|
287
|
+
* Describe every registered namespace for a configuration page: redacted
|
|
288
|
+
* layered values plus the serialized schema the page renders its form from.
|
|
289
|
+
* @returns provider writability, local-document presence, and one view per namespace.
|
|
290
|
+
* @throws RemoteError when no settings provider is mounted.
|
|
291
|
+
*/
|
|
292
|
+
@Remote describe(): SettingsDescribeValue
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Report whether this deployment can open an authored Agent preset directory natively.
|
|
296
|
+
* @returns true when the matching open operation is available.
|
|
297
|
+
*/
|
|
298
|
+
@Remote canOpenAgentPresetDirectory(): boolean
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Merge a patch into one namespace's stored user section.
|
|
302
|
+
* @param ns - namespace key to write.
|
|
303
|
+
* @param patch - fields to merge into the user section.
|
|
304
|
+
* @param expectedRevision - revision the caller read; `undefined` writes unconditionally.
|
|
305
|
+
* @returns the namespace's redacted view after the write.
|
|
306
|
+
* @throws RemoteError when the request is invalid, no provider is mounted, or the provider refuses the write.
|
|
307
|
+
*/
|
|
308
|
+
@Remote update( ns: string, patch: Record<string, JsonValue>, expectedRevision: number | undefined, ): Promise<SettingsNamespaceView>
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Replace one namespace's stored user section wholesale.
|
|
312
|
+
* @param ns - namespace key to write.
|
|
313
|
+
* @param section - complete replacement user section.
|
|
314
|
+
* @param expectedRevision - revision the caller read; `undefined` writes unconditionally.
|
|
315
|
+
* @returns the namespace's redacted view after the write.
|
|
316
|
+
* @throws RemoteError when the request is invalid, no provider is mounted, or the provider refuses the write.
|
|
317
|
+
*/
|
|
318
|
+
@Remote replace( ns: string, section: Record<string, JsonValue>, expectedRevision: number | undefined, ): Promise<SettingsNamespaceView>
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Apply path-addressed edits to one namespace's user section, resolved against
|
|
322
|
+
* the section as stored rather than against whatever the caller last read,
|
|
323
|
+
* then answer with that namespace's new redacted view.
|
|
324
|
+
* @param ns - namespace key to write.
|
|
325
|
+
* @param ops - the edits to apply, in order.
|
|
326
|
+
* @param expectedRevision - revision the caller read; `undefined` writes unconditionally.
|
|
327
|
+
* @returns the namespace's redacted view after the write.
|
|
328
|
+
* @throws RemoteError when the request is invalid, no provider is mounted, or the provider refuses the write.
|
|
329
|
+
*/
|
|
330
|
+
@Remote async mutate( ns: string, ops: SettingsPathOpView[], expectedRevision: number | undefined, ): Promise<SettingsNamespaceView>
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Materialize the provider-owned settings document and open it in a native text editor.
|
|
334
|
+
* @param signal - caller lifetime; abort terminates preparation or the native command.
|
|
335
|
+
* @returns confirmation after the native opener accepts the document.
|
|
336
|
+
* @throws RemoteError when no document exists, preparation fails, or opening fails.
|
|
337
|
+
*/
|
|
338
|
+
@Remote async openSettingsDocument(signal: AbortSignal): Promise<SettingsDocumentOpenValue>
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Open one user-authored Agent preset directory or return its path when no native opener exists.
|
|
342
|
+
* @param agentPreset - preset id resolved against Host-owned roots.
|
|
343
|
+
* @param signal - caller lifetime; abort terminates the native command.
|
|
344
|
+
* @returns an opened confirmation or the resolved directory for text display.
|
|
345
|
+
* @throws RemoteError when the preset is missing, read-only, invalid, or cannot be opened.
|
|
346
|
+
*/
|
|
347
|
+
@Remote async openAgentPresetDirectory( agentPreset: string, signal: AbortSignal, ): Promise<AgentPresetDirectoryOpenValue>
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
Source: [`packages/api/settings-controller/src/index.ts`](../../packages/api/settings-controller/src/index.ts)
|
|
351
|
+
|
|
352
|
+
<a id="settings-events"></a>
|
|
353
|
+
|
|
354
|
+
### `settings/*` events
|
|
355
|
+
|
|
356
|
+
<a id="settingsdocument-updated--emit"></a>
|
|
357
|
+
|
|
358
|
+
#### `settings/document-updated` — emit
|
|
359
|
+
|
|
360
|
+
One registered namespace's RAW user section changed, whether or not the resolved value did. `settings/updated` is the consumer-facing event and stays deep-equal-gated; this one exists for configuration surfaces, which must learn that a field went from inherited to overridden (same resolved value, different meaning) and that their held revision is stale. Listener containment matches `settings/updated`.
|
|
361
|
+
|
|
362
|
+
```ts cordis-catalog
|
|
363
|
+
/**
|
|
364
|
+
* One registered namespace's RAW user section changed, whether or not the
|
|
365
|
+
* resolved value did. `settings/updated` is the consumer-facing event and
|
|
366
|
+
* stays deep-equal-gated; this one exists for configuration surfaces,
|
|
367
|
+
* which must learn that a field went from inherited to overridden (same
|
|
368
|
+
* resolved value, different meaning) and that their held revision is
|
|
369
|
+
* stale. Listener containment matches `settings/updated`.
|
|
370
|
+
* @param ns - the namespace whose stored section changed.
|
|
371
|
+
* @param revision - the namespace's new revision.
|
|
372
|
+
* @mode emit
|
|
373
|
+
*/
|
|
374
|
+
'settings/document-updated'(ns: SettingsNamespace, revision: number): void
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Source: [`packages/settings/settings/src/types.ts`](../../packages/settings/settings/src/types.ts)
|
|
378
|
+
|
|
379
|
+
<a id="settingsupdated--emit"></a>
|
|
380
|
+
|
|
381
|
+
#### `settings/updated` — emit
|
|
382
|
+
|
|
383
|
+
Committed change to one registered namespace's resolved value. Emitted after the provider persisted (for `update`) or published (`provider`) the change; never emitted when the resolved value is deep-equal. Listener failures are contained and logged — a sync throw and an async rejection alike — except `INVARIANT`-coded failures, which rethrow after every listener ran; that rethrow reaches the emitter only from synchronous listeners, so invariant checks on this event must not be async functions.
|
|
384
|
+
|
|
385
|
+
```ts cordis-catalog
|
|
386
|
+
/**
|
|
387
|
+
* Committed change to one registered namespace's resolved value. Emitted
|
|
388
|
+
* after the provider persisted (for `update`) or published (`provider`)
|
|
389
|
+
* the change; never emitted when the resolved value is deep-equal.
|
|
390
|
+
* Listener failures are contained and logged — a sync throw and an async
|
|
391
|
+
* rejection alike — except `INVARIANT`-coded failures, which rethrow
|
|
392
|
+
* after every listener ran; that rethrow reaches the emitter only from
|
|
393
|
+
* synchronous listeners, so invariant checks on this event must not be
|
|
394
|
+
* async functions.
|
|
395
|
+
* @param ns - the namespace whose resolved value changed.
|
|
396
|
+
* @param next - the new resolved value.
|
|
397
|
+
* @param prev - the previous resolved value.
|
|
398
|
+
* @param source - whether the change entered through `update()` or the provider.
|
|
399
|
+
* @mode emit
|
|
400
|
+
*/
|
|
401
|
+
'settings/updated'(ns: SettingsNamespace, next: unknown, prev: unknown, source: SettingsUpdateSource): void
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
Source: [`packages/settings/settings/src/types.ts`](../../packages/settings/settings/src/types.ts)
|
|
405
|
+
<!-- END GENERATED cordis-surface -->
|