deepline 0.3.582 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +79 -36
  2. package/dist/bundling-sources/sdk/src/index.ts +2 -0
  3. package/dist/bundling-sources/sdk/src/release.ts +7 -3
  4. package/dist/bundling-sources/sdk/src/types.ts +37 -0
  5. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +22 -3
  6. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +94 -5
  7. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +66 -12
  8. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +10 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-topology.ts +6 -1
  10. package/dist/bundling-sources/shared_libs/play-runtime/deployment/runtime-tuple-recovery.ts +9 -3
  11. package/dist/bundling-sources/shared_libs/play-runtime/docflow-node-io.ts +86 -20
  12. package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +17 -6
  13. package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +22 -6
  14. package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +14 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +54 -0
  16. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/terminal/postgres-adapter.ts +2 -1
  17. package/dist/bundling-sources/shared_libs/play-runtime/row-failure-summary.ts +1 -0
  18. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +4 -1
  19. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +62 -6
  20. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +14 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-store-adapter.ts +197 -19
  22. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-writer.ts +25 -1
  23. package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +5 -0
  24. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +140 -1
  25. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-wake-policy.ts +419 -0
  26. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +47 -4
  27. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +24 -0
  28. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-scope.ts +1 -1
  29. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +36 -19
  30. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +380 -51
  31. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +21 -10
  32. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +32 -0
  33. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +6 -0
  34. package/dist/bundling-sources/shared_libs/plays/deploy/api-client.ts +3 -1
  35. package/dist/bundling-sources/shared_libs/plays/deploy/run-deployment.ts +34 -4
  36. package/dist/bundling-sources/shared_libs/plays/docflow-recording-lint.ts +512 -0
  37. package/dist/bundling-sources/shared_libs/plays/docflow-requirement.ts +346 -0
  38. package/dist/bundling-sources/shared_libs/plays/docflow-rule-codes.ts +38 -0
  39. package/dist/bundling-sources/shared_libs/plays/docflow-unreached-reason.ts +42 -2
  40. package/dist/bundling-sources/shared_libs/plays/docflow.ts +223 -32
  41. package/dist/bundling-sources/shared_libs/plays/play-check-compact.ts +14 -1
  42. package/dist/bundling-sources/shared_libs/plays/run-result.ts +35 -0
  43. package/dist/cli/{agents-UAXDG4FS.mjs → agents-AHXB7N7Y.mjs} +68 -4
  44. package/dist/cli/{agents-2L73CJHH.js → agents-KBZ7OUZS.js} +95 -31
  45. package/dist/cli/{auth-3B2QB4UH.mjs → auth-3CACO52T.mjs} +5 -5
  46. package/dist/cli/auth-UOHCO5K6.js +44 -0
  47. package/dist/cli/{billing-E7FO622G.js → billing-5KXPGKMO.js} +105 -105
  48. package/dist/cli/{billing-CPBRWG3M.mjs → billing-TSTK63NB.mjs} +9 -9
  49. package/dist/cli/{chunk-3DVWSTAI.mjs → chunk-2GWKBQJZ.mjs} +1 -1
  50. package/dist/cli/{chunk-PNQVB4UD.mjs → chunk-3DJMPID5.mjs} +11 -11
  51. package/dist/cli/{chunk-FBSPHBAF.js → chunk-3ET6NRXP.js} +7 -3
  52. package/dist/cli/{chunk-NZR5PBNP.mjs → chunk-3MWTAM3F.mjs} +3 -3
  53. package/dist/cli/{chunk-ROUNT4NX.mjs → chunk-4ANDW2OT.mjs} +1 -1
  54. package/dist/cli/{chunk-ZH23XGJO.js → chunk-4BSCSQ6I.js} +4 -4
  55. package/dist/cli/{chunk-7QX5PCHP.mjs → chunk-4UEXAMDU.mjs} +2 -2
  56. package/dist/cli/{chunk-3EOET5UB.js → chunk-5XGLDVSD.js} +100 -100
  57. package/dist/cli/{chunk-MRSYC74T.js → chunk-7XXJJVSI.js} +5 -5
  58. package/dist/cli/{chunk-NJGXYYHN.js → chunk-7ZCD7OPO.js} +5 -5
  59. package/dist/cli/{chunk-JF4DUC2F.mjs → chunk-AJJSKKH4.mjs} +2 -2
  60. package/dist/cli/{chunk-XYQMOXP4.mjs → chunk-BHF5UW34.mjs} +1 -1
  61. package/dist/cli/{chunk-POYADK77.js → chunk-BO2TXH5Y.js} +20 -20
  62. package/dist/cli/{chunk-RNZXMOA6.mjs → chunk-BUC2TNF2.mjs} +2 -2
  63. package/dist/cli/{chunk-EGH4JNJP.js → chunk-BUUAFSSN.js} +68 -50
  64. package/dist/cli/{chunk-GZBXN56A.js → chunk-C45E47KC.js} +23 -23
  65. package/dist/cli/{chunk-HP6A3JCX.js → chunk-D4R3AL4F.js} +5 -5
  66. package/dist/cli/{chunk-ABJZQHON.mjs → chunk-DAZRIAXW.mjs} +4 -4
  67. package/dist/cli/{chunk-SKKRESFB.js → chunk-DNOZQGJF.js} +3 -3
  68. package/dist/cli/{chunk-DPLYQITT.js → chunk-DUL6UQ2T.js} +2 -2
  69. package/dist/cli/{chunk-U2QQQNWW.mjs → chunk-ES3S6UXR.mjs} +2 -2
  70. package/dist/cli/{chunk-4TTEAUZV.mjs → chunk-FDAYUP3M.mjs} +3 -3
  71. package/dist/cli/{chunk-V54YQHPV.js → chunk-FEVUIT2U.js} +6 -6
  72. package/dist/cli/{chunk-KDITCSPN.mjs → chunk-FSPEUU3V.mjs} +68 -6
  73. package/dist/cli/{chunk-OUFOJTEJ.mjs → chunk-FZZMCVOS.mjs} +5 -5
  74. package/dist/cli/{chunk-ISN4F6AY.js → chunk-GHOB72U6.js} +13 -13
  75. package/dist/cli/{chunk-LHA45DNY.mjs → chunk-GLYWRTEL.mjs} +3 -3
  76. package/dist/cli/{chunk-LDMCTV2Z.mjs → chunk-HNTIGYRT.mjs} +1 -1
  77. package/dist/cli/{chunk-EB2YLLZJ.js → chunk-IGPHYKEJ.js} +41 -41
  78. package/dist/cli/{chunk-VA35T3AF.js → chunk-ISSYN3DJ.js} +20 -20
  79. package/dist/cli/{chunk-DSHIB2XQ.mjs → chunk-JKQPITEE.mjs} +54 -36
  80. package/dist/cli/{chunk-ZARGHLZZ.mjs → chunk-KMLACXI2.mjs} +7 -3
  81. package/dist/cli/{chunk-DI5MULNX.js → chunk-KQXACHYA.js} +26 -26
  82. package/dist/cli/{chunk-CPZL6Z7D.js → chunk-LW2GKYZW.js} +2 -2
  83. package/dist/cli/{chunk-G5YU6RJ4.mjs → chunk-O2KSPI2M.mjs} +2 -2
  84. package/dist/cli/{chunk-H3KVMALU.js → chunk-O6GT6JD7.js} +9 -9
  85. package/dist/cli/{chunk-4ZAWRCB6.mjs → chunk-OCXWUWUI.mjs} +5 -5
  86. package/dist/cli/{chunk-YPP436NM.js → chunk-QKRDAJ3T.js} +53 -53
  87. package/dist/cli/{chunk-KQEW3EAU.js → chunk-QQESWF6D.js} +16 -16
  88. package/dist/cli/{chunk-CYZSHD66.js → chunk-REX5SUYU.js} +2 -2
  89. package/dist/cli/{chunk-Z3IAEHID.js → chunk-RXIQWG2N.js} +48 -48
  90. package/dist/cli/{chunk-5436ZJPH.js → chunk-S33BN7GZ.js} +3 -3
  91. package/dist/cli/{chunk-JD7P73ZW.mjs → chunk-SGRJJLNV.mjs} +1 -1
  92. package/dist/cli/{chunk-2K6EIL2D.mjs → chunk-TCNYSNVU.mjs} +1 -1
  93. package/dist/cli/{chunk-I5J6HGVR.mjs → chunk-TFPMVSGK.mjs} +2 -2
  94. package/dist/cli/{chunk-6NEMTKTA.mjs → chunk-V73WDQEA.mjs} +5 -5
  95. package/dist/cli/{chunk-Y36SQMSN.js → chunk-VYERVFGB.js} +68 -6
  96. package/dist/cli/{chunk-SYWLWTWM.mjs → chunk-WBRSVML3.mjs} +4 -4
  97. package/dist/cli/{chunk-NVHICORD.mjs → chunk-WW52ANX4.mjs} +2 -2
  98. package/dist/cli/{chunk-3HIJNXRB.js → chunk-XZS35M3Y.js} +10 -10
  99. package/dist/cli/{chunk-ZL3O7F5J.js → chunk-YNYHYL5C.js} +15 -15
  100. package/dist/cli/{chunk-FWB3QR7W.mjs → chunk-ZHE5E2WJ.mjs} +1 -1
  101. package/dist/cli/{chunk-D7J33HTK.mjs → chunk-ZJ2H77VV.mjs} +5 -5
  102. package/dist/cli/{chunk-JUZIMW4S.js → chunk-ZX6UVPGZ.js} +7 -7
  103. package/dist/cli/command-docs.js +2 -2
  104. package/dist/cli/command-docs.mjs +1 -1
  105. package/dist/cli/concurrent-runs-help-H5SZUA5J.js +22 -0
  106. package/dist/cli/{concurrent-runs-help-UFNYQYU2.mjs → concurrent-runs-help-IYELSCHB.mjs} +6 -6
  107. package/dist/cli/{csv-QSDRGLQH.mjs → csv-ENEC3APZ.mjs} +4 -4
  108. package/dist/cli/{csv-ZI5LYFHF.js → csv-X6CP57R4.js} +13 -13
  109. package/dist/cli/{db-ZDL6Q53U.js → db-6HLRSE2M.js} +27 -27
  110. package/dist/cli/{db-WVWXNNMO.mjs → db-YGKRFK4T.mjs} +6 -6
  111. package/dist/cli/{describe-UUQBKUVL.mjs → describe-4SGQEX7K.mjs} +18 -18
  112. package/dist/cli/describe-Q2OYHDVZ.js +50 -0
  113. package/dist/cli/describe-core.d.mts +2 -2
  114. package/dist/cli/describe-core.d.ts +2 -2
  115. package/dist/cli/{executions-SCGHTWTC.js → executions-IC55YJ67.js} +8 -8
  116. package/dist/cli/{executions-QN3OYJKT.mjs → executions-PO2IOSZ7.mjs} +6 -6
  117. package/dist/cli/{feedback-7QPHLXGU.mjs → feedback-6BUD5F4I.mjs} +6 -6
  118. package/dist/cli/{feedback-6QQ7ONLW.js → feedback-BCGQLZ5T.js} +14 -14
  119. package/dist/cli/git-5X3MLBIP.js +26 -0
  120. package/dist/cli/{git-HFPJX573.mjs → git-IN4IBL2K.mjs} +5 -5
  121. package/dist/cli/index.js +148 -148
  122. package/dist/cli/index.mjs +47 -47
  123. package/dist/cli/{integrations-ND2HULSH.js → integrations-R2Z2MDO3.js} +29 -29
  124. package/dist/cli/{integrations-4SZ5O24P.mjs → integrations-ZMGB6NQA.mjs} +7 -7
  125. package/dist/cli/{legacy-noops-WUP3TBR2.mjs → legacy-noops-GIC5OZKP.mjs} +6 -6
  126. package/dist/cli/{legacy-noops-GQF6AYP5.js → legacy-noops-X4JPRPTJ.js} +9 -9
  127. package/dist/cli/{mcp-3GUFYGCQ.mjs → mcp-G4IRJIKK.mjs} +4 -4
  128. package/dist/cli/{mcp-L3YYVEU6.js → mcp-USZKTVL2.js} +24 -24
  129. package/dist/cli/{monitors-OFCVJSH5.mjs → monitors-SNFZPSCY.mjs} +7 -7
  130. package/dist/cli/{monitors-CVZZN5WG.js → monitors-T7LRP7OB.js} +100 -100
  131. package/dist/cli/{org-MQ5AUN7I.js → org-2L2ZZL2P.js} +121 -121
  132. package/dist/cli/{org-3DTAYA52.mjs → org-YTXLKW52.mjs} +6 -6
  133. package/dist/cli/{outcomes-42W24EXG.mjs → outcomes-CJWBIFTA.mjs} +6 -6
  134. package/dist/cli/{outcomes-MGDUYHUD.js → outcomes-O63F57JF.js} +14 -14
  135. package/dist/cli/{play-PD45RNYZ.mjs → play-6UWPUHC6.mjs} +331 -70
  136. package/dist/cli/{play-IMAD7QTV.js → play-T353SULJ.js} +930 -669
  137. package/dist/cli/{providers-DYKHG7NV.mjs → providers-LZABK2UW.mjs} +6 -6
  138. package/dist/cli/{providers-WONHPTRG.js → providers-XORJH2VW.js} +9 -9
  139. package/dist/cli/{quickstart-5QPGHLEX.mjs → quickstart-O4RF7J55.mjs} +4 -4
  140. package/dist/cli/{quickstart-6AAFULGC.js → quickstart-QBNUNPZR.js} +6 -6
  141. package/dist/cli/{run-WOW7QO3W.js → run-2CPMFC6W.js} +44 -44
  142. package/dist/cli/{run-4K6ZU7H7.mjs → run-GBRPFC6P.mjs} +23 -23
  143. package/dist/cli/{search-CKVFWVXQ.mjs → search-G7TS7OFB.mjs} +7 -7
  144. package/dist/cli/search-M3AHFCKQ.js +32 -0
  145. package/dist/cli/{search-output-WWB25JWA.mjs → search-output-BIIJRUCP.mjs} +4 -4
  146. package/dist/cli/{search-output-B5QE7ZNK.js → search-output-NRKLNWSD.js} +6 -6
  147. package/dist/cli/{secrets-SVZB6TSW.mjs → secrets-DN3XEZNH.mjs} +6 -6
  148. package/dist/cli/{secrets-WKIMR346.js → secrets-FUXYSEL5.js} +15 -15
  149. package/dist/cli/{sessions-P3QENG6T.mjs → sessions-PMUTPCTT.mjs} +6 -6
  150. package/dist/cli/sessions-VMBMBGVJ.js +23 -0
  151. package/dist/cli/{settings-V5ABL6D2.mjs → settings-N6GNS2KA.mjs} +12 -12
  152. package/dist/cli/{settings-UIFRGJW3.js → settings-ZDTWCQ6B.js} +85 -85
  153. package/dist/cli/{setup-E67NJTEF.mjs → setup-LJ3KWPSA.mjs} +9 -9
  154. package/dist/cli/{setup-A5MIJU3S.js → setup-PN5TSSJE.js} +49 -49
  155. package/dist/cli/{skills-WLHOQ4DO.mjs → skills-7J42K6VC.mjs} +7 -7
  156. package/dist/cli/skills-CXDENBLF.js +37 -0
  157. package/dist/cli/{tools-EG4KL3BB.mjs → tools-M3S6D6DA.mjs} +17 -17
  158. package/dist/cli/tools-WY2GMOC7.js +57 -0
  159. package/dist/cli/{update-IPFBE6SA.mjs → update-XTVFG74E.mjs} +9 -9
  160. package/dist/cli/update-ZB2IBGXG.js +37 -0
  161. package/dist/cli/{views-ZIBY2RVB.js → views-B4X2FWTF.js} +21 -21
  162. package/dist/cli/{views-XDN6SEWY.mjs → views-UFYRDO4X.mjs} +6 -6
  163. package/dist/cli/{workflow-BLKPBRBT.js → workflow-I2RM2J2J.js} +53 -29
  164. package/dist/cli/{workflow-O2XPMOVL.mjs → workflow-ZLMS3PDE.mjs} +42 -18
  165. package/dist/{client-QznpkWrk.d.ts → client-2QWMJInp.d.ts} +1 -1
  166. package/dist/{client-CmG8MT0x.d.mts → client-7H8TXmLa.d.mts} +1 -1
  167. package/dist/{client-core-CY0jNW0e.d.mts → client-core-BraEuxbg.d.mts} +67 -4
  168. package/dist/{client-core-CXDqfeiB.d.ts → client-core-DRglY5xa.d.ts} +67 -4
  169. package/dist/index.d.mts +3 -3
  170. package/dist/index.d.ts +3 -3
  171. package/dist/index.js +9 -9
  172. package/dist/index.mjs +6 -6
  173. package/dist/install-integrity.json +125 -120
  174. package/dist/plays/bundle-play-file.mjs +5 -0
  175. package/dist/plays/play-description.d.mts +1 -1
  176. package/dist/plays/play-description.d.ts +1 -1
  177. package/dist/plays/run-request.d.mts +1 -1
  178. package/dist/plays/run-request.d.ts +1 -1
  179. package/dist/release.d.mts +3 -3
  180. package/dist/release.d.ts +3 -3
  181. package/dist/release.js +2 -2
  182. package/dist/release.mjs +1 -1
  183. package/dist/server.d.mts +2 -2
  184. package/dist/server.d.ts +2 -2
  185. package/dist/server.js +5 -5
  186. package/dist/server.mjs +3 -3
  187. package/package.json +1 -1
  188. package/dist/cli/auth-ALBG5LF4.js +0 -44
  189. package/dist/cli/concurrent-runs-help-E3YMAO5Q.js +0 -22
  190. package/dist/cli/describe-QB5T47B3.js +0 -50
  191. package/dist/cli/git-4FXTWHXT.js +0 -26
  192. package/dist/cli/search-YZIJS7QU.js +0 -32
  193. package/dist/cli/sessions-VQPGPXMU.js +0 -23
  194. package/dist/cli/skills-GTBK33MV.js +0 -37
  195. package/dist/cli/tools-GPAIPRPQ.js +0 -57
  196. package/dist/cli/update-QLWS32WR.js +0 -37
