@kortix/ui 0.14.14 → 0.14.16

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 (47) hide show
  1. package/dist/_vendor/shared/channel-descriptors.d.ts +5 -1
  2. package/dist/customize/agents/agent-tabs.d.ts +1 -0
  3. package/dist/customize/agents/agent-tabs.js +1 -0
  4. package/dist/customize/shared/capability-library.js +7 -2
  5. package/dist/files/drives/drive-storage.d.ts +47 -0
  6. package/dist/files/drives/drive-storage.js +144 -0
  7. package/dist/files/drives/session-drives-chip.js +20 -2
  8. package/dist/files/index.d.ts +1 -0
  9. package/dist/files/index.js +1 -0
  10. package/dist/files/project/components/drive-explorer.js +13 -5
  11. package/dist/files/project/components/drive-upload-tray.js +1 -1
  12. package/dist/files/project/upload-batch.d.ts +3 -1
  13. package/dist/files/project/upload-batch.js +5 -2
  14. package/dist/i18n/en.d.ts +32 -16
  15. package/dist/i18n/en.js +35 -19
  16. package/dist/internal/chrome/use-chrome-offered.d.ts +14 -5
  17. package/dist/internal/chrome/use-chrome-offered.js +15 -6
  18. package/dist/internal/lib/use-project-feature-flags.js +0 -2
  19. package/dist/internal/lib/utils/kortix-system-tags.d.ts +2 -8
  20. package/dist/internal/lib/utils/kortix-system-tags.js +4 -58
  21. package/dist/session/composer/context-usage.d.ts +2 -0
  22. package/dist/session/composer/context-usage.js +7 -0
  23. package/dist/session/header/compact-modal.js +5 -2
  24. package/dist/session/header/session-site-header.js +5 -2
  25. package/dist/session/status/session-starting-loader.js +15 -5
  26. package/dist/session/thread/transcript.js +2 -2
  27. package/dist/session/tool/tools/kortix-tool-card.d.ts +4 -81
  28. package/dist/session/tool/tools/kortix-tool-card.js +4 -184
  29. package/dist/session/tool/tools/workflow-run.d.ts +4 -126
  30. package/dist/session/tool/tools/workflow-run.js +4 -249
  31. package/dist/session/turn/burst-step-body.js +2 -2
  32. package/dist/session/turn/compaction-card.d.ts +23 -1
  33. package/dist/session/turn/compaction-card.js +20 -8
  34. package/dist/session/turn/subagent-notice.d.ts +4 -56
  35. package/dist/session/turn/subagent-notice.js +4 -109
  36. package/dist/styles.css +1 -1
  37. package/dist/workspace/sidebar/project-nav-items.d.ts +0 -11
  38. package/dist/workspace/sidebar/project-nav-items.js +10 -77
  39. package/dist/workspace/sidebar/project-sidebar.js +4 -3
  40. package/package.json +3 -7
  41. package/skills/kortix-ui/references/modules.md +1 -1
  42. package/dist/internal/stores/sidebar-nav-store.d.ts +0 -78
  43. package/dist/internal/stores/sidebar-nav-store.js +0 -125
  44. package/dist/workspace/sidebar/customize-sidebar-modal.d.ts +0 -9
  45. package/dist/workspace/sidebar/customize-sidebar-modal.js +0 -198
  46. package/dist/workspace/sidebar/nav-row-meta.d.ts +0 -14
  47. package/dist/workspace/sidebar/nav-row-meta.js +0 -94
@@ -1,128 +1,6 @@
1
1
  /**
2
- * The `workflow` tool's part metadata, parsed defensively, and the pure helpers
3
- * its card draws from.
4
- *
5
- * The shape is `WorkflowRunMetadata` in `packages/api-contract/src/kortix-tool-card.ts`.
6
- * `@kortix/ui` does not depend on that package, so the types are mirrored here
7
- * and every field is checked. pi pushes it live with every change of the run,
8
- * and the final copy when the call returns.
2
+ * The `workflow` run document's parser and the helpers its card draws from.
3
+ * They live in `@kortix/sdk` (`core/turns/tools/workflow-run.ts`); this file
4
+ * keeps the old import path for the web card.
9
5
  */
