@cleocode/contracts 2026.6.13 → 2026.6.14

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.
Files changed (128) hide show
  1. package/dist/__tests__/operation-def.test.js +4 -1
  2. package/dist/__tests__/operation-def.test.js.map +1 -1
  3. package/dist/__tests__/provider-def.test.d.ts +12 -0
  4. package/dist/__tests__/provider-def.test.d.ts.map +1 -0
  5. package/dist/__tests__/provider-def.test.js +84 -0
  6. package/dist/__tests__/provider-def.test.js.map +1 -0
  7. package/dist/__tests__/service-provider.test.d.ts +17 -0
  8. package/dist/__tests__/service-provider.test.d.ts.map +1 -0
  9. package/dist/__tests__/service-provider.test.js +108 -0
  10. package/dist/__tests__/service-provider.test.js.map +1 -0
  11. package/dist/boundary.d.ts +52 -0
  12. package/dist/boundary.d.ts.map +1 -1
  13. package/dist/boundary.js +23 -0
  14. package/dist/boundary.js.map +1 -1
  15. package/dist/conduit.d.ts +171 -0
  16. package/dist/conduit.d.ts.map +1 -1
  17. package/dist/config/index.d.ts +23 -0
  18. package/dist/config/index.d.ts.map +1 -0
  19. package/dist/config/index.js +22 -0
  20. package/dist/config/index.js.map +1 -0
  21. package/dist/config.d.ts +2 -1
  22. package/dist/config.d.ts.map +1 -1
  23. package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.d.ts +21 -0
  24. package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.d.ts.map +1 -0
  25. package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.js +84 -0
  26. package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.js.map +1 -0
  27. package/dist/dispatch/identity.d.ts +1 -1
  28. package/dist/dispatch/identity.d.ts.map +1 -1
  29. package/dist/dispatch/identity.js +20 -0
  30. package/dist/dispatch/identity.js.map +1 -1
  31. package/dist/dispatch/operation-def.d.ts +20 -0
  32. package/dist/dispatch/operation-def.d.ts.map +1 -1
  33. package/dist/dispatch/operations-registry.d.ts.map +1 -1
  34. package/dist/dispatch/operations-registry.js +1030 -46
  35. package/dist/dispatch/operations-registry.js.map +1 -1
  36. package/dist/index.d.ts +15 -6
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +15 -2
  39. package/dist/index.js.map +1 -1
  40. package/dist/lease-ipc/__tests__/freeze.test.js +92 -0
  41. package/dist/lease-ipc/__tests__/freeze.test.js.map +1 -1
  42. package/dist/lease-ipc/index.d.ts +2 -2
  43. package/dist/lease-ipc/index.d.ts.map +1 -1
  44. package/dist/lease-ipc/index.js +1 -1
  45. package/dist/lease-ipc/index.js.map +1 -1
  46. package/dist/lease-ipc/messages.d.ts +167 -3
  47. package/dist/lease-ipc/messages.d.ts.map +1 -1
  48. package/dist/lease-ipc/messages.js +93 -0
  49. package/dist/lease-ipc/messages.js.map +1 -1
  50. package/dist/llm/catalog-schema.d.ts +242 -0
  51. package/dist/llm/catalog-schema.d.ts.map +1 -0
  52. package/dist/llm/catalog-schema.js +153 -0
  53. package/dist/llm/catalog-schema.js.map +1 -0
  54. package/dist/llm/catalog-schema.json +139 -0
  55. package/dist/llm/index.d.ts +15 -0
  56. package/dist/llm/index.d.ts.map +1 -0
  57. package/dist/llm/index.js +14 -0
  58. package/dist/llm/index.js.map +1 -0
  59. package/dist/llm/oauth.d.ts +16 -2
  60. package/dist/llm/oauth.d.ts.map +1 -1
  61. package/dist/llm/onboarding.d.ts +126 -0
  62. package/dist/llm/onboarding.d.ts.map +1 -0
  63. package/dist/llm/onboarding.js +34 -0
  64. package/dist/llm/onboarding.js.map +1 -0
  65. package/dist/llm/provider-def.d.ts +254 -0
  66. package/dist/llm/provider-def.d.ts.map +1 -0
  67. package/dist/llm/provider-def.js +93 -0
  68. package/dist/llm/provider-def.js.map +1 -0
  69. package/dist/llm/system-resolver.d.ts +42 -0
  70. package/dist/llm/system-resolver.d.ts.map +1 -1
  71. package/dist/operations/admin.d.ts +124 -1
  72. package/dist/operations/admin.d.ts.map +1 -1
  73. package/dist/operations/entities.d.ts +110 -0
  74. package/dist/operations/entities.d.ts.map +1 -0
  75. package/dist/operations/entities.js +695 -0
  76. package/dist/operations/entities.js.map +1 -0
  77. package/dist/operations/llm.d.ts +15 -0
  78. package/dist/operations/llm.d.ts.map +1 -1
  79. package/dist/operations/output-contracts-data.d.ts.map +1 -1
  80. package/dist/operations/output-contracts-data.js +230 -0
  81. package/dist/operations/output-contracts-data.js.map +1 -1
  82. package/dist/operations/service.d.ts +68 -0
  83. package/dist/operations/service.d.ts.map +1 -0
  84. package/dist/operations/service.js +336 -0
  85. package/dist/operations/service.js.map +1 -0
  86. package/dist/operations/tasks.d.ts +109 -0
  87. package/dist/operations/tasks.d.ts.map +1 -1
  88. package/dist/operations/tasks.js.map +1 -1
  89. package/dist/playbook.d.ts +56 -0
  90. package/dist/playbook.d.ts.map +1 -1
  91. package/dist/release/plan.d.ts +5 -5
  92. package/dist/vault/service-provider.d.ts +343 -0
  93. package/dist/vault/service-provider.d.ts.map +1 -0
  94. package/dist/vault/service-provider.js +857 -0
  95. package/dist/vault/service-provider.js.map +1 -0
  96. package/dist/workgraph.d.ts +12 -12
  97. package/package.json +10 -2
  98. package/src/__tests__/__snapshots__/operations-registry.test.ts.snap +1 -1
  99. package/src/__tests__/operation-def.test.ts +6 -1
  100. package/src/__tests__/provider-def.test.ts +93 -0
  101. package/src/__tests__/service-provider.test.ts +129 -0
  102. package/src/boundary.ts +69 -0
  103. package/src/conduit.ts +200 -0
  104. package/src/config/index.ts +35 -0
  105. package/src/config.ts +2 -1
  106. package/src/dispatch/__tests__/tasks-gateway-crud-ops.test.ts +99 -0
  107. package/src/dispatch/identity.ts +20 -0
  108. package/src/dispatch/operation-def.ts +21 -0
  109. package/src/dispatch/operations-registry.ts +1062 -36
  110. package/src/index.ts +137 -1
  111. package/src/lease-ipc/__tests__/freeze.test.ts +96 -0
  112. package/src/lease-ipc/index.ts +12 -0
  113. package/src/lease-ipc/messages.ts +117 -0
  114. package/src/llm/catalog-schema.json +139 -0
  115. package/src/llm/catalog-schema.ts +184 -0
  116. package/src/llm/index.ts +29 -0
  117. package/src/llm/oauth.ts +16 -2
  118. package/src/llm/onboarding.ts +131 -0
  119. package/src/llm/provider-def.ts +291 -0
  120. package/src/llm/system-resolver.ts +45 -0
  121. package/src/operations/admin.ts +144 -0
  122. package/src/operations/entities.ts +758 -0
  123. package/src/operations/llm.ts +15 -0
  124. package/src/operations/output-contracts-data.ts +264 -0
  125. package/src/operations/service.ts +360 -0
  126. package/src/operations/tasks.ts +119 -0
  127. package/src/playbook.ts +56 -0
  128. package/src/vault/service-provider.ts +1137 -0
