@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
|
@@ -1,59 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shell Parser —
|
|
2
|
+
* Shell Parser — 解析入口 facade
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* 3. 识别 >, >>, < 重定向 → 提取目标路径
|
|
9
|
-
* 4. 识别 sudo, env, exec 等 wrapper → 解包实际命令
|
|
4
|
+
* 主引擎:tree-sitter(shell-parser-treesitter.ts,vendored bash 语法 wasm);
|
|
5
|
+
* 回退引擎:纯字符串解析(shell-parser-fallback.ts,长期保留的降级防线,
|
|
6
|
+
* 保证主引擎缺席/解析报错时硬边界探测仍有输入)。
|
|
7
|
+
* 消费方(risk-evaluator / degradation)只依赖本模块导出,不感知引擎差异。
|
|
10
8
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* 回退语义:
|
|
10
|
+
* - 引擎未初始化(未走 Agent 构建引导的直接调用,如单元测试)→ fallback 结果;
|
|
11
|
+
* - tree-sitter 对某输入解析报错(语法树含 ERROR)或内部异常 → fallback 结果
|
|
12
|
+
* 并标记 `uncertain: true`,风险分档会附加「结构不确定」因子走 unknown 通道。
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* 不止 shell,python/ruby/perl/node 等也是解释器。
|
|
19
|
-
* curl ... | python3 和 curl ... | sh 本质相同。
|
|
20
|
-
*/
|
|
21
|
-
const INTERPRETER_NAMES = new Set([
|
|
22
|
-
'sh', 'bash', 'zsh', 'dash', 'ksh', 'fish',
|
|
23
|
-
'python', 'python3', 'ruby', 'perl', 'node', 'php',
|
|
24
|
-
'lua', 'tclsh', 'Rscript', 'scala', 'groovy',
|
|
25
|
-
'powershell', 'powershell.exe', 'pwsh', 'pwsh.exe', 'cmd', 'cmd.exe',
|
|
26
|
-
]);
|
|
27
|
-
/**
|
|
28
|
-
* 已知的内联代码执行参数
|
|
29
|
-
*
|
|
30
|
-
* python -c "...", node -e "...", ruby -e "...", perl -e "..."
|
|
31
|
-
*/
|
|
32
|
-
const INLINE_CODE_FLAGS = {
|
|
33
|
-
'python': ['-c'], 'python3': ['-c'],
|
|
34
|
-
'node': ['-e', '--eval'],
|
|
35
|
-
'ruby': ['-e'],
|
|
36
|
-
'perl': ['-e'],
|
|
37
|
-
'php': ['-r'],
|
|
38
|
-
'bash': ['-c'], 'sh': ['-c'], 'zsh': ['-c'],
|
|
39
|
-
// Windows shells
|
|
40
|
-
'powershell': ['-Command', '-command', '-c', '-EncodedCommand', '-encodedcommand'],
|
|
41
|
-
'powershell.exe': ['-Command', '-command', '-c', '-EncodedCommand', '-encodedcommand'],
|
|
42
|
-
'pwsh': ['-Command', '-command', '-c', '-EncodedCommand', '-encodedcommand'],
|
|
43
|
-
'pwsh.exe': ['-Command', '-command', '-c', '-EncodedCommand', '-encodedcommand'],
|
|
44
|
-
'cmd': ['/c', '/C', '/k', '/K'],
|
|
45
|
-
'cmd.exe': ['/c', '/C', '/k', '/K'],
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* 仅对真正的 wrapper 剥壳。
|
|
49
|
-
*
|
|
50
|
-
* 不要把 cmd/start 放进来:它们的选项(/c、/b)会被误当成命令名,
|
|
51
|
-
* 且 cmd /c 本身就是内联执行,应保留原命令以便 INLINE_CODE_FLAGS 识别。
|
|
52
|
-
*/
|
|
53
|
-
const WRAPPER_COMMANDS = new Set([
|
|
54
|
-
'sudo', 'env', 'exec', 'nohup', 'strace', 'time',
|
|
55
|
-
]);
|
|
56
|
-
// ── 解析入口 ──
|
|
14
|
+
import { parseShellCommandFallback } from './shell-parser-fallback.js';
|
|
15
|
+
import { initShellParser, isShellParserReady, getShellParserEngine, parseShellCommandWithTreeSitter, } from './shell-parser-treesitter.js';
|
|
16
|
+
export { initShellParser, isShellParserReady, getShellParserEngine };
|
|
17
|
+
export { parseShellCommandFallback } from './shell-parser-fallback.js';
|
|
57
18
|
/**
|
|
58
19
|
* 解析 Shell 命令
|
|
59
20
|
*
|
|
@@ -61,464 +22,44 @@ const WRAPPER_COMMANDS = new Set([
|
|
|
61
22
|
* @returns 解析结果(parsed: true/false 表示解析是否成功)
|
|
62
23
|
*/
|
|
63
24
|
export function parseShellCommand(raw) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
parsed
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
hasSubshell: false,
|
|
74
|
-
hasBackground: false,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
// 检测子 shell 和后台执行
|
|
78
|
-
const hasSubshell = detectSubshell(trimmed);
|
|
79
|
-
const hasBackground = detectBackground(trimmed);
|
|
80
|
-
// 第一层:按连接符拆分
|
|
81
|
-
const { parts, connectors } = splitByConnectors(trimmed);
|
|
82
|
-
// 第二、三层:解析每个命令段
|
|
83
|
-
const segments = [];
|
|
84
|
-
let parsed = true;
|
|
85
|
-
for (const part of parts) {
|
|
86
|
-
const seg = parseSegment(part);
|
|
87
|
-
if (!seg) {
|
|
88
|
-
parsed = false;
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
segments.push(seg);
|
|
92
|
-
}
|
|
93
|
-
// 第四层:检测特殊模式
|
|
94
|
-
const hasShellPipe = detectPipeToInterpreter(segments, connectors);
|
|
95
|
-
const hasInlineCode = detectInlineCode(segments);
|
|
96
|
-
return {
|
|
97
|
-
parsed,
|
|
98
|
-
raw,
|
|
99
|
-
segments,
|
|
100
|
-
connectors,
|
|
101
|
-
hasShellPipe,
|
|
102
|
-
hasInlineCode,
|
|
103
|
-
hasSubshell,
|
|
104
|
-
hasBackground,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
// ── 第一层:按连接符拆分 ──
|
|
108
|
-
/**
|
|
109
|
-
* 按连接符拆分命令
|
|
110
|
-
*
|
|
111
|
-
* 注意处理引号内的连接符。
|
|
112
|
-
*/
|
|
113
|
-
function splitByConnectors(cmd) {
|
|
114
|
-
const parts = [];
|
|
115
|
-
const connectors = [];
|
|
116
|
-
let current = '';
|
|
117
|
-
let inSingleQuote = false;
|
|
118
|
-
let inDoubleQuote = false;
|
|
119
|
-
let escape = false;
|
|
120
|
-
let i = 0;
|
|
121
|
-
while (i < cmd.length) {
|
|
122
|
-
const ch = cmd[i];
|
|
123
|
-
// 转义字符
|
|
124
|
-
if (escape) {
|
|
125
|
-
current += ch;
|
|
126
|
-
escape = false;
|
|
127
|
-
i++;
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
if (ch === '\\') {
|
|
131
|
-
escape = true;
|
|
132
|
-
current += ch;
|
|
133
|
-
i++;
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
// 引号状态
|
|
137
|
-
if (ch === "'" && !inDoubleQuote) {
|
|
138
|
-
inSingleQuote = !inSingleQuote;
|
|
139
|
-
current += ch;
|
|
140
|
-
i++;
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
if (ch === '"' && !inSingleQuote) {
|
|
144
|
-
inDoubleQuote = !inDoubleQuote;
|
|
145
|
-
current += ch;
|
|
146
|
-
i++;
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
// 在引号内,直接追加
|
|
150
|
-
if (inSingleQuote || inDoubleQuote) {
|
|
151
|
-
current += ch;
|
|
152
|
-
i++;
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
// 检测连接符
|
|
156
|
-
if (ch === '|') {
|
|
157
|
-
if (cmd[i + 1] === '|') {
|
|
158
|
-
// ||
|
|
159
|
-
pushPart(parts, current);
|
|
160
|
-
current = '';
|
|
161
|
-
connectors.push('||');
|
|
162
|
-
i += 2;
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
// |
|
|
167
|
-
pushPart(parts, current);
|
|
168
|
-
current = '';
|
|
169
|
-
connectors.push('|');
|
|
170
|
-
i++;
|
|
171
|
-
continue;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
if (ch === '&') {
|
|
175
|
-
if (cmd[i + 1] === '&') {
|
|
176
|
-
// &&
|
|
177
|
-
pushPart(parts, current);
|
|
178
|
-
current = '';
|
|
179
|
-
connectors.push('&&');
|
|
180
|
-
i += 2;
|
|
181
|
-
continue;
|
|
182
|
-
}
|
|
183
|
-
// `>&` / `N>&M`:文件描述符重定向(2>&1、>&2),不是命令分隔
|
|
184
|
-
if (i > 0 && cmd[i - 1] === '>') {
|
|
185
|
-
current += ch;
|
|
186
|
-
i++;
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
|
-
// `&>` / `&>>`:bash 重定向合一,不是命令分隔
|
|
190
|
-
if (cmd[i + 1] === '>') {
|
|
191
|
-
current += ch;
|
|
192
|
-
i++;
|
|
193
|
-
continue;
|
|
194
|
-
}
|
|
195
|
-
// 单 `&` 既是后台标记也是命令分隔:`true & rm -rf /` 必须拆段
|
|
196
|
-
pushPart(parts, current);
|
|
197
|
-
current = '';
|
|
198
|
-
connectors.push('&');
|
|
199
|
-
i++;
|
|
200
|
-
continue;
|
|
201
|
-
}
|
|
202
|
-
if (ch === ';') {
|
|
203
|
-
pushPart(parts, current);
|
|
204
|
-
current = '';
|
|
205
|
-
connectors.push(';');
|
|
206
|
-
i++;
|
|
207
|
-
continue;
|
|
208
|
-
}
|
|
209
|
-
if (ch === '\n') {
|
|
210
|
-
pushPart(parts, current);
|
|
211
|
-
current = '';
|
|
212
|
-
connectors.push('\n');
|
|
213
|
-
i++;
|
|
214
|
-
continue;
|
|
215
|
-
}
|
|
216
|
-
current += ch;
|
|
217
|
-
i++;
|
|
218
|
-
}
|
|
219
|
-
// 最后一段
|
|
220
|
-
pushPart(parts, current);
|
|
221
|
-
return { parts, connectors };
|
|
222
|
-
}
|
|
223
|
-
function pushPart(parts, current) {
|
|
224
|
-
const trimmed = current.trim();
|
|
225
|
-
if (trimmed) {
|
|
226
|
-
parts.push(trimmed);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
// ── 第二、三层:解析命令段 ──
|
|
230
|
-
/**
|
|
231
|
-
* 解析单个命令段
|
|
232
|
-
*
|
|
233
|
-
* 提取 wrapper、命令、参数、重定向。
|
|
234
|
-
* 遇到无法解析的结构返回 null。
|
|
235
|
-
*/
|
|
236
|
-
function parseSegment(raw) {
|
|
237
|
-
const tokens = mergeSplitWindowsPaths(tokenize(raw));
|
|
238
|
-
if (tokens.length === 0)
|
|
239
|
-
return null;
|
|
240
|
-
// 提取重定向
|
|
241
|
-
const redirects = [];
|
|
242
|
-
const cleanTokens = [];
|
|
243
|
-
let i = 0;
|
|
244
|
-
while (i < tokens.length) {
|
|
245
|
-
const token = tokens[i];
|
|
246
|
-
// 检测重定向
|
|
247
|
-
if (token === '>' || token === '>>' || token === '<') {
|
|
248
|
-
const target = tokens[i + 1];
|
|
249
|
-
if (!target)
|
|
250
|
-
return null; // 重定向后没有目标,解析失败
|
|
251
|
-
redirects.push({
|
|
252
|
-
type: token === '>' ? 'overwrite' : token === '>>' ? 'append' : 'input',
|
|
253
|
-
target,
|
|
254
|
-
});
|
|
255
|
-
i += 2;
|
|
256
|
-
continue;
|
|
257
|
-
}
|
|
258
|
-
// 检测 >file 格式(无空格)
|
|
259
|
-
const redirectMatch = matchRedirect(token);
|
|
260
|
-
if (redirectMatch) {
|
|
261
|
-
redirects.push(redirectMatch);
|
|
262
|
-
i++;
|
|
263
|
-
continue;
|
|
264
|
-
}
|
|
265
|
-
cleanTokens.push(token);
|
|
266
|
-
i++;
|
|
267
|
-
}
|
|
268
|
-
if (cleanTokens.length === 0)
|
|
269
|
-
return null;
|
|
270
|
-
// 提取 wrapper
|
|
271
|
-
const wrappers = [];
|
|
272
|
-
let cmdStart = 0;
|
|
273
|
-
while (cmdStart < cleanTokens.length) {
|
|
274
|
-
const token = cleanTokens[cmdStart];
|
|
275
|
-
if (WRAPPER_COMMANDS.has(token)) {
|
|
276
|
-
wrappers.push(token);
|
|
277
|
-
cmdStart++;
|
|
278
|
-
// sudo 可能有 -u user 等参数,跳过
|
|
279
|
-
if (token === 'sudo') {
|
|
280
|
-
while (cmdStart < cleanTokens.length && cleanTokens[cmdStart].startsWith('-')) {
|
|
281
|
-
cmdStart++;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
// env 跳过环境变量(KEY=VALUE 格式)
|
|
285
|
-
if (token === 'env') {
|
|
286
|
-
while (cmdStart < cleanTokens.length && /^[A-Z_][A-Z0-9_]*=/.test(cleanTokens[cmdStart])) {
|
|
287
|
-
cmdStart++;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
else {
|
|
292
|
-
break;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
if (cmdStart >= cleanTokens.length)
|
|
296
|
-
return null;
|
|
297
|
-
const command = cleanTokens[cmdStart];
|
|
298
|
-
const args = cleanTokens.slice(cmdStart + 1);
|
|
299
|
-
return {
|
|
300
|
-
command,
|
|
301
|
-
args,
|
|
302
|
-
redirects,
|
|
303
|
-
isSudo: wrappers.includes('sudo'),
|
|
304
|
-
wrappers,
|
|
305
|
-
raw,
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* 合并被空格切开的 Windows 绝对路径
|
|
310
|
-
*
|
|
311
|
-
* `del C:\Program Files\App\x.exe` → `C:\Program` + `Files\App\x.exe`
|
|
312
|
-
* → `C:\Program Files\App\x.exe`
|
|
313
|
-
*
|
|
314
|
-
* 规则:当前 token 是盘符/UNC 绝对路径,下一段含路径分隔符,
|
|
315
|
-
* 且当前最后一段无文件扩展名时合并。
|
|
316
|
-
* 已知局限:`cp C:\data backup\old` 也可能被误合并。
|
|
317
|
-
*/
|
|
318
|
-
function mergeSplitWindowsPaths(tokens) {
|
|
319
|
-
const out = [];
|
|
320
|
-
let i = 0;
|
|
321
|
-
while (i < tokens.length) {
|
|
322
|
-
let cur = tokens[i];
|
|
323
|
-
while (i + 1 < tokens.length) {
|
|
324
|
-
if (!/^[A-Za-z]:[\\/]/.test(cur) && !cur.startsWith('\\\\'))
|
|
325
|
-
break;
|
|
326
|
-
const next = tokens[i + 1];
|
|
327
|
-
if (!next || next.startsWith('-') || next.startsWith('/'))
|
|
328
|
-
break;
|
|
329
|
-
if (/^[A-Za-z]:[\\/]/.test(next) || next.startsWith('\\\\'))
|
|
330
|
-
break;
|
|
331
|
-
if (!next.includes('\\') && !next.includes('/'))
|
|
332
|
-
break;
|
|
333
|
-
const lastSeg = cur.replace(/[\\/]+$/, '').split(/[\\/]/).pop() ?? '';
|
|
334
|
-
if (lastSeg.includes('.'))
|
|
335
|
-
break;
|
|
336
|
-
cur = `${cur} ${next}`;
|
|
337
|
-
i++;
|
|
338
|
-
}
|
|
339
|
-
out.push(cur);
|
|
340
|
-
i++;
|
|
341
|
-
}
|
|
342
|
-
return out;
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* bash 需要被 `\` 转义的元字符。
|
|
346
|
-
* 其余字符前的 `\` 视为 Windows 路径分隔符并原样保留。
|
|
347
|
-
*/
|
|
348
|
-
const BASH_ESCAPE_TARGETS = new Set([
|
|
349
|
-
'"', "'", '$', '`', ' ', '\t', '\n',
|
|
350
|
-
'|', '&', ';', '(', ')', '<', '>',
|
|
351
|
-
]);
|
|
352
|
-
/**
|
|
353
|
-
* 简单的 tokenizer
|
|
354
|
-
*
|
|
355
|
-
* 处理引号和转义字符。
|
|
356
|
-
* Windows 路径(`C:\Windows`、`\\server\share`)中的 `\` 不会被吃掉——
|
|
357
|
-
* 否则保护路径判定会拿到被拆坏的字符串。
|
|
358
|
-
*/
|
|
359
|
-
function tokenize(raw) {
|
|
360
|
-
const tokens = [];
|
|
361
|
-
let current = '';
|
|
362
|
-
let inSingleQuote = false;
|
|
363
|
-
let inDoubleQuote = false;
|
|
364
|
-
for (let i = 0; i < raw.length; i++) {
|
|
365
|
-
const ch = raw[i];
|
|
366
|
-
if (ch === '\\' && !inSingleQuote) {
|
|
367
|
-
const next = raw[i + 1];
|
|
368
|
-
if (next === undefined) {
|
|
369
|
-
current += ch;
|
|
370
|
-
break;
|
|
371
|
-
}
|
|
372
|
-
// 经典 bash 转义:吃掉 `\`,保留下一字符字面量
|
|
373
|
-
if (BASH_ESCAPE_TARGETS.has(next)) {
|
|
374
|
-
current += next;
|
|
375
|
-
i++;
|
|
376
|
-
continue;
|
|
377
|
-
}
|
|
378
|
-
// Windows 路径分隔符 / UNC:保留 `\`
|
|
379
|
-
current += ch;
|
|
380
|
-
continue;
|
|
381
|
-
}
|
|
382
|
-
if (ch === "'" && !inDoubleQuote) {
|
|
383
|
-
inSingleQuote = !inSingleQuote;
|
|
384
|
-
continue;
|
|
385
|
-
}
|
|
386
|
-
if (ch === '"' && !inSingleQuote) {
|
|
387
|
-
inDoubleQuote = !inDoubleQuote;
|
|
388
|
-
continue;
|
|
389
|
-
}
|
|
390
|
-
if ((ch === ' ' || ch === '\t') && !inSingleQuote && !inDoubleQuote) {
|
|
391
|
-
if (current) {
|
|
392
|
-
tokens.push(current);
|
|
393
|
-
current = '';
|
|
394
|
-
}
|
|
395
|
-
continue;
|
|
396
|
-
}
|
|
397
|
-
current += ch;
|
|
398
|
-
}
|
|
399
|
-
if (current) {
|
|
400
|
-
tokens.push(current);
|
|
401
|
-
}
|
|
402
|
-
return tokens;
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* 匹配 >file 或 >>file 格式(无空格的重定向)
|
|
406
|
-
*
|
|
407
|
-
* 同时识别文件描述符重定向(`2>&1`、`>&2`、`&>file`):
|
|
408
|
-
* 它们是 IO 重定向,不是命令参数,更不是「未知命令」。
|
|
409
|
-
*/
|
|
410
|
-
function matchRedirect(token) {
|
|
411
|
-
// `&>` / `&>>`:bash 重定向合一
|
|
412
|
-
if (token.startsWith('&>>')) {
|
|
413
|
-
return { type: 'append', target: token.slice(3) };
|
|
414
|
-
}
|
|
415
|
-
if (token.startsWith('&>') && token.length > 2) {
|
|
416
|
-
return { type: 'overwrite', target: token.slice(2) };
|
|
417
|
-
}
|
|
418
|
-
// 文件描述符重定向:`2>&1`、`>&2`、`1>&2` 等
|
|
419
|
-
// target 用 fd: 标记,避免被当成路径做风险分类
|
|
420
|
-
const fdDup = token.match(/^(\d*)>{1,2}&(\d+)$/);
|
|
421
|
-
if (fdDup) {
|
|
422
|
-
return {
|
|
423
|
-
type: token.includes('>>') ? 'append' : 'overwrite',
|
|
424
|
-
target: `fd:${fdDup[2]}`,
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
// 先检查开头的重定向
|
|
428
|
-
if (token.startsWith('>>')) {
|
|
429
|
-
return { type: 'append', target: token.slice(2) };
|
|
430
|
-
}
|
|
431
|
-
if (token.startsWith('>') && token.length > 1) {
|
|
432
|
-
return { type: 'overwrite', target: token.slice(1) };
|
|
433
|
-
}
|
|
434
|
-
if (token.startsWith('<') && token.length > 1) {
|
|
435
|
-
return { type: 'input', target: token.slice(1) };
|
|
436
|
-
}
|
|
437
|
-
// 检查 token 中间的重定向(如 hello>/tmp/out.txt);`>&N` 已由 fdDup 覆盖
|
|
438
|
-
const gtIdx = token.indexOf('>');
|
|
439
|
-
if (gtIdx > 0 && gtIdx < token.length - 1) {
|
|
440
|
-
if (token[gtIdx + 1] === '&') {
|
|
441
|
-
return null;
|
|
442
|
-
}
|
|
443
|
-
if (token[gtIdx + 1] === '>') {
|
|
444
|
-
return { type: 'append', target: token.slice(gtIdx + 2) };
|
|
445
|
-
}
|
|
446
|
-
return { type: 'overwrite', target: token.slice(gtIdx + 1) };
|
|
447
|
-
}
|
|
448
|
-
return null;
|
|
449
|
-
}
|
|
450
|
-
// ── 第四层:检测特殊模式 ──
|
|
451
|
-
/**
|
|
452
|
-
* 检测子 shell($(...) 或反引号)
|
|
453
|
-
*/
|
|
454
|
-
function detectSubshell(cmd) {
|
|
455
|
-
// $(...) 模式
|
|
456
|
-
if (cmd.includes('$('))
|
|
457
|
-
return true;
|
|
458
|
-
// 反引号模式
|
|
459
|
-
if (cmd.includes('`'))
|
|
460
|
-
return true;
|
|
461
|
-
return false;
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* 检测后台执行
|
|
465
|
-
*/
|
|
466
|
-
function detectBackground(cmd) {
|
|
467
|
-
const trimmed = cmd.trim();
|
|
468
|
-
return trimmed.endsWith('&') && !trimmed.endsWith('&&');
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* 检测管道到解释器
|
|
472
|
-
*
|
|
473
|
-
* 不止 sh/bash,python/ruby/perl/node 等也是解释器。
|
|
474
|
-
* curl ... | python3 和 curl ... | sh 本质相同(执行外部代码)。
|
|
475
|
-
*/
|
|
476
|
-
function detectPipeToInterpreter(segments, connectors) {
|
|
477
|
-
for (let i = 0; i < connectors.length; i++) {
|
|
478
|
-
if (connectors[i] === '|') {
|
|
479
|
-
const nextSeg = segments[i + 1];
|
|
480
|
-
if (nextSeg && INTERPRETER_NAMES.has(nextSeg.command) && nextSeg.args.length === 0) {
|
|
481
|
-
return true;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
return false;
|
|
486
|
-
}
|
|
487
|
-
/**
|
|
488
|
-
* 检测内联代码执行
|
|
489
|
-
*
|
|
490
|
-
* python -c "...", node -e "...", bash -c "...",
|
|
491
|
-
* powershell -Command "...", cmd /c "..." 等。
|
|
492
|
-
* 命令名大小写不敏感(Windows shell)。
|
|
493
|
-
*/
|
|
494
|
-
function detectInlineCode(segments) {
|
|
495
|
-
for (const seg of segments) {
|
|
496
|
-
const flags = INLINE_CODE_FLAGS[seg.command] ??
|
|
497
|
-
INLINE_CODE_FLAGS[seg.command.toLowerCase()];
|
|
498
|
-
if (!flags)
|
|
499
|
-
continue;
|
|
500
|
-
const argSet = new Set(seg.args.map((a) => a.toLowerCase()));
|
|
501
|
-
if (flags.some((f) => argSet.has(f.toLowerCase()))) {
|
|
502
|
-
return true;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
return false;
|
|
25
|
+
if (isShellParserReady()) {
|
|
26
|
+
const parsed = parseShellCommandWithTreeSitter(raw);
|
|
27
|
+
if (parsed)
|
|
28
|
+
return parsed;
|
|
29
|
+
// tree-sitter 无法确定性解析该输入:回退 fallback 并标记不确定,
|
|
30
|
+
// 让风险分档把「解析不确定」显式计入(未知走 unknown 通道,不静默)。
|
|
31
|
+
return { ...parseShellCommandFallback(raw), uncertain: true };
|
|
32
|
+
}
|
|
33
|
+
return parseShellCommandFallback(raw);
|
|
506
34
|
}
|
|
507
35
|
// ── 导出工具函数 ──
|
|
508
36
|
/**
|
|
509
37
|
* 获取所有命令名(不含 wrapper)
|
|
38
|
+
*
|
|
39
|
+
* @param parsed - 解析结果
|
|
40
|
+
* @returns 命令名列表
|
|
510
41
|
*/
|
|
511
42
|
export function getCommandNames(parsed) {
|
|
512
43
|
return parsed.segments.map(s => s.command);
|
|
513
44
|
}
|
|
514
45
|
/**
|
|
515
|
-
*
|
|
46
|
+
* 获取所有重定向目标路径(含未挂载到命令段的孤立重定向)
|
|
47
|
+
*
|
|
48
|
+
* @param parsed - 解析结果
|
|
49
|
+
* @returns 重定向目标列表
|
|
516
50
|
*/
|
|
517
51
|
export function getRedirectTargets(parsed) {
|
|
518
|
-
return
|
|
52
|
+
return [
|
|
53
|
+
...parsed.segments.flatMap(s => s.redirects.map(r => r.target)),
|
|
54
|
+
...(parsed.orphanRedirects ?? []).map(r => r.target),
|
|
55
|
+
];
|
|
519
56
|
}
|
|
520
57
|
/**
|
|
521
58
|
* 判断命令是否包含指定的命令名
|
|
59
|
+
*
|
|
60
|
+
* @param parsed - 解析结果
|
|
61
|
+
* @param command - 命令名
|
|
62
|
+
* @returns 是否包含
|
|
522
63
|
*/
|
|
523
64
|
export function hasCommand(parsed, command) {
|
|
524
65
|
return parsed.segments.some(s => s.command === command);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Vendored: tree-sitter-bash.wasm
|
|
2
|
+
|
|
3
|
+
主 shell 解析引擎(`shell-parser-treesitter.ts`)依赖的 bash 语法 WASM。
|
|
4
|
+
|
|
5
|
+
## 溯源
|
|
6
|
+
|
|
7
|
+
| 项 | 值 |
|
|
8
|
+
|----|----|
|
|
9
|
+
| 语法上游 | `tree-sitter/tree-sitter-bash` tag **v0.25.1** (commit `a06c2e4415e9bc0346c6b86d401879ffb44058f7`, released 2025-12-02) |
|
|
10
|
+
| 构建来源 | npm `@2h2d/tree-sitter-wasms@0.2.1`("Verified, lifecycle-free Tree-sitter grammar WASMs",SLSA provenance attestation + trusted publishing) |
|
|
11
|
+
| 构建工具链 | tree-sitter 0.26.11 · wasi-sdk 33.0+m (llvm 22.1.0) · binaryen wasm-opt 131 |
|
|
12
|
+
| 文件 | `tree-sitter-bash.wasm` (1,358,594 bytes) |
|
|
13
|
+
| sha256 | `80f035925cb4b3ba1c5126e64189fbd8eab0c62a8c5881a8111658ca4697c8e8` |
|
|
14
|
+
| 许可 | `tree-sitter-bash.LICENSE.txt`(语法上游许可,MIT) |
|
|
15
|
+
|
|
16
|
+
`web-tree-sitter` 运行时(packages/engine dependency)版本需与语法 ABI 兼容,
|
|
17
|
+
升级任一侧后跑 `tests/harness/shell-parser-treesitter.test.ts` 验证(含加载冒烟)。
|
|
18
|
+
|
|
19
|
+
## 更新流程
|
|
20
|
+
|
|
21
|
+
1. 从上游 `tree-sitter/tree-sitter-bash` 的 release tag 构建 wasm
|
|
22
|
+
(`tree-sitter build --wasm`,或采用带 provenance 证明的预编译源)。
|
|
23
|
+
2. 替换本目录 `tree-sitter-bash.wasm`,更新上表(版本 / commit / sha256 / 构建工具链)。
|
|
24
|
+
3. 跑 `npm run build`(copy-engine-assets 会把本目录拷入 dist)+ 安全测试全量。
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Max Brunsfeld
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
Binary file
|
package/dist/harness/index.d.ts
CHANGED
|
@@ -31,12 +31,7 @@ export type { DefaultContextEngineConfig } from './context/default-context-engin
|
|
|
31
31
|
export { HeuristicTokenEstimator, estimateTextTokens, estimateLLMMessages } from './context/index.js';
|
|
32
32
|
export { JSON_CHARS_PER_TOKEN, TOOL_RESULT_CHARS_PER_TOKEN, CHARS_PER_TOKEN, } from './context/index.js';
|
|
33
33
|
export { DefaultMessageSelector } from './context/message-selector.js';
|
|
34
|
-
export { TruncateCompressor } from './context/truncate-compressor.js';
|
|
35
|
-
export { LLMSummaryCompressor } from './context/llm-summarizer.js';
|
|
36
|
-
export { HybridCompressor } from './context/hybrid-compressor.js';
|
|
37
34
|
export { DefaultBudgetAllocator } from './context/budget-allocator.js';
|
|
38
|
-
export { SmartRouter } from './context/smart-router.js';
|
|
39
|
-
export type { SmartRouterConfig, Route, RoutingDecision } from './context/smart-router.js';
|
|
40
35
|
export { LAYER_ORDER, LAYER_PRIORITY, LAYER_DEFAULT_SHARE, extractLayerQuery, hasLayerText, DefaultContextAssembler, truncateTextToTokens, ALL_LAYER_IDS, buildContextLayersSnapshot, deriveLayerStatus, emptyContextLayersSnapshot, probeContextLayerHealth, probeAgentHomeHealth, PersonaLayer, SkillLayer, RuntimeLayer, KnowledgeLayer, MemoryLayer, CognitionLayer, WisdomLayer, createDefaultLayers, createProviderSummarize, pickSummarizeProvider, createDefaultSystemPromptAssembler, } from './context/index.js';
|
|
41
36
|
export type { ContextLayerId, LayerAssembleContext, LayerContent, ContextLayer, LayerManifestEntry, AssembleManifest, SystemAssembleResult, ContextAssembler, ContextAssembleParams, DefaultContextAssemblerConfig, CreateDefaultLayersOptions, CreateProviderSummarizeOptions, SystemPromptAssembleInput, SystemPromptAssembleOutput, ContextLayersSnapshot, LayerRuntimeView, LayerUiStatus, ContextLayerHealth, ContextLayerHealthEntry, ProbeContextHealthDeps, ContextCompactReason, ContextCompactEvent, ContextEmitFn, ContextCompactSnapshot, } from './context/index.js';
|
|
42
37
|
export { CapabilityEnforcer, PluginTrustLevel } from './governance/security/capability-enforcer.js';
|
|
@@ -50,14 +45,14 @@ export { FallbackProvider } from './run/reliability/fallback-provider.js';
|
|
|
50
45
|
export { guardRefusalProvider } from './run/reliability/refusal-guard.js';
|
|
51
46
|
export { detectSummaryContamination } from './context/capabilities/compact/engine.js';
|
|
52
47
|
export { PluginManager } from './extension/plugin-ecosystem/plugins/manager.js';
|
|
53
|
-
export {
|
|
54
|
-
export type { OctopiPluginDefinition
|
|
48
|
+
export { definePlugin } from './extension/plugin-ecosystem/plugins/entry.js';
|
|
49
|
+
export type { OctopiPluginDefinition } from './extension/plugin-ecosystem/plugins/entry.js';
|
|
55
50
|
export { PluginApi } from './extension/plugin-ecosystem/plugins/api.js';
|
|
56
51
|
export { PluginLoader } from './extension/plugin-ecosystem/plugins/loader.js';
|
|
57
|
-
export type { LoadedPlugin, PluginLoaderConfig, PluginEntryConfig } from './extension/plugin-ecosystem/plugins/loader.js';
|
|
58
|
-
export {
|
|
59
|
-
export { validateManifest, parseManifest } from './extension/plugin-ecosystem/plugins/manifest.js';
|
|
60
|
-
export type { PluginManifest,
|
|
52
|
+
export type { LoadedPlugin, PluginLoaderConfig, PluginEntryConfig, PluginDiagnostic } from './extension/plugin-ecosystem/plugins/loader.js';
|
|
53
|
+
export { PluginContributionRegistry } from './extension/plugin-ecosystem/plugins/contribution-registry.js';
|
|
54
|
+
export { validateManifest, parseManifest, validatePluginConfig, PLUGIN_API_VERSION } from './extension/plugin-ecosystem/plugins/manifest.js';
|
|
55
|
+
export type { PluginManifest, PluginContributions, PluginHookName, PluginSessionOpName } from './extension/plugin-ecosystem/plugins/manifest.js';
|
|
61
56
|
export { DefaultToolBus } from './extension/plugin-ecosystem/tools/tool-bus.js';
|
|
62
57
|
export { getBuiltinTools, createShellTool, createFileReadTool, createFileWriteTool, createFileDeleteTool, createFileListTool } from './extension/plugin-ecosystem/tools/builtin.js';
|
|
63
58
|
export { readGitStatusSnapshot, parsePorcelainV2 } from './extension/plugin-ecosystem/tools/git-status-snapshot.js';
|
|
@@ -125,10 +120,15 @@ export type { SessionSwitchRecord } from './session/types.js';
|
|
|
125
120
|
export type { RunAuditRecord } from './activation/types.js';
|
|
126
121
|
export { readSessionCompact, writeSessionCompact } from './session/compact.js';
|
|
127
122
|
export { compactStateKey } from './context/compact-key.js';
|
|
123
|
+
export { JsonlTransformStore, InMemoryTransformStore, resolveSessionTransformPaths, copySessionTransformDir, removeSessionTransformDir, scanOrphanSessionTransform, } from './session/transform-store.js';
|
|
124
|
+
export { foldTransformView } from './context/transform/fold.js';
|
|
125
|
+
export { anchorFor, anchorRange, resolveAnchor, resolveRun, canonicalMessageHash } from './context/transform/anchors.js';
|
|
126
|
+
export { legacySnapshotToRecords } from './context/transform/migrate.js';
|
|
127
|
+
export type { TransformRecord, TransformRun, TransformLedger, TransformStore, NewTransformRecord, MessageAnchor, TransformRecordType, TransformPlaceholder, TransformRecordMeta, } from './context/transform/types.js';
|
|
128
128
|
export { agentLoop, callModel, classifyError } from '@octopi-agent/core/loop/index.js';
|
|
129
129
|
export type { AgentContext, AgentTool, LoopToolResult, AgentLoopConfig, AgentLoopEvent, LoopObserver, ClassifiedError as LoopClassifiedError } from '@octopi-agent/core/loop/index.js';
|
|
130
130
|
export { Agent } from './run/agent/index.js';
|
|
131
|
-
export type { AgentOptions } from './run/agent/index.js';
|
|
131
|
+
export type { AgentOptions, RunIdentity } from './run/agent/index.js';
|
|
132
132
|
export { withRunScope, getRunScope, getRunSessionId, createRunId } from './run/run-scope.js';
|
|
133
133
|
export type { RunScope, RunToolRuntime } from './run/run-scope.js';
|
|
134
134
|
export { ObserverHub } from './observability/observer/hub.js';
|