@alisio/sdk 0.1.0-alpha.8 → 0.1.0-alpha.9
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/index.d.ts +49 -0
- package/dist/index.js +11 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,10 +10,52 @@ export interface ToolCall {
|
|
|
10
10
|
name: string;
|
|
11
11
|
arguments: string;
|
|
12
12
|
}
|
|
13
|
+
/** A node of a `{ kind: "tree" }` UI block. */
|
|
14
|
+
export interface TreeNode {
|
|
15
|
+
label: string;
|
|
16
|
+
children?: TreeNode[];
|
|
17
|
+
/** Optional annotation rendered after the label, e.g. a count or a status word. */
|
|
18
|
+
meta?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Alisio-owned structured rendering of a tool result, produced by core adapters (for example
|
|
22
|
+
* the MCP connector) when a tool returns structured data. It never carries MCP protocol types:
|
|
23
|
+
* plugins wanting a structured block build one of these shapes directly. The runner always
|
|
24
|
+
* keeps a plain-text projection alongside a `ui` part, so providers, compaction and headless
|
|
25
|
+
* output only ever see text; the block is a display hint for TUI rendering.
|
|
26
|
+
*/
|
|
27
|
+
export type UiBlock = {
|
|
28
|
+
kind: "table";
|
|
29
|
+
columns: string[];
|
|
30
|
+
rows: Array<Array<string>>;
|
|
31
|
+
caption?: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: "key-value";
|
|
34
|
+
entries: Array<[string, string]>;
|
|
35
|
+
caption?: string;
|
|
36
|
+
} | {
|
|
37
|
+
kind: "tree";
|
|
38
|
+
nodes: Array<TreeNode>;
|
|
39
|
+
} | {
|
|
40
|
+
kind: "code";
|
|
41
|
+
lang?: string;
|
|
42
|
+
code: string;
|
|
43
|
+
caption?: string;
|
|
44
|
+
} | {
|
|
45
|
+
kind: "markdown";
|
|
46
|
+
text: string;
|
|
47
|
+
};
|
|
13
48
|
export interface ToolResult {
|
|
14
49
|
content: Array<{
|
|
15
50
|
type: "text";
|
|
16
51
|
text: string;
|
|
52
|
+
} | {
|
|
53
|
+
type: "image";
|
|
54
|
+
mimeType: string;
|
|
55
|
+
data: string;
|
|
56
|
+
} | {
|
|
57
|
+
type: "ui";
|
|
58
|
+
block: UiBlock;
|
|
17
59
|
}>;
|
|
18
60
|
isError?: boolean;
|
|
19
61
|
}
|
|
@@ -651,3 +693,10 @@ export interface Plugin {
|
|
|
651
693
|
}
|
|
652
694
|
export declare function definePlugin<T extends Plugin>(plugin: T): T;
|
|
653
695
|
export declare const textResult: (text: string, isError?: boolean) => ToolResult;
|
|
696
|
+
/**
|
|
697
|
+
* Text-only view of a tool result: the content filtered to its text parts, order preserved.
|
|
698
|
+
* This is what the runner hands to providers, what compaction summarizes and what headless
|
|
699
|
+
* output shows; `ui`/`image` parts stay only in the persisted transcript for TUI replay, so
|
|
700
|
+
* raw bytes or structured blocks never reach the model prompt.
|
|
701
|
+
*/
|
|
702
|
+
export declare function textProjection(result: ToolResult): ToolResult;
|
package/dist/index.js
CHANGED
|
@@ -5,3 +5,14 @@ export const textResult = (text, isError = false) => ({
|
|
|
5
5
|
content: [{ type: "text", text }],
|
|
6
6
|
...(isError ? { isError: true } : {}),
|
|
7
7
|
});
|
|
8
|
+
/**
|
|
9
|
+
* Text-only view of a tool result: the content filtered to its text parts, order preserved.
|
|
10
|
+
* This is what the runner hands to providers, what compaction summarizes and what headless
|
|
11
|
+
* output shows; `ui`/`image` parts stay only in the persisted transcript for TUI replay, so
|
|
12
|
+
* raw bytes or structured blocks never reach the model prompt.
|
|
13
|
+
*/
|
|
14
|
+
export function textProjection(result) {
|
|
15
|
+
if (result.content.every((part) => part.type === "text"))
|
|
16
|
+
return result;
|
|
17
|
+
return { ...result, content: result.content.filter((part) => part.type === "text") };
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alisio/sdk",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.9",
|
|
4
4
|
"description": "Typed plugin SDK for Alisio: the stable contract for tools, commands, context, compaction and session hooks, model completions and storage. Types only plus tiny helpers; zero runtime dependencies.",
|
|
5
5
|
"author": "Gustavo Gutiérrez",
|
|
6
6
|
"license": "MIT",
|