deepline 0.3.325 → 0.3.327

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 (128) hide show
  1. package/dist/bundling-sources/sdk/src/client.ts +23 -25
  2. package/dist/bundling-sources/sdk/src/compat.ts +11 -6
  3. package/dist/bundling-sources/sdk/src/db/query.ts +172 -0
  4. package/dist/bundling-sources/sdk/src/errors.ts +35 -0
  5. package/dist/bundling-sources/sdk/src/index.ts +13 -0
  6. package/dist/bundling-sources/sdk/src/play.ts +34 -31
  7. package/dist/bundling-sources/sdk/src/plays/authoring-graph-path.ts +13 -0
  8. package/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +2 -1
  9. package/dist/bundling-sources/sdk/src/plays/local-play-execution.ts +189 -0
  10. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  11. package/dist/bundling-sources/sdk/src/tool-calls.ts +1 -1
  12. package/dist/bundling-sources/shared_libs/play-runtime/projection.ts +11 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +98 -11
  14. package/dist/cli/auth-67YOPQ6M.js +31 -0
  15. package/dist/cli/{auth-PIZESRPC.mjs → auth-EBBDOKNV.mjs} +4 -4
  16. package/dist/cli/{billing-DQKFCQV5.js → billing-6AAB7WPJ.js} +70 -70
  17. package/dist/cli/{billing-HSL6VTCM.mjs → billing-IM2QUFX4.mjs} +4 -4
  18. package/dist/cli/{chunk-WW4XZIVM.mjs → chunk-3ITDKXNC.mjs} +12 -9
  19. package/dist/cli/{chunk-K7FC5IUU.js → chunk-3MXRNPBN.js} +1 -1
  20. package/dist/cli/{chunk-DLW7X2UK.js → chunk-4TO56P22.js} +5928 -5730
  21. package/dist/cli/{chunk-MNKDSR2J.js → chunk-4ZARCCPT.js} +344 -254
  22. package/dist/cli/{chunk-PBNZXZCW.js → chunk-77RAV5XX.js} +48 -48
  23. package/dist/cli/{chunk-HUKWYHBG.js → chunk-7RCJDAJX.js} +2 -2
  24. package/dist/cli/{chunk-5TYU3UIS.mjs → chunk-A5SKM3GL.mjs} +1 -1
  25. package/dist/cli/{chunk-XNL3SEMC.js → chunk-AFNEQ43J.js} +8 -3
  26. package/dist/cli/{chunk-XSEMQ4II.js → chunk-AGH6YP2T.js} +2 -1
  27. package/dist/cli/chunk-AID3OYVJ.js +8 -0
  28. package/dist/cli/{chunk-YE3O2UHM.mjs → chunk-CCRQ2VGJ.mjs} +24 -1
  29. package/dist/cli/{chunk-HPTQEWCF.js → chunk-CISKBOXD.js} +70 -67
  30. package/dist/cli/{chunk-OPERWJR6.mjs → chunk-D6GD5AVN.mjs} +3 -3
  31. package/dist/cli/{chunk-6RMKHN7S.mjs → chunk-DCAU6PND.mjs} +4 -20
  32. package/dist/cli/{chunk-PVDQ55PS.js → chunk-DM3SHV6U.js} +29 -6
  33. package/dist/cli/{chunk-CV5GDCKN.js → chunk-DSDX6EUW.js} +29 -45
  34. package/dist/cli/{chunk-5FHU7TV4.mjs → chunk-DVV4FPS7.mjs} +2 -2
  35. package/dist/cli/{chunk-AQUNQJ5Y.mjs → chunk-F45425TB.mjs} +1 -1
  36. package/dist/cli/{chunk-NWBARG3F.mjs → chunk-G5774EFF.mjs} +1 -1
  37. package/dist/cli/chunk-GVESPYSY.mjs +234 -0
  38. package/dist/cli/{chunk-H5TJBRSC.mjs → chunk-HOWQKN6J.mjs} +98 -113
  39. package/dist/cli/{chunk-UYFWTIKF.js → chunk-HZZJR2GV.js} +26 -26
  40. package/dist/cli/{chunk-76VKBPOC.mjs → chunk-JOA6IKDE.mjs} +7 -2
  41. package/dist/cli/chunk-LVEDPCLJ.js +234 -0
  42. package/dist/cli/{chunk-KZNFYOHX.js → chunk-MOP6D7Z5.js} +6 -6
  43. package/dist/cli/{chunk-YXRPWMGN.js → chunk-NWIJLTRL.js} +147 -162
  44. package/dist/cli/chunk-OVDNJAJN.mjs +8 -0
  45. package/dist/cli/{chunk-XIVUB36F.mjs → chunk-QZAP5VOS.mjs} +104 -14
  46. package/dist/cli/{chunk-6VZDSBK6.mjs → chunk-REP2MYBI.mjs} +2 -2
  47. package/dist/cli/{chunk-PWV2M4LW.mjs → chunk-RSEVBSFE.mjs} +1 -1
  48. package/dist/cli/{chunk-OOPSX57I.js → chunk-TAGHNT5P.js} +6 -6
  49. package/dist/cli/{chunk-QQ2FG5W3.js → chunk-UROXKPND.js} +6 -6
  50. package/dist/cli/{chunk-7PZFGB7L.mjs → chunk-YIY74KUF.mjs} +2 -1
  51. package/dist/cli/{chunk-7MD453WV.mjs → chunk-ZOFARJWH.mjs} +5674 -5476
  52. package/dist/cli/client-7LZCG4VD.js +20 -0
  53. package/dist/cli/{client-57SR4KVM.mjs → client-JCMSACT4.mjs} +3 -3
  54. package/dist/cli/{csv-G2FRMOXL.mjs → csv-NPMWVM5D.mjs} +3 -3
  55. package/dist/cli/{csv-5DJSC6BD.js → csv-OILKDKUX.js} +12 -12
  56. package/dist/cli/{db-WWZEXM3N.mjs → db-AZUAOWPQ.mjs} +214 -137
  57. package/dist/cli/{db-NVO7P4VO.js → db-MNDRYYEX.js} +226 -149
  58. package/dist/cli/{describe-26OMF3A4.mjs → describe-KJWOHMKC.mjs} +12 -11
  59. package/dist/cli/{describe-M26LHDBQ.js → describe-QENLDLM2.js} +28 -27
  60. package/dist/cli/{executions-KI47LPKE.js → executions-P36UHBPG.js} +6 -6
  61. package/dist/cli/{executions-2LLHY3IL.mjs → executions-QZNQWF6F.mjs} +4 -4
  62. package/dist/cli/{feedback-2Y26C2BZ.js → feedback-K4UGTLFD.js} +6 -6
  63. package/dist/cli/{feedback-O26VL2OF.mjs → feedback-RQ6HSZSG.mjs} +3 -3
  64. package/dist/cli/{git-UVPGZN3K.mjs → git-PBRMCBMI.mjs} +4 -4
  65. package/dist/cli/git-RPFH3NJ2.js +23 -0
  66. package/dist/cli/index.js +105 -87
  67. package/dist/cli/index.mjs +65 -47
  68. package/dist/cli/{legacy-noops-IK5CH72U.mjs → legacy-noops-G7GWJ5UC.mjs} +4 -4
  69. package/dist/cli/{legacy-noops-H6Y3SEVB.js → legacy-noops-X74FM35Q.js} +7 -7
  70. package/dist/cli/{monitors-SFVVMAJT.mjs → monitors-KL2MCR57.mjs} +4 -4
  71. package/dist/cli/{monitors-JL6TTQCI.js → monitors-VKURX3YM.js} +85 -85
  72. package/dist/cli/{org-SSDONL57.mjs → org-DT53KTNW.mjs} +4 -4
  73. package/dist/cli/{org-OVMAZCQS.js → org-ZYXJDC44.js} +60 -60
  74. package/dist/cli/play-BUQV47E2.js +153 -0
  75. package/dist/cli/{play-X6NPACUO.mjs → play-WIJGQYTB.mjs} +11 -10
  76. package/dist/cli/{providers-E24JDWSR.js → providers-GRTW4TXX.js} +7 -7
  77. package/dist/cli/{providers-ONUBYYY4.mjs → providers-GYGKGS2J.mjs} +4 -4
  78. package/dist/cli/{quickstart-TB7C3DLG.js → quickstart-WB26543C.js} +5 -5
  79. package/dist/cli/{quickstart-B7NIXACV.mjs → quickstart-XF3M2M2S.mjs} +3 -3
  80. package/dist/cli/{search-N3QUIATW.mjs → search-ANJLTOF2.mjs} +5 -5
  81. package/dist/cli/search-CR2GZLCM.js +26 -0
  82. package/dist/cli/{secrets-CPCVFDYB.js → secrets-5KBUGMTK.js} +13 -13
  83. package/dist/cli/{secrets-V7Z4M67T.mjs → secrets-D6UR5CTW.mjs} +4 -4
  84. package/dist/cli/{sessions-E4FIZLQP.js → sessions-46PXFULL.js} +5 -5
  85. package/dist/cli/{sessions-PDOBKAKO.mjs → sessions-S7N4JEWK.mjs} +4 -4
  86. package/dist/cli/{settings-UVM2WDE4.js → settings-KMNBITSU.js} +74 -74
  87. package/dist/cli/{settings-QYHYHZDI.mjs → settings-V6U3SRTH.mjs} +7 -7
  88. package/dist/cli/{setup-3JFAXQLJ.js → setup-4K5FY6AU.js} +41 -41
  89. package/dist/cli/{setup-4RLAETDW.mjs → setup-OGITSLTN.mjs} +6 -6
  90. package/dist/cli/skills-4FP2MZKL.js +28 -0
  91. package/dist/cli/{skills-ZX2JSWOZ.mjs → skills-AXWAYPBY.mjs} +4 -4
  92. package/dist/cli/tools-7YZPH6WC.js +39 -0
  93. package/dist/cli/{tools-EGXCVIPJ.mjs → tools-LJCY6B23.mjs} +8 -7
  94. package/dist/cli/update-3VUOW6AP.js +28 -0
  95. package/dist/cli/{update-7FEKRQFE.mjs → update-DDR5XIUB.mjs} +6 -6
  96. package/dist/cli/{workflow-54VCKIG2.js → workflow-7CTCDWL3.js} +15 -15
  97. package/dist/cli/{workflow-7V7TTTKK.mjs → workflow-PRNCVANQ.mjs} +5 -5
  98. package/dist/{client-Bb4Jjzmj.d.ts → client-DHq8dJ56.d.ts} +39 -11
  99. package/dist/{client-COa-3GHK.d.mts → client-wiWPZhnI.d.mts} +39 -11
  100. package/dist/{compiler-manifest-CsnWj-AK.d.mts → compiler-manifest-9TkZ_ykI.d.mts} +711 -711
  101. package/dist/{compiler-manifest-CsnWj-AK.d.ts → compiler-manifest-9TkZ_ykI.d.ts} +711 -711
  102. package/dist/index-B-5_Xhud.d.mts +75 -0
  103. package/dist/index-ykksoEyR.d.ts +75 -0
  104. package/dist/index.d.mts +52 -13
  105. package/dist/index.d.ts +52 -13
  106. package/dist/index.js +142 -68
  107. package/dist/index.mjs +102 -28
  108. package/dist/install-integrity.json +91 -84
  109. package/dist/plays/bundle-play-file.d.mts +7 -75
  110. package/dist/plays/bundle-play-file.d.ts +7 -75
  111. package/dist/plays/bundle-play-file.mjs +1 -1
  112. package/dist/plays/run-request.d.mts +2 -2
  113. package/dist/plays/run-request.d.ts +2 -2
  114. package/dist/release.d.mts +1 -1
  115. package/dist/release.d.ts +1 -1
  116. package/dist/release.js +2 -2
  117. package/dist/release.mjs +1 -1
  118. package/package.json +1 -1
  119. package/dist/cli/auth-RXCD4GOV.js +0 -31
  120. package/dist/cli/chunk-OWJZUE3Y.mjs +0 -103
  121. package/dist/cli/chunk-SDK3ZA2C.js +0 -103
  122. package/dist/cli/client-562MULXK.js +0 -20
  123. package/dist/cli/git-KGPX5YPD.js +0 -23
  124. package/dist/cli/play-3DB4MSHN.js +0 -152
  125. package/dist/cli/search-NJ637YGQ.js +0 -26
  126. package/dist/cli/skills-BYRYG64R.js +0 -28
  127. package/dist/cli/tools-TAWOAY5X.js +0 -38
  128. package/dist/cli/update-H24GEBXM.js +0 -28