10
- export type WorkflowRunStatus = 'running' | 'done' | 'failed' | 'stopped';
11
- /** `pending`: declared in the script's `meta.phases`, not started yet. */
12
- export type WorkflowPhaseStatus = WorkflowRunStatus | 'pending';
13
- export type WorkflowAgentStatus = 'starting' | 'running' | 'done' | 'failed' | 'stopped';
14
- export interface WorkflowRunPhase {
15
- title: string;
16
- status: WorkflowPhaseStatus;
17
- }
18
- export interface WorkflowRunAgent {
19
- id: string;
20
- label: string;
21
- agent?: string;
22
- phase?: string;
23
- status: WorkflowAgentStatus;
24
- sessionId?: string;
25
- summary?: string;
26
- /** Resumed run: the saved result of the earlier run was reused; no session started. */
27
- cached?: true;
28
- /** The model the script asked for. */
29
- model?: string;
30
- /** The answer is JSON checked against a schema. */
31
- structured?: true;
32
- /** 1 for the first attempt; a stalled agent restarts with the same prompt. */
33
- attempt?: number;
34
- /** Epoch ms. */
35
- startedAt?: number;
36
- endedAt?: number;
37
- }
38
- export interface WorkflowRun {
39
- runId: string;
40
- title: string;
41
- status: WorkflowRunStatus;
42
- phases: WorkflowRunPhase[];
43
- agents: WorkflowRunAgent[];
44
- startedAt?: number;
45
- endedAt?: number;
46
- error?: string;
47
- /** The most agents this run may start. */
48
- maxAgents?: number;
49
- /** A saved workflow run by name. */
50
- name?: string;
51
- /** The script's newest `log()` lines, oldest first. */
52
- logs: string[];
53
- /** More than 25 agents: the card warns, as Claude Code's "Large workflow". */
54
- large?: true;
55
- /** The run this one resumed. */
56
- resumedFrom?: string;
57
- /** The run goes on in its own runner session; this call returned at once. */
58
- background?: {
59
- sessionId: string;
60
- };
61
- /** `pause` held new agents back; running agents finish. Cleared by `resume`. */
62
- paused?: true;
63
- }
64
- /** The run in a `workflow` call's metadata; `null` when the metadata is not a run. */
65
- export declare function parseWorkflowRun(metadata: unknown): WorkflowRun | null;
66
- /** True for pi's `workflow` tool, under any of its spellings, and for no other name ending in `workflow`. */
67
- export declare function isWorkflowTool(name: string): boolean;
68
- /** The filter of the agent list, as Claude Code's `f` cycles it. */
69
- export type AgentFilter = 'all' | 'running' | 'failed' | 'done';
70
- export declare const AGENT_FILTERS: readonly AgentFilter[];
71
- /** Whether an agent belongs under a filter. `stopped` is listed under `all` only. */
72
- export declare function agentMatches(agent: WorkflowRunAgent, filter: AgentFilter): boolean;
73
- export interface AgentCounts {
74
- total: number;
75
- running: number;
76
- failed: number;
77
- done: number;
78
- }
79
- export declare function countAgents(agents: readonly WorkflowRunAgent[]): AgentCounts;
80
- /** One group of the progress list: a phase and its agents, or the agents started before any phase. */
81
- export interface AgentGroup {
82
- /** `null`: the agents that belong to no phase. They come first and have no header. */
83
- phase: WorkflowRunPhase | null;
84
- agents: WorkflowRunAgent[];
85
- }
86
- /**
87
- * The agents grouped under their phases, in the run's phase order. An agent whose
88
- * phase the list does not name gets a group of its own after the named ones, as a
89
- * `phase()` title with no `meta.phases` entry does in Claude Code.
90
- */
91
- export declare function groupAgents(run: Pick<WorkflowRun, 'phases' | 'agents'>): AgentGroup[];
92
- /** `12s`, `3m 04s`, `1h 05m`. Seconds and minutes are zero-padded so a ticking label keeps its width. */
93
- export declare function formatElapsed(ms: number): string;
94
- /** How long a run or an agent took, or has taken by `now`; undefined when its start is unknown or it never ran. */
95
- export declare function elapsedMs(item: {
96
- startedAt?: number;
97
- endedAt?: number;
98
- }, live: boolean, now: number): number | undefined;
99
- export type StructuredSummary = {
100
- kind: 'object';
101
- keys: number;
102
- pretty: string;
103
- } | {
104
- kind: 'array';
105
- items: number;
106
- pretty: string;
107
- } | {
108
- kind: 'value';
109
- pretty: string;
110
- } | {
111
- kind: 'text';
112
- pretty: string;
113
- };
114
- /** A `structured` agent's summary: the JSON it holds, or its text when it does not parse (a cut answer). */
115
- export declare function structuredSummary(summary: string): StructuredSummary;
116
- export type WorkflowResult = {
117
- kind: 'json';
118
- text: string;
119
- } | {
120
- kind: 'markdown';
121
- text: string;
122
- };
123
- /**
124
- * The script's return value in a finished call's output (`<workflow_result>…</workflow_result>`):
125
- * pretty JSON when it parses as an object or a list, else Markdown. Null when the output has no
126
- * result block (an older run, or a run that failed).
127
- */
128
- export declare function parseWorkflowResult(output: string): WorkflowResult | null;
6
+ export { AGENT_FILTERS, agentMatches, countAgents, elapsedMs, formatElapsed, groupAgents, isWorkflowTool, parseWorkflowResult, parseWorkflowRun, structuredSummary, type AgentCounts, type AgentFilter, type AgentGroup, type StructuredSummary, type WorkflowAgentStatus, type WorkflowPhaseStatus, type WorkflowResult, type WorkflowRun, type WorkflowRunAgent, type WorkflowRunPhase, type WorkflowRunStatus, } from '@kortix/sdk';
@@ -1,251 +1,6 @@
1
1
  /**
2
- * The `workflow` tool's part metadata, parsed defensively, and the pure helpers
3
- * its card draws from.
4
- *
5
- * The shape is `WorkflowRunMetadata` in `packages/api-contract/src/kortix-tool-card.ts`.
6
- * `@kortix/ui` does not depend on that package, so the types are mirrored here
7
- * and every field is checked. pi pushes it live with every change of the run,
8
- * and the final copy when the call returns.
2
+ * The `workflow` run document's parser and the helpers its card draws from.
3
+ * They live in `@kortix/sdk` (`core/turns/tools/workflow-run.ts`); this file
4
+ * keeps the old import path for the web card.
9
5
  */
