@octopi-agent/engine 0.102.10 → 0.121.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtin-model-info.js +28 -7
- package/dist/config-admin/agent-presets.d.ts +32 -0
- package/dist/config-admin/agent-presets.js +133 -0
- package/dist/config-admin/discover.d.ts +33 -4
- package/dist/config-admin/discover.js +101 -6
- package/dist/config-admin/env.d.ts +11 -0
- package/dist/config-admin/env.js +41 -0
- package/dist/config-admin/error-copy.d.ts +106 -0
- package/dist/config-admin/error-copy.js +287 -0
- package/dist/config-admin/i18n.d.ts +21 -0
- package/dist/config-admin/i18n.js +19 -0
- package/dist/config-admin/index.d.ts +6 -2
- package/dist/config-admin/index.js +3 -1
- package/dist/config-admin/model-presets.d.ts +14 -0
- package/dist/config-admin/model-presets.js +595 -70
- package/dist/config-admin/onboarding-apply.d.ts +71 -0
- package/dist/config-admin/onboarding-apply.js +235 -0
- package/dist/config-admin/onboarding.d.ts +154 -0
- package/dist/config-admin/onboarding.js +270 -0
- package/dist/config-admin/redact.d.ts +42 -9
- package/dist/config-admin/redact.js +69 -5
- package/dist/config-schema/agent.d.ts +5 -1
- package/dist/config-schema/agent.js +20 -2
- package/dist/config-schema/browser.d.ts +62 -0
- package/dist/config-schema/browser.js +89 -0
- package/dist/config-schema/context.d.ts +7 -2
- package/dist/config-schema/context.js +6 -3
- package/dist/config-schema/engine.d.ts +86 -7
- package/dist/config-schema/engine.js +9 -2
- package/dist/config-schema/governance.d.ts +12 -1
- package/dist/config-schema/governance.js +10 -2
- package/dist/config-schema/models.d.ts +12 -8
- package/dist/config-schema/models.js +16 -1
- package/dist/config-schema/run.d.ts +4 -0
- package/dist/config-schema/run.js +10 -0
- package/dist/config-schema/shared.d.ts +1 -0
- package/dist/config-schema/shared.js +4 -2
- package/dist/config-schema/substrate.d.ts +5 -0
- package/dist/config-schema/substrate.js +8 -0
- package/dist/config.d.ts +116 -10
- package/dist/config.js +109 -13
- package/dist/file-mode.d.ts +67 -0
- package/dist/file-mode.js +182 -0
- package/dist/fork-child.d.ts +82 -0
- package/dist/fork-child.js +123 -0
- package/dist/harness/activation/delegated-run.d.ts +42 -0
- package/dist/harness/activation/delegated-run.js +71 -0
- package/dist/harness/activation/dispatcher.js +4 -0
- package/dist/harness/activation/index.d.ts +1 -0
- package/dist/harness/activation/run-backend.d.ts +92 -0
- package/dist/harness/activation/run-backend.js +16 -0
- package/dist/harness/activation/run-protocol.d.ts +392 -0
- package/dist/harness/activation/run-protocol.js +19 -0
- package/dist/harness/activation/runtime.d.ts +33 -0
- package/dist/harness/activation/runtime.js +119 -28
- package/dist/harness/activation/types.d.ts +19 -2
- package/dist/harness/agent/builder.d.ts +12 -0
- package/dist/harness/agent/builder.js +78 -22
- package/dist/harness/agent/config-bridge.d.ts +10 -1
- package/dist/harness/agent/config-bridge.js +15 -3
- package/dist/harness/agent/registered-tool-adapter.d.ts +27 -0
- package/dist/harness/agent/registered-tool-adapter.js +67 -0
- package/dist/harness/agent/wire-agent-builder.d.ts +2 -0
- package/dist/harness/agent/wire-agent-builder.js +9 -2
- package/dist/harness/capabilities/document/backends/plain.js +2 -1
- package/dist/harness/capabilities/document/legacy/factory.js +3 -2
- package/dist/harness/collaboration/autonomous-subsystem/audit/reader.d.ts +17 -0
- package/dist/harness/collaboration/autonomous-subsystem/audit/reader.js +66 -36
- package/dist/harness/collaboration/autonomous-subsystem/audit/writer.d.ts +6 -2
- package/dist/harness/collaboration/autonomous-subsystem/audit/writer.js +27 -7
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.js +13 -0
- package/dist/harness/collaboration/autonomous-subsystem/loader.js +1 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +11 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +17 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.d.ts +13 -3
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.js +48 -39
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +3 -0
- package/dist/harness/collaboration/autonomous-subsystem/types.d.ts +4 -0
- package/dist/harness/collaboration/delegation/child-run.d.ts +9 -0
- package/dist/harness/collaboration/delegation/child-run.js +34 -2
- package/dist/harness/collaboration/delegation/registry-types.d.ts +2 -0
- package/dist/harness/collaboration/delegation/service.d.ts +9 -4
- package/dist/harness/collaboration/delegation/service.js +33 -12
- package/dist/harness/collaboration/delegation/store.d.ts +2 -0
- package/dist/harness/collaboration/delegation/store.js +1 -0
- package/dist/harness/collaboration/delegation/types.d.ts +11 -0
- package/dist/harness/collaboration/delegation/wiring.d.ts +2 -0
- package/dist/harness/collaboration/delegation/wiring.js +1 -0
- package/dist/harness/context/capabilities/compact/engine.d.ts +44 -5
- package/dist/harness/context/capabilities/compact/engine.js +127 -39
- package/dist/harness/context/capabilities/compact/index.d.ts +2 -1
- package/dist/harness/context/capabilities/compact/index.js +1 -1
- package/dist/harness/context/capabilities/compact/types.d.ts +59 -9
- package/dist/harness/context/capabilities/summary/gate.d.ts +19 -2
- package/dist/harness/context/capabilities/summary/gate.js +53 -6
- package/dist/harness/context/capabilities/summary/registry.js +20 -0
- package/dist/harness/context/capabilities/summary/tool-binding.js +16 -12
- package/dist/harness/context/capabilities/summary/tool-bindings.d.ts +13 -0
- package/dist/harness/context/capabilities/summary/tool-bindings.js +22 -0
- package/dist/harness/context/capabilities/summary/types.d.ts +16 -0
- package/dist/harness/context/constitution/default-agents.md +85 -0
- package/dist/harness/context/context-size-ledger.js +8 -1
- package/dist/harness/context/default-context-engine.d.ts +100 -6
- package/dist/harness/context/default-context-engine.js +382 -89
- package/dist/harness/context/index.d.ts +2 -1
- package/dist/harness/context/index.js +1 -0
- package/dist/harness/context/layer-health.d.ts +4 -0
- package/dist/harness/context/layer-health.js +4 -0
- package/dist/harness/context/layer-types.d.ts +57 -0
- package/dist/harness/context/layer-types.js +73 -1
- package/dist/harness/context/layers.d.ts +3 -0
- package/dist/harness/context/layers.js +13 -6
- package/dist/harness/context/prefix-fingerprint.d.ts +46 -0
- package/dist/harness/context/prefix-fingerprint.js +52 -0
- package/dist/harness/context/summarize.js +18 -0
- package/dist/harness/context/system-prompt-assembler.d.ts +2 -0
- package/dist/harness/context/system-prompt-assembler.js +5 -2
- package/dist/harness/context/tool-result-aging.d.ts +104 -16
- package/dist/harness/context/tool-result-aging.js +211 -57
- package/dist/harness/context/types.d.ts +71 -4
- package/dist/harness/context/types.js +25 -1
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +4 -3
- package/dist/harness/extension/execution-environment/effect-policy.js +2 -2
- package/dist/harness/extension/execution-environment/privileged-exec.js +4 -1
- package/dist/harness/extension/execution-environment/workspace.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +27 -1
- package/dist/harness/extension/plugin-ecosystem/channel-types.js +11 -2
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.d.ts +12 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.js +25 -0
- package/dist/harness/extension/plugin-ecosystem/commands/builtin.js +28 -1
- package/dist/harness/extension/plugin-ecosystem/index.d.ts +1 -0
- package/dist/harness/extension/plugin-ecosystem/index.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +168 -1
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +156 -15
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-instances.d.ts +95 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-instances.js +170 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-kinds.d.ts +178 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-kinds.js +314 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.d.ts +40 -5
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.js +45 -26
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +11 -1
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +42 -76
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +30 -1
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +46 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +9 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +19 -14
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.d.ts +3 -1
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/browser-types.d.ts +333 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser-types.js +16 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser.d.ts +64 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser.js +692 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +0 -37
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +108 -4
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +18 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +34 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +0 -6
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +57 -4
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +81 -13
- package/dist/harness/extension/plugin-ecosystem/tools/http.js +5 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +13 -7
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +126 -14
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +44 -5
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +10 -24
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +7 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +4 -0
- package/dist/harness/governance/credentials/db.d.ts +9 -0
- package/dist/harness/governance/credentials/db.js +122 -31
- package/dist/harness/governance/credentials/store.d.ts +68 -7
- package/dist/harness/governance/credentials/store.js +177 -64
- package/dist/harness/governance/credentials/types.d.ts +13 -2
- package/dist/harness/governance/index.d.ts +1 -0
- package/dist/harness/governance/index.js +1 -0
- package/dist/harness/governance/registry/db.d.ts +32 -0
- package/dist/harness/governance/registry/db.js +142 -0
- package/dist/harness/governance/registry/index.d.ts +9 -0
- package/dist/harness/governance/registry/index.js +9 -0
- package/dist/harness/governance/registry/service.d.ts +381 -0
- package/dist/harness/governance/registry/service.js +825 -0
- package/dist/harness/governance/registry/types.d.ts +77 -0
- package/dist/harness/governance/registry/types.js +7 -0
- package/dist/harness/governance/security/default-security-guard.d.ts +3 -0
- package/dist/harness/governance/security/default-security-guard.js +12 -1
- package/dist/harness/governance/security/risk-evaluator.d.ts +13 -3
- package/dist/harness/governance/security/risk-evaluator.js +307 -21
- package/dist/harness/governance/security/shell-parser-treesitter.js +12 -4
- package/dist/harness/governance/session-acl/tool-rights.d.ts +1 -0
- package/dist/harness/index.d.ts +5 -3
- package/dist/harness/index.js +2 -2
- package/dist/harness/knowledge/boot-config.d.ts +2 -0
- package/dist/harness/knowledge/boot-config.js +2 -0
- package/dist/harness/knowledge/client.d.ts +53 -7
- package/dist/harness/knowledge/client.js +77 -20
- package/dist/harness/knowledge/db.d.ts +16 -0
- package/dist/harness/knowledge/db.js +107 -41
- package/dist/harness/knowledge/engine-thread.js +5 -7
- package/dist/harness/knowledge/grounding.js +4 -1
- package/dist/harness/knowledge/http-app.d.ts +15 -0
- package/dist/harness/knowledge/http-app.js +82 -21
- package/dist/harness/knowledge/http-bridge.d.ts +15 -0
- package/dist/harness/knowledge/http-bridge.js +19 -0
- package/dist/harness/knowledge/knowledge-serve-child.js +2 -3
- package/dist/harness/knowledge/query-service.d.ts +12 -2
- package/dist/harness/knowledge/query-service.js +75 -41
- package/dist/harness/knowledge/query-worker-client.d.ts +5 -1
- package/dist/harness/knowledge/query-worker-client.js +4 -1
- package/dist/harness/knowledge/query-worker.js +5 -3
- package/dist/harness/knowledge/read-http.d.ts +2 -0
- package/dist/harness/knowledge/read-http.js +9 -2
- package/dist/harness/knowledge/retriever.d.ts +1 -1
- package/dist/harness/knowledge/retriever.js +1 -2
- package/dist/harness/knowledge/serve.d.ts +6 -1
- package/dist/harness/knowledge/serve.js +5 -6
- package/dist/harness/knowledge/source-store.d.ts +101 -5
- package/dist/harness/knowledge/source-store.js +297 -71
- package/dist/harness/knowledge/start-service-process.d.ts +27 -8
- package/dist/harness/knowledge/start-service-process.js +49 -90
- package/dist/harness/knowledge/tenant-gate.d.ts +81 -0
- package/dist/harness/knowledge/tenant-gate.js +167 -0
- package/dist/harness/knowledge/writer-service.d.ts +18 -2
- package/dist/harness/knowledge/writer-service.js +80 -16
- package/dist/harness/knowledge/writer-worker-client.d.ts +9 -2
- package/dist/harness/knowledge/writer-worker-client.js +20 -3
- package/dist/harness/knowledge/writer-worker.js +11 -4
- package/dist/harness/memory/backfill-trigger.d.ts +10 -3
- package/dist/harness/memory/backfill-trigger.js +19 -19
- package/dist/harness/memory/cognition-seeds.d.ts +45 -0
- package/dist/harness/memory/cognition-seeds.js +67 -0
- package/dist/harness/memory/cognition.d.ts +12 -3
- package/dist/harness/memory/cognition.js +55 -35
- package/dist/harness/memory/conceptualizer.d.ts +11 -1
- package/dist/harness/memory/conceptualizer.js +10 -1
- package/dist/harness/memory/context-slice.d.ts +42 -0
- package/dist/harness/memory/context-slice.js +197 -0
- package/dist/harness/memory/health-probe.d.ts +8 -2
- package/dist/harness/memory/health-probe.js +10 -13
- package/dist/harness/memory/index.d.ts +5 -1
- package/dist/harness/memory/index.js +3 -1
- package/dist/harness/memory/sqlite/agent-db.d.ts +1 -0
- package/dist/harness/memory/sqlite/agent-db.js +9 -8
- package/dist/harness/memory/sqlite/cognition-store.d.ts +26 -3
- package/dist/harness/memory/sqlite/cognition-store.js +103 -45
- package/dist/harness/memory/sqlite/memory-store.js +4 -0
- package/dist/harness/memory/sqlite/sqlite-vec.d.ts +24 -1
- package/dist/harness/memory/sqlite/sqlite-vec.js +37 -1
- package/dist/harness/memory/types.d.ts +18 -2
- package/dist/harness/observability/observer/hub.d.ts +10 -0
- package/dist/harness/observability/observer/hub.js +95 -2
- package/dist/harness/run/agent/agent.js +3 -2
- package/dist/harness/run/concurrency/tool-validator.js +4 -3
- package/dist/harness/run/reliability/run-agent.d.ts +22 -0
- package/dist/harness/run/reliability/run-agent.js +79 -10
- package/dist/harness/run/run-host.d.ts +302 -0
- package/dist/harness/run/run-host.js +978 -0
- package/dist/harness/run/run-scope.d.ts +11 -0
- package/dist/harness/run/run-scope.js +19 -1
- package/dist/harness/run/runner.d.ts +149 -22
- package/dist/harness/run/runner.js +352 -35
- package/dist/harness/session/in-memory-store.js +13 -1
- package/dist/harness/session/schedules/service.d.ts +10 -2
- package/dist/harness/session/schedules/service.js +13 -2
- package/dist/harness/session/tasks/tools.js +12 -0
- package/dist/harness/session/types.d.ts +10 -14
- package/dist/harness/shared/events/agent-event-map.d.ts +29 -0
- package/dist/harness/shared/types/agent-definition.d.ts +6 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/integration/agent-runtime/channel-message-source.d.ts +3 -1
- package/dist/integration/agent-runtime/channel-message-source.js +4 -3
- package/dist/integration/browser/camoufox.d.ts +40 -0
- package/dist/integration/browser/camoufox.js +80 -0
- package/dist/integration/browser/index.d.ts +91 -0
- package/dist/integration/browser/index.js +110 -0
- package/dist/integration/browser/install.d.ts +47 -0
- package/dist/integration/browser/install.js +214 -0
- package/dist/integration/browser/playwright.d.ts +224 -0
- package/dist/integration/browser/playwright.js +925 -0
- package/dist/integration/browser/service.d.ts +41 -0
- package/dist/integration/browser/service.js +181 -0
- package/dist/integration/browser/stealth.d.ts +42 -0
- package/dist/integration/browser/stealth.js +104 -0
- package/dist/integration/providers/anthropic-message-normalize.d.ts +20 -0
- package/dist/integration/providers/anthropic-message-normalize.js +48 -0
- package/dist/integration/providers/anthropic.js +27 -2
- package/dist/integration/providers/fetch-timeout.d.ts +17 -0
- package/dist/integration/providers/fetch-timeout.js +24 -0
- package/dist/integration/providers/openai.d.ts +8 -0
- package/dist/integration/providers/openai.js +41 -1
- package/dist/integration/providers/wire-dump-diff.js +2 -1
- package/dist/integration/providers/wire-dump.d.ts +56 -2
- package/dist/integration/providers/wire-dump.js +119 -6
- package/dist/integration/storage/archive-manager.d.ts +14 -2
- package/dist/integration/storage/archive-manager.js +24 -8
- package/dist/integration/storage/atomic-tmp.d.ts +12 -0
- package/dist/integration/storage/atomic-tmp.js +36 -0
- package/dist/integration/storage/jsonl.d.ts +9 -0
- package/dist/integration/storage/jsonl.js +137 -38
- package/dist/integration/storage/session-index.d.ts +5 -0
- package/dist/integration/storage/session-index.js +25 -4
- package/dist/integration/tools/assemble.d.ts +50 -0
- package/dist/integration/tools/assemble.js +137 -0
- package/dist/paths.d.ts +18 -0
- package/dist/paths.js +36 -0
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +3 -1
- package/dist/subsystems/cognition-steward/conceptualize/handler.js +74 -5
- package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +3 -2
- package/dist/subsystems/cognition-steward/consolidate/config.yaml +11 -2
- package/dist/subsystems/cognition-steward/consolidate/handler.d.ts +6 -3
- package/dist/subsystems/cognition-steward/consolidate/handler.js +266 -28
- package/dist/subsystems/memory-steward/backfill/handler.js +3 -2
- package/dist/subsystems/memory-steward/govern/config.yaml +6 -1
- package/dist/subsystems/wisdom-steward/attribute/config.yaml +5 -1
- package/dist/subsystems/wisdom-steward/formation/config.yaml +3 -0
- package/dist/subsystems/wisdom-steward/govern/config.yaml +6 -1
- package/package.json +5 -3
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Onboarding 向导核心 — 单源状态机 / 双语文案表 / 配置组装(纯逻辑无 IO)。
|
|
3
|
+
*
|
|
4
|
+
* CLI 与 Web 向导共享本模块(product-onboarding.md §1):渲染器只做呈现,
|
|
5
|
+
* 步骤序、校验、落盘内容都在这里。生成器语义:产出与手写 octopi.json 同构。
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { expandProviderPreset, getProviderPreset, listProviderPresets } from './model-presets.js';
|
|
10
|
+
import { pickLocalized } from './i18n.js';
|
|
11
|
+
/** 步骤序(`init-mode` 仅在 Web 向导可用时呈现——CLI 先行期只有命令行一条道) */
|
|
12
|
+
export const ONBOARDING_STEPS = [
|
|
13
|
+
'welcome',
|
|
14
|
+
'init-mode',
|
|
15
|
+
'deployment-mode',
|
|
16
|
+
'provider',
|
|
17
|
+
'api-key',
|
|
18
|
+
'model',
|
|
19
|
+
'probe',
|
|
20
|
+
'services',
|
|
21
|
+
'first-chat',
|
|
22
|
+
];
|
|
23
|
+
/** 部署模式选项(顺序即展示序) */
|
|
24
|
+
export const DEPLOYMENT_MODES = [
|
|
25
|
+
{
|
|
26
|
+
id: 'personal',
|
|
27
|
+
labels: { zh: '个人使用', en: 'Personal' },
|
|
28
|
+
descriptions: {
|
|
29
|
+
zh: '单人使用这台机器上的助手,无需账号密码。',
|
|
30
|
+
en: 'Just you on this machine — no login required.',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'organization',
|
|
35
|
+
labels: { zh: '单组织多用户', en: 'Organization' },
|
|
36
|
+
descriptions: {
|
|
37
|
+
zh: '一个组织(团队/公司)内多人使用。组织内可共享知识库、跨用户 agent 协同。',
|
|
38
|
+
en: 'One organization with multiple users. Shared knowledge base and cross-user agent collaboration inside the org.',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 'multi-organization',
|
|
43
|
+
labels: { zh: '多组织多租户', en: 'Multi-organization' },
|
|
44
|
+
descriptions: {
|
|
45
|
+
zh: '多个组织共用一套部署,相互隔离。组织内可共享知识库、跨用户 agent 协同。',
|
|
46
|
+
en: 'Multiple isolated organizations on one deployment. Shared knowledge and collaboration inside each org.',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
/**
|
|
51
|
+
* 取当前语言的双语文案(与 pickLocalized 同源,保留本名给向导渲染器)
|
|
52
|
+
*
|
|
53
|
+
* @param map - 双语映射
|
|
54
|
+
* @param fallback - 回落文案
|
|
55
|
+
* @param lang - 当前语言
|
|
56
|
+
* @returns 本地化文案
|
|
57
|
+
*/
|
|
58
|
+
export function pickLang(map, fallback, lang) {
|
|
59
|
+
return pickLocalized(map, map[lang]?.trim() || fallback, lang);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 预设的 apiKey 环境变量名(.env 键 + `${VAR}` 占位同名)
|
|
63
|
+
*
|
|
64
|
+
* @param providerId - 预设 id
|
|
65
|
+
* @returns 环境变量名;无需 key 的预设(ollama 等)返回 ''
|
|
66
|
+
* @throws 未知 providerId(fail-loud)
|
|
67
|
+
*/
|
|
68
|
+
export function apiKeyEnvVar(providerId) {
|
|
69
|
+
const preset = getProviderPreset(providerId);
|
|
70
|
+
if (!preset)
|
|
71
|
+
throw new Error(`unknown provider preset: ${providerId}`);
|
|
72
|
+
return preset.apiKeyEnvHint || '';
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 校验一步的选择是否完整(渲染器在「下一步」前调用)
|
|
76
|
+
*
|
|
77
|
+
* @param step - 步骤 id
|
|
78
|
+
* @param choices - 当前选择
|
|
79
|
+
* @returns 错误文案(当前语言);'' 表示通过
|
|
80
|
+
*/
|
|
81
|
+
export function validateStep(step, choices) {
|
|
82
|
+
const zh = choices.lang === 'zh';
|
|
83
|
+
switch (step) {
|
|
84
|
+
case 'welcome':
|
|
85
|
+
return choices.lang ? '' : zh ? '请选择语言' : 'Pick a language';
|
|
86
|
+
case 'init-mode':
|
|
87
|
+
return choices.initMode ? '' : zh ? '请选择初始化方式' : 'Pick an init mode';
|
|
88
|
+
case 'deployment-mode': {
|
|
89
|
+
const mode = choices.deploymentMode;
|
|
90
|
+
if (!mode)
|
|
91
|
+
return zh ? '请选择部署模式' : 'Pick a deployment mode';
|
|
92
|
+
// M-4:③模式组织名必填(此前 Web 端漏校验 → seedDeploymentRegistry 退化 'default' 租户)
|
|
93
|
+
if (mode === 'multi-organization' && !String(choices.orgName ?? '').trim()) {
|
|
94
|
+
return zh ? '请填写组织名称' : 'Enter an organization name';
|
|
95
|
+
}
|
|
96
|
+
return '';
|
|
97
|
+
}
|
|
98
|
+
case 'provider': {
|
|
99
|
+
if (!getProviderPreset(choices.providerId))
|
|
100
|
+
return zh ? '请选择一个模型服务' : 'Pick a model provider';
|
|
101
|
+
// custom(OpenAI 兼容)必须给 baseUrl(schema: min(1);空值产出非法配置)
|
|
102
|
+
if (choices.providerId === 'custom' && !String(choices.providerOverrides?.baseUrl ?? '').trim()) {
|
|
103
|
+
return zh ? '请填写服务的 Base URL(OpenAI 兼容接口地址)' : 'Enter the service base URL (OpenAI-compatible endpoint)';
|
|
104
|
+
}
|
|
105
|
+
return '';
|
|
106
|
+
}
|
|
107
|
+
case 'api-key': {
|
|
108
|
+
const envVar = apiKeyEnvVar(choices.providerId);
|
|
109
|
+
if (!envVar)
|
|
110
|
+
return ''; // 无需 key 的预设跳过
|
|
111
|
+
return choices.apiKey?.trim()
|
|
112
|
+
? ''
|
|
113
|
+
: zh
|
|
114
|
+
? '请粘贴 API Key(或返回上一步换无需 key 的本地模型)'
|
|
115
|
+
: 'Paste your API key (or go back and pick a keyless local model)';
|
|
116
|
+
}
|
|
117
|
+
case 'model':
|
|
118
|
+
return choices.modelId?.trim() ? '' : zh ? '请选择或填写模型名' : 'Pick or type a model id';
|
|
119
|
+
case 'probe':
|
|
120
|
+
case 'services':
|
|
121
|
+
case 'first-chat':
|
|
122
|
+
return ''; // 动作步无输入
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* 组装落盘内容(生成器语义:与手写 octopi.json 完全同构)
|
|
127
|
+
*
|
|
128
|
+
* @param choices - 完整选择(须先过 validateStep 全链)
|
|
129
|
+
* @returns 配置片段 + .env 行
|
|
130
|
+
* @throws provider 未知或 apiKey 缺失时抛错(fail-loud,不产半截配置)
|
|
131
|
+
*/
|
|
132
|
+
export function assembleOnboarding(choices) {
|
|
133
|
+
const preset = getProviderPreset(choices.providerId);
|
|
134
|
+
if (!preset)
|
|
135
|
+
throw new Error(`unknown provider preset: ${choices.providerId}`);
|
|
136
|
+
const envVar = apiKeyEnvVar(choices.providerId);
|
|
137
|
+
if (envVar && !choices.apiKey?.trim()) {
|
|
138
|
+
// fail-loud,不产「KEY=」空值配置(运行时静默 401 比向导报错难查得多)
|
|
139
|
+
throw new Error(`missing api key for provider preset: ${choices.providerId}`);
|
|
140
|
+
}
|
|
141
|
+
const baseUrl = String(choices.providerOverrides?.baseUrl ?? '').trim();
|
|
142
|
+
if (choices.providerId === 'custom' && !baseUrl) {
|
|
143
|
+
throw new Error('missing baseUrl for custom provider');
|
|
144
|
+
}
|
|
145
|
+
const modelId = choices.modelId.trim();
|
|
146
|
+
const overrides = (choices.providerOverrides ?? {});
|
|
147
|
+
// 模型目录全量落配置(生成器语义):预设模型全进目录(参考参数随行),
|
|
148
|
+
// 用户「用哪个模型?」只接线 default agent 与 level 三档;手填清单外 id 追加进目录
|
|
149
|
+
const baseModels = Array.isArray(overrides.models) && overrides.models.length > 0 ? overrides.models : preset.models.map((m) => ({ ...m }));
|
|
150
|
+
const models = baseModels.some((m) => m?.id === modelId) ? [...baseModels] : [...baseModels, { id: modelId }];
|
|
151
|
+
const providerConfig = expandProviderPreset(choices.providerId, {
|
|
152
|
+
...overrides,
|
|
153
|
+
...(envVar ? { apiKey: `\${${envVar}}` } : {}),
|
|
154
|
+
models,
|
|
155
|
+
});
|
|
156
|
+
const modelRef = `${preset.id}/${modelId}`;
|
|
157
|
+
return {
|
|
158
|
+
configFragment: {
|
|
159
|
+
language: choices.lang,
|
|
160
|
+
deploymentMode: choices.deploymentMode,
|
|
161
|
+
providers: { [preset.id]: providerConfig },
|
|
162
|
+
// B3:档位与 default agent 全部接线到所选 provider/model(不然「第一句话」仍跑在 openai 写死档上)
|
|
163
|
+
levels: {
|
|
164
|
+
mini: { primary: modelRef },
|
|
165
|
+
standard: { primary: modelRef },
|
|
166
|
+
pro: { primary: modelRef },
|
|
167
|
+
},
|
|
168
|
+
agentModel: modelRef,
|
|
169
|
+
},
|
|
170
|
+
envLines: envVar ? [`${envVar}=${(choices.apiKey ?? '').trim()}`] : [],
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* 列出可选 provider 预设(渲染器用)
|
|
175
|
+
*
|
|
176
|
+
* @returns 预设清单(只读)
|
|
177
|
+
*/
|
|
178
|
+
export function providerChoices() {
|
|
179
|
+
return listProviderPresets();
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* 步骤数据浅合并(白名单字段;Web/CLI 渲染器共用单源——M2)。
|
|
183
|
+
*
|
|
184
|
+
* @param base - 现有选择
|
|
185
|
+
* @param patch - 本步提交的部分字段(只认 OnboardingChoices 顶层键)
|
|
186
|
+
* @returns 合并后的新对象(不改入参)
|
|
187
|
+
*/
|
|
188
|
+
const ONBOARDING_CHOICE_FIELDS = [
|
|
189
|
+
'lang',
|
|
190
|
+
'initMode',
|
|
191
|
+
'deploymentMode',
|
|
192
|
+
'orgName',
|
|
193
|
+
'providerId',
|
|
194
|
+
'providerOverrides',
|
|
195
|
+
'adminPassword',
|
|
196
|
+
'apiKey',
|
|
197
|
+
'modelId',
|
|
198
|
+
];
|
|
199
|
+
export function mergeOnboardingChoices(base, patch) {
|
|
200
|
+
const out = { ...base };
|
|
201
|
+
// MINOR-1:白名单合并(只认 OnboardingChoices 顶层字段;HTTP 层透传对象不能塞任意键)
|
|
202
|
+
for (const key of ONBOARDING_CHOICE_FIELDS) {
|
|
203
|
+
const v = patch[key];
|
|
204
|
+
if (v !== undefined)
|
|
205
|
+
out[key] = v;
|
|
206
|
+
}
|
|
207
|
+
return out;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* 初始状态
|
|
211
|
+
*
|
|
212
|
+
* @param start - 起始步骤(默认 welcome)
|
|
213
|
+
* @returns 全新状态机状态
|
|
214
|
+
*/
|
|
215
|
+
export function initialOnboardingState(start = 'welcome') {
|
|
216
|
+
return { current: start, stack: [], completed: false, aborted: false, exitSave: false };
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* 纯转移函数(M2 核心):无 IO、无渲染,Web/CLI 唯一步骤图真相。
|
|
220
|
+
*
|
|
221
|
+
* @param state - 当前状态
|
|
222
|
+
* @param event - 事件
|
|
223
|
+
* @returns 转移后状态 + commit 时机
|
|
224
|
+
*/
|
|
225
|
+
export function nextStep(state, event) {
|
|
226
|
+
if (state.current === null)
|
|
227
|
+
return { state, commit: 'none' }; // 终态吸收
|
|
228
|
+
const idx = ONBOARDING_STEPS.indexOf(state.current);
|
|
229
|
+
switch (event.kind) {
|
|
230
|
+
case 'next': {
|
|
231
|
+
const nextIdx = idx + 1;
|
|
232
|
+
const done = nextIdx >= ONBOARDING_STEPS.length;
|
|
233
|
+
return {
|
|
234
|
+
state: {
|
|
235
|
+
...state,
|
|
236
|
+
current: done ? null : ONBOARDING_STEPS[nextIdx],
|
|
237
|
+
stack: [...state.stack, state.current],
|
|
238
|
+
completed: done,
|
|
239
|
+
},
|
|
240
|
+
// B2:测通通过即落盘(services 动作读盘拿新配置);走完防御落盘(半截状态不组装)
|
|
241
|
+
commit: state.current === 'probe' ? 'after-probe' : done ? 'on-done' : 'none',
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
case 'back': {
|
|
245
|
+
const prev = state.stack[state.stack.length - 1];
|
|
246
|
+
if (prev === undefined)
|
|
247
|
+
return { state, commit: 'none', notice: 'back-at-first' }; // m13:空栈回退给提示,不静默绕圈
|
|
248
|
+
return { state: { ...state, current: prev, stack: state.stack.slice(0, -1) }, commit: 'none' };
|
|
249
|
+
}
|
|
250
|
+
case 'goto': {
|
|
251
|
+
// M1:探针失败动作面的精确落点(rekey→api-key / reprovider→provider);非法目标忽略(fail-safe 不坏状态)
|
|
252
|
+
if (!ONBOARDING_STEPS.includes(event.step)) {
|
|
253
|
+
return { state, commit: 'none' };
|
|
254
|
+
}
|
|
255
|
+
// 自身不压栈(否则重试循环把「上一步」变成原地踏步 + 栈无限增长)
|
|
256
|
+
const stack = event.step === state.current ? state.stack : [...state.stack, state.current];
|
|
257
|
+
return { state: { ...state, current: event.step, stack }, commit: 'none' };
|
|
258
|
+
}
|
|
259
|
+
case 'exit': {
|
|
260
|
+
// m5:save=true 落盘退出;save=false 半截状态不组装
|
|
261
|
+
return {
|
|
262
|
+
state: { ...state, current: null, exitSave: event.save },
|
|
263
|
+
commit: event.save ? 'on-exit-save' : 'none',
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
case 'eof': {
|
|
267
|
+
return { state: { ...state, current: null, aborted: true }, commit: 'none' };
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
* apiKey 只回显「是否已配置 + 引用形态」,绝不回显明文值。
|
|
5
5
|
* `${VAR}` 形态给变量名;明文形态只标记 `literal`。
|
|
6
6
|
*
|
|
7
|
+
* options 键级脱敏(P6-4/M4):manifest `secretOptions` 声明的键按同一
|
|
8
|
+
* `RedactedSecret` 视图打码;插件贡献不在有效注册表时 fail-closed 全量打码。
|
|
9
|
+
*
|
|
7
10
|
* @module
|
|
8
11
|
*/
|
|
9
|
-
/**
|
|
12
|
+
/** 脱敏后的 Secret 视图 */
|
|
10
13
|
export interface RedactedSecret {
|
|
11
|
-
/** 是否已配置非空值 */
|
|
12
14
|
configured: boolean;
|
|
13
|
-
|
|
14
|
-
ref: string | null;
|
|
15
|
+
ref: 'literal' | string | null;
|
|
15
16
|
}
|
|
16
17
|
/** 脱敏后的 provider 视图(WebUI 表单回显) */
|
|
17
18
|
export interface RedactedProvider {
|
|
@@ -21,19 +22,51 @@ export interface RedactedProvider {
|
|
|
21
22
|
models: Array<Record<string, unknown>>;
|
|
22
23
|
timeoutSeconds?: number;
|
|
23
24
|
apiKey: RedactedSecret;
|
|
25
|
+
/** 插件 Provider 贡献 id(与 api 二选一) */
|
|
26
|
+
plugin?: string;
|
|
27
|
+
/** 插件自定义旋钮:manifest `secretOptions` 声明的键以 RedactedSecret 打码,其余原样透传。 */
|
|
28
|
+
options?: Record<string, unknown>;
|
|
24
29
|
}
|
|
25
30
|
/**
|
|
26
|
-
*
|
|
31
|
+
* 脱敏一个 secret 值(唯一实现点:apiKey 与 options 键共用)
|
|
27
32
|
*
|
|
28
|
-
* @param value -
|
|
33
|
+
* @param value - 原始值(可能为 `${VAR}` 形态、明文、空或非字符串对象)
|
|
29
34
|
* @returns 脱敏视图(不含明文)
|
|
30
35
|
*/
|
|
31
|
-
export declare function redactSecret(value:
|
|
36
|
+
export declare function redactSecret(value: unknown): RedactedSecret;
|
|
37
|
+
/**
|
|
38
|
+
* Whether an option value is one of OUR echo placeholders (a `RedactedSecret`
|
|
39
|
+
* view round-tripped by a config client). A placeholder means "the client did
|
|
40
|
+
* not change this value" — upsert must restore the stored value instead of
|
|
41
|
+
* writing the placeholder to disk (see resolveEchoPlaceholders).
|
|
42
|
+
*
|
|
43
|
+
* @param value - Candidate option value
|
|
44
|
+
* @returns Whether the value is a RedactedSecret-shaped placeholder
|
|
45
|
+
*/
|
|
46
|
+
export declare function isRedactedSecret(value: unknown): value is RedactedSecret;
|
|
47
|
+
/**
|
|
48
|
+
* Resolve echo placeholders in an upserted provider config: for every
|
|
49
|
+
* manifest-declared secret option key holding a `RedactedSecret` placeholder,
|
|
50
|
+
* restore the previous stored value; without a stored value the key is
|
|
51
|
+
* dropped (a placeholder has no meaning on disk).
|
|
52
|
+
*
|
|
53
|
+
* @param config - The upserted provider config fragment
|
|
54
|
+
* @param previous - The stored config fragment it replaces (if any)
|
|
55
|
+
* @param secretOptionKeys - manifest `secretOptions` for this provider
|
|
56
|
+
* @returns The config with placeholders resolved
|
|
57
|
+
*/
|
|
58
|
+
export declare function resolveEchoPlaceholders<T extends {
|
|
59
|
+
options?: Record<string, unknown>;
|
|
60
|
+
}>(config: T, previous: {
|
|
61
|
+
options?: Record<string, unknown>;
|
|
62
|
+
} | undefined, secretOptionKeys: readonly string[]): T;
|
|
32
63
|
/**
|
|
33
64
|
* 脱敏单个 provider 配置
|
|
34
65
|
*
|
|
35
66
|
* @param name - provider 名
|
|
36
|
-
* @param pc - provider
|
|
67
|
+
* @param pc - provider 配置
|
|
68
|
+
* @param secretOptionKeys - manifest `secretOptions`(undefined=内置 provider
|
|
69
|
+
* 原样透传;null=插件贡献未知,fail-closed 全量打码;数组=声明键打码)
|
|
37
70
|
* @returns 脱敏视图
|
|
38
71
|
*/
|
|
39
|
-
export declare function redactProvider(name: string, pc: Record<string, unknown
|
|
72
|
+
export declare function redactProvider(name: string, pc: Record<string, unknown>, secretOptionKeys?: readonly string[] | null): RedactedProvider;
|
|
@@ -4,31 +4,80 @@
|
|
|
4
4
|
* apiKey 只回显「是否已配置 + 引用形态」,绝不回显明文值。
|
|
5
5
|
* `${VAR}` 形态给变量名;明文形态只标记 `literal`。
|
|
6
6
|
*
|
|
7
|
+
* options 键级脱敏(P6-4/M4):manifest `secretOptions` 声明的键按同一
|
|
8
|
+
* `RedactedSecret` 视图打码;插件贡献不在有效注册表时 fail-closed 全量打码。
|
|
9
|
+
*
|
|
7
10
|
* @module
|
|
8
11
|
*/
|
|
9
12
|
const ENV_REF_PATTERN = /^\$\{(\w+)(?::-.*?)?\}$/;
|
|
10
13
|
/**
|
|
11
|
-
*
|
|
14
|
+
* 脱敏一个 secret 值(唯一实现点:apiKey 与 options 键共用)
|
|
12
15
|
*
|
|
13
|
-
* @param value -
|
|
16
|
+
* @param value - 原始值(可能为 `${VAR}` 形态、明文、空或非字符串对象)
|
|
14
17
|
* @returns 脱敏视图(不含明文)
|
|
15
18
|
*/
|
|
16
19
|
export function redactSecret(value) {
|
|
17
|
-
if (
|
|
20
|
+
if (value === undefined || value === null || value === '')
|
|
18
21
|
return { configured: false, ref: null };
|
|
22
|
+
if (typeof value !== 'string')
|
|
23
|
+
return { configured: true, ref: 'literal' };
|
|
19
24
|
const m = ENV_REF_PATTERN.exec(value);
|
|
20
25
|
if (m)
|
|
21
26
|
return { configured: true, ref: m[1] };
|
|
22
27
|
return { configured: true, ref: 'literal' };
|
|
23
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Whether an option value is one of OUR echo placeholders (a `RedactedSecret`
|
|
31
|
+
* view round-tripped by a config client). A placeholder means "the client did
|
|
32
|
+
* not change this value" — upsert must restore the stored value instead of
|
|
33
|
+
* writing the placeholder to disk (see resolveEchoPlaceholders).
|
|
34
|
+
*
|
|
35
|
+
* @param value - Candidate option value
|
|
36
|
+
* @returns Whether the value is a RedactedSecret-shaped placeholder
|
|
37
|
+
*/
|
|
38
|
+
export function isRedactedSecret(value) {
|
|
39
|
+
return (typeof value === 'object' &&
|
|
40
|
+
value !== null &&
|
|
41
|
+
!Array.isArray(value) &&
|
|
42
|
+
typeof value.configured === 'boolean' &&
|
|
43
|
+
Object.keys(value).every((key) => key === 'configured' || key === 'ref'));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Resolve echo placeholders in an upserted provider config: for every
|
|
47
|
+
* manifest-declared secret option key holding a `RedactedSecret` placeholder,
|
|
48
|
+
* restore the previous stored value; without a stored value the key is
|
|
49
|
+
* dropped (a placeholder has no meaning on disk).
|
|
50
|
+
*
|
|
51
|
+
* @param config - The upserted provider config fragment
|
|
52
|
+
* @param previous - The stored config fragment it replaces (if any)
|
|
53
|
+
* @param secretOptionKeys - manifest `secretOptions` for this provider
|
|
54
|
+
* @returns The config with placeholders resolved
|
|
55
|
+
*/
|
|
56
|
+
export function resolveEchoPlaceholders(config, previous, secretOptionKeys) {
|
|
57
|
+
if (!config.options || secretOptionKeys.length === 0)
|
|
58
|
+
return config;
|
|
59
|
+
const options = { ...config.options };
|
|
60
|
+
for (const key of secretOptionKeys) {
|
|
61
|
+
if (!isRedactedSecret(options[key]))
|
|
62
|
+
continue;
|
|
63
|
+
const stored = previous?.options?.[key];
|
|
64
|
+
if (stored !== undefined && !isRedactedSecret(stored))
|
|
65
|
+
options[key] = stored;
|
|
66
|
+
else
|
|
67
|
+
delete options[key];
|
|
68
|
+
}
|
|
69
|
+
return { ...config, options };
|
|
70
|
+
}
|
|
24
71
|
/**
|
|
25
72
|
* 脱敏单个 provider 配置
|
|
26
73
|
*
|
|
27
74
|
* @param name - provider 名
|
|
28
|
-
* @param pc - provider
|
|
75
|
+
* @param pc - provider 配置
|
|
76
|
+
* @param secretOptionKeys - manifest `secretOptions`(undefined=内置 provider
|
|
77
|
+
* 原样透传;null=插件贡献未知,fail-closed 全量打码;数组=声明键打码)
|
|
29
78
|
* @returns 脱敏视图
|
|
30
79
|
*/
|
|
31
|
-
export function redactProvider(name, pc) {
|
|
80
|
+
export function redactProvider(name, pc, secretOptionKeys) {
|
|
32
81
|
const out = {
|
|
33
82
|
name,
|
|
34
83
|
baseUrl: typeof pc.baseUrl === 'string' ? pc.baseUrl : '',
|
|
@@ -38,5 +87,20 @@ export function redactProvider(name, pc) {
|
|
|
38
87
|
};
|
|
39
88
|
if (typeof pc.timeoutSeconds === 'number')
|
|
40
89
|
out.timeoutSeconds = pc.timeoutSeconds;
|
|
90
|
+
if (typeof pc.plugin === 'string')
|
|
91
|
+
out.plugin = pc.plugin;
|
|
92
|
+
if (pc.options !== undefined && pc.options !== null && typeof pc.options === 'object' && !Array.isArray(pc.options)) {
|
|
93
|
+
// Three states: undefined = built-in provider (verbatim echo, no manifest
|
|
94
|
+
// exists); null = plugin contribution unknown to the live registry (fail
|
|
95
|
+
// closed — mask everything rather than echo a possibly-secret value);
|
|
96
|
+
// string[] = manifest-declared secret keys (mask those, pass others).
|
|
97
|
+
out.options =
|
|
98
|
+
secretOptionKeys === undefined
|
|
99
|
+
? { ...pc.options }
|
|
100
|
+
: Object.fromEntries(Object.entries(pc.options).map(([key, value]) => [
|
|
101
|
+
key,
|
|
102
|
+
secretOptionKeys === null || secretOptionKeys.includes(key) ? redactSecret(value) : value,
|
|
103
|
+
]));
|
|
104
|
+
}
|
|
41
105
|
return out;
|
|
42
106
|
}
|
|
@@ -126,6 +126,7 @@ export declare const AgentConfigSchema: z.ZodObject<{
|
|
|
126
126
|
tools: z.ZodOptional<z.ZodObject<{
|
|
127
127
|
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
128
128
|
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
129
|
+
denyCapabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
129
130
|
}, z.core.$strip>>;
|
|
130
131
|
skillDirectory: z.ZodOptional<z.ZodString>;
|
|
131
132
|
skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -222,7 +223,8 @@ export declare const PluginConfigSchema: z.ZodObject<{
|
|
|
222
223
|
}, z.core.$strict>>>;
|
|
223
224
|
}, z.core.$strict>;
|
|
224
225
|
export declare const ChannelConfigSchema: z.ZodObject<{
|
|
225
|
-
type: z.ZodString
|
|
226
|
+
type: z.ZodOptional<z.ZodString>;
|
|
227
|
+
plugin: z.ZodOptional<z.ZodString>;
|
|
226
228
|
port: z.ZodOptional<z.ZodNumber>;
|
|
227
229
|
host: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
228
230
|
local: "local";
|
|
@@ -230,5 +232,7 @@ export declare const ChannelConfigSchema: z.ZodObject<{
|
|
|
230
232
|
}>, z.ZodString]>>;
|
|
231
233
|
path: z.ZodOptional<z.ZodString>;
|
|
232
234
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
235
|
+
tenantId: z.ZodOptional<z.ZodString>;
|
|
233
236
|
corsOrigins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
237
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
234
238
|
}, z.core.$strip>;
|
|
@@ -124,11 +124,29 @@ export const PluginConfigSchema = z
|
|
|
124
124
|
.optional(),
|
|
125
125
|
})
|
|
126
126
|
.strict();
|
|
127
|
-
export const ChannelConfigSchema = z
|
|
128
|
-
|
|
127
|
+
export const ChannelConfigSchema = z
|
|
128
|
+
.object({
|
|
129
|
+
/** 内置通道类型(`http`);与 plugin 二选一(恰好其一) */
|
|
130
|
+
type: z.string().min(1).optional(),
|
|
131
|
+
/** 插件 Channel 贡献 id(manifest contributes.channels);与 type 二选一 */
|
|
132
|
+
plugin: z.string().min(1).optional(),
|
|
129
133
|
port: z.number().positive().optional(),
|
|
130
134
|
host: NetworkHostSchema.optional(),
|
|
131
135
|
path: z.string().optional(),
|
|
136
|
+
/** 密钥通道(如飞书 App Secret,推荐 `${ENV_VAR}` 引用);options 禁放密钥 */
|
|
132
137
|
apiKey: z.string().optional(),
|
|
138
|
+
/** bot 凭证归属租户(Q11=a 渠道锚定);缺省 = default 存量域 */
|
|
139
|
+
tenantId: z.string().min(1).optional(),
|
|
133
140
|
corsOrigins: z.array(z.string()).optional(),
|
|
141
|
+
/** 插件自定义旋钮(非密钥;原样透传) */
|
|
142
|
+
options: z.record(z.string(), z.unknown()).optional(),
|
|
143
|
+
})
|
|
144
|
+
.superRefine((v, ctx) => {
|
|
145
|
+
// type | plugin 恰好其一:schema/写盘校验与装配路由同闸(装配是第二道闸)
|
|
146
|
+
if ((v.type === undefined) === (v.plugin === undefined)) {
|
|
147
|
+
ctx.addIssue({
|
|
148
|
+
code: z.ZodIssueCode.custom,
|
|
149
|
+
message: 'exactly one of type | plugin must be set',
|
|
150
|
+
});
|
|
151
|
+
}
|
|
134
152
|
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* browser — 浏览器操作工具段(→ engine;arch/browser-capability.md §3.8)
|
|
3
|
+
*
|
|
4
|
+
* 缺省 = 默认开(拍板);`enabled: false` 显式关闭。
|
|
5
|
+
* `cloud` 为后续分期槽位,运行时 fail-loud(装配拒绝);`rebrowser` / `camoufox`
|
|
6
|
+
* 双 stealth 后端与 `cdp-attach` 已实现(P2/P3)。
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
export declare const BrowserConfigSchema: z.ZodObject<{
|
|
12
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
engine: z.ZodOptional<z.ZodEnum<{
|
|
14
|
+
auto: "auto";
|
|
15
|
+
playwright: "playwright";
|
|
16
|
+
rebrowser: "rebrowser";
|
|
17
|
+
camoufox: "camoufox";
|
|
18
|
+
"cdp-attach": "cdp-attach";
|
|
19
|
+
cloud: "cloud";
|
|
20
|
+
stealth: "stealth";
|
|
21
|
+
}>>;
|
|
22
|
+
attach: z.ZodOptional<z.ZodObject<{
|
|
23
|
+
endpoint: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>>;
|
|
25
|
+
profiles: z.ZodOptional<z.ZodObject<{
|
|
26
|
+
persist: z.ZodOptional<z.ZodBoolean>;
|
|
27
|
+
defaultProfile: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>>;
|
|
29
|
+
channel: z.ZodOptional<z.ZodEnum<{
|
|
30
|
+
chromium: "chromium";
|
|
31
|
+
chrome: "chrome";
|
|
32
|
+
}>>;
|
|
33
|
+
headless: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
snapshotMaxChars: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
sessionIdleTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
viewport: z.ZodOptional<z.ZodObject<{
|
|
38
|
+
width: z.ZodNumber;
|
|
39
|
+
height: z.ZodNumber;
|
|
40
|
+
}, z.core.$strip>>;
|
|
41
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
42
|
+
network: z.ZodOptional<z.ZodObject<{
|
|
43
|
+
domains: z.ZodOptional<z.ZodObject<{
|
|
44
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
45
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
allowPrivateNetwork: z.ZodOptional<z.ZodBoolean>;
|
|
48
|
+
}, z.core.$strip>>;
|
|
49
|
+
stealth: z.ZodOptional<z.ZodObject<{
|
|
50
|
+
fallback: z.ZodOptional<z.ZodString>;
|
|
51
|
+
humanize: z.ZodOptional<z.ZodObject<{
|
|
52
|
+
typingDelayMs: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
|
|
53
|
+
actionJitterMs: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
|
|
54
|
+
maxRetries: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
}, z.core.$strip>>;
|
|
56
|
+
}, z.core.$strip>>;
|
|
57
|
+
confirm: z.ZodOptional<z.ZodEnum<{
|
|
58
|
+
strict: "strict";
|
|
59
|
+
off: "off";
|
|
60
|
+
standard: "standard";
|
|
61
|
+
}>>;
|
|
62
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* browser — 浏览器操作工具段(→ engine;arch/browser-capability.md §3.8)
|
|
3
|
+
*
|
|
4
|
+
* 缺省 = 默认开(拍板);`enabled: false` 显式关闭。
|
|
5
|
+
* `cloud` 为后续分期槽位,运行时 fail-loud(装配拒绝);`rebrowser` / `camoufox`
|
|
6
|
+
* 双 stealth 后端与 `cdp-attach` 已实现(P2/P3)。
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
export const BrowserConfigSchema = z.object({
|
|
12
|
+
/** 工具面注册开关(缺省 true) */
|
|
13
|
+
enabled: z.boolean().optional(),
|
|
14
|
+
/**
|
|
15
|
+
* 后端引擎:auto = playwright;stealth = 按 stealth.fallback 链的隐身模式
|
|
16
|
+
* (缺省 rebrowser->camoufox);rebrowser / camoufox = 单后端直钉;cdp-attach = 真实 Chrome。
|
|
17
|
+
*/
|
|
18
|
+
engine: z
|
|
19
|
+
.enum(['auto', 'playwright', 'stealth', 'rebrowser', 'camoufox', 'cdp-attach', 'cloud'])
|
|
20
|
+
.optional(),
|
|
21
|
+
/** attach 端点(engine=cdp-attach 用;缺省 http://127.0.0.1:9222) */
|
|
22
|
+
attach: z
|
|
23
|
+
.object({
|
|
24
|
+
endpoint: z.string().min(1).optional(),
|
|
25
|
+
})
|
|
26
|
+
.optional(),
|
|
27
|
+
/** 持久 profile(P2;storageState 归档于 OCTOPI_HOME/browser-profiles) */
|
|
28
|
+
profiles: z
|
|
29
|
+
.object({
|
|
30
|
+
persist: z.boolean().optional(),
|
|
31
|
+
defaultProfile: z.string().min(1).optional(),
|
|
32
|
+
})
|
|
33
|
+
.optional(),
|
|
34
|
+
/** 浏览器来源:chromium(管理版,octopi browser install)| chrome(系统 Chrome) */
|
|
35
|
+
channel: z.enum(['chromium', 'chrome']).optional(),
|
|
36
|
+
headless: z.boolean().optional(),
|
|
37
|
+
/** 工具/动作超时(毫秒,默认 30000) */
|
|
38
|
+
timeoutMs: z.number().positive().optional(),
|
|
39
|
+
/** 快照序列化预算(字符,默认 8000) */
|
|
40
|
+
snapshotMaxChars: z.number().int().positive().optional(),
|
|
41
|
+
/** 会话空闲回收(毫秒;<=0 不回收;默认 1800000 = 30 分钟) */
|
|
42
|
+
sessionIdleTimeoutMs: z.number().int().optional(),
|
|
43
|
+
viewport: z
|
|
44
|
+
.object({
|
|
45
|
+
width: z.number().int().positive(),
|
|
46
|
+
height: z.number().int().positive(),
|
|
47
|
+
})
|
|
48
|
+
.optional(),
|
|
49
|
+
locale: z.string().min(1).optional(),
|
|
50
|
+
network: z
|
|
51
|
+
.object({
|
|
52
|
+
/** 域名 allow/deny(deny 优先;`*.example.com` 后缀通配;缺省无限制) */
|
|
53
|
+
domains: z
|
|
54
|
+
.object({
|
|
55
|
+
allow: z.array(z.string().min(1)).optional(),
|
|
56
|
+
deny: z.array(z.string().min(1)).optional(),
|
|
57
|
+
})
|
|
58
|
+
.optional(),
|
|
59
|
+
/** 私网/环回放行(缺省 false;与 http_request 语义对齐) */
|
|
60
|
+
allowPrivateNetwork: z.boolean().optional(),
|
|
61
|
+
})
|
|
62
|
+
.optional(),
|
|
63
|
+
/**
|
|
64
|
+
* stealth(P3):`fallback` = engine=stealth 的后端链(`->` 分隔,缺省
|
|
65
|
+
* `rebrowser->camoufox`);挑战判定命中切下一后端重试一次(有界),仍败走 HITL。
|
|
66
|
+
* `humanize` = 行为拟人化节流(stealth 引擎缺省启用;区间 [min,max] 毫秒随机)。
|
|
67
|
+
*/
|
|
68
|
+
stealth: z
|
|
69
|
+
.object({
|
|
70
|
+
fallback: z.string().min(1).optional(),
|
|
71
|
+
humanize: z
|
|
72
|
+
.object({
|
|
73
|
+
/** 逐键打字延迟区间(默认 [20, 80]) */
|
|
74
|
+
typingDelayMs: z.tuple([z.number().min(0), z.number().min(0)]).optional(),
|
|
75
|
+
/** 动作间抖动区间(默认 [100, 600]) */
|
|
76
|
+
actionJitterMs: z.tuple([z.number().min(0), z.number().min(0)]).optional(),
|
|
77
|
+
/** 动作重试上限(默认 2;有界重试,禁止重试风暴) */
|
|
78
|
+
maxRetries: z.number().int().min(0).optional(),
|
|
79
|
+
})
|
|
80
|
+
.optional(),
|
|
81
|
+
})
|
|
82
|
+
.optional(),
|
|
83
|
+
/**
|
|
84
|
+
* 敏感动作确认闸门三档(2026-11-20 拍板):
|
|
85
|
+
* `strict` = 所有非 GET 过闸(含页内 fetch/XHR);`standard`(缺省)= 仅文档级
|
|
86
|
+
* (表单提交/密码/上传);`off` = 全放开。
|
|
87
|
+
*/
|
|
88
|
+
confirm: z.enum(['strict', 'standard', 'off']).optional(),
|
|
89
|
+
});
|