@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
|
@@ -1,336 +1,333 @@
|
|
|
1
|
+
/** Manifest-first discovery: no plugin code runs before eligibility and config validation. */
|
|
2
|
+
import { existsSync, readdirSync, readFileSync, realpathSync } from 'node:fs';
|
|
3
|
+
import { join, relative, resolve, sep } from 'node:path';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { PluginApi } from './api.js';
|
|
6
|
+
import { CONTRIBUTION_KINDS, assertManifestCoverage, declaredClaims } from './contribution-kinds.js';
|
|
7
|
+
import { parseManifest, validatePluginConfig, } from './manifest.js';
|
|
8
|
+
import { PluginContributionRegistry, } from './contribution-registry.js';
|
|
9
|
+
import { getEngineVersion, satisfiesEngineRange } from './engine-compatibility.js';
|
|
10
|
+
import { readStaging } from './staging.js';
|
|
1
11
|
/**
|
|
2
|
-
*
|
|
12
|
+
* Resolve a manifest entry to its real path inside the plugin root. Shared
|
|
13
|
+
* single source for the loader and `octopi plugin doctor`: rejects entries
|
|
14
|
+
* that escape the plugin root (before and after symlink resolution).
|
|
3
15
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* 4. Registration — 调用 register() 注册能力
|
|
9
|
-
*/
|
|
10
|
-
import * as path from 'node:path';
|
|
11
|
-
import * as fs from 'node:fs/promises';
|
|
12
|
-
import { existsSync } from 'node:fs';
|
|
13
|
-
import { validateManifest } from './manifest.js';
|
|
14
|
-
import { PluginApi as PluginApiClass } from './api.js';
|
|
15
|
-
import { CapabilityRegistry, registerManifestCapabilities } from './capability.js';
|
|
16
|
-
/**
|
|
17
|
-
* Plugin Loader
|
|
18
|
-
*
|
|
19
|
-
* 负责从文件系统发现和加载 plugins。
|
|
16
|
+
* @param rootDir - Plugin directory
|
|
17
|
+
* @param entry - Manifest `entry` (relative path)
|
|
18
|
+
* @returns The real path of the entry file
|
|
19
|
+
* @throws When the entry is missing, escapes its root, or is not a file
|
|
20
20
|
*/
|
|
21
|
+
export function resolvePluginEntry(rootDir, entry) {
|
|
22
|
+
const root = realpathSync(rootDir);
|
|
23
|
+
const candidate = resolve(root, entry);
|
|
24
|
+
if (relative(root, candidate).startsWith(`..${sep}`) || relative(root, candidate) === '..') {
|
|
25
|
+
throw new Error(`Plugin entry escapes its root: ${entry}`);
|
|
26
|
+
}
|
|
27
|
+
const real = realpathSync(candidate);
|
|
28
|
+
const rel = relative(root, real);
|
|
29
|
+
if (rel === '..' || rel.startsWith(`..${sep}`)) {
|
|
30
|
+
throw new Error(`Plugin entry realpath escapes its root: ${entry}`);
|
|
31
|
+
}
|
|
32
|
+
return real;
|
|
33
|
+
}
|
|
34
|
+
const PLUGIN_MANIFEST_FILENAME = 'octopi.plugin.json';
|
|
21
35
|
export class PluginLoader {
|
|
22
|
-
|
|
23
|
-
plugins = new Map();
|
|
24
|
-
/** Capability Registry */
|
|
25
|
-
capabilities = new CapabilityRegistry();
|
|
26
|
-
/** 配置 */
|
|
36
|
+
contributions = new PluginContributionRegistry();
|
|
27
37
|
config;
|
|
38
|
+
plugins = new Map();
|
|
39
|
+
diagnostics = [];
|
|
28
40
|
constructor(config) {
|
|
29
41
|
this.config = config;
|
|
30
42
|
}
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
/** Resolve a loaded plugin's configured hook policy, including legacy aliases. */
|
|
44
|
+
getPluginConfig(id) {
|
|
45
|
+
const plugin = this.plugins.get(id);
|
|
46
|
+
if (!plugin)
|
|
47
|
+
return undefined;
|
|
48
|
+
const ids = [plugin.id, ...(plugin.manifest.legacyPluginIds ?? [])];
|
|
49
|
+
return ids.map((key) => this.config.entries?.[key]).find((entry) => entry !== undefined);
|
|
50
|
+
}
|
|
51
|
+
/** Discover, validate and atomically publish the successful plugin set. */
|
|
38
52
|
async discover() {
|
|
39
|
-
|
|
53
|
+
// Keep the previous effective snapshot until the next complete set validates.
|
|
54
|
+
this.diagnostics = [];
|
|
55
|
+
const candidates = new Map();
|
|
56
|
+
const aliases = new Map();
|
|
57
|
+
const rejectedIds = new Set();
|
|
40
58
|
for (const loadPath of this.config.loadPaths) {
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
catch (err) {
|
|
46
|
-
console.warn(`[PluginLoader] Failed to scan "${loadPath}":`, err);
|
|
59
|
+
for (const rootDir of this.scanDirectories(loadPath)) {
|
|
60
|
+
const candidate = this.readCandidate(rootDir);
|
|
61
|
+
if (candidate)
|
|
62
|
+
this.addCandidate(candidate, candidates, aliases, rejectedIds);
|
|
47
63
|
}
|
|
48
64
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// 依赖解析:按 requiresPlugins 拓扑排序
|
|
52
|
-
const ordered = this.resolveDependencyOrder(filtered);
|
|
53
|
-
// 检查缺失的依赖
|
|
54
|
-
const ids = new Set(ordered.map(p => p.manifest.id));
|
|
55
|
-
const disabled = new Set();
|
|
56
|
-
for (const plugin of ordered) {
|
|
57
|
-
const deps = plugin.manifest.requiresPlugins ?? [];
|
|
58
|
-
for (const dep of deps) {
|
|
59
|
-
if (!ids.has(dep)) {
|
|
60
|
-
console.warn(`[PluginLoader] Plugin "${plugin.manifest.id}" requires "${dep}", but it was not found. Skipping.`);
|
|
61
|
-
disabled.add(plugin.manifest.id);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
65
|
+
for (const candidate of candidates.values()) {
|
|
66
|
+
candidate.config = this.config.entries?.[candidate.id];
|
|
64
67
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
await this.registerPlugin(plugin);
|
|
68
|
+
for (const id of rejectedIds) {
|
|
69
|
+
const candidate = candidates.get(id);
|
|
70
|
+
if (candidate)
|
|
71
|
+
candidate.rejected = true;
|
|
70
72
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
* 扫描单个目录,发现 plugins
|
|
75
|
-
*/
|
|
76
|
-
async scanDirectory(dirPath) {
|
|
77
|
-
const plugins = [];
|
|
78
|
-
if (!existsSync(dirPath)) {
|
|
79
|
-
return plugins;
|
|
73
|
+
this.applyAliases(candidates);
|
|
74
|
+
for (const candidate of candidates.values()) {
|
|
75
|
+
candidate.eligible = this.isEligible(candidate);
|
|
80
76
|
}
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
77
|
+
for (const candidate of candidates.values()) {
|
|
78
|
+
if (candidate.eligible)
|
|
79
|
+
this.prepareCandidate(candidate);
|
|
80
|
+
}
|
|
81
|
+
// Configuration, entry, conflict and dependency failures must settle before any import.
|
|
82
|
+
let changed = true;
|
|
83
|
+
while (changed) {
|
|
84
|
+
const before = [...candidates.values()].filter((candidate) => candidate.eligible).length;
|
|
85
|
+
this.markDependencyFailures(candidates, aliases);
|
|
86
|
+
this.checkDeclaredConflicts(candidates);
|
|
87
|
+
changed = before !== [...candidates.values()].filter((candidate) => candidate.eligible).length;
|
|
88
|
+
}
|
|
89
|
+
const staged = [];
|
|
90
|
+
for (const candidate of candidates.values()) {
|
|
91
|
+
if (!candidate.eligible)
|
|
88
92
|
continue;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
const plugin = await this.importAndRegister(candidate);
|
|
94
|
+
if (plugin)
|
|
95
|
+
staged.push(plugin);
|
|
96
|
+
else
|
|
97
|
+
candidate.eligible = false;
|
|
98
|
+
}
|
|
99
|
+
this.markDependencyFailures(candidates, aliases);
|
|
100
|
+
const publishable = staged.filter((plugin) => candidates.get(plugin.manifest.id)?.eligible);
|
|
101
|
+
for (const plugin of staged) {
|
|
102
|
+
if (!candidates.get(plugin.manifest.id)?.eligible) {
|
|
103
|
+
this.fail(plugin.manifest.id, 'dependency', new Error('A required plugin failed to register'), plugin.path);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const nextDiscoveryFailed = this.diagnostics.some((item) => item.status === 'failed');
|
|
107
|
+
if (publishable.length === 0 && nextDiscoveryFailed && this.plugins.size > 0) {
|
|
108
|
+
const reason = 'New discovery has no publishable plugins; last complete snapshot retained for diagnosis';
|
|
109
|
+
this.fail('discovery', 'publish', new Error(reason));
|
|
110
|
+
throw new Error(`Plugin discovery failed: ${reason}`);
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
const nextPlugins = new Map();
|
|
114
|
+
for (const plugin of publishable) {
|
|
115
|
+
const loaded = {
|
|
116
|
+
...plugin,
|
|
117
|
+
id: plugin.manifest.id,
|
|
118
|
+
name: plugin.manifest.name,
|
|
119
|
+
version: plugin.manifest.version,
|
|
120
|
+
...(plugin.manifest.description === undefined ? {} : { description: plugin.manifest.description }),
|
|
121
|
+
source: 'local',
|
|
122
|
+
registered: true,
|
|
123
|
+
};
|
|
124
|
+
nextPlugins.set(loaded.id, loaded);
|
|
94
125
|
}
|
|
95
|
-
|
|
96
|
-
|
|
126
|
+
this.contributions.publish(publishable);
|
|
127
|
+
this.plugins = nextPlugins;
|
|
128
|
+
for (const plugin of nextPlugins.values()) {
|
|
129
|
+
this.diagnostics.push({ id: plugin.id, status: 'registered', stage: 'publish', reason: 'registered', path: plugin.path });
|
|
97
130
|
}
|
|
98
131
|
}
|
|
99
|
-
|
|
132
|
+
catch (error) {
|
|
133
|
+
// publish constructs a replacement set before assignment; a conflict cannot leave a partial new set.
|
|
134
|
+
this.fail('unknown', 'publish', error);
|
|
135
|
+
}
|
|
136
|
+
return this.getRegisteredIds().map((id) => this.plugins.get(id));
|
|
100
137
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
*/
|
|
104
|
-
async loadPluginFromDir(pluginDir, manifestPath) {
|
|
105
|
-
// 1. 读取和验证 manifest
|
|
106
|
-
const manifestJson = await fs.readFile(manifestPath, 'utf-8');
|
|
107
|
-
let manifest;
|
|
138
|
+
scanDirectories(loadPath) {
|
|
139
|
+
const root = resolve(loadPath);
|
|
108
140
|
try {
|
|
109
|
-
|
|
141
|
+
const stat = readdirSync(root, { withFileTypes: true });
|
|
142
|
+
if (existsSync(join(root, PLUGIN_MANIFEST_FILENAME)))
|
|
143
|
+
return [root];
|
|
144
|
+
return stat
|
|
145
|
+
// Dot-dirs are never plugin candidates (sync scratch `.sync-*`, VCS, hidden).
|
|
146
|
+
.filter((entry) => entry.isDirectory() && !entry.name.startsWith('.') && existsSync(join(root, entry.name, PLUGIN_MANIFEST_FILENAME)))
|
|
147
|
+
.map((entry) => join(root, entry.name));
|
|
110
148
|
}
|
|
111
|
-
catch (
|
|
112
|
-
|
|
113
|
-
return
|
|
114
|
-
}
|
|
115
|
-
// 2. 查找入口文件
|
|
116
|
-
const entryPoint = await this.resolveEntryPoint(pluginDir);
|
|
117
|
-
if (!entryPoint) {
|
|
118
|
-
console.warn(`[PluginLoader] No entry point found in "${pluginDir}"`);
|
|
119
|
-
return null;
|
|
149
|
+
catch (error) {
|
|
150
|
+
this.diagnostics.push({ id: root, status: 'failed', stage: 'manifest', reason: errorMessage(error), path: root });
|
|
151
|
+
return [];
|
|
120
152
|
}
|
|
121
|
-
|
|
122
|
-
|
|
153
|
+
}
|
|
154
|
+
readCandidate(rootDir) {
|
|
123
155
|
try {
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
if (!definition?.id || !definition?.register) {
|
|
127
|
-
console.warn(`[PluginLoader] Invalid plugin definition in "${entryPoint}": missing id or register`);
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
156
|
+
const manifest = parseManifest(readFileSync(join(rootDir, PLUGIN_MANIFEST_FILENAME), 'utf8'));
|
|
157
|
+
return { id: manifest.id, rootDir, manifest, eligible: false, rejected: false };
|
|
130
158
|
}
|
|
131
|
-
catch (
|
|
132
|
-
|
|
159
|
+
catch (error) {
|
|
160
|
+
this.fail(rootDir, 'manifest', error, rootDir);
|
|
133
161
|
return null;
|
|
134
162
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
source: entryPoint,
|
|
143
|
-
rootDir: pluginDir,
|
|
144
|
-
pluginConfig: entryConfig?.config,
|
|
145
|
-
});
|
|
146
|
-
// 5. 注册 manifest 中声明的能力
|
|
147
|
-
try {
|
|
148
|
-
registerManifestCapabilities(manifest, this.capabilities);
|
|
163
|
+
}
|
|
164
|
+
addCandidate(candidate, candidates, aliases, rejectedIds) {
|
|
165
|
+
const previous = candidates.get(candidate.id);
|
|
166
|
+
if (previous) {
|
|
167
|
+
this.fail(candidate.id, 'manifest', new Error(`Duplicate plugin id at ${candidate.rootDir} and ${previous.rootDir}`), candidate.rootDir);
|
|
168
|
+
rejectedIds.add(candidate.id);
|
|
169
|
+
return;
|
|
149
170
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
171
|
+
const ids = [candidate.id, ...(candidate.manifest.legacyPluginIds ?? [])];
|
|
172
|
+
for (const id of ids) {
|
|
173
|
+
const owner = aliases.get(id);
|
|
174
|
+
if (owner && owner !== candidate.id) {
|
|
175
|
+
this.fail(candidate.id, 'manifest', new Error(`Plugin id or legacy alias "${id}" conflicts with "${owner}"`), candidate.rootDir);
|
|
176
|
+
this.fail(owner, 'manifest', new Error(`Plugin id or legacy alias "${id}" conflicts with "${candidate.id}"`));
|
|
177
|
+
rejectedIds.add(candidate.id).add(owner);
|
|
178
|
+
}
|
|
153
179
|
}
|
|
154
|
-
const
|
|
155
|
-
id
|
|
156
|
-
|
|
157
|
-
definition,
|
|
158
|
-
api,
|
|
159
|
-
source: entryPoint,
|
|
160
|
-
rootDir: pluginDir,
|
|
161
|
-
registered: false,
|
|
162
|
-
};
|
|
163
|
-
this.plugins.set(manifest.id, plugin);
|
|
164
|
-
return plugin;
|
|
180
|
+
for (const id of ids)
|
|
181
|
+
aliases.set(id, candidate.id);
|
|
182
|
+
candidates.set(candidate.id, candidate);
|
|
165
183
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
*/
|
|
174
|
-
async resolveEntryPoint(pluginDir) {
|
|
175
|
-
// 检查 package.json
|
|
176
|
-
const pkgPath = path.join(pluginDir, 'package.json');
|
|
177
|
-
if (existsSync(pkgPath)) {
|
|
178
|
-
try {
|
|
179
|
-
const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf-8'));
|
|
180
|
-
// main 字段
|
|
181
|
-
if (pkg.main) {
|
|
182
|
-
const main = path.resolve(pluginDir, pkg.main);
|
|
183
|
-
if (existsSync(main))
|
|
184
|
-
return main;
|
|
185
|
-
}
|
|
184
|
+
applyAliases(candidates) {
|
|
185
|
+
for (const candidate of candidates.values()) {
|
|
186
|
+
const spellings = [candidate.id, ...(candidate.manifest.legacyPluginIds ?? [])];
|
|
187
|
+
const configured = spellings.filter((id) => this.config.entries?.[id] !== undefined);
|
|
188
|
+
if (configured.length > 1) {
|
|
189
|
+
this.fail(candidate.id, 'policy', new Error(`Plugin is configured under multiple identities: ${configured.join(', ')}`), candidate.rootDir);
|
|
190
|
+
candidate.rejected = true;
|
|
186
191
|
}
|
|
187
|
-
|
|
188
|
-
|
|
192
|
+
else if (configured.length === 1) {
|
|
193
|
+
candidate.config = this.config.entries?.[configured[0]];
|
|
189
194
|
}
|
|
190
195
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
196
|
+
}
|
|
197
|
+
isEligible(candidate) {
|
|
198
|
+
if (candidate.rejected)
|
|
199
|
+
return false;
|
|
200
|
+
const ids = [candidate.id, ...(candidate.manifest.legacyPluginIds ?? [])];
|
|
201
|
+
if (this.config.blockList?.some((id) => ids.includes(id))) {
|
|
202
|
+
this.disabled(candidate, 'blocklisted');
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
if (this.config.allowList && !ids.some((id) => this.config.allowList.includes(id))) {
|
|
206
|
+
this.disabled(candidate, 'not in allowList');
|
|
207
|
+
return false;
|
|
201
208
|
}
|
|
202
|
-
|
|
209
|
+
const enabled = candidate.config?.enabled ?? candidate.manifest.enabledByDefault ?? true;
|
|
210
|
+
if (!enabled) {
|
|
211
|
+
this.disabled(candidate, 'disabled by configuration or manifest default');
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
return true;
|
|
203
215
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
console.info(`[PluginLoader] Plugin "${plugin.id}" is blocklisted, skipping`);
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
// Allowlist
|
|
215
|
-
if (this.config.allowList && this.config.allowList.length > 0) {
|
|
216
|
-
if (!this.config.allowList.includes(plugin.id)) {
|
|
217
|
-
console.info(`[PluginLoader] Plugin "${plugin.id}" not in allowlist, skipping`);
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
216
|
+
prepareCandidate(candidate) {
|
|
217
|
+
try {
|
|
218
|
+
candidate.entryPoint = resolvePluginEntry(candidate.rootDir, candidate.manifest.entry);
|
|
219
|
+
candidate.pluginConfig = validatePluginConfig(candidate.manifest, candidate.config?.config);
|
|
220
|
+
const engineVersion = this.config.engineVersion ?? getEngineVersion();
|
|
221
|
+
if (!satisfiesEngineRange(engineVersion, candidate.manifest.engine.octopi)) {
|
|
222
|
+
throw new Error(`Requires Octopi ${candidate.manifest.engine.octopi}; host is ${engineVersion}`);
|
|
220
223
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
this.fail(candidate.id, 'config', error, candidate.rootDir);
|
|
227
|
+
candidate.eligible = false;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
markDependencyFailures(candidates, aliases) {
|
|
231
|
+
const visiting = new Set();
|
|
232
|
+
const failed = new Set();
|
|
233
|
+
const visit = (id) => {
|
|
234
|
+
const candidate = candidates.get(id);
|
|
235
|
+
if (!candidate || !candidate.eligible)
|
|
236
|
+
return false;
|
|
237
|
+
if (visiting.has(id)) {
|
|
238
|
+
this.fail(id, 'dependency', new Error('Circular plugin dependency'), candidate.rootDir);
|
|
239
|
+
candidate.eligible = false;
|
|
240
|
+
failed.add(id);
|
|
225
241
|
return false;
|
|
226
242
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
return false;
|
|
243
|
+
if (failed.has(id))
|
|
244
|
+
return false;
|
|
245
|
+
visiting.add(id);
|
|
246
|
+
for (const dependencyName of candidate.manifest.requiresPlugins ?? []) {
|
|
247
|
+
const dependency = aliases.get(dependencyName) ?? dependencyName;
|
|
248
|
+
if (!visit(dependency)) {
|
|
249
|
+
this.fail(id, 'dependency', new Error(`Missing or ineligible dependency "${dependencyName}" (resolved to "${dependency}")`), candidate.rootDir);
|
|
250
|
+
candidate.eligible = false;
|
|
251
|
+
failed.add(id);
|
|
252
|
+
break;
|
|
238
253
|
}
|
|
239
254
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
255
|
+
visiting.delete(id);
|
|
256
|
+
return candidate.eligible;
|
|
257
|
+
};
|
|
258
|
+
for (const id of candidates.keys())
|
|
259
|
+
visit(id);
|
|
260
|
+
}
|
|
261
|
+
checkDeclaredConflicts(candidates) {
|
|
262
|
+
const claims = new Map();
|
|
263
|
+
for (const candidate of candidates.values()) {
|
|
264
|
+
if (!candidate.eligible)
|
|
265
|
+
continue;
|
|
266
|
+
for (const kind of CONTRIBUTION_KINDS) {
|
|
267
|
+
for (const claim of declaredClaims(kind, candidate.manifest)) {
|
|
268
|
+
const owner = claims.get(claim);
|
|
269
|
+
if (owner) {
|
|
270
|
+
this.fail(candidate.id, 'register', new Error(`Declared ${claim} conflicts with "${owner}"`), candidate.rootDir);
|
|
271
|
+
candidate.eligible = false;
|
|
272
|
+
const first = candidates.get(owner);
|
|
273
|
+
if (first) {
|
|
274
|
+
first.eligible = false;
|
|
275
|
+
this.fail(owner, 'register', new Error(`Declared ${claim} conflicts with "${candidate.id}"`), first.rootDir);
|
|
276
|
+
}
|
|
246
277
|
}
|
|
278
|
+
else
|
|
279
|
+
claims.set(claim, candidate.id);
|
|
247
280
|
}
|
|
248
281
|
}
|
|
249
|
-
return true;
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* 拓扑排序:按依赖关系排列 plugin 顺序
|
|
254
|
-
*
|
|
255
|
-
* 使用 Kahn 算法。被依赖的 plugin 排在前面。
|
|
256
|
-
* 存在循环依赖时,剩余的 plugin 按原始顺序追加并警告。
|
|
257
|
-
*/
|
|
258
|
-
resolveDependencyOrder(plugins) {
|
|
259
|
-
const idToPlugin = new Map();
|
|
260
|
-
for (const p of plugins) {
|
|
261
|
-
idToPlugin.set(p.id, p);
|
|
262
|
-
}
|
|
263
|
-
// 计算入度(有多少 plugin 依赖它)
|
|
264
|
-
const inDegree = new Map();
|
|
265
|
-
const dependents = new Map(); // dep → [plugins that depend on it]
|
|
266
|
-
for (const p of plugins) {
|
|
267
|
-
if (!inDegree.has(p.id))
|
|
268
|
-
inDegree.set(p.id, 0);
|
|
269
|
-
const deps = (p.manifest.requiresPlugins ?? []).filter(d => idToPlugin.has(d));
|
|
270
|
-
for (const dep of deps) {
|
|
271
|
-
inDegree.set(p.id, (inDegree.get(p.id) ?? 0) + 1);
|
|
272
|
-
if (!dependents.has(dep))
|
|
273
|
-
dependents.set(dep, []);
|
|
274
|
-
dependents.get(dep).push(p.id);
|
|
275
|
-
}
|
|
276
282
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
283
|
+
}
|
|
284
|
+
async importAndRegister(candidate) {
|
|
285
|
+
const { manifest, rootDir, entryPoint, pluginConfig } = candidate;
|
|
286
|
+
if (!entryPoint || !pluginConfig) {
|
|
287
|
+
this.fail(manifest.id, 'config', new Error('Candidate has not completed pre-import validation'), rootDir);
|
|
288
|
+
return null;
|
|
282
289
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
const newDeg = (inDegree.get(dep) ?? 1) - 1;
|
|
289
|
-
inDegree.set(dep, newDeg);
|
|
290
|
-
if (newDeg === 0)
|
|
291
|
-
queue.push(dep);
|
|
290
|
+
try {
|
|
291
|
+
const module = await import(pathToFileURL(entryPoint).href);
|
|
292
|
+
const definition = module.default;
|
|
293
|
+
if (!definition || definition.id !== manifest.id || typeof definition.register !== 'function') {
|
|
294
|
+
throw new Error(`Default entry must be definePlugin({ id: "${manifest.id}", register })`);
|
|
292
295
|
}
|
|
296
|
+
const api = new PluginApi({
|
|
297
|
+
id: manifest.id,
|
|
298
|
+
name: manifest.name,
|
|
299
|
+
version: manifest.version,
|
|
300
|
+
...(manifest.description === undefined ? {} : { description: manifest.description }),
|
|
301
|
+
source: rootDir,
|
|
302
|
+
rootDir,
|
|
303
|
+
pluginConfig,
|
|
304
|
+
});
|
|
305
|
+
await definition.register(api);
|
|
306
|
+
this.assertActualContributions(manifest, api);
|
|
307
|
+
return { manifest, definition, api, path: rootDir };
|
|
293
308
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
if (remaining.length > 0) {
|
|
298
|
-
console.warn(`[PluginLoader] Circular dependency detected among: ${remaining.map(p => p.id).join(', ')}. Appending in original order.`);
|
|
299
|
-
result.push(...remaining);
|
|
309
|
+
catch (error) {
|
|
310
|
+
this.fail(manifest.id, 'register', error, rootDir);
|
|
311
|
+
return null;
|
|
300
312
|
}
|
|
301
|
-
return result;
|
|
302
313
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if (plugin.registered)
|
|
308
|
-
return;
|
|
309
|
-
try {
|
|
310
|
-
await plugin.definition.register(plugin.api);
|
|
311
|
-
plugin.registered = true;
|
|
312
|
-
console.info(`[PluginLoader] Plugin "${plugin.id}" registered successfully`);
|
|
314
|
+
assertActualContributions(manifest, api) {
|
|
315
|
+
const staged = readStaging(api);
|
|
316
|
+
for (const kind of CONTRIBUTION_KINDS) {
|
|
317
|
+
assertManifestCoverage(kind, manifest, staged);
|
|
313
318
|
}
|
|
314
|
-
catch (err) {
|
|
315
|
-
console.error(`[PluginLoader] Plugin "${plugin.id}" register() failed:`, err);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* 获取已加载的 plugin
|
|
320
|
-
*/
|
|
321
|
-
getPlugin(id) {
|
|
322
|
-
return this.plugins.get(id);
|
|
323
319
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
*/
|
|
327
|
-
getAllPlugins() {
|
|
328
|
-
return [...this.plugins.values()];
|
|
320
|
+
disabled(candidate, reason) {
|
|
321
|
+
this.diagnostics.push({ id: candidate.id, status: 'disabled', stage: 'policy', reason, path: candidate.rootDir });
|
|
329
322
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
*/
|
|
333
|
-
getRegisteredIds() {
|
|
334
|
-
return [...this.plugins.values()].filter((p) => p.registered).map((p) => p.id);
|
|
323
|
+
fail(id, stage, error, path) {
|
|
324
|
+
this.diagnostics.push({ id, status: 'failed', stage, reason: errorMessage(error), ...(path === undefined ? {} : { path }) });
|
|
335
325
|
}
|
|
326
|
+
getDiagnostics() { return this.diagnostics.map((item) => ({ ...item })); }
|
|
327
|
+
getRegisteredIds() { return [...this.plugins.keys()]; }
|
|
328
|
+
getPlugin(id) { return this.plugins.get(id); }
|
|
329
|
+
getAllPlugins() { return [...this.plugins.values()]; }
|
|
330
|
+
}
|
|
331
|
+
function errorMessage(error) {
|
|
332
|
+
return error instanceof Error ? error.message : String(error);
|
|
336
333
|
}
|