@@ -2,765 +2,765 @@
2
2
  import * as _sinclair_typebox from '@sinclair/typebox';
3
3
  import { Static } from '@sinclair/typebox';
4
4
 
5
- type EmailStatusVerdict = 'send' | 'send_with_caution' | 'verify_next' | 'hold' | 'drop';
6
- type EmailStatusValue = 'valid' | 'invalid' | 'catch_all' | 'valid_catch_all' | 'unknown' | 'do_not_mail' | 'spamtrap' | 'abuse' | 'disposable';
7
- type EmailDeliverability = 'high' | 'medium' | 'low' | 'unknown';
8
- type EmailMxClass = 'consumer_mailbox' | 'workspace_mailbox' | 'security_gateway' | 'on_prem' | 'unknown';
9
- type EmailStatus = {
10
- verdict: EmailStatusVerdict;
11
- status: EmailStatusValue;
12
- verified: boolean;
13
- confidence: number | null;
14
- reasons: string[];
15
- signals: {
16
- catch_all: boolean | null;
17
- deliverability: EmailDeliverability;
18
- mx_class: EmailMxClass;
19
- mx_provider: string | null;
20
- mx_record: string | null;
21
- fraud_score: number | null;
22
- disposable: boolean | null;
23
- role_based: boolean | null;
24
- free_email: boolean | null;
25
- abuse: boolean | null;
26
- spamtrap: boolean | null;
27
- suspect: boolean | null;
28
- valid: boolean | null;
29
- };
30
- provider: {
31
- name: string;
32
- raw_status: string | boolean | number | null;
33
- raw_score: number | null;
34
- };
35
- };
36
- type EmailStatusMapEntry = {
37
- status: EmailStatusValue;
38
- verdict?: EmailStatusVerdict;
39
- verified?: boolean;
40
- reason?: string;
41
- };
42
- type EmailStatusRule = EmailStatusMapEntry & {
43
- when: Record<string, string | number | boolean | null>;
44
- };
45
- type EmailStatusExtractorConfig = {
46
- provider: string;
47
- rawStatus?: string[];
48
- rawScore?: string[];
49
- valid?: string[];
50
- deliverability?: string[];
51
- catchAll?: string[];
52
- mxProvider?: string[];
53
- mxRecord?: string[];
54
- fraudScore?: string[];
55
- disposable?: string[];
56
- roleBased?: string[];
57
- freeEmail?: string[];
58
- abuse?: string[];
59
- spamtrap?: string[];
60
- suspect?: string[];
61
- statusMap?: Record<string, EmailStatusMapEntry>;
62
- rules?: EmailStatusRule[];
63
- };
64
-
65
- declare const JOB_CHANGE_STATUS_VALUES: readonly ["moved", "no_change", "left_company", "unknown", "profile_unavailable", "no_new_company"];
66
- type JobChangeStatus = (typeof JOB_CHANGE_STATUS_VALUES)[number];
67
- type JobChangeGetterValue = {
68
- status: JobChangeStatus;
69
- date: string | null;
70
- new_company: string | null;
71
- new_title: string | null;
72
- };
73
- declare const PHONE_STATUS_VALUES: readonly ["valid", "invalid", "unknown"];
74
- type PhoneStatus = (typeof PHONE_STATUS_VALUES)[number];
75
- declare const DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS: {
76
- readonly id: {
77
- readonly identity: true;
78
- readonly valueKind: "string";
79
- };
80
- readonly name: {
81
- readonly identity: true;
82
- readonly valueKind: "string";
83
- };
84
- readonly email: {
85
- readonly identity: true;
86
- readonly valueKind: "string";
87
- };
88
- readonly personal_email: {
89
- readonly identity: true;
90
- readonly valueKind: "string";
91
- };
92
- readonly phone: {
93
- readonly identity: true;
94
- readonly valueKind: "string";
95
- };
96
- readonly linkedin: {
97
- readonly identity: true;
98
- readonly valueKind: "string";
99
- };
100
- readonly linkedin_url: {
101
- readonly identity: true;
102
- readonly valueKind: "string";
103
- };
104
- readonly domain: {
105
- readonly identity: true;
106
- readonly valueKind: "string";
107
- };
108
- readonly website: {
109
- readonly identity: true;
110
- readonly valueKind: "string";
111
- };
112
- readonly first_name: {
113
- readonly identity: true;
114
- readonly valueKind: "string";
115
- };
116
- readonly last_name: {
117
- readonly identity: true;
118
- readonly valueKind: "string";
119
- };
120
- readonly full_name: {
121
- readonly identity: true;
122
- readonly valueKind: "string";
123
- };
124
- readonly company: {
125
- readonly identity: true;
126
- readonly valueKind: "string";
127
- };
128
- readonly company_name: {
129
- readonly identity: true;
130
- readonly valueKind: "string";
131
- };
132
- readonly organization_name: {
133
- readonly identity: true;
134
- readonly valueKind: "string";
135
- };
136
- readonly company_domain: {
137
- readonly identity: true;
138
- readonly valueKind: "string";
139
- };
140
- readonly company_website: {
141
- readonly identity: true;
142
- readonly valueKind: "string";
143
- };
144
- readonly company_linkedin_url: {
145
- readonly identity: true;
146
- readonly valueKind: "string";
147
- };
148
- readonly title: {
149
- readonly identity: false;
150
- readonly valueKind: "string";
151
- };
152
- readonly industry: {
153
- readonly identity: false;
154
- readonly valueKind: "string";
155
- };
156
- readonly status: {
157
- readonly identity: false;
158
- readonly valueKind: "string";
159
- };
160
- readonly job_change: {
161
- readonly identity: false;
162
- readonly valueKind: "job_change";
163
- };
164
- readonly job_change_status: {
165
- readonly identity: false;
166
- readonly valueKind: "job_change_status";
167
- readonly enum: readonly ["moved", "no_change", "left_company", "unknown", "profile_unavailable", "no_new_company"];
168
- };
169
- readonly email_status: {
170
- readonly identity: false;
171
- readonly valueKind: "email_status";
172
- };
173
- readonly phone_status: {
174
- readonly identity: false;
175
- readonly valueKind: "phone_status";
176
- readonly enum: readonly ["valid", "invalid", "unknown"];
177
- };
178
- };
179
- type DeeplineExtractorTarget = keyof typeof DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS;
180
- declare const DEEPLINE_EXTRACTOR_TARGETS: DeeplineExtractorTarget[];
181
- type DeeplineEmailStatusGetterValue = EmailStatus;
182
- type DeeplineGetterValueMap = {
183
- id: string;
184
- name: string;
185
- email: string;
186
- personal_email: string;
187
- phone: string;
188
- linkedin: string;
189
- linkedin_url: string;
190
- domain: string;
191
- website: string;
192
- first_name: string;
193
- last_name: string;
194
- full_name: string;
195
- company: string;
196
- company_name: string;
197
- organization_name: string;
198
- company_domain: string;
199
- company_website: string;
200
- company_linkedin_url: string;
201
- title: string;
202
- industry: string;
203
- status: string;
204
- job_change: JobChangeGetterValue;
205
- job_change_status: JobChangeStatus;
206
- email_status: EmailStatus;
207
- phone_status: PhoneStatus;
208
- };
209
- type DeeplineGetterValue<TTarget extends DeeplineExtractorTarget = DeeplineExtractorTarget> = DeeplineGetterValueMap[TTarget];
210
- declare function isDeeplineExtractorTarget(value: string): value is DeeplineExtractorTarget;
211
-
212
- interface PlayR2FileRef {
213
- storageKind: 'r2';
214
- storageKey: string;
215
- logicalPath: string;
216
- fileName: string;
217
- contentHash: string;
218
- contentType: string;
219
- bytes: number;
220
- }
221
- type PlayExecutionFileRef = PlayR2FileRef;
222
-
223
- /** Source evidence is advisory; stored values determine lossless SQL encoding. */
224
- interface PlayDatasetColumnTypeEvidence {
225
- postgresTypeId: number;
226
- valueType: 'boolean' | 'number' | 'string' | 'json';
227
- }
228
- type PlayDatasetColumnTypes = Record<string, PlayDatasetColumnTypeEvidence>;
229
- type PlaySheetColumnSource = 'input' | 'datasetColumn' | 'waterfallStep' | 'childPlayColumn';
230
- interface PlaySheetColumnContract {
231
- id: string;
232
- sqlName: string;
233
- source: PlaySheetColumnSource;
234
- field?: string;
235
- parentField?: string;
236
- playId?: string;
237
- waterfallId?: string;
238
- outputField?: string;
239
- outputSqlName?: string;
240
- stepId?: string;
241
- toolId?: string;
242
- isRowKey?: boolean;
243
- typeEvidence?: PlayDatasetColumnTypeEvidence;
244
- }
245
- interface PlaySheetContract {
246
- tableNamespace: string;
247
- columns: PlaySheetColumnContract[];
248
- }
249
-
250
- declare const PLAY_DATASET_BRAND: unique symbol;
251
- type PlayDatasetKind = 'csv' | 'map';
252
- type PlayDatasetBacking = {
253
- storage: 'neon_sheet';
254
- sheet: {
255
- playName: string;
256
- tableNamespace: string;
257
- };
258
- } | {
259
- storage: 'r2_file';
260
- file: PlayExecutionFileRef;
261
- };
262
- type PlayDatasetWorkProgressSummary = {
263
- total: number;
264
- executed: number;
265
- reused: number;
266
- skipped: number;
267
- pending: number;
268
- failed: number;
269
- degraded?: boolean;
270
- duplicates?: {
271
- exact?: number;
272
- semantic?: number;
273
- rejected?: number;
274
- };
275
- };
276
- type PlayDatasetInput<T> = ReadonlyArray<T> | Iterable<T> | AsyncIterable<T> | PlayDataset<T>;
277
- type PlayDatasetRow<TInput> = TInput extends PlayDataset<infer Row> ? Row : TInput extends ReadonlyArray<infer Row> ? Row : TInput extends Iterable<infer Row> ? Row : TInput extends AsyncIterable<infer Row> ? Row : never;
278
- type PlayDatasetTransformOptions = {
279
- key?: string;
280
- sourceLabel?: string | null;
281
- };
5
+ declare const TOOL_EXECUTION_ERROR_SCHEMA_VERSION: 1;
6
+ declare const SUPPORTED_TOOL_EXECUTION_ERROR_SCHEMA_VERSIONS: readonly [0, 1];
7
+ type ToolExecutionErrorSchemaVersion = (typeof SUPPORTED_TOOL_EXECUTION_ERROR_SCHEMA_VERSIONS)[number];
282
8
  /**
283
- * Durable handle for rows produced by `ctx.csv(...)` or `ctx.dataset(...).run()`.
9
+ * The boundary responsible for a failed tool call.
284
10
  *
285
- * A `PlayDataset` is not a normal in-memory array. It points at runtime-managed
286
- * rows, usually backed by persisted sheet storage, and carries metadata such as
287
- * dataset kind, dataset id, table namespace, count, and preview rows.
11
+ * Use `provider` to distinguish a provider answer from caller input and
12
+ * Deepline infrastructure. `unknown` fails closed and must not trigger a
13
+ * waterfall fallback.
288
14
  *
289
- * Pass dataset handles directly into later `ctx.dataset(...)` stages by default so
290
- * Deepline keeps row progress, retries, memory use, and table output under
291
- * runtime control. Use `count()` and `peek()` for bounded inspection. Use
292
- * `materialize(limit)` or async iteration only when the dataset is intentionally
293
- * small and bounded. `PlayDataset` intentionally does not expose `.rows`,
294
- * `.toArray()`, `.length`, numeric indexing, spread, or synchronous iteration;
295
- * these hide loading costs or make behavior depend on row residency.
15
+ * @sdkReference errors 020
16
+ */
17
+ type ToolExecutionErrorOrigin = 'caller' | 'provider' | 'deepline' | 'unknown';
18
+ /**
19
+ * The stable reason family for a failed tool call.
296
20
  *
297
- * @sdkReference runtime 190
21
+ * Branch on this field only after narrowing to `ToolExecutionError`. Catch
22
+ * `ProviderTransientError` when the policy is simply “try the next read
23
+ * provider”; it is the safer and shorter waterfall contract.
24
+ *
25
+ * @sdkReference errors 030
298
26
  */
