@b3os/sdk 0.0.0-stage → 0.0.1

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 (242) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +233 -2
  3. package/dist/cjs/core/client.d.ts +165 -0
  4. package/dist/cjs/core/client.js +825 -0
  5. package/dist/cjs/core/client.js.map +1 -0
  6. package/dist/cjs/core/errors.d.ts +101 -0
  7. package/dist/cjs/core/errors.js +249 -0
  8. package/dist/cjs/core/errors.js.map +1 -0
  9. package/dist/cjs/core/index.d.ts +12 -0
  10. package/dist/cjs/core/index.js +42 -0
  11. package/dist/cjs/core/index.js.map +1 -0
  12. package/dist/cjs/core/jobs.d.ts +31 -0
  13. package/dist/cjs/core/jobs.js +72 -0
  14. package/dist/cjs/core/jobs.js.map +1 -0
  15. package/dist/cjs/core/namespace.d.ts +7 -0
  16. package/dist/cjs/core/namespace.js +13 -0
  17. package/dist/cjs/core/namespace.js.map +1 -0
  18. package/dist/cjs/core/op.d.ts +47 -0
  19. package/dist/cjs/core/op.js +5 -0
  20. package/dist/cjs/core/op.js.map +1 -0
  21. package/dist/cjs/core/promise.d.ts +106 -0
  22. package/dist/cjs/core/promise.js +200 -0
  23. package/dist/cjs/core/promise.js.map +1 -0
  24. package/dist/cjs/core/response.d.ts +54 -0
  25. package/dist/cjs/core/response.js +92 -0
  26. package/dist/cjs/core/response.js.map +1 -0
  27. package/dist/cjs/core/sse.d.ts +79 -0
  28. package/dist/cjs/core/sse.js +291 -0
  29. package/dist/cjs/core/sse.js.map +1 -0
  30. package/dist/cjs/core/timing.d.ts +20 -0
  31. package/dist/cjs/core/timing.js +96 -0
  32. package/dist/cjs/core/timing.js.map +1 -0
  33. package/dist/cjs/core/transport.d.ts +80 -0
  34. package/dist/cjs/core/transport.js +472 -0
  35. package/dist/cjs/core/transport.js.map +1 -0
  36. package/dist/cjs/core/util.d.ts +25 -0
  37. package/dist/cjs/core/util.js +142 -0
  38. package/dist/cjs/core/util.js.map +1 -0
  39. package/dist/cjs/core/ws.d.ts +52 -0
  40. package/dist/cjs/core/ws.js +181 -0
  41. package/dist/cjs/core/ws.js.map +1 -0
  42. package/dist/cjs/generated/client.d.ts +62 -0
  43. package/dist/cjs/generated/client.js +130 -0
  44. package/dist/cjs/generated/client.js.map +1 -0
  45. package/dist/cjs/generated/errors.d.ts +4 -0
  46. package/dist/cjs/generated/errors.js +160 -0
  47. package/dist/cjs/generated/errors.js.map +1 -0
  48. package/dist/cjs/generated/ids.d.ts +114 -0
  49. package/dist/cjs/generated/ids.js +47 -0
  50. package/dist/cjs/generated/ids.js.map +1 -0
  51. package/dist/cjs/generated/jobs.d.ts +10 -0
  52. package/dist/cjs/generated/jobs.js +24 -0
  53. package/dist/cjs/generated/jobs.js.map +1 -0
  54. package/dist/cjs/generated/ns/actions.d.ts +161 -0
  55. package/dist/cjs/generated/ns/actions.js +304 -0
  56. package/dist/cjs/generated/ns/actions.js.map +1 -0
  57. package/dist/cjs/generated/ns/infer.d.ts +190 -0
  58. package/dist/cjs/generated/ns/infer.js +253 -0
  59. package/dist/cjs/generated/ns/infer.js.map +1 -0
  60. package/dist/cjs/generated/ns/keys.d.ts +76 -0
  61. package/dist/cjs/generated/ns/keys.js +144 -0
  62. package/dist/cjs/generated/ns/keys.js.map +1 -0
  63. package/dist/cjs/generated/ns/limits.d.ts +22 -0
  64. package/dist/cjs/generated/ns/limits.js +32 -0
  65. package/dist/cjs/generated/ns/limits.js.map +1 -0
  66. package/dist/cjs/generated/ns/orgs.d.ts +38 -0
  67. package/dist/cjs/generated/ns/orgs.js +68 -0
  68. package/dist/cjs/generated/ns/orgs.js.map +1 -0
  69. package/dist/cjs/generated/ns/projects.d.ts +57 -0
  70. package/dist/cjs/generated/ns/projects.js +115 -0
  71. package/dist/cjs/generated/ns/projects.js.map +1 -0
  72. package/dist/cjs/generated/ns/render.d.ts +159 -0
  73. package/dist/cjs/generated/ns/render.js +299 -0
  74. package/dist/cjs/generated/ns/render.js.map +1 -0
  75. package/dist/cjs/generated/ns/requests.d.ts +36 -0
  76. package/dist/cjs/generated/ns/requests.js +54 -0
  77. package/dist/cjs/generated/ns/requests.js.map +1 -0
  78. package/dist/cjs/generated/ns/routines.d.ts +212 -0
  79. package/dist/cjs/generated/ns/routines.js +419 -0
  80. package/dist/cjs/generated/ns/routines.js.map +1 -0
  81. package/dist/cjs/generated/ns/sandboxes.d.ts +318 -0
  82. package/dist/cjs/generated/ns/sandboxes.js +549 -0
  83. package/dist/cjs/generated/ns/sandboxes.js.map +1 -0
  84. package/dist/cjs/generated/ns/usage.d.ts +30 -0
  85. package/dist/cjs/generated/ns/usage.js +49 -0
  86. package/dist/cjs/generated/ns/usage.js.map +1 -0
  87. package/dist/cjs/generated/ns/vault.d.ts +69 -0
  88. package/dist/cjs/generated/ns/vault.js +122 -0
  89. package/dist/cjs/generated/ns/vault.js.map +1 -0
  90. package/dist/cjs/generated/ns/vision.d.ts +376 -0
  91. package/dist/cjs/generated/ns/vision.js +736 -0
  92. package/dist/cjs/generated/ns/vision.js.map +1 -0
  93. package/dist/cjs/generated/ns/webhooks.d.ts +50 -0
  94. package/dist/cjs/generated/ns/webhooks.js +91 -0
  95. package/dist/cjs/generated/ns/webhooks.js.map +1 -0
  96. package/dist/cjs/generated/types.d.ts +4613 -0
  97. package/dist/cjs/generated/types.js +4 -0
  98. package/dist/cjs/generated/types.js.map +1 -0
  99. package/dist/cjs/index.d.ts +22 -0
  100. package/dist/cjs/index.js +81 -0
  101. package/dist/cjs/index.js.map +1 -0
  102. package/dist/cjs/package.json +3 -0
  103. package/dist/cjs/webhooks.d.ts +19 -0
  104. package/dist/cjs/webhooks.js +85 -0
  105. package/dist/cjs/webhooks.js.map +1 -0
  106. package/dist/esm/core/client.d.ts +165 -0
  107. package/dist/esm/core/client.js +821 -0
  108. package/dist/esm/core/client.js.map +1 -0
  109. package/dist/esm/core/errors.d.ts +101 -0
  110. package/dist/esm/core/errors.js +239 -0
  111. package/dist/esm/core/errors.js.map +1 -0
  112. package/dist/esm/core/index.d.ts +12 -0
  113. package/dist/esm/core/index.js +15 -0
  114. package/dist/esm/core/index.js.map +1 -0
  115. package/dist/esm/core/jobs.d.ts +31 -0
  116. package/dist/esm/core/jobs.js +66 -0
  117. package/dist/esm/core/jobs.js.map +1 -0
  118. package/dist/esm/core/namespace.d.ts +7 -0
  119. package/dist/esm/core/namespace.js +9 -0
  120. package/dist/esm/core/namespace.js.map +1 -0
  121. package/dist/esm/core/op.d.ts +47 -0
  122. package/dist/esm/core/op.js +4 -0
  123. package/dist/esm/core/op.js.map +1 -0
  124. package/dist/esm/core/promise.d.ts +106 -0
  125. package/dist/esm/core/promise.js +193 -0
  126. package/dist/esm/core/promise.js.map +1 -0
  127. package/dist/esm/core/response.d.ts +54 -0
  128. package/dist/esm/core/response.js +86 -0
  129. package/dist/esm/core/response.js.map +1 -0
  130. package/dist/esm/core/sse.d.ts +79 -0
  131. package/dist/esm/core/sse.js +286 -0
  132. package/dist/esm/core/sse.js.map +1 -0
  133. package/dist/esm/core/timing.d.ts +20 -0
  134. package/dist/esm/core/timing.js +92 -0
  135. package/dist/esm/core/timing.js.map +1 -0
  136. package/dist/esm/core/transport.d.ts +80 -0
  137. package/dist/esm/core/transport.js +465 -0
  138. package/dist/esm/core/transport.js.map +1 -0
  139. package/dist/esm/core/util.d.ts +25 -0
  140. package/dist/esm/core/util.js +128 -0
  141. package/dist/esm/core/util.js.map +1 -0
  142. package/dist/esm/core/ws.d.ts +52 -0
  143. package/dist/esm/core/ws.js +175 -0
  144. package/dist/esm/core/ws.js.map +1 -0
  145. package/dist/esm/generated/client.d.ts +62 -0
  146. package/dist/esm/generated/client.js +126 -0
  147. package/dist/esm/generated/client.js.map +1 -0
  148. package/dist/esm/generated/errors.d.ts +4 -0
  149. package/dist/esm/generated/errors.js +157 -0
  150. package/dist/esm/generated/errors.js.map +1 -0
  151. package/dist/esm/generated/ids.d.ts +114 -0
  152. package/dist/esm/generated/ids.js +42 -0
  153. package/dist/esm/generated/ids.js.map +1 -0
  154. package/dist/esm/generated/jobs.d.ts +10 -0
  155. package/dist/esm/generated/jobs.js +21 -0
  156. package/dist/esm/generated/jobs.js.map +1 -0
  157. package/dist/esm/generated/ns/actions.d.ts +161 -0
  158. package/dist/esm/generated/ns/actions.js +300 -0
  159. package/dist/esm/generated/ns/actions.js.map +1 -0
  160. package/dist/esm/generated/ns/infer.d.ts +190 -0
  161. package/dist/esm/generated/ns/infer.js +249 -0
  162. package/dist/esm/generated/ns/infer.js.map +1 -0
  163. package/dist/esm/generated/ns/keys.d.ts +76 -0
  164. package/dist/esm/generated/ns/keys.js +140 -0
  165. package/dist/esm/generated/ns/keys.js.map +1 -0
  166. package/dist/esm/generated/ns/limits.d.ts +22 -0
  167. package/dist/esm/generated/ns/limits.js +28 -0
  168. package/dist/esm/generated/ns/limits.js.map +1 -0
  169. package/dist/esm/generated/ns/orgs.d.ts +38 -0
  170. package/dist/esm/generated/ns/orgs.js +64 -0
  171. package/dist/esm/generated/ns/orgs.js.map +1 -0
  172. package/dist/esm/generated/ns/projects.d.ts +57 -0
  173. package/dist/esm/generated/ns/projects.js +111 -0
  174. package/dist/esm/generated/ns/projects.js.map +1 -0
  175. package/dist/esm/generated/ns/render.d.ts +159 -0
  176. package/dist/esm/generated/ns/render.js +295 -0
  177. package/dist/esm/generated/ns/render.js.map +1 -0
  178. package/dist/esm/generated/ns/requests.d.ts +36 -0
  179. package/dist/esm/generated/ns/requests.js +50 -0
  180. package/dist/esm/generated/ns/requests.js.map +1 -0
  181. package/dist/esm/generated/ns/routines.d.ts +212 -0
  182. package/dist/esm/generated/ns/routines.js +415 -0
  183. package/dist/esm/generated/ns/routines.js.map +1 -0
  184. package/dist/esm/generated/ns/sandboxes.d.ts +318 -0
  185. package/dist/esm/generated/ns/sandboxes.js +545 -0
  186. package/dist/esm/generated/ns/sandboxes.js.map +1 -0
  187. package/dist/esm/generated/ns/usage.d.ts +30 -0
  188. package/dist/esm/generated/ns/usage.js +45 -0
  189. package/dist/esm/generated/ns/usage.js.map +1 -0
  190. package/dist/esm/generated/ns/vault.d.ts +69 -0
  191. package/dist/esm/generated/ns/vault.js +118 -0
  192. package/dist/esm/generated/ns/vault.js.map +1 -0
  193. package/dist/esm/generated/ns/vision.d.ts +376 -0
  194. package/dist/esm/generated/ns/vision.js +732 -0
  195. package/dist/esm/generated/ns/vision.js.map +1 -0
  196. package/dist/esm/generated/ns/webhooks.d.ts +50 -0
  197. package/dist/esm/generated/ns/webhooks.js +87 -0
  198. package/dist/esm/generated/ns/webhooks.js.map +1 -0
  199. package/dist/esm/generated/types.d.ts +4613 -0
  200. package/dist/esm/generated/types.js +3 -0
  201. package/dist/esm/generated/types.js.map +1 -0
  202. package/dist/esm/index.d.ts +22 -0
  203. package/dist/esm/index.js +28 -0
  204. package/dist/esm/index.js.map +1 -0
  205. package/dist/esm/webhooks.d.ts +19 -0
  206. package/dist/esm/webhooks.js +79 -0
  207. package/dist/esm/webhooks.js.map +1 -0
  208. package/package.json +98 -4
  209. package/src/core/client.ts +1022 -0
  210. package/src/core/errors.ts +296 -0
  211. package/src/core/index.ts +45 -0
  212. package/src/core/jobs.ts +94 -0
  213. package/src/core/namespace.ts +10 -0
  214. package/src/core/op.ts +53 -0
  215. package/src/core/promise.ts +268 -0
  216. package/src/core/response.ts +115 -0
  217. package/src/core/sse.ts +305 -0
  218. package/src/core/timing.ts +106 -0
  219. package/src/core/transport.ts +489 -0
  220. package/src/core/util.ts +138 -0
  221. package/src/core/ws.ts +215 -0
  222. package/src/generated/client.ts +143 -0
  223. package/src/generated/errors.ts +313 -0
  224. package/src/generated/ids.ts +47 -0
  225. package/src/generated/jobs.ts +25 -0
  226. package/src/generated/ns/actions.ts +353 -0
  227. package/src/generated/ns/infer.ts +332 -0
  228. package/src/generated/ns/keys.ts +152 -0
  229. package/src/generated/ns/limits.ts +35 -0
  230. package/src/generated/ns/orgs.ts +77 -0
  231. package/src/generated/ns/projects.ts +122 -0
  232. package/src/generated/ns/render.ts +348 -0
  233. package/src/generated/ns/requests.ts +61 -0
  234. package/src/generated/ns/routines.ts +474 -0
  235. package/src/generated/ns/sandboxes.ts +671 -0
  236. package/src/generated/ns/usage.ts +56 -0
  237. package/src/generated/ns/vault.ts +136 -0
  238. package/src/generated/ns/vision.ts +836 -0
  239. package/src/generated/ns/webhooks.ts +100 -0
  240. package/src/generated/types.ts +5131 -0
  241. package/src/index.ts +30 -0
  242. package/src/webhooks.ts +100 -0
