@octopi-agent/engine 0.70.7 → 0.86.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/NOTICE +7 -7
- package/README.md +64 -26
- package/dist/config-schema/agent.d.ts +89 -1
- package/dist/config-schema/agent.js +69 -0
- package/dist/config-schema/context.d.ts +23 -4
- package/dist/config-schema/context.js +28 -1
- package/dist/config-schema/engine.d.ts +201 -9
- package/dist/config-schema/engine.js +31 -2
- package/dist/config-schema/governance.d.ts +95 -0
- package/dist/config-schema/governance.js +91 -0
- package/dist/config-schema/models.d.ts +1 -1
- package/dist/config-schema/observability.d.ts +6 -0
- package/dist/config-schema/observability.js +16 -0
- package/dist/config-schema/run.d.ts +10 -0
- package/dist/config-schema/run.js +18 -0
- package/dist/config-schema/shared.d.ts +10 -0
- package/dist/config-schema/shared.js +10 -0
- package/dist/config-schema/substrate.d.ts +1 -1
- package/dist/config-schema/subsystems.d.ts +1 -1
- package/dist/config-schema/subsystems.js +2 -1
- package/dist/config.d.ts +178 -7
- package/dist/config.js +113 -3
- package/dist/harness/activation/compiler.js +3 -0
- package/dist/harness/activation/runtime.d.ts +7 -0
- package/dist/harness/activation/runtime.js +60 -2
- package/dist/harness/activation/sources/agent-signal.d.ts +11 -0
- package/dist/harness/activation/sources/agent-signal.js +33 -0
- package/dist/harness/activation/types.d.ts +6 -1
- package/dist/harness/agent/builder.d.ts +47 -3
- package/dist/harness/agent/builder.js +180 -54
- package/dist/harness/agent/config-bridge.d.ts +33 -25
- package/dist/harness/agent/config-bridge.js +81 -291
- package/dist/harness/agent/index.d.ts +3 -1
- package/dist/harness/agent/index.js +2 -1
- package/dist/harness/agent/tool-purpose.d.ts +38 -0
- package/dist/harness/agent/tool-purpose.js +118 -0
- package/dist/harness/agent/wire-agent-builder.d.ts +133 -0
- package/dist/harness/agent/wire-agent-builder.js +363 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +4 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +14 -8
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +12 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +19 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.d.ts +6 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.js +24 -7
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.d.ts +5 -2
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +11 -3
- package/dist/harness/collaboration/autonomous-subsystem/think/index.d.ts +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/index.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.d.ts +7 -4
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.js +8 -9
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.d.ts +36 -10
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.js +60 -7
- package/dist/harness/collaboration/delegation/child-run.d.ts +144 -0
- package/dist/harness/collaboration/delegation/child-run.js +241 -0
- package/dist/harness/collaboration/delegation/index.d.ts +26 -0
- package/dist/harness/collaboration/delegation/index.js +25 -0
- package/dist/harness/collaboration/delegation/notifier.d.ts +46 -0
- package/dist/harness/collaboration/delegation/notifier.js +84 -0
- package/dist/harness/collaboration/delegation/registry-types.d.ts +200 -0
- package/dist/harness/collaboration/delegation/registry-types.js +61 -0
- package/dist/harness/collaboration/delegation/registry.d.ts +110 -0
- package/dist/harness/collaboration/delegation/registry.js +220 -0
- package/dist/harness/collaboration/delegation/service.d.ts +249 -0
- package/dist/harness/collaboration/delegation/service.js +499 -0
- package/dist/harness/collaboration/delegation/store.d.ts +155 -0
- package/dist/harness/collaboration/delegation/store.js +271 -0
- package/dist/harness/collaboration/delegation/transport.d.ts +73 -0
- package/dist/harness/collaboration/delegation/transport.js +61 -0
- package/dist/harness/collaboration/delegation/types.d.ts +231 -0
- package/dist/harness/collaboration/delegation/types.js +70 -0
- package/dist/harness/collaboration/delegation/wiring.d.ts +111 -0
- package/dist/harness/collaboration/delegation/wiring.js +145 -0
- package/dist/harness/collaboration/orchestration/index.d.ts +11 -13
- package/dist/harness/collaboration/orchestration/index.js +11 -11
- package/dist/harness/context/assembler.d.ts +2 -2
- package/dist/harness/context/assembler.js +12 -7
- package/dist/harness/context/capabilities/compact/engine.js +80 -38
- package/dist/harness/context/capabilities/compact/types.d.ts +12 -1
- package/dist/harness/context/capabilities/summary/registry.js +10 -0
- package/dist/harness/context/constitution/default-agents.md +230 -228
- package/dist/harness/context/default-context-engine.d.ts +101 -23
- package/dist/harness/context/default-context-engine.js +483 -172
- package/dist/harness/context/hybrid-compressor.d.ts +3 -3
- package/dist/harness/context/hybrid-compressor.js +18 -23
- package/dist/harness/context/index.d.ts +5 -1
- package/dist/harness/context/index.js +2 -0
- package/dist/harness/context/layer-snapshot.d.ts +4 -0
- package/dist/harness/context/layer-snapshot.js +30 -18
- package/dist/harness/context/layer-types.d.ts +49 -1
- package/dist/harness/context/layer-types.js +72 -4
- package/dist/harness/context/layers.d.ts +5 -2
- package/dist/harness/context/layers.js +11 -5
- package/dist/harness/context/llm-summarizer.d.ts +15 -1
- package/dist/harness/context/llm-summarizer.js +107 -56
- package/dist/harness/context/message-selector.js +6 -2
- package/dist/harness/context/root-instructions.d.ts +72 -0
- package/dist/harness/context/root-instructions.js +227 -0
- package/dist/harness/context/runtime-datetime.d.ts +34 -7
- package/dist/harness/context/runtime-datetime.js +66 -10
- package/dist/harness/context/smart-router.d.ts +1 -1
- package/dist/harness/context/smart-router.js +1 -1
- package/dist/harness/context/system-prompt-assembler.d.ts +30 -0
- package/dist/harness/context/system-prompt-assembler.js +67 -6
- package/dist/harness/context/token-constants.d.ts +2 -2
- package/dist/harness/context/token-constants.js +2 -2
- package/dist/harness/context/token-estimate-fns.d.ts +1 -3
- package/dist/harness/context/token-estimate-fns.js +2 -4
- package/dist/harness/context/token-estimator.d.ts +1 -1
- package/dist/harness/context/token-estimator.js +14 -6
- package/dist/harness/context/tool-result-aging.d.ts +140 -0
- package/dist/harness/context/tool-result-aging.js +331 -0
- package/dist/harness/context/tool-result-body.d.ts +10 -0
- package/dist/harness/context/tool-result-body.js +27 -0
- package/dist/harness/context/turn-envelope.d.ts +123 -0
- package/dist/harness/context/turn-envelope.js +188 -0
- package/dist/harness/context/types.d.ts +35 -47
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +248 -0
- package/dist/harness/extension/execution-environment/effect-policy.js +334 -0
- package/dist/harness/extension/execution-environment/index.d.ts +18 -2
- package/dist/harness/extension/execution-environment/index.js +11 -2
- package/dist/harness/extension/execution-environment/memory-undo.d.ts +101 -0
- package/dist/harness/extension/execution-environment/memory-undo.js +192 -0
- package/dist/harness/extension/execution-environment/process-isolation.d.ts +84 -0
- package/dist/harness/extension/execution-environment/process-isolation.js +315 -0
- package/dist/harness/extension/execution-environment/resource-limits.d.ts +36 -0
- package/dist/harness/extension/execution-environment/resource-limits.js +84 -0
- package/dist/harness/extension/execution-environment/sandbox.d.ts +125 -4
- package/dist/harness/extension/execution-environment/sandbox.js +493 -51
- package/dist/harness/extension/execution-environment/shell-journal.d.ts +100 -0
- package/dist/harness/extension/execution-environment/shell-journal.js +299 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.d.ts +45 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.js +126 -0
- package/dist/harness/extension/execution-environment/types.d.ts +67 -39
- package/dist/harness/extension/execution-environment/types.js +2 -2
- package/dist/harness/extension/execution-environment/undo-log.d.ts +203 -0
- package/dist/harness/extension/execution-environment/undo-log.js +627 -0
- package/dist/harness/extension/execution-environment/undo-merge.d.ts +40 -0
- package/dist/harness/extension/execution-environment/undo-merge.js +167 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/index.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/client-tools/types.d.ts +9 -0
- package/dist/harness/extension/plugin-ecosystem/mcp/bridge.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +1 -6
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +3 -8
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +2 -10
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +2 -9
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +1 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/index.js +1 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +2 -4
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +4 -21
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +3 -9
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +4 -8
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +1 -4
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +1 -3
- package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/skills/manager.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.d.ts +45 -0
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.js +136 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +18 -3
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +277 -81
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.d.ts +31 -0
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +291 -0
- package/dist/harness/extension/plugin-ecosystem/tools/document-tools.js +10 -2
- package/dist/harness/extension/plugin-ecosystem/tools/env-info.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/eol.d.ts +35 -0
- package/dist/harness/extension/plugin-ecosystem/tools/eol.js +43 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +40 -9
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.d.ts +33 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.js +376 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +12 -2
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +239 -61
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.d.ts +27 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +554 -0
- package/dist/harness/extension/plugin-ecosystem/tools/http.d.ts +10 -6
- package/dist/harness/extension/plugin-ecosystem/tools/http.js +41 -47
- package/dist/harness/extension/plugin-ecosystem/tools/index.d.ts +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/index.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +4 -0
- package/dist/harness/extension/plugin-ecosystem/tools/memory.js +25 -1
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.d.ts +13 -0
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +391 -0
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +51 -2
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +151 -12
- package/dist/harness/extension/plugin-ecosystem/tools/session-history.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +10 -1
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +35 -19
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +8 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +5 -0
- package/dist/harness/extension/plugin-ecosystem/tools/web-search.js +1 -0
- package/dist/harness/governance/credentials/index.d.ts +1 -1
- package/dist/harness/governance/credentials/store.d.ts +16 -4
- package/dist/harness/governance/credentials/store.js +33 -6
- package/dist/harness/governance/credentials/types.d.ts +11 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +105 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.js +184 -0
- package/dist/harness/governance/human-in-the-loop/index.d.ts +5 -5
- package/dist/harness/governance/human-in-the-loop/index.js +3 -3
- package/dist/harness/governance/human-in-the-loop/types.d.ts +7 -62
- package/dist/harness/governance/human-in-the-loop/types.js +6 -2
- package/dist/harness/governance/security/capability-enforcer.d.ts +9 -1
- package/dist/harness/governance/security/capability-enforcer.js +31 -8
- package/dist/harness/governance/security/degradation.js +5 -7
- package/dist/harness/governance/security/risk-evaluator.d.ts +1 -1
- package/dist/harness/governance/security/risk-evaluator.js +4 -82
- package/dist/harness/governance/security/temp-path.d.ts +41 -0
- package/dist/harness/governance/security/temp-path.js +117 -0
- package/dist/harness/governance/session-acl/index.d.ts +1 -0
- package/dist/harness/governance/session-acl/index.js +1 -0
- package/dist/harness/governance/session-acl/rights.d.ts +12 -0
- package/dist/harness/governance/session-acl/rights.js +89 -7
- package/dist/harness/governance/session-acl/seed-roles.js +9 -1
- package/dist/harness/governance/session-acl/service.js +21 -29
- package/dist/harness/governance/session-acl/tool-rights.d.ts +81 -0
- package/dist/harness/governance/session-acl/tool-rights.js +238 -0
- package/dist/harness/governance/session-acl/types.d.ts +22 -0
- package/dist/harness/index.d.ts +14 -12
- package/dist/harness/index.js +9 -6
- package/dist/harness/knowledge/file-index-store.js +11 -11
- package/dist/harness/knowledge/grounding.d.ts +2 -1
- package/dist/harness/knowledge/grounding.js +6 -3
- package/dist/harness/knowledge/index.d.ts +2 -2
- package/dist/harness/knowledge/index.js +1 -1
- package/dist/harness/knowledge/ingest.js +4 -1
- package/dist/harness/knowledge/job-control-state.js +4 -4
- package/dist/harness/knowledge/job-control.js +11 -11
- package/dist/harness/knowledge/membership-store.js +11 -11
- package/dist/harness/knowledge/network-guard.d.ts +61 -4
- package/dist/harness/knowledge/network-guard.js +390 -113
- package/dist/harness/knowledge/query-service.js +3 -3
- package/dist/harness/knowledge/writer-service.d.ts +2 -0
- package/dist/harness/knowledge/writer-service.js +14 -13
- package/dist/harness/memory/backfill-trigger.d.ts +2 -2
- package/dist/harness/memory/backfill-trigger.js +4 -4
- package/dist/harness/memory/index.d.ts +1 -0
- package/dist/harness/memory/index.js +1 -0
- package/dist/harness/memory/sqlite/agent-db.js +2 -0
- package/dist/harness/memory/sqlite/memory-store.d.ts +1 -0
- package/dist/harness/memory/sqlite/memory-store.js +14 -4
- package/dist/harness/memory/sqlite/wisdom-store.js +9 -9
- package/dist/harness/memory/store.d.ts +1 -0
- package/dist/harness/memory/store.js +3 -0
- package/dist/harness/memory/time-format.d.ts +28 -0
- package/dist/harness/memory/time-format.js +52 -0
- package/dist/harness/memory/types.d.ts +12 -0
- package/dist/harness/observability/observer/hub.js +23 -1
- package/dist/harness/observability/observer/index.d.ts +2 -2
- package/dist/harness/observability/observer/index.js +1 -1
- package/dist/harness/observability/observer/types.d.ts +57 -0
- package/dist/harness/observability/observer/types.js +118 -9
- package/dist/harness/run/agent/agent.d.ts +18 -0
- package/dist/harness/run/agent/agent.js +26 -0
- package/dist/harness/run/concurrency/tool-loop-detection-core.d.ts +1 -1
- package/dist/harness/run/concurrency/tool-loop-detection-core.js +1 -1
- package/dist/harness/run/reliability/harness-events.d.ts +4 -0
- package/dist/harness/run/reliability/run-agent.js +110 -18
- package/dist/harness/run/reliability/run-metrics-collector.d.ts +28 -2
- package/dist/harness/run/reliability/run-metrics-collector.js +92 -2
- package/dist/harness/run/run-guard/default-run-guard.d.ts +0 -5
- package/dist/harness/run/run-guard/default-run-guard.js +104 -44
- package/dist/harness/run/run-scope.d.ts +52 -0
- package/dist/harness/run/runner.d.ts +101 -16
- package/dist/harness/run/runner.js +556 -158
- package/dist/harness/session/attachments/llm-intent.js +17 -17
- package/dist/harness/session/history/port.js +1 -0
- package/dist/harness/session/in-memory-store.d.ts +1 -0
- package/dist/harness/session/in-memory-store.js +22 -1
- package/dist/harness/session/schedules/index.d.ts +10 -0
- package/dist/harness/session/schedules/index.js +10 -0
- package/dist/harness/session/schedules/render.d.ts +13 -0
- package/dist/harness/session/schedules/render.js +63 -0
- package/dist/harness/session/schedules/service.d.ts +179 -0
- package/dist/harness/session/schedules/service.js +695 -0
- package/dist/harness/session/schedules/store.d.ts +119 -0
- package/dist/harness/session/schedules/store.js +323 -0
- package/dist/harness/session/schedules/tools.d.ts +39 -0
- package/dist/harness/session/schedules/tools.js +442 -0
- package/dist/harness/session/schedules/types.d.ts +104 -0
- package/dist/harness/session/schedules/types.js +97 -0
- package/dist/harness/session/tasks/tools.js +22 -0
- package/dist/harness/session/types.d.ts +35 -0
- package/dist/harness/shared/events/agent-event-map.d.ts +13 -0
- package/dist/harness/shared/types/agent-definition.d.ts +23 -0
- package/dist/index.d.ts +23 -9
- package/dist/index.js +10 -2
- package/dist/integration/providers/anthropic.d.ts +10 -0
- package/dist/integration/providers/anthropic.js +44 -1
- package/dist/integration/providers/openai.d.ts +10 -0
- package/dist/integration/providers/openai.js +58 -2
- package/dist/integration/providers/wire-dump-diff.d.ts +191 -0
- package/dist/integration/providers/wire-dump-diff.js +351 -0
- package/dist/integration/providers/wire-dump.d.ts +178 -0
- package/dist/integration/providers/wire-dump.js +396 -0
- package/dist/integration/storage/jsonl.d.ts +11 -0
- package/dist/integration/storage/jsonl.js +148 -39
- package/dist/integration/storage/session-index.js +63 -8
- package/dist/subsystems/cognition-steward/conceptualize/SUBSYSTEM.md +43 -43
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +50 -50
- package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +6 -6
- package/dist/subsystems/cognition-steward/consolidate/config.yaml +54 -54
- package/dist/subsystems/memory-steward/backfill/handler.js +9 -0
- package/dist/subsystems/wisdom-steward/evaluate/config.yaml +50 -50
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +42 -42
- package/dist/subsystems/wisdom-steward/formation/config.yaml +54 -54
- package/dist/subsystems/wisdom-steward/govern/config.yaml +55 -55
- package/package.json +115 -115
- package/dist/harness/collaboration/multi-agent/agent-registry-types.d.ts +0 -144
- package/dist/harness/collaboration/multi-agent/agent-registry-types.js +0 -25
- package/dist/harness/collaboration/multi-agent/index.d.ts +0 -17
- package/dist/harness/collaboration/multi-agent/index.js +0 -15
- package/dist/harness/collaboration/multi-agent/process.d.ts +0 -167
- package/dist/harness/collaboration/multi-agent/process.js +0 -256
- package/dist/harness/collaboration/multi-agent/registry.d.ts +0 -36
- package/dist/harness/collaboration/multi-agent/registry.js +0 -137
- package/dist/harness/collaboration/multi-agent/swarm.d.ts +0 -135
- package/dist/harness/collaboration/multi-agent/swarm.js +0 -317
- package/dist/harness/collaboration/multi-agent/types.d.ts +0 -66
- package/dist/harness/collaboration/multi-agent/types.js +0 -15
- package/dist/harness/collaboration/orchestration/async-task-store.d.ts +0 -107
- package/dist/harness/collaboration/orchestration/async-task-store.js +0 -12
- package/dist/harness/collaboration/orchestration/async-task.d.ts +0 -156
- package/dist/harness/collaboration/orchestration/async-task.js +0 -359
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.d.ts +0 -47
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.js +0 -61
- package/dist/harness/collaboration/orchestration/planner/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/planner/index.js +0 -6
- package/dist/harness/collaboration/orchestration/planner/llm-planner.d.ts +0 -54
- package/dist/harness/collaboration/orchestration/planner/llm-planner.js +0 -167
- package/dist/harness/collaboration/orchestration/planner/rule-planner.d.ts +0 -85
- package/dist/harness/collaboration/orchestration/planner/rule-planner.js +0 -175
- package/dist/harness/collaboration/orchestration/quality/classifier.d.ts +0 -21
- package/dist/harness/collaboration/orchestration/quality/classifier.js +0 -235
- package/dist/harness/collaboration/orchestration/quality/gate.d.ts +0 -29
- package/dist/harness/collaboration/orchestration/quality/gate.js +0 -409
- package/dist/harness/collaboration/orchestration/quality/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/quality/index.js +0 -8
- package/dist/harness/collaboration/orchestration/quality/types.d.ts +0 -159
- package/dist/harness/collaboration/orchestration/quality/types.js +0 -33
- package/dist/harness/collaboration/orchestration/scheduler/index.d.ts +0 -5
- package/dist/harness/collaboration/orchestration/scheduler/index.js +0 -4
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.js +0 -297
- package/dist/harness/collaboration/orchestration/strategy/classifier.d.ts +0 -12
- package/dist/harness/collaboration/orchestration/strategy/classifier.js +0 -81
- package/dist/harness/collaboration/orchestration/strategy/index.d.ts +0 -3
- package/dist/harness/collaboration/orchestration/strategy/index.js +0 -2
- package/dist/harness/collaboration/orchestration/strategy/router.d.ts +0 -28
- package/dist/harness/collaboration/orchestration/strategy/router.js +0 -105
- package/dist/harness/collaboration/orchestration/strategy/types.d.ts +0 -49
- package/dist/harness/collaboration/orchestration/strategy/types.js +0 -4
- package/dist/harness/collaboration/orchestration/workflow/engine.d.ts +0 -86
- package/dist/harness/collaboration/orchestration/workflow/engine.js +0 -298
- package/dist/harness/collaboration/orchestration/workflow/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/workflow/index.js +0 -7
- package/dist/harness/collaboration/orchestration/workflow/types.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/workflow/types.js +0 -7
- package/dist/harness/governance/human-in-the-loop/approval-manager.d.ts +0 -32
- package/dist/harness/governance/human-in-the-loop/approval-manager.js +0 -93
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.d.ts +0 -0
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.js +0 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 历史工具结果批量冻结老化(F1-B2)— 视图级、零 LLM、write-once
|
|
3
|
+
*
|
|
4
|
+
* 语义(arch/long-session-latency.md §5 B2 + arch/b0-cache-stable-context.md §4):
|
|
5
|
+
* - **当前 run 永不老化**:最近一条真实 user 消息(排除引擎载体插槽)以来的工具结果全原文;
|
|
6
|
+
* - **近 `rawWindow` 条跨轮工具结果**保留原文;
|
|
7
|
+
* - 更旧的候选按 **`freezeBatch` 批量**降级为结构化指针(工具名 + 参数要点 + 结果轮廓 + re-run 提示);
|
|
8
|
+
* - **批量冻结(禁渐进老化)**:老化边界只以 `freezeBatch` 为步长成批推进,段间轮次视图
|
|
9
|
+
* 逐字节稳定——每轮在 recency 边界改写 1 条 = 把边界→尾部整段烧前缀缓存(B0 稿 §4);
|
|
10
|
+
* - **write-once**:指针按工具结果对象记忆化 + 纯函数定形,永不二次改写;
|
|
11
|
+
* ⚠️ 计划必须基于**完整历史**(append-only 的 session 消息序)计算,不能按被裁剪的
|
|
12
|
+
* 装配视图重算——视图收缩会让已降级条目回原文、批量边界来回翻转(评审 F1);
|
|
13
|
+
* - **视图级**:只影响发给 LLM 的消息视图(`buildLlmMessages`);session 持久层保原文。
|
|
14
|
+
*
|
|
15
|
+
* 红线(§4 能力红线):user / assistant **正文**永不降级;**error 结果永不降级**(错误可追溯性优先,
|
|
16
|
+
* 字段保真);不膨胀守卫——只有指针严格小于原文时才降级。
|
|
17
|
+
*
|
|
18
|
+
* tool_call 参数(`ageToolArgs`,默认开):**只对「结果已被老化」的那条调用**同步降级为键值摘要
|
|
19
|
+
* (长值换成长度标记,键名全保)。原因:参数是上下文中唯一无界增长的成分——结果老化成指针后
|
|
20
|
+
* 参数仍留原文,实测其总量可达指针本体的 1.1 倍,且随 session 线性增长。
|
|
21
|
+
* 降级不改变 tool_call ↔ tool_result 配对结构(`id`/`name` 不动,`arguments` 仍是合法 JSON)。
|
|
22
|
+
*
|
|
23
|
+
* @module harness/context/tool-result-aging
|
|
24
|
+
*/
|
|
25
|
+
import { isEngineCarrierSource } from './layer-types.js';
|
|
26
|
+
import { toolResultBody } from './tool-result-body.js';
|
|
27
|
+
/** args / result 轮廓占 maxPointerChars 的比例(合计 ~0.65,加固定骨架 ≈ 目标) */
|
|
28
|
+
const ARGS_OUTLINE_RATIO = 0.2;
|
|
29
|
+
const RESULT_OUTLINE_RATIO = 0.45;
|
|
30
|
+
/** 轮廓下限(小旋钮下仍可读) */
|
|
31
|
+
const MIN_ARGS_OUTLINE_CHARS = 24;
|
|
32
|
+
const MIN_RESULT_OUTLINE_CHARS = 48;
|
|
33
|
+
/**
|
|
34
|
+
* 参数摘要中「原样保留」的单个值上限
|
|
35
|
+
*
|
|
36
|
+
* 只用来区分「标识性短值」(路径、命令、行号)与「载荷长值」(文件内容、diff 正文)。
|
|
37
|
+
* 64 足以容纳常见路径,又远小于任何文件内容。
|
|
38
|
+
*/
|
|
39
|
+
const ARG_VALUE_KEEP_CHARS = 64;
|
|
40
|
+
const TRUNCATION_MARK = '…[truncated]';
|
|
41
|
+
/**
|
|
42
|
+
* 解析老化配置(缺省 = 拍板参数起点:40 条原文 / 批 20 / 指针 400 字符)
|
|
43
|
+
*
|
|
44
|
+
* @param input - 配置面输入(可空)
|
|
45
|
+
* @returns 全字段解析结果(非法值/0 步长回落缺省——0 或负步长等同禁用批量冻结)
|
|
46
|
+
*/
|
|
47
|
+
export function resolveToolResultAgingOptions(input) {
|
|
48
|
+
const rawWindow = Number.isInteger(input?.rawWindow) && (input?.rawWindow ?? -1) >= 0 ? input.rawWindow : 40;
|
|
49
|
+
const freezeBatch = Number.isInteger(input?.freezeBatch) && (input?.freezeBatch ?? -1) >= 1 ? input.freezeBatch : 40;
|
|
50
|
+
const maxPointerChars = Number.isInteger(input?.maxPointerChars) && (input?.maxPointerChars ?? -1) > 0 ? input.maxPointerChars : 400;
|
|
51
|
+
const maxAgedArgChars = Number.isInteger(input?.maxAgedArgChars) && (input?.maxAgedArgChars ?? -1) > 0
|
|
52
|
+
? input.maxAgedArgChars
|
|
53
|
+
: 320;
|
|
54
|
+
return {
|
|
55
|
+
enabled: input?.enabled ?? true,
|
|
56
|
+
rawWindow,
|
|
57
|
+
freezeBatch,
|
|
58
|
+
maxPointerChars,
|
|
59
|
+
ageToolArgs: input?.ageToolArgs ?? true,
|
|
60
|
+
maxAgedArgChars,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 计算老化计划:批量冻结边界 + 工具调用参数索引
|
|
65
|
+
*
|
|
66
|
+
* 边界语义:跨轮工具结果(位于最近一条真实 user 消息之前)中,最旧的
|
|
67
|
+
* `crossTurn - rawWindow` 条为候选;候选前 `freezeBatch` 整批部分「过冻结线」。
|
|
68
|
+
* 过线条目再过三道守卫才降级:error 永不降级;正文 ≤ 指针目标不降级;
|
|
69
|
+
* 实际指针不比原文短不降级(不膨胀)。历史只增不减时边界单调推进、
|
|
70
|
+
* 已降级条目永不回原文——满足 write-once(须以完整历史为输入,见模块头注)。
|
|
71
|
+
*
|
|
72
|
+
* @param messages - **完整**历史消息(按时间序;勿传裁剪后的装配视图)
|
|
73
|
+
* @param opts - 老化配置(已解析)
|
|
74
|
+
* @returns 老化计划(enabled=false 或无候选时 agedIds 为空)
|
|
75
|
+
*/
|
|
76
|
+
export function computeToolResultAgingPlan(messages, opts) {
|
|
77
|
+
const argsById = new Map();
|
|
78
|
+
const ordered = [];
|
|
79
|
+
let lastGenuineUserIdx = -1;
|
|
80
|
+
for (let i = 0; i < messages.length; i++) {
|
|
81
|
+
const msg = messages[i];
|
|
82
|
+
if (msg.role === 'user' && !isEngineCarrierSource(msg.metadata?.source)) {
|
|
83
|
+
lastGenuineUserIdx = i;
|
|
84
|
+
}
|
|
85
|
+
for (const tc of msg.toolCalls ?? []) {
|
|
86
|
+
argsById.set(tc.id, tc.arguments);
|
|
87
|
+
}
|
|
88
|
+
for (const tr of msg.toolResults ?? []) {
|
|
89
|
+
ordered.push({
|
|
90
|
+
toolCallId: tr.toolCallId,
|
|
91
|
+
msgIndex: i,
|
|
92
|
+
bodyLength: toolResultBody(tr).length,
|
|
93
|
+
isError: tr.error !== undefined,
|
|
94
|
+
tr,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const agedIds = new Set();
|
|
99
|
+
if (!opts.enabled)
|
|
100
|
+
return { agedIds, argsById };
|
|
101
|
+
// 边界 = 完整历史最后一个真实 user(两遍判定:旧轮结果在遇到后续 user 前不可下结论)
|
|
102
|
+
const crossTurn = ordered.filter((e) => e.msgIndex < lastGenuineUserIdx);
|
|
103
|
+
const candidates = crossTurn.slice(0, Math.max(0, crossTurn.length - opts.rawWindow));
|
|
104
|
+
const covered = candidates.length - (candidates.length % opts.freezeBatch);
|
|
105
|
+
for (let i = 0; i < covered; i++) {
|
|
106
|
+
const cand = candidates[i];
|
|
107
|
+
if (cand.isError)
|
|
108
|
+
continue; // 红线:error 结果永不降级(错误可追溯性优先)
|
|
109
|
+
if (cand.bodyLength <= opts.maxPointerChars)
|
|
110
|
+
continue; // 预筛:小于指针目标不值得
|
|
111
|
+
const pointer = agedToolResultPointer(cand.tr, argsById.get(cand.toolCallId), opts);
|
|
112
|
+
if (pointer.length < cand.bodyLength) {
|
|
113
|
+
agedIds.add(cand.toolCallId);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return { agedIds, argsById };
|
|
117
|
+
}
|
|
118
|
+
// 指针 write-once 缓存:同 `tr` 对象 + 同配置指纹 → 同字节(toolResultBody 同款 WeakMap 先例;
|
|
119
|
+
// 消息内容写入后不可变,对象身份稳定;即便对象重建,纯函数定形也保证字节一致)。
|
|
120
|
+
const pointerCache = new WeakMap();
|
|
121
|
+
/**
|
|
122
|
+
* 把老化计划物化为消息视图副本(新建对象,不改原消息)
|
|
123
|
+
*
|
|
124
|
+
* 供「量实际请求」的估算路径使用(F1-B3:主动压缩触发线必须量老化后的视图,
|
|
125
|
+
* 否则 B2 稳态的 raw 估算会每 turn 误触发 compact = 双机制打架)。
|
|
126
|
+
* 压缩/摘要输入仍用原消息(摘要质量需要原文)。
|
|
127
|
+
*
|
|
128
|
+
* @param messages - 完整历史消息
|
|
129
|
+
* @param plan - 老化计划
|
|
130
|
+
* @param opts - 老化配置(已解析)
|
|
131
|
+
* @returns 消息副本(老化条目的正文替换为指针;无老化条目时原样返回同一数组)
|
|
132
|
+
*/
|
|
133
|
+
export function applyAgingToMessages(messages, plan, opts) {
|
|
134
|
+
if (plan.agedIds.size === 0)
|
|
135
|
+
return messages;
|
|
136
|
+
return messages.map((msg) => {
|
|
137
|
+
let next = msg;
|
|
138
|
+
// 参数与结果同步老化:只动「结果已老化」的那条调用,配对结构不变
|
|
139
|
+
if (opts.ageToolArgs && msg.toolCalls?.length) {
|
|
140
|
+
let callsChanged = false;
|
|
141
|
+
const toolCalls = msg.toolCalls.map((tc) => {
|
|
142
|
+
if (!plan.agedIds.has(tc.id))
|
|
143
|
+
return tc;
|
|
144
|
+
callsChanged = true;
|
|
145
|
+
return { ...tc, arguments: agedToolArgDigest(tc.name, tc.arguments, opts) };
|
|
146
|
+
});
|
|
147
|
+
if (callsChanged)
|
|
148
|
+
next = { ...next, toolCalls };
|
|
149
|
+
}
|
|
150
|
+
if (!msg.toolResults?.length)
|
|
151
|
+
return next;
|
|
152
|
+
let changed = false;
|
|
153
|
+
const results = msg.toolResults.map((tr) => {
|
|
154
|
+
if (!plan.agedIds.has(tr.toolCallId))
|
|
155
|
+
return tr;
|
|
156
|
+
changed = true;
|
|
157
|
+
return {
|
|
158
|
+
...tr,
|
|
159
|
+
result: agedToolResultPointer(tr, plan.argsById.get(tr.toolCallId), opts),
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
return changed ? { ...next, toolResults: results } : next;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* 生成结构化摘要指针(机械、零 LLM、确定性)
|
|
167
|
+
*
|
|
168
|
+
* 布局:工具名 + args 轮廓(截断)+ result 轮廓(截断)+ re-run 提示;
|
|
169
|
+
* 轮廓预算按 `maxPointerChars` 比例派生(旋钮真实生效)。
|
|
170
|
+
* error 分支为防御性保真(计划永不选中 error 结果)。
|
|
171
|
+
*
|
|
172
|
+
* @param tr - 工具结果(error / result 至少其一)
|
|
173
|
+
* @param args - 对应工具调用参数(可空)
|
|
174
|
+
* @param opts - 老化配置(已解析)
|
|
175
|
+
* @returns 指针文本(write-once:同输入恒同字节)
|
|
176
|
+
*/
|
|
177
|
+
export function agedToolResultPointer(tr, args, opts) {
|
|
178
|
+
const fingerprint = `${opts.maxPointerChars}|${args === undefined ? '' : JSON.stringify(args)}|${tr.error !== undefined ? 'e' : 'r'}`;
|
|
179
|
+
const cached = pointerCache.get(tr);
|
|
180
|
+
if (cached && cached.fingerprint === fingerprint)
|
|
181
|
+
return cached.text;
|
|
182
|
+
const argsBudget = Math.max(MIN_ARGS_OUTLINE_CHARS, Math.floor(opts.maxPointerChars * ARGS_OUTLINE_RATIO));
|
|
183
|
+
const resultBudget = Math.max(MIN_RESULT_OUTLINE_CHARS, Math.floor(opts.maxPointerChars * RESULT_OUTLINE_RATIO));
|
|
184
|
+
const argsOutline = truncateOutline(safeJson(args ?? {}), argsBudget);
|
|
185
|
+
// 结果轮廓只保留头部,若不给总量,读方会把「头部那几条」误当成全部(file_search 尤甚)
|
|
186
|
+
const resultBody = toolResultOutline(tr);
|
|
187
|
+
const errorOrResult = tr.error !== undefined
|
|
188
|
+
? `error: ${tr.error}` // 防御性保真:错误文案不截断、不改写
|
|
189
|
+
: `result ${resultBody.length} chars: ${truncateOutline(resultBody, resultBudget)}`;
|
|
190
|
+
const text = `[aged tool result · pointer] tool: ${tr.name ?? 'unknown'}; ` +
|
|
191
|
+
`args: ${argsOutline}; ${errorOrResult}; ` +
|
|
192
|
+
'full output kept in session log — do NOT re-run unless the output is needed again';
|
|
193
|
+
pointerCache.set(tr, { fingerprint, text });
|
|
194
|
+
return text;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* 参数摘要:把「结果已被老化」的工具调用参数降级为键值摘要
|
|
198
|
+
*
|
|
199
|
+
* 规则(机械、确定性、无 LLM):
|
|
200
|
+
* 1. **键名全保**——LLM 需要知道调用了哪个路径/命令才能在必要时重跑;
|
|
201
|
+
* 2. 序列化长度超过 {@link ARG_VALUE_KEEP_CHARS} 的值替换为长度标记 `…[N chars]`;
|
|
202
|
+
* 3. 若仍是超预算,按「值从大到小、同大小按键名」顺序继续替换,保证确定性;
|
|
203
|
+
* 4. 兜底:键名太多装不下时退化为整体轮廓截断。
|
|
204
|
+
*
|
|
205
|
+
* 返回值仍是合法 JSON 值,调用方照常 `JSON.stringify`,因此 tool_call 结构不变。
|
|
206
|
+
*
|
|
207
|
+
* @param name - 工具名(兜底分支用于说明来源)
|
|
208
|
+
* @param args - 原始调用参数(任意 JSON 值)
|
|
209
|
+
* @param opts - 老化配置(已解析)
|
|
210
|
+
* @returns 摘要值(`ageToolArgs=false` 时原样返回)
|
|
211
|
+
*/
|
|
212
|
+
export function agedToolArgDigest(name, args, opts) {
|
|
213
|
+
if (!opts.ageToolArgs || args == null)
|
|
214
|
+
return args;
|
|
215
|
+
if (typeof args !== 'object' || Array.isArray(args)) {
|
|
216
|
+
return { _aged: `${name} arguments elided`, outline: truncateOutline(safeJson(args), opts.maxAgedArgChars) };
|
|
217
|
+
}
|
|
218
|
+
const cached = argDigestCache.get(args);
|
|
219
|
+
const fingerprint = `${opts.maxAgedArgChars}`;
|
|
220
|
+
if (cached && cached.fingerprint === fingerprint)
|
|
221
|
+
return cached.value;
|
|
222
|
+
const entries = Object.entries(args).map(([k, v]) => ({
|
|
223
|
+
k,
|
|
224
|
+
v,
|
|
225
|
+
size: safeJson(v).length,
|
|
226
|
+
}));
|
|
227
|
+
const out = {};
|
|
228
|
+
for (const e of entries) {
|
|
229
|
+
out[e.k] = digestArgValue(e.k, e.v, e.size);
|
|
230
|
+
}
|
|
231
|
+
// 预算只约束「内容值」,定位字段不计入:
|
|
232
|
+
// 否则一条绝对路径就能吃掉整个预算,反而先把唯一锚点挤掉(实测 path 均长 79,
|
|
233
|
+
// 若计入预算,file_edit 这类调用会退化成「看不到改了哪个文件」)。
|
|
234
|
+
const contentChars = () => safeJson(Object.fromEntries(Object.entries(out).filter(([k]) => !ANCHOR_FIELDS.has(k)))).length;
|
|
235
|
+
const contentEntries = entries
|
|
236
|
+
.filter((e) => !ANCHOR_FIELDS.has(e.k))
|
|
237
|
+
.sort((a, b) => b.size - a.size || (a.k < b.k ? -1 : a.k > b.k ? 1 : 0));
|
|
238
|
+
for (const e of contentEntries) {
|
|
239
|
+
if (contentChars() <= opts.maxAgedArgChars)
|
|
240
|
+
break;
|
|
241
|
+
out[e.k] = elidedMarker(e.size);
|
|
242
|
+
}
|
|
243
|
+
const value = contentChars() > opts.maxAgedArgChars
|
|
244
|
+
? { _aged: `${name} arguments elided`, outline: truncateOutline(safeJson(args), opts.maxAgedArgChars) }
|
|
245
|
+
: out;
|
|
246
|
+
argDigestCache.set(args, { fingerprint, value });
|
|
247
|
+
return value;
|
|
248
|
+
}
|
|
249
|
+
/** 值被省略时的长度标记 */
|
|
250
|
+
function elidedMarker(chars) {
|
|
251
|
+
return `…[${chars} chars]`;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* 定位字段:它们短、且是「这条调用到底碰了哪里」的唯一锚点,优先全保
|
|
255
|
+
*
|
|
256
|
+
* 实测:`path` 均长 79 字符(全保仅 +1.5% 请求体),而 `command` 均长 414
|
|
257
|
+
* (全保 +8.6%)。因此路径类全保、命令类只留头部。
|
|
258
|
+
*/
|
|
259
|
+
const LOCATOR_FIELDS = new Set(['path', 'file', 'glob', 'pattern', 'cwd']);
|
|
260
|
+
/**
|
|
261
|
+
* 锚点字段:不占用内容预算(否则定位信息会被内容载荷挤出)
|
|
262
|
+
*
|
|
263
|
+
* 定位字段与命令字段都属锚点——`command` 头部回答「跑了什么」,
|
|
264
|
+
* 若让它和 `old_text` 之类抢同一个预算,多条命令一累加就会把头部整体省略掉。
|
|
265
|
+
*/
|
|
266
|
+
const ANCHOR_FIELDS = new Set([...LOCATOR_FIELDS, 'command', 'cmd']);
|
|
267
|
+
/** 定位字段全保上限(超长的罕见路径才会退化为标记) */
|
|
268
|
+
const LOCATOR_KEEP_CHARS = 200;
|
|
269
|
+
/** 命令类字段保留的头部长度(其余用长度标记收尾) */
|
|
270
|
+
const COMMAND_HEAD_CHARS = 100;
|
|
271
|
+
/** 命令类字段名 */
|
|
272
|
+
const COMMAND_FIELDS = new Set(['command', 'cmd']);
|
|
273
|
+
function isLocatorField(key) {
|
|
274
|
+
return LOCATOR_FIELDS.has(key);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* 单个参数值的降级策略(确定性、与顺序无关)
|
|
278
|
+
*
|
|
279
|
+
* @param key - 字段名
|
|
280
|
+
* @param value - 字段值
|
|
281
|
+
* @param size - 值的 JSON 序列化长度
|
|
282
|
+
* @returns 保留原值、头部摘录或长度标记
|
|
283
|
+
*/
|
|
284
|
+
function digestArgValue(key, value, size) {
|
|
285
|
+
if (size <= ARG_VALUE_KEEP_CHARS)
|
|
286
|
+
return value;
|
|
287
|
+
if (isLocatorField(key) && size <= LOCATOR_KEEP_CHARS)
|
|
288
|
+
return value;
|
|
289
|
+
if (COMMAND_FIELDS.has(key) && typeof value === 'string') {
|
|
290
|
+
// 短命令原样保留;长命令保留头部(头部才是「跑了什么」的判据)
|
|
291
|
+
if (value.length <= COMMAND_HEAD_CHARS)
|
|
292
|
+
return value;
|
|
293
|
+
return `${value.slice(0, COMMAND_HEAD_CHARS)}…[+${value.length - COMMAND_HEAD_CHARS} chars]`;
|
|
294
|
+
}
|
|
295
|
+
return elidedMarker(size);
|
|
296
|
+
}
|
|
297
|
+
// 参数摘要 write-once 缓存:同 args 对象 + 同配置 → 同值(与 pointerCache 同理)
|
|
298
|
+
const argDigestCache = new WeakMap();
|
|
299
|
+
/**
|
|
300
|
+
* 结果轮廓:结果正文序列化的头部(机械截断,非摘要改写)
|
|
301
|
+
*
|
|
302
|
+
* @param tr - 工具结果
|
|
303
|
+
* @returns 序列化正文(string result 原文;否则 JSON)
|
|
304
|
+
*/
|
|
305
|
+
function toolResultOutline(tr) {
|
|
306
|
+
return typeof tr.result === 'string' ? tr.result : safeJson(tr.result ?? null);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* JSON 序列化(异常时降级为 String(),不抛错)
|
|
310
|
+
*
|
|
311
|
+
* @param value - 任意值
|
|
312
|
+
* @returns JSON 字符串
|
|
313
|
+
*/
|
|
314
|
+
function safeJson(value) {
|
|
315
|
+
try {
|
|
316
|
+
return JSON.stringify(value) ?? String(value);
|
|
317
|
+
}
|
|
318
|
+
catch {
|
|
319
|
+
return String(value);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* 机械截断轮廓(超长加显式标记;机械截断 ≠ 摘要改写)
|
|
324
|
+
*
|
|
325
|
+
* @param text - 原文
|
|
326
|
+
* @param maxChars - 轮廓字符上限
|
|
327
|
+
* @returns 轮廓文本
|
|
328
|
+
*/
|
|
329
|
+
function truncateOutline(text, maxChars) {
|
|
330
|
+
return text.length <= maxChars ? text : `${text.slice(0, maxChars)}${TRUNCATION_MARK}`;
|
|
331
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* toolResultBody — 工具结果正文序列化(带缓存)
|
|
3
|
+
*
|
|
4
|
+
* 消息内容写入后不可变(全库无对已存在消息 content/toolResults/toolCalls 的
|
|
5
|
+
* 原地修改;压缩器一律新建对象),同一 `tr` 对象可安全复用序列化结果。
|
|
6
|
+
* 这消除每轮 context 装配里对同一批 toolResults 反复 `JSON.stringify` 的开销。
|
|
7
|
+
*/
|
|
8
|
+
const cache = new WeakMap();
|
|
9
|
+
/**
|
|
10
|
+
* 序列化工具结果正文:error → `{"error":...}`;string result 原文;否则 JSON。
|
|
11
|
+
*
|
|
12
|
+
* @param tr - 工具结果(error / result 至少其一)
|
|
13
|
+
* @returns 正文字符串
|
|
14
|
+
*/
|
|
15
|
+
export function toolResultBody(tr) {
|
|
16
|
+
const key = tr;
|
|
17
|
+
const hit = cache.get(key);
|
|
18
|
+
if (hit !== undefined)
|
|
19
|
+
return hit;
|
|
20
|
+
const body = tr.error !== undefined
|
|
21
|
+
? JSON.stringify({ error: tr.error })
|
|
22
|
+
: typeof tr.result === 'string'
|
|
23
|
+
? tr.result
|
|
24
|
+
: JSON.stringify(tr.result ?? null);
|
|
25
|
+
cache.set(key, body);
|
|
26
|
+
return body;
|
|
27
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn start/end 信封(全回放 · append-only)
|
|
3
|
+
*
|
|
4
|
+
* 语法(唯一合法形态,无 legacy 分支):
|
|
5
|
+
* - 开 turn:user 消息正文 = `<turn_start id at>…<user_message>…</user_message></turn_start>`
|
|
6
|
+
* - 闭 turn:独立消息 `<turn_end id/>`,`metadata.source='turnEnd'`
|
|
7
|
+
*
|
|
8
|
+
* 不变式:每个 `turn_start.id` ⟺ 恰一条 `turn_end.id`;定形后字节冻结。
|
|
9
|
+
* 正文经 XML 转义嵌入,用户原文不得截断信封。
|
|
10
|
+
*/
|
|
11
|
+
import type { Message } from '@octopi-agent/core/types.js';
|
|
12
|
+
/** turn_start 元素的 id 形态(会话内单调 t1,t2,…) */
|
|
13
|
+
export declare function formatTurnId(seq: number): string;
|
|
14
|
+
/** 归一化 Message.content → 纯文本(多模态取 text 块拼接;空 content → '') */
|
|
15
|
+
export declare function messageText(content: Message['content'] | undefined | null): string;
|
|
16
|
+
/** user 原文嵌入 XML 前的最小转义(防伪影标签截断信封) */
|
|
17
|
+
export declare function escapeUserMessageText(text: string): string;
|
|
18
|
+
/** 解转义(extractUserMessageText 出口) */
|
|
19
|
+
export declare function unescapeUserMessageText(text: string): string;
|
|
20
|
+
/** 开 turn 信封:一次定形后的 user 消息正文 */
|
|
21
|
+
export declare function formatTurnStartContent(params: {
|
|
22
|
+
turnId: string;
|
|
23
|
+
/** ISO 或已格式化时间,写入一次 */
|
|
24
|
+
at: string;
|
|
25
|
+
/** `<turn_context>…</turn_context>` 整段(含 boilerplate) */
|
|
26
|
+
turnContextXml: string;
|
|
27
|
+
/** 用户原文(将被 XML 转义后放入 user_message) */
|
|
28
|
+
userText: string;
|
|
29
|
+
}): string;
|
|
30
|
+
/** 闭 turn 消息正文(write-once) */
|
|
31
|
+
export declare function formatTurnEndContent(turnId: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* 构造 turn_context 块(ephemeral 语义 + 各槽位)。
|
|
34
|
+
* boilerplate **禁止**出现字面量 `<user_message>` / `</user_message>`(解析取最后一块)。
|
|
35
|
+
*/
|
|
36
|
+
export declare function formatTurnContextXml(params: {
|
|
37
|
+
turnId: string;
|
|
38
|
+
/** 已拼好的槽位正文(runtime_snapshot / grounding / attachments);可空 */
|
|
39
|
+
slotsXml: string;
|
|
40
|
+
}): string;
|
|
41
|
+
/**
|
|
42
|
+
* 从 turn_start 正文取出用户原文供检索 / UI / 摘要。
|
|
43
|
+
* 非 turn_start 正文原样返回。
|
|
44
|
+
* 取**最后一个** user_message 块(boilerplate 禁止再写该标签字面量)。
|
|
45
|
+
*/
|
|
46
|
+
export declare function extractUserMessageText(content: string | Message['content'] | undefined | null): string;
|
|
47
|
+
/**
|
|
48
|
+
* 剥掉 `<turn_context>…</turn_context>`(摘要语义输入 / UI)。
|
|
49
|
+
* 保留 `<user_message>` 与 turn_start/turn_end 骨架(或在 UI 场景配合 extractUserMessageText)。
|
|
50
|
+
*/
|
|
51
|
+
export declare function stripTurnContextXml(content: string | Message['content'] | undefined | null): string;
|
|
52
|
+
/**
|
|
53
|
+
* 是否 turn_start 正文(接受 string 或 Message.content)。
|
|
54
|
+
*
|
|
55
|
+
* 判形锚定到**正文开头**(允许前导空白):真实信封由 formatTurnStartContent 定形、必然以开标签起头;
|
|
56
|
+
* 正文中途引用标签字面量(讨论协议/贴日志/知识语料)不得命中——否则普通 user 发言会被
|
|
57
|
+
* 写一次守卫误判「已定形」(NEXT-STEPS D7)。
|
|
58
|
+
*/
|
|
59
|
+
export declare function isTurnStartContent(content: string | Message['content'] | undefined | null): boolean;
|
|
60
|
+
/** 是否 turn_end 正文(同 isTurnStartContent:锚定正文开头,防止字面量误判) */
|
|
61
|
+
export declare function isTurnEndContent(content: string | Message['content'] | undefined | null): boolean;
|
|
62
|
+
/** 从 turn_start / turn_end 正文解析 id */
|
|
63
|
+
export declare function parseTurnIdFromContent(content: string | Message['content'] | undefined | null): string | undefined;
|
|
64
|
+
/** turn_context 内的槽位段(机器生成块,非用户发言) */
|
|
65
|
+
export interface TurnEnvelopeSlot {
|
|
66
|
+
/** 槽位标签(runtime_snapshot / session_attachments / knowledge_grounding) */
|
|
67
|
+
tag: string;
|
|
68
|
+
/** 槽位正文(不含包裹标签,已 trim) */
|
|
69
|
+
body: string;
|
|
70
|
+
}
|
|
71
|
+
/** turn_start 信封解析结果 */
|
|
72
|
+
export interface TurnEnvelopeParts {
|
|
73
|
+
/** `<turn_start id>`;缺失时 undefined */
|
|
74
|
+
turnId?: string;
|
|
75
|
+
/** `<turn_start at>`;缺失时 undefined */
|
|
76
|
+
at?: string;
|
|
77
|
+
/** turn_context 内槽位(boilerplate 不计;白名单外标签跳过;按出现顺序) */
|
|
78
|
+
slots: TurnEnvelopeSlot[];
|
|
79
|
+
/** `<user_message>` 正文(已解转义);块缺失时为 ''(坏信封不回退整段原文冒充用户发言) */
|
|
80
|
+
userText: string;
|
|
81
|
+
/** 是否含 `<user_message>` 块(false = 信封不完整,UI 应标注而非把整封当用户原文) */
|
|
82
|
+
hasUserMessage: boolean;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 槽位标签集(**转义清单的唯一真源**):joinSlotXml 生产、escapeSlotBody 定向转义、
|
|
86
|
+
* parseTurnEnvelope 白名单三处同源引用——新增槽位必须进此表,转义与白名单随之生效。
|
|
87
|
+
* 白名单外的同形标签视为正文噪音 / 注入尝试。
|
|
88
|
+
*/
|
|
89
|
+
export declare const SLOT_TAGS: readonly ["runtime_snapshot", "session_attachments", "knowledge_grounding"];
|
|
90
|
+
export type SlotTag = (typeof SLOT_TAGS)[number];
|
|
91
|
+
/**
|
|
92
|
+
* 槽位正文定向转义(D7 方案 A′):把正文里的同名开/闭标签字面量转义为 XML 实体,
|
|
93
|
+
* 防语料(知识 / grounding / 附件)伪造闭合提前截断槽位、或伪造新槽位条目。
|
|
94
|
+
* 只动 `<tag>` / `</tag>` / `<tag ` 三种序列;其余内容(含其他合法 XML)原样保留。
|
|
95
|
+
*
|
|
96
|
+
* @param tag - 槽位标签(配合 SLOT_TAGS 使用)
|
|
97
|
+
* @param body - 槽位正文
|
|
98
|
+
* @returns 同名字面量已转义的正文
|
|
99
|
+
*/
|
|
100
|
+
export declare function escapeSlotBody(tag: string, body: string): string;
|
|
101
|
+
/**
|
|
102
|
+
* 解析 turn_start 信封(槽位 + 用户原文)。
|
|
103
|
+
*
|
|
104
|
+
* 入口判形锚定正文开头(同 isTurnStartContent);turn_context 取**最后一块**
|
|
105
|
+
* (与 extractUserMessageText 取最后一个 user_message 同口径);槽位只认
|
|
106
|
+
* SLOT_TAGS 白名单(防正文伪影伪造任意槽位条目)。
|
|
107
|
+
*
|
|
108
|
+
* @param content - 消息正文(string 或 Message.content)
|
|
109
|
+
* @returns 信封解析结果;非 turn_start 正文返回 null
|
|
110
|
+
*/
|
|
111
|
+
export declare function parseTurnEnvelope(content: string | Message['content'] | undefined | null): TurnEnvelopeParts | null;
|
|
112
|
+
/**
|
|
113
|
+
* 拼 turn_context 内的槽位 XML(runner 注入)。
|
|
114
|
+
* 正文经 escapeSlotBody 定向转义(D7 A′):语料同名字面量不得产出解析器眼里的标签,
|
|
115
|
+
* 防提前闭合 / 伪造槽位;tag 必须属于 SLOT_TAGS(转义清单唯一真源)。
|
|
116
|
+
* @param parts - 非空槽位段;空段被跳过
|
|
117
|
+
*/
|
|
118
|
+
export declare function joinSlotXml(parts: Array<{
|
|
119
|
+
tag: string;
|
|
120
|
+
body: string;
|
|
121
|
+
}>): string;
|
|
122
|
+
/** 任意 content 归一化后的用户正文(UI / 载体扫描共用) */
|
|
123
|
+
export declare function unwrapUserText(content: string | Message['content'] | undefined | null): string;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn start/end 信封(全回放 · append-only)
|
|
3
|
+
*
|
|
4
|
+
* 语法(唯一合法形态,无 legacy 分支):
|
|
5
|
+
* - 开 turn:user 消息正文 = `<turn_start id at>…<user_message>…</user_message></turn_start>`
|
|
6
|
+
* - 闭 turn:独立消息 `<turn_end id/>`,`metadata.source='turnEnd'`
|
|
7
|
+
*
|
|
8
|
+
* 不变式:每个 `turn_start.id` ⟺ 恰一条 `turn_end.id`;定形后字节冻结。
|
|
9
|
+
* 正文经 XML 转义嵌入,用户原文不得截断信封。
|
|
10
|
+
*/
|
|
11
|
+
import { getTextContent } from '@octopi-agent/core/types.js';
|
|
12
|
+
/** turn_start 元素的 id 形态(会话内单调 t1,t2,…) */
|
|
13
|
+
export function formatTurnId(seq) {
|
|
14
|
+
return `t${seq}`;
|
|
15
|
+
}
|
|
16
|
+
/** 归一化 Message.content → 纯文本(多模态取 text 块拼接;空 content → '') */
|
|
17
|
+
export function messageText(content) {
|
|
18
|
+
if (content == null)
|
|
19
|
+
return '';
|
|
20
|
+
return getTextContent(content);
|
|
21
|
+
}
|
|
22
|
+
/** user 原文嵌入 XML 前的最小转义(防伪影标签截断信封) */
|
|
23
|
+
export function escapeUserMessageText(text) {
|
|
24
|
+
return text
|
|
25
|
+
.replace(/&/g, '&')
|
|
26
|
+
.replace(/</g, '<')
|
|
27
|
+
.replace(/>/g, '>');
|
|
28
|
+
}
|
|
29
|
+
/** 解转义(extractUserMessageText 出口) */
|
|
30
|
+
export function unescapeUserMessageText(text) {
|
|
31
|
+
return text
|
|
32
|
+
.replace(/</g, '<')
|
|
33
|
+
.replace(/>/g, '>')
|
|
34
|
+
.replace(/&/g, '&');
|
|
35
|
+
}
|
|
36
|
+
/** 开 turn 信封:一次定形后的 user 消息正文 */
|
|
37
|
+
export function formatTurnStartContent(params) {
|
|
38
|
+
return (`<turn_start id="${params.turnId}" at="${params.at}">\n` +
|
|
39
|
+
`${params.turnContextXml.trim()}\n` +
|
|
40
|
+
`<user_message>\n${escapeUserMessageText(params.userText)}\n</user_message>\n` +
|
|
41
|
+
`</turn_start>`);
|
|
42
|
+
}
|
|
43
|
+
/** 闭 turn 消息正文(write-once) */
|
|
44
|
+
export function formatTurnEndContent(turnId) {
|
|
45
|
+
return `<turn_end id="${turnId}"/>`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 构造 turn_context 块(ephemeral 语义 + 各槽位)。
|
|
49
|
+
* boilerplate **禁止**出现字面量 `<user_message>` / `</user_message>`(解析取最后一块)。
|
|
50
|
+
*/
|
|
51
|
+
export function formatTurnContextXml(params) {
|
|
52
|
+
const boilerplate = `[turn-scoped · ephemeral · ${params.turnId}]\n` +
|
|
53
|
+
`Picks and snapshots below apply ONLY to the user text in this same turn.\n` +
|
|
54
|
+
`They are not durable memory. Do not carry them forward as facts.\n` +
|
|
55
|
+
`A later turn_context supersedes these picks for new work.\n` +
|
|
56
|
+
`Transcript beats any stale pick.`;
|
|
57
|
+
const slots = params.slotsXml.trim();
|
|
58
|
+
return (`<turn_context authority="ephemeral" applies_to="this-turn-only" supersession="later-turn-wins">\n` +
|
|
59
|
+
`<boilerplate>\n${boilerplate}\n</boilerplate>\n` +
|
|
60
|
+
(slots ? `${slots}\n` : '') +
|
|
61
|
+
`</turn_context>`);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 从 turn_start 正文取出用户原文供检索 / UI / 摘要。
|
|
65
|
+
* 非 turn_start 正文原样返回。
|
|
66
|
+
* 取**最后一个** user_message 块(boilerplate 禁止再写该标签字面量)。
|
|
67
|
+
*/
|
|
68
|
+
export function extractUserMessageText(content) {
|
|
69
|
+
const raw = messageText(content);
|
|
70
|
+
const re = /<user_message>\n?([\s\S]*?)\n?<\/user_message>/g;
|
|
71
|
+
let last;
|
|
72
|
+
let m;
|
|
73
|
+
while ((m = re.exec(raw)) !== null) {
|
|
74
|
+
last = m[1];
|
|
75
|
+
}
|
|
76
|
+
return last !== undefined ? unescapeUserMessageText(last.trim()) : raw;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 剥掉 `<turn_context>…</turn_context>`(摘要语义输入 / UI)。
|
|
80
|
+
* 保留 `<user_message>` 与 turn_start/turn_end 骨架(或在 UI 场景配合 extractUserMessageText)。
|
|
81
|
+
*/
|
|
82
|
+
export function stripTurnContextXml(content) {
|
|
83
|
+
return messageText(content)
|
|
84
|
+
.replace(/<turn_context[\s\S]*?<\/turn_context>/g, '')
|
|
85
|
+
.trim();
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* 是否 turn_start 正文(接受 string 或 Message.content)。
|
|
89
|
+
*
|
|
90
|
+
* 判形锚定到**正文开头**(允许前导空白):真实信封由 formatTurnStartContent 定形、必然以开标签起头;
|
|
91
|
+
* 正文中途引用标签字面量(讨论协议/贴日志/知识语料)不得命中——否则普通 user 发言会被
|
|
92
|
+
* 写一次守卫误判「已定形」(NEXT-STEPS D7)。
|
|
93
|
+
*/
|
|
94
|
+
export function isTurnStartContent(content) {
|
|
95
|
+
return /^\s*<turn_start[\s>]/.test(messageText(content));
|
|
96
|
+
}
|
|
97
|
+
/** 是否 turn_end 正文(同 isTurnStartContent:锚定正文开头,防止字面量误判) */
|
|
98
|
+
export function isTurnEndContent(content) {
|
|
99
|
+
return /^\s*<turn_end[\s/>]/.test(messageText(content));
|
|
100
|
+
}
|
|
101
|
+
/** 从 turn_start / turn_end 正文解析 id */
|
|
102
|
+
export function parseTurnIdFromContent(content) {
|
|
103
|
+
const m = /<turn_(?:start|end)\s[^>]*\bid="([^"]+)"/.exec(messageText(content));
|
|
104
|
+
return m ? m[1] : undefined;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* 槽位标签集(**转义清单的唯一真源**):joinSlotXml 生产、escapeSlotBody 定向转义、
|
|
108
|
+
* parseTurnEnvelope 白名单三处同源引用——新增槽位必须进此表,转义与白名单随之生效。
|
|
109
|
+
* 白名单外的同形标签视为正文噪音 / 注入尝试。
|
|
110
|
+
*/
|
|
111
|
+
export const SLOT_TAGS = [
|
|
112
|
+
'runtime_snapshot',
|
|
113
|
+
'session_attachments',
|
|
114
|
+
'knowledge_grounding',
|
|
115
|
+
];
|
|
116
|
+
const SLOT_TAG_SET = new Set(SLOT_TAGS);
|
|
117
|
+
/**
|
|
118
|
+
* 槽位正文定向转义(D7 方案 A′):把正文里的同名开/闭标签字面量转义为 XML 实体,
|
|
119
|
+
* 防语料(知识 / grounding / 附件)伪造闭合提前截断槽位、或伪造新槽位条目。
|
|
120
|
+
* 只动 `<tag>` / `</tag>` / `<tag ` 三种序列;其余内容(含其他合法 XML)原样保留。
|
|
121
|
+
*
|
|
122
|
+
* @param tag - 槽位标签(配合 SLOT_TAGS 使用)
|
|
123
|
+
* @param body - 槽位正文
|
|
124
|
+
* @returns 同名字面量已转义的正文
|
|
125
|
+
*/
|
|
126
|
+
export function escapeSlotBody(tag, body) {
|
|
127
|
+
return body
|
|
128
|
+
.replaceAll(`</${tag}>`, `</${tag}>`)
|
|
129
|
+
.replaceAll(`<${tag}>`, `<${tag}>`)
|
|
130
|
+
.replaceAll(`<${tag} `, `<${tag} `);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* 解析 turn_start 信封(槽位 + 用户原文)。
|
|
134
|
+
*
|
|
135
|
+
* 入口判形锚定正文开头(同 isTurnStartContent);turn_context 取**最后一块**
|
|
136
|
+
* (与 extractUserMessageText 取最后一个 user_message 同口径);槽位只认
|
|
137
|
+
* SLOT_TAGS 白名单(防正文伪影伪造任意槽位条目)。
|
|
138
|
+
*
|
|
139
|
+
* @param content - 消息正文(string 或 Message.content)
|
|
140
|
+
* @returns 信封解析结果;非 turn_start 正文返回 null
|
|
141
|
+
*/
|
|
142
|
+
export function parseTurnEnvelope(content) {
|
|
143
|
+
const raw = messageText(content);
|
|
144
|
+
if (!/^\s*<turn_start[\s>]/.test(raw))
|
|
145
|
+
return null;
|
|
146
|
+
const at = /\sat="([^"]*)"/.exec(raw.slice(0, raw.indexOf('>') + 1))?.[1];
|
|
147
|
+
const slots = [];
|
|
148
|
+
const ctxRe = /<turn_context[^>]*>([\s\S]*?)<\/turn_context>/g;
|
|
149
|
+
let ctx = '';
|
|
150
|
+
let cm;
|
|
151
|
+
while ((cm = ctxRe.exec(raw)) !== null) {
|
|
152
|
+
ctx = cm[1] ?? '';
|
|
153
|
+
}
|
|
154
|
+
const slotRe = /<([a-z][a-z0-9_-]*)>\n?([\s\S]*?)\n?<\/\1>/g;
|
|
155
|
+
let sm;
|
|
156
|
+
while ((sm = slotRe.exec(ctx)) !== null) {
|
|
157
|
+
const tag = sm[1];
|
|
158
|
+
if (tag === 'boilerplate')
|
|
159
|
+
continue;
|
|
160
|
+
if (!SLOT_TAG_SET.has(tag))
|
|
161
|
+
continue;
|
|
162
|
+
slots.push({ tag, body: sm[2].trim() });
|
|
163
|
+
}
|
|
164
|
+
const hasUserMessage = /<user_message>/.test(raw);
|
|
165
|
+
return {
|
|
166
|
+
turnId: parseTurnIdFromContent(raw),
|
|
167
|
+
at,
|
|
168
|
+
slots,
|
|
169
|
+
userText: hasUserMessage ? extractUserMessageText(raw) : '',
|
|
170
|
+
hasUserMessage,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* 拼 turn_context 内的槽位 XML(runner 注入)。
|
|
175
|
+
* 正文经 escapeSlotBody 定向转义(D7 A′):语料同名字面量不得产出解析器眼里的标签,
|
|
176
|
+
* 防提前闭合 / 伪造槽位;tag 必须属于 SLOT_TAGS(转义清单唯一真源)。
|
|
177
|
+
* @param parts - 非空槽位段;空段被跳过
|
|
178
|
+
*/
|
|
179
|
+
export function joinSlotXml(parts) {
|
|
180
|
+
return parts
|
|
181
|
+
.filter((p) => p.body.trim().length > 0)
|
|
182
|
+
.map((p) => `<${p.tag}>\n${escapeSlotBody(p.tag, p.body.trim())}\n</${p.tag}>`)
|
|
183
|
+
.join('\n');
|
|
184
|
+
}
|
|
185
|
+
/** 任意 content 归一化后的用户正文(UI / 载体扫描共用) */
|
|
186
|
+
export function unwrapUserText(content) {
|
|
187
|
+
return extractUserMessageText(content);
|
|
188
|
+
}
|