@kortix/sdk 0.13.40 → 0.13.42
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 +40 -7
- package/dist/browser/session-sync/server-transcript-mirror.d.ts +7 -4
- package/dist/browser/session-sync/server-transcript-mirror.d.ts.map +1 -1
- package/dist/browser/session-sync/server-transcript-mirror.js +18 -4
- package/dist/browser/session-sync/server-transcript-mirror.js.map +1 -1
- package/dist/browser/stores/sandbox-connection-store.d.ts +1 -10
- package/dist/browser/stores/sandbox-connection-store.d.ts.map +1 -1
- package/dist/browser/stores/sandbox-connection-store.js +11 -1
- package/dist/browser/stores/sandbox-connection-store.js.map +1 -1
- package/dist/browser/stores/sync-store/reconcile-parts.d.ts +14 -0
- package/dist/browser/stores/sync-store/reconcile-parts.d.ts.map +1 -0
- package/dist/browser/stores/sync-store/reconcile-parts.js +55 -0
- package/dist/browser/stores/sync-store/reconcile-parts.js.map +1 -0
- package/dist/browser/stores/sync-store.d.ts.map +1 -1
- package/dist/browser/stores/sync-store.js +11 -92
- package/dist/browser/stores/sync-store.js.map +1 -1
- package/dist/core/agents/composer-agents.d.ts +73 -0
- package/dist/core/agents/composer-agents.d.ts.map +1 -0
- package/dist/core/agents/composer-agents.js +100 -0
- package/dist/core/agents/composer-agents.js.map +1 -0
- package/dist/core/cache/persisted-query-cache.d.ts.map +1 -1
- package/dist/core/cache/persisted-query-cache.js +9 -0
- package/dist/core/cache/persisted-query-cache.js.map +1 -1
- package/dist/core/client/kortix.d.ts +44 -3
- package/dist/core/client/kortix.d.ts.map +1 -1
- package/dist/core/client/kortix.js +22 -1
- package/dist/core/client/kortix.js.map +1 -1
- package/dist/core/models/bedrock-invokable.d.ts +58 -0
- package/dist/core/models/bedrock-invokable.d.ts.map +1 -0
- package/dist/core/models/bedrock-invokable.js +83 -0
- package/dist/core/models/bedrock-invokable.js.map +1 -0
- package/dist/core/models/composer-model.d.ts +51 -0
- package/dist/core/models/composer-model.d.ts.map +1 -0
- package/dist/core/models/composer-model.js +88 -0
- package/dist/core/models/composer-model.js.map +1 -0
- package/dist/core/models/model-flatten.d.ts +90 -0
- package/dist/core/models/model-flatten.d.ts.map +1 -0
- package/dist/core/models/model-flatten.js +88 -0
- package/dist/core/models/model-flatten.js.map +1 -0
- package/dist/core/models/model-key.d.ts +18 -0
- package/dist/core/models/model-key.d.ts.map +1 -0
- package/dist/core/models/model-key.js +16 -0
- package/dist/core/models/model-key.js.map +1 -0
- package/dist/core/models/model-lookup.d.ts +3 -0
- package/dist/core/models/model-lookup.d.ts.map +1 -0
- package/dist/core/models/model-lookup.js +4 -0
- package/dist/core/models/model-lookup.js.map +1 -0
- package/dist/core/models/model-visibility.d.ts +85 -0
- package/dist/core/models/model-visibility.d.ts.map +1 -0
- package/dist/core/models/model-visibility.js +215 -0
- package/dist/core/models/model-visibility.js.map +1 -0
- package/dist/core/models/provider-selection.d.ts +142 -0
- package/dist/core/models/provider-selection.d.ts.map +1 -0
- package/dist/core/models/provider-selection.js +472 -0
- package/dist/core/models/provider-selection.js.map +1 -0
- package/dist/core/rest/platform-client/host-boundary.d.ts +4 -0
- package/dist/core/rest/platform-client/host-boundary.d.ts.map +1 -1
- package/dist/core/rest/platform-client/host-boundary.js.map +1 -1
- package/dist/core/rest/projects-client/access.d.ts +6 -1
- package/dist/core/rest/projects-client/access.d.ts.map +1 -1
- package/dist/core/rest/projects-client/access.js +3 -1
- package/dist/core/rest/projects-client/access.js.map +1 -1
- package/dist/core/rest/projects-client/account-secret-resources.d.ts +7 -0
- package/dist/core/rest/projects-client/account-secret-resources.d.ts.map +1 -1
- package/dist/core/rest/projects-client/account-secret-resources.js.map +1 -1
- package/dist/core/rest/projects-client/agent-config.d.ts +4 -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/connectors.d.ts +58 -2
- package/dist/core/rest/projects-client/connectors.d.ts.map +1 -1
- package/dist/core/rest/projects-client/connectors.js +27 -3
- package/dist/core/rest/projects-client/connectors.js.map +1 -1
- package/dist/core/rest/projects-client/github.d.ts +25 -0
- package/dist/core/rest/projects-client/github.d.ts.map +1 -1
- package/dist/core/rest/projects-client/github.js +19 -0
- package/dist/core/rest/projects-client/github.js.map +1 -1
- package/dist/core/rest/projects-client/index.d.ts +2 -0
- package/dist/core/rest/projects-client/index.d.ts.map +1 -1
- package/dist/core/rest/projects-client/index.js +2 -0
- package/dist/core/rest/projects-client/index.js.map +1 -1
- package/dist/core/rest/projects-client/project-agents.d.ts +29 -0
- package/dist/core/rest/projects-client/project-agents.d.ts.map +1 -0
- package/dist/core/rest/projects-client/project-agents.js +41 -0
- package/dist/core/rest/projects-client/project-agents.js.map +1 -0
- package/dist/core/rest/projects-client/projects.d.ts +24 -4
- package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
- package/dist/core/rest/projects-client/projects.js +8 -3
- package/dist/core/rest/projects-client/projects.js.map +1 -1
- package/dist/core/rest/projects-client/review-items.d.ts +3 -0
- package/dist/core/rest/projects-client/review-items.d.ts.map +1 -1
- package/dist/core/rest/projects-client/review-items.js +1 -0
- package/dist/core/rest/projects-client/review-items.js.map +1 -1
- package/dist/core/rest/projects-client/session-reminders.d.ts +63 -0
- package/dist/core/rest/projects-client/session-reminders.d.ts.map +1 -0
- package/dist/core/rest/projects-client/session-reminders.js +29 -0
- package/dist/core/rest/projects-client/session-reminders.js.map +1 -0
- package/dist/core/rest/projects-client/sessions.d.ts +35 -0
- package/dist/core/rest/projects-client/sessions.d.ts.map +1 -1
- package/dist/core/rest/projects-client/sessions.js +14 -1
- package/dist/core/rest/projects-client/sessions.js.map +1 -1
- package/dist/core/rest/projects-client/setup-links.d.ts +2 -0
- package/dist/core/rest/projects-client/setup-links.d.ts.map +1 -1
- package/dist/core/rest/projects-client/setup-links.js.map +1 -1
- package/dist/core/rest/projects-client/tokens.d.ts +30 -0
- package/dist/core/rest/projects-client/tokens.d.ts.map +1 -1
- package/dist/core/rest/projects-client/tokens.js +11 -0
- package/dist/core/rest/projects-client/tokens.js.map +1 -1
- package/dist/core/runtime/kortix-master.d.ts +74 -5
- package/dist/core/runtime/kortix-master.d.ts.map +1 -1
- package/dist/core/runtime/kortix-master.js +78 -5
- package/dist/core/runtime/kortix-master.js.map +1 -1
- package/dist/core/session/connection.d.ts +22 -0
- package/dist/core/session/connection.d.ts.map +1 -1
- package/dist/core/session/connection.js +28 -0
- package/dist/core/session/connection.js.map +1 -1
- package/dist/core/session/status-vocabulary.d.ts +1 -1
- package/dist/core/session/status-vocabulary.js +1 -1
- package/dist/core/session/status-vocabulary.js.map +1 -1
- package/dist/core/session-sync/saved-copy-store.d.ts +5 -1
- package/dist/core/session-sync/saved-copy-store.d.ts.map +1 -1
- package/dist/core/session-sync/saved-copy-store.js +50 -2
- package/dist/core/session-sync/saved-copy-store.js.map +1 -1
- package/dist/core/session-sync/saved-transcript.d.ts +46 -2
- package/dist/core/session-sync/saved-transcript.d.ts.map +1 -1
- package/dist/core/session-sync/saved-transcript.js +40 -0
- package/dist/core/session-sync/saved-transcript.js.map +1 -1
- package/dist/core/session-sync/session-sync-controller.d.ts +2 -0
- package/dist/core/session-sync/session-sync-controller.d.ts.map +1 -1
- package/dist/core/session-sync/session-sync-controller.js +19 -2
- package/dist/core/session-sync/session-sync-controller.js.map +1 -1
- package/dist/core/stream/fetch-sse.d.ts +4 -0
- package/dist/core/stream/fetch-sse.d.ts.map +1 -1
- package/dist/core/stream/fetch-sse.js +4 -0
- package/dist/core/stream/fetch-sse.js.map +1 -1
- package/dist/core/stream/keepalive.d.ts +1 -1
- package/dist/core/stream/keepalive.js +1 -1
- package/dist/core/turns/errors.d.ts +6 -0
- package/dist/core/turns/errors.d.ts.map +1 -1
- package/dist/core/turns/errors.js +7 -1
- package/dist/core/turns/errors.js.map +1 -1
- package/dist/core/turns/parts.d.ts.map +1 -1
- package/dist/core/turns/parts.js +22 -129
- package/dist/core/turns/parts.js.map +1 -1
- package/dist/core/turns/tools/memory-helpers.d.ts +5 -0
- package/dist/core/turns/tools/memory-helpers.d.ts.map +1 -1
- package/dist/core/turns/tools/memory-helpers.js +9 -1
- package/dist/core/turns/tools/memory-helpers.js.map +1 -1
- package/dist/core/turns/tools/skill-helpers.d.ts +1 -1
- package/dist/core/turns/tools/skill-helpers.d.ts.map +1 -1
- package/dist/core/turns/tools/skill-helpers.js +7 -6
- package/dist/core/turns/tools/skill-helpers.js.map +1 -1
- package/dist/core/turns/tools/web-helpers.d.ts.map +1 -1
- package/dist/core/turns/tools/web-helpers.js +79 -139
- package/dist/core/turns/tools/web-helpers.js.map +1 -1
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -1
- package/dist/kortix.esm.min.js +37 -37
- package/dist/kortix.global.js +37 -37
- package/dist/react/bedrock-invokable.d.ts +1 -57
- package/dist/react/bedrock-invokable.d.ts.map +1 -1
- package/dist/react/bedrock-invokable.js +2 -82
- package/dist/react/bedrock-invokable.js.map +1 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/model-flatten.d.ts +1 -89
- package/dist/react/model-flatten.d.ts.map +1 -1
- package/dist/react/model-flatten.js +2 -85
- package/dist/react/model-flatten.js.map +1 -1
- package/dist/react/model-lookup.d.ts +1 -2
- package/dist/react/model-lookup.d.ts.map +1 -1
- package/dist/react/model-lookup.js +2 -3
- package/dist/react/model-lookup.js.map +1 -1
- package/dist/react/provider-selection.d.ts +1 -107
- package/dist/react/provider-selection.d.ts.map +1 -1
- package/dist/react/provider-selection.js +2 -437
- package/dist/react/provider-selection.js.map +1 -1
- package/dist/react/query-keys.d.ts +19 -1
- package/dist/react/query-keys.d.ts.map +1 -1
- package/dist/react/query-keys.js +25 -54
- package/dist/react/query-keys.js.map +1 -1
- package/dist/react/runtime-actions.d.ts +7 -0
- package/dist/react/runtime-actions.d.ts.map +1 -1
- package/dist/react/runtime-actions.js +7 -0
- package/dist/react/runtime-actions.js.map +1 -1
- package/dist/react/session-cache-write.d.ts +1 -1
- package/dist/react/session-cache-write.d.ts.map +1 -1
- package/dist/react/session-cache-write.js +38 -4
- package/dist/react/session-cache-write.js.map +1 -1
- package/dist/react/sign-in-with-kortix.d.ts +1 -1
- package/dist/react/use-feature-flag.d.ts +3 -3
- package/dist/react/use-feature-flag.d.ts.map +1 -1
- package/dist/react/use-feature-flag.js +8 -4
- package/dist/react/use-feature-flag.js.map +1 -1
- package/dist/react/use-kortix-master.d.ts +81 -3
- package/dist/react/use-kortix-master.d.ts.map +1 -1
- package/dist/react/use-kortix-master.js +84 -3
- package/dist/react/use-kortix-master.js.map +1 -1
- package/dist/react/use-model-defaults.d.ts +2 -1
- package/dist/react/use-model-defaults.d.ts.map +1 -1
- package/dist/react/use-model-defaults.js +3 -7
- package/dist/react/use-model-defaults.js.map +1 -1
- package/dist/react/use-model-store.d.ts +3 -44
- package/dist/react/use-model-store.d.ts.map +1 -1
- package/dist/react/use-model-store.js +16 -182
- package/dist/react/use-model-store.js.map +1 -1
- package/dist/react/use-opencode-events/helpers.d.ts.map +1 -1
- package/dist/react/use-opencode-events/helpers.js +5 -0
- package/dist/react/use-opencode-events/helpers.js.map +1 -1
- package/dist/react/use-opencode-local.d.ts.map +1 -1
- package/dist/react/use-opencode-local.js +41 -110
- package/dist/react/use-opencode-local.js.map +1 -1
- package/dist/react/use-opencode-mcp.d.ts +6 -0
- package/dist/react/use-opencode-mcp.d.ts.map +1 -1
- package/dist/react/use-opencode-mcp.js +6 -0
- package/dist/react/use-opencode-mcp.js.map +1 -1
- package/dist/react/use-opencode-sessions/agents.d.ts +2 -7
- package/dist/react/use-opencode-sessions/agents.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/agents.js +4 -28
- package/dist/react/use-opencode-sessions/agents.js.map +1 -1
- package/dist/react/use-opencode-sessions/mcp.d.ts +1 -0
- package/dist/react/use-opencode-sessions/mcp.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/mcp.js +1 -0
- package/dist/react/use-opencode-sessions/mcp.js.map +1 -1
- package/dist/react/use-opencode-sessions/parts.d.ts +4 -0
- package/dist/react/use-opencode-sessions/parts.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/parts.js +4 -0
- package/dist/react/use-opencode-sessions/parts.js.map +1 -1
- package/dist/react/use-opencode-sessions/projects.d.ts +1 -0
- package/dist/react/use-opencode-sessions/projects.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/projects.js +1 -0
- package/dist/react/use-opencode-sessions/projects.js.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 +4 -4
- package/dist/react/use-opencode-sessions/providers.js.map +1 -1
- package/dist/react/use-opencode-sessions/sessions.d.ts +1 -0
- package/dist/react/use-opencode-sessions/sessions.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/sessions.js +1 -0
- package/dist/react/use-opencode-sessions/sessions.js.map +1 -1
- package/dist/react/use-opencode-sessions/sharing.d.ts +2 -0
- package/dist/react/use-opencode-sessions/sharing.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/sharing.js +2 -0
- package/dist/react/use-opencode-sessions/sharing.js.map +1 -1
- package/dist/react/use-opencode-sessions/tools.d.ts +2 -0
- package/dist/react/use-opencode-sessions/tools.d.ts.map +1 -1
- package/dist/react/use-opencode-sessions/tools.js +2 -0
- package/dist/react/use-opencode-sessions/tools.js.map +1 -1
- package/dist/react/use-project-sessions.d.ts +221 -1
- package/dist/react/use-project-sessions.d.ts.map +1 -1
- package/dist/react/use-project-sessions.js +27 -1
- package/dist/react/use-project-sessions.js.map +1 -1
- package/dist/react/use-reminders.d.ts +465 -0
- package/dist/react/use-reminders.d.ts.map +1 -0
- package/dist/react/use-reminders.js +50 -0
- package/dist/react/use-reminders.js.map +1 -0
- package/dist/react/use-runtime-reconnect.d.ts +41 -8
- package/dist/react/use-runtime-reconnect.d.ts.map +1 -1
- package/dist/react/use-runtime-reconnect.js +93 -27
- package/dist/react/use-runtime-reconnect.js.map +1 -1
- package/dist/react/use-session-sync.d.ts +7 -0
- package/dist/react/use-session-sync.d.ts.map +1 -1
- package/dist/react/use-session-sync.js +25 -12
- package/dist/react/use-session-sync.js.map +1 -1
- package/dist/react/use-session-transcript-history.d.ts +2 -0
- package/dist/react/use-session-transcript-history.d.ts.map +1 -1
- package/dist/react/use-session-transcript-history.js +3 -0
- package/dist/react/use-session-transcript-history.js.map +1 -1
- package/dist/react/use-session.d.ts +25 -15
- package/dist/react/use-session.d.ts.map +1 -1
- package/dist/react/use-session.js +136 -21
- package/dist/react/use-session.js.map +1 -1
- package/dist/react/use-tunnel.d.ts +59 -7
- package/dist/react/use-tunnel.d.ts.map +1 -1
- package/dist/react/use-tunnel.js +82 -123
- package/dist/react/use-tunnel.js.map +1 -1
- package/dist/react/use-visible-agents.d.ts +5 -5
- package/dist/react/use-visible-agents.d.ts.map +1 -1
- package/dist/react/use-visible-agents.js +10 -28
- package/dist/react/use-visible-agents.js.map +1 -1
- package/package.json +2 -2
- package/dist/core/session-sync/durable-log.d.ts +0 -96
- package/dist/core/session-sync/durable-log.d.ts.map +0 -1
- package/dist/core/session-sync/durable-log.js +0 -94
- package/dist/core/session-sync/durable-log.js.map +0 -1
package/dist/react/use-tunnel.js
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Computer (tunnel) hooks — TanStack React Query hooks for paired machines.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
13
|
-
* -
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
5
|
+
* A paired computer is an ACCOUNT of the project's `computer` connector: list
|
|
6
|
+
* and select it with the generic connection APIs (`listConnections`,
|
|
7
|
+
* `--account`). These hooks cover the machine itself:
|
|
8
|
+
* - useTunnelConnections() — the machines the caller paired
|
|
9
|
+
* - useTunnelConnection(tunnelId) — one machine
|
|
10
|
+
* - useUpdateTunnelConnection() — rename a machine
|
|
11
|
+
* - useDeleteTunnelConnection() — unpair a machine
|
|
12
|
+
* - useAddComputerToProject() — add a paired machine to a project
|
|
13
|
+
* - useDeviceAuthInfo / useApproveDeviceAuth / useDenyDeviceAuth — pairing
|
|
14
|
+
*
|
|
15
|
+
* Retired (the API deleted the routes; the hooks fail with ENDPOINT_RETIRED
|
|
16
|
+
* and send no request): useCreateTunnelConnection, useTunnelPermissions,
|
|
17
|
+
* useGrantTunnelPermission, useRevokeTunnelPermission,
|
|
18
|
+
* useTunnelPermissionRequests, useApprovePermissionRequest,
|
|
19
|
+
* useDenyPermissionRequest, useTunnelAuditLogs.
|
|
18
20
|
*/
|
|
19
21
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
20
22
|
import { backendApi } from '../core/http/api-client.js';
|
|
23
|
+
import { addComputerToProject } from '../core/rest/projects-client/index.js';
|
|
24
|
+
import { useRetiredMutation, useRetiredQuery } from './retired-endpoint.js';
|
|
21
25
|
// ─── Query Keys ──────────────────────────────────────────────────────────────
|
|
22
26
|
export const tunnelKeys = {
|
|
23
27
|
all: ['tunnel'],
|
|
@@ -29,7 +33,9 @@ export const tunnelKeys = {
|
|
|
29
33
|
deviceAuth: (code) => [...tunnelKeys.all, 'device-auth', code],
|
|
30
34
|
};
|
|
31
35
|
// ─── Connection Hooks ────────────────────────────────────────────────────────
|
|
32
|
-
|
|
36
|
+
/** Machines the caller paired. Polls every 5 s; pass a slower `refetchInterval`
|
|
37
|
+
* (or `false`) when only "has a machine?" matters. */
|
|
38
|
+
export function useTunnelConnections(options = {}) {
|
|
33
39
|
return useQuery({
|
|
34
40
|
queryKey: tunnelKeys.connections(),
|
|
35
41
|
queryFn: async () => {
|
|
@@ -42,7 +48,7 @@ export function useTunnelConnections() {
|
|
|
42
48
|
return res.data;
|
|
43
49
|
},
|
|
44
50
|
staleTime: 2_000,
|
|
45
|
-
refetchInterval: 5_000,
|
|
51
|
+
refetchInterval: options.refetchInterval ?? 5_000,
|
|
46
52
|
refetchIntervalInBackground: false,
|
|
47
53
|
refetchOnMount: 'always',
|
|
48
54
|
refetchOnWindowFocus: 'always',
|
|
@@ -68,19 +74,13 @@ export function useTunnelConnection(tunnelId) {
|
|
|
68
74
|
refetchOnWindowFocus: 'always',
|
|
69
75
|
});
|
|
70
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* @deprecated The API removed `POST /tunnel/connections`: a machine pairs
|
|
79
|
+
* through device auth (`npx @kortix/agent-tunnel connect`). Fails with
|
|
80
|
+
* `ENDPOINT_RETIRED`. Removed in the next major.
|
|
81
|
+
*/
|
|
71
82
|
export function useCreateTunnelConnection() {
|
|
72
|
-
|
|
73
|
-
return useMutation({
|
|
74
|
-
mutationFn: async (data) => {
|
|
75
|
-
const res = await backendApi.post('/tunnel/connections', data);
|
|
76
|
-
if (!res.success)
|
|
77
|
-
throw new Error(res.error?.message || 'Failed to create connection');
|
|
78
|
-
return res.data;
|
|
79
|
-
},
|
|
80
|
-
onSuccess: () => {
|
|
81
|
-
queryClient.invalidateQueries({ queryKey: tunnelKeys.connections() });
|
|
82
|
-
},
|
|
83
|
-
});
|
|
83
|
+
return useRetiredMutation('useCreateTunnelConnection');
|
|
84
84
|
}
|
|
85
85
|
export function useUpdateTunnelConnection() {
|
|
86
86
|
const queryClient = useQueryClient();
|
|
@@ -107,99 +107,54 @@ export function useDeleteTunnelConnection() {
|
|
|
107
107
|
},
|
|
108
108
|
onSuccess: () => {
|
|
109
109
|
queryClient.invalidateQueries({ queryKey: tunnelKeys.connections() });
|
|
110
|
+
// Unpairing revokes the machine's `computer` accounts in every project.
|
|
111
|
+
queryClient.invalidateQueries({ queryKey: ['connections'] });
|
|
110
112
|
},
|
|
111
113
|
});
|
|
112
114
|
}
|
|
113
|
-
// ───
|
|
115
|
+
// ─── Retired permission hooks ───────────────────────────────────────────────
|
|
116
|
+
// Per-machine permission editing and permission requests are no longer a
|
|
117
|
+
// product surface. The local agent's config is the ceiling; human approval of
|
|
118
|
+
// risky calls is a connector policy (`require_approval`).
|
|
119
|
+
/** @deprecated The API removed this route. Fails with `ENDPOINT_RETIRED`. Removed in the next major. */
|
|
114
120
|
export function useTunnelPermissions(tunnelId) {
|
|
115
|
-
return
|
|
116
|
-
queryKey: tunnelKeys.permissions(tunnelId),
|
|
117
|
-
queryFn: async () => {
|
|
118
|
-
const res = await backendApi.get(`/tunnel/permissions/${tunnelId}`, {
|
|
119
|
-
showErrors: false,
|
|
120
|
-
timeout: 10_000,
|
|
121
|
-
});
|
|
122
|
-
if (!res.success)
|
|
123
|
-
throw new Error(res.error?.message || 'Failed to fetch permissions');
|
|
124
|
-
return res.data;
|
|
125
|
-
},
|
|
126
|
-
enabled: !!tunnelId,
|
|
127
|
-
staleTime: 10_000,
|
|
128
|
-
});
|
|
121
|
+
return useRetiredQuery('useTunnelPermissions', tunnelKeys.permissions(tunnelId), !!tunnelId);
|
|
129
122
|
}
|
|
123
|
+
/** @deprecated The API removed this route. Fails with `ENDPOINT_RETIRED`. Removed in the next major. */
|
|
130
124
|
export function useGrantTunnelPermission() {
|
|
131
|
-
|
|
132
|
-
return useMutation({
|
|
133
|
-
mutationFn: async ({ tunnelId, ...data }) => {
|
|
134
|
-
const res = await backendApi.post(`/tunnel/permissions/${tunnelId}`, data);
|
|
135
|
-
if (!res.success)
|
|
136
|
-
throw new Error(res.error?.message || 'Failed to grant permission');
|
|
137
|
-
return res.data;
|
|
138
|
-
},
|
|
139
|
-
onSuccess: (_, vars) => {
|
|
140
|
-
queryClient.invalidateQueries({ queryKey: tunnelKeys.permissions(vars.tunnelId) });
|
|
141
|
-
},
|
|
142
|
-
});
|
|
125
|
+
return useRetiredMutation('useGrantTunnelPermission');
|
|
143
126
|
}
|
|
127
|
+
/** @deprecated The API removed this route. Fails with `ENDPOINT_RETIRED`. Removed in the next major. */
|
|
144
128
|
export function useRevokeTunnelPermission() {
|
|
145
|
-
|
|
146
|
-
return useMutation({
|
|
147
|
-
mutationFn: async ({ tunnelId, permissionId }) => {
|
|
148
|
-
const res = await backendApi.delete(`/tunnel/permissions/${tunnelId}/${permissionId}`);
|
|
149
|
-
if (!res.success)
|
|
150
|
-
throw new Error(res.error?.message || 'Failed to revoke permission');
|
|
151
|
-
},
|
|
152
|
-
onSuccess: (_, vars) => {
|
|
153
|
-
queryClient.invalidateQueries({ queryKey: tunnelKeys.permissions(vars.tunnelId) });
|
|
154
|
-
},
|
|
155
|
-
});
|
|
129
|
+
return useRetiredMutation('useRevokeTunnelPermission');
|
|
156
130
|
}
|
|
157
|
-
|
|
131
|
+
/** @deprecated The API removed this route. Fails with `ENDPOINT_RETIRED`. Removed in the next major. */
|
|
158
132
|
export function useTunnelPermissionRequests() {
|
|
159
|
-
return
|
|
160
|
-
queryKey: tunnelKeys.permissionRequests(),
|
|
161
|
-
queryFn: async () => {
|
|
162
|
-
const res = await backendApi.get('/tunnel/permission-requests', {
|
|
163
|
-
showErrors: false,
|
|
164
|
-
timeout: 10_000,
|
|
165
|
-
});
|
|
166
|
-
if (!res.success)
|
|
167
|
-
throw new Error(res.error?.message || 'Failed to fetch requests');
|
|
168
|
-
return res.data;
|
|
169
|
-
},
|
|
170
|
-
staleTime: 5_000,
|
|
171
|
-
refetchInterval: 10_000,
|
|
172
|
-
refetchIntervalInBackground: false,
|
|
173
|
-
});
|
|
133
|
+
return useRetiredQuery('useTunnelPermissionRequests', tunnelKeys.permissionRequests());
|
|
174
134
|
}
|
|
135
|
+
/** @deprecated The API removed this route. Fails with `ENDPOINT_RETIRED`. Removed in the next major. */
|
|
175
136
|
export function useApprovePermissionRequest() {
|
|
176
|
-
|
|
177
|
-
return useMutation({
|
|
178
|
-
mutationFn: async ({ requestId, scope, expiresAt }) => {
|
|
179
|
-
const res = await backendApi.post(`/tunnel/permission-requests/${requestId}/approve`, {
|
|
180
|
-
scope,
|
|
181
|
-
expiresAt,
|
|
182
|
-
});
|
|
183
|
-
if (!res.success)
|
|
184
|
-
throw new Error(res.error?.message || 'Failed to approve request');
|
|
185
|
-
return res.data;
|
|
186
|
-
},
|
|
187
|
-
onSuccess: () => {
|
|
188
|
-
queryClient.invalidateQueries({ queryKey: tunnelKeys.permissionRequests() });
|
|
189
|
-
queryClient.invalidateQueries({ queryKey: tunnelKeys.all });
|
|
190
|
-
},
|
|
191
|
-
});
|
|
137
|
+
return useRetiredMutation('useApprovePermissionRequest');
|
|
192
138
|
}
|
|
139
|
+
/** @deprecated The API removed this route. Fails with `ENDPOINT_RETIRED`. Removed in the next major. */
|
|
193
140
|
export function useDenyPermissionRequest() {
|
|
141
|
+
return useRetiredMutation('useDenyPermissionRequest');
|
|
142
|
+
}
|
|
143
|
+
// ─── Project Hooks ───────────────────────────────────────────────────────────
|
|
144
|
+
/**
|
|
145
|
+
* Share a machine the caller paired with a project (`share: 'project'`, needs
|
|
146
|
+
* the connector-manage capability): everyone in the project can use it,
|
|
147
|
+
* including unattended runs. A private account is not needed: the owner's own
|
|
148
|
+
* account follows them into every project they belong to. `share: 'me'`
|
|
149
|
+
* (the server default) stays accepted and is idempotent.
|
|
150
|
+
*/
|
|
151
|
+
export function useAddComputerToProject() {
|
|
194
152
|
const queryClient = useQueryClient();
|
|
195
153
|
return useMutation({
|
|
196
|
-
mutationFn:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
},
|
|
201
|
-
onSuccess: () => {
|
|
202
|
-
queryClient.invalidateQueries({ queryKey: tunnelKeys.permissionRequests() });
|
|
154
|
+
mutationFn: ({ projectId, ...input }) => addComputerToProject(projectId, input),
|
|
155
|
+
onSuccess: (_, vars) => {
|
|
156
|
+
queryClient.invalidateQueries({ queryKey: ['connections', vars.projectId] });
|
|
157
|
+
queryClient.invalidateQueries({ queryKey: tunnelKeys.connections() });
|
|
203
158
|
},
|
|
204
159
|
});
|
|
205
160
|
}
|
|
@@ -220,11 +175,25 @@ export function useDeviceAuthInfo(code) {
|
|
|
220
175
|
refetchInterval: 5_000,
|
|
221
176
|
});
|
|
222
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Approve a pairing request. The machine belongs to the caller and is theirs
|
|
180
|
+
* in every project they are a member of, in their private sessions
|
|
181
|
+
* (`share: 'me'`, the default). `share: 'project'` also shares it with a
|
|
182
|
+
* project (needs the connector-manage capability there): `projectId`, or the
|
|
183
|
+
* project the machine named (`DeviceAuthInfo.projectId`) when it is omitted.
|
|
184
|
+
* Older servers need a project for every approval.
|
|
185
|
+
*/
|
|
223
186
|
export function useApproveDeviceAuth() {
|
|
224
187
|
const queryClient = useQueryClient();
|
|
225
188
|
return useMutation({
|
|
226
|
-
mutationFn: async ({ code, ...data }) => {
|
|
227
|
-
|
|
189
|
+
mutationFn: async ({ code, projectId, share, ...data }) => {
|
|
190
|
+
// `connectionId` is the computer account created on the project: `null`
|
|
191
|
+
// when the approval named no project, absent on older servers.
|
|
192
|
+
const res = await backendApi.post(`/tunnel/device-auth/${code}/approve`, {
|
|
193
|
+
...data,
|
|
194
|
+
...(projectId ? { project_id: projectId } : {}),
|
|
195
|
+
...(share ? { share } : {}),
|
|
196
|
+
});
|
|
228
197
|
if (!res.success)
|
|
229
198
|
throw new Error(res.error?.message || 'Failed to approve device');
|
|
230
199
|
return res.data;
|
|
@@ -232,6 +201,8 @@ export function useApproveDeviceAuth() {
|
|
|
232
201
|
onSuccess: (_, vars) => {
|
|
233
202
|
queryClient.invalidateQueries({ queryKey: tunnelKeys.deviceAuth(vars.code) });
|
|
234
203
|
queryClient.invalidateQueries({ queryKey: tunnelKeys.connections() });
|
|
204
|
+
if (vars.projectId)
|
|
205
|
+
queryClient.invalidateQueries({ queryKey: ['connections', vars.projectId] });
|
|
235
206
|
},
|
|
236
207
|
});
|
|
237
208
|
}
|
|
@@ -248,21 +219,9 @@ export function useDenyDeviceAuth() {
|
|
|
248
219
|
},
|
|
249
220
|
});
|
|
250
221
|
}
|
|
251
|
-
// ───
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
queryFn: async () => {
|
|
256
|
-
const res = await backendApi.get(`/tunnel/audit/${tunnelId}?page=${page}&limit=${limit}`, {
|
|
257
|
-
showErrors: false,
|
|
258
|
-
timeout: 10_000,
|
|
259
|
-
});
|
|
260
|
-
if (!res.success)
|
|
261
|
-
throw new Error(res.error?.message || 'Failed to fetch audit logs');
|
|
262
|
-
return res.data;
|
|
263
|
-
},
|
|
264
|
-
enabled: !!tunnelId,
|
|
265
|
-
staleTime: 15_000,
|
|
266
|
-
});
|
|
222
|
+
// ─── Retired audit hook ──────────────────────────────────────────────────────
|
|
223
|
+
/** @deprecated The API removed this route. Fails with `ENDPOINT_RETIRED`. Removed in the next major. */
|
|
224
|
+
export function useTunnelAuditLogs(tunnelId, page = 1, _limit = 50) {
|
|
225
|
+
return useRetiredQuery('useTunnelAuditLogs', tunnelKeys.auditLogs(tunnelId, page), !!tunnelId);
|
|
267
226
|
}
|
|
268
227
|
//# sourceMappingURL=use-tunnel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tunnel.js","sourceRoot":"","sources":["../../src/react/use-tunnel.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb
|
|
1
|
+
{"version":3,"file":"use-tunnel.js","sourceRoot":"","sources":["../../src/react/use-tunnel.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAA8B,MAA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GAAG,EAAE;IACxE,OAAO,eAAe,CAAe,oBAAoB,EAAE,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;AAC/G,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Agent } from '@opencode-ai/sdk/v2/client';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* Use this for agent selectors in UI where users pick which agent to use.
|
|
3
|
+
* The agents a user can pick, filtered by `isSelectableAgent`.
|
|
5
4
|
*
|
|
6
|
-
* Pass `projectId
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Pass `projectId`. It reads the Kortix project config, which lists only the
|
|
6
|
+
* project's own agents and works before any sandbox exists. Without it the
|
|
7
|
+
* hook reads the sandbox runtime's agent list, which also contains the
|
|
8
|
+
* runtime's built-in agents (`build`, `plan`, …) that are not project agents.
|
|
9
9
|
*/
|
|
10
10
|
export declare function useVisibleAgents(options?: {
|
|
11
11
|
directory?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-visible-agents.d.ts","sourceRoot":"","sources":["../../src/react/use-visible-agents.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"use-visible-agents.d.ts","sourceRoot":"","sources":["../../src/react/use-visible-agents.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAIxD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,GAAG,KAAK,EAAE,CAMV;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,GAAG,KAAK,EAAE,CAOV"}
|
|
@@ -1,38 +1,18 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { useOpenCodeAgents } from './use-opencode-sessions/index.js';
|
|
4
|
-
import {
|
|
4
|
+
import { isSelectableAgent } from '../core/rest/projects-client/project-agents.js';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* The agents a user can pick, filtered by `isSelectableAgent`.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
* project
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* project-paradigm gate.
|
|
13
|
-
*
|
|
14
|
-
* `project-manager` is the per-project PM slug seeded by seedV2Project at
|
|
15
|
-
* /workspace/.opencode/agent/project-manager.md. The file persists on disk
|
|
16
|
-
* after a flag-on cycle even when the flag flips back off, so this picker
|
|
17
|
-
* filter is what keeps it out of the UI in default mode.
|
|
18
|
-
*/
|
|
19
|
-
const PROJECT_ONLY_AGENTS = new Set(['project-manager']);
|
|
20
|
-
function hideProjectOnly(a) {
|
|
21
|
-
if (featureFlags.enableProjects)
|
|
22
|
-
return false;
|
|
23
|
-
return PROJECT_ONLY_AGENTS.has(a.name);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Returns only visible agents (non-hidden, non-subagent).
|
|
27
|
-
* Use this for agent selectors in UI where users pick which agent to use.
|
|
28
|
-
*
|
|
29
|
-
* Pass `projectId` for a SERVER-SIDE fetch (the project config is source of
|
|
30
|
-
* truth, works before any sandbox runtime exists) — preferred for selectors.
|
|
31
|
-
* Pass `directory` to scope the sandbox-runtime fetch to a project instead.
|
|
8
|
+
* Pass `projectId`. It reads the Kortix project config, which lists only the
|
|
9
|
+
* project's own agents and works before any sandbox exists. Without it the
|
|
10
|
+
* hook reads the sandbox runtime's agent list, which also contains the
|
|
11
|
+
* runtime's built-in agents (`build`, `plan`, …) that are not project agents.
|
|
32
12
|
*/
|
|
33
13
|
export function useVisibleAgents(options) {
|
|
34
14
|
const { data: agents = [] } = useOpenCodeAgents(options);
|
|
35
|
-
return useMemo(() => agents.filter(
|
|
15
|
+
return useMemo(() => agents.filter(isSelectableAgent), [agents]);
|
|
36
16
|
}
|
|
37
17
|
/**
|
|
38
18
|
* Returns all visible agents including subagents.
|
|
@@ -40,6 +20,8 @@ export function useVisibleAgents(options) {
|
|
|
40
20
|
*/
|
|
41
21
|
export function useAllVisibleAgents(options) {
|
|
42
22
|
const { data: agents = [] } = useOpenCodeAgents(options);
|
|
43
|
-
return useMemo(
|
|
23
|
+
return useMemo(
|
|
24
|
+
// The same rule with the subagent check lifted.
|
|
25
|
+
() => agents.filter((a) => isSelectableAgent({ ...a, mode: null })), [agents]);
|
|
44
26
|
}
|
|
45
27
|
//# sourceMappingURL=use-visible-agents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-visible-agents.js","sourceRoot":"","sources":["../../src/react/use-visible-agents.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"use-visible-agents.js","sourceRoot":"","sources":["../../src/react/use-visible-agents.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAEhF;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAGhC;IACC,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACzD,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,EACtC,CAAC,MAAM,CAAC,CACT,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAGnC;IACC,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACzD,OAAO,OAAO;IACZ,gDAAgD;IAChD,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EACnE,CAAC,MAAM,CAAC,CACT,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kortix/sdk",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.42",
|
|
4
4
|
"description": "Official Kortix frontend TypeScript SDK — one typed client for the Kortix agent platform. Unifies project/session lifecycle and live agent streaming behind a single ergonomic Session handle, so web, mobile, and white-label apps never touch the raw HTTP API or OpenCode semantics.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Elastic-2.0",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"sideEffects": false,
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@kortix/llm-catalog": "0.13.
|
|
23
|
+
"@kortix/llm-catalog": "0.13.42",
|
|
24
24
|
"@opencode-ai/sdk": "1.18.23",
|
|
25
25
|
"zustand": "^5.0.3"
|
|
26
26
|
},
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The durable per-session event log.
|
|
3
|
-
*
|
|
4
|
-
* OpenCode's runtime keeps an ordered, replayable log per session, and exposes
|
|
5
|
-
* it on two routes that our sandboxes already serve (verified live through the
|
|
6
|
-
* Kortix proxy, dev, 2026-08-24):
|
|
7
|
-
*
|
|
8
|
-
* GET /api/session/{id}/history?limit&after -> { data: SessionDurableEvent[], hasMore }
|
|
9
|
-
* GET /api/session/{id}/event?after=<seq> -> SSE: replay, then tail
|
|
10
|
-
*
|
|
11
|
-
* The SDK's own words for the second one: "Replay durable events after an
|
|
12
|
-
* aggregate sequence, then continue with new durable events."
|
|
13
|
-
*
|
|
14
|
-
* Why this matters more than any repair we have written:
|
|
15
|
-
*
|
|
16
|
-
* Every transcript bug this file's neighbours exist to fix comes from the same
|
|
17
|
-
* shape — the browser holds a COPY assembled from a lossy stream, and has no
|
|
18
|
-
* way to ask "what did I miss?". So we invented answers: re-read the tail on a
|
|
19
|
-
* gap, on turn end, on tab return, on eviction; poll every 10s while working;
|
|
20
|
-
* infer "is it working" from six stamped observations. Each is a guess about
|
|
21
|
-
* loss we could not measure.
|
|
22
|
-
*
|
|
23
|
-
* A sequence cursor replaces all of it with a question the server can answer
|
|
24
|
-
* exactly: everything after `seq`. Missed nothing -> zero events. Missed a
|
|
25
|
-
* turn -> exactly that turn. Cost is proportional to what was MISSED rather
|
|
26
|
-
* than to the size of the transcript, which is the whole reason a 78 MB tail
|
|
27
|
-
* read could never be the right repair.
|
|
28
|
-
*
|
|
29
|
-
* Framework-free on purpose: no DOM, no React, no store. Callers own the cursor.
|
|
30
|
-
*/
|
|
31
|
-
/** One page of durable events. `limit` is per request, not a total. */
|
|
32
|
-
export declare const DURABLE_HISTORY_PAGE_SIZE = 200;
|
|
33
|
-
/** A durable event carries an aggregate sequence; a delta frame does not. */
|
|
34
|
-
export interface DurableEventLike {
|
|
35
|
-
durable?: {
|
|
36
|
-
aggregateID?: string;
|
|
37
|
-
seq?: number;
|
|
38
|
-
version?: number;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
export interface DurableHistoryPage {
|
|
42
|
-
events: unknown[];
|
|
43
|
-
hasMore: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* The cursor to pass as `after` next time. Never lower than the cursor this
|
|
46
|
-
* read was given — a rewind would replay events already applied.
|
|
47
|
-
*/
|
|
48
|
-
lastSeq: number | null;
|
|
49
|
-
}
|
|
50
|
-
export interface DurableLogClient {
|
|
51
|
-
v2?: {
|
|
52
|
-
session: {
|
|
53
|
-
history: (request: {
|
|
54
|
-
sessionID: string;
|
|
55
|
-
limit?: number;
|
|
56
|
-
after?: number;
|
|
57
|
-
}) => Promise<{
|
|
58
|
-
data?: {
|
|
59
|
-
data?: unknown[];
|
|
60
|
-
hasMore?: boolean;
|
|
61
|
-
};
|
|
62
|
-
}>;
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* The aggregate sequence of an event, or null if it carries none.
|
|
68
|
-
*
|
|
69
|
-
* Only durable events advance the cursor. The runtime also emits pure deltas
|
|
70
|
-
* (text, reasoning, tool input, compaction) that exist to make typing look
|
|
71
|
-
* live; they are disposable by design and must never move a cursor, or a
|
|
72
|
-
* reconnect would skip the durable event they were painting over.
|
|
73
|
-
*/
|
|
74
|
-
export declare function durableSeqOf(event: unknown): number | null;
|
|
75
|
-
/**
|
|
76
|
-
* Read one page of the log after `after` (exclusive).
|
|
77
|
-
*
|
|
78
|
-
* The runtime's own note on this route: "Newly committed events may appear on
|
|
79
|
-
* later pages" — so `hasMore: false` means "caught up as of now", not "the log
|
|
80
|
-
* is finished". The caller keeps the cursor and asks again.
|
|
81
|
-
*/
|
|
82
|
-
export declare function readSessionDurableHistory(client: DurableLogClient, sessionId: string, cursor: {
|
|
83
|
-
after?: number;
|
|
84
|
-
limit?: number;
|
|
85
|
-
}): Promise<DurableHistoryPage>;
|
|
86
|
-
/**
|
|
87
|
-
* Does this failure mean "this runtime has no durable log" rather than "the
|
|
88
|
-
* read failed"?
|
|
89
|
-
*
|
|
90
|
-
* Self-hosted installs run older sandbox images. A 404 is a capability answer
|
|
91
|
-
* and must fall back to the message read. Everything else is a real failure and
|
|
92
|
-
* must reach the caller's retry — swallowing a 503 as "unsupported" would
|
|
93
|
-
* permanently downgrade a runtime that was merely asleep.
|
|
94
|
-
*/
|
|
95
|
-
export declare function isDurableLogUnsupported(error: unknown): boolean;
|
|
96
|
-
//# sourceMappingURL=durable-log.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"durable-log.d.ts","sourceRoot":"","sources":["../../../src/core/session-sync/durable-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,uEAAuE;AACvE,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACpE;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,CAAC,EAAE;QACH,OAAO,EAAE;YACP,OAAO,EAAE,CAAC,OAAO,EAAE;gBACjB,SAAS,EAAE,MAAM,CAAC;gBAClB,KAAK,CAAC,EAAE,MAAM,CAAC;gBACf,KAAK,CAAC,EAAE,MAAM,CAAC;aAChB,KAAK,OAAO,CAAC;gBAAE,IAAI,CAAC,EAAE;oBAAE,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;oBAAC,OAAO,CAAC,EAAE,OAAO,CAAA;iBAAE,CAAA;aAAE,CAAC,CAAC;SACnE,CAAC;KACH,CAAC;CACH;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAK1D;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACzC,OAAO,CAAC,kBAAkB,CAAC,CAsB7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAK/D"}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The durable per-session event log.
|
|
3
|
-
*
|
|
4
|
-
* OpenCode's runtime keeps an ordered, replayable log per session, and exposes
|
|
5
|
-
* it on two routes that our sandboxes already serve (verified live through the
|
|
6
|
-
* Kortix proxy, dev, 2026-08-24):
|
|
7
|
-
*
|
|
8
|
-
* GET /api/session/{id}/history?limit&after -> { data: SessionDurableEvent[], hasMore }
|
|
9
|
-
* GET /api/session/{id}/event?after=<seq> -> SSE: replay, then tail
|
|
10
|
-
*
|
|
11
|
-
* The SDK's own words for the second one: "Replay durable events after an
|
|
12
|
-
* aggregate sequence, then continue with new durable events."
|
|
13
|
-
*
|
|
14
|
-
* Why this matters more than any repair we have written:
|
|
15
|
-
*
|
|
16
|
-
* Every transcript bug this file's neighbours exist to fix comes from the same
|
|
17
|
-
* shape — the browser holds a COPY assembled from a lossy stream, and has no
|
|
18
|
-
* way to ask "what did I miss?". So we invented answers: re-read the tail on a
|
|
19
|
-
* gap, on turn end, on tab return, on eviction; poll every 10s while working;
|
|
20
|
-
* infer "is it working" from six stamped observations. Each is a guess about
|
|
21
|
-
* loss we could not measure.
|
|
22
|
-
*
|
|
23
|
-
* A sequence cursor replaces all of it with a question the server can answer
|
|
24
|
-
* exactly: everything after `seq`. Missed nothing -> zero events. Missed a
|
|
25
|
-
* turn -> exactly that turn. Cost is proportional to what was MISSED rather
|
|
26
|
-
* than to the size of the transcript, which is the whole reason a 78 MB tail
|
|
27
|
-
* read could never be the right repair.
|
|
28
|
-
*
|
|
29
|
-
* Framework-free on purpose: no DOM, no React, no store. Callers own the cursor.
|
|
30
|
-
*/
|
|
31
|
-
/** One page of durable events. `limit` is per request, not a total. */
|
|
32
|
-
export const DURABLE_HISTORY_PAGE_SIZE = 200;
|
|
33
|
-
/**
|
|
34
|
-
* The aggregate sequence of an event, or null if it carries none.
|
|
35
|
-
*
|
|
36
|
-
* Only durable events advance the cursor. The runtime also emits pure deltas
|
|
37
|
-
* (text, reasoning, tool input, compaction) that exist to make typing look
|
|
38
|
-
* live; they are disposable by design and must never move a cursor, or a
|
|
39
|
-
* reconnect would skip the durable event they were painting over.
|
|
40
|
-
*/
|
|
41
|
-
export function durableSeqOf(event) {
|
|
42
|
-
if (!event || typeof event !== 'object')
|
|
43
|
-
return null;
|
|
44
|
-
const durable = event.durable;
|
|
45
|
-
if (!durable || typeof durable.seq !== 'number' || !Number.isFinite(durable.seq))
|
|
46
|
-
return null;
|
|
47
|
-
return durable.seq;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Read one page of the log after `after` (exclusive).
|
|
51
|
-
*
|
|
52
|
-
* The runtime's own note on this route: "Newly committed events may appear on
|
|
53
|
-
* later pages" — so `hasMore: false` means "caught up as of now", not "the log
|
|
54
|
-
* is finished". The caller keeps the cursor and asks again.
|
|
55
|
-
*/
|
|
56
|
-
export async function readSessionDurableHistory(client, sessionId, cursor) {
|
|
57
|
-
const history = client.v2?.session.history;
|
|
58
|
-
if (!history)
|
|
59
|
-
throw new Error('durable log unavailable: client exposes no v2 session namespace');
|
|
60
|
-
const result = await history({
|
|
61
|
-
sessionID: sessionId,
|
|
62
|
-
limit: cursor.limit ?? DURABLE_HISTORY_PAGE_SIZE,
|
|
63
|
-
...(cursor.after === undefined ? {} : { after: cursor.after }),
|
|
64
|
-
});
|
|
65
|
-
const events = result.data?.data ?? [];
|
|
66
|
-
// The HIGHEST sequence in the page, not the last element's. A page is not
|
|
67
|
-
// promised in sequence order, and it may carry frames with no sequence at
|
|
68
|
-
// all; taking the tail element would rewind the cursor on either.
|
|
69
|
-
let lastSeq = cursor.after ?? null;
|
|
70
|
-
for (const event of events) {
|
|
71
|
-
const seq = durableSeqOf(event);
|
|
72
|
-
if (seq === null)
|
|
73
|
-
continue;
|
|
74
|
-
if (lastSeq === null || seq > lastSeq)
|
|
75
|
-
lastSeq = seq;
|
|
76
|
-
}
|
|
77
|
-
return { events, hasMore: result.data?.hasMore === true, lastSeq };
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Does this failure mean "this runtime has no durable log" rather than "the
|
|
81
|
-
* read failed"?
|
|
82
|
-
*
|
|
83
|
-
* Self-hosted installs run older sandbox images. A 404 is a capability answer
|
|
84
|
-
* and must fall back to the message read. Everything else is a real failure and
|
|
85
|
-
* must reach the caller's retry — swallowing a 503 as "unsupported" would
|
|
86
|
-
* permanently downgrade a runtime that was merely asleep.
|
|
87
|
-
*/
|
|
88
|
-
export function isDurableLogUnsupported(error) {
|
|
89
|
-
if (!error || typeof error !== 'object')
|
|
90
|
-
return false;
|
|
91
|
-
const status = error.status ?? error.statusCode;
|
|
92
|
-
return status === 404;
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=durable-log.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"durable-log.js","sourceRoot":"","sources":["../../../src/core/session-sync/durable-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,uEAAuE;AACvE,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AA6B7C;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACrD,MAAM,OAAO,GAAI,KAA0B,CAAC,OAAO,CAAC;IACpD,IAAI,CAAC,OAAO,IAAI,OAAO,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