@boxline/sdk 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -42,7 +42,7 @@ export interface LoginResponse {
42
42
  project: Project;
43
43
  }
44
44
  /** What a plan may use; set per plan in the admin panel. Calls that need a missing one fail with 402 `feature_not_in_plan`. */
45
- export type PlanFeature = "shell" | "pauseResume" | "contexts" | "recording" | "realisticBrowser" | "residentialProxy" | "datacenterProxy" | "customProxy" | "captchaSolving" | "agentRuns" | "steps" | "extract" | "quickApis" | "crawl" | "extensions" | "webSearch" | "loginDetails"
45
+ export type PlanFeature = "shell" | "pauseResume" | "profiles" | "recording" | "realisticBrowser" | "residentialProxy" | "datacenterProxy" | "customProxy" | "captchaSolving" | "agentRuns" | "steps" | "extract" | "quickApis" | "crawl" | "extensions" | "webSearch" | "loginDetails"
46
46
  /** Model calls on Boxline's keys; without it (Free) a project runs models on its own keys only. */
47
47
  | "platformModels";
48
48
  /** A plan's limits (null = no limit) and features. */
@@ -69,12 +69,12 @@ export interface Plan {
69
69
  tasks?: number | null;
70
70
  /** Tasks with a schedule switched on; 0 = no schedules, null = no limit. */
71
71
  schedules?: number | null;
72
- /** Project secrets a project may keep. */
73
- maxSecrets?: number;
74
- /** Saved logins (contexts) a project may keep; null = no limit. */
75
- maxContexts?: number | null;
76
- /** Bytes a project's saved logins may hold together; null = no limit. */
77
- maxContextBytes?: number | null;
72
+ /** Credentials (passwords and secrets together) a project may keep. */
73
+ maxCredentials?: number;
74
+ /** Browser profiles a project may keep; null = no limit. */
75
+ maxProfiles?: number | null;
76
+ /** Bytes a project's profiles may hold together; null = no limit. */
77
+ maxProfileBytes?: number | null;
78
78
  features: Record<PlanFeature, boolean>;
79
79
  public?: boolean;
80
80
  }
