@peer-agent/protocol 0.0.1-beta.43
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/LICENSE +21 -0
- package/README.md +25 -0
- package/dist/chat.d.ts +222 -0
- package/dist/chat.js +29 -0
- package/dist/compaction.d.ts +37 -0
- package/dist/compaction.js +40 -0
- package/dist/context-accounting.d.ts +84 -0
- package/dist/context-accounting.js +21 -0
- package/dist/execution.d.ts +257 -0
- package/dist/execution.js +1 -0
- package/dist/goal.d.ts +378 -0
- package/dist/goal.js +1 -0
- package/dist/index.d.ts +682 -0
- package/dist/index.js +23 -0
- package/dist/memory.d.ts +104 -0
- package/dist/memory.js +1 -0
- package/dist/system-context.d.ts +184 -0
- package/dist/system-context.js +1 -0
- package/dist/updater.d.ts +72 -0
- package/dist/updater.js +1 -0
- package/dist/usage-accounting.d.ts +29 -0
- package/dist/usage-accounting.js +1 -0
- package/package.json +43 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,682 @@
|
|
|
1
|
+
export type LocalAccessLevel = 'ask_before_local' | 'session_local' | 'restricted_local' | 'full_local';
|
|
2
|
+
export type { ConversationLifetimeUsage, ProviderRequestUsage, RuntimeTurnUsage, UsageAmounts, UsageScope, } from './usage-accounting.ts';
|
|
3
|
+
export type CapabilityRiskLevel = 'L0_inert' | 'L1_local_read' | 'L2_local_write' | 'L3_external_write' | 'L4_privileged' | 'L5_destructive';
|
|
4
|
+
export type DataLevel = 'D0_public' | 'D1_internal' | 'D2_sensitive' | 'D3_private' | 'D4_regulated';
|
|
5
|
+
export type CapabilitySource = 'native' | 'shell' | 'plugin' | 'mcp' | 'page_bridge' | 'private' | 'web';
|
|
6
|
+
export type CapabilityHealth = 'available' | 'needs_permission' | 'policy_disabled' | 'local_disabled' | 'unhealthy';
|
|
7
|
+
export type LocaleCode = 'zh-CN' | 'en-US';
|
|
8
|
+
export type LocalizedText = Partial<Record<LocaleCode, string>>;
|
|
9
|
+
export interface JsonSchemaLike {
|
|
10
|
+
readonly type?: string;
|
|
11
|
+
readonly properties?: Record<string, JsonSchemaLike>;
|
|
12
|
+
readonly required?: readonly string[];
|
|
13
|
+
readonly items?: JsonSchemaLike;
|
|
14
|
+
readonly enum?: readonly string[];
|
|
15
|
+
readonly description?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface EvidencePolicy {
|
|
18
|
+
readonly returnMode: 'none' | 'summary' | 'diff' | 'redacted_output' | 'artifact_ref';
|
|
19
|
+
readonly maxChars?: number;
|
|
20
|
+
readonly redactSensitive: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface CapabilityManifest {
|
|
23
|
+
readonly capabilityId: string;
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly description: string;
|
|
26
|
+
readonly localizedName?: LocalizedText;
|
|
27
|
+
readonly localizedDescription?: LocalizedText;
|
|
28
|
+
readonly source: CapabilitySource;
|
|
29
|
+
readonly riskLevel: CapabilityRiskLevel;
|
|
30
|
+
readonly dataLevel: DataLevel;
|
|
31
|
+
readonly health: CapabilityHealth;
|
|
32
|
+
readonly inputSchema: JsonSchemaLike;
|
|
33
|
+
readonly evidencePolicy: EvidencePolicy;
|
|
34
|
+
/**
|
|
35
|
+
* Optional human-readable label. For MCP tools this is `${serverName}: ${toolName}`,
|
|
36
|
+
* used by the header capabilities popover to render tool rows.
|
|
37
|
+
*/
|
|
38
|
+
readonly displayName?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Optional provider grouping key. For MCP capabilities this is the MCP server id,
|
|
41
|
+
* letting the UI aggregate every tool of one server under a single collapsible node.
|
|
42
|
+
*/
|
|
43
|
+
readonly providerId?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Optional provider display label (e.g. the MCP server's display name), shown as the
|
|
46
|
+
* service node title when capabilities are grouped by provider.
|
|
47
|
+
*/
|
|
48
|
+
readonly providerLabel?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface SkillSummary {
|
|
51
|
+
readonly skillId: string;
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly description: string;
|
|
54
|
+
readonly version: string;
|
|
55
|
+
readonly dataLevel: DataLevel;
|
|
56
|
+
readonly enabled: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 可从外部「借用来源」(如 a1 公共 skill 仓 ~/.agents/skills)借用的技能条目。
|
|
60
|
+
* linked=true 表示已在本地 userData/skills 下建立软链。
|
|
61
|
+
*/
|
|
62
|
+
export interface AvailableSkillSummary {
|
|
63
|
+
readonly skillId: string;
|
|
64
|
+
readonly name: string;
|
|
65
|
+
readonly description: string;
|
|
66
|
+
readonly version: string;
|
|
67
|
+
readonly dataLevel: DataLevel;
|
|
68
|
+
readonly sourceRoot: string;
|
|
69
|
+
readonly sourceDir: string;
|
|
70
|
+
readonly linked: boolean;
|
|
71
|
+
}
|
|
72
|
+
/** linkSkill / unlinkSkill 的返回结果。 */
|
|
73
|
+
export interface SkillLinkResult {
|
|
74
|
+
readonly ok: boolean;
|
|
75
|
+
readonly error?: string;
|
|
76
|
+
readonly detail?: string;
|
|
77
|
+
readonly alreadyLinked?: boolean;
|
|
78
|
+
}
|
|
79
|
+
export interface RuntimeProjection {
|
|
80
|
+
readonly projectionId: string;
|
|
81
|
+
readonly sessionId: string;
|
|
82
|
+
readonly accessLevel: LocalAccessLevel;
|
|
83
|
+
readonly capabilities: readonly CapabilityManifest[];
|
|
84
|
+
readonly skills?: readonly SkillSummary[];
|
|
85
|
+
readonly createdAt: string;
|
|
86
|
+
}
|
|
87
|
+
export type McpTransportKind = 'streamable_http' | 'sse' | 'stdio';
|
|
88
|
+
export type McpHealthStatus = 'unknown' | 'ok' | 'failed';
|
|
89
|
+
export type McpAuthMode = 'none' | 'http_bearer' | 'http_header' | 'stdio_env' | 'oauth2';
|
|
90
|
+
export type McpCredentialKind = Exclude<McpAuthMode, 'none'>;
|
|
91
|
+
export interface McpOAuthConfigView {
|
|
92
|
+
readonly authorizationServerUrl?: string;
|
|
93
|
+
readonly clientId?: string;
|
|
94
|
+
readonly clientSecretConfigured?: boolean;
|
|
95
|
+
readonly scopes?: readonly string[];
|
|
96
|
+
readonly redirectUrl?: string;
|
|
97
|
+
readonly tokenStatus?: 'missing' | 'available';
|
|
98
|
+
readonly expiresAt?: string;
|
|
99
|
+
}
|
|
100
|
+
export interface McpAuthBindingView {
|
|
101
|
+
readonly mode: McpAuthMode;
|
|
102
|
+
readonly credentialRef?: string;
|
|
103
|
+
readonly headerName?: string;
|
|
104
|
+
readonly envName?: string;
|
|
105
|
+
readonly oauth?: McpOAuthConfigView;
|
|
106
|
+
}
|
|
107
|
+
export interface McpCredentialMetadataView {
|
|
108
|
+
readonly id: string;
|
|
109
|
+
readonly credentialRef: string;
|
|
110
|
+
readonly label: string;
|
|
111
|
+
readonly kind: McpCredentialKind;
|
|
112
|
+
readonly target: 'header' | 'env' | 'oauth';
|
|
113
|
+
readonly headerName?: string;
|
|
114
|
+
readonly envName?: string;
|
|
115
|
+
readonly oauth?: McpOAuthConfigView;
|
|
116
|
+
readonly createdAt: string;
|
|
117
|
+
readonly updatedAt: string;
|
|
118
|
+
readonly lastFour?: string;
|
|
119
|
+
readonly storage?: 'safeStorage' | 'file-fallback';
|
|
120
|
+
}
|
|
121
|
+
export interface McpCredentialPutRequest {
|
|
122
|
+
readonly credentialRef?: string;
|
|
123
|
+
readonly label?: string;
|
|
124
|
+
readonly kind: McpCredentialKind;
|
|
125
|
+
readonly secret?: string;
|
|
126
|
+
readonly headerName?: string;
|
|
127
|
+
readonly envName?: string;
|
|
128
|
+
readonly oauth?: {
|
|
129
|
+
readonly authorizationServerUrl?: string;
|
|
130
|
+
readonly clientId?: string;
|
|
131
|
+
readonly clientSecret?: string;
|
|
132
|
+
readonly scopes?: readonly string[];
|
|
133
|
+
readonly redirectUrl?: string;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
export interface McpOAuthLoginRequest {
|
|
137
|
+
readonly serverId: string;
|
|
138
|
+
}
|
|
139
|
+
export interface McpOAuthLoginResult {
|
|
140
|
+
readonly ok: boolean;
|
|
141
|
+
readonly credential?: McpCredentialMetadataView;
|
|
142
|
+
readonly error?: string;
|
|
143
|
+
}
|
|
144
|
+
export interface McpHealthView {
|
|
145
|
+
readonly status: McpHealthStatus;
|
|
146
|
+
readonly checkedAt?: string | null;
|
|
147
|
+
readonly message?: string;
|
|
148
|
+
}
|
|
149
|
+
export interface McpToolSummary {
|
|
150
|
+
readonly name: string;
|
|
151
|
+
readonly description?: string;
|
|
152
|
+
readonly visible?: boolean;
|
|
153
|
+
readonly inputSchema?: JsonSchemaLike;
|
|
154
|
+
}
|
|
155
|
+
export interface McpResourceSummary {
|
|
156
|
+
readonly uri: string;
|
|
157
|
+
readonly name?: string;
|
|
158
|
+
readonly description?: string;
|
|
159
|
+
readonly mimeType?: string;
|
|
160
|
+
}
|
|
161
|
+
export interface McpPromptSummary {
|
|
162
|
+
readonly name: string;
|
|
163
|
+
readonly description?: string;
|
|
164
|
+
readonly arguments?: readonly Record<string, unknown>[];
|
|
165
|
+
}
|
|
166
|
+
export interface LocalMcpServerView {
|
|
167
|
+
readonly id: string;
|
|
168
|
+
readonly mcpId: string;
|
|
169
|
+
readonly displayName: string;
|
|
170
|
+
readonly name: string;
|
|
171
|
+
/** Name the MCP server reports during the initialize handshake. */
|
|
172
|
+
readonly reportedName?: string | null;
|
|
173
|
+
/** Version the MCP server reports during the initialize handshake. */
|
|
174
|
+
readonly reportedVersion?: string | null;
|
|
175
|
+
readonly description?: string;
|
|
176
|
+
readonly enabled: boolean;
|
|
177
|
+
readonly transport: McpTransportKind;
|
|
178
|
+
readonly commandPreview?: string;
|
|
179
|
+
readonly urlPreview?: string;
|
|
180
|
+
readonly serverUrl?: string;
|
|
181
|
+
readonly auth?: McpAuthBindingView;
|
|
182
|
+
readonly toolsCount: number;
|
|
183
|
+
readonly visibleToolsCount: number;
|
|
184
|
+
readonly resourcesCount: number;
|
|
185
|
+
readonly promptsCount: number;
|
|
186
|
+
readonly tools: readonly McpToolSummary[];
|
|
187
|
+
readonly resources: readonly McpResourceSummary[];
|
|
188
|
+
readonly prompts: readonly McpPromptSummary[];
|
|
189
|
+
readonly health: McpHealthView;
|
|
190
|
+
readonly manifestUpdatedAt?: string | null;
|
|
191
|
+
readonly lastError?: string | null;
|
|
192
|
+
readonly createdAt?: string;
|
|
193
|
+
readonly updatedAt?: string;
|
|
194
|
+
}
|
|
195
|
+
export interface LocalMcpServerUpsertRequest {
|
|
196
|
+
readonly id?: string;
|
|
197
|
+
readonly mcpId?: string;
|
|
198
|
+
readonly displayName?: string;
|
|
199
|
+
readonly name?: string;
|
|
200
|
+
readonly description?: string;
|
|
201
|
+
readonly enabled?: boolean;
|
|
202
|
+
readonly transport: McpTransportKind;
|
|
203
|
+
readonly command?: string;
|
|
204
|
+
readonly args?: readonly string[];
|
|
205
|
+
readonly cwd?: string | null;
|
|
206
|
+
readonly env?: Record<string, string>;
|
|
207
|
+
readonly url?: string;
|
|
208
|
+
readonly serverUrl?: string;
|
|
209
|
+
readonly headers?: Record<string, string>;
|
|
210
|
+
readonly auth?: McpAuthBindingView;
|
|
211
|
+
}
|
|
212
|
+
export interface McpConnectionTestResult {
|
|
213
|
+
readonly ok: boolean;
|
|
214
|
+
readonly health: McpHealthView;
|
|
215
|
+
readonly toolsCount: number;
|
|
216
|
+
readonly resourcesCount: number;
|
|
217
|
+
readonly promptsCount: number;
|
|
218
|
+
readonly errors?: readonly {
|
|
219
|
+
readonly kind: string;
|
|
220
|
+
readonly message: string;
|
|
221
|
+
}[];
|
|
222
|
+
}
|
|
223
|
+
export type McpConnectionProbeState = 'connected' | 'needs_auth' | 'failed';
|
|
224
|
+
export interface McpConnectionProbeAuthAction {
|
|
225
|
+
readonly type: 'oauth' | 'unknown';
|
|
226
|
+
readonly authorizationUrl?: string;
|
|
227
|
+
readonly message?: string;
|
|
228
|
+
}
|
|
229
|
+
export interface McpConnectionProbeResult {
|
|
230
|
+
readonly state: McpConnectionProbeState;
|
|
231
|
+
readonly ok: boolean;
|
|
232
|
+
readonly view?: LocalMcpServerView;
|
|
233
|
+
readonly manifest?: McpManifestRefreshResult['manifest'];
|
|
234
|
+
readonly health: McpHealthView;
|
|
235
|
+
readonly toolsCount: number;
|
|
236
|
+
readonly resourcesCount: number;
|
|
237
|
+
readonly promptsCount: number;
|
|
238
|
+
readonly auth?: McpConnectionProbeAuthAction;
|
|
239
|
+
readonly message?: string;
|
|
240
|
+
readonly errors?: readonly {
|
|
241
|
+
readonly kind: string;
|
|
242
|
+
readonly message: string;
|
|
243
|
+
}[];
|
|
244
|
+
}
|
|
245
|
+
export interface McpManifestRefreshResult {
|
|
246
|
+
readonly view: LocalMcpServerView;
|
|
247
|
+
readonly manifest: {
|
|
248
|
+
readonly discoveredAt: string;
|
|
249
|
+
readonly serverInfo?: {
|
|
250
|
+
readonly name?: string;
|
|
251
|
+
readonly version?: string;
|
|
252
|
+
};
|
|
253
|
+
readonly tools: readonly McpToolSummary[];
|
|
254
|
+
readonly resources: readonly McpResourceSummary[];
|
|
255
|
+
readonly prompts: readonly McpPromptSummary[];
|
|
256
|
+
readonly errors?: readonly {
|
|
257
|
+
readonly kind: string;
|
|
258
|
+
readonly message: string;
|
|
259
|
+
}[];
|
|
260
|
+
readonly health: McpHealthView;
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
export interface ClientSessionState {
|
|
264
|
+
readonly sessionId: string;
|
|
265
|
+
readonly status: 'local_ready' | 'hybrid_ready' | 'permission_required' | 'degraded' | 'offline';
|
|
266
|
+
readonly accessLevel: LocalAccessLevel;
|
|
267
|
+
readonly capabilityCount: number;
|
|
268
|
+
readonly pendingReviewCount: number;
|
|
269
|
+
readonly locale: LocaleCode;
|
|
270
|
+
readonly workspaceLabel?: string;
|
|
271
|
+
}
|
|
272
|
+
export interface GitProjectState {
|
|
273
|
+
readonly branch?: string;
|
|
274
|
+
readonly remote?: string;
|
|
275
|
+
readonly modifiedCount: number;
|
|
276
|
+
readonly untrackedCount: number;
|
|
277
|
+
readonly stagedCount: number;
|
|
278
|
+
readonly ahead: number;
|
|
279
|
+
readonly behind: number;
|
|
280
|
+
readonly isDirty: boolean;
|
|
281
|
+
}
|
|
282
|
+
export interface WorkspaceProject {
|
|
283
|
+
readonly projectId: string;
|
|
284
|
+
readonly name: string;
|
|
285
|
+
readonly absolutePath: string;
|
|
286
|
+
readonly relativePath: string;
|
|
287
|
+
readonly kind: 'workspace_root' | 'workspace_package' | 'directory';
|
|
288
|
+
readonly packageName?: string;
|
|
289
|
+
readonly git?: GitProjectState;
|
|
290
|
+
readonly updatedAt: string;
|
|
291
|
+
}
|
|
292
|
+
export type LlmProviderType = 'openai' | 'anthropic';
|
|
293
|
+
export type LlmWireProtocol = 'openai-chat' | 'openai-responses' | 'anthropic-messages' | 'gemini' | 'qoder-private';
|
|
294
|
+
export type LlmChannelId = string;
|
|
295
|
+
export type LlmReasoningParamStyle = 'openai-effort' | 'anthropic-enabled-budget' | 'anthropic-adaptive-effort' | 'anthropic-output-effort' | 'qwen-enable' | 'none';
|
|
296
|
+
export type LlmReasoningEffortMap = Readonly<Record<string, string | number>>;
|
|
297
|
+
export interface LlmChannelDescriptor {
|
|
298
|
+
readonly id: LlmChannelId;
|
|
299
|
+
readonly label: string;
|
|
300
|
+
readonly legacyProvider: LlmProviderType;
|
|
301
|
+
readonly defaultWire: LlmWireProtocol;
|
|
302
|
+
readonly allowedWires: readonly LlmWireProtocol[];
|
|
303
|
+
readonly defaults: {
|
|
304
|
+
readonly baseUrl: string;
|
|
305
|
+
readonly model: string;
|
|
306
|
+
};
|
|
307
|
+
readonly capabilities?: {
|
|
308
|
+
readonly reasoning?: {
|
|
309
|
+
readonly supported: boolean;
|
|
310
|
+
readonly paramStyle: LlmReasoningParamStyle;
|
|
311
|
+
readonly effortLevels?: readonly string[];
|
|
312
|
+
readonly defaultEffort?: string;
|
|
313
|
+
readonly effortMap?: LlmReasoningEffortMap;
|
|
314
|
+
};
|
|
315
|
+
readonly promptCache?: boolean;
|
|
316
|
+
readonly vision?: boolean;
|
|
317
|
+
readonly toolUse?: boolean;
|
|
318
|
+
readonly temperature?: boolean;
|
|
319
|
+
};
|
|
320
|
+
readonly authMethods?: Partial<Readonly<Record<LlmAuthMethod, {
|
|
321
|
+
readonly wire: LlmWireProtocol;
|
|
322
|
+
}>>>;
|
|
323
|
+
}
|
|
324
|
+
export type LlmAuthMethod = 'api_key' | 'oauth_chatgpt' | 'oauth_google' | 'oauth_grok' | 'qoder_local_auth' | 'local_cli';
|
|
325
|
+
export type LlmOAuthConnectionStatus = 'connected' | 'expired' | 'disconnected';
|
|
326
|
+
export interface LlmOAuthStatus {
|
|
327
|
+
readonly status: LlmOAuthConnectionStatus;
|
|
328
|
+
readonly accountId?: string;
|
|
329
|
+
readonly expiresAt?: string;
|
|
330
|
+
}
|
|
331
|
+
/** 订阅额度窗口(session / weekly / model 等)。 */
|
|
332
|
+
export interface LlmSubscriptionQuotaWindow {
|
|
333
|
+
readonly id: string;
|
|
334
|
+
readonly label?: string;
|
|
335
|
+
readonly remainingPercent?: number;
|
|
336
|
+
readonly usedPercent?: number;
|
|
337
|
+
readonly resetsAt?: string;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* GPT / Gemini / Grok 订阅额度快照。
|
|
341
|
+
* success=false 时用 status/error 表达未登录、过期或拉取失败,UI 应降级展示。
|
|
342
|
+
*/
|
|
343
|
+
export interface LlmSubscriptionQuota {
|
|
344
|
+
readonly success: boolean;
|
|
345
|
+
readonly status?: string;
|
|
346
|
+
readonly providerId?: string;
|
|
347
|
+
readonly authMethod?: LlmAuthMethod;
|
|
348
|
+
readonly provider?: 'chatgpt' | 'gemini' | 'grok' | string;
|
|
349
|
+
readonly planLabel?: string;
|
|
350
|
+
readonly remainingPercent?: number;
|
|
351
|
+
readonly usedPercent?: number;
|
|
352
|
+
readonly resetsAt?: string;
|
|
353
|
+
readonly windows?: readonly LlmSubscriptionQuotaWindow[];
|
|
354
|
+
readonly accountId?: string;
|
|
355
|
+
readonly projectId?: string;
|
|
356
|
+
readonly fetchedAt?: string;
|
|
357
|
+
readonly cached?: boolean;
|
|
358
|
+
readonly error?: string;
|
|
359
|
+
}
|
|
360
|
+
export interface LlmProviderConfig {
|
|
361
|
+
readonly id: string;
|
|
362
|
+
readonly groupId?: string;
|
|
363
|
+
readonly provider: LlmProviderType;
|
|
364
|
+
readonly channelId?: LlmChannelId;
|
|
365
|
+
readonly resolvedWire?: LlmWireProtocol;
|
|
366
|
+
readonly wireOverride?: LlmWireProtocol;
|
|
367
|
+
readonly authMethod: LlmAuthMethod;
|
|
368
|
+
readonly name: string;
|
|
369
|
+
readonly baseUrl: string;
|
|
370
|
+
readonly model: string;
|
|
371
|
+
readonly modelLabel?: string;
|
|
372
|
+
readonly metadataSource?: 'remote' | 'models.dev' | 'builtin' | 'local' | 'manual';
|
|
373
|
+
readonly pricingSource?: 'provider' | 'models.dev-reference';
|
|
374
|
+
readonly metadataSyncedAt?: string;
|
|
375
|
+
readonly enabled: boolean;
|
|
376
|
+
readonly isDefault: boolean;
|
|
377
|
+
readonly createdAt: string;
|
|
378
|
+
readonly contextWindow?: number;
|
|
379
|
+
readonly maxOutputTokens?: number;
|
|
380
|
+
readonly modelOptions?: readonly LlmModelOptionDefinition[];
|
|
381
|
+
readonly modelOptionValues?: LlmModelOptionValues;
|
|
382
|
+
readonly inputPrice?: number;
|
|
383
|
+
readonly outputPrice?: number;
|
|
384
|
+
readonly cacheWritePrice?: number;
|
|
385
|
+
readonly cacheReadPrice?: number;
|
|
386
|
+
readonly longContextInputThreshold?: number;
|
|
387
|
+
readonly longContextInputPrice?: number;
|
|
388
|
+
readonly longContextCacheReadPrice?: number;
|
|
389
|
+
readonly longContextOutputPrice?: number;
|
|
390
|
+
readonly supportsVision?: boolean;
|
|
391
|
+
readonly supportsReasoning?: boolean;
|
|
392
|
+
readonly supportsPromptCaching?: boolean;
|
|
393
|
+
readonly reasoningParamStyle?: LlmReasoningParamStyle;
|
|
394
|
+
readonly reasoningEffortMap?: LlmReasoningEffortMap;
|
|
395
|
+
readonly reasoningEffortLevels?: readonly string[];
|
|
396
|
+
/** 渠道默认思考强度(如 Grok 为 high)。UI 切模型时用于落到正确默认档。 */
|
|
397
|
+
readonly reasoningDefaultEffort?: string;
|
|
398
|
+
readonly oauthProjectId?: string;
|
|
399
|
+
readonly customHeaders?: Readonly<Record<string, string>>;
|
|
400
|
+
readonly customHeadersInvalid?: boolean;
|
|
401
|
+
}
|
|
402
|
+
export interface LlmProviderConfigView extends LlmProviderConfig {
|
|
403
|
+
readonly apiKeyMasked: string;
|
|
404
|
+
readonly apiKeyConfigured: boolean;
|
|
405
|
+
readonly oauthStatus?: LlmOAuthStatus;
|
|
406
|
+
readonly credentialId?: string;
|
|
407
|
+
}
|
|
408
|
+
export interface LlmModelConfig {
|
|
409
|
+
readonly id: string;
|
|
410
|
+
readonly model: string;
|
|
411
|
+
readonly label?: string;
|
|
412
|
+
readonly enabled: boolean;
|
|
413
|
+
readonly createdAt: string;
|
|
414
|
+
readonly resolvedWire?: LlmWireProtocol;
|
|
415
|
+
readonly wireOverride?: LlmWireProtocol;
|
|
416
|
+
readonly contextWindow?: number;
|
|
417
|
+
readonly maxOutputTokens?: number;
|
|
418
|
+
readonly inputPrice?: number;
|
|
419
|
+
readonly outputPrice?: number;
|
|
420
|
+
readonly cacheWritePrice?: number;
|
|
421
|
+
readonly cacheReadPrice?: number;
|
|
422
|
+
readonly longContextInputThreshold?: number;
|
|
423
|
+
readonly longContextInputPrice?: number;
|
|
424
|
+
readonly longContextCacheReadPrice?: number;
|
|
425
|
+
readonly longContextOutputPrice?: number;
|
|
426
|
+
readonly supportsVision?: boolean;
|
|
427
|
+
readonly supportsReasoning?: boolean;
|
|
428
|
+
readonly supportsPromptCaching?: boolean;
|
|
429
|
+
readonly reasoningParamStyle?: LlmReasoningParamStyle;
|
|
430
|
+
readonly reasoningEffortMap?: LlmReasoningEffortMap;
|
|
431
|
+
readonly reasoningEffortLevels?: readonly string[];
|
|
432
|
+
/** 渠道默认思考强度(如 Grok 为 high)。 */
|
|
433
|
+
readonly reasoningDefaultEffort?: string;
|
|
434
|
+
readonly customHeaders?: Readonly<Record<string, string>>;
|
|
435
|
+
readonly customHeadersInvalid?: boolean;
|
|
436
|
+
}
|
|
437
|
+
export interface LlmProviderGroupConfig {
|
|
438
|
+
readonly id: string;
|
|
439
|
+
readonly provider: LlmProviderType;
|
|
440
|
+
readonly channelId?: LlmChannelId;
|
|
441
|
+
readonly authMethod: LlmAuthMethod;
|
|
442
|
+
readonly name: string;
|
|
443
|
+
readonly baseUrl: string;
|
|
444
|
+
readonly createdAt: string;
|
|
445
|
+
readonly oauthProjectId?: string;
|
|
446
|
+
readonly models: readonly LlmModelConfig[];
|
|
447
|
+
}
|
|
448
|
+
export interface LlmProviderGroupConfigView extends LlmProviderGroupConfig {
|
|
449
|
+
readonly apiKeyMasked: string;
|
|
450
|
+
readonly apiKeyConfigured: boolean;
|
|
451
|
+
readonly oauthStatus?: LlmOAuthStatus;
|
|
452
|
+
readonly defaultComboId?: string;
|
|
453
|
+
}
|
|
454
|
+
export type LlmModelOptionValue = string | number | boolean;
|
|
455
|
+
export interface LlmModelOptionChoice {
|
|
456
|
+
readonly value: LlmModelOptionValue;
|
|
457
|
+
readonly label: string;
|
|
458
|
+
readonly description?: string;
|
|
459
|
+
readonly requestValue?: LlmModelOptionValue;
|
|
460
|
+
readonly contextWindow?: number;
|
|
461
|
+
readonly inputTokenLimit?: number;
|
|
462
|
+
}
|
|
463
|
+
export interface LlmModelOptionDefinition {
|
|
464
|
+
readonly id: string;
|
|
465
|
+
readonly label: string;
|
|
466
|
+
readonly kind: 'select';
|
|
467
|
+
readonly description?: string;
|
|
468
|
+
readonly defaultValue: LlmModelOptionValue;
|
|
469
|
+
readonly choices: readonly LlmModelOptionChoice[];
|
|
470
|
+
}
|
|
471
|
+
export type LlmModelOptionValues = Readonly<Record<string, LlmModelOptionValue>>;
|
|
472
|
+
export declare function resolveLlmModelOptionValues(definitions: readonly LlmModelOptionDefinition[] | undefined, values: LlmModelOptionValues | undefined): LlmModelOptionValues;
|
|
473
|
+
export declare function resolveLlmModelOptionChoice(definition: LlmModelOptionDefinition, values: LlmModelOptionValues | undefined): LlmModelOptionChoice | undefined;
|
|
474
|
+
export interface LlmModelInfo {
|
|
475
|
+
readonly id: string;
|
|
476
|
+
readonly label: string;
|
|
477
|
+
readonly created?: number;
|
|
478
|
+
readonly contextWindow?: number;
|
|
479
|
+
readonly maxOutputTokens?: number;
|
|
480
|
+
readonly modelOptions?: readonly LlmModelOptionDefinition[];
|
|
481
|
+
readonly modelOptionValues?: LlmModelOptionValues;
|
|
482
|
+
readonly supportsVision?: boolean;
|
|
483
|
+
readonly supportsReasoning?: boolean;
|
|
484
|
+
readonly metadataSource?: 'provider' | 'models.dev';
|
|
485
|
+
readonly pricingSource?: 'provider' | 'models.dev-reference';
|
|
486
|
+
readonly inputPrice?: number;
|
|
487
|
+
readonly outputPrice?: number;
|
|
488
|
+
readonly cacheReadPrice?: number;
|
|
489
|
+
readonly cacheWritePrice?: number;
|
|
490
|
+
readonly longContextInputThreshold?: number;
|
|
491
|
+
readonly longContextInputPrice?: number;
|
|
492
|
+
readonly longContextCacheReadPrice?: number;
|
|
493
|
+
readonly longContextOutputPrice?: number;
|
|
494
|
+
}
|
|
495
|
+
export interface LlmModelListResult {
|
|
496
|
+
readonly success: boolean;
|
|
497
|
+
readonly models: readonly LlmModelInfo[];
|
|
498
|
+
readonly source?: 'builtin' | 'remote' | 'fallback' | 'local';
|
|
499
|
+
readonly error?: string;
|
|
500
|
+
}
|
|
501
|
+
export interface LlmModelFetchRequest {
|
|
502
|
+
readonly channelId?: string;
|
|
503
|
+
readonly wireOverride?: string;
|
|
504
|
+
/** Qoder 私有接口等本机鉴权渠道需要显式传入,避免 fetch 路径被默认当成 api_key。 */
|
|
505
|
+
readonly authMethod?: LlmAuthMethod;
|
|
506
|
+
readonly baseUrl?: string;
|
|
507
|
+
readonly apiKey?: string;
|
|
508
|
+
readonly customHeaders?: Record<string, string>;
|
|
509
|
+
}
|
|
510
|
+
export interface LlmProviderTestResult {
|
|
511
|
+
readonly success: boolean;
|
|
512
|
+
readonly model?: string;
|
|
513
|
+
readonly latencyMs?: number;
|
|
514
|
+
readonly error?: string;
|
|
515
|
+
}
|
|
516
|
+
export interface ClientBootstrap {
|
|
517
|
+
readonly session: ClientSessionState;
|
|
518
|
+
readonly capabilities: readonly CapabilityManifest[];
|
|
519
|
+
readonly projects: readonly WorkspaceProject[];
|
|
520
|
+
readonly activeProjectId: string;
|
|
521
|
+
readonly availableLocales: readonly LocaleCode[];
|
|
522
|
+
readonly llmProviders: readonly LlmProviderConfigView[];
|
|
523
|
+
}
|
|
524
|
+
export interface CapabilitySelection {
|
|
525
|
+
readonly capabilityId: string;
|
|
526
|
+
readonly reason: string;
|
|
527
|
+
readonly argumentsPreview: Record<string, unknown>;
|
|
528
|
+
}
|
|
529
|
+
export interface ClientToolConfirmation {
|
|
530
|
+
readonly kind: string;
|
|
531
|
+
readonly detail?: string;
|
|
532
|
+
readonly reason?: string;
|
|
533
|
+
readonly riskLevel?: CapabilityRiskLevel;
|
|
534
|
+
readonly [key: string]: unknown;
|
|
535
|
+
}
|
|
536
|
+
export interface RuntimeToolCall {
|
|
537
|
+
readonly toolCallId: string;
|
|
538
|
+
readonly capabilityId: string;
|
|
539
|
+
readonly arguments?: unknown;
|
|
540
|
+
readonly argumentsPreview?: unknown;
|
|
541
|
+
readonly [key: string]: unknown;
|
|
542
|
+
}
|
|
543
|
+
export interface RuntimeToolResult {
|
|
544
|
+
readonly toolCallId?: string;
|
|
545
|
+
readonly status?: string;
|
|
546
|
+
readonly evidence?: unknown;
|
|
547
|
+
readonly [key: string]: unknown;
|
|
548
|
+
}
|
|
549
|
+
export interface RuntimeExecuteRequest {
|
|
550
|
+
readonly sessionId?: string;
|
|
551
|
+
readonly projectionId?: string;
|
|
552
|
+
readonly conversationId?: string;
|
|
553
|
+
readonly call: RuntimeToolCall;
|
|
554
|
+
readonly [key: string]: unknown;
|
|
555
|
+
}
|
|
556
|
+
export interface RuntimeExecutionContext {
|
|
557
|
+
readonly workspaceRoot?: string;
|
|
558
|
+
readonly [key: string]: unknown;
|
|
559
|
+
}
|
|
560
|
+
export interface ClientToolCall extends RuntimeToolCall {
|
|
561
|
+
readonly displayName: string;
|
|
562
|
+
readonly reason: string;
|
|
563
|
+
readonly arguments?: Record<string, unknown>;
|
|
564
|
+
readonly argumentsPreview: Record<string, unknown>;
|
|
565
|
+
readonly confirmation?: ClientToolConfirmation;
|
|
566
|
+
readonly riskLevel: CapabilityRiskLevel;
|
|
567
|
+
readonly dataLevel: DataLevel;
|
|
568
|
+
readonly requestedAt: string;
|
|
569
|
+
}
|
|
570
|
+
export interface ClientToolCallPollRequest {
|
|
571
|
+
readonly sessionId: string;
|
|
572
|
+
readonly projectionId?: string;
|
|
573
|
+
readonly conversationId?: number;
|
|
574
|
+
readonly cursor?: string;
|
|
575
|
+
readonly limit?: number;
|
|
576
|
+
readonly polledAt: string;
|
|
577
|
+
}
|
|
578
|
+
export interface ClientToolCallPollResult {
|
|
579
|
+
readonly calls: readonly ClientToolCall[];
|
|
580
|
+
readonly cursor?: string;
|
|
581
|
+
readonly idleUntil?: string;
|
|
582
|
+
}
|
|
583
|
+
export type PermissionDuration = 'once' | 'task' | 'session' | 'scope' | 'persistent' | 'denied';
|
|
584
|
+
export interface PermissionGrant {
|
|
585
|
+
readonly grantId: string;
|
|
586
|
+
readonly toolCallId: string;
|
|
587
|
+
readonly granted: boolean;
|
|
588
|
+
readonly duration: PermissionDuration;
|
|
589
|
+
readonly scope?: string;
|
|
590
|
+
readonly decidedAt: string;
|
|
591
|
+
}
|
|
592
|
+
export interface LocalShellExecInput {
|
|
593
|
+
readonly command: string;
|
|
594
|
+
readonly cwd?: string;
|
|
595
|
+
readonly timeoutMs?: number;
|
|
596
|
+
readonly description?: string;
|
|
597
|
+
readonly runInBackground?: boolean;
|
|
598
|
+
}
|
|
599
|
+
export interface LocalShellStopInput {
|
|
600
|
+
readonly taskId?: string;
|
|
601
|
+
readonly toolCallId?: string;
|
|
602
|
+
}
|
|
603
|
+
export interface LocalShellExecResult {
|
|
604
|
+
readonly status: 'success' | 'failed' | 'cancelled' | 'running';
|
|
605
|
+
readonly exitCode: number | null;
|
|
606
|
+
readonly stdoutPreview: string | null;
|
|
607
|
+
readonly stderrPreview: string | null;
|
|
608
|
+
readonly interrupted: boolean;
|
|
609
|
+
readonly timedOut: boolean;
|
|
610
|
+
readonly promptDetected: boolean;
|
|
611
|
+
readonly outputArtifactRef?: string | null;
|
|
612
|
+
readonly backgroundTaskId?: string | null;
|
|
613
|
+
}
|
|
614
|
+
export type ShellPermissionBehavior = 'allow' | 'ask' | 'deny';
|
|
615
|
+
export interface ShellPermissionRule {
|
|
616
|
+
readonly id?: string;
|
|
617
|
+
readonly behavior: ShellPermissionBehavior;
|
|
618
|
+
readonly match: {
|
|
619
|
+
readonly type: 'exact';
|
|
620
|
+
readonly command: string;
|
|
621
|
+
} | {
|
|
622
|
+
readonly type: 'prefix';
|
|
623
|
+
readonly prefix: string;
|
|
624
|
+
} | {
|
|
625
|
+
readonly type: 'wildcard';
|
|
626
|
+
readonly pattern: string;
|
|
627
|
+
};
|
|
628
|
+
readonly scope: {
|
|
629
|
+
readonly cwd?: string;
|
|
630
|
+
readonly maxRiskLevel?: CapabilityRiskLevel;
|
|
631
|
+
};
|
|
632
|
+
readonly expiresAt?: string;
|
|
633
|
+
}
|
|
634
|
+
export interface LocalShellProjectionPolicy {
|
|
635
|
+
readonly capabilityId: 'local.shell.exec';
|
|
636
|
+
readonly cwdScope: 'workspace' | 'selected_directories';
|
|
637
|
+
readonly defaultBehavior: 'ask' | 'deny';
|
|
638
|
+
readonly readOnlyAutoAllow: boolean;
|
|
639
|
+
readonly backgroundTasks: boolean;
|
|
640
|
+
readonly sandboxAvailable: boolean;
|
|
641
|
+
}
|
|
642
|
+
export interface Evidence {
|
|
643
|
+
readonly evidenceId: string;
|
|
644
|
+
readonly toolCallId: string;
|
|
645
|
+
readonly summary: string;
|
|
646
|
+
readonly locale: LocaleCode;
|
|
647
|
+
readonly returnedToCloud: boolean;
|
|
648
|
+
readonly dataLevel: DataLevel;
|
|
649
|
+
readonly redactions: readonly string[];
|
|
650
|
+
readonly artifactRefs: readonly string[];
|
|
651
|
+
}
|
|
652
|
+
export interface ClientToolResult {
|
|
653
|
+
readonly toolCallId: string;
|
|
654
|
+
readonly status: 'success' | 'denied' | 'failed' | 'cancelled';
|
|
655
|
+
readonly outputPreview: Record<string, unknown>;
|
|
656
|
+
readonly evidence: Evidence;
|
|
657
|
+
readonly completedAt: string;
|
|
658
|
+
}
|
|
659
|
+
export interface ClientToolResultReport {
|
|
660
|
+
readonly conversationId?: number;
|
|
661
|
+
readonly streamId?: string;
|
|
662
|
+
readonly call: ClientToolCall;
|
|
663
|
+
readonly grant: PermissionGrant;
|
|
664
|
+
readonly result: ClientToolResult;
|
|
665
|
+
readonly reportedAt: string;
|
|
666
|
+
}
|
|
667
|
+
export interface AuditEvent {
|
|
668
|
+
readonly auditId: string;
|
|
669
|
+
readonly sessionId: string;
|
|
670
|
+
readonly eventType: 'session_started' | 'manifest_published' | 'permission_reviewed' | 'tool_started' | 'tool_completed' | 'tool_failed';
|
|
671
|
+
readonly message: string;
|
|
672
|
+
readonly createdAt: string;
|
|
673
|
+
readonly metadata?: Record<string, unknown>;
|
|
674
|
+
}
|
|
675
|
+
export * from './execution.ts';
|
|
676
|
+
export * from './chat.ts';
|
|
677
|
+
export * from './compaction.ts';
|
|
678
|
+
export * from './context-accounting.ts';
|
|
679
|
+
export * from './memory.ts';
|
|
680
|
+
export * from './system-context.ts';
|
|
681
|
+
export * from './goal.ts';
|
|
682
|
+
export * from './updater.ts';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function resolveLlmModelOptionValues(definitions, values) {
|
|
2
|
+
if (!definitions?.length)
|
|
3
|
+
return {};
|
|
4
|
+
const resolved = {};
|
|
5
|
+
for (const definition of definitions) {
|
|
6
|
+
const selected = values?.[definition.id] ?? definition.defaultValue;
|
|
7
|
+
const valid = definition.choices.some((choice) => choice.value === selected);
|
|
8
|
+
resolved[definition.id] = valid ? selected : definition.defaultValue;
|
|
9
|
+
}
|
|
10
|
+
return resolved;
|
|
11
|
+
}
|
|
12
|
+
export function resolveLlmModelOptionChoice(definition, values) {
|
|
13
|
+
const selected = resolveLlmModelOptionValues([definition], values)[definition.id];
|
|
14
|
+
return definition.choices.find((choice) => choice.value === selected);
|
|
15
|
+
}
|
|
16
|
+
export * from "./execution.js";
|
|
17
|
+
export * from "./chat.js";
|
|
18
|
+
export * from "./compaction.js";
|
|
19
|
+
export * from "./context-accounting.js";
|
|
20
|
+
export * from "./memory.js";
|
|
21
|
+
export * from "./system-context.js";
|
|
22
|
+
export * from "./goal.js";
|
|
23
|
+
export * from "./updater.js";
|