deepline 0.3.558 → 0.3.560

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 (157) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +14 -0
  2. package/dist/bundling-sources/sdk/src/index.ts +2 -0
  3. package/dist/bundling-sources/sdk/src/integrations.ts +62 -0
  4. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  5. package/dist/bundling-sources/shared_libs/observability/redaction.ts +23 -1
  6. package/dist/bundling-sources/shared_libs/observability/telemetry.ts +4 -1
  7. package/dist/cli/{auth-JJXTMFWH.mjs → auth-5DIOQ3MO.mjs} +5 -5
  8. package/dist/cli/auth-R2S7KYAA.js +44 -0
  9. package/dist/cli/{billing-RBFJMAI5.mjs → billing-K7EJAM55.mjs} +9 -9
  10. package/dist/cli/{billing-V3TJKUHY.js → billing-N5NS5CU6.js} +102 -102
  11. package/dist/cli/{chunk-FH55SB63.js → chunk-24GZT76F.js} +7 -7
  12. package/dist/cli/{chunk-NAJAAIEE.js → chunk-4CQ7LVRT.js} +48 -48
  13. package/dist/cli/{chunk-DDI4LNVC.js → chunk-4GRIMNDO.js} +41 -41
  14. package/dist/cli/{chunk-P3SLGOGA.mjs → chunk-4MAY2TA3.mjs} +2 -2
  15. package/dist/cli/{chunk-P2MVPTFJ.mjs → chunk-4PBYS3PS.mjs} +1 -1
  16. package/dist/cli/{chunk-YI4ADWTN.js → chunk-5CNHEUGJ.js} +12 -2
  17. package/dist/cli/{chunk-QGDU23YW.js → chunk-5QMEJPN5.js} +206 -180
  18. package/dist/cli/{chunk-6BDLYZYL.js → chunk-5VC6K4NJ.js} +26 -26
  19. package/dist/cli/{chunk-AL4QQKUK.mjs → chunk-5XMABMQU.mjs} +2 -2
  20. package/dist/cli/{chunk-4CTBC6Q7.js → chunk-7ZE6DF6B.js} +3 -3
  21. package/dist/cli/{chunk-XPSSXKBT.mjs → chunk-A4X2O75M.mjs} +2 -2
  22. package/dist/cli/{chunk-6PIQC2XE.mjs → chunk-A62A73U6.mjs} +3 -3
  23. package/dist/cli/{chunk-GAQ6VSRS.mjs → chunk-AMUMEL4C.mjs} +1 -1
  24. package/dist/cli/{chunk-I57JNBKA.mjs → chunk-BQ2Z6PSE.mjs} +5 -5
  25. package/dist/cli/{chunk-6LFPPAMD.js → chunk-BW4NVW5T.js} +3 -3
  26. package/dist/cli/{chunk-CEEUL7ER.mjs → chunk-CQJMFUMK.mjs} +1 -1
  27. package/dist/cli/{chunk-PAJLUB37.js → chunk-CQS5E6D2.js} +100 -100
  28. package/dist/cli/{chunk-DJAP2M5M.mjs → chunk-DOAD7ZCA.mjs} +1 -1
  29. package/dist/cli/{chunk-YVWINBZL.js → chunk-E76MM3SC.js} +20 -20
  30. package/dist/cli/{chunk-FF3BWNLL.mjs → chunk-F5CZ3Q2I.mjs} +150 -124
  31. package/dist/cli/{chunk-5V45LY6Y.js → chunk-FW2WRBZO.js} +9 -9
  32. package/dist/cli/{chunk-CB5DIX5K.mjs → chunk-G33LSF4T.mjs} +2 -2
  33. package/dist/cli/{chunk-BWWLLK56.mjs → chunk-GKONGPVW.mjs} +5 -5
  34. package/dist/cli/{chunk-2FFZ5SEU.mjs → chunk-GR5WG72L.mjs} +2 -2
  35. package/dist/cli/{chunk-KMNLER7F.mjs → chunk-GTRGJITW.mjs} +11 -11
  36. package/dist/cli/{chunk-BFM2RCC3.js → chunk-I7CQJ7JP.js} +2 -2
  37. package/dist/cli/{chunk-WJ7RY3PJ.mjs → chunk-JHS7WKRS.mjs} +3 -3
  38. package/dist/cli/{chunk-7Q5I4KEG.mjs → chunk-JQDVX3D4.mjs} +4 -4
  39. package/dist/cli/{chunk-RIQYBKHK.js → chunk-JYT6P2M2.js} +2 -2
  40. package/dist/cli/{chunk-XV4DHKZ2.js → chunk-KP4B3JOT.js} +13 -13
  41. package/dist/cli/{chunk-M4CJGF53.js → chunk-LMY7CGI7.js} +5 -5
  42. package/dist/cli/{chunk-I3PX6NGG.js → chunk-MBLPUJ5I.js} +5 -5
  43. package/dist/cli/{chunk-YJ46MJMT.js → chunk-MCGR7NG3.js} +6 -6
  44. package/dist/cli/{chunk-YBJSDL34.mjs → chunk-NNKZ4JYP.mjs} +5 -5
  45. package/dist/cli/{chunk-NADXF2C5.js → chunk-OPT36HX4.js} +53 -53
  46. package/dist/cli/{chunk-MAN4IEO4.mjs → chunk-OS3FDGKX.mjs} +4 -4
  47. package/dist/cli/{chunk-FCG42RQZ.js → chunk-Q77PM7U2.js} +20 -20
  48. package/dist/cli/{chunk-T6W7SKE7.mjs → chunk-RQKCNQ5Q.mjs} +2 -2
  49. package/dist/cli/{chunk-CG3R4ZFS.mjs → chunk-SCM6BR4Q.mjs} +1 -1
  50. package/dist/cli/{chunk-A5MRMCMW.js → chunk-TE2NSUT5.js} +5 -5
  51. package/dist/cli/{chunk-BHHCQGUY.mjs → chunk-UI7BBF2O.mjs} +5 -5
  52. package/dist/cli/{chunk-7Q3EXOLC.js → chunk-UTPANENL.js} +12 -12
  53. package/dist/cli/{chunk-4SVFZCCI.mjs → chunk-V7OFUYMO.mjs} +2 -2
  54. package/dist/cli/{chunk-OWOUDGHO.js → chunk-V7ZOAXZ4.js} +23 -23
  55. package/dist/cli/{chunk-BTKVXI3G.mjs → chunk-VACBPVIR.mjs} +12 -2
  56. package/dist/cli/{chunk-LIS6UJSC.mjs → chunk-WOZKGI6H.mjs} +1 -1
  57. package/dist/cli/{chunk-D4GCU735.mjs → chunk-XLM7L4UY.mjs} +1 -1
  58. package/dist/cli/{chunk-QGJ4DYGE.js → chunk-Y5CZWGO4.js} +1 -1
  59. package/dist/cli/{chunk-IS67LBNV.js → chunk-YDWFE7MX.js} +2 -2
  60. package/dist/cli/{chunk-67J4K4G2.js → chunk-Z4FWF237.js} +15 -15
  61. package/dist/cli/{chunk-ARGJDP77.mjs → chunk-ZJJUVUP6.mjs} +2 -2
  62. package/dist/cli/{chunk-6GBQNS6L.mjs → chunk-ZSDZ3Q5P.mjs} +1 -1
  63. package/dist/cli/{chunk-C7BQBKRZ.js → chunk-ZXB2Y3SG.js} +4 -4
  64. package/dist/cli/{chunk-VPJ663PV.js → chunk-ZY64JRBV.js} +10 -10
  65. package/dist/cli/command-docs.js +2 -2
  66. package/dist/cli/command-docs.mjs +1 -1
  67. package/dist/cli/{concurrent-runs-help-ZWWMHCK4.mjs → concurrent-runs-help-TCB2EKTR.mjs} +6 -6
  68. package/dist/cli/concurrent-runs-help-TKAZVMA4.js +22 -0
  69. package/dist/cli/{csv-V2FR4SO2.js → csv-DWC44DLD.js} +13 -13
  70. package/dist/cli/{csv-D76CXYOL.mjs → csv-R45YJYUO.mjs} +4 -4
  71. package/dist/cli/{db-B23O6Q4O.js → db-XIN3KF47.js} +27 -27
  72. package/dist/cli/{db-2D7PD7A3.mjs → db-XZXNKW7B.mjs} +6 -6
  73. package/dist/cli/{describe-3LG6VO3D.mjs → describe-6KSAHJBD.mjs} +18 -18
  74. package/dist/cli/describe-WLRAQDYC.js +50 -0
  75. package/dist/cli/describe-core.d.mts +2 -2
  76. package/dist/cli/describe-core.d.ts +2 -2
  77. package/dist/cli/{executions-4P4UBPMX.js → executions-C3UZLR7Y.js} +8 -8
  78. package/dist/cli/{executions-ORWO4SR4.mjs → executions-RSPQRWYL.mjs} +6 -6
  79. package/dist/cli/{feedback-AY47IRDD.mjs → feedback-7RCSKLW4.mjs} +6 -6
  80. package/dist/cli/{feedback-LPHCSOJT.js → feedback-A7WP67XL.js} +14 -14
  81. package/dist/cli/git-E6XV5MEY.js +26 -0
  82. package/dist/cli/{git-LQGZNBZM.mjs → git-JE6TFEK4.mjs} +5 -5
  83. package/dist/cli/index.js +147 -147
  84. package/dist/cli/index.mjs +46 -46
  85. package/dist/cli/{integrations-NEUZIBQT.mjs → integrations-DEU3ZW5P.mjs} +40 -7
  86. package/dist/cli/{integrations-QEOUALDR.js → integrations-L2D3EY3H.js} +48 -15
  87. package/dist/cli/{legacy-noops-PUO5VKHN.js → legacy-noops-AHTEO6EF.js} +9 -9
  88. package/dist/cli/{legacy-noops-4G3DXN57.mjs → legacy-noops-TL5PBCVQ.mjs} +6 -6
  89. package/dist/cli/{mcp-EWAZKABW.js → mcp-KXR7YJEG.js} +24 -24
  90. package/dist/cli/{mcp-USM2QUKK.mjs → mcp-PVRF5CGK.mjs} +4 -4
  91. package/dist/cli/{monitors-T6FJSZCP.mjs → monitors-BMGSROH3.mjs} +7 -7
  92. package/dist/cli/{monitors-2BI5J46A.js → monitors-YHF6RQGU.js} +100 -100
  93. package/dist/cli/{org-V6V3E7F7.js → org-IQJO6DJ7.js} +121 -121
  94. package/dist/cli/{org-BT45O64S.mjs → org-OO6LQPS6.mjs} +6 -6
  95. package/dist/cli/{outcomes-2T6W554M.mjs → outcomes-6QO6NEKO.mjs} +6 -6
  96. package/dist/cli/{outcomes-B6RPHM6M.js → outcomes-NAEAOCNT.js} +14 -14
  97. package/dist/cli/{play-CBBGJPRI.mjs → play-MZQSOYVV.mjs} +19 -19
  98. package/dist/cli/{play-YCFVGEWK.js → play-TYIBTW4E.js} +324 -324
  99. package/dist/cli/{providers-AGRUGBIY.js → providers-JDSSPMWH.js} +9 -9
  100. package/dist/cli/{providers-RHBUQFFO.mjs → providers-JR4OWXRX.mjs} +6 -6
  101. package/dist/cli/{quickstart-OPR5NLIQ.mjs → quickstart-JBX6BKGZ.mjs} +4 -4
  102. package/dist/cli/{quickstart-6N2KPWII.js → quickstart-T363ASLH.js} +6 -6
  103. package/dist/cli/{run-HAU2STMQ.mjs → run-6PWTGRJI.mjs} +23 -23
  104. package/dist/cli/{run-MMANMS4E.js → run-J3KWBIXA.js} +44 -44
  105. package/dist/cli/search-DPVHT5MJ.js +32 -0
  106. package/dist/cli/{search-TGWQMQ2C.mjs → search-XQG7UXAE.mjs} +7 -7
  107. package/dist/cli/{search-output-DZBYNJEO.mjs → search-output-DNONJFPF.mjs} +4 -4
  108. package/dist/cli/{search-output-VVM3DO2H.js → search-output-YZYLNDU6.js} +6 -6
  109. package/dist/cli/{secrets-Z6NEKNWM.mjs → secrets-MR7VXG74.mjs} +6 -6
  110. package/dist/cli/{secrets-V5WD552F.js → secrets-SCKPXIT7.js} +15 -15
  111. package/dist/cli/{sessions-C5GNXSPB.mjs → sessions-MPIJTGWQ.mjs} +6 -6
  112. package/dist/cli/sessions-VNWLXJR2.js +23 -0
  113. package/dist/cli/{settings-QUDVUIOJ.mjs → settings-Y5NW74ER.mjs} +12 -12
  114. package/dist/cli/{settings-EZPZXJDG.js → settings-YPKR5JFF.js} +85 -85
  115. package/dist/cli/{setup-BCJBVQTI.mjs → setup-5RJCLRZI.mjs} +9 -9
  116. package/dist/cli/{setup-QY5VVGWQ.js → setup-673Q3LGR.js} +49 -49
  117. package/dist/cli/{skills-LY2WZ22U.mjs → skills-2QVBD4LD.mjs} +7 -7
  118. package/dist/cli/skills-YGFFPGCR.js +37 -0
  119. package/dist/cli/tools-2BC7K3ZU.js +57 -0
  120. package/dist/cli/{tools-FNCTTFWA.mjs → tools-627KG34F.mjs} +17 -17
  121. package/dist/cli/{update-YKQAC4AQ.mjs → update-535TTARD.mjs} +9 -9
  122. package/dist/cli/update-HWEOSPDS.js +37 -0
  123. package/dist/cli/{views-5R5NVYHL.mjs → views-3M24ZTXA.mjs} +6 -6
  124. package/dist/cli/{views-NBTOBB67.js → views-FQNWZUWB.js} +21 -21
  125. package/dist/cli/{workflow-HBDW43GT.mjs → workflow-CN46XZPG.mjs} +7 -7
  126. package/dist/cli/{workflow-VNPT5VQS.js → workflow-H6F7WAOE.js} +17 -17
  127. package/dist/{client-BoayTB7p.d.ts → client-BSxuaObS.d.ts} +1 -1
  128. package/dist/{client-1ogYQqUw.d.mts → client-CnphYDTe.d.mts} +1 -1
  129. package/dist/{client-core-Ch8CXaX4.d.mts → client-core-DQOTt3yV.d.mts} +37 -2
  130. package/dist/{client-core-DySw9x_E.d.ts → client-core-Yad6-K7-.d.ts} +37 -2
  131. package/dist/index.d.mts +3 -3
  132. package/dist/index.d.ts +3 -3
  133. package/dist/index.js +9 -9
  134. package/dist/index.mjs +6 -6
  135. package/dist/install-integrity.json +118 -118
  136. package/dist/plays/play-description.d.mts +1 -1
  137. package/dist/plays/play-description.d.ts +1 -1
  138. package/dist/plays/run-request.d.mts +1 -1
  139. package/dist/plays/run-request.d.ts +1 -1
  140. package/dist/release.d.mts +1 -1
  141. package/dist/release.d.ts +1 -1
  142. package/dist/release.js +2 -2
  143. package/dist/release.mjs +1 -1
  144. package/dist/server.d.mts +2 -2
  145. package/dist/server.d.ts +2 -2
  146. package/dist/server.js +5 -5
  147. package/dist/server.mjs +3 -3
  148. package/package.json +1 -1
  149. package/dist/cli/auth-TWSGYOWI.js +0 -44
  150. package/dist/cli/concurrent-runs-help-4VRUNL3T.js +0 -22
  151. package/dist/cli/describe-QE4ITFPG.js +0 -50
  152. package/dist/cli/git-XXVGEPEM.js +0 -26
  153. package/dist/cli/search-7LMUBMDC.js +0 -32
  154. package/dist/cli/sessions-VYIPZBSR.js +0 -23
  155. package/dist/cli/skills-PKNTNDYL.js +0 -37
  156. package/dist/cli/tools-D6CKFZL3.js +0 -57
  157. package/dist/cli/update-E2H2DWH4.js +0 -37
