@armadra/agent 0.0.0-stage → 0.2.1
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/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/README.md +426 -2
- package/dist/agent/agent.d.ts +56 -0
- package/dist/agent/agent.js +129 -0
- package/dist/agent/loop.d.ts +51 -0
- package/dist/agent/loop.js +158 -0
- package/dist/agent/queue.d.ts +25 -0
- package/dist/agent/queue.js +55 -0
- package/dist/agent/retry.d.ts +22 -0
- package/dist/agent/retry.js +92 -0
- package/dist/agent/schema.d.ts +27 -0
- package/dist/agent/schema.js +186 -0
- package/dist/agent/session-cache.d.ts +100 -0
- package/dist/agent/session-cache.js +511 -0
- package/dist/agent/session-compaction.d.ts +49 -0
- package/dist/agent/session-compaction.js +251 -0
- package/dist/agent/session-core.d.ts +103 -0
- package/dist/agent/session-core.js +7 -0
- package/dist/agent/session-run.d.ts +55 -0
- package/dist/agent/session-run.js +246 -0
- package/dist/agent/session-state.d.ts +39 -0
- package/dist/agent/session-state.js +118 -0
- package/dist/agent/session-subagent.d.ts +54 -0
- package/dist/agent/session-subagent.js +157 -0
- package/dist/agent/session-sync.d.ts +20 -0
- package/dist/agent/session-sync.js +104 -0
- package/dist/agent/session-tools.d.ts +24 -0
- package/dist/agent/session-tools.js +277 -0
- package/dist/agent/session.d.ts +117 -0
- package/dist/agent/session.js +484 -0
- package/dist/agent/system-prompt.d.ts +49 -0
- package/dist/agent/system-prompt.js +121 -0
- package/dist/agent/tool-runner.d.ts +64 -0
- package/dist/agent/tool-runner.js +309 -0
- package/dist/agent/transform.d.ts +26 -0
- package/dist/agent/transform.js +171 -0
- package/dist/agent/types.d.ts +378 -0
- package/dist/agent/types.js +21 -0
- package/dist/ai/apis/anthropic-messages.d.ts +26 -0
- package/dist/ai/apis/anthropic-messages.js +214 -0
- package/dist/ai/apis/anthropic-request.d.ts +42 -0
- package/dist/ai/apis/anthropic-request.js +282 -0
- package/dist/ai/apis/api.d.ts +28 -0
- package/dist/ai/apis/api.js +102 -0
- package/dist/ai/apis/cache-params.d.ts +48 -0
- package/dist/ai/apis/cache-params.js +163 -0
- package/dist/ai/apis/google-generative-ai.d.ts +32 -0
- package/dist/ai/apis/google-generative-ai.js +249 -0
- package/dist/ai/apis/google-request.d.ts +40 -0
- package/dist/ai/apis/google-request.js +255 -0
- package/dist/ai/apis/openai-compat.d.ts +35 -0
- package/dist/ai/apis/openai-compat.js +142 -0
- package/dist/ai/apis/openai-completions.d.ts +28 -0
- package/dist/ai/apis/openai-completions.js +246 -0
- package/dist/ai/apis/openai-request.d.ts +35 -0
- package/dist/ai/apis/openai-request.js +303 -0
- package/dist/ai/apis/openai-responses-request.d.ts +52 -0
- package/dist/ai/apis/openai-responses-request.js +266 -0
- package/dist/ai/apis/openai-responses.d.ts +28 -0
- package/dist/ai/apis/openai-responses.js +303 -0
- package/dist/ai/apis/shared.d.ts +56 -0
- package/dist/ai/apis/shared.js +179 -0
- package/dist/ai/cache/economics.d.ts +24 -0
- package/dist/ai/cache/economics.js +69 -0
- package/dist/ai/cache/fingerprint.d.ts +17 -0
- package/dist/ai/cache/fingerprint.js +39 -0
- package/dist/ai/cache/miss.d.ts +49 -0
- package/dist/ai/cache/miss.js +96 -0
- package/dist/ai/cache/reporting.d.ts +39 -0
- package/dist/ai/cache/reporting.js +102 -0
- package/dist/ai/cache/types.d.ts +94 -0
- package/dist/ai/cache/types.js +19 -0
- package/dist/ai/cache/warmer.d.ts +94 -0
- package/dist/ai/cache/warmer.js +224 -0
- package/dist/ai/context.d.ts +35 -0
- package/dist/ai/context.js +114 -0
- package/dist/ai/cost.d.ts +21 -0
- package/dist/ai/cost.js +60 -0
- package/dist/ai/event-stream.d.ts +33 -0
- package/dist/ai/event-stream.js +101 -0
- package/dist/ai/fake/fake-provider.d.ts +68 -0
- package/dist/ai/fake/fake-provider.js +278 -0
- package/dist/ai/fake/fake-script.d.ts +69 -0
- package/dist/ai/fake/fake-script.js +142 -0
- package/dist/ai/http.d.ts +54 -0
- package/dist/ai/http.js +212 -0
- package/dist/ai/json-partial.d.ts +17 -0
- package/dist/ai/json-partial.js +243 -0
- package/dist/ai/overflow.d.ts +22 -0
- package/dist/ai/overflow.js +61 -0
- package/dist/ai/providers/auth.d.ts +71 -0
- package/dist/ai/providers/auth.js +202 -0
- package/dist/ai/providers/builtin.d.ts +23 -0
- package/dist/ai/providers/builtin.js +148 -0
- package/dist/ai/providers/catalog-data.d.ts +5 -0
- package/dist/ai/providers/catalog-data.js +19 -0
- package/dist/ai/providers/catalog.d.ts +28 -0
- package/dist/ai/providers/catalog.js +166 -0
- package/dist/ai/providers/registry.d.ts +83 -0
- package/dist/ai/providers/registry.js +305 -0
- package/dist/ai/sse.d.ts +32 -0
- package/dist/ai/sse.js +140 -0
- package/dist/ai/thinking.d.ts +42 -0
- package/dist/ai/thinking.js +101 -0
- package/dist/ai/types.d.ts +428 -0
- package/dist/ai/types.js +19 -0
- package/dist/bundle/ama-sandbox.cjs +324 -0
- package/dist/bundle/ama.cjs +25770 -0
- package/dist/bundle.d.ts +9 -0
- package/dist/bundle.js +15 -0
- package/dist/cli/args.d.ts +82 -0
- package/dist/cli/args.js +381 -0
- package/dist/cli/bootstrap.d.ts +18 -0
- package/dist/cli/bootstrap.js +398 -0
- package/dist/cli/compose-providers.d.ts +37 -0
- package/dist/cli/compose-providers.js +104 -0
- package/dist/cli/compose-session.d.ts +69 -0
- package/dist/cli/compose-session.js +370 -0
- package/dist/cli/compose-store.d.ts +24 -0
- package/dist/cli/compose-store.js +125 -0
- package/dist/cli/compose.d.ts +106 -0
- package/dist/cli/compose.js +206 -0
- package/dist/cli/default-model.d.ts +16 -0
- package/dist/cli/default-model.js +24 -0
- package/dist/cli/deps.d.ts +205 -0
- package/dist/cli/deps.js +12 -0
- package/dist/cli/exit-codes.d.ts +29 -0
- package/dist/cli/exit-codes.js +40 -0
- package/dist/cli/main.d.ts +26 -0
- package/dist/cli/main.js +165 -0
- package/dist/cli/runtime.d.ts +90 -0
- package/dist/cli/runtime.js +8 -0
- package/dist/cli/startup-screen.d.ts +15 -0
- package/dist/cli/startup-screen.js +56 -0
- package/dist/cli/startup-steps.d.ts +35 -0
- package/dist/cli/startup-steps.js +197 -0
- package/dist/cli/subcommands/auth.d.ts +12 -0
- package/dist/cli/subcommands/auth.js +91 -0
- package/dist/cli/subcommands/config.d.ts +44 -0
- package/dist/cli/subcommands/config.js +201 -0
- package/dist/cli/subcommands/context.d.ts +21 -0
- package/dist/cli/subcommands/context.js +41 -0
- package/dist/cli/subcommands/doctor.d.ts +11 -0
- package/dist/cli/subcommands/doctor.js +246 -0
- package/dist/cli/subcommands/models-cache-probe.d.ts +34 -0
- package/dist/cli/subcommands/models-cache-probe.js +190 -0
- package/dist/cli/subcommands/models-discover.d.ts +40 -0
- package/dist/cli/subcommands/models-discover.js +204 -0
- package/dist/cli/subcommands/models.d.ts +40 -0
- package/dist/cli/subcommands/models.js +144 -0
- package/dist/cli/subcommands/sessions.d.ts +11 -0
- package/dist/cli/subcommands/sessions.js +100 -0
- package/dist/codemode/capability.d.ts +37 -0
- package/dist/codemode/capability.js +55 -0
- package/dist/codemode/declarations.d.ts +44 -0
- package/dist/codemode/declarations.js +111 -0
- package/dist/codemode/host-side.d.ts +59 -0
- package/dist/codemode/host-side.js +253 -0
- package/dist/codemode/modes.d.ts +23 -0
- package/dist/codemode/modes.js +40 -0
- package/dist/codemode/protocol.d.ts +91 -0
- package/dist/codemode/protocol.js +114 -0
- package/dist/codemode/sandbox-entry.d.ts +25 -0
- package/dist/codemode/sandbox-entry.js +323 -0
- package/dist/codemode/store.d.ts +26 -0
- package/dist/codemode/store.js +53 -0
- package/dist/codemode/tool.d.ts +105 -0
- package/dist/codemode/tool.js +283 -0
- package/dist/compaction/branch-summary.d.ts +30 -0
- package/dist/compaction/branch-summary.js +79 -0
- package/dist/compaction/breaker.d.ts +32 -0
- package/dist/compaction/breaker.js +65 -0
- package/dist/compaction/cut-point.d.ts +23 -0
- package/dist/compaction/cut-point.js +70 -0
- package/dist/compaction/estimate.d.ts +30 -0
- package/dist/compaction/estimate.js +114 -0
- package/dist/compaction/prune-tier.d.ts +31 -0
- package/dist/compaction/prune-tier.js +83 -0
- package/dist/compaction/serialize.d.ts +20 -0
- package/dist/compaction/serialize.js +115 -0
- package/dist/compaction/summarize-tier.d.ts +111 -0
- package/dist/compaction/summarize-tier.js +305 -0
- package/dist/config/auth-file.d.ts +39 -0
- package/dist/config/auth-file.js +92 -0
- package/dist/config/context-files.d.ts +30 -0
- package/dist/config/context-files.js +77 -0
- package/dist/config/load.d.ts +45 -0
- package/dist/config/load.js +97 -0
- package/dist/config/merge.d.ts +73 -0
- package/dist/config/merge.js +248 -0
- package/dist/config/paths.d.ts +38 -0
- package/dist/config/paths.js +108 -0
- package/dist/config/profile.d.ts +27 -0
- package/dist/config/profile.js +65 -0
- package/dist/config/schema.d.ts +34 -0
- package/dist/config/schema.js +413 -0
- package/dist/config/trust.d.ts +42 -0
- package/dist/config/trust.js +122 -0
- package/dist/config/types.d.ts +172 -0
- package/dist/config/types.js +27 -0
- package/dist/config/write.d.ts +10 -0
- package/dist/config/write.js +25 -0
- package/dist/errors.d.ts +28 -0
- package/dist/errors.js +30 -0
- package/dist/hooks/config.d.ts +49 -0
- package/dist/hooks/config.js +102 -0
- package/dist/hooks/dispatcher.d.ts +41 -0
- package/dist/hooks/dispatcher.js +104 -0
- package/dist/hooks/matcher.d.ts +22 -0
- package/dist/hooks/matcher.js +108 -0
- package/dist/hooks/protocol.d.ts +33 -0
- package/dist/hooks/protocol.js +240 -0
- package/dist/hooks/runner.d.ts +30 -0
- package/dist/hooks/runner.js +143 -0
- package/dist/hooks/types.d.ts +147 -0
- package/dist/hooks/types.js +20 -0
- package/dist/host/api-impl.d.ts +75 -0
- package/dist/host/api-impl.js +173 -0
- package/dist/host/loader.d.ts +31 -0
- package/dist/host/loader.js +147 -0
- package/dist/host/types.d.ts +169 -0
- package/dist/host/types.js +14 -0
- package/dist/host.d.ts +5 -0
- package/dist/host.js +4 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +28 -0
- package/dist/modes/commands-core.d.ts +44 -0
- package/dist/modes/commands-core.js +171 -0
- package/dist/modes/interactive/approval-dialog.d.ts +48 -0
- package/dist/modes/interactive/approval-dialog.js +202 -0
- package/dist/modes/interactive/commands.d.ts +41 -0
- package/dist/modes/interactive/commands.js +202 -0
- package/dist/modes/interactive/completion.d.ts +53 -0
- package/dist/modes/interactive/completion.js +157 -0
- package/dist/modes/interactive/interactive-mode.d.ts +46 -0
- package/dist/modes/interactive/interactive-mode.js +487 -0
- package/dist/modes/interactive/key-dispatch.d.ts +29 -0
- package/dist/modes/interactive/key-dispatch.js +107 -0
- package/dist/modes/interactive/line/line-editor.d.ts +50 -0
- package/dist/modes/interactive/line/line-editor.js +232 -0
- package/dist/modes/interactive/line/line-mode.d.ts +20 -0
- package/dist/modes/interactive/line/line-mode.js +216 -0
- package/dist/modes/interactive/line/line-render.d.ts +35 -0
- package/dist/modes/interactive/line/line-render.js +171 -0
- package/dist/modes/interactive/line/paste-state.d.ts +26 -0
- package/dist/modes/interactive/line/paste-state.js +72 -0
- package/dist/modes/interactive/message-view.d.ts +77 -0
- package/dist/modes/interactive/message-view.js +269 -0
- package/dist/modes/interactive/pickers.d.ts +42 -0
- package/dist/modes/interactive/pickers.js +115 -0
- package/dist/modes/interactive/startup-ui.d.ts +28 -0
- package/dist/modes/interactive/startup-ui.js +238 -0
- package/dist/modes/interactive/status-bar.d.ts +48 -0
- package/dist/modes/interactive/status-bar.js +139 -0
- package/dist/modes/interactive/tool-view.d.ts +95 -0
- package/dist/modes/interactive/tool-view.js +344 -0
- package/dist/modes/print/json-event.d.ts +15 -0
- package/dist/modes/print/json-event.js +39 -0
- package/dist/modes/print/print-mode.d.ts +15 -0
- package/dist/modes/print/print-mode.js +96 -0
- package/dist/modes/rpc/commands.d.ts +40 -0
- package/dist/modes/rpc/commands.js +258 -0
- package/dist/modes/rpc/jsonl.d.ts +16 -0
- package/dist/modes/rpc/jsonl.js +55 -0
- package/dist/modes/rpc/rpc-mode.d.ts +22 -0
- package/dist/modes/rpc/rpc-mode.js +153 -0
- package/dist/modes/session-report.d.ts +55 -0
- package/dist/modes/session-report.js +278 -0
- package/dist/modes/shared.d.ts +13 -0
- package/dist/modes/shared.js +52 -0
- package/dist/modes/startup-ui-text.d.ts +16 -0
- package/dist/modes/startup-ui-text.js +103 -0
- package/dist/permissions/broker.d.ts +47 -0
- package/dist/permissions/broker.js +107 -0
- package/dist/permissions/dangerous.d.ts +47 -0
- package/dist/permissions/dangerous.js +370 -0
- package/dist/permissions/pipeline.d.ts +51 -0
- package/dist/permissions/pipeline.js +181 -0
- package/dist/permissions/preview.d.ts +43 -0
- package/dist/permissions/preview.js +463 -0
- package/dist/permissions/rules.d.ts +58 -0
- package/dist/permissions/rules.js +249 -0
- package/dist/permissions/types.d.ts +100 -0
- package/dist/permissions/types.js +18 -0
- package/dist/rpc.d.ts +171 -0
- package/dist/rpc.js +13 -0
- package/dist/sdk.d.ts +98 -0
- package/dist/sdk.js +195 -0
- package/dist/session/manager.d.ts +70 -0
- package/dist/session/manager.js +278 -0
- package/dist/session/migrate.d.ts +19 -0
- package/dist/session/migrate.js +53 -0
- package/dist/session/projection.d.ts +50 -0
- package/dist/session/projection.js +180 -0
- package/dist/session/store.d.ts +47 -0
- package/dist/session/store.js +210 -0
- package/dist/session/tree.d.ts +21 -0
- package/dist/session/tree.js +88 -0
- package/dist/session/types.d.ts +199 -0
- package/dist/session/types.js +18 -0
- package/dist/skills/discover.d.ts +60 -0
- package/dist/skills/discover.js +160 -0
- package/dist/skills/expand.d.ts +35 -0
- package/dist/skills/expand.js +46 -0
- package/dist/skills/frontmatter.d.ts +27 -0
- package/dist/skills/frontmatter.js +157 -0
- package/dist/skills/index-prompt.d.ts +13 -0
- package/dist/skills/index-prompt.js +42 -0
- package/dist/skills/templates.d.ts +52 -0
- package/dist/skills/templates.js +177 -0
- package/dist/tools/bash.d.ts +49 -0
- package/dist/tools/bash.js +222 -0
- package/dist/tools/edit-fuzzy.d.ts +36 -0
- package/dist/tools/edit-fuzzy.js +129 -0
- package/dist/tools/edit.d.ts +38 -0
- package/dist/tools/edit.js +241 -0
- package/dist/tools/file-mutex.d.ts +8 -0
- package/dist/tools/file-mutex.js +29 -0
- package/dist/tools/glob.d.ts +44 -0
- package/dist/tools/glob.js +217 -0
- package/dist/tools/grep.d.ts +39 -0
- package/dist/tools/grep.js +179 -0
- package/dist/tools/ignore.d.ts +40 -0
- package/dist/tools/ignore.js +174 -0
- package/dist/tools/ls.d.ts +21 -0
- package/dist/tools/ls.js +96 -0
- package/dist/tools/output-accumulator.d.ts +48 -0
- package/dist/tools/output-accumulator.js +106 -0
- package/dist/tools/paths.d.ts +20 -0
- package/dist/tools/paths.js +58 -0
- package/dist/tools/presets.d.ts +71 -0
- package/dist/tools/presets.js +128 -0
- package/dist/tools/process-tree.d.ts +35 -0
- package/dist/tools/process-tree.js +125 -0
- package/dist/tools/read.d.ts +28 -0
- package/dist/tools/read.js +181 -0
- package/dist/tools/registry.d.ts +43 -0
- package/dist/tools/registry.js +106 -0
- package/dist/tools/shell.d.ts +38 -0
- package/dist/tools/shell.js +91 -0
- package/dist/tools/task.d.ts +29 -0
- package/dist/tools/task.js +107 -0
- package/dist/tools/todo.d.ts +28 -0
- package/dist/tools/todo.js +107 -0
- package/dist/tools/truncate.d.ts +44 -0
- package/dist/tools/truncate.js +175 -0
- package/dist/tools/types.d.ts +135 -0
- package/dist/tools/types.js +19 -0
- package/dist/tools/write.d.ts +20 -0
- package/dist/tools/write.js +84 -0
- package/dist/tui/ansi.d.ts +29 -0
- package/dist/tui/ansi.js +420 -0
- package/dist/tui/component.d.ts +38 -0
- package/dist/tui/component.js +13 -0
- package/dist/tui/components/box.d.ts +26 -0
- package/dist/tui/components/box.js +65 -0
- package/dist/tui/components/container.d.ts +14 -0
- package/dist/tui/components/container.js +39 -0
- package/dist/tui/components/editor-buffer.d.ts +67 -0
- package/dist/tui/components/editor-buffer.js +300 -0
- package/dist/tui/components/editor-paste.d.ts +29 -0
- package/dist/tui/components/editor-paste.js +64 -0
- package/dist/tui/components/editor.d.ts +114 -0
- package/dist/tui/components/editor.js +530 -0
- package/dist/tui/components/key-value.d.ts +29 -0
- package/dist/tui/components/key-value.js +48 -0
- package/dist/tui/components/loader.d.ts +35 -0
- package/dist/tui/components/loader.js +71 -0
- package/dist/tui/components/markdown.d.ts +90 -0
- package/dist/tui/components/markdown.js +462 -0
- package/dist/tui/components/meter.d.ts +29 -0
- package/dist/tui/components/meter.js +47 -0
- package/dist/tui/components/overlay.d.ts +24 -0
- package/dist/tui/components/overlay.js +52 -0
- package/dist/tui/components/select-list.d.ts +57 -0
- package/dist/tui/components/select-list.js +179 -0
- package/dist/tui/components/spacer.d.ts +11 -0
- package/dist/tui/components/spacer.js +16 -0
- package/dist/tui/components/text.d.ts +30 -0
- package/dist/tui/components/text.js +65 -0
- package/dist/tui/keybindings.d.ts +66 -0
- package/dist/tui/keybindings.js +120 -0
- package/dist/tui/keys.d.ts +38 -0
- package/dist/tui/keys.js +275 -0
- package/dist/tui/stdin-buffer.d.ts +41 -0
- package/dist/tui/stdin-buffer.js +206 -0
- package/dist/tui/terminal.d.ts +79 -0
- package/dist/tui/terminal.js +153 -0
- package/dist/tui/theme.d.ts +31 -0
- package/dist/tui/theme.js +199 -0
- package/dist/tui/tui.d.ts +103 -0
- package/dist/tui/tui.js +363 -0
- package/dist/tui/vt-screen.d.ts +46 -0
- package/dist/tui/vt-screen.js +251 -0
- package/dist/tui.d.ts +30 -0
- package/dist/tui.js +31 -0
- package/dist/version.d.ts +8 -0
- package/dist/version.js +24 -0
- package/docs/codemode.md +102 -0
- package/docs/hooks.md +196 -0
- package/docs/host-api.md +161 -0
- package/docs/providers.md +316 -0
- package/docs/rpc.md +253 -0
- package/docs/session-format.md +119 -0
- package/docs/tui.md +168 -0
- package/package.json +101 -4
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模型接入层契约(设计 §3.1–§3.2、§3.5、§3.6)。[B0] 契约文件,实现归 B1 / B8。
|
|
3
|
+
*
|
|
4
|
+
* 补全与偏差(相对设计正文):
|
|
5
|
+
* - 内容块(TextBlock / ThinkingBlock / ImageBlock / ToolCallBlock)、`Usage`、`StopReason`、
|
|
6
|
+
* LLM 消息(`Message`)定义在这里而不是 agent/types.ts:依赖方向是 agent → ai,协议层
|
|
7
|
+
* 必须能拿到这些类型。agent/types.ts 原样再导出它们。
|
|
8
|
+
* - `JsonSchema`(工具参数子集)也定义在这里,因为 `ToolDecl` 要发给供应商;
|
|
9
|
+
* tools/types.ts 与 agent/schema.ts 再导出。
|
|
10
|
+
* - `TranscriptContext` = 循环交给协议的原始转录(含 `system` 节补丁消息);协议实现先调
|
|
11
|
+
* `normalizeContext()`(ai/context.ts,B1)得到 `NormalizedContext` 再拼请求体。
|
|
12
|
+
* - `GoogleCompat` / `OpenAIResponsesCompat` 只列出已知字段,B8 按需追加(走契约变更流程)。
|
|
13
|
+
* - `ProviderRegistryApi` / `ApiKeyResolution` 是 Runtime(cli/runtime.ts)需要的最小接口,
|
|
14
|
+
* B1 的 `ProviderRegistry` 类实现它。
|
|
15
|
+
* - [W3-C0] 第三波 §1.3 的五个缓存兼容开关单列为 `PromptCacheCompat`(各协议共用),只并入
|
|
16
|
+
* `ProviderCompat`(全部可选),不改各协议 compat 接口——`detectCompat` 的返回形状不变,
|
|
17
|
+
* 缺省值由 C1a 在协议层按端点推断。
|
|
18
|
+
*/
|
|
19
|
+
export type KnownApi = "anthropic-messages" | "openai-completions" | "openai-responses" | "google-generative-ai";
|
|
20
|
+
export type Api = KnownApi | (string & {});
|
|
21
|
+
export type ModelThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
22
|
+
/** 除 off 以外的级别。 */
|
|
23
|
+
export type ThinkingLevel = Exclude<ModelThinkingLevel, "off">;
|
|
24
|
+
export type CacheRetention = "none" | "short" | "long";
|
|
25
|
+
/**
|
|
26
|
+
* [W3-C0] 一次请求的用途(第三波 §1.2):会话层按用途分开记录请求链——`turn` 是循环里的
|
|
27
|
+
* 真实回合,`summary` 是压缩 / 分支摘要,`warm` 是缓存保温重放,`probe` 是 `models check` /
|
|
28
|
+
* `cache-probe` 一类的探测。缺省视为 `turn`。协议层只透传,不改变请求体。
|
|
29
|
+
*/
|
|
30
|
+
export type RequestPurpose = "turn" | "summary" | "warm" | "probe";
|
|
31
|
+
/** `provider/model-id` 拆开后的引用。 */
|
|
32
|
+
export interface ModelRef {
|
|
33
|
+
provider: string;
|
|
34
|
+
id: string;
|
|
35
|
+
}
|
|
36
|
+
export type JsonSchemaType = "object" | "string" | "number" | "integer" | "boolean" | "array";
|
|
37
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
38
|
+
/**
|
|
39
|
+
* 支持的关键字:type / properties / required / items / enum / description /
|
|
40
|
+
* additionalProperties(只接受布尔)/ default / title。其它关键字不在子集内,
|
|
41
|
+
* `checkSchemaSubset()`(agent/schema.ts)会报出来。
|
|
42
|
+
*/
|
|
43
|
+
export interface JsonSchema {
|
|
44
|
+
type?: JsonSchemaType;
|
|
45
|
+
title?: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
properties?: Record<string, JsonSchema>;
|
|
48
|
+
required?: readonly string[];
|
|
49
|
+
additionalProperties?: boolean;
|
|
50
|
+
items?: JsonSchema;
|
|
51
|
+
enum?: readonly JsonPrimitive[];
|
|
52
|
+
default?: unknown;
|
|
53
|
+
}
|
|
54
|
+
export interface TextBlock {
|
|
55
|
+
type: "text";
|
|
56
|
+
text: string;
|
|
57
|
+
/** 供应商给的文本签名(原样回放)。 */
|
|
58
|
+
textSignature?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface ThinkingBlock {
|
|
61
|
+
type: "thinking";
|
|
62
|
+
thinking: string;
|
|
63
|
+
/** Anthropic signature 等;跨模型回放时由 transform.ts 降级为文本。 */
|
|
64
|
+
thinkingSignature?: string;
|
|
65
|
+
redacted?: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface ImageBlock {
|
|
68
|
+
type: "image";
|
|
69
|
+
/** base64,不含 data: 前缀。 */
|
|
70
|
+
data: string;
|
|
71
|
+
mimeType: string;
|
|
72
|
+
}
|
|
73
|
+
export interface ToolCallBlock {
|
|
74
|
+
type: "toolCall";
|
|
75
|
+
id: string;
|
|
76
|
+
name: string;
|
|
77
|
+
/** `toolcall_end` 时保证是合法对象(§3.1 流契约)。 */
|
|
78
|
+
arguments: Record<string, unknown>;
|
|
79
|
+
/** Google thoughtSignature 等。 */
|
|
80
|
+
thoughtSignature?: string;
|
|
81
|
+
}
|
|
82
|
+
/** 用户消息与工具结果可携带的块。 */
|
|
83
|
+
export type ContentBlock = TextBlock | ImageBlock;
|
|
84
|
+
/** 助手消息的块。 */
|
|
85
|
+
export type AssistantContentBlock = TextBlock | ThinkingBlock | ToolCallBlock;
|
|
86
|
+
export interface UsageCost {
|
|
87
|
+
input: number;
|
|
88
|
+
output: number;
|
|
89
|
+
cacheRead: number;
|
|
90
|
+
cacheWrite: number;
|
|
91
|
+
total: number;
|
|
92
|
+
}
|
|
93
|
+
/** `input` 不含缓存部分(§3.6)。 */
|
|
94
|
+
export interface Usage {
|
|
95
|
+
input: number;
|
|
96
|
+
output: number;
|
|
97
|
+
cacheRead: number;
|
|
98
|
+
cacheWrite: number;
|
|
99
|
+
/** 1 小时缓存写入(按 2× 计价),已包含在 cacheWrite 中。 */
|
|
100
|
+
cacheWrite1h?: number;
|
|
101
|
+
reasoning?: number;
|
|
102
|
+
totalTokens: number;
|
|
103
|
+
/** 由 ai/cost.ts 写回;模型无 cost 时缺省。 */
|
|
104
|
+
cost?: UsageCost;
|
|
105
|
+
/**
|
|
106
|
+
* [W3-C0] 原始响应里**出现过**任何缓存字段(即使值为 0)为 true;字段缺失为 false;
|
|
107
|
+
* 协议尚未解析该标记时缺省(第三波 §1.6,「值为 0」与「不报」由此区分)。
|
|
108
|
+
*/
|
|
109
|
+
cacheReported?: boolean;
|
|
110
|
+
}
|
|
111
|
+
export type StopReason = "stop" | "length" | "toolUse" | "aborted" | "error";
|
|
112
|
+
/** 工具声明(发给供应商的形状)。 */
|
|
113
|
+
export interface ToolDecl {
|
|
114
|
+
name: string;
|
|
115
|
+
description: string;
|
|
116
|
+
parameters: JsonSchema;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* 系统提示与工具表作为 `system` 消息落盘:首条给全量 `sections`,之后是补丁
|
|
120
|
+
* (节名级替换,`null` 删除;`toolsAdded` / `toolsRemoved` 为工具表差异)。
|
|
121
|
+
*/
|
|
122
|
+
export interface SystemMessage {
|
|
123
|
+
role: "system";
|
|
124
|
+
sections: Record<string, string | null>;
|
|
125
|
+
toolsAdded?: ToolDecl[];
|
|
126
|
+
toolsRemoved?: string[];
|
|
127
|
+
timestamp: number;
|
|
128
|
+
}
|
|
129
|
+
export type KnownMessageOrigin = "steer" | "followUp" | "host";
|
|
130
|
+
export type MessageOrigin = KnownMessageOrigin | (string & {});
|
|
131
|
+
export interface UserMessage {
|
|
132
|
+
role: "user";
|
|
133
|
+
content: string | ContentBlock[];
|
|
134
|
+
/** 无 = 普通用户输入;宿主 `sendUser(text, origin)` 的 origin 原样记录。 */
|
|
135
|
+
origin?: MessageOrigin;
|
|
136
|
+
timestamp: number;
|
|
137
|
+
}
|
|
138
|
+
export interface AssistantMessage {
|
|
139
|
+
role: "assistant";
|
|
140
|
+
content: AssistantContentBlock[];
|
|
141
|
+
api: Api;
|
|
142
|
+
provider: string;
|
|
143
|
+
model: string;
|
|
144
|
+
responseId?: string;
|
|
145
|
+
usage: Usage;
|
|
146
|
+
stopReason: StopReason;
|
|
147
|
+
errorMessage?: string;
|
|
148
|
+
/** 用户面级别(钳位后)。 */
|
|
149
|
+
thinkingLevel?: ModelThinkingLevel;
|
|
150
|
+
/** 实际发给供应商的值(effort 字串或预算)。 */
|
|
151
|
+
providerThinkingLevel?: string;
|
|
152
|
+
/** 供应商原始 finish / stop reason。 */
|
|
153
|
+
rawStopReason?: string;
|
|
154
|
+
timestamp: number;
|
|
155
|
+
}
|
|
156
|
+
export interface ToolResultMessage {
|
|
157
|
+
role: "toolResult";
|
|
158
|
+
toolCallId: string;
|
|
159
|
+
toolName: string;
|
|
160
|
+
content: string | ContentBlock[];
|
|
161
|
+
isError: boolean;
|
|
162
|
+
/** 落盘,不进上下文。 */
|
|
163
|
+
details?: unknown;
|
|
164
|
+
timestamp: number;
|
|
165
|
+
}
|
|
166
|
+
export type Message = SystemMessage | UserMessage | AssistantMessage | ToolResultMessage;
|
|
167
|
+
/** 循环交给协议的转录(未折叠的 system 补丁也在其中)。 */
|
|
168
|
+
export interface TranscriptContext {
|
|
169
|
+
readonly messages: readonly Message[];
|
|
170
|
+
}
|
|
171
|
+
/** normalizeContext() 的输出:system 已折叠为一段文本,工具表已重装,模态已过滤。 */
|
|
172
|
+
export interface NormalizedContext {
|
|
173
|
+
systemPrompt: string;
|
|
174
|
+
/** 节名 → 文本(按装配顺序),供 Anthropic 打缓存断点。 */
|
|
175
|
+
systemSections: readonly {
|
|
176
|
+
name: string;
|
|
177
|
+
text: string;
|
|
178
|
+
}[];
|
|
179
|
+
tools: ToolDecl[];
|
|
180
|
+
messages: (UserMessage | AssistantMessage | ToolResultMessage)[];
|
|
181
|
+
}
|
|
182
|
+
export type OpenAIThinkingFormat = "openai" | "openrouter" | "deepseek" | "zai" | "qwen" | "none";
|
|
183
|
+
export interface OpenAICompletionsCompat {
|
|
184
|
+
maxTokensField: "max_tokens" | "max_completion_tokens";
|
|
185
|
+
supportsDeveloperRole: boolean;
|
|
186
|
+
supportsUsageInStreaming: boolean;
|
|
187
|
+
supportsFinishReason: boolean;
|
|
188
|
+
supportsReasoningEffort: boolean;
|
|
189
|
+
thinkingFormat: OpenAIThinkingFormat;
|
|
190
|
+
/** 预算型思考的字段名(qwen: thinking_budget);无则不发预算。 */
|
|
191
|
+
thinkingTokenBudgetField?: string;
|
|
192
|
+
requiresReasoningContentOnAssistantMessages: boolean;
|
|
193
|
+
requiresToolResultName: boolean;
|
|
194
|
+
requiresAssistantAfterToolResult: boolean;
|
|
195
|
+
supportsMidConvoSystemMessages: boolean;
|
|
196
|
+
/** `anthropic`:OpenRouter 上的 anthropic/* 模型在消息块上打 cache_control。 */
|
|
197
|
+
cacheControlFormat: "none" | "anthropic";
|
|
198
|
+
supportsStrictTools: boolean;
|
|
199
|
+
supportsStore: boolean;
|
|
200
|
+
}
|
|
201
|
+
export interface AnthropicMessagesCompat {
|
|
202
|
+
supportsCacheControlOnTools: boolean;
|
|
203
|
+
supportsTemperatureWithThinking: boolean;
|
|
204
|
+
/** true:新模型用 `effort` 参数;false:老模型用 `budget_tokens`。 */
|
|
205
|
+
adaptiveThinking: boolean;
|
|
206
|
+
maxCacheBreakpoints: number;
|
|
207
|
+
}
|
|
208
|
+
/** B8 补全。 */
|
|
209
|
+
export interface GoogleCompat {
|
|
210
|
+
supportsThoughtSignature: boolean;
|
|
211
|
+
supportsFunctionResponseParts: boolean;
|
|
212
|
+
}
|
|
213
|
+
/** B8 补全。 */
|
|
214
|
+
export interface OpenAIResponsesCompat {
|
|
215
|
+
supportsReasoningSummary: boolean;
|
|
216
|
+
supportsStore: boolean;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* [W3-C0] 供应商不报缓存时的处理(第三波 §1.6):`auto` 按响应自动判定三态;`silent` /
|
|
220
|
+
* `reported` 强制(`ama models cache-probe` 给出建议写法)。
|
|
221
|
+
*/
|
|
222
|
+
export type CacheReportingSetting = "auto" | "silent" | "reported";
|
|
223
|
+
/**
|
|
224
|
+
* [W3-C0] 缓存相关的兼容开关(第三波 §1.3),各协议共用;这里是解析后的完整形状,
|
|
225
|
+
* `ProviderCompat` 里全部可选。缺省值由协议层按端点推断(官方端点开、自定义供应商关)。
|
|
226
|
+
*/
|
|
227
|
+
export interface PromptCacheCompat {
|
|
228
|
+
/** 发 `prompt_cache_key`(OpenAI 系);官方端点缺省 true,其余缺省 false。 */
|
|
229
|
+
sendPromptCacheKey: boolean;
|
|
230
|
+
/** 发 `x-session-affinity` / `x-client-request-id`(OpenRouter 为 `x-session-id`)亲和头。 */
|
|
231
|
+
sendSessionAffinityHeaders: boolean;
|
|
232
|
+
/** `cacheRetention: "long"` 可用(Anthropic 1h、OpenAI 24h);不支持时降为 short。 */
|
|
233
|
+
supportsLongCacheRetention: boolean;
|
|
234
|
+
/** Responses 的 `prompt_cache_options`(30m 显式缓存)。 */
|
|
235
|
+
supportsExplicitPromptCacheMode: boolean;
|
|
236
|
+
cacheReporting: CacheReportingSetting;
|
|
237
|
+
}
|
|
238
|
+
export type ProviderCompat = Partial<OpenAICompletionsCompat & AnthropicMessagesCompat & GoogleCompat & OpenAIResponsesCompat & PromptCacheCompat>;
|
|
239
|
+
export type AuthHeader = "authorization-bearer" | "x-api-key" | "x-goog-api-key" | {
|
|
240
|
+
header: string;
|
|
241
|
+
prefix?: string;
|
|
242
|
+
};
|
|
243
|
+
export interface CostTier {
|
|
244
|
+
/** 当 input + cacheRead + cacheWrite 超过该值时使用本档价格。 */
|
|
245
|
+
inputTokensAbove: number;
|
|
246
|
+
input: number;
|
|
247
|
+
output: number;
|
|
248
|
+
cacheRead: number;
|
|
249
|
+
cacheWrite: number;
|
|
250
|
+
}
|
|
251
|
+
/** 单位:美元 / 百万 token。 */
|
|
252
|
+
export interface ModelCost {
|
|
253
|
+
input: number;
|
|
254
|
+
output: number;
|
|
255
|
+
cacheRead: number;
|
|
256
|
+
cacheWrite: number;
|
|
257
|
+
tiers?: CostTier[];
|
|
258
|
+
}
|
|
259
|
+
/** 模型目录 `promptCache`:只写有公开依据的值,留空 = 不承诺(不保温、归因用启发值)。 */
|
|
260
|
+
export interface ModelPromptCache {
|
|
261
|
+
/** `short` 档 TTL(秒)。 */
|
|
262
|
+
short?: number;
|
|
263
|
+
/** `long` 档 TTL(秒)。 */
|
|
264
|
+
long?: number;
|
|
265
|
+
/** [W3-C0] 最小可缓存长度(token);未命中检测的噪声下限取 max(1024, minTokens)。 */
|
|
266
|
+
minTokens?: number;
|
|
267
|
+
}
|
|
268
|
+
export interface Model {
|
|
269
|
+
id: string;
|
|
270
|
+
name: string;
|
|
271
|
+
provider: string;
|
|
272
|
+
api: Api;
|
|
273
|
+
/** 覆盖供应商 baseUrl。 */
|
|
274
|
+
baseUrl?: string;
|
|
275
|
+
input: ("text" | "image")[];
|
|
276
|
+
reasoning: boolean;
|
|
277
|
+
/** null = 该级别不支持。 */
|
|
278
|
+
thinkingLevelMap?: Partial<Record<ModelThinkingLevel, string | number | null>>;
|
|
279
|
+
/** 缺省 → 关自动压缩并警告。 */
|
|
280
|
+
contextWindow?: number;
|
|
281
|
+
maxTokens: number;
|
|
282
|
+
cost?: ModelCost;
|
|
283
|
+
/** 各档缓存的 TTL(秒)与最小可缓存长度(第三波 §1.4)。 */
|
|
284
|
+
promptCache?: ModelPromptCache;
|
|
285
|
+
headers?: Record<string, string>;
|
|
286
|
+
samplingParams?: Record<string, unknown>;
|
|
287
|
+
compat?: ProviderCompat;
|
|
288
|
+
/**
|
|
289
|
+
* [B1 追加] 鉴权头形状;registry 从 `ProviderData.authHeader` 填入。缺省按协议
|
|
290
|
+
* (anthropic-messages → x-api-key,其余 → Authorization: Bearer)。
|
|
291
|
+
*/
|
|
292
|
+
authHeader?: AuthHeader;
|
|
293
|
+
/**
|
|
294
|
+
* [B1 追加] false = 无 key 也能调用(本地服务);registry 从 `ProviderData.requiresApiKey`
|
|
295
|
+
* 填入。缺省视为 true:流函数缺 key 时同步抛 `AmaError{code:"no_api_key"}`。
|
|
296
|
+
*/
|
|
297
|
+
requiresApiKey?: boolean;
|
|
298
|
+
}
|
|
299
|
+
export interface ProviderData {
|
|
300
|
+
id: string;
|
|
301
|
+
name: string;
|
|
302
|
+
api: Api;
|
|
303
|
+
baseUrl: string;
|
|
304
|
+
/** API Key 环境变量候选,顺序即优先级;首项是各家标准名。 */
|
|
305
|
+
envKeys: string[];
|
|
306
|
+
authHeader?: AuthHeader;
|
|
307
|
+
headers?: Record<string, string>;
|
|
308
|
+
compat?: ProviderCompat;
|
|
309
|
+
models: Model[];
|
|
310
|
+
/** 本地服务 false:无 key 也能用。 */
|
|
311
|
+
requiresApiKey: boolean;
|
|
312
|
+
builtin: boolean;
|
|
313
|
+
}
|
|
314
|
+
/** `catalog/*.json` 文件形状(§3.4)。 */
|
|
315
|
+
export interface ModelCatalogFile {
|
|
316
|
+
version: 1;
|
|
317
|
+
provider: string;
|
|
318
|
+
models: Omit<Model, "provider" | "api">[];
|
|
319
|
+
}
|
|
320
|
+
export interface StreamOptions {
|
|
321
|
+
signal: AbortSignal;
|
|
322
|
+
apiKey?: string;
|
|
323
|
+
/** 值为 null 表示删除该头。 */
|
|
324
|
+
headers?: Record<string, string | null>;
|
|
325
|
+
timeoutMs?: number;
|
|
326
|
+
maxTokens?: number;
|
|
327
|
+
temperature?: number;
|
|
328
|
+
thinkingLevel?: ModelThinkingLevel;
|
|
329
|
+
cacheRetention?: CacheRetention;
|
|
330
|
+
sessionId?: string;
|
|
331
|
+
/** [W3-C0] 请求用途(第三波 §1.2);缺省 `turn`。协议层只透传给观测方,不进请求体。 */
|
|
332
|
+
purpose?: RequestPurpose;
|
|
333
|
+
/**
|
|
334
|
+
* [W3-C0] `"none"`:本次请求带工具表但禁止调用(压缩摘要走会话前缀续写,第三波 §1.8)。
|
|
335
|
+
* 映射:Anthropic `tool_choice:{type:"none"}`、Completions / Responses `tool_choice:"none"`、
|
|
336
|
+
* Google `toolConfig.functionCallingConfig.mode:"NONE"`。缺省不发。
|
|
337
|
+
*/
|
|
338
|
+
toolChoice?: "none";
|
|
339
|
+
/** 观测 / 替换请求体:返回非 undefined 即替换。 */
|
|
340
|
+
onPayload?(payload: unknown): unknown;
|
|
341
|
+
onResponse?(status: number, headers: Headers): void;
|
|
342
|
+
}
|
|
343
|
+
export type AssistantEvent = {
|
|
344
|
+
type: "start";
|
|
345
|
+
partial: AssistantMessage;
|
|
346
|
+
} | {
|
|
347
|
+
type: "text_start" | "text_end";
|
|
348
|
+
contentIndex: number;
|
|
349
|
+
partial: AssistantMessage;
|
|
350
|
+
} | {
|
|
351
|
+
type: "text_delta";
|
|
352
|
+
contentIndex: number;
|
|
353
|
+
delta: string;
|
|
354
|
+
partial: AssistantMessage;
|
|
355
|
+
} | {
|
|
356
|
+
type: "thinking_start" | "thinking_end";
|
|
357
|
+
contentIndex: number;
|
|
358
|
+
partial: AssistantMessage;
|
|
359
|
+
} | {
|
|
360
|
+
type: "thinking_delta";
|
|
361
|
+
contentIndex: number;
|
|
362
|
+
delta: string;
|
|
363
|
+
partial: AssistantMessage;
|
|
364
|
+
} | {
|
|
365
|
+
type: "toolcall_start";
|
|
366
|
+
contentIndex: number;
|
|
367
|
+
id: string;
|
|
368
|
+
name: string;
|
|
369
|
+
partial: AssistantMessage;
|
|
370
|
+
} | {
|
|
371
|
+
type: "toolcall_delta";
|
|
372
|
+
contentIndex: number;
|
|
373
|
+
delta: string;
|
|
374
|
+
partial: AssistantMessage;
|
|
375
|
+
} | {
|
|
376
|
+
type: "toolcall_end";
|
|
377
|
+
contentIndex: number;
|
|
378
|
+
toolCall: ToolCallBlock;
|
|
379
|
+
partial: AssistantMessage;
|
|
380
|
+
} | {
|
|
381
|
+
type: "done";
|
|
382
|
+
reason: "stop" | "length" | "toolUse";
|
|
383
|
+
message: AssistantMessage;
|
|
384
|
+
} | {
|
|
385
|
+
type: "error";
|
|
386
|
+
reason: "aborted" | "error";
|
|
387
|
+
message: AssistantMessage;
|
|
388
|
+
};
|
|
389
|
+
export type AssistantEventType = AssistantEvent["type"];
|
|
390
|
+
/**
|
|
391
|
+
* 流契约:成功后先 `start`;块事件配对;恰好一个终止事件(done / error);
|
|
392
|
+
* 流函数不抛错(缺 key 例外:同步抛 AmaError{code:"no_api_key"})。
|
|
393
|
+
* `result()` 在终止事件后 resolve 为最终消息(error 时也 resolve,不 reject)。
|
|
394
|
+
*/
|
|
395
|
+
export interface AssistantEventStream extends AsyncIterable<AssistantEvent> {
|
|
396
|
+
result(): Promise<AssistantMessage>;
|
|
397
|
+
}
|
|
398
|
+
export interface ApiImplementation<C = unknown> {
|
|
399
|
+
readonly id: Api;
|
|
400
|
+
stream(model: Model, context: TranscriptContext, options: StreamOptions): AssistantEventStream;
|
|
401
|
+
/** 推断缺省 compat。 */
|
|
402
|
+
detectCompat?(model: Model, provider: ProviderData): C;
|
|
403
|
+
}
|
|
404
|
+
export type KeySource = "cli" | "auth-file" | "config" | "env" | "none";
|
|
405
|
+
/** 密钥只存在于 `apiKey` 字段,不进日志、会话、事件。 */
|
|
406
|
+
export interface ApiKeyResolution {
|
|
407
|
+
apiKey: string | undefined;
|
|
408
|
+
source: KeySource;
|
|
409
|
+
/** source 为 env 时的变量名;auth-file 时的文件路径。 */
|
|
410
|
+
origin?: string;
|
|
411
|
+
}
|
|
412
|
+
export type ModelLookup = {
|
|
413
|
+
ok: true;
|
|
414
|
+
model: Model;
|
|
415
|
+
provider: ProviderData;
|
|
416
|
+
} | {
|
|
417
|
+
ok: false;
|
|
418
|
+
reason: "not_found" | "ambiguous" | "provider_not_found";
|
|
419
|
+
candidates: string[];
|
|
420
|
+
};
|
|
421
|
+
export interface ProviderRegistryApi {
|
|
422
|
+
list(): readonly ProviderData[];
|
|
423
|
+
get(providerId: string): ProviderData | undefined;
|
|
424
|
+
/** 解析 `provider/model-id` 或无斜杠的模型 id(§3.4)。 */
|
|
425
|
+
findModel(ref: string): ModelLookup;
|
|
426
|
+
resolveApiKey(providerId: string): Promise<ApiKeyResolution>;
|
|
427
|
+
getApi(api: Api): ApiImplementation | undefined;
|
|
428
|
+
}
|
package/dist/ai/types.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模型接入层契约(设计 §3.1–§3.2、§3.5、§3.6)。[B0] 契约文件,实现归 B1 / B8。
|
|
3
|
+
*
|
|
4
|
+
* 补全与偏差(相对设计正文):
|
|
5
|
+
* - 内容块(TextBlock / ThinkingBlock / ImageBlock / ToolCallBlock)、`Usage`、`StopReason`、
|
|
6
|
+
* LLM 消息(`Message`)定义在这里而不是 agent/types.ts:依赖方向是 agent → ai,协议层
|
|
7
|
+
* 必须能拿到这些类型。agent/types.ts 原样再导出它们。
|
|
8
|
+
* - `JsonSchema`(工具参数子集)也定义在这里,因为 `ToolDecl` 要发给供应商;
|
|
9
|
+
* tools/types.ts 与 agent/schema.ts 再导出。
|
|
10
|
+
* - `TranscriptContext` = 循环交给协议的原始转录(含 `system` 节补丁消息);协议实现先调
|
|
11
|
+
* `normalizeContext()`(ai/context.ts,B1)得到 `NormalizedContext` 再拼请求体。
|
|
12
|
+
* - `GoogleCompat` / `OpenAIResponsesCompat` 只列出已知字段,B8 按需追加(走契约变更流程)。
|
|
13
|
+
* - `ProviderRegistryApi` / `ApiKeyResolution` 是 Runtime(cli/runtime.ts)需要的最小接口,
|
|
14
|
+
* B1 的 `ProviderRegistry` 类实现它。
|
|
15
|
+
* - [W3-C0] 第三波 §1.3 的五个缓存兼容开关单列为 `PromptCacheCompat`(各协议共用),只并入
|
|
16
|
+
* `ProviderCompat`(全部可选),不改各协议 compat 接口——`detectCompat` 的返回形状不变,
|
|
17
|
+
* 缺省值由 C1a 在协议层按端点推断。
|
|
18
|
+
*/
|
|
19
|
+
export {};
|