@cleocode/contracts 2026.6.13 → 2026.6.15
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 +4 -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__/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/boundary.d.ts +52 -0
- package/dist/boundary.d.ts.map +1 -1
- package/dist/boundary.js +23 -0
- package/dist/boundary.js.map +1 -1
- package/dist/branch-lock.d.ts +4 -0
- package/dist/branch-lock.d.ts.map +1 -1
- package/dist/branch-lock.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 +109 -1
- package/dist/config.d.ts.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 +20 -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 +1030 -46
- package/dist/dispatch/operations-registry.js.map +1 -1
- package/dist/index.d.ts +17 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/dist/lease-ipc/__tests__/freeze.test.js +92 -0
- package/dist/lease-ipc/__tests__/freeze.test.js.map +1 -1
- package/dist/lease-ipc/index.d.ts +2 -2
- package/dist/lease-ipc/index.d.ts.map +1 -1
- package/dist/lease-ipc/index.js +1 -1
- package/dist/lease-ipc/index.js.map +1 -1
- package/dist/lease-ipc/messages.d.ts +167 -3
- package/dist/lease-ipc/messages.d.ts.map +1 -1
- package/dist/lease-ipc/messages.js +93 -0
- package/dist/lease-ipc/messages.js.map +1 -1
- 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/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/system-resolver.d.ts +42 -0
- package/dist/llm/system-resolver.d.ts.map +1 -1
- package/dist/operations/admin.d.ts +124 -1
- package/dist/operations/admin.d.ts.map +1 -1
- 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 +16 -1
- 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/worktree.d.ts +11 -1
- package/dist/operations/worktree.d.ts.map +1 -1
- package/dist/playbook.d.ts +56 -0
- package/dist/playbook.d.ts.map +1 -1
- package/dist/release/plan.d.ts +5 -5
- package/dist/spawn.d.ts +70 -0
- package/dist/spawn.d.ts.map +1 -1
- package/dist/spawn.js +1 -0
- package/dist/spawn.js.map +1 -1
- 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 +10 -2
- package/src/__tests__/__snapshots__/operations-registry.test.ts.snap +1 -1
- package/src/__tests__/operation-def.test.ts +6 -1
- package/src/__tests__/provider-def.test.ts +93 -0
- package/src/__tests__/service-provider.test.ts +129 -0
- package/src/boundary.ts +69 -0
- package/src/branch-lock.ts +4 -0
- package/src/conduit.ts +200 -0
- package/src/config/index.ts +35 -0
- package/src/config.ts +116 -1
- package/src/dispatch/__tests__/tasks-gateway-crud-ops.test.ts +99 -0
- package/src/dispatch/identity.ts +20 -0
- package/src/dispatch/operation-def.ts +21 -0
- package/src/dispatch/operations-registry.ts +1062 -36
- package/src/index.ts +147 -2
- package/src/lease-ipc/__tests__/freeze.test.ts +96 -0
- package/src/lease-ipc/index.ts +12 -0
- package/src/lease-ipc/messages.ts +117 -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/oauth.ts +16 -2
- package/src/llm/onboarding.ts +131 -0
- package/src/llm/provider-def.ts +291 -0
- package/src/llm/system-resolver.ts +45 -0
- package/src/operations/admin.ts +144 -0
- package/src/operations/entities.ts +758 -0
- package/src/operations/llm.ts +16 -0
- 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/worktree.ts +11 -0
- package/src/playbook.ts +56 -0
- package/src/spawn.ts +79 -0
- package/src/vault/service-provider.ts +1137 -0
|
@@ -0,0 +1,695 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 5-entity provider-experience operation contracts — INPUT + OUTPUT schemas (T11700).
|
|
3
|
+
*
|
|
4
|
+
* The schema-first I/O contracts for the addressable provider-experience surface
|
|
5
|
+
* the North-Star design needs (§2 — Provider / Alias / Account / Model / Profile).
|
|
6
|
+
* They live HERE in the `contracts` leaf package — alongside `tasks.ts`,
|
|
7
|
+
* `service.ts`, and the OUTPUT-contracts registry — so every consumer (CLI
|
|
8
|
+
* `--describe`, the SDK `describeOperation`, REST clients) resolves the I/O shape
|
|
9
|
+
* against ONE source of truth.
|
|
10
|
+
*
|
|
11
|
+
* ## The five entities (North-Star §2)
|
|
12
|
+
*
|
|
13
|
+
* - **Provider** — a declarative LLM provider definition (`anthropic`, `openai`, …)
|
|
14
|
+
* with its aliases, auth methods, and endpoint variants (`providers` table, #1039).
|
|
15
|
+
* - **Alias** — a case-insensitive name resolving to a provider (carried inside the
|
|
16
|
+
* provider rows; surfaced via `provider.show`).
|
|
17
|
+
* - **Account** — ONE pooled credential for a provider (the rename/successor of the
|
|
18
|
+
* secret-bearing `llm` credential pool). `account.add` is SECRET-BEARING.
|
|
19
|
+
* - **Model** — a row in the models.dev catalog (`models_catalog` table, #1037).
|
|
20
|
+
* - **Profile** — the named, addressable binding of `account + model (+ params + role)`,
|
|
21
|
+
* persisted in config under `llm.profiles[name]` (the resolver-consumed SSoT).
|
|
22
|
+
*
|
|
23
|
+
* ## Secrets never surfaced
|
|
24
|
+
*
|
|
25
|
+
* `account.add` accepts a SECRET token but its OUTPUT view is the same NON-SECRET
|
|
26
|
+
* redacted shape `account.list` returns — `tokenPreview` (last-4) ONLY, NEVER the
|
|
27
|
+
* raw key. There is no `--field` pointer that resolves to a secret, by design. The
|
|
28
|
+
* secret-bearing ops are kept OFF the MCP surface (default-deny `mcpExposed`).
|
|
29
|
+
*
|
|
30
|
+
* @packageDocumentation
|
|
31
|
+
* @module @cleocode/contracts/operations/entities
|
|
32
|
+
*
|
|
33
|
+
* @epic T11666
|
|
34
|
+
* @task T11700 — provider/account/model/profile OperationDefs
|
|
35
|
+
*/
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
// Shared NON-SECRET account (credential) view schema — used by add + list.
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
/**
|
|
40
|
+
* The redacted per-account view schema (shared by `account.add` and
|
|
41
|
+
* `account.list`). Carries `tokenPreview` (last-4 redaction) ONLY — the decrypted
|
|
42
|
+
* secret is NEVER present in any field.
|
|
43
|
+
*/
|
|
44
|
+
const ACCOUNT_VIEW_SCHEMA = {
|
|
45
|
+
type: 'object',
|
|
46
|
+
required: ['provider', 'label', 'authType', 'tokenPreview'],
|
|
47
|
+
additionalProperties: true,
|
|
48
|
+
properties: {
|
|
49
|
+
provider: { type: 'string', description: 'LLM provider transport key.' },
|
|
50
|
+
label: { type: 'string', description: 'Account label, unique within the provider.' },
|
|
51
|
+
authType: { type: 'string', description: 'Storage auth scheme (api_key | oauth | aws_sdk).' },
|
|
52
|
+
tokenPreview: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'Redacted token preview (last-4 chars) — NEVER the raw secret.',
|
|
55
|
+
},
|
|
56
|
+
hasRefreshToken: { type: 'boolean' },
|
|
57
|
+
expiresAt: { type: ['number', 'null'] },
|
|
58
|
+
priority: { type: 'number' },
|
|
59
|
+
source: { type: ['string', 'null'] },
|
|
60
|
+
baseUrl: { type: ['string', 'null'] },
|
|
61
|
+
disabled: { type: 'boolean' },
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
// account.add — store a pooled credential (SECRET-BEARING, cli-only)
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
/** Accepted input shape for `account.add`. `token` is SECRET — never echoed. */
|
|
68
|
+
export const ACCOUNT_ADD_INPUT_SCHEMA = {
|
|
69
|
+
type: 'object',
|
|
70
|
+
required: ['provider', 'token'],
|
|
71
|
+
additionalProperties: false,
|
|
72
|
+
properties: {
|
|
73
|
+
provider: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
minLength: 1,
|
|
76
|
+
description: 'LLM provider transport key (e.g. anthropic, openai).',
|
|
77
|
+
},
|
|
78
|
+
token: {
|
|
79
|
+
type: 'string',
|
|
80
|
+
minLength: 1,
|
|
81
|
+
description: 'API key or OAuth bearer token to persist. SECRET — never logged/echoed.',
|
|
82
|
+
},
|
|
83
|
+
label: {
|
|
84
|
+
type: 'string',
|
|
85
|
+
description: "Account label, unique within the provider (default: 'default').",
|
|
86
|
+
},
|
|
87
|
+
baseUrl: { type: 'string', description: 'Optional override for the provider base URL.' },
|
|
88
|
+
authType: {
|
|
89
|
+
type: 'string',
|
|
90
|
+
enum: ['api_key', 'oauth', 'aws_sdk'],
|
|
91
|
+
description: 'Explicit auth-type override; auto-detected from the token prefix when omitted.',
|
|
92
|
+
},
|
|
93
|
+
priority: { type: 'number', description: 'Optional priority override (lower wins).' },
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
/** Schema-first INPUT contract for `account.add`. */
|
|
97
|
+
export const accountAddInputContract = {
|
|
98
|
+
operation: 'account.add',
|
|
99
|
+
schema: ACCOUNT_ADD_INPUT_SCHEMA,
|
|
100
|
+
examples: [
|
|
101
|
+
{
|
|
102
|
+
name: 'api-key',
|
|
103
|
+
value: { provider: 'anthropic', token: 'sk-ant-xxx', label: 'work' },
|
|
104
|
+
description: 'Store an API key for a provider account.',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'oauth',
|
|
108
|
+
value: { provider: 'anthropic', token: 'sk-ant-oat-xxx', authType: 'oauth' },
|
|
109
|
+
description: 'Store an OAuth bearer token (auto-detected as oauth from the prefix).',
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
};
|
|
113
|
+
/** OUTPUT contract for `account.add` — the NON-SECRET redacted view. */
|
|
114
|
+
export const accountAddOutputContract = {
|
|
115
|
+
operation: 'account.add',
|
|
116
|
+
shapeNote: '`account` is the redacted NON-SECRET view (tokenPreview = last-4 ONLY). The raw secret is NEVER returned. `detectedAuthType` records the resolved scheme.',
|
|
117
|
+
dataSchema: {
|
|
118
|
+
type: 'object',
|
|
119
|
+
required: ['account', 'detectedAuthType'],
|
|
120
|
+
additionalProperties: true,
|
|
121
|
+
properties: {
|
|
122
|
+
account: ACCOUNT_VIEW_SCHEMA,
|
|
123
|
+
detectedAuthType: { type: 'string', description: 'Resolved auth scheme (api_key | oauth).' },
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
fieldPointers: [
|
|
127
|
+
'/data/account/provider',
|
|
128
|
+
'/data/account/label',
|
|
129
|
+
'/data/account/authType',
|
|
130
|
+
'/data/account/tokenPreview',
|
|
131
|
+
'/data/detectedAuthType',
|
|
132
|
+
],
|
|
133
|
+
};
|
|
134
|
+
// ---------------------------------------------------------------------------
|
|
135
|
+
// account.list — redacted account views (NEVER a secret)
|
|
136
|
+
// ---------------------------------------------------------------------------
|
|
137
|
+
/** Accepted input shape for `account.list`. */
|
|
138
|
+
export const ACCOUNT_LIST_INPUT_SCHEMA = {
|
|
139
|
+
type: 'object',
|
|
140
|
+
required: [],
|
|
141
|
+
additionalProperties: false,
|
|
142
|
+
properties: {
|
|
143
|
+
provider: {
|
|
144
|
+
type: 'string',
|
|
145
|
+
description: 'Optional provider filter; lists all providers when omitted.',
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
/** Schema-first INPUT contract for `account.list`. */
|
|
150
|
+
export const accountListInputContract = {
|
|
151
|
+
operation: 'account.list',
|
|
152
|
+
schema: ACCOUNT_LIST_INPUT_SCHEMA,
|
|
153
|
+
examples: [
|
|
154
|
+
{ name: 'all', value: {}, description: 'List every pooled account (redacted).' },
|
|
155
|
+
{
|
|
156
|
+
name: 'one-provider',
|
|
157
|
+
value: { provider: 'anthropic' },
|
|
158
|
+
description: 'Filter to one provider.',
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
};
|
|
162
|
+
/** OUTPUT contract for `account.list` — redacted account views. */
|
|
163
|
+
export const accountListOutputContract = {
|
|
164
|
+
operation: 'account.list',
|
|
165
|
+
shapeNote: 'accounts[] are NON-SECRET views — provider/label/authType/tokenPreview only. No decrypted secret is present in ANY field.',
|
|
166
|
+
dataSchema: {
|
|
167
|
+
type: 'object',
|
|
168
|
+
required: ['accounts'],
|
|
169
|
+
additionalProperties: true,
|
|
170
|
+
properties: {
|
|
171
|
+
accounts: {
|
|
172
|
+
type: 'array',
|
|
173
|
+
items: ACCOUNT_VIEW_SCHEMA,
|
|
174
|
+
description: 'Redacted account views.',
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
fieldPointers: [
|
|
179
|
+
'/data/accounts',
|
|
180
|
+
'/data/accounts/0/provider',
|
|
181
|
+
'/data/accounts/0/label',
|
|
182
|
+
'/data/accounts/0/tokenPreview',
|
|
183
|
+
],
|
|
184
|
+
};
|
|
185
|
+
// ---------------------------------------------------------------------------
|
|
186
|
+
// account.remove — delete a (provider, label) account
|
|
187
|
+
// ---------------------------------------------------------------------------
|
|
188
|
+
/** Accepted input shape for `account.remove`. */
|
|
189
|
+
export const ACCOUNT_REMOVE_INPUT_SCHEMA = {
|
|
190
|
+
type: 'object',
|
|
191
|
+
required: ['provider', 'label'],
|
|
192
|
+
additionalProperties: false,
|
|
193
|
+
properties: {
|
|
194
|
+
provider: { type: 'string', minLength: 1, description: 'LLM provider transport key.' },
|
|
195
|
+
label: { type: 'string', minLength: 1, description: 'Account label to remove.' },
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
/** Schema-first INPUT contract for `account.remove`. */
|
|
199
|
+
export const accountRemoveInputContract = {
|
|
200
|
+
operation: 'account.remove',
|
|
201
|
+
schema: ACCOUNT_REMOVE_INPUT_SCHEMA,
|
|
202
|
+
examples: [
|
|
203
|
+
{
|
|
204
|
+
name: 'remove',
|
|
205
|
+
value: { provider: 'anthropic', label: 'work' },
|
|
206
|
+
description: 'Delete the (provider, label) account from the pool.',
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
};
|
|
210
|
+
/** OUTPUT contract for `account.remove` — the mutate envelope. */
|
|
211
|
+
export const accountRemoveOutputContract = {
|
|
212
|
+
operation: 'account.remove',
|
|
213
|
+
shapeNote: 'Mutate envelope: count=1 + deleted=[provider:label] when an account was removed; count=0 + [] when absent (idempotent).',
|
|
214
|
+
dataSchema: {
|
|
215
|
+
type: 'object',
|
|
216
|
+
required: ['count', 'deleted'],
|
|
217
|
+
additionalProperties: true,
|
|
218
|
+
properties: {
|
|
219
|
+
count: { type: 'number', description: '1 when an account was deleted, else 0.' },
|
|
220
|
+
deleted: {
|
|
221
|
+
type: 'array',
|
|
222
|
+
items: { type: 'string' },
|
|
223
|
+
description: 'The `provider:label` identifier(s) deleted.',
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
fieldPointers: ['/data/count', '/data/deleted/0'],
|
|
228
|
+
};
|
|
229
|
+
// ---------------------------------------------------------------------------
|
|
230
|
+
// provider.list — declarative provider rows (the providers table, #1039)
|
|
231
|
+
// ---------------------------------------------------------------------------
|
|
232
|
+
/** The NON-SECRET per-provider view schema (shared by list + show). */
|
|
233
|
+
const PROVIDER_VIEW_SCHEMA = {
|
|
234
|
+
type: 'object',
|
|
235
|
+
required: ['id', 'displayName', 'aliases', 'authMethods'],
|
|
236
|
+
additionalProperties: true,
|
|
237
|
+
properties: {
|
|
238
|
+
id: { type: 'string', description: 'Canonical provider key (e.g. anthropic).' },
|
|
239
|
+
displayName: { type: 'string' },
|
|
240
|
+
aliases: { type: 'array', items: { type: 'string' }, description: 'Case-insensitive aliases.' },
|
|
241
|
+
authMethods: {
|
|
242
|
+
type: 'array',
|
|
243
|
+
items: { type: 'string' },
|
|
244
|
+
description: 'Supported auth methods (api_key | oauth | aws_sdk).',
|
|
245
|
+
},
|
|
246
|
+
modelsDevId: { type: 'string', description: 'models.dev catalog provider key.' },
|
|
247
|
+
source: { type: 'string', description: 'Provenance (seed | plugin | import).' },
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
/** Accepted input shape for `provider.list`. */
|
|
251
|
+
export const PROVIDER_LIST_INPUT_SCHEMA = {
|
|
252
|
+
type: 'object',
|
|
253
|
+
required: [],
|
|
254
|
+
additionalProperties: false,
|
|
255
|
+
properties: {},
|
|
256
|
+
};
|
|
257
|
+
/** Schema-first INPUT contract for `provider.list`. */
|
|
258
|
+
export const providerListInputContract = {
|
|
259
|
+
operation: 'provider.list',
|
|
260
|
+
schema: PROVIDER_LIST_INPUT_SCHEMA,
|
|
261
|
+
examples: [{ name: 'all', value: {}, description: 'List every declarative provider.' }],
|
|
262
|
+
};
|
|
263
|
+
/** OUTPUT contract for `provider.list` — declarative provider views. */
|
|
264
|
+
export const providerListOutputContract = {
|
|
265
|
+
operation: 'provider.list',
|
|
266
|
+
shapeNote: 'providers[] are declarative NON-SECRET views (id/displayName/aliases/authMethods).',
|
|
267
|
+
dataSchema: {
|
|
268
|
+
type: 'object',
|
|
269
|
+
required: ['providers'],
|
|
270
|
+
additionalProperties: true,
|
|
271
|
+
properties: {
|
|
272
|
+
providers: { type: 'array', items: PROVIDER_VIEW_SCHEMA, description: 'Provider views.' },
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
fieldPointers: [
|
|
276
|
+
'/data/providers',
|
|
277
|
+
'/data/providers/0/id',
|
|
278
|
+
'/data/providers/0/displayName',
|
|
279
|
+
'/data/providers/0/aliases',
|
|
280
|
+
],
|
|
281
|
+
};
|
|
282
|
+
// ---------------------------------------------------------------------------
|
|
283
|
+
// provider.show — one provider resolved by id or alias
|
|
284
|
+
// ---------------------------------------------------------------------------
|
|
285
|
+
/** Accepted input shape for `provider.show`. */
|
|
286
|
+
export const PROVIDER_SHOW_INPUT_SCHEMA = {
|
|
287
|
+
type: 'object',
|
|
288
|
+
required: ['provider'],
|
|
289
|
+
additionalProperties: false,
|
|
290
|
+
properties: {
|
|
291
|
+
provider: {
|
|
292
|
+
type: 'string',
|
|
293
|
+
minLength: 1,
|
|
294
|
+
description: 'Provider id OR a case-insensitive alias (resolved against the alias index).',
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
};
|
|
298
|
+
/** Schema-first INPUT contract for `provider.show`. */
|
|
299
|
+
export const providerShowInputContract = {
|
|
300
|
+
operation: 'provider.show',
|
|
301
|
+
schema: PROVIDER_SHOW_INPUT_SCHEMA,
|
|
302
|
+
examples: [
|
|
303
|
+
{ name: 'by-id', value: { provider: 'anthropic' }, description: 'Resolve by canonical id.' },
|
|
304
|
+
{ name: 'by-alias', value: { provider: 'claude' }, description: 'Resolve by alias.' },
|
|
305
|
+
],
|
|
306
|
+
};
|
|
307
|
+
/** OUTPUT contract for `provider.show` — the resolved provider + the alias matched. */
|
|
308
|
+
export const providerShowOutputContract = {
|
|
309
|
+
operation: 'provider.show',
|
|
310
|
+
shapeNote: '`provider` is the resolved declarative view; `resolvedFrom` echoes the alias/id the lookup matched.',
|
|
311
|
+
dataSchema: {
|
|
312
|
+
type: 'object',
|
|
313
|
+
required: ['provider', 'resolvedFrom'],
|
|
314
|
+
additionalProperties: true,
|
|
315
|
+
properties: {
|
|
316
|
+
provider: PROVIDER_VIEW_SCHEMA,
|
|
317
|
+
resolvedFrom: { type: 'string', description: 'The id/alias the lookup matched.' },
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
fieldPointers: ['/data/provider/id', '/data/provider/displayName', '/data/resolvedFrom'],
|
|
321
|
+
};
|
|
322
|
+
// ---------------------------------------------------------------------------
|
|
323
|
+
// provider.connect — connect a provider (delegates to account.add or OAuth)
|
|
324
|
+
// ---------------------------------------------------------------------------
|
|
325
|
+
/** Accepted input shape for `provider.connect`. */
|
|
326
|
+
export const PROVIDER_CONNECT_INPUT_SCHEMA = {
|
|
327
|
+
type: 'object',
|
|
328
|
+
required: ['provider'],
|
|
329
|
+
additionalProperties: false,
|
|
330
|
+
properties: {
|
|
331
|
+
provider: { type: 'string', minLength: 1, description: 'Provider id or alias to connect.' },
|
|
332
|
+
token: {
|
|
333
|
+
type: 'string',
|
|
334
|
+
description: 'Direct API key / bearer token to store (token-direct mode). SECRET.',
|
|
335
|
+
},
|
|
336
|
+
label: {
|
|
337
|
+
type: 'string',
|
|
338
|
+
description: "Account label to create (default: 'default').",
|
|
339
|
+
},
|
|
340
|
+
authType: {
|
|
341
|
+
type: 'string',
|
|
342
|
+
enum: ['api_key', 'oauth', 'aws_sdk'],
|
|
343
|
+
description: 'Explicit auth-type override.',
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
/** Schema-first INPUT contract for `provider.connect`. */
|
|
348
|
+
export const providerConnectInputContract = {
|
|
349
|
+
operation: 'provider.connect',
|
|
350
|
+
schema: PROVIDER_CONNECT_INPUT_SCHEMA,
|
|
351
|
+
examples: [
|
|
352
|
+
{
|
|
353
|
+
name: 'token-direct',
|
|
354
|
+
value: { provider: 'anthropic', token: 'sk-ant-xxx' },
|
|
355
|
+
description: 'Connect a provider by storing a token as the default account.',
|
|
356
|
+
},
|
|
357
|
+
],
|
|
358
|
+
};
|
|
359
|
+
/** OUTPUT contract for `provider.connect` — the NON-SECRET account identity. */
|
|
360
|
+
export const providerConnectOutputContract = {
|
|
361
|
+
operation: 'provider.connect',
|
|
362
|
+
shapeNote: 'Mutate envelope: count=1 + created=[provider:label]. `account` carries the redacted NON-SECRET view. The raw token is NEVER returned.',
|
|
363
|
+
dataSchema: {
|
|
364
|
+
type: 'object',
|
|
365
|
+
required: ['count', 'created'],
|
|
366
|
+
additionalProperties: true,
|
|
367
|
+
properties: {
|
|
368
|
+
count: { type: 'number', description: 'Number of accounts created/updated (1).' },
|
|
369
|
+
created: {
|
|
370
|
+
type: 'array',
|
|
371
|
+
items: { type: 'string' },
|
|
372
|
+
description: 'The provider:label id(s).',
|
|
373
|
+
},
|
|
374
|
+
account: ACCOUNT_VIEW_SCHEMA,
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
fieldPointers: ['/data/count', '/data/created/0', '/data/account/tokenPreview'],
|
|
378
|
+
};
|
|
379
|
+
// ---------------------------------------------------------------------------
|
|
380
|
+
// model.query — read the models.dev catalog (the models_catalog table, #1037)
|
|
381
|
+
// ---------------------------------------------------------------------------
|
|
382
|
+
/** The per-model catalog view schema (shared by query + show). */
|
|
383
|
+
const MODEL_VIEW_SCHEMA = {
|
|
384
|
+
type: 'object',
|
|
385
|
+
required: ['id', 'providerId', 'name', 'releaseDate'],
|
|
386
|
+
additionalProperties: true,
|
|
387
|
+
properties: {
|
|
388
|
+
id: { type: 'string', description: 'Model id (catalog key).' },
|
|
389
|
+
providerId: { type: 'string', description: 'Provider key (models.dev id).' },
|
|
390
|
+
name: { type: 'string', description: 'Human-readable display name.' },
|
|
391
|
+
family: { type: 'string' },
|
|
392
|
+
releaseDate: { type: 'string', description: 'ISO release date YYYY-MM-DD.' },
|
|
393
|
+
contextLimit: { type: ['number', 'null'] },
|
|
394
|
+
outputLimit: { type: ['number', 'null'] },
|
|
395
|
+
status: { type: 'string', description: 'Lifecycle (stable | beta | preview | …).' },
|
|
396
|
+
},
|
|
397
|
+
};
|
|
398
|
+
/** Accepted input shape for `model.query`. */
|
|
399
|
+
export const MODEL_QUERY_INPUT_SCHEMA = {
|
|
400
|
+
type: 'object',
|
|
401
|
+
required: [],
|
|
402
|
+
additionalProperties: false,
|
|
403
|
+
properties: {
|
|
404
|
+
provider: {
|
|
405
|
+
type: 'string',
|
|
406
|
+
description: 'Optional provider filter (models.dev id); queries all providers when omitted.',
|
|
407
|
+
},
|
|
408
|
+
limit: {
|
|
409
|
+
type: 'number',
|
|
410
|
+
description: 'Optional cap on the number of rows returned (newest-first).',
|
|
411
|
+
},
|
|
412
|
+
},
|
|
413
|
+
};
|
|
414
|
+
/** Schema-first INPUT contract for `model.query`. */
|
|
415
|
+
export const modelQueryInputContract = {
|
|
416
|
+
operation: 'model.query',
|
|
417
|
+
schema: MODEL_QUERY_INPUT_SCHEMA,
|
|
418
|
+
examples: [
|
|
419
|
+
{ name: 'all', value: {}, description: 'Query the entire models.dev catalog.' },
|
|
420
|
+
{
|
|
421
|
+
name: 'one-provider',
|
|
422
|
+
value: { provider: 'anthropic', limit: 10 },
|
|
423
|
+
description: 'Query the 10 newest models for one provider.',
|
|
424
|
+
},
|
|
425
|
+
],
|
|
426
|
+
};
|
|
427
|
+
/** OUTPUT contract for `model.query` — catalog model views. */
|
|
428
|
+
export const modelQueryOutputContract = {
|
|
429
|
+
operation: 'model.query',
|
|
430
|
+
shapeNote: 'models[] are catalog views ordered newest-first by release_date. `count` is the number returned.',
|
|
431
|
+
dataSchema: {
|
|
432
|
+
type: 'object',
|
|
433
|
+
required: ['models', 'count'],
|
|
434
|
+
additionalProperties: true,
|
|
435
|
+
properties: {
|
|
436
|
+
models: { type: 'array', items: MODEL_VIEW_SCHEMA, description: 'Catalog model views.' },
|
|
437
|
+
count: { type: 'number', description: 'Number of models returned.' },
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
fieldPointers: ['/data/models', '/data/models/0/id', '/data/models/0/providerId', '/data/count'],
|
|
441
|
+
};
|
|
442
|
+
// ---------------------------------------------------------------------------
|
|
443
|
+
// model.show — one catalog model resolved by id
|
|
444
|
+
// ---------------------------------------------------------------------------
|
|
445
|
+
/** Accepted input shape for `model.show`. */
|
|
446
|
+
export const MODEL_SHOW_INPUT_SCHEMA = {
|
|
447
|
+
type: 'object',
|
|
448
|
+
required: ['model'],
|
|
449
|
+
additionalProperties: false,
|
|
450
|
+
properties: {
|
|
451
|
+
model: { type: 'string', minLength: 1, description: 'Model id (catalog key) to resolve.' },
|
|
452
|
+
},
|
|
453
|
+
};
|
|
454
|
+
/** Schema-first INPUT contract for `model.show`. */
|
|
455
|
+
export const modelShowInputContract = {
|
|
456
|
+
operation: 'model.show',
|
|
457
|
+
schema: MODEL_SHOW_INPUT_SCHEMA,
|
|
458
|
+
examples: [
|
|
459
|
+
{
|
|
460
|
+
name: 'by-id',
|
|
461
|
+
value: { model: 'claude-3-5-haiku-latest' },
|
|
462
|
+
description: 'Resolve a single catalog model by id.',
|
|
463
|
+
},
|
|
464
|
+
],
|
|
465
|
+
};
|
|
466
|
+
/** OUTPUT contract for `model.show` — one catalog model. */
|
|
467
|
+
export const modelShowOutputContract = {
|
|
468
|
+
operation: 'model.show',
|
|
469
|
+
shapeNote: '`model` is the resolved catalog view; `found` is false when the id is absent.',
|
|
470
|
+
dataSchema: {
|
|
471
|
+
type: 'object',
|
|
472
|
+
required: ['found'],
|
|
473
|
+
additionalProperties: true,
|
|
474
|
+
properties: {
|
|
475
|
+
found: { type: 'boolean', description: 'True IFF the model id resolved to a catalog row.' },
|
|
476
|
+
model: { ...MODEL_VIEW_SCHEMA, type: ['object', 'null'] },
|
|
477
|
+
},
|
|
478
|
+
},
|
|
479
|
+
fieldPointers: ['/data/found', '/data/model/id', '/data/model/providerId'],
|
|
480
|
+
};
|
|
481
|
+
// ---------------------------------------------------------------------------
|
|
482
|
+
// profile.create — bind an account + model into a named profile
|
|
483
|
+
// ---------------------------------------------------------------------------
|
|
484
|
+
/** Accepted input shape for `profile.create`. */
|
|
485
|
+
export const PROFILE_CREATE_INPUT_SCHEMA = {
|
|
486
|
+
type: 'object',
|
|
487
|
+
required: ['name', 'provider', 'model'],
|
|
488
|
+
additionalProperties: false,
|
|
489
|
+
properties: {
|
|
490
|
+
name: { type: 'string', minLength: 1, description: 'Profile name (the addressable handle).' },
|
|
491
|
+
provider: {
|
|
492
|
+
type: 'string',
|
|
493
|
+
minLength: 1,
|
|
494
|
+
description: 'Provider transport the bound account belongs to.',
|
|
495
|
+
},
|
|
496
|
+
model: {
|
|
497
|
+
type: 'string',
|
|
498
|
+
minLength: 1,
|
|
499
|
+
description: 'Model id to bind (validated vs catalog).',
|
|
500
|
+
},
|
|
501
|
+
label: {
|
|
502
|
+
type: 'string',
|
|
503
|
+
description: 'Account label to pin (the credential binding). Validated to exist.',
|
|
504
|
+
},
|
|
505
|
+
role: {
|
|
506
|
+
type: 'string',
|
|
507
|
+
description: 'Optional role this profile occupies (extraction | consolidation | …).',
|
|
508
|
+
},
|
|
509
|
+
},
|
|
510
|
+
};
|
|
511
|
+
/** Schema-first INPUT contract for `profile.create`. */
|
|
512
|
+
export const profileCreateInputContract = {
|
|
513
|
+
operation: 'profile.create',
|
|
514
|
+
schema: PROFILE_CREATE_INPUT_SCHEMA,
|
|
515
|
+
examples: [
|
|
516
|
+
{
|
|
517
|
+
name: 'create',
|
|
518
|
+
value: {
|
|
519
|
+
name: 'fast',
|
|
520
|
+
provider: 'anthropic',
|
|
521
|
+
model: 'claude-3-5-haiku-latest',
|
|
522
|
+
label: 'work',
|
|
523
|
+
},
|
|
524
|
+
description: 'Bind an account + model into a named, addressable profile.',
|
|
525
|
+
},
|
|
526
|
+
],
|
|
527
|
+
};
|
|
528
|
+
/** OUTPUT contract for `profile.create` — the persisted binding. */
|
|
529
|
+
export const profileCreateOutputContract = {
|
|
530
|
+
operation: 'profile.create',
|
|
531
|
+
shapeNote: 'Mutate envelope: count=1 + created=[name]. `profile` echoes the persisted binding {name, provider, model, credentialLabel?, role?}.',
|
|
532
|
+
dataSchema: {
|
|
533
|
+
type: 'object',
|
|
534
|
+
required: ['count', 'created'],
|
|
535
|
+
additionalProperties: true,
|
|
536
|
+
properties: {
|
|
537
|
+
count: { type: 'number' },
|
|
538
|
+
created: { type: 'array', items: { type: 'string' } },
|
|
539
|
+
profile: {
|
|
540
|
+
type: 'object',
|
|
541
|
+
additionalProperties: true,
|
|
542
|
+
properties: {
|
|
543
|
+
name: { type: 'string' },
|
|
544
|
+
provider: { type: 'string' },
|
|
545
|
+
model: { type: 'string' },
|
|
546
|
+
credentialLabel: { type: ['string', 'null'] },
|
|
547
|
+
role: { type: ['string', 'null'] },
|
|
548
|
+
},
|
|
549
|
+
},
|
|
550
|
+
},
|
|
551
|
+
},
|
|
552
|
+
fieldPointers: [
|
|
553
|
+
'/data/count',
|
|
554
|
+
'/data/created/0',
|
|
555
|
+
'/data/profile/name',
|
|
556
|
+
'/data/profile/provider',
|
|
557
|
+
'/data/profile/model',
|
|
558
|
+
],
|
|
559
|
+
};
|
|
560
|
+
// ---------------------------------------------------------------------------
|
|
561
|
+
// profile.list — named profiles from config (llm.profiles)
|
|
562
|
+
// ---------------------------------------------------------------------------
|
|
563
|
+
/** Accepted input shape for `profile.list`. */
|
|
564
|
+
export const PROFILE_LIST_INPUT_SCHEMA = {
|
|
565
|
+
type: 'object',
|
|
566
|
+
required: [],
|
|
567
|
+
additionalProperties: false,
|
|
568
|
+
properties: {},
|
|
569
|
+
};
|
|
570
|
+
/** Schema-first INPUT contract for `profile.list`. */
|
|
571
|
+
export const profileListInputContract = {
|
|
572
|
+
operation: 'profile.list',
|
|
573
|
+
schema: PROFILE_LIST_INPUT_SCHEMA,
|
|
574
|
+
examples: [{ name: 'all', value: {}, description: 'List every named profile.' }],
|
|
575
|
+
};
|
|
576
|
+
/** OUTPUT contract for `profile.list` — named binding views. */
|
|
577
|
+
export const profileListOutputContract = {
|
|
578
|
+
operation: 'profile.list',
|
|
579
|
+
shapeNote: 'profiles[] are the named bindings from llm.profiles (name + provider + model + optional credentialLabel/role).',
|
|
580
|
+
dataSchema: {
|
|
581
|
+
type: 'object',
|
|
582
|
+
required: ['profiles'],
|
|
583
|
+
additionalProperties: true,
|
|
584
|
+
properties: {
|
|
585
|
+
profiles: {
|
|
586
|
+
type: 'array',
|
|
587
|
+
items: {
|
|
588
|
+
type: 'object',
|
|
589
|
+
required: ['name', 'provider', 'model'],
|
|
590
|
+
additionalProperties: true,
|
|
591
|
+
properties: {
|
|
592
|
+
name: { type: 'string' },
|
|
593
|
+
provider: { type: 'string' },
|
|
594
|
+
model: { type: 'string' },
|
|
595
|
+
credentialLabel: { type: ['string', 'null'] },
|
|
596
|
+
},
|
|
597
|
+
},
|
|
598
|
+
},
|
|
599
|
+
},
|
|
600
|
+
},
|
|
601
|
+
fieldPointers: [
|
|
602
|
+
'/data/profiles',
|
|
603
|
+
'/data/profiles/0/name',
|
|
604
|
+
'/data/profiles/0/provider',
|
|
605
|
+
'/data/profiles/0/model',
|
|
606
|
+
],
|
|
607
|
+
};
|
|
608
|
+
// ---------------------------------------------------------------------------
|
|
609
|
+
// profile.pin — pin a role/system to a named profile
|
|
610
|
+
// ---------------------------------------------------------------------------
|
|
611
|
+
/** Accepted input shape for `profile.pin`. */
|
|
612
|
+
export const PROFILE_PIN_INPUT_SCHEMA = {
|
|
613
|
+
type: 'object',
|
|
614
|
+
required: ['name', 'role'],
|
|
615
|
+
additionalProperties: false,
|
|
616
|
+
properties: {
|
|
617
|
+
name: { type: 'string', minLength: 1, description: 'Profile name to pin (must exist).' },
|
|
618
|
+
role: {
|
|
619
|
+
type: 'string',
|
|
620
|
+
minLength: 1,
|
|
621
|
+
description: 'Role to pin to this profile (extraction | consolidation | derivation | …).',
|
|
622
|
+
},
|
|
623
|
+
},
|
|
624
|
+
};
|
|
625
|
+
/** Schema-first INPUT contract for `profile.pin`. */
|
|
626
|
+
export const profilePinInputContract = {
|
|
627
|
+
operation: 'profile.pin',
|
|
628
|
+
schema: PROFILE_PIN_INPUT_SCHEMA,
|
|
629
|
+
examples: [
|
|
630
|
+
{
|
|
631
|
+
name: 'pin',
|
|
632
|
+
value: { name: 'fast', role: 'extraction' },
|
|
633
|
+
description: 'Pin the extraction role to the `fast` profile.',
|
|
634
|
+
},
|
|
635
|
+
],
|
|
636
|
+
};
|
|
637
|
+
/** OUTPUT contract for `profile.pin` — the role→profile binding. */
|
|
638
|
+
export const profilePinOutputContract = {
|
|
639
|
+
operation: 'profile.pin',
|
|
640
|
+
shapeNote: 'Mutate envelope: count=1 + updated=[role]. `role` + `profile` echo the binding.',
|
|
641
|
+
dataSchema: {
|
|
642
|
+
type: 'object',
|
|
643
|
+
required: ['count', 'updated'],
|
|
644
|
+
additionalProperties: true,
|
|
645
|
+
properties: {
|
|
646
|
+
count: { type: 'number' },
|
|
647
|
+
updated: { type: 'array', items: { type: 'string' } },
|
|
648
|
+
role: { type: 'string' },
|
|
649
|
+
profile: { type: 'string' },
|
|
650
|
+
},
|
|
651
|
+
},
|
|
652
|
+
fieldPointers: ['/data/count', '/data/updated/0', '/data/role', '/data/profile'],
|
|
653
|
+
};
|
|
654
|
+
// ---------------------------------------------------------------------------
|
|
655
|
+
// profile.use — set a named profile as the global default binding
|
|
656
|
+
// ---------------------------------------------------------------------------
|
|
657
|
+
/** Accepted input shape for `profile.use`. */
|
|
658
|
+
export const PROFILE_USE_INPUT_SCHEMA = {
|
|
659
|
+
type: 'object',
|
|
660
|
+
required: ['name'],
|
|
661
|
+
additionalProperties: false,
|
|
662
|
+
properties: {
|
|
663
|
+
name: {
|
|
664
|
+
type: 'string',
|
|
665
|
+
minLength: 1,
|
|
666
|
+
description: 'Profile name to mark as default (must exist).',
|
|
667
|
+
},
|
|
668
|
+
},
|
|
669
|
+
};
|
|
670
|
+
/** Schema-first INPUT contract for `profile.use`. */
|
|
671
|
+
export const profileUseInputContract = {
|
|
672
|
+
operation: 'profile.use',
|
|
673
|
+
schema: PROFILE_USE_INPUT_SCHEMA,
|
|
674
|
+
examples: [
|
|
675
|
+
{ name: 'use', value: { name: 'fast' }, description: 'Make `fast` the default profile.' },
|
|
676
|
+
],
|
|
677
|
+
};
|
|
678
|
+
/** OUTPUT contract for `profile.use` — the default-profile binding. */
|
|
679
|
+
export const profileUseOutputContract = {
|
|
680
|
+
operation: 'profile.use',
|
|
681
|
+
shapeNote: 'Mutate envelope: count=1 + updated=[defaultProfile]. `profile` echoes the new default.',
|
|
682
|
+
dataSchema: {
|
|
683
|
+
type: 'object',
|
|
684
|
+
required: ['count', 'updated'],
|
|
685
|
+
additionalProperties: true,
|
|
686
|
+
properties: {
|
|
687
|
+
count: { type: 'number' },
|
|
688
|
+
updated: { type: 'array', items: { type: 'string' } },
|
|
689
|
+
profile: { type: 'string', description: 'The profile name set as default.' },
|
|
690
|
+
scope: { type: 'string', enum: ['global'] },
|
|
691
|
+
},
|
|
692
|
+
},
|
|
693
|
+
fieldPointers: ['/data/count', '/data/updated/0', '/data/profile'],
|
|
694
|
+
};
|
|
695
|
+
//# sourceMappingURL=entities.js.map
|