@octopi-agent/engine 0.65.0 → 0.86.38
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/LICENSE +201 -201
- package/NOTICE +7 -7
- package/README.md +64 -26
- package/dist/config-schema/agent.d.ts +89 -1
- package/dist/config-schema/agent.js +69 -0
- package/dist/config-schema/context.d.ts +23 -4
- package/dist/config-schema/context.js +28 -1
- package/dist/config-schema/engine.d.ts +285 -9
- package/dist/config-schema/engine.js +35 -3
- package/dist/config-schema/governance.d.ts +95 -0
- package/dist/config-schema/governance.js +91 -0
- package/dist/config-schema/models.d.ts +1 -1
- package/dist/config-schema/observability.d.ts +6 -0
- package/dist/config-schema/observability.js +16 -0
- package/dist/config-schema/run.d.ts +10 -0
- package/dist/config-schema/run.js +18 -0
- package/dist/config-schema/shared.d.ts +10 -0
- package/dist/config-schema/shared.js +10 -0
- package/dist/config-schema/substrate.d.ts +87 -1
- package/dist/config-schema/substrate.js +114 -0
- package/dist/config-schema/subsystems.d.ts +1 -1
- package/dist/config-schema/subsystems.js +2 -1
- package/dist/config.d.ts +249 -7
- package/dist/config.js +113 -3
- package/dist/harness/activation/compiler.js +3 -0
- package/dist/harness/activation/runtime.d.ts +7 -0
- package/dist/harness/activation/runtime.js +60 -2
- package/dist/harness/activation/sources/agent-signal.d.ts +11 -0
- package/dist/harness/activation/sources/agent-signal.js +33 -0
- package/dist/harness/activation/types.d.ts +6 -1
- package/dist/harness/agent/builder.d.ts +48 -4
- package/dist/harness/agent/builder.js +206 -55
- package/dist/harness/agent/config-bridge.d.ts +33 -25
- package/dist/harness/agent/config-bridge.js +83 -280
- package/dist/harness/agent/index.d.ts +3 -1
- package/dist/harness/agent/index.js +2 -1
- package/dist/harness/agent/tool-purpose.d.ts +38 -0
- package/dist/harness/agent/tool-purpose.js +118 -0
- package/dist/harness/agent/wire-agent-builder.d.ts +133 -0
- package/dist/harness/agent/wire-agent-builder.js +363 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +4 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +14 -8
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +12 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +19 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.d.ts +6 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.js +24 -7
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.d.ts +5 -2
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +11 -3
- package/dist/harness/collaboration/autonomous-subsystem/think/index.d.ts +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/index.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.d.ts +7 -4
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.js +8 -9
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.d.ts +36 -10
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.js +60 -7
- package/dist/harness/collaboration/delegation/child-run.d.ts +144 -0
- package/dist/harness/collaboration/delegation/child-run.js +241 -0
- package/dist/harness/collaboration/delegation/index.d.ts +26 -0
- package/dist/harness/collaboration/delegation/index.js +25 -0
- package/dist/harness/collaboration/delegation/notifier.d.ts +46 -0
- package/dist/harness/collaboration/delegation/notifier.js +84 -0
- package/dist/harness/collaboration/delegation/registry-types.d.ts +200 -0
- package/dist/harness/collaboration/delegation/registry-types.js +61 -0
- package/dist/harness/collaboration/delegation/registry.d.ts +110 -0
- package/dist/harness/collaboration/delegation/registry.js +220 -0
- package/dist/harness/collaboration/delegation/service.d.ts +249 -0
- package/dist/harness/collaboration/delegation/service.js +499 -0
- package/dist/harness/collaboration/delegation/store.d.ts +155 -0
- package/dist/harness/collaboration/delegation/store.js +271 -0
- package/dist/harness/collaboration/delegation/transport.d.ts +73 -0
- package/dist/harness/collaboration/delegation/transport.js +61 -0
- package/dist/harness/collaboration/delegation/types.d.ts +231 -0
- package/dist/harness/collaboration/delegation/types.js +70 -0
- package/dist/harness/collaboration/delegation/wiring.d.ts +111 -0
- package/dist/harness/collaboration/delegation/wiring.js +145 -0
- package/dist/harness/collaboration/orchestration/index.d.ts +11 -13
- package/dist/harness/collaboration/orchestration/index.js +11 -11
- package/dist/harness/context/assembler.d.ts +2 -2
- package/dist/harness/context/assembler.js +12 -7
- package/dist/harness/context/capabilities/compact/engine.js +80 -38
- package/dist/harness/context/capabilities/compact/types.d.ts +12 -1
- package/dist/harness/context/capabilities/summary/gate.js +2 -2
- package/dist/harness/context/capabilities/summary/policies.js +5 -5
- package/dist/harness/context/capabilities/summary/registry.js +39 -24
- package/dist/harness/context/constitution/default-agents.md +230 -228
- package/dist/harness/context/default-context-engine.d.ts +101 -23
- package/dist/harness/context/default-context-engine.js +483 -172
- package/dist/harness/context/hybrid-compressor.d.ts +3 -3
- package/dist/harness/context/hybrid-compressor.js +18 -23
- package/dist/harness/context/index.d.ts +5 -1
- package/dist/harness/context/index.js +2 -0
- package/dist/harness/context/layer-health.js +3 -2
- package/dist/harness/context/layer-snapshot.d.ts +4 -0
- package/dist/harness/context/layer-snapshot.js +30 -18
- package/dist/harness/context/layer-types.d.ts +49 -1
- package/dist/harness/context/layer-types.js +72 -4
- package/dist/harness/context/layers.d.ts +32 -15
- package/dist/harness/context/layers.js +87 -71
- package/dist/harness/context/llm-summarizer.d.ts +15 -1
- package/dist/harness/context/llm-summarizer.js +107 -56
- package/dist/harness/context/message-selector.js +6 -2
- package/dist/harness/context/root-instructions.d.ts +72 -0
- package/dist/harness/context/root-instructions.js +227 -0
- package/dist/harness/context/runtime-datetime.d.ts +34 -7
- package/dist/harness/context/runtime-datetime.js +66 -10
- package/dist/harness/context/smart-router.d.ts +1 -1
- package/dist/harness/context/smart-router.js +1 -1
- package/dist/harness/context/system-prompt-assembler.d.ts +33 -0
- package/dist/harness/context/system-prompt-assembler.js +78 -7
- package/dist/harness/context/token-constants.d.ts +2 -2
- package/dist/harness/context/token-constants.js +2 -2
- package/dist/harness/context/token-estimate-fns.d.ts +1 -3
- package/dist/harness/context/token-estimate-fns.js +2 -4
- package/dist/harness/context/token-estimator.d.ts +1 -1
- package/dist/harness/context/token-estimator.js +14 -6
- package/dist/harness/context/tool-result-aging.d.ts +140 -0
- package/dist/harness/context/tool-result-aging.js +331 -0
- package/dist/harness/context/tool-result-body.d.ts +10 -0
- package/dist/harness/context/tool-result-body.js +27 -0
- package/dist/harness/context/turn-envelope.d.ts +123 -0
- package/dist/harness/context/turn-envelope.js +188 -0
- package/dist/harness/context/types.d.ts +35 -47
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +248 -0
- package/dist/harness/extension/execution-environment/effect-policy.js +334 -0
- package/dist/harness/extension/execution-environment/index.d.ts +18 -2
- package/dist/harness/extension/execution-environment/index.js +11 -2
- package/dist/harness/extension/execution-environment/memory-undo.d.ts +101 -0
- package/dist/harness/extension/execution-environment/memory-undo.js +192 -0
- package/dist/harness/extension/execution-environment/process-isolation.d.ts +84 -0
- package/dist/harness/extension/execution-environment/process-isolation.js +315 -0
- package/dist/harness/extension/execution-environment/resource-limits.d.ts +36 -0
- package/dist/harness/extension/execution-environment/resource-limits.js +84 -0
- package/dist/harness/extension/execution-environment/sandbox.d.ts +125 -4
- package/dist/harness/extension/execution-environment/sandbox.js +493 -51
- package/dist/harness/extension/execution-environment/shell-journal.d.ts +100 -0
- package/dist/harness/extension/execution-environment/shell-journal.js +299 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.d.ts +45 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.js +126 -0
- package/dist/harness/extension/execution-environment/types.d.ts +67 -39
- package/dist/harness/extension/execution-environment/types.js +2 -2
- package/dist/harness/extension/execution-environment/undo-log.d.ts +203 -0
- package/dist/harness/extension/execution-environment/undo-log.js +627 -0
- package/dist/harness/extension/execution-environment/undo-merge.d.ts +40 -0
- package/dist/harness/extension/execution-environment/undo-merge.js +167 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/index.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/index.js +3 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/invoke.d.ts +56 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/invoke.js +281 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.d.ts +98 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.js +250 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/stream.d.ts +124 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/stream.js +372 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/types.d.ts +118 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/types.js +8 -0
- package/dist/harness/extension/plugin-ecosystem/index.d.ts +1 -0
- package/dist/harness/extension/plugin-ecosystem/index.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/mcp/bridge.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +1 -6
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +3 -8
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +2 -10
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +2 -9
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +1 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/index.js +1 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +2 -4
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +4 -21
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +3 -9
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +4 -8
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +1 -4
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +1 -3
- package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/skills/manager.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.d.ts +45 -0
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.js +136 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +18 -3
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +278 -82
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.d.ts +31 -0
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +291 -0
- package/dist/harness/extension/plugin-ecosystem/tools/document-tools.js +10 -2
- package/dist/harness/extension/plugin-ecosystem/tools/env-info.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/eol.d.ts +35 -0
- package/dist/harness/extension/plugin-ecosystem/tools/eol.js +43 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +40 -9
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.d.ts +33 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.js +376 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +12 -2
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +239 -61
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.d.ts +27 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +554 -0
- package/dist/harness/extension/plugin-ecosystem/tools/http.d.ts +10 -6
- package/dist/harness/extension/plugin-ecosystem/tools/http.js +41 -47
- package/dist/harness/extension/plugin-ecosystem/tools/index.d.ts +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/index.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +4 -0
- package/dist/harness/extension/plugin-ecosystem/tools/memory.d.ts +11 -1
- package/dist/harness/extension/plugin-ecosystem/tools/memory.js +39 -1
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.d.ts +13 -0
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +391 -0
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +51 -2
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +151 -12
- package/dist/harness/extension/plugin-ecosystem/tools/session-history.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +10 -1
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +35 -19
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +8 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +5 -0
- package/dist/harness/extension/plugin-ecosystem/tools/web-search.js +1 -0
- package/dist/harness/governance/credentials/index.d.ts +1 -1
- package/dist/harness/governance/credentials/store.d.ts +16 -4
- package/dist/harness/governance/credentials/store.js +33 -6
- package/dist/harness/governance/credentials/types.d.ts +11 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +105 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.js +184 -0
- package/dist/harness/governance/human-in-the-loop/index.d.ts +5 -5
- package/dist/harness/governance/human-in-the-loop/index.js +3 -3
- package/dist/harness/governance/human-in-the-loop/types.d.ts +7 -62
- package/dist/harness/governance/human-in-the-loop/types.js +6 -2
- package/dist/harness/governance/security/capability-enforcer.d.ts +9 -1
- package/dist/harness/governance/security/capability-enforcer.js +31 -8
- package/dist/harness/governance/security/degradation.js +5 -7
- package/dist/harness/governance/security/risk-evaluator.d.ts +1 -1
- package/dist/harness/governance/security/risk-evaluator.js +4 -82
- package/dist/harness/governance/security/temp-path.d.ts +41 -0
- package/dist/harness/governance/security/temp-path.js +117 -0
- package/dist/harness/governance/session-acl/index.d.ts +1 -0
- package/dist/harness/governance/session-acl/index.js +1 -0
- package/dist/harness/governance/session-acl/rights.d.ts +12 -0
- package/dist/harness/governance/session-acl/rights.js +89 -7
- package/dist/harness/governance/session-acl/seed-roles.js +9 -1
- package/dist/harness/governance/session-acl/service.js +21 -29
- package/dist/harness/governance/session-acl/tool-rights.d.ts +81 -0
- package/dist/harness/governance/session-acl/tool-rights.js +238 -0
- package/dist/harness/governance/session-acl/types.d.ts +22 -0
- package/dist/harness/index.d.ts +18 -15
- package/dist/harness/index.js +11 -7
- package/dist/harness/knowledge/file-index-store.js +11 -11
- package/dist/harness/knowledge/grounding.d.ts +2 -1
- package/dist/harness/knowledge/grounding.js +6 -3
- package/dist/harness/knowledge/index.d.ts +2 -2
- package/dist/harness/knowledge/index.js +1 -1
- package/dist/harness/knowledge/ingest.js +4 -1
- package/dist/harness/knowledge/job-control-state.js +4 -4
- package/dist/harness/knowledge/job-control.js +11 -11
- package/dist/harness/knowledge/membership-store.js +11 -11
- package/dist/harness/knowledge/network-guard.d.ts +61 -4
- package/dist/harness/knowledge/network-guard.js +390 -113
- package/dist/harness/knowledge/query-service.js +8 -8
- package/dist/harness/knowledge/retriever.js +1 -1
- package/dist/harness/knowledge/source-store.d.ts +17 -2
- package/dist/harness/knowledge/source-store.js +6 -5
- package/dist/harness/knowledge/writer-service.d.ts +2 -0
- package/dist/harness/knowledge/writer-service.js +14 -13
- package/dist/harness/memory/backfill-trigger.d.ts +2 -2
- package/dist/harness/memory/backfill-trigger.js +4 -4
- package/dist/harness/memory/cognition-decay.d.ts +36 -0
- package/dist/harness/memory/cognition-decay.js +55 -0
- package/dist/harness/memory/cognition-gates.d.ts +60 -0
- package/dist/harness/memory/cognition-gates.js +191 -0
- package/dist/harness/memory/cognition-trigger.d.ts +30 -0
- package/dist/harness/memory/cognition-trigger.js +41 -0
- package/dist/harness/memory/cognition-types.d.ts +1 -1
- package/dist/harness/memory/cognition.d.ts +40 -8
- package/dist/harness/memory/cognition.js +432 -79
- package/dist/harness/memory/conceptualizer.d.ts +66 -0
- package/dist/harness/memory/conceptualizer.js +246 -0
- package/dist/harness/memory/index.d.ts +17 -2
- package/dist/harness/memory/index.js +12 -1
- package/dist/harness/memory/sqlite/agent-db.d.ts +9 -0
- package/dist/harness/memory/sqlite/agent-db.js +120 -15
- package/dist/harness/memory/sqlite/cognition-store.d.ts +55 -16
- package/dist/harness/memory/sqlite/cognition-store.js +591 -144
- package/dist/harness/memory/sqlite/memory-store.d.ts +1 -0
- package/dist/harness/memory/sqlite/memory-store.js +14 -4
- package/dist/harness/memory/sqlite/wisdom-store.d.ts +33 -14
- package/dist/harness/memory/sqlite/wisdom-store.js +257 -44
- package/dist/harness/memory/store.d.ts +1 -0
- package/dist/harness/memory/store.js +3 -0
- package/dist/harness/memory/time-format.d.ts +28 -0
- package/dist/harness/memory/time-format.js +52 -0
- package/dist/harness/memory/types.d.ts +343 -16
- package/dist/harness/memory/types.js +49 -0
- package/dist/harness/memory/wisdom-formation.d.ts +101 -0
- package/dist/harness/memory/wisdom-formation.js +304 -0
- package/dist/harness/memory/wisdom-gates.d.ts +50 -0
- package/dist/harness/memory/wisdom-gates.js +204 -0
- package/dist/harness/memory/wisdom-policy.d.ts +107 -0
- package/dist/harness/memory/wisdom-policy.js +220 -0
- package/dist/harness/memory/wisdom-types.d.ts +3 -2
- package/dist/harness/memory/wisdom-types.js +2 -2
- package/dist/harness/memory/wisdom.d.ts +27 -0
- package/dist/harness/memory/wisdom.js +181 -0
- package/dist/harness/observability/observer/hub.js +23 -1
- package/dist/harness/observability/observer/index.d.ts +2 -2
- package/dist/harness/observability/observer/index.js +1 -1
- package/dist/harness/observability/observer/types.d.ts +57 -0
- package/dist/harness/observability/observer/types.js +118 -9
- package/dist/harness/run/agent/agent.d.ts +27 -0
- package/dist/harness/run/agent/agent.js +45 -0
- package/dist/harness/run/concurrency/tool-loop-detection-core.d.ts +1 -1
- package/dist/harness/run/concurrency/tool-loop-detection-core.js +1 -1
- package/dist/harness/run/reliability/harness-events.d.ts +4 -0
- package/dist/harness/run/reliability/run-agent.js +116 -20
- package/dist/harness/run/reliability/run-metrics-collector.d.ts +28 -2
- package/dist/harness/run/reliability/run-metrics-collector.js +92 -2
- package/dist/harness/run/run-guard/default-run-guard.d.ts +0 -5
- package/dist/harness/run/run-guard/default-run-guard.js +104 -44
- package/dist/harness/run/run-scope.d.ts +52 -0
- package/dist/harness/run/runner.d.ts +101 -16
- package/dist/harness/run/runner.js +557 -158
- package/dist/harness/session/attachments/llm-intent.js +17 -17
- package/dist/harness/session/history/port.js +1 -0
- package/dist/harness/session/in-memory-store.d.ts +1 -0
- package/dist/harness/session/in-memory-store.js +22 -1
- package/dist/harness/session/index.d.ts +1 -0
- package/dist/harness/session/index.js +1 -0
- package/dist/harness/session/schedules/index.d.ts +10 -0
- package/dist/harness/session/schedules/index.js +10 -0
- package/dist/harness/session/schedules/render.d.ts +13 -0
- package/dist/harness/session/schedules/render.js +63 -0
- package/dist/harness/session/schedules/service.d.ts +179 -0
- package/dist/harness/session/schedules/service.js +695 -0
- package/dist/harness/session/schedules/store.d.ts +119 -0
- package/dist/harness/session/schedules/store.js +323 -0
- package/dist/harness/session/schedules/tools.d.ts +39 -0
- package/dist/harness/session/schedules/tools.js +442 -0
- package/dist/harness/session/schedules/types.d.ts +104 -0
- package/dist/harness/session/schedules/types.js +97 -0
- package/dist/harness/session/tasks/tools.js +22 -0
- package/dist/harness/session/title.d.ts +86 -0
- package/dist/harness/session/title.js +268 -0
- package/dist/harness/session/types.d.ts +35 -0
- package/dist/harness/shared/events/agent-event-map.d.ts +21 -0
- package/dist/harness/shared/events/agent-event-map.js +1 -0
- package/dist/harness/shared/types/agent-definition.d.ts +23 -0
- package/dist/index.d.ts +25 -9
- package/dist/index.js +11 -2
- package/dist/integration/providers/anthropic.d.ts +10 -0
- package/dist/integration/providers/anthropic.js +44 -1
- package/dist/integration/providers/openai.d.ts +10 -0
- package/dist/integration/providers/openai.js +58 -2
- package/dist/integration/providers/wire-dump-diff.d.ts +191 -0
- package/dist/integration/providers/wire-dump-diff.js +351 -0
- package/dist/integration/providers/wire-dump.d.ts +178 -0
- package/dist/integration/providers/wire-dump.js +396 -0
- package/dist/integration/storage/jsonl.d.ts +11 -0
- package/dist/integration/storage/jsonl.js +148 -39
- package/dist/integration/storage/session-index.js +63 -8
- package/dist/subsystems/cognition-steward/conceptualize/SUBSYSTEM.md +43 -0
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +50 -0
- package/dist/subsystems/cognition-steward/conceptualize/handler.d.ts +9 -0
- package/dist/subsystems/cognition-steward/conceptualize/handler.js +125 -0
- package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +6 -0
- package/dist/subsystems/cognition-steward/consolidate/config.yaml +54 -0
- package/dist/subsystems/cognition-steward/consolidate/handler.d.ts +12 -0
- package/dist/subsystems/cognition-steward/consolidate/handler.js +93 -0
- package/dist/subsystems/memory-steward/backfill/handler.js +9 -0
- package/dist/subsystems/wisdom-steward/evaluate/config.yaml +50 -0
- package/dist/subsystems/wisdom-steward/evaluate/handler.d.ts +18 -0
- package/dist/subsystems/wisdom-steward/evaluate/handler.js +91 -0
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +42 -0
- package/dist/subsystems/wisdom-steward/formation/config.yaml +54 -0
- package/dist/subsystems/wisdom-steward/formation/handler.d.ts +18 -0
- package/dist/subsystems/wisdom-steward/formation/handler.js +212 -0
- package/dist/subsystems/wisdom-steward/govern/config.yaml +55 -0
- package/dist/subsystems/wisdom-steward/govern/handler.d.ts +17 -0
- package/dist/subsystems/wisdom-steward/govern/handler.js +68 -0
- package/package.json +115 -115
- package/dist/harness/collaboration/multi-agent/agent-registry-types.d.ts +0 -144
- package/dist/harness/collaboration/multi-agent/agent-registry-types.js +0 -25
- package/dist/harness/collaboration/multi-agent/index.d.ts +0 -17
- package/dist/harness/collaboration/multi-agent/index.js +0 -15
- package/dist/harness/collaboration/multi-agent/process.d.ts +0 -167
- package/dist/harness/collaboration/multi-agent/process.js +0 -256
- package/dist/harness/collaboration/multi-agent/registry.d.ts +0 -36
- package/dist/harness/collaboration/multi-agent/registry.js +0 -137
- package/dist/harness/collaboration/multi-agent/swarm.d.ts +0 -135
- package/dist/harness/collaboration/multi-agent/swarm.js +0 -317
- package/dist/harness/collaboration/multi-agent/types.d.ts +0 -66
- package/dist/harness/collaboration/multi-agent/types.js +0 -15
- package/dist/harness/collaboration/orchestration/async-task-store.d.ts +0 -107
- package/dist/harness/collaboration/orchestration/async-task-store.js +0 -12
- package/dist/harness/collaboration/orchestration/async-task.d.ts +0 -156
- package/dist/harness/collaboration/orchestration/async-task.js +0 -359
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.d.ts +0 -47
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.js +0 -61
- package/dist/harness/collaboration/orchestration/planner/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/planner/index.js +0 -6
- package/dist/harness/collaboration/orchestration/planner/llm-planner.d.ts +0 -54
- package/dist/harness/collaboration/orchestration/planner/llm-planner.js +0 -167
- package/dist/harness/collaboration/orchestration/planner/rule-planner.d.ts +0 -85
- package/dist/harness/collaboration/orchestration/planner/rule-planner.js +0 -175
- package/dist/harness/collaboration/orchestration/quality/classifier.d.ts +0 -21
- package/dist/harness/collaboration/orchestration/quality/classifier.js +0 -235
- package/dist/harness/collaboration/orchestration/quality/gate.d.ts +0 -29
- package/dist/harness/collaboration/orchestration/quality/gate.js +0 -409
- package/dist/harness/collaboration/orchestration/quality/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/quality/index.js +0 -8
- package/dist/harness/collaboration/orchestration/quality/types.d.ts +0 -159
- package/dist/harness/collaboration/orchestration/quality/types.js +0 -33
- package/dist/harness/collaboration/orchestration/scheduler/index.d.ts +0 -5
- package/dist/harness/collaboration/orchestration/scheduler/index.js +0 -4
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.js +0 -297
- package/dist/harness/collaboration/orchestration/strategy/classifier.d.ts +0 -12
- package/dist/harness/collaboration/orchestration/strategy/classifier.js +0 -81
- package/dist/harness/collaboration/orchestration/strategy/index.d.ts +0 -3
- package/dist/harness/collaboration/orchestration/strategy/index.js +0 -2
- package/dist/harness/collaboration/orchestration/strategy/router.d.ts +0 -28
- package/dist/harness/collaboration/orchestration/strategy/router.js +0 -105
- package/dist/harness/collaboration/orchestration/strategy/types.d.ts +0 -49
- package/dist/harness/collaboration/orchestration/strategy/types.js +0 -4
- package/dist/harness/collaboration/orchestration/workflow/engine.d.ts +0 -86
- package/dist/harness/collaboration/orchestration/workflow/engine.js +0 -298
- package/dist/harness/collaboration/orchestration/workflow/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/workflow/index.js +0 -7
- package/dist/harness/collaboration/orchestration/workflow/types.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/workflow/types.js +0 -7
- package/dist/harness/governance/human-in-the-loop/approval-manager.d.ts +0 -32
- package/dist/harness/governance/human-in-the-loop/approval-manager.js +0 -93
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.d.ts +0 -0
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.js +0 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClientStreamTransport — Host 侧 source/sink 采样通道
|
|
3
|
+
*
|
|
4
|
+
* LLM 不可见:不注册 stream_read/write/close。域工具封装生命周期,
|
|
5
|
+
* 样本经事件回调给 UI/插件;大字节仍走 asset。
|
|
6
|
+
*/
|
|
7
|
+
import { requireDevicePurpose, validateClientToolArgs } from './invoke.js';
|
|
8
|
+
function defaultStreamId() {
|
|
9
|
+
return `cs_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 会话流通道注册表 + 节流广播。
|
|
13
|
+
* 通道操作仅 Host/插件调用,不进入 LLM tool 面。
|
|
14
|
+
*/
|
|
15
|
+
export class ClientStreamTransport {
|
|
16
|
+
deps;
|
|
17
|
+
channels = new Map();
|
|
18
|
+
throttleMs;
|
|
19
|
+
maxBatch;
|
|
20
|
+
defaultMaxDurationMs;
|
|
21
|
+
makeStreamId;
|
|
22
|
+
now;
|
|
23
|
+
constructor(deps) {
|
|
24
|
+
this.deps = deps;
|
|
25
|
+
this.throttleMs = deps.throttleMs ?? 200;
|
|
26
|
+
this.maxBatch = deps.maxBatch ?? 32;
|
|
27
|
+
this.defaultMaxDurationMs = deps.defaultMaxDurationMs ?? 300_000;
|
|
28
|
+
this.makeStreamId = deps.makeStreamId ?? defaultStreamId;
|
|
29
|
+
this.now = deps.now ?? Date.now;
|
|
30
|
+
}
|
|
31
|
+
open(input) {
|
|
32
|
+
const at = this.now();
|
|
33
|
+
const maxDurationMs = input.maxDurationMs ?? this.defaultMaxDurationMs;
|
|
34
|
+
const channel = {
|
|
35
|
+
streamId: this.makeStreamId(),
|
|
36
|
+
direction: input.direction,
|
|
37
|
+
sampleHint: input.sampleHint,
|
|
38
|
+
owner: {
|
|
39
|
+
sessionId: input.sessionId,
|
|
40
|
+
clientInstanceId: input.clientInstanceId,
|
|
41
|
+
toolCallId: input.toolCallId,
|
|
42
|
+
toolName: input.toolName,
|
|
43
|
+
},
|
|
44
|
+
status: 'open',
|
|
45
|
+
openedAt: at,
|
|
46
|
+
maxDurationMs,
|
|
47
|
+
};
|
|
48
|
+
const internal = { channel, pending: [] };
|
|
49
|
+
this.channels.set(channel.streamId, internal);
|
|
50
|
+
if (maxDurationMs > 0) {
|
|
51
|
+
internal.ttlTimer = setTimeout(() => {
|
|
52
|
+
this.close(channel.streamId, 'ttl');
|
|
53
|
+
}, maxDurationMs);
|
|
54
|
+
}
|
|
55
|
+
this.deps.emitEvent({
|
|
56
|
+
type: 'client_stream.opened',
|
|
57
|
+
sessionId: input.sessionId,
|
|
58
|
+
timestamp: at,
|
|
59
|
+
data: { channel: { ...channel } },
|
|
60
|
+
});
|
|
61
|
+
return { ...channel, owner: { ...channel.owner } };
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 写入样本(source:client 上报;sink:host 下发前镜像给 UI)。
|
|
65
|
+
* 超过 maxBatch 的可丢样本在本窗丢弃。
|
|
66
|
+
*/
|
|
67
|
+
writeSamples(streamId, samples) {
|
|
68
|
+
const entry = this.channels.get(streamId);
|
|
69
|
+
if (!entry || entry.channel.status !== 'open')
|
|
70
|
+
return false;
|
|
71
|
+
const at = this.now();
|
|
72
|
+
let dropped = 0;
|
|
73
|
+
for (const s of samples) {
|
|
74
|
+
if (entry.pending.length >= this.maxBatch) {
|
|
75
|
+
dropped += 1;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
entry.pending.push({ data: s.data, at });
|
|
79
|
+
}
|
|
80
|
+
if (dropped > 0) {
|
|
81
|
+
this.deps.emitEvent({
|
|
82
|
+
type: 'client_stream.sample',
|
|
83
|
+
sessionId: entry.channel.owner.sessionId,
|
|
84
|
+
timestamp: at,
|
|
85
|
+
data: { streamId, samples: [], dropped },
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
this.scheduleFlush(entry);
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
scheduleFlush(entry) {
|
|
92
|
+
if (entry.sampleTimer !== undefined)
|
|
93
|
+
return;
|
|
94
|
+
entry.sampleTimer = setTimeout(() => {
|
|
95
|
+
entry.sampleTimer = undefined;
|
|
96
|
+
this.flush(entry);
|
|
97
|
+
}, this.throttleMs);
|
|
98
|
+
}
|
|
99
|
+
flush(entry) {
|
|
100
|
+
if (entry.pending.length === 0)
|
|
101
|
+
return;
|
|
102
|
+
const batch = entry.pending.splice(0, this.maxBatch);
|
|
103
|
+
this.deps.emitEvent({
|
|
104
|
+
type: 'client_stream.sample',
|
|
105
|
+
sessionId: entry.channel.owner.sessionId,
|
|
106
|
+
timestamp: this.now(),
|
|
107
|
+
data: {
|
|
108
|
+
streamId: entry.channel.streamId,
|
|
109
|
+
samples: batch.map((s) => ({ data: s.data, at: s.at })),
|
|
110
|
+
dropped: 0,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
if (entry.pending.length > 0)
|
|
114
|
+
this.scheduleFlush(entry);
|
|
115
|
+
}
|
|
116
|
+
close(streamId, reason = 'closed') {
|
|
117
|
+
const entry = this.channels.get(streamId);
|
|
118
|
+
if (!entry)
|
|
119
|
+
return null;
|
|
120
|
+
if (entry.channel.status === 'closed') {
|
|
121
|
+
return { ...entry.channel, owner: { ...entry.channel.owner } };
|
|
122
|
+
}
|
|
123
|
+
this.flush(entry);
|
|
124
|
+
entry.channel.status = 'closed';
|
|
125
|
+
entry.channel.closedAt = this.now();
|
|
126
|
+
if (entry.ttlTimer !== undefined) {
|
|
127
|
+
clearTimeout(entry.ttlTimer);
|
|
128
|
+
entry.ttlTimer = undefined;
|
|
129
|
+
}
|
|
130
|
+
if (entry.sampleTimer !== undefined) {
|
|
131
|
+
clearTimeout(entry.sampleTimer);
|
|
132
|
+
entry.sampleTimer = undefined;
|
|
133
|
+
}
|
|
134
|
+
this.channels.delete(streamId);
|
|
135
|
+
this.deps.emitEvent({
|
|
136
|
+
type: 'client_stream.closed',
|
|
137
|
+
sessionId: entry.channel.owner.sessionId,
|
|
138
|
+
timestamp: entry.channel.closedAt,
|
|
139
|
+
data: { channel: { ...entry.channel }, reason },
|
|
140
|
+
});
|
|
141
|
+
return { ...entry.channel, owner: { ...entry.channel.owner } };
|
|
142
|
+
}
|
|
143
|
+
/** Run abort / session 结束 / client 下线时联动关闭 */
|
|
144
|
+
closeWhere(match, reason = 'closed') {
|
|
145
|
+
let n = 0;
|
|
146
|
+
for (const entry of [...this.channels.values()]) {
|
|
147
|
+
if (match({ ...entry.channel, owner: { ...entry.channel.owner } })) {
|
|
148
|
+
this.close(entry.channel.streamId, reason);
|
|
149
|
+
n += 1;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return n;
|
|
153
|
+
}
|
|
154
|
+
get(streamId) {
|
|
155
|
+
const entry = this.channels.get(streamId);
|
|
156
|
+
return entry ? { ...entry.channel, owner: { ...entry.channel.owner } } : undefined;
|
|
157
|
+
}
|
|
158
|
+
list(sessionId) {
|
|
159
|
+
return [...this.channels.values()]
|
|
160
|
+
.filter((e) => !sessionId || e.channel.owner.sessionId === sessionId)
|
|
161
|
+
.map((e) => ({ ...e.channel, owner: { ...e.channel.owner } }));
|
|
162
|
+
}
|
|
163
|
+
/** 同 session 内某域工具仍打开的通道(复用,避免每次 invoke 新开) */
|
|
164
|
+
findOpenByTool(sessionId, toolName, clientInstanceId) {
|
|
165
|
+
for (const entry of this.channels.values()) {
|
|
166
|
+
const c = entry.channel;
|
|
167
|
+
if (c.status !== 'open')
|
|
168
|
+
continue;
|
|
169
|
+
if (c.owner.sessionId !== sessionId)
|
|
170
|
+
continue;
|
|
171
|
+
if (c.owner.toolName !== toolName)
|
|
172
|
+
continue;
|
|
173
|
+
if (clientInstanceId && c.owner.clientInstanceId !== clientInstanceId)
|
|
174
|
+
continue;
|
|
175
|
+
return { ...c, owner: { ...c.owner } };
|
|
176
|
+
}
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function samplesFromArgs(args) {
|
|
181
|
+
const raw = args.samples;
|
|
182
|
+
if (!Array.isArray(raw) || raw.length === 0)
|
|
183
|
+
return [];
|
|
184
|
+
return raw.map((data) => ({ data }));
|
|
185
|
+
}
|
|
186
|
+
function requiresDeviceConsent(descriptor) {
|
|
187
|
+
return (descriptor.interaction === 'device' &&
|
|
188
|
+
(descriptor.device?.consent ?? 'prompt') !== 'none');
|
|
189
|
+
}
|
|
190
|
+
/** 通道属主校验:禁止跨 session 读写/关闭(§15.1) */
|
|
191
|
+
function assertSameSession(channel, sessionId) {
|
|
192
|
+
if (!sessionId)
|
|
193
|
+
return 'sessionId is required';
|
|
194
|
+
if (!channel)
|
|
195
|
+
return 'stream not found';
|
|
196
|
+
if (channel.status !== 'open')
|
|
197
|
+
return `stream "${channel.streamId}" is not open`;
|
|
198
|
+
if (channel.owner.sessionId !== sessionId) {
|
|
199
|
+
return `stream "${channel.streamId}" belongs to another session`;
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* source 域工具样板(location_watch 类):返回 value 域句柄,样本走 Host 通道。
|
|
205
|
+
* 不是通用 stream_read;生命周期由配对 stop 工具或 TTL 收口。
|
|
206
|
+
* 默认 sticky:同 session 已有 open 通道则复用,避免重复开流。
|
|
207
|
+
*/
|
|
208
|
+
export function createSourceStreamTool(descriptor, deps) {
|
|
209
|
+
return buildStreamTool(descriptor, { reuse: 'sticky', ...deps }, 'source');
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* sink 域工具样板(play 类):打开 host→client 下行通道,返回 value 域句柄。
|
|
213
|
+
* 默认 append:同 session / playId 续写样本,持续下发不新开通道。
|
|
214
|
+
*/
|
|
215
|
+
export function createSinkStreamTool(descriptor, deps) {
|
|
216
|
+
return buildStreamTool(descriptor, { reuse: 'append', ...deps }, 'sink');
|
|
217
|
+
}
|
|
218
|
+
function buildStreamTool(descriptor, deps, direction) {
|
|
219
|
+
const handleKey = deps.handleKey ?? (direction === 'source' ? 'watchId' : 'playId');
|
|
220
|
+
const reuse = deps.reuse ?? 'none';
|
|
221
|
+
return {
|
|
222
|
+
definition: {
|
|
223
|
+
name: descriptor.name,
|
|
224
|
+
description: descriptor.description,
|
|
225
|
+
parameters: descriptor.parameters,
|
|
226
|
+
version: descriptor.version,
|
|
227
|
+
requiresConfirmation: requiresDeviceConsent(descriptor),
|
|
228
|
+
},
|
|
229
|
+
handler: async (args, context) => {
|
|
230
|
+
const argError = validateClientToolArgs(descriptor.parameters ?? {}, args);
|
|
231
|
+
if (argError)
|
|
232
|
+
return { error: 'invalid_arguments', hint: argError };
|
|
233
|
+
const purposeError = requireDevicePurpose(descriptor, args);
|
|
234
|
+
if (purposeError)
|
|
235
|
+
return { error: 'invalid_arguments', hint: purposeError };
|
|
236
|
+
const sessionId = context?.sessionId;
|
|
237
|
+
// 1) 显式句柄:续写 / 确认已有通道(校验属主)
|
|
238
|
+
const explicit = args[handleKey] ?? args.playId ?? args.watchId;
|
|
239
|
+
if (reuse !== 'none' && typeof explicit === 'string' && explicit) {
|
|
240
|
+
const existing = deps.transport.get(explicit);
|
|
241
|
+
if (existing && existing.status === 'open') {
|
|
242
|
+
const denied = assertSameSession(existing, sessionId);
|
|
243
|
+
if (denied)
|
|
244
|
+
return { error: 'permission_denied', hint: denied };
|
|
245
|
+
const extra = samplesFromArgs(args);
|
|
246
|
+
if (extra.length > 0)
|
|
247
|
+
deps.transport.writeSamples(existing.streamId, extra);
|
|
248
|
+
return {
|
|
249
|
+
kind: 'value',
|
|
250
|
+
data: {
|
|
251
|
+
[handleKey]: existing.streamId,
|
|
252
|
+
status: existing.status,
|
|
253
|
+
direction: existing.direction,
|
|
254
|
+
reused: true,
|
|
255
|
+
sampleHint: existing.sampleHint,
|
|
256
|
+
maxDurationMs: existing.maxDurationMs,
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
// 2) 同名 open 通道:sticky 返回 / append 续写
|
|
262
|
+
if (reuse !== 'none') {
|
|
263
|
+
const found = sessionId
|
|
264
|
+
? deps.transport.findOpenByTool(sessionId, descriptor.name)
|
|
265
|
+
: undefined;
|
|
266
|
+
if (found) {
|
|
267
|
+
const denied = assertSameSession(found, sessionId);
|
|
268
|
+
if (denied)
|
|
269
|
+
return { error: 'permission_denied', hint: denied };
|
|
270
|
+
const extra = samplesFromArgs(args);
|
|
271
|
+
if (reuse === 'append' && extra.length > 0) {
|
|
272
|
+
deps.transport.writeSamples(found.streamId, extra);
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
kind: 'value',
|
|
276
|
+
data: {
|
|
277
|
+
[handleKey]: found.streamId,
|
|
278
|
+
status: found.status,
|
|
279
|
+
direction: found.direction,
|
|
280
|
+
reused: true,
|
|
281
|
+
sampleHint: found.sampleHint,
|
|
282
|
+
maxDurationMs: found.maxDurationMs,
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
// 3) 新开通道
|
|
288
|
+
let opened;
|
|
289
|
+
try {
|
|
290
|
+
opened = deps.openChannel({ args, context });
|
|
291
|
+
}
|
|
292
|
+
catch (err) {
|
|
293
|
+
return {
|
|
294
|
+
error: 'internal',
|
|
295
|
+
hint: err instanceof Error ? err.message : String(err),
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
const channel = deps.transport.open({
|
|
299
|
+
...opened,
|
|
300
|
+
direction,
|
|
301
|
+
toolName: descriptor.name,
|
|
302
|
+
});
|
|
303
|
+
try {
|
|
304
|
+
if (samplesFromArgs(args).length > 0) {
|
|
305
|
+
deps.transport.writeSamples(channel.streamId, samplesFromArgs(args));
|
|
306
|
+
}
|
|
307
|
+
deps.onOpen?.(channel, args, deps.transport);
|
|
308
|
+
}
|
|
309
|
+
catch {
|
|
310
|
+
// 附加样本失败不回滚已打开通道;工具结果仍返回句柄
|
|
311
|
+
}
|
|
312
|
+
return {
|
|
313
|
+
kind: 'value',
|
|
314
|
+
data: {
|
|
315
|
+
[handleKey]: channel.streamId,
|
|
316
|
+
status: channel.status,
|
|
317
|
+
direction: channel.direction,
|
|
318
|
+
reused: false,
|
|
319
|
+
sampleHint: channel.sampleHint,
|
|
320
|
+
maxDurationMs: channel.maxDurationMs,
|
|
321
|
+
},
|
|
322
|
+
};
|
|
323
|
+
},
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* 域工具 stop 样板:按域句柄关通道。不是通用 stream_close。
|
|
328
|
+
*/
|
|
329
|
+
export function createStreamStopTool(descriptor, deps) {
|
|
330
|
+
const handleKey = deps.handleKey ?? 'watchId';
|
|
331
|
+
return {
|
|
332
|
+
definition: {
|
|
333
|
+
name: descriptor.name,
|
|
334
|
+
description: descriptor.description,
|
|
335
|
+
parameters: descriptor.parameters,
|
|
336
|
+
version: descriptor.version,
|
|
337
|
+
},
|
|
338
|
+
handler: async (args, context) => {
|
|
339
|
+
const argError = validateClientToolArgs(descriptor.parameters ?? {}, args);
|
|
340
|
+
if (argError)
|
|
341
|
+
return { error: 'invalid_arguments', hint: argError };
|
|
342
|
+
const raw = args[handleKey] ?? args.playId ?? args.watchId;
|
|
343
|
+
const streamId = typeof raw === 'string' ? raw : '';
|
|
344
|
+
if (!streamId) {
|
|
345
|
+
return { error: 'invalid_arguments', hint: `missing ${handleKey}` };
|
|
346
|
+
}
|
|
347
|
+
const existing = deps.transport.get(streamId);
|
|
348
|
+
const denied = assertSameSession(existing, context?.sessionId);
|
|
349
|
+
if (denied) {
|
|
350
|
+
return {
|
|
351
|
+
error: denied === 'stream not found' ? 'unsupported' : 'permission_denied',
|
|
352
|
+
hint: denied,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
const closed = deps.transport.close(streamId, 'stop');
|
|
356
|
+
if (!closed) {
|
|
357
|
+
return {
|
|
358
|
+
error: 'unsupported',
|
|
359
|
+
hint: `no open stream "${streamId}"`,
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
return {
|
|
363
|
+
kind: 'value',
|
|
364
|
+
data: {
|
|
365
|
+
[handleKey]: closed.streamId,
|
|
366
|
+
status: closed.status,
|
|
367
|
+
closedAt: closed.closedAt,
|
|
368
|
+
},
|
|
369
|
+
};
|
|
370
|
+
},
|
|
371
|
+
};
|
|
372
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client Tool 契约 — 客户端能力接入 agent tool 面
|
|
3
|
+
*
|
|
4
|
+
* 设计见 arch/client-tools.md。与 Server Tool 同构进 tool 面;
|
|
5
|
+
* 结果只允许小结构化 value 或 asset 引用(禁止大字节内联)。
|
|
6
|
+
* 解释(OCR/抽取)在 server,client 只规范化。
|
|
7
|
+
*/
|
|
8
|
+
import type { ToolParameter } from '@octopi-agent/core/types/tools.js';
|
|
9
|
+
/** 注册名(进 LLM tool 列表;snake_case) */
|
|
10
|
+
export type ClientToolName = string;
|
|
11
|
+
/** 调用归属单元 id(Gateway 生成) */
|
|
12
|
+
export type ClientToolCallId = string;
|
|
13
|
+
export type ClientToolInteraction = 'silent' | 'ui' | 'device';
|
|
14
|
+
export type ClientToolSensitivity = 'public' | 'personal' | 'sensitive';
|
|
15
|
+
export interface ClientToolDeviceMeta {
|
|
16
|
+
class?: 'sensor' | 'actuator' | 'media_io';
|
|
17
|
+
sensitivity?: ClientToolSensitivity;
|
|
18
|
+
/** none | prompt | strict — sensitive 不得为 none */
|
|
19
|
+
consent?: 'none' | 'prompt' | 'strict';
|
|
20
|
+
}
|
|
21
|
+
/** 候选端过滤(LLM 不可见 instanceId;钉端走注册描述符) */
|
|
22
|
+
export interface ClientToolClientFilter {
|
|
23
|
+
platforms?: string[];
|
|
24
|
+
instanceId?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 插件/客户端注册的工具描述符。
|
|
28
|
+
* `parameters` 与 Core `ToolDefinition.parameters` 同形,便于直接装进 tool 面。
|
|
29
|
+
*/
|
|
30
|
+
export interface ClientToolDescriptor {
|
|
31
|
+
name: ClientToolName;
|
|
32
|
+
/** 工具描述:用途/输入/结果。禁止 UI 控件与布局词汇 */
|
|
33
|
+
description: string;
|
|
34
|
+
parameters: Record<string, ToolParameter>;
|
|
35
|
+
interaction?: ClientToolInteraction;
|
|
36
|
+
device?: ClientToolDeviceMeta;
|
|
37
|
+
/** 哪些端可执行;缺省 = 任一已声明该 name 的 live client */
|
|
38
|
+
clientFilter?: ClientToolClientFilter;
|
|
39
|
+
/** 声明可能的结果种类(LLM 结果仅 value/asset;source/sink 为 Host 通道) */
|
|
40
|
+
resultKinds?: Array<'value' | 'asset'>;
|
|
41
|
+
/** 解释发生地:默认 server;local 仅标注端上处理(审计),schema 校验不变 */
|
|
42
|
+
processing?: 'server' | 'local';
|
|
43
|
+
/**
|
|
44
|
+
* 声明为 Host 流通道域工具(§15.1):
|
|
45
|
+
* source=watch 类,sink=播放类。LLM 仍只拿 value 域句柄。
|
|
46
|
+
*/
|
|
47
|
+
stream?: {
|
|
48
|
+
/** source=watch 类;sink=播放类;stop=按域句柄关通道 */
|
|
49
|
+
direction: 'source' | 'sink' | 'stop';
|
|
50
|
+
/** value 句柄字段名,默认 watchId / playId */
|
|
51
|
+
handleKey?: string;
|
|
52
|
+
};
|
|
53
|
+
version?: string;
|
|
54
|
+
}
|
|
55
|
+
export type ClientToolResult = {
|
|
56
|
+
kind: 'value';
|
|
57
|
+
data: unknown;
|
|
58
|
+
} | {
|
|
59
|
+
kind: 'asset';
|
|
60
|
+
assetId: string;
|
|
61
|
+
mime: string;
|
|
62
|
+
sizeBytes: number;
|
|
63
|
+
name?: string;
|
|
64
|
+
preview?: string;
|
|
65
|
+
};
|
|
66
|
+
export type ClientToolErrorReason = 'invalid_arguments' | 'client_unavailable' | 'consent_denied' | 'permission_denied' | 'expired' | 'cancelled' | 'unsupported' | 'internal';
|
|
67
|
+
/** 已 release 的文件引用(send_file);正文经 fileId 内容 API 获取,不进 tool_result */
|
|
68
|
+
export interface ClientToolFileRef {
|
|
69
|
+
fileId: string;
|
|
70
|
+
name: string;
|
|
71
|
+
mime: string;
|
|
72
|
+
sizeBytes: number;
|
|
73
|
+
}
|
|
74
|
+
export type ClientToolCallOutcome = {
|
|
75
|
+
status: 'ok';
|
|
76
|
+
result: ClientToolResult;
|
|
77
|
+
processing?: 'server' | 'local';
|
|
78
|
+
} | {
|
|
79
|
+
status: 'error';
|
|
80
|
+
reason: ClientToolErrorReason;
|
|
81
|
+
hint?: string;
|
|
82
|
+
processing?: 'server' | 'local';
|
|
83
|
+
};
|
|
84
|
+
export interface ClientToolCall {
|
|
85
|
+
id: ClientToolCallId;
|
|
86
|
+
name: ClientToolName;
|
|
87
|
+
sessionId: string;
|
|
88
|
+
runId?: string;
|
|
89
|
+
agentId: string;
|
|
90
|
+
args: Record<string, unknown>;
|
|
91
|
+
/** 路由解析后的目标端;未解析时 undefined */
|
|
92
|
+
targetClientInstanceId?: string;
|
|
93
|
+
state: 'pending' | 'running' | 'succeeded' | 'failed';
|
|
94
|
+
outcome?: ClientToolCallOutcome;
|
|
95
|
+
completedByPrincipalId?: string;
|
|
96
|
+
/** html_ui 等大正文落 attachment 后的引用 */
|
|
97
|
+
assetId?: string;
|
|
98
|
+
/** send_file 已 release 的文件引用;正文经 GET files/:fileId */
|
|
99
|
+
fileRef?: ClientToolFileRef;
|
|
100
|
+
/** 解释发生地(审计) */
|
|
101
|
+
processing?: 'server' | 'local';
|
|
102
|
+
/** 调用解析时的敏感度(换端判定,§15.3) */
|
|
103
|
+
sensitivity?: ClientToolSensitivity;
|
|
104
|
+
/** 调用解析时是否 clientFilter 钉端(钉端不换端) */
|
|
105
|
+
pinnedClient?: boolean;
|
|
106
|
+
createdAt: number;
|
|
107
|
+
ttlAt: number;
|
|
108
|
+
}
|
|
109
|
+
/** 已注册到某客户端实例的能力 */
|
|
110
|
+
export interface ClientToolProvider {
|
|
111
|
+
clientInstanceId: string;
|
|
112
|
+
sessionId: string;
|
|
113
|
+
platform?: string;
|
|
114
|
+
principalId?: string;
|
|
115
|
+
/** 最近活跃时间戳,用于默认路由(最近活跃端) */
|
|
116
|
+
lastActiveAt: number;
|
|
117
|
+
descriptors: ClientToolDescriptor[];
|
|
118
|
+
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export * from './plugins/index.js';
|
|
7
7
|
export * from './tools/index.js';
|
|
8
|
+
export * from './client-tools/index.js';
|
|
8
9
|
export type { ChannelAdapter, ChannelMessage, ChannelReply } from './channel-types.js';
|
|
9
10
|
export { DefaultSkillManager, FileSystemSkillSource } from './skills/manager.js';
|
|
10
11
|
export type { SkillSource, DiscoveredSkill } from './skills/manager.js';
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export * from './plugins/index.js';
|
|
7
7
|
export * from './tools/index.js';
|
|
8
|
+
export * from './client-tools/index.js';
|
|
8
9
|
export { DefaultSkillManager, FileSystemSkillSource } from './skills/manager.js';
|
|
9
10
|
export * from './mcp/index.js';
|
|
10
11
|
export * from './commands/index.js';
|
|
@@ -51,6 +51,8 @@ export function mcpToolToOctopiDefinition(mcpTool, serverId) {
|
|
|
51
51
|
return {
|
|
52
52
|
name: `${serverId}${MCP_NAMESPACE_SEP}${mcpTool.name}`,
|
|
53
53
|
description: mcpTool.description ?? '',
|
|
54
|
+
// D5: MCP talks to an external process — default egress (reduced surface strips it)
|
|
55
|
+
capabilities: ['egress'],
|
|
54
56
|
parameters: params,
|
|
55
57
|
};
|
|
56
58
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Plugin API
|
|
2
|
+
* Plugin API
|
|
3
3
|
*
|
|
4
4
|
* 这是 plugin register() 回调中接收的 api 对象。
|
|
5
5
|
* Plugin 通过它注册各种能力(provider、channel、tool、hook 等)。
|
|
6
|
-
*
|
|
7
|
-
* 参考: https://docs.openclaw.ai/plugins/sdk-overview#registration-api
|
|
8
6
|
*/
|
|
9
7
|
import type { ModelProvider } from '@octopi-agent/core/interfaces/model-provider.js';
|
|
10
8
|
import type { WebSearchProvider } from '../tools/web-search-types.js';
|
|
@@ -76,7 +74,6 @@ export interface PluginLogger {
|
|
|
76
74
|
/**
|
|
77
75
|
* Plugin API
|
|
78
76
|
*
|
|
79
|
-
* 对齐 OpenClaw 的 OpenClawPluginApi。
|
|
80
77
|
* Plugin 在 register() 回调中使用此对象注册能力。
|
|
81
78
|
*/
|
|
82
79
|
export declare class PluginApi {
|
|
@@ -149,7 +146,6 @@ export declare class PluginApi {
|
|
|
149
146
|
/**
|
|
150
147
|
* 注册 Agent Tool
|
|
151
148
|
*
|
|
152
|
-
* 对齐 OpenClaw 的 api.registerTool()。
|
|
153
149
|
* Tool 名称不能与核心 tool 冲突。
|
|
154
150
|
*
|
|
155
151
|
* @param tool - Tool 定义(包含 name、description、parameters)
|
|
@@ -169,7 +165,6 @@ export declare class PluginApi {
|
|
|
169
165
|
/**
|
|
170
166
|
* 注册 Hook
|
|
171
167
|
*
|
|
172
|
-
* 对齐 OpenClaw 的 api.on()。
|
|
173
168
|
* Hook handler 按 priority 降序执行,同 priority 按注册顺序。
|
|
174
169
|
*
|
|
175
170
|
* @param hookName - Hook 名称
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Plugin API
|
|
2
|
+
* Plugin API
|
|
3
3
|
*
|
|
4
4
|
* 这是 plugin register() 回调中接收的 api 对象。
|
|
5
5
|
* Plugin 通过它注册各种能力(provider、channel、tool、hook 等)。
|
|
6
|
-
*
|
|
7
|
-
* 参考: https://docs.openclaw.ai/plugins/sdk-overview#registration-api
|
|
8
6
|
*/
|
|
9
7
|
/**
|
|
10
8
|
* Plugin API
|
|
11
9
|
*
|
|
12
|
-
* 对齐 OpenClaw 的 OpenClawPluginApi。
|
|
13
10
|
* Plugin 在 register() 回调中使用此对象注册能力。
|
|
14
11
|
*/
|
|
15
12
|
export class PluginApi {
|
|
@@ -61,7 +58,7 @@ export class PluginApi {
|
|
|
61
58
|
};
|
|
62
59
|
}
|
|
63
60
|
// ================================================================
|
|
64
|
-
// Capability Registration
|
|
61
|
+
// Capability Registration
|
|
65
62
|
// ================================================================
|
|
66
63
|
/**
|
|
67
64
|
* 注册 LLM Provider
|
|
@@ -84,7 +81,6 @@ export class PluginApi {
|
|
|
84
81
|
/**
|
|
85
82
|
* 注册 Agent Tool
|
|
86
83
|
*
|
|
87
|
-
* 对齐 OpenClaw 的 api.registerTool()。
|
|
88
84
|
* Tool 名称不能与核心 tool 冲突。
|
|
89
85
|
*
|
|
90
86
|
* @param tool - Tool 定义(包含 name、description、parameters)
|
|
@@ -114,7 +110,6 @@ export class PluginApi {
|
|
|
114
110
|
/**
|
|
115
111
|
* 注册 Hook
|
|
116
112
|
*
|
|
117
|
-
* 对齐 OpenClaw 的 api.on()。
|
|
118
113
|
* Hook handler 按 priority 降序执行,同 priority 按注册顺序。
|
|
119
114
|
*
|
|
120
115
|
* @param hookName - Hook 名称
|
|
@@ -159,7 +154,7 @@ export class PluginApi {
|
|
|
159
154
|
this.logger.info(`Registered service: ${service.id}`);
|
|
160
155
|
}
|
|
161
156
|
// ================================================================
|
|
162
|
-
// Extended Registration
|
|
157
|
+
// Extended Registration
|
|
163
158
|
// ================================================================
|
|
164
159
|
/** 已注册的 web search providers */
|
|
165
160
|
_webSearchProviders = [];
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Capability Registry — 能力注册中心
|
|
3
3
|
*
|
|
4
|
-
* 对齐 OpenClaw 的 capability ownership model。
|
|
5
4
|
* 每种能力类型有独立的注册表,plugin 是能力的所有权边界。
|
|
6
5
|
*
|
|
7
6
|
* 核心原则:
|
|
8
7
|
* - plugin = 所有权边界(一个公司/功能的所有表面)
|
|
9
8
|
* - capability = 核心合约,多个 plugin 可以实现或消费
|
|
10
9
|
* - 冲突检测:同一 capability ID 不能被两个 plugin 注册
|
|
11
|
-
*
|
|
12
|
-
* 参考: https://docs.openclaw.ai/plugins/architecture#capability-ownership-model
|
|
13
10
|
*/
|
|
14
11
|
import type { PluginManifest } from './manifest.js';
|
|
15
12
|
/**
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Capability Registry — 能力注册中心
|
|
3
3
|
*
|
|
4
|
-
* 对齐 OpenClaw 的 capability ownership model。
|
|
5
4
|
* 每种能力类型有独立的注册表,plugin 是能力的所有权边界。
|
|
6
5
|
*
|
|
7
6
|
* 核心原则:
|
|
8
7
|
* - plugin = 所有权边界(一个公司/功能的所有表面)
|
|
9
8
|
* - capability = 核心合约,多个 plugin 可以实现或消费
|
|
10
9
|
* - 冲突检测:同一 capability ID 不能被两个 plugin 注册
|
|
11
|
-
*
|
|
12
|
-
* 参考: https://docs.openclaw.ai/plugins/architecture#capability-ownership-model
|
|
13
10
|
*/
|
|
14
11
|
/**
|
|
15
12
|
* Capability Registry
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Plugin Entry
|
|
2
|
+
* Plugin Entry
|
|
3
3
|
*
|
|
4
4
|
* definePluginEntry 是创建 plugin 的标准方式。
|
|
5
5
|
* 它定义了 plugin 的 id、name、register 回调等。
|
|
6
|
-
*
|
|
7
|
-
* 对齐 OpenClaw 的:
|
|
8
|
-
* import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
9
|
-
*
|
|
10
|
-
* 参考: https://docs.openclaw.ai/plugins/building-plugins
|
|
11
6
|
*/
|
|
12
7
|
import type { PluginApi } from './api.js';
|
|
13
8
|
/**
|
|
@@ -57,7 +52,7 @@ export interface OctopiPluginDefinition {
|
|
|
57
52
|
/**
|
|
58
53
|
* 定义一个 Plugin Entry
|
|
59
54
|
*
|
|
60
|
-
* 这是创建 plugin
|
|
55
|
+
* 这是创建 plugin 的标准方式。
|
|
61
56
|
*
|
|
62
57
|
* @param definition - Plugin 定义
|
|
63
58
|
* @returns Plugin 定义对象
|
|
@@ -84,7 +79,6 @@ export declare function definePluginEntry(definition: OctopiPluginDefinition): O
|
|
|
84
79
|
* Channel Plugin 定义
|
|
85
80
|
*
|
|
86
81
|
* 用于 channel 类型的 plugin。
|
|
87
|
-
* 对齐 OpenClaw 的 defineChannelPluginEntry。
|
|
88
82
|
*/
|
|
89
83
|
export interface OctopiChannelPluginDefinition extends OctopiPluginDefinition {
|
|
90
84
|
/** Channel ID */
|
|
@@ -93,8 +87,6 @@ export interface OctopiChannelPluginDefinition extends OctopiPluginDefinition {
|
|
|
93
87
|
/**
|
|
94
88
|
* 定义一个 Channel Plugin Entry
|
|
95
89
|
*
|
|
96
|
-
* 对齐 OpenClaw 的 defineChannelPluginEntry。
|
|
97
|
-
*
|
|
98
90
|
* @param definition - Channel Plugin 定义
|
|
99
91
|
* @returns Plugin 定义对象
|
|
100
92
|
*/
|