deepline 0.3.546 → 0.3.548

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 (204) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +13 -0
  2. package/dist/bundling-sources/sdk/src/index.ts +7 -1
  3. package/dist/bundling-sources/sdk/src/integrations.ts +17 -7
  4. package/dist/bundling-sources/sdk/src/play.ts +71 -0
  5. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  6. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +13 -4
  7. package/dist/bundling-sources/sdk/src/types.ts +33 -0
  8. package/dist/bundling-sources/shared_libs/integration-contracts/calendar-delegation.ts +7 -0
  9. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +2 -0
  10. package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +1 -0
  11. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +19 -1
  12. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +17 -2
  13. package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +57 -5
  14. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +295 -52
  15. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +10 -1
  16. package/dist/bundling-sources/shared_libs/play-runtime/docflow-decision-tracker.ts +135 -0
  17. package/dist/bundling-sources/shared_libs/play-runtime/docflow-fail-open.ts +177 -0
  18. package/dist/bundling-sources/shared_libs/play-runtime/docflow-node-io.ts +99 -2
  19. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +16 -10
  20. package/dist/bundling-sources/shared_libs/play-runtime/fenced-call-diagnostics.ts +211 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +52 -14
  22. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +68 -2
  23. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +18 -0
  24. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +68 -0
  25. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +100 -3
  26. package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +9 -1
  27. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +48 -0
  28. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +6 -1
  29. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +716 -51
  30. package/dist/bundling-sources/shared_libs/plays/docflow-decision-arms.ts +146 -0
  31. package/dist/bundling-sources/shared_libs/plays/docflow-flow-order.ts +94 -0
  32. package/dist/bundling-sources/shared_libs/plays/docflow-unreached-reason.ts +10 -1
  33. package/dist/bundling-sources/shared_libs/plays/docflow.ts +787 -117
  34. package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +8 -2
  35. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +6 -0
  36. package/dist/bundling-sources/shared_libs/plays/trigger-config-contract.ts +13 -0
  37. package/dist/bundling-sources/shared_libs/product-notifications/billing-sales.ts +25 -0
  38. package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +3 -0
  39. package/dist/bundling-sources/shared_libs/security/email-domain.ts +24 -0
  40. package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +56 -0
  41. package/dist/cli/auth-7UJFY5BY.js +43 -0
  42. package/dist/cli/{auth-KFWG72AZ.mjs → auth-YOOVLLUL.mjs} +5 -5
  43. package/dist/cli/{billing-MMZ336HO.mjs → billing-2NCNX6L2.mjs} +10 -10
  44. package/dist/cli/{billing-OQVOAZ4S.js → billing-HETIOUD6.js} +96 -96
  45. package/dist/cli/{chunk-JVOUQFHT.js → chunk-2OG2KBYJ.js} +1 -1
  46. package/dist/cli/{chunk-JA633HRV.mjs → chunk-3QRU6RY7.mjs} +3 -3
  47. package/dist/cli/{chunk-TI6DTURF.js → chunk-4WAM6TLD.js} +7 -1
  48. package/dist/cli/{chunk-RO66FPTS.mjs → chunk-53QLWPZK.mjs} +1 -1
  49. package/dist/cli/{chunk-6LG7MLJ2.js → chunk-5OJOFUMO.js} +44 -44
  50. package/dist/cli/{chunk-F2VEFMU5.js → chunk-5XFJBIQT.js} +13 -13
  51. package/dist/cli/{chunk-UQJBV5PM.js → chunk-5XXPP3PR.js} +10 -10
  52. package/dist/cli/{chunk-6FBDTYR2.mjs → chunk-64BFUBXX.mjs} +2 -2
  53. package/dist/cli/{chunk-VAT2SXFF.js → chunk-6GIZNOXQ.js} +12 -12
  54. package/dist/cli/{chunk-7MY7KWJS.mjs → chunk-7AJ5V3BK.mjs} +1 -1
  55. package/dist/cli/{chunk-MEGHIX4M.js → chunk-7H6TQ6W2.js} +5 -5
  56. package/dist/cli/{chunk-PMDHY2YK.js → chunk-7JIOJLTS.js} +7 -7
  57. package/dist/cli/{chunk-EEJHB76U.js → chunk-7UJZWI5Z.js} +12 -12
  58. package/dist/cli/{chunk-X5KOHDJN.mjs → chunk-ATTURFOV.mjs} +1 -1
  59. package/dist/cli/{chunk-SH32HL7I.js → chunk-AUYBBFPT.js} +53 -53
  60. package/dist/cli/{chunk-JCWNF44W.js → chunk-BDBEEV6X.js} +22 -22
  61. package/dist/cli/{chunk-WKHPLBJK.js → chunk-BWJZ4NQJ.js} +15 -15
  62. package/dist/cli/{chunk-2JHYYB3F.js → chunk-CSPHSNBW.js} +3 -3
  63. package/dist/cli/{chunk-4AZLGNXV.js → chunk-CXZLHBNK.js} +4 -4
  64. package/dist/cli/{chunk-J65HJCJO.mjs → chunk-F4ON5COB.mjs} +2 -2
  65. package/dist/cli/{chunk-KUK7ARXA.mjs → chunk-FMQA7UZZ.mjs} +2 -2
  66. package/dist/cli/{chunk-UREAIHUU.mjs → chunk-FUUYWEF4.mjs} +3 -3
  67. package/dist/cli/{chunk-HXIR3VQL.mjs → chunk-FZHMNK6F.mjs} +7 -1
  68. package/dist/cli/{chunk-PU3ZAG6V.mjs → chunk-GCEGQ7TQ.mjs} +1 -1
  69. package/dist/cli/{chunk-BLYW6FFB.js → chunk-GJA2PRHJ.js} +2 -2
  70. package/dist/cli/{chunk-TBWYZOSV.js → chunk-GUIYFOG2.js} +3 -3
  71. package/dist/cli/{chunk-BTFUAGHC.js → chunk-HDLMX7SG.js} +16 -16
  72. package/dist/cli/{chunk-VTK3HGMN.mjs → chunk-HIMZ57QD.mjs} +5 -5
  73. package/dist/cli/{chunk-JYG4XZLT.js → chunk-HTZIJORU.js} +99 -99
  74. package/dist/cli/{chunk-VPERQ3U6.mjs → chunk-HU3DDLGD.mjs} +5 -5
  75. package/dist/cli/{chunk-H7Q5IDO3.js → chunk-I2JIWKCQ.js} +20 -20
  76. package/dist/cli/{chunk-MXQP7CXZ.js → chunk-IIWXBRDK.js} +3 -3
  77. package/dist/cli/{chunk-MI7X6V6V.mjs → chunk-IQBXX54G.mjs} +3 -3
  78. package/dist/cli/{chunk-SYTWWVIQ.js → chunk-JQWX377P.js} +5 -5
  79. package/dist/cli/{chunk-Z3UEBFIN.js → chunk-LAVPP6WD.js} +41 -41
  80. package/dist/cli/{chunk-JCH4UNNS.js → chunk-M2OZORIH.js} +2 -2
  81. package/dist/cli/{chunk-Z7SXGOIQ.mjs → chunk-MF7PCM6C.mjs} +1 -1
  82. package/dist/cli/{chunk-7ZW67ME6.mjs → chunk-MQSKSISW.mjs} +1 -1
  83. package/dist/cli/{chunk-JARZ47OP.mjs → chunk-MWQ4WWZF.mjs} +2 -2
  84. package/dist/cli/{chunk-EEG46QZY.mjs → chunk-NFMX7BRF.mjs} +2 -2
  85. package/dist/cli/{chunk-VXTTAYOT.mjs → chunk-OGDQFVCP.mjs} +3 -3
  86. package/dist/cli/{chunk-3DUNNZB6.mjs → chunk-OQCYSLML.mjs} +4 -4
  87. package/dist/cli/{chunk-5W4ENHWM.js → chunk-PVE3A2BO.js} +285 -264
  88. package/dist/cli/{chunk-F5YQXCP3.js → chunk-PVQCX6KQ.js} +50 -7
  89. package/dist/cli/{chunk-GYTSDSQD.mjs → chunk-QQBRXMZM.mjs} +11 -11
  90. package/dist/cli/{chunk-6Y5TU3R7.mjs → chunk-QZ74ZC55.mjs} +1 -1
  91. package/dist/cli/{chunk-5OEFXAKP.mjs → chunk-RMCCB3XY.mjs} +50 -7
  92. package/dist/cli/{chunk-5V7NZKGG.js → chunk-T3RDWG5J.js} +2 -2
  93. package/dist/cli/{chunk-OAKWSLKS.mjs → chunk-TKGFHRHE.mjs} +28 -7
  94. package/dist/cli/{chunk-HJR2DDJS.mjs → chunk-U35ZLVBA.mjs} +2 -2
  95. package/dist/cli/{chunk-ND7SFRQL.js → chunk-U7HJXE6Y.js} +2 -2
  96. package/dist/cli/{chunk-LX2TC3HO.mjs → chunk-UBQQR56I.mjs} +4 -4
  97. package/dist/cli/{chunk-5VNQMVCU.js → chunk-VK2GSTRN.js} +26 -26
  98. package/dist/cli/{chunk-K2XELBPF.mjs → chunk-VSACOMIA.mjs} +5 -5
  99. package/dist/cli/{chunk-IVWU7SJC.js → chunk-WI4MCR7M.js} +5 -5
  100. package/dist/cli/{chunk-LIJKRDDG.js → chunk-WIHQAZPV.js} +6 -6
  101. package/dist/cli/{chunk-LHE2TSV6.mjs → chunk-WVZF4DU7.mjs} +1 -1
  102. package/dist/cli/{chunk-2HSZCQMT.mjs → chunk-WYT3H6JD.mjs} +1 -1
  103. package/dist/cli/{chunk-GOOF7E2B.mjs → chunk-XKEBQVCP.mjs} +5 -5
  104. package/dist/cli/{chunk-P7A3H6G5.mjs → chunk-XU3D2KFR.mjs} +1 -1
  105. package/dist/cli/command-docs.js +2 -2
  106. package/dist/cli/command-docs.mjs +1 -1
  107. package/dist/cli/concurrent-runs-help-A2IQVZRJ.js +21 -0
  108. package/dist/cli/{concurrent-runs-help-C2O5YKQA.mjs → concurrent-runs-help-FDCCZ45D.mjs} +6 -6
  109. package/dist/cli/{csv-Z4DNGR54.mjs → csv-GJYLQ52D.mjs} +4 -4
  110. package/dist/cli/{csv-MJDNOIQJ.js → csv-OCEQWZO3.js} +13 -13
  111. package/dist/cli/{db-4RL2BNOF.mjs → db-5MA2UUHQ.mjs} +7 -7
  112. package/dist/cli/{db-S5QVPK5E.js → db-G5QGXFAX.js} +28 -28
  113. package/dist/cli/{describe-L4P5SZLQ.mjs → describe-4DOJ4DHA.mjs} +19 -19
  114. package/dist/cli/describe-SD7DRTBW.js +50 -0
  115. package/dist/cli/describe-core.d.mts +4 -4
  116. package/dist/cli/describe-core.d.ts +4 -4
  117. package/dist/cli/{executions-RR6O3XK5.mjs → executions-C7SMBHHB.mjs} +7 -7
  118. package/dist/cli/{executions-MFZ2Z36O.js → executions-IYEVUPJI.js} +9 -9
  119. package/dist/cli/{feedback-YDAG7VH2.js → feedback-GYAF46GA.js} +14 -14
  120. package/dist/cli/{feedback-EQBQ3ABB.mjs → feedback-XUU2UKM6.mjs} +6 -6
  121. package/dist/cli/git-7YYVMY6L.js +25 -0
  122. package/dist/cli/{git-YGLCCU35.mjs → git-WVCMK5AH.mjs} +5 -5
  123. package/dist/cli/index.js +146 -146
  124. package/dist/cli/index.mjs +45 -45
  125. package/dist/cli/{integrations-FWYXSBHK.mjs → integrations-FXADGAX2.mjs} +11 -9
  126. package/dist/cli/{integrations-IQXYMRMW.js → integrations-YYBJJFVX.js} +19 -17
  127. package/dist/cli/{legacy-noops-I4YRIX5F.mjs → legacy-noops-LJY7LDUE.mjs} +6 -6
  128. package/dist/cli/{legacy-noops-U7LI7UXC.js → legacy-noops-REZCYES2.js} +9 -9
  129. package/dist/cli/{mcp-GX2UKKWU.js → mcp-L5PURE5S.js} +24 -24
  130. package/dist/cli/{mcp-QJBMB6VS.mjs → mcp-XSB3ZJFR.mjs} +4 -4
  131. package/dist/cli/{monitors-WCJYINGX.js → monitors-I5EIHSGV.js} +119 -101
  132. package/dist/cli/{monitors-Z6EGKYJP.mjs → monitors-UBPF2OLO.mjs} +26 -8
  133. package/dist/cli/{org-NNHICBR2.mjs → org-PHHIN2ER.mjs} +7 -7
  134. package/dist/cli/{org-7SKG423N.js → org-SGSTGGUD.js} +89 -89
  135. package/dist/cli/{play-CXDFPJ7Z.mjs → play-LEJNJLWY.mjs} +295 -67
  136. package/dist/cli/{play-4P4DTG3Q.js → play-WQEKMANL.js} +897 -669
  137. package/dist/cli/{providers-VQLQ7DTR.mjs → providers-3W26ZDAV.mjs} +7 -7
  138. package/dist/cli/{providers-EE4TUE3O.js → providers-RSDXBXIS.js} +10 -10
  139. package/dist/cli/{quickstart-IYNJRB5G.mjs → quickstart-LGJD2M36.mjs} +4 -4
  140. package/dist/cli/{quickstart-RVXHK4WA.js → quickstart-U3QX4EMI.js} +6 -6
  141. package/dist/cli/{run-R3F34KU3.js → run-F2UPZUJS.js} +45 -45
  142. package/dist/cli/{run-VBQPPMEX.mjs → run-YWZ3W5HK.mjs} +25 -25
  143. package/dist/cli/search-K6ANAXLF.js +32 -0
  144. package/dist/cli/{search-B7R62HX5.mjs → search-O2OJH3PY.mjs} +8 -8
  145. package/dist/cli/{search-output-LNQQXIGZ.mjs → search-output-H5BF6SJ3.mjs} +4 -4
  146. package/dist/cli/{search-output-LWHWEPOT.js → search-output-W7OCBYBU.js} +6 -6
  147. package/dist/cli/{secrets-NM3VAJLO.mjs → secrets-65XCAA7U.mjs} +7 -7
  148. package/dist/cli/{secrets-QBOZ7WTD.js → secrets-BN4GYVRI.js} +16 -16
  149. package/dist/cli/sessions-M52QWLA6.js +22 -0
  150. package/dist/cli/{sessions-R5BSIJ4I.mjs → sessions-SVEVESCQ.mjs} +6 -6
  151. package/dist/cli/{settings-POYWKNRD.js → settings-7YMDAFCN.js} +86 -86
  152. package/dist/cli/{settings-S4PN7WLY.mjs → settings-HAU2NP2H.mjs} +13 -13
  153. package/dist/cli/{setup-PFLXVBTL.mjs → setup-5RXHZ6YI.mjs} +9 -9
  154. package/dist/cli/{setup-VHB4Z654.js → setup-G37QXQGM.js} +49 -49
  155. package/dist/cli/{skills-W2TELEU7.mjs → skills-Q7A3XFAU.mjs} +7 -7
  156. package/dist/cli/skills-ZK4D5BJW.js +36 -0
  157. package/dist/cli/tools-DBZTLYFM.js +57 -0
  158. package/dist/cli/{tools-M4FA6N3Y.mjs → tools-ZG4NYRGB.mjs} +18 -18
  159. package/dist/cli/{update-W7LIHEA7.mjs → update-2CMZTZCL.mjs} +9 -9
  160. package/dist/cli/update-LC5HGEEH.js +34 -0
  161. package/dist/cli/{views-KTVPV6UP.mjs → views-A6IIY4OQ.mjs} +7 -7
  162. package/dist/cli/{views-DJXAGD7V.js → views-XUMDMDIE.js} +22 -22
  163. package/dist/cli/{workflow-NVZDJKH2.js → workflow-4EEW6MCD.js} +18 -18
  164. package/dist/cli/{workflow-LGKCRODX.mjs → workflow-74MYISHU.mjs} +8 -8
  165. package/dist/{client-Tp1LSULB.d.mts → client-D1uWA2Vc.d.mts} +1 -1
  166. package/dist/{client-CCyWJqAI.d.ts → client-Hz7SsBXs.d.ts} +1 -1
  167. package/dist/{client-core-BpYiYEfu.d.ts → client-core-D3Ad7Flt.d.ts} +554 -504
  168. package/dist/{client-core-D8eCZz3O.d.mts → client-core-Db_e63Hb.d.mts} +554 -504
  169. package/dist/{compiler-manifest-EBWEUj0b.d.ts → compiler-manifest-BqwVrOri.d.mts} +38 -18
  170. package/dist/{compiler-manifest-EBWEUj0b.d.mts → compiler-manifest-BqwVrOri.d.ts} +38 -18
  171. package/dist/{errors-CParKUQR.d.mts → errors-BU8FB99X.d.mts} +1 -1
  172. package/dist/{errors-Qt0OTA7_.d.ts → errors-DfVN_FUG.d.ts} +1 -1
  173. package/dist/{index-CoqDkIw0.d.ts → index-BGnvtYGc.d.ts} +6 -1
  174. package/dist/{index-BMUVCNp7.d.mts → index-DjZgwpGw.d.mts} +6 -1
  175. package/dist/index.d.mts +28 -8
  176. package/dist/index.d.ts +28 -8
  177. package/dist/index.js +64 -39
  178. package/dist/index.mjs +32 -7
  179. package/dist/install-integrity.json +133 -128
  180. package/dist/plays/bundle-play-file.d.mts +3 -3
  181. package/dist/plays/bundle-play-file.d.ts +3 -3
  182. package/dist/plays/bundle-play-file.mjs +620 -124
  183. package/dist/plays/play-description.d.mts +3 -3
  184. package/dist/plays/play-description.d.ts +3 -3
  185. package/dist/plays/run-request.d.mts +2 -2
  186. package/dist/plays/run-request.d.ts +2 -2
  187. package/dist/release.d.mts +1 -1
  188. package/dist/release.d.ts +1 -1
  189. package/dist/release.js +2 -2
  190. package/dist/release.mjs +1 -1
  191. package/dist/server.d.mts +4 -4
  192. package/dist/server.d.ts +4 -4
  193. package/dist/server.js +6 -6
  194. package/dist/server.mjs +4 -4
  195. package/package.json +1 -1
  196. package/dist/cli/auth-W32GMYND.js +0 -43
  197. package/dist/cli/concurrent-runs-help-6QT7ZR4W.js +0 -21
  198. package/dist/cli/describe-VLU2LUDJ.js +0 -50
  199. package/dist/cli/git-E6W44F5M.js +0 -25
  200. package/dist/cli/search-UUVFXZRA.js +0 -32
  201. package/dist/cli/sessions-K3PD73Q2.js +0 -22
  202. package/dist/cli/skills-QNE2EYT3.js +0 -36
  203. package/dist/cli/tools-3RLI4HGF.js +0 -57
  204. package/dist/cli/update-UT6KIW2W.js +0 -34
