@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,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* integration/browser/install — 浏览器引擎安装单一实现(arch/browser-capability.md §3.9)
|
|
3
|
+
*
|
|
4
|
+
* CLI(`octopi browser install`)与 gateway(WebUI 设置页)共用本模块——安装
|
|
5
|
+
* 逻辑只此一份(One source of truth)。子进程输出按行回调 `onProgress`:CLI 透传
|
|
6
|
+
* 终端,gateway 缓冲进安装任务供前端轮询。
|
|
7
|
+
*
|
|
8
|
+
* 覆盖面:
|
|
9
|
+
* - `playwright` / `rebrowser`:管理版 Chromium(各自驱动的 CLI,版本恒配)。
|
|
10
|
+
* 只补库不补浏览器时二进制来自 playwright 系 registry;安装幂等。
|
|
11
|
+
* - `camoufox`:隔离 provider 目录(自带 camoufox-js + 自洽 playwright-core)+
|
|
12
|
+
* Camoufox 定制 Firefox 下载(不依赖系统 Firefox)。
|
|
13
|
+
* - `stealth` = rebrowser + camoufox(engine="stealth" 链所需全部)。
|
|
14
|
+
*/
|
|
15
|
+
import { spawn } from 'node:child_process';
|
|
16
|
+
import { existsSync, readdirSync } from 'node:fs';
|
|
17
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
18
|
+
import { homedir } from 'node:os';
|
|
19
|
+
import { join } from 'node:path';
|
|
20
|
+
import { camoufoxProviderDir, resolveCamoufoxJsCliPath, resolvePlaywrightCliPath, resolveRebrowserCliPath, } from './index.js';
|
|
21
|
+
const INSTALLABLE = new Set(['playwright', 'rebrowser', 'camoufox', 'stealth']);
|
|
22
|
+
function cacheCandidates(envOverride, name) {
|
|
23
|
+
const out = [];
|
|
24
|
+
if (envOverride)
|
|
25
|
+
out.push(envOverride);
|
|
26
|
+
// playwright 系 registry 缓存平台约定:mac=~/Library/Caches、win=%LOCALAPPDATA%、其余 ~/.cache
|
|
27
|
+
if (process.platform === 'darwin')
|
|
28
|
+
out.push(join(homedir(), 'Library', 'Caches', name));
|
|
29
|
+
else if (process.platform === 'win32') {
|
|
30
|
+
out.push(join(process.env.LOCALAPPDATA ?? join(homedir(), 'AppData', 'Local'), name));
|
|
31
|
+
}
|
|
32
|
+
out.push(join(homedir(), '.cache', name));
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
/** 二进制在位探测(启发式:registry 目录约定、平台多候选;detail 里如实标注探测口径) */
|
|
36
|
+
function chromiumBinaryPresent() {
|
|
37
|
+
// playwright 系 registry 解压为 chromium-<rev> 目录(rebrowser 同布局、独立 rev)
|
|
38
|
+
return cacheCandidates(process.env.PLAYWRIGHT_BROWSERS_PATH, 'ms-playwright').some((root) => {
|
|
39
|
+
if (!existsSync(root))
|
|
40
|
+
return false;
|
|
41
|
+
return (readdirSafe(root) ?? []).some((d) => d.startsWith('chromium-'));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function readdirSafe(dir) {
|
|
45
|
+
try {
|
|
46
|
+
return readdirSync(dir);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 探测全部引擎的就绪状态(WebUI 状态卡 / CLI 预检共用)。
|
|
54
|
+
*
|
|
55
|
+
* @returns 各引擎状态(顺序固定:playwright / rebrowser / camoufox / stealth / cdp-attach)
|
|
56
|
+
*/
|
|
57
|
+
export function probeEngines() {
|
|
58
|
+
const pwDriver = resolvePlaywrightCliPath() !== null;
|
|
59
|
+
const rbDriver = resolveRebrowserCliPath() !== null;
|
|
60
|
+
const bin = chromiumBinaryPresent();
|
|
61
|
+
const providerDir = camoufoxProviderDir();
|
|
62
|
+
const camoufoxJs = resolveCamoufoxJsCliPath() !== null;
|
|
63
|
+
const camoufoxBin = cacheCandidates(process.env.CAMOUFOX_EXTRACT_PATH, 'camoufox').some((d) => existsSync(d));
|
|
64
|
+
const describe = (driver, hint) => {
|
|
65
|
+
if (!driver)
|
|
66
|
+
return { ready: false, detail: `驱动包缺失(可选依赖未装)——先 "npm install ${hint}" 或重装 octopi(勿 --omit=optional)` };
|
|
67
|
+
if (!bin)
|
|
68
|
+
return { ready: false, detail: '驱动在位,浏览器二进制缺失——运行 "octopi browser install" 安装管理版 Chromium' };
|
|
69
|
+
return { ready: true, detail: '就绪(驱动 + 管理版 Chromium,二进制按 registry 目录探测)' };
|
|
70
|
+
};
|
|
71
|
+
const pw = describe(pwDriver, 'playwright-core');
|
|
72
|
+
const rb = describe(rbDriver, 'rebrowser-playwright-core');
|
|
73
|
+
const camoufox = (() => {
|
|
74
|
+
if (!camoufoxJs) {
|
|
75
|
+
return { ready: false, detail: `隔离 provider 未安装(${providerDir})——运行 "octopi browser install camoufox"` };
|
|
76
|
+
}
|
|
77
|
+
if (!camoufoxBin) {
|
|
78
|
+
return { ready: false, detail: 'provider 在位,Camoufox 浏览器未下载——运行 "octopi browser install camoufox"' };
|
|
79
|
+
}
|
|
80
|
+
return { ready: true, detail: '就绪(隔离 provider + Camoufox 定制 Firefox)' };
|
|
81
|
+
})();
|
|
82
|
+
return [
|
|
83
|
+
{ engine: 'playwright', ...pw },
|
|
84
|
+
{ engine: 'rebrowser', ...rb },
|
|
85
|
+
{ engine: 'camoufox', ...camoufox },
|
|
86
|
+
{
|
|
87
|
+
engine: 'stealth',
|
|
88
|
+
ready: rb.ready && camoufox.ready,
|
|
89
|
+
detail: rb.ready && camoufox.ready
|
|
90
|
+
? '就绪(rebrowser + camoufox 链齐备)'
|
|
91
|
+
: `链缺成员:rebrowser ${rb.ready ? '✓' : '✗'} / camoufox ${camoufox.ready ? '✓' : '✗'}——运行 "octopi browser install stealth"`,
|
|
92
|
+
},
|
|
93
|
+
{ engine: 'cdp-attach', ready: true, detail: 'attach 用户真实 Chrome,无需安装(运行时连接 CDP 端点)' },
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 安装引擎二进制 / 提供方(幂等;重跑安全)。
|
|
98
|
+
*
|
|
99
|
+
* @param engine - 引擎名(stealth = rebrowser + camoufox)
|
|
100
|
+
* @param options.onProgress - 子进程输出按行回调(CLI 透传终端;gateway 缓冲)
|
|
101
|
+
* @returns 安装结果(ok=false 时 detail 是失败依据;不静默吞错)
|
|
102
|
+
*/
|
|
103
|
+
export async function installEngine(engine, options = {}) {
|
|
104
|
+
const emit = (line) => options.onProgress?.(line);
|
|
105
|
+
if (!INSTALLABLE.has(engine)) {
|
|
106
|
+
return {
|
|
107
|
+
ok: false,
|
|
108
|
+
detail: `unknown browser engine "${engine}" — supported: playwright | rebrowser | camoufox | stealth`,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
if (engine === 'playwright' || engine === 'stealth') {
|
|
112
|
+
const r = await installManagedChromium('playwright', emit);
|
|
113
|
+
if (!r.ok)
|
|
114
|
+
return r;
|
|
115
|
+
}
|
|
116
|
+
if (engine === 'rebrowser' || engine === 'stealth') {
|
|
117
|
+
const r = await installManagedChromium('rebrowser', emit);
|
|
118
|
+
if (!r.ok)
|
|
119
|
+
return r;
|
|
120
|
+
}
|
|
121
|
+
if (engine === 'camoufox') {
|
|
122
|
+
return installCamoufoxProvider(emit);
|
|
123
|
+
}
|
|
124
|
+
return { ok: true, detail: `${engine} ready` };
|
|
125
|
+
}
|
|
126
|
+
async function installManagedChromium(kind, emit) {
|
|
127
|
+
const cliPath = kind === 'playwright' ? resolvePlaywrightCliPath() : resolveRebrowserCliPath();
|
|
128
|
+
const pkg = kind === 'playwright' ? 'playwright-core' : 'rebrowser-playwright-core';
|
|
129
|
+
if (!cliPath) {
|
|
130
|
+
return {
|
|
131
|
+
ok: false,
|
|
132
|
+
detail: `${pkg} is not installed (optional dependency). ` +
|
|
133
|
+
`Reinstall octopi without --omit=optional, or run: npm install ${pkg}`,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
emit(`[${kind}] installing managed Chromium via ${pkg} (version-matched)…`);
|
|
137
|
+
const code = await run(process.execPath, [cliPath, 'install', 'chromium'], undefined, emit);
|
|
138
|
+
if (code === 0) {
|
|
139
|
+
emit(`[${kind}] chromium ready.`);
|
|
140
|
+
return { ok: true, detail: `${kind} chromium installed` };
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
ok: false,
|
|
144
|
+
detail: `[${kind}] install failed (exit ${code}); on Linux you may also need system libs: node ${cliPath} install --with-deps chromium`,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* 装 camoufox 隔离 provider(自带依赖树)+ 下载 Camoufox 定制 Firefox。
|
|
149
|
+
*
|
|
150
|
+
* 依赖隔离:camoufox-js 的 peer(playwright-core <1.63)与原生依赖只装在 provider
|
|
151
|
+
* 目录内,不触碰主安装树。provider 目录约定见 `camoufoxProviderDir()`。
|
|
152
|
+
*/
|
|
153
|
+
async function installCamoufoxProvider(emit) {
|
|
154
|
+
const dir = camoufoxProviderDir();
|
|
155
|
+
emit(`[camoufox] preparing isolated provider at ${dir}…`);
|
|
156
|
+
await mkdir(dir, { recursive: true });
|
|
157
|
+
await writeFile(join(dir, 'package.json'), JSON.stringify({
|
|
158
|
+
name: 'octopi-camoufox-provider',
|
|
159
|
+
private: true,
|
|
160
|
+
description: 'isolated Camoufox provider (camoufox-js + self-consistent playwright-core)',
|
|
161
|
+
dependencies: {
|
|
162
|
+
'camoufox-js': '^0.13.0',
|
|
163
|
+
// camoufox-js peer 钉 <1.63;这里给自洽版本(仅本目录生效,不外溢)
|
|
164
|
+
'playwright-core': '~1.62.0',
|
|
165
|
+
},
|
|
166
|
+
}, null, 2));
|
|
167
|
+
const installCode = await run('npm', ['install', '--no-audit', '--no-fund'], dir, emit);
|
|
168
|
+
if (installCode !== 0) {
|
|
169
|
+
return { ok: false, detail: 'camoufox provider npm install failed (see progress output)' };
|
|
170
|
+
}
|
|
171
|
+
const fetchCli = resolveCamoufoxJsCliPath();
|
|
172
|
+
if (!fetchCli) {
|
|
173
|
+
return { ok: false, detail: 'camoufox-js CLI not found after install — provider dir is incomplete' };
|
|
174
|
+
}
|
|
175
|
+
emit('[camoufox] fetching Camoufox browser build (pinned)…');
|
|
176
|
+
const fetchCode = await run(process.execPath, [fetchCli, 'fetch'], undefined, emit);
|
|
177
|
+
if (fetchCode !== 0) {
|
|
178
|
+
return { ok: false, detail: 'camoufox fetch failed (see progress output)' };
|
|
179
|
+
}
|
|
180
|
+
emit('[camoufox] ready. Set browser.engine="camoufox" (or "stealth") in octopi.json.');
|
|
181
|
+
return { ok: true, detail: 'camoufox provider + browser installed' };
|
|
182
|
+
}
|
|
183
|
+
/** 透传子进程输出(按行回调),返回退出码(被信号杀死按 1 记) */
|
|
184
|
+
function run(cmd, cmdArgs, cwd, emit) {
|
|
185
|
+
return new Promise((resolve) => {
|
|
186
|
+
const child = spawn(cmd, cmdArgs, {
|
|
187
|
+
stdio: ['inherit', 'pipe', 'pipe'],
|
|
188
|
+
...(cwd ? { cwd } : {}),
|
|
189
|
+
});
|
|
190
|
+
const pump = (stream, prefix) => {
|
|
191
|
+
let buf = '';
|
|
192
|
+
stream.on('data', (chunk) => {
|
|
193
|
+
buf += chunk.toString();
|
|
194
|
+
const lines = buf.split('\n');
|
|
195
|
+
buf = lines.pop() ?? '';
|
|
196
|
+
for (const line of lines)
|
|
197
|
+
emit(prefix + line);
|
|
198
|
+
});
|
|
199
|
+
stream.on('end', () => {
|
|
200
|
+
if (buf.trim())
|
|
201
|
+
emit(prefix + buf);
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
pump(child.stdout, '');
|
|
205
|
+
pump(child.stderr, '[!] ');
|
|
206
|
+
child.on('error', (err) => {
|
|
207
|
+
emit(`failed to launch installer: ${err.message}`);
|
|
208
|
+
resolve(1);
|
|
209
|
+
});
|
|
210
|
+
child.on('close', (code, signal) => {
|
|
211
|
+
resolve(code ?? (signal ? 1 : 0));
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* playwright 后端 — BrowserPort 的 Playwright 实现(arch/browser-capability.md §3.3)
|
|
3
|
+
*
|
|
4
|
+
* 可选依赖纪律:`playwright-core` 经 optionalDependencies 提供,运行时动态 import
|
|
5
|
+
* (零编译期耦合,结构化类型自描述);缺失/浏览器二进制缺失时 fail-loud
|
|
6
|
+
* (`not_implemented` + 安装指引),不装哑 stub。
|
|
7
|
+
*
|
|
8
|
+
* 请求级策略(arch/browser-capability.md §3.6):经 CDP Fetch 域逐请求暂停
|
|
9
|
+
* 对**每个网络请求**(含重定向/子资源/页内导航)执行注入的 BrowserRequestPolicy——
|
|
10
|
+
* URL 判定与外部写闸门在网络层收口,DOM 层敏感标记只是提前预判。
|
|
11
|
+
*/
|
|
12
|
+
import type { ActResult, ActionIntent, BrowserAttachOptions, BrowserEngineId, BrowserIdentity, BrowserLaunchOptions, BrowserPort, BrowserSession, BrowserSessionId, BrowserSessionInfo, ChallengeInfo, ExtractOutcome, ExtractSpec, GotoOptions, GotoResult, PageAction, PageSnapshot, ScreenshotOptions, HumanizeOptions, ScreenshotResult, SnapshotOptions } from '../../harness/extension/plugin-ecosystem/tools/browser-types.js';
|
|
13
|
+
/** playwright-core 的最小编译期零耦合结构(运行时再 import 校验) */
|
|
14
|
+
interface PwLocator {
|
|
15
|
+
click(options?: unknown): Promise<void>;
|
|
16
|
+
fill(value: string, options?: unknown): Promise<void>;
|
|
17
|
+
/** 逐键敲入(P3 拟人化 fill 用) */
|
|
18
|
+
pressSequentially(text: string, options?: unknown): Promise<void>;
|
|
19
|
+
selectOption(value: string, options?: unknown): Promise<unknown>;
|
|
20
|
+
check(options?: unknown): Promise<void>;
|
|
21
|
+
uncheck(options?: unknown): Promise<void>;
|
|
22
|
+
hover(options?: unknown): Promise<void>;
|
|
23
|
+
press(key: string, options?: unknown): Promise<void>;
|
|
24
|
+
screenshot(options?: unknown): Promise<Uint8Array>;
|
|
25
|
+
count(): Promise<number>;
|
|
26
|
+
setInputFiles(path: string, options?: unknown): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
interface PwPage {
|
|
29
|
+
goto(url: string, options?: unknown): Promise<{
|
|
30
|
+
status(): number;
|
|
31
|
+
} | null>;
|
|
32
|
+
url(): string;
|
|
33
|
+
title(): Promise<string>;
|
|
34
|
+
close(): Promise<void>;
|
|
35
|
+
evaluate<R>(fn: (arg: unknown) => R, arg?: unknown): Promise<R>;
|
|
36
|
+
locator(selector: string): PwLocator;
|
|
37
|
+
screenshot(options?: unknown): Promise<Uint8Array>;
|
|
38
|
+
keyboard: {
|
|
39
|
+
press(key: string): Promise<void>;
|
|
40
|
+
};
|
|
41
|
+
mouse: {
|
|
42
|
+
wheel(dx: number, dy: number): Promise<void>;
|
|
43
|
+
};
|
|
44
|
+
waitForTimeout(ms: number): Promise<void>;
|
|
45
|
+
on(event: string, handler: (...args: never[]) => void): unknown;
|
|
46
|
+
mainFrame(): unknown;
|
|
47
|
+
/** 打开本页的源页面(弹窗归属判定:attach 模式不得误关用户自己的标签) */
|
|
48
|
+
opener(): Promise<PwPage | null>;
|
|
49
|
+
}
|
|
50
|
+
interface PwBrowserContext {
|
|
51
|
+
newPage(): Promise<PwPage>;
|
|
52
|
+
close(): Promise<void>;
|
|
53
|
+
newCDPSession(page: PwPage): Promise<PwCDPSession>;
|
|
54
|
+
storageState(options?: unknown): Promise<unknown>;
|
|
55
|
+
/** 路由级拦截(Firefox 后端策略用;重定向跟随跳不触发——须逐跳走查) */
|
|
56
|
+
route(pattern: string, handler: (route: PwRoute) => unknown): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
export interface PwBrowser {
|
|
59
|
+
newContext(options?: unknown): Promise<PwBrowserContext>;
|
|
60
|
+
contexts(): PwBrowserContext[];
|
|
61
|
+
close(): Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
/** CDP Fetch 域(网络栈级逐请求拦截;重定向每跳都停) */
|
|
64
|
+
interface PwCDPSession {
|
|
65
|
+
on(event: 'Fetch.requestPaused', handler: (e: CdpRequestPaused) => void): void;
|
|
66
|
+
send(method: string, params?: unknown): Promise<unknown>;
|
|
67
|
+
}
|
|
68
|
+
interface CdpRequestPaused {
|
|
69
|
+
requestId: string;
|
|
70
|
+
request: {
|
|
71
|
+
url: string;
|
|
72
|
+
method: string;
|
|
73
|
+
};
|
|
74
|
+
resourceType?: string;
|
|
75
|
+
}
|
|
76
|
+
/** route 拦截请求(Firefox 策略用;与 CDP Fetch 的字段语义对齐) */
|
|
77
|
+
interface PwRouteRequest {
|
|
78
|
+
url(): string;
|
|
79
|
+
method(): string;
|
|
80
|
+
resourceType(): string;
|
|
81
|
+
}
|
|
82
|
+
interface PwRoute {
|
|
83
|
+
request(): PwRouteRequest;
|
|
84
|
+
/** 以本请求为基发起取数(可覆写 url/method;maxRedirects:0 = 看见每一跳) */
|
|
85
|
+
fetch(options?: unknown): Promise<PwRouteResponse>;
|
|
86
|
+
continue(): Promise<void>;
|
|
87
|
+
abort(errorCode?: string): Promise<void>;
|
|
88
|
+
fulfill(options: unknown): Promise<void>;
|
|
89
|
+
}
|
|
90
|
+
interface PwRouteResponse {
|
|
91
|
+
status(): number;
|
|
92
|
+
headers(): Record<string, string>;
|
|
93
|
+
body(): Promise<Uint8Array>;
|
|
94
|
+
}
|
|
95
|
+
export declare class PlaywrightBrowserSession implements BrowserSession {
|
|
96
|
+
private readonly browser;
|
|
97
|
+
private readonly context;
|
|
98
|
+
private readonly page;
|
|
99
|
+
private readonly actionTimeoutMs;
|
|
100
|
+
private readonly onClosed?;
|
|
101
|
+
private readonly sessionOptions?;
|
|
102
|
+
readonly id: BrowserSessionId;
|
|
103
|
+
readonly engine: BrowserEngineId;
|
|
104
|
+
readonly identity: BrowserIdentity;
|
|
105
|
+
readonly ownerKey: string;
|
|
106
|
+
/** 当前快照的 ref 元数据(ref 绑定快照代数;导航/重渲染即失效) */
|
|
107
|
+
private readonly refMeta;
|
|
108
|
+
private epoch;
|
|
109
|
+
/** 最近一次被策略拦截的 URL/原因(goto 报错时给人话,不裸抛 ERR_BLOCKED_BY_CLIENT) */
|
|
110
|
+
private lastBlock;
|
|
111
|
+
private closed;
|
|
112
|
+
constructor(browser: PwBrowser, context: PwBrowserContext, page: PwPage, actionTimeoutMs: number, ownerKey: string, onClosed?: ((id: BrowserSessionId) => void) | undefined, sessionOptions?: {
|
|
113
|
+
identity?: BrowserIdentity;
|
|
114
|
+
/** 引擎标识(attach 会话报 cdp-attach,不谎报 playwright) */
|
|
115
|
+
engine?: BrowserEngineId;
|
|
116
|
+
/** attach:只关自己开的页 + 断开连接;managed:关 context + browser */
|
|
117
|
+
closeMode?: "managed" | "attach";
|
|
118
|
+
/** 持久 profile 归档(managed + persist 才生效;attach 是用户活身份,不归档) */
|
|
119
|
+
profile?: {
|
|
120
|
+
id: string;
|
|
121
|
+
dir: string;
|
|
122
|
+
persist: boolean;
|
|
123
|
+
};
|
|
124
|
+
/** P3 拟人化(逐键打字延迟在 fill 生效;区间每键随机采样) */
|
|
125
|
+
humanize?: HumanizeOptions;
|
|
126
|
+
} | undefined);
|
|
127
|
+
/** 策略拦截回调(port 路由处理器注入) */
|
|
128
|
+
noteBlocked(url: string, reason: string): void;
|
|
129
|
+
/**
|
|
130
|
+
* ref 全失效(导航时由监听触发)。epoch 保持单调递增——
|
|
131
|
+
* **不得归零**:归零会让导航前后的 ref 命名空间碰撞(旧 ref 静默命中新页面元素)。
|
|
132
|
+
*/
|
|
133
|
+
private invalidateRefs;
|
|
134
|
+
get url(): string;
|
|
135
|
+
goto(url: string, options?: GotoOptions): Promise<GotoResult>;
|
|
136
|
+
/** 策略拦截导致的失败 → 报人话原因(不裸抛 ERR_BLOCKED_BY_CLIENT) */
|
|
137
|
+
private mapBlockedError;
|
|
138
|
+
snapshot(options?: SnapshotOptions): Promise<PageSnapshot>;
|
|
139
|
+
inspectAction(action: PageAction): Promise<ActionIntent>;
|
|
140
|
+
act(action: PageAction): Promise<ActResult>;
|
|
141
|
+
private runAction;
|
|
142
|
+
/**
|
|
143
|
+
* 挑战页启发式识别(arch/browser-capability.md §3.7)。
|
|
144
|
+
* 标记表刻意小而诚实:命中即透出 kind+marker,不装懂(漏检是已知边界)。
|
|
145
|
+
*/
|
|
146
|
+
detectChallenge(): Promise<ChallengeInfo | undefined>;
|
|
147
|
+
/** 确定性结构化抽取(CSS 选择器 → 真实数据;无匹配字段/属性 = null,不编造) */
|
|
148
|
+
extract(spec: ExtractSpec): Promise<ExtractOutcome>;
|
|
149
|
+
screenshot(options?: ScreenshotOptions): Promise<ScreenshotResult>;
|
|
150
|
+
private locatorForScreenshot;
|
|
151
|
+
close(): Promise<void>;
|
|
152
|
+
private persistProfileState;
|
|
153
|
+
}
|
|
154
|
+
/** Playwright BrowserPort 实现 */
|
|
155
|
+
export declare class PlaywrightBrowserPort implements BrowserPort {
|
|
156
|
+
private readonly defaults;
|
|
157
|
+
private readonly sessions;
|
|
158
|
+
constructor(defaults?: {
|
|
159
|
+
headless?: boolean;
|
|
160
|
+
channel?: 'chromium' | 'chrome';
|
|
161
|
+
viewport?: {
|
|
162
|
+
width: number;
|
|
163
|
+
height: number;
|
|
164
|
+
};
|
|
165
|
+
locale?: string;
|
|
166
|
+
timeoutMs?: number;
|
|
167
|
+
/** attach 引擎模式:launch() 派发到 attach(engine='cdp-attach') */
|
|
168
|
+
attachMode?: boolean;
|
|
169
|
+
/** attach 默认 CDP 端点 */
|
|
170
|
+
attachEndpoint?: string;
|
|
171
|
+
/** P3:驱动模块 specifier(缺省 'playwright-core';rebrowser = 'rebrowser-playwright-core') */
|
|
172
|
+
driver?: string;
|
|
173
|
+
/** P3:会话引擎标识(缺省 playwright) */
|
|
174
|
+
engine?: BrowserEngineId;
|
|
175
|
+
/** P3:请求策略实现——cdp-fetch(Chromium 缺省)| route-walk(Firefox 逐跳走查) */
|
|
176
|
+
policyMode?: 'cdp-fetch' | 'route-walk';
|
|
177
|
+
/** P3:自定义启动器(camoufox 等自带驱动的后端);缺省 pw.chromium.launch */
|
|
178
|
+
launcher?: (opts: {
|
|
179
|
+
headless: boolean;
|
|
180
|
+
channel?: 'chromium' | 'chrome';
|
|
181
|
+
timeoutMs?: number;
|
|
182
|
+
}) => Promise<PwBrowser>;
|
|
183
|
+
});
|
|
184
|
+
launch(options?: BrowserLaunchOptions): Promise<BrowserSession>;
|
|
185
|
+
/**
|
|
186
|
+
* 单页契约弹窗收口。按模式分支(评审 F2/N2):
|
|
187
|
+
* - `managed`:context 为本会话独占——**所有**新页都关。防御性设计:不依赖 CDP 的
|
|
188
|
+
* opener 行为(实证:本栈页内创建的弹窗即使 `rel=noopener` 也带 openerId;
|
|
189
|
+
* opener-less 页面只可能来自 context.newPage() 等页外路径);
|
|
190
|
+
* - `attach`:同 context 里有用户自己的标签——只关**本页打开的**弹窗(opener 实例
|
|
191
|
+
* 同一性判定,异步),用户自己的标签不碰。
|
|
192
|
+
* 首请求存在与关闭的竞态窗口(KNOWN-ISSUES)。
|
|
193
|
+
*/
|
|
194
|
+
private installPopupGuard;
|
|
195
|
+
/**
|
|
196
|
+
* 请求级策略安装(每请求收口:URL 判定 + 非 GET 导航写闸 + 账本)。
|
|
197
|
+
*
|
|
198
|
+
* Chromium 系走 **CDP Fetch 域**(网络栈级逐请求暂停):`context.route` 在重定向
|
|
199
|
+
* 跟随跳上不触发(实证:302 目标由网络栈内部跟走、route 看不到)——路由级拦截
|
|
200
|
+
* 会漏掉正是策略最该管的跳转目标,故 Chromium 弃用 route(评审 B2)。Firefox 系
|
|
201
|
+
* (camoufox)无 CDP Fetch 域,走 {@link installRequestPolicyRouteWalk} 逐跳走查
|
|
202
|
+
* 同等语义(P3)。
|
|
203
|
+
*/
|
|
204
|
+
private installRequestPolicy;
|
|
205
|
+
/**
|
|
206
|
+
* 路由级策略(P3:Firefox/camoufox 后端——Juggler 无 CDP Fetch 域)。
|
|
207
|
+
*
|
|
208
|
+
* `context.route` 同样不触发于重定向跟随跳,故**逐跳走查**:`route.fetch` 以
|
|
209
|
+
* `maxRedirects: 0` 把每一跳摊在明面,每跳都过 URL 策略与写闸,最终响应
|
|
210
|
+
* `route.fulfill` 回填——与 CDP Fetch 路径语义对齐(arch §3.6 同等语义)。
|
|
211
|
+
* 307/308 保留方法(写随跳走、闸跟着走);301/302/303 降级 GET(丢 body)。
|
|
212
|
+
* 残余边界(KNOWN-ISSUES):WS/ServiceWorker 请求不经 route。
|
|
213
|
+
*/
|
|
214
|
+
private installRequestPolicyRouteWalk;
|
|
215
|
+
/**
|
|
216
|
+
* attach 用户真实浏览器(P2;connectOverCDP,复用其登录/指纹)。
|
|
217
|
+
*
|
|
218
|
+
* 安全语义(已实证):策略经 CDP Fetch 同样逐请求收口;`browser.close()` = 断开
|
|
219
|
+
* 连接、不杀用户浏览器;会话关闭只关我们开的页(closeMode='attach')。
|
|
220
|
+
*/
|
|
221
|
+
attach(options?: BrowserAttachOptions): Promise<BrowserSession>;
|
|
222
|
+
list(): Promise<BrowserSessionInfo[]>;
|
|
223
|
+
}
|
|
224
|
+
export {};
|