@kortix/sdk 0.13.46 → 0.13.48
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 +67 -44
- package/dist/browser/session-sync/server-transcript-mirror.d.ts +1 -1
- package/dist/browser/session-sync/server-transcript-mirror.d.ts.map +1 -1
- package/dist/browser/session-sync/session-sync-registry.d.ts +1 -1
- package/dist/browser/session-sync/session-sync-registry.d.ts.map +1 -1
- package/dist/browser/session-sync/visibility.d.ts +0 -12
- package/dist/browser/session-sync/visibility.d.ts.map +1 -1
- package/dist/browser/session-sync/visibility.js +23 -2
- package/dist/browser/session-sync/visibility.js.map +1 -1
- package/dist/browser/stores/opencode-pending-store.d.ts +1 -1
- package/dist/browser/stores/opencode-pending-store.d.ts.map +1 -1
- package/dist/browser/stores/sandbox-connection-store.d.ts +8 -0
- package/dist/browser/stores/sandbox-connection-store.d.ts.map +1 -1
- package/dist/browser/stores/sandbox-connection-store.js +14 -0
- package/dist/browser/stores/sandbox-connection-store.js.map +1 -1
- package/dist/browser/stores/sync-store/reconcile-parts.d.ts +1 -1
- package/dist/browser/stores/sync-store/reconcile-parts.d.ts.map +1 -1
- package/dist/browser/stores/sync-store/types.d.ts +1 -1
- package/dist/browser/stores/sync-store/types.d.ts.map +1 -1
- package/dist/browser/stores/sync-store.d.ts +1 -1
- package/dist/browser/stores/sync-store.d.ts.map +1 -1
- package/dist/browser/stores/sync-store.js +79 -60
- package/dist/browser/stores/sync-store.js.map +1 -1
- package/dist/core/agents/composer-agents.d.ts +8 -6
- package/dist/core/agents/composer-agents.d.ts.map +1 -1
- package/dist/core/agents/composer-agents.js +3 -3
- package/dist/core/agents/composer-agents.js.map +1 -1
- package/dist/core/client/binding-types.d.ts +2 -0
- package/dist/core/client/binding-types.d.ts.map +1 -0
- package/dist/core/client/binding-types.js +2 -0
- package/dist/core/client/binding-types.js.map +1 -0
- package/dist/core/client/facade-accounts.d.ts +57 -0
- package/dist/core/client/facade-accounts.d.ts.map +1 -0
- package/dist/core/client/facade-accounts.js +59 -0
- package/dist/core/client/facade-accounts.js.map +1 -0
- package/dist/core/client/facade-catalog.d.ts +58 -0
- package/dist/core/client/facade-catalog.d.ts.map +1 -0
- package/dist/core/client/facade-catalog.js +70 -0
- package/dist/core/client/facade-catalog.js.map +1 -0
- package/dist/core/client/facade-commerce.d.ts +45 -0
- package/dist/core/client/facade-commerce.d.ts.map +1 -0
- package/dist/core/client/facade-commerce.js +53 -0
- package/dist/core/client/facade-commerce.js.map +1 -0
- package/dist/core/client/facade-iam.d.ts +54 -0
- package/dist/core/client/facade-iam.d.ts.map +1 -0
- package/dist/core/client/facade-iam.js +62 -0
- package/dist/core/client/facade-iam.js.map +1 -0
- package/dist/core/client/facade-identity.d.ts +104 -0
- package/dist/core/client/facade-identity.d.ts.map +1 -0
- package/dist/core/client/facade-identity.js +36 -0
- package/dist/core/client/facade-identity.js.map +1 -0
- package/dist/core/client/facade-preview.d.ts +4 -0
- package/dist/core/client/facade-preview.d.ts.map +1 -0
- package/dist/core/client/facade-preview.js +61 -0
- package/dist/core/client/facade-preview.js.map +1 -0
- package/dist/core/client/kortix.d.ts +662 -985
- package/dist/core/client/kortix.d.ts.map +1 -1
- package/dist/core/client/kortix.js +31 -1162
- package/dist/core/client/kortix.js.map +1 -1
- package/dist/core/client/project-access-resources.d.ts +38 -0
- package/dist/core/client/project-access-resources.d.ts.map +1 -0
- package/dist/core/client/project-access-resources.js +37 -0
- package/dist/core/client/project-access-resources.js.map +1 -0
- package/dist/core/client/project-access-security.d.ts +117 -0
- package/dist/core/client/project-access-security.d.ts.map +1 -0
- package/dist/core/client/project-access-security.js +41 -0
- package/dist/core/client/project-access-security.js.map +1 -0
- package/dist/core/client/project-connections.d.ts +34 -0
- package/dist/core/client/project-connections.d.ts.map +1 -0
- package/dist/core/client/project-connections.js +20 -0
- package/dist/core/client/project-connections.js.map +1 -0
- package/dist/core/client/project-connectors.d.ts +21 -0
- package/dist/core/client/project-connectors.d.ts.map +1 -0
- package/dist/core/client/project-connectors.js +20 -0
- package/dist/core/client/project-connectors.js.map +1 -0
- package/dist/core/client/project-core.d.ts +72 -0
- package/dist/core/client/project-core.d.ts.map +1 -0
- package/dist/core/client/project-core.js +24 -0
- package/dist/core/client/project-core.js.map +1 -0
- package/dist/core/client/project-membership.d.ts +64 -0
- package/dist/core/client/project-membership.d.ts.map +1 -0
- package/dist/core/client/project-membership.js +26 -0
- package/dist/core/client/project-membership.js.map +1 -0
- package/dist/core/client/project-operations-admin.d.ts +112 -0
- package/dist/core/client/project-operations-admin.d.ts.map +1 -0
- package/dist/core/client/project-operations-admin.js +24 -0
- package/dist/core/client/project-operations-admin.js.map +1 -0
- package/dist/core/client/project-operations-review.d.ts +44 -0
- package/dist/core/client/project-operations-review.d.ts.map +1 -0
- package/dist/core/client/project-operations-review.js +34 -0
- package/dist/core/client/project-operations-review.js.map +1 -0
- package/dist/core/client/project-operations-workspace.d.ts +91 -0
- package/dist/core/client/project-operations-workspace.d.ts.map +1 -0
- package/dist/core/client/project-operations-workspace.js +36 -0
- package/dist/core/client/project-operations-workspace.js.map +1 -0
- package/dist/core/client/project-operations.d.ts +225 -0
- package/dist/core/client/project-operations.d.ts.map +1 -0
- package/dist/core/client/project-operations.js +47 -0
- package/dist/core/client/project-operations.js.map +1 -0
- package/dist/core/client/project-platform-resources.d.ts +36 -0
- package/dist/core/client/project-platform-resources.d.ts.map +1 -0
- package/dist/core/client/project-platform-resources.js +29 -0
- package/dist/core/client/project-platform-resources.js.map +1 -0
- package/dist/core/client/project-platform-security.d.ts +83 -0
- package/dist/core/client/project-platform-security.d.ts.map +1 -0
- package/dist/core/client/project-platform-security.js +39 -0
- package/dist/core/client/project-platform-security.js.map +1 -0
- package/dist/core/client/project-platform-settings.d.ts +58 -0
- package/dist/core/client/project-platform-settings.d.ts.map +1 -0
- package/dist/core/client/project-platform-settings.js +28 -0
- package/dist/core/client/project-platform-settings.js.map +1 -0
- package/dist/core/client/session-actions-resources.d.ts +18 -0
- package/dist/core/client/session-actions-resources.d.ts.map +1 -0
- package/dist/core/client/session-actions-resources.js +31 -0
- package/dist/core/client/session-actions-resources.js.map +1 -0
- package/dist/core/client/session-actions-security.d.ts +31 -0
- package/dist/core/client/session-actions-security.d.ts.map +1 -0
- package/dist/core/client/session-actions-security.js +51 -0
- package/dist/core/client/session-actions-security.js.map +1 -0
- package/dist/core/client/session-actions-services.d.ts +64 -0
- package/dist/core/client/session-actions-services.d.ts.map +1 -0
- package/dist/core/client/session-actions-services.js +59 -0
- package/dist/core/client/session-actions-services.js.map +1 -0
- package/dist/core/client/session-context.d.ts +22 -0
- package/dist/core/client/session-context.d.ts.map +1 -0
- package/dist/core/client/session-context.js +2 -0
- package/dist/core/client/session-context.js.map +1 -0
- package/dist/core/client/session-defaults.d.ts +9 -0
- package/dist/core/client/session-defaults.d.ts.map +1 -0
- package/dist/core/client/session-defaults.js +45 -0
- package/dist/core/client/session-defaults.js.map +1 -0
- package/dist/core/client/session-files.d.ts +26 -0
- package/dist/core/client/session-files.d.ts.map +1 -0
- package/dist/core/client/session-files.js +24 -0
- package/dist/core/client/session-files.js.map +1 -0
- package/dist/core/client/session-handle.d.ts +186 -0
- package/dist/core/client/session-handle.d.ts.map +1 -0
- package/dist/core/client/session-handle.js +68 -0
- package/dist/core/client/session-handle.js.map +1 -0
- package/dist/core/client/session-lifecycle-resources.d.ts +67 -0
- package/dist/core/client/session-lifecycle-resources.d.ts.map +1 -0
- package/dist/core/client/session-lifecycle-resources.js +56 -0
- package/dist/core/client/session-lifecycle-resources.js.map +1 -0
- package/dist/core/client/session-lifecycle-security.d.ts +65 -0
- package/dist/core/client/session-lifecycle-security.d.ts.map +1 -0
- package/dist/core/client/session-lifecycle-security.js +54 -0
- package/dist/core/client/session-lifecycle-security.js.map +1 -0
- package/dist/core/client/session-preview.d.ts +26 -0
- package/dist/core/client/session-preview.d.ts.map +1 -0
- package/dist/core/client/session-preview.js +31 -0
- package/dist/core/client/session-preview.js.map +1 -0
- package/dist/core/client/session-readiness.d.ts +11 -0
- package/dist/core/client/session-readiness.d.ts.map +1 -0
- package/dist/core/client/session-readiness.js +77 -0
- package/dist/core/client/session-readiness.js.map +1 -0
- package/dist/core/client/session-runtime.d.ts +35 -0
- package/dist/core/client/session-runtime.d.ts.map +1 -0
- package/dist/core/client/session-runtime.js +30 -0
- package/dist/core/client/session-runtime.js.map +1 -0
- package/dist/core/client/session-shared.d.ts +46 -0
- package/dist/core/client/session-shared.d.ts.map +1 -0
- package/dist/core/client/session-shared.js +48 -0
- package/dist/core/client/session-shared.js.map +1 -0
- package/dist/core/client/session-start.d.ts +3 -0
- package/dist/core/client/session-start.d.ts.map +1 -0
- package/dist/core/client/session-start.js +60 -0
- package/dist/core/client/session-start.js.map +1 -0
- package/dist/core/files/client.d.ts.map +1 -1
- package/dist/core/files/client.js +29 -3
- package/dist/core/files/client.js.map +1 -1
- package/dist/core/http/api-client.d.ts.map +1 -1
- package/dist/core/http/api-client.js +2 -419
- package/dist/core/http/api-client.js.map +1 -1
- package/dist/core/http/config.d.ts +15 -0
- package/dist/core/http/config.d.ts.map +1 -1
- package/dist/core/http/config.js.map +1 -1
- package/dist/core/http/request.d.ts +3 -0
- package/dist/core/http/request.d.ts.map +1 -0
- package/dist/core/http/request.js +215 -0
- package/dist/core/http/request.js.map +1 -0
- package/dist/core/http/response-error.d.ts +3 -0
- package/dist/core/http/response-error.d.ts.map +1 -0
- package/dist/core/http/response-error.js +113 -0
- package/dist/core/http/response-error.js.map +1 -0
- package/dist/core/http/runtime-errors.d.ts +23 -0
- package/dist/core/http/runtime-errors.d.ts.map +1 -1
- package/dist/core/http/runtime-errors.js +39 -1
- package/dist/core/http/runtime-errors.js.map +1 -1
- package/dist/core/http/transport.d.ts +13 -1
- package/dist/core/http/transport.d.ts.map +1 -1
- package/dist/core/http/transport.js +25 -4
- package/dist/core/http/transport.js.map +1 -1
- package/dist/core/models/composer-model.d.ts +1 -1
- package/dist/core/models/composer-model.d.ts.map +1 -1
- package/dist/core/models/model-flatten.d.ts +8 -1
- package/dist/core/models/model-flatten.d.ts.map +1 -1
- package/dist/core/models/model-flatten.js +2 -0
- package/dist/core/models/model-flatten.js.map +1 -1
- package/dist/core/models/model-key.d.ts +11 -0
- package/dist/core/models/model-key.d.ts.map +1 -1
- package/dist/core/models/model-key.js +20 -0
- package/dist/core/models/model-key.js.map +1 -1
- package/dist/core/models/provider-selection.d.ts +1 -1
- package/dist/core/models/provider-selection.d.ts.map +1 -1
- package/dist/core/rest/platform-client/host-boundary.d.ts +14 -19
- package/dist/core/rest/platform-client/host-boundary.d.ts.map +1 -1
- package/dist/core/rest/platform-client/host-boundary.js +7 -38
- package/dist/core/rest/platform-client/host-boundary.js.map +1 -1
- package/dist/core/rest/projects-client/admin-providers.d.ts +64 -3
- package/dist/core/rest/projects-client/admin-providers.d.ts.map +1 -1
- package/dist/core/rest/projects-client/admin-providers.js.map +1 -1
- package/dist/core/rest/projects-client/agent-config.d.ts +8 -0
- package/dist/core/rest/projects-client/agent-config.d.ts.map +1 -1
- package/dist/core/rest/projects-client/agent-config.js.map +1 -1
- package/dist/core/rest/projects-client/apps.d.ts +30 -0
- package/dist/core/rest/projects-client/apps.d.ts.map +1 -1
- package/dist/core/rest/projects-client/apps.js +10 -0
- package/dist/core/rest/projects-client/apps.js.map +1 -1
- package/dist/core/rest/projects-client/audit-filter.d.ts +6 -0
- package/dist/core/rest/projects-client/audit-filter.d.ts.map +1 -0
- package/dist/core/rest/projects-client/audit-filter.js +11 -0
- package/dist/core/rest/projects-client/audit-filter.js.map +1 -0
- package/dist/core/rest/projects-client/audit.d.ts +6 -18
- package/dist/core/rest/projects-client/audit.d.ts.map +1 -1
- package/dist/core/rest/projects-client/audit.js +30 -108
- package/dist/core/rest/projects-client/audit.js.map +1 -1
- package/dist/core/rest/projects-client/channels.d.ts +19 -0
- package/dist/core/rest/projects-client/channels.d.ts.map +1 -1
- package/dist/core/rest/projects-client/channels.js.map +1 -1
- package/dist/core/rest/projects-client/connectors.d.ts +4 -3
- package/dist/core/rest/projects-client/connectors.d.ts.map +1 -1
- package/dist/core/rest/projects-client/connectors.js.map +1 -1
- package/dist/core/rest/projects-client/iam-roles.d.ts +5 -0
- package/dist/core/rest/projects-client/iam-roles.d.ts.map +1 -1
- package/dist/core/rest/projects-client/iam-roles.js +9 -0
- package/dist/core/rest/projects-client/iam-roles.js.map +1 -1
- package/dist/core/rest/projects-client/projects.d.ts +11 -6
- package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
- package/dist/core/rest/projects-client/projects.js +0 -2
- package/dist/core/rest/projects-client/projects.js.map +1 -1
- package/dist/core/rest/projects-client/secrets.d.ts +61 -8
- package/dist/core/rest/projects-client/secrets.d.ts.map +1 -1
- package/dist/core/rest/projects-client/secrets.js +52 -0
- package/dist/core/rest/projects-client/secrets.js.map +1 -1
- package/dist/core/rest/projects-client/session-sandbox.d.ts +6 -0
- package/dist/core/rest/projects-client/session-sandbox.d.ts.map +1 -1
- package/dist/core/rest/projects-client/session-sandbox.js.map +1 -1
- package/dist/core/rest/projects-client/sessions.d.ts +49 -24
- package/dist/core/rest/projects-client/sessions.d.ts.map +1 -1
- package/dist/core/rest/projects-client/sessions.js +33 -4
- package/dist/core/rest/projects-client/sessions.js.map +1 -1
- package/dist/core/rest/projects-client/triggers.d.ts +12 -0
- package/dist/core/rest/projects-client/triggers.d.ts.map +1 -1
- package/dist/core/rest/projects-client/triggers.js.map +1 -1
- package/dist/core/runtime/client.d.ts +12 -11
- package/dist/core/runtime/client.d.ts.map +1 -1
- package/dist/core/runtime/client.js +36 -5
- package/dist/core/runtime/client.js.map +1 -1
- package/dist/core/runtime/runtime-rest-client.d.ts +462 -0
- package/dist/core/runtime/runtime-rest-client.d.ts.map +1 -0
- package/dist/core/runtime/runtime-rest-client.js +309 -0
- package/dist/core/runtime/runtime-rest-client.js.map +1 -0
- package/dist/core/runtime/runtime-types.d.ts +1174 -0
- package/dist/core/runtime/runtime-types.d.ts.map +1 -0
- package/dist/core/runtime/runtime-types.js +2 -0
- package/dist/core/runtime/runtime-types.js.map +1 -0
- package/dist/core/runtime/transcript-types.d.ts +564 -0
- package/dist/core/runtime/transcript-types.d.ts.map +1 -0
- package/dist/core/runtime/transcript-types.js +57 -0
- package/dist/core/runtime/transcript-types.js.map +1 -0
- package/dist/core/session/health.d.ts +2 -1
- package/dist/core/session/health.d.ts.map +1 -1
- package/dist/core/session/health.js.map +1 -1
- package/dist/core/session/host-signals.d.ts +16 -0
- package/dist/core/session/host-signals.d.ts.map +1 -0
- package/dist/core/session/host-signals.js +20 -0
- package/dist/core/session/host-signals.js.map +1 -0
- package/dist/core/session/index.d.ts +3 -0
- package/dist/core/session/index.d.ts.map +1 -1
- package/dist/core/session/index.js +2 -0
- package/dist/core/session/index.js.map +1 -1
- package/dist/core/session/open-bundle.d.ts +16 -0
- package/dist/core/session/open-bundle.d.ts.map +1 -1
- package/dist/core/session/open-bundle.js +31 -0
- package/dist/core/session/open-bundle.js.map +1 -1
- package/dist/core/session/runtime-sessions.d.ts +26 -0
- package/dist/core/session/runtime-sessions.d.ts.map +1 -0
- package/dist/core/session/runtime-sessions.js +39 -0
- package/dist/core/session/runtime-sessions.js.map +1 -0
- package/dist/core/session/runtime-verbs.d.ts +55 -0
- package/dist/core/session/runtime-verbs.d.ts.map +1 -0
- package/dist/core/session/runtime-verbs.js +124 -0
- package/dist/core/session/runtime-verbs.js.map +1 -0
- package/dist/core/session/wake-escalation.d.ts +1 -1
- package/dist/core/session/wake-escalation.js +1 -1
- package/dist/core/session/wire-message-id.d.ts +55 -12
- package/dist/core/session/wire-message-id.d.ts.map +1 -1
- package/dist/core/session/wire-message-id.js +62 -12
- package/dist/core/session/wire-message-id.js.map +1 -1
- package/dist/core/session/working-evidence.d.ts +15 -0
- package/dist/core/session/working-evidence.d.ts.map +1 -0
- package/dist/core/session/working-evidence.js +27 -0
- package/dist/core/session/working-evidence.js.map +1 -0
- package/dist/core/session/working-project.d.ts +3 -0
- package/dist/core/session/working-project.d.ts.map +1 -0
- package/dist/core/session/working-project.js +187 -0
- package/dist/core/session/working-project.js.map +1 -0
- package/dist/core/session/working-runtime.d.ts +33 -0
- package/dist/core/session/working-runtime.d.ts.map +1 -0
- package/dist/core/session/working-runtime.js +46 -0
- package/dist/core/session/working-runtime.js.map +1 -0
- package/dist/core/session/working-time.d.ts +2 -0
- package/dist/core/session/working-time.d.ts.map +1 -0
- package/dist/core/session/working-time.js +7 -0
- package/dist/core/session/working-time.js.map +1 -0
- package/dist/core/session/working.d.ts.map +1 -1
- package/dist/core/session/working.js +2 -316
- package/dist/core/session/working.js.map +1 -1
- package/dist/core/session-sync/session-sync-controller.d.ts +1 -1
- package/dist/core/session-sync/session-sync-controller.d.ts.map +1 -1
- package/dist/core/stream/event-stream.d.ts +25 -6
- package/dist/core/stream/event-stream.d.ts.map +1 -1
- package/dist/core/stream/event-stream.js +63 -9
- package/dist/core/stream/event-stream.js.map +1 -1
- package/dist/core/turns/classify.d.ts +31 -2
- package/dist/core/turns/classify.d.ts.map +1 -1
- package/dist/core/turns/classify.js +94 -0
- package/dist/core/turns/classify.js.map +1 -1
- package/dist/core/turns/index.d.ts +1 -0
- package/dist/core/turns/index.d.ts.map +1 -1
- package/dist/core/turns/index.js +1 -0
- package/dist/core/turns/index.js.map +1 -1
- package/dist/core/turns/parts.d.ts +6 -1
- package/dist/core/turns/parts.d.ts.map +1 -1
- package/dist/core/turns/parts.js +57 -49
- package/dist/core/turns/parts.js.map +1 -1
- package/dist/core/turns/segments/narration.d.ts.map +1 -1
- package/dist/core/turns/segments/narration.js +40 -130
- package/dist/core/turns/segments/narration.js.map +1 -1
- package/dist/core/turns/segments/turn-busy-visibility.d.ts +1 -1
- package/dist/core/turns/segments/turn-busy-visibility.js +1 -1
- package/dist/core/turns/segments/working-turn.js +1 -1
- package/dist/core/turns/segments/working-turn.js.map +1 -1
- package/dist/core/turns/tool-kind.d.ts +15 -0
- package/dist/core/turns/tool-kind.d.ts.map +1 -0
- package/dist/core/turns/tool-kind.js +115 -0
- package/dist/core/turns/tool-kind.js.map +1 -0
- package/dist/core/turns/tool-registry.d.ts +6 -7
- package/dist/core/turns/tool-registry.d.ts.map +1 -1
- package/dist/core/turns/tool-registry.js +78 -73
- package/dist/core/turns/tool-registry.js.map +1 -1
- package/dist/core/turns/tools/tool-meta.d.ts +1 -0
- package/dist/core/turns/tools/tool-meta.d.ts.map +1 -1
- package/dist/core/turns/tools/tool-meta.js +7 -6
- package/dist/core/turns/tools/tool-meta.js.map +1 -1
- package/dist/core/turns/view-model.d.ts.map +1 -1
- package/dist/core/turns/view-model.js +19 -12
- package/dist/core/turns/view-model.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/kortix.esm.min.js +46 -45
- package/dist/kortix.global.js +46 -45
- package/dist/node/app-viewer.js +1 -1
- package/dist/node/app-viewer.js.map +1 -1
- package/dist/node/auth.js +1 -1
- package/dist/node/auth.js.map +1 -1
- package/dist/node/scoped-client.d.ts +20 -0
- package/dist/node/scoped-client.d.ts.map +1 -0
- package/dist/node/scoped-client.js +170 -0
- package/dist/node/scoped-client.js.map +1 -0
- package/dist/node/server.d.ts +2 -21
- package/dist/node/server.d.ts.map +1 -1
- package/dist/node/server.js +2 -170
- package/dist/node/server.js.map +1 -1
- package/dist/react/index.d.ts +4 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +3 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/prefetch-session-open.d.ts +13 -0
- package/dist/react/prefetch-session-open.d.ts.map +1 -1
- package/dist/react/prefetch-session-open.js +22 -1
- package/dist/react/prefetch-session-open.js.map +1 -1
- package/dist/react/query-keys.d.ts +3 -2
- package/dist/react/query-keys.d.ts.map +1 -1
- package/dist/react/query-keys.js +4 -4
- package/dist/react/query-keys.js.map +1 -1
- package/dist/react/sign-in-with-kortix.d.ts +8 -8
- package/dist/react/use-admin-providers.d.ts +18 -0
- package/dist/react/use-admin-providers.d.ts.map +1 -0
- package/dist/react/use-admin-providers.js +36 -0
- package/dist/react/use-admin-providers.js.map +1 -0
- package/dist/react/use-feature-flag.d.ts +2 -2
- package/dist/react/use-feature-flag.d.ts.map +1 -1
- package/dist/react/use-feature-flag.js +3 -2
- package/dist/react/use-feature-flag.js.map +1 -1
- package/dist/react/use-kortix-master.d.ts +1 -1
- package/dist/react/use-opencode-config.d.ts +7 -1
- package/dist/react/use-opencode-config.d.ts.map +1 -1
- package/dist/react/use-opencode-config.js +9 -1
- package/dist/react/use-opencode-config.js.map +1 -1
- package/dist/react/use-opencode-events/diagnostics.d.ts +1 -1
- package/dist/react/use-opencode-events/diagnostics.d.ts.map +1 -1
- package/dist/react/use-opencode-events/handle-event.d.ts +4 -6
- package/dist/react/use-opencode-events/handle-event.d.ts.map +1 -1
- package/dist/react/use-opencode-events/handle-event.js +43 -594
- package/dist/react/use-opencode-events/handle-event.js.map +1 -1
- package/dist/react/use-opencode-events/handle-interaction-event.d.ts +4 -0
- package/dist/react/use-opencode-events/handle-interaction-event.d.ts.map +1 -0
- package/dist/react/use-opencode-events/handle-interaction-event.js +42 -0
- package/dist/react/use-opencode-events/handle-interaction-event.js.map +1 -0
- package/dist/react/use-opencode-events/handle-message-event.d.ts +4 -0
- package/dist/react/use-opencode-events/handle-message-event.d.ts.map +1 -0
- package/dist/react/use-opencode-events/handle-message-event.js +33 -0
- package/dist/react/use-opencode-events/handle-message-event.js.map +1 -0
- package/dist/react/use-opencode-events/handle-session-event.d.ts +5 -0
- package/dist/react/use-opencode-events/handle-session-event.d.ts.map +1 -0
- package/dist/react/use-opencode-events/handle-session-event.js +243 -0
- package/dist/react/use-opencode-events/handle-session-event.js.map +1 -0
- package/dist/react/use-opencode-events/handle-workspace-event.d.ts +4 -0
- package/dist/react/use-opencode-events/handle-workspace-event.d.ts.map +1 -0
- package/dist/react/use-opencode-events/handle-workspace-event.js +113 -0
- package/dist/react/use-opencode-events/handle-workspace-event.js.map +1 -0
- package/dist/react/use-opencode-events/handler-context.d.ts +29 -0
- package/dist/react/use-opencode-events/handler-context.d.ts.map +1 -0
- package/dist/react/use-opencode-events/handler-context.js +2 -0
- package/dist/react/use-opencode-events/handler-context.js.map +1 -0
- package/dist/react/use-opencode-events/hydrate-core.d.ts +23 -0
- package/dist/react/use-opencode-events/hydrate-core.d.ts.map +1 -0
- package/dist/react/use-opencode-events/hydrate-core.js +126 -0
- package/dist/react/use-opencode-events/hydrate-core.js.map +1 -0
- package/dist/react/use-opencode-events/index.d.ts +1 -0
- package/dist/react/use-opencode-events/index.d.ts.map +1 -1
- package/dist/react/use-opencode-events/index.js +40 -143
- package/dist/react/use-opencode-events/index.js.map +1 -1
- package/dist/react/use-opencode-events/runtime-stream-signals.d.ts +45 -0
- package/dist/react/use-opencode-events/runtime-stream-signals.d.ts.map +1 -0
- package/dist/react/use-opencode-events/runtime-stream-signals.js +32 -0
- package/dist/react/use-opencode-events/runtime-stream-signals.js.map +1 -0
- package/dist/react/use-opencode-events/stream-revival.d.ts +0 -21
- package/dist/react/use-opencode-events/stream-revival.d.ts.map +1 -1
- package/dist/react/use-opencode-events/stream-revival.js +33 -2
- package/dist/react/use-opencode-events/stream-revival.js.map +1 -1
- package/dist/react/use-opencode-events/use-event-stream-refs.d.ts +1 -1
- package/dist/react/use-opencode-events/use-event-stream-refs.d.ts.map +1 -1
- package/dist/react/use-opencode-local.d.ts +1 -1
- package/dist/react/use-opencode-local.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/agents.d.ts +1 -1
- package/dist/react/use-opencode-sessions/agents.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/commands.d.ts +4 -1
- package/dist/react/use-opencode-sessions/commands.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/commands.js +6 -1
- package/dist/react/use-opencode-sessions/commands.js.map +1 -1
- package/dist/react/use-opencode-sessions/files.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/files.js +8 -33
- package/dist/react/use-opencode-sessions/files.js.map +1 -1
- package/dist/react/use-opencode-sessions/keys.d.ts +12 -1
- package/dist/react/use-opencode-sessions/keys.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/keys.js +10 -0
- package/dist/react/use-opencode-sessions/keys.js.map +1 -1
- package/dist/react/use-opencode-sessions/mcp.d.ts +1 -1
- package/dist/react/use-opencode-sessions/mcp.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/messages.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/messages.js +8 -2
- package/dist/react/use-opencode-sessions/messages.js.map +1 -1
- package/dist/react/use-opencode-sessions/parts.d.ts +2 -2
- package/dist/react/use-opencode-sessions/parts.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/projects.d.ts +1 -1
- package/dist/react/use-opencode-sessions/projects.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/providers.d.ts +1 -1
- package/dist/react/use-opencode-sessions/providers.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/providers.js +12 -2
- package/dist/react/use-opencode-sessions/providers.js.map +1 -1
- package/dist/react/use-opencode-sessions/sessions.d.ts +8 -3
- package/dist/react/use-opencode-sessions/sessions.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/sessions.js +9 -2
- package/dist/react/use-opencode-sessions/sessions.js.map +1 -1
- package/dist/react/use-opencode-sessions/shared.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/shared.js +6 -1
- package/dist/react/use-opencode-sessions/shared.js.map +1 -1
- package/dist/react/use-opencode-sessions/sharing.d.ts +1 -1
- package/dist/react/use-opencode-sessions/sharing.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/vcs.d.ts +1 -1
- package/dist/react/use-opencode-sessions/vcs.d.ts.map +1 -1
- package/dist/react/use-project-apps.d.ts +6 -0
- package/dist/react/use-project-apps.d.ts.map +1 -1
- package/dist/react/use-project-gateway.d.ts +28 -0
- package/dist/react/use-project-gateway.d.ts.map +1 -0
- package/dist/react/use-project-gateway.js +120 -0
- package/dist/react/use-project-gateway.js.map +1 -0
- package/dist/react/use-project-secrets.d.ts +6 -6
- package/dist/react/use-project-sessions.d.ts +1 -1
- package/dist/react/use-project-sessions.d.ts.map +1 -1
- package/dist/react/use-project-sessions.js +2 -3
- package/dist/react/use-project-sessions.js.map +1 -1
- package/dist/react/use-session-messages.d.ts +4 -2
- package/dist/react/use-session-messages.d.ts.map +1 -1
- package/dist/react/use-session-messages.js +1 -1
- package/dist/react/use-session-messages.js.map +1 -1
- package/dist/react/use-session-participants.d.ts +10 -0
- package/dist/react/use-session-participants.d.ts.map +1 -0
- package/dist/react/use-session-participants.js +19 -0
- package/dist/react/use-session-participants.js.map +1 -0
- package/dist/react/use-session-prompts.d.ts +6 -0
- package/dist/react/use-session-prompts.d.ts.map +1 -1
- package/dist/react/use-session-prompts.js +17 -1
- package/dist/react/use-session-prompts.js.map +1 -1
- package/dist/react/use-session-sync.d.ts +4 -5
- package/dist/react/use-session-sync.d.ts.map +1 -1
- package/dist/react/use-session-sync.js +4 -1
- package/dist/react/use-session-sync.js.map +1 -1
- package/dist/react/use-session-transcript-history.d.ts.map +1 -1
- package/dist/react/use-session-transcript-history.js +14 -5
- package/dist/react/use-session-transcript-history.js.map +1 -1
- package/dist/react/use-session-working.d.ts +1 -1
- package/dist/react/use-session-working.d.ts.map +1 -1
- package/dist/react/use-session.d.ts +21 -9
- package/dist/react/use-session.d.ts.map +1 -1
- package/dist/react/use-session.js +64 -17
- package/dist/react/use-session.js.map +1 -1
- package/dist/react/use-teams-installations.d.ts +14 -0
- package/dist/react/use-teams-installations.d.ts.map +1 -1
- package/dist/react/use-teams-installations.js.map +1 -1
- package/dist/react/use-tunnel.d.ts +9 -0
- package/dist/react/use-tunnel.d.ts.map +1 -1
- package/dist/react/use-tunnel.js +9 -3
- package/dist/react/use-tunnel.js.map +1 -1
- package/dist/react/use-visible-agents.d.ts +1 -1
- package/dist/react/use-visible-agents.d.ts.map +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/transcript.d.ts.map +1 -1
- package/dist/workspace-search/client.d.ts +20 -0
- package/dist/workspace-search/client.d.ts.map +1 -0
- package/dist/workspace-search/client.js +235 -0
- package/dist/workspace-search/client.js.map +1 -0
- package/dist/workspace-search/core.d.ts +2 -2
- package/dist/workspace-search/core.d.ts.map +1 -1
- package/dist/workspace-search/core.js +44 -4
- package/dist/workspace-search/core.js.map +1 -1
- package/dist/workspace-search/index.d.ts +3 -0
- package/dist/workspace-search/index.d.ts.map +1 -0
- package/dist/workspace-search/index.js +3 -0
- package/dist/workspace-search/index.js.map +1 -0
- package/package.json +7 -5
- package/dist/core/runtime/opencode-v2-event-aliases.d.ts +0 -184
- package/dist/core/runtime/opencode-v2-event-aliases.d.ts.map +0 -1
- package/dist/core/runtime/opencode-v2-event-aliases.js +0 -2
- package/dist/core/runtime/opencode-v2-event-aliases.js.map +0 -1
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
import { bindCatalog } from './facade-catalog.js';
|
|
2
|
+
import { bindCommerce } from './facade-commerce.js';
|
|
3
|
+
import { bindIdentity } from './facade-identity.js';
|
|
4
|
+
import { bindPreviewOptions } from './facade-preview.js';
|
|
5
|
+
import { session } from './session-handle.js';
|
|
6
|
+
export { SessionNotReadyError } from './session-shared.js';
|
|
7
|
+
import { bindProjectAccessResources } from './project-access-resources.js';
|
|
8
|
+
import { bindProjectAccessSecurity } from './project-access-security.js';
|
|
9
|
+
import { projectConnections } from './project-connections.js';
|
|
10
|
+
import { connectorDataPlane } from './project-connectors.js';
|
|
11
|
+
import { bindProjectCore } from './project-core.js';
|
|
12
|
+
import { bindProjectOperations } from './project-operations.js';
|
|
13
|
+
import { bindProjectPlatformResources } from './project-platform-resources.js';
|
|
14
|
+
import { bindProjectPlatformSecurity } from './project-platform-security.js';
|
|
1
15
|
/**
|
|
2
16
|
* createKortix — the single opinionated entry point to the Kortix data layer.
|
|
3
17
|
*
|
|
@@ -9,87 +23,19 @@
|
|
|
9
23
|
* await kortix.project(pid).secrets.upsert({ name, value });
|
|
10
24
|
* const s = kortix.session(pid, sid);
|
|
11
25
|
* await s.start();
|
|
12
|
-
* s.
|
|
26
|
+
* await s.send('what files are here?'); // through the prompt inbox
|
|
27
|
+
* const { messages } = await s.messages(); // { info, parts }, kortix.transcript.v1
|
|
13
28
|
*
|
|
14
29
|
* REST methods are direct references to the platform client, so they keep their
|
|
15
30
|
* exact types with zero re-typing. The `project()`/`session()` handles bind ids
|
|
16
31
|
* for ergonomics. Reactive data still comes from `@kortix/sdk/react` hooks.
|
|
17
32
|
*/
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
20
|
-
import { getClient, getClientForUrl } from '../runtime/client.js';
|
|
21
|
-
import { ApiError } from '../http/api/errors.js';
|
|
22
|
-
import { backendApi } from '../http/api-client.js';
|
|
23
|
-
import { configureKortix, platformConfig } from '../http/config.js';
|
|
33
|
+
import { getClient } from '../runtime/client.js';
|
|
34
|
+
import { configureKortix } from '../http/config.js';
|
|
24
35
|
import * as P from '../rest/projects-client/index.js';
|
|
25
|
-
import * as A from '../rest/platform-client/auth.js';
|
|
26
|
-
import { createKortixSession } from '../auth/session.js';
|
|
27
|
-
import { getSessionHealth } from '../session/health.js';
|
|
28
|
-
import { proxyLocalhostUrl, rewriteLocalhostUrl } from '../session/url.js';
|
|
29
|
-
import { loadPreviewUrlTemplate } from '../session/preview-config.js';
|
|
30
|
-
import { resolvePreviewOptions } from '../session/preview-options.js';
|
|
31
|
-
import { setCurrentRuntime } from '../session/current-runtime.js';
|
|
32
|
-
import { clearSessionRuntime, getSessionRuntime, } from '../session/session-runtime-registry.js';
|
|
33
|
-
import { getSandboxUrlForExternalId } from '../session/server-store/url-helpers.js';
|
|
34
|
-
import { openEventStream, } from '../stream/event-stream.js';
|
|
35
|
-
/** The opencode runtime client for the currently-active sandbox (set by the host). */
|
|
36
36
|
function runtime() {
|
|
37
37
|
return getClient();
|
|
38
38
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Thrown by a session handle's runtime-scoped operations (`.runtime`,
|
|
41
|
-
* `.health()`, `.previewUrl()`, `.proxyUrl()`) when called before the handle
|
|
42
|
-
* has resolved its own sandbox runtime. These never fall back to whatever
|
|
43
|
-
* sandbox happens to be globally active (a different session's runtime) —
|
|
44
|
-
* the caller must resolve THIS handle's runtime first.
|
|
45
|
-
*/
|
|
46
|
-
/**
|
|
47
|
-
* Dedupes concurrent `ensureReady()` calls that would otherwise both drive a
|
|
48
|
-
* `/start` long-poll for the SAME (projectId, sessionId) — e.g. two session
|
|
49
|
-
* handles for the same session (or the facade racing the React `useSession`
|
|
50
|
-
* hook) both calling `ensureReady()`/`start()` before either has resolved a
|
|
51
|
-
* runtime. Keyed by `${projectId}\n${sessionId}` (not the process-global
|
|
52
|
-
* "active runtime" — every other handle for a DIFFERENT session gets its own
|
|
53
|
-
* entry and is unaffected). Cleared on settle (success or failure) so a
|
|
54
|
-
* transient failure doesn't wedge the key — the next call issues a fresh
|
|
55
|
-
* `/start` instead of replaying a stale rejected promise forever.
|
|
56
|
-
*/
|
|
57
|
-
const inFlightSessionStarts = new Map();
|
|
58
|
-
/**
|
|
59
|
-
* Build the `RUNTIME_UNAVAILABLE` message from a not-ready `/start` result.
|
|
60
|
-
*
|
|
61
|
-
* The server already earns a concrete reason on a terminal `stage:"failed"` —
|
|
62
|
-
* `failure.category`/`failure.message`, its `failure.evidence.error`, or a
|
|
63
|
-
* plain `reason` (see `SessionStartResultSchema` in `@kortix/api-contract`).
|
|
64
|
-
* Before this, the caller threw only `(stage: <stage>)` and dropped all of it,
|
|
65
|
-
* so `kortix sessions log`/`sessions new --wait` surfaced a bare
|
|
66
|
-
* `Session runtime not ready (stage: failed)` with no cause — the operator
|
|
67
|
-
* could not tell a provider-capacity failure from a git-auth failure
|
|
68
|
-
* (incident-20260922T140537Z-kxhourly). Keep the stage for continuity and
|
|
69
|
-
* append the concrete reason when the result carries one.
|
|
70
|
-
*/
|
|
71
|
-
function runtimeNotReadyMessage(started) {
|
|
72
|
-
const base = `Session runtime not ready (stage: ${started?.stage ?? 'unknown'})`;
|
|
73
|
-
const failure = started?.failure;
|
|
74
|
-
const parts = [];
|
|
75
|
-
if (failure?.category)
|
|
76
|
-
parts.push(failure.category);
|
|
77
|
-
if (failure?.message)
|
|
78
|
-
parts.push(failure.message);
|
|
79
|
-
const providerError = failure?.evidence?.error;
|
|
80
|
-
if (providerError && providerError !== failure?.message)
|
|
81
|
-
parts.push(providerError);
|
|
82
|
-
// `reason` is the coarser fallback the server sends without a `failure` block.
|
|
83
|
-
if (parts.length === 0 && started?.reason)
|
|
84
|
-
parts.push(started.reason);
|
|
85
|
-
return parts.length > 0 ? `${base}: ${parts.join(' — ')}` : base;
|
|
86
|
-
}
|
|
87
|
-
export class SessionNotReadyError extends Error {
|
|
88
|
-
constructor(action) {
|
|
89
|
-
super(`Session runtime not ready — call \`await session.ensureReady()\` (it drives \`start()\` to completion and resolves this session's own sandbox runtime) before calling \`${action}\`.`);
|
|
90
|
-
this.name = 'SessionNotReadyError';
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
39
|
export function createKortix(config, opts) {
|
|
94
40
|
// Wire the platform seam once. All wrapped functions read it.
|
|
95
41
|
//
|
|
@@ -99,1098 +45,21 @@ export function createKortix(config, opts) {
|
|
|
99
45
|
// so this returned facade never touches (or is affected by) the module-global
|
|
100
46
|
// singleton other concurrent `createKortix()` calls in the same process share.
|
|
101
47
|
configureKortix(config, opts);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
* configures it as a relative path like `/api/kortix`. `new URL()` throws on
|
|
107
|
-
* a bare relative string (no base to resolve against). In a browser that's
|
|
108
|
-
* recoverable: resolve it against the page's own origin. Server-side there
|
|
109
|
-
* is no implicit origin, so a relative `backendUrl` is a real misconfiguration
|
|
110
|
-
* — fail loudly instead of silently defaulting to port 80.
|
|
111
|
-
*/
|
|
112
|
-
function parseBackendUrlForPort(apiBaseUrl) {
|
|
113
|
-
try {
|
|
114
|
-
return new URL(apiBaseUrl);
|
|
115
|
-
}
|
|
116
|
-
catch {
|
|
117
|
-
if (typeof window !== 'undefined' && window.location?.origin) {
|
|
118
|
-
try {
|
|
119
|
-
return new URL(apiBaseUrl, window.location.origin);
|
|
120
|
-
}
|
|
121
|
-
catch {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
throw new ApiError(`Kortix SDK: backendUrl must be an absolute URL outside the browser (got ${JSON.stringify(apiBaseUrl)}). Relative paths like "/api/kortix" only resolve against a page origin — configure an absolute backendUrl for server-side hosts.`, { code: 'INVALID_BACKEND_URL' });
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Resolve the proxy/preview URL context (sandboxId + api base) from config +
|
|
130
|
-
* a THIS-handle's own resolved sandbox id, so a session's `previewUrl`/
|
|
131
|
-
* `proxyUrl` never make the host name a sandbox — and never reads whichever
|
|
132
|
-
* sandbox happens to be globally active (which may belong to a different
|
|
133
|
-
* session handle).
|
|
134
|
-
*/
|
|
135
|
-
function resolvePreviewOptsForSandbox(sandboxId) {
|
|
136
|
-
// Read the LIVE platform config, not the `config` captured at
|
|
137
|
-
// `createKortix()` time: a host may re-point the seam after creation
|
|
138
|
-
// (calling `configureKortix()` again — e.g. the whitelabel app switching
|
|
139
|
-
// its `backendUrl` to a same-origin BFF proxy once it learns wrapper mode
|
|
140
|
-
// is on), and preview/proxy URLs must follow the reconfigured base like
|
|
141
|
-
// every other call path already does.
|
|
142
|
-
const apiBaseUrl = platformConfig().backendUrl ?? config.backendUrl;
|
|
143
|
-
let backendPort = 80;
|
|
144
|
-
const u = parseBackendUrlForPort(apiBaseUrl);
|
|
145
|
-
if (u) {
|
|
146
|
-
backendPort = u.port ? Number(u.port) : u.protocol === 'https:' ? 443 : 80;
|
|
147
|
-
}
|
|
148
|
-
// Assembled by the single producer, never by hand — see preview-options.ts.
|
|
149
|
-
return resolvePreviewOptions({ sandboxId, apiBaseUrl, backendPort });
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Headless regular auth — sign-up, sign-in (password, magic link, social),
|
|
153
|
-
* refresh, password reset, sign-out — through the Kortix API, never
|
|
154
|
-
* Supabase. `session()` returns a store whose `getToken` refreshes itself;
|
|
155
|
-
* pass it to `createKortix({ getToken: session.getToken })`.
|
|
156
|
-
*/
|
|
157
|
-
const auth = {
|
|
158
|
-
signUp: A.signUp,
|
|
159
|
-
signInWithPassword: A.signInWithPassword,
|
|
160
|
-
sendMagicLink: A.sendMagicLink,
|
|
161
|
-
verifyOtp: A.verifyOtp,
|
|
162
|
-
signInWithProvider: A.signInWithProvider,
|
|
163
|
-
exchangeCode: A.exchangeCode,
|
|
164
|
-
refresh: A.refreshSession,
|
|
165
|
-
resetPassword: A.resetPassword,
|
|
166
|
-
updatePassword: A.updatePassword,
|
|
167
|
-
updateUserMetadata: A.updateUserMetadata,
|
|
168
|
-
signInWithSso: A.signInWithSso,
|
|
169
|
-
mfa: A.authMfa,
|
|
170
|
-
user: A.authUser,
|
|
171
|
-
signOut: A.signOut,
|
|
172
|
-
session: createKortixSession,
|
|
173
|
-
};
|
|
174
|
-
/** Account-scoped operations. */
|
|
175
|
-
const accounts = {
|
|
176
|
-
list: P.listAccounts,
|
|
177
|
-
get: P.getAccount,
|
|
178
|
-
create: P.createAccount,
|
|
179
|
-
secretResources: {
|
|
180
|
-
list: P.listAccountSecretResources,
|
|
181
|
-
create: P.createAccountSecretResource,
|
|
182
|
-
rotate: P.rotateAccountSecretResource,
|
|
183
|
-
remove: P.deleteAccountSecretResource,
|
|
184
|
-
grant: P.grantAccountSecretResource,
|
|
185
|
-
revoke: P.revokeAccountSecretResourceGrant,
|
|
186
|
-
setAccess: P.setAccountSecretResourceAccess,
|
|
187
|
-
},
|
|
188
|
-
updateName: P.updateAccountName,
|
|
189
|
-
/** Organization branding (Enterprise): own logo / icon / favicon (light + dark) and product name. */
|
|
190
|
-
branding: {
|
|
191
|
-
get: P.getAccountBranding,
|
|
192
|
-
update: P.updateAccountBranding,
|
|
193
|
-
uploadAsset: P.uploadAccountBrandingAsset,
|
|
194
|
-
removeAsset: P.removeAccountBrandingAsset,
|
|
195
|
-
reset: P.resetAccountBranding,
|
|
196
|
-
},
|
|
197
|
-
leave: P.leaveAccount,
|
|
198
|
-
members: P.listAccountMembers,
|
|
199
|
-
invite: P.inviteAccountMember,
|
|
200
|
-
removeMember: P.removeAccountMember,
|
|
201
|
-
updateMemberRole: P.updateAccountMemberRole,
|
|
202
|
-
invites: P.listAccountInvites,
|
|
203
|
-
/** Cancel a pending account invite (accountId still known/scoped). */
|
|
204
|
-
cancelInvite: P.cancelAccountInvite,
|
|
205
|
-
/** Resend a pending account invite (accountId still known/scoped). */
|
|
206
|
-
resendInvite: P.resendAccountInvite,
|
|
207
|
-
/** CLI PAT minting — account-scoped personal access tokens (`kortix_pat_...`). */
|
|
208
|
-
tokens: {
|
|
209
|
-
list: P.listAccountTokens,
|
|
210
|
-
create: P.createAccountToken,
|
|
211
|
-
revoke: P.revokeAccountToken,
|
|
212
|
-
},
|
|
213
|
-
/** Connected apps — the OAuth / MCP clients this person approved, across all accounts. */
|
|
214
|
-
connectedApps: {
|
|
215
|
-
list: P.listOAuthGrants,
|
|
216
|
-
revoke: P.revokeOAuthGrant,
|
|
217
|
-
},
|
|
218
|
-
/** Enterprise audit log — events + CSV/JSONL export + SIEM webhooks. */
|
|
219
|
-
audit: {
|
|
220
|
-
log: P.listAccountAudit,
|
|
221
|
-
export: P.exportAccountAudit,
|
|
222
|
-
webhooks: {
|
|
223
|
-
list: P.listAccountAuditWebhooks,
|
|
224
|
-
create: P.createAccountAuditWebhook,
|
|
225
|
-
update: P.updateAccountAuditWebhook,
|
|
226
|
-
remove: P.removeAccountAuditWebhook,
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
};
|
|
230
|
-
/**
|
|
231
|
-
* Identity and access — the canonical RBAC surface.
|
|
232
|
-
*
|
|
233
|
-
* One vocabulary: a PRINCIPAL (user, group, service account, pending invitee)
|
|
234
|
-
* holds a ROLE at a SCOPE (the account, or one project), optionally narrowed
|
|
235
|
-
* to one OBJECT, as one ASSIGNMENT row. A role is a set of PERMISSIONS.
|
|
236
|
-
*
|
|
237
|
-
* `assignments` is the only grant store — it replaced the account-role column,
|
|
238
|
-
* the project-role column, group grants, policies and resource grants. There is
|
|
239
|
-
* no second way to grant anything, and `can`/`canBatch` is the only way to ask.
|
|
240
|
-
*/
|
|
241
|
-
const iam = {
|
|
242
|
-
/** The grant table. One row per (principal, role, scope, object). */
|
|
243
|
-
assignments: {
|
|
244
|
-
list: P.listAssignments,
|
|
245
|
-
create: P.createAssignment,
|
|
246
|
-
revoke: P.revokeAssignment,
|
|
247
|
-
},
|
|
248
|
-
/** The permission catalog as data — action, scope, delegability, implications. */
|
|
249
|
-
permissions: {
|
|
250
|
-
list: P.listPermissions,
|
|
251
|
-
/** The leaves one role carries. */
|
|
252
|
-
forRole: P.getRolePermissions,
|
|
253
|
-
},
|
|
254
|
-
roles: {
|
|
255
|
-
list: P.listRoles,
|
|
256
|
-
create: P.createRole,
|
|
257
|
-
update: P.updateRole,
|
|
258
|
-
setPermissions: P.updateRolePermissions,
|
|
259
|
-
remove: P.deleteRole,
|
|
260
|
-
usage: P.getRoleUsage,
|
|
261
|
-
},
|
|
262
|
-
groups: {
|
|
263
|
-
list: P.listGroups,
|
|
264
|
-
get: P.getGroup,
|
|
265
|
-
create: P.createGroup,
|
|
266
|
-
update: P.updateGroup,
|
|
267
|
-
remove: P.deleteGroup,
|
|
268
|
-
members: {
|
|
269
|
-
list: P.listGroupMembers,
|
|
270
|
-
add: P.addGroupMembers,
|
|
271
|
-
remove: P.removeGroupMember,
|
|
272
|
-
},
|
|
273
|
-
},
|
|
274
|
-
/** Auto-provisioned agent identities — the principal picker for binding a
|
|
275
|
-
* role to an agent. */
|
|
276
|
-
agentIdentities: P.listAgentIdentities,
|
|
277
|
-
/** "Sign in with Kortix" app registry — pair a client with `createKortixAuth`
|
|
278
|
-
* from `@kortix/sdk/server`. The secret is returned once, on create/rotate. */
|
|
279
|
-
oauthClients: {
|
|
280
|
-
list: P.listOAuthClients,
|
|
281
|
-
get: P.getOAuthClient,
|
|
282
|
-
create: P.createOAuthClient,
|
|
283
|
-
update: P.updateOAuthClient,
|
|
284
|
-
rotateSecret: P.rotateOAuthClientSecret,
|
|
285
|
-
remove: P.deleteOAuthClient,
|
|
286
|
-
},
|
|
287
|
-
/** Ask the engine. This is the ONLY authorization read a client should make:
|
|
288
|
-
* probe the LEAF a route asserts, never a role label. */
|
|
289
|
-
can: P.probeEffectivePermission,
|
|
290
|
-
/** Batch probe — one roundtrip for N leaves. */
|
|
291
|
-
canBatch: P.probeEffectivePermissions,
|
|
292
|
-
};
|
|
293
|
-
/**
|
|
294
|
-
* Billing read surface — credits, subscription, tier, and transaction
|
|
295
|
-
* history for entitlement-gating + a billing/usage UI. Checkout/portal/
|
|
296
|
-
* credit-purchase/subscription MUTATIONS stay app-owned (Stripe flows) —
|
|
297
|
-
* this is reads only.
|
|
298
|
-
*/
|
|
299
|
-
const billing = {
|
|
300
|
-
accountState: P.getAccountState,
|
|
301
|
-
accountStateMinimal: P.getAccountStateMinimal,
|
|
302
|
-
transactions: P.listBillingTransactions,
|
|
303
|
-
transactionsSummary: P.getBillingTransactionsSummary,
|
|
304
|
-
creditBreakdown: P.getBillingCreditBreakdown,
|
|
305
|
-
usageHistory: P.getBillingUsageHistory,
|
|
306
|
-
/** Usage rollup (/v1/usage), optionally grouped by model, provider, or day. */
|
|
307
|
-
usageRollup: P.getUsageRollup,
|
|
308
|
-
/** Unified finalized LLM and compute cost by session. */
|
|
309
|
-
sessionCosts: {
|
|
310
|
-
list: P.listSessionCosts,
|
|
311
|
-
get: P.getSessionCostRecord,
|
|
312
|
-
},
|
|
313
|
-
tierConfigurations: P.getBillingTierConfigurations,
|
|
314
|
-
/** Stripe checkout — start a subscription and confirm it post-redirect. */
|
|
315
|
-
checkout: {
|
|
316
|
-
createSession: (input) => P.createCheckoutSession(input),
|
|
317
|
-
confirmSession: (sessionId, accountId) => P.confirmCheckoutSession(sessionId, accountId),
|
|
318
|
-
},
|
|
319
|
-
/** Manage an existing subscription (portal, cancel/reactivate, downgrade). */
|
|
320
|
-
subscription: {
|
|
321
|
-
createPortalSession: (returnUrl, accountId) => P.createPortalSession(returnUrl, accountId),
|
|
322
|
-
cancel: (feedback, accountId) => P.cancelSubscription(feedback, accountId),
|
|
323
|
-
reactivate: (accountId) => P.reactivateSubscription(accountId),
|
|
324
|
-
scheduleDowngrade: (targetTierKey, commitmentType, accountId) => P.scheduleDowngrade(targetTierKey, commitmentType, accountId),
|
|
325
|
-
cancelScheduledChange: (accountId) => P.cancelScheduledChange(accountId),
|
|
326
|
-
prorationPreview: (newPriceId, accountId) => P.getProrationPreview(newPriceId, accountId),
|
|
327
|
-
},
|
|
328
|
-
/** One-off credit purchases + recurring auto-topup configuration. */
|
|
329
|
-
credits: {
|
|
330
|
-
purchase: (input) => P.purchaseCredits(input),
|
|
331
|
-
autoTopupSettings: (accountId) => P.getAutoTopupSettings(accountId),
|
|
332
|
-
configureAutoTopup: (input) => P.configureAutoTopup(input),
|
|
333
|
-
},
|
|
334
|
-
};
|
|
335
|
-
/**
|
|
336
|
-
* Account-invite lifecycle reached by invite token alone — accept/decline/
|
|
337
|
-
* describe are called by the invitee (who may not be an account member, or
|
|
338
|
-
* even signed into this account, yet), so they take only `inviteId` and
|
|
339
|
-
* genuinely don't fit account- or project-scoping.
|
|
340
|
-
*/
|
|
341
|
-
const accountInvites = {
|
|
342
|
-
/** The caller's own pending invites, matched by email. */
|
|
343
|
-
listMine: P.listMyAccountInvites,
|
|
344
|
-
describe: P.describeAccountInvite,
|
|
345
|
-
accept: P.acceptAccountInvite,
|
|
346
|
-
decline: P.declineAccountInvite,
|
|
347
|
-
};
|
|
348
|
-
/** Top-level project operations (not bound to an id). */
|
|
349
|
-
const projects = {
|
|
350
|
-
list: P.listProjects,
|
|
351
|
-
listForAccount: P.listProjectsForAccount,
|
|
352
|
-
get: P.getProject,
|
|
353
|
-
detail: P.getProjectDetail,
|
|
354
|
-
create: P.createProject,
|
|
355
|
-
/** Create a project backed by a brand-new Kortix-managed GitHub repo. */
|
|
356
|
-
createRepo: P.createProjectRepo,
|
|
357
|
-
provision: P.provisionProject,
|
|
358
|
-
update: P.updateProject,
|
|
359
|
-
archive: P.archiveProject,
|
|
360
|
-
llmCatalog: P.getProjectLlmCatalog,
|
|
361
|
-
modelPicker: P.getProjectModelPicker,
|
|
362
|
-
modelAccess: P.getProjectModelAccess,
|
|
363
|
-
setModelAccess: P.setProjectModelAccess,
|
|
364
|
-
sandboxHealth: P.getProjectSandboxHealth,
|
|
365
|
-
sandboxTemplates: P.listProjectSandboxTemplates,
|
|
366
|
-
sessions: P.listProjectSessions,
|
|
367
|
-
createSession: P.createProjectSession,
|
|
368
|
-
};
|
|
369
|
-
/** GitHub App installation + repository linking — account-scoped, not project-scoped. */
|
|
370
|
-
const github = {
|
|
371
|
-
linkRepository: P.linkRepository,
|
|
372
|
-
replaceProjectRepository: P.replaceProjectRepository,
|
|
373
|
-
getInstallation: P.getGitHubInstallation,
|
|
374
|
-
listInstallations: P.listGitHubInstallations,
|
|
375
|
-
listLinkableInstallations: P.listLinkableGitHubInstallations,
|
|
376
|
-
listRepositories: P.listGitHubRepositories,
|
|
377
|
-
listRepositoryBranches: P.listGitHubRepositoryBranches,
|
|
378
|
-
linkInstallation: P.linkGitHubInstallation,
|
|
379
|
-
saveInstallation: P.saveGitHubInstallation,
|
|
380
|
-
deleteInstallation: P.deleteGitHubInstallation,
|
|
381
|
-
/** Store this user's GitHub authorization — needed to create a repository
|
|
382
|
-
* in a personal GitHub account. */
|
|
383
|
-
storeUserToken: P.storeGitHubUserToken,
|
|
384
|
-
};
|
|
385
|
-
/**
|
|
386
|
-
* The instance git backend ("Kortix managed") — one deployment-wide owner
|
|
387
|
-
* plus credential, never an account connection. `backend()` is readable by
|
|
388
|
-
* any authenticated user; `backendRepositories()` is self-host-operator only.
|
|
389
|
-
*/
|
|
390
|
-
const gitBackend = {
|
|
391
|
-
get: P.getManagedGitBackend,
|
|
392
|
-
repositories: P.listManagedGitRepositories,
|
|
393
|
-
};
|
|
394
|
-
/** Public share links for a sandbox port (`/v1/p/share`) — sandbox-scoped, not project-scoped. */
|
|
395
|
-
const sandboxShares = {
|
|
396
|
-
list: P.listSandboxShares,
|
|
397
|
-
create: P.createSandboxShare,
|
|
398
|
-
revoke: P.revokeSandboxShare,
|
|
399
|
-
};
|
|
400
|
-
/** Deployment-wide flag: is the easy-connect (Pipedream) provider configured? Not project-scoped. */
|
|
401
|
-
const connectStatus = P.getConnectStatus;
|
|
402
|
-
/**
|
|
403
|
-
* Public marketplace catalog browse (`/v1/marketplace/*`) — top-level and
|
|
404
|
-
* distinct from `project(id).marketplace`, which is install-scoped (commits
|
|
405
|
-
* an item onto a specific project's branch). This is read-only browsing +
|
|
406
|
-
* the authed "add a marketplace source" surface.
|
|
407
|
-
*/
|
|
408
|
-
const marketplace = {
|
|
409
|
-
items: (options) => P.listMarketplaceCatalogItems(options),
|
|
410
|
-
item: (id) => P.getMarketplaceCatalogItem(id),
|
|
411
|
-
itemFile: (id, path) => P.getMarketplaceCatalogItemFile(id, path),
|
|
412
|
-
marketplaces: () => P.listMarketplaces(),
|
|
413
|
-
featured: () => P.listFeaturedMarketplaces(),
|
|
414
|
-
sources: {
|
|
415
|
-
list: () => P.listMarketplaceSources(),
|
|
416
|
-
add: (input) => P.addMarketplaceSource(input),
|
|
417
|
-
remove: (id) => P.removeMarketplaceSource(id),
|
|
418
|
-
},
|
|
419
|
-
};
|
|
48
|
+
const resolvePreviewOptsForSandbox = bindPreviewOptions(config);
|
|
49
|
+
const { auth, accounts, iam, accountInvites } = bindIdentity();
|
|
50
|
+
const { billing, sandboxShares } = bindCommerce();
|
|
51
|
+
const { projects, github, gitBackend, connectStatus, marketplace } = bindCatalog();
|
|
420
52
|
/** Id-bound handle for a single project: every sub-resource, projectId pre-applied. */
|
|
421
|
-
function connectorDataPlane(projectId) {
|
|
422
|
-
return {
|
|
423
|
-
/** Callable catalog for this project or token scope. */
|
|
424
|
-
catalog: (options) => P.getConnectorCatalog(projectId, options),
|
|
425
|
-
/** Flattened `<connector>.<action>` tool list. */
|
|
426
|
-
tools: () => P.listConnectorTools(projectId),
|
|
427
|
-
/** Search callable tools by id and description. */
|
|
428
|
-
search: (...a) => P.searchConnectorTools(projectId, ...a),
|
|
429
|
-
/** Describe one `<connector>.<action>` tool. */
|
|
430
|
-
describe: (...a) => P.describeConnectorTool(projectId, ...a),
|
|
431
|
-
/** Call one `<connector>.<action>` tool. */
|
|
432
|
-
call: (...a) => P.callConnector(projectId, ...a),
|
|
433
|
-
/** The accounts a connector can be called as, default first. */
|
|
434
|
-
accounts: (...a) => P.listConnectorAccounts(projectId, ...a),
|
|
435
|
-
/** Upload bytes for use by a later connector call. */
|
|
436
|
-
uploadAttachment: (...a) => P.uploadConnectorAttachment(projectId, ...a),
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
53
|
function project(projectId) {
|
|
440
|
-
const connections =
|
|
441
|
-
list: () => P.listConnections(projectId),
|
|
442
|
-
listAll: () => P.listAllConnections(projectId),
|
|
443
|
-
reconcile: (...a) => P.reconcileConnection(projectId, ...a),
|
|
444
|
-
reconcileMember: (...a) => P.reconcileMemberConnection(projectId, ...a),
|
|
445
|
-
updateCredential: (...a) => P.updateConnectionCredential(projectId, ...a),
|
|
446
|
-
revoke: (...a) => P.revokeConnection(projectId, ...a),
|
|
447
|
-
activate: (...a) => P.activateConnection(projectId, ...a),
|
|
448
|
-
setDefault: (...a) => P.setDefaultConnection(projectId, ...a),
|
|
449
|
-
rename: (...a) => P.renameConnection(projectId, ...a),
|
|
450
|
-
share: (...a) => P.shareConnection(projectId, ...a),
|
|
451
|
-
/** Add a machine the caller paired to this project as a `computer` account. */
|
|
452
|
-
addComputer: (...a) => P.addComputerToProject(projectId, ...a),
|
|
453
|
-
pipedreamConnect: (...a) => P.pipedreamConnectConnection(projectId, ...a),
|
|
454
|
-
pipedreamFinalize: (...a) => P.pipedreamFinalizeConnection(projectId, ...a),
|
|
455
|
-
};
|
|
456
|
-
return {
|
|
457
|
-
attachments: {
|
|
458
|
-
upload: (...args) => P.uploadPromptAttachment(projectId, ...args),
|
|
459
|
-
delete: (...args) => P.deletePromptAttachment(projectId, ...args),
|
|
460
|
-
createController: (options) => createPromptAttachmentController(projectId, options),
|
|
461
|
-
},
|
|
462
|
-
get: (opts) => P.getProject(projectId, opts),
|
|
463
|
-
detail: () => P.getProjectDetail(projectId),
|
|
464
|
-
/** Canonical project-scoped audit timeline. */
|
|
465
|
-
audit: (options) => P.listProjectAudit(projectId, options),
|
|
466
|
-
update: (input) => P.updateProject(projectId, input),
|
|
467
|
-
archive: () => P.archiveProject(projectId),
|
|
468
|
-
llmCatalog: () => P.getProjectLlmCatalog(projectId),
|
|
469
|
-
modelPicker: () => P.getProjectModelPicker(projectId),
|
|
470
|
-
modelAccess: () => P.getProjectModelAccess(projectId),
|
|
471
|
-
setModelAccess: (change) => P.setProjectModelAccess(projectId, change),
|
|
472
|
-
sandboxHealth: () => P.getProjectSandboxHealth(projectId),
|
|
473
|
-
onboardingComplete: (...a) => P.setProjectOnboardingComplete(projectId, ...a),
|
|
474
|
-
/** Provider-neutral serverless Apps owned by this project. */
|
|
475
|
-
apps: {
|
|
476
|
-
list: () => P.listApps(projectId),
|
|
477
|
-
create: (input) => P.createApp(projectId, input),
|
|
478
|
-
get: (appId) => P.getApp(projectId, appId),
|
|
479
|
-
update: (...a) => P.updateApp(projectId, ...a),
|
|
480
|
-
access: {
|
|
481
|
-
get: (...a) => P.getAppAccess(projectId, ...a),
|
|
482
|
-
update: (...a) => P.updateAppAccess(projectId, ...a),
|
|
483
|
-
session: (...a) => P.createAppAccessSession(projectId, ...a),
|
|
484
|
-
/** Agents whose `kortix.yaml` `apps:` grant names this App. Read-only. */
|
|
485
|
-
agents: (appId) => P.listAppAgents(projectId, appId),
|
|
486
|
-
},
|
|
487
|
-
remove: (appId) => P.deleteApp(projectId, appId),
|
|
488
|
-
artifacts: {
|
|
489
|
-
register: (input) => P.registerAppArtifact(projectId, input),
|
|
490
|
-
uploadArchive: (...a) => P.uploadAppArtifactArchive(projectId, ...a),
|
|
491
|
-
finalize: (...a) => P.finalizeAppArtifact(projectId, ...a),
|
|
492
|
-
},
|
|
493
|
-
deployments: {
|
|
494
|
-
create: (...a) => P.createAppDeployment(projectId, ...a),
|
|
495
|
-
list: (appId) => P.listAppDeployments(projectId, appId),
|
|
496
|
-
get: (...a) => P.getAppDeployment(projectId, ...a),
|
|
497
|
-
logs: (...a) => P.getAppDeploymentLogs(projectId, ...a),
|
|
498
|
-
},
|
|
499
|
-
start: (appId) => P.startApp(projectId, appId),
|
|
500
|
-
stop: (appId) => P.stopApp(projectId, appId),
|
|
501
|
-
rollback: (...a) => P.rollbackApp(projectId, ...a),
|
|
502
|
-
},
|
|
503
|
-
/** Project-scoped CLI PATs (auto-minted at session-create as `KORTIX_TOKEN`; can also be minted by hand). */
|
|
504
|
-
tokens: {
|
|
505
|
-
list: () => P.listProjectCliTokens(projectId),
|
|
506
|
-
create: (input) => P.createProjectCliToken(projectId, input),
|
|
507
|
-
revoke: (tokenId) => P.revokeProjectCliToken(projectId, tokenId),
|
|
508
|
-
},
|
|
509
|
-
/** Agent-minted setup links — hand a human a link to enter a secret value or 1-click connect an app. */
|
|
510
|
-
setupLinks: {
|
|
511
|
-
requestSecret: (input) => P.requestProjectSecret(projectId, input),
|
|
512
|
-
requestConnector: (input) => P.requestProjectConnector(projectId, input),
|
|
513
|
-
},
|
|
514
|
-
/** Validate a `kortix.yaml` (or legacy `kortix.toml`) manifest's raw text server-side — format is auto-resolved from the project's manifest path (same schema `kortix ship`/CR-merge use). */
|
|
515
|
-
validateManifest: (raw) => P.validateProjectManifest(projectId, raw),
|
|
516
|
-
/** Mint a fresh scoped git push token for a managed project (409 for BYO repos). */
|
|
517
|
-
gitToken: () => P.getProjectGitToken(projectId),
|
|
518
|
-
secrets: {
|
|
519
|
-
list: () => P.listProjectSecrets(projectId),
|
|
520
|
-
upsert: (input) => P.upsertProjectSecret(projectId, input),
|
|
521
|
-
setStrategy: (...a) => P.setProjectSecretStrategy(projectId, ...a),
|
|
522
|
-
broker: (...a) => P.brokerProjectSecretRequest(projectId, ...a),
|
|
523
|
-
remove: (name) => P.deleteProjectSecret(projectId, name),
|
|
524
|
-
setPersonal: (...a) => P.setPersonalProjectSecret(projectId, ...a),
|
|
525
|
-
removePersonal: (name) => P.deletePersonalProjectSecret(projectId, name),
|
|
526
|
-
setGitCredential: (input) => P.upsertProjectGitCredential(projectId, input),
|
|
527
|
-
/** The provider logins saved on this project (ChatGPT, OpenCode Zen, OpenCode Go). */
|
|
528
|
-
listProviderOAuth: () => P.listProjectProviderOAuth(projectId),
|
|
529
|
-
/** Device-code OAuth flow to connect a subscription-backed provider (e.g. ChatGPT, opencode-go). */
|
|
530
|
-
startProviderOAuth: (...a) => P.startProjectProviderOAuth(projectId, ...a),
|
|
531
|
-
pollProviderOAuth: (...a) => P.pollProjectProviderOAuth(projectId, ...a),
|
|
532
|
-
removeProviderOAuth: (provider) => P.deleteProjectProviderOAuth(projectId, provider),
|
|
533
|
-
},
|
|
534
|
-
access: {
|
|
535
|
-
list: () => P.listProjectAccess(projectId),
|
|
536
|
-
invite: (...a) => P.inviteProjectMember(projectId, ...a),
|
|
537
|
-
update: (...a) => P.updateProjectAccess(projectId, ...a),
|
|
538
|
-
revoke: (userId) => P.revokeProjectAccess(projectId, userId),
|
|
539
|
-
pendingInvites: () => P.listPendingProjectInvites(projectId),
|
|
540
|
-
resendInvite: (...a) => P.resendPendingProjectInvite(projectId, ...a),
|
|
541
|
-
revokeInvite: (...a) => P.revokePendingProjectInvite(projectId, ...a),
|
|
542
|
-
requests: () => P.listProjectAccessRequests(projectId),
|
|
543
|
-
approveRequest: (...a) => P.approveProjectAccessRequest(projectId, ...a),
|
|
544
|
-
rejectRequest: (...a) => P.rejectProjectAccessRequest(projectId, ...a),
|
|
545
|
-
groupGrants: () => P.listProjectGroupGrants(projectId),
|
|
546
|
-
attachGroupGrant: (...a) => P.attachGroupToProject(projectId, ...a),
|
|
547
|
-
updateGroupGrant: (...a) => P.updateProjectGroupGrant(projectId, ...a),
|
|
548
|
-
detachGroupGrant: (groupId) => P.detachGroupFromProject(projectId, groupId),
|
|
549
|
-
/** Per-resource (agent/skill/secret) grants to a member or a group. */
|
|
550
|
-
resourceGrants: {
|
|
551
|
-
list: () => P.listProjectResourceGrants(projectId),
|
|
552
|
-
create: (input) => P.createProjectResourceGrant(projectId, input),
|
|
553
|
-
remove: (grantId) => P.deleteProjectResourceGrant(projectId, grantId),
|
|
554
|
-
},
|
|
555
|
-
},
|
|
556
|
-
connectors: {
|
|
557
|
-
...connectorDataPlane(projectId),
|
|
558
|
-
list: () => P.listConnectors(projectId),
|
|
559
|
-
config: (...a) => P.getConnectorConfig(projectId, ...a),
|
|
560
|
-
create: (...a) => P.createConnector(projectId, ...a),
|
|
561
|
-
remove: (...a) => P.deleteConnector(projectId, ...a),
|
|
562
|
-
sync: () => P.syncConnectors(projectId),
|
|
563
|
-
auth: {
|
|
564
|
-
discover: (...a) => P.discoverConnectorAuth(projectId, ...a),
|
|
565
|
-
},
|
|
566
|
-
setName: (...a) => P.setConnectorName(projectId, ...a),
|
|
567
|
-
setCredentialMode: (...a) => P.setConnectorCredentialMode(projectId, ...a),
|
|
568
|
-
setAuthorizationStrategy: (...a) => P.setConnectorAuthorizationStrategy(projectId, ...a),
|
|
569
|
-
setCredential: (...a) => P.setConnectorCredential(projectId, ...a),
|
|
570
|
-
setSensitive: (...a) => P.setConnectorSensitive(projectId, ...a),
|
|
571
|
-
connections,
|
|
572
|
-
policies: {
|
|
573
|
-
get: (...a) => P.getConnectorPolicies(projectId, ...a),
|
|
574
|
-
set: (...a) => P.setConnectorPolicies(projectId, ...a),
|
|
575
|
-
},
|
|
576
|
-
/** Easy-connect (Pipedream): app catalog + connect/finalize handshake. */
|
|
577
|
-
pipedream: {
|
|
578
|
-
listApps: (...a) => P.listPipedreamApps(projectId, ...a),
|
|
579
|
-
/** The browse page: a fixed top slice of each of the largest
|
|
580
|
-
* categories, with each category's true total, in one request. */
|
|
581
|
-
listSections: (...a) => P.listPipedreamSections(projectId, ...a),
|
|
582
|
-
connect: (...a) => P.pipedreamConnect(projectId, ...a),
|
|
583
|
-
finalize: (...a) => P.pipedreamFinalize(projectId, ...a),
|
|
584
|
-
},
|
|
585
|
-
/** Direct connector catalogue and normalized domain surfaces. */
|
|
586
|
-
discover: {
|
|
587
|
-
list: (...a) => P.listDiscoverConnectors(projectId, ...a),
|
|
588
|
-
/** The browse page: Popular plus a fixed top slice of each section,
|
|
589
|
-
* with each section's true total, in one request. */
|
|
590
|
-
sections: (...a) => P.listDiscoverSections(projectId, ...a),
|
|
591
|
-
detail: (...a) => P.getDiscoverConnector(projectId, ...a),
|
|
592
|
-
},
|
|
593
|
-
},
|
|
594
|
-
policies: {
|
|
595
|
-
list: () => P.listProjectPolicies(projectId),
|
|
596
|
-
set: (...a) => P.setProjectPolicies(projectId, ...a),
|
|
597
|
-
},
|
|
598
|
-
/** Reminders on every session the caller can open — see `listProjectReminders`. */
|
|
599
|
-
reminders: {
|
|
600
|
-
list: () => P.listProjectReminders(projectId),
|
|
601
|
-
},
|
|
602
|
-
triggers: {
|
|
603
|
-
list: () => P.listProjectTriggers(projectId),
|
|
604
|
-
create: (...a) => P.createProjectTrigger(projectId, ...a),
|
|
605
|
-
update: (...a) => P.updateProjectTrigger(projectId, ...a),
|
|
606
|
-
remove: (...a) => P.deleteProjectTrigger(projectId, ...a),
|
|
607
|
-
fire: (...a) => P.fireProjectTrigger(projectId, ...a),
|
|
608
|
-
setActivation: (...a) => P.setProjectTriggersActivation(projectId, ...a),
|
|
609
|
-
},
|
|
610
|
-
files: {
|
|
611
|
-
list: (options) => P.listProjectFiles(projectId, options),
|
|
612
|
-
read: (path, ref) => P.readProjectFile(projectId, path, ref),
|
|
613
|
-
search: (...a) => P.searchProjectFiles(projectId, ...a),
|
|
614
|
-
archive: (...a) => P.fetchProjectArchive(projectId, ...a),
|
|
615
|
-
history: (...a) => P.getProjectFileHistory(projectId, ...a),
|
|
616
|
-
},
|
|
617
|
-
git: {
|
|
618
|
-
commits: () => P.listProjectCommits(projectId),
|
|
619
|
-
commit: (sha) => P.getProjectCommit(projectId, sha),
|
|
620
|
-
commitDiff: (sha) => P.getProjectCommitDiff(projectId, sha),
|
|
621
|
-
branches: () => P.listProjectBranches(projectId),
|
|
622
|
-
versionDiff: (...a) => P.getVersionDiff(projectId, ...a),
|
|
623
|
-
/** Invite a GitHub user as a collaborator on a Kortix-managed repo. */
|
|
624
|
-
inviteCollaborator: (...a) => P.inviteRepoCollaborator(projectId, ...a),
|
|
625
|
-
},
|
|
626
|
-
changeRequests: {
|
|
627
|
-
list: () => P.listChangeRequests(projectId),
|
|
628
|
-
get: (crId) => P.getChangeRequest(projectId, crId),
|
|
629
|
-
diff: (crId) => P.getChangeRequestDiff(projectId, crId),
|
|
630
|
-
mergePreview: (crId) => P.getChangeRequestMergePreview(projectId, crId),
|
|
631
|
-
open: (...a) => P.openChangeRequest(projectId, ...a),
|
|
632
|
-
merge: (...a) => P.mergeChangeRequest(projectId, ...a),
|
|
633
|
-
close: (...a) => P.closeChangeRequest(projectId, ...a),
|
|
634
|
-
reopen: (...a) => P.reopenChangeRequest(projectId, ...a),
|
|
635
|
-
/** Request changes on a CR (Review Center) — records feedback + optionally delivers it back to the originating session. */
|
|
636
|
-
requestChanges: (...a) => P.requestChangesOnChangeRequest(projectId, ...a),
|
|
637
|
-
},
|
|
638
|
-
sessions: {
|
|
639
|
-
/** One page of sessions as a bare array. See `listPage` for `next_cursor`. */
|
|
640
|
-
list: (options) => P.listProjectSessions(projectId, options),
|
|
641
|
-
/** One keyset page plus its continuation token. The list is bounded —
|
|
642
|
-
* walk it with `next_cursor`, and use `get(sessionId)` to resolve one
|
|
643
|
-
* session rather than paging in search of it. */
|
|
644
|
-
listPage: (options) => P.listProjectSessionsPage(projectId, options),
|
|
645
|
-
create: (input) => P.createProjectSession(projectId, input),
|
|
646
|
-
/** Pre-create the session a present user is about to start. Ordinary session; ignore failures. */
|
|
647
|
-
ensureWarm: () => P.ensureWarmProjectSession(projectId),
|
|
648
|
-
/** @deprecated Navigate to `ensureWarm()`'s session and prompt it. Removed in the next major. */
|
|
649
|
-
claimWarm: (input) => P.claimWarmProjectSession(projectId, input),
|
|
650
|
-
},
|
|
651
|
-
/** Review Center — the per-project human-in-the-loop inbox (change requests, tool approvals, agent outputs/decisions). */
|
|
652
|
-
review: {
|
|
653
|
-
list: (params) => P.listReviewItems(projectId, params),
|
|
654
|
-
get: (reviewItemId) => P.getReviewItem(projectId, reviewItemId),
|
|
655
|
-
submit: (input) => P.submitReviewItem(projectId, input),
|
|
656
|
-
act: (...a) => P.actReviewItem(projectId, ...a),
|
|
657
|
-
bulkAct: (input) => P.bulkActReviewItems(projectId, input),
|
|
658
|
-
},
|
|
659
|
-
/** The manager inbox of connector-gated actions awaiting approve/deny (APPROVE / ASK / BLOCK). */
|
|
660
|
-
approvals: {
|
|
661
|
-
list: (options) => P.listPendingApprovals(projectId, options),
|
|
662
|
-
resolve: (...a) => P.resolveApproval(projectId, ...a),
|
|
663
|
-
sessionsNeedingInput: (options) => P.listSessionsNeedingInput(projectId, options),
|
|
664
|
-
},
|
|
665
|
-
/** Gateway observability — LLM request logs, cost/latency rollups, budgets, gateway API keys. */
|
|
666
|
-
gateway: {
|
|
667
|
-
logs: (opts) => P.listGatewayLogs(projectId, opts),
|
|
668
|
-
log: (logId) => P.getGatewayLog(projectId, logId),
|
|
669
|
-
overview: (days) => P.getGatewayOverview(projectId, days),
|
|
670
|
-
series: (days) => P.getGatewaySeries(projectId, days),
|
|
671
|
-
breakdown: (days) => P.getGatewayBreakdown(projectId, days),
|
|
672
|
-
sessions: (days) => P.getGatewaySessions(projectId, days),
|
|
673
|
-
errors: (days) => P.getGatewayErrors(projectId, days),
|
|
674
|
-
budgets: () => P.getGatewayBudgets(projectId),
|
|
675
|
-
setBudget: (input) => P.setGatewayBudget(projectId, input),
|
|
676
|
-
deleteBudget: (budgetId) => P.deleteGatewayBudget(projectId, budgetId),
|
|
677
|
-
keys: () => P.getGatewayKeys(projectId),
|
|
678
|
-
createKey: (name) => P.createGatewayKey(projectId, name),
|
|
679
|
-
revokeKey: (keyId) => P.revokeGatewayKey(projectId, keyId),
|
|
680
|
-
routing: {
|
|
681
|
-
get: () => P.getGatewayRoutingPolicy(projectId),
|
|
682
|
-
set: (policy) => P.setGatewayRoutingPolicy(projectId, policy),
|
|
683
|
-
reset: () => P.resetGatewayRoutingPolicy(projectId),
|
|
684
|
-
preview: (input) => P.previewGatewayRoute(projectId, input),
|
|
685
|
-
},
|
|
686
|
-
/** Run one prompt against up to 6 models side by side (a model-comparison playground). */
|
|
687
|
-
playground: (prompt, models, system) => P.runGatewayPlayground(projectId, prompt, models, system),
|
|
688
|
-
},
|
|
689
|
-
/** Slack + email + Meet channel connections. */
|
|
690
|
-
channels: {
|
|
691
|
-
slack: {
|
|
692
|
-
installation: () => P.getSlackInstallation(projectId),
|
|
693
|
-
connect: (input) => P.connectSlack(projectId, input),
|
|
694
|
-
mode: () => P.getSlackMode(projectId),
|
|
695
|
-
/** Finish an "Add to Slack" install as the signed-in user (web completion page). */
|
|
696
|
-
completeInstall: (input) => P.completeSlackInstall(projectId, input),
|
|
697
|
-
manifest: () => P.getSlackManifest(projectId),
|
|
698
|
-
disconnect: () => P.disconnectSlack(projectId),
|
|
699
|
-
/** Download a Slack-hosted file through the server-side proxy (bot token stays server-side). */
|
|
700
|
-
getFile: (url) => P.getSlackChannelFile(projectId, url),
|
|
701
|
-
/** Upload a file to Slack through the server-side 3-step external-upload proxy. */
|
|
702
|
-
uploadFile: (input) => P.uploadSlackChannelFile(projectId, input),
|
|
703
|
-
},
|
|
704
|
-
teams: {
|
|
705
|
-
/** Finish a Microsoft Teams org install as the signed-in user (web completion page). */
|
|
706
|
-
completeInstall: (input) => P.completeTeamsInstall(projectId, input),
|
|
707
|
-
},
|
|
708
|
-
email: {
|
|
709
|
-
installation: (connectorSlug) => P.getEmailInstallation(projectId, connectorSlug),
|
|
710
|
-
mode: () => P.getEmailMode(projectId),
|
|
711
|
-
connect: (input) => P.connectEmail(projectId, input),
|
|
712
|
-
disconnect: (connectorSlug) => P.disconnectEmail(projectId, connectorSlug),
|
|
713
|
-
updatePolicy: (...a) => P.updateEmailPolicy(projectId, ...a),
|
|
714
|
-
},
|
|
715
|
-
},
|
|
716
|
-
/** Toggle a feature flag (Customize → Feature flags). Pass `enabled: null` to clear the override. */
|
|
717
|
-
updateFeatureFlag: (...a) => P.updateFeatureFlag(projectId, ...a),
|
|
718
|
-
/** @deprecated Renamed to `updateFeatureFlag`. Keeps the legacy `/experimental` wire path for older deployed APIs. */
|
|
719
|
-
updateExperimentalFeature: (...a) => P.updateExperimentalFeature(projectId, ...a),
|
|
720
|
-
/** Default model preferences (account/agent/project scope, gateway-resolved). */
|
|
721
|
-
modelDefaults: {
|
|
722
|
-
get: () => P.getModelDefaults(projectId),
|
|
723
|
-
set: (input) => P.setModelDefault(projectId, input),
|
|
724
|
-
clear: (params) => P.clearModelDefault(projectId, params),
|
|
725
|
-
},
|
|
726
|
-
/** Set the agent used when a new project session does not name one explicitly. */
|
|
727
|
-
setDefaultAgent: (agentName) => P.updateProjectDefaultAgent(projectId, agentName),
|
|
728
|
-
/** Sandbox templates + snapshot builds — Dockerfile/image/warm-pool config, beyond `sandboxHealth`/`sandboxTemplates`. */
|
|
729
|
-
sandbox: {
|
|
730
|
-
list: () => P.listProjectSandboxes(projectId),
|
|
731
|
-
snapshots: () => P.listProjectSnapshots(projectId),
|
|
732
|
-
rebuildSnapshot: (slug) => P.rebuildProjectSnapshot(projectId, slug),
|
|
733
|
-
fixWithAgent: () => P.fixSandboxWithAgent(projectId),
|
|
734
|
-
createTemplate: (input) => P.createSandboxTemplate(projectId, input),
|
|
735
|
-
updateTemplate: (...a) => P.updateSandboxTemplate(projectId, ...a),
|
|
736
|
-
removeTemplate: (templateId) => P.deleteSandboxTemplate(projectId, templateId),
|
|
737
|
-
buildTemplate: (templateId) => P.buildSandboxTemplate(projectId, templateId),
|
|
738
|
-
/** Pin/clear the per-project sandbox provider (null = follow the platform default). */
|
|
739
|
-
setProvider: (provider) => P.updateProjectSandboxProvider(projectId, provider),
|
|
740
|
-
},
|
|
741
|
-
/** Bind specific secrets + connectors to an agent (the inheritance pyramid's declaration step). */
|
|
742
|
-
setAgentScope: (...a) => P.setAgentScope(projectId, ...a),
|
|
743
|
-
session: (sessionId) => session(projectId, sessionId),
|
|
744
|
-
};
|
|
745
|
-
}
|
|
746
|
-
/** Id-bound handle for a single session: lifecycle (REST) + runtime (opencode). */
|
|
747
|
-
function session(projectId, sessionId) {
|
|
748
|
-
// Opinionated-action state, scoped to THIS handle. The opencode runtime is
|
|
749
|
-
// keyed by the OpenCode session id (resolved server-side at /start), NOT the
|
|
750
|
-
// Kortix `sessionId` — they differ. We resolve+cache it once (including the
|
|
751
|
-
// resolved runtime URL + sandbox id), and remember a chosen model so `send`
|
|
752
|
-
// carries it. Every runtime-scoped operation below reads ONLY this cached
|
|
753
|
-
// record — never the module-global "currently active" runtime — so two
|
|
754
|
-
// session handles pointed at two different sandboxes never cross wires.
|
|
755
|
-
let _ready = null;
|
|
756
|
-
let _model;
|
|
757
|
-
let _agent;
|
|
758
|
-
let _persistedPromptDefaults = null;
|
|
759
|
-
/**
|
|
760
|
-
* Resolve the server-owned prompt defaults once per handle.
|
|
761
|
-
*
|
|
762
|
-
* A stateful snapshot can contain an existing OpenCode session. OpenCode
|
|
763
|
-
* then reuses that session's last model unless every prompt specifies the
|
|
764
|
-
* current project-session model. Read the persisted Kortix session so the
|
|
765
|
-
* first SDK prompt cannot inherit stale snapshot configuration.
|
|
766
|
-
*/
|
|
767
|
-
async function persistedPromptDefaults() {
|
|
768
|
-
if (!_persistedPromptDefaults) {
|
|
769
|
-
_persistedPromptDefaults = P.getProjectSession(projectId, sessionId, {
|
|
770
|
-
showErrors: false,
|
|
771
|
-
}).then((projectSession) => {
|
|
772
|
-
const modelReference = typeof projectSession.metadata?.opencode_model === 'string'
|
|
773
|
-
? projectSession.metadata.opencode_model.trim()
|
|
774
|
-
: '';
|
|
775
|
-
const separator = modelReference.indexOf('/');
|
|
776
|
-
const model = separator > 0 && separator < modelReference.length - 1
|
|
777
|
-
? {
|
|
778
|
-
providerID: modelReference.slice(0, separator),
|
|
779
|
-
modelID: modelReference.slice(separator + 1),
|
|
780
|
-
}
|
|
781
|
-
: undefined;
|
|
782
|
-
const agent = projectSession.agent_name?.trim() || undefined;
|
|
783
|
-
return { model, agent };
|
|
784
|
-
});
|
|
785
|
-
}
|
|
786
|
-
try {
|
|
787
|
-
return await _persistedPromptDefaults;
|
|
788
|
-
}
|
|
789
|
-
catch (error) {
|
|
790
|
-
// A transient read must not poison every later send on this handle.
|
|
791
|
-
_persistedPromptDefaults = null;
|
|
792
|
-
throw error;
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
/**
|
|
796
|
-
* Adopt an already-resolved runtime for THIS (projectId, sessionId) from
|
|
797
|
-
* the shared session-runtime registry, if this handle hasn't resolved one
|
|
798
|
-
* itself yet. This is what lets a brand-new `kortix.session(pid, sid)`
|
|
799
|
-
* handle — e.g. a one-off poll tick, or a handle created independently of
|
|
800
|
-
* the one that actually drove `/start` — use a session another handle (or
|
|
801
|
-
* the React `useSession` hook) already brought up, instead of throwing
|
|
802
|
-
* `SessionNotReadyError` or re-provisioning.
|
|
803
|
-
*/
|
|
804
|
-
function tryResolveReady() {
|
|
805
|
-
if (_ready)
|
|
806
|
-
return _ready;
|
|
807
|
-
const cached = getSessionRuntime(projectId, sessionId);
|
|
808
|
-
if (cached)
|
|
809
|
-
_ready = cached;
|
|
810
|
-
return _ready;
|
|
811
|
-
}
|
|
812
|
-
/**
|
|
813
|
-
* Make this session's runtime reachable and return its OpenCode session id
|
|
814
|
-
* (plus this handle's own resolved runtime URL + sandbox id). Idempotent:
|
|
815
|
-
* adopts the registry entry if another handle already resolved this
|
|
816
|
-
* session; otherwise `start` provisions/resumes the sandbox (long-poll
|
|
817
|
-
* until ready) — which itself populates the registry on success — and we
|
|
818
|
-
* cache the resolved runtime for THIS handle. Also points the app's shared
|
|
819
|
-
* "current runtime" store there, for React hosts that still read it.
|
|
820
|
-
*/
|
|
821
|
-
async function ensureReady(opts) {
|
|
822
|
-
const cached = tryResolveReady();
|
|
823
|
-
if (cached)
|
|
824
|
-
return cached;
|
|
825
|
-
const readyTimeoutMs = opts?.readyTimeoutMs ?? 180_000;
|
|
826
|
-
// Learn how this deployment addresses previews while the sandbox boots.
|
|
827
|
-
// `previewUrl()` is synchronous (a React render calls it), so the answer
|
|
828
|
-
// has to be here before it can be asked for. Runs alongside the start
|
|
829
|
-
// poll and never gates it — a failure just leaves the path form.
|
|
830
|
-
const previewConfig = loadPreviewUrlTemplate(platformConfig().backendUrl ?? config.backendUrl).catch(() => null);
|
|
831
|
-
// Dedup concurrent starts for this (projectId, sessionId) — see
|
|
832
|
-
// `inFlightSessionStarts`'s doc comment. If another call (this handle or
|
|
833
|
-
// a different one) already kicked off `/start`, ride its result instead
|
|
834
|
-
// of issuing a second POST.
|
|
835
|
-
const key = `${projectId}\n${sessionId}`;
|
|
836
|
-
const inFlight = inFlightSessionStarts.get(key);
|
|
837
|
-
if (inFlight) {
|
|
838
|
-
_ready = await inFlight;
|
|
839
|
-
await previewConfig;
|
|
840
|
-
return _ready;
|
|
841
|
-
}
|
|
842
|
-
const startPromise = (async () => {
|
|
843
|
-
// Poll /start (each call long-polls up to 30s) until the runtime is
|
|
844
|
-
// ready. `/start` returns `retriable: true` while the sandbox is still
|
|
845
|
-
// provisioning/starting — a cold start can outlast a single long-poll —
|
|
846
|
-
// so keep polling until it's ready, hits a terminal stage, or the
|
|
847
|
-
// deadline. A single check would spuriously throw RUNTIME_UNAVAILABLE
|
|
848
|
-
// on a slow boot, which is exactly what a backend waiting to send the
|
|
849
|
-
// first turn must not do.
|
|
850
|
-
const deadline = Date.now() + readyTimeoutMs;
|
|
851
|
-
// Cap each server long-poll (and the inter-poll pause) to the time left
|
|
852
|
-
// so the total honors readyTimeoutMs — a fixed 30s wait would overshoot
|
|
853
|
-
// the deadline by up to ~30s on the final iteration.
|
|
854
|
-
const remainingMs = () => Math.max(0, deadline - Date.now());
|
|
855
|
-
let started = await P.startProjectSession(projectId, sessionId, Math.min(30_000, remainingMs()));
|
|
856
|
-
// Keep polling while the runtime is still coming up. A `null` result is
|
|
857
|
-
// a TRANSIENT tick, not a terminal state: startProjectSession returns
|
|
858
|
-
// null for a 5xx/408/429/network blip AND the create→start 404 race
|
|
859
|
-
// (row not yet visible on the read path) — the exact cases a backend
|
|
860
|
-
// hits calling ensureReady() right after create(). Only a resolved
|
|
861
|
-
// provisioning/starting+retriable result or the deadline keeps/ends the
|
|
862
|
-
// loop; ready/failed/stopped fall through to the guard below.
|
|
863
|
-
while (Date.now() < deadline &&
|
|
864
|
-
(started == null ||
|
|
865
|
-
((started.stage === 'provisioning' || started.stage === 'starting') &&
|
|
866
|
-
started.retriable))) {
|
|
867
|
-
await new Promise((r) => setTimeout(r, Math.min(1_000, remainingMs())));
|
|
868
|
-
started = await P.startProjectSession(projectId, sessionId, Math.min(30_000, remainingMs()));
|
|
869
|
-
}
|
|
870
|
-
const runtimeSessionId = started?.runtime_session_id ?? started?.opencode_session_id;
|
|
871
|
-
if (!started ||
|
|
872
|
-
started.stage !== 'ready' ||
|
|
873
|
-
!started.sandbox ||
|
|
874
|
-
!runtimeSessionId) {
|
|
875
|
-
throw new ApiError(runtimeNotReadyMessage(started), {
|
|
876
|
-
code: 'RUNTIME_UNAVAILABLE',
|
|
877
|
-
});
|
|
878
|
-
}
|
|
879
|
-
const externalId = started.sandbox.external_id;
|
|
880
|
-
if (!externalId) {
|
|
881
|
-
throw new ApiError('Session sandbox has no external_id — cannot resolve its runtime URL', {
|
|
882
|
-
code: 'RUNTIME_UNAVAILABLE',
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
const runtimeUrl = getSandboxUrlForExternalId(externalId);
|
|
886
|
-
// Point the app's shared runtime store at this session too, so React
|
|
887
|
-
// hosts (which read the global current-runtime) keep working — but this
|
|
888
|
-
// handle's own operations never read it back, only `_ready` below.
|
|
889
|
-
setCurrentRuntime(runtimeUrl, externalId);
|
|
890
|
-
return {
|
|
891
|
-
runtimeSessionId,
|
|
892
|
-
opencodeSessionId: runtimeSessionId,
|
|
893
|
-
runtimeUrl,
|
|
894
|
-
sandboxId: externalId,
|
|
895
|
-
};
|
|
896
|
-
})();
|
|
897
|
-
inFlightSessionStarts.set(key, startPromise);
|
|
898
|
-
try {
|
|
899
|
-
_ready = await startPromise;
|
|
900
|
-
// Resolved concurrently with the boot above, so this is already
|
|
901
|
-
// settled — awaited here only so `previewUrl()` can never be reached
|
|
902
|
-
// before the deployment's preview addressing is known.
|
|
903
|
-
await previewConfig;
|
|
904
|
-
return _ready;
|
|
905
|
-
}
|
|
906
|
-
finally {
|
|
907
|
-
if (inFlightSessionStarts.get(key) === startPromise) {
|
|
908
|
-
inFlightSessionStarts.delete(key);
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
/** Throw `SessionNotReadyError` if neither this handle nor the registry has resolved a runtime yet. */
|
|
913
|
-
function requireReady(action) {
|
|
914
|
-
const ready = tryResolveReady();
|
|
915
|
-
if (!ready)
|
|
916
|
-
throw new SessionNotReadyError(action);
|
|
917
|
-
return ready;
|
|
918
|
-
}
|
|
919
|
-
/** Clear this handle's cached runtime + the shared registry entry (restart/delete). */
|
|
920
|
-
function forgetReady() {
|
|
921
|
-
_ready = null;
|
|
922
|
-
clearSessionRuntime(projectId, sessionId);
|
|
923
|
-
}
|
|
54
|
+
const connections = projectConnections(projectId);
|
|
924
55
|
return {
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
// A deleted session's sandbox is gone — never let a later handle for
|
|
933
|
-
// this (projectId, sessionId) resolve a runtime that no longer exists.
|
|
934
|
-
forgetReady();
|
|
935
|
-
return P.deleteProjectSession(projectId, sessionId);
|
|
936
|
-
},
|
|
937
|
-
start: (...a) => P.startProjectSession(projectId, sessionId, ...a),
|
|
938
|
-
restart: () => {
|
|
939
|
-
// Restart preserves the established sandbox identity, but readiness
|
|
940
|
-
// and the proxy connection must still be resolved again after reboot.
|
|
941
|
-
forgetReady();
|
|
942
|
-
return P.restartProjectSession(projectId, sessionId);
|
|
943
|
-
},
|
|
944
|
-
stop: () => {
|
|
945
|
-
forgetReady();
|
|
946
|
-
return P.stopProjectSession(projectId, sessionId);
|
|
947
|
-
},
|
|
948
|
-
/** Is this session still running the config the manifest compiles to? */
|
|
949
|
-
configState: () => P.getProjectSessionConfigState(projectId, sessionId),
|
|
950
|
-
/**
|
|
951
|
-
* Recompile the agent config from git into this running session.
|
|
952
|
-
*
|
|
953
|
-
* Restarts opencode to rebuild its config, so readiness has to be
|
|
954
|
-
* resolved again — same reason `restart` forgets it.
|
|
955
|
-
*/
|
|
956
|
-
reloadConfig: (input) => {
|
|
957
|
-
forgetReady();
|
|
958
|
-
return P.reloadProjectSessionConfig(projectId, sessionId, input);
|
|
959
|
-
},
|
|
960
|
-
/** Reload config with server-observed progress events. */
|
|
961
|
-
reloadConfigStream: (...args) => {
|
|
962
|
-
forgetReady();
|
|
963
|
-
return P.reloadProjectSessionConfigStream(projectId, sessionId, ...args);
|
|
964
|
-
},
|
|
965
|
-
setSharing: (intent) => P.setProjectSessionSharing(projectId, sessionId, intent),
|
|
966
|
-
previews: () => P.getSessionPreviewCandidates(projectId, sessionId),
|
|
967
|
-
commit: (input) => P.commitSessionChanges(projectId, sessionId, input),
|
|
968
|
-
publicShares: {
|
|
969
|
-
list: () => P.listSessionPublicShares(projectId, sessionId),
|
|
970
|
-
create: (...a) => P.createSessionPublicShare(projectId, sessionId, ...a),
|
|
971
|
-
revoke: (...a) => P.revokeSessionPublicShare(projectId, sessionId, ...a),
|
|
972
|
-
},
|
|
973
|
-
/** Scheduled prompts into this session — see `CreateSessionReminderInput`. */
|
|
974
|
-
reminders: {
|
|
975
|
-
list: () => P.listSessionReminders(projectId, sessionId),
|
|
976
|
-
create: (input) => P.createSessionReminder(projectId, sessionId, input),
|
|
977
|
-
update: (reminderId, input) => P.updateSessionReminder(projectId, sessionId, reminderId, input),
|
|
978
|
-
remove: (reminderId) => P.deleteSessionReminder(projectId, sessionId, reminderId),
|
|
979
|
-
},
|
|
980
|
-
/** Per-session audit trail of connector-gated agent actions. */
|
|
981
|
-
audit: (limit, options) => P.getSessionAudit(projectId, sessionId, limit, options),
|
|
982
|
-
attachments: {
|
|
983
|
-
upload: (file, options) => P.uploadSessionAttachment(projectId, sessionId, file, options),
|
|
984
|
-
read: (attachmentId, signal) => P.fetchSessionAttachment(`kortix-attachment://${projectId}/${sessionId}/${attachmentId}`, signal),
|
|
985
|
-
},
|
|
986
|
-
/** Compact server-side transcript read (text + tool calls, no tool inputs/outputs) — callable with project-scoped session tokens. */
|
|
987
|
-
transcript: (options) => P.getSessionTranscript(projectId, sessionId, options),
|
|
988
|
-
/** Who wrote each message: a member, or another session's agent. */
|
|
989
|
-
messageAuthors: () => P.getSessionMessageAuthors(projectId, sessionId),
|
|
990
|
-
/** The DURABLE server-side transcript mirror, in sync-store shape
|
|
991
|
-
* (OpenCode message envelopes verbatim, attachment bytes and tool
|
|
992
|
-
* inputs/outputs stripped). This is the read that answers while the
|
|
993
|
-
* sandbox is stopped or still waking. */
|
|
994
|
-
transcriptSync: (options) => P.getSessionTranscriptSync(projectId, sessionId, options),
|
|
995
|
-
/** Which turns are running right now, and how did the last one end?
|
|
996
|
-
* Server truth from the control plane's lifecycle authority, independent
|
|
997
|
-
* of the live stream. */
|
|
998
|
-
turn: () => P.getSessionTurn(projectId, sessionId),
|
|
999
|
-
/** This session's SERVER-SIDE prompt inbox: the prompts it still owes the
|
|
1000
|
-
* user. Durable, so it survives a closed tab and is the same list on
|
|
1001
|
-
* every device. */
|
|
1002
|
-
prompts: {
|
|
1003
|
-
create: (input) => P.createSessionPrompt(projectId, sessionId, input),
|
|
1004
|
-
list: () => P.listSessionPrompts(projectId, sessionId),
|
|
1005
|
-
remove: (promptId) => P.deleteSessionPrompt(projectId, sessionId, promptId),
|
|
1006
|
-
retry: (promptId) => P.retrySessionPrompt(projectId, sessionId, promptId),
|
|
1007
|
-
/** Hold (or release) the whole queue — what the Stop button writes. */
|
|
1008
|
-
hold: (held) => P.holdSessionPrompts(projectId, sessionId, held),
|
|
1009
|
-
},
|
|
1010
|
-
/**
|
|
1011
|
-
* Resolve THIS handle's own runtime (idempotent): provisions/resumes the
|
|
1012
|
-
* sandbox (long-poll until ready) and caches the resolved OpenCode session
|
|
1013
|
-
* id + runtime URL + sandbox id for every other call on this handle. Call
|
|
1014
|
-
* this (or `send`/`abort`, which call it internally) before `.runtime`,
|
|
1015
|
-
* `.health()`, `.previewUrl()`, or `.proxyUrl()` — those throw
|
|
1016
|
-
* `SessionNotReadyError` instead of falling back to whatever sandbox
|
|
1017
|
-
* happens to be globally active.
|
|
1018
|
-
*/
|
|
1019
|
-
ensureReady,
|
|
1020
|
-
// ── runtime health + preview (the session owns its runtime) ──────────
|
|
1021
|
-
/**
|
|
1022
|
-
* Liveness/readiness of THIS session's runtime (`GET /kortix/health`).
|
|
1023
|
-
* Unlike `.previewUrl()`/`.proxyUrl()`/`.runtime`, this never throws
|
|
1024
|
-
* `SessionNotReadyError` — a health poller (e.g. a header dot ticking
|
|
1025
|
-
* every 15s on a fresh inline handle) needs to be callable BEFORE the
|
|
1026
|
-
* session has ever resolved a runtime. It degrades to the same graceful
|
|
1027
|
-
* `{ status: 0, ok: false }` shape `getSessionHealth` already returns for
|
|
1028
|
-
* "no URL yet", instead of forcing every caller to guard with `ensureReady()`.
|
|
1029
|
-
*/
|
|
1030
|
-
health: (init) => getSessionHealth(tryResolveReady()?.runtimeUrl ?? null, init),
|
|
1031
|
-
/** Proxy/preview URL for a port THIS session's runtime exposes. */
|
|
1032
|
-
previewUrl: (port, path = '/') => rewriteLocalhostUrl(port, path, resolvePreviewOptsForSandbox(requireReady('previewUrl').sandboxId)),
|
|
1033
|
-
/** Rewrite a localhost URL the agent printed into a reachable proxy URL. */
|
|
1034
|
-
proxyUrl: (url) => proxyLocalhostUrl(url, resolvePreviewOptsForSandbox(requireReady('proxyUrl').sandboxId)),
|
|
1035
|
-
/**
|
|
1036
|
-
* The AUTHENTICATED backend proxy URL for a given sandbox port of THIS
|
|
1037
|
-
* session's runtime: `${backendUrl}/p/{externalId}/{port}` — no browser
|
|
1038
|
-
* preview-origin rewriting. This is the URL a local port-forward proxy
|
|
1039
|
-
* dials with the caller's own bearer token (see `getSandboxUrlForExternalId`).
|
|
1040
|
-
* Use `previewUrl()`/`proxyUrl()` instead for a browser tab.
|
|
1041
|
-
*/
|
|
1042
|
-
sandboxPortUrl: (port) => getSandboxUrlForExternalId(requireReady('sandboxPortUrl').sandboxId, port),
|
|
1043
|
-
// ── agent actions (opinionated wrappers over the runtime) ────────────
|
|
1044
|
-
// These do the right thing end-to-end for scripts/non-React hosts: ensure
|
|
1045
|
-
// the runtime is up, resolve the OpenCode session id, and act through a
|
|
1046
|
-
// client bound to THIS handle's own runtime URL (never the module-global
|
|
1047
|
-
// "active" one, so parallel handles on different sandboxes never cross
|
|
1048
|
-
// wires). React hosts use `@kortix/sdk/react` hooks instead, which bind to
|
|
1049
|
-
// the same resolved id reactively (see the white-label reference app).
|
|
1050
|
-
/** Pick the model `send` will use for subsequent prompts (until changed). */
|
|
1051
|
-
setModel: (model) => {
|
|
1052
|
-
_model = model;
|
|
1053
|
-
},
|
|
1054
|
-
/**
|
|
1055
|
-
* PERSIST a new model for this session server-side, re-pointing the
|
|
1056
|
-
* running sandbox. Distinct from `setModel`, which only chooses what the
|
|
1057
|
-
* NEXT local `send` asks for and never leaves this handle.
|
|
1058
|
-
*
|
|
1059
|
-
* Restarting the runtime is how the change takes effect, so an in-flight
|
|
1060
|
-
* turn ends. `applied_live` reports whether a running session took it now
|
|
1061
|
-
* or whether it applies at next start.
|
|
1062
|
-
*/
|
|
1063
|
-
changeModel: async (model) => {
|
|
1064
|
-
const result = await P.setProjectSessionModel(projectId, sessionId, model);
|
|
1065
|
-
_persistedPromptDefaults = null;
|
|
1066
|
-
return result;
|
|
1067
|
-
},
|
|
1068
|
-
/** Read the authoritative secret allowlist and connections. */
|
|
1069
|
-
scope: () => P.getProjectSessionScope(projectId, sessionId),
|
|
1070
|
-
providerSecretPool: {
|
|
1071
|
-
list: () => P.listSessionProviderSecretPools(projectId, sessionId),
|
|
1072
|
-
get: (providerId) => P.getSessionProviderSecretPool(projectId, sessionId, providerId),
|
|
1073
|
-
set: (providerId, secretIds) => P.setSessionProviderSecretPool(projectId, sessionId, providerId, secretIds),
|
|
1074
|
-
},
|
|
1075
|
-
/** Re-scope a running session — set semantics; see setProjectSessionScope. */
|
|
1076
|
-
rescope: (scope) => P.setProjectSessionScope(projectId, sessionId, scope),
|
|
1077
|
-
/** Pick the agent `send` will use for subsequent prompts (until changed). */
|
|
1078
|
-
setAgent: (agent) => {
|
|
1079
|
-
_agent = agent;
|
|
1080
|
-
},
|
|
1081
|
-
/**
|
|
1082
|
-
* Provision/resume if needed, then send a text prompt to the agent. A
|
|
1083
|
-
* per-call `{ model, agent }` overrides the sticky setModel/setAgent
|
|
1084
|
-
* choices for this message only.
|
|
1085
|
-
*/
|
|
1086
|
-
send: async (text, opts) => {
|
|
1087
|
-
const { runtimeSessionId, runtimeUrl } = await ensureReady();
|
|
1088
|
-
const selectedModel = opts?.model ?? _model;
|
|
1089
|
-
const selectedAgent = opts?.agent ?? _agent;
|
|
1090
|
-
const persisted = selectedModel && selectedAgent ? {} : await persistedPromptDefaults();
|
|
1091
|
-
const model = selectedModel ?? persisted.model;
|
|
1092
|
-
const agent = selectedAgent ?? persisted.agent;
|
|
1093
|
-
return getClientForUrl(runtimeUrl).session.prompt({
|
|
1094
|
-
sessionID: runtimeSessionId,
|
|
1095
|
-
parts: [{ type: 'text', text }],
|
|
1096
|
-
...(model ? { model } : {}),
|
|
1097
|
-
...(agent ? { agent } : {}),
|
|
1098
|
-
});
|
|
1099
|
-
},
|
|
1100
|
-
/** Abort the agent's current run in this session. */
|
|
1101
|
-
abort: async () => {
|
|
1102
|
-
const { runtimeSessionId, runtimeUrl } = await ensureReady();
|
|
1103
|
-
return getClientForUrl(runtimeUrl).session.abort({
|
|
1104
|
-
sessionID: runtimeSessionId,
|
|
1105
|
-
});
|
|
1106
|
-
},
|
|
1107
|
-
/**
|
|
1108
|
-
* Stage a reversible rollback at one user message on this same canonical
|
|
1109
|
-
* OpenCode session. The next prompt commits the new path.
|
|
1110
|
-
*/
|
|
1111
|
-
rewind: async (messageId) => {
|
|
1112
|
-
const { runtimeSessionId, runtimeUrl } = await ensureReady();
|
|
1113
|
-
return getClientForUrl(runtimeUrl).session.revert({
|
|
1114
|
-
sessionID: runtimeSessionId,
|
|
1115
|
-
messageID: messageId,
|
|
1116
|
-
});
|
|
1117
|
-
},
|
|
1118
|
-
/** Restore the path removed by `rewind()` before another prompt commits it. */
|
|
1119
|
-
restoreRewind: async () => {
|
|
1120
|
-
const { runtimeSessionId, runtimeUrl } = await ensureReady();
|
|
1121
|
-
return getClientForUrl(runtimeUrl).session.unrevert({
|
|
1122
|
-
sessionID: runtimeSessionId,
|
|
1123
|
-
});
|
|
1124
|
-
},
|
|
1125
|
-
/**
|
|
1126
|
-
* Live SSE stream of THIS session's runtime events (message/part
|
|
1127
|
-
* updates, session status, permissions/questions, lsp diagnostics, …).
|
|
1128
|
-
* A thin facade over the framework-free `openEventStream` primitive
|
|
1129
|
-
* (`@kortix/sdk`'s `openEventStream`, also used verbatim by
|
|
1130
|
-
* `@kortix/sdk/react`'s `useRuntimeEventStream`): resolves THIS
|
|
1131
|
-
* handle's own runtime first (`ensureReady()`), then connects a client
|
|
1132
|
-
* bound to that runtime URL — never the module-global "active" one, so
|
|
1133
|
-
* two session handles on two different sandboxes never cross wires.
|
|
1134
|
-
* Framework-free — safe to call from a server-side "Kortix as a
|
|
1135
|
-
* Backend" wrapper (Node/Bun), a worker, a CLI, or any non-React host.
|
|
1136
|
-
*
|
|
1137
|
-
* Handles connect/reconnect/backoff, a 15s heartbeat watchdog, and
|
|
1138
|
-
* event coalescing internally. Call `handle.close()` to stop.
|
|
1139
|
-
*
|
|
1140
|
-
* const handle = await session.stream({ onEvent: (e) => console.log(e) });
|
|
1141
|
-
* // later
|
|
1142
|
-
* handle.close();
|
|
1143
|
-
*/
|
|
1144
|
-
stream: async (opts) => {
|
|
1145
|
-
const { runtimeUrl } = await ensureReady();
|
|
1146
|
-
return openEventStream({
|
|
1147
|
-
client: getClientForUrl(runtimeUrl),
|
|
1148
|
-
onEvent: opts.onEvent,
|
|
1149
|
-
onGapRehydrate: opts.onGapRehydrate,
|
|
1150
|
-
signal: opts.signal,
|
|
1151
|
-
});
|
|
1152
|
-
},
|
|
1153
|
-
// ── runtime (opencode v2, THIS session's own sandbox) ────────────────
|
|
1154
|
-
// The typed opencode client, reached ONLY through the SDK. The host never
|
|
1155
|
-
// imports `@opencode-ai/sdk`. Opinionated wrappers (prompt/abort/setModel
|
|
1156
|
-
// with server-owned side-effects) layer on top of this as they land.
|
|
1157
|
-
get runtime() {
|
|
1158
|
-
return getClientForUrl(requireReady('runtime').runtimeUrl);
|
|
1159
|
-
},
|
|
1160
|
-
/**
|
|
1161
|
-
* Workspace file operations (daemon `/file` + `/find`) bound to THIS
|
|
1162
|
-
* session's own resolved runtime — never the module-global "active"
|
|
1163
|
-
* sandbox the top-level `@kortix/sdk` `files` export follows. Fixes a
|
|
1164
|
-
* cross-session bleed: a host juggling multiple open sessions (e.g. a
|
|
1165
|
-
* server wrapping several concurrent agent sessions) that called the
|
|
1166
|
-
* global `files.list()` while a DIFFERENT session was "active" would
|
|
1167
|
-
* silently read/write the wrong sandbox. Each call here auto-provisions
|
|
1168
|
-
* via `ensureReady()` (same as `send`/`abort`/`stream`), then runs
|
|
1169
|
-
* against this handle's own runtime URL. Same 12-op surface as the
|
|
1170
|
-
* global `files` namespace, built from the same parameterized core
|
|
1171
|
-
* (`@kortix/sdk/files`'s exports all take an optional trailing
|
|
1172
|
-
* `baseUrl` — this just always supplies THIS session's).
|
|
1173
|
-
*/
|
|
1174
|
-
files: {
|
|
1175
|
-
list: async (dirPath) => F.listFiles(dirPath, (await ensureReady()).runtimeUrl),
|
|
1176
|
-
read: async (filePath) => F.readFile(filePath, (await ensureReady()).runtimeUrl),
|
|
1177
|
-
readBlob: async (filePath) => F.readBlob(filePath, (await ensureReady()).runtimeUrl),
|
|
1178
|
-
status: async () => F.getFileStatus((await ensureReady()).runtimeUrl),
|
|
1179
|
-
findFiles: async (query, options) => F.findFiles(query, options, (await ensureReady()).runtimeUrl),
|
|
1180
|
-
findText: async (pattern) => F.findText(pattern, (await ensureReady()).runtimeUrl),
|
|
1181
|
-
upload: async (file, targetPath, filename, options) => F.uploadFile(file, targetPath, filename, (await ensureReady()).runtimeUrl, options),
|
|
1182
|
-
/**
|
|
1183
|
-
* Overwrite `filePath` in place. The daemon's upload endpoint never
|
|
1184
|
-
* overwrites (it uniquifies a colliding name), so a plain `upload` over
|
|
1185
|
-
* an existing path silently writes a DIFFERENT file — see `writeFile`.
|
|
1186
|
-
*/
|
|
1187
|
-
write: async (filePath, content) => F.writeFile(filePath, content, (await ensureReady()).runtimeUrl),
|
|
1188
|
-
create: async (filePath) => F.createFile(filePath, (await ensureReady()).runtimeUrl),
|
|
1189
|
-
copy: async (sourcePath, destPath) => F.copyFile(sourcePath, destPath, (await ensureReady()).runtimeUrl),
|
|
1190
|
-
remove: async (filePath) => F.deleteFile(filePath, (await ensureReady()).runtimeUrl),
|
|
1191
|
-
mkdir: async (dirPath) => F.mkdir(dirPath, (await ensureReady()).runtimeUrl),
|
|
1192
|
-
rename: async (from, to) => F.renameFile(from, to, (await ensureReady()).runtimeUrl),
|
|
1193
|
-
},
|
|
56
|
+
...bindProjectCore(projectId),
|
|
57
|
+
...bindProjectAccessResources(projectId),
|
|
58
|
+
...bindProjectAccessSecurity(projectId),
|
|
59
|
+
...bindProjectOperations(projectId, connections),
|
|
60
|
+
...bindProjectPlatformResources(projectId),
|
|
61
|
+
...bindProjectPlatformSecurity(projectId),
|
|
62
|
+
session: (sessionId) => session(projectId, sessionId, config, resolvePreviewOptsForSandbox),
|
|
1194
63
|
};
|
|
1195
64
|
}
|
|
1196
65
|
return {
|
|
@@ -1207,7 +76,7 @@ export function createKortix(config, opts) {
|
|
|
1207
76
|
/** Connector calls scoped by an agent/session token when no project id is available. */
|
|
1208
77
|
connectors: connectorDataPlane(),
|
|
1209
78
|
project,
|
|
1210
|
-
session,
|
|
79
|
+
session: (projectId, sessionId) => session(projectId, sessionId, config, resolvePreviewOptsForSandbox),
|
|
1211
80
|
/** GitHub App installation + repository linking (account-scoped). */
|
|
1212
81
|
github,
|
|
1213
82
|
/** The instance git backend ("Kortix managed", deployment-scoped). */
|