@@ -280,9 +280,9 @@ export interface SessionData {
280
280
  /** A CAPTCHA waiting for a person, or null. */
281
281
  attention: CaptchaAttention | null;
282
282
  workspacePath: string;
283
- contextId: string | null;
284
- /** Whether the session saves its sign-ins back to `contextId` when it ends. */
285
- contextPersist?: boolean;
283
+ profileId: string | null;
284
+ /** Whether the session saves its sign-ins back to `profileId` when it ends. */
285
+ profilePersist?: boolean;
286
286
  userMetadata: Record<string, unknown>;
287
287
  moves: number;
288
288
  /** When the last automatic checkpoint was taken (null before the first one). */
@@ -307,8 +307,8 @@ export interface SessionData {
307
307
  extensions: string[];
308
308
  /** The names of the session's env variables (values are never returned). */
309
309
  env?: string[];
310
- /** The names of the project secrets its shell exports. */
311
- secrets?: string[];
310
+ /** The names of the credentials its shell exports (a credential its profile links is listed too when it went into the shell). */
311
+ credentials?: string[];
312
312
  usage: {
313
313
  seconds: number;
314
314
  costUsd: number;
@@ -340,8 +340,8 @@ export interface CreateSessionParams {
340
340
  keepAlive?: boolean;
341
341
  viewport?: Viewport;
342
342
  userMetadata?: Record<string, unknown>;
343
- /** Start from a saved login; `persist: true` saves the browser's logins back into it at the end. */
344
- context?: {
343
+ /** Start from a profile; `persist: true` saves the browser's logins back into it at the end. */
344
+ profile?: {
345
345
  id: string;
346
346
  persist?: boolean;
347
347
  };
@@ -378,11 +378,13 @@ export interface CreateSessionParams {
378
378
  */
379
379
  env?: Record<string, string | number | boolean>;
380
380
  /**
381
- * Project secrets exported into the shell as `$NAME` (needs shell: true; the secret needs scope "shell" or "all", or
382
- * shell: true, else SecretNotAllowedError). Kept in the machine's memory only and hidden in exec, script and terminal
383
- * output. Anything that runs in the shell can read them: export only what you accept that for.
381
+ * Credentials exported into the shell (needs shell: true; the credential needs scope "shell" or "all", or shell:
382
+ * true, else CredentialNotAllowedError): a secret as `$NAME`, a password as `$NAME_USERNAME` and `$NAME_PASSWORD`
383
+ * (its 2FA code comes from `boxline-otp NAME`, the key itself never enters the machine). Kept in the machine's
384
+ * memory only and hidden in exec, script and terminal output. Anything that runs in the shell can read them: export
385
+ * only what you accept that for.
384
386
  */
385
- secrets?: string[];
387
+ credentials?: string[];
386
388
  }
387
389
  export interface UpdateSessionParams {
388
390
  keepAlive?: boolean;
@@ -437,13 +439,13 @@ export interface MoveTimings {
437
439
  }
438
440
  /**
439
441
  * Sessions with a shell, after a move: where the shell continues and which exported variables came along (the
440
- * session's env and secrets are set again as well). Running processes do not move; the ones that were stopped are listed.
442
+ * session's env and credentials are set again as well). Running processes do not move; the ones that were stopped are listed.
441
443
  */
442
444
  export interface MoveShell {
443
445
  cwd: string;
444
446
  /** Names of the variables the commands exported. */
445
447
  exported: string[];
446
- /** `command` with secret values hidden, at most 200 characters; `seconds`: how long it had run. */
448
+ /** `command` with credential values hidden, at most 200 characters; `seconds`: how long it had run. */
447
449
  stoppedProcesses: {
448
450
  pid: number;
449
451
  command: string;
@@ -488,6 +490,18 @@ export type Action = {
488
490
  text: string;
489
491
  selector?: string;
490
492
  delayMs?: number;
493
+ }
494
+ /**
495
+ * Types a credential's value without it passing through you (see Session.typeCredential): `field` is `"username"`,
496
+ * `"password"` or `"otp"` (the current 2FA code) for a password, and left out for a secret. A credential with sites
497
+ * (every password) goes only into the field `selector` names, on one of those sites.
498
+ */
499
+ | {
500
+ action: "type";
501
+ credential: string;
502
+ field?: CredentialField;
503
+ selector?: string;
504
+ allowWithExtensions?: boolean;
491
505
  } | {
492
506
  action: "press";
493
507
  key: string;
@@ -599,9 +613,13 @@ export type Action = {
599
613
  action: "step";
600
614
  instruction: string;
601
615
  variables?: Record<string, string>;
602
- /** Project secrets usable as %NAME% (scope "agent" or "all"), each on its own sites; never shown in the result. */
603
- secrets?: string[];
604
- /** Allow `secrets` and saved login details in a session with Chrome extensions (VariablesWithExtensionsError otherwise). */
616
+ /**
617
+ * Credentials usable as placeholders (scope "agent" or "all"): `%NAME%` for a secret, `%NAME.username%`,
618
+ * `%NAME.password%` and `%NAME.otp%` for a password, each on its own sites; never shown in the result. A
619
+ * credential the session's profile links is offered too.
620
+ */
621
+ credentials?: string[];
622
+ /** Allow `credentials` in a session with Chrome extensions (VariablesWithExtensionsError otherwise). */
605
623
  allowWithExtensions?: boolean;
606
624
  provider?: AgentProvider;
607
625
  model?: string;
@@ -615,6 +633,16 @@ export type Action = {
615
633
  provider?: AgentProvider;
616
634
  model?: string;
617
635
  targetId?: string;
636
+ }
637
+ /**
638
+ * Signs the browser in with a password credential (default: the one the session's profile links) in one call, see
639
+ * Session.login. It runs alone: the only action of its request.
640
+ */
641
+ | {
642
+ action: "login";
643
+ credential?: string;
644
+ url?: string;
645
+ allowWithExtensions?: boolean;
618
646
  };
619
647
  /** An action, or a plain-English step written as a bare string ("click Sign in"). */
620
648
  export type ActionItem = Action | string;
@@ -626,10 +654,18 @@ export interface ActionResult {
626
654
  /** One line saying what happened ("Dragged from (180, 200) to (400, 200) in 10 steps"); never typed text. */
627
655
  text?: string;
628
656
  error?: string;
629
- /** A stable error code when there is one (e.g. "captcha_timeout", "out_of_viewport"). */
657
+ /** A stable error code when there is one (e.g. "captcha_timeout", "out_of_viewport"; for `login`: "credential_login_failed", "credential_login_timeout", "credential_code_timeout", "credential_link_wrong_site"). */
630
658
  code?: string;
659
+ /** `login`: the agent run that signed in (also in its value when it worked). */
660
+ runId?: string;
631
661
  ms: number;
632
662
  }
663
+ /** What `Session.login` returns: the page the browser is on after signing in (no query or fragment) and the run that did it. */
664
+ export interface LoginValue {
665
+ url: string;
666
+ title: string;
667
+ runId: string;
668
+ }
633
669
  export interface GotoResult {
634
670
  url: string;
635
671
  title: string;
@@ -761,14 +797,15 @@ export interface StepOptions {
761
797
  /** Text values for %name% placeholders. */
762
798
  variables?: Record<string, string>;
763
799
  /**
764
- * Project secrets usable as %NAME% (scope "agent" or "all"), each only on its own sites and in the shell only with
765
- * shell: true. The step's result never shows their values. In a session with a saved login's details,
766
- * %login.username%, %login.password% and %login.otp% work too, on that login's site only.
800
+ * Credentials usable as placeholders (scope "agent" or "all"): `%NAME%` for a secret, `%NAME.username%`,
801
+ * `%NAME.password%` and `%NAME.otp%` for a password. Each is typed only on its own sites and, in the shell, only
802
+ * with `shell: true`. The step's result never shows their values. In a session whose profile links a password
803
+ * credential, that credential is offered too.
767
804
  */
768
- secrets?: string[];
805
+ credentials?: string[];
769
806
  /**
770
- * Allow `secrets` and saved login details in a session with Chrome extensions, which can read every typed value
771
- * (secrets: VariablesWithExtensionsError otherwise; login details are not offered). Logs a warning in the session's events.
807
+ * Allow `credentials` in a session with Chrome extensions, which can read every typed value
808
+ * (VariablesWithExtensionsError otherwise). Logs a warning in the session's events.
772
809
  */
773
810
  allowWithExtensions?: boolean;
774
811
  provider?: AgentProvider;
@@ -780,8 +817,11 @@ export interface ExecOptions {
780
817
  cwd?: string;
781
818
  /** Variables for this command only (it may set PATH, HOME and the like for itself). */
782
819
  env?: Record<string, string>;
783
- /** Project secrets as environment variables for this command only (scope "shell" or "all", or shell: true); hidden in the output. */
784
- secrets?: string[];
820
+ /**
821
+ * Credentials as environment variables for this command only (scope "shell" or "all", or shell: true): a secret as
822
+ * `$NAME`, a password as `$NAME_USERNAME` and `$NAME_PASSWORD`, and `boxline-otp NAME` prints its 2FA code. Hidden in the output.
823
+ */
824
+ credentials?: string[];
785
825
  /** Named persistent shell (default "default"); false runs in a fresh process with no kept state. */
786
826
  shell?: string | false;
787
827
  }
@@ -816,14 +856,13 @@ export interface RunScriptOptions {
816
856
  model?: string;
817
857
  };
818
858
  /**
819
- * Project secrets the script's step() calls may use as %NAME% (scope "agent" or "all"). The values never enter the
820
- * machine: the platform fills them in when the step runs. The grant is for this run only.
859
+ * Credentials the script's step() calls may use as placeholders (scope "agent" or "all"). The values never enter the
860
+ * machine: the platform fills them in when the step runs. The grant is for this run only. A credential the
861
+ * session's profile links is used only when it is listed here.
821
862
  */
822
- secrets?: string[];
823
- /** Let step() use the session's saved login details (%login.username%, %login.password%, %login.otp%). */
824
- login?: boolean;
863
+ credentials?: string[];
825
864
  /**
826
- * Allow `secrets` and `login` in a session with Chrome extensions, which can read every typed value
865
+ * Allow `credentials` in a session with Chrome extensions, which can read every typed value
827
866
  * (VariablesWithExtensionsError otherwise); a warning goes into the session's events.
828
867
  */
829
868
  allowWithExtensions?: boolean;
@@ -883,7 +922,7 @@ export interface Recording {
883
922
  }[];
884
923
  durationMs: number;
885
924
  }
886
- export interface ContextInfo {
925
+ export interface Profile {
887
926
  id: string;
888
927
  name: string;
889
928
  sizeBytes: number;
@@ -891,43 +930,22 @@ export interface ContextInfo {
891
930
  updatedAt: string;
892
931
  /** The running session using it. */
893
932
  inUseBy: string | null;
894
- /** Its login details (contexts.setLogin), never the password or the 2FA secret; null without any. */
895
- login?: ContextLogin | null;
896
- }
897
- /** What a saved login shows of its login details. */
898
- export interface ContextLogin {
899
- origin: string;
900
- username: string;
901
- hasPassword: boolean;
902
- hasTotp: boolean;
903
- updatedAt?: string;
904
- }
905
- /**
906
- * A saved login's sign-in details (plan feature `loginDetails`). Agent runs, plain-English steps and scripts' step() in
907
- * a session started with that context get %login.username%, %login.password% and %login.otp% (a TOTP code made when it
908
- * is typed), filled in only into fields whose frame is on `origin`, never into shell commands, never shown to the model.
909
- */
910
- export interface LoginDetails {
911
- /** The one site they may be typed on: "https://example.com" or "https://*.example.com" (any subdomain). */
912
- origin: string;
913
- /** At most 320 characters. */
914
- username: string;
915
- /** 1 to 1024 characters. */
916
- password: string;
917
933
  /**
918
- * The site's 2FA setup key (base32, any case, spaces allowed) or an otpauth://totp/ link from its QR code (SHA1,
919
- * SHA256 or SHA512, 6 to 8 digits, a 15 to 120 s period; defaults SHA-1, 6 digits, 30 s).
934
+ * The name of the password credential it signs in with (profiles.update with `credential`), or null. Sessions with
935
+ * the profile, and agent runs, task runs and steps in them, get it as if it were listed in their `credentials`.
920
936
  */
921
- totpSecret?: string;
937
+ credential: string | null;
922
938
  }
923
- /** contexts.updateLogin: any of the login details; what is not sent is kept. */
924
- export interface LoginDetailsUpdate {
925
- /** A new site: needs `password` too (and `totpSecret` when the login has 2FA), or the call fails with 400. */
926
- origin?: string;
927
- username?: string;
928
- password?: string;
929
- /** A new 2FA setup key or otpauth://totp/ link; null removes 2FA. */
930
- totpSecret?: string | null;
939
+ /** profiles.update: any of these (at least one). */
940
+ export interface ProfileUpdateParams {
941
+ /** 1 to 100 characters. */
942
+ name?: string;
943
+ /**
944
+ * Link the password credential this profile signs in with, so the AI can sign in again when its cookies have
945
+ * expired; null unlinks it. NotFoundError (404 `credential_not_found`) for a name the project does not have, 400 for a secret (only
946
+ * passwords sign in), FeatureNotInPlanError (402) without `loginDetails`.
947
+ */
948
+ credential?: string | null;
931
949
  }
932
950
  /** Options shared by fetch, screenshot and pdf. */
933
951
  export interface RenderOptions {
@@ -1197,15 +1215,17 @@ export interface AgentRunParams {
1197
1215
  /** Keep the run's own session after it finishes (until its expiresAt, with keepAlive on). */
1198
1216
  keepSession?: boolean;
1199
1217
  /**
1200
- * Project secrets as %NAME% placeholders, exactly like `variables`, each with the secret's own `origins` and `shell`
1201
- * rule (scope "agent" or "all"; SecretNotAllowedError for scope "shell"). An explicit variable with the same name wins.
1218
+ * Credentials as placeholders, exactly like `variables`, each with the credential's own `origins` and `shell` rule
1219
+ * (scope "agent" or "all"; CredentialNotAllowedError for scope "shell"): `%NAME%` for a secret, `%NAME.username%`,
1220
+ * `%NAME.password%` and `%NAME.otp%` for a password. An explicit variable with the same name wins. A password
1221
+ * credential linked to the session's profile is added for you.
1202
1222
  */
1203
- secrets?: string[];
1223
+ credentials?: string[];
1204
1224
  /**
1205
- * For the run's own session: a saved login to start with. With login details the run also gets %login.username%,
1206
- * %login.password% and %login.otp% on the login's site.
1225
+ * For the run's own session: a profile to start with. When it links a password credential (profiles.update), the
1226
+ * run gets that credential as if it were listed in `credentials`.
1207
1227
  */
1208
- context?: {
1228
+ profile?: {
1209
1229
  id: string;
1210
1230
  persist?: boolean;
1211
1231
  };
@@ -1291,7 +1311,8 @@ export interface AgentMessageSent {
1291
1311
  }
1292
1312
  export interface AgentStep {
1293
1313
  /** message: a message you sent (agent.sendMessage), recorded when the model received it. */
1294
- type: "text" | "tool" | "handover" | "handback" | "captcha" | "message";
1314
+ /** code: the run waits for a password's 2FA code or sign-in link (`credentials.pushCode`, or your `codeUrl`), see `state`. */
1315
+ type: "text" | "tool" | "handover" | "handback" | "captcha" | "message" | "code";
1295
1316
  at: string;
1296
1317
  /** message steps: who wrote it, its id, when it was sent (`at` is when the model got it). */
1297
1318
  from?: "user";
@@ -1309,9 +1330,14 @@ export interface AgentStep {
1309
1330
  output?: string;
1310
1331
  isError?: boolean;
1311
1332
  ms?: number;
1312
- /** captcha steps: "solving" (automatic solving), "waiting" (a person's turn), "solved" (the run goes on). */
1313
- state?: "solving" | "waiting" | "solved";
1314
- /** captcha steps: the CAPTCHA kind and the host of its page. */
1333
+ /**
1334
+ * captcha steps: "solving" (automatic solving), "waiting" (a person's turn), "solved" (the run goes on); code steps:
1335
+ * "waiting" (a wait began: push the code or link now), then "received" or "timeout". Never the code or the link.
1336
+ */
1337
+ state?: "solving" | "waiting" | "solved" | "received" | "timeout";
1338
+ /** code steps: the password credential whose code or link the run waits for. */
1339
+ credential?: string;
1340
+ /** captcha steps: the CAPTCHA kind and the host of its page; code steps: "code" or "link". */
1315
1341
  kind?: string;
1316
1342
  host?: string;
1317
1343
  /** captcha "waiting": why a person is asked. */
@@ -1436,7 +1462,7 @@ export interface TaskVariable {
1436
1462
  /**
1437
1463
  * The settings of each run's own session, as on sessions.create, checked when saved and again at each run. A custom
1438
1464
  * proxy's password is stored encrypted and never returned. `allowWithExtensions` is needed for a task with secret
1439
- * variables and extensions (VariablesWithExtensionsError otherwise).
1465
+ * variables or credentials and extensions (VariablesWithExtensionsError otherwise).
1440
1466
  */
1441
1467
  export interface TaskBrowser extends BrowserOptions {
1442
1468
  shell?: boolean;
@@ -1486,8 +1512,8 @@ export interface TaskLastRun {
1486
1512
  createdAt: string;
1487
1513
  finishedAt: string | null;
1488
1514
  }
1489
- /** A saved login (context) each run's session starts with: its id, or `{id, persist}` (persist: keep what the run changes). */
1490
- export type TaskSavedLogin = string | {
1515
+ /** A browser profile each run's session starts with: its id, or `{id, persist}` (persist: keep what the run changes). */
1516
+ export type TaskProfile = string | {
1491
1517
  id: string;
1492
1518
  persist?: boolean;
1493
1519
  };
@@ -1499,14 +1525,14 @@ export interface TaskCreateParams {
1499
1525
  /** Up to 50. */
1500
1526
  variables?: TaskVariable[];
1501
1527
  /**
1502
- * Project secrets (by name, up to 50) each run gets as %NAME%, as `secrets` on agent runs. They must exist with scope
1503
- * "agent" or "all"; a scheduled task may use them (secret variables cannot be scheduled).
1528
+ * Credentials (by name, up to 50) each run gets as placeholders, as `credentials` on agent runs. They must exist with
1529
+ * scope "agent" or "all"; a scheduled task may use them (secret variables cannot be scheduled).
1504
1530
  */
1505
- secrets?: string[];
1531
+ credentials?: string[];
1506
1532
  /** Structured output for every run (see OutputSchema). */
1507
1533
  output?: OutputSchema;
1508
1534
  browser?: TaskBrowser;
1509
- savedLogin?: TaskSavedLogin;
1535
+ profile?: TaskProfile;
1510
1536
  /** From agent.models() (default: the server's default model). */
1511
1537
  model?: {
1512
1538
  provider?: AgentProvider;
@@ -1527,10 +1553,10 @@ export interface TaskUpdateParams {
1527
1553
  instruction?: string;
1528
1554
  variables?: TaskVariable[];
1529
1555
  /** The whole new list; null or [] removes them. */
1530
- secrets?: string[] | null;
1556
+ credentials?: string[] | null;
1531
1557
  output?: OutputSchema | null;
1532
1558
  browser?: TaskBrowser | null;
1533
- savedLogin?: TaskSavedLogin | null;
1559
+ profile?: TaskProfile | null;
1534
1560
  model?: {
1535
1561
  provider?: AgentProvider;
1536
1562
  model?: string;
@@ -1549,11 +1575,11 @@ export interface Task {
1549
1575
  name: string;
1550
1576
  instruction: string;
1551
1577
  variables: TaskVariable[];
1552
- /** Names of the project secrets its runs get (never values). */
1553
- secrets: string[];
1578
+ /** Names of the credentials its runs get (never values). */
1579
+ credentials: string[];
1554
1580
  output: OutputSchema | null;
1555
1581
  browser: TaskBrowser | null;
1556
- savedLogin: {
1582
+ profile: {
1557
1583
  id: string;
1558
1584
  persist: boolean;
1559
1585
  } | null;
@@ -1619,7 +1645,7 @@ export interface TaskRun<T = unknown> {
1619
1645
  export interface TaskRunParams {
1620
1646
  /** Values by name. Secret variables must be given on every run; plain ones fall back to their defaults. */
1621
1647
  variables?: Record<string, string | number | boolean>;
1622
- /** Work in this session (its own settings apply; the task's `browser` and `savedLogin` do not). */
1648
+ /** Work in this session (its own settings apply; the task's `browser` and `profile` do not). */
1623
1649
  sessionId?: string;
1624
1650
  }
1625
1651
  export interface TaskRunListParams extends ListParams {
@@ -1716,7 +1742,7 @@ export interface Pricing {
1716
1742
  * The events an endpoint can subscribe to (`webhook.test` needs no subscription). New types may be added: an endpoint
1717
1743
  * subscribed to "*" gets them too, so a receiver should ignore types it does not know.
1718
1744
  */
1719
- export type WebhookEventType = "session.started" | "session.expiring" | "session.ended" | "agent_run.started" | "agent_run.waiting" | "agent_run.resumed" | "agent_run.finished" | "captcha.waiting" | "captcha.solved" | "captcha.failed" | "crawl.finished" | "task_run.started" | "task_run.finished" | "task.schedule_paused" | "usage.limit_reached" | "api_key.created" | "api_key.revoked" | "secret.changed" | "webhook.changed" | "webhook.disabled" | "extension.uploaded" | "extension.deleted";
1745
+ export type WebhookEventType = "session.started" | "session.expiring" | "session.ended" | "agent_run.started" | "agent_run.waiting" | "agent_run.resumed" | "agent_run.finished" | "captcha.waiting" | "captcha.solved" | "captcha.failed" | "crawl.finished" | "task_run.started" | "task_run.finished" | "task.schedule_paused" | "usage.limit_reached" | "api_key.created" | "api_key.revoked" | "credential.code_needed" | "credential.changed" | "webhook.changed" | "webhook.disabled" | "extension.uploaded" | "extension.deleted";
1720
1746
  /** What an endpoint subscribes to: event types, or "*" for all of them (those added later too). */
1721
1747
  export type WebhookSubscription = WebhookEventType | "*";
1722
1748
  /** One entry of bx.webhooks.eventTypes(): a type, its group (for pickers) and what it says. */
@@ -1995,13 +2021,22 @@ export interface WebhookApiKeyData {
1995
2021
  name: string;
1996
2022
  by: WebhookActor;
1997
2023
  }
1998
- export interface WebhookSecretChangedData {
1999
- /** The secret's name, or for a login the context's id. */
2024
+ export interface WebhookCredentialCodeNeededData {
2025
+ /** The password credential whose code or sign-in link is awaited. */
2026
+ credential: string;
2027
+ /** What the site sends: a 2FA code or a sign-in link. Forward it now with `credentials.pushCode`. */
2028
+ type: "code" | "link";
2029
+ sessionId: string;
2030
+ /** The agent run that waits; null for an action or `boxline-otp`. */
2031
+ runId: string | null;
2032
+ }
2033
+ export interface WebhookCredentialChangedData {
2034
+ /** The credential's name. */
2000
2035
  name: string;
2001
2036
  action: "created" | "updated" | "deleted";
2002
- kind: "secret" | "login";
2037
+ type: CredentialType;
2003
2038
  by: WebhookActor;
2004
- /** Field names an update changed ("value", "origins", …). */
2039
+ /** Field names an update changed ("password", "origins", …; "profiles" when it was linked to or unlinked from a profile). */
2005
2040
  changed?: string[];
2006
2041
  }
2007
2042
  export interface WebhookChangedData {
@@ -2048,7 +2083,8 @@ export interface WebhookEventDataMap {
2048
2083
  "usage.limit_reached": WebhookUsageLimitData;
2049
2084
  "api_key.created": WebhookApiKeyData;
2050
2085
  "api_key.revoked": WebhookApiKeyData;
2051
- "secret.changed": WebhookSecretChangedData;
2086
+ "credential.code_needed": WebhookCredentialCodeNeededData;
2087
+ "credential.changed": WebhookCredentialChangedData;
2052
2088
  "webhook.changed": WebhookChangedData;
2053
2089
  "webhook.disabled": WebhookDisabledData;
2054
2090
  "extension.uploaded": WebhookExtensionData;
@@ -2064,71 +2100,197 @@ export type WebhookEventPayload = {
2064
2100
  type: K;
2065
2101
  };
2066
2102
  }[keyof WebhookEventDataMap];
2103
+ /** A credential holds a website password (with an optional 2FA key) or a secret (one value). */
2104
+ export type CredentialType = "password" | "secret";
2105
+ /**
2106
+ * Where a credential may be used: "agent" (default): only the AI, as placeholders in agent runs, plain-English steps,
2107
+ * scripts' step() and the type action; "shell": only as environment variables in session shells and commands; "all": both.
2108
+ */
2109
+ export type CredentialScope = "agent" | "shell" | "all";
2110
+ /**
2111
+ * What `Session.typeCredential` types from a password credential: its user name, its password or its current 2FA code
2112
+ * (with a `codeSource` of "push" or "url" it waits for a fresh one, up to `codeTimeoutSeconds`).
2113
+ */
2114
+ export type CredentialField = "username" | "password" | "otp";
2067
2115
  /**
2068
- * Where a project secret may be used: "agent" (default): only the AI, as %NAME% in agent runs, plain-English steps and
2069
- * scripts' step(); "shell": only as an environment variable in session shells and commands; "all": both.
2116
+ * Where a password's 2FA codes come from: "totp" (an authenticator key, `totpSecret`), "push" (your system sends each
2117
+ * code or sign-in link the site emails or texts: `credentials.pushCode`) or "url" (the platform asks your endpoint
2118
+ * `codeUrl`, signed like a webhook). A password without one has no 2FA (`codeSource: null`).
2070
2119
  */
2071
- export type SecretScope = "agent" | "shell" | "all";
2072
- /** A project secret. Its value is never returned. */
2073
- export interface Secret {
2120
+ export type CredentialCodeSource = "totp" | "push" | "url";
2121
+ interface CredentialBase {
2122
+ /** Also its placeholder (`%NAME%`, `%NAME.password%`) and its shell variable (`$NAME`, `$NAME_PASSWORD`). */
2074
2123
  name: string;
2075
2124
  description: string | null;
2076
- /** Sites where the AI may type it (null = any site). */
2077
- origins: string[] | null;
2078
2125
  /** The AI may use it in bash commands; this also allows exporting it into shells. */
2079
2126
  shell: boolean;
2080
- scope: SecretScope;
2081
- /** "••••1a2b": the last 4 characters of values of 24 characters or more; null for shorter values and secrets with origins. */
2082
- preview: string | null;
2127
+ scope: CredentialScope;
2083
2128
  createdAt: string;
2084
2129
  updatedAt: string;
2085
2130
  lastUsedAt: string | null;
2086
2131
  }
2087
- export interface SecretCreateParams {
2132
+ /** A website password. Neither the password nor the 2FA key is ever returned. */
2133
+ export interface PasswordCredential extends CredentialBase {
2134
+ type: "password";
2135
+ /** The sites where the AI may type it (1 to 20). */
2136
+ origins: string[];
2137
+ username: string;
2138
+ /** It has a 2FA key (`codeSource` is "totp"): `%NAME.otp%` and `boxline-otp NAME` give the current code. */
2139
+ hasTotp: boolean;
2140
+ /** Where its 2FA codes come from; null: no 2FA. */
2141
+ codeSource: CredentialCodeSource | null;
2142
+ /** The endpoint the platform asks for codes (`codeSource` "url"); null otherwise. Its signing secret is never shown again. */
2143
+ codeUrl: string | null;
2144
+ /** How long a wait for a pushed or asked code or link lasts (5 to 900 s, default 300). */
2145
+ codeTimeoutSeconds: number;
2146
+ }
2147
+ /** A secret (an API key, a token). Its value is never returned. */
2148
+ export interface SecretCredential extends CredentialBase {
2149
+ type: "secret";
2150
+ /** Sites where the AI may type it (null = any site). */
2151
+ origins: string[] | null;
2152
+ /** "••••1a2b": the last 4 characters of values of 24 characters or more; null for shorter values and secrets with origins. */
2153
+ preview: string | null;
2154
+ }
2155
+ /** A credential without its values: `switch (c.type)` tells the two apart. */
2156
+ export type Credential = PasswordCredential | SecretCredential;
2157
+ /**
2158
+ * A credential as `credentials.create` and `credentials.update` return it: when `codeUrl` was set or changed it also
2159
+ * has `codeUrlSecret` (`whsec_…`), the key that signs the platform's requests to `codeUrl`, shown this once (a new one
2160
+ * any time with `credentials.rotateCodeUrlSecret`).
2161
+ */
2162
+ export type CredentialWritten<C extends Credential = Credential> = C & {
2163
+ codeUrlSecret?: string;
2164
+ };
2165
+ interface CredentialCreateBase {
2088
2166
  /**
2089
2167
  * An environment variable name in capitals, [A-Z_][A-Z0-9_]*, at most 64 characters; not one the platform or bash
2090
- * sets (PATH, HOME, PWD, IFS, …, or starting with BOXLINE_, SANDBOXD_ or BASH_). One per project.
2168
+ * sets (PATH, HOME, PWD, IFS, …, or starting with BOXLINE_, SANDBOXD_ or BASH_). One per project, whatever the type.
2091
2169
  */
2092
2170
  name: string;
2093
- /** 1 to 8000 characters, no NUL. Sealed when stored and never returned. */
2094
- value: string;
2095
2171
  /** Up to 500 characters. */
2096
2172
  description?: string;
2097
- /** Sites where the AI may type it, e.g. ["https://example.com"] (recommended for passwords); 1 to 20. */
2098
- origins?: string[];
2099
2173
  /** Let the AI use it in bash commands (and so export it into shells). Default false. */
2100
2174
  shell?: boolean;
2101
2175
  /** Default "agent". */
2102
- scope?: SecretScope;
2176
+ scope?: CredentialScope;
2177
+ }
2178
+ /** A website password; needs the plan's `loginDetails`. */
2179
+ export interface PasswordCredentialCreateParams extends CredentialCreateBase {
2180
+ type: "password";
2181
+ /** The sites where the AI may type it, `"https://shop.example.com"` or `"https://*.example.com"` (any subdomain); 1 to 20. */
2182
+ origins: string[];
2183
+ /** 1 to 320 characters. */
2184
+ username: string;
2185
+ /** 1 to 1024 characters. Sealed when stored and never returned. */
2186
+ password: string;
2187
+ /**
2188
+ * Where its 2FA codes come from: "totp" (with `totpSecret`; `totpSecret` alone means "totp"), "push" (send each code
2189
+ * or link with `credentials.pushCode`), "url" (with `codeUrl`), or left out / null for no 2FA.
2190
+ */
2191
+ codeSource?: CredentialCodeSource | null;
2192
+ /**
2193
+ * The site's 2FA setup key (base32, any case, spaces allowed) or an otpauth://totp/ link from its QR code (SHA1,
2194
+ * SHA256 or SHA512, 6 to 8 digits, a 15 to 120 s period; defaults SHA-1, 6 digits, 30 s). Only with "totp".
2195
+ */
2196
+ totpSecret?: string;
2197
+ /**
2198
+ * `codeSource` "url" (required then): a public HTTPS endpoint (never a private or internal address) the platform
2199
+ * asks with a signed POST every 5 s while a run waits for a code; the answer has `codeUrlSecret` once.
2200
+ */
2201
+ codeUrl?: string;
2202
+ /** How long a "push" or "url" wait lasts: 5 to 900 seconds, default 300. */
2203
+ codeTimeoutSeconds?: number;
2103
2204
  }
2104
- /** Any of these; `description: null` clears it, `origins: null` allows any site. Changes apply to new uses. */
2105
- export interface SecretUpdateParams {
2106
- value?: string;
2205
+ /** A secret: one value. */
2206
+ export interface SecretCredentialCreateParams extends CredentialCreateBase {
2207
+ type: "secret";
2208
+ /** 1 to 8000 characters, no NUL. Sealed when stored and never returned. */
2209
+ value: string;
2210
+ /** Sites where the AI may type it, e.g. ["https://example.com"] (1 to 20); without, any site. */
2211
+ origins?: string[];
2212
+ }
2213
+ export type CredentialCreateParams = PasswordCredentialCreateParams | SecretCredentialCreateParams;
2214
+ /**
2215
+ * Changes to a password; what is not sent is kept. A change of `origins` that adds a site, or of `scope`/`shell` that
2216
+ * makes an AI-only password readable by shells, needs `password` again in the same call (and `totpSecret`, a new one or
2217
+ * null, when it has 2FA); so does a change of `codeSource` (removing 2FA included) or `codeUrl`.
2218
+ */
2219
+ export interface PasswordCredentialUpdateParams {
2220
+ origins?: string[];
2221
+ username?: string;
2222
+ password?: string;
2223
+ /** Where the codes come from; null removes 2FA. Needs `password` again. */
2224
+ codeSource?: CredentialCodeSource | null;
2225
+ /** A new 2FA setup key or otpauth://totp/ link; null removes 2FA. */
2226
+ totpSecret?: string | null;
2227
+ /** The endpoint asked for codes ("url"). Needs `password` again; the answer has a new `codeUrlSecret`. */
2228
+ codeUrl?: string;
2229
+ /** 5 to 900 seconds. */
2230
+ codeTimeoutSeconds?: number;
2231
+ /** null clears it. */
2107
2232
  description?: string | null;
2108
- origins?: string[] | null;
2109
2233
  shell?: boolean;
2110
- scope?: SecretScope;
2234
+ scope?: CredentialScope;
2235
+ value?: never;
2111
2236
  }
2112
- /** One entry of the secrets audit log: a change, or a use (once per session, command, agent run, step session or script). Never values. */
2113
- export interface SecretAuditEntry {
2237
+ /**
2238
+ * Changes to a secret; what is not sent is kept. A change of `origins` that adds a site, or null, or of `scope`/`shell`
2239
+ * that makes an AI-only secret readable by shells, needs `value` again.
2240
+ */
2241
+ export interface SecretCredentialUpdateParams {
2242
+ value?: string;
2243
+ /** null allows any site. */
2244
+ origins?: string[] | null;
2245
+ description?: string | null;
2246
+ shell?: boolean;
2247
+ scope?: CredentialScope;
2248
+ username?: never;
2249
+ password?: never;
2250
+ codeSource?: never;
2251
+ codeUrl?: never;
2252
+ codeTimeoutSeconds?: never;
2253
+ totpSecret?: never;
2254
+ }
2255
+ /** What credentials.update takes: the fields of a password or of a secret (the type cannot change). Changes apply to new uses. */
2256
+ export type CredentialUpdateParams = PasswordCredentialUpdateParams | SecretCredentialUpdateParams;
2257
+ /**
2258
+ * One entry of the credentials audit log: a change, or a use (once per session, command, agent run, step session,
2259
+ * script, task run, type action or boxline-otp session). Never values.
2260
+ */
2261
+ export interface CredentialAuditEntry {
2114
2262
  at: string;
2115
- action: "create" | "update" | "delete" | "use";
2116
- /** "login": a saved login's details (`name` is the context id). */
2117
- kind: "secret" | "login";
2263
+ /** "code": a pushed 2FA code or sign-in link (`details.kind`), never its value. */
2264
+ action: "create" | "update" | "delete" | "use" | "code";
2265
+ type: CredentialType;
2118
2266
  name: string;
2119
2267
  /** Who changed it: "user:<email>", "key:<api key id>", or "support" (Boxline support acting as a user). */
2120
2268
  actor: string | null;
2121
- /** What used it. */
2269
+ /** What used it: `id` is the session, or for `agent_run` the run and for `task_run` the task run. Null for changes. */
2122
2270
  usedBy: {
2123
- type: "session" | "exec" | "agent_run" | "step" | "script" | "task_run";
2271
+ type: "session" | "exec" | "agent_run" | "step" | "script" | "task_run" | "action" | "otp";
2124
2272
  id: string;
2125
2273
  } | null;
2126
2274
  details: Record<string, unknown>;
2127
2275
  }
2128
- export interface SecretAuditParams extends ListParams {
2129
- /** One secret (or a context id, for login details). */
2276
+ export interface CredentialAuditParams extends ListParams {
2277
+ /** One credential. */
2130
2278
  name?: string;
2131
2279
  }
2280
+ /** What `credentials.pushCode` sends: a 2FA code (1 to 64 characters, no spaces) or a sign-in link on one of the credential's sites. */
2281
+ export type CredentialCodePush = {
2282
+ code: string;
2283
+ link?: never;
2284
+ } | {
2285
+ link: string;
2286
+ code?: never;
2287
+ };
2288
+ /** What `credentials.pushCode` returns: the code or link is kept for a wait in progress (used once, at most 10 minutes). */
2289
+ export interface CredentialCodeAccepted {
2290
+ accepted: true;
2291
+ kind: "code" | "link";
2292
+ expiresAt: string;
2293
+ }
2132
2294
  /** An uploaded Chrome extension (Manifest V3). */
2133
2295
  export interface ExtensionInfo {
2134
2296
  id: string;
@@ -2145,3 +2307,4 @@ export interface ExtensionInfo {
2145
2307
  sha256: string;
2146
2308
  createdAt: string;
2147
2309
  }
2310
+ export {};