@@ -0,0 +1,291 @@
1
+ /**
2
+ * Declarative `ProviderDef` contract — the DATA shape of one LLM provider.
3
+ *
4
+ * M3 Provider SSoT (epic T11667 · task T11702). `ProviderDef` is the DECLARATIVE,
5
+ * serializable description of a provider: its identity, aliases, auth methods, wire
6
+ * endpoint (a discriminated union keyed on the `transport` literal), models.dev
7
+ * catalog key, default headers, optional OAuth flow, and a single request-quirk hook
8
+ * signature. It is the contract the `providers` global-DB table (T11703) persists and
9
+ * the alias resolver (T11704) reads.
10
+ *
11
+ * ## ProviderDef vs {@link ProviderProfile} — declarative DATA vs runtime BEHAVIOUR
12
+ *
13
+ * The pre-existing {@link ProviderProfile} (T9262 · T11756) is the RUNTIME provider
14
+ * shape carried in the in-process registry: it bundles live hook FUNCTIONS
15
+ * (`prepareMessages`, `buildExtraBody`, `buildApiKwargsExtras`, `fetchModels`) that
16
+ * cannot be serialized into a DB row. `ProviderDef` is the DECLARATIVE projection of
17
+ * the same provider — only serializable DATA — so it can be a `providers` table row,
18
+ * shipped as a seed, diffed, and resolved without importing provider-specific code.
19
+ * The builtin `ProviderProfile` set is the SEED SOURCE for the builtin `ProviderDef`
20
+ * set (the core mapper derives one from the other); the non-serializable hooks stay
21
+ * on `ProviderProfile`, reduced here to the single declarative {@link RequestQuirk}
22
+ * descriptor that records WHICH quirk a provider needs without embedding a closure.
23
+ *
24
+ * ## Endpoint is a discriminated union (AC5)
25
+ *
26
+ * {@link ProviderEndpoint} is a closed discriminated union keyed on the literal
27
+ * `transport` field — one variant per wire protocol CLEO knows how to speak. No
28
+ * `any`/`unknown` shortcut: every variant carries its own typed fields. This is the
29
+ * declarative analog of {@link ApiMode}; the core transport adapter table (T11767)
30
+ * maps a `transport` value to its `Transport` constructor.
31
+ *
32
+ * ## Contracts purity (Gate 10)
33
+ *
34
+ * This module is TYPES ONLY — interfaces, type aliases, and `as const` literal arrays.
35
+ * It exports NO bodied runtime helper. The builtin-set construction and the seed/upsert
36
+ * logic live in `@cleocode/core` (T11703 · T11704), never here.
37
+ *
38
+ * @module llm/provider-def
39
+ * @task T11702
40
+ * @epic T11667
41
+ * @see ./provider-profile.ts — the RUNTIME provider shape (hooks) this projects from
42
+ * @see ./provider-id.ts — {@link ApiMode} / {@link BuiltinProviderId} the transport mirrors
43
+ * @see ./oauth.ts — {@link ProviderOAuthConfig} the OAuth flow placeholder reuses
44
+ * @see ../../../core/src/store/schema/cleo-global/providers.ts — the persisted table (T11703)
45
+ */
46
+
47
+ import type { StoredAuthTypeWire } from '../operations/llm.js';
48
+ import type { ProviderOAuthConfig } from './oauth.js';
49
+ import type { ProviderId } from './provider-id.js';
50
+
51
+ /**
52
+ * Wire-transport discriminant for a {@link ProviderEndpoint} variant.
53
+ *
54
+ * Closed union — one literal per protocol CLEO has a transport for. The
55
+ * declarative analog of {@link import('./provider-id.js').ApiMode}:
56
+ *
57
+ * - `openai-completions` — OpenAI `/chat/completions` shape (OpenAI, OpenRouter,
58
+ * Moonshot, Kimi, xAI, Gemini-via-OpenAI-compat) — `ApiMode 'chat_completions'`.
59
+ * - `openai-responses` — OpenAI Responses API (Codex backend, xAI-responses) —
60
+ * `ApiMode 'codex_responses'`.
61
+ * - `anthropic-messages` — native Anthropic Messages API (prompt-cache + thinking) —
62
+ * `ApiMode 'anthropic_messages'`.
63
+ * - `aisdk` — routed through the Vercel AI-SDK provider factory (the data-driven
64
+ * `apiMode → provider` adapter, T11767) rather than a bespoke CLEO transport.
65
+ *
66
+ * @task T11702
67
+ */
68
+ export const PROVIDER_TRANSPORTS = [
69
+ 'openai-completions',
70
+ 'openai-responses',
71
+ 'anthropic-messages',
72
+ 'aisdk',
73
+ ] as const;
74
+
75
+ /** TypeScript union derived from {@link PROVIDER_TRANSPORTS}. */
76
+ export type ProviderTransport = (typeof PROVIDER_TRANSPORTS)[number];
77
+
78
+ /**
79
+ * Endpoint for the `openai-completions` transport — the OpenAI
80
+ * `/chat/completions` wire shape (OpenAI, OpenRouter, Moonshot, Kimi, xAI,
81
+ * Gemini-via-compat). `baseUrl` has NO trailing slash.
82
+ *
83
+ * @task T11702
84
+ */
85
+ export interface OpenAICompletionsEndpoint {
86
+ /** Discriminant — the OpenAI chat-completions wire protocol. */
87
+ readonly transport: 'openai-completions';
88
+ /** Base URL for the provider's API — no trailing slash. */
89
+ readonly baseUrl: string;
90
+ }
91
+
92
+ /**
93
+ * Endpoint for the `openai-responses` transport — the OpenAI Responses API
94
+ * (Codex backend, xAI-responses). `baseUrl` has NO trailing slash.
95
+ *
96
+ * @task T11702
97
+ */
98
+ export interface OpenAIResponsesEndpoint {
99
+ /** Discriminant — the OpenAI Responses wire protocol. */
100
+ readonly transport: 'openai-responses';
101
+ /** Base URL for the Responses endpoint — no trailing slash. */
102
+ readonly baseUrl: string;
103
+ }
104
+
105
+ /**
106
+ * Endpoint for the `anthropic-messages` transport — the native Anthropic
107
+ * Messages API (full prompt-cache + extended thinking). `baseUrl` has NO
108
+ * trailing slash.
109
+ *
110
+ * @task T11702
111
+ */
112
+ export interface AnthropicMessagesEndpoint {
113
+ /** Discriminant — the native Anthropic Messages wire protocol. */
114
+ readonly transport: 'anthropic-messages';
115
+ /** Base URL for the Anthropic API — no trailing slash. */
116
+ readonly baseUrl: string;
117
+ }
118
+
119
+ /**
120
+ * Endpoint for the `aisdk` transport — the provider is reached through the
121
+ * Vercel AI-SDK provider factory (the data-driven adapter table, T11767) keyed
122
+ * by `aiSdkProvider`, rather than a bespoke CLEO transport.
123
+ *
124
+ * @task T11702
125
+ */
126
+ export interface AiSdkEndpoint {
127
+ /** Discriminant — routed through the AI-SDK provider factory. */
128
+ readonly transport: 'aisdk';
129
+ /** Base URL passed to the AI-SDK provider factory — no trailing slash. */
130
+ readonly baseUrl: string;
131
+ /**
132
+ * The AI-SDK provider-factory key (e.g. `openai-compatible` | `google` |
133
+ * `bedrock`) the adapter table maps to a `create*` factory. NEVER an inline
134
+ * client construction — the factory call is the LLM chokepoint (T11783).
135
+ */
136
+ readonly aiSdkProvider: string;
137
+ }
138
+
139
+ /**
140
+ * A provider's wire endpoint — a discriminated union keyed on the `transport`
141
+ * literal (AC5). Exactly one variant per {@link ProviderTransport}; each carries
142
+ * its own typed fields, with no `any`/`unknown` shortcut.
143
+ *
144
+ * @task T11702
145
+ */
146
+ export type ProviderEndpoint =
147
+ | OpenAICompletionsEndpoint
148
+ | OpenAIResponsesEndpoint
149
+ | AnthropicMessagesEndpoint
150
+ | AiSdkEndpoint;
151
+
152
+ /**
153
+ * Known request-quirk kinds — the DECLARATIVE record of WHICH provider-specific
154
+ * request adjustment a provider needs, WITHOUT embedding the closure.
155
+ *
156
+ * The live closures stay on {@link ProviderProfile} (`buildExtraBody` /
157
+ * `buildApiKwargsExtras` / `prepareMessages`); a `ProviderDef` row records only
158
+ * the quirk's stable kind so the table/seed stays serializable. The runtime maps
159
+ * a {@link RequestQuirk} `kind` back to its hook implementation.
160
+ *
161
+ * - `grok-conv-id` — inject the process-scoped `x-grok-conv-id` header (xAI).
162
+ * - `gemini-thinking-config` — inject `thinking_config` in `extra_body` (Gemini).
163
+ * - `kimi-reasoning-effort` — top-level `reasoning_effort` kwarg (Kimi Code).
164
+ * - `moonshot-schema-sanitize` — shallow tool-schema sanitization (Moonshot).
165
+ * - `openrouter-pareto` — inject the Pareto price-router plugin (OpenRouter).
166
+ *
167
+ * @task T11702
168
+ */
169
+ export const REQUEST_QUIRK_KINDS = [
170
+ 'grok-conv-id',
171
+ 'gemini-thinking-config',
172
+ 'kimi-reasoning-effort',
173
+ 'moonshot-schema-sanitize',
174
+ 'openrouter-pareto',
175
+ ] as const;
176
+
177
+ /** TypeScript union derived from {@link REQUEST_QUIRK_KINDS}. */
178
+ export type RequestQuirkKind = (typeof REQUEST_QUIRK_KINDS)[number];
179
+
180
+ /**
181
+ * A single declarative request-quirk descriptor (AC4 — the "request-quirk hook
182
+ * signature"). Records the quirk's stable {@link RequestQuirkKind} so a
183
+ * `ProviderDef` row stays serializable; the runtime resolves the `kind` to its
184
+ * hook implementation on {@link ProviderProfile}. The signature the hook MUST
185
+ * satisfy is `(model: string) => Record<string, unknown>` (the declarative shape
186
+ * of `buildExtraBody` / `buildApiKwargsExtras`), captured here only as the
187
+ * documented contract — never as an embedded closure.
188
+ *
189
+ * @task T11702
190
+ */
191
+ export interface RequestQuirk {
192
+ /** The stable quirk kind this provider needs. */
193
+ readonly kind: RequestQuirkKind;
194
+ }
195
+
196
+ /**
197
+ * OAuth flow placeholder embedded on a {@link ProviderDef} (AC4).
198
+ *
199
+ * For M3 this is the existing {@link ProviderOAuthConfig} shape (PKCE / device-code
200
+ * endpoints + client id), aliased so the M4 vault work (T10409) can widen it without
201
+ * a contract rename. A `ProviderDef` carries `oauth` only when the provider supports
202
+ * an OAuth login flow (anthropic, openai, kimi-code); it is omitted otherwise.
203
+ *
204
+ * @task T11702
205
+ */
206
+ export type OAuthFlowDef = ProviderOAuthConfig;
207
+
208
+ /**
209
+ * Declarative description of one LLM provider — the serializable DATA SSoT.
210
+ *
211
+ * The contract persisted as a `providers` table row (T11703) and read by the alias
212
+ * resolver (T11704). Derived from the runtime {@link ProviderProfile} set: identity
213
+ * + aliases + auth + endpoint + catalog key + headers + optional OAuth + the
214
+ * declarative request quirks. Carries NO closures — only serializable DATA.
215
+ *
216
+ * @task T11702
217
+ */
218
+ export interface ProviderDef {
219
+ /**
220
+ * Canonical provider id (lower-cased). For builtins this is a
221
+ * {@link BuiltinProviderId}; plugin providers may use any non-empty string.
222
+ */
223
+ readonly id: ProviderId;
224
+
225
+ /** Human-readable display name shown in pickers and diagnostic output. */
226
+ readonly displayName: string;
227
+
228
+ /**
229
+ * Alternate names that resolve to this provider (case-insensitive). The SINGLE
230
+ * source the alias resolver (T11704) reads — `codex`/`chatgpt` → `openai`,
231
+ * `claude` → `anthropic`, `google` → `gemini`, … An alias colliding with another
232
+ * provider's primary `id` is a resolution error (T11704 AC2).
233
+ */
234
+ readonly aliases: ReadonlyArray<string>;
235
+
236
+ /**
237
+ * Authentication mechanisms this provider supports (`api_key` | `oauth` |
238
+ * `aws_sdk`). The {@link StoredAuthTypeWire} wire enum.
239
+ */
240
+ readonly authMethods: ReadonlyArray<StoredAuthTypeWire>;
241
+
242
+ /**
243
+ * The provider's wire endpoint — a discriminated union keyed on `transport`
244
+ * (AC5). A provider that speaks multiple protocols (e.g. xAI completions +
245
+ * responses) carries the multiple variants in {@link altEndpoints}.
246
+ */
247
+ readonly endpoint: ProviderEndpoint;
248
+
249
+ /**
250
+ * Additional wire endpoints this provider also speaks, beyond the primary
251
+ * {@link endpoint}. Collapses the prior per-ApiMode profile duplication into ONE
252
+ * row (T11703 AC4 — xAI's completions + responses become one `ProviderDef`).
253
+ * Empty/omitted for single-protocol providers.
254
+ */
255
+ readonly altEndpoints?: ReadonlyArray<ProviderEndpoint>;
256
+
257
+ /**
258
+ * The models.dev catalog provider key joining this provider to the
259
+ * `models_catalog` table (T11733). Usually equals {@link id}; carried distinctly
260
+ * because a provider id and its catalog key can differ (e.g. `kimi-code` →
261
+ * `moonshot`).
262
+ */
263
+ readonly modelsDevId: string;
264
+
265
+ /**
266
+ * HTTP headers sent with every request to this provider, merged into the
267
+ * client's `defaultHeaders` (e.g. `{ 'anthropic-version': '2023-06-01' }`).
268
+ * Omitted when the provider needs no pinned headers.
269
+ */
270
+ readonly defaultHeaders?: Readonly<Record<string, string>>;
271
+
272
+ /**
273
+ * Environment variable names that may supply this provider's API key (e.g.
274
+ * `['ANTHROPIC_API_KEY']`). Resolver chains may check these before the vault.
275
+ * Omitted when the provider has no env-var credential path.
276
+ */
277
+ readonly envVars?: ReadonlyArray<string>;
278
+
279
+ /**
280
+ * OAuth flow placeholder (AC4) — present only when the provider supports an
281
+ * OAuth login flow (anthropic, openai, kimi-code). See {@link OAuthFlowDef}.
282
+ */
283
+ readonly oauth?: OAuthFlowDef;
284
+
285
+ /**
286
+ * Declarative request quirks this provider needs (AC4) — the stable
287
+ * {@link RequestQuirk} descriptors WITHOUT the closures (those stay on
288
+ * {@link ProviderProfile}). Empty/omitted when the provider needs no quirk.
289
+ */
290
+ readonly requestQuirks?: ReadonlyArray<RequestQuirk>;
291
+ }
@@ -135,4 +135,49 @@ export interface ResolveLLMForSystemOptions {
135
135
  * @internal
136
136
  */
137
137
  skipCatalogDefault?: boolean;
138
+
139
+ /**
140
+ * Raw prompt used to derive a role from complexity when neither an explicit
141
+ * tier/role nor a role-mapped system label is available (L1 proposer · T11906).
142
+ *
143
+ * When the `system` argument is the flat `'default'` label (which maps to NO
144
+ * role) and `roleOverride` is unset, the resolver runs the L1 complexity
145
+ * classifier over this prompt and proposes a {@link RoleName} from the
146
+ * resulting tier (`low → hygiene`, `mid → consolidation`, `high → judgement`).
147
+ * This is a COMPLEMENT to the resolver — it only supplies a role when one is
148
+ * otherwise absent; an explicit label, descriptor, or `roleOverride` always
149
+ * wins. The classifier returns a TIER only and constructs no LLM client.
150
+ *
151
+ * Ignored when the role is already determined by the input or `roleOverride`.
152
+ */
153
+ complexityPrompt?: string;
154
+
155
+ /**
156
+ * Explicit encoded system-of-use key for the `llm.systems[key]` granular
157
+ * override tier (T11759 · M4).
158
+ *
159
+ * The flat-label input form derives this key from `system` itself; this option
160
+ * lets a caller resolving an OPEN-axis system (whose identity is NOT a flat
161
+ * {@link SystemOfUseLabel}) — e.g. a `.cantbook` node keyed
162
+ * `cantbook:<playbook>#<nodeId>` — supply that identity as the granular
163
+ * override + audit key while passing a resolvable background label as
164
+ * `system`. When set, it OVERRIDES the label-derived key. Omit it and the
165
+ * pre-T11759 derivation is unchanged.
166
+ *
167
+ * @task T11759
168
+ */
169
+ systemKey?: string;
170
+
171
+ /**
172
+ * Optional named profile (a key of `llm.profiles`) that pins the resolution to
173
+ * a specific provider/model/credential, winning over the role tier (T11759 ·
174
+ * M4).
175
+ *
176
+ * Threaded down to `ResolveLLMForRoleOptions.profileOverride`. A `.cantbook`
177
+ * stage's `profile:` flows through here. When the named profile is
178
+ * absent/incomplete, resolution falls through the normal chain unchanged.
179
+ *
180
+ * @task T11759
181
+ */
182
+ profile?: string;
138
183
  }
