@promigence/sdk 0.1.0-beta.7 → 0.1.0-beta.9

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.
@@ -243,6 +243,36 @@ export interface BackgroundExecList {
243
243
  execs: Array<BackgroundExec>;
244
244
  sandbox_id: string;
245
245
  }
246
+ /**
247
+ * `GET /v1/billing/history` — your billing history, newest first: every credit you received and
248
+ * every payment, one page at a time.
249
+ */
250
+ export interface BillingHistory {
251
+ entries: Array<BillingHistoryEntry>;
252
+ /**
253
+ * Pass as `cursor` for the next, older page; `null` on the last page.
254
+ */
255
+ next_cursor?: string | null;
256
+ }
257
+ /**
258
+ * One entry of your billing history: a credit you received or a payment. Exactly one of
259
+ * `credit` and `payment` is set.
260
+ */
261
+ export interface BillingHistoryEntry {
262
+ /**
263
+ * When it happened, RFC 3339: when a credit was added, when a payment was made, failed or
264
+ * was refunded.
265
+ */
266
+ at: string;
267
+ /**
268
+ * A credit you received; `null` for a payment.
269
+ */
270
+ credit?: CreditGrant | null;
271
+ /**
272
+ * A payment; `null` for a credit.
273
+ */
274
+ payment?: Payment | null;
275
+ }
246
276
  /**
247
277
  * The billing period `usage` covers.
248
278
  */
@@ -261,9 +291,9 @@ export interface BillingPeriod {
261
291
  start: string;
262
292
  }
263
293
  /**
264
- * `GET /v1/billing` — plan, card on file, this month's usage, and the upcoming invoice
265
- * preview. Never fails because the payment provider is slow: the estimate is the only part
266
- * that asks it, and its failure is a field, not a status.
294
+ * `GET /v1/billing` — plan, card on file, this month's usage, and the upcoming invoice preview.
295
+ * Never fails because the payment provider is slow: the estimate is the only part that asks it,
296
+ * and its failure is a field, not a status.
267
297
  */
