viem 2.57.15 → 2.57.16
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/CHANGELOG.md +14 -0
- package/_cjs/errors/version.js +1 -1
- package/_cjs/tempo/Gateway.js +195 -0
- package/_cjs/tempo/Gateway.js.map +1 -0
- package/_cjs/tempo/GatewayDecorator.js +168 -0
- package/_cjs/tempo/GatewayDecorator.js.map +1 -0
- package/_cjs/tempo/actions/ai.js +69 -0
- package/_cjs/tempo/actions/ai.js.map +1 -0
- package/_cjs/tempo/actions/bucket.js +85 -0
- package/_cjs/tempo/actions/bucket.js.map +1 -0
- package/_cjs/tempo/actions/compute.js +165 -0
- package/_cjs/tempo/actions/compute.js.map +1 -0
- package/_cjs/tempo/actions/gateway.js +8 -0
- package/_cjs/tempo/actions/gateway.js.map +1 -0
- package/_cjs/tempo/actions/index.js +6 -1
- package/_cjs/tempo/actions/index.js.map +1 -1
- package/_cjs/tempo/actions/kv.js +44 -0
- package/_cjs/tempo/actions/kv.js.map +1 -0
- package/_cjs/tempo/index.js +4 -1
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/tempo/internal/ndjson.js +43 -0
- package/_cjs/tempo/internal/ndjson.js.map +1 -0
- package/_cjs/utils/buildRequest.js +4 -0
- package/_cjs/utils/buildRequest.js.map +1 -1
- package/_cjs/utils/hash/toSignatureHash.js +10 -1
- package/_cjs/utils/hash/toSignatureHash.js.map +1 -1
- package/_cjs/utils/rpc/http.js +6 -3
- package/_cjs/utils/rpc/http.js.map +1 -1
- package/_cjs/utils/rpc/socket.js +20 -9
- package/_cjs/utils/rpc/socket.js.map +1 -1
- package/_cjs/zksync/actions/finalizeWithdrawal.js +4 -2
- package/_cjs/zksync/actions/finalizeWithdrawal.js.map +1 -1
- package/_cjs/zksync/actions/isWithdrawalFinalized.js +4 -5
- package/_cjs/zksync/actions/isWithdrawalFinalized.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/tempo/Gateway.js +294 -0
- package/_esm/tempo/Gateway.js.map +1 -0
- package/_esm/tempo/GatewayDecorator.js +207 -0
- package/_esm/tempo/GatewayDecorator.js.map +1 -0
- package/_esm/tempo/actions/ai.js +132 -0
- package/_esm/tempo/actions/ai.js.map +1 -0
- package/_esm/tempo/actions/bucket.js +181 -0
- package/_esm/tempo/actions/bucket.js.map +1 -0
- package/_esm/tempo/actions/compute.js +424 -0
- package/_esm/tempo/actions/compute.js.map +1 -0
- package/_esm/tempo/actions/gateway.js +22 -0
- package/_esm/tempo/actions/gateway.js.map +1 -0
- package/_esm/tempo/actions/index.js +10 -0
- package/_esm/tempo/actions/index.js.map +1 -1
- package/_esm/tempo/actions/kv.js +124 -0
- package/_esm/tempo/actions/kv.js.map +1 -0
- package/_esm/tempo/index.js +9 -0
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/tempo/internal/ndjson.js +45 -0
- package/_esm/tempo/internal/ndjson.js.map +1 -0
- package/_esm/utils/buildRequest.js +6 -0
- package/_esm/utils/buildRequest.js.map +1 -1
- package/_esm/utils/hash/toSignatureHash.js +11 -1
- package/_esm/utils/hash/toSignatureHash.js.map +1 -1
- package/_esm/utils/rpc/http.js +11 -3
- package/_esm/utils/rpc/http.js.map +1 -1
- package/_esm/utils/rpc/socket.js +24 -9
- package/_esm/utils/rpc/socket.js.map +1 -1
- package/_esm/zksync/actions/finalizeWithdrawal.js +5 -2
- package/_esm/zksync/actions/finalizeWithdrawal.js.map +1 -1
- package/_esm/zksync/actions/isWithdrawalFinalized.js +5 -5
- package/_esm/zksync/actions/isWithdrawalFinalized.js.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/tempo/Gateway.d.ts +337 -0
- package/_types/tempo/Gateway.d.ts.map +1 -0
- package/_types/tempo/GatewayDecorator.d.ts +635 -0
- package/_types/tempo/GatewayDecorator.d.ts.map +1 -0
- package/_types/tempo/actions/ai.d.ts +145 -0
- package/_types/tempo/actions/ai.d.ts.map +1 -0
- package/_types/tempo/actions/bucket.d.ts +210 -0
- package/_types/tempo/actions/bucket.d.ts.map +1 -0
- package/_types/tempo/actions/compute.d.ts +628 -0
- package/_types/tempo/actions/compute.d.ts.map +1 -0
- package/_types/tempo/actions/gateway.d.ts +25 -0
- package/_types/tempo/actions/gateway.d.ts.map +1 -0
- package/_types/tempo/actions/index.d.ts +10 -0
- package/_types/tempo/actions/index.d.ts.map +1 -1
- package/_types/tempo/actions/kv.d.ts +167 -0
- package/_types/tempo/actions/kv.d.ts.map +1 -0
- package/_types/tempo/index.d.ts +11 -0
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/tempo/internal/ndjson.d.ts +9 -0
- package/_types/tempo/internal/ndjson.d.ts.map +1 -0
- package/_types/utils/buildRequest.d.ts.map +1 -1
- package/_types/utils/hash/toSignatureHash.d.ts +1 -1
- package/_types/utils/hash/toSignatureHash.d.ts.map +1 -1
- package/_types/utils/rpc/http.d.ts.map +1 -1
- package/_types/utils/rpc/socket.d.ts.map +1 -1
- package/errors/version.ts +1 -1
- package/package.json +5 -1
- package/tempo/Gateway.ts +477 -0
- package/tempo/GatewayDecorator.ts +909 -0
- package/tempo/actions/ai.ts +250 -0
- package/tempo/actions/bucket.ts +324 -0
- package/tempo/actions/compute.ts +894 -0
- package/tempo/actions/gateway.ts +33 -0
- package/tempo/actions/index.ts +10 -0
- package/tempo/actions/kv.ts +229 -0
- package/tempo/index.ts +12 -0
- package/tempo/internal/ndjson.ts +51 -0
- package/utils/buildRequest.ts +4 -0
- package/utils/hash/toSignatureHash.ts +12 -2
- package/utils/rpc/http.ts +11 -3
- package/utils/rpc/socket.ts +28 -15
- package/zksync/actions/finalizeWithdrawal.ts +5 -2
- package/zksync/actions/isWithdrawalFinalized.ts +5 -5
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import * as Gateway from '../Gateway.js';
|
|
2
|
+
/**
|
|
3
|
+
* Deletes an object from the app's bucket. Paid per request.
|
|
4
|
+
*
|
|
5
|
+
* @experimental
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
10
|
+
*
|
|
11
|
+
* const gateway = Gateway.from({ fetch: mppx.fetch })
|
|
12
|
+
*
|
|
13
|
+
* await Actions.bucket.delete(gateway, { key: 'notes/today.txt' })
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param gateway - Gateway connection.
|
|
17
|
+
* @param parameters - Parameters.
|
|
18
|
+
* @returns Whether the request succeeded.
|
|
19
|
+
*/
|
|
20
|
+
// biome-ignore lint/correctness/noUnusedVariables: exported as delete
|
|
21
|
+
async function delete_(gateway, parameters) {
|
|
22
|
+
const { key, signal } = parameters;
|
|
23
|
+
const response = await Gateway.request(gateway, {
|
|
24
|
+
body: JSON.stringify({ key }),
|
|
25
|
+
path: '/bucket/delete',
|
|
26
|
+
signal,
|
|
27
|
+
});
|
|
28
|
+
return (await response.json());
|
|
29
|
+
}
|
|
30
|
+
export { delete_ as delete };
|
|
31
|
+
/**
|
|
32
|
+
* Reads an object from the app's bucket as a stream. Returns `null` when the
|
|
33
|
+
* object does not exist or expired. Paid per request.
|
|
34
|
+
*
|
|
35
|
+
* @experimental
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
40
|
+
*
|
|
41
|
+
* const gateway = Gateway.from({ fetch: mppx.fetch })
|
|
42
|
+
*
|
|
43
|
+
* const object = await Actions.bucket.get(gateway, { key: 'notes/today.txt' })
|
|
44
|
+
* const text = object ? await new Response(object.body).text() : null
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @param gateway - Gateway connection.
|
|
48
|
+
* @param parameters - Parameters.
|
|
49
|
+
* @returns The object body and metadata, or `null`.
|
|
50
|
+
*/
|
|
51
|
+
export async function get(gateway, parameters) {
|
|
52
|
+
const { key, signal } = parameters;
|
|
53
|
+
const response = await Gateway.request(gateway, {
|
|
54
|
+
body: JSON.stringify({ key }),
|
|
55
|
+
path: '/bucket/get',
|
|
56
|
+
signal,
|
|
57
|
+
}).catch((error) => {
|
|
58
|
+
if (error instanceof Gateway.RequestError && error.code === 'not_found')
|
|
59
|
+
return null;
|
|
60
|
+
throw error;
|
|
61
|
+
});
|
|
62
|
+
if (!response?.body)
|
|
63
|
+
return null;
|
|
64
|
+
const { headers } = response;
|
|
65
|
+
return {
|
|
66
|
+
body: response.body,
|
|
67
|
+
contentType: headers.get('content-type'),
|
|
68
|
+
etag: headers.get('etag'),
|
|
69
|
+
expiresAt: Number(headers.get('gateway-expires-at')),
|
|
70
|
+
key,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Reads the metadata of an object in the app's bucket. Returns `null` when the
|
|
75
|
+
* object does not exist or expired. Paid per request.
|
|
76
|
+
*
|
|
77
|
+
* @experimental
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
82
|
+
*
|
|
83
|
+
* const gateway = Gateway.from({ fetch: mppx.fetch })
|
|
84
|
+
*
|
|
85
|
+
* const metadata = await Actions.bucket.head(gateway, { key: 'notes/today.txt' })
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @param gateway - Gateway connection.
|
|
89
|
+
* @param parameters - Parameters.
|
|
90
|
+
* @returns The object metadata, or `null`.
|
|
91
|
+
*/
|
|
92
|
+
export async function head(gateway, parameters) {
|
|
93
|
+
const { key, signal } = parameters;
|
|
94
|
+
const response = await Gateway.request(gateway, {
|
|
95
|
+
body: JSON.stringify({ key }),
|
|
96
|
+
path: '/bucket/head',
|
|
97
|
+
signal,
|
|
98
|
+
});
|
|
99
|
+
return (await response.json());
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Lists objects in the app's bucket by key prefix. Paid per request.
|
|
103
|
+
*
|
|
104
|
+
* @experimental
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
109
|
+
*
|
|
110
|
+
* const gateway = Gateway.from({ fetch: mppx.fetch })
|
|
111
|
+
*
|
|
112
|
+
* const { cursor, objects } = await Actions.bucket.list(gateway, {
|
|
113
|
+
* prefix: 'notes/',
|
|
114
|
+
* })
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* @param gateway - Gateway connection.
|
|
118
|
+
* @param parameters - Parameters.
|
|
119
|
+
* @returns A page of object metadata and the next cursor.
|
|
120
|
+
*/
|
|
121
|
+
export async function list(gateway, parameters = {}) {
|
|
122
|
+
const { cursor, limit, prefix, signal } = parameters;
|
|
123
|
+
const response = await Gateway.request(gateway, {
|
|
124
|
+
body: JSON.stringify({ cursor, limit, prefix }),
|
|
125
|
+
path: '/bucket/list',
|
|
126
|
+
signal,
|
|
127
|
+
});
|
|
128
|
+
return (await response.json());
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Writes an object to the app's bucket for a retention period. Paid per
|
|
132
|
+
* request.
|
|
133
|
+
*
|
|
134
|
+
* @experimental
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
139
|
+
*
|
|
140
|
+
* const gateway = Gateway.from({ fetch: mppx.fetch })
|
|
141
|
+
*
|
|
142
|
+
* const metadata = await Actions.bucket.put(gateway, {
|
|
143
|
+
* key: 'notes/today.txt',
|
|
144
|
+
* retention: 86_400,
|
|
145
|
+
* value: new Blob(['hello'], { type: 'text/plain' }),
|
|
146
|
+
* })
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @param gateway - Gateway connection.
|
|
150
|
+
* @param parameters - Parameters.
|
|
151
|
+
* @returns The object metadata.
|
|
152
|
+
*/
|
|
153
|
+
export async function put(gateway, parameters) {
|
|
154
|
+
const { key, retention, signal, value } = parameters;
|
|
155
|
+
const body = typeof value === 'string' ? new TextEncoder().encode(value) : value;
|
|
156
|
+
const size = isBlob(body) ? body.size : body.byteLength;
|
|
157
|
+
const contentType = parameters.contentType ??
|
|
158
|
+
(typeof value === 'string' ? 'text/plain;charset=utf-8' : undefined) ??
|
|
159
|
+
(isBlob(value) && value.type ? value.type : undefined) ??
|
|
160
|
+
'application/octet-stream';
|
|
161
|
+
const response = await Gateway.request(gateway, {
|
|
162
|
+
body: body,
|
|
163
|
+
headers: {
|
|
164
|
+
'content-type': contentType,
|
|
165
|
+
'gateway-key': key,
|
|
166
|
+
'gateway-retention': String(retention),
|
|
167
|
+
'gateway-size': String(size),
|
|
168
|
+
},
|
|
169
|
+
path: '/bucket/put',
|
|
170
|
+
signal,
|
|
171
|
+
});
|
|
172
|
+
return (await response.json());
|
|
173
|
+
}
|
|
174
|
+
/** Detects a `Blob` without `instanceof`, so ones from another realm count. */
|
|
175
|
+
function isBlob(value) {
|
|
176
|
+
return (typeof value === 'object' &&
|
|
177
|
+
value !== null &&
|
|
178
|
+
typeof value.arrayBuffer === 'function' &&
|
|
179
|
+
typeof value.size === 'number');
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=bucket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bucket.js","sourceRoot":"","sources":["../../../tempo/actions/bucket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AAsBxC;;;;;;;;;;;;;;;;;GAiBG;AACH,sEAAsE;AACtE,KAAK,UAAU,OAAO,CACpB,OAAwB,EACxB,UAA8B;IAE9B,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,UAAU,CAAA;IAClC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE;QAC9C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;QAC7B,IAAI,EAAE,gBAAg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AC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,SAAS,CAAC;QACpE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QACtD,0BAA0B,CAAA;IAC5B,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE;QAC9C,IAAI,EAAE,IAAgB;QACtB,OAAO,EAAE;YACP,cAAc,EAAE,WAAW;YAC3B,aAAa,EAAE,GAAG;YAClB,mBAAmB,EAAE,MAAM,CAAC,SAAS,CAAC;YACtC,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC;SAC7B;QACD,IAAI,EAAE,aAAa;QACnB,MAAM;KACP,CAAC,CAAA;IACF,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAoB,CAAA;AACnD,CAAC;AAyBD,+EAA+E;AAC/E,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAQ,KAAc,CAAC,WAAW,KAAK,UAAU;QACjD,OAAQ,KAAc,CAAC,IAAI,KAAK,QAAQ,CACzC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import * as Gateway from '../Gateway.js';
|
|
2
|
+
import * as Ndjson from '../internal/ndjson.js';
|
|
3
|
+
/**
|
|
4
|
+
* Starts a sandbox that can live up to `timeout` seconds, from a container image
|
|
5
|
+
* with optional `apt/pip` layers or from a snapshot. Compute is metered: creation
|
|
6
|
+
* pays for `lease` seconds at the sandbox's GPU, CPU, and memory rate (see
|
|
7
|
+
* `Gateway.getCapabilities`), and `renew` pays for more. `ports` are served
|
|
8
|
+
* over public HTTPS tunnels returned in `tunnels`.
|
|
9
|
+
*
|
|
10
|
+
* @experimental
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
15
|
+
*
|
|
16
|
+
* const gateway = Gateway.from({ fetch: mppx.fetch })
|
|
17
|
+
*
|
|
18
|
+
* const sandbox = await Actions.compute.create(gateway, {
|
|
19
|
+
* gpu: 'T4',
|
|
20
|
+
* image: 'pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime',
|
|
21
|
+
* ports: [8000],
|
|
22
|
+
* timeout: 1200,
|
|
23
|
+
* })
|
|
24
|
+
* const url = sandbox.tunnels[8000]
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @param gateway - Gateway connection.
|
|
28
|
+
* @param parameters - Parameters.
|
|
29
|
+
* @returns The sandbox and its tunnels.
|
|
30
|
+
*/
|
|
31
|
+
export async function create(gateway, parameters = {}) {
|
|
32
|
+
const { apt, blockNetwork, cpu, env, gpu, gpuCount, idleTimeout, image, lease, memory, pip, ports, signal, snapshot, timeout, workdir, } = parameters;
|
|
33
|
+
const response = await Gateway.request(gateway, {
|
|
34
|
+
body: JSON.stringify({
|
|
35
|
+
apt,
|
|
36
|
+
blockNetwork,
|
|
37
|
+
cpu,
|
|
38
|
+
env,
|
|
39
|
+
gpu,
|
|
40
|
+
gpuCount,
|
|
41
|
+
idleTimeout,
|
|
42
|
+
image,
|
|
43
|
+
lease,
|
|
44
|
+
memory,
|
|
45
|
+
pip,
|
|
46
|
+
ports,
|
|
47
|
+
snapshot,
|
|
48
|
+
timeout,
|
|
49
|
+
workdir,
|
|
50
|
+
}),
|
|
51
|
+
path: '/compute/create',
|
|
52
|
+
signal,
|
|
53
|
+
});
|
|
54
|
+
return (await response.json());
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Runs a command in a sandbox and waits up to `timeout` seconds (at most 120)
|
|
58
|
+
* for it to finish. Use `spawn` for longer jobs. Paid per request.
|
|
59
|
+
*
|
|
60
|
+
* @experimental
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
65
|
+
*
|
|
66
|
+
* const gateway = Gateway.from({ fetch: mppx.fetch })
|
|
67
|
+
*
|
|
68
|
+
* const { exitCode, stdout } = await Actions.compute.exec(gateway, {
|
|
69
|
+
* command: ['python', '-c', 'print(1 + 1)'],
|
|
70
|
+
* sandboxId: sandbox.sandboxId,
|
|
71
|
+
* })
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @param gateway - Gateway connection.
|
|
75
|
+
* @param parameters - Parameters.
|
|
76
|
+
* @returns The command's output and exit code.
|
|
77
|
+
*/
|
|
78
|
+
export async function exec(gateway, parameters) {
|
|
79
|
+
const { command, env, sandboxId, signal, timeout, workdir } = parameters;
|
|
80
|
+
const response = await Gateway.request(gateway, {
|
|
81
|
+
body: JSON.stringify({ command, env, sandboxId, timeout, workdir }),
|
|
82
|
+
path: '/compute/exec',
|
|
83
|
+
signal,
|
|
84
|
+
});
|
|
85
|
+
return (await response.json());
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Lists the app's sandboxes that have not ended. Paid per request.
|
|
89
|
+
*
|
|
90
|
+
* @experimental
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
95
|
+
*
|
|
96
|
+
* const gateway = Gateway.from({ fetch: mppx.fetch })
|
|
97
|
+
*
|
|
98
|
+
* const { sandboxes } = await Actions.compute.list(gateway)
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @param gateway - Gateway connection.
|
|
102
|
+
* @param parameters - Parameters.
|
|
103
|
+
* @returns A page of sandboxes and the next cursor.
|
|
104
|
+
*/
|
|
105
|
+
export async function list(gateway, parameters = {}) {
|
|
106
|
+
const { cursor, limit, signal } = parameters;
|
|
107
|
+
const response = await Gateway.request(gateway, {
|
|
108
|
+
body: JSON.stringify({ cursor, limit }),
|
|
109
|
+
path: '/compute/list',
|
|
110
|
+
signal,
|
|
111
|
+
});
|
|
112
|
+
return (await response.json());
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Reads a file from a sandbox, from `offset` for up to `length` bytes (8 MiB
|
|
116
|
+
* per request). Returns `null` when the file does not exist. Paid per request.
|
|
117
|
+
*
|
|
118
|
+
* @experimental
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
123
|
+
*
|
|
124
|
+
* const gateway = Gateway.from({ fetch: mppx.fetch })
|
|
125
|
+
*
|
|
126
|
+
* const log = await Actions.compute.read(gateway, {
|
|
127
|
+
* offset: 0,
|
|
128
|
+
* path: job.logPath,
|
|
129
|
+
* sandboxId: sandbox.sandboxId,
|
|
130
|
+
* })
|
|
131
|
+
* const text = log && (await new Response(log.body).text())
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @param gateway - Gateway connection.
|
|
135
|
+
* @param parameters - Parameters.
|
|
136
|
+
* @returns The bytes read and the whole file size, or `null`.
|
|
137
|
+
*/
|
|
138
|
+
export async function read(gateway, parameters) {
|
|
139
|
+
const { length, offset, path, sandboxId, signal } = parameters;
|
|
140
|
+
const response = await Gateway.request(gateway, {
|
|
141
|
+
body: JSON.stringify({ length, offset, path, sandboxId }),
|
|
142
|
+
path: '/compute/read',
|
|
143
|
+
signal,
|
|
144
|
+
}).catch((error) => {
|
|
145
|
+
if (error instanceof Gateway.RequestError && error.code === 'not_found')
|
|
146
|
+
return null;
|
|
147
|
+
throw error;
|
|
148
|
+
});
|
|
149
|
+
if (!response?.body)
|
|
150
|
+
return null;
|
|
151
|
+
return {
|
|
152
|
+
body: response.body,
|
|
153
|
+
offset: offset ?? 0,
|
|
154
|
+
size: Number(response.headers.get('gateway-file-size')),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Saves a sandbox's filesystem as a snapshot kept for 30 days. Pass it to
|
|
159
|
+
* `create` to start new sandboxes from it. Paid per request.
|
|
160
|
+
*
|
|
161
|
+
* @experimental
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
166
|
+
*
|
|
167
|
+
* const gateway = Gateway.from({ fetch: mppx.fetch })
|
|
168
|
+
*
|
|
169
|
+
* const { snapshot } = await Actions.compute.snapshot(gateway, {
|
|
170
|
+
* sandboxId: sandbox.sandboxId,
|
|
171
|
+
* })
|
|
172
|
+
* const copy = await Actions.compute.create(gateway, { snapshot })
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* @param gateway - Gateway connection.
|
|
176
|
+
* @param parameters - Parameters.
|
|
177
|
+
* @returns The snapshot ID and its expiry.
|
|
178
|
+
*/
|
|
179
|
+
export async function snapshot(gateway, parameters) {
|
|
180
|
+
const { sandboxId, signal } = parameters;
|
|
181
|
+
const response = await Gateway.request(gateway, {
|
|
182
|
+
body: JSON.stringify({ sandboxId }),
|
|
183
|
+
path: '/compute/snapshot',
|
|
184
|
+
signal,
|
|
185
|
+
});
|
|
186
|
+
return (await response.json());
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Starts a command in the background and returns at once. Its output goes to
|
|
190
|
+
* `logPath` and its exit code to `exitPath` when it finishes; poll both with
|
|
191
|
+
* `read`. Paid per request.
|
|
192
|
+
*
|
|
193
|
+
* @experimental
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
198
|
+
*
|
|
199
|
+
* const gateway = Gateway.from({ fetch: mppx.fetch })
|
|
200
|
+
*
|
|
201
|
+
* const job = await Actions.compute.spawn(gateway, {
|
|
202
|
+
* command: ['python', 'train.py'],
|
|
203
|
+
* sandboxId: sandbox.sandboxId,
|
|
204
|
+
* })
|
|
205
|
+
* ```
|
|
206
|
+
*
|
|
207
|
+
* @param gateway - Gateway connection.
|
|
208
|
+
* @param parameters - Parameters.
|
|
209
|
+
* @returns The process ID and the paths of its log and exit code.
|
|
210
|
+
*/
|
|
211
|
+
export async function spawn(gateway, parameters) {
|
|
212
|
+
const { command, env, sandboxId, signal, workdir } = parameters;
|
|
213
|
+
const response = await Gateway.request(gateway, {
|
|
214
|
+
body: JSON.stringify({ command, env, sandboxId, workdir }),
|
|
215
|
+
path: '/compute/spawn',
|
|
216
|
+
signal,
|
|
217
|
+
});
|
|
218
|
+
return (await response.json());
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Reads whether a sandbox is running. Paid per request.
|
|
222
|
+
*
|
|
223
|
+
* @experimental
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```ts
|
|
227
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
228
|
+
*
|
|
229
|
+
* const gateway = Gateway.from({ fetch: mppx.fetch })
|
|
230
|
+
*
|
|
231
|
+
* const { status } = await Actions.compute.status(gateway, {
|
|
232
|
+
* sandboxId: sandbox.sandboxId,
|
|
233
|
+
* })
|
|
234
|
+
* ```
|
|
235
|
+
*
|
|
236
|
+
* @param gateway - Gateway connection.
|
|
237
|
+
* @param parameters - Parameters.
|
|
238
|
+
* @returns The sandbox and its status.
|
|
239
|
+
*/
|
|
240
|
+
export async function status(gateway, parameters) {
|
|
241
|
+
const { sandboxId, signal } = parameters;
|
|
242
|
+
const response = await Gateway.request(gateway, {
|
|
243
|
+
body: JSON.stringify({ sandboxId }),
|
|
244
|
+
path: '/compute/status',
|
|
245
|
+
signal,
|
|
246
|
+
});
|
|
247
|
+
return (await response.json());
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Terminates a sandbox. The Gateway credits the unused rest of its lease back
|
|
251
|
+
* to the payment channel. Paid per request.
|
|
252
|
+
*
|
|
253
|
+
* @experimental
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```ts
|
|
257
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
258
|
+
*
|
|
259
|
+
* const gateway = Gateway.from({ fetch: mppx.fetch })
|
|
260
|
+
*
|
|
261
|
+
* await Actions.compute.terminate(gateway, { sandboxId: sandbox.sandboxId })
|
|
262
|
+
* ```
|
|
263
|
+
*
|
|
264
|
+
* @param gateway - Gateway connection.
|
|
265
|
+
* @param parameters - Parameters.
|
|
266
|
+
* @returns The final status.
|
|
267
|
+
*/
|
|
268
|
+
export async function terminate(gateway, parameters) {
|
|
269
|
+
const { sandboxId, signal } = parameters;
|
|
270
|
+
const response = await Gateway.request(gateway, {
|
|
271
|
+
body: JSON.stringify({ sandboxId }),
|
|
272
|
+
path: '/compute/terminate',
|
|
273
|
+
signal,
|
|
274
|
+
});
|
|
275
|
+
return (await response.json());
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Writes a file into a sandbox at an absolute path, creating its directories.
|
|
279
|
+
* Up to 8 MiB. Paid per request.
|
|
280
|
+
*
|
|
281
|
+
* @experimental
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```ts
|
|
285
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
286
|
+
*
|
|
287
|
+
* const gateway = Gateway.from({ fetch: mppx.fetch })
|
|
288
|
+
*
|
|
289
|
+
* await Actions.compute.write(gateway, {
|
|
290
|
+
* path: '/root/train.py',
|
|
291
|
+
* sandboxId: sandbox.sandboxId,
|
|
292
|
+
* value: 'print("training")',
|
|
293
|
+
* })
|
|
294
|
+
* ```
|
|
295
|
+
*
|
|
296
|
+
* @param gateway - Gateway connection.
|
|
297
|
+
* @param parameters - Parameters.
|
|
298
|
+
* @returns The path and size written.
|
|
299
|
+
*/
|
|
300
|
+
export async function write(gateway, parameters) {
|
|
301
|
+
const { path, sandboxId, signal, value } = parameters;
|
|
302
|
+
const body = typeof value === 'string' ? new TextEncoder().encode(value) : value;
|
|
303
|
+
const size = isBlob(body) ? body.size : body.byteLength;
|
|
304
|
+
const response = await Gateway.request(gateway, {
|
|
305
|
+
body: body,
|
|
306
|
+
headers: {
|
|
307
|
+
'content-type': 'application/octet-stream',
|
|
308
|
+
'gateway-path': path,
|
|
309
|
+
'gateway-sandbox': sandboxId,
|
|
310
|
+
'gateway-size': String(size),
|
|
311
|
+
},
|
|
312
|
+
path: '/compute/write',
|
|
313
|
+
signal,
|
|
314
|
+
});
|
|
315
|
+
return (await response.json());
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Pays for more seconds of a sandbox at its per-second rate, up to its
|
|
319
|
+
* `timeout`. A sandbox whose `paidUntil` passes is terminated within about a
|
|
320
|
+
* minute. Paid per request.
|
|
321
|
+
*
|
|
322
|
+
* @experimental
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```ts
|
|
326
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
327
|
+
*
|
|
328
|
+
* const gateway = Gateway.from({ fetch: mppx.fetch })
|
|
329
|
+
*
|
|
330
|
+
* const { paidUntil } = await Actions.compute.renew(gateway, {
|
|
331
|
+
* sandboxId: sandbox.sandboxId,
|
|
332
|
+
* seconds: 300,
|
|
333
|
+
* })
|
|
334
|
+
* ```
|
|
335
|
+
*
|
|
336
|
+
* @param gateway - Gateway connection.
|
|
337
|
+
* @param parameters - Parameters.
|
|
338
|
+
* @returns The sandbox with its new `paidUntil`.
|
|
339
|
+
*/
|
|
340
|
+
export async function renew(gateway, parameters) {
|
|
341
|
+
const { sandboxId, seconds, signal } = parameters;
|
|
342
|
+
const response = await Gateway.request(gateway, {
|
|
343
|
+
body: JSON.stringify({ sandboxId, seconds }),
|
|
344
|
+
path: '/compute/renew',
|
|
345
|
+
signal,
|
|
346
|
+
});
|
|
347
|
+
return (await response.json());
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Runs a command in a sandbox and yields its output as it is written, then
|
|
351
|
+
* its exit. Up to `timeout` seconds (at most 3600). Paid per request.
|
|
352
|
+
*
|
|
353
|
+
* @experimental
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* ```ts
|
|
357
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
358
|
+
*
|
|
359
|
+
* const gateway = Gateway.from({ fetch: mppx.fetch })
|
|
360
|
+
*
|
|
361
|
+
* for await (const event of Actions.compute.stream(gateway, {
|
|
362
|
+
* command: ['python', 'train.py'],
|
|
363
|
+
* sandboxId: sandbox.sandboxId,
|
|
364
|
+
* })) {
|
|
365
|
+
* if (event.type === 'exit') console.log('exit', event.exitCode)
|
|
366
|
+
* else process.stdout.write(event.data)
|
|
367
|
+
* }
|
|
368
|
+
* ```
|
|
369
|
+
*
|
|
370
|
+
* @param gateway - Gateway connection.
|
|
371
|
+
* @param parameters - Parameters.
|
|
372
|
+
* @returns Output and exit events.
|
|
373
|
+
*/
|
|
374
|
+
export async function* stream(gateway, parameters) {
|
|
375
|
+
const { command, env, sandboxId, signal, timeout, workdir } = parameters;
|
|
376
|
+
const response = await Gateway.request(gateway, {
|
|
377
|
+
body: JSON.stringify({ command, env, sandboxId, timeout, workdir }),
|
|
378
|
+
path: '/compute/stream',
|
|
379
|
+
signal,
|
|
380
|
+
});
|
|
381
|
+
yield* Ndjson.read(response);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Follows the log of a command started with `spawn` from `offset` and yields
|
|
385
|
+
* it as it grows, then the exit code. After an hour it yields `end` with the
|
|
386
|
+
* offset to resume from. Paid per request.
|
|
387
|
+
*
|
|
388
|
+
* @experimental
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* ```ts
|
|
392
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
393
|
+
*
|
|
394
|
+
* const gateway = Gateway.from({ fetch: mppx.fetch })
|
|
395
|
+
*
|
|
396
|
+
* for await (const event of Actions.compute.logs(gateway, {
|
|
397
|
+
* logPath: job.logPath,
|
|
398
|
+
* sandboxId: sandbox.sandboxId,
|
|
399
|
+
* })) {
|
|
400
|
+
* if (event.type === 'log') process.stdout.write(event.data)
|
|
401
|
+
* }
|
|
402
|
+
* ```
|
|
403
|
+
*
|
|
404
|
+
* @param gateway - Gateway connection.
|
|
405
|
+
* @param parameters - Parameters.
|
|
406
|
+
* @returns Log, exit, and end events.
|
|
407
|
+
*/
|
|
408
|
+
export async function* logs(gateway, parameters) {
|
|
409
|
+
const { logPath, offset, sandboxId, signal } = parameters;
|
|
410
|
+
const response = await Gateway.request(gateway, {
|
|
411
|
+
body: JSON.stringify({ logPath, offset, sandboxId }),
|
|
412
|
+
path: '/compute/logs',
|
|
413
|
+
signal,
|
|
414
|
+
});
|
|
415
|
+
yield* Ndjson.read(response);
|
|
416
|
+
}
|
|
417
|
+
/** Detects a `Blob` without `instanceof`, so ones from another realm count. */
|
|
418
|
+
function isBlob(value) {
|
|
419
|
+
return (typeof value === 'object' &&
|
|
420
|
+
value !== null &&
|
|
421
|
+
typeof value.arrayBuffer === 'function' &&
|
|
422
|
+
typeof value.size === 'number');
|
|
423
|
+
}
|
|
424
|
+
//# sourceMappingURL=compute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compute.js","sourceRoot":"","sources":["../../../tempo/actions/compute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAA;AAsC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAG1B,OAAwB,EACxB,aAAuC,EAA8B;IAErE,MAAM,EACJ,GAAG,EACH,YAAY,EACZ,GAAG,EACH,GAAG,EACH,GAAG,EACH,QAAQ,EACR,WAAW,EACX,KAAK,EACL,KAAK,EACL,MAAM,EACN,GAAG,EACH,KAAK,EACL,MAAM,EACN,QAAQ,EACR,OAAO,EACP,OAAO,GACR,GAAG,UAAU,CAAA;IAC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AO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QACpD,IAAI,EAAE,eAAe;QACrB,MAAM;KACP,CAAC,CAAA;IACF,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAa,QAAQ,CAAC,CAAA;AAC1C,CAAC;AA0CD,+EAA+E;AAC/E,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAQ,KAAc,CAAC,WAAW,KAAK,UAAU;QACjD,OAAQ,KAAc,CAAC,IAAI,KAAK,QAAQ,CACzC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as Gateway from '../Gateway.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reads the Gateway's free discovery document: chain, currencies, prices,
|
|
4
|
+
* limits, and models.
|
|
5
|
+
*
|
|
6
|
+
* @experimental
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Actions, Gateway } from 'viem/tempo'
|
|
11
|
+
*
|
|
12
|
+
* const capabilities = await Actions.gateway.getCapabilities(Gateway.from())
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param gateway - Gateway connection.
|
|
16
|
+
* @param parameters - Parameters.
|
|
17
|
+
* @returns The Gateway capabilities.
|
|
18
|
+
*/
|
|
19
|
+
export async function getCapabilities(gateway, parameters = {}) {
|
|
20
|
+
return Gateway.getCapabilities(gateway, parameters);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../../tempo/actions/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AAExC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAAwB,EACxB,aAAyC,EAAE;IAE3C,OAAO,OAAO,CAAC,eAAe,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;AACrD,CAAC"}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
// biome-ignore lint/performance/noBarrelFile: _
|
|
2
2
|
export * as accessKey from './accessKey.js';
|
|
3
3
|
export * as accounts from './accounts.js';
|
|
4
|
+
/** @experimental */
|
|
5
|
+
export * as ai from './ai.js';
|
|
4
6
|
export * as amm from './amm.js';
|
|
7
|
+
/** @experimental */
|
|
8
|
+
export * as bucket from './bucket.js';
|
|
5
9
|
export * as channel from './channel.js';
|
|
10
|
+
/** @experimental */
|
|
11
|
+
export * as compute from './compute.js';
|
|
6
12
|
export * as dex from './dex.js';
|
|
7
13
|
export * as earn from './earn.js';
|
|
8
14
|
export * as faucet from './faucet.js';
|
|
9
15
|
export * as fee from './fee.js';
|
|
16
|
+
/** @experimental */
|
|
17
|
+
export * as gateway from './gateway.js';
|
|
18
|
+
/** @experimental */
|
|
19
|
+
export * as kv from './kv.js';
|
|
10
20
|
export * as nonce from './nonce.js';
|
|
11
21
|
export * as policy from './policy.js';
|
|
12
22
|
export * as propAmm from './propAmm.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../tempo/actions/index.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,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