@b3os/sdk 0.2.0 → 0.2.2

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 (152) hide show
  1. package/dist/cjs/core/sse.d.ts +2 -0
  2. package/dist/cjs/core/sse.js +17 -5
  3. package/dist/cjs/core/sse.js.map +1 -1
  4. package/dist/cjs/core/util.d.ts +1 -1
  5. package/dist/cjs/core/util.js +1 -1
  6. package/dist/cjs/generated/client.d.ts +13 -0
  7. package/dist/cjs/generated/client.js +25 -0
  8. package/dist/cjs/generated/client.js.map +1 -1
  9. package/dist/cjs/generated/errors.d.ts +1 -1
  10. package/dist/cjs/generated/errors.js +95 -0
  11. package/dist/cjs/generated/errors.js.map +1 -1
  12. package/dist/cjs/generated/ids.d.ts +61 -0
  13. package/dist/cjs/generated/ids.js +15 -0
  14. package/dist/cjs/generated/ids.js.map +1 -1
  15. package/dist/cjs/generated/jobs.js +4 -0
  16. package/dist/cjs/generated/jobs.js.map +1 -1
  17. package/dist/cjs/generated/ns/actions.d.ts +303 -4
  18. package/dist/cjs/generated/ns/actions.js +446 -4
  19. package/dist/cjs/generated/ns/actions.js.map +1 -1
  20. package/dist/cjs/generated/ns/agents.d.ts +229 -0
  21. package/dist/cjs/generated/ns/agents.js +402 -0
  22. package/dist/cjs/generated/ns/agents.js.map +1 -0
  23. package/dist/cjs/generated/ns/images.d.ts +81 -0
  24. package/dist/cjs/generated/ns/images.js +122 -0
  25. package/dist/cjs/generated/ns/images.js.map +1 -0
  26. package/dist/cjs/generated/ns/infer.d.ts +71 -3
  27. package/dist/cjs/generated/ns/infer.js +98 -3
  28. package/dist/cjs/generated/ns/infer.js.map +1 -1
  29. package/dist/cjs/generated/ns/keys.d.ts +3 -1
  30. package/dist/cjs/generated/ns/keys.js +3 -1
  31. package/dist/cjs/generated/ns/keys.js.map +1 -1
  32. package/dist/cjs/generated/ns/listeners.d.ts +159 -0
  33. package/dist/cjs/generated/ns/listeners.js +264 -0
  34. package/dist/cjs/generated/ns/listeners.js.map +1 -0
  35. package/dist/cjs/generated/ns/orgs.d.ts +10 -0
  36. package/dist/cjs/generated/ns/orgs.js +26 -1
  37. package/dist/cjs/generated/ns/orgs.js.map +1 -1
  38. package/dist/cjs/generated/ns/projects.d.ts +32 -0
  39. package/dist/cjs/generated/ns/projects.js +66 -0
  40. package/dist/cjs/generated/ns/projects.js.map +1 -1
  41. package/dist/cjs/generated/ns/render.d.ts +192 -21
  42. package/dist/cjs/generated/ns/render.js +267 -24
  43. package/dist/cjs/generated/ns/render.js.map +1 -1
  44. package/dist/cjs/generated/ns/requests.d.ts +3 -1
  45. package/dist/cjs/generated/ns/requests.js +3 -1
  46. package/dist/cjs/generated/ns/requests.js.map +1 -1
  47. package/dist/cjs/generated/ns/routines.d.ts +11 -4
  48. package/dist/cjs/generated/ns/routines.js +11 -4
  49. package/dist/cjs/generated/ns/routines.js.map +1 -1
  50. package/dist/cjs/generated/ns/sandboxes.d.ts +292 -7
  51. package/dist/cjs/generated/ns/sandboxes.js +444 -6
  52. package/dist/cjs/generated/ns/sandboxes.js.map +1 -1
  53. package/dist/cjs/generated/ns/usage.d.ts +1 -1
  54. package/dist/cjs/generated/ns/usage.js +1 -1
  55. package/dist/cjs/generated/ns/vision.d.ts +59 -17
  56. package/dist/cjs/generated/ns/vision.js +59 -21
  57. package/dist/cjs/generated/ns/vision.js.map +1 -1
  58. package/dist/cjs/generated/types.d.ts +2787 -85
  59. package/dist/cjs/helpers/sandboxes.d.ts +46 -3
  60. package/dist/cjs/helpers/sandboxes.js +127 -14
  61. package/dist/cjs/helpers/sandboxes.js.map +1 -1
  62. package/dist/cjs/index.d.ts +1 -1
  63. package/dist/cjs/index.js +2 -1
  64. package/dist/cjs/index.js.map +1 -1
  65. package/dist/esm/core/sse.d.ts +2 -0
  66. package/dist/esm/core/sse.js +17 -5
  67. package/dist/esm/core/sse.js.map +1 -1
  68. package/dist/esm/core/util.d.ts +1 -1
  69. package/dist/esm/core/util.js +1 -1
  70. package/dist/esm/generated/client.d.ts +13 -0
  71. package/dist/esm/generated/client.js +25 -0
  72. package/dist/esm/generated/client.js.map +1 -1
  73. package/dist/esm/generated/errors.d.ts +1 -1
  74. package/dist/esm/generated/errors.js +95 -0
  75. package/dist/esm/generated/errors.js.map +1 -1
  76. package/dist/esm/generated/ids.d.ts +61 -0
  77. package/dist/esm/generated/ids.js +15 -0
  78. package/dist/esm/generated/ids.js.map +1 -1
  79. package/dist/esm/generated/jobs.js +4 -0
  80. package/dist/esm/generated/jobs.js.map +1 -1
  81. package/dist/esm/generated/ns/actions.d.ts +303 -4
  82. package/dist/esm/generated/ns/actions.js +446 -4
  83. package/dist/esm/generated/ns/actions.js.map +1 -1
  84. package/dist/esm/generated/ns/agents.d.ts +229 -0
  85. package/dist/esm/generated/ns/agents.js +398 -0
  86. package/dist/esm/generated/ns/agents.js.map +1 -0
  87. package/dist/esm/generated/ns/images.d.ts +81 -0
  88. package/dist/esm/generated/ns/images.js +118 -0
  89. package/dist/esm/generated/ns/images.js.map +1 -0
  90. package/dist/esm/generated/ns/infer.d.ts +71 -3
  91. package/dist/esm/generated/ns/infer.js +98 -3
  92. package/dist/esm/generated/ns/infer.js.map +1 -1
  93. package/dist/esm/generated/ns/keys.d.ts +3 -1
  94. package/dist/esm/generated/ns/keys.js +3 -1
  95. package/dist/esm/generated/ns/keys.js.map +1 -1
  96. package/dist/esm/generated/ns/listeners.d.ts +159 -0
  97. package/dist/esm/generated/ns/listeners.js +260 -0
  98. package/dist/esm/generated/ns/listeners.js.map +1 -0
  99. package/dist/esm/generated/ns/orgs.d.ts +10 -0
  100. package/dist/esm/generated/ns/orgs.js +26 -1
  101. package/dist/esm/generated/ns/orgs.js.map +1 -1
  102. package/dist/esm/generated/ns/projects.d.ts +32 -0
  103. package/dist/esm/generated/ns/projects.js +66 -0
  104. package/dist/esm/generated/ns/projects.js.map +1 -1
  105. package/dist/esm/generated/ns/render.d.ts +192 -21
  106. package/dist/esm/generated/ns/render.js +267 -24
  107. package/dist/esm/generated/ns/render.js.map +1 -1
  108. package/dist/esm/generated/ns/requests.d.ts +3 -1
  109. package/dist/esm/generated/ns/requests.js +3 -1
  110. package/dist/esm/generated/ns/requests.js.map +1 -1
  111. package/dist/esm/generated/ns/routines.d.ts +11 -4
  112. package/dist/esm/generated/ns/routines.js +11 -4
  113. package/dist/esm/generated/ns/routines.js.map +1 -1
  114. package/dist/esm/generated/ns/sandboxes.d.ts +292 -7
  115. package/dist/esm/generated/ns/sandboxes.js +444 -6
  116. package/dist/esm/generated/ns/sandboxes.js.map +1 -1
  117. package/dist/esm/generated/ns/usage.d.ts +1 -1
  118. package/dist/esm/generated/ns/usage.js +1 -1
  119. package/dist/esm/generated/ns/vision.d.ts +59 -17
  120. package/dist/esm/generated/ns/vision.js +59 -21
  121. package/dist/esm/generated/ns/vision.js.map +1 -1
  122. package/dist/esm/generated/types.d.ts +2787 -85
  123. package/dist/esm/helpers/sandboxes.d.ts +46 -3
  124. package/dist/esm/helpers/sandboxes.js +126 -13
  125. package/dist/esm/helpers/sandboxes.js.map +1 -1
  126. package/dist/esm/index.d.ts +1 -1
  127. package/dist/esm/index.js +1 -1
  128. package/dist/esm/index.js.map +1 -1
  129. package/package.json +1 -1
  130. package/src/core/sse.ts +17 -5
  131. package/src/core/util.ts +1 -1
  132. package/src/generated/client.ts +28 -0
  133. package/src/generated/errors.ts +190 -0
  134. package/src/generated/ids.ts +15 -0
  135. package/src/generated/jobs.ts +4 -0
  136. package/src/generated/ns/actions.ts +483 -4
  137. package/src/generated/ns/agents.ts +461 -0
  138. package/src/generated/ns/images.ts +128 -0
  139. package/src/generated/ns/infer.ts +100 -3
  140. package/src/generated/ns/keys.ts +3 -1
  141. package/src/generated/ns/listeners.ts +296 -0
  142. package/src/generated/ns/orgs.ts +27 -1
  143. package/src/generated/ns/projects.ts +74 -0
  144. package/src/generated/ns/render.ts +277 -24
  145. package/src/generated/ns/requests.ts +3 -1
  146. package/src/generated/ns/routines.ts +11 -4
  147. package/src/generated/ns/sandboxes.ts +492 -7
  148. package/src/generated/ns/usage.ts +1 -1
  149. package/src/generated/ns/vision.ts +59 -21
  150. package/src/generated/types.ts +3511 -575
  151. package/src/helpers/sandboxes.ts +167 -14
  152. package/src/index.ts +1 -0
