@kortix/sdk 0.13.47 → 0.13.49
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 +49 -31
- 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/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.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 +7 -5
- 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 +658 -1038
- package/dist/core/client/kortix.d.ts.map +1 -1
- package/dist/core/client/kortix.js +29 -1205
- 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 +73 -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/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/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.d.ts +4 -0
- package/dist/core/rest/projects-client/audit.d.ts.map +1 -1
- package/dist/core/rest/projects-client/audit.js.map +1 -1
- package/dist/core/rest/projects-client/billing.d.ts +4 -0
- package/dist/core/rest/projects-client/billing.d.ts.map +1 -1
- package/dist/core/rest/projects-client/billing.js.map +1 -1
- package/dist/core/rest/projects-client/channels.d.ts +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/projects.d.ts +15 -1
- 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 +44 -0
- 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 +46 -25
- package/dist/core/rest/projects-client/sessions.d.ts.map +1 -1
- package/dist/core/rest/projects-client/sessions.js +34 -6
- package/dist/core/rest/projects-client/sessions.js.map +1 -1
- package/dist/core/runtime/client.d.ts +1 -1
- package/dist/core/runtime/client.d.ts.map +1 -1
- package/dist/core/runtime/client.js +29 -3
- package/dist/core/runtime/client.js.map +1 -1
- package/dist/core/runtime/runtime-rest-client.d.ts +26 -0
- package/dist/core/runtime/runtime-rest-client.d.ts.map +1 -1
- package/dist/core/runtime/runtime-rest-client.js +67 -49
- package/dist/core/runtime/runtime-rest-client.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 +1 -0
- package/dist/core/session/index.d.ts.map +1 -1
- package/dist/core/session/index.js +1 -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/wake-escalation.d.ts +1 -1
- package/dist/core/session/wake-escalation.js +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/stream/event-stream.d.ts +15 -1
- package/dist/core/stream/event-stream.d.ts.map +1 -1
- package/dist/core/stream/event-stream.js +59 -9
- package/dist/core/stream/event-stream.js.map +1 -1
- package/dist/core/turns/parts.d.ts +4 -0
- package/dist/core/turns/parts.d.ts.map +1 -1
- package/dist/core/turns/parts.js +4 -0
- package/dist/core/turns/parts.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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kortix.esm.min.js +44 -44
- package/dist/kortix.global.js +44 -44
- package/dist/react/index.d.ts +3 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +2 -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/use-admin-accounts.d.ts +7 -4
- package/dist/react/use-admin-accounts.d.ts.map +1 -1
- package/dist/react/use-admin-accounts.js +7 -4
- package/dist/react/use-admin-accounts.js.map +1 -1
- 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-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 +15 -0
- 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-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 +11 -0
- 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/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 +5 -0
- 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-project-apps.d.ts +6 -0
- package/dist/react/use-project-apps.d.ts.map +1 -1
- 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.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.d.ts +3 -1
- package/dist/react/use-session.d.ts.map +1 -1
- package/dist/react/use-session.js +8 -6
- package/dist/react/use-session.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/workspace-search/core.d.ts +2 -2
- package/dist/workspace-search/core.d.ts.map +1 -1
- package/dist/workspace-search/core.js +35 -2
- package/dist/workspace-search/core.js.map +1 -1
- package/package.json +2 -2
|
@@ -101,6 +101,7 @@ export function openSessionBundle(projectId, sessionId, options = {}) {
|
|
|
101
101
|
};
|
|
102
102
|
entry.promise = entry.promise.then((bundle) => {
|
|
103
103
|
entry.settledAtMs = now();
|
|
104
|
+
entry.bundle = bundle;
|
|
104
105
|
return bundle;
|
|
105
106
|
});
|
|
106
107
|
entries.set(key, entry);
|
|
@@ -132,6 +133,15 @@ export function claimOpenBundle(projectId, sessionId, nowMs = Date.now()) {
|
|
|
132
133
|
}
|
|
133
134
|
return entry.promise;
|
|
134
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* The bundle this session's open has ALREADY received, inside the share window.
|
|
138
|
+
* `null` while it is in flight: for a reader that must not wait for the
|
|
139
|
+
* snapshot. It asks its own route instead.
|
|
140
|
+
*/
|
|
141
|
+
export function settledOpenBundle(projectId, sessionId, nowMs = Date.now()) {
|
|
142
|
+
const entry = entries.get(scopeKey(projectId, sessionId));
|
|
143
|
+
return entry && entry.settledAtMs !== null && claimable(entry, nowMs) ? (entry.bundle ?? null) : null;
|
|
144
|
+
}
|
|
135
145
|
/**
|
|
136
146
|
* Project the turn leg. `null` for an unknown leg — never `{ turns: [] }`,
|
|
137
147
|
* which would be an idle claim made by something that did not know.
|
|
@@ -173,6 +183,27 @@ export function openBundleAudit(bundle) {
|
|
|
173
183
|
actions: audit.actions,
|
|
174
184
|
};
|
|
175
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Project the transcript leg onto what the saved-history read
|
|
188
|
+
* (`GET .../transcript?shape=sync&history=true`) answers: the same window, served
|
|
189
|
+
* only for the session's CURRENT root. `null` when the leg is unknown or
|
|
190
|
+
* pointer-only, and when a saved copy's root is not the root the session row
|
|
191
|
+
* names. The route decides those.
|
|
192
|
+
*
|
|
193
|
+
* Reads the leg, never the one-shot stash: the stash is the mirror paint's.
|
|
194
|
+
*/
|
|
195
|
+
export function openBundleHistory(bundle) {
|
|
196
|
+
const transcript = bundle.transcript;
|
|
197
|
+
if (!transcript || transcript.known !== true || transcript.requested !== true)
|
|
198
|
+
return null;
|
|
199
|
+
const { known: _known, requested: _requested, ...envelope } = transcript;
|
|
200
|
+
// "No saved copy" is the same answer with or without the root check.
|
|
201
|
+
if (!envelope.available)
|
|
202
|
+
return envelope;
|
|
203
|
+
const root = bundle.session?.runtime_session_id ?? bundle.session?.opencode_session_id;
|
|
204
|
+
const savedRoot = envelope.runtime_session_id ?? envelope.opencode_session_id;
|
|
205
|
+
return root && savedRoot === root ? envelope : null;
|
|
206
|
+
}
|
|
176
207
|
function stashTranscript(key, bundle, nowMs) {
|
|
177
208
|
const transcript = bundle.transcript;
|
|
178
209
|
if (!transcript || transcript.known !== true || transcript.requested !== true)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-bundle.js","sourceRoot":"","sources":["../../../src/core/session/open-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAQL,oBAAoB,GACrB,MAAM,kCAAkC,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAE1C;;kEAEkE;AAClE,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC;AAEpD;0CAC0C;AAC1C,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"open-bundle.js","sourceRoot":"","sources":["../../../src/core/session/open-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAQL,oBAAoB,GACrB,MAAM,kCAAkC,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,CAAC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AC,CAAC;IACnC,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACxB,IAAI,KAAK,GAAG,KAAK,CAAC,WAAW,GAAG,6BAA6B;QAAE,OAAO,IAAI,CAAC;IAC3E,OAAO,KAAK,CAAC,QAAQ,CAAC;AACxB,CAAC"}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* "Couldn't start session <id> — The session runtime did not become
|
|
15
15
|
* reachable. Restart the session to try again."
|
|
16
16
|
*
|
|
17
|
-
* Measured on SampleCo (2026-08-26, box
|
|
17
|
+
* Measured on SampleCo (2026-08-26, one E2B box): that card
|
|
18
18
|
* painted while the box was SECONDS from ready — its daemon logged
|
|
19
19
|
* `opencode ready` at 06:10:02, right after the budget expired. The card is a
|
|
20
20
|
* dead end with no auto-recovery, and the human's fix is always the same one
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* "Couldn't start session <id> — The session runtime did not become
|
|
15
15
|
* reachable. Restart the session to try again."
|
|
16
16
|
*
|
|
17
|
-
* Measured on SampleCo (2026-08-26, box
|
|
17
|
+
* Measured on SampleCo (2026-08-26, one E2B box): that card
|
|
18
18
|
* painted while the box was SECONDS from ready — its daemon logged
|
|
19
19
|
* `opencode ready` at 06:10:02, right after the budget expired. The card is a
|
|
20
20
|
* dead end with no auto-recovery, and the human's fix is always the same one
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type WorkingInputs } from './working.js';
|
|
2
|
+
/** Freshness and local-action floors: a read issued before acknowledgement cannot answer for that action. */
|
|
3
|
+
export declare function workingEvidence({ optimistic, abort, inbox, server, stream, activity, nowMs, }: WorkingInputs): {
|
|
4
|
+
receiptLive: boolean;
|
|
5
|
+
receiptTurnId: string | null;
|
|
6
|
+
serverFloor: number;
|
|
7
|
+
streamFloor: number;
|
|
8
|
+
abortLive: boolean;
|
|
9
|
+
abortFloor: number;
|
|
10
|
+
serverFresh: boolean;
|
|
11
|
+
streamFresh: boolean;
|
|
12
|
+
inboxFresh: boolean;
|
|
13
|
+
activityFresh: boolean;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=working-evidence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"working-evidence.d.ts","sourceRoot":"","sources":["../../../src/core/session/working-evidence.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AAEnB,6GAA6G;AAC7G,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,KAAK,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN,QAAQ,EACR,KAAK,GACN,EAAE,aAAa;;;;;;;;;;;EAuBf"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { INBOX_OBSERVATION_MAX_MS, OPTIMISTIC_ABORT_MAX_MS, OPTIMISTIC_RECEIPT_MAX_MS, SERVER_OBSERVATION_MAX_MS, STREAM_OBSERVATION_MAX_MS, } from './working.js';
|
|
2
|
+
/** Freshness and local-action floors: a read issued before acknowledgement cannot answer for that action. */
|
|
3
|
+
export function workingEvidence({ optimistic, abort, inbox, server, stream, activity, nowMs, }) {
|
|
4
|
+
const receiptLive = !!optimistic && nowMs - optimistic.atMs < OPTIMISTIC_RECEIPT_MAX_MS;
|
|
5
|
+
const abortLive = !!abort && nowMs - abort.atMs < OPTIMISTIC_ABORT_MAX_MS;
|
|
6
|
+
return {
|
|
7
|
+
receiptLive,
|
|
8
|
+
receiptTurnId: optimistic
|
|
9
|
+
? optimistic.turnId === undefined
|
|
10
|
+
? optimistic.messageId
|
|
11
|
+
: optimistic.turnId
|
|
12
|
+
: null,
|
|
13
|
+
serverFloor: receiptLive
|
|
14
|
+
? (optimistic?.acceptedAtMs ?? Number.POSITIVE_INFINITY)
|
|
15
|
+
: Number.NEGATIVE_INFINITY,
|
|
16
|
+
streamFloor: receiptLive ? optimistic?.atMs : Number.NEGATIVE_INFINITY,
|
|
17
|
+
abortLive,
|
|
18
|
+
abortFloor: abortLive
|
|
19
|
+
? (abort?.settledAtMs ?? Number.POSITIVE_INFINITY)
|
|
20
|
+
: Number.NEGATIVE_INFINITY,
|
|
21
|
+
serverFresh: !!server && nowMs - server.atMs <= SERVER_OBSERVATION_MAX_MS,
|
|
22
|
+
streamFresh: !!stream && nowMs - stream.atMs <= STREAM_OBSERVATION_MAX_MS,
|
|
23
|
+
inboxFresh: !!inbox && nowMs - inbox.atMs <= INBOX_OBSERVATION_MAX_MS,
|
|
24
|
+
activityFresh: !!activity && nowMs - activity.atMs <= STREAM_OBSERVATION_MAX_MS,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=working-evidence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"working-evidence.js","sourceRoot":"","sources":["../../../src/core/session/working-evidence.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,GAE1B,MAAM,WAAW,CAAC;AAEnB,6GAA6G;AAC7G,MAAM,UAAU,eAAe,CAAC,EAC9B,UAAU,EACV,KAAK,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN,QAAQ,EACR,KAAK,GACS;IACd,MAAM,WAAW,GAAG,CAAC,CAAC,UAAU,IAAI,KAAK,GAAG,UAAU,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxF,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC,IAAI,GAAG,uBAAuB,CAAC;IAC1E,OAAO;QACL,WAAW;QACX,aAAa,EAAE,UAAU;YACvB,CAAC,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS;gBAC/B,CAAC,CAAC,UAAU,CAAC,SAAS;gBACtB,CAAC,CAAC,UAAU,CAAC,MAAM;YACrB,CAAC,CAAC,IAAI;QACR,WAAW,EAAE,WAAW;YACtB,CAAC,CAAC,CAAC,UAAU,EAAE,YAAY,IAAI,MAAM,CAAC,iBAAiB,CAAC;YACxD,CAAC,CAAC,MAAM,CAAC,iBAAiB;QAC5B,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB;QACtE,SAAS;QACT,UAAU,EAAE,SAAS;YACnB,CAAC,CAAC,CAAC,KAAK,EAAE,WAAW,IAAI,MAAM,CAAC,iBAAiB,CAAC;YAClD,CAAC,CAAC,MAAM,CAAC,iBAAiB;QAC5B,WAAW,EAAE,CAAC,CAAC,MAAM,IAAI,KAAK,GAAG,MAAM,CAAC,IAAI,IAAI,yBAAyB;QACzE,WAAW,EAAE,CAAC,CAAC,MAAM,IAAI,KAAK,GAAG,MAAM,CAAC,IAAI,IAAI,yBAAyB;QACzE,UAAU,EAAE,CAAC,CAAC,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC,IAAI,IAAI,wBAAwB;QACrE,aAAa,EAAE,CAAC,CAAC,QAAQ,IAAI,KAAK,GAAG,QAAQ,CAAC,IAAI,IAAI,yBAAyB;KAChF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"working-project.d.ts","sourceRoot":"","sources":["../../../src/core/session/working-project.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAwOlE,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,iBAAiB,CAatE"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { workingEvidence } from './working-evidence.js';
|
|
2
|
+
import { endedByRuntime } from './working-runtime.js';
|
|
3
|
+
import { instant } from './working-time.js';
|
|
4
|
+
/**
|
|
5
|
+
* The one place a session's working state is decided.
|
|
6
|
+
*
|
|
7
|
+
* Pure, so every rule below is asserted rather than observed by hand. No
|
|
8
|
+
* timers, no latch, no fabricated `SessionStatus` write — a caller that wants
|
|
9
|
+
* to re-evaluate simply calls again with a newer `nowMs`.
|
|
10
|
+
*
|
|
11
|
+
* Precedence:
|
|
12
|
+
*
|
|
13
|
+
* 1. The server is holding a turn open, and no NEWER stream frame contradicts
|
|
14
|
+
* it → working. `GET .../turn` reads the lifecycle authority rather than the
|
|
15
|
+
* ledger, so it is the strongest answer there is — but it is still a read
|
|
16
|
+
* taken at an instant, and an SSE frame from after that instant knows more.
|
|
17
|
+
* 2. The server holds durable inbox rows for this session → working. A prompt
|
|
18
|
+
* is accepted long before it is a turn: the row has to be drained, the box
|
|
19
|
+
* may have to resume (18.9s Daytona / 24.5s Platinum, measured), and only
|
|
20
|
+
* then does `beginSandboxTurn` run. "No turn is running" and "nothing of
|
|
21
|
+
* yours is in flight" stopped being the same statement when the inbox
|
|
22
|
+
* landed.
|
|
23
|
+
* 3. The server says no turns, and its read is at least as new as the stream's
|
|
24
|
+
* last frame → idle. (A dropped end-of-turn frame is exactly why the server
|
|
25
|
+
* has to be able to outrank a stale stream busy.)
|
|
26
|
+
* 4. The stream's own frame decides.
|
|
27
|
+
* 5. A live optimistic receipt → working.
|
|
28
|
+
* 6. Nothing observed → idle.
|
|
29
|
+
*
|
|
30
|
+
* With TWO cross-cutting freshness rules:
|
|
31
|
+
*
|
|
32
|
+
* * An observation that could not yet know about a live LOCAL action cannot
|
|
33
|
+
* answer for it — the send's floors (`SendReceipt.acceptedAtMs`) and the
|
|
34
|
+
* stop's (`AbortReceipt.settledAtMs`), all built the same way.
|
|
35
|
+
* * EVERY observation has a maximum age, and past it decides nothing at all in
|
|
36
|
+
* either direction: `SERVER_OBSERVATION_MAX_MS`, `STREAM_OBSERVATION_MAX_MS`,
|
|
37
|
+
* `INBOX_OBSERVATION_MAX_MS`. An observation the poll has failed to refresh
|
|
38
|
+
* for that long is not evidence, and standing on one is the latch. Callers
|
|
39
|
+
* must re-evaluate at those instants — see `workingExpiryAtMs`.
|
|
40
|
+
*/
|
|
41
|
+
function runtimeActivity(inputs, evidence, idleFrame, serverOpenTurnToken) {
|
|
42
|
+
const { activity, server } = inputs;
|
|
43
|
+
const { serverFresh, abortFloor, activityFresh } = evidence;
|
|
44
|
+
// Runtime content outranks observer frames only while fresh and after any wire idle.
|
|
45
|
+
const activityAfterIdle = activityFresh && (!idleFrame || activity.atMs > idleFrame.atMs);
|
|
46
|
+
if (activityAfterIdle && activity.atMs >= abortFloor) {
|
|
47
|
+
return {
|
|
48
|
+
state: 'working',
|
|
49
|
+
source: 'stream',
|
|
50
|
+
turnId: serverFresh
|
|
51
|
+
? (server.turns.find((turn) => turn.state === 'active' && !endedByRuntime(turn, idleFrame, server))?.message_id ?? null)
|
|
52
|
+
: null,
|
|
53
|
+
since: activity.atMs,
|
|
54
|
+
serverOpenTurnToken,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
function openAuthority(inputs, evidence, idleFrame, serverOpenTurnToken) {
|
|
60
|
+
const { server, stream } = inputs;
|
|
61
|
+
const { serverFresh, abortFloor } = evidence;
|
|
62
|
+
// Keep all ledger rows: a spent first row must not hide a live later one.
|
|
63
|
+
const openTurns = serverFresh
|
|
64
|
+
? server.turns.filter((t) => !endedByRuntime(t, idleFrame, server))
|
|
65
|
+
: [];
|
|
66
|
+
const openTurn = openTurns.find((turn) => turn.state === 'active') ?? openTurns[0];
|
|
67
|
+
const streamContradicts = !!stream && !(stream.type === 'idle' && stream.origin === 'local');
|
|
68
|
+
if (openTurn &&
|
|
69
|
+
server.atMs >= abortFloor &&
|
|
70
|
+
(!streamContradicts || server.atMs >= stream.atMs)) {
|
|
71
|
+
return {
|
|
72
|
+
result: {
|
|
73
|
+
...(openTurn.state === 'delivering' ? { pendingDelivery: true } : {}),
|
|
74
|
+
state: 'working',
|
|
75
|
+
source: 'server',
|
|
76
|
+
turnId: openTurn.message_id,
|
|
77
|
+
since: instant(openTurn.started_at) ?? server.atMs,
|
|
78
|
+
serverOpenTurnToken,
|
|
79
|
+
},
|
|
80
|
+
openTurn,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return { result: null, openTurn };
|
|
84
|
+
}
|
|
85
|
+
function inboxAuthority(inputs, evidence, serverOpenTurnToken) {
|
|
86
|
+
const { inbox, server, stream } = inputs;
|
|
87
|
+
const { inboxFresh, abortFloor, streamFresh, serverFresh, receiptLive, receiptTurnId, abortLive, } = evidence;
|
|
88
|
+
if (inboxFresh && inbox.pending > 0 && inbox.atMs >= abortFloor) {
|
|
89
|
+
const runtimeIsResponding = streamFresh &&
|
|
90
|
+
stream.type !== 'idle' &&
|
|
91
|
+
(!serverFresh || stream.atMs > server.atMs) &&
|
|
92
|
+
stream.atMs >= abortFloor;
|
|
93
|
+
return {
|
|
94
|
+
...(!runtimeIsResponding ? { pendingDelivery: true } : {}),
|
|
95
|
+
state: 'working',
|
|
96
|
+
source: 'server',
|
|
97
|
+
turnId: receiptLive ? receiptTurnId : null,
|
|
98
|
+
since: inbox.atMs,
|
|
99
|
+
serverOpenTurnToken,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
// Only a later server read retires a witnessed queue drain; status snapshots cannot.
|
|
103
|
+
const drainedAtMs = inbox?.drainedAtMs;
|
|
104
|
+
const drainFloorHolds = inboxFresh &&
|
|
105
|
+
inbox.pending === 0 &&
|
|
106
|
+
drainedAtMs != null &&
|
|
107
|
+
!abortLive &&
|
|
108
|
+
!(serverFresh && server.atMs >= drainedAtMs);
|
|
109
|
+
if (drainFloorHolds) {
|
|
110
|
+
return {
|
|
111
|
+
pendingDelivery: true,
|
|
112
|
+
state: 'working',
|
|
113
|
+
source: 'server',
|
|
114
|
+
turnId: null,
|
|
115
|
+
since: drainedAtMs,
|
|
116
|
+
serverOpenTurnToken,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
function lastAnswer(inputs, evidence, openTurn, serverOpenTurnToken) {
|
|
122
|
+
const { server, stream, optimistic, nowMs } = inputs;
|
|
123
|
+
const { serverFresh, serverFloor, streamFresh, streamFloor, abortFloor, receiptLive, receiptTurnId, } = evidence;
|
|
124
|
+
// A local send sets separate server and stream floors; abort floors bar old busy reads.
|
|
125
|
+
const serverAnswers = serverFresh && !openTurn && server.atMs >= serverFloor;
|
|
126
|
+
const streamAnswers = streamFresh &&
|
|
127
|
+
stream.atMs >= streamFloor &&
|
|
128
|
+
(stream.type === 'idle' || stream.atMs >= abortFloor);
|
|
129
|
+
if (serverAnswers && (!stream || server.atMs >= stream.atMs)) {
|
|
130
|
+
return {
|
|
131
|
+
state: 'idle',
|
|
132
|
+
source: 'server',
|
|
133
|
+
turnId: null,
|
|
134
|
+
since: instant(server.lastEnded?.ended_at) ?? server.atMs,
|
|
135
|
+
serverOpenTurnToken,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
if (streamAnswers) {
|
|
139
|
+
return {
|
|
140
|
+
state: stream.type === 'idle' ? 'idle' : 'working',
|
|
141
|
+
source: 'stream',
|
|
142
|
+
turnId: null,
|
|
143
|
+
since: stream.atMs,
|
|
144
|
+
serverOpenTurnToken,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (receiptLive) {
|
|
148
|
+
return {
|
|
149
|
+
pendingDelivery: true,
|
|
150
|
+
state: 'working',
|
|
151
|
+
source: 'optimistic',
|
|
152
|
+
turnId: receiptTurnId,
|
|
153
|
+
since: optimistic.atMs,
|
|
154
|
+
serverOpenTurnToken,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const newest = server && stream
|
|
158
|
+
? server.atMs >= stream.atMs
|
|
159
|
+
? { source: 'server', atMs: server.atMs }
|
|
160
|
+
: { source: 'stream', atMs: stream.atMs }
|
|
161
|
+
: server
|
|
162
|
+
? { source: 'server', atMs: server.atMs }
|
|
163
|
+
: stream
|
|
164
|
+
? { source: 'stream', atMs: stream.atMs }
|
|
165
|
+
: { source: 'server', atMs: nowMs };
|
|
166
|
+
return {
|
|
167
|
+
state: 'idle',
|
|
168
|
+
source: newest.source,
|
|
169
|
+
turnId: null,
|
|
170
|
+
since: newest.atMs,
|
|
171
|
+
serverOpenTurnToken,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
export function decideWorking(inputs) {
|
|
175
|
+
const evidence = workingEvidence(inputs);
|
|
176
|
+
const { server, stream } = inputs;
|
|
177
|
+
const idleFrame = stream && stream.type === 'idle' && stream.origin !== 'local' ? stream : null;
|
|
178
|
+
const serverOpenTurnToken = server?.turns[0]?.turn_token ?? null;
|
|
179
|
+
const activity = runtimeActivity(inputs, evidence, idleFrame, serverOpenTurnToken);
|
|
180
|
+
if (activity)
|
|
181
|
+
return activity;
|
|
182
|
+
const { result, openTurn } = openAuthority(inputs, evidence, idleFrame, serverOpenTurnToken);
|
|
183
|
+
return (result ??
|
|
184
|
+
inboxAuthority(inputs, evidence, serverOpenTurnToken) ??
|
|
185
|
+
lastAnswer(inputs, evidence, openTurn, serverOpenTurnToken));
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=working-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"working-project.js","sourceRoot":"","sources":["../../../src/core/session/working-project.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,SAAS,eAAe,CACtB,MAAqB,EACrB,QAA4C,EAC5C,SAAkC,EAClC,mBAAkC;IAElC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACpC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,QAAQ,CAAC;IAC5D,qFAAqF;IACrF,MAAM,iBAAiB,GA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0 +1,33 @@
|
|
|
1
|
+
import type { SessionTurn } from '../rest/projects-client/sessions.js';
|
|
2
|
+
import type { WorkingServerInput, WorkingStreamInput } from './working.js';
|
|
3
|
+
/**
|
|
4
|
+
* Whether the runtime has already finished this turn.
|
|
5
|
+
*
|
|
6
|
+
* "Newer read wins" is the rule this replaces, and it is wrong here, because
|
|
7
|
+
* the two observers do not learn the same fact at the same time. The idle
|
|
8
|
+
* frame comes straight off the runtime over SSE. The ledger row is closed by
|
|
9
|
+
* a SEPARATE daemon relay (`POST .../turn-stream` `kind:"end"`) — so a `/turn`
|
|
10
|
+
* read ISSUED after the frame is still ABOUT a turn the frame already ended.
|
|
11
|
+
*
|
|
12
|
+
* MEASURED, local stack 2026-08-21, one ordinary composer turn: the idle
|
|
13
|
+
* frame reached the tab at 00:03:59.964, the refetch that frame itself
|
|
14
|
+
* triggers landed at 00:04:00.150 stamped 44ms later and still reported the
|
|
15
|
+
* turn `active`, and the ledger did not record `ended_at` until 00:04:15.132
|
|
16
|
+
* — the relay for that turn never arrived and a reconciliation sweep closed
|
|
17
|
+
* it 15.1s late. The composer's Stop button and the turn's shimmer came back
|
|
18
|
+
* 186ms after they left and stayed for fifteen seconds, with the finished
|
|
19
|
+
* reply already on screen. Even in the healthy case the relay lands ~200ms
|
|
20
|
+
* after the frame, which is still inside the window its own refetch lands in.
|
|
21
|
+
*
|
|
22
|
+
* `started_at` is what separates the two turns the rule has to tell apart: a
|
|
23
|
+
* turn that began BEFORE the frame is the turn that frame ended, and a turn
|
|
24
|
+
* that began after it is a NEW one the frame knows nothing about — a queued
|
|
25
|
+
* prompt draining, a trigger firing, a second device sending. That one keeps
|
|
26
|
+
* the ledger's full authority, with no delay and no window.
|
|
27
|
+
*
|
|
28
|
+
* A row with no start instant (a legacy `activeTurn`) cannot be ranked
|
|
29
|
+
* against the frame at all, and inventing an order there would hide a live
|
|
30
|
+
* turn. The ledger keeps it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function endedByRuntime(candidate: SessionTurn, idleFrame: WorkingStreamInput | null, server: WorkingServerInput | null): boolean;
|
|
33
|
+
//# sourceMappingURL=working-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"working-runtime.d.ts","sourceRoot":"","sources":["../../../src/core/session/working-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAIxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,WAAW,EACtB,SAAS,EAAE,kBAAkB,GAAG,IAAI,EACpC,MAAM,EAAE,kBAAkB,GAAG,IAAI,GAChC,OAAO,CAcT"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { instant } from './working-time.js';
|
|
2
|
+
/**
|
|
3
|
+
* Whether the runtime has already finished this turn.
|
|
4
|
+
*
|
|
5
|
+
* "Newer read wins" is the rule this replaces, and it is wrong here, because
|
|
6
|
+
* the two observers do not learn the same fact at the same time. The idle
|
|
7
|
+
* frame comes straight off the runtime over SSE. The ledger row is closed by
|
|
8
|
+
* a SEPARATE daemon relay (`POST .../turn-stream` `kind:"end"`) — so a `/turn`
|
|
9
|
+
* read ISSUED after the frame is still ABOUT a turn the frame already ended.
|
|
10
|
+
*
|
|
11
|
+
* MEASURED, local stack 2026-08-21, one ordinary composer turn: the idle
|
|
12
|
+
* frame reached the tab at 00:03:59.964, the refetch that frame itself
|
|
13
|
+
* triggers landed at 00:04:00.150 stamped 44ms later and still reported the
|
|
14
|
+
* turn `active`, and the ledger did not record `ended_at` until 00:04:15.132
|
|
15
|
+
* — the relay for that turn never arrived and a reconciliation sweep closed
|
|
16
|
+
* it 15.1s late. The composer's Stop button and the turn's shimmer came back
|
|
17
|
+
* 186ms after they left and stayed for fifteen seconds, with the finished
|
|
18
|
+
* reply already on screen. Even in the healthy case the relay lands ~200ms
|
|
19
|
+
* after the frame, which is still inside the window its own refetch lands in.
|
|
20
|
+
*
|
|
21
|
+
* `started_at` is what separates the two turns the rule has to tell apart: a
|
|
22
|
+
* turn that began BEFORE the frame is the turn that frame ended, and a turn
|
|
23
|
+
* that began after it is a NEW one the frame knows nothing about — a queued
|
|
24
|
+
* prompt draining, a trigger firing, a second device sending. That one keeps
|
|
25
|
+
* the ledger's full authority, with no delay and no window.
|
|
26
|
+
*
|
|
27
|
+
* A row with no start instant (a legacy `activeTurn`) cannot be ranked
|
|
28
|
+
* against the frame at all, and inventing an order there would hide a live
|
|
29
|
+
* turn. The ledger keeps it.
|
|
30
|
+
*/
|
|
31
|
+
export function endedByRuntime(candidate, idleFrame, server) {
|
|
32
|
+
if (!idleFrame)
|
|
33
|
+
return false;
|
|
34
|
+
const startedAt = instant(candidate.started_at);
|
|
35
|
+
if (startedAt === null || startedAt >= idleFrame.atMs)
|
|
36
|
+
return false;
|
|
37
|
+
const lastEnded = server?.lastEnded;
|
|
38
|
+
const endedAt = instant(lastEnded?.ended_at);
|
|
39
|
+
if (lastEnded &&
|
|
40
|
+
endedAt !== null &&
|
|
41
|
+
Math.abs(endedAt - idleFrame.atMs) <= 1_000 &&
|
|
42
|
+
lastEnded.turn_token !== candidate.turn_token)
|
|
43
|
+
return false;
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=working-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"working-runtime.js","sourceRoot":"","sources":["../../../src/core/session/working-runtime.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,cAAc,CAC5B,SAAsB,EACtB,SAAoC,EACpC,MAAiC;IAEjC,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7B,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAChD,IAAI,SAAS,KAAK,IAAI,IAAI,SAAS,IAAI,SAAS,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACpE,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,CAAC;IACpC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC7C,IACE,SAAS;QACT,OAAO,KAAK,IAAI;QAChB,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,KAAK;QAC3C,SAAS,CAAC,UAAU,KAAK,SAAS,CAAC,UAAU;QAE7C,OAAO,KAAK,CAAC;IACf,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"working-time.d.ts","sourceRoot":"","sources":["../../../src/core/session/working-time.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAIvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"working-time.js","sourceRoot":"","sources":["../../../src/core/session/working-time.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO,CAAC,KAAgC;IACtD,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;AAC9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"working.d.ts","sourceRoot":"","sources":["../../../src/core/session/working.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,g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