@kortix/sdk 0.13.29 → 0.13.30

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 (156) hide show
  1. package/dist/core/client/kortix.d.ts +4 -0
  2. package/dist/core/client/kortix.d.ts.map +1 -1
  3. package/dist/core/client/kortix.js +2 -0
  4. package/dist/core/client/kortix.js.map +1 -1
  5. package/dist/core/http/api-client.js.map +1 -1
  6. package/dist/core/rest/projects-client/accounts.d.ts +5 -0
  7. package/dist/core/rest/projects-client/accounts.d.ts.map +1 -1
  8. package/dist/core/rest/projects-client/accounts.js.map +1 -1
  9. package/dist/core/rest/projects-client/agent-config.d.ts +8 -0
  10. package/dist/core/rest/projects-client/agent-config.d.ts.map +1 -1
  11. package/dist/core/rest/projects-client/agent-config.js.map +1 -1
  12. package/dist/core/rest/projects-client/apps.d.ts +14 -0
  13. package/dist/core/rest/projects-client/apps.d.ts.map +1 -1
  14. package/dist/core/rest/projects-client/apps.js +4 -0
  15. package/dist/core/rest/projects-client/apps.js.map +1 -1
  16. package/dist/core/rest/projects-client/audit.d.ts +4 -0
  17. package/dist/core/rest/projects-client/audit.d.ts.map +1 -1
  18. package/dist/core/rest/projects-client/audit.js.map +1 -1
  19. package/dist/core/rest/projects-client/gateway.d.ts +4 -8
  20. package/dist/core/rest/projects-client/gateway.d.ts.map +1 -1
  21. package/dist/core/rest/projects-client/gateway.js.map +1 -1
  22. package/dist/core/rest/projects-client/index.d.ts +1 -0
  23. package/dist/core/rest/projects-client/index.d.ts.map +1 -1
  24. package/dist/core/rest/projects-client/index.js +1 -0
  25. package/dist/core/rest/projects-client/index.js.map +1 -1
  26. package/dist/core/rest/projects-client/projects.d.ts +15 -1
  27. package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
  28. package/dist/core/rest/projects-client/projects.js +1 -0
  29. package/dist/core/rest/projects-client/projects.js.map +1 -1
  30. package/dist/core/rest/projects-client/review-items.d.ts +173 -0
  31. package/dist/core/rest/projects-client/review-items.d.ts.map +1 -0
  32. package/dist/core/rest/projects-client/review-items.js +260 -0
  33. package/dist/core/rest/projects-client/review-items.js.map +1 -0
  34. package/dist/core/rest/projects-client/session-costs.d.ts +7 -9
  35. package/dist/core/rest/projects-client/session-costs.d.ts.map +1 -1
  36. package/dist/core/rest/projects-client/session-costs.js.map +1 -1
  37. package/dist/core/turns/index.d.ts +3 -0
  38. package/dist/core/turns/index.d.ts.map +1 -1
  39. package/dist/core/turns/index.js +2 -0
  40. package/dist/core/turns/index.js.map +1 -1
  41. package/dist/core/turns/segments/burst-summary.d.ts +49 -0
  42. package/dist/core/turns/segments/burst-summary.d.ts.map +1 -0
  43. package/dist/core/turns/segments/burst-summary.js +64 -0
  44. package/dist/core/turns/segments/burst-summary.js.map +1 -0
  45. package/dist/core/turns/segments/compaction-state.d.ts +44 -0
  46. package/dist/core/turns/segments/compaction-state.d.ts.map +1 -0
  47. package/dist/core/turns/segments/compaction-state.js +79 -0
  48. package/dist/core/turns/segments/compaction-state.js.map +1 -0
  49. package/dist/core/turns/segments/group-steps.d.ts +22 -0
  50. package/dist/core/turns/segments/group-steps.d.ts.map +1 -0
  51. package/dist/core/turns/segments/group-steps.js +89 -0
  52. package/dist/core/turns/segments/group-steps.js.map +1 -0
  53. package/dist/core/turns/segments/index.d.ts +21 -0
  54. package/dist/core/turns/segments/index.d.ts.map +1 -0
  55. package/dist/core/turns/segments/index.js +21 -0
  56. package/dist/core/turns/segments/index.js.map +1 -0
  57. package/dist/core/turns/segments/merge-steps.d.ts +79 -0
  58. package/dist/core/turns/segments/merge-steps.d.ts.map +1 -0
  59. package/dist/core/turns/segments/merge-steps.js +190 -0
  60. package/dist/core/turns/segments/merge-steps.js.map +1 -0
  61. package/dist/core/turns/segments/message-time.d.ts +86 -0
  62. package/dist/core/turns/segments/message-time.d.ts.map +1 -0
  63. package/dist/core/turns/segments/message-time.js +196 -0
  64. package/dist/core/turns/segments/message-time.js.map +1 -0
  65. package/dist/core/turns/segments/narration.d.ts +71 -0
  66. package/dist/core/turns/segments/narration.d.ts.map +1 -0
  67. package/dist/core/turns/segments/narration.js +836 -0
  68. package/dist/core/turns/segments/narration.js.map +1 -0
  69. package/dist/core/turns/segments/segment-turn.d.ts +26 -0
  70. package/dist/core/turns/segments/segment-turn.d.ts.map +1 -0
  71. package/dist/core/turns/segments/segment-turn.js +36 -0
  72. package/dist/core/turns/segments/segment-turn.js.map +1 -0
  73. package/dist/core/turns/segments/session-activity-groups.d.ts +93 -0
  74. package/dist/core/turns/segments/session-activity-groups.d.ts.map +1 -0
  75. package/dist/core/turns/segments/session-activity-groups.js +127 -0
  76. package/dist/core/turns/segments/session-activity-groups.js.map +1 -0
  77. package/dist/core/turns/segments/step-label.d.ts +44 -0
  78. package/dist/core/turns/segments/step-label.d.ts.map +1 -0
  79. package/dist/core/turns/segments/step-label.js +129 -0
  80. package/dist/core/turns/segments/step-label.js.map +1 -0
  81. package/dist/core/turns/segments/turn-busy-visibility.d.ts +51 -0
  82. package/dist/core/turns/segments/turn-busy-visibility.d.ts.map +1 -0
  83. package/dist/core/turns/segments/turn-busy-visibility.js +47 -0
  84. package/dist/core/turns/segments/turn-busy-visibility.js.map +1 -0
  85. package/dist/core/turns/segments/working-turn.d.ts +165 -0
  86. package/dist/core/turns/segments/working-turn.d.ts.map +1 -0
  87. package/dist/core/turns/segments/working-turn.js +168 -0
  88. package/dist/core/turns/segments/working-turn.js.map +1 -0
  89. package/dist/core/turns/text-scan.d.ts +65 -0
  90. package/dist/core/turns/text-scan.d.ts.map +1 -0
  91. package/dist/core/turns/text-scan.js +344 -0
  92. package/dist/core/turns/text-scan.js.map +1 -0
  93. package/dist/core/turns/tools/agent-helpers.d.ts +10 -0
  94. package/dist/core/turns/tools/agent-helpers.d.ts.map +1 -0
  95. package/dist/core/turns/tools/agent-helpers.js +54 -0
  96. package/dist/core/turns/tools/agent-helpers.js.map +1 -0
  97. package/dist/core/turns/tools/file-verb.d.ts +81 -0
  98. package/dist/core/turns/tools/file-verb.d.ts.map +1 -0
  99. package/dist/core/turns/tools/file-verb.js +70 -0
  100. package/dist/core/turns/tools/file-verb.js.map +1 -0
  101. package/dist/core/turns/tools/index.d.ts +22 -0
  102. package/dist/core/turns/tools/index.d.ts.map +1 -0
  103. package/dist/core/turns/tools/index.js +22 -0
  104. package/dist/core/turns/tools/index.js.map +1 -0
  105. package/dist/core/turns/tools/memory-helpers.d.ts +16 -0
  106. package/dist/core/turns/tools/memory-helpers.d.ts.map +1 -0
  107. package/dist/core/turns/tools/memory-helpers.js +55 -0
  108. package/dist/core/turns/tools/memory-helpers.js.map +1 -0
  109. package/dist/core/turns/tools/patch-summary.d.ts +53 -0
  110. package/dist/core/turns/tools/patch-summary.d.ts.map +1 -0
  111. package/dist/core/turns/tools/patch-summary.js +71 -0
  112. package/dist/core/turns/tools/patch-summary.js.map +1 -0
  113. package/dist/core/turns/tools/presentation-helpers.d.ts +16 -0
  114. package/dist/core/turns/tools/presentation-helpers.d.ts.map +1 -0
  115. package/dist/core/turns/tools/presentation-helpers.js +18 -0
  116. package/dist/core/turns/tools/presentation-helpers.js.map +1 -0
  117. package/dist/core/turns/tools/question-helpers.d.ts +10 -0
  118. package/dist/core/turns/tools/question-helpers.d.ts.map +1 -0
  119. package/dist/core/turns/tools/question-helpers.js +13 -0
  120. package/dist/core/turns/tools/question-helpers.js.map +1 -0
  121. package/dist/core/turns/tools/read-helpers.d.ts +8 -0
  122. package/dist/core/turns/tools/read-helpers.d.ts.map +1 -0
  123. package/dist/core/turns/tools/read-helpers.js +25 -0
  124. package/dist/core/turns/tools/read-helpers.js.map +1 -0
  125. package/dist/core/turns/tools/search-query.d.ts +28 -0
  126. package/dist/core/turns/tools/search-query.d.ts.map +1 -0
  127. package/dist/core/turns/tools/search-query.js +137 -0
  128. package/dist/core/turns/tools/search-query.js.map +1 -0
  129. package/dist/core/turns/tools/show-availability.d.ts +53 -0
  130. package/dist/core/turns/tools/show-availability.d.ts.map +1 -0
  131. package/dist/core/turns/tools/show-availability.js +110 -0
  132. package/dist/core/turns/tools/show-availability.js.map +1 -0
  133. package/dist/core/turns/tools/skill-helpers.d.ts +35 -0
  134. package/dist/core/turns/tools/skill-helpers.d.ts.map +1 -0
  135. package/dist/core/turns/tools/skill-helpers.js +129 -0
  136. package/dist/core/turns/tools/skill-helpers.js.map +1 -0
  137. package/dist/core/turns/tools/tool-meta.d.ts +72 -0
  138. package/dist/core/turns/tools/tool-meta.d.ts.map +1 -0
  139. package/dist/core/turns/tools/tool-meta.js +174 -0
  140. package/dist/core/turns/tools/tool-meta.js.map +1 -0
  141. package/dist/core/turns/tools/tool-outcome.d.ts +78 -0
  142. package/dist/core/turns/tools/tool-outcome.d.ts.map +1 -0
  143. package/dist/core/turns/tools/tool-outcome.js +244 -0
  144. package/dist/core/turns/tools/tool-outcome.js.map +1 -0
  145. package/dist/core/turns/tools/tool-output-format.d.ts +63 -0
  146. package/dist/core/turns/tools/tool-output-format.d.ts.map +1 -0
  147. package/dist/core/turns/tools/tool-output-format.js +174 -0
  148. package/dist/core/turns/tools/tool-output-format.js.map +1 -0
  149. package/dist/core/turns/tools/web-helpers.d.ts +40 -0
  150. package/dist/core/turns/tools/web-helpers.d.ts.map +1 -0
  151. package/dist/core/turns/tools/web-helpers.js +297 -0
  152. package/dist/core/turns/tools/web-helpers.js.map +1 -0
  153. package/dist/kortix.esm.min.js +42 -26
  154. package/dist/kortix.global.js +42 -26
  155. package/dist/react/sign-in-with-kortix.d.ts +3 -3
  156. package/package.json +2 -2
