@octopi-agent/engine 0.97.15 → 0.102.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/config-schema/agent.d.ts +37 -5
- package/dist/config-schema/agent.js +24 -4
- package/dist/config-schema/context.d.ts +6 -36
- package/dist/config-schema/context.js +4 -28
- package/dist/config-schema/engine.d.ts +61 -160
- package/dist/config-schema/engine.js +1 -5
- package/dist/config-schema/governance.d.ts +10 -1
- package/dist/config-schema/governance.js +38 -1
- package/dist/config-schema/models.d.ts +2 -8
- package/dist/config-schema/models.js +0 -2
- package/dist/config-schema/run.d.ts +2 -2
- package/dist/config-schema/run.js +2 -2
- package/dist/config-schema/shared.d.ts +0 -3
- package/dist/config-schema/shared.js +0 -2
- package/dist/config-schema/substrate.d.ts +14 -88
- package/dist/config-schema/substrate.js +22 -107
- package/dist/config.d.ts +45 -113
- package/dist/config.js +8 -2
- package/dist/harness/activation/dispatcher.js +7 -0
- package/dist/harness/activation/inbox.d.ts +3 -3
- package/dist/harness/activation/inbox.js +3 -3
- package/dist/harness/activation/runtime.js +13 -5
- package/dist/harness/activation/types.d.ts +2 -2
- package/dist/harness/agent/builder.d.ts +34 -2
- package/dist/harness/agent/builder.js +189 -58
- package/dist/harness/agent/config-bridge.js +9 -2
- package/dist/harness/agent/config-integrity.d.ts +66 -0
- package/dist/harness/agent/config-integrity.js +108 -2
- package/dist/harness/agent/wire-agent-builder.d.ts +11 -3
- package/dist/harness/agent/wire-agent-builder.js +31 -7
- package/dist/harness/capabilities/document/factory.d.ts +5 -0
- package/dist/harness/capabilities/document/factory.js +1 -0
- 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/index.d.ts +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/index.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/loader.js +4 -1
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.d.ts +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.js +21 -4
- 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/completion-guard.d.ts +40 -0
- package/dist/harness/collaboration/autonomous-subsystem/think/completion-guard.js +59 -0
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/index.d.ts +2 -0
- package/dist/harness/collaboration/autonomous-subsystem/think/index.js +1 -0
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/types.d.ts +12 -3
- package/dist/harness/collaboration/delegation/child-run.d.ts +1 -1
- package/dist/harness/collaboration/delegation/child-run.js +4 -4
- 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/service.d.ts +2 -0
- package/dist/harness/collaboration/delegation/service.js +2 -1
- package/dist/harness/collaboration/delegation/store.d.ts +2 -0
- package/dist/harness/collaboration/delegation/store.js +2 -1
- package/dist/harness/collaboration/delegation/types.d.ts +23 -2
- package/dist/harness/collaboration/delegation/types.js +22 -0
- package/dist/harness/collaboration/delegation/wiring.js +11 -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 +0 -6
- package/dist/harness/context/capabilities/compact/engine.js +169 -121
- 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 +5 -1
- package/dist/harness/context/capabilities/compact/index.js +4 -0
- 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 +76 -11
- 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/port.js +0 -1
- package/dist/harness/context/capabilities/summary/resolver.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/resolver.js +4 -9
- package/dist/harness/context/capabilities/summary/tool-binding.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/types.d.ts +4 -7
- package/dist/harness/context/context-size-ledger.d.ts +143 -0
- package/dist/harness/context/context-size-ledger.js +236 -0
- package/dist/harness/context/default-context-engine.d.ts +195 -119
- package/dist/harness/context/default-context-engine.js +1241 -743
- package/dist/harness/context/index.d.ts +2 -2
- package/dist/harness/context/index.js +1 -1
- package/dist/harness/context/layer-types.d.ts +15 -0
- package/dist/harness/context/layer-types.js +14 -1
- package/dist/harness/context/layers.d.ts +16 -19
- package/dist/harness/context/layers.js +42 -14
- package/dist/harness/context/message-selector.d.ts +10 -8
- package/dist/harness/context/message-selector.js +49 -27
- package/dist/harness/context/summarize.d.ts +3 -3
- package/dist/harness/context/summarize.js +11 -4
- package/dist/harness/context/system-prompt-assembler.d.ts +4 -0
- package/dist/harness/context/system-prompt-assembler.js +3 -1
- 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 +6 -1
- package/dist/harness/context/tool-result-aging.js +16 -5
- 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 +127 -117
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +24 -2
- package/dist/harness/extension/execution-environment/effect-policy.js +30 -0
- package/dist/harness/extension/execution-environment/ops-audit.d.ts +7 -3
- package/dist/harness/extension/execution-environment/ops-audit.js +11 -12
- 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/undo-log.d.ts +6 -2
- package/dist/harness/extension/execution-environment/undo-log.js +31 -10
- package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +1 -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/plugins/api.d.ts +83 -249
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +88 -214
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.d.ts +43 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.js +61 -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 +50 -117
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +316 -285
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +23 -490
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +85 -353
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +41 -223
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +138 -19
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.d.ts +15 -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/builtin.js +17 -24
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +18 -8
- package/dist/harness/extension/plugin-ecosystem/tools/document-tools.js +3 -9
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +3 -6
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.js +9 -5
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +9 -130
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +122 -14
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +4 -13
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +25 -11
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +168 -62
- 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 +11 -2
- 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/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/security/capability-enforcer.js +1 -2
- package/dist/harness/governance/security/default-risk-policy.d.ts +1 -0
- package/dist/harness/governance/security/default-risk-policy.js +1 -0
- package/dist/harness/governance/security/default-security-guard.js +9 -0
- package/dist/harness/governance/security/index.d.ts +1 -0
- package/dist/harness/governance/security/index.js +2 -0
- package/dist/harness/governance/security/risk-evaluator.js +13 -0
- package/dist/harness/governance/security/risk-types.d.ts +12 -0
- package/dist/harness/governance/security/shell-parser-fallback.d.ts +29 -0
- package/dist/harness/governance/security/shell-parser-fallback.js +410 -0
- package/dist/harness/governance/security/shell-parser-shared.d.ts +83 -0
- package/dist/harness/governance/security/shell-parser-shared.js +188 -0
- package/dist/harness/governance/security/shell-parser-treesitter.d.ts +52 -0
- package/dist/harness/governance/security/shell-parser-treesitter.js +370 -0
- package/dist/harness/governance/security/shell-parser.d.ts +23 -10
- package/dist/harness/governance/security/shell-parser.js +37 -496
- package/dist/harness/governance/security/vendor/README.md +24 -0
- package/dist/harness/governance/security/vendor/tree-sitter-bash.LICENSE.txt +21 -0
- package/dist/harness/governance/security/vendor/tree-sitter-bash.wasm +0 -0
- package/dist/harness/index.d.ts +12 -12
- package/dist/harness/index.js +7 -7
- package/dist/harness/knowledge/boot-config.d.ts +55 -0
- package/dist/harness/knowledge/boot-config.js +50 -0
- package/dist/harness/knowledge/catalog-types.d.ts +2 -0
- package/dist/harness/knowledge/client.d.ts +24 -2
- package/dist/harness/knowledge/client.js +19 -5
- package/dist/harness/knowledge/db.js +5 -0
- 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 +6 -0
- package/dist/harness/knowledge/grounding.js +3 -1
- package/dist/harness/knowledge/http-app.js +35 -4
- 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 +3 -0
- package/dist/harness/knowledge/purge.js +5 -2
- package/dist/harness/knowledge/query-service.d.ts +13 -2
- package/dist/harness/knowledge/query-service.js +4 -2
- package/dist/harness/knowledge/query-worker-client.d.ts +9 -1
- package/dist/harness/knowledge/query-worker-client.js +4 -2
- package/dist/harness/knowledge/query-worker.js +4 -2
- package/dist/harness/knowledge/read-http.js +5 -1
- package/dist/harness/knowledge/serve.d.ts +8 -7
- package/dist/harness/knowledge/serve.js +9 -0
- package/dist/harness/knowledge/source-store.js +26 -3
- package/dist/harness/knowledge/start-service-process.d.ts +15 -7
- package/dist/harness/knowledge/start-service-process.js +21 -9
- package/dist/harness/knowledge/types.d.ts +7 -0
- package/dist/harness/knowledge/writer-service.d.ts +37 -9
- package/dist/harness/knowledge/writer-service.js +120 -14
- package/dist/harness/knowledge/writer-worker-client.d.ts +10 -9
- package/dist/harness/knowledge/writer-worker-client.js +20 -2
- package/dist/harness/knowledge/writer-worker.js +9 -1
- package/dist/harness/memory/index.d.ts +6 -2
- package/dist/harness/memory/index.js +4 -1
- package/dist/harness/memory/memory-events.d.ts +25 -0
- package/dist/harness/memory/memory-events.js +38 -0
- package/dist/harness/memory/sqlite/agent-db.js +15 -0
- package/dist/harness/memory/sqlite/wisdom-store.d.ts +7 -2
- package/dist/harness/memory/sqlite/wisdom-store.js +86 -12
- package/dist/harness/memory/steward-policy.d.ts +3 -0
- package/dist/harness/memory/steward-policy.js +1 -1
- package/dist/harness/memory/types.d.ts +47 -7
- package/dist/harness/memory/wisdom-attribution.d.ts +136 -0
- package/dist/harness/memory/wisdom-attribution.js +287 -0
- package/dist/harness/memory/wisdom-events.d.ts +37 -0
- package/dist/harness/memory/wisdom-events.js +61 -0
- package/dist/harness/memory/wisdom-formation.d.ts +31 -1
- package/dist/harness/memory/wisdom-formation.js +130 -33
- package/dist/harness/memory/wisdom-gates.d.ts +14 -0
- package/dist/harness/memory/wisdom-gates.js +59 -19
- package/dist/harness/memory/wisdom.d.ts +7 -2
- package/dist/harness/memory/wisdom.js +49 -2
- package/dist/harness/observability/observer/hub.js +25 -15
- 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 +66 -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/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 +10 -4
- package/dist/harness/run/reliability/run-agent.js +137 -53
- 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-scope.d.ts +41 -4
- package/dist/harness/run/runner.d.ts +71 -31
- package/dist/harness/run/runner.js +368 -106
- 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/transform-store.d.ts +136 -0
- package/dist/harness/session/transform-store.js +302 -0
- package/dist/harness/session/types.d.ts +2 -2
- package/dist/harness/shared/events/agent-event-map.d.ts +46 -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/paths/glob.d.ts +52 -0
- package/dist/harness/shared/paths/glob.js +218 -0
- package/dist/harness/shared/paths/index.d.ts +84 -0
- package/dist/harness/shared/paths/index.js +179 -0
- package/dist/harness/shared/types/agent-definition.d.ts +1 -2
- package/dist/index.d.ts +14 -17
- package/dist/index.js +7 -9
- 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.js +14 -1
- package/dist/integration/providers/openai.js +7 -1
- package/dist/integration/providers/usage.d.ts +1 -1
- package/dist/integration/providers/wire-dump.d.ts +1 -1
- package/dist/integration/storage/archive-manager.d.ts +6 -0
- package/dist/integration/storage/archive-manager.js +10 -0
- package/dist/integration/storage/jsonl.d.ts +1 -1
- package/dist/integration/storage/jsonl.js +18 -16
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +4 -2
- package/dist/subsystems/cognition-steward/conceptualize/handler.js +12 -20
- package/dist/subsystems/memory-steward/backfill/config.yaml +4 -2
- package/dist/subsystems/memory-steward/backfill/handler.js +44 -52
- package/dist/subsystems/wisdom-steward/attribute/SUBSYSTEM.md +24 -0
- package/dist/subsystems/wisdom-steward/attribute/config.yaml +60 -0
- package/dist/subsystems/wisdom-steward/attribute/handler.d.ts +23 -0
- package/dist/subsystems/wisdom-steward/attribute/handler.js +167 -0
- package/dist/subsystems/wisdom-steward/evaluate/handler.js +3 -1
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +8 -1
- package/dist/subsystems/wisdom-steward/formation/config.yaml +13 -5
- package/dist/subsystems/wisdom-steward/formation/handler.js +39 -23
- package/dist/subsystems/wisdom-steward/govern/config.yaml +1 -1
- package/dist/subsystems/wisdom-steward/govern/handler.js +4 -0
- package/package.json +16 -14
- 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,46 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Plugin API
|
|
9
|
-
*
|
|
10
|
-
* Plugin 在 register() 回调中使用此对象注册能力。
|
|
11
|
-
*/
|
|
1
|
+
/** Public author API. Runtime ownership lives in PluginContributionRegistry. */
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { TOOL_CAPABILITIES } from '@octopi-agent/core/types.js';
|
|
4
|
+
import { createStaging, readStaging } from './staging.js';
|
|
5
|
+
import { normalizeCommandName } from '../commands/parse.js';
|
|
6
|
+
import { COMMAND_INVOKERS } from '../commands/types.js';
|
|
12
7
|
export class PluginApi {
|
|
13
|
-
/** Plugin ID */
|
|
14
8
|
id;
|
|
15
|
-
/** Plugin 显示名称 */
|
|
16
9
|
name;
|
|
17
|
-
/** Plugin 版本 */
|
|
18
10
|
version;
|
|
19
|
-
/** Plugin 描述 */
|
|
20
11
|
description;
|
|
21
|
-
/** Plugin 源路径 */
|
|
22
12
|
source;
|
|
23
|
-
/** Plugin root 目录 */
|
|
24
13
|
rootDir;
|
|
25
|
-
/** Plugin 配置 */
|
|
26
14
|
pluginConfig;
|
|
27
|
-
/** Plugin Logger */
|
|
28
15
|
logger;
|
|
29
|
-
// ── 内部存储(PluginManager 读取) ──
|
|
30
|
-
/** 已注册的 providers */
|
|
31
|
-
_providers = [];
|
|
32
|
-
/** 已注册的 channels */
|
|
33
|
-
_channels = [];
|
|
34
|
-
/** 已注册的 tools */
|
|
35
|
-
_tools = [];
|
|
36
|
-
/** 已注册的 context engines */
|
|
37
|
-
_contextEngines = [];
|
|
38
|
-
/** 已注册的 hooks */
|
|
39
|
-
_hooks = new Map();
|
|
40
|
-
/** 已注册的 commands */
|
|
41
|
-
_commands = [];
|
|
42
|
-
/** 已注册的服务 */
|
|
43
|
-
_services = [];
|
|
44
16
|
constructor(opts) {
|
|
45
17
|
this.id = opts.id;
|
|
46
18
|
this.name = opts.name;
|
|
@@ -48,218 +20,120 @@ export class PluginApi {
|
|
|
48
20
|
this.description = opts.description;
|
|
49
21
|
this.source = opts.source;
|
|
50
22
|
this.rootDir = opts.rootDir;
|
|
51
|
-
this.pluginConfig = opts.pluginConfig
|
|
23
|
+
this.pluginConfig = opts.pluginConfig;
|
|
24
|
+
createStaging(this);
|
|
52
25
|
const prefix = `[plugin:${opts.id}]`;
|
|
53
26
|
this.logger = {
|
|
54
|
-
debug: (
|
|
55
|
-
info: (
|
|
56
|
-
warn: (
|
|
57
|
-
error: (
|
|
27
|
+
debug: (message, ...args) => console.debug(`${prefix} ${message}`, ...args),
|
|
28
|
+
info: (message, ...args) => console.info(`${prefix} ${message}`, ...args),
|
|
29
|
+
warn: (message, ...args) => console.warn(`${prefix} ${message}`, ...args),
|
|
30
|
+
error: (message, ...args) => console.error(`${prefix} ${message}`, ...args),
|
|
58
31
|
};
|
|
59
32
|
}
|
|
60
|
-
// ================================================================
|
|
61
|
-
// Capability Registration
|
|
62
|
-
// ================================================================
|
|
63
33
|
/**
|
|
64
|
-
*
|
|
34
|
+
* Stage a Tool contribution. It is not mounted or exposed by this call.
|
|
65
35
|
*
|
|
66
|
-
* @param
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this._providers.push(registration);
|
|
70
|
-
this.logger.info(`Registered provider: ${registration.id}`);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* 注册 Channel Adapter
|
|
74
|
-
*
|
|
75
|
-
* @param registration - Channel 注册定义
|
|
76
|
-
*/
|
|
77
|
-
registerChannel(registration) {
|
|
78
|
-
this._channels.push(registration);
|
|
79
|
-
this.logger.info(`Registered channel: ${registration.id}`);
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* 注册 Agent Tool
|
|
83
|
-
*
|
|
84
|
-
* Tool 名称不能与核心 tool 冲突。
|
|
85
|
-
*
|
|
86
|
-
* @param tool - Tool 定义(包含 name、description、parameters)
|
|
87
|
-
* @param handler - Tool 处理函数
|
|
88
|
-
* @param opts - 注册选项
|
|
36
|
+
* @param tool - Core ToolDefinition
|
|
37
|
+
* @param handler - Core ToolHandler
|
|
38
|
+
* @param opts - Execution and optional contribution metadata
|
|
89
39
|
*/
|
|
90
40
|
registerTool(tool, handler, opts) {
|
|
91
|
-
|
|
41
|
+
if (!tool.capabilities || tool.capabilities.length === 0) {
|
|
42
|
+
throw new Error(`Plugin tool "${tool.name}" must declare non-empty capabilities`);
|
|
43
|
+
}
|
|
44
|
+
if (new Set(tool.capabilities).size !== tool.capabilities.length ||
|
|
45
|
+
tool.capabilities.some((capability) => !TOOL_CAPABILITIES.includes(capability))) {
|
|
46
|
+
throw new Error(`Plugin tool "${tool.name}" has unknown or duplicate capabilities`);
|
|
47
|
+
}
|
|
48
|
+
if (readStaging(this).tools.some((entry) => entry.definition.name === tool.name)) {
|
|
49
|
+
throw new Error(`Plugin "${this.id}" registered duplicate tool "${tool.name}"`);
|
|
50
|
+
}
|
|
51
|
+
const executionMode = opts?.executionMode ??
|
|
52
|
+
(tool.capabilities.includes('fs-write') ? 'sequential' : undefined);
|
|
53
|
+
readStaging(this).tools.push({
|
|
92
54
|
definition: tool,
|
|
93
|
-
handler
|
|
55
|
+
handler,
|
|
94
56
|
optional: opts?.optional ?? false,
|
|
57
|
+
...(executionMode === undefined ? {} : { executionMode }),
|
|
95
58
|
});
|
|
96
|
-
this.logger.info(`Registered tool: ${tool.name}${opts?.optional ? ' (optional)' : ''}`);
|
|
97
59
|
}
|
|
98
60
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* Context Engine 是 exclusive slot —— 同一时刻只有一个 active。
|
|
61
|
+
* Stage a typed hook contribution using one of the 22 existing event names.
|
|
102
62
|
*
|
|
103
|
-
* @param
|
|
104
|
-
* @param
|
|
105
|
-
|
|
106
|
-
registerContextEngine(id, engine) {
|
|
107
|
-
this._contextEngines.push({ id, engine });
|
|
108
|
-
this.logger.info(`Registered context engine: ${id}`);
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* 注册 Hook
|
|
112
|
-
*
|
|
113
|
-
* Hook handler 按 priority 降序执行,同 priority 按注册顺序。
|
|
114
|
-
*
|
|
115
|
-
* @param hookName - Hook 名称
|
|
116
|
-
* @param handler - Hook handler
|
|
117
|
-
* @param opts - 选项(priority、timeoutMs)
|
|
63
|
+
* @param hookName - Existing hook name
|
|
64
|
+
* @param handler - Event-specific handler
|
|
65
|
+
* @param opts - Ordering and cooperative timeout options
|
|
118
66
|
*/
|
|
119
67
|
on(hookName, handler, opts) {
|
|
120
|
-
|
|
121
|
-
|
|
68
|
+
const dualPhase = hookName === 'before_tool_call' || hookName === 'before_iteration';
|
|
69
|
+
if (dualPhase !== (opts?.phase !== undefined)) {
|
|
70
|
+
throw new Error(`Plugin "${this.id}" must ${dualPhase ? 'declare' : 'omit'} phase for hook "${hookName}"`);
|
|
71
|
+
}
|
|
72
|
+
if (opts?.priority !== undefined && !Number.isFinite(opts.priority)) {
|
|
73
|
+
throw new Error(`Plugin "${this.id}" registered invalid hook priority`);
|
|
122
74
|
}
|
|
123
|
-
|
|
124
|
-
|
|
75
|
+
if (opts?.timeoutMs !== undefined && (!Number.isFinite(opts.timeoutMs) || opts.timeoutMs <= 0)) {
|
|
76
|
+
throw new Error(`Plugin "${this.id}" registered invalid hook timeout`);
|
|
77
|
+
}
|
|
78
|
+
const entry = {
|
|
125
79
|
pluginId: this.id,
|
|
126
80
|
hookName,
|
|
127
81
|
handler: handler,
|
|
82
|
+
phase: opts?.phase ?? 'single',
|
|
128
83
|
priority: opts?.priority ?? 0,
|
|
129
|
-
timeoutMs: opts
|
|
130
|
-
}
|
|
131
|
-
|
|
84
|
+
...(opts?.timeoutMs === undefined ? {} : { timeoutMs: opts.timeoutMs }),
|
|
85
|
+
};
|
|
86
|
+
const entries = [...(readStaging(this).hooks.get(hookName) ?? []), entry];
|
|
132
87
|
entries.sort((a, b) => b.priority - a.priority);
|
|
88
|
+
readStaging(this).hooks.set(hookName, entries);
|
|
133
89
|
}
|
|
134
|
-
/**
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
* Command 绕过 LLM,直接执行。
|
|
138
|
-
*
|
|
139
|
-
* @param def - Command 定义
|
|
140
|
-
*/
|
|
141
|
-
registerCommand(def) {
|
|
142
|
-
this._commands.push(def);
|
|
143
|
-
this.logger.info(`Registered command: ${def.name}`);
|
|
90
|
+
/** Register a parameter Transform or admission Vote for before_tool_call. */
|
|
91
|
+
onBeforeToolCall(phase, handler, opts) {
|
|
92
|
+
this.on('before_tool_call', handler, { ...opts, phase });
|
|
144
93
|
}
|
|
145
|
-
/**
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
* 服务在 Gateway 启动时 start,关闭时 stop。
|
|
149
|
-
*
|
|
150
|
-
* @param service - 服务定义
|
|
151
|
-
*/
|
|
152
|
-
registerService(service) {
|
|
153
|
-
this._services.push(service);
|
|
154
|
-
this.logger.info(`Registered service: ${service.id}`);
|
|
94
|
+
/** Register a controlled Iteration Transform or admission Vote. */
|
|
95
|
+
onBeforeIteration(phase, handler, opts) {
|
|
96
|
+
this.on('before_iteration', handler, { ...opts, phase });
|
|
155
97
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
/** 已注册的 music generation providers */
|
|
166
|
-
_musicGenerationProviders = [];
|
|
167
|
-
/** 已注册的 video generation providers */
|
|
168
|
-
_videoGenerationProviders = [];
|
|
169
|
-
/** 已注册的 speech providers */
|
|
170
|
-
_speechProviders = [];
|
|
171
|
-
/** 已注册的 model catalog providers */
|
|
172
|
-
_modelCatalogProviders = [];
|
|
173
|
-
/** 已注册的 memory embedding providers */
|
|
174
|
-
_memoryEmbeddingProviders = [];
|
|
175
|
-
/**
|
|
176
|
-
* 注册 Web Search Provider
|
|
177
|
-
*
|
|
178
|
-
* @param provider - 实现 WebSearchProvider 契约的实例
|
|
179
|
-
*/
|
|
180
|
-
registerWebSearchProvider(provider) {
|
|
181
|
-
const id = provider.id || this.getProviderId(provider);
|
|
182
|
-
this._webSearchProviders.push({ id, provider });
|
|
183
|
-
this.logger.info(`Registered web search provider: ${id}`);
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* 注册 Media Understanding Provider
|
|
187
|
-
*/
|
|
188
|
-
registerMediaUnderstandingProvider(provider) {
|
|
189
|
-
const id = this.getProviderId(provider);
|
|
190
|
-
this._mediaUnderstandingProviders.push({ id, provider });
|
|
191
|
-
this.logger.info(`Registered media understanding provider: ${id}`);
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* 注册 Image Generation Provider
|
|
195
|
-
*/
|
|
196
|
-
registerImageGenerationProvider(provider) {
|
|
197
|
-
const id = this.getProviderId(provider);
|
|
198
|
-
this._imageGenerationProviders.push({ id, provider });
|
|
199
|
-
this.logger.info(`Registered image generation provider: ${id}`);
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* 注册 Music Generation Provider
|
|
203
|
-
*/
|
|
204
|
-
registerMusicGenerationProvider(provider) {
|
|
205
|
-
const id = this.getProviderId(provider);
|
|
206
|
-
this._musicGenerationProviders.push({ id, provider });
|
|
207
|
-
this.logger.info(`Registered music generation provider: ${id}`);
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* 注册 Video Generation Provider
|
|
211
|
-
*/
|
|
212
|
-
registerVideoGenerationProvider(provider) {
|
|
213
|
-
const id = this.getProviderId(provider);
|
|
214
|
-
this._videoGenerationProviders.push({ id, provider });
|
|
215
|
-
this.logger.info(`Registered video generation provider: ${id}`);
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* 注册 Speech Provider
|
|
219
|
-
*/
|
|
220
|
-
registerSpeechProvider(provider) {
|
|
221
|
-
const id = this.getProviderId(provider);
|
|
222
|
-
this._speechProviders.push({ id, provider });
|
|
223
|
-
this.logger.info(`Registered speech provider: ${id}`);
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* 注册 Model Catalog Provider
|
|
227
|
-
*/
|
|
228
|
-
registerModelCatalogProvider(catalog) {
|
|
229
|
-
this._modelCatalogProviders.push(catalog);
|
|
230
|
-
this.logger.info(`Registered model catalog: ${catalog.provider} (${catalog.kinds.join(', ')})`);
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* 注册 Memory Embedding Provider
|
|
234
|
-
*/
|
|
235
|
-
registerMemoryEmbeddingProvider(provider) {
|
|
236
|
-
const id = this.getProviderId(provider);
|
|
237
|
-
this._memoryEmbeddingProviders.push({ id, provider });
|
|
238
|
-
this.logger.info(`Registered memory embedding provider: ${id}`);
|
|
98
|
+
/** Stage a Host-owned background service; start/stop is driven by Gateway. */
|
|
99
|
+
registerService(registration) {
|
|
100
|
+
if (!registration.serviceId.trim() || readStaging(this).services.some((item) => item.serviceId === registration.serviceId)) {
|
|
101
|
+
throw new Error(`Plugin "${this.id}" registered an empty or duplicate service id`);
|
|
102
|
+
}
|
|
103
|
+
if (registration.timeoutMs !== undefined && (!Number.isFinite(registration.timeoutMs) || registration.timeoutMs <= 0)) {
|
|
104
|
+
throw new Error(`Plugin "${this.id}" registered an invalid service timeout`);
|
|
105
|
+
}
|
|
106
|
+
readStaging(this).services.push({ ...registration });
|
|
239
107
|
}
|
|
240
|
-
// ================================================================
|
|
241
|
-
// Utility
|
|
242
|
-
// ================================================================
|
|
243
108
|
/**
|
|
244
|
-
*
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
109
|
+
* Stage a Command contribution. Host authorization is enforced when mounted.
|
|
110
|
+
*
|
|
111
|
+
* @param definition - Command metadata and handler
|
|
112
|
+
*/
|
|
113
|
+
registerCommand(definition) {
|
|
114
|
+
const name = normalizeCommandName(definition.name);
|
|
115
|
+
if (!name)
|
|
116
|
+
throw new Error(`Plugin "${this.id}" registered invalid command name`);
|
|
117
|
+
if (definition.kind !== undefined && definition.kind !== 'control' && definition.kind !== 'prompt') {
|
|
118
|
+
throw new Error(`Plugin "${this.id}" registered unsupported kind for command "${name}"`);
|
|
119
|
+
}
|
|
120
|
+
if (definition.invocableBy && (definition.invocableBy.length === 0 ||
|
|
121
|
+
new Set(definition.invocableBy).size !== definition.invocableBy.length ||
|
|
122
|
+
definition.invocableBy.some((invoker) => !COMMAND_INVOKERS.includes(invoker)))) {
|
|
123
|
+
throw new Error(`Plugin "${this.id}" registered invalid invocableBy for command "${name}"`);
|
|
124
|
+
}
|
|
125
|
+
if (readStaging(this).commands.some((entry) => entry.name === name)) {
|
|
126
|
+
throw new Error(`Plugin "${this.id}" registered duplicate command "${definition.name}"`);
|
|
250
127
|
}
|
|
251
|
-
|
|
128
|
+
readStaging(this).commands.push({ ...definition, name });
|
|
252
129
|
}
|
|
253
130
|
/**
|
|
254
|
-
*
|
|
131
|
+
* Resolve a path relative to the plugin root in ESM.
|
|
255
132
|
*
|
|
256
|
-
* @param input -
|
|
257
|
-
* @returns
|
|
133
|
+
* @param input - Relative or absolute path
|
|
134
|
+
* @returns Absolute path; not a filesystem security boundary
|
|
258
135
|
*/
|
|
259
136
|
resolvePath(input) {
|
|
260
|
-
|
|
261
|
-
return input;
|
|
262
|
-
const path = require('node:path');
|
|
263
|
-
return path.resolve(this.rootDir, input);
|
|
137
|
+
return resolve(this.rootDir, input);
|
|
264
138
|
}
|
|
265
139
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Host-level effective contribution registry; per-Agent buses are mount projections. */
|
|
2
|
+
import type { PluginManifest } from './manifest.js';
|
|
3
|
+
import type { HookServiceRegistration } from '../hooks/types.js';
|
|
4
|
+
export interface PluginServiceRecord extends HookServiceRegistration {
|
|
5
|
+
pluginId: string;
|
|
6
|
+
}
|
|
7
|
+
import type { PluginApi } from './api.js';
|
|
8
|
+
import type { PluginCommandRegistration, PluginToolContribution, OrderedHookEntry } from './api.js';
|
|
9
|
+
export interface RegisteredPlugin {
|
|
10
|
+
manifest: PluginManifest;
|
|
11
|
+
definition: {
|
|
12
|
+
id: string;
|
|
13
|
+
register(api: PluginApi): void | Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
api: PluginApi;
|
|
16
|
+
path: string;
|
|
17
|
+
}
|
|
18
|
+
export interface PluginToolRecord extends PluginToolContribution {
|
|
19
|
+
pluginId: string;
|
|
20
|
+
}
|
|
21
|
+
export interface PluginCommandRecord extends PluginCommandRegistration {
|
|
22
|
+
pluginId: string;
|
|
23
|
+
}
|
|
24
|
+
/** An immutable published contribution set. Mutations are staged by PluginLoader. */
|
|
25
|
+
export declare class PluginContributionRegistry {
|
|
26
|
+
private plugins;
|
|
27
|
+
private tools;
|
|
28
|
+
private commands;
|
|
29
|
+
private hooks;
|
|
30
|
+
private services;
|
|
31
|
+
private owners;
|
|
32
|
+
/** Replace the effective set only after all staged registrations validate. */
|
|
33
|
+
publish(plugins: readonly RegisteredPlugin[]): void;
|
|
34
|
+
/** Clear the effective set before a fresh discovery attempt. */
|
|
35
|
+
clear(): void;
|
|
36
|
+
private addOwner;
|
|
37
|
+
getPlugins(): RegisteredPlugin[];
|
|
38
|
+
getPlugin(id: string): RegisteredPlugin | undefined;
|
|
39
|
+
getTools(): PluginToolRecord[];
|
|
40
|
+
getCommands(): PluginCommandRecord[];
|
|
41
|
+
getHooks(): OrderedHookEntry[];
|
|
42
|
+
getServices(): PluginServiceRecord[];
|
|
43
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** Host-level effective contribution registry; per-Agent buses are mount projections. */
|
|
2
|
+
import { readStaging } from './staging.js';
|
|
3
|
+
/** An immutable published contribution set. Mutations are staged by PluginLoader. */
|
|
4
|
+
export class PluginContributionRegistry {
|
|
5
|
+
plugins = new Map();
|
|
6
|
+
tools = [];
|
|
7
|
+
commands = [];
|
|
8
|
+
hooks = [];
|
|
9
|
+
services = [];
|
|
10
|
+
owners = new Map();
|
|
11
|
+
/** Replace the effective set only after all staged registrations validate. */
|
|
12
|
+
publish(plugins) {
|
|
13
|
+
const next = new PluginContributionRegistry();
|
|
14
|
+
for (const plugin of plugins) {
|
|
15
|
+
next.plugins.set(plugin.manifest.id, plugin);
|
|
16
|
+
const staged = readStaging(plugin.api);
|
|
17
|
+
for (const tool of staged.tools) {
|
|
18
|
+
next.addOwner('tool', tool.definition.name, plugin.manifest.id);
|
|
19
|
+
next.tools.push({ pluginId: plugin.manifest.id, ...tool });
|
|
20
|
+
}
|
|
21
|
+
for (const command of staged.commands) {
|
|
22
|
+
next.addOwner('command', command.name, plugin.manifest.id);
|
|
23
|
+
next.commands.push({ pluginId: plugin.manifest.id, ...command });
|
|
24
|
+
}
|
|
25
|
+
for (const entries of staged.hooks.values())
|
|
26
|
+
next.hooks.push(...entries);
|
|
27
|
+
for (const service of staged.services) {
|
|
28
|
+
next.addOwner('service', service.serviceId, plugin.manifest.id);
|
|
29
|
+
next.services.push({ pluginId: plugin.manifest.id, ...service });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const replyOwners = next.hooks.filter((entry) => entry.hookName === 'before_agent_reply');
|
|
33
|
+
if (replyOwners.length > 1) {
|
|
34
|
+
throw new Error(`Override hook before_agent_reply has multiple owners: ${replyOwners.map((entry) => entry.pluginId).join(', ')}`);
|
|
35
|
+
}
|
|
36
|
+
this.plugins = next.plugins;
|
|
37
|
+
this.tools = next.tools;
|
|
38
|
+
this.commands = next.commands;
|
|
39
|
+
this.hooks = next.hooks;
|
|
40
|
+
this.services = next.services;
|
|
41
|
+
this.owners = next.owners;
|
|
42
|
+
}
|
|
43
|
+
/** Clear the effective set before a fresh discovery attempt. */
|
|
44
|
+
clear() {
|
|
45
|
+
this.publish([]);
|
|
46
|
+
}
|
|
47
|
+
addOwner(type, id, pluginId) {
|
|
48
|
+
const key = `${type}:${id}`;
|
|
49
|
+
const owner = this.owners.get(key);
|
|
50
|
+
if (owner !== undefined) {
|
|
51
|
+
throw new Error(`Contribution conflict ${key}: "${owner}" and "${pluginId}"`);
|
|
52
|
+
}
|
|
53
|
+
this.owners.set(key, pluginId);
|
|
54
|
+
}
|
|
55
|
+
getPlugins() { return [...this.plugins.values()]; }
|
|
56
|
+
getPlugin(id) { return this.plugins.get(id); }
|
|
57
|
+
getTools() { return [...this.tools]; }
|
|
58
|
+
getCommands() { return [...this.commands]; }
|
|
59
|
+
getHooks() { return [...this.hooks]; }
|
|
60
|
+
getServices() { return [...this.services]; }
|
|
61
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Read the installed engine package version through its public package export. */
|
|
2
|
+
export declare function getEngineVersion(): string;
|
|
3
|
+
/** Return whether the installed engine satisfies a manifest's semver range. */
|
|
4
|
+
export declare function satisfiesEngineRange(version: string, range: string): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import semver from 'semver';
|
|
3
|
+
let cachedVersion;
|
|
4
|
+
/** Read the installed engine package version through its public package export. */
|
|
5
|
+
export function getEngineVersion() {
|
|
6
|
+
if (cachedVersion === undefined) {
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const metadata = require('@octopi-agent/engine/package.json');
|
|
9
|
+
cachedVersion = metadata.version;
|
|
10
|
+
}
|
|
11
|
+
return cachedVersion;
|
|
12
|
+
}
|
|
13
|
+
/** Return whether the installed engine satisfies a manifest's semver range. */
|
|
14
|
+
export function satisfiesEngineRange(version, range) {
|
|
15
|
+
if (!semver.valid(version) || !semver.validRange(range))
|
|
16
|
+
return false;
|
|
17
|
+
return semver.satisfies(version, range);
|
|
18
|
+
}
|
|
@@ -1,93 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin Entry
|
|
3
|
-
*
|
|
4
|
-
* definePluginEntry 是创建 plugin 的标准方式。
|
|
5
|
-
* 它定义了 plugin 的 id、name、register 回调等。
|
|
6
|
-
*/
|
|
1
|
+
/** Plugin entry contract. Installation metadata lives in octopi.plugin.json. */
|
|
7
2
|
import type { PluginApi } from './api.js';
|
|
8
|
-
/**
|
|
9
|
-
* Plugin 定义
|
|
10
|
-
*
|
|
11
|
-
* 这是 plugin 的完整定义。每个 plugin 必须导出一个 default export,
|
|
12
|
-
* 使用 definePluginEntry() 创建。
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* export default definePluginEntry({
|
|
17
|
-
* id: 'my-plugin',
|
|
18
|
-
* name: 'My Plugin',
|
|
19
|
-
* description: 'Adds custom capabilities',
|
|
20
|
-
* register(api) {
|
|
21
|
-
* api.on('before_tool_call', async (event) => {
|
|
22
|
-
* // hook logic
|
|
23
|
-
* });
|
|
24
|
-
*
|
|
25
|
-
* api.registerTool(
|
|
26
|
-
* { name: 'my_tool', description: '...', parameters: {} },
|
|
27
|
-
* async (args, ctx) => { return 'result'; },
|
|
28
|
-
* );
|
|
29
|
-
* },
|
|
30
|
-
* });
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
3
|
export interface OctopiPluginDefinition {
|
|
34
|
-
/**
|
|
4
|
+
/** Must match the manifest identity. */
|
|
35
5
|
id: string;
|
|
36
|
-
/**
|
|
37
|
-
name: string;
|
|
38
|
-
/** Plugin 描述 */
|
|
39
|
-
description?: string;
|
|
40
|
-
/** Plugin 版本 */
|
|
41
|
-
version?: string;
|
|
42
|
-
/**
|
|
43
|
-
* 注册回调
|
|
44
|
-
*
|
|
45
|
-
* 框架在加载 plugin 时调用此方法,传入 PluginApi 对象。
|
|
46
|
-
* Plugin 通过 api 对象注册各种能力。
|
|
47
|
-
*
|
|
48
|
-
* @param api - Plugin API 对象
|
|
49
|
-
*/
|
|
6
|
+
/** Declaration-only registration; external resources start at a host lifecycle point. */
|
|
50
7
|
register(api: PluginApi): void | Promise<void>;
|
|
51
8
|
}
|
|
52
9
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* 这是创建 plugin 的标准方式。
|
|
56
|
-
*
|
|
57
|
-
* @param definition - Plugin 定义
|
|
58
|
-
* @returns Plugin 定义对象
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```ts
|
|
62
|
-
* // index.ts
|
|
63
|
-
* import { definePluginEntry } from '@octopi-agent/engine/plugin-sdk/plugin-entry';
|
|
64
|
-
*
|
|
65
|
-
* export default definePluginEntry({
|
|
66
|
-
* id: 'tool-preflight',
|
|
67
|
-
* name: 'Tool Preflight',
|
|
68
|
-
* register(api) {
|
|
69
|
-
* api.on('before_tool_call', async (event) => {
|
|
70
|
-
* if (event.toolName !== 'web_search') return;
|
|
71
|
-
* return { requireApproval: { title: 'Run web search' } };
|
|
72
|
-
* }, { priority: 50 });
|
|
73
|
-
* },
|
|
74
|
-
* });
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
export declare function definePluginEntry(definition: OctopiPluginDefinition): OctopiPluginDefinition;
|
|
78
|
-
/**
|
|
79
|
-
* Channel Plugin 定义
|
|
80
|
-
*
|
|
81
|
-
* 用于 channel 类型的 plugin。
|
|
82
|
-
*/
|
|
83
|
-
export interface OctopiChannelPluginDefinition extends OctopiPluginDefinition {
|
|
84
|
-
/** Channel ID */
|
|
85
|
-
channelId: string;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* 定义一个 Channel Plugin Entry
|
|
10
|
+
* Define a v1 plugin entry without duplicating its manifest.
|
|
89
11
|
*
|
|
90
|
-
* @param definition -
|
|
91
|
-
* @returns
|
|
12
|
+
* @param definition - Entry identity and registration function
|
|
13
|
+
* @returns The validated definition
|
|
92
14
|
*/
|
|
93
|
-
export declare function
|
|
15
|
+
export declare function definePlugin(definition: OctopiPluginDefinition): OctopiPluginDefinition;
|
|
@@ -1,58 +1,16 @@
|
|
|
1
|
+
/** Plugin entry contract. Installation metadata lives in octopi.plugin.json. */
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Define a v1 plugin entry without duplicating its manifest.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* @param definition - Entry identity and registration function
|
|
6
|
+
* @returns The validated definition
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* 这是创建 plugin 的标准方式。
|
|
11
|
-
*
|
|
12
|
-
* @param definition - Plugin 定义
|
|
13
|
-
* @returns Plugin 定义对象
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* // index.ts
|
|
18
|
-
* import { definePluginEntry } from '@octopi-agent/engine/plugin-sdk/plugin-entry';
|
|
19
|
-
*
|
|
20
|
-
* export default definePluginEntry({
|
|
21
|
-
* id: 'tool-preflight',
|
|
22
|
-
* name: 'Tool Preflight',
|
|
23
|
-
* register(api) {
|
|
24
|
-
* api.on('before_tool_call', async (event) => {
|
|
25
|
-
* if (event.toolName !== 'web_search') return;
|
|
26
|
-
* return { requireApproval: { title: 'Run web search' } };
|
|
27
|
-
* }, { priority: 50 });
|
|
28
|
-
* },
|
|
29
|
-
* });
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export function definePluginEntry(definition) {
|
|
33
|
-
// 验证必填字段
|
|
34
|
-
if (!definition.id || typeof definition.id !== 'string') {
|
|
35
|
-
throw new Error('definePluginEntry: "id" is required and must be a string');
|
|
36
|
-
}
|
|
37
|
-
if (!definition.name || typeof definition.name !== 'string') {
|
|
38
|
-
throw new Error('definePluginEntry: "name" is required and must be a string');
|
|
8
|
+
export function definePlugin(definition) {
|
|
9
|
+
if (typeof definition.id !== 'string' || definition.id.length === 0) {
|
|
10
|
+
throw new Error('definePlugin: "id" is required and must be a string');
|
|
39
11
|
}
|
|
40
12
|
if (typeof definition.register !== 'function') {
|
|
41
|
-
throw new Error(`
|
|
42
|
-
}
|
|
43
|
-
return definition;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* 定义一个 Channel Plugin Entry
|
|
47
|
-
*
|
|
48
|
-
* @param definition - Channel Plugin 定义
|
|
49
|
-
* @returns Plugin 定义对象
|
|
50
|
-
*/
|
|
51
|
-
export function defineChannelPluginEntry(definition) {
|
|
52
|
-
if (!definition.channelId) {
|
|
53
|
-
throw new Error(`defineChannelPluginEntry: "channelId" is required (plugin: ${definition.id})`);
|
|
13
|
+
throw new Error(`definePlugin: "register" must be a function (plugin: ${definition.id})`);
|
|
54
14
|
}
|
|
55
|
-
// 基础验证
|
|
56
|
-
definePluginEntry(definition);
|
|
57
15
|
return definition;
|
|
58
16
|
}
|