@kortix/sdk 0.13.4 → 0.13.7
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 +63 -6
- package/dist/browser/cache/idb-sync-cache.d.ts +19 -1
- package/dist/browser/cache/idb-sync-cache.d.ts.map +1 -1
- package/dist/browser/cache/idb-sync-cache.js +39 -4
- package/dist/browser/cache/idb-sync-cache.js.map +1 -1
- package/dist/browser/session-sync/server-transcript-mirror.d.ts +82 -0
- package/dist/browser/session-sync/server-transcript-mirror.d.ts.map +1 -0
- package/dist/browser/session-sync/server-transcript-mirror.js +143 -0
- package/dist/browser/session-sync/server-transcript-mirror.js.map +1 -0
- package/dist/browser/session-sync/session-sync-registry.d.ts +11 -1
- package/dist/browser/session-sync/session-sync-registry.d.ts.map +1 -1
- package/dist/browser/session-sync/session-sync-registry.js +117 -9
- package/dist/browser/session-sync/session-sync-registry.js.map +1 -1
- package/dist/browser/session-sync/visibility.d.ts +19 -0
- package/dist/browser/session-sync/visibility.d.ts.map +1 -0
- package/dist/browser/session-sync/visibility.js +16 -0
- package/dist/browser/session-sync/visibility.js.map +1 -0
- package/dist/browser/stores/sandbox-connection-store.d.ts +13 -1
- package/dist/browser/stores/sandbox-connection-store.d.ts.map +1 -1
- package/dist/browser/stores/sandbox-connection-store.js +6 -3
- package/dist/browser/stores/sandbox-connection-store.js.map +1 -1
- package/dist/browser/stores/session-working-store.d.ts +10 -5
- package/dist/browser/stores/session-working-store.d.ts.map +1 -1
- package/dist/browser/stores/session-working-store.js +32 -8
- package/dist/browser/stores/session-working-store.js.map +1 -1
- package/dist/browser/stores/sync-store.d.ts +56 -2
- package/dist/browser/stores/sync-store.d.ts.map +1 -1
- package/dist/browser/stores/sync-store.js +682 -402
- package/dist/browser/stores/sync-store.js.map +1 -1
- package/dist/core/auth/app-viewer.d.ts +57 -0
- package/dist/core/auth/app-viewer.d.ts.map +1 -0
- package/dist/core/auth/app-viewer.js +82 -0
- package/dist/core/auth/app-viewer.js.map +1 -0
- package/dist/core/auth/session.d.ts +45 -0
- package/dist/core/auth/session.d.ts.map +1 -0
- package/dist/core/auth/session.js +113 -0
- package/dist/core/auth/session.js.map +1 -0
- package/dist/core/client/kortix.d.ts +37 -29
- package/dist/core/client/kortix.d.ts.map +1 -1
- package/dist/core/client/kortix.js +61 -8
- package/dist/core/client/kortix.js.map +1 -1
- package/dist/core/http/config.d.ts +4 -2
- package/dist/core/http/config.d.ts.map +1 -1
- package/dist/core/http/config.js.map +1 -1
- package/dist/core/http/opencode-errors.d.ts +17 -0
- package/dist/core/http/opencode-errors.d.ts.map +1 -1
- package/dist/core/http/opencode-errors.js +25 -0
- package/dist/core/http/opencode-errors.js.map +1 -1
- package/dist/core/rest/platform-client/auth.d.ts +120 -0
- package/dist/core/rest/platform-client/auth.d.ts.map +1 -0
- package/dist/core/rest/platform-client/auth.js +98 -0
- package/dist/core/rest/platform-client/auth.js.map +1 -0
- package/dist/core/rest/platform-client/host-boundary.d.ts +5 -0
- package/dist/core/rest/platform-client/host-boundary.d.ts.map +1 -1
- package/dist/core/rest/platform-client/host-boundary.js.map +1 -1
- package/dist/core/rest/projects-client/accounts.d.ts +57 -0
- package/dist/core/rest/projects-client/accounts.d.ts.map +1 -1
- package/dist/core/rest/projects-client/accounts.js +31 -0
- package/dist/core/rest/projects-client/accounts.js.map +1 -1
- package/dist/core/rest/projects-client/apps.d.ts +9 -0
- package/dist/core/rest/projects-client/apps.d.ts.map +1 -1
- package/dist/core/rest/projects-client/apps.js.map +1 -1
- package/dist/core/rest/projects-client/billing.d.ts +2 -0
- package/dist/core/rest/projects-client/billing.d.ts.map +1 -1
- package/dist/core/rest/projects-client/billing.js.map +1 -1
- package/dist/core/rest/projects-client/channels.d.ts +0 -3
- package/dist/core/rest/projects-client/channels.d.ts.map +1 -1
- package/dist/core/rest/projects-client/channels.js +0 -6
- package/dist/core/rest/projects-client/channels.js.map +1 -1
- package/dist/core/rest/projects-client/connectors.d.ts +104 -19
- package/dist/core/rest/projects-client/connectors.d.ts.map +1 -1
- package/dist/core/rest/projects-client/connectors.js +56 -2
- package/dist/core/rest/projects-client/connectors.js.map +1 -1
- package/dist/core/rest/projects-client/index.d.ts +1 -2
- package/dist/core/rest/projects-client/index.d.ts.map +1 -1
- package/dist/core/rest/projects-client/index.js +1 -2
- package/dist/core/rest/projects-client/index.js.map +1 -1
- package/dist/core/rest/projects-client/oauth-clients.d.ts +47 -0
- package/dist/core/rest/projects-client/oauth-clients.d.ts.map +1 -0
- package/dist/core/rest/projects-client/oauth-clients.js +33 -0
- package/dist/core/rest/projects-client/oauth-clients.js.map +1 -0
- package/dist/core/rest/projects-client/projects.d.ts +23 -6
- package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
- package/dist/core/rest/projects-client/projects.js +6 -3
- package/dist/core/rest/projects-client/projects.js.map +1 -1
- package/dist/core/rest/projects-client/session-sandbox.d.ts +52 -0
- package/dist/core/rest/projects-client/session-sandbox.d.ts.map +1 -1
- package/dist/core/rest/projects-client/session-sandbox.js.map +1 -1
- package/dist/core/rest/projects-client/sessions.d.ts +142 -34
- package/dist/core/rest/projects-client/sessions.d.ts.map +1 -1
- package/dist/core/rest/projects-client/sessions.js +48 -19
- package/dist/core/rest/projects-client/sessions.js.map +1 -1
- package/dist/core/runtime/attachment-part.d.ts +26 -0
- package/dist/core/runtime/attachment-part.d.ts.map +1 -0
- package/dist/core/runtime/attachment-part.js +41 -0
- package/dist/core/runtime/attachment-part.js.map +1 -0
- package/dist/core/runtime/client.d.ts +4 -2
- package/dist/core/runtime/client.d.ts.map +1 -1
- package/dist/core/runtime/client.js +3 -2
- package/dist/core/runtime/client.js.map +1 -1
- package/dist/core/runtime/opencode-v2-event-aliases.d.ts +184 -0
- package/dist/core/runtime/opencode-v2-event-aliases.d.ts.map +1 -0
- package/dist/core/runtime/opencode-v2-event-aliases.js +2 -0
- package/dist/core/runtime/opencode-v2-event-aliases.js.map +1 -0
- package/dist/core/runtime/pty.d.ts +11 -1
- package/dist/core/runtime/pty.d.ts.map +1 -1
- package/dist/core/runtime/pty.js +19 -6
- package/dist/core/runtime/pty.js.map +1 -1
- package/dist/core/session/connection.d.ts +64 -0
- package/dist/core/session/connection.d.ts.map +1 -0
- package/dist/core/session/connection.js +36 -0
- package/dist/core/session/connection.js.map +1 -0
- package/dist/core/session/index.d.ts +2 -0
- package/dist/core/session/index.d.ts.map +1 -1
- package/dist/core/session/index.js +2 -0
- package/dist/core/session/index.js.map +1 -1
- package/dist/core/session/open-bundle.d.ts +110 -0
- package/dist/core/session/open-bundle.d.ts.map +1 -0
- package/dist/core/session/open-bundle.js +183 -0
- package/dist/core/session/open-bundle.js.map +1 -0
- package/dist/core/session/poll-owner.d.ts +35 -0
- package/dist/core/session/poll-owner.d.ts.map +1 -0
- package/dist/core/session/poll-owner.js +90 -0
- package/dist/core/session/poll-owner.js.map +1 -0
- package/dist/core/session/preview-auth.d.ts +25 -0
- package/dist/core/session/preview-auth.d.ts.map +1 -1
- package/dist/core/session/preview-auth.js +31 -1
- package/dist/core/session/preview-auth.js.map +1 -1
- package/dist/core/session/preview-config.d.ts +26 -0
- package/dist/core/session/preview-config.d.ts.map +1 -0
- package/dist/core/session/preview-config.js +95 -0
- package/dist/core/session/preview-config.js.map +1 -0
- package/dist/core/session/preview-options.d.ts +25 -0
- package/dist/core/session/preview-options.d.ts.map +1 -0
- package/dist/core/session/preview-options.js +45 -0
- package/dist/core/session/preview-options.js.map +1 -0
- package/dist/core/session/preview.d.ts +8 -3
- package/dist/core/session/preview.d.ts.map +1 -1
- package/dist/core/session/preview.js +11 -4
- package/dist/core/session/preview.js.map +1 -1
- package/dist/core/session/rewind.d.ts +67 -24
- package/dist/core/session/rewind.d.ts.map +1 -1
- package/dist/core/session/rewind.js +74 -26
- package/dist/core/session/rewind.js.map +1 -1
- package/dist/core/session/server-store/active.d.ts +10 -12
- package/dist/core/session/server-store/active.d.ts.map +1 -1
- package/dist/core/session/server-store/active.js +11 -9
- package/dist/core/session/server-store/active.js.map +1 -1
- package/dist/core/session/server-store/url-helpers.d.ts +11 -2
- package/dist/core/session/server-store/url-helpers.d.ts.map +1 -1
- package/dist/core/session/server-store/url-helpers.js +11 -2
- package/dist/core/session/server-store/url-helpers.js.map +1 -1
- package/dist/core/session/static-file-preview.d.ts +50 -0
- package/dist/core/session/static-file-preview.d.ts.map +1 -0
- package/dist/core/session/static-file-preview.js +91 -0
- package/dist/core/session/static-file-preview.js.map +1 -0
- package/dist/core/session/url.d.ts +25 -2
- package/dist/core/session/url.d.ts.map +1 -1
- package/dist/core/session/url.js +87 -11
- package/dist/core/session/url.js.map +1 -1
- package/dist/core/session/wake-escalation.d.ts +188 -0
- package/dist/core/session/wake-escalation.d.ts.map +1 -0
- package/dist/core/session/wake-escalation.js +241 -0
- package/dist/core/session/wake-escalation.js.map +1 -0
- package/dist/core/session/working.d.ts +107 -2
- package/dist/core/session/working.d.ts.map +1 -1
- package/dist/core/session/working.js +206 -7
- package/dist/core/session/working.js.map +1 -1
- package/dist/core/session-sync/durable-log.d.ts +96 -0
- package/dist/core/session-sync/durable-log.d.ts.map +1 -0
- package/dist/core/session-sync/durable-log.js +94 -0
- package/dist/core/session-sync/durable-log.js.map +1 -0
- package/dist/core/session-sync/fragment.d.ts +27 -0
- package/dist/core/session-sync/fragment.d.ts.map +1 -0
- package/dist/core/session-sync/fragment.js +24 -0
- package/dist/core/session-sync/fragment.js.map +1 -0
- package/dist/core/session-sync/session-sync-controller.d.ts +117 -11
- package/dist/core/session-sync/session-sync-controller.d.ts.map +1 -1
- package/dist/core/session-sync/session-sync-controller.js +278 -26
- package/dist/core/session-sync/session-sync-controller.js.map +1 -1
- package/dist/core/stream/keepalive.d.ts +17 -0
- package/dist/core/stream/keepalive.d.ts.map +1 -0
- package/dist/core/stream/keepalive.js +19 -0
- package/dist/core/stream/keepalive.js.map +1 -0
- package/dist/core/turns/grouping.d.ts.map +1 -1
- package/dist/core/turns/grouping.js +73 -23
- package/dist/core/turns/grouping.js.map +1 -1
- package/dist/core/turns/types.d.ts +5 -0
- package/dist/core/turns/types.d.ts.map +1 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/dist/kortix.esm.min.js +25 -25
- package/dist/kortix.global.js +25 -25
- package/dist/node/app-viewer.d.ts +41 -0
- package/dist/node/app-viewer.d.ts.map +1 -0
- package/dist/node/app-viewer.js +150 -0
- package/dist/node/app-viewer.js.map +1 -0
- package/dist/node/auth.d.ts +84 -0
- package/dist/node/auth.d.ts.map +1 -0
- package/dist/node/auth.js +414 -0
- package/dist/node/auth.js.map +1 -0
- package/dist/node/server.d.ts +19 -0
- package/dist/node/server.d.ts.map +1 -1
- package/dist/node/server.js +13 -1
- package/dist/node/server.js.map +1 -1
- package/dist/platform/auth-core.d.ts +13 -1
- package/dist/platform/auth-core.d.ts.map +1 -1
- package/dist/platform/auth-core.js +13 -1
- package/dist/platform/auth-core.js.map +1 -1
- package/dist/react/bedrock-invokable.d.ts +58 -0
- package/dist/react/bedrock-invokable.d.ts.map +1 -0
- package/dist/react/bedrock-invokable.js +83 -0
- package/dist/react/bedrock-invokable.js.map +1 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +7 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/model-flatten.d.ts +14 -1
- package/dist/react/model-flatten.d.ts.map +1 -1
- package/dist/react/model-flatten.js +3 -4
- package/dist/react/model-flatten.js.map +1 -1
- package/dist/react/opencode.d.ts +3 -1
- package/dist/react/opencode.d.ts.map +1 -1
- package/dist/react/opencode.js +5 -1
- package/dist/react/opencode.js.map +1 -1
- package/dist/react/provider-selection.d.ts +58 -0
- package/dist/react/provider-selection.d.ts.map +1 -1
- package/dist/react/provider-selection.js +253 -2
- package/dist/react/provider-selection.js.map +1 -1
- package/dist/react/session-start-giveup.d.ts +12 -0
- package/dist/react/session-start-giveup.d.ts.map +1 -0
- package/dist/react/session-start-giveup.js +13 -0
- package/dist/react/session-start-giveup.js.map +1 -0
- package/dist/react/session-title-sync.d.ts.map +1 -1
- package/dist/react/session-title-sync.js +15 -5
- package/dist/react/session-title-sync.js.map +1 -1
- package/dist/react/sign-in-with-kortix.d.ts +346 -0
- package/dist/react/sign-in-with-kortix.d.ts.map +1 -0
- package/dist/react/sign-in-with-kortix.js +65 -0
- package/dist/react/sign-in-with-kortix.js.map +1 -0
- package/dist/react/use-admin-accounts.d.ts +36 -1
- package/dist/react/use-admin-accounts.d.ts.map +1 -1
- package/dist/react/use-admin-accounts.js +19 -0
- package/dist/react/use-admin-accounts.js.map +1 -1
- package/dist/react/use-gateway-routing-policy.d.ts +1 -0
- package/dist/react/use-gateway-routing-policy.d.ts.map +1 -1
- package/dist/react/use-gateway-routing-policy.js +12 -1
- package/dist/react/use-gateway-routing-policy.js.map +1 -1
- package/dist/react/use-kortix-app-viewer.d.ts +13 -0
- package/dist/react/use-kortix-app-viewer.d.ts.map +1 -0
- package/dist/react/use-kortix-app-viewer.js +29 -0
- package/dist/react/use-kortix-app-viewer.js.map +1 -0
- package/dist/react/use-model-defaults.d.ts +7 -0
- package/dist/react/use-model-defaults.d.ts.map +1 -1
- package/dist/react/use-model-defaults.js +7 -1
- package/dist/react/use-model-defaults.js.map +1 -1
- package/dist/react/use-model-enablement.d.ts.map +1 -1
- package/dist/react/use-model-enablement.js +5 -1
- package/dist/react/use-model-enablement.js.map +1 -1
- package/dist/react/use-model-store.d.ts +31 -0
- package/dist/react/use-model-store.d.ts.map +1 -1
- package/dist/react/use-model-store.js +31 -2
- package/dist/react/use-model-store.js.map +1 -1
- package/dist/react/use-opencode-events/handle-event.d.ts.map +1 -1
- package/dist/react/use-opencode-events/handle-event.js +26 -0
- package/dist/react/use-opencode-events/handle-event.js.map +1 -1
- package/dist/react/use-opencode-events/helpers.d.ts +49 -5
- package/dist/react/use-opencode-events/helpers.d.ts.map +1 -1
- package/dist/react/use-opencode-events/helpers.js +54 -6
- package/dist/react/use-opencode-events/helpers.js.map +1 -1
- package/dist/react/use-opencode-events/index.d.ts.map +1 -1
- package/dist/react/use-opencode-events/index.js +80 -8
- package/dist/react/use-opencode-events/index.js.map +1 -1
- package/dist/react/use-opencode-events/rehydrate-targets.d.ts +18 -0
- package/dist/react/use-opencode-events/rehydrate-targets.d.ts.map +1 -0
- package/dist/react/use-opencode-events/rehydrate-targets.js +20 -0
- package/dist/react/use-opencode-events/rehydrate-targets.js.map +1 -0
- package/dist/react/use-opencode-events/stream-revival.d.ts +37 -0
- package/dist/react/use-opencode-events/stream-revival.d.ts.map +1 -0
- package/dist/react/use-opencode-events/stream-revival.js +53 -0
- package/dist/react/use-opencode-events/stream-revival.js.map +1 -0
- package/dist/react/use-opencode-events/use-event-stream-refs.d.ts.map +1 -1
- package/dist/react/use-opencode-events/use-event-stream-refs.js +14 -2
- package/dist/react/use-opencode-events/use-event-stream-refs.js.map +1 -1
- package/dist/react/use-opencode-local.d.ts.map +1 -1
- package/dist/react/use-opencode-local.js +27 -8
- package/dist/react/use-opencode-local.js.map +1 -1
- package/dist/react/use-opencode-pty.d.ts +7 -1
- package/dist/react/use-opencode-pty.d.ts.map +1 -1
- package/dist/react/use-opencode-pty.js +6 -2
- package/dist/react/use-opencode-pty.js.map +1 -1
- package/dist/react/use-opencode-sessions/agents.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/agents.js +13 -2
- package/dist/react/use-opencode-sessions/agents.js.map +1 -1
- package/dist/react/use-opencode-sessions/commands.d.ts +12 -0
- package/dist/react/use-opencode-sessions/commands.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/commands.js +15 -3
- package/dist/react/use-opencode-sessions/commands.js.map +1 -1
- package/dist/react/use-opencode-sessions/index.d.ts +1 -0
- package/dist/react/use-opencode-sessions/index.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/index.js +1 -0
- package/dist/react/use-opencode-sessions/index.js.map +1 -1
- package/dist/react/use-opencode-sessions/keys.d.ts +8 -0
- package/dist/react/use-opencode-sessions/keys.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/keys.js +8 -0
- package/dist/react/use-opencode-sessions/keys.js.map +1 -1
- package/dist/react/use-opencode-sessions/providers.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/providers.js +56 -5
- package/dist/react/use-opencode-sessions/providers.js.map +1 -1
- package/dist/react/use-opencode-sessions/shared.d.ts +23 -0
- package/dist/react/use-opencode-sessions/shared.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/shared.js +31 -0
- package/dist/react/use-opencode-sessions/shared.js.map +1 -1
- package/dist/react/use-opencode-sessions/vcs.d.ts +28 -0
- package/dist/react/use-opencode-sessions/vcs.d.ts.map +1 -0
- package/dist/react/use-opencode-sessions/vcs.js +42 -0
- package/dist/react/use-opencode-sessions/vcs.js.map +1 -0
- package/dist/react/use-poll-owner.d.ts +14 -0
- package/dist/react/use-poll-owner.d.ts.map +1 -0
- package/dist/react/use-poll-owner.js +32 -0
- package/dist/react/use-poll-owner.js.map +1 -0
- package/dist/react/use-project-llm-gateway.d.ts +27 -0
- package/dist/react/use-project-llm-gateway.d.ts.map +1 -0
- package/dist/react/use-project-llm-gateway.js +41 -0
- package/dist/react/use-project-llm-gateway.js.map +1 -0
- package/dist/react/use-project-models.d.ts +9 -0
- package/dist/react/use-project-models.d.ts.map +1 -1
- package/dist/react/use-project-models.js +24 -1
- package/dist/react/use-project-models.js.map +1 -1
- package/dist/react/use-runtime-reconnect.d.ts +11 -0
- package/dist/react/use-runtime-reconnect.d.ts.map +1 -1
- package/dist/react/use-runtime-reconnect.js +34 -3
- package/dist/react/use-runtime-reconnect.js.map +1 -1
- package/dist/react/use-session-prompts.d.ts +53 -3
- package/dist/react/use-session-prompts.d.ts.map +1 -1
- package/dist/react/use-session-prompts.js +133 -21
- package/dist/react/use-session-prompts.js.map +1 -1
- package/dist/react/use-session-send.d.ts +17 -0
- package/dist/react/use-session-send.d.ts.map +1 -1
- package/dist/react/use-session-send.js +54 -5
- package/dist/react/use-session-send.js.map +1 -1
- package/dist/react/use-session-start-give-up.d.ts +20 -0
- package/dist/react/use-session-start-give-up.d.ts.map +1 -0
- package/dist/react/use-session-start-give-up.js +60 -0
- package/dist/react/use-session-start-give-up.js.map +1 -0
- package/dist/react/use-session-sync.d.ts +35 -1
- package/dist/react/use-session-sync.d.ts.map +1 -1
- package/dist/react/use-session-sync.js +135 -53
- package/dist/react/use-session-sync.js.map +1 -1
- package/dist/react/use-session-working.d.ts +55 -0
- package/dist/react/use-session-working.d.ts.map +1 -1
- package/dist/react/use-session-working.js +114 -13
- package/dist/react/use-session-working.js.map +1 -1
- package/dist/react/use-session.d.ts +13 -13
- package/dist/react/use-session.d.ts.map +1 -1
- package/dist/react/use-session.js +74 -53
- package/dist/react/use-session.js.map +1 -1
- package/dist/react/use-static-file-preview.d.ts +12 -0
- package/dist/react/use-static-file-preview.d.ts.map +1 -0
- package/dist/react/use-static-file-preview.js +119 -0
- package/dist/react/use-static-file-preview.js.map +1 -0
- package/dist/react/use-wake-escalation.d.ts +51 -0
- package/dist/react/use-wake-escalation.d.ts.map +1 -0
- package/dist/react/use-wake-escalation.js +62 -0
- package/dist/react/use-wake-escalation.js.map +1 -0
- package/package.json +6 -4
- package/dist/browser/session-sync/session-transcript-cache.d.ts +0 -79
- package/dist/browser/session-sync/session-transcript-cache.d.ts.map +0 -1
- package/dist/browser/session-sync/session-transcript-cache.js +0 -91
- package/dist/browser/session-sync/session-transcript-cache.js.map +0 -1
- package/dist/core/rest/projects-client/public-voice-join.d.ts +0 -59
- package/dist/core/rest/projects-client/public-voice-join.d.ts.map +0 -1
- package/dist/core/rest/projects-client/public-voice-join.js +0 -64
- package/dist/core/rest/projects-client/public-voice-join.js.map +0 -1
- package/dist/core/rest/projects-client/transcription.d.ts +0 -5
- package/dist/core/rest/projects-client/transcription.d.ts.map +0 -1
- package/dist/core/rest/projects-client/transcription.js +0 -14
- package/dist/core/rest/projects-client/transcription.js.map +0 -1
package/README.md
CHANGED
|
@@ -207,7 +207,7 @@ exhaustive — see `API-MAP.md` for the full per-domain surface:
|
|
|
207
207
|
| namespace | what |
|
|
208
208
|
|---|---|
|
|
209
209
|
| `kortix.projects` | list · get · detail · create · provision · update · archive · llmCatalog · modelPicker · sandboxTemplates · sessions (+ more: `listForAccount`, `sandboxHealth`, `createSession`) |
|
|
210
|
-
| `kortix.accounts` | list · get · create · members · invites · `tokens.{list,create,revoke}` (account-scoped CLI PATs, `kortix_pat_…`) · `audit.{log,export,webhooks.*}` (filterable project/session reconstruction log) (+ more: `updateName`, `leave`, `invite`, `removeMember`, `updateMemberRole`) |
|
|
210
|
+
| `kortix.accounts` | list · get · create · members · invites · `tokens.{list,create,revoke}` (account-scoped CLI PATs, `kortix_pat_…`) · `audit.{log,export,webhooks.*}` (filterable project/session reconstruction log) · `branding.{get,update,uploadAsset,removeAsset,reset}` (Enterprise organization branding: logo / icon / favicon, light + dark, product name) (+ more: `updateName`, `leave`, `invite`, `removeMember`, `updateMemberRole`) |
|
|
211
211
|
| `kortix.billing` | entitlement/usage reads: `accountState` · `accountStateMinimal` · `transactions` · `transactionsSummary` · `creditBreakdown` · `usageHistory` · `usageRollup` · `sessionCosts.{list,get}` · `tierConfigurations` — plus a curated mutation surface: `checkout.{createSession,confirmSession}` · `subscription.{createPortalSession,cancel,reactivate,scheduleDowngrade,cancelScheduledChange,prorationPreview}` · `credits.{purchase,autoTopupSettings,configureAutoTopup}` |
|
|
212
212
|
| `kortix.marketplace` | public marketplace catalog browse + sources (not project-scoped): `items` · `item` · `itemFile` · `marketplaces` · `featured` · `sources.{list,add,remove}` — distinct from the install-scoped `project(id).marketplace` |
|
|
213
213
|
| `kortix.validateToken()` | pasted-API-key validation helper — `GET /accounts/me`, never throws, resolves `{valid, identity?, error?}` |
|
|
@@ -430,7 +430,7 @@ them too). They're real classes: `instanceof` works across every host, and
|
|
|
430
430
|
- `ApiError` — any failed request; branch on `.status` / `.code` (e.g.
|
|
431
431
|
`'TIMEOUT'`, `'RUNTIME_UNAVAILABLE'`, `'ABORTED'`). Timeout errors carry
|
|
432
432
|
`.url` / `.endpoint` / `.timeout`.
|
|
433
|
-
- `
|
|
433
|
+
- `HeadlessAuthError extends ApiError` — `getToken()` returned null; the request was
|
|
434
434
|
never sent (`code: 'NO_SESSION'`).
|
|
435
435
|
- `BillingError` — HTTP 402, with the backend's payload on `.detail`.
|
|
436
436
|
- `RequestTooLargeError` — HTTP 431 (usually a too-large upload batch), with a
|
|
@@ -443,7 +443,7 @@ The canonical server-side wrapper shape — catch a 402 and pass the payload
|
|
|
443
443
|
through to your own client for re-billing, instead of leaking a Kortix error:
|
|
444
444
|
|
|
445
445
|
```ts
|
|
446
|
-
import { ApiError,
|
|
446
|
+
import { ApiError, HeadlessAuthError, BillingError } from "@kortix/sdk";
|
|
447
447
|
|
|
448
448
|
try {
|
|
449
449
|
await kortix.session(pid, sid).send(prompt);
|
|
@@ -452,7 +452,7 @@ try {
|
|
|
452
452
|
// 402 — surface the upgrade/cost payload under YOUR billing story.
|
|
453
453
|
return res.status(402).json({ reason: "quota", detail: err.detail });
|
|
454
454
|
}
|
|
455
|
-
if (err instanceof
|
|
455
|
+
if (err instanceof HeadlessAuthError)
|
|
456
456
|
return res.status(401).json({ error: "not authenticated" });
|
|
457
457
|
if (err instanceof ApiError)
|
|
458
458
|
return res.status(err.status ?? 502).json({ error: err.message });
|
|
@@ -551,8 +551,65 @@ Native cannot consume the SDK's fetch-based SSE stream.
|
|
|
551
551
|
|
|
552
552
|
## Auth
|
|
553
553
|
|
|
554
|
-
`Authorization: Bearer <token>` — a Supabase JWT (user sessions)
|
|
555
|
-
(`kortix_pat_…`) for server-side / automation use,
|
|
554
|
+
`Authorization: Bearer <token>` — a Supabase JWT (user sessions), a Kortix PAT
|
|
555
|
+
(`kortix_pat_…`) for server-side / automation use, or an OAuth access token
|
|
556
|
+
(`kortix_oat_…`) minted by "Sign in with Kortix" — supplied via `getToken`.
|
|
557
|
+
|
|
558
|
+
### Sign in with Kortix (your app, their Kortix account)
|
|
559
|
+
|
|
560
|
+
Make Kortix the identity provider for an app you run. Register the app once
|
|
561
|
+
(`kortix.iam.oauthClients.create`, or Account → Tokens → OAuth apps), then:
|
|
562
|
+
|
|
563
|
+
```ts
|
|
564
|
+
import { createKortixAuth } from '@kortix/sdk/server';
|
|
565
|
+
|
|
566
|
+
export const auth = createKortixAuth({
|
|
567
|
+
backendUrl: 'https://api.kortix.com/v1',
|
|
568
|
+
clientId: process.env.KORTIX_OAUTH_CLIENT_ID!,
|
|
569
|
+
clientSecret: process.env.KORTIX_OAUTH_CLIENT_SECRET, // omit for a public (PKCE-only) client
|
|
570
|
+
redirectUri: 'https://app.example.com/api/kortix/auth/callback',
|
|
571
|
+
cookieSecret: process.env.KORTIX_AUTH_COOKIE_SECRET!, // ≥ 32 chars
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
// one catch-all route: /signin /callback /refresh /signout /me /proxy/*
|
|
575
|
+
export const GET = (req: Request) => auth.handler(req);
|
|
576
|
+
export const POST = GET;
|
|
577
|
+
|
|
578
|
+
// anywhere on the server
|
|
579
|
+
const gate = await auth.requireViewer(req); // { viewer } | { response: 302 }
|
|
580
|
+
const kortix = await auth.kortix(req); // acts as the viewer
|
|
581
|
+
// in the browser
|
|
582
|
+
const client = createKortix(auth.clientConfig()); // talks to Kortix through /proxy
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
`@kortix/sdk/react` adds `useKortixViewer()` and `<SignInWithKortix />`.
|
|
586
|
+
Full guide: `/docs/sdk/sign-in`. Example: `examples/11-sign-in-with-kortix.ts`.
|
|
587
|
+
|
|
588
|
+
### A Kortix-hosted App is already signed in
|
|
589
|
+
|
|
590
|
+
```ts
|
|
591
|
+
const kortix = createKortix({ backendUrl, getToken: kortixAppViewerToken() }); // browser
|
|
592
|
+
const viewer = await readAppViewer(request); // server (@kortix/sdk/server)
|
|
593
|
+
const asViewer = await createAppViewerKortix(request, { backendUrl }); // act as them
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
The Apps gate authenticated the visitor before your App was served and signs
|
|
597
|
+
their identity into every request; `viewer_token_scope` on the App's access
|
|
598
|
+
policy decides whether the App also gets a token to act with. Guide:
|
|
599
|
+
`/docs/sdk/apps`.
|
|
600
|
+
|
|
601
|
+
### Headless sign-in (your users, straight through the API)
|
|
602
|
+
|
|
603
|
+
```ts
|
|
604
|
+
const session = kortix.auth.session({ storage }); // self-refreshing token store
|
|
605
|
+
const { session: s, user } = await kortix.auth.signInWithPassword({ email, password });
|
|
606
|
+
await session.set(s, user);
|
|
607
|
+
const asUser = createKortix({ backendUrl, getToken: session.getToken });
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
Also `signUp`, `sendMagicLink` + `verifyOtp`, `signInWithProvider` +
|
|
611
|
+
`exchangeCode` (PKCE), `resetPassword`, `updatePassword`, `user`, `signOut` —
|
|
612
|
+
all `/v1/auth/*`, no Supabase in the client. Guide: `/docs/sdk/auth`.
|
|
556
613
|
|
|
557
614
|
## Tests
|
|
558
615
|
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* IndexedDB persistence layer for the sync store.
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* **NOTHING IN KORTIX WRITES OR READS TRANSCRIPTS HERE ANY MORE.** The mirror
|
|
5
|
+
* that painted a session before its sandbox woke is gone (`use-session-sync.ts`
|
|
6
|
+
* carries the full reasoning): its freshness test read the transcript's SHAPE —
|
|
7
|
+
* message count, total part count, tail id — and the two changes that END a
|
|
8
|
+
* turn move none of them. `time.completed` on the tail and the `error` an abort
|
|
9
|
+
* stamps were both invisible, so a stopped thread's disk copy claimed the turn
|
|
10
|
+
* was still running and the next cold paint dimmed every message after it to
|
|
11
|
+
* "Queued".
|
|
12
|
+
*
|
|
13
|
+
* What remains, and why:
|
|
14
|
+
*
|
|
15
|
+
* - `deleteSessionFromIDB` / `clearSessionIDBCache` / `pruneIDBCache` — the
|
|
16
|
+
* CLEANUP half, still wired to session delete, sign-out and account switch.
|
|
17
|
+
* They must keep working to purge what earlier versions left on disk.
|
|
18
|
+
* - `saveSessionToIDB` / `loadSessionFromIDB` / `flushIDBWrites` /
|
|
19
|
+
* `loadAllSessionIdsFromIDB` — published API (`public-surface.snapshot.json`).
|
|
20
|
+
* Removing an export is a breaking change for a package on npm, so they stay
|
|
21
|
+
* and keep their contract. No Kortix host calls them.
|
|
4
22
|
*
|
|
5
23
|
* Schema: one object store "sessions" keyed by cacheKey, each entry holds
|
|
6
24
|
* { cacheKey, userId, sessionId, messages, parts, updatedAt }.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idb-sync-cache.d.ts","sourceRoot":"","sources":["../../../src/browser/cache/idb-sync-cache.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"idb-sync-cache.d.ts","sourceRoot":"","sources":["../../../src/browser/cache/idb-sync-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAsJH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,GAAG,EAAE,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAC5B,kBAAkB,CAAC,EAAE,MAAM,GAC1B,OAAO,CAAC,IAAI,CAAC,CAef;AAED,wBAAgB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAK9C;AAED,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,EACjB,kBAAkB,CAAC,EAAE,MAAM,GAC1B,OAAO,CAAC;IAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;CAAE,GAAG,IAAI,CAAC,CA4BnE;AAED,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAiBlE;AAED,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,kBAAkB,CAAC,EAAE,MAAM,GAC1B,OAAO,CAAC,IAAI,CAAC,CAWf;AAED,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAgB1D;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CA6BnD"}
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* IndexedDB persistence layer for the sync store.
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* **NOTHING IN KORTIX WRITES OR READS TRANSCRIPTS HERE ANY MORE.** The mirror
|
|
5
|
+
* that painted a session before its sandbox woke is gone (`use-session-sync.ts`
|
|
6
|
+
* carries the full reasoning): its freshness test read the transcript's SHAPE —
|
|
7
|
+
* message count, total part count, tail id — and the two changes that END a
|
|
8
|
+
* turn move none of them. `time.completed` on the tail and the `error` an abort
|
|
9
|
+
* stamps were both invisible, so a stopped thread's disk copy claimed the turn
|
|
10
|
+
* was still running and the next cold paint dimmed every message after it to
|
|
11
|
+
* "Queued".
|
|
12
|
+
*
|
|
13
|
+
* What remains, and why:
|
|
14
|
+
*
|
|
15
|
+
* - `deleteSessionFromIDB` / `clearSessionIDBCache` / `pruneIDBCache` — the
|
|
16
|
+
* CLEANUP half, still wired to session delete, sign-out and account switch.
|
|
17
|
+
* They must keep working to purge what earlier versions left on disk.
|
|
18
|
+
* - `saveSessionToIDB` / `loadSessionFromIDB` / `flushIDBWrites` /
|
|
19
|
+
* `loadAllSessionIdsFromIDB` — published API (`public-surface.snapshot.json`).
|
|
20
|
+
* Removing an export is a breaking change for a package on npm, so they stay
|
|
21
|
+
* and keep their contract. No Kortix host calls them.
|
|
4
22
|
*
|
|
5
23
|
* Schema: one object store "sessions" keyed by cacheKey, each entry holds
|
|
6
24
|
* { cacheKey, userId, sessionId, messages, parts, updatedAt }.
|
|
@@ -8,7 +26,25 @@
|
|
|
8
26
|
import { platformConfig } from '../../core/http/config.js';
|
|
9
27
|
import { buildSessionCacheKey } from './idb-sync-cache-key.js';
|
|
10
28
|
const DB_NAME = 'kortix-session-cache';
|
|
11
|
-
|
|
29
|
+
/**
|
|
30
|
+
* 3 — bumped to PURGE what the retired mirror left behind: `onupgradeneeded`
|
|
31
|
+
* drops and recreates the store.
|
|
32
|
+
*
|
|
33
|
+
* BUT NOT ON PAGE LOAD, and that is worth being exact about. `openDB` is lazy,
|
|
34
|
+
* and with the mirror gone the only callers that still reach it are
|
|
35
|
+
* `deleteSessionFromIDB` (a session was deleted) and `clearSessionIDBCache`
|
|
36
|
+
* (sign-out / account switch). So a user who does neither keeps their old
|
|
37
|
+
* entries on disk indefinitely — `pruneIDBCache`'s 50-session / 7-day caps are
|
|
38
|
+
* unreachable too, because the only thing that called it was the flush.
|
|
39
|
+
*
|
|
40
|
+
* That data is INERT: nothing reads it, so it cannot affect the transcript. It
|
|
41
|
+
* is wasted quota, not a correctness risk. Purging it eagerly would need a
|
|
42
|
+
* host-side call at app start, which is deliberately not added here.
|
|
43
|
+
*/
|
|
44
|
+
const DB_VERSION = 3;
|
|
45
|
+
/** Debounce for the batched write. Flat: the caller that made this cadence
|
|
46
|
+
* worth tuning is gone. */
|
|
47
|
+
const FLUSH_INTERVAL_MS = 500;
|
|
12
48
|
const STORE_NAME = 'sessions';
|
|
13
49
|
const MAX_CACHED_SESSIONS = 50;
|
|
14
50
|
const MAX_SESSION_AGE_MS = 7 * 24 * 60 * 60 * 1000; // 7 days
|
|
@@ -65,7 +101,6 @@ function openDB() {
|
|
|
65
101
|
}
|
|
66
102
|
const pendingWrites = new Map();
|
|
67
103
|
let flushTimer = null;
|
|
68
|
-
const FLUSH_INTERVAL_MS = 500;
|
|
69
104
|
// The caps below are only real if something enforces them. Prune once per page
|
|
70
105
|
// load, off the back of the first flush, so the cache cannot grow forever
|
|
71
106
|
// without any host having to remember to call it.
|
|
@@ -107,7 +142,7 @@ async function flushPendingWrites() {
|
|
|
107
142
|
});
|
|
108
143
|
}
|
|
109
144
|
catch {
|
|
110
|
-
// Non-critical
|
|
145
|
+
// Non-critical — this cache is disposable by construction.
|
|
111
146
|
}
|
|
112
147
|
}
|
|
113
148
|
export async function saveSessionToIDB(sessionId, messages, parts, kortixSessionScope) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idb-sync-cache.js","sourceRoot":"","sources":["../../../src/browser/cache/idb-sync-cache.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"idb-sync-cache.js","sourceRoot":"","sources":["../../../src/browser/cache/idb-sync-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,OAAO,GAAG,sBAAsB,CAAC;AACvC;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,GAAG,CAAC,CAAC;AACrB;4BAC4B;AAC5B,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,UAAU,GAAG,UAAU,CAAC;AAC9B,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,SAAS;AAY7D,IAAI,iBAAiB,GAAkC,IAAI,CAAC;AAE5D,SAAS,oBAAoB;IAC3B,IAAI,iBAAiB;QAAE,OAAO,iBAAiB,CAAC;IAEhD,MAAM,OAAO,GAAG,CAAC,KAAK,IAAI,EAAE;QAC1B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,CAAC,MAAM,cAAc,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC;YAC9D,OAAO,MAAM,CAAC,CAAC,CAAC,QAAQ,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAC1C,CAAC;QAAC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AC;AACH,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Painting a session's history from the SERVER's transcript mirror while its
|
|
3
|
+
* sandbox is still waking.
|
|
4
|
+
*
|
|
5
|
+
* WHAT THIS REPLACES. An IndexedDB mirror used to do this and was deleted
|
|
6
|
+
* (`5a7a43517f`) because its freshness test read the transcript's SHAPE —
|
|
7
|
+
* message count, total part count, tail id — and the two things that end a turn
|
|
8
|
+
* move none of them: `time.completed` stamped on the tail message, and the
|
|
9
|
+
* `error` a Stop stamps. A stopped thread therefore cold-painted as still
|
|
10
|
+
* running, with every message under it dimmed to "Queued".
|
|
11
|
+
* `use-session-sync.ts` records the acceptance criterion for any replacement:
|
|
12
|
+
* *it needs a mirror whose freshness test reads the MESSAGE, not its shape.*
|
|
13
|
+
*
|
|
14
|
+
* This one does, three ways:
|
|
15
|
+
*
|
|
16
|
+
* 1. The server writes the mirror BECAUSE a turn ended (the `turn-stream`
|
|
17
|
+
* `end`/`turn_end` relay), so freshness is a property of the write. There
|
|
18
|
+
* is no client-side freshness test left to get wrong.
|
|
19
|
+
* 2. The payload carries OpenCode's `info` envelope VERBATIM, so
|
|
20
|
+
* `time.completed` and `error` travel with the message and every existing
|
|
21
|
+
* turn predicate reads the truth.
|
|
22
|
+
* 3. The envelope names the OpenCode ROOT it was captured from, so a mirror
|
|
23
|
+
* belonging to a re-pinned box is REFUSED rather than painted as ghosts.
|
|
24
|
+
* The disk cache was keyed by a scope string and could not make this check.
|
|
25
|
+
*
|
|
26
|
+
* Painted messages are hydrated with `source: 'cache'`, so the store's existing
|
|
27
|
+
* settle rule owns reconciliation: the first runtime read confirms every id it
|
|
28
|
+
* contains and drops any it covers but lacks. That rule is unchanged — the
|
|
29
|
+
* mirror simply gives it real OpenCode ids to settle, which is what the old
|
|
30
|
+
* cache could not guarantee (it also held optimistic stubs that never existed
|
|
31
|
+
* on the runtime).
|
|
32
|
+
*/
|
|
33
|
+
import type { Message, Part } from "@opencode-ai/sdk/v2/client";
|
|
34
|
+
import { type SessionTranscriptSyncEnvelope } from "../../core/rest/projects-client/sessions.js";
|
|
35
|
+
/** How many mirrored messages a first paint asks for. Matches the sync
|
|
36
|
+
* controller's own initial tail, so the mirror and the read that replaces it
|
|
37
|
+
* cover the same window. */
|
|
38
|
+
export declare const MIRROR_HYDRATE_LIMIT = 40;
|
|
39
|
+
export interface MirrorHydrateDecision {
|
|
40
|
+
envelope: SessionTranscriptSyncEnvelope | null;
|
|
41
|
+
/** The OpenCode root this hook is about to sync. */
|
|
42
|
+
runtimeSessionId: string;
|
|
43
|
+
/** The store already holds messages for that root. */
|
|
44
|
+
hasMessages: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* May this mirror be painted? Pure, so every refusal is a test rather than a
|
|
48
|
+
* convention.
|
|
49
|
+
*/
|
|
50
|
+
export declare function shouldHydrateFromMirror(input: MirrorHydrateDecision): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Envelope -> the exact shape `useSyncStore.hydrate` takes.
|
|
53
|
+
*
|
|
54
|
+
* A message with no `id` is DROPPED, never given one: an id the runtime will
|
|
55
|
+
* not also produce is precisely the ghost the settle rule cannot reconcile.
|
|
56
|
+
* Parts are id-sorted because the store's part lookup is a binary search that
|
|
57
|
+
* assumes its writers sorted (see `sync-store.ts`).
|
|
58
|
+
*/
|
|
59
|
+
export declare function mirrorMessagesForHydrate(envelope: SessionTranscriptSyncEnvelope): Array<{
|
|
60
|
+
info: Message;
|
|
61
|
+
parts: Part[];
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* `${projectId}/${sessionId}` — the scope string `useSessionSync` already
|
|
65
|
+
* carries for cache ownership. Parsed rather than threaded through as two more
|
|
66
|
+
* options so the hook's published signature does not change.
|
|
67
|
+
*/
|
|
68
|
+
export declare function parseKortixSessionScope(scope: string | undefined): {
|
|
69
|
+
projectId: string;
|
|
70
|
+
sessionId: string;
|
|
71
|
+
} | null;
|
|
72
|
+
/**
|
|
73
|
+
* Fetch the mirror. Never throws and never surfaces an error toast: a session
|
|
74
|
+
* that has never been captured is an ordinary answer, not a failure, and this
|
|
75
|
+
* read is an accelerator whose absence costs only the old blank wake.
|
|
76
|
+
*/
|
|
77
|
+
export declare function loadSessionTranscriptMirror(input: {
|
|
78
|
+
kortixSessionScope: string | undefined;
|
|
79
|
+
limit?: number;
|
|
80
|
+
signal?: AbortSignal;
|
|
81
|
+
}): Promise<SessionTranscriptSyncEnvelope | null>;
|
|
82
|
+
//# sourceMappingURL=server-transcript-mirror.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-transcript-mirror.d.ts","sourceRoot":"","sources":["../../../src/browser/session-sync/server-transcript-mirror.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EACN,KAAK,6BAA6B,EAElC,MAAM,0CAA0C,CAAC;AAGlD;;6BAE6B;AAC7B,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,6BAA6B,GAAG,IAAI,CAAC;IAC/C,oDAAoD;IACpD,gBAAgB,EAAE,MAAM,CAAC;IACzB,sDAAsD;IACtD,WAAW,EAAE,OAAO,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAgB7E;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACvC,QAAQ,EAAE,6BAA6B,GACrC,KAAK,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,IAAI,EAAE,CAAA;CAAE,CAAC,CAczC;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,MAAM,GAAG,SAAS,GACvB;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAQjD;AAED;;;;GAIG;AACH,wBAAsB,2BAA2B,CAAC,KAAK,EAAE;IACxD,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC,6BAA6B,GAAG,IAAI,CAAC,CAwBhD"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Painting a session's history from the SERVER's transcript mirror while its
|
|
3
|
+
* sandbox is still waking.
|
|
4
|
+
*
|
|
5
|
+
* WHAT THIS REPLACES. An IndexedDB mirror used to do this and was deleted
|
|
6
|
+
* (`5a7a43517f`) because its freshness test read the transcript's SHAPE —
|
|
7
|
+
* message count, total part count, tail id — and the two things that end a turn
|
|
8
|
+
* move none of them: `time.completed` stamped on the tail message, and the
|
|
9
|
+
* `error` a Stop stamps. A stopped thread therefore cold-painted as still
|
|
10
|
+
* running, with every message under it dimmed to "Queued".
|
|
11
|
+
* `use-session-sync.ts` records the acceptance criterion for any replacement:
|
|
12
|
+
* *it needs a mirror whose freshness test reads the MESSAGE, not its shape.*
|
|
13
|
+
*
|
|
14
|
+
* This one does, three ways:
|
|
15
|
+
*
|
|
16
|
+
* 1. The server writes the mirror BECAUSE a turn ended (the `turn-stream`
|
|
17
|
+
* `end`/`turn_end` relay), so freshness is a property of the write. There
|
|
18
|
+
* is no client-side freshness test left to get wrong.
|
|
19
|
+
* 2. The payload carries OpenCode's `info` envelope VERBATIM, so
|
|
20
|
+
* `time.completed` and `error` travel with the message and every existing
|
|
21
|
+
* turn predicate reads the truth.
|
|
22
|
+
* 3. The envelope names the OpenCode ROOT it was captured from, so a mirror
|
|
23
|
+
* belonging to a re-pinned box is REFUSED rather than painted as ghosts.
|
|
24
|
+
* The disk cache was keyed by a scope string and could not make this check.
|
|
25
|
+
*
|
|
26
|
+
* Painted messages are hydrated with `source: 'cache'`, so the store's existing
|
|
27
|
+
* settle rule owns reconciliation: the first runtime read confirms every id it
|
|
28
|
+
* contains and drops any it covers but lacks. That rule is unchanged — the
|
|
29
|
+
* mirror simply gives it real OpenCode ids to settle, which is what the old
|
|
30
|
+
* cache could not guarantee (it also held optimistic stubs that never existed
|
|
31
|
+
* on the runtime).
|
|
32
|
+
*/
|
|
33
|
+
import { getSessionTranscriptSync, } from "../../core/rest/projects-client/sessions.js";
|
|
34
|
+
import { claimOpenBundle, takeOpenBundleTranscript } from "../../core/session/open-bundle.js";
|
|
35
|
+
/** How many mirrored messages a first paint asks for. Matches the sync
|
|
36
|
+
* controller's own initial tail, so the mirror and the read that replaces it
|
|
37
|
+
* cover the same window. */
|
|
38
|
+
export const MIRROR_HYDRATE_LIMIT = 40;
|
|
39
|
+
/**
|
|
40
|
+
* May this mirror be painted? Pure, so every refusal is a test rather than a
|
|
41
|
+
* convention.
|
|
42
|
+
*/
|
|
43
|
+
export function shouldHydrateFromMirror(input) {
|
|
44
|
+
const { envelope, runtimeSessionId, hasMessages } = input;
|
|
45
|
+
if (!envelope)
|
|
46
|
+
return false;
|
|
47
|
+
// A live read outranks a snapshot, always.
|
|
48
|
+
if (hasMessages)
|
|
49
|
+
return false;
|
|
50
|
+
// No root yet means no identity to match against, so nothing can be proven
|
|
51
|
+
// about the ids in the payload.
|
|
52
|
+
if (!runtimeSessionId)
|
|
53
|
+
return false;
|
|
54
|
+
if (!envelope.available)
|
|
55
|
+
return false;
|
|
56
|
+
// `source` is the claim. An empty array is not one.
|
|
57
|
+
if (envelope.source !== "mirror")
|
|
58
|
+
return false;
|
|
59
|
+
if (envelope.messages.length === 0)
|
|
60
|
+
return false;
|
|
61
|
+
// THE IDENTITY GUARD: ids from another OpenCode root can never be settled by
|
|
62
|
+
// this root's runtime read.
|
|
63
|
+
if (envelope.opencode_session_id !== runtimeSessionId)
|
|
64
|
+
return false;
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Envelope -> the exact shape `useSyncStore.hydrate` takes.
|
|
69
|
+
*
|
|
70
|
+
* A message with no `id` is DROPPED, never given one: an id the runtime will
|
|
71
|
+
* not also produce is precisely the ghost the settle rule cannot reconcile.
|
|
72
|
+
* Parts are id-sorted because the store's part lookup is a binary search that
|
|
73
|
+
* assumes its writers sorted (see `sync-store.ts`).
|
|
74
|
+
*/
|
|
75
|
+
export function mirrorMessagesForHydrate(envelope) {
|
|
76
|
+
const out = [];
|
|
77
|
+
for (const row of envelope.messages) {
|
|
78
|
+
const info = row?.info;
|
|
79
|
+
if (!info || typeof info !== "object")
|
|
80
|
+
continue;
|
|
81
|
+
const id = typeof info.id === "string" ? info.id.trim() : "";
|
|
82
|
+
if (!id)
|
|
83
|
+
continue;
|
|
84
|
+
const parts = (Array.isArray(row.parts) ? row.parts : [])
|
|
85
|
+
.filter((p) => !!p && typeof p === "object")
|
|
86
|
+
.slice()
|
|
87
|
+
.sort((a, b) => String(a.id ?? "").localeCompare(String(b.id ?? "")));
|
|
88
|
+
out.push({ info: info, parts: parts });
|
|
89
|
+
}
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* `${projectId}/${sessionId}` — the scope string `useSessionSync` already
|
|
94
|
+
* carries for cache ownership. Parsed rather than threaded through as two more
|
|
95
|
+
* options so the hook's published signature does not change.
|
|
96
|
+
*/
|
|
97
|
+
export function parseKortixSessionScope(scope) {
|
|
98
|
+
if (!scope)
|
|
99
|
+
return null;
|
|
100
|
+
const slash = scope.indexOf("/");
|
|
101
|
+
if (slash <= 0 || slash === scope.length - 1)
|
|
102
|
+
return null;
|
|
103
|
+
const projectId = scope.slice(0, slash);
|
|
104
|
+
const sessionId = scope.slice(slash + 1);
|
|
105
|
+
if (!projectId || !sessionId || sessionId.includes("/"))
|
|
106
|
+
return null;
|
|
107
|
+
return { projectId, sessionId };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Fetch the mirror. Never throws and never surfaces an error toast: a session
|
|
111
|
+
* that has never been captured is an ordinary answer, not a failure, and this
|
|
112
|
+
* read is an accelerator whose absence costs only the old blank wake.
|
|
113
|
+
*/
|
|
114
|
+
export async function loadSessionTranscriptMirror(input) {
|
|
115
|
+
const scope = parseKortixSessionScope(input.kortixSessionScope);
|
|
116
|
+
if (!scope)
|
|
117
|
+
return null;
|
|
118
|
+
// The SESSION-OPEN BUNDLE fetches this mirror in the same round trip that
|
|
119
|
+
// answers the turn and the queue. This hydrate runs at MOUNT, while that
|
|
120
|
+
// read is still in flight, so it waits for the read it is riding rather
|
|
121
|
+
// than starting a second one — the wait costs nothing (the bundle is
|
|
122
|
+
// already on the wire) and saves a full transcript request per open.
|
|
123
|
+
//
|
|
124
|
+
// The stash is ONE-SHOT: this is the only reader allowed to paint a
|
|
125
|
+
// snapshot, and a second paint over a store the runtime has already filled
|
|
126
|
+
// is how a transcript grows ghosts.
|
|
127
|
+
const claimed = claimOpenBundle(scope.projectId, scope.sessionId);
|
|
128
|
+
if (claimed)
|
|
129
|
+
await claimed;
|
|
130
|
+
const stashed = takeOpenBundleTranscript(scope.projectId, scope.sessionId);
|
|
131
|
+
if (stashed)
|
|
132
|
+
return stashed;
|
|
133
|
+
try {
|
|
134
|
+
return await getSessionTranscriptSync(scope.projectId, scope.sessionId, {
|
|
135
|
+
limit: input.limit ?? MIRROR_HYDRATE_LIMIT,
|
|
136
|
+
signal: input.signal,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=server-transcript-mirror.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-transcript-mirror.js","sourceRoot":"","sources":["../../../src/browser/session-sync/server-transcript-mirror.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAG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C;IACrE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AACjC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,KAIjD;IACA,MAAM,KAAK,GAAG,uBAAuB,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAChE,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,0EAA0E;IAC1E,yEAAyE;IACzE,wEAAwE;IACxE,qEAAqE;IACrE,qEAAqE;IACrE,EAAE;IACF,oEAAoE;IACpE,2EAA2E;IAC3E,oCAAoC;IACpC,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAClE,IAAI,OAAO;QAAE,MAAM,OAAO,CAAC;IAC3B,MAAM,OAAO,GAAG,wBAAwB,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC3E,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAC5B,IAAI,CAAC;QACJ,OAAO,MAAM,wBAAwB,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE;YACvE,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,oBAAoB;YAC1C,MAAM,EAAE,KAAK,CAAC,MAAM;SACpB,CAAC,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC"}
|
|
@@ -5,6 +5,14 @@ interface MessagesResponse {
|
|
|
5
5
|
info: Message;
|
|
6
6
|
parts: Part[];
|
|
7
7
|
}>;
|
|
8
|
+
/**
|
|
9
|
+
* The generated OpenCode client RESOLVES with `{ error }` on a non-2xx
|
|
10
|
+
* response — it never throws unless the caller opted into `throwOnError`, and
|
|
11
|
+
* we do not. So the ONLY place a 503 or a runtime failure is visible is here.
|
|
12
|
+
* Reading `data ?? []` and ignoring this is exactly how a cold-boot 503
|
|
13
|
+
* became a success-looking empty page.
|
|
14
|
+
*/
|
|
15
|
+
error?: unknown;
|
|
8
16
|
response?: Response;
|
|
9
17
|
}
|
|
10
18
|
interface SessionMessageClient {
|
|
@@ -13,6 +21,8 @@ interface SessionMessageClient {
|
|
|
13
21
|
sessionID: string;
|
|
14
22
|
limit: number;
|
|
15
23
|
before?: string;
|
|
24
|
+
}, options?: {
|
|
25
|
+
signal?: AbortSignal;
|
|
16
26
|
}) => Promise<MessagesResponse>;
|
|
17
27
|
status?: () => Promise<{
|
|
18
28
|
data?: Record<string, SessionStatus>;
|
|
@@ -24,7 +34,7 @@ type SessionPrefetchSource = string | typeof ACTIVE_SESSION_PREFETCH_SOURCE;
|
|
|
24
34
|
export declare function readSessionMessagePage(client: SessionMessageClient, sessionId: string, request: {
|
|
25
35
|
limit: number;
|
|
26
36
|
before?: string;
|
|
27
|
-
}): Promise<SessionSyncPage>;
|
|
37
|
+
}, signal?: AbortSignal): Promise<SessionSyncPage>;
|
|
28
38
|
export declare function getSessionSyncController(sessionId: string, client?: SessionMessageClient, runtimeScope?: string): SessionSyncController;
|
|
29
39
|
export declare function prefetchSessionSyncOnce(sessionId: string, source: SessionPrefetchSource, client?: SessionMessageClient): Promise<boolean>;
|
|
30
40
|
export declare function clearActiveSessionPrefetches(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-sync-registry.d.ts","sourceRoot":"","sources":["../../../src/browser/session-sync/session-sync-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"session-sync-registry.d.ts","sourceRoot":"","sources":["../../../src/browser/session-sync/session-sync-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG/E,OAAO,EACL,qBAAqB,EACrB,KAAK,eAAe,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