@octopi-agent/engine 0.70.7 → 0.90.11
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 +81 -5
- package/dist/config-schema/context.d.ts +24 -5
- package/dist/config-schema/context.js +28 -1
- package/dist/config-schema/engine.d.ts +205 -13
- package/dist/config-schema/engine.js +31 -2
- package/dist/config-schema/governance.d.ts +95 -0
- package/dist/config-schema/governance.js +93 -1
- package/dist/config-schema/models.d.ts +3 -3
- 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 +13 -0
- package/dist/config-schema/shared.js +22 -0
- package/dist/config-schema/substrate.d.ts +2 -2
- package/dist/config-schema/subsystems.d.ts +1 -1
- package/dist/config-schema/subsystems.js +2 -1
- package/dist/config.d.ts +201 -8
- package/dist/config.js +105 -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 +50 -5
- package/dist/harness/agent/builder.js +189 -59
- package/dist/harness/agent/config-bridge.d.ts +33 -25
- package/dist/harness/agent/config-bridge.js +84 -291
- 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 +46 -0
- package/dist/harness/agent/tool-purpose.js +127 -0
- package/dist/harness/agent/wire-agent-builder.d.ts +133 -0
- package/dist/harness/agent/wire-agent-builder.js +370 -0
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.d.ts +11 -1
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.js +11 -1
- package/dist/harness/collaboration/autonomous-subsystem/loader.d.ts +13 -0
- package/dist/harness/collaboration/autonomous-subsystem/loader.js +16 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +8 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +17 -9
- 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/registry.js +10 -0
- 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-snapshot.d.ts +4 -0
- package/dist/harness/context/layer-snapshot.js +30 -18
- package/dist/harness/context/layer-types.d.ts +85 -1
- package/dist/harness/context/layer-types.js +110 -4
- package/dist/harness/context/layers.d.ts +5 -2
- package/dist/harness/context/layers.js +11 -5
- 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 +30 -0
- package/dist/harness/context/system-prompt-assembler.js +73 -6
- 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 +258 -0
- package/dist/harness/extension/execution-environment/effect-policy.js +358 -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/isolation.js +5 -1
- 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 +521 -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 +1 -1
- package/dist/harness/extension/plugin-ecosystem/client-tools/types.d.ts +9 -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 +51 -0
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.js +153 -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 +277 -81
- 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 +241 -70
- package/dist/harness/extension/plugin-ecosystem/tools/git-runner.d.ts +31 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-runner.js +104 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-status-snapshot.d.ts +111 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-status-snapshot.js +197 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.d.ts +27 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +463 -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 +6 -0
- package/dist/harness/extension/plugin-ecosystem/tools/index.js +4 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +4 -0
- package/dist/harness/extension/plugin-ecosystem/tools/memory.js +25 -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 +16 -12
- package/dist/harness/index.js +10 -6
- package/dist/harness/knowledge/file-identity.d.ts +8 -0
- package/dist/harness/knowledge/file-identity.js +26 -1
- 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 +8 -5
- package/dist/harness/knowledge/index-store.d.ts +31 -4
- package/dist/harness/knowledge/index-store.js +121 -39
- package/dist/harness/knowledge/index.d.ts +2 -2
- package/dist/harness/knowledge/index.js +1 -1
- package/dist/harness/knowledge/ingest.d.ts +115 -115
- package/dist/harness/knowledge/ingest.js +154 -151
- package/dist/harness/knowledge/job-control-state.js +4 -4
- package/dist/harness/knowledge/job-control.js +11 -11
- package/dist/harness/knowledge/knowledge-serve-child.js +1 -1
- 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/purge.js +4 -1
- package/dist/harness/knowledge/query-service.js +3 -3
- package/dist/harness/knowledge/writer-service.d.ts +2 -0
- package/dist/harness/knowledge/writer-service.js +14 -13
- package/dist/harness/memory/backfill-coverage.js +3 -1
- package/dist/harness/memory/backfill-trigger.d.ts +2 -2
- package/dist/harness/memory/backfill-trigger.js +4 -4
- package/dist/harness/memory/index.d.ts +1 -0
- package/dist/harness/memory/index.js +1 -0
- package/dist/harness/memory/sqlite/agent-db.js +2 -0
- 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.js +9 -9
- 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 +12 -0
- package/dist/harness/observability/observer/hub.js +53 -2
- 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 +80 -0
- package/dist/harness/observability/observer/types.js +118 -9
- package/dist/harness/run/agent/agent.d.ts +18 -0
- package/dist/harness/run/agent/agent.js +26 -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 +110 -18
- 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 +117 -16
- package/dist/harness/run/runner.js +668 -157
- package/dist/harness/session/attachments/llm-intent.js +17 -17
- package/dist/harness/session/history/port.js +16 -5
- package/dist/harness/session/in-memory-store.d.ts +6 -0
- package/dist/harness/session/in-memory-store.js +55 -3
- 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.js +25 -9
- package/dist/harness/session/types.d.ts +35 -0
- package/dist/harness/shared/events/agent-event-map.d.ts +39 -0
- package/dist/harness/shared/events/agent-event-map.js +2 -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/observability/run-telemetry.d.ts +8 -0
- package/dist/integration/observability/run-telemetry.js +31 -8
- package/dist/integration/observability/trace-collector.js +26 -4
- package/dist/integration/observability/trace-events.d.ts +1 -0
- package/dist/integration/observability/trace-events.js +2 -0
- package/dist/integration/observability/trace-logger.js +27 -17
- 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 +29 -0
- package/dist/integration/storage/jsonl.js +243 -41
- package/dist/integration/storage/session-index.js +63 -8
- package/dist/paths.d.ts +19 -0
- package/dist/paths.js +38 -1
- package/dist/subsystems/cognition-steward/conceptualize/SUBSYSTEM.md +43 -43
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +50 -50
- package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +6 -6
- package/dist/subsystems/cognition-steward/consolidate/config.yaml +54 -54
- package/dist/subsystems/memory-steward/backfill/handler.js +9 -0
- package/dist/subsystems/safety-guard/config.yaml +3 -1
- package/dist/subsystems/wisdom-steward/evaluate/config.yaml +50 -50
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +42 -42
- package/dist/subsystems/wisdom-steward/formation/config.yaml +54 -54
- package/dist/subsystems/wisdom-steward/govern/config.yaml +55 -55
- 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,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* temp-path — 临时目录路径分类(单一来源)
|
|
3
|
+
*
|
|
4
|
+
* @layer harness/governance/security
|
|
5
|
+
*
|
|
6
|
+
* 三处消费方(risk-evaluator / degradation / capability-enforcer)共用同一份
|
|
7
|
+
* 临时目录清单与前缀匹配,防止各处手抄前缀清单再次漂移。
|
|
8
|
+
*
|
|
9
|
+
* 分类语义(纯字符串分类,不做 fs 探测):
|
|
10
|
+
* - POSIX 共享临时 `/tmp`、`/var/tmp` 及其 macOS 规范(realpath)双形态
|
|
11
|
+
* `/private/tmp`、`/private/var/tmp`——兼容性不押在 env 透传上(C4 拍板)
|
|
12
|
+
* - `os.tmpdir()` 实际值(反映 TMPDIR/TEMP/TMP 生效值,macOS 为 `/var/folders/…`)
|
|
13
|
+
* - 显式 `TMPDIR`/`TEMP`/`TMP`/`Tmp` 兜底
|
|
14
|
+
* - Windows 静态临时区(`C:\Windows\Temp`、SystemRoot Temp、用户 AppData Temp)
|
|
15
|
+
*/
|
|
16
|
+
import { homedir, tmpdir } from 'node:os';
|
|
17
|
+
let cachedTempPrefixes = null;
|
|
18
|
+
/** 仅测试用:环境变量变更后清空临时目录缓存 */
|
|
19
|
+
export function resetTempPathCache() {
|
|
20
|
+
cachedTempPrefixes = null;
|
|
21
|
+
}
|
|
22
|
+
/** Windows 风格路径:盘符或 UNC */
|
|
23
|
+
export function isWindowsStylePath(p) {
|
|
24
|
+
return /^[A-Za-z]:[\\/]/.test(p) || /^[A-Za-z]:$/.test(p) || p.includes('\\') || p.startsWith('\\\\');
|
|
25
|
+
}
|
|
26
|
+
/** 去掉末尾分隔符(保留根 `/` 或 `C:\`) */
|
|
27
|
+
export function stripTrailingSep(p) {
|
|
28
|
+
if (p.length > 1 && (p.endsWith('/') || p.endsWith('\\'))) {
|
|
29
|
+
// `C:\` 保留
|
|
30
|
+
if (/^[A-Za-z]:[\\/]$/.test(p))
|
|
31
|
+
return p;
|
|
32
|
+
return p.slice(0, -1);
|
|
33
|
+
}
|
|
34
|
+
return p;
|
|
35
|
+
}
|
|
36
|
+
/** 绝对路径(POSIX + Windows 盘符/UNC),跨平台评估时用 */
|
|
37
|
+
export function isAbsolutePath(p) {
|
|
38
|
+
return (p.startsWith('/') ||
|
|
39
|
+
/^[A-Za-z]:[\\/]/.test(p) ||
|
|
40
|
+
/^[A-Za-z]:$/.test(p) ||
|
|
41
|
+
p.startsWith('\\\\'));
|
|
42
|
+
}
|
|
43
|
+
/** 补尾部分隔符(按路径自身风格选 `/` 或 `\`) */
|
|
44
|
+
export function ensureTrailingSep(p) {
|
|
45
|
+
if (!p)
|
|
46
|
+
return p;
|
|
47
|
+
const sepChar = isWindowsStylePath(p) ? '\\' : '/';
|
|
48
|
+
return p.endsWith('/') || p.endsWith('\\') ? p : p + sepChar;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 路径前缀匹配(路径段边界,拒绝 project 前缀绕过 project-evil)
|
|
52
|
+
*
|
|
53
|
+
* 要求 path === base 或 path 以 base + 分隔符 开头。
|
|
54
|
+
* Windows 风格路径大小写不敏感、分隔符归一为 `\`。
|
|
55
|
+
*/
|
|
56
|
+
export function startsWithPathPrefix(path, prefix) {
|
|
57
|
+
const isWin = isWindowsStylePath(path) || isWindowsStylePath(prefix);
|
|
58
|
+
if (isWin) {
|
|
59
|
+
const p = stripTrailingSep(path.replace(/\//g, '\\')).toLowerCase();
|
|
60
|
+
const b = stripTrailingSep(prefix.replace(/\//g, '\\')).toLowerCase();
|
|
61
|
+
if (p === b)
|
|
62
|
+
return true;
|
|
63
|
+
return p.startsWith(b + '\\');
|
|
64
|
+
}
|
|
65
|
+
const p = stripTrailingSep(path);
|
|
66
|
+
const b = stripTrailingSep(prefix);
|
|
67
|
+
if (p === b)
|
|
68
|
+
return true;
|
|
69
|
+
return p.startsWith(b + '/');
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 临时目录前缀清单
|
|
73
|
+
*
|
|
74
|
+
* 必须在 PROTECTED 之前匹配:`C:\Windows\Temp` 虽在 `C:\Windows\` 下,
|
|
75
|
+
* 但是可清空的临时区,应归 safe 而非 protected。
|
|
76
|
+
*/
|
|
77
|
+
export function getTempPrefixes() {
|
|
78
|
+
if (cachedTempPrefixes)
|
|
79
|
+
return cachedTempPrefixes;
|
|
80
|
+
const prefixes = [
|
|
81
|
+
// POSIX 共享临时:词法 + macOS 规范(realpath)双形态
|
|
82
|
+
'/tmp/',
|
|
83
|
+
'/private/tmp/',
|
|
84
|
+
'/var/tmp/',
|
|
85
|
+
'/private/var/tmp/',
|
|
86
|
+
];
|
|
87
|
+
// os.tmpdir() 反映 TMPDIR/TEMP/TMP 生效值(macOS 为 /var/folders/…)
|
|
88
|
+
const osTemp = tmpdir();
|
|
89
|
+
if (osTemp)
|
|
90
|
+
prefixes.push(ensureTrailingSep(osTemp));
|
|
91
|
+
// 显式环境变量兜底(os.tmpdir() 之外的显式设定)
|
|
92
|
+
for (const key of ['TEMP', 'TMP', 'Tmp', 'TMPDIR']) {
|
|
93
|
+
const v = process.env[key];
|
|
94
|
+
if (v)
|
|
95
|
+
prefixes.push(ensureTrailingSep(v));
|
|
96
|
+
}
|
|
97
|
+
// Windows 静态临时区
|
|
98
|
+
prefixes.push('C:\\Windows\\Temp\\');
|
|
99
|
+
const systemRoot = process.env.SystemRoot ?? process.env.windir;
|
|
100
|
+
if (systemRoot) {
|
|
101
|
+
prefixes.push(ensureTrailingSep(systemRoot) + 'Temp\\');
|
|
102
|
+
}
|
|
103
|
+
// 用户 AppData Temp(无 TEMP 环境变量时的静态路径)
|
|
104
|
+
const userProfile = process.env.USERPROFILE ?? process.env.HOME;
|
|
105
|
+
const home = userProfile ? userProfile.replace(/\//g, '\\') : homedir().replace(/\//g, '\\');
|
|
106
|
+
if (home) {
|
|
107
|
+
const base = home.endsWith('\\') ? home : home + '\\';
|
|
108
|
+
prefixes.push(base + 'AppData\\Local\\Temp\\');
|
|
109
|
+
prefixes.push(base + 'AppData\\Local\\Microsoft\\Windows\\Temp\\');
|
|
110
|
+
}
|
|
111
|
+
cachedTempPrefixes = prefixes;
|
|
112
|
+
return prefixes;
|
|
113
|
+
}
|
|
114
|
+
/** 临时目录判定(路径段边界,防 `/tmpdir` 假命中) */
|
|
115
|
+
export function isTempPath(path) {
|
|
116
|
+
return getTempPrefixes().some((p) => startsWithPathPrefix(path, p));
|
|
117
|
+
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
export * from './types.js';
|
|
5
5
|
export { BUILTIN_SESSION_ROLES, L0_SESSION_RIGHTS_FLOOR } from './seed-roles.js';
|
|
6
6
|
export { SessionRoleCatalog, computeEffectiveRights, intersectRights, applyRightsOverlay, exceedsRightsCeiling, } from './rights.js';
|
|
7
|
+
export { EMPTY_TOOL_RIGHTS, normalizeToolRights, intersectToolRights, toolRightsExceeds, isToolAllowedByRights, isToolPermitted, } from './tool-rights.js';
|
|
7
8
|
export { SessionAclService } from './service.js';
|
|
8
9
|
export type { AgentSessionAclHint } from './service.js';
|
|
9
10
|
export type { PrincipalRef, SessionSwitchMode, SwitchSessionResult } from './types.js';
|
|
@@ -4,4 +4,5 @@
|
|
|
4
4
|
export * from './types.js';
|
|
5
5
|
export { BUILTIN_SESSION_ROLES, L0_SESSION_RIGHTS_FLOOR } from './seed-roles.js';
|
|
6
6
|
export { SessionRoleCatalog, computeEffectiveRights, intersectRights, applyRightsOverlay, exceedsRightsCeiling, } from './rights.js';
|
|
7
|
+
export { EMPTY_TOOL_RIGHTS, normalizeToolRights, intersectToolRights, toolRightsExceeds, isToolAllowedByRights, isToolPermitted, } from './tool-rights.js';
|
|
7
8
|
export { SessionAclService } from './service.js';
|
|
@@ -15,6 +15,7 @@ export declare function intersectRights(a: EffectiveSessionRights, b: EffectiveS
|
|
|
15
15
|
*
|
|
16
16
|
* Binding fields that are set **replace** defaults (then clamped to max/L0/agentMax).
|
|
17
17
|
* Binding may raise a default toward role.max; it may not exceed max (clamped later).
|
|
18
|
+
* `toolRights` is narrow-only at merge time via later intersection with ceilings.
|
|
18
19
|
*
|
|
19
20
|
* @param base - role defaults
|
|
20
21
|
* @param overlay - participant override
|
|
@@ -76,3 +77,14 @@ export declare function computeEffectiveRights(input: {
|
|
|
76
77
|
participantRights?: SessionRights;
|
|
77
78
|
allowAgentInitiatedHandoff?: boolean;
|
|
78
79
|
}): EffectiveSessionRights;
|
|
80
|
+
/**
|
|
81
|
+
* 取两个 `SessionRights` 中**更严**的一侧(逐轴收紧)
|
|
82
|
+
*
|
|
83
|
+
* 用于叠加一个额外的权利天花板(如委派时传入的 `rightsCeiling`,`arch/delegation.md` D3):
|
|
84
|
+
* 结果在每一根轴上都不宽于任一入参。缺省轴(undefined)表示该轴无额外限制,不参与收紧。
|
|
85
|
+
*
|
|
86
|
+
* @param a - 第一层天花板(可缺省)
|
|
87
|
+
* @param b - 第二层天花板(可缺省)
|
|
88
|
+
* @returns 收紧后的天花板;两者皆缺省时返回 undefined
|
|
89
|
+
*/
|
|
90
|
+
export declare function tightenSessionRights(a: SessionRights | undefined, b: SessionRights | undefined): SessionRights | undefined;
|
|
@@ -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;
|