@@ -380,6 +380,9 @@ export type AdminOp =
380
380
  | 'admin.health'
381
381
  | 'admin.config.show'
382
382
  | 'admin.config.presets'
383
+ | 'admin.config.get'
384
+ | 'admin.config.list'
385
+ | 'admin.config.validate'
383
386
  | 'admin.stats'
384
387
  | 'admin.context'
385
388
  | 'admin.context.pull'
@@ -406,6 +409,7 @@ export type AdminOp =
406
409
  | 'admin.health.mutate'
407
410
  | 'admin.config.set'
408
411
  | 'admin.config.set-preset'
412
+ | 'admin.config.unset'
409
413
  | 'admin.backup.mutate'
410
414
  | 'admin.migrate'
411
415
  | 'admin.cleanup'
@@ -513,6 +517,109 @@ export interface AdminConfigPresetsResult {
513
517
  presets: AdminPresetDefinition[];
514
518
  }
515
519
 
520
+ // ---------------------------------------------------------------------------
521
+ // admin.config.get (T11917 — config-as-domain, ConfigManifest cascade)
522
+ // ---------------------------------------------------------------------------
523
+
524
+ /**
525
+ * Cascade slice selector for the config-as-domain query ops.
526
+ *
527
+ * - `'global'` — read ONLY `~/.cleo/config.json` (precedence 10)
528
+ * - `'project'` — read ONLY `<project>/.cleo/config.json` (precedence 20)
529
+ * - `'merged'` — read the deep-merge `{ ...global, ...project }` (default)
530
+ *
531
+ * Mirrors the `ResolveScope` of the `resolveCleoConfig` cascade resolver.
532
+ *
533
+ * @task T11917
534
+ */
535
+ export type AdminConfigScope = 'global' | 'project' | 'merged';
536
+
537
+ /** Parameters for `admin.config.get`. */
538
+ export interface AdminConfigGetParams {
539
+ /** Dot-notation config key to read a single value (required). */
540
+ key: string;
541
+ /** Cascade slice to read from. Defaults to `'merged'`. */
542
+ scope?: AdminConfigScope;
543
+ }
544
+
545
+ /**
546
+ * Result of `admin.config.get`.
547
+ *
548
+ * Returns the resolved value for `key`, or `null` when the key is absent in the
549
+ * selected cascade slice. `found` disambiguates a present `null` value from an
550
+ * absent key.
551
+ *
552
+ * @task T11917
553
+ */
554
+ export interface AdminConfigGetResult {
555
+ /** The dot-notation key that was resolved. */
556
+ key: string;
557
+ /** Cascade slice the value was resolved against. */
558
+ scope: AdminConfigScope;
559
+ /** Resolved value, or `null` when the key is absent. */
560
+ value: unknown;
561
+ /** `true` IFF the key resolved to a defined value in the cascade. */
562
+ found: boolean;
563
+ }
564
+
565
+ // ---------------------------------------------------------------------------
566
+ // admin.config.list (T11917 — full resolved cascade)
567
+ // ---------------------------------------------------------------------------
568
+
569
+ /** Parameters for `admin.config.list`. */
570
+ export interface AdminConfigListParams {
571
+ /** Cascade slice to project. Defaults to `'merged'`. */
572
+ scope?: AdminConfigScope;
573
+ }
574
+
575
+ /**
576
+ * Result of `admin.config.list`.
577
+ *
578
+ * Returns the full resolved config object for the selected cascade slice plus
579
+ * the flattened dot-notation key list for discovery.
580
+ *
581
+ * @task T11917
582
+ */
583
+ export interface AdminConfigListResult {
584
+ /** Cascade slice the config was resolved against. */
585
+ scope: AdminConfigScope;
586
+ /** Full resolved config object for the slice. */
587
+ config: Record<string, unknown>;
588
+ /** Flattened dot-notation keys present in the resolved config. */
589
+ keys: string[];
590
+ }
591
+
592
+ // ---------------------------------------------------------------------------
593
+ // admin.config.validate (T11917 — schema-validate the cascade entry)
594
+ // ---------------------------------------------------------------------------
595
+
596
+ /** Parameters for `admin.config.validate`. */
597
+ export interface AdminConfigValidateParams {
598
+ /**
599
+ * Scope to validate. Only the cascade-participating scopes are valid —
600
+ * `'merged'` is rejected because validation runs against a single file's
601
+ * manifest entry schema. Defaults to `'project'`.
602
+ */
603
+ scope?: 'global' | 'project';
604
+ }
605
+
606
+ /**
607
+ * Result of `admin.config.validate`.
608
+ *
609
+ * `ok` is `true` IFF the file passed its manifest entry's schema gate (or no
610
+ * schema was configured). `issues` carries human-readable rejection reasons.
611
+ *
612
+ * @task T11917
613
+ */
614
+ export interface AdminConfigValidateResult {
615
+ /** Scope that was validated. */
616
+ scope: 'global' | 'project';
617
+ /** `true` IFF every gate passed. */
618
+ ok: boolean;
619
+ /** Human-readable schema issues. Empty when `ok === true`. */
620
+ issues: string[];
621
+ }
622
+
516
623
  // ---------------------------------------------------------------------------
