@kortix/sdk 0.16.4 → 0.16.6
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 +65 -10
- package/dist/browser/cache/idb-sync-cache.d.ts +6 -18
- package/dist/browser/cache/idb-sync-cache.d.ts.map +1 -1
- package/dist/browser/cache/idb-sync-cache.js +7 -22
- package/dist/browser/cache/idb-sync-cache.js.map +1 -1
- package/dist/browser/session-sync/session-scope.d.ts +10 -0
- package/dist/browser/session-sync/session-scope.d.ts.map +1 -0
- package/dist/browser/session-sync/session-scope.js +18 -0
- package/dist/browser/session-sync/session-scope.js.map +1 -0
- package/dist/browser/session-sync/session-sync-registry.d.ts +0 -2
- package/dist/browser/session-sync/session-sync-registry.d.ts.map +1 -1
- package/dist/browser/session-sync/session-sync-registry.js +7 -10
- package/dist/browser/session-sync/session-sync-registry.js.map +1 -1
- package/dist/browser/stores/sandbox-connection-store.d.ts.map +1 -1
- package/dist/browser/stores/sandbox-connection-store.js +21 -41
- package/dist/browser/stores/sandbox-connection-store.js.map +1 -1
- package/dist/browser/stores/sync-store/binary.d.ts +2 -0
- package/dist/browser/stores/sync-store/binary.d.ts.map +1 -1
- package/dist/browser/stores/sync-store/binary.js +4 -0
- package/dist/browser/stores/sync-store/binary.js.map +1 -1
- package/dist/browser/stores/sync-store/reconcile-parts.js +2 -2
- package/dist/browser/stores/sync-store/reconcile-parts.js.map +1 -1
- package/dist/browser/stores/sync-store/types.d.ts +2 -5
- package/dist/browser/stores/sync-store/types.d.ts.map +1 -1
- package/dist/browser/stores/sync-store.d.ts +4 -2
- package/dist/browser/stores/sync-store.d.ts.map +1 -1
- package/dist/browser/stores/sync-store.js +2 -2
- package/dist/browser/stores/sync-store.js.map +1 -1
- package/dist/core/client/kortix.d.ts +16 -6
- package/dist/core/client/kortix.d.ts.map +1 -1
- package/dist/core/client/project-core.d.ts +5 -0
- package/dist/core/client/project-core.d.ts.map +1 -1
- package/dist/core/client/project-core.js +5 -0
- package/dist/core/client/project-core.js.map +1 -1
- package/dist/core/client/project-operations-admin.d.ts +4 -0
- package/dist/core/client/project-operations-admin.d.ts.map +1 -1
- package/dist/core/client/project-operations-review.d.ts +6 -0
- package/dist/core/client/project-operations-review.d.ts.map +1 -1
- package/dist/core/client/project-operations-review.js +6 -0
- package/dist/core/client/project-operations-review.js.map +1 -1
- package/dist/core/client/project-operations-workspace.d.ts +4 -0
- package/dist/core/client/project-operations-workspace.d.ts.map +1 -1
- package/dist/core/client/project-operations.d.ts +4 -0
- package/dist/core/client/project-operations.d.ts.map +1 -1
- package/dist/core/client/session-handle.d.ts +0 -2
- package/dist/core/client/session-handle.d.ts.map +1 -1
- package/dist/core/client/session-lifecycle-security.d.ts +0 -14
- package/dist/core/client/session-lifecycle-security.d.ts.map +1 -1
- package/dist/core/client/session-lifecycle-security.js +0 -14
- package/dist/core/client/session-lifecycle-security.js.map +1 -1
- package/dist/core/http/abort-error.js +1 -1
- package/dist/core/http/abort-error.js.map +1 -1
- package/dist/core/http/request.d.ts.map +1 -1
- package/dist/core/http/request.js +1 -3
- package/dist/core/http/request.js.map +1 -1
- package/dist/core/rest/platform-client/host-boundary.d.ts +21 -3
- package/dist/core/rest/platform-client/host-boundary.d.ts.map +1 -1
- package/dist/core/rest/platform-client/host-boundary.js +14 -1
- package/dist/core/rest/platform-client/host-boundary.js.map +1 -1
- package/dist/core/rest/projects-client/account-secret-resources.d.ts +4 -2
- 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/admin-providers.d.ts +12 -0
- package/dist/core/rest/projects-client/admin-providers.d.ts.map +1 -1
- package/dist/core/rest/projects-client/admin-providers.js.map +1 -1
- package/dist/core/rest/projects-client/agent-directory.d.ts +37 -0
- package/dist/core/rest/projects-client/agent-directory.d.ts.map +1 -0
- package/dist/core/rest/projects-client/agent-directory.js +29 -0
- package/dist/core/rest/projects-client/agent-directory.js.map +1 -0
- package/dist/core/rest/projects-client/artifacts.d.ts +34 -0
- package/dist/core/rest/projects-client/artifacts.d.ts.map +1 -1
- package/dist/core/rest/projects-client/artifacts.js +13 -0
- package/dist/core/rest/projects-client/artifacts.js.map +1 -1
- package/dist/core/rest/projects-client/asks.d.ts +2 -0
- package/dist/core/rest/projects-client/asks.d.ts.map +1 -1
- package/dist/core/rest/projects-client/asks.js.map +1 -1
- package/dist/core/rest/projects-client/dictation.d.ts +40 -0
- package/dist/core/rest/projects-client/dictation.d.ts.map +1 -0
- package/dist/core/rest/projects-client/dictation.js +47 -0
- package/dist/core/rest/projects-client/dictation.js.map +1 -0
- package/dist/core/rest/projects-client/iam-actions.d.ts +20 -120
- package/dist/core/rest/projects-client/iam-actions.d.ts.map +1 -1
- package/dist/core/rest/projects-client/iam-actions.js +13 -152
- package/dist/core/rest/projects-client/iam-actions.js.map +1 -1
- package/dist/core/rest/projects-client/index.d.ts +2 -1
- package/dist/core/rest/projects-client/index.d.ts.map +1 -1
- package/dist/core/rest/projects-client/index.js +2 -1
- package/dist/core/rest/projects-client/index.js.map +1 -1
- package/dist/core/rest/projects-client/projects.d.ts +21 -12
- package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
- package/dist/core/rest/projects-client/projects.js +4 -3
- package/dist/core/rest/projects-client/projects.js.map +1 -1
- package/dist/core/rest/projects-client/secrets.d.ts +3 -1
- package/dist/core/rest/projects-client/secrets.d.ts.map +1 -1
- package/dist/core/rest/projects-client/secrets.js.map +1 -1
- package/dist/core/rest/projects-client/session-costs.d.ts +43 -0
- package/dist/core/rest/projects-client/session-costs.d.ts.map +1 -1
- package/dist/core/rest/projects-client/session-costs.js +78 -0
- package/dist/core/rest/projects-client/session-costs.js.map +1 -1
- package/dist/core/rest/projects-client/sessions.d.ts +5 -157
- package/dist/core/rest/projects-client/sessions.d.ts.map +1 -1
- package/dist/core/rest/projects-client/sessions.js +3 -67
- package/dist/core/rest/projects-client/sessions.js.map +1 -1
- package/dist/core/rest/projects-client/spaces.d.ts +27 -0
- package/dist/core/rest/projects-client/spaces.d.ts.map +1 -1
- package/dist/core/rest/projects-client/spaces.js +7 -0
- package/dist/core/rest/projects-client/spaces.js.map +1 -1
- package/dist/core/rest/projects-client/workspaces.d.ts +2 -1
- package/dist/core/rest/projects-client/workspaces.d.ts.map +1 -1
- package/dist/core/rest/projects-client/workspaces.js +2 -1
- package/dist/core/rest/projects-client/workspaces.js.map +1 -1
- package/dist/core/session/open-bundle.d.ts +5 -9
- package/dist/core/session/open-bundle.d.ts.map +1 -1
- package/dist/core/session/open-bundle.js +6 -8
- package/dist/core/session/open-bundle.js.map +1 -1
- package/dist/core/session/runtime-actions.d.ts +0 -10
- package/dist/core/session/runtime-actions.d.ts.map +1 -1
- package/dist/core/session/runtime-actions.js +0 -25
- package/dist/core/session/runtime-actions.js.map +1 -1
- package/dist/core/session-log/saved-log.d.ts +5 -18
- package/dist/core/session-log/saved-log.d.ts.map +1 -1
- package/dist/core/session-log/saved-log.js +0 -16
- package/dist/core/session-log/saved-log.js.map +1 -1
- package/dist/core/session-log/source.d.ts +12 -0
- package/dist/core/session-log/source.d.ts.map +1 -1
- package/dist/core/session-log/source.js +3 -1
- package/dist/core/session-log/source.js.map +1 -1
- package/dist/core/session-log/store.d.ts +14 -1
- package/dist/core/session-log/store.d.ts.map +1 -1
- package/dist/core/session-log/store.js +59 -9
- package/dist/core/session-log/store.js.map +1 -1
- package/dist/core/session-log/sync-controller.d.ts +36 -0
- package/dist/core/session-log/sync-controller.d.ts.map +1 -0
- package/dist/core/session-log/sync-controller.js +274 -0
- package/dist/core/session-log/sync-controller.js.map +1 -0
- package/dist/core/session-log/turns/agent-runs.d.ts.map +1 -1
- package/dist/core/session-log/turns/agent-runs.js +108 -14
- package/dist/core/session-log/turns/agent-runs.js.map +1 -1
- package/dist/core/session-sync/copy-store-types.d.ts +6 -7
- package/dist/core/session-sync/copy-store-types.d.ts.map +1 -1
- package/dist/core/session-sync/copy-store-types.js +5 -0
- package/dist/core/session-sync/copy-store-types.js.map +1 -1
- package/dist/core/session-sync/saved-copy-store.d.ts +27 -32
- package/dist/core/session-sync/saved-copy-store.d.ts.map +1 -1
- package/dist/core/session-sync/saved-copy-store.js +34 -91
- package/dist/core/session-sync/saved-copy-store.js.map +1 -1
- package/dist/core/session-sync/saved-transcript.d.ts +5 -26
- package/dist/core/session-sync/saved-transcript.d.ts.map +1 -1
- package/dist/core/session-sync/saved-transcript.js +8 -26
- package/dist/core/session-sync/saved-transcript.js.map +1 -1
- package/dist/core/turns/parts.d.ts.map +1 -1
- package/dist/core/turns/parts.js +40 -7
- package/dist/core/turns/parts.js.map +1 -1
- package/dist/core/turns/segments/group-steps.d.ts.map +1 -1
- package/dist/core/turns/segments/group-steps.js +5 -0
- package/dist/core/turns/segments/group-steps.js.map +1 -1
- package/dist/core/turns/segments/retried-agent-failures.d.ts +11 -0
- package/dist/core/turns/segments/retried-agent-failures.d.ts.map +1 -0
- package/dist/core/turns/segments/retried-agent-failures.js +38 -0
- package/dist/core/turns/segments/retried-agent-failures.js.map +1 -0
- package/dist/core/turns/segments/segment-turn.d.ts.map +1 -1
- package/dist/core/turns/segments/segment-turn.js +5 -0
- package/dist/core/turns/segments/segment-turn.js.map +1 -1
- package/dist/core/turns/segments/started-work.d.ts +2 -1
- package/dist/core/turns/segments/started-work.d.ts.map +1 -1
- package/dist/core/turns/segments/started-work.js +3 -2
- package/dist/core/turns/segments/started-work.js.map +1 -1
- package/dist/core/turns/state.d.ts.map +1 -1
- package/dist/core/turns/state.js +22 -81
- package/dist/core/turns/state.js.map +1 -1
- package/dist/genui/catalog.d.ts +4 -3
- package/dist/genui/catalog.d.ts.map +1 -1
- package/dist/genui/catalog.js +1 -1
- package/dist/genui/catalog.js.map +1 -1
- package/dist/genui/fence.d.ts +0 -12
- package/dist/genui/fence.d.ts.map +1 -1
- package/dist/genui/fence.js +2 -2
- package/dist/genui/fence.js.map +1 -1
- package/dist/genui/react/default-components.d.ts.map +1 -1
- package/dist/genui/react/default-components.js +2 -1
- package/dist/genui/react/default-components.js.map +1 -1
- package/dist/genui/urls.d.ts +1 -0
- package/dist/genui/urls.d.ts.map +1 -1
- package/dist/genui/urls.js +1 -0
- package/dist/genui/urls.js.map +1 -1
- package/dist/iam-actions.d.ts +148 -0
- package/dist/iam-actions.d.ts.map +1 -0
- package/dist/iam-actions.js +203 -0
- package/dist/iam-actions.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kortix.esm.min.js +61 -59
- package/dist/kortix.global.js +61 -59
- package/dist/node/app-viewer.d.ts.map +1 -1
- package/dist/node/app-viewer.js +1 -14
- package/dist/node/app-viewer.js.map +1 -1
- package/dist/node/auth.d.ts.map +1 -1
- package/dist/node/auth.js +5 -24
- package/dist/node/auth.js.map +1 -1
- package/dist/node/b64url.d.ts +4 -0
- package/dist/node/b64url.d.ts.map +1 -0
- package/dist/node/b64url.js +16 -0
- package/dist/node/b64url.js.map +1 -0
- package/dist/react/index.d.ts +3 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +4 -2
- package/dist/react/index.js.map +1 -1
- package/dist/react/query-keys.d.ts +3 -0
- package/dist/react/query-keys.d.ts.map +1 -1
- package/dist/react/query-keys.js +3 -0
- package/dist/react/query-keys.js.map +1 -1
- package/dist/react/session-cache-write.d.ts.map +1 -1
- package/dist/react/session-cache-write.js +2 -0
- 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-artifacts.d.ts +11 -1
- package/dist/react/use-artifacts.d.ts.map +1 -1
- package/dist/react/use-artifacts.js +28 -2
- package/dist/react/use-artifacts.js.map +1 -1
- package/dist/react/use-feature-flag.d.ts +2 -2
- package/dist/react/use-feature-flag.d.ts.map +1 -1
- package/dist/react/use-feature-flag.js +8 -4
- package/dist/react/use-feature-flag.js.map +1 -1
- package/dist/react/use-project-sessions.d.ts.map +1 -1
- package/dist/react/use-project-sessions.js +3 -2
- package/dist/react/use-project-sessions.js.map +1 -1
- package/dist/react/use-project-spaces.d.ts +6 -0
- package/dist/react/use-project-spaces.d.ts.map +1 -1
- package/dist/react/use-project-spaces.js +14 -1
- package/dist/react/use-project-spaces.js.map +1 -1
- package/dist/react/use-runtime-sessions/keys.d.ts +1 -4
- package/dist/react/use-runtime-sessions/keys.d.ts.map +1 -1
- package/dist/react/use-runtime-sessions/keys.js.map +1 -1
- package/dist/react/use-session-log.d.ts +22 -19
- package/dist/react/use-session-log.d.ts.map +1 -1
- package/dist/react/use-session-log.js +42 -325
- package/dist/react/use-session-log.js.map +1 -1
- package/dist/react/use-session-model-selection.d.ts +1 -0
- package/dist/react/use-session-model-selection.d.ts.map +1 -1
- package/dist/react/use-session-model-selection.js +2 -1
- package/dist/react/use-session-model-selection.js.map +1 -1
- package/dist/react/use-session-stream.d.ts.map +1 -1
- package/dist/react/use-session-stream.js +14 -42
- package/dist/react/use-session-stream.js.map +1 -1
- package/dist/react/use-session-sync.d.ts +12 -13
- package/dist/react/use-session-sync.d.ts.map +1 -1
- package/dist/react/use-session-sync.js +19 -100
- package/dist/react/use-session-sync.js.map +1 -1
- package/dist/react/use-session.d.ts +1 -1
- package/dist/react/use-session.d.ts.map +1 -1
- package/dist/react/use-session.js +4 -10
- package/dist/react/use-session.js.map +1 -1
- package/dist/react/use-workspace-agent-directory.d.ts +15 -0
- package/dist/react/use-workspace-agent-directory.d.ts.map +1 -0
- package/dist/react/use-workspace-agent-directory.js +28 -0
- package/dist/react/use-workspace-agent-directory.js.map +1 -0
- package/package.json +6 -2
- package/dist/browser/session-sync/server-transcript-mirror.d.ts +0 -69
- package/dist/browser/session-sync/server-transcript-mirror.d.ts.map +0 -1
- package/dist/browser/session-sync/server-transcript-mirror.js +0 -112
- package/dist/browser/session-sync/server-transcript-mirror.js.map +0 -1
- package/dist/core/rest/projects-client/public-session-shares.d.ts +0 -77
- package/dist/core/rest/projects-client/public-session-shares.d.ts.map +0 -1
- package/dist/core/rest/projects-client/public-session-shares.js +0 -74
- package/dist/core/rest/projects-client/public-session-shares.js.map +0 -1
|
@@ -2,21 +2,18 @@
|
|
|
2
2
|
* The last saved copies of a user's sessions, kept on the device.
|
|
3
3
|
*
|
|
4
4
|
* Opening a session painted nothing until the control plane answered with the
|
|
5
|
-
* saved
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* message id.
|
|
5
|
+
* session's saved history: skeleton rows for 0.3-2.3 s on every cold open, and
|
|
6
|
+
* for as long as the backend took when it was slow. With this store the next
|
|
7
|
+
* open paints the last copy as soon as the device reads it (one task after the
|
|
8
|
+
* first frame), and the fresh page reconciles into it by message id.
|
|
10
9
|
*
|
|
11
|
-
* WHAT IT STORES, AND WHY THAT IS SAFE. Only
|
|
12
|
-
*
|
|
13
|
-
* the
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* wrong, and the painting side keeps its root-identity guard
|
|
19
|
-
* (`shouldHydrateFromMirror`).
|
|
10
|
+
* WHAT IT STORES, AND WHY THAT IS SAFE. Only pages the SERVER sent: the newest
|
|
11
|
+
* page of the session log's root thread (`GET …/log`, `SessionLogPage`), which
|
|
12
|
+
* the daemon journals at each turn end. Every read validates the page
|
|
13
|
+
* (`isSessionLogPage`). It never stores the live transcript. An IndexedDB mirror
|
|
14
|
+
* of the live store was deleted (`5a7a43517f`) because its write test read the
|
|
15
|
+
* transcript's shape, missed a Stop, and painted a stopped turn as running. A
|
|
16
|
+
* server page has no client-side freshness test to get wrong.
|
|
20
17
|
*
|
|
21
18
|
* Framework-free: the host passes the storage (IndexedDB on web, through
|
|
22
19
|
* `indexedDBKeyValueStorage`; AsyncStorage on mobile) and the signed-in user.
|
|
@@ -24,7 +21,7 @@
|
|
|
24
21
|
* corrupt or missing store — costs only the old cold open; nothing throws.
|
|
25
22
|
*/
|
|
26
23
|
import type { KeyValueStorage } from '../cache/persisted-query-cache.js';
|
|
27
|
-
import type {
|
|
24
|
+
import type { SessionLogPage } from '../session-log/source.js';
|
|
28
25
|
export interface SavedCopyStoreOptions {
|
|
29
26
|
storage: KeyValueStorage;
|
|
30
27
|
/** The signed-in user. Only this user's copies are read or written. */
|
|
@@ -34,42 +31,40 @@ export interface SavedCopyStoreOptions {
|
|
|
34
31
|
/** Upper bound of all copies together, in UTF-16 code units. Default: 1,500,000. */
|
|
35
32
|
maxBytes?: number;
|
|
36
33
|
/**
|
|
37
|
-
* Upper bound of one session's copy, in UTF-16 code units. A larger
|
|
38
|
-
* keeps its newest messages that fit and pages the rest
|
|
39
|
-
* one whose newest message alone does not fit is not kept.
|
|
34
|
+
* Upper bound of one session's copy, in UTF-16 code units. A larger page
|
|
35
|
+
* keeps its newest messages that fit (`has_more: true`) and pages the rest
|
|
36
|
+
* from the server; one whose newest message alone does not fit is not kept.
|
|
37
|
+
* Default: 300,000.
|
|
40
38
|
*/
|
|
41
39
|
maxEnvelopeBytes?: number;
|
|
42
40
|
/** A copy older than this is not painted. Default: 14 days. */
|
|
43
41
|
maxAgeMs?: number;
|
|
44
|
-
/** Storage key prefix. Default: `kortix.saved-copy`. */
|
|
42
|
+
/** Storage key prefix. Copies live under `<namespace>.log`. Default: `kortix.saved-copy`. */
|
|
45
43
|
namespace?: string;
|
|
46
44
|
now?: () => number;
|
|
47
45
|
}
|
|
48
46
|
export interface SavedCopyStore {
|
|
49
|
-
/** The storage key of one session's copy
|
|
47
|
+
/** The storage key of one session's copy: `<namespace>.log:<user>:<project>/<session>`. */
|
|
50
48
|
keyFor(projectId: string, sessionId: string): string;
|
|
51
|
-
/** The last saved
|
|
52
|
-
read(projectId: string, sessionId: string):
|
|
49
|
+
/** The last saved page, synchronously when the storage is synchronous. */
|
|
50
|
+
read(projectId: string, sessionId: string): SessionLogPage | null | Promise<SessionLogPage | null>;
|
|
53
51
|
/**
|
|
54
|
-
* Keep `
|
|
55
|
-
*
|
|
56
|
-
*
|
|
52
|
+
* Keep `page` (the newest page of the session log's root thread) as this
|
|
53
|
+
* session's copy. A page that cannot be painted (invalid, or no messages)
|
|
54
|
+
* removes the copy instead: the server no longer vouches for one.
|
|
57
55
|
*/
|
|
58
|
-
write(projectId: string, sessionId: string,
|
|
56
|
+
write(projectId: string, sessionId: string, page: SessionLogPage): Promise<void>;
|
|
59
57
|
remove(projectId: string, sessionId: string): Promise<void>;
|
|
60
58
|
/** Forget every copy of this user. */
|
|
61
59
|
clear(): Promise<void>;
|
|
62
60
|
}
|
|
63
|
-
/** A copy worth painting: a non-empty mirror window that names its runtime root. */
|
|
64
|
-
export declare function isPaintableSavedCopy(envelope: SessionTranscriptSyncEnvelope | null | undefined): envelope is SessionTranscriptSyncEnvelope;
|
|
65
61
|
/**
|
|
66
|
-
* The
|
|
67
|
-
*
|
|
68
|
-
* read as the other. `remove` and `clear` forget both.
|
|
62
|
+
* The device's store of saved session-log pages, under `<namespace>.log`. It also deletes the
|
|
63
|
+
* v1 copies an older SDK kept under `<namespace>` (`RETIRED_V1_COPY`).
|
|
69
64
|
*/
|
|
70
65
|
export declare function createSavedCopyStore(options: SavedCopyStoreOptions): SavedCopyStore;
|
|
71
66
|
/**
|
|
72
|
-
* The store the session
|
|
67
|
+
* The store the session log paints from and writes to. The host sets it
|
|
73
68
|
* when a user signs in and sets `null` on sign-out (after `clear()`), because
|
|
74
69
|
* only the host knows who is signed in. With no store, opening a session
|
|
75
70
|
* behaves exactly as before: nothing is read or written on the device.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saved-copy-store.d.ts","sourceRoot":"","sources":["../../../src/core/session-sync/saved-copy-store.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"saved-copy-store.d.ts","sourceRoot":"","sources":["../../../src/core/session-sync/saved-copy-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,eAA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IAAI,CAEpE;AAED,wBAAgB,qBAAqB,IAAI,cAAc,GAAG,IAAI,CAE7D"}
|
|
@@ -2,120 +2,63 @@
|
|
|
2
2
|
* The last saved copies of a user's sessions, kept on the device.
|
|
3
3
|
*
|
|
4
4
|
* Opening a session painted nothing until the control plane answered with the
|
|
5
|
-
* saved
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* message id.
|
|
5
|
+
* session's saved history: skeleton rows for 0.3-2.3 s on every cold open, and
|
|
6
|
+
* for as long as the backend took when it was slow. With this store the next
|
|
7
|
+
* open paints the last copy as soon as the device reads it (one task after the
|
|
8
|
+
* first frame), and the fresh page reconciles into it by message id.
|
|
10
9
|
*
|
|
11
|
-
* WHAT IT STORES, AND WHY THAT IS SAFE. Only
|
|
12
|
-
*
|
|
13
|
-
* the
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* wrong, and the painting side keeps its root-identity guard
|
|
19
|
-
* (`shouldHydrateFromMirror`).
|
|
10
|
+
* WHAT IT STORES, AND WHY THAT IS SAFE. Only pages the SERVER sent: the newest
|
|
11
|
+
* page of the session log's root thread (`GET …/log`, `SessionLogPage`), which
|
|
12
|
+
* the daemon journals at each turn end. Every read validates the page
|
|
13
|
+
* (`isSessionLogPage`). It never stores the live transcript. An IndexedDB mirror
|
|
14
|
+
* of the live store was deleted (`5a7a43517f`) because its write test read the
|
|
15
|
+
* transcript's shape, missed a Stop, and painted a stopped turn as running. A
|
|
16
|
+
* server page has no client-side freshness test to get wrong.
|
|
20
17
|
*
|
|
21
18
|
* Framework-free: the host passes the storage (IndexedDB on web, through
|
|
22
19
|
* `indexedDBKeyValueStorage`; AsyncStorage on mobile) and the signed-in user.
|
|
23
20
|
* Both are asynchronous, so no read blocks a frame. Every failure — a full,
|
|
24
21
|
* corrupt or missing store — costs only the old cold open; nothing throws.
|
|
25
22
|
*/
|
|
26
|
-
import {
|
|
23
|
+
import { SESSION_LOG_COPY } from '../session-log/saved-log.js';
|
|
27
24
|
import { VERSION, createSavedCopyIndex, isPromise, then } from './saved-copy-index.js';
|
|
28
|
-
/** A copy worth painting: a non-empty mirror window that names its runtime root. */
|
|
29
|
-
export function isPaintableSavedCopy(envelope) {
|
|
30
|
-
return (!!envelope &&
|
|
31
|
-
envelope.available === true &&
|
|
32
|
-
envelope.source === 'mirror' &&
|
|
33
|
-
Array.isArray(envelope.messages) &&
|
|
34
|
-
envelope.messages.length > 0 &&
|
|
35
|
-
// A copy saved by an SDK before W4 names the root only `runtime_session_id`.
|
|
36
|
-
!!envelope.runtime_session_id);
|
|
37
|
-
}
|
|
38
25
|
const DEFAULT_MAX_SESSIONS = 12;
|
|
39
26
|
const DEFAULT_MAX_BYTES = 1_500_000;
|
|
40
27
|
const DEFAULT_MAX_ENVELOPE_BYTES = 300_000;
|
|
41
28
|
const DEFAULT_MAX_AGE_MS = 14 * 24 * 60 * 60 * 1000;
|
|
42
29
|
const DEFAULT_NAMESPACE = 'kortix.saved-copy';
|
|
43
30
|
/**
|
|
44
|
-
* The
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* when not even the newest message fits.
|
|
48
|
-
*
|
|
49
|
-
* Copies carry every tool call 1:1, so a 40-message window of a tool-heavy
|
|
50
|
-
* thread outgrows the bound. The newest messages are what the first frame
|
|
51
|
-
* shows; refusing the whole copy gave exactly those sessions a cold open.
|
|
31
|
+
* The v1 transcript window an SDK before the session-log major kept under `<namespace>:`.
|
|
32
|
+
* Never painted: a read deletes it, and `write`, `remove` and `clear` delete it too, so a
|
|
33
|
+
* device frees the space without a migration.
|
|
52
34
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const { messages } = stored.e;
|
|
58
|
-
if (messages.length === 0)
|
|
59
|
-
return null;
|
|
60
|
-
const trimmed = (keep) => {
|
|
61
|
-
const kept = messages.slice(messages.length - keep);
|
|
62
|
-
return JSON.stringify({
|
|
63
|
-
...stored,
|
|
64
|
-
e: {
|
|
65
|
-
...stored.e,
|
|
66
|
-
messages: kept,
|
|
67
|
-
message_count: kept.length,
|
|
68
|
-
complete: false,
|
|
69
|
-
next_cursor: String(kept[0].info.id),
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
// Count what fits from the newest message back, then confirm on the real
|
|
74
|
-
// text: the cursor and count fields change length with the cut.
|
|
75
|
-
let size = trimmed(1).length - JSON.stringify(messages[messages.length - 1]).length;
|
|
76
|
-
let keep = 0;
|
|
77
|
-
while (keep < messages.length) {
|
|
78
|
-
const next = JSON.stringify(messages[messages.length - 1 - keep]).length + (keep > 0 ? 1 : 0);
|
|
79
|
-
if (size + next > maxChars)
|
|
80
|
-
break;
|
|
81
|
-
size += next;
|
|
82
|
-
keep += 1;
|
|
83
|
-
}
|
|
84
|
-
for (; keep > 0; keep -= 1) {
|
|
85
|
-
const text = trimmed(keep);
|
|
86
|
-
if (text.length <= maxChars)
|
|
87
|
-
return text;
|
|
88
|
-
}
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
function capturedAtMs(envelope) {
|
|
92
|
-
const parsed = envelope.captured_at ? Date.parse(envelope.captured_at) : Number.NaN;
|
|
93
|
-
return Number.isFinite(parsed) ? parsed : 0;
|
|
94
|
-
}
|
|
95
|
-
const ENVELOPE = {
|
|
96
|
-
paintable: isPaintableSavedCopy,
|
|
97
|
-
fit: fitSavedCopy,
|
|
98
|
-
capturedAt: capturedAtMs,
|
|
35
|
+
const RETIRED_V1_COPY = {
|
|
36
|
+
paintable: (_value) => false,
|
|
37
|
+
fit: () => null,
|
|
38
|
+
capturedAt: () => 0,
|
|
99
39
|
};
|
|
100
40
|
/**
|
|
101
|
-
* The
|
|
102
|
-
*
|
|
103
|
-
* read as the other. `remove` and `clear` forget both.
|
|
41
|
+
* The device's store of saved session-log pages, under `<namespace>.log`. It also deletes the
|
|
42
|
+
* v1 copies an older SDK kept under `<namespace>` (`RETIRED_V1_COPY`).
|
|
104
43
|
*/
|
|
105
44
|
export function createSavedCopyStore(options) {
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
|
|
45
|
+
const namespace = options.namespace ?? DEFAULT_NAMESPACE;
|
|
46
|
+
const pages = createCopyStore({ ...options, namespace: `${namespace}.log` }, SESSION_LOG_COPY);
|
|
47
|
+
const retired = createCopyStore({ ...options, namespace }, RETIRED_V1_COPY);
|
|
48
|
+
return {
|
|
49
|
+
keyFor: pages.keyFor,
|
|
50
|
+
read: pages.read,
|
|
51
|
+
write: async (projectId, sessionId, page) => {
|
|
52
|
+
await pages.write(projectId, sessionId, page);
|
|
53
|
+
await retired.remove(projectId, sessionId);
|
|
54
|
+
},
|
|
110
55
|
remove: async (projectId, sessionId) => {
|
|
111
|
-
await Promise.all([
|
|
56
|
+
await Promise.all([pages.remove(projectId, sessionId), retired.remove(projectId, sessionId)]);
|
|
112
57
|
},
|
|
113
58
|
clear: async () => {
|
|
114
|
-
await Promise.all([
|
|
59
|
+
await Promise.all([pages.clear(), retired.clear()]);
|
|
115
60
|
},
|
|
116
61
|
};
|
|
117
|
-
registerSessionLogCopies(store, v2, v1.remove);
|
|
118
|
-
return store;
|
|
119
62
|
}
|
|
120
63
|
function createCopyStore(options, codec) {
|
|
121
64
|
const { storage, userId, maxSessions = DEFAULT_MAX_SESSIONS, maxBytes = DEFAULT_MAX_BYTES, maxEnvelopeBytes = DEFAULT_MAX_ENVELOPE_BYTES, maxAgeMs = DEFAULT_MAX_AGE_MS, namespace = DEFAULT_NAMESPACE, now = () => Date.now(), } = options;
|
|
@@ -217,7 +160,7 @@ function createCopyStore(options, codec) {
|
|
|
217
160
|
}
|
|
218
161
|
let currentStore = null;
|
|
219
162
|
/**
|
|
220
|
-
* The store the session
|
|
163
|
+
* The store the session log paints from and writes to. The host sets it
|
|
221
164
|
* when a user signs in and sets `null` on sign-out (after `clear()`), because
|
|
222
165
|
* only the host knows who is signed in. With no store, opening a session
|
|
223
166
|
* behaves exactly as before: nothing is read or written on the device.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saved-copy-store.js","sourceRoot":"","sources":["../../../src/core/session-sync/saved-copy-store.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"saved-copy-store.js","sourceRoot":"","sources":["../../../src/core/session-sync/saved-copy-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,IAAI,EAAmB,MAAM,oBAAoB,CAAC;AAwCrG,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AACpC,MAAM,0BAA0B,GAAG,OAAO,CAAC;AAC3C,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACpD,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAE9C;;;;GAIG;AACH,MAAM,eAAe,GAAqB;IACxC,SAAS,EAAE,CAAC,MAAM,EAAmB,EAAE,CAAC,KAAK;IAC7C,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI;IACf,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA8B;IACjE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,iBAAiB,CAAC;IACzD,MAAM,KAAK,GAAG,eAAe,CAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,GAAG,SAAS,MAAM,EAAE,EAAE,gBAAgB,CAAC,CAAC;IAC/F,MAAM,OAAO,GAAG,eAAe,CAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,EAAE,eAAe,CAAC,CAAC;IAC5E,OAAO;QACL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,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;wBACtB,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC;oBAC3D,CAAC;gBACH,CAAC;gBACD,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;YACxB,CAAC,CAAC,CAAC;QACL,CAAC;QAED,MAAM,CAAC,SAAS,EAAE,SAAS;YACzB,OAAO,WAAW,CAAC,GAAG,SAAS,IAAI,SAAS,EAAE,CAAC,CAAC;QAClD,CAAC;QAED,KAAK;YACH,OAAO,OAAO,CAAC,KAAK,IAAI,EAAE;gBACxB,MAAM,OAAO,GAAG,MAAM,SAAS,EAAE,CAAC;gBAClC,KAAK,MAAM,KAAK,IAAI,OAAO;oBAAE,MAAM,UAAU,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;gBACrE,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC;AAED,IAAI,YAAY,GAA0B,IAAI,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA4B;IAC5D,YAAY,GAAG,KAAK,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,qBAAqB;IACnC,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -20,14 +20,8 @@
|
|
|
20
20
|
* its reads yet (no signed-in user) says `loading`: an unknown is never
|
|
21
21
|
* rendered as a negative.
|
|
22
22
|
*/
|
|
23
|
-
import { type SessionTranscriptSyncEnvelope } from '../rest/projects-client/sessions.js';
|
|
24
23
|
import { type SessionLogPage } from '../session-log/source.js';
|
|
25
24
|
export interface SavedSessionCopy {
|
|
26
|
-
/**
|
|
27
|
-
* @deprecated Always null: no v1 saved copy is read (`GET …/transcript`, P8.3). The session
|
|
28
|
-
* log's page is `log`. Removed in the next major.
|
|
29
|
-
*/
|
|
30
|
-
envelope: SessionTranscriptSyncEnvelope | null;
|
|
31
25
|
/**
|
|
32
26
|
* The conversation is proven empty, with nothing to wait for
|
|
33
27
|
* ({@link isEmptyConversation}): show the composer, not a boot screen.
|
|
@@ -43,13 +37,12 @@ export interface SavedSessionCopy {
|
|
|
43
37
|
* The saved copy of a session, for a host that shows the session before
|
|
44
38
|
* `useSession` binds it (a connecting view while the computer wakes).
|
|
45
39
|
*
|
|
46
|
-
* The session log
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
40
|
+
* The session log's newest page of the root thread (`GET …/log`), as `log`. The host puts it
|
|
41
|
+
* in the session store (`applySessionLogPage`) and renders `useSessionLogThread`, which loads a
|
|
42
|
+
* sub-agent's thread from the heads that page names. `useSession` reads the page again at the
|
|
43
|
+
* bind.
|
|
50
44
|
*
|
|
51
|
-
* Any other answer (a 404, a failed read, an invalid page) answers no copy: `log: null`.
|
|
52
|
-
* window is read (`GET …/transcript`, P8.3).
|
|
45
|
+
* Any other answer (a 404, a failed read, an invalid page) answers no copy: `log: null`.
|
|
53
46
|
*
|
|
54
47
|
* The turn record is read only when the page proves `runtimeSessionId` empty. Never throws.
|
|
55
48
|
*/
|
|
@@ -59,11 +52,6 @@ export declare function readSavedSessionCopy(input: {
|
|
|
59
52
|
sessionId: string;
|
|
60
53
|
/** The runtime session the copy belongs to (the root). */
|
|
61
54
|
runtimeSessionId: string;
|
|
62
|
-
/**
|
|
63
|
-
* @deprecated Ignored: the session log is always read, and no v1 window. The project flag
|
|
64
|
-
* `session_log` it carried is gone.
|
|
65
|
-
*/
|
|
66
|
-
sessionLog?: boolean;
|
|
67
55
|
}): Promise<SavedSessionCopy>;
|
|
68
56
|
export type SavedTranscript = 'loading' | 'shown' | 'none';
|
|
69
57
|
export interface SavedTranscriptInput {
|
|
@@ -96,15 +84,6 @@ export interface SavedTranscriptInput {
|
|
|
96
84
|
emptyAwaitingTurnRead?: boolean;
|
|
97
85
|
}
|
|
98
86
|
export declare function resolveSavedTranscript(input: SavedTranscriptInput): SavedTranscript;
|
|
99
|
-
/**
|
|
100
|
-
* The runtime root a saved window proves EMPTY, or null.
|
|
101
|
-
*
|
|
102
|
-
* The proof is the server's: a complete read of the runtime that found no
|
|
103
|
-
* messages, served as an available, complete window that counts zero. `total`
|
|
104
|
-
* must say so explicitly; an older API sends none and never answers an empty
|
|
105
|
-
* window as available.
|
|
106
|
-
*/
|
|
107
|
-
export declare function savedCopyEmptyRoot(envelope: SessionTranscriptSyncEnvelope | null | undefined): string | null;
|
|
108
87
|
export interface EmptyConversationInput {
|
|
109
88
|
/**
|
|
110
89
|
* The runtime root the server's saved copy proves empty: a complete read of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saved-transcript.d.ts","sourceRoot":"","sources":["../../../src/core/session-sync/saved-transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;
|
|
1
|
+
{"version":3,"file":"saved-transcript.d.ts","sourceRoot":"","sources":["../../../src/core/session-sync/saved-transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAiD,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI3G,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,GAAG,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAC7B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,gBAAgB,EAAE,MAAM,CAAC;CAC1B,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAQ5B;AAqBD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAE3D,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,OAAO,EAAE,OAAO,CAAC;IACjB,oEAAoE;IACpE,WAAW,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,OAAO,EAAE,KAAK,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IAClD;;;;OAIG;IACH,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IAClD;;;;OAIG;IACH,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;IACtC;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,oBAAoB,GAAG,eAAe,CAUnF;AAED,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,uEAAuE;IACvE,aAAa,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,EAAE,OAAO,CAAC;IAClB,0DAA0D;IAC1D,YAAY,EAAE,OAAO,CAAC;IACtB,+DAA+D;IAC/D,mBAAmB,EAAE,OAAO,CAAC;CAC9B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAQ1E"}
|
|
@@ -28,26 +28,25 @@ import { sessionLogRoot } from '../session-log/v1-view.js';
|
|
|
28
28
|
* The saved copy of a session, for a host that shows the session before
|
|
29
29
|
* `useSession` binds it (a connecting view while the computer wakes).
|
|
30
30
|
*
|
|
31
|
-
* The session log
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
31
|
+
* The session log's newest page of the root thread (`GET …/log`), as `log`. The host puts it
|
|
32
|
+
* in the session store (`applySessionLogPage`) and renders `useSessionLogThread`, which loads a
|
|
33
|
+
* sub-agent's thread from the heads that page names. `useSession` reads the page again at the
|
|
34
|
+
* bind.
|
|
35
35
|
*
|
|
36
|
-
* Any other answer (a 404, a failed read, an invalid page) answers no copy: `log: null`.
|
|
37
|
-
* window is read (`GET …/transcript`, P8.3).
|
|
36
|
+
* Any other answer (a 404, a failed read, an invalid page) answers no copy: `log: null`.
|
|
38
37
|
*
|
|
39
38
|
* The turn record is read only when the page proves `runtimeSessionId` empty. Never throws.
|
|
40
39
|
*/
|
|
41
40
|
export async function readSavedSessionCopy(input) {
|
|
42
41
|
const { projectId, sessionId, runtimeSessionId } = input;
|
|
43
42
|
if (!projectId || !sessionId || !runtimeSessionId)
|
|
44
|
-
return {
|
|
43
|
+
return { empty: false };
|
|
45
44
|
const log = await readFirstSessionLogAnswer(loadSessionLogPage, projectId, sessionId);
|
|
46
45
|
if (!log || log === 'missing')
|
|
47
|
-
return {
|
|
46
|
+
return { empty: false, log: null };
|
|
48
47
|
const root = sessionLogRoot(applySessionLogPage(EMPTY_SESSION_LOG_STATE, log));
|
|
49
48
|
const provenEmpty = !!root?.empty && root.runtimeSessionId === runtimeSessionId;
|
|
50
|
-
return {
|
|
49
|
+
return { empty: provenEmpty && (await noTurnSince(projectId, sessionId, runtimeSessionId)), log };
|
|
51
50
|
}
|
|
52
51
|
/**
|
|
53
52
|
* A page proved `runtimeSessionId` empty: no turn ended since and none is open (the page is
|
|
@@ -87,23 +86,6 @@ export function resolveSavedTranscript(input) {
|
|
|
87
86
|
return 'none';
|
|
88
87
|
return 'loading';
|
|
89
88
|
}
|
|
90
|
-
/**
|
|
91
|
-
* The runtime root a saved window proves EMPTY, or null.
|
|
92
|
-
*
|
|
93
|
-
* The proof is the server's: a complete read of the runtime that found no
|
|
94
|
-
* messages, served as an available, complete window that counts zero. `total`
|
|
95
|
-
* must say so explicitly; an older API sends none and never answers an empty
|
|
96
|
-
* window as available.
|
|
97
|
-
*/
|
|
98
|
-
export function savedCopyEmptyRoot(envelope) {
|
|
99
|
-
return envelope?.available &&
|
|
100
|
-
envelope.source === 'mirror' &&
|
|
101
|
-
envelope.complete &&
|
|
102
|
-
envelope.total === 0 &&
|
|
103
|
-
envelope.messages.length === 0
|
|
104
|
-
? (envelope.runtime_session_id ?? null)
|
|
105
|
-
: null;
|
|
106
|
-
}
|
|
107
89
|
/**
|
|
108
90
|
* Is this session's conversation empty, with nothing to wait for?
|
|
109
91
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saved-transcript.js","sourceRoot":"","sources":["../../../src/core/session-sync/saved-transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"saved-transcript.js","sourceRoot":"","sources":["../../../src/core/session-sync/saved-transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAuB,MAAM,uBAAuB,CAAC;AAC3G,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAexD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,KAM1C;IACC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;IACzD,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,IAAI,CAAC,gBAAgB;QAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC3E,MAAM,GAAG,GAAG,MAAM,yBAAyB,CAAC,kBAAkB,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IACtF,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;IAClE,MAAM,IAAI,GAAG,cAAc,CAAC,mBAAmB,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SAAS,EAAE,SAAS,CAAC,EAAE,EACvB,MAAM,EAAE,MAAM,GACb,CAAC,GAAG,SAAS,CAEf;AAcD,oDAAoD;AACpD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG7C"}
|
package/dist/core/turns/parts.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Split out of `turns/index.ts` — see that file's history for the original
|
|
7
7
|
* single-file version. No React / DOM / framework imports allowed.
|
|
8
8
|
*/
|
|
9
|
-
import { isReadAction, kortixPlatformTool } from './tools/kortix-tool-card.js';
|
|
9
|
+
import { isReadAction, kortixPlatformTool, parseKortixToolResult } from './tools/kortix-tool-card.js';
|
|
10
10
|
import { unwrapError } from './errors.js';
|
|
11
11
|
import { isToolCallBlock, toolPartOf } from '../session-log/tool-call.js';
|
|
12
12
|
import { inputPath, toolKind } from './tool-kind.js';
|
|
@@ -97,24 +97,57 @@ export function isToolPartHidden(part, messageId, hidden) {
|
|
|
97
97
|
// Tool part filtering
|
|
98
98
|
// ============================================================================
|
|
99
99
|
const HIDDEN_TOOLS = new Set(['todoread', 'context_info']);
|
|
100
|
+
/** A tool call's result text: the session-log block's content, or a v1 part's output. */
|
|
101
|
+
function resultText(part) {
|
|
102
|
+
if (isToolCallBlock(part)) {
|
|
103
|
+
if (part.status !== 'complete')
|
|
104
|
+
return undefined;
|
|
105
|
+
return (part.result?.content ?? []).map((item) => (item.type === 'text' ? item.text : '')).join('');
|
|
106
|
+
}
|
|
107
|
+
const output = part.state?.output;
|
|
108
|
+
return typeof output === 'string' ? output : undefined;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Reading another session that has not answered yet (`kortix_sessions` read,
|
|
112
|
+
* no answer) is the agent checking in. It tells the person nothing, and the
|
|
113
|
+
* turn says what the agent does next, so the step stays out of the transcript.
|
|
114
|
+
* A read that found an answer still shows.
|
|
115
|
+
*/
|
|
116
|
+
function isUnansweredSessionRead(part, name, input) {
|
|
117
|
+
if (kortixPlatformTool(name) !== 'kortix_sessions')
|
|
118
|
+
return false;
|
|
119
|
+
const action = typeof input === 'object' && input !== null ? input.action : undefined;
|
|
120
|
+
const text = resultText(part);
|
|
121
|
+
// A read still running has no answer yet: it stays out until one comes back,
|
|
122
|
+
// so the row never shows and then vanishes. A read that failed shows.
|
|
123
|
+
const status = isToolCallBlock(part) ? part.status : part.state?.status;
|
|
124
|
+
if (action === 'read' && (status === 'pending' || status === 'running'))
|
|
125
|
+
return true;
|
|
126
|
+
const result = parseKortixToolResult(text, name);
|
|
127
|
+
if (!result?.ok || result.action !== 'read')
|
|
128
|
+
return false;
|
|
129
|
+
const answer = result.data?.answer;
|
|
130
|
+
return typeof answer !== 'string' || !answer.trim();
|
|
131
|
+
}
|
|
100
132
|
/**
|
|
101
|
-
* Reading the agent roster (`kortix_agents` list or get)
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* change to an agent (create, update,
|
|
133
|
+
* Reading the agent roster (`kortix_agents` list or get) or the models an agent
|
|
134
|
+
* can run (`models`) is the agent checking what it can call before it acts. The
|
|
135
|
+
* person never asked for it, and the turn says what the agent decided, so the
|
|
136
|
+
* step stays out of the transcript. A change to an agent (create, update,
|
|
137
|
+
* delete) still shows.
|
|
105
138
|
*/
|
|
106
139
|
function isAgentRosterRead(name, input) {
|
|
107
140
|
if (kortixPlatformTool(name) !== 'kortix_agents')
|
|
108
141
|
return false;
|
|
109
142
|
const action = typeof input === 'object' && input !== null ? input.action : undefined;
|
|
110
|
-
return isReadAction(action);
|
|
143
|
+
return action === 'models' || isReadAction(action);
|
|
111
144
|
}
|
|
112
145
|
export function shouldShowToolPart(part) {
|
|
113
146
|
const name = isToolCallBlock(part) ? part.name : part.tool;
|
|
114
147
|
if (HIDDEN_TOOLS.has(name))
|
|
115
148
|
return false;
|
|
116
149
|
const input = isToolCallBlock(part) ? part.input : part.state?.input;
|
|
117
|
-
return !isAgentRosterRead(name, input);
|
|
150
|
+
return !isAgentRosterRead(name, input) && !isUnansweredSessionRead(part, name, input);
|
|
118
151
|
}
|
|
119
152
|
// ============================================================================
|
|
120
153
|
// Child session helpers
|