@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
package/dist/harness/index.js
CHANGED
|
@@ -24,11 +24,7 @@ export { DefaultContextEngine } from './context/default-context-engine.js';
|
|
|
24
24
|
export { HeuristicTokenEstimator, estimateTextTokens, estimateLLMMessages } from './context/index.js';
|
|
25
25
|
export { JSON_CHARS_PER_TOKEN, TOOL_RESULT_CHARS_PER_TOKEN, CHARS_PER_TOKEN, } from './context/index.js';
|
|
26
26
|
export { DefaultMessageSelector } from './context/message-selector.js';
|
|
27
|
-
export { TruncateCompressor } from './context/truncate-compressor.js';
|
|
28
|
-
export { LLMSummaryCompressor } from './context/llm-summarizer.js';
|
|
29
|
-
export { HybridCompressor } from './context/hybrid-compressor.js';
|
|
30
27
|
export { DefaultBudgetAllocator } from './context/budget-allocator.js';
|
|
31
|
-
export { SmartRouter } from './context/smart-router.js';
|
|
32
28
|
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';
|
|
33
29
|
// ── Security ──
|
|
34
30
|
export { CapabilityEnforcer, PluginTrustLevel } from './governance/security/capability-enforcer.js';
|
|
@@ -42,11 +38,11 @@ export { guardRefusalProvider } from './run/reliability/refusal-guard.js';
|
|
|
42
38
|
export { detectSummaryContamination } from './context/capabilities/compact/engine.js';
|
|
43
39
|
// ── Plugin Ecosystem ──
|
|
44
40
|
export { PluginManager } from './extension/plugin-ecosystem/plugins/manager.js';
|
|
45
|
-
export {
|
|
41
|
+
export { definePlugin } from './extension/plugin-ecosystem/plugins/entry.js';
|
|
46
42
|
export { PluginApi } from './extension/plugin-ecosystem/plugins/api.js';
|
|
47
43
|
export { PluginLoader } from './extension/plugin-ecosystem/plugins/loader.js';
|
|
48
|
-
export {
|
|
49
|
-
export { validateManifest, parseManifest } from './extension/plugin-ecosystem/plugins/manifest.js';
|
|
44
|
+
export { PluginContributionRegistry } from './extension/plugin-ecosystem/plugins/contribution-registry.js';
|
|
45
|
+
export { validateManifest, parseManifest, validatePluginConfig, PLUGIN_API_VERSION } from './extension/plugin-ecosystem/plugins/manifest.js';
|
|
50
46
|
export { DefaultToolBus } from './extension/plugin-ecosystem/tools/tool-bus.js';
|
|
51
47
|
export { getBuiltinTools, createShellTool, createFileReadTool, createFileWriteTool, createFileDeleteTool, createFileListTool } from './extension/plugin-ecosystem/tools/builtin.js';
|
|
52
48
|
export { readGitStatusSnapshot, parsePorcelainV2 } from './extension/plugin-ecosystem/tools/git-status-snapshot.js';
|
|
@@ -94,6 +90,10 @@ export { InProcessSessionLock } from './run/concurrency/session-lease.js';
|
|
|
94
90
|
export { SessionAclService, SessionRoleCatalog, BUILTIN_SESSION_ROLES, computeEffectiveRights, intersectRights, applyRightsOverlay, exceedsRightsCeiling, L0_SESSION_RIGHTS_FLOOR, EMPTY_TOOL_RIGHTS, normalizeToolRights, intersectToolRights, toolRightsExceeds, isToolAllowedByRights, isToolPermitted, } from './governance/session-acl/index.js';
|
|
95
91
|
export { readSessionCompact, writeSessionCompact } from './session/compact.js';
|
|
96
92
|
export { compactStateKey } from './context/compact-key.js';
|
|
93
|
+
export { JsonlTransformStore, InMemoryTransformStore, resolveSessionTransformPaths, copySessionTransformDir, removeSessionTransformDir, scanOrphanSessionTransform, } from './session/transform-store.js';
|
|
94
|
+
export { foldTransformView } from './context/transform/fold.js';
|
|
95
|
+
export { anchorFor, anchorRange, resolveAnchor, resolveRun, canonicalMessageHash } from './context/transform/anchors.js';
|
|
96
|
+
export { legacySnapshotToRecords } from './context/transform/migrate.js';
|
|
97
97
|
// ── Config Bridge ──
|
|
98
98
|
// (exported from agent-building above)
|
|
99
99
|
// ── Loop re-export(纯函数与协议类型;Agent 门面在 harness/agent) ──
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* octopi.json `knowledge.*` 调参面 → Knowledge Service boot 调参块(唯一映射点)
|
|
3
|
+
*
|
|
4
|
+
* 背景:v0.51 Gateway 直连 knowledge.db 时这些键全量贯通;v0.60 拆独立 Service
|
|
5
|
+
* 后传递线丢失(配了不生效,见 arch/config-key-audit-2026-11-01.md §1a/§2)。
|
|
6
|
+
* v0.98.11 起经 boot 文件传入 Service——schema 形状(knowledge.embed / index /
|
|
7
|
+
* load / keywordWeight / autoInject / hint)到消费侧形状(KnowledgeIngestOptions /
|
|
8
|
+
* KnowledgeRetrieverOptions)的转换只发生在这里。
|
|
9
|
+
*
|
|
10
|
+
* @module harness/knowledge/boot-config
|
|
11
|
+
*/
|
|
12
|
+
import type { KnowledgeRuntimeConfig } from '../../config.js';
|
|
13
|
+
import type { KnowledgeFileLimitsInput } from './file-limits.js';
|
|
14
|
+
/** Phase B 向量化调参(KnowledgeIngestOptions embed 子集 + 启用开关) */
|
|
15
|
+
export interface KnowledgeBootEmbed {
|
|
16
|
+
/** false = 纯关键词索引(不外发 embed);缺省 true */
|
|
17
|
+
enabled?: boolean;
|
|
18
|
+
embedBatch?: number;
|
|
19
|
+
embedMinIntervalMs?: number;
|
|
20
|
+
embedConcurrency?: number;
|
|
21
|
+
embedSecretPolicy?: 'allow' | 'redact' | 'skip';
|
|
22
|
+
}
|
|
23
|
+
/** Ingest 调参(KnowledgeIngestOptions 子集) */
|
|
24
|
+
export interface KnowledgeBootIngest {
|
|
25
|
+
parseConcurrency?: number;
|
|
26
|
+
/** fs watch debounce ms */
|
|
27
|
+
debounceMs?: number;
|
|
28
|
+
/** 队列深度上限(超出只报警,不丢任务) */
|
|
29
|
+
maxQueueDepth?: number;
|
|
30
|
+
diskWatermarkAlert?: boolean;
|
|
31
|
+
fileLimits?: KnowledgeFileLimitsInput;
|
|
32
|
+
}
|
|
33
|
+
/** 检索调参(KnowledgeRetrieverOptions 子集) */
|
|
34
|
+
export interface KnowledgeBootRetriever {
|
|
35
|
+
hybridKeyword?: boolean;
|
|
36
|
+
keywordWeight?: number;
|
|
37
|
+
injectMinScore?: number;
|
|
38
|
+
hintMinScore?: number;
|
|
39
|
+
minCoverage?: number;
|
|
40
|
+
}
|
|
41
|
+
/** boot 文件里的调参块 */
|
|
42
|
+
export interface KnowledgeBootTuning {
|
|
43
|
+
embed?: KnowledgeBootEmbed;
|
|
44
|
+
ingest?: KnowledgeBootIngest;
|
|
45
|
+
retriever?: KnowledgeBootRetriever;
|
|
46
|
+
/** false = 索引稳定后不自动生成 generatedDescription(catalog.autoDescribe;仅 manageLocal) */
|
|
47
|
+
autoDescribe?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 把 `knowledge.*` 配置映射为 Service boot 调参块。
|
|
51
|
+
*
|
|
52
|
+
* @param kn - octopi.json 的 knowledge 段(undefined = 全默认)
|
|
53
|
+
* @returns 调参三块;未配置的键不出现在输出中(消费侧用各自默认值)
|
|
54
|
+
*/
|
|
55
|
+
export declare function knowledgeTuningFromConfig(kn?: KnowledgeRuntimeConfig | null): KnowledgeBootTuning;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** 去掉值为 undefined 的键,保证输出只含显式配置(可安全展开进选项对象) */
|
|
2
|
+
function definedOnly(obj) {
|
|
3
|
+
const out = {};
|
|
4
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
5
|
+
if (v !== undefined)
|
|
6
|
+
out[k] = v;
|
|
7
|
+
}
|
|
8
|
+
return out;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 把 `knowledge.*` 配置映射为 Service boot 调参块。
|
|
12
|
+
*
|
|
13
|
+
* @param kn - octopi.json 的 knowledge 段(undefined = 全默认)
|
|
14
|
+
* @returns 调参三块;未配置的键不出现在输出中(消费侧用各自默认值)
|
|
15
|
+
*/
|
|
16
|
+
export function knowledgeTuningFromConfig(kn) {
|
|
17
|
+
if (!kn)
|
|
18
|
+
return {};
|
|
19
|
+
const tuning = {};
|
|
20
|
+
const embed = definedOnly({
|
|
21
|
+
enabled: kn.embed?.enabled,
|
|
22
|
+
embedBatch: kn.embed?.embedBatch,
|
|
23
|
+
embedMinIntervalMs: kn.embed?.embedMinIntervalMs,
|
|
24
|
+
embedConcurrency: kn.embed?.embedConcurrency,
|
|
25
|
+
embedSecretPolicy: kn.embed?.embedSecretPolicy,
|
|
26
|
+
});
|
|
27
|
+
if (Object.keys(embed).length > 0)
|
|
28
|
+
tuning.embed = embed;
|
|
29
|
+
const ingest = definedOnly({
|
|
30
|
+
parseConcurrency: kn.load?.parseConcurrency,
|
|
31
|
+
debounceMs: kn.load?.debounceMs,
|
|
32
|
+
maxQueueDepth: kn.index?.queue?.maxDepth,
|
|
33
|
+
diskWatermarkAlert: kn.load?.diskWatermarkAlert,
|
|
34
|
+
fileLimits: kn.index?.files,
|
|
35
|
+
});
|
|
36
|
+
if (Object.keys(ingest).length > 0)
|
|
37
|
+
tuning.ingest = ingest;
|
|
38
|
+
const retriever = definedOnly({
|
|
39
|
+
hybridKeyword: kn.index?.hybridKeyword,
|
|
40
|
+
keywordWeight: kn.keywordWeight,
|
|
41
|
+
injectMinScore: kn.autoInject?.minScore,
|
|
42
|
+
hintMinScore: kn.hint?.minScore,
|
|
43
|
+
minCoverage: kn.autoInject?.minCoverage,
|
|
44
|
+
});
|
|
45
|
+
if (Object.keys(retriever).length > 0)
|
|
46
|
+
tuning.retriever = retriever;
|
|
47
|
+
if (kn.catalog?.autoDescribe !== undefined)
|
|
48
|
+
tuning.autoDescribe = kn.catalog.autoDescribe;
|
|
49
|
+
return tuning;
|
|
50
|
+
}
|
|
@@ -17,6 +17,8 @@ export interface KnowledgeCatalogItem {
|
|
|
17
17
|
status?: string;
|
|
18
18
|
/** 一行用途说明(人工 description 或 generatedDescription) */
|
|
19
19
|
description?: string;
|
|
20
|
+
/** description 的生成方(信任分级 human > llm > heuristic);仅自动描述时存在 */
|
|
21
|
+
descriptionSource?: 'human' | 'llm' | 'heuristic';
|
|
20
22
|
/** global | project | session */
|
|
21
23
|
scopeLevel?: string;
|
|
22
24
|
/** 规模粗标,如 "~1.2k files" / "small" */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* KnowledgeClient — Gateway 侧 RPC(不打开 knowledge.db)
|
|
3
3
|
*/
|
|
4
|
+
import type { KnowledgeSourceKind } from './types.js';
|
|
4
5
|
export interface KnowledgeClientOptions {
|
|
5
6
|
baseUrl: string;
|
|
6
7
|
token: string;
|
|
@@ -116,11 +117,32 @@ export declare class KnowledgeClient {
|
|
|
116
117
|
}>;
|
|
117
118
|
}>;
|
|
118
119
|
catalog(agentId: string): Promise<unknown[]>;
|
|
119
|
-
promotionCandidates(
|
|
120
|
-
|
|
120
|
+
promotionCandidates(opts?: {
|
|
121
|
+
minSessions?: number;
|
|
122
|
+
minHits?: number;
|
|
123
|
+
}): Promise<unknown[]>;
|
|
124
|
+
describeSource(sourceId: string, input?: {
|
|
125
|
+
description: string;
|
|
126
|
+
source?: 'llm' | 'heuristic';
|
|
127
|
+
}): Promise<{
|
|
121
128
|
generatedDescription: string;
|
|
122
129
|
source: string;
|
|
123
130
|
}>;
|
|
131
|
+
/** B 方案取素材(Service 侧密钥扫描把关;blocked=true 时无 sample) */
|
|
132
|
+
getDescribeSample(sourceId: string): Promise<{
|
|
133
|
+
blocked: false;
|
|
134
|
+
meta: {
|
|
135
|
+
displayName: string;
|
|
136
|
+
kind: KnowledgeSourceKind;
|
|
137
|
+
location: string;
|
|
138
|
+
};
|
|
139
|
+
sample: string;
|
|
140
|
+
} | {
|
|
141
|
+
blocked: true;
|
|
142
|
+
secretHits: string[];
|
|
143
|
+
}>;
|
|
144
|
+
/** 待 LLM 升级的源 id(boot sweep 用) */
|
|
145
|
+
listDescribePending(): Promise<string[]>;
|
|
124
146
|
listChunks(agentId: string, sourceId: string, path: string): Promise<Array<{
|
|
125
147
|
id: string;
|
|
126
148
|
text: string;
|
|
@@ -161,11 +161,25 @@ export class KnowledgeClient {
|
|
|
161
161
|
catalog(agentId) {
|
|
162
162
|
return this.request('GET', `/v1/principals/${encodeURIComponent(agentId)}/catalog`, undefined, undefined, { read: true });
|
|
163
163
|
}
|
|
164
|
-
promotionCandidates() {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
promotionCandidates(opts) {
|
|
165
|
+
const qs = new URLSearchParams();
|
|
166
|
+
if (opts?.minSessions != null)
|
|
167
|
+
qs.set('minSessions', String(opts.minSessions));
|
|
168
|
+
if (opts?.minHits != null)
|
|
169
|
+
qs.set('minHits', String(opts.minHits));
|
|
170
|
+
const search = qs.toString();
|
|
171
|
+
return this.request('GET', `/v1/promotion-candidates${search ? `?${search}` : ''}`, undefined, undefined, { read: true });
|
|
172
|
+
}
|
|
173
|
+
describeSource(sourceId, input) {
|
|
174
|
+
return this.request('POST', `/v1/sources/${encodeURIComponent(sourceId)}/describe`, input);
|
|
175
|
+
}
|
|
176
|
+
/** B 方案取素材(Service 侧密钥扫描把关;blocked=true 时无 sample) */
|
|
177
|
+
getDescribeSample(sourceId) {
|
|
178
|
+
return this.request('GET', `/v1/sources/${encodeURIComponent(sourceId)}/describe-sample`, undefined, undefined, { read: true });
|
|
179
|
+
}
|
|
180
|
+
/** 待 LLM 升级的源 id(boot sweep 用) */
|
|
181
|
+
listDescribePending() {
|
|
182
|
+
return this.request('GET', '/v1/describe-pending', undefined, undefined, { read: true });
|
|
169
183
|
}
|
|
170
184
|
listChunks(agentId, sourceId, path) {
|
|
171
185
|
const qs = new URLSearchParams({ sourceId, path });
|
|
@@ -138,6 +138,7 @@ export class KnowledgeDatabase {
|
|
|
138
138
|
display_name TEXT NOT NULL,
|
|
139
139
|
description TEXT,
|
|
140
140
|
generated_description TEXT,
|
|
141
|
+
generated_description_source TEXT,
|
|
141
142
|
catalog_priority INTEGER,
|
|
142
143
|
hidden_from_catalog INTEGER NOT NULL DEFAULT 0,
|
|
143
144
|
last_polled_at INTEGER,
|
|
@@ -267,6 +268,10 @@ export class KnowledgeDatabase {
|
|
|
267
268
|
{ name: 'discover_json', ddl: `discover_json TEXT` },
|
|
268
269
|
{ name: 'auth_ref', ddl: `auth_ref TEXT` },
|
|
269
270
|
{ name: 'last_polled_at', ddl: `last_polled_at INTEGER` },
|
|
271
|
+
{
|
|
272
|
+
name: 'generated_description_source',
|
|
273
|
+
ddl: `generated_description_source TEXT`,
|
|
274
|
+
},
|
|
270
275
|
]);
|
|
271
276
|
alterIfMissing('knowledge_projects', [
|
|
272
277
|
{ name: 'tenant_id', ddl: `tenant_id TEXT NOT NULL DEFAULT 'default'` },
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* describe 抽样组装 — auto-describe 素材面(Tier 0)
|
|
3
|
+
*
|
|
4
|
+
* 素材组合(拍板 2026-11-02):
|
|
5
|
+
* ① 源元数据 —— 经 `generateKnowledgeDescription` 的 source 参数单独传给端口,不进 sample;
|
|
6
|
+
* ② logical_path 前 20 条(结构辨识);
|
|
7
|
+
* ③ 路径派生 topics(`deriveTopicsFromPaths`,与关键词索引同词面);
|
|
8
|
+
* ④ 文件头 chunk(ordinal=0)抽样——唯一涉正文素材。
|
|
9
|
+
*
|
|
10
|
+
* 密钥形态扫描由调用边界把关:REST 出口(`describeSample`)与端口出口
|
|
11
|
+
* (`generateKnowledgeDescription` 内部)各自扫描;本组装器不重复扫。
|
|
12
|
+
*/
|
|
13
|
+
import type { KnowledgeDatabase } from './db.js';
|
|
14
|
+
/** 抽样总预算(字符):paths + topics + 文件头共享 */
|
|
15
|
+
export declare const DESCRIBE_SAMPLE_MAX_CHARS = 4000;
|
|
16
|
+
/**
|
|
17
|
+
* 组装 describe 抽样文本(②+③+④;① 由调用方单独携带)。
|
|
18
|
+
*
|
|
19
|
+
* @param db - knowledge.db 读句柄
|
|
20
|
+
* @param sourceId - 源 id
|
|
21
|
+
* @returns 抽样文本(≤ DESCRIBE_SAMPLE_MAX_CHARS;无内容时为空串)
|
|
22
|
+
*/
|
|
23
|
+
export declare function assembleDescribeSample(db: KnowledgeDatabase, sourceId: string): string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* describe 抽样组装 — auto-describe 素材面(Tier 0)
|
|
3
|
+
*
|
|
4
|
+
* 素材组合(拍板 2026-11-02):
|
|
5
|
+
* ① 源元数据 —— 经 `generateKnowledgeDescription` 的 source 参数单独传给端口,不进 sample;
|
|
6
|
+
* ② logical_path 前 20 条(结构辨识);
|
|
7
|
+
* ③ 路径派生 topics(`deriveTopicsFromPaths`,与关键词索引同词面);
|
|
8
|
+
* ④ 文件头 chunk(ordinal=0)抽样——唯一涉正文素材。
|
|
9
|
+
*
|
|
10
|
+
* 密钥形态扫描由调用边界把关:REST 出口(`describeSample`)与端口出口
|
|
11
|
+
* (`generateKnowledgeDescription` 内部)各自扫描;本组装器不重复扫。
|
|
12
|
+
*/
|
|
13
|
+
import { deriveTopicsFromPaths } from './topics.js';
|
|
14
|
+
/** 抽样总预算(字符):paths + topics + 文件头共享 */
|
|
15
|
+
export const DESCRIBE_SAMPLE_MAX_CHARS = 4000;
|
|
16
|
+
/** ② 展示路径条数 */
|
|
17
|
+
const PATH_SAMPLE_LIMIT = 20;
|
|
18
|
+
/** ③ topics 统计的路径上限(词频稳定性,不追求全量) */
|
|
19
|
+
const TOPIC_PATH_LIMIT = 500;
|
|
20
|
+
/** ④ 文件头抽样的文件数 */
|
|
21
|
+
const HEAD_FILE_LIMIT = 8;
|
|
22
|
+
/** ④ 单文件头字符预算 */
|
|
23
|
+
const HEAD_PER_FILE_CHARS = 400;
|
|
24
|
+
/**
|
|
25
|
+
* 组装 describe 抽样文本(②+③+④;① 由调用方单独携带)。
|
|
26
|
+
*
|
|
27
|
+
* @param db - knowledge.db 读句柄
|
|
28
|
+
* @param sourceId - 源 id
|
|
29
|
+
* @returns 抽样文本(≤ DESCRIBE_SAMPLE_MAX_CHARS;无内容时为空串)
|
|
30
|
+
*/
|
|
31
|
+
export function assembleDescribeSample(db, sourceId) {
|
|
32
|
+
const pathRows = db.raw
|
|
33
|
+
.prepare('SELECT logical_path FROM knowledge_memberships WHERE source_id = ? ORDER BY logical_path LIMIT ?')
|
|
34
|
+
.all(sourceId, TOPIC_PATH_LIMIT);
|
|
35
|
+
const allPaths = pathRows.map((r) => r.logical_path);
|
|
36
|
+
if (allPaths.length === 0)
|
|
37
|
+
return '';
|
|
38
|
+
const shownPaths = allPaths.slice(0, PATH_SAMPLE_LIMIT);
|
|
39
|
+
const topics = deriveTopicsFromPaths(allPaths);
|
|
40
|
+
const headRows = db.raw
|
|
41
|
+
.prepare(`SELECT m.logical_path AS path, c.text AS text
|
|
42
|
+
FROM knowledge_memberships m
|
|
43
|
+
JOIN knowledge_chunks c ON c.file_id = m.file_id AND c.ordinal = 0
|
|
44
|
+
WHERE m.source_id = ?
|
|
45
|
+
ORDER BY m.logical_path
|
|
46
|
+
LIMIT ?`)
|
|
47
|
+
.all(sourceId, HEAD_FILE_LIMIT);
|
|
48
|
+
const parts = [];
|
|
49
|
+
parts.push(`paths (${shownPaths.length} of ${allPaths.length}):\n${shownPaths.join('\n')}`);
|
|
50
|
+
if (topics.length > 0) {
|
|
51
|
+
parts.push(`topics: ${topics.join(', ')}`);
|
|
52
|
+
}
|
|
53
|
+
if (headRows.length > 0) {
|
|
54
|
+
const heads = headRows.map((r) => `--- ${r.path}\n${r.text.slice(0, HEAD_PER_FILE_CHARS)}`);
|
|
55
|
+
parts.push(`file heads:\n${heads.join('\n')}`);
|
|
56
|
+
}
|
|
57
|
+
return parts.join('\n\n').slice(0, DESCRIBE_SAMPLE_MAX_CHARS);
|
|
58
|
+
}
|
|
@@ -30,6 +30,14 @@ export interface KnowledgeDescribeResult {
|
|
|
30
30
|
* @param sampleText - 目录树/文件头抽样(调用方提供;P2 起由 ingest 采集)
|
|
31
31
|
*/
|
|
32
32
|
export declare function generateKnowledgeDescription(source: Pick<KnowledgeSource, 'displayName' | 'kind' | 'location'>, sampleText: string, options?: KnowledgeDescribeOptions): Promise<KnowledgeDescribeResult>;
|
|
33
|
+
/**
|
|
34
|
+
* 描述文本归一:折叠空白为单行、剥行首列表标记,钳 300 字符。
|
|
35
|
+
*
|
|
36
|
+
* generatedDescription 会拼进系统提示的 catalog `purpose:` 行(layers.ts);
|
|
37
|
+
* 多行文本可伪造额外 catalog 行/指令行(内容→LLM→system prompt 间接注入面),
|
|
38
|
+
* 必须在**写入侧**归一,而不是只靠渲染侧。
|
|
39
|
+
*/
|
|
40
|
+
export declare function normalizeGeneratedDescription(text: string): string;
|
|
33
41
|
/**
|
|
34
42
|
* 启发式一行描述(不能当正确描述,仅 fallback)
|
|
35
43
|
*
|
|
@@ -15,6 +15,8 @@ export async function generateKnowledgeDescription(source, sampleText, options)
|
|
|
15
15
|
const sample = (sampleText ?? '').slice(0, options?.sampleChars ?? 2000);
|
|
16
16
|
const secretHits = scanSecretShapes(sample);
|
|
17
17
|
if (secretHits.length > 0) {
|
|
18
|
+
// 封锁现场(仅规则名,不泄密):上线后这是唯一可查的触发线索(评审 P2-4)
|
|
19
|
+
console.warn(`[Knowledge] describe sample blocked by secret scan (rules: ${secretHits.join(', ')}); falling back to heuristic`);
|
|
18
20
|
return {
|
|
19
21
|
description: heuristicDescription(source),
|
|
20
22
|
source: 'blocked_secret',
|
|
@@ -38,12 +40,26 @@ export async function generateKnowledgeDescription(source, sampleText, options)
|
|
|
38
40
|
if (!trimmed) {
|
|
39
41
|
return { description: heuristicDescription(source), source: 'heuristic' };
|
|
40
42
|
}
|
|
41
|
-
return { description: trimmed
|
|
43
|
+
return { description: normalizeGeneratedDescription(trimmed), source: 'llm' };
|
|
42
44
|
}
|
|
43
45
|
catch {
|
|
44
46
|
return { description: heuristicDescription(source), source: 'heuristic' };
|
|
45
47
|
}
|
|
46
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* 描述文本归一:折叠空白为单行、剥行首列表标记,钳 300 字符。
|
|
51
|
+
*
|
|
52
|
+
* generatedDescription 会拼进系统提示的 catalog `purpose:` 行(layers.ts);
|
|
53
|
+
* 多行文本可伪造额外 catalog 行/指令行(内容→LLM→system prompt 间接注入面),
|
|
54
|
+
* 必须在**写入侧**归一,而不是只靠渲染侧。
|
|
55
|
+
*/
|
|
56
|
+
export function normalizeGeneratedDescription(text) {
|
|
57
|
+
return text
|
|
58
|
+
.replace(/\s+/g, ' ')
|
|
59
|
+
.replace(/^[\-*#>·•]+\s*/, '')
|
|
60
|
+
.trim()
|
|
61
|
+
.slice(0, 300);
|
|
62
|
+
}
|
|
47
63
|
/**
|
|
48
64
|
* 启发式一行描述(不能当正确描述,仅 fallback)
|
|
49
65
|
*
|
|
@@ -52,5 +68,5 @@ export async function generateKnowledgeDescription(source, sampleText, options)
|
|
|
52
68
|
export function heuristicDescription(source) {
|
|
53
69
|
const loc = source.location.replace(/[\\/]+$/, '');
|
|
54
70
|
const tail = loc.split(/[\\/]/).filter(Boolean).slice(-2).join('/');
|
|
55
|
-
return `derived: ${source.kind} corpus «${source.displayName}»${tail ? ` (${tail})` : ''}; search when you need what this corpus documents
|
|
71
|
+
return normalizeGeneratedDescription(`derived: ${source.kind} corpus «${source.displayName}»${tail ? ` (${tail})` : ''}; search when you need what this corpus documents`);
|
|
56
72
|
}
|
|
@@ -163,6 +163,8 @@ async function main() {
|
|
|
163
163
|
documentConfig: boot.documentConfig ?? null,
|
|
164
164
|
embeddingProvider: embeddingProvider,
|
|
165
165
|
embed: boot.embed ?? null,
|
|
166
|
+
ingest: boot.ingest ?? null,
|
|
167
|
+
autoDescribe: boot.autoDescribe,
|
|
166
168
|
});
|
|
167
169
|
const sources = new KnowledgeSourceStore(writeDb);
|
|
168
170
|
const index = new KnowledgeIndexStore(writeDb);
|
|
@@ -170,6 +172,7 @@ async function main() {
|
|
|
170
172
|
sourceStore: sources,
|
|
171
173
|
indexStore: index,
|
|
172
174
|
embeddingProvider: embeddingProvider,
|
|
175
|
+
...(boot.retriever ?? {}),
|
|
173
176
|
});
|
|
174
177
|
query = new LocalKnowledgeQueryService({
|
|
175
178
|
db: writeDb,
|
|
@@ -188,6 +191,8 @@ async function main() {
|
|
|
188
191
|
sqliteVecExtensionPath: boot.sqliteVecExtensionPath,
|
|
189
192
|
embeddingModels: boot.testEmbeddingStub ? null : (boot.embeddingModels ?? null),
|
|
190
193
|
embed: boot.embed ?? null,
|
|
194
|
+
ingest: boot.ingest ?? null,
|
|
195
|
+
autoDescribe: boot.autoDescribe,
|
|
191
196
|
testEmbeddingStub: boot.testEmbeddingStub ?? false,
|
|
192
197
|
});
|
|
193
198
|
// 残留写路由上的短读:独立只读连接(WAL)
|
|
@@ -205,6 +210,7 @@ async function main() {
|
|
|
205
210
|
sourceStore: sources,
|
|
206
211
|
indexStore: index,
|
|
207
212
|
embeddingProvider: embeddingProvider,
|
|
213
|
+
...(boot.retriever ?? {}),
|
|
208
214
|
});
|
|
209
215
|
query = new LocalKnowledgeQueryService({
|
|
210
216
|
db: readDb,
|
|
@@ -8,6 +8,7 @@ import { getTextContent } from '@octopi-agent/core/types.js';
|
|
|
8
8
|
export const KNOWLEDGE_GROUNDING_SOURCE = 'knowledgeGrounding';
|
|
9
9
|
/** 真实用户发言判定(载体插槽不是用户发言,query 不采信;谓词见 context/layer-types) */
|
|
10
10
|
import { isHumanSpeech } from '../context/layer-types.js';
|
|
11
|
+
import { estimateTextTokens } from '../context/token-estimate-fns.js';
|
|
11
12
|
/**
|
|
12
13
|
* v1 query:最近 user + 可选前 1–2 条 user;不用 assistant 长文
|
|
13
14
|
*/
|
|
@@ -60,7 +61,8 @@ export function formatKnowledgeGroundingMessage(pack) {
|
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
63
|
function estimateTokens(text) {
|
|
63
|
-
|
|
64
|
+
// P1-c 一把尺:走统一分类查表(旧 ceil(length/4) 对 CJK 高估 4×,装载预算被保守压缩)
|
|
65
|
+
return estimateTextTokens(text);
|
|
64
66
|
}
|
|
65
67
|
/** 最近一条真实用户发言的文本(skipIf 启发式只看本轮;载体插槽不计) */
|
|
66
68
|
function latestUserText(messages) {
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* 纯读 GET 在主线程 `read-http.ts` 直达 Meta/Search,不经本层。
|
|
7
7
|
*/
|
|
8
8
|
import { matchKnowledgeToken } from './http-bridge.js';
|
|
9
|
+
import { promotionThresholdsFromParams } from './http-params.js';
|
|
9
10
|
function json(res, status, payload) {
|
|
10
11
|
const buf = Buffer.from(JSON.stringify(payload), 'utf8');
|
|
11
12
|
res.writeHead(status, {
|
|
@@ -304,9 +305,16 @@ export class KnowledgeHttpApp {
|
|
|
304
305
|
}
|
|
305
306
|
json(res, 200, { ok: true, data: await this.write.resumeSource(params.sid) });
|
|
306
307
|
});
|
|
307
|
-
this.route('POST', '/v1/sources/:sid/describe', async (_req, res, ctx, params) => {
|
|
308
|
+
this.route('POST', '/v1/sources/:sid/describe', async (_req, res, ctx, params, body) => {
|
|
308
309
|
try {
|
|
309
|
-
|
|
310
|
+
// 写入口(B 方案):body {description,source} = gateway 回写 LLM 描述;无 body = 本地启发式生成
|
|
311
|
+
const input = body;
|
|
312
|
+
const data = await this.write.describeSource(this.identityOf(ctx), params.sid, input?.description != null
|
|
313
|
+
? {
|
|
314
|
+
description: String(input.description),
|
|
315
|
+
...(input.source === 'heuristic' ? { source: 'heuristic' } : {}),
|
|
316
|
+
}
|
|
317
|
+
: undefined);
|
|
310
318
|
if (!data)
|
|
311
319
|
return err(res, 404, 'source_not_found', 'source not found');
|
|
312
320
|
json(res, 200, { ok: true, data });
|
|
@@ -317,6 +325,25 @@ export class KnowledgeHttpApp {
|
|
|
317
325
|
}
|
|
318
326
|
}
|
|
319
327
|
});
|
|
328
|
+
this.route('GET', '/v1/sources/:sid/describe-sample', async (req, res, ctx, params) => {
|
|
329
|
+
try {
|
|
330
|
+
const data = await this.write.describeSample(this.identityOf(ctx), params.sid);
|
|
331
|
+
if (!data)
|
|
332
|
+
return err(res, 404, 'source_not_found', 'source not found');
|
|
333
|
+
json(res, 200, { ok: true, data });
|
|
334
|
+
}
|
|
335
|
+
catch (e) {
|
|
336
|
+
if (!mapWriteError(res, e)) {
|
|
337
|
+
err(res, 400, 'bad_request', e instanceof Error ? e.message : String(e));
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
this.route('GET', '/v1/describe-pending', async (req, res, ctx) => {
|
|
342
|
+
json(res, 200, {
|
|
343
|
+
ok: true,
|
|
344
|
+
data: await this.write.listDescribePending(this.identityOf(ctx)),
|
|
345
|
+
});
|
|
346
|
+
});
|
|
320
347
|
this.route('POST', '/v1/jobs/abort', async (_req, res, ctx) => {
|
|
321
348
|
json(res, 200, { ok: true, data: await this.write.abortAllOwned(this.identityOf(ctx)) });
|
|
322
349
|
});
|
|
@@ -575,8 +602,12 @@ export class KnowledgeHttpApp {
|
|
|
575
602
|
return err(res, 404, 'source_not_found', 'source not found');
|
|
576
603
|
json(res, 200, { ok: true, data: detail.jobControl });
|
|
577
604
|
});
|
|
578
|
-
this.route('GET', '/v1/promotion-candidates', async (
|
|
579
|
-
|
|
605
|
+
this.route('GET', '/v1/promotion-candidates', async (req, res) => {
|
|
606
|
+
const url = new URL(req.url ?? '/', 'http://local');
|
|
607
|
+
json(res, 200, {
|
|
608
|
+
ok: true,
|
|
609
|
+
data: await this.query().promotionCandidates(promotionThresholdsFromParams(url.searchParams)),
|
|
610
|
+
});
|
|
580
611
|
});
|
|
581
612
|
}
|
|
582
613
|
/** 拉起 ingest 运行时(Service 入口调用一次;实现落在 Writer) */
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP 查询参数解析(纯函数叶子模块)
|
|
3
|
+
*
|
|
4
|
+
* API 路由(http-app)与纯读路由(read-http)共用;刻意不依赖 query-service
|
|
5
|
+
* 实现,避免 HTTP 层反向依赖服务层。
|
|
6
|
+
*
|
|
7
|
+
* @module harness/knowledge/http-params
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* 解析 promotion 候选阈值查询参数(非法值忽略,回落 hit-log 默认 3/10)。
|
|
11
|
+
*
|
|
12
|
+
* @param searchParams - URL 查询参数(`minSessions` / `minHits`)
|
|
13
|
+
* @returns 有效阈值;未配置或非法的键不出现
|
|
14
|
+
*/
|
|
15
|
+
export declare function promotionThresholdsFromParams(searchParams: URLSearchParams): {
|
|
16
|
+
minSessions?: number;
|
|
17
|
+
minHits?: number;
|
|
18
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP 查询参数解析(纯函数叶子模块)
|
|
3
|
+
*
|
|
4
|
+
* API 路由(http-app)与纯读路由(read-http)共用;刻意不依赖 query-service
|
|
5
|
+
* 实现,避免 HTTP 层反向依赖服务层。
|
|
6
|
+
*
|
|
7
|
+
* @module harness/knowledge/http-params
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* 解析 promotion 候选阈值查询参数(非法值忽略,回落 hit-log 默认 3/10)。
|
|
11
|
+
*
|
|
12
|
+
* @param searchParams - URL 查询参数(`minSessions` / `minHits`)
|
|
13
|
+
* @returns 有效阈值;未配置或非法的键不出现
|
|
14
|
+
*/
|
|
15
|
+
export function promotionThresholdsFromParams(searchParams) {
|
|
16
|
+
const out = {};
|
|
17
|
+
const minSessions = Number(searchParams.get('minSessions'));
|
|
18
|
+
if (Number.isFinite(minSessions) && minSessions > 0)
|
|
19
|
+
out.minSessions = Math.floor(minSessions);
|
|
20
|
+
const minHits = Number(searchParams.get('minHits'));
|
|
21
|
+
if (Number.isFinite(minHits) && minHits > 0)
|
|
22
|
+
out.minHits = Math.floor(minHits);
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
@@ -28,6 +28,8 @@ export { EmbedRunner } from './embed-runner.js';
|
|
|
28
28
|
export type { EmbedSecretPolicy } from './embed-runner.js';
|
|
29
29
|
export { DEFAULT_KNOWLEDGE_FILE_LIMITS, classifyFileKind, decideBySize, formatMaxBytes, isRetryableSkipReason, parseTimeoutForSize, resolveKnowledgeFileLimits, } from './file-limits.js';
|
|
30
30
|
export type { KnowledgeFileKind, KnowledgeFileLimits, KnowledgeFileLimitsInput, OversizePolicy, } from './file-limits.js';
|
|
31
|
+
export { knowledgeTuningFromConfig } from './boot-config.js';
|
|
32
|
+
export type { KnowledgeBootTuning, KnowledgeBootEmbed, KnowledgeBootIngest, KnowledgeBootRetriever, } from './boot-config.js';
|
|
31
33
|
export { LocalFsFetcher, UrlFetcher, } from './fetchers.js';
|
|
32
34
|
export type { SourceFetcher, DiscoveredDocRef, DiscoverResult, VirtualDocument, } from './fetchers.js';
|
|
33
35
|
export { ConnectorRegistry, RestConnector } from './connectors.js';
|
|
@@ -18,6 +18,7 @@ export { KnowledgeJobControl } from './job-control.js';
|
|
|
18
18
|
export { JobQueue } from './job-queue.js';
|
|
19
19
|
export { EmbedRunner } from './embed-runner.js';
|
|
20
20
|
export { DEFAULT_KNOWLEDGE_FILE_LIMITS, classifyFileKind, decideBySize, formatMaxBytes, isRetryableSkipReason, parseTimeoutForSize, resolveKnowledgeFileLimits, } from './file-limits.js';
|
|
21
|
+
export { knowledgeTuningFromConfig } from './boot-config.js';
|
|
21
22
|
export { LocalFsFetcher, UrlFetcher, } from './fetchers.js';
|
|
22
23
|
export { ConnectorRegistry, RestConnector } from './connectors.js';
|
|
23
24
|
export { ConnectorFetcher } from './connector-fetcher.js';
|
|
@@ -48,6 +48,9 @@ async function main() {
|
|
|
48
48
|
documentConfig: boot.documentConfig ?? null,
|
|
49
49
|
embeddingModels: boot.embeddingModels ?? null,
|
|
50
50
|
embed: boot.embed ?? null,
|
|
51
|
+
ingest: boot.ingest ?? null,
|
|
52
|
+
retriever: boot.retriever ?? null,
|
|
53
|
+
autoDescribe: boot.autoDescribe,
|
|
51
54
|
...(boot.sqliteVecExtensionPath
|
|
52
55
|
? { sqliteVecExtensionPath: boot.sqliteVecExtensionPath }
|
|
53
56
|
: {}),
|
|
@@ -47,8 +47,11 @@ export class KnowledgePurger {
|
|
|
47
47
|
return false;
|
|
48
48
|
if (!source.generatedDescription)
|
|
49
49
|
return false;
|
|
50
|
-
// 人工 description
|
|
51
|
-
this.sources.update(sourceId, {
|
|
50
|
+
// 人工 description 权威不动;只清自动描述(含生成方归因),待重生成
|
|
51
|
+
this.sources.update(sourceId, {
|
|
52
|
+
generatedDescription: null,
|
|
53
|
+
generatedDescriptionSource: null,
|
|
54
|
+
});
|
|
52
55
|
return true;
|
|
53
56
|
}
|
|
54
57
|
}
|
|
@@ -14,6 +14,7 @@ import type { KnowledgeSource } from './types.js';
|
|
|
14
14
|
import type { KnowledgeCatalogItem } from './catalog-types.js';
|
|
15
15
|
import { type KnowledgeJobControlState } from './job-control-state.js';
|
|
16
16
|
import { type PromotionCandidate } from './hit-log.js';
|
|
17
|
+
import type { KnowledgeBootRetriever, KnowledgeBootEmbed } from './boot-config.js';
|
|
17
18
|
export interface QueryIdentity {
|
|
18
19
|
tenantId?: string;
|
|
19
20
|
gatewayId?: string;
|
|
@@ -166,7 +167,10 @@ export interface KnowledgeQueryService {
|
|
|
166
167
|
isSourceOwner(sourceId: string, gatewayId: string): Promise<boolean>;
|
|
167
168
|
ready(): Promise<ReadySnapshot>;
|
|
168
169
|
listJobs(query: ListJobsQuery): Promise<Array<Record<string, unknown>>>;
|
|
169
|
-
promotionCandidates(
|
|
170
|
+
promotionCandidates(opts?: {
|
|
171
|
+
minSessions?: number;
|
|
172
|
+
minHits?: number;
|
|
173
|
+
}): Promise<PromotionCandidate[]>;
|
|
170
174
|
dispose(): Promise<void> | void;
|
|
171
175
|
}
|
|
172
176
|
export interface LocalQueryDeps {
|
|
@@ -243,7 +247,10 @@ export declare class LocalKnowledgeQueryService implements KnowledgeQueryService
|
|
|
243
247
|
isSourceOwner(sourceId: string, gatewayId: string): Promise<boolean>;
|
|
244
248
|
ready(): Promise<ReadySnapshot>;
|
|
245
249
|
listJobs(query: ListJobsQuery): Promise<Array<Record<string, unknown>>>;
|
|
246
|
-
promotionCandidates(
|
|
250
|
+
promotionCandidates(opts?: {
|
|
251
|
+
minSessions?: number;
|
|
252
|
+
minHits?: number;
|
|
253
|
+
}): Promise<PromotionCandidate[]>;
|
|
247
254
|
dispose(): void;
|
|
248
255
|
private gatewayVisible;
|
|
249
256
|
}
|
|
@@ -269,4 +276,8 @@ export declare function createKnowledgeQueryService(opts: {
|
|
|
269
276
|
/** Worker 角色:meta=列表/控制面,search=检索/catalog,all=单 Worker 全量 */
|
|
270
277
|
role?: QueryWorkerRole;
|
|
271
278
|
queryTimeoutMs?: number;
|
|
279
|
+
/** 向量化开关(embed.enabled=false 时检索侧不建 embedding provider,不外发 query embed) */
|
|
280
|
+
embed?: KnowledgeBootEmbed | null;
|
|
281
|
+
/** 检索调参(透传进 Worker 的 KnowledgeRetriever) */
|
|
282
|
+
retriever?: KnowledgeBootRetriever | null;
|
|
272
283
|
}): Promise<KnowledgeQueryService>;
|