10
- const RUN_STATUSES = new Set(['running', 'done', 'failed', 'stopped']);
11
- const PHASE_STATUSES = new Set(['pending', 'running', 'done', 'failed', 'stopped']);
12
- const AGENT_STATUSES = new Set(['starting', 'running', 'done', 'failed', 'stopped']);
13
- /** A run's rows stay a list a person can read; the rest is the session list's job. */
14
- const MAX_AGENTS = 200;
15
- /** The contract sends at most 5 `log()` lines; a longer list keeps the newest 5. */
16
- const MAX_LOGS = 5;
17
- const MAX_LOG_CHARS = 500;
18
- const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
19
- const text = (value) => typeof value === 'string' && value.trim() ? value.trim() : undefined;
20
- const time = (value) => typeof value === 'number' && Number.isFinite(value) ? value : undefined;
21
- const count = (value) => typeof value === 'number' && Number.isFinite(value) && value >= 1 ? Math.floor(value) : undefined;
22
- function phase(entry) {
23
- if (!isObject(entry))
24
- return undefined;
25
- const title = text(entry.title);
26
- return title && PHASE_STATUSES.has(entry.status)
27
- ? { title, status: entry.status }
28
- : undefined;
29
- }
30
- function agent(entry, index) {
31
- if (!isObject(entry) || !AGENT_STATUSES.has(entry.status))
32
- return undefined;
33
- const label = text(entry.label) ?? text(entry.agent);
34
- if (!label)
35
- return undefined;
36
- const name = text(entry.agent);
37
- const phaseTitle = text(entry.phase);
38
- const sessionId = text(entry.sessionId);
39
- const summary = text(entry.summary);
40
- const model = text(entry.model);
41
- const attempt = count(entry.attempt);
42
- const startedAt = time(entry.startedAt);
43
- const endedAt = time(entry.endedAt);
44
- return {
45
- id: text(entry.id) ?? `a${index + 1}`,
46
- label,
47
- ...(name ? { agent: name } : {}),
48
- ...(phaseTitle ? { phase: phaseTitle } : {}),
49
- status: entry.status,
50
- ...(sessionId ? { sessionId } : {}),
51
- ...(summary ? { summary } : {}),
52
- ...(entry.cached === true ? { cached: true } : {}),
53
- ...(model ? { model } : {}),
54
- ...(entry.structured === true ? { structured: true } : {}),
55
- ...(attempt !== undefined ? { attempt } : {}),
56
- ...(startedAt !== undefined ? { startedAt } : {}),
57
- ...(endedAt !== undefined ? { endedAt } : {}),
58
- };
59
- }
60
- function logs(value) {
61
- if (!Array.isArray(value))
62
- return [];
63
- return value
64
- .map((line) => text(line))
65
- .filter((line) => line !== undefined)
66
- .slice(-MAX_LOGS)
67
- .map((line) => line.slice(0, MAX_LOG_CHARS));
68
- }
69
- /** The run in a `workflow` call's metadata; `null` when the metadata is not a run. */
70
- export function parseWorkflowRun(metadata) {
71
- if (!isObject(metadata))
72
- return null;
73
- // A background call that handed its run to a runner may say `started`: the run runs.
74
- if (metadata.status === 'started')
75
- metadata = { ...metadata, status: 'running', agents: Array.isArray(metadata.agents) ? metadata.agents : [] };
76
- if (!isObject(metadata) || !RUN_STATUSES.has(metadata.status))
77
- return null;
78
- if (!Array.isArray(metadata.agents))
79
- return null;
80
- const agents = [];
81
- for (const [index, entry] of metadata.agents.slice(0, MAX_AGENTS).entries()) {
82
- const parsed = agent(entry, index);
83
- if (parsed)
84
- agents.push(parsed);
85
- }
86
- const phases = Array.isArray(metadata.phases)
87
- ? metadata.phases.map(phase).filter((p) => p !== undefined)
88
- : [];
89
- const startedAt = time(metadata.startedAt);
90
- const endedAt = time(metadata.endedAt);
91
- const error = text(metadata.error);
92
- const maxAgents = count(metadata.maxAgents);
93
- const name = text(metadata.name);
94
- const resumedFrom = text(metadata.resumedFrom);
95
- // A background run names its runner session as `background.sessionId`, or (a started call's
96
- // details) as `runnerSessionId` / `runner_session_id`.
97
- const backgroundSession = (isObject(metadata.background) ? text(metadata.background.sessionId) : undefined) ??
98
- text(metadata.runnerSessionId) ??
99
- text(metadata.runner_session_id);
100
- return {
101
- runId: text(metadata.runId) ?? '',
102
- title: text(metadata.title) ?? '',
103
- status: metadata.status,
104
- phases,
105
- agents,
106
- ...(startedAt !== undefined ? { startedAt } : {}),
107
- ...(endedAt !== undefined ? { endedAt } : {}),
108
- ...(error ? { error } : {}),
109
- ...(maxAgents !== undefined ? { maxAgents } : {}),
110
- ...(name ? { name } : {}),
111
- logs: logs(metadata.logs),
112
- ...(metadata.large === true ? { large: true } : {}),
113
- ...(resumedFrom ? { resumedFrom } : {}),
114
- ...(backgroundSession ? { background: { sessionId: backgroundSession } } : {}),
115
- ...(metadata.paused === true ? { paused: true } : {}),
116
- };
117
- }
118
- /** True for pi's `workflow` tool, under any of its spellings, and for no other name ending in `workflow`. */
119
- export function isWorkflowTool(name) {
120
- return name.replace(/^oc[-_]/, '') === 'workflow';
121
- }
122
- export const AGENT_FILTERS = ['all', 'running', 'failed', 'done'];
123
- /** Whether an agent belongs under a filter. `stopped` is listed under `all` only. */
124
- export function agentMatches(agent, filter) {
125
- switch (filter) {
126
- case 'all':
127
- return true;
128
- case 'running':
129
- return agent.status === 'starting' || agent.status === 'running';
130
- case 'failed':
131
- return agent.status === 'failed';
132
- case 'done':
133
- return agent.status === 'done';
134
- }
135
- }
136
- export function countAgents(agents) {
137
- const counts = { total: agents.length, running: 0, failed: 0, done: 0 };
138
- for (const agent of agents) {
139
- if (agentMatches(agent, 'running'))
140
- counts.running += 1;
141
- else if (agent.status === 'failed')
142
- counts.failed += 1;
143
- else if (agent.status === 'done')
144
- counts.done += 1;
145
- }
146
- return counts;
147
- }
148
- /**
149
- * The agents grouped under their phases, in the run's phase order. An agent whose
150
- * phase the list does not name gets a group of its own after the named ones, as a
151
- * `phase()` title with no `meta.phases` entry does in Claude Code.
152
- */
153
- export function groupAgents(run) {
154
- const loose = [];
155
- const byPhase = new Map();
156
- for (const phase of run.phases)
157
- if (!byPhase.has(phase.title))
158
- byPhase.set(phase.title, []);
159
- const extra = [];
160
- for (const agent of run.agents) {
161
- if (!agent.phase) {
162
- loose.push(agent);
163
- continue;
164
- }
165
- let list = byPhase.get(agent.phase);
166
- if (!list) {
167
- list = [];
168
- byPhase.set(agent.phase, list);
169
- extra.push(agent.phase);
170
- }
171
- list.push(agent);
172
- }
173
- const groups = loose.length > 0 ? [{ phase: null, agents: loose }] : [];
174
- const seen = new Set();
175
- for (const phase of run.phases) {
176
- if (seen.has(phase.title))
177
- continue;
178
- seen.add(phase.title);
179
- groups.push({ phase, agents: byPhase.get(phase.title) ?? [] });
180
- }
181
- for (const title of extra) {
182
- const agents = byPhase.get(title) ?? [];
183
- groups.push({ phase: { title, status: derivedStatus(agents) }, agents });
184
- }
185
- return groups;
186
- }
187
- function derivedStatus(agents) {
188
- if (agents.some((agent) => agentMatches(agent, 'running')))
189
- return 'running';
190
- if (agents.some((agent) => agent.status === 'failed'))
191
- return 'failed';
192
- return 'done';
193
- }
194
- // ── Time ─────────────────────────────────────────────────────────────────────
195
- /** `12s`, `3m 04s`, `1h 05m`. Seconds and minutes are zero-padded so a ticking label keeps its width. */
196
- export function formatElapsed(ms) {
197
- const seconds = Math.max(0, Math.floor(ms / 1000));
198
- if (seconds < 60)
199
- return `${seconds}s`;
200
- const minutes = Math.floor(seconds / 60);
201
- if (minutes < 60)
202
- return `${minutes}m ${String(seconds % 60).padStart(2, '0')}s`;
203
- return `${Math.floor(minutes / 60)}h ${String(minutes % 60).padStart(2, '0')}m`;
204
- }
205
- /** How long a run or an agent took, or has taken by `now`; undefined when its start is unknown or it never ran. */
206
- export function elapsedMs(item, live, now) {
207
- if (item.startedAt === undefined)
208
- return undefined;
209
- if (item.endedAt !== undefined)
210
- return Math.max(0, item.endedAt - item.startedAt);
211
- return live ? Math.max(0, now - item.startedAt) : undefined;
212
- }
213
- /** A `structured` agent's summary: the JSON it holds, or its text when it does not parse (a cut answer). */
214
- export function structuredSummary(summary) {
215
- try {
216
- const value = JSON.parse(summary);
217
- const pretty = JSON.stringify(value, null, 2);
218
- if (Array.isArray(value))
219
- return { kind: 'array', items: value.length, pretty };
220
- if (isObject(value))
221
- return { kind: 'object', keys: Object.keys(value).length, pretty };
222
- return { kind: 'value', pretty };
223
- }
224
- catch {
225
- return { kind: 'text', pretty: summary };
226
- }
227
- }
228
- /**
229
- * The script's return value in a finished call's output (`<workflow_result>…</workflow_result>`):
230
- * pretty JSON when it parses as an object or a list, else Markdown. Null when the output has no
231
- * result block (an older run, or a run that failed).
232
- */
233
- export function parseWorkflowResult(output) {
234
- const open = output.indexOf('<workflow_result>');
235
- if (open === -1)
236
- return null;
237
- const start = open + '<workflow_result>'.length;
238
- const close = output.indexOf('</workflow_result>', start);
239
- const body = (close === -1 ? output.slice(start) : output.slice(start, close)).trim();
240
- if (!body)
241
- return null;
242
- if (body.startsWith('{') || body.startsWith('[')) {
243
- try {
244
- return { kind: 'json', text: JSON.stringify(JSON.parse(body), null, 2) };
245
- }
246
- catch {
247
- // A cut or hand-written block: show it as text.
248
- }
249
- }
250
- return { kind: 'markdown', text: body };
251
- }
6
+ export { AGENT_FILTERS, agentMatches, countAgents, elapsedMs, formatElapsed, groupAgents, isWorkflowTool, parseWorkflowResult, parseWorkflowRun, structuredSummary, } from '@kortix/sdk';
@@ -5,7 +5,7 @@ import { ActivityGroupStep } from './activity-group-step.js';
5
5
  import { ActivityStep, StepLabelRow } from './activity-step.js';
