@armadra/agent 0.5.0 → 0.6.0
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 +177 -294
- package/CHANGELOG.zh-CN.md +442 -0
- package/README.md +408 -364
- package/README.zh-CN.md +705 -0
- package/dist/agent/session-plan.js +2 -2
- package/dist/agent/session-state.d.ts +3 -0
- package/dist/agent/session-state.js +20 -0
- package/dist/agent/session-subagent.d.ts +15 -1
- package/dist/agent/session-subagent.js +26 -3
- package/dist/agent/session-telemetry.d.ts +16 -2
- package/dist/agent/session-telemetry.js +29 -7
- package/dist/agent/session-tools.js +5 -2
- package/dist/agent/session-trace-writer.d.ts +27 -0
- package/dist/agent/session-trace-writer.js +253 -0
- package/dist/agent/session.d.ts +2 -0
- package/dist/agent/session.js +12 -0
- package/dist/agent/subagent-direct.d.ts +20 -0
- package/dist/agent/subagent-direct.js +76 -0
- package/dist/agent/subagent-registry.d.ts +8 -1
- package/dist/agent/subagent-registry.js +28 -1
- package/dist/agent/system-prompt.d.ts +3 -1
- package/dist/agent/system-prompt.js +3 -0
- package/dist/agent/tool-runner.d.ts +2 -1
- package/dist/agent/tool-runner.js +5 -4
- package/dist/agent/types-w6.d.ts +39 -0
- package/dist/agent/types-w6.js +4 -0
- package/dist/agent/types.d.ts +5 -2
- package/dist/agents/external.js +1 -1
- package/dist/agents/task-record.d.ts +74 -1
- package/dist/agents/task-record.js +100 -0
- package/dist/ai/apis/cache-params.js +2 -1
- package/dist/ai/apis/chatgpt-backend.d.ts +52 -0
- package/dist/ai/apis/chatgpt-backend.js +224 -0
- package/dist/ai/apis/chatgpt-rate-limits.d.ts +26 -0
- package/dist/ai/apis/chatgpt-rate-limits.js +91 -0
- package/dist/ai/apis/openai-responses-request.d.ts +2 -1
- package/dist/ai/apis/openai-responses-request.js +8 -2
- package/dist/ai/apis/openai-responses.d.ts +2 -0
- package/dist/ai/apis/openai-responses.js +51 -16
- package/dist/ai/overflow.d.ts +1 -1
- package/dist/ai/overflow.js +10 -7
- package/dist/ai/providers/auth.d.ts +15 -2
- package/dist/ai/providers/auth.js +69 -2
- package/dist/ai/providers/builtin.js +27 -0
- package/dist/ai/providers/catalog-data.js +1 -0
- package/dist/ai/providers/enrich.js +2 -7
- package/dist/ai/providers/models-dev-cache.js +15 -19
- package/dist/ai/providers/models-dev-snapshot.js +8 -7
- package/dist/ai/providers/models-dev.js +5 -15
- package/dist/ai/providers/suggest.js +2 -16
- package/dist/ai/types.d.ts +27 -1
- package/dist/auth/chatgpt/backend-client.d.ts +26 -0
- package/dist/auth/chatgpt/backend-client.js +74 -0
- package/dist/auth/chatgpt/claims.d.ts +17 -0
- package/dist/auth/chatgpt/claims.js +46 -0
- package/dist/auth/chatgpt/cli.d.ts +33 -0
- package/dist/auth/chatgpt/cli.js +252 -0
- package/dist/auth/chatgpt/doctor.d.ts +17 -0
- package/dist/auth/chatgpt/doctor.js +36 -0
- package/dist/auth/chatgpt/host-id.d.ts +7 -0
- package/dist/auth/chatgpt/host-id.js +26 -0
- package/dist/auth/chatgpt/login.d.ts +30 -0
- package/dist/auth/chatgpt/login.js +130 -0
- package/dist/auth/chatgpt/presets.d.ts +66 -0
- package/dist/auth/chatgpt/presets.js +120 -0
- package/dist/auth/chatgpt/quota-text.d.ts +13 -0
- package/dist/auth/chatgpt/quota-text.js +36 -0
- package/dist/auth/oauth/browser.d.ts +12 -0
- package/dist/auth/oauth/browser.js +27 -0
- package/dist/auth/oauth/callback-server.d.ts +47 -0
- package/dist/auth/oauth/callback-server.js +147 -0
- package/dist/auth/oauth/flows.d.ts +62 -0
- package/dist/auth/oauth/flows.js +113 -0
- package/dist/auth/oauth/jwt.d.ts +24 -0
- package/dist/auth/oauth/jwt.js +81 -0
- package/dist/auth/oauth/live.d.ts +21 -0
- package/dist/auth/oauth/live.js +25 -0
- package/dist/auth/oauth/oidc.d.ts +26 -0
- package/dist/auth/oauth/oidc.js +72 -0
- package/dist/auth/oauth/pkce.d.ts +15 -0
- package/dist/auth/oauth/pkce.js +20 -0
- package/dist/auth/oauth/refresh.d.ts +35 -0
- package/dist/auth/oauth/refresh.js +129 -0
- package/dist/auth/oauth/token-client.d.ts +33 -0
- package/dist/auth/oauth/token-client.js +121 -0
- package/dist/auth/oauth/token-store.d.ts +23 -0
- package/dist/auth/oauth/token-store.js +125 -0
- package/dist/auth/testing/fake-oauth.d.ts +73 -0
- package/dist/auth/testing/fake-oauth.js +271 -0
- package/dist/auth/testing/refresh-child.d.ts +5 -0
- package/dist/auth/testing/refresh-child.js +16 -0
- package/dist/bundle/ama.cjs +28307 -13241
- package/dist/checkpoints/backend.js +6 -5
- package/dist/checkpoints/restore.js +3 -2
- package/dist/checkpoints/settings.js +2 -1
- package/dist/checkpoints/shadow-git.js +7 -6
- package/dist/checkpoints/shadow-restore.js +3 -2
- package/dist/checkpoints/tracker.js +4 -3
- package/dist/cli/args.d.ts +9 -2
- package/dist/cli/args.js +74 -27
- package/dist/cli/bootstrap.js +53 -31
- package/dist/cli/choice-prompt.d.ts +58 -0
- package/dist/cli/choice-prompt.js +142 -0
- package/dist/cli/codemode-notice.js +2 -2
- package/dist/cli/compose-agents.js +2 -1
- package/dist/cli/compose-extensions.js +2 -0
- package/dist/cli/compose-memory.d.ts +53 -0
- package/dist/cli/compose-memory.js +127 -0
- package/dist/cli/compose-providers.d.ts +5 -0
- package/dist/cli/compose-providers.js +32 -2
- package/dist/cli/compose-session.d.ts +5 -0
- package/dist/cli/compose-session.js +27 -13
- package/dist/cli/compose-store.d.ts +2 -0
- package/dist/cli/compose-store.js +9 -5
- package/dist/cli/compose.d.ts +2 -0
- package/dist/cli/compose.js +13 -5
- package/dist/cli/default-model.d.ts +0 -2
- package/dist/cli/default-model.js +5 -8
- package/dist/cli/deps.d.ts +5 -1
- package/dist/cli/exit-codes.d.ts +1 -1
- package/dist/cli/exit-codes.js +7 -16
- package/dist/cli/from-prompt.js +3 -2
- package/dist/cli/help-text.d.ts +2 -1
- package/dist/cli/help-text.js +5 -99
- package/dist/cli/main.d.ts +5 -0
- package/dist/cli/main.js +21 -2
- package/dist/cli/proxy.js +14 -9
- package/dist/cli/runtime.d.ts +5 -0
- package/dist/cli/startup-screen.js +20 -27
- package/dist/cli/startup-steps.js +6 -8
- package/dist/cli/subcommands/auth.d.ts +6 -3
- package/dist/cli/subcommands/auth.js +52 -22
- package/dist/cli/subcommands/config-set.d.ts +21 -0
- package/dist/cli/subcommands/config-set.js +137 -0
- package/dist/cli/subcommands/config.d.ts +2 -1
- package/dist/cli/subcommands/config.js +51 -37
- package/dist/cli/subcommands/doctor.d.ts +2 -1
- package/dist/cli/subcommands/doctor.js +97 -58
- package/dist/cli/subcommands/init.d.ts +1 -1
- package/dist/cli/subcommands/init.js +8 -7
- package/dist/cli/subcommands/memory.d.ts +18 -0
- package/dist/cli/subcommands/memory.js +189 -0
- package/dist/cli/subcommands/model-meta.js +11 -9
- package/dist/cli/subcommands/models-cache-probe.d.ts +1 -1
- package/dist/cli/subcommands/models-cache-probe.js +26 -32
- package/dist/cli/subcommands/models-discover.d.ts +3 -0
- package/dist/cli/subcommands/models-discover.js +44 -21
- package/dist/cli/subcommands/models.d.ts +1 -1
- package/dist/cli/subcommands/models.js +29 -22
- package/dist/cli/subcommands/probe-runner.js +8 -7
- package/dist/cli/subcommands/providers-list.js +32 -21
- package/dist/cli/subcommands/providers-plan.js +24 -25
- package/dist/cli/subcommands/providers-probe.js +5 -6
- package/dist/cli/subcommands/providers.d.ts +2 -2
- package/dist/cli/subcommands/providers.js +48 -59
- package/dist/cli/subcommands/sessions-export.d.ts +1 -1
- package/dist/cli/subcommands/sessions-export.js +10 -9
- package/dist/cli/subcommands/sessions-search.d.ts +1 -1
- package/dist/cli/subcommands/sessions-search.js +11 -10
- package/dist/cli/subcommands/sessions-trace.d.ts +30 -0
- package/dist/cli/subcommands/sessions-trace.js +156 -0
- package/dist/cli/subcommands/sessions.d.ts +4 -3
- package/dist/cli/subcommands/sessions.js +40 -37
- package/dist/cli/subcommands/stats.d.ts +1 -1
- package/dist/cli/subcommands/stats.js +49 -30
- package/dist/cli/system-prompt-arg.js +3 -2
- package/dist/codemode/capability.js +3 -2
- package/dist/compaction/post-compact.d.ts +1 -0
- package/dist/compaction/post-compact.js +15 -1
- package/dist/compaction/prune-tier.d.ts +1 -1
- package/dist/compaction/prune-tier.js +3 -3
- package/dist/compaction/serialize.js +2 -1
- package/dist/config/auth-file.d.ts +12 -2
- package/dist/config/auth-file.js +32 -10
- package/dist/config/checker.js +12 -11
- package/dist/config/context-files.js +3 -2
- package/dist/config/edit.d.ts +106 -0
- package/dist/config/edit.js +350 -0
- package/dist/config/init.d.ts +4 -3
- package/dist/config/init.js +10 -18
- package/dist/config/json-schema.d.ts +2 -1
- package/dist/config/json-schema.js +101 -68
- package/dist/config/key-docs.d.ts +18 -7
- package/dist/config/key-docs.js +43 -128
- package/dist/config/load.js +7 -6
- package/dist/config/merge.d.ts +4 -1
- package/dist/config/merge.js +42 -22
- package/dist/config/paths.js +6 -5
- package/dist/config/profile.d.ts +5 -1
- package/dist/config/profile.js +7 -2
- package/dist/config/schema-w5.js +3 -2
- package/dist/config/schema-w6.d.ts +19 -0
- package/dist/config/schema-w6.js +115 -0
- package/dist/config/schema.js +34 -20
- package/dist/config/settings-registry.d.ts +78 -0
- package/dist/config/settings-registry.js +184 -0
- package/dist/config/types-w6.d.ts +109 -0
- package/dist/config/types-w6.js +19 -0
- package/dist/config/types.d.ts +11 -8
- package/dist/config/types.js +1 -0
- package/dist/drivers/acp/client.js +1 -1
- package/dist/drivers/acp/driver.js +13 -8
- package/dist/drivers/agents.js +4 -3
- package/dist/drivers/base.js +3 -2
- package/dist/drivers/host-runners.js +2 -1
- package/dist/drivers/native/claude-stream.js +12 -11
- package/dist/drivers/native/codex-app-server.js +17 -12
- package/dist/drivers/native/oneshot.js +8 -7
- package/dist/drivers/pool.js +1 -1
- package/dist/drivers/runner.d.ts +3 -1
- package/dist/drivers/runner.js +68 -20
- package/dist/drivers/turn.js +1 -1
- package/dist/hooks/config.js +3 -2
- package/dist/hooks/protocol.js +18 -12
- package/dist/host/api-impl.js +11 -10
- package/dist/host/loader.js +9 -8
- package/dist/host/types.d.ts +3 -0
- package/dist/i18n/catalog.d.ts +2169 -0
- package/dist/i18n/catalog.js +72 -0
- package/dist/i18n/format.d.ts +21 -0
- package/dist/i18n/format.js +58 -0
- package/dist/i18n/index.d.ts +58 -0
- package/dist/i18n/index.js +72 -0
- package/dist/i18n/messages/agents.d.ts +84 -0
- package/dist/i18n/messages/agents.js +85 -0
- package/dist/i18n/messages/approval.d.ts +99 -0
- package/dist/i18n/messages/approval.js +100 -0
- package/dist/i18n/messages/auth.d.ts +187 -0
- package/dist/i18n/messages/auth.js +189 -0
- package/dist/i18n/messages/cli-args.d.ts +46 -0
- package/dist/i18n/messages/cli-args.js +46 -0
- package/dist/i18n/messages/cli-help.d.ts +12 -0
- package/dist/i18n/messages/cli-help.js +244 -0
- package/dist/i18n/messages/cli.d.ts +336 -0
- package/dist/i18n/messages/cli.js +311 -0
- package/dist/i18n/messages/config-keys.d.ts +289 -0
- package/dist/i18n/messages/config-keys.js +292 -0
- package/dist/i18n/messages/config.d.ts +502 -0
- package/dist/i18n/messages/config.js +239 -0
- package/dist/i18n/messages/drivers.d.ts +123 -0
- package/dist/i18n/messages/drivers.js +124 -0
- package/dist/i18n/messages/errors.d.ts +83 -0
- package/dist/i18n/messages/errors.js +171 -0
- package/dist/i18n/messages/interactive-line.d.ts +61 -0
- package/dist/i18n/messages/interactive-line.js +69 -0
- package/dist/i18n/messages/interactive-startup.d.ts +103 -0
- package/dist/i18n/messages/interactive-startup.js +104 -0
- package/dist/i18n/messages/interactive-view.d.ts +140 -0
- package/dist/i18n/messages/interactive-view.js +141 -0
- package/dist/i18n/messages/interactive.d.ts +493 -0
- package/dist/i18n/messages/interactive.js +248 -0
- package/dist/i18n/messages/memory.d.ts +123 -0
- package/dist/i18n/messages/memory.js +128 -0
- package/dist/i18n/messages/panels.d.ts +190 -0
- package/dist/i18n/messages/panels.js +189 -0
- package/dist/i18n/messages/permissions.d.ts +126 -0
- package/dist/i18n/messages/permissions.js +151 -0
- package/dist/i18n/messages/plan.d.ts +123 -0
- package/dist/i18n/messages/plan.js +124 -0
- package/dist/i18n/messages/print.d.ts +86 -0
- package/dist/i18n/messages/print.js +91 -0
- package/dist/i18n/messages/report.d.ts +391 -0
- package/dist/i18n/messages/report.js +490 -0
- package/dist/i18n/messages/rewind.d.ts +198 -0
- package/dist/i18n/messages/rewind.js +217 -0
- package/dist/i18n/messages/session.d.ts +230 -0
- package/dist/i18n/messages/session.js +258 -0
- package/dist/i18n/messages/settings.d.ts +348 -0
- package/dist/i18n/messages/settings.js +336 -0
- package/dist/i18n/messages/subcommands-config.d.ts +111 -0
- package/dist/i18n/messages/subcommands-config.js +127 -0
- package/dist/i18n/messages/subcommands.d.ts +548 -0
- package/dist/i18n/messages/subcommands.js +474 -0
- package/dist/i18n/messages/trace.d.ts +243 -0
- package/dist/i18n/messages/trace.js +238 -0
- package/dist/i18n/types.d.ts +15 -0
- package/dist/i18n/types.js +7 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +2 -0
- package/dist/memory/edit.d.ts +24 -0
- package/dist/memory/edit.js +63 -0
- package/dist/memory/frontmatter.d.ts +37 -0
- package/dist/memory/frontmatter.js +79 -0
- package/dist/memory/index.d.ts +28 -0
- package/dist/memory/index.js +126 -0
- package/dist/memory/lock.d.ts +17 -0
- package/dist/memory/lock.js +62 -0
- package/dist/memory/paths.d.ts +57 -0
- package/dist/memory/paths.js +175 -0
- package/dist/memory/report.d.ts +36 -0
- package/dist/memory/report.js +86 -0
- package/dist/memory/runtime.d.ts +42 -0
- package/dist/memory/runtime.js +36 -0
- package/dist/memory/secrets.d.ts +8 -0
- package/dist/memory/secrets.js +27 -0
- package/dist/memory/section.d.ts +28 -0
- package/dist/memory/section.js +59 -0
- package/dist/memory/store.d.ts +70 -0
- package/dist/memory/store.js +284 -0
- package/dist/memory/tool.d.ts +31 -0
- package/dist/memory/tool.js +94 -0
- package/dist/modes/acp/acp-events.js +2 -1
- package/dist/modes/acp/acp-server.js +13 -12
- package/dist/modes/commands-core.d.ts +17 -0
- package/dist/modes/commands-core.js +101 -61
- package/dist/modes/image-input.js +20 -6
- package/dist/modes/interactive/agent-bar.d.ts +95 -0
- package/dist/modes/interactive/agent-bar.js +248 -0
- package/dist/modes/interactive/agent-panels.js +27 -26
- package/dist/modes/interactive/agent-transcript.d.ts +47 -0
- package/dist/modes/interactive/agent-transcript.js +191 -0
- package/dist/modes/interactive/agent-ui.d.ts +36 -1
- package/dist/modes/interactive/agent-ui.js +180 -14
- package/dist/modes/interactive/agent-view.d.ts +72 -0
- package/dist/modes/interactive/agent-view.js +281 -0
- package/dist/modes/interactive/approval-dialog.js +46 -34
- package/dist/modes/interactive/clipboard-paste.d.ts +2 -2
- package/dist/modes/interactive/clipboard-paste.js +9 -4
- package/dist/modes/interactive/commands.d.ts +22 -1
- package/dist/modes/interactive/commands.js +93 -38
- package/dist/modes/interactive/completion.js +2 -1
- package/dist/modes/interactive/config-panel.d.ts +70 -0
- package/dist/modes/interactive/config-panel.js +319 -0
- package/dist/modes/interactive/config-ui.d.ts +96 -0
- package/dist/modes/interactive/config-ui.js +397 -0
- package/dist/modes/interactive/confirm-dialog.d.ts +49 -0
- package/dist/modes/interactive/confirm-dialog.js +120 -0
- package/dist/modes/interactive/event-notices.js +11 -9
- package/dist/modes/interactive/interactive-mode.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode.js +25 -22
- package/dist/modes/interactive/key-dispatch.d.ts +18 -0
- package/dist/modes/interactive/key-dispatch.js +39 -13
- package/dist/modes/interactive/line/line-editor.js +2 -1
- package/dist/modes/interactive/line/line-mode.d.ts +2 -0
- package/dist/modes/interactive/line/line-mode.js +24 -4
- package/dist/modes/interactive/line/line-render.js +25 -24
- package/dist/modes/interactive/memory-panel.d.ts +64 -0
- package/dist/modes/interactive/memory-panel.js +221 -0
- package/dist/modes/interactive/message-view.d.ts +4 -2
- package/dist/modes/interactive/message-view.js +42 -33
- package/dist/modes/interactive/panels.js +39 -31
- package/dist/modes/interactive/pickers.d.ts +2 -1
- package/dist/modes/interactive/pickers.js +10 -6
- package/dist/modes/interactive/plan-command.d.ts +1 -1
- package/dist/modes/interactive/plan-command.js +24 -27
- package/dist/modes/interactive/plan-dialog.js +18 -17
- package/dist/modes/interactive/plan-flow.js +6 -5
- package/dist/modes/interactive/rewind-command.d.ts +1 -1
- package/dist/modes/interactive/rewind-command.js +18 -16
- package/dist/modes/interactive/rewind-flow.d.ts +0 -1
- package/dist/modes/interactive/rewind-flow.js +13 -14
- package/dist/modes/interactive/rewind-list.js +7 -6
- package/dist/modes/interactive/rewind-panel.js +40 -40
- package/dist/modes/interactive/rewind-text.d.ts +5 -3
- package/dist/modes/interactive/rewind-text.js +48 -38
- package/dist/modes/interactive/run-indicator.js +15 -12
- package/dist/modes/interactive/session-events.js +3 -2
- package/dist/modes/interactive/startup-header.js +22 -23
- package/dist/modes/interactive/startup-ui.js +41 -29
- package/dist/modes/interactive/status-area.d.ts +2 -0
- package/dist/modes/interactive/status-area.js +8 -2
- package/dist/modes/interactive/status-bar.js +4 -3
- package/dist/modes/interactive/subagent-view.js +9 -7
- package/dist/modes/interactive/tasks-report.d.ts +6 -0
- package/dist/modes/interactive/tasks-report.js +28 -31
- package/dist/modes/interactive/terminal-setup.d.ts +9 -0
- package/dist/modes/interactive/terminal-setup.js +23 -0
- package/dist/modes/interactive/tool-summary.js +19 -17
- package/dist/modes/interactive/tool-view.js +7 -4
- package/dist/modes/interactive/trace-view.d.ts +89 -0
- package/dist/modes/interactive/trace-view.js +332 -0
- package/dist/modes/print/print-mode.js +14 -15
- package/dist/modes/rpc/commands.js +7 -3
- package/dist/modes/rpc/rpc-mode.js +9 -3
- package/dist/modes/session-report.d.ts +2 -0
- package/dist/modes/session-report.js +101 -105
- package/dist/modes/startup-ui-text.js +11 -6
- package/dist/permissions/bypass.d.ts +30 -0
- package/dist/permissions/bypass.js +45 -0
- package/dist/permissions/memory-class.d.ts +23 -0
- package/dist/permissions/memory-class.js +54 -0
- package/dist/permissions/modes.d.ts +3 -3
- package/dist/permissions/modes.js +21 -16
- package/dist/permissions/pipeline.d.ts +1 -1
- package/dist/permissions/pipeline.js +9 -2
- package/dist/permissions/preview.js +49 -42
- package/dist/permissions/rules.js +5 -2
- package/dist/permissions/types.d.ts +4 -0
- package/dist/plan/store.js +2 -1
- package/dist/rpc.d.ts +39 -1
- package/dist/rpc.js +3 -0
- package/dist/sandbox/bash.js +11 -8
- package/dist/sandbox/detect.js +14 -11
- package/dist/sdk.d.ts +17 -1
- package/dist/sdk.js +29 -7
- package/dist/session/export.js +31 -30
- package/dist/session/manager.d.ts +1 -1
- package/dist/session/manager.js +5 -3
- package/dist/session/reuse.js +5 -4
- package/dist/session/scan.js +3 -2
- package/dist/session/stats-aggregate.d.ts +3 -1
- package/dist/session/stats-aggregate.js +5 -1
- package/dist/session/stats-index.js +2 -1
- package/dist/session/stats-scan.d.ts +4 -1
- package/dist/session/stats-scan.js +6 -2
- package/dist/session/store.d.ts +11 -0
- package/dist/session/store.js +48 -1
- package/dist/session/types.d.ts +2 -0
- package/dist/skills/builtin.js +2 -1
- package/dist/tools/image-file.d.ts +26 -1
- package/dist/tools/image-file.js +55 -13
- package/dist/tools/presets.d.ts +14 -1
- package/dist/tools/presets.js +3 -3
- package/dist/tools/registry.js +1 -1
- package/dist/tools/truncate.d.ts +1 -1
- package/dist/tools/truncate.js +2 -2
- package/dist/tools/types.d.ts +17 -1
- package/dist/trace/build-index.d.ts +91 -0
- package/dist/trace/build-index.js +127 -0
- package/dist/trace/build-nodes.d.ts +24 -0
- package/dist/trace/build-nodes.js +279 -0
- package/dist/trace/build-util.d.ts +43 -0
- package/dist/trace/build-util.js +120 -0
- package/dist/trace/build.d.ts +82 -0
- package/dist/trace/build.js +382 -0
- package/dist/trace/detail.d.ts +35 -0
- package/dist/trace/detail.js +205 -0
- package/dist/trace/flatten.d.ts +69 -0
- package/dist/trace/flatten.js +173 -0
- package/dist/trace/format.d.ts +47 -0
- package/dist/trace/format.js +329 -0
- package/dist/trace/html-template.d.ts +19 -0
- package/dist/trace/html-template.js +150 -0
- package/dist/trace/html.d.ts +104 -0
- package/dist/trace/html.js +292 -0
- package/dist/trace/preview.d.ts +29 -0
- package/dist/trace/preview.js +59 -0
- package/dist/trace/query-session.d.ts +14 -0
- package/dist/trace/query-session.js +38 -0
- package/dist/trace/query.d.ts +55 -0
- package/dist/trace/query.js +188 -0
- package/dist/trace/session.d.ts +40 -0
- package/dist/trace/session.js +168 -0
- package/dist/trace/types.d.ts +243 -0
- package/dist/trace/types.js +13 -0
- package/dist/tui/components/editor-paste.d.ts +2 -0
- package/dist/tui/components/editor-paste.js +6 -3
- package/dist/tui/components/editor.js +2 -2
- package/dist/tui/components/loader.d.ts +3 -0
- package/dist/tui/components/loader.js +14 -0
- package/dist/tui/components/settings-list.d.ts +61 -0
- package/dist/tui/components/settings-list.js +135 -0
- package/dist/tui/keybindings.d.ts +6 -1
- package/dist/tui/keybindings.js +18 -6
- package/dist/tui.d.ts +1 -0
- package/dist/tui.js +2 -0
- package/docs/en/host-api.md +167 -0
- package/docs/en/permissions.md +214 -0
- package/docs/en/providers.md +625 -0
- package/docs/en/rpc.md +361 -0
- package/docs/en/sessions.md +219 -0
- package/docs/en/tui.md +527 -0
- package/docs/host-api.md +18 -17
- package/docs/memory.md +172 -0
- package/docs/permissions.md +3 -2
- package/docs/providers.md +67 -1
- package/docs/rpc.md +31 -3
- package/docs/session-format.md +8 -2
- package/docs/sessions.md +29 -1
- package/docs/tui.md +189 -21
- package/package.json +8 -3
package/dist/config/merge.js
CHANGED
|
@@ -8,12 +8,14 @@
|
|
|
8
8
|
* auto / full-auto)、
|
|
9
9
|
* `compaction`、`tools.disabled`、`tools.preset`(只能更严)、`codemode.mode: "off"`、`ui`、
|
|
10
10
|
* `checkpoints.mode: "off"`、`checkpoints.maxFileBytes`(只能调小)、(W5-C0)`plan.bash`(只能更严)、
|
|
11
|
-
* `reminders`;`compaction.prune / pruneExclude`
|
|
11
|
+
* `reminders`;`compaction.prune / pruneExclude` 与第五波其余段只认用户级;(W6-C0)`ui.language` /
|
|
12
|
+
* `ui.agentBar` 随 `ui` 段、`memory.enabled: false`;`ui.replyLanguage`、`memory` 其余键、`auth` 只认用户级;
|
|
12
13
|
* 其它字段与放宽项(含 `permission.builtinDeny / autoModel / autoSafeCommands`)被忽略并记 warning。
|
|
13
14
|
* - 同时产出带来源的权限规则清单(`ruleSpecs`),交给权限管线(B3 的 rules.ts 解析)。
|
|
14
15
|
*/
|
|
15
16
|
import { CONFIG_FILE_VERSION, DEFAULT_CHECKPOINTS_CONFIG, PLAN_BASH_MODES_STRICT_FIRST, TOOLS_PRESETS_STRICT_FIRST, canonicalPreset, } from "./types.js";
|
|
16
17
|
import { isAtLeastAsStrict } from "../permissions/rules.js";
|
|
18
|
+
import { msg } from "../i18n/index.js";
|
|
17
19
|
export const DEFAULT_CONFIG = Object.freeze({
|
|
18
20
|
version: CONFIG_FILE_VERSION,
|
|
19
21
|
thinkingLevel: "medium",
|
|
@@ -33,8 +35,8 @@ export const DEFAULT_CONFIG = Object.freeze({
|
|
|
33
35
|
});
|
|
34
36
|
/** 嵌入宿主(有 profile)时的缺省覆盖(§12.10)。 */
|
|
35
37
|
export const PROFILE_DEFAULTS = Object.freeze({
|
|
36
|
-
// [W5-A] 嵌入宿主以「最后一行 =
|
|
37
|
-
ui: { quietStartup: "header", statusLine: "compact" },
|
|
38
|
+
// [W5-A] 嵌入宿主以「最后一行 = 状态栏」锚定,底部信息行缺省单行;[W6-C0] 宿主自己展示节点,Agent 栏缺省关
|
|
39
|
+
ui: { quietStartup: "header", statusLine: "compact", agentBar: "off" },
|
|
38
40
|
});
|
|
39
41
|
/** 层名 → 规则来源(RuleSource)。 */
|
|
40
42
|
const RULE_SOURCE = {
|
|
@@ -109,7 +111,7 @@ export function restrictProjectConfig(project, currentMode, label = ".ama/config
|
|
|
109
111
|
if (project.compaction !== undefined) {
|
|
110
112
|
const { prune, pruneExclude, ...rest } = structuredClone(project.compaction);
|
|
111
113
|
if (prune !== undefined || pruneExclude !== undefined)
|
|
112
|
-
warnings.push(
|
|
114
|
+
warnings.push(msg().config.merge.projectIgnored(label, "compaction.prune / pruneExclude"));
|
|
113
115
|
if (Object.keys(rest).length > 0)
|
|
114
116
|
accepted.compaction = rest;
|
|
115
117
|
}
|
|
@@ -125,15 +127,29 @@ export function restrictProjectConfig(project, currentMode, label = ".ama/config
|
|
|
125
127
|
break;
|
|
126
128
|
}
|
|
127
129
|
case "ui":
|
|
128
|
-
if (project.ui !== undefined)
|
|
129
|
-
|
|
130
|
+
if (project.ui !== undefined) {
|
|
131
|
+
// [W6-C0] 回复语言改的是发给模型的规则,只认用户级 / profile
|
|
132
|
+
const { replyLanguage, ...rest } = structuredClone(project.ui);
|
|
133
|
+
if (replyLanguage !== undefined)
|
|
134
|
+
warnings.push(msg().config.merge.projectIgnored(label, "ui.replyLanguage"));
|
|
135
|
+
accepted.ui = rest;
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
case "memory": {
|
|
139
|
+
// [W6-C0] 记忆不由仓库决定:项目级只能关闭(D9)
|
|
140
|
+
const memory = project.memory ?? {};
|
|
141
|
+
if (Object.keys(memory).some((k) => k !== "enabled") || memory.enabled === true)
|
|
142
|
+
warnings.push(msg().config.merge.projectMemoryOnlyDisable(label));
|
|
143
|
+
if (memory.enabled === false)
|
|
144
|
+
accepted.memory = { enabled: false };
|
|
130
145
|
break;
|
|
146
|
+
}
|
|
131
147
|
case "tools": {
|
|
132
148
|
const tools = project.tools ?? {};
|
|
133
149
|
const result = {};
|
|
134
150
|
for (const sub of Object.keys(tools)) {
|
|
135
151
|
if (sub !== "disabled" && sub !== "preset")
|
|
136
|
-
warnings.push(
|
|
152
|
+
warnings.push(msg().config.merge.projectOnlyKeys(label, "tools.disabled / tools.preset", `tools.${sub}`));
|
|
137
153
|
}
|
|
138
154
|
if (tools.disabled !== undefined)
|
|
139
155
|
result.disabled = [...tools.disabled];
|
|
@@ -141,7 +157,7 @@ export function restrictProjectConfig(project, currentMode, label = ".ama/config
|
|
|
141
157
|
if (isPresetStricterOrEqual(tools.preset, currentPreset))
|
|
142
158
|
result.preset = tools.preset;
|
|
143
159
|
else
|
|
144
|
-
warnings.push(
|
|
160
|
+
warnings.push(msg().config.merge.projectPresetLoosen(label, tools.preset, currentPreset));
|
|
145
161
|
}
|
|
146
162
|
if (Object.keys(result).length > 0)
|
|
147
163
|
accepted.tools = result;
|
|
@@ -152,7 +168,8 @@ export function restrictProjectConfig(project, currentMode, label = ".ama/config
|
|
|
152
168
|
for (const [sub, v] of Object.entries(codemode)) {
|
|
153
169
|
if (sub === "mode" && v === "off")
|
|
154
170
|
continue;
|
|
155
|
-
|
|
171
|
+
const ignored = `codemode.${sub}${sub === "mode" ? ` ${String(v)}` : ""}`;
|
|
172
|
+
warnings.push(msg().config.merge.projectOnlyValue(label, "codemode.mode", "off", ignored));
|
|
156
173
|
}
|
|
157
174
|
if (codemode.mode === "off")
|
|
158
175
|
accepted.codemode = { mode: "off" };
|
|
@@ -177,14 +194,15 @@ export function restrictProjectConfig(project, currentMode, label = ".ama/config
|
|
|
177
194
|
for (const [sub, v] of Object.entries(sandbox)) {
|
|
178
195
|
if (sub === "network" && v === "deny")
|
|
179
196
|
continue;
|
|
180
|
-
|
|
197
|
+
const ignored = `sandbox.${sub}${sub === "network" ? ` ${String(v)}` : ""}`;
|
|
198
|
+
warnings.push(msg().config.merge.projectOnlyValue(label, "sandbox.network", "deny", ignored));
|
|
181
199
|
}
|
|
182
200
|
if (sandbox.network === "deny")
|
|
183
201
|
accepted.sandbox = { network: "deny" };
|
|
184
202
|
break;
|
|
185
203
|
}
|
|
186
204
|
default:
|
|
187
|
-
warnings.push(
|
|
205
|
+
warnings.push(msg().config.merge.projectIgnored(label, key));
|
|
188
206
|
}
|
|
189
207
|
}
|
|
190
208
|
return { accepted, warnings };
|
|
@@ -193,14 +211,14 @@ export function restrictProjectConfig(project, currentMode, label = ".ama/config
|
|
|
193
211
|
function restrictPlan(plan, current, label, warnings) {
|
|
194
212
|
for (const sub of Object.keys(plan)) {
|
|
195
213
|
if (sub !== "bash")
|
|
196
|
-
warnings.push(
|
|
214
|
+
warnings.push(msg().config.merge.projectOnlyKeys(label, "plan.bash", `plan.${sub}`));
|
|
197
215
|
}
|
|
198
216
|
if (plan.bash === undefined)
|
|
199
217
|
return undefined;
|
|
200
218
|
const order = PLAN_BASH_MODES_STRICT_FIRST;
|
|
201
219
|
if (order.indexOf(plan.bash) <= order.indexOf(current))
|
|
202
220
|
return { bash: plan.bash };
|
|
203
|
-
warnings.push(
|
|
221
|
+
warnings.push(msg().config.merge.projectPlanBashTighten(label, plan.bash, current));
|
|
204
222
|
return undefined;
|
|
205
223
|
}
|
|
206
224
|
/** 项目级检查点:只能关闭、只能调小单文件上限(多备份即多占用户磁盘);`keep` 只认用户级。 */
|
|
@@ -211,16 +229,16 @@ function restrictCheckpoints(checkpoints, currentMaxFileBytes, label, warnings)
|
|
|
211
229
|
if (v === "off")
|
|
212
230
|
result.mode = "off";
|
|
213
231
|
else
|
|
214
|
-
warnings.push(
|
|
232
|
+
warnings.push(msg().config.merge.projectOnlyValue(label, "checkpoints.mode", "off", String(v)));
|
|
215
233
|
}
|
|
216
234
|
else if (sub === "maxFileBytes" && typeof v === "number") {
|
|
217
235
|
if (v <= currentMaxFileBytes)
|
|
218
236
|
result.maxFileBytes = v;
|
|
219
237
|
else
|
|
220
|
-
warnings.push(
|
|
238
|
+
warnings.push(msg().config.merge.projectLowerOnly(label, "checkpoints.maxFileBytes", v, currentMaxFileBytes));
|
|
221
239
|
}
|
|
222
240
|
else {
|
|
223
|
-
warnings.push(
|
|
241
|
+
warnings.push(msg().config.merge.projectIgnored(label, `checkpoints.${sub}`));
|
|
224
242
|
}
|
|
225
243
|
}
|
|
226
244
|
return Object.keys(result).length > 0 ? result : undefined;
|
|
@@ -228,28 +246,28 @@ function restrictCheckpoints(checkpoints, currentMaxFileBytes, label, warnings)
|
|
|
228
246
|
function restrictPermission(permission, currentMode, label, warnings) {
|
|
229
247
|
const result = {};
|
|
230
248
|
if (permission.allow !== undefined && permission.allow.length > 0) {
|
|
231
|
-
warnings.push(
|
|
249
|
+
warnings.push(msg().config.merge.projectNoAllow(label, permission.allow.join(", ")));
|
|
232
250
|
}
|
|
233
251
|
if (permission.deny !== undefined && permission.deny.length > 0)
|
|
234
252
|
result.deny = [...permission.deny];
|
|
235
253
|
if (permission.builtinDeny !== undefined) {
|
|
236
|
-
warnings.push(
|
|
254
|
+
warnings.push(msg().config.merge.projectNoBuiltinDeny(label));
|
|
237
255
|
}
|
|
238
256
|
if (permission.autoModel !== undefined) {
|
|
239
|
-
warnings.push(
|
|
257
|
+
warnings.push(msg().config.merge.projectIgnored(label, "permission.autoModel"));
|
|
240
258
|
}
|
|
241
259
|
if (permission.autoSafeCommands !== undefined && permission.autoSafeCommands.length > 0) {
|
|
242
|
-
warnings.push(
|
|
260
|
+
warnings.push(msg().config.merge.projectNoAutoSafe(label));
|
|
243
261
|
}
|
|
244
262
|
if (permission.mode === "auto" || permission.mode === "full-auto") {
|
|
245
|
-
warnings.push(
|
|
263
|
+
warnings.push(msg().config.merge.projectModeLoosen(label, permission.mode));
|
|
246
264
|
}
|
|
247
265
|
else if (permission.mode !== undefined) {
|
|
248
266
|
if (isAtLeastAsStrict(permission.mode, currentMode)) {
|
|
249
267
|
result.mode = permission.mode;
|
|
250
268
|
}
|
|
251
269
|
else {
|
|
252
|
-
warnings.push(
|
|
270
|
+
warnings.push(msg().config.merge.projectModeTighten(label, permission.mode, currentMode));
|
|
253
271
|
}
|
|
254
272
|
}
|
|
255
273
|
return Object.keys(result).length > 0 ? result : undefined;
|
|
@@ -278,6 +296,8 @@ export function cliOverridesToConfig(cli) {
|
|
|
278
296
|
out.tools = { preset: cli.toolsPreset };
|
|
279
297
|
if (cli.codemode !== undefined)
|
|
280
298
|
out.codemode = { mode: cli.codemode };
|
|
299
|
+
if (cli.memory !== undefined)
|
|
300
|
+
out.memory = { enabled: cli.memory };
|
|
281
301
|
return out;
|
|
282
302
|
}
|
|
283
303
|
function collectRules(layer, permission) {
|
package/dist/config/paths.js
CHANGED
|
@@ -9,6 +9,7 @@ import { accessSync, constants, mkdirSync, statSync } from "node:fs";
|
|
|
9
9
|
import { homedir } from "node:os";
|
|
10
10
|
import { isAbsolute, join, resolve } from "node:path";
|
|
11
11
|
import { StartupError } from "../errors.js";
|
|
12
|
+
import { msg } from "../i18n/index.js";
|
|
12
13
|
/** 与 cli/exit-codes.ts 的 Config 相同;config 层不反向依赖 cli 的值。 */
|
|
13
14
|
const EXIT_CONFIG = 3;
|
|
14
15
|
export const CONFIG_FILE = "config.json";
|
|
@@ -87,18 +88,18 @@ export function ensureDir(dir, label) {
|
|
|
87
88
|
try {
|
|
88
89
|
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
89
90
|
if (!statSync(dir).isDirectory())
|
|
90
|
-
throw new Error(
|
|
91
|
+
throw new Error(msg().config.paths.notDirectory);
|
|
91
92
|
accessSync(dir, constants.W_OK);
|
|
92
93
|
}
|
|
93
94
|
catch (error) {
|
|
94
|
-
throw new StartupError("config_invalid",
|
|
95
|
+
throw new StartupError("config_invalid", msg().config.paths.notWritable(label, dir, error instanceof Error ? error.message : String(error)), EXIT_CONFIG, { cause: error });
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
/** 第 5 步:建 configDir / dataDir / sessionDir。 */
|
|
98
99
|
export function ensurePaths(paths) {
|
|
99
|
-
ensureDir(paths.configDir,
|
|
100
|
-
ensureDir(paths.dataDir,
|
|
101
|
-
ensureDir(paths.sessionDir,
|
|
100
|
+
ensureDir(paths.configDir, msg().config.paths.configDir);
|
|
101
|
+
ensureDir(paths.dataDir, msg().config.paths.dataDir);
|
|
102
|
+
ensureDir(paths.sessionDir, msg().config.paths.sessionDir);
|
|
102
103
|
}
|
|
103
104
|
export function userFile(paths, name) {
|
|
104
105
|
return join(paths.configDir, name);
|
package/dist/config/profile.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* profile 的字段等价于对应命令行参数;命令行显式参数优先(合并在 cli/bootstrap.ts)。
|
|
5
5
|
* 文件不存在 / 版本不符 / 路径不是绝对路径 → StartupError(退出码 3)。profile 不含密钥。
|
|
6
6
|
*/
|
|
7
|
-
import type { AmaConfig } from "./types.js";
|
|
7
|
+
import type { AmaConfig, ProfileMemoryOptions } from "./types.js";
|
|
8
8
|
/** profile 展开后的等价参数(全部为绝对路径)。 */
|
|
9
9
|
export interface ProfileOptions {
|
|
10
10
|
path: string;
|
|
@@ -24,6 +24,10 @@ export interface ProfileOptions {
|
|
|
24
24
|
/** profile.config 的内容(已校验)。 */
|
|
25
25
|
config?: AmaConfig;
|
|
26
26
|
trustProject: boolean;
|
|
27
|
+
/** [W6-C0] 宿主界面语言。 */
|
|
28
|
+
language?: "zh" | "en";
|
|
29
|
+
/** [W6-C0] 记忆(W6-M):按工作空间隔离的目录(已校验为绝对路径)。 */
|
|
30
|
+
memory?: ProfileMemoryOptions;
|
|
27
31
|
warnings: string[];
|
|
28
32
|
}
|
|
29
33
|
export declare function loadProfile(path: string, cwd?: string): ProfileOptions;
|
package/dist/config/profile.js
CHANGED
|
@@ -8,12 +8,13 @@ import { isAbsolute, resolve } from "node:path";
|
|
|
8
8
|
import { StartupError } from "../errors.js";
|
|
9
9
|
import { loadConfigFile } from "./load.js";
|
|
10
10
|
import { PROFILE_PATH_FIELDS, PROFILE_PATH_LIST_FIELDS } from "./schema.js";
|
|
11
|
+
import { msg } from "../i18n/index.js";
|
|
11
12
|
const EXIT_CONFIG = 3;
|
|
12
13
|
export function loadProfile(path, cwd = process.cwd()) {
|
|
13
14
|
const abs = resolve(cwd, path);
|
|
14
15
|
const loaded = loadConfigFile("profile", abs, { required: true });
|
|
15
16
|
if (loaded === undefined) {
|
|
16
|
-
throw new StartupError("profile_invalid",
|
|
17
|
+
throw new StartupError("profile_invalid", msg().config.profile.notFound(abs), EXIT_CONFIG);
|
|
17
18
|
}
|
|
18
19
|
const profile = loaded.value;
|
|
19
20
|
const relative = [];
|
|
@@ -29,7 +30,7 @@ export function loadProfile(path, cwd = process.cwd()) {
|
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
if (relative.length > 0) {
|
|
32
|
-
throw new StartupError("profile_invalid",
|
|
33
|
+
throw new StartupError("profile_invalid", msg().config.profile.relativePaths(abs, relative), EXIT_CONFIG);
|
|
33
34
|
}
|
|
34
35
|
const options = profileToOptions(abs, profile, loaded.warnings);
|
|
35
36
|
if (profile.config !== undefined) {
|
|
@@ -63,5 +64,9 @@ function profileToOptions(path, profile, warnings) {
|
|
|
63
64
|
options.sessionDir = profile.sessionDir;
|
|
64
65
|
if (profile.config !== undefined)
|
|
65
66
|
options.configFile = profile.config;
|
|
67
|
+
if (profile.language !== undefined)
|
|
68
|
+
options.language = profile.language;
|
|
69
|
+
if (profile.memory !== undefined)
|
|
70
|
+
options.memory = { ...profile.memory };
|
|
66
71
|
return options;
|
|
67
72
|
}
|
package/dist/config/schema-w5.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* 未知字段是 warning。只校验形状;行为由各批次实现。
|
|
6
6
|
*/
|
|
7
7
|
import { PERMISSION_MODES_STRICT_FIRST } from "../permissions/types.js";
|
|
8
|
+
import { msg } from "../i18n/index.js";
|
|
8
9
|
import { Checker, THINKING_LEVELS, checkSection, join } from "./checker.js";
|
|
9
10
|
import { AGENTS_RESERVED_KEYS, IMAGE_RESIZE_MODES, PLAN_BASH_MODES_STRICT_FIRST, PLAN_UNATTENDED_MODES, STATUS_LINE_MODES, } from "./types-w5.js";
|
|
10
11
|
/** 第五波新增的顶层键(schema.ts 的 CONFIG_KEYS 并入)。 */
|
|
@@ -38,7 +39,7 @@ export function checkCompactionW5(c, compaction, path) {
|
|
|
38
39
|
c.number(prune, "keepResults", p, 0);
|
|
39
40
|
const clear = prune["clearAtLeast"];
|
|
40
41
|
if (clear !== undefined && clear !== "auto" && (typeof clear !== "number" || clear < 0))
|
|
41
|
-
c.error(join(p, "clearAtLeast"),
|
|
42
|
+
c.error(join(p, "clearAtLeast"), msg().config.schema.clearAtLeast);
|
|
42
43
|
}
|
|
43
44
|
function checkAgentEntry(c, entry, path) {
|
|
44
45
|
if (!c.object(entry, path))
|
|
@@ -66,7 +67,7 @@ function checkAgents(c, config) {
|
|
|
66
67
|
continue;
|
|
67
68
|
const p = join("agents", id);
|
|
68
69
|
if (!AGENT_ID_PATTERN.test(id))
|
|
69
|
-
c.error(p,
|
|
70
|
+
c.error(p, msg().config.schema.agentId);
|
|
70
71
|
else
|
|
71
72
|
checkAgentEntry(c, entry, p);
|
|
72
73
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 第六波配置键的校验(docs/wave6-plan.md §7;规则与 json-schema.ts 一一对应,json-schema.test.ts 守住)。[W6-C0]
|
|
3
|
+
*
|
|
4
|
+
* 类型 / 取值错误是 error,未知字段是 warning。只校验形状;行为由各批次实现。
|
|
5
|
+
*/
|
|
6
|
+
import { type Checker, type Obj } from "./checker.js";
|
|
7
|
+
/** 第六波新增的顶层键(schema.ts 的 CONFIG_KEYS 并入)。 */
|
|
8
|
+
export declare const W6_CONFIG_KEYS: readonly ["memory", "auth"];
|
|
9
|
+
/** 已有 `ui` 段新增的键。 */
|
|
10
|
+
export declare const W6_UI_KEYS: readonly ["language", "replyLanguage", "agentBar"];
|
|
11
|
+
export declare const MEMORY_KEYS: readonly ["enabled", "scopes", "indexMaxBytes", "fileMaxBytes", "maxFiles", "subagents"];
|
|
12
|
+
export declare const CHATGPT_AUTH_KEYS: readonly ["flavor", "clientId", "issuer", "originator", "redirectPorts"];
|
|
13
|
+
export declare function checkUiW6(c: Checker, ui: Obj, path: string): void;
|
|
14
|
+
/** 第六波顶层段的校验(validateConfig 末尾调用)。 */
|
|
15
|
+
export declare function validateConfigW6(c: Checker, config: Obj): void;
|
|
16
|
+
/** auth.json 的 OAuth 条目(`type: "oauth"`,W6-O):只查形状,不碰 token 内容。 */
|
|
17
|
+
export declare function checkOAuthEntry(c: Checker, entry: Obj, path: string): void;
|
|
18
|
+
/** profile.json 的 `memory`(D11):`enabled: true` 时 `dir` 必填且为绝对路径。 */
|
|
19
|
+
export declare function checkProfileMemory(c: Checker, profile: Obj): void;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 第六波配置键的校验(docs/wave6-plan.md §7;规则与 json-schema.ts 一一对应,json-schema.test.ts 守住)。[W6-C0]
|
|
3
|
+
*
|
|
4
|
+
* 类型 / 取值错误是 error,未知字段是 warning。只校验形状;行为由各批次实现。
|
|
5
|
+
*/
|
|
6
|
+
import { isAbsolute } from "node:path";
|
|
7
|
+
import { msg } from "../i18n/index.js";
|
|
8
|
+
import { checkSection, join } from "./checker.js";
|
|
9
|
+
import { AGENT_BAR_MODES, CHATGPT_FLAVORS, LANGUAGE_SETTINGS, MEMORY_SCOPES, MEMORY_SUBAGENT_MODES, } from "./types-w6.js";
|
|
10
|
+
/** 第六波新增的顶层键(schema.ts 的 CONFIG_KEYS 并入)。 */
|
|
11
|
+
export const W6_CONFIG_KEYS = ["memory", "auth"];
|
|
12
|
+
/** 已有 `ui` 段新增的键。 */
|
|
13
|
+
export const W6_UI_KEYS = ["language", "replyLanguage", "agentBar"];
|
|
14
|
+
export const MEMORY_KEYS = [
|
|
15
|
+
"enabled",
|
|
16
|
+
"scopes",
|
|
17
|
+
"indexMaxBytes",
|
|
18
|
+
"fileMaxBytes",
|
|
19
|
+
"maxFiles",
|
|
20
|
+
"subagents",
|
|
21
|
+
];
|
|
22
|
+
export const CHATGPT_AUTH_KEYS = [
|
|
23
|
+
"flavor",
|
|
24
|
+
"clientId",
|
|
25
|
+
"issuer",
|
|
26
|
+
"originator",
|
|
27
|
+
"redirectPorts",
|
|
28
|
+
];
|
|
29
|
+
export function checkUiW6(c, ui, path) {
|
|
30
|
+
c.oneOf(ui, "language", path, LANGUAGE_SETTINGS);
|
|
31
|
+
c.string(ui, "replyLanguage", path);
|
|
32
|
+
c.oneOf(ui, "agentBar", path, AGENT_BAR_MODES);
|
|
33
|
+
}
|
|
34
|
+
function checkEnumArray(c, value, key, path, choices) {
|
|
35
|
+
const v = value[key];
|
|
36
|
+
if (v === undefined)
|
|
37
|
+
return;
|
|
38
|
+
if (!Array.isArray(v) || v.some((item) => typeof item !== "string" || !choices.includes(item)))
|
|
39
|
+
c.error(join(path, key), msg().config.schema.enumArray(choices));
|
|
40
|
+
}
|
|
41
|
+
function checkPorts(c, value, key, path) {
|
|
42
|
+
const v = value[key];
|
|
43
|
+
if (v === undefined)
|
|
44
|
+
return;
|
|
45
|
+
if (!Array.isArray(v) ||
|
|
46
|
+
v.some((item) => typeof item !== "number" || !Number.isInteger(item) || item < 0 || item > 65535))
|
|
47
|
+
c.error(join(path, key), msg().config.schema.ports);
|
|
48
|
+
}
|
|
49
|
+
/** 第六波顶层段的校验(validateConfig 末尾调用)。 */
|
|
50
|
+
export function validateConfigW6(c, config) {
|
|
51
|
+
checkSection(c, config, "memory", MEMORY_KEYS, (s, p) => {
|
|
52
|
+
c.boolean(s, "enabled", p);
|
|
53
|
+
checkEnumArray(c, s, "scopes", p, MEMORY_SCOPES);
|
|
54
|
+
c.number(s, "indexMaxBytes", p, 0, 1_048_576);
|
|
55
|
+
c.number(s, "fileMaxBytes", p, 1, 1_048_576);
|
|
56
|
+
c.number(s, "maxFiles", p, 1, 10_000);
|
|
57
|
+
c.oneOf(s, "subagents", p, MEMORY_SUBAGENT_MODES);
|
|
58
|
+
});
|
|
59
|
+
checkSection(c, config, "auth", ["chatgpt"], (s, p) => {
|
|
60
|
+
const chatgpt = s["chatgpt"];
|
|
61
|
+
const cp = join(p, "chatgpt");
|
|
62
|
+
if (chatgpt === undefined || !c.object(chatgpt, cp))
|
|
63
|
+
return;
|
|
64
|
+
c.keys(chatgpt, cp, CHATGPT_AUTH_KEYS);
|
|
65
|
+
c.oneOf(chatgpt, "flavor", cp, CHATGPT_FLAVORS);
|
|
66
|
+
for (const key of ["clientId", "issuer", "originator"])
|
|
67
|
+
c.string(chatgpt, key, cp);
|
|
68
|
+
checkPorts(c, chatgpt, "redirectPorts", cp);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/** auth.json 的 OAuth 条目(`type: "oauth"`,W6-O):只查形状,不碰 token 内容。 */
|
|
72
|
+
export function checkOAuthEntry(c, entry, path) {
|
|
73
|
+
c.keys(entry, path, [
|
|
74
|
+
"type",
|
|
75
|
+
"flavor",
|
|
76
|
+
"clientId",
|
|
77
|
+
"issuer",
|
|
78
|
+
"accountId",
|
|
79
|
+
"planType",
|
|
80
|
+
"email",
|
|
81
|
+
"accessToken",
|
|
82
|
+
"refreshToken",
|
|
83
|
+
"idToken",
|
|
84
|
+
"expiresAt",
|
|
85
|
+
"lastRefresh",
|
|
86
|
+
"acknowledgedAt",
|
|
87
|
+
"needsLogin",
|
|
88
|
+
]);
|
|
89
|
+
c.oneOf(entry, "flavor", path, CHATGPT_FLAVORS);
|
|
90
|
+
if (entry["flavor"] === undefined)
|
|
91
|
+
c.error(join(path, "flavor"), msg().config.schema.required);
|
|
92
|
+
c.string(entry, "accessToken", path, true);
|
|
93
|
+
c.string(entry, "refreshToken", path, true);
|
|
94
|
+
for (const key of ["clientId", "issuer", "accountId", "planType", "email", "idToken"])
|
|
95
|
+
c.string(entry, key, path);
|
|
96
|
+
for (const key of ["lastRefresh", "acknowledgedAt"])
|
|
97
|
+
c.string(entry, key, path);
|
|
98
|
+
c.number(entry, "expiresAt", path);
|
|
99
|
+
if (entry["expiresAt"] === undefined)
|
|
100
|
+
c.error(join(path, "expiresAt"), msg().config.schema.required);
|
|
101
|
+
c.boolean(entry, "needsLogin", path);
|
|
102
|
+
}
|
|
103
|
+
/** profile.json 的 `memory`(D11):`enabled: true` 时 `dir` 必填且为绝对路径。 */
|
|
104
|
+
export function checkProfileMemory(c, profile) {
|
|
105
|
+
const memory = profile["memory"];
|
|
106
|
+
if (memory === undefined || !c.object(memory, "memory"))
|
|
107
|
+
return;
|
|
108
|
+
c.keys(memory, "memory", ["enabled", "dir"]);
|
|
109
|
+
if (typeof memory["enabled"] !== "boolean")
|
|
110
|
+
c.error("memory.enabled", msg().config.schema.required);
|
|
111
|
+
c.string(memory, "dir", "memory");
|
|
112
|
+
const dir = memory["dir"];
|
|
113
|
+
if (memory["enabled"] === true && (typeof dir !== "string" || !isAbsolute(dir)))
|
|
114
|
+
c.error("memory.dir", msg().config.schema.memoryDir);
|
|
115
|
+
}
|