parallel-web 0.4.0 → 0.5.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 (160) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/client.d.mts +37 -12
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +37 -12
  5. package/client.d.ts.map +1 -1
  6. package/client.js +42 -8
  7. package/client.js.map +1 -1
  8. package/client.mjs +42 -8
  9. package/client.mjs.map +1 -1
  10. package/internal/qs/formats.d.mts +7 -0
  11. package/internal/qs/formats.d.mts.map +1 -0
  12. package/internal/qs/formats.d.ts +7 -0
  13. package/internal/qs/formats.d.ts.map +1 -0
  14. package/internal/qs/formats.js +13 -0
  15. package/internal/qs/formats.js.map +1 -0
  16. package/internal/qs/formats.mjs +9 -0
  17. package/internal/qs/formats.mjs.map +1 -0
  18. package/internal/qs/index.d.mts +10 -0
  19. package/internal/qs/index.d.mts.map +1 -0
  20. package/internal/qs/index.d.ts +10 -0
  21. package/internal/qs/index.d.ts.map +1 -0
  22. package/internal/qs/index.js +14 -0
  23. package/internal/qs/index.js.map +1 -0
  24. package/internal/qs/index.mjs +10 -0
  25. package/internal/qs/index.mjs.map +1 -0
  26. package/internal/qs/stringify.d.mts +3 -0
  27. package/internal/qs/stringify.d.mts.map +1 -0
  28. package/internal/qs/stringify.d.ts +3 -0
  29. package/internal/qs/stringify.d.ts.map +1 -0
  30. package/internal/qs/stringify.js +277 -0
  31. package/internal/qs/stringify.js.map +1 -0
  32. package/internal/qs/stringify.mjs +274 -0
  33. package/internal/qs/stringify.mjs.map +1 -0
  34. package/internal/qs/types.d.mts +57 -0
  35. package/internal/qs/types.d.mts.map +1 -0
  36. package/internal/qs/types.d.ts +57 -0
  37. package/internal/qs/types.d.ts.map +1 -0
  38. package/internal/qs/types.js +3 -0
  39. package/internal/qs/types.js.map +1 -0
  40. package/internal/qs/types.mjs +2 -0
  41. package/internal/qs/types.mjs.map +1 -0
  42. package/internal/qs/utils.d.mts +15 -0
  43. package/internal/qs/utils.d.mts.map +1 -0
  44. package/internal/qs/utils.d.ts +15 -0
  45. package/internal/qs/utils.d.ts.map +1 -0
  46. package/internal/qs/utils.js +230 -0
  47. package/internal/qs/utils.js.map +1 -0
  48. package/internal/qs/utils.mjs +217 -0
  49. package/internal/qs/utils.mjs.map +1 -0
  50. package/internal/types.d.mts +6 -6
  51. package/internal/types.d.mts.map +1 -1
  52. package/internal/types.d.ts +6 -6
  53. package/internal/types.d.ts.map +1 -1
  54. package/internal/utils/query.d.mts +0 -3
  55. package/internal/utils/query.d.mts.map +1 -1
  56. package/internal/utils/query.d.ts +0 -3
  57. package/internal/utils/query.d.ts.map +1 -1
  58. package/internal/utils/query.js +3 -16
  59. package/internal/utils/query.js.map +1 -1
  60. package/internal/utils/query.mjs +2 -16
  61. package/internal/utils/query.mjs.map +1 -1
  62. package/package.json +1 -1
  63. package/resources/beta/beta.d.mts +22 -28
  64. package/resources/beta/beta.d.mts.map +1 -1
  65. package/resources/beta/beta.d.ts +22 -28
  66. package/resources/beta/beta.d.ts.map +1 -1
  67. package/resources/beta/beta.js +4 -10
  68. package/resources/beta/beta.js.map +1 -1
  69. package/resources/beta/beta.mjs +4 -10
  70. package/resources/beta/beta.mjs.map +1 -1
  71. package/resources/beta/findall.d.mts +127 -177
  72. package/resources/beta/findall.d.mts.map +1 -1
  73. package/resources/beta/findall.d.ts +127 -177
  74. package/resources/beta/findall.d.ts.map +1 -1
  75. package/resources/beta/findall.js +2 -4
  76. package/resources/beta/findall.js.map +1 -1
  77. package/resources/beta/findall.mjs +2 -4
  78. package/resources/beta/findall.mjs.map +1 -1
  79. package/resources/beta/index.d.mts +2 -2
  80. package/resources/beta/index.d.mts.map +1 -1
  81. package/resources/beta/index.d.ts +2 -2
  82. package/resources/beta/index.d.ts.map +1 -1
  83. package/resources/beta/index.js.map +1 -1
  84. package/resources/beta/index.mjs.map +1 -1
  85. package/resources/beta/task-group.d.mts +22 -143
  86. package/resources/beta/task-group.d.mts.map +1 -1
  87. package/resources/beta/task-group.d.ts +22 -143
  88. package/resources/beta/task-group.d.ts.map +1 -1
  89. package/resources/beta/task-group.js +7 -42
  90. package/resources/beta/task-group.js.map +1 -1
  91. package/resources/beta/task-group.mjs +7 -42
  92. package/resources/beta/task-group.mjs.map +1 -1
  93. package/resources/beta/task-run.d.mts +22 -70
  94. package/resources/beta/task-run.d.mts.map +1 -1
  95. package/resources/beta/task-run.d.ts +22 -70
  96. package/resources/beta/task-run.d.ts.map +1 -1
  97. package/resources/beta/task-run.js +1 -1
  98. package/resources/beta/task-run.mjs +1 -1
  99. package/resources/index.d.mts +4 -2
  100. package/resources/index.d.mts.map +1 -1
  101. package/resources/index.d.ts +4 -2
  102. package/resources/index.d.ts.map +1 -1
  103. package/resources/index.js +5 -1
  104. package/resources/index.js.map +1 -1
  105. package/resources/index.mjs +2 -0
  106. package/resources/index.mjs.map +1 -1
  107. package/resources/monitor.d.mts +625 -0
  108. package/resources/monitor.d.mts.map +1 -0
  109. package/resources/monitor.d.ts +625 -0
  110. package/resources/monitor.d.ts.map +1 -0
  111. package/resources/monitor.js +140 -0
  112. package/resources/monitor.js.map +1 -0
  113. package/resources/monitor.mjs +136 -0
  114. package/resources/monitor.mjs.map +1 -0
  115. package/resources/task-group.d.mts +213 -0
  116. package/resources/task-group.d.mts.map +1 -0
  117. package/resources/task-group.d.ts +213 -0
  118. package/resources/task-group.d.ts.map +1 -0
  119. package/resources/task-group.js +95 -0
  120. package/resources/task-group.js.map +1 -0
  121. package/resources/task-group.mjs +91 -0
  122. package/resources/task-group.mjs.map +1 -0
  123. package/resources/task-run.d.mts +97 -80
  124. package/resources/task-run.d.mts.map +1 -1
  125. package/resources/task-run.d.ts +97 -80
  126. package/resources/task-run.d.ts.map +1 -1
  127. package/resources/task-run.js +14 -1
  128. package/resources/task-run.js.map +1 -1
  129. package/resources/task-run.mjs +14 -1
  130. package/resources/task-run.mjs.map +1 -1
  131. package/resources/top-level.d.mts +19 -15
  132. package/resources/top-level.d.mts.map +1 -1
  133. package/resources/top-level.d.ts +19 -15
  134. package/resources/top-level.d.ts.map +1 -1
  135. package/src/client.ts +128 -8
  136. package/src/internal/qs/LICENSE.md +13 -0
  137. package/src/internal/qs/README.md +3 -0
  138. package/src/internal/qs/formats.ts +10 -0
  139. package/src/internal/qs/index.ts +13 -0
  140. package/src/internal/qs/stringify.ts +385 -0
  141. package/src/internal/qs/types.ts +71 -0
  142. package/src/internal/qs/utils.ts +265 -0
  143. package/src/internal/types.ts +6 -8
  144. package/src/internal/utils/query.ts +2 -18
  145. package/src/resources/beta/api.md +9 -5
  146. package/src/resources/beta/beta.ts +38 -28
  147. package/src/resources/beta/findall.ts +153 -202
  148. package/src/resources/beta/index.ts +7 -4
  149. package/src/resources/beta/task-group.ts +30 -157
  150. package/src/resources/beta/task-run.ts +26 -86
  151. package/src/resources/index.ts +42 -0
  152. package/src/resources/monitor.ts +752 -0
  153. package/src/resources/task-group.ts +315 -0
  154. package/src/resources/task-run.ts +122 -95
  155. package/src/resources/top-level.ts +23 -15
  156. package/src/version.ts +1 -1
  157. package/version.d.mts +1 -1
  158. package/version.d.ts +1 -1
  159. package/version.js +1 -1
  160. package/version.mjs +1 -1
