@cleocode/contracts 2026.6.11 → 2026.6.13

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 (136) hide show
  1. package/dist/__tests__/operation-def.test.js +2 -1
  2. package/dist/__tests__/operation-def.test.js.map +1 -1
  3. package/dist/__tests__/sealed-credential.test.d.ts +19 -0
  4. package/dist/__tests__/sealed-credential.test.d.ts.map +1 -0
  5. package/dist/__tests__/sealed-credential.test.js +74 -0
  6. package/dist/__tests__/sealed-credential.test.js.map +1 -0
  7. package/dist/__tests__/skill-executor-contract.test.js +3 -0
  8. package/dist/__tests__/skill-executor-contract.test.js.map +1 -1
  9. package/dist/acceptance-gate.d.ts +2 -3
  10. package/dist/acceptance-gate.d.ts.map +1 -1
  11. package/dist/boundary.d.ts.map +1 -1
  12. package/dist/boundary.js +1 -19
  13. package/dist/boundary.js.map +1 -1
  14. package/dist/config.d.ts +102 -0
  15. package/dist/config.d.ts.map +1 -1
  16. package/dist/data-accessor.d.ts +21 -1
  17. package/dist/data-accessor.d.ts.map +1 -1
  18. package/dist/data-accessor.js.map +1 -1
  19. package/dist/dispatch/identity.d.ts +1 -1
  20. package/dist/dispatch/identity.d.ts.map +1 -1
  21. package/dist/dispatch/identity.js +5 -0
  22. package/dist/dispatch/identity.js.map +1 -1
  23. package/dist/dispatch/operations-registry.d.ts.map +1 -1
  24. package/dist/dispatch/operations-registry.js +46 -168
  25. package/dist/dispatch/operations-registry.js.map +1 -1
  26. package/dist/docs/read.d.ts +2 -2
  27. package/dist/index.d.ts +12 -7
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +3 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/lease-ipc/__tests__/freeze.test.d.ts +15 -0
  32. package/dist/lease-ipc/__tests__/freeze.test.d.ts.map +1 -0
  33. package/dist/lease-ipc/__tests__/freeze.test.js +221 -0
  34. package/dist/lease-ipc/__tests__/freeze.test.js.map +1 -0
  35. package/dist/lease-ipc/index.d.ts +17 -0
  36. package/dist/lease-ipc/index.d.ts.map +1 -0
  37. package/dist/lease-ipc/index.js +16 -0
  38. package/dist/lease-ipc/index.js.map +1 -0
  39. package/dist/lease-ipc/messages.d.ts +754 -0
  40. package/dist/lease-ipc/messages.d.ts.map +1 -0
  41. package/dist/lease-ipc/messages.js +383 -0
  42. package/dist/lease-ipc/messages.js.map +1 -0
  43. package/dist/lease-ipc/version.d.ts +41 -0
  44. package/dist/lease-ipc/version.d.ts.map +1 -0
  45. package/dist/lease-ipc/version.js +43 -0
  46. package/dist/lease-ipc/version.js.map +1 -0
  47. package/dist/llm/interfaces.d.ts +23 -0
  48. package/dist/llm/interfaces.d.ts.map +1 -1
  49. package/dist/llm/sealed-credential.d.ts +164 -0
  50. package/dist/llm/sealed-credential.d.ts.map +1 -0
  51. package/dist/llm/sealed-credential.js +43 -0
  52. package/dist/llm/sealed-credential.js.map +1 -0
  53. package/dist/llm/system-of-use.d.ts +383 -0
  54. package/dist/llm/system-of-use.d.ts.map +1 -0
  55. package/dist/llm/system-of-use.js +238 -0
  56. package/dist/llm/system-of-use.js.map +1 -0
  57. package/dist/llm/system-resolver.d.ts +45 -11
  58. package/dist/llm/system-resolver.d.ts.map +1 -1
  59. package/dist/llm/system-resolver.js +14 -7
  60. package/dist/llm/system-resolver.js.map +1 -1
  61. package/dist/operations/__tests__/ensures-schema-registry.test.d.ts +17 -0
  62. package/dist/operations/__tests__/ensures-schema-registry.test.d.ts.map +1 -0
  63. package/dist/operations/__tests__/ensures-schema-registry.test.js +113 -0
  64. package/dist/operations/__tests__/ensures-schema-registry.test.js.map +1 -0
  65. package/dist/operations/ensures-schema-registry.d.ts +172 -0
  66. package/dist/operations/ensures-schema-registry.d.ts.map +1 -0
  67. package/dist/operations/ensures-schema-registry.js +226 -0
  68. package/dist/operations/ensures-schema-registry.js.map +1 -0
  69. package/dist/operations/llm.d.ts +101 -9
  70. package/dist/operations/llm.d.ts.map +1 -1
  71. package/dist/operations/validate.d.ts +1 -12
  72. package/dist/operations/validate.d.ts.map +1 -1
  73. package/dist/operations/validate.js +1 -1
  74. package/dist/playbook.d.ts +60 -0
  75. package/dist/playbook.d.ts.map +1 -1
  76. package/dist/session.d.ts +11 -0
  77. package/dist/session.d.ts.map +1 -1
  78. package/dist/session.js.map +1 -1
  79. package/dist/templates/manifest.d.ts +1 -1
  80. package/dist/tools/agent-tools.d.ts +231 -0
  81. package/dist/tools/agent-tools.d.ts.map +1 -0
  82. package/dist/tools/agent-tools.js +25 -0
  83. package/dist/tools/agent-tools.js.map +1 -0
  84. package/dist/tools/atomic.d.ts +19 -0
  85. package/dist/tools/atomic.d.ts.map +1 -1
  86. package/dist/tools/atomic.js +17 -0
  87. package/dist/tools/atomic.js.map +1 -1
  88. package/dist/tools/index.d.ts +2 -0
  89. package/dist/tools/index.d.ts.map +1 -1
  90. package/dist/tools/skill-executor.d.ts +7 -0
  91. package/dist/tools/skill-executor.d.ts.map +1 -1
  92. package/dist/tools/web-tools.d.ts +217 -0
  93. package/dist/tools/web-tools.d.ts.map +1 -0
  94. package/dist/tools/web-tools.js +31 -0
  95. package/dist/tools/web-tools.js.map +1 -0
  96. package/package.json +6 -2
  97. package/src/__tests__/__snapshots__/operations-registry.test.ts.snap +1 -1
  98. package/src/__tests__/operation-def.test.ts +2 -1
  99. package/src/__tests__/sealed-credential.test.ts +100 -0
  100. package/src/__tests__/skill-executor-contract.test.ts +3 -0
  101. package/src/acceptance-gate.ts +2 -3
  102. package/src/boundary.ts +1 -20
  103. package/src/config.ts +104 -0
  104. package/src/data-accessor.ts +22 -1
  105. package/src/dispatch/identity.ts +5 -0
  106. package/src/dispatch/operations-registry.ts +51 -170
  107. package/src/index.ts +103 -24
  108. package/src/lease-ipc/__tests__/freeze.test.ts +246 -0
  109. package/src/lease-ipc/index.ts +63 -0
  110. package/src/lease-ipc/messages.ts +471 -0
  111. package/src/lease-ipc/version.ts +46 -0
  112. package/src/llm/interfaces.ts +23 -0
  113. package/src/llm/sealed-credential.ts +166 -0
  114. package/src/llm/system-of-use.ts +503 -0
  115. package/src/llm/system-resolver.ts +46 -11
  116. package/src/operations/__tests__/ensures-schema-registry.test.ts +169 -0
  117. package/src/operations/ensures-schema-registry.ts +260 -0
  118. package/src/operations/llm.ts +105 -8
  119. package/src/operations/validate.ts +1 -14
  120. package/src/playbook.ts +61 -0
  121. package/src/session.ts +11 -0
  122. package/src/tools/agent-tools.ts +270 -0
  123. package/src/tools/atomic.ts +21 -0
  124. package/src/tools/index.ts +46 -0
  125. package/src/tools/skill-executor.ts +7 -0
  126. package/src/tools/web-tools.ts +247 -0
  127. package/dist/tessera.d.ts +0 -32
  128. package/dist/tessera.d.ts.map +0 -1
  129. package/dist/tessera.js +0 -11
  130. package/dist/tessera.js.map +0 -1
  131. package/dist/warp-chain.d.ts +0 -129
  132. package/dist/warp-chain.d.ts.map +0 -1
  133. package/dist/warp-chain.js +0 -13
  134. package/dist/warp-chain.js.map +0 -1
  135. package/src/tessera.ts +0 -35
  136. package/src/warp-chain.ts +0 -185
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Sealed credential handle — the E10 on-demand-decrypt contract (T11752).
3
+ *
4
+ * ## Why a sealed handle exists
5
+ *
6
+ * Until E10, a resolved credential carried the secret **inline** as a bare
7
+ * `apiKey: string` field on `CredentialResultWire` / `ResolvedLLM`. That
8
+ * plaintext token traveled up the entire resolution call stack — through
9
+ * `resolveLLMForRole` → `resolveLLMForSystem` → consumers — where it could be
10
+ * accidentally logged, serialized into a LAFS envelope, or copied into a
11
+ * diagnostic. Every layer that merely *routed* the credential to the wire still
12
+ * had structural read access to the plaintext.
13
+ *
14
+ * A {@link SealedCredential} inverts that. The resolver returns an **opaque
15
+ * handle** that names the credential (`provider` + `account`) and exposes a
16
+ * single asynchronous {@link SealedCredential.fetch} method. The plaintext token
17
+ * is materialized ONLY when `fetch()` is invoked — and by E10 design that call
18
+ * happens at exactly two trust boundaries:
19
+ *
20
+ * 1. the wire — `transportForProvider` / `session-factory.ts` immediately
21
+ * before building the provider transport / auth headers, or
22
+ * 2. daemon worker-injection — the daemon brokering a short-lived credential
23
+ * into a spawned agent.
24
+ *
25
+ * Between the resolver and those boundaries, NO layer holds a plaintext secret;
26
+ * it holds a handle whose `fetch()` is the sole decryption chokepoint.
27
+ *
28
+ * ## Types-only (Gate 10 contracts purity)
29
+ *
30
+ * This module is **types-only**. {@link SealedCredential.fetch} is a
31
+ * *function-typed field* on an interface — a declaration of shape, NOT a bodied
32
+ * runtime function — so it satisfies the contracts-purity gate
33
+ * (`lint-no-runtime-in-contracts`). The concrete implementation of `fetch()`
34
+ * (the actual `crypto/credentials.ts` decrypt + the vault/daemon round-trip)
35
+ * lives in `@cleocode/core` — never in contracts.
36
+ *
37
+ * @module llm/sealed-credential
38
+ * @task T11752
39
+ * @epic T11746
40
+ * @see ADR-072 §Type lock-in
41
+ */
42
+ import type { ProviderId } from './provider-id.js';
43
+ /**
44
+ * The plaintext secret materialized by {@link SealedCredential.fetch}.
45
+ *
46
+ * ## Branded so it cannot be silently created or widened
47
+ *
48
+ * `DecryptedToken` is a *branded* string: an opaque nominal type produced ONLY
49
+ * by the core decrypt chokepoint inside {@link SealedCredential.fetch}. The
50
+ * `readonly __decryptedToken` brand is a phantom marker — it is NEVER assigned a
51
+ * runtime value (there is no runtime field; this is purely a compile-time
52
+ * nominal tag), so a plain `string` cannot be passed where a `DecryptedToken`
53
+ * is expected, and a `DecryptedToken` is not assignable to an arbitrary
54
+ * `string` sink without an explicit, auditable read of `.value`.
55
+ *
56
+ * ## NEVER serialized
57
+ *
58
+ * A `DecryptedToken` MUST NEVER be:
59
+ * - returned up the resolver call stack (it exists only transiently inside
60
+ * the `fetch()` consumer at the wire / daemon worker-injection boundary),
61
+ * - placed on any envelope, `NormalizedResponse.providerData`, log line,
62
+ * diagnostic, or `cleo llm whoami` output,
63
+ * - persisted, cached across calls, or held beyond the single transport
64
+ * construction / auth-header build that consumed it.
65
+ *
66
+ * The CI chokepoint lint (`lint-llm-chokepoint`) plus the E10 redaction tests
67
+ * (T11754) enforce that no bare secret string crosses the resolver boundary.
68
+ *
69
+ * Because the brand is phantom (compile-time only) and there is no enumerable
70
+ * runtime field, `JSON.stringify(token)` over the value field yields only the
71
+ * underlying string — which is precisely why callers MUST treat the value as
72
+ * write-once-to-the-wire and never route it into a serializer.
73
+ *
74
+ * @task T11752
75
+ */
76
+ export type DecryptedToken = {
77
+ /**
78
+ * Phantom brand marker — compile-time only, never materialized at runtime.
79
+ * Prevents a plain `string` from being assigned where a {@link DecryptedToken}
80
+ * is required (nominal typing). Reading this field is meaningless at runtime;
81
+ * it exists solely to make the type opaque.
82
+ *
83
+ * @internal
84
+ */
85
+ readonly __decryptedToken: 'DecryptedToken';
86
+ /**
87
+ * The materialized plaintext secret (API key or OAuth bearer token).
88
+ *
89
+ * SECURITY: read this ONLY at the wire (`transportForProvider`) or daemon
90
+ * worker-injection, build the auth header, and discard. NEVER log, serialize,
91
+ * or return it up the stack. Marked `readonly` so a consumer cannot mutate it
92
+ * in place.
93
+ */
94
+ readonly value: string;
95
+ };
96
+ /**
97
+ * An opaque, sealed reference to a credential whose plaintext is fetched on
98
+ * demand at the wire — never carried inline up the resolver stack.
99
+ *
100
+ * The resolver returns this *instead of* a bare `apiKey: string` (E10 ·
101
+ * T11753). Consumers route the handle to the transport boundary unchanged;
102
+ * only the boundary calls {@link fetch} to materialize the
103
+ * {@link DecryptedToken}, build the provider auth headers, and discard the
104
+ * plaintext.
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * // At the wire boundary (session-factory.ts) — the ONLY place fetch() runs.
109
+ * // Prefer `authHeadersFromSealed` (core), which invokes fetch() internally so
110
+ * // the plaintext is never bound to a caller-visible variable:
111
+ * const headers = await authHeadersFromSealed(sealed, authType);
112
+ * // …or, for diagnostics, name the credential WITHOUT materializing it:
113
+ * log.info({ provider: sealed.provider, preview: sealed.tokenPreview });
114
+ * // The full token is NEVER returned, logged, or serialized.
115
+ * ```
116
+ *
117
+ * @task T11752
118
+ */
119
+ export interface SealedCredential {
120
+ /** Provider this credential targets (e.g. `'anthropic'`, `'openai'`). */
121
+ readonly provider: ProviderId;
122
+ /**
123
+ * Account / store-label identifier this handle resolves against (e.g.
124
+ * `'default'`, `'work'`). Names *which* credential the handle points at
125
+ * without revealing its secret — safe to log and serialize.
126
+ */
127
+ readonly account: string;
128
+ /**
129
+ * Non-secret, redacted preview of the underlying credential (e.g. `'…6789'`
130
+ * or `'oat-…6789'` for OAuth). The SOLE token-derived value safe to place on
131
+ * a log line, LAFS envelope, or `cleo llm whoami` diagnostic.
132
+ *
133
+ * SECURITY: this is computed ONCE at seal time from at most the last 4 token
134
+ * characters via the core redaction chokepoint (`tokenPreviewOf`) — it can
135
+ * never be reversed into the plaintext. Diagnostics that need to *name* a
136
+ * credential without materializing it MUST read this field, never call
137
+ * {@link fetch}. The E10 redaction test (T11754 · AC3) asserts that the
138
+ * preview, not the full token, is the only credential-derived string that
139
+ * crosses any logging/diagnostic boundary.
140
+ *
141
+ * @task T11754
142
+ */
143
+ readonly tokenPreview: string;
144
+ /**
145
+ * Materialize the plaintext secret on demand.
146
+ *
147
+ * SECURITY INVARIANT: the returned {@link DecryptedToken} is the ONLY point
148
+ * at which the secret exists in plaintext. Implementations (in
149
+ * `@cleocode/core`) run the `crypto/credentials.ts` decrypt INSIDE this
150
+ * method and MUST be invoked ONLY at the wire (`transportForProvider` /
151
+ * `session-factory.ts`) or daemon worker-injection — never to surface a key
152
+ * up the resolution stack. The result MUST NOT be cached, persisted, logged,
153
+ * or serialized by any caller.
154
+ *
155
+ * This is a *function-typed field on an interface* (a type, not a bodied
156
+ * function), so the declaration is contracts-purity-safe (Gate 10): the body
157
+ * lives in core.
158
+ *
159
+ * @returns The materialized plaintext token, valid only for immediate
160
+ * wire/daemon use.
161
+ */
162
+ readonly fetch: () => Promise<DecryptedToken>;
163
+ }
164
+ //# sourceMappingURL=sealed-credential.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sealed-credential.d.ts","sourceRoot":"","sources":["../../src/llm/sealed-credential.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;;;OAOG;IACH,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C;;;;;;;OAOG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;CAC/C"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Sealed credential handle — the E10 on-demand-decrypt contract (T11752).
3
+ *
4
+ * ## Why a sealed handle exists
5
+ *
6
+ * Until E10, a resolved credential carried the secret **inline** as a bare
7
+ * `apiKey: string` field on `CredentialResultWire` / `ResolvedLLM`. That
8
+ * plaintext token traveled up the entire resolution call stack — through
9
+ * `resolveLLMForRole` → `resolveLLMForSystem` → consumers — where it could be
10
+ * accidentally logged, serialized into a LAFS envelope, or copied into a
11
+ * diagnostic. Every layer that merely *routed* the credential to the wire still
12
+ * had structural read access to the plaintext.
13
+ *
14
+ * A {@link SealedCredential} inverts that. The resolver returns an **opaque
15
+ * handle** that names the credential (`provider` + `account`) and exposes a
16
+ * single asynchronous {@link SealedCredential.fetch} method. The plaintext token
17
+ * is materialized ONLY when `fetch()` is invoked — and by E10 design that call
18
+ * happens at exactly two trust boundaries:
19
+ *
20
+ * 1. the wire — `transportForProvider` / `session-factory.ts` immediately
21
+ * before building the provider transport / auth headers, or
22
+ * 2. daemon worker-injection — the daemon brokering a short-lived credential
23
+ * into a spawned agent.
24
+ *
25
+ * Between the resolver and those boundaries, NO layer holds a plaintext secret;
26
+ * it holds a handle whose `fetch()` is the sole decryption chokepoint.
27
+ *
28
+ * ## Types-only (Gate 10 contracts purity)
29
+ *
30
+ * This module is **types-only**. {@link SealedCredential.fetch} is a
31
+ * *function-typed field* on an interface — a declaration of shape, NOT a bodied
32
+ * runtime function — so it satisfies the contracts-purity gate
33
+ * (`lint-no-runtime-in-contracts`). The concrete implementation of `fetch()`
34
+ * (the actual `crypto/credentials.ts` decrypt + the vault/daemon round-trip)
35
+ * lives in `@cleocode/core` — never in contracts.
36
+ *
37
+ * @module llm/sealed-credential
38
+ * @task T11752
39
+ * @epic T11746
40
+ * @see ADR-072 §Type lock-in
41
+ */
42
+ export {};
43
+ //# sourceMappingURL=sealed-credential.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sealed-credential.js","sourceRoot":"","sources":["../../src/llm/sealed-credential.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG"}
@@ -0,0 +1,383 @@
1
+ /**
2
+ * `SystemOfUse` taxonomy — the structured identity of every CLEO subsystem that
3
+ * may request an LLM through the E9 chokepoint (`resolveLLMForSystem`).
4
+ *
5
+ * ## Why a discriminated descriptor (the hermes `_AUX_TASKS` analog)
6
+ *
7
+ * The first cut of the E9 chokepoint (T11749) accepted a flat string-literal
8
+ * label ({@link SystemOfUseLabel} — `'sentient' | 'memory' | …`). That covered
9
+ * the seven role-mapped background subsystems but had no room for the OTHER
10
+ * axes CLEO routes LLMs along:
11
+ *
12
+ * - **orchestration tiers** (`frontier`/`standard`/`fast`/`local`) — the
13
+ * capability lane a delegated turn runs in, independent of any role;
14
+ * - **tools / skills** — atomic tool primitives and `ct-*` skills that each
15
+ * may pin a model (the hermes `_AUX_TASKS` registry: one entry per named
16
+ * auxiliary task, each with its own provider/model binding);
17
+ * - **cantbook nodes** — per-node model selection inside a `.cantbook` flow;
18
+ * - **spawn units** — orchestrator-spawned worker agents that resolve their
19
+ * own LLM.
20
+ *
21
+ * `SystemOfUse` is the discriminated `{ kind, id }` descriptor that unifies all
22
+ * of these axes under ONE identity type. {@link BUILTIN_SYSTEMS_OF_USE} is the
23
+ * static registry of the well-known systems (orchestration tiers + the seven
24
+ * {@link RoleName}s + the auxiliary systems); `tool:` / `skill:` / `cantbook:` /
25
+ * `spawn-unit:` keys are OPEN — any runtime id is a valid `SystemOfUse` of the
26
+ * corresponding kind without a registry edit (see {@link OPEN_SYSTEM_KEY_PREFIXES}).
27
+ *
28
+ * ## Relationship to the resolver input
29
+ *
30
+ * This descriptor is the *taxonomy / identity* layer. The E9 resolver
31
+ * (`resolveLLMForSystem`) still accepts the ergonomic flat {@link SystemOfUseLabel}
32
+ * for the seven role-mapped background subsystems (its locked contract); this
33
+ * file is the SSoT that label set is derived against ({@link AUX_SYSTEM_IDS}),
34
+ * and the home of the richer descriptor that profile-axis routing (tiers,
35
+ * tools, skills, cantbook nodes, spawn units) keys off.
36
+ *
37
+ * Contracts-purity: this module is **types + `as const` DATA + type guards**
38
+ * only — no runtime logic (Gate 10 · T11418). The runtime encode/decode for the
39
+ * open-axis string keys (`parseSystemKey` / `formatSystemKey`) is intentionally
40
+ * NOT defined here; it lives in `@cleocode/core` so this package stays type-only
41
+ * (this module exposes only the {@link OPEN_SYSTEM_KEY_PREFIXES} DATA those
42
+ * helpers read).
43
+ *
44
+ * @module llm/system-of-use
45
+ * @task T11747
46
+ * @epic T11745
47
+ */
48
+ import type { LlmProviderTransport, RoleName } from '../config.js';
49
+ import type { ProviderTier } from './provider-profile.js';
50
+ /**
51
+ * The axis a {@link SystemOfUse} belongs to — the discriminant of the
52
+ * descriptor union.
53
+ *
54
+ * | Kind | Meaning | Registry |
55
+ * |-----------------|----------------------------------------------------------------|-----------------|
56
+ * | `role` | One of the seven background {@link RoleName}s. | closed (7) |
57
+ * | `orchestration` | A capability tier lane (frontier/standard/fast/local). | closed (4) |
58
+ * | `aux` | A named auxiliary subsystem (hermes `_AUX_TASKS` analog). | closed (~10) |
59
+ * | `tool` | An atomic tool primitive that pins a model. | open (`tool:`) |
60
+ * | `skill` | A `ct-*` skill that pins a model. | open (`skill:`) |
61
+ * | `cantbook-node` | A node inside a `.cantbook` flow. | open (`cantbook:`) |
62
+ * | `spawn-unit` | An orchestrator-spawned worker agent. | open (`spawn-unit:`) |
63
+ *
64
+ * @task T11747
65
+ */
66
+ export type SystemOfUseKind = 'role' | 'orchestration' | 'aux' | 'tool' | 'skill' | 'cantbook-node' | 'spawn-unit';
67
+ /**
68
+ * A subsystem whose identity is one of the seven background {@link RoleName}s.
69
+ *
70
+ * `id` is constrained to {@link RoleName} so the role axis can never drift from
71
+ * the config SSoT.
72
+ *
73
+ * @task T11747
74
+ */
75
+ export interface RoleSystem {
76
+ readonly kind: 'role';
77
+ /** The canonical role name (config SSoT — {@link RoleName}). */
78
+ readonly id: RoleName;
79
+ }
80
+ /**
81
+ * A subsystem identified by an orchestration capability tier.
82
+ *
83
+ * `id` is a {@link ProviderTier} — the lane a delegated/orchestrated turn runs
84
+ * in (frontier flagship reasoning ↔ local on-device), independent of role.
85
+ *
86
+ * @task T11747
87
+ */
88
+ export interface OrchestrationSystem {
89
+ readonly kind: 'orchestration';
90
+ /** Capability tier lane (see {@link ProviderTier}). */
91
+ readonly id: ProviderTier;
92
+ }
93
+ /**
94
+ * A named auxiliary subsystem — the direct analog of a hermes `_AUX_TASKS`
95
+ * entry. Each id (`sentient`, `memory`, `compression`, …) is a stable,
96
+ * code-referenced subsystem that may carry its own model binding.
97
+ *
98
+ * @task T11747
99
+ */
100
+ export interface AuxSystem {
101
+ readonly kind: 'aux';
102
+ /** Stable auxiliary subsystem id (a member of {@link AUX_SYSTEM_IDS}). */
103
+ readonly id: AuxSystemId;
104
+ }
105
+ /**
106
+ * A tool primitive that resolves its own LLM. OPEN id — any atomic tool name is
107
+ * valid (encoded `tool:<name>`), so new tools need no registry edit.
108
+ *
109
+ * @task T11747
110
+ */
111
+ export interface ToolSystem {
112
+ readonly kind: 'tool';
113
+ /** Atomic tool name (free-form runtime id). */
114
+ readonly id: string;
115
+ }
116
+ /**
117
+ * A `ct-*` skill that resolves its own LLM. OPEN id — encoded `skill:<name>`.
118
+ *
119
+ * @task T11747
120
+ */
121
+ export interface SkillSystem {
122
+ readonly kind: 'skill';
123
+ /** Skill name (free-form runtime id). */
124
+ readonly id: string;
125
+ }
126
+ /**
127
+ * A node inside a `.cantbook` flow that resolves its own LLM. OPEN id — encoded
128
+ * `cantbook:<nodeId>`.
129
+ *
130
+ * @task T11747
131
+ */
132
+ export interface CantbookNodeSystem {
133
+ readonly kind: 'cantbook-node';
134
+ /** Cantbook node id (free-form runtime id). */
135
+ readonly id: string;
136
+ }
137
+ /**
138
+ * An orchestrator-spawned worker agent that resolves its own LLM. OPEN id —
139
+ * encoded `spawn-unit:<taskId>` (typically the `T####` it executes).
140
+ *
141
+ * @task T11747
142
+ */
143
+ export interface SpawnUnitSystem {
144
+ readonly kind: 'spawn-unit';
145
+ /** Spawn-unit id, typically the executing task id (free-form runtime id). */
146
+ readonly id: string;
147
+ }
148
+ /**
149
+ * The discriminated `{ kind, id }` identity of any CLEO subsystem that requests
150
+ * an LLM through the E9 chokepoint.
151
+ *
152
+ * Discriminate on {@link SystemOfUseKind} (`system.kind`) to narrow `id` to the
153
+ * axis-specific type. Closed-axis kinds (`role`/`orchestration`/`aux`) carry a
154
+ * typed id; open-axis kinds (`tool`/`skill`/`cantbook-node`/`spawn-unit`) carry
155
+ * a free-form runtime string.
156
+ *
157
+ * @example
158
+ * ```ts
159
+ * const sys: SystemOfUse = { kind: 'tool', id: 'web-search' };
160
+ * if (sys.kind === 'role') {
161
+ * // sys.id is narrowed to RoleName here
162
+ * }
163
+ * ```
164
+ *
165
+ * @task T11747
166
+ * @epic T11745
167
+ */
168
+ export type SystemOfUse = RoleSystem | OrchestrationSystem | AuxSystem | ToolSystem | SkillSystem | CantbookNodeSystem | SpawnUnitSystem;
169
+ /**
170
+ * Value-level SSoT for the seven {@link RoleName}s.
171
+ *
172
+ * The `RoleName` *type* lives in `config.ts`; this `as const` tuple is the
173
+ * single iterable VALUE mirror used to build the registry (and any other
174
+ * `for (const role of ROLE_SYSTEM_IDS)` loop) so the role axis is enumerated
175
+ * from ONE place. A compile-time `satisfies readonly RoleName[]` keeps it
176
+ * locked to the type — adding a role to `RoleName` without extending this tuple
177
+ * is a type error.
178
+ *
179
+ * @task T11747
180
+ */
181
+ export declare const ROLE_SYSTEM_IDS: readonly ["extraction", "consolidation", "derivation", "hygiene", "judgement", "plugin", "compression"];
182
+ /**
183
+ * Value-level SSoT for the user-facing, *enumerable* background {@link RoleName}s
184
+ * — the set `cleo llm whoami` reports and `cleo llm profile` accepts.
185
+ *
186
+ * This is the proper subset of {@link ROLE_SYSTEM_IDS} that excludes the two
187
+ * internal sandbox/utility roles (`plugin`, `compression`): they are resolved
188
+ * by code paths (plugin-scoped single-turn calls, context compression) rather
189
+ * than configured per-call by users, so they are intentionally NOT enumerated
190
+ * by the `whoami` / `profile` CLI surface.
191
+ *
192
+ * Sourcing the `cli-ops.ts` role list from THIS one tuple (instead of a
193
+ * duplicated inline array) is the AC3 "ALL_ROLES from one SSoT" requirement
194
+ * (T11750): the type-checker's `satisfies readonly RoleName[]` keeps every id
195
+ * locked to {@link RoleName}, so the enumerable set can never silently drift
196
+ * from the config vocabulary.
197
+ *
198
+ * @task T11750
199
+ * @epic T11745
200
+ */
201
+ export declare const WHOAMI_ROLE_IDS: readonly ["extraction", "consolidation", "derivation", "hygiene", "judgement"];
202
+ /**
203
+ * The id of a `whoami`-enumerable role — the element type of
204
+ * {@link WHOAMI_ROLE_IDS}.
205
+ *
206
+ * @task T11750
207
+ */
208
+ export type WhoamiRoleId = (typeof WHOAMI_ROLE_IDS)[number];
209
+ /**
210
+ * Value-level SSoT for the four orchestration capability tiers. Mirrors the
211
+ * {@link ProviderTier} type, most→least capable.
212
+ *
213
+ * @task T11747
214
+ */
215
+ export declare const ORCHESTRATION_TIER_IDS: readonly ["frontier", "standard", "fast", "local"];
216
+ /**
217
+ * Value-level SSoT for the auxiliary subsystem ids (the hermes `_AUX_TASKS`
218
+ * key set). These are the stable, code-referenced background subsystems CLEO
219
+ * resolves an LLM for outside the role/tier/tool axes.
220
+ *
221
+ * The seven role-mapped resolver labels in {@link SystemOfUseLabel} are derived
222
+ * from this set plus `default` — keeping the flat resolver vocabulary and the
223
+ * structured taxonomy in lock-step.
224
+ *
225
+ * @task T11747
226
+ */
227
+ export declare const AUX_SYSTEM_IDS: readonly ["sentient", "memory", "task-executor", "deriver", "hygiene", "plugin", "compression", "decision-validator", "title-generation", "embedding"];
228
+ /**
229
+ * The id of a registered auxiliary subsystem — the element type of
230
+ * {@link AUX_SYSTEM_IDS}.
231
+ *
232
+ * @task T11747
233
+ */
234
+ export type AuxSystemId = (typeof AUX_SYSTEM_IDS)[number];
235
+ /**
236
+ * The four OPEN {@link SystemOfUseKind}s and the string-key prefix each is
237
+ * encoded with for transport across string-only boundaries (config keys, CLI
238
+ * args, audit logs). E.g. `{ kind: 'tool', id: 'web-search' }` ↔ `'tool:web-search'`.
239
+ *
240
+ * Declared as DATA so encode/decode never branches on a hardcoded prefix —
241
+ * `@cleocode/core` reads this map (Gate 10 keeps the runtime split out).
242
+ *
243
+ * @task T11747
244
+ */
245
+ export declare const OPEN_SYSTEM_KEY_PREFIXES: {
246
+ readonly tool: "tool:";
247
+ readonly skill: "skill:";
248
+ readonly 'cantbook-node': "cantbook:";
249
+ readonly 'spawn-unit': "spawn-unit:";
250
+ };
251
+ /**
252
+ * The subset of {@link SystemOfUseKind} whose ids are OPEN (any runtime string),
253
+ * encoded via {@link OPEN_SYSTEM_KEY_PREFIXES}.
254
+ *
255
+ * @task T11747
256
+ */
257
+ export type OpenSystemKind = 'tool' | 'skill' | 'cantbook-node' | 'spawn-unit';
258
+ /**
259
+ * Static registry of every well-known (closed-axis) {@link SystemOfUse}: the
260
+ * four orchestration tiers, the seven {@link RoleName}s, and the ~10 auxiliary
261
+ * subsystems — the hermes `_AUX_TASKS` analog as a single typed table.
262
+ *
263
+ * Open-axis systems (`tool:`/`skill:`/`cantbook:`/`spawn-unit:`) are NOT listed
264
+ * here — they are valid without a registry edit (see {@link OPEN_SYSTEM_KEY_PREFIXES}).
265
+ *
266
+ * Built by spreading the three closed-axis value SSoTs so the registry can
267
+ * never drift from {@link ROLE_SYSTEM_IDS} / {@link ORCHESTRATION_TIER_IDS} /
268
+ * {@link AUX_SYSTEM_IDS}.
269
+ *
270
+ * @task T11747
271
+ * @epic T11745
272
+ */
273
+ export declare const BUILTIN_SYSTEMS_OF_USE: readonly (RoleSystem | OrchestrationSystem | AuxSystem)[];
274
+ /**
275
+ * Type guard: is `value` a {@link SystemOfUse} descriptor (a `{ kind, id }`
276
+ * object whose `kind` is a known {@link SystemOfUseKind})?
277
+ *
278
+ * Structural-only — does NOT assert that closed-axis ids are registered (use
279
+ * {@link isBuiltinSystemOfUse} for that); an open-axis or as-yet-unregistered
280
+ * id still passes.
281
+ *
282
+ * @param value - The candidate value.
283
+ * @returns `true` when `value` is shaped like a {@link SystemOfUse}.
284
+ * @task T11747
285
+ */
286
+ export declare function isSystemOfUse(value: unknown): value is SystemOfUse;
287
+ /**
288
+ * Type guard: is `value` a closed-axis {@link SystemOfUse} present in
289
+ * {@link BUILTIN_SYSTEMS_OF_USE} (an exact `kind`+`id` match)?
290
+ *
291
+ * @param value - The candidate value.
292
+ * @returns `true` when `value` is a registered builtin system-of-use.
293
+ * @task T11747
294
+ */
295
+ export declare function isBuiltinSystemOfUse(value: unknown): value is SystemOfUse;
296
+ /**
297
+ * Type guard: is `kind` an OPEN-axis {@link OpenSystemKind} (one whose ids are
298
+ * encoded with an {@link OPEN_SYSTEM_KEY_PREFIXES} prefix)?
299
+ *
300
+ * @param kind - The kind discriminant to test.
301
+ * @returns `true` for `tool` / `skill` / `cantbook-node` / `spawn-unit`.
302
+ * @task T11747
303
+ */
304
+ export declare function isOpenSystemKind(kind: SystemOfUseKind): kind is OpenSystemKind;
305
+ /**
306
+ * The default provider/model binding a runtime-registered {@link SystemOfUse}
307
+ * advertises (T11751 · AC1).
308
+ *
309
+ * `registerSystemOfUse(key, displayName, defaults)` lets a plugin / extension /
310
+ * downstream package declare a NEW system-of-use without a registry edit and
311
+ * give it a default binding. That default is consulted strictly BELOW user
312
+ * config (`llm.systems[key]` / `llm.default` / `llm.defaultProfile`) so the user
313
+ * always wins — it only supplies a binding when the user has configured nothing
314
+ * for that key.
315
+ *
316
+ * Either `profile` (a key of `LlmConfig.profiles`) OR an inline `provider` +
317
+ * `model` tuple supplies the binding; `profile` wins when both are present. An
318
+ * entry that supplies neither a resolvable `profile` nor a complete
319
+ * `provider`+`model` tuple is structurally incomplete and is skipped at
320
+ * resolution time (the chain falls through to implicit-fallback) — never an
321
+ * error.
322
+ *
323
+ * @task T11751
324
+ * @epic T11745
325
+ */
326
+ export interface SystemOfUseDefaults {
327
+ /**
328
+ * Optional reference to a named profile in `LlmConfig.profiles`. When set and
329
+ * resolvable, the named profile's provider/model/credentialLabel win over this
330
+ * entry's inline tuple.
331
+ */
332
+ readonly profile?: string;
333
+ /** Inline LLM provider transport (used when `profile` is absent/unresolvable). */
334
+ readonly provider?: LlmProviderTransport;
335
+ /** Inline full model identifier (used when `profile` is absent/unresolvable). */
336
+ readonly model?: string;
337
+ /**
338
+ * Optional credential label pinning this default to a specific credential pool
339
+ * entry. When omitted, standard priority-based credential resolution applies.
340
+ */
341
+ readonly credentialLabel?: string;
342
+ }
343
+ /**
344
+ * A runtime-registered system-of-use — the merged record surfaced by the
345
+ * profile-picker enumeration (T11751 · AC2).
346
+ *
347
+ * @task T11751
348
+ * @epic T11745
349
+ */
350
+ export interface RegisteredSystemOfUse {
351
+ /** Encoded system-of-use key (e.g. `'sentient'`, `'tool:web-search'`). */
352
+ readonly key: string;
353
+ /** Human-readable display name for the picker surface. */
354
+ readonly displayName: string;
355
+ /** Default binding consulted strictly below user config (user wins). */
356
+ readonly defaults: SystemOfUseDefaults;
357
+ }
358
+ /**
359
+ * One enumerated entry in the merged profile-picker surface (T11751 · AC2).
360
+ *
361
+ * Combines the structured {@link SystemOfUse} identity with its display name and
362
+ * provenance so the TUI/Studio picker can render every well-known builtin AND
363
+ * every runtime-registered system in one list.
364
+ *
365
+ * @task T11751
366
+ * @epic T11745
367
+ */
368
+ export interface SystemOfUsePickerEntry {
369
+ /** Encoded system-of-use key (the picker value). */
370
+ readonly key: string;
371
+ /** Human-readable display name. */
372
+ readonly displayName: string;
373
+ /** Discriminant axis of this system (see {@link SystemOfUseKind}). */
374
+ readonly kind: SystemOfUseKind;
375
+ /** Where this entry came from: a static builtin or a runtime registration. */
376
+ readonly source: 'builtin' | 'registered';
377
+ /**
378
+ * The default binding when `source === 'registered'`. Absent for builtins
379
+ * (their binding is resolved purely from user config + the role/aux mapping).
380
+ */
381
+ readonly defaults?: SystemOfUseDefaults;
382
+ }
383
+ //# sourceMappingURL=system-of-use.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-of-use.d.ts","sourceRoot":"","sources":["../../src/llm/system-of-use.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,eAAe,GACf,KAAK,GACL,MAAM,GACN,OAAO,GACP,eA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