@@ -16,10 +16,10 @@ import {
16
16
  playRuntimeNames,
17
17
  validateScriptPlay,
18
18
  wrapScriptPlay
19
- } from "../cli/chunk-2HSZCQMT.mjs";
19
+ } from "../cli/chunk-WYT3H6JD.mjs";
20
20
  import {
21
21
  resolveExecutionProfile
22
- } from "../cli/chunk-Z7SXGOIQ.mjs";
22
+ } from "../cli/chunk-MF7PCM6C.mjs";
23
23
  import {
24
24
  validatePlaySourceFilesHaveNoInlineSecrets
25
25
  } from "../cli/chunk-H7HIDGZ7.mjs";
@@ -34,7 +34,7 @@ import {
34
34
  UnsupportedToolResponseContractError,
35
35
  normalizeToolResponseContract,
36
36
  normalizeToolResponseReceiptRevision
37
- } from "../cli/chunk-HXIR3VQL.mjs";
37
+ } from "../cli/chunk-FZHMNK6F.mjs";
38
38
  import {
39
39
  PLAY_SANDBOX_SIZE_INPUTS,
40
40
  SUPPORTED_PLAY_SANDBOX_SIZES
@@ -2035,7 +2035,14 @@ var FLOW_START = /^\s*(?:flowchart|graph)\s+(LR|RL|TB|TD|BT)\s*$/i;
2035
2035
  var MERMAID_NODE = /^\s*\/\/\s*@mermaid-node\s+([A-Za-z][\w-]*)(?:\s+(.*))?$/;
2036
2036
  var MERMAID_NODE_HINT = /@mermaid-node/;
2037
2037
  var ATTRIBUTE = /([A-Za-z][\w-]*)\s*:\s*"([^"\n]*)"/y;
