@blockrun/franklin 3.49.23 → 3.49.24

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.
@@ -5,7 +5,9 @@
5
5
  * underlying primitives.
6
6
  *
7
7
  * Pricing (per-call, USDC):
8
- * create: $0.01 (CPU) / $0.05 (T4) / $0.08 (L4) / $0.10 (A10G) / $0.20 (A100) / $0.40 (H100)
8
+ * create at up to 1 CPU and 1024 MB: $0.01 (CPU) / $0.05 (T4) / $0.08 (L4) / $0.10 (A10G) / $0.20 (A100) / $0.40 (H100)
9
+ * create above that: hourly rate x lifetime, never below the flat rate:
10
+ * $4 (T4) / $4.50 (L4) / $5 (A10G) / $7 (A100) / $9 (H100) per hour
9
11
  * exec: $0.001
10
12
  * status: $0.001
11
13
  * terminate: $0.001
@@ -28,6 +30,13 @@
28
30
  import type { CapabilityHandler } from '../agent/types.js';
29
31
  import { type Chain } from '../config.js';
30
32
  import { type ReservationToken } from '../wallet/reservation.js';
33
+ /**
34
+ * What the gateway will ask for this create. The reservation and the confirm
35
+ * dialog both read it, so it has to see size as well as GPU type: an 8-core T4
36
+ * is $0.33, not the $0.05 a tier lookup says. Lifetime is capped at 300s here,
37
+ * so the CPU tier is always flat.
38
+ */
39
+ export declare function modalCreatePriceUsd(tier: string, cpu?: number, memory?: number, timeoutSeconds?: number): number;
31
40
  export interface SandboxRecord {
32
41
  id: string;
33
42
  gpu: string;
@@ -5,7 +5,9 @@
5
5
  * underlying primitives.
6
6
  *
7
7
  * Pricing (per-call, USDC):
8
- * create: $0.01 (CPU) / $0.05 (T4) / $0.08 (L4) / $0.10 (A10G) / $0.20 (A100) / $0.40 (H100)
8
+ * create at up to 1 CPU and 1024 MB: $0.01 (CPU) / $0.05 (T4) / $0.08 (L4) / $0.10 (A10G) / $0.20 (A100) / $0.40 (H100)
9
+ * create above that: hourly rate x lifetime, never below the flat rate:
10
+ * $4 (T4) / $4.50 (L4) / $5 (A10G) / $7 (A100) / $9 (H100) per hour
9
11
  * exec: $0.001
10
12
  * status: $0.001
11
13
  * terminate: $0.001
@@ -41,6 +43,32 @@ const CREATE_PRICE_USD = {
41
43
  A100: 0.20,
42
44
  H100: 0.40,
43
45
  };
46
+ // The gateway bills a larger sandbox by the hour for its whole lifetime. Keep in
47
+ // step with getModalCreatePricing in the gateway's src/lib/modal.ts.
48
+ const GPU_HOURLY_PRICE_USD = {
49
+ T4: 4.00,
50
+ L4: 4.50,
51
+ A10G: 5.00,
52
+ A100: 7.00,
53
+ H100: 9.00,
54
+ };
55
+ const FLAT_RATE_MAX_CPU = 1;
56
+ const FLAT_RATE_MAX_MEMORY_MB = 1024;
57
+ const DEFAULT_TIMEOUT_SECONDS = 300;
58
+ /**
59
+ * What the gateway will ask for this create. The reservation and the confirm
60
+ * dialog both read it, so it has to see size as well as GPU type: an 8-core T4
61
+ * is $0.33, not the $0.05 a tier lookup says. Lifetime is capped at 300s here,
62
+ * so the CPU tier is always flat.
63
+ */
64
+ export function modalCreatePriceUsd(tier, cpu, memory, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) {
65
+ const flat = CREATE_PRICE_USD[tier];
66
+ const hourly = GPU_HOURLY_PRICE_USD[tier];
67
+ const small = (cpu ?? 1) <= FLAT_RATE_MAX_CPU && (memory ?? 512) <= FLAT_RATE_MAX_MEMORY_MB;
68
+ if (small || hourly === undefined)
69
+ return flat;
70
+ return Math.max(flat, hourly * (timeoutSeconds / 3600));
71
+ }
44
72
  const EXEC_PRICE_USD = 0.001;
45
73
  const STATUS_PRICE_USD = 0.001;
46
74
  const TERMINATE_PRICE_USD = 0.001;
@@ -274,8 +302,9 @@ export const modalCreateCapability = {
274
302
  spec: {
275
303
  name: 'ModalCreate',
276
304
  description: 'Create a Modal Python 3.11 sandbox (CPU or GPU) via the BlockRun gateway. ' +
277
- 'Returns a sandbox_id you pass to ModalExec. Charged once per create at the ' +
278
- 'GPU tier price: CPU $0.01, T4 $0.05, L4 $0.08, A10G $0.10, A100 $0.20, H100 $0.40. ' +
305
+ 'Returns a sandbox_id you pass to ModalExec. Charged once per create. Up to 1 CPU and ' +
306
+ '1024 MB: CPU $0.01, T4 $0.05, L4 $0.08, A10G $0.10, A100 $0.20, H100 $0.40. Larger GPU ' +
307
+ 'sandboxes pay hourly for the lifetime, at least the same: T4 $4, L4 $4.50, A10G $5, A100 $7, H100 $9 per hour. ' +
279
308
  'IMPORTANT — current limitations (BlockRun gateway is in early-access for sandboxes):\n' +
280
309
  ' - sandbox lifetime: 5 minutes MAX (gateway hard-cap, regardless of GPU tier)\n' +
281
310
  ' - per ModalExec call: 60 seconds MAX wall-clock\n' +
@@ -299,8 +328,8 @@ export const modalCreateCapability = {
299
328
  properties: {
300
329
  gpu: { type: 'string', description: 'GPU tier. One of T4, L4, A10G, A100, H100. Omit for CPU-only ($0.01).' },
301
330
  timeout: { type: 'number', description: 'Lifetime cap in seconds. Default + Max = 300 (5 min). Gateway rejects values > 300 with HTTP 400.' },
302
- cpu: { type: 'number', description: 'Number of CPU cores. Default 0.125, max 8.' },
303
- memory: { type: 'number', description: 'Memory MB. Default 128, max 32768.' },
331
+ cpu: { type: 'number', description: 'Number of CPU cores. Default 1, min 0.125, max 1 for CPU sandboxes and 8 with a GPU. Above 1 bills hourly.' },
332
+ memory: { type: 'number', description: 'Memory MB. Default 512, max 1024 for CPU sandboxes and 32768 with a GPU. Above 1024 bills hourly.' },
304
333
  },
305
334
  },
306
335
  },
@@ -326,7 +355,6 @@ export const modalCreateCapability = {
326
355
  };
327
356
  }
328
357
  const tier = gpu ?? 'cpu';
329
- const price = CREATE_PRICE_USD[tier];
330
358
  // Coerce numeric fields. Reject NaN explicitly so we don't ship
331
359
  // garbage to the gateway.
332
360
  const coerceNum = (v, name) => {
@@ -359,6 +387,7 @@ export const modalCreateCapability = {
359
387
  isError: true,
360
388
  };
361
389
  }
390
+ const price = modalCreatePriceUsd(tier, typeof cpuCoerced === 'number' ? cpuCoerced : undefined, typeof memoryCoerced === 'number' ? memoryCoerced : undefined, typeof timeoutCoerced === 'number' ? timeoutCoerced : undefined);
362
391
  // ── AskUser cost preview (skipped if env auto-approve or non-UI mode) ──
363
392
  const autoApprove = process.env.FRANKLIN_MEDIA_AUTO_APPROVE_ALL === '1';
364
393
  if (ctx.onAskUser && !autoApprove) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/franklin",
3
- "version": "3.49.23",
3
+ "version": "3.49.24",
4
4
  "description": "Franklin Agent — The AI agent with a wallet. Spends USDC autonomously to get real work done. Pay per action, no subscriptions.",
5
5
  "type": "module",
6
6
  "exports": {