@cleocode/contracts 2026.6.12 → 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.
- package/dist/__tests__/operation-def.test.js +5 -1
- package/dist/__tests__/operation-def.test.js.map +1 -1
- package/dist/__tests__/provider-def.test.d.ts +12 -0
- package/dist/__tests__/provider-def.test.d.ts.map +1 -0
- package/dist/__tests__/provider-def.test.js +84 -0
- package/dist/__tests__/provider-def.test.js.map +1 -0
- package/dist/__tests__/sealed-credential.test.d.ts +19 -0
- package/dist/__tests__/sealed-credential.test.d.ts.map +1 -0
- package/dist/__tests__/sealed-credential.test.js +74 -0
- package/dist/__tests__/sealed-credential.test.js.map +1 -0
- package/dist/__tests__/service-provider.test.d.ts +17 -0
- package/dist/__tests__/service-provider.test.d.ts.map +1 -0
- package/dist/__tests__/service-provider.test.js +108 -0
- package/dist/__tests__/service-provider.test.js.map +1 -0
- package/dist/__tests__/skill-executor-contract.test.js +3 -0
- package/dist/__tests__/skill-executor-contract.test.js.map +1 -1
- package/dist/acceptance-gate.d.ts +2 -3
- package/dist/acceptance-gate.d.ts.map +1 -1
- package/dist/boundary.d.ts +52 -0
- package/dist/boundary.d.ts.map +1 -1
- package/dist/boundary.js +24 -19
- package/dist/boundary.js.map +1 -1
- package/dist/conduit.d.ts +171 -0
- package/dist/conduit.d.ts.map +1 -1
- package/dist/config/index.d.ts +23 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +22 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config.d.ts +104 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/data-accessor.d.ts +21 -1
- package/dist/data-accessor.d.ts.map +1 -1
- package/dist/data-accessor.js.map +1 -1
- package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.d.ts +21 -0
- package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.d.ts.map +1 -0
- package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.js +84 -0
- package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.js.map +1 -0
- package/dist/dispatch/identity.d.ts +1 -1
- package/dist/dispatch/identity.d.ts.map +1 -1
- package/dist/dispatch/identity.js +25 -0
- package/dist/dispatch/identity.js.map +1 -1
- package/dist/dispatch/operation-def.d.ts +20 -0
- package/dist/dispatch/operation-def.d.ts.map +1 -1
- package/dist/dispatch/operations-registry.d.ts.map +1 -1
- package/dist/dispatch/operations-registry.js +1044 -182
- package/dist/dispatch/operations-registry.js.map +1 -1
- package/dist/docs/read.d.ts +2 -2
- package/dist/index.d.ts +25 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/lease-ipc/__tests__/freeze.test.d.ts +15 -0
- package/dist/lease-ipc/__tests__/freeze.test.d.ts.map +1 -0
- package/dist/lease-ipc/__tests__/freeze.test.js +313 -0
- package/dist/lease-ipc/__tests__/freeze.test.js.map +1 -0
- package/dist/lease-ipc/index.d.ts +17 -0
- package/dist/lease-ipc/index.d.ts.map +1 -0
- package/dist/lease-ipc/index.js +16 -0
- package/dist/lease-ipc/index.js.map +1 -0
- package/dist/lease-ipc/messages.d.ts +918 -0
- package/dist/lease-ipc/messages.d.ts.map +1 -0
- package/dist/lease-ipc/messages.js +476 -0
- package/dist/lease-ipc/messages.js.map +1 -0
- package/dist/lease-ipc/version.d.ts +41 -0
- package/dist/lease-ipc/version.d.ts.map +1 -0
- package/dist/lease-ipc/version.js +43 -0
- package/dist/lease-ipc/version.js.map +1 -0
- package/dist/llm/catalog-schema.d.ts +242 -0
- package/dist/llm/catalog-schema.d.ts.map +1 -0
- package/dist/llm/catalog-schema.js +153 -0
- package/dist/llm/catalog-schema.js.map +1 -0
- package/dist/llm/catalog-schema.json +139 -0
- package/dist/llm/index.d.ts +15 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +14 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/interfaces.d.ts +23 -0
- package/dist/llm/interfaces.d.ts.map +1 -1
- package/dist/llm/oauth.d.ts +16 -2
- package/dist/llm/oauth.d.ts.map +1 -1
- package/dist/llm/onboarding.d.ts +126 -0
- package/dist/llm/onboarding.d.ts.map +1 -0
- package/dist/llm/onboarding.js +34 -0
- package/dist/llm/onboarding.js.map +1 -0
- package/dist/llm/provider-def.d.ts +254 -0
- package/dist/llm/provider-def.d.ts.map +1 -0
- package/dist/llm/provider-def.js +93 -0
- package/dist/llm/provider-def.js.map +1 -0
- package/dist/llm/sealed-credential.d.ts +164 -0
- package/dist/llm/sealed-credential.d.ts.map +1 -0
- package/dist/llm/sealed-credential.js +43 -0
- package/dist/llm/sealed-credential.js.map +1 -0
- package/dist/llm/system-of-use.d.ts +383 -0
- package/dist/llm/system-of-use.d.ts.map +1 -0
- package/dist/llm/system-of-use.js +238 -0
- package/dist/llm/system-of-use.js.map +1 -0
- package/dist/llm/system-resolver.d.ts +87 -11
- package/dist/llm/system-resolver.d.ts.map +1 -1
- package/dist/llm/system-resolver.js +14 -7
- package/dist/llm/system-resolver.js.map +1 -1
- package/dist/operations/__tests__/ensures-schema-registry.test.d.ts +17 -0
- package/dist/operations/__tests__/ensures-schema-registry.test.d.ts.map +1 -0
- package/dist/operations/__tests__/ensures-schema-registry.test.js +113 -0
- package/dist/operations/__tests__/ensures-schema-registry.test.js.map +1 -0
- package/dist/operations/admin.d.ts +124 -1
- package/dist/operations/admin.d.ts.map +1 -1
- package/dist/operations/ensures-schema-registry.d.ts +172 -0
- package/dist/operations/ensures-schema-registry.d.ts.map +1 -0
- package/dist/operations/ensures-schema-registry.js +226 -0
- package/dist/operations/ensures-schema-registry.js.map +1 -0
- package/dist/operations/entities.d.ts +110 -0
- package/dist/operations/entities.d.ts.map +1 -0
- package/dist/operations/entities.js +695 -0
- package/dist/operations/entities.js.map +1 -0
- package/dist/operations/llm.d.ts +116 -9
- package/dist/operations/llm.d.ts.map +1 -1
- package/dist/operations/output-contracts-data.d.ts.map +1 -1
- package/dist/operations/output-contracts-data.js +230 -0
- package/dist/operations/output-contracts-data.js.map +1 -1
- package/dist/operations/service.d.ts +68 -0
- package/dist/operations/service.d.ts.map +1 -0
- package/dist/operations/service.js +336 -0
- package/dist/operations/service.js.map +1 -0
- package/dist/operations/tasks.d.ts +109 -0
- package/dist/operations/tasks.d.ts.map +1 -1
- package/dist/operations/tasks.js.map +1 -1
- package/dist/operations/validate.d.ts +1 -12
- package/dist/operations/validate.d.ts.map +1 -1
- package/dist/operations/validate.js +1 -1
- package/dist/playbook.d.ts +116 -0
- package/dist/playbook.d.ts.map +1 -1
- package/dist/release/plan.d.ts +5 -5
- package/dist/session.d.ts +11 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js.map +1 -1
- package/dist/templates/manifest.d.ts +1 -1
- package/dist/tools/agent-tools.d.ts +231 -0
- package/dist/tools/agent-tools.d.ts.map +1 -0
- package/dist/tools/agent-tools.js +25 -0
- package/dist/tools/agent-tools.js.map +1 -0
- package/dist/tools/atomic.d.ts +19 -0
- package/dist/tools/atomic.d.ts.map +1 -1
- package/dist/tools/atomic.js +17 -0
- package/dist/tools/atomic.js.map +1 -1
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/skill-executor.d.ts +7 -0
- package/dist/tools/skill-executor.d.ts.map +1 -1
- package/dist/tools/web-tools.d.ts +217 -0
- package/dist/tools/web-tools.d.ts.map +1 -0
- package/dist/tools/web-tools.js +31 -0
- package/dist/tools/web-tools.js.map +1 -0
- package/dist/vault/service-provider.d.ts +343 -0
- package/dist/vault/service-provider.d.ts.map +1 -0
- package/dist/vault/service-provider.js +857 -0
- package/dist/vault/service-provider.js.map +1 -0
- package/dist/workgraph.d.ts +12 -12
- package/package.json +14 -2
- package/src/__tests__/__snapshots__/operations-registry.test.ts.snap +1 -1
- package/src/__tests__/operation-def.test.ts +7 -1
- package/src/__tests__/provider-def.test.ts +93 -0
- package/src/__tests__/sealed-credential.test.ts +100 -0
- package/src/__tests__/service-provider.test.ts +129 -0
- package/src/__tests__/skill-executor-contract.test.ts +3 -0
- package/src/acceptance-gate.ts +2 -3
- package/src/boundary.ts +70 -20
- package/src/conduit.ts +200 -0
- package/src/config/index.ts +35 -0
- package/src/config.ts +106 -1
- package/src/data-accessor.ts +22 -1
- package/src/dispatch/__tests__/tasks-gateway-crud-ops.test.ts +99 -0
- package/src/dispatch/identity.ts +25 -0
- package/src/dispatch/operation-def.ts +21 -0
- package/src/dispatch/operations-registry.ts +1083 -176
- package/src/index.ts +240 -25
- package/src/lease-ipc/__tests__/freeze.test.ts +342 -0
- package/src/lease-ipc/index.ts +75 -0
- package/src/lease-ipc/messages.ts +588 -0
- package/src/lease-ipc/version.ts +46 -0
- package/src/llm/catalog-schema.json +139 -0
- package/src/llm/catalog-schema.ts +184 -0
- package/src/llm/index.ts +29 -0
- package/src/llm/interfaces.ts +23 -0
- package/src/llm/oauth.ts +16 -2
- package/src/llm/onboarding.ts +131 -0
- package/src/llm/provider-def.ts +291 -0
- package/src/llm/sealed-credential.ts +166 -0
- package/src/llm/system-of-use.ts +503 -0
- package/src/llm/system-resolver.ts +91 -11
- package/src/operations/__tests__/ensures-schema-registry.test.ts +169 -0
- package/src/operations/admin.ts +144 -0
- package/src/operations/ensures-schema-registry.ts +260 -0
- package/src/operations/entities.ts +758 -0
- package/src/operations/llm.ts +120 -8
- package/src/operations/output-contracts-data.ts +264 -0
- package/src/operations/service.ts +360 -0
- package/src/operations/tasks.ts +119 -0
- package/src/operations/validate.ts +1 -14
- package/src/playbook.ts +117 -0
- package/src/session.ts +11 -0
- package/src/tools/agent-tools.ts +270 -0
- package/src/tools/atomic.ts +21 -0
- package/src/tools/index.ts +46 -0
- package/src/tools/skill-executor.ts +7 -0
- package/src/tools/web-tools.ts +247 -0
- package/src/vault/service-provider.ts +1137 -0
- package/dist/tessera.d.ts +0 -32
- package/dist/tessera.d.ts.map +0 -1
- package/dist/tessera.js +0 -11
- package/dist/tessera.js.map +0 -1
- package/dist/warp-chain.d.ts +0 -129
- package/dist/warp-chain.d.ts.map +0 -1
- package/dist/warp-chain.js +0 -13
- package/dist/warp-chain.js.map +0 -1
- package/src/tessera.ts +0 -35
- package/src/warp-chain.ts +0 -185
package/dist/llm/oauth.d.ts
CHANGED
|
@@ -134,9 +134,23 @@ export interface ProviderOAuthConfig {
|
|
|
134
134
|
* `code_challenge`/`code_challenge_method`/`state`).
|
|
135
135
|
*
|
|
136
136
|
* Used by OpenAI/Codex (`id_token_add_organizations=true`,
|
|
137
|
-
* `codex_cli_simplified_flow=true`, `originator=codex_cli_rs`)
|
|
138
|
-
*
|
|
137
|
+
* `codex_cli_simplified_flow=true`, `originator=codex_cli_rs`) and Anthropic
|
|
138
|
+
* (`code=true` — makes the hosted callback page display the authorization
|
|
139
|
+
* code for manual paste-back). Kimi Code leaves this unset.
|
|
139
140
|
*/
|
|
140
141
|
extraAuthParams?: Readonly<Record<string, string>>;
|
|
142
|
+
/**
|
|
143
|
+
* Encoding of the token-endpoint request body (code exchange + refresh).
|
|
144
|
+
*
|
|
145
|
+
* - `'form'` (default) — RFC 6749 §4.1.3 `application/x-www-form-urlencoded`.
|
|
146
|
+
* Used by OpenAI/Codex and every spec-compliant authorization server.
|
|
147
|
+
* - `'json'` — non-standard `application/json` body. Anthropic's token
|
|
148
|
+
* endpoint (`platform.claude.com/v1/oauth/token`) expects JSON and
|
|
149
|
+
* additionally requires the authorize-time `state` echoed in the exchange
|
|
150
|
+
* body (the same wire shape pi-ai, OpenCode, and Claude Code use).
|
|
151
|
+
*
|
|
152
|
+
* @default 'form'
|
|
153
|
+
*/
|
|
154
|
+
tokenBodyFormat?: 'form' | 'json';
|
|
141
155
|
}
|
|
142
156
|
//# sourceMappingURL=oauth.d.ts.map
|
package/dist/llm/oauth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/llm/oauth.ts"],"names":[],"mappings":"AAAA;;;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,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACnC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Onboarding login engine — typed result envelope (T11724 · M3).
|
|
3
|
+
*
|
|
4
|
+
* The 3-step onboarding login flow (`runOnboardingLogin` in `@cleocode/core`)
|
|
5
|
+
* walks a provider from a cold start to a usable, validated profile binding:
|
|
6
|
+
*
|
|
7
|
+
* 1. **connect** — resolve the provider (alias → canonical) and land a
|
|
8
|
+
* credential (Account) in the multi-credential pool (OAuth token or API
|
|
9
|
+
* key). NO browser interaction in the engine itself: the owner-driven
|
|
10
|
+
* OAuth code/token is passed in, so the flow is non-interactive and
|
|
11
|
+
* testable.
|
|
12
|
+
* 2. **select** — pick a model from the catalog (latest by `release_date`,
|
|
13
|
+
* or an explicit override validated against the catalog).
|
|
14
|
+
* 3. **bind** — write the `llm.default` / `llm.roles[role]` config binding
|
|
15
|
+
* that ties the account + model together.
|
|
16
|
+
* 4. **validate** — round-trip the binding through `resolveLLMForSystem` and
|
|
17
|
+
* confirm the resolved provider/model are consistent. NOT a live LLM call:
|
|
18
|
+
* no token is materialized, only the resolution metadata is asserted.
|
|
19
|
+
*
|
|
20
|
+
* ## Security — NO secret fields (AC2)
|
|
21
|
+
*
|
|
22
|
+
* This module is **types-only** (Gate 10 contracts-purity). The result
|
|
23
|
+
* envelope carries ONLY non-secret identifiers — provider name, account label,
|
|
24
|
+
* model id, profile/role name, and per-step status. It NEVER carries an access
|
|
25
|
+
* token, API key, refresh token, or any token-derived value beyond a redacted
|
|
26
|
+
* preview. The plaintext secret is materialized only at the wire via the
|
|
27
|
+
* {@link SealedCredential} handle — never on this envelope.
|
|
28
|
+
*
|
|
29
|
+
* @module llm/onboarding
|
|
30
|
+
* @task T11724
|
|
31
|
+
* @epic T11671 (E6-ONBOARDING-FRONT-DOOR)
|
|
32
|
+
*/
|
|
33
|
+
import type { ProviderId } from './provider-id.js';
|
|
34
|
+
/**
|
|
35
|
+
* Discriminant naming each step of the onboarding login flow, in execution
|
|
36
|
+
* order. Surfaced on every {@link OnboardingStepResult} so a UI / CLI can
|
|
37
|
+
* render a deterministic 4-row progress checklist.
|
|
38
|
+
*
|
|
39
|
+
* @task T11724
|
|
40
|
+
*/
|
|
41
|
+
export type OnboardingStepName = 'connect' | 'select' | 'bind' | 'validate';
|
|
42
|
+
/**
|
|
43
|
+
* Outcome of a single onboarding step.
|
|
44
|
+
*
|
|
45
|
+
* - `'ok'` — the step completed successfully.
|
|
46
|
+
* - `'failed'` — the step could not complete (e.g. missing credential,
|
|
47
|
+
* unknown model, config write error). The engine STOPS at the first
|
|
48
|
+
* `'failed'` step and returns the partial envelope; it does NOT throw.
|
|
49
|
+
* - `'skipped'` — the step was intentionally not run because an earlier step
|
|
50
|
+
* failed (downstream steps are short-circuited but still reported so the
|
|
51
|
+
* 4-row shape is stable).
|
|
52
|
+
*
|
|
53
|
+
* @task T11724
|
|
54
|
+
*/
|
|
55
|
+
export type OnboardingStepStatus = 'ok' | 'failed' | 'skipped';
|
|
56
|
+
/**
|
|
57
|
+
* Result of one step in the onboarding login flow.
|
|
58
|
+
*
|
|
59
|
+
* `detail` is a short, human-readable, SECRET-FREE summary of what the step
|
|
60
|
+
* did (e.g. `"account 'work' connected (oauth)"`, `"model 'claude-…' selected
|
|
61
|
+
* from catalog"`). `code` carries a stable `E_*` error code on failure so a
|
|
62
|
+
* caller can branch programmatically without string-matching `detail`.
|
|
63
|
+
*
|
|
64
|
+
* @task T11724
|
|
65
|
+
*/
|
|
66
|
+
export interface OnboardingStepResult {
|
|
67
|
+
/** Which step this result describes. */
|
|
68
|
+
readonly step: OnboardingStepName;
|
|
69
|
+
/** Terminal status of the step. */
|
|
70
|
+
readonly status: OnboardingStepStatus;
|
|
71
|
+
/** Human-readable, secret-free summary of the step outcome. */
|
|
72
|
+
readonly detail: string;
|
|
73
|
+
/**
|
|
74
|
+
* Stable `E_*` error code when `status === 'failed'`; omitted otherwise.
|
|
75
|
+
* Never carries a token or other secret.
|
|
76
|
+
*/
|
|
77
|
+
readonly code?: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The auth scheme by which the connect step landed a credential in the pool.
|
|
81
|
+
*
|
|
82
|
+
* - `'oauth'` — an OAuth access token (PKCE / device-code) was supplied.
|
|
83
|
+
* - `'api_key'` — a raw API key was supplied (OAuth-less providers fall
|
|
84
|
+
* through to this path — AC4).
|
|
85
|
+
*
|
|
86
|
+
* @task T11724
|
|
87
|
+
*/
|
|
88
|
+
export type OnboardingAuthMode = 'oauth' | 'api_key';
|
|
89
|
+
/**
|
|
90
|
+
* Typed result envelope returned by `runOnboardingLogin` (AC2).
|
|
91
|
+
*
|
|
92
|
+
* Carries NO secret fields — only the per-step trace and the non-secret
|
|
93
|
+
* identifiers needed to render the result and confirm the binding. `validated`
|
|
94
|
+
* is the single boolean a caller checks to know the end-to-end flow succeeded
|
|
95
|
+
* (all four steps `'ok'` AND the round-trip resolution was consistent).
|
|
96
|
+
*
|
|
97
|
+
* @task T11724
|
|
98
|
+
*/
|
|
99
|
+
export interface OnboardingResult {
|
|
100
|
+
/** The 4 step traces, always length 4, in execution order. */
|
|
101
|
+
readonly steps: ReadonlyArray<OnboardingStepResult>;
|
|
102
|
+
/** Canonical provider id the flow resolved to (alias → canonical). */
|
|
103
|
+
readonly provider: ProviderId;
|
|
104
|
+
/**
|
|
105
|
+
* Human-readable account/credential label the connect step stored in the
|
|
106
|
+
* pool (e.g. `'oauth-login'`, `'work'`). Names *which* credential the
|
|
107
|
+
* binding points at — safe to log/serialize; NOT a secret.
|
|
108
|
+
*/
|
|
109
|
+
readonly accountLabel: string;
|
|
110
|
+
/** The auth scheme used by the connect step, or `null` when connect failed. */
|
|
111
|
+
readonly authMode: OnboardingAuthMode | null;
|
|
112
|
+
/** Catalog model id the select step chose, or `null` when select failed. */
|
|
113
|
+
readonly modelId: string | null;
|
|
114
|
+
/**
|
|
115
|
+
* The profile/role name the bind step wrote (e.g. `'default'` for the global
|
|
116
|
+
* binding or a {@link import('../config.js').RoleName} for a per-role
|
|
117
|
+
* binding), or `null` when bind failed.
|
|
118
|
+
*/
|
|
119
|
+
readonly profileName: string | null;
|
|
120
|
+
/**
|
|
121
|
+
* `true` only when all four steps succeeded AND the validate round-trip
|
|
122
|
+
* confirmed the binding resolves to the connected provider + selected model.
|
|
123
|
+
*/
|
|
124
|
+
readonly validated: boolean;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=onboarding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboarding.d.ts","sourceRoot":"","sources":["../../src/llm/onboarding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AAE5E;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE/D;;;;;;;;;GASG;AACH,MAAM,WAAW,oBAAoB;IACnC,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,mCAAmC;IACnC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACtC,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,CAAC;AAErD;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;IACpD,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC7C,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Onboarding login engine — typed result envelope (T11724 · M3).
|
|
3
|
+
*
|
|
4
|
+
* The 3-step onboarding login flow (`runOnboardingLogin` in `@cleocode/core`)
|
|
5
|
+
* walks a provider from a cold start to a usable, validated profile binding:
|
|
6
|
+
*
|
|
7
|
+
* 1. **connect** — resolve the provider (alias → canonical) and land a
|
|
8
|
+
* credential (Account) in the multi-credential pool (OAuth token or API
|
|
9
|
+
* key). NO browser interaction in the engine itself: the owner-driven
|
|
10
|
+
* OAuth code/token is passed in, so the flow is non-interactive and
|
|
11
|
+
* testable.
|
|
12
|
+
* 2. **select** — pick a model from the catalog (latest by `release_date`,
|
|
13
|
+
* or an explicit override validated against the catalog).
|
|
14
|
+
* 3. **bind** — write the `llm.default` / `llm.roles[role]` config binding
|
|
15
|
+
* that ties the account + model together.
|
|
16
|
+
* 4. **validate** — round-trip the binding through `resolveLLMForSystem` and
|
|
17
|
+
* confirm the resolved provider/model are consistent. NOT a live LLM call:
|
|
18
|
+
* no token is materialized, only the resolution metadata is asserted.
|
|
19
|
+
*
|
|
20
|
+
* ## Security — NO secret fields (AC2)
|
|
21
|
+
*
|
|
22
|
+
* This module is **types-only** (Gate 10 contracts-purity). The result
|
|
23
|
+
* envelope carries ONLY non-secret identifiers — provider name, account label,
|
|
24
|
+
* model id, profile/role name, and per-step status. It NEVER carries an access
|
|
25
|
+
* token, API key, refresh token, or any token-derived value beyond a redacted
|
|
26
|
+
* preview. The plaintext secret is materialized only at the wire via the
|
|
27
|
+
* {@link SealedCredential} handle — never on this envelope.
|
|
28
|
+
*
|
|
29
|
+
* @module llm/onboarding
|
|
30
|
+
* @task T11724
|
|
31
|
+
* @epic T11671 (E6-ONBOARDING-FRONT-DOOR)
|
|
32
|
+
*/
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=onboarding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboarding.js","sourceRoot":"","sources":["../../src/llm/onboarding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG"}
|
|
@@ -0,0 +1,254 @@
|
|
|
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
|
+
import type { StoredAuthTypeWire } from '../operations/llm.js';
|
|
47
|
+
import type { ProviderOAuthConfig } from './oauth.js';
|
|
48
|
+
import type { ProviderId } from './provider-id.js';
|
|
49
|
+
/**
|
|
50
|
+
* Wire-transport discriminant for a {@link ProviderEndpoint} variant.
|
|
51
|
+
*
|
|
52
|
+
* Closed union — one literal per protocol CLEO has a transport for. The
|
|
53
|
+
* declarative analog of {@link import('./provider-id.js').ApiMode}:
|
|
54
|
+
*
|
|
55
|
+
* - `openai-completions` — OpenAI `/chat/completions` shape (OpenAI, OpenRouter,
|
|
56
|
+
* Moonshot, Kimi, xAI, Gemini-via-OpenAI-compat) — `ApiMode 'chat_completions'`.
|
|
57
|
+
* - `openai-responses` — OpenAI Responses API (Codex backend, xAI-responses) —
|
|
58
|
+
* `ApiMode 'codex_responses'`.
|
|
59
|
+
* - `anthropic-messages` — native Anthropic Messages API (prompt-cache + thinking) —
|
|
60
|
+
* `ApiMode 'anthropic_messages'`.
|
|
61
|
+
* - `aisdk` — routed through the Vercel AI-SDK provider factory (the data-driven
|
|
62
|
+
* `apiMode → provider` adapter, T11767) rather than a bespoke CLEO transport.
|
|
63
|
+
*
|
|
64
|
+
* @task T11702
|
|
65
|
+
*/
|
|
66
|
+
export declare const PROVIDER_TRANSPORTS: readonly ["openai-completions", "openai-responses", "anthropic-messages", "aisdk"];
|
|
67
|
+
/** TypeScript union derived from {@link PROVIDER_TRANSPORTS}. */
|
|
68
|
+
export type ProviderTransport = (typeof PROVIDER_TRANSPORTS)[number];
|
|
69
|
+
/**
|
|
70
|
+
* Endpoint for the `openai-completions` transport — the OpenAI
|
|
71
|
+
* `/chat/completions` wire shape (OpenAI, OpenRouter, Moonshot, Kimi, xAI,
|
|
72
|
+
* Gemini-via-compat). `baseUrl` has NO trailing slash.
|
|
73
|
+
*
|
|
74
|
+
* @task T11702
|
|
75
|
+
*/
|
|
76
|
+
export interface OpenAICompletionsEndpoint {
|
|
77
|
+
/** Discriminant — the OpenAI chat-completions wire protocol. */
|
|
78
|
+
readonly transport: 'openai-completions';
|
|
79
|
+
/** Base URL for the provider's API — no trailing slash. */
|
|
80
|
+
readonly baseUrl: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Endpoint for the `openai-responses` transport — the OpenAI Responses API
|
|
84
|
+
* (Codex backend, xAI-responses). `baseUrl` has NO trailing slash.
|
|
85
|
+
*
|
|
86
|
+
* @task T11702
|
|
87
|
+
*/
|
|
88
|
+
export interface OpenAIResponsesEndpoint {
|
|
89
|
+
/** Discriminant — the OpenAI Responses wire protocol. */
|
|
90
|
+
readonly transport: 'openai-responses';
|
|
91
|
+
/** Base URL for the Responses endpoint — no trailing slash. */
|
|
92
|
+
readonly baseUrl: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Endpoint for the `anthropic-messages` transport — the native Anthropic
|
|
96
|
+
* Messages API (full prompt-cache + extended thinking). `baseUrl` has NO
|
|
97
|
+
* trailing slash.
|
|
98
|
+
*
|
|
99
|
+
* @task T11702
|
|
100
|
+
*/
|
|
101
|
+
export interface AnthropicMessagesEndpoint {
|
|
102
|
+
/** Discriminant — the native Anthropic Messages wire protocol. */
|
|
103
|
+
readonly transport: 'anthropic-messages';
|
|
104
|
+
/** Base URL for the Anthropic API — no trailing slash. */
|
|
105
|
+
readonly baseUrl: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Endpoint for the `aisdk` transport — the provider is reached through the
|
|
109
|
+
* Vercel AI-SDK provider factory (the data-driven adapter table, T11767) keyed
|
|
110
|
+
* by `aiSdkProvider`, rather than a bespoke CLEO transport.
|
|
111
|
+
*
|
|
112
|
+
* @task T11702
|
|
113
|
+
*/
|
|
114
|
+
export interface AiSdkEndpoint {
|
|
115
|
+
/** Discriminant — routed through the AI-SDK provider factory. */
|
|
116
|
+
readonly transport: 'aisdk';
|
|
117
|
+
/** Base URL passed to the AI-SDK provider factory — no trailing slash. */
|
|
118
|
+
readonly baseUrl: string;
|
|
119
|
+
/**
|
|
120
|
+
* The AI-SDK provider-factory key (e.g. `openai-compatible` | `google` |
|
|
121
|
+
* `bedrock`) the adapter table maps to a `create*` factory. NEVER an inline
|
|
122
|
+
* client construction — the factory call is the LLM chokepoint (T11783).
|
|
123
|
+
*/
|
|
124
|
+
readonly aiSdkProvider: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A provider's wire endpoint — a discriminated union keyed on the `transport`
|
|
128
|
+
* literal (AC5). Exactly one variant per {@link ProviderTransport}; each carries
|
|
129
|
+
* its own typed fields, with no `any`/`unknown` shortcut.
|
|
130
|
+
*
|
|
131
|
+
* @task T11702
|
|
132
|
+
*/
|
|
133
|
+
export type ProviderEndpoint = OpenAICompletionsEndpoint | OpenAIResponsesEndpoint | AnthropicMessagesEndpoint | AiSdkEndpoint;
|
|
134
|
+
/**
|
|
135
|
+
* Known request-quirk kinds — the DECLARATIVE record of WHICH provider-specific
|
|
136
|
+
* request adjustment a provider needs, WITHOUT embedding the closure.
|
|
137
|
+
*
|
|
138
|
+
* The live closures stay on {@link ProviderProfile} (`buildExtraBody` /
|
|
139
|
+
* `buildApiKwargsExtras` / `prepareMessages`); a `ProviderDef` row records only
|
|
140
|
+
* the quirk's stable kind so the table/seed stays serializable. The runtime maps
|
|
141
|
+
* a {@link RequestQuirk} `kind` back to its hook implementation.
|
|
142
|
+
*
|
|
143
|
+
* - `grok-conv-id` — inject the process-scoped `x-grok-conv-id` header (xAI).
|
|
144
|
+
* - `gemini-thinking-config` — inject `thinking_config` in `extra_body` (Gemini).
|
|
145
|
+
* - `kimi-reasoning-effort` — top-level `reasoning_effort` kwarg (Kimi Code).
|
|
146
|
+
* - `moonshot-schema-sanitize` — shallow tool-schema sanitization (Moonshot).
|
|
147
|
+
* - `openrouter-pareto` — inject the Pareto price-router plugin (OpenRouter).
|
|
148
|
+
*
|
|
149
|
+
* @task T11702
|
|
150
|
+
*/
|
|
151
|
+
export declare const REQUEST_QUIRK_KINDS: readonly ["grok-conv-id", "gemini-thinking-config", "kimi-reasoning-effort", "moonshot-schema-sanitize", "openrouter-pareto"];
|
|
152
|
+
/** TypeScript union derived from {@link REQUEST_QUIRK_KINDS}. */
|
|
153
|
+
export type RequestQuirkKind = (typeof REQUEST_QUIRK_KINDS)[number];
|
|
154
|
+
/**
|
|
155
|
+
* A single declarative request-quirk descriptor (AC4 — the "request-quirk hook
|
|
156
|
+
* signature"). Records the quirk's stable {@link RequestQuirkKind} so a
|
|
157
|
+
* `ProviderDef` row stays serializable; the runtime resolves the `kind` to its
|
|
158
|
+
* hook implementation on {@link ProviderProfile}. The signature the hook MUST
|
|
159
|
+
* satisfy is `(model: string) => Record<string, unknown>` (the declarative shape
|
|
160
|
+
* of `buildExtraBody` / `buildApiKwargsExtras`), captured here only as the
|
|
161
|
+
* documented contract — never as an embedded closure.
|
|
162
|
+
*
|
|
163
|
+
* @task T11702
|
|
164
|
+
*/
|
|
165
|
+
export interface RequestQuirk {
|
|
166
|
+
/** The stable quirk kind this provider needs. */
|
|
167
|
+
readonly kind: RequestQuirkKind;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* OAuth flow placeholder embedded on a {@link ProviderDef} (AC4).
|
|
171
|
+
*
|
|
172
|
+
* For M3 this is the existing {@link ProviderOAuthConfig} shape (PKCE / device-code
|
|
173
|
+
* endpoints + client id), aliased so the M4 vault work (T10409) can widen it without
|
|
174
|
+
* a contract rename. A `ProviderDef` carries `oauth` only when the provider supports
|
|
175
|
+
* an OAuth login flow (anthropic, openai, kimi-code); it is omitted otherwise.
|
|
176
|
+
*
|
|
177
|
+
* @task T11702
|
|
178
|
+
*/
|
|
179
|
+
export type OAuthFlowDef = ProviderOAuthConfig;
|
|
180
|
+
/**
|
|
181
|
+
* Declarative description of one LLM provider — the serializable DATA SSoT.
|
|
182
|
+
*
|
|
183
|
+
* The contract persisted as a `providers` table row (T11703) and read by the alias
|
|
184
|
+
* resolver (T11704). Derived from the runtime {@link ProviderProfile} set: identity
|
|
185
|
+
* + aliases + auth + endpoint + catalog key + headers + optional OAuth + the
|
|
186
|
+
* declarative request quirks. Carries NO closures — only serializable DATA.
|
|
187
|
+
*
|
|
188
|
+
* @task T11702
|
|
189
|
+
*/
|
|
190
|
+
export interface ProviderDef {
|
|
191
|
+
/**
|
|
192
|
+
* Canonical provider id (lower-cased). For builtins this is a
|
|
193
|
+
* {@link BuiltinProviderId}; plugin providers may use any non-empty string.
|
|
194
|
+
*/
|
|
195
|
+
readonly id: ProviderId;
|
|
196
|
+
/** Human-readable display name shown in pickers and diagnostic output. */
|
|
197
|
+
readonly displayName: string;
|
|
198
|
+
/**
|
|
199
|
+
* Alternate names that resolve to this provider (case-insensitive). The SINGLE
|
|
200
|
+
* source the alias resolver (T11704) reads — `codex`/`chatgpt` → `openai`,
|
|
201
|
+
* `claude` → `anthropic`, `google` → `gemini`, … An alias colliding with another
|
|
202
|
+
* provider's primary `id` is a resolution error (T11704 AC2).
|
|
203
|
+
*/
|
|
204
|
+
readonly aliases: ReadonlyArray<string>;
|
|
205
|
+
/**
|
|
206
|
+
* Authentication mechanisms this provider supports (`api_key` | `oauth` |
|
|
207
|
+
* `aws_sdk`). The {@link StoredAuthTypeWire} wire enum.
|
|
208
|
+
*/
|
|
209
|
+
readonly authMethods: ReadonlyArray<StoredAuthTypeWire>;
|
|
210
|
+
/**
|
|
211
|
+
* The provider's wire endpoint — a discriminated union keyed on `transport`
|
|
212
|
+
* (AC5). A provider that speaks multiple protocols (e.g. xAI completions +
|
|
213
|
+
* responses) carries the multiple variants in {@link altEndpoints}.
|
|
214
|
+
*/
|
|
215
|
+
readonly endpoint: ProviderEndpoint;
|
|
216
|
+
/**
|
|
217
|
+
* Additional wire endpoints this provider also speaks, beyond the primary
|
|
218
|
+
* {@link endpoint}. Collapses the prior per-ApiMode profile duplication into ONE
|
|
219
|
+
* row (T11703 AC4 — xAI's completions + responses become one `ProviderDef`).
|
|
220
|
+
* Empty/omitted for single-protocol providers.
|
|
221
|
+
*/
|
|
222
|
+
readonly altEndpoints?: ReadonlyArray<ProviderEndpoint>;
|
|
223
|
+
/**
|
|
224
|
+
* The models.dev catalog provider key joining this provider to the
|
|
225
|
+
* `models_catalog` table (T11733). Usually equals {@link id}; carried distinctly
|
|
226
|
+
* because a provider id and its catalog key can differ (e.g. `kimi-code` →
|
|
227
|
+
* `moonshot`).
|
|
228
|
+
*/
|
|
229
|
+
readonly modelsDevId: string;
|
|
230
|
+
/**
|
|
231
|
+
* HTTP headers sent with every request to this provider, merged into the
|
|
232
|
+
* client's `defaultHeaders` (e.g. `{ 'anthropic-version': '2023-06-01' }`).
|
|
233
|
+
* Omitted when the provider needs no pinned headers.
|
|
234
|
+
*/
|
|
235
|
+
readonly defaultHeaders?: Readonly<Record<string, string>>;
|
|
236
|
+
/**
|
|
237
|
+
* Environment variable names that may supply this provider's API key (e.g.
|
|
238
|
+
* `['ANTHROPIC_API_KEY']`). Resolver chains may check these before the vault.
|
|
239
|
+
* Omitted when the provider has no env-var credential path.
|
|
240
|
+
*/
|
|
241
|
+
readonly envVars?: ReadonlyArray<string>;
|
|
242
|
+
/**
|
|
243
|
+
* OAuth flow placeholder (AC4) — present only when the provider supports an
|
|
244
|
+
* OAuth login flow (anthropic, openai, kimi-code). See {@link OAuthFlowDef}.
|
|
245
|
+
*/
|
|
246
|
+
readonly oauth?: OAuthFlowDef;
|
|
247
|
+
/**
|
|
248
|
+
* Declarative request quirks this provider needs (AC4) — the stable
|
|
249
|
+
* {@link RequestQuirk} descriptors WITHOUT the closures (those stay on
|
|
250
|
+
* {@link ProviderProfile}). Empty/omitted when the provider needs no quirk.
|
|
251
|
+
*/
|
|
252
|
+
readonly requestQuirks?: ReadonlyArray<RequestQuirk>;
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=provider-def.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-def.d.ts","sourceRoot":"","sources":["../../src/llm/provider-def.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAA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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
|
+
* Wire-transport discriminant for a {@link ProviderEndpoint} variant.
|
|
48
|
+
*
|
|
49
|
+
* Closed union — one literal per protocol CLEO has a transport for. The
|
|
50
|
+
* declarative analog of {@link import('./provider-id.js').ApiMode}:
|
|
51
|
+
*
|
|
52
|
+
* - `openai-completions` — OpenAI `/chat/completions` shape (OpenAI, OpenRouter,
|
|
53
|
+
* Moonshot, Kimi, xAI, Gemini-via-OpenAI-compat) — `ApiMode 'chat_completions'`.
|
|
54
|
+
* - `openai-responses` — OpenAI Responses API (Codex backend, xAI-responses) —
|
|
55
|
+
* `ApiMode 'codex_responses'`.
|
|
56
|
+
* - `anthropic-messages` — native Anthropic Messages API (prompt-cache + thinking) —
|
|
57
|
+
* `ApiMode 'anthropic_messages'`.
|
|
58
|
+
* - `aisdk` — routed through the Vercel AI-SDK provider factory (the data-driven
|
|
59
|
+
* `apiMode → provider` adapter, T11767) rather than a bespoke CLEO transport.
|
|
60
|
+
*
|
|
61
|
+
* @task T11702
|
|
62
|
+
*/
|
|
63
|
+
export const PROVIDER_TRANSPORTS = [
|
|
64
|
+
'openai-completions',
|
|
65
|
+
'openai-responses',
|
|
66
|
+
'anthropic-messages',
|
|
67
|
+
'aisdk',
|
|
68
|
+
];
|
|
69
|
+
/**
|
|
70
|
+
* Known request-quirk kinds — the DECLARATIVE record of WHICH provider-specific
|
|
71
|
+
* request adjustment a provider needs, WITHOUT embedding the closure.
|
|
72
|
+
*
|
|
73
|
+
* The live closures stay on {@link ProviderProfile} (`buildExtraBody` /
|
|
74
|
+
* `buildApiKwargsExtras` / `prepareMessages`); a `ProviderDef` row records only
|
|
75
|
+
* the quirk's stable kind so the table/seed stays serializable. The runtime maps
|
|
76
|
+
* a {@link RequestQuirk} `kind` back to its hook implementation.
|
|
77
|
+
*
|
|
78
|
+
* - `grok-conv-id` — inject the process-scoped `x-grok-conv-id` header (xAI).
|
|
79
|
+
* - `gemini-thinking-config` — inject `thinking_config` in `extra_body` (Gemini).
|
|
80
|
+
* - `kimi-reasoning-effort` — top-level `reasoning_effort` kwarg (Kimi Code).
|
|
81
|
+
* - `moonshot-schema-sanitize` — shallow tool-schema sanitization (Moonshot).
|
|
82
|
+
* - `openrouter-pareto` — inject the Pareto price-router plugin (OpenRouter).
|
|
83
|
+
*
|
|
84
|
+
* @task T11702
|
|
85
|
+
*/
|
|
86
|
+
export const REQUEST_QUIRK_KINDS = [
|
|
87
|
+
'grok-conv-id',
|
|
88
|
+
'gemini-thinking-config',
|
|
89
|
+
'kimi-reasoning-effort',
|
|
90
|
+
'moonshot-schema-sanitize',
|
|
91
|
+
'openrouter-pareto',
|
|
92
|
+
];
|
|
93
|
+
//# sourceMappingURL=provider-def.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-def.js","sourceRoot":"","sources":["../../src/llm/provider-def.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAMH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,oBAAoB;IACpB,kBAAkB;IAClB,oBAAoB;IACpB,OAAO;CACC,CAAC;AA+EX;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,cAAc;IACd,wBAAwB;IACxB,uBAAuB;IACvB,0BAA0B;IAC1B,mBAAmB;CACX,CAAC"}
|