6
6
  import { AnsweredQuestionStep, isAnsweredQuestionCall } from './answered-question-step.js';
7
7
  import { stepLabel } from '@kortix/sdk';
8
- import { CompactionMarker } from './compaction-card.js';
8
+ import { CompactionMarker, compactionReset } from './compaction-card.js';
9
9
  import { ToolRegistry } from '../tool/shared/registry.js';
10
10
  /** A host's `ToolRegistry.register` row for this tool wins over the chip and question rows. */
11
11
  const hostRow = (call) => ToolRegistry.replaced(call.name, call.kind);
@@ -46,7 +46,7 @@ export function StepBody({ step, bareRow = false, running, sessionId, disableNav
46
46
  return isFileChipRun(calls) ? (_jsx(ActivityFileChipStep, { calls: calls, sessionId: sessionId, disableNavigation: disableNavigation })) : (_jsx(ActivityGroupStep, { step: { id: calls[0].call_id, family: step.family, label: step.label, parts: calls, status: step.status, durationMs: step.durationMs }, sessionId: sessionId, disableNavigation: disableNavigation }));
47
47
  }
48
48
  if (step.block.type === 'compaction') {
49
- return _jsx(CompactionMarker, { running: running && step.block.summary === null, summary: step.block.summary ?? undefined });
49
+ return _jsx(CompactionMarker, { running: running && step.block.summary === null, summary: step.block.summary ?? undefined, reset: compactionReset(step.block) });
50
50
  }
51
51
  // Neither tool nor reasoning: the label row only. The turn modules never
52
52
  // silently drop a block (`stepLabel` falls back to a generic 'Used' label).
@@ -1,3 +1,23 @@
1
+ /**
2
+ * A reset onto the session's searchable record (kortixd `extensions/context-record.ts`): the block's
3
+ * `mode: 'record'`. Nothing was summarized, so the pill explains the reset instead of opening the
4
+ * model's text.
5
+ */
6
+ export interface CompactionReset {
7
+ /** The person started it (`/compact`, the Compact dialog). */
8
+ manual: boolean;
9
+ /** The context size when it reset. */
10
+ tokensBefore?: number;
11
+ /** The entries the record held at the reset. */
12
+ entries?: number;
13
+ }
14
+ /** The reset block's fields as the marker takes them; null for a summary compaction. */
15
+ export declare function compactionReset(block: {
16
+ mode?: 'record';
17
+ trigger?: string;
18
+ tokens_before?: number;
19
+ entries?: number;
20
+ } | null | undefined): CompactionReset | null;
1
21
  /**
2
22
  * The summary prose — ONE component whether it renders in the panel detail
3
23
  * (the normal path) or inline under the pill (the no-panel fallback), so the
@@ -6,7 +26,9 @@
6
26
  export declare function CompactionSummaryBody({ summary }: {
7
27
  summary: string;
8
28
  }): import("react").JSX.Element;
9
- declare function CompactionMarkerImpl({ running, summary, onOpenSummary, }: {
29
+ declare function CompactionMarkerImpl({ running, summary, onOpenSummary, reset, }: {
30
+ /** A reset onto the record: the pill explains it inline, and `summary` is not shown. */
31
+ reset?: CompactionReset | null;
10
32
  /** The summarize is still producing (optimistic, or the summary message is open). */
11
33
  running: boolean;
12
34
  /** The landed summary markdown, if any. */
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useTranslations } from '../../i18n/index.js';
3
+ import { useLocale, useTranslations } from '../../i18n/index.js';
4
4
  /**
5
5
  * Compaction, as ONE minimal marker — the divider pill IS the whole UI:
6
6
  *
7
- * 1. running (optimistic or streaming) → rule ── [⛁ Compacting context…] ── rule
7
+ * 1. running (optimistic or streaming) → rule ── [⛁ Freeing up context…] ── rule
8
8
  * (shimmer label; the summary text is deliberately NOT streamed into the
9
9
  * transcript — a wall of live markdown read as noise, grew the transcript
10
10
  * under the reader, and made a slow summarize FEEL slower)
@@ -28,22 +28,34 @@ import { SandboxUrlDetector } from '../media/sandbox-url-detector.js';
28
28
  const PILL_CLASS = 'bg-muted/80 flex shrink-0 items-center gap-2 rounded-md px-3 py-1.5';
29
29
  const PILL_LABEL_CLASS = 'text-muted-foreground text-xs tracking-wide';
30
30
  /** Transcript copy — sentence case, one idea per line (kortix-brand voice-and-tone.md). */
