@octopi-agent/engine 0.70.7 → 0.86.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/NOTICE +7 -7
- package/README.md +64 -26
- package/dist/config-schema/agent.d.ts +89 -1
- package/dist/config-schema/agent.js +69 -0
- package/dist/config-schema/context.d.ts +23 -4
- package/dist/config-schema/context.js +28 -1
- package/dist/config-schema/engine.d.ts +201 -9
- package/dist/config-schema/engine.js +31 -2
- package/dist/config-schema/governance.d.ts +95 -0
- package/dist/config-schema/governance.js +91 -0
- package/dist/config-schema/models.d.ts +1 -1
- package/dist/config-schema/observability.d.ts +6 -0
- package/dist/config-schema/observability.js +16 -0
- package/dist/config-schema/run.d.ts +10 -0
- package/dist/config-schema/run.js +18 -0
- package/dist/config-schema/shared.d.ts +10 -0
- package/dist/config-schema/shared.js +10 -0
- package/dist/config-schema/substrate.d.ts +1 -1
- package/dist/config-schema/subsystems.d.ts +1 -1
- package/dist/config-schema/subsystems.js +2 -1
- package/dist/config.d.ts +178 -7
- package/dist/config.js +113 -3
- package/dist/harness/activation/compiler.js +3 -0
- package/dist/harness/activation/runtime.d.ts +7 -0
- package/dist/harness/activation/runtime.js +60 -2
- package/dist/harness/activation/sources/agent-signal.d.ts +11 -0
- package/dist/harness/activation/sources/agent-signal.js +33 -0
- package/dist/harness/activation/types.d.ts +6 -1
- package/dist/harness/agent/builder.d.ts +47 -3
- package/dist/harness/agent/builder.js +180 -54
- package/dist/harness/agent/config-bridge.d.ts +33 -25
- package/dist/harness/agent/config-bridge.js +81 -291
- package/dist/harness/agent/index.d.ts +3 -1
- package/dist/harness/agent/index.js +2 -1
- package/dist/harness/agent/tool-purpose.d.ts +38 -0
- package/dist/harness/agent/tool-purpose.js +118 -0
- package/dist/harness/agent/wire-agent-builder.d.ts +133 -0
- package/dist/harness/agent/wire-agent-builder.js +363 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +4 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +14 -8
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +12 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +19 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.d.ts +6 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.js +24 -7
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.d.ts +5 -2
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +11 -3
- package/dist/harness/collaboration/autonomous-subsystem/think/index.d.ts +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/index.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.d.ts +7 -4
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.js +8 -9
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.d.ts +36 -10
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.js +60 -7
- package/dist/harness/collaboration/delegation/child-run.d.ts +144 -0
- package/dist/harness/collaboration/delegation/child-run.js +241 -0
- package/dist/harness/collaboration/delegation/index.d.ts +26 -0
- package/dist/harness/collaboration/delegation/index.js +25 -0
- package/dist/harness/collaboration/delegation/notifier.d.ts +46 -0
- package/dist/harness/collaboration/delegation/notifier.js +84 -0
- package/dist/harness/collaboration/delegation/registry-types.d.ts +200 -0
- package/dist/harness/collaboration/delegation/registry-types.js +61 -0
- package/dist/harness/collaboration/delegation/registry.d.ts +110 -0
- package/dist/harness/collaboration/delegation/registry.js +220 -0
- package/dist/harness/collaboration/delegation/service.d.ts +249 -0
- package/dist/harness/collaboration/delegation/service.js +499 -0
- package/dist/harness/collaboration/delegation/store.d.ts +155 -0
- package/dist/harness/collaboration/delegation/store.js +271 -0
- package/dist/harness/collaboration/delegation/transport.d.ts +73 -0
- package/dist/harness/collaboration/delegation/transport.js +61 -0
- package/dist/harness/collaboration/delegation/types.d.ts +231 -0
- package/dist/harness/collaboration/delegation/types.js +70 -0
- package/dist/harness/collaboration/delegation/wiring.d.ts +111 -0
- package/dist/harness/collaboration/delegation/wiring.js +145 -0
- package/dist/harness/collaboration/orchestration/index.d.ts +11 -13
- package/dist/harness/collaboration/orchestration/index.js +11 -11
- package/dist/harness/context/assembler.d.ts +2 -2
- package/dist/harness/context/assembler.js +12 -7
- package/dist/harness/context/capabilities/compact/engine.js +80 -38
- package/dist/harness/context/capabilities/compact/types.d.ts +12 -1
- package/dist/harness/context/capabilities/summary/registry.js +10 -0
- package/dist/harness/context/constitution/default-agents.md +230 -228
- package/dist/harness/context/default-context-engine.d.ts +101 -23
- package/dist/harness/context/default-context-engine.js +483 -172
- package/dist/harness/context/hybrid-compressor.d.ts +3 -3
- package/dist/harness/context/hybrid-compressor.js +18 -23
- package/dist/harness/context/index.d.ts +5 -1
- package/dist/harness/context/index.js +2 -0
- package/dist/harness/context/layer-snapshot.d.ts +4 -0
- package/dist/harness/context/layer-snapshot.js +30 -18
- package/dist/harness/context/layer-types.d.ts +49 -1
- package/dist/harness/context/layer-types.js +72 -4
- package/dist/harness/context/layers.d.ts +5 -2
- package/dist/harness/context/layers.js +11 -5
- package/dist/harness/context/llm-summarizer.d.ts +15 -1
- package/dist/harness/context/llm-summarizer.js +107 -56
- package/dist/harness/context/message-selector.js +6 -2
- package/dist/harness/context/root-instructions.d.ts +72 -0
- package/dist/harness/context/root-instructions.js +227 -0
- package/dist/harness/context/runtime-datetime.d.ts +34 -7
- package/dist/harness/context/runtime-datetime.js +66 -10
- package/dist/harness/context/smart-router.d.ts +1 -1
- package/dist/harness/context/smart-router.js +1 -1
- package/dist/harness/context/system-prompt-assembler.d.ts +30 -0
- package/dist/harness/context/system-prompt-assembler.js +67 -6
- package/dist/harness/context/token-constants.d.ts +2 -2
- package/dist/harness/context/token-constants.js +2 -2
- package/dist/harness/context/token-estimate-fns.d.ts +1 -3
- package/dist/harness/context/token-estimate-fns.js +2 -4
- package/dist/harness/context/token-estimator.d.ts +1 -1
- package/dist/harness/context/token-estimator.js +14 -6
- package/dist/harness/context/tool-result-aging.d.ts +140 -0
- package/dist/harness/context/tool-result-aging.js +331 -0
- package/dist/harness/context/tool-result-body.d.ts +10 -0
- package/dist/harness/context/tool-result-body.js +27 -0
- package/dist/harness/context/turn-envelope.d.ts +123 -0
- package/dist/harness/context/turn-envelope.js +188 -0
- package/dist/harness/context/types.d.ts +35 -47
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +248 -0
- package/dist/harness/extension/execution-environment/effect-policy.js +334 -0
- package/dist/harness/extension/execution-environment/index.d.ts +18 -2
- package/dist/harness/extension/execution-environment/index.js +11 -2
- package/dist/harness/extension/execution-environment/memory-undo.d.ts +101 -0
- package/dist/harness/extension/execution-environment/memory-undo.js +192 -0
- package/dist/harness/extension/execution-environment/process-isolation.d.ts +84 -0
- package/dist/harness/extension/execution-environment/process-isolation.js +315 -0
- package/dist/harness/extension/execution-environment/resource-limits.d.ts +36 -0
- package/dist/harness/extension/execution-environment/resource-limits.js +84 -0
- package/dist/harness/extension/execution-environment/sandbox.d.ts +125 -4
- package/dist/harness/extension/execution-environment/sandbox.js +493 -51
- package/dist/harness/extension/execution-environment/shell-journal.d.ts +100 -0
- package/dist/harness/extension/execution-environment/shell-journal.js +299 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.d.ts +45 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.js +126 -0
- package/dist/harness/extension/execution-environment/types.d.ts +67 -39
- package/dist/harness/extension/execution-environment/types.js +2 -2
- package/dist/harness/extension/execution-environment/undo-log.d.ts +203 -0
- package/dist/harness/extension/execution-environment/undo-log.js +627 -0
- package/dist/harness/extension/execution-environment/undo-merge.d.ts +40 -0
- package/dist/harness/extension/execution-environment/undo-merge.js +167 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/index.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/client-tools/types.d.ts +9 -0
- package/dist/harness/extension/plugin-ecosystem/mcp/bridge.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +1 -6
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +3 -8
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +2 -10
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +2 -9
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +1 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/index.js +1 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +2 -4
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +4 -21
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +3 -9
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +4 -8
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +1 -4
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +1 -3
- package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/skills/manager.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.d.ts +45 -0
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.js +136 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +18 -3
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +277 -81
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.d.ts +31 -0
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +291 -0
- package/dist/harness/extension/plugin-ecosystem/tools/document-tools.js +10 -2
- package/dist/harness/extension/plugin-ecosystem/tools/env-info.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/eol.d.ts +35 -0
- package/dist/harness/extension/plugin-ecosystem/tools/eol.js +43 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +40 -9
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.d.ts +33 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.js +376 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +12 -2
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +239 -61
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.d.ts +27 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +554 -0
- package/dist/harness/extension/plugin-ecosystem/tools/http.d.ts +10 -6
- package/dist/harness/extension/plugin-ecosystem/tools/http.js +41 -47
- package/dist/harness/extension/plugin-ecosystem/tools/index.d.ts +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/index.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +4 -0
- package/dist/harness/extension/plugin-ecosystem/tools/memory.js +25 -1
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.d.ts +13 -0
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +391 -0
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +51 -2
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +151 -12
- package/dist/harness/extension/plugin-ecosystem/tools/session-history.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +10 -1
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +35 -19
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +8 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +5 -0
- package/dist/harness/extension/plugin-ecosystem/tools/web-search.js +1 -0
- package/dist/harness/governance/credentials/index.d.ts +1 -1
- package/dist/harness/governance/credentials/store.d.ts +16 -4
- package/dist/harness/governance/credentials/store.js +33 -6
- package/dist/harness/governance/credentials/types.d.ts +11 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +105 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.js +184 -0
- package/dist/harness/governance/human-in-the-loop/index.d.ts +5 -5
- package/dist/harness/governance/human-in-the-loop/index.js +3 -3
- package/dist/harness/governance/human-in-the-loop/types.d.ts +7 -62
- package/dist/harness/governance/human-in-the-loop/types.js +6 -2
- package/dist/harness/governance/security/capability-enforcer.d.ts +9 -1
- package/dist/harness/governance/security/capability-enforcer.js +31 -8
- package/dist/harness/governance/security/degradation.js +5 -7
- package/dist/harness/governance/security/risk-evaluator.d.ts +1 -1
- package/dist/harness/governance/security/risk-evaluator.js +4 -82
- package/dist/harness/governance/security/temp-path.d.ts +41 -0
- package/dist/harness/governance/security/temp-path.js +117 -0
- package/dist/harness/governance/session-acl/index.d.ts +1 -0
- package/dist/harness/governance/session-acl/index.js +1 -0
- package/dist/harness/governance/session-acl/rights.d.ts +12 -0
- package/dist/harness/governance/session-acl/rights.js +89 -7
- package/dist/harness/governance/session-acl/seed-roles.js +9 -1
- package/dist/harness/governance/session-acl/service.js +21 -29
- package/dist/harness/governance/session-acl/tool-rights.d.ts +81 -0
- package/dist/harness/governance/session-acl/tool-rights.js +238 -0
- package/dist/harness/governance/session-acl/types.d.ts +22 -0
- package/dist/harness/index.d.ts +14 -12
- package/dist/harness/index.js +9 -6
- package/dist/harness/knowledge/file-index-store.js +11 -11
- package/dist/harness/knowledge/grounding.d.ts +2 -1
- package/dist/harness/knowledge/grounding.js +6 -3
- package/dist/harness/knowledge/index.d.ts +2 -2
- package/dist/harness/knowledge/index.js +1 -1
- package/dist/harness/knowledge/ingest.js +4 -1
- package/dist/harness/knowledge/job-control-state.js +4 -4
- package/dist/harness/knowledge/job-control.js +11 -11
- package/dist/harness/knowledge/membership-store.js +11 -11
- package/dist/harness/knowledge/network-guard.d.ts +61 -4
- package/dist/harness/knowledge/network-guard.js +390 -113
- package/dist/harness/knowledge/query-service.js +3 -3
- package/dist/harness/knowledge/writer-service.d.ts +2 -0
- package/dist/harness/knowledge/writer-service.js +14 -13
- package/dist/harness/memory/backfill-trigger.d.ts +2 -2
- package/dist/harness/memory/backfill-trigger.js +4 -4
- package/dist/harness/memory/index.d.ts +1 -0
- package/dist/harness/memory/index.js +1 -0
- package/dist/harness/memory/sqlite/agent-db.js +2 -0
- package/dist/harness/memory/sqlite/memory-store.d.ts +1 -0
- package/dist/harness/memory/sqlite/memory-store.js +14 -4
- package/dist/harness/memory/sqlite/wisdom-store.js +9 -9
- package/dist/harness/memory/store.d.ts +1 -0
- package/dist/harness/memory/store.js +3 -0
- package/dist/harness/memory/time-format.d.ts +28 -0
- package/dist/harness/memory/time-format.js +52 -0
- package/dist/harness/memory/types.d.ts +12 -0
- package/dist/harness/observability/observer/hub.js +23 -1
- package/dist/harness/observability/observer/index.d.ts +2 -2
- package/dist/harness/observability/observer/index.js +1 -1
- package/dist/harness/observability/observer/types.d.ts +57 -0
- package/dist/harness/observability/observer/types.js +118 -9
- package/dist/harness/run/agent/agent.d.ts +18 -0
- package/dist/harness/run/agent/agent.js +26 -0
- package/dist/harness/run/concurrency/tool-loop-detection-core.d.ts +1 -1
- package/dist/harness/run/concurrency/tool-loop-detection-core.js +1 -1
- package/dist/harness/run/reliability/harness-events.d.ts +4 -0
- package/dist/harness/run/reliability/run-agent.js +110 -18
- package/dist/harness/run/reliability/run-metrics-collector.d.ts +28 -2
- package/dist/harness/run/reliability/run-metrics-collector.js +92 -2
- package/dist/harness/run/run-guard/default-run-guard.d.ts +0 -5
- package/dist/harness/run/run-guard/default-run-guard.js +104 -44
- package/dist/harness/run/run-scope.d.ts +52 -0
- package/dist/harness/run/runner.d.ts +101 -16
- package/dist/harness/run/runner.js +556 -158
- package/dist/harness/session/attachments/llm-intent.js +17 -17
- package/dist/harness/session/history/port.js +1 -0
- package/dist/harness/session/in-memory-store.d.ts +1 -0
- package/dist/harness/session/in-memory-store.js +22 -1
- package/dist/harness/session/schedules/index.d.ts +10 -0
- package/dist/harness/session/schedules/index.js +10 -0
- package/dist/harness/session/schedules/render.d.ts +13 -0
- package/dist/harness/session/schedules/render.js +63 -0
- package/dist/harness/session/schedules/service.d.ts +179 -0
- package/dist/harness/session/schedules/service.js +695 -0
- package/dist/harness/session/schedules/store.d.ts +119 -0
- package/dist/harness/session/schedules/store.js +323 -0
- package/dist/harness/session/schedules/tools.d.ts +39 -0
- package/dist/harness/session/schedules/tools.js +442 -0
- package/dist/harness/session/schedules/types.d.ts +104 -0
- package/dist/harness/session/schedules/types.js +97 -0
- package/dist/harness/session/tasks/tools.js +22 -0
- package/dist/harness/session/types.d.ts +35 -0
- package/dist/harness/shared/events/agent-event-map.d.ts +13 -0
- package/dist/harness/shared/types/agent-definition.d.ts +23 -0
- package/dist/index.d.ts +23 -9
- package/dist/index.js +10 -2
- package/dist/integration/providers/anthropic.d.ts +10 -0
- package/dist/integration/providers/anthropic.js +44 -1
- package/dist/integration/providers/openai.d.ts +10 -0
- package/dist/integration/providers/openai.js +58 -2
- package/dist/integration/providers/wire-dump-diff.d.ts +191 -0
- package/dist/integration/providers/wire-dump-diff.js +351 -0
- package/dist/integration/providers/wire-dump.d.ts +178 -0
- package/dist/integration/providers/wire-dump.js +396 -0
- package/dist/integration/storage/jsonl.d.ts +11 -0
- package/dist/integration/storage/jsonl.js +148 -39
- package/dist/integration/storage/session-index.js +63 -8
- package/dist/subsystems/cognition-steward/conceptualize/SUBSYSTEM.md +43 -43
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +50 -50
- package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +6 -6
- package/dist/subsystems/cognition-steward/consolidate/config.yaml +54 -54
- package/dist/subsystems/memory-steward/backfill/handler.js +9 -0
- package/dist/subsystems/wisdom-steward/evaluate/config.yaml +50 -50
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +42 -42
- package/dist/subsystems/wisdom-steward/formation/config.yaml +54 -54
- package/dist/subsystems/wisdom-steward/govern/config.yaml +55 -55
- package/package.json +115 -115
- package/dist/harness/collaboration/multi-agent/agent-registry-types.d.ts +0 -144
- package/dist/harness/collaboration/multi-agent/agent-registry-types.js +0 -25
- package/dist/harness/collaboration/multi-agent/index.d.ts +0 -17
- package/dist/harness/collaboration/multi-agent/index.js +0 -15
- package/dist/harness/collaboration/multi-agent/process.d.ts +0 -167
- package/dist/harness/collaboration/multi-agent/process.js +0 -256
- package/dist/harness/collaboration/multi-agent/registry.d.ts +0 -36
- package/dist/harness/collaboration/multi-agent/registry.js +0 -137
- package/dist/harness/collaboration/multi-agent/swarm.d.ts +0 -135
- package/dist/harness/collaboration/multi-agent/swarm.js +0 -317
- package/dist/harness/collaboration/multi-agent/types.d.ts +0 -66
- package/dist/harness/collaboration/multi-agent/types.js +0 -15
- package/dist/harness/collaboration/orchestration/async-task-store.d.ts +0 -107
- package/dist/harness/collaboration/orchestration/async-task-store.js +0 -12
- package/dist/harness/collaboration/orchestration/async-task.d.ts +0 -156
- package/dist/harness/collaboration/orchestration/async-task.js +0 -359
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.d.ts +0 -47
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.js +0 -61
- package/dist/harness/collaboration/orchestration/planner/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/planner/index.js +0 -6
- package/dist/harness/collaboration/orchestration/planner/llm-planner.d.ts +0 -54
- package/dist/harness/collaboration/orchestration/planner/llm-planner.js +0 -167
- package/dist/harness/collaboration/orchestration/planner/rule-planner.d.ts +0 -85
- package/dist/harness/collaboration/orchestration/planner/rule-planner.js +0 -175
- package/dist/harness/collaboration/orchestration/quality/classifier.d.ts +0 -21
- package/dist/harness/collaboration/orchestration/quality/classifier.js +0 -235
- package/dist/harness/collaboration/orchestration/quality/gate.d.ts +0 -29
- package/dist/harness/collaboration/orchestration/quality/gate.js +0 -409
- package/dist/harness/collaboration/orchestration/quality/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/quality/index.js +0 -8
- package/dist/harness/collaboration/orchestration/quality/types.d.ts +0 -159
- package/dist/harness/collaboration/orchestration/quality/types.js +0 -33
- package/dist/harness/collaboration/orchestration/scheduler/index.d.ts +0 -5
- package/dist/harness/collaboration/orchestration/scheduler/index.js +0 -4
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.js +0 -297
- package/dist/harness/collaboration/orchestration/strategy/classifier.d.ts +0 -12
- package/dist/harness/collaboration/orchestration/strategy/classifier.js +0 -81
- package/dist/harness/collaboration/orchestration/strategy/index.d.ts +0 -3
- package/dist/harness/collaboration/orchestration/strategy/index.js +0 -2
- package/dist/harness/collaboration/orchestration/strategy/router.d.ts +0 -28
- package/dist/harness/collaboration/orchestration/strategy/router.js +0 -105
- package/dist/harness/collaboration/orchestration/strategy/types.d.ts +0 -49
- package/dist/harness/collaboration/orchestration/strategy/types.js +0 -4
- package/dist/harness/collaboration/orchestration/workflow/engine.d.ts +0 -86
- package/dist/harness/collaboration/orchestration/workflow/engine.js +0 -298
- package/dist/harness/collaboration/orchestration/workflow/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/workflow/index.js +0 -7
- package/dist/harness/collaboration/orchestration/workflow/types.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/workflow/types.js +0 -7
- package/dist/harness/governance/human-in-the-loop/approval-manager.d.ts +0 -32
- package/dist/harness/governance/human-in-the-loop/approval-manager.js +0 -93
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.d.ts +0 -0
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.js +0 -0
|
@@ -28,6 +28,7 @@ export class LocalKnowledgeWriteService {
|
|
|
28
28
|
indexStore: this.index,
|
|
29
29
|
documentConfig: deps.documentConfig ?? null,
|
|
30
30
|
embeddingProvider: embed?.enabled === false ? null : (deps.embeddingProvider ?? null),
|
|
31
|
+
credentials: deps.credentials ?? null,
|
|
31
32
|
...(embed?.embedBatch != null ? { embedBatch: embed.embedBatch } : {}),
|
|
32
33
|
...(embed?.embedMinIntervalMs != null ? { embedMinIntervalMs: embed.embedMinIntervalMs } : {}),
|
|
33
34
|
...(embed?.embedConcurrency != null ? { embedConcurrency: embed.embedConcurrency } : {}),
|
|
@@ -50,19 +51,19 @@ export class LocalKnowledgeWriteService {
|
|
|
50
51
|
async upsertPrincipal(identity, agentId, body) {
|
|
51
52
|
const now = Date.now();
|
|
52
53
|
this.db.raw
|
|
53
|
-
.prepare(`INSERT INTO knowledge_principals
|
|
54
|
-
(tenant_id, gateway_id, local_agent_id, display_name, status, last_seen_at, created_at, updated_at)
|
|
55
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
56
|
-
ON CONFLICT(tenant_id, gateway_id, local_agent_id) DO UPDATE SET
|
|
57
|
-
display_name = COALESCE(excluded.display_name, knowledge_principals.display_name),
|
|
58
|
-
status = excluded.status,
|
|
59
|
-
last_seen_at = excluded.last_seen_at,
|
|
54
|
+
.prepare(`INSERT INTO knowledge_principals
|
|
55
|
+
(tenant_id, gateway_id, local_agent_id, display_name, status, last_seen_at, created_at, updated_at)
|
|
56
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
57
|
+
ON CONFLICT(tenant_id, gateway_id, local_agent_id) DO UPDATE SET
|
|
58
|
+
display_name = COALESCE(excluded.display_name, knowledge_principals.display_name),
|
|
59
|
+
status = excluded.status,
|
|
60
|
+
last_seen_at = excluded.last_seen_at,
|
|
60
61
|
updated_at = excluded.updated_at`)
|
|
61
62
|
.run(identity.tenantId, identity.gatewayId, agentId, body.displayName ?? null, body.status ?? 'active', now, now, now);
|
|
62
63
|
}
|
|
63
64
|
async ensurePrincipal(identity, agentId, autoRegister) {
|
|
64
65
|
const row = this.db.raw
|
|
65
|
-
.prepare(`SELECT status FROM knowledge_principals
|
|
66
|
+
.prepare(`SELECT status FROM knowledge_principals
|
|
66
67
|
WHERE tenant_id = ? AND gateway_id = ? AND local_agent_id = ?`)
|
|
67
68
|
.get(identity.tenantId, identity.gatewayId, agentId);
|
|
68
69
|
if (row)
|
|
@@ -79,7 +80,7 @@ export class LocalKnowledgeWriteService {
|
|
|
79
80
|
// 不得按 gateway 预过滤后再比较——那是永不失败的空检查。
|
|
80
81
|
// 同名 principal 可挂多 gateway(复合 PK);仅当**另一 gateway 已登记**时拒绝。
|
|
81
82
|
const rows = this.db.raw
|
|
82
|
-
.prepare(`SELECT gateway_id FROM knowledge_principals
|
|
83
|
+
.prepare(`SELECT gateway_id FROM knowledge_principals
|
|
83
84
|
WHERE tenant_id = ? AND local_agent_id = ?`)
|
|
84
85
|
.all(identity.tenantId, agentId);
|
|
85
86
|
const foreign = rows.find((r) => r.gateway_id !== identity.gatewayId);
|
|
@@ -89,7 +90,7 @@ export class LocalKnowledgeWriteService {
|
|
|
89
90
|
}
|
|
90
91
|
async createProject(identity, input) {
|
|
91
92
|
const existing = this.db.raw
|
|
92
|
-
.prepare(`SELECT registered_by FROM knowledge_projects
|
|
93
|
+
.prepare(`SELECT registered_by FROM knowledge_projects
|
|
93
94
|
WHERE tenant_id = ? AND project_key = ?`)
|
|
94
95
|
.get(identity.tenantId, input.projectKey);
|
|
95
96
|
if (existing?.registered_by && existing.registered_by !== identity.gatewayId) {
|
|
@@ -103,7 +104,7 @@ export class LocalKnowledgeWriteService {
|
|
|
103
104
|
});
|
|
104
105
|
const visibility = input.visibility === 'public' ? 'public' : 'private';
|
|
105
106
|
this.db.raw
|
|
106
|
-
.prepare(`UPDATE knowledge_projects SET registered_by = ?, visibility = ?
|
|
107
|
+
.prepare(`UPDATE knowledge_projects SET registered_by = ?, visibility = ?
|
|
107
108
|
WHERE tenant_id = ? AND project_key = ?`)
|
|
108
109
|
.run(identity.gatewayId, visibility, identity.tenantId, input.projectKey);
|
|
109
110
|
return {
|
|
@@ -115,7 +116,7 @@ export class LocalKnowledgeWriteService {
|
|
|
115
116
|
}
|
|
116
117
|
async removeProject(identity, projectKey) {
|
|
117
118
|
const row = this.db.raw
|
|
118
|
-
.prepare(`SELECT registered_by FROM knowledge_projects
|
|
119
|
+
.prepare(`SELECT registered_by FROM knowledge_projects
|
|
119
120
|
WHERE tenant_id = ? AND project_key = ?`)
|
|
120
121
|
.get(identity.tenantId, projectKey);
|
|
121
122
|
if (row?.registered_by && row.registered_by !== identity.gatewayId) {
|
|
@@ -142,7 +143,7 @@ export class LocalKnowledgeWriteService {
|
|
|
142
143
|
delete input.tenant_id;
|
|
143
144
|
const src = this.sources.register(input);
|
|
144
145
|
this.db.raw
|
|
145
|
-
.prepare(`UPDATE knowledge_sources SET registered_by = ?, visibility = ?, tenant_id = ?
|
|
146
|
+
.prepare(`UPDATE knowledge_sources SET registered_by = ?, visibility = ?, tenant_id = ?
|
|
146
147
|
WHERE id = ?`)
|
|
147
148
|
.run(identity.gatewayId, typeof input.visibility === 'string' ? input.visibility : 'private', identity.tenantId, src.id);
|
|
148
149
|
void this.ingest.ingestSource(src.id, { full: true }).catch((e) => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* BackfillTrigger — 补录脉搏协调器
|
|
3
3
|
*
|
|
4
4
|
* 时机:
|
|
5
|
-
* - 硬收敛(session → recent /
|
|
5
|
+
* - 硬收敛(session → recent / `/new`)立即评估并 emit
|
|
6
6
|
* - 空闲漂移(默认 20min)软收敛
|
|
7
7
|
* - 覆盖差扫描(默认 6h)兜底
|
|
8
8
|
*
|
|
@@ -60,7 +60,7 @@ export declare class BackfillTrigger {
|
|
|
60
60
|
noteActivity(sessionId: string, agentId?: string, at?: number): void;
|
|
61
61
|
/**
|
|
62
62
|
* 硬收敛:立即评估并 emit(穿透意图是「这段干完了」)
|
|
63
|
-
* 可传入 session
|
|
63
|
+
* 可传入 session 快照;`/new` 后旧会话仍可读,事件快照与 store 并存。
|
|
64
64
|
*/
|
|
65
65
|
requestHardConverge(input: {
|
|
66
66
|
sessionId: string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* BackfillTrigger — 补录脉搏协调器
|
|
3
3
|
*
|
|
4
4
|
* 时机:
|
|
5
|
-
* - 硬收敛(session → recent /
|
|
5
|
+
* - 硬收敛(session → recent / `/new`)立即评估并 emit
|
|
6
6
|
* - 空闲漂移(默认 20min)软收敛
|
|
7
7
|
* - 覆盖差扫描(默认 6h)兜底
|
|
8
8
|
*
|
|
@@ -61,7 +61,7 @@ export class BackfillTrigger {
|
|
|
61
61
|
void this.requestHardConverge({
|
|
62
62
|
sessionId,
|
|
63
63
|
agentId,
|
|
64
|
-
//
|
|
64
|
+
// 事件可带 sessionText 快照;store.messages 不会因 lifecycle 收敛被清空
|
|
65
65
|
sessionText: typeof data.sessionText === 'string' ? data.sessionText : undefined,
|
|
66
66
|
trigger: 'hard_converge',
|
|
67
67
|
});
|
|
@@ -104,7 +104,7 @@ export class BackfillTrigger {
|
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
106
|
* 硬收敛:立即评估并 emit(穿透意图是「这段干完了」)
|
|
107
|
-
* 可传入 session
|
|
107
|
+
* 可传入 session 快照;`/new` 后旧会话仍可读,事件快照与 store 并存。
|
|
108
108
|
*/
|
|
109
109
|
async requestHardConverge(input) {
|
|
110
110
|
return this.evaluateAndEmit({
|
|
@@ -177,7 +177,7 @@ export class BackfillTrigger {
|
|
|
177
177
|
session = undefined;
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
//
|
|
180
|
+
// 事件快照优先;store.messages 仍保留全量 Discourse
|
|
181
181
|
// 此时必须用事件里的 sessionText,不得退回空密度。
|
|
182
182
|
const snapshot = input.sessionText?.trim() ? input.sessionText : undefined;
|
|
183
183
|
const sessionText = snapshot ?? (session ? this.renderSessionText(session) : undefined);
|
|
@@ -43,5 +43,6 @@ export { provisionalConfidence, injectFilter, searchFilter, profileToConfidenceC
|
|
|
43
43
|
export type { ChannelPriors, ConfidenceProfileConfig, MemoryProfileName, ProvisionalInput, ProvisionalResult } from './confidence.js';
|
|
44
44
|
export { evaluateGates, mapLegacyType } from './gates.js';
|
|
45
45
|
export type { GateCandidate, GateConfig, GateOutcome, GateRejectReason } from './gates.js';
|
|
46
|
+
export { formatMemoryClock, formatMemoryTimeSuffix, parseAsOf } from './time-format.js';
|
|
46
47
|
export { admitCandidates, applySoftDeletes, planSoftDeletes, applyBoosts, planBoosts, planPromotionCandidates, resolvePolicy, DEFAULT_SOFT_DELETE_POLICY, MAX_ENTRIES_PER_SOURCE, } from './steward-policy.js';
|
|
47
48
|
export type { SoftDeletePolicyConfig, StewardCandidate, GovernPlanItem, BoostPlanItem, AdmitResult, } from './steward-policy.js';
|
|
@@ -34,5 +34,6 @@ export { BackfillTrigger, BACKFILL_REQUEST_EVENT } from './backfill-trigger.js';
|
|
|
34
34
|
// ── 置信度与门控 ──
|
|
35
35
|
export { provisionalConfidence, injectFilter, searchFilter, profileToConfidenceConfig, hasQuoteEvidence, DEFAULT_CHANNEL_PRIORS, } from './confidence.js';
|
|
36
36
|
export { evaluateGates, mapLegacyType } from './gates.js';
|
|
37
|
+
export { formatMemoryClock, formatMemoryTimeSuffix, parseAsOf } from './time-format.js';
|
|
37
38
|
// ── Steward 共享策略(subsystem 从 @octopi-agent/engine 引用) ──
|
|
38
39
|
export { admitCandidates, applySoftDeletes, planSoftDeletes, applyBoosts, planBoosts, planPromotionCandidates, resolvePolicy, DEFAULT_SOFT_DELETE_POLICY, MAX_ENTRIES_PER_SOURCE, } from './steward-policy.js';
|
|
@@ -83,6 +83,7 @@ export class AgentDatabase {
|
|
|
83
83
|
["anchors", "TEXT NOT NULL DEFAULT '[]'"],
|
|
84
84
|
['evidence', 'TEXT'],
|
|
85
85
|
['reinforced_at', 'INTEGER'],
|
|
86
|
+
['as_of', 'INTEGER'],
|
|
86
87
|
['deleted', 'INTEGER NOT NULL DEFAULT 0'],
|
|
87
88
|
['deleted_at', 'INTEGER'],
|
|
88
89
|
['deleted_by', 'TEXT'],
|
|
@@ -193,6 +194,7 @@ export class AgentDatabase {
|
|
|
193
194
|
anchors TEXT NOT NULL DEFAULT '[]',
|
|
194
195
|
evidence TEXT,
|
|
195
196
|
reinforced_at INTEGER,
|
|
197
|
+
as_of INTEGER,
|
|
196
198
|
deleted INTEGER NOT NULL DEFAULT 0,
|
|
197
199
|
deleted_at INTEGER,
|
|
198
200
|
deleted_by TEXT,
|
|
@@ -79,6 +79,7 @@ export declare class SqliteMemoryStore implements MemoryStore {
|
|
|
79
79
|
winnerId?: string;
|
|
80
80
|
}): Promise<void>;
|
|
81
81
|
undelete(id: string): Promise<void>;
|
|
82
|
+
importEntry(entry: MemoryEntry): Promise<void>;
|
|
82
83
|
listForGovern(filter?: {
|
|
83
84
|
includeDeleted?: boolean;
|
|
84
85
|
}): Promise<MemoryEntry[]>;
|
|
@@ -90,9 +90,9 @@ export class SqliteMemoryStore {
|
|
|
90
90
|
INSERT INTO memories (
|
|
91
91
|
id, type, content, source, confidence, importance,
|
|
92
92
|
access_count, last_accessed_at, created_at, decay_factor, tags, embedding,
|
|
93
|
-
status, channel, future_use, anchors, evidence, deleted
|
|
94
|
-
) VALUES (?, ?, ?, ?, ?, ?, 0, ?, ?, 1.0, ?, ?, ?, ?, ?, ?, ?, 0)
|
|
95
|
-
`).run(id, mapLegacyType(entry.type), entry.content, entry.source, entry.confidence, entry.importance, now, now, JSON.stringify(entry.tags ?? []), embeddingStr, entry.status ?? 'active', entry.channel ?? 'model_inference', entry.futureUse ?? null, JSON.stringify(entry.anchors ?? []), entry.evidence ?? null);
|
|
93
|
+
status, channel, future_use, anchors, evidence, deleted, as_of
|
|
94
|
+
) VALUES (?, ?, ?, ?, ?, ?, 0, ?, ?, 1.0, ?, ?, ?, ?, ?, ?, ?, 0, ?)
|
|
95
|
+
`).run(id, mapLegacyType(entry.type), entry.content, entry.source, entry.confidence, entry.importance, now, now, JSON.stringify(entry.tags ?? []), embeddingStr, entry.status ?? 'active', entry.channel ?? 'model_inference', entry.futureUse ?? null, JSON.stringify(entry.anchors ?? []), entry.evidence ?? null, entry.asOf ?? null);
|
|
96
96
|
if (embeddingStr && this.vecReady) {
|
|
97
97
|
try {
|
|
98
98
|
const vec = parseEmbedding(embeddingStr);
|
|
@@ -207,7 +207,7 @@ export class SqliteMemoryStore {
|
|
|
207
207
|
const vis = this.visibilityWhere(query);
|
|
208
208
|
const cap = this.candidateCap;
|
|
209
209
|
const minSim = query.minSimilarity ?? this.defaultMinSimilarity;
|
|
210
|
-
let sql = `SELECT id, type, content, source, confidence, importance, access_count, last_accessed_at, created_at, decay_factor, tags, embedding, status, channel, future_use, anchors, evidence, deleted, deleted_at, deleted_by, deleted_reason, deleted_meta, reinforced_at
|
|
210
|
+
let sql = `SELECT id, type, content, source, confidence, importance, access_count, last_accessed_at, created_at, decay_factor, tags, embedding, status, channel, future_use, anchors, evidence, deleted, deleted_at, deleted_by, deleted_reason, deleted_meta, reinforced_at, as_of
|
|
211
211
|
FROM memories WHERE embedding IS NOT NULL${vis.sql}`;
|
|
212
212
|
const params = [...vis.params];
|
|
213
213
|
if (query.type) {
|
|
@@ -460,6 +460,8 @@ export class SqliteMemoryStore {
|
|
|
460
460
|
set('evidence', patch.evidence);
|
|
461
461
|
if (patch.reinforcedAt !== undefined)
|
|
462
462
|
set('reinforced_at', patch.reinforcedAt);
|
|
463
|
+
if (patch.asOf !== undefined)
|
|
464
|
+
set('as_of', patch.asOf);
|
|
463
465
|
if (patch.deleted !== undefined)
|
|
464
466
|
set('deleted', patch.deleted ? 1 : 0);
|
|
465
467
|
if (patch.deletedAt !== undefined)
|
|
@@ -524,6 +526,13 @@ export class SqliteMemoryStore {
|
|
|
524
526
|
WHERE id = ?
|
|
525
527
|
`).run(id);
|
|
526
528
|
}
|
|
529
|
+
async importEntry(entry) {
|
|
530
|
+
this.db.raw.prepare(`INSERT OR REPLACE INTO memories (
|
|
531
|
+
id, type, content, source, confidence, importance,
|
|
532
|
+
access_count, last_accessed_at, created_at, decay_factor, tags, embedding,
|
|
533
|
+
status, channel, future_use, anchors, evidence, deleted, as_of
|
|
534
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(entry.id, mapLegacyType(entry.type), entry.content, entry.source, entry.confidence, entry.importance, entry.accessCount ?? 0, entry.lastAccessedAt ?? Date.now(), entry.createdAt ?? Date.now(), entry.decayFactor ?? 1, JSON.stringify(entry.tags ?? []), null, entry.status ?? 'active', entry.channel ?? 'model_inference', entry.futureUse ?? null, JSON.stringify(entry.anchors ?? []), entry.evidence ?? null, entry.deleted ? 1 : 0, entry.asOf ?? null);
|
|
535
|
+
}
|
|
527
536
|
async listForGovern(filter) {
|
|
528
537
|
const sql = filter?.includeDeleted
|
|
529
538
|
? 'SELECT * FROM memories'
|
|
@@ -588,6 +597,7 @@ export class SqliteMemoryStore {
|
|
|
588
597
|
anchors: row.anchors ? JSON.parse(row.anchors) : [],
|
|
589
598
|
evidence: row.evidence ?? undefined,
|
|
590
599
|
reinforcedAt: row.reinforced_at ?? undefined,
|
|
600
|
+
asOf: row.as_of ?? undefined,
|
|
591
601
|
deleted: !!row.deleted,
|
|
592
602
|
deletedAt: row.deleted_at ?? undefined,
|
|
593
603
|
deletedBy: row.deleted_by ?? undefined,
|
|
@@ -45,10 +45,10 @@ export class SqliteWisdomStore {
|
|
|
45
45
|
.run(id, now, prev.id);
|
|
46
46
|
}
|
|
47
47
|
this.db.raw
|
|
48
|
-
.prepare(`INSERT INTO wisdom (
|
|
49
|
-
id, statement, rationale, scenario_json, effect_json, status, confidence, priority,
|
|
50
|
-
derived_from_json, exceptions_json, counterevidence_json, outcomes_json,
|
|
51
|
-
origin, kind, superseded_by, created_at, updated_at
|
|
48
|
+
.prepare(`INSERT INTO wisdom (
|
|
49
|
+
id, statement, rationale, scenario_json, effect_json, status, confidence, priority,
|
|
50
|
+
derived_from_json, exceptions_json, counterevidence_json, outcomes_json,
|
|
51
|
+
origin, kind, superseded_by, created_at, updated_at
|
|
52
52
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
53
53
|
.run(id, input.statement.trim(), input.rationale?.trim() || null, JSON.stringify(input.scenario), JSON.stringify(input.effect), status, clamp01(input.confidence ?? defaultConfidence(status, input.origin ?? 'distilled')), input.priority ?? defaultPriority(status, input.origin ?? 'distilled'), JSON.stringify(input.derivedFrom), JSON.stringify(input.exceptions ?? []), JSON.stringify([]), JSON.stringify(emptyOutcomes()), input.origin ?? 'distilled', input.kind, null, now, now);
|
|
54
54
|
return {
|
|
@@ -93,11 +93,11 @@ export class SqliteWisdomStore {
|
|
|
93
93
|
outcomes: { ...current.outcomes, ...(patch.outcomes ?? {}) },
|
|
94
94
|
};
|
|
95
95
|
this.db.raw
|
|
96
|
-
.prepare(`UPDATE wisdom SET
|
|
97
|
-
statement = ?, rationale = ?, scenario_json = ?, effect_json = ?,
|
|
98
|
-
status = ?, confidence = ?, priority = ?, derived_from_json = ?,
|
|
99
|
-
exceptions_json = ?, counterevidence_json = ?, outcomes_json = ?,
|
|
100
|
-
origin = ?, kind = ?, superseded_by = ?, updated_at = ?
|
|
96
|
+
.prepare(`UPDATE wisdom SET
|
|
97
|
+
statement = ?, rationale = ?, scenario_json = ?, effect_json = ?,
|
|
98
|
+
status = ?, confidence = ?, priority = ?, derived_from_json = ?,
|
|
99
|
+
exceptions_json = ?, counterevidence_json = ?, outcomes_json = ?,
|
|
100
|
+
origin = ?, kind = ?, superseded_by = ?, updated_at = ?
|
|
101
101
|
WHERE id = ?`)
|
|
102
102
|
.run(merged.statement, merged.rationale ?? null, JSON.stringify(merged.scenario), JSON.stringify(merged.effect), merged.status, clamp01(merged.confidence), merged.priority, JSON.stringify(merged.derivedFrom), JSON.stringify(merged.exceptions ?? []), JSON.stringify(merged.counterevidence ?? []), JSON.stringify(merged.outcomes), merged.origin, merged.kind, merged.supersededBy ?? null, merged.updatedAt, id);
|
|
103
103
|
}
|
|
@@ -18,6 +18,7 @@ export declare class InMemoryMemoryStore implements MemoryStore {
|
|
|
18
18
|
winnerId?: string;
|
|
19
19
|
}): Promise<void>;
|
|
20
20
|
undelete(id: string): Promise<void>;
|
|
21
|
+
importEntry(entry: MemoryEntry): Promise<void>;
|
|
21
22
|
listForGovern(filter?: {
|
|
22
23
|
includeDeleted?: boolean;
|
|
23
24
|
}): Promise<MemoryEntry[]>;
|
|
@@ -150,6 +150,9 @@ export class InMemoryMemoryStore {
|
|
|
150
150
|
entry.deletedReason = undefined;
|
|
151
151
|
entry.deletedMeta = undefined;
|
|
152
152
|
}
|
|
153
|
+
async importEntry(entry) {
|
|
154
|
+
this.entries.set(entry.id, { ...entry });
|
|
155
|
+
}
|
|
153
156
|
async listForGovern(filter) {
|
|
154
157
|
return Array.from(this.entries.values()).filter((e) => filter?.includeDeleted || !e.deleted);
|
|
155
158
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 记忆时间戳的 LLM 可读格式 — 与 Runtime `Current datetime` 同为本地墙上时钟
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* 格式化 epoch ms 为 `YYYY-MM-DD HH:mm`(本地时区)
|
|
6
|
+
*
|
|
7
|
+
* @param ms - epoch 毫秒
|
|
8
|
+
* @returns 本地时钟字符串(分钟精度)
|
|
9
|
+
*/
|
|
10
|
+
export declare function formatMemoryClock(ms: number): string;
|
|
11
|
+
/**
|
|
12
|
+
* 解析 memory_store 的 as_of 入参(epoch ms / 数字串 / 可被 Date.parse 的日期串)
|
|
13
|
+
*
|
|
14
|
+
* @param raw - 工具入参
|
|
15
|
+
* @returns epoch ms;缺省返回 undefined
|
|
16
|
+
* @throws 无法解析为时刻时抛出
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseAsOf(raw: unknown): number | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* 召回条目的时间后缀 — 显式标注 recorded / as of
|
|
21
|
+
*
|
|
22
|
+
* @param entry - 含 createdAt 与可选 asOf 的条目
|
|
23
|
+
* @returns 以 ` · ` 开头的时间后缀;createdAt 缺失时返回空串
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatMemoryTimeSuffix(entry: {
|
|
26
|
+
createdAt?: number;
|
|
27
|
+
asOf?: number;
|
|
28
|
+
}): string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 记忆时间戳的 LLM 可读格式 — 与 Runtime `Current datetime` 同为本地墙上时钟
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* 格式化 epoch ms 为 `YYYY-MM-DD HH:mm`(本地时区)
|
|
6
|
+
*
|
|
7
|
+
* @param ms - epoch 毫秒
|
|
8
|
+
* @returns 本地时钟字符串(分钟精度)
|
|
9
|
+
*/
|
|
10
|
+
export function formatMemoryClock(ms) {
|
|
11
|
+
const d = new Date(ms);
|
|
12
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
13
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 解析 memory_store 的 as_of 入参(epoch ms / 数字串 / 可被 Date.parse 的日期串)
|
|
17
|
+
*
|
|
18
|
+
* @param raw - 工具入参
|
|
19
|
+
* @returns epoch ms;缺省返回 undefined
|
|
20
|
+
* @throws 无法解析为时刻时抛出
|
|
21
|
+
*/
|
|
22
|
+
export function parseAsOf(raw) {
|
|
23
|
+
if (raw == null || raw === '')
|
|
24
|
+
return undefined;
|
|
25
|
+
if (typeof raw === 'number' && Number.isFinite(raw))
|
|
26
|
+
return raw;
|
|
27
|
+
const s = String(raw).trim();
|
|
28
|
+
if (!s)
|
|
29
|
+
return undefined;
|
|
30
|
+
if (/^\d+$/.test(s))
|
|
31
|
+
return Number(s);
|
|
32
|
+
const t = Date.parse(s);
|
|
33
|
+
if (!Number.isFinite(t)) {
|
|
34
|
+
throw new Error(`invalid_as_of: ${s} is not a date (use YYYY-MM-DD or epoch ms)`);
|
|
35
|
+
}
|
|
36
|
+
return t;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 召回条目的时间后缀 — 显式标注 recorded / as of
|
|
40
|
+
*
|
|
41
|
+
* @param entry - 含 createdAt 与可选 asOf 的条目
|
|
42
|
+
* @returns 以 ` · ` 开头的时间后缀;createdAt 缺失时返回空串
|
|
43
|
+
*/
|
|
44
|
+
export function formatMemoryTimeSuffix(entry) {
|
|
45
|
+
if (entry.createdAt == null)
|
|
46
|
+
return '';
|
|
47
|
+
const recorded = formatMemoryClock(entry.createdAt);
|
|
48
|
+
if (entry.asOf != null) {
|
|
49
|
+
return ` · as of ${formatMemoryClock(entry.asOf)} · recorded ${recorded}`;
|
|
50
|
+
}
|
|
51
|
+
return ` · recorded ${recorded}`;
|
|
52
|
+
}
|
|
@@ -44,6 +44,11 @@ export interface MemoryEntry {
|
|
|
44
44
|
evidence?: string;
|
|
45
45
|
/** 最近强化时间 */
|
|
46
46
|
reinforcedAt?: number;
|
|
47
|
+
/**
|
|
48
|
+
* 命题成立时刻(as-of)— 与 createdAt(入库时刻)区分。
|
|
49
|
+
* 时效敏感 fact 用:「3 月时版本是 1.2」≠「3 月写入了当前版本是 1.2」。
|
|
50
|
+
*/
|
|
51
|
+
asOf?: number;
|
|
47
52
|
/** 软删除 */
|
|
48
53
|
deleted?: boolean;
|
|
49
54
|
deletedAt?: number;
|
|
@@ -101,6 +106,11 @@ export interface MemoryStore {
|
|
|
101
106
|
winnerId?: string;
|
|
102
107
|
}): Promise<void>;
|
|
103
108
|
undelete(id: string): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* 按原 id 恢复整行(L3 undo / 硬删除逆放)。
|
|
111
|
+
* 与 store() 不同:不重新生成 id。
|
|
112
|
+
*/
|
|
113
|
+
importEntry(entry: MemoryEntry): Promise<void>;
|
|
104
114
|
/** 治理批量读取 */
|
|
105
115
|
listForGovern(filter?: {
|
|
106
116
|
includeDeleted?: boolean;
|
|
@@ -487,6 +497,8 @@ export interface MemoryWriteSlot {
|
|
|
487
497
|
channel: MemoryChannel;
|
|
488
498
|
importance?: number;
|
|
489
499
|
tags?: string[];
|
|
500
|
+
/** 命题成立时刻(epoch ms);时效敏感 fact 建议写入 */
|
|
501
|
+
asOf?: number;
|
|
490
502
|
}
|
|
491
503
|
/** 门控/置信度可调用的 store 入参 */
|
|
492
504
|
export type MemoryStoreInput = Omit<MemoryEntry, 'id' | 'accessCount' | 'lastAccessedAt' | 'createdAt' | 'decayFactor'>;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 为 Web/测试提供「当前/最近 Run」可检视现场。
|
|
6
6
|
* 观测失败 fail-open,不打断业务路径。
|
|
7
7
|
*/
|
|
8
|
-
import { resolveObserverConfig, buildRunMessagesDiff, summarizeLlmMessages, } from './types.js';
|
|
8
|
+
import { resolveObserverConfig, attributeRunMessage, buildRunMessagesDiff, summarizeLlmMessages, } from './types.js';
|
|
9
9
|
import { buildRunMessagesSnapshot, buildRunScopeView } from './run-snapshot.js';
|
|
10
10
|
import { buildContextLayersSnapshot } from '../../context/layer-snapshot.js';
|
|
11
11
|
const SECURITY_EVENT_TYPES = new Set([
|
|
@@ -271,6 +271,11 @@ export class ObserverHub {
|
|
|
271
271
|
return {
|
|
272
272
|
index,
|
|
273
273
|
role: (m.role || 'unknown'),
|
|
274
|
+
// 归因与 summary.byKind 同源(attributeRunMessage),LLM 视图条目与汇总口径一致
|
|
275
|
+
attribution: attributeRunMessage({
|
|
276
|
+
role: m.role,
|
|
277
|
+
content: (m.content ?? ''),
|
|
278
|
+
}),
|
|
274
279
|
content: text,
|
|
275
280
|
contentChars: text.length,
|
|
276
281
|
contentPreview: text.slice(0, 200),
|
|
@@ -378,6 +383,18 @@ export class ObserverHub {
|
|
|
378
383
|
record.updatedAt = Date.now();
|
|
379
384
|
// 继续落入 timeline(若启用)
|
|
380
385
|
}
|
|
386
|
+
if (event.type === 'tool.effect.ledger') {
|
|
387
|
+
const d = (event.data ?? {});
|
|
388
|
+
const nr = d.notReversed;
|
|
389
|
+
record.toolEffect.undo = {
|
|
390
|
+
entries: Number(d.entries ?? 0),
|
|
391
|
+
truncated: d.truncated === true,
|
|
392
|
+
notReversedReason: nr?.reason,
|
|
393
|
+
notReversedPaths: (nr?.created?.length ?? 0) + (nr?.modified?.length ?? 0) + (nr?.deleted?.length ?? 0),
|
|
394
|
+
};
|
|
395
|
+
record.updatedAt = Date.now();
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
381
398
|
// memory / tool.effect:从 tool.exec.end 投影
|
|
382
399
|
if (event.type === 'tool.exec.end' &&
|
|
383
400
|
(this.config.channels.memory || this.config.channels['tool.effect'])) {
|
|
@@ -604,6 +621,7 @@ export class ObserverHub {
|
|
|
604
621
|
elapsedMs: record.guardMetrics?.elapsedMs ?? 0,
|
|
605
622
|
consecutiveErrors: record.guardMetrics?.consecutiveErrors ?? 0,
|
|
606
623
|
consecutiveSameTool: record.guardMetrics?.consecutiveSameTool ?? 0,
|
|
624
|
+
consecutiveIdenticalFailures: record.guardMetrics?.consecutiveIdenticalFailures ?? 0,
|
|
607
625
|
noopStreak: record.guardMetrics?.noopStreak ?? 0,
|
|
608
626
|
hasProgress: record.guardMetrics?.hasProgress ?? true,
|
|
609
627
|
uniqueTools: record.guardMetrics?.uniqueTools ?? [],
|
|
@@ -624,6 +642,7 @@ export class ObserverHub {
|
|
|
624
642
|
elapsedMs: record.lifecycle.durationMs ?? 0,
|
|
625
643
|
consecutiveErrors: record.guardMetrics?.consecutiveErrors ?? 0,
|
|
626
644
|
consecutiveSameTool: record.guardMetrics?.consecutiveSameTool ?? 0,
|
|
645
|
+
consecutiveIdenticalFailures: record.guardMetrics?.consecutiveIdenticalFailures ?? 0,
|
|
627
646
|
noopStreak: record.guardMetrics?.noopStreak ?? 0,
|
|
628
647
|
hasProgress: record.guardMetrics?.hasProgress ?? true,
|
|
629
648
|
uniqueTools: record.guardMetrics?.uniqueTools ?? [],
|
|
@@ -642,6 +661,7 @@ export class ObserverHub {
|
|
|
642
661
|
elapsedMs: record.guardMetrics?.elapsedMs ?? 0,
|
|
643
662
|
consecutiveErrors: record.guardMetrics?.consecutiveErrors ?? 0,
|
|
644
663
|
consecutiveSameTool: record.guardMetrics?.consecutiveSameTool ?? 0,
|
|
664
|
+
consecutiveIdenticalFailures: record.guardMetrics?.consecutiveIdenticalFailures ?? 0,
|
|
645
665
|
noopStreak: record.guardMetrics?.noopStreak ?? 0,
|
|
646
666
|
hasProgress: record.guardMetrics?.hasProgress ?? false,
|
|
647
667
|
uniqueTools: record.guardMetrics?.uniqueTools ?? [],
|
|
@@ -660,6 +680,7 @@ export class ObserverHub {
|
|
|
660
680
|
elapsedMs: record.guardMetrics?.elapsedMs ?? 0,
|
|
661
681
|
consecutiveErrors: record.guardMetrics?.consecutiveErrors ?? 0,
|
|
662
682
|
consecutiveSameTool: record.guardMetrics?.consecutiveSameTool ?? 0,
|
|
683
|
+
consecutiveIdenticalFailures: record.guardMetrics?.consecutiveIdenticalFailures ?? 0,
|
|
663
684
|
noopStreak: record.guardMetrics?.noopStreak ?? 0,
|
|
664
685
|
hasProgress: record.guardMetrics?.hasProgress ?? true,
|
|
665
686
|
uniqueTools: record.guardMetrics?.uniqueTools ?? [],
|
|
@@ -786,6 +807,7 @@ export class ObserverHub {
|
|
|
786
807
|
? {
|
|
787
808
|
...record.toolEffect,
|
|
788
809
|
tools: record.toolEffect.tools.map((t) => ({ ...t })),
|
|
810
|
+
undo: record.toolEffect.undo ? { ...record.toolEffect.undo } : undefined,
|
|
789
811
|
notes: record.toolEffect.notes ? [...record.toolEffect.notes] : undefined,
|
|
790
812
|
}
|
|
791
813
|
: undefined,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { DEFAULT_OBSERVER_CONFIG, resolveObserverConfig, isChannelEnabled, shouldCaptureMessageFullText, summarizeMessages, summarizeLlmMessages, buildRunMessagesDiff, isHiddenFromChat, attachFullContent, cloneMessages, } from './types.js';
|
|
2
|
-
export type { ObserverChannelId, ObserverConfig, ObserverLevel, ResolvedObserverConfig, RunGuardMetricsView, RunLifecycleView, RunMemoryActivityView, RunMessageView, RunMessagesDiff, RunMessagesPhase, RunMessagesSnapshot, RunMessagesSummary, RunMessagesView, RunObservatorySnapshot, RunScopeView, RunSecurityEventView, RunTimelineEventView, RunToolEffectView, RunToolRuntimeView, } from './types.js';
|
|
1
|
+
export { DEFAULT_OBSERVER_CONFIG, resolveObserverConfig, isChannelEnabled, shouldCaptureMessageFullText, summarizeMessages, summarizeLlmMessages, attributeRunMessage, buildRunMessagesDiff, isHiddenFromChat, attachFullContent, cloneMessages, } from './types.js';
|
|
2
|
+
export type { ObserverChannelId, ObserverConfig, ObserverLevel, ResolvedObserverConfig, RunGuardMetricsView, RunLifecycleView, RunMemoryActivityView, RunMessageAttribution, RunMessageView, RunMessagesDiff, RunMessagesPhase, RunMessagesSnapshot, RunMessagesSummary, RunMessagesView, RunObservatorySnapshot, RunScopeView, RunSecurityEventView, RunTimelineEventView, RunToolEffectView, RunToolRuntimeView, } from './types.js';
|
|
3
3
|
export { buildRunScopeView, buildRunMessagesSnapshot } from './run-snapshot.js';
|
|
4
4
|
export { ObserverHub } from './hub.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { DEFAULT_OBSERVER_CONFIG, resolveObserverConfig, isChannelEnabled, shouldCaptureMessageFullText, summarizeMessages, summarizeLlmMessages, buildRunMessagesDiff, isHiddenFromChat, attachFullContent, cloneMessages, } from './types.js';
|
|
1
|
+
export { DEFAULT_OBSERVER_CONFIG, resolveObserverConfig, isChannelEnabled, shouldCaptureMessageFullText, summarizeMessages, summarizeLlmMessages, attributeRunMessage, buildRunMessagesDiff, isHiddenFromChat, attachFullContent, cloneMessages, } from './types.js';
|
|
2
2
|
export { buildRunScopeView, buildRunMessagesSnapshot } from './run-snapshot.js';
|
|
3
3
|
export { ObserverHub } from './hub.js';
|
|
@@ -108,6 +108,32 @@ export declare function isChannelEnabled(cfg: ResolvedObserverConfig, channel: O
|
|
|
108
108
|
*/
|
|
109
109
|
export declare function shouldCaptureMessageFullText(cfg: ResolvedObserverConfig): boolean;
|
|
110
110
|
export type RunMessageViewRole = 'user' | 'assistant' | 'system' | 'tool';
|
|
111
|
+
/**
|
|
112
|
+
* Run message 归因(G2/G4):区分用户真实发言与引擎载体机器插槽。
|
|
113
|
+
*
|
|
114
|
+
* 机器插槽(turn 信封槽位 / 载体消息 / 摘要 / 引擎提示 / turn 闭标)**不是用户发言**——
|
|
115
|
+
* 本字段是检查器归因的唯一真源,UI 只渲染不自行判定。
|
|
116
|
+
*/
|
|
117
|
+
export interface RunMessageAttribution {
|
|
118
|
+
/** 发言方:human=用户真实发言(含 turn 信封内的用户原文);engine=机器生成;llm=模型输出;tool=工具结果 */
|
|
119
|
+
speaker: 'human' | 'engine' | 'llm' | 'tool';
|
|
120
|
+
/** 细类 */
|
|
121
|
+
kind: 'user_speech' | 'turn_envelope' | 'carrier' | 'context_summary' | 'engine_hint' | 'turn_end' | 'hosted_system' | 'system' | 'assistant' | 'tool';
|
|
122
|
+
/** 信封/闭标的 turn id(可解析出时) */
|
|
123
|
+
turnId?: string;
|
|
124
|
+
/** `metadata.source` 原值(carrier / summary / hint 等溯源) */
|
|
125
|
+
source?: string;
|
|
126
|
+
/** turn_envelope 内嵌槽位(机器生成块);摘要视图只带 chars,正文由 attachFullContent 补 */
|
|
127
|
+
slots?: Array<{
|
|
128
|
+
tag: string;
|
|
129
|
+
chars: number;
|
|
130
|
+
body?: string;
|
|
131
|
+
}>;
|
|
132
|
+
/** turn_envelope 中真实用户正文字符数(无 user_message 块 = 0) */
|
|
133
|
+
userChars?: number;
|
|
134
|
+
/** turn_envelope 是否含 `<user_message>` 块(false = 信封不完整,UI 应标注而非把整封当用户原文) */
|
|
135
|
+
hasUserMessage?: boolean;
|
|
136
|
+
}
|
|
111
137
|
/** 单条 Run message 的 UI 视图 */
|
|
112
138
|
export interface RunMessageView {
|
|
113
139
|
index: number;
|
|
@@ -120,6 +146,8 @@ export interface RunMessageView {
|
|
|
120
146
|
metadata?: Record<string, unknown>;
|
|
121
147
|
/** 中栏对话是否会隐藏本条 */
|
|
122
148
|
hiddenFromChat?: boolean;
|
|
149
|
+
/** 归因(机器插槽 vs 用户发言;见 RunMessageAttribution) */
|
|
150
|
+
attribution?: RunMessageAttribution;
|
|
123
151
|
contentChars?: number;
|
|
124
152
|
/** 摘要模式下的截断预览 */
|
|
125
153
|
contentPreview?: string;
|
|
@@ -129,6 +157,8 @@ export type RunMessagesView = 'workspace' | 'llm';
|
|
|
129
157
|
export interface RunMessagesSummary {
|
|
130
158
|
count: number;
|
|
131
159
|
byRole: Record<string, number>;
|
|
160
|
+
/** 按归因 kind 计数(RunMessageAttribution.kind)——机器插槽与用户发言在汇总层即分开 */
|
|
161
|
+
byKind: Record<string, number>;
|
|
132
162
|
systemPromptCount: number;
|
|
133
163
|
contextSummaryCount: number;
|
|
134
164
|
hiddenFromChatCount: number;
|
|
@@ -145,7 +175,11 @@ export interface RunGuardMetricsView {
|
|
|
145
175
|
nominalTotalTokens: number;
|
|
146
176
|
elapsedMs: number;
|
|
147
177
|
consecutiveErrors: number;
|
|
178
|
+
/** 连续同一错误(名+参数+错误内容一致)——「卡住」的强信号 */
|
|
179
|
+
consecutiveIdenticalFailures?: number;
|
|
148
180
|
consecutiveSameTool: number;
|
|
181
|
+
/** 连续相同调用(名+参数+结果一致)——无进展循环的强信号 */
|
|
182
|
+
consecutiveIdenticalCalls?: number;
|
|
149
183
|
noopStreak: number;
|
|
150
184
|
hasProgress: boolean;
|
|
151
185
|
uniqueTools: string[];
|
|
@@ -288,6 +322,13 @@ export interface RunToolEffectView {
|
|
|
288
322
|
errors: number;
|
|
289
323
|
lastDurationMs?: number;
|
|
290
324
|
}>;
|
|
325
|
+
/** L3 效应账本(§5.6) */
|
|
326
|
+
undo?: {
|
|
327
|
+
entries: number;
|
|
328
|
+
truncated?: boolean;
|
|
329
|
+
notReversedReason?: string;
|
|
330
|
+
notReversedPaths?: number;
|
|
331
|
+
};
|
|
291
332
|
notes?: string[];
|
|
292
333
|
}
|
|
293
334
|
/** 单次 Run 的观测投影(WS/REST 摘要;全文经 messages REST) */
|
|
@@ -319,6 +360,22 @@ export interface RunObservatorySnapshot {
|
|
|
319
360
|
webPanel: boolean;
|
|
320
361
|
};
|
|
321
362
|
}
|
|
363
|
+
/**
|
|
364
|
+
* Run message 归因(G2/G4 唯一判定处)。
|
|
365
|
+
*
|
|
366
|
+
* 判定次序:**source 优先、内容兜底**——
|
|
367
|
+
* ① role 二值(assistant/tool)→ ② 引擎载体 source(turnEnd / 载体插槽 / contextSummary / engineHint,
|
|
368
|
+
* 语义真源 `harness/context/layer-types.ts` ENGINE_CARRIER_SOURCES)→ ③ system role →
|
|
369
|
+
* ④ 无 source + user role + 正文以信封开标签起头 = turn_envelope → ⑤ 其余 user_speech。
|
|
370
|
+
*
|
|
371
|
+
* source 优先是审计面的可靠性要求:载体消息正文来自不可信语料(知识/grounding/附件),
|
|
372
|
+
* 含信封字面量也不得被内容嗅探抢走归因(否则机器插槽挂上「用户发言」徽章)。
|
|
373
|
+
* turn_end 的内容兜底仅作 legacy 降级:无 source 且整条正文就是闭标形状才认。
|
|
374
|
+
*
|
|
375
|
+
* @param msg - 消息(role/content/metadata)
|
|
376
|
+
* @returns 归因
|
|
377
|
+
*/
|
|
378
|
+
export declare function attributeRunMessage(msg: Pick<Message, 'role' | 'content' | 'metadata'>): RunMessageAttribution;
|
|
322
379
|
/** message 摘要统计 */
|
|
323
380
|
export declare function summarizeMessages(messages: Message[], opts?: {
|
|
324
381
|
maxPreviewChars?: number;
|