517
624
  // admin.stats
518
625
  // ---------------------------------------------------------------------------
@@ -1466,6 +1573,35 @@ export interface AdminConfigSetResult {
1466
1573
  value: unknown;
1467
1574
  }
1468
1575
 
1576
+ // ---------------------------------------------------------------------------
1577
+ // admin.config.unset (T11917 — remove a key from a scoped config file)
1578
+ // ---------------------------------------------------------------------------
1579
+
1580
+ /** Parameters for `admin.config.unset`. */
1581
+ export interface AdminConfigUnsetParams {
1582
+ /** Dot-notation config key to remove (required). */
1583
+ key: string;
1584
+ /** Remove from the global file instead of the project file. */
1585
+ global?: boolean;
1586
+ }
1587
+
1588
+ /**
1589
+ * Result of `admin.config.unset`.
1590
+ *
1591
+ * `removed` is `true` IFF the key existed and was deleted; `false` when the key
1592
+ * was already absent (idempotent no-op).
1593
+ *
1594
+ * @task T11917
1595
+ */
1596
+ export interface AdminConfigUnsetResult {
1597
+ /** Config key that was targeted. */
1598
+ key: string;
1599
+ /** Scope the key was removed from. */
1600
+ scope: 'project' | 'global';
1601
+ /** `true` IFF a value was actually deleted. */
1602
+ removed: boolean;
1603
+ }
1604
+
1469
1605
  // ---------------------------------------------------------------------------
