@terminals-tech/sdk 1.0.0-rc.1 → 1.0.0-rc.2
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/WebContainerManager-SHXC5VKI.js +22 -0
- package/dist/browser-http-client-ZQLDWZMU.js +317 -0
- package/dist/cache-VKYSQRXX.js +45 -0
- package/dist/capabilities-MIPUMBLL.js +96 -0
- package/dist/chunk-2ESYSVXG.js +48 -0
- package/dist/chunk-2WTYE4SW.js +190 -0
- package/dist/chunk-3CEM77QZ.js +474 -0
- package/dist/chunk-3LFMIVJM.js +40 -0
- package/dist/chunk-ABCK4FWN.js +136 -0
- package/dist/chunk-AFDUOYHD.js +2060 -0
- package/dist/chunk-BCOQMFKT.js +265 -0
- package/dist/chunk-BKB3MD5Y.js +723 -0
- package/dist/chunk-BYXBJQAS.js +0 -0
- package/dist/chunk-DKFJIILR.js +9798 -0
- package/dist/chunk-EXI3LJVJ.js +51 -0
- package/dist/chunk-FOXUEYWK.js +42 -0
- package/dist/chunk-GJWAJAX3.js +173 -0
- package/dist/chunk-H3POJCFA.js +333 -0
- package/dist/chunk-KHR7ZYCX.js +4034 -0
- package/dist/chunk-NTMBOESX.js +152 -0
- package/dist/chunk-OSSRZOGC.js +190 -0
- package/dist/chunk-PUZ2S62E.js +977 -0
- package/dist/chunk-PWAHFID5.js +381 -0
- package/dist/chunk-Q2VI6ICE.js +188 -0
- package/dist/chunk-Q4B7YS7T.js +557 -0
- package/dist/chunk-QJFKEQHF.js +6460 -0
- package/dist/chunk-QWXPVB2L.js +320 -0
- package/dist/chunk-QWZRZKLZ.js +896 -0
- package/dist/chunk-SHPGIVDH.js +5521 -0
- package/dist/chunk-TSQ3BGLA.js +11945 -0
- package/dist/chunk-UJDUQNE2.js +79 -0
- package/dist/chunk-UKVUPKZP.js +296 -0
- package/dist/chunk-VZA2NUH3.js +118 -0
- package/dist/chunk-WGBCRNMB.js +1817 -0
- package/dist/chunk-WU4OTGJE.js +752 -0
- package/dist/chunk-XPJ63Y6T.js +70 -0
- package/dist/chunk-Y2EULKA2.js +172 -0
- package/dist/chunk-YJEZWCYV.js +94 -0
- package/dist/chunk-ZVO47SQV.js +150 -0
- package/dist/container-lite-KQX3NMPY.js +327 -0
- package/dist/core-H2UUDATO.js +146 -0
- package/dist/crypto-D4LMI2RN.js +45 -0
- package/dist/db-BWC2GGBN.js +50 -0
- package/dist/demo-VXMGMJNK.js +87 -0
- package/dist/diagnostics-6RQTBR6I.js +113 -0
- package/dist/dist-OPDCWARF.js +727 -0
- package/dist/dist-VXJEKX3T.js +2441 -0
- package/dist/dist-VYGJXGUS.js +1008 -0
- package/dist/embeddings-7QXTXUMC.js +15 -0
- package/dist/embeddings-MAEWWUHW.js +9 -0
- package/dist/graph-RKMNE2X5.js +36 -0
- package/dist/hvm-DRQK2MUT.js +126 -0
- package/dist/index.cjs +11706 -4004
- package/dist/index.d.cts +1299 -1339
- package/dist/index.d.ts +1299 -1339
- package/dist/index.js +189 -7938
- package/dist/mcp-NK34ZNM5.js +101 -0
- package/dist/mcp-client-service-browser-SGB2K3VZ.js +14 -0
- package/dist/neuro-state-XHRGIRVO.js +498 -0
- package/dist/nodes-DXKYDTVO.js +224 -0
- package/dist/package-EXUIU2RL.js +93 -0
- package/dist/package-VGL7HYTO.js +106 -0
- package/dist/package-XHMLOAQ4.js +98 -0
- package/dist/pg-events-QJAM2HIP.js +15 -0
- package/dist/pgliteService-IUGNNOVU.js +258 -0
- package/dist/policy-IRJCM6FS.js +13 -0
- package/dist/registry-BL3TDQDB.js +26 -0
- package/dist/registry-FW63E7FE.js +16 -0
- package/dist/registry-ZQ2IBLF6.js +9 -0
- package/dist/scheduler-H6Q53IMI.js +122 -0
- package/dist/secret-store-H7273UIT.js +18 -0
- package/dist/server-7DM74VFW.js +18 -0
- package/dist/skills-KLTTT2RM.js +6375 -0
- package/dist/stack-CHDAFU2S.js +103 -0
- package/dist/storage-L7MWNSPG.js +13 -0
- package/dist/supabaseService-6AYP2VY3.js +476 -0
- package/dist/topology-CIWWNVAN.js +13 -0
- package/dist/webcontainer-3LDJVIIL.js +281 -0
- package/package.json +2 -2
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProcessPriority,
|
|
3
|
+
WebContainerManager,
|
|
4
|
+
WebContainerManager_default
|
|
5
|
+
} from "./chunk-SHPGIVDH.js";
|
|
6
|
+
import "./chunk-DKFJIILR.js";
|
|
7
|
+
import "./chunk-KHR7ZYCX.js";
|
|
8
|
+
import "./chunk-QWZRZKLZ.js";
|
|
9
|
+
import "./chunk-OSSRZOGC.js";
|
|
10
|
+
import "./chunk-TSQ3BGLA.js";
|
|
11
|
+
import "./chunk-2WTYE4SW.js";
|
|
12
|
+
import "./chunk-QJFKEQHF.js";
|
|
13
|
+
import "./chunk-WGBCRNMB.js";
|
|
14
|
+
import "./chunk-3LFMIVJM.js";
|
|
15
|
+
import "./chunk-AFDUOYHD.js";
|
|
16
|
+
import "./chunk-NTMBOESX.js";
|
|
17
|
+
import "./chunk-2ESYSVXG.js";
|
|
18
|
+
export {
|
|
19
|
+
ProcessPriority,
|
|
20
|
+
WebContainerManager,
|
|
21
|
+
WebContainerManager_default as default
|
|
22
|
+
};
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ErrorCodes,
|
|
3
|
+
MCPError
|
|
4
|
+
} from "./chunk-OSSRZOGC.js";
|
|
5
|
+
import "./chunk-2ESYSVXG.js";
|
|
6
|
+
|
|
7
|
+
// ../../lib/terminals-tech/interfaces/mcp/browser-http-client.ts
|
|
8
|
+
var MCPHTTPClient = class {
|
|
9
|
+
config;
|
|
10
|
+
baseUrl;
|
|
11
|
+
sessionId = null;
|
|
12
|
+
requestId = 0;
|
|
13
|
+
notificationPollingInterval = null;
|
|
14
|
+
isPolling = false;
|
|
15
|
+
notificationHandlers = /* @__PURE__ */ new Map();
|
|
16
|
+
elicitationHandlers = /* @__PURE__ */ new Map();
|
|
17
|
+
protocolVersion = "2025-06-18";
|
|
18
|
+
authToken = null;
|
|
19
|
+
resourceIndicator = null;
|
|
20
|
+
constructor(config, auth) {
|
|
21
|
+
this.config = {
|
|
22
|
+
...config,
|
|
23
|
+
capabilities: {
|
|
24
|
+
experimental: {},
|
|
25
|
+
elicitation: true,
|
|
26
|
+
structuredContent: true,
|
|
27
|
+
...config.capabilities
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
this.baseUrl = "";
|
|
31
|
+
this.authToken = auth?.token || null;
|
|
32
|
+
this.resourceIndicator = auth?.resourceIndicator || null;
|
|
33
|
+
}
|
|
34
|
+
async connect(url) {
|
|
35
|
+
this.baseUrl = url;
|
|
36
|
+
try {
|
|
37
|
+
const initRequest = {
|
|
38
|
+
jsonrpc: "2.0",
|
|
39
|
+
id: this.getNextId(),
|
|
40
|
+
method: "initialize",
|
|
41
|
+
params: {
|
|
42
|
+
protocolVersion: this.protocolVersion,
|
|
43
|
+
capabilities: this.config.capabilities,
|
|
44
|
+
clientInfo: {
|
|
45
|
+
name: this.config.name,
|
|
46
|
+
version: this.config.version
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const response = await this.sendRequestWithRetry(initRequest, 3);
|
|
51
|
+
if (response.error) {
|
|
52
|
+
throw new MCPError(
|
|
53
|
+
`Failed to initialize: ${response.error.message}`,
|
|
54
|
+
ErrorCodes.MCP_CONNECTION_FAILED,
|
|
55
|
+
{ url, errorCode: response.error.code, errorData: response.error.data }
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
await this.sendNotification("initialized", {});
|
|
59
|
+
if (this.sessionId) {
|
|
60
|
+
this.startNotificationPolling();
|
|
61
|
+
}
|
|
62
|
+
console.log(
|
|
63
|
+
"[MCPHTTPClient] Connected to",
|
|
64
|
+
url,
|
|
65
|
+
"using protocol version",
|
|
66
|
+
this.protocolVersion
|
|
67
|
+
);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error("[MCPHTTPClient] Connection failed:", error);
|
|
70
|
+
throw new MCPError(
|
|
71
|
+
`Failed to connect to MCP server: ${error instanceof Error ? error.message : String(error)}`,
|
|
72
|
+
ErrorCodes.MCP_CONNECTION_FAILED,
|
|
73
|
+
{ url, originalError: error instanceof Error ? error.message : String(error) }
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
startNotificationPolling() {
|
|
78
|
+
if (this.isPolling || !this.sessionId) return;
|
|
79
|
+
this.isPolling = true;
|
|
80
|
+
this.notificationPollingInterval = setInterval(async () => {
|
|
81
|
+
try {
|
|
82
|
+
const response = await fetch(`${this.baseUrl}?action=poll`, {
|
|
83
|
+
method: "GET",
|
|
84
|
+
headers: {
|
|
85
|
+
"MCP-Protocol-Version": this.protocolVersion,
|
|
86
|
+
"mcp-session-id": this.sessionId,
|
|
87
|
+
...this.authToken ? { Authorization: `Bearer ${this.authToken}` } : {},
|
|
88
|
+
...this.resourceIndicator ? { "Resource-Indicator": this.resourceIndicator } : {}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
if (response.ok) {
|
|
92
|
+
const notifications = await response.json();
|
|
93
|
+
if (Array.isArray(notifications)) {
|
|
94
|
+
notifications.forEach((notification) => this.handleNotification(notification));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.warn("[MCPHTTPClient] Notification polling error:", error);
|
|
99
|
+
}
|
|
100
|
+
}, 1e3);
|
|
101
|
+
}
|
|
102
|
+
stopNotificationPolling() {
|
|
103
|
+
if (this.notificationPollingInterval) {
|
|
104
|
+
clearInterval(this.notificationPollingInterval);
|
|
105
|
+
this.notificationPollingInterval = null;
|
|
106
|
+
}
|
|
107
|
+
this.isPolling = false;
|
|
108
|
+
}
|
|
109
|
+
async sendRequestWithRetry(request, maxRetries = 3) {
|
|
110
|
+
let lastError = null;
|
|
111
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
112
|
+
try {
|
|
113
|
+
return await this.sendRequest(request);
|
|
114
|
+
} catch (error) {
|
|
115
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
116
|
+
console.warn(
|
|
117
|
+
`[MCPHTTPClient] Request attempt ${attempt}/${maxRetries} failed:`,
|
|
118
|
+
lastError.message
|
|
119
|
+
);
|
|
120
|
+
if (attempt < maxRetries) {
|
|
121
|
+
await new Promise((resolve) => setTimeout(resolve, 100 * Math.pow(2, attempt - 1)));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (lastError) {
|
|
126
|
+
throw lastError;
|
|
127
|
+
}
|
|
128
|
+
throw new Error("Request failed after max retries");
|
|
129
|
+
}
|
|
130
|
+
handleNotification(notification) {
|
|
131
|
+
if (!notification.method) return;
|
|
132
|
+
if (notification.method === "elicitationRequest") {
|
|
133
|
+
this.handleElicitationRequest(notification.params);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const handler = this.notificationHandlers.get(notification.method);
|
|
137
|
+
if (handler) {
|
|
138
|
+
handler(notification.params || {});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async handleElicitationRequest(params) {
|
|
142
|
+
const handler = this.elicitationHandlers.get("default");
|
|
143
|
+
if (handler) {
|
|
144
|
+
try {
|
|
145
|
+
const response = await handler(params);
|
|
146
|
+
await this.request("continueElicitation", response);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
console.error("[MCPHTTPClient] Elicitation handler error:", error);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
onNotification(method, handler) {
|
|
153
|
+
this.notificationHandlers.set(method, handler);
|
|
154
|
+
}
|
|
155
|
+
onElicitation(handler) {
|
|
156
|
+
this.elicitationHandlers.set("default", handler);
|
|
157
|
+
}
|
|
158
|
+
getNextId() {
|
|
159
|
+
return `${++this.requestId}`;
|
|
160
|
+
}
|
|
161
|
+
async sendRequest(request) {
|
|
162
|
+
const headers = {
|
|
163
|
+
"Content-Type": "application/json",
|
|
164
|
+
"MCP-Protocol-Version": this.protocolVersion
|
|
165
|
+
// Required in 2025-06-18 spec
|
|
166
|
+
};
|
|
167
|
+
if (this.sessionId) {
|
|
168
|
+
headers["mcp-session-id"] = this.sessionId;
|
|
169
|
+
}
|
|
170
|
+
if (this.authToken) {
|
|
171
|
+
headers["Authorization"] = `Bearer ${this.authToken}`;
|
|
172
|
+
}
|
|
173
|
+
if (this.resourceIndicator) {
|
|
174
|
+
headers["Resource-Indicator"] = this.resourceIndicator;
|
|
175
|
+
}
|
|
176
|
+
const controller = new AbortController();
|
|
177
|
+
const timeoutId = setTimeout(() => controller.abort(), 3e4);
|
|
178
|
+
try {
|
|
179
|
+
const response = await fetch(this.baseUrl, {
|
|
180
|
+
method: "POST",
|
|
181
|
+
headers,
|
|
182
|
+
body: JSON.stringify(request),
|
|
183
|
+
signal: controller.signal
|
|
184
|
+
});
|
|
185
|
+
clearTimeout(timeoutId);
|
|
186
|
+
const newSessionId = response.headers.get("mcp-session-id");
|
|
187
|
+
if (newSessionId && !this.sessionId) {
|
|
188
|
+
this.sessionId = newSessionId;
|
|
189
|
+
this.startNotificationPolling();
|
|
190
|
+
}
|
|
191
|
+
if (!response.ok) {
|
|
192
|
+
throw new MCPError(
|
|
193
|
+
`HTTP error! status: ${response.status}`,
|
|
194
|
+
ErrorCodes.MCP_CONNECTION_FAILED,
|
|
195
|
+
{ baseUrl: this.baseUrl, status: response.status, method: request.method }
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
return await response.json();
|
|
199
|
+
} catch (error) {
|
|
200
|
+
clearTimeout(timeoutId);
|
|
201
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
202
|
+
throw new MCPError("Request timeout after 30 seconds", ErrorCodes.MCP_CONNECTION_FAILED, {
|
|
203
|
+
baseUrl: this.baseUrl,
|
|
204
|
+
method: request.method,
|
|
205
|
+
timeout: 3e4
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
if (error instanceof MCPError) {
|
|
209
|
+
throw error;
|
|
210
|
+
}
|
|
211
|
+
throw new MCPError(
|
|
212
|
+
`Request failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
213
|
+
ErrorCodes.MCP_CONNECTION_FAILED,
|
|
214
|
+
{
|
|
215
|
+
baseUrl: this.baseUrl,
|
|
216
|
+
method: request.method,
|
|
217
|
+
originalError: error instanceof Error ? error.message : String(error)
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
async sendNotification(method, params) {
|
|
223
|
+
const notification = {
|
|
224
|
+
jsonrpc: "2.0",
|
|
225
|
+
method,
|
|
226
|
+
params
|
|
227
|
+
};
|
|
228
|
+
const headers = {
|
|
229
|
+
"Content-Type": "application/json",
|
|
230
|
+
"MCP-Protocol-Version": this.protocolVersion
|
|
231
|
+
};
|
|
232
|
+
if (this.sessionId) {
|
|
233
|
+
headers["mcp-session-id"] = this.sessionId;
|
|
234
|
+
}
|
|
235
|
+
if (this.authToken) {
|
|
236
|
+
headers["Authorization"] = `Bearer ${this.authToken}`;
|
|
237
|
+
}
|
|
238
|
+
if (this.resourceIndicator) {
|
|
239
|
+
headers["Resource-Indicator"] = this.resourceIndicator;
|
|
240
|
+
}
|
|
241
|
+
await fetch(this.baseUrl, {
|
|
242
|
+
method: "POST",
|
|
243
|
+
headers,
|
|
244
|
+
body: JSON.stringify(notification)
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
async request(method, params) {
|
|
248
|
+
const request = {
|
|
249
|
+
jsonrpc: "2.0",
|
|
250
|
+
id: this.getNextId(),
|
|
251
|
+
method,
|
|
252
|
+
params
|
|
253
|
+
};
|
|
254
|
+
const response = await this.sendRequest(request);
|
|
255
|
+
if (response.error) {
|
|
256
|
+
throw new MCPError(
|
|
257
|
+
`RPC error ${response.error.code}: ${response.error.message}`,
|
|
258
|
+
ErrorCodes.MCP_TOOL_EXECUTION_FAILED,
|
|
259
|
+
{ method, errorCode: response.error.code, errorData: response.error.data }
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
return response.result;
|
|
263
|
+
}
|
|
264
|
+
async listTools() {
|
|
265
|
+
return await this.request("tools/list");
|
|
266
|
+
}
|
|
267
|
+
async callTool(toolRequest) {
|
|
268
|
+
return await this.request("tools/call", {
|
|
269
|
+
name: toolRequest.name,
|
|
270
|
+
arguments: toolRequest.arguments,
|
|
271
|
+
_meta: toolRequest._meta
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
async listResources() {
|
|
275
|
+
return await this.request("resources/list");
|
|
276
|
+
}
|
|
277
|
+
async readResource(uri, _meta) {
|
|
278
|
+
return await this.request("resources/read", { uri, _meta });
|
|
279
|
+
}
|
|
280
|
+
async listPrompts() {
|
|
281
|
+
return await this.request("prompts/list");
|
|
282
|
+
}
|
|
283
|
+
async getPrompt(name, args, context) {
|
|
284
|
+
return await this.request("prompts/get", {
|
|
285
|
+
name,
|
|
286
|
+
arguments: args,
|
|
287
|
+
context
|
|
288
|
+
// New context field support
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
// New completion support with context
|
|
292
|
+
async complete(request) {
|
|
293
|
+
return await this.request("completion/complete", request);
|
|
294
|
+
}
|
|
295
|
+
// Elicitation continuation support
|
|
296
|
+
async continueElicitation(response) {
|
|
297
|
+
return await this.request("continueElicitation", response);
|
|
298
|
+
}
|
|
299
|
+
async close() {
|
|
300
|
+
this.stopNotificationPolling();
|
|
301
|
+
if (this.sessionId) {
|
|
302
|
+
await fetch(this.baseUrl, {
|
|
303
|
+
method: "DELETE",
|
|
304
|
+
headers: {
|
|
305
|
+
"MCP-Protocol-Version": this.protocolVersion,
|
|
306
|
+
"mcp-session-id": this.sessionId,
|
|
307
|
+
...this.authToken ? { Authorization: `Bearer ${this.authToken}` } : {},
|
|
308
|
+
...this.resourceIndicator ? { "Resource-Indicator": this.resourceIndicator } : {}
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
this.sessionId = null;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
export {
|
|
316
|
+
MCPHTTPClient
|
|
317
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getGlobalStore
|
|
3
|
+
} from "./chunk-VZA2NUH3.js";
|
|
4
|
+
import "./chunk-BYXBJQAS.js";
|
|
5
|
+
import "./chunk-EXI3LJVJ.js";
|
|
6
|
+
import "./chunk-2ESYSVXG.js";
|
|
7
|
+
|
|
8
|
+
// ../../lib/terminals-tech/machines/core/cache.ts
|
|
9
|
+
function stableStringify(value) {
|
|
10
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
11
|
+
const walk = (v) => {
|
|
12
|
+
if (v === null || typeof v !== "object") return v;
|
|
13
|
+
if (seen.has(v)) return v;
|
|
14
|
+
seen.add(v);
|
|
15
|
+
if (Array.isArray(v)) return v.map(walk);
|
|
16
|
+
const out = {};
|
|
17
|
+
for (const k of Object.keys(v).sort())
|
|
18
|
+
out[k] = walk(v[k]);
|
|
19
|
+
return out;
|
|
20
|
+
};
|
|
21
|
+
return JSON.stringify(walk(value));
|
|
22
|
+
}
|
|
23
|
+
var store = getGlobalStore("output_cache");
|
|
24
|
+
var enabled = true;
|
|
25
|
+
function makeKey(shapeHash, nodeId, input) {
|
|
26
|
+
return `${shapeHash || "shape:none"}::${nodeId}::${stableStringify(input)}`;
|
|
27
|
+
}
|
|
28
|
+
function getCachedOutput(key) {
|
|
29
|
+
if (!enabled) return null;
|
|
30
|
+
const rec = store.get(key);
|
|
31
|
+
return rec ? rec.output : null;
|
|
32
|
+
}
|
|
33
|
+
function setCachedOutput(key, output) {
|
|
34
|
+
if (!enabled) return;
|
|
35
|
+
store.set(key, { output, ts: Date.now() });
|
|
36
|
+
}
|
|
37
|
+
function setCacheEnabled(on) {
|
|
38
|
+
enabled = on;
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
getCachedOutput,
|
|
42
|
+
makeKey,
|
|
43
|
+
setCacheEnabled,
|
|
44
|
+
setCachedOutput
|
|
45
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import "./chunk-2ESYSVXG.js";
|
|
2
|
+
|
|
3
|
+
// ../../lib/terminals-tech/machines/core/capabilities.ts
|
|
4
|
+
async function probeCapabilities() {
|
|
5
|
+
const g = globalThis;
|
|
6
|
+
const snap = {
|
|
7
|
+
vector: false,
|
|
8
|
+
pgTrgm: false,
|
|
9
|
+
webgpu: typeof g.navigator !== "undefined" && !!g.navigator?.gpu,
|
|
10
|
+
wasm: await supportsWasm(),
|
|
11
|
+
sab: typeof g.SharedArrayBuffer !== "undefined",
|
|
12
|
+
coi: typeof g.window !== "undefined" ? g.window.crossOriginIsolated === true : false,
|
|
13
|
+
storageBytes: void 0,
|
|
14
|
+
timestamp: Date.now()
|
|
15
|
+
};
|
|
16
|
+
try {
|
|
17
|
+
const nav = navigator;
|
|
18
|
+
if (typeof navigator !== "undefined" && nav.storage?.estimate) {
|
|
19
|
+
const est = await nav.storage.estimate();
|
|
20
|
+
snap.storageBytes = est?.usage || 0;
|
|
21
|
+
}
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
return snap;
|
|
25
|
+
}
|
|
26
|
+
async function checkWebGPUSupportDetailed() {
|
|
27
|
+
const g = globalThis;
|
|
28
|
+
const nav = g.navigator;
|
|
29
|
+
if (typeof nav === "undefined" || !nav?.gpu) {
|
|
30
|
+
return { supported: false, reason: "WebGPU not available on navigator" };
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const adapter = await nav.gpu.requestAdapter();
|
|
34
|
+
if (!adapter) {
|
|
35
|
+
return { supported: false, reason: "No GPU adapter available" };
|
|
36
|
+
}
|
|
37
|
+
return { supported: true };
|
|
38
|
+
} catch (error) {
|
|
39
|
+
return {
|
|
40
|
+
supported: false,
|
|
41
|
+
reason: `Adapter error: ${error instanceof Error ? error.message : String(error)}`
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function hasSharedArrayBuffer() {
|
|
46
|
+
try {
|
|
47
|
+
const g = globalThis;
|
|
48
|
+
return typeof g.SharedArrayBuffer !== "undefined";
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function isCrossOriginIsolated() {
|
|
54
|
+
try {
|
|
55
|
+
const g = globalThis;
|
|
56
|
+
return typeof g.window !== "undefined" && !!g.window?.crossOriginIsolated;
|
|
57
|
+
} catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async function supportsWasm() {
|
|
62
|
+
try {
|
|
63
|
+
const g = globalThis;
|
|
64
|
+
if (typeof g.WebAssembly === "undefined") return false;
|
|
65
|
+
const wasmModule = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0]);
|
|
66
|
+
await WebAssembly.instantiate(wasmModule);
|
|
67
|
+
return true;
|
|
68
|
+
} catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function getDefaultOnnxExecutionProviders() {
|
|
73
|
+
const webgpu = await checkWebGPUSupportDetailed();
|
|
74
|
+
if (webgpu.supported) {
|
|
75
|
+
return ["webgpu", "wasm"];
|
|
76
|
+
}
|
|
77
|
+
if (await supportsWasm()) {
|
|
78
|
+
return ["wasm"];
|
|
79
|
+
}
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
async function getPreferredEmbeddingBackend() {
|
|
83
|
+
const providers = await getDefaultOnnxExecutionProviders();
|
|
84
|
+
if (providers.includes("webgpu")) return "webgpu";
|
|
85
|
+
if (providers.includes("wasm")) return "wasm";
|
|
86
|
+
return "api";
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
checkWebGPUSupportDetailed,
|
|
90
|
+
getDefaultOnnxExecutionProviders,
|
|
91
|
+
getPreferredEmbeddingBackend,
|
|
92
|
+
hasSharedArrayBuffer,
|
|
93
|
+
isCrossOriginIsolated,
|
|
94
|
+
probeCapabilities,
|
|
95
|
+
supportsWasm
|
|
96
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __esm = (fn, res) => function __init() {
|
|
14
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
15
|
+
};
|
|
16
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
17
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
18
|
+
};
|
|
19
|
+
var __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
22
|
+
};
|
|
23
|
+
var __copyProps = (to, from, except, desc) => {
|
|
24
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
25
|
+
for (let key of __getOwnPropNames(from))
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
27
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
28
|
+
}
|
|
29
|
+
return to;
|
|
30
|
+
};
|
|
31
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
32
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
33
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
34
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
35
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
36
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
37
|
+
mod
|
|
38
|
+
));
|
|
39
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
__require,
|
|
43
|
+
__esm,
|
|
44
|
+
__commonJS,
|
|
45
|
+
__export,
|
|
46
|
+
__toESM,
|
|
47
|
+
__toCommonJS
|
|
48
|
+
};
|