31
- const COMPACTION_LABEL_LOADING = 'Compacting context…';
32
31
  const COMPACTION_LABEL_DONE = 'Context automatically compacted';
32
+ /** The reset block's fields as the marker takes them; null for a summary compaction. */
33
+ export function compactionReset(block) {
34
+ if (block?.mode !== 'record')
35
+ return null;
36
+ return { manual: block.trigger === 'manual', tokensBefore: block.tokens_before, entries: block.entries };
37
+ }
33
38
  /**
34
39
  * The summary prose — ONE component whether it renders in the panel detail
35
40
  * (the normal path) or inline under the pill (the no-panel fallback), so the
36
41
  * two can never drift in typography.
37
42
  */
38
43
  export function CompactionSummaryBody({ summary }) {
39
- return (_jsx("div", { className: "text-muted-foreground/90 [&_h1]:text-foreground [&_h2]:text-foreground [&_h3]:text-foreground [&_strong]:text-foreground/90 p-6 text-sm", children: _jsx(SandboxUrlDetector, { content: summary, isStreaming: false }) }));
44
+ return (_jsx("div", { className: "text-muted-foreground [&_h1]:text-foreground [&_h2]:text-foreground [&_h3]:text-foreground [&_strong]:text-foreground p-6 text-sm", children: _jsx(SandboxUrlDetector, { content: summary, isStreaming: false }) }));
40
45
  }
