@sliprail/sdk 0.1.20 → 0.1.21
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/lib/ai.d.ts +119 -0
- package/lib/index.d.ts +3 -0
- package/package.json +4 -4
package/lib/ai.d.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export type AIModelTier = 'fast' | 'balanced' | 'advanced';
|
|
2
|
+
export type AIJsonPrimitive = string | number | boolean | null;
|
|
3
|
+
export type AIJsonObject = {
|
|
4
|
+
[key: string]: AIJsonValue;
|
|
5
|
+
};
|
|
6
|
+
export type AIJsonValue = AIJsonPrimitive | AIJsonObject | AIJsonValue[];
|
|
7
|
+
export type AIJsonSchema = {
|
|
8
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
9
|
+
description: string;
|
|
10
|
+
enum?: AIJsonPrimitive[];
|
|
11
|
+
const?: AIJsonValue;
|
|
12
|
+
properties?: Record<string, AIJsonSchema>;
|
|
13
|
+
required?: string[];
|
|
14
|
+
items?: AIJsonSchema;
|
|
15
|
+
additionalProperties?: boolean | AIJsonSchema;
|
|
16
|
+
};
|
|
17
|
+
export type AIObjectSchema = AIJsonSchema & {
|
|
18
|
+
type: 'object';
|
|
19
|
+
properties?: Record<string, AIJsonSchema>;
|
|
20
|
+
};
|
|
21
|
+
export type AITool = {
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
parameters: AIObjectSchema;
|
|
25
|
+
};
|
|
26
|
+
export type AIFileSource = {
|
|
27
|
+
type: 'inline';
|
|
28
|
+
data: Blob | ArrayBuffer | Uint8Array;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'url';
|
|
31
|
+
url: string;
|
|
32
|
+
} | {
|
|
33
|
+
type: 'path';
|
|
34
|
+
path: string;
|
|
35
|
+
};
|
|
36
|
+
export type AIInputPart = {
|
|
37
|
+
type: 'text';
|
|
38
|
+
text: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: 'file';
|
|
41
|
+
mimeType: string;
|
|
42
|
+
filename?: string;
|
|
43
|
+
source: AIFileSource;
|
|
44
|
+
} | {
|
|
45
|
+
type: 'tool-result';
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
result: AIJsonValue;
|
|
49
|
+
};
|
|
50
|
+
export type AIInput = string | AIInputPart[];
|
|
51
|
+
export type AISessionRequest = {
|
|
52
|
+
input: AIInput;
|
|
53
|
+
tools?: AITool[];
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
};
|
|
56
|
+
export type AIRequest = AISessionRequest & {
|
|
57
|
+
modelTier?: AIModelTier;
|
|
58
|
+
instructions?: string;
|
|
59
|
+
};
|
|
60
|
+
export type AIOutputFile = {
|
|
61
|
+
mimeType: string;
|
|
62
|
+
url: string;
|
|
63
|
+
filename?: string;
|
|
64
|
+
};
|
|
65
|
+
export type AIChunk = {
|
|
66
|
+
type: 'text';
|
|
67
|
+
text: string;
|
|
68
|
+
} | {
|
|
69
|
+
type: 'file';
|
|
70
|
+
file: AIOutputFile;
|
|
71
|
+
} | {
|
|
72
|
+
type: 'tool';
|
|
73
|
+
id: string;
|
|
74
|
+
name: string;
|
|
75
|
+
arguments: AIJsonObject;
|
|
76
|
+
} | {
|
|
77
|
+
type: 'done';
|
|
78
|
+
reason: 'completed' | 'tool' | 'cancelled';
|
|
79
|
+
} | {
|
|
80
|
+
type: 'done';
|
|
81
|
+
reason: 'error';
|
|
82
|
+
error: string;
|
|
83
|
+
};
|
|
84
|
+
export type AIResponse = AsyncIterable<AIChunk>;
|
|
85
|
+
export type AISessionSummary = {
|
|
86
|
+
id: string;
|
|
87
|
+
title?: string;
|
|
88
|
+
modelTier?: AIModelTier;
|
|
89
|
+
tag?: string;
|
|
90
|
+
createdAt: string;
|
|
91
|
+
updatedAt: string;
|
|
92
|
+
};
|
|
93
|
+
export type AISessionOptions = {
|
|
94
|
+
title?: string;
|
|
95
|
+
modelTier?: AIModelTier;
|
|
96
|
+
instructions?: string;
|
|
97
|
+
tag?: string;
|
|
98
|
+
};
|
|
99
|
+
export type AIListSessionsOptions = {
|
|
100
|
+
tag?: string;
|
|
101
|
+
};
|
|
102
|
+
export type AISession = {
|
|
103
|
+
request: (request: AISessionRequest) => AIResponse;
|
|
104
|
+
delete: () => Promise<void>;
|
|
105
|
+
id: string;
|
|
106
|
+
title?: string;
|
|
107
|
+
modelTier?: AIModelTier;
|
|
108
|
+
tag?: string;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
export type SliprailAI = {
|
|
114
|
+
request: (request: AIRequest) => AIResponse;
|
|
115
|
+
createSession: (options?: AISessionOptions) => Promise<AISession>;
|
|
116
|
+
getSession: (sessionId: string) => Promise<AISession | undefined>;
|
|
117
|
+
listSessions: (options?: AIListSessionsOptions) => Promise<AISessionSummary[]>;
|
|
118
|
+
deleteSession: (sessionId: string) => Promise<void>;
|
|
119
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { SliprailAI } from './ai';
|
|
2
3
|
export type SelectFilesOptions = {
|
|
3
4
|
type?: 'single-file' | 'multiple-files' | 'directory';
|
|
4
5
|
extensions?: string[];
|
|
@@ -77,6 +78,7 @@ export type ShortcutContext = SliprailMain & {
|
|
|
77
78
|
createStorage: () => KVStorage;
|
|
78
79
|
getWindows: (options?: GetWindowsOptions) => WindowControl[];
|
|
79
80
|
channel: WindowChannel | undefined;
|
|
81
|
+
ai: SliprailAI;
|
|
80
82
|
toPreviewUrl: (filePath: string) => string;
|
|
81
83
|
events: {
|
|
82
84
|
on: (event: 'settingsChange', callback: () => unknown) => void;
|
|
@@ -261,6 +263,7 @@ export type SliprailMain = {
|
|
|
261
263
|
getPath: (name: 'home' | 'appData' | 'userData' | 'sessionData' | 'temp' | 'exe' | 'module' | 'desktop' | 'documents' | 'downloads' | 'music' | 'pictures' | 'videos' | 'recent' | 'logs' | 'crashDumps') => string;
|
|
262
264
|
};
|
|
263
265
|
export type SliprailRenderer = {
|
|
266
|
+
ai: SliprailAI;
|
|
264
267
|
executeShortcut: (parameters: {
|
|
265
268
|
extensionId: string;
|
|
266
269
|
shortcutId: string;
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sliprail/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.mjs",
|
|
7
7
|
"files": [
|
|
8
|
-
"lib
|
|
8
|
+
"lib/*.d.ts"
|
|
9
9
|
],
|
|
10
10
|
"types": "lib/index.d.ts",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@types/react": "^18.3.27"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@types/node": "^20.19.
|
|
16
|
-
"typescript": "5.
|
|
15
|
+
"@types/node": "^20.19.37",
|
|
16
|
+
"typescript": "5.9.3"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=20"
|