@@ -0,0 +1,836 @@
1
+ // Generated by packages/sdk/scripts/generate.mjs from packages/spec/dist. Do not edit; run `pnpm generate`.
2
+
3
+ import type { RequestOptions, StreamOptions } from "../../core/client.ts";
4
+ import { isTerminalJobEvent } from "../../core/jobs.ts";
5
+ import { Namespace } from "../../core/namespace.ts";
6
+ import type { Op } from "../../core/op.ts";
7
+ import type { APIPromise, JobPromise, ListPromise } from "../../core/promise.ts";
8
+ import type { EventStream } from "../../core/sse.ts";
9
+ import { type CdpEndpoint, ticketedUrl } from "../../core/ws.ts";
10
+ import type * as T from "../types.ts";
11
+
12
+ const listBatchesOp: Op = {
13
+ id: "visionListBatches",
14
+ method: "GET",
15
+ path: "/v1/vision/batches",
16
+ timeoutMs: 10000,
17
+ scope: "vision:read",
18
+ };
19
+ const getBatchOp: Op = {
20
+ id: "visionGetBatch",
21
+ method: "GET",
22
+ path: "/v1/vision/batches/{batch_id}",
23
+ params: ["batch_id"],
24
+ timeoutMs: 10000,
25
+ scope: "vision:read",
26
+ };
27
+ const cancelBatchOp: Op = {
28
+ id: "visionCancelBatch",
29
+ method: "POST",
30
+ path: "/v1/vision/batches/{batch_id}/cancel",
31
+ params: ["batch_id"],
32
+ timeoutMs: 10000,
33
+ scope: "vision:run",
34
+ };
35
+ const batchEventsOp: Op = {
36
+ id: "visionBatchEvents",
37
+ method: "GET",
38
+ path: "/v1/vision/batches/{batch_id}/events",
39
+ params: ["batch_id"],
40
+ stream: "sse",
41
+ timeoutMs: 3600000,
42
+ scope: "vision:read",
43
+ };
44
+ const listBatchPagesOp: Op = {
45
+ id: "visionListBatchPages",
46
+ method: "GET",
47
+ path: "/v1/vision/batches/{batch_id}/pages",
48
+ params: ["batch_id"],
49
+ timeoutMs: 10000,
50
+ scope: "vision:read",
51
+ };
52
+ const listCrawlsOp: Op = {
53
+ id: "visionListCrawls",
54
+ method: "GET",
55
+ path: "/v1/vision/crawls",
56
+ timeoutMs: 10000,
57
+ scope: "vision:read",
58
+ };
59
+ const getCrawlOp: Op = {
60
+ id: "visionGetCrawl",
61
+ method: "GET",
62
+ path: "/v1/vision/crawls/{crawl_id}",
63
+ params: ["crawl_id"],
64
+ timeoutMs: 10000,
65
+ scope: "vision:read",
66
+ };
67
+ const cancelCrawlOp: Op = {
68
+ id: "visionCancelCrawl",
69
+ method: "POST",
70
+ path: "/v1/vision/crawls/{crawl_id}/cancel",
71
+ params: ["crawl_id"],
72
+ timeoutMs: 10000,
73
+ scope: "vision:run",
74
+ };
75
+ const crawlEventsOp: Op = {
76
+ id: "visionCrawlEvents",
77
+ method: "GET",
78
+ path: "/v1/vision/crawls/{crawl_id}/events",
79
+ params: ["crawl_id"],
80
+ stream: "sse",
81
+ timeoutMs: 3600000,
82
+ scope: "vision:read",
83
+ };
84
+ const listCrawlPagesOp: Op = {
85
+ id: "visionListCrawlPages",
86
+ method: "GET",
87
+ path: "/v1/vision/crawls/{crawl_id}/pages",
88
+ params: ["crawl_id"],
89
+ timeoutMs: 10000,
90
+ scope: "vision:read",
91
+ };
92
+ const getExtractOp: Op = {
93
+ id: "visionGetExtract",
94
+ method: "GET",
95
+ path: "/v1/vision/extracts/{job_id}",
96
+ params: ["job_id"],
97
+ timeoutMs: 10000,
98
+ stretch: true,
99
+ scope: "vision:read",
100
+ };
101
+ const cancelExtractOp: Op = {
102
+ id: "visionCancelExtract",
103
+ method: "POST",
104
+ path: "/v1/vision/extracts/{job_id}/cancel",
105
+ params: ["job_id"],
106
+ timeoutMs: 10000,
107
+ stretch: true,
108
+ scope: "vision:run",
109
+ };
110
+ const extractEventsOp: Op = {
111
+ id: "visionExtractEvents",
112
+ method: "GET",
113
+ path: "/v1/vision/extracts/{job_id}/events",
114
+ params: ["job_id"],
115
+ stream: "sse",
116
+ timeoutMs: 3600000,
117
+ stretch: true,
118
+ scope: "vision:read",
119
+ };
120
+ const mapOp: Op = {
121
+ id: "visionMap",
122
+ method: "POST",
123
+ path: "/v1/vision/map",
124
+ body: "json",
125
+ timeoutMs: 65000,
126
+ scope: "vision:run",
127
+ };
128
+ const listProfilesOp: Op = {
129
+ id: "visionListProfiles",
130
+ method: "GET",
131
+ path: "/v1/vision/profiles",
132
+ timeoutMs: 10000,
133
+ scope: "vision:read",
134
+ };
135
+ const createProfileOp: Op = {
136
+ id: "visionCreateProfile",
137
+ method: "POST",
138
+ path: "/v1/vision/profiles",
139
+ body: "json",
140
+ idem: true,
141
+ timeoutMs: 10000,
142
+ scope: "vision:write",
143
+ };
144
+ const deleteProfileOp: Op = {
145
+ id: "visionDeleteProfile",
146
+ method: "DELETE",
147
+ path: "/v1/vision/profiles/{profile_id}",
148
+ params: ["profile_id"],
149
+ timeoutMs: 10000,
150
+ scope: "vision:write",
151
+ };
152
+ const getProfileOp: Op = {
153
+ id: "visionGetProfile",
154
+ method: "GET",
155
+ path: "/v1/vision/profiles/{profile_id}",
156
+ params: ["profile_id"],
157
+ timeoutMs: 10000,
158
+ scope: "vision:read",
159
+ };
160
+ const updateProfileOp: Op = {
161
+ id: "visionUpdateProfile",
162
+ method: "PATCH",
163
+ path: "/v1/vision/profiles/{profile_id}",
164
+ params: ["profile_id"],
165
+ body: "json",
166
+ timeoutMs: 10000,
167
+ scope: "vision:write",
168
+ };
169
+ const exportProfileStateOp: Op = {
170
+ id: "visionExportProfileState",
171
+ method: "GET",
172
+ path: "/v1/vision/profiles/{profile_id}/state",
173
+ params: ["profile_id"],
174
+ timeoutMs: 10000,
175
+ scope: "vision:write",
176
+ };
177
+ const readUrlOp: Op = {
178
+ id: "visionReadUrl",
179
+ method: "GET",
180
+ path: "/v1/vision/r/{url}",
181
+ params: ["url"],
182
+ wildcard: "url",
183
+ headerParams: {
184
+ format: "X-B3OS-Format",
185
+ engine: "X-B3OS-Engine",
186
+ timeout_ms: "X-B3OS-Timeout-Ms",
187
+ max_age_ms: "X-B3OS-Max-Age-Ms",
188
+ only_main_content: "X-B3OS-Only-Main-Content",
189
+ wait_for_ms: "X-B3OS-Wait-For-Ms",
190
+ },
191
+ timeoutMs: 65000,
192
+ scope: "vision:run",
193
+ };
194
+ const scrapeOp: Op = {
195
+ id: "visionScrape",
196
+ method: "POST",
197
+ path: "/v1/vision/scrape",
198
+ body: "json",
199
+ timeoutMs: 65000,
200
+ scope: "vision:run",
201
+ };
202
+ const listSessionsOp: Op = {
203
+ id: "visionListSessions",
204
+ method: "GET",
205
+ path: "/v1/vision/sessions",
206
+ timeoutMs: 10000,
207
+ scope: "vision:read",
208
+ };
209
+ const createSessionOp: Op = {
210
+ id: "visionCreateSession",
211
+ method: "POST",
212
+ path: "/v1/vision/sessions",
213
+ body: "json",
214
+ idem: true,
215
+ timeoutMs: 30000,
216
+ scope: "vision:write",
217
+ };
218
+ const closeSessionOp: Op = {
219
+ id: "visionCloseSession",
220
+ method: "DELETE",
221
+ path: "/v1/vision/sessions/{session_id}",
222
+ params: ["session_id"],
223
+ timeoutMs: 15000,
224
+ scope: "vision:write",
225
+ };
226
+ const getSessionOp: Op = {
227
+ id: "visionGetSession",
228
+ method: "GET",
229
+ path: "/v1/vision/sessions/{session_id}",
230
+ params: ["session_id"],
231
+ timeoutMs: 10000,
232
+ scope: "vision:read",
233
+ };
234
+ const actOp: Op = {
235
+ id: "visionAct",
236
+ method: "POST",
237
+ path: "/v1/vision/sessions/{session_id}/act",
238
+ params: ["session_id"],
239
+ body: "json",
240
+ timeoutMs: 65000,
241
+ scope: "vision:run",
242
+ };
243
+ const connectCdpOp: Op = {
244
+ id: "visionConnectCdp",
245
+ method: "GET",
246
+ path: "/v1/vision/sessions/{session_id}/cdp",
247
+ params: ["session_id"],
248
+ stream: "ws",
249
+ timeoutMs: 1800000,
250
+ scope: "vision:run",
251
+ };
252
+ const saveSessionProfileOp: Op = {
253
+ id: "visionSaveSessionProfile",
254
+ method: "POST",
255
+ path: "/v1/vision/sessions/{session_id}/profile",
256
+ params: ["session_id"],
257
+ body: "json",
258
+ timeoutMs: 15000,
259
+ scope: "vision:write",
260
+ };
261
+ const createSessionTicketOp: Op = {
262
+ id: "visionCreateSessionTicket",
263
+ method: "POST",
264
+ path: "/v1/vision/sessions/{session_id}/ticket",
265
+ params: ["session_id"],
266
+ timeoutMs: 5000,
267
+ scope: "vision:read",
268
+ };
269
+ const createBatchOp: Op = {
270
+ id: "visionCreateBatch",
271
+ method: "POST",
272
+ path: "/v1/vision/batches",
273
+ body: "json",
274
+ idem: true,
275
+ stream: "sse",
276
+ timeoutMs: 3600000,
277
+ scope: "vision:run",
278
+ job: { get: getBatchOp, events: batchEventsOp, cancel: cancelBatchOp },
279
+ };
280
+ const createCrawlOp: Op = {
281
+ id: "visionCreateCrawl",
282
+ method: "POST",
283
+ path: "/v1/vision/crawls",
284
+ body: "json",
285
+ idem: true,
286
+ stream: "sse",
287
+ timeoutMs: 3600000,
288
+ scope: "vision:run",
289
+ job: { get: getCrawlOp, events: crawlEventsOp, cancel: cancelCrawlOp },
290
+ };
291
+ const createExtractOp: Op = {
292
+ id: "visionCreateExtract",
293
+ method: "POST",
294
+ path: "/v1/vision/extracts",
295
+ body: "json",
296
+ idem: true,
297
+ stream: "sse",
298
+ timeoutMs: 3600000,
299
+ stretch: true,
300
+ scope: "vision:run",
301
+ job: { get: getExtractOp, events: extractEventsOp, cancel: cancelExtractOp },
302
+ };
303
+
304
+ /** Descriptors of every vision operation, keyed by method name (for tooling and custom clients). */
305
+ export const visionOps = {
306
+ listBatches: listBatchesOp,
307
+ createBatch: createBatchOp,
308
+ getBatch: getBatchOp,
309
+ cancelBatch: cancelBatchOp,
310
+ batchEvents: batchEventsOp,
311
+ listBatchPages: listBatchPagesOp,
312
+ listCrawls: listCrawlsOp,
313
+ createCrawl: createCrawlOp,
314
+ getCrawl: getCrawlOp,
315
+ cancelCrawl: cancelCrawlOp,
316
+ crawlEvents: crawlEventsOp,
317
+ listCrawlPages: listCrawlPagesOp,
318
+ createExtract: createExtractOp,
319
+ getExtract: getExtractOp,
320
+ cancelExtract: cancelExtractOp,
321
+ extractEvents: extractEventsOp,
322
+ map: mapOp,
323
+ listProfiles: listProfilesOp,
324
+ createProfile: createProfileOp,
325
+ deleteProfile: deleteProfileOp,
326
+ getProfile: getProfileOp,
327
+ updateProfile: updateProfileOp,
328
+ exportProfileState: exportProfileStateOp,
329
+ readUrl: readUrlOp,
330
+ scrape: scrapeOp,
331
+ listSessions: listSessionsOp,
332
+ createSession: createSessionOp,
333
+ closeSession: closeSessionOp,
334
+ getSession: getSessionOp,
335
+ act: actOp,
336
+ connectCdp: connectCdpOp,
337
+ saveSessionProfile: saveSessionProfileOp,
338
+ createSessionTicket: createSessionTicketOp,
339
+ } as const;
340
+
341
+ /**
342
+ * Browsers and web extraction: scrape, map, crawl, batch, browser sessions and profiles (`/v1/vision`).
343
+ */
344
+ export class VisionAPI extends Namespace {
345
+ /**
346
+ * List batch scrapes
347
+ *
348
+ * Lists batch scrapes in this project, newest first. Records are kept for 7 days after they finish.
349
+ *
350
+ * `GET /v1/vision/batches` · scope `vision:read` · served by the node
351
+ */
352
+ listBatches(
353
+ params?: T.VisionListBatchesParams,
354
+ options?: RequestOptions,
355
+ ): ListPromise<T.BatchScrapeList, T.BatchScrape> {
356
+ return this._client._list<T.BatchScrapeList, T.BatchScrape>(listBatchesOp, { query: params }, options);
357
+ }
358
+
359
+ /**
360
+ * Scrape a list of URLs
361
+ *
362
+ * Starts a job that scrapes up to 1,000 URLs with the same options. Each page bills one `vision.page`.
363
+ * Results are listed with `GET /v1/vision/batches/{batch_id}/pages`; `?wait=`, the events stream and
364
+ * `webhook` report progress.
365
+ *
366
+ * `POST /v1/vision/batches` · scope `vision:run` · served by the node
367
+ */
368
+ createBatch(body: T.BatchCreateRequest, options?: RequestOptions): JobPromise<T.BatchScrape, T.BatchEvent> {
369
+ return this._client._job<T.BatchScrape, T.BatchEvent>(createBatchOp, { body }, options);
370
+ }
371
+
372
+ /**
373
+ * Get a batch scrape
374
+ *
375
+ * Returns the batch job with its status, progress and summary result. Page contents are listed separately.
376
+ *
377
+ * `GET /v1/vision/batches/{batch_id}` · scope `vision:read` · served by the node
378
+ */
379
+ getBatch(batchId: string, options?: RequestOptions): APIPromise<T.BatchScrape> {
380
+ return this._client._call<T.BatchScrape>(getBatchOp, { path: [batchId] }, options);
381
+ }
382
+
383
+ /**
384
+ * Cancel a batch scrape
385
+ *
386
+ * Stops scraping new URLs. Pages already scraped stay listed and billed. Returns the batch with status `canceled`.
387
+ *
388
+ * `POST /v1/vision/batches/{batch_id}/cancel` · scope `vision:run` · served by the node
389
+ */
390
+ cancelBatch(batchId: string, options?: RequestOptions): APIPromise<T.BatchScrape> {
391
+ return this._client._call<T.BatchScrape>(cancelBatchOp, { path: [batchId] }, options);
392
+ }
393
+
394
+ /**
395
+ * Stream a batch's events
396
+ *
397
+ * Server-sent events for the batch: lifecycle events plus `page.succeeded` and `page.failed` per URL. Ends
398
+ * after the terminal event. Reconnect with `Last-Event-ID` to resume.
399
+ *
400
+ * `GET /v1/vision/batches/{batch_id}/events` · scope `vision:read` · served by the node
401
+ */
402
+ batchEvents(batchId: string, options?: StreamOptions): EventStream<T.BatchEvent> {
403
+ return this._client._stream<T.BatchEvent>(batchEventsOp, { path: [batchId] }, options, {
404
+ terminal: isTerminalJobEvent,
405
+ reconnectOnEnd: true,
406
+ });
407
+ }
408
+
409
+ /**
410
+ * List a batch's page results
411
+ *
412
+ * Lists the scraped pages of a batch in completion order, including failures. Available while the batch runs.
413
+ *
414
+ * `GET /v1/vision/batches/{batch_id}/pages` · scope `vision:read` · served by the node
415
+ */
416
+ listBatchPages(
417
+ batchId: string,
418
+ params?: T.VisionListBatchPagesParams,
419
+ options?: RequestOptions,
420
+ ): ListPromise<T.PageResultList, T.PageResult> {
421
+ return this._client._list<T.PageResultList, T.PageResult>(
422
+ listBatchPagesOp,
423
+ { path: [batchId], query: params },
424
+ options,
425
+ );
426
+ }
427
+
428
+ /**
429
+ * List crawls
430
+ *
431
+ * Lists crawls in this project, newest first. Records are kept for 7 days after they finish.
432
+ *
433
+ * `GET /v1/vision/crawls` · scope `vision:read` · served by the node
434
+ */
435
+ listCrawls(params?: T.VisionListCrawlsParams, options?: RequestOptions): ListPromise<T.CrawlList, T.Crawl> {
436
+ return this._client._list<T.CrawlList, T.Crawl>(listCrawlsOp, { query: params }, options);
437
+ }
438
+
439
+ /**
440
+ * Crawl a site
441
+ *
442
+ * Starts a job that discovers pages from `url` (links and sitemaps), breadth first, and scrapes up to `limit`
443
+ * pages (at most 500). robots.txt is honored and requests to one host are spaced politely. One crawl runs
444
+ * at a time per organization. Each page bills one `vision.page`.
445
+ *
446
+ * `POST /v1/vision/crawls` · scope `vision:run` · served by the node
447
+ */
448
+ createCrawl(body: T.CrawlCreateRequest, options?: RequestOptions): JobPromise<T.Crawl, T.CrawlEvent> {
449
+ return this._client._job<T.Crawl, T.CrawlEvent>(createCrawlOp, { body }, options);
450
+ }
451
+
452
+ /**
453
+ * Get a crawl
454
+ *
455
+ * Returns the crawl job with its status, progress and summary result. Page contents are listed separately.
456
+ *
457
+ * `GET /v1/vision/crawls/{crawl_id}` · scope `vision:read` · served by the node
458
+ */
459
+ getCrawl(crawlId: string, options?: RequestOptions): APIPromise<T.Crawl> {
460
+ return this._client._call<T.Crawl>(getCrawlOp, { path: [crawlId] }, options);
461
+ }
462
+
463
+ /**
464
+ * Cancel a crawl
465
+ *
466
+ * Stops discovering and scraping pages. Pages already scraped stay listed and billed.
467
+ *
468
+ * `POST /v1/vision/crawls/{crawl_id}/cancel` · scope `vision:run` · served by the node
469
+ */
470
+ cancelCrawl(crawlId: string, options?: RequestOptions): APIPromise<T.Crawl> {
471
+ return this._client._call<T.Crawl>(cancelCrawlOp, { path: [crawlId] }, options);
472
+ }
473
+
474
+ /**
475
+ * Stream a crawl's events
476
+ *
477
+ * Server-sent events for the crawl: lifecycle events plus `page.succeeded` and `page.failed` per page. Ends
478
+ * after the terminal event. Reconnect with `Last-Event-ID` to resume.
479
+ *
480
+ * `GET /v1/vision/crawls/{crawl_id}/events` · scope `vision:read` · served by the node
481
+ */
482
+ crawlEvents(crawlId: string, options?: StreamOptions): EventStream<T.CrawlEvent> {
483
+ return this._client._stream<T.CrawlEvent>(crawlEventsOp, { path: [crawlId] }, options, {
484
+ terminal: isTerminalJobEvent,
485
+ reconnectOnEnd: true,
486
+ });
487
+ }
488
+
489
+ /**
490
+ * List a crawl's page results
491
+ *
492
+ * Lists crawled pages in completion order, including failures. Available while the crawl runs.
493
+ *
494
+ * `GET /v1/vision/crawls/{crawl_id}/pages` · scope `vision:read` · served by the node
495
+ */
496
+ listCrawlPages(
497
+ crawlId: string,
498
+ params?: T.VisionListCrawlPagesParams,
499
+ options?: RequestOptions,
500
+ ): ListPromise<T.PageResultList, T.PageResult> {
501
+ return this._client._list<T.PageResultList, T.PageResult>(
502
+ listCrawlPagesOp,
503
+ { path: [crawlId], query: params },
504
+ options,
505
+ );
506
+ }
507
+
508
+ /**
509
+ * Extract structured data
510
+ *
511
+ * Starts a job that scrapes up to 10 URLs and asks the node's model to fill your JSON Schema from their
512
+ * content (with `prompt` as guidance). The result is validated against the schema; an invalid result after
513
+ * retries fails the job with `extraction_failed`. Bills `vision.page` per page plus the model's tokens.
514
+ *
515
+ * `POST /v1/vision/extracts` · scope `vision:run` · served by the node
516
+ *
517
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
518
+ */
519
+ createExtract(body: T.ExtractCreateRequest, options?: RequestOptions): JobPromise<T.ExtractJob, T.JobEvent> {
520
+ return this._client._job<T.ExtractJob, T.JobEvent>(createExtractOp, { body }, options);
521
+ }
522
+
523
+ /**
524
+ * Get an extraction
525
+ *
526
+ * Returns the extraction job; `result.data` holds the extracted JSON once it succeeded.
527
+ *
528
+ * `GET /v1/vision/extracts/{job_id}` · scope `vision:read` · served by the node
529
+ *
530
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
531
+ */
532
+ getExtract(jobId: string, options?: RequestOptions): APIPromise<T.ExtractJob> {
533
+ return this._client._call<T.ExtractJob>(getExtractOp, { path: [jobId] }, options);
534
+ }
535
+
536
+ /**
537
+ * Cancel an extraction
538
+ *
539
+ * Stops the extraction. Pages already scraped and tokens already used stay billed.
540
+ *
541
+ * `POST /v1/vision/extracts/{job_id}/cancel` · scope `vision:run` · served by the node
542
+ *
543
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
544
+ */
545
+ cancelExtract(jobId: string, options?: RequestOptions): APIPromise<T.ExtractJob> {
546
+ return this._client._call<T.ExtractJob>(cancelExtractOp, { path: [jobId] }, options);
547
+ }
548
+
549
+ /**
550
+ * Stream an extraction's events
551
+ *
552
+ * Server-sent lifecycle events for the extraction job. Ends after the terminal event.
553
+ *
554
+ * `GET /v1/vision/extracts/{job_id}/events` · scope `vision:read` · served by the node
555
+ *
556
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
557
+ */
558
+ extractEvents(jobId: string, options?: StreamOptions): EventStream<T.JobEvent> {
559
+ return this._client._stream<T.JobEvent>(extractEventsOp, { path: [jobId] }, options, {
560
+ terminal: isTerminalJobEvent,
561
+ reconnectOnEnd: true,
562
+ });
563
+ }
564
+
565
+ /**
566
+ * Map a site's URLs
567
+ *
568
+ * Lists URLs on a site from its sitemaps and from links on the start page, without scraping each page. Use it
569
+ * to choose what to scrape or crawl. `search` orders the results by relevance to a phrase. Bills one
570
+ * `vision.page` per call.
571
+ *
572
+ * `POST /v1/vision/map` · scope `vision:run` · served by the node
573
+ */
574
+ map(body: T.MapRequest, options?: RequestOptions): APIPromise<T.MapResult> {
575
+ return this._client._call<T.MapResult>(mapOp, { body }, options);
576
+ }
577
+
578
+ /**
579
+ * List profiles
580
+ *
581
+ * Lists profiles in this project, newest first.
582
+ *
583
+ * `GET /v1/vision/profiles` · scope `vision:read` · served by the node
584
+ */
585
+ listProfiles(params?: T.VisionListProfilesParams, options?: RequestOptions): ListPromise<T.ProfileList, T.Profile> {
586
+ return this._client._list<T.ProfileList, T.Profile>(listProfilesOp, { query: params }, options);
587
+ }
588
+
589
+ /**
590
+ * Create a profile
591
+ *
592
+ * Stores cookies and storage as a named profile, encrypted in the node's vault. `state` is Playwright's
593
+ * `storageState` JSON (`context.storageState({indexedDB: true})`) uploaded as is. Every cookie domain and
594
+ * origin must belong to `domains` (derived from the state when omitted). The API returns counts and domains,
595
+ * never cookie values; `GET /v1/vision/profiles/{profile_id}/state` exports the state.
596
+ *
597
+ * `POST /v1/vision/profiles` · scope `vision:write` · served by the node
598
+ */
599
+ createProfile(body: T.ProfileCreateRequest, options?: RequestOptions): APIPromise<T.Profile> {
600
+ return this._client._call<T.Profile>(createProfileOp, { body }, options);
601
+ }
602
+
603
+ /**
604
+ * Delete a profile
605
+ *
606
+ * Deletes the profile and every stored revision. Open sessions that loaded it keep their cookies until they close.
607
+ *
608
+ * `DELETE /v1/vision/profiles/{profile_id}` · scope `vision:write` · served by the node
609
+ */
610
+ deleteProfile(profileId: string, options?: RequestOptions): APIPromise<T.Deleted> {
611
+ return this._client._call<T.Deleted>(deleteProfileOp, { path: [profileId] }, options);
612
+ }
613
+
614
+ /**
615
+ * Get a profile
616
+ *
617
+ * Returns a profile's metadata, revision and counts. Cookie values and storage contents are never returned here.
618
+ *
619
+ * `GET /v1/vision/profiles/{profile_id}` · scope `vision:read` · served by the node
620
+ */
621
+ getProfile(profileId: string, options?: RequestOptions): APIPromise<T.Profile> {
622
+ return this._client._call<T.Profile>(getProfileOp, { path: [profileId] }, options);
623
+ }
624
+
625
+ /**
626
+ * Update a profile
627
+ *
628
+ * Renames a profile, changes its domains, expiry or metadata, or replaces its state (a new revision).
629
+ * Omitted fields are unchanged.
630
+ *
631
+ * `PATCH /v1/vision/profiles/{profile_id}` · scope `vision:write` · served by the node
632
+ */
633
+ updateProfile(profileId: string, body: T.ProfileUpdateRequest, options?: RequestOptions): APIPromise<T.Profile> {
634
+ return this._client._call<T.Profile>(updateProfileOp, { path: [profileId], body }, options);
635
+ }
636
+
637
+ /**
638
+ * Export a profile's state
639
+ *
640
+ * Returns the current revision's storage state (Playwright `storageState` JSON) so you can load it into your
641
+ * own browser or move it to another project. It contains live session cookies: treat the response like a
642
+ * password. Requires `vision:write`, the same scope that can replace the state.
643
+ *
644
+ * `GET /v1/vision/profiles/{profile_id}/state` · scope `vision:write` · served by the node
645
+ */
646
+ exportProfileState(profileId: string, options?: RequestOptions): APIPromise<T.ProfileStorageState> {
647
+ return this._client._call<T.ProfileStorageState>(exportProfileStateOp, { path: [profileId] }, options);
648
+ }
649
+
650
+ /**
651
+ * Read a URL as Markdown
652
+ *
653
+ * The shortest way to read a page: put the target URL after `/v1/vision/r/`, unencoded, for example
654
+ * `GET /v1/vision/r/https://example.com/pricing`. Returns `text/markdown` by default. Options go in
655
+ * `X-B3OS-*` headers so the target URL stays untouched. Same tiers, cache and billing as `scrape`.
656
+ *
657
+ * `GET /v1/vision/r/{url}` · scope `vision:run` · served by the node
658
+ */
659
+ readUrl(
660
+ url: string,
661
+ params: T.VisionReadUrlParams & { format: "json" },
662
+ options?: RequestOptions,
663
+ ): APIPromise<T.ScrapeResult>;
664
+ readUrl(url: string, params?: T.VisionReadUrlParams, options?: RequestOptions): APIPromise<string>;
665
+ readUrl(
666
+ url: string,
667
+ params: T.VisionReadUrlParams = {},
668
+ options: RequestOptions = {},
669
+ ): APIPromise<string | T.ScrapeResult> {
670
+ if (params.format === "json") {
671
+ return this._client._call<T.ScrapeResult>(
672
+ readUrlOp,
673
+ { path: [url], headerParams: params },
674
+ options,
675
+ "application/json",
676
+ "json",
677
+ );
678
+ }
679
+ return this._client._call<string>(
680
+ readUrlOp,
681
+ { path: [url], headerParams: params },
682
+ options,
683
+ "text/markdown, text/html, text/plain",
684
+ "text",
685
+ );
686
+ }
687
+
688
+ /**
689
+ * Scrape a page
690
+ *
691
+ * Fetches one URL and returns the formats you ask for. With `engine: "auto"` (the default) vision answers
692
+ * from the cache when a fresh copy exists (`max_age_ms`, default 2 days), otherwise fetches over HTTP and
693
+ * switches to a warm browser only when the page needs JavaScript. Custom `headers`, a `profile` or `actions`
694
+ * bypass the cache; a page that sets cookies (by a response or a script) is cached for your organization
695
+ * only. The response's `cache.state` and `tier` say what served it.
696
+ *
697
+ * Synchronous: the response arrives when the page is done, within `timeout_ms` (at most 60 seconds). For
698
+ * many pages use a batch scrape or a crawl.
699
+ *
700
+ * `POST /v1/vision/scrape` · scope `vision:run` · served by the node
701
+ */
702
+ scrape(body: T.ScrapeRequest, options?: RequestOptions): APIPromise<T.ScrapeResult> {
703
+ return this._client._call<T.ScrapeResult>(scrapeOp, { body }, options);
704
+ }
705
+
706
+ /**
707
+ * List browser sessions
708
+ *
709
+ * Lists sessions in this project, newest first, including recently closed ones (kept for 7 days).
710
+ *
711
+ * `GET /v1/vision/sessions` · scope `vision:read` · served by the node
712
+ */
713
+ listSessions(
714
+ params?: T.VisionListSessionsParams,
715
+ options?: RequestOptions,
716
+ ): ListPromise<T.BrowserSessionList, T.BrowserSession> {
717
+ return this._client._list<T.BrowserSessionList, T.BrowserSession>(listSessionsOp, { query: params }, options);
718
+ }
719
+
720
+ /**
721
+ * Create a browser session
722
+ *
723
+ * Claims a warm, dedicated browser for your organization and returns it ready to drive. Load a `profile` to
724
+ * start signed in; set `persist_profile` to save cookies and storage back when the session closes. The
725
+ * session closes after `timeout_s` (at most 1,800) or on `DELETE`. Bills `vision.browser_ms` from claim to
726
+ * close.
727
+ *
728
+ * `POST /v1/vision/sessions` · scope `vision:write` · served by the node
729
+ */
730
+ createSession(body?: T.SessionCreateRequest, options?: RequestOptions): APIPromise<T.BrowserSession> {
731
+ return this._client._call<T.BrowserSession>(createSessionOp, { body }, options);
732
+ }
733
+
734
+ /**
735
+ * Close a browser session
736
+ *
737
+ * Closes the session and destroys its browser. With `persist_profile`, cookies and storage are saved to the
738
+ * profile first (a newer revision saved by another session fails the save with `profile_conflict` unless
739
+ * `overwrite_profile` was set; the session still closes). Returns the closed session with the final browser
740
+ * time. Closing a closed session returns it unchanged.
741
+ *
742
+ * `DELETE /v1/vision/sessions/{session_id}` · scope `vision:write` · served by the node
743
+ */
744
+ closeSession(sessionId: string, options?: RequestOptions): APIPromise<T.BrowserSession> {
745
+ return this._client._call<T.BrowserSession>(closeSessionOp, { path: [sessionId] }, options);
746
+ }
747
+
748
+ /**
749
+ * Get a browser session
750
+ *
751
+ * Returns the session, its open pages and the browser time used so far.
752
+ *
753
+ * `GET /v1/vision/sessions/{session_id}` · scope `vision:read` · served by the node
754
+ */
755
+ getSession(sessionId: string, options?: RequestOptions): APIPromise<T.BrowserSession> {
756
+ return this._client._call<T.BrowserSession>(getSessionOp, { path: [sessionId] }, options);
757
+ }
758
+
759
+ /**
760
+ * Run browser actions
761
+ *
762
+ * Runs a batch of browser actions in order on one page and returns every result in one round trip:
763
+ * `navigate`, `click`, `hover`, `type`, `key`, `scroll`, `select` and `wait` (the same kinds and fields as
764
+ * render scripts), plus `evaluate`, `screenshot` and `markdown`. Execution stops at the first failed action
765
+ * unless `continue_on_error` is set; the failed action's result carries the error (for example
766
+ * `target_not_found`) and later actions are reported as `skipped`. The batch must finish within `timeout_ms`.
767
+ *
768
+ * `POST /v1/vision/sessions/{session_id}/act` · scope `vision:run` · served by the node
769
+ */
770
+ act(sessionId: string, body: T.ActRequest, options?: RequestOptions): APIPromise<T.ActResult> {
771
+ return this._client._call<T.ActResult>(actOp, { path: [sessionId], body }, options);
772
+ }
773
+
774
+ /**
775
+ * Connect over CDP
776
+ *
777
+ * Opens a WebSocket that speaks the Chrome DevTools Protocol for this session only, so Playwright
778
+ * (`chromium.connectOverCDP`), Puppeteer (`puppeteer.connect`) or any CDP client can drive the browser. The
779
+ * proxy exposes only the session's own targets. It refuses `SystemInfo.*`, `Tethering.*`, `Extensions.*`,
780
+ * `Cast.*`, and `Browser.*` except the methods Playwright and Puppeteer need to drive a browser
781
+ * (`getVersion`, the permission methods, window bounds, `setDownloadBehavior` and `cancelDownload`); host
782
+ * file access (`DOM.setFileInputFiles`, file drags); downloads to host paths (they land in the session's
783
+ * own directory, wiped with the browser); and navigation to anything but `http:`, `https:` and
784
+ * `about:blank` (`file:`, `chrome:`, `chrome-extension:`, `view-source:`, `devtools:`, `data:`). These
785
+ * answer `cdp_method_blocked` in the CDP error (`error.data.code`). `Target.createBrowserContext` with
786
+ * `proxyServer`, `proxyBypassList` or `originsWithUniversalNetworkAccess` answers `forbidden` (403):
787
+ * every context of a session uses the session's egress. Authenticate with the `Authorization` header or a
788
+ * ticket from `POST /v1/vision/sessions/{session_id}/ticket`. A client that falls more than a few MB
789
+ * behind is disconnected, and so is one that sends a message over 32 MiB. A message with a repeated member
790
+ * (two `method`s, say) answers the JSON-RPC parse error `-32700`.
791
+ *
792
+ * `GET /v1/vision/sessions/{session_id}/cdp` · scope `vision:run` · served by the node
793
+ */
794
+ async connectCdp(sessionId: string, options: RequestOptions = {}): Promise<CdpEndpoint> {
795
+ const { url, ticket } = await ticketedUrl(
796
+ this._client,
797
+ connectCdpOp,
798
+ createSessionTicketOp,
799
+ { path: [sessionId] },
800
+ options,
801
+ true,
802
+ );
803
+ return { url, expiresInS: ticket?.expires_in_s ?? null };
804
+ }
805
+
806
+ /**
807
+ * Save a session to a profile
808
+ *
809
+ * Saves the session's current cookies and storage to a profile now: the named profile is created if it does
810
+ * not exist, otherwise a new revision replaces its state. Use it right after an agent or a person signs in.
811
+ * If another session saved the profile since this one loaded it, the save fails with `profile_conflict`
812
+ * unless `overwrite` is set.
813
+ *
814
+ * `POST /v1/vision/sessions/{session_id}/profile` · scope `vision:write` · served by the node
815
+ */
816
+ saveSessionProfile(
817
+ sessionId: string,
818
+ body: T.SessionProfileSaveRequest,
819
+ options?: RequestOptions,
820
+ ): APIPromise<T.Profile> {
821
+ return this._client._call<T.Profile>(saveSessionProfileOp, { path: [sessionId], body }, options);
822
+ }
823
+
824
+ /**
825
+ * Create a stream ticket
826
+ *
827
+ * Returns a single-use ticket, valid for 30 seconds, that opens the session's CDP socket without a bearer
828
+ * header (for browsers and CDP clients that cannot set headers). Pass it as `?ticket=` or in
829
+ * `Sec-WebSocket-Protocol: b3os.v1, b3os.ticket.<ticket>`. The socket runs with this caller's scopes.
830
+ *
831
+ * `POST /v1/vision/sessions/{session_id}/ticket` · scope `vision:read` · served by the node
832
+ */
833
+ createSessionTicket(sessionId: string, options?: RequestOptions): APIPromise<T.StreamTicket> {
834
+ return this._client._call<T.StreamTicket>(createSessionTicketOp, { path: [sessionId] }, options);
835
+ }
836
+ }