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.
Files changed (111) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/_cjs/errors/version.js +1 -1
  3. package/_cjs/tempo/Gateway.js +195 -0
  4. package/_cjs/tempo/Gateway.js.map +1 -0
  5. package/_cjs/tempo/GatewayDecorator.js +168 -0
  6. package/_cjs/tempo/GatewayDecorator.js.map +1 -0
  7. package/_cjs/tempo/actions/ai.js +69 -0
  8. package/_cjs/tempo/actions/ai.js.map +1 -0
  9. package/_cjs/tempo/actions/bucket.js +85 -0
  10. package/_cjs/tempo/actions/bucket.js.map +1 -0
  11. package/_cjs/tempo/actions/compute.js +165 -0
  12. package/_cjs/tempo/actions/compute.js.map +1 -0
  13. package/_cjs/tempo/actions/gateway.js +8 -0
  14. package/_cjs/tempo/actions/gateway.js.map +1 -0
  15. package/_cjs/tempo/actions/index.js +6 -1
  16. package/_cjs/tempo/actions/index.js.map +1 -1
  17. package/_cjs/tempo/actions/kv.js +44 -0
  18. package/_cjs/tempo/actions/kv.js.map +1 -0
  19. package/_cjs/tempo/index.js +4 -1
  20. package/_cjs/tempo/index.js.map +1 -1
  21. package/_cjs/tempo/internal/ndjson.js +43 -0
  22. package/_cjs/tempo/internal/ndjson.js.map +1 -0
  23. package/_cjs/utils/buildRequest.js +4 -0
  24. package/_cjs/utils/buildRequest.js.map +1 -1
  25. package/_cjs/utils/hash/toSignatureHash.js +10 -1
  26. package/_cjs/utils/hash/toSignatureHash.js.map +1 -1
  27. package/_cjs/utils/rpc/http.js +6 -3
  28. package/_cjs/utils/rpc/http.js.map +1 -1
  29. package/_cjs/utils/rpc/socket.js +20 -9
  30. package/_cjs/utils/rpc/socket.js.map +1 -1
  31. package/_cjs/zksync/actions/finalizeWithdrawal.js +4 -2
  32. package/_cjs/zksync/actions/finalizeWithdrawal.js.map +1 -1
  33. package/_cjs/zksync/actions/isWithdrawalFinalized.js +4 -5
  34. package/_cjs/zksync/actions/isWithdrawalFinalized.js.map +1 -1
  35. package/_esm/errors/version.js +1 -1
  36. package/_esm/tempo/Gateway.js +294 -0
  37. package/_esm/tempo/Gateway.js.map +1 -0
  38. package/_esm/tempo/GatewayDecorator.js +207 -0
  39. package/_esm/tempo/GatewayDecorator.js.map +1 -0
  40. package/_esm/tempo/actions/ai.js +132 -0
  41. package/_esm/tempo/actions/ai.js.map +1 -0
  42. package/_esm/tempo/actions/bucket.js +181 -0
  43. package/_esm/tempo/actions/bucket.js.map +1 -0
  44. package/_esm/tempo/actions/compute.js +424 -0
  45. package/_esm/tempo/actions/compute.js.map +1 -0
  46. package/_esm/tempo/actions/gateway.js +22 -0
  47. package/_esm/tempo/actions/gateway.js.map +1 -0
  48. package/_esm/tempo/actions/index.js +10 -0
  49. package/_esm/tempo/actions/index.js.map +1 -1
  50. package/_esm/tempo/actions/kv.js +124 -0
  51. package/_esm/tempo/actions/kv.js.map +1 -0
  52. package/_esm/tempo/index.js +9 -0
  53. package/_esm/tempo/index.js.map +1 -1
  54. package/_esm/tempo/internal/ndjson.js +45 -0
  55. package/_esm/tempo/internal/ndjson.js.map +1 -0
  56. package/_esm/utils/buildRequest.js +6 -0
  57. package/_esm/utils/buildRequest.js.map +1 -1
  58. package/_esm/utils/hash/toSignatureHash.js +11 -1
  59. package/_esm/utils/hash/toSignatureHash.js.map +1 -1
  60. package/_esm/utils/rpc/http.js +11 -3
  61. package/_esm/utils/rpc/http.js.map +1 -1
  62. package/_esm/utils/rpc/socket.js +24 -9
  63. package/_esm/utils/rpc/socket.js.map +1 -1
  64. package/_esm/zksync/actions/finalizeWithdrawal.js +5 -2
  65. package/_esm/zksync/actions/finalizeWithdrawal.js.map +1 -1
  66. package/_esm/zksync/actions/isWithdrawalFinalized.js +5 -5
  67. package/_esm/zksync/actions/isWithdrawalFinalized.js.map +1 -1
  68. package/_types/errors/version.d.ts +1 -1
  69. package/_types/tempo/Gateway.d.ts +337 -0
  70. package/_types/tempo/Gateway.d.ts.map +1 -0
  71. package/_types/tempo/GatewayDecorator.d.ts +635 -0
  72. package/_types/tempo/GatewayDecorator.d.ts.map +1 -0
  73. package/_types/tempo/actions/ai.d.ts +145 -0
  74. package/_types/tempo/actions/ai.d.ts.map +1 -0
  75. package/_types/tempo/actions/bucket.d.ts +210 -0
  76. package/_types/tempo/actions/bucket.d.ts.map +1 -0
  77. package/_types/tempo/actions/compute.d.ts +628 -0
  78. package/_types/tempo/actions/compute.d.ts.map +1 -0
  79. package/_types/tempo/actions/gateway.d.ts +25 -0
  80. package/_types/tempo/actions/gateway.d.ts.map +1 -0
  81. package/_types/tempo/actions/index.d.ts +10 -0
  82. package/_types/tempo/actions/index.d.ts.map +1 -1
  83. package/_types/tempo/actions/kv.d.ts +167 -0
  84. package/_types/tempo/actions/kv.d.ts.map +1 -0
  85. package/_types/tempo/index.d.ts +11 -0
  86. package/_types/tempo/index.d.ts.map +1 -1
  87. package/_types/tempo/internal/ndjson.d.ts +9 -0
  88. package/_types/tempo/internal/ndjson.d.ts.map +1 -0
  89. package/_types/utils/buildRequest.d.ts.map +1 -1
  90. package/_types/utils/hash/toSignatureHash.d.ts +1 -1
  91. package/_types/utils/hash/toSignatureHash.d.ts.map +1 -1
  92. package/_types/utils/rpc/http.d.ts.map +1 -1
  93. package/_types/utils/rpc/socket.d.ts.map +1 -1
  94. package/errors/version.ts +1 -1
  95. package/package.json +5 -1
  96. package/tempo/Gateway.ts +477 -0
  97. package/tempo/GatewayDecorator.ts +909 -0
  98. package/tempo/actions/ai.ts +250 -0
  99. package/tempo/actions/bucket.ts +324 -0
  100. package/tempo/actions/compute.ts +894 -0
  101. package/tempo/actions/gateway.ts +33 -0
  102. package/tempo/actions/index.ts +10 -0
  103. package/tempo/actions/kv.ts +229 -0
  104. package/tempo/index.ts +12 -0
  105. package/tempo/internal/ndjson.ts +51 -0
  106. package/utils/buildRequest.ts +4 -0
  107. package/utils/hash/toSignatureHash.ts +12 -2
  108. package/utils/rpc/http.ts +11 -3
  109. package/utils/rpc/socket.ts +28 -15
  110. package/zksync/actions/finalizeWithdrawal.ts +5 -2
  111. package/zksync/actions/isWithdrawalFinalized.ts +5 -5