@@ -95,7 +95,6 @@ const getExtractOp: Op = {
95
95
  path: "/v1/vision/extracts/{job_id}",
96
96
  params: ["job_id"],
97
97
  timeoutMs: 10000,
98
- stretch: true,
99
98
  scope: "vision:read",
100
99
  };
101
100
  const cancelExtractOp: Op = {
@@ -104,7 +103,6 @@ const cancelExtractOp: Op = {
104
103
  path: "/v1/vision/extracts/{job_id}/cancel",
105
104
  params: ["job_id"],
106
105
  timeoutMs: 10000,
107
- stretch: true,
108
106
  scope: "vision:run",
109
107
  };
110
108
  const extractEventsOp: Op = {
@@ -114,7 +112,6 @@ const extractEventsOp: Op = {
114
112
  params: ["job_id"],
115
113
  stream: "sse",
116
114
  timeoutMs: 3600000,
117
- stretch: true,
118
115
  scope: "vision:read",
119
116
  };
120
117
  const mapOp: Op = {
@@ -322,7 +319,6 @@ const createExtractOp: Op = {
322
319
  idem: true,
323
320
  stream: "sse",
324
321
  timeoutMs: 3600000,
325
- stretch: true,
326
322
  scope: "vision:run",
327
323
  job: { get: getExtractOp, events: extractEventsOp, cancel: cancelExtractOp },
328
324
  };
@@ -390,7 +386,9 @@ export class VisionAPI extends Namespace {
390
386
  *
391
387
  * Starts a job that scrapes up to 1,000 URLs with the same options. Each delivered page bills one
392
388
  * `vision.page`, except a wall, which is free and carries only its state, status and final URL
393
- * (`content_withheld`) unless the page options set `walls: "bill"`, as for a single scrape (visionScrape).
389
+ * (`content_withheld`) unless the page options set `walls: "bill"`, as for a single scrape (visionScrape). A
390
+ * URL that serves a PDF is read as a single scrape reads it and bills one `vision.page` per PDF page read; a
391
+ * PDF that cannot be opened fails its page with `pdf_unreadable` or `pdf_encrypted`.
394
392
  * Results are listed with `GET /v1/vision/batches/{batch_id}/pages`; `?wait=`, the events stream and
395
393
  * `webhook` report progress.
396
394
  *
@@ -480,7 +478,9 @@ export class VisionAPI extends Namespace {
480
478
  * sitemap discovery starts from `/sitemap.xml`. One crawl runs at a time per organization.
481
479
  * Each delivered page bills one `vision.page`, except a wall, which is free and carries only its state, status
482
480
  * and final URL (`content_withheld`; its links are not followed) unless the page options set
483
- * `walls: "bill"`, as for a single scrape (visionScrape).
481
+ * `walls: "bill"`, as for a single scrape (visionScrape). Links to PDFs (paths that end in `.pdf`) are
482
+ * followed unless the page options set `pdf.mode: "off"`: each PDF is one page of `limit` and bills one
483
+ * `vision.page` per PDF page read. A PDF's links are not followed.
484
484
  *
485
485
  * `POST /v1/vision/crawls` · scope `vision:run` · served by the node
486
486
  */
@@ -549,13 +549,32 @@ export class VisionAPI extends Namespace {
549
549
  /**
550
550
  * Extract structured data
551
551
  *
552
- * Starts a job that scrapes up to 10 URLs and asks the node's model to fill your JSON Schema from their
553
- * content (with `prompt` as guidance). The result is validated against the schema; an invalid result after
554
- * retries fails the job with `extraction_failed`. Bills `vision.page` per page plus the model's tokens.
552
+ * Starts a job that scrapes up to 10 URLs (PDFs included) and has the node's model fill your JSON Schema from
553
+ * their Markdown, with `prompt` as guidance. With `prompt` alone the model answers one JSON object, which is
554
+ * not validated. At least one of `schema` and `prompt` is required.
555
+ *
556
+ * The schema is checked when the job is created: one that does not compile, uses a remote `$ref`, is larger
557
+ * than 64 KiB or nests deeper than 32 levels answers 400 with a pointer under `/schema`, before anything runs
558
+ * or bills. `scrape` takes the page options of a batch, except that the only format is `markdown`.
559
+ *
560
+ * The pages go to the model together in one call when they fit its context window, else one call per page
561
+ * (or per piece of a long page) whose answers are merged: objects key by key, arrays concatenated without
562
+ * duplicates, and for a single value the first page's, with a warning when another page says otherwise. The
563
+ * model may answer null where the pages do not state a value. The answer is then validated against your
564
+ * schema: a required field no page states fails the job with `extract_fields_missing` (one `errors[]` item per
565
+ * pointer, the rest of the object in `partial_data`), and an answer that does not match is retried once with
566
+ * the errors, then fails with `extraction_failed` (`reason: invalid_answer`). URLs that fail to scrape are
567
+ * listed in `result.pages` and the job goes on with the rest; when every URL fails, the job fails with
568
+ * `extraction_failed` (`reason: no_pages`). `result.field_sources` names the pages each top-level field came
569
+ * from. The data is the model's reading of the pages, so check the values that matter.
570
+ *
571
+ * Needs `infer:run` as well as `vision:run`: the model is called as you, through
572
+ * `POST /v1/infer/chat/completions`, and a node with no model answers 503 `product_unavailable`
573
+ * (`reason: model`). Bills `vision.page` per page read (a PDF one per page read) and the model's tokens
574
+ * (`infer.input_tokens`, `infer.output_tokens`). A job that fails or is canceled after it read pages or called
575
+ * the model keeps those billed, `extract_fields_missing` included.
555
576
  *
556
577
  * `POST /v1/vision/extracts` · scope `vision:run` · served by the node
557
- *
558
- * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
559
578
  */
560
579
  createExtract(body: T.ExtractCreateRequest, options?: RequestOptions): JobPromise<T.ExtractJob, T.JobEvent> {
561
580
  return this._client._job<T.ExtractJob, T.JobEvent>(createExtractOp, { body }, options);
@@ -567,8 +586,6 @@ export class VisionAPI extends Namespace {
567
586
  * Returns the extraction job; `result.data` holds the extracted JSON once it succeeded.
568
587
  *
569
588
  * `GET /v1/vision/extracts/{job_id}` · scope `vision:read` · served by the node
570
- *
571
- * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
572
589
  */
573
590
  getExtract(jobId: string, options?: RequestOptions): APIPromise<T.ExtractJob> {
574
591
  return this._client._call<T.ExtractJob>(getExtractOp, { path: [jobId] }, options);
@@ -580,8 +597,6 @@ export class VisionAPI extends Namespace {
580
597
  * Stops the extraction. Pages already scraped and tokens already used stay billed.
581
598
  *
582
599
  * `POST /v1/vision/extracts/{job_id}/cancel` · scope `vision:run` · served by the node
583
- *
584
- * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
585
600
  */
586
601
  cancelExtract(jobId: string, options?: RequestOptions): APIPromise<T.ExtractJob> {
587
602
  return this._client._call<T.ExtractJob>(cancelExtractOp, { path: [jobId] }, options);
@@ -593,8 +608,6 @@ export class VisionAPI extends Namespace {
593
608
  * Server-sent lifecycle events for the extraction job. Ends after the terminal event.
594
609
  *
595
610
  * `GET /v1/vision/extracts/{job_id}/events` · scope `vision:read` · served by the node
596
- *
597
- * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
598
611
  */
599
612
  extractEvents(jobId: string, options?: StreamOptions): EventStream<T.JobEvent> {
600
613
  return this._client._stream<T.JobEvent>(extractEventsOp, { path: [jobId] }, options, {
@@ -773,6 +786,17 @@ export class VisionAPI extends Namespace {
773
786
  * Synchronous: the response arrives when the page is done, within `timeout_ms` (at most 60 seconds). For
774
787
  * many pages use a batch scrape or a crawl.
775
788
  *
789
+ * PDFs: a URL that serves a PDF (an `application/pdf` type, or an octet-stream or untyped body that starts
790
+ * with `%PDF-`) is read from its text layer by the HTTP fetch tier, never by a browser, and returns Markdown:
791
+ * text in reading order, headings, lists, tables where the columns are clear, and the marker
792
+ * `<!-- page N -->` between pages (`pdf.page_markers`). `pdf` in the result carries the page counts, the
793
+ * document's own metadata and `truncated` when a cap stopped the read (`pdf.max_pages`, the node's
794
+ * `vision.pdf.pages_max`, about 2 million characters, or the time left). A PDF bills one `vision.page` per page
795
+ * read, not one per file, and is never served from the cache (`cache.state: bypass`). Scanned pages have no
796
+ * text layer and give a warning (OCR is not available yet). A PDF that cannot be opened answers `422
797
+ * pdf_unreadable` or `422 pdf_encrypted` and bills nothing; `pdf.mode: "off"` answers `422
798
+ * content_type_unsupported` for a PDF, as before PDFs were read.
799
+ *
776
800
  * Billing: one `vision.page` for a page that is returned, whichever tier served it. A free scrape never
777
801
  * carries page content. A scrape that returns no page (an error answer: upstream error, timeout, blocked
778
802
  * target, egress denial, extraction failure, a cache-only miss) bills nothing and does not count against the
@@ -792,6 +816,18 @@ export class VisionAPI extends Namespace {
792
816
  * A browser that goes away during the render (the node's Chrome launcher stopped or restarted) answers `503
793
817
  * product_unavailable` with `Retry-After`: retry, the node reconnects to the launcher by itself.
794
818
  *
819
+ * Where the request leaves from (`proxy`): the node's own address by default. Your own `http://` proxy, with
820
+ * its username and password in a `basic` vault connection (`proxy.connection`, which needs `vault:run`), on
821
+ * the fetch tier and the browser tier alike. With `auto`, vision asks once more from a residential address for
822
+ * a page the node's address got as a wall (`page_state` `blocked` or `captcha`), which gets around the site's
823
+ * IP-based block; where residential reads are off, `auto` is exactly `none`. `residential` reads the page from
824
+ * a residential address, every request of the scrape. A residential read takes public pages only (no profile,
825
+ * credential header or actions), always follows robots.txt and Content Signals, skips sites on the opt-out
826
+ * list and some categories, keeps one address per organization and host, and never retries a 429 or 503. A page read through a proxy is never read from or stored in the cache. `egress` says which exit served
827
+ * the page, `options` and `X-B3OS-Options` which values applied. A page bills one `vision.page` whichever
828
+ * address it was read from; bytes are never billed. The bytes of residential reads (walls and robots.txt
829
+ * included) count against the monthly safety limit `vision.proxy.bytes.monthly`. Batches, crawls, sessions and the Firecrawl surface leave from the node's address.
830
+ *
795
831
  * `POST /v1/vision/scrape` · scope `vision:run` · served by the node
796
832
  */
797
833
  scrape(body: T.ScrapeRequest, options?: RequestOptions): APIPromise<T.ScrapeResult> {
@@ -908,20 +944,22 @@ export class VisionAPI extends Namespace {
908
944
  * file access (`DOM.setFileInputFiles`, file drags); downloads to host paths (they land in the session's
909
945
  * own directory, wiped with the browser); and navigation to anything but `http:`, `https:` and
910
946
  * `about:blank` (`file:`, `chrome:`, `chrome-extension:`, `view-source:`, `devtools:`, `data:`). These
911
- * answer `cdp_method_blocked` in the CDP error (`error.data.code`). `Target.createBrowserContext` with
947
+ * answer a CDP error whose `data` is `cdp_method_blocked` (a string, as Chrome's own errors carry it; `code`
948
+ * and `status` are also in `error.b3os`). `Target.createBrowserContext` with
912
949
  * `proxyServer`, `proxyBypassList` or `originsWithUniversalNetworkAccess` answers `forbidden` (403):
913
950
  * every context of a session uses the session's egress. Reading the browser's cookies and storage, which
914
951
  * hold any profile the session loaded, needs `vision:profiles:export`, as exporting a profile's state does
915
952
  * (default keys, `*` and `vision:*` leave it out): without it, `Network.getAllCookies`,
916
953
  * `Network.getCookies`, `Storage.getCookies`, `Storage.getSharedStorageEntries`, `DOMStorage.*`,
917
- * `IndexedDB.*` and `CacheStorage.*` answer `forbidden` (403) with `required_scope` in `error.data`, and
954
+ * `IndexedDB.*` and `CacheStorage.*` answer `forbidden` (403) with `required_scope` in `error.b3os`, and
918
955
  * network events reach the client without `Cookie` and `Set-Cookie` headers, raw header text or cookie
919
956
  * lists. Until the profile scopes' kept window ends (2026-11-16) these reads still work. Scripts in the page
920
957
  * are not filtered: `Runtime.evaluate` reads what the page's own scripts can, such as `document.cookie`
921
958
  * (without HttpOnly cookies) and `localStorage`. Authenticate with the `Authorization` header or a
922
959
  * ticket from `POST /v1/vision/sessions/{session_id}/ticket`. A client that falls more than a few MB
923
- * behind is disconnected, and so is one that sends a message over 32 MiB. A message with a repeated member
924
- * (two `method`s, say) answers the JSON-RPC parse error `-32700`.
960
+ * behind is disconnected, and so is one that sends a message over 32 MiB. A session takes at most 4 CDP
961
+ * clients at once; the next answers `429 concurrency_limited` until one disconnects. A message with a
962
+ * repeated member (two `method`s, say) answers the JSON-RPC parse error `-32700`.
925
963
  *
926
964
  * `GET /v1/vision/sessions/{session_id}/cdp` · scope `vision:run` · served by the node
927
965
  */