@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.
- package/dist/_vendor/shared/channel-descriptors.d.ts +5 -1
- package/dist/customize/agents/agent-tabs.d.ts +1 -0
- package/dist/customize/agents/agent-tabs.js +1 -0
- package/dist/customize/shared/capability-library.js +7 -2
- package/dist/files/drives/drive-storage.d.ts +47 -0
- package/dist/files/drives/drive-storage.js +144 -0
- package/dist/files/drives/session-drives-chip.js +20 -2
- package/dist/files/index.d.ts +1 -0
- package/dist/files/index.js +1 -0
- package/dist/files/project/components/drive-explorer.js +13 -5
- package/dist/files/project/components/drive-upload-tray.js +1 -1
- package/dist/files/project/upload-batch.d.ts +3 -1
- package/dist/files/project/upload-batch.js +5 -2
- package/dist/i18n/en.d.ts +32 -16
- package/dist/i18n/en.js +35 -19
- package/dist/internal/chrome/use-chrome-offered.d.ts +14 -5
- package/dist/internal/chrome/use-chrome-offered.js +15 -6
- package/dist/internal/lib/use-project-feature-flags.js +0 -2
- package/dist/internal/lib/utils/kortix-system-tags.d.ts +2 -8
- package/dist/internal/lib/utils/kortix-system-tags.js +4 -58
- package/dist/session/composer/context-usage.d.ts +2 -0
- package/dist/session/composer/context-usage.js +7 -0
- package/dist/session/header/compact-modal.js +5 -2
- package/dist/session/header/session-site-header.js +5 -2
- package/dist/session/status/session-starting-loader.js +15 -5
- package/dist/session/thread/transcript.js +2 -2
- package/dist/session/tool/tools/kortix-tool-card.d.ts +4 -81
- package/dist/session/tool/tools/kortix-tool-card.js +4 -184
- package/dist/session/tool/tools/workflow-run.d.ts +4 -126
- package/dist/session/tool/tools/workflow-run.js +4 -249
- package/dist/session/turn/burst-step-body.js +2 -2
- package/dist/session/turn/compaction-card.d.ts +23 -1
- package/dist/session/turn/compaction-card.js +20 -8
- package/dist/session/turn/subagent-notice.d.ts +4 -56
- package/dist/session/turn/subagent-notice.js +4 -109
- package/dist/styles.css +1 -1
- package/dist/workspace/sidebar/project-nav-items.d.ts +0 -11
- package/dist/workspace/sidebar/project-nav-items.js +10 -77
- package/dist/workspace/sidebar/project-sidebar.js +4 -3
- package/package.json +3 -7
- package/skills/kortix-ui/references/modules.md +1 -1
- package/dist/internal/stores/sidebar-nav-store.d.ts +0 -78
- package/dist/internal/stores/sidebar-nav-store.js +0 -125
- package/dist/workspace/sidebar/customize-sidebar-modal.d.ts +0 -9
- package/dist/workspace/sidebar/customize-sidebar-modal.js +0 -198
- package/dist/workspace/sidebar/nav-row-meta.d.ts +0 -14
- package/dist/workspace/sidebar/nav-row-meta.js +0 -94
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
/** @internal Kortix apps only. No semver: it may change in any release. */
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* The web app's master switch for Kortix in Chrome. Off, no surface renders
|
|
4
|
+
* and nothing calls /v1/chrome/*: no Settings page, no command-palette entry,
|
|
5
|
+
* no sidebar row and no card in Apps and extensions. Off on every deployment
|
|
6
|
+
* until launch: the probe below logged a 404 in the console on staging and
|
|
7
|
+
* prod, where the API's KORTIX_CHROME_ENABLED is off. Set true to bring the
|
|
8
|
+
* surfaces back where the API serves the routes.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CHROME_UI_ENABLED = false;
|
|
11
|
+
/**
|
|
12
|
+
* Whether this platform offers Kortix in Chrome at all. The API answers 404
|
|
13
|
+
* on /v1/chrome/* where KORTIX_CHROME_ENABLED is off (staging, prod), so the
|
|
14
|
+
* account-level surfaces — Settings → Kortix in Chrome and its command-palette
|
|
15
|
+
* entry — show only once the browser list answers. Project surfaces read the
|
|
16
|
+
* project's `chrome` flag and `CHROME_UI_ENABLED` instead.
|
|
8
17
|
*
|
|
9
18
|
* `enabled`: ask only while the surface that needs the answer is open.
|
|
10
19
|
*/
|
|
@@ -3,11 +3,20 @@ import { listChromeConnections } from '@kortix/sdk';
|
|
|
3
3
|
import { chromeKeys } from '@kortix/sdk/react';
|
|
4
4
|
import { useQuery } from '@tanstack/react-query';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* The web app's master switch for Kortix in Chrome. Off, no surface renders
|
|
7
|
+
* and nothing calls /v1/chrome/*: no Settings page, no command-palette entry,
|
|
8
|
+
* no sidebar row and no card in Apps and extensions. Off on every deployment
|
|
9
|
+
* until launch: the probe below logged a 404 in the console on staging and
|
|
10
|
+
* prod, where the API's KORTIX_CHROME_ENABLED is off. Set true to bring the
|
|
11
|
+
* surfaces back where the API serves the routes.
|
|
12
|
+
*/
|
|
13
|
+
export const CHROME_UI_ENABLED = false;
|
|
14
|
+
/**
|
|
15
|
+
* Whether this platform offers Kortix in Chrome at all. The API answers 404
|
|
16
|
+
* on /v1/chrome/* where KORTIX_CHROME_ENABLED is off (staging, prod), so the
|
|
17
|
+
* account-level surfaces — Settings → Kortix in Chrome and its command-palette
|
|
18
|
+
* entry — show only once the browser list answers. Project surfaces read the
|
|
19
|
+
* project's `chrome` flag and `CHROME_UI_ENABLED` instead.
|
|
11
20
|
*
|
|
12
21
|
* `enabled`: ask only while the surface that needs the answer is open.
|
|
13
22
|
*/
|
|
@@ -15,7 +24,7 @@ export function useChromeOffered(enabled = true) {
|
|
|
15
24
|
return useQuery({
|
|
16
25
|
queryKey: chromeKeys.list(),
|
|
17
26
|
queryFn: listChromeConnections,
|
|
18
|
-
enabled,
|
|
27
|
+
enabled: CHROME_UI_ENABLED && enabled,
|
|
19
28
|
staleTime: 60_000,
|
|
20
29
|
retry: false,
|
|
21
30
|
}).isSuccess;
|
|
@@ -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
|
-
|
|
6
|
-
|
|
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
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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).
|
|
@@ -11,6 +11,8 @@ export interface ContextBreakdown {
|
|
|
11
11
|
/**
|
|
12
12
|
* The context size: the usage of the last reply (an assistant message, or a
|
|
13
13
|
* compaction, whose usage is its summary reply's) with a positive token total.
|
|
14
|
+
* A reset onto the record (a compaction block with `mode: 'record'`) reads 0
|
|
15
|
+
* until the next reply.
|
|
14
16
|
* `sessionLogThreadMetrics(...).context` picks the same message, but prices the
|
|
15
17
|
* whole thread to do it.
|
|
16
18
|
*
|
|
@@ -8,6 +8,8 @@ const EMPTY_BREAKDOWN = {
|
|
|
8
8
|
/**
|
|
9
9
|
* The context size: the usage of the last reply (an assistant message, or a
|
|
10
10
|
* compaction, whose usage is its summary reply's) with a positive token total.
|
|
11
|
+
* A reset onto the record (a compaction block with `mode: 'record'`) reads 0
|
|
12
|
+
* until the next reply.
|
|
11
13
|
* `sessionLogThreadMetrics(...).context` picks the same message, but prices the
|
|
12
14
|
* whole thread to do it.
|
|
13
15
|
*
|
|
@@ -23,6 +25,11 @@ export function getLastAssistantTokenBreakdown(messages) {
|
|
|
23
25
|
const msg = messages[i];
|
|
24
26
|
if (msg.role !== 'assistant' && msg.kind !== 'compaction')
|
|
25
27
|
continue;
|
|
28
|
+
// A reset onto the record made no model call: the context is near empty from here on, and
|
|
29
|
+
// the next reply measures it. Reading past it would show the size before the reset.
|
|
30
|
+
if (msg.kind === 'compaction' && msg.blocks.some((block) => block.type === 'compaction' && block.mode === 'record')) {
|
|
31
|
+
return EMPTY_BREAKDOWN;
|
|
32
|
+
}
|
|
26
33
|
const t = msg.usage;
|
|
27
34
|
if (!t)
|
|
28
35
|
continue;
|
|
@@ -3,11 +3,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { Button } from '../../primitives/button.js';
|
|
4
4
|
import { Modal, ModalBody, ModalContent, ModalDescription, ModalFooter, ModalHeader, ModalTitle, } from '../../primitives/modal.js';
|
|
5
5
|
import { errorToast } from '../../primitives/toast.js';
|
|
6
|
-
import { useSummarizeRuntimeSession } from '@kortix/sdk/react';
|
|
6
|
+
import { useRuntimeSupports, useSummarizeRuntimeSession } from '@kortix/sdk/react';
|
|
7
7
|
import { useTranslations } from '../../i18n/index.js';
|
|
8
8
|
import { useCallback } from 'react';
|
|
9
9
|
export function CompactModal({ sessionId, open, onOpenChange, onCompactStart, }) {
|
|
10
10
|
const tHardcodedUi = useTranslations('hardcodedUi');
|
|
11
|
+
const tReset = useTranslations('contextReset');
|
|
12
|
+
// A runtime that resets onto the record summarizes nothing: the dialog says what happens there.
|
|
13
|
+
const record = useRuntimeSupports('session.context_record');
|
|
11
14
|
const summarize = useSummarizeRuntimeSession();
|
|
12
15
|
const handleCompact = useCallback(() => {
|
|
13
16
|
onCompactStart?.();
|
|
@@ -20,5 +23,5 @@ export function CompactModal({ sessionId, open, onOpenChange, onCompactStart, })
|
|
|
20
23
|
errorToast(error instanceof Error ? error.message : tHardcodedUi.raw('i18nComplete.texta4a83d949891'));
|
|
21
24
|
});
|
|
22
25
|
}, [onCompactStart, onOpenChange, summarize, sessionId, tHardcodedUi]);
|
|
23
|
-
return (_jsx(Modal, { open: open, onOpenChange: onOpenChange, children: _jsxs(ModalContent, { className: "lg:max-w-md", children: [_jsxs(ModalHeader, { children: [_jsx(ModalTitle, { children: tHardcodedUi.raw('componentsSessionCompactDialog.line47JsxTextCompactSession') }), _jsx(ModalDescription, { children: tHardcodedUi.raw('componentsSessionCompactDialog.line50JsxTextThisWillSummarizeOlderMessagesUsingAiTo') })] }), _jsx(ModalBody, { children: _jsxs("div", { className: "text-muted-foreground space-y-1.5 text-sm", children: [_jsx("p", { children: tHardcodedUi.raw('componentsSessionCompactDialog.line56JsxTextWhatHappensDuringCompaction') }), _jsxs("ul", { className: "list-inside list-disc space-y-0.5 pl-1", children: [_jsx("li", { children: tHardcodedUi.raw('componentsSessionCompactDialog.line58JsxTextOlderMessagesAreSummarizedIntoAConciseRecap') }), _jsx("li", { children: tHardcodedUi.raw('componentsSessionCompactDialog.line59JsxTextToolOutputsAndFileChangesArePreservedAs') }), _jsx("li", { children: tHardcodedUi.raw('componentsSessionCompactDialog.line60JsxTextRecentMessagesRemainUnchanged') })] })] }) }), _jsxs(ModalFooter, { children: [_jsx(Button, { variant: "outline-ghost", size: "sm", className: "w-full sm:w-auto", onClick: () => onOpenChange(false), children: tHardcodedUi.raw('i18nComplete.text19766ed6ccb2') }), _jsx(Button, { size: "sm", className: "w-full sm:w-auto", onClick: handleCompact, children: tHardcodedUi.raw('i18nComplete.text99452646e34b') })] })] }) }));
|
|
26
|
+
return (_jsx(Modal, { open: open, onOpenChange: onOpenChange, children: _jsxs(ModalContent, { className: "lg:max-w-md", children: [record ? (_jsxs(ModalHeader, { children: [_jsx(ModalTitle, { children: tReset('dialogTitle') }), _jsx(ModalDescription, { children: tReset('dialogDescription') })] })) : (_jsxs(ModalHeader, { children: [_jsx(ModalTitle, { children: tHardcodedUi.raw('componentsSessionCompactDialog.line47JsxTextCompactSession') }), _jsx(ModalDescription, { children: tHardcodedUi.raw('componentsSessionCompactDialog.line50JsxTextThisWillSummarizeOlderMessagesUsingAiTo') })] })), !record && (_jsx(ModalBody, { children: _jsxs("div", { className: "text-muted-foreground space-y-1.5 text-sm", children: [_jsx("p", { children: tHardcodedUi.raw('componentsSessionCompactDialog.line56JsxTextWhatHappensDuringCompaction') }), _jsxs("ul", { className: "list-inside list-disc space-y-0.5 pl-1", children: [_jsx("li", { children: tHardcodedUi.raw('componentsSessionCompactDialog.line58JsxTextOlderMessagesAreSummarizedIntoAConciseRecap') }), _jsx("li", { children: tHardcodedUi.raw('componentsSessionCompactDialog.line59JsxTextToolOutputsAndFileChangesArePreservedAs') }), _jsx("li", { children: tHardcodedUi.raw('componentsSessionCompactDialog.line60JsxTextRecentMessagesRemainUnchanged') })] })] }) })), _jsxs(ModalFooter, { children: [_jsx(Button, { variant: "outline-ghost", size: "sm", className: "w-full sm:w-auto", onClick: () => onOpenChange(false), children: tHardcodedUi.raw('i18nComplete.text19766ed6ccb2') }), _jsx(Button, { size: "sm", className: "w-full sm:w-auto", onClick: handleCompact, children: record ? tReset('dialogAction') : tHardcodedUi.raw('i18nComplete.text99452646e34b') })] })] }) }));
|
|
24
27
|
}
|
|
@@ -87,6 +87,9 @@ export function SessionSiteHeader({ sessionId, sessionTitle, isMobileView, leadi
|
|
|
87
87
|
const [compactOpen, setCompactOpen] = useState(false);
|
|
88
88
|
// E1: a runtime without on-demand compaction (pi) offers no Compact item.
|
|
89
89
|
const canCompact = useRuntimeSupports('session.compact');
|
|
90
|
+
// A runtime with the context record starts a fresh context: nothing is summarized.
|
|
91
|
+
const contextRecord = useRuntimeSupports('session.context_record');
|
|
92
|
+
const tReset = useTranslations('contextReset');
|
|
90
93
|
const [shareOpen, setShareOpen] = useState(false);
|
|
91
94
|
const { ShareSessionModal } = useUiComponents();
|
|
92
95
|
// The name edits in place: the name button swaps for a field. The menu's
|
|
@@ -258,7 +261,7 @@ export function SessionSiteHeader({ sessionId, sessionTitle, isMobileView, leadi
|
|
|
258
261
|
? err.message
|
|
259
262
|
: tI18nHardcoded.raw('i18nComplete.text32ad3abe4479'));
|
|
260
263
|
},
|
|
261
|
-
}), children: [forkSession.isPending ? _jsx(Loading, {}) : _jsx(GitForkIcon, {}), tI18nHardcoded.raw('i18nComplete.text0e5f7f6732e0')] }))] })), outOfContextPresent && (_jsx(DropdownMenuCheckboxItem, { className: "cursor-pointer", checked: !outOfContextHidden, onCheckedChange: (checked) => setOutOfContextHidden(historyKey, !checked), children: tHistory('showOutOfContext') })), _jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => setExportOpen(true), children: [_jsx(FileDown, {}), tI18nHardcoded.raw('i18nComplete.text5d974f9e80c3')] }), canCompact && (_jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => setCompactOpen(true), children: [_jsx(Layers, {}), tI18nHardcoded.raw('i18nComplete.textca838377bb5a')] })), isProjectSession && canManageLifecycle && (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => setDeleteOpen(true), children: [_jsx(TrashIcon, {}), tI18nHardcoded.raw('i18nComplete.texte2d0a54968ea')] })] }))] }));
|
|
264
|
+
}), children: [forkSession.isPending ? _jsx(Loading, {}) : _jsx(GitForkIcon, {}), tI18nHardcoded.raw('i18nComplete.text0e5f7f6732e0')] }))] })), outOfContextPresent && (_jsx(DropdownMenuCheckboxItem, { className: "cursor-pointer", checked: !outOfContextHidden, onCheckedChange: (checked) => setOutOfContextHidden(historyKey, !checked), children: tHistory('showOutOfContext') })), _jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => setExportOpen(true), children: [_jsx(FileDown, {}), tI18nHardcoded.raw('i18nComplete.text5d974f9e80c3')] }), canCompact && (_jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => setCompactOpen(true), children: [_jsx(Layers, {}), contextRecord ? tReset('dialogAction') : tI18nHardcoded.raw('i18nComplete.textca838377bb5a')] })), isProjectSession && canManageLifecycle && (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => setDeleteOpen(true), children: [_jsx(TrashIcon, {}), tI18nHardcoded.raw('i18nComplete.texte2d0a54968ea')] })] }))] }));
|
|
262
265
|
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "relative z-50 w-full", children: [_jsxs("div", { className: cn('flex items-center justify-between p-2 px-3.5 pt-2 pr-4',
|
|
263
266
|
// Unconditional on the shell. The LEFT indent depends on the
|
|
264
267
|
// sidebar (expanded, it covers the macOS lights itself) and is
|
|
@@ -287,7 +290,7 @@ export function SessionSiteHeader({ sessionId, sessionTitle, isMobileView, leadi
|
|
|
287
290
|
return;
|
|
288
291
|
renameFromMenu.current = false;
|
|
289
292
|
e.preventDefault();
|
|
290
|
-
}, children: sessionActionItems })] })] }), leadingAction] }), _jsxs("div", { className: cn('pointer-events-auto flex items-center gap-1.5', sidebarHidden && 'h-[var(--kx-titlebar-control-size)]'), children: [_jsx(SessionChangesIndicator, { sessionId: sessionId }), _jsx(SessionPendingApprovalsIndicator, { sessionId: sessionId }), isProjectSession ? _jsx(SessionGoalIndicator, {}) : null, isProjectSession ? _jsx(SessionRemindersIndicator, { runtimeSessionId: sessionId }) : null, isProjectSession && (_jsx(SessionConfigIndicator, { projectId: projectId, sessionId: projectSessionId, chatSessionId: sessionId, baseRef: projectSession?.base_ref, reload: reloadConfig.reload, isPending: reloadConfig.isPending, phase: reloadConfig.phase, canReload: canManageLifecycle })), _jsx("div", { className: "hidden items-center gap-1.5 lg:flex", children: devTools.map(({ view, label, Icon }) => (_jsx(Hint, { side: "bottom", sideOffset: 4, delayDuration: 300, label: label, children: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": label, onClick: () => openSessionQuickView(view, 'header'), className: "text-foreground
|
|
293
|
+
}, children: sessionActionItems })] })] }), leadingAction] }), _jsxs("div", { className: cn('pointer-events-auto flex items-center gap-1.5', sidebarHidden && 'h-[var(--kx-titlebar-control-size)]'), children: [_jsx(SessionChangesIndicator, { sessionId: sessionId }), _jsx(SessionPendingApprovalsIndicator, { sessionId: sessionId }), isProjectSession ? _jsx(SessionGoalIndicator, {}) : null, isProjectSession ? _jsx(SessionRemindersIndicator, { runtimeSessionId: sessionId }) : null, isProjectSession && (_jsx(SessionConfigIndicator, { projectId: projectId, sessionId: projectSessionId, chatSessionId: sessionId, baseRef: projectSession?.base_ref, reload: reloadConfig.reload, isPending: reloadConfig.isPending, phase: reloadConfig.phase, canReload: canManageLifecycle })), _jsx("div", { className: "hidden items-center gap-1.5 lg:flex", children: devTools.map(({ view, label, Icon }) => (_jsx(Hint, { side: "bottom", sideOffset: 4, delayDuration: 300, label: label, children: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": label, onClick: () => openSessionQuickView(view, 'header'), className: "text-muted-foreground hover:text-foreground cursor-pointer transition-colors active:scale-[0.96]", children: _jsx(Icon, { className: "h-4 w-4" }) }) }, view))) }), _jsxs(DropdownMenu, { children: [_jsx(Hint, { side: "bottom", sideOffset: 4, delayDuration: 300, label: tI18nHardcoded.raw('i18nComplete.text96f0c06bbcb7'), children: _jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": tI18nHardcoded.raw('i18nComplete.text96f0c06bbcb7'), className: "text-muted-foreground hover:text-foreground cursor-pointer transition-colors active:scale-[0.96] lg:hidden", children: _jsx(Code2, { className: "h-4 w-4" }) }) }) }), _jsx(DropdownMenuContent, { align: "end", className: "w-44", children: devTools.map(({ view, label, Icon }) => (_jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => openSessionQuickView(view, 'header'), children: [_jsx(Icon, {}), label] }, view))) })] }), isProjectSession && projectSession && (_jsx(SessionParticipantStack, { participants: sessionParticipants })), isProjectSession && projectSession && ShareSessionModal && (_jsx(Hint, { side: "bottom", sideOffset: 4, delayDuration: 300, label: shareLabel, open: isMobileViewport ? undefined : false, children: _jsxs(Button, { variant: "ghost", size: "xs", "aria-label": shareLabel, onClick: () => setShareOpen(true), className: "cursor-pointer rounded-md active:scale-[0.96] max-md:w-7 max-md:has-[>svg]:px-0", children: [_jsx(Share, {}), _jsx("span", { className: "hidden md:inline", children: tI18nHardcoded.raw('i18nComplete.text29887a5ff984') })] }) })), isMobileViewport && (_jsx(Hint, { side: "bottom", sideOffset: 4, delayDuration: 300, label: tI18nHardcoded.raw('i18nComplete.text2534086de9fe'), children: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": tI18nHardcoded.raw('i18nComplete.text2534086de9fe'), "aria-expanded": isActionPanelOpen, onClick: toggleActionPanel, className: "text-muted-foreground hover:text-foreground cursor-pointer transition-colors active:scale-[0.96]", children: _jsxs("span", { className: "relative inline-flex", children: [_jsx(CaretDoubleLeftIcon, { className: "size-4" }), readyChip?.sessionId === sessionId && !isActionPanelOpen && (_jsx("span", { className: "bg-kortix-green ring-background absolute -top-1 -right-1 size-2 rounded-full ring-2", "aria-hidden": true }))] }) }) }))] })] }), isProjectSession && _jsx(PreviousRepositoryNotice, {})] }), _jsx(ExportTranscriptModal, { sessionId: sessionId, kortixSessionScope: isProjectSession ? `${projectId}/${projectSessionId}` : undefined, open: exportOpen, onOpenChange: setExportOpen }), _jsx(CompactModal, { sessionId: sessionId, open: compactOpen, onOpenChange: setCompactOpen }), isProjectSession && (_jsxs(_Fragment, { children: [_jsx(SessionConfigReloadConfirm, { busyReason: reloadConfig.busyReason, isPending: reloadConfig.isPending, onConfirm: () => reloadConfig.reload({ force: true }), onDismiss: reloadConfig.clearBusy }), ShareSessionModal && (_jsx(ShareSessionModal, { projectId: projectId, session: projectSession, open: shareOpen, onOpenChange: setShareOpen, onSaved: () => queryClient.invalidateQueries({
|
|
291
294
|
queryKey: qk.project.sessionsScope(projectId ?? ''),
|
|
292
295
|
}) })), _jsx(SessionDeleteModal, { projectId: projectId, sessionId: projectSessionId, sessionLabel: projectTitle, open: deleteOpen, onOpenChange: setDeleteOpen, onDeleted: () => router.push(uiRoutes().project(projectId)) })] }))] }));
|
|
293
296
|
}
|
|
@@ -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
|
|
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(
|
|
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
|
|
57
|
+
return `${lead} Trying again automatically (attempt ${nextAttempt}).`;
|
|
48
58
|
}
|
|
49
59
|
if (seconds === 0)
|
|
50
|
-
return
|
|
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
|
|
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() {
|
|
@@ -29,7 +29,7 @@ import { UserAvatar } from '../../primitives/user-avatar.js';
|
|
|
29
29
|
import { stripSystemPtyText, } from './message-parsing.js';
|
|
30
30
|
import { ActivityBurst } from '../turn/activity-burst.js';
|
|
31
31
|
import { TurnWorkAccordion } from '../turn/turn-work-accordion.js';
|
|
32
|
-
import { CompactionFailedRow, CompactionMarker } from '../turn/compaction-card.js';
|
|
32
|
+
import { CompactionFailedRow, CompactionMarker, compactionReset } from '../turn/compaction-card.js';
|
|
33
33
|
import { ExpandableOutput } from '../turn/expandable-output.js';
|
|
34
34
|
import { isPlanWriteTool } from '../turn/plan-anchor.js';
|
|
35
35
|
import { TurnFallbackRows } from '../turn/fallback-row.js';
|
|
@@ -962,7 +962,7 @@ function TurnCompactionOutcome(props) {
|
|
|
962
962
|
}, [onOpenCompactionSummary, turn.id, response]);
|
|
963
963
|
const compactionRunning = working || compactionInfo.inFlight;
|
|
964
964
|
if (compactionRunning || response || compactionInfo.hasContent) {
|
|
965
|
-
return (_jsx("div", { className: "group/turn", children: _jsx(CompactionMarker, { running: compactionRunning, summary: response, onOpenSummary: onOpenCompactionSummary ? openCompactionSummary : undefined }) }));
|
|
965
|
+
return (_jsx("div", { className: "group/turn", children: _jsx(CompactionMarker, { running: compactionRunning, summary: response, onOpenSummary: onOpenCompactionSummary ? openCompactionSummary : undefined, reset: compactionReset(compactionInfo.block) }) }));
|
|
966
966
|
}
|
|
967
967
|
// An attempt that produced nothing (errored, or stopped before the first
|
|
968
968
|
// token) collapses to one slim row. Falling through to the normal turn
|
|
@@ -1,83 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The My Kortix platform tools'
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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
|
-
|
|
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'
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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
|
-
|
|
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', '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';
|