@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,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ChildRunPort — 子 Run 执行端口
|
|
3
|
+
*
|
|
4
|
+
* @layer harness/collaboration/delegation
|
|
5
|
+
* 设计权威:`arch/delegation.md` §10。
|
|
6
|
+
*
|
|
7
|
+
* 职责:把一个 `DelegateRequest` 变成一次**真实受监督的子 Run**,产出 `ChildRunOutput`。
|
|
8
|
+
*
|
|
9
|
+
* 不变量落点:
|
|
10
|
+
* - **D7** 子 Run 落**独立 Session**,带 `spawnBy` 父子关联(`SessionSpawnLink`)
|
|
11
|
+
* - **D8** 子 Run 走 `SessionAwareRunner.handle()` —— 该入口自带
|
|
12
|
+
* per-run `AgentContext` + `RunScope` + session 锁 + SessionGate + ACL,
|
|
13
|
+
* 因此**绝不写 `agent.context.messages`**(旧 multi-agent 路径的 I1 违规)
|
|
14
|
+
* - **D9** 并发硬闸仍只在 SessionGate 一处(委派层不建第二把闸)
|
|
15
|
+
*
|
|
16
|
+
* 与 transport 的分工:
|
|
17
|
+
* transport 管"怎么把请求送到目标"(进程内 / 将来跨进程);
|
|
18
|
+
* 本端口管"目标本地怎么起 Run"。两者不可互相渗透。
|
|
19
|
+
*/
|
|
20
|
+
import { emptyTokenUsage } from '@octopi-agent/core/types/turn.js';
|
|
21
|
+
/**
|
|
22
|
+
* 累加 turn 级 usage 到总账(决策 C2:归集到父的 run 账)
|
|
23
|
+
*
|
|
24
|
+
* @param total - 累计账本(原地更新)
|
|
25
|
+
* @param add - 本轮 usage
|
|
26
|
+
*/
|
|
27
|
+
function addUsage(total, add) {
|
|
28
|
+
if (!add)
|
|
29
|
+
return;
|
|
30
|
+
total.outputTokens += add.outputTokens ?? 0;
|
|
31
|
+
total.inputUncachedTokens += add.inputUncachedTokens ?? 0;
|
|
32
|
+
total.inputCachedTokens += add.inputCachedTokens ?? 0;
|
|
33
|
+
total.inputCacheWriteTokens += add.inputCacheWriteTokens ?? 0;
|
|
34
|
+
if (add.inputReportedTokens != null) {
|
|
35
|
+
total.inputReportedTokens = (total.inputReportedTokens ?? 0) + add.inputReportedTokens;
|
|
36
|
+
}
|
|
37
|
+
if (add.cacheAware)
|
|
38
|
+
total.cacheAware = true;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* RunnerChildRunPort — 以 `SessionAwareRunner.handle()` 起子 Run
|
|
42
|
+
*
|
|
43
|
+
* 保证 D7/D8/D9:独立 session、per-run 上下文、并发闸仍只在 SessionGate。
|
|
44
|
+
*/
|
|
45
|
+
export class RunnerChildRunPort {
|
|
46
|
+
config;
|
|
47
|
+
/**
|
|
48
|
+
* @param config - 目标解析与 session 存储
|
|
49
|
+
*/
|
|
50
|
+
constructor(config) {
|
|
51
|
+
this.config = config;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 起一次受监督的子 Run
|
|
55
|
+
*
|
|
56
|
+
* @param input - 子 Run 入参
|
|
57
|
+
* @param signal - 中止信号
|
|
58
|
+
* @returns 子 Run 产出
|
|
59
|
+
* @throws 目标不可运行,或 session 预创建失败
|
|
60
|
+
*/
|
|
61
|
+
async run(input, signal) {
|
|
62
|
+
const target = this.config.resolve(input.childAgentId);
|
|
63
|
+
if (!target) {
|
|
64
|
+
throw new Error(`delegate target not runnable: ${input.childAgentId}`);
|
|
65
|
+
}
|
|
66
|
+
// id 由服务方在起 Run 前生成并落库(D7);此处只消费,不生成
|
|
67
|
+
const childSessionId = input.childSessionId;
|
|
68
|
+
const childRunId = input.childRunId;
|
|
69
|
+
// D7:预创建 child session 并写入父子关联。
|
|
70
|
+
// 随后 `handle()` 会 load 到本 session(而非 createSession),spawnBy 得以保留。
|
|
71
|
+
await target.store.save(childSessionId, this.newChildSession(childSessionId, input));
|
|
72
|
+
const userText = input.context === 'fork' && input.parentMessages?.length
|
|
73
|
+
? `${renderForkHeader(input.parentMessages)}\n\n${input.task}\n\n${input.input}`
|
|
74
|
+
: `${input.task}\n\n${input.input}`;
|
|
75
|
+
const userMessage = {
|
|
76
|
+
role: 'user',
|
|
77
|
+
content: userText,
|
|
78
|
+
timestamp: Date.now(),
|
|
79
|
+
};
|
|
80
|
+
const runConfig = {
|
|
81
|
+
systemPrompt: input.systemPrompt,
|
|
82
|
+
agentId: input.childAgentId,
|
|
83
|
+
sessionId: childSessionId,
|
|
84
|
+
// D3:委派权利天花板,Runner 会与模板天花板取交集
|
|
85
|
+
rightsCeiling: input.rightsCeiling,
|
|
86
|
+
};
|
|
87
|
+
const usage = emptyTokenUsage();
|
|
88
|
+
let output;
|
|
89
|
+
let error;
|
|
90
|
+
let aborted = false;
|
|
91
|
+
const artifacts = [];
|
|
92
|
+
try {
|
|
93
|
+
for await (const event of target.runner.handle(childSessionId, userMessage, runConfig, signal)) {
|
|
94
|
+
switch (event.type) {
|
|
95
|
+
case 'turn.end': {
|
|
96
|
+
const data = event.data;
|
|
97
|
+
if (typeof data.content === 'string' && data.content.length > 0) {
|
|
98
|
+
output = data.content;
|
|
99
|
+
}
|
|
100
|
+
addUsage(usage, data.usage);
|
|
101
|
+
if (data.error != null && error == null) {
|
|
102
|
+
error = data.error instanceof Error ? data.error.message : String(data.error);
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case 'engine.error': {
|
|
107
|
+
const data = event.data;
|
|
108
|
+
const message = data.error instanceof Error ? data.error.message : String(data.error ?? 'unknown error');
|
|
109
|
+
error = message;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
default:
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
error = err instanceof Error ? err.message : String(err);
|
|
119
|
+
}
|
|
120
|
+
if (signal?.aborted)
|
|
121
|
+
aborted = true;
|
|
122
|
+
return {
|
|
123
|
+
childSessionId,
|
|
124
|
+
childRunId,
|
|
125
|
+
output,
|
|
126
|
+
...(artifacts.length > 0 ? { artifacts } : {}),
|
|
127
|
+
usage,
|
|
128
|
+
error: aborted ? (error ?? 'aborted') : error,
|
|
129
|
+
aborted,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/** 构造带 `spawnBy` 的 child session 骨架 */
|
|
133
|
+
newChildSession(sessionId, input) {
|
|
134
|
+
const timestamp = Date.now();
|
|
135
|
+
return {
|
|
136
|
+
id: sessionId,
|
|
137
|
+
agentId: input.childAgentId,
|
|
138
|
+
primaryAgentId: input.childAgentId,
|
|
139
|
+
spawnBy: { ...input.spawnBy },
|
|
140
|
+
meta: {
|
|
141
|
+
title: `delegation: ${input.task}`.slice(0, 120),
|
|
142
|
+
createdAt: timestamp,
|
|
143
|
+
updatedAt: timestamp,
|
|
144
|
+
status: 'idle',
|
|
145
|
+
},
|
|
146
|
+
messages: [],
|
|
147
|
+
turns: [],
|
|
148
|
+
metadata: { delegationId: input.delegationId },
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* 渲染 fork 模式的父历史前缀(§9.4:显式 `context: 'fork'` 才继承)
|
|
154
|
+
*
|
|
155
|
+
* @param parentMessages - 父消息历史(只取可序列化文本)
|
|
156
|
+
* @returns 前缀文本
|
|
157
|
+
*/
|
|
158
|
+
function renderForkHeader(parentMessages) {
|
|
159
|
+
const lines = parentMessages.map((m) => {
|
|
160
|
+
const msg = m;
|
|
161
|
+
const role = typeof msg?.role === 'string' ? msg.role : 'unknown';
|
|
162
|
+
const content = typeof msg?.content === 'string' ? msg.content : JSON.stringify(msg?.content ?? '');
|
|
163
|
+
return `- [${role}] ${content}`;
|
|
164
|
+
});
|
|
165
|
+
return [
|
|
166
|
+
'[Context Fork] 以下是从父会话分叉的上下文,供你理解任务背景:',
|
|
167
|
+
...lines,
|
|
168
|
+
].join('\n');
|
|
169
|
+
}
|
|
170
|
+
/** 缺省编排指令 */
|
|
171
|
+
export const DEFAULT_DELEGATION_DIRECTIVE = 'You are being delegated a task by a parent agent. ' +
|
|
172
|
+
'Work the task independently and end your run with a concise conclusion as your final message. ' +
|
|
173
|
+
'Do not wait for further instructions.';
|
|
174
|
+
/**
|
|
175
|
+
* 构造子的 systemPrompt(§9.4)
|
|
176
|
+
*
|
|
177
|
+
* @param options - persona 与编排指令
|
|
178
|
+
* @param parentAgentId - 父 agentId(进指令文本)
|
|
179
|
+
* @returns systemPrompt 文本
|
|
180
|
+
*/
|
|
181
|
+
export function buildChildSystemPrompt(options, parentAgentId) {
|
|
182
|
+
const directive = options.directive ?? DEFAULT_DELEGATION_DIRECTIVE;
|
|
183
|
+
return [options.persona, directive, `Delegating parent: ${parentAgentId}`]
|
|
184
|
+
.filter((s) => s && s.length > 0)
|
|
185
|
+
.join('\n\n');
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* 把 `ChildRunPort` 适配成 `LocalDelegateExecutor`(供 `InProcessTransport` 使用)
|
|
189
|
+
*
|
|
190
|
+
* @param port - 子 Run 执行端口
|
|
191
|
+
* @param options - systemPrompt 构造选项
|
|
192
|
+
* @param resolvePersona - 从 childAgentId 取 persona(缺省取空串)
|
|
193
|
+
* @returns transport 可用的执行器
|
|
194
|
+
*/
|
|
195
|
+
export function createChildRunExecutor(port, options, resolvePersona) {
|
|
196
|
+
return async (request, signal) => {
|
|
197
|
+
const childAgentId = request.to.agentId;
|
|
198
|
+
if (!childAgentId) {
|
|
199
|
+
return {
|
|
200
|
+
delegationId: request.delegationId,
|
|
201
|
+
status: 'failed',
|
|
202
|
+
error: 'delegate_request: unresolved target agentId',
|
|
203
|
+
schemaVersion: request.schemaVersion,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
const persona = resolvePersona?.(childAgentId) ?? options.persona;
|
|
207
|
+
const systemPrompt = buildChildSystemPrompt({ persona, directive: options.directive }, request.from.agentId);
|
|
208
|
+
const output = await port.run({
|
|
209
|
+
delegationId: request.delegationId,
|
|
210
|
+
childAgentId,
|
|
211
|
+
// D7:id 由服务方在起 Run 前生成并落库,此处透传
|
|
212
|
+
childSessionId: request.childSessionId,
|
|
213
|
+
childRunId: request.childRunId,
|
|
214
|
+
task: request.task,
|
|
215
|
+
input: request.input,
|
|
216
|
+
context: request.context,
|
|
217
|
+
parentMessages: request.parentMessages,
|
|
218
|
+
spawnBy: {
|
|
219
|
+
delegationId: request.delegationId,
|
|
220
|
+
parentAgentId: request.from.agentId,
|
|
221
|
+
parentSessionId: request.from.sessionId,
|
|
222
|
+
parentRunId: request.from.runId,
|
|
223
|
+
},
|
|
224
|
+
systemPrompt,
|
|
225
|
+
budget: request.budget,
|
|
226
|
+
rightsCeiling: request.rightsCeiling,
|
|
227
|
+
}, signal);
|
|
228
|
+
return {
|
|
229
|
+
delegationId: request.delegationId,
|
|
230
|
+
// 中止 ≠ 失败:cascade / cancel 落 cancelled,其余失败落 failed(补-2)
|
|
231
|
+
status: output.aborted ? 'cancelled' : output.error ? 'failed' : 'completed',
|
|
232
|
+
childSessionId: output.childSessionId,
|
|
233
|
+
childRunId: output.childRunId,
|
|
234
|
+
output: output.output,
|
|
235
|
+
artifacts: output.artifacts,
|
|
236
|
+
usage: output.usage,
|
|
237
|
+
error: output.error,
|
|
238
|
+
schemaVersion: request.schemaVersion,
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegation 模块统一导出
|
|
3
|
+
*
|
|
4
|
+
* @layer harness/collaboration/delegation
|
|
5
|
+
* 设计权威:`arch/delegation.md`。
|
|
6
|
+
*
|
|
7
|
+
* L2 委派契约层:`DelegateRequest` / `DelegateResult`(纯 JSON,D1/D5)
|
|
8
|
+
* + `AgentHandle`(D2 寻址)+ `DelegateTransport`(唯一分布式缝)。
|
|
9
|
+
*/
|
|
10
|
+
export type { Delegation, DelegationBudget, DelegationContextMode, DelegationEventType, DelegationParentRef, DelegationStatus, DelegationTarget, DelegateRequest, DelegateResult, AgentHandle, } from './types.js';
|
|
11
|
+
export { DELEGATION_SCHEMA_VERSION, DELEGATION_TERMINAL_STATUSES, DELEGATION_ACTIVE_STATUSES, DelegationEvents, isTerminalDelegationStatus, isActiveDelegationStatus, } from './types.js';
|
|
12
|
+
export type { AgentRegistry, AgentInfo, AgentQuery, AgentRelation, AgentRelationType, AgentDelegationPolicy, } from './registry-types.js';
|
|
13
|
+
export { AgentRegistryEvents } from './registry-types.js';
|
|
14
|
+
export { DefaultAgentRegistry } from './registry.js';
|
|
15
|
+
export { DelegationStore, canTransitionDelegation } from './store.js';
|
|
16
|
+
export type { CreateDelegationInput, UpdateDelegationPatch, DelegationListFilter, } from './store.js';
|
|
17
|
+
export { InProcessTransport, assertCompatibleSchema } from './transport.js';
|
|
18
|
+
export type { DelegateTransport, LocalDelegateExecutor } from './transport.js';
|
|
19
|
+
export { RunnerChildRunPort, createChildRunExecutor, buildChildSystemPrompt, DEFAULT_DELEGATION_DIRECTIVE, } from './child-run.js';
|
|
20
|
+
export type { ChildRunPort, ChildRunInput, ChildRunOutput, ChildRunTarget, RunnerChildRunPortConfig, DelegationPromptOptions, } from './child-run.js';
|
|
21
|
+
export { DelegateService, DelegateResolutionError, intersectBudget } from './service.js';
|
|
22
|
+
export type { DispatchDelegationInput, DispatchResult, DelegateServiceConfig, DelegationNotifier, } from './service.js';
|
|
23
|
+
export { createDelegationNotifier, renderDelegationNotice, delegationReason, } from './notifier.js';
|
|
24
|
+
export type { DelegationNotifierConfig } from './notifier.js';
|
|
25
|
+
export { wireDelegation, createDelegationRuntime } from './wiring.js';
|
|
26
|
+
export type { DelegatableAgent, DelegationRuntimeOptions, DelegationRuntime, } from './wiring.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegation 模块统一导出
|
|
3
|
+
*
|
|
4
|
+
* @layer harness/collaboration/delegation
|
|
5
|
+
* 设计权威:`arch/delegation.md`。
|
|
6
|
+
*
|
|
7
|
+
* L2 委派契约层:`DelegateRequest` / `DelegateResult`(纯 JSON,D1/D5)
|
|
8
|
+
* + `AgentHandle`(D2 寻址)+ `DelegateTransport`(唯一分布式缝)。
|
|
9
|
+
*/
|
|
10
|
+
export { DELEGATION_SCHEMA_VERSION, DELEGATION_TERMINAL_STATUSES, DELEGATION_ACTIVE_STATUSES, DelegationEvents, isTerminalDelegationStatus, isActiveDelegationStatus, } from './types.js';
|
|
11
|
+
export { AgentRegistryEvents } from './registry-types.js';
|
|
12
|
+
// ── Registry 实现 ──
|
|
13
|
+
export { DefaultAgentRegistry } from './registry.js';
|
|
14
|
+
// ── Store ──
|
|
15
|
+
export { DelegationStore, canTransitionDelegation } from './store.js';
|
|
16
|
+
// ── Transport ──
|
|
17
|
+
export { InProcessTransport, assertCompatibleSchema } from './transport.js';
|
|
18
|
+
// ── Child Run(子 Run 执行端口,D7/D8/D9) ──
|
|
19
|
+
export { RunnerChildRunPort, createChildRunExecutor, buildChildSystemPrompt, DEFAULT_DELEGATION_DIRECTIVE, } from './child-run.js';
|
|
20
|
+
// ── Service ──
|
|
21
|
+
export { DelegateService, DelegateResolutionError, intersectBudget } from './service.js';
|
|
22
|
+
// ── notify 通道(§7.1) ──
|
|
23
|
+
export { createDelegationNotifier, renderDelegationNotice, delegationReason, } from './notifier.js';
|
|
24
|
+
// ── 生产接线 ──
|
|
25
|
+
export { wireDelegation, createDelegationRuntime } from './wiring.js';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DelegationNotifier — notify 通道投递器
|
|
3
|
+
*
|
|
4
|
+
* @layer harness/collaboration/delegation
|
|
5
|
+
* 设计权威:`arch/delegation.md` §7.1。
|
|
6
|
+
*
|
|
7
|
+
* 子 Run 终态 → 写 `DelegationStore`(已由 service 完成)→ **本模块投递**
|
|
8
|
+
* → `emitAgentSignal` → `AgentSignalSource` → `AgentRuntime.dispatch`
|
|
9
|
+
* → Compiler 编译成 user 消息进父 session 队列。
|
|
10
|
+
*
|
|
11
|
+
* **复用既有 Trigger 模型,不新造父子通道**(`arch/agent-runtime.md`)。
|
|
12
|
+
*
|
|
13
|
+
* 不打断父 Run:同 session 运行中再来 Trigger 由 Runner FIFO 锁排队,
|
|
14
|
+
* 禁止在调用链上 await(`arch/agent-runtime.md` 重入策略)。
|
|
15
|
+
*/
|
|
16
|
+
import type { EventBus } from '@octopi-agent/core/primitives/event-bus.js';
|
|
17
|
+
import type { Delegation } from './types.js';
|
|
18
|
+
import type { DelegationNotifier } from './service.js';
|
|
19
|
+
/** notify 投递器配置 */
|
|
20
|
+
export interface DelegationNotifierConfig {
|
|
21
|
+
/** 事件总线(须与挂载 `AgentSignalSource` 的总线同一条) */
|
|
22
|
+
events: EventBus;
|
|
23
|
+
/** 自定义内容渲染(缺省用 `renderDelegationNotice`) */
|
|
24
|
+
render?: (delegation: Delegation) => string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 渲染委派终态通知(§7.1:`<delegation_completed …/>`)
|
|
28
|
+
*
|
|
29
|
+
* @param delegation - 终态委派单
|
|
30
|
+
* @returns 通知文本
|
|
31
|
+
*/
|
|
32
|
+
export declare function renderDelegationNotice(delegation: Delegation): string;
|
|
33
|
+
/** 委派终态 → notify 通道 reason */
|
|
34
|
+
export declare function delegationReason(delegation: Delegation): string;
|
|
35
|
+
/**
|
|
36
|
+
* 创建 notify 投递器
|
|
37
|
+
*
|
|
38
|
+
* 投递前提:总线上有存活的 `AgentSignalSource` 接收端。`bus.emit` 对有无监听者
|
|
39
|
+
* 零反馈,不校验就会把发进空总线的通知误标已送达(2026-10-22 断链根因)。
|
|
40
|
+
* 无接收端时抛出,由 `DelegateService.notify` 按投递失败处理(留 `deliveryState` 为 pending
|
|
41
|
+
* 给状态提示兜底并打 warn)。
|
|
42
|
+
*
|
|
43
|
+
* @param config - 事件总线与渲染器
|
|
44
|
+
* @returns 可注入 `DelegateServiceConfig.notifier` 的投递器
|
|
45
|
+
*/
|
|
46
|
+
export declare function createDelegationNotifier(config: DelegationNotifierConfig): DelegationNotifier;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DelegationNotifier — notify 通道投递器
|
|
3
|
+
*
|
|
4
|
+
* @layer harness/collaboration/delegation
|
|
5
|
+
* 设计权威:`arch/delegation.md` §7.1。
|
|
6
|
+
*
|
|
7
|
+
* 子 Run 终态 → 写 `DelegationStore`(已由 service 完成)→ **本模块投递**
|
|
8
|
+
* → `emitAgentSignal` → `AgentSignalSource` → `AgentRuntime.dispatch`
|
|
9
|
+
* → Compiler 编译成 user 消息进父 session 队列。
|
|
10
|
+
*
|
|
11
|
+
* **复用既有 Trigger 模型,不新造父子通道**(`arch/agent-runtime.md`)。
|
|
12
|
+
*
|
|
13
|
+
* 不打断父 Run:同 session 运行中再来 Trigger 由 Runner FIFO 锁排队,
|
|
14
|
+
* 禁止在调用链上 await(`arch/agent-runtime.md` 重入策略)。
|
|
15
|
+
*/
|
|
16
|
+
import { emitAgentSignal, hasAgentSignalReceiver, } from '../../activation/sources/agent-signal.js';
|
|
17
|
+
/**
|
|
18
|
+
* 渲染委派终态通知(§7.1:`<delegation_completed …/>`)
|
|
19
|
+
*
|
|
20
|
+
* @param delegation - 终态委派单
|
|
21
|
+
* @returns 通知文本
|
|
22
|
+
*/
|
|
23
|
+
export function renderDelegationNotice(delegation) {
|
|
24
|
+
const attrs = [
|
|
25
|
+
`id="${escapeAttr(delegation.id)}"`,
|
|
26
|
+
`status="${delegation.status}"`,
|
|
27
|
+
`agent="${escapeAttr(delegation.resolvedAgentId ?? delegation.target.agentId ?? '')}"`,
|
|
28
|
+
`task="${escapeAttr(truncate(delegation.task, 120))}"`,
|
|
29
|
+
];
|
|
30
|
+
const body = [];
|
|
31
|
+
if (delegation.output) {
|
|
32
|
+
body.push(`<output>${escapeText(truncate(delegation.output, 4000))}</output>`);
|
|
33
|
+
}
|
|
34
|
+
if (delegation.error) {
|
|
35
|
+
body.push(`<error>${escapeText(truncate(delegation.error, 1000))}</error>`);
|
|
36
|
+
}
|
|
37
|
+
if (delegation.artifacts?.length) {
|
|
38
|
+
body.push(`<artifacts>${delegation.artifacts.map((a) => escapeText(a)).join(', ')}</artifacts>`);
|
|
39
|
+
}
|
|
40
|
+
const tag = delegation.status === 'completed' ? 'delegation_completed' : 'delegation_failed';
|
|
41
|
+
return body.length > 0
|
|
42
|
+
? `<${tag} ${attrs.join(' ')}>${body.join('')}</${tag}>`
|
|
43
|
+
: `<${tag} ${attrs.join(' ')}/>`;
|
|
44
|
+
}
|
|
45
|
+
/** 委派终态 → notify 通道 reason */
|
|
46
|
+
export function delegationReason(delegation) {
|
|
47
|
+
return delegation.status === 'completed' ? 'delegation_completed' : `delegation_${delegation.status}`;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 创建 notify 投递器
|
|
51
|
+
*
|
|
52
|
+
* 投递前提:总线上有存活的 `AgentSignalSource` 接收端。`bus.emit` 对有无监听者
|
|
53
|
+
* 零反馈,不校验就会把发进空总线的通知误标已送达(2026-10-22 断链根因)。
|
|
54
|
+
* 无接收端时抛出,由 `DelegateService.notify` 按投递失败处理(留 `deliveryState` 为 pending
|
|
55
|
+
* 给状态提示兜底并打 warn)。
|
|
56
|
+
*
|
|
57
|
+
* @param config - 事件总线与渲染器
|
|
58
|
+
* @returns 可注入 `DelegateServiceConfig.notifier` 的投递器
|
|
59
|
+
*/
|
|
60
|
+
export function createDelegationNotifier(config) {
|
|
61
|
+
const render = config.render ?? renderDelegationNotice;
|
|
62
|
+
return (delegation) => {
|
|
63
|
+
if (!hasAgentSignalReceiver(config.events)) {
|
|
64
|
+
throw new Error('delegation notify not delivered: no AgentSignalSource receiver on the bus');
|
|
65
|
+
}
|
|
66
|
+
emitAgentSignal(config.events, {
|
|
67
|
+
fromAgentId: delegation.resolvedAgentId ?? delegation.target.agentId ?? 'child',
|
|
68
|
+
toAgentId: delegation.parent.agentId,
|
|
69
|
+
sessionId: delegation.parent.sessionId,
|
|
70
|
+
payload: { kind: 'system_note', content: render(delegation) },
|
|
71
|
+
reason: delegationReason(delegation),
|
|
72
|
+
delegationId: delegation.id,
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function truncate(text, max) {
|
|
77
|
+
return text.length <= max ? text : `${text.slice(0, max)}…`;
|
|
78
|
+
}
|
|
79
|
+
function escapeAttr(value) {
|
|
80
|
+
return value.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<');
|
|
81
|
+
}
|
|
82
|
+
function escapeText(value) {
|
|
83
|
+
return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
84
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentRegistry — Agent 注册与发现契约(L2 委派契约层)
|
|
3
|
+
*
|
|
4
|
+
* @layer harness/collaboration/delegation
|
|
5
|
+
* 设计权威:`arch/delegation.md` §12.1。
|
|
6
|
+
*
|
|
7
|
+
* **迁移说明**:本契约原居 `collaboration/multi-agent/agent-registry-types.ts`,
|
|
8
|
+
* 随旧 multi-agent 实现(`swarm.ts` / `process.ts`)一并重构。契约**保留**并扩展:
|
|
9
|
+
* `arch/agent-runtime.md` 多 Agent 模型规划的 v2 `CapabilityRouter` 对接
|
|
10
|
+
* `AgentRegistry.findByTrait`,删掉会堵死 Runtime 的路由扩展。
|
|
11
|
+
*
|
|
12
|
+
* 设计原则(沿用原契约):
|
|
13
|
+
* - 契约与实现分离:本文件只有类型与常量,不含实现
|
|
14
|
+
* - 跨域只 import 本文件 types,不 import 实现
|
|
15
|
+
* - 支持按能力(capability)发现 Agent
|
|
16
|
+
* - 支持 Agent 上下线通知
|
|
17
|
+
* - 支持 Agent 拓扑描述
|
|
18
|
+
*
|
|
19
|
+
* 新增(`arch/delegation.md` §9.2):
|
|
20
|
+
* - `AgentInfo.delegation` — 委派策略(可否被委派、递归深度、权利天花板、预算)
|
|
21
|
+
*/
|
|
22
|
+
import type { SessionRights } from '../../governance/session-acl/types.js';
|
|
23
|
+
import type { DelegationBudget } from './types.js';
|
|
24
|
+
/**
|
|
25
|
+
* Agent 的委派策略。
|
|
26
|
+
*
|
|
27
|
+
* 静态可审计:工具面/权限面由 AgentConfig 固定,父 agent 不得现场改写(§9.3 不做 ad-hoc)。
|
|
28
|
+
*
|
|
29
|
+
* **缺省语义**:未声明 `delegation` 的 agent 等价于 `DEFAULT_DELEGATION_POLICY`
|
|
30
|
+
* ——**缺省默认具备委派能力**(可被委派、可发委派、限一层)。
|
|
31
|
+
* 要关闭必须显式写 `callable: false` / `canDelegate: false`。
|
|
32
|
+
* 一律经 `effectiveDelegationPolicy()` 取生效值,不要直接读字段。
|
|
33
|
+
*/
|
|
34
|
+
export interface AgentDelegationPolicy {
|
|
35
|
+
/** 能否被委派(默认 **true**;显式 false = 只能被用户直接对话) */
|
|
36
|
+
callable: boolean;
|
|
37
|
+
/** 允许哪些 agentId 调我(缺省 = 任意) */
|
|
38
|
+
callableBy?: string[];
|
|
39
|
+
/** 我能不能再委派(默认 **true**) */
|
|
40
|
+
canDelegate: boolean;
|
|
41
|
+
/** 递归上限(缺省 = **1**,即子不能再派;§10.4 成本/爆炸半径兜底) */
|
|
42
|
+
maxDepth?: number;
|
|
43
|
+
/** 被委派时的权利天花板(D3:只能收紧不能放宽) */
|
|
44
|
+
rightsCeiling?: SessionRights;
|
|
45
|
+
/** 委派预算上限(请求预算与此取交集) */
|
|
46
|
+
budget?: DelegationBudget;
|
|
47
|
+
}
|
|
48
|
+
/** Agent 注册信息 */
|
|
49
|
+
export interface AgentInfo {
|
|
50
|
+
/** Agent 唯一 ID */
|
|
51
|
+
id: string;
|
|
52
|
+
/** Agent 名称(人类可读) */
|
|
53
|
+
name: string;
|
|
54
|
+
/** Agent 描述 */
|
|
55
|
+
description?: string;
|
|
56
|
+
/** Agent 特质标签(供按特质发现;`AgentConfig.traits` 落点);无权限语义 */
|
|
57
|
+
traits: string[];
|
|
58
|
+
/** 委派策略(§9.2);整段可省略 = 用 DEFAULT_DELEGATION_POLICY(委派默认开启)*/
|
|
59
|
+
delegation?: AgentDelegationPolicy;
|
|
60
|
+
/** Agent 元数据(必须可序列化) */
|
|
61
|
+
metadata?: Record<string, unknown>;
|
|
62
|
+
/** 注册时间 */
|
|
63
|
+
registeredAt: number;
|
|
64
|
+
/** 最后活跃时间 */
|
|
65
|
+
lastActiveAt: number;
|
|
66
|
+
/** Agent 状态 */
|
|
67
|
+
status: 'active' | 'idle' | 'busy' | 'offline';
|
|
68
|
+
}
|
|
69
|
+
/** Agent 查询条件 */
|
|
70
|
+
export interface AgentQuery {
|
|
71
|
+
/** 按特质过滤 */
|
|
72
|
+
traits?: string[];
|
|
73
|
+
/** 按状态过滤 */
|
|
74
|
+
status?: AgentInfo['status'];
|
|
75
|
+
/** 按元数据过滤 */
|
|
76
|
+
metadata?: Record<string, unknown>;
|
|
77
|
+
/** 仅返回可被委派的 Agent(delegation.callable === true) */
|
|
78
|
+
callableOnly?: boolean;
|
|
79
|
+
/** 按可被指定 caller 委派过滤(校验 delegation.callableBy) */
|
|
80
|
+
callableBy?: string;
|
|
81
|
+
}
|
|
82
|
+
/** Agent 间关系类型 */
|
|
83
|
+
export type AgentRelationType = 'peer' | 'superior' | 'subordinate' | 'pipeline' | 'depends';
|
|
84
|
+
/** Agent 间关系 */
|
|
85
|
+
export interface AgentRelation {
|
|
86
|
+
/** 关系来源 Agent */
|
|
87
|
+
from: string;
|
|
88
|
+
/** 关系目标 Agent */
|
|
89
|
+
to: string;
|
|
90
|
+
/** 关系类型 */
|
|
91
|
+
type: AgentRelationType;
|
|
92
|
+
/** 关系元数据 */
|
|
93
|
+
metadata?: Record<string, unknown>;
|
|
94
|
+
}
|
|
95
|
+
export declare const AgentRegistryEvents: {
|
|
96
|
+
/** Agent 注册 */
|
|
97
|
+
readonly AGENT_REGISTERED: "registry.agent.registered";
|
|
98
|
+
/** Agent 注销 */
|
|
99
|
+
readonly AGENT_UNREGISTERED: "registry.agent.unregistered";
|
|
100
|
+
/** Agent 状态变更 */
|
|
101
|
+
readonly AGENT_STATUS_CHANGED: "registry.agent.status_changed";
|
|
102
|
+
/** 关系添加 */
|
|
103
|
+
readonly RELATION_ADDED: "registry.relation.added";
|
|
104
|
+
/** 关系移除 */
|
|
105
|
+
readonly RELATION_REMOVED: "registry.relation.removed";
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* AgentRegistry 接口
|
|
109
|
+
*
|
|
110
|
+
* Agent 注册与发现的核心契约。
|
|
111
|
+
*/
|
|
112
|
+
export interface AgentRegistry {
|
|
113
|
+
/**
|
|
114
|
+
* 注册 Agent
|
|
115
|
+
*
|
|
116
|
+
* @param info - Agent 信息
|
|
117
|
+
*/
|
|
118
|
+
register(info: Omit<AgentInfo, 'registeredAt' | 'lastActiveAt'>): void;
|
|
119
|
+
/**
|
|
120
|
+
* 注销 Agent
|
|
121
|
+
*
|
|
122
|
+
* @param agentId - Agent ID
|
|
123
|
+
* @returns 是否成功注销
|
|
124
|
+
*/
|
|
125
|
+
unregister(agentId: string): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* 获取 Agent 信息
|
|
128
|
+
*
|
|
129
|
+
* @param agentId - Agent ID
|
|
130
|
+
* @returns Agent 信息,不存在返回 undefined
|
|
131
|
+
*/
|
|
132
|
+
get(agentId: string): AgentInfo | undefined;
|
|
133
|
+
/**
|
|
134
|
+
* 查询 Agent
|
|
135
|
+
*
|
|
136
|
+
* @param query - 查询条件
|
|
137
|
+
* @returns 匹配的 Agent 列表
|
|
138
|
+
*/
|
|
139
|
+
query(query: AgentQuery): AgentInfo[];
|
|
140
|
+
/**
|
|
141
|
+
* 列出所有已注册 Agent
|
|
142
|
+
*/
|
|
143
|
+
list(): AgentInfo[];
|
|
144
|
+
/**
|
|
145
|
+
* 更新 Agent 状态
|
|
146
|
+
*
|
|
147
|
+
* @param agentId - Agent ID
|
|
148
|
+
* @param status - 新状态
|
|
149
|
+
*/
|
|
150
|
+
updateStatus(agentId: string, status: AgentInfo['status']): void;
|
|
151
|
+
/**
|
|
152
|
+
* 更新 Agent 活跃时间
|
|
153
|
+
*
|
|
154
|
+
* @param agentId - Agent ID
|
|
155
|
+
*/
|
|
156
|
+
touch(agentId: string): void;
|
|
157
|
+
/**
|
|
158
|
+
* 添加 Agent 间关系
|
|
159
|
+
*
|
|
160
|
+
* @param relation - 关系描述
|
|
161
|
+
*/
|
|
162
|
+
addRelation(relation: AgentRelation): void;
|
|
163
|
+
/**
|
|
164
|
+
* 移除 Agent 间关系
|
|
165
|
+
*
|
|
166
|
+
* @param from - 来源 Agent ID
|
|
167
|
+
* @param to - 目标 Agent ID
|
|
168
|
+
* @param type - 关系类型(不传则移除所有关系)
|
|
169
|
+
*/
|
|
170
|
+
removeRelation(from: string, to: string, type?: AgentRelationType): void;
|
|
171
|
+
/**
|
|
172
|
+
* 获取 Agent 的所有关系
|
|
173
|
+
*
|
|
174
|
+
* @param agentId - Agent ID
|
|
175
|
+
* @returns 关系列表
|
|
176
|
+
*/
|
|
177
|
+
getRelations(agentId: string): AgentRelation[];
|
|
178
|
+
/**
|
|
179
|
+
* 查找具有特定特质的 Agent
|
|
180
|
+
*
|
|
181
|
+
* @param trait - 特质标签
|
|
182
|
+
* @returns 具备该特质的 Agent 列表
|
|
183
|
+
*/
|
|
184
|
+
findByTrait(trait: string): AgentInfo[];
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* 缺省委派策略(`arch/delegation.md` §9.2)。
|
|
188
|
+
*
|
|
189
|
+
* agent **缺省默认具备委派能力**:可被委派、可发委派,但**只准一层**
|
|
190
|
+
* (`maxDepth: 1` = 我能派子,子不能再派)。默认开启委派时,
|
|
191
|
+
* 递归层数是唯一能自动限住 runaway 的旋钮,故这里必须收紧。
|
|
192
|
+
*/
|
|
193
|
+
export declare const DEFAULT_DELEGATION_POLICY: AgentDelegationPolicy;
|
|
194
|
+
/**
|
|
195
|
+
* 取 agent 的**生效**委派策略(未声明即用缺省)
|
|
196
|
+
*
|
|
197
|
+
* @param delegation - agent 声明的策略,可缺省
|
|
198
|
+
* @returns 生效策略(永远不是 undefined)
|
|
199
|
+
*/
|
|
200
|
+
export declare function effectiveDelegationPolicy(delegation: AgentDelegationPolicy | undefined): AgentDelegationPolicy;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentRegistry — Agent 注册与发现契约(L2 委派契约层)
|
|
3
|
+
*
|
|
4
|
+
* @layer harness/collaboration/delegation
|
|
5
|
+
* 设计权威:`arch/delegation.md` §12.1。
|
|
6
|
+
*
|
|
7
|
+
* **迁移说明**:本契约原居 `collaboration/multi-agent/agent-registry-types.ts`,
|
|
8
|
+
* 随旧 multi-agent 实现(`swarm.ts` / `process.ts`)一并重构。契约**保留**并扩展:
|
|
9
|
+
* `arch/agent-runtime.md` 多 Agent 模型规划的 v2 `CapabilityRouter` 对接
|
|
10
|
+
* `AgentRegistry.findByTrait`,删掉会堵死 Runtime 的路由扩展。
|
|
11
|
+
*
|
|
12
|
+
* 设计原则(沿用原契约):
|
|
13
|
+
* - 契约与实现分离:本文件只有类型与常量,不含实现
|
|
14
|
+
* - 跨域只 import 本文件 types,不 import 实现
|
|
15
|
+
* - 支持按能力(capability)发现 Agent
|
|
16
|
+
* - 支持 Agent 上下线通知
|
|
17
|
+
* - 支持 Agent 拓扑描述
|
|
18
|
+
*
|
|
19
|
+
* 新增(`arch/delegation.md` §9.2):
|
|
20
|
+
* - `AgentInfo.delegation` — 委派策略(可否被委派、递归深度、权利天花板、预算)
|
|
21
|
+
*/
|
|
22
|
+
// ── 事件 ──
|
|
23
|
+
export const AgentRegistryEvents = {
|
|
24
|
+
/** Agent 注册 */
|
|
25
|
+
AGENT_REGISTERED: 'registry.agent.registered',
|
|
26
|
+
/** Agent 注销 */
|
|
27
|
+
AGENT_UNREGISTERED: 'registry.agent.unregistered',
|
|
28
|
+
/** Agent 状态变更 */
|
|
29
|
+
AGENT_STATUS_CHANGED: 'registry.agent.status_changed',
|
|
30
|
+
/** 关系添加 */
|
|
31
|
+
RELATION_ADDED: 'registry.relation.added',
|
|
32
|
+
/** 关系移除 */
|
|
33
|
+
RELATION_REMOVED: 'registry.relation.removed',
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* 缺省委派策略(`arch/delegation.md` §9.2)。
|
|
37
|
+
*
|
|
38
|
+
* agent **缺省默认具备委派能力**:可被委派、可发委派,但**只准一层**
|
|
39
|
+
* (`maxDepth: 1` = 我能派子,子不能再派)。默认开启委派时,
|
|
40
|
+
* 递归层数是唯一能自动限住 runaway 的旋钮,故这里必须收紧。
|
|
41
|
+
*/
|
|
42
|
+
export const DEFAULT_DELEGATION_POLICY = {
|
|
43
|
+
callable: true,
|
|
44
|
+
canDelegate: true,
|
|
45
|
+
maxDepth: 1,
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* 取 agent 的**生效**委派策略(未声明即用缺省)
|
|
49
|
+
*
|
|
50
|
+
* @param delegation - agent 声明的策略,可缺省
|
|
51
|
+
* @returns 生效策略(永远不是 undefined)
|
|
52
|
+
*/
|
|
53
|
+
export function effectiveDelegationPolicy(delegation) {
|
|
54
|
+
if (!delegation)
|
|
55
|
+
return { ...DEFAULT_DELEGATION_POLICY };
|
|
56
|
+
return {
|
|
57
|
+
...DEFAULT_DELEGATION_POLICY,
|
|
58
|
+
...delegation,
|
|
59
|
+
maxDepth: delegation.maxDepth ?? DEFAULT_DELEGATION_POLICY.maxDepth,
|
|
60
|
+
};
|
|
61
|
+
}
|