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