41
- function CompactionMarkerImpl({ running, summary, onOpenSummary, }) {
46
+ function CompactionMarkerImpl({ running, summary, onOpenSummary, reset, }) {
42
47
  const tI18nComplete = useTranslations('hardcodedUi.i18nComplete');
48
+ const tReset = useTranslations('contextReset');
49
+ const locale = useLocale();
43
50
  const [open, setOpen] = useState(false);
51
+ if (reset && !running) {
52
+ const tokens = new Intl.NumberFormat(locale, { notation: 'compact', maximumFractionDigits: 0 }).format(reset.tokensBefore ?? 0);
53
+ const detail = tReset(reset.manual ? 'detailManual' : 'detail', { tokens, entries: reset.entries ?? 0 });
54
+ return (_jsxs("div", { children: [_jsxs("div", { className: "my-3 flex items-center gap-2 py-4", children: [_jsx("div", { className: "bg-border h-px flex-1" }), _jsxs("button", { type: "button", "aria-expanded": open, "aria-label": open ? tReset('hideDetail') : tReset('showDetail'), onClick: () => setOpen((v) => !v), className: cn(PILL_CLASS, 'hit-area-1 hover:bg-accent cursor-pointer transition-[background-color,scale] active:scale-[0.96]'), children: [_jsx(Layers, { weight: "duotone", className: "text-muted-foreground size-3.5 shrink-0" }), _jsx("span", { className: PILL_LABEL_CLASS, children: tReset('pill') }), _jsx(CaretDownIcon, { className: cn('text-muted-foreground size-3 shrink-0 transition-transform', open && 'rotate-180') })] }), _jsx("div", { className: "bg-border h-px flex-1" })] }), open && _jsx("p", { className: "text-muted-foreground mx-auto max-w-prose px-6 pb-2 text-center text-sm", children: detail })] }));
55
+ }
44
56
  const hasSummary = !running && Boolean(summary?.trim());
45
57
  const opensDetail = hasSummary && Boolean(onOpenSummary);
46
- return (_jsxs("div", { children: [_jsxs("div", { className: "my-3 flex items-center gap-2 py-4", children: [_jsx("div", { className: "bg-border h-px flex-1" }), running ? (_jsxs("div", { className: PILL_CLASS, children: [_jsx(Loading, { variant: "spokes", className: "text-muted-foreground size-3.5 shrink-0" }), _jsx(TextShimmer, { className: "text-xs tracking-wide", children: COMPACTION_LABEL_LOADING })] })) : hasSummary ? (_jsxs("button", { type: "button", "aria-expanded": opensDetail ? undefined : open, "aria-label": opensDetail
58
+ return (_jsxs("div", { children: [_jsxs("div", { className: "my-3 flex items-center gap-2 py-4", children: [_jsx("div", { className: "bg-border h-px flex-1" }), running ? (_jsxs("div", { className: PILL_CLASS, children: [_jsx(Loading, { variant: "spokes", className: "text-muted-foreground size-3.5 shrink-0" }), _jsx(TextShimmer, { className: "text-xs tracking-wide", children: tReset('pillRunning') })] })) : hasSummary ? (_jsxs("button", { type: "button", "aria-expanded": opensDetail ? undefined : open, "aria-label": opensDetail
47
59
  ? tI18nComplete.raw('textab742f4db494')
48
60
  : open
49
61
  ? tI18nComplete.raw('text92bfa8a05e5a')
@@ -56,7 +68,7 @@ function CompactionMarkerImpl({ running, summary, onOpenSummary, }) {
56
68
  }, className: cn(PILL_CLASS, 'hit-area-1 hover:bg-accent cursor-pointer transition-[background-color,scale] active:scale-[0.96]'), children: [_jsx(Layers, { weight: "duotone", className: "text-muted-foreground size-3.5 shrink-0" }), _jsx("span", { className: PILL_LABEL_CLASS, children: COMPACTION_LABEL_DONE }), opensDetail ? (
57
69
  // A right caret, not a chevron-down: the summary opens ELSEWHERE
58
70
  // (the panel detail), the same grammar as a row that navigates.
59
- _jsx(CaretRightIcon, { className: "text-muted-foreground/70 size-3 shrink-0" })) : (_jsx(CaretDownIcon, { className: cn('text-muted-foreground/70 size-3 shrink-0 transition-transform', open && 'rotate-180') }))] })) : (_jsxs("div", { className: PILL_CLASS, children: [_jsx(Layers, { weight: "duotone", className: "text-muted-foreground size-3.5 shrink-0" }), _jsx("span", { className: PILL_LABEL_CLASS, children: COMPACTION_LABEL_DONE })] })), _jsx("div", { className: "bg-border h-px flex-1" })] }), open && hasSummary && !opensDetail && (_jsx("div", { className: "pb-2", children: _jsx(CompactionSummaryBody, { summary: summary }) }))] }));
71
+ _jsx(CaretRightIcon, { className: "text-muted-foreground size-3 shrink-0" })) : (_jsx(CaretDownIcon, { className: cn('text-muted-foreground size-3 shrink-0 transition-transform', open && 'rotate-180') }))] })) : (_jsxs("div", { className: PILL_CLASS, children: [_jsx(Layers, { weight: "duotone", className: "text-muted-foreground size-3.5 shrink-0" }), _jsx("span", { className: PILL_LABEL_CLASS, children: COMPACTION_LABEL_DONE })] })), _jsx("div", { className: "bg-border h-px flex-1" })] }), open && hasSummary && !opensDetail && (_jsx("div", { className: "pb-2", children: _jsx(CompactionSummaryBody, { summary: summary }) }))] }));
60
72
  }
