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