@@ -0,0 +1,79 @@
1
+ /**
2
+ * What a compaction turn amounts to — pure, so the marker/failed-row
3
+ * decisions in session-chat.tsx have a test that can fail (the component
4
+ * around them needs a DOM and this repo's `bun test` has none).
5
+ *
6
+ * A turn is a COMPACTION turn when a summary message is present. Usually that
7
+ * is an assistant message carrying the runtime's `summary: true` flag — but a
8
+ * summary message with NO user prompt to attach to becomes a SYNTHETIC turn
9
+ * (`groupMessagesIntoTurns`): the summary message IS `turn.userMessage` and
10
+ * `assistantMessages` is empty. Scanning only `assistantMessages` missed
11
+ * those, so each failed attempt rendered as an EMPTY normal turn — a 0px
12
+ * TurnViewport whose `contain-intrinsic-size: auto 600px` ballooned to a
13
+ * 600px blank block whenever `content-visibility` skipped it.
14
+ *
15
+ * It HAS CONTENT when a `compaction` part exists or a summary message has
16
+ * non-whitespace text. `inFlight` means a summary message is neither
17
+ * completed nor errored — the message-state half of "is this running", which
18
+ * the working projection cannot see (compaction "is not a turn" to it).
19
+ * `error` is the first summary message's raw error, needed because
20
+ * `getTurnError` also reads only `assistantMessages` and so reports nothing
21
+ * for a synthetic turn.
22
+ */
23
+ export function compactionTurnInfo(turn) {
24
+ let isCompaction = false;
25
+ let hasContent = false;
26
+ let inFlight = false;
27
+ let error = null;
28
+ const scanSummaryInfo = (raw) => {
29
+ const info = raw;
30
+ if (info?.summary !== true)
31
+ return false;
32
+ isCompaction = true;
33
+ if (!info.time?.completed && !info.error)
34
+ inFlight = true;
35
+ if (error == null && info.error != null)
36
+ error = info.error;
37
+ return true;
38
+ };
39
+ const scanParts = (parts) => {
40
+ for (const part of parts ?? []) {
41
+ if (part.type === 'compaction') {
42
+ isCompaction = true;
43
+ hasContent = true;
44
+ }
45
+ else if (part.type === 'text' && part.text?.trim()) {
46
+ hasContent = true;
47
+ }
48
+ }
49
+ };
50
+ // The REQUEST marker: opencode's `SessionCompaction.create` mints a user
51
+ // message whose only part is `type: "compaction"` — present from the moment
52
+ // an attempt starts, success or failure. It marks the turn as a compaction
53
+ // but is NOT content (it exists for attempts that summarised nothing) —
54
+ // that is what lets a failed attempt whose error landed on a PLAIN
55
+ // assistant message (the loop died before minting the summary-flagged one)
56
+ // still classify as a failed compaction instead of a bare error turn.
57
+ const userParts = turn.userMessage?.parts ?? [];
58
+ const hasRequestMarker = userParts.some((p) => p.type === 'compaction');
59
+ if (hasRequestMarker)
60
+ isCompaction = true;
61
+ // The synthetic-turn case: a summary message with no user prompt to attach
62
+ // to becomes the turn's userMessage. Its TEXT only counts under the summary
63
+ // flag, so a real user prompt's text can never count as summary content.
64
+ if (turn.userMessage && scanSummaryInfo(turn.userMessage.info)) {
65
+ scanParts(turn.userMessage.parts);
66
+ }
67
+ for (const msg of turn.assistantMessages) {
68
+ scanSummaryInfo(msg.info);
69
+ scanParts(msg.parts);
70
+ }
71
+ // Request accepted, reply not minted yet: the marker exists but no
72
+ // assistant message does — the gap between the compaction user message
73
+ // arriving and the summary message starting. Without this the turn reads
74
+ // "failed" for those frames and the failed row flickers in at stream start.
75
+ if (hasRequestMarker && turn.assistantMessages.length === 0)
76
+ inFlight = true;
77
+ return { isCompaction, hasContent, inFlight, error };
78
+ }
79
+ //# sourceMappingURL=compaction-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compaction-state.js","sourceRoot":"","sources":["../../../../src/core/turns/segments/compaction-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AA2BH,MAAM,UAAU,kBAAkB,CAAC,IAAwB;IACzD,IAAI,YAAY,GAAG,KAAK,CAAC;IACzB,IAAI,UAAU,GAAG,KAAK,CAAC;IACvB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,KAAK,GAAY,IAAI,CAAC;IAE1B,MAAM,eAAe,GAAG,CAAC,GAAY,EAAW,EAAE;QAChD,MAAM,IAAI,GAAG,GAAyC,CAAC;QACvD,IAAI,IAAI,EAAE,OAAO,KAAK,IAAI;YAAE,OAAO,KAAK,CAAC;QACzC,YAAY,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,QAAQ,GAAG,IAAI,CAAC;QAC1D,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI;YAAE,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5D,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IACF,MAAM,SAAS,GAAG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AC,MAAM,KAAK,CAAC;QAAE,QAAQ,GAAG,IAAI,CAAC;IAE7E,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AACvD,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Collapse an ordered ToolPart[] into the story Easy mode tells.
3
+ *
4
+ * Consecutive calls in the same family become one step ("Read 6 files", "Wrote 6 files"),
5
+ * which is what turns a 60-call run into an ~8-line narrative. Two tools are exempt:
6
+ * show / show_user are distinct artifacts the user has to actually see, so folding them
7
+ * would hide output. That rule already exists in `session-activity-groups.ts` — we reuse
8
+ * it rather than restate it.
9
+ */
10
+ import type { ToolPart } from '../../runtime/client.js';
11
+ import { type StepFamily } from './narration.js';
12
+ export interface Step {
13
+ /** Stable across re-renders: the callID of the step's first part. */
14
+ id: string;
15
+ family: StepFamily;
16
+ label: string;
17
+ parts: ToolPart[];
18
+ status: 'running' | 'error' | 'done';
19
+ durationMs?: number;
20
+ }
21
+ export declare function groupSteps(parts: ToolPart[]): Step[];
22
+ //# sourceMappingURL=group-steps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group-steps.d.ts","sourceRoot":"","sources":["../../../../src/core/turns/segments/group-steps.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,KAAK,UAAU,EAAiD,MAAM,aAAa,CAAC;AAE7F,MAAM,WAAW,IAAI;IACnB,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AA4CD,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,CAoCpD"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Collapse an ordered ToolPart[] into the story Easy mode tells.
3
+ *
4
+ * Consecutive calls in the same family become one step ("Read 6 files", "Wrote 6 files"),
5
+ * which is what turns a 60-call run into an ~8-line narrative. Two tools are exempt:
6
+ * show / show_user are distinct artifacts the user has to actually see, so folding them
7
+ * would hide output. That rule already exists in `session-activity-groups.ts` — we reuse
8
+ * it rather than restate it.
9
+ */
10
+ import { isEmptyShowPart, isNoGroupActivityTool } from './session-activity-groups.js';
11
+ import { familyForTool, narrateFailedStep, narrateStep } from './narration.js';
12
+ function statusOf(parts) {
13
+ if (parts.some((p) => p.state?.status === 'running' || p.state?.status === 'pending')) {
14
+ return 'running';
15
+ }
16
+ if (parts.some((p) => p.state?.status === 'error'))
17
+ return 'error';
18
+ return 'done';
19
+ }
20
+ /**
21
+ * Wall-clock duration of a step. `state.time` is not on the typed interface but
22
+ * is present at runtime — `advanced/advanced-panel.tsx` reads it the same way.
23
+ */
24
+ function durationOf(parts) {
25
+ let start = Number.POSITIVE_INFINITY;
26
+ let end = 0;
27
+ for (const p of parts) {
28
+ const time = p.state.time;
29
+ if (typeof time?.start === 'number')
30
+ start = Math.min(start, time.start);
31
+ if (typeof time?.end === 'number')
32
+ end = Math.max(end, time.end);
33
+ }
34
+ if (!Number.isFinite(start) || end <= start)
35
+ return undefined;
36
+ return end - start;
37
+ }
38
+ function finalize(family, parts) {
39
+ const status = statusOf(parts);
40
+ return {
41
+ id: parts[0].callID,
42
+ family,
43
+ // A failed step must never wear success wording — "Wrote budget.csv" for a
44
+ // write that errored is the panel lying (W7).
45
+ label: status === 'error' ? narrateFailedStep(family, parts) : narrateStep(family, parts),
46
+ parts,
47
+ status,
48
+ // A duration must never sit next to a live spinner — a running step may
49
+ // still carry stale/partial `time` data from a prior run of the same
50
+ // callID, and pairing that with the shimmer would visually claim the
51
+ // step is both finished and still going.
52
+ durationMs: status === 'running' ? undefined : durationOf(parts),
53
+ };
54
+ }
55
+ export function groupSteps(parts) {
56
+ const steps = [];
57
+ let family = null;
58
+ let buffer = [];
59
+ const flush = () => {
60
+ if (family && buffer.length)
61
+ steps.push(finalize(family, buffer));
62
+ family = null;
63
+ buffer = [];
64
+ };
65
+ for (const part of parts) {
66
+ const f = familyForTool(part.tool);
67
+ if (f === 'hidden')
68
+ continue; // dropped, and must not split a run
69
+ // A `show` that handed nothing over is hidden for the same reason: its own
70
+ // step would narrate "Showed you the result" and open onto an empty card.
71
+ // Dropped here, before the standalone branch, so it also cannot split a run.
72
+ if (isEmptyShowPart(part))
73
+ continue;
74
+ // show / show_user each stand alone.
75
+ if (isNoGroupActivityTool(part.tool)) {
76
+ flush();
77
+ steps.push(finalize(f, [part]));
78
+ continue;
79
+ }
80
+ if (f !== family) {
81
+ flush();
82
+ family = f;
83
+ }
84
+ buffer.push(part);
85
+ }
86
+ flush();
87
+ return steps;
88
+ }
89
+ //# sourceMappingURL=group-steps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group-steps.js","sourceRoot":"","sources":["../../../../src/core/turns/segments/group-steps.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAmB,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAY7F,SAAS,QAAQ,CAAC,KAAiB;IACjC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC,EAAE,CAAC;QACtF,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;Q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vs text vs standalone tools), same-family step
5
+ * grouping ("Read 6 files"), burst summaries ("Working · N steps"), thought
6
+ * merging ("Thought for 12s"), plain-language narration, the working-turn
7
+ * resolver, compaction state, and message timestamps. Pure data → data, no
8
+ * framework, so web and mobile render the same transcript from one source.
9
+ */
10
+ export * from './burst-summary.js';
11
+ export * from './compaction-state.js';
12
+ export * from './group-steps.js';
13
+ export * from './merge-steps.js';
14
+ export * from './message-time.js';
15
+ export * from './narration.js';
16
+ export * from './segment-turn.js';
17
+ export * from './session-activity-groups.js';
18
+ export * from './step-label.js';
19
+ export * from './working-turn.js';
20
+ export * from './turn-busy-visibility.js';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/turns/segments/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Transcript structure — how a turn's parts become the rows a reader sees.
3
+ *
4
+ * Segmentation (bursts vs text vs standalone tools), same-family step
5
+ * grouping ("Read 6 files"), burst summaries ("Working · N steps"), thought
6
+ * merging ("Thought for 12s"), plain-language narration, the working-turn
7
+ * resolver, compaction state, and message timestamps. Pure data → data, no
8
+ * framework, so web and mobile render the same transcript from one source.
9
+ */
10
+ export * from './burst-summary.js';
11
+ export * from './compaction-state.js';
12
+ export * from './group-steps.js';
13
+ export * from './merge-steps.js';
14
+ export * from './message-time.js';
15
+ export * from './narration.js';
16
+ export * from './segment-turn.js';
17
+ export * from './session-activity-groups.js';
18
+ export * from './step-label.js';
19
+ export * from './working-turn.js';
20
+ export * from './turn-busy-visibility.js';
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/turns/segments/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Burst parts → the rows a reader actually sees.
3
+ *
4
+ * Three rules, all about reducing the row count rather than the information:
5
+ *
6
+ * 1. Plumbing never appears. Memory reads/writes and context compaction are
7
+ * machinery the reader did not ask for and cannot act on.
8
+ * 2. A run of consecutive thinking collapses into ONE row. The model emits
9
+ * reasoning in fragments; rendering a row per fragment turns a single
10
+ * train of thought into a wall of near-identical lines.
11
+ * 3. A run of consecutive same-family tool calls collapses into ONE group
12
+ * row that opens to its members. Two reads and two commands are two pieces
13
+ * of work, not four; expanding a burst to seven flat siblings un-groups
14
+ * exactly what makes a 60-call run readable.
15
+ *
16
+ * A thought row also carries whether IT is the one still being written. That
17
+ * cannot be answered by the burst around it: a trailing burst reports "running"
18
+ * for the whole turn on purpose (so the disclosure does not blink shut between
19
+ * SSE tool calls), so a burst-wide flag makes every thought a turn ever emitted
20
+ * claim to be live — shimmering, and forcing its paragraph open, twenty steps
21
+ * after it closed. See `reasoningIsRunning` and the settle pass at the end of
22
+ * `mergeBurstSteps`.
23
+ *
24
+ * Rule 3 reuses `groupSteps` — the same model the Easy action panel renders
25
+ * from — rather than restating the family table here. There is one grouping
26
+ * implementation; two that must agree forever is the trap this avoids.
27
+ *
28
+ * No React import — every rule here is unit-tested.
29
+ */
30
+ import type { Part } from '../../runtime/client.js';
31
+ import { type Step } from './group-steps.js';
32
+ import type { StepTier } from './step-label.js';
33
+ export type BurstStep = {
34
+ kind: 'thought';
35
+ key: string;
36
+ texts: string[];
37
+ running: boolean;
38
+ /**
39
+ * How long the whole run of reasoning took, in ms — first fragment's
40
+ * `time.start` to the last one's `time.end`.
41
+ *
42
+ * Undefined when either end is missing (a live thought has no end yet,
43
+ * and some providers send no timing at all), so the row can tell "not
44
+ * timed" apart from "took no time" and fall back to the bare label
45
+ * rather than printing a zero.
46
+ */
47
+ durationMs?: number;
48
+ } | {
49
+ kind: 'part';
50
+ key: string;
51
+ part: Part;
52
+ } | {
53
+ kind: 'group';
54
+ key: string;
55
+ step: Step;
56
+ };
57
+ /**
58
+ * True while the model is still writing this reasoning fragment.
59
+ *
60
+ * A closed reasoning block carries `time.end`; an open one has a start and
61
+ * nothing else. Exported so `burstIsRunning` asks the same question in the same
62
+ * words — two copies of this predicate is exactly how a burst and the rows
63
+ * inside it end up disagreeing about who is still working.
64
+ */
65
+ export declare function reasoningIsRunning(part: Part): boolean;
66
+ /**
67
+ * `tierOf` is injected rather than imported so the merge rules can be tested
68
+ * without dragging the whole tool-name table in behind them.
69
+ */
70
+ export declare function mergeBurstSteps(parts: ReadonlyArray<Part>, tierOf: (part: Part) => StepTier): BurstStep[];
71
+ /**
72
+ * A run of thinking fragments → the one sentence the row shows.
73
+ *
74
+ * Fragments are joined, stripped of document markup, and given a "Thinking
75
+ * about" lead-in — unless they already open with a thinking verb, where the
76
+ * prefix would read as a stutter ("Thinking about thinking about…").
77
+ */
78
+ export declare function flattenThought(texts: ReadonlyArray<string>): string;
79
+ //# sourceMappingURL=merge-steps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-steps.d.ts","sourceRoot":"","sources":["../../../../src/core/turns/segments/merge-steps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAY,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,MAAM,SAAS,GACjB;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAE/C;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAGtD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,EAC1B,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,QAAQ,GAC/B,SAAS,EAAE,CAmHb;AAmBD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAkBnE"}
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Burst parts → the rows a reader actually sees.
3
+ *
4
+ * Three rules, all about reducing the row count rather than the information:
5
+ *
6
+ * 1. Plumbing never appears. Memory reads/writes and context compaction are
7
+ * machinery the reader did not ask for and cannot act on.
8
+ * 2. A run of consecutive thinking collapses into ONE row. The model emits
9
+ * reasoning in fragments; rendering a row per fragment turns a single
10
+ * train of thought into a wall of near-identical lines.
11
+ * 3. A run of consecutive same-family tool calls collapses into ONE group
12
+ * row that opens to its members. Two reads and two commands are two pieces
13
+ * of work, not four; expanding a burst to seven flat siblings un-groups
14
+ * exactly what makes a 60-call run readable.
15
+ *
16
+ * A thought row also carries whether IT is the one still being written. That
17
+ * cannot be answered by the burst around it: a trailing burst reports "running"
18
+ * for the whole turn on purpose (so the disclosure does not blink shut between
19
+ * SSE tool calls), so a burst-wide flag makes every thought a turn ever emitted
20
+ * claim to be live — shimmering, and forcing its paragraph open, twenty steps
21
+ * after it closed. See `reasoningIsRunning` and the settle pass at the end of
22
+ * `mergeBurstSteps`.
23
+ *
24
+ * Rule 3 reuses `groupSteps` — the same model the Easy action panel renders
25
+ * from — rather than restating the family table here. There is one grouping
26
+ * implementation; two that must agree forever is the trap this avoids.
27
+ *
28
+ * No React import — every rule here is unit-tested.
29
+ */
30
+ import { isReasoningPart, isToolPart } from '../parts.js';
31
+ import { groupSteps } from './group-steps.js';
32
+ /**
33
+ * True while the model is still writing this reasoning fragment.
34
+ *
35
+ * A closed reasoning block carries `time.end`; an open one has a start and
36
+ * nothing else. Exported so `burstIsRunning` asks the same question in the same
37
+ * words — two copies of this predicate is exactly how a burst and the rows
38
+ * inside it end up disagreeing about who is still working.
39
+ */
40
+ export function reasoningIsRunning(part) {
41
+ const end = part.time?.end;
42
+ return !(typeof end === 'number' && end > 0);
43
+ }
44
+ /**
45
+ * `tierOf` is injected rather than imported so the merge rules can be tested
46
+ * without dragging the whole tool-name table in behind them.
47
+ */
48
+ export function mergeBurstSteps(parts, tierOf) {
49
+ const steps = [];
50
+ let pending = null;
51
+ let tools = [];
52
+ const flushThought = () => {
53
+ if (pending && pending.texts.length > 0) {
54
+ // FIRST start to LAST end: the fragments of one thought are one stretch
55
+ // of thinking, and the row that merges them reports the stretch. A sum of
56
+ // per-fragment durations would silently drop the gaps between them.
57
+ const { startedAt, endedAt } = pending;
58
+ const durationMs = typeof startedAt === 'number' && typeof endedAt === 'number' && endedAt > startedAt
59
+ ? endedAt - startedAt
60
+ : undefined;
61
+ steps.push({
62
+ kind: 'thought',
63
+ key: pending.key,
64
+ texts: pending.texts,
65
+ running: pending.running,
66
+ durationMs,
67
+ });
68
+ }
69
+ pending = null;
70
+ };
71
+ /**
72
+ * The buffered run → its group rows, in order.
73
+ *
74
+ * A group of one is NOT wrapped. An expandable row holding a single call
75
+ * hides that call behind a click and says nothing the call did not already
76
+ * say — strictly worse than the flat row it replaced.
77
+ */
78
+ const flushTools = () => {
79
+ if (tools.length === 0)
80
+ return;
81
+ for (const step of groupSteps(tools)) {
82
+ steps.push(step.parts.length === 1
83
+ ? { kind: 'part', key: step.parts[0].id, part: step.parts[0] }
84
+ : { kind: 'group', key: `group-${step.parts[0].id}`, step });
85
+ }
86
+ tools = [];
87
+ };
88
+ for (const part of parts) {
89
+ // Machinery is dropped outright, and — importantly — without breaking the
90
+ // run around it, thinking or tool. A memory write between two thoughts
91
+ // should not split them into two rows, and one between two shells should
92
+ // not split "Ran 2 commands" into two singles.
93
+ if (tierOf(part) === 'plumbing')
94
+ continue;
95
+ if (isReasoningPart(part)) {
96
+ // Read the text before flushing: an empty fragment renders nothing, so
97
+ // it must not break the tool run it happens to sit inside either.
98
+ const text = part.text?.trim();
99
+ if (!text)
100
+ continue;
101
+ flushTools();
102
+ if (!pending)
103
+ pending = { key: `thought-${part.id}`, texts: [], running: false };
104
+ pending.texts.push(text);
105
+ const time = part.time;
106
+ if (pending.startedAt === undefined && typeof time?.start === 'number') {
107
+ pending.startedAt = time.start;
108
+ }
109
+ // The LAST fragment's end is the run's end, for the same reason it
110
+ // decides `running` below: an earlier fragment closes as the next opens.
111
+ pending.endedAt = typeof time?.end === 'number' && time.end > 0 ? time.end : undefined;
112
+ // The LAST fragment decides. Fragments arrive one at a time and each
113
+ // closes as the next opens, so an early `time.end` says nothing about
114
+ // whether the run as a whole is still being written.
115
+ pending.running = reasoningIsRunning(part);
116
+ continue;
117
+ }
118
+ flushThought();
119
+ if (isToolPart(part)) {
120
+ tools.push(part);
121
+ continue;
122
+ }
123
+ // Neither tool nor reasoning. `groupSteps` has no family for it and
124
+ // `ActivityStep` renders it as a bare label row — but it is still a part,
125
+ // and this module never silently drops one.
126
+ flushTools();
127
+ steps.push({ kind: 'part', key: part.id, part });
128
+ }
129
+ flushThought();
130
+ flushTools();
131
+ /**
132
+ * Only the final row can still be live.
133
+ *
134
+ * `time.end` is the provider's answer and this is the structural one: the
135
+ * model cannot call a tool and then keep writing the same reasoning block —
136
+ * more reasoning after the tool arrives as a NEW row. So a thought with any
137
+ * later step is finished, whatever its own timestamps say, and the rule holds
138
+ * even against a provider that never writes `time.end` at all.
139
+ *
140
+ * Dropped plumbing is not a later step: it renders no row, so it is no
141
+ * evidence the model stopped thinking.
142
+ */
143
+ for (let i = 0; i < steps.length - 1; i++) {
144
+ const step = steps[i];
145
+ if (step.kind === 'thought')
146
+ step.running = false;
147
+ }
148
+ return steps;
149
+ }
150
+ /** Words that already announce a thought, so the prefix would double up. */
151
+ const ALREADY_THINKING = /^(thinking|thought|considering|planning|deciding|weighing|exploring|analy[sz]ing|reasoning|working out|figuring)/i;
152
+ /** Markdown that carries no meaning once the block becomes a single sentence. */
153
+ function stripMarkdown(text) {
154
+ return text
155
+ .replace(/```[\s\S]*?```/g, ' ')
156
+ .replace(/`([^`]*)`/g, '$1')
157
+ .replace(/^#{1,6}\s*/gm, '')
158
+ .replace(/\*\*([^*]*)\*\*/g, '$1')
159
+ .replace(/(^|\s)[*_]([^*_]+)[*_]/g, '$1$2')
160
+ .replace(/^\s*[-*+]\s+/gm, '')
161
+ .replace(/\s+/g, ' ')
162
+ .trim();
163
+ }
164
+ /**
165
+ * A run of thinking fragments → the one sentence the row shows.
166
+ *
167
+ * Fragments are joined, stripped of document markup, and given a "Thinking
168
+ * about" lead-in — unless they already open with a thinking verb, where the
169
+ * prefix would read as a stutter ("Thinking about thinking about…").
170
+ */
171
+ export function flattenThought(texts) {
172
+ const joined = texts
173
+ .flatMap((text) => {
174
+ const stripped = stripMarkdown(text);
175
+ return stripped ? [stripped] : [];
176
+ })
177
+ .join(' ')
178
+ .trim();
179
+ if (!joined)
180
+ return 'Thinking';
181
+ if (ALREADY_THINKING.test(joined))
182
+ return joined;
183
+ // Lower-case the lead-in so it reads as one sentence — but only when the
184
+ // opening word is ordinary sentence case. Lowering "API" to "aPI" would be
185
+ // worse than the capital it replaced.
186
+ const isSentenceCased = /^[A-Z][a-z]/.test(joined);
187
+ const body = isSentenceCased ? joined[0].toLowerCase() + joined.slice(1) : joined;
188
+ return `Thinking about ${body}`;
189
+ }
190
+ //# sourceMappingURL=merge-steps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-steps.js","sourceRoot":"","sources":["../../../../src/core/turns/segments/merge-steps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AAuBtD;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAU;IAC3C,MAAM,GAAG,GAAI,IAAoC,CAAC,IAAI,EAAE,GAAG,CAAC;IAC5D,OAAO,CAAC,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,KAA0B,EAC1B,MAAgC;IAEhC,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,IAAI,OAAO,GAMA,IAAI,CAAC;IAChB,IAAI,KAAK,GAAe,EAAE,CAAC;IAE3B,MAAM,YAAY,GAAG,GAAG,EAAE;QACxB,IAAI,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxC,wEAAwE;YACxE,0EAA0E;YAC1E,oEAAo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CAAC;SACD,IAAI,CAAC,GAAG,CAAC;SACT,IAAI,EAAE,CAAC;IAEV,IAAI,CAAC,MAAM;QAAE,OAAO,UAAU,CAAC;IAC/B,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAEjD,yEAAyE;IACzE,2EAA2E;IAC3E,sCAAsC;IACtC,MAAM,eAAe,GAAG,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAClF,OAAO,kBAAkB,IAAI,EAAE,CAAC;AAClC,CAAC"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * When a message was sent, in the two registers a reader actually wants.
3
+ *
4
+ * **The label says how long ago. The hint says exactly when.** Recent messages
5
+ * are easiest to place by distance — "5 days ago" lands immediately, where a
6
+ * date makes you do arithmetic. Past a week that inverts: nobody counts to
7
+ * "23 days ago", so the label becomes the date itself. The precise instant,
8
+ * down to the second, lives one hover away and never clutters the thread.
9
+ *
10
+ * `now` is injected, never read here. Same reason the sibling
11
+ * `session-turn-meta-rows` does it: the wording is a pure function of two
12
+ * instants, so it stays testable, and one render derives every label from a
13
+ * single clock read instead of each row racing its own.
14
+ */
15
+ import type { MessageWithParts } from '../../../transcript.js';
16
+ /**
17
+ * `Message` is a union whose user and assistant arms carry different `time`
18
+ * shapes, and neither is on the shared `info` type — so `info.time` does not
19
+ * typecheck against the union. This narrow accessor is the one place that cast
20
+ * lives; `session-turn-meta-rows` imports it rather than keeping a second copy.
21
+ */
22
+ export declare function messageTime(message: MessageWithParts | undefined): {
23
+ created?: number;
24
+ completed?: number;
25
+ };
26
+ /**
27
+ * When the message was created, in epoch **milliseconds**, or `null` when the
28
+ * backend never stamped one.
29
+ *
30
+ * Milliseconds is not an assumption: `packages/sdk/src/transcript.ts` feeds the
31
+ * same field straight to `new Date(...)` with no `* 1000`, and hands
32
+ * `time.completed - time.created` to a `formatDuration(ms)`.
33
+ *
34
+ * `0` is rejected along with `NaN`: the epoch is not a plausible message time,
35
+ * so a zeroed field is missing data, not midnight in 1970.
36
+ */
37
+ export declare function messageCreatedAt(message: MessageWithParts | undefined): number | null;
38
+ export interface MessageTimeOptions {
39
+ /**
40
+ * IANA zone to render in. Omit for the viewer's own zone — which is what the
41
+ * browser should use, and exactly what a server render must NOT, since the
42
+ * server's zone is its own and the resulting text would not survive
43
+ * hydration.
44
+ */
45
+ timeZone?: string;
46
+ /**
47
+ * BCP-47 locale. Omit for the viewer's own — it decides 12- vs 24-hour, which
48
+ * is the whole reason not to hardcode `en-US` on the client.
49
+ */
50
+ locale?: string;
51
+ }
52
+ /**
53
+ * The label on screen.
54
+ *
55
+ * | When | Reads as (`en-US`) |
56
+ * | --------------- | ------------------ |
57
+ * | under a minute | `just now` |
58
+ * | under a week | `5 days ago` |
59
+ * | this year | `June 9` |
60
+ * | any older | `June 9, 2025` |
61
+ *
62
+ * Strict distance (`relativePast`) rather than a loose one: it never rounds up
63
+ * into a vague "about 1 minute", and the point of the label is a real
64
+ * distance, not an impression.
65
+ *
66
+ * `now` is `null` for a server render, where distance is unknowable: the
67
+ * server cannot know the viewer's clock, and guessing produces text that
68
+ * changes on hydration. `null` returns the dated form instead, so the string
69
+ * shown before hydration is never *wrong* — only less immediate than it will be.
70
+ *
71
+ * Returns `''` for a timestamp that is absent or unparseable, so the caller can
72
+ * render nothing rather than an `Invalid Date` placeholder.
73
+ */
74
+ export declare function formatMessageDay(timestamp: number | null | undefined, now: number | null, opts?: MessageTimeOptions): string;
75
+ /**
76
+ * The hover label: the full date and the time of day. `June 9, 2026 2:32 PM`.
77
+ *
78
+ * This is where the specifics belong. The label on screen is deliberately
79
+ * loose so the thread stays readable; hovering answers "when exactly" without
80
+ * that answer ever taking up room in the transcript.
81
+ *
82
+ * Minutes, not seconds. A second-level reading looks like it is worth reading
83
+ * and never is — nobody hovers a chat message to learn it landed at :05.
84
+ */
85
+ export declare function formatMessageExact(timestamp: number | null | undefined, opts?: MessageTimeOptions): string;
86
+ //# sourceMappingURL=message-time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-time.d.ts","sourceRoot":"","sources":["../../../../src/core/turns/segments/message-time.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,GAAG;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAIA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAIrF;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAoHD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,GAAG,EAAE,MAAM,GAAG,IAAI,EAClB,IAAI,GAAE,kBAAuB,GAC5B,MAAM,CAoBR;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,IAAI,GAAE,kBAAuB,GAC5B,MAAM,CAMR"}