299
- interface PlayDataset<T> extends AsyncIterable<T> {
300
- readonly [PLAY_DATASET_BRAND]: true;
301
- /** Dataset kind. */
302
- readonly datasetKind: PlayDatasetKind;
303
- /** Dataset id. */
304
- readonly datasetId: string;
305
- /** Backing store info. */
306
- readonly backing?: PlayDatasetBacking;
307
- /** Display label. */
308
- readonly sourceLabel?: string | null;
309
- /** Runtime table name. */
310
- readonly tableNamespace?: string | null;
311
- /** Advisory source types; transformed fields must infer from their values. */
312
- readonly columnTypes?: PlayDatasetColumnTypes;
313
- /** Row count. */
314
- count(): Promise<number>;
315
- /** Preview rows. */
316
- peek(limit?: number): Promise<T[]>;
317
- /** First row, loading it asynchronously when necessary. */
318
- first(): Promise<T | undefined>;
319
- /** Row at an array-style index, loading it asynchronously when necessary. */
320
- at(index: number): Promise<T | undefined>;
321
- map<U>(mapper: (row: T, index: number) => U | Promise<U>, options?: PlayDatasetTransformOptions): PlayDataset<U>;
322
- filter(predicate: (row: T, index: number) => boolean | Promise<boolean>, options?: PlayDatasetTransformOptions): PlayDataset<T>;
323
- slice(start?: number, end?: number, options?: PlayDatasetTransformOptions): PlayDataset<T>;
324
- take(limit: number, options?: PlayDatasetTransformOptions): PlayDataset<T>;
27
+ type ToolExecutionErrorCategory = 'validation' | 'authentication' | 'authorization' | 'rate_limit' | 'network' | 'upstream' | 'billing' | 'conflict' | 'internal' | 'unknown';
28
+ /**
29
+ * The transport failure observed when `category` is `network`.
30
+ *
31
+ * This is `null` for failures that are not network failures.
32
+ *
33
+ * @sdkReference errors 040
34
+ */
35
+ type ToolExecutionNetworkKind = 'timeout' | 'dns' | 'connect' | 'reset' | 'unavailable' | 'unknown';
36
+ /**
37
+ * The request boundary on which a network failure occurred.
38
+ *
39
+ * `deepline_to_provider` is provider-side. Client and runtime scopes are
40
+ * Deepline transport failures and never qualify as provider fallthrough.
41
+ *
42
+ * @sdkReference errors 050
43
+ */
44
+ type ToolExecutionNetworkScope = 'client_to_deepline' | 'runtime_to_deepline' | 'deepline_to_provider';
45
+ /**
46
+ * Bounded, primitive-only diagnostics explicitly approved for customers.
47
+ * Raw provider bodies, credentials, prompts, stacks, and causes never belong
48
+ * in this shared API/SDK/Play contract.
49
+ *
50
+ * @sdkReference errors 063
51
+ */
52
+ type ToolExecutionPublicDetails = Readonly<Record<string, string | number | boolean | null>>;
53
+ /**
54
+ * Portable version-1 `tool_error` payload.
55
+ *
56
+ * This allowlisted shape crosses the API, runtime, and SDK boundaries.
57
+ * `message` remains on the Error object and is deliberately not a policy
58
+ * field.
59
+ *
60
+ * @sdkReference errors 064
61
+ */
62
+ type ToolExecutionFailureV1 = {
63
+ /** Payload version. */
64
+ schemaVersion: typeof TOOL_EXECUTION_ERROR_SCHEMA_VERSION;
65
+ /** Public tool id passed to `tools.execute`. */
66
+ toolId: string;
67
+ /** Provider responsible for the operation, or `null`. */
68
+ provider: string | null;
69
+ /** Provider operation name, or `null`. */
70
+ operation: string | null;
71
+ /** Stable machine-readable failure code, or `null`. */
72
+ code: string | null;
73
+ /** Boundary responsible for the failure. */
74
+ origin: ToolExecutionErrorOrigin;
75
+ /** Stable reason family. */
76
+ category: ToolExecutionErrorCategory;
77
+ /** Whether repeating the same semantic call is delivery-safe. */
78
+ retryable: boolean;
79
+ /** HTTP status when one exists, or `null`. */
80
+ statusCode: number | null;
81
+ /** Provider or Deepline request id, or `null`. */
82
+ requestId: string | null;
83
+ /** Suggested same-call retry delay in milliseconds, or `null`. */
84
+ retryAfterMs: number | null;
85
+ /** Network failure kind, or `null`. */
86
+ networkKind: ToolExecutionNetworkKind | null;
87
+ /** Network boundary that failed, or `null`. */
88
+ networkScope: ToolExecutionNetworkScope | null;
89
+ /** Explicitly allowlisted customer diagnostics, when present. */
90
+ publicDetails?: ToolExecutionPublicDetails | null;
91
+ };
92
+ /**
93
+ * Constructor input for a structured tool failure.
94
+ *
95
+ * Deepline creates these values while decoding the versioned wire payload.
96
+ * Customer code normally reads `ToolExecutionError` fields instead of
97
+ * constructing an error.
98
+ *
99
+ * @sdkReference errors 065
100
+ */
101
+ type ToolExecutionErrorOptions = Omit<ToolExecutionFailureV1, 'schemaVersion'> & {
325
102
  /**
326
- * Explicit escape hatch for bounded result sets.
327
- * Large datasets should flow by handle through Neon-backed storage, not
328
- * through worker memory as giant arrays.
103
+ * Local diagnostic context inherited from DeeplineError. This is not part of
104
+ * the portable failure payload and is intentionally omitted by serialization.
329
105
  */
330
- materialize(options?: number | PlayDatasetMaterializeOptions): Promise<T[]>;
331
- toJSON(): {
332
- kind: 'dataset';
333
- datasetKind: PlayDatasetKind;
334
- datasetId: string;
335
- count: number;
336
- backing?: PlayDatasetBacking;
337
- sourceLabel?: string | null;
338
- tableNamespace?: string | null;
339
- columns?: string[];
340
- columnTypes?: PlayDatasetColumnTypes;
341
- _metadata?: {
342
- workProgress?: PlayDatasetWorkProgressSummary;
343
- };
344
- preview: T[];
345
- };
346
- }
347
- type PlayDatasetMaterializeScope = 'result' | 'full_persisted_dataset';
348
- type PlayDatasetMaterializeOptions = {
349
- /** Rows returned by this operation, or every current row in its persisted dataset. */
350
- scope?: PlayDatasetMaterializeScope;
351
- /** Maximum number of rows to load into memory. */
352
- limit?: number;
106
+ details?: Record<string, unknown>;
353
107
  };
354
-
355
108
  /**
356
- * Customer pricing reported by the execution API, never provider spend.
357
- * `credits_charged` and `cost_usd` describe the price of the original call;
358
- * they do not acknowledge durable handoff or wallet posting. Receipt replay
359
- * preserves this observation and does not imply a new charge or fresher state.
109
+ * Provider-owned failure categories that may fall through to another read
110
+ * provider.
111
+ *
112
+ * @sdkReference errors 060
360
113
  */
361
- type ToolResultBilling = {
362
- credits_charged?: number;
363
- cost_usd?: number;
364
- /** Missing on historical responses. Pending pricing has no final amount. */
365
- pricing_status?: 'final' | 'pending';
366
- settlement_status?: 'pending' | 'queued' | 'settled' | 'released' | 'requires_recovery';
367
- billing_outcome_reason?: 'free_operation' | 'provider_no_billable_result' | 'provider_reported_zero_usage' | 'zero_price';
368
- estimated_credits?: number;
369
- estimated_cost_usd?: number;
370
- /** Preserve additive public pricing details across runtime/deployment skew. */
371
- [key: string]: unknown;
372
- };
373
- type ToolResultExecutionMetadata = {
374
- idempotent: true;
375
- cached: boolean;
376
- source: 'live' | 'checkpoint' | 'cache' | 'in_flight' | 'source_run';
377
- cacheKey?: string;
378
- receiptRole?: 'owner' | 'follower';
379
- receiptKey?: string;
380
- /** Canonical saved result identity; receiptKey may name a transport alias. */
381
- resultReceiptKey?: string;
382
- attachedToReceiptKey?: string;
383
- };
384
- type ToolResultTargetMetadata = {
385
- value: unknown;
386
- path: string;
387
- };
388
- type ToolResultListMetadata = {
389
- path: string;
390
- count: number | null;
391
- keys: Record<string, string>;
392
- };
393
- type ToolResultExtractorDescriptor = {
394
- paths: readonly string[];
395
- transforms?: readonly string[];
396
- enum?: readonly string[];
397
- overrides?: readonly ToolResultExtractorOverride[];
398
- emailStatus?: EmailStatusExtractorConfig;
399
- };
400
- type ToolResultExtractorOverride = {
401
- paths: readonly string[];
402
- equals?: string | number | boolean | null;
403
- value: string | number | boolean | null;
404
- };
405
- type ToolResultTargetAccessor<T = unknown> = ToolResultTargetMetadata & {
406
- get(): T | null;
407
- };
408
- type ToolResultListAccessor<T = Record<string, unknown>, TKey extends string = string> = Omit<ToolResultListMetadata, 'keys'> & {
409
- keys: Partial<Record<TKey, string>> & Record<string, string>;
410
- get(): PlayDataset<T>;
411
- };
412
- type ToolResponseEnvelope<TData = unknown, TMeta = Record<string, unknown>> = {
413
- /** @deprecated Use declared getters or toolResponse.rawV2. */
414
- raw: TData;
415
- /** Complete parsed and scrubbed provider response, materialized from raw-v2. */
416
- rawV2?: unknown;
417
- /** Durable descriptor for deriving the legacy raw view from `rawV2`. */
418
- view?: 'data' | 'rawV2';
419
- meta?: TMeta;
420
- };
421
- type ToolExecuteResultBase<TResult = unknown, TMeta = Record<string, unknown>> = {
422
- status: string;
423
- job_id?: string;
424
- /** Deepline-owned execution/result metadata. */
425
- meta?: Record<string, unknown>;
426
- billing?: ToolResultBilling;
427
- toolResponse: ToolResponseEnvelope<TResult, TMeta>;
428
- extractedValues: Record<string, ToolResultTargetAccessor>;
429
- extractedLists: Record<string, ToolResultListAccessor>;
430
- /** Convenience alias for play code. Serialized output uses toolResponse. */
431
- toolOutput: ToolResponseEnvelope<TResult, TMeta>;
432
- _metadata: {
433
- toolId: string;
434
- execution: ToolResultExecutionMetadata;
435
- targets: Record<string, {
436
- value: unknown;
437
- path: string;
438
- }>;
439
- extractors?: Record<string, ToolResultExtractorDescriptor>;
440
- lists: Record<string, {
441
- path: string;
442
- count: number | null;
443
- keys: Record<string, string>;
444
- }>;
445
- /** Original declarations preserve semantic accessor names across replay. */
446
- listExtractorPaths?: readonly string[];
447
- };
448
- };
449
- type ToolExecuteResultAccessors<TExtracted extends Record<string, unknown> = Partial<DeeplineGetterValueMap>, TLists extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>> = {
450
- extractedValues: {
451
- [K in keyof TExtracted]: ToolResultTargetAccessor<TExtracted[K]>;
452
- };
453
- extractedLists: {
454
- [K in keyof TLists]: ToolResultListAccessor<TLists[K]>;
455
- };
456
- };
114
+ type ProviderTransientErrorCategory = 'rate_limit' | 'network' | 'upstream';
457
115
  /**
458
- * Canonical result returned by Deepline tool execution.
116
+ * Base error class shared by the SDK and play runtime.
459
117
  *
460
- * The top-level object is Deepline-owned execution metadata and semantic
461
- * extraction state. The canonical provider response lives under
462
- * `toolResponse.rawV2`. Response metadata lives under `toolResponse.meta`. Semantic single-value
463
- * getters live under `extractedValues.<name>.get()`, and list getters live
464
- * under `extractedLists.<name>.get()`.
118
+ * The global brand preserves `instanceof DeeplineError` when a bundled play
119
+ * and the runtime load separate physical copies of this module.
465
120
  *
466
- * Use extractors first when a tool contract exposes them. Use list getters for
467
- * row-shaped data. Use `toolResponse.rawV2` for provider-specific fields or
468
- * debugging. Inspect the observed response before selecting a nested field;
469
- * provider envelopes are preserved, including pagination and sibling resources.
470
- * This is parsed, scrubbed data, not the original HTTP bytes or headers.
121
+ * @sdkReference errors 010
122
+ */
123
+ declare class DeeplineError extends Error {
124
+ /** HTTP status when the failure crossed an HTTP boundary. */
125
+ statusCode?: number;
126
+ /** Stable machine-readable error code when one exists. */
127
+ code?: string;
128
+ /** Local diagnostic context; not a portable error contract. */
129
+ details?: Record<string, unknown>;
130
+ /**
131
+ * Construct a Deepline error.
132
+ *
133
+ * SDK and runtime code construct these errors. Application and Play code
134
+ * normally catches the public subclasses instead.
135
+ *
136
+ * @param message Human-readable failure summary.
137
+ * @param statusCode HTTP status when one exists.
138
+ * @param code Stable machine-readable code when one exists.
139
+ * @param details Local diagnostic context; never a portable error contract.
140
+ */
141
+ constructor(message: string, statusCode?: number, code?: string, details?: Record<string, unknown>);
142
+ static [Symbol.hasInstance](value: unknown): boolean;
143
+ }
144
+ /**
145
+ * A failed `tools.execute` call with stable, allowlisted provenance.
471
146
  *
472
- * @sdkReference runtime 200
147
+ * `retryable` means Deepline's delivery/idempotency contract says it is safe
148
+ * to repeat the same semantic call. It does not describe durable receipt
149
+ * repairability and does not make arbitrary side-effecting fallbacks safe.
150
+ *
151
+ * In a Play, catch `ProviderTransientError` to continue a read waterfall and
152
+ * let every other `ToolExecutionError` remain loud. In an SDK client, catch
153
+ * this base class when you need structured diagnostics for every tool failure.
154
+ *
155
+ * @sdkReference errors 070
473
156
  */
474
- type ToolExecuteResult<TResult = unknown, TMeta = Record<string, unknown>, TExtracted extends Record<string, unknown> = Partial<DeeplineGetterValueMap>, TLists extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>> = ToolExecuteResultBase<TResult, TMeta> & ToolExecuteResultAccessors<TExtracted, TLists>;
475
-
476
- declare const TOOL_EXECUTION_ERROR_SCHEMA_VERSION: 1;
477
- declare const SUPPORTED_TOOL_EXECUTION_ERROR_SCHEMA_VERSIONS: readonly [0, 1];
478
- type ToolExecutionErrorSchemaVersion = (typeof SUPPORTED_TOOL_EXECUTION_ERROR_SCHEMA_VERSIONS)[number];
157
+ declare class ToolExecutionError extends DeeplineError {
158
+ /** Public tool id passed to `tools.execute`. */
159
+ readonly toolId: string;
160
+ /** Provider responsible for the operation, or `null` when unattributed. */
161
+ readonly provider: string | null;
162
+ /** Provider operation name, or `null` when unavailable. */
163
+ readonly operation: string | null;
164
+ /** Boundary responsible for the failure. */
165
+ readonly origin: ToolExecutionErrorOrigin;
166
+ /** Stable reason family for policy and diagnostics. */
167
+ readonly category: ToolExecutionErrorCategory;
168
+ /**
169
+ * Whether repeating the same semantic call is delivery-safe.
170
+ *
171
+ * This does not mean the error may be ignored. Waterfall fallthrough is
172
+ * represented by `ProviderTransientError`.
173
+ */
174
+ readonly retryable: boolean;
175
+ /** Provider or Deepline request id, or `null` when unavailable. */
176
+ readonly requestId: string | null;
177
+ /** Suggested same-call retry delay in milliseconds, or `null`. */
178
+ readonly retryAfterMs: number | null;
179
+ /** Network failure kind, or `null` for non-network failures. */
180
+ readonly networkKind: ToolExecutionNetworkKind | null;
181
+ /** Network boundary that failed, or `null` for non-network failures. */
182
+ readonly networkScope: ToolExecutionNetworkScope | null;
183
+ /** Explicitly allowlisted diagnostics safe for SDK and Play callers. */
184
+ readonly publicDetails: ToolExecutionPublicDetails | null;
185
+ /**
186
+ * Construct a structured tool error.
187
+ *
188
+ * Deepline constructs this from the versioned `tool_error` payload.
189
+ * Application and Play code should catch it rather than create it.
190
+ */
191
+ constructor(message: string, options: ToolExecutionErrorOptions);
192
+ static [Symbol.hasInstance](value: unknown): boolean;
193
+ }
479
194
  /**
480
- * The boundary responsible for a failed tool call.
195
+ * A provider-owned transient failure that is safe to handle as an empty
196
+ * waterfall leg. Validation, auth, billing, Deepline, and unknown failures
197
+ * never satisfy this type.
481
198
  *
482
- * Use `provider` to distinguish a provider answer from caller input and
483
- * Deepline infrastructure. `unknown` fails closed and must not trigger a
484
- * waterfall fallback.
199
+ * `retryable` remains independent: it says whether the same semantic call may
200
+ * be repeated safely. Falling through to a different read provider depends on
201
+ * this class, not on `retryable`.
485
202
  *
486
- * @sdkReference errors 020
203
+ * @sdkReference errors 080
487
204
  */
488
- type ToolExecutionErrorOrigin = 'caller' | 'provider' | 'deepline' | 'unknown';
205
+ declare class ProviderTransientError extends ToolExecutionError {
206
+ /** Provider attribution is guaranteed for this subtype. */
207
+ readonly origin: "provider";
208
+ /** Provider failure category that made this error eligible for fallthrough. */
209
+ readonly category: ProviderTransientErrorCategory;
210
+ /** Constructed by Deepline when a provider-owned transient failure arrives. */
211
+ constructor(message: string, options: Omit<ToolExecutionErrorOptions, 'origin' | 'category'> & {
212
+ category: ProviderTransientErrorCategory;
213
+ });
214
+ static [Symbol.hasInstance](value: unknown): boolean;
215
+ }
216
+ /** Why a provider cannot serve the current read request. */
217
+ type ProviderUnavailableReason = ProviderTransientErrorCategory | 'account_capacity' | 'credentials_missing';
489
218
  /**
490
- * The stable reason family for a failed tool call.
491
- *
492
- * Branch on this field only after narrowing to `ToolExecutionError`. Catch
493
- * `ProviderTransientError` when the policy is simply “try the next read
494
- * provider”; it is the safer and shorter waterfall contract.
495
- *
496
- * @sdkReference errors 030
219
+ * A provider failure that permits a read waterfall to try its next provider.
220
+ * A missing provider connection is included because another provider may still
221
+ * serve the read. Invalid credentials, caller input, and Deepline billing
222
+ * failures remain loud.
497
223
  */
498
- type ToolExecutionErrorCategory = 'validation' | 'authentication' | 'authorization' | 'rate_limit' | 'network' | 'upstream' | 'billing' | 'conflict' | 'internal' | 'unknown';
224
+ type ProviderUnavailableError = ProviderTransientError | (ToolExecutionError & {
225
+ readonly origin: 'provider';
226
+ readonly code: 'PROVIDER_ACCOUNT_CAPACITY';
227
+ }) | (ToolExecutionError & {
228
+ readonly origin: 'caller';
229
+ readonly code: 'INTEGRATION_CREDENTIALS_MISSING';
230
+ });
499
231
  /**
500
- * The transport failure observed when `category` is `network`.
501
- *
502
- * This is `null` for failures that are not network failures.
232
+ * Return the provider-specific reason a read cannot run right now.
503
233
  *
504
- * @sdkReference errors 040
234
+ * `null` means this error must stay loud: it is caller input, an invalid
235
+ * customer credential, Deepline billing, or an internal failure. A missing
236
+ * provider connection is different: an explicit read waterfall may continue
237
+ * to a configured fallback and record the unavailable leg.
505
238
  */
506
- type ToolExecutionNetworkKind = 'timeout' | 'dns' | 'connect' | 'reset' | 'unavailable' | 'unknown';
239
+ declare function getProviderUnavailableReason(error: unknown): ProviderUnavailableReason | null;
507
240
  /**
508
- * The request boundary on which a network failure occurred.
509
- *
510
- * `deepline_to_provider` is provider-side. Client and runtime scopes are
511
- * Deepline transport failures and never qualify as provider fallthrough.
241
+ * Whether a provider cannot serve this read right now.
512
242
  *
513
- * @sdkReference errors 050
243
+ * Use this in an explicit `catch` to advance a read-only waterfall. For
244
+ * diagnostics, use `getProviderUnavailableReason(error)`.
514
245
  */
515
- type ToolExecutionNetworkScope = 'client_to_deepline' | 'runtime_to_deepline' | 'deepline_to_provider';
246
+ declare function isProviderUnavailable(error: unknown): error is ProviderUnavailableError;
247
+ /** @deprecated Use isProviderUnavailable. */
248
+ declare const isProviderWaterfallUnavailableError: typeof isProviderUnavailable;
249
+
516
250
  /**
517
- * Bounded, primitive-only diagnostics explicitly approved for customers.
518
- * Raw provider bodies, credentials, prompts, stacks, and causes never belong
519
- * in this shared API/SDK/Play contract.
520
- *
521
- * @sdkReference errors 063
251
+ * Public tool-response contracts shared by the API, SDK, Play bundler, and
252
+ * runtime. This is a versioned response transformation contract: a change to
253
+ * the persisted public tool-result shape must introduce a new value here and
254
+ * have newly built Play artifacts select it. Receipt-cache revisions are
255
+ * intentionally separate: ordinary response-contract changes do not refresh
256
+ * durable receipts unless the response transformation changed as well.
522
257
  */
523
- type ToolExecutionPublicDetails = Readonly<Record<string, string | number | boolean | null>>;
258
+ declare const V2_TOOL_RESPONSE_CONTRACT: "v2-tool-response";
259
+ declare const RAW_V2_TOOL_RESPONSE_CONTRACT: "raw-v2";
260
+ type ToolResponseContract = typeof V2_TOOL_RESPONSE_CONTRACT | typeof RAW_V2_TOOL_RESPONSE_CONTRACT;
261
+
524
262
  /**
525
- * Portable version-1 `tool_error` payload.
263
+ * Previous durable cell value passed to object-column resolvers.
526
264
  *
527
- * This allowlisted shape crosses the API, runtime, and SDK boundaries.
528
- * `message` remains on the Error object and is deliberately not a policy
529
- * field.
265
+ * The runtime supplies this when a row+column is being recomputed after a
266
+ * previous value existed. `value` has the same type that the column returns;
267
+ * freshness metadata lives beside it.
530
268
  *
531
- * @sdkReference errors 064
269
+ * @sdkReference runtime 120
532
270
  */
533
- type ToolExecutionFailureV1 = {
534
- /** Payload version. */
535
- schemaVersion: typeof TOOL_EXECUTION_ERROR_SCHEMA_VERSION;
536
- /** Public tool id passed to `tools.execute`. */
537
- toolId: string;
538
- /** Provider responsible for the operation, or `null`. */
539
- provider: string | null;
540
- /** Provider operation name, or `null`. */
541
- operation: string | null;
542
- /** Stable machine-readable failure code, or `null`. */
543
- code: string | null;
544
- /** Boundary responsible for the failure. */
545
- origin: ToolExecutionErrorOrigin;
546
- /** Stable reason family. */
547
- category: ToolExecutionErrorCategory;
548
- /** Whether repeating the same semantic call is delivery-safe. */
549
- retryable: boolean;
550
- /** HTTP status when one exists, or `null`. */
551
- statusCode: number | null;
552
- /** Provider or Deepline request id, or `null`. */
553
- requestId: string | null;
554
- /** Suggested same-call retry delay in milliseconds, or `null`. */
555
- retryAfterMs: number | null;
556
- /** Network failure kind, or `null`. */
557
- networkKind: ToolExecutionNetworkKind | null;
558
- /** Network boundary that failed, or `null`. */
559
- networkScope: ToolExecutionNetworkScope | null;
560
- /** Explicitly allowlisted customer diagnostics, when present. */
561
- publicDetails?: ToolExecutionPublicDetails | null;
271
+ type PreviousCell<Value = unknown> = {
272
+ /** Previous completed value for this row+column. */
273
+ value: Value;
274
+ /** Millisecond timestamp when the previous value completed. */
275
+ completedAt?: number;
276
+ /** Millisecond timestamp when the previous value becomes stale; `null` means no expiry. */
277
+ staleAt?: number | null;
278
+ /** Resolved numeric TTL in seconds for the previous value, when present. */
279
+ staleAfterSeconds?: number;
280
+ };
281
+
282
+ type PlaySandboxRuntimeLimits = {
283
+ timeoutSeconds: number;
284
+ memoryGiB: number;
285
+ cpu: number;
286
+ diskGiB: number;
287
+ };
288
+ type PlaySandboxSize = 'standard';
289
+ type PlaySandboxRuntimeDeclaration = {
290
+ timeout?: string;
291
+ size?: PlaySandboxSize;
292
+ };
293
+
294
+ type EmailStatusVerdict = 'send' | 'send_with_caution' | 'verify_next' | 'hold' | 'drop';
295
+ type EmailStatusValue = 'valid' | 'invalid' | 'catch_all' | 'valid_catch_all' | 'unknown' | 'do_not_mail' | 'spamtrap' | 'abuse' | 'disposable';
296
+ type EmailDeliverability = 'high' | 'medium' | 'low' | 'unknown';
297
+ type EmailMxClass = 'consumer_mailbox' | 'workspace_mailbox' | 'security_gateway' | 'on_prem' | 'unknown';
298
+ type EmailStatus = {
299
+ verdict: EmailStatusVerdict;
300
+ status: EmailStatusValue;
301
+ verified: boolean;
302
+ confidence: number | null;
303
+ reasons: string[];
304
+ signals: {
305
+ catch_all: boolean | null;
306
+ deliverability: EmailDeliverability;
307
+ mx_class: EmailMxClass;
308
+ mx_provider: string | null;
309
+ mx_record: string | null;
310
+ fraud_score: number | null;
311
+ disposable: boolean | null;
312
+ role_based: boolean | null;
313
+ free_email: boolean | null;
314
+ abuse: boolean | null;
315
+ spamtrap: boolean | null;
316
+ suspect: boolean | null;
317
+ valid: boolean | null;
318
+ };
319
+ provider: {
320
+ name: string;
321
+ raw_status: string | boolean | number | null;
322
+ raw_score: number | null;
323
+ };
324
+ };
325
+ type EmailStatusMapEntry = {
326
+ status: EmailStatusValue;
327
+ verdict?: EmailStatusVerdict;
328
+ verified?: boolean;
329
+ reason?: string;
330
+ };
331
+ type EmailStatusRule = EmailStatusMapEntry & {
332
+ when: Record<string, string | number | boolean | null>;
333
+ };
334
+ type EmailStatusExtractorConfig = {
335
+ provider: string;
336
+ rawStatus?: string[];
337
+ rawScore?: string[];
338
+ valid?: string[];
339
+ deliverability?: string[];
340
+ catchAll?: string[];
341
+ mxProvider?: string[];
342
+ mxRecord?: string[];
343
+ fraudScore?: string[];
344
+ disposable?: string[];
345
+ roleBased?: string[];
346
+ freeEmail?: string[];
347
+ abuse?: string[];
348
+ spamtrap?: string[];
349
+ suspect?: string[];
350
+ statusMap?: Record<string, EmailStatusMapEntry>;
351
+ rules?: EmailStatusRule[];
352
+ };
353
+
354
+ declare const JOB_CHANGE_STATUS_VALUES: readonly ["moved", "no_change", "left_company", "unknown", "profile_unavailable", "no_new_company"];
355
+ type JobChangeStatus = (typeof JOB_CHANGE_STATUS_VALUES)[number];
356
+ type JobChangeGetterValue = {
357
+ status: JobChangeStatus;
358
+ date: string | null;
359
+ new_company: string | null;
360
+ new_title: string | null;
361
+ };
362
+ declare const PHONE_STATUS_VALUES: readonly ["valid", "invalid", "unknown"];
363
+ type PhoneStatus = (typeof PHONE_STATUS_VALUES)[number];
364
+ declare const DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS: {
365
+ readonly id: {
366
+ readonly identity: true;
367
+ readonly valueKind: "string";
368
+ };
369
+ readonly name: {
370
+ readonly identity: true;
371
+ readonly valueKind: "string";
372
+ };
373
+ readonly email: {
374
+ readonly identity: true;
375
+ readonly valueKind: "string";
376
+ };
377
+ readonly personal_email: {
378
+ readonly identity: true;
379
+ readonly valueKind: "string";
380
+ };
381
+ readonly phone: {
382
+ readonly identity: true;
383
+ readonly valueKind: "string";
384
+ };
385
+ readonly linkedin: {
386
+ readonly identity: true;
387
+ readonly valueKind: "string";
388
+ };
389
+ readonly linkedin_url: {
390
+ readonly identity: true;
391
+ readonly valueKind: "string";
392
+ };
393
+ readonly domain: {
394
+ readonly identity: true;
395
+ readonly valueKind: "string";
396
+ };
397
+ readonly website: {
398
+ readonly identity: true;
399
+ readonly valueKind: "string";
400
+ };
401
+ readonly first_name: {
402
+ readonly identity: true;
403
+ readonly valueKind: "string";
404
+ };
405
+ readonly last_name: {
406
+ readonly identity: true;
407
+ readonly valueKind: "string";
408
+ };
409
+ readonly full_name: {
410
+ readonly identity: true;
411
+ readonly valueKind: "string";
412
+ };
413
+ readonly company: {
414
+ readonly identity: true;
415
+ readonly valueKind: "string";
416
+ };
417
+ readonly company_name: {
418
+ readonly identity: true;
419
+ readonly valueKind: "string";
420
+ };
421
+ readonly organization_name: {
422
+ readonly identity: true;
423
+ readonly valueKind: "string";
424
+ };
425
+ readonly company_domain: {
426
+ readonly identity: true;
427
+ readonly valueKind: "string";
428
+ };
429
+ readonly company_website: {
430
+ readonly identity: true;
431
+ readonly valueKind: "string";
432
+ };
433
+ readonly company_linkedin_url: {
434
+ readonly identity: true;
435
+ readonly valueKind: "string";
436
+ };
437
+ readonly title: {
438
+ readonly identity: false;
439
+ readonly valueKind: "string";
440
+ };
441
+ readonly industry: {
442
+ readonly identity: false;
443
+ readonly valueKind: "string";
444
+ };
445
+ readonly status: {
446
+ readonly identity: false;
447
+ readonly valueKind: "string";
448
+ };
449
+ readonly job_change: {
450
+ readonly identity: false;
451
+ readonly valueKind: "job_change";
452
+ };
453
+ readonly job_change_status: {
454
+ readonly identity: false;
455
+ readonly valueKind: "job_change_status";
456
+ readonly enum: readonly ["moved", "no_change", "left_company", "unknown", "profile_unavailable", "no_new_company"];
457
+ };
458
+ readonly email_status: {
459
+ readonly identity: false;
460
+ readonly valueKind: "email_status";
461
+ };
462
+ readonly phone_status: {
463
+ readonly identity: false;
464
+ readonly valueKind: "phone_status";
465
+ readonly enum: readonly ["valid", "invalid", "unknown"];
466
+ };
562
467
  };
563
- /**
564
- * Constructor input for a structured tool failure.
565
- *
566
- * Deepline creates these values while decoding the versioned wire payload.
567
- * Customer code normally reads `ToolExecutionError` fields instead of
568
- * constructing an error.
569
- *
570
- * @sdkReference errors 065
571
- */
572
- type ToolExecutionErrorOptions = Omit<ToolExecutionFailureV1, 'schemaVersion'> & {
573
- /**
574
- * Local diagnostic context inherited from DeeplineError. This is not part of
575
- * the portable failure payload and is intentionally omitted by serialization.
576
- */
577
- details?: Record<string, unknown>;
468
+ type DeeplineExtractorTarget = keyof typeof DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS;
469
+ declare const DEEPLINE_EXTRACTOR_TARGETS: DeeplineExtractorTarget[];
470
+ type DeeplineEmailStatusGetterValue = EmailStatus;
471
+ type DeeplineGetterValueMap = {
472
+ id: string;
473
+ name: string;
474
+ email: string;
475
+ personal_email: string;
476
+ phone: string;
477
+ linkedin: string;
478
+ linkedin_url: string;
479
+ domain: string;
480
+ website: string;
481
+ first_name: string;
482
+ last_name: string;
483
+ full_name: string;
484
+ company: string;
485
+ company_name: string;
486
+ organization_name: string;
487
+ company_domain: string;
488
+ company_website: string;
489
+ company_linkedin_url: string;
490
+ title: string;
491
+ industry: string;
492
+ status: string;
493
+ job_change: JobChangeGetterValue;
494
+ job_change_status: JobChangeStatus;
495
+ email_status: EmailStatus;
496
+ phone_status: PhoneStatus;
578
497
  };
579
- /**
580
- * Provider-owned failure categories that may fall through to another read
581
- * provider.
582
- *
583
- * @sdkReference errors 060
584
- */
585
- type ProviderTransientErrorCategory = 'rate_limit' | 'network' | 'upstream';
586
- /**
587
- * Base error class shared by the SDK and play runtime.
588
- *
589
- * The global brand preserves `instanceof DeeplineError` when a bundled play
590
- * and the runtime load separate physical copies of this module.
591
- *
592
- * @sdkReference errors 010
593
- */
594
- declare class DeeplineError extends Error {
595
- /** HTTP status when the failure crossed an HTTP boundary. */
596
- statusCode?: number;
597
- /** Stable machine-readable error code when one exists. */
598
- code?: string;
599
- /** Local diagnostic context; not a portable error contract. */
600
- details?: Record<string, unknown>;
601
- /**
602
- * Construct a Deepline error.
603
- *
604
- * SDK and runtime code construct these errors. Application and Play code
605
- * normally catches the public subclasses instead.
606
- *
607
- * @param message Human-readable failure summary.
608
- * @param statusCode HTTP status when one exists.
609
- * @param code Stable machine-readable code when one exists.
610
- * @param details Local diagnostic context; never a portable error contract.
611
- */
612
- constructor(message: string, statusCode?: number, code?: string, details?: Record<string, unknown>);
613
- static [Symbol.hasInstance](value: unknown): boolean;
498
+ type DeeplineGetterValue<TTarget extends DeeplineExtractorTarget = DeeplineExtractorTarget> = DeeplineGetterValueMap[TTarget];
499
+ declare function isDeeplineExtractorTarget(value: string): value is DeeplineExtractorTarget;
500
+
501
+ interface PlayR2FileRef {
502
+ storageKind: 'r2';
503
+ storageKey: string;
504
+ logicalPath: string;
505
+ fileName: string;
506
+ contentHash: string;
507
+ contentType: string;
508
+ bytes: number;
614
509
  }
615
- /**
616
- * A failed `tools.execute` call with stable, allowlisted provenance.
617
- *
618
- * `retryable` means Deepline's delivery/idempotency contract says it is safe
619
- * to repeat the same semantic call. It does not describe durable receipt
620
- * repairability and does not make arbitrary side-effecting fallbacks safe.
621
- *
622
- * In a Play, catch `ProviderTransientError` to continue a read waterfall and
623
- * let every other `ToolExecutionError` remain loud. In an SDK client, catch
624
- * this base class when you need structured diagnostics for every tool failure.
625
- *
626
- * @sdkReference errors 070
627
- */
628
- declare class ToolExecutionError extends DeeplineError {
629
- /** Public tool id passed to `tools.execute`. */
630
- readonly toolId: string;
631
- /** Provider responsible for the operation, or `null` when unattributed. */
632
- readonly provider: string | null;
633
- /** Provider operation name, or `null` when unavailable. */
634
- readonly operation: string | null;
635
- /** Boundary responsible for the failure. */
636
- readonly origin: ToolExecutionErrorOrigin;
637
- /** Stable reason family for policy and diagnostics. */
638
- readonly category: ToolExecutionErrorCategory;
639
- /**
640
- * Whether repeating the same semantic call is delivery-safe.
641
- *
642
- * This does not mean the error may be ignored. Waterfall fallthrough is
643
- * represented by `ProviderTransientError`.
644
- */
645
- readonly retryable: boolean;
646
- /** Provider or Deepline request id, or `null` when unavailable. */
647
- readonly requestId: string | null;
648
- /** Suggested same-call retry delay in milliseconds, or `null`. */
649
- readonly retryAfterMs: number | null;
650
- /** Network failure kind, or `null` for non-network failures. */
651
- readonly networkKind: ToolExecutionNetworkKind | null;
652
- /** Network boundary that failed, or `null` for non-network failures. */
653
- readonly networkScope: ToolExecutionNetworkScope | null;
654
- /** Explicitly allowlisted diagnostics safe for SDK and Play callers. */
655
- readonly publicDetails: ToolExecutionPublicDetails | null;
656
- /**
657
- * Construct a structured tool error.
658
- *
659
- * Deepline constructs this from the versioned `tool_error` payload.
660
- * Application and Play code should catch it rather than create it.
661
- */
662
- constructor(message: string, options: ToolExecutionErrorOptions);
663
- static [Symbol.hasInstance](value: unknown): boolean;
510
+ type PlayExecutionFileRef = PlayR2FileRef;
511
+
512
+ /** Source evidence is advisory; stored values determine lossless SQL encoding. */
513
+ interface PlayDatasetColumnTypeEvidence {
514
+ postgresTypeId: number;
515
+ valueType: 'boolean' | 'number' | 'string' | 'json';
664
516
  }
665
- /**
666
- * A provider-owned transient failure that is safe to handle as an empty
667
- * waterfall leg. Validation, auth, billing, Deepline, and unknown failures
668
- * never satisfy this type.
669
- *
670
- * `retryable` remains independent: it says whether the same semantic call may
671
- * be repeated safely. Falling through to a different read provider depends on
672
- * this class, not on `retryable`.
673
- *
674
- * @sdkReference errors 080
675
- */
676
- declare class ProviderTransientError extends ToolExecutionError {
677
- /** Provider attribution is guaranteed for this subtype. */
678
- readonly origin: "provider";
679
- /** Provider failure category that made this error eligible for fallthrough. */
680
- readonly category: ProviderTransientErrorCategory;
681
- /** Constructed by Deepline when a provider-owned transient failure arrives. */
682
- constructor(message: string, options: Omit<ToolExecutionErrorOptions, 'origin' | 'category'> & {
683
- category: ProviderTransientErrorCategory;
684
- });
685
- static [Symbol.hasInstance](value: unknown): boolean;
517
+ type PlayDatasetColumnTypes = Record<string, PlayDatasetColumnTypeEvidence>;
518
+ type PlaySheetColumnSource = 'input' | 'datasetColumn' | 'waterfallStep' | 'childPlayColumn';
519
+ interface PlaySheetColumnContract {
520
+ id: string;
521
+ sqlName: string;
522
+ source: PlaySheetColumnSource;
523
+ field?: string;
524
+ parentField?: string;
525
+ playId?: string;
526
+ waterfallId?: string;
527
+ outputField?: string;
528
+ outputSqlName?: string;
529
+ stepId?: string;
530
+ toolId?: string;
531
+ isRowKey?: boolean;
532
+ typeEvidence?: PlayDatasetColumnTypeEvidence;
686
533
  }
687
- /** Why a provider cannot serve the current read request. */
688
- type ProviderUnavailableReason = ProviderTransientErrorCategory | 'account_capacity' | 'credentials_missing';
689
- /**
690
- * A provider failure that permits a read waterfall to try its next provider.
691
- * A missing provider connection is included because another provider may still
692
- * serve the read. Invalid credentials, caller input, and Deepline billing
693
- * failures remain loud.
694
- */
695
- type ProviderUnavailableError = ProviderTransientError | (ToolExecutionError & {
696
- readonly origin: 'provider';
697
- readonly code: 'PROVIDER_ACCOUNT_CAPACITY';
698
- }) | (ToolExecutionError & {
699
- readonly origin: 'caller';
700
- readonly code: 'INTEGRATION_CREDENTIALS_MISSING';
701
- });
534
+ interface PlaySheetContract {
535
+ tableNamespace: string;
536
+ columns: PlaySheetColumnContract[];
537
+ }
538
+
539
+ declare const PLAY_DATASET_BRAND: unique symbol;
540
+ type PlayDatasetKind = 'csv' | 'map';
541
+ type PlayDatasetBacking = {
542
+ storage: 'neon_sheet';
543
+ sheet: {
544
+ playName: string;
545
+ tableNamespace: string;
546
+ };
547
+ } | {
548
+ storage: 'r2_file';
549
+ file: PlayExecutionFileRef;
550
+ };
551
+ type PlayDatasetWorkProgressSummary = {
552
+ total: number;
553
+ executed: number;
554
+ reused: number;
555
+ skipped: number;
556
+ pending: number;
557
+ failed: number;
558
+ degraded?: boolean;
559
+ duplicates?: {
560
+ exact?: number;
561
+ semantic?: number;
562
+ rejected?: number;
563
+ };
564
+ };
565
+ type PlayDatasetInput<T> = ReadonlyArray<T> | Iterable<T> | AsyncIterable<T> | PlayDataset<T>;
566
+ type PlayDatasetRow<TInput> = TInput extends PlayDataset<infer Row> ? Row : TInput extends ReadonlyArray<infer Row> ? Row : TInput extends Iterable<infer Row> ? Row : TInput extends AsyncIterable<infer Row> ? Row : never;
567
+ type PlayDatasetTransformOptions = {
568
+ key?: string;
569
+ sourceLabel?: string | null;
570
+ };
702
571
  /**
703
- * Return the provider-specific reason a read cannot run right now.
572
+ * Durable handle for rows produced by `ctx.csv(...)` or `ctx.dataset(...).run()`.
704
573
  *
705
- * `null` means this error must stay loud: it is caller input, an invalid
706
- * customer credential, Deepline billing, or an internal failure. A missing
707
- * provider connection is different: an explicit read waterfall may continue
708
- * to a configured fallback and record the unavailable leg.
709
- */
710
- declare function getProviderUnavailableReason(error: unknown): ProviderUnavailableReason | null;
711
- /**
712
- * Whether a provider cannot serve this read right now.
574
+ * A `PlayDataset` is not a normal in-memory array. It points at runtime-managed
575
+ * rows, usually backed by persisted sheet storage, and carries metadata such as
576
+ * dataset kind, dataset id, table namespace, count, and preview rows.
713
577
  *
714
- * Use this in an explicit `catch` to advance a read-only waterfall. For
715
- * diagnostics, use `getProviderUnavailableReason(error)`.
578
+ * Pass dataset handles directly into later `ctx.dataset(...)` stages by default so
579
+ * Deepline keeps row progress, retries, memory use, and table output under
580
+ * runtime control. Use `count()` and `peek()` for bounded inspection. Use
581
+ * `materialize(limit)` or async iteration only when the dataset is intentionally
582
+ * small and bounded. `PlayDataset` intentionally does not expose `.rows`,
583
+ * `.toArray()`, `.length`, numeric indexing, spread, or synchronous iteration;
584
+ * these hide loading costs or make behavior depend on row residency.
585
+ *
586
+ * @sdkReference runtime 190
716
587
  */
717
- declare function isProviderUnavailable(error: unknown): error is ProviderUnavailableError;
718
- /** @deprecated Use isProviderUnavailable. */
719
- declare const isProviderWaterfallUnavailableError: typeof isProviderUnavailable;
588
+ interface PlayDataset<T> extends AsyncIterable<T> {
589
+ readonly [PLAY_DATASET_BRAND]: true;
590
+ /** Dataset kind. */
591
+ readonly datasetKind: PlayDatasetKind;
592
+ /** Dataset id. */
593
+ readonly datasetId: string;
594
+ /** Backing store info. */
595
+ readonly backing?: PlayDatasetBacking;
596
+ /** Display label. */
597
+ readonly sourceLabel?: string | null;
598
+ /** Runtime table name. */
599
+ readonly tableNamespace?: string | null;
600
+ /** Advisory source types; transformed fields must infer from their values. */
601
+ readonly columnTypes?: PlayDatasetColumnTypes;
602
+ /** Row count. */
603
+ count(): Promise<number>;
604
+ /** Preview rows. */
605
+ peek(limit?: number): Promise<T[]>;
606
+ /** First row, loading it asynchronously when necessary. */
607
+ first(): Promise<T | undefined>;
608
+ /** Row at an array-style index, loading it asynchronously when necessary. */
609
+ at(index: number): Promise<T | undefined>;
610
+ map<U>(mapper: (row: T, index: number) => U | Promise<U>, options?: PlayDatasetTransformOptions): PlayDataset<U>;
611
+ filter(predicate: (row: T, index: number) => boolean | Promise<boolean>, options?: PlayDatasetTransformOptions): PlayDataset<T>;
612
+ slice(start?: number, end?: number, options?: PlayDatasetTransformOptions): PlayDataset<T>;
613
+ take(limit: number, options?: PlayDatasetTransformOptions): PlayDataset<T>;
614
+ /**
615
+ * Explicit escape hatch for bounded result sets.
616
+ * Large datasets should flow by handle through Neon-backed storage, not
617
+ * through worker memory as giant arrays.
618
+ */
619
+ materialize(options?: number | PlayDatasetMaterializeOptions): Promise<T[]>;
620
+ toJSON(): {
621
+ kind: 'dataset';
622
+ datasetKind: PlayDatasetKind;
623
+ datasetId: string;
624
+ count: number;
625
+ backing?: PlayDatasetBacking;
626
+ sourceLabel?: string | null;
627
+ tableNamespace?: string | null;
628
+ columns?: string[];
629
+ columnTypes?: PlayDatasetColumnTypes;
630
+ _metadata?: {
631
+ workProgress?: PlayDatasetWorkProgressSummary;
632
+ };
633
+ preview: T[];
634
+ };
635
+ }
636
+ type PlayDatasetMaterializeScope = 'result' | 'full_persisted_dataset';
637
+ type PlayDatasetMaterializeOptions = {
638
+ /** Rows returned by this operation, or every current row in its persisted dataset. */
639
+ scope?: PlayDatasetMaterializeScope;
640
+ /** Maximum number of rows to load into memory. */
641
+ limit?: number;
642
+ };
720
643
 
721
644
  /**
722
- * Public tool-response contracts shared by the API, SDK, Play bundler, and
723
- * runtime. This is a versioned response transformation contract: a change to
724
- * the persisted public tool-result shape must introduce a new value here and
725
- * have newly built Play artifacts select it. Receipt-cache revisions are
726
- * intentionally separate: ordinary response-contract changes do not refresh
727
- * durable receipts unless the response transformation changed as well.
645
+ * Customer pricing reported by the execution API, never provider spend.
646
+ * `credits_charged` and `cost_usd` describe the price of the original call;
647
+ * they do not acknowledge durable handoff or wallet posting. Receipt replay
648
+ * preserves this observation and does not imply a new charge or fresher state.
728
649
  */
729
- declare const V2_TOOL_RESPONSE_CONTRACT: "v2-tool-response";
730
- declare const RAW_V2_TOOL_RESPONSE_CONTRACT: "raw-v2";
731
- type ToolResponseContract = typeof V2_TOOL_RESPONSE_CONTRACT | typeof RAW_V2_TOOL_RESPONSE_CONTRACT;
732
-
650
+ type ToolResultBilling = {
651
+ credits_charged?: number;
652
+ cost_usd?: number;
653
+ /** Missing on historical responses. Pending pricing has no final amount. */
654
+ pricing_status?: 'final' | 'pending';
655
+ settlement_status?: 'pending' | 'queued' | 'settled' | 'released' | 'requires_recovery';
656
+ billing_outcome_reason?: 'free_operation' | 'provider_no_billable_result' | 'provider_reported_zero_usage' | 'zero_price';
657
+ estimated_credits?: number;
658
+ estimated_cost_usd?: number;
659
+ /** Preserve additive public pricing details across runtime/deployment skew. */
660
+ [key: string]: unknown;
661
+ };
662
+ type ToolResultExecutionMetadata = {
663
+ idempotent: true;
664
+ cached: boolean;
665
+ source: 'live' | 'checkpoint' | 'cache' | 'in_flight' | 'source_run';
666
+ cacheKey?: string;
667
+ receiptRole?: 'owner' | 'follower';
668
+ receiptKey?: string;
669
+ /** Canonical saved result identity; receiptKey may name a transport alias. */
670
+ resultReceiptKey?: string;
671
+ attachedToReceiptKey?: string;
672
+ };
673
+ type ToolResultTargetMetadata = {
674
+ value: unknown;
675
+ path: string;
676
+ };
677
+ type ToolResultListMetadata = {
678
+ path: string;
679
+ count: number | null;
680
+ keys: Record<string, string>;
681
+ };
682
+ type ToolResultExtractorDescriptor = {
683
+ paths: readonly string[];
684
+ transforms?: readonly string[];
685
+ enum?: readonly string[];
686
+ overrides?: readonly ToolResultExtractorOverride[];
687
+ emailStatus?: EmailStatusExtractorConfig;
688
+ };
689
+ type ToolResultExtractorOverride = {
690
+ paths: readonly string[];
691
+ equals?: string | number | boolean | null;
692
+ value: string | number | boolean | null;
693
+ };
694
+ type ToolResultTargetAccessor<T = unknown> = ToolResultTargetMetadata & {
695
+ get(): T | null;
696
+ };
697
+ type ToolResultListAccessor<T = Record<string, unknown>, TKey extends string = string> = Omit<ToolResultListMetadata, 'keys'> & {
698
+ keys: Partial<Record<TKey, string>> & Record<string, string>;
699
+ get(): PlayDataset<T>;
700
+ };
701
+ type ToolResponseEnvelope<TData = unknown, TMeta = Record<string, unknown>> = {
702
+ /** @deprecated Use declared getters or toolResponse.rawV2. */
703
+ raw: TData;
704
+ /** Complete parsed and scrubbed provider response, materialized from raw-v2. */
705
+ rawV2?: unknown;
706
+ /** Durable descriptor for deriving the legacy raw view from `rawV2`. */
707
+ view?: 'data' | 'rawV2';
708
+ meta?: TMeta;
709
+ };
710
+ type ToolExecuteResultBase<TResult = unknown, TMeta = Record<string, unknown>> = {
711
+ status: string;
712
+ job_id?: string;
713
+ /** Deepline-owned execution/result metadata. */
714
+ meta?: Record<string, unknown>;
715
+ billing?: ToolResultBilling;
716
+ toolResponse: ToolResponseEnvelope<TResult, TMeta>;
717
+ extractedValues: Record<string, ToolResultTargetAccessor>;
718
+ extractedLists: Record<string, ToolResultListAccessor>;
719
+ /** Convenience alias for play code. Serialized output uses toolResponse. */
720
+ toolOutput: ToolResponseEnvelope<TResult, TMeta>;
721
+ _metadata: {
722
+ toolId: string;
723
+ execution: ToolResultExecutionMetadata;
724
+ targets: Record<string, {
725
+ value: unknown;
726
+ path: string;
727
+ }>;
728
+ extractors?: Record<string, ToolResultExtractorDescriptor>;
729
+ lists: Record<string, {
730
+ path: string;
731
+ count: number | null;
732
+ keys: Record<string, string>;
733
+ }>;
734
+ /** Original declarations preserve semantic accessor names across replay. */
735
+ listExtractorPaths?: readonly string[];
736
+ };
737
+ };
738
+ type ToolExecuteResultAccessors<TExtracted extends Record<string, unknown> = Partial<DeeplineGetterValueMap>, TLists extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>> = {
739
+ extractedValues: {
740
+ [K in keyof TExtracted]: ToolResultTargetAccessor<TExtracted[K]>;
741
+ };
742
+ extractedLists: {
743
+ [K in keyof TLists]: ToolResultListAccessor<TLists[K]>;
744
+ };
745
+ };
733
746
  /**
734
- * Previous durable cell value passed to object-column resolvers.
747
+ * Canonical result returned by Deepline tool execution.
735
748
  *
736
- * The runtime supplies this when a row+column is being recomputed after a
737
- * previous value existed. `value` has the same type that the column returns;
738
- * freshness metadata lives beside it.
749
+ * The top-level object is Deepline-owned execution metadata and semantic
750
+ * extraction state. The canonical provider response lives under
751
+ * `toolResponse.rawV2`. Response metadata lives under `toolResponse.meta`. Semantic single-value
752
+ * getters live under `extractedValues.<name>.get()`, and list getters live
753
+ * under `extractedLists.<name>.get()`.
739
754
  *
740
- * @sdkReference runtime 120
755
+ * Use extractors first when a tool contract exposes them. Use list getters for
756
+ * row-shaped data. Use `toolResponse.rawV2` for provider-specific fields or
757
+ * debugging. Inspect the observed response before selecting a nested field;
758
+ * provider envelopes are preserved, including pagination and sibling resources.
759
+ * This is parsed, scrubbed data, not the original HTTP bytes or headers.
760
+ *
761
+ * @sdkReference runtime 200
741
762
  */
742
- type PreviousCell<Value = unknown> = {
743
- /** Previous completed value for this row+column. */
744
- value: Value;
745
- /** Millisecond timestamp when the previous value completed. */
746
- completedAt?: number;
747
- /** Millisecond timestamp when the previous value becomes stale; `null` means no expiry. */
748
- staleAt?: number | null;
749
- /** Resolved numeric TTL in seconds for the previous value, when present. */
750
- staleAfterSeconds?: number;
751
- };
752
-
753
- type PlaySandboxRuntimeLimits = {
754
- timeoutSeconds: number;
755
- memoryGiB: number;
756
- cpu: number;
757
- diskGiB: number;
758
- };
759
- type PlaySandboxSize = 'standard';
760
- type PlaySandboxRuntimeDeclaration = {
761
- timeout?: string;
762
- size?: PlaySandboxSize;
763
- };
763
+ type ToolExecuteResult<TResult = unknown, TMeta = Record<string, unknown>, TExtracted extends Record<string, unknown> = Partial<DeeplineGetterValueMap>, TLists extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>> = ToolExecuteResultBase<TResult, TMeta> & ToolExecuteResultAccessors<TExtracted, TLists>;
764
764
 
765
765
  declare const SUPPORTED_PLAY_AUTHORING_CONTRACT_EDITIONS: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9];
766
766
  type PlayAuthoringContractEdition = (typeof SUPPORTED_PLAY_AUTHORING_CONTRACT_EDITIONS)[number];
@@ -3283,4 +3283,4 @@ type PlayCompilerManifest = {
3283
3283
  authoringContract?: AdmittedPlayAuthoringContract;
3284
3284
  };
3285
3285
 
3286
- export { type DeeplineGetterValue as $, type AsyncPlayRunRef as A, type PlayAuthoringCallOptions as B, type PlayAuthoringFetchResponse as C, type PlayAuthoringInputContract as D, type PlayRunId as E, type PlayAuthoringStepProgramStep as F, type PlayAuthoringRuntimeStepOptions as G, type PlaySqlListenerDeclaration as H, type PlaySqlListenerEvent as I, type PlaySqlListenerOperation as J, type PlaySqlQuery as K, type PlayAuthoringStepOptions as L, type PlayAuthoringStepProgram as M, type PlayAuthoringStepProgramResolver as N, type PlayAuthoringStepResolver as O, type PlayArtifactKind as P, type PlayToolExecutionRequest as Q, type PlayAuthoringStepProgramOptions as R, DeeplineError as S, type ToolExecuteResult as T, ToolExecutionError as U, type ToolExecutionErrorOptions as V, CtxFetchHttpError as W, DEEPLINE_EXTRACTOR_TARGETS as X, DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS as Y, type DeeplineEmailStatusGetterValue as Z, type DeeplineExtractorTarget as _, type PlayBundleArtifact as a, type DeeplineGetterValueMap as a0, JOB_CHANGE_STATUS_VALUES as a1, type JobChangeStatus as a2, PHONE_STATUS_VALUES as a3, type PhoneStatus as a4, type PlayDataset as a5, type PlayDatasetInput as a6, type PreviousCell as a7, ProviderTransientError as a8, type ProviderTransientErrorCategory as a9, type ProviderUnavailableError as aa, type ProviderUnavailableReason as ab, type ToolExecutionErrorCategory as ac, type ToolExecutionErrorOrigin as ad, type ToolExecutionFailureV1 as ae, type ToolExecutionNetworkKind as af, type ToolExecutionNetworkScope as ag, type ToolExecutionPublicDetails as ah, type ToolResultBilling as ai, getProviderUnavailableReason as aj, isDeeplineExtractorTarget as ak, isProviderUnavailable as al, isProviderWaterfallUnavailableError as am, type PlaySandboxRuntimeDeclaration as b, type PlayCompilerManifest as c, PLAY_ARTIFACT_KINDS as d, type PlayArtifactCompatibility as e, type PlayImportPolicy as f, type PlayPackageImport as g, type PlayRuntimeFeature as h, type PlayAuthoringColumnMap as i, type PlayAuthoringColumnResolver as j, type PlayAuthoringRuntimeContext as k, type PlayAuthoringConditionalStepResolver as l, type PlayAuthoringCsvInput as m, type PlayAuthoringCsvOptions as n, type PlayAuthoringDatasetBuilder as o, type PlayAuthoringDatasetColumnDefinition as p, type PlayAuthoringDatasetColumnRunInput as q, type PlayAuthoringReferenceLike as r, type PlayReturnObject as s, type PlayAuthoringDefineConfig as t, type PlayAuthoringDefinedPlay as u, type PlayAuthoringFetchOptions as v, type PlayAuthoringFileInput as w, type PlayAuthoringAsyncCallOptions as x, type PlayAuthoringBindings as y, type PlayAuthoringCallExecution as z };
3286
+ export { type DeeplineGetterValue as $, type AsyncPlayRunRef as A, type PlayAuthoringCallOptions as B, type PlayAuthoringFetchResponse as C, type PlayAuthoringInputContract as D, type PlayRunId as E, type PlayAuthoringStepProgramStep as F, type PlayAuthoringRuntimeStepOptions as G, type PlaySqlListenerDeclaration as H, type PlaySqlListenerEvent as I, type PlaySqlListenerOperation as J, type PlaySqlQuery as K, type PlayAuthoringStepOptions as L, type PlayAuthoringStepProgram as M, type PlayAuthoringStepProgramResolver as N, type PlayAuthoringStepResolver as O, PLAY_ARTIFACT_KINDS as P, type PlayToolExecutionRequest as Q, type PlayAuthoringStepProgramOptions as R, DeeplineError as S, type ToolExecuteResult as T, ToolExecutionError as U, type ToolExecutionErrorOptions as V, CtxFetchHttpError as W, DEEPLINE_EXTRACTOR_TARGETS as X, DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS as Y, type DeeplineEmailStatusGetterValue as Z, type DeeplineExtractorTarget as _, type PlayArtifactCompatibility as a, type DeeplineGetterValueMap as a0, JOB_CHANGE_STATUS_VALUES as a1, type JobChangeStatus as a2, PHONE_STATUS_VALUES as a3, type PhoneStatus as a4, type PlayDataset as a5, type PlayDatasetInput as a6, type PreviousCell as a7, ProviderTransientError as a8, type ProviderTransientErrorCategory as a9, type ProviderUnavailableError as aa, type ProviderUnavailableReason as ab, type ToolExecutionErrorCategory as ac, type ToolExecutionErrorOrigin as ad, type ToolExecutionFailureV1 as ae, type ToolExecutionNetworkKind as af, type ToolExecutionNetworkScope as ag, type ToolExecutionPublicDetails as ah, type ToolResultBilling as ai, getProviderUnavailableReason as aj, isDeeplineExtractorTarget as ak, isProviderUnavailable as al, isProviderWaterfallUnavailableError as am, type PlayBundleArtifact as b, type PlayImportPolicy as c, type PlayPackageImport as d, type PlayRuntimeFeature as e, type PlaySandboxRuntimeDeclaration as f, type PlayCompilerManifest as g, type PlayArtifactKind as h, type PlayAuthoringColumnMap as i, type PlayAuthoringColumnResolver as j, type PlayAuthoringRuntimeContext as k, type PlayAuthoringConditionalStepResolver as l, type PlayAuthoringCsvInput as m, type PlayAuthoringCsvOptions as n, type PlayAuthoringDatasetBuilder as o, type PlayAuthoringDatasetColumnDefinition as p, type PlayAuthoringDatasetColumnRunInput as q, type PlayAuthoringReferenceLike as r, type PlayReturnObject as s, type PlayAuthoringDefineConfig as t, type PlayAuthoringDefinedPlay as u, type PlayAuthoringFetchOptions as v, type PlayAuthoringFileInput as w, type PlayAuthoringAsyncCallOptions as x, type PlayAuthoringBindings as y, type PlayAuthoringCallExecution as z };