@@ -0,0 +1,635 @@
1
+ import type { Account } from '../accounts/types.js';
2
+ import type { Client } from '../clients/createClient.js';
3
+ import type { Transport } from '../clients/transports/createTransport.js';
4
+ import type { Chain } from '../types/chain.js';
5
+ import * as aiActions from './actions/ai.js';
6
+ import * as bucketActions from './actions/bucket.js';
7
+ import * as computeActions from './actions/compute.js';
8
+ import * as gatewayActions from './actions/gateway.js';
9
+ import * as kvActions from './actions/kv.js';
10
+ import * as Gateway from './Gateway.js';
11
+ /**
12
+ * Gateway actions added to a Client by {@link decorator}.
13
+ *
14
+ * @experimental
15
+ */
16
+ export type Decorator = {
17
+ /** Inference. */
18
+ ai: {
19
+ /**
20
+ * Embeds text with a Gateway model. Paid per request.
21
+ *
22
+ * @experimental
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import { createClient, gatewayActions } from 'viem/tempo'
27
+ *
28
+ * const client = createClient({ account }).extend(
29
+ * gatewayActions(),
30
+ * )
31
+ *
32
+ * const { embeddings } = await client.ai.embed({
33
+ * input: ['hello world'],
34
+ * model: '@cf/baai/bge-m3',
35
+ * })
36
+ * ```
37
+ *
38
+ * @param parameters - Parameters.
39
+ * @returns The embeddings and their shape.
40
+ */
41
+ embed: (parameters: aiActions.embed.Parameters) => Promise<aiActions.embed.ReturnValue>;
42
+ /**
43
+ * Generates text with a Gateway model. Paid per request.
44
+ *
45
+ * @experimental
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * import { createClient, gatewayActions } from 'viem/tempo'
50
+ *
51
+ * const client = createClient({ account }).extend(
52
+ * gatewayActions(),
53
+ * )
54
+ *
55
+ * const { text } = await client.ai.generateText({
56
+ * model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast',
57
+ * prompt: 'Describe this app in one sentence.',
58
+ * })
59
+ * ```
60
+ *
61
+ * @param parameters - Parameters.
62
+ * @returns The generated text and token usage.
63
+ */
64
+ generateText: (parameters: aiActions.generateText.Parameters) => Promise<aiActions.generateText.ReturnValue>;
65
+ /**
66
+ * Generates text with a Gateway model and yields it as it is produced.
67
+ * Paid per request.
68
+ *
69
+ * @experimental
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * import { createClient, gatewayActions } from 'viem/tempo'
74
+ *
75
+ * const client = createClient({ account }).extend(
76
+ * gatewayActions(),
77
+ * )
78
+ *
79
+ * for await (const event of client.ai.streamText({
80
+ * model: '@cf/zai-org/glm-5.3',
81
+ * prompt: 'Write a haiku about Tempo.',
82
+ * })) {
83
+ * if (event.type === 'text') process.stdout.write(event.delta)
84
+ * }
85
+ * ```
86
+ *
87
+ * @param parameters - Parameters.
88
+ * @returns Text and reasoning deltas, then usage.
89
+ */
90
+ streamText: (parameters: aiActions.streamText.Parameters) => AsyncGenerator<aiActions.streamText.Event>;
91
+ };
92
+ /** Object storage, private to the payer and app. */
93
+ bucket: {
94
+ /**
95
+ * Deletes an object from the app's bucket. Paid per request.
96
+ *
97
+ * @experimental
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * import { createClient, gatewayActions } from 'viem/tempo'
102
+ *
103
+ * const client = createClient({ account }).extend(
104
+ * gatewayActions(),
105
+ * )
106
+ *
107
+ * await client.bucket.delete({ key: 'notes/today.txt' })
108
+ * ```
109
+ *
110
+ * @param parameters - Parameters.
111
+ * @returns Whether the request succeeded.
112
+ */
113
+ delete: (parameters: bucketActions.delete.Parameters) => Promise<bucketActions.delete.ReturnValue>;
114
+ /**
115
+ * Reads an object from the app's bucket as a stream. Returns `null` when the
116
+ * object does not exist or expired. Paid per request.
117
+ *
118
+ * @experimental
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * import { createClient, gatewayActions } from 'viem/tempo'
123
+ *
124
+ * const client = createClient({ account }).extend(
125
+ * gatewayActions(),
126
+ * )
127
+ *
128
+ * const object = await client.bucket.get({ key: 'notes/today.txt' })
129
+ * ```
130
+ *
131
+ * @param parameters - Parameters.
132
+ * @returns The object body and metadata, or `null`.
133
+ */
134
+ get: (parameters: bucketActions.get.Parameters) => Promise<bucketActions.get.ReturnValue>;
135
+ /**
136
+ * Reads the metadata of an object in the app's bucket. Returns `null` when
137
+ * the object does not exist or expired. Paid per request.
138
+ *
139
+ * @experimental
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * import { createClient, gatewayActions } from 'viem/tempo'
144
+ *
145
+ * const client = createClient({ account }).extend(
146
+ * gatewayActions(),
147
+ * )
148
+ *
149
+ * const metadata = await client.bucket.head({ key: 'notes/today.txt' })
150
+ * ```
151
+ *
152
+ * @param parameters - Parameters.
153
+ * @returns The object metadata, or `null`.
154
+ */
155
+ head: (parameters: bucketActions.head.Parameters) => Promise<bucketActions.head.ReturnValue>;
156
+ /**
157
+ * Lists objects in the app's bucket by key prefix. Paid per request.
158
+ *
159
+ * @experimental
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * import { createClient, gatewayActions } from 'viem/tempo'
164
+ *
165
+ * const client = createClient({ account }).extend(
166
+ * gatewayActions(),
167
+ * )
168
+ *
169
+ * const { objects } = await client.bucket.list({ prefix: 'notes/' })
170
+ * ```
171
+ *
172
+ * @param parameters - Parameters.
173
+ * @returns A page of object metadata and the next cursor.
174
+ */
175
+ list: (parameters?: bucketActions.list.Parameters) => Promise<bucketActions.list.ReturnValue>;
176
+ /**
177
+ * Writes an object to the app's bucket for a retention period. Paid per
178
+ * request.
179
+ *
180
+ * @experimental
181
+ *
182
+ * @example
183
+ * ```ts
184
+ * import { createClient, gatewayActions } from 'viem/tempo'
185
+ *
186
+ * const client = createClient({ account }).extend(
187
+ * gatewayActions(),
188
+ * )
189
+ *
190
+ * const metadata = await client.bucket.put({
191
+ * key: 'notes/today.txt',
192
+ * retention: 86_400,
193
+ * value: new Blob(['hello'], { type: 'text/plain' }),
194
+ * })
195
+ * ```
196
+ *
197
+ * @param parameters - Parameters.
198
+ * @returns The object metadata.
199
+ */
200
+ put: (parameters: bucketActions.put.Parameters) => Promise<bucketActions.put.ReturnValue>;
201
+ };
202
+ /** Sandboxed CPU and GPU compute, private to the payer and app. */
203
+ compute: {
204
+ /**
205
+ * Starts a sandbox that can live up to `timeout` seconds, from a container
206
+ * image with optional `apt/pip` layers or from a snapshot. Compute is
207
+ * metered: creation pays for `lease` seconds at the sandbox's GPU, CPU, and
208
+ * memory rate, and `renew` pays for more. `ports` are served over public
209
+ * HTTPS tunnels.
210
+ *
211
+ * @experimental
212
+ *
213
+ * @example
214
+ * ```ts
215
+ * import { createClient, gatewayActions } from 'viem/tempo'
216
+ *
217
+ * const client = createClient({ account }).extend(
218
+ * gatewayActions(),
219
+ * )
220
+ *
221
+ * const sandbox = await client.compute.create({
222
+ * gpu: 'T4',
223
+ * image: 'pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime',
224
+ * timeout: 1200,
225
+ * })
226
+ * ```
227
+ *
228
+ * @param parameters - Parameters.
229
+ * @returns The sandbox and its tunnels.
230
+ */
231
+ create: <const ports extends readonly number[] = readonly []>(parameters?: computeActions.create.Parameters<ports>) => Promise<computeActions.create.ReturnValue<ports>>;
232
+ /**
233
+ * Runs a command in a sandbox and waits up to `timeout` seconds (at most
234
+ * 120). Use `spawn` for longer jobs. Paid per request.
235
+ *
236
+ * @experimental
237
+ *
238
+ * @example
239
+ * ```ts
240
+ * import { createClient, gatewayActions } from 'viem/tempo'
241
+ *
242
+ * const client = createClient({ account }).extend(
243
+ * gatewayActions(),
244
+ * )
245
+ *
246
+ * const { stdout } = await client.compute.exec({
247
+ * command: ['nvidia-smi'],
248
+ * sandboxId: sandbox.sandboxId,
249
+ * })
250
+ * ```
251
+ *
252
+ * @param parameters - Parameters.
253
+ * @returns The command's output and exit code.
254
+ */
255
+ exec: (parameters: computeActions.exec.Parameters) => Promise<computeActions.exec.ReturnValue>;
256
+ /**
257
+ * Lists the app's sandboxes that have not ended. Paid per request.
258
+ *
259
+ * @experimental
260
+ *
261
+ * @example
262
+ * ```ts
263
+ * import { createClient, gatewayActions } from 'viem/tempo'
264
+ *
265
+ * const client = createClient({ account }).extend(
266
+ * gatewayActions(),
267
+ * )
268
+ *
269
+ * const { sandboxes } = await client.compute.list()
270
+ * ```
271
+ *
272
+ * @param parameters - Parameters.
273
+ * @returns A page of sandboxes and the next cursor.
274
+ */
275
+ list: (parameters?: computeActions.list.Parameters) => Promise<computeActions.list.ReturnValue>;
276
+ /**
277
+ * Reads a file from a sandbox from `offset`, up to 8 MiB per request. Returns
278
+ * `null` when the file does not exist. Paid per request.
279
+ *
280
+ * @experimental
281
+ *
282
+ * @example
283
+ * ```ts
284
+ * import { createClient, gatewayActions } from 'viem/tempo'
285
+ *
286
+ * const client = createClient({ account }).extend(
287
+ * gatewayActions(),
288
+ * )
289
+ *
290
+ * const log = await client.compute.read({
291
+ * path: job.logPath,
292
+ * sandboxId: sandbox.sandboxId,
293
+ * })
294
+ * ```
295
+ *
296
+ * @param parameters - Parameters.
297
+ * @returns The bytes read and the whole file size, or `null`.
298
+ */
299
+ read: (parameters: computeActions.read.Parameters) => Promise<computeActions.read.ReturnValue>;
300
+ /**
301
+ * Saves a sandbox's filesystem as a snapshot kept for 30 days. Paid per
302
+ * request.
303
+ *
304
+ * @experimental
305
+ *
306
+ * @example
307
+ * ```ts
308
+ * import { createClient, gatewayActions } from 'viem/tempo'
309
+ *
310
+ * const client = createClient({ account }).extend(
311
+ * gatewayActions(),
312
+ * )
313
+ *
314
+ * const { snapshot } = await client.compute.snapshot({
315
+ * sandboxId: sandbox.sandboxId,
316
+ * })
317
+ * ```
318
+ *
319
+ * @param parameters - Parameters.
320
+ * @returns The snapshot ID and its expiry.
321
+ */
322
+ snapshot: (parameters: computeActions.snapshot.Parameters) => Promise<computeActions.snapshot.ReturnValue>;
323
+ /**
324
+ * Starts a command in the background; its output goes to `logPath` and its
325
+ * exit code to `exitPath`. Paid per request.
326
+ *
327
+ * @experimental
328
+ *
329
+ * @example
330
+ * ```ts
331
+ * import { createClient, gatewayActions } from 'viem/tempo'
332
+ *
333
+ * const client = createClient({ account }).extend(
334
+ * gatewayActions(),
335
+ * )
336
+ *
337
+ * const job = await client.compute.spawn({
338
+ * command: ['python', 'train.py'],
339
+ * sandboxId: sandbox.sandboxId,
340
+ * })
341
+ * ```
342
+ *
343
+ * @param parameters - Parameters.
344
+ * @returns The process ID and the paths of its log and exit code.
345
+ */
346
+ spawn: (parameters: computeActions.spawn.Parameters) => Promise<computeActions.spawn.ReturnValue>;
347
+ /**
348
+ * Reads whether a sandbox is running. Paid per request.
349
+ *
350
+ * @experimental
351
+ *
352
+ * @example
353
+ * ```ts
354
+ * import { createClient, gatewayActions } from 'viem/tempo'
355
+ *
356
+ * const client = createClient({ account }).extend(
357
+ * gatewayActions(),
358
+ * )
359
+ *
360
+ * const { status } = await client.compute.status({
361
+ * sandboxId: sandbox.sandboxId,
362
+ * })
363
+ * ```
364
+ *
365
+ * @param parameters - Parameters.
366
+ * @returns The sandbox and its status.
367
+ */
368
+ status: (parameters: computeActions.status.Parameters) => Promise<computeActions.status.ReturnValue>;
369
+ /**
370
+ * Terminates a sandbox. The Gateway credits the unused rest of its lease back to the payment channel. Paid per request.
371
+ *
372
+ * @experimental
373
+ *
374
+ * @example
375
+ * ```ts
376
+ * import { createClient, gatewayActions } from 'viem/tempo'
377
+ *
378
+ * const client = createClient({ account }).extend(
379
+ * gatewayActions(),
380
+ * )
381
+ *
382
+ * await client.compute.terminate({ sandboxId: sandbox.sandboxId })
383
+ * ```
384
+ *
385
+ * @param parameters - Parameters.
386
+ * @returns The final status.
387
+ */
388
+ terminate: (parameters: computeActions.terminate.Parameters) => Promise<computeActions.terminate.ReturnValue>;
389
+ /**
390
+ * Writes a file into a sandbox, up to 8 MiB. Paid per request.
391
+ *
392
+ * @experimental
393
+ *
394
+ * @example
395
+ * ```ts
396
+ * import { createClient, gatewayActions } from 'viem/tempo'
397
+ *
398
+ * const client = createClient({ account }).extend(
399
+ * gatewayActions(),
400
+ * )
401
+ *
402
+ * await client.compute.write({
403
+ * path: '/root/train.py',
404
+ * sandboxId: sandbox.sandboxId,
405
+ * value: 'print("training")',
406
+ * })
407
+ * ```
408
+ *
409
+ * @param parameters - Parameters.
410
+ * @returns The path and size written.
411
+ */
412
+ write: (parameters: computeActions.write.Parameters) => Promise<computeActions.write.ReturnValue>;
413
+ /**
414
+ * Pays for more seconds of a sandbox at its per-second rate, up to its
415
+ * `timeout`. Paid per request.
416
+ *
417
+ * @experimental
418
+ *
419
+ * @example
420
+ * ```ts
421
+ * import { createClient, gatewayActions } from 'viem/tempo'
422
+ *
423
+ * const client = createClient({ account }).extend(
424
+ * gatewayActions(),
425
+ * )
426
+ *
427
+ * await client.compute.renew({ sandboxId: sandbox.sandboxId, seconds: 300 })
428
+ * ```
429
+ *
430
+ * @param parameters - Parameters.
431
+ * @returns The sandbox with its new `paidUntil`.
432
+ */
433
+ renew: (parameters: computeActions.renew.Parameters) => Promise<computeActions.renew.ReturnValue>;
434
+ /**
435
+ * Runs a command and yields its output as it is written, then its exit.
436
+ * Paid per request.
437
+ *
438
+ * @experimental
439
+ *
440
+ * @example
441
+ * ```ts
442
+ * import { createClient, gatewayActions } from 'viem/tempo'
443
+ *
444
+ * const client = createClient({ account }).extend(
445
+ * gatewayActions(),
446
+ * )
447
+ *
448
+ * for await (const event of client.compute.stream({
449
+ * command: ['python', 'train.py'],
450
+ * sandboxId: sandbox.sandboxId,
451
+ * })) {
452
+ * if (event.type !== 'exit') process.stdout.write(event.data)
453
+ * }
454
+ * ```
455
+ *
456
+ * @param parameters - Parameters.
457
+ * @returns Output and exit events.
458
+ */
459
+ stream: (parameters: computeActions.stream.Parameters) => AsyncGenerator<computeActions.stream.Event>;
460
+ /**
461
+ * Follows the log of a command started with `spawn` and yields it as it
462
+ * grows, then the exit code. Paid per request.
463
+ *
464
+ * @experimental
465
+ *
466
+ * @example
467
+ * ```ts
468
+ * import { createClient, gatewayActions } from 'viem/tempo'
469
+ *
470
+ * const client = createClient({ account }).extend(
471
+ * gatewayActions(),
472
+ * )
473
+ *
474
+ * for await (const event of client.compute.logs({
475
+ * logPath: job.logPath,
476
+ * sandboxId: sandbox.sandboxId,
477
+ * })) {
478
+ * if (event.type === 'log') process.stdout.write(event.data)
479
+ * }
480
+ * ```
481
+ *
482
+ * @param parameters - Parameters.
483
+ * @returns Log, exit, and end events.
484
+ */
485
+ logs: (parameters: computeActions.logs.Parameters) => AsyncGenerator<computeActions.logs.Event>;
486
+ };
487
+ /** Gateway discovery. */
488
+ gateway: {
489
+ /**
490
+ * Reads the Gateway's free discovery document: chain, currencies, prices,
491
+ * limits, and models.
492
+ *
493
+ * @experimental
494
+ *
495
+ * @example
496
+ * ```ts
497
+ * import { createClient, gatewayActions } from 'viem/tempo'
498
+ *
499
+ * const client = createClient().extend(gatewayActions())
500
+ *
501
+ * const capabilities = await client.gateway.getCapabilities()
502
+ * ```
503
+ *
504
+ * @param parameters - Parameters.
505
+ * @returns The Gateway capabilities.
506
+ */
507
+ getCapabilities: (parameters?: gatewayActions.getCapabilities.Parameters | undefined) => Promise<gatewayActions.getCapabilities.ReturnValue>;
508
+ };
509
+ /** Key-value state, private to the payer and app. */
510
+ kv: {
511
+ /**
512
+ * Deletes a key from the app's key-value store. Paid per request.
513
+ *
514
+ * @experimental
515
+ *
516
+ * @example
517
+ * ```ts
518
+ * import { createClient, gatewayActions } from 'viem/tempo'
519
+ *
520
+ * const client = createClient({ account }).extend(
521
+ * gatewayActions(),
522
+ * )
523
+ *
524
+ * const { deleted } = await client.kv.delete({ key: 'counter' })
525
+ * ```
526
+ *
527
+ * @param parameters - Parameters.
528
+ * @returns Whether the key existed.
529
+ */
530
+ delete: (parameters: kvActions.delete.Parameters) => Promise<kvActions.delete.ReturnValue>;
531
+ /**
532
+ * Reads a key from the app's key-value store. Returns `null` when the key
533
+ * does not exist or expired. Paid per request.
534
+ *
535
+ * @experimental
536
+ *
537
+ * @example
538
+ * ```ts
539
+ * import { createClient, gatewayActions } from 'viem/tempo'
540
+ *
541
+ * const client = createClient({ account }).extend(
542
+ * gatewayActions(),
543
+ * )
544
+ *
545
+ * const entry = await client.kv.get({ key: 'counter' })
546
+ * ```
547
+ *
548
+ * @param parameters - Parameters.
549
+ * @returns The entry, or `null`.
550
+ */
551
+ get: (parameters: kvActions.get.Parameters) => Promise<kvActions.get.ReturnValue>;
552
+ /**
553
+ * Lists entries in the app's key-value store by key prefix, in key order.
554
+ * Paid per request.
555
+ *
556
+ * @experimental
557
+ *
558
+ * @example
559
+ * ```ts
560
+ * import { createClient, gatewayActions } from 'viem/tempo'
561
+ *
562
+ * const client = createClient({ account }).extend(
563
+ * gatewayActions(),
564
+ * )
565
+ *
566
+ * const { entries } = await client.kv.list({ prefix: 'settings/' })
567
+ * ```
568
+ *
569
+ * @param parameters - Parameters.
570
+ * @returns A page of entries and the next cursor.
571
+ */
572
+ list: (parameters?: kvActions.list.Parameters) => Promise<kvActions.list.ReturnValue>;
573
+ /**
574
+ * Writes a JSON value to the app's key-value store. Paid per request.
575
+ *
576
+ * Pass `ifVersion` to write conditionally: `null` creates the key only if it
577
+ * does not exist, and a version replaces the value only if it is still that
578
+ * version. A failed condition throws `Gateway.VersionConflictError`.
579
+ *
580
+ * @experimental
581
+ *
582
+ * @example
583
+ * ```ts
584
+ * import { createClient, gatewayActions } from 'viem/tempo'
585
+ *
586
+ * const client = createClient({ account }).extend(
587
+ * gatewayActions(),
588
+ * )
589
+ *
590
+ * const entry = await client.kv.set({
591
+ * ifVersion: null,
592
+ * key: 'counter',
593
+ * value: { count: 1 },
594
+ * })
595
+ * ```
596
+ *
597
+ * @param parameters - Parameters.
598
+ * @returns The written entry.
599
+ */
600
+ set: (parameters: kvActions.set.Parameters) => Promise<kvActions.set.ReturnValue>;
601
+ };
602
+ };
603
+ /**
604
+ * Adds Gateway inference (`client.ai`), object storage (`client.bucket`),
605
+ * sandboxed compute (`client.compute`), and key-value state (`client.kv`) to a
606
+ * Client.
607
+ *
608
+ * When the Client has a local account, requests are paid with it through
609
+ * `mppx` (an optional peer dependency, loaded on the first request). Other
610
+ * Clients use `globalThis.fetch`, which the Accounts SDK makes payment-aware
611
+ * for Tempo Wallet. Pass `fetch` to pay another way. Data is scoped by chain, the paying wallet, and `app`.
612
+ *
613
+ * @experimental
614
+ *
615
+ * @example
616
+ * ```ts
617
+ * import { createClient, gatewayActions } from 'viem/tempo'
618
+ *
619
+ * const client = createClient({ account }).extend(gatewayActions())
620
+ *
621
+ * const { text } = await client.ai.generateText({
622
+ * model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast',
623
+ * prompt: 'Describe this app in one sentence.',
624
+ * })
625
+ * await client.kv.set({ key: 'description', value: text })
626
+ * ```
627
+ *
628
+ * @param options - Gateway connection options.
629
+ * @returns A Client decorator.
630
+ */
631
+ export declare function decorator(options?: decorator.Options): <transport extends Transport, chain extends Chain | undefined, account extends Account | undefined>(client: Client<transport, chain, account>) => Decorator;
632
+ export declare namespace decorator {
633
+ type Options = Gateway.from.Options;
634
+ }
635
+ //# sourceMappingURL=GatewayDecorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GatewayDecorator.d.ts","sourceRoot":"","sources":["../../tempo/GatewayDecorator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAA;AAEzE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAC5C,OAAO,K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