@@ -37,7 +37,7 @@ var _chunkPMH4GLMDjs = require('./chunk-PMH4GLMD.js');
37
37
 
38
38
 
39
39
 
40
- var _chunkC7BQBKRZjs = require('./chunk-C7BQBKRZ.js');
40
+ var _chunkZXB2Y3SGjs = require('./chunk-ZXB2Y3SG.js');
41
41
 
42
42
 
43
43
  var _chunk6VLFQZK6js = require('./chunk-6VLFQZK6.js');
@@ -48,6 +48,145 @@ var _chunk6VLFQZK6js = require('./chunk-6VLFQZK6.js');
48
48
 
49
49
  var _chunkLFQJW4S2js = require('./chunk-LFQJW4S2.js');
50
50
 
51
+ // src/integrations.ts
52
+ var CALENDAR_PROVIDER = "google_calendar_availability";
53
+ var AD_ACCOUNT_DISCOVERY_PROVIDERS = [
54
+ "google_ads_audiences",
55
+ "linkedin_ads_audiences"
56
+ ];
57
+ function invalid(message) {
58
+ throw new (0, _chunkLFQJW4S2js.DeeplineError)(message, 400, "INVALID_ARGUMENT");
59
+ }
60
+ function planAdAccountDiscovery(provider) {
61
+ if (!AD_ACCOUNT_DISCOVERY_PROVIDERS.includes(provider)) {
62
+ invalid(`Choose ${AD_ACCOUNT_DISCOVERY_PROVIDERS.join(" or ")}.`);
63
+ }
64
+ return {
65
+ provider,
66
+ method: "POST",
67
+ path: `/api/v2/integrations/${provider}/accounts`,
68
+ body: {}
69
+ };
70
+ }
71
+ async function findConnection(client, name, provider) {
72
+ const { connections } = await client.listWorkspaceConnectionInventory(
73
+ provider,
74
+ { authorizationsOnly: true }
75
+ );
76
+ const matches = connections.filter(
77
+ (row) => row.name === name && (!provider || row.provider === provider)
78
+ );
79
+ if (matches.length === 0)
80
+ throw new (0, _chunkLFQJW4S2js.DeeplineError)(
81
+ `No org connection named ${JSON.stringify(name)}. Run deepline integrations list --json.`,
82
+ 404,
83
+ "NOT_FOUND"
84
+ );
85
+ if (matches.length > 1)
86
+ invalid("This name exists for multiple providers. Pass --provider.");
87
+ return matches[0];
88
+ }
89
+ async function changeConnection(client, action, name, options) {
90
+ const row = await findConnection(client, name, options.provider);
91
+ if (options.booking && (action !== "reconnect" || row.type !== "workspace_delegation"))
92
+ invalid("Use --booking with Google Workspace verify or reconnect.");
93
+ if (options.listCalendars && (action !== "reconnect" || row.type !== "workspace_delegation"))
94
+ invalid("Use --list-calendars with Google Workspace verify or reconnect.");
95
+ if (row.type === "workspace_delegation") {
96
+ if (row.provider !== CALENDAR_PROVIDER || !row.domain)
97
+ invalid(
98
+ "The Google Workspace approval is missing its provider or domain."
99
+ );
100
+ if (row.authorizationVersion === void 0)
101
+ invalid("The API did not return a Google Workspace approval revision.");
102
+ if (action === "reconnect") {
103
+ return verifyWorkspace(client, row.domain, options, row);
104
+ }
105
+ if (options.verificationEmail)
106
+ invalid("Use --verification-email with reconnect or verify.");
107
+ if (action === "delete" && row.status !== "disconnected")
108
+ invalid("Disconnect this approval before deleting it.");
109
+ const change2 = action === "delete" ? {
110
+ action: "remove_workspace",
111
+ domain: row.domain,
112
+ connectionId: row.id,
113
+ grantRevision: row.authorizationVersion
114
+ } : {
115
+ action: "disable_workspace",
116
+ domain: row.domain,
117
+ connectionId: row.id,
118
+ grantRevision: row.authorizationVersion
119
+ };
120
+ if (options.dryRun) return change2;
121
+ return client.changeCalendarDelegation(change2);
122
+ }
123
+ if (options.verificationEmail)
124
+ invalid("--verification-email applies to Google Workspace approvals.");
125
+ if (row.type !== "oauth" || row.provider !== "hubspot" && row.provider !== CALENDAR_PROVIDER)
126
+ invalid(
127
+ "Manage this credential type through deepline integrations connect <provider> --link."
128
+ );
129
+ if (row.authorizationVersion === void 0)
130
+ invalid("The API did not return a connection authorization version.");
131
+ const change = {
132
+ action: action === "delete" ? "remove" : action,
133
+ provider: row.provider,
134
+ name,
135
+ connectionId: row.id,
136
+ authorizationVersion: row.authorizationVersion
137
+ };
138
+ if (options.dryRun) return change;
139
+ return client.manageWorkspaceIntegrationConnection(change);
140
+ }
141
+ async function verifyWorkspace(client, domain, options, existing) {
142
+ domain = domain.trim().toLowerCase();
143
+ if (!_chunk4WAM6TLDjs.GOOGLE_WORKSPACE_DOMAIN_PATTERN.test(domain))
144
+ invalid("Enter a Google Workspace domain, such as example.com.");
145
+ const email = _optionalChain([options, 'access', _ => _.verificationEmail, 'optionalAccess', _2 => _2.trim, 'call', _3 => _3(), 'access', _4 => _4.toLowerCase, 'call', _5 => _5()]);
146
+ if (!email || email.length > 254 || !/^[^\s@]+@[^\s@]+$/.test(email) || email.split("@")[1] !== domain)
147
+ invalid("Pass --verification-email with a work email in this domain.");
148
+ const settings = existing ? {
149
+ grantRevision: existing.authorizationVersion,
150
+ connectionId: existing.id,
151
+ grantedScopes: existing.scopes
152
+ } : await client.getCalendarDelegation(void 0, void 0, domain);
153
+ if (settings.grantRevision === void 0)
154
+ invalid("The API did not return a Google Workspace approval revision.");
155
+ const requestedScopes = [
156
+ .../* @__PURE__ */ new Set([
157
+ _chunk4WAM6TLDjs.GOOGLE_WORKSPACE_AVAILABILITY_SCOPE,
158
+ ..._nullishCoalesce(settings.grantedScopes, () => ( [])),
159
+ ...options.booking ? [_chunk4WAM6TLDjs.GOOGLE_WORKSPACE_BOOKING_SCOPE] : [],
160
+ ...options.listCalendars ? [_chunk4WAM6TLDjs.GOOGLE_WORKSPACE_CALENDAR_LIST_SCOPE] : []
161
+ ])
162
+ ];
163
+ const change = {
164
+ action: "enable_workspace",
165
+ domain,
166
+ grantRevision: settings.grantRevision,
167
+ ...settings.connectionId ? { connectionId: settings.connectionId } : {},
168
+ verificationEmail: email,
169
+ ...requestedScopes.length > 1 ? { requestedScopes } : {}
170
+ };
171
+ if (options.dryRun) return change;
172
+ return client.changeCalendarDelegation(change);
173
+ }
174
+ function createIntegrationsNamespace(client) {
175
+ return {
176
+ list: (options = {}) => client.listWorkspaceConnectionInventory(options.provider, {
177
+ authorizationsOnly: true
178
+ }),
179
+ get: (name, options = {}) => findConnection(client, name, options.provider),
180
+ connect: (provider) => client.getIntegrationConnectLink(provider),
181
+ discoverAdAccounts: (provider) => client.discoverAdAccounts(provider),
182
+ reconnect: (name, options = {}) => changeConnection(client, "reconnect", name, options),
183
+ disconnect: (name, options = {}) => changeConnection(client, "disconnect", name, options),
184
+ delete: (name, options = {}) => changeConnection(client, "delete", name, options),
185
+ verify: (domain, options) => verifyWorkspace(client, domain, options),
186
+ members: (provider, options = {}) => client.listManagedConnectionMembers(provider, options.cursor)
187
+ };
188
+ }
189
+
51
190
  // ../integration-contracts/billing-plan-skus.ts
