@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
|
@@ -48,10 +48,10 @@ export interface MetricsSnapshot {
|
|
|
48
48
|
toolErrors: Record<string, number>;
|
|
49
49
|
/** 活跃 session 数 */
|
|
50
50
|
sessionsActive: number;
|
|
51
|
-
/** 总
|
|
52
|
-
|
|
53
|
-
/** 以失败告终的
|
|
54
|
-
|
|
51
|
+
/** 总 step 数 */
|
|
52
|
+
stepsTotal: number;
|
|
53
|
+
/** 以失败告终的 step 数(step.end 带 error;含重试中失败尝试,失败不再是指标盲区) */
|
|
54
|
+
failedSteps: number;
|
|
55
55
|
/** 空回复数 */
|
|
56
56
|
emptyResponses: number;
|
|
57
57
|
/** 重试次数 */
|
|
@@ -85,8 +85,8 @@ export declare class MetricsAggregator {
|
|
|
85
85
|
private _toolLatency;
|
|
86
86
|
private _toolErrors;
|
|
87
87
|
private _sessionsActive;
|
|
88
|
-
private
|
|
89
|
-
private
|
|
88
|
+
private _stepsTotal;
|
|
89
|
+
private _failedSteps;
|
|
90
90
|
private _emptyResponses;
|
|
91
91
|
private _retriesTotal;
|
|
92
92
|
private _snapshots;
|
|
@@ -62,8 +62,8 @@ export class MetricsAggregator {
|
|
|
62
62
|
_toolErrors = new Map();
|
|
63
63
|
// Session 指标
|
|
64
64
|
_sessionsActive = new Set();
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
_stepsTotal = 0;
|
|
66
|
+
_failedSteps = 0;
|
|
67
67
|
_emptyResponses = 0;
|
|
68
68
|
_retriesTotal = 0;
|
|
69
69
|
// 快照历史
|
|
@@ -123,20 +123,20 @@ export class MetricsAggregator {
|
|
|
123
123
|
}
|
|
124
124
|
break;
|
|
125
125
|
}
|
|
126
|
-
// ──
|
|
127
|
-
// 只计完整结束的 turn:重试中失败尝试的
|
|
128
|
-
// 否则
|
|
126
|
+
// ── Step ──
|
|
127
|
+
// 只计完整结束的 turn:重试中失败尝试的 step_end(error) 不是用户语义上的轮次,
|
|
128
|
+
// 否则 stepsTotal 会把失败尝试计成 step、与 llmCalls 倒挂;失败调用的空输出
|
|
129
129
|
// 也不是「空响应」。
|
|
130
|
-
case '
|
|
130
|
+
case 'step.end': {
|
|
131
131
|
const failed = Boolean(event.data?.error);
|
|
132
132
|
if (!failed) {
|
|
133
|
-
this.
|
|
133
|
+
this._stepsTotal++;
|
|
134
134
|
if (!event.data?.content || event.data.content.length === 0) {
|
|
135
135
|
this._emptyResponses++;
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
else {
|
|
139
|
-
this.
|
|
139
|
+
this._failedSteps++;
|
|
140
140
|
}
|
|
141
141
|
break;
|
|
142
142
|
}
|
|
@@ -170,8 +170,8 @@ export class MetricsAggregator {
|
|
|
170
170
|
toolLatency: Object.fromEntries([...this._toolLatency.entries()].map(([k, v]) => [k, v.getStats()])),
|
|
171
171
|
toolErrors: Object.fromEntries(this._toolErrors),
|
|
172
172
|
sessionsActive: this._sessionsActive.size,
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
stepsTotal: this._stepsTotal,
|
|
174
|
+
failedSteps: this._failedSteps,
|
|
175
175
|
emptyResponses: this._emptyResponses,
|
|
176
176
|
retriesTotal: this._retriesTotal,
|
|
177
177
|
estimatedCostUsd: Math.round(estimatedCostUsd * 10000) / 10000,
|
|
@@ -197,8 +197,8 @@ export class MetricsAggregator {
|
|
|
197
197
|
this._toolLatency.clear();
|
|
198
198
|
this._toolErrors.clear();
|
|
199
199
|
this._sessionsActive.clear();
|
|
200
|
-
this.
|
|
201
|
-
this.
|
|
200
|
+
this._stepsTotal = 0;
|
|
201
|
+
this._failedSteps = 0;
|
|
202
202
|
this._emptyResponses = 0;
|
|
203
203
|
this._retriesTotal = 0;
|
|
204
204
|
this._snapshots = [];
|
|
@@ -222,7 +222,7 @@ export function formatMetricsSnapshot(snap) {
|
|
|
222
222
|
lines.push(`${'─'.repeat(50)}`);
|
|
223
223
|
lines.push(`Uptime: ${(snap.uptimeMs / 1000).toFixed(0)}s`);
|
|
224
224
|
lines.push(`Sessions: ${snap.sessionsActive} active`);
|
|
225
|
-
lines.push(`
|
|
225
|
+
lines.push(`Steps: ${snap.stepsTotal} (${snap.failedSteps} failed)`);
|
|
226
226
|
lines.push(`Empty replies: ${snap.emptyResponses}`);
|
|
227
227
|
lines.push(`Retries: ${snap.retriesTotal}`);
|
|
228
228
|
lines.push('');
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { TraceLogger } from './trace-logger.js';
|
|
14
14
|
import { MetricsAggregator } from './metrics.js';
|
|
15
15
|
import { TraceLevel, TRACE_EVENTS } from './trace-events.js';
|
|
16
|
-
import { makeTokenUsage } from '@octopi-agent/core/types/
|
|
16
|
+
import { makeTokenUsage } from '@octopi-agent/core/types/step.js';
|
|
17
17
|
// ── Span 实现 ──
|
|
18
18
|
class BridgeSpan {
|
|
19
19
|
id;
|
|
@@ -176,7 +176,7 @@ export class ObserverBridge {
|
|
|
176
176
|
return { ts: Date.now(), level: TraceLevel.INFO, type: TRACE_EVENTS.MODEL_CALL_START, data: attributes };
|
|
177
177
|
case 'agent.tool.exec':
|
|
178
178
|
return { ts: Date.now(), level: TraceLevel.INFO, type: TRACE_EVENTS.TOOL_EXEC_START, data: attributes };
|
|
179
|
-
case 'agent.
|
|
179
|
+
case 'agent.step':
|
|
180
180
|
// 迭代开始,MetricsAggregator 不直接处理这个
|
|
181
181
|
return null;
|
|
182
182
|
default:
|
|
@@ -30,8 +30,8 @@ export declare class TraceCollector {
|
|
|
30
30
|
private logger;
|
|
31
31
|
private metrics;
|
|
32
32
|
private config;
|
|
33
|
-
private
|
|
34
|
-
private
|
|
33
|
+
private stepCount;
|
|
34
|
+
private currentStepId?;
|
|
35
35
|
constructor(config?: TraceCollectorConfig);
|
|
36
36
|
/**
|
|
37
37
|
* 包装引擎事件流,自动记录 trace
|
|
@@ -55,12 +55,12 @@ export declare class TraceCollector {
|
|
|
55
55
|
*
|
|
56
56
|
* @param event - AgentEvent
|
|
57
57
|
* @param ctx - 会话上下文
|
|
58
|
-
* @param
|
|
58
|
+
* @param stepId - 轮次 id(可选)
|
|
59
59
|
*/
|
|
60
60
|
record(event: AgentEvent, ctx?: {
|
|
61
61
|
sessionId?: string;
|
|
62
62
|
agentId?: string;
|
|
63
|
-
},
|
|
63
|
+
}, stepId?: string): void;
|
|
64
64
|
/**
|
|
65
65
|
* 记录单个事件
|
|
66
66
|
*/
|
|
@@ -82,7 +82,7 @@ export declare class TraceCollector {
|
|
|
82
82
|
recordSessionState(ctx: {
|
|
83
83
|
sessionId: string;
|
|
84
84
|
messageCount: number;
|
|
85
|
-
|
|
85
|
+
stepCount: number;
|
|
86
86
|
sessionSize?: string;
|
|
87
87
|
agentId?: string;
|
|
88
88
|
}): void;
|
|
@@ -14,8 +14,8 @@ export class TraceCollector {
|
|
|
14
14
|
logger;
|
|
15
15
|
metrics;
|
|
16
16
|
config;
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
stepCount = 0;
|
|
18
|
+
currentStepId;
|
|
19
19
|
constructor(config) {
|
|
20
20
|
this.config = {
|
|
21
21
|
captureStreamDeltas: false,
|
|
@@ -43,22 +43,22 @@ export class TraceCollector {
|
|
|
43
43
|
* @yields 原始事件(不修改)
|
|
44
44
|
*/
|
|
45
45
|
async *wrap(events, ctx = {}) {
|
|
46
|
-
const
|
|
47
|
-
this.
|
|
48
|
-
this.logger.info(TRACE_EVENTS.
|
|
49
|
-
let
|
|
46
|
+
const stepId = `step_${++this.stepCount}`;
|
|
47
|
+
this.currentStepId = stepId;
|
|
48
|
+
this.logger.info(TRACE_EVENTS.STEP_START, { stepId }, ctx);
|
|
49
|
+
let sawStepEnd = false;
|
|
50
50
|
for await (const event of events) {
|
|
51
|
-
if (event.type === '
|
|
52
|
-
|
|
51
|
+
if (event.type === 'step.end')
|
|
52
|
+
sawStepEnd = true;
|
|
53
53
|
// 记录到 trace
|
|
54
|
-
this.recordEvent(event, ctx,
|
|
54
|
+
this.recordEvent(event, ctx, stepId);
|
|
55
55
|
// 原样传递
|
|
56
56
|
yield event;
|
|
57
57
|
}
|
|
58
|
-
// 收口行仅在事件流自身无
|
|
59
|
-
// 再补一行即双计(
|
|
60
|
-
if (!
|
|
61
|
-
this.logger.info(TRACE_EVENTS.
|
|
58
|
+
// 收口行仅在事件流自身无 step.end 时补——recordEvent 已把 step.end 映射为 STEP_END,
|
|
59
|
+
// 再补一行即双计(step 统计翻倍)
|
|
60
|
+
if (!sawStepEnd) {
|
|
61
|
+
this.logger.info(TRACE_EVENTS.STEP_END, { stepId }, ctx);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
@@ -74,17 +74,17 @@ export class TraceCollector {
|
|
|
74
74
|
*
|
|
75
75
|
* @param event - AgentEvent
|
|
76
76
|
* @param ctx - 会话上下文
|
|
77
|
-
* @param
|
|
77
|
+
* @param stepId - 轮次 id(可选)
|
|
78
78
|
*/
|
|
79
|
-
record(event, ctx = {},
|
|
80
|
-
if (!this.
|
|
81
|
-
this.
|
|
82
|
-
this.recordEvent(event, ctx,
|
|
79
|
+
record(event, ctx = {}, stepId = `step_${++this.stepCount}`) {
|
|
80
|
+
if (!this.currentStepId)
|
|
81
|
+
this.currentStepId = stepId;
|
|
82
|
+
this.recordEvent(event, ctx, stepId);
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* 记录单个事件
|
|
86
86
|
*/
|
|
87
|
-
recordEvent(event, ctx,
|
|
87
|
+
recordEvent(event, ctx, stepId) {
|
|
88
88
|
const base = {
|
|
89
89
|
sessionId: event.sessionId ?? ctx.sessionId,
|
|
90
90
|
agentId: event.agentId ?? ctx.agentId,
|
|
@@ -94,19 +94,18 @@ export class TraceCollector {
|
|
|
94
94
|
case 'engine.start':
|
|
95
95
|
this.logger.info(TRACE_EVENTS.ENGINE_START, event.data, base);
|
|
96
96
|
break;
|
|
97
|
-
//
|
|
98
|
-
case '
|
|
99
|
-
|
|
100
|
-
this.logger.info(TRACE_EVENTS.TURN_START, { turnId }, base);
|
|
97
|
+
// step.start = 模型轮开始
|
|
98
|
+
case 'step.start':
|
|
99
|
+
this.logger.info(TRACE_EVENTS.STEP_START, { stepId }, base);
|
|
101
100
|
break;
|
|
102
|
-
// Runner 词表:
|
|
101
|
+
// Runner 词表:step.end 携带 usage。F3-c 起不再冒充 model.call.end
|
|
103
102
|
//(LoopObserver 的 model.call.end 才带 durationMs/ttft;两行各归各位,p50/p95 取数不双计。
|
|
104
|
-
// F3-d 起
|
|
105
|
-
case '
|
|
106
|
-
this.logger.info(TRACE_EVENTS.
|
|
103
|
+
// F3-d 起 step.end 事件还带 llmTiming 供 UI timeline 展示,本白名单仍不落盘——trace 指标只认 model.call.*)
|
|
104
|
+
case 'step.end':
|
|
105
|
+
this.logger.info(TRACE_EVENTS.STEP_END, {
|
|
107
106
|
contentLength: event.data?.content?.length ?? 0,
|
|
108
107
|
usage: event.data?.usage,
|
|
109
|
-
|
|
108
|
+
stepId,
|
|
110
109
|
}, base);
|
|
111
110
|
break;
|
|
112
111
|
case 'model.call.start':
|
|
@@ -115,7 +114,7 @@ export class TraceCollector {
|
|
|
115
114
|
callId: event.data?.callId,
|
|
116
115
|
reqChars: event.data?.reqChars,
|
|
117
116
|
toolChars: event.data?.toolChars,
|
|
118
|
-
|
|
117
|
+
stepId,
|
|
119
118
|
}, base);
|
|
120
119
|
break;
|
|
121
120
|
case 'model.call.end':
|
|
@@ -130,7 +129,7 @@ export class TraceCollector {
|
|
|
130
129
|
contentLength: event.data?.content?.length ?? 0,
|
|
131
130
|
toolCallCount: event.data?.toolCallCount ?? 0,
|
|
132
131
|
usage: event.data?.usage,
|
|
133
|
-
|
|
132
|
+
stepId,
|
|
134
133
|
}, base);
|
|
135
134
|
break;
|
|
136
135
|
// Runner 收口计时(wait/build/run_end;`[timing]` 探针转正,F3)
|
|
@@ -140,7 +139,7 @@ export class TraceCollector {
|
|
|
140
139
|
case 'model.call.error':
|
|
141
140
|
this.logger.error(TRACE_EVENTS.MODEL_CALL_ERROR, {
|
|
142
141
|
error: event.data?.error,
|
|
143
|
-
|
|
142
|
+
stepId,
|
|
144
143
|
}, base);
|
|
145
144
|
break;
|
|
146
145
|
// ── 工具执行 ──
|
|
@@ -148,14 +147,14 @@ export class TraceCollector {
|
|
|
148
147
|
this.logger.info(TRACE_EVENTS.TOOL_EXEC_START, {
|
|
149
148
|
toolName: event.data?.toolName,
|
|
150
149
|
toolCallId: event.data?.toolCallId,
|
|
151
|
-
|
|
150
|
+
stepId,
|
|
152
151
|
}, base);
|
|
153
152
|
break;
|
|
154
153
|
case 'tool.exec.end':
|
|
155
154
|
this.logger.info(TRACE_EVENTS.TOOL_EXEC_END, {
|
|
156
155
|
toolName: event.data?.toolName,
|
|
157
156
|
hasError: event.data?.hasError,
|
|
158
|
-
|
|
157
|
+
stepId,
|
|
159
158
|
}, base);
|
|
160
159
|
break;
|
|
161
160
|
// ── 流式 delta(TRACE 级别,数据量大) ──
|
|
@@ -163,7 +162,7 @@ export class TraceCollector {
|
|
|
163
162
|
if (this.config.captureStreamDeltas) {
|
|
164
163
|
this.logger.trace(TRACE_EVENTS.MODEL_STREAM_DELTA, {
|
|
165
164
|
delta: event.data?.delta,
|
|
166
|
-
|
|
165
|
+
stepId,
|
|
167
166
|
}, base);
|
|
168
167
|
}
|
|
169
168
|
break;
|
|
@@ -171,7 +170,7 @@ export class TraceCollector {
|
|
|
171
170
|
case 'retry':
|
|
172
171
|
this.logger.warn(TRACE_EVENTS.MODEL_RETRY, {
|
|
173
172
|
delayMs: event.data?.delayMs,
|
|
174
|
-
|
|
173
|
+
stepId,
|
|
175
174
|
}, base);
|
|
176
175
|
break;
|
|
177
176
|
// ── 安全 ──
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Level 0: FATAL — 系统崩溃
|
|
6
6
|
* Level 1: ERROR — 功能异常(空回复、工具失败)
|
|
7
7
|
* Level 2: WARN — 可降级问题(重试、fallback)
|
|
8
|
-
* Level 3: INFO — 关键节点(
|
|
8
|
+
* Level 3: INFO — 关键节点(step 开始/结束、tool 调用)
|
|
9
9
|
* Level 4: DEBUG — 完整数据(消息内容、token 统计)
|
|
10
10
|
* Level 5: TRACE — 底层细节(原始 API 请求/响应、流式 chunk)
|
|
11
11
|
*/
|
|
@@ -39,8 +39,8 @@ export interface TraceEvent {
|
|
|
39
39
|
export declare const TRACE_EVENTS: {
|
|
40
40
|
readonly ENGINE_START: "engine.start";
|
|
41
41
|
readonly ENGINE_END: "engine.end";
|
|
42
|
-
readonly
|
|
43
|
-
readonly
|
|
42
|
+
readonly STEP_START: "step.start";
|
|
43
|
+
readonly STEP_END: "step.end";
|
|
44
44
|
readonly MODEL_CALL_START: "model.call.start";
|
|
45
45
|
readonly MODEL_CALL_END: "model.call.end";
|
|
46
46
|
readonly TOOL_EXEC_START: "tool.exec.start";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Level 0: FATAL — 系统崩溃
|
|
6
6
|
* Level 1: ERROR — 功能异常(空回复、工具失败)
|
|
7
7
|
* Level 2: WARN — 可降级问题(重试、fallback)
|
|
8
|
-
* Level 3: INFO — 关键节点(
|
|
8
|
+
* Level 3: INFO — 关键节点(step 开始/结束、tool 调用)
|
|
9
9
|
* Level 4: DEBUG — 完整数据(消息内容、token 统计)
|
|
10
10
|
* Level 5: TRACE — 底层细节(原始 API 请求/响应、流式 chunk)
|
|
11
11
|
*/
|
|
@@ -34,8 +34,8 @@ export const TRACE_EVENTS = {
|
|
|
34
34
|
// Level 3: INFO — 关键节点
|
|
35
35
|
ENGINE_START: 'engine.start',
|
|
36
36
|
ENGINE_END: 'engine.end',
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
STEP_START: 'step.start',
|
|
38
|
+
STEP_END: 'step.end',
|
|
39
39
|
MODEL_CALL_START: 'model.call.start',
|
|
40
40
|
MODEL_CALL_END: 'model.call.end',
|
|
41
41
|
TOOL_EXEC_START: 'tool.exec.start',
|
|
@@ -54,12 +54,18 @@ export class AnthropicProvider {
|
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
56
56
|
this.models.push(entry.name);
|
|
57
|
-
if (entry.contextWindow != null ||
|
|
57
|
+
if (entry.contextWindow != null ||
|
|
58
|
+
entry.maxOutputTokens != null ||
|
|
59
|
+
entry.temperature != null ||
|
|
60
|
+
entry.reasoning != null ||
|
|
61
|
+
entry.input != null) {
|
|
58
62
|
this.modelInfoMap.set(entry.name, {
|
|
59
63
|
name: entry.name,
|
|
60
64
|
contextWindow: entry.contextWindow,
|
|
61
65
|
maxOutputTokens: entry.maxOutputTokens,
|
|
62
66
|
temperature: entry.temperature,
|
|
67
|
+
reasoning: entry.reasoning,
|
|
68
|
+
input: entry.input,
|
|
63
69
|
});
|
|
64
70
|
}
|
|
65
71
|
}
|
|
@@ -353,6 +359,13 @@ export class AnthropicProvider {
|
|
|
353
359
|
*/
|
|
354
360
|
toAnthropicRequest(request) {
|
|
355
361
|
const systemMessages = request.messages.filter((m) => m.role === 'system');
|
|
362
|
+
// 契约断言:system 至多一条(托管 systemPrompt)。多条 = 上游装配契约违约
|
|
363
|
+
//(非托管 system 漏过反向围栏)。库语境无可靠 NODE_ENV,生产 throw 会把可容错
|
|
364
|
+
// 情况升级成运行失败——故此处告警 + 按序拼接容错,开发期严格性由单测断言保证
|
|
365
|
+
//(测试红线:违约输入必须触发告警且请求可发)。
|
|
366
|
+
if (systemMessages.length > 1) {
|
|
367
|
+
console.warn(`[octopi] anthropic adapter: contract violation — ${systemMessages.length} system messages in LLM view (expected at most 1); joining for compatibility`);
|
|
368
|
+
}
|
|
356
369
|
const nonSystemMessages = request.messages.filter((m) => m.role !== 'system');
|
|
357
370
|
const systemPrompt = systemMessages.map((m) => String(m.content ?? '')).join('\n\n');
|
|
358
371
|
const messages = this.toAnthropicMessages(nonSystemMessages);
|
|
@@ -51,12 +51,18 @@ export class OpenAIProvider {
|
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
53
53
|
this.models.push(entry.name);
|
|
54
|
-
if (entry.contextWindow != null ||
|
|
54
|
+
if (entry.contextWindow != null ||
|
|
55
|
+
entry.maxOutputTokens != null ||
|
|
56
|
+
entry.temperature != null ||
|
|
57
|
+
entry.reasoning != null ||
|
|
58
|
+
entry.input != null) {
|
|
55
59
|
this.modelInfoMap.set(entry.name, {
|
|
56
60
|
name: entry.name,
|
|
57
61
|
contextWindow: entry.contextWindow,
|
|
58
62
|
maxOutputTokens: entry.maxOutputTokens,
|
|
59
63
|
temperature: entry.temperature,
|
|
64
|
+
reasoning: entry.reasoning,
|
|
65
|
+
input: entry.input,
|
|
60
66
|
});
|
|
61
67
|
}
|
|
62
68
|
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @module integration/providers/wire-dump
|
|
19
19
|
*/
|
|
20
|
-
import type { TokenUsage } from '@octopi-agent/core/types/
|
|
20
|
+
import type { TokenUsage } from '@octopi-agent/core/types/step.js';
|
|
21
21
|
import type { LLMRequest, ModelProvider } from '@octopi-agent/core/interfaces/model-provider.js';
|
|
22
22
|
/** 调用方身份(由 harness 侧解析,integration 不反向依赖 harness) */
|
|
23
23
|
export interface WireDumpContext {
|
|
@@ -25,6 +25,11 @@ export interface ArchiveManagerOptions {
|
|
|
25
25
|
forceArchiveDays?: number;
|
|
26
26
|
/** 可选 EventBus:归档成功后 emit session.ended */
|
|
27
27
|
events?: EventBus;
|
|
28
|
+
/** Optional Host observation after archive export and hot-store deletion. */
|
|
29
|
+
onSessionArchived?: (event: {
|
|
30
|
+
sessionId: string;
|
|
31
|
+
agentId: string;
|
|
32
|
+
}) => void | Promise<void>;
|
|
28
33
|
}
|
|
29
34
|
export declare class SessionArchiveManager {
|
|
30
35
|
private store;
|
|
@@ -33,6 +38,7 @@ export declare class SessionArchiveManager {
|
|
|
33
38
|
private archiveRetentionMs;
|
|
34
39
|
private forceArchiveMs;
|
|
35
40
|
private events?;
|
|
41
|
+
private onSessionArchived?;
|
|
36
42
|
/**
|
|
37
43
|
* @param store - SessionStore(契约级;不绑具体后端)
|
|
38
44
|
* @param options - 归档目录与保留策略
|
|
@@ -23,6 +23,7 @@ export class SessionArchiveManager {
|
|
|
23
23
|
archiveRetentionMs;
|
|
24
24
|
forceArchiveMs;
|
|
25
25
|
events;
|
|
26
|
+
onSessionArchived;
|
|
26
27
|
/**
|
|
27
28
|
* @param store - SessionStore(契约级;不绑具体后端)
|
|
28
29
|
* @param options - 归档目录与保留策略
|
|
@@ -34,6 +35,7 @@ export class SessionArchiveManager {
|
|
|
34
35
|
this.archiveRetentionMs = (options.archiveRetentionDays ?? 180) * 24 * 60 * 60 * 1000;
|
|
35
36
|
this.forceArchiveMs = (options.forceArchiveDays ?? 90) * 24 * 60 * 60 * 1000;
|
|
36
37
|
this.events = options.events;
|
|
38
|
+
this.onSessionArchived = options.onSessionArchived;
|
|
37
39
|
}
|
|
38
40
|
/**
|
|
39
41
|
* 执行归档流程
|
|
@@ -93,6 +95,14 @@ export class SessionArchiveManager {
|
|
|
93
95
|
sessionId: session.id,
|
|
94
96
|
data: { reason: 'archived' },
|
|
95
97
|
});
|
|
98
|
+
if (this.onSessionArchived) {
|
|
99
|
+
try {
|
|
100
|
+
await this.onSessionArchived({ sessionId: session.id, agentId: session.agentId });
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
// Observation cannot undo a completed archive; its adapter records the failure.
|
|
104
|
+
}
|
|
105
|
+
}
|
|
96
106
|
}
|
|
97
107
|
/**
|
|
98
108
|
* 追加一条记录到压缩归档文件(temp + rename,避免截断式写坏当月冷备)
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* <sessionsDir>/
|
|
6
6
|
* sessions.json ← 所有 session 的元数据索引(键 = sessionId;含 lifecycle 投影)
|
|
7
7
|
* <sessionId>.jsonl ← 对话记录(JSONL;save 整聚合快照写回,非磁盘 append-only)
|
|
8
|
-
* <sessionId>.state.json ← 附带状态(tasks /
|
|
8
|
+
* <sessionId>.state.json ← 附带状态(tasks / steps / metadata / 模型 2 字段)
|
|
9
9
|
*
|
|
10
10
|
* 主键 = sessionId;文件名一律 `toSessionFileName`(跨平台安全)。
|
|
11
11
|
* 可选 `index`:可重建检索投影(失败不阻断权威写)。禁止把 index 当权威。
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* <sessionsDir>/
|
|
6
6
|
* sessions.json ← 所有 session 的元数据索引(键 = sessionId;含 lifecycle 投影)
|
|
7
7
|
* <sessionId>.jsonl ← 对话记录(JSONL;save 整聚合快照写回,非磁盘 append-only)
|
|
8
|
-
* <sessionId>.state.json ← 附带状态(tasks /
|
|
8
|
+
* <sessionId>.state.json ← 附带状态(tasks / steps / metadata / 模型 2 字段)
|
|
9
9
|
*
|
|
10
10
|
* 主键 = sessionId;文件名一律 `toSessionFileName`(跨平台安全)。
|
|
11
11
|
* 可选 `index`:可重建检索投影(失败不阻断权威写)。禁止把 index 当权威。
|
|
@@ -45,16 +45,16 @@ function isRefPrefix(synced, incoming) {
|
|
|
45
45
|
return true;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* 历史 state.json 的 turns[].input
|
|
48
|
+
* 历史 state.json 的 turns[].input(全量历史快照;turns 为账本旧字段名)已废弃:读取即剥,turns 整键读入 steps,
|
|
49
49
|
* 下次 save 自然瘦身。输入正文的唯一权威是 messages JSONL(Discourse)。
|
|
50
50
|
*
|
|
51
51
|
* 读取端宽松、写入端严格:legacy 账本可能缺 inputCount(旧格式无此字段),
|
|
52
52
|
* rest spread 保全其余键,仅类型层面放宽;新写入的账本必含 inputCount。
|
|
53
53
|
*/
|
|
54
|
-
function
|
|
55
|
-
if (!Array.isArray(
|
|
54
|
+
function slimSteps(steps) {
|
|
55
|
+
if (!Array.isArray(steps))
|
|
56
56
|
return [];
|
|
57
|
-
return
|
|
57
|
+
return steps.flatMap((t) => {
|
|
58
58
|
if (!t || typeof t !== 'object')
|
|
59
59
|
return [];
|
|
60
60
|
const { input: _dropped, ...rest } = t;
|
|
@@ -102,7 +102,7 @@ export class JsonlSessionStore {
|
|
|
102
102
|
return null;
|
|
103
103
|
try {
|
|
104
104
|
const parsed = JSON.parse(await readFile(statePath, 'utf-8'));
|
|
105
|
-
return { ...parsed,
|
|
105
|
+
return { ...parsed, steps: slimSteps(parsed?.steps ?? parsed?.turns) };
|
|
106
106
|
}
|
|
107
107
|
catch {
|
|
108
108
|
return null;
|
|
@@ -177,7 +177,7 @@ export class JsonlSessionStore {
|
|
|
177
177
|
if (resolved.state) {
|
|
178
178
|
try {
|
|
179
179
|
const parsed = JSON.parse(await readFile(resolved.state, 'utf-8'));
|
|
180
|
-
state = { ...parsed,
|
|
180
|
+
state = { ...parsed, steps: slimSteps(parsed?.steps ?? parsed?.turns) };
|
|
181
181
|
}
|
|
182
182
|
catch { /* corrupt state, ignore */ }
|
|
183
183
|
}
|
|
@@ -214,7 +214,7 @@ export class JsonlSessionStore {
|
|
|
214
214
|
updatedAt: Date.now(),
|
|
215
215
|
},
|
|
216
216
|
messages,
|
|
217
|
-
|
|
217
|
+
steps: state.steps ?? [],
|
|
218
218
|
metadata: state.metadata ?? {},
|
|
219
219
|
tasks: state.tasks ?? [],
|
|
220
220
|
};
|
|
@@ -225,18 +225,20 @@ export class JsonlSessionStore {
|
|
|
225
225
|
await unlink(p);
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
// OP-15:会话附件目录随 session
|
|
228
|
+
// OP-15:会话附件目录随 session 删除清理;转换记录同理(F6:摘要正文含用户内容)
|
|
229
229
|
try {
|
|
230
230
|
const { rm } = await import('node:fs/promises');
|
|
231
231
|
const { join } = await import('node:path');
|
|
232
232
|
const { toSessionFileName } = await import('@octopi-agent/core/session-filename.js');
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
233
|
+
for (const dir of ['attachments', 'transform']) {
|
|
234
|
+
await rm(join(this.sessionsDir, toSessionFileName(sessionId), dir), {
|
|
235
|
+
recursive: true,
|
|
236
|
+
force: true,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
237
239
|
}
|
|
238
240
|
catch {
|
|
239
|
-
//
|
|
241
|
+
// 附件/转换记录清理失败不阻断 session 删除;残留由磁盘清理兜底
|
|
240
242
|
}
|
|
241
243
|
const metaPath = this.metaFile();
|
|
242
244
|
if (await fileExists(metaPath)) {
|
|
@@ -301,7 +303,7 @@ export class JsonlSessionStore {
|
|
|
301
303
|
contextCompacts: data.contextCompacts,
|
|
302
304
|
lifecycle: data.lifecycle,
|
|
303
305
|
tasks: data.tasks ?? [],
|
|
304
|
-
|
|
306
|
+
steps: data.steps ?? [],
|
|
305
307
|
metadata,
|
|
306
308
|
}, null, 2));
|
|
307
309
|
// 索引携带 lifecycle 投影:list 过滤 / 归档扫描不必打开 state
|
|
@@ -351,7 +353,7 @@ export class JsonlSessionStore {
|
|
|
351
353
|
contextCompacts: prev?.contextCompacts,
|
|
352
354
|
lifecycle: prev?.lifecycle,
|
|
353
355
|
tasks: prev?.tasks ?? [],
|
|
354
|
-
|
|
356
|
+
steps: prev?.steps ?? [],
|
|
355
357
|
metadata,
|
|
356
358
|
}, null, 2));
|
|
357
359
|
try {
|
|
@@ -11,7 +11,8 @@ sense:
|
|
|
11
11
|
isolation: isolated
|
|
12
12
|
|
|
13
13
|
think:
|
|
14
|
-
|
|
14
|
+
# code = 调 handler.ts 确定性实现(llm 模式是自由 decide,handler 从未执行——2026-10-30 修复)
|
|
15
|
+
implementation: code
|
|
15
16
|
strategy: single
|
|
16
17
|
maxIterations: 1
|
|
17
18
|
|
|
@@ -36,7 +37,7 @@ session:
|
|
|
36
37
|
|
|
37
38
|
lifecycle:
|
|
38
39
|
maxConcurrent: 1
|
|
39
|
-
maxDurationMs:
|
|
40
|
+
maxDurationMs: 120000
|
|
40
41
|
|
|
41
42
|
runtimeInject:
|
|
42
43
|
requires: ['conceptGraphStore']
|
|
@@ -48,3 +49,4 @@ metadata:
|
|
|
48
49
|
config:
|
|
49
50
|
maxNodesPerProposition: 6
|
|
50
51
|
maxEdgesPerProposition: 12
|
|
52
|
+
maxTokens: 8192
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { readFileSync } from 'node:fs';
|
|
8
8
|
import { dirname, join } from 'node:path';
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
|
-
import { DEP_LLM_PORT, DEP_SUBSYSTEM_PROMPT, } from '@octopi-agent/engine/harness/collaboration/autonomous-subsystem/index.js';
|
|
10
|
+
import { DEP_LLM_PORT, DEP_SUBSYSTEM_PROMPT, chatForCompleteOutput, } from '@octopi-agent/engine/harness/collaboration/autonomous-subsystem/index.js';
|
|
11
11
|
import { conceptualizeAndAdmit, parseConceptualizerJson, } from '../../../harness/memory/conceptualizer.js';
|
|
12
12
|
const DEP_CONCEPT_GRAPH = 'conceptGraphStore';
|
|
13
13
|
const DEP_CONFIG = '__subsystem_config__';
|
|
@@ -66,26 +66,18 @@ async function handler(input, deps) {
|
|
|
66
66
|
`evidence: ${evidence}`,
|
|
67
67
|
`contextSlice: ${contextSlice}`,
|
|
68
68
|
].join('\n');
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
llmText = res.content ?? '';
|
|
81
|
-
}
|
|
82
|
-
catch (err) {
|
|
83
|
-
return failOutput(err instanceof Error ? err.message : String(err), 'llm_error');
|
|
84
|
-
}
|
|
85
|
-
const parsed = parseConceptualizerJson(llmText);
|
|
86
|
-
if (!parsed) {
|
|
87
|
-
return failOutput('parse_failed', 'parse_failed');
|
|
69
|
+
// maxTokens 只是生成配额(LLM 传参):截断(finish=length)或解析失败都放大配额重试
|
|
70
|
+
// 一次,仍失败显式上报——业务完整性优先,禁止静默半截结果
|
|
71
|
+
const config = deps?.[DEP_CONFIG] ?? {};
|
|
72
|
+
const outcome = await chatForCompleteOutput(llmPort, {
|
|
73
|
+
systemPrompt: systemPrompt || undefined,
|
|
74
|
+
messages: [{ role: 'user', content: userText }],
|
|
75
|
+
maxTokens: config.maxTokens ?? 8192,
|
|
76
|
+
}, (text) => parseConceptualizerJson(text));
|
|
77
|
+
if (!outcome.ok) {
|
|
78
|
+
return failOutput(outcome.message, outcome.reason);
|
|
88
79
|
}
|
|
80
|
+
const parsed = outcome.parsed;
|
|
89
81
|
const result = await conceptualizeAndAdmit(parsed, {
|
|
90
82
|
proposition,
|
|
91
83
|
memoryId,
|