deepline 0.3.578 → 0.3.580

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 (175) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +20 -2
  2. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  3. package/dist/bundling-sources/shared_libs/monitors/billing/public-pricing.ts +470 -15
  4. package/dist/bundling-sources/shared_libs/monitors/billing/tamradar.ts +12 -0
  5. package/dist/bundling-sources/shared_libs/monitors/billing/types.ts +59 -0
  6. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-capability.ts +5 -3
  7. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +3 -1
  8. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +18 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +124 -57
  10. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +4 -0
  11. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +182 -80
  12. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +39 -2
  13. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +25 -0
  14. package/dist/bundling-sources/shared_libs/plays/sandbox-runtime-limits.ts +83 -0
  15. package/dist/cli/{agents-MCU3ITQZ.js → agents-BF5VX5ZB.js} +31 -31
  16. package/dist/cli/{agents-LRBANBZH.mjs → agents-JRFTZE7G.mjs} +4 -4
  17. package/dist/cli/auth-25MVD7TK.js +44 -0
  18. package/dist/cli/{auth-5BJKVYMQ.mjs → auth-XJXZ64R4.mjs} +5 -5
  19. package/dist/cli/{billing-EBBI4MVL.mjs → billing-TXJBGP2I.mjs} +69 -64
  20. package/dist/cli/{billing-NT57POHH.js → billing-VGMTJI7W.js} +158 -153
  21. package/dist/cli/{chunk-XBO4ERH6.js → chunk-2ZCFAUCV.js} +3 -3
  22. package/dist/cli/{chunk-P35YQAUC.js → chunk-3OSNEWGR.js} +281 -275
  23. package/dist/cli/{chunk-7J473OJ5.mjs → chunk-3P4QZIJ5.mjs} +1 -1
  24. package/dist/cli/{chunk-SKHUWQZE.js → chunk-3S5KFHQH.js} +17 -7
  25. package/dist/cli/{chunk-4LMTY4RQ.mjs → chunk-3ZBPXNSW.mjs} +2 -2
  26. package/dist/cli/{chunk-H7DY5NQ3.mjs → chunk-5BPJW6X5.mjs} +5 -5
  27. package/dist/cli/{chunk-A7NKOXBV.js → chunk-6VSUP4WN.js} +4 -4
  28. package/dist/cli/{chunk-4KNRCUKY.mjs → chunk-7HOG3JZE.mjs} +21 -15
  29. package/dist/cli/{chunk-OAQYLTUN.mjs → chunk-7ORX33JX.mjs} +5 -5
  30. package/dist/cli/{chunk-24FGR73C.js → chunk-ANX3PYLT.js} +13 -13
  31. package/dist/cli/{chunk-VVZ7JZMQ.js → chunk-APJ7IPRT.js} +15 -15
  32. package/dist/cli/{chunk-MXPCTF57.js → chunk-AZTQJJH7.js} +17 -2
  33. package/dist/cli/{chunk-3GF33QJJ.mjs → chunk-BAXLPQTM.mjs} +4 -4
  34. package/dist/cli/{chunk-DDJN4RR6.mjs → chunk-BK4Z62CF.mjs} +4 -4
  35. package/dist/cli/{chunk-IFWB4BYZ.mjs → chunk-C6YXUGX2.mjs} +3 -3
  36. package/dist/cli/{chunk-J7PCSLRY.js → chunk-COAAKSFX.js} +5 -5
  37. package/dist/cli/{chunk-Y2TK7OXN.js → chunk-D6I7QWOZ.js} +2 -2
  38. package/dist/cli/{chunk-W47SXEWQ.js → chunk-DQEHBAHL.js} +9 -9
  39. package/dist/cli/{chunk-ITYSPUKD.mjs → chunk-EI7KTESB.mjs} +2 -2
  40. package/dist/cli/{chunk-HZXF2HFF.mjs → chunk-FCJJPEKN.mjs} +5 -5
  41. package/dist/cli/{chunk-NEH7NZFT.js → chunk-GDBNH57Z.js} +10 -10
  42. package/dist/cli/{chunk-CFG3ZM7M.mjs → chunk-GE4ZEMMA.mjs} +2 -2
  43. package/dist/cli/{chunk-4YSJOSBG.mjs → chunk-GIZIWNL5.mjs} +1 -1
  44. package/dist/cli/{chunk-PJXPHUAR.mjs → chunk-H3B6QM6V.mjs} +3 -3
  45. package/dist/cli/{chunk-25SSGQJJ.js → chunk-HEZ24K5F.js} +2 -2
  46. package/dist/cli/{chunk-LYZPGP3P.mjs → chunk-HLMF53HZ.mjs} +1 -1
  47. package/dist/cli/{chunk-T2CCLYHV.mjs → chunk-IERWFFDB.mjs} +7 -7
  48. package/dist/cli/{chunk-CFLAGRWL.mjs → chunk-IG3CXIJY.mjs} +1 -1
  49. package/dist/cli/{chunk-ALXYCC4K.mjs → chunk-IM322G7M.mjs} +1 -1
  50. package/dist/cli/{chunk-RW3URFZK.mjs → chunk-KLBIHDZB.mjs} +2 -2
  51. package/dist/cli/{chunk-VMCJKGZS.mjs → chunk-LC4ETCOA.mjs} +2 -2
  52. package/dist/cli/{chunk-CS36W3RL.js → chunk-LHV3HPAY.js} +26 -26
  53. package/dist/cli/{chunk-CPNTDIJK.js → chunk-MBOPKQJF.js} +1 -1
  54. package/dist/cli/{chunk-BPMA4S3O.js → chunk-MCYZO3RB.js} +21 -21
  55. package/dist/cli/{chunk-JQPFICW3.mjs → chunk-MEDA3STC.mjs} +1 -1
  56. package/dist/cli/{chunk-ZO65VJRJ.js → chunk-MOZDEYQC.js} +11 -1
  57. package/dist/cli/{chunk-6UFTWNC5.mjs → chunk-MP6XUVAJ.mjs} +2 -2
  58. package/dist/cli/{chunk-HGQT6EGK.js → chunk-NNWEQDZR.js} +20 -20
  59. package/dist/cli/{chunk-AZFSCPYK.mjs → chunk-NV5IJ3NY.mjs} +17 -2
  60. package/dist/cli/{chunk-QPOJLAFT.mjs → chunk-O7AWGIDD.mjs} +2 -2
  61. package/dist/cli/{chunk-G7PH2QVM.js → chunk-PFNYLTCZ.js} +5 -5
  62. package/dist/cli/{chunk-DWUESXDD.mjs → chunk-QXQBTTRD.mjs} +11 -1
  63. package/dist/cli/{chunk-5IMWXYVB.js → chunk-R77IVVEZ.js} +53 -53
  64. package/dist/cli/{chunk-MXK4M7HP.js → chunk-S2YKIWCD.js} +17 -17
  65. package/dist/cli/{chunk-FYKHAT2F.mjs → chunk-SECFDB27.mjs} +10 -0
  66. package/dist/cli/{chunk-NTHN7ODR.mjs → chunk-SQBSK74D.mjs} +7 -3
  67. package/dist/cli/{chunk-M3ITWEGS.js → chunk-TSOXJZSW.js} +41 -41
  68. package/dist/cli/{chunk-CSPOWVWS.mjs → chunk-U4VCAECC.mjs} +8 -3
  69. package/dist/cli/{chunk-RLPPLS6A.js → chunk-URZPR54R.js} +6 -6
  70. package/dist/cli/{chunk-27HAQRGH.js → chunk-V5NDHTBB.js} +23 -23
  71. package/dist/cli/{chunk-HKZN33F2.mjs → chunk-VF3EGTHU.mjs} +3 -3
  72. package/dist/cli/{chunk-5LCV36BR.js → chunk-VOQWPUIF.js} +20 -20
  73. package/dist/cli/{chunk-3ZUKYLC6.js → chunk-WJUAVMQC.js} +217 -213
  74. package/dist/cli/{chunk-W66GXHYR.mjs → chunk-X5RXG6VS.mjs} +1 -1
  75. package/dist/cli/{chunk-UKSOIH2P.js → chunk-XFVJ3JNA.js} +5 -5
  76. package/dist/cli/{chunk-RWDYULX2.js → chunk-XQUVLYOL.js} +17 -12
  77. package/dist/cli/{chunk-XE66BGLB.js → chunk-YY6EB252.js} +2 -2
  78. package/dist/cli/{chunk-XX7TZM4N.js → chunk-Z6DERGHY.js} +48 -48
  79. package/dist/cli/{chunk-PXMCPEE2.js → chunk-ZADJC22U.js} +3 -3
  80. package/dist/cli/{chunk-4CNHOBUO.mjs → chunk-ZR7PDXIA.mjs} +2 -2
  81. package/dist/cli/command-docs.js +2 -2
  82. package/dist/cli/command-docs.mjs +1 -1
  83. package/dist/cli/concurrent-runs-help-DEN63DUM.js +22 -0
  84. package/dist/cli/{concurrent-runs-help-2MHLIUC6.mjs → concurrent-runs-help-DSUQRWZQ.mjs} +6 -6
  85. package/dist/cli/{csv-RYYDAC76.js → csv-HSHF6JYZ.js} +13 -13
  86. package/dist/cli/{csv-J6SRBMOT.mjs → csv-QNXJBT5T.mjs} +4 -4
  87. package/dist/cli/{db-WK226TM7.mjs → db-RAWY3SWS.mjs} +6 -6
  88. package/dist/cli/{db-5QLH6QK5.js → db-VHYWVLLU.js} +27 -27
  89. package/dist/cli/{describe-UBSCFPH5.mjs → describe-WZOVHWAM.mjs} +21 -21
  90. package/dist/cli/describe-YHZ2EGBQ.js +50 -0
  91. package/dist/cli/describe-core.d.mts +4 -2
  92. package/dist/cli/describe-core.d.ts +4 -2
  93. package/dist/cli/describe-core.js +4 -4
  94. package/dist/cli/describe-core.mjs +3 -3
  95. package/dist/cli/{executions-AGV5V7SD.js → executions-DQIFH4Z6.js} +8 -8
  96. package/dist/cli/{executions-XF5BNCFS.mjs → executions-QABOXV4K.mjs} +6 -6
  97. package/dist/cli/{feedback-3RDEZE2M.js → feedback-6IER2W4G.js} +14 -14
  98. package/dist/cli/{feedback-LT3PDK72.mjs → feedback-DW4O63DG.mjs} +6 -6
  99. package/dist/cli/{git-7VBTCCBV.mjs → git-3NAPGZGR.mjs} +5 -5
  100. package/dist/cli/git-SQ2MAKAH.js +26 -0
  101. package/dist/cli/index.js +148 -148
  102. package/dist/cli/index.mjs +47 -47
  103. package/dist/cli/{integrations-JP732FQB.js → integrations-5LHIBBXB.js} +29 -29
  104. package/dist/cli/{integrations-E7QRWMKZ.mjs → integrations-TSRUTENK.mjs} +7 -7
  105. package/dist/cli/{legacy-noops-UFNQBPIT.mjs → legacy-noops-4N63A6H7.mjs} +6 -6
  106. package/dist/cli/{legacy-noops-UTL4W5WE.js → legacy-noops-S22XGYGN.js} +9 -9
  107. package/dist/cli/{mcp-YHETA3AU.mjs → mcp-4EJHRRFV.mjs} +4 -4
  108. package/dist/cli/{mcp-5X4XFB4V.js → mcp-JERBGJYE.js} +24 -24
  109. package/dist/cli/{monitors-WFVZ42OQ.mjs → monitors-7BTLBD6S.mjs} +16 -11
  110. package/dist/cli/{monitors-AN6KH4XY.js → monitors-FF35CGC4.js} +109 -104
  111. package/dist/cli/{org-CN3XJZLA.js → org-ADCDO7KU.js} +121 -121
  112. package/dist/cli/{org-OMDV7WDF.mjs → org-QYIIBKA2.mjs} +6 -6
  113. package/dist/cli/{outcomes-7HCZ6K3Q.js → outcomes-2LW4GK2L.js} +14 -14
  114. package/dist/cli/{outcomes-I4ZTG5ND.mjs → outcomes-C5DIBG4Q.mjs} +6 -6
  115. package/dist/cli/{play-TSNBSHGA.mjs → play-DTTDTISL.mjs} +20 -20
  116. package/dist/cli/{play-45VXZ57A.js → play-S5MZ2GRA.js} +349 -349
  117. package/dist/cli/{providers-4TB56ZLK.mjs → providers-AXOEFQ6Q.mjs} +6 -6
  118. package/dist/cli/{providers-RB3TT7AE.js → providers-N2IWEJBW.js} +9 -9
  119. package/dist/cli/{quickstart-XHZ3PG5I.mjs → quickstart-ADWSZBV6.mjs} +4 -4
  120. package/dist/cli/{quickstart-ZNDM6VUD.js → quickstart-UC5AJZWU.js} +6 -6
  121. package/dist/cli/{run-XNEJGAKV.js → run-6TDYUL7L.js} +49 -48
  122. package/dist/cli/{run-7PY4G6GB.mjs → run-R2FVH3K6.mjs} +27 -26
  123. package/dist/cli/{search-BG7KCIOG.mjs → search-GRHUFSLY.mjs} +7 -7
  124. package/dist/cli/search-V7ANBX3J.js +32 -0
  125. package/dist/cli/{search-output-3ZBNTHGO.js → search-output-O7NY3VMD.js} +8 -8
  126. package/dist/cli/{search-output-TWKKP2BE.mjs → search-output-UPQNAFAF.mjs} +5 -5
  127. package/dist/cli/{secrets-FNR6MX6A.js → secrets-72GJHFER.js} +15 -15
  128. package/dist/cli/{secrets-AZZCE7E3.mjs → secrets-NKAEJLIQ.mjs} +6 -6
  129. package/dist/cli/sessions-EO6RTMUC.js +23 -0
  130. package/dist/cli/{sessions-ZAMKN3AF.mjs → sessions-VIMF3UF5.mjs} +6 -6
  131. package/dist/cli/{settings-QGASFWV3.js → settings-HFAW5HIF.js} +85 -85
  132. package/dist/cli/{settings-WKWOOOI2.mjs → settings-KCQHBFNZ.mjs} +12 -12
  133. package/dist/cli/{setup-KUZDCR3F.js → setup-2MHWGEAD.js} +49 -49
  134. package/dist/cli/{setup-U36W42LE.mjs → setup-2ZD5ZIUH.mjs} +9 -9
  135. package/dist/cli/skills-ID6KKDLH.js +37 -0
  136. package/dist/cli/{skills-25CSZQIK.mjs → skills-X2DZZG5P.mjs} +7 -7
  137. package/dist/cli/tools-7UY7GERW.js +57 -0
  138. package/dist/cli/{tools-4NZQ22AA.mjs → tools-KPTOWKD4.mjs} +19 -19
  139. package/dist/cli/{update-CJYP36TG.mjs → update-6PMQCEUP.mjs} +9 -9
  140. package/dist/cli/update-T2RDLLSY.js +37 -0
  141. package/dist/cli/{views-76UIPWJD.js → views-MNBHNO6C.js} +37 -24
  142. package/dist/cli/{views-GYGE7FSV.mjs → views-VRZ5CTFL.mjs} +21 -8
  143. package/dist/cli/{workflow-LZSWALZS.mjs → workflow-7JUJWA5S.mjs} +7 -7
  144. package/dist/cli/{workflow-NCVXBATM.js → workflow-SSMFO7YE.js} +17 -17
  145. package/dist/{client-CF-bsrtI.d.mts → client-CmG8MT0x.d.mts} +1 -1
  146. package/dist/{client-BrdMPFCM.d.ts → client-QznpkWrk.d.ts} +1 -1
  147. package/dist/{client-core-rMoUWSYM.d.ts → client-core-CXDqfeiB.d.ts} +12 -1
  148. package/dist/{client-core-DM1ZedOG.d.mts → client-core-CY0jNW0e.d.mts} +12 -1
  149. package/dist/index.d.mts +3 -3
  150. package/dist/index.d.ts +3 -3
  151. package/dist/index.js +9 -9
  152. package/dist/index.mjs +6 -6
  153. package/dist/install-integrity.json +126 -126
  154. package/dist/plays/play-description.d.mts +1 -1
  155. package/dist/plays/play-description.d.ts +1 -1
  156. package/dist/plays/run-request.d.mts +1 -1
  157. package/dist/plays/run-request.d.ts +1 -1
  158. package/dist/release.d.mts +1 -1
  159. package/dist/release.d.ts +1 -1
  160. package/dist/release.js +2 -2
  161. package/dist/release.mjs +1 -1
  162. package/dist/server.d.mts +2 -2
  163. package/dist/server.d.ts +2 -2
  164. package/dist/server.js +5 -5
  165. package/dist/server.mjs +3 -3
  166. package/package.json +1 -1
  167. package/dist/cli/auth-VSW3MTFO.js +0 -44
  168. package/dist/cli/concurrent-runs-help-ATT2GVTQ.js +0 -22
  169. package/dist/cli/describe-Q27SRQWM.js +0 -50
  170. package/dist/cli/git-BBTP3H7J.js +0 -26
  171. package/dist/cli/search-ZBU5GW4W.js +0 -32
  172. package/dist/cli/sessions-GCY62GAW.js +0 -23
  173. package/dist/cli/skills-43DHMLRW.js +0 -37
  174. package/dist/cli/tools-5BGKNMFU.js +0 -57
  175. package/dist/cli/update-CUO2MTB6.js +0 -37