52
191
  var PLAN_OFFER_SKUS = {
53
192
  solo: "payg-v1",
@@ -166,7 +305,7 @@ async function queryCustomerDatabase(http, input, maxRetries) {
166
305
  }
167
306
  );
168
307
  } catch (error) {
169
- if (error instanceof _chunkLFQJW4S2js.DeeplineError && (_optionalChain([error, 'access', _ => _.code, 'optionalAccess', _2 => _2.startsWith, 'call', _3 => _3("NETWORK_")]) || // Older API readers return PostgreSQL errors as HTTP 400, including
308
+ if (error instanceof _chunkLFQJW4S2js.DeeplineError && (_optionalChain([error, 'access', _6 => _6.code, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8("NETWORK_")]) || // Older API readers return PostgreSQL errors as HTTP 400, including
170
309
  // lost connections and explicitly unknown transaction resolution.
171
310
  /^08[A-Z0-9]{3}$/.test(_nullishCoalesce(error.code, () => ( ""))) || ["57P01", "57P02", "57P03"].includes(_nullishCoalesce(error.code, () => ( ""))) || error.statusCode === 408 || (_nullishCoalesce(error.statusCode, () => ( 0))) >= 500)) {
172
311
  throw new (0, _chunk6VLFQZK6js.CustomerDbQueryOutcomeUnknownError)(
@@ -365,7 +504,7 @@ function parseExecuteServerTiming(header) {
365
504
  const durations = /* @__PURE__ */ new Map();
366
505
  for (const rawEntry of header.split(",")) {
367
506
  const parts = rawEntry.split(";");
368
- const name = _optionalChain([parts, 'access', _4 => _4[0], 'optionalAccess', _5 => _5.trim, 'call', _6 => _6(), 'access', _7 => _7.toLowerCase, 'call', _8 => _8()]);
507
+ const name = _optionalChain([parts, 'access', _9 => _9[0], 'optionalAccess', _10 => _10.trim, 'call', _11 => _11(), 'access', _12 => _12.toLowerCase, 'call', _13 => _13()]);
369
508
  if (!name) continue;
370
509
  for (const parameter of parts.slice(1)) {
371
510
  const separator = parameter.indexOf("=");
@@ -500,7 +639,7 @@ function isRecoverableExecutionAttemptError(error) {
500
639
  if (error instanceof _chunkLFQJW4S2js.ToolExecutionError) {
501
640
  return error.code === "EXECUTION_IN_PROGRESS" || error.origin === "deepline" && error.category === "network" && error.networkScope === "client_to_deepline";
502
641
  }
503
- return error instanceof _chunkLFQJW4S2js.DeeplineError && (error.code === "EXECUTION_IN_PROGRESS" || _optionalChain([error, 'access', _9 => _9.code, 'optionalAccess', _10 => _10.startsWith, 'call', _11 => _11("NETWORK_")]) === true && error.statusCode === void 0);
642
+ return error instanceof _chunkLFQJW4S2js.DeeplineError && (error.code === "EXECUTION_IN_PROGRESS" || _optionalChain([error, 'access', _14 => _14.code, 'optionalAccess', _15 => _15.startsWith, 'call', _16 => _16("NETWORK_")]) === true && error.statusCode === void 0);
504
643
  }
505
644
  function isRecoverableExecutionLookupError(error) {
506
645
  if (isRecoverableExecutionAttemptError(error)) return true;
@@ -609,32 +748,32 @@ var ToolCalls = class {
609
748
  this.configuredRequestTimeoutMs = configuredRequestTimeoutMs;
610
749
  }
611
750
  async call(toolId, input, options) {
612
- const connection = _optionalChain([options, 'optionalAccess', _12 => _12.connection]);
613
- if (connection !== void 0 && (!_chunk4WAM6TLDjs.isToolConnectionName.call(void 0, connection) || _optionalChain([options, 'optionalAccess', _13 => _13.idempotencyKey]) !== void 0 || _optionalChain([options, 'optionalAccess', _14 => _14.recover]))) {
751
+ const connection = _optionalChain([options, 'optionalAccess', _17 => _17.connection]);
752
+ if (connection !== void 0 && (!_chunk4WAM6TLDjs.isToolConnectionName.call(void 0, connection) || _optionalChain([options, 'optionalAccess', _18 => _18.idempotencyKey]) !== void 0 || _optionalChain([options, 'optionalAccess', _19 => _19.recover]))) {
614
753
  throw new (0, _chunkLFQJW4S2js.DeeplineError)(
615
754
  "Use a valid org connection name without execution recovery.",
616
755
  400,
617
756
  "NAMED_CONNECTION_INVALID"
618
757
  );
619
758
  }
620
- if (_optionalChain([options, 'optionalAccess', _15 => _15.cliInvocationId]) !== void 0) {
759
+ if (_optionalChain([options, 'optionalAccess', _20 => _20.cliInvocationId]) !== void 0) {
621
760
  validateCliInvocationId(options.cliInvocationId);
622
761
  }
623
762
  const inputSnapshot = JSON.parse(JSON.stringify(input));
624
- const metadataSnapshot = _optionalChain([options, 'optionalAccess', _16 => _16.metadata]) ? JSON.parse(JSON.stringify(options.metadata)) : void 0;
625
- const idempotencyKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _17 => _17.idempotencyKey]), () => ( (_optionalChain([options, 'optionalAccess', _18 => _18.recover]) ? crypto.randomUUID() : void 0)));
763
+ const metadataSnapshot = _optionalChain([options, 'optionalAccess', _21 => _21.metadata]) ? JSON.parse(JSON.stringify(options.metadata)) : void 0;
764
+ const idempotencyKey = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _22 => _22.idempotencyKey]), () => ( (_optionalChain([options, 'optionalAccess', _23 => _23.recover]) ? crypto.randomUUID() : void 0)));
626
765
  if (idempotencyKey !== void 0) {
627
766
  validateExecutionIdempotencyKey(idempotencyKey);
628
- if (_optionalChain([options, 'optionalAccess', _19 => _19.recoveryTimeoutMs]) !== void 0 && (!Number.isFinite(options.recoveryTimeoutMs) || options.recoveryTimeoutMs < 0)) {
767
+ if (_optionalChain([options, 'optionalAccess', _24 => _24.recoveryTimeoutMs]) !== void 0 && (!Number.isFinite(options.recoveryTimeoutMs) || options.recoveryTimeoutMs < 0)) {
629
768
  throw new (0, _chunkLFQJW4S2js.DeeplineError)(
630
769
  "recoveryTimeoutMs must be a finite, non-negative number.",
631
770
  void 0,
632
771
  "IDEMPOTENCY_KEY_INVALID"
633
772
  );
634
773
  }
635
- await _optionalChain([options, 'optionalAccess', _20 => _20.onExecution, 'optionalCall', _21 => _21({ idempotencyKey })]);
774
+ await _optionalChain([options, 'optionalAccess', _25 => _25.onExecution, 'optionalCall', _26 => _26({ idempotencyKey })]);
636
775
  }
637
- const timeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _22 => _22.timeout]), () => ( resolveToolExecuteTimeoutMs(
776
+ const timeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _27 => _27.timeout]), () => ( resolveToolExecuteTimeoutMs(
638
777
  toolId,
639
778
  inputSnapshot,
640
779
  this.configuredRequestTimeoutMs
@@ -646,11 +785,11 @@ var ToolCalls = class {
646
785
  [_chunkLFQJW4S2js.TOOL_EXECUTION_ERROR_SCHEMA_HEADER]: String(
647
786
  _chunkLFQJW4S2js.TOOL_EXECUTION_ERROR_SCHEMA_VERSION
648
787
  ),
649
- ..._optionalChain([options, 'optionalAccess', _23 => _23.includeToolMetadata]) ? { [INCLUDE_TOOL_METADATA_HEADER]: "true" } : {},
650
- [EXECUTE_RESPONSE_INTENT_HEADER]: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _24 => _24.responseIntent]), () => ( "raw")),
788
+ ..._optionalChain([options, 'optionalAccess', _28 => _28.includeToolMetadata]) ? { [INCLUDE_TOOL_METADATA_HEADER]: "true" } : {},
789
+ [EXECUTE_RESPONSE_INTENT_HEADER]: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _29 => _29.responseIntent]), () => ( "raw")),
651
790
  ...idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {},
652
- ..._optionalChain([options, 'optionalAccess', _25 => _25.searchRef]) ? { "x-deepline-search-ref": options.searchRef } : {},
653
- ..._optionalChain([options, 'optionalAccess', _26 => _26.cliInvocationId]) !== void 0 ? { "x-deepline-cli-invocation-id": options.cliInvocationId } : {}
791
+ ..._optionalChain([options, 'optionalAccess', _30 => _30.searchRef]) ? { "x-deepline-search-ref": options.searchRef } : {},
792
+ ..._optionalChain([options, 'optionalAccess', _31 => _31.cliInvocationId]) !== void 0 ? { "x-deepline-cli-invocation-id": options.cliInvocationId } : {}
654
793
  };
655
794
  let lastResponse = null;
656
795
  const observeTerminal = (failure) => {
@@ -665,7 +804,7 @@ var ToolCalls = class {
665
804
  if (recovery === "running" || recovery === "outcome_unknown") return;
666
805
  const state = isRecord(body) ? body.status : null;
667
806
  const terminal = state === "completed" || state === "failed" || state === "cancelled" ? state : state === "canceled" ? "cancelled" : failure ? "failed" : null;
668
- if (!terminal || !_optionalChain([options, 'optionalAccess', _27 => _27.onResponseReceived])) return;
807
+ if (!terminal || !_optionalChain([options, 'optionalAccess', _32 => _32.onResponseReceived])) return;
669
808
  const reportObservationFailure = () => console.error("[tools.execute] response observation failed");
670
809
  try {
671
810
  const notification = options.onResponseReceived({
@@ -680,8 +819,8 @@ var ToolCalls = class {
680
819
  };
681
820
  const legacyEndpoint = `/api/v2/integrations/${encodeURIComponent(toolId)}/execute`;
682
821
  let useLegacyEndpoint = idempotencyKey === void 0;
683
- const atomicToolOnly = _optionalChain([options, 'optionalAccess', _28 => _28.atomicToolOnly]) === true;
684
- const retryAmbiguousDelivery = connection === void 0 && atomicToolOnly && !idempotencyKey && _optionalChain([options, 'optionalAccess', _29 => _29.retryAmbiguousDelivery]) === true;
822
+ const atomicToolOnly = _optionalChain([options, 'optionalAccess', _33 => _33.atomicToolOnly]) === true;
823
+ const retryAmbiguousDelivery = connection === void 0 && atomicToolOnly && !idempotencyKey && _optionalChain([options, 'optionalAccess', _34 => _34.retryAmbiguousDelivery]) === true;
685
824
  const dispatchRequest = async (requestTimeoutMs) => {
686
825
  let recoverySupported = false;
687
826
  let atomicToolsSupported = false;
@@ -695,9 +834,9 @@ var ToolCalls = class {
695
834
  headers,
696
835
  {
697
836
  timeout: requestTimeoutMs,
698
- maxRetries: connection !== void 0 || idempotencyKey ? 0 : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _30 => _30.maxRetries]), () => ( (retryAmbiguousDelivery ? 2 : 0))),
699
- ...connection === void 0 && atomicToolOnly && !idempotencyKey && _optionalChain([options, 'optionalAccess', _31 => _31.maxRetries]) === void 0 ? { executePolicyMaxRetries: 2 } : {},
700
- retryApiErrors: connection === void 0 && (atomicToolOnly || _optionalChain([options, 'optionalAccess', _32 => _32.retryApiErrors]) === true),
837
+ maxRetries: connection !== void 0 || idempotencyKey ? 0 : _nullishCoalesce(_optionalChain([options, 'optionalAccess', _35 => _35.maxRetries]), () => ( (retryAmbiguousDelivery ? 2 : 0))),
838
+ ...connection === void 0 && atomicToolOnly && !idempotencyKey && _optionalChain([options, 'optionalAccess', _36 => _36.maxRetries]) === void 0 ? { executePolicyMaxRetries: 2 } : {},
839
+ retryApiErrors: connection === void 0 && (atomicToolOnly || _optionalChain([options, 'optionalAccess', _37 => _37.retryApiErrors]) === true),
701
840
  retryFromExecutePolicy: connection === void 0 && atomicToolOnly,
702
841
  retryAmbiguousDelivery,
703
842
  exactUrlOnly: true,
@@ -705,9 +844,9 @@ var ToolCalls = class {
705
844
  idempotencyKey,
706
845
  onResponse: (response2) => {
707
846
  lastResponse = null;
708
- atomicToolsSupported = response2.headers.get(_chunkC7BQBKRZjs.ATOMIC_TOOL_EXECUTE_SUPPORTED_HEADER) === "true";
847
+ atomicToolsSupported = response2.headers.get(_chunkZXB2Y3SGjs.ATOMIC_TOOL_EXECUTE_SUPPORTED_HEADER) === "true";
709
848
  recoverySupported = response2.headers.get("X-Deepline-Idempotency-Supported") === "true";
710
- if (_optionalChain([options, 'optionalAccess', _33 => _33.onServerTiming])) {
849
+ if (_optionalChain([options, 'optionalAccess', _38 => _38.onServerTiming])) {
711
850
  try {
712
851
  const notification = options.onServerTiming(
713
852
  parseExecuteServerTiming(
@@ -744,7 +883,7 @@ var ToolCalls = class {
744
883
  await this.lookupExecutionByKey(
745
884
  idempotencyKey,
746
885
  requestTimeoutMs,
747
- _optionalChain([options, 'optionalAccess', _34 => _34.cliInvocationId])
886
+ _optionalChain([options, 'optionalAccess', _39 => _39.cliInvocationId])
748
887
  );
749
888
  useLegacyEndpoint = true;
750
889
  return post();
@@ -761,7 +900,7 @@ var ToolCalls = class {
761
900
  };
762
901
  let response;
763
902
  let recoveryDeadline = null;
764
- const recoveryTimeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _35 => _35.recoveryTimeoutMs]), () => ( DEFAULT_EXECUTION_RECOVERY_TIMEOUT_MS));
903
+ const recoveryTimeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _40 => _40.recoveryTimeoutMs]), () => ( DEFAULT_EXECUTION_RECOVERY_TIMEOUT_MS));
765
904
  let retryDelayMs = 1e3;
766
905
  const recoveryTimeoutError = () => executionRecoveryError({
767
906
  toolId,
@@ -789,7 +928,7 @@ var ToolCalls = class {
789
928
  this.defaultRequestTimeoutMs,
790
929
  remainingMs
791
930
  ),
792
- _optionalChain([options, 'optionalAccess', _36 => _36.cliInvocationId])
931
+ _optionalChain([options, 'optionalAccess', _41 => _41.cliInvocationId])
793
932
  );
794
933
  } catch (error) {
795
934
  if (!isRecoverableExecutionLookupError(error)) throw error;
@@ -982,11 +1121,11 @@ function resolvePlayRunRuntimeSelection(request, env) {
982
1121
  }
983
1122
  return runtime;
984
1123
  }
985
- const configured = _optionalChain([env, 'access', _37 => _37.DEEPLINE_RUNTIME_ENVIRONMENT, 'optionalAccess', _38 => _38.trim, 'call', _39 => _39()]);
986
- const configuredNamespace = _optionalChain([env, 'access', _40 => _40.DEEPLINE_RUNTIME_NAMESPACE, 'optionalAccess', _41 => _41.trim, 'call', _42 => _42()]);
987
- const configuredToken = _optionalChain([env, 'access', _43 => _43.DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN, 'optionalAccess', _44 => _44.trim, 'call', _45 => _45()]);
988
- const configuredPlacementPolicy = _optionalChain([env, 'access', _46 => _46.DEEPLINE_RUNTIME_SANDBOX_PLACEMENT_POLICY, 'optionalAccess', _47 => _47.trim, 'call', _48 => _48()]);
989
- if (_optionalChain([env, 'access', _49 => _49.DEEPLINE_RUNTIME_GATEWAY_PROFILE, 'optionalAccess', _50 => _50.trim, 'call', _51 => _51()])) {
1124
+ const configured = _optionalChain([env, 'access', _42 => _42.DEEPLINE_RUNTIME_ENVIRONMENT, 'optionalAccess', _43 => _43.trim, 'call', _44 => _44()]);
1125
+ const configuredNamespace = _optionalChain([env, 'access', _45 => _45.DEEPLINE_RUNTIME_NAMESPACE, 'optionalAccess', _46 => _46.trim, 'call', _47 => _47()]);
1126
+ const configuredToken = _optionalChain([env, 'access', _48 => _48.DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN, 'optionalAccess', _49 => _49.trim, 'call', _50 => _50()]);
1127
+ const configuredPlacementPolicy = _optionalChain([env, 'access', _51 => _51.DEEPLINE_RUNTIME_SANDBOX_PLACEMENT_POLICY, 'optionalAccess', _52 => _52.trim, 'call', _53 => _53()]);
1128
+ if (_optionalChain([env, 'access', _54 => _54.DEEPLINE_RUNTIME_GATEWAY_PROFILE, 'optionalAccess', _55 => _55.trim, 'call', _56 => _56()])) {
990
1129
  throw new (0, _chunkLFQJW4S2js.DeeplineError)(
991
1130
  "DEEPLINE_RUNTIME_GATEWAY_PROFILE was removed: Runtime gateway profiles (vercel_app@1) are no longer available. Unset it to run on the default gateways.",
992
1131
  void 0,
@@ -1044,7 +1183,7 @@ function resolvePlayRunRuntimeSelection(request, env) {
1044
1183
  "INVALID_RUNTIME_NAMESPACE"
1045
1184
  );
1046
1185
  }
1047
- const configuredBackendValue = _optionalChain([env, 'access', _52 => _52.DEEPLINE_PLAY_RUNNER_BACKEND, 'optionalAccess', _53 => _53.trim, 'call', _54 => _54()]);
1186
+ const configuredBackendValue = _optionalChain([env, 'access', _57 => _57.DEEPLINE_PLAY_RUNNER_BACKEND, 'optionalAccess', _58 => _58.trim, 'call', _59 => _59()]);
1048
1187
  const configuredBackend = configuredBackendValue === "daytona" || configuredBackendValue === "modal" ? configuredBackendValue : void 0;
1049
1188
  if (configuredBackendValue && !configuredBackend) {
1050
1189
  throw new (0, _chunkLFQJW4S2js.DeeplineError)(
@@ -1082,7 +1221,7 @@ function resolveStartPlayRunRequest(request, env) {
1082
1221
  }
1083
1222
  function runtimeSelectionHeaders(runtime, env) {
1084
1223
  if (!runtime || runtime.environment === "native") return void 0;
1085
- const token = _optionalChain([env, 'access', _55 => _55.DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN, 'optionalAccess', _56 => _56.trim, 'call', _57 => _57()]);
1224
+ const token = _optionalChain([env, 'access', _60 => _60.DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN, 'optionalAccess', _61 => _61.trim, 'call', _62 => _62()]);
1086
1225
  if (!token) {
1087
1226
  throw new (0, _chunkLFQJW4S2js.DeeplineError)(
1088
1227
  "DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN is required for explicit preview runtime selection.",
@@ -1090,17 +1229,17 @@ function runtimeSelectionHeaders(runtime, env) {
1090
1229
  "RUNTIME_ENVIRONMENT_TOKEN_REQUIRED"
1091
1230
  );
1092
1231
  }
1093
- const receivers = _optionalChain([env, 'access', _58 => _58.DEEPLINE_RUNTIME_RETAINED_PIPELINE_RECEIVERS, 'optionalAccess', _59 => _59.trim, 'call', _60 => _60()]);
1232
+ const receivers = _optionalChain([env, 'access', _63 => _63.DEEPLINE_RUNTIME_RETAINED_PIPELINE_RECEIVERS, 'optionalAccess', _64 => _64.trim, 'call', _65 => _65()]);
1094
1233
  return {
1095
- [_chunkC7BQBKRZjs.RUNTIME_ENVIRONMENT_TOKEN_HEADER]: token,
1096
- ...receivers ? { [_chunkC7BQBKRZjs.RETAINED_PIPELINE_RECEIVERS_HEADER]: receivers } : {}
1234
+ [_chunkZXB2Y3SGjs.RUNTIME_ENVIRONMENT_TOKEN_HEADER]: token,
1235
+ ...receivers ? { [_chunkZXB2Y3SGjs.RETAINED_PIPELINE_RECEIVERS_HEADER]: receivers } : {}
1097
1236
  };
1098
1237
  }
1099
1238
  function playRunStartHeaders(runtime, env) {
1100
1239
  const headers = runtimeSelectionHeaders(runtime, env);
1101
- const experimentSwitches = _optionalChain([env, 'access', _61 => _61.DEEPLINE_EXPERIMENT_SWITCHES, 'optionalAccess', _62 => _62.trim, 'call', _63 => _63()]);
1240
+ const experimentSwitches = _optionalChain([env, 'access', _66 => _66.DEEPLINE_EXPERIMENT_SWITCHES, 'optionalAccess', _67 => _67.trim, 'call', _68 => _68()]);
1102
1241
  if (!experimentSwitches) return headers;
1103
- return { ...headers, [_chunkC7BQBKRZjs.EXPERIMENT_SWITCHES_HEADER]: experimentSwitches };
1242
+ return { ...headers, [_chunkZXB2Y3SGjs.EXPERIMENT_SWITCHES_HEADER]: experimentSwitches };
1104
1243
  }
1105
1244
  function normalizeTestPolicyOverrides(value, source) {
1106
1245
  if (value && typeof value === "object" && !Array.isArray(value)) {
@@ -1114,7 +1253,7 @@ function normalizeTestPolicyOverrides(value, source) {
1114
1253
  }
1115
1254
  function parseEnvTestPolicyOverrides(env) {
1116
1255
  const raw = env.DEEPLINE_TEST_POLICY_OVERRIDES;
1117
- const trimmed = _optionalChain([raw, 'optionalAccess', _64 => _64.trim, 'call', _65 => _65()]);
1256
+ const trimmed = _optionalChain([raw, 'optionalAccess', _69 => _69.trim, 'call', _70 => _70()]);
1118
1257
  if (!trimmed) return void 0;
1119
1258
  let parsed;
1120
1259
  try {
@@ -1134,17 +1273,17 @@ function isRecord2(value) {
1134
1273
  }
1135
1274
  function normalizePlayStatus(raw) {
1136
1275
  const runPackage = _chunkMJTVX4QKjs.isPlayRunPackage.call(void 0, raw) ? raw : _chunkMJTVX4QKjs.isPlayRunPackage.call(void 0, raw.package) ? raw.package : null;
1137
- const packageRun = _optionalChain([runPackage, 'optionalAccess', _66 => _66.run]);
1138
- const rawStatus = typeof raw.status === "string" ? raw.status : typeof _optionalChain([packageRun, 'optionalAccess', _67 => _67.status]) === "string" ? packageRun.status : null;
1276
+ const packageRun = _optionalChain([runPackage, 'optionalAccess', _71 => _71.run]);
1277
+ const rawStatus = typeof raw.status === "string" ? raw.status : typeof _optionalChain([packageRun, 'optionalAccess', _72 => _72.status]) === "string" ? packageRun.status : null;
1139
1278
  const status = _chunkMJTVX4QKjs.decodePlayRunPublicStatus.call(void 0, rawStatus);
1140
1279
  if (!status) {
1141
1280
  throw new Error(
1142
1281
  `Invalid play run lifecycle status in API response: ${JSON.stringify(rawStatus)}.`
1143
1282
  );
1144
1283
  }
1145
- const runId = typeof raw.runId === "string" ? raw.runId : typeof raw.workflowId === "string" ? raw.workflowId : _nullishCoalesce(_optionalChain([packageRun, 'optionalAccess', _68 => _68.id]), () => ( ""));
1146
- const legacyOverview = _nullishCoalesce(_optionalChain([runPackage, 'optionalAccess', _69 => _69.overview]), () => ( raw.overview));
1147
- const runStatus = _nullishCoalesce(_optionalChain([runPackage, 'optionalAccess', _70 => _70.runStatus]), () => ( raw.runStatus));
1284
+ const runId = typeof raw.runId === "string" ? raw.runId : typeof raw.workflowId === "string" ? raw.workflowId : _nullishCoalesce(_optionalChain([packageRun, 'optionalAccess', _73 => _73.id]), () => ( ""));
1285
+ const legacyOverview = _nullishCoalesce(_optionalChain([runPackage, 'optionalAccess', _74 => _74.overview]), () => ( raw.overview));
1286
+ const runStatus = _nullishCoalesce(_optionalChain([runPackage, 'optionalAccess', _75 => _75.runStatus]), () => ( raw.runStatus));
1148
1287
  return {
1149
1288
  ...raw,
1150
1289
  runId,
@@ -1170,22 +1309,22 @@ var PlayClient = class {
1170
1309
  return _chunkMJTVX4QKjs.startPlayRun.call(void 0,
1171
1310
  this.http,
1172
1311
  resolved.request,
1173
- _optionalChain([options, 'optionalAccess', _71 => _71.cliAdmission]) ? { ...headers, "X-Deepline-API-Major": String(_chunkC7BQBKRZjs.SDK_API_MAJOR) } : headers,
1312
+ _optionalChain([options, 'optionalAccess', _76 => _76.cliAdmission]) ? { ...headers, "X-Deepline-API-Major": String(_chunkZXB2Y3SGjs.SDK_API_MAJOR) } : headers,
1174
1313
  options
1175
1314
  );
1176
1315
  }
1177
1316
  async getPlayStatus(workflowId, options) {
1178
1317
  const params = new URLSearchParams();
1179
- if (_optionalChain([options, 'optionalAccess', _72 => _72.billing]) === false) {
1318
+ if (_optionalChain([options, 'optionalAccess', _77 => _77.billing]) === false) {
1180
1319
  params.set("billing", "false");
1181
1320
  }
1182
- if (_optionalChain([options, 'optionalAccess', _73 => _73.full]) === true) {
1321
+ if (_optionalChain([options, 'optionalAccess', _78 => _78.full]) === true) {
1183
1322
  params.set("full", "true");
1184
1323
  }
1185
1324
  const query = params.size > 0 ? `?${params.toString()}` : "";
1186
1325
  const response = await this.http.get(
1187
1326
  `/api/v2/runs/${encodeURIComponent(workflowId)}${query}`,
1188
- _optionalChain([options, 'optionalAccess', _74 => _74.runStatus]) === true ? { headers: { "x-deepline-run-status": "1" } } : void 0
1327
+ _optionalChain([options, 'optionalAccess', _79 => _79.runStatus]) === true ? { headers: { "x-deepline-run-status": "1" } } : void 0
1189
1328
  );
1190
1329
  return normalizePlayStatus(response);
1191
1330
  }
@@ -1198,7 +1337,7 @@ var PlayClient = class {
1198
1337
  async stopPlay(workflowId, options) {
1199
1338
  return this.http.post(
1200
1339
  `/api/v2/runs/${encodeURIComponent(workflowId)}/stop`,
1201
- _optionalChain([options, 'optionalAccess', _75 => _75.reason]) ? { reason: options.reason } : {}
1340
+ _optionalChain([options, 'optionalAccess', _80 => _80.reason]) ? { reason: options.reason } : {}
1202
1341
  );
1203
1342
  }
1204
1343
  async listPlayRuns(playName) {
@@ -1210,7 +1349,7 @@ var PlayClient = class {
1210
1349
  }
1211
1350
  async getPlay(name, options) {
1212
1351
  const encodedName = encodeURIComponent(name);
1213
- const query = _optionalChain([options, 'optionalAccess', _76 => _76.source]) ? `?include=source&revision=${encodeURIComponent(options.source)}` : _optionalChain([options, 'optionalAccess', _77 => _77.guidance]) ? "?include=guidance" : "";
1352
+ const query = _optionalChain([options, 'optionalAccess', _81 => _81.source]) ? `?include=source&revision=${encodeURIComponent(options.source)}` : _optionalChain([options, 'optionalAccess', _82 => _82.guidance]) ? "?include=guidance" : "";
1214
1353
  return this.http.get(`/api/v2/plays/${encodedName}${query}`);
1215
1354
  }
1216
1355
  async clearPlayHistory(name, request = {}) {
@@ -1222,7 +1361,7 @@ var PlayClient = class {
1222
1361
  }
1223
1362
  async listPlayVersions(name, options) {
1224
1363
  const encodedName = encodeURIComponent(name);
1225
- const suffix = _optionalChain([options, 'optionalAccess', _78 => _78.full]) ? "?full=true" : "";
1364
+ const suffix = _optionalChain([options, 'optionalAccess', _83 => _83.full]) ? "?full=true" : "";
1226
1365
  const response = await this.http.get(
1227
1366
  `/api/v2/plays/${encodedName}/versions${suffix}`
1228
1367
  );
@@ -2179,7 +2318,7 @@ function parseDsl(input) {
2179
2318
  input.slice(position)
2180
2319
  );
2181
2320
  if (!operation) {
2182
- const token = _nullishCoalesce(_nullishCoalesce(_optionalChain([/^(?:[=!<>~]+|[A-Za-z_]+)/, 'access', _79 => _79.exec, 'call', _80 => _80(input.slice(position)), 'optionalAccess', _81 => _81[0]]), () => ( input[position])), () => ( "<end>"));
2321
+ const token = _nullishCoalesce(_nullishCoalesce(_optionalChain([/^(?:[=!<>~]+|[A-Za-z_]+)/, 'access', _84 => _84.exec, 'call', _85 => _85(input.slice(position)), 'optionalAccess', _86 => _86[0]]), () => ( input[position])), () => ( "<end>"));
2183
2322
  if (token === "=") {
2184
2323
  const corrected = `${input.slice(0, position)}==${input.slice(position + 1)}`;
2185
2324
  fail(
@@ -2258,7 +2397,7 @@ function normalizeRunEventQueryTimestamp(value) {
2258
2397
  return /[1-9]/.test(extraMicros) ? canonical2.replace(/Z$/, `${extraMicros}Z`) : canonical2;
2259
2398
  }
2260
2399
  function timestampMicros(value) {
2261
- const fraction = _nullishCoalesce(_optionalChain([/\.(\d+)Z$/, 'access', _82 => _82.exec, 'call', _83 => _83(value), 'optionalAccess', _84 => _84[1]]), () => ( ""));
2400
+ const fraction = _nullishCoalesce(_optionalChain([/\.(\d+)Z$/, 'access', _87 => _87.exec, 'call', _88 => _88(value), 'optionalAccess', _89 => _89[1]]), () => ( ""));
2262
2401
  return BigInt(Date.parse(value)) * BigInt(1e3) + BigInt(fraction.padEnd(6, "0").slice(3));
2263
2402
  }
2264
2403
  function time(value, nowMs, fallback) {
@@ -2434,129 +2573,6 @@ function isStopAllPlayRunsDryRunResult(result) {
2434
2573
  return "dryRun" in result && result.dryRun === true;
2435
2574
  }
2436
2575
 
2437
- // src/integrations.ts
2438
- var CALENDAR_PROVIDER = "google_calendar_availability";
2439
- function invalid(message) {
2440
- throw new (0, _chunkLFQJW4S2js.DeeplineError)(message, 400, "INVALID_ARGUMENT");
2441
- }
2442
- async function findConnection(client, name, provider) {
2443
- const { connections } = await client.listWorkspaceConnectionInventory(
2444
- provider,
2445
- { authorizationsOnly: true }
2446
- );
2447
- const matches = connections.filter(
2448
- (row) => row.name === name && (!provider || row.provider === provider)
2449
- );
2450
- if (matches.length === 0)
2451
- throw new (0, _chunkLFQJW4S2js.DeeplineError)(
2452
- `No org connection named ${JSON.stringify(name)}. Run deepline integrations list --json.`,
2453
- 404,
2454
- "NOT_FOUND"
2455
- );
2456
- if (matches.length > 1)
2457
- invalid("This name exists for multiple providers. Pass --provider.");
2458
- return matches[0];
2459
- }
2460
- async function changeConnection(client, action, name, options) {
2461
- const row = await findConnection(client, name, options.provider);
2462
- if (options.booking && (action !== "reconnect" || row.type !== "workspace_delegation"))
2463
- invalid("Use --booking with Google Workspace verify or reconnect.");
2464
- if (options.listCalendars && (action !== "reconnect" || row.type !== "workspace_delegation"))
2465
- invalid("Use --list-calendars with Google Workspace verify or reconnect.");
2466
- if (row.type === "workspace_delegation") {
2467
- if (row.provider !== CALENDAR_PROVIDER || !row.domain)
2468
- invalid(
2469
- "The Google Workspace approval is missing its provider or domain."
2470
- );
2471
- if (row.authorizationVersion === void 0)
2472
- invalid("The API did not return a Google Workspace approval revision.");
2473
- if (action === "reconnect") {
2474
- return verifyWorkspace(client, row.domain, options, row);
2475
- }
2476
- if (options.verificationEmail)
2477
- invalid("Use --verification-email with reconnect or verify.");
2478
- if (action === "delete" && row.status !== "disconnected")
2479
- invalid("Disconnect this approval before deleting it.");
2480
- const change2 = action === "delete" ? {
2481
- action: "remove_workspace",
2482
- domain: row.domain,
2483
- connectionId: row.id,
2484
- grantRevision: row.authorizationVersion
2485
- } : {
2486
- action: "disable_workspace",
2487
- domain: row.domain,
2488
- connectionId: row.id,
2489
- grantRevision: row.authorizationVersion
2490
- };
2491
- if (options.dryRun) return change2;
2492
- return client.changeCalendarDelegation(change2);
2493
- }
2494
- if (options.verificationEmail)
2495
- invalid("--verification-email applies to Google Workspace approvals.");
2496
- if (row.type !== "oauth" || row.provider !== "hubspot" && row.provider !== CALENDAR_PROVIDER)
2497
- invalid(
2498
- "Manage this credential type through deepline integrations connect <provider> --link."
2499
- );
2500
- if (row.authorizationVersion === void 0)
2501
- invalid("The API did not return a connection authorization version.");
2502
- const change = {
2503
- action: action === "delete" ? "remove" : action,
2504
- provider: row.provider,
2505
- name,
2506
- connectionId: row.id,
2507
- authorizationVersion: row.authorizationVersion
2508
- };
2509
- if (options.dryRun) return change;
2510
- return client.manageWorkspaceIntegrationConnection(change);
2511
- }
2512
- async function verifyWorkspace(client, domain, options, existing) {
2513
- domain = domain.trim().toLowerCase();
2514
- if (!_chunk4WAM6TLDjs.GOOGLE_WORKSPACE_DOMAIN_PATTERN.test(domain))
2515
- invalid("Enter a Google Workspace domain, such as example.com.");
2516
- const email = _optionalChain([options, 'access', _85 => _85.verificationEmail, 'optionalAccess', _86 => _86.trim, 'call', _87 => _87(), 'access', _88 => _88.toLowerCase, 'call', _89 => _89()]);
2517
- if (!email || email.length > 254 || !/^[^\s@]+@[^\s@]+$/.test(email) || email.split("@")[1] !== domain)
2518
- invalid("Pass --verification-email with a work email in this domain.");
2519
- const settings = existing ? {
2520
- grantRevision: existing.authorizationVersion,
2521
- connectionId: existing.id,
2522
- grantedScopes: existing.scopes
2523
- } : await client.getCalendarDelegation(void 0, void 0, domain);
2524
- if (settings.grantRevision === void 0)
2525
- invalid("The API did not return a Google Workspace approval revision.");
2526
- const requestedScopes = [
2527
- .../* @__PURE__ */ new Set([
2528
- _chunk4WAM6TLDjs.GOOGLE_WORKSPACE_AVAILABILITY_SCOPE,
2529
- ..._nullishCoalesce(settings.grantedScopes, () => ( [])),
2530
- ...options.booking ? [_chunk4WAM6TLDjs.GOOGLE_WORKSPACE_BOOKING_SCOPE] : [],
2531
- ...options.listCalendars ? [_chunk4WAM6TLDjs.GOOGLE_WORKSPACE_CALENDAR_LIST_SCOPE] : []
2532
- ])
2533
- ];
2534
- const change = {
2535
- action: "enable_workspace",
2536
- domain,
2537
- grantRevision: settings.grantRevision,
2538
- ...settings.connectionId ? { connectionId: settings.connectionId } : {},
2539
- verificationEmail: email,
2540
- ...requestedScopes.length > 1 ? { requestedScopes } : {}
2541
- };
2542
- if (options.dryRun) return change;
2543
- return client.changeCalendarDelegation(change);
2544
- }
2545
- function createIntegrationsNamespace(client) {
2546
- return {
2547
- list: (options = {}) => client.listWorkspaceConnectionInventory(options.provider, {
2548
- authorizationsOnly: true
2549
- }),
2550
- get: (name, options = {}) => findConnection(client, name, options.provider),
2551
- connect: (provider) => client.getIntegrationConnectLink(provider),
2552
- reconnect: (name, options = {}) => changeConnection(client, "reconnect", name, options),
2553
- disconnect: (name, options = {}) => changeConnection(client, "disconnect", name, options),
2554
- delete: (name, options = {}) => changeConnection(client, "delete", name, options),
2555
- verify: (domain, options) => verifyWorkspace(client, domain, options),
2556
- members: (provider, options = {}) => client.listManagedConnectionMembers(provider, options.cursor)
2557
- };
2558
- }
2559
-
2560
2576
  // ../plays/trigger-config-route.ts
2561
2577
  function playTriggerConfigPath(playName) {
2562
2578
  return `/api/v2/plays/${encodeURIComponent(playName)}/triggers`;
@@ -3411,7 +3427,7 @@ function isolatedCiRuntimeEventReadHeaders(env) {
3411
3427
  "RUNTIME_EVENT_INTERNAL_TOKEN_REQUIRED"
3412
3428
  );
3413
3429
  }
3414
- return { [_chunkC7BQBKRZjs.COORDINATOR_INTERNAL_TOKEN_HEADER]: token };
3430
+ return { [_chunkZXB2Y3SGjs.COORDINATOR_INTERNAL_TOKEN_HEADER]: token };
3415
3431
  }
3416
3432
  function sleep(ms) {
3417
3433
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -4347,7 +4363,7 @@ var DeeplineClient = (_class = class _DeeplineClient {
4347
4363
  );
4348
4364
  const headers = _optionalChain([options, 'optionalAccess', _200 => _200.cliAdmission]) ? {
4349
4365
  ...runtimeHeaders,
4350
- "X-Deepline-API-Major": String(_chunkC7BQBKRZjs.SDK_API_MAJOR)
4366
+ "X-Deepline-API-Major": String(_chunkZXB2Y3SGjs.SDK_API_MAJOR)
4351
4367
  } : runtimeHeaders;
4352
4368
  const http = this.http;
4353
4369
  let submitted = false;
@@ -5768,6 +5784,14 @@ var DeeplineClient = (_class = class _DeeplineClient {
5768
5784
  const params = new URLSearchParams({ provider });
5769
5785
  return this.http.get(`/api/v2/integrations/balance?${params}`);
5770
5786
  }
5787
+ /** Discover and save the ad accounts accessible to the workspace connection. */
5788
+ async discoverAdAccounts(provider) {
5789
+ const { path, body } = planAdAccountDiscovery(provider);
5790
+ return this.http.post(path, body, void 0, {
5791
+ maxRetries: 0,
5792
+ exactUrlOnly: true
5793
+ });
5794
+ }
5771
5795
  /** List the internal pilot's workspace connections. */
5772
5796
  async listWorkspaceIntegrationConnections() {
5773
5797
  return this.http.get("/api/v2/integrations/connections");
@@ -7629,4 +7653,6 @@ var DeeplineClient = (_class = class _DeeplineClient {
7629
7653
 
7630
7654
 
7631
7655
 
7632
- exports.PUBLIC_PLAN_SKUS = PUBLIC_PLAN_SKUS; exports.iterateCursorPages = iterateCursorPages; exports.requireBillingIdempotencyKey = requireBillingIdempotencyKey; exports.planCustomerDbQuery = planCustomerDbQuery; exports.validateExecutionIdempotencyKey = validateExecutionIdempotencyKey; exports.normalizePlayStatus = normalizePlayStatus; exports.PlayClient = PlayClient; exports.PRODUCT_NOTIFICATION_EVENT_CATALOG = PRODUCT_NOTIFICATION_EVENT_CATALOG; exports.resolveLegacySlackNotification = resolveLegacySlackNotification; exports.RUN_EVENT_SEARCH_KIND_VALUES = RUN_EVENT_SEARCH_KIND_VALUES; exports.logProvenanceReaches = logProvenanceReaches; exports.logLevelReaches = logLevelReaches; exports.parseLogLevel = parseLogLevel; exports.classifyLogLine = classifyLogLine; exports.isTransientPlayRunReadError = isTransientPlayRunReadError; exports.encodeRunLogsCursor = encodeRunLogsCursor; exports.isRunLogsCursor = isRunLogsCursor; exports.RunEventQueryInputError = RunEventQueryInputError; exports.normalizeRunEventOperationRequest = normalizeRunEventOperationRequest; exports.isStopAllPlayRunsDryRunResult = isStopAllPlayRunsDryRunResult; exports.MONITOR_JOB_STATES = MONITOR_JOB_STATES; exports.MONITOR_JOB_PHASES = MONITOR_JOB_PHASES; exports.MONITOR_JOB_RECONCILIATION_STATES = MONITOR_JOB_RECONCILIATION_STATES; exports.DeeplineClient = DeeplineClient;
7656
+
7657
+
7658
+ exports.AD_ACCOUNT_DISCOVERY_PROVIDERS = AD_ACCOUNT_DISCOVERY_PROVIDERS; exports.planAdAccountDiscovery = planAdAccountDiscovery; exports.PUBLIC_PLAN_SKUS = PUBLIC_PLAN_SKUS; exports.iterateCursorPages = iterateCursorPages; exports.requireBillingIdempotencyKey = requireBillingIdempotencyKey; exports.planCustomerDbQuery = planCustomerDbQuery; exports.validateExecutionIdempotencyKey = validateExecutionIdempotencyKey; exports.normalizePlayStatus = normalizePlayStatus; exports.PlayClient = PlayClient; exports.PRODUCT_NOTIFICATION_EVENT_CATALOG = PRODUCT_NOTIFICATION_EVENT_CATALOG; exports.resolveLegacySlackNotification = resolveLegacySlackNotification; exports.RUN_EVENT_SEARCH_KIND_VALUES = RUN_EVENT_SEARCH_KIND_VALUES; exports.logProvenanceReaches = logProvenanceReaches; exports.logLevelReaches = logLevelReaches; exports.parseLogLevel = parseLogLevel; exports.classifyLogLine = classifyLogLine; exports.isTransientPlayRunReadError = isTransientPlayRunReadError; exports.encodeRunLogsCursor = encodeRunLogsCursor; exports.isRunLogsCursor = isRunLogsCursor; exports.RunEventQueryInputError = RunEventQueryInputError; exports.normalizeRunEventOperationRequest = normalizeRunEventOperationRequest; exports.isStopAllPlayRunsDryRunResult = isStopAllPlayRunsDryRunResult; exports.MONITOR_JOB_STATES = MONITOR_JOB_STATES; exports.MONITOR_JOB_PHASES = MONITOR_JOB_PHASES; exports.MONITOR_JOB_RECONCILIATION_STATES = MONITOR_JOB_RECONCILIATION_STATES; exports.DeeplineClient = DeeplineClient;