@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,14 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Manifest 是 plugin 的声明式元数据,框架在不执行 plugin 代码的情况下
|
|
5
|
-
* 就能读取和验证。这是 plugin 系统的基础。
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* JSON Schema 基础类型(简化版)
|
|
2
|
+
* Installation-time plugin declaration. This module must remain safe to use
|
|
3
|
+
* before importing plugin code.
|
|
9
4
|
*/
|
|
5
|
+
export declare const PLUGIN_API_VERSION: "1";
|
|
10
6
|
export interface JsonSchema {
|
|
11
|
-
type?: string;
|
|
7
|
+
type?: 'object' | 'array' | 'string' | 'number' | 'integer' | 'boolean' | 'null';
|
|
12
8
|
properties?: Record<string, JsonSchema>;
|
|
13
9
|
required?: string[];
|
|
14
10
|
additionalProperties?: boolean | JsonSchema;
|
|
@@ -25,234 +21,56 @@ export interface JsonSchema {
|
|
|
25
21
|
anyOf?: JsonSchema[];
|
|
26
22
|
allOf?: JsonSchema[];
|
|
27
23
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
export declare const PLUGIN_HOOK_NAMES: readonly ["before_model_resolve", "agent_turn_prepare", "before_prompt_build", "before_agent_run", "before_agent_reply", "before_agent_finalize", "agent_end", "before_tool_call", "after_tool_call", "message_received", "message_sending", "message_sent", "session_start", "session_end", "before_compaction", "after_compaction", "gateway_start", "gateway_stop", "before_install", "before_iteration", "after_iteration", "loop_end"];
|
|
25
|
+
export type PluginHookName = (typeof PLUGIN_HOOK_NAMES)[number];
|
|
26
|
+
export declare const PLUGIN_SESSION_OP_NAMES: readonly ["abort_run", "new_session", "set_model", "compact", "set_preferred_agent"];
|
|
27
|
+
export type PluginSessionOpName = (typeof PLUGIN_SESSION_OP_NAMES)[number];
|
|
28
|
+
export interface PluginCommandContribution {
|
|
29
|
+
name: string;
|
|
30
|
+
sessionOps?: PluginSessionOpName[];
|
|
31
|
+
}
|
|
32
|
+
export interface PluginContributions {
|
|
33
|
+
tools?: string[];
|
|
34
|
+
commands?: PluginCommandContribution[];
|
|
35
|
+
hooks?: PluginHookName[];
|
|
36
|
+
/** Stable service ids; required/timeout are trusted Host execution policy. */
|
|
37
|
+
services?: string[];
|
|
38
|
+
}
|
|
33
39
|
export interface PluginManifest {
|
|
34
|
-
/** Plugin 唯一 ID(必填) */
|
|
35
40
|
id: string;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
apiVersion: typeof PLUGIN_API_VERSION;
|
|
42
|
+
version: string;
|
|
43
|
+
name: string;
|
|
39
44
|
description?: string;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
entry: string;
|
|
46
|
+
enabledByDefault?: boolean;
|
|
47
|
+
engine: {
|
|
48
|
+
octopi: string;
|
|
49
|
+
};
|
|
43
50
|
configSchema: JsonSchema;
|
|
44
|
-
|
|
45
|
-
providers?: string[];
|
|
46
|
-
/** 此 plugin 拥有的 channel IDs */
|
|
47
|
-
channels?: string[];
|
|
48
|
-
/** 此 plugin 拥有的 CLI backend IDs */
|
|
49
|
-
cliBackends?: string[];
|
|
50
|
-
/** 此 plugin 拥有的能力声明 */
|
|
51
|
-
contracts?: PluginContracts;
|
|
52
|
-
/** 激活规划元数据(控制何时加载 plugin) */
|
|
53
|
-
activation?: ActivationConfig;
|
|
54
|
-
/** Setup/onboarding 元数据 */
|
|
55
|
-
setup?: SetupConfig;
|
|
56
|
-
/** Skill 目录列表(相对于 plugin root) */
|
|
57
|
-
skills?: string[];
|
|
58
|
-
/** 依赖的其他 plugin IDs */
|
|
51
|
+
contributes?: PluginContributions;
|
|
59
52
|
requiresPlugins?: string[];
|
|
60
|
-
/** 是否默认启用 */
|
|
61
|
-
enabledByDefault?: boolean;
|
|
62
|
-
/** 仅在指定平台默认启用 */
|
|
63
|
-
enabledByDefaultOnPlatforms?: string[];
|
|
64
|
-
/** 旧版 plugin IDs(兼容迁移) */
|
|
65
53
|
legacyPluginIds?: string[];
|
|
66
|
-
/** 配置了指定 provider 时自动启用 */
|
|
67
|
-
autoEnableWhenConfiguredProviders?: string[];
|
|
68
|
-
/** exclusive slot 类型(如 "memory"、"context-engine") */
|
|
69
|
-
kind?: 'memory' | 'context-engine';
|
|
70
|
-
/** 模型前缀匹配(自动识别 provider) */
|
|
71
|
-
modelSupport?: {
|
|
72
|
-
modelPrefixes?: string[];
|
|
73
|
-
modelPatterns?: string[];
|
|
74
|
-
};
|
|
75
|
-
/** Provider 目录元数据 */
|
|
76
|
-
modelCatalog?: Record<string, unknown>;
|
|
77
|
-
/** UI 提示信息 */
|
|
78
|
-
uiHints?: Record<string, UiHint>;
|
|
79
|
-
/** Tool 可用性元数据 */
|
|
80
|
-
toolMetadata?: Record<string, ToolAvailabilityMetadata>;
|
|
81
|
-
/** Channel 配置元数据 */
|
|
82
|
-
channelConfigs?: Record<string, ChannelConfigMetadata>;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* 能力声明(contracts)
|
|
86
|
-
*
|
|
87
|
-
* 声明此 plugin 拥有的各种能力。
|
|
88
|
-
* 用于不加载 plugin 代码就能知道谁拥有什么能力。
|
|
89
|
-
*/
|
|
90
|
-
export interface PluginContracts {
|
|
91
|
-
/** Agent tool 名称列表 */
|
|
92
|
-
tools?: string[];
|
|
93
|
-
/** Embedding provider IDs */
|
|
94
|
-
embeddingProviders?: string[];
|
|
95
|
-
/** Speech provider IDs */
|
|
96
|
-
speechProviders?: string[];
|
|
97
|
-
/** Realtime transcription provider IDs */
|
|
98
|
-
realtimeTranscriptionProviders?: string[];
|
|
99
|
-
/** Realtime voice provider IDs */
|
|
100
|
-
realtimeVoiceProviders?: string[];
|
|
101
|
-
/** Media understanding provider IDs */
|
|
102
|
-
mediaUnderstandingProviders?: string[];
|
|
103
|
-
/** Image generation provider IDs */
|
|
104
|
-
imageGenerationProviders?: string[];
|
|
105
|
-
/** Video generation provider IDs */
|
|
106
|
-
videoGenerationProviders?: string[];
|
|
107
|
-
/** Music generation provider IDs */
|
|
108
|
-
musicGenerationProviders?: string[];
|
|
109
|
-
/** Web fetch provider IDs */
|
|
110
|
-
webFetchProviders?: string[];
|
|
111
|
-
/** Web search provider IDs */
|
|
112
|
-
webSearchProviders?: string[];
|
|
113
|
-
/** External auth provider IDs */
|
|
114
|
-
externalAuthProviders?: string[];
|
|
115
|
-
/** Gateway method dispatch 授权 */
|
|
116
|
-
gatewayMethodDispatch?: string[];
|
|
117
54
|
}
|
|
118
55
|
/**
|
|
119
|
-
*
|
|
56
|
+
* Validate a declaration without importing the plugin entry.
|
|
120
57
|
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
58
|
+
* @param raw - Parsed manifest JSON
|
|
59
|
+
* @returns Strictly validated v1 manifest
|
|
123
60
|
*/
|
|
124
|
-
export
|
|
125
|
-
/** Gateway 启动时加载 */
|
|
126
|
-
onStartup?: boolean;
|
|
127
|
-
/** 匹配指定 provider 时加载 */
|
|
128
|
-
onProviders?: string[];
|
|
129
|
-
/** 匹配指定 command 时加载 */
|
|
130
|
-
onCommands?: string[];
|
|
131
|
-
/** 匹配指定 channel 时加载 */
|
|
132
|
-
onChannels?: string[];
|
|
133
|
-
/** 匹配指定 route 时加载 */
|
|
134
|
-
onRoutes?: string[];
|
|
135
|
-
/** 匹配指定 config path 时加载 */
|
|
136
|
-
onConfigPaths?: string[];
|
|
137
|
-
/** 匹配指定能力类型时加载 */
|
|
138
|
-
onCapabilities?: Array<'provider' | 'channel' | 'tool' | 'hook'>;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Setup 配置
|
|
142
|
-
*
|
|
143
|
-
* 用于 onboarding 和初始设置流程。
|
|
144
|
-
*/
|
|
145
|
-
export interface SetupConfig {
|
|
146
|
-
/** Provider setup 描述 */
|
|
147
|
-
providers?: SetupProviderDescriptor[];
|
|
148
|
-
/** CLI backend IDs */
|
|
149
|
-
cliBackends?: string[];
|
|
150
|
-
/** 是否需要运行时执行(false = 只用描述符) */
|
|
151
|
-
requiresRuntime?: boolean;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Provider setup 描述符
|
|
155
|
-
*/
|
|
156
|
-
export interface SetupProviderDescriptor {
|
|
157
|
-
/** Provider ID */
|
|
158
|
-
id: string;
|
|
159
|
-
/** 支持的认证方式 */
|
|
160
|
-
authMethods?: string[];
|
|
161
|
-
/** 环境变量列表 */
|
|
162
|
-
envVars?: string[];
|
|
163
|
-
/** 认证证据(本地文件/环境变量检查) */
|
|
164
|
-
authEvidence?: AuthEvidence[];
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* 认证证据
|
|
168
|
-
*/
|
|
169
|
-
export interface AuthEvidence {
|
|
170
|
-
/** 证据类型 */
|
|
171
|
-
type: 'local-file-with-env';
|
|
172
|
-
/** 包含凭证文件路径的环境变量 */
|
|
173
|
-
fileEnvVar?: string;
|
|
174
|
-
/** 备选文件路径 */
|
|
175
|
-
fallbackPaths?: string[];
|
|
176
|
-
/** 必须存在的环境变量(至少一个) */
|
|
177
|
-
requiresAnyEnv?: string[];
|
|
178
|
-
/** 必须存在的环境变量(全部) */
|
|
179
|
-
requiresAllEnv?: string[];
|
|
180
|
-
/** 非密钥标记 */
|
|
181
|
-
credentialMarker: string;
|
|
182
|
-
/** 来源标签 */
|
|
183
|
-
source?: string;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* UI 提示
|
|
187
|
-
*/
|
|
188
|
-
export interface UiHint {
|
|
189
|
-
/** 字段标签 */
|
|
190
|
-
label?: string;
|
|
191
|
-
/** 帮助文本 */
|
|
192
|
-
help?: string;
|
|
193
|
-
/** 占位符 */
|
|
194
|
-
placeholder?: string;
|
|
195
|
-
/** 是否敏感(密码等) */
|
|
196
|
-
sensitive?: boolean;
|
|
197
|
-
/** 是否为高级选项 */
|
|
198
|
-
advanced?: boolean;
|
|
199
|
-
/** 标签 */
|
|
200
|
-
tags?: string[];
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Tool 可用性元数据
|
|
204
|
-
*
|
|
205
|
-
* 用于在不加载 plugin 代码的情况下判断 tool 是否可用。
|
|
206
|
-
*/
|
|
207
|
-
export interface ToolAvailabilityMetadata {
|
|
208
|
-
/** 认证信号 */
|
|
209
|
-
authSignals?: Array<{
|
|
210
|
-
provider: string;
|
|
211
|
-
providerBaseUrl?: {
|
|
212
|
-
provider: string;
|
|
213
|
-
defaultBaseUrl?: string;
|
|
214
|
-
allowedBaseUrls?: string[];
|
|
215
|
-
};
|
|
216
|
-
}>;
|
|
217
|
-
/** 配置信号 */
|
|
218
|
-
configSignals?: Array<{
|
|
219
|
-
rootPath: string;
|
|
220
|
-
overlayPath?: string;
|
|
221
|
-
required?: string[];
|
|
222
|
-
requiredAny?: string[];
|
|
223
|
-
mode?: {
|
|
224
|
-
path?: string;
|
|
225
|
-
default?: string;
|
|
226
|
-
allowed?: string[];
|
|
227
|
-
disallowed?: string[];
|
|
228
|
-
};
|
|
229
|
-
}>;
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Channel 配置元数据
|
|
233
|
-
*/
|
|
234
|
-
export interface ChannelConfigMetadata {
|
|
235
|
-
/** Channel config JSON Schema */
|
|
236
|
-
schema?: JsonSchema;
|
|
237
|
-
/** UI 提示 */
|
|
238
|
-
uiHints?: Record<string, UiHint>;
|
|
239
|
-
/** Channel 标签 */
|
|
240
|
-
label?: string;
|
|
241
|
-
/** Channel 描述 */
|
|
242
|
-
description?: string;
|
|
243
|
-
}
|
|
61
|
+
export declare function validateManifest(raw: unknown): PluginManifest;
|
|
244
62
|
/**
|
|
245
|
-
*
|
|
63
|
+
* Parse and validate an octopi.plugin.json document.
|
|
246
64
|
*
|
|
247
|
-
* @param
|
|
248
|
-
* @returns
|
|
249
|
-
* @throws 验证失败时抛出错误
|
|
65
|
+
* @param json - Manifest JSON text
|
|
66
|
+
* @returns Strictly validated v1 manifest
|
|
250
67
|
*/
|
|
251
|
-
export declare function
|
|
68
|
+
export declare function parseManifest(json: string): PluginManifest;
|
|
252
69
|
/**
|
|
253
|
-
*
|
|
70
|
+
* Validate plugin business config before importing the plugin module.
|
|
254
71
|
*
|
|
255
|
-
* @param
|
|
256
|
-
* @
|
|
72
|
+
* @param manifest - Validated manifest
|
|
73
|
+
* @param config - Plugin-local business config
|
|
74
|
+
* @returns A cloned config, including schema defaults applied by Ajv
|
|
257
75
|
*/
|
|
258
|
-
export declare function
|
|
76
|
+
export declare function validatePluginConfig(manifest: PluginManifest, config: Record<string, unknown> | undefined): Record<string, unknown>;
|
|
@@ -1,34 +1,126 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Manifest 是 plugin 的声明式元数据,框架在不执行 plugin 代码的情况下
|
|
5
|
-
* 就能读取和验证。这是 plugin 系统的基础。
|
|
2
|
+
* Installation-time plugin declaration. This module must remain safe to use
|
|
3
|
+
* before importing plugin code.
|
|
6
4
|
*/
|
|
5
|
+
import Ajv from 'ajv';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export const PLUGIN_API_VERSION = '1';
|
|
8
|
+
const jsonSchemaSchema = z.lazy(() => z
|
|
9
|
+
.object({
|
|
10
|
+
type: z.enum(['object', 'array', 'string', 'number', 'integer', 'boolean', 'null']).optional(),
|
|
11
|
+
properties: z.record(z.string(), jsonSchemaSchema).optional(),
|
|
12
|
+
required: z.array(z.string().min(1)).optional(),
|
|
13
|
+
additionalProperties: z.union([z.boolean(), jsonSchemaSchema]).optional(),
|
|
14
|
+
items: jsonSchemaSchema.optional(),
|
|
15
|
+
enum: z.array(z.unknown()).min(1).optional(),
|
|
16
|
+
default: z.unknown().optional(),
|
|
17
|
+
description: z.string().optional(),
|
|
18
|
+
minimum: z.number().optional(),
|
|
19
|
+
maximum: z.number().optional(),
|
|
20
|
+
minLength: z.number().int().nonnegative().optional(),
|
|
21
|
+
maxLength: z.number().int().nonnegative().optional(),
|
|
22
|
+
pattern: z.string().optional(),
|
|
23
|
+
oneOf: z.array(jsonSchemaSchema).min(1).optional(),
|
|
24
|
+
anyOf: z.array(jsonSchemaSchema).min(1).optional(),
|
|
25
|
+
allOf: z.array(jsonSchemaSchema).min(1).optional(),
|
|
26
|
+
})
|
|
27
|
+
.strict());
|
|
28
|
+
export const PLUGIN_HOOK_NAMES = [
|
|
29
|
+
'before_model_resolve',
|
|
30
|
+
'agent_turn_prepare',
|
|
31
|
+
'before_prompt_build',
|
|
32
|
+
'before_agent_run',
|
|
33
|
+
'before_agent_reply',
|
|
34
|
+
'before_agent_finalize',
|
|
35
|
+
'agent_end',
|
|
36
|
+
'before_tool_call',
|
|
37
|
+
'after_tool_call',
|
|
38
|
+
'message_received',
|
|
39
|
+
'message_sending',
|
|
40
|
+
'message_sent',
|
|
41
|
+
'session_start',
|
|
42
|
+
'session_end',
|
|
43
|
+
'before_compaction',
|
|
44
|
+
'after_compaction',
|
|
45
|
+
'gateway_start',
|
|
46
|
+
'gateway_stop',
|
|
47
|
+
'before_install',
|
|
48
|
+
'before_iteration',
|
|
49
|
+
'after_iteration',
|
|
50
|
+
'loop_end',
|
|
51
|
+
];
|
|
52
|
+
export const PLUGIN_SESSION_OP_NAMES = ['abort_run', 'new_session', 'set_model', 'compact', 'set_preferred_agent'];
|
|
53
|
+
const contributionName = z.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]*$/, 'must be a stable capability name');
|
|
54
|
+
const pluginId = z.string().regex(/^[a-z0-9][a-z0-9._-]*$/, 'must be a lowercase stable plugin id');
|
|
55
|
+
const manifestSchema = z
|
|
56
|
+
.object({
|
|
57
|
+
id: pluginId,
|
|
58
|
+
apiVersion: z.literal(PLUGIN_API_VERSION),
|
|
59
|
+
version: z.string().min(1),
|
|
60
|
+
name: z.string().min(1),
|
|
61
|
+
description: z.string().optional(),
|
|
62
|
+
entry: z.string().min(1),
|
|
63
|
+
enabledByDefault: z.boolean().optional(),
|
|
64
|
+
engine: z.object({ octopi: z.string().min(1) }).strict(),
|
|
65
|
+
configSchema: jsonSchemaSchema,
|
|
66
|
+
contributes: z
|
|
67
|
+
.object({
|
|
68
|
+
tools: z.array(contributionName).optional(),
|
|
69
|
+
commands: z
|
|
70
|
+
.array(z
|
|
71
|
+
.object({
|
|
72
|
+
name: contributionName,
|
|
73
|
+
sessionOps: z.array(z.enum(PLUGIN_SESSION_OP_NAMES)).optional(),
|
|
74
|
+
})
|
|
75
|
+
.strict())
|
|
76
|
+
.optional(),
|
|
77
|
+
hooks: z.array(z.enum(PLUGIN_HOOK_NAMES)).optional(),
|
|
78
|
+
services: z.array(contributionName).optional(),
|
|
79
|
+
})
|
|
80
|
+
.strict()
|
|
81
|
+
.optional(),
|
|
82
|
+
requiresPlugins: z.array(pluginId).optional(),
|
|
83
|
+
legacyPluginIds: z.array(pluginId).optional(),
|
|
84
|
+
})
|
|
85
|
+
.strict();
|
|
7
86
|
/**
|
|
8
|
-
*
|
|
87
|
+
* Validate a declaration without importing the plugin entry.
|
|
9
88
|
*
|
|
10
|
-
* @param raw -
|
|
11
|
-
* @returns
|
|
12
|
-
* @throws 验证失败时抛出错误
|
|
89
|
+
* @param raw - Parsed manifest JSON
|
|
90
|
+
* @returns Strictly validated v1 manifest
|
|
13
91
|
*/
|
|
14
92
|
export function validateManifest(raw) {
|
|
15
|
-
|
|
16
|
-
|
|
93
|
+
const result = manifestSchema.safeParse(raw);
|
|
94
|
+
if (!result.success) {
|
|
95
|
+
throw new Error(`Invalid plugin manifest: ${z.prettifyError(result.error)}`);
|
|
96
|
+
}
|
|
97
|
+
const manifest = result.data;
|
|
98
|
+
assertUnique(manifest.requiresPlugins ?? [], 'requiresPlugins');
|
|
99
|
+
assertUnique(manifest.legacyPluginIds ?? [], 'legacyPluginIds');
|
|
100
|
+
if (manifest.legacyPluginIds?.includes(manifest.id)) {
|
|
101
|
+
throw new Error(`Plugin "${manifest.id}" cannot list itself in legacyPluginIds`);
|
|
17
102
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
103
|
+
assertUnique(manifest.contributes?.tools ?? [], 'contributes.tools');
|
|
104
|
+
assertUnique(manifest.contributes?.hooks ?? [], 'contributes.hooks');
|
|
105
|
+
assertUnique(manifest.contributes?.services ?? [], 'contributes.services');
|
|
106
|
+
const commands = manifest.contributes?.commands ?? [];
|
|
107
|
+
assertUnique(commands.map((command) => command.name), 'contributes.commands');
|
|
108
|
+
for (const command of commands) {
|
|
109
|
+
assertUnique(command.sessionOps ?? [], `contributes.commands.${command.name}.sessionOps`);
|
|
21
110
|
}
|
|
22
|
-
|
|
23
|
-
|
|
111
|
+
createConfigValidator(manifest.configSchema);
|
|
112
|
+
return manifest;
|
|
113
|
+
}
|
|
114
|
+
function assertUnique(values, field) {
|
|
115
|
+
if (new Set(values).size !== values.length) {
|
|
116
|
+
throw new Error(`Plugin manifest ${field} contains duplicate entries`);
|
|
24
117
|
}
|
|
25
|
-
return m;
|
|
26
118
|
}
|
|
27
119
|
/**
|
|
28
|
-
*
|
|
120
|
+
* Parse and validate an octopi.plugin.json document.
|
|
29
121
|
*
|
|
30
|
-
* @param json - JSON
|
|
31
|
-
* @returns
|
|
122
|
+
* @param json - Manifest JSON text
|
|
123
|
+
* @returns Strictly validated v1 manifest
|
|
32
124
|
*/
|
|
33
125
|
export function parseManifest(json) {
|
|
34
126
|
let raw;
|
|
@@ -40,3 +132,30 @@ export function parseManifest(json) {
|
|
|
40
132
|
}
|
|
41
133
|
return validateManifest(raw);
|
|
42
134
|
}
|
|
135
|
+
function createConfigValidator(schema) {
|
|
136
|
+
const ajv = new Ajv({ allErrors: true, strict: true, allowUnionTypes: false, useDefaults: true });
|
|
137
|
+
return ajv.compile(schema);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Validate plugin business config before importing the plugin module.
|
|
141
|
+
*
|
|
142
|
+
* @param manifest - Validated manifest
|
|
143
|
+
* @param config - Plugin-local business config
|
|
144
|
+
* @returns A cloned config, including schema defaults applied by Ajv
|
|
145
|
+
*/
|
|
146
|
+
export function validatePluginConfig(manifest, config) {
|
|
147
|
+
const validate = createConfigValidator(manifest.configSchema);
|
|
148
|
+
const value = config === undefined ? {} : structuredClone(config);
|
|
149
|
+
if (!validate(value)) {
|
|
150
|
+
const details = (validate.errors ?? []).map(formatConfigError).join('; ');
|
|
151
|
+
throw new Error(`Plugin "${manifest.id}" config validation failed: ${details}`);
|
|
152
|
+
}
|
|
153
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
154
|
+
throw new Error(`Plugin "${manifest.id}" config must be an object`);
|
|
155
|
+
}
|
|
156
|
+
return value;
|
|
157
|
+
}
|
|
158
|
+
function formatConfigError(error) {
|
|
159
|
+
const path = error.instancePath || '/';
|
|
160
|
+
return `${path} ${error.message ?? 'is invalid'}`;
|
|
161
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Host-private staging storage. Not exported through the author SDK. */
|
|
2
|
+
import type { PluginApi } from './api.js';
|
|
3
|
+
import type { OrderedHookEntry, PluginCommandRegistration, PluginToolContribution } from './api.js';
|
|
4
|
+
import type { PluginHookName } from './manifest.js';
|
|
5
|
+
import type { HookServiceRegistration } from '../hooks/types.js';
|
|
6
|
+
export interface StagedContributions {
|
|
7
|
+
tools: PluginToolContribution[];
|
|
8
|
+
commands: PluginCommandRegistration[];
|
|
9
|
+
hooks: Map<PluginHookName, OrderedHookEntry[]>;
|
|
10
|
+
services: HookServiceRegistration[];
|
|
11
|
+
}
|
|
12
|
+
/** Called only by the host when constructing an author API. */
|
|
13
|
+
export declare function createStaging(api: PluginApi): StagedContributions;
|
|
14
|
+
/** Read the host-owned staging snapshot while validating or publishing a plugin. */
|
|
15
|
+
export declare function readStaging(api: PluginApi): StagedContributions;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Host-private staging storage. Not exported through the author SDK. */
|
|
2
|
+
const staged = new WeakMap();
|
|
3
|
+
/** Called only by the host when constructing an author API. */
|
|
4
|
+
export function createStaging(api) {
|
|
5
|
+
const value = { tools: [], commands: [], hooks: new Map(), services: [] };
|
|
6
|
+
staged.set(api, value);
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
/** Read the host-owned staging snapshot while validating or publishing a plugin. */
|
|
10
|
+
export function readStaging(api) {
|
|
11
|
+
const value = staged.get(api);
|
|
12
|
+
if (!value)
|
|
13
|
+
throw new Error('PluginApi was not created by the host loader');
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
@@ -76,10 +76,15 @@ export declare class FileSystemSkillSource implements SkillSource {
|
|
|
76
76
|
export declare class DefaultSkillManager implements SkillManager {
|
|
77
77
|
private skills;
|
|
78
78
|
private source;
|
|
79
|
+
/** Skill id allowlist(`agents[].skills`);undefined = 全部启用 */
|
|
80
|
+
private readonly only?;
|
|
79
81
|
/**
|
|
80
82
|
* @param sourceOrDirectory - SkillSource 实例或目录路径(向后兼容)
|
|
83
|
+
* @param options.only - 启用的 Skill id allowlist(缺省全部);discover 未列入的 Skill 不进索引、load 恒 null
|
|
81
84
|
*/
|
|
82
|
-
constructor(sourceOrDirectory?: SkillSource | string
|
|
85
|
+
constructor(sourceOrDirectory?: SkillSource | string, options?: {
|
|
86
|
+
only?: string[];
|
|
87
|
+
});
|
|
83
88
|
/**
|
|
84
89
|
* 扫描目录发现所有 Skill(只读元数据)
|
|
85
90
|
*
|
|
@@ -104,16 +104,20 @@ export class FileSystemSkillSource {
|
|
|
104
104
|
export class DefaultSkillManager {
|
|
105
105
|
skills = new Map();
|
|
106
106
|
source;
|
|
107
|
+
/** Skill id allowlist(`agents[].skills`);undefined = 全部启用 */
|
|
108
|
+
only;
|
|
107
109
|
/**
|
|
108
110
|
* @param sourceOrDirectory - SkillSource 实例或目录路径(向后兼容)
|
|
111
|
+
* @param options.only - 启用的 Skill id allowlist(缺省全部);discover 未列入的 Skill 不进索引、load 恒 null
|
|
109
112
|
*/
|
|
110
|
-
constructor(sourceOrDirectory) {
|
|
113
|
+
constructor(sourceOrDirectory, options) {
|
|
111
114
|
if (typeof sourceOrDirectory === 'string') {
|
|
112
115
|
this.source = new FileSystemSkillSource(sourceOrDirectory);
|
|
113
116
|
}
|
|
114
117
|
else {
|
|
115
118
|
this.source = sourceOrDirectory ?? new FileSystemSkillSource('./skills');
|
|
116
119
|
}
|
|
120
|
+
this.only = options?.only ? new Set(options.only) : undefined;
|
|
117
121
|
}
|
|
118
122
|
/**
|
|
119
123
|
* 扫描目录发现所有 Skill(只读元数据)
|
|
@@ -130,7 +134,11 @@ export class DefaultSkillManager {
|
|
|
130
134
|
this.source = new FileSystemSkillSource(directory);
|
|
131
135
|
}
|
|
132
136
|
const discovered = await this.source.discover();
|
|
137
|
+
const discoveredIds = new Set(discovered.map((d) => d.id));
|
|
133
138
|
for (const item of discovered) {
|
|
139
|
+
// agents[].skills allowlist:未列入的 Skill 不进索引(load 经 skills map 天然拒绝)
|
|
140
|
+
if (this.only && !this.only.has(item.id))
|
|
141
|
+
continue;
|
|
134
142
|
const skill = {
|
|
135
143
|
id: item.id,
|
|
136
144
|
name: item.meta.name,
|
|
@@ -143,6 +151,14 @@ export class DefaultSkillManager {
|
|
|
143
151
|
};
|
|
144
152
|
this.skills.set(skill.id, skill);
|
|
145
153
|
}
|
|
154
|
+
// allowlist 中未命中的 id(拼写错 / Skill 目录未落地)——fail-loud,防「静默全关」
|
|
155
|
+
if (this.only) {
|
|
156
|
+
for (const id of this.only) {
|
|
157
|
+
if (!discoveredIds.has(id)) {
|
|
158
|
+
console.warn(`[Skills] agents[].skills id "${id}" not found in skill directory (typo, or not landed yet)`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
146
162
|
}
|
|
147
163
|
/**
|
|
148
164
|
* 格式化所有 Skill 描述为 system prompt 片段
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
* 无超时(2026-10-26 拍板):需要用户确认的问题不能被时间自动跳过。
|
|
8
8
|
* 退出只有两路:会话中止(abortSignal)或 Gateway 取消(ASK_USER_CANCELLED 哨兵)。
|
|
9
9
|
* definition 不声明 timeoutMs,工具总线(runWithToolLimits)因此不设看门狗。
|
|
10
|
+
*
|
|
11
|
+
* 等待时长经 context.noteHumanWait 回传预算层(2026-11-01):等人不计入
|
|
12
|
+
* wall-clock,用户多久之后回答都不会触发「运行时间达到预算上限」误杀。
|
|
10
13
|
*/
|
|
11
14
|
import type { RegisteredTool } from '@octopi-agent/core/types.js';
|
|
12
15
|
/** askUser 回调上下文(绑定到具体会话) */
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
* 无超时(2026-10-26 拍板):需要用户确认的问题不能被时间自动跳过。
|
|
8
8
|
* 退出只有两路:会话中止(abortSignal)或 Gateway 取消(ASK_USER_CANCELLED 哨兵)。
|
|
9
9
|
* definition 不声明 timeoutMs,工具总线(runWithToolLimits)因此不设看门狗。
|
|
10
|
+
*
|
|
11
|
+
* 等待时长经 context.noteHumanWait 回传预算层(2026-11-01):等人不计入
|
|
12
|
+
* wall-clock,用户多久之后回答都不会触发「运行时间达到预算上限」误杀。
|
|
10
13
|
*/
|
|
11
14
|
/** Gateway cancel 哨兵(与 gateway.ASK_USER_CANCELLED 同值,避免 harness→integration 依赖) */
|
|
12
15
|
export const ASK_USER_CANCELLED = '__ask_user_cancelled__';
|
|
@@ -51,29 +54,51 @@ export function createAskUserTool(callback) {
|
|
|
51
54
|
return { answer: null, error: 'aborted before asking user' };
|
|
52
55
|
}
|
|
53
56
|
const abortSignal = context?.abortSignal;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
if (abortSignal) {
|
|
63
|
-
abortSignal.addEventListener('abort', onAbort, { once: true });
|
|
64
|
-
if (abortSignal.aborted) {
|
|
65
|
-
onAbort();
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
57
|
+
// 等人时长回传预算层(方案A):等人不计入 wall-clock。abort(run 已终止)
|
|
58
|
+
// 不回传;回调自身失败时 run 会继续执行,等待真实发生,照常回传。回传是
|
|
59
|
+
// 旁路记账:它抛错不得吞掉已到手的用户答案。
|
|
60
|
+
const waitStartedAt = Date.now();
|
|
61
|
+
const reportHumanWait = () => {
|
|
62
|
+
try {
|
|
63
|
+
context?.noteHumanWait?.(Date.now() - waitStartedAt);
|
|
68
64
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
catch {
|
|
66
|
+
// 只吞记账通道的抛错:预算回传失败不应改变工具结果(无其他路径可抛)
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
let answer;
|
|
70
|
+
try {
|
|
71
|
+
answer = await new Promise((resolve, reject) => {
|
|
72
|
+
const cleanup = () => {
|
|
73
|
+
abortSignal?.removeEventListener('abort', onAbort);
|
|
74
|
+
};
|
|
75
|
+
const onAbort = () => {
|
|
76
|
+
cleanup();
|
|
77
|
+
reject(new Error('ask_user aborted'));
|
|
78
|
+
};
|
|
79
|
+
if (abortSignal) {
|
|
80
|
+
abortSignal.addEventListener('abort', onAbort, { once: true });
|
|
81
|
+
if (abortSignal.aborted) {
|
|
82
|
+
onAbort();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
callback(question, options, ctx).then((value) => {
|
|
87
|
+
cleanup();
|
|
88
|
+
resolve(value);
|
|
89
|
+
}, (err) => {
|
|
90
|
+
cleanup();
|
|
91
|
+
reject(err instanceof Error ? err : new Error(String(err)));
|
|
92
|
+
});
|
|
75
93
|
});
|
|
76
|
-
}
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
if (!abortSignal?.aborted) {
|
|
97
|
+
reportHumanWait();
|
|
98
|
+
}
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
reportHumanWait();
|
|
77
102
|
if (answer === ASK_USER_CANCELLED) {
|
|
78
103
|
return { answer: null, error: 'aborted while waiting for user' };
|
|
79
104
|
}
|