kiokuko-dsh 0.2.7 → 0.2.9
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/PERMISSIONS.md +1 -1
- package/README.ja.md +38 -11
- package/README.ko.md +34 -3
- package/README.md +39 -13
- package/README.zh-CN.md +34 -3
- package/THIRD_PARTY_NOTICES.md +4 -0
- package/dist/db/transaction.d.ts +2 -1
- package/dist/db/transaction.d.ts.map +1 -1
- package/dist/db/transaction.js +44 -7
- package/dist/db/transaction.js.map +1 -1
- package/dist/deep-planning-config.d.ts +32 -0
- package/dist/deep-planning-config.d.ts.map +1 -0
- package/dist/deep-planning-config.js +20 -0
- package/dist/deep-planning-config.js.map +1 -0
- package/dist/deep-thinker/core/contracts.d.ts +1 -29
- package/dist/deep-thinker/core/contracts.d.ts.map +1 -1
- package/dist/deep-thinker/core/contracts.js +2 -17
- package/dist/deep-thinker/core/contracts.js.map +1 -1
- package/dist/deep-thinker/memory-finalizer.d.ts.map +1 -1
- package/dist/deep-thinker/memory-finalizer.js +1 -114
- package/dist/deep-thinker/memory-finalizer.js.map +1 -1
- package/dist/deep-thinker/native-executor.d.ts.map +1 -1
- package/dist/deep-thinker/native-executor.js +3 -4
- package/dist/deep-thinker/native-executor.js.map +1 -1
- package/dist/deep-thinker/store.js +1 -2
- package/dist/deep-thinker/store.js.map +1 -1
- package/dist/dsh/agenticreplay-event-mapper.d.ts +1 -1
- package/dist/dsh/agenticreplay-event-mapper.d.ts.map +1 -1
- package/dist/dsh/agenticreplay-event-mapper.js +5 -1
- package/dist/dsh/agenticreplay-event-mapper.js.map +1 -1
- package/dist/dsh/agenticreplay-files.d.ts +1 -0
- package/dist/dsh/agenticreplay-files.d.ts.map +1 -1
- package/dist/dsh/agenticreplay-files.js +19 -2
- package/dist/dsh/agenticreplay-files.js.map +1 -1
- package/dist/dsh/agenticreplay-host.js +3 -3
- package/dist/dsh/agenticreplay-host.js.map +1 -1
- package/dist/dsh/agenticreplay-read-service.d.ts +20 -0
- package/dist/dsh/agenticreplay-read-service.d.ts.map +1 -1
- package/dist/dsh/agenticreplay-read-service.js +27 -0
- package/dist/dsh/agenticreplay-read-service.js.map +1 -1
- package/dist/dsh/agenticreplay-recorder.d.ts +18 -12
- package/dist/dsh/agenticreplay-recorder.d.ts.map +1 -1
- package/dist/dsh/agenticreplay-recorder.js +43 -13
- package/dist/dsh/agenticreplay-recorder.js.map +1 -1
- package/dist/dsh/agenticreplay-security.d.ts +1 -0
- package/dist/dsh/agenticreplay-security.d.ts.map +1 -1
- package/dist/dsh/agenticreplay-security.js +84 -3
- package/dist/dsh/agenticreplay-security.js.map +1 -1
- package/dist/dsh/answer-review/coordinator.js +2 -1
- package/dist/dsh/answer-review/coordinator.js.map +1 -1
- package/dist/dsh/auto-memory-review.d.ts.map +1 -1
- package/dist/dsh/auto-memory-review.js +10 -193
- package/dist/dsh/auto-memory-review.js.map +1 -1
- package/dist/dsh/coding-workflow/contracts.d.ts +2 -0
- package/dist/dsh/coding-workflow/contracts.d.ts.map +1 -1
- package/dist/dsh/coding-workflow/contracts.js.map +1 -1
- package/dist/dsh/coding-workflow/intent.d.ts.map +1 -1
- package/dist/dsh/coding-workflow/intent.js +12 -4
- package/dist/dsh/coding-workflow/intent.js.map +1 -1
- package/dist/dsh/coding-workflow/service.d.ts +10 -81
- package/dist/dsh/coding-workflow/service.d.ts.map +1 -1
- package/dist/dsh/coding-workflow/service.js +52 -1
- package/dist/dsh/coding-workflow/service.js.map +1 -1
- package/dist/dsh/coding-workflow/store.d.ts +22 -0
- package/dist/dsh/coding-workflow/store.d.ts.map +1 -1
- package/dist/dsh/coding-workflow/store.js +51 -0
- package/dist/dsh/coding-workflow/store.js.map +1 -1
- package/dist/dsh/completion-verifiers.d.ts +6 -0
- package/dist/dsh/completion-verifiers.d.ts.map +1 -1
- package/dist/dsh/completion-verifiers.js.map +1 -1
- package/dist/dsh/composition.d.ts +2 -0
- package/dist/dsh/composition.d.ts.map +1 -1
- package/dist/dsh/composition.js +3 -0
- package/dist/dsh/composition.js.map +1 -1
- package/dist/dsh/config.d.ts +1 -1
- package/dist/dsh/config.d.ts.map +1 -1
- package/dist/dsh/config.js +3 -3
- package/dist/dsh/config.js.map +1 -1
- package/dist/dsh/core/host.d.ts.map +1 -1
- package/dist/dsh/core/host.js +159 -34
- package/dist/dsh/core/host.js.map +1 -1
- package/dist/dsh/core/tasks.d.ts +5 -2
- package/dist/dsh/core/tasks.d.ts.map +1 -1
- package/dist/dsh/core/tasks.js +124 -93
- package/dist/dsh/core/tasks.js.map +1 -1
- package/dist/dsh/decisions/request-intent.d.ts +114 -1
- package/dist/dsh/decisions/request-intent.d.ts.map +1 -1
- package/dist/dsh/decisions/request-intent.js +102 -18
- package/dist/dsh/decisions/request-intent.js.map +1 -1
- package/dist/dsh/execution-result.d.ts +1 -0
- package/dist/dsh/execution-result.d.ts.map +1 -1
- package/dist/dsh/execution-support.d.ts +2 -0
- package/dist/dsh/execution-support.d.ts.map +1 -1
- package/dist/dsh/execution-support.js +39 -4
- package/dist/dsh/execution-support.js.map +1 -1
- package/dist/dsh/existing-task-intake.d.ts +22 -0
- package/dist/dsh/existing-task-intake.d.ts.map +1 -0
- package/dist/dsh/existing-task-intake.js +46 -0
- package/dist/dsh/existing-task-intake.js.map +1 -0
- package/dist/dsh/finalization-request.d.ts +1 -1
- package/dist/dsh/finalization-request.d.ts.map +1 -1
- package/dist/dsh/finalization-request.js +1 -1
- package/dist/dsh/finalization-request.js.map +1 -1
- package/dist/dsh/guardrail/contracts.d.ts +85 -0
- package/dist/dsh/guardrail/contracts.d.ts.map +1 -0
- package/dist/dsh/guardrail/contracts.js +10 -0
- package/dist/dsh/guardrail/contracts.js.map +1 -0
- package/dist/dsh/guardrail/engine.d.ts +19 -0
- package/dist/dsh/guardrail/engine.d.ts.map +1 -0
- package/dist/dsh/guardrail/engine.js +178 -0
- package/dist/dsh/guardrail/engine.js.map +1 -0
- package/dist/dsh/guardrail/evidence.d.ts +16 -0
- package/dist/dsh/guardrail/evidence.d.ts.map +1 -0
- package/dist/dsh/guardrail/evidence.js +101 -0
- package/dist/dsh/guardrail/evidence.js.map +1 -0
- package/dist/dsh/guardrail/service.d.ts +27 -0
- package/dist/dsh/guardrail/service.d.ts.map +1 -0
- package/dist/dsh/guardrail/service.js +253 -0
- package/dist/dsh/guardrail/service.js.map +1 -0
- package/dist/dsh/host-adapter/admission.d.ts.map +1 -1
- package/dist/dsh/host-adapter/admission.js +143 -144
- package/dist/dsh/host-adapter/admission.js.map +1 -1
- package/dist/dsh/host-adapter/lifecycle.d.ts +1 -0
- package/dist/dsh/host-adapter/lifecycle.d.ts.map +1 -1
- package/dist/dsh/host-adapter/lifecycle.js +107 -77
- package/dist/dsh/host-adapter/lifecycle.js.map +1 -1
- package/dist/dsh/host-adapter/routing.d.ts.map +1 -1
- package/dist/dsh/host-adapter/routing.js +4 -4
- package/dist/dsh/host-adapter/routing.js.map +1 -1
- package/dist/dsh/host-adapter/turn-state.d.ts +4 -2
- package/dist/dsh/host-adapter/turn-state.d.ts.map +1 -1
- package/dist/dsh/host-adapter/turn-state.js +14 -7
- package/dist/dsh/host-adapter/turn-state.js.map +1 -1
- package/dist/dsh/host-adapter.d.ts.map +1 -1
- package/dist/dsh/host-adapter.js +125 -24
- package/dist/dsh/host-adapter.js.map +1 -1
- package/dist/dsh/intake-clarification.js +2 -2
- package/dist/dsh/intake-clarification.js.map +1 -1
- package/dist/dsh/intake-gate.js +6 -7
- package/dist/dsh/intake-gate.js.map +1 -1
- package/dist/dsh/legacy-session-codecs.d.ts +1 -0
- package/dist/dsh/legacy-session-codecs.d.ts.map +1 -1
- package/dist/dsh/legacy-session-codecs.js +831 -127
- package/dist/dsh/legacy-session-codecs.js.map +4 -4
- package/dist/dsh/lifecycle-memory.d.ts +66 -0
- package/dist/dsh/lifecycle-memory.d.ts.map +1 -0
- package/dist/dsh/lifecycle-memory.js +380 -0
- package/dist/dsh/lifecycle-memory.js.map +1 -0
- package/dist/dsh/lisp/candidate.d.ts +2 -2
- package/dist/dsh/lisp/ci.d.ts +2 -1
- package/dist/dsh/lisp/ci.d.ts.map +1 -1
- package/dist/dsh/lisp/ci.js +15 -2
- package/dist/dsh/lisp/ci.js.map +1 -1
- package/dist/dsh/lisp/contracts.d.ts +1 -18
- package/dist/dsh/lisp/contracts.d.ts.map +1 -1
- package/dist/dsh/lisp/contracts.js +1 -10
- package/dist/dsh/lisp/contracts.js.map +1 -1
- package/dist/dsh/lisp/files.d.ts +1 -1
- package/dist/dsh/lisp/files.d.ts.map +1 -1
- package/dist/dsh/lisp/files.js +17 -4
- package/dist/dsh/lisp/files.js.map +1 -1
- package/dist/dsh/lisp/hot-store.d.ts.map +1 -1
- package/dist/dsh/lisp/hot-store.js +4 -0
- package/dist/dsh/lisp/hot-store.js.map +1 -1
- package/dist/dsh/lisp/hot-tools.d.ts +2 -0
- package/dist/dsh/lisp/hot-tools.d.ts.map +1 -1
- package/dist/dsh/lisp/hot-tools.js +10 -0
- package/dist/dsh/lisp/hot-tools.js.map +1 -1
- package/dist/dsh/lisp/manager.d.ts +14 -1
- package/dist/dsh/lisp/manager.d.ts.map +1 -1
- package/dist/dsh/lisp/manager.js +238 -37
- package/dist/dsh/lisp/manager.js.map +1 -1
- package/dist/dsh/lisp/memory-verification.d.ts +5 -2
- package/dist/dsh/lisp/memory-verification.d.ts.map +1 -1
- package/dist/dsh/lisp/memory-verification.js +5 -1
- package/dist/dsh/lisp/memory-verification.js.map +1 -1
- package/dist/dsh/lisp/package-manager.d.ts +1 -1
- package/dist/dsh/lisp/package-manager.d.ts.map +1 -1
- package/dist/dsh/lisp/package-manager.js +10 -1
- package/dist/dsh/lisp/package-manager.js.map +1 -1
- package/dist/dsh/lisp/packages.d.ts +1 -1
- package/dist/dsh/lisp/packages.d.ts.map +1 -1
- package/dist/dsh/lisp/packages.js +15 -5
- package/dist/dsh/lisp/packages.js.map +1 -1
- package/dist/dsh/lisp/proposal-batch.d.ts +2 -0
- package/dist/dsh/lisp/proposal-batch.d.ts.map +1 -1
- package/dist/dsh/lisp/proposal-batch.js +17 -3
- package/dist/dsh/lisp/proposal-batch.js.map +1 -1
- package/dist/dsh/lisp/request-surface.d.ts +12 -0
- package/dist/dsh/lisp/request-surface.d.ts.map +1 -1
- package/dist/dsh/lisp/store.d.ts +2 -1
- package/dist/dsh/lisp/store.d.ts.map +1 -1
- package/dist/dsh/lisp/store.js +5 -1
- package/dist/dsh/lisp/store.js.map +1 -1
- package/dist/dsh/lisp/surface.d.ts.map +1 -1
- package/dist/dsh/lisp/surface.js +107 -13
- package/dist/dsh/lisp/surface.js.map +1 -1
- package/dist/dsh/lisp/task-authority.d.ts +29 -0
- package/dist/dsh/lisp/task-authority.d.ts.map +1 -0
- package/dist/dsh/lisp/task-authority.js +87 -0
- package/dist/dsh/lisp/task-authority.js.map +1 -0
- package/dist/dsh/lisp/worker.d.ts +3 -1
- package/dist/dsh/lisp/worker.d.ts.map +1 -1
- package/dist/dsh/lisp/worker.js +26 -4
- package/dist/dsh/lisp/worker.js.map +1 -1
- package/dist/dsh/lisp-config.d.ts +21 -0
- package/dist/dsh/lisp-config.d.ts.map +1 -0
- package/dist/dsh/lisp-config.js +13 -0
- package/dist/dsh/lisp-config.js.map +1 -0
- package/dist/dsh/memory-application.d.ts +3 -2
- package/dist/dsh/memory-application.d.ts.map +1 -1
- package/dist/dsh/memory-application.js +31 -22
- package/dist/dsh/memory-application.js.map +1 -1
- package/dist/dsh/model-handoff.d.ts.map +1 -1
- package/dist/dsh/model-handoff.js +2 -1
- package/dist/dsh/model-handoff.js.map +1 -1
- package/dist/dsh/models/service.d.ts.map +1 -1
- package/dist/dsh/models/service.js +13 -2
- package/dist/dsh/models/service.js.map +1 -1
- package/dist/dsh/models/vendor/opencode-codec.d.ts.map +1 -1
- package/dist/dsh/models/vendor/opencode-codec.js +71 -0
- package/dist/dsh/models/vendor/opencode-codec.js.map +1 -1
- package/dist/dsh/native-cancellation-observer.d.ts +13 -0
- package/dist/dsh/native-cancellation-observer.d.ts.map +1 -0
- package/dist/dsh/native-cancellation-observer.js +54 -0
- package/dist/dsh/native-cancellation-observer.js.map +1 -0
- package/dist/dsh/native-execution-ownership.d.ts +6 -0
- package/dist/dsh/native-execution-ownership.d.ts.map +1 -0
- package/dist/dsh/native-execution-ownership.js +34 -0
- package/dist/dsh/native-execution-ownership.js.map +1 -0
- package/dist/dsh/native-subagent.d.ts +2 -2
- package/dist/dsh/native-subagent.d.ts.map +1 -1
- package/dist/dsh/native-subagent.js +2 -3
- package/dist/dsh/native-subagent.js.map +1 -1
- package/dist/dsh/native-task-authority.d.ts +66 -0
- package/dist/dsh/native-task-authority.d.ts.map +1 -0
- package/dist/dsh/native-task-authority.js +220 -0
- package/dist/dsh/native-task-authority.js.map +1 -0
- package/dist/dsh/node-tap-summary.d.ts +1 -2
- package/dist/dsh/node-tap-summary.d.ts.map +1 -1
- package/dist/dsh/node-tap-summary.js +2 -24
- package/dist/dsh/node-tap-summary.js.map +1 -1
- package/dist/dsh/observation-pack/policy.d.ts +1 -0
- package/dist/dsh/observation-pack/policy.d.ts.map +1 -1
- package/dist/dsh/observation-pack/policy.js +3 -0
- package/dist/dsh/observation-pack/policy.js.map +1 -1
- package/dist/dsh/observation-pack/service.d.ts.map +1 -1
- package/dist/dsh/observation-pack/service.js +3 -1
- package/dist/dsh/observation-pack/service.js.map +1 -1
- package/dist/dsh/on-demand-intake.d.ts +28 -1
- package/dist/dsh/on-demand-intake.d.ts.map +1 -1
- package/dist/dsh/on-demand-intake.js +171 -10
- package/dist/dsh/on-demand-intake.js.map +1 -1
- package/dist/dsh/orchestration/execution-owner.js +1 -1
- package/dist/dsh/orchestration/execution-owner.js.map +1 -1
- package/dist/dsh/orchestration/managed-agent-executor.d.ts +12 -1
- package/dist/dsh/orchestration/managed-agent-executor.d.ts.map +1 -1
- package/dist/dsh/orchestration/managed-agent-executor.js +28 -2
- package/dist/dsh/orchestration/managed-agent-executor.js.map +1 -1
- package/dist/dsh/owned-completion-evidence.d.ts +11 -0
- package/dist/dsh/owned-completion-evidence.d.ts.map +1 -0
- package/dist/dsh/owned-completion-evidence.js +59 -0
- package/dist/dsh/owned-completion-evidence.js.map +1 -0
- package/dist/dsh/owned-execution.d.ts +28 -1
- package/dist/dsh/owned-execution.d.ts.map +1 -1
- package/dist/dsh/owned-execution.js +325 -101
- package/dist/dsh/owned-execution.js.map +1 -1
- package/dist/dsh/owned-read-owner.d.ts +6 -0
- package/dist/dsh/owned-read-owner.d.ts.map +1 -0
- package/dist/dsh/owned-read-owner.js +22 -0
- package/dist/dsh/owned-read-owner.js.map +1 -0
- package/dist/dsh/replay-memory-extract.d.ts +36 -0
- package/dist/dsh/replay-memory-extract.d.ts.map +1 -0
- package/dist/dsh/replay-memory-extract.js +192 -0
- package/dist/dsh/replay-memory-extract.js.map +1 -0
- package/dist/dsh/semantic-compaction/coordinator.d.ts.map +1 -1
- package/dist/dsh/semantic-compaction/coordinator.js +2 -1
- package/dist/dsh/semantic-compaction/coordinator.js.map +1 -1
- package/dist/dsh/session-bridge.d.ts +3 -0
- package/dist/dsh/session-bridge.d.ts.map +1 -1
- package/dist/dsh/session-bridge.js +22 -25
- package/dist/dsh/session-bridge.js.map +1 -1
- package/dist/dsh/session-history-compatibility.d.ts.map +1 -1
- package/dist/dsh/session-history-compatibility.js +15 -1
- package/dist/dsh/session-history-compatibility.js.map +1 -1
- package/dist/dsh/session-history-lookup.d.ts +1 -1
- package/dist/dsh/session-history-lookup.d.ts.map +1 -1
- package/dist/dsh/session-history-lookup.js +4 -3
- package/dist/dsh/session-history-lookup.js.map +1 -1
- package/dist/dsh/session-memory-finalizer.d.ts.map +1 -1
- package/dist/dsh/session-memory-finalizer.js +129 -117
- package/dist/dsh/session-memory-finalizer.js.map +1 -1
- package/dist/dsh/setup.d.ts +1 -1
- package/dist/dsh/setup.d.ts.map +1 -1
- package/dist/dsh/setup.js +1 -1
- package/dist/dsh/skill-prompts.json +1 -1
- package/dist/dsh/task-authority-context.d.ts +8 -0
- package/dist/dsh/task-authority-context.d.ts.map +1 -0
- package/dist/dsh/task-authority-context.js +28 -0
- package/dist/dsh/task-authority-context.js.map +1 -0
- package/dist/dsh/task-completion-host.d.ts +2 -1
- package/dist/dsh/task-completion-host.d.ts.map +1 -1
- package/dist/dsh/task-completion-host.js +17 -5
- package/dist/dsh/task-completion-host.js.map +1 -1
- package/dist/dsh/task-completion.d.ts +13 -0
- package/dist/dsh/task-completion.d.ts.map +1 -1
- package/dist/dsh/task-completion.js +23 -6
- package/dist/dsh/task-completion.js.map +1 -1
- package/dist/dsh/task-intake.d.ts.map +1 -1
- package/dist/dsh/task-intake.js +7 -16
- package/dist/dsh/task-intake.js.map +1 -1
- package/dist/dsh/task-source-history.d.ts +33 -0
- package/dist/dsh/task-source-history.d.ts.map +1 -0
- package/dist/dsh/task-source-history.js +62 -0
- package/dist/dsh/task-source-history.js.map +1 -0
- package/dist/dsh/task-state-host.d.ts +124 -0
- package/dist/dsh/task-state-host.d.ts.map +1 -0
- package/dist/dsh/task-state-host.js +403 -0
- package/dist/dsh/task-state-host.js.map +1 -0
- package/dist/dsh/task-state-surface.d.ts +8 -0
- package/dist/dsh/task-state-surface.d.ts.map +1 -0
- package/dist/dsh/task-state-surface.js +113 -0
- package/dist/dsh/task-state-surface.js.map +1 -0
- package/dist/dsh/task-state.d.ts +217 -0
- package/dist/dsh/task-state.d.ts.map +1 -0
- package/dist/dsh/task-state.js +315 -0
- package/dist/dsh/task-state.js.map +1 -0
- package/dist/dsh/tool-exposure-config.d.ts +12 -0
- package/dist/dsh/tool-exposure-config.d.ts.map +1 -0
- package/dist/dsh/tool-exposure-config.js +4 -0
- package/dist/dsh/tool-exposure-config.js.map +1 -0
- package/dist/dsh/tool-exposure.d.ts +2 -11
- package/dist/dsh/tool-exposure.d.ts.map +1 -1
- package/dist/dsh/tool-exposure.js +2 -2
- package/dist/dsh/tool-exposure.js.map +1 -1
- package/dist/dsh/tools.d.ts +2 -2
- package/dist/dsh/tools.d.ts.map +1 -1
- package/dist/dsh/tools.js +3 -2
- package/dist/dsh/tools.js.map +1 -1
- package/dist/enno-oduno/memory-verification.d.ts +2 -1
- package/dist/enno-oduno/memory-verification.d.ts.map +1 -1
- package/dist/enno-oduno/memory-verification.js +42 -30
- package/dist/enno-oduno/memory-verification.js.map +1 -1
- package/dist/enno-oduno/schemas.d.ts +1 -1
- package/dist/enno-oduno/store.d.ts +7 -0
- package/dist/enno-oduno/store.d.ts.map +1 -1
- package/dist/enno-oduno/store.js +42 -0
- package/dist/enno-oduno/store.js.map +1 -1
- package/dist/ledger/store.d.ts.map +1 -1
- package/dist/ledger/store.js +0 -5
- package/dist/ledger/store.js.map +1 -1
- package/dist/locale/en.json +1 -1
- package/dist/locale/ja.json +1 -1
- package/dist/locale/ko.json +1 -1
- package/dist/locale/zh-CN.json +1 -1
- package/dist/memory/application.js +1 -1
- package/dist/memory/application.js.map +1 -1
- package/dist/memory/auto-globalization.d.ts.map +1 -1
- package/dist/memory/auto-globalization.js +4 -82
- package/dist/memory/auto-globalization.js.map +1 -1
- package/dist/memory/evolution/contracts.d.ts +3 -1
- package/dist/memory/evolution/contracts.d.ts.map +1 -1
- package/dist/memory/evolution/contracts.js +1 -1
- package/dist/memory/evolution/contracts.js.map +1 -1
- package/dist/memory/evolution/store.d.ts +2 -1
- package/dist/memory/evolution/store.d.ts.map +1 -1
- package/dist/memory/evolution/store.js +75 -34
- package/dist/memory/evolution/store.js.map +1 -1
- package/dist/memory/evolution/worker.d.ts +1 -0
- package/dist/memory/evolution/worker.d.ts.map +1 -1
- package/dist/memory/evolution/worker.js +6 -18
- package/dist/memory/evolution/worker.js.map +1 -1
- package/dist/memory/explain.d.ts.map +1 -1
- package/dist/memory/explain.js +2 -2
- package/dist/memory/explain.js.map +1 -1
- package/dist/memory/forget.d.ts.map +1 -1
- package/dist/memory/forget.js +12 -3
- package/dist/memory/forget.js.map +1 -1
- package/dist/memory/hybrid-retrieval.d.ts.map +1 -1
- package/dist/memory/hybrid-retrieval.js +3 -0
- package/dist/memory/hybrid-retrieval.js.map +1 -1
- package/dist/memory/index-reasoning/service.d.ts.map +1 -1
- package/dist/memory/index-reasoning/service.js +5 -43
- package/dist/memory/index-reasoning/service.js.map +1 -1
- package/dist/memory/index-reasoning/worker.d.ts.map +1 -1
- package/dist/memory/index-reasoning/worker.js +1 -15
- package/dist/memory/index-reasoning/worker.js.map +1 -1
- package/dist/memory/lifecycle-cache.d.ts +12 -0
- package/dist/memory/lifecycle-cache.d.ts.map +1 -0
- package/dist/memory/lifecycle-cache.js +36 -0
- package/dist/memory/lifecycle-cache.js.map +1 -0
- package/dist/memory/lifecycle-database.d.ts +5 -0
- package/dist/memory/lifecycle-database.d.ts.map +1 -0
- package/dist/memory/lifecycle-database.js +32 -0
- package/dist/memory/lifecycle-database.js.map +1 -0
- package/dist/memory/lifecycle-global-state.d.ts +5 -0
- package/dist/memory/lifecycle-global-state.d.ts.map +1 -0
- package/dist/memory/lifecycle-global-state.js +23 -0
- package/dist/memory/lifecycle-global-state.js.map +1 -0
- package/dist/memory/lifecycle-global.d.ts +23 -0
- package/dist/memory/lifecycle-global.d.ts.map +1 -0
- package/dist/memory/lifecycle-global.js +56 -0
- package/dist/memory/lifecycle-global.js.map +1 -0
- package/dist/memory/lifecycle.d.ts +152 -0
- package/dist/memory/lifecycle.d.ts.map +1 -0
- package/dist/memory/lifecycle.js +152 -0
- package/dist/memory/lifecycle.js.map +1 -0
- package/dist/memory/replay-review.d.ts +90 -0
- package/dist/memory/replay-review.d.ts.map +1 -0
- package/dist/memory/replay-review.js +82 -0
- package/dist/memory/replay-review.js.map +1 -0
- package/dist/memory/replay-store.d.ts +14 -0
- package/dist/memory/replay-store.d.ts.map +1 -0
- package/dist/memory/replay-store.js +117 -0
- package/dist/memory/replay-store.js.map +1 -0
- package/dist/memory/review/adoption.d.ts.map +1 -1
- package/dist/memory/review/adoption.js +2 -106
- package/dist/memory/review/adoption.js.map +1 -1
- package/dist/memory/review/store.d.ts.map +1 -1
- package/dist/memory/review/store.js +9 -5
- package/dist/memory/review/store.js.map +1 -1
- package/dist/memory/review/worker.d.ts.map +1 -1
- package/dist/memory/review/worker.js +1 -7
- package/dist/memory/review/worker.js.map +1 -1
- package/dist/memory/scoped-memory.js +1 -1
- package/dist/memory/scoped-memory.js.map +1 -1
- package/dist/model-tools/contracts.d.ts +4 -4
- package/dist/model-tools/contracts.d.ts.map +1 -1
- package/dist/model-tools/contracts.js +1 -11
- package/dist/model-tools/contracts.js.map +1 -1
- package/dist/model-tools/names.d.ts +4 -0
- package/dist/model-tools/names.d.ts.map +1 -0
- package/dist/model-tools/names.js +13 -0
- package/dist/model-tools/names.js.map +1 -0
- package/docs/agenticreplay-recording.md +1 -1
- package/docs/code-intelligence.md +54 -119
- package/docs/dsh-plugin.md +86 -9
- package/docs/getting-started.md +10 -0
- package/docs/guardrail-licenses/Apache-2.0.txt +73 -0
- package/docs/guardrail-licenses/BSD-2-Clause.txt +9 -0
- package/docs/guardrail-licenses/COPYRIGHT-Rust.txt +34 -0
- package/docs/guardrail-licenses/COPYRIGHT-library.html +29357 -0
- package/docs/guardrail-licenses/ISC.txt +7 -0
- package/docs/guardrail-licenses/LICENSE-APACHE +176 -0
- package/docs/guardrail-licenses/LICENSE-MIT +25 -0
- package/docs/guardrail-licenses/LLVM-exception.txt +15 -0
- package/docs/guardrail-licenses/MIT.txt +9 -0
- package/docs/guardrail-licenses/NCSA.txt +29 -0
- package/docs/guardrail-licenses/README.md +7 -0
- package/docs/guardrail-licenses/Unicode-3.0.txt +39 -0
- package/docs/guardrail-licenses/libunwind-LICENSE.txt +311 -0
- package/docs/guardrail-licenses/manifest.json +71 -0
- package/docs/guardrail-licenses/musl-COPYRIGHT.txt +193 -0
- package/docs/guardrail.md +33 -0
- package/docs/lifecycle-memory.md +25 -0
- package/docs/lisp.md +33 -9
- package/docs/memory-evolution.md +6 -6
- package/docs/owned-execution.md +3 -3
- package/docs/replay-memory-review.md +26 -0
- package/docs/semantic-compaction.md +2 -0
- package/guardrail/aarch64-apple-darwin/kiokuko-guardrail +0 -0
- package/guardrail/aarch64-apple-darwin/manifest.json +71 -0
- package/guardrail/aarch64-unknown-linux-musl/kiokuko-guardrail +0 -0
- package/guardrail/aarch64-unknown-linux-musl/manifest.json +69 -0
- package/guardrail/manifest.json +204 -0
- package/guardrail/node-runner.mjs +37 -0
- package/guardrail/protocols/coding-routine.lisp +33 -0
- package/guardrail/x86_64-apple-darwin/kiokuko-guardrail +0 -0
- package/guardrail/x86_64-apple-darwin/manifest.json +71 -0
- package/guardrail/x86_64-unknown-linux-musl/kiokuko-guardrail +0 -0
- package/guardrail/x86_64-unknown-linux-musl/manifest.json +68 -0
- package/migrations/038_coding_admission.sql +19 -0
- package/migrations/039_memory_lifecycle.sql +336 -0
- package/migrations/040_task_state.sql +45 -0
- package/migrations/041_task_source_history.sql +88 -0
- package/migrations/042_evolution_source_epochs.sql +148 -0
- package/package.json +45 -27
- package/scripts/guardrail-artifacts.d.mts +13 -0
- package/scripts/guardrail-artifacts.mjs +136 -0
- package/skills/kiokuko-lisp/SKILL.md +1 -1
- package/skills/kiokuko-soul/SKILL.md +6 -6
|
@@ -142,7 +142,7 @@ var PartialArguments = class PartialArguments2 {
|
|
|
142
142
|
* @returns top-level keys seen so far, in first-appearance order.
|
|
143
143
|
*/
|
|
144
144
|
keys() {
|
|
145
|
-
return this.remember("keys", "", () => this.keysNow(), (
|
|
145
|
+
return this.remember("keys", "", () => this.keysNow(), (keys2) => keys2.length);
|
|
146
146
|
}
|
|
147
147
|
/**
|
|
148
148
|
* Check whether a top-level field has appeared.
|
|
@@ -642,9 +642,9 @@ function hasPlainObjectPrototype(value) {
|
|
|
642
642
|
return prototype === null || typeof prototype === "object" && isIntrinsicObjectPrototype(prototype);
|
|
643
643
|
}
|
|
644
644
|
function enumerableStringKeys(value) {
|
|
645
|
-
const
|
|
646
|
-
if (
|
|
647
|
-
return
|
|
645
|
+
const keys2 = Reflect.ownKeys(value);
|
|
646
|
+
if (keys2.some((key) => typeof key !== "string" || !Object.prototype.propertyIsEnumerable.call(value, key))) return void 0;
|
|
647
|
+
return keys2;
|
|
648
648
|
}
|
|
649
649
|
function walkJsonValue(value, detach) {
|
|
650
650
|
const ancestors = /* @__PURE__ */ new Set();
|
|
@@ -731,8 +731,8 @@ function walkJsonValue(value, detach) {
|
|
|
731
731
|
continue;
|
|
732
732
|
}
|
|
733
733
|
if (!hasPlainObjectPrototype(current)) return void 0;
|
|
734
|
-
const
|
|
735
|
-
if (
|
|
734
|
+
const keys2 = enumerableStringKeys(current);
|
|
735
|
+
if (keys2 === void 0) return void 0;
|
|
736
736
|
const target = detach ? {} : void 0;
|
|
737
737
|
if (target !== void 0) assign(task.destination, target);
|
|
738
738
|
ancestors.add(current);
|
|
@@ -740,8 +740,8 @@ function walkJsonValue(value, detach) {
|
|
|
740
740
|
kind: "leave",
|
|
741
741
|
source: current
|
|
742
742
|
});
|
|
743
|
-
for (let index =
|
|
744
|
-
const key =
|
|
743
|
+
for (let index = keys2.length - 1; index >= 0; index--) {
|
|
744
|
+
const key = keys2[index];
|
|
745
745
|
if (key === void 0) return void 0;
|
|
746
746
|
tasks.push({
|
|
747
747
|
kind: "object-property",
|
|
@@ -768,9 +768,9 @@ function deepEqualJson(a, b) {
|
|
|
768
768
|
}
|
|
769
769
|
const left = a;
|
|
770
770
|
const right = b;
|
|
771
|
-
const
|
|
772
|
-
if (
|
|
773
|
-
return
|
|
771
|
+
const keys2 = Object.keys(left);
|
|
772
|
+
if (keys2.length !== Object.keys(right).length) return false;
|
|
773
|
+
return keys2.every((key) => key in right && deepEqualJson(left[key], right[key]));
|
|
774
774
|
}
|
|
775
775
|
function deepFreeze(value) {
|
|
776
776
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
@@ -794,9 +794,9 @@ function deepFreeze(value) {
|
|
|
794
794
|
if (seen.has(node)) continue;
|
|
795
795
|
seen.add(node);
|
|
796
796
|
Object.freeze(node);
|
|
797
|
-
const
|
|
798
|
-
for (let index =
|
|
799
|
-
const key =
|
|
797
|
+
const keys2 = Object.keys(node);
|
|
798
|
+
for (let index = keys2.length - 1; index >= 0; index--) {
|
|
799
|
+
const key = keys2[index];
|
|
800
800
|
if (key === void 0) continue;
|
|
801
801
|
pending.push({
|
|
802
802
|
kind: "property",
|
|
@@ -1065,11 +1065,11 @@ function releasedV0Record(value, label) {
|
|
|
1065
1065
|
if (!isSessionFormatJsonObject(value)) throw new SessionFormatError(`${label} must be a JSON object`);
|
|
1066
1066
|
return value;
|
|
1067
1067
|
}
|
|
1068
|
-
function assertReleasedV0Keys(
|
|
1068
|
+
function assertReleasedV0Keys(record3, required, optional = [], label) {
|
|
1069
1069
|
const allowed = /* @__PURE__ */ new Set([...required, ...optional]);
|
|
1070
|
-
const unexpected = Object.keys(
|
|
1070
|
+
const unexpected = Object.keys(record3).find((key) => !allowed.has(key));
|
|
1071
1071
|
if (unexpected !== void 0) throw new SessionFormatError(`${label} has unexpected member ${JSON.stringify(unexpected)}`);
|
|
1072
|
-
const missing = required.find((key) => !Object.hasOwn(
|
|
1072
|
+
const missing = required.find((key) => !Object.hasOwn(record3, key));
|
|
1073
1073
|
if (missing !== void 0) throw new SessionFormatError(`${label} lacks required member ${JSON.stringify(missing)}`);
|
|
1074
1074
|
}
|
|
1075
1075
|
function assertReleasedPayloadSemantics(event, version) {
|
|
@@ -1365,9 +1365,9 @@ function assertReleasedPayloadSemantics(event, version) {
|
|
|
1365
1365
|
}
|
|
1366
1366
|
}
|
|
1367
1367
|
function exactRecord(value, label, required, optional = []) {
|
|
1368
|
-
const
|
|
1369
|
-
assertReleasedV0Keys(
|
|
1370
|
-
return
|
|
1368
|
+
const record3 = releasedV0Record(value, label);
|
|
1369
|
+
assertReleasedV0Keys(record3, required, optional, label);
|
|
1370
|
+
return record3;
|
|
1371
1371
|
}
|
|
1372
1372
|
function stringValue(value, label) {
|
|
1373
1373
|
if (typeof value !== "string") throw new SessionFormatError(`${label} must be a string`);
|
|
@@ -2040,35 +2040,35 @@ function scheduleChangeValue(data, label) {
|
|
|
2040
2040
|
if (data["acceptedAt"] !== void 0) instantValue(data["acceptedAt"], `${label} acceptedAt`);
|
|
2041
2041
|
}
|
|
2042
2042
|
function scheduleRecordValue(value, label) {
|
|
2043
|
-
const
|
|
2044
|
-
if (
|
|
2045
|
-
assertReleasedV0Keys(
|
|
2043
|
+
const record3 = releasedV0Record(value, label);
|
|
2044
|
+
if (record3["kind"] === "after") {
|
|
2045
|
+
assertReleasedV0Keys(record3, [
|
|
2046
2046
|
"id",
|
|
2047
2047
|
"kind",
|
|
2048
2048
|
"prompt",
|
|
2049
2049
|
"afterSeconds",
|
|
2050
2050
|
"scheduledAt"
|
|
2051
2051
|
], [], label);
|
|
2052
|
-
positiveIntegerValue(
|
|
2053
|
-
} else if (
|
|
2052
|
+
positiveIntegerValue(record3["afterSeconds"], `${label} afterSeconds`);
|
|
2053
|
+
} else if (record3["kind"] === "at") assertReleasedV0Keys(record3, [
|
|
2054
2054
|
"id",
|
|
2055
2055
|
"kind",
|
|
2056
2056
|
"prompt",
|
|
2057
2057
|
"scheduledAt"
|
|
2058
2058
|
], [], label);
|
|
2059
|
-
else if (
|
|
2060
|
-
assertReleasedV0Keys(
|
|
2059
|
+
else if (record3["kind"] === "every") {
|
|
2060
|
+
assertReleasedV0Keys(record3, [
|
|
2061
2061
|
"id",
|
|
2062
2062
|
"kind",
|
|
2063
2063
|
"prompt",
|
|
2064
2064
|
"everySeconds",
|
|
2065
2065
|
"scheduledAt"
|
|
2066
2066
|
], [], label);
|
|
2067
|
-
if (positiveIntegerValue(
|
|
2067
|
+
if (positiveIntegerValue(record3["everySeconds"], `${label} everySeconds`) < 300) throw new SessionFormatError(`${label} everySeconds must be at least 300`);
|
|
2068
2068
|
} else throw new SessionFormatError(`${label} has unknown schedule kind`);
|
|
2069
|
-
scheduleIdValue(
|
|
2070
|
-
nonEmptyString(
|
|
2071
|
-
instantValue(
|
|
2069
|
+
scheduleIdValue(record3["id"], `${label} id`);
|
|
2070
|
+
nonEmptyString(record3["prompt"], `${label} prompt`);
|
|
2071
|
+
instantValue(record3["scheduledAt"], `${label} scheduledAt`);
|
|
2072
2072
|
}
|
|
2073
2073
|
function scheduleIdValue(value, label) {
|
|
2074
2074
|
nonEmptyString(value, label);
|
|
@@ -2246,24 +2246,50 @@ var HEADER_OPTIONAL = [
|
|
|
2246
2246
|
"agentPreset"
|
|
2247
2247
|
];
|
|
2248
2248
|
function assertReleasedSessionFormatHeader(header, version) {
|
|
2249
|
-
const
|
|
2250
|
-
assertReleasedV0Keys(
|
|
2251
|
-
if (
|
|
2252
|
-
if (typeof
|
|
2253
|
-
sessionFormatCount(
|
|
2254
|
-
if (typeof
|
|
2255
|
-
sessionFormatCount(
|
|
2249
|
+
const record3 = releasedV0Record(header, `format v${version} header`);
|
|
2250
|
+
assertReleasedV0Keys(record3, HEADER_REQUIRED, HEADER_OPTIONAL, `format v${version} header`);
|
|
2251
|
+
if (record3["version"] !== version) throw new SessionFormatError(`expected format v${version} header`);
|
|
2252
|
+
if (typeof record3["id"] !== "string") throw new SessionFormatError(`format v${version} header id must be a string`);
|
|
2253
|
+
sessionFormatCount(record3["createdAt"], `format v${version} header createdAt`);
|
|
2254
|
+
if (typeof record3["isSeeded"] !== "boolean") throw new SessionFormatError(`format v${version} header isSeeded must be a boolean`);
|
|
2255
|
+
sessionFormatCount(record3["delegationDepth"], `format v${version} header delegationDepth`);
|
|
2256
2256
|
for (const key of [
|
|
2257
2257
|
"cwd",
|
|
2258
2258
|
"parentSession",
|
|
2259
2259
|
"agentPreset"
|
|
2260
|
-
]) if (
|
|
2261
|
-
if (typeof
|
|
2262
|
-
if (
|
|
2260
|
+
]) if (record3[key] !== void 0 && typeof record3[key] !== "string") throw new SessionFormatError(`format v${version} header ${key} must be a string`);
|
|
2261
|
+
if (typeof record3["cwd"] === "string" && !isAbsolute(record3["cwd"])) throw new SessionFormatError(`format v${version} header cwd must be absolute`);
|
|
2262
|
+
if (record3["origin"] !== void 0 && record3["origin"] !== "subagent") throw new SessionFormatError(`format v${version} header origin must be "subagent"`);
|
|
2263
2263
|
}
|
|
2264
2264
|
function assertReleasedV1Header(header) {
|
|
2265
2265
|
assertReleasedSessionFormatHeader(header, 1);
|
|
2266
2266
|
}
|
|
2267
|
+
function assertReleasedSurfaceMetadata(record3, seq, type, assistantSources) {
|
|
2268
|
+
const sources = record3["sourceEventSeqs"];
|
|
2269
|
+
if (type === "assistant/message" && sources !== void 0 && assistantSources === "forbid-assistant") throw new SessionFormatError(`assistant/message ${seq} retains obsolete chunk references`);
|
|
2270
|
+
if (sources !== void 0) {
|
|
2271
|
+
if (!Array.isArray(sources)) throw new SessionFormatError(`${type} ${seq} sourceEventSeqs must be an array`);
|
|
2272
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2273
|
+
for (const source of sources) {
|
|
2274
|
+
const current = sessionFormatCount(source, `${type} ${seq} sourceEventSeqs member`);
|
|
2275
|
+
if (current >= seq || seen.has(current)) throw new SessionFormatError(`${type} ${seq} sourceEventSeqs must be unique earlier seqs`);
|
|
2276
|
+
seen.add(current);
|
|
2277
|
+
}
|
|
2278
|
+
if (sources.length === 0 && type !== "assistant/message") throw new SessionFormatError(`${type} ${seq} sourceEventSeqs must be non-empty`);
|
|
2279
|
+
}
|
|
2280
|
+
const operation = record3["surfaceOp"];
|
|
2281
|
+
if (operation === void 0 || operation === "append") return;
|
|
2282
|
+
const replacement = releasedV0Record(operation, `${type} ${seq} surfaceOp`);
|
|
2283
|
+
assertReleasedV0Keys(replacement, [
|
|
2284
|
+
"op",
|
|
2285
|
+
"start",
|
|
2286
|
+
"end"
|
|
2287
|
+
], [], `${type} ${seq} surfaceOp`);
|
|
2288
|
+
if (replacement["op"] !== "replace") throw new SessionFormatError(`${type} ${seq} surfaceOp must replace`);
|
|
2289
|
+
const start = sessionFormatCount(replacement["start"], `${type} ${seq} surface start`);
|
|
2290
|
+
const end = sessionFormatCount(replacement["end"], `${type} ${seq} surface end`);
|
|
2291
|
+
if (start >= seq || end >= seq) throw new SessionFormatError(`${type} ${seq} has an invalid surface replacement`);
|
|
2292
|
+
}
|
|
2267
2293
|
function assertReleasedEventPayload(event, version) {
|
|
2268
2294
|
const disposition2 = RELEASED_V0_EVENT_DISPOSITIONS[event.type];
|
|
2269
2295
|
if (disposition2 === void 0) throw new SessionFormatUnsupportedMigrationError(`format v0 contains unknown historical event type ${JSON.stringify(event.type)} at seq ${event.seq}; migration refuses unknown historical events even when ignorable`);
|
|
@@ -2334,12 +2360,12 @@ function scanRows(recoverable) {
|
|
|
2334
2360
|
let packed = false;
|
|
2335
2361
|
let decoded;
|
|
2336
2362
|
try {
|
|
2337
|
-
const
|
|
2338
|
-
const type =
|
|
2363
|
+
const record3 = releasedV0Record(rowValue, `released Session row ${currentRow}`);
|
|
2364
|
+
const type = record3["type"];
|
|
2339
2365
|
if (typeof type === "string" && PACKED_TAGS.has(type)) {
|
|
2340
2366
|
packed = true;
|
|
2341
|
-
decoded = decodePackedRun(
|
|
2342
|
-
} else decoded = decodeEvent(
|
|
2367
|
+
decoded = decodePackedRun(record3, type, currentRow);
|
|
2368
|
+
} else decoded = decodeEvent(record3, currentRow);
|
|
2343
2369
|
} catch (error) {
|
|
2344
2370
|
const current = error instanceof SessionFormatError ? error : new SessionFormatError(`released Session row ${currentRow} is malformed`, { cause: error });
|
|
2345
2371
|
if (!recoverable) throw current;
|
|
@@ -2376,29 +2402,29 @@ function decodeHeader(value, version) {
|
|
|
2376
2402
|
return decodePhysicalHeader(value, version).header;
|
|
2377
2403
|
}
|
|
2378
2404
|
function decodePhysicalHeader(value, version) {
|
|
2379
|
-
const
|
|
2380
|
-
assertReleasedV0Keys(
|
|
2381
|
-
if (
|
|
2382
|
-
if (typeof
|
|
2383
|
-
const createdAt = sessionFormatCount(
|
|
2384
|
-
const delegationDepth = sessionFormatCount(
|
|
2385
|
-
const seedLength =
|
|
2405
|
+
const record3 = releasedV0Record(snapshotSessionFormatJson(value, `released v${version} physical header`), `released v${version} physical header`);
|
|
2406
|
+
assertReleasedV0Keys(record3, PHYSICAL_HEADER_REQUIRED, PHYSICAL_HEADER_OPTIONAL, `released v${version} physical header`);
|
|
2407
|
+
if (record3["type"] !== "session" || record3["version"] !== version) throw new SessionFormatError(`expected released v${version} physical Session header`);
|
|
2408
|
+
if (typeof record3["id"] !== "string") throw new SessionFormatError(`released v${version} header id must be a string`);
|
|
2409
|
+
const createdAt = sessionFormatCount(record3["createdAt"], `released v${version} header createdAt`);
|
|
2410
|
+
const delegationDepth = sessionFormatCount(record3["delegationDepth"], `released v${version} header delegationDepth`);
|
|
2411
|
+
const seedLength = record3["seedLength"] === void 0 ? 0 : sessionFormatCount(record3["seedLength"], `released v${version} header seedLength`);
|
|
2386
2412
|
for (const key of [
|
|
2387
2413
|
"cwd",
|
|
2388
2414
|
"parentSession",
|
|
2389
2415
|
"agentPreset"
|
|
2390
|
-
]) if (
|
|
2391
|
-
if (
|
|
2416
|
+
]) if (record3[key] !== void 0 && typeof record3[key] !== "string") throw new SessionFormatError(`released v${version} header ${key} must be a string`);
|
|
2417
|
+
if (record3["origin"] !== void 0 && record3["origin"] !== "subagent") throw new SessionFormatError(`released v${version} header origin must be "subagent"`);
|
|
2392
2418
|
const header = {
|
|
2393
2419
|
version,
|
|
2394
|
-
id:
|
|
2420
|
+
id: record3["id"],
|
|
2395
2421
|
createdAt,
|
|
2396
|
-
...
|
|
2397
|
-
...
|
|
2398
|
-
isSeeded:
|
|
2399
|
-
...
|
|
2422
|
+
...record3["cwd"] === void 0 ? {} : { cwd: record3["cwd"] },
|
|
2423
|
+
...record3["parentSession"] === void 0 ? {} : { parentSession: record3["parentSession"] },
|
|
2424
|
+
isSeeded: record3["seedLength"] !== void 0,
|
|
2425
|
+
...record3["origin"] === void 0 ? {} : { origin: record3["origin"] },
|
|
2400
2426
|
delegationDepth,
|
|
2401
|
-
...
|
|
2427
|
+
...record3["agentPreset"] === void 0 ? {} : { agentPreset: record3["agentPreset"] }
|
|
2402
2428
|
};
|
|
2403
2429
|
assertReleasedSessionFormatHeader(header, version);
|
|
2404
2430
|
return {
|
|
@@ -2406,15 +2432,15 @@ function decodePhysicalHeader(value, version) {
|
|
|
2406
2432
|
inheritedEventCount: seedLength
|
|
2407
2433
|
};
|
|
2408
2434
|
}
|
|
2409
|
-
function decodeEvent(
|
|
2410
|
-
if (
|
|
2411
|
-
const seq = sessionFormatCount(
|
|
2435
|
+
function decodeEvent(record3, rowIndex) {
|
|
2436
|
+
if (record3["sourceEventSeqs"] !== void 0) {
|
|
2437
|
+
const seq = sessionFormatCount(record3["seq"], `released Session row ${rowIndex} seq`);
|
|
2412
2438
|
return {
|
|
2413
|
-
...
|
|
2414
|
-
sourceEventSeqs: decodeSeqRanges(
|
|
2439
|
+
...record3,
|
|
2440
|
+
sourceEventSeqs: decodeSeqRanges(record3["sourceEventSeqs"], seq)
|
|
2415
2441
|
};
|
|
2416
2442
|
}
|
|
2417
|
-
return
|
|
2443
|
+
return record3;
|
|
2418
2444
|
}
|
|
2419
2445
|
function decodePackedRun(row, type, rowIndex) {
|
|
2420
2446
|
const label = `released ${type} row ${rowIndex}`;
|
|
@@ -2828,16 +2854,16 @@ function normalizeLegacyErrorReason(reason, seq, sessionId) {
|
|
|
2828
2854
|
"step",
|
|
2829
2855
|
"failure"
|
|
2830
2856
|
], [], `turn/end ${seq} reason`);
|
|
2831
|
-
const
|
|
2832
|
-
assertReleasedV0Keys(
|
|
2857
|
+
const record3 = releasedV0Record(failure, `turn/end ${seq} failure`);
|
|
2858
|
+
assertReleasedV0Keys(record3, ["message", "code"], [
|
|
2833
2859
|
"status",
|
|
2834
2860
|
"providerRetryAfterMs",
|
|
2835
2861
|
"requestId"
|
|
2836
2862
|
], `turn/end ${seq} failure`);
|
|
2837
|
-
if (typeof
|
|
2863
|
+
if (typeof record3["message"] !== "string" || typeof record3["code"] !== "string") throw malformedLegacy(sessionId, "turn/end", seq);
|
|
2838
2864
|
return {
|
|
2839
2865
|
kind: "error",
|
|
2840
|
-
error:
|
|
2866
|
+
error: record3
|
|
2841
2867
|
};
|
|
2842
2868
|
}
|
|
2843
2869
|
assertReleasedV0Keys(reason, [
|
|
@@ -3045,10 +3071,10 @@ var AssistantStreamAccumulator = class {
|
|
|
3045
3071
|
* @returns a detached immutable record list suitable for a durable event.
|
|
3046
3072
|
*/
|
|
3047
3073
|
snapshot() {
|
|
3048
|
-
const records = this.records.map((
|
|
3049
|
-
if (
|
|
3050
|
-
return { ...
|
|
3051
|
-
const { lastTime: _lastTime, ...durable } =
|
|
3074
|
+
const records = this.records.map((record3) => {
|
|
3075
|
+
if (record3.type === "chunk")
|
|
3076
|
+
return { ...record3 };
|
|
3077
|
+
const { lastTime: _lastTime, ...durable } = record3;
|
|
3052
3078
|
if (durable.type === "tool-call-chunks") {
|
|
3053
3079
|
return { ...durable, dt: [...durable.dt], args: [...durable.args] };
|
|
3054
3080
|
}
|
|
@@ -3091,16 +3117,16 @@ var HEADER_OPTIONAL$1 = [
|
|
|
3091
3117
|
"agentPreset"
|
|
3092
3118
|
];
|
|
3093
3119
|
function assertReleasedV2Header(header) {
|
|
3094
|
-
const
|
|
3095
|
-
assertReleasedV2Keys(
|
|
3096
|
-
if (
|
|
3097
|
-
if (typeof
|
|
3098
|
-
sessionFormatCount(
|
|
3099
|
-
sessionFormatCount(
|
|
3100
|
-
if (typeof
|
|
3101
|
-
if (
|
|
3102
|
-
for (const key of ["parentSession", "agentPreset"]) if (
|
|
3103
|
-
if (
|
|
3120
|
+
const record3 = releasedV2Record(header, "format v2 header");
|
|
3121
|
+
assertReleasedV2Keys(record3, HEADER_REQUIRED$1, HEADER_OPTIONAL$1, "format v2 header");
|
|
3122
|
+
if (record3["version"] !== 2) throw new SessionFormatError("expected format v2 header");
|
|
3123
|
+
if (typeof record3["id"] !== "string") throw new SessionFormatError("format v2 header id must be a string");
|
|
3124
|
+
sessionFormatCount(record3["createdAt"], "format v2 header createdAt");
|
|
3125
|
+
sessionFormatCount(record3["delegationDepth"], "format v2 header delegationDepth");
|
|
3126
|
+
if (typeof record3["isSeeded"] !== "boolean") throw new SessionFormatError("format v2 header isSeeded must be boolean");
|
|
3127
|
+
if (record3["cwd"] !== void 0 && (typeof record3["cwd"] !== "string" || !isAbsolute2(record3["cwd"]))) throw new SessionFormatError("format v2 header cwd must be absolute");
|
|
3128
|
+
for (const key of ["parentSession", "agentPreset"]) if (record3[key] !== void 0 && typeof record3[key] !== "string") throw new SessionFormatError(`format v2 header ${key} must be a string`);
|
|
3129
|
+
if (record3["origin"] !== void 0 && record3["origin"] !== "subagent") throw new SessionFormatError('format v2 header origin must be "subagent"');
|
|
3104
3130
|
}
|
|
3105
3131
|
function releasedV2Record(value, label) {
|
|
3106
3132
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new SessionFormatError(`${label} must be an object`);
|
|
@@ -3155,29 +3181,29 @@ var releasedV2SessionFormatCodec = Object.freeze({
|
|
|
3155
3181
|
}
|
|
3156
3182
|
});
|
|
3157
3183
|
function decodePhysicalHeader2(value) {
|
|
3158
|
-
const
|
|
3159
|
-
exactKeys(
|
|
3160
|
-
if (
|
|
3161
|
-
if (typeof
|
|
3162
|
-
const createdAt = sessionFormatCount(
|
|
3163
|
-
const delegationDepth = sessionFormatCount(
|
|
3164
|
-
if (typeof
|
|
3184
|
+
const record3 = jsonRecord(snapshotSessionFormatJson(value, "released v2 physical header"), "released v2 physical header");
|
|
3185
|
+
exactKeys(record3, HEADER_REQUIRED2, HEADER_OPTIONAL2, "released v2 physical header");
|
|
3186
|
+
if (record3["type"] !== "session" || record3["version"] !== 2) throw new SessionFormatError("expected released v2 physical Session header");
|
|
3187
|
+
if (typeof record3["id"] !== "string") throw new SessionFormatError("released v2 header id must be a string");
|
|
3188
|
+
const createdAt = sessionFormatCount(record3["createdAt"], "released v2 header createdAt");
|
|
3189
|
+
const delegationDepth = sessionFormatCount(record3["delegationDepth"], "released v2 header delegationDepth");
|
|
3190
|
+
if (typeof record3["isSeeded"] !== "boolean") throw new SessionFormatError("released v2 header isSeeded must be boolean");
|
|
3165
3191
|
for (const key of [
|
|
3166
3192
|
"cwd",
|
|
3167
3193
|
"parentSession",
|
|
3168
3194
|
"agentPreset"
|
|
3169
|
-
]) if (
|
|
3170
|
-
if (
|
|
3195
|
+
]) if (record3[key] !== void 0 && typeof record3[key] !== "string") throw new SessionFormatError(`released v2 header ${key} must be a string`);
|
|
3196
|
+
if (record3["origin"] !== void 0 && record3["origin"] !== "subagent") throw new SessionFormatError('released v2 header origin must be "subagent"');
|
|
3171
3197
|
const header = snapshotSessionFormatJson({
|
|
3172
3198
|
version: 2,
|
|
3173
|
-
id:
|
|
3199
|
+
id: record3["id"],
|
|
3174
3200
|
createdAt,
|
|
3175
|
-
...
|
|
3176
|
-
...
|
|
3177
|
-
isSeeded:
|
|
3178
|
-
...
|
|
3201
|
+
...record3["cwd"] === void 0 ? {} : { cwd: record3["cwd"] },
|
|
3202
|
+
...record3["parentSession"] === void 0 ? {} : { parentSession: record3["parentSession"] },
|
|
3203
|
+
isSeeded: record3["isSeeded"],
|
|
3204
|
+
...record3["origin"] === void 0 ? {} : { origin: record3["origin"] },
|
|
3179
3205
|
delegationDepth,
|
|
3180
|
-
...
|
|
3206
|
+
...record3["agentPreset"] === void 0 ? {} : { agentPreset: record3["agentPreset"] }
|
|
3181
3207
|
}, "released v2 logical header");
|
|
3182
3208
|
assertReleasedV2Header(header);
|
|
3183
3209
|
return header;
|
|
@@ -3227,19 +3253,19 @@ function createDecoder(headerValue, recovery) {
|
|
|
3227
3253
|
};
|
|
3228
3254
|
}
|
|
3229
3255
|
function decodeEvent2(value, rowIndex) {
|
|
3230
|
-
const
|
|
3231
|
-
const missing = EVENT_REQUIRED.find((key) => !Object.hasOwn(
|
|
3256
|
+
const record3 = jsonRecord(value, `released v2 row ${rowIndex}`);
|
|
3257
|
+
const missing = EVENT_REQUIRED.find((key) => !Object.hasOwn(record3, key));
|
|
3232
3258
|
if (missing !== void 0) throw new SessionFormatError(`released v2 row ${rowIndex} lacks required field ${missing}`);
|
|
3233
|
-
const unexpected = Object.keys(
|
|
3259
|
+
const unexpected = Object.keys(record3).find((key) => !EVENT_KEYS.has(key));
|
|
3234
3260
|
if (unexpected !== void 0) throw new SessionFormatError(`released v2 row ${rowIndex} has unexpected field ${unexpected}`);
|
|
3235
|
-
if (typeof
|
|
3236
|
-
sessionFormatSafeInteger(
|
|
3237
|
-
if (
|
|
3238
|
-
if (
|
|
3239
|
-
const seq = sessionFormatCount(
|
|
3261
|
+
if (typeof record3["type"] !== "string") throw new SessionFormatError(`released v2 row ${rowIndex} type must be a string`);
|
|
3262
|
+
sessionFormatSafeInteger(record3["time"], `released v2 row ${rowIndex} time`);
|
|
3263
|
+
if (record3["ignorable"] !== void 0 && record3["ignorable"] !== true) throw new SessionFormatError(`released v2 row ${rowIndex} ignorable must be true when present`);
|
|
3264
|
+
if (record3["sourceEventSeqs"] === void 0) return record3;
|
|
3265
|
+
const seq = sessionFormatCount(record3["seq"], `released v2 row ${rowIndex} seq`);
|
|
3240
3266
|
return {
|
|
3241
|
-
...
|
|
3242
|
-
sourceEventSeqs: decodeSeqRanges2(
|
|
3267
|
+
...record3,
|
|
3268
|
+
sourceEventSeqs: decodeSeqRanges2(record3["sourceEventSeqs"], seq)
|
|
3243
3269
|
};
|
|
3244
3270
|
}
|
|
3245
3271
|
function encodeHeader(header, inheritedEventCount) {
|
|
@@ -3310,11 +3336,11 @@ function jsonRecord(value, label) {
|
|
|
3310
3336
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new SessionFormatError(`${label} must be an object`);
|
|
3311
3337
|
return value;
|
|
3312
3338
|
}
|
|
3313
|
-
function exactKeys(
|
|
3339
|
+
function exactKeys(record3, required, optional, label) {
|
|
3314
3340
|
const allowed = /* @__PURE__ */ new Set([...required, ...optional]);
|
|
3315
|
-
const missing = required.find((key) => !Object.hasOwn(
|
|
3341
|
+
const missing = required.find((key) => !Object.hasOwn(record3, key));
|
|
3316
3342
|
if (missing !== void 0) throw new SessionFormatError(`${label} lacks ${missing}`);
|
|
3317
|
-
const unexpected = Object.keys(
|
|
3343
|
+
const unexpected = Object.keys(record3).find((key) => !allowed.has(key));
|
|
3318
3344
|
if (unexpected !== void 0) throw new SessionFormatError(`${label} has unexpected field ${unexpected}`);
|
|
3319
3345
|
}
|
|
3320
3346
|
var CHUNK_EVENT_REQUIRED = [
|
|
@@ -3641,21 +3667,21 @@ function matchesChunkSources(group, sources) {
|
|
|
3641
3667
|
}
|
|
3642
3668
|
return true;
|
|
3643
3669
|
}
|
|
3644
|
-
function recordLastTime(
|
|
3645
|
-
if (
|
|
3646
|
-
return
|
|
3670
|
+
function recordLastTime(record3) {
|
|
3671
|
+
if (record3.type === "chunk") return record3.time;
|
|
3672
|
+
return record3.dt.reduce((time, gap) => time + gap, record3.time0);
|
|
3647
3673
|
}
|
|
3648
|
-
function mutableRecord(
|
|
3649
|
-
if (
|
|
3650
|
-
if (
|
|
3651
|
-
...
|
|
3652
|
-
dt: [...
|
|
3653
|
-
args: [...
|
|
3674
|
+
function mutableRecord(record3) {
|
|
3675
|
+
if (record3.type === "chunk") return record3;
|
|
3676
|
+
if (record3.type === "tool-call-chunks") return {
|
|
3677
|
+
...record3,
|
|
3678
|
+
dt: [...record3.dt],
|
|
3679
|
+
args: [...record3.args]
|
|
3654
3680
|
};
|
|
3655
3681
|
return {
|
|
3656
|
-
...
|
|
3657
|
-
dt: [...
|
|
3658
|
-
texts: [...
|
|
3682
|
+
...record3,
|
|
3683
|
+
dt: [...record3.dt],
|
|
3684
|
+
texts: [...record3.texts]
|
|
3659
3685
|
};
|
|
3660
3686
|
}
|
|
3661
3687
|
function appendStreamRecord(group, source, lastTime, owned = true) {
|
|
@@ -3698,12 +3724,12 @@ function appendStreamRecord(group, source, lastTime, owned = true) {
|
|
|
3698
3724
|
function flushAccumulator(group) {
|
|
3699
3725
|
const accumulator = group.accumulator;
|
|
3700
3726
|
if (accumulator === void 0) return;
|
|
3701
|
-
for (const
|
|
3727
|
+
for (const record3 of accumulator.snapshot()) appendStreamRecord(group, record3, recordLastTime(record3), false);
|
|
3702
3728
|
delete group.accumulator;
|
|
3703
3729
|
}
|
|
3704
3730
|
function streamOf(group) {
|
|
3705
3731
|
flushAccumulator(group);
|
|
3706
|
-
return group.stream.map(({ record:
|
|
3732
|
+
return group.stream.map(({ record: record3 }) => record3);
|
|
3707
3733
|
}
|
|
3708
3734
|
function messageEvent(source, group) {
|
|
3709
3735
|
const data = record(source.data);
|
|
@@ -3798,9 +3824,687 @@ function coordinate(value) {
|
|
|
3798
3824
|
function refusal(message) {
|
|
3799
3825
|
return new SessionFormatUnsupportedMigrationError(message);
|
|
3800
3826
|
}
|
|
3827
|
+
|
|
3828
|
+
// node_modules/@deepseek-ai/dsh-session-format-v2-to-v3/lib/index.js
|
|
3829
|
+
import { createHash } from "node:crypto";
|
|
3830
|
+
var SURFACE_TYPES = /* @__PURE__ */ new Set([
|
|
3831
|
+
"system/message",
|
|
3832
|
+
"user/message",
|
|
3833
|
+
"assistant/message",
|
|
3834
|
+
"tool/result"
|
|
3835
|
+
]);
|
|
3836
|
+
var SOURCE_KINDS = /* @__PURE__ */ new Set([
|
|
3837
|
+
"user",
|
|
3838
|
+
"plugin",
|
|
3839
|
+
"model",
|
|
3840
|
+
"tool",
|
|
3841
|
+
"agent-instructions",
|
|
3842
|
+
"session-reference",
|
|
3843
|
+
"team-message",
|
|
3844
|
+
"goal",
|
|
3845
|
+
"skill-invocation",
|
|
3846
|
+
"skill-catalog",
|
|
3847
|
+
"coordinator",
|
|
3848
|
+
"subagent-report",
|
|
3849
|
+
"subagent-settled",
|
|
3850
|
+
"webhook",
|
|
3851
|
+
"agent-message"
|
|
3852
|
+
]);
|
|
3853
|
+
function record2(value, label) {
|
|
3854
|
+
if (!isSessionFormatJsonObject(value)) throw new SessionFormatError(label + " must be an object");
|
|
3855
|
+
return value;
|
|
3856
|
+
}
|
|
3857
|
+
function keys(value, required, optional, label) {
|
|
3858
|
+
const missing = required.find((key) => !Object.hasOwn(value, key));
|
|
3859
|
+
const unexpected = Object.keys(value).find((key) => !required.includes(key) && !optional.includes(key));
|
|
3860
|
+
if (missing !== void 0) throw new SessionFormatError(label + " lacks required field " + missing);
|
|
3861
|
+
if (unexpected !== void 0) throw new SessionFormatError(label + " has unexpected field " + unexpected);
|
|
3862
|
+
}
|
|
3863
|
+
function assertEvent(event, version) {
|
|
3864
|
+
if (version === 3) {
|
|
3865
|
+
assertV3Event(event);
|
|
3866
|
+
return;
|
|
3867
|
+
}
|
|
3868
|
+
const disposition2 = RELEASED_V2_EVENT_DISPOSITIONS[event.type];
|
|
3869
|
+
const feedback = event.type === "feedback/message-put" || event.type === "feedback/message-delete";
|
|
3870
|
+
if (disposition2 === void 0 && !feedback) throw new SessionFormatUnsupportedMigrationError("format v2 to v3 cannot safely transform unclassified event " + event.type);
|
|
3871
|
+
const surface = SURFACE_TYPES.has(event.type);
|
|
3872
|
+
keys(event, [
|
|
3873
|
+
"type",
|
|
3874
|
+
"seq",
|
|
3875
|
+
"time",
|
|
3876
|
+
"data"
|
|
3877
|
+
], surface ? [
|
|
3878
|
+
"ignorable",
|
|
3879
|
+
"sourceEventSeqs",
|
|
3880
|
+
"surfaceOp"
|
|
3881
|
+
] : ["ignorable"], event.type);
|
|
3882
|
+
sessionFormatCount(event.seq, "event seq");
|
|
3883
|
+
sessionFormatSafeInteger(event.time, "event time");
|
|
3884
|
+
if (event["ignorable"] !== void 0 && event["ignorable"] !== true) throw new SessionFormatError("ignorable must be true");
|
|
3885
|
+
if (surface) {
|
|
3886
|
+
assertReleasedSurfaceMetadata(event, event.seq, event.type, "forbid-assistant");
|
|
3887
|
+
if (event["surfaceOp"] === void 0) throw new SessionFormatError(event.type + " requires surfaceOp");
|
|
3888
|
+
}
|
|
3889
|
+
const data = record2(event.data, event.type + " data");
|
|
3890
|
+
if (feedback) {
|
|
3891
|
+
assertFeedback(event.type, data);
|
|
3892
|
+
return;
|
|
3893
|
+
}
|
|
3894
|
+
const admitted = disposition2;
|
|
3895
|
+
keys(data, admitted.required, admitted.optional, event.type + " data");
|
|
3896
|
+
assertOwnedContent(event, data);
|
|
3897
|
+
if (event.type !== "assistant/attempt") assertReleasedPayloadSemantics(event, version);
|
|
3898
|
+
if (event.type === "assistant/message" || event.type === "assistant/attempt") {
|
|
3899
|
+
for (const coordinate2 of ["turn", "step"]) if (sessionFormatCount(data[coordinate2], coordinate2) === 0) throw new SessionFormatError(coordinate2 + " must be positive");
|
|
3900
|
+
}
|
|
3901
|
+
if (event.type === "session/end-seed" && data["inherited"] !== void 0 && data["inherited"] !== true) throw new SessionFormatError("session/end-seed inherited must be true");
|
|
3902
|
+
if (event.type === "user/message") assertSource(data);
|
|
3903
|
+
if (event.type === "assistant/message" || event.type === "tool/result") assertSource(record2(data["message"], "message"));
|
|
3904
|
+
if (event.type === "tool/result" && isSessionFormatJsonObject(data["error"]) && data["error"]["code"] === "TOOL_NOT_STARTED") {
|
|
3905
|
+
const message = record2(data["message"], "tool result message");
|
|
3906
|
+
const source = record2(message["source"], "tool result source");
|
|
3907
|
+
if (!isRepairIdentity(message["id"], source["callId"])) throw new SessionFormatError("TOOL_NOT_STARTED repair requires its canonical historical message id");
|
|
3908
|
+
}
|
|
3909
|
+
if (event.type === "agent/inbox/spliced" || event.type === "session/title-llm-request") {
|
|
3910
|
+
const messages = data[event.type === "agent/inbox/spliced" ? "inserted" : "messages"];
|
|
3911
|
+
for (const message of messages) assertSource(message);
|
|
3912
|
+
}
|
|
3913
|
+
}
|
|
3914
|
+
function isRepairIdentity(id, callId) {
|
|
3915
|
+
if (typeof callId !== "string") return false;
|
|
3916
|
+
const prefix = "interrupted-tool-result-" + callId + "-";
|
|
3917
|
+
if (typeof id !== "string" || !id.startsWith(prefix)) return false;
|
|
3918
|
+
const suffix = id.slice(prefix.length);
|
|
3919
|
+
return /^(0|[1-9]\d*)$/.test(suffix) && Number.isSafeInteger(Number(suffix));
|
|
3920
|
+
}
|
|
3921
|
+
function assertSource(message) {
|
|
3922
|
+
const source = record2(message["source"], "message source");
|
|
3923
|
+
if (typeof source["kind"] !== "string" || !SOURCE_KINDS.has(source["kind"])) throw new SessionFormatUnsupportedMigrationError("cannot safely transform unclassified message source");
|
|
3924
|
+
if (source["kind"] === "agent-message") {
|
|
3925
|
+
keys(source, [
|
|
3926
|
+
"kind",
|
|
3927
|
+
"form",
|
|
3928
|
+
"senderSessionId"
|
|
3929
|
+
], [], "agent-message source");
|
|
3930
|
+
if (source["form"] !== "relay" || typeof source["senderSessionId"] !== "string" || source["senderSessionId"].length === 0) throw new SessionFormatError("agent-message source requires relay form and senderSessionId");
|
|
3931
|
+
}
|
|
3932
|
+
}
|
|
3933
|
+
var CONTENT_KINDS = /* @__PURE__ */ new Set([
|
|
3934
|
+
"text",
|
|
3935
|
+
"reasoning",
|
|
3936
|
+
"image",
|
|
3937
|
+
"file",
|
|
3938
|
+
"tool-call",
|
|
3939
|
+
"tool-result"
|
|
3940
|
+
]);
|
|
3941
|
+
function contentArray(value, label) {
|
|
3942
|
+
if (!Array.isArray(value)) throw new SessionFormatError(label + ": content must be an array");
|
|
3943
|
+
return value;
|
|
3944
|
+
}
|
|
3945
|
+
function assertOwnedContent(event, data) {
|
|
3946
|
+
const label = "format v2 " + event.type + " at seq " + String(event.seq) + " data";
|
|
3947
|
+
switch (event.type) {
|
|
3948
|
+
case "user/message":
|
|
3949
|
+
case "tool/code-dispatch":
|
|
3950
|
+
assertContentKinds(data["content"], label + ".content");
|
|
3951
|
+
break;
|
|
3952
|
+
case "assistant/message":
|
|
3953
|
+
case "tool/result":
|
|
3954
|
+
case "team/message/queued":
|
|
3955
|
+
assertContentKinds(record2(data["message"], label + ".message")["content"], label + ".message.content");
|
|
3956
|
+
break;
|
|
3957
|
+
case "agent/inbox/spliced":
|
|
3958
|
+
case "session/title-llm-request": {
|
|
3959
|
+
const field = event.type === "agent/inbox/spliced" ? "inserted" : "messages";
|
|
3960
|
+
for (const [index, value] of contentArray(data[field], label + "." + field).entries()) {
|
|
3961
|
+
const path = label + "." + field + "[" + String(index) + "]";
|
|
3962
|
+
assertContentKinds(record2(value, path)["content"], path + ".content");
|
|
3963
|
+
}
|
|
3964
|
+
break;
|
|
3965
|
+
}
|
|
3966
|
+
case "compaction/summary":
|
|
3967
|
+
assertContentKinds(data["summary"], label + ".summary");
|
|
3968
|
+
if (data["rawOutput"] !== void 0) assertContentKinds(data["rawOutput"], label + ".rawOutput");
|
|
3969
|
+
break;
|
|
3970
|
+
}
|
|
3971
|
+
if (event.type === "assistant/message" || event.type === "assistant/attempt") for (const [index, value] of contentArray(data["stream"], label + ".stream").entries()) {
|
|
3972
|
+
const path = label + ".stream[" + String(index) + "]";
|
|
3973
|
+
const entry = record2(value, path);
|
|
3974
|
+
if (entry["type"] !== "chunk") continue;
|
|
3975
|
+
const chunk = record2(entry["chunk"], path + ".chunk");
|
|
3976
|
+
if (chunk["type"] === "block-end") assertContentBlock(chunk["block"], path + ".chunk.block");
|
|
3977
|
+
if (chunk["type"] === "block-start") assertContentKind(chunk["blockType"], path + ".chunk.blockType");
|
|
3978
|
+
}
|
|
3979
|
+
}
|
|
3980
|
+
function assertContentKind(kind, label) {
|
|
3981
|
+
if (typeof kind !== "string" || !CONTENT_KINDS.has(kind)) throw new SessionFormatUnsupportedMigrationError(label + ": cannot safely transform unclassified message content kind " + JSON.stringify(kind));
|
|
3982
|
+
}
|
|
3983
|
+
function assertContentKinds(content, label) {
|
|
3984
|
+
for (const [index, value] of contentArray(content, label).entries()) assertContentBlock(value, label + "[" + String(index) + "]");
|
|
3985
|
+
}
|
|
3986
|
+
function assertContentBlock(value, label) {
|
|
3987
|
+
const block = record2(value, label);
|
|
3988
|
+
assertContentKind(block["type"], label);
|
|
3989
|
+
if (block["type"] === "tool-result") {
|
|
3990
|
+
if (!Array.isArray(block["content"])) throw new SessionFormatError(label + '.content: invalid message content kind "tool-result": content must be an array');
|
|
3991
|
+
assertContentKinds(block["content"], label + ".content");
|
|
3992
|
+
}
|
|
3993
|
+
if (block["type"] === "file") {
|
|
3994
|
+
keys(block, ["type", "attachment"], [], label + ' kind "file"');
|
|
3995
|
+
const attachment = record2(block["attachment"], label + ' kind "file" attachment');
|
|
3996
|
+
keys(attachment, [
|
|
3997
|
+
"attachmentId",
|
|
3998
|
+
"name",
|
|
3999
|
+
"bytes"
|
|
4000
|
+
], [], label + ' kind "file" attachment');
|
|
4001
|
+
if (typeof attachment["attachmentId"] !== "string" || attachment["attachmentId"].length === 0 || typeof attachment["name"] !== "string") throw new SessionFormatError(label + ' kind "file": file attachment requires attachmentId and name');
|
|
4002
|
+
sessionFormatCount(attachment["bytes"], label + ' kind "file" attachment bytes');
|
|
4003
|
+
return;
|
|
4004
|
+
}
|
|
4005
|
+
const probe = {
|
|
4006
|
+
type: "user/message",
|
|
4007
|
+
seq: 0,
|
|
4008
|
+
time: 0,
|
|
4009
|
+
data: {
|
|
4010
|
+
id: "content-admission",
|
|
4011
|
+
role: "user",
|
|
4012
|
+
source: { kind: "user" },
|
|
4013
|
+
content: [block["type"] === "tool-result" ? {
|
|
4014
|
+
...block,
|
|
4015
|
+
content: []
|
|
4016
|
+
} : block]
|
|
4017
|
+
}
|
|
4018
|
+
};
|
|
4019
|
+
try {
|
|
4020
|
+
assertReleasedPayloadSemantics(probe, 2);
|
|
4021
|
+
} catch (error) {
|
|
4022
|
+
throw new SessionFormatError(label + ": invalid message content kind " + JSON.stringify(block["type"]) + ": " + String(error));
|
|
4023
|
+
}
|
|
4024
|
+
}
|
|
4025
|
+
function assertV3StructuralRow(value) {
|
|
4026
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return;
|
|
4027
|
+
const row = value;
|
|
4028
|
+
if (row["type"] === "request/header") {
|
|
4029
|
+
const data = record2(row["data"], "request/header data");
|
|
4030
|
+
if (Object.hasOwn(record2(data["header"], "request header"), "system")) throw new SessionFormatUnsupportedMigrationError("format v3 request/header rejects retired header.system");
|
|
4031
|
+
} else if (row["type"] === "system/message") {
|
|
4032
|
+
const data = record2(row["data"], "system/message data");
|
|
4033
|
+
assertSystem({
|
|
4034
|
+
type: "system/message",
|
|
4035
|
+
seq: 0,
|
|
4036
|
+
time: 0,
|
|
4037
|
+
data
|
|
4038
|
+
}, data);
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4041
|
+
function assertSystem(event, data) {
|
|
4042
|
+
keys(data, [
|
|
4043
|
+
"turn",
|
|
4044
|
+
"step",
|
|
4045
|
+
"message"
|
|
4046
|
+
], [], "system/message data");
|
|
4047
|
+
for (const coordinate2 of ["turn", "step"]) if (sessionFormatCount(data[coordinate2], coordinate2) === 0) throw new SessionFormatError(coordinate2 + " must be positive");
|
|
4048
|
+
const message = record2(data["message"], "system message");
|
|
4049
|
+
keys(message, [
|
|
4050
|
+
"id",
|
|
4051
|
+
"role",
|
|
4052
|
+
"source",
|
|
4053
|
+
"content"
|
|
4054
|
+
], [], "system message");
|
|
4055
|
+
if (typeof message["id"] !== "string" || message["id"].length === 0 || message["role"] !== "system") throw new SessionFormatError("system message requires an id and system role");
|
|
4056
|
+
const source = record2(message["source"], "system source");
|
|
4057
|
+
if (source["kind"] !== "plugin" || typeof source["plugin"] !== "string" || source["plugin"].length === 0) throw new SessionFormatError("system message requires plugin source");
|
|
4058
|
+
assertReleasedPayloadSemantics({
|
|
4059
|
+
...event,
|
|
4060
|
+
type: "user/message",
|
|
4061
|
+
data: {
|
|
4062
|
+
...message,
|
|
4063
|
+
role: "user"
|
|
4064
|
+
}
|
|
4065
|
+
}, 3);
|
|
4066
|
+
}
|
|
4067
|
+
function assertFeedback(type, data) {
|
|
4068
|
+
keys(data, type === "feedback/message-put" ? ["sessionId", "item"] : ["sessionId", "messageId"], [], type);
|
|
4069
|
+
if (typeof data["sessionId"] !== "string") throw new SessionFormatError("feedback sessionId must be a string");
|
|
4070
|
+
if (type === "feedback/message-delete") {
|
|
4071
|
+
if (typeof data["messageId"] !== "string") throw new SessionFormatError("feedback messageId must be a string");
|
|
4072
|
+
return;
|
|
4073
|
+
}
|
|
4074
|
+
const item = record2(data["item"], "feedback item");
|
|
4075
|
+
keys(item, [
|
|
4076
|
+
"messageId",
|
|
4077
|
+
"rating",
|
|
4078
|
+
"version",
|
|
4079
|
+
"createdAt",
|
|
4080
|
+
"updatedAt"
|
|
4081
|
+
], ["note"], "feedback item");
|
|
4082
|
+
for (const key of ["messageId", "version"]) if (typeof item[key] !== "string") throw new SessionFormatError("feedback " + key + " must be a string");
|
|
4083
|
+
if (item["rating"] !== "positive" && item["rating"] !== "negative") throw new SessionFormatError("invalid feedback rating");
|
|
4084
|
+
if (item["note"] !== void 0 && typeof item["note"] !== "string") throw new SessionFormatError("feedback note must be a string");
|
|
4085
|
+
sessionFormatCount(item["createdAt"], "feedback createdAt");
|
|
4086
|
+
sessionFormatCount(item["updatedAt"], "feedback updatedAt");
|
|
4087
|
+
}
|
|
4088
|
+
function assertV3Event(event, knownEventTypes) {
|
|
4089
|
+
const value = record2(event, "format v3 event");
|
|
4090
|
+
const subject = `format v3 ${event.type} at seq ${event.seq}`;
|
|
4091
|
+
const opaque = !(!(event.type === "tool/code-dispatch-start" || event.type === "tool/code-dispatch") && (SURFACE_TYPES.has(event.type) || RELEASED_V2_EVENT_DISPOSITIONS[event.type] !== void 0 || event.type === "tool/ptc-dispatch-start" || event.type === "tool/ptc-dispatch" || event.type === "feedback/message-put" || event.type === "feedback/message-delete" || knownEventTypes?.has(event.type) === true));
|
|
4092
|
+
keys(value, [
|
|
4093
|
+
"type",
|
|
4094
|
+
"seq",
|
|
4095
|
+
"time",
|
|
4096
|
+
"data"
|
|
4097
|
+
], SURFACE_TYPES.has(event.type) || opaque ? [
|
|
4098
|
+
"ignorable",
|
|
4099
|
+
"surfaceOp",
|
|
4100
|
+
"sourceEventSeqs"
|
|
4101
|
+
] : ["ignorable"], subject);
|
|
4102
|
+
if (typeof event.type !== "string") throw new SessionFormatError(`${subject} type must be a string`);
|
|
4103
|
+
sessionFormatCount(event.seq, `${subject} seq`);
|
|
4104
|
+
sessionFormatSafeInteger(event.time, `${subject} time`);
|
|
4105
|
+
if (Object.hasOwn(value, "ignorable") && value["ignorable"] !== true) throw new SessionFormatError(`${subject} ignorable must be true when present`);
|
|
4106
|
+
if (SURFACE_TYPES.has(event.type)) {
|
|
4107
|
+
const operation = value["surfaceOp"];
|
|
4108
|
+
if (operation === void 0) throw new SessionFormatError(`${subject} requires a surfaceOp marker`);
|
|
4109
|
+
if (operation !== "append") {
|
|
4110
|
+
const replace = record2(operation, `${subject} surfaceOp`);
|
|
4111
|
+
if (Object.keys(replace).length !== 3 || replace["op"] !== "replace" || !Object.hasOwn(replace, "startSeq") || !Object.hasOwn(replace, "endSeq")) throw new SessionFormatError(`${subject} requires exact replace fields op/startSeq/endSeq`);
|
|
4112
|
+
for (const key of ["startSeq", "endSeq"]) if (sessionFormatCount(replace[key], `${subject} surfaceOp ${key}`) >= event.seq) throw new SessionFormatError(`${subject} replacement endpoints must reference earlier events`);
|
|
4113
|
+
}
|
|
4114
|
+
const sources = value["sourceEventSeqs"];
|
|
4115
|
+
if (event.type === "assistant/message" && sources !== void 0) throw new SessionFormatError(`${subject} embeds its stream and cannot carry sourceEventSeqs`);
|
|
4116
|
+
if (sources !== void 0) {
|
|
4117
|
+
if (!Array.isArray(sources) || sources.length === 0) throw new SessionFormatError(`${subject} sourceEventSeqs must be a non-empty array`);
|
|
4118
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4119
|
+
for (const source of sources) {
|
|
4120
|
+
const seq = sessionFormatCount(source, `${subject} sourceEventSeqs member`);
|
|
4121
|
+
if (seq >= event.seq || seen.has(seq)) throw new SessionFormatError(`${subject} sourceEventSeqs must be unique earlier seqs`);
|
|
4122
|
+
seen.add(seq);
|
|
4123
|
+
}
|
|
4124
|
+
}
|
|
4125
|
+
}
|
|
4126
|
+
assertV3StructuralRow(event);
|
|
4127
|
+
assertCanonicalPayload(event);
|
|
4128
|
+
}
|
|
4129
|
+
function assertCanonicalPayload(event) {
|
|
4130
|
+
const subject = `format v3 ${event.type} at seq ${event.seq}`;
|
|
4131
|
+
if (event.type === "request/header") {
|
|
4132
|
+
const header = record2(record2(event.data, `${subject} data`)["header"], `${subject} header`);
|
|
4133
|
+
if (Array.isArray(header["tools"]) && header["tools"].length === 0 || isSessionFormatJsonObject(header["adapterDefaults"]) && Object.keys(header["adapterDefaults"]).length === 0) throw new SessionFormatError(`${subject} empty optional header fields must be omitted`);
|
|
4134
|
+
}
|
|
4135
|
+
if (event.type !== "tool/result") return;
|
|
4136
|
+
const data = record2(event.data, `${subject} data`);
|
|
4137
|
+
if (data["error"] === void 0) return;
|
|
4138
|
+
const content = record2(data["message"], `${subject} message`)["content"];
|
|
4139
|
+
if (!Array.isArray(content) || content.length !== 1 || !isSessionFormatJsonObject(content[0]) || content[0]["type"] !== "tool-result" || content[0]["isError"] !== true) throw new SessionFormatError(`${subject} carries error metadata for a non-error tool result`);
|
|
4140
|
+
}
|
|
4141
|
+
function canonicalizeTransformedEvent(event) {
|
|
4142
|
+
let target = event;
|
|
4143
|
+
const operation = event["surfaceOp"];
|
|
4144
|
+
if (operation !== void 0 && operation !== "append") {
|
|
4145
|
+
const replace = record2(operation, `format v2 ${event.type} at seq ${event.seq} surfaceOp`);
|
|
4146
|
+
if (Object.keys(replace).length !== 3 || replace["op"] !== "replace" || !Object.hasOwn(replace, "start") || !Object.hasOwn(replace, "end")) throw new SessionFormatError(`format v2 ${event.type} at seq ${event.seq} requires exact replace fields op/start/end`);
|
|
4147
|
+
target = {
|
|
4148
|
+
...event,
|
|
4149
|
+
surfaceOp: {
|
|
4150
|
+
op: "replace",
|
|
4151
|
+
startSeq: sessionFormatCount(replace["start"], `format v2 ${event.type} at seq ${event.seq} replace start`),
|
|
4152
|
+
endSeq: sessionFormatCount(replace["end"], `format v2 ${event.type} at seq ${event.seq} replace end`)
|
|
4153
|
+
}
|
|
4154
|
+
};
|
|
4155
|
+
}
|
|
4156
|
+
if (event.type === "request/header") {
|
|
4157
|
+
const data = record2(event.data, `format v2 request/header at seq ${event.seq} data`);
|
|
4158
|
+
const header = record2(data["header"], `format v2 request/header at seq ${event.seq} header`);
|
|
4159
|
+
const empty = Object.keys(header).filter((key) => key === "tools" && Array.isArray(header[key]) && header[key].length === 0 || key === "adapterDefaults" && isSessionFormatJsonObject(header[key]) && Object.keys(header[key]).length === 0);
|
|
4160
|
+
if (empty.length > 0) {
|
|
4161
|
+
const canonical = Object.fromEntries(Object.entries(header).filter(([key]) => !empty.includes(key)));
|
|
4162
|
+
target = {
|
|
4163
|
+
...target,
|
|
4164
|
+
data: {
|
|
4165
|
+
...data,
|
|
4166
|
+
header: canonical
|
|
4167
|
+
}
|
|
4168
|
+
};
|
|
4169
|
+
}
|
|
4170
|
+
}
|
|
4171
|
+
assertV3Event(target);
|
|
4172
|
+
return target;
|
|
4173
|
+
}
|
|
4174
|
+
function assertReleasedV3Header(header) {
|
|
4175
|
+
if (header.version !== 3) throw new SessionFormatError("expected format v3 header");
|
|
4176
|
+
assertReleasedV2Header({
|
|
4177
|
+
...header,
|
|
4178
|
+
version: 2
|
|
4179
|
+
});
|
|
4180
|
+
}
|
|
4181
|
+
function assertV3EventAdmission(event) {
|
|
4182
|
+
if ((event.type === "tool/code-dispatch-start" || event.type === "tool/code-dispatch") && event["ignorable"] !== true) throw new SessionFormatUnsupportedMigrationError("format v3 contains unknown event type " + JSON.stringify(event.type) + " at seq " + String(event.seq));
|
|
4183
|
+
}
|
|
4184
|
+
var releasedV3SessionFormatCodec = Object.freeze({
|
|
4185
|
+
version: 3,
|
|
4186
|
+
decodeHeader(value) {
|
|
4187
|
+
return {
|
|
4188
|
+
...releasedV2SessionFormatCodec.decodeHeader(v2PhysicalHeader(value)),
|
|
4189
|
+
version: 3
|
|
4190
|
+
};
|
|
4191
|
+
},
|
|
4192
|
+
createDecoder(value, recovery) {
|
|
4193
|
+
const decoder = releasedV2SessionFormatCodec.createDecoder(v2PhysicalHeader(value), recovery);
|
|
4194
|
+
let issue;
|
|
4195
|
+
let acceptedInheritedCut;
|
|
4196
|
+
return {
|
|
4197
|
+
header: {
|
|
4198
|
+
...decoder.header,
|
|
4199
|
+
version: 3
|
|
4200
|
+
},
|
|
4201
|
+
decodeRow(row, context) {
|
|
4202
|
+
assertV3RowAdmission(row);
|
|
4203
|
+
decoder.decodeRow(row, {
|
|
4204
|
+
emitRun: context.emitRun.bind(context),
|
|
4205
|
+
emitEvent(event) {
|
|
4206
|
+
assertV3EventAdmission(event);
|
|
4207
|
+
if (issue === void 0) try {
|
|
4208
|
+
assertV3Event(event);
|
|
4209
|
+
} catch (error) {
|
|
4210
|
+
const invalid = error;
|
|
4211
|
+
if (recovery === "strict") throw invalid;
|
|
4212
|
+
issue = invalid;
|
|
4213
|
+
}
|
|
4214
|
+
if (issue !== void 0) {
|
|
4215
|
+
if (event.type === "turn/end") throw issue;
|
|
4216
|
+
return;
|
|
4217
|
+
}
|
|
4218
|
+
if (event.type === "session/end-seed" && isSessionFormatJsonObject(event.data) && event.data["inherited"] === true) acceptedInheritedCut = event.seq;
|
|
4219
|
+
context.emitEvent(event);
|
|
4220
|
+
}
|
|
4221
|
+
});
|
|
4222
|
+
},
|
|
4223
|
+
finish(context) {
|
|
4224
|
+
if (issue === void 0) return decoder.finish(context);
|
|
4225
|
+
if (decoder.header.isSeeded && acceptedInheritedCut === void 0) throw new SessionFormatError("format v3 seeded Session lacks an accepted inherited end-seed marker");
|
|
4226
|
+
if (!decoder.header.isSeeded && acceptedInheritedCut !== void 0) throw new SessionFormatError("format v3 unseeded Session contains an inherited end-seed marker");
|
|
4227
|
+
return acceptedInheritedCut ?? 0;
|
|
4228
|
+
}
|
|
4229
|
+
};
|
|
4230
|
+
},
|
|
4231
|
+
encodeHeader(header, inheritedEventCount) {
|
|
4232
|
+
assertReleasedV3Header(header);
|
|
4233
|
+
return {
|
|
4234
|
+
...releasedV2SessionFormatCodec.encodeHeader({
|
|
4235
|
+
...header,
|
|
4236
|
+
version: 2
|
|
4237
|
+
}, inheritedEventCount),
|
|
4238
|
+
version: 3
|
|
4239
|
+
};
|
|
4240
|
+
},
|
|
4241
|
+
encodeEvent(event) {
|
|
4242
|
+
assertV3EventAdmission(event);
|
|
4243
|
+
assertV3Event(event);
|
|
4244
|
+
return releasedV2SessionFormatCodec.encodeEvent(event);
|
|
4245
|
+
}
|
|
4246
|
+
});
|
|
4247
|
+
function assertV3RowAdmission(row) {
|
|
4248
|
+
assertV3StructuralRow(row);
|
|
4249
|
+
if (typeof row === "object" && row !== null && !Array.isArray(row)) assertV3EventAdmission(row);
|
|
4250
|
+
}
|
|
4251
|
+
function v2PhysicalHeader(value) {
|
|
4252
|
+
const header = snapshotSessionFormatJson(value, "format v3 physical header");
|
|
4253
|
+
if (!isSessionFormatJsonObject(header) || header["version"] !== 3) throw new SessionFormatError("expected format v3 physical Session header");
|
|
4254
|
+
return {
|
|
4255
|
+
...header,
|
|
4256
|
+
version: 2
|
|
4257
|
+
};
|
|
4258
|
+
}
|
|
4259
|
+
function remapEvent(event, seq, mapping) {
|
|
4260
|
+
const one = (value) => {
|
|
4261
|
+
const source = sessionFormatCount(value, "source event reference");
|
|
4262
|
+
const target = mapping[source];
|
|
4263
|
+
if (source >= event.seq || target === void 0) throw new SessionFormatError("reference must name an earlier source event");
|
|
4264
|
+
return target;
|
|
4265
|
+
};
|
|
4266
|
+
const list = (value) => {
|
|
4267
|
+
if (!Array.isArray(value)) throw new SessionFormatError("sequence references must be an array");
|
|
4268
|
+
return value.map(one);
|
|
4269
|
+
};
|
|
4270
|
+
const range = (value) => {
|
|
4271
|
+
const source = record2(value, "sequence range");
|
|
4272
|
+
return {
|
|
4273
|
+
...source,
|
|
4274
|
+
start: one(source["start"]),
|
|
4275
|
+
end: one(source["end"])
|
|
4276
|
+
};
|
|
4277
|
+
};
|
|
4278
|
+
let data = record2(event.data, event.type);
|
|
4279
|
+
switch (event.type) {
|
|
4280
|
+
case "command/done":
|
|
4281
|
+
if (data["sourceEventSeq"] !== void 0) data = {
|
|
4282
|
+
...data,
|
|
4283
|
+
sourceEventSeq: one(data["sourceEventSeq"])
|
|
4284
|
+
};
|
|
4285
|
+
break;
|
|
4286
|
+
case "compaction/summary":
|
|
4287
|
+
case "compaction/prune":
|
|
4288
|
+
data = {
|
|
4289
|
+
...data,
|
|
4290
|
+
shadowedRange: range(data["shadowedRange"]),
|
|
4291
|
+
shadowedSeqs: list(data["shadowedSeqs"])
|
|
4292
|
+
};
|
|
4293
|
+
break;
|
|
4294
|
+
case "session/title":
|
|
4295
|
+
case "session/title-llm-request":
|
|
4296
|
+
data = {
|
|
4297
|
+
...data,
|
|
4298
|
+
messageSeqs: list(data["messageSeqs"])
|
|
4299
|
+
};
|
|
4300
|
+
break;
|
|
4301
|
+
}
|
|
4302
|
+
return {
|
|
4303
|
+
...event,
|
|
4304
|
+
seq,
|
|
4305
|
+
data,
|
|
4306
|
+
...event["sourceEventSeqs"] === void 0 ? {} : { sourceEventSeqs: list(event["sourceEventSeqs"]) },
|
|
4307
|
+
...event["surfaceOp"] === void 0 || event["surfaceOp"] === "append" ? {} : { surfaceOp: range(event["surfaceOp"]) }
|
|
4308
|
+
};
|
|
4309
|
+
}
|
|
4310
|
+
var sessionFormatV2ToV3 = defineSessionFormatMigration({
|
|
4311
|
+
name: "@deepseek-ai/dsh-session-format-v2-to-v3",
|
|
4312
|
+
fromVersion: 2,
|
|
4313
|
+
toVersion: 3,
|
|
4314
|
+
migrateHeader(header) {
|
|
4315
|
+
assertReleasedV2Header(header);
|
|
4316
|
+
return {
|
|
4317
|
+
...header,
|
|
4318
|
+
version: 3,
|
|
4319
|
+
...header.agentPreset === "code" ? { agentPreset: "ptc" } : {}
|
|
4320
|
+
};
|
|
4321
|
+
},
|
|
4322
|
+
createStage(input) {
|
|
4323
|
+
return new ReleasedV2ToV3Stage(input);
|
|
4324
|
+
},
|
|
4325
|
+
validateTargetHeader: assertReleasedV3Header
|
|
4326
|
+
});
|
|
4327
|
+
var ReleasedV2ToV3Stage = class {
|
|
4328
|
+
input;
|
|
4329
|
+
headerInheritedEventCount;
|
|
4330
|
+
mapping = [];
|
|
4331
|
+
originalIds = /* @__PURE__ */ new Set();
|
|
4332
|
+
generatedIds = /* @__PURE__ */ new Set();
|
|
4333
|
+
targetSeq = 0;
|
|
4334
|
+
sourceCut;
|
|
4335
|
+
targetCut;
|
|
4336
|
+
lastForeignDeliverySeq;
|
|
4337
|
+
step;
|
|
4338
|
+
head;
|
|
4339
|
+
prompt = "";
|
|
4340
|
+
constructor(input) {
|
|
4341
|
+
this.input = input;
|
|
4342
|
+
assertReleasedV2Header(input.sourceHeader);
|
|
4343
|
+
this.sourceCut = input.sourceHeader.isSeeded ? void 0 : 0;
|
|
4344
|
+
this.targetCut = input.sourceHeader.isSeeded ? void 0 : 0;
|
|
4345
|
+
if (!input.sourceHeader.isSeeded) this.headerInheritedEventCount = 0;
|
|
4346
|
+
}
|
|
4347
|
+
transformEvent(event, context) {
|
|
4348
|
+
if (event.seq !== this.mapping.length) throw new SessionFormatError("format v2 source events must be dense");
|
|
4349
|
+
assertEvent(event, 2);
|
|
4350
|
+
this.observeMessageIds(event);
|
|
4351
|
+
let source = event;
|
|
4352
|
+
const data = record2(event.data, event.type);
|
|
4353
|
+
if (event.type === "request/header") {
|
|
4354
|
+
const { system, ...header } = record2(data["header"], "request header");
|
|
4355
|
+
const prompt = typeof system === "string" ? system : "";
|
|
4356
|
+
if (prompt !== this.prompt) this.emitSystem(prompt, event, context);
|
|
4357
|
+
source = {
|
|
4358
|
+
...event,
|
|
4359
|
+
data: {
|
|
4360
|
+
...data,
|
|
4361
|
+
header
|
|
4362
|
+
}
|
|
4363
|
+
};
|
|
4364
|
+
}
|
|
4365
|
+
if (SURFACE_TYPES.has(event.type) && this.head === void 0) throw new SessionFormatUnsupportedMigrationError("format v2 surface before first step cannot acquire a system head without changing chronology");
|
|
4366
|
+
if (event.type === "session/end-seed" && data["inherited"] === true) {
|
|
4367
|
+
if (!this.input.sourceHeader.isSeeded) throw new SessionFormatError("format v2 unseeded Session contains an inherited end-seed marker");
|
|
4368
|
+
this.sourceCut = event.seq;
|
|
4369
|
+
this.targetCut = this.targetSeq;
|
|
4370
|
+
}
|
|
4371
|
+
if (event.type === "session-log-deepseek/delivery-accepted") {
|
|
4372
|
+
if (data["sessionFormatVersion"] === 3) throw new SessionFormatError("format v2 delivery marker claims target format v3");
|
|
4373
|
+
if (data["sessionFormatVersion"] === 2 && data["sessionId"] !== this.input.sourceHeader.id) this.lastForeignDeliverySeq = event.seq;
|
|
4374
|
+
}
|
|
4375
|
+
const target = remapEvent(source, this.targetSeq, this.mapping);
|
|
4376
|
+
this.mapping.push(this.targetSeq++);
|
|
4377
|
+
context.emitEvent(canonicalizeTransformedEvent(renamePtcEvent(target)));
|
|
4378
|
+
if (event.type === "step/start") {
|
|
4379
|
+
this.step = {
|
|
4380
|
+
turn: data["turn"],
|
|
4381
|
+
step: data["step"]
|
|
4382
|
+
};
|
|
4383
|
+
if (this.head === void 0) this.emitSystem("", event, context);
|
|
4384
|
+
} else if (event.type === "step/end" || event.type === "turn/end") this.step = void 0;
|
|
4385
|
+
}
|
|
4386
|
+
transformRun(run, context) {
|
|
4387
|
+
for (const event of run.expand()) this.transformEvent(event, context);
|
|
4388
|
+
}
|
|
4389
|
+
finish(_context) {
|
|
4390
|
+
const cut = sessionFormatCount(this.sourceCut, "format v2 inherited end-seed marker");
|
|
4391
|
+
if (this.input.sourceInheritedEventCount !== void 0 && this.input.sourceInheritedEventCount !== cut) throw new SessionFormatError("format v2 inherited end-seed marker disagrees with its source cut");
|
|
4392
|
+
if (this.lastForeignDeliverySeq !== void 0 && (this.input.sourceHeader.parentSession === void 0 || this.lastForeignDeliverySeq >= cut)) throw new SessionFormatError("current-generation delivery marker names the wrong Session");
|
|
4393
|
+
return sessionFormatCount(this.targetCut, "format v3 inherited event count");
|
|
4394
|
+
}
|
|
4395
|
+
observeMessageIds(event) {
|
|
4396
|
+
const data = record2(event.data, event.type);
|
|
4397
|
+
const messages = event.type === "user/message" ? [data] : event.type === "assistant/message" || event.type === "tool/result" ? [record2(data["message"], "message")] : event.type === "agent/inbox/spliced" ? data["inserted"] : event.type === "session/title-llm-request" ? data["messages"] : [];
|
|
4398
|
+
for (const message of messages) {
|
|
4399
|
+
const id = message["id"];
|
|
4400
|
+
if (this.generatedIds.has(id)) throw new SessionFormatUnsupportedMigrationError("source message id collides with a generated system message id");
|
|
4401
|
+
this.originalIds.add(id);
|
|
4402
|
+
}
|
|
4403
|
+
}
|
|
4404
|
+
emitSystem(prompt, anchor, context) {
|
|
4405
|
+
if (this.step === void 0) throw new SessionFormatUnsupportedMigrationError("format v2 changed request prompt outside an open step cannot retain source chronology");
|
|
4406
|
+
const identity = JSON.stringify([
|
|
4407
|
+
"session-format-v2-to-v3",
|
|
4408
|
+
this.input.sourceHeader.id,
|
|
4409
|
+
anchor.seq,
|
|
4410
|
+
anchor.type
|
|
4411
|
+
]);
|
|
4412
|
+
const id = "v2-to-v3-system-" + createHash("sha256").update(identity).digest("hex");
|
|
4413
|
+
if (this.originalIds.has(id) || this.generatedIds.has(id)) throw new SessionFormatUnsupportedMigrationError("generated system message id collides with an existing message id");
|
|
4414
|
+
this.generatedIds.add(id);
|
|
4415
|
+
const seq = this.targetSeq++;
|
|
4416
|
+
context.emitEvent(canonicalizeTransformedEvent({
|
|
4417
|
+
type: "system/message",
|
|
4418
|
+
seq,
|
|
4419
|
+
time: anchor.time,
|
|
4420
|
+
data: {
|
|
4421
|
+
...this.step,
|
|
4422
|
+
message: {
|
|
4423
|
+
id,
|
|
4424
|
+
role: "system",
|
|
4425
|
+
source: {
|
|
4426
|
+
kind: "plugin",
|
|
4427
|
+
plugin: "@deepseek-ai/dsh-system-prompt"
|
|
4428
|
+
},
|
|
4429
|
+
content: prompt === "" ? [] : [{
|
|
4430
|
+
type: "text",
|
|
4431
|
+
text: prompt
|
|
4432
|
+
}]
|
|
4433
|
+
}
|
|
4434
|
+
},
|
|
4435
|
+
...this.head === void 0 ? { surfaceOp: "append" } : {
|
|
4436
|
+
surfaceOp: {
|
|
4437
|
+
op: "replace",
|
|
4438
|
+
start: this.head,
|
|
4439
|
+
end: this.head
|
|
4440
|
+
},
|
|
4441
|
+
sourceEventSeqs: [this.head]
|
|
4442
|
+
}
|
|
4443
|
+
}));
|
|
4444
|
+
this.head = seq;
|
|
4445
|
+
this.prompt = prompt;
|
|
4446
|
+
}
|
|
4447
|
+
};
|
|
4448
|
+
function renamePtcEvent(event) {
|
|
4449
|
+
switch (event.type) {
|
|
4450
|
+
case "agent-preset/selected":
|
|
4451
|
+
return event.data["agentPreset"] === "code" ? {
|
|
4452
|
+
...event,
|
|
4453
|
+
data: {
|
|
4454
|
+
...event.data,
|
|
4455
|
+
agentPreset: "ptc"
|
|
4456
|
+
}
|
|
4457
|
+
} : event;
|
|
4458
|
+
case "tool/code-dispatch-start":
|
|
4459
|
+
return {
|
|
4460
|
+
...event,
|
|
4461
|
+
type: "tool/ptc-dispatch-start"
|
|
4462
|
+
};
|
|
4463
|
+
case "tool/code-dispatch":
|
|
4464
|
+
return {
|
|
4465
|
+
...event,
|
|
4466
|
+
type: "tool/ptc-dispatch"
|
|
4467
|
+
};
|
|
4468
|
+
case "user/message": {
|
|
4469
|
+
const data = renameMessageSource(event.data);
|
|
4470
|
+
return data === event.data ? event : {
|
|
4471
|
+
...event,
|
|
4472
|
+
data
|
|
4473
|
+
};
|
|
4474
|
+
}
|
|
4475
|
+
case "agent/inbox/spliced":
|
|
4476
|
+
case "session/title-llm-request": {
|
|
4477
|
+
const data = event.data;
|
|
4478
|
+
const key = event.type === "agent/inbox/spliced" ? "inserted" : "messages";
|
|
4479
|
+
const messages = data[key];
|
|
4480
|
+
const renamed = messages.map(renameMessageSource);
|
|
4481
|
+
return renamed.every((message, index) => message === messages[index]) ? event : {
|
|
4482
|
+
...event,
|
|
4483
|
+
data: {
|
|
4484
|
+
...data,
|
|
4485
|
+
[key]: renamed
|
|
4486
|
+
}
|
|
4487
|
+
};
|
|
4488
|
+
}
|
|
4489
|
+
default:
|
|
4490
|
+
return event;
|
|
4491
|
+
}
|
|
4492
|
+
}
|
|
4493
|
+
function renameMessageSource(message) {
|
|
4494
|
+
const source = message["source"];
|
|
4495
|
+
if (source["kind"] !== "plugin" || source["plugin"] !== "tools-code-mode") return message;
|
|
4496
|
+
return {
|
|
4497
|
+
...message,
|
|
4498
|
+
source: {
|
|
4499
|
+
...source,
|
|
4500
|
+
plugin: "tools-ptc"
|
|
4501
|
+
}
|
|
4502
|
+
};
|
|
4503
|
+
}
|
|
3801
4504
|
export {
|
|
3802
4505
|
releasedV0SessionFormatCodec,
|
|
3803
4506
|
releasedV1SessionFormatCodec,
|
|
3804
|
-
releasedV2SessionFormatCodec
|
|
4507
|
+
releasedV2SessionFormatCodec,
|
|
4508
|
+
releasedV3SessionFormatCodec
|
|
3805
4509
|
};
|
|
3806
4510
|
//# sourceMappingURL=legacy-session-codecs.js.map
|