@octopi-agent/engine 0.97.15 → 0.102.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config-schema/agent.d.ts +37 -5
- package/dist/config-schema/agent.js +24 -4
- package/dist/config-schema/context.d.ts +6 -36
- package/dist/config-schema/context.js +4 -28
- package/dist/config-schema/engine.d.ts +61 -160
- package/dist/config-schema/engine.js +1 -5
- package/dist/config-schema/governance.d.ts +10 -1
- package/dist/config-schema/governance.js +38 -1
- package/dist/config-schema/models.d.ts +2 -8
- package/dist/config-schema/models.js +0 -2
- package/dist/config-schema/run.d.ts +2 -2
- package/dist/config-schema/run.js +2 -2
- package/dist/config-schema/shared.d.ts +0 -3
- package/dist/config-schema/shared.js +0 -2
- package/dist/config-schema/substrate.d.ts +14 -88
- package/dist/config-schema/substrate.js +22 -107
- package/dist/config.d.ts +45 -113
- package/dist/config.js +8 -2
- package/dist/harness/activation/dispatcher.js +7 -0
- package/dist/harness/activation/inbox.d.ts +3 -3
- package/dist/harness/activation/inbox.js +3 -3
- package/dist/harness/activation/runtime.js +13 -5
- package/dist/harness/activation/types.d.ts +2 -2
- package/dist/harness/agent/builder.d.ts +34 -2
- package/dist/harness/agent/builder.js +189 -58
- package/dist/harness/agent/config-bridge.js +9 -2
- package/dist/harness/agent/config-integrity.d.ts +66 -0
- package/dist/harness/agent/config-integrity.js +108 -2
- package/dist/harness/agent/wire-agent-builder.d.ts +11 -3
- package/dist/harness/agent/wire-agent-builder.js +31 -7
- package/dist/harness/capabilities/document/factory.d.ts +5 -0
- package/dist/harness/capabilities/document/factory.js +1 -0
- package/dist/harness/capabilities/document/port.js +6 -3
- package/dist/harness/capabilities/document/types.d.ts +5 -0
- package/dist/harness/collaboration/autonomous-subsystem/index.d.ts +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/index.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/loader.js +4 -1
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.d.ts +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.js +21 -4
- package/dist/harness/collaboration/autonomous-subsystem/sense/input-builder.js +4 -4
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/signal/bus.d.ts +6 -0
- package/dist/harness/collaboration/autonomous-subsystem/signal/bus.js +25 -4
- package/dist/harness/collaboration/autonomous-subsystem/think/completion-guard.d.ts +40 -0
- package/dist/harness/collaboration/autonomous-subsystem/think/completion-guard.js +59 -0
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/index.d.ts +2 -0
- package/dist/harness/collaboration/autonomous-subsystem/think/index.js +1 -0
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/types.d.ts +12 -3
- package/dist/harness/collaboration/delegation/child-run.d.ts +1 -1
- package/dist/harness/collaboration/delegation/child-run.js +4 -4
- package/dist/harness/collaboration/delegation/index.d.ts +1 -1
- package/dist/harness/collaboration/delegation/index.js +1 -1
- package/dist/harness/collaboration/delegation/notifier.d.ts +6 -1
- package/dist/harness/collaboration/delegation/notifier.js +8 -1
- package/dist/harness/collaboration/delegation/service.d.ts +2 -0
- package/dist/harness/collaboration/delegation/service.js +2 -1
- package/dist/harness/collaboration/delegation/store.d.ts +2 -0
- package/dist/harness/collaboration/delegation/store.js +2 -1
- package/dist/harness/collaboration/delegation/types.d.ts +23 -2
- package/dist/harness/collaboration/delegation/types.js +22 -0
- package/dist/harness/collaboration/delegation/wiring.js +11 -1
- package/dist/harness/context/budget-allocator.d.ts +26 -18
- package/dist/harness/context/budget-allocator.js +67 -32
- package/dist/harness/context/capabilities/compact/engine.d.ts +0 -6
- package/dist/harness/context/capabilities/compact/engine.js +169 -121
- package/dist/harness/context/capabilities/compact/handover.d.ts +5 -3
- package/dist/harness/context/capabilities/compact/handover.js +7 -5
- package/dist/harness/context/capabilities/compact/index.d.ts +5 -1
- package/dist/harness/context/capabilities/compact/index.js +4 -0
- package/dist/harness/context/capabilities/compact/mechanical.d.ts +130 -0
- package/dist/harness/context/capabilities/compact/mechanical.js +268 -0
- package/dist/harness/context/capabilities/compact/messages.d.ts +60 -0
- package/dist/harness/context/capabilities/compact/messages.js +91 -0
- package/dist/harness/context/capabilities/compact/types.d.ts +76 -11
- package/dist/harness/context/capabilities/compact/types.js +11 -1
- package/dist/harness/context/capabilities/compact/view-split.d.ts +36 -0
- package/dist/harness/context/capabilities/compact/view-split.js +72 -0
- package/dist/harness/context/capabilities/summary/port.js +0 -1
- package/dist/harness/context/capabilities/summary/resolver.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/resolver.js +4 -9
- package/dist/harness/context/capabilities/summary/tool-binding.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/types.d.ts +4 -7
- package/dist/harness/context/context-size-ledger.d.ts +143 -0
- package/dist/harness/context/context-size-ledger.js +236 -0
- package/dist/harness/context/default-context-engine.d.ts +195 -119
- package/dist/harness/context/default-context-engine.js +1241 -743
- package/dist/harness/context/index.d.ts +2 -2
- package/dist/harness/context/index.js +1 -1
- package/dist/harness/context/layer-types.d.ts +15 -0
- package/dist/harness/context/layer-types.js +14 -1
- package/dist/harness/context/layers.d.ts +16 -19
- package/dist/harness/context/layers.js +42 -14
- package/dist/harness/context/message-selector.d.ts +10 -8
- package/dist/harness/context/message-selector.js +49 -27
- package/dist/harness/context/summarize.d.ts +3 -3
- package/dist/harness/context/summarize.js +11 -4
- package/dist/harness/context/system-prompt-assembler.d.ts +4 -0
- package/dist/harness/context/system-prompt-assembler.js +3 -1
- package/dist/harness/context/token-constants.d.ts +8 -6
- package/dist/harness/context/token-constants.js +8 -7
- package/dist/harness/context/token-estimate-fns.d.ts +37 -27
- package/dist/harness/context/token-estimate-fns.js +85 -66
- package/dist/harness/context/token-estimator.d.ts +27 -12
- package/dist/harness/context/token-estimator.js +120 -66
- package/dist/harness/context/token-segments.d.ts +88 -0
- package/dist/harness/context/token-segments.js +103 -0
- package/dist/harness/context/tool-result-aging.d.ts +6 -1
- package/dist/harness/context/tool-result-aging.js +16 -5
- package/dist/harness/context/tool-result-body.js +2 -0
- package/dist/harness/context/transform/anchors.d.ts +66 -0
- package/dist/harness/context/transform/anchors.js +125 -0
- package/dist/harness/context/transform/fold.d.ts +56 -0
- package/dist/harness/context/transform/fold.js +135 -0
- package/dist/harness/context/transform/migrate.d.ts +41 -0
- package/dist/harness/context/transform/migrate.js +69 -0
- package/dist/harness/context/transform/types.d.ts +129 -0
- package/dist/harness/context/transform/types.js +19 -0
- package/dist/harness/context/turn-envelope.d.ts +6 -3
- package/dist/harness/context/types.d.ts +127 -117
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +24 -2
- package/dist/harness/extension/execution-environment/effect-policy.js +30 -0
- package/dist/harness/extension/execution-environment/ops-audit.d.ts +7 -3
- package/dist/harness/extension/execution-environment/ops-audit.js +11 -12
- package/dist/harness/extension/execution-environment/resource-limits.d.ts +1 -1
- package/dist/harness/extension/execution-environment/resource-limits.js +1 -1
- package/dist/harness/extension/execution-environment/undo-log.d.ts +6 -2
- package/dist/harness/extension/execution-environment/undo-log.js +31 -10
- package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/commands/index.d.ts +3 -1
- package/dist/harness/extension/plugin-ecosystem/commands/index.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/commands/plugin-bridge.d.ts +12 -1
- package/dist/harness/extension/plugin-ecosystem/commands/plugin-bridge.js +14 -4
- package/dist/harness/extension/plugin-ecosystem/commands/router.d.ts +5 -4
- package/dist/harness/extension/plugin-ecosystem/commands/router.js +23 -14
- package/dist/harness/extension/plugin-ecosystem/commands/types.d.ts +8 -1
- package/dist/harness/extension/plugin-ecosystem/commands/types.js +2 -1
- package/dist/harness/extension/plugin-ecosystem/hooks/adapter.d.ts +54 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/adapter.js +397 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/compaction-integration.d.ts +16 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/compaction-integration.js +66 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/index.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/index.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/iteration-snapshot.d.ts +11 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/iteration-snapshot.js +54 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/journal.d.ts +9 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/journal.js +22 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/policy-error.d.ts +12 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/policy-error.js +19 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/run-integration.d.ts +36 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/run-integration.js +338 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/services.d.ts +24 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/services.js +139 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/types.d.ts +229 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/types.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +83 -249
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +88 -214
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.d.ts +43 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.js +61 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/engine-compatibility.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/engine-compatibility.js +18 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +7 -85
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +8 -50
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +6 -23
- package/dist/harness/extension/plugin-ecosystem/plugins/index.js +3 -23
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +50 -117
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +316 -285
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +23 -490
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +85 -353
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +41 -223
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +138 -19
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.d.ts +15 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.js +15 -0
- package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +6 -1
- package/dist/harness/extension/plugin-ecosystem/skills/manager.js +17 -1
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.d.ts +3 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +46 -21
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +17 -24
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +18 -8
- package/dist/harness/extension/plugin-ecosystem/tools/document-tools.js +3 -9
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +3 -6
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.js +9 -5
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +9 -130
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +122 -14
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +4 -13
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +25 -11
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +168 -62
- package/dist/harness/extension/plugin-ecosystem/tools/plugin-tool.d.ts +11 -0
- package/dist/harness/extension/plugin-ecosystem/tools/plugin-tool.js +39 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +11 -2
- package/dist/harness/governance/accounting/usage-ledger.d.ts +13 -1
- package/dist/harness/governance/accounting/usage-ledger.js +23 -1
- package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +3 -3
- package/dist/harness/governance/human-in-the-loop/decision-cache.js +2 -2
- package/dist/harness/governance/security/capability-enforcer.js +1 -2
- package/dist/harness/governance/security/default-risk-policy.d.ts +1 -0
- package/dist/harness/governance/security/default-risk-policy.js +1 -0
- package/dist/harness/governance/security/default-security-guard.js +9 -0
- package/dist/harness/governance/security/index.d.ts +1 -0
- package/dist/harness/governance/security/index.js +2 -0
- package/dist/harness/governance/security/risk-evaluator.js +13 -0
- package/dist/harness/governance/security/risk-types.d.ts +12 -0
- package/dist/harness/governance/security/shell-parser-fallback.d.ts +29 -0
- package/dist/harness/governance/security/shell-parser-fallback.js +410 -0
- package/dist/harness/governance/security/shell-parser-shared.d.ts +83 -0
- package/dist/harness/governance/security/shell-parser-shared.js +188 -0
- package/dist/harness/governance/security/shell-parser-treesitter.d.ts +52 -0
- package/dist/harness/governance/security/shell-parser-treesitter.js +370 -0
- package/dist/harness/governance/security/shell-parser.d.ts +23 -10
- package/dist/harness/governance/security/shell-parser.js +37 -496
- package/dist/harness/governance/security/vendor/README.md +24 -0
- package/dist/harness/governance/security/vendor/tree-sitter-bash.LICENSE.txt +21 -0
- package/dist/harness/governance/security/vendor/tree-sitter-bash.wasm +0 -0
- package/dist/harness/index.d.ts +12 -12
- package/dist/harness/index.js +7 -7
- package/dist/harness/knowledge/boot-config.d.ts +55 -0
- package/dist/harness/knowledge/boot-config.js +50 -0
- package/dist/harness/knowledge/catalog-types.d.ts +2 -0
- package/dist/harness/knowledge/client.d.ts +24 -2
- package/dist/harness/knowledge/client.js +19 -5
- package/dist/harness/knowledge/db.js +5 -0
- package/dist/harness/knowledge/describe-sample.d.ts +23 -0
- package/dist/harness/knowledge/describe-sample.js +58 -0
- package/dist/harness/knowledge/describe.d.ts +8 -0
- package/dist/harness/knowledge/describe.js +18 -2
- package/dist/harness/knowledge/engine-thread.js +6 -0
- package/dist/harness/knowledge/grounding.js +3 -1
- package/dist/harness/knowledge/http-app.js +35 -4
- package/dist/harness/knowledge/http-params.d.ts +18 -0
- package/dist/harness/knowledge/http-params.js +24 -0
- package/dist/harness/knowledge/index.d.ts +2 -0
- package/dist/harness/knowledge/index.js +1 -0
- package/dist/harness/knowledge/knowledge-serve-child.js +3 -0
- package/dist/harness/knowledge/purge.js +5 -2
- package/dist/harness/knowledge/query-service.d.ts +13 -2
- package/dist/harness/knowledge/query-service.js +4 -2
- package/dist/harness/knowledge/query-worker-client.d.ts +9 -1
- package/dist/harness/knowledge/query-worker-client.js +4 -2
- package/dist/harness/knowledge/query-worker.js +4 -2
- package/dist/harness/knowledge/read-http.js +5 -1
- package/dist/harness/knowledge/serve.d.ts +8 -7
- package/dist/harness/knowledge/serve.js +9 -0
- package/dist/harness/knowledge/source-store.js +26 -3
- package/dist/harness/knowledge/start-service-process.d.ts +15 -7
- package/dist/harness/knowledge/start-service-process.js +21 -9
- package/dist/harness/knowledge/types.d.ts +7 -0
- package/dist/harness/knowledge/writer-service.d.ts +37 -9
- package/dist/harness/knowledge/writer-service.js +120 -14
- package/dist/harness/knowledge/writer-worker-client.d.ts +10 -9
- package/dist/harness/knowledge/writer-worker-client.js +20 -2
- package/dist/harness/knowledge/writer-worker.js +9 -1
- package/dist/harness/memory/index.d.ts +6 -2
- package/dist/harness/memory/index.js +4 -1
- package/dist/harness/memory/memory-events.d.ts +25 -0
- package/dist/harness/memory/memory-events.js +38 -0
- package/dist/harness/memory/sqlite/agent-db.js +15 -0
- package/dist/harness/memory/sqlite/wisdom-store.d.ts +7 -2
- package/dist/harness/memory/sqlite/wisdom-store.js +86 -12
- package/dist/harness/memory/steward-policy.d.ts +3 -0
- package/dist/harness/memory/steward-policy.js +1 -1
- package/dist/harness/memory/types.d.ts +47 -7
- package/dist/harness/memory/wisdom-attribution.d.ts +136 -0
- package/dist/harness/memory/wisdom-attribution.js +287 -0
- package/dist/harness/memory/wisdom-events.d.ts +37 -0
- package/dist/harness/memory/wisdom-events.js +61 -0
- package/dist/harness/memory/wisdom-formation.d.ts +31 -1
- package/dist/harness/memory/wisdom-formation.js +130 -33
- package/dist/harness/memory/wisdom-gates.d.ts +14 -0
- package/dist/harness/memory/wisdom-gates.js +59 -19
- package/dist/harness/memory/wisdom.d.ts +7 -2
- package/dist/harness/memory/wisdom.js +49 -2
- package/dist/harness/observability/observer/hub.js +25 -15
- package/dist/harness/observability/observer/types.d.ts +10 -6
- package/dist/harness/run/agent/agent.d.ts +40 -21
- package/dist/harness/run/agent/agent.js +66 -13
- package/dist/harness/run/agent/index.d.ts +1 -1
- package/dist/harness/run/budget/budget.d.ts +28 -10
- package/dist/harness/run/budget/budget.js +38 -15
- package/dist/harness/run/model/index.d.ts +3 -1
- package/dist/harness/run/model/index.js +2 -1
- package/dist/harness/run/model/resolver.d.ts +4 -1
- package/dist/harness/run/model/resolver.js +36 -2
- package/dist/harness/run/model/run-scope.d.ts +2 -0
- package/dist/harness/run/model/run-scope.js +7 -0
- package/dist/harness/run/model/types.d.ts +22 -5
- package/dist/harness/run/model/types.js +3 -2
- package/dist/harness/run/model/window-truth.d.ts +37 -0
- package/dist/harness/run/model/window-truth.js +39 -0
- package/dist/harness/run/reliability/context-length-feedback.d.ts +77 -0
- package/dist/harness/run/reliability/context-length-feedback.js +128 -0
- package/dist/harness/run/reliability/harness-events.d.ts +3 -3
- package/dist/harness/run/reliability/model-error-policy.js +4 -0
- package/dist/harness/run/reliability/run-agent.d.ts +10 -4
- package/dist/harness/run/reliability/run-agent.js +137 -53
- package/dist/harness/run/reliability/run-metrics-collector.d.ts +19 -8
- package/dist/harness/run/reliability/run-metrics-collector.js +38 -23
- package/dist/harness/run/run-guard/default-run-guard.js +8 -8
- package/dist/harness/run/run-scope.d.ts +41 -4
- package/dist/harness/run/runner.d.ts +71 -31
- package/dist/harness/run/runner.js +368 -106
- package/dist/harness/session/attachments/index.d.ts +1 -0
- package/dist/harness/session/attachments/index.js +1 -0
- package/dist/harness/session/attachments/inject.d.ts +21 -10
- package/dist/harness/session/attachments/inject.js +76 -24
- package/dist/harness/session/attachments/recall-index.d.ts +70 -0
- package/dist/harness/session/attachments/recall-index.js +219 -0
- package/dist/harness/session/attachments/service.d.ts +21 -0
- package/dist/harness/session/attachments/service.js +258 -139
- package/dist/harness/session/attachments/types.d.ts +6 -0
- package/dist/harness/session/transform-store.d.ts +136 -0
- package/dist/harness/session/transform-store.js +302 -0
- package/dist/harness/session/types.d.ts +2 -2
- package/dist/harness/shared/events/agent-event-map.d.ts +46 -13
- package/dist/harness/shared/events/agent-event-map.js +3 -2
- package/dist/harness/shared/events/scenario-events.d.ts +6 -6
- package/dist/harness/shared/paths/glob.d.ts +52 -0
- package/dist/harness/shared/paths/glob.js +218 -0
- package/dist/harness/shared/paths/index.d.ts +84 -0
- package/dist/harness/shared/paths/index.js +179 -0
- package/dist/harness/shared/types/agent-definition.d.ts +1 -2
- package/dist/index.d.ts +14 -17
- package/dist/index.js +7 -9
- package/dist/integration/observability/metrics.d.ts +6 -6
- package/dist/integration/observability/metrics.js +13 -13
- package/dist/integration/observability/observer-bridge.js +2 -2
- package/dist/integration/observability/trace-collector.d.ts +5 -5
- package/dist/integration/observability/trace-collector.js +34 -35
- package/dist/integration/observability/trace-events.d.ts +3 -3
- package/dist/integration/observability/trace-events.js +3 -3
- package/dist/integration/providers/anthropic.js +14 -1
- package/dist/integration/providers/openai.js +7 -1
- package/dist/integration/providers/usage.d.ts +1 -1
- package/dist/integration/providers/wire-dump.d.ts +1 -1
- package/dist/integration/storage/archive-manager.d.ts +6 -0
- package/dist/integration/storage/archive-manager.js +10 -0
- package/dist/integration/storage/jsonl.d.ts +1 -1
- package/dist/integration/storage/jsonl.js +18 -16
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +4 -2
- package/dist/subsystems/cognition-steward/conceptualize/handler.js +12 -20
- package/dist/subsystems/memory-steward/backfill/config.yaml +4 -2
- package/dist/subsystems/memory-steward/backfill/handler.js +44 -52
- package/dist/subsystems/wisdom-steward/attribute/SUBSYSTEM.md +24 -0
- package/dist/subsystems/wisdom-steward/attribute/config.yaml +60 -0
- package/dist/subsystems/wisdom-steward/attribute/handler.d.ts +23 -0
- package/dist/subsystems/wisdom-steward/attribute/handler.js +167 -0
- package/dist/subsystems/wisdom-steward/evaluate/handler.js +3 -1
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +8 -1
- package/dist/subsystems/wisdom-steward/formation/config.yaml +13 -5
- package/dist/subsystems/wisdom-steward/formation/handler.js +39 -23
- package/dist/subsystems/wisdom-steward/govern/config.yaml +1 -1
- package/dist/subsystems/wisdom-steward/govern/handler.js +4 -0
- package/package.json +16 -14
- package/dist/harness/context/hybrid-compressor.d.ts +0 -41
- package/dist/harness/context/hybrid-compressor.js +0 -159
- package/dist/harness/context/llm-summarizer.d.ts +0 -46
- package/dist/harness/context/llm-summarizer.js +0 -249
- package/dist/harness/context/smart-router.d.ts +0 -75
- package/dist/harness/context/smart-router.js +0 -118
- package/dist/harness/context/truncate-compressor.d.ts +0 -28
- package/dist/harness/context/truncate-compressor.js +0 -107
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -97
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -155
- package/dist/harness/extension/plugin-ecosystem/plugins/hooks.d.ts +0 -7
- package/dist/harness/extension/plugin-ecosystem/plugins/hooks.js +0 -7
- package/dist/harness/extension/plugin-ecosystem/plugins/lifecycle.d.ts +0 -86
- package/dist/harness/extension/plugin-ecosystem/plugins/lifecycle.js +0 -139
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path glob compilation — shared by tool glob filters and path denylists.
|
|
3
|
+
*
|
|
4
|
+
* Semantics follow rg/git so that `file_search`'s `glob` argument and
|
|
5
|
+
* `effectPolicy.pathDenylist` cannot drift apart:
|
|
6
|
+
* - `**` crosses directories; `*` and `?` do not cross `/`
|
|
7
|
+
* - a pattern without `/` (for example `*.md`) matches at any depth
|
|
8
|
+
* - `{a,b}` alternatives are supported, including nesting
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Compile a path glob into a regular expression over root-relative paths.
|
|
12
|
+
*
|
|
13
|
+
* @param glob - glob pattern
|
|
14
|
+
* @returns anchored, case-insensitive matcher for a root-relative path
|
|
15
|
+
*/
|
|
16
|
+
export function globToPathRegex(glob) {
|
|
17
|
+
const trimmed = glob.trim();
|
|
18
|
+
if (!trimmed)
|
|
19
|
+
throw new Error('glob must be non-empty');
|
|
20
|
+
// Compiled patterns are pure functions of the pattern text, and denylists are
|
|
21
|
+
// re-evaluated for every walked file, so memoize instead of recompiling.
|
|
22
|
+
const cached = COMPILED.get(trimmed);
|
|
23
|
+
if (cached)
|
|
24
|
+
return cached;
|
|
25
|
+
const normalized = trimmed.includes('/') ? trimmed : `**/${trimmed}`;
|
|
26
|
+
const regex = new RegExp(`^${globToSource(normalized)}$`, 'i');
|
|
27
|
+
if (COMPILED.size >= COMPILE_CACHE_LIMIT)
|
|
28
|
+
COMPILED.clear();
|
|
29
|
+
COMPILED.set(trimmed, regex);
|
|
30
|
+
return regex;
|
|
31
|
+
}
|
|
32
|
+
const COMPILED = new Map();
|
|
33
|
+
const COMPILE_CACHE_LIMIT = 512;
|
|
34
|
+
/**
|
|
35
|
+
* Normalize a deny pattern into the path dialect the matcher speaks.
|
|
36
|
+
*
|
|
37
|
+
* Windows deployments write separators the way their shell does, so `\` is
|
|
38
|
+
* always a separator here. That makes an escaped literal (`.git\**` meaning
|
|
39
|
+
* "a file literally named `.git*`") impossible to express — acceptable, since a
|
|
40
|
+
* separator is what every real denylist entry means.
|
|
41
|
+
*
|
|
42
|
+
* @param pattern - raw deny pattern from configuration
|
|
43
|
+
* @returns pattern using `/` separators
|
|
44
|
+
*/
|
|
45
|
+
export function normalizeDenyPattern(pattern) {
|
|
46
|
+
return pattern.trim().split('\\').join('/');
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Reject deny patterns that can never match a root-relative path.
|
|
50
|
+
*
|
|
51
|
+
* A pattern that silently matches nothing is worse than a startup error: the
|
|
52
|
+
* deployment keeps believing it is protected. Shapes rejected here are all
|
|
53
|
+
* spellings that look meaningful but cannot match (`/x` anchors outside the
|
|
54
|
+
* root, `x/` never matches a resolved file, `../x` has no candidate).
|
|
55
|
+
*
|
|
56
|
+
* @param pattern - raw deny pattern from configuration
|
|
57
|
+
*/
|
|
58
|
+
export function validateDenyPattern(pattern) {
|
|
59
|
+
const normalized = normalizeDenyPattern(pattern);
|
|
60
|
+
if (!normalized)
|
|
61
|
+
throw new Error('pathDenylist: pattern must be non-empty');
|
|
62
|
+
if (normalized.startsWith('/')) {
|
|
63
|
+
throw new Error(`pathDenylist: "${pattern}" must be root-relative (drop the leading "/")`);
|
|
64
|
+
}
|
|
65
|
+
if (normalized.endsWith('/')) {
|
|
66
|
+
throw new Error(`pathDenylist: "${pattern}" must not end with a separator`);
|
|
67
|
+
}
|
|
68
|
+
if (normalized.split('/').some((segment) => segment === '..' || segment === '.')) {
|
|
69
|
+
throw new Error(`pathDenylist: "${pattern}" must not contain "." or ".." segments`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Compile a normalized glob fragment into regex source.
|
|
74
|
+
*
|
|
75
|
+
* @param glob - glob containing path separators
|
|
76
|
+
* @returns regex source without anchors
|
|
77
|
+
*/
|
|
78
|
+
function globToSource(glob) {
|
|
79
|
+
let out = '';
|
|
80
|
+
let index = 0;
|
|
81
|
+
while (index < glob.length) {
|
|
82
|
+
const char = glob[index];
|
|
83
|
+
// `\*`, `\?` and friends are literals.
|
|
84
|
+
if (char === '\\' && index + 1 < glob.length && '*?[]{}\\/!'.includes(glob[index + 1])) {
|
|
85
|
+
out += escapeRegex(glob[index + 1]);
|
|
86
|
+
index += 2;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (char === '*' && glob[index + 1] === '*') {
|
|
90
|
+
index += 2;
|
|
91
|
+
if (glob[index] === '/') {
|
|
92
|
+
index += 1;
|
|
93
|
+
// `**/` → any depth prefix, including zero segments
|
|
94
|
+
out += '(?:.*/)?';
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
out += '.*';
|
|
98
|
+
}
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (char === '*') {
|
|
102
|
+
index += 1;
|
|
103
|
+
out += '[^/]*';
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (char === '?') {
|
|
107
|
+
index += 1;
|
|
108
|
+
out += '[^/]';
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (char === '{') {
|
|
112
|
+
const end = findBraceEnd(glob, index);
|
|
113
|
+
if (end === -1) {
|
|
114
|
+
out += '\\{';
|
|
115
|
+
index += 1;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const alternatives = splitBraceAlternatives(glob.slice(index + 1, end));
|
|
119
|
+
out += `(?:${alternatives.map((alt) => globToSource(alt)).join('|')})`;
|
|
120
|
+
index = end + 1;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if ('.+^$()|[]'.includes(char)) {
|
|
124
|
+
out += `\\${char}`;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
out += char;
|
|
128
|
+
}
|
|
129
|
+
index += 1;
|
|
130
|
+
}
|
|
131
|
+
return out;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Find the `}` matching the `{` at `openIndex`, skipping nesting.
|
|
135
|
+
*
|
|
136
|
+
* @param glob - glob string
|
|
137
|
+
* @param openIndex - index of `{`
|
|
138
|
+
* @returns index of the matching `}`; -1 when unbalanced
|
|
139
|
+
*/
|
|
140
|
+
function findBraceEnd(glob, openIndex) {
|
|
141
|
+
let depth = 0;
|
|
142
|
+
for (let index = openIndex; index < glob.length; index += 1) {
|
|
143
|
+
if (glob[index] === '{')
|
|
144
|
+
depth += 1;
|
|
145
|
+
else if (glob[index] === '}') {
|
|
146
|
+
depth -= 1;
|
|
147
|
+
if (depth === 0)
|
|
148
|
+
return index;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return -1;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Split top-level comma alternatives inside braces.
|
|
155
|
+
*
|
|
156
|
+
* @param body - contents between braces
|
|
157
|
+
* @returns alternatives
|
|
158
|
+
*/
|
|
159
|
+
function splitBraceAlternatives(body) {
|
|
160
|
+
const alternatives = [];
|
|
161
|
+
let depth = 0;
|
|
162
|
+
let current = '';
|
|
163
|
+
for (const char of body) {
|
|
164
|
+
if (char === '{')
|
|
165
|
+
depth += 1;
|
|
166
|
+
if (char === '}')
|
|
167
|
+
depth -= 1;
|
|
168
|
+
if (char === ',' && depth === 0) {
|
|
169
|
+
alternatives.push(current);
|
|
170
|
+
current = '';
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
current += char;
|
|
174
|
+
}
|
|
175
|
+
alternatives.push(current);
|
|
176
|
+
return alternatives;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Escape a single character for use in a regex literal.
|
|
180
|
+
*
|
|
181
|
+
* @param char - character to escape
|
|
182
|
+
* @returns escaped character
|
|
183
|
+
*/
|
|
184
|
+
function escapeRegex(char) {
|
|
185
|
+
return char.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Whether a root-relative path matches any denylist pattern.
|
|
189
|
+
*
|
|
190
|
+
* Both the full relative path and the file name are tested, so `.env*` and
|
|
191
|
+
* `.git/**` can coexist without the caller deciding which form a pattern means.
|
|
192
|
+
* Invalid patterns are the caller's mistake and throw: silently ignoring a
|
|
193
|
+
* typo'd security pattern would leave the deployment believing it is protected.
|
|
194
|
+
*
|
|
195
|
+
* @param relativePath - path relative to the containing root, using `/`
|
|
196
|
+
* @param patterns - denylist globs
|
|
197
|
+
* @returns true when any pattern matches
|
|
198
|
+
*/
|
|
199
|
+
export function matchesDenyPattern(relativePath, patterns) {
|
|
200
|
+
if (patterns.length === 0)
|
|
201
|
+
return false;
|
|
202
|
+
const normalized = relativePath.split('\\').join('/');
|
|
203
|
+
const segments = normalized.split('/').filter(Boolean);
|
|
204
|
+
// Test the full path *and every suffix*, so a pattern like `.git/**` denies a
|
|
205
|
+
// `.git` directory at any depth. Anchoring only at the root would let
|
|
206
|
+
// `pkg/.git/config` through, which for a security denylist is a silent hole.
|
|
207
|
+
const candidates = [normalized];
|
|
208
|
+
for (let index = 1; index < segments.length; index += 1) {
|
|
209
|
+
candidates.push(segments.slice(index).join('/'));
|
|
210
|
+
}
|
|
211
|
+
const name = segments[segments.length - 1] ?? normalized;
|
|
212
|
+
if (!candidates.includes(name))
|
|
213
|
+
candidates.push(name);
|
|
214
|
+
return patterns.some((pattern) => {
|
|
215
|
+
const matcher = globToPathRegex(normalizeDenyPattern(pattern));
|
|
216
|
+
return candidates.some((candidate) => matcher.test(candidate));
|
|
217
|
+
});
|
|
218
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path containment primitives — shared by tool execution and effect auditing
|
|
3
|
+
*
|
|
4
|
+
* Containment is a cross-cutting mechanism, not a policy owned by one domain:
|
|
5
|
+
* the tools domain decides *what* may be touched (`pathRoots`, `containment`),
|
|
6
|
+
* while the execution-environment domain decides *what gets recorded*. Both
|
|
7
|
+
* need the same answer to "is this path under that root", and both need it in
|
|
8
|
+
* real coordinates — a purely lexical comparison lets a symlink inside a root
|
|
9
|
+
* reach outside it.
|
|
10
|
+
*
|
|
11
|
+
* These helpers live in `shared/` so that no domain has to import another
|
|
12
|
+
* domain's internals to get correct containment. They are foundation code:
|
|
13
|
+
* no policy defaults, no product decisions.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Resolve a path that may not exist yet to its real location.
|
|
17
|
+
*
|
|
18
|
+
* `realpathSync` throws for a missing target, but creating a new file is a
|
|
19
|
+
* normal operation. Walk up to the deepest existing ancestor, resolve that,
|
|
20
|
+
* and re-append the remaining segments. `resolve()` already folded `..`, so the
|
|
21
|
+
* appended tail cannot introduce a new escape.
|
|
22
|
+
*
|
|
23
|
+
* A missing segment that *does* exist as a directory entry is not treated as
|
|
24
|
+
* "about to be created": that is a dangling symlink or a link loop, and letting
|
|
25
|
+
* it through would allow the following open/write to follow it out of the root.
|
|
26
|
+
* `lstatSync` does not follow the final component, which separates the cases.
|
|
27
|
+
*
|
|
28
|
+
* @param abs - absolute, lexically normalized path
|
|
29
|
+
* @returns real path, or null when it cannot be resolved safely
|
|
30
|
+
*/
|
|
31
|
+
export declare function realpathAllowMissing(abs: string): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Containment over already-normalized paths (no filesystem access).
|
|
34
|
+
*
|
|
35
|
+
* Use this only when both sides are already real paths; otherwise prefer
|
|
36
|
+
* {@link isPathUnderRoots}, which resolves them first.
|
|
37
|
+
*
|
|
38
|
+
* Windows drive letters are compared case-insensitively, matching how the
|
|
39
|
+
* effect policy treats volume names.
|
|
40
|
+
*
|
|
41
|
+
* @param absPath - path already resolved to its real form
|
|
42
|
+
* @param roots - roots already resolved to their real form
|
|
43
|
+
* @returns whether the path is one of the roots or under one
|
|
44
|
+
*/
|
|
45
|
+
export declare function lexicalUnderRoots(absPath: string, roots: string[]): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Whether a path falls under any of the given roots, in real coordinates.
|
|
48
|
+
*
|
|
49
|
+
* Both sides are resolved: comparing a resolved target against an unresolved
|
|
50
|
+
* root would wrongly deny legitimate paths whenever the root is itself an alias
|
|
51
|
+
* (macOS `/var` → `/private/var`, a symlinked `$HOME`). A path that cannot be
|
|
52
|
+
* resolved falls back to its lexical form, so this only ever answers "is it
|
|
53
|
+
* inside", never "is it safe to operate on" — callers that need the resolved
|
|
54
|
+
* path must use their own resolution step.
|
|
55
|
+
*
|
|
56
|
+
* @param absPath - path to test
|
|
57
|
+
* @param roots - allowed roots
|
|
58
|
+
* @returns true when the path is one of the roots or under one
|
|
59
|
+
*/
|
|
60
|
+
export declare function isPathUnderRoots(absPath: string, roots: readonly string[]): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Whether the final path component is a symbolic link, without following it.
|
|
63
|
+
*
|
|
64
|
+
* `lstat` inspects the entry itself, so a dangling link still reports `true` —
|
|
65
|
+
* which is what a write guard needs: an unresolvable link is exactly the case
|
|
66
|
+
* where a later open would follow it somewhere unintended.
|
|
67
|
+
*
|
|
68
|
+
* @param path - path to inspect
|
|
69
|
+
* @returns true when the entry exists and is a symlink
|
|
70
|
+
*/
|
|
71
|
+
export declare function isFinalSymlink(path: string): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Read a file refusing to traverse a symlink at the final component.
|
|
74
|
+
*
|
|
75
|
+
* Resolving containment already returns a real path, so normally the final
|
|
76
|
+
* component is not a link. If it is one at open time, something replaced it
|
|
77
|
+
* between the containment check and this open; `O_NOFOLLOW` makes the kernel
|
|
78
|
+
* refuse instead of following it (`ELOOP`).
|
|
79
|
+
*
|
|
80
|
+
* @param path - absolute path, normally already resolved
|
|
81
|
+
* @param encoding - text encoding
|
|
82
|
+
* @returns file contents
|
|
83
|
+
*/
|
|
84
|
+
export declare function readFileNoFollow(path: string, encoding: 'utf8'): Promise<string>;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path containment primitives — shared by tool execution and effect auditing
|
|
3
|
+
*
|
|
4
|
+
* Containment is a cross-cutting mechanism, not a policy owned by one domain:
|
|
5
|
+
* the tools domain decides *what* may be touched (`pathRoots`, `containment`),
|
|
6
|
+
* while the execution-environment domain decides *what gets recorded*. Both
|
|
7
|
+
* need the same answer to "is this path under that root", and both need it in
|
|
8
|
+
* real coordinates — a purely lexical comparison lets a symlink inside a root
|
|
9
|
+
* reach outside it.
|
|
10
|
+
*
|
|
11
|
+
* These helpers live in `shared/` so that no domain has to import another
|
|
12
|
+
* domain's internals to get correct containment. They are foundation code:
|
|
13
|
+
* no policy defaults, no product decisions.
|
|
14
|
+
*/
|
|
15
|
+
import { lstatSync, realpathSync } from 'node:fs';
|
|
16
|
+
import { basename, dirname, join, resolve, sep } from 'node:path';
|
|
17
|
+
/**
|
|
18
|
+
* Resolve a path that may not exist yet to its real location.
|
|
19
|
+
*
|
|
20
|
+
* `realpathSync` throws for a missing target, but creating a new file is a
|
|
21
|
+
* normal operation. Walk up to the deepest existing ancestor, resolve that,
|
|
22
|
+
* and re-append the remaining segments. `resolve()` already folded `..`, so the
|
|
23
|
+
* appended tail cannot introduce a new escape.
|
|
24
|
+
*
|
|
25
|
+
* A missing segment that *does* exist as a directory entry is not treated as
|
|
26
|
+
* "about to be created": that is a dangling symlink or a link loop, and letting
|
|
27
|
+
* it through would allow the following open/write to follow it out of the root.
|
|
28
|
+
* `lstatSync` does not follow the final component, which separates the cases.
|
|
29
|
+
*
|
|
30
|
+
* @param abs - absolute, lexically normalized path
|
|
31
|
+
* @returns real path, or null when it cannot be resolved safely
|
|
32
|
+
*/
|
|
33
|
+
export function realpathAllowMissing(abs) {
|
|
34
|
+
let current = abs;
|
|
35
|
+
const tail = [];
|
|
36
|
+
for (;;) {
|
|
37
|
+
try {
|
|
38
|
+
const real = realpathSync(current);
|
|
39
|
+
return tail.length ? join(real, ...tail) : real;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
const code = error.code;
|
|
43
|
+
if (code !== 'ENOENT' && code !== 'ENOTDIR')
|
|
44
|
+
return null;
|
|
45
|
+
if (existsLstat(current))
|
|
46
|
+
return null;
|
|
47
|
+
const parent = dirname(current);
|
|
48
|
+
if (parent === current)
|
|
49
|
+
return null;
|
|
50
|
+
tail.unshift(basename(current));
|
|
51
|
+
current = parent;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Whether anything exists at this path, without following a final symlink.
|
|
57
|
+
*
|
|
58
|
+
* @param path - absolute path
|
|
59
|
+
* @returns true when an entry exists (including a dangling link)
|
|
60
|
+
*/
|
|
61
|
+
function existsLstat(path) {
|
|
62
|
+
try {
|
|
63
|
+
lstatSync(path);
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Containment over already-normalized paths (no filesystem access).
|
|
72
|
+
*
|
|
73
|
+
* Use this only when both sides are already real paths; otherwise prefer
|
|
74
|
+
* {@link isPathUnderRoots}, which resolves them first.
|
|
75
|
+
*
|
|
76
|
+
* Windows drive letters are compared case-insensitively, matching how the
|
|
77
|
+
* effect policy treats volume names.
|
|
78
|
+
*
|
|
79
|
+
* @param absPath - path already resolved to its real form
|
|
80
|
+
* @param roots - roots already resolved to their real form
|
|
81
|
+
* @returns whether the path is one of the roots or under one
|
|
82
|
+
*/
|
|
83
|
+
export function lexicalUnderRoots(absPath, roots) {
|
|
84
|
+
const win = process.platform === 'win32';
|
|
85
|
+
const norm = (s) => (win ? s.toLowerCase() : s);
|
|
86
|
+
const target = norm(absPath);
|
|
87
|
+
return roots.some((root) => {
|
|
88
|
+
const r = norm(root);
|
|
89
|
+
return target === r || target.startsWith(r.endsWith(sep) ? r : r + sep);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Whether a path falls under any of the given roots, in real coordinates.
|
|
94
|
+
*
|
|
95
|
+
* Both sides are resolved: comparing a resolved target against an unresolved
|
|
96
|
+
* root would wrongly deny legitimate paths whenever the root is itself an alias
|
|
97
|
+
* (macOS `/var` → `/private/var`, a symlinked `$HOME`). A path that cannot be
|
|
98
|
+
* resolved falls back to its lexical form, so this only ever answers "is it
|
|
99
|
+
* inside", never "is it safe to operate on" — callers that need the resolved
|
|
100
|
+
* path must use their own resolution step.
|
|
101
|
+
*
|
|
102
|
+
* @param absPath - path to test
|
|
103
|
+
* @param roots - allowed roots
|
|
104
|
+
* @returns true when the path is one of the roots or under one
|
|
105
|
+
*/
|
|
106
|
+
export function isPathUnderRoots(absPath, roots) {
|
|
107
|
+
const lexical = roots.map((root) => resolve(root));
|
|
108
|
+
const target = resolve(absPath);
|
|
109
|
+
const real = (s) => realpathAllowMissing(s) ?? s;
|
|
110
|
+
const realTarget = realpathAllowMissing(target);
|
|
111
|
+
if (realTarget !== null) {
|
|
112
|
+
// Compare in real coordinates: a resolved target against an unresolved root
|
|
113
|
+
// would deny legitimate paths whenever the root is itself an alias.
|
|
114
|
+
return lexicalUnderRoots(realTarget, lexical.map(real));
|
|
115
|
+
}
|
|
116
|
+
// The target exists but cannot be resolved (dangling symlink or link loop).
|
|
117
|
+
// Comparing a lexical target against resolved roots would mix coordinate
|
|
118
|
+
// systems and report an in-root link as outside. Stay lexical on both sides.
|
|
119
|
+
// This answers containment only; callers that act on the path must take
|
|
120
|
+
// realpathAllowMissing's null and refuse, which is what containPath does.
|
|
121
|
+
return lexicalUnderRoots(target, lexical);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Whether the final path component is a symbolic link, without following it.
|
|
125
|
+
*
|
|
126
|
+
* `lstat` inspects the entry itself, so a dangling link still reports `true` —
|
|
127
|
+
* which is what a write guard needs: an unresolvable link is exactly the case
|
|
128
|
+
* where a later open would follow it somewhere unintended.
|
|
129
|
+
*
|
|
130
|
+
* @param path - path to inspect
|
|
131
|
+
* @returns true when the entry exists and is a symlink
|
|
132
|
+
*/
|
|
133
|
+
export function isFinalSymlink(path) {
|
|
134
|
+
try {
|
|
135
|
+
return lstatSync(path).isSymbolicLink();
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
// ENOENT / ENOTDIR: nothing at that name, so nothing to follow.
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Read a file refusing to traverse a symlink at the final component.
|
|
144
|
+
*
|
|
145
|
+
* Resolving containment already returns a real path, so normally the final
|
|
146
|
+
* component is not a link. If it is one at open time, something replaced it
|
|
147
|
+
* between the containment check and this open; `O_NOFOLLOW` makes the kernel
|
|
148
|
+
* refuse instead of following it (`ELOOP`).
|
|
149
|
+
*
|
|
150
|
+
* @param path - absolute path, normally already resolved
|
|
151
|
+
* @param encoding - text encoding
|
|
152
|
+
* @returns file contents
|
|
153
|
+
*/
|
|
154
|
+
export async function readFileNoFollow(path, encoding) {
|
|
155
|
+
const { open, constants } = await import('node:fs/promises');
|
|
156
|
+
// O_NOFOLLOW is POSIX-only. On Windows it is absent, and `0 | undefined` is
|
|
157
|
+
// `0` — which would silently mean "follow the link", the opposite of intent.
|
|
158
|
+
// Fall back to an lstat pre-check there: it keeps refusing dangling links
|
|
159
|
+
// (the common planted case) at the cost of a narrower TOCTOU window.
|
|
160
|
+
if (constants.O_NOFOLLOW === undefined) {
|
|
161
|
+
if (isFinalSymlink(path)) {
|
|
162
|
+
throw new Error(`path_forbidden: "${path}" final component is a symlink (no O_NOFOLLOW on this platform)`);
|
|
163
|
+
}
|
|
164
|
+
const handle = await open(path, 'r');
|
|
165
|
+
try {
|
|
166
|
+
return await handle.readFile({ encoding });
|
|
167
|
+
}
|
|
168
|
+
finally {
|
|
169
|
+
await handle.close();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
173
|
+
try {
|
|
174
|
+
return await handle.readFile({ encoding });
|
|
175
|
+
}
|
|
176
|
+
finally {
|
|
177
|
+
await handle.close();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -18,7 +18,6 @@ export interface AgentPersona {
|
|
|
18
18
|
export interface ModelConfig {
|
|
19
19
|
provider: string;
|
|
20
20
|
model: string;
|
|
21
|
-
temperature?: number;
|
|
22
21
|
maxTokens?: number;
|
|
23
22
|
contextWindow?: number;
|
|
24
23
|
/** 回退模型列表(按优先级排序,由 resolveModelConfig 解析后的完整配置) */
|
|
@@ -65,7 +64,7 @@ export interface AgentDefinition {
|
|
|
65
64
|
rightsCeiling?: SessionRights;
|
|
66
65
|
/** 委派预算上限(请求预算与此取交集) */
|
|
67
66
|
budget?: {
|
|
68
|
-
|
|
67
|
+
maxSteps?: number;
|
|
69
68
|
maxTokens?: number;
|
|
70
69
|
timeoutMs?: number;
|
|
71
70
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ export { BudgetPolicyEngine, DEFAULT_BUDGET } from './harness/run/budget/budget.
|
|
|
12
12
|
export type { BudgetPolicyConfig } from './harness/run/budget/budget.js';
|
|
13
13
|
export { UsageLedger } from './harness/governance/accounting/usage-ledger.js';
|
|
14
14
|
export type { UsageLedgerSnapshot } from './harness/governance/accounting/usage-ledger.js';
|
|
15
|
-
export { emptyTokenUsage, makeTokenUsage, nominalTotalTokens, reportedPromptTokens, } from '@octopi-agent/core/types/
|
|
16
|
-
export type { TokenUsage } from '@octopi-agent/core/types/
|
|
15
|
+
export { emptyTokenUsage, makeTokenUsage, nominalTotalTokens, reportedPromptTokens, } from '@octopi-agent/core/types/step.js';
|
|
16
|
+
export type { TokenUsage } from '@octopi-agent/core/types/step.js';
|
|
17
17
|
export type { ModelProvider, LLMRequest, LLMResponse, LLMStreamChunk, LLMToolDefinition } from '@octopi-agent/core/interfaces/model-provider.js';
|
|
18
18
|
/** 领域富模型(注册/权限/参数校验);LLM 传输格式见 LLMToolDefinition */
|
|
19
19
|
export type { ToolDefinition, RegisteredTool, ToolHandler, ToolParameter, ToolSource, ToolExecutionContext } from '@octopi-agent/core/types/tools.js';
|
|
@@ -22,7 +22,7 @@ export type { SecurityAction } from '@octopi-agent/core/security-guard.js';
|
|
|
22
22
|
export type { Observer, Span, LogLevel } from '@octopi-agent/core/interfaces/observer.js';
|
|
23
23
|
export type { SessionStore, SessionListFilter } from '@octopi-agent/core/interfaces/session-store.js';
|
|
24
24
|
export type { SessionData, SessionLifecycleMeta, SessionLifecycleStatus, MemoryExtractionStatus } from './harness/session/types.js';
|
|
25
|
-
export type { ContextEngine, ContextEngineInfo, AssembleParams, AssembleResult, IngestParams,
|
|
25
|
+
export type { ContextEngine, ContextEngineInfo, AssembleParams, AssembleResult, IngestParams, AfterStepParams, TokenEstimator, SummarizeFunction, MessageSelector, SelectResult, SelectOptions, BudgetAllocator, BudgetAllocateParams, BudgetAllocateResult, } from './harness/context/types.js';
|
|
26
26
|
export { setRunTelemetryFactory, getRunTelemetryFactory } from './harness/observability/run-telemetry.js';
|
|
27
27
|
export type { RunTelemetry, RunTelemetryFactory } from './harness/observability/run-telemetry.js';
|
|
28
28
|
export { createRunTelemetry } from './integration/observability/run-telemetry.js';
|
|
@@ -31,7 +31,7 @@ export type { AgentTraceOptions } from './harness/agent/builder.js';
|
|
|
31
31
|
export type { AgentBuildOptions, AgentBuildResult, AgentBuildCoreResult } from './harness/agent/builder.js';
|
|
32
32
|
export type { ChannelAdapter, ChannelMessage, ChannelReply } from './harness/extension/plugin-ecosystem/channel-types.js';
|
|
33
33
|
export { Agent } from './harness/run/agent/index.js';
|
|
34
|
-
export type { AgentOptions } from './harness/run/agent/index.js';
|
|
34
|
+
export type { AgentOptions, RunIdentity } from './harness/run/agent/index.js';
|
|
35
35
|
export type { HarnessLoopEvent, BudgetControlEvent, ControlStopMetric, PolicyUnit } from './harness/run/reliability/harness-events.js';
|
|
36
36
|
export { SessionAwareRunner } from './harness/run/runner.js';
|
|
37
37
|
export { DEFAULT_TOOL_ISOLATION, resolveToolIsolationCwd, } from './harness/extension/execution-environment/isolation.js';
|
|
@@ -47,6 +47,7 @@ export { runWithToolLimits, resolveToolTimeoutMs, ToolTimeoutError, } from './ha
|
|
|
47
47
|
export type { EffectIntent, ConfirmEffect, ConfirmEffectDecision, UntrustedAdmission, JailIntent, OnJailUnavailable, OpsJailState, ToolSurface, SecurityDegradation, SessionEffectOverrides, } from './harness/extension/execution-environment/effect-policy.js';
|
|
48
48
|
export type { EffectRunMode, EffectPolicyConfig, EffectiveEffectPolicy, PathContainment, ShellEscapePolicy, } from './harness/extension/execution-environment/effect-policy.js';
|
|
49
49
|
export { scanOrphanSessionUndo, } from './harness/extension/execution-environment/undo-log.js';
|
|
50
|
+
export { scanOrphanSessionTransform } from './harness/session/transform-store.js';
|
|
50
51
|
export type { SessionUndoPaths, FileUndoEntry, DiscardFileEffectsResult, DiscardConflictReason, EditResendResult, NotReversedEffects, NotReversedReason, UndoLimitConfig, OrphanUndoDir, } from './harness/extension/execution-environment/undo-log.js';
|
|
51
52
|
export type { ShellJournalMode } from './harness/extension/execution-environment/effect-policy.js';
|
|
52
53
|
export type { ToolFileEffects } from '@octopi-agent/core/types/tools.js';
|
|
@@ -61,22 +62,17 @@ export { DefaultContextEngine } from './harness/context/default-context-engine.j
|
|
|
61
62
|
export type { DefaultContextEngineConfig } from './harness/context/default-context-engine.js';
|
|
62
63
|
export { HeuristicTokenEstimator, estimateTextTokens } from './harness/context/index.js';
|
|
63
64
|
export { DefaultMessageSelector } from './harness/context/message-selector.js';
|
|
64
|
-
export { TruncateCompressor } from './harness/context/truncate-compressor.js';
|
|
65
|
-
export { LLMSummaryCompressor } from './harness/context/llm-summarizer.js';
|
|
66
|
-
export { HybridCompressor } from './harness/context/hybrid-compressor.js';
|
|
67
65
|
export { DefaultBudgetAllocator } from './harness/context/budget-allocator.js';
|
|
68
|
-
export { SmartRouter } from './harness/context/smart-router.js';
|
|
69
|
-
export type { SmartRouterConfig, Route, RoutingDecision } from './harness/context/smart-router.js';
|
|
70
66
|
export { CapabilityEnforcer, PluginTrustLevel } from './harness/governance/security/capability-enforcer.js';
|
|
71
67
|
export { PluginManager } from './harness/extension/plugin-ecosystem/plugins/manager.js';
|
|
72
|
-
export {
|
|
73
|
-
export type { OctopiPluginDefinition
|
|
68
|
+
export { definePlugin } from './harness/extension/plugin-ecosystem/plugins/entry.js';
|
|
69
|
+
export type { OctopiPluginDefinition } from './harness/extension/plugin-ecosystem/plugins/entry.js';
|
|
74
70
|
export { PluginApi } from './harness/extension/plugin-ecosystem/plugins/api.js';
|
|
75
71
|
export { PluginLoader } from './harness/extension/plugin-ecosystem/plugins/loader.js';
|
|
76
|
-
export type { LoadedPlugin, PluginLoaderConfig, PluginEntryConfig } from './harness/extension/plugin-ecosystem/plugins/loader.js';
|
|
77
|
-
export {
|
|
78
|
-
export { validateManifest, parseManifest } from './harness/extension/plugin-ecosystem/plugins/manifest.js';
|
|
79
|
-
export type { PluginManifest,
|
|
72
|
+
export type { LoadedPlugin, PluginLoaderConfig, PluginEntryConfig, PluginDiagnostic } from './harness/extension/plugin-ecosystem/plugins/loader.js';
|
|
73
|
+
export { PluginContributionRegistry } from './harness/extension/plugin-ecosystem/plugins/contribution-registry.js';
|
|
74
|
+
export { validateManifest, parseManifest, validatePluginConfig, PLUGIN_API_VERSION } from './harness/extension/plugin-ecosystem/plugins/manifest.js';
|
|
75
|
+
export type { PluginManifest, PluginContributions, PluginHookName, PluginSessionOpName } from './harness/extension/plugin-ecosystem/plugins/manifest.js';
|
|
80
76
|
export { DefaultSkillManager, FileSystemSkillSource } from './harness/extension/plugin-ecosystem/skills/manager.js';
|
|
81
77
|
export type { SkillSource, DiscoveredSkill } from './harness/extension/plugin-ecosystem/skills/manager.js';
|
|
82
78
|
export type { SkillDefinition, SkillManager } from './harness/extension/plugin-ecosystem/skills/types.js';
|
|
@@ -92,7 +88,8 @@ export { readGitStatusSnapshot, parsePorcelainV2 } from './harness/extension/plu
|
|
|
92
88
|
export type { GitStatusSnapshot, GitStatusSnapshotBody, GitStatusSnapshotOptions, GitStatusEntry, GitStatusBranch, GitStatusCounts, GitStatusGroup, GitStatusKind, } from './harness/extension/plugin-ecosystem/tools/git-status-snapshot.js';
|
|
93
89
|
export { createSummaryPort, applyToolOutputGate, createCompactEngine } from './harness/context/capabilities/index.js';
|
|
94
90
|
export { createDefaultDocumentPort, createDocumentPortFromConfig, DocumentExtractError } from './harness/capabilities/document/index.js';
|
|
95
|
-
export type { SummaryPort, SummaryPolicy, ContentUnit, ToolSummarySupport, CompactEngine } from './harness/context/capabilities/index.js';
|
|
91
|
+
export type { SummaryPort, SummaryPolicy, ContentUnit, ToolSummarySupport, CompactEngine, CompactOutcome, CompactTransportOutcome } from './harness/context/capabilities/index.js';
|
|
92
|
+
export { toCompactTransport } from './harness/context/capabilities/compact/types.js';
|
|
96
93
|
export type { DocumentPort, ExtractResult, ExtractSource } from './harness/capabilities/document/index.js';
|
|
97
94
|
export type { ToolSet, ToolSetConfig } from './harness/extension/plugin-ecosystem/tools/tool-set.js';
|
|
98
95
|
export { createWebSearchTool } from './harness/extension/plugin-ecosystem/tools/web-search.js';
|
|
@@ -102,7 +99,7 @@ export { createSessionHistoryTools, createSessionSearchTool, createSessionReadTo
|
|
|
102
99
|
export type { SessionHistoryPort, SessionHistoryQuery, SessionHistorySearchResult, } from './harness/session/history/index.js';
|
|
103
100
|
export { buildFromConfig } from './harness/agent/config-bridge.js';
|
|
104
101
|
export type { BuiltAgent } from './harness/agent/config-bridge.js';
|
|
105
|
-
export { DefaultAgentRegistry, DelegationStore, DelegateService, DelegateResolutionError, InProcessTransport, RunnerChildRunPort, createChildRunExecutor, createDelegationNotifier, renderDelegationNotice, wireDelegation, createDelegationRuntime, AgentRegistryEvents, DelegationEvents, DELEGATION_SCHEMA_VERSION, } from './harness/collaboration/delegation/index.js';
|
|
102
|
+
export { DefaultAgentRegistry, DelegationStore, DelegateService, DelegateResolutionError, InProcessTransport, RunnerChildRunPort, createChildRunExecutor, createDelegationNotifier, renderDelegationNotice, wireDelegation, createDelegationRuntime, AgentRegistryEvents, DelegationEvents, DELEGATION_SCHEMA_VERSION, DEFAULT_DELEGATION_OUTPUT_CHARS, normalizeMaxOutputChars, } from './harness/collaboration/delegation/index.js';
|
|
106
103
|
export type { Delegation, DelegateRequest, DelegateResult, AgentHandle, AgentRegistry, AgentInfo, AgentQuery, AgentRelation, AgentRelationType, AgentDelegationPolicy, DelegateTransport, DelegatableAgent, DelegationRuntime, } from './harness/collaboration/delegation/index.js';
|
|
107
104
|
export { JsonlSessionStore } from './integration/storage/jsonl.js';
|
|
108
105
|
export { InMemorySessionStore } from './integration/storage/memory.js';
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export { AgentEvents } from './harness/shared/events/agent-event-map.js';
|
|
|
11
11
|
export { DefaultSecurityGuard } from './harness/governance/security/default-security-guard.js';
|
|
12
12
|
export { BudgetPolicyEngine, DEFAULT_BUDGET } from './harness/run/budget/budget.js';
|
|
13
13
|
export { UsageLedger } from './harness/governance/accounting/usage-ledger.js';
|
|
14
|
-
export { emptyTokenUsage, makeTokenUsage, nominalTotalTokens, reportedPromptTokens, } from '@octopi-agent/core/types/
|
|
14
|
+
export { emptyTokenUsage, makeTokenUsage, nominalTotalTokens, reportedPromptTokens, } from '@octopi-agent/core/types/step.js';
|
|
15
15
|
// ============================================================
|
|
16
16
|
// Harness 层
|
|
17
17
|
// ============================================================
|
|
@@ -31,24 +31,21 @@ export { resolveEffectiveEffectPolicy, requiresJail, buildOpsJailState, isPathAl
|
|
|
31
31
|
export { ProcessSandbox, createProcessSandbox, assessL4ProcessMinimum, probeProcessIsolation, scrubEnv, killProcessTree, supervisedSpawnProfile, } from './harness/extension/execution-environment/index.js';
|
|
32
32
|
export { runWithToolLimits, resolveToolTimeoutMs, ToolTimeoutError, } from './harness/extension/execution-environment/resource-limits.js';
|
|
33
33
|
export { scanOrphanSessionUndo, } from './harness/extension/execution-environment/undo-log.js';
|
|
34
|
+
export { scanOrphanSessionTransform } from './harness/session/transform-store.js';
|
|
34
35
|
export { InProcessSessionLock } from './harness/run/concurrency/session-lease.js';
|
|
35
36
|
export { SessionAclService, BUILTIN_SESSION_ROLES, computeEffectiveRights, } from './harness/governance/session-acl/index.js';
|
|
36
37
|
export { loadPersona, composePersonas, PersonaSource } from './harness/agent/persona.js';
|
|
37
38
|
export { DefaultContextEngine } from './harness/context/default-context-engine.js';
|
|
38
39
|
export { HeuristicTokenEstimator, estimateTextTokens } from './harness/context/index.js';
|
|
39
40
|
export { DefaultMessageSelector } from './harness/context/message-selector.js';
|
|
40
|
-
export { TruncateCompressor } from './harness/context/truncate-compressor.js';
|
|
41
|
-
export { LLMSummaryCompressor } from './harness/context/llm-summarizer.js';
|
|
42
|
-
export { HybridCompressor } from './harness/context/hybrid-compressor.js';
|
|
43
41
|
export { DefaultBudgetAllocator } from './harness/context/budget-allocator.js';
|
|
44
|
-
export { SmartRouter } from './harness/context/smart-router.js';
|
|
45
42
|
export { CapabilityEnforcer, PluginTrustLevel } from './harness/governance/security/capability-enforcer.js';
|
|
46
43
|
export { PluginManager } from './harness/extension/plugin-ecosystem/plugins/manager.js';
|
|
47
|
-
export {
|
|
44
|
+
export { definePlugin } from './harness/extension/plugin-ecosystem/plugins/entry.js';
|
|
48
45
|
export { PluginApi } from './harness/extension/plugin-ecosystem/plugins/api.js';
|
|
49
46
|
export { PluginLoader } from './harness/extension/plugin-ecosystem/plugins/loader.js';
|
|
50
|
-
export {
|
|
51
|
-
export { validateManifest, parseManifest } from './harness/extension/plugin-ecosystem/plugins/manifest.js';
|
|
47
|
+
export { PluginContributionRegistry } from './harness/extension/plugin-ecosystem/plugins/contribution-registry.js';
|
|
48
|
+
export { validateManifest, parseManifest, validatePluginConfig, PLUGIN_API_VERSION } from './harness/extension/plugin-ecosystem/plugins/manifest.js';
|
|
52
49
|
export { DefaultSkillManager, FileSystemSkillSource } from './harness/extension/plugin-ecosystem/skills/manager.js';
|
|
53
50
|
export { DefaultToolBus } from './harness/extension/plugin-ecosystem/tools/tool-bus.js';
|
|
54
51
|
export { buildToolLlmParameters, prepareHandlerArgs, readToolCallPurpose, resolveToolCallPurpose, sanitizeToolJsonSchema, toolDeclaresPurpose, TOOL_PURPOSE_PARAM, TOOL_PURPOSE_SYSTEM_NOTE, } from './harness/agent/tool-purpose.js';
|
|
@@ -58,12 +55,13 @@ export { createToolSet } from './harness/extension/plugin-ecosystem/tools/tool-s
|
|
|
58
55
|
export { readGitStatusSnapshot, parsePorcelainV2 } from './harness/extension/plugin-ecosystem/tools/git-status-snapshot.js';
|
|
59
56
|
export { createSummaryPort, applyToolOutputGate, createCompactEngine } from './harness/context/capabilities/index.js';
|
|
60
57
|
export { createDefaultDocumentPort, createDocumentPortFromConfig, DocumentExtractError } from './harness/capabilities/document/index.js';
|
|
58
|
+
export { toCompactTransport } from './harness/context/capabilities/compact/types.js';
|
|
61
59
|
export { createWebSearchTool } from './harness/extension/plugin-ecosystem/tools/web-search.js';
|
|
62
60
|
export { createSessionHistoryPort, resolveHistoryAccess, } from './harness/session/history/index.js';
|
|
63
61
|
export { createSessionHistoryTools, createSessionSearchTool, createSessionReadTool, } from './harness/extension/plugin-ecosystem/tools/session-history.js';
|
|
64
62
|
export { buildFromConfig } from './harness/agent/config-bridge.js';
|
|
65
63
|
// ── Delegation(L2 委派契约层;arch/delegation.md)──
|
|
66
|
-
export { DefaultAgentRegistry, DelegationStore, DelegateService, DelegateResolutionError, InProcessTransport, RunnerChildRunPort, createChildRunExecutor, createDelegationNotifier, renderDelegationNotice, wireDelegation, createDelegationRuntime, AgentRegistryEvents, DelegationEvents, DELEGATION_SCHEMA_VERSION, } from './harness/collaboration/delegation/index.js';
|
|
64
|
+
export { DefaultAgentRegistry, DelegationStore, DelegateService, DelegateResolutionError, InProcessTransport, RunnerChildRunPort, createChildRunExecutor, createDelegationNotifier, renderDelegationNotice, wireDelegation, createDelegationRuntime, AgentRegistryEvents, DelegationEvents, DELEGATION_SCHEMA_VERSION, DEFAULT_DELEGATION_OUTPUT_CHARS, normalizeMaxOutputChars, } from './harness/collaboration/delegation/index.js';
|
|
67
65
|
// ============================================================
|
|
68
66
|
// Integration 层(engine 库能力)
|
|
69
67
|
// ============================================================
|