@kortix/sdk 0.16.4 → 0.16.5

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.
Files changed (153) hide show
  1. package/README.md +50 -10
  2. package/dist/browser/cache/idb-sync-cache.d.ts +6 -18
  3. package/dist/browser/cache/idb-sync-cache.d.ts.map +1 -1
  4. package/dist/browser/cache/idb-sync-cache.js +7 -22
  5. package/dist/browser/cache/idb-sync-cache.js.map +1 -1
  6. package/dist/browser/session-sync/session-scope.d.ts +10 -0
  7. package/dist/browser/session-sync/session-scope.d.ts.map +1 -0
  8. package/dist/browser/session-sync/session-scope.js +18 -0
  9. package/dist/browser/session-sync/session-scope.js.map +1 -0
  10. package/dist/browser/session-sync/session-sync-registry.d.ts +0 -2
  11. package/dist/browser/session-sync/session-sync-registry.d.ts.map +1 -1
  12. package/dist/browser/session-sync/session-sync-registry.js +4 -4
  13. package/dist/browser/session-sync/session-sync-registry.js.map +1 -1
  14. package/dist/browser/stores/sync-store.d.ts +4 -2
  15. package/dist/browser/stores/sync-store.d.ts.map +1 -1
  16. package/dist/browser/stores/sync-store.js +2 -2
  17. package/dist/browser/stores/sync-store.js.map +1 -1
  18. package/dist/core/client/kortix.d.ts +8 -6
  19. package/dist/core/client/kortix.d.ts.map +1 -1
  20. package/dist/core/client/project-core.d.ts +5 -0
  21. package/dist/core/client/project-core.d.ts.map +1 -1
  22. package/dist/core/client/project-core.js +5 -0
  23. package/dist/core/client/project-core.js.map +1 -1
  24. package/dist/core/client/session-handle.d.ts +0 -2
  25. package/dist/core/client/session-handle.d.ts.map +1 -1
  26. package/dist/core/client/session-lifecycle-security.d.ts +0 -14
  27. package/dist/core/client/session-lifecycle-security.d.ts.map +1 -1
  28. package/dist/core/client/session-lifecycle-security.js +0 -14
  29. package/dist/core/client/session-lifecycle-security.js.map +1 -1
  30. package/dist/core/rest/platform-client/host-boundary.d.ts +21 -3
  31. package/dist/core/rest/platform-client/host-boundary.d.ts.map +1 -1
  32. package/dist/core/rest/platform-client/host-boundary.js +14 -1
  33. package/dist/core/rest/platform-client/host-boundary.js.map +1 -1
  34. package/dist/core/rest/projects-client/artifacts.d.ts +34 -0
  35. package/dist/core/rest/projects-client/artifacts.d.ts.map +1 -1
  36. package/dist/core/rest/projects-client/artifacts.js +13 -0
  37. package/dist/core/rest/projects-client/artifacts.js.map +1 -1
  38. package/dist/core/rest/projects-client/dictation.d.ts +40 -0
  39. package/dist/core/rest/projects-client/dictation.d.ts.map +1 -0
  40. package/dist/core/rest/projects-client/dictation.js +47 -0
  41. package/dist/core/rest/projects-client/dictation.js.map +1 -0
  42. package/dist/core/rest/projects-client/index.d.ts +1 -1
  43. package/dist/core/rest/projects-client/index.d.ts.map +1 -1
  44. package/dist/core/rest/projects-client/index.js +1 -1
  45. package/dist/core/rest/projects-client/index.js.map +1 -1
  46. package/dist/core/rest/projects-client/projects.d.ts +14 -11
  47. package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
  48. package/dist/core/rest/projects-client/projects.js +1 -3
  49. package/dist/core/rest/projects-client/projects.js.map +1 -1
  50. package/dist/core/rest/projects-client/secrets.d.ts +3 -1
  51. package/dist/core/rest/projects-client/secrets.d.ts.map +1 -1
  52. package/dist/core/rest/projects-client/secrets.js.map +1 -1
  53. package/dist/core/rest/projects-client/sessions.d.ts +5 -157
  54. package/dist/core/rest/projects-client/sessions.d.ts.map +1 -1
  55. package/dist/core/rest/projects-client/sessions.js +3 -67
  56. package/dist/core/rest/projects-client/sessions.js.map +1 -1
  57. package/dist/core/rest/projects-client/workspaces.d.ts +2 -1
  58. package/dist/core/rest/projects-client/workspaces.d.ts.map +1 -1
  59. package/dist/core/rest/projects-client/workspaces.js +2 -1
  60. package/dist/core/rest/projects-client/workspaces.js.map +1 -1
  61. package/dist/core/session/open-bundle.d.ts +5 -9
  62. package/dist/core/session/open-bundle.d.ts.map +1 -1
  63. package/dist/core/session/open-bundle.js +6 -8
  64. package/dist/core/session/open-bundle.js.map +1 -1
  65. package/dist/core/session/runtime-actions.d.ts +0 -10
  66. package/dist/core/session/runtime-actions.d.ts.map +1 -1
  67. package/dist/core/session/runtime-actions.js +0 -25
  68. package/dist/core/session/runtime-actions.js.map +1 -1
  69. package/dist/core/session-log/saved-log.d.ts +5 -18
  70. package/dist/core/session-log/saved-log.d.ts.map +1 -1
  71. package/dist/core/session-log/saved-log.js +0 -16
  72. package/dist/core/session-log/saved-log.js.map +1 -1
  73. package/dist/core/session-log/source.d.ts +12 -0
  74. package/dist/core/session-log/source.d.ts.map +1 -1
  75. package/dist/core/session-log/source.js +3 -1
  76. package/dist/core/session-log/source.js.map +1 -1
  77. package/dist/core/session-log/store.d.ts +14 -1
  78. package/dist/core/session-log/store.d.ts.map +1 -1
  79. package/dist/core/session-log/store.js +59 -9
  80. package/dist/core/session-log/store.js.map +1 -1
  81. package/dist/core/session-log/turns/agent-runs.d.ts.map +1 -1
  82. package/dist/core/session-log/turns/agent-runs.js +108 -14
  83. package/dist/core/session-log/turns/agent-runs.js.map +1 -1
  84. package/dist/core/session-sync/copy-store-types.d.ts +6 -7
  85. package/dist/core/session-sync/copy-store-types.d.ts.map +1 -1
  86. package/dist/core/session-sync/copy-store-types.js +5 -0
  87. package/dist/core/session-sync/copy-store-types.js.map +1 -1
  88. package/dist/core/session-sync/saved-copy-store.d.ts +27 -32
  89. package/dist/core/session-sync/saved-copy-store.d.ts.map +1 -1
  90. package/dist/core/session-sync/saved-copy-store.js +34 -91
  91. package/dist/core/session-sync/saved-copy-store.js.map +1 -1
  92. package/dist/core/session-sync/saved-transcript.d.ts +5 -26
  93. package/dist/core/session-sync/saved-transcript.d.ts.map +1 -1
  94. package/dist/core/session-sync/saved-transcript.js +8 -26
  95. package/dist/core/session-sync/saved-transcript.js.map +1 -1
  96. package/dist/core/turns/parts.d.ts.map +1 -1
  97. package/dist/core/turns/parts.js +40 -7
  98. package/dist/core/turns/parts.js.map +1 -1
  99. package/dist/core/turns/segments/group-steps.d.ts.map +1 -1
  100. package/dist/core/turns/segments/group-steps.js +5 -0
  101. package/dist/core/turns/segments/group-steps.js.map +1 -1
  102. package/dist/core/turns/segments/retried-agent-failures.d.ts +11 -0
  103. package/dist/core/turns/segments/retried-agent-failures.d.ts.map +1 -0
  104. package/dist/core/turns/segments/retried-agent-failures.js +38 -0
  105. package/dist/core/turns/segments/retried-agent-failures.js.map +1 -0
  106. package/dist/core/turns/segments/segment-turn.d.ts.map +1 -1
  107. package/dist/core/turns/segments/segment-turn.js +5 -0
  108. package/dist/core/turns/segments/segment-turn.js.map +1 -1
  109. package/dist/core/turns/segments/started-work.d.ts +2 -1
  110. package/dist/core/turns/segments/started-work.d.ts.map +1 -1
  111. package/dist/core/turns/segments/started-work.js +3 -2
  112. package/dist/core/turns/segments/started-work.js.map +1 -1
  113. package/dist/index.d.ts +2 -2
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.js +1 -1
  116. package/dist/index.js.map +1 -1
  117. package/dist/kortix.esm.min.js +58 -58
  118. package/dist/kortix.global.js +59 -59
  119. package/dist/node/auth.d.ts.map +1 -1
  120. package/dist/node/auth.js +4 -10
  121. package/dist/node/auth.js.map +1 -1
  122. package/dist/react/index.d.ts +1 -1
  123. package/dist/react/index.d.ts.map +1 -1
  124. package/dist/react/index.js +1 -1
  125. package/dist/react/index.js.map +1 -1
  126. package/dist/react/use-artifacts.d.ts +11 -1
  127. package/dist/react/use-artifacts.d.ts.map +1 -1
  128. package/dist/react/use-artifacts.js +28 -2
  129. package/dist/react/use-artifacts.js.map +1 -1
  130. package/dist/react/use-feature-flag.d.ts +2 -2
  131. package/dist/react/use-feature-flag.d.ts.map +1 -1
  132. package/dist/react/use-feature-flag.js +8 -4
  133. package/dist/react/use-feature-flag.js.map +1 -1
  134. package/dist/react/use-session-log.d.ts +22 -19
  135. package/dist/react/use-session-log.d.ts.map +1 -1
  136. package/dist/react/use-session-log.js +73 -107
  137. package/dist/react/use-session-log.js.map +1 -1
  138. package/dist/react/use-session-sync.d.ts +11 -12
  139. package/dist/react/use-session-sync.d.ts.map +1 -1
  140. package/dist/react/use-session-sync.js +19 -100
  141. package/dist/react/use-session-sync.js.map +1 -1
  142. package/dist/react/use-session.d.ts.map +1 -1
  143. package/dist/react/use-session.js +4 -10
  144. package/dist/react/use-session.js.map +1 -1
  145. package/package.json +2 -2
  146. package/dist/browser/session-sync/server-transcript-mirror.d.ts +0 -69
  147. package/dist/browser/session-sync/server-transcript-mirror.d.ts.map +0 -1
  148. package/dist/browser/session-sync/server-transcript-mirror.js +0 -112
  149. package/dist/browser/session-sync/server-transcript-mirror.js.map +0 -1
  150. package/dist/core/rest/projects-client/public-session-shares.d.ts +0 -77
  151. package/dist/core/rest/projects-client/public-session-shares.d.ts.map +0 -1
  152. package/dist/core/rest/projects-client/public-session-shares.js +0 -74
  153. 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 copy it captured at the last turn end: skeleton rows for 0.3-2.3 s on
