@kortix/sdk 0.9.98
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 +313 -0
- package/dist/files/client.d.ts +96 -0
- package/dist/files/client.d.ts.map +1 -0
- package/dist/files/client.js +346 -0
- package/dist/files/client.js.map +1 -0
- package/dist/files/types.d.ts +82 -0
- package/dist/files/types.d.ts.map +1 -0
- package/dist/files/types.js +6 -0
- package/dist/files/types.js.map +1 -0
- package/dist/index.d.ts +119 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +93 -0
- package/dist/index.js.map +1 -0
- package/dist/kortix.d.ts +897 -0
- package/dist/kortix.d.ts.map +1 -0
- package/dist/kortix.js +772 -0
- package/dist/kortix.js.map +1 -0
- package/dist/opencode/client.d.ts +89 -0
- package/dist/opencode/client.d.ts.map +1 -0
- package/dist/opencode/client.js +191 -0
- package/dist/opencode/client.js.map +1 -0
- package/dist/opencode/env.d.ts +13 -0
- package/dist/opencode/env.d.ts.map +1 -0
- package/dist/opencode/env.js +63 -0
- package/dist/opencode/env.js.map +1 -0
- package/dist/opencode/kortix-master.d.ts +487 -0
- package/dist/opencode/kortix-master.d.ts.map +1 -0
- package/dist/opencode/kortix-master.js +313 -0
- package/dist/opencode/kortix-master.js.map +1 -0
- package/dist/opencode/triggers.d.ts +6 -0
- package/dist/opencode/triggers.d.ts.map +1 -0
- package/dist/opencode/triggers.js +34 -0
- package/dist/opencode/triggers.js.map +1 -0
- package/dist/platform/api/errors.d.ts +106 -0
- package/dist/platform/api/errors.d.ts.map +1 -0
- package/dist/platform/api/errors.js +137 -0
- package/dist/platform/api/errors.js.map +1 -0
- package/dist/platform/api-client.d.ts +35 -0
- package/dist/platform/api-client.d.ts.map +1 -0
- package/dist/platform/api-client.js +279 -0
- package/dist/platform/api-client.js.map +1 -0
- package/dist/platform/auth-core.d.ts +60 -0
- package/dist/platform/auth-core.d.ts.map +1 -0
- package/dist/platform/auth-core.js +104 -0
- package/dist/platform/auth-core.js.map +1 -0
- package/dist/platform/auth.d.ts +88 -0
- package/dist/platform/auth.d.ts.map +1 -0
- package/dist/platform/auth.js +161 -0
- package/dist/platform/auth.js.map +1 -0
- package/dist/platform/config-node.d.ts +33 -0
- package/dist/platform/config-node.d.ts.map +1 -0
- package/dist/platform/config-node.js +63 -0
- package/dist/platform/config-node.js.map +1 -0
- package/dist/platform/config.d.ts +77 -0
- package/dist/platform/config.d.ts.map +1 -0
- package/dist/platform/config.js +62 -0
- package/dist/platform/config.js.map +1 -0
- package/dist/platform/feature-flags.d.ts +25 -0
- package/dist/platform/feature-flags.d.ts.map +1 -0
- package/dist/platform/feature-flags.js +114 -0
- package/dist/platform/feature-flags.js.map +1 -0
- package/dist/platform/fresh-sessions.d.ts +4 -0
- package/dist/platform/fresh-sessions.d.ts.map +1 -0
- package/dist/platform/fresh-sessions.js +22 -0
- package/dist/platform/fresh-sessions.js.map +1 -0
- package/dist/platform/instance-routes.d.ts +17 -0
- package/dist/platform/instance-routes.d.ts.map +1 -0
- package/dist/platform/instance-routes.js +105 -0
- package/dist/platform/instance-routes.js.map +1 -0
- package/dist/platform/logger.d.ts +20 -0
- package/dist/platform/logger.d.ts.map +1 -0
- package/dist/platform/logger.js +44 -0
- package/dist/platform/logger.js.map +1 -0
- package/dist/platform/opencode-errors.d.ts +20 -0
- package/dist/platform/opencode-errors.d.ts.map +1 -0
- package/dist/platform/opencode-errors.js +71 -0
- package/dist/platform/opencode-errors.js.map +1 -0
- package/dist/platform/platform-client/backups.d.ts +22 -0
- package/dist/platform/platform-client/backups.d.ts.map +1 -0
- package/dist/platform/platform-client/backups.js +16 -0
- package/dist/platform/platform-client/backups.js.map +1 -0
- package/dist/platform/platform-client/index.d.ts +21 -0
- package/dist/platform/platform-client/index.d.ts.map +1 -0
- package/dist/platform/platform-client/index.js +21 -0
- package/dist/platform/platform-client/index.js.map +1 -0
- package/dist/platform/platform-client/instance-admin.d.ts +67 -0
- package/dist/platform/platform-client/instance-admin.d.ts.map +1 -0
- package/dist/platform/platform-client/instance-admin.js +59 -0
- package/dist/platform/platform-client/instance-admin.js.map +1 -0
- package/dist/platform/platform-client/invites.d.ts +35 -0
- package/dist/platform/platform-client/invites.d.ts.map +1 -0
- package/dist/platform/platform-client/invites.js +25 -0
- package/dist/platform/platform-client/invites.js.map +1 -0
- package/dist/platform/platform-client/lifecycle.d.ts +78 -0
- package/dist/platform/platform-client/lifecycle.d.ts.map +1 -0
- package/dist/platform/platform-client/lifecycle.js +151 -0
- package/dist/platform/platform-client/lifecycle.js.map +1 -0
- package/dist/platform/platform-client/members.d.ts +81 -0
- package/dist/platform/platform-client/members.d.ts.map +1 -0
- package/dist/platform/platform-client/members.js +59 -0
- package/dist/platform/platform-client/members.js.map +1 -0
- package/dist/platform/platform-client/shared.d.ts +44 -0
- package/dist/platform/platform-client/shared.d.ts.map +1 -0
- package/dist/platform/platform-client/shared.js +177 -0
- package/dist/platform/platform-client/shared.js.map +1 -0
- package/dist/platform/platform-client/ssh.d.ts +29 -0
- package/dist/platform/platform-client/ssh.d.ts.map +1 -0
- package/dist/platform/platform-client/ssh.js +14 -0
- package/dist/platform/platform-client/ssh.js.map +1 -0
- package/dist/platform/platform-client/types.d.ts +56 -0
- package/dist/platform/platform-client/types.d.ts.map +1 -0
- package/dist/platform/platform-client/types.js +19 -0
- package/dist/platform/platform-client/types.js.map +1 -0
- package/dist/platform/platform-client/updates.d.ts +117 -0
- package/dist/platform/platform-client/updates.d.ts.map +1 -0
- package/dist/platform/platform-client/updates.js +97 -0
- package/dist/platform/platform-client/updates.js.map +1 -0
- package/dist/platform/platform-client/urls.d.ts +18 -0
- package/dist/platform/platform-client/urls.d.ts.map +1 -0
- package/dist/platform/platform-client/urls.js +31 -0
- package/dist/platform/platform-client/urls.js.map +1 -0
- package/dist/platform/projects-client/access.d.ts +273 -0
- package/dist/platform/projects-client/access.d.ts.map +1 -0
- package/dist/platform/projects-client/access.js +89 -0
- package/dist/platform/projects-client/access.js.map +1 -0
- package/dist/platform/projects-client/accounts.d.ts +184 -0
- package/dist/platform/projects-client/accounts.d.ts.map +1 -0
- package/dist/platform/projects-client/accounts.js +78 -0
- package/dist/platform/projects-client/accounts.js.map +1 -0
- package/dist/platform/projects-client/agent-config.d.ts +58 -0
- package/dist/platform/projects-client/agent-config.d.ts.map +1 -0
- package/dist/platform/projects-client/agent-config.js +9 -0
- package/dist/platform/projects-client/agent-config.js.map +1 -0
- package/dist/platform/projects-client/agent-scope.d.ts +12 -0
- package/dist/platform/projects-client/agent-scope.d.ts.map +1 -0
- package/dist/platform/projects-client/agent-scope.js +6 -0
- package/dist/platform/projects-client/agent-scope.js.map +1 -0
- package/dist/platform/projects-client/apps.d.ts +98 -0
- package/dist/platform/projects-client/apps.d.ts.map +1 -0
- package/dist/platform/projects-client/apps.js +29 -0
- package/dist/platform/projects-client/apps.js.map +1 -0
- package/dist/platform/projects-client/audit.d.ts +85 -0
- package/dist/platform/projects-client/audit.d.ts.map +1 -0
- package/dist/platform/projects-client/audit.js +51 -0
- package/dist/platform/projects-client/audit.js.map +1 -0
- package/dist/platform/projects-client/billing.d.ts +336 -0
- package/dist/platform/projects-client/billing.d.ts.map +1 -0
- package/dist/platform/projects-client/billing.js +260 -0
- package/dist/platform/projects-client/billing.js.map +1 -0
- package/dist/platform/projects-client/change-requests.d.ts +119 -0
- package/dist/platform/projects-client/change-requests.d.ts.map +1 -0
- package/dist/platform/projects-client/change-requests.js +56 -0
- package/dist/platform/projects-client/change-requests.js.map +1 -0
- package/dist/platform/projects-client/channels.d.ts +135 -0
- package/dist/platform/projects-client/channels.d.ts.map +1 -0
- package/dist/platform/projects-client/channels.js +103 -0
- package/dist/platform/projects-client/channels.js.map +1 -0
- package/dist/platform/projects-client/connectors.d.ts +148 -0
- package/dist/platform/projects-client/connectors.d.ts.map +1 -0
- package/dist/platform/projects-client/connectors.js +66 -0
- package/dist/platform/projects-client/connectors.js.map +1 -0
- package/dist/platform/projects-client/files.d.ts +37 -0
- package/dist/platform/projects-client/files.d.ts.map +1 -0
- package/dist/platform/projects-client/files.js +58 -0
- package/dist/platform/projects-client/files.js.map +1 -0
- package/dist/platform/projects-client/gateway.d.ts +177 -0
- package/dist/platform/projects-client/gateway.d.ts.map +1 -0
- package/dist/platform/projects-client/gateway.js +59 -0
- package/dist/platform/projects-client/gateway.js.map +1 -0
- package/dist/platform/projects-client/git-history.d.ts +74 -0
- package/dist/platform/projects-client/git-history.d.ts.map +1 -0
- package/dist/platform/projects-client/git-history.js +40 -0
- package/dist/platform/projects-client/git-history.js.map +1 -0
- package/dist/platform/projects-client/github.d.ts +62 -0
- package/dist/platform/projects-client/github.d.ts.map +1 -0
- package/dist/platform/projects-client/github.js +30 -0
- package/dist/platform/projects-client/github.js.map +1 -0
- package/dist/platform/projects-client/index.d.ts +32 -0
- package/dist/platform/projects-client/index.d.ts.map +1 -0
- package/dist/platform/projects-client/index.js +34 -0
- package/dist/platform/projects-client/index.js.map +1 -0
- package/dist/platform/projects-client/marketplace-catalog.d.ts +76 -0
- package/dist/platform/projects-client/marketplace-catalog.d.ts.map +1 -0
- package/dist/platform/projects-client/marketplace-catalog.js +48 -0
- package/dist/platform/projects-client/marketplace-catalog.js.map +1 -0
- package/dist/platform/projects-client/marketplace.d.ts +80 -0
- package/dist/platform/projects-client/marketplace.d.ts.map +1 -0
- package/dist/platform/projects-client/marketplace.js +52 -0
- package/dist/platform/projects-client/marketplace.js.map +1 -0
- package/dist/platform/projects-client/model-defaults.d.ts +36 -0
- package/dist/platform/projects-client/model-defaults.d.ts.map +1 -0
- package/dist/platform/projects-client/model-defaults.js +16 -0
- package/dist/platform/projects-client/model-defaults.js.map +1 -0
- package/dist/platform/projects-client/policies.d.ts +21 -0
- package/dist/platform/projects-client/policies.d.ts.map +1 -0
- package/dist/platform/projects-client/policies.js +10 -0
- package/dist/platform/projects-client/policies.js.map +1 -0
- package/dist/platform/projects-client/projects.d.ts +235 -0
- package/dist/platform/projects-client/projects.d.ts.map +1 -0
- package/dist/platform/projects-client/projects.js +161 -0
- package/dist/platform/projects-client/projects.js.map +1 -0
- package/dist/platform/projects-client/public-session-shares.d.ts +52 -0
- package/dist/platform/projects-client/public-session-shares.d.ts.map +1 -0
- package/dist/platform/projects-client/public-session-shares.js +54 -0
- package/dist/platform/projects-client/public-session-shares.js.map +1 -0
- package/dist/platform/projects-client/review.d.ts +57 -0
- package/dist/platform/projects-client/review.d.ts.map +1 -0
- package/dist/platform/projects-client/review.js +28 -0
- package/dist/platform/projects-client/review.js.map +1 -0
- package/dist/platform/projects-client/sandbox-shares.d.ts +25 -0
- package/dist/platform/projects-client/sandbox-shares.d.ts.map +1 -0
- package/dist/platform/projects-client/sandbox-shares.js +29 -0
- package/dist/platform/projects-client/sandbox-shares.js.map +1 -0
- package/dist/platform/projects-client/sandbox.d.ts +123 -0
- package/dist/platform/projects-client/sandbox.d.ts.map +1 -0
- package/dist/platform/projects-client/sandbox.js +45 -0
- package/dist/platform/projects-client/sandbox.js.map +1 -0
- package/dist/platform/projects-client/secrets.d.ts +122 -0
- package/dist/platform/projects-client/secrets.d.ts.map +1 -0
- package/dist/platform/projects-client/secrets.js +34 -0
- package/dist/platform/projects-client/secrets.js.map +1 -0
- package/dist/platform/projects-client/session-sandbox.d.ts +61 -0
- package/dist/platform/projects-client/session-sandbox.d.ts.map +1 -0
- package/dist/platform/projects-client/session-sandbox.js +82 -0
- package/dist/platform/projects-client/session-sandbox.js.map +1 -0
- package/dist/platform/projects-client/sessions.d.ts +216 -0
- package/dist/platform/projects-client/sessions.d.ts.map +1 -0
- package/dist/platform/projects-client/sessions.js +74 -0
- package/dist/platform/projects-client/sessions.js.map +1 -0
- package/dist/platform/projects-client/setup-links.d.ts +35 -0
- package/dist/platform/projects-client/setup-links.d.ts.map +1 -0
- package/dist/platform/projects-client/setup-links.js +24 -0
- package/dist/platform/projects-client/setup-links.js.map +1 -0
- package/dist/platform/projects-client/shared.d.ts +66 -0
- package/dist/platform/projects-client/shared.d.ts.map +1 -0
- package/dist/platform/projects-client/shared.js +44 -0
- package/dist/platform/projects-client/shared.js.map +1 -0
- package/dist/platform/projects-client/tokens.d.ts +77 -0
- package/dist/platform/projects-client/tokens.d.ts.map +1 -0
- package/dist/platform/projects-client/tokens.js +43 -0
- package/dist/platform/projects-client/tokens.js.map +1 -0
- package/dist/platform/projects-client/transcription.d.ts +5 -0
- package/dist/platform/projects-client/transcription.d.ts.map +1 -0
- package/dist/platform/projects-client/transcription.js +14 -0
- package/dist/platform/projects-client/transcription.js.map +1 -0
- package/dist/platform/projects-client/triggers.d.ts +102 -0
- package/dist/platform/projects-client/triggers.d.ts.map +1 -0
- package/dist/platform/projects-client/triggers.js +27 -0
- package/dist/platform/projects-client/triggers.js.map +1 -0
- package/dist/platform/session-id.d.ts +9 -0
- package/dist/platform/session-id.d.ts.map +1 -0
- package/dist/platform/session-id.js +23 -0
- package/dist/platform/session-id.js.map +1 -0
- package/dist/platform/storage/managed-storage.d.ts +97 -0
- package/dist/platform/storage/managed-storage.d.ts.map +1 -0
- package/dist/platform/storage/managed-storage.js +271 -0
- package/dist/platform/storage/managed-storage.js.map +1 -0
- package/dist/platform/strings.d.ts +12 -0
- package/dist/platform/strings.d.ts.map +1 -0
- package/dist/platform/strings.js +17 -0
- package/dist/platform/strings.js.map +1 -0
- package/dist/platform/ui.d.ts +11 -0
- package/dist/platform/ui.d.ts.map +1 -0
- package/dist/platform/ui.js +22 -0
- package/dist/platform/ui.js.map +1 -0
- package/dist/react/chat/index.d.ts +3 -0
- package/dist/react/chat/index.d.ts.map +1 -0
- package/dist/react/chat/index.js +7 -0
- package/dist/react/chat/index.js.map +1 -0
- package/dist/react/chat/render-parts.d.ts +39 -0
- package/dist/react/chat/render-parts.d.ts.map +1 -0
- package/dist/react/chat/render-parts.js +34 -0
- package/dist/react/chat/render-parts.js.map +1 -0
- package/dist/react/chat/use-chat-turns.d.ts +19 -0
- package/dist/react/chat/use-chat-turns.d.ts.map +1 -0
- package/dist/react/chat/use-chat-turns.js +27 -0
- package/dist/react/chat/use-chat-turns.js.map +1 -0
- package/dist/react/file-keys.d.ts +18 -0
- package/dist/react/file-keys.d.ts.map +1 -0
- package/dist/react/file-keys.js +18 -0
- package/dist/react/file-keys.js.map +1 -0
- package/dist/react/index.d.ts +12 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +49 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/model-flatten.d.ts +33 -0
- package/dist/react/model-flatten.d.ts.map +1 -0
- package/dist/react/model-flatten.js +59 -0
- package/dist/react/model-flatten.js.map +1 -0
- package/dist/react/opencode.d.ts +43 -0
- package/dist/react/opencode.d.ts.map +1 -0
- package/dist/react/opencode.js +100 -0
- package/dist/react/opencode.js.map +1 -0
- package/dist/react/prefetch-session-start.d.ts +10 -0
- package/dist/react/prefetch-session-start.d.ts.map +1 -0
- package/dist/react/prefetch-session-start.js +17 -0
- package/dist/react/prefetch-session-start.js.map +1 -0
- package/dist/react/provider-refresh.d.ts +7 -0
- package/dist/react/provider-refresh.d.ts.map +1 -0
- package/dist/react/provider-refresh.js +28 -0
- package/dist/react/provider-refresh.js.map +1 -0
- package/dist/react/provider-selection.d.ts +31 -0
- package/dist/react/provider-selection.d.ts.map +1 -0
- package/dist/react/provider-selection.js +135 -0
- package/dist/react/provider-selection.js.map +1 -0
- package/dist/react/route-project.d.ts +7 -0
- package/dist/react/route-project.d.ts.map +1 -0
- package/dist/react/route-project.js +19 -0
- package/dist/react/route-project.js.map +1 -0
- package/dist/react/session-start-stash.d.ts +56 -0
- package/dist/react/session-start-stash.d.ts.map +1 -0
- package/dist/react/session-start-stash.js +202 -0
- package/dist/react/session-start-stash.js.map +1 -0
- package/dist/react/use-canonical-opencode-session.d.ts +35 -0
- package/dist/react/use-canonical-opencode-session.d.ts.map +1 -0
- package/dist/react/use-canonical-opencode-session.js +52 -0
- package/dist/react/use-canonical-opencode-session.js.map +1 -0
- package/dist/react/use-change-requests.d.ts +321 -0
- package/dist/react/use-change-requests.d.ts.map +1 -0
- package/dist/react/use-change-requests.js +43 -0
- package/dist/react/use-change-requests.js.map +1 -0
- package/dist/react/use-current-runtime.d.ts +8 -0
- package/dist/react/use-current-runtime.d.ts.map +1 -0
- package/dist/react/use-current-runtime.js +12 -0
- package/dist/react/use-current-runtime.js.map +1 -0
- package/dist/react/use-gateway-catalog-sync.d.ts +2 -0
- package/dist/react/use-gateway-catalog-sync.d.ts.map +1 -0
- package/dist/react/use-gateway-catalog-sync.js +39 -0
- package/dist/react/use-gateway-catalog-sync.js.map +1 -0
- package/dist/react/use-kortix-master.d.ts +384 -0
- package/dist/react/use-kortix-master.d.ts.map +1 -0
- package/dist/react/use-kortix-master.js +958 -0
- package/dist/react/use-kortix-master.js.map +1 -0
- package/dist/react/use-model-store.d.ts +71 -0
- package/dist/react/use-model-store.d.ts.map +1 -0
- package/dist/react/use-model-store.js +411 -0
- package/dist/react/use-model-store.js.map +1 -0
- package/dist/react/use-opencode-config.d.ts +15 -0
- package/dist/react/use-opencode-config.d.ts.map +1 -0
- package/dist/react/use-opencode-config.js +79 -0
- package/dist/react/use-opencode-config.js.map +1 -0
- package/dist/react/use-opencode-events/diagnostics.d.ts +11 -0
- package/dist/react/use-opencode-events/diagnostics.d.ts.map +1 -0
- package/dist/react/use-opencode-events/diagnostics.js +58 -0
- package/dist/react/use-opencode-events/diagnostics.js.map +1 -0
- package/dist/react/use-opencode-events/handle-event.d.ts +20 -0
- package/dist/react/use-opencode-events/handle-event.d.ts.map +1 -0
- package/dist/react/use-opencode-events/handle-event.js +450 -0
- package/dist/react/use-opencode-events/handle-event.js.map +1 -0
- package/dist/react/use-opencode-events/helpers.d.ts +30 -0
- package/dist/react/use-opencode-events/helpers.d.ts.map +1 -0
- package/dist/react/use-opencode-events/helpers.js +93 -0
- package/dist/react/use-opencode-events/helpers.js.map +1 -0
- package/dist/react/use-opencode-events/index.d.ts +25 -0
- package/dist/react/use-opencode-events/index.d.ts.map +1 -0
- package/dist/react/use-opencode-events/index.js +242 -0
- package/dist/react/use-opencode-events/index.js.map +1 -0
- package/dist/react/use-opencode-events/types.d.ts +10 -0
- package/dist/react/use-opencode-events/types.d.ts.map +1 -0
- package/dist/react/use-opencode-events/types.js +2 -0
- package/dist/react/use-opencode-events/types.js.map +1 -0
- package/dist/react/use-opencode-events/use-event-stream-refs.d.ts +22 -0
- package/dist/react/use-opencode-events/use-event-stream-refs.d.ts.map +1 -0
- package/dist/react/use-opencode-events/use-event-stream-refs.js +158 -0
- package/dist/react/use-opencode-events/use-event-stream-refs.js.map +1 -0
- package/dist/react/use-opencode-local.d.ts +139 -0
- package/dist/react/use-opencode-local.d.ts.map +1 -0
- package/dist/react/use-opencode-local.js +484 -0
- package/dist/react/use-opencode-local.js.map +1 -0
- package/dist/react/use-opencode-mcp.d.ts +34 -0
- package/dist/react/use-opencode-mcp.d.ts.map +1 -0
- package/dist/react/use-opencode-mcp.js +190 -0
- package/dist/react/use-opencode-mcp.js.map +1 -0
- package/dist/react/use-opencode-pty.d.ts +30 -0
- package/dist/react/use-opencode-pty.d.ts.map +1 -0
- package/dist/react/use-opencode-pty.js +126 -0
- package/dist/react/use-opencode-pty.js.map +1 -0
- package/dist/react/use-opencode-sessions/agents.d.ts +14 -0
- package/dist/react/use-opencode-sessions/agents.d.ts.map +1 -0
- package/dist/react/use-opencode-sessions/agents.js +82 -0
- package/dist/react/use-opencode-sessions/agents.js.map +1 -0
- package/dist/react/use-opencode-sessions/commands.d.ts +8 -0
- package/dist/react/use-opencode-sessions/commands.d.ts.map +1 -0
- package/dist/react/use-opencode-sessions/commands.js +46 -0
- package/dist/react/use-opencode-sessions/commands.js.map +1 -0
- package/dist/react/use-opencode-sessions/files.d.ts +2 -0
- package/dist/react/use-opencode-sessions/files.d.ts.map +1 -0
- package/dist/react/use-opencode-sessions/files.js +181 -0
- package/dist/react/use-opencode-sessions/files.js.map +1 -0
- package/dist/react/use-opencode-sessions/index.d.ts +15 -0
- package/dist/react/use-opencode-sessions/index.d.ts.map +1 -0
- package/dist/react/use-opencode-sessions/index.js +21 -0
- package/dist/react/use-opencode-sessions/index.js.map +1 -0
- package/dist/react/use-opencode-sessions/keys.d.ts +94 -0
- package/dist/react/use-opencode-sessions/keys.d.ts.map +1 -0
- package/dist/react/use-opencode-sessions/keys.js +39 -0
- package/dist/react/use-opencode-sessions/keys.js.map +1 -0
- package/dist/react/use-opencode-sessions/mcp.d.ts +3 -0
- package/dist/react/use-opencode-sessions/mcp.d.ts.map +1 -0
- package/dist/react/use-opencode-sessions/mcp.js +23 -0
- package/dist/react/use-opencode-sessions/mcp.js.map +1 -0
- package/dist/react/use-opencode-sessions/messages.d.ts +75 -0
- package/dist/react/use-opencode-sessions/messages.d.ts.map +1 -0
- package/dist/react/use-opencode-sessions/messages.js +319 -0
- package/dist/react/use-opencode-sessions/messages.js.map +1 -0
- package/dist/react/use-opencode-sessions/parts.d.ts +23 -0
- package/dist/react/use-opencode-sessions/parts.d.ts.map +1 -0
- package/dist/react/use-opencode-sessions/parts.js +49 -0
- package/dist/react/use-opencode-sessions/parts.js.map +1 -0
- package/dist/react/use-opencode-sessions/permissions.d.ts +17 -0
- package/dist/react/use-opencode-sessions/permissions.d.ts.map +1 -0
- package/dist/react/use-opencode-sessions/permissions.js +66 -0
- package/dist/react/use-opencode-sessions/permissions.js.map +1 -0
- package/dist/react/use-opencode-sessions/projects.d.ts +5 -0
- package/dist/react/use-opencode-sessions/projects.d.ts.map +1 -0
- package/dist/react/use-opencode-sessions/projects.js +54 -0
- package/dist/react/use-opencode-sessions/projects.js.map +1 -0
- package/dist/react/use-opencode-sessions/providers.d.ts +10 -0
- package/dist/react/use-opencode-sessions/providers.d.ts.map +1 -0
- package/dist/react/use-opencode-sessions/providers.js +98 -0
- package/dist/react/use-opencode-sessions/providers.js.map +1 -0
- package/dist/react/use-opencode-sessions/sessions.d.ts +35 -0
- package/dist/react/use-opencode-sessions/sessions.d.ts.map +1 -0
- package/dist/react/use-opencode-sessions/sessions.js +380 -0
- package/dist/react/use-opencode-sessions/sessions.js.map +1 -0
- package/dist/react/use-opencode-sessions/shared.d.ts +43 -0
- package/dist/react/use-opencode-sessions/shared.d.ts.map +1 -0
- package/dist/react/use-opencode-sessions/shared.js +109 -0
- package/dist/react/use-opencode-sessions/shared.js.map +1 -0
- package/dist/react/use-opencode-sessions/sharing.d.ts +4 -0
- package/dist/react/use-opencode-sessions/sharing.d.ts.map +1 -0
- package/dist/react/use-opencode-sessions/sharing.js +57 -0
- package/dist/react/use-opencode-sessions/sharing.js.map +1 -0
- package/dist/react/use-opencode-sessions/tools.d.ts +5 -0
- package/dist/react/use-opencode-sessions/tools.d.ts.map +1 -0
- package/dist/react/use-opencode-sessions/tools.js +54 -0
- package/dist/react/use-opencode-sessions/tools.js.map +1 -0
- package/dist/react/use-permission-self-heal.d.ts +45 -0
- package/dist/react/use-permission-self-heal.d.ts.map +1 -0
- package/dist/react/use-permission-self-heal.js +144 -0
- package/dist/react/use-permission-self-heal.js.map +1 -0
- package/dist/react/use-project-config.d.ts +11 -0
- package/dist/react/use-project-config.d.ts.map +1 -0
- package/dist/react/use-project-config.js +22 -0
- package/dist/react/use-project-config.js.map +1 -0
- package/dist/react/use-project-models.d.ts +11 -0
- package/dist/react/use-project-models.d.ts.map +1 -0
- package/dist/react/use-project-models.js +25 -0
- package/dist/react/use-project-models.js.map +1 -0
- package/dist/react/use-project-secrets.d.ts +265 -0
- package/dist/react/use-project-secrets.d.ts.map +1 -0
- package/dist/react/use-project-secrets.js +41 -0
- package/dist/react/use-project-secrets.js.map +1 -0
- package/dist/react/use-project-triggers.d.ts +228 -0
- package/dist/react/use-project-triggers.d.ts.map +1 -0
- package/dist/react/use-project-triggers.js +42 -0
- package/dist/react/use-project-triggers.js.map +1 -0
- package/dist/react/use-question-self-heal.d.ts +36 -0
- package/dist/react/use-question-self-heal.d.ts.map +1 -0
- package/dist/react/use-question-self-heal.js +95 -0
- package/dist/react/use-question-self-heal.js.map +1 -0
- package/dist/react/use-runtime-phase.d.ts +9 -0
- package/dist/react/use-runtime-phase.d.ts.map +1 -0
- package/dist/react/use-runtime-phase.js +20 -0
- package/dist/react/use-runtime-phase.js.map +1 -0
- package/dist/react/use-runtime-reconnect.d.ts +90 -0
- package/dist/react/use-runtime-reconnect.d.ts.map +1 -0
- package/dist/react/use-runtime-reconnect.js +234 -0
- package/dist/react/use-runtime-reconnect.js.map +1 -0
- package/dist/react/use-session-picks.d.ts +17 -0
- package/dist/react/use-session-picks.d.ts.map +1 -0
- package/dist/react/use-session-picks.js +36 -0
- package/dist/react/use-session-picks.js.map +1 -0
- package/dist/react/use-session-prefetch.d.ts +18 -0
- package/dist/react/use-session-prefetch.d.ts.map +1 -0
- package/dist/react/use-session-prefetch.js +84 -0
- package/dist/react/use-session-prefetch.js.map +1 -0
- package/dist/react/use-session-send.d.ts +183 -0
- package/dist/react/use-session-send.d.ts.map +1 -0
- package/dist/react/use-session-send.js +287 -0
- package/dist/react/use-session-send.js.map +1 -0
- package/dist/react/use-session-sync.d.ts +24 -0
- package/dist/react/use-session-sync.d.ts.map +1 -0
- package/dist/react/use-session-sync.js +375 -0
- package/dist/react/use-session-sync.js.map +1 -0
- package/dist/react/use-session.d.ts +171 -0
- package/dist/react/use-session.d.ts.map +1 -0
- package/dist/react/use-session.js +396 -0
- package/dist/react/use-session.js.map +1 -0
- package/dist/react/use-visible-agents.d.ts +22 -0
- package/dist/react/use-visible-agents.d.ts.map +1 -0
- package/dist/react/use-visible-agents.js +45 -0
- package/dist/react/use-visible-agents.js.map +1 -0
- package/dist/server.d.ts +55 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +122 -0
- package/dist/server.js.map +1 -0
- package/dist/session/health.d.ts +49 -0
- package/dist/session/health.d.ts.map +1 -0
- package/dist/session/health.js +57 -0
- package/dist/session/health.js.map +1 -0
- package/dist/session/index.d.ts +19 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +19 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/preview.d.ts +24 -0
- package/dist/session/preview.d.ts.map +1 -0
- package/dist/session/preview.js +85 -0
- package/dist/session/preview.js.map +1 -0
- package/dist/session/url.d.ts +160 -0
- package/dist/session/url.d.ts.map +1 -0
- package/dist/session/url.js +522 -0
- package/dist/session/url.js.map +1 -0
- package/dist/state/chat-events.d.ts +141 -0
- package/dist/state/chat-events.d.ts.map +1 -0
- package/dist/state/chat-events.js +135 -0
- package/dist/state/chat-events.js.map +1 -0
- package/dist/state/current-runtime.d.ts +44 -0
- package/dist/state/current-runtime.d.ts.map +1 -0
- package/dist/state/current-runtime.js +44 -0
- package/dist/state/current-runtime.js.map +1 -0
- package/dist/state/diagnostics-store.d.ts +114 -0
- package/dist/state/diagnostics-store.d.ts.map +1 -0
- package/dist/state/diagnostics-store.js +319 -0
- package/dist/state/diagnostics-store.js.map +1 -0
- package/dist/state/event-stream.d.ts +134 -0
- package/dist/state/event-stream.d.ts.map +1 -0
- package/dist/state/event-stream.js +424 -0
- package/dist/state/event-stream.js.map +1 -0
- package/dist/state/idb-sync-cache.d.ts +18 -0
- package/dist/state/idb-sync-cache.d.ts.map +1 -0
- package/dist/state/idb-sync-cache.js +209 -0
- package/dist/state/idb-sync-cache.js.map +1 -0
- package/dist/state/opencode-compaction-store.d.ts +10 -0
- package/dist/state/opencode-compaction-store.d.ts.map +1 -0
- package/dist/state/opencode-compaction-store.js +32 -0
- package/dist/state/opencode-compaction-store.js.map +1 -0
- package/dist/state/opencode-pending-store.d.ts +19 -0
- package/dist/state/opencode-pending-store.d.ts.map +1 -0
- package/dist/state/opencode-pending-store.js +76 -0
- package/dist/state/opencode-pending-store.js.map +1 -0
- package/dist/state/sandbox-connection-store.d.ts +62 -0
- package/dist/state/sandbox-connection-store.d.ts.map +1 -0
- package/dist/state/sandbox-connection-store.js +290 -0
- package/dist/state/sandbox-connection-store.js.map +1 -0
- package/dist/state/server-store/active.d.ts +49 -0
- package/dist/state/server-store/active.d.ts.map +1 -0
- package/dist/state/server-store/active.js +76 -0
- package/dist/state/server-store/active.js.map +1 -0
- package/dist/state/server-store/types.d.ts +12 -0
- package/dist/state/server-store/types.d.ts.map +1 -0
- package/dist/state/server-store/types.js +2 -0
- package/dist/state/server-store/types.js.map +1 -0
- package/dist/state/server-store/url-helpers.d.ts +33 -0
- package/dist/state/server-store/url-helpers.d.ts.map +1 -0
- package/dist/state/server-store/url-helpers.js +55 -0
- package/dist/state/server-store/url-helpers.js.map +1 -0
- package/dist/state/server-store.d.ts +18 -0
- package/dist/state/server-store.d.ts.map +1 -0
- package/dist/state/server-store.js +23 -0
- package/dist/state/server-store.js.map +1 -0
- package/dist/state/session-runtime-registry.d.ts +49 -0
- package/dist/state/session-runtime-registry.d.ts.map +1 -0
- package/dist/state/session-runtime-registry.js +85 -0
- package/dist/state/session-runtime-registry.js.map +1 -0
- package/dist/state/sync-store/ascending-id.d.ts +2 -0
- package/dist/state/sync-store/ascending-id.d.ts.map +1 -0
- package/dist/state/sync-store/ascending-id.js +21 -0
- package/dist/state/sync-store/ascending-id.js.map +1 -0
- package/dist/state/sync-store/binary.d.ts +7 -0
- package/dist/state/sync-store/binary.d.ts.map +1 -0
- package/dist/state/sync-store/binary.js +21 -0
- package/dist/state/sync-store/binary.js.map +1 -0
- package/dist/state/sync-store/stream-cache.d.ts +2 -0
- package/dist/state/sync-store/stream-cache.d.ts.map +1 -0
- package/dist/state/sync-store/stream-cache.js +29 -0
- package/dist/state/sync-store/stream-cache.js.map +1 -0
- package/dist/state/sync-store/types.d.ts +29 -0
- package/dist/state/sync-store/types.d.ts.map +1 -0
- package/dist/state/sync-store/types.js +2 -0
- package/dist/state/sync-store/types.js.map +1 -0
- package/dist/state/sync-store.d.ts +39 -0
- package/dist/state/sync-store.d.ts.map +1 -0
- package/dist/state/sync-store.js +692 -0
- package/dist/state/sync-store.js.map +1 -0
- package/dist/state/tab-store.d.ts +91 -0
- package/dist/state/tab-store.d.ts.map +1 -0
- package/dist/state/tab-store.js +369 -0
- package/dist/state/tab-store.js.map +1 -0
- package/dist/transcript.d.ts +40 -0
- package/dist/transcript.d.ts.map +1 -0
- package/dist/transcript.js +126 -0
- package/dist/transcript.js.map +1 -0
- package/dist/turns/classify.d.ts +166 -0
- package/dist/turns/classify.d.ts.map +1 -0
- package/dist/turns/classify.js +259 -0
- package/dist/turns/classify.js.map +1 -0
- package/dist/turns/errors.d.ts +11 -0
- package/dist/turns/errors.d.ts.map +1 -0
- package/dist/turns/errors.js +85 -0
- package/dist/turns/errors.js.map +1 -0
- package/dist/turns/index.d.ts +264 -0
- package/dist/turns/index.d.ts.map +1 -0
- package/dist/turns/index.js +1243 -0
- package/dist/turns/index.js.map +1 -0
- package/dist/turns/tool-registry.d.ts +33 -0
- package/dist/turns/tool-registry.d.ts.map +1 -0
- package/dist/turns/tool-registry.js +108 -0
- package/dist/turns/tool-registry.js.map +1 -0
- package/dist/turns/types.d.ts +125 -0
- package/dist/turns/types.d.ts.map +1 -0
- package/dist/turns/types.js +12 -0
- package/dist/turns/types.js.map +1 -0
- package/dist/turns/view-model.d.ts +127 -0
- package/dist/turns/view-model.d.ts.map +1 -0
- package/dist/turns/view-model.js +401 -0
- package/dist/turns/view-model.js.map +1 -0
- package/package.json +155 -0
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
/**
|
|
3
|
+
* useSession — the ONE hook a host needs to open a session and stream a chat.
|
|
4
|
+
*
|
|
5
|
+
* Everything sandbox-shaped is internal: it drives `/start` (server long-poll),
|
|
6
|
+
* points the runtime at the session's sandbox, opens the SSE stream, resolves the
|
|
7
|
+
* canonical OpenCode id, and syncs messages — exposing one `phase`
|
|
8
|
+
* (starting|ready|error) plus messages/send/abort/questions/permissions and the
|
|
9
|
+
* server-side capabilities (models/agents/commands/picks). The host imports
|
|
10
|
+
* `createKortix` + `useSession` and NOTHING else runtime-related: no server-store,
|
|
11
|
+
* no `switchToSessionSandboxAsync`, no health poller, no event-stream provider.
|
|
12
|
+
*
|
|
13
|
+
* Readiness comes from the SERVER (`stage==='ready'` is only returned after the
|
|
14
|
+
* daemon answered), seeded into the connection store on switch — so there is NO
|
|
15
|
+
* client health poller, and the first turn streams immediately.
|
|
16
|
+
*
|
|
17
|
+
* Call this ONCE per session view (like a provider): it owns the SSE subscription
|
|
18
|
+
* and the `/start` poll for `(projectId, sessionId)`.
|
|
19
|
+
*/
|
|
20
|
+
import { useQuery } from '@tanstack/react-query';
|
|
21
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
22
|
+
import { RuntimeNotReadyError } from '../opencode/client.js';
|
|
23
|
+
import { useOpenCodePendingStore } from '../state/opencode-pending-store.js';
|
|
24
|
+
import { setOpenCodeHealth, setSandboxStatus, } from '../state/sandbox-connection-store.js';
|
|
25
|
+
import { getSandboxUrlForExternalId } from '../state/server-store.js';
|
|
26
|
+
import { setCurrentRuntime } from '../state/current-runtime.js';
|
|
27
|
+
import { isSessionStartError, sessionStartKey, startProjectSession, } from '../platform/projects-client/index.js';
|
|
28
|
+
import { isSessionFresh } from '../platform/fresh-sessions.js';
|
|
29
|
+
import { BillingError, parseBillingError } from '../platform/api/errors.js';
|
|
30
|
+
import { formatOpenCodeRuntimeError } from '../platform/opencode-errors.js';
|
|
31
|
+
import { useCanonicalOpenCodeSession } from './use-canonical-opencode-session.js';
|
|
32
|
+
import { useOpenCodeEventStream } from './use-opencode-events/index.js';
|
|
33
|
+
import { useProjectConfig } from './use-project-config.js';
|
|
34
|
+
import { useProjectModels } from './use-project-models.js';
|
|
35
|
+
import { useQuestionSelfHeal } from './use-question-self-heal.js';
|
|
36
|
+
import { useRuntimePhase } from './use-runtime-phase.js';
|
|
37
|
+
import { clearStartStash, readStartStash } from './session-start-stash.js';
|
|
38
|
+
import { useSessionPicks } from './use-session-picks.js';
|
|
39
|
+
import { useSessionSync } from './use-session-sync.js';
|
|
40
|
+
import { useVisibleAgents } from './use-visible-agents.js';
|
|
41
|
+
import { rejectQuestion as rejectQuestionApi, replyToPermission, replyToQuestion, useAbortOpenCodeSession, useExecuteOpenCodeCommand, useSendOpenCodeMessage, } from './use-opencode-sessions/index.js';
|
|
42
|
+
// Grace window for the optimistic create-vs-start race: how long /start keeps
|
|
43
|
+
// retrying a 404 for a freshly-minted session before treating it as terminal.
|
|
44
|
+
// ~12 × 800ms ≈ 9.6s, comfortably past the sub-second create POST.
|
|
45
|
+
const FRESH_START_404_RETRIES = 12;
|
|
46
|
+
const FRESH_START_404_RETRY_DELAY_MS = 800;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the `/start` poll should retry. A 404 on a freshly-minted session is
|
|
49
|
+
* the optimistic create-vs-start race (the create POST hasn't landed yet), so
|
|
50
|
+
* retry it for the grace window; a 404 on any other (non-fresh) session is a
|
|
51
|
+
* genuinely-missing/no-access session and is terminal at once. Other terminal
|
|
52
|
+
* SessionStartErrors never retry; transient transport failures retry a few times.
|
|
53
|
+
*/
|
|
54
|
+
export function shouldRetrySessionStart(failureCount, error, sessionId) {
|
|
55
|
+
if (isSessionStartError(error) && error.status === 404 && isSessionFresh(sessionId)) {
|
|
56
|
+
return failureCount < FRESH_START_404_RETRIES;
|
|
57
|
+
}
|
|
58
|
+
return !isSessionStartError(error) && failureCount < 3;
|
|
59
|
+
}
|
|
60
|
+
// `getClient()` (packages/sdk/src/opencode/client.ts) throws a
|
|
61
|
+
// `RuntimeNotReadyError` with this exact message when the sandbox url hasn't
|
|
62
|
+
// been resolved yet (session still starting). The string match is kept as a
|
|
63
|
+
// fallback for callers that re-wrap the original error (losing the
|
|
64
|
+
// `instanceof` chain) but still preserve its message.
|
|
65
|
+
const RUNTIME_NOT_READY_MARKER = 'Server URL not ready';
|
|
66
|
+
/** Classify a thrown/rejected error from a send or a permission/question reply
|
|
67
|
+
* into a `KortixSendError`. Pure — safe to unit test without a runtime. */
|
|
68
|
+
export function classifySendError(error) {
|
|
69
|
+
if (error instanceof RuntimeNotReadyError ||
|
|
70
|
+
(error instanceof Error && error.message.includes(RUNTIME_NOT_READY_MARKER))) {
|
|
71
|
+
return {
|
|
72
|
+
kind: 'runtime-not-ready',
|
|
73
|
+
message: 'The session runtime is still starting — try again in a moment.',
|
|
74
|
+
cause: error,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (error && typeof error === 'object') {
|
|
78
|
+
const parsed = parseBillingError(error);
|
|
79
|
+
if (parsed instanceof BillingError) {
|
|
80
|
+
return { kind: 'billing', message: parsed.message, billing: parsed, cause: error };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const formatted = formatOpenCodeRuntimeError(error);
|
|
84
|
+
return { kind: 'runtime-error', message: formatted.message, cause: error };
|
|
85
|
+
}
|
|
86
|
+
const IDLE_SEND_STATE = { pending: null, sendError: null };
|
|
87
|
+
/** New state when a send is kicked off — always clears any previous error. */
|
|
88
|
+
export function sendStateOnStart(text) {
|
|
89
|
+
return { pending: text, sendError: null };
|
|
90
|
+
}
|
|
91
|
+
/** New state when a send fails — drops the optimistic message and classifies
|
|
92
|
+
* the error. */
|
|
93
|
+
export function sendStateOnError(error) {
|
|
94
|
+
return { pending: null, sendError: classifySendError(error) };
|
|
95
|
+
}
|
|
96
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
97
|
+
// Permission/question replies. Standalone (not closures over hook state) since
|
|
98
|
+
// they only need the global runtime client + the global pending store — both
|
|
99
|
+
// singletons — so they double as the implementation AND a directly testable,
|
|
100
|
+
// hook-free surface.
|
|
101
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
102
|
+
/**
|
|
103
|
+
* Answer an agent question through the session's runtime and drop it from
|
|
104
|
+
* local pending state — but only once the server has actually accepted the
|
|
105
|
+
* reply. On failure the question stays pending and a `KortixSendError` is
|
|
106
|
+
* thrown.
|
|
107
|
+
*/
|
|
108
|
+
export async function answerQuestion(requestId, answers) {
|
|
109
|
+
try {
|
|
110
|
+
await replyToQuestion(requestId, answers);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
throw classifySendError(error);
|
|
114
|
+
}
|
|
115
|
+
useOpenCodePendingStore.getState().removeQuestion(requestId);
|
|
116
|
+
}
|
|
117
|
+
/** Reject an agent question through the session's runtime (see `answerQuestion`). */
|
|
118
|
+
export async function rejectQuestion(requestId) {
|
|
119
|
+
try {
|
|
120
|
+
await rejectQuestionApi(requestId);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
throw classifySendError(error);
|
|
124
|
+
}
|
|
125
|
+
useOpenCodePendingStore.getState().removeQuestion(requestId);
|
|
126
|
+
}
|
|
127
|
+
/** Answer an agent permission request through the session's runtime (see `answerQuestion`). */
|
|
128
|
+
export async function answerPermission(requestId, reply, message) {
|
|
129
|
+
try {
|
|
130
|
+
await replyToPermission(requestId, reply, message);
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
throw classifySendError(error);
|
|
134
|
+
}
|
|
135
|
+
useOpenCodePendingStore.getState().removePermission(requestId);
|
|
136
|
+
}
|
|
137
|
+
/** Stable, empty chat state — used when `chatEngine: false` so the hook's
|
|
138
|
+
* public chat fields stay type-stable (empty arrays/idle status, never
|
|
139
|
+
* `undefined`) instead of leaking whatever an unmounted-in-spirit
|
|
140
|
+
* `useSessionSync('')` call happens to return. */
|
|
141
|
+
const DISABLED_CHAT_ENGINE_SYNC = {
|
|
142
|
+
messages: [],
|
|
143
|
+
status: { type: 'idle' },
|
|
144
|
+
isBusy: false,
|
|
145
|
+
isLoading: false,
|
|
146
|
+
diffs: [],
|
|
147
|
+
todos: [],
|
|
148
|
+
};
|
|
149
|
+
export function useSession(projectId, sessionId, options = {}) {
|
|
150
|
+
const { waitMs = 15_000, replayStartStash = true, enabled = true, chatEngine = true, } = options;
|
|
151
|
+
// 1. Drive /start until the runtime is ready (the server long-polls each tick).
|
|
152
|
+
const start = useQuery({
|
|
153
|
+
queryKey: sessionStartKey(projectId, sessionId),
|
|
154
|
+
queryFn: () => startProjectSession(projectId, sessionId, waitMs),
|
|
155
|
+
enabled: enabled && !!projectId && !!sessionId,
|
|
156
|
+
retry: (failureCount, error) => shouldRetrySessionStart(failureCount, error, sessionId),
|
|
157
|
+
retryDelay: (failureCount, error) => isSessionStartError(error) && error.status === 404
|
|
158
|
+
? FRESH_START_404_RETRY_DELAY_MS
|
|
159
|
+
: Math.min(1000 * 2 ** failureCount, 5000),
|
|
160
|
+
refetchInterval: (q) => {
|
|
161
|
+
if (isSessionStartError(q.state.error))
|
|
162
|
+
return false;
|
|
163
|
+
const stage = q.state.data?.stage;
|
|
164
|
+
return stage === 'ready' || stage === 'failed' || stage === 'stopped' ? false : 1500;
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
const startData = start.data ?? null;
|
|
168
|
+
const startError = isSessionStartError(start.error) ? start.error : null;
|
|
169
|
+
const stage = startData?.stage ?? null;
|
|
170
|
+
const sandbox = startData?.sandbox ?? null;
|
|
171
|
+
const startReady = stage === 'ready';
|
|
172
|
+
const terminal = stage === 'failed' || stage === 'stopped';
|
|
173
|
+
// 2. Point the SDK's runtime at this session's sandbox once ready. Track WHICH
|
|
174
|
+
// sandbox we switched to (not a bare bool) so navigating between sessions (this
|
|
175
|
+
// hook instance is reused) re-gates instead of binding the new session to the
|
|
176
|
+
// previous sandbox. One active session at a time is the supported model, so the
|
|
177
|
+
// whole chat path (SSE, sync, send) rides this single global switch — there is no
|
|
178
|
+
// separate per-session client to keep in sync.
|
|
179
|
+
const [switchedSandboxId, setSwitchedSandboxId] = useState(null);
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
if (!startReady || !sandbox?.external_id || switchedSandboxId === sandbox.sandbox_id)
|
|
182
|
+
return;
|
|
183
|
+
// Point the app's runtime at THIS session's box — no global "switch", just set
|
|
184
|
+
// the current runtime url. Every read (getClient, the SSE stream, files/
|
|
185
|
+
// terminal/git) resolves through it. `stage==='ready'` is server-proven, so the
|
|
186
|
+
// health effect below seeds connected+healthy with no client poll.
|
|
187
|
+
setCurrentRuntime(getSandboxUrlForExternalId(sandbox.external_id), sandbox.external_id, sandbox.sandbox_id);
|
|
188
|
+
setSwitchedSandboxId(sandbox.sandbox_id);
|
|
189
|
+
}, [startReady, sandbox, switchedSandboxId]);
|
|
190
|
+
// Clear the current runtime when this session view unmounts.
|
|
191
|
+
useEffect(() => () => setCurrentRuntime(null), []);
|
|
192
|
+
const switched = startReady && !!sandbox && switchedSandboxId === sandbox.sandbox_id;
|
|
193
|
+
// 3. Keep the connection store healthy from server-truth while switched, with NO
|
|
194
|
+
// poller. If the box later dies mid-session the SSE's own disconnect/heartbeat
|
|
195
|
+
// handling drives recovery (no steady-state health loop to halt — the old
|
|
196
|
+
// first-load bug is structurally gone).
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
if (!switched)
|
|
199
|
+
return;
|
|
200
|
+
setSandboxStatus('connected');
|
|
201
|
+
setOpenCodeHealth(true);
|
|
202
|
+
}, [switched]);
|
|
203
|
+
// 4. Open the live SSE stream. This was a provider component (OpenCodeEvent
|
|
204
|
+
// StreamProvider); calling the underlying hook here means the host mounts
|
|
205
|
+
// nothing. It self-gates on the connection store's healthy flag (seeded above).
|
|
206
|
+
useOpenCodeEventStream();
|
|
207
|
+
// 5. Resolve the canonical OpenCode root id (server-owned; /start hands it over)
|
|
208
|
+
// and sync messages off it.
|
|
209
|
+
const { rootSessionId } = useCanonicalOpenCodeSession({
|
|
210
|
+
projectId,
|
|
211
|
+
sessionId,
|
|
212
|
+
pinFromStart: startData?.opencode_session_id ?? null,
|
|
213
|
+
});
|
|
214
|
+
const ocSessionId = rootSessionId ?? '';
|
|
215
|
+
// Always call the hook (rules-of-hooks) so it stays in the same position
|
|
216
|
+
// every render, but starve it with an empty session id when the chat engine
|
|
217
|
+
// is off — `useSessionSync('')` fetches/polls nothing (its effects no-op on
|
|
218
|
+
// a falsy/non-canonical session id) — and use a fixed, type-stable empty
|
|
219
|
+
// result instead of whatever it happens to return for that starved call.
|
|
220
|
+
const rawSync = useSessionSync(chatEngine ? ocSessionId : '');
|
|
221
|
+
const sync = chatEngine ? rawSync : DISABLED_CHAT_ENGINE_SYNC;
|
|
222
|
+
const runtimePhase = useRuntimePhase();
|
|
223
|
+
// 5b. Self-heal a missed `question.asked` SSE event (a `question` tool part
|
|
224
|
+
// rendering as running with nothing in the pending store) — see
|
|
225
|
+
// `useQuestionSelfHeal` for why this is distinct from the SSE reconnect-gap
|
|
226
|
+
// hydration in `useOpenCodeEventStream`. Disabled entirely when `chatEngine`
|
|
227
|
+
// is off — see that option's jsdoc: a host mounting its own chat surface
|
|
228
|
+
// already runs its own copy of this poller for the same session.
|
|
229
|
+
useQuestionSelfHeal(ocSessionId, sync.messages, { enabled: chatEngine && !!ocSessionId });
|
|
230
|
+
// 6. Interactive prompts live in the pending store (the SSE writes them there,
|
|
231
|
+
// keyed by request id carrying sessionID). useSessionSync does NOT surface them.
|
|
232
|
+
const questionMap = useOpenCodePendingStore((s) => s.questions);
|
|
233
|
+
const permissionMap = useOpenCodePendingStore((s) => s.permissions);
|
|
234
|
+
const removeQuestion = useOpenCodePendingStore((s) => s.removeQuestion);
|
|
235
|
+
const removePermission = useOpenCodePendingStore((s) => s.removePermission);
|
|
236
|
+
const questions = useMemo(() => Object.values(questionMap).filter((q) => q.sessionID === ocSessionId), [questionMap, ocSessionId]);
|
|
237
|
+
const permissions = useMemo(() => Object.values(permissionMap).filter((p) => p.sessionID === ocSessionId), [permissionMap, ocSessionId]);
|
|
238
|
+
// 7. Server-side capabilities + per-session picks (all pre-runtime — no sandbox).
|
|
239
|
+
const models = useProjectModels(projectId);
|
|
240
|
+
const agents = useVisibleAgents({ projectId });
|
|
241
|
+
const config = useProjectConfig(projectId);
|
|
242
|
+
const picks = useSessionPicks(sessionId);
|
|
243
|
+
// 8. Mutations.
|
|
244
|
+
const sendMutation = useSendOpenCodeMessage();
|
|
245
|
+
const abortMutation = useAbortOpenCodeSession();
|
|
246
|
+
const commandMutation = useExecuteOpenCodeCommand();
|
|
247
|
+
// 9. Optimistic send: show the user's message instantly until a NEW user message
|
|
248
|
+
// lands (count grows) — robust to server-normalized text where a text-equality
|
|
249
|
+
// match would clear too early or never (wedging the composer). 30s backstop.
|
|
250
|
+
const userMsgCount = useMemo(() => sync.messages.filter((m) => m.info.role === 'user').length, [sync.messages]);
|
|
251
|
+
const [sendState, setSendState] = useState(IDLE_SEND_STATE);
|
|
252
|
+
const pending = sendState.pending;
|
|
253
|
+
const pendingBaseCount = useRef(0);
|
|
254
|
+
useEffect(() => {
|
|
255
|
+
if (pending && userMsgCount > pendingBaseCount.current) {
|
|
256
|
+
setSendState((s) => (s.pending ? { ...s, pending: null } : s));
|
|
257
|
+
}
|
|
258
|
+
}, [userMsgCount, pending]);
|
|
259
|
+
useEffect(() => {
|
|
260
|
+
if (!pending)
|
|
261
|
+
return;
|
|
262
|
+
const t = setTimeout(() => setSendState((s) => (s.pending ? { ...s, pending: null } : s)), 30_000);
|
|
263
|
+
return () => clearTimeout(t);
|
|
264
|
+
}, [pending]);
|
|
265
|
+
const send = (text, override) => {
|
|
266
|
+
if (!ocSessionId)
|
|
267
|
+
return;
|
|
268
|
+
pendingBaseCount.current = userMsgCount;
|
|
269
|
+
setSendState(sendStateOnStart(text));
|
|
270
|
+
const model = override?.model ?? picks.model;
|
|
271
|
+
const agent = override?.agent ?? picks.agent;
|
|
272
|
+
const variant = override?.variant;
|
|
273
|
+
const opts = {
|
|
274
|
+
...(model ? { model } : {}),
|
|
275
|
+
...(agent ? { agent } : {}),
|
|
276
|
+
...(variant ? { variant } : {}),
|
|
277
|
+
};
|
|
278
|
+
sendMutation.mutate({
|
|
279
|
+
sessionId: ocSessionId,
|
|
280
|
+
parts: [{ type: 'text', text }],
|
|
281
|
+
...(Object.keys(opts).length ? { options: opts } : {}),
|
|
282
|
+
}, { onError: (err) => setSendState(sendStateOnError(err)) });
|
|
283
|
+
};
|
|
284
|
+
// Run a project slash-command (server-side `/command`), distinct from a prompt.
|
|
285
|
+
const runCommand = (command, args) => {
|
|
286
|
+
if (!ocSessionId)
|
|
287
|
+
return;
|
|
288
|
+
commandMutation.mutate({ sessionId: ocSessionId, command, args });
|
|
289
|
+
};
|
|
290
|
+
// The one true cancel: abort the run AND drop any pending prompt + open prompts.
|
|
291
|
+
const cancel = () => {
|
|
292
|
+
if (ocSessionId)
|
|
293
|
+
abortMutation.mutate(ocSessionId);
|
|
294
|
+
questions.forEach((q) => removeQuestion(q.id));
|
|
295
|
+
permissions.forEach((p) => removePermission(p.id));
|
|
296
|
+
setSendState(IDLE_SEND_STATE);
|
|
297
|
+
};
|
|
298
|
+
const phase = terminal || startError ? 'error' : switched ? 'ready' : 'starting';
|
|
299
|
+
// 10. Replay the new-session hand-off once ready + thread empty (exactly once).
|
|
300
|
+
// Force-disabled when `chatEngine` is off: this reads `sync.isLoading`/
|
|
301
|
+
// `sync.messages`, which are the fixed empty stand-ins above when the chat
|
|
302
|
+
// engine isn't mounted, so it could never correctly gate on thread-empty —
|
|
303
|
+
// a host that disables the chat engine already owns its own hand-off.
|
|
304
|
+
const startedRef = useRef(false);
|
|
305
|
+
useEffect(() => {
|
|
306
|
+
if (!replayStartStash || !chatEngine)
|
|
307
|
+
return;
|
|
308
|
+
if (startedRef.current || phase !== 'ready' || sync.isLoading)
|
|
309
|
+
return;
|
|
310
|
+
const stash = readStartStash(sessionId);
|
|
311
|
+
if (!stash)
|
|
312
|
+
return;
|
|
313
|
+
startedRef.current = true;
|
|
314
|
+
clearStartStash(sessionId);
|
|
315
|
+
if (sync.messages.length > 0)
|
|
316
|
+
return;
|
|
317
|
+
if (stash.model)
|
|
318
|
+
picks.setModel(stash.model);
|
|
319
|
+
if (stash.agent)
|
|
320
|
+
picks.setAgent(stash.agent);
|
|
321
|
+
send(stash.prompt, { model: stash.model, agent: stash.agent, variant: stash.variant });
|
|
322
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
323
|
+
}, [phase, sync.isLoading, sync.messages.length, sessionId, replayStartStash, chatEngine]);
|
|
324
|
+
return {
|
|
325
|
+
projectId,
|
|
326
|
+
sessionId,
|
|
327
|
+
/** Canonical OpenCode root id, or null while resolving. */
|
|
328
|
+
opencodeSessionId: rootSessionId ?? null,
|
|
329
|
+
// live data
|
|
330
|
+
messages: sync.messages,
|
|
331
|
+
status: sync.status,
|
|
332
|
+
questions,
|
|
333
|
+
permissions,
|
|
334
|
+
diffs: sync.diffs,
|
|
335
|
+
todos: sync.todos,
|
|
336
|
+
// lifecycle
|
|
337
|
+
phase,
|
|
338
|
+
/** Raw /start stage (provisioning|starting|ready|stopped|failed), for boot UI. */
|
|
339
|
+
stage,
|
|
340
|
+
/** The serialized session_sandboxes row from /start (status, metadata, ids), or null. */
|
|
341
|
+
sandbox,
|
|
342
|
+
/** True once the runtime is switched in and ready (equivalent to phase==='ready'). */
|
|
343
|
+
switched,
|
|
344
|
+
/** Whether polling /start again can still make progress (false = terminal). */
|
|
345
|
+
retriable: startData?.retriable ?? false,
|
|
346
|
+
/** Terminal /start failure, for hosts to render instead of spinning forever. */
|
|
347
|
+
startError,
|
|
348
|
+
/** Granular boot phase (connecting|booting|ready|unreachable) for detailed UI. */
|
|
349
|
+
runtimePhase,
|
|
350
|
+
isBusy: sync.isBusy || !!pending,
|
|
351
|
+
isLoading: sync.isLoading,
|
|
352
|
+
isError: terminal || !!startError,
|
|
353
|
+
/** Whether there are open interactive prompts (questions/permissions). */
|
|
354
|
+
hasPending: questions.length > 0 || permissions.length > 0,
|
|
355
|
+
/** Latest /start reason (e.g. 'runtime_waking'), surfaced for boot/error UI. */
|
|
356
|
+
reason: startData?.reason ?? null,
|
|
357
|
+
/** Pending optimistic message text, or null. */
|
|
358
|
+
pending,
|
|
359
|
+
/** True while the current `send` mutation is in flight. */
|
|
360
|
+
isSending: sendMutation.isPending,
|
|
361
|
+
/** Last `send` failure, typed (billing / runtime-not-ready / runtime-error),
|
|
362
|
+
* or null. Reset on every new `send` call. */
|
|
363
|
+
sendError: sendState.sendError,
|
|
364
|
+
// server-side capabilities (pre-runtime)
|
|
365
|
+
models,
|
|
366
|
+
agents,
|
|
367
|
+
defaultAgent: config?.open_code_default_agent ?? null,
|
|
368
|
+
commands: config?.commands ?? [],
|
|
369
|
+
picks,
|
|
370
|
+
// actions
|
|
371
|
+
send,
|
|
372
|
+
cancel,
|
|
373
|
+
runCommand,
|
|
374
|
+
/** Answer an agent question through the server and drop it from pending
|
|
375
|
+
* state on success; throws a `KortixSendError` and leaves it pending on
|
|
376
|
+
* failure. */
|
|
377
|
+
answerQuestion,
|
|
378
|
+
/** Reject an agent question through the server (see `answerQuestion`). */
|
|
379
|
+
rejectQuestion,
|
|
380
|
+
/** Answer an agent permission request through the server (see `answerQuestion`). */
|
|
381
|
+
answerPermission,
|
|
382
|
+
/** @deprecated Drops the question from local state WITHOUT replying to the
|
|
383
|
+
* server — the agent run stays blocked waiting on it. Use `answerQuestion`
|
|
384
|
+
* / `rejectQuestion` instead. */
|
|
385
|
+
removeQuestion,
|
|
386
|
+
/** @deprecated Drops the permission request from local state WITHOUT
|
|
387
|
+
* replying to the server — the agent run stays blocked waiting on it. Use
|
|
388
|
+
* `answerPermission` instead. */
|
|
389
|
+
removePermission,
|
|
390
|
+
/** Force a re-poll of /start (e.g. a Retry button on the boot screen). */
|
|
391
|
+
retry: () => {
|
|
392
|
+
void start.refetch();
|
|
393
|
+
},
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
//# sourceMappingURL=use-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-session.js","sourceRoot":"","sources":["../../src/react/use-session.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,E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AS,IAAI,KAAK;QACxC,gFAAgF;QAChF,UAAU;QACV,kFAAkF;QAClF,YAAY;QACZ,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO;QAChC,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,OAAO,EAAE,QAAQ,IAAI,CAAC,CAAC,UAAU;QACjC,0EAA0E;QAC1E,UAAU,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;QAC1D,gFAAgF;QAChF,MAAM,EAAE,SAAS,EAAE,MAAM,IAAI,IAAI;QACjC,gDAAgD;QAChD,OAAO;QACP,2DAA2D;QAC3D,SAAS,EAAE,YAAY,CAAC,SAAS;QACjC;sDAC8C;QAC9C,SAAS,EAAE,SAAS,CAAC,SAAS;QAE9B,yCAAyC;QACzC,MAAM;QACN,MAAM;QACN,YAAY,EAAE,MAAM,EAAE,uBAAuB,IAAI,IAAI;QACrD,QAAQ,EAAE,MAAM,EAAE,QAAQ,IAAI,EAAE;QAChC,KAAK;QAEL,UAAU;QACV,IAAI;QACJ,MAAM;QACN,UAAU;QACV;;sBAEc;QACd,cAAc;QACd,0EAA0E;QAC1E,cAAc;QACd,oFAAoF;QACpF,gBAAgB;QAChB;;yCAEiC;QACjC,cAAc;QACd;;yCAEiC;QACjC,gBAAgB;QAChB,0EAA0E;QAC1E,KAAK,EAAE,GAAG,EAAE;YACV,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Agent } from '@opencode-ai/sdk/v2/client';
|
|
2
|
+
/**
|
|
3
|
+
* Returns only visible agents (non-hidden, non-subagent).
|
|
4
|
+
* Use this for agent selectors in UI where users pick which agent to use.
|
|
5
|
+
*
|
|
6
|
+
* Pass `projectId` for a SERVER-SIDE fetch (the project config is source of
|
|
7
|
+
* truth, works before any sandbox runtime exists) — preferred for selectors.
|
|
8
|
+
* Pass `directory` to scope the sandbox-runtime fetch to a project instead.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useVisibleAgents(options?: {
|
|
11
|
+
directory?: string;
|
|
12
|
+
projectId?: string | null;
|
|
13
|
+
}): Agent[];
|
|
14
|
+
/**
|
|
15
|
+
* Returns all visible agents including subagents.
|
|
16
|
+
* Use this when you need to show subagents too (e.g., advanced mode).
|
|
17
|
+
*/
|
|
18
|
+
export declare function useAllVisibleAgents(options?: {
|
|
19
|
+
directory?: string;
|
|
20
|
+
projectId?: string | null;
|
|
21
|
+
}): Agent[];
|
|
22
|
+
//# sourceMappingURL=use-visible-agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-visible-agents.d.ts","sourceRoot":"","sources":["../../src/react/use-visible-agents.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAyBxD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,GAAG,KAAK,EAAE,CAMV;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,GAAG,KAAK,EAAE,CAMV"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { useOpenCodeAgents } from './use-opencode-sessions/index.js';
|
|
4
|
+
import { featureFlags } from '../platform/feature-flags.js';
|
|
5
|
+
/**
|
|
6
|
+
* Project-only agents — surfaced only when the project paradigm is on.
|
|
7
|
+
*
|
|
8
|
+
* Just `project-manager`. The other agents (orchestrator, worker,
|
|
9
|
+
* project-maintainer) stay visible regardless of flag state — they're
|
|
10
|
+
* useful general-purpose roles, even when their preferred tools (task_*)
|
|
11
|
+
* aren't registered. The user reasons about the PM agent as the
|
|
12
|
+
* project-paradigm gate.
|
|
13
|
+
*
|
|
14
|
+
* `project-manager` is the per-project PM slug seeded by seedV2Project at
|
|
15
|
+
* /workspace/.opencode/agent/project-manager.md. The file persists on disk
|
|
16
|
+
* after a flag-on cycle even when the flag flips back off, so this picker
|
|
17
|
+
* filter is what keeps it out of the UI in default mode.
|
|
18
|
+
*/
|
|
19
|
+
const PROJECT_ONLY_AGENTS = new Set(['project-manager']);
|
|
20
|
+
function hideProjectOnly(a) {
|
|
21
|
+
if (featureFlags.enableProjects)
|
|
22
|
+
return false;
|
|
23
|
+
return PROJECT_ONLY_AGENTS.has(a.name);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns only visible agents (non-hidden, non-subagent).
|
|
27
|
+
* Use this for agent selectors in UI where users pick which agent to use.
|
|
28
|
+
*
|
|
29
|
+
* Pass `projectId` for a SERVER-SIDE fetch (the project config is source of
|
|
30
|
+
* truth, works before any sandbox runtime exists) — preferred for selectors.
|
|
31
|
+
* Pass `directory` to scope the sandbox-runtime fetch to a project instead.
|
|
32
|
+
*/
|
|
33
|
+
export function useVisibleAgents(options) {
|
|
34
|
+
const { data: agents = [] } = useOpenCodeAgents(options);
|
|
35
|
+
return useMemo(() => agents.filter((a) => !a.hidden && a.mode !== 'subagent' && !hideProjectOnly(a)), [agents]);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Returns all visible agents including subagents.
|
|
39
|
+
* Use this when you need to show subagents too (e.g., advanced mode).
|
|
40
|
+
*/
|
|
41
|
+
export function useAllVisibleAgents(options) {
|
|
42
|
+
const { data: agents = [] } = useOpenCodeAgents(options);
|
|
43
|
+
return useMemo(() => agents.filter((a) => !a.hidden && !hideProjectOnly(a)), [agents]);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=use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CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAC5D,CAAC,MAAM,CAAC,CACT,CAAC;AACJ,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@kortix/sdk/server` — Node/Bun-only request-scoped config isolation for
|
|
3
|
+
* "Kortix as a Backend": a third-party server process that wraps Kortix on
|
|
4
|
+
* behalf of multiple end users/tenants concurrently.
|
|
5
|
+
*
|
|
6
|
+
* NEVER import this subpath from a browser bundle. It statically imports
|
|
7
|
+
* `config-node.ts`, which statically imports `node:async_hooks` — most
|
|
8
|
+
* browser bundlers choke if that appears anywhere in their graph. The root
|
|
9
|
+
* `@kortix/sdk` entry point and `@kortix/sdk/react` never import this file,
|
|
10
|
+
* so a web host's bundle is unaffected either way; this subpath exists
|
|
11
|
+
* specifically for the non-browser "backend" case.
|
|
12
|
+
*
|
|
13
|
+
* Why this exists: `configureKortix()`/`createKortix()` (the root `@kortix/sdk`
|
|
14
|
+
* seam) store the platform config — crucially, the bearer token getter — in a
|
|
15
|
+
* single process-wide module-global (see `platform/config.ts`). That's fine
|
|
16
|
+
* for a host with exactly one config for its whole lifetime (a browser tab, a
|
|
17
|
+
* CLI, a single-tenant server). It is UNSAFE for a server process handling
|
|
18
|
+
* concurrent requests on behalf of different users: two in-flight requests
|
|
19
|
+
* racing through `configureKortix()` with different tokens clobber each
|
|
20
|
+
* other — whichever call landed last wins for every other in-flight request
|
|
21
|
+
* (see the warning on `ServerTokenOptions` in
|
|
22
|
+
* `platform/projects-client/shared.ts`).
|
|
23
|
+
*
|
|
24
|
+
* `runWithKortix`/`createScopedKortix` fix that using Node's
|
|
25
|
+
* `AsyncLocalStorage`: the config passed to one call is visible ONLY inside
|
|
26
|
+
* that call's async continuation (every `await` inside it), correctly
|
|
27
|
+
* isolated from any other concurrent call in the same process.
|
|
28
|
+
*/
|
|
29
|
+
import { type Kortix } from './kortix.js';
|
|
30
|
+
import { runWithKortix, getScopedConfig } from './platform/config-node.js';
|
|
31
|
+
import type { KortixPlatformConfig } from './platform/config.js';
|
|
32
|
+
export { runWithKortix, getScopedConfig };
|
|
33
|
+
/**
|
|
34
|
+
* Same shape as `createKortix(config)`, but every method call — including
|
|
35
|
+
* calls reached through `.project(id)`/`.session(pid, sid)` handles minted at
|
|
36
|
+
* call time — automatically runs inside `runWithKortix(config, ...)`. This
|
|
37
|
+
* handle never writes to (or is affected by) the process-global config
|
|
38
|
+
* singleton other `createKortix()`/`configureKortix()` callers in the same
|
|
39
|
+
* process share. Safe to construct one per incoming request in a multi-tenant
|
|
40
|
+
* server:
|
|
41
|
+
*
|
|
42
|
+
* import { createScopedKortix } from '@kortix/sdk/server';
|
|
43
|
+
*
|
|
44
|
+
* app.get('/projects', async (req, res) => {
|
|
45
|
+
* const kortix = createScopedKortix({ backendUrl, getToken: () => tokenFor(req) });
|
|
46
|
+
* res.json(await kortix.projects.list());
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* Two concurrent requests each calling `createScopedKortix` with a different
|
|
50
|
+
* token never see each other's config, even though both run in the same
|
|
51
|
+
* process — unlike two concurrent `createKortix()` calls, which share (and
|
|
52
|
+
* race on) the global singleton.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createScopedKortix(config: KortixPlatformConfig): Kortix;
|
|
55
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAa,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;AAqE1C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAGvE"}
|