@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,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TruncateCompressor — 截断压缩器
|
|
3
|
-
*
|
|
4
|
-
* 最简单的压缩策略:直接截断早期消息,保留最近消息。
|
|
5
|
-
* 不需要 LLM,零成本,但信息损失最大。
|
|
6
|
-
*
|
|
7
|
-
* 作为兜底方案,当 LLM 摘要不可用时使用。
|
|
8
|
-
*/
|
|
9
|
-
import { HeuristicTokenEstimator } from './token-estimator.js';
|
|
10
|
-
export class TruncateCompressor {
|
|
11
|
-
/**
|
|
12
|
-
* 压缩消息
|
|
13
|
-
*
|
|
14
|
-
* 策略:
|
|
15
|
-
* 1. 从头部开始移除消息,直到达到目标 token 数
|
|
16
|
-
* 2. 插入一条摘要消息说明被移除的内容
|
|
17
|
-
* 3. 保持边界对齐(不拆分 tool_call/tool_result 对)
|
|
18
|
-
*/
|
|
19
|
-
async compress(params) {
|
|
20
|
-
const { messages, targetTokens, tokenEstimator } = params;
|
|
21
|
-
const estimator = tokenEstimator ?? new HeuristicTokenEstimator();
|
|
22
|
-
// 如果没有消息需要压缩
|
|
23
|
-
if (messages.length === 0) {
|
|
24
|
-
return {
|
|
25
|
-
result: [],
|
|
26
|
-
estimatedTokens: 0,
|
|
27
|
-
fresh: false,
|
|
28
|
-
summarizeAttempted: false,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// 计算当前 token 数
|
|
32
|
-
const currentTokens = estimator.estimateMessages(messages);
|
|
33
|
-
// 如果已经在预算内,不需要压缩
|
|
34
|
-
if (currentTokens <= targetTokens) {
|
|
35
|
-
return {
|
|
36
|
-
result: [...messages],
|
|
37
|
-
estimatedTokens: currentTokens,
|
|
38
|
-
fresh: false,
|
|
39
|
-
summarizeAttempted: false,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
// 需要压缩的 token 数
|
|
43
|
-
const excessTokens = currentTokens - targetTokens;
|
|
44
|
-
// 从头部开始移除消息
|
|
45
|
-
const remaining = [...messages];
|
|
46
|
-
let removedCount = 0;
|
|
47
|
-
let removedTokens = 0;
|
|
48
|
-
while (remaining.length > 0 && removedTokens < excessTokens) {
|
|
49
|
-
const msg = remaining[0];
|
|
50
|
-
const msgTokens = estimator.estimateMessage(msg);
|
|
51
|
-
// 边界对齐:如果下一条是 tool_result,一起移除
|
|
52
|
-
if (this.hasToolCall(msg) && remaining.length > 1 && this.isToolResult(remaining[1])) {
|
|
53
|
-
const nextTokens = estimator.estimateMessage(remaining[1]);
|
|
54
|
-
remaining.splice(0, 2);
|
|
55
|
-
removedTokens += msgTokens + nextTokens;
|
|
56
|
-
removedCount += 2;
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
remaining.shift();
|
|
60
|
-
removedTokens += msgTokens;
|
|
61
|
-
removedCount++;
|
|
62
|
-
}
|
|
63
|
-
// 至少保留最后 2 条消息
|
|
64
|
-
if (remaining.length <= 2) {
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// 如果没有移除任何消息,强制移除最早的一条
|
|
69
|
-
if (removedCount === 0 && remaining.length > 2) {
|
|
70
|
-
const removed = remaining.shift();
|
|
71
|
-
removedCount = 1;
|
|
72
|
-
removedTokens = estimator.estimateMessage(removed);
|
|
73
|
-
}
|
|
74
|
-
// 生成摘要消息(user 角色,避免中段 system)
|
|
75
|
-
const summaryMessage = {
|
|
76
|
-
role: 'user',
|
|
77
|
-
content: `[Context compressed: ${removedCount} earlier messages removed to fit context window. ` +
|
|
78
|
-
`Approximately ${removedTokens} tokens saved. ` +
|
|
79
|
-
`The conversation continues from here.]`,
|
|
80
|
-
timestamp: Date.now(),
|
|
81
|
-
metadata: { source: 'contextSummary' },
|
|
82
|
-
};
|
|
83
|
-
// 组装结果
|
|
84
|
-
const result = [summaryMessage, ...remaining];
|
|
85
|
-
const estimatedTokens = estimator.estimateMessages(result);
|
|
86
|
-
return {
|
|
87
|
-
result,
|
|
88
|
-
estimatedTokens,
|
|
89
|
-
droppedSummary: `${removedCount} messages removed (~${removedTokens} tokens)`,
|
|
90
|
-
// 纯截断不是语义摘要(F8R-01 显式契约);调用方冷却语义:截断未发起 LLM
|
|
91
|
-
fresh: false,
|
|
92
|
-
summarizeAttempted: false,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* 检查消息是否包含工具调用
|
|
97
|
-
*/
|
|
98
|
-
hasToolCall(msg) {
|
|
99
|
-
return msg.role === 'assistant' && msg.toolCalls !== undefined && msg.toolCalls.length > 0;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* 检查消息是否是工具结果
|
|
103
|
-
*/
|
|
104
|
-
isToolResult(msg) {
|
|
105
|
-
return msg.role === 'tool' || (msg.toolResults !== undefined && msg.toolResults.length > 0);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Capability Registry — 能力注册中心
|
|
3
|
-
*
|
|
4
|
-
* 每种能力类型有独立的注册表,plugin 是能力的所有权边界。
|
|
5
|
-
*
|
|
6
|
-
* 核心原则:
|
|
7
|
-
* - plugin = 所有权边界(一个公司/功能的所有表面)
|
|
8
|
-
* - capability = 核心合约,多个 plugin 可以实现或消费
|
|
9
|
-
* - 冲突检测:同一 capability ID 不能被两个 plugin 注册
|
|
10
|
-
*/
|
|
11
|
-
import type { PluginManifest } from './manifest.js';
|
|
12
|
-
/**
|
|
13
|
-
* 能力类型枚举
|
|
14
|
-
*/
|
|
15
|
-
export type CapabilityType = 'provider' | 'channel' | 'tool' | 'context-engine' | 'embedding-provider' | 'speech-provider' | 'media-understanding-provider' | 'image-generation-provider' | 'video-generation-provider' | 'web-search-provider' | 'web-fetch-provider' | 'service' | 'command';
|
|
16
|
-
/**
|
|
17
|
-
* 能力注册记录
|
|
18
|
-
*/
|
|
19
|
-
export interface CapabilityRecord {
|
|
20
|
-
/** 能力类型 */
|
|
21
|
-
type: CapabilityType;
|
|
22
|
-
/** 能力 ID(如 provider name、tool name、channel id) */
|
|
23
|
-
capabilityId: string;
|
|
24
|
-
/** 拥有者 plugin ID */
|
|
25
|
-
pluginId: string;
|
|
26
|
-
/** 额外元数据 */
|
|
27
|
-
metadata?: Record<string, unknown>;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Capability Registry
|
|
31
|
-
*
|
|
32
|
-
* 中央能力注册中心。所有 plugin 注册的能力都在这里记录,
|
|
33
|
-
* 用于冲突检测、ownership 查询和诊断。
|
|
34
|
-
*/
|
|
35
|
-
export declare class CapabilityRegistry {
|
|
36
|
-
/** 所有能力记录 */
|
|
37
|
-
private records;
|
|
38
|
-
/** 索引:type:capabilityId → record */
|
|
39
|
-
private index;
|
|
40
|
-
/**
|
|
41
|
-
* 注册一个能力
|
|
42
|
-
*
|
|
43
|
-
* @param type - 能力类型
|
|
44
|
-
* @param capabilityId - 能力 ID
|
|
45
|
-
* @param pluginId - 拥有者 plugin ID
|
|
46
|
-
* @param metadata - 额外元数据
|
|
47
|
-
* @throws 如果能力已被另一个 plugin 注册
|
|
48
|
-
*/
|
|
49
|
-
register(type: CapabilityType, capabilityId: string, pluginId: string, metadata?: Record<string, unknown>): void;
|
|
50
|
-
/**
|
|
51
|
-
* 查询能力的拥有者
|
|
52
|
-
*
|
|
53
|
-
* @param type - 能力类型
|
|
54
|
-
* @param capabilityId - 能力 ID
|
|
55
|
-
* @returns 拥有者 plugin ID,未注册返回 null
|
|
56
|
-
*/
|
|
57
|
-
lookup(type: CapabilityType, capabilityId: string): string | null;
|
|
58
|
-
/**
|
|
59
|
-
* 查询指定 plugin 拥有的所有能力
|
|
60
|
-
*
|
|
61
|
-
* @param pluginId - Plugin ID
|
|
62
|
-
* @returns 能力记录列表
|
|
63
|
-
*/
|
|
64
|
-
getCapabilitiesForPlugin(pluginId: string): CapabilityRecord[];
|
|
65
|
-
/**
|
|
66
|
-
* 查询指定类型的所有能力
|
|
67
|
-
*
|
|
68
|
-
* @param type - 能力类型
|
|
69
|
-
* @returns 能力记录列表
|
|
70
|
-
*/
|
|
71
|
-
getCapabilitiesByType(type: CapabilityType): CapabilityRecord[];
|
|
72
|
-
/**
|
|
73
|
-
* 移除指定 plugin 的所有能力
|
|
74
|
-
*
|
|
75
|
-
* @param pluginId - Plugin ID
|
|
76
|
-
*/
|
|
77
|
-
unregisterPlugin(pluginId: string): void;
|
|
78
|
-
/**
|
|
79
|
-
* 获取所有注册记录(用于诊断)
|
|
80
|
-
*/
|
|
81
|
-
getAll(): CapabilityRecord[];
|
|
82
|
-
/**
|
|
83
|
-
* 获取能力总数
|
|
84
|
-
*/
|
|
85
|
-
get size(): number;
|
|
86
|
-
/**
|
|
87
|
-
* 检查能力是否已注册
|
|
88
|
-
*/
|
|
89
|
-
has(type: CapabilityType, capabilityId: string): boolean;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* 从 manifest 提取能力声明并注册到 CapabilityRegistry
|
|
93
|
-
*
|
|
94
|
-
* @param manifest - Plugin manifest
|
|
95
|
-
* @param registry - Capability Registry
|
|
96
|
-
*/
|
|
97
|
-
export declare function registerManifestCapabilities(manifest: PluginManifest, registry: CapabilityRegistry): void;
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Capability Registry — 能力注册中心
|
|
3
|
-
*
|
|
4
|
-
* 每种能力类型有独立的注册表,plugin 是能力的所有权边界。
|
|
5
|
-
*
|
|
6
|
-
* 核心原则:
|
|
7
|
-
* - plugin = 所有权边界(一个公司/功能的所有表面)
|
|
8
|
-
* - capability = 核心合约,多个 plugin 可以实现或消费
|
|
9
|
-
* - 冲突检测:同一 capability ID 不能被两个 plugin 注册
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Capability Registry
|
|
13
|
-
*
|
|
14
|
-
* 中央能力注册中心。所有 plugin 注册的能力都在这里记录,
|
|
15
|
-
* 用于冲突检测、ownership 查询和诊断。
|
|
16
|
-
*/
|
|
17
|
-
export class CapabilityRegistry {
|
|
18
|
-
/** 所有能力记录 */
|
|
19
|
-
records = [];
|
|
20
|
-
/** 索引:type:capabilityId → record */
|
|
21
|
-
index = new Map();
|
|
22
|
-
/**
|
|
23
|
-
* 注册一个能力
|
|
24
|
-
*
|
|
25
|
-
* @param type - 能力类型
|
|
26
|
-
* @param capabilityId - 能力 ID
|
|
27
|
-
* @param pluginId - 拥有者 plugin ID
|
|
28
|
-
* @param metadata - 额外元数据
|
|
29
|
-
* @throws 如果能力已被另一个 plugin 注册
|
|
30
|
-
*/
|
|
31
|
-
register(type, capabilityId, pluginId, metadata) {
|
|
32
|
-
const key = `${type}:${capabilityId}`;
|
|
33
|
-
const existing = this.index.get(key);
|
|
34
|
-
if (existing && existing.pluginId !== pluginId) {
|
|
35
|
-
throw new Error(`Capability conflict: "${type}:${capabilityId}" is already registered by plugin "${existing.pluginId}", ` +
|
|
36
|
-
`cannot register from plugin "${pluginId}"`);
|
|
37
|
-
}
|
|
38
|
-
if (existing) {
|
|
39
|
-
// 同一 plugin 重复注册,静默忽略
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const record = { type, capabilityId, pluginId, metadata };
|
|
43
|
-
this.records.push(record);
|
|
44
|
-
this.index.set(key, record);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* 查询能力的拥有者
|
|
48
|
-
*
|
|
49
|
-
* @param type - 能力类型
|
|
50
|
-
* @param capabilityId - 能力 ID
|
|
51
|
-
* @returns 拥有者 plugin ID,未注册返回 null
|
|
52
|
-
*/
|
|
53
|
-
lookup(type, capabilityId) {
|
|
54
|
-
const key = `${type}:${capabilityId}`;
|
|
55
|
-
return this.index.get(key)?.pluginId ?? null;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* 查询指定 plugin 拥有的所有能力
|
|
59
|
-
*
|
|
60
|
-
* @param pluginId - Plugin ID
|
|
61
|
-
* @returns 能力记录列表
|
|
62
|
-
*/
|
|
63
|
-
getCapabilitiesForPlugin(pluginId) {
|
|
64
|
-
return this.records.filter((r) => r.pluginId === pluginId);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* 查询指定类型的所有能力
|
|
68
|
-
*
|
|
69
|
-
* @param type - 能力类型
|
|
70
|
-
* @returns 能力记录列表
|
|
71
|
-
*/
|
|
72
|
-
getCapabilitiesByType(type) {
|
|
73
|
-
return this.records.filter((r) => r.type === type);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* 移除指定 plugin 的所有能力
|
|
77
|
-
*
|
|
78
|
-
* @param pluginId - Plugin ID
|
|
79
|
-
*/
|
|
80
|
-
unregisterPlugin(pluginId) {
|
|
81
|
-
this.records = this.records.filter((r) => {
|
|
82
|
-
if (r.pluginId === pluginId) {
|
|
83
|
-
const key = `${r.type}:${r.capabilityId}`;
|
|
84
|
-
this.index.delete(key);
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
return true;
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* 获取所有注册记录(用于诊断)
|
|
92
|
-
*/
|
|
93
|
-
getAll() {
|
|
94
|
-
return [...this.records];
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* 获取能力总数
|
|
98
|
-
*/
|
|
99
|
-
get size() {
|
|
100
|
-
return this.records.length;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* 检查能力是否已注册
|
|
104
|
-
*/
|
|
105
|
-
has(type, capabilityId) {
|
|
106
|
-
return this.index.has(`${type}:${capabilityId}`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* 从 manifest 提取能力声明并注册到 CapabilityRegistry
|
|
111
|
-
*
|
|
112
|
-
* @param manifest - Plugin manifest
|
|
113
|
-
* @param registry - Capability Registry
|
|
114
|
-
*/
|
|
115
|
-
export function registerManifestCapabilities(manifest, registry) {
|
|
116
|
-
const pluginId = manifest.id;
|
|
117
|
-
// 注册 providers
|
|
118
|
-
if (manifest.providers) {
|
|
119
|
-
for (const providerId of manifest.providers) {
|
|
120
|
-
registry.register('provider', providerId, pluginId);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
// 注册 channels
|
|
124
|
-
if (manifest.channels) {
|
|
125
|
-
for (const channelId of manifest.channels) {
|
|
126
|
-
registry.register('channel', channelId, pluginId);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
// 注册 contracts.tools
|
|
130
|
-
if (manifest.contracts?.tools) {
|
|
131
|
-
for (const toolName of manifest.contracts.tools) {
|
|
132
|
-
registry.register('tool', toolName, pluginId);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
// 注册 contracts 中的其他能力
|
|
136
|
-
const contractTypes = [
|
|
137
|
-
{ key: 'embeddingProviders', type: 'embedding-provider' },
|
|
138
|
-
{ key: 'speechProviders', type: 'speech-provider' },
|
|
139
|
-
{ key: 'mediaUnderstandingProviders', type: 'media-understanding-provider' },
|
|
140
|
-
{ key: 'imageGenerationProviders', type: 'image-generation-provider' },
|
|
141
|
-
{ key: 'videoGenerationProviders', type: 'video-generation-provider' },
|
|
142
|
-
{ key: 'webFetchProviders', type: 'web-fetch-provider' },
|
|
143
|
-
{ key: 'webSearchProviders', type: 'web-search-provider' },
|
|
144
|
-
];
|
|
145
|
-
if (manifest.contracts) {
|
|
146
|
-
for (const { key, type } of contractTypes) {
|
|
147
|
-
const ids = manifest.contracts[key];
|
|
148
|
-
if (ids) {
|
|
149
|
-
for (const id of ids) {
|
|
150
|
-
registry.register(type, id, pluginId);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin 生命周期管理 — 扩展 PluginManager
|
|
3
|
-
*
|
|
4
|
-
* 为 PluginManager 添加完整的生命周期管理能力:
|
|
5
|
-
* - PluginState 状态机
|
|
6
|
-
* - activate / suspend / resume / unload 方法
|
|
7
|
-
* - 状态查询
|
|
8
|
-
*/
|
|
9
|
-
/** Plugin 状态 */
|
|
10
|
-
export type PluginState = 'discovered' | 'loaded' | 'activated' | 'suspended' | 'deactivated' | 'unloaded' | 'error';
|
|
11
|
-
/** Plugin 条目(带状态) */
|
|
12
|
-
export interface PluginEntry {
|
|
13
|
-
/** Plugin ID */
|
|
14
|
-
id: string;
|
|
15
|
-
/** 当前状态 */
|
|
16
|
-
state: PluginState;
|
|
17
|
-
/** 加载时间 */
|
|
18
|
-
loadedAt?: number;
|
|
19
|
-
/** 激活时间 */
|
|
20
|
-
activatedAt?: number;
|
|
21
|
-
/** 错误信息 */
|
|
22
|
-
error?: Error;
|
|
23
|
-
/** 扩展元数据 */
|
|
24
|
-
metadata: Record<string, unknown>;
|
|
25
|
-
}
|
|
26
|
-
/** Plugin 生命周期管理器 */
|
|
27
|
-
export declare class PluginLifecycleManager {
|
|
28
|
-
/** Plugin 状态映射 */
|
|
29
|
-
private states;
|
|
30
|
-
/**
|
|
31
|
-
* 注册 Plugin(发现后调用)
|
|
32
|
-
*/
|
|
33
|
-
register(pluginId: string): void;
|
|
34
|
-
/**
|
|
35
|
-
* 标记为已加载
|
|
36
|
-
*/
|
|
37
|
-
markLoaded(pluginId: string): void;
|
|
38
|
-
/**
|
|
39
|
-
* 激活 Plugin
|
|
40
|
-
*/
|
|
41
|
-
activate(pluginId: string): void;
|
|
42
|
-
/**
|
|
43
|
-
* 暂停 Plugin
|
|
44
|
-
*/
|
|
45
|
-
suspend(pluginId: string): void;
|
|
46
|
-
/**
|
|
47
|
-
* 恢复 Plugin
|
|
48
|
-
*/
|
|
49
|
-
resume(pluginId: string): void;
|
|
50
|
-
/**
|
|
51
|
-
* 停用 Plugin
|
|
52
|
-
*/
|
|
53
|
-
deactivate(pluginId: string): void;
|
|
54
|
-
/**
|
|
55
|
-
* 卸载 Plugin
|
|
56
|
-
*/
|
|
57
|
-
unload(pluginId: string): void;
|
|
58
|
-
/**
|
|
59
|
-
* 标记错误
|
|
60
|
-
*/
|
|
61
|
-
markError(pluginId: string, error: Error): void;
|
|
62
|
-
/**
|
|
63
|
-
* 获取 Plugin 状态
|
|
64
|
-
*/
|
|
65
|
-
getState(pluginId: string): PluginState;
|
|
66
|
-
/**
|
|
67
|
-
* 获取 Plugin 条目
|
|
68
|
-
*/
|
|
69
|
-
getEntry(pluginId: string): PluginEntry | undefined;
|
|
70
|
-
/**
|
|
71
|
-
* 获取所有 Plugin 状态
|
|
72
|
-
*/
|
|
73
|
-
listStates(): PluginEntry[];
|
|
74
|
-
/**
|
|
75
|
-
* 检查 Plugin 是否激活
|
|
76
|
-
*/
|
|
77
|
-
isActivated(pluginId: string): boolean;
|
|
78
|
-
/**
|
|
79
|
-
* 获取已激活的 Plugin ID 列表
|
|
80
|
-
*/
|
|
81
|
-
getActivatedIds(): string[];
|
|
82
|
-
/**
|
|
83
|
-
* 获取或创建条目
|
|
84
|
-
*/
|
|
85
|
-
private getOrCreate;
|
|
86
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin 生命周期管理 — 扩展 PluginManager
|
|
3
|
-
*
|
|
4
|
-
* 为 PluginManager 添加完整的生命周期管理能力:
|
|
5
|
-
* - PluginState 状态机
|
|
6
|
-
* - activate / suspend / resume / unload 方法
|
|
7
|
-
* - 状态查询
|
|
8
|
-
*/
|
|
9
|
-
/** Plugin 生命周期管理器 */
|
|
10
|
-
export class PluginLifecycleManager {
|
|
11
|
-
/** Plugin 状态映射 */
|
|
12
|
-
states = new Map();
|
|
13
|
-
/**
|
|
14
|
-
* 注册 Plugin(发现后调用)
|
|
15
|
-
*/
|
|
16
|
-
register(pluginId) {
|
|
17
|
-
if (!this.states.has(pluginId)) {
|
|
18
|
-
this.states.set(pluginId, {
|
|
19
|
-
id: pluginId,
|
|
20
|
-
state: 'discovered',
|
|
21
|
-
metadata: {},
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* 标记为已加载
|
|
27
|
-
*/
|
|
28
|
-
markLoaded(pluginId) {
|
|
29
|
-
const entry = this.getOrCreate(pluginId);
|
|
30
|
-
entry.state = 'loaded';
|
|
31
|
-
entry.loadedAt = Date.now();
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* 激活 Plugin
|
|
35
|
-
*/
|
|
36
|
-
activate(pluginId) {
|
|
37
|
-
const entry = this.getOrCreate(pluginId);
|
|
38
|
-
if (entry.state === 'unloaded') {
|
|
39
|
-
throw new Error(`Cannot activate unloaded plugin "${pluginId}"`);
|
|
40
|
-
}
|
|
41
|
-
entry.state = 'activated';
|
|
42
|
-
entry.activatedAt = Date.now();
|
|
43
|
-
entry.error = undefined;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* 暂停 Plugin
|
|
47
|
-
*/
|
|
48
|
-
suspend(pluginId) {
|
|
49
|
-
const entry = this.getEntry(pluginId);
|
|
50
|
-
if (!entry || entry.state !== 'activated') {
|
|
51
|
-
throw new Error(`Plugin "${pluginId}" is not activated`);
|
|
52
|
-
}
|
|
53
|
-
entry.state = 'suspended';
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* 恢复 Plugin
|
|
57
|
-
*/
|
|
58
|
-
resume(pluginId) {
|
|
59
|
-
const entry = this.getEntry(pluginId);
|
|
60
|
-
if (!entry || entry.state !== 'suspended') {
|
|
61
|
-
throw new Error(`Plugin "${pluginId}" is not suspended`);
|
|
62
|
-
}
|
|
63
|
-
entry.state = 'activated';
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* 停用 Plugin
|
|
67
|
-
*/
|
|
68
|
-
deactivate(pluginId) {
|
|
69
|
-
const entry = this.getEntry(pluginId);
|
|
70
|
-
if (!entry)
|
|
71
|
-
throw new Error(`Plugin "${pluginId}" not found`);
|
|
72
|
-
if (entry.state !== 'activated' && entry.state !== 'suspended') {
|
|
73
|
-
throw new Error(`Plugin "${pluginId}" is not activated or suspended`);
|
|
74
|
-
}
|
|
75
|
-
entry.state = 'deactivated';
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* 卸载 Plugin
|
|
79
|
-
*/
|
|
80
|
-
unload(pluginId) {
|
|
81
|
-
const entry = this.getEntry(pluginId);
|
|
82
|
-
if (!entry)
|
|
83
|
-
throw new Error(`Plugin "${pluginId}" not found`);
|
|
84
|
-
entry.state = 'unloaded';
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* 标记错误
|
|
88
|
-
*/
|
|
89
|
-
markError(pluginId, error) {
|
|
90
|
-
const entry = this.getOrCreate(pluginId);
|
|
91
|
-
entry.state = 'error';
|
|
92
|
-
entry.error = error;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* 获取 Plugin 状态
|
|
96
|
-
*/
|
|
97
|
-
getState(pluginId) {
|
|
98
|
-
return this.states.get(pluginId)?.state ?? 'unloaded';
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* 获取 Plugin 条目
|
|
102
|
-
*/
|
|
103
|
-
getEntry(pluginId) {
|
|
104
|
-
return this.states.get(pluginId);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* 获取所有 Plugin 状态
|
|
108
|
-
*/
|
|
109
|
-
listStates() {
|
|
110
|
-
return Array.from(this.states.values());
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* 检查 Plugin 是否激活
|
|
114
|
-
*/
|
|
115
|
-
isActivated(pluginId) {
|
|
116
|
-
return this.getState(pluginId) === 'activated';
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* 获取已激活的 Plugin ID 列表
|
|
120
|
-
*/
|
|
121
|
-
getActivatedIds() {
|
|
122
|
-
return this.listStates()
|
|
123
|
-
.filter(entry => entry.state === 'activated')
|
|
124
|
-
.map(entry => entry.id);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* 获取或创建条目
|
|
128
|
-
*/
|
|
129
|
-
getOrCreate(pluginId) {
|
|
130
|
-
if (!this.states.has(pluginId)) {
|
|
131
|
-
this.states.set(pluginId, {
|
|
132
|
-
id: pluginId,
|
|
133
|
-
state: 'discovered',
|
|
134
|
-
metadata: {},
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
return this.states.get(pluginId);
|
|
138
|
-
}
|
|
139
|
-
}
|