@@ -11,6 +11,11 @@ import {
11
11
  parsePlaySourceForAnalysis,
12
12
  type AstNode,
13
13
  } from './ts-ast';
14
+ import {
15
+ createRecordingSourceIndex,
16
+ docflowRecordedOutputProblems,
17
+ docflowStatementReads,
18
+ } from './docflow-recording-lint';
14
19
 
15
20
  export type PlayDocflowNodeKind =
16
21
  | 'action'
@@ -243,6 +248,9 @@ export type PlayDocflowLintIssue = {
243
248
  | 'docflow_layout_complexity'
244
249
  | 'docflow_topology_invalid'
245
250
  | 'docflow_io_missing'
251
+ | 'docflow_inputs_undeclared'
252
+ | 'docflow_output_records_empty'
253
+ | 'docflow_output_is_tool_result'
246
254
  | 'docflow_box_is_sketch'
247
255
  | 'docflow_input_not_found'
248
256
  | 'docflow_output_not_found'
@@ -696,7 +704,12 @@ function docflowSourceLocator(sourceCode: string | undefined) {
696
704
  const diagramLines: number[] = [];
697
705
  let inside = false;
698
706
  lines.forEach((text, index) => {
699
- if (!inside && /\/\*\*\s*@mermaid\b/.test(text)) inside = true;
707
+ if (
708
+ !inside &&
709
+ /\/\*\*\s*@mermaid\b/.test(text) &&
710
+ !/\/\*\*\s*@mermaid[ \t]+off\b(?:[ \t]*:.*)?\*\/\s*$/.test(text)
711
+ )
712
+ inside = true;
700
713
  if (inside) diagramLines.push(index);
701
714
  if (inside && text.includes('*/')) inside = false;
702
715
  });
@@ -744,7 +757,10 @@ function docflowAnnotationFix(
744
757
  const join = (paths: string[] | undefined) =>
745
758
  paths?.length ? paths.join(',') : undefined;
746
759
  const attributes: Array<[string, string | undefined]> = [
747
- ['type', binding.kind && binding.kind !== 'action' ? binding.kind : undefined],
760
+ [
761
+ 'type',
762
+ binding.kind && binding.kind !== 'action' ? binding.kind : undefined,
763
+ ],
748
764
  ['in', changes.in ?? join(binding.inputs)],
749
765
  ['out', changes.out ?? join(binding.outputs)],
750
766
  ['arm', binding.arm],
@@ -863,6 +879,44 @@ function cleanBlockBody(raw: string): string {
863
879
  .trim();
864
880
  }
865
881
 
882
+ /**
883
+ * `/** @mermaid off: <reason> *\/`: the author's explicit choice to publish a
884
+ * Play without a diagram. The block is the whole directive (`off`, then an
885
+ * optional `: reason`, and nothing else), so `@mermaid off` followed by a
886
+ * `flowchart` line stays what it always was: a diagram for an export named
887
+ * `off`.
888
+ */
889
+ const MERMAID_OFF_DIRECTIVE = /^@mermaid[ \t]+off(?:[ \t]*:([\s\S]*))?$/;
890
+
891
+ /**
892
+ * A file's `@mermaid off` directive. `reason` is null when the author wrote
893
+ * none (`@mermaid off`, or `@mermaid off:` with nothing after it), which is
894
+ * not an opt-out: the reason is the record of why this Play records no
895
+ * per-step values.
896
+ */
897
+ export type PlayDiagramOptOut = { line: number; reason: string | null };
898
+
899
+ /** The first `/** @mermaid off… *\/` directive in `sourceCode`, or null. */
900
+ export function readPlayDiagramOptOut(
901
+ sourceCode: string,
902
+ ): PlayDiagramOptOut | null {
903
+ for (const match of sourceCode.matchAll(JSDOC_BLOCK)) {
904
+ const directive = MERMAID_OFF_DIRECTIVE.exec(cleanBlockBody(match[1]!));
905
+ if (!directive) continue;
906
+ const reason = (directive[1] ?? '').replace(/\s+/g, ' ').trim();
907
+ return {
908
+ line: sourceCode.slice(0, match.index!).split(/\r?\n/).length,
909
+ reason: reason || null,
910
+ };
911
+ }
912
+ return null;
913
+ }
914
+
915
+ /** Whether a JSDoc block body is the `@mermaid off` directive, not a diagram. */
916
+ function isDiagramOptOutBlock(rawBody: string): boolean {
917
+ return MERMAID_OFF_DIRECTIVE.test(cleanBlockBody(rawBody));
918
+ }
919
+
866
920
  /**
867
921
  * Splits `/** @mermaid contact-to-phone-waterfall` into the play it names and
868
922
  * the diagram itself.
@@ -1289,6 +1343,7 @@ export function parsePlayDocflowFile(
1289
1343
  JSDOC_BLOCK.lastIndex = 0;
1290
1344
  for (const match of sourceCode.matchAll(JSDOC_BLOCK)) {
1291
1345
  const cleanedBody = cleanBlockBody(match[1]!);
1346
+ if (isDiagramOptOutBlock(match[1]!)) continue;
1292
1347
  const mermaid = /^@mermaid(?:[ \t]+|\r?\n|$)([\s\S]*)$/.exec(cleanedBody);
1293
1348
  if (!mermaid) continue;
1294
1349
  rawBlocks.push({
@@ -1796,13 +1851,13 @@ export function parsePlayDocflow(
1796
1851
  : undefined);
1797
1852
  const unread = selected
1798
1853
  ? undefined
1799
- : parsed.unreadBlocks.find(
1854
+ : (parsed.unreadBlocks.find(
1800
1855
  (block) =>
1801
1856
  (block.authoredExportName ?? PLAY_DEFAULT_EXPORT) === requested,
1802
1857
  ) ??
1803
1858
  (parsed.unreadBlocks.length === 1 && parsed.blocks.length === 0
1804
1859
  ? parsed.unreadBlocks[0]
1805
- : undefined);
1860
+ : undefined));
1806
1861
  return {
1807
1862
  docflow: selected?.docflow ?? null,
1808
1863
  errors: parsed.errors,
@@ -2179,7 +2234,11 @@ export function lintPlayDocflow(
2179
2234
  // external trigger at the top of the flow, or a legend beside it, is
2180
2235
  // honestly a sketch; a box the flow passes INTO is a step the Play takes,
2181
2236
  // so its sketch hides real work from every run.
2182
- if (node.sketch && node.kind !== 'conceptual' && (indegree.get(node.id) ?? 0) > 0) {
2237
+ if (
2238
+ node.sketch &&
2239
+ node.kind !== 'conceptual' &&
2240
+ (indegree.get(node.id) ?? 0) > 0
2241
+ ) {
2183
2242
  issues.push({
2184
2243
  code: 'docflow_box_is_sketch',
2185
2244
  severity: 'warning',
@@ -2246,6 +2305,11 @@ export function lintPlayDocflow(
2246
2305
  (docflow.subgraphs ?? []).flatMap((subgraph) => subgraph.memberIds),
2247
2306
  );
2248
2307
 
2308
+ const inputsMissing: Array<{
2309
+ binding: PlayDocflowBinding;
2310
+ bindingSource: string | undefined;
2311
+ }> = [];
2312
+ const recordingIndex = createRecordingSourceIndex();
2249
2313
  for (const binding of docflow.bindings) {
2250
2314
  const node = byId.get(binding.nodeId);
2251
2315
  if (!node) continue;
@@ -2265,35 +2329,121 @@ export function lintPlayDocflow(
2265
2329
  if (node.kind !== 'conceptual') {
2266
2330
  // A chained per-row column (`.withColumn(…)`) reads its row; only what
2267
2331
  // it adds needs naming.
2268
- const readsItsRow = boundLine.startsWith('.');
2269
- const missing = [
2270
- ...(binding.inputs?.length || readsItsRow ? [] : ['in']),
2271
- ...(binding.outputs?.length ? [] : ['out']),
2272
- ];
2273
- if (missing.length > 0) {
2274
- const produced = /^return\b/.test(boundLine)
2275
- ? '$output'
2276
- : (assignedName ?? '<what it produces>');
2332
+ // So does a loop member, whose annotation may be stacked above the
2333
+ // `const x = await ctx.dataset(…).withColumn(…)` statement it names a
2334
+ // column of.
2335
+ const readsItsRow =
2336
+ boundLine.startsWith('.') || subgraphMemberIds.has(binding.nodeId);
2337
+ // `out:` is required when the statement produces a value: it assigns
2338
+ // one, returns one, or (a chained `.withColumn`) adds a column. A
2339
+ // statement that produces nothing needs no empty `out:""`.
2340
+ const produced = /^return\b/.test(boundLine)
2341
+ ? '$output'
2342
+ : (assignedName ?? (readsItsRow ? '<the column it adds>' : null));
2343
+ // An explicit `out:""` declares that the box records no output.
2344
+ if (binding.outputs === undefined && produced) {
2345
+ const located = at(binding.nodeId, 'annotation');
2277
2346
  issues.push({
2278
2347
  code: 'docflow_io_missing',
2279
2348
  severity: 'warning',
2280
- message:
2281
- missing.length === 2
2282
- ? `Box "${binding.nodeId}" does not say what it reads or produces, so a run cannot show its input or its result.`
2283
- : missing[0] === 'in'
2284
- ? `Box "${binding.nodeId}" does not say what it reads, so a run cannot show its input.`
2285
- : `Box "${binding.nodeId}" does not say what it produces, so a run cannot show its result.`,
2349
+ message: `Box "${binding.nodeId}"${located.line ? ` (annotation on line ${located.line})` : ''} has no out:, but its statement produces ${produced === '$output' ? 'the play\'s return value' : `\`${produced}\``}, so a run cannot show its result.`,
2286
2350
  path: `docflow.nodes.${binding.nodeId}`,
2287
- hint: `Add ${missing.map((name) => `${name}:"…"`).join(' and ')} to its annotation.`,
2288
- ...at(binding.nodeId, 'annotation'),
2289
- fix: docflowAnnotationFix(binding, {
2290
- ...(missing.includes('in') ? { in: '<what it reads>' } : {}),
2291
- ...(missing.includes('out') ? { out: produced } : {}),
2292
- }),
2351
+ hint: `Name what it produces in its annotation:`,
2352
+ ...located,
2353
+ fix: docflowAnnotationFix(binding, { out: produced }),
2354
+ });
2355
+ }
2356
+ // `in:` is required when static analysis sees the statement read local
2357
+ // values; those boxes are reported together below. A chained
2358
+ // `.withColumn` reads its row.
2359
+ // An explicit `in:""` declares that the box records no input.
2360
+ if (binding.inputs === undefined && !readsItsRow) {
2361
+ inputsMissing.push({ binding, bindingSource });
2362
+ }
2363
+ }
2364
+ // `const [a, b] = await …` with out:"a,b": a box reads each out: off the
2365
+ // statement's value, an array, so `a` and `b` record nothing. Name the
2366
+ // array and destructure it on the next line.
2367
+ const destructured = /^(?:const|let|var)\s*\[([^\]]*)\]\s*=/.exec(
2368
+ boundLine,
2369
+ )?.[1];
2370
+ if (destructured && node.kind !== 'conceptual' && binding.outputs?.length) {
2371
+ const elements = new Set(
2372
+ destructured
2373
+ .split(',')
2374
+ .map((element) => element.trim().replace(/\s*=.*$/, ''))
2375
+ .filter(Boolean),
2376
+ );
2377
+ const named = binding.outputs.filter((path) =>
2378
+ elements.has(rootPath(path)),
2379
+ );
2380
+ if (named.length > 0) {
2381
+ const located = at(binding.nodeId, 'annotation');
2382
+ issues.push({
2383
+ code: 'docflow_output_records_empty',
2384
+ severity: 'warning',
2385
+ message: `Box "${binding.nodeId}"${located.line ? ` (annotation on line ${located.line})` : ''} records out:"${named.join(',')}", names destructured from an array on line ${binding.line}. A box reads each out: off the statement's value, the array, so ${named.length === 1 ? 'it records' : 'they record'} nothing.`,
2386
+ path: `docflow.nodes.${binding.nodeId}.out`,
2387
+ hint: 'Name the array in the statement the box binds, and destructure it on the next line:',
2388
+ ...located,
2389
+ fix: [
2390
+ docflowAnnotationFix(binding, { out: 'results' }),
2391
+ `const results = ${boundLine.replace(/^(?:const|let|var)\s*\[[^\]]*\]\s*=\s*/, '')}`,
2392
+ `const [${destructured.trim()}] = results;`,
2393
+ ].join('\n'),
2293
2394
  });
2294
2395
  }
2295
2396
  }
2296
2397
  if (!bindingSource) continue;
2398
+ // What the box will record. A box that records `[]` or `{}` for a value
2399
+ // the Play did produce is worse than none: it reads as "nothing found".
2400
+ for (const problem of node.kind === 'conceptual'
2401
+ ? []
2402
+ : docflowRecordedOutputProblems(binding, bindingSource, recordingIndex)) {
2403
+ const located = at(binding.nodeId, 'annotation');
2404
+ const where = located.line ? ` (annotation on line ${located.line})` : '';
2405
+ if (problem.kind === 'filled_after') {
2406
+ const fill =
2407
+ problem.emptyAs === 'new Map()'
2408
+ ? 'out.set(key, value)'
2409
+ : problem.emptyAs === 'new Set()'
2410
+ ? 'out.add(value)'
2411
+ : problem.emptyAs === '{}'
2412
+ ? 'out[key] = value'
2413
+ : 'out.push(value)';
2414
+ issues.push({
2415
+ code: 'docflow_output_records_empty',
2416
+ severity: 'warning',
2417
+ message: `Box "${binding.nodeId}"${where} records out:"${problem.name}", but \`${problem.name}\` is created empty (\`${problem.emptyAs}\`) on line ${problem.declarationLine} and only filled afterwards, from line ${problem.mutationLine}. A box records its value when its statement ends, so every run records ${problem.emptyAs === '[]' || problem.emptyAs === '{}' ? `\`${problem.emptyAs}\`` : 'an empty value'}.`,
2418
+ path: `docflow.nodes.${binding.nodeId}.out`,
2419
+ hint: `Build the finished \`${problem.name}\` in one statement (move the loop from line ${problem.mutationLine} inside it) and put the annotation above that statement:`,
2420
+ ...located,
2421
+ fix: [
2422
+ docflowAnnotationFix(binding),
2423
+ `const ${problem.name} = await (async () => {`,
2424
+ ` const out = ${problem.emptyAs};`,
2425
+ ` for (/* the loop from line ${problem.mutationLine} */) ${fill};`,
2426
+ ' return out;',
2427
+ '})();',
2428
+ ].join('\n'),
2429
+ });
2430
+ } else {
2431
+ const value = `${problem.name}Value`;
2432
+ issues.push({
2433
+ code: 'docflow_output_is_tool_result',
2434
+ severity: 'warning',
2435
+ message: `Box "${binding.nodeId}"${where} records out:"${problem.name}", the whole result of ${problem.callee}(...) on line ${problem.declarationLine}. A run records only the fields the tool declares, read through its getters; a tool that declares none records {}.`,
2436
+ path: `docflow.nodes.${binding.nodeId}.out`,
2437
+ hint: `To show exactly the value this step uses, read it into its own variable and bind the box to that statement:`,
2438
+ ...located,
2439
+ fix: [
2440
+ `const ${problem.name} = await ${problem.callee}({ /* unchanged */ });`,
2441
+ docflowAnnotationFix(binding, { out: value }),
2442
+ `const ${value} = /* the plain field this step needs, read from ${problem.name} */;`,
2443
+ ].join('\n'),
2444
+ });
2445
+ }
2446
+ }
2297
2447
  const sourceIdentifiers = identifiersForSource(bindingSource);
