@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
|
@@ -290,8 +290,8 @@ export class LocalKnowledgeQueryService {
|
|
|
290
290
|
.prepare(`SELECT * FROM knowledge_jobs WHERE ${where.join(' AND ')} ORDER BY created_at DESC LIMIT ?`)
|
|
291
291
|
.all(...args, limit);
|
|
292
292
|
}
|
|
293
|
-
async promotionCandidates() {
|
|
294
|
-
return new KnowledgeHitLog(this.deps.db).promotionCandidates();
|
|
293
|
+
async promotionCandidates(opts) {
|
|
294
|
+
return new KnowledgeHitLog(this.deps.db).promotionCandidates(opts);
|
|
295
295
|
}
|
|
296
296
|
dispose() {
|
|
297
297
|
/* 只读;连接由调用方持有 */
|
|
@@ -322,5 +322,7 @@ export async function createKnowledgeQueryService(opts) {
|
|
|
322
322
|
sqliteVecExtensionPath: opts.sqliteVecExtensionPath,
|
|
323
323
|
role: opts.role ?? 'all',
|
|
324
324
|
queryTimeoutMs: opts.queryTimeoutMs,
|
|
325
|
+
embed: opts.embed ?? null,
|
|
326
|
+
retriever: opts.retriever ?? null,
|
|
325
327
|
});
|
|
326
328
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { KnowledgeQueryService, SearchQuery, AutoGroundQuery, ListSourcesQuery, QueryIdentity, PrincipalStats, ReadChunkResult, SourceStatsBundle, SourceDetail, ListJobsQuery, ReadySnapshot, QueryWorkerRole } from './query-service.js';
|
|
2
2
|
import type { PromotionCandidate } from './hit-log.js';
|
|
3
|
+
import type { KnowledgeBootEmbed, KnowledgeBootRetriever } from './boot-config.js';
|
|
3
4
|
import type { HybridSearchResult, AutoGroundDecision } from './retriever.js';
|
|
4
5
|
import type { KnowledgeSource } from './types.js';
|
|
5
6
|
import type { KnowledgeCatalogItem } from './catalog-types.js';
|
|
@@ -29,6 +30,10 @@ export declare class WorkerQueryService implements KnowledgeQueryService {
|
|
|
29
30
|
providers?: Record<string, unknown>;
|
|
30
31
|
embedding?: unknown;
|
|
31
32
|
} | null;
|
|
33
|
+
/** 向量化开关(embed.enabled=false 时不建 embedding provider) */
|
|
34
|
+
embed?: KnowledgeBootEmbed | null;
|
|
35
|
+
/** 检索调参(透传进 Worker 的 KnowledgeRetriever) */
|
|
36
|
+
retriever?: KnowledgeBootRetriever | null;
|
|
32
37
|
}): Promise<WorkerQueryService>;
|
|
33
38
|
private failAll;
|
|
34
39
|
private call;
|
|
@@ -91,6 +96,9 @@ export declare class WorkerQueryService implements KnowledgeQueryService {
|
|
|
91
96
|
isSourceOwner(sourceId: string, gatewayId: string): Promise<boolean>;
|
|
92
97
|
ready(): Promise<ReadySnapshot>;
|
|
93
98
|
listJobs(query: ListJobsQuery): Promise<Array<Record<string, unknown>>>;
|
|
94
|
-
promotionCandidates(
|
|
99
|
+
promotionCandidates(opts?: {
|
|
100
|
+
minSessions?: number;
|
|
101
|
+
minHits?: number;
|
|
102
|
+
}): Promise<PromotionCandidate[]>;
|
|
95
103
|
dispose(): Promise<void>;
|
|
96
104
|
}
|
|
@@ -75,6 +75,8 @@ export class WorkerQueryService {
|
|
|
75
75
|
sqliteVecExtensionPath: opts.sqliteVecExtensionPath,
|
|
76
76
|
embeddingModels: opts.embeddingModels ?? null,
|
|
77
77
|
role: opts.role ?? 'all',
|
|
78
|
+
embed: opts.embed ?? null,
|
|
79
|
+
retriever: opts.retriever ?? null,
|
|
78
80
|
},
|
|
79
81
|
});
|
|
80
82
|
const client = new WorkerQueryService(worker, opts.queryTimeoutMs ?? 15_000);
|
|
@@ -187,8 +189,8 @@ export class WorkerQueryService {
|
|
|
187
189
|
async listJobs(query) {
|
|
188
190
|
return (await this.call({ method: 'listJobs', query }));
|
|
189
191
|
}
|
|
190
|
-
async promotionCandidates() {
|
|
191
|
-
return (await this.call({ method: 'promotionCandidates' }));
|
|
192
|
+
async promotionCandidates(opts) {
|
|
193
|
+
return (await this.call({ method: 'promotionCandidates', opts }));
|
|
192
194
|
}
|
|
193
195
|
async dispose() {
|
|
194
196
|
if (this.disposed)
|
|
@@ -60,7 +60,8 @@ async function main() {
|
|
|
60
60
|
: true,
|
|
61
61
|
});
|
|
62
62
|
let embeddingProvider = null;
|
|
63
|
-
|
|
63
|
+
// embed.enabled=false:纯关键词索引——检索侧不建 provider,query 不外发 embed(与写侧 resolveEmbedding 同判)
|
|
64
|
+
if (boot.embeddingModels && boot.embed?.enabled !== false) {
|
|
64
65
|
const { resolveEmbeddingRuntime } = await import('../memory/sqlite/embedding-from-models.js');
|
|
65
66
|
const runtime = resolveEmbeddingRuntime(boot.embeddingModels);
|
|
66
67
|
embeddingProvider = runtime?.provider ?? null;
|
|
@@ -71,6 +72,7 @@ async function main() {
|
|
|
71
72
|
sourceStore: sources,
|
|
72
73
|
indexStore: index,
|
|
73
74
|
embeddingProvider: embeddingProvider,
|
|
75
|
+
...(boot.retriever ?? {}),
|
|
74
76
|
});
|
|
75
77
|
const svc = new LocalKnowledgeQueryService({
|
|
76
78
|
db,
|
|
@@ -162,7 +164,7 @@ async function main() {
|
|
|
162
164
|
data = await svc.listJobs(msg.query);
|
|
163
165
|
break;
|
|
164
166
|
case 'promotionCandidates':
|
|
165
|
-
data = await svc.promotionCandidates();
|
|
167
|
+
data = await svc.promotionCandidates(msg.opts);
|
|
166
168
|
break;
|
|
167
169
|
default:
|
|
168
170
|
throw new Error(`unknown_query_method`);
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* ingest 占死写线程时列表/详情仍应答。
|
|
6
6
|
*/
|
|
7
7
|
import { matchKnowledgeToken } from './http-bridge.js';
|
|
8
|
+
import { promotionThresholdsFromParams } from './http-params.js';
|
|
8
9
|
function json(res, status, payload) {
|
|
9
10
|
const buf = Buffer.from(JSON.stringify(payload), 'utf8');
|
|
10
11
|
res.writeHead(status, {
|
|
@@ -337,7 +338,10 @@ export async function handleKnowledgeReadHttp(deps, req, res, auth) {
|
|
|
337
338
|
return true;
|
|
338
339
|
}
|
|
339
340
|
if (path === '/v1/promotion-candidates') {
|
|
340
|
-
json(res, 200, {
|
|
341
|
+
json(res, 200, {
|
|
342
|
+
ok: true,
|
|
343
|
+
data: await meta.promotionCandidates(promotionThresholdsFromParams(url.searchParams)),
|
|
344
|
+
});
|
|
341
345
|
return true;
|
|
342
346
|
}
|
|
343
347
|
err(res, 404, 'not_found', `no route ${method} ${path}`);
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { type Server } from 'node:http';
|
|
14
14
|
import type { KnowledgeServiceToken } from './http-app.js';
|
|
15
|
+
import type { KnowledgeBootEmbed, KnowledgeBootIngest, KnowledgeBootRetriever } from './boot-config.js';
|
|
15
16
|
export interface KnowledgeServeOptions {
|
|
16
17
|
dbPath: string;
|
|
17
18
|
host?: string;
|
|
@@ -21,13 +22,13 @@ export interface KnowledgeServeOptions {
|
|
|
21
22
|
documentConfig?: import('../capabilities/document/factory.js').DocumentCapabilityConfig | null;
|
|
22
23
|
/** 测试 stub(闭包无法进 Worker);生产用 embeddingModels */
|
|
23
24
|
testEmbeddingStub?: boolean;
|
|
24
|
-
embed?:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
embed?: KnowledgeBootEmbed | null;
|
|
26
|
+
/** Ingest 调参(knowledge.load / index.queue / index.files) */
|
|
27
|
+
ingest?: KnowledgeBootIngest | null;
|
|
28
|
+
/** 检索调参(knowledge.keywordWeight / autoInject / hint / index.hybridKeyword) */
|
|
29
|
+
retriever?: KnowledgeBootRetriever | null;
|
|
30
|
+
/** false = 索引稳定后不自动生成 generatedDescription(knowledge.catalog.autoDescribe) */
|
|
31
|
+
autoDescribe?: boolean;
|
|
31
32
|
sqliteVecExtensionPath?: string;
|
|
32
33
|
embeddingModels?: {
|
|
33
34
|
providers?: Record<string, unknown>;
|
|
@@ -35,6 +35,8 @@ async function startQueryWorker(opts) {
|
|
|
35
35
|
mode: 'worker',
|
|
36
36
|
role: opts.role,
|
|
37
37
|
embeddingModels: opts.embeddingModels ?? null,
|
|
38
|
+
embed: opts.embed ?? null,
|
|
39
|
+
retriever: opts.retriever ?? null,
|
|
38
40
|
...(opts.sqliteVecExtensionPath
|
|
39
41
|
? { sqliteVecExtensionPath: opts.sqliteVecExtensionPath }
|
|
40
42
|
: {}),
|
|
@@ -59,6 +61,9 @@ export async function startKnowledgeService(opts) {
|
|
|
59
61
|
sqliteVecExtensionPath: opts.sqliteVecExtensionPath,
|
|
60
62
|
embeddingModels: opts.embeddingModels ?? null,
|
|
61
63
|
embed: opts.embed ?? null,
|
|
64
|
+
ingest: opts.ingest ?? null,
|
|
65
|
+
retriever: opts.retriever ?? null,
|
|
66
|
+
autoDescribe: opts.autoDescribe,
|
|
62
67
|
testEmbeddingStub: opts.testEmbeddingStub ?? false,
|
|
63
68
|
// 文件库:纯读在主线程 Meta/Search;Engine 只做写编排 + 残留短读
|
|
64
69
|
skipQueryWorker: useSplitQuery,
|
|
@@ -100,12 +105,16 @@ export async function startKnowledgeService(opts) {
|
|
|
100
105
|
role: 'meta',
|
|
101
106
|
sqliteVecExtensionPath: opts.sqliteVecExtensionPath,
|
|
102
107
|
embeddingModels: opts.embeddingModels,
|
|
108
|
+
embed: opts.embed,
|
|
109
|
+
retriever: opts.retriever,
|
|
103
110
|
}),
|
|
104
111
|
startQueryWorker({
|
|
105
112
|
dbPath: opts.dbPath,
|
|
106
113
|
role: 'search',
|
|
107
114
|
sqliteVecExtensionPath: opts.sqliteVecExtensionPath,
|
|
108
115
|
embeddingModels: opts.embeddingModels,
|
|
116
|
+
embed: opts.embed,
|
|
117
|
+
retriever: opts.retriever,
|
|
109
118
|
}),
|
|
110
119
|
]);
|
|
111
120
|
}
|
|
@@ -60,12 +60,22 @@ function deriveDisplayName(location) {
|
|
|
60
60
|
return parts[parts.length - 1] || location || 'source';
|
|
61
61
|
}
|
|
62
62
|
function toCatalogItem(source, extras) {
|
|
63
|
+
const human = source.description?.trim();
|
|
64
|
+
const generated = source.generatedDescription?.trim();
|
|
63
65
|
return {
|
|
64
66
|
id: source.id,
|
|
65
67
|
displayName: source.displayName,
|
|
66
68
|
kind: source.kind,
|
|
67
69
|
status: statusBucket(source.status),
|
|
68
|
-
description:
|
|
70
|
+
description: human || generated || undefined,
|
|
71
|
+
// 信任分级(human > llm > heuristic);blocked_secret 的文本是启发式,归 heuristic 档
|
|
72
|
+
...(human
|
|
73
|
+
? { descriptionSource: 'human' }
|
|
74
|
+
: generated
|
|
75
|
+
? {
|
|
76
|
+
descriptionSource: source.generatedDescriptionSource === 'llm' ? 'llm' : 'heuristic',
|
|
77
|
+
}
|
|
78
|
+
: {}),
|
|
69
79
|
scopeLevel: source.scopeRef.level,
|
|
70
80
|
scaleLabel: scaleLabel(source, extras?.fileCount),
|
|
71
81
|
location: source.location,
|
|
@@ -93,6 +103,9 @@ function rowToSource(row) {
|
|
|
93
103
|
displayName: String(row.display_name),
|
|
94
104
|
description: row.description == null ? undefined : String(row.description),
|
|
95
105
|
generatedDescription: row.generated_description == null ? undefined : String(row.generated_description),
|
|
106
|
+
generatedDescriptionSource: row.generated_description_source == null
|
|
107
|
+
? undefined
|
|
108
|
+
: String(row.generated_description_source),
|
|
96
109
|
catalogPriority: row.catalog_priority == null ? undefined : Number(row.catalog_priority),
|
|
97
110
|
hiddenFromCatalog: Number(row.hidden_from_catalog) === 1,
|
|
98
111
|
authRef: row.auth_ref == null ? undefined : String(row.auth_ref),
|
|
@@ -138,6 +151,7 @@ export class KnowledgeSourceStore {
|
|
|
138
151
|
displayName,
|
|
139
152
|
description: input.description,
|
|
140
153
|
generatedDescription: input.generatedDescription,
|
|
154
|
+
generatedDescriptionSource: input.generatedDescriptionSource,
|
|
141
155
|
catalogPriority: input.catalogPriority,
|
|
142
156
|
hiddenFromCatalog: input.hiddenFromCatalog ?? false,
|
|
143
157
|
authRef: input.authRef,
|
|
@@ -181,6 +195,13 @@ export class KnowledgeSourceStore {
|
|
|
181
195
|
: patch.generatedDescription,
|
|
182
196
|
}
|
|
183
197
|
: {}),
|
|
198
|
+
...(patch.generatedDescriptionSource !== undefined
|
|
199
|
+
? {
|
|
200
|
+
generatedDescriptionSource: patch.generatedDescriptionSource === null
|
|
201
|
+
? undefined
|
|
202
|
+
: patch.generatedDescriptionSource,
|
|
203
|
+
}
|
|
204
|
+
: {}),
|
|
184
205
|
...(patch.catalogPriority !== undefined ? { catalogPriority: patch.catalogPriority } : {}),
|
|
185
206
|
...(patch.hiddenFromCatalog !== undefined
|
|
186
207
|
? { hiddenFromCatalog: patch.hiddenFromCatalog }
|
|
@@ -617,9 +638,10 @@ export class KnowledgeSourceStore {
|
|
|
617
638
|
.prepare(`INSERT INTO knowledge_sources (
|
|
618
639
|
id, kind, location, scope_level, scope_key, sync_json, status, coverage,
|
|
619
640
|
errors_json, display_name, description, generated_description,
|
|
641
|
+
generated_description_source,
|
|
620
642
|
catalog_priority, hidden_from_catalog, auth_ref, network_json, discover_json,
|
|
621
643
|
last_polled_at, created_at, updated_at
|
|
622
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
644
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
623
645
|
ON CONFLICT(id) DO UPDATE SET
|
|
624
646
|
kind=excluded.kind,
|
|
625
647
|
location=excluded.location,
|
|
@@ -632,6 +654,7 @@ export class KnowledgeSourceStore {
|
|
|
632
654
|
display_name=excluded.display_name,
|
|
633
655
|
description=excluded.description,
|
|
634
656
|
generated_description=excluded.generated_description,
|
|
657
|
+
generated_description_source=excluded.generated_description_source,
|
|
635
658
|
catalog_priority=excluded.catalog_priority,
|
|
636
659
|
hidden_from_catalog=excluded.hidden_from_catalog,
|
|
637
660
|
auth_ref=excluded.auth_ref,
|
|
@@ -639,6 +662,6 @@ export class KnowledgeSourceStore {
|
|
|
639
662
|
discover_json=excluded.discover_json,
|
|
640
663
|
last_polled_at=excluded.last_polled_at,
|
|
641
664
|
updated_at=excluded.updated_at`)
|
|
642
|
-
.run(source.id, source.kind, source.location, source.scopeRef.level, source.scopeRef.key, JSON.stringify(source.sync), source.status, source.coverage ?? null, JSON.stringify(source.errors ?? []), source.displayName, source.description ?? null, source.generatedDescription ?? null, source.catalogPriority ?? null, source.hiddenFromCatalog ? 1 : 0, source.authRef ?? null, source.network ? JSON.stringify(source.network) : null, source.discover ? JSON.stringify(source.discover) : null, source.lastPolledAt ?? null, source.createdAt, source.updatedAt);
|
|
665
|
+
.run(source.id, source.kind, source.location, source.scopeRef.level, source.scopeRef.key, JSON.stringify(source.sync), source.status, source.coverage ?? null, JSON.stringify(source.errors ?? []), source.displayName, source.description ?? null, source.generatedDescription ?? null, source.generatedDescriptionSource ?? null, source.catalogPriority ?? null, source.hiddenFromCatalog ? 1 : 0, source.authRef ?? null, source.network ? JSON.stringify(source.network) : null, source.discover ? JSON.stringify(source.discover) : null, source.lastPolledAt ?? null, source.createdAt, source.updatedAt);
|
|
643
666
|
}
|
|
644
667
|
}
|
|
@@ -14,19 +14,20 @@
|
|
|
14
14
|
import { type ChildProcess } from 'node:child_process';
|
|
15
15
|
import type { KnowledgeServiceToken } from './http-app.js';
|
|
16
16
|
import type { DocumentCapabilityConfig } from '../capabilities/document/factory.js';
|
|
17
|
+
import type { KnowledgeBootEmbed, KnowledgeBootIngest, KnowledgeBootRetriever } from './boot-config.js';
|
|
17
18
|
export interface KnowledgeServiceProcessOptions {
|
|
18
19
|
dbPath: string;
|
|
19
20
|
port?: number;
|
|
20
21
|
host?: string;
|
|
21
22
|
tokens: KnowledgeServiceToken[];
|
|
22
23
|
documentConfig?: DocumentCapabilityConfig | null;
|
|
23
|
-
embed?:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
embed?: KnowledgeBootEmbed;
|
|
25
|
+
/** Ingest 调参(knowledge.load / index.queue / index.files) */
|
|
26
|
+
ingest?: KnowledgeBootIngest;
|
|
27
|
+
/** 检索调参(knowledge.keywordWeight / autoInject / hint / index.hybridKeyword) */
|
|
28
|
+
retriever?: KnowledgeBootRetriever;
|
|
29
|
+
/** false = 索引稳定后不自动生成 generatedDescription(knowledge.catalog.autoDescribe) */
|
|
30
|
+
autoDescribe?: boolean;
|
|
30
31
|
sqliteVecExtensionPath?: string;
|
|
31
32
|
embeddingModels?: {
|
|
32
33
|
providers?: Record<string, unknown>;
|
|
@@ -40,6 +41,13 @@ export interface KnowledgeServiceProcessHandle {
|
|
|
40
41
|
/** 发 close 并等待退出;超时 SIGTERM */
|
|
41
42
|
stop(): Promise<void>;
|
|
42
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* 组装 boot 文件内容 — Gateway 调参面 → Service 子进程的唯一交接面(纯函数,可单测锁 hop)。
|
|
46
|
+
*
|
|
47
|
+
* @param opts - 进程启动选项(与 startKnowledgeService 同构 + embeddingModels)
|
|
48
|
+
* @returns boot JSON 对象(与 knowledge-serve-child 的 BootFile 同构)
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildKnowledgeServiceBootFile(opts: KnowledgeServiceProcessOptions): Record<string, unknown>;
|
|
43
51
|
/**
|
|
44
52
|
* 在独立子进程启动 Knowledge HTTP Service。
|
|
45
53
|
*
|
|
@@ -33,25 +33,37 @@ function childNodeEnv() {
|
|
|
33
33
|
return env;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* 组装 boot 文件内容 — Gateway 调参面 → Service 子进程的唯一交接面(纯函数,可单测锁 hop)。
|
|
37
37
|
*
|
|
38
|
-
* @param opts -
|
|
39
|
-
* @returns child
|
|
38
|
+
* @param opts - 进程启动选项(与 startKnowledgeService 同构 + embeddingModels)
|
|
39
|
+
* @returns boot JSON 对象(与 knowledge-serve-child 的 BootFile 同构)
|
|
40
40
|
*/
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
const bootDir = await mkdtemp(join(tmpdir(), 'octopi-kn-boot-'));
|
|
44
|
-
const bootPath = join(bootDir, 'boot.json');
|
|
45
|
-
await writeFile(bootPath, JSON.stringify({
|
|
41
|
+
export function buildKnowledgeServiceBootFile(opts) {
|
|
42
|
+
return {
|
|
46
43
|
dbPath: opts.dbPath,
|
|
47
44
|
host: opts.host,
|
|
48
45
|
port: opts.port ?? 18280,
|
|
49
46
|
tokens: opts.tokens,
|
|
50
47
|
documentConfig: opts.documentConfig ?? null,
|
|
51
48
|
embed: opts.embed,
|
|
49
|
+
ingest: opts.ingest,
|
|
50
|
+
retriever: opts.retriever,
|
|
51
|
+
autoDescribe: opts.autoDescribe,
|
|
52
52
|
sqliteVecExtensionPath: opts.sqliteVecExtensionPath,
|
|
53
53
|
embeddingModels: opts.embeddingModels ?? null,
|
|
54
|
-
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 在独立子进程启动 Knowledge HTTP Service。
|
|
58
|
+
*
|
|
59
|
+
* @param opts - 与 startKnowledgeService 同构 + embeddingModels(子进程内重建 provider)
|
|
60
|
+
* @returns child + 端口 + stop
|
|
61
|
+
*/
|
|
62
|
+
export async function startKnowledgeServiceProcess(opts) {
|
|
63
|
+
const entry = fileURLToPath(resolveWorkerUrl('./knowledge-serve-child.js', import.meta.url));
|
|
64
|
+
const bootDir = await mkdtemp(join(tmpdir(), 'octopi-kn-boot-'));
|
|
65
|
+
const bootPath = join(bootDir, 'boot.json');
|
|
66
|
+
await writeFile(bootPath, JSON.stringify(buildKnowledgeServiceBootFile(opts)), 'utf8');
|
|
55
67
|
// @types/node 的 ForkOptions 未声明 windowsHide 等字段,运行时有效
|
|
56
68
|
// execPath 必须保持 process.execPath:Electron 下换捆绑 node 会切断 IPC
|
|
57
69
|
const forkOpts = {
|
|
@@ -20,6 +20,8 @@ export interface KnowledgeScopeRef {
|
|
|
20
20
|
/** global: 'global';project: projectKey;session: sessionId */
|
|
21
21
|
key: string;
|
|
22
22
|
}
|
|
23
|
+
/** generatedDescription 生成方(信任分级 human > llm > heuristic) */
|
|
24
|
+
export type KnowledgeGeneratedDescriptionSource = 'heuristic' | 'llm' | 'blocked_secret';
|
|
23
25
|
export type KnowledgeSourceStatus = 'pending' | 'discovering' | 'partial' | 'ready' | 'error' | 'disabled' | 'removed';
|
|
24
26
|
export type KnowledgeSourceKind = 'workspace' | 'directory' | 'file' | 'url' | 'connector';
|
|
25
27
|
export interface KnowledgeSourceSync {
|
|
@@ -72,6 +74,8 @@ export interface KnowledgeSource {
|
|
|
72
74
|
description?: string;
|
|
73
75
|
/** 自动描述(可被 description 覆盖) */
|
|
74
76
|
generatedDescription?: string;
|
|
77
|
+
/** 自动描述生成方(信任分级:llm 优于 heuristic;blocked_secret=抽样含密钥形态,未外发) */
|
|
78
|
+
generatedDescriptionSource?: KnowledgeGeneratedDescriptionSource;
|
|
75
79
|
catalogPriority?: number;
|
|
76
80
|
hiddenFromCatalog?: boolean;
|
|
77
81
|
/** CredentialStore 凭证名(密钥不进本库) */
|
|
@@ -94,6 +98,7 @@ export type KnowledgeSourceInput = {
|
|
|
94
98
|
displayName?: string;
|
|
95
99
|
description?: string;
|
|
96
100
|
generatedDescription?: string;
|
|
101
|
+
generatedDescriptionSource?: KnowledgeGeneratedDescriptionSource;
|
|
97
102
|
catalogPriority?: number;
|
|
98
103
|
hiddenFromCatalog?: boolean;
|
|
99
104
|
status?: KnowledgeSourceStatus;
|
|
@@ -107,6 +112,8 @@ export type KnowledgeSourcePatch = Partial<Pick<KnowledgeSource, 'location' | 's
|
|
|
107
112
|
displayName?: string | null;
|
|
108
113
|
description?: string | null;
|
|
109
114
|
generatedDescription?: string | null;
|
|
115
|
+
/** 传 null 可清除(与 generatedDescription 同清) */
|
|
116
|
+
generatedDescriptionSource?: KnowledgeGeneratedDescriptionSource | null;
|
|
110
117
|
authRef?: string | null;
|
|
111
118
|
network?: KnowledgeSourceNetwork | null;
|
|
112
119
|
discover?: KnowledgeSourceDiscover | null;
|
|
@@ -12,6 +12,7 @@ import { KnowledgeIngest, type IngestProgressEvent } from './ingest.js';
|
|
|
12
12
|
import type { KnowledgeSource } from './types.js';
|
|
13
13
|
import type { KnowledgeJobControlState } from './job-control-state.js';
|
|
14
14
|
import type { DocumentCapabilityConfig } from '../capabilities/document/factory.js';
|
|
15
|
+
import type { KnowledgeBootEmbed, KnowledgeBootIngest } from './boot-config.js';
|
|
15
16
|
import type { EmbeddingProvider } from '../memory/sqlite/embedding.js';
|
|
16
17
|
export interface WriteIdentity {
|
|
17
18
|
tenantId: string;
|
|
@@ -33,6 +34,25 @@ export interface WriteDescribeResult {
|
|
|
33
34
|
generatedDescription: string;
|
|
34
35
|
source: string;
|
|
35
36
|
}
|
|
37
|
+
/** gateway 代生成(B 方案)的抽样出 Service 边界形态:密钥扫描在此把关 */
|
|
38
|
+
export type WriteDescribeSampleResult = {
|
|
39
|
+
blocked: false;
|
|
40
|
+
meta: {
|
|
41
|
+
displayName: string;
|
|
42
|
+
kind: string;
|
|
43
|
+
location: string;
|
|
44
|
+
};
|
|
45
|
+
sample: string;
|
|
46
|
+
} | {
|
|
47
|
+
blocked: true;
|
|
48
|
+
secretHits: string[];
|
|
49
|
+
};
|
|
50
|
+
/** describe 写入口(gateway 回写 LLM 描述) */
|
|
51
|
+
export interface WriteDescribeInput {
|
|
52
|
+
description: string;
|
|
53
|
+
/** 缺省 'llm'(写入口的调用方是 gateway 的 LLM describe 流程) */
|
|
54
|
+
source?: 'llm' | 'heuristic';
|
|
55
|
+
}
|
|
36
56
|
export interface WriteReprocessResult {
|
|
37
57
|
queued: number;
|
|
38
58
|
alreadyActive: number;
|
|
@@ -69,7 +89,11 @@ export interface KnowledgeWriteService {
|
|
|
69
89
|
id: string;
|
|
70
90
|
purgedFiles: number;
|
|
71
91
|
}>;
|
|
72
|
-
describeSource(identity: WriteIdentity, sourceId: string): Promise<WriteDescribeResult | null>;
|
|
92
|
+
describeSource(identity: WriteIdentity, sourceId: string, input?: WriteDescribeInput): Promise<WriteDescribeResult | null>;
|
|
93
|
+
/** 抽样出 Service 边界(gateway 代生成取素材);密钥命中即封锁不外发 */
|
|
94
|
+
describeSample(identity: WriteIdentity, sourceId: string): Promise<WriteDescribeSampleResult | null>;
|
|
95
|
+
/** 待 LLM 升级的源(heuristic/legacy 归因且无人工描述),供 gateway boot sweep */
|
|
96
|
+
listDescribePending(identity: WriteIdentity): Promise<string[]>;
|
|
73
97
|
reindexSource(sourceId: string): Promise<void>;
|
|
74
98
|
/** 按路径强制重解析(中止态自动 resume) */
|
|
75
99
|
reprocessFiles(sourceId: string, paths: string[]): Promise<WriteReprocessResult>;
|
|
@@ -112,13 +136,11 @@ export interface LocalWriteDeps {
|
|
|
112
136
|
embeddingProvider?: EmbeddingProvider | null;
|
|
113
137
|
/** source.authRef 解析(SEC-3c consumer 绑定强制) */
|
|
114
138
|
credentials?: import('../governance/credentials/store.js').CredentialStore | null;
|
|
115
|
-
embed?:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
embedSecretPolicy?: 'allow' | 'redact' | 'skip';
|
|
121
|
-
} | null;
|
|
139
|
+
embed?: KnowledgeBootEmbed | null;
|
|
140
|
+
/** Ingest 调参(knowledge.load / index.queue / index.files) */
|
|
141
|
+
ingest?: KnowledgeBootIngest | null;
|
|
142
|
+
/** false = 索引稳定后不自动生成 generatedDescription(knowledge.catalog.autoDescribe) */
|
|
143
|
+
autoDescribe?: boolean;
|
|
122
144
|
}
|
|
123
145
|
/** 进程内唯一写者(测试 / :memory:)。 */
|
|
124
146
|
export declare class LocalKnowledgeWriteService implements KnowledgeWriteService {
|
|
@@ -156,7 +178,11 @@ export declare class LocalKnowledgeWriteService implements KnowledgeWriteService
|
|
|
156
178
|
id: string;
|
|
157
179
|
purgedFiles: number;
|
|
158
180
|
}>;
|
|
159
|
-
describeSource(identity: WriteIdentity, sourceId: string): Promise<WriteDescribeResult | null>;
|
|
181
|
+
describeSource(identity: WriteIdentity, sourceId: string, input?: WriteDescribeInput): Promise<WriteDescribeResult | null>;
|
|
182
|
+
describeSample(identity: WriteIdentity, sourceId: string): Promise<WriteDescribeSampleResult | null>;
|
|
183
|
+
listDescribePending(identity: WriteIdentity): Promise<string[]>;
|
|
184
|
+
/** 启发式/封锁描述生成(无 describePort:Service 侧永不含 LLM 出网,B 方案拍板) */
|
|
185
|
+
private describeWithSample;
|
|
160
186
|
private assertSourceOwner;
|
|
161
187
|
reindexSource(sourceId: string): Promise<void>;
|
|
162
188
|
reprocessFiles(sourceId: string, paths: string[]): Promise<WriteReprocessResult>;
|
|
@@ -192,5 +218,7 @@ export declare class LocalKnowledgeWriteService implements KnowledgeWriteService
|
|
|
192
218
|
sourceVisibleToGateway(sourceId: string, gatewayId: string): Promise<boolean>;
|
|
193
219
|
startIngestRuntime(): Promise<void>;
|
|
194
220
|
onProgress(cb: (evt: IngestProgressEvent) => void): () => void;
|
|
221
|
+
/** Writer 自产事件(describe-pending 等);归属补齐口径与 IngestProgressEvent 一致 */
|
|
222
|
+
private emitProgress;
|
|
195
223
|
dispose(): Promise<void>;
|
|
196
224
|
}
|