@kortix/ui 0.14.15 → 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.
@@ -21,7 +21,11 @@ export interface ChannelDescriptor {
21
21
  };
22
22
  /** The most characters one message holds. */
23
23
  messageChars?: number;
24
- /** One tap per option up to `max` options. `dataBytes`: the platform's cap on a button's data. */
24
+ /**
25
+ * Up to `max` option buttons on one question: Teams posts more options as a
26
+ * form, Telegram turns pages of `max`. `dataBytes`: the platform's cap on a
27
+ * button's data.
28
+ */
25
29
  buttons?: {
26
30
  max: number;
27
31
  dataBytes?: number;
package/dist/i18n/en.d.ts CHANGED
@@ -772,10 +772,6 @@ declare const catalog: {
772
772
  name: string;
773
773
  description: string;
774
774
  };
775
- meta_agent: {
776
- name: string;
777
- description: string;
778
- };
779
775
  warm_sessions: {
780
776
  name: string;
781
777
  description: string;
package/dist/i18n/en.js CHANGED
@@ -773,10 +773,6 @@ const catalog = {
773
773
  "name": "Marketplace",
774
774
  "description": "Browse and install skills from community and vendor registries. Sources, updates, and team scopes are still changing."
775
775
  },
776
- "meta_agent": {
777
- "name": "My Kortix",
778
- "description": "My Kortix, the one agent you talk to. It routes each task to the agent made for it and runs it, with your permissions. The project setting is `builtin_agents.my_kortix` in kortix.yaml; this switch applies only when that key is not set."
779
- },
780
776
  "warm_sessions": {
781
777
  "name": "Warm Sessions",
782
778
  "description": "Keep one sandbox ready for instant session starts. The idle sandbox uses compute."
@@ -7604,8 +7600,8 @@ const catalog = {
7604
7600
  "listPlaceholder": "value 1, value 2"
7605
7601
  },
7606
7602
  "triggerAutoPause": {
7607
- "title": "Paused itself at its run limit",
7608
- "description": "It ran at its hourly run limit for 2 hours in a row, so it stopped starting runs. Find what keeps firing it, then resume it."
7603
+ "title": "Paused automatically",
7604
+ "description": "It stopped starting runs for the reason below. Fix the cause, then resume it."
7609
7605
  },
7610
7606
  "featureGate": {
7611
7607
  "enable": "Enable {name}",
@@ -22,7 +22,6 @@ import { useFeatureFlag } from '@kortix/sdk/react';
22
22
  */
23
23
  export function useProjectFeatureFlags(projectId) {
24
24
  const marketplace = useFeatureFlag(projectId, 'marketplace');
25
- const metaAgent = useFeatureFlag(projectId, 'meta_agent');
26
25
  const reminders = useFeatureFlag(projectId, 'reminders');
27
26
  const warmSessions = useFeatureFlag(projectId, 'warm_sessions');
28
27
  const secretsEgress = useFeatureFlag(projectId, 'secrets_egress');
@@ -47,7 +46,6 @@ export function useProjectFeatureFlags(projectId) {
47
46
  return {
48
47
  flags: {
49
48
  marketplace: marketplace.enabled,
50
- meta_agent: metaAgent.enabled,
51
49
  reminders: reminders.enabled,
52
50
  warm_sessions: warmSessions.enabled,
53
51
  secrets_egress: secretsEgress.enabled,
@@ -2,14 +2,8 @@
2
2
  import type { UiTranslator } from '../../../i18n/index.js';
3
3
  /** Removes every `<kortix_system …>…</kortix_system>` block, in any ASCII case. */
4
4
  export declare function stripKortixSystemTags(text: string): string;
5
- export interface SessionReport {
6
- sessionId: string;
7
- status: 'COMPLETE' | 'FAILED';
8
- project: string;
9
- prompt: string;
10
- result: string;
11
- }
12
- export declare function extractSessionReport(text: string): SessionReport | null;
5
+ /** The parser lives in `@kortix/sdk` (`core/turns/session-report.ts`). */
6
+ export { extractSessionReport, type SessionReport } from '@kortix/sdk';
13
7
  /**
14
8
  * Check if a user message text is purely a kortix_system message
15
9
  * (no visible user content outside the tags).
@@ -6,7 +6,7 @@ import { indexOfIgnoreCase, removeSpans, tagBlocks } from '../../../_vendor/kort
6
6
  * state, PTY output, etc.) in <kortix_system type="..." source="..."> tags.
7
7
  *
8
8
  * - stripKortixSystemTags: removes ALL tags before markdown rendering
9
- * - extractSessionReport: parses session-report tags into structured data
9
+ * - extractSessionReport: parses session-report tags (re-exported from `@kortix/sdk`)
10
10
  *
11
11
  * Nothing here runs a regex over the message. The regexes these functions used
12
12
  * were quadratic or cubic in the text — extracting system messages from 60k
@@ -21,63 +21,9 @@ export function stripKortixSystemTags(text) {
21
21
  return '';
22
22
  return removeSpans(text, tagBlocks(text, 'kortix_system', { attributes: 'any', ignoreCase: true })).trim();
23
23
  }
24
- export function extractSessionReport(text) {
25
- if (!text)
26
- return null;
27
- const xml = sessionReportXml(text);
28
- if (xml === null)
29
- return null;
30
- const get = (tag) => tagBlocks(xml, tag, { limit: 1 })[0]?.body.trim() || '';
31
- return {
32
- sessionId: get('session-id'),
33
- status: get('status') === 'FAILED' ? 'FAILED' : 'COMPLETE',
34
- project: get('project'),
35
- prompt: get('prompt'),
36
- result: get('result'),
37
- };
38
- }
39
- /**
40
- * The text between `<session-report>` and `</session-report>` after the first
41
- * `<kortix_system …>` tag that holds `type="session-report"`, with a closing
42
- * `</kortix_system>` after it — what
43
- * `/<kortix_system[^>]*type="session-report"[^>]*>[\s\S]*?<session-report>([\s\S]*?)<\/session-report>[\s\S]*?<\/kortix_system>/i`
44
- * captured. That regex was cubic: 7.6 s at 60k characters.
45
- */
46
- function sessionReportXml(text) {
47
- const marker = 'type="session-report"';
48
- let from = 0;
49
- // The first marker at or after the last position searched from; -2 until searched.
50
- let markerAt = -2;
51
- for (;;) {
52
- const open = indexOfIgnoreCase(text, OPEN, from);
53
- if (open === -1)
54
- return null;
55
- const attrs = open + OPEN.length;
56
- const gt = text.indexOf('>', attrs);
57
- if (gt === -1)
58
- return null;
59
- if (markerAt < attrs)
60
- markerAt = indexOfIgnoreCase(text, marker, attrs);
61
- if (markerAt === -1)
62
- return null;
63
- // The marker lies past this tag. Every opener before `gt` shares this tag's
64
- // attributes, so none of them holds the marker either.
65
- if (markerAt > gt) {
66
- from = gt;
67
- continue;
68
- }
69
- // Each search below failing means no later opener can succeed: its search starts later still.
70
- const start = indexOfIgnoreCase(text, '<session-report>', gt + 1);
71
- if (start === -1)
72
- return null;
73
- const stop = indexOfIgnoreCase(text, '</session-report>', start + 16);
74
- if (stop === -1)
75
- return null;
76
- if (indexOfIgnoreCase(text, CLOSE, stop + 17) === -1)
77
- return null;
78
- return text.slice(start + 16, stop);
79
- }
80
- }
24
+ // ── Session Report extraction ────────────────────────────────────────────────
25
+ /** The parser lives in `@kortix/sdk` (`core/turns/session-report.ts`). */
26
+ export { extractSessionReport } from '@kortix/sdk';
81
27
  /**
82
28
  * Check if a user message text is purely a kortix_system message
83
29
  * (no visible user content outside the tags).
@@ -32,6 +32,8 @@ export const STUCK_AFTER_MS = 45_000;
32
32
  * from a skewed or unset `now`, and it rendered as tens of millions of minutes.
33
33
  */
34
34
  const MAX_COUNTDOWN_SECONDS = 60 * 60;
35
+ /** `failure.evidence.check` of a box whose agent did not start (apps/api `RUNTIME_BOOT_ERROR_PARK_REASON`). */
36
+ const RUNTIME_BOOT_ERROR_CHECK = 'runtime_boot_error';
35
37
  /**
36
38
  * Keep the server's retry visible while `/start` waits for its retry clock.
37
39
  * The server re-attempts on its own, so this is a waiting state, not an error.
@@ -39,20 +41,28 @@ const MAX_COUNTDOWN_SECONDS = 60 * 60;
39
41
  export function sessionWakeStatusNote(input) {
40
42
  if (input.reason !== 'runtime_wake_cooldown' || !input.failure)
41
43
  return input.note ?? null;
42
- const attempts = Math.max(1, input.failure.evidence?.attempts ?? 1);
44
+ const evidence = input.failure.evidence;
45
+ // The computer ran and the agent in it did not start: say why, not "still starting".
46
+ const error = evidence?.check === RUNTIME_BOOT_ERROR_CHECK ? evidence.error : null;
47
+ let end = error?.length ?? 0;
48
+ while (error && end > 0 && /[.\s]/.test(error[end - 1]))
49
+ end--;
50
+ const bootError = error?.slice(0, end);
51
+ const lead = bootError ? `Could not start the agent: ${bootError}.` : 'Still starting your computer.';
52
+ const attempts = Math.max(1, evidence?.attempts ?? 1);
43
53
  const nextAttempt = attempts + 1;
44
- const retryAt = Date.parse(input.failure.evidence?.next_retry_at ?? '');
54
+ const retryAt = Date.parse(evidence?.next_retry_at ?? '');
45
55
  const seconds = Math.max(0, Math.ceil((retryAt - input.now) / 1_000));
46
56
  if (!Number.isFinite(seconds) || seconds > MAX_COUNTDOWN_SECONDS) {
47
- return `Still starting your computer. Trying again automatically (attempt ${nextAttempt}).`;
57
+ return `${lead} Trying again automatically (attempt ${nextAttempt}).`;
48
58
  }
49
59
  if (seconds === 0)
50
- return `Still starting your computer. Trying again now (attempt ${nextAttempt}).`;
60
+ return `${lead} Trying again now (attempt ${nextAttempt}).`;
51
61
  const minutes = Math.floor(seconds / 60);
52
62
  const remainder = seconds % 60;
53
63
  // One unit: a line break never falls between the minutes and the seconds.
54
64
  const duration = minutes > 0 ? `${minutes}m\u00a0${remainder}s` : `${remainder}s`;
55
- return `Still starting your computer. Trying again in ${duration} (attempt ${nextAttempt}).`;
65
+ return `${lead} Trying again in ${duration} (attempt ${nextAttempt}).`;
56
66
  }
57
67
  /** A 1 s tick: the retry countdown and the stuck clock read it. */
58
68
  function useNow() {
@@ -1,83 +1,6 @@
1
1
  /**
2
- * The My Kortix platform tools' result, parsed defensively.
3
- *
4
- * The shape is `KortixToolResult` in `packages/api-contract/src/kortix-tool-card.ts`.
5
- * `@kortix/ui` does not depend on that package, so the types are mirrored here
6
- * and every field is checked. A result that does not parse is `null`, and the
7
- * call renders as the generic tool card instead of a half-drawn one.
2
+ * The My Kortix platform tools' and the multi-agent tools' `KortixToolResult`
3
+ * parser. It lives in `@kortix/sdk` (`core/turns/tools/kortix-tool-card.ts`);
4
+ * this file keeps the old import path for the web cards.
8
5
  */
9
- /** `KORTIX_PLATFORM_TOOL_NAMES` in `packages/api-contract/src/kortix-tool-card.ts`. */
10
- export declare const KORTIX_PLATFORM_TOOLS: readonly ["kortix_agents", "kortix_sessions", "kortix_schedules", "kortix_connectors", "kortix_people", "kortix_access", "kortix_usage", "kortix_change_requests", "kortix_memory"];
11
- export type KortixPlatformTool = (typeof KORTIX_PLATFORM_TOOLS)[number];
12
- /**
13
- * The multi-agent tools (`packages/api-contract/src/multi-agent.ts`): the same
14
- * `KortixToolResult`, with `data` = the contract object the card body draws.
15
- * `task_create`, `task_list`, `task_get` and `task_update` are also the names of
16
- * older plugin tools: `multi-agent-tools.tsx` tells the two apart by the output.
17
- */
18
- export declare const MULTI_AGENT_TOOLS: readonly ["send_message", "list_agents", "task_create", "task_list", "task_get", "task_update", "task_stop"];
19
- export type MultiAgentTool = (typeof MULTI_AGENT_TOOLS)[number];
20
- /** Every tool whose result is a `KortixToolResult` card. */
21
- export type KortixCardTool = KortixPlatformTool | MultiAgentTool;
22
- export type KortixCardStatus = 'done' | 'running' | 'needs_you' | 'denied' | 'error';
23
- export interface KortixCardRow {
24
- title: string;
25
- detail?: string;
26
- badge?: string;
27
- /** In-app path (`/projects/…`). A row never links outside the app. */
28
- href?: string;
29
- }
30
- /** A `before` of `null` is a new setting; an `after` of `null` is a removed one. */
31
- export interface KortixCardChange {
32
- field: string;
33
- before: string | null;
34
- after: string | null;
35
- }
36
- export interface KortixCardLink {
37
- label: string;
38
- /** An in-app path, or an absolute `https://` URL (a connector sign-in link). */
39
- href: string;
40
- /** True for an absolute `https://` URL: it opens in a new tab and is the card's primary action. */
41
- external: boolean;
42
- }
43
- export interface KortixToolCard {
44
- title: string;
45
- subtitle?: string;
46
- status: KortixCardStatus;
47
- rows: KortixCardRow[];
48
- changes: KortixCardChange[];
49
- links: KortixCardLink[];
50
- }
51
- export interface KortixGrantor {
52
- name: string;
53
- role: string;
54
- }
55
- export interface KortixToolError {
56
- kind: 'denied' | 'not_found' | 'invalid' | 'failed';
57
- message: string;
58
- grantors: KortixGrantor[];
59
- }
60
- export interface KortixToolResult {
61
- ok: boolean;
62
- tool: KortixCardTool;
63
- action: string;
64
- card: KortixToolCard;
65
- error?: KortixToolError;
66
- /** What the model reads. Only the multi-agent card bodies draw it, each through its own defensive parser. */
67
- data?: unknown;
68
- }
69
- /** The platform tool a call name names: `kortix_agents`, also as `kortix-agents` or `oc-kortix_agents`. */
70
- export declare function kortixPlatformTool(name: string): KortixPlatformTool | undefined;
71
- /** A multi-agent tool a call name names: `send_message`, also as `send-message` or `oc-send_message`. */
72
- export declare function multiAgentTool(name: string): MultiAgentTool | undefined;
73
- /** Any tool that answers with a `KortixToolResult` card. */
74
- export declare function kortixCardTool(name: string): KortixCardTool | undefined;
75
- /** An in-app path: one leading `/`, never `//` (a protocol-relative URL leaves the app). */
76
- export declare function inAppHref(value: unknown): string | undefined;
77
- /**
78
- * The result in a platform call's output (or its error text, when the call threw
79
- * it): one JSON object. `null` when the text is not that object. `callName` names
80
- * the tool when the result leaves `tool` out.
81
- */
82
- export declare function parseKortixToolResult(raw: string | undefined, callName?: string): KortixToolResult | null;
83
- export declare function isReadAction(action: unknown): boolean;
6
+ export { KORTIX_PLATFORM_TOOLS, MULTI_AGENT_TOOLS, inAppHref, isReadAction, kortixCardTool, kortixPlatformTool, multiAgentTool, parseKortixToolResult, type KortixCardChange, type KortixCardLink, type KortixCardRow, type KortixCardStatus, type KortixCardTool, type KortixGrantor, type KortixPlatformTool, type KortixToolCard, type KortixToolError, type KortixToolResult, type MultiAgentTool, } from '@kortix/sdk';
@@ -1,186 +1,6 @@
1
1
  /**
2
- * The My Kortix platform tools' result, parsed defensively.
3
- *
4
- * The shape is `KortixToolResult` in `packages/api-contract/src/kortix-tool-card.ts`.
5
- * `@kortix/ui` does not depend on that package, so the types are mirrored here
6
- * and every field is checked. A result that does not parse is `null`, and the
7
- * call renders as the generic tool card instead of a half-drawn one.
2
+ * The My Kortix platform tools' and the multi-agent tools' `KortixToolResult`
3
+ * parser. It lives in `@kortix/sdk` (`core/turns/tools/kortix-tool-card.ts`);
4
+ * this file keeps the old import path for the web cards.
8
5
  */
9
- /** `KORTIX_PLATFORM_TOOL_NAMES` in `packages/api-contract/src/kortix-tool-card.ts`. */
10
- export const KORTIX_PLATFORM_TOOLS = [
11
- 'kortix_agents',
12
- 'kortix_sessions',
13
- 'kortix_schedules',
14
- 'kortix_connectors',
15
- 'kortix_people',
16
- 'kortix_access',
17
- 'kortix_usage',
18
- 'kortix_change_requests',
19
- 'kortix_memory',
20
- ];
21
- /**
22
- * The multi-agent tools (`packages/api-contract/src/multi-agent.ts`): the same
23
- * `KortixToolResult`, with `data` = the contract object the card body draws.
24
- * `task_create`, `task_list`, `task_get` and `task_update` are also the names of
25
- * older plugin tools: `multi-agent-tools.tsx` tells the two apart by the output.
26
- */
27
- export const MULTI_AGENT_TOOLS = [
28
- 'send_message',
29
- 'list_agents',
30
- 'task_create',
31
- 'task_list',
32
- 'task_get',
33
- 'task_update',
34
- 'task_stop',
35
- ];
36
- const STATUSES = new Set(['done', 'running', 'needs_you', 'denied', 'error']);
37
- const ERROR_KINDS = new Set(['denied', 'not_found', 'invalid', 'failed']);
38
- /** A card holds a short list; a longer one is the tool's mistake, not a page to render. */
39
- const MAX_ITEMS = 50;
40
- const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
41
- const text = (value) => typeof value === 'string' && value.trim() ? value.trim() : undefined;
42
- /** The platform tool a call name names: `kortix_agents`, also as `kortix-agents` or `oc-kortix_agents`. */
43
- export function kortixPlatformTool(name) {
44
- const normalized = name.replace(/^oc[-_]/, '').replace(/-/g, '_');
45
- return KORTIX_PLATFORM_TOOLS.includes(normalized)
46
- ? normalized
47
- : undefined;
48
- }
49
- /** A multi-agent tool a call name names: `send_message`, also as `send-message` or `oc-send_message`. */
50
- export function multiAgentTool(name) {
51
- const normalized = name.replace(/^oc[-_]/, '').replace(/-/g, '_');
52
- return MULTI_AGENT_TOOLS.includes(normalized) ? normalized : undefined;
53
- }
54
- /** Any tool that answers with a `KortixToolResult` card. */
55
- export function kortixCardTool(name) {
56
- return kortixPlatformTool(name) ?? multiAgentTool(name);
57
- }
58
- /** An in-app path: one leading `/`, never `//` (a protocol-relative URL leaves the app). */
59
- export function inAppHref(value) {
60
- const href = text(value);
61
- return href && href.startsWith('/') && !href.startsWith('//') && !href.includes('\\') ? href : undefined;
62
- }
63
- function externalHref(value) {
64
- const href = text(value);
65
- if (!href)
66
- return undefined;
67
- try {
68
- return new URL(href).protocol === 'https:' ? href : undefined;
69
- }
70
- catch {
71
- return undefined;
72
- }
73
- }
74
- function list(value, item) {
75
- if (!Array.isArray(value))
76
- return [];
77
- const out = [];
78
- for (const entry of value.slice(0, MAX_ITEMS)) {
79
- const parsed = item(entry);
80
- if (parsed !== undefined)
81
- out.push(parsed);
82
- }
83
- return out;
84
- }
85
- function row(entry) {
86
- if (!isObject(entry))
87
- return undefined;
88
- const title = text(entry.title);
89
- if (!title)
90
- return undefined;
91
- const detail = text(entry.detail);
92
- const badge = text(entry.badge);
93
- const href = inAppHref(entry.href);
94
- return { title, ...(detail ? { detail } : {}), ...(badge ? { badge } : {}), ...(href ? { href } : {}) };
95
- }
96
- const setting = (value) => value === null ? null : typeof value === 'string' ? value : typeof value === 'number' || typeof value === 'boolean' ? String(value) : undefined;
97
- function change(entry) {
98
- if (!isObject(entry))
99
- return undefined;
100
- const field = text(entry.field);
101
- const before = setting(entry.before);
102
- const after = setting(entry.after);
103
- if (!field || before === undefined || after === undefined || (before === null && after === null))
104
- return undefined;
105
- return { field, before, after };
106
- }
107
- function link(entry) {
108
- if (!isObject(entry))
109
- return undefined;
110
- const label = text(entry.label);
111
- if (!label)
112
- return undefined;
113
- const internal = inAppHref(entry.href);
114
- if (internal)
115
- return { label, href: internal, external: false };
116
- const external = externalHref(entry.href);
117
- return external ? { label, href: external, external: true } : undefined;
118
- }
119
- function grantor(entry) {
120
- if (!isObject(entry))
121
- return undefined;
122
- const name = text(entry.name);
123
- return name ? { name, role: text(entry.role) ?? '' } : undefined;
124
- }
125
- function toolError(value) {
126
- if (!isObject(value) || !ERROR_KINDS.has(value.kind))
127
- return undefined;
128
- return {
129
- kind: value.kind,
130
- message: text(value.message) ?? '',
131
- grantors: list(value.grantors, grantor),
132
- };
133
- }
134
- /**
135
- * The result in a platform call's output (or its error text, when the call threw
136
- * it): one JSON object. `null` when the text is not that object. `callName` names
137
- * the tool when the result leaves `tool` out.
138
- */
139
- export function parseKortixToolResult(raw, callName) {
140
- const source = raw?.trim();
141
- if (!source || !source.startsWith('{'))
142
- return null;
143
- let value;
144
- try {
145
- value = JSON.parse(source);
146
- }
147
- catch {
148
- return null;
149
- }
150
- if (!isObject(value) || typeof value.ok !== 'boolean' || !isObject(value.card))
151
- return null;
152
- const tool = typeof value.tool === 'string' ? kortixCardTool(value.tool) : callName !== undefined ? kortixCardTool(callName) : undefined;
153
- const title = text(value.card.title);
154
- if (!tool || !title)
155
- return null;
156
- const error = toolError(value.error);
157
- // A refusal reads as one whatever status the card names: the error kind is the fact.
158
- const status = error?.kind === 'denied'
159
- ? 'denied'
160
- : STATUSES.has(value.card.status)
161
- ? value.card.status
162
- : value.ok
163
- ? 'done'
164
- : 'error';
165
- const subtitle = text(value.card.subtitle);
166
- return {
167
- ok: value.ok,
168
- tool,
169
- action: text(value.action) ?? '',
170
- card: {
171
- title,
172
- ...(subtitle ? { subtitle } : {}),
173
- status,
174
- rows: list(value.card.rows, row),
175
- changes: list(value.card.changes, change),
176
- links: list(value.card.links, link),
177
- },
178
- ...(error ? { error } : {}),
179
- ...(value.data !== undefined ? { data: value.data } : {}),
180
- };
181
- }
182
- /** The actions that only read; every other action changes something (the SDK narration uses the same set). */
183
- const READ_ACTIONS = new Set(['', 'list', 'get', 'read', 'find', 'show', 'view', 'events', 'runs', 'test', 'search', 'check', 'status', 'pending', 'who']);
184
- export function isReadAction(action) {
185
- return READ_ACTIONS.has(typeof action === 'string' ? action : '');
186
- }
6
+ export { KORTIX_PLATFORM_TOOLS, MULTI_AGENT_TOOLS, inAppHref, isReadAction, kortixCardTool, kortixPlatformTool, multiAgentTool, parseKortixToolResult, } from '@kortix/sdk';
@@ -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';
@@ -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';
@@ -1,111 +1,6 @@
1
- import { parsePeerMessagePrompt, tagBlocks } from '../../_vendor/kortix-shared.js';
2
- import { extractSessionReport } from '../../internal/lib/utils/kortix-system-tags.js';
3
- const SUBAGENT_LEAD = 'A background subagent you started has finished.';
4
- const TEAMMATE_LEAD = /^Your teammate (\S+) finished its turn and is idle\./;
5
- const PEER_IDLE_HEAD = '[idle notice from ';
6
- const STATUSES = new Set(['completed', 'failed', 'stopped']);
7
- /** `session-notice-batch.ts` `NOTICE_BATCH_MAX`; a longer prompt is not a batch it wrote. */
8
- const MAX_NOTICES = 20;
9
- function block(text, tag) {
10
- const found = tagBlocks(text, tag, { limit: 1 })[0];
11
- return found ? found.body.trim() : null;
12
- }
13
- /** The first line with words, without Markdown heading, list and emphasis marks. */
14
- export function firstLine(text) {
15
- for (const raw of text.split('\n')) {
16
- const line = raw
17
- .replace(/^\s*(?:#{1,6}\s+|[-*+]\s+|>\s*|\d+\.\s+)/, '')
18
- .replace(/[*_`]+/g, '')
19
- .trim();
20
- if (line)
21
- return line;
22
- }
23
- return '';
24
- }
25
- /** The background subagent or teammate notice a text carries (one notice, not a batch), or null. */
26
- export function parseSubagentNotice(text) {
27
- if (!text)
28
- return null;
29
- const body = text.trimStart();
30
- const teammate = TEAMMATE_LEAD.exec(body);
31
- if (!teammate && !body.startsWith(SUBAGENT_LEAD))
32
- return null;
33
- const report = extractSessionReport(body);
34
- const head = body.slice(0, 600);
35
- const sessionId = /^task_id:\s*(\S+)/m.exec(head)?.[1] ?? report?.sessionId ?? '';
36
- if (!sessionId)
37
- return null;
38
- const stated = /^status:\s*(\w+)/m.exec(head)?.[1];
39
- // The API writes `error` for a turn that ended on an error; it reads as a failure.
40
- const normalized = stated === 'error' ? 'failed' : stated;
41
- const status = normalized && STATUSES.has(normalized)
42
- ? normalized
43
- : report?.status === 'FAILED'
44
- ? 'failed'
45
- : 'completed';
46
- const resultXml = report?.result ?? '';
47
- const answer = block(resultXml, 'task_result');
48
- const error = block(resultXml, 'task_error');
49
- const result = (status === 'completed' ? answer : (error ?? answer)) ?? resultXml;
50
- const title = report?.prompt?.replace(/\s*\(@[^)]*\bsubagent\)\s*$/i, '').trim() || null;
51
- const handle = teammate?.[1] ?? null;
52
- const owned = handle ? /^Tasks \S+ still owns: (.+?)\.?$/m.exec(body)?.[1]?.trim() : undefined;
53
- return {
54
- kind: teammate ? 'teammate' : 'subagent',
55
- sessionId,
56
- status,
57
- handle,
58
- agent: report?.project?.trim() || null,
59
- title,
60
- result,
61
- excerpt: firstLine(result),
62
- ownedTasks: owned || null,
63
- };
64
- }
65
- /** True when a notice of any kind starts at `index` of `text`. */
66
- function startsNotice(text, index) {
67
- return (text.startsWith(SUBAGENT_LEAD, index) ||
68
- text.startsWith(PEER_IDLE_HEAD, index) ||
69
- (text.startsWith('Your teammate ', index) && TEAMMATE_LEAD.test(text.slice(index, index + 300))));
70
- }
71
1
  /**
72
- * The notices a delivered prompt carries, in order, or null when the prompt is
73
- * anything else. A notice starts at the start of the prompt or right after the
74
- * blank line that joins two notices, so a notice line quoted inside a report
75
- * never splits one. Every piece must parse: one that does not makes the whole
76
- * prompt "not a batch", and it renders as the turn it is.
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.
77
5
  */
78
- export function parseNoticeBatch(text) {
79
- if (!text)
80
- return null;
81
- const body = text.trim();
82
- if (!startsNotice(body, 0))
83
- return null;
84
- const starts = [0];
85
- for (let at = body.indexOf('\n\n'); at !== -1; at = body.indexOf('\n\n', at + 2)) {
86
- // Several blank lines in a row: the notice starts at the first non-newline.
87
- let index = at + 2;
88
- while (body[index] === '\n')
89
- index += 1;
90
- if (index > starts[starts.length - 1] && startsNotice(body, index))
91
- starts.push(index);
92
- if (starts.length > MAX_NOTICES)
93
- return null;
94
- }
95
- const items = [];
96
- for (const [i, start] of starts.entries()) {
97
- const piece = body.slice(start, starts[i + 1] ?? body.length).trim();
98
- if (piece.startsWith(PEER_IDLE_HEAD)) {
99
- const info = parsePeerMessagePrompt(piece);
100
- if (!info || info.kind !== 'idle_notice')
101
- return null;
102
- items.push({ kind: 'peer_idle', info });
103
- continue;
104
- }
105
- const notice = parseSubagentNotice(piece);
106
- if (!notice)
107
- return null;
108
- items.push({ kind: notice.kind, notice });
109
- }
110
- return items;
111
- }
6
+ export { noticeFirstLine as firstLine, parseNoticeBatch, parseSubagentNotice, } from '@kortix/sdk';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kortix/ui",
3
- "version": "0.14.15",
3
+ "version": "0.14.16",
4
4
  "description": "Kortix UI: the shared React component library for apps/web, Kortix Apps and SDK hosts. Tailwind v4 classes, themed by CSS variables.",
5
5
  "type": "module",
6
6
  "license": "Elastic-2.0",
@@ -2185,7 +2185,7 @@
2185
2185
  "@extend-ai/react-docx": "^0.7.5",
2186
2186
  "@extend-ai/react-xlsx": "0.13.4",
2187
2187
  "@glideapps/glide-data-grid": "6.0.4-alpha24",
2188
- "@kortix/llm-catalog": "0.14.15",
2188
+ "@kortix/llm-catalog": "0.14.16",
2189
2189
  "@lezer/highlight": "1.2.3",
2190
2190
  "@paper-design/shaders-react": "^0.0.76",
2191
2191
  "@phosphor-icons/react": "2.1.10",
@@ -2284,7 +2284,7 @@
2284
2284
  "yaml": "^2.8.2"
2285
2285
  },
2286
2286
  "peerDependencies": {
2287
- "@kortix/sdk": "^0.14.15",
2287
+ "@kortix/sdk": "^0.14.16",
2288
2288
  "@tanstack/react-query": "^5.75.2",
2289
2289
  "@types/react": ">=18",
2290
2290
  "react": ">=19",