@@ -2776,6 +2776,13 @@ export type BillingRecentUsageEntry = {
2776
2776
  | 'failed';
2777
2777
  /** Final billing truth may be unknown even after execution completes. */
2778
2778
  charge_finality?: 'final' | 'pending' | 'unknown';
2779
+ /**
2780
+ * The provider key the call ran on: `managed` (Deepline's key) or `user`
2781
+ * (the workspace's own connected key). `unknown` for calls recorded before
2782
+ * this was stored and for tools that need no provider key; absent from
2783
+ * older servers. Never the key itself.
2784
+ */
2785
+ credential_source?: 'managed' | 'user' | 'unknown';
2779
2786
  rough_usd_cost: number | null;
2780
2787
  created_at: string;
2781
2788
  };
@@ -3238,6 +3245,8 @@ export type View = {
3238
3245
  play: string;
3239
3246
  input: Record<string, unknown>;
3240
3247
  access: ViewAccess;
3248
+ embed_origins?: string[];
3249
+ embed_url?: string;
3241
3250
  /** The view's workspace; null is the org's default workspace. Absent from older servers. */
3242
3251
  team_id?: string | null;
3243
3252
  created_at: number;
@@ -3730,10 +3739,19 @@ export class DeeplineClient {
3730
3739
  }
3731
3740
 
3732
3741
  /** Who can open a view: its workspace, every org member, or anyone with its URL. */
3733
- async setViewAccess(id: string, access: ViewAccess): Promise<View> {
3742
+ async setViewAccess(
3743
+ id: string,
3744
+ access: ViewAccess,
3745
+ options?: { embedOrigins?: string[] },
3746
+ ): Promise<View> {
3734
3747
  return await this.http.post<View>(
3735
3748
  `/api/v2/views/${encodeURIComponent(id)}/access`,
3736
- { access },
3749
+ {
3750
+ access,
3751
+ ...(options?.embedOrigins !== undefined
3752
+ ? { embed_origins: options.embedOrigins }
3753
+ : {}),
3754
+ },
3737
3755
  );
3738
3756
  }
3739
3757
 
@@ -205,7 +205,7 @@ export const SDK_RELEASE = {
205
205
  // getters keep their established compatibility behavior.
206
206
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
207
207
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
208
- version: '0.3.578',
208
+ version: '0.3.580',
209
209
  updateSummary: {
210
210
  introducedIn: '0.3.90',
211
211
  summary:
@@ -1,4 +1,10 @@
1
+ import { quoteMonitorCustomerCharge } from '@deepline/monitors/billing/charges';
2
+ import { monitorUnitCredits } from '@deepline/monitors/billing/pricing';
1
3
  import type {
4
+ MonitorBillingPhase,
5
+ MonitorRunMoney,
6
+ MonitorRunPrice,
7
+ MonitorRunPricing,
2
8
  MonitorBillingPolicy,
3
9
  MonitorPayloadPricingEntry,
4
10
  MonitorPayloadPricingMode,
@@ -6,7 +12,7 @@ import type {
6
12
 
7
13
  export type PublicMonitorPricing = {
8
14
  mode: MonitorPayloadPricingMode;
9
- billing_basis: 'per_accepted_event' | 'recurring';
15
+ billing_basis: 'per_accepted_event' | 'per_completed_run' | 'recurring';
10
16
  deepline_credits: number;
11
17
  unit: string;
12
18
  charge_timing: string;
@@ -14,11 +20,57 @@ export type PublicMonitorPricing = {
14
20
  display: string;
15
21
  };
16
22
 
17
- export type PublicResolvedMonitorPricing = PublicMonitorPricing & {
18
- discriminator: string;
19
- selection: string;
23
+ /** The account a monitor's provider calls run in (the binding's `credential_lane`). */
24
+ export type MonitorCredentialLane = 'deepline_managed' | 'customer_key';
25
+
26
+ /** One run a pay-per-run monitor's price tables list. */
27
+ export type PublicMonitorRunPrice = {
28
+ label: string;
29
+ deepline_credits: number;
30
+ };
31
+
32
+ /**
33
+ * Everything one monitor charges over its life, in Deepline credits (never
34
+ * provider spend), read from its billing policy: per accepted finding, per
35
+ * completed run, once on deploy, and per period while active. One monitor
36
+ * tracks one contact, company, feed or query, so a per-period charge is per
37
+ * tracked entity. A null amount settles from provider usage and is not known
38
+ * in advance.
39
+ */
40
+ export type PublicMonitorChargeSchedule = {
41
+ /** Per accepted finding (per result). */
42
+ per_result_credits: number | null;
43
+ /**
44
+ * Per completed run, for a monitor billed per run (External Monitors),
45
+ * including runs that find nothing new. Null when the monitor is not billed
46
+ * per run, or when no payload picks the run's size (see `per_run_options`).
47
+ */
48
+ per_run_credits: number | null;
49
+ /** The runs a pay-per-run monitor's price tables list, when no payload picks one. */
50
+ per_run_options?: PublicMonitorRunPrice[];
51
+ /** Once when the monitor is deployed. */
52
+ on_deploy_credits: number | null;
53
+ /** Once when a suspended monitor is reactivated (quoted on its own phase). */
54
+ on_reactivate_credits: number | null;
55
+ /** Recurring charge per monitor while it is active; null when there is none. */
56
+ per_period: { deepline_credits: number | null; period_days: number } | null;
57
+ /** The charges above in one sentence, for agents (CLI and API). */
58
+ display: string;
59
+ /**
60
+ * The same price in a few words, for people on the website (dashboard and
61
+ * docs): "6.5 credits per finding", "0.34 credits per run (…)", "BYOK",
62
+ * "Compute only".
63
+ */
64
+ display_short: string;
20
65
  };
21
66
 
67
+ export type PublicResolvedMonitorPricing = PublicMonitorPricing &
68
+ Partial<PublicMonitorChargeSchedule> & {
69
+ /** The payload field and value that picked this price (a radar type). */
70
+ discriminator?: string;
71
+ selection?: string;
72
+ };
73
+
22
74
  function formatCredits(credits: number) {
23
75
  return `${credits.toLocaleString('en')} Deepline ${
24
76
  credits === 1 ? 'credit' : 'credits'
@@ -52,21 +104,424 @@ export function publicMonitorPricingEntry(
52
104
  };
53
105
  }
54
106
 
55
- /** Resolve the selected payload price without exposing provider cost inputs. */
107
+ function quotedCredits(input: {
108
+ policy: MonitorBillingPolicy;
109
+ phases: readonly MonitorBillingPhase[];
110
+ providerCostKey?: string;
111
+ }): number | null {
112
+ let total = 0;
113
+ for (const phase of input.phases) {
114
+ const quote = quoteMonitorCustomerCharge({
115
+ policy: input.policy,
116
+ phase,
117
+ providerCostKey: input.providerCostKey,
118
+ });
119
+ if (quote.pendingProviderCostKeys.length > 0) return null;
120
+ total += quote.knownCredits;
121
+ }
122
+ return total;
123
+ }
124
+
125
+ const EVENT_PHASES: readonly MonitorBillingPhase[] = [
126
+ 'webhook_event',
127
+ 'provider_execution',
128
+ ];
129
+
130
+ /** The phase a completed run is charged in, as the live webhook charge quotes it. */
131
+ const RUN_PHASES: readonly MonitorBillingPhase[] = ['webhook_event'];
132
+
133
+ /** The event charges that carry a price, with how many priced components each has. */
134
+ function pricedCharges(input: {
135
+ policy: MonitorBillingPolicy;
136
+ phases: readonly MonitorBillingPhase[];
137
+ providerCostKey?: string;
138
+ }) {
139
+ return input.policy.customerUsageCharges
140
+ .filter((charge) => input.phases.includes(charge.phase))
141
+ .map((charge) => ({
142
+ basis: charge.basis,
143
+ priced: charge.components.filter(
144
+ (component) =>
145
+ component.kind === 'fixed_deepline_credits' ||
146
+ (component.kind === 'upstream_cost_markup' &&
147
+ (!input.providerCostKey ||
148
+ component.providerCostKey === input.providerCostKey)),
149
+ ).length,
150
+ }))
151
+ .filter((charge) => charge.priced > 0);
152
+ }
153
+
154
+ /**
155
+ * Credits for one completed run of `payload`, exactly as its webhook charge
156
+ * bills it; null when the payload names no priceable run.
157
+ */
158
+ function runCredits(input: {
159
+ unitCredits: number;
160
+ run: MonitorRunPricing;
161
+ payload: Record<string, unknown>;
162
+ }): number | null {
163
+ const units = input.run.units(input.payload);
164
+ return units === null ? null : monitorUnitCredits(input.unitCredits, units);
165
+ }
166
+
167
+ /**
168
+ * The charge schedule of a monitor, from the same quotes the live charges
169
+ * use. `entry` selects one payload-priced option (a radar type); without it,
170
+ * every charge of the policy counts.
171
+ *
172
+ * A pay-per-run monitor (`run`, from its capability's catalog) is priced per
173
+ * completed run: one usage unit's quote times the units its own counter gives
174
+ * for `payload`, which is the counter its webhook charge calls, so a quote
175
+ * cannot drift from a charge. Without a payload it lists `run.examples`. A
176
+ * `credential: "byok"` payload on a policy whose customer-key lane is free
177
+ * costs nothing.
178
+ *
179
+ * Null when an event has no single price and no run counter: a charge per
180
+ * usage unit (`basis`) or several alternative prices the event type picks
181
+ * between (Findymail, TheirStack). Those keep their own pricing presentation.
182
+ */
183
+ export function publicMonitorChargeSchedule(input: {
184
+ policy: MonitorBillingPolicy;
185
+ entry?: MonitorPayloadPricingEntry;
186
+ run?: MonitorRunPricing;
187
+ payload?: Record<string, unknown> | null;
188
+ /**
189
+ * The lane the monitor runs (or would run) in, when known: a check resolves
190
+ * it the way deploy does and a deployed monitor pins it on its binding.
191
+ * Without it, only an explicit `credential: "byok"` reads as the customer's
192
+ * key.
193
+ */
194
+ credentialLane?: MonitorCredentialLane | null;
195
+ }): PublicMonitorChargeSchedule | null {
196
+ const { policy, run, payload } = input;
197
+ const providerCostKey = input.entry?.providerCostKey;
198
+ const onDeploy = quotedCredits({
199
+ policy,
200
+ phases: ['create'],
201
+ providerCostKey,
202
+ });
203
+ const onReactivate = quotedCredits({
204
+ policy,
205
+ phases: ['reactivate'],
206
+ providerCostKey,
207
+ });
208
+ const perPeriodCredits = quotedCredits({
209
+ policy,
210
+ phases: ['subscription_renewal', 'periodic_renewal'],
211
+ providerCostKey,
212
+ });
213
+ const recurring = policy.providerChargeComponents.find(
214
+ (component) => component.kind === 'provider_recurring_period',
215
+ );
216
+ const periodDays =
217
+ input.entry?.periodDays ??
218
+ (recurring?.kind === 'provider_recurring_period'
219
+ ? recurring.periodDays
220
+ : 30);
221
+ const perPeriod =
222
+ perPeriodCredits === 0
223
+ ? null
224
+ : { deepline_credits: perPeriodCredits, period_days: periodDays };
225
+ const freeOnCustomerKey = policy.customerKeyLaneCharge === 'none';
226
+ // The webhook charge is waived on the binding's customer-key lane, so the
227
+ // quote follows the effective lane, not only what the payload spelled out.
228
+ const onCustomerKey =
229
+ freeOnCustomerKey &&
230
+ (input.credentialLane
231
+ ? input.credentialLane === 'customer_key'
232
+ : payload?.credential === 'byok');
233
+
234
+ let perResult: number | null = 0;
235
+ let perRun: number | null = null;
236
+ let runOptions: PublicMonitorRunPrice[] | undefined;
237
+ let runPrice: MonitorRunPrice | undefined;
238
+ if (run) {
239
+ const charges = pricedCharges({ policy, phases: RUN_PHASES });
240
+ if (charges.length !== 1 || charges[0]!.priced !== 1) {
241
+ throw new Error(
242
+ `Pay-per-run monitor ${policy.providerCapability} needs exactly one priced usage unit per run.`,
243
+ );
244
+ }
245
+ const unitCredits = quotedCredits({ policy, phases: RUN_PHASES });
246
+ if (unitCredits === null) return null;
247
+ runPrice = (examplePayload) => {
248
+ const credits = runCredits({ unitCredits, run, payload: examplePayload });
249
+ if (credits === null) {
250
+ throw new Error(
251
+ `Pay-per-run monitor ${policy.providerCapability} cannot price a run its website wording names.`,
252
+ );
253
+ }
254
+ return credits;
255
+ };
256
+ if (payload) {
257
+ perRun = onCustomerKey ? 0 : runCredits({ unitCredits, run, payload });
258
+ // No priceable run in this payload: no price, never "free".
259
+ if (perRun === null) return null;
260
+ } else {
261
+ runOptions = run.examples.map((example) => {
262
+ const credits = runCredits({
263
+ unitCredits,
264
+ run,
265
+ payload: example.payload,
266
+ });
267
+ if (credits === null) {
268
+ throw new Error(
269
+ `Pay-per-run monitor ${policy.providerCapability} lists run "${example.label}" that its run counter cannot price.`,
270
+ );
271
+ }
272
+ return { label: example.label, deepline_credits: credits };
273
+ });
274
+ }
275
+ } else {
276
+ const charges = pricedCharges({
277
+ policy,
278
+ phases: EVENT_PHASES,
279
+ providerCostKey,
280
+ });
281
+ if (
282
+ charges.some((charge) => charge.basis) ||
283
+ charges.reduce((total, charge) => total + charge.priced, 0) > 1
284
+ ) {
285
+ return null;
286
+ }
287
+ perResult = onCustomerKey
288
+ ? 0
289
+ : quotedCredits({ policy, phases: EVENT_PHASES, providerCostKey });
290
+ }
291
+
292
+ const unitEvent = input.entry ? `${input.entry.unitLabel} event` : 'event';
293
+ const amount = (credits: number | null) =>
294
+ credits === null
295
+ ? 'A price set from provider usage'
296
+ : formatCredits(credits);
297
+ // The rates price any configuration; the examples show common ones.
298
+ const runRate =
299
+ run && runPrice
300
+ ? run.website.rate(runPrice, {
301
+ amount: (credits) => credits.toLocaleString('en'),
302
+ unit: ' Deepline credits',
303
+ })
304
+ : null;
305
+ const runCharge = runOptions
306
+ ? `Per completed run, even one that finds nothing new: ${runRate}. For example: ${runOptions
307
+ .map(
308
+ (option, index) =>
309
+ `${
310
+ index === 0
311
+ ? formatCredits(option.deepline_credits)
312
+ : option.deepline_credits.toLocaleString('en')
313
+ } for ${option.label}`,
314
+ )
315
+ .join('; ')}`
316
+ : perRun
317
+ ? `${amount(perRun)} per completed run, even one that finds nothing new`
318
+ : null;
319
+ const charges = [
320
+ perResult === 0 ? null : `${amount(perResult)} per accepted ${unitEvent}`,
321
+ runCharge,
322
+ ...(onDeploy === onReactivate
323
+ ? [
324
+ onDeploy === 0
325
+ ? null
326
+ : `${amount(onDeploy)} on deploy or reactivation`,
327
+ ]
328
+ : [
329
+ onDeploy === 0 ? null : `${amount(onDeploy)} on deploy`,
330
+ onReactivate === 0 ? null : `${amount(onReactivate)} on reactivation`,
331
+ ]),
332
+ perPeriod
333
+ ? `${amount(perPeriod.deepline_credits)} per monitor every ${periodDays} days while active`
334
+ : null,
335
+ ].filter((charge) => charge !== null);
336
+ const uncharged = [
337
+ onDeploy === 0 && onReactivate === 0 ? 'deploy' : null,
338
+ perPeriod ? null : 'recurring',
339
+ ].filter((charge) => charge !== null);
340
+ const customerKeyNote =
341
+ freeOnCustomerKey && !onCustomerKey && charges.length > 0
342
+ ? ' No Deepline charge on your own provider key (credential "byok"); the provider bills you.'
343
+ : '';
344
+ const display = onCustomerKey
345
+ ? 'No Deepline charge: it runs on your own provider key, and the provider bills you.'
346
+ : charges.length === 0
347
+ ? 'No monitor charge: only the compute its events use is billed.'
348
+ : `${charges.join('. ')}.${uncharged.length ? ` No ${uncharged.join(' or ')} charge.` : ''}${customerKeyNote}`;
349
+ return {
350
+ per_result_credits: perResult,
351
+ per_run_credits: perRun,
352
+ ...(runOptions ? { per_run_options: runOptions } : {}),
353
+ on_deploy_credits: onDeploy,
354
+ on_reactivate_credits: onReactivate,
355
+ per_period: perPeriod,
356
+ display,
357
+ display_short: shortDisplay({
358
+ onCustomerKey,
359
+ free: charges.length === 0,
360
+ perResult,
361
+ unit: input.entry?.unitLabel ?? 'event',
362
+ run,
363
+ runPrice,
364
+ runOptions,
365
+ perRun,
366
+ payload,
367
+ onDeploy,
368
+ onReactivate,
369
+ perPeriod,
370
+ }),
371
+ };
372
+ }
373
+
374
+ /**
375
+ * A pay-per-run monitor's run price function on the managed lane: one usage
376
+ * unit's quote times the units its counter gives a payload, the math the
377
+ * webhook charge uses. Null when the policy has no single per-run unit price.
378
+ */
379
+ export function monitorRunPrice(input: {
380
+ policy: MonitorBillingPolicy;
381
+ run: MonitorRunPricing;
382
+ }): MonitorRunPrice | null {
383
+ const unitCredits = quotedCredits({
384
+ policy: input.policy,
385
+ phases: RUN_PHASES,
386
+ });
387
+ if (unitCredits === null) return null;
388
+ return (payload) => {
389
+ const credits = runCredits({ unitCredits, run: input.run, payload });
390
+ if (credits === null) {
391
+ throw new Error(
392
+ `Pay-per-run monitor ${input.policy.providerCapability} cannot price a run its website wording names.`,
393
+ );
394
+ }
395
+ return credits;
396
+ };
397
+ }
398
+
399
+ /** A credit amount as the website writes it: "0.04", "6.5", "1,000". */
400
+ function shortCredits(credits: number): string {
401
+ return Number(credits.toFixed(6)).toLocaleString('en', {
402
+ maximumFractionDigits: 4,
403
+ });
404
+ }
405
+
406
+ const SHORT_CREDITS: MonitorRunMoney = {
407
+ amount: shortCredits,
408
+ unit: ' credits',
409
+ };
410
+
411
+ /** The website's few-word price: the schedule's charges, nothing else. */
412
+ function shortDisplay(input: {
413
+ onCustomerKey: boolean;
414
+ free: boolean;
415
+ perResult: number | null;
416
+ unit: string;
417
+ run?: MonitorRunPricing;
418
+ runPrice?: MonitorRunPrice;
419
+ runOptions?: PublicMonitorRunPrice[];
420
+ perRun: number | null;
421
+ payload?: Record<string, unknown> | null;
422
+ onDeploy: number | null;
423
+ onReactivate: number | null;
424
+ perPeriod: PublicMonitorChargeSchedule['per_period'];
425
+ }): string {
426
+ if (input.onCustomerKey) return 'BYOK';
427
+ if (input.free) return 'Compute only';
428
+ const amount = (credits: number | null) =>
429
+ credits === null ? 'Usage-based' : `${shortCredits(credits)} credits`;
430
+ const parts: string[] = [];
431
+ if (input.perResult)
432
+ parts.push(`${amount(input.perResult)} per ${input.unit}`);
433
+ if (input.run && input.runPrice) {
434
+ if (input.runOptions) {
435
+ parts.push(input.run.website.rate(input.runPrice, SHORT_CREDITS));
436
+ } else if (input.perRun && input.payload) {
437
+ parts.push(
438
+ `${amount(input.perRun)} per run (${input.run.website.run(input.payload, input.runPrice, SHORT_CREDITS)})`,
439
+ );
440
+ }
441
+ }
442
+ if (input.onDeploy === input.onReactivate) {
443
+ if (input.onDeploy)
444
+ parts.push(`${amount(input.onDeploy)} on deploy or reactivation`);
445
+ } else {
446
+ if (input.onDeploy) parts.push(`${amount(input.onDeploy)} on deploy`);
447
+ if (input.onReactivate)
448
+ parts.push(`${amount(input.onReactivate)} on reactivation`);
449
+ }
450
+ if (input.perPeriod) {
451
+ parts.push(
452
+ `${amount(input.perPeriod.deepline_credits)} every ${input.perPeriod.period_days} days`,
453
+ );
454
+ }
455
+ return parts.join('; ');
456
+ }
457
+
458
+ /**
459
+ * A monitor's public price for one deploy payload, or for its type when the
460
+ * payload is absent: the selected radar type's price plus the whole charge
461
+ * schedule, a pay-per-run monitor's run price, or the plain schedule. Every
462
+ * surface that shows a monitor's price reads it here, so none can drift from
463
+ * what the monitor charges. Undefined when there is no price to show.
464
+ */
56
465
  export function resolvePublicMonitorPricing(input: {
57
466
  policy: MonitorBillingPolicy | null | undefined;
58
467
  payload: Record<string, unknown> | null | undefined;
468
+ /** The capability's `catalog.run`, for a monitor billed per completed run. */
469
+ run?: MonitorRunPricing;
470
+ /** The effective credential lane, when known (see `publicMonitorChargeSchedule`). */
471
+ credentialLane?: MonitorCredentialLane | null;
59
472
  }): PublicResolvedMonitorPricing | undefined {
60
- const pricing = input.policy?.payloadPricing;
61
- if (!pricing || !input.payload) return undefined;
62
- const rawSelection = input.payload[pricing.discriminator];
63
- if (typeof rawSelection !== 'string') return undefined;
64
- const selection = rawSelection.trim();
65
- const entry = pricing.entries[selection];
66
- if (!selection || !entry) return undefined;
473
+ const { policy, payload, run, credentialLane } = input;
474
+ if (!policy) return undefined;
475
+ const pricing = policy.payloadPricing;
476
+ if (pricing) {
477
+ if (!payload) return undefined;
478
+ const rawSelection = payload[pricing.discriminator];
479
+ if (typeof rawSelection !== 'string') return undefined;
480
+ const selection = rawSelection.trim();
481
+ const entry = pricing.entries[selection];
482
+ if (!entry) return undefined;
483
+ return {
484
+ discriminator: pricing.discriminator,
485
+ selection,
486
+ ...publicMonitorPricingEntry(entry),
487
+ ...publicMonitorChargeSchedule({
488
+ policy,
489
+ entry,
490
+ payload,
491
+ credentialLane,
492
+ }),
493
+ };
494
+ }
495
+ const schedule = publicMonitorChargeSchedule({
496
+ policy,
497
+ run,
498
+ payload,
499
+ credentialLane,
500
+ });
501
+ if (!schedule) return undefined;
502
+ if (run) {
503
+ // The type's cheapest listed run when no payload picks one.
504
+ const credits =
505
+ schedule.per_run_credits ??
506
+ schedule.per_run_options?.[0]?.deepline_credits ??
507
+ null;
508
+ if (credits === null) return undefined;
509
+ return {
510
+ mode: 'monitor_usage',
511
+ billing_basis: 'per_completed_run',
512
+ deepline_credits: credits,
513
+ unit: 'run',
514
+ charge_timing: 'for each completed run',
515
+ ...schedule,
516
+ };
517
+ }
518
+ if (schedule.per_result_credits === null) return undefined;
67
519
  return {
68
- discriminator: pricing.discriminator,
69
- selection,
70
- ...publicMonitorPricingEntry(entry),
520
+ mode: 'monitor_usage',
521
+ billing_basis: 'per_accepted_event',
522
+ deepline_credits: schedule.per_result_credits,
523
+ unit: 'event',
524
+ charge_timing: 'for each accepted provider event',
525
+ ...schedule,
71
526
  };
72
527
  }
@@ -47,6 +47,18 @@ export const TAMRADAR_RADAR_TYPE_PRICING = {
47
47
  providerCostUsd: 0.03,
48
48
  unitLabel: 'finding',
49
49
  },
50
+ // Source: TAMRadar per-update pricing (confidential/internal), measured on
51
+ // the dev account 2026-11-30 (PR #11756): five company_funding_rounds
52
+ // findings, the only updates in the window, debited $0.50. Launched in beta
53
+ // 2026-11; same content as industry funding rounds.
54
+ // https://docs.tamradar.com/webhooks/company/funding-rounds
55
+ company_funding_rounds: {
56
+ capability: 'company_radar',
57
+ label: 'Company funding rounds',
58
+ mode: 'monitor_usage',
59
+ providerCostUsd: 0.1,
60
+ unitLabel: 'finding',
61
+ },
50
62
  // Source: TAMRadar per-update pricing (confidential/internal),
51
63
  // https://tamradar.mintlify.app/api-reference/create-company-radar (social_posts).
52
64
  company_social_posts: {
@@ -104,6 +104,65 @@ export type MonitorPayloadPricingMap = {
104
104
  entries: Record<string, MonitorPayloadPricingEntry>;
105
105
  };
106
106
 
107
+ /**
108
+ * How a pay-per-run monitor (one charge per completed run, sized by its
109
+ * payload) is priced. `units` is the function its webhook charge calls on the
110
+ * stored payload, so a quote and a charge count the same units.
111
+ */
112
+ export type MonitorRunPricing = {
113
+ /**
114
+ * Usage units one completed run of this deploy payload bills, or null when
115
+ * the payload names no run that can be priced (an invalid definition, which
116
+ * `check` still prices beside its validation errors).
117
+ */
118
+ units: (payload: Record<string, unknown>) => number | null;
119
+ /** Runs the price tables list, cheapest first, each with a payload that makes it. */
120
+ examples: readonly {
121
+ label: string;
122
+ payload: Record<string, unknown>;
123
+ }[];
124
+ /**
125
+ * Short, human-facing wording for the website (dashboard and docs). The CLI
126
+ * and API keep the full sentence. Every amount comes from `price`, which
127
+ * prices a payload through `units`, so the wording cannot drift from what a
128
+ * run is charged.
129
+ */
130
+ website: {
131
+ /** The type's rate, e.g. "0.04 credits for 10 results, then 0.02 per additional result". */
132
+ rate: (price: MonitorRunPrice, money: MonitorRunMoney) => string;
133
+ /** The dashboard pricing page's line under the cheapest run's price. */
134
+ catalogNote: (price: MonitorRunPrice, money: MonitorRunMoney) => string;
135
+ /** What one configured run is, shown after its per-run price. */
136
+ run: (
137
+ payload: Record<string, unknown>,
138
+ price: MonitorRunPrice,
139
+ money: MonitorRunMoney,
140
+ ) => string;
141
+ /** Rows of the docs and rate-card price tables. */
142
+ table: (price: MonitorRunPrice) => readonly MonitorRunTableRow[];
143
+ };
144
+ };
145
+
146
+ /** Credits for one completed run of a payload, as its webhook charge bills it. */
147
+ export type MonitorRunPrice = (payload: Record<string, unknown>) => number;
148
+
149
+ /** How amounts are written: credits ("0.04", unit " credits") or dollars ("$0.004", unit ""). */
150
+ export type MonitorRunMoney = {
151
+ amount: (credits: number) => string;
152
+ unit: string;
153
+ };
154
+
155
+ export type MonitorRunTableRow = {
156
+ label: string;
157
+ credits: number;
158
+ /** Added to a run's price rather than a run's whole price. */
159
+ increment?: boolean;
160
+ /** Appended to the amount, e.g. "per result". */
161
+ per?: string;
162
+ /** The rate card's billing basis column. */
163
+ basis: string;
164
+ };
165
+
107
166
  export type MonitorProviderTruthSource =
108
167
  | 'provider_response'
109
168
  | 'provider_webhook'
@@ -1,4 +1,5 @@
1
1
  import { MONITOR_FLEET_MAX_MEMBERS } from '../integration-contracts/monitor-fleet-contract';
2
+ import type { MonitorRunPricing } from '@deepline/monitors/billing/types';
2
3
  import {
3
4
  monitorSdkIssue,
4
5
  type MonitorSdkValidationIssue,
@@ -25,10 +26,11 @@ export type ProviderMonitorCatalogListing = {
25
26
  /** The same per radar type, for a capability whose variants are listed separately. */
26
27
  variants?: Readonly<Record<string, { label: string; summary: string }>>;
27
28
  /**
28
- * A pay-per-search monitor's cheapest completed run: how many of its
29
- * billing policy's usage units one run costs, and what to call that run.
29
+ * A pay-per-run monitor's run pricing: the usage units one completed run of
30
+ * a deploy payload bills (the same count its webhook charge uses), and the
31
+ * runs price tables list, cheapest first.
30
32
  */
31
- run?: { units: number; label: string };
33
+ run?: MonitorRunPricing;
32
34
  };
33
35
 
34
36
  export type ProviderMonitorSubjectPathCandidate = {
@@ -1858,9 +1858,11 @@ async function createEarlyModalSandbox(
1858
1858
  },
1859
1859
  ): Promise<EarlyModalSandboxEntry> {
1860
1860
  const { key, orgId, hintAtMs } = input;
1861
+ // The run's own limits when the hint carried them, so the create, its
1862
+ // limitsKey, the pre-boot runner and the PX plan match the launch's.
1861
1863
  const modalConfig = await loadModalRequiredConfig({
1862
1864
  runtimeSchedulerSchema: input.runtimeSchedulerSchema,
1863
- limits: null,
1865
+ limits: input.sandboxRuntimeLimits ?? null,
1864
1866
  });
1865
1867
  const supervisorSidecar = DURABLE_RUNS_ROLLOUT.modalSupervisorSidecar;
1866
1868
  const memoryPolicy = resolveModalSandboxMemoryPolicy({