268
298
  export interface BillingStatus {
269
299
  /**
@@ -274,11 +304,22 @@ export interface BillingStatus {
274
304
  * `null` while no card is on file.
275
305
  */
276
306
  card?: CardOnFile | null;
307
+ /**
308
+ * A sentence to show beside the card when it does not unlock paid limits for this
309
+ * organization (it already pays for another one, or it is being confirmed with a $1 charge, or
310
+ * that charge did not go through); `null` otherwise.
311
+ */
312
+ card_note?: string | null;
277
313
  card_on_file: boolean;
278
314
  /**
279
315
  * True once a billing customer exists for the organisation.
280
316
  */
281
317
  customer: boolean;
318
+ /**
319
+ * The $1 that confirms the payment method on file when it has no stable payer (Apple Pay,
320
+ * Google Pay, Amazon Pay); `null` when it needed none.
321
+ */
322
+ method_check?: MethodCheckView | null;
282
323
  notice?: TrialNotice | null;
283
324
  org_id: string;
284
325
  period: BillingPeriod;
@@ -305,16 +346,29 @@ export interface BuildJoined {
305
346
  alias?: string | null;
306
347
  alias_applied?: boolean | null;
307
348
  /**
308
- * The alias that was asked for, when the running build carries another. It was not applied;
309
- * `warnings` says what to do once the build verifies.
349
+ * The alias that was asked for, when the build in progress was to carry another, or none.
350
+ * The build carries it now (`alias_applied: true`) and its snapshot is stored under it;
351
+ * `warnings` names the alias the build was to carry.
310
352
  */
311
353
  alias_requested?: string | null;
354
+ /**
355
+ * Once the build has ended, the seconds it is billed for: the time it ran, whether it was
356
+ * stored, its own `setup` or `verify` failed, or it ran to its time limit; 0 when it failed
357
+ * on our side. Absent while it is queued or running, and for a build priced per build.
358
+ */
359
+ billable_seconds?: number | null;
312
360
  build_id: string;
313
361
  /**
314
- * What the build cost, in USD.
362
+ * The most the build can cost, in USD, as said when it was started: `max_seconds` at
363
+ * `per_second_usd`. What it was billed is `cost_usd`.
315
364
  */
316
365
  build_price: number;
317
366
  commit: string;
367
+ /**
368
+ * Once the build has ended, what it cost in USD; 0 when nothing was charged. Absent while it
369
+ * is queued or running.
370
+ */
371
+ cost_usd?: number | null;
318
372
  /**
319
373
  * RFC 3339.
320
374
  */
@@ -337,10 +391,20 @@ export interface BuildJoined {
337
391
  * Always true here.
338
392
  */
339
393
  joined: boolean;
394
+ /**
395
+ * The longest the build may run, in seconds: it is billed for at most this long. Absent for
396
+ * a build priced per build.
397
+ */
398
+ max_seconds?: number | null;
340
399
  /**
341
400
  * What to do next, ready to run.
342
401
  */
343
402
  next: Array<string>;
403
+ /**
404
+ * What one second of the build costs, in USD: its tier's per-second rate. Absent for a build
405
+ * priced per build, before builds were billed per second.
406
+ */
407
+ per_second_usd?: number | null;
344
408
  repo: string;
345
409
  setup: Array<string>;
346
410
  /**
@@ -371,8 +435,8 @@ export interface BuildJoined {
371
435
  /**
372
436
  * True when the build finished `verified` and its verification command passed. False while
373
437
  * it is queued or running, when it failed or was rejected, and for an image built without
374
- * `verify` (state `built`: stored, but nothing was verified). Nothing is stored and nothing
375
- * is charged if the command exits non-zero.
438
+ * `verify` (state `built`: stored, but nothing was verified). Nothing is stored if the
439
+ * command exits non-zero; the time the build ran is billed.
376
440
  */
377
441
  verified: boolean;
378
442
  /**
@@ -414,7 +478,8 @@ export interface BuildQueued {
414
478
  alias?: string | null;
415
479
  build_id: string;
416
480
  /**
417
- * What the build costs, in USD, said before it runs.
481
+ * The most the build can cost, in USD, said before it runs: `max_seconds` at
482
+ * `per_second_usd`. It is billed per second for the time it runs.
418
483
  */
419
484
  build_price: number;
420
485
  commit: string;
@@ -428,10 +493,18 @@ export interface BuildQueued {
428
493
  * given, so a client can say which earlier request this repeats.
429
494
  */
430
495
  idempotent_replay_age_s?: number | null;
496
+ /**
497
+ * The longest the build may run, in seconds: it is billed for at most this long.
498
+ */
499
+ max_seconds?: number | null;
431
500
  /**
432
501
  * What to do next, ready to run.
433
502
  */
434
503
  next: Array<string>;
504
+ /**
505
+ * What one second of the build costs, in USD: its tier's per-second rate.
506
+ */
507
+ per_second_usd?: number | null;
435
508
  repo: string;
436
509
  /**
437
510
  * What it is being built from. The `kind` field says which of the three forms it is.
@@ -470,12 +543,24 @@ export interface BuildView {
470
543
  * the snapshot is deleted: the name may belong to another snapshot by then.
471
544
  */
472
545
  alias?: string | null;
546
+ /**
547
+ * Once the build has ended, the seconds it is billed for: the time it ran, whether it was
548
+ * stored, its own `setup` or `verify` failed, or it ran to its time limit; 0 when it failed
549
+ * on our side. Absent while it is queued or running, and for a build priced per build.
550
+ */
551
+ billable_seconds?: number | null;
473
552
  build_id: string;
474
553
  /**
475
- * What the build cost, in USD.
554
+ * The most the build can cost, in USD, as said when it was started: `max_seconds` at
555
+ * `per_second_usd`. What it was billed is `cost_usd`.
476
556
  */
477
557
  build_price: number;
478
558
  commit: string;
559
+ /**
560
+ * Once the build has ended, what it cost in USD; 0 when nothing was charged. Absent while it
561
+ * is queued or running.
562
+ */
563
+ cost_usd?: number | null;
479
564
  /**
480
565
  * RFC 3339.
481
566
  */
@@ -488,10 +573,20 @@ export interface BuildView {
488
573
  * RFC 3339.
489
574
  */
490
575
  finished_at?: string | null;
576
+ /**
577
+ * The longest the build may run, in seconds: it is billed for at most this long. Absent for
578
+ * a build priced per build.
579
+ */
580
+ max_seconds?: number | null;
491
581
  /**
492
582
  * What to do next, ready to run.
493
583
  */
494
584
  next: Array<string>;
585
+ /**
586
+ * What one second of the build costs, in USD: its tier's per-second rate. Absent for a build
587
+ * priced per build, before builds were billed per second.
588
+ */
589
+ per_second_usd?: number | null;
495
590
  repo: string;
496
591
  setup: Array<string>;
497
592
  /**
@@ -522,8 +617,8 @@ export interface BuildView {
522
617
  /**
523
618
  * True when the build finished `verified` and its verification command passed. False while
524
619
  * it is queued or running, when it failed or was rejected, and for an image built without
525
- * `verify` (state `built`: stored, but nothing was verified). Nothing is stored and nothing
526
- * is charged if the command exits non-zero.
620
+ * `verify` (state `built`: stored, but nothing was verified). Nothing is stored if the
621
+ * command exits non-zero; the time the build ran is billed.
527
622
  */
528
623
  verified: boolean;
529
624
  /**
@@ -830,7 +925,7 @@ export interface CliTokenCreate {
830
925
  /**
831
926
  * Every error and failure code the API returns.
832
927
  */
833
- export type Code = "fork_failed" | "start_timeout" | "readiness_failed" | "verify_too_slow" | "verify_each_failed" | "sandbox_unresponsive" | "oom_within_tier" | "disk_full_within_tier" | "sandbox_interrupted" | "integrity_mismatch" | "egress_unavailable" | "service_timeout" | "capacity_busy" | "verify_did_not_cover" | "nonzero_exit" | "task_timeout" | "oom_over_tier" | "disk_over_tier" | "cap_killed" | "cap_exceeded" | "aborted_by_client" | "expired" | "not_started" | "superseded" | "usage" | "internal" | "auth" | "not_found" | "unreachable" | "rate_limited" | "timeout" | "not_verified" | "enoent" | "trial_credits_exhausted" | "card_required" | "concurrency_limit" | "egress_cap_reached" | "network_policy_unsupported" | "network_host_refused" | "toolchain_mismatch" | "resume_unavailable" | "sandbox_unreachable" | "region_at_capacity" | "tier_unavailable" | "snapshot_unavailable" | "capacity_limit" | "build_timeout" | "builder_unavailable" | "builder_busy" | "overloaded" | "preempted" | "grader_failed" | "grade_not_passed" | "shutdown_by_task" | "modified_by_task" | "cap_paused" | "credits_paused" | "stopped_by_support" | "forbidden" | "snapshot_incompatible" | "storage_limit_reached" | "dockerfile_build_failed" | "image_unresolvable" | "registry_unavailable" | "credit_unclaimed" | "billing_unavailable" | "project_cap_reached" | "spend_limit_reached" | "tier_over_plan" | "secrets_in_snapshot" | "secrets_unavailable" | "secret_binding_unsupported" | "idempotency_key_reused" | "idempotency_key_in_use" | "repo_credentials_not_supported" | "account_exists" | "invite_invalid" | "invite_required" | "key_expired" | "account_blocked" | "setup_required";
928
+ export type Code = "fork_failed" | "start_timeout" | "readiness_failed" | "verify_too_slow" | "verify_each_failed" | "sandbox_unresponsive" | "oom_within_tier" | "disk_full_within_tier" | "sandbox_interrupted" | "integrity_mismatch" | "egress_unavailable" | "service_timeout" | "capacity_busy" | "verify_did_not_cover" | "nonzero_exit" | "task_timeout" | "oom_over_tier" | "disk_over_tier" | "cap_killed" | "cap_exceeded" | "aborted_by_client" | "expired" | "not_started" | "superseded" | "usage" | "internal" | "auth" | "not_found" | "unreachable" | "rate_limited" | "timeout" | "not_verified" | "enoent" | "trial_credits_exhausted" | "card_required" | "concurrency_limit" | "egress_cap_reached" | "network_policy_unsupported" | "network_host_refused" | "toolchain_mismatch" | "resume_unavailable" | "sandbox_unreachable" | "region_at_capacity" | "tier_unavailable" | "snapshot_unavailable" | "capacity_limit" | "build_timeout" | "builder_unavailable" | "builder_busy" | "overloaded" | "preempted" | "grader_failed" | "grade_not_passed" | "shutdown_by_task" | "modified_by_task" | "cap_paused" | "credits_paused" | "stopped_by_support" | "forbidden" | "snapshot_incompatible" | "storage_limit_reached" | "dockerfile_build_failed" | "image_unresolvable" | "registry_unavailable" | "credit_unclaimed" | "billing_unavailable" | "project_cap_reached" | "spend_limit_reached" | "billing_hold" | "tier_over_plan" | "secrets_in_snapshot" | "secrets_unavailable" | "secret_binding_unsupported" | "idempotency_key_reused" | "idempotency_key_in_use" | "repo_credentials_not_supported" | "account_exists" | "invite_invalid" | "invite_required" | "key_expired" | "account_blocked" | "setup_required";
834
929
  export interface Concurrency {
835
930
  }
836
931
  /**
@@ -916,6 +1011,41 @@ export interface CreditClaim {
916
1011
  terms_version?: string | null;
917
1012
  token?: string | null;
918
1013
  }
1014
+ /**
1015
+ * A credit your organization received, and what is left of it.
1016
+ */
1017
+ export interface CreditGrant {
1018
+ /**
1019
+ * When it expires, RFC 3339; `null` when it never expires.
1020
+ */
1021
+ expires_at?: string | null;
1022
+ /**
1023
+ * When it was added, RFC 3339.
1024
+ */
1025
+ granted_at: string;
1026
+ /**
1027
+ * USD.
1028
+ */
1029
+ granted_usd: number;
1030
+ /**
1031
+ * What it is: `free_credit` (the free credit), `card_bonus` (credit for adding a card),
1032
+ * `referral` (a referral reward), `plan` (usage included with a paid plan),
1033
+ * `from_promigence` (credit Promigence added to your account), `service_restart` (credit
1034
+ * for a command a service restart stopped), `confirmation_credit` (a $1 charge that
1035
+ * confirmed a payment method, added back as credit), or `other`.
1036
+ */
1037
+ kind: string;
1038
+ /**
1039
+ * What is left of it, USD: 0 once it is used, expired or taken back. Credit that expires
1040
+ * soonest is used first, and credit that never expires last.
1041
+ */
1042
+ remaining_usd: number;
1043
+ /**
1044
+ * `active` (some of it is left), `used` (all of it was used), `expired` (it expired before
1045
+ * all of it was used), or `taken_back`.
1046
+ */
1047
+ status: string;
1048
+ }
919
1049
  /**
920
1050
  * The account's free credit (`GET /v1/credits/offer`, and the answer to a claim). The credit is
921
1051
  * claimed in the browser, where the terms are accepted: `POST /v1/credits/claim-link` makes the
@@ -942,6 +1072,11 @@ export interface CreditOffer {
942
1072
  * One sentence for a person.
943
1073
  */
944
1074
  message: string;
1075
+ /**
1076
+ * USD charged to confirm a payment method with no stable payer when it is added (Apple Pay,
1077
+ * Google Pay, Amazon Pay): it is added to your credit, and the card bonus comes with it.
1078
+ */
1079
+ method_check_usd?: number;
945
1080
  /**
946
1081
  * `claimable`, `claimed`, `pending_review`, `needs_card`, `not_eligible`, `offer_ended`,
947
1082
  * `denied` or `none`.
@@ -1075,7 +1210,7 @@ export interface ErrorBody {
1075
1210
  /**
1076
1211
  * Every error code the API returns. `category` decides whether the failure is billed: `env` is ours (not billed before hand-over; after it, the time since the sandbox's last snapshot is credited back, up to 24 hours, when our side shows the cause), `task` is your command and is billed. The full table is `x-promigence-error-codes` at the document root.
1077
1212
  */
1078
- export type ErrorCode = "fork_failed" | "start_timeout" | "readiness_failed" | "verify_too_slow" | "verify_each_failed" | "toolchain_mismatch" | "sandbox_unresponsive" | "oom_within_tier" | "disk_full_within_tier" | "sandbox_interrupted" | "integrity_mismatch" | "egress_unavailable" | "service_timeout" | "preempted" | "verify_did_not_cover" | "grader_failed" | "nonzero_exit" | "grade_not_passed" | "task_timeout" | "oom_over_tier" | "disk_over_tier" | "shutdown_by_task" | "modified_by_task" | "cap_killed" | "cap_exceeded" | "cap_paused" | "credits_paused" | "aborted_by_client" | "stopped_by_support" | "expired" | "not_started" | "superseded" | "usage" | "internal" | "auth" | "forbidden" | "not_found" | "unreachable" | "rate_limited" | "timeout" | "not_verified" | "snapshot_incompatible" | "storage_limit_reached" | "resume_unavailable" | "sandbox_unreachable" | "capacity_busy" | "region_at_capacity" | "builder_unavailable" | "builder_busy" | "overloaded" | "tier_unavailable" | "snapshot_unavailable" | "capacity_limit" | "build_timeout" | "dockerfile_build_failed" | "image_unresolvable" | "registry_unavailable" | "enoent" | "trial_credits_exhausted" | "credit_unclaimed" | "setup_required" | "card_required" | "billing_unavailable" | "concurrency_limit" | "egress_cap_reached" | "project_cap_reached" | "spend_limit_reached" | "tier_over_plan" | "network_host_refused" | "network_policy_unsupported" | "secrets_in_snapshot" | "secrets_unavailable" | "secret_binding_unsupported" | "idempotency_key_reused" | "idempotency_key_in_use" | "repo_credentials_not_supported" | "account_exists" | "invite_invalid" | "invite_required" | "key_expired" | "account_blocked";
1213
+ export type ErrorCode = "fork_failed" | "start_timeout" | "readiness_failed" | "verify_too_slow" | "verify_each_failed" | "toolchain_mismatch" | "sandbox_unresponsive" | "oom_within_tier" | "disk_full_within_tier" | "sandbox_interrupted" | "integrity_mismatch" | "egress_unavailable" | "service_timeout" | "preempted" | "verify_did_not_cover" | "grader_failed" | "nonzero_exit" | "grade_not_passed" | "task_timeout" | "oom_over_tier" | "disk_over_tier" | "shutdown_by_task" | "modified_by_task" | "cap_killed" | "cap_exceeded" | "cap_paused" | "credits_paused" | "aborted_by_client" | "stopped_by_support" | "expired" | "not_started" | "superseded" | "usage" | "internal" | "auth" | "forbidden" | "not_found" | "unreachable" | "rate_limited" | "timeout" | "not_verified" | "snapshot_incompatible" | "storage_limit_reached" | "resume_unavailable" | "sandbox_unreachable" | "capacity_busy" | "region_at_capacity" | "builder_unavailable" | "builder_busy" | "overloaded" | "tier_unavailable" | "snapshot_unavailable" | "capacity_limit" | "build_timeout" | "dockerfile_build_failed" | "image_unresolvable" | "registry_unavailable" | "enoent" | "trial_credits_exhausted" | "credit_unclaimed" | "setup_required" | "card_required" | "billing_unavailable" | "concurrency_limit" | "egress_cap_reached" | "project_cap_reached" | "spend_limit_reached" | "billing_hold" | "tier_over_plan" | "network_host_refused" | "network_policy_unsupported" | "secrets_in_snapshot" | "secrets_unavailable" | "secret_binding_unsupported" | "idempotency_key_reused" | "idempotency_key_in_use" | "repo_credentials_not_supported" | "account_exists" | "invite_invalid" | "invite_required" | "key_expired" | "account_blocked";
1079
1214
  /**
1080
1215
  * `POST /v1/sandboxes/{id}/execs`, and the `exec` of `POST /v1/runs`: one command. `argv` (a
1081
1216
  * non-empty list) or `sh` (a shell line) is required.
@@ -2379,7 +2514,7 @@ export interface LedgerEntryView {
2379
2514
  */
2380
2515
  seconds: number;
2381
2516
  /**
2382
- * What was charged: a sandbox id or a build id.
2517
+ * What was charged: a sandbox id or a build id; for credit, what it is for (e.g. "Credit from Promigence").
2383
2518
  */
2384
2519
  subject: string;
2385
2520
  tier: string;
@@ -2547,6 +2682,29 @@ export interface MemberView {
2547
2682
  */
2548
2683
  you: boolean;
2549
2684
  }
2685
+ /**
2686
+ * The $1 charged to confirm a payment method with no stable payer (`GET /v1/billing`
2687
+ * `method_check`).
2688
+ */
2689
+ export interface MethodCheckView {
2690
+ /**
2691
+ * USD charged; added to your credit once paid.
2692
+ */
2693
+ amount_usd: number;
2694
+ /**
2695
+ * USD of credit that came with it (the card bonus), once paid; `null` otherwise.
2696
+ */
2697
+ bonus_usd?: number | null;
2698
+ /**
2699
+ * The method as a person reads it: `Apple Pay`, `Google Pay`, `Amazon Pay`, ...
2700
+ */
2701
+ method: string;
2702
+ /**
2703
+ * `confirming` (charged, its answer not in yet), `paid` (it counts as your payment method) or
2704
+ * `failed` (declined, or it needed you there to approve it: it does not count; add a card).
2705
+ */
2706
+ status: string;
2707
+ }
2550
2708
  /**
2551
2709
  * `POST /v1/orgs` and `POST /v1/orgs/{org}/projects`.
2552
2710
  */
@@ -2814,6 +2972,44 @@ export interface ParkedBytes {
2814
2972
  */
2815
2973
  allocated: number;
2816
2974
  }
2975
+ /**
2976
+ * A payment: an invoice paid, a payment that failed, a refund, or the charge that confirmed a
2977
+ * payment method.
2978
+ */
2979
+ export interface Payment {
2980
+ /**
2981
+ * USD: what was paid, what was due, what was refunded, or what confirmed the method.
2982
+ */
2983
+ amount_usd: number;
2984
+ /**
2985
+ * The invoice's number, as the invoice shows it; `null` when not known.
2986
+ */
2987
+ invoice_number?: string | null;
2988
+ /**
2989
+ * The invoice's page: its receipt once it is paid, where to pay it while a payment has
2990
+ * failed; `null` when not known.
2991
+ */
2992
+ invoice_url?: string | null;
2993
+ /**
2994
+ * `invoice_paid`, `payment_failed`, `refund`, or `method_check` (a charge, usually $1, that
2995
+ * confirmed a payment method; it comes back as credit).
2996
+ */
2997
+ kind: string;
2998
+ /**
2999
+ * `method_check`: the payment method it confirmed, by name (`Apple Pay`); `null` otherwise.
3000
+ */
3001
+ method?: string | null;
3002
+ /**
3003
+ * The plan whose fee the invoice billed; `null` when it billed usage alone.
3004
+ */
3005
+ plan?: string | null;
3006
+ /**
3007
+ * `paid` (for a payment that failed: paid since), `retrying` (it failed and will be tried
3008
+ * again), `failed` (it failed and will not be tried again; for `method_check`, the method
3009
+ * was not confirmed), `refunded`, or `confirmed` (`method_check`: the method is confirmed).
3010
+ */
3011
+ status: string;
3012
+ }
2817
3013
  export interface Percentiles {
2818
3014
  p50: number;
2819
3015
  p95: number;
@@ -2961,6 +3157,11 @@ export interface PricingFreeCredit {
2961
3157
  * The limits in force.
2962
3158
  */
2963
3159
  export interface PricingLimits {
3160
+ /**
3161
+ * The longest a snapshot build may run, in seconds, and so the most seconds one build is
3162
+ * billed for.
3163
+ */
3164
+ build_max_s?: number | null;
2964
3165
  /**
2965
3166
  * A sandbox's timeout when its run names none, in seconds.
2966
3167
  */
@@ -3019,8 +3220,11 @@ export interface PricingPlan {
3019
3220
  */
3020
3221
  export interface PricingRates {
3021
3222
  /**
3022
- * One snapshot build, charged once it verifies. A build that fails `verify` stores nothing
3023
- * and is not charged; reusing an identical build is free.
3223
+ * The most one snapshot build of the default tier can cost: `limits.build_max_s` seconds at
3224
+ * that tier's per-second rate. A build is billed per second at its own tier's rate (`tiers`)
3225
+ * for the time it runs, whether it is stored, its own `setup` or `verify` fails, or it runs to
3226
+ * its time limit; a failure on our side, and reusing or joining an identical build, cost
3227
+ * nothing.
3024
3228
  */
3025
3229
  build_usd: number;
3026
3230
  /**
@@ -4502,7 +4706,7 @@ export interface SandboxView {
4502
4706
  */
4503
4707
  outcome?: string | null;
4504
4708
  /**
4505
- * While it is paused: when it will be deleted, with its memory and files, unless it is
4709
+ * While it is paused: when it will be deleted, with its files and state, unless it is
4506
4710
  * resumed before then (RFC 3339). A paused sandbox is kept for 30 days, and resuming it
4507
4711
  * starts the 30 days again. Absent while it is not paused, and for a paused sandbox that is
4508
4712
  * not due to be deleted.
@@ -5059,8 +5263,7 @@ export interface SnapshotCreate {
5059
5263
  */
5060
5264
  export type SnapshotCreated = BuildQueued | BuildJoined | SnapshotDeduped;
5061
5265
  /**
5062
- * Inputs that are already built: the existing snapshot, and whether the alias that was asked
5063
- * for could be applied to it.
5266
+ * Inputs that are already built: the existing snapshot, named with the alias that was asked for.
5064
5267
  */
5065
5268
  export interface SnapshotDeduped {
5066
5269
  /**
@@ -5069,8 +5272,10 @@ export interface SnapshotDeduped {
5069
5272
  alias?: string | null;
5070
5273
  alias_applied?: boolean | null;
5071
5274
  /**
5072
- * The alias that was asked for, when it differs from the snapshot's. An unnamed snapshot
5073
- * takes the name (`alias_applied: true`); a named one keeps its own and `warnings` says so.
5275
+ * The alias that was asked for, when the snapshot did not hold it. The snapshot takes it
5276
+ * (`alias_applied: true`) as a new build would: another snapshot of the project that had it
5277
+ * keeps its row, without a name. A snapshot has one alias, so a name it had before gives
5278
+ * way, and `warnings` says which.
5074
5279
  */
5075
5280
  alias_requested?: string | null;
5076
5281
  /**
package/dist/proxy.js CHANGED
@@ -199,8 +199,9 @@ export function requestVia(url, options, env = process.env) {
199
199
  connect.end();
200
200
  return undefined;
201
201
  };
202
+ const { agent: _agent, ...direct } = options;
202
203
  return httpsRequest(url, {
203
- ...options,
204
+ ...direct,
204
205
  createConnection: createConnection,
205
206
  });
206
207
  }
package/dist/pty.d.ts CHANGED
@@ -13,6 +13,10 @@
13
13
  */
14
14
  /** Largest terminal input frame sent; the server's cap is 1 MiB per client frame. */
15
15
  export declare const PTY_INPUT_CHUNK: number;
16
+ /** How much of what was typed a session keeps, to send again to a terminal picked up again. */
17
+ export declare const PTY_INPUT_KEEP: number;
18
+ /** The header a terminal is picked up again with (its resume token). */
19
+ export declare const PTY_RESUME_HEADER = "promigence-resume";
16
20
  export interface PtySize {
17
21
  cols: number;
18
22
  rows: number;
@@ -53,6 +57,33 @@ export interface PtyConnectOpts {
53
57
  caller?: string;
54
58
  onData?: (data: Uint8Array) => void;
55
59
  onExit?: (exit: PtyExit) => void;
60
+ /**
61
+ * Reconnect in a new shell when the service is updated (a WebSocket `Close` 1012) and the
62
+ * terminal cannot be picked up again ([`resume`]). The session goes on over a new connection,
63
+ * with its callbacks, its size and what was typed meanwhile, in a NEW shell: what ran in the old
64
+ * one has ended. Tried for up to 30 s ([`PTY_RECONNECT_FOR_MS`]); past that the session ends with
65
+ * `error.code` `"service_restart"`.
66
+ *
67
+ * Default: on for a shell, off when `command` is set (reconnecting starts the command again,
68
+ * which may not be safe to run twice); `true` or `false` decides either way.
69
+ */
70
+ reconnect?: boolean;
71
+ /**
72
+ * Pick the same terminal up again when its connection drops or the service restarts (default
73
+ * on): the terminal keeps running for a short while, and the session picks up where it left off
74
+ * over a new connection, with what was typed meanwhile delivered once — the same shell, or the
75
+ * same command, still running. Where it cannot be picked up (it ended meanwhile, or too much time
76
+ * passed), a restart falls back to [`reconnect`]; a dropped connection ends the session, as
77
+ * before.
78
+ */
79
+ resume?: boolean;
80
+ /**
81
+ * Called after each reconnect: `resumed` is `true` when it is the same terminal picked up
82
+ * again, `false` when it is a new shell (what ran in the old one has ended).
83
+ */
84
+ onReconnected?: (how: {
85
+ resumed: boolean;
86
+ }) => void;
56
87
  /** Handshake bound (default 30 s). The session itself has none. */
57
88
  timeoutMs?: number;
58
89
  /** Maps a refused upgrade (`status`, body text, its `Retry-After`) onto the SDK's error classes. */
@@ -80,15 +111,28 @@ export declare class FrameReader {
80
111
  */
81
112
  export declare class PtySession {
82
113
  #private;
83
- private readonly socket;
84
- /** The id of the terminal's process inside the sandbox (`req_id`); what `pty.kill(pid)` addresses. */
114
+ private socket;
115
+ /**
116
+ * The id of the terminal's process inside the sandbox (`req_id`); what `pty.kill(pid)`
117
+ * addresses. It names this session: it stays the same after a reconnect.
118
+ */
85
119
  readonly pid: number;
86
120
  cols: number;
87
121
  rows: number;
88
122
  private closed;
89
123
  private readonly done;
124
+ /** Frames written while the session reconnects, sent once it has (at most 1 MiB). */
125
+ private pending;
126
+ /** Keystrokes written to a connection, in all, and the last of them, from `inputBase` on: what a
127
+ * terminal picked up again did not take is sent again. */
128
+ private inputSent;
129
+ private inputBase;
130
+ private inputLog;
90
131
  /** `true` once the terminal has ended (its exit arrived, or the socket closed). */
91
132
  get ended(): boolean;
133
+ private flush;
134
+ /** Write a frame to the connection now, counting keystrokes. */
135
+ private writeNow;
92
136
  private send;
93
137
  /** Keystrokes / a paste. A string is sent as UTF-8. */
94
138
  write(data: string | Uint8Array): void;
@@ -105,5 +149,23 @@ export declare class PtySession {
105
149
  */
106
150
  disconnect(): void;
107
151
  }
108
- /** Open a terminal. Rejects with `opts.refuse(...)` if the server does not switch protocols. */
152
+ /** The `Close` code a terminal is asked to reconnect with: 1012, "service restart" (RFC 6455's registry). */
153
+ export declare const PTY_RECONNECT_CODE = 1012;
154
+ /** How long a terminal tries to reconnect before it ends (`error.code` `"service_restart"`). */
155
+ export declare const PTY_RECONNECT_FOR_MS = 30000;
156
+ /** The first wait before a reconnect, doubled each try up to [`PTY_RECONNECT_MAX_WAIT_MS`]; each wait is jittered (50-100 %). */
157
+ export declare const PTY_RECONNECT_FIRST_WAIT_MS = 250;
158
+ export declare const PTY_RECONNECT_MAX_WAIT_MS = 4000;
159
+ /** How a session that could not reconnect within [`PTY_RECONNECT_FOR_MS`] ends. */
160
+ export declare const PTY_RESTART_EXIT: PtyExit;
161
+ /** How a session that is not to reconnect (`reconnect` off, or a command's) ends at a 1012. */
162
+ export declare const PTY_RESTART_CLOSED_EXIT: PtyExit;
163
+ /**
164
+ * Open a terminal. Rejects with `opts.refuse(...)` if the server does not switch protocols.
165
+ *
166
+ * When its connection drops, or the service asks it to reconnect (`Close` 1012), the session goes
167
+ * on over a new connection: the same terminal picked up again where the service still holds it
168
+ * ([`PtyConnectOpts.resume`]), else, at a restart, a new shell ([`PtyConnectOpts.reconnect`]).
169
+ * `wait()` resolves only when the session really ends.
170
+ */
109
171
  export declare function connectPty(opts: PtyConnectOpts): Promise<PtySession>;