@heyputer/puter.js 2.1.6 → 2.1.8
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/puter.cjs +2 -2
- package/index.d.ts +103 -626
- package/package.json +1 -1
- package/src/index.js +91 -91
- package/src/lib/APICallLogger.js +20 -21
- package/src/lib/EventListener.js +10 -10
- package/src/lib/filesystem/APIFS.js +11 -19
- package/src/lib/filesystem/CacheFS.js +25 -25
- package/src/lib/filesystem/PostMessageFS.js +11 -11
- package/src/lib/filesystem/definitions.js +11 -10
- package/src/lib/path.js +505 -446
- package/src/lib/polyfills/fileReaderPoly.js +40 -0
- package/src/lib/polyfills/localStorage.js +30 -33
- package/src/lib/polyfills/xhrshim.js +206 -207
- package/src/lib/utils.js +160 -151
- package/src/lib/xdrpc.js +9 -9
- package/src/modules/AI.js +416 -290
- package/src/modules/Apps.js +56 -56
- package/src/modules/Auth.js +17 -17
- package/src/modules/Debug.js +1 -1
- package/src/modules/Drivers.js +41 -41
- package/src/modules/FSItem.js +64 -62
- package/src/modules/FileSystem/index.js +22 -23
- package/src/modules/FileSystem/operations/copy.js +7 -7
- package/src/modules/FileSystem/operations/deleteFSEntry.js +14 -12
- package/src/modules/FileSystem/operations/getReadUrl.js +16 -14
- package/src/modules/FileSystem/operations/mkdir.js +11 -11
- package/src/modules/FileSystem/operations/move.js +12 -12
- package/src/modules/FileSystem/operations/read.js +10 -10
- package/src/modules/FileSystem/operations/readdir.js +28 -28
- package/src/modules/FileSystem/operations/rename.js +11 -11
- package/src/modules/FileSystem/operations/sign.js +33 -30
- package/src/modules/FileSystem/operations/space.js +7 -7
- package/src/modules/FileSystem/operations/stat.js +25 -25
- package/src/modules/FileSystem/operations/symlink.js +15 -17
- package/src/modules/FileSystem/operations/upload.js +151 -122
- package/src/modules/FileSystem/operations/write.js +16 -12
- package/src/modules/FileSystem/utils/getAbsolutePathForApp.js +10 -6
- package/src/modules/Hosting.js +29 -29
- package/src/modules/KV.js +23 -23
- package/src/modules/OS.js +15 -15
- package/src/modules/Perms.js +19 -21
- package/src/modules/PuterDialog.js +46 -48
- package/src/modules/Threads.js +17 -20
- package/src/modules/UI.js +156 -156
- package/src/modules/Util.js +3 -3
- package/src/modules/Workers.js +52 -49
- package/src/modules/networking/PSocket.js +38 -38
- package/src/modules/networking/PTLS.js +54 -47
- package/src/modules/networking/PWispHandler.js +49 -47
- package/src/modules/networking/parsers.js +110 -108
- package/src/modules/networking/requests.js +67 -78
- package/src/services/APIAccess.js +9 -9
- package/src/services/FSRelay.js +6 -6
- package/src/services/Filesystem.js +8 -8
- package/src/services/NoPuterYet.js +2 -2
- package/src/services/XDIncoming.js +1 -1
package/index.d.ts
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Puter } from './types/puter.d.ts';
|
|
2
|
+
import type { AI, ChatMessage, ChatOptions, ChatResponse, ChatResponseChunk, Img2TxtOptions, Speech2SpeechOptions, Speech2TxtOptions, Txt2ImgOptions, Txt2SpeechCallable, Txt2SpeechOptions, Txt2VidOptions } from './types/modules/ai.d.ts';
|
|
3
|
+
import type { Apps, AppListOptions, AppRecord, CreateAppOptions, UpdateAppAttributes } from './types/modules/apps.d.ts';
|
|
4
|
+
import type { Auth, APIUsage, AllowanceInfo, AppUsage, AuthUser, DetailedAppUsage, MonthlyUsage } from './types/modules/auth.d.ts';
|
|
5
|
+
import type { Debug } from './types/modules/debug.d.ts';
|
|
6
|
+
import type { Driver, DriverDescriptor, Drivers } from './types/modules/drivers.d.ts';
|
|
7
|
+
import type { PuterJSFileSystemModule, CopyOptions, DeleteOptions, MkdirOptions, MoveOptions, ReadOptions, ReaddirOptions, SignResult, SpaceInfo, UploadOptions, WriteOptions } from './types/modules/filesystem.d.ts';
|
|
8
|
+
import type { FSItem, FileSignatureInfo, InternalFSProperties } from './types/modules/fs-item.d.ts';
|
|
9
|
+
import type { Hosting, Subdomain } from './types/modules/hosting.d.ts';
|
|
10
|
+
import type { KV, KVIncrementPath, KVPair } from './types/modules/kv.d.ts';
|
|
11
|
+
import type { Networking, PSocket, PTLSSocket } from './types/modules/networking.d.ts';
|
|
12
|
+
import type { OS } from './types/modules/os.d.ts';
|
|
13
|
+
import type { Perms } from './types/modules/perms.d.ts';
|
|
14
|
+
import type Threads from './types/modules/threads.d.ts';
|
|
15
|
+
import type { AlertButton, AppConnection, AppConnectionCloseEvent, CancelAwarePromise, ContextMenuItem, ContextMenuOptions, DirectoryPickerOptions, FilePickerOptions, LaunchAppOptions, MenuItem, MenubarOptions, ThemeData, UI, WindowOptions } from './types/modules/ui.d.ts';
|
|
16
|
+
import type Util, { UtilRPC } from './types/modules/util.d.ts';
|
|
17
|
+
import type { WorkerDeployment, WorkerInfo, WorkersHandler } from './types/modules/workers.d.ts';
|
|
18
|
+
import type { APICallLogger, APILoggingConfig, PaginationOptions, PaginatedResult, PuterEnvironment, RequestCallbacks, ToolSchema } from './types/shared.d.ts';
|
|
2
19
|
|
|
3
20
|
declare global {
|
|
4
21
|
interface Window {
|
|
@@ -6,633 +23,93 @@ declare global {
|
|
|
6
23
|
}
|
|
7
24
|
}
|
|
8
25
|
|
|
9
|
-
declare class Puter {
|
|
10
|
-
// Properties
|
|
11
|
-
appID: string;
|
|
12
|
-
env: 'app' | 'web' | 'gui' | 'nodejs' | 'service-worker';
|
|
13
|
-
|
|
14
|
-
// Utility methods
|
|
15
|
-
print(text: string, options?: { code?: boolean }): void;
|
|
16
|
-
randName(separator?: string): string;
|
|
17
|
-
exit(statusCode?: number): void;
|
|
18
|
-
|
|
19
|
-
// Sub-modules
|
|
20
|
-
ai: AI;
|
|
21
|
-
apps: Apps;
|
|
22
|
-
auth: Auth;
|
|
23
|
-
drivers: Drivers;
|
|
24
|
-
fs: FileSystem;
|
|
25
|
-
hosting: Hosting;
|
|
26
|
-
kv: KV;
|
|
27
|
-
net: Networking;
|
|
28
|
-
perms: Permissions;
|
|
29
|
-
ui: UI;
|
|
30
|
-
workers: Workers;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// AI Module
|
|
34
|
-
interface AI {
|
|
35
|
-
// Streaming overloads
|
|
36
|
-
chat(prompt: string, options: StreamingChatOptions): AsyncIterable<ChatResponseChunk>;
|
|
37
|
-
chat(prompt: string, testMode: boolean, options: StreamingChatOptions): AsyncIterable<ChatResponseChunk>;
|
|
38
|
-
chat(prompt: string, imageURL: string, testMode: boolean, options: StreamingChatOptions): AsyncIterable<ChatResponseChunk>;
|
|
39
|
-
chat(prompt: string, imageURLArray: string[], testMode: boolean, options: StreamingChatOptions): AsyncIterable<ChatResponseChunk>;
|
|
40
|
-
chat(messages: ChatMessage[], testMode: boolean, options: StreamingChatOptions): AsyncIterable<ChatResponseChunk>;
|
|
41
|
-
|
|
42
|
-
// Non-streaming overloads
|
|
43
|
-
chat(prompt: string, options?: NonStreamingChatOptions): Promise<ChatResponse>;
|
|
44
|
-
chat(prompt: string, testMode?: boolean, options?: NonStreamingChatOptions): Promise<ChatResponse>;
|
|
45
|
-
chat(prompt: string, imageURL?: string, testMode?: boolean, options?: NonStreamingChatOptions): Promise<ChatResponse>;
|
|
46
|
-
chat(prompt: string, imageURLArray?: string[], testMode?: boolean, options?: NonStreamingChatOptions): Promise<ChatResponse>;
|
|
47
|
-
chat(messages: ChatMessage[], testMode?: boolean, options?: NonStreamingChatOptions): Promise<ChatResponse>;
|
|
48
|
-
|
|
49
|
-
img2txt(image: string | File | Blob, testMode?: boolean): Promise<string>;
|
|
50
|
-
img2txt(image: string | File | Blob, options?: Img2TxtOptions): Promise<string>;
|
|
51
|
-
img2txt(image: string | File | Blob, testMode?: boolean, options?: Img2TxtOptions): Promise<string>;
|
|
52
|
-
img2txt(options: Img2TxtOptions): Promise<string>;
|
|
53
|
-
|
|
54
|
-
txt2img(prompt: string, testMode?: boolean): Promise<HTMLImageElement>;
|
|
55
|
-
txt2img(prompt: string, options?: Txt2ImgOptions): Promise<HTMLImageElement>;
|
|
56
|
-
|
|
57
|
-
txt2vid(prompt: string, testMode?: boolean): Promise<HTMLVideoElement>;
|
|
58
|
-
txt2vid(prompt: string, options?: Txt2VidOptions): Promise<HTMLVideoElement>;
|
|
59
|
-
|
|
60
|
-
txt2speech(text: string): Promise<HTMLAudioElement>;
|
|
61
|
-
txt2speech(text: string, options?: Txt2SpeechOptions): Promise<HTMLAudioElement>;
|
|
62
|
-
txt2speech(text: string, language?: string): Promise<HTMLAudioElement>;
|
|
63
|
-
txt2speech(text: string, language?: string, voice?: string): Promise<HTMLAudioElement>;
|
|
64
|
-
txt2speech(text: string, language?: string, voice?: string, engine?: string): Promise<HTMLAudioElement>;
|
|
65
|
-
|
|
66
|
-
speech2txt(source: string | File | Blob): Promise<string | Speech2TxtResult>;
|
|
67
|
-
speech2txt(source: string | File | Blob, options?: Speech2TxtOptions): Promise<string | Speech2TxtResult>;
|
|
68
|
-
speech2txt(options: Speech2TxtOptions): Promise<string | Speech2TxtResult>;
|
|
69
|
-
speech2txt(source: string | File | Blob, testMode?: boolean): Promise<string | Speech2TxtResult>;
|
|
70
|
-
speech2txt(source: Speech2TxtOptions, testMode?: boolean): Promise<string | Speech2TxtResult>;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
type StreamingChatOptions = Omit<ChatOptions, "stream"> & { stream: true };
|
|
74
|
-
type NonStreamingChatOptions = Omit<ChatOptions, "stream"> & { stream?: false | undefined };
|
|
75
|
-
|
|
76
|
-
interface ChatOptions {
|
|
77
|
-
model?: string;
|
|
78
|
-
stream?: boolean;
|
|
79
|
-
max_tokens?: number;
|
|
80
|
-
temperature?: number;
|
|
81
|
-
reasoning?: {
|
|
82
|
-
effort?: 'none' | 'low' | 'medium' | 'high' | 'minimal';
|
|
83
|
-
[key: string]: unknown;
|
|
84
|
-
};
|
|
85
|
-
reasoning_effort?: 'none' | 'low' | 'medium' | 'high' | 'minimal';
|
|
86
|
-
text?: {
|
|
87
|
-
verbosity?: 'low' | 'medium' | 'high';
|
|
88
|
-
[key: string]: unknown;
|
|
89
|
-
};
|
|
90
|
-
verbosity?: 'low' | 'medium' | 'high';
|
|
91
|
-
tools?: ToolDefinition[];
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
interface ToolDefinition {
|
|
95
|
-
type: 'function';
|
|
96
|
-
function: {
|
|
97
|
-
name: string;
|
|
98
|
-
description: string;
|
|
99
|
-
parameters: object;
|
|
100
|
-
strict?: boolean;
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
interface ChatMessage {
|
|
105
|
-
role: 'system' | 'assistant' | 'user' | 'function' | 'tool';
|
|
106
|
-
content: string | ContentObject[];
|
|
107
|
-
tool_call_id?: string;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
interface ContentObject {
|
|
111
|
-
type: 'text' | 'file';
|
|
112
|
-
text?: string;
|
|
113
|
-
puter_path?: string;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
interface ChatResponse {
|
|
117
|
-
message: {
|
|
118
|
-
role: string;
|
|
119
|
-
content: string;
|
|
120
|
-
tool_calls?: ToolCall[];
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
interface ToolCall {
|
|
125
|
-
id: string;
|
|
126
|
-
function: {
|
|
127
|
-
name: string;
|
|
128
|
-
arguments: string;
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
interface Txt2ImgOptions {
|
|
133
|
-
model?: 'gpt-image-1' | 'gpt-image-1-mini' | 'gemini-2.5-flash-image-preview' | 'dall-e-3';
|
|
134
|
-
quality?: 'high' | 'medium' | 'low' | 'hd' | 'standard';
|
|
135
|
-
input_image?: string;
|
|
136
|
-
input_image_mime_type?: string;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
interface Txt2VidOptions {
|
|
140
|
-
prompt?: string;
|
|
141
|
-
model?: string;
|
|
142
|
-
duration?: number;
|
|
143
|
-
seconds?: number;
|
|
144
|
-
size?: string;
|
|
145
|
-
resolution?: string;
|
|
146
|
-
width?: number;
|
|
147
|
-
height?: number;
|
|
148
|
-
fps?: number;
|
|
149
|
-
steps?: number;
|
|
150
|
-
guidance_scale?: number;
|
|
151
|
-
seed?: number;
|
|
152
|
-
output_format?: string;
|
|
153
|
-
output_quality?: number;
|
|
154
|
-
negative_prompt?: string;
|
|
155
|
-
reference_images?: string[];
|
|
156
|
-
frame_images?: Array<Record<string, unknown>>;
|
|
157
|
-
metadata?: Record<string, unknown>;
|
|
158
|
-
provider?: string;
|
|
159
|
-
service?: string;
|
|
160
|
-
driver?: string;
|
|
161
|
-
test_mode?: boolean;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
interface Img2TxtOptions {
|
|
165
|
-
source?: string | File | Blob;
|
|
166
|
-
provider?: 'aws-textract' | 'mistral';
|
|
167
|
-
model?: string;
|
|
168
|
-
pages?: number[];
|
|
169
|
-
includeImageBase64?: boolean;
|
|
170
|
-
imageLimit?: number;
|
|
171
|
-
imageMinSize?: number;
|
|
172
|
-
bboxAnnotationFormat?: Record<string, unknown>;
|
|
173
|
-
documentAnnotationFormat?: Record<string, unknown>;
|
|
174
|
-
testMode?: boolean;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
interface Txt2SpeechOptions {
|
|
178
|
-
language?: string;
|
|
179
|
-
voice?: string;
|
|
180
|
-
engine?: 'standard' | 'neural' | 'long-form' | 'generative' | string;
|
|
181
|
-
provider?: 'aws-polly' | 'openai' | string;
|
|
182
|
-
model?: 'gpt-4o-mini-tts' | 'tts-1' | 'tts-1-hd' | string;
|
|
183
|
-
response_format?: 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm' | string;
|
|
184
|
-
instructions?: string;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
interface Speech2TxtOptions {
|
|
188
|
-
file?: string | File | Blob;
|
|
189
|
-
audio?: string | File | Blob;
|
|
190
|
-
model?: 'gpt-4o-mini-transcribe' | 'gpt-4o-transcribe' | 'gpt-4o-transcribe-diarize' | 'whisper-1' | string;
|
|
191
|
-
response_format?: 'json' | 'text' | 'diarized_json' | 'srt' | 'verbose_json' | 'vtt' | string;
|
|
192
|
-
language?: string;
|
|
193
|
-
prompt?: string;
|
|
194
|
-
temperature?: number;
|
|
195
|
-
logprobs?: boolean;
|
|
196
|
-
timestamp_granularities?: string[];
|
|
197
|
-
translate?: boolean;
|
|
198
|
-
stream?: boolean;
|
|
199
|
-
chunking_strategy?: string;
|
|
200
|
-
known_speaker_names?: string[];
|
|
201
|
-
known_speaker_references?: string[];
|
|
202
|
-
extra_body?: Record<string, unknown>;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
interface Speech2TxtResult {
|
|
206
|
-
text?: string;
|
|
207
|
-
language?: string;
|
|
208
|
-
segments?: Array<Record<string, unknown>>;
|
|
209
|
-
[key: string]: any;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
interface ChatResponseChunk {
|
|
213
|
-
text?: string;
|
|
214
|
-
[key: string]: any;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Apps Module
|
|
218
|
-
interface Apps {
|
|
219
|
-
create(name: string, indexURL: string): Promise<App>;
|
|
220
|
-
create(name: string, indexURL: string, title?: string): Promise<App>;
|
|
221
|
-
create(name: string, indexURL: string, title?: string, description?: string): Promise<App>;
|
|
222
|
-
create(options: CreateAppOptions): Promise<App>;
|
|
223
|
-
|
|
224
|
-
delete(name: string): Promise<App>;
|
|
225
|
-
get(name: string, options?: GetAppOptions): Promise<App>;
|
|
226
|
-
list(options?: ListAppOptions): Promise<App[]>;
|
|
227
|
-
update(name: string, attributes: UpdateAppAttributes): Promise<App>;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
interface CreateAppOptions {
|
|
231
|
-
name: string;
|
|
232
|
-
indexURL: string;
|
|
233
|
-
title?: string;
|
|
234
|
-
description?: string;
|
|
235
|
-
icon?: string;
|
|
236
|
-
maximizeOnStart?: boolean;
|
|
237
|
-
filetypeAssociations?: string[];
|
|
238
|
-
dedupeName?: boolean;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
interface GetAppOptions {
|
|
242
|
-
stats_period?: StatsPeriod;
|
|
243
|
-
icon_size?: null | 16 | 32 | 64 | 128 | 256 | 512;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
interface ListAppOptions extends GetAppOptions { }
|
|
247
|
-
|
|
248
|
-
interface UpdateAppAttributes {
|
|
249
|
-
name?: string;
|
|
250
|
-
indexURL?: string;
|
|
251
|
-
title?: string;
|
|
252
|
-
description?: string;
|
|
253
|
-
icon?: string;
|
|
254
|
-
maximizeOnStart?: boolean;
|
|
255
|
-
filetypeAssociations?: string[];
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
type StatsPeriod = 'all' | 'today' | 'yesterday' | '7d' | '30d' | 'this_month' | 'last_month' | 'this_year' | 'last_year' | 'month_to_date' | 'year_to_date' | 'last_12_months';
|
|
259
|
-
|
|
260
|
-
interface App {
|
|
261
|
-
uid: string;
|
|
262
|
-
name: string;
|
|
263
|
-
icon: string;
|
|
264
|
-
description: string;
|
|
265
|
-
title: string;
|
|
266
|
-
maximize_on_start: boolean;
|
|
267
|
-
index_url: string;
|
|
268
|
-
created_at: string;
|
|
269
|
-
background: boolean;
|
|
270
|
-
filetype_associations: string[];
|
|
271
|
-
open_count: number;
|
|
272
|
-
user_count: number;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// Auth Module
|
|
276
|
-
interface Auth {
|
|
277
|
-
signIn(options?: { attempt_temp_user_creation?: boolean }): Promise<boolean>;
|
|
278
|
-
signOut(): void;
|
|
279
|
-
isSignedIn(): boolean;
|
|
280
|
-
getUser(): Promise<User>;
|
|
281
|
-
getMonthlyUsage(): Promise<MonthlyUsage>;
|
|
282
|
-
getDetailedAppUsage(appId: string): Promise<DetailedAppUsage>;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
interface User {
|
|
286
|
-
uuid: string;
|
|
287
|
-
username: string;
|
|
288
|
-
email_confirmed: boolean;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
interface AllowanceInfo {
|
|
292
|
-
monthUsageAllowance: number;
|
|
293
|
-
remaining: number;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
interface AppUsage {
|
|
297
|
-
count: number;
|
|
298
|
-
total: number;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
interface APIUsage {
|
|
302
|
-
cost: number;
|
|
303
|
-
count: number;
|
|
304
|
-
units: number;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
interface MonthlyUsage {
|
|
308
|
-
allowanceInfo: AllowanceInfo;
|
|
309
|
-
appTotals: Record<string, AppUsage>;
|
|
310
|
-
usage: Record<string, APIUsage>;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
interface DetailedAppUsage {
|
|
314
|
-
total: number;
|
|
315
|
-
[key: string]: APIUsage;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// Drivers Module
|
|
319
|
-
interface Drivers {
|
|
320
|
-
call(interface: string, driver: string, method: string, args?: object): Promise<any>;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
// FileSystem Module
|
|
324
|
-
interface FileSystem {
|
|
325
|
-
copy(source: string, destination: string, options?: CopyOptions): Promise<FSItem>;
|
|
326
|
-
delete(path: string, options?: DeleteOptions): Promise<void>;
|
|
327
|
-
getReadURL(path: string, expiresIn?: number): Promise<string>;
|
|
328
|
-
mkdir(path: string, options?: MkdirOptions): Promise<FSItem>;
|
|
329
|
-
move(source: string, destination: string, options?: MoveOptions): Promise<FSItem>;
|
|
330
|
-
read(path: string, options?: ReadOptions): Promise<Blob>;
|
|
331
|
-
readdir(path: string, options?: ReaddirOptions): Promise<FSItem[]>;
|
|
332
|
-
readdir(options?: ReaddirOptions): Promise<FSItem[]>;
|
|
333
|
-
rename(path: string, newName: string): Promise<FSItem>;
|
|
334
|
-
space(): Promise<SpaceInfo>;
|
|
335
|
-
stat(path: string): Promise<FSItem>;
|
|
336
|
-
upload(items: FileList | File[] | Blob[], dirPath?: string, options?: UploadOptions): Promise<FSItem[]>;
|
|
337
|
-
write(path: string, data?: string | File | Blob, options?: WriteOptions): Promise<FSItem>;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
interface CopyOptions {
|
|
341
|
-
overwrite?: boolean;
|
|
342
|
-
dedupeName?: boolean;
|
|
343
|
-
newName?: string;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
interface DeleteOptions {
|
|
347
|
-
recursive?: boolean;
|
|
348
|
-
descendantsOnly?: boolean;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
interface MkdirOptions {
|
|
352
|
-
overwrite?: boolean;
|
|
353
|
-
dedupeName?: boolean;
|
|
354
|
-
createMissingParents?: boolean;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
interface MoveOptions extends CopyOptions {
|
|
358
|
-
createMissingParents?: boolean;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
interface ReadOptions {
|
|
362
|
-
offset?: number;
|
|
363
|
-
byte_count?: number;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
interface ReaddirOptions {
|
|
367
|
-
path?: string;
|
|
368
|
-
uid?: string;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
interface WriteOptions {
|
|
372
|
-
overwrite?: boolean;
|
|
373
|
-
dedupeName?: boolean;
|
|
374
|
-
createMissingParents?: boolean;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
interface UploadOptions {
|
|
378
|
-
overwrite?: boolean;
|
|
379
|
-
dedupeName?: boolean;
|
|
380
|
-
name?: string;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
interface SpaceInfo {
|
|
384
|
-
capacity: number;
|
|
385
|
-
used: number;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
interface FSItem {
|
|
389
|
-
id: string;
|
|
390
|
-
uid: string;
|
|
391
|
-
name: string;
|
|
392
|
-
path: string;
|
|
393
|
-
is_dir: boolean;
|
|
394
|
-
parent_id: string;
|
|
395
|
-
parent_uid: string;
|
|
396
|
-
created: number;
|
|
397
|
-
modified: number;
|
|
398
|
-
accessed: number;
|
|
399
|
-
size: number | null;
|
|
400
|
-
writable: boolean;
|
|
401
|
-
read(): Promise<Blob>;
|
|
402
|
-
readdir(): Promise<FSItem[]>;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// Hosting Module
|
|
406
|
-
interface Hosting {
|
|
407
|
-
create(subdomain: string, dirPath?: string): Promise<Subdomain>;
|
|
408
|
-
delete(subdomain: string): Promise<boolean>;
|
|
409
|
-
get(subdomain: string): Promise<Subdomain>;
|
|
410
|
-
list(): Promise<Subdomain[]>;
|
|
411
|
-
update(subdomain: string, dirPath?: string): Promise<Subdomain>;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
interface Subdomain {
|
|
415
|
-
uid: string;
|
|
416
|
-
subdomain: string;
|
|
417
|
-
root_dir: FSItem;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
// Key-Value Store Module
|
|
421
|
-
interface KV {
|
|
422
|
-
set(key: string, value: string | number | boolean | object | any[]): Promise<boolean>;
|
|
423
|
-
get(key: string): Promise<any>;
|
|
424
|
-
del(key: string): Promise<boolean>;
|
|
425
|
-
incr(key: string, pathAndAmount: { [key: string]: number }): Promise<number>;
|
|
426
|
-
incr(key: string, amount?: number): Promise<number>;
|
|
427
|
-
decr(key: string, pathAndAmount: { [key: string]: number }): Promise<number>;
|
|
428
|
-
decr(key: string, amount?: number): Promise<number>;
|
|
429
|
-
list(pattern?: string, returnValues?: boolean): Promise<string[] | KVPair[]>;
|
|
430
|
-
list(returnValues?: boolean): Promise<string[] | KVPair[]>;
|
|
431
|
-
flush(): Promise<boolean>;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
interface KVPair {
|
|
435
|
-
key: string;
|
|
436
|
-
value: any;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
// Networking Module
|
|
440
|
-
interface Networking {
|
|
441
|
-
fetch(url: string, options?: RequestInit): Promise<Response>;
|
|
442
|
-
Socket: typeof Socket;
|
|
443
|
-
tls: {
|
|
444
|
-
TLSSocket: typeof TLSSocket;
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
declare class Socket {
|
|
449
|
-
constructor(hostname: string, port: number);
|
|
450
|
-
write(data: ArrayBuffer | Uint8Array | string): void;
|
|
451
|
-
close(): void;
|
|
452
|
-
on(event: 'open', callback: () => void): void;
|
|
453
|
-
on(event: 'data', callback: (buffer: Uint8Array) => void): void;
|
|
454
|
-
on(event: 'error', callback: (reason: string) => void): void;
|
|
455
|
-
on(event: 'close', callback: (hadError: boolean) => void): void;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
declare class TLSSocket extends Socket {
|
|
459
|
-
constructor(hostname: string, port: number);
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
// Permissions Module
|
|
463
|
-
interface Permissions {
|
|
464
|
-
grantApp(app_uid: string, permissionString: string): Promise<object>;
|
|
465
|
-
grantAppAnyUser(app_uid: string, permissionString: string): Promise<object>;
|
|
466
|
-
grantGroup(group_uid: string, permissionString: string): Promise<object>;
|
|
467
|
-
grantOrigin(origin: string, permissionString: string): Promise<object>;
|
|
468
|
-
grantUser(username: string, permissionString: string): Promise<object>;
|
|
469
|
-
revokeApp(app_uid: string, permissionString: string): Promise<object>;
|
|
470
|
-
revokeAppAnyUser(app_uid: string, permissionString: string): Promise<object>;
|
|
471
|
-
revokeGroup(group_uid: string, permissionString: string): Promise<object>;
|
|
472
|
-
revokeOrigin(origin: string, permissionString: string): Promise<object>;
|
|
473
|
-
revokeUser(username: string, permissionString: string): Promise<object>;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
// UI Module
|
|
477
|
-
interface UI {
|
|
478
|
-
alert(message?: string, buttons?: AlertButton[]): Promise<string>;
|
|
479
|
-
prompt(message?: string, defaultValue?: string): Promise<string | null>;
|
|
480
|
-
authenticateWithPuter(): Promise<boolean>;
|
|
481
|
-
contextMenu(options: ContextMenuOptions): void;
|
|
482
|
-
createWindow(options?: WindowOptions): void;
|
|
483
|
-
exit(statusCode?: number): void;
|
|
484
|
-
getLanguage(): Promise<string>;
|
|
485
|
-
hideSpinner(): void;
|
|
486
|
-
launchApp(appName?: string, args?: object): Promise<AppConnection>;
|
|
487
|
-
launchApp(options: LaunchAppOptions): Promise<AppConnection>;
|
|
488
|
-
on(eventName: 'localeChanged', handler: (data: { language: string }) => void): void;
|
|
489
|
-
on(eventName: 'themeChanged', handler: (data: ThemeData) => void): void;
|
|
490
|
-
onItemsOpened(handler: (items: FSItem[]) => void): void;
|
|
491
|
-
onLaunchedWithItems(handler: (items: FSItem[]) => void): void;
|
|
492
|
-
onWindowClose(handler: () => void): void;
|
|
493
|
-
parentApp(): AppConnection | null;
|
|
494
|
-
setMenubar(options: MenubarOptions): void;
|
|
495
|
-
setWindowHeight(height: number): void;
|
|
496
|
-
setWindowPosition(x: number, y: number): void;
|
|
497
|
-
setWindowSize(width: number, height: number): void;
|
|
498
|
-
setWindowTitle(title: string): void;
|
|
499
|
-
setWindowWidth(width: number): void;
|
|
500
|
-
setWindowX(x: number): void;
|
|
501
|
-
setWindowY(y: number): void;
|
|
502
|
-
showColorPicker(defaultColor?: string): Promise<string>;
|
|
503
|
-
showColorPicker(options?: object): Promise<string>;
|
|
504
|
-
showDirectoryPicker(options?: { multiple?: boolean }): Promise<FSItem | FSItem[]>;
|
|
505
|
-
showFontPicker(defaultFont?: string): Promise<{ fontFamily: string }>;
|
|
506
|
-
showFontPicker(options?: object): Promise<{ fontFamily: string }>;
|
|
507
|
-
showOpenFilePicker(options?: FilePickerOptions): Promise<FSItem | FSItem[]>;
|
|
508
|
-
showSaveFilePicker(data?: any, defaultFileName?: string): Promise<FSItem>;
|
|
509
|
-
showSpinner(): void;
|
|
510
|
-
socialShare(url: string, message?: string, options?: { left?: number; top?: number }): void;
|
|
511
|
-
wasLaunchedWithItems(): boolean;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
interface AlertButton {
|
|
515
|
-
label: string;
|
|
516
|
-
value?: string;
|
|
517
|
-
type?: 'primary' | 'success' | 'info' | 'warning' | 'danger';
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
interface ContextMenuOptions {
|
|
521
|
-
items: (ContextMenuItem | '-')[];
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
interface ContextMenuItem {
|
|
525
|
-
label: string;
|
|
526
|
-
action?: () => void;
|
|
527
|
-
icon?: string;
|
|
528
|
-
icon_active?: string;
|
|
529
|
-
disabled?: boolean;
|
|
530
|
-
items?: (ContextMenuItem | '-')[];
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
interface WindowOptions {
|
|
534
|
-
center?: boolean;
|
|
535
|
-
content?: string;
|
|
536
|
-
disable_parent_window?: boolean;
|
|
537
|
-
has_head?: boolean;
|
|
538
|
-
height?: number;
|
|
539
|
-
is_resizable?: boolean;
|
|
540
|
-
show_in_taskbar?: boolean;
|
|
541
|
-
title?: string;
|
|
542
|
-
width?: number;
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
interface LaunchAppOptions {
|
|
546
|
-
name?: string;
|
|
547
|
-
args?: object;
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
interface ThemeData {
|
|
551
|
-
palette: {
|
|
552
|
-
primaryHue: number;
|
|
553
|
-
primarySaturation: string;
|
|
554
|
-
primaryLightness: string;
|
|
555
|
-
primaryAlpha: number;
|
|
556
|
-
primaryColor: string;
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
interface MenubarOptions {
|
|
561
|
-
items: MenuItem[];
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
interface MenuItem {
|
|
565
|
-
label: string;
|
|
566
|
-
action?: () => void;
|
|
567
|
-
items?: MenuItem[];
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
interface FilePickerOptions {
|
|
571
|
-
multiple?: boolean;
|
|
572
|
-
accept?: string | string[];
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
interface AppConnection {
|
|
576
|
-
usesSDK: boolean;
|
|
577
|
-
on(eventName: 'message', handler: (message: any) => void): void;
|
|
578
|
-
on(eventName: 'close', handler: (data: { appInstanceID: string }) => void): void;
|
|
579
|
-
off(eventName: string, handler: Function): void;
|
|
580
|
-
postMessage(message: any): void;
|
|
581
|
-
close(): void;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
// Workers Module
|
|
585
|
-
interface Workers {
|
|
586
|
-
create(workerName: string, filePath: string): Promise<WorkerDeployment>;
|
|
587
|
-
delete(workerName: string): Promise<boolean>;
|
|
588
|
-
exec(workerURL: string, options?: WorkerExecOptions): Promise<Response>;
|
|
589
|
-
get(workerName: string): Promise<WorkerInfo>;
|
|
590
|
-
list(): Promise<WorkerInfo[]>;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
interface WorkerDeployment {
|
|
594
|
-
success: boolean;
|
|
595
|
-
url: string;
|
|
596
|
-
errors: any[];
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
interface WorkerExecOptions extends RequestInit {
|
|
600
|
-
method?: string;
|
|
601
|
-
headers?: object;
|
|
602
|
-
body?: string | object;
|
|
603
|
-
cache?: RequestCache;
|
|
604
|
-
credentials?: RequestCredentials;
|
|
605
|
-
mode?: RequestMode;
|
|
606
|
-
redirect?: RequestRedirect;
|
|
607
|
-
referrer?: string;
|
|
608
|
-
signal?: AbortSignal;
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
interface WorkerInfo {
|
|
612
|
-
name: string;
|
|
613
|
-
url: string;
|
|
614
|
-
file_path: string;
|
|
615
|
-
file_uid: string;
|
|
616
|
-
created_at: string;
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
// Global puter instance
|
|
620
26
|
declare const puter: Puter;
|
|
621
27
|
|
|
622
|
-
// Export the Puter class as both default and named export
|
|
623
28
|
export default puter;
|
|
624
|
-
export { puter };
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
29
|
+
export { puter, Puter };
|
|
30
|
+
|
|
31
|
+
export type {
|
|
32
|
+
AI,
|
|
33
|
+
APIUsage,
|
|
34
|
+
APICallLogger,
|
|
35
|
+
APILoggingConfig,
|
|
36
|
+
AlertButton,
|
|
37
|
+
AllowanceInfo,
|
|
38
|
+
CancelAwarePromise,
|
|
39
|
+
AppConnection,
|
|
40
|
+
AppConnectionCloseEvent,
|
|
41
|
+
AppListOptions,
|
|
42
|
+
AppRecord,
|
|
43
|
+
AppUsage,
|
|
44
|
+
Apps,
|
|
45
|
+
Auth,
|
|
46
|
+
AuthUser,
|
|
47
|
+
ChatMessage,
|
|
48
|
+
ChatOptions,
|
|
49
|
+
ChatResponse,
|
|
50
|
+
ChatResponseChunk,
|
|
51
|
+
ContextMenuItem,
|
|
52
|
+
ContextMenuOptions,
|
|
53
|
+
CopyOptions,
|
|
54
|
+
CreateAppOptions,
|
|
55
|
+
Debug,
|
|
56
|
+
DeleteOptions,
|
|
57
|
+
DetailedAppUsage,
|
|
58
|
+
DirectoryPickerOptions,
|
|
59
|
+
Driver,
|
|
60
|
+
DriverDescriptor,
|
|
61
|
+
Drivers,
|
|
62
|
+
FSItem,
|
|
63
|
+
FilePickerOptions,
|
|
64
|
+
FileSignatureInfo,
|
|
65
|
+
Hosting,
|
|
66
|
+
Img2TxtOptions,
|
|
67
|
+
InternalFSProperties,
|
|
630
68
|
KV,
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
69
|
+
KVIncrementPath,
|
|
70
|
+
KVPair,
|
|
71
|
+
LaunchAppOptions,
|
|
72
|
+
MenuItem,
|
|
73
|
+
MenubarOptions,
|
|
74
|
+
MkdirOptions,
|
|
75
|
+
MonthlyUsage,
|
|
76
|
+
MoveOptions,
|
|
77
|
+
Networking,
|
|
78
|
+
OS,
|
|
79
|
+
PaginatedResult,
|
|
80
|
+
PaginationOptions,
|
|
81
|
+
Perms,
|
|
82
|
+
PSocket,
|
|
83
|
+
PTLSSocket,
|
|
84
|
+
Puter,
|
|
85
|
+
PuterEnvironment,
|
|
86
|
+
PuterJSFileSystemModule,
|
|
87
|
+
ReadOptions,
|
|
88
|
+
ReaddirOptions,
|
|
89
|
+
RequestCallbacks,
|
|
90
|
+
SignResult,
|
|
91
|
+
SpaceInfo,
|
|
92
|
+
Speech2SpeechOptions,
|
|
93
|
+
Speech2TxtOptions,
|
|
94
|
+
Subdomain,
|
|
95
|
+
ThemeData,
|
|
96
|
+
Threads,
|
|
97
|
+
ToolSchema,
|
|
98
|
+
Txt2ImgOptions,
|
|
99
|
+
Txt2SpeechCallable,
|
|
100
|
+
Txt2SpeechOptions,
|
|
101
|
+
Txt2VidOptions,
|
|
102
|
+
UI,
|
|
103
|
+
UpdateAppAttributes,
|
|
104
|
+
UploadOptions,
|
|
105
|
+
Util,
|
|
106
|
+
UtilRPC,
|
|
107
|
+
WindowOptions,
|
|
108
|
+
WorkerDeployment,
|
|
109
|
+
WorkerInfo,
|
|
110
|
+
WorkersHandler,
|
|
111
|
+
WriteOptions,
|
|
638
112
|
};
|
|
113
|
+
|
|
114
|
+
// NOTE: Provider-specific response bodies (AI, drivers, workers logging stream) intentionally
|
|
115
|
+
// remain loosely typed because the SDK does not yet expose stable shapes for those payloads.
|