@kortix/sdk 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/README.md +34 -0
- package/dist/core/client/kortix.d.ts.map +1 -1
- package/dist/core/client/project-core.d.ts.map +1 -1
- package/dist/core/http/request.js +1 -1
- package/dist/core/http/request.js.map +1 -1
- package/dist/core/http/response-error.d.ts +1 -1
- package/dist/core/http/response-error.d.ts.map +1 -1
- package/dist/core/http/response-error.js +13 -2
- package/dist/core/http/response-error.js.map +1 -1
- package/dist/core/rest/projects-client/agent-config.d.ts +3 -0
- package/dist/core/rest/projects-client/agent-config.d.ts.map +1 -1
- package/dist/core/rest/projects-client/agent-config.js.map +1 -1
- package/dist/core/rest/projects-client/billing.d.ts +2 -0
- package/dist/core/rest/projects-client/billing.d.ts.map +1 -1
- package/dist/core/rest/projects-client/billing.js.map +1 -1
- package/dist/core/rest/projects-client/drives.d.ts +115 -1
- package/dist/core/rest/projects-client/drives.d.ts.map +1 -1
- package/dist/core/rest/projects-client/drives.js +59 -0
- package/dist/core/rest/projects-client/drives.js.map +1 -1
- package/dist/core/rest/projects-client/projects.d.ts +5 -3
- package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
- package/dist/core/rest/projects-client/projects.js +0 -1
- package/dist/core/rest/projects-client/projects.js.map +1 -1
- package/dist/core/rest/projects-client/session-costs.d.ts +18 -0
- package/dist/core/rest/projects-client/session-costs.d.ts.map +1 -1
- package/dist/core/rest/projects-client/session-costs.js.map +1 -1
- package/dist/core/runtime/transcript-types.d.ts +6 -0
- package/dist/core/runtime/transcript-types.d.ts.map +1 -1
- package/dist/core/runtime/transcript-types.js.map +1 -1
- package/dist/core/session/health.d.ts +2 -1
- package/dist/core/session/health.d.ts.map +1 -1
- package/dist/core/session/health.js.map +1 -1
- package/dist/core/session/runtime-verbs.d.ts +3 -1
- package/dist/core/session/runtime-verbs.d.ts.map +1 -1
- package/dist/core/session/runtime-verbs.js +3 -1
- package/dist/core/session/runtime-verbs.js.map +1 -1
- package/dist/core/session-log/turns/turn.d.ts.map +1 -1
- package/dist/core/session-log/turns/turn.js +3 -1
- package/dist/core/session-log/turns/turn.js.map +1 -1
- package/dist/core/session-log/types.d.ts +4 -0
- package/dist/core/session-log/types.d.ts.map +1 -1
- package/dist/core/session-log/v1.d.ts.map +1 -1
- package/dist/core/session-log/v1.js +5 -1
- package/dist/core/session-log/v1.js.map +1 -1
- package/dist/core/turns/classify.d.ts +12 -0
- package/dist/core/turns/classify.d.ts.map +1 -1
- package/dist/core/turns/classify.js +4 -0
- package/dist/core/turns/classify.js.map +1 -1
- package/dist/core/turns/index.d.ts +6 -0
- package/dist/core/turns/index.d.ts.map +1 -1
- package/dist/core/turns/index.js +3 -0
- package/dist/core/turns/index.js.map +1 -1
- package/dist/core/turns/peer-message-prompt.d.ts +35 -0
- package/dist/core/turns/peer-message-prompt.d.ts.map +1 -0
- package/dist/core/turns/peer-message-prompt.js +27 -0
- package/dist/core/turns/peer-message-prompt.js.map +1 -0
- package/dist/core/turns/segments/narration.js +1 -1
- package/dist/core/turns/segments/narration.js.map +1 -1
- package/dist/core/turns/session-report.d.ts +12 -0
- package/dist/core/turns/session-report.d.ts.map +1 -0
- package/dist/core/turns/session-report.js +101 -0
- package/dist/core/turns/session-report.js.map +1 -0
- package/dist/core/turns/subagent-notice.d.ts +53 -0
- package/dist/core/turns/subagent-notice.d.ts.map +1 -0
- package/dist/core/turns/subagent-notice.js +127 -0
- package/dist/core/turns/subagent-notice.js.map +1 -0
- package/dist/core/turns/tools/index.d.ts +4 -1
- package/dist/core/turns/tools/index.d.ts.map +1 -1
- package/dist/core/turns/tools/index.js +4 -1
- package/dist/core/turns/tools/index.js.map +1 -1
- package/dist/core/turns/tools/kortix-tool-card.d.ts +84 -0
- package/dist/core/turns/tools/kortix-tool-card.d.ts.map +1 -0
- package/dist/core/turns/tools/kortix-tool-card.js +187 -0
- package/dist/core/turns/tools/kortix-tool-card.js.map +1 -0
- package/dist/core/turns/tools/workflow-run.d.ts +109 -0
- package/dist/core/turns/tools/workflow-run.d.ts.map +1 -0
- package/dist/core/turns/tools/workflow-run.js +243 -0
- package/dist/core/turns/tools/workflow-run.js.map +1 -0
- package/dist/core/turns/view-model.d.ts +13 -0
- package/dist/core/turns/view-model.d.ts.map +1 -1
- package/dist/core/turns/view-model.js +16 -1
- package/dist/core/turns/view-model.js.map +1 -1
- package/dist/kortix.esm.min.js +52 -42
- package/dist/kortix.global.js +52 -42
- package/dist/react/query-keys.d.ts +4 -0
- package/dist/react/query-keys.d.ts.map +1 -1
- package/dist/react/query-keys.js +4 -0
- package/dist/react/query-keys.js.map +1 -1
- package/dist/react/use-admin-accounts.d.ts +2 -2
- package/dist/react/use-admin-accounts.d.ts.map +1 -1
- package/dist/react/use-admin-accounts.js +4 -0
- package/dist/react/use-admin-accounts.js.map +1 -1
- package/dist/react/use-project-files.d.ts +27 -1
- package/dist/react/use-project-files.d.ts.map +1 -1
- package/dist/react/use-project-files.js +33 -1
- package/dist/react/use-project-files.js.map +1 -1
- package/dist/react/use-session-log.d.ts.map +1 -1
- package/dist/react/use-session-log.js +14 -1
- package/dist/react/use-session-log.js.map +1 -1
- package/package.json +2 -2
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
* and what its output says. Primary-arg extraction, file verbs, search-query
|
|
4
4
|
* humanizing, patch verbs, success/partial/failed outcomes, and parsers for
|
|
5
5
|
* web search, scrape, skill, memory, read, question, presentation and worker
|
|
6
|
-
* output,
|
|
6
|
+
* output, the `image_gen` card's state, the platform tools' `KortixToolResult`
|
|
7
|
+
* card, and the `workflow` run document. Pure data → data, no framework.
|
|
7
8
|
*/
|
|
8
9
|
export * from './agent-helpers.js';
|
|
9
10
|
export * from './file-verb.js';
|
|
10
11
|
export * from './image-gen-view.js';
|
|
12
|
+
export * from './kortix-tool-card.js';
|
|
11
13
|
export * from './memory-helpers.js';
|
|
12
14
|
export * from './patch-summary.js';
|
|
13
15
|
export * from './presentation-helpers.js';
|
|
@@ -20,4 +22,5 @@ export * from './tool-meta.js';
|
|
|
20
22
|
export * from './tool-outcome.js';
|
|
21
23
|
export * from './tool-output-format.js';
|
|
22
24
|
export * from './web-helpers.js';
|
|
25
|
+
export * from './workflow-run.js';
|
|
23
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/turns/tools/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/turns/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
* The SDK does not depend on that package, so the types are mirrored here and
|
|
6
|
+
* every field is checked. A result that does not parse is `null`, and a host
|
|
7
|
+
* renders the call as its generic tool card instead of a half-drawn one.
|
|
8
|
+
*/
|
|
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: a host tells the two apart by the output (`isTeamTaskCall` in `@kortix/ui`).
|
|
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;
|
|
84
|
+
//# sourceMappingURL=kortix-tool-card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kortix-tool-card.d.ts","sourceRoot":"","sources":["../../../../src/core/turns/tools/kortix-tool-card.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,uFAAuF;AACvF,eAAO,MAAM,qBAAqB,qLAUxB,CAAC;AACX,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,8GAQpB,CAAC;AACX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,4DAA4D;AAC5D,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,cAAc,CAAC;AAEjE,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC;AAErF,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,oFAAoF;AACpF,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC;IACb,mGAAmG;IACnG,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM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OAAO,GAAG,OAAO,CAErD"}
|
|
@@ -0,0 +1,187 @@
|
|
|
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
|
+
* The SDK does not depend on that package, so the types are mirrored here and
|
|
6
|
+
* every field is checked. A result that does not parse is `null`, and a host
|
|
7
|
+
* renders the call as its generic tool card instead of a half-drawn one.
|
|
8
|
+
*/
|
|
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: a host tells the two apart by the output (`isTeamTaskCall` in `@kortix/ui`).
|
|
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
|
+
}
|
|
187
|
+
//# sourceMappingURL=kortix-tool-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kortix-tool-card.js","sourceRoot":"","sources":["../../../../src/core/turns/tools/kortix-tool-card.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,uFAAuF;AACvF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,eAAe;IACf,iBAAiB;IACjB,kBAAkB;IAClB,mBAAmB;IACnB,eAAe;IACf,eAAe;IACf,cAAc;IACd,wBAAwB;IACxB,eAAe;CACP,CAAC;AAGX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,cAAc;IACd,aAAa;IACb,aAAa;IACb,WAAW;IACX,UAAU;IACV,aAAa;IACb,WAAW;CACH,CAAC;AA6DX,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAChG,MAAM,WAAW,GAAG,IAAI,GAAG,CAA0B,CAAC,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AACnG,2FAA2F;AAC3F,MAAM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E,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;AAE3J,MAAM,UAAU,YAAY,CAAC,MAAe;IAC1C,OAAO,YAAY,CAAC,GAAG,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `workflow` tool's run document, parsed defensively, and the pure helpers
|
|
3
|
+
* a run card draws from (web, TUI, mobile).
|
|
4
|
+
*
|
|
5
|
+
* The shape is `WorkflowRunMetadata` (`core/rest/projects-client/multi-agent.ts`,
|
|
6
|
+
* held equal to `packages/api-contract/src/kortix-tool-card.ts`). It arrives as a
|
|
7
|
+
* tool part's metadata (`ToolView.metadata`) or from `GET …/workflows`, so every
|
|
8
|
+
* field is checked. pi pushes it live with every change of the run, and the
|
|
9
|
+
* final copy when the call returns.
|
|
10
|
+
*/
|
|
11
|
+
import type { WorkflowRunAgent, WorkflowRunPhase, WorkflowRunStatus } from '../../rest/projects-client/multi-agent.js';
|
|
12
|
+
/** A phase's status. `pending`: declared in the script's `meta.phases`, not started yet. */
|
|
13
|
+
export type WorkflowPhaseStatus = WorkflowRunPhase['status'];
|
|
14
|
+
/**
|
|
15
|
+
* A run as a card draws it: `WorkflowRunMetadata` after `parseWorkflowRun`, with
|
|
16
|
+
* `logs` always a list and the newest 5 lines at most.
|
|
17
|
+
*/
|
|
18
|
+
export interface WorkflowRun {
|
|
19
|
+
runId: string;
|
|
20
|
+
title: string;
|
|
21
|
+
status: WorkflowRunStatus;
|
|
22
|
+
phases: WorkflowRunPhase[];
|
|
23
|
+
agents: WorkflowRunAgent[];
|
|
24
|
+
startedAt?: number;
|
|
25
|
+
endedAt?: number;
|
|
26
|
+
error?: string;
|
|
27
|
+
/** The most agents this run may start. */
|
|
28
|
+
maxAgents?: number;
|
|
29
|
+
/** A saved workflow run by name. */
|
|
30
|
+
name?: string;
|
|
31
|
+
/** The script's newest `log()` lines, oldest first. */
|
|
32
|
+
logs: string[];
|
|
33
|
+
/** More than 25 agents: the card warns, as Claude Code's "Large workflow". */
|
|
34
|
+
large?: true;
|
|
35
|
+
/** The run this one resumed. */
|
|
36
|
+
resumedFrom?: string;
|
|
37
|
+
/** The run goes on in its own runner session; this call returned at once. */
|
|
38
|
+
background?: {
|
|
39
|
+
sessionId: string;
|
|
40
|
+
};
|
|
41
|
+
/** `pause` held new agents back; running agents finish. Cleared by `resume`. */
|
|
42
|
+
paused?: true;
|
|
43
|
+
}
|
|
44
|
+
/** The run in a `workflow` call's metadata; `null` when the metadata is not a run. */
|
|
45
|
+
export declare function parseWorkflowRun(metadata: unknown): WorkflowRun | null;
|
|
46
|
+
/** True for pi's `workflow` tool, under any of its spellings, and for no other name ending in `workflow`. */
|
|
47
|
+
export declare function isWorkflowTool(name: string): boolean;
|
|
48
|
+
/** The filter of the agent list, as Claude Code's `f` cycles it. */
|
|
49
|
+
export type AgentFilter = 'all' | 'running' | 'failed' | 'done';
|
|
50
|
+
export declare const AGENT_FILTERS: readonly AgentFilter[];
|
|
51
|
+
/** Whether an agent belongs under a filter. `stopped` is listed under `all` only. */
|
|
52
|
+
export declare function agentMatches(agent: WorkflowRunAgent, filter: AgentFilter): boolean;
|
|
53
|
+
export interface AgentCounts {
|
|
54
|
+
total: number;
|
|
55
|
+
running: number;
|
|
56
|
+
failed: number;
|
|
57
|
+
done: number;
|
|
58
|
+
}
|
|
59
|
+
export declare function countAgents(agents: readonly WorkflowRunAgent[]): AgentCounts;
|
|
60
|
+
/** One group of the progress list: a phase and its agents, or the agents started before any phase. */
|
|
61
|
+
export interface AgentGroup {
|
|
62
|
+
/** `null`: the agents that belong to no phase. They come first and have no header. */
|
|
63
|
+
phase: WorkflowRunPhase | null;
|
|
64
|
+
agents: WorkflowRunAgent[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The agents grouped under their phases, in the run's phase order. An agent whose
|
|
68
|
+
* phase the list does not name gets a group of its own after the named ones, as a
|
|
69
|
+
* `phase()` title with no `meta.phases` entry does in Claude Code.
|
|
70
|
+
*/
|
|
71
|
+
export declare function groupAgents(run: Pick<WorkflowRun, 'phases' | 'agents'>): AgentGroup[];
|
|
72
|
+
/** `12s`, `3m 04s`, `1h 05m`. Seconds and minutes are zero-padded so a ticking label keeps its width. */
|
|
73
|
+
export declare function formatElapsed(ms: number): string;
|
|
74
|
+
/** How long a run or an agent took, or has taken by `now`; undefined when its start is unknown or it never ran. */
|
|
75
|
+
export declare function elapsedMs(item: {
|
|
76
|
+
startedAt?: number;
|
|
77
|
+
endedAt?: number;
|
|
78
|
+
}, live: boolean, now: number): number | undefined;
|
|
79
|
+
export type StructuredSummary = {
|
|
80
|
+
kind: 'object';
|
|
81
|
+
keys: number;
|
|
82
|
+
pretty: string;
|
|
83
|
+
} | {
|
|
84
|
+
kind: 'array';
|
|
85
|
+
items: number;
|
|
86
|
+
pretty: string;
|
|
87
|
+
} | {
|
|
88
|
+
kind: 'value';
|
|
89
|
+
pretty: string;
|
|
90
|
+
} | {
|
|
91
|
+
kind: 'text';
|
|
92
|
+
pretty: string;
|
|
93
|
+
};
|
|
94
|
+
/** A `structured` agent's summary: the JSON it holds, or its text when it does not parse (a cut answer). */
|
|
95
|
+
export declare function structuredSummary(summary: string): StructuredSummary;
|
|
96
|
+
export type WorkflowResult = {
|
|
97
|
+
kind: 'json';
|
|
98
|
+
text: string;
|
|
99
|
+
} | {
|
|
100
|
+
kind: 'markdown';
|
|
101
|
+
text: string;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* The script's return value in a finished call's output (`<workflow_result>…</workflow_result>`):
|
|
105
|
+
* pretty JSON when it parses as an object or a list, else Markdown. Null when the output has no
|
|
106
|
+
* result block (an older run, or a run that failed).
|
|
107
|
+
*/
|
|
108
|
+
export declare function parseWorkflowResult(output: string): WorkflowResult | null;
|
|
109
|
+
//# sourceMappingURL=workflow-run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-run.d.ts","sourceRoot":"","sources":["../../../../src/core/turns/tools/workflow-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAEV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,wCAAwC,CAAC;AAEhD,4FAA4F;AAC5F,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;AAE7D;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,8EAA8E;IAC9E,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,UAAU,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACnC,gFAAgF;IAChF,MAAM,CAAC,EAAE,IAAI,CAAC;CACf;AAoED,sFAAsF;AACtF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CA2CtE;AAED,6GAA6G;AAC7G,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAID,oEAAoE;AACpE,MA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