@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.
- package/dist/core/client/kortix.d.ts +4 -0
- package/dist/core/client/kortix.d.ts.map +1 -1
- package/dist/core/client/kortix.js +2 -0
- package/dist/core/client/kortix.js.map +1 -1
- package/dist/core/http/api-client.js.map +1 -1
- package/dist/core/rest/projects-client/accounts.d.ts +5 -0
- package/dist/core/rest/projects-client/accounts.d.ts.map +1 -1
- package/dist/core/rest/projects-client/accounts.js.map +1 -1
- package/dist/core/rest/projects-client/agent-config.d.ts +8 -0
- package/dist/core/rest/projects-client/agent-config.d.ts.map +1 -1
- package/dist/core/rest/projects-client/agent-config.js.map +1 -1
- package/dist/core/rest/projects-client/apps.d.ts +14 -0
- package/dist/core/rest/projects-client/apps.d.ts.map +1 -1
- package/dist/core/rest/projects-client/apps.js +4 -0
- package/dist/core/rest/projects-client/apps.js.map +1 -1
- package/dist/core/rest/projects-client/audit.d.ts +4 -0
- package/dist/core/rest/projects-client/audit.d.ts.map +1 -1
- package/dist/core/rest/projects-client/audit.js.map +1 -1
- package/dist/core/rest/projects-client/gateway.d.ts +4 -8
- package/dist/core/rest/projects-client/gateway.d.ts.map +1 -1
- package/dist/core/rest/projects-client/gateway.js.map +1 -1
- package/dist/core/rest/projects-client/index.d.ts +1 -0
- package/dist/core/rest/projects-client/index.d.ts.map +1 -1
- package/dist/core/rest/projects-client/index.js +1 -0
- package/dist/core/rest/projects-client/index.js.map +1 -1
- package/dist/core/rest/projects-client/projects.d.ts +15 -1
- package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
- package/dist/core/rest/projects-client/projects.js +1 -0
- package/dist/core/rest/projects-client/projects.js.map +1 -1
- package/dist/core/rest/projects-client/review-items.d.ts +173 -0
- package/dist/core/rest/projects-client/review-items.d.ts.map +1 -0
- package/dist/core/rest/projects-client/review-items.js +260 -0
- package/dist/core/rest/projects-client/review-items.js.map +1 -0
- package/dist/core/rest/projects-client/session-costs.d.ts +7 -9
- package/dist/core/rest/projects-client/session-costs.d.ts.map +1 -1
- package/dist/core/rest/projects-client/session-costs.js.map +1 -1
- package/dist/core/turns/index.d.ts +3 -0
- package/dist/core/turns/index.d.ts.map +1 -1
- package/dist/core/turns/index.js +2 -0
- package/dist/core/turns/index.js.map +1 -1
- package/dist/core/turns/segments/burst-summary.d.ts +49 -0
- package/dist/core/turns/segments/burst-summary.d.ts.map +1 -0
- package/dist/core/turns/segments/burst-summary.js +64 -0
- package/dist/core/turns/segments/burst-summary.js.map +1 -0
- package/dist/core/turns/segments/compaction-state.d.ts +44 -0
- package/dist/core/turns/segments/compaction-state.d.ts.map +1 -0
- package/dist/core/turns/segments/compaction-state.js +79 -0
- package/dist/core/turns/segments/compaction-state.js.map +1 -0
- package/dist/core/turns/segments/group-steps.d.ts +22 -0
- package/dist/core/turns/segments/group-steps.d.ts.map +1 -0
- package/dist/core/turns/segments/group-steps.js +89 -0
- package/dist/core/turns/segments/group-steps.js.map +1 -0
- package/dist/core/turns/segments/index.d.ts +21 -0
- package/dist/core/turns/segments/index.d.ts.map +1 -0
- package/dist/core/turns/segments/index.js +21 -0
- package/dist/core/turns/segments/index.js.map +1 -0
- package/dist/core/turns/segments/merge-steps.d.ts +79 -0
- package/dist/core/turns/segments/merge-steps.d.ts.map +1 -0
- package/dist/core/turns/segments/merge-steps.js +190 -0
- package/dist/core/turns/segments/merge-steps.js.map +1 -0
- package/dist/core/turns/segments/message-time.d.ts +86 -0
- package/dist/core/turns/segments/message-time.d.ts.map +1 -0
- package/dist/core/turns/segments/message-time.js +196 -0
- package/dist/core/turns/segments/message-time.js.map +1 -0
- package/dist/core/turns/segments/narration.d.ts +71 -0
- package/dist/core/turns/segments/narration.d.ts.map +1 -0
- package/dist/core/turns/segments/narration.js +836 -0
- package/dist/core/turns/segments/narration.js.map +1 -0
- package/dist/core/turns/segments/segment-turn.d.ts +26 -0
- package/dist/core/turns/segments/segment-turn.d.ts.map +1 -0
- package/dist/core/turns/segments/segment-turn.js +36 -0
- package/dist/core/turns/segments/segment-turn.js.map +1 -0
- package/dist/core/turns/segments/session-activity-groups.d.ts +93 -0
- package/dist/core/turns/segments/session-activity-groups.d.ts.map +1 -0
- package/dist/core/turns/segments/session-activity-groups.js +127 -0
- package/dist/core/turns/segments/session-activity-groups.js.map +1 -0
- package/dist/core/turns/segments/step-label.d.ts +44 -0
- package/dist/core/turns/segments/step-label.d.ts.map +1 -0
- package/dist/core/turns/segments/step-label.js +129 -0
- package/dist/core/turns/segments/step-label.js.map +1 -0
- package/dist/core/turns/segments/turn-busy-visibility.d.ts +51 -0
- package/dist/core/turns/segments/turn-busy-visibility.d.ts.map +1 -0
- package/dist/core/turns/segments/turn-busy-visibility.js +47 -0
- package/dist/core/turns/segments/turn-busy-visibility.js.map +1 -0
- package/dist/core/turns/segments/working-turn.d.ts +165 -0
- package/dist/core/turns/segments/working-turn.d.ts.map +1 -0
- package/dist/core/turns/segments/working-turn.js +168 -0
- package/dist/core/turns/segments/working-turn.js.map +1 -0
- package/dist/core/turns/text-scan.d.ts +65 -0
- package/dist/core/turns/text-scan.d.ts.map +1 -0
- package/dist/core/turns/text-scan.js +344 -0
- package/dist/core/turns/text-scan.js.map +1 -0
- package/dist/core/turns/tools/agent-helpers.d.ts +10 -0
- package/dist/core/turns/tools/agent-helpers.d.ts.map +1 -0
- package/dist/core/turns/tools/agent-helpers.js +54 -0
- package/dist/core/turns/tools/agent-helpers.js.map +1 -0
- package/dist/core/turns/tools/file-verb.d.ts +81 -0
- package/dist/core/turns/tools/file-verb.d.ts.map +1 -0
- package/dist/core/turns/tools/file-verb.js +70 -0
- package/dist/core/turns/tools/file-verb.js.map +1 -0
- package/dist/core/turns/tools/index.d.ts +22 -0
- package/dist/core/turns/tools/index.d.ts.map +1 -0
- package/dist/core/turns/tools/index.js +22 -0
- package/dist/core/turns/tools/index.js.map +1 -0
- package/dist/core/turns/tools/memory-helpers.d.ts +16 -0
- package/dist/core/turns/tools/memory-helpers.d.ts.map +1 -0
- package/dist/core/turns/tools/memory-helpers.js +55 -0
- package/dist/core/turns/tools/memory-helpers.js.map +1 -0
- package/dist/core/turns/tools/patch-summary.d.ts +53 -0
- package/dist/core/turns/tools/patch-summary.d.ts.map +1 -0
- package/dist/core/turns/tools/patch-summary.js +71 -0
- package/dist/core/turns/tools/patch-summary.js.map +1 -0
- package/dist/core/turns/tools/presentation-helpers.d.ts +16 -0
- package/dist/core/turns/tools/presentation-helpers.d.ts.map +1 -0
- package/dist/core/turns/tools/presentation-helpers.js +18 -0
- package/dist/core/turns/tools/presentation-helpers.js.map +1 -0
- package/dist/core/turns/tools/question-helpers.d.ts +10 -0
- package/dist/core/turns/tools/question-helpers.d.ts.map +1 -0
- package/dist/core/turns/tools/question-helpers.js +13 -0
- package/dist/core/turns/tools/question-helpers.js.map +1 -0
- package/dist/core/turns/tools/read-helpers.d.ts +8 -0
- package/dist/core/turns/tools/read-helpers.d.ts.map +1 -0
- package/dist/core/turns/tools/read-helpers.js +25 -0
- package/dist/core/turns/tools/read-helpers.js.map +1 -0
- package/dist/core/turns/tools/search-query.d.ts +28 -0
- package/dist/core/turns/tools/search-query.d.ts.map +1 -0
- package/dist/core/turns/tools/search-query.js +137 -0
- package/dist/core/turns/tools/search-query.js.map +1 -0
- package/dist/core/turns/tools/show-availability.d.ts +53 -0
- package/dist/core/turns/tools/show-availability.d.ts.map +1 -0
- package/dist/core/turns/tools/show-availability.js +110 -0
- package/dist/core/turns/tools/show-availability.js.map +1 -0
- package/dist/core/turns/tools/skill-helpers.d.ts +35 -0
- package/dist/core/turns/tools/skill-helpers.d.ts.map +1 -0
- package/dist/core/turns/tools/skill-helpers.js +129 -0
- package/dist/core/turns/tools/skill-helpers.js.map +1 -0
- package/dist/core/turns/tools/tool-meta.d.ts +72 -0
- package/dist/core/turns/tools/tool-meta.d.ts.map +1 -0
- package/dist/core/turns/tools/tool-meta.js +174 -0
- package/dist/core/turns/tools/tool-meta.js.map +1 -0
- package/dist/core/turns/tools/tool-outcome.d.ts +78 -0
- package/dist/core/turns/tools/tool-outcome.d.ts.map +1 -0
- package/dist/core/turns/tools/tool-outcome.js +244 -0
- package/dist/core/turns/tools/tool-outcome.js.map +1 -0
- package/dist/core/turns/tools/tool-output-format.d.ts +63 -0
- package/dist/core/turns/tools/tool-output-format.d.ts.map +1 -0
- package/dist/core/turns/tools/tool-output-format.js +174 -0
- package/dist/core/turns/tools/tool-output-format.js.map +1 -0
- package/dist/core/turns/tools/web-helpers.d.ts +40 -0
- package/dist/core/turns/tools/web-helpers.d.ts.map +1 -0
- package/dist/core/turns/tools/web-helpers.js +297 -0
- package/dist/core/turns/tools/web-helpers.js.map +1 -0
- package/dist/kortix.esm.min.js +42 -26
- package/dist/kortix.global.js +42 -26
- package/dist/react/sign-in-with-kortix.d.ts +3 -3
- package/package.json +2 -2
|
@@ -0,0 +1,196 @@
|
|
|
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
|
+
/**
|
|
16
|
+
* `Message` is a union whose user and assistant arms carry different `time`
|
|
17
|
+
* shapes, and neither is on the shared `info` type — so `info.time` does not
|
|
18
|
+
* typecheck against the union. This narrow accessor is the one place that cast
|
|
19
|
+
* lives; `session-turn-meta-rows` imports it rather than keeping a second copy.
|
|
20
|
+
*/
|
|
21
|
+
export function messageTime(message) {
|
|
22
|
+
return (message?.info?.time ?? {});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* When the message was created, in epoch **milliseconds**, or `null` when the
|
|
26
|
+
* backend never stamped one.
|
|
27
|
+
*
|
|
28
|
+
* Milliseconds is not an assumption: `packages/sdk/src/transcript.ts` feeds the
|
|
29
|
+
* same field straight to `new Date(...)` with no `* 1000`, and hands
|
|
30
|
+
* `time.completed - time.created` to a `formatDuration(ms)`.
|
|
31
|
+
*
|
|
32
|
+
* `0` is rejected along with `NaN`: the epoch is not a plausible message time,
|
|
33
|
+
* so a zeroed field is missing data, not midnight in 1970.
|
|
34
|
+
*/
|
|
35
|
+
export function messageCreatedAt(message) {
|
|
36
|
+
const created = messageTime(message).created;
|
|
37
|
+
if (typeof created !== 'number' || !Number.isFinite(created) || created <= 0)
|
|
38
|
+
return null;
|
|
39
|
+
return created;
|
|
40
|
+
}
|
|
41
|
+
const MINUTE = 60_000;
|
|
42
|
+
const WEEK = 7 * 24 * 60 * MINUTE;
|
|
43
|
+
const MINUTES_IN_DAY = 24 * 60;
|
|
44
|
+
/**
|
|
45
|
+
* The runtime zone's UTC offset at an instant, in milliseconds, with second
|
|
46
|
+
* precision. A day that crosses a DST change is 23 or 25 wall-clock hours, and
|
|
47
|
+
* `relativePast` counts days in wall-clock terms so "1 day ago" still means
|
|
48
|
+
* "same time yesterday".
|
|
49
|
+
*/
|
|
50
|
+
function zoneOffsetMs(date) {
|
|
51
|
+
const utc = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
|
|
52
|
+
utc.setUTCFullYear(date.getFullYear());
|
|
53
|
+
return date.getTime() - utc.getTime();
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* `date` → "N minutes ago" / "N hours ago" / "N days ago", for a `date` at
|
|
57
|
+
* least one minute and under one week before `now`.
|
|
58
|
+
*
|
|
59
|
+
* This is `date-fns`' `formatDistanceStrict(date, now, { addSuffix: true })`
|
|
60
|
+
* for the en-US locale, restricted to the range `formatMessageDay` calls it
|
|
61
|
+
* with: the same unit thresholds, the same `Math.round`, and the same DST
|
|
62
|
+
* normalisation for days. It lives here so the SDK carries no date library.
|
|
63
|
+
*/
|
|
64
|
+
function relativePast(date, now) {
|
|
65
|
+
const milliseconds = now.getTime() - date.getTime();
|
|
66
|
+
const minutes = milliseconds / MINUTE;
|
|
67
|
+
const plural = (count, unit) => `${count} ${unit}${count === 1 ? '' : 's'} ago`;
|
|
68
|
+
if (minutes < 60)
|
|
69
|
+
return plural(Math.round(minutes), 'minute');
|
|
70
|
+
if (minutes < MINUTES_IN_DAY)
|
|
71
|
+
return plural(Math.round(minutes / 60), 'hour');
|
|
72
|
+
const dstNormalizedMinutes = (milliseconds - (zoneOffsetMs(now) - zoneOffsetMs(date))) / MINUTE;
|
|
73
|
+
return plural(Math.round(dstNormalizedMinutes / MINUTES_IN_DAY), 'day');
|
|
74
|
+
}
|
|
75
|
+
/** A usable instant, or `null`. One guard, used by both formatters. */
|
|
76
|
+
function instant(timestamp) {
|
|
77
|
+
if (typeof timestamp !== 'number' || !Number.isFinite(timestamp) || timestamp <= 0)
|
|
78
|
+
return null;
|
|
79
|
+
const date = new Date(timestamp);
|
|
80
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* `Intl.DateTimeFormat` construction is the expensive half of formatting — it
|
|
84
|
+
* resolves locale data every time — while the instances themselves are
|
|
85
|
+
* immutable and safe to reuse. A transcript re-renders every label on each
|
|
86
|
+
* clock tick, so building a fresh formatter per label per tick is the one cost
|
|
87
|
+
* here that scales with conversation length. There are only a handful of
|
|
88
|
+
* distinct (locale, options) pairs in this module, so they are all cached.
|
|
89
|
+
*/
|
|
90
|
+
const formatters = new Map();
|
|
91
|
+
function formatter(options, opts) {
|
|
92
|
+
const resolved = { ...options, ...(opts.timeZone ? { timeZone: opts.timeZone } : {}) };
|
|
93
|
+
const key = `${opts.locale ?? ''}|${JSON.stringify(resolved)}`;
|
|
94
|
+
let cached = formatters.get(key);
|
|
95
|
+
if (!cached) {
|
|
96
|
+
cached = new Intl.DateTimeFormat(opts.locale, resolved);
|
|
97
|
+
formatters.set(key, cached);
|
|
98
|
+
}
|
|
99
|
+
return cached;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Format, with the day period forced to upper case.
|
|
103
|
+
*
|
|
104
|
+
* `Intl` does not agree with itself here: CLDR gives `en-US` an uppercase
|
|
105
|
+
* "PM" but hands `en-AU` a lowercase "pm" — so the same code renders
|
|
106
|
+
* "2:32 PM" for one reader and "2:32 pm" for another, with nothing in this
|
|
107
|
+
* file to explain the difference. Uppercasing the one token settles it without
|
|
108
|
+
* touching month names, weekday names, or the 24-hour locales that have no day
|
|
109
|
+
* period at all.
|
|
110
|
+
*
|
|
111
|
+
* `formatToParts(...).join('')` reproduces `format()` exactly, so this is the
|
|
112
|
+
* same string with one token changed — not a reimplementation of formatting.
|
|
113
|
+
*/
|
|
114
|
+
function part(date, options, opts) {
|
|
115
|
+
return formatter(options, opts)
|
|
116
|
+
.formatToParts(date)
|
|
117
|
+
.map((token) => (token.type === 'dayPeriod' ? dayPeriod(token.value, opts) : token.value))
|
|
118
|
+
.join('');
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* CLDR also drifts on punctuation, not just case: depending on the ICU
|
|
122
|
+
* version, `en-CA` hands out "p.m." where `en-US` gives "PM" — dots included.
|
|
123
|
+
* Every Latin a.m./p.m. variant collapses to the same two letters; day
|
|
124
|
+
* periods in other scripts keep their own convention, uppercased as before.
|
|
125
|
+
*/
|
|
126
|
+
function dayPeriod(value, opts) {
|
|
127
|
+
const latin = /^([ap])\.?\s?m\.?$/i.exec(value.trim());
|
|
128
|
+
if (latin)
|
|
129
|
+
return `${latin[1].toUpperCase()}M`;
|
|
130
|
+
return value.toLocaleUpperCase(opts.locale);
|
|
131
|
+
}
|
|
132
|
+
/** The calendar year at an instant, in the render zone — so "same year" is
|
|
133
|
+
* asked in the zone the date is printed in, not the runtime's. */
|
|
134
|
+
function yearIn(date, opts) {
|
|
135
|
+
return part(date, { year: 'numeric' }, opts);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The label on screen.
|
|
139
|
+
*
|
|
140
|
+
* | When | Reads as (`en-US`) |
|
|
141
|
+
* | --------------- | ------------------ |
|
|
142
|
+
* | under a minute | `just now` |
|
|
143
|
+
* | under a week | `5 days ago` |
|
|
144
|
+
* | this year | `June 9` |
|
|
145
|
+
* | any older | `June 9, 2025` |
|
|
146
|
+
*
|
|
147
|
+
* Strict distance (`relativePast`) rather than a loose one: it never rounds up
|
|
148
|
+
* into a vague "about 1 minute", and the point of the label is a real
|
|
149
|
+
* distance, not an impression.
|
|
150
|
+
*
|
|
151
|
+
* `now` is `null` for a server render, where distance is unknowable: the
|
|
152
|
+
* server cannot know the viewer's clock, and guessing produces text that
|
|
153
|
+
* changes on hydration. `null` returns the dated form instead, so the string
|
|
154
|
+
* shown before hydration is never *wrong* — only less immediate than it will be.
|
|
155
|
+
*
|
|
156
|
+
* Returns `''` for a timestamp that is absent or unparseable, so the caller can
|
|
157
|
+
* render nothing rather than an `Invalid Date` placeholder.
|
|
158
|
+
*/
|
|
159
|
+
export function formatMessageDay(timestamp, now, opts = {}) {
|
|
160
|
+
const date = instant(timestamp);
|
|
161
|
+
if (!date)
|
|
162
|
+
return '';
|
|
163
|
+
const dated = (withYear) => part(date, { month: 'long', day: 'numeric', ...(withYear ? { year: 'numeric' } : {}) }, opts);
|
|
164
|
+
if (now === null)
|
|
165
|
+
return dated(true);
|
|
166
|
+
// A negative gap means the stamp is ahead of this clock — a few seconds of
|
|
167
|
+
// skew between the sandbox and the browser, not a message from the future.
|
|
168
|
+
// Clamping keeps the skew invisible instead of printing "in 3 seconds".
|
|
169
|
+
const elapsed = Math.max(0, now - date.getTime());
|
|
170
|
+
// Under a minute, a strict distance says "8 seconds ago" and then
|
|
171
|
+
// "9 seconds ago" — motion that carries nothing. One word covers it.
|
|
172
|
+
if (elapsed < MINUTE)
|
|
173
|
+
return 'just now';
|
|
174
|
+
if (elapsed < WEEK)
|
|
175
|
+
return relativePast(date, new Date(now));
|
|
176
|
+
return dated(yearIn(date, opts) !== yearIn(new Date(now), opts));
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The hover label: the full date and the time of day. `June 9, 2026 2:32 PM`.
|
|
180
|
+
*
|
|
181
|
+
* This is where the specifics belong. The label on screen is deliberately
|
|
182
|
+
* loose so the thread stays readable; hovering answers "when exactly" without
|
|
183
|
+
* that answer ever taking up room in the transcript.
|
|
184
|
+
*
|
|
185
|
+
* Minutes, not seconds. A second-level reading looks like it is worth reading
|
|
186
|
+
* and never is — nobody hovers a chat message to learn it landed at :05.
|
|
187
|
+
*/
|
|
188
|
+
export function formatMessageExact(timestamp, opts = {}) {
|
|
189
|
+
const date = instant(timestamp);
|
|
190
|
+
if (!date)
|
|
191
|
+
return '';
|
|
192
|
+
const day = part(date, { month: 'long', day: 'numeric', year: 'numeric' }, opts);
|
|
193
|
+
const clock = part(date, { hour: 'numeric', minute: '2-digit' }, opts);
|
|
194
|
+
return `${day} ${clock}`;
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=message-time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-time.js","sourceRoot":"","sources":["../../../../src/core/turns/segments/message-time.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,OAAqC;IAI/D,OAAO,CACJ,OAAO,EAAE,IAAwE,EAAE,IAAI,IAAI,EAAE,CAC/F,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAqC;IACpE,MAAM,OAAO,GAAG,WAAW,CAAC,O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,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,IAAI,CAAC,CAAC;IACjF,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,IAAI,CAAC,CAAC;IACvE,OAAO,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plain-language narration for Easy mode.
|
|
3
|
+
*
|
|
4
|
+
* Turns the 104 registered tools into sentences a non-technical user can read.
|
|
5
|
+
* The registry holds ~200 keys because every tool registers snake_case,
|
|
6
|
+
* kebab-case and an `oc-` alias — `normalizeName` collapses those first.
|
|
7
|
+
*
|
|
8
|
+
* The `other` fallback is load-bearing: MCP tools have arbitrary `server/tool`
|
|
9
|
+
* names that cannot be enumerated, and tools added after this ships are unknown
|
|
10
|
+
* here. Neither may ever surface a raw identifier.
|
|
11
|
+
*
|
|
12
|
+
* GOVERNING RULE: narration must never mislead. A tool's family and sentence
|
|
13
|
+
* are decided by what its registered component actually renders/does (see
|
|
14
|
+
* apps/web/src/features/session/tool/tools/*.tsx), not by how its name reads.
|
|
15
|
+
* Several tools register the *same* component under multiple aliases (e.g.
|
|
16
|
+
* `task_create` and `agent_task_create` both render `AgentSpawnTool`) — those
|
|
17
|
+
* aliases must always resolve to the same family and the same sentence.
|
|
18
|
+
*/
|
|
19
|
+
import type { ToolPart } from '../../runtime/client.js';
|
|
20
|
+
export type StepFamily = 'explore' | 'edit' | 'run' | 'web' | 'create' | 'plan' | 'delegate' | 'sessions' | 'memory' | 'connectors' | 'automations' | 'projects' | 'skills' | 'ask' | 'retired' | 'other';
|
|
21
|
+
export declare function familyForTool(toolName: string): StepFamily | 'hidden';
|
|
22
|
+
/**
|
|
23
|
+
* `linear/create_issue` → `Create Issue`. Never returns a raw identifier.
|
|
24
|
+
*
|
|
25
|
+
* Named `narrationToolName`, not `humanizeToolName`: the SDK already exports a
|
|
26
|
+
* `humanizeToolName` (tool-registry) that keeps the server segment
|
|
27
|
+
* (`linear/create_issue` → "Linear/create Issue"). This one names only the
|
|
28
|
+
* leaf, which is what a narrated sentence wants.
|
|
29
|
+
*
|
|
30
|
+
* MCP tool ids also arrive as `mcp__server__tool_name` — `__` is that
|
|
31
|
+
* format's hierarchy separator, the same role `/` plays elsewhere. Without
|
|
32
|
+
* normalizing it first, only the trailing `_` gets word-split, leaving the
|
|
33
|
+
* server segment glued onto the leaf ("Mcp Linear Create Issue", still
|
|
34
|
+
* effectively the raw identifier) — collapsing `__` to `/` first lets the
|
|
35
|
+
* existing leaf-splitting logic below do the same job it already does for
|
|
36
|
+
* `linear/create_issue`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function narrationToolName(toolName: string): string;
|
|
39
|
+
export declare function contextLabelForTool(toolName: string): string;
|
|
40
|
+
export type CreateArtifactKind = 'image' | 'video' | 'presentation';
|
|
41
|
+
/**
|
|
42
|
+
* The kind of artifact this call produced, or `null` if it did not make
|
|
43
|
+
* anything worth surfacing in Outputs (a delete, a listing, a preview, …).
|
|
44
|
+
*
|
|
45
|
+
* `image_gen` has no pure-read action — generate/edit/upscale/remove_bg (and
|
|
46
|
+
* a missing/unrecognized action) all leave behind a real image file the user
|
|
47
|
+
* asked for and will want to open (see ImageGenTool, which renders a
|
|
48
|
+
* resulting image for every one of these). Only the LABEL differs by action
|
|
49
|
+
* (see `imageGenSentence` — calling an edit "Made an image" would be a lie);
|
|
50
|
+
* the artifact itself must always surface here, or a user who asks to
|
|
51
|
+
* edit/upscale/remove a background gets an empty Outputs card despite the
|
|
52
|
+
* agent having actually produced something.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createArtifactKind(part: ToolPart): CreateArtifactKind | null;
|
|
55
|
+
/**
|
|
56
|
+
* One sentence for a group of same-family calls.
|
|
57
|
+
* `parts` is guaranteed non-empty and homogeneous by `group-steps` — homogeneous
|
|
58
|
+
* by *family*, not by tool, so a single call can still mix several distinct
|
|
59
|
+
* tools (e.g. `image_gen` + `video_gen`, or `connector_get` + `connector_setup`).
|
|
60
|
+
* Every branch below inspects every part, never just `parts[0]`.
|
|
61
|
+
*/
|
|
62
|
+
export declare function narrateStep(family: StepFamily, parts: ToolPart[]): string;
|
|
63
|
+
/**
|
|
64
|
+
* The failure phrasing for a step whose status is 'error' (W7). Same rules as
|
|
65
|
+
* `narrateStep` — plain language, never a raw identifier, never an error code.
|
|
66
|
+
* Grouped steps can mix one failure among successes; the step-level status is
|
|
67
|
+
* already 'error' (see group-steps.statusOf), so the sentence owns the whole
|
|
68
|
+
* step: vague-but-true beats specific-but-false here exactly as everywhere else.
|
|
69
|
+
*/
|
|
70
|
+
export declare function narrateFailedStep(family: StepFamily, parts: ToolPart[]): string;
|
|
71
|
+
//# sourceMappingURL=narration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"narration.d.ts","sourceRoot":"","sources":["../../../../src/core/turns/segments/narration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAgBrD,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,MAAM,GACN,KAAK,GACL,KAAK,GACL,QAAQ,GACR,MAAM,GACN,UAAU,GACV,UAAU,GACV,QAAQ,GACR,YAAY,GACZ,aAAa,GACb,UAAU,GACV,QAAQ,GACR,KAAK,GACL,SAAS,GACT,OAAO,CAAC;AA+HZ,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,QAAQ,CAIrE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAO1D;AAwBD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAI5D;AAoWD,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,OAAO,GAAG,cAAc,CAAC;AAQpE;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,GAAG,kBAAkB,GAAG,IAAI,CAa5E;AA8CD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,CA2LzE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,CAmD/E"}
|