2298
2448
  // What a module's box reads may be the play's own input, which the entry
2299
2449
  // names and hands to it (`in:"input.domain"` wires the box to the canvas's
@@ -2314,10 +2464,7 @@ export function lintPlayDocflow(
2314
2464
  )
2315
2465
  ? objectLiteralFields(bindingSource.split(/\r?\n/), binding.line - 1)
2316
2466
  : null;
2317
- if (
2318
- builtObject &&
2319
- (builtObject.spread || builtObject.fields.length > 1)
2320
- ) {
2467
+ if (builtObject && (builtObject.spread || builtObject.fields.length > 1)) {
2321
2468
  const example = builtObject.fields.slice(0, 2).join(',');
2322
2469
  issues.push({
2323
2470
  code: 'docflow_show_undeclared',
@@ -2398,6 +2545,45 @@ export function lintPlayDocflow(
2398
2545
  }
2399
2546
  }
2400
2547
 
2548
+ if (inputsMissing.length > 0) {
2549
+ const described = inputsMissing.map(({ binding, bindingSource }) => {
2550
+ const reads = bindingSource
2551
+ ? docflowStatementReads(binding.line, bindingSource, recordingIndex)
2552
+ : [];
2553
+ return { binding, reads };
2554
+ });
2555
+ const located = described
2556
+ .filter((entry) => entry.reads.length > 0)
2557
+ .map((entry) => ({
2558
+ ...entry,
2559
+ line: at(entry.binding.nodeId, 'annotation').line,
2560
+ }));
2561
+ const lineLabel = (line: number | undefined) =>
2562
+ line === undefined ? '' : ` (line ${line})`;
2563
+ if (located.length > 0) issues.push({
2564
+ code: 'docflow_inputs_undeclared',
2565
+ severity: 'warning',
2566
+ message: `${located.length} ${located.length === 1 ? 'step records' : 'steps record'} no inputs, because ${located.length === 1 ? 'its annotation has' : 'their annotations have'} no in:"…", so a run cannot show what ${located.length === 1 ? 'it' : 'each'} started from: ${located
2567
+ .map(
2568
+ ({ binding, reads, line }) =>
2569
+ `${binding.nodeId}${lineLabel(line)}${reads.length ? ` reads ${reads.join(', ')}` : ''}`,
2570
+ )
2571
+ .join('; ')}.`,
2572
+ path: 'docflow.nodes',
2573
+ hint: 'Name what each step reads in its annotation. The annotations, completed with what static analysis sees each step read:',
2574
+ ...(located[0]!.line === undefined ? {} : { line: located[0]!.line }),
2575
+ fix: located
2576
+ .map(
2577
+ ({ binding, reads, line }) =>
2578
+ `${line === undefined ? '' : `line ${line}: `}${docflowAnnotationFix(
2579
+ binding,
2580
+ { in: reads.length ? reads.join(',') : '<what it reads>' },
2581
+ )}`,
2582
+ )
2583
+ .join('\n'),
2584
+ });
2585
+ }
2586
+
2401
2587
  // Regions fold by default, so count what each view of the canvas shows.
2402
2588
  for (const view of docflowCanvasViews(docflow)) {
2403
2589
  if (view.boxes <= DOCFLOW_MAX_NODES) continue;
@@ -2407,14 +2593,19 @@ export function lintPlayDocflow(
2407
2593
  message: view.regionId
2408
2594
  ? `Subgraph "${view.regionId}" shows ${view.boxes} boxes when opened; more than ${DOCFLOW_MAX_NODES} makes it hard to scan.`
2409
2595
  : `The diagram shows ${view.boxes} top-level boxes with every subgraph folded; more than ${DOCFLOW_MAX_NODES} makes the default view hard to scan.`,
2410
- path: view.regionId ? `docflow.subgraphs.${view.regionId}` : 'docflow.nodes',
2596
+ path: view.regionId
2597
+ ? `docflow.subgraphs.${view.regionId}`
2598
+ : 'docflow.nodes',
2411
2599
  hint: view.regionId
2412
2600
  ? 'Split the subgraph into nested phases, or move supporting detail into code.'
2413
2601
  : 'Group related steps into named `subgraph` phases; each folds to one box.',
2414
2602
  ...(view.regionId
2415
2603
  ? (() => {
2416
2604
  const line = locate.diagram(view.regionId);
2417
- return { node: view.regionId, ...(line === undefined ? {} : { line }) };
2605
+ return {
2606
+ node: view.regionId,
2607
+ ...(line === undefined ? {} : { line }),
2608
+ };
2418
2609
  })()
2419
2610
  : {}),
2420
2611
  fix: view.regionId
@@ -510,6 +510,12 @@ export type PlayCheckDiagramSummary = {
510
510
  warnings: number;
511
511
  };
512
512
 
513
+ const NO_DIAGRAM_CODES: ReadonlySet<string> = new Set([
514
+ 'docflow_visualization_missing',
515
+ 'docflow_diagram_disabled',
516
+ 'docflow_diagram_opt_out_invalid',
517
+ ]);
518
+
513
519
  function summarizeDiagram(
514
520
  docflow: PlayCheckCompactDocflow | undefined,
515
521
  issues: PlayCheckIssueShape[],
@@ -517,7 +523,14 @@ function summarizeDiagram(
517
523
  const diagramIssues = issues.filter(
518
524
  (issue) => isDiagramIssue(issue) && !isOptionalDiagramNudge(issue),
519
525
  );
520
- if (!docflow && diagramIssues.length === 0) return undefined;
526
+ // With no diagram drawn, an issue that the Play has none (or opted out) is
527
+ // the headline, not a diagram to count: there are no boxes to summarize.
528
+ if (
529
+ !docflow &&
530
+ diagramIssues.every((issue) => NO_DIAGRAM_CODES.has(issue.code))
531
+ ) {
532
+ return undefined;
533
+ }
521
534
  const nodes = docflow?.nodes ?? [];
522
535
  return {
523
536
  drawn: Boolean(docflow),
@@ -0,0 +1,35 @@
1
+ type StoredPlayRunResultCarrier = {
2
+ result?: unknown;
3
+ runSnapshot?: unknown;
4
+ };
5
+
6
+ /**
7
+ * A stored run's result. `runSnapshot.result` is the Run Ledger's copy; the
8
+ * top-level `result` duplicates it for older readers and can be absent on
9
+ * newer run documents. Prefer the top-level field while it exists so reads
10
+ * of existing runs stay byte-identical.
11
+ */
12
+ export function playRunResult(
13
+ run: StoredPlayRunResultCarrier | null | undefined,
14
+ ): unknown {
15
+ if (!run) return undefined;
16
+ if (run.result !== undefined) return run.result;
17
+ const snapshot = run.runSnapshot;
18
+ if (!snapshot || typeof snapshot !== 'object' || Array.isArray(snapshot)) {
19
+ return undefined;
20
+ }
21
+ return (snapshot as { result?: unknown }).result;
22
+ }
23
+
24
+ /**
25
+ * Present a stored run with its top-level `result`, so a caller that reads
26
+ * only that field sees the same value whether or not the document still
27
+ * carries the duplicate. Returns the input unchanged when nothing is missing.
28
+ */
29
+ export function withPlayRunResult<T extends StoredPlayRunResultCarrier>(
30
+ run: T,
31
+ ): T {
32
+ if (run.result !== undefined) return run;
33
+ const result = playRunResult(run);
34
+ return result === undefined ? run : { ...run, result };
35
+ }
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  getAuthedHttpClient,
3
3
  printCommandEnvelope
4
- } from "./chunk-NVHICORD.mjs";
4
+ } from "./chunk-WW52ANX4.mjs";
5
5
  import {
6
6
  cliFeatureEnabled
7
- } from "./chunk-ROUNT4NX.mjs";
8
- import "./chunk-LDMCTV2Z.mjs";
7
+ } from "./chunk-4ANDW2OT.mjs";
8
+ import "./chunk-HNTIGYRT.mjs";
9
9
  import "./chunk-ASB47RXJ.mjs";
10
10
  import "./chunk-DLIRSHV6.mjs";
11
11
  import {
12
12
  DeeplineError
13
13
  } from "./chunk-Z3A2S3QM.mjs";
14
14
  import "./chunk-2MGZAI54.mjs";
15
- import "./chunk-ZARGHLZZ.mjs";
15
+ import "./chunk-KMLACXI2.mjs";
16
16
  import "./chunk-WZYKRD7T.mjs";
17
17
  import "./chunk-KRD6H754.mjs";
18
18
 
@@ -42,6 +42,10 @@ function describeOwnedOutcome(owned) {
42
42
  const last = owned.lastWake ? `last ring ${new Date(owned.lastWake.at).toISOString()} ${WAKE_STATUS_WORDS[owned.lastWake.status]}${owned.lastWake.what.length > 0 ? ` (${owned.lastWake.what.join(", ")})` : ""}` : "never rung";
43
43
  return `${owned.outcome} \u2014 as ${owned.agent}; ${watch}; ${last}; ${owned.turnsInWindow} of ${owned.turnLimit} turns this hour`;
44
44
  }
45
+ function describeHomeWakes(home) {
46
+ const last = home.lastWake ? `last ring ${new Date(home.lastWake.at).toISOString()} ${WAKE_STATUS_WORDS[home.lastWake.status]}${home.lastWake.what.length > 0 ? ` (${home.lastWake.what.join(", ")})` : ""}` : "never rung";
47
+ return `#${home.conversationName} (${home.conversationId}) \u2014 ${home.agent} on ${home.outcome}; ${home.watching ? "woken there" : "not woken (no watch)"}; ${last}; ${home.turnsInWindow} of ${home.turnLimit} turns this hour`;
48
+ }
45
49
  var REPLIES_MAX_LIMIT = 100;
46
50
  var REPLIES_INVALID_CURSOR = "DEEPLINE_AGENT_REPLIES_INVALID_CURSOR";
47
51
  var FEEDBACK_MAX_LIMIT = 100;
@@ -496,6 +500,66 @@ function registerWorkspaceCommands(agents, readKey) {
496
500
  options
497
501
  );
498
502
  });
503
+ agents.command("wakes").description(
504
+ "List outcome home channels with how their agent was last woken and its hourly turn budget."
505
+ ).option("--json", "Emit JSON output").action(async (options) => {
506
+ const { http } = getAuthedHttpClient();
507
+ const result = await http.get(
508
+ `${AGENT_PATH}/wakes`
509
+ );
510
+ print(
511
+ result,
512
+ "agent wakes",
513
+ result.homes.length === 0 ? [
514
+ "No channel is an outcome\u2019s home. Make one with: deepline agents channels set <channel-id> --outcome <outcome>"
515
+ ] : result.homes.map(describeHomeWakes),
516
+ options
517
+ );
518
+ });
519
+ agents.command("memory").description(
520
+ "Show what the agent remembers about an outcome, in each channel that works toward it, and who said it; --clear forgets it all (both need member access)."
521
+ ).argument("<outcome>", "Outcome name, as deepline outcomes list prints it").option(
522
+ "--clear",
523
+ "Forget everything the agent remembers about this outcome (member access)"
524
+ ).option("--json", "Emit JSON output").action(
525
+ async (outcome, options) => {
526
+ const name = requireArgument(outcome, "an outcome name");
527
+ const path = `${AGENT_PATH}/memory?outcome=${encodeURIComponent(name)}`;
528
+ const { http } = getAuthedHttpClient();
529
+ if (options.clear) {
530
+ const result2 = await http.delete(path);
531
+ print(
532
+ result2,
533
+ "agent memory",
534
+ [
535
+ result2.cleared === 0 ? `The agent remembered nothing about ${name}.` : `Forgot ${result2.cleared} ${result2.cleared === 1 ? "thing" : "things"} the agent remembered about ${name}.`
536
+ ],
537
+ options
538
+ );
539
+ return;
540
+ }
541
+ const result = await http.get(path);
542
+ print(
543
+ result,
544
+ "agent memory",
545
+ result.memories.length === 0 ? [
546
+ `The agent remembers nothing about ${name} yet. It saves what people tell it that will matter later (decisions, deadlines, preferences, who owns what).`
547
+ ] : [
548
+ ...result.memories.flatMap(describeOutcomeMemory),
549
+ `Forget it all with: deepline agents memory ${name} --clear`
550
+ ],
551
+ options
552
+ );
553
+ }
554
+ );
555
+ }
556
+ function describeOutcomeMemory(memory) {
557
+ return [
558
+ memory.owner ? "Bot by Deepline (no channel):" : `#${memory.conversationName}:`,
559
+ ...memory.entries.map(
560
+ (entry) => ` ${entry.n}. ${entry.text} (${entry.source})`
561
+ )
562
+ ];
499
563
  }
500
564
  function registerAgentCommands(agents) {
501
565
  agents.command("get").description("Show one agent: its instructions, skills and channels.").argument("<name>", "Agent name").option("--json", "Emit JSON output").action(async (name, options) => {