deepline 0.3.461 → 0.3.463

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 (297) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +7593 -0
  2. package/dist/bundling-sources/sdk/src/client.ts +8 -7366
  3. package/dist/bundling-sources/sdk/src/http-core.ts +1239 -0
  4. package/dist/bundling-sources/sdk/src/http.ts +6 -1231
  5. package/dist/bundling-sources/sdk/src/index.ts +4 -1
  6. package/dist/bundling-sources/sdk/src/play.ts +5 -5
  7. package/dist/bundling-sources/sdk/src/plays/client-core.ts +437 -0
  8. package/dist/bundling-sources/sdk/src/plays/client.ts +4 -421
  9. package/dist/bundling-sources/sdk/src/plays/input-example.ts +3 -4
  10. package/dist/bundling-sources/sdk/src/plays/play-description.ts +1 -1
  11. package/dist/bundling-sources/sdk/src/plays/run-request.ts +1 -1
  12. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  13. package/dist/bundling-sources/sdk/src/server.ts +43 -0
  14. package/dist/bundling-sources/sdk/src/types.ts +15 -5
  15. package/dist/bundling-sources/shared_libs/integration-contracts/billing-entitlements.ts +15 -0
  16. package/dist/bundling-sources/shared_libs/monitors/billing/tamradar.ts +17 -17
  17. package/dist/bundling-sources/shared_libs/monitors/callback-security.ts +0 -307
  18. package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +3 -0
  19. package/dist/bundling-sources/shared_libs/monitors/lifecycle-notifications.ts +3 -2
  20. package/dist/bundling-sources/shared_libs/monitors/package.json +2 -0
  21. package/dist/bundling-sources/shared_libs/monitors/provider-callback-verification.ts +34 -0
  22. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +61 -0
  23. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-upstream-identity.ts +122 -2
  24. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +11 -1
  25. package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-failure-codes.ts +24 -0
  26. package/dist/bundling-sources/shared_libs/observability/dlq.ts +32 -0
  27. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +57 -3
  28. package/dist/bundling-sources/shared_libs/observability/scheduled-work.ts +1 -0
  29. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +66 -1
  30. package/dist/bundling-sources/shared_libs/play-data-plane/sheet-column-storage.ts +36 -7
  31. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +250 -11
  32. package/dist/bundling-sources/shared_libs/play-runtime/array-input-store.ts +319 -0
  33. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +991 -359
  34. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +17 -0
  35. package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-janitor.ts +13 -0
  36. package/dist/bundling-sources/shared_libs/play-runtime/daytona-sandbox-reaper.ts +110 -0
  37. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +155 -6
  38. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-registry.ts +110 -6
  39. package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +127 -13
  40. package/dist/bundling-sources/shared_libs/play-runtime/execution-capabilities.ts +14 -1
  41. package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +57 -1
  42. package/dist/bundling-sources/shared_libs/play-runtime/free-company-lookup-batching.ts +218 -0
  43. package/dist/bundling-sources/shared_libs/play-runtime/gateway-postgres-admission.ts +42 -5
  44. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-budget-state-backend.ts +6 -1
  45. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +92 -31
  46. package/dist/bundling-sources/shared_libs/play-runtime/governor/block-reserving-budget-state-backend.ts +69 -14
  47. package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +93 -23
  48. package/dist/bundling-sources/shared_libs/play-runtime/governor/in-memory-rate-state-backend.ts +15 -4
  49. package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +22 -18
  50. package/dist/bundling-sources/shared_libs/play-runtime/governor/rate-state-backend.ts +5 -0
  51. package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +2 -0
  52. package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +190 -14
  53. package/dist/bundling-sources/shared_libs/play-runtime/memory-ledger.ts +131 -0
  54. package/dist/bundling-sources/shared_libs/play-runtime/modal-runtime-config.ts +77 -2
  55. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +271 -2
  56. package/dist/bundling-sources/shared_libs/play-runtime/play-run-recovery-policy.ts +51 -0
  57. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/contracts.ts +2 -0
  58. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/job.ts +27 -1
  59. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-batching-registry.ts +2 -0
  60. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +3 -0
  61. package/dist/bundling-sources/shared_libs/play-runtime/provider-text-for-log.ts +63 -0
  62. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +19 -0
  63. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-event-transport.ts +112 -16
  64. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +104 -2
  65. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +265 -151
  66. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-gateway-transport.ts +17 -0
  67. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-progress-push.ts +35 -14
  68. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-sheet-persistence-retry.ts +12 -1
  69. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-control-transport.ts +4 -0
  70. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-labels.ts +36 -0
  71. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +136 -70
  72. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +237 -36
  73. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-runtime-watchdog.ts +148 -4
  74. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-session-execution.ts +6 -0
  75. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +285 -32
  76. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +251 -56
  77. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runtime-sandbox-reconciliation.ts +29 -4
  78. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/sandbox-create-outcome.ts +27 -0
  79. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +22 -1
  80. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +1397 -382
  81. package/dist/bundling-sources/shared_libs/play-runtime/runtime-array-input-receipts.ts +920 -0
  82. package/dist/bundling-sources/shared_libs/play-runtime/runtime-constants.ts +16 -0
  83. package/dist/bundling-sources/shared_libs/play-runtime/runtime-environment.ts +38 -0
  84. package/dist/bundling-sources/shared_libs/play-runtime/runtime-flow.ts +6 -0
  85. package/dist/bundling-sources/shared_libs/play-runtime/runtime-incident-drills.ts +26 -1
  86. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +30 -0
  87. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-store-adapter.ts +14 -3
  88. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-writer.ts +31 -4
  89. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-row-transition.ts +47 -0
  90. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-compute-usage.ts +20 -7
  91. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/contract.ts +12 -0
  92. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/index.ts +9 -0
  93. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +10 -0
  94. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +4 -0
  95. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +1496 -320
  96. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-worker-required-env.ts +31 -1
  97. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +1389 -129
  98. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +36 -0
  99. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-dispatch-authority.ts +4 -0
  100. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +162 -23
  101. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +499 -115
  102. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +377 -9
  103. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +117 -8
  104. package/dist/bundling-sources/shared_libs/play-runtime/secret-resolution-retry-policy.ts +25 -0
  105. package/dist/bundling-sources/shared_libs/play-runtime/terminal-runtime-performance.ts +391 -0
  106. package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +40 -0
  107. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/index.ts +6 -0
  108. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/mapped-calls.ts +171 -0
  109. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/receipt-cohort.ts +16 -1
  110. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +38 -12
  111. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +33 -9
  112. package/dist/bundling-sources/shared_libs/play-runtime/transport-error-diagnostics.ts +28 -0
  113. package/dist/bundling-sources/shared_libs/play-runtime/work-receipt-storage-contract.ts +55 -5
  114. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +41 -1
  115. package/dist/bundling-sources/shared_libs/plays/contracts.ts +4 -0
  116. package/dist/bundling-sources/shared_libs/plays/dataset.ts +9 -3
  117. package/dist/bundling-sources/shared_libs/plays/deploy/manifest-contract.ts +2 -0
  118. package/dist/bundling-sources/shared_libs/plays/deploy/manifest.ts +3 -2
  119. package/dist/bundling-sources/shared_libs/plays/deploy/project-serializer.ts +2 -2
  120. package/dist/bundling-sources/shared_libs/plays/run-output-summary.ts +66 -0
  121. package/dist/bundling-sources/shared_libs/plays/script-entry.ts +1 -1
  122. package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +43 -1
  123. package/dist/bundling-sources/shared_libs/product-notifications/content.ts +9 -0
  124. package/dist/bundling-sources/shared_libs/product-notifications/email.ts +91 -13
  125. package/dist/bundling-sources/shared_libs/product-notifications/events.ts +3 -0
  126. package/dist/bundling-sources/shared_libs/product-notifications/slack-delivery.ts +41 -24
  127. package/dist/bundling-sources/shared_libs/security/attested-client-ip.ts +91 -0
  128. package/dist/bundling-sources/shared_libs/security/internal-actor.ts +0 -11
  129. package/dist/cli/{auth-6HJXNWUG.mjs → auth-LZLBR4C3.mjs} +5 -4
  130. package/dist/cli/auth-XPGKBJKB.js +41 -0
  131. package/dist/cli/{billing-6P5HO6QG.js → billing-6TJPNJQD.js} +152 -78
  132. package/dist/cli/{billing-MJ42N7YF.mjs → billing-OTOP5RE4.mjs} +84 -10
  133. package/dist/cli/{chunk-FCAZQ7WV.js → chunk-2NISBXMN.js} +52 -50
  134. package/dist/cli/{chunk-PNATXKLP.js → chunk-2ZIRCBYG.js} +6 -6
  135. package/dist/cli/{chunk-5FDKJQZE.js → chunk-3BOIOCNX.js} +1 -1
  136. package/dist/cli/chunk-3BVLLJ3H.mjs +1038 -0
  137. package/dist/cli/{chunk-FJZILBL7.mjs → chunk-3U5EAP6E.mjs} +5 -5
  138. package/dist/cli/{describe-FRAVCY5F.mjs → chunk-4YZKBBLZ.mjs} +19 -36
  139. package/dist/cli/{chunk-QWRHGGUH.js → chunk-5DRNNC72.js} +20 -2
  140. package/dist/cli/{chunk-Z2GUFYT6.js → chunk-5LEAXRHV.js} +11 -11
  141. package/dist/cli/{chunk-5MDIZX7M.js → chunk-5LHXOIPT.js} +8 -6
  142. package/dist/cli/{chunk-NMJ4D2WO.js → chunk-6PMCRYDA.js} +216 -91
  143. package/dist/cli/{chunk-EBU7LQ64.js → chunk-6V7KVRR5.js} +3 -3
  144. package/dist/cli/{chunk-MGXEUZHL.mjs → chunk-7D6X7IXW.mjs} +7 -5
  145. package/dist/cli/{chunk-SAZFZQRI.js → chunk-7FCYPAPP.js} +2 -2
  146. package/dist/cli/{chunk-ACCR7POB.js → chunk-7XYDDCQ2.js} +27 -27
  147. package/dist/cli/{chunk-5IYOUBFZ.js → chunk-ALZBANZI.js} +28 -54
  148. package/dist/cli/{chunk-3DNKFH2G.mjs → chunk-BAPTQDLF.mjs} +19 -1
  149. package/dist/cli/chunk-BGNWI3KH.js +827 -0
  150. package/dist/cli/{chunk-V7REJRDZ.mjs → chunk-C25QE4CH.mjs} +1 -1
  151. package/dist/cli/{chunk-FGMX4HUZ.js → chunk-CBZP6J3V.js} +29 -27
  152. package/dist/cli/{chunk-QEYHTIV4.mjs → chunk-CTQ56DXP.mjs} +10 -1
  153. package/dist/cli/{chunk-IHHLTHE7.mjs → chunk-CVQ7N5CV.mjs} +267 -38
  154. package/dist/cli/{chunk-7DH2FD7Y.mjs → chunk-D464JW3N.mjs} +5 -85
  155. package/dist/cli/{chunk-MEAIOXJL.mjs → chunk-DHXCBITQ.mjs} +7 -5
  156. package/dist/cli/chunk-F2RHUPVH.mjs +827 -0
  157. package/dist/cli/chunk-F6QV42MC.mjs +91 -0
  158. package/dist/cli/{chunk-OZBWRICM.js → chunk-FK2HNDCN.js} +2 -2
  159. package/dist/cli/{chunk-BGY2PLP7.mjs → chunk-GUT7CLOL.mjs} +23 -49
  160. package/dist/cli/{chunk-RY4IVOU3.mjs → chunk-I624J4H5.mjs} +16 -806
  161. package/dist/cli/{chunk-Z2XUZC34.js → chunk-IAYSWZDJ.js} +188 -76
  162. package/dist/cli/{chunk-FGLKOWSC.mjs → chunk-IKWRUNAP.mjs} +1 -1
  163. package/dist/cli/{chunk-KCCOQ5G5.js → chunk-JVDKZJUH.js} +511 -282
  164. package/dist/cli/{chunk-HDFRJ4IT.mjs → chunk-JVHOS3K3.mjs} +177 -65
  165. package/dist/cli/chunk-LYFKBLJI.mjs +1039 -0
  166. package/dist/cli/{chunk-SLEUWLJE.mjs → chunk-MSY22NQW.mjs} +5 -5
  167. package/dist/cli/{chunk-5FY72YOV.js → chunk-NAPTMYTY.js} +8 -8
  168. package/dist/cli/{chunk-O6QOMHCH.js → chunk-NDHJR2WZ.js} +37 -35
  169. package/dist/cli/{chunk-KXMNM4AQ.js → chunk-NMU3VR5U.js} +4 -5
  170. package/dist/cli/chunk-NTLI6P6Y.mjs +19 -0
  171. package/dist/cli/{chunk-RFONC4WJ.mjs → chunk-O3BJYD6D.mjs} +3 -3
  172. package/dist/cli/{describe-2WQY7ZCY.js → chunk-PVY4DPPF.js} +27 -44
  173. package/dist/cli/{chunk-WIYWSYDS.mjs → chunk-Q2EIZKVX.mjs} +3 -3
  174. package/dist/cli/{chunk-VZBCEA5S.mjs → chunk-RD6IQ2JY.mjs} +223 -92
  175. package/dist/cli/chunk-RGOUCIIZ.js +1039 -0
  176. package/dist/cli/{chunk-EIMG75BT.mjs → chunk-S3A4IXBQ.mjs} +4 -5
  177. package/dist/cli/{chunk-QIW7TVV6.mjs → chunk-S4XQCFES.mjs} +14 -12
  178. package/dist/cli/chunk-SKU6ECIY.js +19 -0
  179. package/dist/cli/{chunk-CRYOUPEB.js → chunk-TIRBDQ3W.js} +16 -16
  180. package/dist/cli/{chunk-G7L27KZB.mjs → chunk-TKAQR3IB.mjs} +31 -21
  181. package/dist/cli/{chunk-MDJPEGVN.js → chunk-UC4SFYNU.js} +392 -261
  182. package/dist/cli/{chunk-3BMLICF7.mjs → chunk-UIURR26V.mjs} +13 -8
  183. package/dist/cli/{chunk-TNMBPMMC.js → chunk-UROQDCVW.js} +13 -4
  184. package/dist/cli/{chunk-R64BGGRQ.mjs → chunk-VDGTTH7K.mjs} +2 -2
  185. package/dist/cli/chunk-VLEVVDWG.js +91 -0
  186. package/dist/cli/{chunk-R2GLGLDR.mjs → chunk-VPHN2HAL.mjs} +216 -91
  187. package/dist/cli/chunk-VY2GBNTX.js +1038 -0
  188. package/dist/cli/{chunk-CFUTOWE4.js → chunk-WG3KGAII.js} +8 -88
  189. package/dist/cli/{chunk-QAJAJPKK.mjs → chunk-WUMIYOXQ.mjs} +4 -2
  190. package/dist/cli/{chunk-SCIR5JXW.js → chunk-WUZS2HK6.js} +56 -51
  191. package/dist/cli/{chunk-T3MVIPHG.mjs → chunk-XDWS2JJT.mjs} +1 -1
  192. package/dist/cli/{chunk-KGQNIA37.js → chunk-XQCTG5OO.js} +44 -34
  193. package/dist/cli/{chunk-KVJ5VHW5.mjs → chunk-XW2JIYG7.mjs} +2 -2
  194. package/dist/cli/chunk-YGGIZ3VT.js +920 -0
  195. package/dist/cli/command-docs.d.mts +5 -0
  196. package/dist/cli/command-docs.d.ts +5 -0
  197. package/dist/cli/command-docs.js +2 -2
  198. package/dist/cli/command-docs.mjs +1 -1
  199. package/dist/cli/{csv-NX7NO3O6.js → csv-EH5QWR4O.js} +13 -12
  200. package/dist/cli/{csv-DQ6GW5B5.mjs → csv-OK45Z5XQ.mjs} +4 -3
  201. package/dist/cli/{db-R72DFMP6.js → db-3ESJKETS.js} +30 -27
  202. package/dist/cli/{db-2YP33M4K.mjs → db-6Z5E4HKN.mjs} +10 -7
  203. package/dist/cli/describe-PNDQB7YS.mjs +48 -0
  204. package/dist/cli/describe-QUF7VTTR.js +48 -0
  205. package/dist/cli/describe-core.d.mts +153 -5
  206. package/dist/cli/describe-core.d.ts +153 -5
  207. package/dist/cli/describe-core.js +9 -5
  208. package/dist/cli/describe-core.mjs +10 -6
  209. package/dist/cli/{executions-WFBU7L2Q.mjs → executions-2NTWQFEG.mjs} +7 -5
  210. package/dist/cli/{executions-ZLHD4QIT.js → executions-KUOBRX5V.js} +9 -7
  211. package/dist/cli/{feedback-CN3HJFVF.mjs → feedback-7RPRMSGY.mjs} +6 -5
  212. package/dist/cli/{feedback-NDV6TPHG.js → feedback-UPHAZJ4C.js} +10 -9
  213. package/dist/cli/getting-started.d.mts +6 -6
  214. package/dist/cli/getting-started.d.ts +6 -6
  215. package/dist/cli/getting-started.js +2 -2
  216. package/dist/cli/getting-started.mjs +1 -1
  217. package/dist/cli/{git-QAD6E3HW.mjs → git-SCYP6WSZ.mjs} +5 -4
  218. package/dist/cli/git-UH653WHV.js +25 -0
  219. package/dist/cli/index.js +152 -142
  220. package/dist/cli/index.mjs +56 -46
  221. package/dist/cli/{legacy-noops-KVC5QJ74.js → legacy-noops-7XMFCVRG.js} +8 -7
  222. package/dist/cli/{legacy-noops-TPTKNBI2.mjs → legacy-noops-A4KYAGI6.mjs} +5 -4
  223. package/dist/cli/{monitors-SV57JFLO.mjs → monitors-FLC5J7RI.mjs} +19 -6
  224. package/dist/cli/{monitors-KCROV6PJ.js → monitors-NZV6IX5H.js} +103 -90
  225. package/dist/cli/{org-NJYX5743.js → org-IZ7UP3XF.js} +70 -67
  226. package/dist/cli/{org-KX6QIR7A.mjs → org-LUETJ7Z5.mjs} +9 -6
  227. package/dist/cli/pages-22ML3O7O.js +252 -0
  228. package/dist/cli/pages-EUX5EAGF.mjs +252 -0
  229. package/dist/cli/{play-IQQ57L7Z.mjs → play-CDHPAKKM.mjs} +512 -1508
  230. package/dist/cli/{play-32L7EQN4.js → play-USJBQADG.js} +1090 -2086
  231. package/dist/cli/{providers-4WEC2EQN.mjs → providers-CCXZ3SQF.mjs} +7 -5
  232. package/dist/cli/{providers-ZQV6QLVQ.js → providers-WFEUNPGC.js} +10 -8
  233. package/dist/cli/{quickstart-HKUSFADF.js → quickstart-O4JSUORZ.js} +13 -12
  234. package/dist/cli/{quickstart-RQ76RIUE.mjs → quickstart-ZUULI635.mjs} +5 -4
  235. package/dist/cli/run-ISDJYJMU.js +443 -0
  236. package/dist/cli/run-QJ4NX5F5.mjs +443 -0
  237. package/dist/cli/{search-ZRAVFBZC.mjs → search-IX3XKZJ3.mjs} +8 -6
  238. package/dist/cli/search-TIFNLRPM.js +32 -0
  239. package/dist/cli/{secrets-CMJOVNVH.mjs → secrets-7VUDXTUZ.mjs} +7 -5
  240. package/dist/cli/{secrets-J3G5Y43U.js → secrets-ELQSNCTR.js} +16 -14
  241. package/dist/cli/{sessions-WY7VN4AE.js → sessions-A3FG3AZX.js} +6 -5
  242. package/dist/cli/{sessions-MDQYY5CB.mjs → sessions-VOIQ62GB.mjs} +5 -4
  243. package/dist/cli/{settings-4RWZPCT5.mjs → settings-S6N6EFBG.mjs} +14 -11
  244. package/dist/cli/{settings-HTNTFKCE.js → settings-ZTXQEMZI.js} +80 -77
  245. package/dist/cli/{setup-P3GYYZWG.mjs → setup-AYPIK4JE.mjs} +12 -10
  246. package/dist/cli/{setup-QGCAP62X.js → setup-Y3WOIFLS.js} +53 -51
  247. package/dist/cli/{skills-7NAE4ICL.mjs → skills-5SF5QWNI.mjs} +7 -6
  248. package/dist/cli/skills-MWFRMG3H.js +31 -0
  249. package/dist/cli/tools-3XNZ4J64.mjs +55 -0
  250. package/dist/cli/tools-XEC4OD3R.js +55 -0
  251. package/dist/cli/{update-GODLRKNB.mjs → update-3U4OVX5R.mjs} +9 -8
  252. package/dist/cli/update-DWYEYTZE.js +33 -0
  253. package/dist/cli/{workflow-4BXOUVEO.mjs → workflow-2M5JP7SA.mjs} +10 -8
  254. package/dist/cli/{workflow-AO3A6LXN.js → workflow-RM7H7555.js} +20 -18
  255. package/dist/client-DS2IWYZF.d.ts +10 -0
  256. package/dist/client-DTwnz_AW.d.mts +10 -0
  257. package/dist/{client-CYqG23K1.d.ts → client-core-B_6HAIBy.d.ts} +385 -12
  258. package/dist/{client-BbU5_j7n.d.mts → client-core-DzBSlY1U.d.mts} +385 -12
  259. package/dist/{compiler-manifest-CWz_sNOQ.d.ts → compiler-manifest-Dcyd3-Zd.d.mts} +43 -1
  260. package/dist/{compiler-manifest-CWz_sNOQ.d.mts → compiler-manifest-Dcyd3-Zd.d.ts} +43 -1
  261. package/dist/errors-d-sTrZhe.d.mts +142 -0
  262. package/dist/errors-yQwfgrcX.d.ts +142 -0
  263. package/dist/{index-BF2JB_Ug.d.mts → index-C6oXchjN.d.mts} +1 -1
  264. package/dist/{index-4NPXDzlD.d.ts → index-P56zy_z5.d.ts} +1 -1
  265. package/dist/index.d.mts +11 -147
  266. package/dist/index.d.ts +11 -147
  267. package/dist/index.js +16 -12
  268. package/dist/index.mjs +15 -11
  269. package/dist/install-integrity.json +141 -104
  270. package/dist/plays/bundle-play-file.d.mts +3 -3
  271. package/dist/plays/bundle-play-file.d.ts +3 -3
  272. package/dist/plays/bundle-play-file.mjs +2 -1
  273. package/dist/plays/play-description.d.mts +2 -2
  274. package/dist/plays/play-description.d.ts +2 -2
  275. package/dist/plays/play-description.js +2 -2
  276. package/dist/plays/play-description.mjs +1 -1
  277. package/dist/plays/run-request.d.mts +2 -2
  278. package/dist/plays/run-request.d.ts +2 -2
  279. package/dist/release.d.mts +1 -1
  280. package/dist/release.d.ts +1 -1
  281. package/dist/release.js +2 -2
  282. package/dist/release.mjs +1 -1
  283. package/dist/server.d.mts +17 -0
  284. package/dist/server.d.ts +17 -0
  285. package/dist/server.js +76 -0
  286. package/dist/server.mjs +76 -0
  287. package/package.json +6 -1
  288. package/dist/cli/auth-IACERYQH.js +0 -40
  289. package/dist/cli/chunk-PQUUWFXY.js +0 -95
  290. package/dist/cli/chunk-YBWAG72P.mjs +0 -95
  291. package/dist/cli/chunk-YQDUODZW.js +0 -1710
  292. package/dist/cli/git-JVI36ZFV.js +0 -24
  293. package/dist/cli/search-75X5LTDE.js +0 -30
  294. package/dist/cli/skills-BKJ53JOQ.js +0 -30
  295. package/dist/cli/tools-COWMIEJ6.mjs +0 -45
  296. package/dist/cli/tools-TASOCE7I.js +0 -45
  297. package/dist/cli/update-SJIKVME6.js +0 -32
