@x-otto/plugin 0.1.0-alpha.0 → 0.1.0-alpha.2
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/README.md +8 -8
- package/dist/index.d.ts +36 -1631
- package/dist/index.js +2 -2
- package/package.json +13 -13
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import { ConnectionOptions, TLSSocket } from "node:tls";
|
|
8
|
-
import { IpcNetConnectOpts, Socket, TcpNetConnectOpts } from "node:net";
|
|
2
|
+
import { TypedEventEmitter } from "@x-otto/shared";
|
|
3
|
+
import * as _$_x_otto_interchange0 from "@x-otto/interchange";
|
|
4
|
+
import { PluginInputRegistry, SigilEntry, SigilKind, SigilPrefix, SigilProvider, SigilSource, sigilOf } from "@x-otto/interchange";
|
|
5
|
+
import * as _$_x_otto_provider0 from "@x-otto/provider";
|
|
9
6
|
|
|
10
7
|
//#region src/capabilities.d.ts
|
|
11
8
|
/**
|
|
@@ -117,7 +114,7 @@ type PluginFileViewerEntry = z.infer<typeof fileViewerEntrySchema>;
|
|
|
117
114
|
/**
|
|
118
115
|
* a2ui 组件贡献(RFC-105 D1/D6 "a2uiComponents 轴",RFC-155 M155-2 补齐实现):插件声明
|
|
119
116
|
* 一个新的 a2ui 组件类型名 + 提供渲染实现,扩展宿主受信 catalog(Text/Card/List/Progress/
|
|
120
|
-
* Chip/Button 六个内置类型,见 `@otto/tui a2ui-renderer.ts`)。`entry` 同 renderers/panels
|
|
117
|
+
* Chip/Button 六个内置类型,见 `@x-otto/tui a2ui-renderer.ts`)。`entry` 同 renderers/panels
|
|
121
118
|
* 是**已编译产物**路径。内置类型名为保留字(不可在此声明覆盖,装载层拒绝,见 R4)——
|
|
122
119
|
* schema 层只做基础字段校验,保留字/跨插件同名冲突检查在装载层完成(装载层才知道运行时
|
|
123
120
|
* 已注册了哪些类型,schema 层是纯静态声明校验,职责分离)。
|
|
@@ -322,7 +319,7 @@ type PluginI18nContribution = z.infer<typeof i18nContributionSchema>;
|
|
|
322
319
|
/**
|
|
323
320
|
* RFC-277 M5:插件贡献主题预设的完整颜色表——镜像 `packages/tui/src/theme/colors.ts` 的
|
|
324
321
|
* `ThemeColors` interface 全部 27 个字段(`text` 允许省略,对应"终端默认前景"语义)。
|
|
325
|
-
* 与 `@otto/setting` 的 `themeColorRoleSchema`(settings 层用户 override,只放行角色名)
|
|
322
|
+
* 与 `@x-otto/setting` 的 `themeColorRoleSchema`(settings 层用户 override,只放行角色名)
|
|
326
323
|
* 是两个正交的枚举:这里是插件声明**完整调色板**(必须是真实颜色值),那里是用户**引用
|
|
327
324
|
* 已有角色**做轻量 override(RFC-277 D3 受限覆盖面)。两者不得混淆合并。
|
|
328
325
|
*/
|
|
@@ -2095,7 +2092,7 @@ declare const PLUGIN_API_VERSION = 1;
|
|
|
2095
2092
|
*
|
|
2096
2093
|
* 单一真源(RFC-082 R7):两条作者路径必须 round-trip 到**同一个** `PluginContributions`——
|
|
2097
2094
|
* 1. Tier 0 文件约定(`skills/`*.md、`commands/`、`.mcp.json`、`panels/` …)解析 → 本形状
|
|
2098
|
-
* 2. Tier 1 `definePlugin()`(`@otto/plugin-sdk`,M082-04)直接返回 → 本形状
|
|
2095
|
+
* 2. Tier 1 `definePlugin()`(`@x-otto/plugin-sdk`,M082-04)直接返回 → 本形状
|
|
2099
2096
|
* 禁止文件 schema 与代码 schema 两套并行漂移。
|
|
2100
2097
|
*
|
|
2101
2098
|
* 装载(RFC-082 D1/D4,Shape B 保形):合并后的 `PluginContributions` 在装载时被**拆解**,
|
|
@@ -2116,7 +2113,7 @@ interface CommandContribution {
|
|
|
2116
2113
|
body: string;
|
|
2117
2114
|
}
|
|
2118
2115
|
/**
|
|
2119
|
-
* Agent 贡献(→ 装载为 `@otto/prompt AgentProfile`)。
|
|
2116
|
+
* Agent 贡献(→ 装载为 `@x-otto/prompt AgentProfile`)。
|
|
2120
2117
|
* 作者可声明子集;运行时解析/补默认在 agent loader。
|
|
2121
2118
|
*/
|
|
2122
2119
|
interface AgentContribution {
|
|
@@ -2132,7 +2129,7 @@ interface AgentContribution {
|
|
|
2132
2129
|
allowSubagents?: boolean;
|
|
2133
2130
|
}
|
|
2134
2131
|
/**
|
|
2135
|
-
* Skill 贡献(→ 装载为 `@otto/skill SkillDefinition`)。
|
|
2132
|
+
* Skill 贡献(→ 装载为 `@x-otto/skill SkillDefinition`)。
|
|
2136
2133
|
* 作者声明元数据 + 正文;目录/附属文件路径由 loader 在发现时解析。
|
|
2137
2134
|
*/
|
|
2138
2135
|
interface SkillContribution {
|
|
@@ -2141,11 +2138,11 @@ interface SkillContribution {
|
|
|
2141
2138
|
/** SKILL.md 去 frontmatter 后正文。 */
|
|
2142
2139
|
body: string;
|
|
2143
2140
|
}
|
|
2144
|
-
/** MCP transport(镜像 `@otto/mcp McpTransportType`,作者侧字面量避免运行时依赖)。 */
|
|
2141
|
+
/** MCP transport(镜像 `@x-otto/mcp McpTransportType`,作者侧字面量避免运行时依赖)。 */
|
|
2145
2142
|
type McpTransport = 'stdio' | 'http' | 'sse';
|
|
2146
2143
|
/**
|
|
2147
2144
|
* MCP server 贡献(→ 装载为 `EffectiveMcpServer`,loader 注入 source/pluginId)。
|
|
2148
|
-
* 镜像 `@otto/mcp McpServerConfig` 的作者可声明子集。插件层 MCP 默认 `managed`(RFC-081 归属保护)
|
|
2145
|
+
* 镜像 `@x-otto/mcp McpServerConfig` 的作者可声明子集。插件层 MCP 默认 `managed`(RFC-081 归属保护)
|
|
2149
2146
|
* 由 loader 标记,作者无需声明。
|
|
2150
2147
|
*/
|
|
2151
2148
|
interface McpContribution {
|
|
@@ -2295,771 +2292,9 @@ interface DispatchCaps {
|
|
|
2295
2292
|
/** 按 type 路由 CommandRef 到注入的 capability。未注入对应 cap → 抛 MissingCapabilityError。 */
|
|
2296
2293
|
declare function dispatch(cmd: CommandRef, caps: DispatchCaps): Promise<void>;
|
|
2297
2294
|
//#endregion
|
|
2298
|
-
//#region ../provider/dist/index.d.ts
|
|
2299
|
-
//#region ../interchange/dist/index.d.ts
|
|
2300
|
-
//#region src/message.d.ts
|
|
2301
|
-
/** Message: AgentMessage/UserMessage/SystemMessage interchange types. */
|
|
2302
|
-
type Timestamp = number;
|
|
2303
|
-
type KnownApi = 'openai-completions' | 'openai-responses' | 'azure-openai-responses' | 'openai-codex-responses' | 'anthropic-messages' | 'bedrock-converse-stream' | 'google-generative-ai' | 'google-gemini-cli' | 'google-vertex';
|
|
2304
|
-
type Api = KnownApi | (string & {});
|
|
2305
|
-
type KnownProvider = 'anthropic' | 'openai' | 'google' | 'amazon-bedrock' | 'github-copilot' | 'xai' | 'groq' | 'openrouter' | 'deepseek' | 'ollama' | 'moonshot' | 'custom';
|
|
2306
|
-
type Provider = KnownProvider | (string & {});
|
|
2307
|
-
type StopReason = 'end_turn' | 'max_tokens' | 'tool_use' | 'stop_sequence' | 'refusal';
|
|
2308
|
-
interface Usage {
|
|
2309
|
-
inputTokens: number;
|
|
2310
|
-
outputTokens: number;
|
|
2311
|
-
cacheReadTokens: number;
|
|
2312
|
-
cacheWriteTokens: number;
|
|
2313
|
-
}
|
|
2314
|
-
/**
|
|
2315
|
-
* 结构化的 zod 兼容垫片——协议层不直接依赖 zod,靠结构类型让 provider/工具定义喂入真 zod schema。
|
|
2316
|
-
*/
|
|
2317
|
-
interface ZodType<T = unknown> {
|
|
2318
|
-
parse(data: unknown): T;
|
|
2319
|
-
safeParse(data: unknown): {
|
|
2320
|
-
success: boolean;
|
|
2321
|
-
data?: T;
|
|
2322
|
-
error?: unknown;
|
|
2323
|
-
};
|
|
2324
|
-
toJSONSchema?: () => unknown;
|
|
2325
|
-
}
|
|
2326
|
-
interface TextContent {
|
|
2327
|
-
type: 'text';
|
|
2328
|
-
text: string;
|
|
2329
|
-
signature?: string;
|
|
2330
|
-
}
|
|
2331
|
-
interface ImageContent {
|
|
2332
|
-
type: 'image';
|
|
2333
|
-
mime: string;
|
|
2334
|
-
source: string;
|
|
2335
|
-
}
|
|
2336
|
-
interface ThinkingContent {
|
|
2337
|
-
type: 'thinking';
|
|
2338
|
-
text: string;
|
|
2339
|
-
signature?: string;
|
|
2340
|
-
}
|
|
2341
|
-
interface ToolCall {
|
|
2342
|
-
type: 'tool_call';
|
|
2343
|
-
id: string;
|
|
2344
|
-
name: string;
|
|
2345
|
-
arguments: Record<string, unknown>;
|
|
2346
|
-
/**
|
|
2347
|
-
* 流式参数 JSON 解析失败标记(RFC-142 D4)——`stopReason: max_tokens` 截断半截
|
|
2348
|
-
* JSON 时 `parseToolArguments` 置位,runtime 责任链据此把该调用转为明确错误
|
|
2349
|
-
* tool_result 而非带空参数进入 zod 校验(与污染类错误分离错误通道)。
|
|
2350
|
-
*
|
|
2351
|
-
* **进程内标记,不进 wire**:各 provider 序列化发给模型时均为显式字段拾取
|
|
2352
|
-
* (`{type, id, name, input: arguments}`,无 spread),本字段天然剥除——有测试钉住
|
|
2353
|
-
* (RFC-142 重要事项规则4)。
|
|
2354
|
-
*/
|
|
2355
|
-
argumentsParseFailed?: boolean;
|
|
2356
|
-
}
|
|
2357
|
-
/**
|
|
2358
|
-
* A2UI content block(RFC-105 D6/M105-5b):agent 生成的声明式 UI payload。
|
|
2359
|
-
* 对齐 a2ui-project/a2ui(v0.9)的核心哲学——扁平组件列表 + ID 引用 + 受信组件 catalog、
|
|
2360
|
-
* 纯数据非代码、未知组件类型文本降级。
|
|
2361
|
-
*
|
|
2362
|
-
* 组件类型(TUI 终端安全子集,首阶段只读 display):
|
|
2363
|
-
* - Text:纯文本(text 字段)。
|
|
2364
|
-
* - Card:带标题容器(title + children ID 引用)。
|
|
2365
|
-
* - List:条目列表(items ID 引用 + ordered 标志)。
|
|
2366
|
-
* - Progress:ASCII 进度条(value 0-100,label 可选)。
|
|
2367
|
-
* - Chip:内联彩色标签(text + color)。
|
|
2368
|
-
* - Button:交互按钮(RFC-105 D6 F5/M105-5c,数字键触发 a2ui action;只读 display 通过
|
|
2369
|
-
* renderA2uiBlock 提取为 A2uiButtonInfo 元数据)。
|
|
2370
|
-
* - Form:交互式表单(RFC-211 M1:字段定义 + TUI 弹窗填写 + web-ui 原生表单)。
|
|
2371
|
-
* 字段类型 text/select/toggle,payload 原样回流,不可执行代码。
|
|
2372
|
-
* 未知 type → 文本摘要表示(不崩,fail-soft,R7)。
|
|
2373
|
-
*/
|
|
2374
|
-
interface A2uiComponent {
|
|
2375
|
-
id: string;
|
|
2376
|
-
type: 'Text' | 'Card' | 'List' | 'Progress' | 'Chip' | 'Button' | 'Form' | (string & {});
|
|
2377
|
-
text?: string;
|
|
2378
|
-
title?: string;
|
|
2379
|
-
children?: string[];
|
|
2380
|
-
items?: string[];
|
|
2381
|
-
ordered?: boolean;
|
|
2382
|
-
value?: number;
|
|
2383
|
-
max?: number;
|
|
2384
|
-
label?: string;
|
|
2385
|
-
color?: 'accent' | 'green' | 'amber' | 'red' | 'gray';
|
|
2386
|
-
action?: string;
|
|
2387
|
-
shortcut?: string;
|
|
2388
|
-
/** 表单标题(弹窗标题 + 对话流摘要标题)。 */
|
|
2389
|
-
formTitle?: string;
|
|
2390
|
-
/** 表单字段定义。 */
|
|
2391
|
-
fields?: A2uiFormField[];
|
|
2392
|
-
}
|
|
2393
|
-
/** 单个表单字段(`A2uiComponent.type === 'Form'` 时使用)。 */
|
|
2394
|
-
interface A2uiFormField {
|
|
2395
|
-
/** 字段 id(Form 内唯一,submit payload 的 key)。 */
|
|
2396
|
-
id: string;
|
|
2397
|
-
/** 字段类型。 */
|
|
2398
|
-
type: 'text' | 'select' | 'toggle';
|
|
2399
|
-
/** 显示标签。 */
|
|
2400
|
-
label: string;
|
|
2401
|
-
/** 默认值(text=字符串, select=option id, toggle=boolean)。 */
|
|
2402
|
-
defaultValue?: string | boolean;
|
|
2403
|
-
/** 占位符(text 类型)。 */
|
|
2404
|
-
placeholder?: string;
|
|
2405
|
-
/** 选项列表(select 类型必填)。 */
|
|
2406
|
-
options?: Array<{
|
|
2407
|
-
id: string;
|
|
2408
|
-
label: string;
|
|
2409
|
-
}>;
|
|
2410
|
-
/** 是否必填(渲染提示,不做前端校验——非目标)。 */
|
|
2411
|
-
required?: boolean;
|
|
2412
|
-
}
|
|
2413
|
-
interface A2uiContent {
|
|
2414
|
-
type: 'a2ui';
|
|
2415
|
-
/** A2UI 协议版本(v0.9 snapshot),供未来版本迁移用。 */
|
|
2416
|
-
version: string;
|
|
2417
|
-
/** 扁平组件列表,ID 引用构建组件树,增量子集可追加/替换。 */
|
|
2418
|
-
components: A2uiComponent[];
|
|
2419
|
-
}
|
|
2420
|
-
type ContentPart = TextContent | ImageContent | ThinkingContent | ToolCall | A2uiContent;
|
|
2421
|
-
interface UserMessage {
|
|
2422
|
-
role: 'user';
|
|
2423
|
-
content: string | ContentPart[];
|
|
2424
|
-
timestamp: Timestamp;
|
|
2425
|
-
uuid?: string;
|
|
2426
|
-
/**
|
|
2427
|
-
* RFC-050 REV-1:引擎注入的内部消息(如预算收尾 steering、截断续写提示),模型需要看到、
|
|
2428
|
-
* 但**不应渲染给用户**(否则 resume 时显示成用户从未输入的发言)。provider 序列化忽略此字段。
|
|
2429
|
-
*/
|
|
2430
|
-
internal?: boolean;
|
|
2431
|
-
}
|
|
2432
|
-
interface AssistantMessage {
|
|
2433
|
-
role: 'assistant';
|
|
2434
|
-
/**
|
|
2435
|
-
* 消息内容。A2uiContent 是前向兼容新增(RFC-155 M2 结案后的协议层收口):
|
|
2436
|
-
* provider 序列化层仅消费 text/tool_call/thinking,a2ui 块被静默跳过不出进 LLM 请求体;
|
|
2437
|
-
* 渲染层(message-lines.ts)经 `renderA2uiBlock` 渲染。
|
|
2438
|
-
*/
|
|
2439
|
-
content: (TextContent | ThinkingContent | ToolCall | A2uiContent)[];
|
|
2440
|
-
api: Api;
|
|
2441
|
-
provider: Provider;
|
|
2442
|
-
model: string;
|
|
2443
|
-
usage: Usage;
|
|
2444
|
-
stopReason: StopReason;
|
|
2445
|
-
uuid?: string;
|
|
2446
|
-
}
|
|
2447
|
-
interface ToolResultMessage<T extends unknown = unknown> {
|
|
2448
|
-
role: 'tool_result';
|
|
2449
|
-
toolCallId: string;
|
|
2450
|
-
toolName: string;
|
|
2451
|
-
/**
|
|
2452
|
-
* 工具结果内容。A2uiContent 是前向兼容新增(RFC-155 M2 结案后的协议层收口):
|
|
2453
|
-
* provider 序列化仅消费 text,a2ui 块被静默跳过;渲染层(message-lines.ts)经
|
|
2454
|
-
* `renderA2uiBlock` 渲染为终端卡片。
|
|
2455
|
-
*/
|
|
2456
|
-
content: (TextContent | ImageContent | A2uiContent)[];
|
|
2457
|
-
details: T;
|
|
2458
|
-
isError: boolean;
|
|
2459
|
-
timestamp: Timestamp;
|
|
2460
|
-
uuid?: string;
|
|
2461
|
-
/** RFC-050 REV-1:引擎合成的内部 tool_result(如预算耗尽未执行的占位),不渲染给用户。 */
|
|
2462
|
-
internal?: boolean;
|
|
2463
|
-
}
|
|
2464
|
-
/**
|
|
2465
|
-
* RFC-144 M1:mid-conversation system 通知消息——**真正进 provider 请求**的协议消息类型
|
|
2466
|
-
* (区别于 `@otto/hook-contracts` 的 `SystemAgentMessage`,后者是 hooks/UI 域、
|
|
2467
|
-
* convertToLLM 类型边界显式过滤、绝不进 provider 请求)。
|
|
2468
|
-
*
|
|
2469
|
-
* 用途:lifecycleAsync 工具(RFC-144)真正完成时,追加一条独立消息告知 LLM"运营方观察到
|
|
2470
|
-
* 的状态变化"(Anthropic mid-conversation system message 官方场景之一),不修改/替换任何
|
|
2471
|
-
* 历史消息(纯追加语义),LLM 在下一轮推理中作为权威事实处理。
|
|
2472
|
-
*
|
|
2473
|
-
* provider 序列化:
|
|
2474
|
-
* - Anthropic(原生支持,Claude Opus 4.8+)→ `{role: 'system', content}` 追加进 messages 数组,
|
|
2475
|
-
* 放置规则见 RFC-144 重要事项规则 5(必须紧跟携带 tool_result 的 user turn 之后)。
|
|
2476
|
-
* - 不支持该特性的模型/provider(如 OpenAI,或 Anthropic 旧模型)→ 降级为等价的
|
|
2477
|
-
* `role: 'user'` 消息 + 显式文本前缀(牺牲"运营方权威"语义,保留基本可用性),
|
|
2478
|
-
* 降级逻辑归属 provider adapter 层(本类型定义不关心降级细节)。
|
|
2479
|
-
*
|
|
2480
|
-
* 不可变性(RFC-144 禁区):一旦追加,绝不编辑或删除已发送的 system 通知——结果更新一律
|
|
2481
|
-
* 追加新消息,不改写旧消息(Anthropic 官方限制:编辑会使该点之后的 prompt cache 失效)。
|
|
2482
|
-
*/
|
|
2483
|
-
interface SystemNotificationMessage {
|
|
2484
|
-
role: 'system_notification';
|
|
2485
|
-
/** 通知正文(如 "[Tool completion] pnpm build finished: exit 0")。 */
|
|
2486
|
-
content: string;
|
|
2487
|
-
/**
|
|
2488
|
-
* 该通知对应的工具执行是否失败——显式字段,供消费方(渲染层/审计)直接读取,不必解析
|
|
2489
|
-
* `content` 文案判断状态(RFC-144 M2:文案格式可能演进,靠字符串匹配脆弱且易误判)。
|
|
2490
|
-
*/
|
|
2491
|
-
isError?: boolean;
|
|
2492
|
-
/** 关联的 lifecycleAsync 工具调用 id,供消费方(渲染层/审计)溯源。 */
|
|
2493
|
-
relatedToolCallId?: string;
|
|
2494
|
-
timestamp: Timestamp;
|
|
2495
|
-
uuid?: string;
|
|
2496
|
-
}
|
|
2497
|
-
type Message = UserMessage | AssistantMessage | ToolResultMessage | SystemNotificationMessage;
|
|
2498
|
-
/**
|
|
2499
|
-
* 历史压缩摘要消息的标记前缀——单一真相源(跨包协议常量)。
|
|
2500
|
-
* 生产者 @otto/memory 注入摘要消息时用、压缩去重(isSummaryMessage)时识别;消费者
|
|
2501
|
-
* @otto/agent 的 ContextPipeline 从会话树恢复摘要时用同一前缀重建摘要消息。放在协议叶子,
|
|
2502
|
-
* 避免双份字面量漂移导致 isSummaryMessage 失配。
|
|
2503
|
-
*/
|
|
2504
|
-
//#endregion
|
|
2505
|
-
//#region src/stream.d.ts
|
|
2506
|
-
/**
|
|
2507
|
-
* 供应商 usage 快照(状态栏「周/小时额度」展示,RFC 无编号临时功能——状态栏 provider usage)。
|
|
2508
|
-
*
|
|
2509
|
-
* 仅 Anthropic OAuth 订阅计划(Claude Pro/Max)请求会带 anthropic-ratelimit-unified-* 响应头族;
|
|
2510
|
-
* API key 走标准 RPM/TPM 限流不带此头族,故 provider/ai 层解析不到时返回 null,调用方天然
|
|
2511
|
-
* 实现"API key 不显示"(见 packages/ai/src/provider-usage.ts extractProviderUsageFromHeaders
|
|
2512
|
-
* 与 packages/ai/src/auth-store.ts getAuthSource)。
|
|
2513
|
-
*
|
|
2514
|
-
* usedPercent 未经 Anthropic 官方文档确认(仅有 status/representative-claim/reset 三个字段有
|
|
2515
|
-
* SDK 源码级证据),探测不到时为 undefined——UI 侧绝不显示猜测/编造的百分比数字。
|
|
2516
|
-
*/
|
|
2517
|
-
interface ProviderUsageSnapshot {
|
|
2518
|
-
/**
|
|
2519
|
-
* 订阅配额状态。'allowed'/'allowed_warning'/'rejected' 来自 Anthropic unified 头族的
|
|
2520
|
-
* 真实语义;**'unknown' = 无订阅配额数据**(RFC-118 小修 S11:OpenAI 只有标准
|
|
2521
|
-
* x-ratelimit-* 头无配额语义,此前重载 'allowed' 造成同字段双语义——UI 按
|
|
2522
|
-
* status!=='rejected' 判「额度 OK」会让 OpenAI 用户永远看不到预警)。
|
|
2523
|
-
* 消费端对 'unknown' 应展示中性态(不判额度充足也不报警)。
|
|
2524
|
-
*/
|
|
2525
|
-
status: 'allowed' | 'allowed_warning' | 'rejected' | 'unknown';
|
|
2526
|
-
limitType?: 'five_hour' | 'seven_day' | 'seven_day_opus' | 'seven_day_sonnet' | 'seven_day_overage_included';
|
|
2527
|
-
/** Unix 时间戳(秒)——配额重置时刻。 */
|
|
2528
|
-
resetsAt?: number;
|
|
2529
|
-
/** 已用百分比(0-100)。未探测到时 undefined。 */
|
|
2530
|
-
usedPercent?: number;
|
|
2531
|
-
/**
|
|
2532
|
-
* Overage(额外用量池)状态。
|
|
2533
|
-
* 仅当标准额度已耗尽(status='rejected')且 overage 可用(overageStatus='allowed'/'allowed_warning')
|
|
2534
|
-
* 时有意义——此时 isUsingOverage = true,状态栏应展示 overage 标识而非 rejected 错误态。
|
|
2535
|
-
* 无 overage 头族的请求(API key / 未开通 overage)此字段为 undefined。
|
|
2536
|
-
*/
|
|
2537
|
-
overageStatus?: 'allowed' | 'allowed_warning' | 'rejected';
|
|
2538
|
-
/** Overage 池重置时刻(Unix 秒)。 */
|
|
2539
|
-
overageResetsAt?: number;
|
|
2540
|
-
/** Overage 不可用原因(仅在 overageStatus='rejected' 时可能有值)。 */
|
|
2541
|
-
overageDisabledReason?: string;
|
|
2542
|
-
/**
|
|
2543
|
-
* 标准 API 限流快照(x-ratelimit-* 头族,有官方文档)。与 Anthropic unified 订阅配额
|
|
2544
|
-
* 不同——这里表示的是分钟级请求/Token 的 token bucket 限流,任何认证方式的请求都返回
|
|
2545
|
-
* (Anthropic API key + OpenAI API key + OAuth 订阅)。undefined = 没有标准限流头。
|
|
2546
|
-
*
|
|
2547
|
-
* 格式来自 OpenAI Rate Limits 文档(x-ratelimit-limit-requests/remaining-requests/
|
|
2548
|
-
* reset-requests/-limit-tokens/-remaining-tokens/-reset-tokens),Anthropic 也用
|
|
2549
|
-
* 同名头族但加上 `anthropic-` 前缀。
|
|
2550
|
-
*/
|
|
2551
|
-
standardLimits?: {
|
|
2552
|
-
remainingRequests?: number;
|
|
2553
|
-
remainingTokens?: number;
|
|
2554
|
-
limitRequests?: number;
|
|
2555
|
-
limitTokens?: number;
|
|
2556
|
-
resetRequestsMs?: number;
|
|
2557
|
-
resetTokensMs?: number;
|
|
2558
|
-
};
|
|
2559
|
-
}
|
|
2560
|
-
/**
|
|
2561
|
-
* 流式增量事件——provider converse() 的统一产物面。RFC-067 M111(A5):所有 provider 都必须
|
|
2562
|
-
* 发齐 text/thinking/tool_call 的 start/delta/end 包络(end 带累积 content),否则下游
|
|
2563
|
-
* 「完成通知」会丢内容。单一真相源避免 anthropic 全发 12 变体而 OpenAI 系发不全的漂移。
|
|
2564
|
-
*/
|
|
2565
|
-
type StreamEvent = {
|
|
2566
|
-
type: 'start';
|
|
2567
|
-
partial: AssistantMessage;
|
|
2568
|
-
} | {
|
|
2569
|
-
type: 'text_start';
|
|
2570
|
-
index: number;
|
|
2571
|
-
partial: AssistantMessage;
|
|
2572
|
-
} | {
|
|
2573
|
-
type: 'text_delta';
|
|
2574
|
-
index: number;
|
|
2575
|
-
delta: string;
|
|
2576
|
-
partial: AssistantMessage;
|
|
2577
|
-
} | {
|
|
2578
|
-
type: 'text_end';
|
|
2579
|
-
index: number;
|
|
2580
|
-
content: string;
|
|
2581
|
-
partial: AssistantMessage;
|
|
2582
|
-
} | {
|
|
2583
|
-
type: 'thinking_start';
|
|
2584
|
-
index: number;
|
|
2585
|
-
partial: AssistantMessage;
|
|
2586
|
-
} | {
|
|
2587
|
-
type: 'thinking_delta';
|
|
2588
|
-
index: number;
|
|
2589
|
-
delta: string;
|
|
2590
|
-
partial: AssistantMessage;
|
|
2591
|
-
} | {
|
|
2592
|
-
type: 'thinking_end';
|
|
2593
|
-
index: number;
|
|
2594
|
-
content: string;
|
|
2595
|
-
partial: AssistantMessage;
|
|
2596
|
-
} | {
|
|
2597
|
-
type: 'tool_call_start';
|
|
2598
|
-
index: number;
|
|
2599
|
-
partial: AssistantMessage;
|
|
2600
|
-
} | {
|
|
2601
|
-
type: 'tool_call_delta';
|
|
2602
|
-
index: number;
|
|
2603
|
-
delta: string;
|
|
2604
|
-
partial: AssistantMessage;
|
|
2605
|
-
} | {
|
|
2606
|
-
type: 'tool_call_end';
|
|
2607
|
-
index: number;
|
|
2608
|
-
toolCall: ToolCall;
|
|
2609
|
-
partial: AssistantMessage;
|
|
2610
|
-
} | {
|
|
2611
|
-
type: 'done';
|
|
2612
|
-
reason: StopReason;
|
|
2613
|
-
message: AssistantMessage; /** 本轮成功响应解析出的供应商 usage 快照(仅 Anthropic OAuth 订阅计划非 null)。 */
|
|
2614
|
-
providerUsage?: ProviderUsageSnapshot | null;
|
|
2615
|
-
} | {
|
|
2616
|
-
type: 'error';
|
|
2617
|
-
error: Error;
|
|
2618
|
-
}; //#endregion
|
|
2619
|
-
//#region src/model.d.ts
|
|
2620
|
-
/**
|
|
2621
|
-
* 推理投入档(reasoning effort)——RFC-235 对齐 Claude Code 词表:`low/medium/high/xhigh/max`。
|
|
2622
|
-
* 去除历史遗留的 `minimal`(无对应厂商语义,存量配置载入时迁移为 `low`),新增 `max`(Claude
|
|
2623
|
-
* Code 最高档 + DeepSeek `reasoning_effort:'max'` 顶档)。各模型真实支持的子集由 manifest 的
|
|
2624
|
-
* `Model.thinkingLevels` 声明,provider 组装请求体时按"≤该档最高支持档"降级(见 RFC-235 §3.3)。
|
|
2625
|
-
*/
|
|
2626
|
-
type ThinkingLevel = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
2627
|
-
/**
|
|
2628
|
-
* 模型能力优势标签(供大模型为 subagent 选型)。非 /models API 返回——由
|
|
2629
|
-
* model-capabilities 据「精选家族图 + 启发式」推导。
|
|
2630
|
-
* planning=方案/架构 · knowledge=知识/通识 · coding=编码 · reasoning=深度推理
|
|
2631
|
-
* · vision=视觉 · speed=低延迟 · long-context=长上下文
|
|
2632
|
-
*/
|
|
2633
|
-
type ModelStrength = 'planning' | 'knowledge' | 'coding' | 'reasoning' | 'vision' | 'speed' | 'long-context';
|
|
2634
|
-
interface Cost {
|
|
2635
|
-
input: number;
|
|
2636
|
-
output: number;
|
|
2637
|
-
cacheRead: number;
|
|
2638
|
-
cacheWrite: number;
|
|
2639
|
-
}
|
|
2640
|
-
interface Model<T = Api> {
|
|
2641
|
-
id: string;
|
|
2642
|
-
name: string;
|
|
2643
|
-
api: T;
|
|
2644
|
-
provider: Provider;
|
|
2645
|
-
baseUrl: string;
|
|
2646
|
-
reasoning: boolean;
|
|
2647
|
-
input: ('text' | 'image')[];
|
|
2648
|
-
/**
|
|
2649
|
-
* 美元 / 百万 token 定价(终局修复:改为可选,不再强制归零)。三家主流供应商
|
|
2650
|
-
* (Anthropic/OpenAI/GitHub Copilot,逐一核实过官方文档+SDK 源码)的 `/models` 列表接口
|
|
2651
|
-
* 均不返回定价——这不是接口设计缺陷,是行业普遍现状:`/models` 回答"能用哪些模型",
|
|
2652
|
-
* 定价只写在面向人类阅读的文档页(会随时间调整),没有供应商把它做成程序化查询接口。
|
|
2653
|
-
* 缺省(`undefined`)= 该模型没有已知定价来源(如运行时从供应商接口动态发现的新型号),
|
|
2654
|
-
* UI 层应据此不显示开销估算,而非显示误导性的 $0(用户可能误以为模型免费,实际正常计费)。
|
|
2655
|
-
* 有值 = 人工核实过的真实历史定价(当前来自各插件 manifest 声明)。
|
|
2656
|
-
*/
|
|
2657
|
-
cost?: Cost;
|
|
2658
|
-
contextWindow: number;
|
|
2659
|
-
maxOutputTokens: number;
|
|
2660
|
-
thinkingLevels?: ThinkingLevel[];
|
|
2661
|
-
/**
|
|
2662
|
-
* thinking 配置格式声明:
|
|
2663
|
-
* - 'enabled'(缺省):标准 Anthropic `{ type: 'enabled', budget_tokens: N }`
|
|
2664
|
-
* - 'adaptive':`{ type: 'adaptive' }` + 顶层 `output_config.effort`(部分网关要求此格式)
|
|
2665
|
-
*/
|
|
2666
|
-
thinkingMode?: 'enabled' | 'adaptive';
|
|
2667
|
-
/** 能力优势标签(供 subagent 选型);由 model-capabilities 推导,非内置硬编码真源。 */
|
|
2668
|
-
strengths?: ModelStrength[];
|
|
2669
|
-
/**
|
|
2670
|
-
* 图片约束声明(RFC-148 M5):单请求最大图片数 + 超阈值后的单图最大边长约束。
|
|
2671
|
-
* 由插件 manifest 的模型条目声明(供应商专属约束,如 Anthropic 官方规则"单请求
|
|
2672
|
-
* >maxImagesPerRequest 张图时单图任一边 > maxDimensionPxIfOverLimit 即 400",
|
|
2673
|
-
* 见 `packages/agent/src/image-degradation.ts` 消费方)。缺省 = 无已知约束
|
|
2674
|
-
* (引擎侧不主动截断,行为等价于约束不存在——不臆造保守默认值)。
|
|
2675
|
-
*/
|
|
2676
|
-
imageConstraints?: {
|
|
2677
|
-
maxImagesPerRequest: number;
|
|
2678
|
-
maxDimensionPxIfOverLimit?: number;
|
|
2679
|
-
};
|
|
2680
|
-
/**
|
|
2681
|
-
* 工具调用支持声明(RFC-130 M131-2,同 `imageConstraints` 声明化模式):该模型/provider
|
|
2682
|
-
* 是否支持客户端工具委托。缺省 `undefined` = 支持(向后兼容——绝大多数 provider 支持工具,
|
|
2683
|
-
* 不臆造保守默认值破坏存量行为)。仅当 provider 协议层明确不支持工具委托时(如 Cursor
|
|
2684
|
-
* agent API 只服务端自跑内置工具,M131-3-00b 已证伪双向映射可行性)声明 `false`,宿主
|
|
2685
|
-
* (`session-config-resolver.ts`)据此剥离工具集,避免 provider 抛协议错误——引擎侧
|
|
2686
|
-
* 只读布尔声明,不识别具体厂商字符串(终局判据,同 RFC-148 系列的 zero-vendor-knowledge
|
|
2687
|
-
* 原则)。
|
|
2688
|
-
*/
|
|
2689
|
-
supportsTools?: boolean;
|
|
2690
|
-
/**
|
|
2691
|
-
* Responses API 请求体策略声明(RFC-213):供 `openai-responses` 协议实现按声明覆盖
|
|
2692
|
-
* 标准请求体字段,替代此前失效的 `model.api === 'openai-codex-responses'` 字符串判断
|
|
2693
|
-
* (RFC-122 provider 插件化迁移后该字面量已物理不可达,是死代码——见 RFC-213 背景的
|
|
2694
|
-
* 逐层源码追溯)。缺省 = 标准行为(不设置 `store`、按
|
|
2695
|
-
* `context.maxTokens ?? model.maxOutputTokens` 发送 `max_output_tokens`)。
|
|
2696
|
-
*/
|
|
2697
|
-
responseBodyPolicy?: {
|
|
2698
|
-
/** 显式设置 body.store(如 ZDR 合规场景需要 false)。缺省不设置该字段(沿用 API 默认)。 */store?: boolean;
|
|
2699
|
-
/**
|
|
2700
|
-
* false = 不发送 max_output_tokens 字段。官方 `openai/codex` CLI 源码(`ResponsesApiRequest`
|
|
2701
|
-
* 结构体)从不发送该字段(用 `reasoning`/`text` 控制输出),且社区证据(reasoning 模型
|
|
2702
|
-
* 系列经 Responses API 收到该字段会被 400 拒绝)表明这不是可选的风格差异。缺省 true(发送)。
|
|
2703
|
-
*/
|
|
2704
|
-
sendMaxOutputTokens?: boolean;
|
|
2705
|
-
};
|
|
2706
|
-
} //#endregion
|
|
2707
|
-
//#region src/types.d.ts
|
|
2708
|
-
interface ToolDefinition<TArgs = unknown> {
|
|
2709
|
-
name: string;
|
|
2710
|
-
description: string;
|
|
2711
|
-
parameters: ZodType<TArgs>;
|
|
2712
|
-
}
|
|
2713
|
-
/**
|
|
2714
|
-
* system prompt 的缓存稳定性分层段。仅用于 Anthropic 动态断点定位——
|
|
2715
|
-
* provider 在「最后一个 stable 段」之后挂 cache_control,volatile 段照发但不进缓存前缀。
|
|
2716
|
-
* content 的真相源仍是 StreamContext.systemPrompt(完整扁平串,供其它 provider 消费)。
|
|
2717
|
-
*/
|
|
2718
|
-
interface SystemPromptSegment {
|
|
2719
|
-
text: string;
|
|
2720
|
-
/** 'stable'(默认)=会话内冻结、进缓存前缀;'volatile'=每轮可变、落在断点之后。 */
|
|
2721
|
-
cache?: 'stable' | 'volatile';
|
|
2722
|
-
}
|
|
2723
|
-
/**
|
|
2724
|
-
* prompt cache 保留档(决定 Anthropic ephemeral 断点的 TTL):
|
|
2725
|
-
* - 'none':不放任何缓存断点(一次性/eval 请求,省去缓存写开销);
|
|
2726
|
-
* - 'short'(缺省语义):5 分钟 TTL;
|
|
2727
|
-
* - 'long':1 小时 TTL(长会话——思考久/工具轮多/有交互空档时命中率更高)。
|
|
2728
|
-
*/
|
|
2729
|
-
type CacheRetention = 'none' | 'short' | 'long';
|
|
2730
|
-
interface StreamContext {
|
|
2731
|
-
model: Model;
|
|
2732
|
-
/** 完整 system 文本(stable + volatile 已拼接)。所有 provider 的 content 真相源。 */
|
|
2733
|
-
systemPrompt: string;
|
|
2734
|
-
/**
|
|
2735
|
-
* 可选的缓存分层视图。仅 Anthropic 据此动态放断点;省略时退化为单块尾部断点(旧行为)。
|
|
2736
|
-
* 各段 text 拼接应等价于 systemPrompt。
|
|
2737
|
-
*/
|
|
2738
|
-
systemPromptSegments?: SystemPromptSegment[];
|
|
2739
|
-
messages: Message[];
|
|
2740
|
-
tools?: ToolDefinition[];
|
|
2741
|
-
thinkingLevel?: ThinkingLevel;
|
|
2742
|
-
maxTokens?: number;
|
|
2743
|
-
temperature?: number;
|
|
2744
|
-
cacheRetention?: CacheRetention;
|
|
2745
|
-
}
|
|
2746
|
-
interface StreamOptions {
|
|
2747
|
-
signal?: AbortSignal;
|
|
2748
|
-
timeout?: number;
|
|
2749
|
-
/**
|
|
2750
|
-
* SSE 流的**空闲**超时(毫秒,仅 stream()):每收到一个 chunk 重置;连续此 ms 内无任何
|
|
2751
|
-
* 字节到达即 abort。与 `timeout`(整请求墙钟上限)不同——专治「连接活着但 provider
|
|
2752
|
-
* 静默不再吐字节」的挂死。缺省 120s。
|
|
2753
|
-
*
|
|
2754
|
-
* RFC-XX reasoning-thinking:reasoning 模型(kimi-k3/GLM-5.2 等)的 thinking 阶段可
|
|
2755
|
-
* 长达分钟级零 visible token——中间无任何 SSE chunk,默认 120s idle 会无差别单边坑
|
|
2756
|
-
* 所有 reasoning 模型(实测 turn 3 触发:thinking_start → 零输出 → stream.retry×2 →
|
|
2757
|
-
* 崩)。调用方应据此在转产 conversational function 具调用(work-loop 等里)显式加大。
|
|
2758
|
-
*/
|
|
2759
|
-
idleTimeout?: number;
|
|
2760
|
-
}
|
|
2761
|
-
interface ProviderStream {
|
|
2762
|
-
readonly id: string;
|
|
2763
|
-
readonly displayName: string;
|
|
2764
|
-
/**
|
|
2765
|
-
* 统一鉴权解析(RFC-140 D5):此前 4 个 provider 实现(当时在本包,RFC-148 M2 后
|
|
2766
|
-
* anthropic-messages/openai-responses/openai-completions 已迁至
|
|
2767
|
-
* extensions/plugin-otto-wire-protocols/src/,github-copilot 在
|
|
2768
|
-
* extensions/plugin-github-copilot/src/provider.ts)各自的凭据解析签名各不相同——
|
|
2769
|
-
* anthropic 是 `resolveAuthCredential(): Promise<ResolvedAuth>`(唯一带 mode/beta 的
|
|
2770
|
-
* 完整版,未走接口声明的 `resolveKey`),其余三个各自实现
|
|
2771
|
-
* `resolveKey(): Promise<string>` 但入参/来源不统一。新 provider 作者(含第三方代码式
|
|
2772
|
-
* 插件)不知道该实现哪一个。统一为单一签名:`ResolvedAuth` 已含 token/mode/beta,语义
|
|
2773
|
-
* 完整,解析失败时 reject(不返回 null——沿用各实现既有的 PROVIDER_AUTH_MISSING
|
|
2774
|
-
* 错误纹理)。
|
|
2775
|
-
*
|
|
2776
|
-
* 可选(`?`)保留是因为 `ProviderRegistry`/`AuthStore` 侧的调用路径本就允许 provider
|
|
2777
|
-
* 不声明鉴权解析(极少数场景,如未来的零凭据本地 provider);四个内置 wire 实现全部
|
|
2778
|
-
* 实现该方法。
|
|
2779
|
-
*/
|
|
2780
|
-
resolveAuth?(model: Model): Promise<ResolvedAuth>;
|
|
2781
|
-
converse(model: Model<Api>, context: StreamContext, options: StreamOptions, signal: AbortSignal): AsyncIterable<StreamEvent>;
|
|
2782
|
-
/**
|
|
2783
|
-
* 可选清理钩子(RFC-105 D2/评审 F8):卸载时释放 HTTP 连接池/流等资源。
|
|
2784
|
-
* 内置 provider 目前均无持久资源,可不实现;插件 provider 卸载时
|
|
2785
|
-
* `ProviderRegistry.unregisterBySource` 会调用(存在则调用)。
|
|
2786
|
-
*/
|
|
2787
|
-
dispose?(): void | Promise<void>;
|
|
2788
|
-
}
|
|
2789
|
-
/**
|
|
2790
|
-
* JWT claim 派生 header 配置(RFC-122 D3)。结构对齐 openai-responses/openai-completions
|
|
2791
|
-
* 各自的同名本地定义——本类型仅供 `WireProtocolFactoryInput` 使用(RFC-148 新增的协议中立层
|
|
2792
|
-
* 入口);两个协议实现随 RFC-148 M2 物理迁移至 extensions/plugin-otto-wire-protocols/src/。
|
|
2793
|
-
*/
|
|
2794
|
-
interface TokenDerivedHeader {
|
|
2795
|
-
header: string;
|
|
2796
|
-
source: {
|
|
2797
|
-
kind: 'jwt-claim';
|
|
2798
|
-
claim: string;
|
|
2799
|
-
namespace?: string;
|
|
2800
|
-
tokenSources?: Array<'id_token' | 'access_token'>;
|
|
2801
|
-
};
|
|
2802
|
-
}
|
|
2803
|
-
/**
|
|
2804
|
-
* Wire 协议实现的注册契约(RFC-148 D1)——`@otto/ai` 的 `WireProtocolRegistry` 与
|
|
2805
|
-
* `@otto/plugin` 的 `PluginModule.wireProtocols` 轴共用同一份类型定义,避免跨包重复。
|
|
2806
|
-
* 定义在协议中立层(`@otto/provider`)而非 `@otto/ai`:两个消费方(宿主注册表 + 插件 SDK)
|
|
2807
|
-
* 都已 type-only 依赖本包,符合既有 `AnthropicRequestCustomizeInput` 的分层先例。
|
|
2808
|
-
*/
|
|
2809
|
-
interface WireRequestCustomizeInput {
|
|
2810
|
-
auth: {
|
|
2811
|
-
mode: 'api_key' | 'oauth';
|
|
2812
|
-
beta?: string;
|
|
2813
|
-
};
|
|
2814
|
-
sessionId: string;
|
|
2815
|
-
}
|
|
2816
|
-
/** 通用 system 文本块最小结构(`Anthropic.TextBlockParam` 的子集,SDK 无关,见 WireRequestCustomization.transformSystemBlocks)。 */
|
|
2817
|
-
interface WireSystemTextBlock {
|
|
2818
|
-
type: 'text';
|
|
2819
|
-
text: string;
|
|
2820
|
-
cache_control?: unknown;
|
|
2821
|
-
}
|
|
2822
|
-
interface WireRequestCustomization {
|
|
2823
|
-
defaultHeaders?: Record<string, string>;
|
|
2824
|
-
/** system 数组变换(如插入身份前缀块);非全部协议都支持——不支持的协议实现忽略该字段。 */
|
|
2825
|
-
transformSystemBlocks?: (blocks: WireSystemTextBlock[] | undefined) => WireSystemTextBlock[] | undefined;
|
|
2826
|
-
metadata?: Record<string, unknown>;
|
|
2827
|
-
}
|
|
2828
|
-
/**
|
|
2829
|
-
* 插件侧协议实现的日志端口(RFC-185 D3)。宿主注入(走宿主进程的单一 pino 单例 →
|
|
2830
|
-
* 日志总线/文件),插件源码**禁止**自建 `createLogger`——esbuild bundle 会把
|
|
2831
|
-
* `@otto/shared` logger 整体复制成第二份单例,宿主的级别/通道控制够不着它,直写
|
|
2832
|
-
* stderr 破坏 TUI(findings-backlog「2026-07-13 TUI 残影回归」根因环 2)。
|
|
2833
|
-
* `debug` 档是宿主↔协议实现的内部约定(`PluginContext.logger` 对外仍是
|
|
2834
|
-
* info/warn/error 三档 + 可选 debug)。
|
|
2835
|
-
*/
|
|
2836
|
-
interface WireProtocolLogger {
|
|
2837
|
-
/** 首参兼容 pino 两种惯用形态:结构化对象(mergingObject)或格式化字符串。 */
|
|
2838
|
-
debug: (objOrMsg: string | Record<string, unknown>, ...args: unknown[]) => void;
|
|
2839
|
-
info: (objOrMsg: string | Record<string, unknown>, ...args: unknown[]) => void;
|
|
2840
|
-
warn: (objOrMsg: string | Record<string, unknown>, ...args: unknown[]) => void;
|
|
2841
|
-
error: (objOrMsg: string | Record<string, unknown>, ...args: unknown[]) => void;
|
|
2842
|
-
}
|
|
2843
|
-
interface WireProtocolFactoryInput {
|
|
2844
|
-
resolveAuth: () => Promise<{
|
|
2845
|
-
token: string;
|
|
2846
|
-
mode: 'api_key' | 'oauth';
|
|
2847
|
-
beta?: string;
|
|
2848
|
-
} | undefined>;
|
|
2849
|
-
resolveBaseUrl: () => Promise<string | undefined>;
|
|
2850
|
-
headers?: Record<string, string>;
|
|
2851
|
-
tokenDerivedHeaders?: TokenDerivedHeader[];
|
|
2852
|
-
/** 请求定制点——厂商个性注入唯一通道(如 plugin-anthropic 的 Claude Code 伪装)。 */
|
|
2853
|
-
customizeRequest?: (input: WireRequestCustomizeInput) => WireRequestCustomization;
|
|
2854
|
-
/**
|
|
2855
|
-
* RFC-270 D3:允许 manifest 静态头/JWT 派生头/拦截器覆盖鉴权头(`authorization`/`x-api-key`)。
|
|
2856
|
-
* 缺省 `undefined` = 不允许(默认丢弃 + warn)——otto 的 manifest 可由第三方插件分发,
|
|
2857
|
-
* 静默替换 Authorization 等于把用户凭据路由到任意端点。企业网关确需换鉴权时由 provider
|
|
2858
|
-
* 在 manifest 显式声明 `allowAuthHeaderOverride: true`,装载期 warn 一条保证可审计。
|
|
2859
|
-
*/
|
|
2860
|
-
allowAuthHeaderOverride?: boolean;
|
|
2861
|
-
sessionId?: string;
|
|
2862
|
-
/**
|
|
2863
|
-
* RFC-185 D3:宿主注入的日志端口。可选字段(向后兼容,不 bump PLUGIN_API_VERSION);
|
|
2864
|
-
* 缺省时协议实现必须 fallback 到 no-op——绝不 fallback 到 createLogger(复活第二单例)。
|
|
2865
|
-
*/
|
|
2866
|
-
logger?: WireProtocolLogger;
|
|
2867
|
-
}
|
|
2868
|
-
/** 协议注册携带的能力元数据(RFC-147 B-1:替代 `CACHE_REPORTING_APIS` 硬编码白名单)。 */
|
|
2869
|
-
interface WireProtocolMeta {
|
|
2870
|
-
/** 该协议的 usage 是否携带 cache token 字段。缺省 = false(不上报)。 */
|
|
2871
|
-
reportsCacheTokens?: boolean;
|
|
2872
|
-
}
|
|
2873
|
-
interface WireProtocolRegistration {
|
|
2874
|
-
create: (input: WireProtocolFactoryInput) => ProviderStream;
|
|
2875
|
-
meta?: WireProtocolMeta;
|
|
2876
|
-
}
|
|
2877
|
-
type OAuthCredentials = {
|
|
2878
|
-
refresh: string;
|
|
2879
|
-
access: string;
|
|
2880
|
-
expires: number; /** GitHub Enterprise host(如 company.ghe.com);持久化以便后续刷新仍打到企业域而非默认 github.com。 */
|
|
2881
|
-
domain?: string;
|
|
2882
|
-
[key: string]: unknown;
|
|
2883
|
-
};
|
|
2884
|
-
type OAuthProviderId = string;
|
|
2885
|
-
interface OAuthInfo {
|
|
2886
|
-
url: string;
|
|
2887
|
-
code?: string;
|
|
2888
|
-
instructions?: string;
|
|
2889
|
-
}
|
|
2890
|
-
interface OAuthPrompt {
|
|
2891
|
-
message: string;
|
|
2892
|
-
placeholder?: string;
|
|
2893
|
-
allowEmpty?: boolean;
|
|
2894
|
-
}
|
|
2895
|
-
interface OAuthLoginOptions {
|
|
2896
|
-
onAuth: (info: OAuthInfo) => void;
|
|
2897
|
-
onPrompt: (prompt: OAuthPrompt) => Promise<string>;
|
|
2898
|
-
onProgress?: (message: string) => void;
|
|
2899
|
-
/**
|
|
2900
|
-
* 手动粘贴授权码兜底通道。`signal` 由 provider 在自动通道(loopback 回调)
|
|
2901
|
-
* 先完成时触发——实现方应据此关闭粘贴输入框并 resolve 空串。
|
|
2902
|
-
*/
|
|
2903
|
-
onManualCode?: (signal?: AbortSignal) => Promise<string>;
|
|
2904
|
-
signal?: AbortSignal;
|
|
2905
|
-
}
|
|
2906
|
-
interface OAuthRefreshTokenOptions extends OAuthCredentials {
|
|
2907
|
-
domain?: string;
|
|
2908
|
-
}
|
|
2909
|
-
interface OAuthProvider {
|
|
2910
|
-
readonly id: OAuthProviderId;
|
|
2911
|
-
readonly name: string;
|
|
2912
|
-
usesCallbackServer?: boolean;
|
|
2913
|
-
/**
|
|
2914
|
-
* 以 OAuth token 调用对应 API 时必带的 beta 头(如 Anthropic 的 `oauth-2025-04-20`)。
|
|
2915
|
-
* provider 据此在 oauth 模式下附加 `anthropic-beta`(M8-04/05)。
|
|
2916
|
-
*/
|
|
2917
|
-
readonly oauthBeta?: string;
|
|
2918
|
-
/**
|
|
2919
|
-
* 此 OAuth 令牌是否绑定到某个**产品订阅**(如 Anthropic 的 Claude Code 订阅 token
|
|
2920
|
-
* `sk-ant-oat`)。这类令牌在用于该产品自身 system prompt 之外的请求时会被服务端限流
|
|
2921
|
-
* (HTTP 429),因此**不适合**用作 subagent 委派的可用模型来源(RFC-061 §3 D2)。
|
|
2922
|
-
* 由 usability gate(`@otto/ai/model-usability`)消费;供 api_key 凭证不受此影响——
|
|
2923
|
-
* provider 一旦持有真 API key,`getAuthSource` 返回 `api_key`,此标志即不被查询。
|
|
2924
|
-
*/
|
|
2925
|
-
readonly subscriptionScoped?: boolean;
|
|
2926
|
-
login(options: OAuthLoginOptions): Promise<OAuthCredentials>;
|
|
2927
|
-
refreshToken(options: OAuthRefreshTokenOptions): Promise<OAuthCredentials>;
|
|
2928
|
-
getAccessKey(credentials: OAuthCredentials): string;
|
|
2929
|
-
}
|
|
2930
|
-
type AuthMode = 'api_key' | 'oauth';
|
|
2931
|
-
interface ResolvedAuth {
|
|
2932
|
-
/** 实际用于鉴权的令牌(API key 或 OAuth access token)。 */
|
|
2933
|
-
token: string;
|
|
2934
|
-
/** 鉴权模式。 */
|
|
2935
|
-
mode: AuthMode;
|
|
2936
|
-
/** OAuth 模式下需附带的 beta 头(来源于 OAuthProvider.oauthBeta)。 */
|
|
2937
|
-
beta?: string;
|
|
2938
|
-
} //#endregion
|
|
2939
|
-
//#region src/provider/chat-completions.d.ts
|
|
2940
|
-
//#endregion
|
|
2941
|
-
//#region ../interchange/dist/index.d.ts
|
|
2942
|
-
interface GrillOption {
|
|
2943
|
-
label: string;
|
|
2944
|
-
rationale: string;
|
|
2945
|
-
recommended?: boolean;
|
|
2946
|
-
preview?: string;
|
|
2947
|
-
}
|
|
2948
|
-
interface GrillAnswer {
|
|
2949
|
-
answer: string;
|
|
2950
|
-
selectedOptionLabels?: string[];
|
|
2951
|
-
acceptedRecommendation: boolean;
|
|
2952
|
-
/**
|
|
2953
|
-
* 回答的来源(终局语义):
|
|
2954
|
-
* - 'human':真实用户(TUI/交互端)作答。
|
|
2955
|
-
* - 'auto_recommendation':调用方/LLM 侧在无交互需求下按推荐直接沉降(推荐被采纳,且这不是环境限制导致)。
|
|
2956
|
-
* - 'environment_headless':运行环境本身不支持问询(headless/无 UI),自动把推荐沉降。
|
|
2957
|
-
* 插件状态机不应把这种回答当作"用户明确接受"来推进候选。
|
|
2958
|
-
*/
|
|
2959
|
-
resolvedBy: 'human' | 'auto_recommendation' | 'environment_headless';
|
|
2960
|
-
/** grill_me allowFreeform:用户在选项之外输入的补充文字。 */
|
|
2961
|
-
freeformText?: string;
|
|
2962
|
-
}
|
|
2963
|
-
//#endregion
|
|
2964
|
-
//#region src/input.d.ts
|
|
2965
|
-
/** Input: mentions, sigils, content providers — user input enrichment types. */
|
|
2966
|
-
/** sigil 子类型:`hashtag` 属 `#`,其余属 `@`。`resource` = 插件自定义资源(RFC-210 D2);
|
|
2967
|
-
* `shortcut` = 用户在本仓库自定义的文本快捷方式(RFC-233)。 */
|
|
2968
|
-
type SigilKind = 'hashtag' | 'file' | 'person' | 'agent' | 'skill' | 'mcp' | 'plugin' | 'model' | 'resource' | 'shortcut';
|
|
2969
|
-
/** 触发前缀。 */
|
|
2970
|
-
type SigilPrefix = '#' | '@';
|
|
2971
|
-
/** 条目来源标识(unregisterBySource 据此批量注销,防僵尸条目)。 */
|
|
2972
|
-
type SigilSource = 'builtin' | 'plugin' | 'skill' | 'mcp' | (string & {});
|
|
2973
|
-
/**
|
|
2974
|
-
* 动态供给函数(pull 模型):按 query 懒查候选,服务 @file 等大候选集——
|
|
2975
|
-
* 不全量 register()。可同步或异步(文件系统遍历走异步)。
|
|
2976
|
-
*/
|
|
2977
|
-
type SigilProvider = (query: string, sigil: SigilPrefix) => SigilEntry[] | Promise<SigilEntry[]>;
|
|
2978
|
-
/** sigil 面板条目:label(展示)与 value(替换内容)严格分离(R2)。 */
|
|
2979
|
-
interface SigilEntry {
|
|
2980
|
-
/** 面板中展示的名称(简短、人类可读)。绝不进入 prompt 文本。 */
|
|
2981
|
-
label: string;
|
|
2982
|
-
/** 选中后替换 #trigger/@trigger 的实质内容。绝不在面板中完整展示。 */
|
|
2983
|
-
value: string;
|
|
2984
|
-
/** 面板中展示的描述(可选,列表副标题)。 */
|
|
2985
|
-
description?: string;
|
|
2986
|
-
/** 条目类型(影响面板分组/着色,并决定属于 # 还是 @)。 */
|
|
2987
|
-
kind: SigilKind;
|
|
2988
|
-
/** 来源标识(builtin | plugin | skill | mcp | 自定义 pluginId)。 */
|
|
2989
|
-
source?: SigilSource;
|
|
2990
|
-
/**
|
|
2991
|
-
* RFC-210 D2:resolve 引用。非空 = "提交时展开"型资源——展开管线(app.expandSigilChips)
|
|
2992
|
-
* 用此 id 查 SigilResolverRegistry 拿 resolve 函数,把该条目的 chip 替换为其返回值。
|
|
2993
|
-
* 空 = 透传型(chip 原样给 LLM)或纯文本型(value 即内容),行为与现状完全一致。
|
|
2994
|
-
*/
|
|
2995
|
-
resolverId?: string;
|
|
2996
|
-
}
|
|
2997
|
-
/**
|
|
2998
|
-
* RFC-210 D2:@ 资源提交时展开函数(代码契约——不可序列化,归 coding 层
|
|
2999
|
-
* SigilResolverRegistry,与纯数据的 PluginInputRegistry 平行;D9 两类契约纪律)。
|
|
3000
|
-
*/
|
|
3001
|
-
interface SigilResolver {
|
|
3002
|
-
/** resolver id,命名空间 `<pluginId>:<name>`(内置无前缀)。 */
|
|
3003
|
-
id: string;
|
|
3004
|
-
/** 提交时展开:输入 chip 参数(`[@kind:param]` 的 param 段),返回发给 LLM 的内容。 */
|
|
3005
|
-
resolve: (param: string, ctx: SigilResolveContext) => string | Promise<string>;
|
|
3006
|
-
/** 超时(ms,缺省 10_000,对齐既有 CONTEXT_CHIPS 约束)。 */
|
|
3007
|
-
timeoutMs?: number;
|
|
3008
|
-
/**
|
|
3009
|
-
* uiHostOnly(RFC-210 评审 B11):true = 读取"UI 所在机器"的本地资源(非 workspaceDir
|
|
3010
|
-
* 内容),只应在与用户同机的宿主进程(TUI/cli)执行;service expand 端点跳过执行。
|
|
3011
|
-
* @clipboard = true(读桌面剪贴板);@changes/@git = false(读 workspaceDir git 状态,
|
|
3012
|
-
* service 为远程 workspace 服务时服务器上的状态正是用户要的内容)。
|
|
3013
|
-
*/
|
|
3014
|
-
uiHostOnly?: boolean;
|
|
3015
|
-
}
|
|
3016
|
-
/** SigilResolver.resolve 的执行上下文。 */
|
|
3017
|
-
interface SigilResolveContext {
|
|
3018
|
-
workspaceDir: string;
|
|
3019
|
-
/** 输出上限(字符,缺省 20_000,超限截断——对齐既有 MAX_OUTPUT)。 */
|
|
3020
|
-
maxOutput: number;
|
|
3021
|
-
}
|
|
3022
|
-
/**
|
|
3023
|
-
* 插件输入注册表(UI 无关,由 createApp() 创建单例,实现留 @otto/coding)。
|
|
3024
|
-
*
|
|
3025
|
-
* 静态 push 供给(register)+ 动态 pull 供给(registerProvider,服务 @file
|
|
3026
|
-
* 大候选集懒查,RFC §1.3.1 F-domain / RFC-044 M044-07)。
|
|
3027
|
-
*/
|
|
3028
|
-
interface PluginInputRegistry {
|
|
3029
|
-
/** 注册一批条目(last-write-wins,按 (label, kind) 复合键去重)。 */
|
|
3030
|
-
register(entries: SigilEntry[]): void;
|
|
3031
|
-
/**
|
|
3032
|
-
* 注册某 sigil 的动态供给器(pull 模型,按 query 懒查,如 @file)。
|
|
3033
|
-
* 返回注销函数。其结果在 searchAsync 中与静态条目合并。
|
|
3034
|
-
*/
|
|
3035
|
-
registerProvider(sigil: SigilPrefix, provider: SigilProvider): () => void;
|
|
3036
|
-
/**
|
|
3037
|
-
* 按 query + sigil 过滤匹配条目。过滤在此完成(R4),UI 只渲染结果。
|
|
3038
|
-
* 命中数达 maxResults 立即返回,不全量遍历(F-domain 性能)。
|
|
3039
|
-
* 仅静态条目;动态 provider 结果见 searchAsync。
|
|
3040
|
-
*/
|
|
3041
|
-
search(query: string, sigil?: SigilPrefix, maxResults?: number): SigilEntry[];
|
|
3042
|
-
/**
|
|
3043
|
-
* 异步搜索:静态条目(即时)+ 动态 provider 结果(await)合并去重。
|
|
3044
|
-
* UI 应优先用此方法以纳入 @file 等懒查候选;无 provider 时等价 search。
|
|
3045
|
-
*/
|
|
3046
|
-
searchAsync(query: string, sigil?: SigilPrefix, maxResults?: number): Promise<SigilEntry[]>;
|
|
3047
|
-
/** 返回某 sigil(或全部)的全量条目(只读快照)。 */
|
|
3048
|
-
getAll(sigil?: SigilPrefix): readonly SigilEntry[];
|
|
3049
|
-
/** 按 label 查首个匹配条目。 */
|
|
3050
|
-
findByLabel(label: string): SigilEntry | undefined;
|
|
3051
|
-
/** 注销某 label 的所有条目,返回是否删除过。 */
|
|
3052
|
-
unregister(label: string): boolean;
|
|
3053
|
-
/** 注销某 source 的所有条目(插件 unload 必调,防僵尸——R5)。 */
|
|
3054
|
-
unregisterBySource(source: string): void;
|
|
3055
|
-
}
|
|
3056
|
-
/** 根据 kind 推断其归属的 sigil 前缀。 */
|
|
3057
|
-
declare function sigilOf(kind: SigilKind): SigilPrefix;
|
|
3058
|
-
/** sigil 触发信息:检测到的 sigil 字符 + 查询串 + 锚点位置。 */
|
|
3059
|
-
//#endregion
|
|
3060
2295
|
//#region src/sdk.d.ts
|
|
3061
2296
|
/**
|
|
3062
|
-
* @otto/plugin-sdk —— 插件作者 SDK(RFC-082 M082-04,代码逻辑入口)。
|
|
2297
|
+
* @x-otto/plugin-sdk —— 插件作者 SDK(RFC-082 M082-04,代码逻辑入口)。
|
|
3063
2298
|
*
|
|
3064
2299
|
* 作者写一份 `plugin.ts`,`export default definePlugin(ctx => ({...}))`。这是 Vite `defineConfig`
|
|
3065
2300
|
* 的对等物:`definePlugin` 仅做**类型锚 + identity**(原样返回工厂),不含任何运行时编排——
|
|
@@ -3214,7 +2449,7 @@ interface PluginContext {
|
|
|
3214
2449
|
* RFC-132 既定架构边界)——`WireProtocolRegistry.get()` 就是插件间协议复用的公开通道。
|
|
3215
2450
|
* 未注入 `wireProtocolRegistry` 时(如轻量测试装配)恒返回 `undefined`。
|
|
3216
2451
|
*/
|
|
3217
|
-
getWireProtocol: (wireApi: string) => WireProtocolRegistration | undefined;
|
|
2452
|
+
getWireProtocol: (wireApi: string) => _$_x_otto_provider0.WireProtocolRegistration | undefined;
|
|
3218
2453
|
/**
|
|
3219
2454
|
* 解析该插件自身 provider 的完整凭据(RFC-148 M3,`resolveProviderCredential` 的姊妹方法):
|
|
3220
2455
|
* 后者只给裸 key(多数代码式 provider 够用,如 GitHub Copilot),本方法额外给 `mode`/`beta`
|
|
@@ -3223,7 +2458,7 @@ interface PluginContext {
|
|
|
3223
2458
|
* 白名单校验,装载器实现层面共享同一份判定逻辑,见 `plugin-module-manager.ts`)。
|
|
3224
2459
|
* 未注入 `providerRegistry` 或 api 不属于本插件时恒返回 `null`。
|
|
3225
2460
|
*/
|
|
3226
|
-
resolveProviderAuth: (api: string) => Promise<ResolvedAuth | null>;
|
|
2461
|
+
resolveProviderAuth: (api: string) => Promise<_$_x_otto_provider0.ResolvedAuth | null>;
|
|
3227
2462
|
/**
|
|
3228
2463
|
* RFC-287 D2:受控宿主能力面——每个字段对应一个独立声明+独立授权的高危能力,
|
|
3229
2464
|
* 未声明/未授予即为 `undefined`(fail-closed)。详见 `PluginHostCapabilities`。
|
|
@@ -3242,32 +2477,32 @@ interface PluginContext {
|
|
|
3242
2477
|
* provider 工厂(RFC-105 D3,代码式 provider 轴)。
|
|
3243
2478
|
*
|
|
3244
2479
|
* **分层纪律例外(RFC-140 D6,评审 R2,显式承认)**:此前签名故意保持轻量、不 import
|
|
3245
|
-
* `@otto/ai` 的 `ProviderStream`——`@otto/plugin` 是前端与领域无关的契约层(同
|
|
3246
|
-
* session-contract 分层纪律),不该下沉到具体能力包的类型。这里对 `@otto/provider` 的
|
|
3247
|
-
* type-only 依赖是对该纪律的**有意识放松**,非"不违反":`@otto/provider` 是可发布的
|
|
2480
|
+
* `@x-otto/ai` 的 `ProviderStream`——`@x-otto/plugin` 是前端与领域无关的契约层(同
|
|
2481
|
+
* session-contract 分层纪律),不该下沉到具体能力包的类型。这里对 `@x-otto/provider` 的
|
|
2482
|
+
* type-only 依赖是对该纪律的**有意识放松**,非"不违反":`@x-otto/provider` 是可发布的
|
|
3248
2483
|
* provider 插入点公开契约包(不是任意能力包),此依赖消除了每个代码式 provider 插件
|
|
3249
2484
|
* 之前被迫写的 `as unknown as Record<string, unknown>` 双重类型断言。
|
|
3250
2485
|
*
|
|
3251
|
-
* 守卫条款:`@otto/provider` **不得**反向依赖 `@otto/plugin`(已核实零依赖,见
|
|
2486
|
+
* 守卫条款:`@x-otto/provider` **不得**反向依赖 `@x-otto/plugin`(已核实零依赖,见
|
|
3252
2487
|
* `packages/provider/package.json`)——若未来该依赖产生实际问题,可回退为宽松形状。
|
|
3253
2488
|
*/
|
|
3254
|
-
type PluginProviderFactory = () => ProviderStream;
|
|
2489
|
+
type PluginProviderFactory = () => _$_x_otto_provider0.ProviderStream;
|
|
3255
2490
|
/**
|
|
3256
2491
|
* Wire 协议实现注册(RFC-148 D1/D2):注册具名 wire 格式(如 `anthropic-messages`)的流式
|
|
3257
2492
|
* 协议实现,供任意声明式/代码式 provider 插件经 `wireApi` 字符串引用。与 `PluginProviderFactory`
|
|
3258
|
-
* 同一分层纪律——type-only 依赖 `@otto/provider`(可发布的公开契约包),不下沉到具体能力包。
|
|
3259
|
-
* 直接复用 `@otto/provider` 的 `WireProtocolRegistration`(宿主 `WireProtocolRegistry` 与本
|
|
2493
|
+
* 同一分层纪律——type-only 依赖 `@x-otto/provider`(可发布的公开契约包),不下沉到具体能力包。
|
|
2494
|
+
* 直接复用 `@x-otto/provider` 的 `WireProtocolRegistration`(宿主 `WireProtocolRegistry` 与本
|
|
3260
2495
|
* SDK 类型共用同一份定义,见 `packages/provider/src/types.ts`),不重复声明字段。
|
|
3261
2496
|
*/
|
|
3262
|
-
type PluginWireProtocolRegistration = WireProtocolRegistration;
|
|
2497
|
+
type PluginWireProtocolRegistration = _$_x_otto_provider0.WireProtocolRegistration;
|
|
3263
2498
|
/**
|
|
3264
2499
|
* 代码式 OAuth 工厂(RFC-122 D1 逃生口,RFC-130 M131-1 首用)。
|
|
3265
|
-
* 分层纪律同 `PluginProviderFactory`(终局 review 修复:直接 import `@otto/provider` 的
|
|
3266
|
-
* `OAuthProvider` 官方类型而非宽松 `Record<string, unknown>`——`@otto/provider` 是零反向
|
|
2500
|
+
* 分层纪律同 `PluginProviderFactory`(终局 review 修复:直接 import `@x-otto/provider` 的
|
|
2501
|
+
* `OAuthProvider` 官方类型而非宽松 `Record<string, unknown>`——`@x-otto/provider` 是零反向
|
|
3267
2502
|
* 依赖的公开契约包,插件作者可获得编译期类型检查,`class XxxOAuthProvider implements
|
|
3268
2503
|
* OAuthProvider` 能直接赋值,不再需要类型收窄绕行)。
|
|
3269
2504
|
*/
|
|
3270
|
-
type PluginOAuthProviderFactory = () => OAuthProvider;
|
|
2505
|
+
type PluginOAuthProviderFactory = () => _$_x_otto_provider0.OAuthProvider;
|
|
3271
2506
|
/**
|
|
3272
2507
|
* RFC-303 M4:代码式工具执行上下文(execute 的可选第二参数,additive——存量单参工具
|
|
3273
2508
|
* `execute(args)` 零改动继续工作,R7 不 bump PLUGIN_API_VERSION)。
|
|
@@ -3304,7 +2539,7 @@ interface PluginToolContext {
|
|
|
3304
2539
|
}
|
|
3305
2540
|
/**
|
|
3306
2541
|
* 代码式工具(RFC-105 D4,tools 轴)。同 `PluginProviderFactory` 的分层纪律——不 import
|
|
3307
|
-
* `@otto/interchange` 的 `AgentTool`,避免契约层下沉到具体能力包类型。作者写的工具对象在
|
|
2542
|
+
* `@x-otto/interchange` 的 `AgentTool`,避免契约层下沉到具体能力包类型。作者写的工具对象在
|
|
3308
2543
|
* 装载时由 `coding/src/plugin/` 收窄校验为真实 `AgentTool`(结构不符时 fail-soft 丢弃该条)。
|
|
3309
2544
|
*/
|
|
3310
2545
|
interface PluginTool {
|
|
@@ -3507,11 +2742,11 @@ interface PluginModule {
|
|
|
3507
2742
|
* key = resolver 名(装载器强制 `<pluginId>:<name>` 命名空间前缀防碰撞,同 providerFactories
|
|
3508
2743
|
* 纪律)。声明式条目(`contributes.sigilEntries`)经 `resolverId` 引用这里的 resolver——
|
|
3509
2744
|
* 装载器校验引用完整性(entry.resolverId 无对应 resolver → warn + 该条目仍注册但提交时
|
|
3510
|
-
* 透传,fail-soft)。resolve 契约见 `@otto/interchange` SigilResolver(本 SDK 不重复类型,
|
|
2745
|
+
* 透传,fail-soft)。resolve 契约见 `@x-otto/interchange` SigilResolver(本 SDK 不重复类型,
|
|
3511
2746
|
* 分层纪律同 PluginProviderFactory 的 type-only 依赖豁免——interchange 是可发布契约包)。
|
|
3512
2747
|
*/
|
|
3513
|
-
sigilResolvers?: Record<string, SigilResolver['resolve'] | {
|
|
3514
|
-
resolve: SigilResolver['resolve'];
|
|
2748
|
+
sigilResolvers?: Record<string, _$_x_otto_interchange0.SigilResolver['resolve'] | {
|
|
2749
|
+
resolve: _$_x_otto_interchange0.SigilResolver['resolve'];
|
|
3515
2750
|
timeoutMs?: number;
|
|
3516
2751
|
uiHostOnly?: boolean;
|
|
3517
2752
|
}>;
|
|
@@ -3521,7 +2756,7 @@ interface PluginModule {
|
|
|
3521
2756
|
* `SigilProvider` 先例)。装载器注册进 PluginInputRegistry.registerProvider('@', …),
|
|
3522
2757
|
* 返回条目的 source 由装载器强制打为 pluginId(R2)。
|
|
3523
2758
|
*/
|
|
3524
|
-
sigilProviders?: SigilProvider[];
|
|
2759
|
+
sigilProviders?: _$_x_otto_interchange0.SigilProvider[];
|
|
3525
2760
|
/**
|
|
3526
2761
|
* RFC-287 D-M3-1:常驻服务(代码轴)。需 manifest 声明 `capabilities: ["service"]`
|
|
3527
2762
|
* (fail-closed,高危)。宿主在独立的 `PluginServicePool`(长生命周期 worker,启用
|
|
@@ -3650,10 +2885,10 @@ interface PluginHostCapabilities {
|
|
|
3650
2885
|
* 入参没有 `id` / `askedBy` / `sessionId`;`askedBy` 由宿主按连接侧插件身份强制填
|
|
3651
2886
|
* `plugin:<pluginId>`,插件不能伪装成 agent/user/其他插件。
|
|
3652
2887
|
*/
|
|
3653
|
-
ask?: (input: HostAskInput) => Promise<GrillAnswer>;
|
|
2888
|
+
ask?: (input: HostAskInput) => Promise<_$_x_otto_interchange0.GrillAnswer>;
|
|
3654
2889
|
}
|
|
3655
2890
|
/**
|
|
3656
|
-
* RFC-318 D2(M1):`readTranscript` 的投影消息——**不是** `@otto/ai` 的 `Message`。
|
|
2891
|
+
* RFC-318 D2(M1):`readTranscript` 的投影消息——**不是** `@x-otto/ai` 的 `Message`。
|
|
3657
2892
|
*
|
|
3658
2893
|
* 契约层刻意定义独立结构:既隔离内部消息模型的演进(插件不耦合 `Message` 内部形状),
|
|
3659
2894
|
* 又在类型层面就物理排除敏感字段(没有 `tool_calls`/`arguments` 字段可填)。
|
|
@@ -3663,7 +2898,7 @@ interface HostAskInput {
|
|
|
3663
2898
|
question: string;
|
|
3664
2899
|
background: string;
|
|
3665
2900
|
recommendation: string;
|
|
3666
|
-
options?: GrillOption[];
|
|
2901
|
+
options?: _$_x_otto_interchange0.GrillOption[];
|
|
3667
2902
|
allowFreeform?: boolean;
|
|
3668
2903
|
multiSelect?: boolean;
|
|
3669
2904
|
evidence?: string[];
|
|
@@ -3764,8 +2999,8 @@ interface PluginServiceContext {
|
|
|
3764
2999
|
onNotify?: (handler: (n: PluginServiceNotification) => void | Promise<void>) => void;
|
|
3765
3000
|
}
|
|
3766
3001
|
/**
|
|
3767
|
-
* RFC-303 M5:插件 scoped persistence 的契约 shape(`@otto/plugin` 契约层不下沉实现——
|
|
3768
|
-
* 只声明插件侧可见的接口;`PluginScopedStorage` 实现类在 `@otto/coding`,结构适配)。
|
|
3002
|
+
* RFC-303 M5:插件 scoped persistence 的契约 shape(`@x-otto/plugin` 契约层不下沉实现——
|
|
3003
|
+
* 只声明插件侧可见的接口;`PluginScopedStorage` 实现类在 `@x-otto/coding`,结构适配)。
|
|
3769
3004
|
*/
|
|
3770
3005
|
interface PluginScopedStorageShape {
|
|
3771
3006
|
/** 当前插件的 scoped 根目录(realpath 已断言在 plugin-state 根下)。 */
|
|
@@ -3893,7 +3128,7 @@ declare function grantedPluginCapabilities(pluginDir: string, storePath?: string
|
|
|
3893
3128
|
* `sourceDir` 是包/本地目录本身;读不到/解析失败时返回空数组
|
|
3894
3129
|
* (fail-soft——不阻塞安装流程本身,只是不弹确认)。
|
|
3895
3130
|
*
|
|
3896
|
-
* 单一真相源:此前 `@otto/cli` 的 CLI 安装路径(`plugin.ts`)与 TUI 安装路径
|
|
3131
|
+
* 单一真相源:此前 `@x-otto/cli` 的 CLI 安装路径(`plugin.ts`)与 TUI 安装路径
|
|
3897
3132
|
* (`extension-plugin.ts`)各自内联实现了同一段"读 manifest → 过滤高危能力"逻辑,
|
|
3898
3133
|
* 下沉到此处消除双写(终局架构 review 2026-07-20)。
|
|
3899
3134
|
*/
|
|
@@ -3969,836 +3204,6 @@ interface PluginTrustVerdict {
|
|
|
3969
3204
|
*/
|
|
3970
3205
|
declare function evaluatePluginTrust(plugin: DiscoveredPlugin, storePath?: string): PluginTrustVerdict;
|
|
3971
3206
|
//#endregion
|
|
3972
|
-
//#region ../shared/dist/event-bus-inioRzYz.d.ts
|
|
3973
|
-
//#region src/event-emitter.d.ts
|
|
3974
|
-
type EventListener = (...args: never[]) => void;
|
|
3975
|
-
declare class TypedEventEmitter<T extends Record<keyof T, EventListener>> {
|
|
3976
|
-
private readonly listeners;
|
|
3977
|
-
on<K extends keyof T>(event: K, listener: T[K]): () => void;
|
|
3978
|
-
off<K extends keyof T>(event: K, listener: T[K]): void;
|
|
3979
|
-
emit<K extends keyof T>(event: K, ...args: Parameters<T[K]>): void;
|
|
3980
|
-
once<K extends keyof T>(event: K, listener: T[K]): () => void;
|
|
3981
|
-
removeAllListeners<K extends keyof T>(event?: K): void;
|
|
3982
|
-
listenerCount<K extends keyof T>(event: K): number;
|
|
3983
|
-
} //#endregion
|
|
3984
|
-
//#region src/event-bus.d.ts
|
|
3985
|
-
//#endregion
|
|
3986
|
-
//#region ../../node_modules/.pnpm/undici@8.7.0/node_modules/undici/types/utility.d.ts
|
|
3987
|
-
type AutocompletePrimitiveBaseType<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : never;
|
|
3988
|
-
type Autocomplete<T> = T | (AutocompletePrimitiveBaseType<T> & Record<never, never>);
|
|
3989
|
-
//#endregion
|
|
3990
|
-
//#region ../../node_modules/.pnpm/undici@8.7.0/node_modules/undici/types/header.d.ts
|
|
3991
|
-
/**
|
|
3992
|
-
* The header type declaration of `undici`.
|
|
3993
|
-
*/
|
|
3994
|
-
type IncomingHttpHeaders = Record<string, string | string[] | undefined>;
|
|
3995
|
-
/**
|
|
3996
|
-
* The header type declaration of `undici` for outgoing requests.
|
|
3997
|
-
*/
|
|
3998
|
-
type OutgoingHttpHeaders = Record<string, number | string | string[] | undefined>;
|
|
3999
|
-
type HeaderNames = Autocomplete<'Accept' | 'Accept-CH' | 'Accept-Charset' | 'Accept-Encoding' | 'Accept-Language' | 'Accept-Patch' | 'Accept-Post' | 'Accept-Ranges' | 'Access-Control-Allow-Credentials' | 'Access-Control-Allow-Headers' | 'Access-Control-Allow-Methods' | 'Access-Control-Allow-Origin' | 'Access-Control-Expose-Headers' | 'Access-Control-Max-Age' | 'Access-Control-Request-Headers' | 'Access-Control-Request-Method' | 'Age' | 'Allow' | 'Alt-Svc' | 'Alt-Used' | 'Authorization' | 'Cache-Control' | 'Clear-Site-Data' | 'Connection' | 'Content-Disposition' | 'Content-Encoding' | 'Content-Language' | 'Content-Length' | 'Content-Location' | 'Content-Range' | 'Content-Security-Policy' | 'Content-Security-Policy-Report-Only' | 'Content-Type' | 'Cookie' | 'Cross-Origin-Embedder-Policy' | 'Cross-Origin-Opener-Policy' | 'Cross-Origin-Resource-Policy' | 'Date' | 'Device-Memory' | 'ETag' | 'Expect' | 'Expect-CT' | 'Expires' | 'Forwarded' | 'From' | 'Host' | 'If-Match' | 'If-Modified-Since' | 'If-None-Match' | 'If-Range' | 'If-Unmodified-Since' | 'Keep-Alive' | 'Last-Modified' | 'Link' | 'Location' | 'Max-Forwards' | 'Origin' | 'Permissions-Policy' | 'Priority' | 'Proxy-Authenticate' | 'Proxy-Authorization' | 'Range' | 'Referer' | 'Referrer-Policy' | 'Retry-After' | 'Sec-Fetch-Dest' | 'Sec-Fetch-Mode' | 'Sec-Fetch-Site' | 'Sec-Fetch-User' | 'Sec-Purpose' | 'Sec-WebSocket-Accept' | 'Server' | 'Server-Timing' | 'Service-Worker-Navigation-Preload' | 'Set-Cookie' | 'SourceMap' | 'Strict-Transport-Security' | 'TE' | 'Timing-Allow-Origin' | 'Trailer' | 'Transfer-Encoding' | 'Upgrade' | 'Upgrade-Insecure-Requests' | 'User-Agent' | 'Vary' | 'Via' | 'WWW-Authenticate' | 'X-Content-Type-Options' | 'X-Frame-Options'>;
|
|
4000
|
-
type IANARegisteredMimeType = Autocomplete<'audio/aac' | 'video/x-msvideo' | 'image/avif' | 'video/av1' | 'application/octet-stream' | 'image/bmp' | 'text/css' | 'text/csv' | 'application/vnd.ms-fontobject' | 'application/epub+zip' | 'image/gif' | 'application/gzip' | 'text/html' | 'image/x-icon' | 'text/calendar' | 'image/jpeg' | 'text/javascript' | 'application/json' | 'application/ld+json' | 'audio/x-midi' | 'audio/mpeg' | 'video/mp4' | 'video/mpeg' | 'audio/ogg' | 'video/ogg' | 'application/ogg' | 'audio/opus' | 'font/otf' | 'application/pdf' | 'image/png' | 'application/rtf' | 'image/svg+xml' | 'image/tiff' | 'video/mp2t' | 'font/ttf' | 'text/plain' | 'application/wasm' | 'video/webm' | 'audio/webm' | 'image/webp' | 'font/woff' | 'font/woff2' | 'application/xhtml+xml' | 'application/xml' | 'application/zip' | 'video/3gpp' | 'video/3gpp2' | 'model/gltf+json' | 'model/gltf-binary'>;
|
|
4001
|
-
type KnownHeaderValues = {
|
|
4002
|
-
'content-type': IANARegisteredMimeType;
|
|
4003
|
-
};
|
|
4004
|
-
type HeaderRecord = { [K in HeaderNames | Lowercase<HeaderNames>]?: Lowercase<K> extends keyof KnownHeaderValues ? KnownHeaderValues[Lowercase<K>] : string };
|
|
4005
|
-
//#endregion
|
|
4006
|
-
//#region ../../node_modules/.pnpm/undici@8.7.0/node_modules/undici/types/readable.d.ts
|
|
4007
|
-
declare class BodyReadable extends Readable {
|
|
4008
|
-
constructor(opts: {
|
|
4009
|
-
resume: (this: Readable, size: number) => void | null;
|
|
4010
|
-
abort: () => void | null;
|
|
4011
|
-
contentType?: string;
|
|
4012
|
-
contentLength?: number;
|
|
4013
|
-
highWaterMark?: number;
|
|
4014
|
-
});
|
|
4015
|
-
/** Consumes and returns the body as a string
|
|
4016
|
-
* https://fetch.spec.whatwg.org/#dom-body-text
|
|
4017
|
-
*/
|
|
4018
|
-
text(): Promise<string>;
|
|
4019
|
-
/** Consumes and returns the body as a JavaScript Object
|
|
4020
|
-
* https://fetch.spec.whatwg.org/#dom-body-json
|
|
4021
|
-
*/
|
|
4022
|
-
json(): Promise<unknown>;
|
|
4023
|
-
/** Consumes and returns the body as a Blob
|
|
4024
|
-
* https://fetch.spec.whatwg.org/#dom-body-blob
|
|
4025
|
-
*/
|
|
4026
|
-
blob(): Promise<Blob>;
|
|
4027
|
-
/** Consumes and returns the body as an Uint8Array
|
|
4028
|
-
* https://fetch.spec.whatwg.org/#dom-body-bytes
|
|
4029
|
-
*/
|
|
4030
|
-
bytes(): Promise<Uint8Array>;
|
|
4031
|
-
/** Consumes and returns the body as an ArrayBuffer
|
|
4032
|
-
* https://fetch.spec.whatwg.org/#dom-body-arraybuffer
|
|
4033
|
-
*/
|
|
4034
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
4035
|
-
/** Not implemented
|
|
4036
|
-
*
|
|
4037
|
-
* https://fetch.spec.whatwg.org/#dom-body-formdata
|
|
4038
|
-
*/
|
|
4039
|
-
formData(): Promise<never>;
|
|
4040
|
-
/** Returns true if the body is not null and the body has been consumed
|
|
4041
|
-
*
|
|
4042
|
-
* Otherwise, returns false
|
|
4043
|
-
*
|
|
4044
|
-
* https://fetch.spec.whatwg.org/#dom-body-bodyused
|
|
4045
|
-
*/
|
|
4046
|
-
readonly bodyUsed: boolean;
|
|
4047
|
-
/**
|
|
4048
|
-
* If body is null, it should return null as the body
|
|
4049
|
-
*
|
|
4050
|
-
* If body is not null, should return the body as a ReadableStream
|
|
4051
|
-
*
|
|
4052
|
-
* https://fetch.spec.whatwg.org/#dom-body-body
|
|
4053
|
-
*/
|
|
4054
|
-
readonly body: never | undefined;
|
|
4055
|
-
/** Dumps the response body by reading `limit` number of bytes.
|
|
4056
|
-
* @param opts.limit Number of bytes to read (optional) - Default: 131072
|
|
4057
|
-
* @param opts.signal AbortSignal to cancel the operation (optional)
|
|
4058
|
-
*/
|
|
4059
|
-
dump(opts?: {
|
|
4060
|
-
limit: number;
|
|
4061
|
-
signal?: AbortSignal;
|
|
4062
|
-
}): Promise<void>;
|
|
4063
|
-
}
|
|
4064
|
-
//#endregion
|
|
4065
|
-
//#region ../../node_modules/.pnpm/undici@8.7.0/node_modules/undici/types/fetch.d.ts
|
|
4066
|
-
type BodyInit = ArrayBuffer | AsyncIterable<Uint8Array> | Blob | FormData | Iterable<Uint8Array> | NodeJS.ArrayBufferView | URLSearchParams$1 | null | string;
|
|
4067
|
-
interface SpecIterator<T, TReturn = any, TNext = undefined> {
|
|
4068
|
-
next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
|
|
4069
|
-
}
|
|
4070
|
-
interface SpecIteratorObject<T, TReturn = undefined, TNext = unknown> extends SpecIterator<T, TReturn, TNext> {
|
|
4071
|
-
[Symbol.iterator](): SpecIteratorObject<T, TReturn, TNext>;
|
|
4072
|
-
map<U>(callbackfn: (value: T, index: number) => U): SpecIteratorObject<U>;
|
|
4073
|
-
filter<S extends T>(predicate: (value: T, index: number) => value is S): SpecIteratorObject<S>;
|
|
4074
|
-
filter(predicate: (value: T, index: number) => unknown): SpecIteratorObject<T>;
|
|
4075
|
-
take(limit: number): SpecIteratorObject<T>;
|
|
4076
|
-
drop(count: number): SpecIteratorObject<T>;
|
|
4077
|
-
flatMap<U>(callbackfn: (value: T, index: number) => Iterator<U> | Iterable<U>): SpecIteratorObject<U>;
|
|
4078
|
-
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T): T;
|
|
4079
|
-
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number) => T, initialValue: T): T;
|
|
4080
|
-
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U;
|
|
4081
|
-
toArray(): T[];
|
|
4082
|
-
forEach(callbackfn: (value: T, index: number) => void): void;
|
|
4083
|
-
some(predicate: (value: T, index: number) => unknown): boolean;
|
|
4084
|
-
every(predicate: (value: T, index: number) => unknown): boolean;
|
|
4085
|
-
find<S extends T>(predicate: (value: T, index: number) => value is S): S | undefined;
|
|
4086
|
-
find(predicate: (value: T, index: number) => unknown): T | undefined;
|
|
4087
|
-
readonly [Symbol.toStringTag]: string;
|
|
4088
|
-
}
|
|
4089
|
-
interface SpecIterableIterator<T> extends SpecIteratorObject<T> {
|
|
4090
|
-
[Symbol.iterator](): SpecIterableIterator<T>;
|
|
4091
|
-
}
|
|
4092
|
-
interface SpecIterable<T> {
|
|
4093
|
-
[Symbol.iterator](): SpecIterableIterator<T>;
|
|
4094
|
-
}
|
|
4095
|
-
type HeadersInit = [string, string][] | HeaderRecord | Headers$1;
|
|
4096
|
-
declare class Headers$1 implements SpecIterable<[string, string]> {
|
|
4097
|
-
constructor(init?: HeadersInit);
|
|
4098
|
-
readonly append: (name: string, value: string) => void;
|
|
4099
|
-
readonly delete: (name: string) => void;
|
|
4100
|
-
readonly get: (name: string) => string | null;
|
|
4101
|
-
readonly has: (name: string) => boolean;
|
|
4102
|
-
readonly set: (name: string, value: string) => void;
|
|
4103
|
-
readonly getSetCookie: () => string[];
|
|
4104
|
-
readonly forEach: (callbackfn: (value: string, key: string, iterable: Headers$1) => void, thisArg?: unknown) => void;
|
|
4105
|
-
readonly keys: () => SpecIterableIterator<string>;
|
|
4106
|
-
readonly values: () => SpecIterableIterator<string>;
|
|
4107
|
-
readonly entries: () => SpecIterableIterator<[string, string]>;
|
|
4108
|
-
readonly [Symbol.iterator]: () => SpecIterableIterator<[string, string]>;
|
|
4109
|
-
}
|
|
4110
|
-
//#endregion
|
|
4111
|
-
//#region ../../node_modules/.pnpm/undici@8.7.0/node_modules/undici/types/formdata.d.ts
|
|
4112
|
-
/**
|
|
4113
|
-
* A `string` or `File` that represents a single value from a set of `FormData` key-value pairs.
|
|
4114
|
-
*/
|
|
4115
|
-
declare type FormDataEntryValue = string | File;
|
|
4116
|
-
/**
|
|
4117
|
-
* Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using fetch().
|
|
4118
|
-
*/
|
|
4119
|
-
declare class FormData {
|
|
4120
|
-
/**
|
|
4121
|
-
* Appends a new value onto an existing key inside a FormData object,
|
|
4122
|
-
* or adds the key if it does not already exist.
|
|
4123
|
-
*
|
|
4124
|
-
* The difference between `set()` and `append()` is that if the specified key already exists, `set()` will overwrite all existing values with the new one, whereas `append()` will append the new value onto the end of the existing set of values.
|
|
4125
|
-
*
|
|
4126
|
-
* @param name The name of the field whose data is contained in `value`.
|
|
4127
|
-
* @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
|
|
4128
|
-
or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
|
|
4129
|
-
* @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
|
|
4130
|
-
*/
|
|
4131
|
-
append(name: string, value: unknown, fileName?: string): void;
|
|
4132
|
-
/**
|
|
4133
|
-
* Set a new value for an existing key inside FormData,
|
|
4134
|
-
* or add the new field if it does not already exist.
|
|
4135
|
-
*
|
|
4136
|
-
* @param name The name of the field whose data is contained in `value`.
|
|
4137
|
-
* @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
|
|
4138
|
-
or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
|
|
4139
|
-
* @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
|
|
4140
|
-
*
|
|
4141
|
-
*/
|
|
4142
|
-
set(name: string, value: unknown, fileName?: string): void;
|
|
4143
|
-
/**
|
|
4144
|
-
* Returns the first value associated with a given key from within a `FormData` object.
|
|
4145
|
-
* If you expect multiple values and want all of them, use the `getAll()` method instead.
|
|
4146
|
-
*
|
|
4147
|
-
* @param {string} name A name of the value you want to retrieve.
|
|
4148
|
-
*
|
|
4149
|
-
* @returns A `FormDataEntryValue` containing the value. If the key doesn't exist, the method returns null.
|
|
4150
|
-
*/
|
|
4151
|
-
get(name: string): FormDataEntryValue | null;
|
|
4152
|
-
/**
|
|
4153
|
-
* Returns all the values associated with a given key from within a `FormData` object.
|
|
4154
|
-
*
|
|
4155
|
-
* @param {string} name A name of the value you want to retrieve.
|
|
4156
|
-
*
|
|
4157
|
-
* @returns An array of `FormDataEntryValue` whose key matches the value passed in the `name` parameter. If the key doesn't exist, the method returns an empty list.
|
|
4158
|
-
*/
|
|
4159
|
-
getAll(name: string): FormDataEntryValue[];
|
|
4160
|
-
/**
|
|
4161
|
-
* Returns a boolean stating whether a `FormData` object contains a certain key.
|
|
4162
|
-
*
|
|
4163
|
-
* @param name A string representing the name of the key you want to test for.
|
|
4164
|
-
*
|
|
4165
|
-
* @return A boolean value.
|
|
4166
|
-
*/
|
|
4167
|
-
has(name: string): boolean;
|
|
4168
|
-
/**
|
|
4169
|
-
* Deletes a key and its value(s) from a `FormData` object.
|
|
4170
|
-
*
|
|
4171
|
-
* @param name The name of the key you want to delete.
|
|
4172
|
-
*/
|
|
4173
|
-
delete(name: string): void;
|
|
4174
|
-
/**
|
|
4175
|
-
* Executes given callback function for each field of the FormData instance
|
|
4176
|
-
*/
|
|
4177
|
-
forEach: (callbackfn: (value: FormDataEntryValue, key: string, iterable: FormData) => void, thisArg?: unknown) => void;
|
|
4178
|
-
/**
|
|
4179
|
-
* Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all keys contained in this `FormData` object.
|
|
4180
|
-
* Each key is a `string`.
|
|
4181
|
-
*/
|
|
4182
|
-
keys: () => SpecIterableIterator<string>;
|
|
4183
|
-
/**
|
|
4184
|
-
* Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all values contained in this object `FormData` object.
|
|
4185
|
-
* Each value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
|
|
4186
|
-
*/
|
|
4187
|
-
values: () => SpecIterableIterator<FormDataEntryValue>;
|
|
4188
|
-
/**
|
|
4189
|
-
* Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through the `FormData` key/value pairs.
|
|
4190
|
-
* The key of each pair is a string; the value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
|
|
4191
|
-
*/
|
|
4192
|
-
entries: () => SpecIterableIterator<[string, FormDataEntryValue]>;
|
|
4193
|
-
/**
|
|
4194
|
-
* An alias for FormData#entries()
|
|
4195
|
-
*/
|
|
4196
|
-
[Symbol.iterator]: () => SpecIterableIterator<[string, FormDataEntryValue]>;
|
|
4197
|
-
readonly [Symbol.toStringTag]: string;
|
|
4198
|
-
}
|
|
4199
|
-
//#endregion
|
|
4200
|
-
//#region ../../node_modules/.pnpm/undici@8.7.0/node_modules/undici/types/connector.d.ts
|
|
4201
|
-
declare function buildConnector(options?: buildConnector.BuildOptions): buildConnector.connector;
|
|
4202
|
-
declare namespace buildConnector {
|
|
4203
|
-
export type BuildOptions = (ConnectionOptions | TcpNetConnectOpts | IpcNetConnectOpts) & {
|
|
4204
|
-
allowH2?: boolean;
|
|
4205
|
-
preferH2?: boolean;
|
|
4206
|
-
maxCachedSessions?: number | null;
|
|
4207
|
-
socketPath?: string | null;
|
|
4208
|
-
timeout?: number | null;
|
|
4209
|
-
port?: number;
|
|
4210
|
-
keepAlive?: boolean | null;
|
|
4211
|
-
keepAliveInitialDelay?: number | null;
|
|
4212
|
-
typeOfService?: number | null;
|
|
4213
|
-
};
|
|
4214
|
-
export interface Options {
|
|
4215
|
-
hostname: string;
|
|
4216
|
-
host?: string;
|
|
4217
|
-
protocol: string;
|
|
4218
|
-
port: string;
|
|
4219
|
-
servername?: string;
|
|
4220
|
-
localAddress?: string | null;
|
|
4221
|
-
socketPath?: string | null;
|
|
4222
|
-
httpSocket?: Socket;
|
|
4223
|
-
}
|
|
4224
|
-
export type Callback = (...args: CallbackArgs) => void;
|
|
4225
|
-
type CallbackArgs = [null, Socket | TLSSocket] | [Error, null];
|
|
4226
|
-
export interface connector {
|
|
4227
|
-
(options: buildConnector.Options, callback: buildConnector.Callback): void;
|
|
4228
|
-
}
|
|
4229
|
-
}
|
|
4230
|
-
//#endregion
|
|
4231
|
-
//#region ../../node_modules/.pnpm/undici@8.7.0/node_modules/undici/types/client-stats.d.ts
|
|
4232
|
-
declare class ClientStats {
|
|
4233
|
-
constructor(pool: Client);
|
|
4234
|
-
/** If socket has open connection. */
|
|
4235
|
-
connected: boolean;
|
|
4236
|
-
/** Number of open socket connections in this client that do not have an active request. */
|
|
4237
|
-
pending: number;
|
|
4238
|
-
/** Number of currently active requests of this client. */
|
|
4239
|
-
running: number;
|
|
4240
|
-
/** Number of active, pending, or queued requests of this client. */
|
|
4241
|
-
size: number;
|
|
4242
|
-
}
|
|
4243
|
-
//#endregion
|
|
4244
|
-
//#region ../../node_modules/.pnpm/undici@8.7.0/node_modules/undici/types/client.d.ts
|
|
4245
|
-
type ClientConnectOptions<TOpaque = null> = Omit<Dispatcher.ConnectOptions<TOpaque>, 'origin'>;
|
|
4246
|
-
/**
|
|
4247
|
-
* A basic HTTP/1.1 client, mapped on top a single TCP/TLS connection. Pipelining is disabled by default.
|
|
4248
|
-
*/
|
|
4249
|
-
declare class Client extends Dispatcher {
|
|
4250
|
-
constructor(url: string | URL, options?: Client.Options);
|
|
4251
|
-
/** Property to get and set the pipelining factor. */
|
|
4252
|
-
pipelining: number;
|
|
4253
|
-
/** `true` after `client.close()` has been called. */
|
|
4254
|
-
closed: boolean;
|
|
4255
|
-
/** `true` after `client.destroyed()` has been called or `client.close()` has been called and the client shutdown has completed. */
|
|
4256
|
-
destroyed: boolean;
|
|
4257
|
-
/** Aggregate stats for a Client. */
|
|
4258
|
-
readonly stats: ClientStats; // Override dispatcher APIs.
|
|
4259
|
-
override connect<TOpaque = null>(options: ClientConnectOptions<TOpaque>): Promise<Dispatcher.ConnectData<TOpaque>>;
|
|
4260
|
-
override connect<TOpaque = null>(options: ClientConnectOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ConnectData<TOpaque>) => void): void;
|
|
4261
|
-
}
|
|
4262
|
-
declare namespace Client {
|
|
4263
|
-
export interface Options {
|
|
4264
|
-
/** The maximum length of request headers in bytes. Default: Node.js' `--max-http-header-size` or `16384` (16KiB). */
|
|
4265
|
-
maxHeaderSize?: number;
|
|
4266
|
-
/** The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */
|
|
4267
|
-
headersTimeout?: number;
|
|
4268
|
-
/** @deprecated unsupported socketTimeout, use headersTimeout & bodyTimeout instead */
|
|
4269
|
-
socketTimeout?: never;
|
|
4270
|
-
/** @deprecated unsupported requestTimeout, use headersTimeout & bodyTimeout instead */
|
|
4271
|
-
requestTimeout?: never;
|
|
4272
|
-
/** The timeout for establishing a socket connection, in milliseconds. Use `0` to disable it entirely. Default: `10e3` milliseconds (10s). */
|
|
4273
|
-
connectTimeout?: number;
|
|
4274
|
-
/** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `300e3` milliseconds (300s). */
|
|
4275
|
-
bodyTimeout?: number;
|
|
4276
|
-
/** @deprecated unsupported idleTimeout, use keepAliveTimeout instead */
|
|
4277
|
-
idleTimeout?: never;
|
|
4278
|
-
/** @deprecated unsupported keepAlive, use pipelining=0 instead */
|
|
4279
|
-
keepAlive?: never;
|
|
4280
|
-
/** the timeout, in milliseconds, after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. Default: `4e3` milliseconds (4s). */
|
|
4281
|
-
keepAliveTimeout?: number;
|
|
4282
|
-
/** @deprecated unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead */
|
|
4283
|
-
maxKeepAliveTimeout?: never;
|
|
4284
|
-
/** the maximum allowed `idleTimeout`, in milliseconds, when overridden by *keep-alive* hints from the server. Default: `600e3` milliseconds (10min). */
|
|
4285
|
-
keepAliveMaxTimeout?: number;
|
|
4286
|
-
/** A number of milliseconds subtracted from server *keep-alive* hints when overriding `idleTimeout` to account for timing inaccuracies caused by e.g. transport latency. Default: `1e3` milliseconds (1s). */
|
|
4287
|
-
keepAliveTimeoutThreshold?: number;
|
|
4288
|
-
/** An IPC endpoint, either a Unix domain socket or Windows named pipe. Default: `null`. */
|
|
4289
|
-
socketPath?: string;
|
|
4290
|
-
/** The amount of concurrent requests to be sent over the single TCP/TLS connection according to [RFC7230](https://tools.ietf.org/html/rfc7230#section-6.3.2). Only enable values greater than `1` when the remote server is trusted. Default: `1`. */
|
|
4291
|
-
pipelining?: number;
|
|
4292
|
-
/** @deprecated use the connect option instead */
|
|
4293
|
-
tls?: never;
|
|
4294
|
-
/** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */
|
|
4295
|
-
strictContentLength?: boolean;
|
|
4296
|
-
/** Maximum number of TLS cached sessions used by the built-in connector. Use `0` to disable TLS session caching. Default: `100`. */
|
|
4297
|
-
maxCachedSessions?: number;
|
|
4298
|
-
/** Connector options passed to `buildConnector`, or a custom connector function. Default: `null`. */
|
|
4299
|
-
connect?: Partial<buildConnector.BuildOptions> | buildConnector.connector;
|
|
4300
|
-
/** The maximum number of requests to send over a single connection before it is reset. Use `0` to disable this limit. Default: `null`. */
|
|
4301
|
-
maxRequestsPerClient?: number;
|
|
4302
|
-
/** Local IP address the socket should connect from. */
|
|
4303
|
-
localAddress?: string;
|
|
4304
|
-
/** Max response body size in bytes, -1 is disabled */
|
|
4305
|
-
maxResponseSize?: number;
|
|
4306
|
-
/** WebSocket-specific options */
|
|
4307
|
-
webSocket?: Client.WebSocketOptions;
|
|
4308
|
-
/** Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. */
|
|
4309
|
-
autoSelectFamily?: boolean;
|
|
4310
|
-
/** The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. */
|
|
4311
|
-
autoSelectFamilyAttemptTimeout?: number;
|
|
4312
|
-
/**
|
|
4313
|
-
* @description Enables support for H2 if the server has assigned bigger priority to it through ALPN negotiation.
|
|
4314
|
-
* @default true
|
|
4315
|
-
*/
|
|
4316
|
-
allowH2?: boolean;
|
|
4317
|
-
/**
|
|
4318
|
-
* @description Dictates the maximum number of concurrent streams for a single H2 session. It can be overridden by a SETTINGS remote frame.
|
|
4319
|
-
* @default 100
|
|
4320
|
-
*/
|
|
4321
|
-
maxConcurrentStreams?: number;
|
|
4322
|
-
/**
|
|
4323
|
-
* @description Sets the HTTP/2 stream-level flow-control window size (SETTINGS_INITIAL_WINDOW_SIZE).
|
|
4324
|
-
* @default 262144
|
|
4325
|
-
*/
|
|
4326
|
-
initialWindowSize?: number;
|
|
4327
|
-
/**
|
|
4328
|
-
* @description Sets the HTTP/2 connection-level flow-control window size (ClientHttp2Session.setLocalWindowSize).
|
|
4329
|
-
* @default 524288
|
|
4330
|
-
*/
|
|
4331
|
-
connectionWindowSize?: number;
|
|
4332
|
-
/**
|
|
4333
|
-
* @description Time interval between PING frames dispatch
|
|
4334
|
-
* @default 60000
|
|
4335
|
-
*/
|
|
4336
|
-
pingInterval?: number;
|
|
4337
|
-
}
|
|
4338
|
-
export interface SocketInfo {
|
|
4339
|
-
localAddress?: string;
|
|
4340
|
-
localPort?: number;
|
|
4341
|
-
remoteAddress?: string;
|
|
4342
|
-
remotePort?: number;
|
|
4343
|
-
remoteFamily?: string;
|
|
4344
|
-
timeout?: number;
|
|
4345
|
-
bytesWritten?: number;
|
|
4346
|
-
bytesRead?: number;
|
|
4347
|
-
}
|
|
4348
|
-
export interface WebSocketOptions {
|
|
4349
|
-
/**
|
|
4350
|
-
* Maximum number of fragments in a message. Set to 0 to disable the limit.
|
|
4351
|
-
* @default 131072
|
|
4352
|
-
*/
|
|
4353
|
-
maxFragments?: number;
|
|
4354
|
-
/**
|
|
4355
|
-
* Maximum allowed payload size in bytes for WebSocket messages.
|
|
4356
|
-
* Applied to uncompressed messages, compressed frame payloads, and decompressed (permessage-deflate) messages.
|
|
4357
|
-
* Set to 0 to disable the limit.
|
|
4358
|
-
* @default 134217728 (128 MB)
|
|
4359
|
-
*/
|
|
4360
|
-
maxPayloadSize?: number;
|
|
4361
|
-
}
|
|
4362
|
-
}
|
|
4363
|
-
//#endregion
|
|
4364
|
-
//#region ../../node_modules/.pnpm/undici@8.7.0/node_modules/undici/types/errors.d.ts
|
|
4365
|
-
declare namespace Errors {
|
|
4366
|
-
export class UndiciError extends Error {
|
|
4367
|
-
name: string;
|
|
4368
|
-
code: string;
|
|
4369
|
-
}
|
|
4370
|
-
/** Connect timeout error. */
|
|
4371
|
-
export class ConnectTimeoutError extends UndiciError {
|
|
4372
|
-
name: 'ConnectTimeoutError';
|
|
4373
|
-
code: 'UND_ERR_CONNECT_TIMEOUT';
|
|
4374
|
-
}
|
|
4375
|
-
/** A header exceeds the `headersTimeout` option. */
|
|
4376
|
-
export class HeadersTimeoutError extends UndiciError {
|
|
4377
|
-
name: 'HeadersTimeoutError';
|
|
4378
|
-
code: 'UND_ERR_HEADERS_TIMEOUT';
|
|
4379
|
-
}
|
|
4380
|
-
/** Headers overflow error. */
|
|
4381
|
-
export class HeadersOverflowError extends UndiciError {
|
|
4382
|
-
name: 'HeadersOverflowError';
|
|
4383
|
-
code: 'UND_ERR_HEADERS_OVERFLOW';
|
|
4384
|
-
}
|
|
4385
|
-
/** A body exceeds the `bodyTimeout` option. */
|
|
4386
|
-
export class BodyTimeoutError extends UndiciError {
|
|
4387
|
-
name: 'BodyTimeoutError';
|
|
4388
|
-
code: 'UND_ERR_BODY_TIMEOUT';
|
|
4389
|
-
}
|
|
4390
|
-
export class ResponseError extends UndiciError {
|
|
4391
|
-
constructor(message: string, code: number, options: {
|
|
4392
|
-
headers?: IncomingHttpHeaders | string[] | null;
|
|
4393
|
-
body?: null | Record<string, any> | string;
|
|
4394
|
-
});
|
|
4395
|
-
name: 'ResponseError';
|
|
4396
|
-
code: 'UND_ERR_RESPONSE';
|
|
4397
|
-
statusCode: number;
|
|
4398
|
-
body: null | Record<string, any> | string;
|
|
4399
|
-
headers: IncomingHttpHeaders | string[] | null;
|
|
4400
|
-
}
|
|
4401
|
-
/** Passed an invalid argument. */
|
|
4402
|
-
export class InvalidArgumentError extends UndiciError {
|
|
4403
|
-
name: 'InvalidArgumentError';
|
|
4404
|
-
code: 'UND_ERR_INVALID_ARG';
|
|
4405
|
-
}
|
|
4406
|
-
/** Returned an invalid value. */
|
|
4407
|
-
export class InvalidReturnValueError extends UndiciError {
|
|
4408
|
-
name: 'InvalidReturnValueError';
|
|
4409
|
-
code: 'UND_ERR_INVALID_RETURN_VALUE';
|
|
4410
|
-
}
|
|
4411
|
-
/** The request has been aborted by the user. */
|
|
4412
|
-
export class RequestAbortedError extends UndiciError {
|
|
4413
|
-
name: 'AbortError';
|
|
4414
|
-
code: 'UND_ERR_ABORTED';
|
|
4415
|
-
}
|
|
4416
|
-
/** Expected error with reason. */
|
|
4417
|
-
export class InformationalError extends UndiciError {
|
|
4418
|
-
name: 'InformationalError';
|
|
4419
|
-
code: 'UND_ERR_INFO';
|
|
4420
|
-
}
|
|
4421
|
-
/** Request body length does not match content-length header. */
|
|
4422
|
-
export class RequestContentLengthMismatchError extends UndiciError {
|
|
4423
|
-
name: 'RequestContentLengthMismatchError';
|
|
4424
|
-
code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH';
|
|
4425
|
-
}
|
|
4426
|
-
/** Response body length does not match content-length header. */
|
|
4427
|
-
export class ResponseContentLengthMismatchError extends UndiciError {
|
|
4428
|
-
name: 'ResponseContentLengthMismatchError';
|
|
4429
|
-
code: 'UND_ERR_RES_CONTENT_LENGTH_MISMATCH';
|
|
4430
|
-
}
|
|
4431
|
-
/** Trying to use a destroyed client. */
|
|
4432
|
-
export class ClientDestroyedError extends UndiciError {
|
|
4433
|
-
name: 'ClientDestroyedError';
|
|
4434
|
-
code: 'UND_ERR_DESTROYED';
|
|
4435
|
-
}
|
|
4436
|
-
/** Trying to use a closed client. */
|
|
4437
|
-
export class ClientClosedError extends UndiciError {
|
|
4438
|
-
name: 'ClientClosedError';
|
|
4439
|
-
code: 'UND_ERR_CLOSED';
|
|
4440
|
-
}
|
|
4441
|
-
/** There is an error with the socket. */
|
|
4442
|
-
export class SocketError extends UndiciError {
|
|
4443
|
-
name: 'SocketError';
|
|
4444
|
-
code: 'UND_ERR_SOCKET';
|
|
4445
|
-
socket: Client.SocketInfo | null;
|
|
4446
|
-
}
|
|
4447
|
-
/** Encountered unsupported functionality. */
|
|
4448
|
-
export class NotSupportedError extends UndiciError {
|
|
4449
|
-
name: 'NotSupportedError';
|
|
4450
|
-
code: 'UND_ERR_NOT_SUPPORTED';
|
|
4451
|
-
}
|
|
4452
|
-
/** No upstream has been added to the BalancedPool. */
|
|
4453
|
-
export class BalancedPoolMissingUpstreamError extends UndiciError {
|
|
4454
|
-
name: 'MissingUpstreamError';
|
|
4455
|
-
code: 'UND_ERR_BPL_MISSING_UPSTREAM';
|
|
4456
|
-
}
|
|
4457
|
-
export class HTTPParserError extends UndiciError {
|
|
4458
|
-
name: 'HTTPParserError';
|
|
4459
|
-
code: string;
|
|
4460
|
-
}
|
|
4461
|
-
/** The response exceed the length allowed. */
|
|
4462
|
-
export class ResponseExceededMaxSizeError extends UndiciError {
|
|
4463
|
-
name: 'ResponseExceededMaxSizeError';
|
|
4464
|
-
code: 'UND_ERR_RES_EXCEEDED_MAX_SIZE';
|
|
4465
|
-
}
|
|
4466
|
-
export class RequestRetryError extends UndiciError {
|
|
4467
|
-
constructor(message: string, statusCode: number, headers?: IncomingHttpHeaders | string[] | null, body?: null | Record<string, any> | string);
|
|
4468
|
-
name: 'RequestRetryError';
|
|
4469
|
-
code: 'UND_ERR_REQ_RETRY';
|
|
4470
|
-
statusCode: number;
|
|
4471
|
-
data: {
|
|
4472
|
-
count: number;
|
|
4473
|
-
};
|
|
4474
|
-
headers: Record<string, string | string[]>;
|
|
4475
|
-
}
|
|
4476
|
-
export class SecureProxyConnectionError extends UndiciError {
|
|
4477
|
-
constructor(cause?: Error, message?: string, options?: Record<any, any>);
|
|
4478
|
-
name: 'SecureProxyConnectionError';
|
|
4479
|
-
code: 'UND_ERR_PRX_TLS';
|
|
4480
|
-
}
|
|
4481
|
-
export class ProxyConnectionError extends UndiciError {
|
|
4482
|
-
constructor(cause?: Error, message?: string, options?: Record<any, any>);
|
|
4483
|
-
name: 'ProxyConnectionError';
|
|
4484
|
-
code: 'UND_ERR_PRX_CONN';
|
|
4485
|
-
}
|
|
4486
|
-
export class MaxOriginsReachedError extends UndiciError {
|
|
4487
|
-
name: 'MaxOriginsReachedError';
|
|
4488
|
-
code: 'UND_ERR_MAX_ORIGINS_REACHED';
|
|
4489
|
-
}
|
|
4490
|
-
/** SOCKS5 proxy related error. */
|
|
4491
|
-
export class Socks5ProxyError extends UndiciError {
|
|
4492
|
-
constructor(message?: string, code?: string);
|
|
4493
|
-
name: 'Socks5ProxyError';
|
|
4494
|
-
code: string;
|
|
4495
|
-
}
|
|
4496
|
-
/** WebSocket decompressed message exceeded maximum size. */
|
|
4497
|
-
export class MessageSizeExceededError extends UndiciError {
|
|
4498
|
-
name: 'MessageSizeExceededError';
|
|
4499
|
-
code: 'UND_ERR_WS_MESSAGE_SIZE_EXCEEDED';
|
|
4500
|
-
}
|
|
4501
|
-
}
|
|
4502
|
-
//#endregion
|
|
4503
|
-
//#region ../../node_modules/.pnpm/undici@8.7.0/node_modules/undici/types/dispatcher.d.ts
|
|
4504
|
-
type UndiciHeaders = OutgoingHttpHeaders | string[] | Iterable<[string, string | string[] | undefined]> | null;
|
|
4505
|
-
/** Dispatcher is the core API used to dispatch requests. */
|
|
4506
|
-
declare class Dispatcher extends EventEmitter {
|
|
4507
|
-
/** Dispatches a request. This API is expected to evolve through semver-major versions and is less stable than the preceding higher level APIs. It is primarily intended for library developers who implement higher level APIs on top of this. */
|
|
4508
|
-
dispatch(options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean;
|
|
4509
|
-
/** Starts two-way communications with the requested resource. */
|
|
4510
|
-
connect<TOpaque = null>(options: Dispatcher.ConnectOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ConnectData<TOpaque>) => void): void;
|
|
4511
|
-
connect<TOpaque = null>(options: Dispatcher.ConnectOptions<TOpaque>): Promise<Dispatcher.ConnectData<TOpaque>>;
|
|
4512
|
-
/** Compose a chain of dispatchers */
|
|
4513
|
-
compose(dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher;
|
|
4514
|
-
compose(...dispatchers: Dispatcher.DispatcherComposeInterceptor[]): Dispatcher.ComposedDispatcher;
|
|
4515
|
-
/** Performs an HTTP request. */
|
|
4516
|
-
request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ResponseData<TOpaque>) => void): void;
|
|
4517
|
-
request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>): Promise<Dispatcher.ResponseData<TOpaque>>;
|
|
4518
|
-
/** For easy use with `stream.pipeline`. */
|
|
4519
|
-
pipeline<TOpaque = null>(options: Dispatcher.PipelineOptions<TOpaque>, handler: Dispatcher.PipelineHandler<TOpaque>): Duplex;
|
|
4520
|
-
/** A faster version of `Dispatcher.request`. */
|
|
4521
|
-
stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>, callback: (err: Error | null, data: Dispatcher.StreamData<TOpaque>) => void): void;
|
|
4522
|
-
stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>): Promise<Dispatcher.StreamData<TOpaque>>;
|
|
4523
|
-
/** Upgrade to a different protocol. */
|
|
4524
|
-
upgrade(options: Dispatcher.UpgradeOptions, callback: (err: Error | null, data: Dispatcher.UpgradeData) => void): void;
|
|
4525
|
-
upgrade(options: Dispatcher.UpgradeOptions): Promise<Dispatcher.UpgradeData>;
|
|
4526
|
-
/** Closes the client and gracefully waits for enqueued requests to complete before invoking the callback (or returning a promise if no callback is provided). */
|
|
4527
|
-
close(callback: () => void): void;
|
|
4528
|
-
close(): Promise<void>;
|
|
4529
|
-
/** Destroy the client abruptly with the given err. All the pending and running requests will be asynchronously aborted and error. Waits until socket is closed before invoking the callback (or returning a promise if no callback is provided). Since this operation is asynchronously dispatched there might still be some progress on dispatched requests. */
|
|
4530
|
-
destroy(err: Error | null, callback: () => void): void;
|
|
4531
|
-
destroy(callback: () => void): void;
|
|
4532
|
-
destroy(err: Error | null): Promise<void>;
|
|
4533
|
-
destroy(): Promise<void>;
|
|
4534
|
-
on(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
|
|
4535
|
-
on(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
4536
|
-
on(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
4537
|
-
on(eventName: 'drain', callback: (origin: URL) => void): this;
|
|
4538
|
-
once(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
|
|
4539
|
-
once(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
4540
|
-
once(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
4541
|
-
once(eventName: 'drain', callback: (origin: URL) => void): this;
|
|
4542
|
-
off(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
|
|
4543
|
-
off(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
4544
|
-
off(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
4545
|
-
off(eventName: 'drain', callback: (origin: URL) => void): this;
|
|
4546
|
-
addListener(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
|
|
4547
|
-
addListener(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
4548
|
-
addListener(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
4549
|
-
addListener(eventName: 'drain', callback: (origin: URL) => void): this;
|
|
4550
|
-
removeListener(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
|
|
4551
|
-
removeListener(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
4552
|
-
removeListener(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
4553
|
-
removeListener(eventName: 'drain', callback: (origin: URL) => void): this;
|
|
4554
|
-
prependListener(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
|
|
4555
|
-
prependListener(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
4556
|
-
prependListener(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
4557
|
-
prependListener(eventName: 'drain', callback: (origin: URL) => void): this;
|
|
4558
|
-
prependOnceListener(eventName: 'connect', callback: (origin: URL, targets: readonly Dispatcher[]) => void): this;
|
|
4559
|
-
prependOnceListener(eventName: 'disconnect', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
4560
|
-
prependOnceListener(eventName: 'connectionError', callback: (origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void): this;
|
|
4561
|
-
prependOnceListener(eventName: 'drain', callback: (origin: URL) => void): this;
|
|
4562
|
-
listeners(eventName: 'connect'): ((origin: URL, targets: readonly Dispatcher[]) => void)[];
|
|
4563
|
-
listeners(eventName: 'disconnect'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
|
|
4564
|
-
listeners(eventName: 'connectionError'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
|
|
4565
|
-
listeners(eventName: 'drain'): ((origin: URL) => void)[];
|
|
4566
|
-
rawListeners(eventName: 'connect'): ((origin: URL, targets: readonly Dispatcher[]) => void)[];
|
|
4567
|
-
rawListeners(eventName: 'disconnect'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
|
|
4568
|
-
rawListeners(eventName: 'connectionError'): ((origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError) => void)[];
|
|
4569
|
-
rawListeners(eventName: 'drain'): ((origin: URL) => void)[];
|
|
4570
|
-
emit(eventName: 'connect', origin: URL, targets: readonly Dispatcher[]): boolean;
|
|
4571
|
-
emit(eventName: 'disconnect', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
|
|
4572
|
-
emit(eventName: 'connectionError', origin: URL, targets: readonly Dispatcher[], error: Errors.UndiciError): boolean;
|
|
4573
|
-
emit(eventName: 'drain', origin: URL): boolean;
|
|
4574
|
-
}
|
|
4575
|
-
declare namespace Dispatcher {
|
|
4576
|
-
export interface ComposedDispatcher extends Dispatcher {}
|
|
4577
|
-
export type Dispatch = Dispatcher['dispatch'];
|
|
4578
|
-
export type DispatcherComposeInterceptor = (dispatch: Dispatch) => Dispatch;
|
|
4579
|
-
export interface DispatchOptions {
|
|
4580
|
-
origin?: string | URL;
|
|
4581
|
-
path: string;
|
|
4582
|
-
method: HttpMethod;
|
|
4583
|
-
/** Default: `null` */
|
|
4584
|
-
body?: string | Buffer | Uint8Array | Readable | null | FormData;
|
|
4585
|
-
/** Default: `null` */
|
|
4586
|
-
headers?: UndiciHeaders;
|
|
4587
|
-
/** Query string params to be embedded in the request URL. Default: `null` */
|
|
4588
|
-
query?: Record<string, any>;
|
|
4589
|
-
/** Whether the requests can be safely retried or not. If `false` the request won't be sent until all preceding requests in the pipeline have completed. Default: `true` if `method` is `HEAD` or `GET`. */
|
|
4590
|
-
idempotent?: boolean;
|
|
4591
|
-
/** Whether the response is expected to take a long time and would end up blocking the pipeline. When this is set to `true` further pipelining will be avoided on the same connection until headers have been received. Defaults to `method !== 'HEAD'`. */
|
|
4592
|
-
blocking?: boolean;
|
|
4593
|
-
/** The IP Type of Service (ToS) value for the request socket. Must be an integer between 0 and 255. Default: `0` */
|
|
4594
|
-
typeOfService?: number | null;
|
|
4595
|
-
/** Upgrade the request. Should be used to specify the kind of upgrade i.e. `'Websocket'`. Default: `method === 'CONNECT' || null`. */
|
|
4596
|
-
upgrade?: boolean | string | null;
|
|
4597
|
-
/** The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers. Defaults to 300 seconds. */
|
|
4598
|
-
headersTimeout?: number | null;
|
|
4599
|
-
/** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use 0 to disable it entirely. Defaults to 300 seconds. */
|
|
4600
|
-
bodyTimeout?: number | null;
|
|
4601
|
-
/** Whether the request should stablish a keep-alive or not. Default `false` */
|
|
4602
|
-
reset?: boolean;
|
|
4603
|
-
/** For H2, it appends the expect: 100-continue header, and halts the request body until a 100-continue is received from the remote server */
|
|
4604
|
-
expectContinue?: boolean;
|
|
4605
|
-
}
|
|
4606
|
-
export interface ConnectOptions<TOpaque = null> {
|
|
4607
|
-
origin: string | URL;
|
|
4608
|
-
path: string;
|
|
4609
|
-
/** Default: `null` */
|
|
4610
|
-
headers?: UndiciHeaders;
|
|
4611
|
-
/** Default: `null` */
|
|
4612
|
-
signal?: AbortSignal | EventEmitter | null;
|
|
4613
|
-
/** This argument parameter is passed through to `ConnectData` */
|
|
4614
|
-
opaque?: TOpaque;
|
|
4615
|
-
/** Default: `null` */
|
|
4616
|
-
responseHeaders?: 'raw' | null;
|
|
4617
|
-
}
|
|
4618
|
-
export interface RequestOptions<TOpaque = null> extends DispatchOptions {
|
|
4619
|
-
/** Default: `null` */
|
|
4620
|
-
opaque?: TOpaque;
|
|
4621
|
-
/** Default: `null` */
|
|
4622
|
-
signal?: AbortSignal | EventEmitter | null;
|
|
4623
|
-
/** Default: `null` */
|
|
4624
|
-
onInfo?: (info: {
|
|
4625
|
-
statusCode: number;
|
|
4626
|
-
headers: Record<string, string | string[]>;
|
|
4627
|
-
}) => void;
|
|
4628
|
-
/** Default: `null` */
|
|
4629
|
-
responseHeaders?: 'raw' | null;
|
|
4630
|
-
/** Default: `64 KiB` */
|
|
4631
|
-
highWaterMark?: number;
|
|
4632
|
-
}
|
|
4633
|
-
export interface PipelineOptions<TOpaque = null> extends RequestOptions<TOpaque> {
|
|
4634
|
-
/** `true` if the `handler` will return an object stream. Default: `false` */
|
|
4635
|
-
objectMode?: boolean;
|
|
4636
|
-
}
|
|
4637
|
-
export interface UpgradeOptions {
|
|
4638
|
-
path: string;
|
|
4639
|
-
/** Default: `'GET'` */
|
|
4640
|
-
method?: string;
|
|
4641
|
-
/** Default: `null` */
|
|
4642
|
-
headers?: UndiciHeaders;
|
|
4643
|
-
/** A string of comma separated protocols, in descending preference order. Default: `'Websocket'` */
|
|
4644
|
-
protocol?: string;
|
|
4645
|
-
/** Default: `null` */
|
|
4646
|
-
signal?: AbortSignal | EventEmitter | null;
|
|
4647
|
-
/** Default: `null` */
|
|
4648
|
-
responseHeaders?: 'raw' | null;
|
|
4649
|
-
}
|
|
4650
|
-
export interface ConnectData<TOpaque = null> {
|
|
4651
|
-
statusCode: number;
|
|
4652
|
-
headers: IncomingHttpHeaders;
|
|
4653
|
-
socket: Duplex;
|
|
4654
|
-
opaque: TOpaque;
|
|
4655
|
-
}
|
|
4656
|
-
export interface ResponseData<TOpaque = null> {
|
|
4657
|
-
statusCode: number;
|
|
4658
|
-
statusText: string;
|
|
4659
|
-
headers: IncomingHttpHeaders;
|
|
4660
|
-
body: BodyReadable & BodyMixin;
|
|
4661
|
-
trailers: Record<string, string>;
|
|
4662
|
-
opaque: TOpaque;
|
|
4663
|
-
context: object;
|
|
4664
|
-
}
|
|
4665
|
-
export interface PipelineHandlerData<TOpaque = null> {
|
|
4666
|
-
statusCode: number;
|
|
4667
|
-
headers: IncomingHttpHeaders;
|
|
4668
|
-
opaque: TOpaque;
|
|
4669
|
-
body: BodyReadable;
|
|
4670
|
-
context: object;
|
|
4671
|
-
}
|
|
4672
|
-
export interface StreamData<TOpaque = null> {
|
|
4673
|
-
opaque: TOpaque;
|
|
4674
|
-
trailers: Record<string, string>;
|
|
4675
|
-
}
|
|
4676
|
-
export interface UpgradeData<TOpaque = null> {
|
|
4677
|
-
headers: IncomingHttpHeaders;
|
|
4678
|
-
socket: Duplex;
|
|
4679
|
-
opaque: TOpaque;
|
|
4680
|
-
}
|
|
4681
|
-
export interface StreamFactoryData<TOpaque = null> {
|
|
4682
|
-
statusCode: number;
|
|
4683
|
-
headers: IncomingHttpHeaders;
|
|
4684
|
-
opaque: TOpaque;
|
|
4685
|
-
context: object;
|
|
4686
|
-
}
|
|
4687
|
-
export type StreamFactory<TOpaque = null> = (data: StreamFactoryData<TOpaque>) => Writable;
|
|
4688
|
-
export interface DispatchController {
|
|
4689
|
-
get aborted(): boolean;
|
|
4690
|
-
get paused(): boolean;
|
|
4691
|
-
get reason(): Error | null;
|
|
4692
|
-
rawHeaders?: Buffer[] | string[] | IncomingHttpHeaders | null;
|
|
4693
|
-
rawTrailers?: Buffer[] | string[] | IncomingHttpHeaders | null;
|
|
4694
|
-
abort(reason: Error): void;
|
|
4695
|
-
pause(): void;
|
|
4696
|
-
resume(): void;
|
|
4697
|
-
}
|
|
4698
|
-
export interface DispatchHandler {
|
|
4699
|
-
onRequestStart?(controller: DispatchController, context: any): void;
|
|
4700
|
-
onRequestUpgrade?(controller: DispatchController, statusCode: number, headers: IncomingHttpHeaders, socket: Duplex): void;
|
|
4701
|
-
onResponseStart?(controller: DispatchController, statusCode: number, headers: IncomingHttpHeaders, statusMessage?: string): void;
|
|
4702
|
-
onResponseData?(controller: DispatchController, chunk: Buffer): void;
|
|
4703
|
-
onResponseEnd?(controller: DispatchController, trailers: IncomingHttpHeaders): void;
|
|
4704
|
-
onResponseError?(controller: DispatchController, error: Error): void;
|
|
4705
|
-
/** Invoked when response is received, before headers have been read. **/
|
|
4706
|
-
onResponseStarted?(): void;
|
|
4707
|
-
/** Invoked when a body chunk is sent to the server. May be invoked multiple times for chunked requests */
|
|
4708
|
-
onBodySent?(chunk: Buffer): void;
|
|
4709
|
-
/** Invoked after the request body is fully sent. */
|
|
4710
|
-
onRequestSent?(): void;
|
|
4711
|
-
}
|
|
4712
|
-
export type PipelineHandler<TOpaque = null> = (data: PipelineHandlerData<TOpaque>) => Readable;
|
|
4713
|
-
export type HttpMethod = Autocomplete<'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH'>;
|
|
4714
|
-
/**
|
|
4715
|
-
* @link https://fetch.spec.whatwg.org/#body-mixin
|
|
4716
|
-
*/
|
|
4717
|
-
interface BodyMixin {
|
|
4718
|
-
readonly body?: never;
|
|
4719
|
-
readonly bodyUsed: boolean;
|
|
4720
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
4721
|
-
blob(): Promise<Blob>;
|
|
4722
|
-
bytes(): Promise<Uint8Array>;
|
|
4723
|
-
formData(): Promise<never>;
|
|
4724
|
-
json(): Promise<unknown>;
|
|
4725
|
-
text(): Promise<string>;
|
|
4726
|
-
}
|
|
4727
|
-
export interface DispatchInterceptor {
|
|
4728
|
-
(dispatch: Dispatch): Dispatch;
|
|
4729
|
-
}
|
|
4730
|
-
}
|
|
4731
|
-
//#endregion
|
|
4732
|
-
//#region ../../node_modules/.pnpm/undici@8.7.0/node_modules/undici/types/mock-interceptor.d.ts
|
|
4733
|
-
/** The scope associated with a mock dispatch. */
|
|
4734
|
-
declare class MockScope<TData extends object = object> {
|
|
4735
|
-
constructor(mockDispatch: MockInterceptor.MockDispatch<TData>);
|
|
4736
|
-
/** Delay a reply by a set amount of time in ms. */
|
|
4737
|
-
delay(waitInMs: number): MockScope<TData>;
|
|
4738
|
-
/** Persist the defined mock data for the associated reply. It will return the defined mock data indefinitely. */
|
|
4739
|
-
persist(): MockScope<TData>;
|
|
4740
|
-
/** Define a reply for a set amount of matching requests. */
|
|
4741
|
-
times(repeatTimes: number): MockScope<TData>;
|
|
4742
|
-
}
|
|
4743
|
-
/** The interceptor for a Mock. */
|
|
4744
|
-
declare class MockInterceptor {
|
|
4745
|
-
constructor(options: MockInterceptor.Options, mockDispatches: MockInterceptor.MockDispatch[]);
|
|
4746
|
-
/** Mock an undici request with the defined reply. */
|
|
4747
|
-
reply<TData extends object = object>(replyOptionsCallback: MockInterceptor.MockReplyOptionsCallback<TData>): MockScope<TData>;
|
|
4748
|
-
reply<TData extends object = object>(statusCode: number, data?: TData | Buffer | string | MockInterceptor.MockResponseDataHandler<TData>, responseOptions?: MockInterceptor.MockResponseOptions): MockScope<TData>;
|
|
4749
|
-
/** Mock an undici request by throwing the defined reply error. */
|
|
4750
|
-
replyWithError<TError extends Error = Error>(error: TError): MockScope;
|
|
4751
|
-
/** Set default reply headers on the interceptor for subsequent mocked replies. */
|
|
4752
|
-
defaultReplyHeaders(headers: IncomingHttpHeaders): MockInterceptor;
|
|
4753
|
-
/** Set default reply trailers on the interceptor for subsequent mocked replies. */
|
|
4754
|
-
defaultReplyTrailers(trailers: Record<string, string>): MockInterceptor;
|
|
4755
|
-
/** Set automatically calculated content-length header on subsequent mocked replies. */
|
|
4756
|
-
replyContentLength(): MockInterceptor;
|
|
4757
|
-
}
|
|
4758
|
-
declare namespace MockInterceptor {
|
|
4759
|
-
/** MockInterceptor options. */
|
|
4760
|
-
export interface Options {
|
|
4761
|
-
/** Path to intercept on. */
|
|
4762
|
-
path: string | RegExp | ((path: string) => boolean);
|
|
4763
|
-
/** Method to intercept on. Defaults to GET. */
|
|
4764
|
-
method?: string | RegExp | ((method: string) => boolean);
|
|
4765
|
-
/** Body to intercept on. */
|
|
4766
|
-
body?: string | RegExp | ((body: string) => boolean);
|
|
4767
|
-
/** Headers to intercept on. */
|
|
4768
|
-
headers?: Record<string, string | RegExp | ((body: string) => boolean)> | ((headers: Record<string, string>) => boolean);
|
|
4769
|
-
/** Query params to intercept on */
|
|
4770
|
-
query?: Record<string, any>;
|
|
4771
|
-
}
|
|
4772
|
-
export interface MockDispatch<TData extends object = object, TError extends Error = Error> extends Options {
|
|
4773
|
-
times: number | null;
|
|
4774
|
-
persist: boolean;
|
|
4775
|
-
consumed: boolean;
|
|
4776
|
-
data: MockDispatchData<TData, TError>;
|
|
4777
|
-
}
|
|
4778
|
-
export interface MockDispatchData<TData extends object = object, TError extends Error = Error> extends MockResponseOptions {
|
|
4779
|
-
error: TError | null;
|
|
4780
|
-
statusCode?: number;
|
|
4781
|
-
data?: TData | string;
|
|
4782
|
-
}
|
|
4783
|
-
export interface MockResponseOptions {
|
|
4784
|
-
headers?: IncomingHttpHeaders;
|
|
4785
|
-
trailers?: Record<string, string>;
|
|
4786
|
-
}
|
|
4787
|
-
export interface MockResponseCallbackOptions {
|
|
4788
|
-
path: string;
|
|
4789
|
-
method: string;
|
|
4790
|
-
headers?: Headers$1 | Record<string, string>;
|
|
4791
|
-
origin?: string;
|
|
4792
|
-
body?: BodyInit | Dispatcher.DispatchOptions['body'] | null;
|
|
4793
|
-
}
|
|
4794
|
-
export type MockResponseDataHandler<TData extends object = object> = (opts: MockResponseCallbackOptions) => TData | Buffer | string;
|
|
4795
|
-
export type MockReplyOptionsCallback<TData extends object = object> = (opts: MockResponseCallbackOptions) => {
|
|
4796
|
-
statusCode: number;
|
|
4797
|
-
data?: TData | Buffer | string;
|
|
4798
|
-
responseOptions?: MockResponseOptions;
|
|
4799
|
-
};
|
|
4800
|
-
}
|
|
4801
|
-
//#endregion
|
|
4802
3207
|
//#region src/i18n-registry.d.ts
|
|
4803
3208
|
/** 单条 i18n 贡献条目(loader 产出,供 `register()` 消费)。 */
|
|
4804
3209
|
interface PluginI18nEntry {
|