@sliprail/sdk 0.1.20 → 0.1.22
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/activity.d.ts +29 -0
- package/lib/ai.d.ts +119 -0
- package/lib/index.d.ts +5 -0
- package/package.json +4 -4
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { LocalizedString } from './index';
|
|
2
|
+
export type ActivityState = 'running' | 'paused' | 'completed' | 'failed' | 'canceled';
|
|
3
|
+
export type ActivityUpdateOptions = {
|
|
4
|
+
progressFraction?: number;
|
|
5
|
+
statusText?: LocalizedString;
|
|
6
|
+
state?: ActivityState;
|
|
7
|
+
};
|
|
8
|
+
export type Activity = {
|
|
9
|
+
id: string;
|
|
10
|
+
update: (options: ActivityUpdateOptions) => void;
|
|
11
|
+
};
|
|
12
|
+
export type ActivityOptions = {
|
|
13
|
+
title: LocalizedString;
|
|
14
|
+
subtitle?: LocalizedString;
|
|
15
|
+
statusText?: LocalizedString;
|
|
16
|
+
progressFraction?: number;
|
|
17
|
+
onClick?: () => void | Promise<void>;
|
|
18
|
+
onAbort?: () => void | Promise<void>;
|
|
19
|
+
onPause?: () => void | Promise<void>;
|
|
20
|
+
onResume?: () => void | Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export type SliprailActivity = {
|
|
26
|
+
create: (options: ActivityOptions) => Activity;
|
|
27
|
+
get: (id: string) => Activity | undefined;
|
|
28
|
+
list: () => Activity[];
|
|
29
|
+
};
|
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,6 @@
|
|
|
1
1
|
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { SliprailAI } from './ai';
|
|
3
|
+
import { SliprailActivity } from './activity';
|
|
2
4
|
export type SelectFilesOptions = {
|
|
3
5
|
type?: 'single-file' | 'multiple-files' | 'directory';
|
|
4
6
|
extensions?: string[];
|
|
@@ -77,6 +79,8 @@ export type ShortcutContext = SliprailMain & {
|
|
|
77
79
|
createStorage: () => KVStorage;
|
|
78
80
|
getWindows: (options?: GetWindowsOptions) => WindowControl[];
|
|
79
81
|
channel: WindowChannel | undefined;
|
|
82
|
+
ai: SliprailAI;
|
|
83
|
+
activity: SliprailActivity;
|
|
80
84
|
toPreviewUrl: (filePath: string) => string;
|
|
81
85
|
events: {
|
|
82
86
|
on: (event: 'settingsChange', callback: () => unknown) => void;
|
|
@@ -261,6 +265,7 @@ export type SliprailMain = {
|
|
|
261
265
|
getPath: (name: 'home' | 'appData' | 'userData' | 'sessionData' | 'temp' | 'exe' | 'module' | 'desktop' | 'documents' | 'downloads' | 'music' | 'pictures' | 'videos' | 'recent' | 'logs' | 'crashDumps') => string;
|
|
262
266
|
};
|
|
263
267
|
export type SliprailRenderer = {
|
|
268
|
+
ai: SliprailAI;
|
|
264
269
|
executeShortcut: (parameters: {
|
|
265
270
|
extensionId: string;
|
|
266
271
|
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.22",
|
|
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"
|