@@ -0,0 +1,1039 @@
1
+ import {
2
+ SCHEMA_LINE_LIMIT,
3
+ fieldBlockLines,
4
+ schemaFields
5
+ } from "./chunk-JVHOS3K3.mjs";
6
+ import {
7
+ csvSafeJsonString,
8
+ csvStringFromRows
9
+ } from "./chunk-WUMIYOXQ.mjs";
10
+
11
+ // src/cli/describe-options.ts
12
+ function addDescribeOptions(command, options = {}) {
13
+ command.option(
14
+ "--prebuilt",
15
+ "Show the Deepline tool or play, not a play your workspace created under the same name"
16
+ ).option("--tool", "Same as --prebuilt").option(
17
+ "--verbose",
18
+ "Show secondary fields, and fill in every input and read every output in the examples"
19
+ ).option(
20
+ "--cli-example",
21
+ "Show only the CLI example, and explain how it takes inputs and returns outputs"
22
+ ).option(
23
+ "--play-example",
24
+ "Show only the in-play example, and explain how it takes inputs and returns outputs"
25
+ ).option("--no-example", "Hide the run examples").option(
26
+ "--full-schema",
27
+ `Print every field: a long schema unfolded (over ${SCHEMA_LINE_LIMIT} lines), list rows, and a tool's raw response`
28
+ ).option(
29
+ "--fields <names>",
30
+ "Show only these fields, comma-separated, plus every required input"
31
+ ).option(
32
+ "--feature <name[=value]>",
33
+ "Describe one feature of a tool, such as a model: --feature model=openai/gpt-5.6-luna. A tool lists its features."
34
+ ).option(
35
+ "-o, --out <path>",
36
+ "Save the output to this file instead of printing it"
37
+ );
38
+ if (options.schemaOnly !== false) {
39
+ command.option(
40
+ "--schema-only",
41
+ "Print only the schema, with every field, and nothing else"
42
+ );
43
+ }
44
+ if (options.json !== false) {
45
+ command.option(
46
+ "--json",
47
+ "Print JSON instead of text; with --schema-only, only the input and output JSON Schemas"
48
+ );
49
+ }
50
+ return command;
51
+ }
52
+
53
+ // src/cli/execution-observation.ts
54
+ import { writeFileSync, renameSync } from "fs";
55
+ function writeObservation(observation) {
56
+ const path = process.env.DEEPLINE_EXECUTION_OBSERVATION_PATH;
57
+ const invocationId = process.env.DEEPLINE_EXECUTION_OBSERVATION_ID;
58
+ if (!path || !invocationId) return;
59
+ const pending = `${path}.pending`;
60
+ try {
61
+ writeFileSync(
62
+ pending,
63
+ JSON.stringify({
64
+ schema_version: 1,
65
+ invocation_id: invocationId,
66
+ ...observation
67
+ }),
68
+ { mode: 384 }
69
+ );
70
+ renameSync(pending, path);
71
+ } catch {
72
+ console.error(
73
+ "[execution-observation] could not write the configured diagnostic sink",
74
+ { kind: observation.kind }
75
+ );
76
+ }
77
+ }
78
+ function recordApiResponse(observation) {
79
+ writeObservation({
80
+ kind: "api_response",
81
+ received_at_ms: observation.receivedAtMs,
82
+ state: observation.state,
83
+ http_status: observation.httpStatus
84
+ });
85
+ }
86
+ function recordPlayTermination(run) {
87
+ if (typeof run.id !== "string" || !["completed", "failed", "cancelled", "canceled"].includes(
88
+ String(run.status)
89
+ ) || typeof run.finishedAt !== "number" || !Number.isSafeInteger(run.finishedAt) || run.finishedAt <= 0)
90
+ return;
91
+ writeObservation({
92
+ kind: "play_terminal",
93
+ run: { id: run.id, status: run.status, finishedAt: run.finishedAt }
94
+ });
95
+ }
96
+
97
+ // ../plays/table-csv.ts
98
+ var TABLE_EXPORT_ERROR_COLUMN = "_error";
99
+ var UNRECORDED_FAILURE_REASON = "Row failed without a recorded reason.";
100
+ function tableCellText(value) {
101
+ if (value === null || value === void 0) return "";
102
+ if (typeof value === "string") return value;
103
+ if (typeof value === "number" || typeof value === "bigint" || typeof value === "boolean")
104
+ return String(value);
105
+ if (value instanceof Date) return value.toISOString();
106
+ if (typeof value === "symbol" || typeof value === "function") return "";
107
+ try {
108
+ return JSON.stringify(
109
+ value,
110
+ (_key, nested) => typeof nested === "bigint" ? nested.toString() : nested
111
+ ) ?? "";
112
+ } catch {
113
+ return String(value);
114
+ }
115
+ }
116
+ function csvField(value) {
117
+ const text = tableCellText(value);
118
+ return /[",\r\n]/.test(text) ? `"${text.replaceAll('"', '""')}"` : text;
119
+ }
120
+ function csvRecord(values) {
121
+ return `${values.map(csvField).join(",")}
122
+ `;
123
+ }
124
+ function isFailedRow(row) {
125
+ return row.status === "failed";
126
+ }
127
+ function tableExportHasFailedRows(rows) {
128
+ for (const row of rows) if (isFailedRow(row)) return true;
129
+ return false;
130
+ }
131
+ function tableExportErrorCell(row) {
132
+ if (!isFailedRow(row)) return "";
133
+ const reason = typeof row.error === "string" ? row.error.trim() : "";
134
+ return reason || UNRECORDED_FAILURE_REASON;
135
+ }
136
+ function tableExportColumns(columns, withError) {
137
+ if (!withError) return [...columns];
138
+ return [
139
+ ...columns.filter((column) => column !== TABLE_EXPORT_ERROR_COLUMN),
140
+ TABLE_EXPORT_ERROR_COLUMN
141
+ ];
142
+ }
143
+ function tableExportCells(row, columns, withError) {
144
+ return tableExportColumns(columns, withError).map(
145
+ (column) => column === TABLE_EXPORT_ERROR_COLUMN && withError ? tableExportErrorCell(row) : Object.hasOwn(row.data, column) ? row.data[column] : void 0
146
+ );
147
+ }
148
+ function tableCsvText(header, records) {
149
+ let text = csvRecord(header);
150
+ for (const record2 of records) text += csvRecord(record2);
151
+ return text;
152
+ }
153
+
154
+ // src/cli/run-dataset-order.ts
155
+ function underscoreKeysLast(keys) {
156
+ return [...keys].sort(
157
+ (left, right) => Number(left.startsWith("_")) - Number(right.startsWith("_"))
158
+ );
159
+ }
160
+ function orderRunExportJson(value) {
161
+ const copies = /* @__PURE__ */ new WeakMap();
162
+ function visit(item) {
163
+ if (item === null || typeof item !== "object") return item;
164
+ if (copies.has(item)) return copies.get(item);
165
+ if (Array.isArray(item)) {
166
+ const copy2 = [];
167
+ copies.set(item, copy2);
168
+ for (const element of item) copy2.push(visit(element));
169
+ return copy2;
170
+ }
171
+ const prototype = Object.getPrototypeOf(item);
172
+ if (prototype !== Object.prototype && prototype !== null) return item;
173
+ const record2 = item;
174
+ const copy = /* @__PURE__ */ Object.create(null);
175
+ copies.set(item, copy);
176
+ for (const key of underscoreKeysLast(Object.keys(record2))) {
177
+ copy[key] = visit(record2[key]);
178
+ }
179
+ return copy;
180
+ }
181
+ return visit(value);
182
+ }
183
+
184
+ // src/cli/execution-output.ts
185
+ import {
186
+ accessSync,
187
+ appendFileSync,
188
+ constants,
189
+ existsSync,
190
+ linkSync,
191
+ mkdtempSync,
192
+ realpathSync,
193
+ unlinkSync,
194
+ writeFileSync as writeFileSync3
195
+ } from "fs";
196
+ import { tmpdir } from "os";
197
+ import { dirname, join, resolve as resolve2 } from "path";
198
+ import { randomUUID } from "crypto";
199
+
200
+ // src/cli/run-dataset-csv.ts
201
+ import { writeFileSync as writeFileSync2 } from "fs";
202
+ import { resolve } from "path";
203
+ var RunDatasetCsv = class _RunDatasetCsv {
204
+ #projection;
205
+ constructor(input) {
206
+ const rows = input.rows.map(projectRunDatasetRow);
207
+ this.#projection = {
208
+ rows,
209
+ columns: runDatasetCsvColumns(rows, input.columns)
210
+ };
211
+ }
212
+ static from(input) {
213
+ return new _RunDatasetCsv(input);
214
+ }
215
+ projection() {
216
+ return this.#projection;
217
+ }
218
+ write(outPath) {
219
+ const absolutePath = resolve(outPath);
220
+ const { rows, columns } = this.#projection;
221
+ writeFileSync2(
222
+ absolutePath,
223
+ tableCsvText(
224
+ columns,
225
+ rows.map((data) => tableExportCells({ data }, columns, false))
226
+ ),
227
+ "utf-8"
228
+ );
229
+ return absolutePath;
230
+ }
231
+ };
232
+ function projectRunDatasetCsv(input) {
233
+ return RunDatasetCsv.from(input).projection();
234
+ }
235
+ function writeRunDatasetCsv(input) {
236
+ return RunDatasetCsv.from(input).write(input.outPath);
237
+ }
238
+ function projectRunDatasetRow(row) {
239
+ return Object.fromEntries(
240
+ Object.entries(row).map(([column, value]) => [
241
+ column,
242
+ projectRunDatasetCell(value)
243
+ ])
244
+ );
245
+ }
246
+ function projectRunDatasetCell(value) {
247
+ const logicalValue = parseSerializedDatasetValue(value);
248
+ if (logicalValue === null || logicalValue === void 0) return logicalValue;
249
+ if (typeof logicalValue === "object") {
250
+ return csvSafeJsonString(canonicalDatasetJson(logicalValue));
251
+ }
252
+ return logicalValue;
253
+ }
254
+ function canonicalDatasetJson(value) {
255
+ return canonicalDatasetJsonValue(value, /* @__PURE__ */ new WeakSet());
256
+ }
257
+ function canonicalDatasetJsonValue(value, ancestors) {
258
+ if (Array.isArray(value)) {
259
+ if (ancestors.has(value)) return value;
260
+ ancestors.add(value);
261
+ const normalized2 = value.map(
262
+ (item) => canonicalDatasetJsonValue(item, ancestors)
263
+ );
264
+ ancestors.delete(value);
265
+ return normalized2;
266
+ }
267
+ if (!value || typeof value !== "object" || value instanceof Date) {
268
+ return value;
269
+ }
270
+ if (ancestors.has(value)) return value;
271
+ ancestors.add(value);
272
+ const record2 = value;
273
+ const normalized = Object.fromEntries(
274
+ underscoreKeysLast(
275
+ Object.keys(record2).sort((left, right) => left.localeCompare(right))
276
+ ).map((key) => [key, canonicalDatasetJsonValue(record2[key], ancestors)])
277
+ );
278
+ ancestors.delete(value);
279
+ return normalized;
280
+ }
281
+ function parseSerializedDatasetValue(value) {
282
+ if (typeof value !== "string") return value;
283
+ const text = value.trim();
284
+ if (!text || !["{", "["].includes(text[0] ?? "")) return value;
285
+ try {
286
+ return JSON.parse(text);
287
+ } catch {
288
+ return value;
289
+ }
290
+ }
291
+ function runDatasetCsvColumns(rows, declaredColumns) {
292
+ const columns = [];
293
+ const seen = /* @__PURE__ */ new Set();
294
+ const add = (column) => {
295
+ if (!column || seen.has(column)) return;
296
+ seen.add(column);
297
+ columns.push(column);
298
+ };
299
+ for (const column of declaredColumns) add(column);
300
+ for (const row of rows) {
301
+ for (const column of Object.keys(row)) add(column);
302
+ }
303
+ return underscoreKeysLast(columns);
304
+ }
305
+
306
+ // src/cli/value-outline.ts
307
+ var OUTLINE_LINES = 32;
308
+ var ITEMS_SHOWN = 3;
309
+ var VALUE_CHARACTERS = 60;
310
+ function isRecord(value) {
311
+ return typeof value === "object" && value !== null && !Array.isArray(value);
312
+ }
313
+ function isContainer(value) {
314
+ return Array.isArray(value) && value.length > 0 || isRecord(value) && Object.keys(value).length > 0;
315
+ }
316
+ function node(label, value) {
317
+ const children = !isContainer(value) ? null : Array.isArray(value) ? value.some(isContainer) ? value.map((item) => node(null, item)) : null : Object.entries(value).filter(([, child]) => child !== void 0).map(([key, child]) => node(key, child));
318
+ return { label, value, children, shown: 0 };
319
+ }
320
+ function wanted(parent, left) {
321
+ const count = parent.children?.length ?? 0;
322
+ if (!Array.isArray(parent.value)) return count;
323
+ const first = parent.value[0];
324
+ const perItem = isRecord(first) ? Math.max(1, Object.keys(first).length) : 1;
325
+ return Math.min(count, Math.max(ITEMS_SHOWN, Math.floor(left / perItem)));
326
+ }
327
+ function shareLines(wants, total) {
328
+ const grants = wants.map(() => 0);
329
+ let left = total;
330
+ let open = wants.flatMap((want, index) => want > 0 ? [index] : []);
331
+ while (left > 0 && open.length) {
332
+ const each = Math.floor(left / open.length);
333
+ if (each === 0) {
334
+ for (const index of open.slice(0, left)) grants[index] += 1;
335
+ break;
336
+ }
337
+ for (const index of open) {
338
+ const grant = Math.min(each, wants[index] - grants[index]);
339
+ grants[index] += grant;
340
+ left -= grant;
341
+ }
342
+ open = open.filter((index) => grants[index] < wants[index]);
343
+ }
344
+ return grants;
345
+ }
346
+ function cut(text) {
347
+ return text.length > VALUE_CHARACTERS ? `${text.slice(0, VALUE_CHARACTERS)}\u2026` : text;
348
+ }
349
+ function valueText(value) {
350
+ if (Array.isArray(value)) {
351
+ if (!value.length) return "[]";
352
+ const items = value.map((item) => cut(JSON.stringify(item) ?? "null"));
353
+ const text = `[${items.join(", ")}]`;
354
+ return text.length <= VALUE_CHARACTERS ? text : `[${items[0]}, \u2026 ${value.length} items]`;
355
+ }
356
+ if (isRecord(value)) return "{}";
357
+ return typeof value === "string" ? JSON.stringify(cut(value)) : String(JSON.stringify(value) ?? "null");
358
+ }
359
+ function foldedText(value) {
360
+ if (Array.isArray(value)) return `[${value.length} items]`;
361
+ return `{ ${cut(Object.keys(value).join(", "))} }`;
362
+ }
363
+ function countNote(item) {
364
+ const total = item.children?.length ?? 0;
365
+ if (Array.isArray(item.value)) {
366
+ return item.shown < total ? `(${item.shown} of ${total} items)` : `(${total} ${total === 1 ? "item" : "items"})`;
367
+ }
368
+ return item.shown < total ? `(${item.shown} of ${total} fields)` : "";
369
+ }
370
+ function renderChildren(parent, indent) {
371
+ return (parent.children ?? []).slice(0, parent.shown).flatMap((child) => renderNode(child, indent));
372
+ }
373
+ function renderNode(item, indent) {
374
+ const prefix = item.label === null ? "- " : `${item.label}: `;
375
+ if (!item.children) return [`${indent}${prefix}${valueText(item.value)}`];
376
+ if (!item.shown) return [`${indent}${prefix}${foldedText(item.value)}`];
377
+ const note = countNote(item);
378
+ const children = renderChildren(item, `${indent} `);
379
+ if (mergesWithFirstField(item)) {
380
+ const [first, ...rest] = children;
381
+ const head = `${indent}- ${first.slice(indent.length + 2)}`;
382
+ return [note ? `${head} ${note}` : head, ...rest];
383
+ }
384
+ return [`${indent}${prefix.trimEnd()}${note ? ` ${note}` : ""}`, ...children];
385
+ }
386
+ function mergesWithFirstField(item) {
387
+ return item.label === null && isRecord(item.value) && item.shown > 0;
388
+ }
389
+ function anythingHidden(item) {
390
+ if (!item.children) return false;
391
+ if (item.shown < item.children.length) return true;
392
+ return item.children.some(anythingHidden);
393
+ }
394
+ function outlineLines(value, budget = OUTLINE_LINES) {
395
+ const root = node("", value);
396
+ if (!root.children)
397
+ return { lines: [valueText(value)], note: "", cut: false };
398
+ let left = budget;
399
+ let level = [root];
400
+ while (level.length) {
401
+ const wants = level.map((parent) => wanted(parent, left));
402
+ const items = level.map(
403
+ (parent, index) => parent.label === null && isRecord(parent.value) && wants[index] > 0
404
+ );
405
+ let returned = items.filter(Boolean).length;
406
+ if (left + returned <= 0) break;
407
+ let grants = shareLines(wants, left + returned);
408
+ for (; ; ) {
409
+ const merged = grants.filter((grant, index) => items[index] && grant > 0);
410
+ if (merged.length === returned) break;
411
+ returned = merged.length;
412
+ grants = shareLines(wants, left + returned);
413
+ }
414
+ left += returned;
415
+ const next = [];
416
+ level.forEach((parent, index) => {
417
+ parent.shown = grants[index];
418
+ left -= parent.shown;
419
+ next.push(
420
+ ...parent.children.slice(0, parent.shown).filter((child) => child.children)
421
+ );
422
+ });
423
+ level = next;
424
+ }
425
+ return {
426
+ lines: renderChildren(root, ""),
427
+ note: countNote(root),
428
+ cut: anythingHidden(root)
429
+ };
430
+ }
431
+ function merge(a, b) {
432
+ if (Array.isArray(a) && Array.isArray(b)) {
433
+ return a.map((item, index) => merge(item, b[index]));
434
+ }
435
+ if (isRecord(a) && isRecord(b)) {
436
+ const merged = { ...a };
437
+ for (const [key, value] of Object.entries(b)) {
438
+ merged[key] = key in merged ? merge(merged[key], value) : value;
439
+ }
440
+ return merged;
441
+ }
442
+ return b === void 0 ? a : b;
443
+ }
444
+ function pick(value, path) {
445
+ if (!path.length) return value;
446
+ if (Array.isArray(value)) return value.map((item) => pick(item, path));
447
+ if (!isRecord(value) || !(path[0] in value)) return void 0;
448
+ const child = pick(value[path[0]], path.slice(1));
449
+ return child === void 0 ? void 0 : { [path[0]]: child };
450
+ }
451
+ function pickFields(value, paths) {
452
+ const missing = [];
453
+ let picked;
454
+ for (const path of paths) {
455
+ const one = pick(value, path.split("."));
456
+ const found = Array.isArray(one) ? one.some((item) => item !== void 0) : one !== void 0;
457
+ if (found) picked = picked === void 0 ? one : merge(picked, one);
458
+ else missing.push(path);
459
+ }
460
+ return { value: picked, missing };
461
+ }
462
+
463
+ // src/cli/execution-output.ts
464
+ var ExecutionOutputError = class extends Error {
465
+ };
466
+ var JSON_SCHEMA_DIALECT = "https://json-schema.org/draft/2020-12/schema";
467
+ function dataOnStdout(options) {
468
+ return options.jsonOut === "-" || (options.csvOut ?? []).some((target) => target.path === "-");
469
+ }
470
+ function listPath(source) {
471
+ return source.replace(/^\//, "").replace(/\//g, ".").replace(/^result(\.|$)/, "");
472
+ }
473
+ function valueAt(value, path) {
474
+ return path.split(".").reduce((at, key) => record(at) ? at[key] : void 0, value);
475
+ }
476
+ function validateExecutionOutput(options) {
477
+ const toStdout = [
478
+ ["--json-out", options.jsonOut],
479
+ ...(options.csvOut ?? []).map((target) => ["--csv-out", target.path]),
480
+ ["--logs-out", options.logsOut]
481
+ ].filter(([, path]) => path === "-");
482
+ if ((options.csvOut ?? []).filter((target) => !target.list).length > 1) {
483
+ throw new Error(
484
+ "Only one --csv-out may leave out the list name; name the others as list=path."
485
+ );
486
+ }
487
+ if (toStdout.length > 1) {
488
+ throw new Error(
489
+ `Only one of ${toStdout.map(([flag]) => flag).join(" and ")} may write to stdout.`
490
+ );
491
+ }
492
+ if (options.receiptOut === "-") {
493
+ throw new Error(
494
+ "--receipt-out takes a file. Use --json to print the receipt as JSON."
495
+ );
496
+ }
497
+ const paths = [
498
+ options.jsonOut,
499
+ ...(options.csvOut ?? []).map((target) => target.path),
500
+ options.receiptOut,
501
+ options.logsOut
502
+ ].filter((p) => p !== void 0 && p !== "-");
503
+ const resolved = paths.map((p) => {
504
+ if (!p.trim()) throw new Error("Output filenames must not be empty.");
505
+ const absolute = resolve2(p);
506
+ if (existsSync(absolute))
507
+ throw new Error(
508
+ `Output file already exists: ${absolute}. Choose a new filename.`
509
+ );
510
+ accessSync(dirname(absolute), constants.W_OK);
511
+ return join(
512
+ realpathSync(dirname(absolute)),
513
+ absolute.slice(dirname(absolute).length + 1)
514
+ );
515
+ });
516
+ if (new Set(resolved).size !== resolved.length) {
517
+ throw new Error(
518
+ "--json-out, --csv-out, --receipt-out and --logs-out must use different files."
519
+ );
520
+ }
521
+ }
522
+ function preflightExecutionOutput(options) {
523
+ try {
524
+ validateExecutionOutput(options);
525
+ return true;
526
+ } catch (error) {
527
+ writeExecutionOutput(
528
+ {
529
+ id: null,
530
+ status: "failed",
531
+ error: {
532
+ message: error instanceof Error ? error.message : String(error)
533
+ },
534
+ ran: false
535
+ },
536
+ // A rejected destination must not be opened, nor may errors pollute data stdout.
537
+ {
538
+ receiptJson: options.receiptJson,
539
+ ...dataOnStdout(options) ? { jsonOut: "-" } : {}
540
+ }
541
+ );
542
+ return false;
543
+ }
544
+ }
545
+ function record(value) {
546
+ return value !== null && typeof value === "object" && !Array.isArray(value);
547
+ }
548
+ function pointerPart(key) {
549
+ return key.replace(/~/g, "~0").replace(/\//g, "~1");
550
+ }
551
+ function outputCollections(data, source = "") {
552
+ if (Array.isArray(data)) return [{ source, rows: data, complete: null }];
553
+ if (!record(data)) return [];
554
+ return Object.entries(data).flatMap(
555
+ ([key, value]) => outputCollections(value, `${source}/${pointerPart(key)}`)
556
+ );
557
+ }
558
+ function mergeSchema(a, b) {
559
+ if (!Object.keys(a).length) return b;
560
+ if (!Object.keys(b).length) return a;
561
+ if (a.type !== b.type || a.anyOf || b.anyOf) {
562
+ const variants = [
563
+ ...Array.isArray(a.anyOf) ? a.anyOf : [a],
564
+ ...Array.isArray(b.anyOf) ? b.anyOf : [b]
565
+ ];
566
+ const byType = /* @__PURE__ */ new Map();
567
+ for (const variant of variants) {
568
+ const previous = byType.get(variant.type);
569
+ byType.set(
570
+ variant.type,
571
+ previous ? mergeSchema(previous, variant) : variant
572
+ );
573
+ }
574
+ return { anyOf: [...byType.values()] };
575
+ }
576
+ if (a.type === "array")
577
+ return {
578
+ type: "array",
579
+ items: mergeSchema(a.items, b.items)
580
+ };
581
+ if (a.type !== "object") return a;
582
+ const properties = { ...a.properties };
583
+ for (const [key, value] of Object.entries(
584
+ b.properties
585
+ )) {
586
+ Object.defineProperty(properties, key, {
587
+ value: properties[key] && Object.hasOwn(properties, key) ? mergeSchema(properties[key], value) : value,
588
+ enumerable: true,
589
+ configurable: true,
590
+ writable: true
591
+ });
592
+ }
593
+ return {
594
+ type: "object",
595
+ properties,
596
+ required: a.required.filter(
597
+ (key) => b.required.includes(key)
598
+ )
599
+ };
600
+ }
601
+ function observedSchema(value) {
602
+ if (value === null) return { type: "null" };
603
+ if (Array.isArray(value))
604
+ return {
605
+ type: "array",
606
+ items: value.reduce(
607
+ (schema, item) => mergeSchema(schema, observedSchema(item ?? null)),
608
+ {}
609
+ )
610
+ };
611
+ if (record(value)) {
612
+ const entries = Object.entries(value).filter(
613
+ ([, item]) => item !== void 0
614
+ );
615
+ return {
616
+ type: "object",
617
+ properties: Object.fromEntries(
618
+ entries.map(([key, item]) => [key, observedSchema(item)])
619
+ ),
620
+ required: entries.map(([key]) => key)
621
+ };
622
+ }
623
+ return { type: typeof value === "number" ? "number" : typeof value };
624
+ }
625
+ function csvColumns(collection, fields) {
626
+ const prefix = listPath(collection.source);
627
+ const columns = (fields ?? []).flatMap(
628
+ (field) => !prefix ? [field] : field.startsWith(`${prefix}.`) ? [field.slice(prefix.length + 1)] : []
629
+ );
630
+ if (!columns.length) return csvText(collection.rows, collection.columns);
631
+ return csvText(
632
+ collection.rows.map(
633
+ (row) => Object.fromEntries(
634
+ columns.map((column) => [column, valueAt(row, column)])
635
+ )
636
+ ),
637
+ columns
638
+ );
639
+ }
640
+ function csvText(rows, columns = []) {
641
+ const projection = projectRunDatasetCsv({
642
+ rows: rows.map((row) => record(row) ? row : { value: row }),
643
+ columns
644
+ });
645
+ return csvStringFromRows(projection.rows, projection.columns);
646
+ }
647
+ function writeExecutionOutput(result, options) {
648
+ let temp;
649
+ const temporary = (name) => join(temp ??= mkdtempSync(join(tmpdir(), "deepline-output-")), name);
650
+ const jsonText = (value) => `${JSON.stringify(value, null, 2)}
651
+ `;
652
+ const persist = (path, content) => {
653
+ const absolute = resolve2(path);
654
+ const staging = join(dirname(absolute), `.deepline-${randomUUID()}.tmp`);
655
+ try {
656
+ writeFileSync3(staging, content, { flag: "wx", mode: 384 });
657
+ linkSync(staging, absolute);
658
+ } finally {
659
+ if (existsSync(staging)) unlinkSync(staging);
660
+ }
661
+ return absolute;
662
+ };
663
+ let stdoutData;
664
+ const artifact = (destination, content, format, source, rowCount, complete) => {
665
+ const stdout = destination === "-";
666
+ if (stdout) stdoutData = content;
667
+ return {
668
+ path: stdout ? null : persist(destination, content),
669
+ destination: stdout ? "stdout" : "file",
670
+ format,
671
+ source,
672
+ rowCount,
673
+ complete
674
+ };
675
+ };
676
+ let savedJson;
677
+ const ensureJson = () => savedJson ??= persist(temporary("result.json"), jsonText(result.data));
678
+ try {
679
+ const hasData = result.data !== void 0;
680
+ const collections = result.collections ?? (hasData ? outputCollections(result.data).map((collection) => ({
681
+ ...collection,
682
+ complete: result.complete ?? null
683
+ })) : []);
684
+ const ordered = collections.map((c, index) => ({ ...c, index })).sort((a, b) => b.rows.length - a.rows.length || a.index - b.index);
685
+ const csvTargets = hasData ? options.csvOut ?? [] : [];
686
+ if (csvTargets.length && !ordered.length)
687
+ throw new Error(
688
+ "This result has no row list to write as CSV. Use --json-out."
689
+ );
690
+ const underFields = ordered.find((collection) => {
691
+ const prefix = listPath(collection.source);
692
+ return prefix && options.fields?.some((field) => field.startsWith(`${prefix}.`));
693
+ });
694
+ const declaredList = ordered.find(
695
+ (collection) => result.declared?.some(
696
+ ({ path }) => path !== null && path === listPath(collection.source)
697
+ )
698
+ );
699
+ const defaultList = underFields ?? declaredList ?? ordered[0];
700
+ const csvFor = /* @__PURE__ */ new Map();
701
+ for (const target of csvTargets) {
702
+ const chosen = target.list ? ordered.find(
703
+ (collection) => collection.name === target.list || listPath(collection.source) === target.list || listPath(collection.source).endsWith(`.${target.list}`)
704
+ ) : defaultList;
705
+ if (!chosen) {
706
+ throw new Error(
707
+ `No row list named "${target.list}". The lists are: ${ordered.map((collection) => collection.name ?? (listPath(collection.source) || "(top level)")).join(", ")}`
708
+ );
709
+ }
710
+ csvFor.set(chosen, target);
711
+ }
712
+ const outputs = { json: null, csv: [] };
713
+ if (hasData && (options.jsonOut || !csvTargets.length)) {
714
+ outputs.json = artifact(
715
+ options.jsonOut ?? temporary("result.json"),
716
+ jsonText(result.data),
717
+ "json",
718
+ "",
719
+ Array.isArray(result.data) ? result.data.length : null,
720
+ result.complete ?? null
721
+ );
722
+ savedJson = outputs.json.path ?? void 0;
723
+ }
724
+ const summaries = ordered.map((collection) => {
725
+ const target = csvFor.get(collection);
726
+ const csv = target ? artifact(
727
+ target.path,
728
+ csvColumns(collection, options.fields),
729
+ "csv",
730
+ collection.source,
731
+ collection.rows.length,
732
+ collection.complete
733
+ ) : null;
734
+ if (csv) outputs.csv.push(csv);
735
+ return {
736
+ source: collection.source,
737
+ rowCount: collection.rows.length,
738
+ complete: collection.complete,
739
+ outcomes: collection.outcomes ?? null,
740
+ columns: collection.columns?.length ? collection.columns : columnsOf(collection.rows),
741
+ csv: csv ? csv.path ?? "stdout" : null
742
+ };
743
+ });
744
+ const schemaFile = hasData ? persist(
745
+ temporary("result.schema.json"),
746
+ jsonText({
747
+ $schema: JSON_SCHEMA_DIALECT,
748
+ ...observedSchema(result.data)
749
+ })
750
+ ) : null;
751
+ const receipt = {
752
+ status: result.status,
753
+ id: result.id,
754
+ name: options.label ?? null,
755
+ credits: result.credits ?? null,
756
+ outputs,
757
+ page: result.page ?? null,
758
+ price: result.price ?? null,
759
+ declaredOutputs: (result.declared ?? []).map(({ name, path }) => ({
760
+ name,
761
+ path
762
+ })),
763
+ schemaFile,
764
+ logsFile: options.logsFile ?? null,
765
+ collections: summaries,
766
+ warnings: result.warnings ?? [],
767
+ error: result.error ?? null,
768
+ next: result.next ?? {}
769
+ };
770
+ const receiptFile = options.receiptOut ? persist(options.receiptOut, jsonText(receipt)) : null;
771
+ printReceipt(receipt, options, {
772
+ receiptFile,
773
+ data: hasData ? result.data : void 0,
774
+ ran: result.ran,
775
+ declared: result.declared
776
+ });
777
+ if (stdoutData !== void 0) process.stdout.write(stdoutData);
778
+ } catch (error) {
779
+ let recoveryFile = null;
780
+ try {
781
+ if (result.data !== void 0) recoveryFile = ensureJson();
782
+ } catch {
783
+ }
784
+ const failure = {
785
+ status: "output_failed",
786
+ id: result.id,
787
+ name: options.label ?? null,
788
+ credits: result.credits ?? null,
789
+ outputs: { json: null, csv: [] },
790
+ page: result.page ?? null,
791
+ price: result.price ?? null,
792
+ declaredOutputs: [],
793
+ schemaFile: null,
794
+ logsFile: options.logsFile ?? null,
795
+ collections: [],
796
+ warnings: [],
797
+ error: {
798
+ message: error instanceof Error ? error.message : String(error),
799
+ recoveryFile
800
+ },
801
+ next: result.next ?? {}
802
+ };
803
+ printReceipt(failure, options, { receiptFile: null, ran: result.ran });
804
+ throw new ExecutionOutputError(
805
+ `Output failed${result.id ? ` for ${result.id}` : ""}: ${error instanceof Error ? error.message : String(error)}. Do not re-execute paid work.`,
806
+ { cause: error }
807
+ );
808
+ }
809
+ }
810
+ var EXAMPLE_CHARACTERS = 40;
811
+ var HEADLINES = {
812
+ completed: "Completed",
813
+ failed: "Failed",
814
+ cancelled: "Cancelled",
815
+ running: "Still running",
816
+ queued: "Started",
817
+ pending: "Started",
818
+ output_failed: "Ran, but the output could not be written",
819
+ dry_run: "Dry run, nothing sent"
820
+ };
821
+ var NEXT_NOTES = {
822
+ billing: "what this call cost",
823
+ status: "check on the run",
824
+ export: "save its rows once it finishes",
825
+ getActorRun: "check the Apify run",
826
+ getDatasetItems: "read the Apify run\u2019s items"
827
+ };
828
+ function exampleOf(value) {
829
+ return typeof value === "string" && value.length > EXAMPLE_CHARACTERS ? `${value.slice(0, EXAMPLE_CHARACTERS)}\u2026` : value;
830
+ }
831
+ function annotated(schema, values) {
832
+ const present = values.filter((value) => value !== void 0);
833
+ const first = present.find(
834
+ (value) => value !== null && typeof value !== "object"
835
+ );
836
+ const node2 = { ...schema };
837
+ if (first !== void 0) node2.example = exampleOf(first);
838
+ if (Array.isArray(schema.anyOf)) {
839
+ node2.anyOf = schema.anyOf.map(
840
+ (variant) => annotated(variant, present)
841
+ );
842
+ }
843
+ if (record(schema.properties)) {
844
+ const rows = present.filter(record);
845
+ node2.properties = Object.fromEntries(
846
+ Object.entries(schema.properties).map(([key, child]) => [
847
+ key,
848
+ annotated(
849
+ child,
850
+ rows.map((row) => row[key])
851
+ )
852
+ ])
853
+ );
854
+ }
855
+ if (schema.type === "array" && record(schema.items)) {
856
+ const lists = present.filter(Array.isArray);
857
+ node2.items = annotated(schema.items, lists.flat());
858
+ const lengths = lists.map((list) => list.length);
859
+ const [low, high] = [Math.min(...lengths), Math.max(...lengths)];
860
+ const items = high === 1 ? "item" : "items";
861
+ if (lengths.length === 1) node2.description = `${low} ${items}`;
862
+ else if (lengths.length > 1) {
863
+ node2.description = low === high ? `${low} ${items} each` : `${low}-${high} items each`;
864
+ }
865
+ }
866
+ return node2;
867
+ }
868
+ function shapeLines(title, data) {
869
+ const schema = annotated(observedSchema(data), [data]);
870
+ const block = (heading, fieldSchema) => {
871
+ const { lines, folded } = fieldBlockLines(
872
+ heading,
873
+ schemaFields(fieldSchema)
874
+ );
875
+ return [
876
+ ...lines,
877
+ ...folded ? ["Long result: deeper objects show only their field names."] : [],
878
+ "Types are what this result contained; a field that was only ever null shows as null."
879
+ ];
880
+ };
881
+ if (record(schema.properties)) return block(title, schema);
882
+ if (schema.type === "array" && record(schema.items) && record(schema.items.properties)) {
883
+ const count = Array.isArray(data) ? data.length : 0;
884
+ return block(`${title}
885
+ A list of ${count} items, each:`, schema.items);
886
+ }
887
+ const value = Array.isArray(data) ? `a list of ${data.length} values` : data === null ? "null" : `${typeof data}, ${JSON.stringify(exampleOf(data))}`;
888
+ return [`${title} ${value}`];
889
+ }
890
+ function receiptText(receipt, options, extra) {
891
+ const headline = HEADLINES[receipt.status] ?? receipt.status;
892
+ const sections = [
893
+ [
894
+ options.label ? `${headline}: ${options.label}` : headline,
895
+ ...receipt.id ? [`Id: ${receipt.id}`] : [],
896
+ ...receipt.credits !== null ? [
897
+ `Cost: ${receipt.credits} ${receipt.credits === 1 ? "credit" : "credits"}`
898
+ ] : [],
899
+ ...receipt.price ? [`Price: ${receipt.price}`] : []
900
+ ]
901
+ ];
902
+ const { csv, json } = receipt.outputs;
903
+ const data = [];
904
+ for (const artifact of csv) {
905
+ data.push(
906
+ `Rows: ${artifact.path ?? "stdout"} (${artifact.rowCount} rows from ${listPath(artifact.source ?? "") || "the result"})`
907
+ );
908
+ }
909
+ if (extra.data !== void 0) {
910
+ const title = json ? `Result: ${json.path ?? "stdout"}` : "Result (not saved; --json-out saves all of it):";
911
+ data.push(...resultLines(title, extra.data, extra.declared, options));
912
+ if (receipt.schemaFile) {
913
+ data.push(`Full JSON Schema: ${receipt.schemaFile}`);
914
+ }
915
+ }
916
+ if (receipt.logsFile) data.push(`Logs: ${receipt.logsFile}`);
917
+ if (receipt.page) data.push(`Page: ${receipt.page}`);
918
+ if (data.length) sections.push(data);
919
+ const problems = [];
920
+ if (receipt.warnings.length) {
921
+ problems.push(
922
+ "Warnings:",
923
+ ...receipt.warnings.map((warning) => ` - ${warning}`)
924
+ );
925
+ }
926
+ if (receipt.error) {
927
+ const error = receipt.error;
928
+ problems.push(
929
+ `Error: ${record(error) && typeof error.message === "string" ? error.message : JSON.stringify(error)}`
930
+ );
931
+ if (record(error) && typeof error.recoveryFile === "string") {
932
+ problems.push(
933
+ `The data was saved to ${error.recoveryFile}; do not run again.`
934
+ );
935
+ }
936
+ }
937
+ if (extra.ran === false) problems.push("Nothing ran.");
938
+ if (problems.length) sections.push(problems);
939
+ const next = Object.entries(receipt.next);
940
+ if (next.length) {
941
+ const width = Math.max(...next.map(([, command]) => command.length));
942
+ sections.push([
943
+ "Next:",
944
+ ...next.map(
945
+ ([key, command]) => NEXT_NOTES[key] ? ` ${command.padEnd(width)} # ${NEXT_NOTES[key]}` : ` ${command}`
946
+ )
947
+ ]);
948
+ }
949
+ if (extra.receiptFile) {
950
+ sections.push([`JSON receipt: ${extra.receiptFile}`]);
951
+ }
952
+ return `${sections.map((lines) => lines.join("\n")).join("\n\n")}
953
+ `;
954
+ }
955
+ function columnsOf(rows) {
956
+ const columns = /* @__PURE__ */ new Set();
957
+ for (const row of rows) {
958
+ if (record(row)) for (const key of Object.keys(row)) columns.add(key);
959
+ }
960
+ return [...columns];
961
+ }
962
+ function resultLines(title, data, declared, options) {
963
+ if (options.full) {
964
+ const sources = (declared ?? []).flatMap(
965
+ ({ name, path }) => path ? [`${name} at ${path}`] : []
966
+ );
967
+ return [
968
+ ...shapeLines(title, data),
969
+ ...sources.length ? [`Declared outputs: ${sources.join(", ")}`] : []
970
+ ];
971
+ }
972
+ const budget = options.lines ?? OUTLINE_LINES;
973
+ const indented = (lines) => lines.map((line) => ` ${line}`);
974
+ const more = "Not everything is shown: --lines <n> shows more, --fields <paths> picks fields, --full shows every field's type.";
975
+ if (options.fields?.length) {
976
+ const { value, missing } = pickFields(data, options.fields);
977
+ const outline2 = value === void 0 ? null : outlineLines(value, budget);
978
+ return [
979
+ `${title}${outline2?.note ? ` ${outline2.note}` : ""}`,
980
+ ...indented(outline2?.lines ?? []),
981
+ ...missing.map((path) => `No field at ${path}.`),
982
+ ...outline2?.cut ? [more] : []
983
+ ];
984
+ }
985
+ if (declared?.length) {
986
+ const outline2 = outlineLines(
987
+ Object.fromEntries(declared.map(({ name, value }) => [name, value])),
988
+ budget
989
+ );
990
+ return [
991
+ title,
992
+ "Outputs, as the tool declares them:",
993
+ ...indented(outline2.lines),
994
+ outline2.cut ? more : "--full shows every field of the result; --fields <paths> picks fields."
995
+ ];
996
+ }
997
+ const outline = outlineLines(data, budget);
998
+ return [
999
+ `${title}${outline.note ? ` ${outline.note}` : ""}`,
1000
+ ...indented(outline.lines),
1001
+ ...outline.cut ? [more] : []
1002
+ ];
1003
+ }
1004
+ function printReceipt(receipt, options, extra) {
1005
+ const text = options.receiptJson ? `${JSON.stringify(receipt, null, 2)}
1006
+ ` : receiptText(receipt, options, extra);
1007
+ (dataOnStdout(options) ? process.stderr : process.stdout).write(text);
1008
+ }
1009
+ function openLogDestination(output) {
1010
+ if (output.logsOut === "-") {
1011
+ return (line) => process.stdout.write(`${line}
1012
+ `);
1013
+ }
1014
+ const path = resolve2(
1015
+ output.logsOut ?? join(mkdtempSync(join(tmpdir(), "deepline-logs-")), "logs.txt")
1016
+ );
1017
+ writeFileSync3(path, "", { flag: "wx", mode: 384 });
1018
+ output.logsFile = path;
1019
+ process.stderr.write(`Live logs: ${path}
1020
+ `);
1021
+ return (line) => appendFileSync(path, `${line}
1022
+ `);
1023
+ }
1024
+
1025
+ export {
1026
+ addDescribeOptions,
1027
+ recordApiResponse,
1028
+ recordPlayTermination,
1029
+ TABLE_EXPORT_ERROR_COLUMN,
1030
+ tableExportHasFailedRows,
1031
+ tableExportErrorCell,
1032
+ underscoreKeysLast,
1033
+ orderRunExportJson,
1034
+ writeRunDatasetCsv,
1035
+ preflightExecutionOutput,
1036
+ outputCollections,
1037
+ writeExecutionOutput,
1038
+ openLogDestination
1039
+ };