@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
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Effective rights math (E6) + role catalog merge.
|
|
3
3
|
*/
|
|
4
4
|
import { BUILTIN_SESSION_ROLES, L0_SESSION_RIGHTS_FLOOR } from './seed-roles.js';
|
|
5
|
+
import { intersectToolRights, toolRightsExceeds, } from './tool-rights.js';
|
|
5
6
|
const READ_SCOPE_RANK = {
|
|
6
7
|
none: 0,
|
|
7
8
|
summary_tail: 1,
|
|
@@ -22,6 +23,7 @@ export function intersectRights(a, b) {
|
|
|
22
23
|
writeMemory: a.writeMemory && b.writeMemory,
|
|
23
24
|
canManageTasks: a.canManageTasks && b.canManageTasks,
|
|
24
25
|
canHandoff: a.canHandoff && b.canHandoff,
|
|
26
|
+
toolRights: intersectToolRights(a.toolRights, b.toolRights),
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
@@ -29,20 +31,24 @@ export function intersectRights(a, b) {
|
|
|
29
31
|
*
|
|
30
32
|
* Binding fields that are set **replace** defaults (then clamped to max/L0/agentMax).
|
|
31
33
|
* Binding may raise a default toward role.max; it may not exceed max (clamped later).
|
|
34
|
+
* `toolRights` is narrow-only at merge time via later intersection with ceilings.
|
|
32
35
|
*
|
|
33
36
|
* @param base - role defaults
|
|
34
37
|
* @param overlay - participant override
|
|
35
38
|
* @returns merged rights (not yet clamped to max)
|
|
36
39
|
*/
|
|
37
40
|
export function applyRightsOverlay(base, overlay) {
|
|
38
|
-
if (!overlay)
|
|
39
|
-
return { ...base };
|
|
41
|
+
if (!overlay) {
|
|
42
|
+
return { ...base, toolRights: intersectToolRights(undefined, base.toolRights) };
|
|
43
|
+
}
|
|
40
44
|
return {
|
|
41
45
|
canRun: overlay.canRun ?? base.canRun,
|
|
42
46
|
readScope: overlay.readScope ?? base.readScope,
|
|
43
47
|
writeMemory: overlay.writeMemory ?? base.writeMemory,
|
|
44
48
|
canManageTasks: overlay.canManageTasks ?? base.canManageTasks,
|
|
45
49
|
canHandoff: overlay.canHandoff ?? base.canHandoff,
|
|
50
|
+
// SEC-2 toolRights are narrow-only: overlay intersects base (never expands).
|
|
51
|
+
toolRights: intersectToolRights(base.toolRights, overlay.toolRights),
|
|
46
52
|
};
|
|
47
53
|
}
|
|
48
54
|
/**
|
|
@@ -57,7 +63,8 @@ export function exceedsRightsCeiling(value, ceiling) {
|
|
|
57
63
|
READ_SCOPE_RANK[value.readScope] > READ_SCOPE_RANK[ceiling.readScope] ||
|
|
58
64
|
(value.writeMemory && !ceiling.writeMemory) ||
|
|
59
65
|
(value.canManageTasks && !ceiling.canManageTasks) ||
|
|
60
|
-
(value.canHandoff && !ceiling.canHandoff)
|
|
66
|
+
(value.canHandoff && !ceiling.canHandoff) ||
|
|
67
|
+
toolRightsExceeds(value.toolRights, ceiling.toolRights));
|
|
61
68
|
}
|
|
62
69
|
/**
|
|
63
70
|
* Role catalog: builtin seeds + config overrides/additions.
|
|
@@ -70,18 +77,41 @@ export class SessionRoleCatalog {
|
|
|
70
77
|
* @param config - sessionAcl config; omitted → builtin only
|
|
71
78
|
*/
|
|
72
79
|
constructor(config) {
|
|
80
|
+
// Preserve deny-all `allow: []`; empty config allow stays unrestricted.
|
|
81
|
+
const copyFull = (r) => ({
|
|
82
|
+
...r,
|
|
83
|
+
toolRights: intersectToolRights(undefined, r.toolRights),
|
|
84
|
+
});
|
|
85
|
+
// max.toolRights omitted → inherit defaults (do not silently open the ceiling)
|
|
86
|
+
const copyMax = (max, defaults) => {
|
|
87
|
+
if (!max)
|
|
88
|
+
return copyFull(defaults);
|
|
89
|
+
const m = copyFull(max);
|
|
90
|
+
if (max.toolRights === undefined) {
|
|
91
|
+
m.toolRights = intersectToolRights(undefined, defaults.toolRights);
|
|
92
|
+
}
|
|
93
|
+
return m;
|
|
94
|
+
};
|
|
73
95
|
for (const role of BUILTIN_SESSION_ROLES) {
|
|
74
|
-
|
|
96
|
+
const defaults = copyFull(role.defaults);
|
|
97
|
+
this.roles.set(role.id, {
|
|
98
|
+
...role,
|
|
99
|
+
defaults,
|
|
100
|
+
max: copyMax(role.max, role.defaults),
|
|
101
|
+
});
|
|
75
102
|
}
|
|
76
103
|
if (config?.roles) {
|
|
77
104
|
for (const role of config.roles) {
|
|
78
105
|
const prev = this.roles.get(role.id);
|
|
106
|
+
const defaults = copyFull(role.defaults);
|
|
79
107
|
this.roles.set(role.id, {
|
|
80
108
|
id: role.id,
|
|
81
109
|
description: role.description ?? prev?.description,
|
|
82
110
|
isBuiltin: prev?.isBuiltin ?? false,
|
|
83
|
-
defaults
|
|
84
|
-
max: role.max
|
|
111
|
+
defaults,
|
|
112
|
+
max: role.max
|
|
113
|
+
? copyMax(role.max, role.defaults)
|
|
114
|
+
: (prev?.max ? copyFull(prev.max) : copyMax(undefined, role.defaults)),
|
|
85
115
|
});
|
|
86
116
|
}
|
|
87
117
|
}
|
|
@@ -131,12 +161,64 @@ export function computeEffectiveRights(input) {
|
|
|
131
161
|
writeMemory: input.agentMax?.writeMemory ?? true,
|
|
132
162
|
canManageTasks: input.agentMax?.canManageTasks ?? true,
|
|
133
163
|
canHandoff: input.agentMax?.canHandoff ?? true,
|
|
164
|
+
// undefined → unrestricted; preserve explicit allow:[] deny-all
|
|
165
|
+
toolRights: intersectToolRights(undefined, input.agentMax?.toolRights),
|
|
134
166
|
};
|
|
135
167
|
// L0:canHandoff 不是永久 false 交集项;由引擎策略 + role.max 决定(I3)
|
|
136
168
|
const l0 = {
|
|
137
169
|
...L0_SESSION_RIGHTS_FLOOR,
|
|
170
|
+
toolRights: intersectToolRights(undefined, L0_SESSION_RIGHTS_FLOOR.toolRights),
|
|
138
171
|
canHandoff: input.allowAgentInitiatedHandoff === true,
|
|
139
172
|
};
|
|
140
|
-
const
|
|
173
|
+
const roleMaxFull = {
|
|
174
|
+
...roleMax,
|
|
175
|
+
toolRights: intersectToolRights(undefined, roleMax.toolRights),
|
|
176
|
+
};
|
|
177
|
+
const effective = intersectRights(intersectRights(intersectRights(l0, roleMaxFull), agentCeiling), merged);
|
|
141
178
|
return effective;
|
|
142
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* readScope 从宽到严的次序(越靠后越受限)
|
|
182
|
+
*
|
|
183
|
+
* `arch/delegation.md` D3:子的 rights 只能收紧不能放宽。
|
|
184
|
+
*/
|
|
185
|
+
const READ_SCOPE_ORDER = ['full', 'from_grant', 'summary_tail', 'none'];
|
|
186
|
+
/**
|
|
187
|
+
* 取两个 `SessionRights` 中**更严**的一侧(逐轴收紧)
|
|
188
|
+
*
|
|
189
|
+
* 用于叠加一个额外的权利天花板(如委派时传入的 `rightsCeiling`,`arch/delegation.md` D3):
|
|
190
|
+
* 结果在每一根轴上都不宽于任一入参。缺省轴(undefined)表示该轴无额外限制,不参与收紧。
|
|
191
|
+
*
|
|
192
|
+
* @param a - 第一层天花板(可缺省)
|
|
193
|
+
* @param b - 第二层天花板(可缺省)
|
|
194
|
+
* @returns 收紧后的天花板;两者皆缺省时返回 undefined
|
|
195
|
+
*/
|
|
196
|
+
export function tightenSessionRights(a, b) {
|
|
197
|
+
if (!a)
|
|
198
|
+
return b ? { ...b } : undefined;
|
|
199
|
+
if (!b)
|
|
200
|
+
return { ...a };
|
|
201
|
+
const pickBool = (x, y) => {
|
|
202
|
+
if (x === undefined)
|
|
203
|
+
return y;
|
|
204
|
+
if (y === undefined)
|
|
205
|
+
return x;
|
|
206
|
+
return x && y;
|
|
207
|
+
};
|
|
208
|
+
const pickScope = (x, y) => {
|
|
209
|
+
if (x === undefined)
|
|
210
|
+
return y;
|
|
211
|
+
if (y === undefined)
|
|
212
|
+
return x;
|
|
213
|
+
// 下标越大越受限
|
|
214
|
+
return READ_SCOPE_ORDER.indexOf(x) >= READ_SCOPE_ORDER.indexOf(y) ? x : y;
|
|
215
|
+
};
|
|
216
|
+
return {
|
|
217
|
+
canRun: pickBool(a.canRun, b.canRun),
|
|
218
|
+
readScope: pickScope(a.readScope, b.readScope),
|
|
219
|
+
writeMemory: pickBool(a.writeMemory, b.writeMemory),
|
|
220
|
+
canManageTasks: pickBool(a.canManageTasks, b.canManageTasks),
|
|
221
|
+
canHandoff: pickBool(a.canHandoff, b.canHandoff),
|
|
222
|
+
toolRights: intersectToolRights(a.toolRights, b.toolRights),
|
|
223
|
+
};
|
|
224
|
+
}
|
|
@@ -4,7 +4,15 @@
|
|
|
4
4
|
* Factory roles have canHandoff=false.
|
|
5
5
|
*/
|
|
6
6
|
function rights(input) {
|
|
7
|
-
return {
|
|
7
|
+
return {
|
|
8
|
+
canRun: input.canRun,
|
|
9
|
+
readScope: input.readScope,
|
|
10
|
+
writeMemory: input.writeMemory,
|
|
11
|
+
canManageTasks: input.canManageTasks,
|
|
12
|
+
canHandoff: input.canHandoff,
|
|
13
|
+
// Factory roles ship unrestricted tool surface (SEC-2: omit = no extra limit)
|
|
14
|
+
toolRights: input.toolRights ?? { allow: undefined, deny: [], denyCapabilities: [] },
|
|
15
|
+
};
|
|
8
16
|
}
|
|
9
17
|
/** Built-in five-role catalog (v1: no consultant) */
|
|
10
18
|
export const BUILTIN_SESSION_ROLES = [
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Session ACL service: grant/revoke + authorizeRun (E6).
|
|
3
3
|
* v1: in-memory + SessionData.participants; no role DB.
|
|
4
4
|
*/
|
|
5
|
-
import { SessionRoleCatalog, computeEffectiveRights,
|
|
5
|
+
import { SessionRoleCatalog, computeEffectiveRights, } from './rights.js';
|
|
6
|
+
import { toolRightsExceeds, } from './tool-rights.js';
|
|
6
7
|
/**
|
|
7
8
|
* Session ACL service
|
|
8
9
|
*/
|
|
@@ -77,43 +78,34 @@ export class SessionAclService {
|
|
|
77
78
|
reason: 'canHandoff is host-controlled; factory roles and engine L0 deny agent handoff',
|
|
78
79
|
};
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
-
role,
|
|
82
|
-
agentMax,
|
|
83
|
-
participantRights: input.rights,
|
|
84
|
-
allowAgentInitiatedHandoff: this.allowAgentInitiatedHandoff,
|
|
85
|
-
});
|
|
86
|
-
// Illegal grant if candidate tries to exceed role.max ∩ agent.max on any field
|
|
81
|
+
// Ceiling = role.max ∩ agent.max (no participant overlay)
|
|
87
82
|
const ceiling = computeEffectiveRights({
|
|
88
83
|
role: { ...role, defaults: roleMax },
|
|
89
84
|
agentMax,
|
|
90
85
|
participantRights: undefined,
|
|
91
86
|
allowAgentInitiatedHandoff: this.allowAgentInitiatedHandoff,
|
|
92
87
|
});
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
88
|
+
// Illegal grant at grant time: any explicit overlay field stronger than
|
|
89
|
+
// ceiling. Effective rights are later intersected and cannot exceed.
|
|
90
|
+
if (input.rights) {
|
|
91
|
+
const readRank = {
|
|
92
|
+
none: 0,
|
|
93
|
+
summary_tail: 1,
|
|
94
|
+
from_grant: 2,
|
|
95
|
+
full: 3,
|
|
96
|
+
};
|
|
97
|
+
const illegalRaise = (input.rights.canRun === true && !ceiling.canRun) ||
|
|
98
|
+
(input.rights.writeMemory === true && !ceiling.writeMemory) ||
|
|
99
|
+
(input.rights.canManageTasks === true && !ceiling.canManageTasks) ||
|
|
100
|
+
(input.rights.canHandoff === true && !ceiling.canHandoff) ||
|
|
101
|
+
(input.rights.readScope !== undefined &&
|
|
102
|
+
readRank[input.rights.readScope] > readRank[ceiling.readScope]) ||
|
|
103
|
+
(input.rights.toolRights !== undefined &&
|
|
104
|
+
toolRightsExceeds(input.rights.toolRights, ceiling.toolRights));
|
|
105
|
+
if (illegalRaise) {
|
|
107
106
|
return { ok: false, reason: 'rights override exceeds role.max / agent.max' };
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
|
-
// boolean 提升不得越过 role.max ∩ agent.max
|
|
111
|
-
const illegalRaise = (input.rights?.canRun === true && !ceiling.canRun) ||
|
|
112
|
-
(input.rights?.writeMemory === true && !ceiling.writeMemory) ||
|
|
113
|
-
(input.rights?.canManageTasks === true && !ceiling.canManageTasks);
|
|
114
|
-
if (illegalRaise) {
|
|
115
|
-
return { ok: false, reason: 'rights override exceeds role.max / agent.max' };
|
|
116
|
-
}
|
|
117
109
|
const participant = {
|
|
118
110
|
sessionId: session.id,
|
|
119
111
|
agentId: input.agentId,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolRights algebra (SEC-2) — narrow-only intersection across policy layers.
|
|
3
|
+
*
|
|
4
|
+
* A tool is permitted when every layer allows it. Deny always wins.
|
|
5
|
+
* Capability denies use the same tags as `ToolDefinition.capabilities` (D5-a).
|
|
6
|
+
*
|
|
7
|
+
* `allow` semantics:
|
|
8
|
+
* - `undefined` = unrestricted names (identity for intersection)
|
|
9
|
+
* - `[]` (empty array) = deny-all names (result of disjoint allow intersection)
|
|
10
|
+
* - non-empty = allowlist; `'*'` matches any name
|
|
11
|
+
*
|
|
12
|
+
* User config ergonomics: `normalizeToolRights` maps input `allow: []` to
|
|
13
|
+
* `undefined` (same as ToolPolicy empty-allow = allow-all). Intersection
|
|
14
|
+
* results must NOT re-collapse `[]` away — that would fail open.
|
|
15
|
+
*/
|
|
16
|
+
import type { ToolRights } from './types.js';
|
|
17
|
+
/** Normalized ToolRights. `allow: []` means deny-all names, not unrestricted. */
|
|
18
|
+
export interface NormalizedToolRights {
|
|
19
|
+
allow: string[] | undefined;
|
|
20
|
+
deny: string[];
|
|
21
|
+
denyCapabilities: string[];
|
|
22
|
+
}
|
|
23
|
+
/** Unrestricted surface (identity for intersection). */
|
|
24
|
+
export declare const EMPTY_TOOL_RIGHTS: NormalizedToolRights;
|
|
25
|
+
/**
|
|
26
|
+
* Normalize a user/config ToolRights bag.
|
|
27
|
+
* Empty input `allow` is treated as unrestricted (ToolPolicy ergonomics).
|
|
28
|
+
* Do NOT use this on intersection results (empty there means deny-all).
|
|
29
|
+
*
|
|
30
|
+
* @param input - raw rights (possibly undefined)
|
|
31
|
+
* @returns normalized rights
|
|
32
|
+
*/
|
|
33
|
+
export declare function normalizeToolRights(input?: ToolRights): NormalizedToolRights;
|
|
34
|
+
/**
|
|
35
|
+
* Intersect two tool-rights layers (stricter wins).
|
|
36
|
+
*
|
|
37
|
+
* - deny / denyCapabilities: union
|
|
38
|
+
* - allow: both defined → set intersection (`[]` = deny-all); one undefined
|
|
39
|
+
* → the defined one; both undefined → unrestricted
|
|
40
|
+
*
|
|
41
|
+
* @param a - left layer
|
|
42
|
+
* @param b - right layer
|
|
43
|
+
* @returns intersection; empty allow stays `[]` (deny-all)
|
|
44
|
+
*/
|
|
45
|
+
export declare function intersectToolRights(a: ToolRights | undefined, b: ToolRights | undefined): NormalizedToolRights;
|
|
46
|
+
/**
|
|
47
|
+
* Whether `value` is strictly more powerful than `ceiling` (illegal grant).
|
|
48
|
+
*
|
|
49
|
+
* Compares permitted surfaces: value exceeds when some tool name would be
|
|
50
|
+
* permitted by value but not by ceiling. A narrow allowlist satisfies a
|
|
51
|
+
* deny-based ceiling without restating those denies.
|
|
52
|
+
*
|
|
53
|
+
* @param value - proposed rights
|
|
54
|
+
* @param ceiling - max rights
|
|
55
|
+
* @returns true when value exceeds ceiling
|
|
56
|
+
*/
|
|
57
|
+
export declare function toolRightsExceeds(value: ToolRights | undefined, ceiling: ToolRights | undefined): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Evaluate one tool against a single ToolRights layer.
|
|
60
|
+
*
|
|
61
|
+
* Fail-closed when `denyCapabilities` is set and the tool's capability tags
|
|
62
|
+
* are unknown (aligned with reduced-surface unknown-reject).
|
|
63
|
+
*
|
|
64
|
+
* @param toolName - registered tool name
|
|
65
|
+
* @param capabilities - resolved capability tags (explicit preferred)
|
|
66
|
+
* @param rights - layer to test
|
|
67
|
+
* @returns false when this layer strips the tool
|
|
68
|
+
*/
|
|
69
|
+
export declare function isToolAllowedByRights(toolName: string, capabilities: readonly string[] | null | undefined, rights: ToolRights | undefined): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Merge ToolPolicy (allow/deny names) and ToolRights into one narrow-only check.
|
|
72
|
+
*
|
|
73
|
+
* @param toolName - registered tool name
|
|
74
|
+
* @param capabilities - resolved capability tags
|
|
75
|
+
* @param layers - every active layer (agent policy, session rights, …)
|
|
76
|
+
* @returns true only when all layers permit
|
|
77
|
+
*/
|
|
78
|
+
export declare function isToolPermitted(toolName: string, capabilities: readonly string[] | null | undefined, layers: Array<ToolRights | {
|
|
79
|
+
allow?: string[];
|
|
80
|
+
deny?: string[];
|
|
81
|
+
} | undefined>): boolean;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolRights algebra (SEC-2) — narrow-only intersection across policy layers.
|
|
3
|
+
*
|
|
4
|
+
* A tool is permitted when every layer allows it. Deny always wins.
|
|
5
|
+
* Capability denies use the same tags as `ToolDefinition.capabilities` (D5-a).
|
|
6
|
+
*
|
|
7
|
+
* `allow` semantics:
|
|
8
|
+
* - `undefined` = unrestricted names (identity for intersection)
|
|
9
|
+
* - `[]` (empty array) = deny-all names (result of disjoint allow intersection)
|
|
10
|
+
* - non-empty = allowlist; `'*'` matches any name
|
|
11
|
+
*
|
|
12
|
+
* User config ergonomics: `normalizeToolRights` maps input `allow: []` to
|
|
13
|
+
* `undefined` (same as ToolPolicy empty-allow = allow-all). Intersection
|
|
14
|
+
* results must NOT re-collapse `[]` away — that would fail open.
|
|
15
|
+
*/
|
|
16
|
+
import { resolveToolCapabilities } from '../../extension/execution-environment/tool-capabilities.js';
|
|
17
|
+
/** Unrestricted surface (identity for intersection). */
|
|
18
|
+
export const EMPTY_TOOL_RIGHTS = {
|
|
19
|
+
allow: undefined,
|
|
20
|
+
deny: [],
|
|
21
|
+
denyCapabilities: [],
|
|
22
|
+
};
|
|
23
|
+
function dedupe(list) {
|
|
24
|
+
if (!list || list.length === 0)
|
|
25
|
+
return [];
|
|
26
|
+
const out = [];
|
|
27
|
+
const seen = new Set();
|
|
28
|
+
for (const raw of list) {
|
|
29
|
+
const t = typeof raw === 'string' ? raw.trim() : '';
|
|
30
|
+
if (!t || seen.has(t))
|
|
31
|
+
continue;
|
|
32
|
+
seen.add(t);
|
|
33
|
+
out.push(t);
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Normalize a user/config ToolRights bag.
|
|
39
|
+
* Empty input `allow` is treated as unrestricted (ToolPolicy ergonomics).
|
|
40
|
+
* Do NOT use this on intersection results (empty there means deny-all).
|
|
41
|
+
*
|
|
42
|
+
* @param input - raw rights (possibly undefined)
|
|
43
|
+
* @returns normalized rights
|
|
44
|
+
*/
|
|
45
|
+
export function normalizeToolRights(input) {
|
|
46
|
+
const allow = dedupe(input?.allow);
|
|
47
|
+
return {
|
|
48
|
+
allow: allow.length > 0 ? allow : undefined,
|
|
49
|
+
deny: dedupe(input?.deny),
|
|
50
|
+
denyCapabilities: dedupe(input?.denyCapabilities),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Coerce any layer to arrays without collapsing empty allow.
|
|
55
|
+
* `undefined` allow stays unrestricted; `[]` stays deny-all.
|
|
56
|
+
*/
|
|
57
|
+
function toLayer(input) {
|
|
58
|
+
if (!input)
|
|
59
|
+
return EMPTY_TOOL_RIGHTS;
|
|
60
|
+
return {
|
|
61
|
+
allow: input.allow === undefined ? undefined : dedupe(input.allow),
|
|
62
|
+
deny: dedupe(input.deny),
|
|
63
|
+
denyCapabilities: dedupe(input.denyCapabilities),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Intersect two allowlists (`'*'` matches any name).
|
|
68
|
+
* Returns `[]` when the intersection is empty (deny-all) — never `undefined`.
|
|
69
|
+
*/
|
|
70
|
+
function intersectAllow(a, b) {
|
|
71
|
+
if (a === undefined)
|
|
72
|
+
return b === undefined ? undefined : [...b];
|
|
73
|
+
if (b === undefined)
|
|
74
|
+
return [...a];
|
|
75
|
+
const aHasStar = a.includes('*');
|
|
76
|
+
const bHasStar = b.includes('*');
|
|
77
|
+
if (aHasStar && bHasStar)
|
|
78
|
+
return ['*'];
|
|
79
|
+
if (aHasStar)
|
|
80
|
+
return [...b];
|
|
81
|
+
if (bHasStar)
|
|
82
|
+
return [...a];
|
|
83
|
+
const bSet = new Set(b);
|
|
84
|
+
return a.filter((n) => bSet.has(n));
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Intersect two tool-rights layers (stricter wins).
|
|
88
|
+
*
|
|
89
|
+
* - deny / denyCapabilities: union
|
|
90
|
+
* - allow: both defined → set intersection (`[]` = deny-all); one undefined
|
|
91
|
+
* → the defined one; both undefined → unrestricted
|
|
92
|
+
*
|
|
93
|
+
* @param a - left layer
|
|
94
|
+
* @param b - right layer
|
|
95
|
+
* @returns intersection; empty allow stays `[]` (deny-all)
|
|
96
|
+
*/
|
|
97
|
+
export function intersectToolRights(a, b) {
|
|
98
|
+
const na = toLayer(a);
|
|
99
|
+
const nb = toLayer(b);
|
|
100
|
+
return {
|
|
101
|
+
allow: intersectAllow(na.allow, nb.allow),
|
|
102
|
+
deny: [...new Set([...na.deny, ...nb.deny])],
|
|
103
|
+
denyCapabilities: [...new Set([...na.denyCapabilities, ...nb.denyCapabilities])],
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function permitsName(rights, name, caps) {
|
|
107
|
+
// deny '*' = deny every tool name (same as allow '*')
|
|
108
|
+
if (rights.deny.includes('*') || rights.deny.includes(name))
|
|
109
|
+
return false;
|
|
110
|
+
if (caps && rights.denyCapabilities.length > 0) {
|
|
111
|
+
for (const cap of caps) {
|
|
112
|
+
if (rights.denyCapabilities.includes(cap))
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (rights.allow !== undefined) {
|
|
117
|
+
if (!rights.allow.includes(name) && !rights.allow.includes('*'))
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Whether `value` is strictly more powerful than `ceiling` (illegal grant).
|
|
124
|
+
*
|
|
125
|
+
* Compares permitted surfaces: value exceeds when some tool name would be
|
|
126
|
+
* permitted by value but not by ceiling. A narrow allowlist satisfies a
|
|
127
|
+
* deny-based ceiling without restating those denies.
|
|
128
|
+
*
|
|
129
|
+
* @param value - proposed rights
|
|
130
|
+
* @param ceiling - max rights
|
|
131
|
+
* @returns true when value exceeds ceiling
|
|
132
|
+
*/
|
|
133
|
+
export function toolRightsExceeds(value, ceiling) {
|
|
134
|
+
const v = toLayer(value);
|
|
135
|
+
const c = toLayer(ceiling);
|
|
136
|
+
// Ceiling deny-all names: value may permit nothing.
|
|
137
|
+
if (c.deny.includes('*')) {
|
|
138
|
+
if (v.deny.includes('*')) {
|
|
139
|
+
// both deny-all on names — fall through to capability axis
|
|
140
|
+
}
|
|
141
|
+
else if (v.allow === undefined || v.allow.length > 0) {
|
|
142
|
+
// value still permits some name (unrestricted or non-empty allowlist)
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Allow axis: if ceiling restricts names, value's allowlist must be ⊆ ceiling.
|
|
147
|
+
// Ceiling `'*'` matches every name (so a concrete allowlist never exceeds it).
|
|
148
|
+
if (c.allow !== undefined) {
|
|
149
|
+
if (v.allow === undefined)
|
|
150
|
+
return true;
|
|
151
|
+
const cSet = new Set(c.allow);
|
|
152
|
+
const ceilingAllowsAll = cSet.has('*');
|
|
153
|
+
for (const name of v.allow) {
|
|
154
|
+
if (name === '*') {
|
|
155
|
+
// value wildcard only legal when ceiling is also wildcard
|
|
156
|
+
if (!ceilingAllowsAll)
|
|
157
|
+
return true;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
if (!ceilingAllowsAll && !cSet.has(name))
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// Name denies: value must not permit a tool ceiling denies.
|
|
165
|
+
for (const name of c.deny) {
|
|
166
|
+
if (name === '*')
|
|
167
|
+
continue; // handled above
|
|
168
|
+
if (permitsName(v, name, resolveToolCapabilities(name)))
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
// Capability denies: value must not permit tools carrying that capability.
|
|
172
|
+
for (const cap of c.denyCapabilities) {
|
|
173
|
+
if (v.denyCapabilities.includes(cap))
|
|
174
|
+
continue;
|
|
175
|
+
if (v.allow === undefined)
|
|
176
|
+
return true;
|
|
177
|
+
for (const name of v.allow) {
|
|
178
|
+
const caps = resolveToolCapabilities(name);
|
|
179
|
+
if (caps === null)
|
|
180
|
+
return true;
|
|
181
|
+
if (caps.includes(cap))
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Evaluate one tool against a single ToolRights layer.
|
|
189
|
+
*
|
|
190
|
+
* Fail-closed when `denyCapabilities` is set and the tool's capability tags
|
|
191
|
+
* are unknown (aligned with reduced-surface unknown-reject).
|
|
192
|
+
*
|
|
193
|
+
* @param toolName - registered tool name
|
|
194
|
+
* @param capabilities - resolved capability tags (explicit preferred)
|
|
195
|
+
* @param rights - layer to test
|
|
196
|
+
* @returns false when this layer strips the tool
|
|
197
|
+
*/
|
|
198
|
+
export function isToolAllowedByRights(toolName, capabilities, rights) {
|
|
199
|
+
if (!rights)
|
|
200
|
+
return true;
|
|
201
|
+
const r = toLayer(rights);
|
|
202
|
+
const name = toolName.trim();
|
|
203
|
+
// deny '*' = deny every tool (mirror allow '*')
|
|
204
|
+
if (r.deny.includes('*') || r.deny.includes(name))
|
|
205
|
+
return false;
|
|
206
|
+
const caps = capabilities !== undefined ? capabilities : resolveToolCapabilities(name);
|
|
207
|
+
if (r.denyCapabilities.length > 0) {
|
|
208
|
+
if (caps === null)
|
|
209
|
+
return false;
|
|
210
|
+
for (const cap of caps) {
|
|
211
|
+
if (r.denyCapabilities.includes(cap))
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (r.allow !== undefined) {
|
|
216
|
+
if (!r.allow.includes(name) && !r.allow.includes('*'))
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Merge ToolPolicy (allow/deny names) and ToolRights into one narrow-only check.
|
|
223
|
+
*
|
|
224
|
+
* @param toolName - registered tool name
|
|
225
|
+
* @param capabilities - resolved capability tags
|
|
226
|
+
* @param layers - every active layer (agent policy, session rights, …)
|
|
227
|
+
* @returns true only when all layers permit
|
|
228
|
+
*/
|
|
229
|
+
export function isToolPermitted(toolName, capabilities, layers) {
|
|
230
|
+
for (const layer of layers) {
|
|
231
|
+
if (!layer)
|
|
232
|
+
continue;
|
|
233
|
+
if (!isToolAllowedByRights(toolName, capabilities, layer)) {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
@@ -4,6 +4,24 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/** Information visibility for a Run on a Session */
|
|
6
6
|
export type ReadScope = 'full' | 'from_grant' | 'summary_tail' | 'none';
|
|
7
|
+
/**
|
|
8
|
+
* Per-tool surface on a session (SEC-2).
|
|
9
|
+
*
|
|
10
|
+
* Omitted fields mean "no extra restriction on this axis". Layers
|
|
11
|
+
* **intersect** (narrow-only): deny lists union, allow lists intersect.
|
|
12
|
+
* `'*'` in `allow` or `deny` is a wildcard (all names).
|
|
13
|
+
* Capability denies strip any tool carrying that capability tag (D5-a).
|
|
14
|
+
* After normalization/intersection: `allow: undefined` = names unrestricted,
|
|
15
|
+
* `allow: []` = deny-all names (empty intersection, never folded open).
|
|
16
|
+
*/
|
|
17
|
+
export interface ToolRights {
|
|
18
|
+
/** Allowlist of tool names. `'*'` = all. Omitted = unrestricted names. */
|
|
19
|
+
allow?: string[];
|
|
20
|
+
/** Tool-name denials (always win). `'*'` = deny all names. */
|
|
21
|
+
deny?: string[];
|
|
22
|
+
/** Capability-tag denials (exec / egress / send / dynamic-code / …). */
|
|
23
|
+
denyCapabilities?: string[];
|
|
24
|
+
}
|
|
7
25
|
/** Session participation rights (partial overrides allowed) */
|
|
8
26
|
export interface SessionRights {
|
|
9
27
|
canRun?: boolean;
|
|
@@ -13,6 +31,8 @@ export interface SessionRights {
|
|
|
13
31
|
canManageTasks?: boolean;
|
|
14
32
|
/** Factory roles all false; host-controlled handoff only by default */
|
|
15
33
|
canHandoff?: boolean;
|
|
34
|
+
/** Per-tool / per-capability surface (SEC-2); omit = no extra restriction */
|
|
35
|
+
toolRights?: ToolRights;
|
|
16
36
|
}
|
|
17
37
|
/** Full rights used for effective intersection */
|
|
18
38
|
export interface EffectiveSessionRights {
|
|
@@ -21,6 +41,8 @@ export interface EffectiveSessionRights {
|
|
|
21
41
|
writeMemory: boolean;
|
|
22
42
|
canManageTasks: boolean;
|
|
23
43
|
canHandoff: boolean;
|
|
44
|
+
/** Resolved tool surface (never undefined; empty = unrestricted) */
|
|
45
|
+
toolRights: ToolRights;
|
|
24
46
|
}
|
|
25
47
|
/** Role catalog entry (config seed or host override) */
|
|
26
48
|
export interface SessionRoleDefinition {
|