2038
- var MERMAID_NODE_ATTRIBUTES = ["label", "type", "in", "out", "arm"];
2038
+ var MERMAID_NODE_ATTRIBUTES = [
2039
+ "label",
2040
+ "type",
2041
+ "in",
2042
+ "out",
2043
+ "arm",
2044
+ "show"
2045
+ ];
2039
2046
  var MERMAID_NODE_ID = /^[A-Za-z][\w-]*/;
2040
2047
  var SKETCH_CLASS = /^\s*class\s+([A-Za-z][\w-]*(?:\s*,\s*[A-Za-z][\w-]*)*)\s+sketch\s*;?\s*$/;
2041
2048
  var MERMAID_NODE_SHAPES = [
@@ -2279,15 +2286,47 @@ function splitBlockExportHeader(body) {
2279
2286
  function blockLabel(block) {
2280
2287
  return block.authoredExportName ? `@mermaid ${block.authoredExportName}` : "@mermaid";
2281
2288
  }
2282
- function parseDocflowBlockGraph(mermaidSource, errors) {
2289
+ function docflowBlockLineLocator(sourceCode, blockStart, blockText) {
2290
+ const firstLine = sourceCode.slice(0, blockStart).split(/\r?\n/).length;
2291
+ const rawLines = blockText.split(/\r?\n/).map(
2292
+ (line) => line.replace(/^\s*\/\*\*/, "").replace(/\*\/\s*$/, "").replace(/^\s*\* ?/, "").trim()
2293
+ );
2294
+ let cursor = 0;
2295
+ return (diagramLine) => {
2296
+ const wanted = diagramLine.trim();
2297
+ if (!wanted) return null;
2298
+ for (let index = cursor; index < rawLines.length; index += 1) {
2299
+ const raw = rawLines[index].replace(/^@mermaid\b\s*/, "");
2300
+ if (raw === wanted || raw.endsWith(` ${wanted}`)) {
2301
+ cursor = index + 1;
2302
+ return firstLine + index;
2303
+ }
2304
+ }
2305
+ return null;
2306
+ };
2307
+ }
2308
+ function locateDocflowErrors(errors, from, line) {
2309
+ if (line === null) return;
2310
+ for (let index = from; index < errors.length; index += 1) {
2311
+ errors[index] = `${errors[index]} (line ${line})`;
2312
+ }
2313
+ }
2314
+ function parseDocflowBlockGraph(mermaidSource, errors, locate = () => null) {
2283
2315
  const docLines = mermaidSource.split(/\r?\n/).filter((line) => line.trim() && !line.trim().startsWith("%%"));
2284
2316
  const direction = FLOW_START.exec(docLines[0] ?? "")?.[1]?.toUpperCase();
2285
2317
  if (!direction) {
2318
+ const firstErrorAt = errors.length;
2286
2319
  errors.push(
2287
- "Docflow must start with `flowchart` or `graph` and direction `LR`, `RL`, `TB`, `TD`, or `BT`."
2320
+ docLines[0] ? `Docflow must start with \`flowchart\` or \`graph\` and direction \`LR\`, \`RL\`, \`TB\`, \`TD\`, or \`BT\`; found: ${docLines[0].trim()}` : "Docflow must start with `flowchart` or `graph` and direction `LR`, `RL`, `TB`, `TD`, or `BT`."
2321
+ );
2322
+ locateDocflowErrors(
2323
+ errors,
2324
+ firstErrorAt,
2325
+ docLines[0] ? locate(docLines[0]) : null
2288
2326
  );
2289
2327
  return null;
2290
2328
  }
2329
+ locate(docLines[0]);
2291
2330
  const nodes = /* @__PURE__ */ new Map();
2292
2331
  const edges = [];
2293
2332
  const subgraphs = /* @__PURE__ */ new Map();
@@ -2343,83 +2382,97 @@ function parseDocflowBlockGraph(mermaidSource, errors) {
2343
2382
  }
2344
2383
  return sawDeclaration;
2345
2384
  };
2385
+ const openedAt = /* @__PURE__ */ new Map();
2346
2386
  for (const line of docLines.slice(1)) {
2347
- const opened = SUBGRAPH_OPEN.exec(line);
2348
- if (opened) {
2349
- const id = opened[1];
2350
- const rawLabel = opened[2]?.trim() ?? "";
2351
- const label = rawLabel.length >= 2 && (rawLabel.startsWith('"') && rawLabel.endsWith('"') || rawLabel.startsWith("'") && rawLabel.endsWith("'")) ? rawLabel.slice(1, -1) : rawLabel;
2352
- const parent = subgraphStack[subgraphStack.length - 1];
2353
- const subgraph = {
2354
- id,
2355
- label: label || id,
2356
- memberIds: [],
2357
- ...parent ? { parentId: parent.id } : {}
2358
- };
2359
- subgraphs.set(id, subgraph);
2360
- subgraphStack.push(subgraph);
2361
- continue;
2362
- }
2363
- if (SUBGRAPH_END.test(line)) {
2364
- if (subgraphStack.length === 0) {
2365
- errors.push(
2366
- "Docflow has an `end` with no open `subgraph` above it. Every `end` closes exactly one `subgraph`."
2367
- );
2387
+ const lineErrorsFrom = errors.length;
2388
+ const fileLine = locate(line);
2389
+ try {
2390
+ const opened = SUBGRAPH_OPEN.exec(line);
2391
+ if (opened) {
2392
+ const id = opened[1];
2393
+ const rawLabel = opened[2]?.trim() ?? "";
2394
+ const label = rawLabel.length >= 2 && (rawLabel.startsWith('"') && rawLabel.endsWith('"') || rawLabel.startsWith("'") && rawLabel.endsWith("'")) ? rawLabel.slice(1, -1) : rawLabel;
2395
+ const parent = subgraphStack[subgraphStack.length - 1];
2396
+ const subgraph = {
2397
+ id,
2398
+ label: label || id,
2399
+ memberIds: [],
2400
+ ...parent ? { parentId: parent.id } : {}
2401
+ };
2402
+ subgraphs.set(id, subgraph);
2403
+ subgraphStack.push(subgraph);
2404
+ openedAt.set(subgraph, fileLine);
2405
+ continue;
2368
2406
  }
2369
- subgraphStack.pop();
2370
- continue;
2371
- }
2372
- let declaredOnThisLine = false;
2373
- const isDirective = /^\s*(?:direction|classDef|class|style|linkStyle|click)\b/i.test(line);
2374
- if (isDirective) {
2375
- const sketch = SKETCH_CLASS.exec(line);
2376
- if (sketch) {
2377
- for (const id of sketch[1].split(",")) {
2378
- const trimmed = id.trim();
2379
- if (trimmed) sketchIds.add(trimmed);
2407
+ if (SUBGRAPH_END.test(line)) {
2408
+ if (subgraphStack.length === 0) {
2409
+ errors.push(
2410
+ "Docflow has an `end` with no open `subgraph` above it. Every `end` closes exactly one `subgraph`."
2411
+ );
2380
2412
  }
2381
- } else {
2382
- ignoredDirectives.push(line.trim());
2413
+ subgraphStack.pop();
2414
+ continue;
2383
2415
  }
2384
- }
2385
- if (!isDirective) {
2386
- declaredOnThisLine = addNodes(line, line);
2387
- }
2388
- const chain = parseEdgeChain(line);
2389
- if (!chain) {
2390
- if (!isDirective && !declaredOnThisLine) {
2391
- errors.push(
2392
- `Docflow line is not an edge, a node declaration, or a directive this parser understands: ${line.trim()}`
2393
- );
2416
+ let declaredOnThisLine = false;
2417
+ const isDirective = /^\s*(?:direction|classDef|class|style|linkStyle|click)\b/i.test(line);
2418
+ if (isDirective) {
2419
+ const sketch = SKETCH_CLASS.exec(line);
2420
+ if (sketch) {
2421
+ for (const id of sketch[1].split(",")) {
2422
+ const trimmed = id.trim();
2423
+ if (trimmed) sketchIds.add(trimmed);
2424
+ }
2425
+ } else {
2426
+ ignoredDirectives.push(line.trim());
2427
+ }
2394
2428
  }
2395
- continue;
2396
- }
2397
- addNodes(line, line);
2398
- for (const node of chain.nodes) {
2399
- if (subgraphIds.has(node.id)) continue;
2400
- const existing = nodes.get(node.id);
2401
- if (!existing) {
2402
- nodes.set(node.id, node);
2403
- subgraphStack[subgraphStack.length - 1]?.memberIds.push(node.id);
2404
- } else if (existing.label === existing.id && node.label !== node.id) {
2405
- existing.label = node.label;
2406
- existing.kind = node.kind;
2429
+ if (!isDirective) {
2430
+ declaredOnThisLine = addNodes(line, line);
2407
2431
  }
2408
- }
2409
- for (let index = 0; index < chain.nodes.length - 1; index += 1) {
2410
- edges.push({
2411
- from: chain.nodes[index].id,
2412
- to: chain.nodes[index + 1].id,
2413
- ...chain.labels[index] ? { label: chain.labels[index] } : {}
2414
- });
2432
+ const chain = parseEdgeChain(line);
2433
+ if (!chain) {
2434
+ if (!isDirective && !declaredOnThisLine) {
2435
+ errors.push(
2436
+ `Docflow line is not an edge, a node declaration, or a directive this parser understands: ${line.trim()}`
2437
+ );
2438
+ }
2439
+ continue;
2440
+ }
2441
+ addNodes(line, line);
2442
+ for (const node of chain.nodes) {
2443
+ if (subgraphIds.has(node.id)) continue;
2444
+ const existing = nodes.get(node.id);
2445
+ if (!existing) {
2446
+ nodes.set(node.id, node);
2447
+ subgraphStack[subgraphStack.length - 1]?.memberIds.push(node.id);
2448
+ } else if (existing.label === existing.id && node.label !== node.id) {
2449
+ existing.label = node.label;
2450
+ existing.kind = node.kind;
2451
+ }
2452
+ }
2453
+ for (let index = 0; index < chain.nodes.length - 1; index += 1) {
2454
+ edges.push({
2455
+ from: chain.nodes[index].id,
2456
+ to: chain.nodes[index + 1].id,
2457
+ ...chain.labels[index] ? { label: chain.labels[index] } : {}
2458
+ });
2459
+ }
2460
+ } finally {
2461
+ locateDocflowErrors(errors, lineErrorsFrom, fileLine);
2415
2462
  }
2416
2463
  }
2417
2464
  if (subgraphStack.length > 0) {
2465
+ const unclosedFrom = errors.length;
2418
2466
  errors.push(
2419
2467
  `Docflow subgraph${subgraphStack.length === 1 ? "" : "s"} ${subgraphStack.map((subgraph) => `"${subgraph.id}"`).join(
2420
2468
  ", "
2421
2469
  )} ${subgraphStack.length === 1 ? "is" : "are"} never closed with \`end\`. Everything below an unclosed subgraph is silently drawn inside it.`
2422
2470
  );
2471
+ locateDocflowErrors(
2472
+ errors,
2473
+ unclosedFrom,
2474
+ openedAt.get(subgraphStack[0]) ?? null
2475
+ );
2423
2476
  }
2424
2477
  for (const node of nodes.values()) {
2425
2478
  if (declaredIds.has(node.id) || subgraphIds.has(node.id)) continue;
@@ -2448,9 +2501,29 @@ function materializeDocflow(block) {
2448
2501
  syntax: block.syntax,
2449
2502
  mermaidSource: block.mermaidSource,
2450
2503
  ...block.subgraphs.size ? { subgraphs: [...block.subgraphs.values()] } : {},
2451
- ...block.ignoredDirectives.length ? { ignoredDirectives: block.ignoredDirectives } : {}
2504
+ ...block.ignoredDirectives.length ? { ignoredDirectives: block.ignoredDirectives } : {},
2505
+ ...block.inputShow?.length ? { inputShow: block.inputShow } : {}
2452
2506
  };
2453
2507
  }
2508
+ var MERMAID_INPUT_SHOW = /^\s*%%\s*@input\b(.*)$/;
2509
+ function parseBlockInputShow(diagram, errors) {
2510
+ const declarations = diagram.split(/\r?\n/).map((line) => MERMAID_INPUT_SHOW.exec(line)?.[1]).filter((rest) => rest !== void 0);
2511
+ if (declarations.length === 0) return void 0;
2512
+ if (declarations.length > 1) {
2513
+ errors.push(
2514
+ "Docflow `%% @input` appears more than once in one diagram. Declare the input's fields once."
2515
+ );
2516
+ return void 0;
2517
+ }
2518
+ const match = /^\s+show:"([^"]*)"\s*$/.exec(declarations[0]);
2519
+ if (!match) {
2520
+ errors.push(
2521
+ 'Docflow `%% @input` takes one attribute: show:"field,nested.field", the run input fields a reader sees first.'
2522
+ );
2523
+ return void 0;
2524
+ }
2525
+ return parseContractPaths(match[1], "show", "@input", 0, errors);
2526
+ }
2454
2527
  function parsePlayDocflowFile(sourceCode, moduleSources) {
2455
2528
  const errors = [];
2456
2529
  const rawBlocks = [];
@@ -2459,9 +2532,14 @@ function parsePlayDocflowFile(sourceCode, moduleSources) {
2459
2532
  const cleanedBody = cleanBlockBody(match[1]);
2460
2533
  const mermaid = /^@mermaid(?:[ \t]+|\r?\n|$)([\s\S]*)$/.exec(cleanedBody);
2461
2534
  if (!mermaid) continue;
2462
- rawBlocks.push({ syntax: "mermaid", body: mermaid[1].trim() });
2535
+ rawBlocks.push({
2536
+ syntax: "mermaid",
2537
+ body: mermaid[1].trim(),
2538
+ locate: docflowBlockLineLocator(sourceCode, match.index, match[0])
2539
+ });
2463
2540
  }
2464
- if (rawBlocks.length === 0) return { blocks: [], bindings: [], errors };
2541
+ if (rawBlocks.length === 0)
2542
+ return { blocks: [], bindings: [], errors, unreadBlocks: [] };
2465
2543
  const rejectedNodeIds = /* @__PURE__ */ new Set();
2466
2544
  const annotationSources = [{ sourceCode }];
2467
2545
  for (const [sourcePath, moduleCode] of moduleSources ?? []) {
@@ -2474,12 +2552,22 @@ function parsePlayDocflowFile(sourceCode, moduleSources) {
2474
2552
  rejectedNodeIds
2475
2553
  );
2476
2554
  const parsedBlocks = [];
2555
+ const unreadBlocks = [];
2477
2556
  for (const raw of rawBlocks) {
2478
2557
  const { exportName, diagram } = splitBlockExportHeader(raw.body);
2479
- const graph = parseDocflowBlockGraph(diagram, errors);
2480
- if (!graph) continue;
2558
+ const blockErrorsFrom = errors.length;
2559
+ const graph = parseDocflowBlockGraph(diagram, errors, raw.locate);
2560
+ const inputShow = graph ? parseBlockInputShow(diagram, errors) : void 0;
2561
+ if (!graph || errors.length > blockErrorsFrom) {
2562
+ unreadBlocks.push({
2563
+ authoredExportName: exportName,
2564
+ reason: errors[blockErrorsFrom] ?? "the diagram did not parse"
2565
+ });
2566
+ continue;
2567
+ }
2481
2568
  parsedBlocks.push({
2482
2569
  ...graph,
2570
+ ...inputShow?.length ? { inputShow } : {},
2483
2571
  authoredExportName: exportName,
2484
2572
  exportName: null,
2485
2573
  syntax: raw.syntax,
@@ -2493,7 +2581,8 @@ function parsePlayDocflowFile(sourceCode, moduleSources) {
2493
2581
  parsedBlocks,
2494
2582
  bindings,
2495
2583
  errors,
2496
- rejectedNodeIds
2584
+ rejectedNodeIds,
2585
+ unreadBlocks.length > 0
2497
2586
  );
2498
2587
  return {
2499
2588
  blocks: parsedBlocks.filter((block) => block.exportName !== null).map((block) => ({
@@ -2501,7 +2590,8 @@ function parsePlayDocflowFile(sourceCode, moduleSources) {
2501
2590
  docflow: materializeDocflow(block)
2502
2591
  })),
2503
2592
  bindings,
2504
- errors
2593
+ errors,
2594
+ unreadBlocks
2505
2595
  };
2506
2596
  }
2507
2597
  function resolveBlockExports(sourceCode, blocks, errors) {
@@ -2641,12 +2731,13 @@ function projectRecordedArms(block, errors) {
2641
2731
  edge.arm = binding.arm;
2642
2732
  }
2643
2733
  }
2644
- function attachBindingsToBlocks(sourceCode, blocks, bindings, errors, rejectedNodeIds) {
2734
+ function attachBindingsToBlocks(sourceCode, blocks, bindings, errors, rejectedNodeIds, someBlockUnread = false) {
2645
2735
  const lineStarts = sourceLineStartsForDocflow(sourceCode);
2646
2736
  const exportRanges = playExportSourceRanges(sourceCode);
2647
2737
  for (const binding of bindings) {
2648
2738
  let owners = blocks.filter((block) => block.nodes.has(binding.nodeId));
2649
- if (owners.length === 0 && binding.sourcePath) continue;
2739
+ if (owners.length === 0 && (binding.sourcePath || someBlockUnread))
2740
+ continue;
2650
2741
  if (owners.length === 0) {
2651
2742
  errors.push(
2652
2743
  `Docflow annotation "${binding.nodeId}" does not name a graph node.`
@@ -2680,15 +2771,16 @@ function attachBindingsToBlocks(sourceCode, blocks, bindings, errors, rejectedNo
2680
2771
  owner.bindings.push(binding);
2681
2772
  }
2682
2773
  for (const block of blocks) {
2683
- for (const binding of block.bindings) {
2774
+ for (const binding of [...block.bindings]) {
2684
2775
  const node = block.nodes.get(binding.nodeId);
2685
- if (binding.label) node.label = binding.label;
2686
2776
  if (block.sketchIds.has(binding.nodeId)) {
2687
2777
  errors.push(
2688
2778
  `Docflow box "${binding.nodeId}" is declared \`class ${binding.nodeId} sketch\` and also bound by \`// @mermaid-node ${binding.nodeId}\` on line ${binding.line}. It is one or the other: drop it from the class line, or drop the annotation.`
2689
2779
  );
2780
+ block.bindings.splice(block.bindings.indexOf(binding), 1);
2690
2781
  continue;
2691
2782
  }
2783
+ if (binding.label) node.label = binding.label;
2692
2784
  if (binding.kind) node.kind = binding.kind;
2693
2785
  }
2694
2786
  projectRecordedArms(block, errors);
@@ -2697,7 +2789,7 @@ function attachBindingsToBlocks(sourceCode, blocks, bindings, errors, rejectedNo
2697
2789
  if (node.sketch || node.kind === "conceptual" || bound.has(node.id) || rejectedNodeIds.has(node.id))
2698
2790
  continue;
2699
2791
  errors.push(
2700
- `Docflow box "${node.id}" in \`${blockLabel(block)}\` points at nothing, so the canvas can only draw it and say nothing about it. Either put \`// @mermaid-node ${node.id}\` above the statement it runs, or \u2014 if this play has no such statement, because the work happens in another module or inside a loop \u2014 add it to a \`class ${node.id} sketch\` line in the block to declare it a sketch.`
2792
+ `Docflow box "${node.id}" in \`${blockLabel(block)}\` points at nothing, so the canvas can only draw it and say nothing about it. Put \`// @mermaid-node ${node.id}\` above the statement it runs, in this file or a module it imports. Only a box no statement runs, such as the event that starts the play, belongs on a \`class ${node.id} sketch\` line.`
2701
2793
  );
2702
2794
  }
2703
2795
  }
@@ -2777,7 +2869,14 @@ function parseDocflowBindingsInSource(source, errors, rejectedNodeIds) {
2777
2869
  index + 1,
2778
2870
  errors
2779
2871
  );
2780
- if (attributes.in !== void 0 && !inputs || attributes.out !== void 0 && !outputs) {
2872
+ const show = parseContractPaths(
2873
+ attributes.show,
2874
+ "show",
2875
+ id,
2876
+ index + 1,
2877
+ errors
2878
+ );
2879
+ if (attributes.in !== void 0 && !inputs || attributes.out !== void 0 && !outputs || attributes.show !== void 0 && !show) {
2781
2880
  continue;
2782
2881
  }
2783
2882
  const inferred = inputs || outputs ? {
@@ -2796,6 +2895,7 @@ function parseDocflowBindingsInSource(source, errors, rejectedNodeIds) {
2796
2895
  // explicit `undefined` key survives `JSON.stringify` round-trips in some
2797
2896
  // callers and would reintroduce the hash drift this omission avoids.
2798
2897
  ...arm ? { arm } : {},
2898
+ ...show?.length ? { show } : {},
2799
2899
  ...inferred
2800
2900
  });
2801
2901
  }
@@ -4246,7 +4346,7 @@ function docflowObservationTarget(statement) {
4246
4346
  function docflowObservedExpression(input) {
4247
4347
  const body = input.throws ? `{throw (${input.expression})}` : `(${input.expression})`;
4248
4348
  const callback = input.awaitsResult ? `async()=>${body}` : `()=>${body}`;
4249
- const observation = `((runtimeContext,inputCaptures,execute)=>typeof runtimeContext.__deeplineObserveDocflowNode==="function"?runtimeContext.__deeplineObserveDocflowNode(${JSON.stringify(input.nodeId)},inputCaptures,${JSON.stringify(input.outputs)},execute):execute())(${input.contextName},${docflowInputCaptureSource(input.inputs)},${callback})`;
4349
+ const observation = `((runtimeContext,inputCaptures,execute)=>{let state=0,value,error;const once=()=>{if(state===0){state=1;try{value=execute();state=2}catch(thrown){error=thrown;state=3}}if(state===3)throw error;return value};try{if(runtimeContext!=null&&typeof runtimeContext.__deeplineObserveDocflowNode==="function")runtimeContext.__deeplineObserveDocflowNode(${JSON.stringify(input.nodeId)},inputCaptures,${JSON.stringify(input.outputs)},once)}catch(ignored){}return once()})(${input.contextName},${docflowInputCaptureSource(input.inputs)},${callback})`;
4250
4350
  return input.awaitsResult ? `(await ${observation})` : observation;
4251
4351
  }
4252
4352
  function expressionContainsTopLevelAwait(expression) {
@@ -4264,53 +4364,321 @@ function expressionContainsTopLevelAwait(expression) {
4264
4364
  }
4265
4365
  return false;
4266
4366
  }
4267
- function instrumentPlayDocflowRuntimeHits(sourceCode) {
4268
- const parsed = parsePlayDocflowFile(sourceCode);
4269
- if (parsed.blocks.length === 0 || parsed.errors.length > 0) return sourceCode;
4270
- const ast = parsePlaySourceAst(sourceCode);
4271
- if (!ast) return sourceCode;
4367
+ var DOCFLOW_STORE_CONTEXT_READER = "__deeplineDocflowRunContext";
4368
+ var DOCFLOW_STORE_CONTEXT_BINDER = "__deeplineDocflowBindRunContext";
4369
+ var DOCFLOW_SDK_NAMESPACE = "__deeplineDocflowSdk";
4370
+ function docflowRunContextPrelude(ast, sourceCode) {
4371
+ const isModule = astArray(ast.body).some(
4372
+ (statement) => statement.type === "ImportDeclaration" || statement.type === "ExportNamedDeclaration" || statement.type === "ExportDefaultDeclaration" || statement.type === "ExportAllDeclaration"
4373
+ );
4374
+ const sdk = DOCFLOW_SDK_NAMESPACE;
4375
+ const binding = isModule ? `import * as ${sdk} from 'deepline';` : `var ${sdk}=require('deepline');`;
4376
+ const value = `${binding}function ${DOCFLOW_STORE_CONTEXT_READER}(){try{return (typeof ${sdk}.__deeplineCurrentDocflowContext==="function"?${sdk}.__deeplineCurrentDocflowContext():null)??{}}catch(ignored){return {}}}function ${DOCFLOW_STORE_CONTEXT_BINDER}(context,body){let entered=false;const run=()=>{entered=true;return body()};try{if(typeof ${sdk}.__deeplineRunWithDocflowContext==="function")return ${sdk}.__deeplineRunWithDocflowContext(context,run)}catch(failure){if(entered)throw failure}return entered?void 0:body()} `;
4377
+ const at = docflowPreludeOffset(ast, sourceCode);
4378
+ return { start: at, end: at, value };
4379
+ }
4380
+ function docflowPreludeOffset(ast, sourceCode) {
4381
+ let at = sourceCode.startsWith("#!") ? sourceCode.indexOf("\n") + 1 : 0;
4382
+ for (const statement of astArray(ast.body)) {
4383
+ if (statement.type !== "ExpressionStatement" || typeof statement.directive !== "string") {
4384
+ break;
4385
+ }
4386
+ at = astNodeBounds(statement)?.end ?? at;
4387
+ }
4388
+ return at;
4389
+ }
4390
+ function docflowPatternNames(pattern, names) {
4391
+ const pending = [pattern];
4392
+ while (pending.length > 0) {
4393
+ const value = pending.pop();
4394
+ if (Array.isArray(value)) {
4395
+ pending.push(...value);
4396
+ continue;
4397
+ }
4398
+ if (!isAstNode(value)) continue;
4399
+ if (value.type === "Identifier" && typeof value.name === "string") {
4400
+ names.add(value.name);
4401
+ }
4402
+ for (const [key, child] of Object.entries(value)) {
4403
+ if (key === "typeAnnotation") continue;
4404
+ if (Array.isArray(child) || isAstNode(child)) pending.push(child);
4405
+ }
4406
+ }
4407
+ }
4408
+ var DOCFLOW_FUNCTION_NODE_TYPES = /* @__PURE__ */ new Set([
4409
+ "FunctionDeclaration",
4410
+ "FunctionExpression",
4411
+ "ArrowFunctionExpression"
4412
+ ]);
4413
+ function docflowRunBodyRedeclaresParameter(run) {
4414
+ const parameters = /* @__PURE__ */ new Set();
4415
+ docflowPatternNames(run.params, parameters);
4416
+ if (parameters.size === 0 || !isAstNode(run.body)) return false;
4417
+ const declared = /* @__PURE__ */ new Set();
4418
+ for (const statement of astArray(run.body.body)) {
4419
+ if (statement.type === "FunctionDeclaration" && isAstNode(statement.id)) {
4420
+ docflowPatternNames(statement.id, declared);
4421
+ }
4422
+ }
4423
+ const pending = [run.body];
4424
+ while (pending.length > 0) {
4425
+ const value = pending.pop();
4426
+ if (Array.isArray(value)) {
4427
+ pending.push(...value);
4428
+ continue;
4429
+ }
4430
+ if (!isAstNode(value)) continue;
4431
+ if (DOCFLOW_FUNCTION_NODE_TYPES.has(value.type)) continue;
4432
+ if (value.type === "VariableDeclaration" && value.kind === "var") {
4433
+ for (const declaration of astArray(value.declarations)) {
4434
+ docflowPatternNames(declaration.id, declared);
4435
+ }
4436
+ }
4437
+ for (const child of Object.values(value)) {
4438
+ if (Array.isArray(child) || isAstNode(child)) pending.push(child);
4439
+ }
4440
+ }
4441
+ return [...declared].some((name) => parameters.has(name));
4442
+ }
4443
+ function docflowRunContextBindings(ast, sourceCode, injectedContextAt, warnings) {
4444
+ const replacements = [];
4445
+ const pending = [ast];
4446
+ while (pending.length > 0) {
4447
+ const value = pending.pop();
4448
+ if (!isAstNode(value)) continue;
4449
+ for (const child of Object.values(value)) {
4450
+ if (Array.isArray(child)) pending.push(...child);
4451
+ else if (isAstNode(child)) pending.push(child);
4452
+ }
4453
+ const context = docflowContextFromCall(value, sourceCode);
4454
+ if (!context || context.kind === "unsupported" || context.kind === "store")
4455
+ continue;
4456
+ const run = definePlayRunFunction(value);
4457
+ if (!run || run.generator === true || !isAstNode(run.body)) continue;
4458
+ if (docflowRunBodyRedeclaresParameter(run)) {
4459
+ warnings.push(
4460
+ "Diagram boxes in imported helper modules are not tracked for this play: its run function redeclares a parameter with `var` or `function`, whose meaning would change if its body were wrapped. The play runs unchanged."
4461
+ );
4462
+ continue;
4463
+ }
4464
+ const body = astNodeBounds(run.body);
4465
+ if (!body) continue;
4466
+ if (context.kind === "inject") injectedContextAt.add(context.at);
4467
+ const contextName = context.kind === "inject" ? DOCFLOW_INJECTED_CONTEXT_NAME : context.name;
4468
+ const arrow = run.async === true ? "async()=>" : "()=>";
4469
+ if (run.body.type === "BlockStatement") {
4470
+ const directives = astArray(run.body.body).filter(
4471
+ (statement) => statement.type === "ExpressionStatement" && typeof statement.directive === "string"
4472
+ );
4473
+ if (directives.length > 0) continue;
4474
+ replacements.push(
4475
+ {
4476
+ start: body.start + 1,
4477
+ end: body.start + 1,
4478
+ value: `return ${DOCFLOW_STORE_CONTEXT_BINDER}(${contextName},${arrow}{`
4479
+ },
4480
+ { start: body.end - 1, end: body.end - 1, value: "});" }
4481
+ );
4482
+ } else {
4483
+ replacements.push(
4484
+ {
4485
+ start: body.start,
4486
+ end: body.start,
4487
+ value: `${DOCFLOW_STORE_CONTEXT_BINDER}(${contextName},${arrow}(`
4488
+ },
4489
+ { start: body.end, end: body.end, value: "))" }
4490
+ );
4491
+ }
4492
+ }
4493
+ return replacements;
4494
+ }
4495
+ function instrumentPlayDocflowRuntimeHitsWithReport(sourceCode, options = {}) {
4496
+ const warnings = [];
4497
+ const untouched = (reason) => {
4498
+ if (reason) warnings.push(reason);
4499
+ return { code: sourceCode, instrumented: false, warnings };
4500
+ };
4501
+ let code;
4502
+ try {
4503
+ code = instrumentPlayDocflowRuntimeHitsCore(sourceCode, options, warnings);
4504
+ } catch (error) {
4505
+ return untouched(
4506
+ `Diagram tracking was skipped for this file: instrumentation failed (${boundedInstrumentationReason(error)}). The play runs unchanged.`
4507
+ );
4508
+ }
4509
+ if (code === sourceCode) return untouched();
4510
+ if (!parsePlaySourceAstExact(code)) {
4511
+ return untouched(
4512
+ "Diagram tracking was skipped for this file: the instrumented source did not parse. The play runs unchanged."
4513
+ );
4514
+ }
4515
+ return { code, instrumented: true, warnings };
4516
+ }
4517
+ function boundedInstrumentationReason(error) {
4518
+ let message;
4519
+ try {
4520
+ message = error instanceof Error ? error.message : String(error);
4521
+ } catch {
4522
+ message = "unknown error";
4523
+ }
4524
+ return message.length > 300 ? `${message.slice(0, 300)}\u2026` : message;
4525
+ }
4526
+ function parsePlaySourceAstExact(sourceCode) {
4527
+ try {
4528
+ return TypeScriptParser.parse(sourceCode, {
4529
+ ecmaVersion: "latest",
4530
+ sourceType: "module",
4531
+ allowHashBang: true,
4532
+ // Script plays may end early with a top-level `return`.
4533
+ allowReturnOutsideFunction: true
4534
+ });
4535
+ } catch {
4536
+ return null;
4537
+ }
4538
+ }
4539
+ function docflowStatementListStarts(ast) {
4540
+ const starts = /* @__PURE__ */ new Set();
4541
+ const pending = [ast];
4542
+ while (pending.length > 0) {
4543
+ const value = pending.pop();
4544
+ if (!isAstNode(value)) continue;
4545
+ const list = value.type === "Program" || value.type === "BlockStatement" || value.type === "StaticBlock" ? value.body : value.type === "SwitchCase" ? value.consequent : null;
4546
+ for (const statement of astArray(list)) {
4547
+ if (statement.type === "ExpressionStatement" && typeof statement.directive === "string") {
4548
+ continue;
4549
+ }
4550
+ if (/^(Import|Export)/.test(statement.type)) continue;
4551
+ const bounds = astNodeBounds(statement);
4552
+ if (bounds) starts.add(bounds.start);
4553
+ }
4554
+ for (const child of Object.values(value)) {
4555
+ if (Array.isArray(child)) pending.push(...child);
4556
+ else if (isAstNode(child)) pending.push(child);
4557
+ }
4558
+ }
4559
+ return starts;
4560
+ }
4561
+ function docflowUnwrappableReason(statement, expression) {
4562
+ const pending = [expression];
4563
+ while (pending.length > 0) {
4564
+ const node = pending.pop();
4565
+ if (node.type === "YieldExpression") {
4566
+ return "the statement contains `yield`, which cannot move into an observation callback";
4567
+ }
4568
+ if (node !== expression && (node.type === "FunctionExpression" || node.type === "FunctionDeclaration" || node.type === "ArrowFunctionExpression")) {
4569
+ continue;
4570
+ }
4571
+ for (const child of Object.values(node)) {
4572
+ if (Array.isArray(child)) pending.push(...child.filter(isAstNode));
4573
+ else if (isAstNode(child)) pending.push(child);
4574
+ }
4575
+ }
4576
+ let inner = expression;
4577
+ while ((inner.type === "TSAsExpression" || inner.type === "TSSatisfiesExpression" || inner.type === "TSNonNullExpression" || inner.type === "TSTypeAssertion" || inner.type === "ParenthesizedExpression") && isAstNode(inner.expression)) {
4578
+ inner = inner.expression;
4579
+ }
4580
+ const anonymousCallable = inner.type === "ArrowFunctionExpression" || (inner.type === "FunctionExpression" || inner.type === "ClassExpression") && !isAstNode(inner.id);
4581
+ if (statement?.type === "VariableDeclaration" && anonymousCallable) {
4582
+ return "the declaration initializes an anonymous function or class, whose name comes from the declaration";
4583
+ }
4584
+ return null;
4585
+ }
4586
+ function instrumentPlayDocflowRuntimeHitsCore(sourceCode, options, warnings) {
4587
+ const helperBindings = options.helperBindings;
4588
+ let fileBindings;
4589
+ if (helperBindings !== void 0) {
4590
+ if (helperBindings.length === 0) return sourceCode;
4591
+ fileBindings = helperBindings;
4592
+ } else {
4593
+ const parsed = parsePlayDocflowFile(sourceCode, options.moduleSources);
4594
+ if (parsed.blocks.length === 0) return sourceCode;
4595
+ if (parsed.errors.length > 0) {
4596
+ warnings.push(
4597
+ `Diagram tracking skipped what did not resolve in this file's @mermaid diagram (${boundedInstrumentationReason(parsed.errors[0])}${parsed.errors.length > 1 ? `, and ${parsed.errors.length - 1} more` : ""}). The play runs unchanged.`
4598
+ );
4599
+ fileBindings = parsed.blocks.flatMap((block) => block.docflow.bindings).filter((binding) => !binding.sourcePath);
4600
+ if (fileBindings.length === 0) return sourceCode;
4601
+ } else {
4602
+ fileBindings = parsed.bindings.filter((binding) => !binding.sourcePath);
4603
+ }
4604
+ }
4605
+ const ast = parsePlaySourceAstExact(sourceCode);
4606
+ if (!ast) {
4607
+ warnings.push(
4608
+ "Diagram tracking was skipped for this file: its source could not be parsed exactly for instrumentation. The play runs unchanged."
4609
+ );
4610
+ return sourceCode;
4611
+ }
4272
4612
  const lineStarts = sourceLineStarts(sourceCode);
4273
4613
  const replacements = [];
4614
+ let statementListStarts = null;
4274
4615
  const targets = [];
4275
4616
  const injectedContextAt = /* @__PURE__ */ new Set();
4276
4617
  const parents = buildDocflowParentIndex(ast);
4277
4618
  const scriptContext = parseScriptPlay(sourceCode)?.contextName ?? null;
4278
- for (const binding of parsed.bindings) {
4619
+ let usesRunContextStore = false;
4620
+ for (const binding of fileBindings) {
4279
4621
  const resolution = resolveDocflowBinding(ast, binding, lineStarts, parents);
4280
- const context = findDocflowContext({
4622
+ const context = (helperBindings === void 0 ? findDocflowContext({
4281
4623
  ast,
4282
4624
  sourceCode,
4283
4625
  statement: resolution.statement,
4284
4626
  bindingLine: binding.line,
4285
4627
  lineStarts,
4286
4628
  parents
4287
- }) ?? (scriptContext ? { kind: "named", name: scriptContext } : null);
4288
- if (!context) continue;
4629
+ }) ?? (scriptContext ? { kind: "named", name: scriptContext } : null) : null) ?? { kind: "store" };
4289
4630
  if (context.kind === "unsupported") {
4290
- throw new Error(
4291
- `@mermaid-node ${binding.nodeId} (line ${binding.line}) cannot be observed at runtime: ${context.reason}.`
4631
+ warnings.push(
4632
+ `@mermaid-node ${binding.nodeId} (line ${binding.line}) cannot be observed at runtime: ${context.reason}. The box is drawn but not tracked.`
4292
4633
  );
4634
+ continue;
4293
4635
  }
4636
+ if (context.kind === "store") usesRunContextStore = true;
4294
4637
  if (context.kind === "inject") injectedContextAt.add(context.at);
4295
- const contextName = context.kind === "inject" ? `(${context.name}??{})` : context.name;
4638
+ const contextName = context.kind === "inject" ? `(${context.name}??{})` : context.kind === "store" ? `${DOCFLOW_STORE_CONTEXT_READER}()` : context.name;
4296
4639
  const target = docflowObservationTarget(resolution.statement);
4297
4640
  const observedRoot = docflowOutputRoot(binding);
4298
4641
  if (target && observedRoot && docflowExpressionWrapsStepBuilder(target.expression, observedRoot)) {
4299
4642
  continue;
4300
4643
  }
4301
4644
  if (target) {
4645
+ const unwrappable = docflowUnwrappableReason(
4646
+ resolution.statement,
4647
+ target.expression
4648
+ );
4649
+ if (unwrappable) {
4650
+ warnings.push(
4651
+ `@mermaid-node ${binding.nodeId} (line ${binding.line}) is not tracked: ${unwrappable}.`
4652
+ );
4653
+ continue;
4654
+ }
4302
4655
  targets.push({ ...target, contextName, binding });
4303
4656
  continue;
4304
4657
  }
4305
4658
  const lineStart = lineStarts[binding.line - 1];
4306
- if (lineStart !== void 0) {
4307
- const indentationLength = /^\s*/.exec(sourceCode.slice(lineStart))?.[0].length ?? 0;
4308
- replacements.push({
4309
- start: lineStart + indentationLength,
4310
- end: lineStart + indentationLength,
4311
- value: `await (typeof ${contextName}.__deeplineDocflowHit==="function"?${contextName}.__deeplineDocflowHit(${JSON.stringify(binding.nodeId)}):void 0); `
4312
- });
4659
+ const statementBounds = resolution.statement ? astNodeBounds(resolution.statement) : null;
4660
+ const indentationLength = lineStart === void 0 ? 0 : /^\s*/.exec(sourceCode.slice(lineStart))?.[0].length ?? 0;
4661
+ statementListStarts ??= docflowStatementListStarts(ast);
4662
+ const listStarts = statementListStarts;
4663
+ const at = [
4664
+ statementBounds?.start,
4665
+ lineStart === void 0 ? void 0 : lineStart + indentationLength
4666
+ ].find(
4667
+ (candidate) => candidate !== void 0 && listStarts.has(candidate)
4668
+ );
4669
+ if (at === void 0) {
4670
+ warnings.push(
4671
+ `@mermaid-node ${binding.nodeId} (line ${binding.line}) is not tracked: it binds no expression and does not start a statement.`
4672
+ );
4673
+ continue;
4313
4674
  }
4675
+ replacements.push({
4676
+ start: at,
4677
+ end: at,
4678
+ // `void` first: a statement opening with `(` would continue a previous
4679
+ // line written without a semicolon (`f()\n(…)` calls f's result).
4680
+ value: `void ((runtimeContext)=>{try{if(runtimeContext!=null&&typeof runtimeContext.__deeplineDocflowHit==="function"){const pending=runtimeContext.__deeplineDocflowHit(${JSON.stringify(binding.nodeId)});if(pending!=null&&typeof pending.then==="function")pending.then(null,()=>{})}}catch(ignored){}})(${contextName}); `
4681
+ });
4314
4682
  }
4315
4683
  targets.sort(
4316
4684
  (left, right) => left.start - right.start || right.end - left.end
@@ -4346,12 +4714,27 @@ function instrumentPlayDocflowRuntimeHits(sourceCode) {
4346
4714
  });
4347
4715
  innermost = false;
4348
4716
  }
4717
+ statementListStarts ??= docflowStatementListStarts(ast);
4349
4718
  replacements.push({
4350
4719
  start: group.start,
4351
4720
  end: group.end,
4352
- value: expression
4721
+ value: statementListStarts.has(group.start) ? `void ${expression}` : expression
4353
4722
  });
4354
4723
  }
4724
+ const bindRunContext = helperBindings === void 0 && !scriptContext && (usesRunContextStore || options.bindRunContext === true);
4725
+ if (bindRunContext) {
4726
+ replacements.push(
4727
+ ...docflowRunContextBindings(
4728
+ ast,
4729
+ sourceCode,
4730
+ injectedContextAt,
4731
+ warnings
4732
+ )
4733
+ );
4734
+ }
4735
+ if (usesRunContextStore || bindRunContext) {
4736
+ replacements.push(docflowRunContextPrelude(ast, sourceCode));
4737
+ }
4355
4738
  for (const at of injectedContextAt) {
4356
4739
  replacements.push({
4357
4740
  start: at,
@@ -4359,27 +4742,53 @@ function instrumentPlayDocflowRuntimeHits(sourceCode) {
4359
4742
  value: DOCFLOW_INJECTED_CONTEXT_NAME
4360
4743
  });
4361
4744
  }
4362
- return replacements.sort((left, right) => right.start - left.start).reduce(
4745
+ return replacements.sort((left, right) => right.start - left.start || right.end - left.end).reduce(
4363
4746
  (source, replacement) => `${source.slice(0, replacement.start)}${replacement.value}${source.slice(replacement.end)}`,
4364
4747
  sourceCode
4365
4748
  );
4366
4749
  }
4367
- function docflowRuntimeInstrumentationPlugin(analyzedSources, scriptEntry) {
4750
+ function docflowRuntimeInstrumentationPlugin(analyzedSources, entryFile, scriptEntry) {
4368
4751
  const customerSourceFiles = new Map(
4369
4752
  Object.entries(analyzedSources).filter(([path]) => extname(path).toLowerCase() !== ".json").map(([path, contents]) => [resolve(path), contents])
4370
4753
  );
4754
+ const entryPath = resolve(entryFile);
4755
+ const planWarnings = [];
4756
+ const plan = docflowHelperInstrumentationPlanFailOpen(
4757
+ entryPath,
4758
+ scriptEntry?.source ?? customerSourceFiles.get(entryPath) ?? null,
4759
+ customerSourceFiles,
4760
+ planWarnings
4761
+ );
4762
+ const entryOptions = {
4763
+ moduleSources: plan.moduleSources,
4764
+ bindRunContext: plan.helperBindings.size > 0
4765
+ };
4766
+ const asWarnings = (path, warnings) => warnings.map((text) => ({
4767
+ text: `${DOCFLOW_INSTRUMENTATION_WARNING_PREFIX}${text}`,
4768
+ location: { file: path }
4769
+ }));
4371
4770
  return {
4372
4771
  name: "deepline-docflow-runtime-instrumentation",
4373
4772
  setup(buildContext) {
4374
4773
  buildContext.onLoad({ filter: /./ }, (args) => {
4375
- if (scriptEntry && resolve(args.path) === resolve(scriptEntry.path)) {
4774
+ const path = resolve(args.path);
4775
+ if (scriptEntry && path === resolve(scriptEntry.path)) {
4776
+ const script = scriptEntryModule(
4777
+ scriptEntry.source,
4778
+ args.path,
4779
+ entryOptions
4780
+ );
4376
4781
  return {
4377
- contents: scriptEntryModule(scriptEntry.source, args.path),
4782
+ contents: script.contents,
4378
4783
  loader: sourceLoaderForPath(args.path),
4379
- resolveDir: dirname(args.path)
4784
+ resolveDir: dirname(args.path),
4785
+ warnings: asWarnings(args.path, [
4786
+ ...planWarnings,
4787
+ ...script.warnings
4788
+ ])
4380
4789
  };
4381
4790
  }
4382
- const contents = customerSourceFiles.get(resolve(args.path));
4791
+ const contents = customerSourceFiles.get(path);
4383
4792
  if (contents === void 0) return void 0;
4384
4793
  if (isTextImportFile(args.path)) {
4385
4794
  return {
@@ -4388,27 +4797,98 @@ function docflowRuntimeInstrumentationPlugin(analyzedSources, scriptEntry) {
4388
4797
  resolveDir: dirname(args.path)
4389
4798
  };
4390
4799
  }
4800
+ const helperBindings = plan.helperBindings.get(path);
4801
+ const report = instrumentPlayDocflowRuntimeHitsWithReport(
4802
+ contents,
4803
+ path === entryPath ? entryOptions : helperBindings ? { helperBindings } : {}
4804
+ );
4391
4805
  return {
4392
- contents: instrumentPlayDocflowRuntimeHits(contents),
4806
+ contents: report.code,
4393
4807
  loader: sourceLoaderForPath(args.path),
4394
- resolveDir: dirname(args.path)
4808
+ resolveDir: dirname(args.path),
4809
+ warnings: asWarnings(args.path, [
4810
+ ...path === entryPath ? planWarnings : [],
4811
+ ...report.warnings
4812
+ ])
4395
4813
  };
4396
4814
  });
4397
4815
  }
4398
4816
  };
4399
4817
  }
4400
- function scriptEntryModule(source, path) {
4401
- const instrumented = instrumentPlayDocflowRuntimeHits(source);
4402
- const script = parseScriptPlay(instrumented);
4403
- if (!script) {
4404
- throw new Error(
4405
- "Docflow instrumentation turned a script play into a non-script."
4818
+ var DOCFLOW_INSTRUMENTATION_WARNING_PREFIX = "[diagram tracking] ";
4819
+ function docflowHelperInstrumentationPlanFailOpen(entryPath, entrySource, sources, warnings) {
4820
+ try {
4821
+ return docflowHelperInstrumentationPlan(entryPath, entrySource, sources);
4822
+ } catch (error) {
4823
+ warnings.push(
4824
+ `Diagram tracking in imported helper modules was skipped: ${boundedInstrumentationReason(error)}.`
4406
4825
  );
4826
+ return {
4827
+ moduleSources: new Map(
4828
+ [...sources].filter(
4829
+ ([path]) => path !== entryPath && !isTextImportFile(path)
4830
+ )
4831
+ ),
4832
+ helperBindings: /* @__PURE__ */ new Map()
4833
+ };
4407
4834
  }
4408
- return wrapScriptPlay(instrumented, script, {
4409
- typed: /^tsx?$/.test(sourceLoaderForPath(path)),
4410
- authoredSource: source
4411
- });
4835
+ }
4836
+ function docflowHelperInstrumentationPlan(entryPath, entrySource, sources) {
4837
+ const moduleSources = new Map(
4838
+ [...sources].filter(
4839
+ ([path]) => path !== entryPath && !isTextImportFile(path)
4840
+ )
4841
+ );
4842
+ const helperBindings = /* @__PURE__ */ new Map();
4843
+ if (entrySource === null || moduleSources.size === 0) {
4844
+ return { moduleSources, helperBindings };
4845
+ }
4846
+ const parsed = parsePlayDocflowFile(entrySource, moduleSources);
4847
+ const drawn = new Set(
4848
+ parsed.blocks.flatMap(
4849
+ (block) => block.docflow.nodes.map((node) => node.id)
4850
+ )
4851
+ );
4852
+ const tracked = parsed.errors.length > 0 ? parsed.blocks.flatMap((block) => block.docflow.bindings) : parsed.bindings;
4853
+ for (const binding of tracked) {
4854
+ if (!binding.sourcePath || !drawn.has(binding.nodeId)) continue;
4855
+ const path = resolve(binding.sourcePath);
4856
+ helperBindings.set(path, [...helperBindings.get(path) ?? [], binding]);
4857
+ }
4858
+ return { moduleSources, helperBindings };
4859
+ }
4860
+ function scriptEntryModule(source, path, options = {}) {
4861
+ const typed = /^tsx?$/.test(sourceLoaderForPath(path));
4862
+ const report = instrumentPlayDocflowRuntimeHitsWithReport(source, options);
4863
+ if (report.instrumented) {
4864
+ try {
4865
+ const script2 = parseScriptPlay(report.code);
4866
+ if (script2) {
4867
+ return {
4868
+ contents: wrapScriptPlay(report.code, script2, {
4869
+ typed,
4870
+ authoredSource: source
4871
+ }),
4872
+ warnings: report.warnings
4873
+ };
4874
+ }
4875
+ } catch {
4876
+ }
4877
+ report.warnings.push(
4878
+ "Diagram tracking was skipped for this script play: the instrumented source is no longer a script play. The play runs unchanged."
4879
+ );
4880
+ }
4881
+ const script = parseScriptPlay(source);
4882
+ if (!script) {
4883
+ throw new Error("Script play entry could not be parsed as a script play.");
4884
+ }
4885
+ return {
4886
+ contents: wrapScriptPlay(source, script, {
4887
+ typed,
4888
+ authoredSource: source
4889
+ }),
4890
+ warnings: report.warnings
4891
+ };
4412
4892
  }
4413
4893
  function buildImportedPlayProxyModule(playName) {
4414
4894
  const serializedName = JSON.stringify(playName);
@@ -4806,6 +5286,7 @@ async function runEsbuildForCjsNode(entryFile, analyzedSources, entryScript, imp
4806
5286
  const playProxyPlugin = importedPlayProxyPlugin(importedPlayDependencies);
4807
5287
  const docflowPlugin = docflowRuntimeInstrumentationPlugin(
4808
5288
  analyzedSources,
5289
+ entryFile,
4809
5290
  entryScript === null ? null : { path: entryFile, source: entryScript }
4810
5291
  );
4811
5292
  const namedExportShim = exportName !== "default" ? `export { ${exportName} as default } from ${JSON.stringify(entryFile)};
@@ -4850,7 +5331,16 @@ async function runEsbuildForCjsNode(entryFile, analyzedSources, entryScript, imp
4850
5331
  return {
4851
5332
  bundledCode: codeFile.text,
4852
5333
  sourceMapText: mapFile.text,
4853
- outputExtension: "cjs"
5334
+ outputExtension: "cjs",
5335
+ docflowInstrumentationWarnings: [
5336
+ ...new Set(
5337
+ result.warnings.map((warning) => warning.text).filter(
5338
+ (text) => text.startsWith(DOCFLOW_INSTRUMENTATION_WARNING_PREFIX)
5339
+ ).map(
5340
+ (text) => text.slice(DOCFLOW_INSTRUMENTATION_WARNING_PREFIX.length)
5341
+ )
5342
+ )
5343
+ ]
4854
5344
  };
4855
5345
  }
4856
5346
  async function bundlePlayFile(filePath, options) {
@@ -5002,7 +5492,12 @@ preserved-compatibility:${JSON.stringify(preservedCompatibility)}`}` + // A scri
5002
5492
  errors: buildOutcome
5003
5493
  };
5004
5494
  }
5005
- const { bundledCode, sourceMapText, outputExtension } = buildOutcome;
5495
+ const {
5496
+ bundledCode,
5497
+ sourceMapText,
5498
+ outputExtension,
5499
+ docflowInstrumentationWarnings
5500
+ } = buildOutcome;
5006
5501
  const normalizedSourceMap = normalizeSourceMapForRuntime(
5007
5502
  sourceMapText,
5008
5503
  bundleRoot
@@ -5065,7 +5560,8 @@ preserved-compatibility:${JSON.stringify(preservedCompatibility)}`}` + // A scri
5065
5560
  sandboxRuntimeDeclaration: analysis.sandboxRuntimeDeclaration,
5066
5561
  packagedFiles: discoveredFiles.files,
5067
5562
  unresolvedFileReferences: discoveredFiles.unresolved,
5068
- importedPlayDependencies: analysis.importedPlayDependencies
5563
+ importedPlayDependencies: analysis.importedPlayDependencies,
5564
+ ...docflowInstrumentationWarnings.length > 0 ? { docflowInstrumentationWarnings } : {}
5069
5565
  };
5070
5566
  } catch (error) {
5071
5567
  if (error instanceof AggregateError) {