@octopi-agent/engine 0.98.4 → 0.121.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/builtin-model-info.js +28 -7
- package/dist/config-admin/agent-presets.d.ts +32 -0
- package/dist/config-admin/agent-presets.js +133 -0
- package/dist/config-admin/discover.d.ts +33 -4
- package/dist/config-admin/discover.js +101 -6
- package/dist/config-admin/env.d.ts +11 -0
- package/dist/config-admin/env.js +41 -0
- package/dist/config-admin/error-copy.d.ts +106 -0
- package/dist/config-admin/error-copy.js +287 -0
- package/dist/config-admin/i18n.d.ts +21 -0
- package/dist/config-admin/i18n.js +19 -0
- package/dist/config-admin/index.d.ts +6 -2
- package/dist/config-admin/index.js +3 -1
- package/dist/config-admin/model-presets.d.ts +14 -0
- package/dist/config-admin/model-presets.js +595 -70
- package/dist/config-admin/onboarding-apply.d.ts +71 -0
- package/dist/config-admin/onboarding-apply.js +235 -0
- package/dist/config-admin/onboarding.d.ts +154 -0
- package/dist/config-admin/onboarding.js +270 -0
- package/dist/config-admin/redact.d.ts +42 -9
- package/dist/config-admin/redact.js +69 -5
- package/dist/config-schema/agent.d.ts +40 -6
- package/dist/config-schema/agent.js +44 -6
- package/dist/config-schema/browser.d.ts +62 -0
- package/dist/config-schema/browser.js +89 -0
- package/dist/config-schema/context.d.ts +12 -37
- package/dist/config-schema/context.js +10 -31
- package/dist/config-schema/engine.d.ts +140 -164
- package/dist/config-schema/engine.js +10 -7
- package/dist/config-schema/governance.d.ts +20 -2
- package/dist/config-schema/governance.js +18 -3
- package/dist/config-schema/models.d.ts +10 -12
- package/dist/config-schema/models.js +16 -3
- package/dist/config-schema/run.d.ts +6 -2
- package/dist/config-schema/run.js +12 -2
- package/dist/config-schema/shared.d.ts +1 -3
- package/dist/config-schema/shared.js +4 -4
- package/dist/config-schema/substrate.d.ts +19 -88
- package/dist/config-schema/substrate.js +30 -107
- package/dist/config.d.ts +161 -123
- package/dist/config.js +109 -7
- package/dist/file-mode.d.ts +67 -0
- package/dist/file-mode.js +182 -0
- package/dist/fork-child.d.ts +82 -0
- package/dist/fork-child.js +123 -0
- package/dist/harness/activation/delegated-run.d.ts +42 -0
- package/dist/harness/activation/delegated-run.js +71 -0
- package/dist/harness/activation/dispatcher.js +11 -0
- package/dist/harness/activation/inbox.d.ts +3 -3
- package/dist/harness/activation/inbox.js +3 -3
- package/dist/harness/activation/index.d.ts +1 -0
- package/dist/harness/activation/run-backend.d.ts +92 -0
- package/dist/harness/activation/run-backend.js +16 -0
- package/dist/harness/activation/run-protocol.d.ts +392 -0
- package/dist/harness/activation/run-protocol.js +19 -0
- package/dist/harness/activation/runtime.d.ts +33 -0
- package/dist/harness/activation/runtime.js +130 -31
- package/dist/harness/activation/types.d.ts +20 -3
- package/dist/harness/agent/builder.d.ts +36 -3
- package/dist/harness/agent/builder.js +206 -46
- package/dist/harness/agent/config-bridge.d.ts +10 -1
- package/dist/harness/agent/config-bridge.js +24 -5
- package/dist/harness/agent/config-integrity.js +19 -2
- package/dist/harness/agent/registered-tool-adapter.d.ts +27 -0
- package/dist/harness/agent/registered-tool-adapter.js +67 -0
- package/dist/harness/agent/wire-agent-builder.d.ts +13 -3
- package/dist/harness/agent/wire-agent-builder.js +35 -9
- package/dist/harness/capabilities/document/backends/plain.js +2 -1
- package/dist/harness/capabilities/document/factory.d.ts +5 -0
- package/dist/harness/capabilities/document/factory.js +1 -0
- package/dist/harness/capabilities/document/legacy/factory.js +3 -2
- 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/audit/reader.d.ts +17 -0
- package/dist/harness/collaboration/autonomous-subsystem/audit/reader.js +66 -36
- package/dist/harness/collaboration/autonomous-subsystem/audit/writer.d.ts +6 -2
- package/dist/harness/collaboration/autonomous-subsystem/audit/writer.js +27 -7
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.js +13 -0
- package/dist/harness/collaboration/autonomous-subsystem/loader.js +2 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +11 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +17 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.d.ts +14 -4
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.js +50 -41
- 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/executor.js +4 -1
- package/dist/harness/collaboration/autonomous-subsystem/types.d.ts +7 -3
- package/dist/harness/collaboration/delegation/child-run.d.ts +10 -1
- package/dist/harness/collaboration/delegation/child-run.js +38 -6
- 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/registry-types.d.ts +2 -0
- package/dist/harness/collaboration/delegation/service.d.ts +11 -4
- package/dist/harness/collaboration/delegation/service.js +35 -13
- package/dist/harness/collaboration/delegation/store.d.ts +4 -0
- package/dist/harness/collaboration/delegation/store.js +3 -1
- package/dist/harness/collaboration/delegation/types.d.ts +34 -2
- package/dist/harness/collaboration/delegation/types.js +22 -0
- package/dist/harness/collaboration/delegation/wiring.d.ts +2 -0
- package/dist/harness/collaboration/delegation/wiring.js +12 -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 +44 -11
- package/dist/harness/context/capabilities/compact/engine.js +296 -160
- 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 +7 -2
- package/dist/harness/context/capabilities/compact/index.js +5 -1
- 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 +134 -19
- 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/gate.d.ts +19 -2
- package/dist/harness/context/capabilities/summary/gate.js +53 -6
- package/dist/harness/context/capabilities/summary/port.js +0 -1
- package/dist/harness/context/capabilities/summary/registry.js +20 -0
- package/dist/harness/context/capabilities/summary/resolver.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/resolver.js +1 -6
- package/dist/harness/context/capabilities/summary/tool-binding.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/tool-binding.js +16 -12
- package/dist/harness/context/capabilities/summary/tool-bindings.d.ts +13 -0
- package/dist/harness/context/capabilities/summary/tool-bindings.js +22 -0
- package/dist/harness/context/capabilities/summary/types.d.ts +19 -6
- package/dist/harness/context/constitution/default-agents.md +85 -0
- package/dist/harness/context/context-size-ledger.d.ts +143 -0
- package/dist/harness/context/context-size-ledger.js +243 -0
- package/dist/harness/context/default-context-engine.d.ts +290 -120
- package/dist/harness/context/default-context-engine.js +1555 -764
- package/dist/harness/context/index.d.ts +3 -2
- package/dist/harness/context/index.js +2 -1
- package/dist/harness/context/layer-health.d.ts +4 -0
- package/dist/harness/context/layer-health.js +4 -0
- package/dist/harness/context/layer-types.d.ts +72 -0
- package/dist/harness/context/layer-types.js +87 -2
- package/dist/harness/context/layers.d.ts +17 -15
- package/dist/harness/context/layers.js +54 -17
- package/dist/harness/context/message-selector.d.ts +10 -8
- package/dist/harness/context/message-selector.js +49 -27
- package/dist/harness/context/prefix-fingerprint.d.ts +46 -0
- package/dist/harness/context/prefix-fingerprint.js +52 -0
- package/dist/harness/context/summarize.d.ts +2 -2
- package/dist/harness/context/summarize.js +27 -2
- package/dist/harness/context/system-prompt-assembler.d.ts +4 -0
- package/dist/harness/context/system-prompt-assembler.js +7 -3
- 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 +109 -16
- package/dist/harness/context/tool-result-aging.js +220 -55
- 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 +196 -119
- package/dist/harness/context/types.js +25 -1
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +4 -3
- package/dist/harness/extension/execution-environment/effect-policy.js +2 -2
- package/dist/harness/extension/execution-environment/ops-audit.d.ts +1 -1
- package/dist/harness/extension/execution-environment/privileged-exec.js +4 -1
- 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/workspace.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +28 -2
- package/dist/harness/extension/plugin-ecosystem/channel-types.js +11 -2
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.d.ts +12 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.js +25 -0
- package/dist/harness/extension/plugin-ecosystem/commands/builtin.js +28 -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/index.d.ts +1 -0
- package/dist/harness/extension/plugin-ecosystem/index.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +223 -222
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +218 -203
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-instances.d.ts +95 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-instances.js +170 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-kinds.d.ts +178 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-kinds.js +314 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.d.ts +78 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.js +80 -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 +57 -114
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +279 -282
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +46 -484
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +123 -345
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +50 -223
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +144 -20
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.d.ts +17 -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/browser-types.d.ts +333 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser-types.js +16 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser.d.ts +64 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser.js +692 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +0 -37
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +108 -4
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +36 -8
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +34 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +0 -6
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +57 -4
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +81 -13
- package/dist/harness/extension/plugin-ecosystem/tools/http.js +5 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +13 -7
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +126 -14
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +44 -5
- 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 +19 -24
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +7 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +4 -0
- 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/credentials/db.d.ts +9 -0
- package/dist/harness/governance/credentials/db.js +122 -31
- package/dist/harness/governance/credentials/store.d.ts +68 -7
- package/dist/harness/governance/credentials/store.js +177 -64
- package/dist/harness/governance/credentials/types.d.ts +13 -2
- 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/index.d.ts +1 -0
- package/dist/harness/governance/index.js +1 -0
- package/dist/harness/governance/registry/db.d.ts +32 -0
- package/dist/harness/governance/registry/db.js +142 -0
- package/dist/harness/governance/registry/index.d.ts +9 -0
- package/dist/harness/governance/registry/index.js +9 -0
- package/dist/harness/governance/registry/service.d.ts +381 -0
- package/dist/harness/governance/registry/service.js +825 -0
- package/dist/harness/governance/registry/types.d.ts +77 -0
- package/dist/harness/governance/registry/types.js +7 -0
- package/dist/harness/governance/security/capability-enforcer.js +1 -2
- package/dist/harness/governance/security/default-security-guard.d.ts +3 -0
- package/dist/harness/governance/security/default-security-guard.js +12 -1
- package/dist/harness/governance/security/risk-evaluator.d.ts +13 -3
- package/dist/harness/governance/security/risk-evaluator.js +307 -21
- package/dist/harness/governance/security/shell-parser-treesitter.js +12 -4
- package/dist/harness/governance/session-acl/tool-rights.d.ts +1 -0
- package/dist/harness/index.d.ts +17 -15
- package/dist/harness/index.js +9 -9
- package/dist/harness/knowledge/boot-config.d.ts +57 -0
- package/dist/harness/knowledge/boot-config.js +52 -0
- package/dist/harness/knowledge/catalog-types.d.ts +2 -0
- package/dist/harness/knowledge/client.d.ts +77 -9
- package/dist/harness/knowledge/client.js +95 -24
- package/dist/harness/knowledge/db.d.ts +16 -0
- package/dist/harness/knowledge/db.js +112 -41
- 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 +11 -7
- package/dist/harness/knowledge/grounding.js +7 -2
- package/dist/harness/knowledge/http-app.d.ts +15 -0
- package/dist/harness/knowledge/http-app.js +117 -25
- package/dist/harness/knowledge/http-bridge.d.ts +15 -0
- package/dist/harness/knowledge/http-bridge.js +19 -0
- 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 +5 -3
- package/dist/harness/knowledge/purge.js +5 -2
- package/dist/harness/knowledge/query-service.d.ts +25 -4
- package/dist/harness/knowledge/query-service.js +79 -43
- package/dist/harness/knowledge/query-worker-client.d.ts +14 -2
- package/dist/harness/knowledge/query-worker-client.js +8 -3
- package/dist/harness/knowledge/query-worker.js +9 -5
- package/dist/harness/knowledge/read-http.d.ts +2 -0
- package/dist/harness/knowledge/read-http.js +14 -3
- package/dist/harness/knowledge/retriever.d.ts +1 -1
- package/dist/harness/knowledge/retriever.js +1 -2
- package/dist/harness/knowledge/serve.d.ts +14 -8
- package/dist/harness/knowledge/serve.js +14 -6
- package/dist/harness/knowledge/source-store.d.ts +101 -5
- package/dist/harness/knowledge/source-store.js +323 -74
- package/dist/harness/knowledge/start-service-process.d.ts +41 -14
- package/dist/harness/knowledge/start-service-process.js +67 -96
- package/dist/harness/knowledge/tenant-gate.d.ts +81 -0
- package/dist/harness/knowledge/tenant-gate.js +167 -0
- package/dist/harness/knowledge/types.d.ts +7 -0
- package/dist/harness/knowledge/writer-service.d.ts +55 -11
- package/dist/harness/knowledge/writer-service.js +200 -30
- package/dist/harness/knowledge/writer-worker-client.d.ts +19 -11
- package/dist/harness/knowledge/writer-worker-client.js +40 -5
- package/dist/harness/knowledge/writer-worker.js +20 -5
- package/dist/harness/memory/backfill-trigger.d.ts +10 -3
- package/dist/harness/memory/backfill-trigger.js +19 -19
- package/dist/harness/memory/cognition-seeds.d.ts +45 -0
- package/dist/harness/memory/cognition-seeds.js +67 -0
- package/dist/harness/memory/cognition.d.ts +12 -3
- package/dist/harness/memory/cognition.js +55 -35
- package/dist/harness/memory/conceptualizer.d.ts +11 -1
- package/dist/harness/memory/conceptualizer.js +10 -1
- package/dist/harness/memory/context-slice.d.ts +42 -0
- package/dist/harness/memory/context-slice.js +197 -0
- package/dist/harness/memory/health-probe.d.ts +8 -2
- package/dist/harness/memory/health-probe.js +10 -13
- package/dist/harness/memory/index.d.ts +5 -1
- package/dist/harness/memory/index.js +3 -1
- package/dist/harness/memory/sqlite/agent-db.d.ts +1 -0
- package/dist/harness/memory/sqlite/agent-db.js +9 -8
- package/dist/harness/memory/sqlite/cognition-store.d.ts +26 -3
- package/dist/harness/memory/sqlite/cognition-store.js +103 -45
- package/dist/harness/memory/sqlite/memory-store.js +4 -0
- package/dist/harness/memory/sqlite/sqlite-vec.d.ts +24 -1
- package/dist/harness/memory/sqlite/sqlite-vec.js +37 -1
- package/dist/harness/memory/sqlite/wisdom-store.js +35 -10
- package/dist/harness/memory/types.d.ts +24 -6
- package/dist/harness/memory/wisdom-formation.d.ts +14 -3
- package/dist/harness/memory/wisdom-formation.js +85 -22
- package/dist/harness/memory/wisdom-gates.d.ts +14 -0
- package/dist/harness/memory/wisdom-gates.js +59 -19
- package/dist/harness/memory/wisdom.js +9 -0
- package/dist/harness/observability/observer/hub.d.ts +10 -0
- package/dist/harness/observability/observer/hub.js +120 -17
- 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 +67 -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/concurrency/tool-validator.js +4 -3
- 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 +32 -4
- package/dist/harness/run/reliability/run-agent.js +216 -63
- 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-host.d.ts +302 -0
- package/dist/harness/run/run-host.js +978 -0
- package/dist/harness/run/run-scope.d.ts +48 -4
- package/dist/harness/run/run-scope.js +19 -1
- package/dist/harness/run/runner.d.ts +181 -39
- package/dist/harness/run/runner.js +654 -119
- 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/in-memory-store.js +13 -1
- package/dist/harness/session/schedules/service.d.ts +10 -2
- package/dist/harness/session/schedules/service.js +13 -2
- package/dist/harness/session/tasks/tools.js +12 -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 +11 -15
- package/dist/harness/shared/events/agent-event-map.d.ts +75 -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/types/agent-definition.d.ts +7 -2
- package/dist/index.d.ts +16 -18
- package/dist/index.js +9 -10
- package/dist/integration/agent-runtime/channel-message-source.d.ts +3 -1
- package/dist/integration/agent-runtime/channel-message-source.js +4 -3
- package/dist/integration/browser/camoufox.d.ts +40 -0
- package/dist/integration/browser/camoufox.js +80 -0
- package/dist/integration/browser/index.d.ts +91 -0
- package/dist/integration/browser/index.js +110 -0
- package/dist/integration/browser/install.d.ts +47 -0
- package/dist/integration/browser/install.js +214 -0
- package/dist/integration/browser/playwright.d.ts +224 -0
- package/dist/integration/browser/playwright.js +925 -0
- package/dist/integration/browser/service.d.ts +41 -0
- package/dist/integration/browser/service.js +181 -0
- package/dist/integration/browser/stealth.d.ts +42 -0
- package/dist/integration/browser/stealth.js +104 -0
- 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-message-normalize.d.ts +20 -0
- package/dist/integration/providers/anthropic-message-normalize.js +48 -0
- package/dist/integration/providers/anthropic.js +41 -3
- package/dist/integration/providers/fetch-timeout.d.ts +17 -0
- package/dist/integration/providers/fetch-timeout.js +24 -0
- package/dist/integration/providers/openai.d.ts +8 -0
- package/dist/integration/providers/openai.js +48 -2
- package/dist/integration/providers/usage.d.ts +1 -1
- package/dist/integration/providers/wire-dump-diff.js +2 -1
- package/dist/integration/providers/wire-dump.d.ts +57 -3
- package/dist/integration/providers/wire-dump.js +119 -6
- package/dist/integration/storage/archive-manager.d.ts +20 -2
- package/dist/integration/storage/archive-manager.js +34 -8
- package/dist/integration/storage/atomic-tmp.d.ts +12 -0
- package/dist/integration/storage/atomic-tmp.js +36 -0
- package/dist/integration/storage/jsonl.d.ts +10 -1
- package/dist/integration/storage/jsonl.js +155 -54
- package/dist/integration/storage/session-index.d.ts +5 -0
- package/dist/integration/storage/session-index.js +25 -4
- package/dist/integration/tools/assemble.d.ts +50 -0
- package/dist/integration/tools/assemble.js +137 -0
- package/dist/paths.d.ts +18 -0
- package/dist/paths.js +36 -0
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +3 -1
- package/dist/subsystems/cognition-steward/conceptualize/handler.js +74 -5
- package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +3 -2
- package/dist/subsystems/cognition-steward/consolidate/config.yaml +11 -2
- package/dist/subsystems/cognition-steward/consolidate/handler.d.ts +6 -3
- package/dist/subsystems/cognition-steward/consolidate/handler.js +266 -28
- package/dist/subsystems/memory-steward/backfill/handler.js +3 -2
- package/dist/subsystems/memory-steward/govern/config.yaml +6 -1
- package/dist/subsystems/wisdom-steward/attribute/config.yaml +5 -1
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +8 -1
- package/dist/subsystems/wisdom-steward/formation/config.yaml +4 -0
- package/dist/subsystems/wisdom-steward/formation/handler.js +27 -5
- package/dist/subsystems/wisdom-steward/govern/config.yaml +6 -1
- package/package.json +14 -15
- 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
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic fold — the sole view implementation in the transform-record
|
|
3
|
+
* model: `view = originals with every effective record's runs replaced by its
|
|
4
|
+
* placeholder`.
|
|
5
|
+
*
|
|
6
|
+
* No cursors, no incremental rescue: any message not covered by an effective
|
|
7
|
+
* record is verbatim in the view. The same (messages, ledger) always yields
|
|
8
|
+
* the same view — that identity is the operational definition of the red line
|
|
9
|
+
* 「压缩产物跨装配永久生效」.
|
|
10
|
+
*
|
|
11
|
+
* Overlap composition: a later record wins the overlapping span **only when
|
|
12
|
+
* its text represents the subsumed content** — a fresh summary was merged from
|
|
13
|
+
* the previous summary at creation. A `degrade` record's mechanical text does
|
|
14
|
+
* NOT represent subsumed records, so the translation layer
|
|
15
|
+
* (`appendRecordFromProduct`) never lets degrade records cover placeholder
|
|
16
|
+
* spans; by the time spans reach this fold, later-seq-wins is safe.
|
|
17
|
+
*
|
|
18
|
+
* Orphan handling is **per run** (review F3): a record applies every run that
|
|
19
|
+
* still resolves; only a record with zero resolvable runs is fully orphaned.
|
|
20
|
+
* Edit-resend truncates the message stream — run-level application keeps the
|
|
21
|
+
* surviving coverage instead of refilling it.
|
|
22
|
+
*
|
|
23
|
+
* @module harness/context/transform/fold
|
|
24
|
+
*/
|
|
25
|
+
import type { Message } from '@octopi-agent/core/types.js';
|
|
26
|
+
import type { TransformLedger, TransformRecord } from './types.js';
|
|
27
|
+
export interface FoldOptions {
|
|
28
|
+
/** Called once per fully-orphaned record (no run resolves anymore) */
|
|
29
|
+
onOrphan?: (record: TransformRecord) => void;
|
|
30
|
+
/** Called per record whose runs were partially dropped (some runs no longer resolve) */
|
|
31
|
+
onPartialOrphan?: (record: TransformRecord, droppedRuns: number) => void;
|
|
32
|
+
}
|
|
33
|
+
export interface FoldRun {
|
|
34
|
+
record: TransformRecord;
|
|
35
|
+
/** resolved inclusive raw ranges (original index space) */
|
|
36
|
+
spans: Array<[number, number]>;
|
|
37
|
+
}
|
|
38
|
+
export interface FoldResult {
|
|
39
|
+
/** the deterministic assembled view (originals + placeholders) */
|
|
40
|
+
view: Message[];
|
|
41
|
+
/** effective records with resolved spans (for translation/events) */
|
|
42
|
+
applied: FoldRun[];
|
|
43
|
+
/** effective records with zero resolvable spans (skipped entirely) */
|
|
44
|
+
orphans: TransformRecord[];
|
|
45
|
+
/** rendered placeholder message → its record (product translation identity map) */
|
|
46
|
+
placeholderOf: Map<Message, FoldRun>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Apply effective records over the original messages.
|
|
50
|
+
*
|
|
51
|
+
* @param messages - full original stream (may include ephemeral entries)
|
|
52
|
+
* @param ledger - transform ledger (records ordered by seq)
|
|
53
|
+
* @param options - orphan sinks
|
|
54
|
+
* @returns fold result
|
|
55
|
+
*/
|
|
56
|
+
export declare function foldTransformView(messages: Message[], ledger: TransformLedger, options: FoldOptions): FoldResult;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic fold — the sole view implementation in the transform-record
|
|
3
|
+
* model: `view = originals with every effective record's runs replaced by its
|
|
4
|
+
* placeholder`.
|
|
5
|
+
*
|
|
6
|
+
* No cursors, no incremental rescue: any message not covered by an effective
|
|
7
|
+
* record is verbatim in the view. The same (messages, ledger) always yields
|
|
8
|
+
* the same view — that identity is the operational definition of the red line
|
|
9
|
+
* 「压缩产物跨装配永久生效」.
|
|
10
|
+
*
|
|
11
|
+
* Overlap composition: a later record wins the overlapping span **only when
|
|
12
|
+
* its text represents the subsumed content** — a fresh summary was merged from
|
|
13
|
+
* the previous summary at creation. A `degrade` record's mechanical text does
|
|
14
|
+
* NOT represent subsumed records, so the translation layer
|
|
15
|
+
* (`appendRecordFromProduct`) never lets degrade records cover placeholder
|
|
16
|
+
* spans; by the time spans reach this fold, later-seq-wins is safe.
|
|
17
|
+
*
|
|
18
|
+
* Orphan handling is **per run** (review F3): a record applies every run that
|
|
19
|
+
* still resolves; only a record with zero resolvable runs is fully orphaned.
|
|
20
|
+
* Edit-resend truncates the message stream — run-level application keeps the
|
|
21
|
+
* surviving coverage instead of refilling it.
|
|
22
|
+
*
|
|
23
|
+
* @module harness/context/transform/fold
|
|
24
|
+
*/
|
|
25
|
+
import { asSummaryMessage } from '../capabilities/compact/messages.js';
|
|
26
|
+
import { resolveRun } from './anchors.js';
|
|
27
|
+
/**
|
|
28
|
+
* Apply effective records over the original messages.
|
|
29
|
+
*
|
|
30
|
+
* @param messages - full original stream (may include ephemeral entries)
|
|
31
|
+
* @param ledger - transform ledger (records ordered by seq)
|
|
32
|
+
* @param options - orphan sinks
|
|
33
|
+
* @returns fold result
|
|
34
|
+
*/
|
|
35
|
+
export function foldTransformView(messages, ledger, options) {
|
|
36
|
+
const applied = [];
|
|
37
|
+
const orphans = [];
|
|
38
|
+
// span assignment in original index space; later seq overwrites (see module doc)
|
|
39
|
+
const coverAt = new Array(messages.length).fill(undefined);
|
|
40
|
+
// first/last covered index per record (placeholder position / coverage line)
|
|
41
|
+
const firstIndex = new Map();
|
|
42
|
+
const lastIndex = new Map();
|
|
43
|
+
for (const record of ledger.records) {
|
|
44
|
+
if (record.revoked)
|
|
45
|
+
continue;
|
|
46
|
+
// per-run resolution(F3):能解析的 run 生效;整记录零可解析才算孤儿
|
|
47
|
+
const spans = [];
|
|
48
|
+
let droppedRuns = 0;
|
|
49
|
+
for (const run of record.covers) {
|
|
50
|
+
const resolved = resolveRun(messages, run);
|
|
51
|
+
if (resolved === undefined) {
|
|
52
|
+
droppedRuns += 1;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
spans.push(resolved);
|
|
56
|
+
}
|
|
57
|
+
if (record.covers.length > 0 && spans.length === 0) {
|
|
58
|
+
orphans.push(record);
|
|
59
|
+
options.onOrphan?.(record);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (droppedRuns > 0) {
|
|
63
|
+
options.onPartialOrphan?.(record, droppedRuns);
|
|
64
|
+
}
|
|
65
|
+
applied.push({ record, spans });
|
|
66
|
+
for (const [a, b] of spans) {
|
|
67
|
+
for (let i = a; i <= b; i++) {
|
|
68
|
+
coverAt[i] = record;
|
|
69
|
+
const f = firstIndex.get(record);
|
|
70
|
+
const l = lastIndex.get(record);
|
|
71
|
+
if (f === undefined || i < f)
|
|
72
|
+
firstIndex.set(record, i);
|
|
73
|
+
if (l === undefined || i > l)
|
|
74
|
+
lastIndex.set(record, i);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// 零覆盖记录(covers:[],legacy 迁移的「覆盖未知」残缺快照):summary 型且有正文时
|
|
79
|
+
// 渲染在视图最前(旧粘滞视图把它插在 head 之后;fold 无 protectFirstN 概念,
|
|
80
|
+
// 位置取确定性的起点——信息等价、位置不同,仅此一形)。
|
|
81
|
+
const zeroCover = applied.filter((r) => r.spans.length === 0 && r.record.type === 'summary' && r.record.text);
|
|
82
|
+
const view = [];
|
|
83
|
+
const placeholderOf = new Map();
|
|
84
|
+
const rendered = new Set();
|
|
85
|
+
// zero-cover summary 占位映射到其记录(spans 空);翻译需要身份映射
|
|
86
|
+
for (const zc of zeroCover) {
|
|
87
|
+
rendered.add(zc.record);
|
|
88
|
+
// 无覆盖行(coveredEnd 省略,与 legacy 缺 coverEnd 的渲染同形)
|
|
89
|
+
const msg = asSummaryMessage(zc.record.text);
|
|
90
|
+
const placeholder = { ...msg, timestamp: messages[0]?.timestamp ?? 0 };
|
|
91
|
+
placeholderOf.set(placeholder, zc);
|
|
92
|
+
view.push(placeholder);
|
|
93
|
+
}
|
|
94
|
+
for (let i = 0; i < messages.length; i++) {
|
|
95
|
+
const record = coverAt[i];
|
|
96
|
+
if (record === undefined) {
|
|
97
|
+
view.push(messages[i]);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (rendered.has(record))
|
|
101
|
+
continue;
|
|
102
|
+
rendered.add(record);
|
|
103
|
+
const run = applied.find((r) => r.record === record);
|
|
104
|
+
const placeholder = renderPlaceholder(record, messages[firstIndex.get(record)], lastIndex.get(record));
|
|
105
|
+
placeholderOf.set(placeholder, run);
|
|
106
|
+
view.push(placeholder);
|
|
107
|
+
}
|
|
108
|
+
return { view, applied, orphans, placeholderOf };
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Render the placeholder message for a record at its first covered index.
|
|
112
|
+
*
|
|
113
|
+
* Summary records render through the single-source wrapper (marker + dynamic
|
|
114
|
+
* `[Coverage]` line, F11); degrade records render their honest mechanical text
|
|
115
|
+
* as-is. Timestamp = first covered message's timestamp — deterministic (the
|
|
116
|
+
* timestamp is not part of the LLM request anyway).
|
|
117
|
+
*
|
|
118
|
+
* @param record - the record being rendered
|
|
119
|
+
* @param at - first covered message (timestamp source)
|
|
120
|
+
* @param lastCoveredIdx - last covered raw index (coverage line)
|
|
121
|
+
* @returns placeholder message
|
|
122
|
+
*/
|
|
123
|
+
function renderPlaceholder(record, at, lastCoveredIdx) {
|
|
124
|
+
const text = record.text ?? '';
|
|
125
|
+
if (record.type === 'summary') {
|
|
126
|
+
const msg = asSummaryMessage(text, lastCoveredIdx + 1);
|
|
127
|
+
return { ...msg, timestamp: at.timestamp };
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
role: record.placeholder.role,
|
|
131
|
+
content: text,
|
|
132
|
+
timestamp: at.timestamp,
|
|
133
|
+
...(record.placeholder.source ? { metadata: { source: record.placeholder.source } } : {}),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legacy compact-snapshot migration — one-shot conversion of the old
|
|
3
|
+
* `ContextCompactSnapshot` (previousSummary + coverEnd cursor) into initial
|
|
4
|
+
* transform records.
|
|
5
|
+
*
|
|
6
|
+
* Mapping: the legacy sticky view rendered `head + summary + [coverEnd..tailStart)
|
|
7
|
+
* + tail`, i.e. the summary replaced the raw originals in `[headEnd, coverEnd)`
|
|
8
|
+
* while the head stayed verbatim (cache-prefix anchor). The migrated record
|
|
9
|
+
* therefore covers exactly `[headEnd, coverEnd)`, reproducing the legacy view
|
|
10
|
+
* byte-for-byte through the fold.
|
|
11
|
+
*
|
|
12
|
+
* Counter-only legacy states ("compacted, no summary") migrate to a `degrade`
|
|
13
|
+
* gate-anchor record with empty covers: the legacy behavior covered nothing
|
|
14
|
+
* (products refilled), so no coverage may be claimed. The growth-gate **count**
|
|
15
|
+
* base carries over; the token base does **not** — legacy `lastProactiveTokens`
|
|
16
|
+
* is a stale calibrated quantity and, without its write-time ratio, cannot be
|
|
17
|
+
* converted to the raw unit the gate now stores (M-3, review del-e1ee43ef N3).
|
|
18
|
+
*
|
|
19
|
+
* Idempotence is owned by the caller: migrate only when the ledger is empty.
|
|
20
|
+
*
|
|
21
|
+
* @module harness/context/transform/migrate
|
|
22
|
+
*/
|
|
23
|
+
import type { Message } from '@octopi-agent/core/types.js';
|
|
24
|
+
import type { ContextCompactSnapshot } from '../types.js';
|
|
25
|
+
import type { NewTransformRecord } from './types.js';
|
|
26
|
+
export interface LegacyMigrateParams {
|
|
27
|
+
sessionId: string;
|
|
28
|
+
agentId: string;
|
|
29
|
+
snapshot: ContextCompactSnapshot;
|
|
30
|
+
messages: Message[];
|
|
31
|
+
protectFirstN: number;
|
|
32
|
+
protectLastN: number;
|
|
33
|
+
now?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Convert a legacy snapshot into initial transform records.
|
|
37
|
+
*
|
|
38
|
+
* @param params - migration inputs
|
|
39
|
+
* @returns records to append, or undefined when the snapshot holds nothing migratable
|
|
40
|
+
*/
|
|
41
|
+
export declare function legacySnapshotToRecords(params: LegacyMigrateParams): NewTransformRecord[] | undefined;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legacy compact-snapshot migration — one-shot conversion of the old
|
|
3
|
+
* `ContextCompactSnapshot` (previousSummary + coverEnd cursor) into initial
|
|
4
|
+
* transform records.
|
|
5
|
+
*
|
|
6
|
+
* Mapping: the legacy sticky view rendered `head + summary + [coverEnd..tailStart)
|
|
7
|
+
* + tail`, i.e. the summary replaced the raw originals in `[headEnd, coverEnd)`
|
|
8
|
+
* while the head stayed verbatim (cache-prefix anchor). The migrated record
|
|
9
|
+
* therefore covers exactly `[headEnd, coverEnd)`, reproducing the legacy view
|
|
10
|
+
* byte-for-byte through the fold.
|
|
11
|
+
*
|
|
12
|
+
* Counter-only legacy states ("compacted, no summary") migrate to a `degrade`
|
|
13
|
+
* gate-anchor record with empty covers: the legacy behavior covered nothing
|
|
14
|
+
* (products refilled), so no coverage may be claimed. The growth-gate **count**
|
|
15
|
+
* base carries over; the token base does **not** — legacy `lastProactiveTokens`
|
|
16
|
+
* is a stale calibrated quantity and, without its write-time ratio, cannot be
|
|
17
|
+
* converted to the raw unit the gate now stores (M-3, review del-e1ee43ef N3).
|
|
18
|
+
*
|
|
19
|
+
* Idempotence is owned by the caller: migrate only when the ledger is empty.
|
|
20
|
+
*
|
|
21
|
+
* @module harness/context/transform/migrate
|
|
22
|
+
*/
|
|
23
|
+
import { alignViewSplit } from '../capabilities/compact/index.js';
|
|
24
|
+
import { anchorRange } from './anchors.js';
|
|
25
|
+
/**
|
|
26
|
+
* Convert a legacy snapshot into initial transform records.
|
|
27
|
+
*
|
|
28
|
+
* @param params - migration inputs
|
|
29
|
+
* @returns records to append, or undefined when the snapshot holds nothing migratable
|
|
30
|
+
*/
|
|
31
|
+
export function legacySnapshotToRecords(params) {
|
|
32
|
+
const { sessionId, agentId, snapshot, messages, protectFirstN, protectLastN } = params;
|
|
33
|
+
const hasSummary = Boolean(snapshot.summary);
|
|
34
|
+
const hasCounters = snapshot.lastProactiveMessageCount != null;
|
|
35
|
+
if (!hasSummary && !hasCounters)
|
|
36
|
+
return undefined;
|
|
37
|
+
const meta = {
|
|
38
|
+
reason: 'manual',
|
|
39
|
+
fresh: hasSummary,
|
|
40
|
+
summarizeAttempted: false,
|
|
41
|
+
messageCount: snapshot.lastProactiveMessageCount ?? messages.length,
|
|
42
|
+
// M-3(评审 del-e1ee43ef N3):不迁移 viewTokens——旧值是校准存量(缺写入时 ratio 无法
|
|
43
|
+
// 换算成 raw),迁移过去也会被恢复端的口径版本守卫丢弃;计数基数照常带。
|
|
44
|
+
};
|
|
45
|
+
const covers = [];
|
|
46
|
+
if (hasSummary && (snapshot.lastProactiveCoverEnd ?? 0) > 0 && messages.length > 0) {
|
|
47
|
+
// legacy coverage: [headEnd, coverEnd); head stays verbatim (see module doc)
|
|
48
|
+
const { headEnd } = alignViewSplit(messages, protectFirstN, protectLastN);
|
|
49
|
+
const coverEnd = Math.min(snapshot.lastProactiveCoverEnd, messages.length);
|
|
50
|
+
const run = coverEnd > headEnd ? anchorRange(messages, headEnd, coverEnd - 1) : undefined;
|
|
51
|
+
if (run)
|
|
52
|
+
covers.push(run);
|
|
53
|
+
}
|
|
54
|
+
// 残缺快照(summary 但覆盖未知/无计数):照样迁移——零覆盖 summary 记录在 fold
|
|
55
|
+
// 渲染为无覆盖行的摘要占位(legacy 视图同样注入该摘要;信息等价,评审 F9)
|
|
56
|
+
const record = {
|
|
57
|
+
sessionId,
|
|
58
|
+
agentId,
|
|
59
|
+
type: hasSummary ? 'summary' : 'degrade',
|
|
60
|
+
createdAt: params.now ?? Date.now(),
|
|
61
|
+
covers,
|
|
62
|
+
...(hasSummary ? { text: snapshot.summary } : {}),
|
|
63
|
+
placeholder: hasSummary
|
|
64
|
+
? { role: 'user', source: 'contextSummary' }
|
|
65
|
+
: { role: 'user', source: 'contextLedger' },
|
|
66
|
+
meta,
|
|
67
|
+
};
|
|
68
|
+
return [record];
|
|
69
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transform records — persistent compaction products.
|
|
3
|
+
*
|
|
4
|
+
* Model (arch/context-size-accounting.md §10.18「持久转换记录」拍板):
|
|
5
|
+
* a compaction product is a **fact**, not a temporary view. Once a record is
|
|
6
|
+
* appended it is permanently effective; the original text only returns to the
|
|
7
|
+
* view on an explicit revocation entry. Assembly = deterministic application
|
|
8
|
+
* of effective records over the append-only original messages (fold).
|
|
9
|
+
*
|
|
10
|
+
* - Per-agent ledger: records are keyed (sessionId, agentId) (E4 shape); agents
|
|
11
|
+
* never see each other's compaction views.
|
|
12
|
+
* - Coordinates are message content anchors (hash + occurrence), never array
|
|
13
|
+
* indices — indices survive neither fork/copy nor re-indexing.
|
|
14
|
+
* - `type` is honest: `summary` only for fresh semantic summaries (the fresh
|
|
15
|
+
* gate's sole remaining job); mechanical products are `degrade`.
|
|
16
|
+
*
|
|
17
|
+
* @module harness/context/transform/types
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Stable coordinate of one original message.
|
|
21
|
+
*
|
|
22
|
+
* `hash` is the canonical identity hash of the persisted message; `occurrence`
|
|
23
|
+
* disambiguates byte-identical duplicates in stream order; `indexHint` is the
|
|
24
|
+
* raw index at creation time (fast path only — never authoritative).
|
|
25
|
+
*/
|
|
26
|
+
export interface MessageAnchor {
|
|
27
|
+
/** sha256 hex of the canonical message identity */
|
|
28
|
+
hash: string;
|
|
29
|
+
/** 0-based occurrence of this hash in the message stream at creation */
|
|
30
|
+
occurrence: number;
|
|
31
|
+
/** raw index at creation (resolution fast path) */
|
|
32
|
+
indexHint: number;
|
|
33
|
+
}
|
|
34
|
+
/** One covered run: inclusive original-message range `[from, to]`. */
|
|
35
|
+
export interface TransformRun {
|
|
36
|
+
from: MessageAnchor;
|
|
37
|
+
to: MessageAnchor;
|
|
38
|
+
}
|
|
39
|
+
export type TransformRecordType = 'summary' | 'degrade';
|
|
40
|
+
/** Rendering shape of the replacement placeholder message. */
|
|
41
|
+
export interface TransformPlaceholder {
|
|
42
|
+
role: 'user' | 'system' | 'assistant';
|
|
43
|
+
/** Message.metadata.source marker (e.g. 'contextSummary' / 'contextLedger') */
|
|
44
|
+
source?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* One compaction product. Created only by compaction paths (proactive /
|
|
48
|
+
* overflow / manual); appended durably before the compacted view is returned.
|
|
49
|
+
*
|
|
50
|
+
* `covers` may be empty: a pure growth-gate anchor (a completed compaction
|
|
51
|
+
* round that produced no durable coverage — legacy migrate / counters-only).
|
|
52
|
+
*/
|
|
53
|
+
export interface TransformRecord {
|
|
54
|
+
/** per-(sessionId, agentId) monotonic sequence, assigned by the store */
|
|
55
|
+
seq: number;
|
|
56
|
+
sessionId: string;
|
|
57
|
+
agentId: string;
|
|
58
|
+
type: TransformRecordType;
|
|
59
|
+
createdAt: number;
|
|
60
|
+
/** covered original-message runs (inclusive; usually exactly one run) */
|
|
61
|
+
covers: TransformRun[];
|
|
62
|
+
/** content-addressed replacement text ref (`sha256:<hex>`); undefined iff covers is empty */
|
|
63
|
+
blobRef?: string;
|
|
64
|
+
/** replacement text (hydrated at load / consumed at append; persisted via blobRef) */
|
|
65
|
+
text?: string;
|
|
66
|
+
/** replacement message shape (text comes from the blob) */
|
|
67
|
+
placeholder: TransformPlaceholder;
|
|
68
|
+
/** appended revocation entry flipped this flag at load (append-only ledger) */
|
|
69
|
+
revoked: boolean;
|
|
70
|
+
meta: TransformRecordMeta;
|
|
71
|
+
}
|
|
72
|
+
export interface TransformRecordMeta {
|
|
73
|
+
reason: 'proactive' | 'overflow' | 'manual';
|
|
74
|
+
/** fresh semantic summary at creation (record type gate) */
|
|
75
|
+
fresh: boolean;
|
|
76
|
+
/** a summarize LLM call was actually issued (success or failure) */
|
|
77
|
+
summarizeAttempted: boolean;
|
|
78
|
+
/** messages.length at creation (growth-gate base) */
|
|
79
|
+
messageCount: number;
|
|
80
|
+
/** raw-history token estimate at creation — 仅诊断口径(有多段历史时远大于实际请求)
|
|
81
|
+
* :**不作增长门基数**(2026-11-07 起,改用 viewTokens) */
|
|
82
|
+
fullTokens?: number;
|
|
83
|
+
/** post-compaction view token estimate = 实际请求口径(fold + 老化);单位 raw(M-3) */
|
|
84
|
+
viewTokens?: number;
|
|
85
|
+
/** viewTokens 的计量口径版本:缺省 = 旧口径(fold 视图未老化、且非请求形状)。
|
|
86
|
+
* 增长门只认 'request-raw'(请求形状 + raw 单位);'request' 是历史存量(校准单位、
|
|
87
|
+
* 缺写入时 ratio 无法换算)只读不写,与更旧记录一律视为无基数(允许一次压缩自愈),
|
|
88
|
+
* 否则两种口径/单位互比会永久压制压缩。 */
|
|
89
|
+
viewTokensSource?: 'request' | 'request-raw';
|
|
90
|
+
}
|
|
91
|
+
/** Record as handed to the store (seq assigned by the store; text goes to a blob). */
|
|
92
|
+
export type NewTransformRecord = Omit<TransformRecord, 'seq' | 'blobRef' | 'revoked'>;
|
|
93
|
+
export interface TransformLedger {
|
|
94
|
+
/** ordered by seq;`revoked` 已折叠 */
|
|
95
|
+
records: TransformRecord[];
|
|
96
|
+
/**
|
|
97
|
+
* 账本文件曾有任何条目(含损坏行 / blob 丢失被丢弃的)。
|
|
98
|
+
* 迁移幂等门用它而不是 records.length——「行在 blob 全丢」不得被当成空账本
|
|
99
|
+
* 而重放旧快照迁移(评审 F7)。
|
|
100
|
+
*/
|
|
101
|
+
hadEntries?: boolean;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Persistence port for transform records.
|
|
105
|
+
*
|
|
106
|
+
* Appends are durable-before-return: a compaction product must hit the store
|
|
107
|
+
* before the compacted view is sent (otherwise a crash refills the raw text —
|
|
108
|
+
* exactly the defect this model exists to remove).
|
|
109
|
+
*/
|
|
110
|
+
export interface TransformStore {
|
|
111
|
+
/**
|
|
112
|
+
* Load the ledger for (sessionId, agentId).
|
|
113
|
+
*
|
|
114
|
+
* @param sessionId - session id
|
|
115
|
+
* @param agentId - agent id ("" for legacy single-agent)
|
|
116
|
+
* @returns ledger (empty when none)
|
|
117
|
+
*/
|
|
118
|
+
load(sessionId: string, agentId: string): Promise<TransformLedger>;
|
|
119
|
+
/**
|
|
120
|
+
* Durably append records (and optional revocations).
|
|
121
|
+
*
|
|
122
|
+
* @param sessionId - session id
|
|
123
|
+
* @param agentId - agent id
|
|
124
|
+
* @param records - new records (seq assigned by the store)
|
|
125
|
+
* @param revokeSeqs - seqs of existing records to revoke (explicit revocation)
|
|
126
|
+
* @returns the appended records with seq assigned
|
|
127
|
+
*/
|
|
128
|
+
append(sessionId: string, agentId: string, records: NewTransformRecord[], revokeSeqs?: number[]): Promise<TransformRecord[]>;
|
|
129
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transform records — persistent compaction products.
|
|
3
|
+
*
|
|
4
|
+
* Model (arch/context-size-accounting.md §10.18「持久转换记录」拍板):
|
|
5
|
+
* a compaction product is a **fact**, not a temporary view. Once a record is
|
|
6
|
+
* appended it is permanently effective; the original text only returns to the
|
|
7
|
+
* view on an explicit revocation entry. Assembly = deterministic application
|
|
8
|
+
* of effective records over the append-only original messages (fold).
|
|
9
|
+
*
|
|
10
|
+
* - Per-agent ledger: records are keyed (sessionId, agentId) (E4 shape); agents
|
|
11
|
+
* never see each other's compaction views.
|
|
12
|
+
* - Coordinates are message content anchors (hash + occurrence), never array
|
|
13
|
+
* indices — indices survive neither fork/copy nor re-indexing.
|
|
14
|
+
* - `type` is honest: `summary` only for fresh semantic summaries (the fresh
|
|
15
|
+
* gate's sole remaining job); mechanical products are `degrade`.
|
|
16
|
+
*
|
|
17
|
+
* @module harness/context/transform/types
|
|
18
|
+
*/
|
|
19
|
+
export {};
|
|
@@ -10,10 +10,12 @@
|
|
|
10
10
|
* 定形后字节冻结。正文经 XML 转义嵌入,用户原文不得截断信封。
|
|
11
11
|
*/
|
|
12
12
|
import type { Message } from '@octopi-agent/core/types.js';
|
|
13
|
+
import type { LLMMessage } from '@octopi-agent/core/interfaces/model-provider.js';
|
|
14
|
+
type EnvelopeContent = Message['content'] | LLMMessage['content'];
|
|
13
15
|
/** turn_start 元素的 id 形态(会话内单调 t1,t2,…) */
|
|
14
16
|
export declare function formatTurnId(seq: number): string;
|
|
15
17
|
/** 归一化 Message.content → 纯文本(多模态取 text 块拼接;空 content → '') */
|
|
16
|
-
export declare function messageText(content:
|
|
18
|
+
export declare function messageText(content: EnvelopeContent | undefined): string;
|
|
17
19
|
/** user 原文嵌入 XML 前的最小转义(防伪影标签截断信封) */
|
|
18
20
|
export declare function escapeUserMessageText(text: string): string;
|
|
19
21
|
/** 解转义(extractUserMessageText 出口) */
|
|
@@ -44,7 +46,7 @@ export declare function formatTurnContextXml(params: {
|
|
|
44
46
|
* 非 turn_start 正文原样返回。
|
|
45
47
|
* 取**最后一个** user_message 块(boilerplate 禁止再写该标签字面量)。
|
|
46
48
|
*/
|
|
47
|
-
export declare function extractUserMessageText(content:
|
|
49
|
+
export declare function extractUserMessageText(content: EnvelopeContent | undefined): string;
|
|
48
50
|
/**
|
|
49
51
|
* 剥掉 `<turn_context>…</turn_context>`(摘要语义输入 / UI)。
|
|
50
52
|
* 保留 `<user_message>` 与 turn_start/turn_end 骨架(或在 UI 场景配合 extractUserMessageText)。
|
|
@@ -109,7 +111,7 @@ export declare function escapeSlotBody(tag: string, body: string): string;
|
|
|
109
111
|
* @param content - 消息正文(string 或 Message.content)
|
|
110
112
|
* @returns 信封解析结果;非 turn_start 正文返回 null
|
|
111
113
|
*/
|
|
112
|
-
export declare function parseTurnEnvelope(content:
|
|
114
|
+
export declare function parseTurnEnvelope(content: EnvelopeContent | undefined): TurnEnvelopeParts | null;
|
|
113
115
|
/**
|
|
114
116
|
* 拼 turn_context 内的槽位 XML(runner 注入)。
|
|
115
117
|
* 正文经 escapeSlotBody 定向转义(D7 A′):语料同名字面量不得产出解析器眼里的标签,
|
|
@@ -122,3 +124,4 @@ export declare function joinSlotXml(parts: Array<{
|
|
|
122
124
|
}>): string;
|
|
123
125
|
/** 任意 content 归一化后的用户正文(UI / 载体扫描共用) */
|
|
124
126
|
export declare function unwrapUserText(content: string | Message['content'] | undefined | null): string;
|
|
127
|
+
export {};
|