tensorlake 0.4.46 → 0.4.48
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/bin/darwin-arm64/tensorlake +0 -0
- package/dist/bin/darwin-arm64/tl +0 -0
- package/dist/bin/linux-x64/tensorlake +0 -0
- package/dist/bin/linux-x64/tl +0 -0
- package/dist/bin/win32-x64/tensorlake.exe +0 -0
- package/dist/bin/win32-x64/tl.exe +0 -0
- package/dist/index.cjs +36 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +40 -24
- package/dist/index.js.map +1 -1
- package/dist/{sandbox-image-B5Fa0xqb.d.cts → sandbox-image-BQ6fJT92.d.cts} +3 -0
- package/dist/{sandbox-image-B5Fa0xqb.d.ts → sandbox-image-BQ6fJT92.d.ts} +3 -0
- package/dist/sandbox-image.cjs +36 -24
- package/dist/sandbox-image.cjs.map +1 -1
- package/dist/sandbox-image.d.cts +1 -1
- package/dist/sandbox-image.d.ts +1 -1
- package/dist/sandbox-image.js +40 -24
- package/dist/sandbox-image.js.map +1 -1
- package/package.json +3 -2
|
Binary file
|
package/dist/bin/darwin-arm64/tl
CHANGED
|
Binary file
|
|
Binary file
|
package/dist/bin/linux-x64/tl
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.cjs
CHANGED
|
@@ -150,6 +150,13 @@ var RequestExecutionError = class extends Error {
|
|
|
150
150
|
};
|
|
151
151
|
|
|
152
152
|
// src/http.ts
|
|
153
|
+
var import_undici = require("undici");
|
|
154
|
+
(0, import_undici.setGlobalDispatcher)(
|
|
155
|
+
new import_undici.Agent({
|
|
156
|
+
keepAliveTimeout: 6e4,
|
|
157
|
+
allowH2: true
|
|
158
|
+
})
|
|
159
|
+
);
|
|
153
160
|
var HttpClient = class {
|
|
154
161
|
baseUrl;
|
|
155
162
|
headers;
|
|
@@ -176,6 +183,9 @@ var HttpClient = class {
|
|
|
176
183
|
if (options.hostHeader) {
|
|
177
184
|
this.headers["Host"] = options.hostHeader;
|
|
178
185
|
}
|
|
186
|
+
if (options.routingHint) {
|
|
187
|
+
this.headers["X-Tensorlake-Route-Hint"] = options.routingHint;
|
|
188
|
+
}
|
|
179
189
|
}
|
|
180
190
|
close() {
|
|
181
191
|
this.abortController?.abort();
|
|
@@ -198,31 +208,26 @@ var HttpClient = class {
|
|
|
198
208
|
if (options?.contentType) {
|
|
199
209
|
headers["Content-Type"] = options.contentType;
|
|
200
210
|
}
|
|
201
|
-
const response = await this.requestResponse(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
headers,
|
|
207
|
-
signal: options?.signal
|
|
208
|
-
}
|
|
209
|
-
);
|
|
211
|
+
const response = await this.requestResponse(method, path2, {
|
|
212
|
+
body: options?.body,
|
|
213
|
+
headers,
|
|
214
|
+
signal: options?.signal
|
|
215
|
+
});
|
|
210
216
|
const buffer = await response.arrayBuffer();
|
|
211
217
|
return new Uint8Array(buffer);
|
|
212
218
|
}
|
|
213
219
|
/** Make a request and return the response body as an SSE stream. */
|
|
214
220
|
async requestStream(method, path2, options) {
|
|
215
|
-
const response = await this.requestResponse(
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
headers: { Accept: "text/event-stream" },
|
|
221
|
-
signal: options?.signal
|
|
222
|
-
}
|
|
223
|
-
);
|
|
221
|
+
const response = await this.requestResponse(method, path2, {
|
|
222
|
+
json: options?.json,
|
|
223
|
+
headers: { Accept: "text/event-stream" },
|
|
224
|
+
signal: options?.signal
|
|
225
|
+
});
|
|
224
226
|
if (!response.body) {
|
|
225
|
-
throw new RemoteAPIError(
|
|
227
|
+
throw new RemoteAPIError(
|
|
228
|
+
response.status,
|
|
229
|
+
"No response body for SSE stream"
|
|
230
|
+
);
|
|
226
231
|
}
|
|
227
232
|
return response.body;
|
|
228
233
|
}
|
|
@@ -261,7 +266,7 @@ var HttpClient = class {
|
|
|
261
266
|
);
|
|
262
267
|
const combinedSignal = signal ? anySignal([signal, this.abortController.signal]) : this.abortController.signal;
|
|
263
268
|
try {
|
|
264
|
-
const response = await fetch(url, {
|
|
269
|
+
const response = await (0, import_undici.fetch)(url, {
|
|
265
270
|
method,
|
|
266
271
|
headers,
|
|
267
272
|
body,
|
|
@@ -3149,7 +3154,8 @@ var Sandbox = class {
|
|
|
3149
3154
|
apiKey: options.apiKey,
|
|
3150
3155
|
organizationId: options.organizationId,
|
|
3151
3156
|
projectId: options.projectId,
|
|
3152
|
-
hostHeader
|
|
3157
|
+
hostHeader,
|
|
3158
|
+
routingHint: options.routingHint
|
|
3153
3159
|
});
|
|
3154
3160
|
}
|
|
3155
3161
|
/** @internal Used by SandboxClient.createAndConnect to set ownership. */
|
|
@@ -3744,14 +3750,15 @@ var SandboxClient = class _SandboxClient {
|
|
|
3744
3750
|
);
|
|
3745
3751
|
}
|
|
3746
3752
|
// --- Connect ---
|
|
3747
|
-
connect(identifier, proxyUrl) {
|
|
3753
|
+
connect(identifier, proxyUrl, routingHint) {
|
|
3748
3754
|
const resolvedProxy = proxyUrl ?? resolveProxyUrl(this.apiUrl);
|
|
3749
3755
|
return new Sandbox({
|
|
3750
3756
|
sandboxId: identifier,
|
|
3751
3757
|
proxyUrl: resolvedProxy,
|
|
3752
3758
|
apiKey: this.apiKey,
|
|
3753
3759
|
organizationId: this.organizationId,
|
|
3754
|
-
projectId: this.projectId
|
|
3760
|
+
projectId: this.projectId,
|
|
3761
|
+
routingHint
|
|
3755
3762
|
});
|
|
3756
3763
|
}
|
|
3757
3764
|
async createAndConnect(options) {
|
|
@@ -3762,11 +3769,16 @@ var SandboxClient = class _SandboxClient {
|
|
|
3762
3769
|
} else {
|
|
3763
3770
|
result = await this.create(options);
|
|
3764
3771
|
}
|
|
3772
|
+
if (result.status === "running" /* RUNNING */) {
|
|
3773
|
+
const sandbox = this.connect(result.sandboxId, options?.proxyUrl, result.routingHint);
|
|
3774
|
+
sandbox._setOwner(this);
|
|
3775
|
+
return sandbox;
|
|
3776
|
+
}
|
|
3765
3777
|
const deadline = Date.now() + startupTimeout * 1e3;
|
|
3766
3778
|
while (Date.now() < deadline) {
|
|
3767
3779
|
const info = await this.get(result.sandboxId);
|
|
3768
3780
|
if (info.status === "running" /* RUNNING */) {
|
|
3769
|
-
const sandbox = this.connect(result.sandboxId, options?.proxyUrl);
|
|
3781
|
+
const sandbox = this.connect(result.sandboxId, options?.proxyUrl, info.routingHint);
|
|
3770
3782
|
sandbox._setOwner(this);
|
|
3771
3783
|
return sandbox;
|
|
3772
3784
|
}
|