@nomix-ai/nomix-harness 0.2.5 → 0.2.6
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/README.md +2 -9
- package/dist/assets/web/assets/index-BnapMmQ_.css +1 -0
- package/dist/assets/web/assets/index-Dx7Ws_OC.js +96 -0
- package/dist/assets/web/assets/langs/{php-D-uCvoST.js → php-DDkx9sim.js} +2 -2
- package/dist/{kernel/web-frontend/dist/assets/langs/ruby-DEItuUFs.js → assets/web/assets/langs/ruby-DCxyoPen.js} +2 -2
- package/dist/assets/web/assets/{vendor-Cjbwl5VI.js → vendor-D22_Mp1f.js} +2 -2
- package/dist/assets/web/favicon.svg +8 -0
- package/dist/assets/web/index.html +5 -5
- package/dist/bundles/base/cordis.patch.yml +31 -6
- package/dist/bundles/web-app/cordis.patch.yml +27 -6
- package/dist/cli/bin.js +4 -5
- package/dist/cli/builtin-registry.js +34 -4
- package/dist/cli/{dump-config-d3ECray2.js → dump-config-BEj2GlJo.js} +1 -1
- package/dist/cli/{plugin-Bw9wgrmj.js → plugin-D_gLgCYL.js} +1 -1
- package/dist/cli/profile-boot-BSrYtiQI.js +2 -0
- package/dist/cli/{profile-boot-DFHdh9Xq.js → profile-boot-CByqUxLM.js} +0 -2
- package/dist/cli/runtime.js +0 -2
- package/dist/config/agent-presets/code/agent.cordis.yml +4 -3
- package/dist/config/agent-presets/cordis/agent.cordis.yml +4 -3
- package/dist/config/agent-presets/cordis/skills/editing-cordis-compositions/SKILL.md +13 -2
- package/dist/config/agent-presets/minimal/agent.cordis.yml +27 -1
- package/dist/config/agent-presets/standard/agent.cordis.yml +4 -3
- package/dist/kernel/acp/package.json +1 -1
- package/dist/kernel/agent/package.json +1 -1
- package/dist/kernel/agent-default-model/package.json +1 -1
- package/dist/kernel/agent-instructions/package.json +1 -1
- package/dist/kernel/agent-loop/lib/index.js +33 -10
- package/dist/kernel/agent-loop/lib/types/agent.js +26 -6
- package/dist/kernel/agent-loop/package.json +1 -1
- package/dist/kernel/agent-presets/package.json +1 -1
- package/dist/kernel/agent-tool-presentation/package.json +1 -1
- package/dist/kernel/anonymous-user-id/package.json +1 -1
- package/dist/kernel/api-gateway/lib/client.js +84 -55
- package/dist/kernel/api-gateway/lib/types/client/index.js +93 -61
- package/dist/kernel/api-gateway/package.json +1 -1
- package/dist/kernel/api-remotes/lib/client.js +166 -27
- package/dist/kernel/api-remotes/lib/index.js +1 -1
- package/dist/kernel/api-remotes/lib/types/client/index.d.ts +4 -0
- package/dist/kernel/api-remotes/lib/types/client/index.js +4 -1
- package/dist/kernel/api-remotes/lib/types/remote-events.d.ts +1 -1
- package/dist/kernel/api-remotes/lib/types/remote-events.js +1 -1
- package/dist/kernel/api-remotes/package.json +11 -7
- package/dist/kernel/app-boot/lib/index.js +19 -41
- package/dist/kernel/app-boot/lib/types/index.d.ts +0 -1
- package/dist/kernel/app-boot/lib/types/index.js +2 -3
- package/dist/kernel/app-boot/lib/types/profile.d.ts +15 -12
- package/dist/kernel/app-boot/lib/types/profile.js +15 -25
- package/dist/kernel/app-boot/package.json +1 -1
- package/dist/kernel/atomic-write/lib/index.js +36 -16
- package/dist/kernel/atomic-write/lib/types/index.d.ts +21 -5
- package/dist/kernel/atomic-write/lib/types/index.js +40 -16
- package/dist/kernel/atomic-write/package.json +1 -1
- package/dist/kernel/attachment/lib/index.js +62 -3
- package/dist/kernel/attachment/lib/types/admission.d.ts +15 -0
- package/dist/kernel/attachment/lib/types/admission.js +33 -0
- package/dist/kernel/attachment/lib/types/brand.d.ts +8 -0
- package/dist/kernel/attachment/lib/types/brand.js +8 -0
- package/dist/kernel/attachment/lib/types/error.d.ts +2 -2
- package/dist/kernel/attachment/lib/types/error.js +1 -0
- package/dist/kernel/attachment/lib/types/index.d.ts +23 -5
- package/dist/kernel/attachment/lib/types/index.js +24 -2
- package/dist/kernel/attachment/lib/types/types.d.ts +47 -2
- package/dist/kernel/attachment/package.json +3 -2
- package/dist/kernel/attachment-local/lib/index.js +640 -48
- package/dist/kernel/attachment-local/lib/types/compression-limiter.d.ts +18 -0
- package/dist/kernel/attachment-local/lib/types/compression-limiter.js +43 -0
- package/dist/kernel/attachment-local/lib/types/encoding.d.ts +23 -0
- package/dist/kernel/attachment-local/lib/types/encoding.js +33 -0
- package/dist/kernel/attachment-local/lib/types/image.d.ts +31 -2
- package/dist/kernel/attachment-local/lib/types/image.js +43 -4
- package/dist/kernel/attachment-local/lib/types/index.d.ts +45 -10
- package/dist/kernel/attachment-local/lib/types/index.js +140 -10
- package/dist/kernel/attachment-local/lib/types/normalization.d.ts +44 -0
- package/dist/kernel/attachment-local/lib/types/normalization.js +148 -0
- package/dist/kernel/attachment-local/lib/types/request-image.d.ts +35 -0
- package/dist/kernel/attachment-local/lib/types/request-image.js +208 -0
- package/dist/kernel/attachment-local/lib/types/store.d.ts +36 -9
- package/dist/kernel/attachment-local/lib/types/store.js +60 -24
- package/dist/kernel/attachment-local/package.json +1 -1
- package/dist/kernel/authorization/lib/index.js +248 -0
- package/dist/kernel/authorization/lib/invariant.js +36 -0
- package/dist/kernel/authorization/lib/types/index.d.ts +223 -0
- package/dist/kernel/authorization/lib/types/index.js +299 -0
- package/dist/kernel/authorization/lib/types/invariant.d.ts +16 -0
- package/dist/kernel/authorization/lib/types/invariant.js +38 -0
- package/dist/kernel/authorization/lib/types/types.d.ts +83 -0
- package/dist/kernel/authorization/lib/types/types.js +8 -0
- package/dist/kernel/{client-web-react → authorization}/package.json +19 -16
- package/dist/kernel/base/cordis.patch.yml +31 -6
- package/dist/kernel/base/package.json +3 -1
- package/dist/kernel/bash-local/package.json +1 -1
- package/dist/kernel/bash-sandbox/package.json +1 -1
- package/dist/kernel/brand/package.json +1 -1
- package/dist/kernel/client-connection/lib/client.js +148 -28
- package/dist/kernel/client-connection/lib/index.js +4 -4
- package/dist/kernel/client-connection/lib/types/client/fixture.js +112 -20
- package/dist/kernel/client-connection/lib/types/client/index.d.ts +21 -1
- package/dist/kernel/client-connection/lib/types/client/index.js +3 -2
- package/dist/kernel/client-connection/lib/types/client/rpc.d.ts +4 -1
- package/dist/kernel/client-connection/lib/types/client/rpc.js +4 -2
- package/dist/kernel/client-connection/lib/types/http-bridge.d.ts +2 -2
- package/dist/kernel/client-connection/lib/types/http-bridge.js +3 -3
- package/dist/kernel/client-connection/lib/types/index.d.ts +1 -1
- package/dist/kernel/client-connection/package.json +15 -9
- package/dist/kernel/client-hmr/package.json +1 -1
- package/dist/kernel/client-locale/lib/client.js +48 -9
- package/dist/kernel/client-locale/lib/types/client/index.d.ts +19 -3
- package/dist/kernel/client-locale/lib/types/client/index.js +48 -7
- package/dist/kernel/client-locale/package.json +6 -6
- package/dist/kernel/client-modules/lib/client.js +188 -123
- package/dist/kernel/client-modules/lib/index.js +177 -31
- package/dist/kernel/client-modules/lib/types/client/index.d.ts +19 -8
- package/dist/kernel/client-modules/lib/types/client/index.js +25 -8
- package/dist/kernel/client-modules/lib/types/client/manifest.d.ts +90 -41
- package/dist/kernel/client-modules/lib/types/client/manifest.js +45 -12
- package/dist/kernel/client-modules/lib/types/client/system.d.ts +15 -17
- package/dist/kernel/client-modules/lib/types/client/system.js +85 -56
- package/dist/kernel/client-modules/lib/types/index.d.ts +28 -12
- package/dist/kernel/client-modules/lib/types/index.js +128 -34
- package/dist/kernel/client-modules/package.json +4 -2
- package/dist/kernel/client-runtime/lib/client.js +43 -8
- package/dist/kernel/client-runtime/lib/types/client/contract/session.d.ts +1 -1
- package/dist/kernel/client-runtime/lib/types/client/contract/store.d.ts +1 -1
- package/dist/kernel/client-runtime/lib/types/client/contract/store.js +2 -2
- package/dist/kernel/client-runtime/lib/types/client/index.d.ts +2 -2
- package/dist/kernel/client-runtime/lib/types/client/index.js +3 -3
- package/dist/kernel/client-runtime/lib/types/client/sessions/context-provenance.d.ts +8 -0
- package/dist/kernel/client-runtime/lib/types/client/sessions/context-provenance.js +13 -0
- package/dist/kernel/client-runtime/lib/types/client/sessions/conversation.d.ts +11 -7
- package/dist/kernel/client-runtime/lib/types/client/sessions/projection-store.d.ts +1 -1
- package/dist/kernel/client-runtime/lib/types/client/sessions/session.d.ts +1 -1
- package/dist/kernel/client-runtime/lib/types/client/sessions/session.js +4 -4
- package/dist/kernel/client-runtime/lib/types/client/slots.d.ts +1 -1
- package/dist/kernel/client-runtime/lib/types/client/slots.js +1 -1
- package/dist/kernel/client-runtime/lib/types/client/workspaces/path.d.ts +9 -0
- package/dist/kernel/client-runtime/lib/types/client/workspaces/path.js +27 -1
- package/dist/kernel/client-runtime/package.json +25 -14
- package/dist/kernel/client-ui-agent-preset/lib/client.js +55 -55
- package/dist/kernel/client-ui-agent-preset/lib/types/client/index.js +2 -2
- package/dist/kernel/client-ui-agent-preset/lib/types/client/settings-store.d.ts +7 -1
- package/dist/kernel/client-ui-agent-preset/lib/types/client/settings-store.js +21 -20
- package/dist/kernel/client-ui-agent-preset/package.json +2 -7
- package/dist/kernel/client-ui-attachment/lib/client.js +782 -0
- package/dist/kernel/client-ui-attachment/lib/index.js +5 -505
- package/dist/kernel/client-ui-attachment/lib/invariant.js +2 -3
- package/dist/kernel/client-ui-attachment/lib/types/client/ComposerAttachments.d.ts +4 -0
- package/dist/kernel/client-ui-attachment/lib/types/client/ComposerAttachments.js +85 -0
- package/dist/kernel/client-ui-attachment/lib/types/client/MessageImages.d.ts +4 -0
- package/dist/kernel/client-ui-attachment/lib/types/client/MessageImages.js +8 -0
- package/dist/kernel/client-ui-attachment/lib/types/client/index.d.ts +7 -0
- package/dist/kernel/client-ui-attachment/lib/types/client/index.js +16 -0
- package/dist/kernel/client-ui-attachment/lib/types/client/labels.d.ts +35 -0
- package/dist/kernel/client-ui-attachment/lib/types/client/labels.js +52 -0
- package/dist/kernel/client-ui-attachment/lib/types/index.d.ts +3 -15
- package/dist/kernel/client-ui-attachment/lib/types/index.js +3 -11
- package/dist/kernel/client-ui-attachment/lib/types/invariant.js +2 -3
- package/dist/kernel/client-ui-attachment/package.json +32 -9
- package/dist/kernel/client-ui-brand-official/lib/client.js +50 -0
- package/dist/kernel/client-ui-brand-official/lib/index.js +9 -0
- package/dist/kernel/{client-web-react → client-ui-brand-official}/lib/invariant.js +6 -8
- package/dist/kernel/client-ui-brand-official/lib/types/client/Brand.d.ts +16 -0
- package/dist/kernel/client-ui-brand-official/lib/types/client/Brand.js +18 -0
- package/dist/kernel/client-ui-brand-official/lib/types/client/index.d.ts +10 -0
- package/dist/kernel/client-ui-brand-official/lib/types/client/index.js +17 -0
- package/dist/kernel/client-ui-brand-official/lib/types/index.d.ts +7 -0
- package/dist/kernel/client-ui-brand-official/lib/types/index.js +7 -0
- package/dist/kernel/client-ui-brand-official/lib/types/invariant.d.ts +16 -0
- package/dist/kernel/{client-web-react → client-ui-brand-official}/lib/types/invariant.js +6 -8
- package/dist/kernel/client-ui-brand-official/package.json +72 -0
- package/dist/kernel/client-ui-commands/lib/client.js +44 -15
- package/dist/kernel/client-ui-commands/lib/types/client/locales.d.ts +2 -0
- package/dist/kernel/client-ui-commands/lib/types/client/locales.js +2 -0
- package/dist/kernel/client-ui-commands/lib/types/client/service.d.ts +11 -1
- package/dist/kernel/client-ui-commands/lib/types/client/service.js +39 -7
- package/dist/kernel/client-ui-commands/package.json +2 -5
- package/dist/kernel/client-ui-conversation/lib/client.js +949 -531
- package/dist/kernel/client-ui-conversation/lib/types/client/apply.js +6 -4
- package/dist/kernel/client-ui-conversation/lib/types/client/chat/AssistantMarkdown.d.ts +4 -5
- package/dist/kernel/client-ui-conversation/lib/types/client/chat/AssistantMarkdown.js +6 -6
- package/dist/kernel/client-ui-conversation/lib/types/client/chat/AssistantNodeView.d.ts +1 -1
- package/dist/kernel/client-ui-conversation/lib/types/client/chat/AssistantNodeView.js +2 -2
- package/dist/kernel/client-ui-conversation/lib/types/client/chat/ChatNodeSeat.d.ts +1 -1
- package/dist/kernel/client-ui-conversation/lib/types/client/chat/ChatNodeSeat.js +5 -3
- package/dist/kernel/client-ui-conversation/lib/types/client/chat/ChatView.js +53 -10
- package/dist/kernel/client-ui-conversation/lib/types/client/chat/ContextInjectionRow.js +4 -1
- package/dist/kernel/client-ui-conversation/lib/types/client/chat/MessageItem.d.ts +4 -5
- package/dist/kernel/client-ui-conversation/lib/types/client/chat/MessageItem.js +46 -16
- package/dist/kernel/client-ui-conversation/lib/types/client/chat/StatsLine.d.ts +5 -3
- package/dist/kernel/client-ui-conversation/lib/types/client/chat/StatsLine.js +54 -5
- package/dist/kernel/client-ui-conversation/lib/types/client/contract/slots.d.ts +90 -8
- package/dist/kernel/client-ui-conversation/lib/types/client/conversation-nodes/assistant.js +1 -0
- package/dist/kernel/client-ui-conversation/lib/types/client/conversation-nodes/chat-snapshot-builder.d.ts +1 -0
- package/dist/kernel/client-ui-conversation/lib/types/client/conversation-nodes/chat-snapshot-builder.js +95 -6
- package/dist/kernel/client-ui-conversation/lib/types/client/conversation-nodes/message.d.ts +11 -3
- package/dist/kernel/client-ui-conversation/lib/types/client/conversation-nodes/turn-error.d.ts +6 -3
- package/dist/kernel/client-ui-conversation/lib/types/client/conversation-nodes/turn-error.js +10 -26
- package/dist/kernel/client-ui-conversation/lib/types/client/image-labels.d.ts +1 -33
- package/dist/kernel/client-ui-conversation/lib/types/client/image-labels.js +5 -54
- package/dist/kernel/client-ui-conversation/lib/types/client/index.d.ts +1 -1
- package/dist/kernel/client-ui-conversation/lib/types/client/input/contract.d.ts +17 -14
- package/dist/kernel/client-ui-conversation/lib/types/client/input/decorations.d.ts +13 -5
- package/dist/kernel/client-ui-conversation/lib/types/client/input/decorations.js +26 -10
- package/dist/kernel/client-ui-conversation/lib/types/client/input/facade.d.ts +34 -14
- package/dist/kernel/client-ui-conversation/lib/types/client/input/facade.js +116 -34
- package/dist/kernel/client-ui-conversation/lib/types/client/input/hub.d.ts +1 -1
- package/dist/kernel/client-ui-conversation/lib/types/client/input/hub.js +21 -19
- package/dist/kernel/client-ui-conversation/lib/types/client/input/machine.d.ts +35 -14
- package/dist/kernel/client-ui-conversation/lib/types/client/input/machine.js +71 -34
- package/dist/kernel/client-ui-conversation/lib/types/client/locales.d.ts +16 -0
- package/dist/kernel/client-ui-conversation/lib/types/client/locales.js +16 -0
- package/dist/kernel/client-ui-conversation/lib/types/client/reference/ReferenceIcon.d.ts +16 -0
- package/dist/kernel/client-ui-conversation/lib/types/client/reference/ReferenceIcon.js +16 -0
- package/dist/kernel/client-ui-conversation/lib/types/client/service.d.ts +14 -1
- package/dist/kernel/client-ui-conversation/lib/types/client/service.js +26 -6
- package/dist/kernel/client-ui-conversation/lib/types/client/skeleton/ConversationRoot.js +1 -1
- package/dist/kernel/client-ui-conversation/lib/types/client/skeleton/ConversationSession.js +18 -3
- package/dist/kernel/client-ui-conversation/lib/types/client/skeleton/EmptyHero.d.ts +3 -1
- package/dist/kernel/client-ui-conversation/lib/types/client/skeleton/EmptyHero.js +4 -2
- package/dist/kernel/client-ui-conversation/lib/types/client/skeleton/InputBar.js +141 -126
- package/dist/kernel/client-ui-conversation/package.json +9 -8
- package/dist/kernel/client-ui-cordis/lib/client.js +48 -48
- package/dist/kernel/client-ui-cordis/package.json +2 -5
- package/dist/kernel/client-ui-deliverables/lib/client.js +5 -5
- package/dist/kernel/client-ui-deliverables/package.json +4 -6
- package/dist/kernel/client-ui-directory-picker-browse/lib/client.js +26 -26
- package/dist/kernel/client-ui-directory-picker-browse/package.json +2 -5
- package/dist/kernel/client-ui-directory-picker-native/package.json +2 -5
- package/dist/kernel/client-ui-goal/lib/client.js +8 -8
- package/dist/kernel/client-ui-goal/package.json +6 -5
- package/dist/kernel/client-ui-input-trigger/lib/client.js +82 -26
- package/dist/kernel/client-ui-input-trigger/lib/types/client/MenuView.js +13 -9
- package/dist/kernel/client-ui-input-trigger/lib/types/client/controller.d.ts +5 -3
- package/dist/kernel/client-ui-input-trigger/lib/types/client/controller.js +19 -7
- package/dist/kernel/client-ui-input-trigger/lib/types/client/index.d.ts +1 -1
- package/dist/kernel/client-ui-input-trigger/lib/types/core/contract.d.ts +7 -2
- package/dist/kernel/client-ui-input-trigger/lib/types/core/detect.d.ts +4 -4
- package/dist/kernel/client-ui-input-trigger/lib/types/core/detect.js +24 -6
- package/dist/kernel/client-ui-input-trigger/lib/types/core/menu.d.ts +15 -2
- package/dist/kernel/client-ui-input-trigger/lib/types/core/menu.js +13 -4
- package/dist/kernel/client-ui-input-trigger/lib/types/types.d.ts +52 -8
- package/dist/kernel/client-ui-input-trigger/package.json +4 -5
- package/dist/kernel/client-ui-jobs/lib/client.js +10 -10
- package/dist/kernel/client-ui-jobs/package.json +3 -7
- package/dist/kernel/client-ui-layout/lib/client.js +3 -3
- package/dist/kernel/client-ui-layout/package.json +2 -4
- package/dist/kernel/client-ui-message-feedback/lib/client.js +174 -58
- package/dist/kernel/client-ui-message-feedback/lib/types/client/MessageFeedbackActions.d.ts +9 -3
- package/dist/kernel/client-ui-message-feedback/lib/types/client/MessageFeedbackActions.js +164 -25
- package/dist/kernel/client-ui-message-feedback/lib/types/client/locales.d.ts +2 -0
- package/dist/kernel/client-ui-message-feedback/lib/types/client/locales.js +2 -0
- package/dist/kernel/client-ui-message-feedback/package.json +3 -5
- package/dist/kernel/client-ui-model-selection/lib/client.js +18 -18
- package/dist/kernel/client-ui-model-selection/package.json +7 -9
- package/dist/kernel/client-ui-permission-presets/lib/client.js +97 -83
- package/dist/kernel/client-ui-permission-presets/lib/types/client/index.js +6 -19
- package/dist/kernel/client-ui-permission-presets/lib/types/client/settings-store.d.ts +27 -18
- package/dist/kernel/client-ui-permission-presets/lib/types/client/settings-store.js +95 -68
- package/dist/kernel/client-ui-permission-presets/package.json +2 -8
- package/dist/kernel/client-ui-plan/lib/client.js +1 -1
- package/dist/kernel/client-ui-plan/lib/types/client/index.js +1 -1
- package/dist/kernel/client-ui-plan/package.json +2 -6
- package/dist/kernel/client-ui-primitives/lib/Button.module.css +79 -0
- package/dist/kernel/client-ui-primitives/lib/ConnectionBanner.module.css +13 -0
- package/dist/kernel/client-ui-primitives/lib/DiffBlock.module.css +107 -0
- package/dist/kernel/client-ui-primitives/lib/DisclosureRow.module.css +69 -0
- package/dist/kernel/client-ui-primitives/lib/HoverCard.module.css +54 -0
- package/dist/kernel/client-ui-primitives/lib/Input.module.css +38 -0
- package/dist/kernel/client-ui-primitives/lib/JsonTree.module.css +222 -0
- package/dist/kernel/client-ui-primitives/lib/Menu.module.css +242 -0
- package/dist/kernel/client-ui-primitives/lib/Modal.module.css +103 -0
- package/dist/kernel/client-ui-primitives/lib/OnboardingSurface.module.css +29 -0
- package/dist/kernel/client-ui-primitives/lib/Pill.module.css +27 -0
- package/dist/kernel/client-ui-primitives/lib/ReadBlock.module.css +117 -0
- package/dist/kernel/client-ui-primitives/lib/RiskConfirmation.module.css +73 -0
- package/dist/kernel/client-ui-primitives/lib/SearchBlock.module.css +120 -0
- package/dist/kernel/client-ui-primitives/lib/StateDot.module.css +65 -0
- package/dist/kernel/client-ui-primitives/lib/TerminalBlock.module.css +211 -0
- package/dist/kernel/client-ui-primitives/lib/Toast.module.css +70 -0
- package/dist/kernel/client-ui-primitives/lib/Tooltip.module.css +49 -0
- package/dist/kernel/client-ui-primitives/lib/WebBlock.module.css +130 -0
- package/dist/kernel/client-ui-primitives/lib/index.js +291 -261
- package/dist/kernel/client-ui-primitives/lib/invariant.js +2 -0
- package/dist/kernel/client-ui-primitives/lib/markdown/CodeBlock.module.css +96 -0
- package/dist/kernel/client-ui-primitives/lib/markdown/JsonBlock.module.css +32 -0
- package/dist/kernel/client-ui-primitives/lib/markdown/MarkdownText.module.css +304 -0
- package/dist/kernel/client-ui-primitives/lib/markdown/MessageText.module.css +9 -0
- package/dist/kernel/client-ui-primitives/lib/types/BrandWordmark.d.ts +7 -1
- package/dist/kernel/client-ui-primitives/lib/types/BrandWordmark.js +4 -2
- package/dist/kernel/client-ui-primitives/lib/types/index.d.ts +4 -1
- package/dist/kernel/client-ui-primitives/lib/types/index.js +2 -1
- package/dist/kernel/client-ui-primitives/lib/types/markdown/render.d.ts +2 -0
- package/dist/kernel/client-ui-primitives/lib/types/markdown/render.js +10 -2
- package/dist/kernel/client-ui-primitives/lib/types/useAnchoredPosition.d.ts +32 -0
- package/dist/kernel/client-ui-primitives/lib/types/useAnchoredPosition.js +69 -0
- package/dist/kernel/client-ui-primitives/package.json +2 -1
- package/dist/kernel/client-ui-reference/lib/client.js +149 -0
- package/dist/kernel/client-ui-reference/lib/index.js +11 -0
- package/dist/kernel/{client-schema-form → client-ui-reference}/lib/invariant.js +7 -8
- package/dist/kernel/client-ui-reference/lib/types/client/index.d.ts +9 -0
- package/dist/kernel/client-ui-reference/lib/types/client/index.js +106 -0
- package/dist/kernel/client-ui-reference/lib/types/client/locales.d.ts +30 -0
- package/dist/kernel/client-ui-reference/lib/types/client/locales.js +22 -0
- package/dist/kernel/client-ui-reference/lib/types/index.d.ts +9 -0
- package/dist/kernel/client-ui-reference/lib/types/index.js +9 -0
- package/dist/kernel/{client-schema-form → client-ui-reference}/lib/types/invariant.d.ts +3 -3
- package/dist/kernel/{client-schema-form → client-ui-reference}/lib/types/invariant.js +7 -8
- package/dist/kernel/client-ui-reference/package.json +77 -0
- package/dist/kernel/client-ui-renderer/lib/client.js +989 -0
- package/dist/kernel/client-ui-renderer/lib/index.js +6 -0
- package/dist/kernel/client-ui-renderer/lib/invariant.js +23 -0
- package/dist/kernel/{client-web/lib/types → client-ui-renderer/lib/types/client}/DocumentTitle.d.ts +4 -4
- package/dist/kernel/client-ui-renderer/lib/types/client/DocumentTitle.js +17 -0
- package/dist/kernel/client-ui-renderer/lib/types/client/app.d.ts +18 -0
- package/dist/kernel/{client-web/lib/types → client-ui-renderer/lib/types/client}/app.js +5 -5
- package/dist/kernel/{client-web-react/lib/types → client-ui-renderer/lib/types/client}/bind.d.ts +1 -1
- package/dist/kernel/client-ui-renderer/lib/types/client/index.d.ts +29 -0
- package/dist/kernel/client-ui-renderer/lib/types/client/index.js +51 -0
- package/dist/kernel/{client-web-react/lib/types → client-ui-renderer/lib/types/client}/scoped-slots.d.ts +1 -1
- package/dist/kernel/{client-web-react/lib/types → client-ui-renderer/lib/types/client}/scoped-slots.js +1 -1
- package/dist/kernel/{client-web-react/lib/types → client-ui-renderer/lib/types/client}/session-provider.d.ts +1 -1
- package/dist/kernel/client-ui-renderer/lib/types/index.d.ts +4 -0
- package/dist/kernel/client-ui-renderer/lib/types/index.js +4 -0
- package/dist/kernel/{client-web-react → client-ui-renderer}/lib/types/invariant.d.ts +3 -3
- package/dist/kernel/client-ui-renderer/lib/types/invariant.js +22 -0
- package/dist/kernel/client-ui-renderer/package.json +71 -0
- package/dist/kernel/client-ui-settings/lib/client.js +1177 -67
- package/dist/kernel/client-ui-settings/lib/types/client/index.d.ts +20 -12
- package/dist/kernel/client-ui-settings/lib/types/client/index.js +25 -6
- package/dist/kernel/client-ui-settings/lib/types/client/schema.d.ts +72 -0
- package/dist/kernel/client-ui-settings/lib/types/client/schema.js +152 -0
- package/dist/kernel/client-ui-settings/lib/types/client/settings-mirror.d.ts +118 -0
- package/dist/kernel/client-ui-settings/lib/types/client/settings-mirror.js +160 -0
- package/dist/kernel/client-ui-settings/lib/types/client/settings-scope.d.ts +51 -24
- package/dist/kernel/client-ui-settings/lib/types/client/settings-scope.js +88 -71
- package/dist/kernel/client-ui-settings/package.json +7 -7
- package/dist/kernel/client-ui-settings-general/lib/client.js +60 -64
- package/dist/kernel/client-ui-settings-general/lib/types/client/SettingsDocumentAction.d.ts +7 -6
- package/dist/kernel/client-ui-settings-general/lib/types/client/index.js +10 -11
- package/dist/kernel/client-ui-settings-general/lib/types/client/settings-document-store.d.ts +13 -11
- package/dist/kernel/client-ui-settings-general/lib/types/client/settings-document-store.js +37 -40
- package/dist/kernel/client-ui-settings-general/package.json +4 -8
- package/dist/kernel/client-ui-settings-models/lib/client.js +280 -210
- package/dist/kernel/client-ui-settings-models/lib/types/client/DeepSeekOnboardingDialog.d.ts +3 -0
- package/dist/kernel/client-ui-settings-models/lib/types/client/DeepSeekOnboardingDialog.js +2 -2
- package/dist/kernel/client-ui-settings-models/lib/types/client/ModelListEditor.js +11 -1
- package/dist/kernel/client-ui-settings-models/lib/types/client/ModelsSection.d.ts +10 -5
- package/dist/kernel/client-ui-settings-models/lib/types/client/ModelsSection.js +9 -6
- package/dist/kernel/client-ui-settings-models/lib/types/client/ProviderEditor.d.ts +3 -0
- package/dist/kernel/client-ui-settings-models/lib/types/client/ProviderEditor.js +30 -29
- package/dist/kernel/client-ui-settings-models/lib/types/client/index.js +27 -22
- package/dist/kernel/client-ui-settings-models/lib/types/client/locales.d.ts +2 -0
- package/dist/kernel/client-ui-settings-models/lib/types/client/locales.js +4 -0
- package/dist/kernel/client-ui-settings-models/lib/types/client/schema-operations.d.ts +10 -0
- package/dist/kernel/client-ui-settings-models/lib/types/client/schema-operations.js +17 -0
- package/dist/kernel/client-ui-settings-models/lib/types/client/store.d.ts +15 -7
- package/dist/kernel/client-ui-settings-models/lib/types/client/store.js +30 -21
- package/dist/kernel/client-ui-settings-models/lib/types/client/welcome-store.d.ts +35 -18
- package/dist/kernel/client-ui-settings-models/lib/types/client/welcome-store.js +89 -82
- package/dist/kernel/client-ui-settings-models/package.json +3 -8
- package/dist/kernel/client-ui-settings-plugin-inventory/lib/client.js +11 -11
- package/dist/kernel/client-ui-settings-plugin-inventory/package.json +2 -5
- package/dist/kernel/client-ui-settings-plugins/lib/client.js +42 -65
- package/dist/kernel/client-ui-settings-plugins/lib/types/client/index.js +5 -8
- package/dist/kernel/client-ui-settings-plugins/lib/types/client/tab-store.d.ts +8 -17
- package/dist/kernel/client-ui-settings-plugins/lib/types/client/tab-store.js +22 -44
- package/dist/kernel/client-ui-settings-plugins/package.json +2 -7
- package/dist/kernel/client-ui-sidebar/lib/client.js +50 -20
- package/dist/kernel/client-ui-sidebar/lib/types/client/SidebarRoot.js +7 -3
- package/dist/kernel/client-ui-sidebar/lib/types/client/contract/slots.d.ts +30 -1
- package/dist/kernel/client-ui-sidebar/lib/types/client/index.d.ts +1 -1
- package/dist/kernel/client-ui-sidebar/lib/types/client/index.js +2 -0
- package/dist/kernel/client-ui-sidebar/package.json +2 -4
- package/dist/kernel/client-ui-skill/lib/client.js +12 -12
- package/dist/kernel/client-ui-skill/package.json +2 -5
- package/dist/kernel/client-ui-slots/lib/index.js +2 -0
- package/dist/kernel/client-ui-slots/lib/invariant.js +2 -0
- package/dist/kernel/client-ui-slots/lib/types/renderer.d.ts +1 -1
- package/dist/kernel/client-ui-slots/lib/types/store.d.ts +1 -1
- package/dist/kernel/client-ui-slots/package.json +1 -1
- package/dist/kernel/client-ui-subagent/lib/client.js +289 -157
- package/dist/kernel/client-ui-subagent/lib/types/client/SubagentHeaderLineage.d.ts +18 -0
- package/dist/kernel/client-ui-subagent/lib/types/client/{SubagentCatalogAction.js → SubagentHeaderLineage.js} +153 -25
- package/dist/kernel/client-ui-subagent/lib/types/client/index.d.ts +4 -16
- package/dist/kernel/client-ui-subagent/lib/types/client/index.js +7 -45
- package/dist/kernel/client-ui-subagent/lib/types/client/locales.d.ts +1 -0
- package/dist/kernel/client-ui-subagent/lib/types/client/locales.js +2 -0
- package/dist/kernel/client-ui-subagent/package.json +6 -8
- package/dist/kernel/client-ui-theme/lib/client.js +46 -3
- package/dist/kernel/client-ui-theme/lib/index.js +22 -23
- package/dist/kernel/client-ui-theme/lib/types/boot-theme.d.ts +9 -10
- package/dist/kernel/client-ui-theme/lib/types/boot-theme.js +12 -19
- package/dist/kernel/client-ui-theme/lib/types/client/index.d.ts +1 -1
- package/dist/kernel/client-ui-theme/lib/types/client/index.js +3 -1
- package/dist/kernel/client-ui-theme/lib/types/client/styles.d.ts +7 -0
- package/dist/kernel/client-ui-theme/lib/types/client/styles.js +32 -0
- package/dist/kernel/client-ui-theme/lib/types/index.d.ts +4 -3
- package/dist/kernel/client-ui-theme/lib/types/index.js +7 -6
- package/dist/kernel/client-ui-theme/package.json +4 -6
- package/dist/kernel/client-ui-tool/lib/client.js +105 -65
- package/dist/kernel/client-ui-tool/lib/types/client/apply.d.ts +1 -2
- package/dist/kernel/client-ui-tool/lib/types/client/apply.js +6 -2
- package/dist/kernel/client-ui-tool/lib/types/client/contract/slots.d.ts +13 -3
- package/dist/kernel/client-ui-tool/lib/types/client/index.d.ts +1 -1
- package/dist/kernel/client-ui-tool/lib/types/client/tool/ToolCallTree.d.ts +1 -1
- package/dist/kernel/client-ui-tool/lib/types/client/tool/ToolCallTree.js +8 -6
- package/dist/kernel/client-ui-tool/lib/types/client/tool/ToolDetails.d.ts +2 -9
- package/dist/kernel/client-ui-tool/lib/types/client/tool/ToolDetails.js +4 -3
- package/dist/kernel/client-ui-tool/lib/types/client/tool/models/read-card-model.d.ts +4 -18
- package/dist/kernel/client-ui-tool/lib/types/client/tool/models/read-card-model.js +21 -4
- package/dist/kernel/client-ui-tool/lib/types/client/tool/models/tool-call-model.d.ts +2 -9
- package/dist/kernel/client-ui-tool/lib/types/client/tool/models/tool-call-model.js +22 -2
- package/dist/kernel/client-ui-tool/lib/types/client/tool/toolviews/GenericToolCard.d.ts +1 -1
- package/dist/kernel/client-ui-tool/lib/types/client/tool/toolviews/GenericToolCard.js +3 -3
- package/dist/kernel/client-ui-tool/lib/types/client/tool/toolviews/file-mutation-row.d.ts +1 -1
- package/dist/kernel/client-ui-tool/lib/types/client/tool/toolviews/file-mutation-row.js +2 -2
- package/dist/kernel/client-ui-tool/lib/types/client/tool/toolviews/read-row.d.ts +1 -1
- package/dist/kernel/client-ui-tool/lib/types/client/tool/toolviews/read-row.js +3 -3
- package/dist/kernel/client-ui-tool/package.json +4 -6
- package/dist/kernel/client-ui-trajectory/lib/client.js +144 -143
- package/dist/kernel/client-ui-trajectory/lib/types/client/trajectory-assistant-definition.js +2 -1
- package/dist/kernel/client-ui-trajectory/package.json +2 -4
- package/dist/kernel/client-ui-user-questions/lib/client.js +73 -36
- package/dist/kernel/client-ui-user-questions/lib/types/client/QuestionComposer.js +24 -6
- package/dist/kernel/client-ui-user-questions/package.json +12 -10
- package/dist/kernel/client-ui-workflow-run/lib/client.js +262 -87
- package/dist/kernel/client-ui-workflow-run/lib/types/client/WorkflowRunPanel.js +162 -23
- package/dist/kernel/client-ui-workflow-run/package.json +3 -7
- package/dist/kernel/client-ui-workspace/lib/client.js +96 -60
- package/dist/kernel/client-ui-workspace/lib/types/client/WorkspaceBrowser.d.ts +1 -1
- package/dist/kernel/client-ui-workspace/lib/types/client/WorkspaceBrowser.js +38 -6
- package/dist/kernel/client-ui-workspace/lib/types/client/contract/slots.d.ts +9 -7
- package/dist/kernel/client-ui-workspace/lib/types/client/index.js +4 -2
- package/dist/kernel/client-ui-workspace/lib/types/client/rows/Rows.d.ts +4 -1
- package/dist/kernel/client-ui-workspace/lib/types/client/rows/Rows.js +5 -3
- package/dist/kernel/client-ui-workspace/package.json +6 -4
- package/dist/kernel/client-web/lib/base.css +41 -0
- package/dist/kernel/client-web/lib/boot-page.module.css +104 -0
- package/dist/kernel/client-web/lib/index.js +154 -308
- package/dist/kernel/client-web/lib/invariant.js +2 -0
- package/dist/kernel/client-web/lib/types/boot-page.d.ts +46 -0
- package/dist/kernel/client-web/lib/types/boot-page.js +93 -0
- package/dist/kernel/client-web/lib/types/boot.d.ts +20 -33
- package/dist/kernel/client-web/lib/types/boot.js +76 -149
- package/dist/kernel/client-web/lib/types/index.d.ts +5 -11
- package/dist/kernel/client-web/lib/types/index.js +4 -10
- package/dist/kernel/client-web/lib/types/loader-status.d.ts +3 -51
- package/dist/kernel/client-web/lib/types/loader-status.js +0 -35
- package/dist/kernel/client-web/lib/types/platform.d.ts +3 -1
- package/dist/kernel/client-web/lib/types/platform.js +4 -3
- package/dist/kernel/client-web/lib/types/seed.js +0 -6
- package/dist/kernel/client-web/package.json +8 -15
- package/dist/kernel/cmdline/package.json +1 -1
- package/dist/kernel/code-runtime/package.json +1 -1
- package/dist/kernel/code-runtime-python/lib/index.js +413 -0
- package/dist/kernel/code-runtime-python/lib/invariant.js +24 -0
- package/dist/kernel/code-runtime-python/lib/types/index.d.ts +12 -0
- package/dist/kernel/code-runtime-python/lib/types/index.js +11 -0
- package/dist/kernel/code-runtime-python/lib/types/invariant.d.ts +16 -0
- package/dist/kernel/code-runtime-python/lib/types/invariant.js +23 -0
- package/dist/kernel/code-runtime-python/lib/types/protocol.d.ts +329 -0
- package/dist/kernel/code-runtime-python/lib/types/protocol.js +496 -0
- package/dist/kernel/{client-schema-form → code-runtime-python}/package.json +11 -14
- package/dist/kernel/code-runtime-python/py/protocol.py +138 -0
- package/dist/kernel/code-runtime-worker-thread/package.json +1 -1
- package/dist/kernel/command-compact/package.json +1 -1
- package/dist/kernel/command-feedback/package.json +1 -1
- package/dist/kernel/command-goal/lib/index.js +40 -6
- package/dist/kernel/command-goal/lib/types/index.js +35 -6
- package/dist/kernel/command-goal/package.json +2 -1
- package/dist/kernel/commands/lib/index.js +78 -21
- package/dist/kernel/commands/lib/typert.host.js +53 -9
- package/dist/kernel/commands/lib/typert.remote-client.d.ts +4 -3
- package/dist/kernel/commands/lib/typert.remote-client.js +18 -2
- package/dist/kernel/commands/lib/types/index.d.ts +20 -1
- package/dist/kernel/commands/lib/types/index.js +77 -20
- package/dist/kernel/commands/lib/types/types.d.ts +8 -0
- package/dist/kernel/commands/package.json +5 -1
- package/dist/kernel/compaction/package.json +1 -1
- package/dist/kernel/compaction-basic/package.json +1 -1
- package/dist/kernel/compaction-tool-result-pruner/package.json +1 -1
- package/dist/kernel/cordis/package.json +3 -1
- package/dist/kernel/cordis-client-runner/lib/client.js +171 -37
- package/dist/kernel/cordis-client-runner/lib/types/client/api-catalog.js +3 -3
- package/dist/kernel/cordis-client-runner/lib/types/client/slot-catalog.js +208 -30
- package/dist/kernel/cordis-client-runner/package.json +2 -5
- package/dist/kernel/cordis-host-runner/lib/index.js +28 -5
- package/dist/kernel/cordis-host-runner/lib/typert.host.js +54 -6
- package/dist/kernel/cordis-host-runner/lib/types/sandbox.d.ts +9 -3
- package/dist/kernel/cordis-host-runner/lib/types/sandbox.js +34 -6
- package/dist/kernel/cordis-host-runner/package.json +1 -1
- package/dist/kernel/cordis-plugin-group/package.json +3 -1
- package/dist/kernel/cordis-plugin-hmr/lib/types/index.js +1 -1
- package/dist/kernel/cordis-plugin-hmr/package.json +3 -1
- package/dist/kernel/cordis-plugin-include/lib/index.js +2 -2
- package/dist/kernel/cordis-plugin-include/lib/types/index.d.ts +2 -2
- package/dist/kernel/cordis-plugin-include/lib/types/index.js +2 -2
- package/dist/kernel/cordis-plugin-include/package.json +3 -1
- package/dist/kernel/cordis-plugin-loader/package.json +3 -1
- package/dist/kernel/cordis-plugin-logger-console/package.json +3 -1
- package/dist/kernel/cordis-plugin-timer/package.json +3 -1
- package/dist/kernel/cosmokit/package.json +3 -1
- package/dist/kernel/credentials/lib/index.js +104 -13
- package/dist/kernel/credentials/lib/invariant.js +3 -3
- package/dist/kernel/credentials/lib/types/index.d.ts +136 -7
- package/dist/kernel/credentials/lib/types/index.js +114 -15
- package/dist/kernel/credentials/lib/types/invariant.js +3 -3
- package/dist/kernel/credentials/lib/types/types.d.ts +58 -5
- package/dist/kernel/credentials/lib/types/types.js +4 -4
- package/dist/kernel/credentials/package.json +1 -1
- package/dist/kernel/credentials-local/lib/index.js +387 -29
- package/dist/kernel/credentials-local/lib/invariant.js +1 -1
- package/dist/kernel/credentials-local/lib/types/index.d.ts +57 -12
- package/dist/kernel/credentials-local/lib/types/index.js +445 -30
- package/dist/kernel/credentials-local/lib/types/invariant.js +1 -1
- package/dist/kernel/credentials-local/package.json +1 -1
- package/dist/kernel/e2b/package.json +1 -1
- package/dist/kernel/experimental-agent-team/lib/index.js +1728 -0
- package/dist/kernel/experimental-agent-team/lib/invariant.js +354 -0
- package/dist/kernel/experimental-agent-team/lib/types/activity.d.ts +23 -0
- package/dist/kernel/experimental-agent-team/lib/types/activity.js +85 -0
- package/dist/kernel/experimental-agent-team/lib/types/error.d.ts +13 -0
- package/dist/kernel/experimental-agent-team/lib/types/error.js +23 -0
- package/dist/kernel/experimental-agent-team/lib/types/fold.d.ts +44 -0
- package/dist/kernel/experimental-agent-team/lib/types/fold.js +243 -0
- package/dist/kernel/experimental-agent-team/lib/types/index.d.ts +115 -0
- package/dist/kernel/experimental-agent-team/lib/types/index.js +205 -0
- package/dist/kernel/experimental-agent-team/lib/types/invariant.d.ts +9 -0
- package/dist/kernel/experimental-agent-team/lib/types/invariant.js +29 -0
- package/dist/kernel/experimental-agent-team/lib/types/journal.d.ts +39 -0
- package/dist/kernel/experimental-agent-team/lib/types/journal.js +59 -0
- package/dist/kernel/experimental-agent-team/lib/types/lifecycle.d.ts +33 -0
- package/dist/kernel/experimental-agent-team/lib/types/lifecycle.js +85 -0
- package/dist/kernel/experimental-agent-team/lib/types/mailbox.d.ts +79 -0
- package/dist/kernel/experimental-agent-team/lib/types/mailbox.js +303 -0
- package/dist/kernel/experimental-agent-team/lib/types/roster.d.ts +113 -0
- package/dist/kernel/experimental-agent-team/lib/types/roster.js +445 -0
- package/dist/kernel/experimental-agent-team/lib/types/session-message.d.ts +11 -0
- package/dist/kernel/experimental-agent-team/lib/types/session-message.js +23 -0
- package/dist/kernel/experimental-agent-team/lib/types/task-board.d.ts +62 -0
- package/dist/kernel/experimental-agent-team/lib/types/task-board.js +275 -0
- package/dist/kernel/experimental-agent-team/lib/types/task-graph.d.ts +21 -0
- package/dist/kernel/experimental-agent-team/lib/types/task-graph.js +62 -0
- package/dist/kernel/experimental-agent-team/lib/types/types.d.ts +192 -0
- package/dist/kernel/experimental-agent-team/lib/types/types.js +26 -0
- package/dist/kernel/experimental-agent-team/lib/types/validation.d.ts +16 -0
- package/dist/kernel/experimental-agent-team/lib/types/validation.js +33 -0
- package/dist/kernel/experimental-agent-team/package.json +62 -0
- package/dist/kernel/experimental-tool-agent-team/lib/index.js +555 -0
- package/dist/kernel/experimental-tool-agent-team/lib/invariant.js +13 -0
- package/dist/kernel/experimental-tool-agent-team/lib/types/index.d.ts +19 -0
- package/dist/kernel/experimental-tool-agent-team/lib/types/index.js +379 -0
- package/dist/kernel/experimental-tool-agent-team/lib/types/invariant.d.ts +9 -0
- package/dist/kernel/experimental-tool-agent-team/lib/types/invariant.js +11 -0
- package/dist/kernel/experimental-tool-agent-team/package.json +61 -0
- package/dist/kernel/file-reference/lib/index.js +138 -0
- package/dist/kernel/file-reference/lib/invariant.js +23 -0
- package/dist/kernel/file-reference/lib/typert.host.d.ts +3 -0
- package/dist/kernel/file-reference/lib/typert.host.js +436 -0
- package/dist/kernel/file-reference/lib/typert.remote-client.d.ts +26 -0
- package/dist/kernel/file-reference/lib/typert.remote-client.js +59 -0
- package/dist/kernel/file-reference/lib/types/grammar.d.ts +33 -0
- package/dist/kernel/file-reference/lib/types/grammar.js +43 -0
- package/dist/kernel/file-reference/lib/types/index.d.ts +42 -0
- package/dist/kernel/file-reference/lib/types/index.js +75 -0
- package/dist/kernel/file-reference/lib/types/invariant.d.ts +16 -0
- package/dist/kernel/file-reference/lib/types/invariant.js +22 -0
- package/dist/kernel/file-reference/lib/types/types.d.ts +13 -0
- package/dist/kernel/file-reference/lib/types/types.js +7 -0
- package/dist/kernel/file-reference/package.json +70 -0
- package/dist/kernel/file-reference-local/lib/index.js +327 -0
- package/dist/kernel/file-reference-local/lib/invariant.js +23 -0
- package/dist/kernel/file-reference-local/lib/types/index.d.ts +35 -0
- package/dist/kernel/file-reference-local/lib/types/index.js +105 -0
- package/dist/kernel/file-reference-local/lib/types/invariant.d.ts +16 -0
- package/dist/kernel/file-reference-local/lib/types/invariant.js +22 -0
- package/dist/kernel/file-reference-local/lib/types/search.d.ts +52 -0
- package/dist/kernel/file-reference-local/lib/types/search.js +258 -0
- package/dist/kernel/file-reference-local/package.json +58 -0
- package/dist/kernel/fs/package.json +1 -1
- package/dist/kernel/fs-e2b/package.json +1 -1
- package/dist/kernel/fs-local/package.json +1 -1
- package/dist/kernel/fs-observation-policy/package.json +1 -1
- package/dist/kernel/fs-sandbox/package.json +1 -1
- package/dist/kernel/goal/lib/index.js +5 -2
- package/dist/kernel/goal/lib/typert.host.js +27 -3
- package/dist/kernel/goal/lib/types/index.js +2 -2
- package/dist/kernel/goal/lib/types/types.d.ts +3 -0
- package/dist/kernel/goal/package.json +1 -1
- package/dist/kernel/goal-round-driver/package.json +1 -1
- package/dist/kernel/headless/package.json +1 -1
- package/dist/kernel/home-paths/package.json +1 -1
- package/dist/kernel/hook-protocol/package.json +1 -1
- package/dist/kernel/hooks-claude-code/package.json +1 -1
- package/dist/kernel/hooks-codex/package.json +1 -1
- package/dist/kernel/host-apiproxy/lib/index.js +25 -57
- package/dist/kernel/host-apiproxy/lib/types/api/host.d.ts +2 -0
- package/dist/kernel/host-apiproxy/lib/types/api/host.schema.d.ts +1 -0
- package/dist/kernel/host-apiproxy/lib/types/api/host.schema.js +1 -0
- package/dist/kernel/host-apiproxy/lib/types/api/sessions.d.ts +4 -0
- package/dist/kernel/host-apiproxy/lib/types/api/sessions.schema.js +1 -0
- package/dist/kernel/host-apiproxy/lib/types/api-proxy.js +15 -53
- package/dist/kernel/host-apiproxy/package.json +1 -1
- package/dist/kernel/host-directory-picker/package.json +1 -1
- package/dist/kernel/host-directory-picker-auto/package.json +1 -1
- package/dist/kernel/host-directory-picker-browse/package.json +1 -1
- package/dist/kernel/host-directory-picker-native/package.json +1 -1
- package/dist/kernel/host-frontend-static/lib/index.js +34 -26
- package/dist/kernel/host-frontend-static/lib/types/index.d.ts +10 -10
- package/dist/kernel/host-frontend-static/lib/types/index.js +38 -27
- package/dist/kernel/host-frontend-static/package.json +2 -2
- package/dist/kernel/host-plugin-inventory/package.json +1 -1
- package/dist/kernel/host-webserver/lib/index.js +102 -6
- package/dist/kernel/host-webserver/lib/types/index.d.ts +33 -5
- package/dist/kernel/host-webserver/lib/types/index.js +28 -5
- package/dist/kernel/host-webserver/lib/types/injections.d.ts +56 -0
- package/dist/kernel/host-webserver/lib/types/injections.js +82 -0
- package/dist/kernel/host-webserver/package.json +1 -1
- package/dist/kernel/invariants/package.json +1 -1
- package/dist/kernel/jobs/package.json +1 -1
- package/dist/kernel/jobs-local/package.json +1 -1
- package/dist/kernel/launch-environment/package.json +1 -1
- package/dist/kernel/llm/lib/index.js +247 -25
- package/dist/kernel/llm/lib/types/assembler.d.ts +10 -1
- package/dist/kernel/llm/lib/types/assembler.js +20 -1
- package/dist/kernel/llm/lib/types/content.d.ts +59 -0
- package/dist/kernel/llm/lib/types/content.js +149 -0
- package/dist/kernel/llm/lib/types/index.d.ts +24 -1
- package/dist/kernel/llm/lib/types/index.js +61 -8
- package/dist/kernel/llm/lib/types/retry-policy.d.ts +1 -1
- package/dist/kernel/llm/lib/types/retry-policy.js +6 -2
- package/dist/kernel/llm/package.json +1 -1
- package/dist/kernel/llm-deepseek/lib/index.js +1100 -70
- package/dist/kernel/llm-deepseek/lib/types/adapter.d.ts +69 -1
- package/dist/kernel/llm-deepseek/lib/types/adapter.js +296 -60
- package/dist/kernel/llm-deepseek/lib/types/file-id.d.ts +19 -0
- package/dist/kernel/llm-deepseek/lib/types/file-id.js +18 -0
- package/dist/kernel/llm-deepseek/lib/types/file-store.d.ts +83 -0
- package/dist/kernel/llm-deepseek/lib/types/file-store.js +261 -0
- package/dist/kernel/llm-deepseek/lib/types/files-api.d.ts +103 -0
- package/dist/kernel/llm-deepseek/lib/types/files-api.js +206 -0
- package/dist/kernel/llm-deepseek/lib/types/index.d.ts +31 -3
- package/dist/kernel/llm-deepseek/lib/types/index.js +139 -3
- package/dist/kernel/llm-deepseek/lib/types/serialize.d.ts +55 -6
- package/dist/kernel/llm-deepseek/lib/types/serialize.js +179 -23
- package/dist/kernel/llm-deepseek/lib/types/types.d.ts +28 -5
- package/dist/kernel/llm-deepseek/lib/types/upload-index.d.ts +68 -0
- package/dist/kernel/llm-deepseek/lib/types/upload-index.js +171 -0
- package/dist/kernel/llm-deepseek/package.json +9 -1
- package/dist/kernel/llm-pi-ai/lib/index.js +1758 -1171
- package/dist/kernel/llm-pi-ai/lib/types/adapter.d.ts +30 -5
- package/dist/kernel/llm-pi-ai/lib/types/adapter.js +43 -23
- package/dist/kernel/llm-pi-ai/lib/types/auth.d.ts +60 -0
- package/dist/kernel/llm-pi-ai/lib/types/auth.js +196 -0
- package/dist/kernel/llm-pi-ai/lib/types/catalog.d.ts +176 -38
- package/dist/kernel/llm-pi-ai/lib/types/catalog.js +245 -50
- package/dist/kernel/llm-pi-ai/lib/types/config.d.ts +37 -5
- package/dist/kernel/llm-pi-ai/lib/types/config.js +67 -2
- package/dist/kernel/llm-pi-ai/lib/types/context.d.ts +8 -3
- package/dist/kernel/llm-pi-ai/lib/types/context.js +60 -16
- package/dist/kernel/llm-pi-ai/lib/types/index.d.ts +1 -0
- package/dist/kernel/llm-pi-ai/lib/types/index.js +21 -19
- package/dist/kernel/llm-pi-ai/lib/types/login.d.ts +21 -0
- package/dist/kernel/llm-pi-ai/lib/types/login.js +154 -0
- package/dist/kernel/llm-pi-ai/lib/types/stream.js +4 -0
- package/dist/kernel/llm-pi-ai/package.json +3 -1
- package/dist/kernel/llm-retry/package.json +1 -1
- package/dist/kernel/lsp/package.json +1 -1
- package/dist/kernel/lsp-stdio/package.json +1 -1
- package/dist/kernel/manifest.json +10 -2
- package/dist/kernel/mcp-client/package.json +1 -1
- package/dist/kernel/message-feedback/package.json +1 -1
- package/dist/kernel/native-command/package.json +1 -1
- package/dist/kernel/node-addon-landlock-run/lib/index.js +1 -1
- package/dist/kernel/node-addon-landlock-run/package.json +4 -2
- package/dist/kernel/output-retention/package.json +1 -1
- package/dist/kernel/permission-presets/lib/index.js +14 -2
- package/dist/kernel/permission-presets/lib/types/index.d.ts +5 -0
- package/dist/kernel/permission-presets/lib/types/index.js +11 -2
- package/dist/kernel/permission-presets/package.json +1 -1
- package/dist/kernel/persona/package.json +1 -1
- package/dist/kernel/plan-mode/lib/index.js +49 -15
- package/dist/kernel/plan-mode/lib/types/index.d.ts +22 -0
- package/dist/kernel/plan-mode/lib/types/index.js +45 -19
- package/dist/kernel/plan-mode/lib/types/types.d.ts +5 -4
- package/dist/kernel/plan-mode/package.json +1 -1
- package/dist/kernel/pwsh-local/package.json +1 -1
- package/dist/kernel/pwsh-sandbox/package.json +1 -1
- package/dist/kernel/repeat-tool-reminder/lib/index.js +1 -1
- package/dist/kernel/repeat-tool-reminder/package.json +1 -1
- package/dist/kernel/sandbox/package.json +1 -1
- package/dist/kernel/sandbox-local/lib/index.js +8 -13
- package/dist/kernel/sandbox-local/lib/types/index.d.ts +1 -3
- package/dist/kernel/sandbox-local/lib/types/index.js +4 -7
- package/dist/kernel/sandbox-local/lib/types/profiles.js +1 -1
- package/dist/kernel/sandbox-local/package.json +1 -1
- package/dist/kernel/sandbox-policy/package.json +1 -1
- package/dist/kernel/sandbox-windows-acl/package.json +1 -1
- package/dist/kernel/schedule/package.json +1 -1
- package/dist/kernel/schemastery/package.json +3 -1
- package/dist/kernel/scope/package.json +1 -1
- package/dist/kernel/sdk-client/lib/index.js +2 -2
- package/dist/kernel/sdk-client/lib/types/api.js +2 -2
- package/dist/kernel/sdk-client/lib/types/types.d.ts +4 -4
- package/dist/kernel/sdk-client/package.json +1 -1
- package/dist/kernel/sdk-jsonrpc-server/lib/index.js +12 -5
- package/dist/kernel/sdk-jsonrpc-server/lib/types/index.js +7 -0
- package/dist/kernel/sdk-jsonrpc-server/lib/types/server.d.ts +2 -1
- package/dist/kernel/sdk-jsonrpc-server/lib/types/server.js +15 -6
- package/dist/kernel/sdk-jsonrpc-server/package.json +2 -1
- package/dist/kernel/sdk-protocol/package.json +1 -1
- package/dist/kernel/session/lib/index.js +4 -0
- package/dist/kernel/session/lib/types/known-event-types.js +4 -0
- package/dist/kernel/session/lib/types/types.d.ts +6 -1
- package/dist/kernel/session/package.json +1 -1
- package/dist/kernel/session-checkpoint-policy/package.json +1 -1
- package/dist/kernel/session-log-export/package.json +2 -5
- package/dist/kernel/session-persistence/lib/index.js +1 -1
- package/dist/kernel/session-persistence/lib/types/coordinator.js +2 -1
- package/dist/kernel/session-persistence/package.json +1 -1
- package/dist/kernel/session-persistence-jsonl/package.json +1 -1
- package/dist/kernel/session-persistence-sqlite/lib/index.js +1105 -375
- package/dist/kernel/session-persistence-sqlite/lib/invariant.js +2 -2
- package/dist/kernel/session-persistence-sqlite/lib/types/codec.d.ts +72 -0
- package/dist/kernel/session-persistence-sqlite/lib/types/codec.js +304 -0
- package/dist/kernel/session-persistence-sqlite/lib/types/compression.d.ts +46 -0
- package/dist/kernel/session-persistence-sqlite/lib/types/compression.js +234 -0
- package/dist/kernel/session-persistence-sqlite/lib/types/index.d.ts +22 -80
- package/dist/kernel/session-persistence-sqlite/lib/types/index.js +27 -278
- package/dist/kernel/session-persistence-sqlite/lib/types/invariant.js +2 -2
- package/dist/kernel/session-persistence-sqlite/lib/types/schema.d.ts +63 -85
- package/dist/kernel/session-persistence-sqlite/lib/types/schema.js +293 -159
- package/dist/kernel/session-persistence-sqlite/lib/types/sql.d.ts +15 -0
- package/dist/kernel/session-persistence-sqlite/lib/types/sql.js +57 -0
- package/dist/kernel/session-persistence-sqlite/lib/types/store.d.ts +66 -0
- package/dist/kernel/session-persistence-sqlite/lib/types/store.js +394 -0
- package/dist/kernel/session-persistence-sqlite/package.json +9 -3
- package/dist/kernel/session-persistence-sqlite/resources/sql/begin-immediate.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/begin.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/commit.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/delete-events-from.sql +2 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/foreign-keys-on.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/insert-event.sql +3 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/insert-persistence-state.sql +2 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/journal-mode-delete.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/journal-mode-persist.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/journal-mode-truncate.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/journal-mode-wal.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/mmap-off.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/rollback.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/schema.sql +30 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/select-application-id.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/select-events-from.sql +4 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/select-events.sql +4 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/select-mmap-size.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/select-packed-predecessors.sql +6 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/select-schema-objects.sql +4 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/select-session.sql +4 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/select-sessions.sql +3 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/select-store-id.sql +3 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/select-synchronous.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/select-tail-events.sql +5 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/select-trusted-schema.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/select-user-object-count.sql +3 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/select-user-version.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/set-application-id.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/set-user-version-17.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/synchronous-full.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/trusted-schema-off.sql +1 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/update-session-revision.sql +3 -0
- package/dist/kernel/session-persistence-sqlite/resources/sql/upsert-session.sql +13 -0
- package/dist/kernel/session-projection/lib/index.js +55 -30
- package/dist/kernel/session-projection/lib/types/index.d.ts +57 -34
- package/dist/kernel/session-projection/lib/types/index.js +61 -36
- package/dist/kernel/session-projection/lib/types/types.d.ts +11 -4
- package/dist/kernel/session-projection/package.json +1 -1
- package/dist/kernel/session-projection-cache/lib/index.js +1 -1
- package/dist/kernel/session-projection-cache/lib/types/index.d.ts +1 -1
- package/dist/kernel/session-projection-cache/lib/types/index.js +4 -5
- package/dist/kernel/session-projection-cache/package.json +1 -1
- package/dist/kernel/session-query/package.json +1 -1
- package/dist/kernel/session-query-sqlite/package.json +1 -1
- package/dist/kernel/session-reference/lib/index.js +232 -110
- package/dist/kernel/session-reference/lib/typert.host.d.ts +3 -0
- package/dist/kernel/session-reference/lib/typert.host.js +458 -0
- package/dist/kernel/session-reference/lib/typert.remote-client.d.ts +26 -0
- package/dist/kernel/session-reference/lib/typert.remote-client.js +62 -0
- package/dist/kernel/session-reference/lib/types/index.d.ts +25 -5
- package/dist/kernel/session-reference/lib/types/index.js +230 -126
- package/dist/kernel/session-reference/lib/types/types.d.ts +14 -3
- package/dist/kernel/session-reference/lib/types/types.js +6 -1
- package/dist/kernel/session-reference/package.json +23 -3
- package/dist/kernel/session-stats/lib/index.js +31 -12
- package/dist/kernel/session-stats/lib/types/projection.d.ts +64 -2
- package/dist/kernel/session-stats/lib/types/projection.js +31 -12
- package/dist/kernel/session-stats/package.json +1 -1
- package/dist/kernel/session-telemetry/package.json +1 -1
- package/dist/kernel/session-telemetry-otel/package.json +1 -1
- package/dist/kernel/session-title/lib/index.js +6 -2
- package/dist/kernel/session-title/lib/types/index.js +3 -2
- package/dist/kernel/session-title/lib/types/types.d.ts +3 -0
- package/dist/kernel/session-title/package.json +1 -1
- package/dist/kernel/session-title-all-prompts-llm/package.json +1 -1
- package/dist/kernel/session-title-first-prompt-llm/package.json +1 -1
- package/dist/kernel/session-title-llm/package.json +1 -1
- package/dist/kernel/settings/package.json +1 -1
- package/dist/kernel/settings-file/package.json +1 -1
- package/dist/kernel/shell/package.json +1 -1
- package/dist/kernel/shell-env/package.json +1 -1
- package/dist/kernel/skill/package.json +1 -1
- package/dist/kernel/skill-badge/assets/nomix-badge.md +6 -6
- package/dist/kernel/skill-badge/assets/nomix-badge.png +0 -0
- package/dist/kernel/skill-badge/lib/index.js +1 -1
- package/dist/kernel/skill-badge/lib/types/index.js +1 -1
- package/dist/kernel/skill-badge/package.json +1 -1
- package/dist/kernel/skill-filesystem/package.json +1 -1
- package/dist/kernel/spill/package.json +1 -1
- package/dist/kernel/spill-local/package.json +1 -1
- package/dist/kernel/spill-policy/package.json +1 -1
- package/dist/kernel/storage/package.json +1 -1
- package/dist/kernel/storage-domain/package.json +1 -1
- package/dist/kernel/storage-json/package.json +1 -1
- package/dist/kernel/storage-sqlite/package.json +1 -1
- package/dist/kernel/subagent/lib/index.js +123 -20
- package/dist/kernel/subagent/lib/types/continuation.d.ts +21 -2
- package/dist/kernel/subagent/lib/types/continuation.js +58 -7
- package/dist/kernel/subagent/lib/types/index.d.ts +11 -0
- package/dist/kernel/subagent/lib/types/index.js +16 -0
- package/dist/kernel/subagent/lib/types/out-of-process.d.ts +2 -0
- package/dist/kernel/subagent/lib/types/out-of-process.js +31 -1
- package/dist/kernel/subagent/lib/types/projection.d.ts +55 -8
- package/dist/kernel/subagent/lib/types/projection.js +30 -15
- package/dist/kernel/subagent/lib/types/run-settlement.js +10 -3
- package/dist/kernel/subagent/lib/types/types.d.ts +7 -0
- package/dist/kernel/subagent/package.json +1 -1
- package/dist/kernel/subagent-acp/package.json +1 -1
- package/dist/kernel/subagent-claude-code/cordis.patch.yml +6 -0
- package/dist/kernel/subagent-claude-code/lib/index.js +267 -73
- package/dist/kernel/subagent-claude-code/lib/types/index.d.ts +16 -6
- package/dist/kernel/subagent-claude-code/lib/types/index.js +35 -14
- package/dist/kernel/subagent-claude-code/lib/types/process.d.ts +5 -7
- package/dist/kernel/subagent-claude-code/lib/types/process.js +12 -24
- package/dist/kernel/subagent-claude-code/lib/types/run.d.ts +24 -7
- package/dist/kernel/subagent-claude-code/lib/types/run.js +266 -40
- package/dist/kernel/subagent-claude-code/package.json +10 -2
- package/dist/kernel/subagent-codex/cordis.patch.yml +5 -0
- package/dist/kernel/subagent-codex/lib/index.js +482 -91
- package/dist/kernel/subagent-codex/lib/types/index.d.ts +11 -6
- package/dist/kernel/subagent-codex/lib/types/index.js +33 -12
- package/dist/kernel/subagent-codex/lib/types/run.d.ts +17 -8
- package/dist/kernel/subagent-codex/lib/types/run.js +235 -42
- package/dist/kernel/subagent-codex/lib/types/wire.d.ts +49 -1
- package/dist/kernel/subagent-codex/lib/types/wire.js +280 -33
- package/dist/kernel/subagent-codex/package.json +10 -5
- package/dist/kernel/subagent-fork-in-process/package.json +1 -1
- package/dist/kernel/subagent-in-process-driver/package.json +1 -1
- package/dist/kernel/subagent-nomix-sdk/package.json +1 -1
- package/dist/kernel/subagent-spawn-in-process/package.json +1 -1
- package/dist/kernel/subprocess/package.json +1 -1
- package/dist/kernel/subprocess-e2b/package.json +1 -1
- package/dist/kernel/subprocess-local/lib/index.js +303 -1
- package/dist/kernel/subprocess-local/lib/types/process-inspector.js +3 -0
- package/dist/kernel/subprocess-local/lib/types/terminal.d.ts +6 -1
- package/dist/kernel/subprocess-local/lib/types/terminal.js +78 -1
- package/dist/kernel/subprocess-local/lib/types/windows-inspector.d.ts +80 -0
- package/dist/kernel/subprocess-local/lib/types/windows-inspector.js +259 -0
- package/dist/kernel/subprocess-local/package.json +2 -1
- package/dist/kernel/system-prompt/package.json +1 -1
- package/dist/kernel/terminal/package.json +1 -1
- package/dist/kernel/terminal-bash/lib/index.js +85 -20
- package/dist/kernel/terminal-bash/lib/types/config.d.ts +29 -5
- package/dist/kernel/terminal-bash/lib/types/config.js +33 -3
- package/dist/kernel/terminal-bash/lib/types/index.d.ts +7 -0
- package/dist/kernel/terminal-bash/lib/types/index.js +65 -13
- package/dist/kernel/terminal-bash/package.json +2 -1
- package/dist/kernel/time-context/lib/index.js +1 -1
- package/dist/kernel/time-context/lib/invariant.js +1 -1
- package/dist/kernel/time-context/package.json +1 -1
- package/dist/kernel/timeout/package.json +1 -1
- package/dist/kernel/tmux-context/lib/index.js +1 -1
- package/dist/kernel/tmux-context/package.json +1 -1
- package/dist/kernel/token-meter/lib/index.js +77 -21
- package/dist/kernel/token-meter/lib/types/breakdown-projection.d.ts +76 -9
- package/dist/kernel/token-meter/lib/types/breakdown-projection.js +22 -6
- package/dist/kernel/token-meter/lib/types/usage-projection.d.ts +186 -25
- package/dist/kernel/token-meter/lib/types/usage-projection.js +44 -15
- package/dist/kernel/token-meter/package.json +1 -1
- package/dist/kernel/tool-ask-user/package.json +1 -1
- package/dist/kernel/tool-bash/package.json +1 -1
- package/dist/kernel/tool-bash-persistent/lib/index.js +15 -5
- package/dist/kernel/tool-bash-persistent/lib/types/index.js +23 -6
- package/dist/kernel/tool-bash-persistent/package.json +1 -1
- package/dist/kernel/tool-call-timeout-policy/package.json +1 -1
- package/dist/kernel/tool-cordis/lib/index.js +655 -83
- package/dist/kernel/tool-cordis/lib/types/api-catalog.js +439 -41
- package/dist/kernel/tool-cordis/package.json +1 -1
- package/dist/kernel/tool-fs/lib/index.js +80 -52
- package/dist/kernel/tool-fs/lib/types/read-image.d.ts +16 -12
- package/dist/kernel/tool-fs/lib/types/read-image.js +73 -29
- package/dist/kernel/tool-fs/package.json +1 -1
- package/dist/kernel/tool-fs-search/lib/index.js +11 -7
- package/dist/kernel/tool-fs-search/lib/types/search-core.d.ts +5 -6
- package/dist/kernel/tool-fs-search/lib/types/search-core.js +12 -7
- package/dist/kernel/tool-fs-search/package.json +1 -1
- package/dist/kernel/tool-goal/package.json +1 -1
- package/dist/kernel/tool-jobs/package.json +1 -1
- package/dist/kernel/tool-lsp/package.json +1 -1
- package/dist/kernel/tool-pwsh/package.json +1 -1
- package/dist/kernel/tool-pwsh-persistent/lib/index.js +407 -0
- package/dist/kernel/tool-pwsh-persistent/lib/invariant.js +24 -0
- package/dist/kernel/tool-pwsh-persistent/lib/types/index.d.ts +24 -0
- package/dist/kernel/tool-pwsh-persistent/lib/types/index.js +465 -0
- package/dist/kernel/tool-pwsh-persistent/lib/types/invariant.d.ts +16 -0
- package/dist/kernel/tool-pwsh-persistent/lib/types/invariant.js +23 -0
- package/dist/kernel/tool-pwsh-persistent/package.json +62 -0
- package/dist/kernel/tool-ralph/package.json +1 -1
- package/dist/kernel/tool-session-query/package.json +1 -1
- package/dist/kernel/tool-skill/package.json +1 -1
- package/dist/kernel/tool-str-replace-editor/package.json +1 -1
- package/dist/kernel/tool-subagent/lib/index.js +10 -8
- package/dist/kernel/tool-subagent/lib/types/index.js +15 -8
- package/dist/kernel/tool-subagent/package.json +1 -1
- package/dist/kernel/tool-subagent-control/package.json +1 -1
- package/dist/kernel/tool-subagent-report/lib/index.js +1 -1
- package/dist/kernel/tool-subagent-report/lib/types/index.d.ts +3 -3
- package/dist/kernel/tool-subagent-report/lib/types/index.js +1 -1
- package/dist/kernel/tool-subagent-report/package.json +1 -1
- package/dist/kernel/tool-terminal/package.json +1 -1
- package/dist/kernel/tool-todo/lib/index.js +5 -2
- package/dist/kernel/tool-todo/lib/types/index.js +2 -2
- package/dist/kernel/tool-todo/lib/types/types.d.ts +3 -0
- package/dist/kernel/tool-todo/package.json +1 -1
- package/dist/kernel/tool-web/lib/index.js +101 -26
- package/dist/kernel/tool-web/lib/types/index.d.ts +4 -2
- package/dist/kernel/tool-web/lib/types/index.js +5 -3
- package/dist/kernel/tool-web/lib/types/search.d.ts +23 -20
- package/dist/kernel/tool-web/lib/types/search.js +109 -20
- package/dist/kernel/tool-web/package.json +1 -1
- package/dist/kernel/tool-workflow/package.json +1 -1
- package/dist/kernel/tools/package.json +1 -1
- package/dist/kernel/typert-generator/lib/index.js +8 -3
- package/dist/kernel/typert-generator/lib/types/cordis-catalog.js +8 -3
- package/dist/kernel/typert-generator/package.json +1 -1
- package/dist/kernel/typert-loader/package.json +1 -1
- package/dist/kernel/typert-protocol/package.json +1 -1
- package/dist/kernel/typert-registry/package.json +1 -1
- package/dist/kernel/user-approval/package.json +1 -1
- package/dist/kernel/user-questions/package.json +1 -1
- package/dist/kernel/web/lib/types/types.d.ts +4 -3
- package/dist/kernel/web/package.json +1 -1
- package/dist/kernel/web-app/cordis.patch.yml +27 -6
- package/dist/kernel/web-app/lib/index.js +111 -15
- package/dist/kernel/web-app/lib/startup.js +4 -2
- package/dist/kernel/web-app/lib/types/index.d.ts +8 -4
- package/dist/kernel/web-app/lib/types/index.js +116 -23
- package/dist/kernel/web-app/lib/types/startup.d.ts +3 -1
- package/dist/kernel/web-app/lib/types/startup.js +4 -1
- package/dist/kernel/web-app/package.json +12 -2
- package/dist/kernel/web-fetch-http/lib/index.js +1 -1
- package/dist/kernel/web-fetch-http/lib/types/index.d.ts +1 -1
- package/dist/kernel/web-fetch-http/lib/types/index.js +1 -1
- package/dist/kernel/web-fetch-http/package.json +1 -1
- package/dist/kernel/web-frontend/dist/assets/index-BnapMmQ_.css +1 -0
- package/dist/kernel/web-frontend/dist/assets/index-Dx7Ws_OC.js +96 -0
- package/dist/kernel/web-frontend/dist/assets/langs/{php-D-uCvoST.js → php-DDkx9sim.js} +2 -2
- package/dist/{assets/web/assets/langs/ruby-DEItuUFs.js → kernel/web-frontend/dist/assets/langs/ruby-DCxyoPen.js} +2 -2
- package/dist/kernel/web-frontend/dist/assets/{vendor-Cjbwl5VI.js → vendor-D22_Mp1f.js} +2 -2
- package/dist/kernel/web-frontend/dist/favicon.svg +8 -0
- package/dist/kernel/web-frontend/dist/index.html +5 -5
- package/dist/kernel/web-frontend/package.json +5 -8
- package/dist/kernel/web-search-deepseek/lib/index.js +1 -1
- package/dist/kernel/web-search-deepseek/lib/types/provider.js +1 -1
- package/dist/kernel/web-search-deepseek/package.json +1 -1
- package/dist/kernel/web-search-exa/lib/index.js +1 -1
- package/dist/kernel/web-search-exa/lib/types/provider.js +1 -1
- package/dist/kernel/web-search-exa/package.json +1 -1
- package/dist/kernel/web-search-perplexity/lib/index.js +1 -1
- package/dist/kernel/web-search-perplexity/lib/types/provider.js +1 -1
- package/dist/kernel/web-search-perplexity/package.json +1 -1
- package/dist/kernel/workflow/package.json +1 -1
- package/dist/kernel/workflow-worker-thread/package.json +1 -1
- package/dist/kernel/workspace/package.json +1 -1
- package/dist/plugins/manifest.json +50 -10
- package/dist/runtime/index.js +0 -2
- package/package.json +8 -6
- package/dist/assets/web/assets/index-B_fSXASy.css +0 -1
- package/dist/assets/web/assets/index-B_sZ-Gsu.js +0 -112
- package/dist/cli/builtin-registry.d.ts +0 -5
- package/dist/cli/profile-boot-CeU09iFc.js +0 -2
- package/dist/kernel/app-boot/lib/types/legacy-branding.d.ts +0 -6
- package/dist/kernel/app-boot/lib/types/legacy-branding.js +0 -18
- package/dist/kernel/client-schema-form/lib/index.js +0 -137
- package/dist/kernel/client-schema-form/lib/types/index.d.ts +0 -10
- package/dist/kernel/client-schema-form/lib/types/index.js +0 -9
- package/dist/kernel/client-schema-form/lib/types/model.d.ts +0 -66
- package/dist/kernel/client-schema-form/lib/types/model.js +0 -153
- package/dist/kernel/client-ui-subagent/lib/types/client/SubagentCatalogAction.d.ts +0 -18
- package/dist/kernel/client-ui-theme/lib/styles/base.css +0 -15
- package/dist/kernel/client-ui-theme/lib/styles/design-platform.css +0 -338
- package/dist/kernel/client-ui-theme/lib/styles/gradient-shadow-text.css +0 -232
- package/dist/kernel/client-ui-theme/lib/styles/scrollbar.css +0 -90
- package/dist/kernel/client-ui-theme/lib/styles/shiki.css +0 -31
- package/dist/kernel/client-web/lib/types/AppRoot.d.ts +0 -16
- package/dist/kernel/client-web/lib/types/AppRoot.js +0 -27
- package/dist/kernel/client-web/lib/types/DocumentTitle.js +0 -16
- package/dist/kernel/client-web/lib/types/app-shell.d.ts +0 -28
- package/dist/kernel/client-web/lib/types/app-shell.js +0 -27
- package/dist/kernel/client-web/lib/types/app.d.ts +0 -21
- package/dist/kernel/client-web-react/lib/index.js +0 -810
- package/dist/kernel/client-web-react/lib/types/index.d.ts +0 -16
- package/dist/kernel/client-web-react/lib/types/index.js +0 -6
- package/dist/kernel/client-web-react/lib/types/use-invoke.d.ts +0 -9
- package/dist/kernel/client-web-react/lib/types/use-invoke.js +0 -52
- package/dist/kernel/skill-badge/assets/nomix-badge.svg +0 -8
- package/dist/kernel/web-frontend/dist/assets/index-B_fSXASy.css +0 -1
- package/dist/kernel/web-frontend/dist/assets/index-B_sZ-Gsu.js +0 -112
- /package/dist/kernel/{client-web-react/lib/types → client-ui-renderer/lib/types/client}/bind.js +0 -0
- /package/dist/kernel/{client-web-react/lib/types → client-ui-renderer/lib/types/client}/session-provider.js +0 -0
|
@@ -1,487 +1,1217 @@
|
|
|
1
|
+
import { Service } from "../../cordis/lib/index.js";
|
|
1
2
|
import z from "../../schemastery/lib/index.mjs";
|
|
2
|
-
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { statSync } from "node:fs";
|
|
4
|
-
import { mkdir, open } from "node:fs/promises";
|
|
5
|
-
import { dirname, resolve } from "node:path";
|
|
6
3
|
import { DEFAULT_PREPARED_SESSION_CACHE_SIZE, DEFAULT_WRITE_BATCH_MAX_DELAY_MS, MAX_WRITE_BATCH_DELAY_MS, PersistenceCoordinator, SessionPersistence, SessionPersistenceRevision } from "../../session-persistence/lib/index.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
|
+
import { readFileSync, statSync } from "node:fs";
|
|
6
|
+
import { lstat, mkdir, open } from "node:fs/promises";
|
|
7
|
+
import { dirname, isAbsolute, resolve } from "node:path";
|
|
8
|
+
import { TextDecoder } from "node:util";
|
|
9
|
+
import { constants, zstdCompressSync, zstdDecompressSync } from "node:zlib";
|
|
10
|
+
import { performance } from "node:perf_hooks";
|
|
11
|
+
import { setTimeout } from "node:timers/promises";
|
|
12
|
+
import { SessionId } from "../../session/lib/index.js";
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
14
|
+
/** Maximum logical members represented by one packed physical record. */
|
|
15
|
+
const MAX_PACKED_ROW_MEMBERS = 1024;
|
|
16
|
+
/** Maximum UTF-8 bytes in one packed physical record's data column. */
|
|
17
|
+
const MAX_PACKED_DATA_BYTES = 1048576;
|
|
18
|
+
function isRecord(value) {
|
|
19
|
+
return typeof value === "object" && value !== null;
|
|
20
|
+
}
|
|
21
|
+
function hasExactKeys(value, keys) {
|
|
22
|
+
return Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));
|
|
23
|
+
}
|
|
24
|
+
function classify(event) {
|
|
25
|
+
if (event.type !== "assistant/chunk") return void 0;
|
|
26
|
+
if (!hasExactKeys(event, [
|
|
27
|
+
"type",
|
|
28
|
+
"seq",
|
|
29
|
+
"time",
|
|
30
|
+
"data"
|
|
31
|
+
])) return void 0;
|
|
32
|
+
if (!Number.isSafeInteger(event.seq) || event.seq < 0 || !Number.isSafeInteger(event.time)) return void 0;
|
|
33
|
+
const data = event.data;
|
|
34
|
+
if (!isRecord(data) || !hasExactKeys(data, [
|
|
35
|
+
"turn",
|
|
36
|
+
"step",
|
|
37
|
+
"chunk"
|
|
38
|
+
])) return void 0;
|
|
39
|
+
if (typeof data.turn !== "number" || typeof data.step !== "number") return void 0;
|
|
40
|
+
const chunk = data.chunk;
|
|
41
|
+
if (!isRecord(chunk) || typeof chunk.index !== "number") return void 0;
|
|
42
|
+
switch (chunk.type) {
|
|
43
|
+
case "text-delta":
|
|
44
|
+
case "reasoning-delta": return hasExactKeys(chunk, [
|
|
45
|
+
"type",
|
|
46
|
+
"index",
|
|
47
|
+
"text"
|
|
48
|
+
]) && typeof chunk.text === "string" ? chunk.type : void 0;
|
|
49
|
+
case "tool-call-delta": return (hasExactKeys(chunk, [
|
|
50
|
+
"type",
|
|
51
|
+
"index",
|
|
52
|
+
"id",
|
|
53
|
+
"argumentsDelta"
|
|
54
|
+
]) || hasExactKeys(chunk, [
|
|
55
|
+
"type",
|
|
56
|
+
"index",
|
|
57
|
+
"id",
|
|
58
|
+
"name",
|
|
59
|
+
"argumentsDelta"
|
|
60
|
+
]) && typeof chunk.name === "string") && typeof chunk.id === "string" && typeof chunk.argumentsDelta === "string" ? chunk.type : void 0;
|
|
61
|
+
default: return;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function toolCallOf(event) {
|
|
65
|
+
return event.data.chunk;
|
|
66
|
+
}
|
|
67
|
+
function indexOf(event) {
|
|
68
|
+
return event.data.chunk.index;
|
|
69
|
+
}
|
|
70
|
+
function continues(previous, next, kind) {
|
|
71
|
+
if (next.seq !== previous.seq + 1 || !Number.isSafeInteger(next.time - previous.time)) return false;
|
|
72
|
+
if (next.data.turn !== previous.data.turn || next.data.step !== previous.data.step) return false;
|
|
73
|
+
if (indexOf(next) !== indexOf(previous)) return false;
|
|
74
|
+
if (kind !== "tool-call-delta") return true;
|
|
75
|
+
const left = toolCallOf(previous);
|
|
76
|
+
const right = toolCallOf(next);
|
|
77
|
+
return left.id === right.id && Object.hasOwn(left, "name") === Object.hasOwn(right, "name") && left.name === right.name;
|
|
78
|
+
}
|
|
79
|
+
function buildRow(kind, run) {
|
|
80
|
+
const first = run[0];
|
|
81
|
+
const base = {
|
|
82
|
+
turn: first.data.turn,
|
|
83
|
+
step: first.data.step,
|
|
84
|
+
index: indexOf(first),
|
|
85
|
+
dt: run.slice(1).map((event, index) => event.time - run[index].time)
|
|
86
|
+
};
|
|
87
|
+
const envelope = {
|
|
88
|
+
seq0: first.seq,
|
|
89
|
+
time0: first.time
|
|
90
|
+
};
|
|
91
|
+
if (kind === "tool-call-delta") {
|
|
92
|
+
const call = toolCallOf(first);
|
|
93
|
+
return {
|
|
94
|
+
type: "tool-call-chunks",
|
|
95
|
+
...envelope,
|
|
96
|
+
data: {
|
|
97
|
+
...base,
|
|
98
|
+
id: call.id,
|
|
99
|
+
...Object.hasOwn(call, "name") ? { name: call.name } : {},
|
|
100
|
+
args: run.map((event) => event.data.chunk.argumentsDelta)
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const data = {
|
|
105
|
+
...base,
|
|
106
|
+
texts: run.map((event) => event.data.chunk.text)
|
|
107
|
+
};
|
|
108
|
+
return kind === "text-delta" ? {
|
|
109
|
+
type: "text-chunks",
|
|
110
|
+
...envelope,
|
|
111
|
+
data
|
|
112
|
+
} : {
|
|
113
|
+
type: "reasoning-chunks",
|
|
114
|
+
...envelope,
|
|
115
|
+
data
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function packedDataBytes(row) {
|
|
119
|
+
return Buffer.byteLength(JSON.stringify(row.data));
|
|
120
|
+
}
|
|
121
|
+
function emitBoundedRun(out, kind, completeRun) {
|
|
122
|
+
let offset = 0;
|
|
123
|
+
while (completeRun.length - offset >= 3) {
|
|
124
|
+
let low = 3;
|
|
125
|
+
let high = Math.min(completeRun.length - offset, MAX_PACKED_ROW_MEMBERS);
|
|
126
|
+
const largest = buildRow(kind, completeRun.slice(offset, offset + high));
|
|
127
|
+
if (packedDataBytes(largest) <= 1048576) {
|
|
128
|
+
out.push(largest);
|
|
129
|
+
offset += high;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
high -= 1;
|
|
133
|
+
let accepted = 0;
|
|
134
|
+
let acceptedRow;
|
|
135
|
+
while (low <= high) {
|
|
136
|
+
const middle = Math.floor((low + high) / 2);
|
|
137
|
+
const candidate = buildRow(kind, completeRun.slice(offset, offset + middle));
|
|
138
|
+
if (packedDataBytes(candidate) <= 1048576) {
|
|
139
|
+
accepted = middle;
|
|
140
|
+
acceptedRow = candidate;
|
|
141
|
+
low = middle + 1;
|
|
142
|
+
} else high = middle - 1;
|
|
143
|
+
}
|
|
144
|
+
if (accepted === 0) {
|
|
145
|
+
out.push(completeRun[offset]);
|
|
146
|
+
offset += 1;
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
/* v8 ignore next -- accepted is set only with its same-branch candidate. */
|
|
150
|
+
out.push(acceptedRow ?? malformed(kind, "bounded encoder lost its accepted row"));
|
|
151
|
+
offset += accepted;
|
|
152
|
+
}
|
|
153
|
+
out.push(...completeRun.slice(offset));
|
|
154
|
+
}
|
|
26
155
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* being migrated in place.
|
|
31
|
-
* @param path - the SQLite database file to open (created when absent).
|
|
32
|
-
* @param journalMode - validated journal pragma.
|
|
33
|
-
* @returns the open handle with pragmas applied and all three tables ensured.
|
|
156
|
+
* Pack eligible logical chunk runs into bounded schema-17 records.
|
|
157
|
+
* @param events - logical events in sequence order.
|
|
158
|
+
* @returns scalar and packed physical records in equivalent order.
|
|
34
159
|
*/
|
|
35
|
-
function
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
160
|
+
function packChunkRuns(events) {
|
|
161
|
+
const out = [];
|
|
162
|
+
let kind;
|
|
163
|
+
let run = [];
|
|
164
|
+
const flush = () => {
|
|
165
|
+
if (kind === void 0) out.push(...run);
|
|
166
|
+
else emitBoundedRun(out, kind, run);
|
|
167
|
+
kind = void 0;
|
|
168
|
+
run = [];
|
|
169
|
+
};
|
|
170
|
+
for (const event of events) {
|
|
171
|
+
const nextKind = classify(event);
|
|
172
|
+
if (nextKind === void 0) {
|
|
173
|
+
flush();
|
|
174
|
+
out.push(event);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const delta = event;
|
|
178
|
+
const previous = run.at(-1);
|
|
179
|
+
if (nextKind === kind && previous !== void 0 && continues(previous, delta, nextKind)) {
|
|
180
|
+
run.push(delta);
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
flush();
|
|
184
|
+
kind = nextKind;
|
|
185
|
+
run = [delta];
|
|
43
186
|
}
|
|
187
|
+
flush();
|
|
188
|
+
return out;
|
|
44
189
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
190
|
+
function malformed(tag, reason) {
|
|
191
|
+
throw new Error(`malformed ${tag} storage row: ${reason}`);
|
|
192
|
+
}
|
|
193
|
+
function validateRunData(tag, data, payloadKey, serializedBytes) {
|
|
194
|
+
if (typeof data.turn !== "number" || typeof data.step !== "number" || typeof data.index !== "number") malformed(tag, "turn/step/index must be numbers");
|
|
195
|
+
const payload = data[payloadKey];
|
|
196
|
+
if (!Array.isArray(payload) || payload.length < 3 || payload.length > 1024 || payload.some((member) => typeof member !== "string")) malformed(tag, `${payloadKey} must contain 3..${MAX_PACKED_ROW_MEMBERS} strings`);
|
|
197
|
+
const gaps = data.dt;
|
|
198
|
+
if (!Array.isArray(gaps) || gaps.some((gap) => !Number.isSafeInteger(gap))) malformed(tag, "dt must be an array of safe integers");
|
|
199
|
+
if (gaps.length !== payload.length - 1) malformed(tag, "dt length must match the member count");
|
|
200
|
+
if ((serializedBytes ?? Buffer.byteLength(JSON.stringify(data))) > 1048576) malformed(tag, `data exceeds ${MAX_PACKED_DATA_BYTES} UTF-8 bytes`);
|
|
201
|
+
return payload;
|
|
202
|
+
}
|
|
203
|
+
function validateRow(value, tag, serializedBytes) {
|
|
204
|
+
if (!hasExactKeys(value, [
|
|
205
|
+
"type",
|
|
206
|
+
"seq0",
|
|
207
|
+
"time0",
|
|
208
|
+
"data"
|
|
209
|
+
])) malformed(tag, "invalid envelope fields");
|
|
210
|
+
if (!Number.isSafeInteger(value.seq0) || value.seq0 < 0) malformed(tag, "seq0 must be non-negative");
|
|
211
|
+
if (!Number.isSafeInteger(value.time0)) malformed(tag, "time0 must be a safe integer");
|
|
212
|
+
const data = value.data;
|
|
213
|
+
if (!isRecord(data)) malformed(tag, "data must be an object");
|
|
214
|
+
let payload;
|
|
215
|
+
if (tag === "tool-call-chunks") {
|
|
216
|
+
const withName = hasExactKeys(data, [
|
|
217
|
+
"turn",
|
|
218
|
+
"step",
|
|
219
|
+
"index",
|
|
220
|
+
"id",
|
|
221
|
+
"name",
|
|
222
|
+
"dt",
|
|
223
|
+
"args"
|
|
224
|
+
]);
|
|
225
|
+
if (!withName && !hasExactKeys(data, [
|
|
226
|
+
"turn",
|
|
227
|
+
"step",
|
|
228
|
+
"index",
|
|
229
|
+
"id",
|
|
230
|
+
"dt",
|
|
231
|
+
"args"
|
|
232
|
+
])) malformed(tag, "invalid tool-call data fields");
|
|
233
|
+
if (typeof data.id !== "string" || withName && typeof data.name !== "string") malformed(tag, "id and optional name must be strings");
|
|
234
|
+
payload = validateRunData(tag, data, "args", serializedBytes);
|
|
235
|
+
} else {
|
|
236
|
+
if (!hasExactKeys(data, [
|
|
237
|
+
"turn",
|
|
238
|
+
"step",
|
|
239
|
+
"index",
|
|
240
|
+
"dt",
|
|
241
|
+
"texts"
|
|
242
|
+
])) malformed(tag, "invalid text data fields");
|
|
243
|
+
payload = validateRunData(tag, data, "texts", serializedBytes);
|
|
244
|
+
}
|
|
245
|
+
if (!Number.isSafeInteger(value.seq0 + payload.length - 1)) malformed(tag, "member seqs exceed safe integers");
|
|
246
|
+
let time = value.time0;
|
|
247
|
+
for (const gap of data.dt) {
|
|
248
|
+
time += gap;
|
|
249
|
+
if (!Number.isSafeInteger(time)) malformed(tag, "member times exceed safe integers");
|
|
250
|
+
}
|
|
251
|
+
return value;
|
|
252
|
+
}
|
|
253
|
+
function expandRow(row) {
|
|
254
|
+
const members = row.type === "tool-call-chunks" ? row.data.args : row.data.texts;
|
|
255
|
+
const events = [];
|
|
256
|
+
let time = row.time0;
|
|
257
|
+
for (let index = 0; index < members.length; index += 1) {
|
|
258
|
+
if (index > 0) time += row.data.dt[index - 1];
|
|
259
|
+
let chunk;
|
|
260
|
+
switch (row.type) {
|
|
261
|
+
case "text-chunks":
|
|
262
|
+
chunk = {
|
|
263
|
+
type: "text-delta",
|
|
264
|
+
index: row.data.index,
|
|
265
|
+
text: members[index]
|
|
266
|
+
};
|
|
267
|
+
break;
|
|
268
|
+
case "reasoning-chunks":
|
|
269
|
+
chunk = {
|
|
270
|
+
type: "reasoning-delta",
|
|
271
|
+
index: row.data.index,
|
|
272
|
+
text: members[index]
|
|
273
|
+
};
|
|
274
|
+
break;
|
|
275
|
+
case "tool-call-chunks":
|
|
276
|
+
chunk = {
|
|
277
|
+
type: "tool-call-delta",
|
|
278
|
+
index: row.data.index,
|
|
279
|
+
id: row.data.id,
|
|
280
|
+
...Object.hasOwn(row.data, "name") ? { name: row.data.name } : {},
|
|
281
|
+
argumentsDelta: members[index]
|
|
282
|
+
};
|
|
283
|
+
break;
|
|
93
284
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
285
|
+
events.push({
|
|
286
|
+
type: "assistant/chunk",
|
|
287
|
+
seq: row.seq0 + index,
|
|
288
|
+
time,
|
|
289
|
+
data: {
|
|
290
|
+
turn: row.data.turn,
|
|
291
|
+
step: row.data.step,
|
|
292
|
+
chunk
|
|
293
|
+
}
|
|
294
|
+
});
|
|
104
295
|
}
|
|
105
|
-
|
|
296
|
+
return events;
|
|
106
297
|
}
|
|
107
298
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* @
|
|
299
|
+
* Decode one packed row from its exact uncompressed data value. The byte bound
|
|
300
|
+
* rejects oversized input before JSON parsing and avoids serializing it again.
|
|
301
|
+
* @param tag - validated packed physical type.
|
|
302
|
+
* @param seq0 - first represented logical sequence number.
|
|
303
|
+
* @param time0 - first represented logical timestamp.
|
|
304
|
+
* @param serializedData - decoded SQLite data-column text.
|
|
305
|
+
* @returns the represented logical events.
|
|
111
306
|
*/
|
|
112
|
-
function
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
307
|
+
function decodeSerializedChunkRow(tag, seq0, time0, serializedData) {
|
|
308
|
+
const bytes = Buffer.byteLength(serializedData);
|
|
309
|
+
if (bytes > 1048576) malformed(tag, `data exceeds ${MAX_PACKED_DATA_BYTES} UTF-8 bytes`);
|
|
310
|
+
return expandRow(validateRow({
|
|
311
|
+
type: tag,
|
|
312
|
+
seq0,
|
|
313
|
+
time0,
|
|
314
|
+
data: JSON.parse(serializedData)
|
|
315
|
+
}, tag, bytes));
|
|
316
|
+
}
|
|
317
|
+
const MAX_SAFE_INTEGER = BigInt(Number.MAX_SAFE_INTEGER);
|
|
318
|
+
const MAX_ZIGZAG_INTEGER = MAX_SAFE_INTEGER * 2n;
|
|
319
|
+
const UTF8_DECODER = new TextDecoder("utf-8", { fatal: true });
|
|
320
|
+
const ZSTD_COMPRESSION_LEVEL = 3;
|
|
321
|
+
const PACKED_ROW_SENTINEL = 0;
|
|
322
|
+
const CHUNK_TAGS = [
|
|
323
|
+
"text-chunks",
|
|
324
|
+
"reasoning-chunks",
|
|
325
|
+
"tool-call-chunks"
|
|
326
|
+
];
|
|
327
|
+
function isChunkTag(value) {
|
|
328
|
+
return CHUNK_TAGS.includes(value);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Decode one physical SQLite row into its complete logical event span.
|
|
332
|
+
* @param row - detached SQLite event row.
|
|
333
|
+
* @returns every logical event represented by the row.
|
|
334
|
+
*/
|
|
335
|
+
function decodeRow(row) {
|
|
336
|
+
if (row.ignorable !== PACKED_ROW_SENTINEL) return [decodeScalarRow(row)];
|
|
337
|
+
if (!isChunkTag(row.type)) throw new Error(`malformed ${row.type} storage row: packed discriminator requires a chunk tag`);
|
|
338
|
+
if (row.source_event_seqs !== null || row.surface_op !== null) throw new Error(`malformed ${row.type} storage row: packed surface fields must be null`);
|
|
339
|
+
return decodeSerializedChunkRow(row.type, row.seq, row.time, decodeData(row.data, MAX_PACKED_DATA_BYTES));
|
|
125
340
|
}
|
|
126
341
|
/**
|
|
127
|
-
*
|
|
128
|
-
* @param
|
|
129
|
-
* @returns
|
|
130
|
-
* ({@link scanRows} treats that as a hole, not corruption, in the tail).
|
|
342
|
+
* Convert a storage record to SQLite column values.
|
|
343
|
+
* @param record - scalar event or packed chunk record.
|
|
344
|
+
* @returns column values for one physical insert.
|
|
131
345
|
*/
|
|
132
|
-
function
|
|
346
|
+
function bindRecord(record) {
|
|
347
|
+
if (isChunkRow(record)) return {
|
|
348
|
+
seq: record.seq0,
|
|
349
|
+
type: record.type,
|
|
350
|
+
time: record.time0,
|
|
351
|
+
data: encodeData(JSON.stringify(record.data)),
|
|
352
|
+
sourceEventSeqs: null,
|
|
353
|
+
surfaceOp: null,
|
|
354
|
+
ignorable: PACKED_ROW_SENTINEL
|
|
355
|
+
};
|
|
356
|
+
const event = record;
|
|
357
|
+
const surface = event;
|
|
358
|
+
return {
|
|
359
|
+
seq: event.seq,
|
|
360
|
+
type: event.type,
|
|
361
|
+
time: event.time,
|
|
362
|
+
data: encodeData(JSON.stringify(event.data)),
|
|
363
|
+
sourceEventSeqs: surface.sourceEventSeqs === void 0 ? null : encodeSourceEventSeqs(surface.sourceEventSeqs),
|
|
364
|
+
surfaceOp: surface.surfaceOp === void 0 ? null : JSON.stringify(surface.surfaceOp),
|
|
365
|
+
ignorable: event.ignorable === true ? 1 : null
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
function encodeData(serialized) {
|
|
369
|
+
const bytes = Buffer.from(serialized);
|
|
370
|
+
if (bytes.length < 4096) return serialized;
|
|
371
|
+
const compressed = zstdCompressSync(bytes, { params: { [constants.ZSTD_c_compressionLevel]: ZSTD_COMPRESSION_LEVEL } });
|
|
372
|
+
return compressed.length < bytes.length ? compressed : serialized;
|
|
373
|
+
}
|
|
374
|
+
function decodeData(value, maxOutputLength) {
|
|
375
|
+
if (typeof value === "string") return value;
|
|
376
|
+
const decoded = maxOutputLength === void 0 ? zstdDecompressSync(value) : zstdDecompressSync(value, { maxOutputLength });
|
|
377
|
+
return UTF8_DECODER.decode(decoded);
|
|
378
|
+
}
|
|
379
|
+
function encodeSourceEventSeqs(values) {
|
|
380
|
+
const bytes = [];
|
|
381
|
+
let previous = 0n;
|
|
382
|
+
for (let index = 0; index < values.length; index += 1) {
|
|
383
|
+
const sourceSeq = values[index];
|
|
384
|
+
if (!Number.isSafeInteger(sourceSeq) || sourceSeq < 0) throw new TypeError("sourceEventSeqs must contain non-negative safe integers");
|
|
385
|
+
const value = BigInt(sourceSeq);
|
|
386
|
+
appendVarint(bytes, index === 0 ? value : value >= previous ? (value - previous) * 2n : (previous - value) * 2n - 1n);
|
|
387
|
+
previous = value;
|
|
388
|
+
}
|
|
389
|
+
return Buffer.from(bytes);
|
|
390
|
+
}
|
|
391
|
+
function appendVarint(bytes, value) {
|
|
392
|
+
let remaining = value;
|
|
393
|
+
while (remaining >= 128n) {
|
|
394
|
+
bytes.push(Number(remaining & 127n) | 128);
|
|
395
|
+
remaining >>= 7n;
|
|
396
|
+
}
|
|
397
|
+
bytes.push(Number(remaining));
|
|
398
|
+
}
|
|
399
|
+
function decodeSourceEventSeqs(bytes) {
|
|
400
|
+
const values = [];
|
|
401
|
+
let previous = 0n;
|
|
402
|
+
let offset = 0;
|
|
403
|
+
while (offset < bytes.length) {
|
|
404
|
+
const first = values.length === 0;
|
|
405
|
+
const decoded = readVarint(bytes, offset, first ? MAX_SAFE_INTEGER : MAX_ZIGZAG_INTEGER);
|
|
406
|
+
offset = decoded.offset;
|
|
407
|
+
const delta = first ? decoded.value : (decoded.value & 1n) === 0n ? decoded.value / 2n : -((decoded.value + 1n) / 2n);
|
|
408
|
+
const value = first ? delta : previous + delta;
|
|
409
|
+
if (value < 0n || value > MAX_SAFE_INTEGER) throw new Error("malformed source_event_seqs storage value: decoded seq is out of range");
|
|
410
|
+
values.push(Number(value));
|
|
411
|
+
previous = value;
|
|
412
|
+
}
|
|
413
|
+
return values;
|
|
414
|
+
}
|
|
415
|
+
function readVarint(bytes, offset, limit) {
|
|
416
|
+
let value = 0n;
|
|
417
|
+
let shift = 0n;
|
|
418
|
+
while (offset < bytes.length) {
|
|
419
|
+
const byte = bytes[offset];
|
|
420
|
+
offset += 1;
|
|
421
|
+
value |= BigInt(byte & 127) << shift;
|
|
422
|
+
if ((byte & 128) === 0) {
|
|
423
|
+
if (shift > 0n && (byte & 127) === 0) throw new Error("malformed source_event_seqs storage value: non-canonical varint");
|
|
424
|
+
if (value > limit) throw new Error("malformed source_event_seqs storage value: varint is out of range");
|
|
425
|
+
return {
|
|
426
|
+
value,
|
|
427
|
+
offset
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
shift += 7n;
|
|
431
|
+
if (shift > 56n) throw new Error("malformed source_event_seqs storage value: varint is out of range");
|
|
432
|
+
}
|
|
433
|
+
throw new Error("malformed source_event_seqs storage value: truncated varint");
|
|
434
|
+
}
|
|
435
|
+
function isChunkRow(record) {
|
|
436
|
+
return isChunkTag(record.type) && "seq0" in record && !("seq" in record);
|
|
437
|
+
}
|
|
438
|
+
function decodeScalarRow(row) {
|
|
133
439
|
const surfaceFields = {
|
|
134
|
-
...row.source_event_seqs
|
|
135
|
-
...row.surface_op
|
|
440
|
+
...row.source_event_seqs === null ? {} : { sourceEventSeqs: decodeSourceEventSeqs(row.source_event_seqs) },
|
|
441
|
+
...row.surface_op === null ? {} : { surfaceOp: JSON.parse(row.surface_op) }
|
|
136
442
|
};
|
|
137
|
-
const ignorableField = row.ignorable === 1 ? { ignorable: true } : {};
|
|
138
443
|
return {
|
|
139
444
|
type: row.type,
|
|
140
445
|
seq: row.seq,
|
|
141
446
|
time: row.time,
|
|
142
|
-
data: JSON.parse(row.data),
|
|
447
|
+
data: JSON.parse(decodeData(row.data)),
|
|
143
448
|
...surfaceFields,
|
|
144
|
-
...
|
|
449
|
+
...row.ignorable === 1 ? { ignorable: true } : {}
|
|
145
450
|
};
|
|
146
451
|
}
|
|
147
452
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
* @
|
|
154
|
-
* @param base - the seq the first row is expected to carry; `0` for a whole
|
|
155
|
-
* log, the requested `fromSeq` for a suffix read (`loadStoredFrom`).
|
|
156
|
-
* @returns the preserved event prefix, plus `tornFrom` — the seq the physical
|
|
157
|
-
* delete starts at — when a torn tail exists.
|
|
453
|
+
* Validate and flatten physical rows into their logical prefix. A malformed
|
|
454
|
+
* row or logical gap is committed corruption when a later valid turn end
|
|
455
|
+
* exists; otherwise it starts a removable physical tail.
|
|
456
|
+
* @param rows - physical rows ordered by their first logical sequence.
|
|
457
|
+
* @param base - logical sequence expected from the first selected row.
|
|
458
|
+
* @returns the contiguous logical prefix and optional physical deletion base.
|
|
158
459
|
*/
|
|
159
460
|
function scanRows(rows, base = 0) {
|
|
160
|
-
|
|
461
|
+
let lastTurnEndRow = -1;
|
|
462
|
+
for (let index = rows.length - 1; index >= 0; index -= 1) try {
|
|
463
|
+
if (decodeRow(rows[index]).some((event) => event.type === "turn/end")) {
|
|
464
|
+
lastTurnEndRow = index;
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
} catch {}
|
|
468
|
+
const preserved = [];
|
|
469
|
+
let expected = base;
|
|
470
|
+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
|
|
471
|
+
const physical = rows[rowIndex];
|
|
472
|
+
let logicalEvents;
|
|
161
473
|
try {
|
|
474
|
+
logicalEvents = decodeRow(physical);
|
|
475
|
+
} catch {}
|
|
476
|
+
if (logicalEvents === void 0) {
|
|
477
|
+
if (rowIndex <= lastTurnEndRow) throw new Error(`corrupt session log: invalid committed physical row at seq ${physical.seq}`);
|
|
162
478
|
return {
|
|
163
|
-
|
|
164
|
-
|
|
479
|
+
preserved,
|
|
480
|
+
tornFrom: physical.seq
|
|
165
481
|
};
|
|
166
|
-
} catch {
|
|
167
|
-
return { ok: false };
|
|
168
482
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
for (let i = 0; i < rows.length; i++) {
|
|
177
|
-
const p = parsed[i];
|
|
178
|
-
if (!p?.ok || p.event === void 0) {
|
|
179
|
-
if (i <= lastTurnEnd) throw new Error(`corrupt session log: unparsable committed event at seq ${rows[i]?.seq}`);
|
|
180
|
-
break;
|
|
483
|
+
let contiguous = true;
|
|
484
|
+
for (const event of logicalEvents) {
|
|
485
|
+
if (event.seq !== expected) {
|
|
486
|
+
contiguous = false;
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
expected += 1;
|
|
181
490
|
}
|
|
182
|
-
if (
|
|
183
|
-
if (
|
|
184
|
-
|
|
491
|
+
if (!contiguous) {
|
|
492
|
+
if (rowIndex <= lastTurnEndRow) throw new Error(`corrupt session log: invalid committed physical row at seq ${physical.seq}`);
|
|
493
|
+
return {
|
|
494
|
+
preserved,
|
|
495
|
+
tornFrom: physical.seq
|
|
496
|
+
};
|
|
185
497
|
}
|
|
186
|
-
preserved.push(
|
|
498
|
+
preserved.push(...logicalEvents);
|
|
187
499
|
}
|
|
188
|
-
return preserved
|
|
189
|
-
preserved,
|
|
190
|
-
tornFrom: base + preserved.length
|
|
191
|
-
} : { preserved };
|
|
500
|
+
return { preserved };
|
|
192
501
|
}
|
|
193
502
|
//#endregion
|
|
194
|
-
//#region lib/types/
|
|
503
|
+
//#region lib/types/sql.js
|
|
195
504
|
/**
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
* {@link PersistenceCoordinator}. It has no independent per-session artifact,
|
|
199
|
-
* so its locator returns `undefined`.
|
|
200
|
-
* @module @nomix-ai/nomix-session-persistence-sqlite
|
|
505
|
+
* Closed, package-owned SQL resource loading for SQLite.
|
|
506
|
+
* @module @nomix-ai/nomix-session-persistence-sqlite/sql
|
|
201
507
|
*/
|
|
508
|
+
const cache = /* @__PURE__ */ new Map();
|
|
202
509
|
/**
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* ignorable marker is a nullable INTEGER column — `1` iff the envelope carries
|
|
207
|
-
* `ignorable: true`.
|
|
510
|
+
* Load an immutable SQL statement by closed resource name.
|
|
511
|
+
* @param name - package-owned resource basename.
|
|
512
|
+
* @returns the resource text.
|
|
208
513
|
*/
|
|
209
|
-
function
|
|
210
|
-
const
|
|
211
|
-
return
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
];
|
|
216
|
-
}
|
|
217
|
-
/** Build the source-qualified revision shared by full and lightweight reads. */
|
|
218
|
-
function sqliteRevision(storeIdentity, row) {
|
|
219
|
-
return SessionPersistenceRevision(`${storeIdentity}:incarnation:${row.incarnation}:revision:${row.revision}`);
|
|
514
|
+
function sql(name) {
|
|
515
|
+
const cached = cache.get(name);
|
|
516
|
+
if (cached !== void 0) return cached;
|
|
517
|
+
const statement = readFileSync(fileURLToPath(new URL(`../resources/sql/${name}.sql`, import.meta.url)), "utf8");
|
|
518
|
+
cache.set(name, statement);
|
|
519
|
+
return statement;
|
|
220
520
|
}
|
|
521
|
+
//#endregion
|
|
522
|
+
//#region lib/types/schema.js
|
|
221
523
|
/**
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* `DatabaseSync` reopens by path, so this does not protect confidentiality or
|
|
225
|
-
* integrity when another principal can replace the database entry in its parent
|
|
226
|
-
* directory.
|
|
524
|
+
* SQLite schema ownership and durable-row validation.
|
|
525
|
+
* @module @nomix-ai/nomix-session-persistence-sqlite/schema
|
|
227
526
|
*/
|
|
228
|
-
|
|
527
|
+
/** Current physical-record schema with packed and compressed event rows. */
|
|
528
|
+
const SCHEMA_VERSION = 17;
|
|
529
|
+
/** Application id reserved for Nomix Harness SQLite session databases. */
|
|
530
|
+
const SESSION_PERSISTENCE_SQLITE_APPLICATION_ID = 1146308688;
|
|
531
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
|
|
532
|
+
const JOURNAL_BUSY_RETRY_INTERVAL_MS = 10;
|
|
533
|
+
/**
|
|
534
|
+
* Open and validate a SQLite session database.
|
|
535
|
+
* @param Database - lazily imported Node SQLite constructor.
|
|
536
|
+
* @param path - SQLite path, including `:memory:`.
|
|
537
|
+
* @param journalMode - validated journal pragma.
|
|
538
|
+
* @param busyTimeoutMs - validated maximum wait for a competing SQLite lock.
|
|
539
|
+
* @returns the configured database handle.
|
|
540
|
+
* @throws when connection settings, schema ownership, or SQLite setup cannot be validated.
|
|
541
|
+
*/
|
|
542
|
+
async function openDatabase(Database, path, journalMode, busyTimeoutMs) {
|
|
543
|
+
const deadline = performance.now() + busyTimeoutMs;
|
|
544
|
+
const db = new Database(path, { timeout: busyTimeoutMs });
|
|
229
545
|
try {
|
|
230
|
-
|
|
546
|
+
configureConnectionSecurity(db, path);
|
|
547
|
+
configureDatabase(Database, db, path);
|
|
548
|
+
await selectJournalMode(db, path, journalMode, deadline);
|
|
549
|
+
configureDurability(db, path);
|
|
550
|
+
return db;
|
|
231
551
|
} catch (error) {
|
|
232
|
-
|
|
552
|
+
db.close();
|
|
553
|
+
throw error;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
function configureConnectionSecurity(db, path) {
|
|
557
|
+
db.exec(sql("trusted-schema-off"));
|
|
558
|
+
const trustedSchema = integerField(db.prepare(sql("select-trusted-schema")).get(), "trusted_schema");
|
|
559
|
+
/* v8 ignore next 3 -- supported SQLite versions return the fixed setting. */
|
|
560
|
+
if (trustedSchema !== 0) throw new Error(`session database at "${path}" retained trusted_schema=${trustedSchema}, expected 0`);
|
|
561
|
+
db.exec(sql("mmap-off"));
|
|
562
|
+
if (path === ":memory:") return;
|
|
563
|
+
const mmapSize = integerField(db.prepare(sql("select-mmap-size")).get(), "mmap_size");
|
|
564
|
+
/* v8 ignore next 3 -- supported file-backed SQLite connections return the fixed setting. */
|
|
565
|
+
if (mmapSize !== 0) throw new Error(`session database at "${path}" retained mmap_size=${mmapSize}, expected 0`);
|
|
566
|
+
}
|
|
567
|
+
function configureDatabase(Database, db, path) {
|
|
568
|
+
db.exec(sql("foreign-keys-on"));
|
|
569
|
+
let began = false;
|
|
570
|
+
try {
|
|
571
|
+
db.exec(sql("begin-immediate"));
|
|
572
|
+
began = true;
|
|
573
|
+
const onDisk = integerField(db.prepare(sql("select-user-version")).get(), "user_version");
|
|
574
|
+
const applicationId = integerField(db.prepare(sql("select-application-id")).get(), "application_id");
|
|
575
|
+
const userObjectCount = integerField(db.prepare(sql("select-user-object-count")).get(), "count");
|
|
576
|
+
if (onDisk === 0 && (applicationId !== 0 || userObjectCount > 0)) throw new Error(`session database at "${path}" has an unversioned schema or application identity`);
|
|
577
|
+
if (onDisk !== 0 && onDisk !== 17) throw new Error(`session database at "${path}" has schema version ${onDisk}, incompatible with this build (17)`);
|
|
578
|
+
if (onDisk !== 0 && applicationId !== 1146308688) throw new Error(`session database at "${path}" has application id ${applicationId}, expected ${SESSION_PERSISTENCE_SQLITE_APPLICATION_ID}`);
|
|
579
|
+
if (onDisk === 0) initializeDatabase(db);
|
|
580
|
+
validateRequiredSchema(Database, db, path);
|
|
581
|
+
db.exec(sql("commit"));
|
|
582
|
+
began = false;
|
|
583
|
+
} catch (error) {
|
|
584
|
+
/* v8 ignore else -- a failed begin leaves no transaction to roll back. */
|
|
585
|
+
if (began)
|
|
586
|
+
/* v8 ignore next 5 -- retain the original ownership failure if rollback fails too. */
|
|
587
|
+
try {
|
|
588
|
+
db.exec(sql("rollback"));
|
|
589
|
+
} catch {}
|
|
590
|
+
throw error;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
async function selectJournalMode(db, path, journalMode, deadline) {
|
|
594
|
+
let result;
|
|
595
|
+
while (true) try {
|
|
596
|
+
result = db.prepare(sql(journalResource(journalMode))).get();
|
|
597
|
+
break;
|
|
598
|
+
} catch (error) {
|
|
599
|
+
const remainingMs = Math.max(0, Math.ceil(deadline - performance.now()));
|
|
600
|
+
if (!isSqliteBusy(error) || remainingMs === 0) throw error;
|
|
601
|
+
await setTimeout(Math.min(JOURNAL_BUSY_RETRY_INTERVAL_MS, remainingMs));
|
|
602
|
+
if (performance.now() >= deadline) throw error;
|
|
603
|
+
}
|
|
604
|
+
const selected = stringField(result, "journal_mode").toLowerCase();
|
|
605
|
+
const expected = path === ":memory:" ? "memory" : journalMode;
|
|
606
|
+
/* v8 ignore next 3 -- SQLite returns the selected mode from these fixed, valid pragmas. */
|
|
607
|
+
if (selected !== expected) throw new Error(`session database at "${path}" selected journal mode ${selected}, expected ${expected}`);
|
|
608
|
+
}
|
|
609
|
+
function configureDurability(db, path) {
|
|
610
|
+
db.exec(sql("synchronous-full"));
|
|
611
|
+
const synchronous = integerField(db.prepare(sql("select-synchronous")).get(), "synchronous");
|
|
612
|
+
/* v8 ignore next 3 -- supported SQLite versions return the fixed setting. */
|
|
613
|
+
if (synchronous !== 2) throw new Error(`session database at "${path}" retained synchronous=${synchronous}, expected FULL (2)`);
|
|
614
|
+
}
|
|
615
|
+
function isSqliteBusy(error) {
|
|
616
|
+
return typeof error === "object" && error !== null && Reflect.get(error, "errcode") === 5;
|
|
617
|
+
}
|
|
618
|
+
function journalResource(mode) {
|
|
619
|
+
switch (mode) {
|
|
620
|
+
case "wal": return "journal-mode-wal";
|
|
621
|
+
case "delete": return "journal-mode-delete";
|
|
622
|
+
case "truncate": return "journal-mode-truncate";
|
|
623
|
+
case "persist": return "journal-mode-persist";
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
function initializeDatabase(db) {
|
|
627
|
+
db.exec(sql("schema"));
|
|
628
|
+
db.prepare(sql("insert-persistence-state")).run(randomUUID());
|
|
629
|
+
db.exec(sql("set-application-id"));
|
|
630
|
+
db.exec(sql("set-user-version-17"));
|
|
631
|
+
}
|
|
632
|
+
let canonicalSchema;
|
|
633
|
+
function expectedSchema(Database) {
|
|
634
|
+
if (canonicalSchema !== void 0) return canonicalSchema;
|
|
635
|
+
const reference = new Database(":memory:");
|
|
636
|
+
try {
|
|
637
|
+
reference.exec(sql("foreign-keys-on"));
|
|
638
|
+
reference.exec(sql("schema"));
|
|
639
|
+
canonicalSchema = schemaObjects(reference);
|
|
640
|
+
return canonicalSchema;
|
|
641
|
+
} finally {
|
|
642
|
+
reference.close();
|
|
233
643
|
}
|
|
234
644
|
}
|
|
645
|
+
function schemaObjects(db) {
|
|
646
|
+
return db.prepare(sql("select-schema-objects")).all().map((value) => {
|
|
647
|
+
const row = record(value, "schema object");
|
|
648
|
+
return {
|
|
649
|
+
type: stringField(row, "type"),
|
|
650
|
+
name: stringField(row, "name"),
|
|
651
|
+
tbl_name: stringField(row, "tbl_name"),
|
|
652
|
+
sql: normalizeSql(stringField(row, "sql"))
|
|
653
|
+
};
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
function normalizeSql(value) {
|
|
657
|
+
return value.replaceAll(/\s+/gu, " ").trim();
|
|
658
|
+
}
|
|
659
|
+
function validateRequiredSchema(Database, db, path) {
|
|
660
|
+
if (JSON.stringify(schemaObjects(db)) !== JSON.stringify(expectedSchema(Database))) throw new Error(`session database at "${path}" does not contain the required schema objects`);
|
|
661
|
+
}
|
|
235
662
|
/**
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
663
|
+
* Recheck schema ownership inside the caller's mutation transaction.
|
|
664
|
+
* @param Database - constructor used to validate the canonical schema.
|
|
665
|
+
* @param db - open owned database with an active immediate transaction.
|
|
666
|
+
* @param path - database location used in ownership diagnostics.
|
|
667
|
+
* @throws when another writer changed the application identity, schema, or version.
|
|
239
668
|
*/
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
669
|
+
function validateSchemaForMutation(Database, db, path) {
|
|
670
|
+
const version = integerField(db.prepare(sql("select-user-version")).get(), "user_version");
|
|
671
|
+
const applicationId = integerField(db.prepare(sql("select-application-id")).get(), "application_id");
|
|
672
|
+
if (applicationId !== 1146308688) throw new Error(`session database application id changed before mutation (expected ${SESSION_PERSISTENCE_SQLITE_APPLICATION_ID}, got ${applicationId})`);
|
|
673
|
+
validateRequiredSchema(Database, db, path);
|
|
674
|
+
if (version !== 17) throw new Error(`session database schema changed before mutation (expected 17, got ${version})`);
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Decode and validate one durable session row.
|
|
678
|
+
* @param value - value returned by SQLite.
|
|
679
|
+
* @returns a validated session row.
|
|
680
|
+
*/
|
|
681
|
+
function decodeSessionRow(value) {
|
|
682
|
+
const row = record(value, "stored session metadata");
|
|
683
|
+
const id = nonemptyStringField(row, "id");
|
|
684
|
+
const version = safeIntegerField(row, "version");
|
|
685
|
+
const cwd = nullableStringField(row, "cwd");
|
|
686
|
+
if (cwd !== null && !isAbsolute(cwd)) throw new Error("stored session cwd must be absolute");
|
|
687
|
+
const parent = nullableStringField(row, "parent_session");
|
|
688
|
+
const origin = nullableStringField(row, "origin");
|
|
689
|
+
if (origin !== null && origin !== "subagent") throw new Error("stored session origin must be subagent or null");
|
|
690
|
+
const incarnation = nonemptyStringField(row, "incarnation");
|
|
691
|
+
if (!UUID.test(incarnation)) throw new Error("stored session incarnation must be a UUID");
|
|
692
|
+
return {
|
|
693
|
+
id,
|
|
694
|
+
version,
|
|
695
|
+
created_at: nonnegativeSafeIntegerField(row, "created_at"),
|
|
696
|
+
cwd,
|
|
697
|
+
parent_session: parent,
|
|
698
|
+
seed_length: nullableNonnegativeSafeIntegerField(row, "seed_length"),
|
|
699
|
+
origin,
|
|
700
|
+
delegation_depth: nullableNonnegativeSafeIntegerField(row, "delegation_depth"),
|
|
701
|
+
agent_preset: nullableStringField(row, "agent_preset"),
|
|
702
|
+
incarnation,
|
|
703
|
+
revision: nonnegativeSafeIntegerField(row, "revision")
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Decode and validate one durable event row before JSON interpretation.
|
|
708
|
+
* @param value - value returned by SQLite.
|
|
709
|
+
* @returns a validated physical event row.
|
|
710
|
+
*/
|
|
711
|
+
function decodeEventRow(value) {
|
|
712
|
+
const row = record(value, "stored event");
|
|
713
|
+
const ignorable = nullableSafeIntegerField(row, "ignorable");
|
|
714
|
+
if (ignorable !== null && ignorable !== 0 && ignorable !== 1) throw new Error("stored event ignorable must be 0, 1, or null");
|
|
715
|
+
return {
|
|
716
|
+
seq: nonnegativeSafeIntegerField(row, "seq"),
|
|
717
|
+
type: nonemptyStringField(row, "type"),
|
|
718
|
+
time: safeIntegerField(row, "time"),
|
|
719
|
+
data: stringOrBlobField(row, "data"),
|
|
720
|
+
source_event_seqs: nullableBlobField(row, "source_event_seqs"),
|
|
721
|
+
surface_op: nullableStringField(row, "surface_op"),
|
|
722
|
+
ignorable
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Validate the singleton identity read from durable storage.
|
|
727
|
+
* @param value - value returned by SQLite.
|
|
728
|
+
* @returns the UUID store identity.
|
|
729
|
+
*/
|
|
730
|
+
function decodeStoreIdentity(value) {
|
|
731
|
+
const identity = nonemptyStringField(value, "store_id");
|
|
732
|
+
if (!UUID.test(identity)) throw new Error("stored store_id must be a UUID");
|
|
733
|
+
return identity;
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Reconstruct an immutable session header from a validated metadata row.
|
|
737
|
+
* @param row - validated stored metadata row.
|
|
738
|
+
* @returns the session header.
|
|
739
|
+
*/
|
|
740
|
+
function rowToMeta(row) {
|
|
741
|
+
return {
|
|
742
|
+
version: row.version,
|
|
743
|
+
id: SessionId(row.id),
|
|
744
|
+
createdAt: row.created_at,
|
|
745
|
+
...row.cwd === null ? {} : { cwd: row.cwd },
|
|
746
|
+
...row.parent_session === null ? {} : { parentSession: SessionId(row.parent_session) },
|
|
747
|
+
...row.seed_length === null ? {} : { seedLength: row.seed_length },
|
|
748
|
+
...row.origin === null ? {} : { origin: row.origin },
|
|
749
|
+
...row.delegation_depth === null ? {} : { delegationDepth: row.delegation_depth },
|
|
750
|
+
...row.agent_preset === null ? {} : { agentPreset: row.agent_preset }
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
function record(value, label) {
|
|
754
|
+
if (typeof value !== "object" || value === null) throw new Error(`${label} must be an object`);
|
|
755
|
+
return value;
|
|
756
|
+
}
|
|
757
|
+
function stringField(value, key) {
|
|
758
|
+
const field = record(value, "SQLite row")[key];
|
|
759
|
+
if (typeof field !== "string") throw new Error(`stored ${key} must be a string`);
|
|
760
|
+
return field;
|
|
761
|
+
}
|
|
762
|
+
function nonemptyStringField(value, key) {
|
|
763
|
+
const field = stringField(value, key);
|
|
764
|
+
if (field.length === 0) throw new Error(`stored ${key} must not be empty`);
|
|
765
|
+
return field;
|
|
766
|
+
}
|
|
767
|
+
function nullableStringField(value, key) {
|
|
768
|
+
const field = record(value, "SQLite row")[key];
|
|
769
|
+
if (field === null) return null;
|
|
770
|
+
if (typeof field !== "string") throw new Error(`stored ${key} must be a string or null`);
|
|
771
|
+
return field;
|
|
772
|
+
}
|
|
773
|
+
function stringOrBlobField(value, key) {
|
|
774
|
+
const field = record(value, "SQLite row")[key];
|
|
775
|
+
if (typeof field === "string" || field instanceof Uint8Array) return field;
|
|
776
|
+
throw new Error(`stored ${key} must be a string or blob`);
|
|
777
|
+
}
|
|
778
|
+
function nullableBlobField(value, key) {
|
|
779
|
+
const field = record(value, "SQLite row")[key];
|
|
780
|
+
if (field === null || field instanceof Uint8Array) return field;
|
|
781
|
+
throw new Error(`stored ${key} must be a blob or null`);
|
|
782
|
+
}
|
|
783
|
+
function integerField(value, key) {
|
|
784
|
+
const field = record(value, "SQLite row")[key];
|
|
785
|
+
if (!Number.isSafeInteger(field)) throw new Error(`stored ${key} must be a safe integer`);
|
|
786
|
+
return field;
|
|
787
|
+
}
|
|
788
|
+
function safeIntegerField(value, key) {
|
|
789
|
+
return integerField(value, key);
|
|
790
|
+
}
|
|
791
|
+
function nonnegativeSafeIntegerField(value, key) {
|
|
792
|
+
const field = integerField(value, key);
|
|
793
|
+
if (field < 0) throw new Error(`stored ${key} must be non-negative`);
|
|
794
|
+
return field;
|
|
795
|
+
}
|
|
796
|
+
function nullableSafeIntegerField(value, key) {
|
|
797
|
+
const field = record(value, "SQLite row")[key];
|
|
798
|
+
if (field === null) return null;
|
|
799
|
+
if (!Number.isSafeInteger(field)) throw new Error(`stored ${key} must be a safe integer or null`);
|
|
800
|
+
return field;
|
|
801
|
+
}
|
|
802
|
+
function nullableNonnegativeSafeIntegerField(value, key) {
|
|
803
|
+
const field = nullableSafeIntegerField(value, key);
|
|
804
|
+
if (field !== null && field < 0) throw new Error(`stored ${key} must be non-negative or null`);
|
|
805
|
+
return field;
|
|
806
|
+
}
|
|
807
|
+
//#endregion
|
|
808
|
+
//#region lib/types/store.js
|
|
809
|
+
/**
|
|
810
|
+
* SQLite storage primitives: transactional append-batch packing, physical
|
|
811
|
+
* reads, schema validation, revisions, repair, and lifecycle closure.
|
|
812
|
+
* @module @nomix-ai/nomix-session-persistence-sqlite/store
|
|
813
|
+
*/
|
|
814
|
+
/** SQLite implementation of the coordinator's physical backend hooks. */
|
|
815
|
+
var SqliteStore = class {
|
|
816
|
+
options;
|
|
260
817
|
name = "session-persistence-sqlite";
|
|
261
818
|
db;
|
|
819
|
+
databaseConstructor;
|
|
262
820
|
storeIdentity;
|
|
821
|
+
databasePath;
|
|
822
|
+
opened = false;
|
|
823
|
+
pathReady;
|
|
263
824
|
ready;
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
});
|
|
825
|
+
constructor(options) {
|
|
826
|
+
this.options = options;
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Validate filesystem ownership without importing or opening Node SQLite.
|
|
830
|
+
* @returns settlement of the store's one path-validation operation.
|
|
831
|
+
*/
|
|
832
|
+
validatePath() {
|
|
833
|
+
this.pathReady ??= this.preparePath(this.options.path);
|
|
834
|
+
return this.pathReady;
|
|
275
835
|
}
|
|
276
|
-
|
|
836
|
+
/**
|
|
837
|
+
* Lazily open and validate the database on first persistence use.
|
|
838
|
+
* @returns settlement of the store's one database-open operation.
|
|
839
|
+
*/
|
|
840
|
+
open() {
|
|
841
|
+
this.ready ??= this.openDb();
|
|
842
|
+
return this.ready;
|
|
843
|
+
}
|
|
844
|
+
async preparePath(path) {
|
|
277
845
|
const actual = path === ":memory:" ? path : resolve(path);
|
|
278
846
|
if (actual !== ":memory:") {
|
|
279
847
|
await mkdir(dirname(actual), {
|
|
280
848
|
recursive: true,
|
|
281
849
|
mode: 448
|
|
282
850
|
});
|
|
283
|
-
await
|
|
851
|
+
await validateParentDirectory(dirname(actual));
|
|
852
|
+
await validateDatabaseFileIfPresent(actual);
|
|
284
853
|
}
|
|
285
|
-
this.
|
|
854
|
+
this.databasePath = actual;
|
|
855
|
+
}
|
|
856
|
+
async openDb() {
|
|
857
|
+
await this.validatePath();
|
|
858
|
+
if (this.databasePath !== ":memory:") {
|
|
859
|
+
await createDatabaseFile(this.databasePath);
|
|
860
|
+
await validateDatabaseFile(this.databasePath);
|
|
861
|
+
}
|
|
862
|
+
const { DatabaseSync } = await loadNodeSqlite();
|
|
863
|
+
this.databaseConstructor = DatabaseSync;
|
|
864
|
+
this.db = await openDatabase(DatabaseSync, this.databasePath, this.options.journalMode, this.options.busyTimeoutMs);
|
|
286
865
|
try {
|
|
287
|
-
const row = this.db.prepare("
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
866
|
+
const row = this.db.prepare(sql("select-store-id")).get();
|
|
867
|
+
if (row === void 0) throw new Error(`session database at "${this.databasePath}" has no valid store identity`);
|
|
868
|
+
let storeId;
|
|
869
|
+
try {
|
|
870
|
+
storeId = decodeStoreIdentity(row);
|
|
871
|
+
} catch (error) {
|
|
872
|
+
throw new Error(`session database at "${this.databasePath}" has no valid store identity`, { cause: error });
|
|
873
|
+
}
|
|
874
|
+
if (this.databasePath === ":memory:") this.storeIdentity = `memory:store:${storeId}`;
|
|
875
|
+
else {
|
|
876
|
+
const identity = statSync(this.databasePath, { bigint: true });
|
|
877
|
+
this.storeIdentity = `file:${identity.dev}:${identity.ino}:${identity.birthtimeNs}:store:${storeId}`;
|
|
878
|
+
}
|
|
879
|
+
this.opened = true;
|
|
295
880
|
} catch (error) {
|
|
296
881
|
this.db.close();
|
|
297
882
|
throw error;
|
|
298
883
|
}
|
|
299
884
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
/** Read a stored prefix by id (ids are globally unique — no scope to scan). */
|
|
321
|
-
loadStored(id, signal) {
|
|
322
|
-
return this.readPrefix(id, signal);
|
|
885
|
+
async loadStored(id, signal) {
|
|
886
|
+
await this.observe(signal);
|
|
887
|
+
const snapshot = this.readTransaction(() => {
|
|
888
|
+
const row = this.rowFor(id);
|
|
889
|
+
if (row === void 0) return void 0;
|
|
890
|
+
return {
|
|
891
|
+
row,
|
|
892
|
+
eventRows: this.db.prepare(sql("select-events")).all(id).map(decodeEventRow)
|
|
893
|
+
};
|
|
894
|
+
});
|
|
895
|
+
signal?.throwIfAborted();
|
|
896
|
+
if (snapshot === void 0) return void 0;
|
|
897
|
+
const scanned = scanRows(snapshot.eventRows);
|
|
898
|
+
return {
|
|
899
|
+
meta: rowToMeta(snapshot.row),
|
|
900
|
+
events: scanned.preserved,
|
|
901
|
+
revision: sqliteRevision(this.storeIdentity, snapshot.row),
|
|
902
|
+
...scanned.tornFrom === void 0 ? {} : { tornMarker: scanned.tornFrom }
|
|
903
|
+
};
|
|
323
904
|
}
|
|
324
|
-
/** Read one row's revision without loading its events. */
|
|
325
905
|
async readStoredRevision(id, signal) {
|
|
326
|
-
signal
|
|
327
|
-
await this.ready;
|
|
328
|
-
signal?.throwIfAborted();
|
|
906
|
+
await this.observe(signal);
|
|
329
907
|
const row = this.rowFor(id);
|
|
908
|
+
signal?.throwIfAborted();
|
|
330
909
|
return row === void 0 ? void 0 : sqliteRevision(this.storeIdentity, row);
|
|
331
910
|
}
|
|
332
|
-
/**
|
|
333
|
-
* Seek-capable suffix read: SQL selects `seq >= fromSeq` directly, so the
|
|
334
|
-
* read scales with the suffix, not the log. Torn rows past the preserved
|
|
335
|
-
* region are dropped, never repaired (non-mutating read).
|
|
336
|
-
*/
|
|
337
911
|
async loadStoredFrom(id, fromSeq, signal) {
|
|
338
|
-
signal
|
|
339
|
-
|
|
340
|
-
signal?.throwIfAborted();
|
|
341
|
-
const row = this.rowFor(id);
|
|
342
|
-
if (row === void 0) return void 0;
|
|
343
|
-
const meta = rowToMeta(row);
|
|
344
|
-
const eventRows = this.db.prepare("SELECT seq, type, time, data, source_event_seqs, surface_op, ignorable FROM events WHERE session_id = ? AND seq >= ? ORDER BY seq").all(id, fromSeq);
|
|
345
|
-
signal?.throwIfAborted();
|
|
346
|
-
const { preserved } = scanRows(eventRows, fromSeq);
|
|
347
|
-
return {
|
|
348
|
-
meta,
|
|
349
|
-
events: preserved
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Read a session's row + ordered events into a {@link StoredPrefix}. The
|
|
354
|
-
* torn-tail marker is the seq from which a never-committed tail must be deleted
|
|
355
|
-
* (`scanRows` already returns it as `number | undefined`).
|
|
356
|
-
*/
|
|
357
|
-
async readPrefix(id, signal) {
|
|
358
|
-
signal?.throwIfAborted();
|
|
359
|
-
await this.ready;
|
|
360
|
-
signal?.throwIfAborted();
|
|
361
|
-
this.db.exec("BEGIN");
|
|
362
|
-
let snapshot;
|
|
363
|
-
try {
|
|
912
|
+
await this.observe(signal);
|
|
913
|
+
const snapshot = this.readTransaction(() => {
|
|
364
914
|
const row = this.rowFor(id);
|
|
365
|
-
if (row
|
|
915
|
+
if (row === void 0) return void 0;
|
|
916
|
+
return {
|
|
366
917
|
row,
|
|
367
|
-
|
|
918
|
+
...this.physicalSpanFrom(id, fromSeq)
|
|
368
919
|
};
|
|
369
|
-
|
|
370
|
-
} catch (error) {
|
|
371
|
-
/* v8 ignore start -- synchronous read failures only need transaction cleanup before propagation. */
|
|
372
|
-
this.db.exec("ROLLBACK");
|
|
373
|
-
throw error;
|
|
374
|
-
}
|
|
920
|
+
});
|
|
375
921
|
signal?.throwIfAborted();
|
|
376
922
|
if (snapshot === void 0) return void 0;
|
|
377
|
-
const {
|
|
378
|
-
const { preserved, tornFrom } = scanRows(eventRows);
|
|
923
|
+
const { preserved } = scanRows(snapshot.eventRows, snapshot.base);
|
|
379
924
|
return {
|
|
380
|
-
meta: rowToMeta(row),
|
|
381
|
-
events: preserved
|
|
382
|
-
revision: sqliteRevision(this.storeIdentity, row),
|
|
383
|
-
...tornFrom !== void 0 ? { tornMarker: tornFrom } : {}
|
|
925
|
+
meta: rowToMeta(snapshot.row),
|
|
926
|
+
events: preserved.filter((event) => event.seq >= fromSeq)
|
|
384
927
|
};
|
|
385
928
|
}
|
|
386
|
-
/**
|
|
387
|
-
* Durably append a batch in ONE transaction: materialize the sessions row (if
|
|
388
|
-
* lazy) and INSERT every event, or roll back entirely. The transaction is the
|
|
389
|
-
* atomicity + durability boundary, so a mid-batch failure (a UNIQUE violation
|
|
390
|
-
* on a duplicated seq) leaves the stored log untouched.
|
|
391
|
-
*/
|
|
392
929
|
async appendBatch(meta, events, isMaterialized) {
|
|
393
|
-
await this.
|
|
394
|
-
|
|
395
|
-
this.db.exec("
|
|
930
|
+
await this.open();
|
|
931
|
+
if (events.length === 0) return;
|
|
932
|
+
this.db.exec(sql("begin-immediate"));
|
|
396
933
|
try {
|
|
934
|
+
validateSchemaForMutation(this.databaseConstructor, this.db, this.databasePath);
|
|
935
|
+
const tailRows = this.tailRows(meta.id);
|
|
936
|
+
const currentLast = this.logicalLastEvent(meta.id, tailRows);
|
|
937
|
+
const expected = currentLast === void 0 ? 0 : currentLast.seq + 1;
|
|
938
|
+
const first = events[0];
|
|
939
|
+
if (first.seq !== expected) throw new Error(`session ${meta.id} append starts at seq ${first.seq}, stored next seq is ${expected}`);
|
|
397
940
|
if (!isMaterialized) this.writeRow(meta);
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
this.db.prepare("UPDATE sessions SET revision = revision + 1 WHERE id = ?").run(meta.id);
|
|
403
|
-
this.db.exec("COMMIT");
|
|
941
|
+
const insert = this.insertStatement();
|
|
942
|
+
for (const record of packChunkRuns(events)) this.insertRecord(insert, meta.id, bindRecord(record));
|
|
943
|
+
this.incrementRevision(meta.id);
|
|
944
|
+
this.db.exec(sql("commit"));
|
|
404
945
|
} catch (error) {
|
|
405
|
-
this.
|
|
406
|
-
throw error;
|
|
946
|
+
this.rollback(error, "append");
|
|
407
947
|
}
|
|
408
948
|
}
|
|
409
|
-
/**
|
|
410
|
-
* Make a crash repair durable in ONE transaction: DELETE the torn tail (from
|
|
411
|
-
* `tornMarker`) and INSERT the synthetic `closers`. After COMMIT the stored rows
|
|
412
|
-
* == the balanced log.
|
|
413
|
-
*/
|
|
414
949
|
async commitRepair(meta, tornMarker, closers) {
|
|
415
|
-
await this.
|
|
416
|
-
|
|
950
|
+
await this.open();
|
|
951
|
+
if (tornMarker === void 0 && closers.length === 0) return;
|
|
952
|
+
this.db.exec(sql("begin-immediate"));
|
|
417
953
|
try {
|
|
418
|
-
|
|
954
|
+
validateSchemaForMutation(this.databaseConstructor, this.db, this.databasePath);
|
|
955
|
+
if (this.rowFor(meta.id) === void 0) throw new Error(`session ${meta.id} metadata row is missing`);
|
|
956
|
+
const current = scanRows(this.db.prepare(sql("select-events")).all(meta.id).map(decodeEventRow));
|
|
957
|
+
if (tornMarker !== void 0) {
|
|
958
|
+
if (current.tornFrom !== tornMarker) throw new Error(`session ${meta.id} repair is stale: physical tail no longer starts at seq ${tornMarker}`);
|
|
959
|
+
this.db.prepare(sql("delete-events-from")).run(meta.id, tornMarker);
|
|
960
|
+
} else if (current.tornFrom !== void 0) throw new Error(`session ${meta.id} repair omitted current torn tail at seq ${current.tornFrom}`);
|
|
419
961
|
if (closers.length > 0) {
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
}
|
|
962
|
+
const expected = current.preserved.at(-1)?.seq === void 0 ? 0 : current.preserved.at(-1).seq + 1;
|
|
963
|
+
if (closers[0]?.seq !== expected) throw new Error(`session ${meta.id} repair is stale: closer starts at seq ${closers[0]?.seq}, stored next seq is ${expected}`);
|
|
964
|
+
const insert = this.insertStatement();
|
|
965
|
+
for (const closer of closers) this.insertRecord(insert, meta.id, bindRecord(closer));
|
|
425
966
|
}
|
|
426
|
-
|
|
427
|
-
this.db.exec("
|
|
967
|
+
this.incrementRevision(meta.id);
|
|
968
|
+
this.db.exec(sql("commit"));
|
|
428
969
|
} catch (error) {
|
|
429
|
-
|
|
430
|
-
this.db.exec("ROLLBACK");
|
|
431
|
-
throw error;
|
|
970
|
+
this.rollback(error, "repair");
|
|
432
971
|
}
|
|
433
972
|
}
|
|
434
|
-
/** List all materialized sessions' metadata (every row is a materialized session). */
|
|
435
973
|
async list(signal) {
|
|
436
|
-
signal
|
|
437
|
-
|
|
438
|
-
signal?.throwIfAborted();
|
|
439
|
-
const rows = this.db.prepare("SELECT * FROM sessions").all();
|
|
974
|
+
await this.observe(signal);
|
|
975
|
+
const rows = this.sessionRows();
|
|
440
976
|
signal?.throwIfAborted();
|
|
441
977
|
return rows.map(rowToMeta);
|
|
442
978
|
}
|
|
443
|
-
/**
|
|
979
|
+
/**
|
|
980
|
+
* Return every materialized header with its source-qualified revision.
|
|
981
|
+
* @param signal - optional cancellation before or after the metadata query.
|
|
982
|
+
* @returns stored headers and revisions without loading event rows.
|
|
983
|
+
*/
|
|
444
984
|
async listSnapshots(signal) {
|
|
445
|
-
signal
|
|
446
|
-
|
|
447
|
-
signal?.throwIfAborted();
|
|
448
|
-
const rows = this.db.prepare("SELECT * FROM sessions").all();
|
|
985
|
+
await this.observe(signal);
|
|
986
|
+
const rows = this.sessionRows();
|
|
449
987
|
signal?.throwIfAborted();
|
|
450
988
|
return rows.map((row) => ({
|
|
451
989
|
header: rowToMeta(row),
|
|
452
|
-
revision:
|
|
990
|
+
revision: sqliteRevision(this.storeIdentity, row)
|
|
453
991
|
}));
|
|
454
992
|
}
|
|
455
|
-
/** Close the database handle (awaited by the coordinator's dispose, post-drain). */
|
|
456
993
|
async close() {
|
|
457
|
-
|
|
994
|
+
if (this.ready === void 0) {
|
|
995
|
+
if (this.pathReady !== void 0) await Promise.allSettled([this.pathReady]);
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
await Promise.allSettled([this.ready]);
|
|
999
|
+
if (!this.opened) return;
|
|
1000
|
+
this.opened = false;
|
|
458
1001
|
this.db.close();
|
|
459
1002
|
}
|
|
460
|
-
/** Fetch a session's row, or undefined if absent. */
|
|
461
1003
|
rowFor(id) {
|
|
462
|
-
|
|
1004
|
+
const value = this.db.prepare(sql("select-session")).get(id);
|
|
1005
|
+
return value === void 0 ? void 0 : decodeSessionRow(value);
|
|
1006
|
+
}
|
|
1007
|
+
async observe(signal) {
|
|
1008
|
+
signal?.throwIfAborted();
|
|
1009
|
+
await this.open();
|
|
1010
|
+
signal?.throwIfAborted();
|
|
1011
|
+
}
|
|
1012
|
+
readTransaction(read) {
|
|
1013
|
+
this.db.exec(sql("begin"));
|
|
1014
|
+
try {
|
|
1015
|
+
const value = read();
|
|
1016
|
+
this.db.exec(sql("commit"));
|
|
1017
|
+
return value;
|
|
1018
|
+
} catch (error) {
|
|
1019
|
+
this.rollback(error, "read");
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
sessionRows() {
|
|
1023
|
+
return this.db.prepare(sql("select-sessions")).all().map(decodeSessionRow);
|
|
1024
|
+
}
|
|
1025
|
+
rollback(error, operation) {
|
|
1026
|
+
try {
|
|
1027
|
+
this.db.exec(sql("rollback"));
|
|
1028
|
+
} catch (rollbackError) {
|
|
1029
|
+
/* v8 ignore next -- requires SQLite to fail both an operation and its immediate rollback. */
|
|
1030
|
+
throw new AggregateError([error, rollbackError], `${this.name} ${operation} failed and rollback also failed`);
|
|
1031
|
+
}
|
|
1032
|
+
throw error;
|
|
1033
|
+
}
|
|
1034
|
+
incrementRevision(id) {
|
|
1035
|
+
const updated = this.db.prepare(sql("update-session-revision")).run(id);
|
|
1036
|
+
/* v8 ignore next -- materialized writes follow coordinator create(); other writes upsert in this transaction. */
|
|
1037
|
+
if (Number(updated.changes) !== 1) throw new Error(`session ${id} metadata row is missing`);
|
|
1038
|
+
}
|
|
1039
|
+
tailRows(id) {
|
|
1040
|
+
const tail = this.db.prepare(sql("select-tail-events")).all(id, 2).map(decodeEventRow).reverse();
|
|
1041
|
+
if (tail.length === 0) return [];
|
|
1042
|
+
return this.physicalSpanFrom(id, tail[0].seq).eventRows;
|
|
1043
|
+
}
|
|
1044
|
+
/** Select the bounded physical span that may represent `fromSeq`. */
|
|
1045
|
+
physicalSpanFrom(id, fromSeq) {
|
|
1046
|
+
const packedFloor = Math.max(0, fromSeq - MAX_PACKED_ROW_MEMBERS + 1);
|
|
1047
|
+
const packedPredecessors = this.db.prepare(sql("select-packed-predecessors")).all(id, packedFloor, fromSeq).map(decodeEventRow);
|
|
1048
|
+
let base = fromSeq;
|
|
1049
|
+
for (const predecessor of packedPredecessors) try {
|
|
1050
|
+
const last = decodeRow(predecessor).at(-1);
|
|
1051
|
+
if (last !== void 0 && last.seq >= fromSeq) base = Math.min(base, predecessor.seq);
|
|
1052
|
+
} catch {
|
|
1053
|
+
base = Math.min(base, predecessor.seq);
|
|
1054
|
+
}
|
|
1055
|
+
const eventRows = this.db.prepare(sql("select-events-from")).all(id, base).map(decodeEventRow);
|
|
1056
|
+
return {
|
|
1057
|
+
base,
|
|
1058
|
+
eventRows
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
logicalLastEvent(id, tailRows) {
|
|
1062
|
+
if (tailRows.length === 0) return void 0;
|
|
1063
|
+
const { preserved, tornFrom } = scanRows(tailRows, tailRows[0].seq);
|
|
1064
|
+
if (tornFrom !== void 0) throw new Error(`session ${id} has an invalid physical tail at seq ${tornFrom}`);
|
|
1065
|
+
return preserved.at(-1);
|
|
1066
|
+
}
|
|
1067
|
+
insertStatement() {
|
|
1068
|
+
return this.db.prepare(sql("insert-event"));
|
|
1069
|
+
}
|
|
1070
|
+
insertRecord(insert, id, record) {
|
|
1071
|
+
insert.run(id, record.seq, record.type, record.time, record.data, record.sourceEventSeqs, record.surfaceOp, record.ignorable);
|
|
463
1072
|
}
|
|
464
|
-
/**
|
|
465
|
-
* Insert-or-replace a session's metadata row. The only caller is the first
|
|
466
|
-
* materializing `appendBatch`, so writing the row IS the materialization (its
|
|
467
|
-
* existence is the signal `list` reads).
|
|
468
|
-
*/
|
|
469
1073
|
writeRow(meta) {
|
|
470
|
-
this.db.prepare(
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
1074
|
+
this.db.prepare(sql("upsert-session")).run(meta.id, meta.version, meta.createdAt, meta.cwd ?? null, meta.parentSession ?? null, meta.seedLength ?? null, meta.origin ?? null, meta.delegationDepth ?? null, meta.agentPreset ?? null, randomUUID());
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
function sqliteRevision(storeIdentity, row) {
|
|
1078
|
+
return SessionPersistenceRevision(`${storeIdentity}:incarnation:${row.incarnation}:revision:${row.revision}`);
|
|
1079
|
+
}
|
|
1080
|
+
async function createDatabaseFile(path) {
|
|
1081
|
+
try {
|
|
1082
|
+
await (await open(path, "wx", 384)).close();
|
|
1083
|
+
} catch (error) {
|
|
1084
|
+
if (error.code !== "EEXIST") throw error;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
async function validateParentDirectory(path) {
|
|
1088
|
+
const parent = await lstat(path);
|
|
1089
|
+
if (parent.isSymbolicLink() || !parent.isDirectory()) throw new Error(`session database parent "${path}" must be a real directory`);
|
|
1090
|
+
const uid = process.getuid?.();
|
|
1091
|
+
/* v8 ignore start -- Windows exposes neither process.getuid nor meaningful
|
|
1092
|
+
* uid/mode bits; POSIX tests cover owner and mode rejection. */
|
|
1093
|
+
if (uid !== void 0 && (parent.uid !== uid || (parent.mode & 18) !== 0)) throw new Error(`session database parent "${path}" must be owned by the current user and not group/world-writable`);
|
|
1094
|
+
/* v8 ignore stop */
|
|
1095
|
+
}
|
|
1096
|
+
async function validateDatabaseFile(path) {
|
|
1097
|
+
const file = await lstat(path);
|
|
1098
|
+
if (file.isSymbolicLink() || !file.isFile()) throw new Error(`session database "${path}" must be a regular file, not a symbolic link`);
|
|
1099
|
+
const uid = process.getuid?.();
|
|
1100
|
+
/* v8 ignore start -- Windows exposes neither process.getuid nor meaningful
|
|
1101
|
+
* uid/mode bits; POSIX tests cover owner and mode rejection. */
|
|
1102
|
+
if (uid !== void 0 && (file.uid !== uid || (file.mode & 63) !== 0)) throw new Error(`session database "${path}" must be owned by the current user and accessible only by that user`);
|
|
1103
|
+
/* v8 ignore stop */
|
|
1104
|
+
}
|
|
1105
|
+
async function validateDatabaseFileIfPresent(path) {
|
|
1106
|
+
try {
|
|
1107
|
+
await validateDatabaseFile(path);
|
|
1108
|
+
} catch (error) {
|
|
1109
|
+
if (error.code !== "ENOENT") throw error;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
let nodeSqlite;
|
|
1113
|
+
/** Load Node SQLite once so concurrent stores share one warning-filter lifetime. */
|
|
1114
|
+
function loadNodeSqlite() {
|
|
1115
|
+
nodeSqlite ??= importNodeSqlite();
|
|
1116
|
+
return nodeSqlite;
|
|
1117
|
+
}
|
|
1118
|
+
/** Import Node 22's SQLite dependency without its process-wide experimental warning. */
|
|
1119
|
+
async function importNodeSqlite() {
|
|
1120
|
+
const emitWarning = Reflect.get(process, "emitWarning");
|
|
1121
|
+
/* v8 ignore start -- Node 22 alone emits this warning; primary coverage runs on Node 24. */
|
|
1122
|
+
const filteredEmitWarning = (warning, ...args) => {
|
|
1123
|
+
const message = warning instanceof Error ? warning.message : warning;
|
|
1124
|
+
const first = args[0];
|
|
1125
|
+
const type = warning instanceof Error ? warning.name : typeof first === "string" ? first : typeof first === "object" && first !== null && "type" in first ? first.type : void 0;
|
|
1126
|
+
if (message === "SQLite is an experimental feature and might change at any time" && type === "ExperimentalWarning") return;
|
|
1127
|
+
Reflect.apply(emitWarning, process, [warning, ...args]);
|
|
1128
|
+
};
|
|
1129
|
+
Reflect.set(process, "emitWarning", filteredEmitWarning);
|
|
1130
|
+
try {
|
|
1131
|
+
return await import("node:sqlite");
|
|
1132
|
+
} finally {
|
|
1133
|
+
Reflect.set(process, "emitWarning", emitWarning);
|
|
1134
|
+
}
|
|
1135
|
+
/* v8 ignore stop */
|
|
1136
|
+
}
|
|
1137
|
+
//#endregion
|
|
1138
|
+
//#region lib/types/index.js
|
|
1139
|
+
/**
|
|
1140
|
+
* Opt-in SQLite persistence provider. Logical sessions remain unchanged;
|
|
1141
|
+
* the physical backend packs eligible chunk runs into schema-17 rows.
|
|
1142
|
+
* @module @nomix-ai/nomix-session-persistence-sqlite
|
|
1143
|
+
*/
|
|
1144
|
+
/** Default wait for another SQLite connection's write reservation. */
|
|
1145
|
+
const DEFAULT_BUSY_TIMEOUT_MS = 5e3;
|
|
1146
|
+
/** Largest busy timeout accepted by SQLite's signed millisecond interface. */
|
|
1147
|
+
const MAX_BUSY_TIMEOUT_MS = 2147483647;
|
|
1148
|
+
/**
|
|
1149
|
+
* SQLite `SessionPersistence` provider with a schema-owned physical codec.
|
|
1150
|
+
*/
|
|
1151
|
+
var SqliteSessionPersistence = class extends SessionPersistence {
|
|
1152
|
+
config;
|
|
1153
|
+
supportsRawArtifacts = false;
|
|
1154
|
+
name = "session-persistence-sqlite";
|
|
1155
|
+
static inject = ["sessions"];
|
|
1156
|
+
static Config = z.object({
|
|
1157
|
+
path: z.string().required(),
|
|
1158
|
+
journalMode: z.union([
|
|
1159
|
+
"wal",
|
|
1160
|
+
"delete",
|
|
1161
|
+
"truncate",
|
|
1162
|
+
"persist"
|
|
1163
|
+
]).default("wal"),
|
|
1164
|
+
busyTimeoutMs: z.number().step(1).min(0).max(MAX_BUSY_TIMEOUT_MS).default(DEFAULT_BUSY_TIMEOUT_MS),
|
|
1165
|
+
preparedSessionCacheSize: z.number().step(1).min(1).default(DEFAULT_PREPARED_SESSION_CACHE_SIZE),
|
|
1166
|
+
writeBatchMaxDelayMs: z.number().step(1).min(1).max(MAX_WRITE_BATCH_DELAY_MS).default(DEFAULT_WRITE_BATCH_MAX_DELAY_MS)
|
|
1167
|
+
});
|
|
1168
|
+
store;
|
|
1169
|
+
coordinator;
|
|
1170
|
+
constructor(ctx, config) {
|
|
1171
|
+
super(ctx);
|
|
1172
|
+
this.config = config;
|
|
1173
|
+
const preparedSessionCacheSize = config.preparedSessionCacheSize ?? DEFAULT_PREPARED_SESSION_CACHE_SIZE;
|
|
1174
|
+
const writeBatchMaxDelayMs = config.writeBatchMaxDelayMs ?? DEFAULT_WRITE_BATCH_MAX_DELAY_MS;
|
|
1175
|
+
this.store = new SqliteStore({
|
|
1176
|
+
path: config.path,
|
|
1177
|
+
journalMode: config.journalMode ?? "wal",
|
|
1178
|
+
busyTimeoutMs: config.busyTimeoutMs ?? 5e3
|
|
1179
|
+
});
|
|
1180
|
+
this.coordinator = new PersistenceCoordinator(this.ctx, this.store, {
|
|
1181
|
+
preparedSessionCacheSize,
|
|
1182
|
+
writeBatchMaxDelayMs
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
/** Reject self-contained path and ownership failures without loading Node SQLite. */
|
|
1186
|
+
async [Service.init]() {
|
|
1187
|
+
await this.store.validatePath();
|
|
1188
|
+
}
|
|
1189
|
+
/** SQLite has one database, not an independent per-session artifact. */
|
|
1190
|
+
locate(_meta) {}
|
|
1191
|
+
create(meta) {
|
|
1192
|
+
return this.coordinator.create(meta);
|
|
1193
|
+
}
|
|
1194
|
+
append(id, events) {
|
|
1195
|
+
return this.coordinator.append(id, events);
|
|
1196
|
+
}
|
|
1197
|
+
prepare(id, signal) {
|
|
1198
|
+
return this.coordinator.prepare(id, signal);
|
|
1199
|
+
}
|
|
1200
|
+
load(id) {
|
|
1201
|
+
return this.coordinator.load(id);
|
|
1202
|
+
}
|
|
1203
|
+
inspect(id, signal) {
|
|
1204
|
+
return this.coordinator.inspect(id, signal);
|
|
1205
|
+
}
|
|
1206
|
+
readFrom(id, fromSeq, signal) {
|
|
1207
|
+
return this.coordinator.readFrom(id, fromSeq, signal);
|
|
1208
|
+
}
|
|
1209
|
+
list(signal) {
|
|
1210
|
+
return this.store.list(signal);
|
|
1211
|
+
}
|
|
1212
|
+
listSnapshots(signal) {
|
|
1213
|
+
return this.store.listSnapshots(signal);
|
|
484
1214
|
}
|
|
485
1215
|
};
|
|
486
1216
|
//#endregion
|
|
487
|
-
export { SCHEMA_VERSION, SqliteSessionPersistence, SqliteSessionPersistence as default };
|
|
1217
|
+
export { DEFAULT_BUSY_TIMEOUT_MS, MAX_BUSY_TIMEOUT_MS, SCHEMA_VERSION, SqliteSessionPersistence, SqliteSessionPersistence as default };
|