@beeuni/sdk 0.1.0
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 +1234 -0
- package/dist/beeuni.esm.min.js +96 -0
- package/dist/beeuni.global.js +96 -0
- package/dist/browser/cache/idb-sync-cache.d.ts +12 -0
- package/dist/browser/cache/idb-sync-cache.js +88 -0
- package/dist/browser/session-sync/mirror-paging.d.ts +7 -0
- package/dist/browser/session-sync/mirror-paging.js +10 -0
- package/dist/browser/session-sync/server-transcript-mirror.d.ts +33 -0
- package/dist/browser/session-sync/server-transcript-mirror.js +112 -0
- package/dist/browser/session-sync/session-cache-ownership.d.ts +8 -0
- package/dist/browser/session-sync/session-cache-ownership.js +36 -0
- package/dist/browser/session-sync/session-sync-registry.d.ts +44 -0
- package/dist/browser/session-sync/session-sync-registry.js +253 -0
- package/dist/browser/session-sync/visibility.d.ts +6 -0
- package/dist/browser/session-sync/visibility.js +21 -0
- package/dist/browser/stores/diagnostics-store.d.ts +61 -0
- package/dist/browser/stores/diagnostics-store.js +216 -0
- package/dist/browser/stores/opencode-compaction-store.d.ts +7 -0
- package/dist/browser/stores/opencode-compaction-store.js +21 -0
- package/dist/browser/stores/opencode-pending-store.d.ts +19 -0
- package/dist/browser/stores/opencode-pending-store.js +65 -0
- package/dist/browser/stores/sandbox-connection-store.d.ts +35 -0
- package/dist/browser/stores/sandbox-connection-store.js +230 -0
- package/dist/browser/stores/server-store.d.ts +4 -0
- package/dist/browser/stores/server-store.js +7 -0
- package/dist/browser/stores/session-working-store.d.ts +21 -0
- package/dist/browser/stores/session-working-store.js +106 -0
- package/dist/browser/stores/sync-store/ascending-id.d.ts +1 -0
- package/dist/browser/stores/sync-store/ascending-id.js +17 -0
- package/dist/browser/stores/sync-store/binary.d.ts +6 -0
- package/dist/browser/stores/sync-store/binary.js +17 -0
- package/dist/browser/stores/sync-store/delta-event-window.d.ts +1 -0
- package/dist/browser/stores/sync-store/delta-event-window.js +1 -0
- package/dist/browser/stores/sync-store/reconcile-parts.d.ts +12 -0
- package/dist/browser/stores/sync-store/reconcile-parts.js +53 -0
- package/dist/browser/stores/sync-store/types.d.ts +20 -0
- package/dist/browser/stores/sync-store/types.js +1 -0
- package/dist/browser/stores/sync-store.d.ts +65 -0
- package/dist/browser/stores/sync-store.js +1336 -0
- package/dist/core/agents/composer-agents.d.ts +19 -0
- package/dist/core/agents/composer-agents.js +57 -0
- package/dist/core/attachments/limits.d.ts +3 -0
- package/dist/core/attachments/limits.js +3 -0
- package/dist/core/attachments/prompt-attachments.d.ts +37 -0
- package/dist/core/attachments/prompt-attachments.js +377 -0
- package/dist/core/auth/app-viewer.d.ts +43 -0
- package/dist/core/auth/app-viewer.js +104 -0
- package/dist/core/auth/beeuni-member.d.ts +31 -0
- package/dist/core/auth/beeuni-member.js +168 -0
- package/dist/core/auth/session.d.ts +24 -0
- package/dist/core/auth/session.js +145 -0
- package/dist/core/cache/persisted-query-cache.d.ts +55 -0
- package/dist/core/cache/persisted-query-cache.js +220 -0
- package/dist/core/client/beeuni.d.ts +1216 -0
- package/dist/core/client/beeuni.js +96 -0
- package/dist/core/client/binding-types.d.ts +1 -0
- package/dist/core/client/binding-types.js +1 -0
- package/dist/core/client/facade-accounts.d.ts +51 -0
- package/dist/core/client/facade-accounts.js +53 -0
- package/dist/core/client/facade-catalog.d.ts +54 -0
- package/dist/core/client/facade-catalog.js +53 -0
- package/dist/core/client/facade-commerce.d.ts +39 -0
- package/dist/core/client/facade-commerce.js +40 -0
- package/dist/core/client/facade-iam.d.ts +43 -0
- package/dist/core/client/facade-iam.js +45 -0
- package/dist/core/client/facade-identity.d.ts +103 -0
- package/dist/core/client/facade-identity.js +33 -0
- package/dist/core/client/facade-preview.d.ts +3 -0
- package/dist/core/client/facade-preview.js +30 -0
- package/dist/core/client/project-access-resources.d.ts +65 -0
- package/dist/core/client/project-access-resources.js +54 -0
- package/dist/core/client/project-access-security.d.ts +109 -0
- package/dist/core/client/project-access-security.js +33 -0
- package/dist/core/client/project-connections.d.ts +32 -0
- package/dist/core/client/project-connections.js +18 -0
- package/dist/core/client/project-connectors.d.ts +15 -0
- package/dist/core/client/project-connectors.js +34 -0
- package/dist/core/client/project-core.d.ts +74 -0
- package/dist/core/client/project-core.js +25 -0
- package/dist/core/client/project-membership.d.ts +62 -0
- package/dist/core/client/project-membership.js +24 -0
- package/dist/core/client/project-operations-admin.d.ts +125 -0
- package/dist/core/client/project-operations-admin.js +26 -0
- package/dist/core/client/project-operations-review.d.ts +35 -0
- package/dist/core/client/project-operations-review.js +24 -0
- package/dist/core/client/project-operations-workspace.d.ts +94 -0
- package/dist/core/client/project-operations-workspace.js +36 -0
- package/dist/core/client/project-operations.d.ts +237 -0
- package/dist/core/client/project-operations.js +41 -0
- package/dist/core/client/project-platform-resources.d.ts +34 -0
- package/dist/core/client/project-platform-resources.js +27 -0
- package/dist/core/client/project-platform-security.d.ts +76 -0
- package/dist/core/client/project-platform-security.js +31 -0
- package/dist/core/client/project-platform-settings.d.ts +53 -0
- package/dist/core/client/project-platform-settings.js +23 -0
- package/dist/core/client/session-actions-resources.d.ts +7 -0
- package/dist/core/client/session-actions-resources.js +13 -0
- package/dist/core/client/session-actions-security.d.ts +22 -0
- package/dist/core/client/session-actions-security.js +38 -0
- package/dist/core/client/session-actions-services.d.ts +39 -0
- package/dist/core/client/session-actions-services.js +34 -0
- package/dist/core/client/session-context.d.ts +21 -0
- package/dist/core/client/session-context.js +1 -0
- package/dist/core/client/session-defaults.d.ts +8 -0
- package/dist/core/client/session-defaults.js +35 -0
- package/dist/core/client/session-files.d.ts +20 -0
- package/dist/core/client/session-files.js +18 -0
- package/dist/core/client/session-handle.d.ts +207 -0
- package/dist/core/client/session-handle.js +53 -0
- package/dist/core/client/session-lifecycle-resources.d.ts +76 -0
- package/dist/core/client/session-lifecycle-resources.js +44 -0
- package/dist/core/client/session-lifecycle-security.d.ts +42 -0
- package/dist/core/client/session-lifecycle-security.js +31 -0
- package/dist/core/client/session-preview.d.ts +7 -0
- package/dist/core/client/session-preview.js +11 -0
- package/dist/core/client/session-readiness.d.ts +10 -0
- package/dist/core/client/session-readiness.js +54 -0
- package/dist/core/client/session-runtime.d.ts +21 -0
- package/dist/core/client/session-runtime.js +15 -0
- package/dist/core/client/session-shared.d.ts +20 -0
- package/dist/core/client/session-shared.js +22 -0
- package/dist/core/client/session-start.d.ts +2 -0
- package/dist/core/client/session-start.js +39 -0
- package/dist/core/files/client.d.ts +68 -0
- package/dist/core/files/client.js +491 -0
- package/dist/core/files/types.d.ts +75 -0
- package/dist/core/files/types.js +1 -0
- package/dist/core/http/abort-error.d.ts +5 -0
- package/dist/core/http/abort-error.js +74 -0
- package/dist/core/http/abort.d.ts +3 -0
- package/dist/core/http/abort.js +34 -0
- package/dist/core/http/api/errors.d.ts +68 -0
- package/dist/core/http/api/errors.js +132 -0
- package/dist/core/http/api-client.d.ts +44 -0
- package/dist/core/http/api-client.js +121 -0
- package/dist/core/http/auth.d.ts +12 -0
- package/dist/core/http/auth.js +37 -0
- package/dist/core/http/authenticated-request.d.ts +5 -0
- package/dist/core/http/authenticated-request.js +11 -0
- package/dist/core/http/config.d.ts +35 -0
- package/dist/core/http/config.js +23 -0
- package/dist/core/http/env.d.ts +1 -0
- package/dist/core/http/env.js +8 -0
- package/dist/core/http/feature-flags.d.ts +8 -0
- package/dist/core/http/feature-flags.js +41 -0
- package/dist/core/http/fresh-sessions.d.ts +3 -0
- package/dist/core/http/fresh-sessions.js +17 -0
- package/dist/core/http/impersonation.d.ts +14 -0
- package/dist/core/http/impersonation.js +110 -0
- package/dist/core/http/instance-routes.d.ts +16 -0
- package/dist/core/http/instance-routes.js +99 -0
- package/dist/core/http/logger.d.ts +10 -0
- package/dist/core/http/logger.js +29 -0
- package/dist/core/http/request.d.ts +2 -0
- package/dist/core/http/request.js +194 -0
- package/dist/core/http/response-error.d.ts +2 -0
- package/dist/core/http/response-error.js +92 -0
- package/dist/core/http/runtime-errors.d.ts +32 -0
- package/dist/core/http/runtime-errors.js +116 -0
- package/dist/core/http/session-stopped.d.ts +2 -0
- package/dist/core/http/session-stopped.js +16 -0
- package/dist/core/http/transport.d.ts +20 -0
- package/dist/core/http/transport.js +133 -0
- package/dist/core/models/bedrock-invokable.d.ts +3 -0
- package/dist/core/models/bedrock-invokable.js +22 -0
- package/dist/core/models/composer-model.d.ts +20 -0
- package/dist/core/models/composer-model.js +57 -0
- package/dist/core/models/model-flatten.d.ts +43 -0
- package/dist/core/models/model-flatten.js +73 -0
- package/dist/core/models/model-key.d.ts +8 -0
- package/dist/core/models/model-key.js +18 -0
- package/dist/core/models/model-lookup.d.ts +2 -0
- package/dist/core/models/model-lookup.js +3 -0
- package/dist/core/models/model-visibility.d.ts +28 -0
- package/dist/core/models/model-visibility.js +110 -0
- package/dist/core/models/provider-selection.d.ts +72 -0
- package/dist/core/models/provider-selection.js +307 -0
- package/dist/core/rest/platform-client/auth.d.ts +139 -0
- package/dist/core/rest/platform-client/auth.js +92 -0
- package/dist/core/rest/platform-client/backups.d.ts +18 -0
- package/dist/core/rest/platform-client/backups.js +12 -0
- package/dist/core/rest/platform-client/connector-setup.d.ts +35 -0
- package/dist/core/rest/platform-client/connector-setup.js +105 -0
- package/dist/core/rest/platform-client/github-app.d.ts +45 -0
- package/dist/core/rest/platform-client/github-app.js +54 -0
- package/dist/core/rest/platform-client/host-boundary.d.ts +140 -0
- package/dist/core/rest/platform-client/host-boundary.js +188 -0
- package/dist/core/rest/platform-client/index.d.ts +12 -0
- package/dist/core/rest/platform-client/index.js +12 -0
- package/dist/core/rest/platform-client/instance-admin.d.ts +53 -0
- package/dist/core/rest/platform-client/instance-admin.js +20 -0
- package/dist/core/rest/platform-client/invites.d.ts +31 -0
- package/dist/core/rest/platform-client/invites.js +11 -0
- package/dist/core/rest/platform-client/lifecycle.d.ts +27 -0
- package/dist/core/rest/platform-client/lifecycle.js +80 -0
- package/dist/core/rest/platform-client/members.d.ts +14 -0
- package/dist/core/rest/platform-client/members.js +28 -0
- package/dist/core/rest/platform-client/shared.d.ts +18 -0
- package/dist/core/rest/platform-client/shared.js +99 -0
- package/dist/core/rest/platform-client/ssh.d.ts +21 -0
- package/dist/core/rest/platform-client/ssh.js +6 -0
- package/dist/core/rest/platform-client/types.d.ts +47 -0
- package/dist/core/rest/platform-client/types.js +10 -0
- package/dist/core/rest/platform-client/updates.d.ts +77 -0
- package/dist/core/rest/platform-client/updates.js +54 -0
- package/dist/core/rest/platform-client/urls.d.ts +3 -0
- package/dist/core/rest/platform-client/urls.js +16 -0
- package/dist/core/rest/projects-client/access.d.ts +226 -0
- package/dist/core/rest/projects-client/access.js +82 -0
- package/dist/core/rest/projects-client/account-lifecycle.d.ts +21 -0
- package/dist/core/rest/projects-client/account-lifecycle.js +25 -0
- package/dist/core/rest/projects-client/account-secret-resources.d.ts +60 -0
- package/dist/core/rest/projects-client/account-secret-resources.js +40 -0
- package/dist/core/rest/projects-client/accounts.d.ts +240 -0
- package/dist/core/rest/projects-client/accounts.js +82 -0
- package/dist/core/rest/projects-client/admin-providers.d.ts +131 -0
- package/dist/core/rest/projects-client/admin-providers.js +39 -0
- package/dist/core/rest/projects-client/agent-config.d.ts +72 -0
- package/dist/core/rest/projects-client/agent-config.js +39 -0
- package/dist/core/rest/projects-client/agent-connectors.d.ts +6 -0
- package/dist/core/rest/projects-client/agent-connectors.js +32 -0
- package/dist/core/rest/projects-client/agent-scope.d.ts +13 -0
- package/dist/core/rest/projects-client/agent-scope.js +7 -0
- package/dist/core/rest/projects-client/apps-fleet.d.ts +82 -0
- package/dist/core/rest/projects-client/apps-fleet.js +45 -0
- package/dist/core/rest/projects-client/apps.d.ts +356 -0
- package/dist/core/rest/projects-client/apps.js +126 -0
- package/dist/core/rest/projects-client/assignments.d.ts +73 -0
- package/dist/core/rest/projects-client/assignments.js +45 -0
- package/dist/core/rest/projects-client/audit-filter.d.ts +4 -0
- package/dist/core/rest/projects-client/audit-filter.js +9 -0
- package/dist/core/rest/projects-client/audit.d.ts +125 -0
- package/dist/core/rest/projects-client/audit.js +49 -0
- package/dist/core/rest/projects-client/billing.d.ts +390 -0
- package/dist/core/rest/projects-client/billing.js +257 -0
- package/dist/core/rest/projects-client/change-requests.d.ts +116 -0
- package/dist/core/rest/projects-client/change-requests.js +50 -0
- package/dist/core/rest/projects-client/channels.d.ts +131 -0
- package/dist/core/rest/projects-client/channels.js +112 -0
- package/dist/core/rest/projects-client/connector-run.d.ts +62 -0
- package/dist/core/rest/projects-client/connector-run.js +155 -0
- package/dist/core/rest/projects-client/connectors.d.ts +721 -0
- package/dist/core/rest/projects-client/connectors.js +421 -0
- package/dist/core/rest/projects-client/drives.d.ts +149 -0
- package/dist/core/rest/projects-client/drives.js +88 -0
- package/dist/core/rest/projects-client/files.d.ts +45 -0
- package/dist/core/rest/projects-client/files.js +69 -0
- package/dist/core/rest/projects-client/gateway.d.ts +257 -0
- package/dist/core/rest/projects-client/gateway.js +72 -0
- package/dist/core/rest/projects-client/git-backend.d.ts +15 -0
- package/dist/core/rest/projects-client/git-backend.js +15 -0
- package/dist/core/rest/projects-client/git-history.d.ts +78 -0
- package/dist/core/rest/projects-client/git-history.js +47 -0
- package/dist/core/rest/projects-client/github.d.ts +128 -0
- package/dist/core/rest/projects-client/github.js +54 -0
- package/dist/core/rest/projects-client/iam-audit.d.ts +81 -0
- package/dist/core/rest/projects-client/iam-audit.js +21 -0
- package/dist/core/rest/projects-client/iam-enterprise.d.ts +2 -0
- package/dist/core/rest/projects-client/iam-enterprise.js +11 -0
- package/dist/core/rest/projects-client/iam-grants.d.ts +21 -0
- package/dist/core/rest/projects-client/iam-grants.js +6 -0
- package/dist/core/rest/projects-client/iam-groups.d.ts +65 -0
- package/dist/core/rest/projects-client/iam-groups.js +42 -0
- package/dist/core/rest/projects-client/iam-policies.d.ts +53 -0
- package/dist/core/rest/projects-client/iam-policies.js +26 -0
- package/dist/core/rest/projects-client/iam-probe.d.ts +27 -0
- package/dist/core/rest/projects-client/iam-probe.js +16 -0
- package/dist/core/rest/projects-client/iam-query.d.ts +1 -0
- package/dist/core/rest/projects-client/iam-query.js +9 -0
- package/dist/core/rest/projects-client/iam-roles.d.ts +47 -0
- package/dist/core/rest/projects-client/iam-roles.js +43 -0
- package/dist/core/rest/projects-client/iam-scim.d.ts +22 -0
- package/dist/core/rest/projects-client/iam-scim.js +14 -0
- package/dist/core/rest/projects-client/iam-security.d.ts +28 -0
- package/dist/core/rest/projects-client/iam-security.js +17 -0
- package/dist/core/rest/projects-client/iam-service-accounts.d.ts +26 -0
- package/dist/core/rest/projects-client/iam-service-accounts.js +14 -0
- package/dist/core/rest/projects-client/iam-sessions.d.ts +27 -0
- package/dist/core/rest/projects-client/iam-sessions.js +25 -0
- package/dist/core/rest/projects-client/iam-shared.d.ts +6 -0
- package/dist/core/rest/projects-client/iam-shared.js +8 -0
- package/dist/core/rest/projects-client/iam-sso.d.ts +60 -0
- package/dist/core/rest/projects-client/iam-sso.js +28 -0
- package/dist/core/rest/projects-client/iam-types.d.ts +52 -0
- package/dist/core/rest/projects-client/iam-types.js +1 -0
- package/dist/core/rest/projects-client/iam.d.ts +13 -0
- package/dist/core/rest/projects-client/iam.js +13 -0
- package/dist/core/rest/projects-client/index.d.ts +55 -0
- package/dist/core/rest/projects-client/index.js +54 -0
- package/dist/core/rest/projects-client/marketplace-catalog.d.ts +74 -0
- package/dist/core/rest/projects-client/marketplace-catalog.js +41 -0
- package/dist/core/rest/projects-client/model-access.d.ts +13 -0
- package/dist/core/rest/projects-client/model-access.js +8 -0
- package/dist/core/rest/projects-client/model-defaults.d.ts +28 -0
- package/dist/core/rest/projects-client/model-defaults.js +15 -0
- package/dist/core/rest/projects-client/model-enablement.d.ts +4 -0
- package/dist/core/rest/projects-client/model-enablement.js +5 -0
- package/dist/core/rest/projects-client/notifications.d.ts +95 -0
- package/dist/core/rest/projects-client/notifications.js +61 -0
- package/dist/core/rest/projects-client/oauth-clients.d.ts +41 -0
- package/dist/core/rest/projects-client/oauth-clients.js +24 -0
- package/dist/core/rest/projects-client/policies.d.ts +26 -0
- package/dist/core/rest/projects-client/policies.js +8 -0
- package/dist/core/rest/projects-client/presentations.d.ts +11 -0
- package/dist/core/rest/projects-client/presentations.js +8 -0
- package/dist/core/rest/projects-client/project-agents.d.ts +10 -0
- package/dist/core/rest/projects-client/project-agents.js +22 -0
- package/dist/core/rest/projects-client/projects.d.ts +376 -0
- package/dist/core/rest/projects-client/projects.js +237 -0
- package/dist/core/rest/projects-client/prompt-attachments.d.ts +31 -0
- package/dist/core/rest/projects-client/prompt-attachments.js +294 -0
- package/dist/core/rest/projects-client/provider-connections.d.ts +54 -0
- package/dist/core/rest/projects-client/provider-connections.js +28 -0
- package/dist/core/rest/projects-client/public-session-shares.d.ts +49 -0
- package/dist/core/rest/projects-client/public-session-shares.js +35 -0
- package/dist/core/rest/projects-client/referrals.d.ts +52 -0
- package/dist/core/rest/projects-client/referrals.js +19 -0
- package/dist/core/rest/projects-client/review-items.d.ts +139 -0
- package/dist/core/rest/projects-client/review-items.js +217 -0
- package/dist/core/rest/projects-client/review.d.ts +56 -0
- package/dist/core/rest/projects-client/review.js +23 -0
- package/dist/core/rest/projects-client/sandbox-shares.d.ts +21 -0
- package/dist/core/rest/projects-client/sandbox-shares.js +19 -0
- package/dist/core/rest/projects-client/sandbox.d.ts +144 -0
- package/dist/core/rest/projects-client/sandbox.js +35 -0
- package/dist/core/rest/projects-client/secrets.d.ts +187 -0
- package/dist/core/rest/projects-client/secrets.js +79 -0
- package/dist/core/rest/projects-client/session-attachments.d.ts +22 -0
- package/dist/core/rest/projects-client/session-attachments.js +166 -0
- package/dist/core/rest/projects-client/session-costs.d.ts +193 -0
- package/dist/core/rest/projects-client/session-costs.js +87 -0
- package/dist/core/rest/projects-client/session-prompt-actions.d.ts +10 -0
- package/dist/core/rest/projects-client/session-prompt-actions.js +4 -0
- package/dist/core/rest/projects-client/session-reminders.d.ts +58 -0
- package/dist/core/rest/projects-client/session-reminders.js +50 -0
- package/dist/core/rest/projects-client/session-sandbox.d.ts +85 -0
- package/dist/core/rest/projects-client/session-sandbox.js +113 -0
- package/dist/core/rest/projects-client/sessions.d.ts +670 -0
- package/dist/core/rest/projects-client/sessions.js +321 -0
- package/dist/core/rest/projects-client/setup-links.d.ts +54 -0
- package/dist/core/rest/projects-client/setup-links.js +22 -0
- package/dist/core/rest/projects-client/shared.d.ts +51 -0
- package/dist/core/rest/projects-client/shared.js +29 -0
- package/dist/core/rest/projects-client/skills.d.ts +11 -0
- package/dist/core/rest/projects-client/skills.js +8 -0
- package/dist/core/rest/projects-client/starter-suggestions.d.ts +17 -0
- package/dist/core/rest/projects-client/starter-suggestions.js +5 -0
- package/dist/core/rest/projects-client/templates.d.ts +47 -0
- package/dist/core/rest/projects-client/templates.js +7 -0
- package/dist/core/rest/projects-client/tokens.d.ts +94 -0
- package/dist/core/rest/projects-client/tokens.js +46 -0
- package/dist/core/rest/projects-client/triggers.d.ts +175 -0
- package/dist/core/rest/projects-client/triggers.js +29 -0
- package/dist/core/runtime/attachment-part.d.ts +3 -0
- package/dist/core/runtime/attachment-part.js +18 -0
- package/dist/core/runtime/beeuni-master.d.ts +477 -0
- package/dist/core/runtime/beeuni-master.js +264 -0
- package/dist/core/runtime/client.d.ts +30 -0
- package/dist/core/runtime/client.js +124 -0
- package/dist/core/runtime/env.d.ts +8 -0
- package/dist/core/runtime/env.js +42 -0
- package/dist/core/runtime/pty.d.ts +43 -0
- package/dist/core/runtime/pty.js +117 -0
- package/dist/core/runtime/runtime-rest-client.d.ts +414 -0
- package/dist/core/runtime/runtime-rest-client.js +296 -0
- package/dist/core/runtime/runtime-types.d.ts +1094 -0
- package/dist/core/runtime/runtime-types.js +1 -0
- package/dist/core/runtime/transcript-types.d.ts +507 -0
- package/dist/core/runtime/transcript-types.js +31 -0
- package/dist/core/runtime/triggers.d.ts +1 -0
- package/dist/core/runtime/triggers.js +18 -0
- package/dist/core/session/compaction.d.ts +10 -0
- package/dist/core/session/compaction.js +22 -0
- package/dist/core/session/connection.d.ts +20 -0
- package/dist/core/session/connection.js +52 -0
- package/dist/core/session/control-stream.d.ts +62 -0
- package/dist/core/session/control-stream.js +329 -0
- package/dist/core/session/current-runtime.d.ts +14 -0
- package/dist/core/session/current-runtime.js +34 -0
- package/dist/core/session/health.d.ts +41 -0
- package/dist/core/session/health.js +53 -0
- package/dist/core/session/host-signals.d.ts +3 -0
- package/dist/core/session/host-signals.js +16 -0
- package/dist/core/session/index.d.ts +15 -0
- package/dist/core/session/index.js +14 -0
- package/dist/core/session/message-queue.d.ts +43 -0
- package/dist/core/session/message-queue.js +101 -0
- package/dist/core/session/open-bundle.d.ts +24 -0
- package/dist/core/session/open-bundle.js +135 -0
- package/dist/core/session/poll-owner.d.ts +5 -0
- package/dist/core/session/poll-owner.js +58 -0
- package/dist/core/session/presentation.d.ts +11 -0
- package/dist/core/session/presentation.js +70 -0
- package/dist/core/session/preview-auth.d.ts +6 -0
- package/dist/core/session/preview-auth.js +36 -0
- package/dist/core/session/preview-config.d.ts +5 -0
- package/dist/core/session/preview-config.js +54 -0
- package/dist/core/session/preview-options.d.ts +9 -0
- package/dist/core/session/preview-options.js +12 -0
- package/dist/core/session/preview-origin-trust.d.ts +7 -0
- package/dist/core/session/preview-origin-trust.js +64 -0
- package/dist/core/session/preview-probe.d.ts +7 -0
- package/dist/core/session/preview-probe.js +36 -0
- package/dist/core/session/preview.d.ts +3 -0
- package/dist/core/session/preview.js +66 -0
- package/dist/core/session/project-session-read.d.ts +5 -0
- package/dist/core/session/project-session-read.js +12 -0
- package/dist/core/session/rewind.d.ts +29 -0
- package/dist/core/session/rewind.js +53 -0
- package/dist/core/session/runtime-gone.d.ts +5 -0
- package/dist/core/session/runtime-gone.js +14 -0
- package/dist/core/session/runtime-sessions.d.ts +7 -0
- package/dist/core/session/runtime-sessions.js +26 -0
- package/dist/core/session/runtime-verbs.d.ts +34 -0
- package/dist/core/session/runtime-verbs.js +94 -0
- package/dist/core/session/server-store/active.d.ts +7 -0
- package/dist/core/session/server-store/active.js +35 -0
- package/dist/core/session/server-store/types.d.ts +4 -0
- package/dist/core/session/server-store/types.js +1 -0
- package/dist/core/session/server-store/url-helpers.d.ts +5 -0
- package/dist/core/session/server-store/url-helpers.js +25 -0
- package/dist/core/session/session-runtime-registry.d.ts +9 -0
- package/dist/core/session/session-runtime-registry.js +28 -0
- package/dist/core/session/single-flight.d.ts +3 -0
- package/dist/core/session/single-flight.js +22 -0
- package/dist/core/session/static-file-preview.d.ts +10 -0
- package/dist/core/session/static-file-preview.js +34 -0
- package/dist/core/session/status-vocabulary.d.ts +23 -0
- package/dist/core/session/status-vocabulary.js +59 -0
- package/dist/core/session/turn-end-cause.d.ts +22 -0
- package/dist/core/session/turn-end-cause.js +41 -0
- package/dist/core/session/turn-end-settle.d.ts +1 -0
- package/dist/core/session/turn-end-settle.js +1 -0
- package/dist/core/session/url.d.ts +49 -0
- package/dist/core/session/url.js +415 -0
- package/dist/core/session/wake-escalation.d.ts +37 -0
- package/dist/core/session/wake-escalation.js +104 -0
- package/dist/core/session/wire-id-unwrap.d.ts +2 -0
- package/dist/core/session/wire-id-unwrap.js +15 -0
- package/dist/core/session/wire-message-id.d.ts +27 -0
- package/dist/core/session/wire-message-id.js +88 -0
- package/dist/core/session/working-evidence.d.ts +13 -0
- package/dist/core/session/working-evidence.js +25 -0
- package/dist/core/session/working-project.d.ts +2 -0
- package/dist/core/session/working-project.js +145 -0
- package/dist/core/session/working-runtime.d.ts +3 -0
- package/dist/core/session/working-runtime.js +16 -0
- package/dist/core/session/working-server.d.ts +20 -0
- package/dist/core/session/working-server.js +57 -0
- package/dist/core/session/working-time.d.ts +1 -0
- package/dist/core/session/working-time.js +6 -0
- package/dist/core/session/working.d.ts +58 -0
- package/dist/core/session/working.js +48 -0
- package/dist/core/session-sync/fragment.d.ts +4 -0
- package/dist/core/session-sync/fragment.js +3 -0
- package/dist/core/session-sync/saved-copy-store.d.ts +23 -0
- package/dist/core/session-sync/saved-copy-store.js +232 -0
- package/dist/core/session-sync/saved-transcript.d.ts +20 -0
- package/dist/core/session-sync/saved-transcript.js +35 -0
- package/dist/core/session-sync/session-sync-controller.d.ts +111 -0
- package/dist/core/session-sync/session-sync-controller.js +440 -0
- package/dist/core/stream/chat-events.d.ts +96 -0
- package/dist/core/stream/chat-events.js +95 -0
- package/dist/core/stream/event-stream.d.ts +52 -0
- package/dist/core/stream/event-stream.js +372 -0
- package/dist/core/stream/fetch-sse.d.ts +20 -0
- package/dist/core/stream/fetch-sse.js +136 -0
- package/dist/core/stream/keepalive.d.ts +4 -0
- package/dist/core/stream/keepalive.js +6 -0
- package/dist/core/stream/platform-event-transport.d.ts +2 -0
- package/dist/core/stream/platform-event-transport.js +20 -0
- package/dist/core/turns/classify.d.ts +131 -0
- package/dist/core/turns/classify.js +306 -0
- package/dist/core/turns/errors.d.ts +24 -0
- package/dist/core/turns/errors.js +355 -0
- package/dist/core/turns/grouping.d.ts +47 -0
- package/dist/core/turns/grouping.js +247 -0
- package/dist/core/turns/index.d.ts +13 -0
- package/dist/core/turns/index.js +12 -0
- package/dist/core/turns/open-turn.d.ts +13 -0
- package/dist/core/turns/open-turn.js +17 -0
- package/dist/core/turns/parts.d.ts +60 -0
- package/dist/core/turns/parts.js +414 -0
- package/dist/core/turns/segments/burst-summary.d.ts +9 -0
- package/dist/core/turns/segments/burst-summary.js +45 -0
- package/dist/core/turns/segments/compaction-state.d.ts +19 -0
- package/dist/core/turns/segments/compaction-state.js +42 -0
- package/dist/core/turns/segments/group-steps.d.ts +11 -0
- package/dist/core/turns/segments/group-steps.js +65 -0
- package/dist/core/turns/segments/index.d.ts +12 -0
- package/dist/core/turns/segments/index.js +12 -0
- package/dist/core/turns/segments/merge-steps.d.ts +21 -0
- package/dist/core/turns/segments/merge-steps.js +100 -0
- package/dist/core/turns/segments/message-time.d.ts +12 -0
- package/dist/core/turns/segments/message-time.js +82 -0
- package/dist/core/turns/segments/narration.d.ts +9 -0
- package/dist/core/turns/segments/narration.js +573 -0
- package/dist/core/turns/segments/segment-turn.d.ts +15 -0
- package/dist/core/turns/segments/segment-turn.js +32 -0
- package/dist/core/turns/segments/session-activity-groups.d.ts +20 -0
- package/dist/core/turns/segments/session-activity-groups.js +56 -0
- package/dist/core/turns/segments/show-group.d.ts +23 -0
- package/dist/core/turns/segments/show-group.js +101 -0
- package/dist/core/turns/segments/step-label.d.ts +10 -0
- package/dist/core/turns/segments/step-label.js +85 -0
- package/dist/core/turns/segments/turn-busy-visibility.d.ts +6 -0
- package/dist/core/turns/segments/turn-busy-visibility.js +9 -0
- package/dist/core/turns/segments/working-turn.d.ts +70 -0
- package/dist/core/turns/segments/working-turn.js +98 -0
- package/dist/core/turns/shell.d.ts +5 -0
- package/dist/core/turns/shell.js +21 -0
- package/dist/core/turns/state.d.ts +24 -0
- package/dist/core/turns/state.js +364 -0
- package/dist/core/turns/text-scan.d.ts +21 -0
- package/dist/core/turns/text-scan.js +347 -0
- package/dist/core/turns/tool-kind.d.ts +3 -0
- package/dist/core/turns/tool-kind.js +99 -0
- package/dist/core/turns/tool-registry.d.ts +8 -0
- package/dist/core/turns/tool-registry.js +87 -0
- package/dist/core/turns/tools/agent-helpers.d.ts +9 -0
- package/dist/core/turns/tools/agent-helpers.js +53 -0
- package/dist/core/turns/tools/file-verb.d.ts +10 -0
- package/dist/core/turns/tools/file-verb.js +22 -0
- package/dist/core/turns/tools/index.d.ts +14 -0
- package/dist/core/turns/tools/index.js +14 -0
- package/dist/core/turns/tools/memory-helpers.d.ts +15 -0
- package/dist/core/turns/tools/memory-helpers.js +50 -0
- package/dist/core/turns/tools/patch-summary.d.ts +6 -0
- package/dist/core/turns/tools/patch-summary.js +21 -0
- package/dist/core/turns/tools/presentation-helpers.d.ts +15 -0
- package/dist/core/turns/tools/presentation-helpers.js +17 -0
- package/dist/core/turns/tools/question-helpers.d.ts +9 -0
- package/dist/core/turns/tools/question-helpers.js +12 -0
- package/dist/core/turns/tools/read-helpers.d.ts +7 -0
- package/dist/core/turns/tools/read-helpers.js +24 -0
- package/dist/core/turns/tools/search-query.d.ts +1 -0
- package/dist/core/turns/tools/search-query.js +73 -0
- package/dist/core/turns/tools/show-availability.d.ts +11 -0
- package/dist/core/turns/tools/show-availability.js +38 -0
- package/dist/core/turns/tools/skill-helpers.d.ts +5 -0
- package/dist/core/turns/tools/skill-helpers.js +61 -0
- package/dist/core/turns/tools/tool-meta.d.ts +30 -0
- package/dist/core/turns/tools/tool-meta.js +146 -0
- package/dist/core/turns/tools/tool-outcome.d.ts +15 -0
- package/dist/core/turns/tools/tool-outcome.js +147 -0
- package/dist/core/turns/tools/tool-output-format.d.ts +17 -0
- package/dist/core/turns/tools/tool-output-format.js +124 -0
- package/dist/core/turns/tools/web-helpers.d.ts +34 -0
- package/dist/core/turns/tools/web-helpers.js +229 -0
- package/dist/core/turns/types.d.ts +110 -0
- package/dist/core/turns/types.js +1 -0
- package/dist/core/turns/view-model.d.ts +76 -0
- package/dist/core/turns/view-model.js +300 -0
- package/dist/deprecated/api-client.d.ts +1 -0
- package/dist/deprecated/api-client.js +1 -0
- package/dist/deprecated/auth.d.ts +1 -0
- package/dist/deprecated/auth.js +1 -0
- package/dist/deprecated/config.d.ts +1 -0
- package/dist/deprecated/config.js +1 -0
- package/dist/deprecated/event-stream.d.ts +1 -0
- package/dist/deprecated/event-stream.js +1 -0
- package/dist/deprecated/feature-flags.d.ts +1 -0
- package/dist/deprecated/feature-flags.js +1 -0
- package/dist/deprecated/files.d.ts +1 -0
- package/dist/deprecated/files.js +1 -0
- package/dist/deprecated/fresh-sessions.d.ts +1 -0
- package/dist/deprecated/fresh-sessions.js +1 -0
- package/dist/deprecated/idb-sync-cache.d.ts +1 -0
- package/dist/deprecated/idb-sync-cache.js +1 -0
- package/dist/deprecated/instance-routes.d.ts +1 -0
- package/dist/deprecated/instance-routes.js +1 -0
- package/dist/deprecated/opencode-client.d.ts +1 -0
- package/dist/deprecated/opencode-client.js +1 -0
- package/dist/deprecated/opencode-errors.d.ts +1 -0
- package/dist/deprecated/opencode-errors.js +1 -0
- package/dist/deprecated/opencode-pending-store.d.ts +1 -0
- package/dist/deprecated/opencode-pending-store.js +1 -0
- package/dist/deprecated/platform-client.d.ts +1 -0
- package/dist/deprecated/platform-client.js +1 -0
- package/dist/deprecated/projects-client.d.ts +1 -0
- package/dist/deprecated/projects-client.js +1 -0
- package/dist/deprecated/sandbox-connection-store.d.ts +1 -0
- package/dist/deprecated/sandbox-connection-store.js +1 -0
- package/dist/deprecated/server-store.d.ts +1 -0
- package/dist/deprecated/server-store.js +1 -0
- package/dist/deprecated/session-url.d.ts +1 -0
- package/dist/deprecated/session-url.js +1 -0
- package/dist/deprecated/session.d.ts +1 -0
- package/dist/deprecated/session.js +1 -0
- package/dist/deprecated/sync-store.d.ts +1 -0
- package/dist/deprecated/sync-store.js +1 -0
- package/dist/deprecated/turns.d.ts +1 -0
- package/dist/deprecated/turns.js +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +53 -0
- package/dist/internal/diagnostics-store.d.ts +1 -0
- package/dist/internal/diagnostics-store.js +1 -0
- package/dist/internal/idb-sync-cache.d.ts +1 -0
- package/dist/internal/idb-sync-cache.js +1 -0
- package/dist/internal/managed-storage.d.ts +1 -0
- package/dist/internal/managed-storage.js +1 -0
- package/dist/internal/opencode-pending-store.d.ts +1 -0
- package/dist/internal/opencode-pending-store.js +1 -0
- package/dist/internal/sandbox-connection-store.d.ts +1 -0
- package/dist/internal/sandbox-connection-store.js +1 -0
- package/dist/internal/server-store.d.ts +1 -0
- package/dist/internal/server-store.js +1 -0
- package/dist/internal/sync-store.d.ts +1 -0
- package/dist/internal/sync-store.js +1 -0
- package/dist/node/app-guard.d.ts +36 -0
- package/dist/node/app-guard.js +118 -0
- package/dist/node/app-viewer.d.ts +30 -0
- package/dist/node/app-viewer.js +113 -0
- package/dist/node/auth.d.ts +52 -0
- package/dist/node/auth.js +387 -0
- package/dist/node/scoped-client.d.ts +9 -0
- package/dist/node/scoped-client.js +106 -0
- package/dist/node/server.d.ts +8 -0
- package/dist/node/server.js +5 -0
- package/dist/platform/auth-core.d.ts +10 -0
- package/dist/platform/auth-core.js +44 -0
- package/dist/platform/config-node.d.ts +4 -0
- package/dist/platform/config-node.js +13 -0
- package/dist/platform/session-id.d.ts +1 -0
- package/dist/platform/session-id.js +15 -0
- package/dist/platform/storage/managed-storage.d.ts +25 -0
- package/dist/platform/storage/managed-storage.js +215 -0
- package/dist/platform/strings.d.ts +1 -0
- package/dist/platform/strings.js +6 -0
- package/dist/platform/ui.d.ts +5 -0
- package/dist/platform/ui.js +16 -0
- package/dist/react/agent-selection-scope.d.ts +7 -0
- package/dist/react/agent-selection-scope.js +3 -0
- package/dist/react/bedrock-invokable.d.ts +1 -0
- package/dist/react/bedrock-invokable.js +1 -0
- package/dist/react/chat/index.d.ts +2 -0
- package/dist/react/chat/index.js +3 -0
- package/dist/react/chat/render-parts.d.ts +11 -0
- package/dist/react/chat/render-parts.js +10 -0
- package/dist/react/chat/use-chat-turns.d.ts +9 -0
- package/dist/react/chat/use-chat-turns.js +9 -0
- package/dist/react/connector-setup.d.ts +21 -0
- package/dist/react/connector-setup.js +130 -0
- package/dist/react/file-keys.d.ts +16 -0
- package/dist/react/file-keys.js +16 -0
- package/dist/react/hold-live-start.d.ts +3 -0
- package/dist/react/hold-live-start.js +27 -0
- package/dist/react/human-presence.d.ts +15 -0
- package/dist/react/human-presence.js +62 -0
- package/dist/react/identity-reset-registry.d.ts +2 -0
- package/dist/react/identity-reset-registry.js +14 -0
- package/dist/react/index.d.ts +62 -0
- package/dist/react/index.js +63 -0
- package/dist/react/initial-session-pin.d.ts +14 -0
- package/dist/react/initial-session-pin.js +28 -0
- package/dist/react/invalidate-project.d.ts +22 -0
- package/dist/react/invalidate-project.js +26 -0
- package/dist/react/model-flatten.d.ts +1 -0
- package/dist/react/model-flatten.js +1 -0
- package/dist/react/opencode.d.ts +43 -0
- package/dist/react/opencode.js +43 -0
- package/dist/react/prefetch-session-open.d.ts +5 -0
- package/dist/react/prefetch-session-open.js +48 -0
- package/dist/react/prefetch-session-start.d.ts +2 -0
- package/dist/react/prefetch-session-start.js +9 -0
- package/dist/react/provider-refresh.d.ts +9 -0
- package/dist/react/provider-refresh.js +72 -0
- package/dist/react/provider-selection.d.ts +1 -0
- package/dist/react/provider-selection.js +1 -0
- package/dist/react/pty-query-state.d.ts +2 -0
- package/dist/react/pty-query-state.js +6 -0
- package/dist/react/query-contracts.d.ts +49 -0
- package/dist/react/query-contracts.js +63 -0
- package/dist/react/query-keys.d.ts +105 -0
- package/dist/react/query-keys.js +115 -0
- package/dist/react/reset-identity-state.d.ts +2 -0
- package/dist/react/reset-identity-state.js +19 -0
- package/dist/react/retired-endpoint.d.ts +3 -0
- package/dist/react/retired-endpoint.js +15 -0
- package/dist/react/route-project.d.ts +6 -0
- package/dist/react/route-project.js +9 -0
- package/dist/react/run-pty-command.d.ts +4 -0
- package/dist/react/run-pty-command.js +41 -0
- package/dist/react/runtime-actions.d.ts +31 -0
- package/dist/react/runtime-actions.js +87 -0
- package/dist/react/self-heal-poll-gate.d.ts +8 -0
- package/dist/react/self-heal-poll-gate.js +5 -0
- package/dist/react/session-agent-name-guard.d.ts +1 -0
- package/dist/react/session-agent-name-guard.js +5 -0
- package/dist/react/session-cache-write.d.ts +8 -0
- package/dist/react/session-cache-write.js +116 -0
- package/dist/react/session-start-giveup.d.ts +4 -0
- package/dist/react/session-start-giveup.js +5 -0
- package/dist/react/session-start-stash.d.ts +17 -0
- package/dist/react/session-start-stash.js +146 -0
- package/dist/react/session-stop.d.ts +20 -0
- package/dist/react/session-stop.js +63 -0
- package/dist/react/session-title-sync.d.ts +12 -0
- package/dist/react/session-title-sync.js +88 -0
- package/dist/react/session-transcript-subscription.d.ts +7 -0
- package/dist/react/session-transcript-subscription.js +71 -0
- package/dist/react/sign-in-with-beeuni.d.ts +330 -0
- package/dist/react/sign-in-with-beeuni.js +51 -0
- package/dist/react/teams-install-polling.d.ts +3 -0
- package/dist/react/teams-install-polling.js +4 -0
- package/dist/react/use-accounts.d.ts +47 -0
- package/dist/react/use-accounts.js +31 -0
- package/dist/react/use-admin-accounts.d.ts +236 -0
- package/dist/react/use-admin-accounts.js +287 -0
- package/dist/react/use-admin-activity-analytics.d.ts +48 -0
- package/dist/react/use-admin-activity-analytics.js +47 -0
- package/dist/react/use-admin-analytics.d.ts +331 -0
- package/dist/react/use-admin-analytics.js +85 -0
- package/dist/react/use-admin-billing.d.ts +26 -0
- package/dist/react/use-admin-billing.js +13 -0
- package/dist/react/use-admin-feedback.d.ts +118 -0
- package/dist/react/use-admin-feedback.js +46 -0
- package/dist/react/use-admin-projects.d.ts +31 -0
- package/dist/react/use-admin-projects.js +27 -0
- package/dist/react/use-admin-providers.d.ts +20 -0
- package/dist/react/use-admin-providers.js +45 -0
- package/dist/react/use-admin-role.d.ts +4 -0
- package/dist/react/use-admin-role.js +15 -0
- package/dist/react/use-admin-sandboxes.d.ts +156 -0
- package/dist/react/use-admin-sandboxes.js +52 -0
- package/dist/react/use-authenticated-preview-url.d.ts +3 -0
- package/dist/react/use-authenticated-preview-url.js +96 -0
- package/dist/react/use-beeuni-app-viewer.d.ts +12 -0
- package/dist/react/use-beeuni-app-viewer.js +19 -0
- package/dist/react/use-beeuni-master.d.ts +333 -0
- package/dist/react/use-beeuni-master.js +845 -0
- package/dist/react/use-can.d.ts +35 -0
- package/dist/react/use-can.js +129 -0
- package/dist/react/use-canonical-opencode-session.d.ts +21 -0
- package/dist/react/use-canonical-opencode-session.js +44 -0
- package/dist/react/use-change-requests.d.ts +291 -0
- package/dist/react/use-change-requests.js +31 -0
- package/dist/react/use-connector-query.d.ts +7 -0
- package/dist/react/use-connector-query.js +23 -0
- package/dist/react/use-current-runtime.d.ts +2 -0
- package/dist/react/use-current-runtime.js +6 -0
- package/dist/react/use-feature-flag.d.ts +6 -0
- package/dist/react/use-feature-flag.js +25 -0
- package/dist/react/use-gateway-catalog-sync.d.ts +1 -0
- package/dist/react/use-gateway-catalog-sync.js +40 -0
- package/dist/react/use-gateway-routing-policy.d.ts +8 -0
- package/dist/react/use-gateway-routing-policy.js +36 -0
- package/dist/react/use-impersonation.d.ts +20 -0
- package/dist/react/use-impersonation.js +55 -0
- package/dist/react/use-model-access.d.ts +9 -0
- package/dist/react/use-model-access.js +46 -0
- package/dist/react/use-model-defaults.d.ts +23 -0
- package/dist/react/use-model-defaults.js +115 -0
- package/dist/react/use-model-enablement.d.ts +8 -0
- package/dist/react/use-model-enablement.js +69 -0
- package/dist/react/use-model-store.d.ts +47 -0
- package/dist/react/use-model-store.js +234 -0
- package/dist/react/use-notifications.d.ts +618 -0
- package/dist/react/use-notifications.js +104 -0
- package/dist/react/use-opencode-config.d.ts +12 -0
- package/dist/react/use-opencode-config.js +69 -0
- package/dist/react/use-opencode-events/diagnostics.d.ts +4 -0
- package/dist/react/use-opencode-events/diagnostics.js +42 -0
- package/dist/react/use-opencode-events/handle-event.d.ts +23 -0
- package/dist/react/use-opencode-events/handle-event.js +57 -0
- package/dist/react/use-opencode-events/handle-interaction-event.d.ts +3 -0
- package/dist/react/use-opencode-events/handle-interaction-event.js +41 -0
- package/dist/react/use-opencode-events/handle-message-event.d.ts +3 -0
- package/dist/react/use-opencode-events/handle-message-event.js +32 -0
- package/dist/react/use-opencode-events/handle-session-event.d.ts +4 -0
- package/dist/react/use-opencode-events/handle-session-event.js +240 -0
- package/dist/react/use-opencode-events/handle-workspace-event.d.ts +3 -0
- package/dist/react/use-opencode-events/handle-workspace-event.js +112 -0
- package/dist/react/use-opencode-events/handler-context.d.ts +28 -0
- package/dist/react/use-opencode-events/handler-context.js +1 -0
- package/dist/react/use-opencode-events/helpers.d.ts +27 -0
- package/dist/react/use-opencode-events/helpers.js +126 -0
- package/dist/react/use-opencode-events/hydrate-core.d.ts +22 -0
- package/dist/react/use-opencode-events/hydrate-core.js +78 -0
- package/dist/react/use-opencode-events/index.d.ts +9 -0
- package/dist/react/use-opencode-events/index.js +181 -0
- package/dist/react/use-opencode-events/rehydrate-targets.d.ts +1 -0
- package/dist/react/use-opencode-events/rehydrate-targets.js +3 -0
- package/dist/react/use-opencode-events/runtime-stream-signals.d.ts +19 -0
- package/dist/react/use-opencode-events/runtime-stream-signals.js +22 -0
- package/dist/react/use-opencode-events/stream-revival.d.ts +11 -0
- package/dist/react/use-opencode-events/stream-revival.js +60 -0
- package/dist/react/use-opencode-events/types.d.ts +2 -0
- package/dist/react/use-opencode-events/types.js +1 -0
- package/dist/react/use-opencode-events/use-event-stream-refs.d.ts +16 -0
- package/dist/react/use-opencode-events/use-event-stream-refs.js +129 -0
- package/dist/react/use-opencode-local.d.ts +72 -0
- package/dist/react/use-opencode-local.js +306 -0
- package/dist/react/use-opencode-mcp.d.ts +29 -0
- package/dist/react/use-opencode-mcp.js +149 -0
- package/dist/react/use-opencode-pty.d.ts +39 -0
- package/dist/react/use-opencode-pty.js +61 -0
- package/dist/react/use-opencode-sessions/agents.d.ts +11 -0
- package/dist/react/use-opencode-sessions/agents.js +57 -0
- package/dist/react/use-opencode-sessions/commands.d.ts +16 -0
- package/dist/react/use-opencode-sessions/commands.js +42 -0
- package/dist/react/use-opencode-sessions/files.d.ts +2 -0
- package/dist/react/use-opencode-sessions/files.js +144 -0
- package/dist/react/use-opencode-sessions/index.d.ts +15 -0
- package/dist/react/use-opencode-sessions/index.js +15 -0
- package/dist/react/use-opencode-sessions/keys.d.ts +102 -0
- package/dist/react/use-opencode-sessions/keys.js +38 -0
- package/dist/react/use-opencode-sessions/mcp.d.ts +2 -0
- package/dist/react/use-opencode-sessions/mcp.js +19 -0
- package/dist/react/use-opencode-sessions/messages.d.ts +57 -0
- package/dist/react/use-opencode-sessions/messages.js +342 -0
- package/dist/react/use-opencode-sessions/no-compaction-model-error.d.ts +3 -0
- package/dist/react/use-opencode-sessions/no-compaction-model-error.js +6 -0
- package/dist/react/use-opencode-sessions/parts.d.ts +12 -0
- package/dist/react/use-opencode-sessions/parts.js +31 -0
- package/dist/react/use-opencode-sessions/permissions.d.ts +5 -0
- package/dist/react/use-opencode-sessions/permissions.js +44 -0
- package/dist/react/use-opencode-sessions/projects.d.ts +6 -0
- package/dist/react/use-opencode-sessions/projects.js +49 -0
- package/dist/react/use-opencode-sessions/provider-load-plan.d.ts +5 -0
- package/dist/react/use-opencode-sessions/provider-load-plan.js +3 -0
- package/dist/react/use-opencode-sessions/providers.d.ts +10 -0
- package/dist/react/use-opencode-sessions/providers.js +98 -0
- package/dist/react/use-opencode-sessions/sessions.d.ts +34 -0
- package/dist/react/use-opencode-sessions/sessions.js +330 -0
- package/dist/react/use-opencode-sessions/shared.d.ts +10 -0
- package/dist/react/use-opencode-sessions/shared.js +36 -0
- package/dist/react/use-opencode-sessions/sharing.d.ts +3 -0
- package/dist/react/use-opencode-sessions/sharing.js +51 -0
- package/dist/react/use-opencode-sessions/tools.d.ts +5 -0
- package/dist/react/use-opencode-sessions/tools.js +48 -0
- package/dist/react/use-opencode-sessions/vcs.d.ts +7 -0
- package/dist/react/use-opencode-sessions/vcs.js +24 -0
- package/dist/react/use-ops-overview.d.ts +63 -0
- package/dist/react/use-ops-overview.js +15 -0
- package/dist/react/use-permission-self-heal.d.ts +10 -0
- package/dist/react/use-permission-self-heal.js +114 -0
- package/dist/react/use-poll-owner.d.ts +1 -0
- package/dist/react/use-poll-owner.js +14 -0
- package/dist/react/use-project-apps.d.ts +879 -0
- package/dist/react/use-project-apps.js +185 -0
- package/dist/react/use-project-config.d.ts +2 -0
- package/dist/react/use-project-config.js +16 -0
- package/dist/react/use-project-files.d.ts +87 -0
- package/dist/react/use-project-files.js +109 -0
- package/dist/react/use-project-gateway.d.ts +26 -0
- package/dist/react/use-project-gateway.js +111 -0
- package/dist/react/use-project-llm-gateway.d.ts +6 -0
- package/dist/react/use-project-llm-gateway.js +20 -0
- package/dist/react/use-project-models.d.ts +4 -0
- package/dist/react/use-project-models.js +31 -0
- package/dist/react/use-project-name.d.ts +4 -0
- package/dist/react/use-project-name.js +35 -0
- package/dist/react/use-project-secrets.d.ts +279 -0
- package/dist/react/use-project-secrets.js +34 -0
- package/dist/react/use-project-session.d.ts +4 -0
- package/dist/react/use-project-session.js +18 -0
- package/dist/react/use-project-sessions.d.ts +447 -0
- package/dist/react/use-project-sessions.js +86 -0
- package/dist/react/use-project-starter-suggestions.d.ts +2 -0
- package/dist/react/use-project-starter-suggestions.js +13 -0
- package/dist/react/use-project-triggers.d.ts +221 -0
- package/dist/react/use-project-triggers.js +53 -0
- package/dist/react/use-prompt-attachments.d.ts +3 -0
- package/dist/react/use-prompt-attachments.js +34 -0
- package/dist/react/use-provider-secrets.d.ts +229 -0
- package/dist/react/use-provider-secrets.js +38 -0
- package/dist/react/use-question-self-heal.d.ts +7 -0
- package/dist/react/use-question-self-heal.js +81 -0
- package/dist/react/use-reminders.d.ts +501 -0
- package/dist/react/use-reminders.js +51 -0
- package/dist/react/use-runtime-boot-stalled.d.ts +2 -0
- package/dist/react/use-runtime-boot-stalled.js +18 -0
- package/dist/react/use-runtime-phase.d.ts +2 -0
- package/dist/react/use-runtime-phase.js +13 -0
- package/dist/react/use-runtime-reconnect.d.ts +52 -0
- package/dist/react/use-runtime-reconnect.js +248 -0
- package/dist/react/use-runtime-supports.d.ts +2 -0
- package/dist/react/use-runtime-supports.js +5 -0
- package/dist/react/use-sandbox-image.d.ts +33 -0
- package/dist/react/use-sandbox-image.js +119 -0
- package/dist/react/use-session-audit.d.ts +4 -0
- package/dist/react/use-session-audit.js +25 -0
- package/dist/react/use-session-message-authors.d.ts +1 -0
- package/dist/react/use-session-message-authors.js +14 -0
- package/dist/react/use-session-messages.d.ts +11 -0
- package/dist/react/use-session-messages.js +62 -0
- package/dist/react/use-session-model-selection.d.ts +8 -0
- package/dist/react/use-session-model-selection.js +20 -0
- package/dist/react/use-session-model-usage.d.ts +1 -0
- package/dist/react/use-session-model-usage.js +13 -0
- package/dist/react/use-session-participants.d.ts +4 -0
- package/dist/react/use-session-participants.js +13 -0
- package/dist/react/use-session-phase.d.ts +8 -0
- package/dist/react/use-session-phase.js +9 -0
- package/dist/react/use-session-picks.d.ts +13 -0
- package/dist/react/use-session-picks.js +65 -0
- package/dist/react/use-session-prefetch.d.ts +6 -0
- package/dist/react/use-session-prefetch.js +22 -0
- package/dist/react/use-session-prompts.d.ts +53 -0
- package/dist/react/use-session-prompts.js +378 -0
- package/dist/react/use-session-send.d.ts +97 -0
- package/dist/react/use-session-send.js +233 -0
- package/dist/react/use-session-start-give-up.d.ts +19 -0
- package/dist/react/use-session-start-give-up.js +59 -0
- package/dist/react/use-session-stream.d.ts +17 -0
- package/dist/react/use-session-stream.js +181 -0
- package/dist/react/use-session-sync.d.ts +43 -0
- package/dist/react/use-session-sync.js +252 -0
- package/dist/react/use-session-transcript-history.d.ts +6 -0
- package/dist/react/use-session-transcript-history.js +38 -0
- package/dist/react/use-session-working.d.ts +37 -0
- package/dist/react/use-session-working.js +217 -0
- package/dist/react/use-session.d.ts +201 -0
- package/dist/react/use-session.js +893 -0
- package/dist/react/use-sessions-needing-input.d.ts +5 -0
- package/dist/react/use-sessions-needing-input.js +23 -0
- package/dist/react/use-static-file-preview.d.ts +9 -0
- package/dist/react/use-static-file-preview.js +72 -0
- package/dist/react/use-system-status.d.ts +38 -0
- package/dist/react/use-system-status.js +5 -0
- package/dist/react/use-teams-installations.d.ts +41 -0
- package/dist/react/use-teams-installations.js +95 -0
- package/dist/react/use-tunnel.d.ts +165 -0
- package/dist/react/use-tunnel.js +186 -0
- package/dist/react/use-visible-agents.d.ts +9 -0
- package/dist/react/use-visible-agents.js +12 -0
- package/dist/react/use-wake-escalation.d.ts +31 -0
- package/dist/react/use-wake-escalation.js +82 -0
- package/dist/transcript.d.ts +50 -0
- package/dist/transcript.js +93 -0
- package/dist/workspace-search/client.d.ts +19 -0
- package/dist/workspace-search/client.js +229 -0
- package/dist/workspace-search/core.d.ts +21 -0
- package/dist/workspace-search/core.js +259 -0
- package/dist/workspace-search/index.d.ts +2 -0
- package/dist/workspace-search/index.js +2 -0
- package/package.json +178 -0
|
@@ -0,0 +1,893 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
3
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import { useOpenCodeCompactionStore } from '../browser/stores/opencode-compaction-store.js';
|
|
5
|
+
import { useSessionWorkingStore } from '../browser/stores/session-working-store.js';
|
|
6
|
+
import { compactionExpiryAtMs, projectCompacting, serverCompactionRevalidateAtMs, } from '../core/session/compaction.js';
|
|
7
|
+
import { useRuntimePendingStore } from '../browser/stores/opencode-pending-store.js';
|
|
8
|
+
import { markRuntimeReadyVerified, seedConnectionFromReadyStart, } from '../browser/stores/sandbox-connection-store.js';
|
|
9
|
+
import { getSandboxUrlForExternalId } from '../browser/stores/server-store.js';
|
|
10
|
+
import { getBackendUrl } from '../core/session/server-store/url-helpers.js';
|
|
11
|
+
import { ascendingId, useSyncStore } from '../browser/stores/sync-store.js';
|
|
12
|
+
import { BillingError, parseBillingError } from '../core/http/api/errors.js';
|
|
13
|
+
import { isSessionFresh } from '../core/http/fresh-sessions.js';
|
|
14
|
+
import { onSessionStopped } from '../core/http/session-stopped.js';
|
|
15
|
+
import { formatRuntimeError } from '../core/http/runtime-errors.js';
|
|
16
|
+
import { createSessionPrompt, isSessionStartError, sessionStartKey, startProjectSession, } from '../core/rest/projects-client/index.js';
|
|
17
|
+
import { RuntimeNotReadyError, getClient } from '../core/runtime/client.js';
|
|
18
|
+
import { setCurrentRuntime } from '../core/session/current-runtime.js';
|
|
19
|
+
import { onRuntimeGone } from '../core/session/runtime-gone.js';
|
|
20
|
+
import { openSessionBundle } from '../core/session/open-bundle.js';
|
|
21
|
+
import { messagesBeforeRewind } from '../core/session/rewind.js';
|
|
22
|
+
import { extractGatewayErrorDetails, unwrapError } from '../core/turns/errors.js';
|
|
23
|
+
import { holdLiveStart, liveStartPollMode } from './hold-live-start.js';
|
|
24
|
+
import { clearStartStash, readStartStash } from './session-start-stash.js';
|
|
25
|
+
import { reconcileHydratedSessionTitle } from './session-title-sync.js';
|
|
26
|
+
import { seedModelDefaultsFromOpenBundle } from './prefetch-session-open.js';
|
|
27
|
+
import { useSessionTranscriptHistory } from './use-session-transcript-history.js';
|
|
28
|
+
import { useCanonicalRuntimeSession } from './use-canonical-opencode-session.js';
|
|
29
|
+
import { useRuntimeEventStream } from './use-opencode-events/index.js';
|
|
30
|
+
import { useSessionStream } from './use-session-stream.js';
|
|
31
|
+
import { sessionStreamConnected } from '../core/session/control-stream.js';
|
|
32
|
+
import { presenceReporter, watchHumanPresence } from './human-presence.js';
|
|
33
|
+
import { formatModelString } from './use-opencode-local.js';
|
|
34
|
+
import { runtimeKeys, rejectQuestion as rejectQuestionApi, replyToPermission, replyToQuestion, useAbortRuntimeSession, useExecuteRuntimeCommand, useRuntimeSession, } from './use-opencode-sessions/index.js';
|
|
35
|
+
import { mintSessionWireMessageId } from './use-opencode-sessions/messages.js';
|
|
36
|
+
import { unwrap } from './use-opencode-sessions/shared.js';
|
|
37
|
+
import { usePermissionSelfHeal } from './use-permission-self-heal.js';
|
|
38
|
+
import { useProjectConfig } from './use-project-config.js';
|
|
39
|
+
import { useProjectModels } from './use-project-models.js';
|
|
40
|
+
import { useQuestionSelfHeal } from './use-question-self-heal.js';
|
|
41
|
+
import { useRuntimePhase } from './use-runtime-phase.js';
|
|
42
|
+
import { useSessionPicks } from './use-session-picks.js';
|
|
43
|
+
import { derivePhase } from './use-session-phase.js';
|
|
44
|
+
import { isEmptyConversation, resolveSavedTranscript } from '../core/session-sync/saved-transcript.js';
|
|
45
|
+
import { useSessionSync } from './use-session-sync.js';
|
|
46
|
+
import { selectTranscriptShapeKey } from './session-transcript-subscription.js';
|
|
47
|
+
import { useSessionStartGiveUp } from './use-session-start-give-up.js';
|
|
48
|
+
import { useSessionTurnOutcome, useSessionWorking } from './use-session-working.js';
|
|
49
|
+
import { cancelSessionTurn } from './session-stop.js';
|
|
50
|
+
import { useVisibleAgents } from './use-visible-agents.js';
|
|
51
|
+
import { createBeeuni } from '../core/client/beeuni.js';
|
|
52
|
+
import { platformConfig } from '../core/http/config.js';
|
|
53
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
54
|
+
const FRESH_START_404_RETRIES = 12;
|
|
55
|
+
const FRESH_START_404_RETRY_DELAY_MS = 800;
|
|
56
|
+
export function shouldRetrySessionStart(failureCount, error, sessionId) {
|
|
57
|
+
if (isSessionStartError(error) && error.status === 404 && isSessionFresh(sessionId)) {
|
|
58
|
+
return failureCount < FRESH_START_404_RETRIES;
|
|
59
|
+
}
|
|
60
|
+
return !isSessionStartError(error) && failureCount < 3;
|
|
61
|
+
}
|
|
62
|
+
export const SESSION_START_POLL_MS = 1_500;
|
|
63
|
+
export function resolveSessionRuntimeUrl(start) {
|
|
64
|
+
if (!start || start.stage !== 'ready')
|
|
65
|
+
return null;
|
|
66
|
+
const externalId = start.sandbox?.external_id;
|
|
67
|
+
if (externalId)
|
|
68
|
+
return getSandboxUrlForExternalId(externalId);
|
|
69
|
+
const path = start.runtime_url;
|
|
70
|
+
if (!path)
|
|
71
|
+
return null;
|
|
72
|
+
if (/^https?:\/\//i.test(path))
|
|
73
|
+
return path;
|
|
74
|
+
return `${getBackendUrl()}${path.startsWith('/') ? '' : '/'}${path}`;
|
|
75
|
+
}
|
|
76
|
+
export function resolveSendOptions(picks, override) {
|
|
77
|
+
const model = override?.model ?? picks.model;
|
|
78
|
+
const agent = override?.agent ?? picks.agent;
|
|
79
|
+
const variant = override?.variant ?? picks.variant;
|
|
80
|
+
return {
|
|
81
|
+
...(model ? { model } : {}),
|
|
82
|
+
...(agent ? { agent } : {}),
|
|
83
|
+
...(variant ? { variant } : {}),
|
|
84
|
+
...(override?.directory ? { directory: override.directory } : {}),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export function sessionPromptFromParts(runtimeSessionId, parts, options, clientMessageId, nowMs = Date.now()) {
|
|
88
|
+
const messageId = mintSessionWireMessageId(runtimeSessionId, clientMessageId);
|
|
89
|
+
const wireParts = parts.map((part) => {
|
|
90
|
+
if (part.type === 'file') {
|
|
91
|
+
return {
|
|
92
|
+
type: 'file',
|
|
93
|
+
mime: part.mime,
|
|
94
|
+
url: part.url,
|
|
95
|
+
...(part.filename ? { filename: part.filename } : {}),
|
|
96
|
+
...(part.source ? { source: part.source } : {}),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
if (part.type === 'agent')
|
|
100
|
+
return { type: 'agent', name: part.name, ...(part.source ? { source: part.source } : {}) };
|
|
101
|
+
return { type: 'text', text: part.text };
|
|
102
|
+
});
|
|
103
|
+
const overrides = {
|
|
104
|
+
...(options.model ? { model: options.model } : {}),
|
|
105
|
+
...(options.agent ? { agent: options.agent } : {}),
|
|
106
|
+
...(options.variant ? { variant: options.variant } : {}),
|
|
107
|
+
...(options.directory ? { directory: options.directory } : {}),
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
clientMessageId: clientMessageId ?? messageId,
|
|
111
|
+
messageId,
|
|
112
|
+
parts: wireParts,
|
|
113
|
+
...(Object.keys(overrides).length ? { overrides } : {}),
|
|
114
|
+
remintOnDelivery: true,
|
|
115
|
+
clientSentAtMs: nowMs,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export function shouldPollSessionStart(error, data, now = Date.now()) {
|
|
119
|
+
if (isSessionStartError(error))
|
|
120
|
+
return false;
|
|
121
|
+
if (data?.retriable === false)
|
|
122
|
+
return false;
|
|
123
|
+
const stage = data?.stage;
|
|
124
|
+
if (stage === 'ready' || stage === 'failed' || stage === 'stopped')
|
|
125
|
+
return false;
|
|
126
|
+
const retryPause = sessionStartRetryPauseMs(data, now);
|
|
127
|
+
return retryPause ?? SESSION_START_POLL_MS;
|
|
128
|
+
}
|
|
129
|
+
function sessionStartRetryPauseMs(data, now) {
|
|
130
|
+
const nextRetryAt = data?.failure?.evidence?.next_retry_at;
|
|
131
|
+
if (!nextRetryAt)
|
|
132
|
+
return null;
|
|
133
|
+
const atMs = Date.parse(nextRetryAt);
|
|
134
|
+
if (!Number.isFinite(atMs))
|
|
135
|
+
return null;
|
|
136
|
+
return Math.max(SESSION_START_POLL_MS, Math.min(atMs - now + 1_000, 60_000));
|
|
137
|
+
}
|
|
138
|
+
export { START_INCONCLUSIVE_GIVE_UP_MS, hasStartGivenUp, nextInconclusiveSince, } from './use-session-start-give-up.js';
|
|
139
|
+
export function computeStartSettled(input) {
|
|
140
|
+
if (!input.enabled)
|
|
141
|
+
return true;
|
|
142
|
+
if (input.hasGivenUp)
|
|
143
|
+
return true;
|
|
144
|
+
if (input.isFetching)
|
|
145
|
+
return false;
|
|
146
|
+
return !shouldPollSessionStart(input.error, input.data);
|
|
147
|
+
}
|
|
148
|
+
export const SESSION_START_FRESH_MS = 30_000;
|
|
149
|
+
const RUNTIME_GONE_REFETCH_MIN_MS = 3_000;
|
|
150
|
+
export function sessionStartStaleTime(query) {
|
|
151
|
+
return query.state.data?.stage === 'ready' ? SESSION_START_FRESH_MS : 0;
|
|
152
|
+
}
|
|
153
|
+
export function cachedStartResultIsReady(cachedState) {
|
|
154
|
+
return cachedState?.data?.stage === 'ready';
|
|
155
|
+
}
|
|
156
|
+
function startPollSignature(data) {
|
|
157
|
+
return [
|
|
158
|
+
data?.stage ?? '',
|
|
159
|
+
data?.reason ?? '',
|
|
160
|
+
data?.failure?.evidence?.next_retry_at ?? '',
|
|
161
|
+
].join('|');
|
|
162
|
+
}
|
|
163
|
+
const SESSION_START_POLL_BACKOFF_STEPS = [
|
|
164
|
+
{ afterMs: 30_000, pollMs: 5_000 },
|
|
165
|
+
{ afterMs: 90_000, pollMs: 15_000 },
|
|
166
|
+
{ afterMs: 240_000, pollMs: 30_000 },
|
|
167
|
+
];
|
|
168
|
+
const START_POLL_PACE_TTL_MS = 300_000;
|
|
169
|
+
const startPollPaceByQuery = new WeakMap();
|
|
170
|
+
function sessionStartRefetchIntervalMs(query, now) {
|
|
171
|
+
if (query.state.data?.stage === 'ready')
|
|
172
|
+
return 60_000;
|
|
173
|
+
const base = shouldPollSessionStart(query.state.error, query.state.data, now);
|
|
174
|
+
if (base === false) {
|
|
175
|
+
startPollPaceByQuery.delete(query);
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
const signature = startPollSignature(query.state.data);
|
|
179
|
+
const previous = startPollPaceByQuery.get(query);
|
|
180
|
+
const pace = previous &&
|
|
181
|
+
previous.signature === signature &&
|
|
182
|
+
now - previous.touchedAt <= START_POLL_PACE_TTL_MS
|
|
183
|
+
? previous
|
|
184
|
+
: { signature, unchangedSince: now, touchedAt: now };
|
|
185
|
+
pace.touchedAt = now;
|
|
186
|
+
startPollPaceByQuery.set(query, pace);
|
|
187
|
+
const unchangedMs = now - pace.unchangedSince;
|
|
188
|
+
const stretched = [...SESSION_START_POLL_BACKOFF_STEPS]
|
|
189
|
+
.reverse()
|
|
190
|
+
.find((step) => unchangedMs >= step.afterMs)?.pollMs;
|
|
191
|
+
return stretched ? Math.max(base, stretched) : base;
|
|
192
|
+
}
|
|
193
|
+
export const SESSION_START_POLL_OPTIONS = {
|
|
194
|
+
refetchInterval: (query) => sessionStartRefetchIntervalMs(query, Date.now()),
|
|
195
|
+
refetchIntervalInBackground: true,
|
|
196
|
+
};
|
|
197
|
+
const RUNTIME_NOT_READY_MARKER = 'Server URL not ready';
|
|
198
|
+
export function markDispatchedForPartIds(sessionId, parts) {
|
|
199
|
+
const partIds = new Set(parts
|
|
200
|
+
.map((p) => p.id)
|
|
201
|
+
.filter((id) => typeof id === 'string' && !!id));
|
|
202
|
+
if (partIds.size === 0)
|
|
203
|
+
return;
|
|
204
|
+
const store = useSyncStore.getState();
|
|
205
|
+
for (const message of store.messages[sessionId] ?? []) {
|
|
206
|
+
if (message.role !== 'user')
|
|
207
|
+
continue;
|
|
208
|
+
const owns = (store.parts[message.id] ?? []).some((p) => partIds.has(p.id));
|
|
209
|
+
if (owns)
|
|
210
|
+
store.markOptimisticDispatched(sessionId, message.id);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
export function beginOptimisticPlainTextSend(sessionId, text) {
|
|
214
|
+
const messageId = ascendingId('msg');
|
|
215
|
+
const partId = ascendingId('prt');
|
|
216
|
+
const optimisticParts = text.trim()
|
|
217
|
+
? [
|
|
218
|
+
{
|
|
219
|
+
id: partId,
|
|
220
|
+
sessionID: sessionId,
|
|
221
|
+
messageID: messageId,
|
|
222
|
+
type: 'text',
|
|
223
|
+
text,
|
|
224
|
+
},
|
|
225
|
+
]
|
|
226
|
+
: [];
|
|
227
|
+
const info = {
|
|
228
|
+
id: messageId,
|
|
229
|
+
sessionID: sessionId,
|
|
230
|
+
role: 'user',
|
|
231
|
+
time: {},
|
|
232
|
+
};
|
|
233
|
+
useSyncStore.getState().optimisticAdd(sessionId, info, optimisticParts);
|
|
234
|
+
return { messageId, parts: [{ type: 'text', text, id: partId }] };
|
|
235
|
+
}
|
|
236
|
+
function errorBody(error) {
|
|
237
|
+
if (!error || typeof error !== 'object')
|
|
238
|
+
return null;
|
|
239
|
+
const holder = error;
|
|
240
|
+
for (const key of ['data', 'details', 'body']) {
|
|
241
|
+
const candidate = holder[key];
|
|
242
|
+
if (candidate && typeof candidate === 'object')
|
|
243
|
+
return candidate;
|
|
244
|
+
}
|
|
245
|
+
return holder;
|
|
246
|
+
}
|
|
247
|
+
function errorBodyMessage(error) {
|
|
248
|
+
const body = errorBody(error);
|
|
249
|
+
for (const key of ['message', 'error']) {
|
|
250
|
+
const value = body?.[key];
|
|
251
|
+
if (typeof value === 'string' && value.trim())
|
|
252
|
+
return value.trim();
|
|
253
|
+
}
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
function connectorRefusalConnections(error) {
|
|
257
|
+
const body = errorBody(error);
|
|
258
|
+
if (body?.code !== 'CONNECTOR_CONNECTION_REQUIRED')
|
|
259
|
+
return null;
|
|
260
|
+
const listed = [body.connector_connections, body.connectorConnections].find(Array.isArray);
|
|
261
|
+
const connections = [];
|
|
262
|
+
for (const entry of listed ?? []) {
|
|
263
|
+
if (!entry || typeof entry !== 'object')
|
|
264
|
+
continue;
|
|
265
|
+
const connection = entry;
|
|
266
|
+
const strategy = connection.authorization_strategy ?? connection.authorizationStrategy;
|
|
267
|
+
if (typeof connection.id !== 'string' || typeof connection.slug !== 'string')
|
|
268
|
+
continue;
|
|
269
|
+
if (strategy !== 'project' && strategy !== 'user')
|
|
270
|
+
continue;
|
|
271
|
+
connections.push({
|
|
272
|
+
id: connection.id,
|
|
273
|
+
slug: connection.slug,
|
|
274
|
+
name: typeof connection.name === 'string' && connection.name ? connection.name : connection.slug,
|
|
275
|
+
authorization_strategy: strategy,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
return connections.length > 0 ? connections : null;
|
|
279
|
+
}
|
|
280
|
+
export function classifySendError(error) {
|
|
281
|
+
if (error instanceof RuntimeNotReadyError ||
|
|
282
|
+
(error instanceof Error && error.message.includes(RUNTIME_NOT_READY_MARKER))) {
|
|
283
|
+
return {
|
|
284
|
+
kind: 'runtime-not-ready',
|
|
285
|
+
message: 'The session runtime is still starting — try again in a moment.',
|
|
286
|
+
cause: error,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
if (error && typeof error === 'object') {
|
|
290
|
+
const parsed = parseBillingError(error);
|
|
291
|
+
if (parsed instanceof BillingError) {
|
|
292
|
+
return {
|
|
293
|
+
kind: 'billing',
|
|
294
|
+
message: parsed.message,
|
|
295
|
+
billing: parsed,
|
|
296
|
+
cause: error,
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
const connectors = connectorRefusalConnections(error);
|
|
300
|
+
if (connectors) {
|
|
301
|
+
return {
|
|
302
|
+
kind: 'connector',
|
|
303
|
+
message: errorBodyMessage(error) ??
|
|
304
|
+
'Connect the required connectors before continuing this session.',
|
|
305
|
+
connectors,
|
|
306
|
+
cause: error,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const gateway = extractGatewayErrorDetails(error);
|
|
311
|
+
const formatted = formatRuntimeError(error);
|
|
312
|
+
return {
|
|
313
|
+
kind: 'runtime-error',
|
|
314
|
+
message: gateway?.message || unwrapError(formatted.message),
|
|
315
|
+
...(gateway
|
|
316
|
+
? {
|
|
317
|
+
gateway: {
|
|
318
|
+
provider: gateway.provider,
|
|
319
|
+
code: gateway.code,
|
|
320
|
+
suggestion: gateway.suggestion,
|
|
321
|
+
upstreamStatus: gateway.upstreamStatus,
|
|
322
|
+
requestId: gateway.requestId,
|
|
323
|
+
},
|
|
324
|
+
}
|
|
325
|
+
: {}),
|
|
326
|
+
cause: error,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
export function buildSessionCommandInput(sessionId, command, args, options = {}) {
|
|
330
|
+
return {
|
|
331
|
+
sessionId,
|
|
332
|
+
command,
|
|
333
|
+
args,
|
|
334
|
+
...(options.agent ? { agent: options.agent } : {}),
|
|
335
|
+
...(options.model ? { model: formatModelString(options.model) } : {}),
|
|
336
|
+
...(options.variant ? { variant: options.variant } : {}),
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
const IDLE_SEND_STATE = { pending: null, sendError: null };
|
|
340
|
+
export function sendStateOnStart(text) {
|
|
341
|
+
return { pending: text, sendError: null };
|
|
342
|
+
}
|
|
343
|
+
export function sendStateOnError(error) {
|
|
344
|
+
return { pending: null, sendError: classifySendError(error) };
|
|
345
|
+
}
|
|
346
|
+
export function sendReceiptId(sessionId, parts, clientMessageId) {
|
|
347
|
+
const identified = parts.find((part) => 'id' in part && typeof part.id === 'string');
|
|
348
|
+
return clientMessageId ?? identified?.id ?? sessionId;
|
|
349
|
+
}
|
|
350
|
+
export async function rewindOpenCodeSession(sessionId, messageId) {
|
|
351
|
+
if (!messageId)
|
|
352
|
+
throw new Error('Session rewind requires a message id');
|
|
353
|
+
unwrap(await getClient().session.revert({
|
|
354
|
+
sessionID: sessionId,
|
|
355
|
+
messageID: messageId,
|
|
356
|
+
}));
|
|
357
|
+
}
|
|
358
|
+
export async function restoreOpenCodeSessionRewind(sessionId) {
|
|
359
|
+
unwrap(await getClient().session.unrevert({ sessionID: sessionId }));
|
|
360
|
+
}
|
|
361
|
+
export async function answerQuestion(requestId, answers) {
|
|
362
|
+
try {
|
|
363
|
+
await replyToQuestion(requestId, answers);
|
|
364
|
+
}
|
|
365
|
+
catch (error) {
|
|
366
|
+
throw classifySendError(error);
|
|
367
|
+
}
|
|
368
|
+
useRuntimePendingStore.getState().removeQuestion(requestId);
|
|
369
|
+
}
|
|
370
|
+
export async function rejectQuestion(requestId) {
|
|
371
|
+
try {
|
|
372
|
+
await rejectQuestionApi(requestId);
|
|
373
|
+
}
|
|
374
|
+
catch (error) {
|
|
375
|
+
throw classifySendError(error);
|
|
376
|
+
}
|
|
377
|
+
useRuntimePendingStore.getState().removeQuestion(requestId);
|
|
378
|
+
}
|
|
379
|
+
export async function answerPermission(requestId, reply, message) {
|
|
380
|
+
try {
|
|
381
|
+
await replyToPermission(requestId, reply, message);
|
|
382
|
+
}
|
|
383
|
+
catch (error) {
|
|
384
|
+
throw classifySendError(error);
|
|
385
|
+
}
|
|
386
|
+
useRuntimePendingStore.getState().removePermission(requestId);
|
|
387
|
+
}
|
|
388
|
+
const DISABLED_CHAT_ENGINE_SYNC = {
|
|
389
|
+
messages: [],
|
|
390
|
+
status: { type: 'idle' },
|
|
391
|
+
freshness: 'idle',
|
|
392
|
+
retryTranscript: () => { },
|
|
393
|
+
isBusy: false,
|
|
394
|
+
isLoading: false,
|
|
395
|
+
mirrorState: 'idle',
|
|
396
|
+
diffs: [],
|
|
397
|
+
todos: [],
|
|
398
|
+
hasOlder: false,
|
|
399
|
+
isLoadingOlder: false,
|
|
400
|
+
loadOlder: async () => { },
|
|
401
|
+
};
|
|
402
|
+
export function useSession(projectId, sessionId, options = {}) {
|
|
403
|
+
const queryClient = useQueryClient();
|
|
404
|
+
const titleRefreshAbortRef = useRef(null);
|
|
405
|
+
const { waitMs = 15_000, repositoryMode, replayStartStash = true, enabled = true, chatEngine = true, initialRuntimeSessionId = options.initialOpenCodeSessionId ?? null, subscribeMessages = true, browserPresence = false, presenceAlerts = false, presencePageExit = false, } = options;
|
|
406
|
+
const [presenceTabId] = useState(() => (browserPresence ? crypto.randomUUID() : null));
|
|
407
|
+
const presenceAlertsRef = useRef(presenceAlerts);
|
|
408
|
+
const presencePageExitRef = useRef(presencePageExit);
|
|
409
|
+
const presenceReporterRef = useRef(null);
|
|
410
|
+
useEffect(() => {
|
|
411
|
+
if (!browserPresence || !presenceTabId || !projectId || !sessionId)
|
|
412
|
+
return;
|
|
413
|
+
const tab_id = presenceTabId;
|
|
414
|
+
const handle = createBeeuni(platformConfig()).session(projectId, sessionId);
|
|
415
|
+
const reporter = presenceReporter(({ active, alerts }) => {
|
|
416
|
+
const keepalive = !active && presencePageExitRef.current;
|
|
417
|
+
void handle.presence({ tab_id, active, alerts }, { keepalive }).catch(() => { });
|
|
418
|
+
}, presenceAlertsRef.current);
|
|
419
|
+
presenceReporterRef.current = reporter;
|
|
420
|
+
const stop = watchHumanPresence({ doc: document, win: window }, reporter.report, () => sessionStreamConnected(projectId, sessionId), () => presencePageExitRef.current);
|
|
421
|
+
return () => {
|
|
422
|
+
presenceReporterRef.current = null;
|
|
423
|
+
stop();
|
|
424
|
+
};
|
|
425
|
+
}, [browserPresence, presenceTabId, projectId, sessionId]);
|
|
426
|
+
useEffect(() => {
|
|
427
|
+
presenceAlertsRef.current = presenceAlerts;
|
|
428
|
+
presenceReporterRef.current?.setAlerts(presenceAlerts);
|
|
429
|
+
}, [presenceAlerts]);
|
|
430
|
+
useEffect(() => {
|
|
431
|
+
presencePageExitRef.current = presencePageExit;
|
|
432
|
+
}, [presencePageExit]);
|
|
433
|
+
const startEnabled = enabled && !!projectId && !!sessionId;
|
|
434
|
+
const streamConnectedRef = useRef(false);
|
|
435
|
+
const stoppedByUserRef = useRef(null);
|
|
436
|
+
const openedAtRef = useRef(null);
|
|
437
|
+
const start = useQuery({
|
|
438
|
+
queryKey: sessionStartKey(projectId, sessionId),
|
|
439
|
+
queryFn: async () => {
|
|
440
|
+
const previous = queryClient.getQueryData(sessionStartKey(projectId, sessionId));
|
|
441
|
+
if (openedAtRef.current?.sessionId !== sessionId)
|
|
442
|
+
openedAtRef.current = { sessionId, at: Date.now() };
|
|
443
|
+
const heldByStop = stoppedByUserRef.current === sessionId;
|
|
444
|
+
const mode = heldByStop
|
|
445
|
+
? 'keep-stopped'
|
|
446
|
+
: liveStartPollMode(previous, typeof document !== 'undefined' && document.hidden);
|
|
447
|
+
if (mode === 'skip' && previous)
|
|
448
|
+
return previous;
|
|
449
|
+
const next = await startProjectSession(projectId, sessionId, {
|
|
450
|
+
waitMs,
|
|
451
|
+
repositoryMode,
|
|
452
|
+
keepStopped: mode === 'keep-stopped',
|
|
453
|
+
intentAgeMs: Date.now() - openedAtRef.current.at,
|
|
454
|
+
});
|
|
455
|
+
if (heldByStop && next && next.stage !== 'stopped' && stoppedByUserRef.current === sessionId) {
|
|
456
|
+
stoppedByUserRef.current = null;
|
|
457
|
+
openedAtRef.current = { sessionId, at: Date.now() };
|
|
458
|
+
}
|
|
459
|
+
return holdLiveStart(previous, next);
|
|
460
|
+
},
|
|
461
|
+
enabled: startEnabled,
|
|
462
|
+
retry: (failureCount, error) => shouldRetrySessionStart(failureCount, error, sessionId),
|
|
463
|
+
retryDelay: (failureCount, error) => isSessionStartError(error) && error.status === 404
|
|
464
|
+
? FRESH_START_404_RETRY_DELAY_MS
|
|
465
|
+
: Math.min(1000 * 2 ** failureCount, 5000),
|
|
466
|
+
staleTime: sessionStartStaleTime,
|
|
467
|
+
...SESSION_START_POLL_OPTIONS,
|
|
468
|
+
refetchInterval: (query) => streamConnectedRef.current && query.state.data?.stage === 'ready'
|
|
469
|
+
? false
|
|
470
|
+
: SESSION_START_POLL_OPTIONS.refetchInterval(query),
|
|
471
|
+
});
|
|
472
|
+
useEffect(() => {
|
|
473
|
+
if (!startEnabled)
|
|
474
|
+
return;
|
|
475
|
+
return onSessionStopped((stoppedId) => {
|
|
476
|
+
if (stoppedId !== sessionId)
|
|
477
|
+
return;
|
|
478
|
+
stoppedByUserRef.current = sessionId;
|
|
479
|
+
void queryClient.invalidateQueries({ queryKey: sessionStartKey(projectId, sessionId) });
|
|
480
|
+
});
|
|
481
|
+
}, [startEnabled, projectId, sessionId, queryClient]);
|
|
482
|
+
const startData = start.data ?? null;
|
|
483
|
+
const startError = isSessionStartError(start.error) ? start.error : null;
|
|
484
|
+
const stage = startData?.stage ?? null;
|
|
485
|
+
const sandbox = startData?.sandbox ?? null;
|
|
486
|
+
const startReady = stage === 'ready';
|
|
487
|
+
const terminal = stage === 'failed' || stage === 'stopped';
|
|
488
|
+
useIsomorphicLayoutEffect(() => {
|
|
489
|
+
if (!startEnabled)
|
|
490
|
+
return;
|
|
491
|
+
const cached = queryClient.getQueryState(sessionStartKey(projectId, sessionId));
|
|
492
|
+
if (cachedStartResultIsReady(cached))
|
|
493
|
+
markRuntimeReadyVerified();
|
|
494
|
+
}, [projectId, sessionId]);
|
|
495
|
+
useIsomorphicLayoutEffect(() => {
|
|
496
|
+
if (!startEnabled)
|
|
497
|
+
return;
|
|
498
|
+
openSessionBundle(projectId, sessionId);
|
|
499
|
+
seedModelDefaultsFromOpenBundle(queryClient, projectId, sessionId);
|
|
500
|
+
}, [projectId, sessionId]);
|
|
501
|
+
const streamConnected = useSessionStream(projectId, sessionId, {
|
|
502
|
+
enabled: startEnabled,
|
|
503
|
+
tabId: presenceTabId ?? undefined,
|
|
504
|
+
});
|
|
505
|
+
streamConnectedRef.current = streamConnected;
|
|
506
|
+
const startGivenUp = useSessionStartGiveUp({
|
|
507
|
+
identity: `${projectId}\u0000${sessionId}`,
|
|
508
|
+
enabled: startEnabled,
|
|
509
|
+
hasData: !!start.data,
|
|
510
|
+
hasError: !!start.error,
|
|
511
|
+
isFetching: start.isFetching,
|
|
512
|
+
});
|
|
513
|
+
const startSettled = computeStartSettled({
|
|
514
|
+
enabled: startEnabled,
|
|
515
|
+
isFetching: start.isFetching,
|
|
516
|
+
data: start.data,
|
|
517
|
+
error: start.error,
|
|
518
|
+
hasGivenUp: startGivenUp,
|
|
519
|
+
});
|
|
520
|
+
const [switchedBoxId, setSwitchedBoxId] = useState(null);
|
|
521
|
+
useEffect(() => {
|
|
522
|
+
if (!startReady || !sandbox?.external_id || switchedBoxId === sandbox.external_id)
|
|
523
|
+
return;
|
|
524
|
+
setCurrentRuntime(getSandboxUrlForExternalId(sandbox.external_id), sandbox.external_id, sandbox.sandbox_id);
|
|
525
|
+
setSwitchedBoxId(sandbox.external_id);
|
|
526
|
+
}, [startReady, sandbox, switchedBoxId]);
|
|
527
|
+
useEffect(() => () => setCurrentRuntime(null), []);
|
|
528
|
+
const switched = startReady && !!sandbox?.external_id && switchedBoxId === sandbox.external_id;
|
|
529
|
+
useEffect(() => {
|
|
530
|
+
if (!switched || !sandbox?.external_id)
|
|
531
|
+
return;
|
|
532
|
+
seedConnectionFromReadyStart(getSandboxUrlForExternalId(sandbox.external_id), startData?.capabilities);
|
|
533
|
+
}, [switched, switchedBoxId]);
|
|
534
|
+
const refetchStart = start.refetch;
|
|
535
|
+
useEffect(() => {
|
|
536
|
+
if (!startEnabled || !switchedBoxId)
|
|
537
|
+
return;
|
|
538
|
+
const switchedUrl = getSandboxUrlForExternalId(switchedBoxId);
|
|
539
|
+
let lastAt = 0;
|
|
540
|
+
return onRuntimeGone((runtimeUrl) => {
|
|
541
|
+
if (runtimeUrl !== switchedUrl)
|
|
542
|
+
return;
|
|
543
|
+
const now = Date.now();
|
|
544
|
+
if (now - lastAt < RUNTIME_GONE_REFETCH_MIN_MS)
|
|
545
|
+
return;
|
|
546
|
+
lastAt = now;
|
|
547
|
+
void refetchStart();
|
|
548
|
+
});
|
|
549
|
+
}, [startEnabled, switchedBoxId, refetchStart]);
|
|
550
|
+
useRuntimeEventStream({ enabled: switched, projectId, sessionId });
|
|
551
|
+
const transcriptHistoryEnabled = startEnabled && chatEngine;
|
|
552
|
+
const transcriptHistory = useSessionTranscriptHistory(projectId, sessionId, transcriptHistoryEnabled);
|
|
553
|
+
const canonicalSession = useCanonicalRuntimeSession({
|
|
554
|
+
projectId,
|
|
555
|
+
sessionId,
|
|
556
|
+
pinFromStart: startData?.runtime_session_id ?? startData?.opencode_session_id ?? null,
|
|
557
|
+
initialPin: transcriptHistory.rootSessionId ?? initialRuntimeSessionId,
|
|
558
|
+
listRuntimeSessions: switched,
|
|
559
|
+
});
|
|
560
|
+
const { rootSessionId } = canonicalSession;
|
|
561
|
+
const ocSessionId = rootSessionId ?? '';
|
|
562
|
+
useEffect(() => () => {
|
|
563
|
+
titleRefreshAbortRef.current?.abort();
|
|
564
|
+
titleRefreshAbortRef.current = null;
|
|
565
|
+
}, [projectId, sessionId]);
|
|
566
|
+
const working = useSessionWorking(projectId, sessionId, {
|
|
567
|
+
enabled,
|
|
568
|
+
runtimeSessionId: ocSessionId,
|
|
569
|
+
});
|
|
570
|
+
const { noteSendReceipt, acceptSendReceipt, clearSendReceipt } = useSessionWorkingStore.getState();
|
|
571
|
+
const rawSync = useSessionSync(chatEngine ? ocSessionId : '', {
|
|
572
|
+
beeuniSessionScope: `${projectId}/${sessionId}`,
|
|
573
|
+
streamConnected,
|
|
574
|
+
mirror: transcriptHistory.envelope ?? undefined,
|
|
575
|
+
networkEnabled: switched,
|
|
576
|
+
working: working.state === 'working',
|
|
577
|
+
serverHoldsTurn: working.serverOpenTurnToken !== null,
|
|
578
|
+
subscribeMessages,
|
|
579
|
+
});
|
|
580
|
+
useSyncStore((state) => !subscribeMessages && chatEngine && ocSessionId
|
|
581
|
+
? selectTranscriptShapeKey(state, ocSessionId)
|
|
582
|
+
: '');
|
|
583
|
+
const sync = chatEngine ? rawSync : DISABLED_CHAT_ENGINE_SYNC;
|
|
584
|
+
const runtimePhase = useRuntimePhase();
|
|
585
|
+
const restRewind = useSyncStore((s) => s.sessionRevert[ocSessionId] ?? null);
|
|
586
|
+
const [rewindPending, setRewindPending] = useState(false);
|
|
587
|
+
const [rewindError, setRewindError] = useState(null);
|
|
588
|
+
const rewindMessageId = restRewind?.staged ? restRewind.messageId : null;
|
|
589
|
+
const messages = useMemo(() => messagesBeforeRewind(sync.messages, restRewind), [sync.messages, restRewind]);
|
|
590
|
+
const turnOutcome = useSessionTurnOutcome(projectId, sessionId);
|
|
591
|
+
const turnRead = typeof turnOutcome.atMs === 'number';
|
|
592
|
+
const savedEmptyRoot = transcriptHistoryEnabled ? transcriptHistory.emptyRootSessionId : null;
|
|
593
|
+
const emptyProvenForRoot = savedEmptyRoot !== null && savedEmptyRoot === ocSessionId;
|
|
594
|
+
const savedTranscript = resolveSavedTranscript({
|
|
595
|
+
enabled: startEnabled && chatEngine,
|
|
596
|
+
hasMessages: sync.messages.length > 0,
|
|
597
|
+
history: !transcriptHistoryEnabled
|
|
598
|
+
? 'off'
|
|
599
|
+
: transcriptHistory.isLoading
|
|
600
|
+
? 'loading'
|
|
601
|
+
: transcriptHistory.envelope
|
|
602
|
+
? 'present'
|
|
603
|
+
: 'absent',
|
|
604
|
+
mirror: sync.mirrorState,
|
|
605
|
+
root: ocSessionId ? 'known' : canonicalSession.pinSettled ? 'unknown' : 'pending',
|
|
606
|
+
emptyAwaitingTurnRead: emptyProvenForRoot && !turnRead,
|
|
607
|
+
});
|
|
608
|
+
const conversationEmpty = isEmptyConversation({
|
|
609
|
+
savedEmptyRoot,
|
|
610
|
+
rootSessionId: ocSessionId,
|
|
611
|
+
turnRead,
|
|
612
|
+
hasEndedTurn: turnOutcome.last_ended != null,
|
|
613
|
+
hasOpenOrQueuedTurn: working.state === 'working' ||
|
|
614
|
+
working.pendingDelivery === true ||
|
|
615
|
+
working.serverOpenTurnToken !== null,
|
|
616
|
+
});
|
|
617
|
+
useEffect(() => {
|
|
618
|
+
setRewindPending(false);
|
|
619
|
+
setRewindError(null);
|
|
620
|
+
}, [sessionId, ocSessionId]);
|
|
621
|
+
useQuestionSelfHeal(ocSessionId, sync.messages, {
|
|
622
|
+
enabled: switched && chatEngine && !!ocSessionId && !streamConnected,
|
|
623
|
+
});
|
|
624
|
+
usePermissionSelfHeal(ocSessionId, sync.messages, {
|
|
625
|
+
enabled: switched && chatEngine && !!ocSessionId && !streamConnected,
|
|
626
|
+
});
|
|
627
|
+
const questionMap = useRuntimePendingStore((s) => s.questions);
|
|
628
|
+
const permissionMap = useRuntimePendingStore((s) => s.permissions);
|
|
629
|
+
const optimisticCompactionAtMs = useOpenCodeCompactionStore((state) => switched ? (state.compactingBySession[ocSessionId] ?? null) : null);
|
|
630
|
+
const runtimeSessionRow = useRuntimeSession(switched ? ocSessionId : '');
|
|
631
|
+
const compactionInputs = {
|
|
632
|
+
optimisticAtMs: optimisticCompactionAtMs,
|
|
633
|
+
serverCompactingAtMs: runtimeSessionRow.data?.time?.compacting ?? null,
|
|
634
|
+
nowMs: Date.now(),
|
|
635
|
+
};
|
|
636
|
+
const isCompacting = projectCompacting(compactionInputs);
|
|
637
|
+
const [, setCompactionTick] = useState(0);
|
|
638
|
+
const compactionExpiry = compactionExpiryAtMs(compactionInputs);
|
|
639
|
+
useEffect(() => {
|
|
640
|
+
if (compactionExpiry === null)
|
|
641
|
+
return;
|
|
642
|
+
const timer = setTimeout(() => setCompactionTick((tick) => tick + 1), Math.max(0, compactionExpiry - Date.now()) + 1);
|
|
643
|
+
return () => clearTimeout(timer);
|
|
644
|
+
}, [compactionExpiry]);
|
|
645
|
+
const serverCompactionRevalidateAt = serverCompactionRevalidateAtMs(compactionInputs);
|
|
646
|
+
useEffect(() => {
|
|
647
|
+
if (serverCompactionRevalidateAt === null || !switched || !ocSessionId)
|
|
648
|
+
return;
|
|
649
|
+
const timer = setTimeout(() => {
|
|
650
|
+
void queryClient.invalidateQueries({ queryKey: runtimeKeys.runtimeSession(ocSessionId) });
|
|
651
|
+
}, Math.max(0, serverCompactionRevalidateAt - Date.now()));
|
|
652
|
+
return () => clearTimeout(timer);
|
|
653
|
+
}, [serverCompactionRevalidateAt, switched, ocSessionId, queryClient]);
|
|
654
|
+
const removeQuestion = useRuntimePendingStore((s) => s.removeQuestion);
|
|
655
|
+
const removePermission = useRuntimePendingStore((s) => s.removePermission);
|
|
656
|
+
const questions = useMemo(() => (switched ? Object.values(questionMap).filter((q) => q.sessionID === ocSessionId) : []), [questionMap, ocSessionId, switched]);
|
|
657
|
+
const permissions = useMemo(() => (switched ? Object.values(permissionMap).filter((p) => p.sessionID === ocSessionId) : []), [permissionMap, ocSessionId, switched]);
|
|
658
|
+
const runtimeActionReady = switched && !!rootSessionId;
|
|
659
|
+
const models = useProjectModels(projectId);
|
|
660
|
+
const agents = useVisibleAgents({ projectId });
|
|
661
|
+
const config = useProjectConfig(projectId);
|
|
662
|
+
const picks = useSessionPicks(sessionId);
|
|
663
|
+
const sendMutation = useMutation({
|
|
664
|
+
mutationFn: (input) => createSessionPrompt(projectId, sessionId, input),
|
|
665
|
+
retry: false,
|
|
666
|
+
});
|
|
667
|
+
const abortMutation = useAbortRuntimeSession();
|
|
668
|
+
const commandMutation = useExecuteRuntimeCommand();
|
|
669
|
+
const userMsgCount = useMemo(() => messages.filter((m) => m.info.role === 'user').length, [messages]);
|
|
670
|
+
const hasUserMessages = userMsgCount > 0;
|
|
671
|
+
useEffect(() => {
|
|
672
|
+
if (!chatEngine || !hasUserMessages || streamConnected)
|
|
673
|
+
return;
|
|
674
|
+
titleRefreshAbortRef.current?.abort();
|
|
675
|
+
const controller = new AbortController();
|
|
676
|
+
titleRefreshAbortRef.current = controller;
|
|
677
|
+
void reconcileHydratedSessionTitle(queryClient, projectId, sessionId, 1, {
|
|
678
|
+
signal: controller.signal,
|
|
679
|
+
}).finally(() => {
|
|
680
|
+
if (titleRefreshAbortRef.current === controller) {
|
|
681
|
+
titleRefreshAbortRef.current = null;
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
return () => controller.abort();
|
|
685
|
+
}, [chatEngine, projectId, queryClient, sessionId, hasUserMessages, streamConnected]);
|
|
686
|
+
const [sendState, setSendState] = useState(IDLE_SEND_STATE);
|
|
687
|
+
const pending = sendState.pending;
|
|
688
|
+
const pendingBaseCount = useRef(0);
|
|
689
|
+
useEffect(() => {
|
|
690
|
+
if (pending && userMsgCount > pendingBaseCount.current) {
|
|
691
|
+
setSendState((s) => (s.pending ? { ...s, pending: null } : s));
|
|
692
|
+
}
|
|
693
|
+
}, [userMsgCount, pending]);
|
|
694
|
+
const sendParts = async (parts, override) => {
|
|
695
|
+
if (!runtimeActionReady)
|
|
696
|
+
throw new RuntimeNotReadyError();
|
|
697
|
+
const opts = resolveSendOptions(picks, override);
|
|
698
|
+
markDispatchedForPartIds(ocSessionId, parts);
|
|
699
|
+
const receipt = {
|
|
700
|
+
messageId: sendReceiptId(ocSessionId, parts, override?.clientMessageId),
|
|
701
|
+
atMs: Date.now(),
|
|
702
|
+
};
|
|
703
|
+
noteSendReceipt(sessionId, receipt);
|
|
704
|
+
try {
|
|
705
|
+
const result = await sendMutation.mutateAsync(sessionPromptFromParts(ocSessionId, parts, opts, override?.clientMessageId));
|
|
706
|
+
if (result.state === 'failed') {
|
|
707
|
+
throw new Error('This prompt was refused: its earlier delivery already failed.');
|
|
708
|
+
}
|
|
709
|
+
acceptSendReceipt(sessionId, receipt.messageId, Date.now());
|
|
710
|
+
}
|
|
711
|
+
catch (error) {
|
|
712
|
+
clearSendReceipt(sessionId, receipt.messageId);
|
|
713
|
+
throw error;
|
|
714
|
+
}
|
|
715
|
+
useSyncStore.getState().commitSessionRevert(ocSessionId);
|
|
716
|
+
};
|
|
717
|
+
const send = (text, override) => {
|
|
718
|
+
if (!runtimeActionReady)
|
|
719
|
+
return;
|
|
720
|
+
pendingBaseCount.current = userMsgCount;
|
|
721
|
+
setSendState(sendStateOnStart(text));
|
|
722
|
+
const { messageId, parts } = beginOptimisticPlainTextSend(ocSessionId, text);
|
|
723
|
+
void sendParts(parts, override).catch((error) => {
|
|
724
|
+
useSyncStore.getState().optimisticRemove(ocSessionId, messageId);
|
|
725
|
+
setSendState(sendStateOnError(error));
|
|
726
|
+
});
|
|
727
|
+
};
|
|
728
|
+
const runCommand = (command, args, options = {}) => {
|
|
729
|
+
if (!runtimeActionReady)
|
|
730
|
+
return Promise.resolve();
|
|
731
|
+
return commandMutation.mutateAsync(buildSessionCommandInput(ocSessionId, command, args, options));
|
|
732
|
+
};
|
|
733
|
+
const rewind = async (messageId) => {
|
|
734
|
+
if (!runtimeActionReady)
|
|
735
|
+
throw new RuntimeNotReadyError();
|
|
736
|
+
if (!messageId)
|
|
737
|
+
throw new Error('Session rewind requires a message id');
|
|
738
|
+
if (working.state === 'working' || rewindPending) {
|
|
739
|
+
throw new Error('Cannot rewind a busy session');
|
|
740
|
+
}
|
|
741
|
+
setRewindPending(true);
|
|
742
|
+
setRewindError(null);
|
|
743
|
+
try {
|
|
744
|
+
await rewindOpenCodeSession(ocSessionId, messageId);
|
|
745
|
+
useSyncStore.getState().stageSessionRevert(ocSessionId, messageId);
|
|
746
|
+
}
|
|
747
|
+
catch (error) {
|
|
748
|
+
const classified = classifySendError(error);
|
|
749
|
+
setRewindError(classified);
|
|
750
|
+
throw classified;
|
|
751
|
+
}
|
|
752
|
+
finally {
|
|
753
|
+
setRewindPending(false);
|
|
754
|
+
}
|
|
755
|
+
};
|
|
756
|
+
const restoreRewind = async () => {
|
|
757
|
+
if (!runtimeActionReady)
|
|
758
|
+
throw new RuntimeNotReadyError();
|
|
759
|
+
if (!rewindMessageId || rewindPending)
|
|
760
|
+
return;
|
|
761
|
+
setRewindPending(true);
|
|
762
|
+
setRewindError(null);
|
|
763
|
+
try {
|
|
764
|
+
await restoreOpenCodeSessionRewind(ocSessionId);
|
|
765
|
+
useSyncStore.getState().clearSessionRevert(ocSessionId);
|
|
766
|
+
}
|
|
767
|
+
catch (error) {
|
|
768
|
+
const classified = classifySendError(error);
|
|
769
|
+
setRewindError(classified);
|
|
770
|
+
throw classified;
|
|
771
|
+
}
|
|
772
|
+
finally {
|
|
773
|
+
setRewindPending(false);
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
const cancel = () => {
|
|
777
|
+
const settlement = cancelSessionTurn({
|
|
778
|
+
projectId,
|
|
779
|
+
sessionId,
|
|
780
|
+
runtimeSessionId: ocSessionId,
|
|
781
|
+
runtimeActionReady,
|
|
782
|
+
runAbort: () => abortMutation.mutateAsync(ocSessionId),
|
|
783
|
+
});
|
|
784
|
+
questions.forEach((q) => removeQuestion(q.id));
|
|
785
|
+
permissions.forEach((p) => removePermission(p.id));
|
|
786
|
+
setSendState(IDLE_SEND_STATE);
|
|
787
|
+
return settlement;
|
|
788
|
+
};
|
|
789
|
+
const runtimeSessionError = canonicalSession.error;
|
|
790
|
+
const phase = derivePhase({
|
|
791
|
+
terminal,
|
|
792
|
+
startError,
|
|
793
|
+
runtimeError: runtimeSessionError,
|
|
794
|
+
startSettled,
|
|
795
|
+
switched,
|
|
796
|
+
});
|
|
797
|
+
const startedRef = useRef(false);
|
|
798
|
+
useEffect(() => {
|
|
799
|
+
if (!replayStartStash || !chatEngine)
|
|
800
|
+
return;
|
|
801
|
+
if (startedRef.current || phase !== 'ready' || sync.isLoading)
|
|
802
|
+
return;
|
|
803
|
+
const stash = readStartStash(sessionId);
|
|
804
|
+
if (!stash)
|
|
805
|
+
return;
|
|
806
|
+
startedRef.current = true;
|
|
807
|
+
clearStartStash(sessionId);
|
|
808
|
+
if (sync.messages.length > 0)
|
|
809
|
+
return;
|
|
810
|
+
if (stash.model)
|
|
811
|
+
picks.setModel(stash.model);
|
|
812
|
+
if (stash.agent)
|
|
813
|
+
picks.setAgent(stash.agent);
|
|
814
|
+
if (!stash.prompt.trim())
|
|
815
|
+
return;
|
|
816
|
+
send(stash.prompt, {
|
|
817
|
+
model: stash.model,
|
|
818
|
+
agent: stash.agent,
|
|
819
|
+
variant: stash.variant,
|
|
820
|
+
});
|
|
821
|
+
}, [phase, sync.isLoading, sync.messages.length, sessionId, replayStartStash, chatEngine]);
|
|
822
|
+
return {
|
|
823
|
+
projectId,
|
|
824
|
+
sessionId,
|
|
825
|
+
runtimeSessionId: rootSessionId ?? null,
|
|
826
|
+
opencodeSessionId: rootSessionId ?? null,
|
|
827
|
+
runtimeTransport: 'rest',
|
|
828
|
+
runtimeSessions: canonicalSession.sessions,
|
|
829
|
+
runtimeSessionsLoading: canonicalSession.isLoading,
|
|
830
|
+
runtimeSessionsListed: canonicalSession.listed,
|
|
831
|
+
runtimeError: runtimeSessionError,
|
|
832
|
+
messages,
|
|
833
|
+
status: sync.status,
|
|
834
|
+
freshness: sync.freshness,
|
|
835
|
+
retryTranscript: sync.retryTranscript,
|
|
836
|
+
questions,
|
|
837
|
+
permissions,
|
|
838
|
+
diffs: sync.diffs,
|
|
839
|
+
todos: sync.todos,
|
|
840
|
+
hasOlder: sync.hasOlder,
|
|
841
|
+
isLoadingOlder: sync.isLoadingOlder,
|
|
842
|
+
loadOlder: sync.loadOlder,
|
|
843
|
+
phase,
|
|
844
|
+
stage,
|
|
845
|
+
agentName: startData?.agent_name && startData.agent_name !== 'default'
|
|
846
|
+
? startData.agent_name
|
|
847
|
+
: null,
|
|
848
|
+
sandbox,
|
|
849
|
+
runtimeUrl: resolveSessionRuntimeUrl(startData),
|
|
850
|
+
switched,
|
|
851
|
+
retriable: startData?.retriable ?? false,
|
|
852
|
+
activelyStarting: startData?.boot?.actively_starting ?? false,
|
|
853
|
+
startError,
|
|
854
|
+
failure: startData?.failure ?? null,
|
|
855
|
+
runtimePhase,
|
|
856
|
+
working,
|
|
857
|
+
isBusy: working.state === 'working',
|
|
858
|
+
isCompacting,
|
|
859
|
+
isLoading: sync.isLoading,
|
|
860
|
+
savedTranscript,
|
|
861
|
+
conversationEmpty,
|
|
862
|
+
isError: terminal || !!startError || !!runtimeSessionError,
|
|
863
|
+
hasPending: questions.length > 0 || permissions.length > 0,
|
|
864
|
+
reason: startData?.reason ?? null,
|
|
865
|
+
pending,
|
|
866
|
+
isSending: sendMutation.isPending,
|
|
867
|
+
sendError: sendState.sendError,
|
|
868
|
+
rewindMessageId,
|
|
869
|
+
rewindPending,
|
|
870
|
+
rewindError,
|
|
871
|
+
models,
|
|
872
|
+
agents,
|
|
873
|
+
defaultAgent: config?.default_agent ?? config?.open_code_default_agent ?? null,
|
|
874
|
+
commands: config?.commands ?? [],
|
|
875
|
+
picks,
|
|
876
|
+
send,
|
|
877
|
+
sendParts,
|
|
878
|
+
rewind,
|
|
879
|
+
restoreRewind,
|
|
880
|
+
cancel,
|
|
881
|
+
runCommand,
|
|
882
|
+
answerQuestion,
|
|
883
|
+
rejectQuestion,
|
|
884
|
+
answerPermission,
|
|
885
|
+
removeQuestion,
|
|
886
|
+
removePermission,
|
|
887
|
+
retry: () => {
|
|
888
|
+
stoppedByUserRef.current = null;
|
|
889
|
+
openedAtRef.current = { sessionId, at: Date.now() };
|
|
890
|
+
void start.refetch();
|
|
891
|
+
},
|
|
892
|
+
};
|
|
893
|
+
}
|