@octopi-agent/engine 0.102.10 → 0.121.15
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/console-access-key.d.ts +46 -0
- package/dist/config-admin/console-access-key.js +47 -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 +8 -2
- package/dist/config-admin/index.js +4 -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 +83 -0
- package/dist/config-admin/onboarding-apply.js +259 -0
- package/dist/config-admin/onboarding.d.ts +160 -0
- package/dist/config-admin/onboarding.js +298 -0
- package/dist/config-admin/password-policy.d.ts +24 -0
- package/dist/config-admin/password-policy.js +31 -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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PluginLoaderConfig, LoadedPlugin, PluginDiagnostic } from './loader.js';
|
|
2
|
-
import type { PluginCommandRecord, PluginToolRecord, PluginServiceRecord } from './contribution-registry.js';
|
|
2
|
+
import type { PluginCommandRecord, PluginToolRecord, PluginServiceRecord, PluginProviderRecord, PluginChannelRecord } from './contribution-registry.js';
|
|
3
3
|
import { HookAuditJournal } from '../hooks/journal.js';
|
|
4
4
|
import { type HitlAskResult } from '../../../governance/human-in-the-loop/decision-cache.js';
|
|
5
5
|
import type { ExtensionHookPort, HookToolApproval, HookToolEvent } from '../hooks/types.js';
|
|
@@ -24,6 +24,35 @@ export declare class PluginManager {
|
|
|
24
24
|
getTools(includeOptional?: boolean): PluginToolRecord[];
|
|
25
25
|
getCommands(): PluginCommandRecord[];
|
|
26
26
|
getServices(): PluginServiceRecord[];
|
|
27
|
+
getProviders(): PluginProviderRecord[];
|
|
28
|
+
getChannels(): PluginChannelRecord[];
|
|
29
|
+
/** Resolve a published provider factory by its globally unique contribution id. */
|
|
30
|
+
resolveProviderFactory(ref: string): PluginProviderRecord | undefined;
|
|
31
|
+
/** Resolve a published channel factory by its globally unique contribution id. */
|
|
32
|
+
resolveChannelFactory(ref: string): PluginChannelRecord | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Secret-marked option keys declared by a contribution's manifest
|
|
35
|
+
* (`secretOptions`), for config echo redaction.
|
|
36
|
+
*
|
|
37
|
+
* @param kind - 'provider' or 'channel'
|
|
38
|
+
* @param ref - Contribution id
|
|
39
|
+
* @returns Declared secret option keys (empty when undeclared/unknown)
|
|
40
|
+
*/
|
|
41
|
+
getContributionSecretOptions(kind: 'provider' | 'channel', ref: string): string[] | null;
|
|
42
|
+
/**
|
|
43
|
+
* Roll back an accepted-but-never-installed instance (config-apply abort);
|
|
44
|
+
* resurrects the instance it superseded in the instance tables.
|
|
45
|
+
*
|
|
46
|
+
* @param instance - The instance the Host validated but never routed to
|
|
47
|
+
*/
|
|
48
|
+
discardInstance(instance: object): void;
|
|
49
|
+
/**
|
|
50
|
+
* Logical instance retirement at Host routing removal (physical dispose
|
|
51
|
+
* remains the backstop).
|
|
52
|
+
*
|
|
53
|
+
* @param instance - The instance the Host stopped routing to
|
|
54
|
+
*/
|
|
55
|
+
retireInstance(instance: object): void;
|
|
27
56
|
getCommandSessionOps(pluginId: string, name: string): PluginCommandRecord['sessionOps'] | undefined;
|
|
28
57
|
private getHookConfig;
|
|
29
58
|
private recordHook;
|
|
@@ -38,6 +38,52 @@ export class PluginManager {
|
|
|
38
38
|
}
|
|
39
39
|
getCommands() { return this.loader.contributions.getCommands(); }
|
|
40
40
|
getServices() { return this.loader.contributions.getServices(); }
|
|
41
|
+
getProviders() { return this.loader.contributions.getProviders(); }
|
|
42
|
+
getChannels() { return this.loader.contributions.getChannels(); }
|
|
43
|
+
/** Resolve a published provider factory by its globally unique contribution id. */
|
|
44
|
+
resolveProviderFactory(ref) {
|
|
45
|
+
return this.loader.contributions.getProviders().find((provider) => provider.id === ref);
|
|
46
|
+
}
|
|
47
|
+
/** Resolve a published channel factory by its globally unique contribution id. */
|
|
48
|
+
resolveChannelFactory(ref) {
|
|
49
|
+
return this.loader.contributions.getChannels().find((channel) => channel.id === ref);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Secret-marked option keys declared by a contribution's manifest
|
|
53
|
+
* (`secretOptions`), for config echo redaction.
|
|
54
|
+
*
|
|
55
|
+
* @param kind - 'provider' or 'channel'
|
|
56
|
+
* @param ref - Contribution id
|
|
57
|
+
* @returns Declared secret option keys (empty when undeclared/unknown)
|
|
58
|
+
*/
|
|
59
|
+
getContributionSecretOptions(kind, ref) {
|
|
60
|
+
const record = kind === 'provider'
|
|
61
|
+
? this.resolveProviderFactory(ref)
|
|
62
|
+
: this.resolveChannelFactory(ref);
|
|
63
|
+
// Unknown contribution → null: the caller must fail closed (mask all)
|
|
64
|
+
// instead of echoing options whose secret keys cannot be determined.
|
|
65
|
+
if (!record)
|
|
66
|
+
return null;
|
|
67
|
+
return this.loader.contributions.getPlugin(record.pluginId)?.manifest.secretOptions ?? [];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Roll back an accepted-but-never-installed instance (config-apply abort);
|
|
71
|
+
* resurrects the instance it superseded in the instance tables.
|
|
72
|
+
*
|
|
73
|
+
* @param instance - The instance the Host validated but never routed to
|
|
74
|
+
*/
|
|
75
|
+
discardInstance(instance) {
|
|
76
|
+
this.loader.contributions.discardInstance(instance);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Logical instance retirement at Host routing removal (physical dispose
|
|
80
|
+
* remains the backstop).
|
|
81
|
+
*
|
|
82
|
+
* @param instance - The instance the Host stopped routing to
|
|
83
|
+
*/
|
|
84
|
+
retireInstance(instance) {
|
|
85
|
+
this.loader.contributions.retireInstance(instance);
|
|
86
|
+
}
|
|
41
87
|
getCommandSessionOps(pluginId, name) {
|
|
42
88
|
const command = this.loader.contributions.getCommands().find((candidate) => candidate.pluginId === pluginId &&
|
|
43
89
|
candidate.name.replace(/^\/+/, '').toLowerCase() === name);
|
|
@@ -25,6 +25,7 @@ export declare const PLUGIN_HOOK_NAMES: readonly ["before_model_resolve", "agent
|
|
|
25
25
|
export type PluginHookName = (typeof PLUGIN_HOOK_NAMES)[number];
|
|
26
26
|
export declare const PLUGIN_SESSION_OP_NAMES: readonly ["abort_run", "new_session", "set_model", "compact", "set_preferred_agent"];
|
|
27
27
|
export type PluginSessionOpName = (typeof PLUGIN_SESSION_OP_NAMES)[number];
|
|
28
|
+
export declare const CONTRIBUTION_NAME_RE: RegExp;
|
|
28
29
|
export interface PluginCommandContribution {
|
|
29
30
|
name: string;
|
|
30
31
|
sessionOps?: PluginSessionOpName[];
|
|
@@ -35,6 +36,10 @@ export interface PluginContributions {
|
|
|
35
36
|
hooks?: PluginHookName[];
|
|
36
37
|
/** Stable service ids; required/timeout are trusted Host execution policy. */
|
|
37
38
|
services?: string[];
|
|
39
|
+
/** Stable provider factory ids; referenced by models.providers entries via their `plugin` field. */
|
|
40
|
+
providers?: string[];
|
|
41
|
+
/** Stable channel factory ids; referenced by channels entries via their `plugin` field. */
|
|
42
|
+
channels?: string[];
|
|
38
43
|
}
|
|
39
44
|
export interface PluginManifest {
|
|
40
45
|
id: string;
|
|
@@ -48,6 +53,10 @@ export interface PluginManifest {
|
|
|
48
53
|
octopi: string;
|
|
49
54
|
};
|
|
50
55
|
configSchema: JsonSchema;
|
|
56
|
+
/** Option keys whose values are secrets; redacted in config echo surfaces. */
|
|
57
|
+
secretOptions?: string[];
|
|
58
|
+
/** Dependencies require npm lifecycle scripts (requirement, not permission — the operator consents via CLI --allow-scripts). */
|
|
59
|
+
installScripts?: boolean;
|
|
51
60
|
contributes?: PluginContributions;
|
|
52
61
|
requiresPlugins?: string[];
|
|
53
62
|
legacyPluginIds?: string[];
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import Ajv from 'ajv';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
+
import { assertManifestKeysUnique, assertUnique } from './contribution-kinds.js';
|
|
7
8
|
export const PLUGIN_API_VERSION = '1';
|
|
8
9
|
const jsonSchemaSchema = z.lazy(() => z
|
|
9
10
|
.object({
|
|
@@ -50,7 +51,8 @@ export const PLUGIN_HOOK_NAMES = [
|
|
|
50
51
|
'loop_end',
|
|
51
52
|
];
|
|
52
53
|
export const PLUGIN_SESSION_OP_NAMES = ['abort_run', 'new_session', 'set_model', 'compact', 'set_preferred_agent'];
|
|
53
|
-
const
|
|
54
|
+
export const CONTRIBUTION_NAME_RE = /^[a-zA-Z][a-zA-Z0-9_.-]*$/;
|
|
55
|
+
const contributionName = z.string().regex(CONTRIBUTION_NAME_RE, 'must be a stable capability name');
|
|
54
56
|
const pluginId = z.string().regex(/^[a-z0-9][a-z0-9._-]*$/, 'must be a lowercase stable plugin id');
|
|
55
57
|
const manifestSchema = z
|
|
56
58
|
.object({
|
|
@@ -63,6 +65,19 @@ const manifestSchema = z
|
|
|
63
65
|
enabledByDefault: z.boolean().optional(),
|
|
64
66
|
engine: z.object({ octopi: z.string().min(1) }).strict(),
|
|
65
67
|
configSchema: jsonSchemaSchema,
|
|
68
|
+
/**
|
|
69
|
+
* Option keys whose values are secrets (e.g. tokens). The Host redacts
|
|
70
|
+
* them in config echo surfaces (Web console) — values are never shown.
|
|
71
|
+
*/
|
|
72
|
+
secretOptions: z.array(contributionName).optional(),
|
|
73
|
+
/**
|
|
74
|
+
* Declare that this plugin's dependencies require npm lifecycle scripts
|
|
75
|
+
* (preinstall/postinstall). This is a requirement declaration, NOT a
|
|
76
|
+
* permission: scripts run only when the OPERATOR consents (CLI
|
|
77
|
+
* --allow-scripts); without consent deployment is refused so a skipped
|
|
78
|
+
* postinstall cannot silently produce a broken plugin.
|
|
79
|
+
*/
|
|
80
|
+
installScripts: z.boolean().optional(),
|
|
66
81
|
contributes: z
|
|
67
82
|
.object({
|
|
68
83
|
tools: z.array(contributionName).optional(),
|
|
@@ -76,6 +91,8 @@ const manifestSchema = z
|
|
|
76
91
|
.optional(),
|
|
77
92
|
hooks: z.array(z.enum(PLUGIN_HOOK_NAMES)).optional(),
|
|
78
93
|
services: z.array(contributionName).optional(),
|
|
94
|
+
providers: z.array(contributionName).optional(),
|
|
95
|
+
channels: z.array(contributionName).optional(),
|
|
79
96
|
})
|
|
80
97
|
.strict()
|
|
81
98
|
.optional(),
|
|
@@ -100,22 +117,10 @@ export function validateManifest(raw) {
|
|
|
100
117
|
if (manifest.legacyPluginIds?.includes(manifest.id)) {
|
|
101
118
|
throw new Error(`Plugin "${manifest.id}" cannot list itself in legacyPluginIds`);
|
|
102
119
|
}
|
|
103
|
-
|
|
104
|
-
assertUnique(manifest.contributes?.hooks ?? [], 'contributes.hooks');
|
|
105
|
-
assertUnique(manifest.contributes?.services ?? [], 'contributes.services');
|
|
106
|
-
const commands = manifest.contributes?.commands ?? [];
|
|
107
|
-
assertUnique(commands.map((command) => command.name), 'contributes.commands');
|
|
108
|
-
for (const command of commands) {
|
|
109
|
-
assertUnique(command.sessionOps ?? [], `contributes.commands.${command.name}.sessionOps`);
|
|
110
|
-
}
|
|
120
|
+
assertManifestKeysUnique(manifest);
|
|
111
121
|
createConfigValidator(manifest.configSchema);
|
|
112
122
|
return manifest;
|
|
113
123
|
}
|
|
114
|
-
function assertUnique(values, field) {
|
|
115
|
-
if (new Set(values).size !== values.length) {
|
|
116
|
-
throw new Error(`Plugin manifest ${field} contains duplicate entries`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
124
|
/**
|
|
120
125
|
* Parse and validate an octopi.plugin.json document.
|
|
121
126
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Host-private staging storage. Not exported through the author SDK. */
|
|
2
2
|
import type { PluginApi } from './api.js';
|
|
3
|
-
import type { OrderedHookEntry, PluginCommandRegistration, PluginToolContribution } from './api.js';
|
|
3
|
+
import type { OrderedHookEntry, PluginChannelRegistration, PluginCommandRegistration, PluginProviderRegistration, PluginToolContribution } from './api.js';
|
|
4
4
|
import type { PluginHookName } from './manifest.js';
|
|
5
5
|
import type { HookServiceRegistration } from '../hooks/types.js';
|
|
6
6
|
export interface StagedContributions {
|
|
@@ -8,6 +8,8 @@ export interface StagedContributions {
|
|
|
8
8
|
commands: PluginCommandRegistration[];
|
|
9
9
|
hooks: Map<PluginHookName, OrderedHookEntry[]>;
|
|
10
10
|
services: HookServiceRegistration[];
|
|
11
|
+
providers: PluginProviderRegistration[];
|
|
12
|
+
channels: PluginChannelRegistration[];
|
|
11
13
|
}
|
|
12
14
|
/** Called only by the host when constructing an author API. */
|
|
13
15
|
export declare function createStaging(api: PluginApi): StagedContributions;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const staged = new WeakMap();
|
|
3
3
|
/** Called only by the host when constructing an author API. */
|
|
4
4
|
export function createStaging(api) {
|
|
5
|
-
const value = { tools: [], commands: [], hooks: new Map(), services: [] };
|
|
5
|
+
const value = { tools: [], commands: [], hooks: new Map(), services: [], providers: [], channels: [] };
|
|
6
6
|
staged.set(api, value);
|
|
7
7
|
return value;
|
|
8
8
|
}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* browser-types — 浏览器操作契约(arch/browser-capability.md §3.2)
|
|
3
|
+
*
|
|
4
|
+
* 契约住在 Harness(与 `web-search-types.ts` 同模式):工具面消费这些类型,
|
|
5
|
+
* `integration/browser/*` 实现之(依赖方向:Integration → Harness,边界测试强制)。
|
|
6
|
+
*
|
|
7
|
+
* 效应语义(arch/browser-capability.md §3.6):
|
|
8
|
+
* - 浏览器 = 网络出口(外泄通道)+ 不可逆外部写;工具面须走确认闸门/审计。
|
|
9
|
+
* - {@link BrowserSession.inspectAction} 在执行前暴露敏感效应分类(密码字段 /
|
|
10
|
+
* 表单提交),由工具层决定是否过 {@link import('@octopi-agent/core/types.js').HitlDecision}。
|
|
11
|
+
* - ref 生命周期绑定快照代数:导航/上下文失效后旧 ref 一律 `stale_ref` 报错,
|
|
12
|
+
* 不静默重试(避免对错误元素操作)。
|
|
13
|
+
*/
|
|
14
|
+
/** 浏览器会话 ID(跨工具↔集成边界的品牌 ID) */
|
|
15
|
+
/** 默认工具/动作超时(毫秒;`browser.timeoutMs` 可覆盖)——工具定义与驱动共用一个源 */
|
|
16
|
+
export declare const BROWSER_DEFAULT_TIMEOUT_MS = 30000;
|
|
17
|
+
export type BrowserSessionId = string & {
|
|
18
|
+
readonly __brand: 'BrowserSessionId';
|
|
19
|
+
};
|
|
20
|
+
/** 快照元素引用(绑定快照代数,导航后失效) */
|
|
21
|
+
export type ElementRef = string & {
|
|
22
|
+
readonly __brand: 'ElementRef';
|
|
23
|
+
};
|
|
24
|
+
/** 后端引擎标识(arch/browser-capability.md §3.3 后端矩阵) */
|
|
25
|
+
export type BrowserEngineId = 'playwright' | 'rebrowser' | 'camoufox' | 'cdp-attach' | 'cloud';
|
|
26
|
+
/** 拟人化节流参数(P3;区间 [min,max] 毫秒随机;0 = 关闭该维度) */
|
|
27
|
+
export interface HumanizeOptions {
|
|
28
|
+
/** 逐键打字延迟区间(默认 [20, 80]) */
|
|
29
|
+
typingDelayMs?: [number, number];
|
|
30
|
+
/** 动作间抖动区间(默认 [100, 600]) */
|
|
31
|
+
actionJitterMs?: [number, number];
|
|
32
|
+
/** 动作重试上限(默认 2;有界重试,禁止重试风暴) */
|
|
33
|
+
maxRetries?: number;
|
|
34
|
+
}
|
|
35
|
+
/** stealth 配置(P3;arch/browser-capability.md §3.5/§3.6) */
|
|
36
|
+
export interface BrowserStealthConfig {
|
|
37
|
+
/** engine=stealth 的后端链(`->` 分隔,缺省 `rebrowser->camoufox`) */
|
|
38
|
+
fallback?: string;
|
|
39
|
+
/** 行为拟人化节流(stealth 引擎缺省启用) */
|
|
40
|
+
humanize?: HumanizeOptions;
|
|
41
|
+
}
|
|
42
|
+
/** 会话身份三型 */
|
|
43
|
+
export interface BrowserIdentity {
|
|
44
|
+
kind: 'incognito' | 'profile' | 'attach';
|
|
45
|
+
profileId?: string;
|
|
46
|
+
}
|
|
47
|
+
/** 启动选项(P1:无痕单页;持久 profile = P2) */
|
|
48
|
+
export interface BrowserLaunchOptions {
|
|
49
|
+
/** 默认 true(无头);HITL 场景可有头 */
|
|
50
|
+
headless?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* 浏览器来源:`chromium` = 管理版 Chromium(`octopi browser install`);
|
|
53
|
+
* `chrome` = 系统安装的 Google Chrome(零下载)。
|
|
54
|
+
*/
|
|
55
|
+
channel?: 'chromium' | 'chrome';
|
|
56
|
+
viewport?: {
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
};
|
|
60
|
+
locale?: string;
|
|
61
|
+
timeoutMs?: number;
|
|
62
|
+
/** 会话归属 key(service 层设置;显式引用校验用,防跨会话操作) */
|
|
63
|
+
ownerKey?: string;
|
|
64
|
+
/** 请求级策略(URL 判定/写确认/账本);缺省 = 无策略(仅裸端口直用时允许) */
|
|
65
|
+
policy?: BrowserRequestPolicy;
|
|
66
|
+
/** P3:拟人化节流参数(会话消费逐键打字延迟;工具层消费抖动/重试) */
|
|
67
|
+
humanize?: HumanizeOptions;
|
|
68
|
+
/** 持久 profile ID(P2:identity.kind='profile';storageState 归档/恢复) */
|
|
69
|
+
profileId?: string;
|
|
70
|
+
/** profile 存储目录(`OCTOPI_HOME/browser-profiles`;assemble 注入) */
|
|
71
|
+
profileDir?: string;
|
|
72
|
+
/** 关闭时归档 storageState(缺省 false;与 profileId/profileDir 同用) */
|
|
73
|
+
persistProfile?: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 请求级策略(arch/browser-capability.md §3.6)。
|
|
77
|
+
* 在**网络请求层**收口(CDP Fetch 域逐请求暂停;`context.route` 不触发于重定向跳,
|
|
78
|
+
* 已弃用):覆盖重定向、子资源、
|
|
79
|
+
* 页内点击导航——策略判定是单一实现,DOM 层敏感标记只是提前预判。
|
|
80
|
+
*/
|
|
81
|
+
export interface BrowserRequestPolicy {
|
|
82
|
+
/** 每个网络请求的 URL 判定;抛错 = 拦截该请求 */
|
|
83
|
+
checkUrl(url: string): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* 外部写确认闸门:**所有非 GET 请求**触发(P2 收紧:含 fetch/XHR;P1 只闸文档导航)。
|
|
86
|
+
* `documentLevel` = 文档级提交(表单/上传语义);false = 页内脚本写入。
|
|
87
|
+
* false = 拦截。工具层按 `method+origin` 做会话级审批缓存,避免同源重复确认。
|
|
88
|
+
*/
|
|
89
|
+
confirmWrite(intent: {
|
|
90
|
+
method: string;
|
|
91
|
+
url: string;
|
|
92
|
+
documentLevel: boolean;
|
|
93
|
+
}): Promise<boolean>;
|
|
94
|
+
/** 账本回调(写尝试/拦截;fire-and-forget) */
|
|
95
|
+
record?(event: BrowserPolicyEvent): void;
|
|
96
|
+
}
|
|
97
|
+
export interface BrowserPolicyEvent {
|
|
98
|
+
kind: 'write.attempt' | 'write.blocked' | 'blocked';
|
|
99
|
+
url: string;
|
|
100
|
+
method?: string;
|
|
101
|
+
reason?: string;
|
|
102
|
+
}
|
|
103
|
+
/** attach 用户真实浏览器(P2;经 connectOverCDP,复用其登录/指纹) */
|
|
104
|
+
export interface BrowserAttachOptions {
|
|
105
|
+
/** CDP 端点(ws://… 或 http://127.0.0.1:9222;缺省后者) */
|
|
106
|
+
endpoint?: string;
|
|
107
|
+
timeoutMs?: number;
|
|
108
|
+
/** 会话归属 key(同 launch) */
|
|
109
|
+
ownerKey?: string;
|
|
110
|
+
/** 请求级策略(同 launch;attach 会话同样逐请求收口) */
|
|
111
|
+
policy?: BrowserRequestPolicy;
|
|
112
|
+
}
|
|
113
|
+
/** 会话摘要(list) */
|
|
114
|
+
export interface BrowserSessionInfo {
|
|
115
|
+
id: BrowserSessionId;
|
|
116
|
+
engine: BrowserEngineId;
|
|
117
|
+
identity: BrowserIdentity;
|
|
118
|
+
url?: string;
|
|
119
|
+
}
|
|
120
|
+
export interface GotoOptions {
|
|
121
|
+
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle';
|
|
122
|
+
timeoutMs?: number;
|
|
123
|
+
}
|
|
124
|
+
export interface GotoResult {
|
|
125
|
+
url: string;
|
|
126
|
+
title: string;
|
|
127
|
+
/**
|
|
128
|
+
* HTTP 状态码。**同文档导航/`about:blank` 无 HTTP 响应时省略**——
|
|
129
|
+
* 不编造 200(AGENTS.md no-fake-data)。
|
|
130
|
+
*/
|
|
131
|
+
status?: number;
|
|
132
|
+
}
|
|
133
|
+
/** 挑战页情报(启发式识别;见 arch/browser-capability.md §3.7) */
|
|
134
|
+
export interface ChallengeInfo {
|
|
135
|
+
kind: 'captcha' | 'interstitial';
|
|
136
|
+
/** 命中的识别标记(如实透出,供人/模型判断) */
|
|
137
|
+
marker: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* 确定性结构化抽取规格(P2):字段名 → CSS 选择器 + 可选属性。
|
|
141
|
+
* 不做语义理解(那是模型自己的活);只做 DOM 查询,结果为真实数据或 null。
|
|
142
|
+
*/
|
|
143
|
+
export interface ExtractFieldSpec {
|
|
144
|
+
selector: string;
|
|
145
|
+
/** 取元素属性;缺省取文本(textContent 去空白);属性缺失 = null */
|
|
146
|
+
attribute?: string;
|
|
147
|
+
/** 取全部匹配(数组);缺省取第一个 */
|
|
148
|
+
multiple?: boolean;
|
|
149
|
+
/** multiple 数组上限(缺省 50,防整表进上下文;超限截断) */
|
|
150
|
+
maxItems?: number;
|
|
151
|
+
}
|
|
152
|
+
export type ExtractSpec = Record<string, ExtractFieldSpec>;
|
|
153
|
+
/**
|
|
154
|
+
* 抽取结果:字段 → 字符串 / `Array<string | null>`(multiple;属性缺失项为 null)/ null
|
|
155
|
+
* (无匹配 = null,不编造)。
|
|
156
|
+
*/
|
|
157
|
+
export type ExtractResult = Record<string, string | Array<string | null> | null>;
|
|
158
|
+
/**
|
|
159
|
+
* 抽取产出(P2 预算语义,评审 N5):数据 + 截断标记 + multiple 命中总数
|
|
160
|
+
* (`counts` 让调用方知道被 maxItems 截断前的真实条数——"50 条不是全部")。
|
|
161
|
+
*/
|
|
162
|
+
export interface ExtractOutcome {
|
|
163
|
+
data: ExtractResult;
|
|
164
|
+
truncated: boolean;
|
|
165
|
+
counts?: Record<string, number>;
|
|
166
|
+
}
|
|
167
|
+
export interface SnapshotOptions {
|
|
168
|
+
/** 只列可交互元素(省 token) */
|
|
169
|
+
interactiveOnly?: boolean;
|
|
170
|
+
/** 序列化预算(字符);超出截断并标 truncated */
|
|
171
|
+
maxChars?: number;
|
|
172
|
+
}
|
|
173
|
+
/** 快照元素语义标签(敏感效应判定 + 语义提示) */
|
|
174
|
+
export type SnapshotTag = 'submit' | 'password' | 'file' | 'heading';
|
|
175
|
+
/** 快照条目:可交互元素(带 ref)或纯文本流 */
|
|
176
|
+
export type SnapshotItem = {
|
|
177
|
+
ref: ElementRef;
|
|
178
|
+
role: string;
|
|
179
|
+
name: string;
|
|
180
|
+
value?: string;
|
|
181
|
+
checked?: boolean;
|
|
182
|
+
tags?: SnapshotTag[];
|
|
183
|
+
} | {
|
|
184
|
+
ref?: undefined;
|
|
185
|
+
role: 'text' | 'heading';
|
|
186
|
+
name: string;
|
|
187
|
+
};
|
|
188
|
+
export interface PageSnapshot {
|
|
189
|
+
url: string;
|
|
190
|
+
title: string;
|
|
191
|
+
/** 文档序条目(可交互元素 + 文本流) */
|
|
192
|
+
items: SnapshotItem[];
|
|
193
|
+
/** 因 maxChars 预算截断 */
|
|
194
|
+
truncated?: boolean;
|
|
195
|
+
}
|
|
196
|
+
/** 页面动作(可辨识联合) */
|
|
197
|
+
export type PageAction = {
|
|
198
|
+
kind: 'click';
|
|
199
|
+
ref: ElementRef;
|
|
200
|
+
} | {
|
|
201
|
+
kind: 'fill';
|
|
202
|
+
ref: ElementRef;
|
|
203
|
+
value: string;
|
|
204
|
+
} | {
|
|
205
|
+
kind: 'select';
|
|
206
|
+
ref: ElementRef;
|
|
207
|
+
value: string;
|
|
208
|
+
} | {
|
|
209
|
+
kind: 'check';
|
|
210
|
+
ref: ElementRef;
|
|
211
|
+
} | {
|
|
212
|
+
kind: 'uncheck';
|
|
213
|
+
ref: ElementRef;
|
|
214
|
+
} | {
|
|
215
|
+
kind: 'hover';
|
|
216
|
+
ref: ElementRef;
|
|
217
|
+
} | {
|
|
218
|
+
kind: 'press';
|
|
219
|
+
key: string;
|
|
220
|
+
ref?: ElementRef;
|
|
221
|
+
} | {
|
|
222
|
+
kind: 'scroll';
|
|
223
|
+
deltaY: number;
|
|
224
|
+
} | {
|
|
225
|
+
kind: 'wait';
|
|
226
|
+
ms: number;
|
|
227
|
+
}
|
|
228
|
+
/** P2:向文件输入框上传本地文件(外部写;fileUpload 闸) */
|
|
229
|
+
| {
|
|
230
|
+
kind: 'upload';
|
|
231
|
+
ref: ElementRef;
|
|
232
|
+
path: string;
|
|
233
|
+
};
|
|
234
|
+
/** 动作意图预检(工具层确认闸门依据;基于快照元数据,不发浏览器往返) */
|
|
235
|
+
export interface ActionIntent {
|
|
236
|
+
action: PageAction;
|
|
237
|
+
/**
|
|
238
|
+
* 敏感效应分类:`false` = 常规;对象 = 需过确认闸门的不可逆外部写。
|
|
239
|
+
* `passwordField` = 向密码字段填写;`formSubmit` = 提交表单;`fileUpload` = 上传本地文件。
|
|
240
|
+
*/
|
|
241
|
+
sensitive: false | {
|
|
242
|
+
kind: 'passwordField' | 'formSubmit' | 'fileUpload';
|
|
243
|
+
description: string;
|
|
244
|
+
};
|
|
245
|
+
/** 目标元素(审计/UI 展示) */
|
|
246
|
+
target?: {
|
|
247
|
+
role: string;
|
|
248
|
+
name: string;
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
export interface ActResult {
|
|
252
|
+
ok: true;
|
|
253
|
+
url: string;
|
|
254
|
+
title: string;
|
|
255
|
+
}
|
|
256
|
+
export interface ScreenshotOptions {
|
|
257
|
+
fullPage?: boolean;
|
|
258
|
+
/** 元素截图(省略 = 视口/整页) */
|
|
259
|
+
ref?: ElementRef;
|
|
260
|
+
type?: 'png' | 'jpeg';
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* 截图结果。**数据不进 LLM 工具结果**(工具结果在 LLM 边界是纯文本序列化,
|
|
264
|
+
* 见 core `normalizeMessagesForLlm`):工具面落盘后返回路径。
|
|
265
|
+
*/
|
|
266
|
+
export interface ScreenshotResult {
|
|
267
|
+
mimeType: string;
|
|
268
|
+
data: Uint8Array;
|
|
269
|
+
}
|
|
270
|
+
/** 浏览器端口(integration/browser 实现) */
|
|
271
|
+
export interface BrowserPort {
|
|
272
|
+
launch(options?: BrowserLaunchOptions): Promise<BrowserSession>;
|
|
273
|
+
/** P2:attach 用户真实浏览器(CDP) */
|
|
274
|
+
attach(options?: BrowserAttachOptions): Promise<BrowserSession>;
|
|
275
|
+
list(): Promise<BrowserSessionInfo[]>;
|
|
276
|
+
}
|
|
277
|
+
/** stealth 链服务(P3)的挑战轮换原语;非链式服务不实现(工具层视同链穷尽) */
|
|
278
|
+
export interface StealthRotatable {
|
|
279
|
+
/**
|
|
280
|
+
* 挑战驱动的后端轮换:关掉该 key 当前会话并切到链上下一后端。
|
|
281
|
+
*
|
|
282
|
+
* @param sessionKey - 会话归属 key(acquire 时的 key)
|
|
283
|
+
* @returns true=已轮换(调用方重新 acquire 重试一次);false=链已穷尽(走 HITL)
|
|
284
|
+
*/
|
|
285
|
+
rotateAfterChallenge(sessionKey: string): Promise<boolean>;
|
|
286
|
+
}
|
|
287
|
+
/** 单会话页面面(P1 单页;多标签 P2+) */
|
|
288
|
+
export interface BrowserSession {
|
|
289
|
+
readonly id: BrowserSessionId;
|
|
290
|
+
readonly engine: BrowserEngineId;
|
|
291
|
+
readonly identity: BrowserIdentity;
|
|
292
|
+
/** 会话归属 key(创建时的 sessionKey;显式引用须同 owner) */
|
|
293
|
+
readonly ownerKey: string;
|
|
294
|
+
/** 当前页面 URL(未导航时 about:blank) */
|
|
295
|
+
readonly url: string;
|
|
296
|
+
goto(url: string, options?: GotoOptions): Promise<GotoResult>;
|
|
297
|
+
snapshot(options?: SnapshotOptions): Promise<PageSnapshot>;
|
|
298
|
+
/**
|
|
299
|
+
* 动作预检:暴露敏感效应分类(不执行动作)。
|
|
300
|
+
* 元数据来源 = 快照时刻;ref 过期由后续 `act` 的 stale_ref 兜底。
|
|
301
|
+
*/
|
|
302
|
+
inspectAction(action: PageAction): Promise<ActionIntent>;
|
|
303
|
+
act(action: PageAction): Promise<ActResult>;
|
|
304
|
+
screenshot(options?: ScreenshotOptions): Promise<ScreenshotResult>;
|
|
305
|
+
/** 挑战页启发式识别(captcha/interstitial;无挑战返回 undefined) */
|
|
306
|
+
detectChallenge(): Promise<ChallengeInfo | undefined>;
|
|
307
|
+
/** 确定性结构化抽取(CSS 选择器 → 真实数据;无匹配字段为 null;带截断标记与命中数) */
|
|
308
|
+
extract(spec: ExtractSpec): Promise<ExtractOutcome>;
|
|
309
|
+
close(): Promise<void>;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* 会话服务(工具面唯一入口;integration/browser/service.ts 实现)。
|
|
313
|
+
* 按会话 key(工具侧 = `context.sessionId`)取得/创建隐式会话;
|
|
314
|
+
* 显式 `session` 参数经 {@link byId} 直取。
|
|
315
|
+
*/
|
|
316
|
+
export interface BrowserService {
|
|
317
|
+
/** 取得/创建 key 的隐式会话(已存在则复用) */
|
|
318
|
+
acquire(sessionKey: string, options?: BrowserLaunchOptions): Promise<BrowserSession>;
|
|
319
|
+
/** 只查不建:key 的既有隐式会话(无则 undefined) */
|
|
320
|
+
get(sessionKey: string): Promise<BrowserSession | undefined>;
|
|
321
|
+
/** 按会话 ID 直取(显式 session 参数) */
|
|
322
|
+
byId(id: BrowserSessionId): Promise<BrowserSession | undefined>;
|
|
323
|
+
/** 关闭会话(隐式 key 或显式 ID 同参);返回是否确实关闭过 */
|
|
324
|
+
close(sessionKeyOrId: string): Promise<boolean>;
|
|
325
|
+
/**
|
|
326
|
+
* P3(可选):挑战驱动的后端轮换(stealth 链)。true=已切下一后端(调用方重新
|
|
327
|
+
* acquire 重试一次);false=链已穷尽(走 HITL)。非链式服务不实现(视同 false)。
|
|
328
|
+
*/
|
|
329
|
+
rotateAfterChallenge?(sessionKey: string): Promise<boolean>;
|
|
330
|
+
list(): Promise<BrowserSessionInfo[]>;
|
|
331
|
+
/** 进程/装配生命周期收尾:关掉全部会话并停止回收定时器 */
|
|
332
|
+
dispose(): Promise<void>;
|
|
333
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* browser-types — 浏览器操作契约(arch/browser-capability.md §3.2)
|
|
3
|
+
*
|
|
4
|
+
* 契约住在 Harness(与 `web-search-types.ts` 同模式):工具面消费这些类型,
|
|
5
|
+
* `integration/browser/*` 实现之(依赖方向:Integration → Harness,边界测试强制)。
|
|
6
|
+
*
|
|
7
|
+
* 效应语义(arch/browser-capability.md §3.6):
|
|
8
|
+
* - 浏览器 = 网络出口(外泄通道)+ 不可逆外部写;工具面须走确认闸门/审计。
|
|
9
|
+
* - {@link BrowserSession.inspectAction} 在执行前暴露敏感效应分类(密码字段 /
|
|
10
|
+
* 表单提交),由工具层决定是否过 {@link import('@octopi-agent/core/types.js').HitlDecision}。
|
|
11
|
+
* - ref 生命周期绑定快照代数:导航/上下文失效后旧 ref 一律 `stale_ref` 报错,
|
|
12
|
+
* 不静默重试(避免对错误元素操作)。
|
|
13
|
+
*/
|
|
14
|
+
/** 浏览器会话 ID(跨工具↔集成边界的品牌 ID) */
|
|
15
|
+
/** 默认工具/动作超时(毫秒;`browser.timeoutMs` 可覆盖)——工具定义与驱动共用一个源 */
|
|
16
|
+
export const BROWSER_DEFAULT_TIMEOUT_MS = 30_000;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* browser_* 工具面 — 浏览器操作五件套(arch/browser-capability.md §3.4)
|
|
3
|
+
*
|
|
4
|
+
* 效应纪律(§3.6):
|
|
5
|
+
* - 浏览器 = 网络出口(外泄通道)+ 不可逆外部写。URL 判定与外部写闸门在**请求层**
|
|
6
|
+
* 收口(BrowserRequestPolicy 注入会话;重定向/子资源/页内导航全覆盖),DOM 层
|
|
7
|
+
* 敏感标记(passwordField/formSubmit)只是提前预判——两层都过才执行。
|
|
8
|
+
* - 确认闸门复用 HitlDecision(confirmEffect 缺失时敏感动作 fail-closed 拒绝)。
|
|
9
|
+
* - 导航/写尝试/拦截经 recordOpsEvent 进统一效应账本。
|
|
10
|
+
* - 截图落盘经 fileEffects(L3 undo 记账),返回**路径**——工具结果在 LLM 边界是
|
|
11
|
+
* 纯文本序列化(core normalizeMessagesForLlm),图像数据不进上下文。
|
|
12
|
+
*/
|
|
13
|
+
import type { RegisteredTool } from '@octopi-agent/core/types.js';
|
|
14
|
+
import type { BrowserService, BrowserStealthConfig, HumanizeOptions } from './browser-types.js';
|
|
15
|
+
export interface BrowserToolOptions {
|
|
16
|
+
/**
|
|
17
|
+
* 敏感动作确认闸门三档(2026-11-20 拍板,替代布尔组合):
|
|
18
|
+
* `strict` = 所有非 GET 过闸(含页内 fetch/XHR);`standard`(缺省)= 仅文档级
|
|
19
|
+
* (表单提交/密码/上传);`off` = 全放开。
|
|
20
|
+
*/
|
|
21
|
+
confirm?: 'strict' | 'standard' | 'off';
|
|
22
|
+
/** P3:引擎名(humanize 缺省启用判定用;stealth/rebrowser/camoufox = 启用) */
|
|
23
|
+
engine?: string;
|
|
24
|
+
/** stealth(P3):humanize 拟人化节流由工具层消费(stealth 引擎缺省启用) */
|
|
25
|
+
stealth?: BrowserStealthConfig;
|
|
26
|
+
/** 持久 profile(P2):persist=关闭时归档 storageState;defaultProfile=隐式会话默认身份 */
|
|
27
|
+
profiles?: {
|
|
28
|
+
persist?: boolean;
|
|
29
|
+
defaultProfile?: string;
|
|
30
|
+
};
|
|
31
|
+
/** profile 存储目录(assemble 按 OCTOPI_HOME 注入) */
|
|
32
|
+
profileDir?: string;
|
|
33
|
+
urlPolicy?: {
|
|
34
|
+
/** 域名 allow(`*.suffix` 通配,匹配域及其子域);缺省 = 不限制 */
|
|
35
|
+
allow?: string[];
|
|
36
|
+
/** 域名 deny(优先于 allow) */
|
|
37
|
+
deny?: string[];
|
|
38
|
+
};
|
|
39
|
+
allowPrivateNetwork?: boolean;
|
|
40
|
+
timeoutMs?: number;
|
|
41
|
+
snapshotMaxChars?: number;
|
|
42
|
+
}
|
|
43
|
+
export declare function domainMatches(pattern: string, host: string): boolean;
|
|
44
|
+
export declare function assertBrowserUrlAllowed(rawUrl: string, options: {
|
|
45
|
+
urlPolicy?: BrowserToolOptions['urlPolicy'];
|
|
46
|
+
allowPrivateNetwork?: boolean;
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* 确认闸三档 → 单闸开关的唯一映射(DOM 闸与请求层闸共用;勿在调用点手写档位判断)。
|
|
50
|
+
*
|
|
51
|
+
* @param confirm - 三档配置(缺省 `standard`)
|
|
52
|
+
* @param kind - 闸门种类(`xhr` = 页内 fetch/XHR 外部写)
|
|
53
|
+
* @returns 该闸在当前档位下是否启用
|
|
54
|
+
*/
|
|
55
|
+
export declare function confirmGateEnabled(confirm: BrowserToolOptions['confirm'], kind: 'passwordField' | 'formSubmit' | 'fileUpload' | 'xhr'): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* 生效 humanize 参数:显式配置优先;stealth 系引擎(stealth/rebrowser/camoufox)
|
|
58
|
+
* 缺省启用;其余引擎无配置则不启用。
|
|
59
|
+
*
|
|
60
|
+
* @param opts - 工具选项(engine + stealth.humanize)
|
|
61
|
+
* @returns 生效参数;undefined = 不启用拟人化
|
|
62
|
+
*/
|
|
63
|
+
export declare function effectiveHumanize(opts: BrowserToolOptions): Required<HumanizeOptions> | undefined;
|
|
64
|
+
export declare function createBrowserTools(service: BrowserService, options?: BrowserToolOptions): RegisteredTool[];
|