6
- * every cold open, and for as long as the backend took when it was slow. With
7
- * this store the next open paints the last copy as soon as the device reads it
8
- * (one task after the first frame), and the fresh one reconciles into it by
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 envelopes the SERVER sent: the
12
- * transcript mirror, which the API writes because a turn ended, carrying
13
- * the runtime's `info` verbatim (`time.completed` and `error` included) and the
14
- * runtime root it was captured from. It never stores the live transcript. An
15
- * IndexedDB mirror of the live store was deleted (`5a7a43517f`) because its
16
- * write test read the transcript's shape, missed a Stop, and painted a stopped
17
- * turn as running. A server capture has no client-side freshness test to get
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 { SessionTranscriptSyncEnvelope } from '../rest/projects-client/sessions.js';
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 copy
38
- * keeps its newest messages that fit and pages the rest from the server;
39
- * one whose newest message alone does not fit is not kept. Default: 300,000.
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 copy, synchronously when the storage is synchronous. */
52
- read(projectId: string, sessionId: string): SessionTranscriptSyncEnvelope | null | Promise<SessionTranscriptSyncEnvelope | null>;
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 `envelope` as this session's copy. An envelope that cannot be painted
55
- * (unavailable, empty, rootless) removes the copy instead: the server no
56
- * longer vouches for one. An older capture never replaces a newer one.
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, envelope: SessionTranscriptSyncEnvelope): Promise<void>;
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 v1 store. A second store under `<namespace>.log` keeps the v2 copies (the session-log
67
- * page, `core/session-log/saved-log.ts`): a separate key, so a copy one format wrote is never
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 transcript paints from and writes to. The host sets it
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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAKtF,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,eAAe,CAAC;IACzB,uEAAuE;IACvE,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oFAAoF;IACpF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,6CAA6C;IAC7C,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IACrD,0EAA0E;IAC1E,IAAI,CACF,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,6BAA6B,GAAG,IAAI,GAAG,OAAO,CAAC,6BAA6B,GAAG,IAAI,CAAC,CAAC;IACxF;;;;OAIG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpG,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA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AC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACnG;;;;OAIG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjF,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,sCAAsC;IACtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAmBD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAkBnF;AA+GD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,GAAG,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 copy it captured at the last turn end: skeleton rows for 0.3-2.3 s on
6
- * every cold open, and for as long as the backend took when it was slow. With
7
- * this store the next open paints the last copy as soon as the device reads it
8
- * (one task after the first frame), and the fresh one reconciles into it by
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 envelopes the SERVER sent: the
12
- * transcript mirror, which the API writes because a turn ended, carrying
13
- * the runtime's `info` verbatim (`time.completed` and `error` included) and the
14
- * runtime root it was captured from. It never stores the live transcript. An
15
- * IndexedDB mirror of the live store was deleted (`5a7a43517f`) because its
16
- * write test read the transcript's shape, missed a Stop, and painted a stopped
17
- * turn as running. A server capture has no client-side freshness test to get
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 { registerSessionLogCopies, SESSION_LOG_COPY } from '../session-log/saved-log.js';
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 serialized copy to keep within `maxChars`: the whole copy when it fits,
45
- * else its NEWEST messages that fit, with the cursor moved to the oldest one
46
- * kept (the server serves the window strictly older than the cursor). Null
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
- function fitSavedCopy(stored, maxChars) {
54
- const whole = JSON.stringify(stored);
55
- if (whole.length <= maxChars)
56
- return whole;
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 v1 store. A second store under `<namespace>.log` keeps the v2 copies (the session-log
102
- * page, `core/session-log/saved-log.ts`): a separate key, so a copy one format wrote is never
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 v1 = createCopyStore(options, ENVELOPE);
107
- const v2 = createCopyStore({ ...options, namespace: `${options.namespace ?? DEFAULT_NAMESPACE}.log` }, SESSION_LOG_COPY);
108
- const store = {
109
- ...v1,
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([v1.remove(projectId, sessionId), v2.remove(projectId, sessionId)]);
56
+ await Promise.all([pages.remove(projectId, sessionId), retired.remove(projectId, sessionId)]);
112
57
  },
113
58
  clear: async () => {
114
- await Promise.all([v1.clear(), v2.clear()]);
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 transcript paints from and writes to. The host sets it
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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEtF,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,IAAI,EAAmB,MAAM,oBAAoB,CAAC;AA0CrG,oFAAoF;AACpF,MAAM,UAAU,oBAAoB,CAClC,QAA0D;IAE1D,OAAO,CACL,CAAC,CAAC,QAAQ;QACV,QAAQ,CAAC,SAAS,KAAK,IAAI;QAC3B,QAAQ,CAAC,MAAM,KAAK,QAAQ;QAC5B,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAChC,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;QAC5B,6EAA6E;QAC7E,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAC9B,CAAC;AACJ,CAAC;AAED,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;;;;;;;;;GASG;AACH,SAAS,YAAY,CAAC,MAAiD,EAAE,QAAgB;IACvF,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,KAAK,CAAC,MAAM,IAAI,QAAQ;QAA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
- 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 first: its newest page of the root thread (`GET …/log`), as `log` with
47
- * `envelope: null`. The host puts it in the session store (`applySessionLogPage`) and renders
48
- * `useSessionLogThread`, which loads a sub-agent's thread from the heads that page names.
49
- * `useSession` reads the page again at the bind. No v1 window is read then.
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`. No v1
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;AAEH,OAAO,EAAE,KAAK,6BAA6B,EAAkB,MAAM,kCAAkC,CAAC;AACtG,OAAO,EAAiD,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI3G,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,QAAQ,EAAE,6BAA6B,GAAG,IAAI,CAAC;IAC/C;;;OAGG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,GAAG,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAC7B;AAED;;;;;;;;;;;;;GAaG;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;IACzB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAQ5B;AAqBD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAE3D,MAAM,WAAW,oBAAoB;IACnC,6EAA6E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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 first: its newest page of the root thread (`GET …/log`), as `log` with
32
- * `envelope: null`. The host puts it in the session store (`applySessionLogPage`) and renders
33
- * `useSessionLogThread`, which loads a sub-agent's thread from the heads that page names.
34
- * `useSession` reads the page again at the bind. No v1 window is read then.
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`. No v1
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 { envelope: null, empty: false };
43
+ return { empty: false };
45
44
  const log = await readFirstSessionLogAnswer(loadSessionLogPage, projectId, sessionId);
46
45
  if (!log || log === 'missing')
47
- return { envelope: null, empty: false, log: null };
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 { envelope: null, empty: provenEmpty && (await noTurnSince(projectId, sessionId, runtimeSessionId)), log };
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,EAAsC,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACtG,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;AAoBxD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,KAW1C;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,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC3F,MAAM,GAAG,GAAG,MAAM,yBAAyB,CAAC,kBAAkB,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IACtF,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;IAClF,MAAM,IAAI,GAAG,cAAc,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
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) is the agent checking
102
- * who it can call before it acts. The person never asked for it, and the turn
103
- * says what the agent decided, so the step stays out of the transcript. A
104
- * change to an agent (create, update, delete) still shows.
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