@octopi-agent/engine 0.98.4 → 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 +40 -6
- package/dist/config-schema/agent.js +44 -6
- package/dist/config-schema/browser.d.ts +62 -0
- package/dist/config-schema/browser.js +89 -0
- package/dist/config-schema/context.d.ts +12 -37
- package/dist/config-schema/context.js +10 -31
- package/dist/config-schema/engine.d.ts +140 -164
- package/dist/config-schema/engine.js +10 -7
- package/dist/config-schema/governance.d.ts +20 -2
- package/dist/config-schema/governance.js +18 -3
- package/dist/config-schema/models.d.ts +10 -12
- package/dist/config-schema/models.js +16 -3
- package/dist/config-schema/run.d.ts +6 -2
- package/dist/config-schema/run.js +12 -2
- package/dist/config-schema/shared.d.ts +1 -3
- package/dist/config-schema/shared.js +4 -4
- package/dist/config-schema/substrate.d.ts +19 -88
- package/dist/config-schema/substrate.js +30 -107
- package/dist/config.d.ts +161 -123
- package/dist/config.js +109 -7
- 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 +11 -0
- package/dist/harness/activation/inbox.d.ts +3 -3
- package/dist/harness/activation/inbox.js +3 -3
- 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 +130 -31
- package/dist/harness/activation/types.d.ts +20 -3
- package/dist/harness/agent/builder.d.ts +36 -3
- package/dist/harness/agent/builder.js +206 -46
- package/dist/harness/agent/config-bridge.d.ts +10 -1
- package/dist/harness/agent/config-bridge.js +24 -5
- package/dist/harness/agent/config-integrity.js +19 -2
- 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 +13 -3
- package/dist/harness/agent/wire-agent-builder.js +35 -9
- package/dist/harness/capabilities/document/backends/plain.js +2 -1
- package/dist/harness/capabilities/document/factory.d.ts +5 -0
- package/dist/harness/capabilities/document/factory.js +1 -0
- package/dist/harness/capabilities/document/legacy/factory.js +3 -2
- package/dist/harness/capabilities/document/port.js +6 -3
- package/dist/harness/capabilities/document/types.d.ts +5 -0
- 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 +2 -1
- 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 +14 -4
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.js +50 -41
- package/dist/harness/collaboration/autonomous-subsystem/sense/input-builder.js +4 -4
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/signal/bus.d.ts +6 -0
- package/dist/harness/collaboration/autonomous-subsystem/signal/bus.js +25 -4
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +4 -1
- package/dist/harness/collaboration/autonomous-subsystem/types.d.ts +7 -3
- package/dist/harness/collaboration/delegation/child-run.d.ts +10 -1
- package/dist/harness/collaboration/delegation/child-run.js +38 -6
- package/dist/harness/collaboration/delegation/index.d.ts +1 -1
- package/dist/harness/collaboration/delegation/index.js +1 -1
- package/dist/harness/collaboration/delegation/notifier.d.ts +6 -1
- package/dist/harness/collaboration/delegation/notifier.js +8 -1
- package/dist/harness/collaboration/delegation/registry-types.d.ts +2 -0
- package/dist/harness/collaboration/delegation/service.d.ts +11 -4
- package/dist/harness/collaboration/delegation/service.js +35 -13
- package/dist/harness/collaboration/delegation/store.d.ts +4 -0
- package/dist/harness/collaboration/delegation/store.js +3 -1
- package/dist/harness/collaboration/delegation/types.d.ts +34 -2
- package/dist/harness/collaboration/delegation/types.js +22 -0
- package/dist/harness/collaboration/delegation/wiring.d.ts +2 -0
- package/dist/harness/collaboration/delegation/wiring.js +12 -1
- package/dist/harness/context/budget-allocator.d.ts +26 -18
- package/dist/harness/context/budget-allocator.js +67 -32
- package/dist/harness/context/capabilities/compact/engine.d.ts +44 -11
- package/dist/harness/context/capabilities/compact/engine.js +296 -160
- package/dist/harness/context/capabilities/compact/handover.d.ts +5 -3
- package/dist/harness/context/capabilities/compact/handover.js +7 -5
- package/dist/harness/context/capabilities/compact/index.d.ts +7 -2
- package/dist/harness/context/capabilities/compact/index.js +5 -1
- package/dist/harness/context/capabilities/compact/mechanical.d.ts +130 -0
- package/dist/harness/context/capabilities/compact/mechanical.js +268 -0
- package/dist/harness/context/capabilities/compact/messages.d.ts +60 -0
- package/dist/harness/context/capabilities/compact/messages.js +91 -0
- package/dist/harness/context/capabilities/compact/types.d.ts +134 -19
- package/dist/harness/context/capabilities/compact/types.js +11 -1
- package/dist/harness/context/capabilities/compact/view-split.d.ts +36 -0
- package/dist/harness/context/capabilities/compact/view-split.js +72 -0
- 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/port.js +0 -1
- package/dist/harness/context/capabilities/summary/registry.js +20 -0
- package/dist/harness/context/capabilities/summary/resolver.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/resolver.js +1 -6
- package/dist/harness/context/capabilities/summary/tool-binding.d.ts +1 -1
- 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 +19 -6
- package/dist/harness/context/constitution/default-agents.md +85 -0
- package/dist/harness/context/context-size-ledger.d.ts +143 -0
- package/dist/harness/context/context-size-ledger.js +243 -0
- package/dist/harness/context/default-context-engine.d.ts +290 -120
- package/dist/harness/context/default-context-engine.js +1555 -764
- package/dist/harness/context/index.d.ts +3 -2
- package/dist/harness/context/index.js +2 -1
- 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 +72 -0
- package/dist/harness/context/layer-types.js +87 -2
- package/dist/harness/context/layers.d.ts +17 -15
- package/dist/harness/context/layers.js +54 -17
- package/dist/harness/context/message-selector.d.ts +10 -8
- package/dist/harness/context/message-selector.js +49 -27
- package/dist/harness/context/prefix-fingerprint.d.ts +46 -0
- package/dist/harness/context/prefix-fingerprint.js +52 -0
- package/dist/harness/context/summarize.d.ts +2 -2
- package/dist/harness/context/summarize.js +27 -2
- package/dist/harness/context/system-prompt-assembler.d.ts +4 -0
- package/dist/harness/context/system-prompt-assembler.js +7 -3
- package/dist/harness/context/token-constants.d.ts +8 -6
- package/dist/harness/context/token-constants.js +8 -7
- package/dist/harness/context/token-estimate-fns.d.ts +37 -27
- package/dist/harness/context/token-estimate-fns.js +85 -66
- package/dist/harness/context/token-estimator.d.ts +27 -12
- package/dist/harness/context/token-estimator.js +120 -66
- package/dist/harness/context/token-segments.d.ts +88 -0
- package/dist/harness/context/token-segments.js +103 -0
- package/dist/harness/context/tool-result-aging.d.ts +109 -16
- package/dist/harness/context/tool-result-aging.js +220 -55
- package/dist/harness/context/tool-result-body.js +2 -0
- package/dist/harness/context/transform/anchors.d.ts +66 -0
- package/dist/harness/context/transform/anchors.js +125 -0
- package/dist/harness/context/transform/fold.d.ts +56 -0
- package/dist/harness/context/transform/fold.js +135 -0
- package/dist/harness/context/transform/migrate.d.ts +41 -0
- package/dist/harness/context/transform/migrate.js +69 -0
- package/dist/harness/context/transform/types.d.ts +129 -0
- package/dist/harness/context/transform/types.js +19 -0
- package/dist/harness/context/turn-envelope.d.ts +6 -3
- package/dist/harness/context/types.d.ts +196 -119
- 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/ops-audit.d.ts +1 -1
- package/dist/harness/extension/execution-environment/privileged-exec.js +4 -1
- package/dist/harness/extension/execution-environment/resource-limits.d.ts +1 -1
- package/dist/harness/extension/execution-environment/resource-limits.js +1 -1
- package/dist/harness/extension/execution-environment/workspace.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +28 -2
- 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/commands/index.d.ts +3 -1
- package/dist/harness/extension/plugin-ecosystem/commands/index.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/commands/plugin-bridge.d.ts +12 -1
- package/dist/harness/extension/plugin-ecosystem/commands/plugin-bridge.js +14 -4
- package/dist/harness/extension/plugin-ecosystem/commands/router.d.ts +5 -4
- package/dist/harness/extension/plugin-ecosystem/commands/router.js +23 -14
- package/dist/harness/extension/plugin-ecosystem/commands/types.d.ts +8 -1
- package/dist/harness/extension/plugin-ecosystem/commands/types.js +2 -1
- package/dist/harness/extension/plugin-ecosystem/hooks/adapter.d.ts +54 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/adapter.js +397 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/compaction-integration.d.ts +16 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/compaction-integration.js +66 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/index.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/index.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/iteration-snapshot.d.ts +11 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/iteration-snapshot.js +54 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/journal.d.ts +9 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/journal.js +22 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/policy-error.d.ts +12 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/policy-error.js +19 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/run-integration.d.ts +36 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/run-integration.js +338 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/services.d.ts +24 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/services.js +139 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/types.d.ts +229 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/types.js +1 -0
- 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 +223 -222
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +218 -203
- 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 +78 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.js +80 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/engine-compatibility.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/engine-compatibility.js +18 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +7 -85
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +8 -50
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +6 -23
- package/dist/harness/extension/plugin-ecosystem/plugins/index.js +3 -23
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +57 -114
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +279 -282
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +46 -484
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +123 -345
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +50 -223
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +144 -20
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.d.ts +17 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.js +15 -0
- package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +6 -1
- package/dist/harness/extension/plugin-ecosystem/skills/manager.js +17 -1
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.d.ts +3 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +46 -21
- 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 +36 -8
- 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/plugin-tool.d.ts +11 -0
- package/dist/harness/extension/plugin-ecosystem/tools/plugin-tool.js +39 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +19 -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/accounting/usage-ledger.d.ts +13 -1
- package/dist/harness/governance/accounting/usage-ledger.js +23 -1
- 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/human-in-the-loop/decision-cache.d.ts +3 -3
- package/dist/harness/governance/human-in-the-loop/decision-cache.js +2 -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/capability-enforcer.js +1 -2
- 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 +17 -15
- package/dist/harness/index.js +9 -9
- package/dist/harness/knowledge/boot-config.d.ts +57 -0
- package/dist/harness/knowledge/boot-config.js +52 -0
- package/dist/harness/knowledge/catalog-types.d.ts +2 -0
- package/dist/harness/knowledge/client.d.ts +77 -9
- package/dist/harness/knowledge/client.js +95 -24
- package/dist/harness/knowledge/db.d.ts +16 -0
- package/dist/harness/knowledge/db.js +112 -41
- package/dist/harness/knowledge/describe-sample.d.ts +23 -0
- package/dist/harness/knowledge/describe-sample.js +58 -0
- package/dist/harness/knowledge/describe.d.ts +8 -0
- package/dist/harness/knowledge/describe.js +18 -2
- package/dist/harness/knowledge/engine-thread.js +11 -7
- package/dist/harness/knowledge/grounding.js +7 -2
- package/dist/harness/knowledge/http-app.d.ts +15 -0
- package/dist/harness/knowledge/http-app.js +117 -25
- package/dist/harness/knowledge/http-bridge.d.ts +15 -0
- package/dist/harness/knowledge/http-bridge.js +19 -0
- package/dist/harness/knowledge/http-params.d.ts +18 -0
- package/dist/harness/knowledge/http-params.js +24 -0
- package/dist/harness/knowledge/index.d.ts +2 -0
- package/dist/harness/knowledge/index.js +1 -0
- package/dist/harness/knowledge/knowledge-serve-child.js +5 -3
- package/dist/harness/knowledge/purge.js +5 -2
- package/dist/harness/knowledge/query-service.d.ts +25 -4
- package/dist/harness/knowledge/query-service.js +79 -43
- package/dist/harness/knowledge/query-worker-client.d.ts +14 -2
- package/dist/harness/knowledge/query-worker-client.js +8 -3
- package/dist/harness/knowledge/query-worker.js +9 -5
- package/dist/harness/knowledge/read-http.d.ts +2 -0
- package/dist/harness/knowledge/read-http.js +14 -3
- package/dist/harness/knowledge/retriever.d.ts +1 -1
- package/dist/harness/knowledge/retriever.js +1 -2
- package/dist/harness/knowledge/serve.d.ts +14 -8
- package/dist/harness/knowledge/serve.js +14 -6
- package/dist/harness/knowledge/source-store.d.ts +101 -5
- package/dist/harness/knowledge/source-store.js +323 -74
- package/dist/harness/knowledge/start-service-process.d.ts +41 -14
- package/dist/harness/knowledge/start-service-process.js +67 -96
- package/dist/harness/knowledge/tenant-gate.d.ts +81 -0
- package/dist/harness/knowledge/tenant-gate.js +167 -0
- package/dist/harness/knowledge/types.d.ts +7 -0
- package/dist/harness/knowledge/writer-service.d.ts +55 -11
- package/dist/harness/knowledge/writer-service.js +200 -30
- package/dist/harness/knowledge/writer-worker-client.d.ts +19 -11
- package/dist/harness/knowledge/writer-worker-client.js +40 -5
- package/dist/harness/knowledge/writer-worker.js +20 -5
- 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/sqlite/wisdom-store.js +35 -10
- package/dist/harness/memory/types.d.ts +24 -6
- package/dist/harness/memory/wisdom-formation.d.ts +14 -3
- package/dist/harness/memory/wisdom-formation.js +85 -22
- package/dist/harness/memory/wisdom-gates.d.ts +14 -0
- package/dist/harness/memory/wisdom-gates.js +59 -19
- package/dist/harness/memory/wisdom.js +9 -0
- package/dist/harness/observability/observer/hub.d.ts +10 -0
- package/dist/harness/observability/observer/hub.js +120 -17
- package/dist/harness/observability/observer/types.d.ts +10 -6
- package/dist/harness/run/agent/agent.d.ts +40 -21
- package/dist/harness/run/agent/agent.js +67 -13
- package/dist/harness/run/agent/index.d.ts +1 -1
- package/dist/harness/run/budget/budget.d.ts +28 -10
- package/dist/harness/run/budget/budget.js +38 -15
- package/dist/harness/run/concurrency/tool-validator.js +4 -3
- package/dist/harness/run/model/index.d.ts +3 -1
- package/dist/harness/run/model/index.js +2 -1
- package/dist/harness/run/model/resolver.d.ts +4 -1
- package/dist/harness/run/model/resolver.js +36 -2
- package/dist/harness/run/model/run-scope.d.ts +2 -0
- package/dist/harness/run/model/run-scope.js +7 -0
- package/dist/harness/run/model/types.d.ts +22 -5
- package/dist/harness/run/model/types.js +3 -2
- package/dist/harness/run/model/window-truth.d.ts +37 -0
- package/dist/harness/run/model/window-truth.js +39 -0
- package/dist/harness/run/reliability/context-length-feedback.d.ts +77 -0
- package/dist/harness/run/reliability/context-length-feedback.js +128 -0
- package/dist/harness/run/reliability/harness-events.d.ts +3 -3
- package/dist/harness/run/reliability/model-error-policy.js +4 -0
- package/dist/harness/run/reliability/run-agent.d.ts +32 -4
- package/dist/harness/run/reliability/run-agent.js +216 -63
- package/dist/harness/run/reliability/run-metrics-collector.d.ts +19 -8
- package/dist/harness/run/reliability/run-metrics-collector.js +38 -23
- package/dist/harness/run/run-guard/default-run-guard.js +8 -8
- 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 +48 -4
- package/dist/harness/run/run-scope.js +19 -1
- package/dist/harness/run/runner.d.ts +181 -39
- package/dist/harness/run/runner.js +654 -119
- package/dist/harness/session/attachments/index.d.ts +1 -0
- package/dist/harness/session/attachments/index.js +1 -0
- package/dist/harness/session/attachments/inject.d.ts +21 -10
- package/dist/harness/session/attachments/inject.js +76 -24
- package/dist/harness/session/attachments/recall-index.d.ts +70 -0
- package/dist/harness/session/attachments/recall-index.js +219 -0
- package/dist/harness/session/attachments/service.d.ts +21 -0
- package/dist/harness/session/attachments/service.js +258 -139
- package/dist/harness/session/attachments/types.d.ts +6 -0
- 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/transform-store.d.ts +136 -0
- package/dist/harness/session/transform-store.js +302 -0
- package/dist/harness/session/types.d.ts +11 -15
- package/dist/harness/shared/events/agent-event-map.d.ts +75 -13
- package/dist/harness/shared/events/agent-event-map.js +3 -2
- package/dist/harness/shared/events/scenario-events.d.ts +6 -6
- package/dist/harness/shared/types/agent-definition.d.ts +7 -2
- package/dist/index.d.ts +16 -18
- package/dist/index.js +9 -10
- 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/observability/metrics.d.ts +6 -6
- package/dist/integration/observability/metrics.js +13 -13
- package/dist/integration/observability/observer-bridge.js +2 -2
- package/dist/integration/observability/trace-collector.d.ts +5 -5
- package/dist/integration/observability/trace-collector.js +34 -35
- package/dist/integration/observability/trace-events.d.ts +3 -3
- package/dist/integration/observability/trace-events.js +3 -3
- 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 +41 -3
- 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 +48 -2
- package/dist/integration/providers/usage.d.ts +1 -1
- package/dist/integration/providers/wire-dump-diff.js +2 -1
- package/dist/integration/providers/wire-dump.d.ts +57 -3
- package/dist/integration/providers/wire-dump.js +119 -6
- package/dist/integration/storage/archive-manager.d.ts +20 -2
- package/dist/integration/storage/archive-manager.js +34 -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 +10 -1
- package/dist/integration/storage/jsonl.js +155 -54
- 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/SUBSYSTEM.md +8 -1
- package/dist/subsystems/wisdom-steward/formation/config.yaml +4 -0
- package/dist/subsystems/wisdom-steward/formation/handler.js +27 -5
- package/dist/subsystems/wisdom-steward/govern/config.yaml +6 -1
- package/package.json +14 -15
- package/dist/harness/context/hybrid-compressor.d.ts +0 -41
- package/dist/harness/context/hybrid-compressor.js +0 -159
- package/dist/harness/context/llm-summarizer.d.ts +0 -46
- package/dist/harness/context/llm-summarizer.js +0 -249
- package/dist/harness/context/smart-router.d.ts +0 -75
- package/dist/harness/context/smart-router.js +0 -118
- package/dist/harness/context/truncate-compressor.d.ts +0 -28
- package/dist/harness/context/truncate-compressor.js +0 -107
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -97
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -155
- package/dist/harness/extension/plugin-ecosystem/plugins/hooks.d.ts +0 -7
- package/dist/harness/extension/plugin-ecosystem/plugins/hooks.js +0 -7
- package/dist/harness/extension/plugin-ecosystem/plugins/lifecycle.d.ts +0 -86
- package/dist/harness/extension/plugin-ecosystem/plugins/lifecycle.js +0 -139
|
@@ -8,7 +8,7 @@ import type { ToolCall } from '@octopi-agent/core/types.js';
|
|
|
8
8
|
import type { TokenUsage } from '@octopi-agent/core/types.js';
|
|
9
9
|
import type { ClassifiedError, ErrorReason } from '@octopi-agent/core/interfaces/error-strategy.js';
|
|
10
10
|
export type { ErrorReason, ClassifiedError };
|
|
11
|
-
export type LoopEndReason = 'completed' | '
|
|
11
|
+
export type LoopEndReason = 'completed' | 'max_steps' | 'budget_exhausted' | 'plugin_stop' | 'interrupted' | 'error';
|
|
12
12
|
export type AgentEventDetail = {
|
|
13
13
|
type: 'loop_start';
|
|
14
14
|
sessionId: string;
|
|
@@ -17,12 +17,12 @@ export type AgentEventDetail = {
|
|
|
17
17
|
reason: LoopEndReason;
|
|
18
18
|
response?: string;
|
|
19
19
|
} | {
|
|
20
|
-
type: '
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
type: 'step_start';
|
|
21
|
+
stepId: string;
|
|
22
|
+
stepIndex: number;
|
|
23
23
|
} | {
|
|
24
|
-
type: '
|
|
25
|
-
|
|
24
|
+
type: 'step_end';
|
|
25
|
+
stepId: string;
|
|
26
26
|
shouldContinue: boolean;
|
|
27
27
|
phase?: 'pre_tools' | 'final';
|
|
28
28
|
} | {
|
|
@@ -18,7 +18,6 @@ export interface AgentPersona {
|
|
|
18
18
|
export interface ModelConfig {
|
|
19
19
|
provider: string;
|
|
20
20
|
model: string;
|
|
21
|
-
temperature?: number;
|
|
22
21
|
maxTokens?: number;
|
|
23
22
|
contextWindow?: number;
|
|
24
23
|
/** 回退模型列表(按优先级排序,由 resolveModelConfig 解析后的完整配置) */
|
|
@@ -27,6 +26,12 @@ export interface ModelConfig {
|
|
|
27
26
|
/** Agent 定义(产品装配形状,非内核合同) */
|
|
28
27
|
export interface AgentDefinition {
|
|
29
28
|
id: string;
|
|
29
|
+
/**
|
|
30
|
+
* 归属租户(arch/multi-tenancy.md §4 隔离矩阵)。
|
|
31
|
+
* 缺省视作 DEFAULT_TENANT_ID(配置 agent / 存量注册表条目);
|
|
32
|
+
* 决定 workspace 派生路径与 audit/credentials 域。
|
|
33
|
+
*/
|
|
34
|
+
tenantId?: string;
|
|
30
35
|
/** Agent home 目录:persona、skills、sessions、extract 的根目录 */
|
|
31
36
|
home: string;
|
|
32
37
|
/** 沙箱工作目录:agent 工具操作的 cwd */
|
|
@@ -65,7 +70,7 @@ export interface AgentDefinition {
|
|
|
65
70
|
rightsCeiling?: SessionRights;
|
|
66
71
|
/** 委派预算上限(请求预算与此取交集) */
|
|
67
72
|
budget?: {
|
|
68
|
-
|
|
73
|
+
maxSteps?: number;
|
|
69
74
|
maxTokens?: number;
|
|
70
75
|
timeoutMs?: number;
|
|
71
76
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ export { BudgetPolicyEngine, DEFAULT_BUDGET } from './harness/run/budget/budget.
|
|
|
12
12
|
export type { BudgetPolicyConfig } from './harness/run/budget/budget.js';
|
|
13
13
|
export { UsageLedger } from './harness/governance/accounting/usage-ledger.js';
|
|
14
14
|
export type { UsageLedgerSnapshot } from './harness/governance/accounting/usage-ledger.js';
|
|
15
|
-
export { emptyTokenUsage, makeTokenUsage, nominalTotalTokens, reportedPromptTokens, } from '@octopi-agent/core/types/
|
|
16
|
-
export type { TokenUsage } from '@octopi-agent/core/types/
|
|
15
|
+
export { emptyTokenUsage, makeTokenUsage, nominalTotalTokens, reportedPromptTokens, } from '@octopi-agent/core/types/step.js';
|
|
16
|
+
export type { TokenUsage } from '@octopi-agent/core/types/step.js';
|
|
17
17
|
export type { ModelProvider, LLMRequest, LLMResponse, LLMStreamChunk, LLMToolDefinition } from '@octopi-agent/core/interfaces/model-provider.js';
|
|
18
18
|
/** 领域富模型(注册/权限/参数校验);LLM 传输格式见 LLMToolDefinition */
|
|
19
19
|
export type { ToolDefinition, RegisteredTool, ToolHandler, ToolParameter, ToolSource, ToolExecutionContext } from '@octopi-agent/core/types/tools.js';
|
|
@@ -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,
|
|
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';
|
|
@@ -31,7 +32,7 @@ export type { AgentTraceOptions } from './harness/agent/builder.js';
|
|
|
31
32
|
export type { AgentBuildOptions, AgentBuildResult, AgentBuildCoreResult } from './harness/agent/builder.js';
|
|
32
33
|
export type { ChannelAdapter, ChannelMessage, ChannelReply } from './harness/extension/plugin-ecosystem/channel-types.js';
|
|
33
34
|
export { Agent } from './harness/run/agent/index.js';
|
|
34
|
-
export type { AgentOptions } from './harness/run/agent/index.js';
|
|
35
|
+
export type { AgentOptions, RunIdentity } from './harness/run/agent/index.js';
|
|
35
36
|
export type { HarnessLoopEvent, BudgetControlEvent, ControlStopMetric, PolicyUnit } from './harness/run/reliability/harness-events.js';
|
|
36
37
|
export { SessionAwareRunner } from './harness/run/runner.js';
|
|
37
38
|
export { DEFAULT_TOOL_ISOLATION, resolveToolIsolationCwd, } from './harness/extension/execution-environment/isolation.js';
|
|
@@ -47,6 +48,7 @@ export { runWithToolLimits, resolveToolTimeoutMs, ToolTimeoutError, } from './ha
|
|
|
47
48
|
export type { EffectIntent, ConfirmEffect, ConfirmEffectDecision, UntrustedAdmission, JailIntent, OnJailUnavailable, OpsJailState, ToolSurface, SecurityDegradation, SessionEffectOverrides, } from './harness/extension/execution-environment/effect-policy.js';
|
|
48
49
|
export type { EffectRunMode, EffectPolicyConfig, EffectiveEffectPolicy, PathContainment, ShellEscapePolicy, } from './harness/extension/execution-environment/effect-policy.js';
|
|
49
50
|
export { scanOrphanSessionUndo, } from './harness/extension/execution-environment/undo-log.js';
|
|
51
|
+
export { scanOrphanSessionTransform } from './harness/session/transform-store.js';
|
|
50
52
|
export type { SessionUndoPaths, FileUndoEntry, DiscardFileEffectsResult, DiscardConflictReason, EditResendResult, NotReversedEffects, NotReversedReason, UndoLimitConfig, OrphanUndoDir, } from './harness/extension/execution-environment/undo-log.js';
|
|
51
53
|
export type { ShellJournalMode } from './harness/extension/execution-environment/effect-policy.js';
|
|
52
54
|
export type { ToolFileEffects } from '@octopi-agent/core/types/tools.js';
|
|
@@ -61,22 +63,17 @@ export { DefaultContextEngine } from './harness/context/default-context-engine.j
|
|
|
61
63
|
export type { DefaultContextEngineConfig } from './harness/context/default-context-engine.js';
|
|
62
64
|
export { HeuristicTokenEstimator, estimateTextTokens } from './harness/context/index.js';
|
|
63
65
|
export { DefaultMessageSelector } from './harness/context/message-selector.js';
|
|
64
|
-
export { TruncateCompressor } from './harness/context/truncate-compressor.js';
|
|
65
|
-
export { LLMSummaryCompressor } from './harness/context/llm-summarizer.js';
|
|
66
|
-
export { HybridCompressor } from './harness/context/hybrid-compressor.js';
|
|
67
66
|
export { DefaultBudgetAllocator } from './harness/context/budget-allocator.js';
|
|
68
|
-
export { SmartRouter } from './harness/context/smart-router.js';
|
|
69
|
-
export type { SmartRouterConfig, Route, RoutingDecision } from './harness/context/smart-router.js';
|
|
70
67
|
export { CapabilityEnforcer, PluginTrustLevel } from './harness/governance/security/capability-enforcer.js';
|
|
71
68
|
export { PluginManager } from './harness/extension/plugin-ecosystem/plugins/manager.js';
|
|
72
|
-
export {
|
|
73
|
-
export type { OctopiPluginDefinition
|
|
69
|
+
export { definePlugin } from './harness/extension/plugin-ecosystem/plugins/entry.js';
|
|
70
|
+
export type { OctopiPluginDefinition } from './harness/extension/plugin-ecosystem/plugins/entry.js';
|
|
74
71
|
export { PluginApi } from './harness/extension/plugin-ecosystem/plugins/api.js';
|
|
75
72
|
export { PluginLoader } from './harness/extension/plugin-ecosystem/plugins/loader.js';
|
|
76
|
-
export type { LoadedPlugin, PluginLoaderConfig, PluginEntryConfig } from './harness/extension/plugin-ecosystem/plugins/loader.js';
|
|
77
|
-
export {
|
|
78
|
-
export { validateManifest, parseManifest } from './harness/extension/plugin-ecosystem/plugins/manifest.js';
|
|
79
|
-
export type { PluginManifest,
|
|
73
|
+
export type { LoadedPlugin, PluginLoaderConfig, PluginEntryConfig, PluginDiagnostic } from './harness/extension/plugin-ecosystem/plugins/loader.js';
|
|
74
|
+
export { PluginContributionRegistry } from './harness/extension/plugin-ecosystem/plugins/contribution-registry.js';
|
|
75
|
+
export { validateManifest, parseManifest, validatePluginConfig, PLUGIN_API_VERSION } from './harness/extension/plugin-ecosystem/plugins/manifest.js';
|
|
76
|
+
export type { PluginManifest, PluginContributions, PluginHookName, PluginSessionOpName } from './harness/extension/plugin-ecosystem/plugins/manifest.js';
|
|
80
77
|
export { DefaultSkillManager, FileSystemSkillSource } from './harness/extension/plugin-ecosystem/skills/manager.js';
|
|
81
78
|
export type { SkillSource, DiscoveredSkill } from './harness/extension/plugin-ecosystem/skills/manager.js';
|
|
82
79
|
export type { SkillDefinition, SkillManager } from './harness/extension/plugin-ecosystem/skills/types.js';
|
|
@@ -92,7 +89,8 @@ export { readGitStatusSnapshot, parsePorcelainV2 } from './harness/extension/plu
|
|
|
92
89
|
export type { GitStatusSnapshot, GitStatusSnapshotBody, GitStatusSnapshotOptions, GitStatusEntry, GitStatusBranch, GitStatusCounts, GitStatusGroup, GitStatusKind, } from './harness/extension/plugin-ecosystem/tools/git-status-snapshot.js';
|
|
93
90
|
export { createSummaryPort, applyToolOutputGate, createCompactEngine } from './harness/context/capabilities/index.js';
|
|
94
91
|
export { createDefaultDocumentPort, createDocumentPortFromConfig, DocumentExtractError } from './harness/capabilities/document/index.js';
|
|
95
|
-
export type { SummaryPort, SummaryPolicy, ContentUnit, ToolSummarySupport, CompactEngine } from './harness/context/capabilities/index.js';
|
|
92
|
+
export type { SummaryPort, SummaryPolicy, ContentUnit, ToolSummarySupport, CompactEngine, CompactOutcome, CompactTransportOutcome } from './harness/context/capabilities/index.js';
|
|
93
|
+
export { toCompactTransport } from './harness/context/capabilities/compact/types.js';
|
|
96
94
|
export type { DocumentPort, ExtractResult, ExtractSource } from './harness/capabilities/document/index.js';
|
|
97
95
|
export type { ToolSet, ToolSetConfig } from './harness/extension/plugin-ecosystem/tools/tool-set.js';
|
|
98
96
|
export { createWebSearchTool } from './harness/extension/plugin-ecosystem/tools/web-search.js';
|
|
@@ -102,7 +100,7 @@ export { createSessionHistoryTools, createSessionSearchTool, createSessionReadTo
|
|
|
102
100
|
export type { SessionHistoryPort, SessionHistoryQuery, SessionHistorySearchResult, } from './harness/session/history/index.js';
|
|
103
101
|
export { buildFromConfig } from './harness/agent/config-bridge.js';
|
|
104
102
|
export type { BuiltAgent } from './harness/agent/config-bridge.js';
|
|
105
|
-
export { DefaultAgentRegistry, DelegationStore, DelegateService, DelegateResolutionError, InProcessTransport, RunnerChildRunPort, createChildRunExecutor, createDelegationNotifier, renderDelegationNotice, wireDelegation, createDelegationRuntime, AgentRegistryEvents, DelegationEvents, DELEGATION_SCHEMA_VERSION, } from './harness/collaboration/delegation/index.js';
|
|
103
|
+
export { DefaultAgentRegistry, DelegationStore, DelegateService, DelegateResolutionError, InProcessTransport, RunnerChildRunPort, createChildRunExecutor, createDelegationNotifier, renderDelegationNotice, wireDelegation, createDelegationRuntime, AgentRegistryEvents, DelegationEvents, DELEGATION_SCHEMA_VERSION, DEFAULT_DELEGATION_OUTPUT_CHARS, normalizeMaxOutputChars, } from './harness/collaboration/delegation/index.js';
|
|
106
104
|
export type { Delegation, DelegateRequest, DelegateResult, AgentHandle, AgentRegistry, AgentInfo, AgentQuery, AgentRelation, AgentRelationType, AgentDelegationPolicy, DelegateTransport, DelegatableAgent, DelegationRuntime, } from './harness/collaboration/delegation/index.js';
|
|
107
105
|
export { JsonlSessionStore } from './integration/storage/jsonl.js';
|
|
108
106
|
export { InMemorySessionStore } from './integration/storage/memory.js';
|
|
@@ -120,7 +118,7 @@ export { AnthropicProvider } from './integration/providers/anthropic.js';
|
|
|
120
118
|
export type { AnthropicProviderConfig } from './integration/providers/anthropic.js';
|
|
121
119
|
export { createDuckDuckGoProvider, createTavilyProvider, createBraveProvider, createSerperProvider, createMimoProvider, createWebSearchProviderFromSlot, resolveWebSearchProviders, createWebSearchWithFallback, } from './integration/web-search/index.js';
|
|
122
120
|
export type { WebSearchProvider, WebSearchOptions, WebSearchResponse, WebSearchResultItem, WebSearchConfig, WebSearchProviderSlotConfig, ResolvedWebSearchProviders, } from './integration/web-search/index.js';
|
|
123
|
-
export { createProviderFromConfig, resolveModelConfig, flattenModels, resolveListenHost, resolveViteHostArg, isLanHost, } from './config.js';
|
|
121
|
+
export { createProviderFromConfig, createChannelAdapterFromConfig, resolveModelConfig, flattenModels, resolveListenHost, resolveViteHostArg, isLanHost, } from './config.js';
|
|
124
122
|
export type { ModelsConfig, ModelProviderConfig, ModelCapability, ModelInputType, NormalizedHarnessConfig, NormalizedModelInfo, HarnessConfig, AgentConfig, ContextEngineConfig, ContextAssemblerConfig, ChannelConfig, PluginConfig, Defaults, NetworkHostConfig, WebSearchToolConfig, WebSearchProviderSlot, } from './config.js';
|
|
125
123
|
export { engineConfigSchema } from './config-schema/engine.js';
|
|
126
124
|
export type { EngineConfig } from './config-schema/engine.js';
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,8 @@ export { AgentEvents } from './harness/shared/events/agent-event-map.js';
|
|
|
11
11
|
export { DefaultSecurityGuard } from './harness/governance/security/default-security-guard.js';
|
|
12
12
|
export { BudgetPolicyEngine, DEFAULT_BUDGET } from './harness/run/budget/budget.js';
|
|
13
13
|
export { UsageLedger } from './harness/governance/accounting/usage-ledger.js';
|
|
14
|
-
export { emptyTokenUsage, makeTokenUsage, nominalTotalTokens, reportedPromptTokens, } from '@octopi-agent/core/types/
|
|
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
|
// ============================================================
|
|
@@ -31,24 +32,21 @@ export { resolveEffectiveEffectPolicy, requiresJail, buildOpsJailState, isPathAl
|
|
|
31
32
|
export { ProcessSandbox, createProcessSandbox, assessL4ProcessMinimum, probeProcessIsolation, scrubEnv, killProcessTree, supervisedSpawnProfile, } from './harness/extension/execution-environment/index.js';
|
|
32
33
|
export { runWithToolLimits, resolveToolTimeoutMs, ToolTimeoutError, } from './harness/extension/execution-environment/resource-limits.js';
|
|
33
34
|
export { scanOrphanSessionUndo, } from './harness/extension/execution-environment/undo-log.js';
|
|
35
|
+
export { scanOrphanSessionTransform } from './harness/session/transform-store.js';
|
|
34
36
|
export { InProcessSessionLock } from './harness/run/concurrency/session-lease.js';
|
|
35
37
|
export { SessionAclService, BUILTIN_SESSION_ROLES, computeEffectiveRights, } from './harness/governance/session-acl/index.js';
|
|
36
38
|
export { loadPersona, composePersonas, PersonaSource } from './harness/agent/persona.js';
|
|
37
39
|
export { DefaultContextEngine } from './harness/context/default-context-engine.js';
|
|
38
40
|
export { HeuristicTokenEstimator, estimateTextTokens } from './harness/context/index.js';
|
|
39
41
|
export { DefaultMessageSelector } from './harness/context/message-selector.js';
|
|
40
|
-
export { TruncateCompressor } from './harness/context/truncate-compressor.js';
|
|
41
|
-
export { LLMSummaryCompressor } from './harness/context/llm-summarizer.js';
|
|
42
|
-
export { HybridCompressor } from './harness/context/hybrid-compressor.js';
|
|
43
42
|
export { DefaultBudgetAllocator } from './harness/context/budget-allocator.js';
|
|
44
|
-
export { SmartRouter } from './harness/context/smart-router.js';
|
|
45
43
|
export { CapabilityEnforcer, PluginTrustLevel } from './harness/governance/security/capability-enforcer.js';
|
|
46
44
|
export { PluginManager } from './harness/extension/plugin-ecosystem/plugins/manager.js';
|
|
47
|
-
export {
|
|
45
|
+
export { definePlugin } from './harness/extension/plugin-ecosystem/plugins/entry.js';
|
|
48
46
|
export { PluginApi } from './harness/extension/plugin-ecosystem/plugins/api.js';
|
|
49
47
|
export { PluginLoader } from './harness/extension/plugin-ecosystem/plugins/loader.js';
|
|
50
|
-
export {
|
|
51
|
-
export { validateManifest, parseManifest } from './harness/extension/plugin-ecosystem/plugins/manifest.js';
|
|
48
|
+
export { PluginContributionRegistry } from './harness/extension/plugin-ecosystem/plugins/contribution-registry.js';
|
|
49
|
+
export { validateManifest, parseManifest, validatePluginConfig, PLUGIN_API_VERSION } from './harness/extension/plugin-ecosystem/plugins/manifest.js';
|
|
52
50
|
export { DefaultSkillManager, FileSystemSkillSource } from './harness/extension/plugin-ecosystem/skills/manager.js';
|
|
53
51
|
export { DefaultToolBus } from './harness/extension/plugin-ecosystem/tools/tool-bus.js';
|
|
54
52
|
export { buildToolLlmParameters, prepareHandlerArgs, readToolCallPurpose, resolveToolCallPurpose, sanitizeToolJsonSchema, toolDeclaresPurpose, TOOL_PURPOSE_PARAM, TOOL_PURPOSE_SYSTEM_NOTE, } from './harness/agent/tool-purpose.js';
|
|
@@ -58,12 +56,13 @@ export { createToolSet } from './harness/extension/plugin-ecosystem/tools/tool-s
|
|
|
58
56
|
export { readGitStatusSnapshot, parsePorcelainV2 } from './harness/extension/plugin-ecosystem/tools/git-status-snapshot.js';
|
|
59
57
|
export { createSummaryPort, applyToolOutputGate, createCompactEngine } from './harness/context/capabilities/index.js';
|
|
60
58
|
export { createDefaultDocumentPort, createDocumentPortFromConfig, DocumentExtractError } from './harness/capabilities/document/index.js';
|
|
59
|
+
export { toCompactTransport } from './harness/context/capabilities/compact/types.js';
|
|
61
60
|
export { createWebSearchTool } from './harness/extension/plugin-ecosystem/tools/web-search.js';
|
|
62
61
|
export { createSessionHistoryPort, resolveHistoryAccess, } from './harness/session/history/index.js';
|
|
63
62
|
export { createSessionHistoryTools, createSessionSearchTool, createSessionReadTool, } from './harness/extension/plugin-ecosystem/tools/session-history.js';
|
|
64
63
|
export { buildFromConfig } from './harness/agent/config-bridge.js';
|
|
65
64
|
// ── Delegation(L2 委派契约层;arch/delegation.md)──
|
|
66
|
-
export { DefaultAgentRegistry, DelegationStore, DelegateService, DelegateResolutionError, InProcessTransport, RunnerChildRunPort, createChildRunExecutor, createDelegationNotifier, renderDelegationNotice, wireDelegation, createDelegationRuntime, AgentRegistryEvents, DelegationEvents, DELEGATION_SCHEMA_VERSION, } from './harness/collaboration/delegation/index.js';
|
|
65
|
+
export { DefaultAgentRegistry, DelegationStore, DelegateService, DelegateResolutionError, InProcessTransport, RunnerChildRunPort, createChildRunExecutor, createDelegationNotifier, renderDelegationNotice, wireDelegation, createDelegationRuntime, AgentRegistryEvents, DelegationEvents, DELEGATION_SCHEMA_VERSION, DEFAULT_DELEGATION_OUTPUT_CHARS, normalizeMaxOutputChars, } from './harness/collaboration/delegation/index.js';
|
|
67
66
|
// ============================================================
|
|
68
67
|
// Integration 层(engine 库能力)
|
|
69
68
|
// ============================================================
|
|
@@ -80,7 +79,7 @@ export { createDuckDuckGoProvider, createTavilyProvider, createBraveProvider, cr
|
|
|
80
79
|
// ============================================================
|
|
81
80
|
// Config(类型 + 工厂)
|
|
82
81
|
// ============================================================
|
|
83
|
-
export { createProviderFromConfig, resolveModelConfig, flattenModels, resolveListenHost, resolveViteHostArg, isLanHost, } from './config.js';
|
|
82
|
+
export { createProviderFromConfig, createChannelAdapterFromConfig, resolveModelConfig, flattenModels, resolveListenHost, resolveViteHostArg, isLanHost, } from './config.js';
|
|
84
83
|
export { engineConfigSchema } from './config-schema/engine.js';
|
|
85
84
|
export { getBuiltinModelInfo, mergeWithBuiltinInfo } from './builtin-model-info.js';
|
|
86
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
|
+
}
|