@@ -0,0 +1,752 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as Shared from './shared';
5
+ import * as TaskRunAPI from './task-run';
6
+ import { APIPromise } from '../core/api-promise';
7
+ import { buildHeaders } from '../internal/headers';
8
+ import { RequestOptions } from '../internal/request-options';
9
+ import { path } from '../internal/utils/path';
10
+
11
+ /**
12
+ * The Monitor API watches the web for material changes on a fixed frequency. Each monitor runs once on creation and then on its configured schedule, emitting events when meaningful changes are detected.
13
+ * - `event_stream` monitors track a search query and emit an event for each new material change.
14
+ * - `snapshot` monitors track a specific task run's output and emit an event when the output changes.
15
+ *
16
+ * Results can be polled via the events endpoint or delivered via webhooks.
17
+ */
18
+ export class MonitorResource extends APIResource {
19
+ /**
20
+ * Create a monitor.
21
+ *
22
+ * Monitors run on a fixed frequency to detect material changes in web content. Set
23
+ * `type=event_stream` to monitor a search query, or `type=snapshot` to monitor a
24
+ * specific task run's output. The monitor runs once immediately at creation, then
25
+ * continues on the configured schedule.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const monitor = await client.monitor.create({
30
+ * frequency: '1h',
31
+ * settings: { query: 'Extract recent news about AI' },
32
+ * type: 'event_stream',
33
+ * });
34
+ * ```
35
+ */
36
+ create(body: MonitorCreateParams, options?: RequestOptions): APIPromise<Monitor> {
37
+ return this._client.post('/v1/monitors', { body, ...options });
38
+ }
39
+
40
+ /**
41
+ * Retrieve a monitor.
42
+ *
43
+ * Retrieves a specific monitor by `monitor_id`. Returns the monitor configuration
44
+ * including status, frequency, query, and webhook settings.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * const monitor = await client.monitor.retrieve('monitor_id');
49
+ * ```
50
+ */
51
+ retrieve(monitorID: string, options?: RequestOptions): APIPromise<Monitor> {
52
+ return this._client.get(path`/v1/monitors/${monitorID}`, options);
53
+ }
54
+
55
+ /**
56
+ * Update a monitor.
57
+ *
58
+ * Only fields explicitly included in the request body are changed. Pass `null` for
59
+ * `webhook` or `metadata` to clear those fields. Pass `type` and `settings` to
60
+ * update type-specific settings on an `event_stream` monitor. At least one field
61
+ * must be provided. Cancelled monitors cannot be updated.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * const monitor = await client.monitor.update('monitor_id');
66
+ * ```
67
+ */
68
+ update(monitorID: string, body: MonitorUpdateParams, options?: RequestOptions): APIPromise<Monitor> {
69
+ return this._client.post(path`/v1/monitors/${monitorID}/update`, { body, ...options });
70
+ }
71
+
72
+ /**
73
+ * List monitors ordered by creation time, newest first.
74
+ *
75
+ * Monitors are sorted by `created_at` descending. `limit` defaults to 100. Use
76
+ * `next_cursor` from the response and pass it as `cursor` to fetch the next page.
77
+ * Pagination ends when `next_cursor` is absent.
78
+ *
79
+ * By default only `active` monitors are returned. Pass `status=cancelled` or both
80
+ * values to include cancelled monitors.
81
+ *
82
+ * The legacy Monitor API (`/v1alpha/monitors` endpoints) is documented under the
83
+ * `Monitor (Alpha)` tag.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * const paginatedMonitorResponse =
88
+ * await client.monitor.list();
89
+ * ```
90
+ */
91
+ list(
92
+ query: MonitorListParams | null | undefined = {},
93
+ options?: RequestOptions,
94
+ ): APIPromise<PaginatedMonitorResponse> {
95
+ return this._client.get('/v1/monitors', { query, ...options });
96
+ }
97
+
98
+ /**
99
+ * Cancel a monitor.
100
+ *
101
+ * Permanently stops the monitor from running. Cancellation is irreversible —
102
+ * create a new monitor to resume monitoring. Cancelling an already-cancelled
103
+ * monitor is a no-op.
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * const monitor = await client.monitor.cancel('monitor_id');
108
+ * ```
109
+ */
110
+ cancel(monitorID: string, options?: RequestOptions): APIPromise<Monitor> {
111
+ return this._client.post(path`/v1/monitors/${monitorID}/cancel`, options);
112
+ }
113
+
114
+ /**
115
+ * List events for a monitor, newest first.
116
+ *
117
+ * Pass `event_group_id` to narrow results to a single execution. Otherwise returns
118
+ * all executions newest-first; use `next_cursor` to paginate. Set
119
+ * `include_completions=true` to also include no-change executions.
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * const paginatedMonitorEvents = await client.monitor.events(
124
+ * 'monitor_id',
125
+ * );
126
+ * ```
127
+ */
128
+ events(
129
+ monitorID: string,
130
+ query: MonitorEventsParams | null | undefined = {},
131
+ options?: RequestOptions,
132
+ ): APIPromise<PaginatedMonitorEvents> {
133
+ return this._client.get(path`/v1/monitors/${monitorID}/events`, { query, ...options });
134
+ }
135
+
136
+ /**
137
+ * Trigger an immediate monitor run.
138
+ *
139
+ * Enqueues a one-off execution of the monitor outside its normal schedule. The
140
+ * monitor's regular schedule is not affected. An event is only emitted if the
141
+ * execution detects a material change. Cancelled monitors cannot be triggered.
142
+ *
143
+ * @example
144
+ * ```ts
145
+ * await client.monitor.trigger('monitor_id');
146
+ * ```
147
+ */
148
+ trigger(monitorID: string, options?: RequestOptions): APIPromise<void> {
149
+ return this._client.post(path`/v1/monitors/${monitorID}/trigger`, {
150
+ ...options,
151
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
152
+ });
153
+ }
154
+ }
155
+
156
+ /**
157
+ * Advanced monitor configuration.
158
+ */
159
+ export interface AdvancedMonitorSettings {
160
+ /**
161
+ * ISO 3166-1 alpha-2 country code for geo-targeted monitor results.
162
+ */
163
+ location?: string | null;
164
+
165
+ /**
166
+ * Source policy for web search results.
167
+ *
168
+ * This policy governs which sources are allowed/disallowed in results.
169
+ */
170
+ source_policy?: Shared.SourcePolicy | null;
171
+ }
172
+
173
+ /**
174
+ * Request body to create a monitor.
175
+ *
176
+ * The `type` field at the root determines the expected shape of `settings`:
177
+ * `event_stream` requires `MonitorEventStreamSettings`, and `snapshot` requires
178
+ * `MonitorSnapshotSettings`.
179
+ */
180
+ export interface CreateMonitorRequest {
181
+ /**
182
+ * Frequency of the monitor. Format: '<number><unit>' where unit is 'h' (hours),
183
+ * 'd' (days), or 'w' (weeks). Must be between 1h and 30d (inclusive).
184
+ */
185
+ frequency: string;
186
+
187
+ /**
188
+ * Type-specific settings for the monitor. The expected shape is determined by the
189
+ * root `type` field: pass `MonitorEventStreamSettings` when `type` is
190
+ * `event_stream`, and `MonitorSnapshotSettings` when `type` is `snapshot`.
191
+ */
192
+ settings: MonitorEventStreamSettings | MonitorSnapshotSettings;
193
+
194
+ /**
195
+ * Type of monitor to create. `event_stream` monitors a search query for material
196
+ * changes; `snapshot` monitors a specific task run's output. Determines the
197
+ * expected shape of `settings`.
198
+ */
199
+ type: 'event_stream' | 'snapshot';
200
+
201
+ /**
202
+ * User-provided metadata stored with the monitor and echoed back in webhook
203
+ * notifications and GET responses, so you can map events to objects in your
204
+ * application. Keys: max 16 chars; values: max 512 chars.
205
+ */
206
+ metadata?: { [key: string]: string } | null;
207
+
208
+ /**
209
+ * Processor to use for the monitor. `lite` is faster and cheaper; `base` performs
210
+ * more thorough analysis at higher cost and latency. Defaults to `lite`.
211
+ */
212
+ processor?: 'lite' | 'base';
213
+
214
+ /**
215
+ * Webhook configuration for a monitor.
216
+ */
217
+ webhook?: MonitorWebhook | null;
218
+ }
219
+
220
+ /**
221
+ * Response object for a monitor.
222
+ *
223
+ * The `type` field at the root determines the concrete shape of `settings`:
224
+ * `event_stream` uses `MonitorEventStreamResponseSettings`, and `snapshot` uses
225
+ * `MonitorSnapshotResponseSettings`. Snapshot monitors also carry an `output`
226
+ * field (`MonitorSnapshotOutput`) with the latest computed state.
227
+ */
228
+ export interface Monitor {
229
+ /**
230
+ * Timestamp of the creation of the monitor, as an RFC 3339 string.
231
+ */
232
+ created_at: string;
233
+
234
+ /**
235
+ * Frequency of the monitor. Format: '<number><unit>' where unit is 'h' (hours),
236
+ * 'd' (days), or 'w' (weeks). Must be between 1h and 30d (inclusive).
237
+ */
238
+ frequency: string;
239
+
240
+ /**
241
+ * ID of the monitor.
242
+ */
243
+ monitor_id: string;
244
+
245
+ /**
246
+ * Processor to use for the monitor. `lite` is faster and cheaper; `base` performs
247
+ * more thorough analysis at higher cost and latency. Defaults to `lite`.
248
+ */
249
+ processor: 'lite' | 'base';
250
+
251
+ /**
252
+ * Type-specific configuration. Shape is determined by `type`:
253
+ * `MonitorEventStreamResponseSettings` for `event_stream`,
254
+ * `MonitorSnapshotResponseSettings` for `snapshot`.
255
+ */
256
+ settings: MonitorEventStreamResponseSettings | MonitorSnapshotResponseSettings;
257
+
258
+ /**
259
+ * Status of the monitor.
260
+ */
261
+ status: 'active' | 'cancelled';
262
+
263
+ /**
264
+ * The type of monitor.
265
+ */
266
+ type: 'event_stream' | 'snapshot';
267
+
268
+ /**
269
+ * Timestamp of the last run for the monitor, as an RFC 3339 string.
270
+ */
271
+ last_run_at?: string | null;
272
+
273
+ /**
274
+ * User-provided metadata stored with the monitor and echoed back in webhook
275
+ * notifications and GET responses, so you can map events to objects in your
276
+ * application. Keys: max 16 chars; values: max 512 chars.
277
+ */
278
+ metadata?: { [key: string]: string } | null;
279
+
280
+ /**
281
+ * Runtime output state for a `snapshot` monitor.
282
+ */
283
+ output?: MonitorSnapshotOutput | null;
284
+
285
+ /**
286
+ * Webhook configuration for a monitor.
287
+ */
288
+ webhook?: MonitorWebhook | null;
289
+ }
290
+
291
+ /**
292
+ * Emitted when a monitor execution ran but detected no material changes.
293
+ *
294
+ * Only returned when `include_completions=true` is passed to the list events
295
+ * endpoint. Useful for auditing execution history alongside content events.
296
+ */
297
+ export interface MonitorCompletionEvent {
298
+ /**
299
+ * Timestamp of when the monitor execution completed, as an RFC 3339 string.
300
+ */
301
+ timestamp: string;
302
+
303
+ /**
304
+ * Discriminant for the completion event variant.
305
+ */
306
+ event_type?: 'completion';
307
+ }
308
+
309
+ /**
310
+ * Emitted when a monitor execution failed (e.g. payment or quota error).
311
+ *
312
+ * Always included in the events list regardless of `include_completions`.
313
+ */
314
+ export interface MonitorErrorEvent {
315
+ /**
316
+ * Human-readable description of the failure.
317
+ */
318
+ error_message: string;
319
+
320
+ /**
321
+ * Timestamp of when the monitor execution failed, as an RFC 3339 string.
322
+ */
323
+ timestamp: string;
324
+
325
+ /**
326
+ * Discriminant for the error event variant.
327
+ */
328
+ event_type?: 'error';
329
+ }
330
+
331
+ /**
332
+ * Append-only event from an event_stream monitor.
333
+ *
334
+ * Each event represents a distinct material change detected since the previous
335
+ * execution. Events are net-new relative to the cursor; clients should treat them
336
+ * as an append-only log.
337
+ */
338
+ export interface MonitorEventStreamEvent {
339
+ /**
340
+ * Date when this event was produced. ISO 8601 date (YYYY-MM-DD) or partial
341
+ * (YYYY-MM or YYYY).
342
+ */
343
+ event_date: string | null;
344
+
345
+ /**
346
+ * ID of the event group that owns this event.
347
+ */
348
+ event_group_id: string;
349
+
350
+ /**
351
+ * Stable identifier for this event. Safe to use for client-side deduplication
352
+ * across pagination and retries.
353
+ */
354
+ event_id: string;
355
+
356
+ /**
357
+ * Text or JSON output describing the detected change.
358
+ */
359
+ output: TaskRunAPI.TaskRunTextOutput | TaskRunAPI.TaskRunJsonOutput;
360
+
361
+ /**
362
+ * Discriminant for the event_stream event variant.
363
+ */
364
+ event_type?: 'event_stream';
365
+ }
366
+
367
+ /**
368
+ * Type-specific response fields for an `event_stream` monitor.
369
+ */
370
+ export interface MonitorEventStreamResponseSettings {
371
+ /**
372
+ * The search query being monitored.
373
+ */
374
+ query: string;
375
+
376
+ /**
377
+ * Advanced monitor configuration.
378
+ */
379
+ advanced_settings?: AdvancedMonitorSettings | null;
380
+
381
+ /**
382
+ * If true, the first execution returns a sample of recent historical events
383
+ * matching the query (preview only — not exhaustive). If false or omitted, only
384
+ * events from the monitor's creation date onward are returned. Subsequent
385
+ * executions are always incremental.
386
+ */
387
+ include_backfill?: boolean | null;
388
+
389
+ /**
390
+ * JSON schema for a task input or output.
391
+ */
392
+ output_schema?: TaskRunAPI.JsonSchema | null;
393
+ }
394
+
395
+ /**
396
+ * Type-specific settings for an `event_stream` monitor.
397
+ */
398
+ export interface MonitorEventStreamSettings {
399
+ /**
400
+ * Search query to monitor for material changes.
401
+ */
402
+ query: string;
403
+
404
+ /**
405
+ * Advanced monitor configuration.
406
+ */
407
+ advanced_settings?: AdvancedMonitorSettings | null;
408
+
409
+ /**
410
+ * If true, the first execution returns a sample of recent historical events
411
+ * matching the query (preview only — not exhaustive). If false or omitted, only
412
+ * events from the monitor's creation date onward are returned. Subsequent
413
+ * executions are always incremental.
414
+ */
415
+ include_backfill?: boolean | null;
416
+
417
+ /**
418
+ * JSON schema for a task input or output.
419
+ */
420
+ output_schema?: TaskRunAPI.JsonSchema | null;
421
+ }
422
+
423
+ /**
424
+ * Snapshot diff event emitted when a monitored task run's output changes.
425
+ *
426
+ * `changed_output` contains only the fields that changed since the previous
427
+ * execution, along with their `basis` (reasoning + citations). `previous_output`
428
+ * holds the complete output from the prior run for comparison.
429
+ */
430
+ export interface MonitorSnapshotEvent {
431
+ /**
432
+ * Partial output containing only the fields that changed since the previous
433
+ * execution, each with its `basis` (reasoning and citations).
434
+ */
435
+ changed_output: TaskRunAPI.TaskRunTextOutput | TaskRunAPI.TaskRunJsonOutput;
436
+
437
+ /**
438
+ * Date when this event was produced. ISO 8601 date (YYYY-MM-DD) or partial
439
+ * (YYYY-MM or YYYY).
440
+ */
441
+ event_date: string | null;
442
+
443
+ /**
444
+ * ID of the event group that owns this event.
445
+ */
446
+ event_group_id: string;
447
+
448
+ /**
449
+ * Stable identifier for this event. Safe to use for client-side deduplication
450
+ * across pagination and retries.
451
+ */
452
+ event_id: string;
453
+
454
+ /**
455
+ * The full output from the prior run, including all fields and basis.
456
+ */
457
+ previous_output: TaskRunAPI.TaskRunTextOutput | TaskRunAPI.TaskRunJsonOutput;
458
+
459
+ /**
460
+ * Discriminant for the snapshot event variant.
461
+ */
462
+ event_type?: 'snapshot';
463
+ }
464
+
465
+ /**
466
+ * Runtime output state for a `snapshot` monitor.
467
+ */
468
+ export interface MonitorSnapshotOutput {
469
+ /**
470
+ * Task run output from the most recent completed execution of this snapshot
471
+ * monitor — same structure as the output of the original task run the monitor was
472
+ * created from. `null` until the first run completes.
473
+ */
474
+ latest_snapshot?: TaskRunAPI.TaskRunTextOutput | TaskRunAPI.TaskRunJsonOutput | null;
475
+ }
476
+
477
+ /**
478
+ * Configuration settings for a `snapshot` monitor.
479
+ */
480
+ export interface MonitorSnapshotResponseSettings {
481
+ /**
482
+ * The original task input from the baseline task run that this monitor tracks.
483
+ */
484
+ query: string;
485
+
486
+ /**
487
+ * ID of the task run used as the monitoring baseline.
488
+ */
489
+ task_run_id: string;
490
+
491
+ /**
492
+ * JSON schema for a task input or output.
493
+ */
494
+ output_schema?: TaskRunAPI.JsonSchema | null;
495
+ }
496
+
497
+ /**
498
+ * Type-specific settings for a `snapshot` monitor.
499
+ */
500
+ export interface MonitorSnapshotSettings {
501
+ /**
502
+ * Task run ID whose output becomes the data and schema for the monitor.
503
+ */
504
+ task_run_id: string;
505
+ }
506
+
507
+ /**
508
+ * Webhook configuration for a monitor.
509
+ */
510
+ export interface MonitorWebhook {
511
+ /**
512
+ * URL for the webhook.
513
+ */
514
+ url: string;
515
+
516
+ /**
517
+ * Event types to send the webhook notifications for.
518
+ */
519
+ event_types?: Array<'monitor.event.detected' | 'monitor.execution.completed' | 'monitor.execution.failed'>;
520
+ }
521
+
522
+ /**
523
+ * Paginated list of monitor events, newest first.
524
+ */
525
+ export interface PaginatedMonitorEvents {
526
+ /**
527
+ * Monitor events returned by this request, ordered newest first.
528
+ */
529
+ events: Array<MonitorEventStreamEvent | MonitorSnapshotEvent | MonitorCompletionEvent | MonitorErrorEvent>;
530
+
531
+ /**
532
+ * Pass as `cursor` to retrieve more events. Absent when there are no more events.
533
+ */
534
+ next_cursor?: string | null;
535
+
536
+ /**
537
+ * Execution caveats for this page of events, e.g. compute limits.
538
+ */
539
+ warnings?: Array<Shared.Warning> | null;
540
+ }
541
+
542
+ /**
543
+ * Paginated list of monitors.
544
+ */
545
+ export interface PaginatedMonitorResponse {
546
+ /**
547
+ * List of monitors for the current page.
548
+ */
549
+ monitors: Array<Monitor>;
550
+
551
+ /**
552
+ * Opaque pagination token. Pass as `cursor` to retrieve the next page. Absent when
553
+ * there are no more pages.
554
+ */
555
+ next_cursor?: string | null;
556
+ }
557
+
558
+ /**
559
+ * Type-specific update settings for an `event_stream` monitor.
560
+ */
561
+ export interface UpdateMonitorEventStreamSettings {
562
+ /**
563
+ * Advanced monitor configuration.
564
+ */
565
+ advanced_settings?: AdvancedMonitorSettings | null;
566
+ }
567
+
568
+ /**
569
+ * Request body to update a monitor.
570
+ *
571
+ * Only fields that are explicitly included in the request body are updated. Pass
572
+ * `null` for `webhook` or `metadata` to clear those fields. To update
573
+ * type-specific settings on an `event_stream` monitor, include `type` and
574
+ * `settings`; pass `null` for `settings.advanced_settings` to clear it. At least
575
+ * one non-`type` field must be provided.
576
+ */
577
+ export interface UpdateMonitorRequest {
578
+ /**
579
+ * Frequency of the monitor. Format: '<number><unit>' where unit is 'h' (hours),
580
+ * 'd' (days), or 'w' (weeks). Must be between 1h and 30d (inclusive).
581
+ */
582
+ frequency?: string | null;
583
+
584
+ /**
585
+ * User-provided metadata stored with the monitor and echoed back in webhook
586
+ * notifications and GET responses, so you can map events to objects in your
587
+ * application. Keys: max 16 chars; values: max 512 chars.
588
+ */
589
+ metadata?: { [key: string]: string } | null;
590
+
591
+ /**
592
+ * Type-specific update settings for an `event_stream` monitor.
593
+ */
594
+ settings?: UpdateMonitorEventStreamSettings | null;
595
+
596
+ /**
597
+ * Type of the monitor being updated. Required when `settings` is provided; must be
598
+ * `event_stream` (snapshot monitors have no updatable type-specific settings).
599
+ */
600
+ type?: 'event_stream' | 'snapshot' | null;
601
+
602
+ /**
603
+ * Webhook configuration for a monitor.
604
+ */
605
+ webhook?: MonitorWebhook | null;
606
+ }
607
+
608
+ export interface MonitorCreateParams {
609
+ /**
610
+ * Frequency of the monitor. Format: '<number><unit>' where unit is 'h' (hours),
611
+ * 'd' (days), or 'w' (weeks). Must be between 1h and 30d (inclusive).
612
+ */
613
+ frequency: string;
614
+
615
+ /**
616
+ * Type-specific settings for the monitor. The expected shape is determined by the
617
+ * root `type` field: pass `MonitorEventStreamSettings` when `type` is
618
+ * `event_stream`, and `MonitorSnapshotSettings` when `type` is `snapshot`.
619
+ */
620
+ settings: MonitorEventStreamSettings | MonitorSnapshotSettings;
621
+
622
+ /**
623
+ * Type of monitor to create. `event_stream` monitors a search query for material
624
+ * changes; `snapshot` monitors a specific task run's output. Determines the
625
+ * expected shape of `settings`.
626
+ */
627
+ type: 'event_stream' | 'snapshot';
628
+
629
+ /**
630
+ * User-provided metadata stored with the monitor and echoed back in webhook
631
+ * notifications and GET responses, so you can map events to objects in your
632
+ * application. Keys: max 16 chars; values: max 512 chars.
633
+ */
634
+ metadata?: { [key: string]: string } | null;
635
+
636
+ /**
637
+ * Processor to use for the monitor. `lite` is faster and cheaper; `base` performs
638
+ * more thorough analysis at higher cost and latency. Defaults to `lite`.
639
+ */
640
+ processor?: 'lite' | 'base';
641
+
642
+ /**
643
+ * Webhook configuration for a monitor.
644
+ */
645
+ webhook?: MonitorWebhook | null;
646
+ }
647
+
648
+ export interface MonitorUpdateParams {
649
+ /**
650
+ * Frequency of the monitor. Format: '<number><unit>' where unit is 'h' (hours),
651
+ * 'd' (days), or 'w' (weeks). Must be between 1h and 30d (inclusive).
652
+ */
653
+ frequency?: string | null;
654
+
655
+ /**
656
+ * User-provided metadata stored with the monitor and echoed back in webhook
657
+ * notifications and GET responses, so you can map events to objects in your
658
+ * application. Keys: max 16 chars; values: max 512 chars.
659
+ */
660
+ metadata?: { [key: string]: string } | null;
661
+
662
+ /**
663
+ * Type-specific update settings for an `event_stream` monitor.
664
+ */
665
+ settings?: UpdateMonitorEventStreamSettings | null;
666
+
667
+ /**
668
+ * Type of the monitor being updated. Required when `settings` is provided; must be
669
+ * `event_stream` (snapshot monitors have no updatable type-specific settings).
670
+ */
671
+ type?: 'event_stream' | 'snapshot' | null;
672
+
673
+ /**
674
+ * Webhook configuration for a monitor.
675
+ */
676
+ webhook?: MonitorWebhook | null;
677
+ }
678
+
679
+ export interface MonitorListParams {
680
+ /**
681
+ * Pagination token from `next_cursor` in a previous response. Omit to start from
682
+ * the most recently created monitor.
683
+ */
684
+ cursor?: string | null;
685
+
686
+ /**
687
+ * Maximum number of monitors to return. Defaults to 100. Between 1 and 10000.
688
+ */
689
+ limit?: number | null;
690
+
691
+ /**
692
+ * Filter by monitor status. Pass multiple times to filter by multiple values.
693
+ * Defaults to `active` only.
694
+ */
695
+ status?: Array<'active' | 'cancelled'> | null;
696
+
697
+ /**
698
+ * Filter by monitor type. Pass multiple times to filter by multiple values. Omit
699
+ * to return all types.
700
+ */
701
+ type?: Array<'event_stream' | 'snapshot'> | null;
702
+ }
703
+
704
+ export interface MonitorEventsParams {
705
+ /**
706
+ * Pass `next_cursor` from a previous response to retrieve more events.
707
+ */
708
+ cursor?: string | null;
709
+
710
+ /**
711
+ * Filter to a single execution. Values come from `event_group_id` in webhook
712
+ * events and listed events. Pagination params are ignored when set.
713
+ */
714
+ event_group_id?: string | null;
715
+
716
+ /**
717
+ * When true, include completion events for executions that ran but detected no
718
+ * material changes. Useful for auditing execution history.
719
+ */
720
+ include_completions?: boolean;
721
+
722
+ /**
723
+ * Maximum number of events to return. Defaults to 20. Between 1 and 100.
724
+ */
725
+ limit?: number | null;
726
+ }
727
+
728
+ export declare namespace MonitorResource {
729
+ export {
730
+ type AdvancedMonitorSettings as AdvancedMonitorSettings,
731
+ type CreateMonitorRequest as CreateMonitorRequest,
732
+ type Monitor as Monitor,
733
+ type MonitorCompletionEvent as MonitorCompletionEvent,
734
+ type MonitorErrorEvent as MonitorErrorEvent,
735
+ type MonitorEventStreamEvent as MonitorEventStreamEvent,
736
+ type MonitorEventStreamResponseSettings as MonitorEventStreamResponseSettings,
737
+ type MonitorEventStreamSettings as MonitorEventStreamSettings,
738
+ type MonitorSnapshotEvent as MonitorSnapshotEvent,
739
+ type MonitorSnapshotOutput as MonitorSnapshotOutput,
740
+ type MonitorSnapshotResponseSettings as MonitorSnapshotResponseSettings,
741
+ type MonitorSnapshotSettings as MonitorSnapshotSettings,
742
+ type MonitorWebhook as MonitorWebhook,
743
+ type PaginatedMonitorEvents as PaginatedMonitorEvents,
744
+ type PaginatedMonitorResponse as PaginatedMonitorResponse,
745
+ type UpdateMonitorEventStreamSettings as UpdateMonitorEventStreamSettings,
746
+ type UpdateMonitorRequest as UpdateMonitorRequest,
747
+ type MonitorCreateParams as MonitorCreateParams,
748
+ type MonitorUpdateParams as MonitorUpdateParams,
749
+ type MonitorListParams as MonitorListParams,
750
+ type MonitorEventsParams as MonitorEventsParams,
751
+ };
752
+ }