61
73
  /** Primitive props, so per-token `summary` growth while running is a DOM no-op. */
62
74
  export const CompactionMarker = memo(CompactionMarkerImpl);
@@ -76,7 +88,7 @@ function CompactionFailedRowImpl({ error, isAbort, }) {
76
88
  : error
77
89
  ? 'Compaction failed'
78
90
  : 'Compaction incomplete';
79
- return (_jsxs(Checkpoint, { children: [_jsx(CheckpointIcon, { children: _jsx(Layers, { className: "text-muted-foreground size-4 shrink-0" }) }), _jsxs(CheckpointLabel, { title: !isAbort && error ? error : undefined, children: [label, !isAbort && error ? (_jsxs("span", { className: "text-muted-foreground/70 font-normal", children: [" \u00B7 ", error] })) : null] })] }));
91
+ return (_jsxs(Checkpoint, { children: [_jsx(CheckpointIcon, { children: _jsx(Layers, { className: "text-muted-foreground size-4 shrink-0" }) }), _jsxs(CheckpointLabel, { title: !isAbort && error ? error : undefined, children: [label, !isAbort && error ? (_jsxs("span", { className: "text-muted-foreground font-normal", children: [" \u00B7 ", error] })) : null] })] }));
80
92
  }
81
93
  export const CompactionFailedRow = memo(CompactionFailedRowImpl);