1470
1606
  // admin.config.set-preset
1471
1607
  // ---------------------------------------------------------------------------
@@ -1996,6 +2132,13 @@ export type AdminOps =
1996
2132
  params: AdminConfigPresetsParams;
1997
2133
  result: AdminConfigPresetsResult;
1998
2134
  }
2135
+ | { op: 'admin.config.get'; params: AdminConfigGetParams; result: AdminConfigGetResult }
2136
+ | { op: 'admin.config.list'; params: AdminConfigListParams; result: AdminConfigListResult }
2137
+ | {
2138
+ op: 'admin.config.validate';
2139
+ params: AdminConfigValidateParams;
2140
+ result: AdminConfigValidateResult;
2141
+ }
1999
2142
  | { op: 'admin.stats'; params: AdminStatsParams; result: AdminStatsResult }
2000
2143
  | { op: 'admin.context'; params: AdminContextParams; result: AdminContextResult }
2001
2144
  | { op: 'admin.context.pull'; params: AdminContextPullParams; result: AdminContextPullResult }
@@ -2046,6 +2189,7 @@ export type AdminOps =
2046
2189
  params: AdminConfigSetPresetParams;
2047
2190
  result: AdminConfigSetPresetResult;
2048
2191
  }
2192
+ | { op: 'admin.config.unset'; params: AdminConfigUnsetParams; result: AdminConfigUnsetResult }
2049
2193
  | {
2050
2194
  op: 'admin.backup.mutate';
2051
2195
  params: AdminBackupMutateParams;