@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
|
@@ -69,13 +69,19 @@ export class SessionScheduleService {
|
|
|
69
69
|
this.notify = options.notify;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* 打开/建库。幂等(先开者语义为准)。
|
|
73
|
+
*
|
|
74
|
+
* @param options - `arm: false` = 只开 store 不重臂/不起 tick(执行面用:§5.4
|
|
75
|
+
* 触发面唯一在 gateway,run 节点若重臂会把到期作业经空 wakeup 静默消费)
|
|
73
76
|
*/
|
|
74
|
-
async open() {
|
|
77
|
+
async open(options) {
|
|
75
78
|
if (this.opened)
|
|
76
79
|
return;
|
|
77
80
|
this.store = await SessionScheduleStore.create(this.options);
|
|
78
81
|
this.opened = true;
|
|
82
|
+
this.armEnabled = options?.arm !== false;
|
|
83
|
+
if (!this.armEnabled)
|
|
84
|
+
return;
|
|
79
85
|
this.rearmAll();
|
|
80
86
|
this.startTick();
|
|
81
87
|
}
|
|
@@ -460,7 +466,12 @@ export class SessionScheduleService {
|
|
|
460
466
|
}
|
|
461
467
|
this.firing.delete(id);
|
|
462
468
|
}
|
|
469
|
+
/** store-only 模式(执行面,open({arm:false})):不点火/不起 tick/不自消费——
|
|
470
|
+
* set/update/resume 经本口也不得 arm(否则到期作业被空 wakeup 静默消费)。 */
|
|
471
|
+
armEnabled = true;
|
|
463
472
|
arm(schedule) {
|
|
473
|
+
if (!this.armEnabled)
|
|
474
|
+
return;
|
|
464
475
|
if (schedule.status !== 'active')
|
|
465
476
|
return;
|
|
466
477
|
this.disarm(schedule.id);
|
|
@@ -50,6 +50,18 @@ export function createTaskListTool(service) {
|
|
|
50
50
|
},
|
|
51
51
|
},
|
|
52
52
|
},
|
|
53
|
+
/**
|
|
54
|
+
* 结果老化:**整体丢弃**,只留「调用发生过」的最小标记。
|
|
55
|
+
*
|
|
56
|
+
* 依据:任务状态在本请求里已有**活读**副本——`renderSessionTasksInjection(session.tasks)`
|
|
57
|
+
* 每次 run 起点注入 `<session_tasks>`(未完成 goal 的 id / status / description /
|
|
58
|
+
* 步骤进度 / 进展备注)。所以旧的 task_list 结果不是信息补充,而是**同一信息的
|
|
59
|
+
* 过期副本**;而 task_list 是本地查询、零网络成本,重查比读副本更准。
|
|
60
|
+
*
|
|
61
|
+
* 不给「计数摘要」:计数器没有时态标记,40 条消息后会被读成当前事实;
|
|
62
|
+
* 活注入写的是「当前会话未完成任务」,时态明确。
|
|
63
|
+
*/
|
|
64
|
+
ageResult: () => '[stale task_list] call task_list again for current tasks',
|
|
53
65
|
handler: async (args, context) => {
|
|
54
66
|
const status = args.status;
|
|
55
67
|
const parentId = args.parent_id;
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* @layer harness — Session 的具体结构和生命周期管理类型。
|
|
5
5
|
* Core 层的 SessionStore 接口是泛型的,不引用此文件。
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { TenantId } from '@octopi-agent/core/types.js';
|
|
8
|
+
import type { Message, Step, SessionMeta, SessionSpawnLink } from '@octopi-agent/core/types.js';
|
|
8
9
|
import type { SessionTask } from './tasks/types.js';
|
|
9
10
|
import type { ContextCompactSnapshot } from '../context/types.js';
|
|
10
11
|
import type { SessionParticipant } from '../governance/session-acl/types.js';
|
|
@@ -22,24 +23,14 @@ export interface SessionSwitchRecord extends PrincipalRef {
|
|
|
22
23
|
/**
|
|
23
24
|
* 委派产生的 Session 父子关联(I2 投影可重建)
|
|
24
25
|
*
|
|
26
|
+
* 形状单一来源在 core(`@octopi-agent/core/types.js`):`SessionMeta` 投影同源复用。
|
|
25
27
|
* 子 agent 经委派(`arch/delegation.md`)起 Run 时落**独立 Session**,
|
|
26
|
-
*
|
|
28
|
+
* 写入 `SessionData.spawnBy`,使审计链不断(D7)。
|
|
27
29
|
*
|
|
28
30
|
* 刻意不塞 `metadata`:I2 要求 Discourse 权威可重建,
|
|
29
31
|
* 显式字段才好投影 / 检索 / 审计。
|
|
30
32
|
*/
|
|
31
|
-
export
|
|
32
|
-
/** 委派单 ID(`harness/collaboration/delegation`) */
|
|
33
|
-
delegationId: string;
|
|
34
|
-
/** 发起委派的 agentId */
|
|
35
|
-
parentAgentId: string;
|
|
36
|
-
/** 父 session ID */
|
|
37
|
-
parentSessionId: string;
|
|
38
|
-
/** 父 run ID */
|
|
39
|
-
parentRunId: string;
|
|
40
|
-
/** 委派链深度(根委派 = 1) */
|
|
41
|
-
depth?: number;
|
|
42
|
-
}
|
|
33
|
+
export type { SessionSpawnLink };
|
|
43
34
|
/** Session 生命周期状态(`extracted` 已废除:提炼进度归 memory.steward) */
|
|
44
35
|
export type SessionLifecycleStatus = 'active' | 'recent' | 'archived';
|
|
45
36
|
/**
|
|
@@ -67,6 +58,11 @@ export interface SessionData {
|
|
|
67
58
|
* **存储主键是 sessionId**,本字段不再决定物理路径。
|
|
68
59
|
*/
|
|
69
60
|
agentId: string;
|
|
61
|
+
/**
|
|
62
|
+
* 归属租户(arch/multi-tenancy.md §4);创建时写入,不可变。
|
|
63
|
+
* 缺省 DEFAULT_TENANT_ID(存量数据与未接身份层的创建路径同)。
|
|
64
|
+
*/
|
|
65
|
+
tenantId?: TenantId;
|
|
70
66
|
/**
|
|
71
67
|
* 主责 Agent(模型 2 · Accountability)。
|
|
72
68
|
*
|
|
@@ -56,6 +56,9 @@ export interface AgentEventMap {
|
|
|
56
56
|
/** 全量原文估算(仅 Run 页签展示,不进决策/主显示) */
|
|
57
57
|
rawTokens?: number;
|
|
58
58
|
contextWindow?: number;
|
|
59
|
+
/** 当前上下文大小快照(显示槽):只随真实用量写入(stale 回填不带,不冒名新实测)——
|
|
60
|
+
* web 顶栏「xxx / xxx」前段唯一取数源(持久化同源) */
|
|
61
|
+
contextSize?: import('../../context/types.js').ContextSizeSnapshot;
|
|
59
62
|
};
|
|
60
63
|
'tool.exec.start': {
|
|
61
64
|
toolCallId: string;
|
|
@@ -191,6 +194,9 @@ export interface AgentEventMap {
|
|
|
191
194
|
reason: 'proactive' | 'overflow' | 'manual';
|
|
192
195
|
tokensBefore?: number;
|
|
193
196
|
tokensAfter?: number;
|
|
197
|
+
/** 当前上下文大小快照(显示槽;tokens 与 tokensAfter 同值同源,报告尺)。
|
|
198
|
+
* 只在真压缩完成时携带——0/0(无新压缩)与 cancelled(中止零写入)不带 = 显示不动 */
|
|
199
|
+
contextSize?: import('../../context/types.js').ContextSizeSnapshot;
|
|
194
200
|
durationMs?: number;
|
|
195
201
|
cached?: boolean;
|
|
196
202
|
/** true=中止收尾(本轮作废、零写入)——不是「压缩完成」,UI 不得显示 compacted */
|
|
@@ -222,11 +228,34 @@ export interface AgentEventMap {
|
|
|
222
228
|
phase: 'summarize';
|
|
223
229
|
/** 摘要请求体量(JSON 字符数)——事故里就是它从 ~150KB 涨到 2.13MB */
|
|
224
230
|
requestChars?: number;
|
|
231
|
+
/** 摘要请求体量的 token 估算(与会话侧同口径)——面板据此显示,避免「字符 vs token」量纲混排 */
|
|
232
|
+
requestTokens?: number;
|
|
225
233
|
/** 摘要请求消息条数 */
|
|
226
234
|
requestMessages?: number;
|
|
227
235
|
/** 本次调用的单次预算(ms);缺失 = 不设预算 */
|
|
228
236
|
timeoutMs?: number;
|
|
229
237
|
};
|
|
238
|
+
/**
|
|
239
|
+
* 摘要输出闸门判定结果(可观测):每次闸门检查都上报,无论通过与否。
|
|
240
|
+
*
|
|
241
|
+
* 事故背景(2026-11-13):一次摘要被判污染触发 strict 重试,重发整份 348k token
|
|
242
|
+
* 请求(+59s),但全程零事件——UI 只显示「已等待 Ns」,日志无迹可查。闸门必须
|
|
243
|
+
* fail-loud:判定理由、命中量、被丢弃的输出体量都要如实上报。
|
|
244
|
+
*/
|
|
245
|
+
'context.compact.contamination': {
|
|
246
|
+
reason?: 'proactive' | 'overflow' | 'manual';
|
|
247
|
+
/** 判定结论;null = 干净通过 */
|
|
248
|
+
verdict: 'clean' | 'canned_refusal' | 'transcript_shape' | 'verbatim_echo';
|
|
249
|
+
/** 第几次尝试(1=首次,2=strict 重试) */
|
|
250
|
+
attempt: number;
|
|
251
|
+
/** 回声命中行数 / 命中字符数(仅 verbatim_echo 有意义) */
|
|
252
|
+
echoHits?: number;
|
|
253
|
+
echoHitChars?: number;
|
|
254
|
+
/** 被判定输出的字符数 */
|
|
255
|
+
textChars?: number;
|
|
256
|
+
/** 是否因此触发重试(true = 本次输出被丢弃) */
|
|
257
|
+
retryTriggered: boolean;
|
|
258
|
+
};
|
|
230
259
|
/** 摘要请求 cache-miss 旁路/穷尽可观测(F22):no_prefix=无同形前缀,window_guard=前缀放不下改文本化旁路,window_exhausted=最终失败 */
|
|
231
260
|
'context.compact.summarize_fallback': {
|
|
232
261
|
reason?: 'proactive' | 'overflow';
|
|
@@ -26,6 +26,12 @@ export interface ModelConfig {
|
|
|
26
26
|
/** Agent 定义(产品装配形状,非内核合同) */
|
|
27
27
|
export interface AgentDefinition {
|
|
28
28
|
id: string;
|
|
29
|
+
/**
|
|
30
|
+
* 归属租户(arch/multi-tenancy.md §4 隔离矩阵)。
|
|
31
|
+
* 缺省视作 DEFAULT_TENANT_ID(配置 agent / 存量注册表条目);
|
|
32
|
+
* 决定 workspace 派生路径与 audit/credentials 域。
|
|
33
|
+
*/
|
|
34
|
+
tenantId?: string;
|
|
29
35
|
/** Agent home 目录:persona、skills、sessions、extract 的根目录 */
|
|
30
36
|
home: string;
|
|
31
37
|
/** 沙箱工作目录:agent 工具操作的 cwd */
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,8 @@ export type { SecurityAction } from '@octopi-agent/core/security-guard.js';
|
|
|
22
22
|
export type { Observer, Span, LogLevel } from '@octopi-agent/core/interfaces/observer.js';
|
|
23
23
|
export type { SessionStore, SessionListFilter } from '@octopi-agent/core/interfaces/session-store.js';
|
|
24
24
|
export type { SessionData, SessionLifecycleMeta, SessionLifecycleStatus, MemoryExtractionStatus } from './harness/session/types.js';
|
|
25
|
-
export type { ContextEngine, ContextEngineInfo, AssembleParams, AssembleResult, IngestParams, AfterStepParams, TokenEstimator, SummarizeFunction, MessageSelector, SelectResult, SelectOptions, BudgetAllocator, BudgetAllocateParams, BudgetAllocateResult, } from './harness/context/types.js';
|
|
25
|
+
export type { ContextEngine, ContextEngineInfo, AssembleParams, AssembleResult, IngestParams, AfterStepParams, TokenEstimator, SummarizeFunction, MessageSelector, SelectResult, SelectOptions, BudgetAllocator, BudgetAllocateParams, BudgetAllocateResult, ContextSizeSnapshot, } from './harness/context/types.js';
|
|
26
|
+
export { contextSizeSnapshot, isContextSizeSnapshot } from './harness/context/types.js';
|
|
26
27
|
export { setRunTelemetryFactory, getRunTelemetryFactory } from './harness/observability/run-telemetry.js';
|
|
27
28
|
export type { RunTelemetry, RunTelemetryFactory } from './harness/observability/run-telemetry.js';
|
|
28
29
|
export { createRunTelemetry } from './integration/observability/run-telemetry.js';
|
|
@@ -117,7 +118,7 @@ export { AnthropicProvider } from './integration/providers/anthropic.js';
|
|
|
117
118
|
export type { AnthropicProviderConfig } from './integration/providers/anthropic.js';
|
|
118
119
|
export { createDuckDuckGoProvider, createTavilyProvider, createBraveProvider, createSerperProvider, createMimoProvider, createWebSearchProviderFromSlot, resolveWebSearchProviders, createWebSearchWithFallback, } from './integration/web-search/index.js';
|
|
119
120
|
export type { WebSearchProvider, WebSearchOptions, WebSearchResponse, WebSearchResultItem, WebSearchConfig, WebSearchProviderSlotConfig, ResolvedWebSearchProviders, } from './integration/web-search/index.js';
|
|
120
|
-
export { createProviderFromConfig, resolveModelConfig, flattenModels, resolveListenHost, resolveViteHostArg, isLanHost, } from './config.js';
|
|
121
|
+
export { createProviderFromConfig, createChannelAdapterFromConfig, resolveModelConfig, flattenModels, resolveListenHost, resolveViteHostArg, isLanHost, } from './config.js';
|
|
121
122
|
export type { ModelsConfig, ModelProviderConfig, ModelCapability, ModelInputType, NormalizedHarnessConfig, NormalizedModelInfo, HarnessConfig, AgentConfig, ContextEngineConfig, ContextAssemblerConfig, ChannelConfig, PluginConfig, Defaults, NetworkHostConfig, WebSearchToolConfig, WebSearchProviderSlot, } from './config.js';
|
|
122
123
|
export { engineConfigSchema } from './config-schema/engine.js';
|
|
123
124
|
export type { EngineConfig } from './config-schema/engine.js';
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export { DefaultSecurityGuard } from './harness/governance/security/default-secu
|
|
|
12
12
|
export { BudgetPolicyEngine, DEFAULT_BUDGET } from './harness/run/budget/budget.js';
|
|
13
13
|
export { UsageLedger } from './harness/governance/accounting/usage-ledger.js';
|
|
14
14
|
export { emptyTokenUsage, makeTokenUsage, nominalTotalTokens, reportedPromptTokens, } from '@octopi-agent/core/types/step.js';
|
|
15
|
+
export { contextSizeSnapshot, isContextSizeSnapshot } from './harness/context/types.js';
|
|
15
16
|
// ============================================================
|
|
16
17
|
// Harness 层
|
|
17
18
|
// ============================================================
|
|
@@ -78,7 +79,7 @@ export { createDuckDuckGoProvider, createTavilyProvider, createBraveProvider, cr
|
|
|
78
79
|
// ============================================================
|
|
79
80
|
// Config(类型 + 工厂)
|
|
80
81
|
// ============================================================
|
|
81
|
-
export { createProviderFromConfig, resolveModelConfig, flattenModels, resolveListenHost, resolveViteHostArg, isLanHost, } from './config.js';
|
|
82
|
+
export { createProviderFromConfig, createChannelAdapterFromConfig, resolveModelConfig, flattenModels, resolveListenHost, resolveViteHostArg, isLanHost, } from './config.js';
|
|
82
83
|
export { engineConfigSchema } from './config-schema/engine.js';
|
|
83
84
|
export { getBuiltinModelInfo, mergeWithBuiltinInfo } from './builtin-model-info.js';
|
|
84
85
|
// ============================================================
|
|
@@ -13,8 +13,10 @@ export interface ChannelMessageSourceOptions {
|
|
|
13
13
|
resolveAgentId: (msg: ChannelMessage) => string | undefined;
|
|
14
14
|
/** ChannelMessage → sessionId */
|
|
15
15
|
resolveSessionId: (msg: ChannelMessage) => string;
|
|
16
|
+
/** 触发源归属租户(§9.1-6:渠道 bot 归属锚);随 Trigger 传播进 run principal */
|
|
17
|
+
tenantId?: string;
|
|
16
18
|
}
|
|
17
|
-
export declare function channelMessageToTrigger(msg: ChannelMessage, agentId: string, sessionId: string): Trigger;
|
|
19
|
+
export declare function channelMessageToTrigger(msg: ChannelMessage, agentId: string, sessionId: string, tenantId?: string): Trigger;
|
|
18
20
|
/**
|
|
19
21
|
* dispatch 一条通道消息(模型 A:await 至 Run 结束)。
|
|
20
22
|
* onEvent 用于 Gateway 流式广播 / 捕获最终回复。
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 协议解耦在 Integration;Harness 只见 Trigger(arch/agent-runtime.md)。
|
|
6
6
|
*/
|
|
7
7
|
import { randomUUID } from 'node:crypto';
|
|
8
|
-
export function channelMessageToTrigger(msg, agentId, sessionId) {
|
|
8
|
+
export function channelMessageToTrigger(msg, agentId, sessionId, tenantId) {
|
|
9
9
|
const modelOverride = msg.metadata?.model;
|
|
10
10
|
const attachRefs = msg.metadata?.attachments;
|
|
11
11
|
return {
|
|
@@ -13,6 +13,7 @@ export function channelMessageToTrigger(msg, agentId, sessionId) {
|
|
|
13
13
|
type: 'message',
|
|
14
14
|
agentId,
|
|
15
15
|
sessionId,
|
|
16
|
+
...(tenantId === undefined ? {} : { tenantId }),
|
|
16
17
|
timestamp: msg.timestamp,
|
|
17
18
|
payload: {
|
|
18
19
|
kind: 'user_message',
|
|
@@ -47,7 +48,7 @@ export function channelMessageToTrigger(msg, agentId, sessionId) {
|
|
|
47
48
|
* onEvent 用于 Gateway 流式广播 / 捕获最终回复。
|
|
48
49
|
*/
|
|
49
50
|
export async function dispatchChannelMessage(options) {
|
|
50
|
-
const { runtime, msg, resolveAgentId, resolveSessionId, onEvent } = options;
|
|
51
|
+
const { runtime, msg, resolveAgentId, resolveSessionId, onEvent, tenantId } = options;
|
|
51
52
|
const agentId = resolveAgentId(msg);
|
|
52
53
|
if (!agentId) {
|
|
53
54
|
// 回执契约 = 恒发一次(liveness);no_agent 的实际结果由上层 error/静默路径处理
|
|
@@ -56,7 +57,7 @@ export async function dispatchChannelMessage(options) {
|
|
|
56
57
|
return { status: 'skipped', reason: 'no_agent' };
|
|
57
58
|
}
|
|
58
59
|
const sessionId = resolveSessionId(msg);
|
|
59
|
-
const trigger = channelMessageToTrigger(msg, agentId, sessionId);
|
|
60
|
+
const trigger = channelMessageToTrigger(msg, agentId, sessionId, tenantId);
|
|
60
61
|
// 单一入口:dispatch 内部 offer;活跃 Run 接收即回执(早于 Run 结束)。
|
|
61
62
|
// 拒绝/早退路径(runtime_stopped 等)也要回执一次(liveness),错误走 error 通道。
|
|
62
63
|
let delivered = false;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { PwBrowser } from './playwright.js';
|
|
2
|
+
/** camoufox-js 的最小结构(运行时动态 import;编译期零耦合) */
|
|
3
|
+
interface CamoufoxModule {
|
|
4
|
+
/** 启动定制 Firefox,返回 Playwright Browser(firefox/Juggler) */
|
|
5
|
+
Camoufox(options?: unknown): Promise<unknown>;
|
|
6
|
+
}
|
|
7
|
+
/** 启动器形状(与 PlaywrightBrowserPort 的 launcher 参数结构兼容) */
|
|
8
|
+
export type CamoufoxLauncher = (opts: {
|
|
9
|
+
headless: boolean;
|
|
10
|
+
channel?: 'chromium' | 'chrome';
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
}) => Promise<PwBrowser>;
|
|
13
|
+
/**
|
|
14
|
+
* camoufox provider 安装目录(与 `octopi browser install --engine camoufox` 同一约定)。
|
|
15
|
+
*
|
|
16
|
+
* @returns `<OCTOPI_HOME>/browser-providers/camoufox`(OCTOPI_HOME 缺省 ~/.octopi)
|
|
17
|
+
*/
|
|
18
|
+
export declare function camoufoxProviderDir(): string;
|
|
19
|
+
/**
|
|
20
|
+
* 解析 camoufox-js 自带 CLI 路径(`octopi browser install` 下载浏览器用)。
|
|
21
|
+
*
|
|
22
|
+
* @returns dist/__main__.js 绝对路径;provider 未安装时返回 null
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveCamoufoxJsCliPath(): string | null;
|
|
25
|
+
/**
|
|
26
|
+
* 加载隔离安装的 camoufox-js provider(绝对路径 import;单飞缓存)。
|
|
27
|
+
*
|
|
28
|
+
* @throws provider 未安装时 `not_implemented: … — run "octopi browser install --engine camoufox"`(fail-loud,不静默降级)
|
|
29
|
+
*/
|
|
30
|
+
export declare function loadCamoufoxProvider(): Promise<CamoufoxModule>;
|
|
31
|
+
/**
|
|
32
|
+
* 创建 camoufox 启动器(注入 PlaywrightBrowserPort 的 `launcher`)。
|
|
33
|
+
*
|
|
34
|
+
* 浏览器二进制由 camoufox-js 自行解析(`CAMOUFOX_INSTALL_DIR`/`~/.cache/camoufox`,
|
|
35
|
+
* 缺失时首启自动下载——显式安装仍推荐 `octopi browser install --engine camoufox`)。
|
|
36
|
+
*
|
|
37
|
+
* @returns 结构兼容 PwBrowser 的启动器(firefox/Juggler 驱动)
|
|
38
|
+
*/
|
|
39
|
+
export declare function createCamoufoxLauncher(): CamoufoxLauncher;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* integration/browser/camoufox.ts — Camoufox 后端接入(P3 备选 stealth)
|
|
3
|
+
*
|
|
4
|
+
* **依赖隔离设计**:camoufox-js 的 peer 钉 `playwright-core <1.63`(与主树
|
|
5
|
+
* 1.65+ 冲突)且带原生依赖(better-sqlite3 等)——不进主依赖树。`octopi browser
|
|
6
|
+
* install --engine camoufox` 在独立 provider 目录(`OCTOPI_HOME/browser-providers/
|
|
7
|
+
* camoufox/`,自带 package.json)安装 camoufox-js + 自洽的 playwright-core,运行期
|
|
8
|
+
* **按绝对路径动态 import**,依赖冲突与原生构建不外溢到嵌入方安装树。
|
|
9
|
+
*
|
|
10
|
+
* Camoufox 自带定制 Firefox 二进制(`camoufox-js fetch` 下载,pin 版本),不依赖
|
|
11
|
+
* 系统安装 Firefox;其返回的是标准 Playwright Browser/Page,走既有会话实现。
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import { existsSync } from 'node:fs';
|
|
16
|
+
import { homedir } from 'node:os';
|
|
17
|
+
import { join } from 'node:path';
|
|
18
|
+
import { pathToFileURL } from 'node:url';
|
|
19
|
+
/**
|
|
20
|
+
* camoufox provider 安装目录(与 `octopi browser install --engine camoufox` 同一约定)。
|
|
21
|
+
*
|
|
22
|
+
* @returns `<OCTOPI_HOME>/browser-providers/camoufox`(OCTOPI_HOME 缺省 ~/.octopi)
|
|
23
|
+
*/
|
|
24
|
+
export function camoufoxProviderDir() {
|
|
25
|
+
const home = process.env.OCTOPI_HOME || join(homedir(), '.octopi');
|
|
26
|
+
return join(home, 'browser-providers', 'camoufox');
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 解析 camoufox-js 自带 CLI 路径(`octopi browser install` 下载浏览器用)。
|
|
30
|
+
*
|
|
31
|
+
* @returns dist/__main__.js 绝对路径;provider 未安装时返回 null
|
|
32
|
+
*/
|
|
33
|
+
export function resolveCamoufoxJsCliPath() {
|
|
34
|
+
try {
|
|
35
|
+
const entry = join(camoufoxProviderDir(), 'node_modules', 'camoufox-js', 'dist', '__main__.js');
|
|
36
|
+
// 必须查存在性:仅拼路径会在 provider 缺席时返回假阳性(状态卡会放大成谎报)
|
|
37
|
+
return existsSync(entry) ? entry : null;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
let providerPromise;
|
|
44
|
+
/**
|
|
45
|
+
* 加载隔离安装的 camoufox-js provider(绝对路径 import;单飞缓存)。
|
|
46
|
+
*
|
|
47
|
+
* @throws provider 未安装时 `not_implemented: … — run "octopi browser install --engine camoufox"`(fail-loud,不静默降级)
|
|
48
|
+
*/
|
|
49
|
+
export async function loadCamoufoxProvider() {
|
|
50
|
+
if (!providerPromise) {
|
|
51
|
+
providerPromise = (async () => {
|
|
52
|
+
const entry = join(camoufoxProviderDir(), 'node_modules', 'camoufox-js', 'dist', 'index.js');
|
|
53
|
+
try {
|
|
54
|
+
return (await import(pathToFileURL(entry).href));
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
providerPromise = undefined; // 允许安装后重试
|
|
58
|
+
throw new Error('not_implemented: camoufox provider not installed — run "octopi browser install --engine camoufox"', { cause: err });
|
|
59
|
+
}
|
|
60
|
+
})();
|
|
61
|
+
}
|
|
62
|
+
return providerPromise;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 创建 camoufox 启动器(注入 PlaywrightBrowserPort 的 `launcher`)。
|
|
66
|
+
*
|
|
67
|
+
* 浏览器二进制由 camoufox-js 自行解析(`CAMOUFOX_INSTALL_DIR`/`~/.cache/camoufox`,
|
|
68
|
+
* 缺失时首启自动下载——显式安装仍推荐 `octopi browser install --engine camoufox`)。
|
|
69
|
+
*
|
|
70
|
+
* @returns 结构兼容 PwBrowser 的启动器(firefox/Juggler 驱动)
|
|
71
|
+
*/
|
|
72
|
+
export function createCamoufoxLauncher() {
|
|
73
|
+
return async ({ headless, timeoutMs }) => {
|
|
74
|
+
const mod = await loadCamoufoxProvider();
|
|
75
|
+
return mod.Camoufox({
|
|
76
|
+
headless,
|
|
77
|
+
...(timeoutMs ? { timeout: timeoutMs } : {}),
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* integration/browser — 浏览器后端集成(arch/browser-capability.md §3)
|
|
3
|
+
*
|
|
4
|
+
* 后端矩阵(§3.3):playwright / rebrowser / camoufox / cdp-attach 已实现;
|
|
5
|
+
* cloud 为 P4 槽位——显式配置未实现引擎时 fail-loud 拒绝装配(不静默降级)。
|
|
6
|
+
*/
|
|
7
|
+
import type { BrowserService, BrowserStealthConfig } from '../../harness/extension/plugin-ecosystem/tools/browser-types.js';
|
|
8
|
+
export { DefaultBrowserService } from './service.js';
|
|
9
|
+
export { PlaywrightBrowserPort, PlaywrightBrowserSession } from './playwright.js';
|
|
10
|
+
export { camoufoxProviderDir, createCamoufoxLauncher, loadCamoufoxProvider, resolveCamoufoxJsCliPath, } from './camoufox.js';
|
|
11
|
+
export { parseFallbackChain, StealthFallbackService } from './stealth.js';
|
|
12
|
+
export { installEngine, probeEngines, type EngineStatus, type InstallableEngine, type InstallResult, } from './install.js';
|
|
13
|
+
/**
|
|
14
|
+
* `browser.*` 配置块形状(createBrowserService 的入参)。
|
|
15
|
+
*
|
|
16
|
+
* **消费方分工**(勿假设全部由引擎消费):`engine/channel/headless/timeoutMs/
|
|
17
|
+
* viewport/locale/sessionIdleTimeoutMs` 由本工厂消费(启动/回收);
|
|
18
|
+
* `enabled/network/confirm/snapshotMaxChars` 由**工具面**消费(assemble →
|
|
19
|
+
* `createBrowserTools`),工厂不读——放这里只为让配置块形状单一。
|
|
20
|
+
*/
|
|
21
|
+
export interface BrowserServiceOptions {
|
|
22
|
+
/** 工具面注册开关(缺省 true = 拍板默认开)——工具面消费 */
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
/** 后端引擎(auto = playwright)——工厂消费 */
|
|
25
|
+
engine?: string;
|
|
26
|
+
/** attach 端点(engine=cdp-attach;缺省 http://127.0.0.1:9222)——工厂消费 */
|
|
27
|
+
attach?: {
|
|
28
|
+
endpoint?: string;
|
|
29
|
+
};
|
|
30
|
+
/** 持久 profile(P2):defaultProfile/persist——工具面消费(注入 launch 选项) */
|
|
31
|
+
profiles?: {
|
|
32
|
+
persist?: boolean;
|
|
33
|
+
defaultProfile?: string;
|
|
34
|
+
};
|
|
35
|
+
/** profile 存储目录——工具面消费 */
|
|
36
|
+
profileDir?: string;
|
|
37
|
+
/** 浏览器来源:chromium(管理版)| chrome(系统 Chrome)——工厂消费 */
|
|
38
|
+
channel?: 'chromium' | 'chrome';
|
|
39
|
+
/** 无头开关——工厂消费 */
|
|
40
|
+
headless?: boolean;
|
|
41
|
+
/** 工具/动作超时(毫秒)——工厂消费 */
|
|
42
|
+
timeoutMs?: number;
|
|
43
|
+
/** 快照序列化预算(字符)——工具面消费 */
|
|
44
|
+
snapshotMaxChars?: number;
|
|
45
|
+
/** 会话空闲回收(毫秒;<=0 不回收;缺省 30 分钟)——工厂消费 */
|
|
46
|
+
sessionIdleTimeoutMs?: number;
|
|
47
|
+
/** 视口——工厂消费 */
|
|
48
|
+
viewport?: {
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
};
|
|
52
|
+
/** 语言环境——工厂消费 */
|
|
53
|
+
locale?: string;
|
|
54
|
+
/** URL 策略:域名 allow/deny(deny 优先)+ 私网门禁——工具面消费(注入会话策略) */
|
|
55
|
+
network?: {
|
|
56
|
+
domains?: {
|
|
57
|
+
allow?: string[];
|
|
58
|
+
deny?: string[];
|
|
59
|
+
};
|
|
60
|
+
allowPrivateNetwork?: boolean;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* 敏感动作确认闸门三档(2026-11-20 拍板)——工具面消费:
|
|
64
|
+
* `strict` = 所有非 GET 过闸(含页内 fetch/XHR);`standard`(缺省)= 仅文档级
|
|
65
|
+
* (表单提交/密码/上传);`off` = 全放开。
|
|
66
|
+
*/
|
|
67
|
+
confirm?: 'strict' | 'standard' | 'off';
|
|
68
|
+
/** stealth(P3):fallback 链由服务层消费;humanize 透传工具层 */
|
|
69
|
+
stealth?: BrowserStealthConfig;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 按配置创建浏览器会话服务。
|
|
73
|
+
*
|
|
74
|
+
* @param options - 引擎与启动默认值
|
|
75
|
+
* @throws 配置了未实现的引擎时 `not_implemented: …`(fail-loud,不静默降级)
|
|
76
|
+
*/
|
|
77
|
+
export declare function createBrowserService(options?: BrowserServiceOptions): BrowserService;
|
|
78
|
+
/**
|
|
79
|
+
* 解析 playwright-core 自带 CLI 路径(`octopi browser install` 用)。
|
|
80
|
+
* 从引擎侧解析(engine 自己的可选依赖),npm/pnpm/嵌套布局都一致。
|
|
81
|
+
*
|
|
82
|
+
* @returns cli.js 绝对路径;playwright-core 未安装时返回 null(调用方 fail-loud)
|
|
83
|
+
*/
|
|
84
|
+
export declare function resolvePlaywrightCliPath(): string | null;
|
|
85
|
+
/**
|
|
86
|
+
* 解析 rebrowser-playwright-core 自带 CLI 路径(P3:rebrowser Chromium 安装用)。
|
|
87
|
+
* 同 `resolvePlaywrightCliPath` 解析方式(fork 同布局)。
|
|
88
|
+
*
|
|
89
|
+
* @returns cli.js 绝对路径;未安装时返回 null(调用方 fail-loud)
|
|
90
|
+
*/
|
|
91
|
+
export declare function resolveRebrowserCliPath(): string | null;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* integration/browser — 浏览器后端集成(arch/browser-capability.md §3)
|
|
3
|
+
*
|
|
4
|
+
* 后端矩阵(§3.3):playwright / rebrowser / camoufox / cdp-attach 已实现;
|
|
5
|
+
* cloud 为 P4 槽位——显式配置未实现引擎时 fail-loud 拒绝装配(不静默降级)。
|
|
6
|
+
*/
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
import { dirname, join } from 'node:path';
|
|
9
|
+
import { DefaultBrowserService } from './service.js';
|
|
10
|
+
import { PlaywrightBrowserPort } from './playwright.js';
|
|
11
|
+
import { createCamoufoxLauncher } from './camoufox.js';
|
|
12
|
+
import { parseFallbackChain, StealthFallbackService } from './stealth.js';
|
|
13
|
+
export { DefaultBrowserService } from './service.js';
|
|
14
|
+
export { PlaywrightBrowserPort, PlaywrightBrowserSession } from './playwright.js';
|
|
15
|
+
export { camoufoxProviderDir, createCamoufoxLauncher, loadCamoufoxProvider, resolveCamoufoxJsCliPath, } from './camoufox.js';
|
|
16
|
+
export { parseFallbackChain, StealthFallbackService } from './stealth.js';
|
|
17
|
+
export { installEngine, probeEngines, } from './install.js';
|
|
18
|
+
/**
|
|
19
|
+
* 按配置创建浏览器会话服务。
|
|
20
|
+
*
|
|
21
|
+
* @param options - 引擎与启动默认值
|
|
22
|
+
* @throws 配置了未实现的引擎时 `not_implemented: …`(fail-loud,不静默降级)
|
|
23
|
+
*/
|
|
24
|
+
export function createBrowserService(options = {}) {
|
|
25
|
+
const engine = options.engine ?? 'auto';
|
|
26
|
+
switch (engine) {
|
|
27
|
+
case 'auto':
|
|
28
|
+
case 'playwright':
|
|
29
|
+
return new DefaultBrowserService(new PlaywrightBrowserPort({
|
|
30
|
+
headless: options.headless,
|
|
31
|
+
channel: options.channel,
|
|
32
|
+
timeoutMs: options.timeoutMs,
|
|
33
|
+
viewport: options.viewport,
|
|
34
|
+
locale: options.locale,
|
|
35
|
+
}), { sessionIdleTimeoutMs: options.sessionIdleTimeoutMs });
|
|
36
|
+
case 'cdp-attach':
|
|
37
|
+
// P2:attach 用户真实 Chrome(launch 派发到 connectOverCDP;close=断开不杀)
|
|
38
|
+
return new DefaultBrowserService(new PlaywrightBrowserPort({
|
|
39
|
+
timeoutMs: options.timeoutMs,
|
|
40
|
+
attachMode: true,
|
|
41
|
+
attachEndpoint: options.attach?.endpoint,
|
|
42
|
+
}), { sessionIdleTimeoutMs: options.sessionIdleTimeoutMs });
|
|
43
|
+
case 'rebrowser':
|
|
44
|
+
// P3 默认 stealth 后端:drop-in 补丁版 playwright-core(同 API、同 Chromium 二进制;
|
|
45
|
+
// 补 Runtime.enable 泄漏/webdriver 标记;请求策略仍走 CDP Fetch)
|
|
46
|
+
return new DefaultBrowserService(new PlaywrightBrowserPort({
|
|
47
|
+
headless: options.headless,
|
|
48
|
+
channel: options.channel,
|
|
49
|
+
timeoutMs: options.timeoutMs,
|
|
50
|
+
viewport: options.viewport,
|
|
51
|
+
locale: options.locale,
|
|
52
|
+
driver: 'rebrowser-playwright-core',
|
|
53
|
+
engine: 'rebrowser',
|
|
54
|
+
}), { sessionIdleTimeoutMs: options.sessionIdleTimeoutMs });
|
|
55
|
+
case 'camoufox':
|
|
56
|
+
// P3 备选 stealth 后端:隔离 provider 的定制 Firefox(指纹差异化;无 CDP Fetch
|
|
57
|
+
// 域 → 请求策略走 route 逐跳走查)
|
|
58
|
+
return new DefaultBrowserService(new PlaywrightBrowserPort({
|
|
59
|
+
headless: options.headless,
|
|
60
|
+
timeoutMs: options.timeoutMs,
|
|
61
|
+
viewport: options.viewport,
|
|
62
|
+
locale: options.locale,
|
|
63
|
+
engine: 'camoufox',
|
|
64
|
+
policyMode: 'route-walk',
|
|
65
|
+
launcher: createCamoufoxLauncher(),
|
|
66
|
+
}), { sessionIdleTimeoutMs: options.sessionIdleTimeoutMs });
|
|
67
|
+
case 'stealth': {
|
|
68
|
+
// P3 隐身链:按 stealth.fallback(缺省 rebrowser->camoufox)建链;挑战命中有界轮换
|
|
69
|
+
const chainNames = parseFallbackChain(options.stealth?.fallback);
|
|
70
|
+
const chain = chainNames.map((name) => createBrowserService({ ...options, engine: name }));
|
|
71
|
+
return new StealthFallbackService(chain);
|
|
72
|
+
}
|
|
73
|
+
case 'cloud':
|
|
74
|
+
throw new Error(`not_implemented: browser engine "${engine}" lands in P4 (arch/browser-capability.md §4)`);
|
|
75
|
+
default:
|
|
76
|
+
throw new Error(`not_implemented: unknown browser engine "${engine}"`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 解析 playwright-core 自带 CLI 路径(`octopi browser install` 用)。
|
|
81
|
+
* 从引擎侧解析(engine 自己的可选依赖),npm/pnpm/嵌套布局都一致。
|
|
82
|
+
*
|
|
83
|
+
* @returns cli.js 绝对路径;playwright-core 未安装时返回 null(调用方 fail-loud)
|
|
84
|
+
*/
|
|
85
|
+
export function resolvePlaywrightCliPath() {
|
|
86
|
+
try {
|
|
87
|
+
const require = createRequire(import.meta.url);
|
|
88
|
+
const pkgPath = require.resolve('playwright-core/package.json');
|
|
89
|
+
return join(dirname(pkgPath), 'cli.js');
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 解析 rebrowser-playwright-core 自带 CLI 路径(P3:rebrowser Chromium 安装用)。
|
|
97
|
+
* 同 `resolvePlaywrightCliPath` 解析方式(fork 同布局)。
|
|
98
|
+
*
|
|
99
|
+
* @returns cli.js 绝对路径;未安装时返回 null(调用方 fail-loud)
|
|
100
|
+
*/
|
|
101
|
+
export function resolveRebrowserCliPath() {
|
|
102
|
+
try {
|
|
103
|
+
const require = createRequire(import.meta.url);
|
|
104
|
+
const pkgPath = require.resolve('rebrowser-playwright-core/package.json');
|
|
105
|
+
return join(dirname(pkgPath), 'cli.js');
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
/** 可安装引擎(与 browser.engine 同名;cdp-attach 用真实浏览器无需安装) */
|
|
16
|
+
export type InstallableEngine = 'playwright' | 'rebrowser' | 'camoufox' | 'stealth';
|
|
17
|
+
/** 引擎就绪状态(WebUI 状态卡消费) */
|
|
18
|
+
export interface EngineStatus {
|
|
19
|
+
/** 引擎名(含 cdp-attach:恒 ready——浏览器就是用户的 Chrome) */
|
|
20
|
+
engine: 'playwright' | 'rebrowser' | 'camoufox' | 'stealth' | 'cdp-attach';
|
|
21
|
+
/** 就绪判定:驱动包在 + 二进制在(启发式探测,detail 说明依据) */
|
|
22
|
+
ready: boolean;
|
|
23
|
+
/** 人类可读的状态依据(缺什么、下一步跑什么) */
|
|
24
|
+
detail: string;
|
|
25
|
+
}
|
|
26
|
+
/** 安装结果 */
|
|
27
|
+
export interface InstallResult {
|
|
28
|
+
ok: boolean;
|
|
29
|
+
/** 汇总说明(ok=false 时是失败依据) */
|
|
30
|
+
detail: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 探测全部引擎的就绪状态(WebUI 状态卡 / CLI 预检共用)。
|
|
34
|
+
*
|
|
35
|
+
* @returns 各引擎状态(顺序固定:playwright / rebrowser / camoufox / stealth / cdp-attach)
|
|
36
|
+
*/
|
|
37
|
+
export declare function probeEngines(): EngineStatus[];
|
|
38
|
+
/**
|
|
39
|
+
* 安装引擎二进制 / 提供方(幂等;重跑安全)。
|
|
40
|
+
*
|
|
41
|
+
* @param engine - 引擎名(stealth = rebrowser + camoufox)
|
|
42
|
+
* @param options.onProgress - 子进程输出按行回调(CLI 透传终端;gateway 缓冲)
|
|
43
|
+
* @returns 安装结果(ok=false 时 detail 是失败依据;不静默吞错)
|
|
44
|
+
*/
|
|
45
|
+
export declare function installEngine(engine: string, options?: {
|
|
46
|
+
onProgress?: (line: string) => void;
|
|
47
|
+
}): Promise<InstallResult>;
|