82
94
  CompactionFailedRow.displayName = 'CompactionFailedRow';
@@ -1,58 +1,6 @@
1
- import { type PeerMessagePromptInfo } from '../../_vendor/shared/index.js';
2
1
  /**
3
- * The notices the API delivers into a session as a prompt, written by
4
- * `subagentNoticeText` in `apps/api/src/projects/subagent-notice.ts`:
5
- *
6
- * A background subagent you started has finished. This message is from the platform, not from the user.
7
- * (or) Your teammate <handle> finished its turn and is idle. This message is from the platform, not from the user.
8
- * task_id: <child session id>
9
- * status: completed | error | failed | stopped
10
- *
11
- * <kortix_system type="session-report" source="subagent"><session-report>…</session-report></kortix_system>
12
- *
13
- * Tasks <handle> still owns: #3 subject (in progress); … . (a teammate only)
14
- * …
15
- *
16
- * `apps/api/src/projects/session-notice-batch.ts` coalesces the notices that
17
- * arrive together into one prompt, joined by a blank line (at most 20): these,
18
- * and the idle notice a `send_message({ notify_when_idle })` asked for
19
- * (`peerMessagePromptText` kind `idle_notice`).
2
+ * The background subagent, teammate and peer idle notices the API delivers
3
+ * into a session as a prompt. The parsers live in `@kortix/sdk`
4
+ * (`core/turns/subagent-notice.ts`); this file keeps the old import path.
20
5
  */
21
- export interface SubagentNotice {
22
- /** `teammate`: a teammate of an agent team went idle; `subagent`: a background subagent ended. */
23
- kind: 'subagent' | 'teammate';
24
- sessionId: string;
25
- status: 'completed' | 'failed' | 'stopped';
26
- /** A teammate's handle, from its lead line; null for a subagent. */
27
- handle: string | null;
28
- /** The project agent the child ran as, or null. */
29
- agent: string | null;
30
- /** The child's title, without the "(@agent subagent)" suffix, or null. */
31
- title: string | null;
32
- /** The child's final report (Markdown), or its error. */
33
- result: string;
34
- /** The first line of `result` that holds words. */
35
- excerpt: string;
36
- /** A teammate's unfinished tasks ("#3 Write the fix (in progress); #4 …"), or null when it owns none. */
37
- ownedTasks: string | null;
38
- }
39
- /** One notice of a delivered notice prompt. */
40
- export type NoticeBatchItem = {
41
- kind: 'subagent' | 'teammate';
42
- notice: SubagentNotice;
43
- } | {
44
- kind: 'peer_idle';
45
- info: PeerMessagePromptInfo;
46
- };
47
- /** The first line with words, without Markdown heading, list and emphasis marks. */
48
- export declare function firstLine(text: string): string;
49
- /** The background subagent or teammate notice a text carries (one notice, not a batch), or null. */
50
- export declare function parseSubagentNotice(text: string | null | undefined): SubagentNotice | null;
51
- /**
52
- * The notices a delivered prompt carries, in order, or null when the prompt is
53
- * anything else. A notice starts at the start of the prompt or right after the
54
- * blank line that joins two notices, so a notice line quoted inside a report
55
- * never splits one. Every piece must parse: one that does not makes the whole
56
- * prompt "not a batch", and it renders as the turn it is.
57
- */
58
- export declare function parseNoticeBatch(text: string | null | undefined): NoticeBatchItem[] | null;
6
+ export { noticeFirstLine as firstLine, parseNoticeBatch, parseSubagentNotice, type NoticeBatchItem, type SubagentNotice, } from '@kortix/sdk';