mcp-scraper 0.38.2 → 0.40.1

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 (111) hide show
  1. package/README.md +5 -2
  2. package/package.json +5 -6
  3. package/dist/bin/api-server.cjs +0 -58752
  4. package/dist/bin/api-server.cjs.map +0 -1
  5. package/dist/bin/api-server.d.cts +0 -1
  6. package/dist/bin/api-server.d.ts +0 -1
  7. package/dist/bin/api-server.js +0 -38
  8. package/dist/bin/api-server.js.map +0 -1
  9. package/dist/bin/mcp-scraper-cli.cjs +0 -2671
  10. package/dist/bin/mcp-scraper-cli.cjs.map +0 -1
  11. package/dist/bin/mcp-scraper-cli.d.cts +0 -1
  12. package/dist/bin/mcp-scraper-cli.d.ts +0 -1
  13. package/dist/bin/mcp-scraper-cli.js +0 -742
  14. package/dist/bin/mcp-scraper-cli.js.map +0 -1
  15. package/dist/bin/mcp-scraper-install.cjs +0 -129
  16. package/dist/bin/mcp-scraper-install.cjs.map +0 -1
  17. package/dist/bin/mcp-scraper-install.d.cts +0 -1
  18. package/dist/bin/mcp-scraper-install.d.ts +0 -1
  19. package/dist/bin/mcp-scraper-install.js +0 -27
  20. package/dist/bin/mcp-scraper-install.js.map +0 -1
  21. package/dist/bin/mcp-stdio-server.cjs +0 -12264
  22. package/dist/bin/mcp-stdio-server.cjs.map +0 -1
  23. package/dist/bin/mcp-stdio-server.d.cts +0 -1
  24. package/dist/bin/mcp-stdio-server.d.ts +0 -1
  25. package/dist/bin/mcp-stdio-server.js +0 -135
  26. package/dist/bin/mcp-stdio-server.js.map +0 -1
  27. package/dist/bin/paa-harvest.cjs +0 -3808
  28. package/dist/bin/paa-harvest.cjs.map +0 -1
  29. package/dist/bin/paa-harvest.d.cts +0 -1
  30. package/dist/bin/paa-harvest.d.ts +0 -1
  31. package/dist/bin/paa-harvest.js +0 -44
  32. package/dist/bin/paa-harvest.js.map +0 -1
  33. package/dist/chunk-345BQXZH.js +0 -712
  34. package/dist/chunk-345BQXZH.js.map +0 -1
  35. package/dist/chunk-44HZLHDV.js +0 -52
  36. package/dist/chunk-44HZLHDV.js.map +0 -1
  37. package/dist/chunk-AZRPG43B.js +0 -617
  38. package/dist/chunk-AZRPG43B.js.map +0 -1
  39. package/dist/chunk-CB5C3BPB.js +0 -135
  40. package/dist/chunk-CB5C3BPB.js.map +0 -1
  41. package/dist/chunk-EGJKUB4Q.js +0 -276
  42. package/dist/chunk-EGJKUB4Q.js.map +0 -1
  43. package/dist/chunk-FQI5PFE7.js +0 -1866
  44. package/dist/chunk-FQI5PFE7.js.map +0 -1
  45. package/dist/chunk-FRYT3ID4.js +0 -684
  46. package/dist/chunk-FRYT3ID4.js.map +0 -1
  47. package/dist/chunk-G3P3ZDB4.js +0 -69
  48. package/dist/chunk-G3P3ZDB4.js.map +0 -1
  49. package/dist/chunk-K443GQY5.js +0 -24
  50. package/dist/chunk-K443GQY5.js.map +0 -1
  51. package/dist/chunk-N7KUTTCC.js +0 -3007
  52. package/dist/chunk-N7KUTTCC.js.map +0 -1
  53. package/dist/chunk-NGM237OO.js +0 -3410
  54. package/dist/chunk-NGM237OO.js.map +0 -1
  55. package/dist/chunk-NKCCGADE.js +0 -11285
  56. package/dist/chunk-NKCCGADE.js.map +0 -1
  57. package/dist/chunk-NNW3O6ZD.js +0 -108
  58. package/dist/chunk-NNW3O6ZD.js.map +0 -1
  59. package/dist/chunk-QZXKQB7Y.js +0 -414
  60. package/dist/chunk-QZXKQB7Y.js.map +0 -1
  61. package/dist/chunk-SFRMFGQ6.js +0 -158
  62. package/dist/chunk-SFRMFGQ6.js.map +0 -1
  63. package/dist/chunk-YCI2PNCS.js +0 -499
  64. package/dist/chunk-YCI2PNCS.js.map +0 -1
  65. package/dist/chunk-YODBNTTN.js +0 -7
  66. package/dist/chunk-YODBNTTN.js.map +0 -1
  67. package/dist/db-C5KVCOYT.js +0 -239
  68. package/dist/db-C5KVCOYT.js.map +0 -1
  69. package/dist/extract-bundle-KUBX6N6Z.js +0 -568
  70. package/dist/extract-bundle-KUBX6N6Z.js.map +0 -1
  71. package/dist/index.cjs +0 -4160
  72. package/dist/index.cjs.map +0 -1
  73. package/dist/index.d.cts +0 -413
  74. package/dist/index.d.ts +0 -413
  75. package/dist/index.js +0 -338
  76. package/dist/index.js.map +0 -1
  77. package/dist/location-data-repository-TTWF3OTM.js +0 -35
  78. package/dist/location-data-repository-TTWF3OTM.js.map +0 -1
  79. package/dist/server-5EX6XBIA.js +0 -33596
  80. package/dist/server-5EX6XBIA.js.map +0 -1
  81. package/dist/site-extract-repository-XSPJTCIL.js +0 -62
  82. package/dist/site-extract-repository-XSPJTCIL.js.map +0 -1
  83. package/dist/worker-XCPU4YSN.js +0 -142
  84. package/dist/worker-XCPU4YSN.js.map +0 -1
  85. package/docs/adr/0001-in-page-graphql-interception-for-anti-bot-scraping.md +0 -58
  86. package/docs/adr/0002-hybrid-smart-rag-vault-retrieval.md +0 -62
  87. package/docs/adr/0003-waive-unrecoverable-scheduled-model-cost.md +0 -22
  88. package/docs/adr/README.md +0 -13
  89. package/docs/final-tooling-spec.md +0 -206
  90. package/docs/hosted-location-data.md +0 -108
  91. package/docs/kernel-proxy-future-enhancements.md +0 -80
  92. package/docs/mcp-tool-craft-lint.generated.md +0 -183
  93. package/docs/mcp-tool-design-guide.md +0 -225
  94. package/docs/mcp-tool-manifest.generated.json +0 -22871
  95. package/docs/mcp-tool-quality-spec.md +0 -240
  96. package/docs/oauth-legal-review.md +0 -38
  97. package/docs/seo-crawl-report-spec.md +0 -287
  98. package/docs/specs/api-forge-spec.md +0 -234
  99. package/docs/specs/connected-services-control-plane-decoupling-spec.md +0 -1044
  100. package/docs/specs/deferred-work-spec.md +0 -86
  101. package/docs/specs/google-drive-bulk-access-and-mcp-schema-passthrough-spec.md +0 -1689
  102. package/docs/specs/kernel-stealth-captcha-test-matrix.md +0 -278
  103. package/docs/specs/main-mcp-integration-ownership-spec.md +0 -1164
  104. package/docs/specs/mcp-tool-definition-quality-audit-spec.md +0 -1602
  105. package/docs/specs/meta-ad-creative-media-resolution-spec.md +0 -31
  106. package/docs/specs/multimodal-image-memory-architecture-spec.md +0 -1022
  107. package/docs/specs/oauth-mcp-spec.md +0 -213
  108. package/docs/specs/query-fanout-transport-contract-fix.md +0 -45
  109. package/docs/specs/relationship-workspace-ai-behavior-plan.md +0 -26
  110. package/docs/specs/unified-credit-and-scheduled-execution-billing-spec.md +0 -995
  111. package/docs/tool-catalog-spec.md +0 -388
@@ -1,995 +0,0 @@
1
- # Unified Credits, Integrations, and Scheduled Execution Billing
2
-
3
- - Status: Released scheduled-execution contract plus approved connected-account v2 contract
4
- - Spec date: 2026-07-15
5
- - Primary repos: mcp-scraper, mcp-scraper-scheduler, mcpscraper-web, mcpscraper-sdk
6
- - Commercial decision: Scheduled Actions is a product capability, not a separate subscription
7
- - Connected-account decision: each active Nango connection is a $3/month add-on; usage is metered in Credits
8
- - Accounting decision: MCP Scraper's main credit ledger is the only debit authority
9
-
10
- ## Executive decision
11
-
12
- MCP Scraper will use one visible usage currency: Credits.
13
-
14
- Scheduled Actions uses the same Credit wallet as the rest of MCP Scraper. It is no longer sold as a separate $10-per-month product with a 1,000-run quota. Connected accounts are commercial add-ons: each active Nango connection costs $3 per month, and provider usage is settled from the shared Credit wallet using authoritative receipts.
15
-
16
- The replacement contract is:
17
-
18
- 1. Every paid MCP Scraper plan includes access to scheduling and the ability to add connected accounts.
19
- 2. OAuth connect and reconnect cost 0 Credits. Each active Nango connection is a separate $3-per-month recurring add-on, prorated by the subscription system.
20
- 3. Each scheduled occurrence that passes the balance check and begins execution costs 75 Credits exactly once.
21
- 4. A deterministic `connection_sync` occurrence has no model charge beyond that 75-Credit base.
22
- 5. An agent-mode occurrence additionally settles OpenRouter's actual reported model cost, multiplied by 1.5, then converted to Credits.
23
- 6. Token prices may be shown as current per-million-token estimates in Credits, but OpenRouter's reported cost is the settlement truth.
24
- 7. Separately metered scraper, browser, transcription, video-analysis, and similar tools keep their published rate-card prices when a schedule calls them.
25
- 8. Connected usage costs 2 Credits per Nango function run, 2 Credits per Nango Proxy request, and 5 Credits per compute second, prorated from aggregate milliseconds and rounded once up to integer mc.
26
- 9. The older 5/10/15/25-Credit semantic read/write tariff, per-record/byte tariff, and 20,000-Credit active-connection minimum remain retired and are not enabled.
27
-
28
- This design separates the predictable credential-carrying cost from variable work. The $3 recurring line item pays for keeping a Nango connection active; function, Proxy, and compute activity draw from the shared Credit balance. There is no artificial 1,000-run cliff or separate scheduler product.
29
-
30
- ### Released v1 implementation boundary
31
-
32
- - Authorization currently performs an idempotent wallet balance check, not a hard balance reservation.
33
- - The server-side default maximum is 5,000 Credits per run and is environment-configurable; it is not yet editable in the customer UI.
34
- - A missing authoritative model cost moves the schedule to `cost_pending` and pauses it. Automated recovery/reconciliation is still a hardening item.
35
- - The main API accepts idempotent connected-usage receipts and is the settlement authority. The scheduler must preflight at least the fixed 2-Credit function unit, and a prior `cost_pending` connected receipt blocks new work until recovered.
36
- - User-editable monthly caps, auto-refill, hard reservations, and automated Nango-to-ledger reconciliation remain hardening work.
37
-
38
- ## What was found before the v1 cutover
39
-
40
- The originally intended scheduler economics are recognizable in the code, but the implementation is not safe enough to keep.
41
-
42
- ### Confirmed historical behavior
43
-
44
- - Stripe has a $10-per-month Scheduled Actions checkout.
45
- - The webhook grants a scheduling entitlement with a 1,000-run period quota.
46
- - The scheduler contains a 1.5 OpenRouter markup constant.
47
- - The scheduler reads OpenRouter's provider-reported usage cost.
48
- - Scheduled agent execution attempts to record model usage and a pass-through cost.
49
-
50
- So the answer to “was $10 meant to open the feature and then AI cost was marked up 50%?” is: substantially yes. The entitlement and the 50% markup both exist.
51
-
52
- ### Pre-cutover billing defect
53
-
54
- The pre-cutover path did not reliably implement that intended price:
55
-
56
- 1. schedule-execute invokes both meterLlmUsage and billPassThroughCost for the generated result.
57
- 2. Both paths can call recordCost.
58
- 3. recordCost can forward each raw AI cost to the main MCP Scraper AI-debit endpoint.
59
- 4. That endpoint applies the existing 3.0 memory-AI multiplier.
60
- 5. If both HTTP debits succeed, the final-step model cost can therefore produce two 3.0 debits—up to 6.0 times that raw cost—while the scheduler's local usage record describes a 1.5 billable amount.
61
- 6. The current metering client is fail-open, so missing configuration or a failed internal request can instead produce no debit.
62
- 7. The current call uses top-level usage and provider metadata. For a multi-step agent result, this describes the last step, not necessarily the complete run. Earlier model steps can be omitted.
63
-
64
- The scheduler environment had the internal MCP Scraper URL, internal debit secret, and OpenRouter key configured, so this was a real production risk rather than dead local code. The v1 cutover removed the duplicate/fail-open path and now aggregates model-step costs before one settlement.
65
-
66
- ### Required immediate interpretation
67
-
68
- Do not assume existing scheduled-agent charges equal a clean 1.5 markup. Before changing customers or migrating subscriptions, reconcile scheduler usage records against the main credit ledger. Overcharges receive compensating Credits. Historical fail-open undercharges are not collected retroactively.
69
-
70
- ## Canonical Build Spec
71
-
72
- - **Request:** Keep Scheduled Actions on the shared Credit wallet; charge one 75-Credit occurrence base and correctly settle all-step OpenRouter cost at 1.5; add a $3 active-Nango-connection recurring line item plus receipt-based function, Proxy, and millisecond compute usage.
73
- - **Lane:** Mastra Agentic Development plus MCP/API product billing.
74
- - **Capability:** Unified Metered Execution.
75
- - **Audience:** MCP Scraper customers, scheduled-agent users, MCP clients, SDK users, operators, finance, and support.
76
- - **User-Facing Outcome:** A user pays $3/month for each active Nango account, sees connected usage itemized in Credits, optionally schedules work, and receives idempotent receipts without duplicate debits on retries.
77
- - **Target Runtime:** Main MCP Scraper API and credit ledger; Vercel-hosted Mastra scheduler; Inngest workers; Nango connections and Proxy/functions; private Blob artifacts; public MCP; npm/SDK clients.
78
- - **Inputs:** Authenticated identity, connection ID, tool or sync request, scheduled occurrence, model selection, per-run and monthly Credit limits, actual provider results, OpenRouter usage metadata, bytes and records delivered.
79
- - **Agents:** Existing Scheduled Action Agent for interpretive work. Deterministic connection_sync workers remain non-agentic. Both use the same billing context.
80
- - **Workflows:** Connect; direct read/write; bulk export; memory import; schedule estimate; occurrence claim; Credit authorization; execution; incremental settlement; final settlement; receipt; retry/reconciliation.
81
- - **Tools:** Existing generic connected-service tools, provider-native tools, schedule tools, bulk export/import tools, credits_info, a new schedule estimator, and a shared internal billing adapter.
82
- - **MCP:** Credit behavior is transport-independent. Tool descriptions state charge categories and estimates, results include receipt summaries, and exact provider tools remain protected by tenant ownership, action switches, and grants.
83
- - **Signals:** Billing authorization created; connected-use preflight; low balance; budget threshold; cost pending; settlement complete; and insufficient Credits.
84
- - **Background Tasks:** Usage aggregation, connection-minimum settlement, pending-cost reconciliation, low-balance notifications, automatic refill, legacy subscription migration, receipt retention, and rate-snapshot refresh.
85
- - **Guardrails:** Integer microcredit arithmetic, idempotent charges, one debit authority, no model-visible billing credentials, fail closed before externally costly work, action approval independent of price, no prompt or provider credential in billing events.
86
- - **Observability:** Itemized receipt per run; raw vendor cost; multiplier; model/provider; tokens; bytes; changed records; connection and schedule IDs; idempotency keys; authorization, settlement, and refund state.
87
- - **Enforcement:** A call cannot bypass the billing adapter by using Mastra, the generic MCP bridge, direct REST, SDK, Nango, or a background job. Duplicate occurrence or HTTP retry cannot debit twice.
88
- - **Persistence:** The main MCP Scraper/Turso credit ledger owns balances and debits. Scheduler Postgres owns schedule state, occurrence state, and a mirrored receipt reference, not the authoritative wallet.
89
- - **Deployment:** Main API/ledger first, then scheduler and connection adapters, then public MCP, frontend, SDK/npm/MCPB, generated docs, Stripe migration, and Vercel production.
90
- - **Done Contract:** A production scheduled run charges its 75-Credit base once and aggregates every OpenRouter model step once. Every Nango call is preflighted, reports function/Proxy/compute usage under the active rate revision, and settles once in the main ledger. The UI, MCP, API, SDK, and recurring connection quantity publish the same contract.
91
- - **Receipt Requirements:** Code and deployment SHAs; rate-table revision; Stripe migration result; test output; production Vercel IDs; npm/MCPB versions; sample agent and deterministic-sync billing receipts; reconciliation report; public pricing and tool-description parity.
92
-
93
- ## Product contract in plain language
94
-
95
- ### Scheduling is included
96
-
97
- Scheduled Actions remains a first-class page and capability. It is not a separate product, subscription, or quota bundle.
98
-
99
- Users with an active paid plan can create schedules immediately. A future pay-as-you-go activation may use a minimum $10 Credit purchase, but that path is not part of the released v1 contract. If released, the $10 must be a wallet purchase rather than an expiring scheduler access fee.
100
-
101
- Existing scheduled-action subscriptions are migrated; customers do not keep paying a separate scheduler subscription.
102
-
103
- ### Customers pay for a run, not internal loops
104
-
105
- A scheduled occurrence pays:
106
-
107
- 75-Credit execution charge
108
- + 1.5 × actual OpenRouter cost when agent mode uses a model
109
- + any separately metered scraper, browser, transcription,
110
- video-analysis, or other published rate-card tools it calls
111
-
112
- Direct connected-service reads, enabled actions, supported exports, and bounded Memory snapshots report the Nango resources they actually consume: function runs, Proxy requests, and function compute milliseconds. The tool's semantic label does not change those infrastructure rates.
113
-
114
- Internal pagination, retries, leases, and orchestration steps are not separate “runs.” A retry of the same occurrence cannot pay the fixed charge again.
115
-
116
- ### OpenRouter AI costs are transparent
117
-
118
- The customer-facing rule is:
119
-
120
- > AI model use consumes Credits equal to 1.5 times OpenRouter's actual reported cost.
121
-
122
- MCP Scraper may show a model's current input, output, cached-input, image, and audio prices as estimated Credits per unit. Actual settlement always uses OpenRouter's returned usage.cost across every successful model step. This correctly captures routing, cache discounts, reasoning tokens, media, and provider-specific pricing.
123
-
124
- ### Action safety is not for sale
125
-
126
- Charging more for a write does not authorize it. Mutations still require:
127
-
128
- - a tenant-owned active connection;
129
- - a live upstream tool that intersects source-controlled policy;
130
- - the connection's action switch;
131
- - the exact scheduled grant when scheduled;
132
- - any required confirmation or destructive-action rule.
133
-
134
- ## Credit unit and accounting rules
135
-
136
- ### Canonical units
137
-
138
- - Internal accounting unit: mc, an integer microcredit.
139
- - Public accounting unit: Credit.
140
- - Conversion: 100 mc = 1 Credit.
141
- - Billing conversion: 2,000,000 mc per $3.00 of vendor cost, represented as an exact rational rather than a floating-point value.
142
- - Fractional public Credits may be displayed to two decimal places, but all ledger math uses integer mc.
143
- - Credit lots continue to expire according to the current three-month policy unless a later commercial decision changes it.
144
- - Debits consume eligible lots using the existing ledger order.
145
-
146
- The public skill currently says 1 Credit equals 1,000 mc while the source rate table says 1 Credit equals 100 mc. This 10-times documentation discrepancy is a release blocker. All public rates and examples must be generated from the canonical source table.
147
-
148
- ### Current plan grants
149
-
150
- The current source rate table implies:
151
-
152
- | Plan | Monthly price | Credits | Approximate Credits per dollar |
153
- |---|---:|---:|---:|
154
- | Starter | $12 | 80,000 | 6,666.7 |
155
- | Growth | $40 | 266,667 | 6,666.7 |
156
- | Scale | $100 | 800,000 | 8,000 |
157
-
158
- The Scale grant is a deliberate volume discount. A fixed Credit charge therefore has a lower cash-equivalent markup for a Scale customer. Product copy may say the billing formula is 1.5 times raw OpenRouter cost; it must not promise that every plan produces a 50% cash gross margin after volume discounts.
159
-
160
- The billing conversion must become an explicit rate-registry constant. It must no longer be derived from a Stripe plan's price or Credit grant. Otherwise an innocent plan-price edit would silently reprice AI work.
161
-
162
- ### One-time activation and refill
163
-
164
- The old one-time pack mapping must not be reactivated because its $10 pack would grant 110,000 Credits and undercut recurring plans.
165
-
166
- Recommended pay-as-you-go contract:
167
-
168
- | Purchase | Credits | Purpose |
169
- |---|---:|---|
170
- | $10 minimum activation/refill | 50,000 | Enables metered integrations and schedules for a non-plan account |
171
- | Customer-selected auto-refill | Same 5,000 Credits per dollar | Prevents interrupted schedules, subject to a monthly dollar cap |
172
-
173
- Auto-refill is off by default. The customer chooses a threshold and a monthly maximum, and receives a receipt for each Stripe charge.
174
-
175
- This is intentionally less generous than subscription grants. Plans remain the best value; pay-as-you-go exists for activation and overflow.
176
-
177
- ## Released v1 rate table
178
-
179
- All rates live in one versioned server-side registry. Frontends, MCP descriptions, SDKs, and docs consume generated projections from that registry.
180
-
181
- ### Connection operations
182
-
183
- Released v1 rates:
184
-
185
- | Billing class | Charge |
186
- |---|---:|
187
- | OAuth connect, reconnect, or consent callback | Free |
188
- | Active Nango connection | $3 per month, recurring and prorated |
189
- | Nango function run | 2 Credits per run |
190
- | Nango Proxy request | 2 Credits per request |
191
- | Nango function compute | 5 Credits per second, prorated from aggregate milliseconds |
192
-
193
- Action safety remains independent of price: ownership, live inventory, source-controlled policy, the account action switch, and exact scheduled grants still apply.
194
-
195
- The active rate revision is `2026-07-15.connected-usage-v1`. Compute settlement uses:
196
-
197
- compute mc = ceil(computeMilliseconds * 500 mc / 1000)
198
-
199
- The scheduler aggregates raw milliseconds for one receipt before applying that ceiling. It does not round each span or function up to a whole second. Function, Proxy, and compute line items are additive; the recurring $3 connection charge is not converted into Credits.
200
-
201
- ### Deferred connected-operation pricing options (not enabled)
202
-
203
- Earlier design work proposed 5/10/15/25-Credit read/write classes, a 25-Credit bulk base, per-record charges, and per-MiB charges. Those values are retained only as research for a later commercial decision. They are not present in the production registry and must not appear as current pricing in UI, MCP descriptions, SDKs, or support answers.
204
-
205
- ### Retired active connection minimum proposal
206
-
207
- An earlier proposal described a 20,000-Credit wallet minimum per active connection per 30-day billing period. It is superseded by the flat $3/month recurring add-on and must not be presented as current pricing.
208
-
209
- The remainder of this subsection records the deferred proposal for future evaluation only:
210
-
211
- One tenant-owned credential/account row is one connection. Two Google accounts, two Slack workspaces, or two WordPress sites are separate connections. Disconnected and billing-paused credentials do not accrue a new minimum; active and reauthorization-grace credentials accrue only for the active seconds in the period.
212
-
213
- Eligible connected-service usage offsets this minimum:
214
-
215
- - bounded reads and writes;
216
- - bulk-export base;
217
- - delivered/changed records;
218
- - transferred bytes;
219
- - explicit provider-operation surcharges when later added.
220
-
221
- The following do not offset the connection minimum:
222
-
223
- - OpenRouter model inference;
224
- - scheduled-occurrence base;
225
- - generic web scraping;
226
- - memory storage capacity;
227
- - memory embeddings or other AI processing.
228
-
229
- The first connection's first 30 days are waived. This creates a real activation path before an idle-connection charge appears.
230
-
231
- At settlement, only the shortfall is charged:
232
-
233
- connection minimum debit
234
- = max(0, prorated minimum - eligible usage already charged)
235
-
236
- If a wallet cannot cover the minimum:
237
-
238
- 1. Mark the connection billing-paused.
239
- 2. Allow a seven-day read-only recovery window for refill or plan activation.
240
- 3. Block new scheduled use and mutations immediately.
241
- 4. After the grace period, remove or disconnect the stored upstream credential if necessary to stop ongoing vendor charges.
242
- 5. Keep non-secret connection history and explain that reconnection is required.
243
-
244
- This behavior must be disclosed before connection and in low-balance notices.
245
-
246
- ### Scheduled execution
247
-
248
- | Billing class | Charge |
249
- |---|---:|
250
- | Authorized scheduled occurrence that begins execution | 75 Credits |
251
- | Duplicate/replayed occurrence | Free |
252
- | Skipped before execution for insufficient Credits | Free |
253
- | Work inside the occurrence | Normal applicable rates |
254
-
255
- The 75-Credit base preserves the rough economics of the former $10-for-1,000-runs product:
256
-
257
- - 1,000 runs use 75,000 Credits.
258
- - That is approximately $9.38 of Scale plan Credits or $11.25 of Starter/Growth plan Credits.
259
-
260
- It also allows a light schedule to remain inexpensive. A schedule running at 8 AM, noon, and 4 PM Mountain executes about 90 times in a 30-day month, using 6,750 Credits in fixed run charges before its data and model work.
261
-
262
- #### Agent schedule
263
-
264
- An agent occurrence settles:
265
-
266
- 75-Credit occurrence base
267
- + OpenRouter actual cost times 1.5
268
- + any separately metered published tools invoked by the run
269
-
270
- #### Deterministic connection sync
271
-
272
- A connection_sync occurrence settles:
273
-
274
- 75-Credit occurrence base
275
-
276
- There is no model charge unless that deterministic pipeline actually invokes a model.
277
-
278
- ### OpenRouter model inference
279
-
280
- The settlement formula is:
281
-
282
- raw_cost_usd = sum(OpenRouter usage.cost for every successful model step)
283
- billable_mc = ceil(raw_cost_usd × 1.5 × canonical_mc_per_usd)
284
- billable_credits = billable_mc / 100
285
-
286
- At the current canonical conversion derived from Starter/Growth grants:
287
-
288
- canonical_mc_per_usd = 2,000,000 / 3
289
- $1.00 raw OpenRouter cost = 10,000 billed Credits
290
-
291
- As of this spec, OpenRouter lists MiniMax M3 at $0.30 per million input tokens, $1.20 per million output tokens, and $0.06 per million cached-input tokens for standard providers. The customer-facing estimate is therefore:
292
-
293
- | MiniMax M3 usage | Estimated Credits |
294
- |---|---:|
295
- | 1 million input tokens | 3,000 Credits |
296
- | 1 million output tokens | 12,000 Credits |
297
- | 1 million cached-input tokens | 600 Credits |
298
-
299
- These are display estimates, not a settlement substitute. The rate UI must show the source timestamp and refresh when OpenRouter pricing changes.
300
-
301
- ### Worked examples
302
-
303
- #### Light scheduled agent
304
-
305
- Assume one MiniMax M3 run uses 100,000 input tokens, 20,000 output tokens, and one bounded connected-service read:
306
-
307
- | Line item | Credits |
308
- |---|---:|
309
- | Scheduled occurrence | 75 |
310
- | Connected-service read | Included |
311
- | Estimated model input | 300 |
312
- | Estimated model output | 240 |
313
- | Estimated total | 615 |
314
-
315
- The model lines settle from the actual reported OpenRouter cost, so 615 is an estimate until the receipt closes.
316
-
317
- #### Deterministic bulk sync
318
-
319
- Assume a deterministic connection sync delivers 500 changed records and 50 MiB without calling a separately metered tool:
320
-
321
- | Line item | Credits |
322
- |---|---:|
323
- | Scheduled occurrence | 75 |
324
- | Connected records and transfer | Included |
325
- | Total | 75 |
326
-
327
- ### Existing non-scheduler AI classes
328
-
329
- The unified registry keeps existing product-specific multipliers explicit:
330
-
331
- | Billing class | Initial multiplier |
332
- |---|---:|
333
- | scheduled_agent_llm | 1.5 |
334
- | memory_ai | 3.0 |
335
- | site_audit_ai | 1.5 |
336
- | video_analysis_ai | 1.5 |
337
- | media_transcription_ai | 3.0 |
338
-
339
- The caller supplies the billing class, not the multiplier. The main billing server resolves the multiplier from its versioned registry. This prevents a compromised or outdated worker from choosing its own price.
340
-
341
- ## Price display policy
342
-
343
- The primary display is Credits.
344
-
345
- Recommended copy:
346
-
347
- > Integrations and scheduling are included. Each run uses Credits for the work it performs.
348
-
349
- > AI model use is billed at OpenRouter's actual reported cost plus 50%, converted to Credits.
350
-
351
- > Estimated MiniMax M3 rate: 3,000 Credits per million input tokens and 12,000 Credits per million output tokens. Exact usage may vary by provider, caching, reasoning, media, and routing.
352
-
353
- The UI may place raw dollar rates in a secondary tooltip or expandable explanation. A single fixed dollar-per-million claim must not replace actual-cost settlement.
354
-
355
- ## Per-run and monthly budgets
356
-
357
- Released v1 has a server-side `maxCreditsPerRun` default of 5,000 Credits and pauses on insufficient balance or unresolved model cost. The cap is environment-configurable and is not yet user-editable. User-defined monthly caps, model allowlists, auto-refill behavior, and a pre-activation estimator remain future work.
358
-
359
- Before each occurrence:
360
-
361
- 1. Perform an idempotent balance authorization before model execution.
362
- 2. If the wallet cannot cover the maximum, skip without a run-base charge.
363
- 3. Settle the 75-Credit base once plus all authoritative model-step cost.
364
- 4. If authoritative model cost is missing, move to `cost_pending` and pause later occurrences.
365
-
366
- Hard reservations, incremental budget stopping, monthly caps, and automatic release of unused reserved balance remain hardening work.
367
-
368
- The current very large max-output-token ceiling cannot function as the spending guard. Budget enforcement must occur during execution, including after each model step.
369
-
370
- ## End-to-end execution contract
371
-
372
- ### Occurrence flow
373
-
374
- Inngest or scheduler trigger
375
- -> idempotently claim identity + schedule + scheduledFor
376
- -> ask main billing service for an idempotent balance authorization
377
- -> receive an opaque billing context
378
- -> execute exact schedule grants
379
- -> aggregate every OpenRouter model-step cost
380
- -> settle the 75-Credit base plus model amount once
381
- -> persist billing event references
382
-
383
- The billing context travels in an internal authenticated transport header or server-side execution context. It is never put in the model prompt, tool arguments, provider payload, or public result.
384
-
385
- Hard reservations, incremental child-call line items, and full customer-facing itemized receipts are the next hardening phase rather than released-v1 claims.
386
-
387
- ### Direct non-scheduled flow
388
-
389
- Direct connected-service MCP, REST, or SDK work is included and still follows the same tenant ownership and permission checks. If that work invokes a separately metered public tool, the existing tool-specific billing path applies:
390
-
391
- validate tenant-owned exact tool
392
- -> execute the connected-service operation without an integration debit
393
- -> separately meter only published scraper/media/browser classes used
394
-
395
- The generic MCP bridge and a provider-native MCP tool must not silently produce different integration pricing for the same operation.
396
-
397
- ### Multi-step model accounting
398
-
399
- For Mastra/AI SDK generate results:
400
-
401
- - top-level usage represents the last step;
402
- - totalUsage aggregates tokens but does not by itself provide a trustworthy total dollar cost;
403
- - providerMetadata on each step contains that step's OpenRouter usage.cost in the current runtime.
404
-
405
- Therefore the scheduler must iterate all result.steps and sum each providerMetadata.openrouter.usage.cost. It must not debit from both a generic usage meter and a pass-through-cost function.
406
-
407
- When a step has no usage.cost:
408
-
409
- 1. Save the OpenRouter generation ID when available.
410
- 2. Query OpenRouter's generation endpoint for the authoritative cost.
411
- 3. Keep the receipt in cost_pending state until reconciled.
412
- 4. Use a current rate snapshot only for authorization and estimates, never silent final settlement.
413
- 5. Pause later occurrences if pending costs cannot be reconciled within the configured window.
414
-
415
- ## Single debit authority
416
-
417
- The main MCP Scraper billing service is the only component allowed to mutate the customer's Credit balance.
418
-
419
- | Component | May do | Must not do |
420
- |---|---|---|
421
- | Main billing service | Authorize, reserve, settle, refund, expire, and report Credits | Execute schedules or hold provider credentials |
422
- | Scheduler | Request authorization, emit line items, mirror receipt status | Directly debit a wallet or apply a multiplier |
423
- | Mastra agent | Use granted tools within a budget | Receive wallet secrets or price itself |
424
- | Connected-service adapter | Report classified outcomes, records, and bytes | Create plan-dependent rates |
425
- | Nango | Authenticate provider calls and return results | Own MCP Scraper pricing or Credits |
426
- | Frontend/SDK/MCP | Display estimates and receipts from server | Calculate authoritative charges locally |
427
-
428
- The existing internal memory AI-debit endpoint becomes a compatibility adapter during migration, then routes through the unified billing service. It may not apply an extra 3.0 multiplier to a scheduled_agent_llm event.
429
-
430
- ## Billing data model and hardening roadmap
431
-
432
- The released v1 authorization and billing-event tables are smaller than the target below. Names are illustrative; the following reservation, receipt, and connection-period structures describe future hardening and must not be treated as already released.
433
-
434
- ### billing_events
435
-
436
- Required fields:
437
-
438
- - id;
439
- - identity_id;
440
- - idempotency_key, globally unique;
441
- - billing_class;
442
- - source_surface;
443
- - schedule_id, nullable;
444
- - occurrence_id, nullable;
445
- - connection_id, nullable;
446
- - tool_name, nullable;
447
- - model and provider, nullable;
448
- - generation_id, nullable;
449
- - raw_cost_usd_nanos or an exact decimal representation, nullable;
450
- - multiplier_basis_points, nullable;
451
- - input_tokens, output_tokens, cached_input_tokens, reasoning_tokens, nullable;
452
- - record_count, nullable;
453
- - byte_count, nullable;
454
- - amount_mc;
455
- - rate_revision;
456
- - status: estimated, authorized, pending, settled, refunded, void, or cost_pending;
457
- - safe metadata JSON;
458
- - created_at and settled_at.
459
-
460
- Do not store prompts, model responses, provider tokens, OAuth tokens, email bodies, file content, or raw tool arguments.
461
-
462
- ### credit_reservations
463
-
464
- Required fields:
465
-
466
- - id;
467
- - identity_id;
468
- - idempotency_key, unique;
469
- - max_amount_mc;
470
- - consumed_amount_mc;
471
- - released_amount_mc;
472
- - status: active, settled, released, expired;
473
- - expires_at;
474
- - occurrence_id or request_id;
475
- - created_at and updated_at.
476
-
477
- The balance available for new work excludes active reservations.
478
-
479
- ### billing_receipts
480
-
481
- A receipt groups line items for one direct request, bulk job slice, or scheduled occurrence:
482
-
483
- - receipt ID;
484
- - identity;
485
- - source and run IDs;
486
- - rate revision;
487
- - total mc and public Credits;
488
- - line-item summaries;
489
- - reserved, settled, and released amounts;
490
- - status;
491
- - timestamps;
492
- - safe failure/refund reason.
493
-
494
- ### connection_billing_periods
495
-
496
- Required fields:
497
-
498
- - identity and connection ID;
499
- - period start/end;
500
- - active seconds and prorated minimum;
501
- - eligible usage mc;
502
- - shortfall mc;
503
- - settlement event ID;
504
- - status;
505
- - grace deadline.
506
-
507
- ## Idempotency and retry rules
508
-
509
- ### Scheduled occurrence key
510
-
511
- The canonical occurrence key is:
512
-
513
- schedule:{identityId}:{scheduleId}:{scheduledForIso}
514
-
515
- It owns at most one occurrence-base event. In released v1 the base event is created only after the claim obtains its balance authorization and execution begins. Future hard-reservation work will retain the same key. Worker retries, leases, and resumed slices reference that event.
516
-
517
- ### Line-item keys
518
-
519
- Examples:
520
-
521
- occurrenceKey:base
522
- occurrenceKey:llm:{stepId}
523
- occurrenceKey:connection:{callId}
524
- occurrenceKey:records:{dataset}:{checkpoint}
525
- occurrenceKey:bytes:{artifactId}
526
- request:{requestId}:tool:{toolCallId}
527
-
528
- The main ledger rejects a second settlement for the same key and returns the existing receipt.
529
-
530
- ### Partial success
531
-
532
- - Work completed before a provider or user error remains chargeable.
533
- - No provider-work line is charged for validation failure before the provider call.
534
- - Included connected-service records and bytes do not create their own charge in released v1.
535
- - Unused reservation is always released.
536
- - The 75-Credit platform base is refunded when MCP Scraper itself fails before useful execution.
537
- - The base is not refunded for invalid customer configuration, expired OAuth after a valid start, provider outage after dispatch, or user-authored agent failure unless support policy grants a courtesy refund.
538
- - Actual OpenRouter cost remains chargeable whenever the provider incurred it, even if the final workflow outcome fails.
539
-
540
- Refund reasons are structured and support-visible.
541
-
542
- ## Internal billing API
543
-
544
- The exact route naming may follow current conventions, but the contract must include:
545
-
546
- ### Authorize
547
-
548
- POST /api/internal/billing/authorizations
549
-
550
- Input:
551
-
552
- - identity;
553
- - idempotency key;
554
- - billing intent;
555
- - maximum mc;
556
- - schedule, occurrence, connection, and request references;
557
- - rate revision requested or latest.
558
-
559
- Output:
560
-
561
- - authorization ID;
562
- - opaque billing-context token;
563
- - reserved mc;
564
- - rate revision;
565
- - expiry;
566
- - remaining wallet and monthly-budget summaries.
567
-
568
- ### Add line items
569
-
570
- POST /api/internal/billing/authorizations/:id/line-items
571
-
572
- Input is a batch of classified, idempotent measurements. The server applies rates and multipliers. The worker never sends an authoritative final Credit amount for a class whose price is server-owned.
573
-
574
- ### Settle
575
-
576
- POST /api/internal/billing/authorizations/:id/settle
577
-
578
- The server atomically debits actual mc, releases the remainder, and returns the final receipt.
579
-
580
- ### Void or refund
581
-
582
- POST /api/internal/billing/authorizations/:id/void
583
-
584
- POST /api/internal/billing/receipts/:id/refunds
585
-
586
- Refunds append compensating ledger events. Settled rows are never silently edited.
587
-
588
- ### Availability policy
589
-
590
- - If authorization is unavailable, fail closed before externally costly work.
591
- - If line-item reporting is temporarily unavailable after work starts, persist a durable outbox record.
592
- - If settlement is pending, mark cost_pending and pause future work that could increase exposure.
593
- - Never discard a charge measurement because an HTTP request failed.
594
-
595
- ## Public API, MCP, and SDK contract
596
-
597
- Released v1 publishes the 75-Credit occurrence base and 1.5-times actual OpenRouter rule across the hosted MCP, npm packages, generated SDK contracts, marketing pages, and scheduler status. The richer fields below are the follow-on receipt and budget roadmap.
598
-
599
- ### Existing tools to extend
600
-
601
- credits_info adds:
602
-
603
- - canonical Credit conversion;
604
- - rate revision;
605
- - connection rates;
606
- - connection minimum policy;
607
- - schedule base;
608
- - current model estimate table;
609
- - actual-cost language;
610
- - credit expiry and auto-refill summary.
611
-
612
- create_scheduled_action adds:
613
-
614
- - maxCreditsPerRun;
615
- - maxCreditsPerMonth;
616
- - estimatedCreditsPerRun;
617
- - estimate assumptions and warning range.
618
-
619
- get_schedule_status adds:
620
-
621
- - month-to-date Credit spend;
622
- - remaining monthly budget;
623
- - last authorization and receipt IDs;
624
- - last itemized Credit summary;
625
- - paused-for-billing state;
626
- - pending-cost state.
627
-
628
- Connection list/status adds:
629
-
630
- - current billing period;
631
- - eligible usage toward minimum;
632
- - projected shortfall;
633
- - billing-paused/grace state;
634
- - next settlement date.
635
-
636
- All connected-service execution tools return a compact billing summary:
637
-
638
- - receipt ID;
639
- - Credits charged;
640
- - line-item category;
641
- - pending or settled status.
642
-
643
- ### New estimator
644
-
645
- Add estimate_scheduled_action_cost to the root MCP and corresponding REST/SDK methods.
646
-
647
- Inputs:
648
-
649
- - schedule mode;
650
- - frequency and timezone;
651
- - selected connections and tools;
652
- - expected records/bytes when known;
653
- - model and estimated input/output tokens when agentic;
654
- - memory destination;
655
- - proposed budgets.
656
-
657
- Outputs:
658
-
659
- - fixed Credits per occurrence and per month;
660
- - variable estimate range;
661
- - model rate snapshot;
662
- - assumptions;
663
- - recommended maxCreditsPerRun and maxCreditsPerMonth;
664
- - warning that actual OpenRouter-reported cost controls settlement.
665
-
666
- Estimation is free and creates no reservation.
667
-
668
- ### Tool-description language
669
-
670
- Every billable tool schema includes:
671
-
672
- - its billing class;
673
- - fixed charge if any;
674
- - variable units;
675
- - whether failure can incur provider/model cost;
676
- - link or pointer to credits_info;
677
- - whether it participates in a connection minimum.
678
-
679
- Tool descriptions do not hardcode copied rates by hand. They are generated or injected from the canonical registry.
680
-
681
- ## Mastra integration
682
-
683
- ### Scheduled Action Agent
684
-
685
- The agent receives:
686
-
687
- - exact tenant-owned connection toolsets;
688
- - a server-side Credit budget;
689
- - a per-step guard;
690
- - remaining-budget context as trusted runtime metadata, not user prompt content;
691
- - no access to billing credentials or wallet mutation tools.
692
-
693
- Use onStepFinish or the current equivalent to:
694
-
695
- 1. capture each model step's OpenRouter usage cost;
696
- 2. append one idempotent line item;
697
- 3. check remaining reserved budget;
698
- 4. stop before the next expensive step when the cap is reached.
699
-
700
- The final result uses total tool outcomes plus all step records. Remove the dual meterLlmUsage and billPassThroughCost debit behavior.
701
-
702
- ### Connection sync worker
703
-
704
- The deterministic worker:
705
-
706
- - claims the same occurrence key;
707
- - authorizes its budget;
708
- - charges the 75-Credit occurrence base once;
709
- - settles observed Nango function runs, Proxy requests, and aggregate compute milliseconds under the active connected-usage rate revision;
710
- - checkpoints before settlement so retry behavior is deterministic.
711
-
712
- The worker never invokes a model merely to paginate or transfer content.
713
-
714
- ## User experience
715
-
716
- ### Pricing page
717
-
718
- Remove the Scheduled Actions add-on card.
719
-
720
- Under every paid plan:
721
-
722
- > Integration access and scheduled work included. Each active Nango account is $3/month; connected usage draws from your shared Credit balance.
723
-
724
- Show the 75-Credit scheduled occurrence, the “actual OpenRouter cost plus 50%” disclosure, the $3 active-account recurring fee, and the 2/2/5 connected-usage rates. Do not show the retired semantic read/write tariff or active-connection Credit minimum as current pricing.
725
-
726
- ### Integrations page
727
-
728
- Each card shows:
729
-
730
- - connected account count;
731
- - real callable read/action inventory;
732
- - action switch;
733
- - a link to import/schedule.
734
-
735
- OAuth authorization itself remains free.
736
-
737
- ### Scheduling page
738
-
739
- Keep Scheduling as a prominent feature and navigation destination.
740
-
741
- The creation flow shows:
742
-
743
- 1. frequency and timezone;
744
- 2. selected connection/data/action;
745
- 3. destination or intended result;
746
- 4. estimated fixed and variable Credits;
747
- 5. per-run and monthly caps;
748
- 6. low-balance behavior;
749
- 7. action confirmation/grants;
750
- 8. activate.
751
-
752
- The schedule detail view presents an itemized history, not just “one run.”
753
-
754
- ### Usage page
755
-
756
- Group receipts by:
757
-
758
- - direct tools;
759
- - connected-service operations;
760
- - bulk/import;
761
- - scheduled occurrences;
762
- - OpenRouter AI;
763
- - memory processing;
764
- - connection minimums;
765
- - refunds.
766
-
767
- Users can filter by connection, schedule, model, provider, and date.
768
-
769
- ## Scheduled Actions subscription migration
770
-
771
- ### Live migration result
772
-
773
- The legacy live-mode Stripe price `price_1ToXcHS8aAcsk3TGf3cW7zHx` still exists as an active $10 monthly price, but a read-only all-status audit on 2026-07-14 found zero subscriptions. The old checkout route now returns `410 Gone`, so no customer cancellation, proration, or compensating migration Credit is currently required. The price may be archived separately as Stripe catalog cleanup; archiving it is not required for runtime cutover and was not performed automatically.
774
-
775
- ### Customer treatment
776
-
777
- 1. Stop new scheduler-subscription checkout after the unified billing path is proven.
778
- 2. Identify active, trialing, past-due, and cancelled-at-period-end scheduler subscriptions.
779
- 3. Grant a migration Credit amount equal to the unused prepaid portion, with a customer-friendly floor.
780
- 4. Cancel the separate Stripe scheduler subscription at the correct boundary without interrupting saved schedules.
781
- 5. Remove entitlement and 1,000-run quota gates.
782
- 6. Preserve schedule definitions, timezone, encrypted service key, grants, and history.
783
- 7. Assign default per-run and monthly budgets.
784
- 8. Notify customers before the first Credit-billed occurrence.
785
-
786
- Recommended migration grant:
787
-
788
- max(prorated unused $10 converted at plan rate, 75,000 Credits for a fully unused current period)
789
-
790
- The exact grant must be tested against Stripe period data and approved before execution.
791
-
792
- ### Historical billing reconciliation
793
-
794
- Build a one-time report joining:
795
-
796
- - scheduler mem_usage_ledger scheduled entries;
797
- - schedule occurrence/run IDs;
798
- - raw OpenRouter costs and step metadata where retained;
799
- - main credit-ledger debit events;
800
- - Stripe scheduler subscription state.
801
-
802
- Classify each occurrence:
803
-
804
- - correctly debited once;
805
- - potentially duplicated;
806
- - wrong multiplier;
807
- - missing earlier model steps;
808
- - fail-open/no debit;
809
- - no usable evidence.
810
-
811
- Issue compensating Credits for defensible overcharges. Do not retroactively debit undercharges. Retain an operator receipt and customer-support note.
812
-
813
- ## Rollout sequence
814
-
815
- ### Gate 0 — freeze unsafe expansion
816
-
817
- - Do not add more callers to the current scheduled AI debit functions.
818
- - Add telemetry that identifies both debit paths without changing customer balances.
819
- - Preserve current schedule service while the replacement is built.
820
-
821
- ### Gate 1 — canonical registry and generated public rates
822
-
823
- - Move Credit conversion, billing classes, multipliers, and display estimates into one versioned registry.
824
- - Generate the MCP skill, public rate API, frontend copy data, and SDK constants.
825
- - Fix the 100-versus-1,000 mc public discrepancy.
826
-
827
- ### Gate 2 — unified ledger and reservation API
828
-
829
- - Add billing events, reservations, receipts, idempotency constraints, and durable outbox.
830
- - Wrap existing direct Credit debits behind the service.
831
- - Keep old endpoints as compatibility adapters.
832
-
833
- ### Gate 3 — shadow scheduler billing
834
-
835
- - Authorize no real reservations yet.
836
- - Calculate the proposed 75-Credit base and all-step OpenRouter amount in shadow.
837
- - Compare against current debits and production receipts.
838
- - Prove multi-step aggregation and single-debit behavior.
839
-
840
- ### Gate 4 — scheduler cutover
841
-
842
- - Enable reservations and settlement for internal/test tenants.
843
- - Remove the duplicate model debit path.
844
- - Enable per-run/month caps and cost-pending reconciliation.
845
- - Expand to production cohorts after receipt review.
846
-
847
- ### Gate 5 — deterministic sync and direct connection billing (partially deferred)
848
-
849
- - Route `connection_sync` through the shared 75-Credit occurrence context.
850
- - Keep generic MCP, REST, SDK, exports, and snapshots included in released v1.
851
- - Reconsider connected-operation tariffs or active-connection minimums only after a new explicit commercial decision, shadow period, and customer notice.
852
-
853
- ### Gate 6 — commercial migration
854
-
855
- - Stop new schedule add-on sales.
856
- - Grant migration Credits and cancel old Stripe subscriptions.
857
- - Remove entitlement/quota enforcement.
858
- - Activate $10 pay-as-you-go refill only after its Stripe and ledger path is complete.
859
-
860
- ### Gate 7 — full release
861
-
862
- - Update frontend, pricing, scheduler copy, MCP schemas, npm package, SDKs, MCPB, terms, support docs, and Vercel production.
863
- - Run production smoke receipts.
864
- - Publish a customer explanation and migration FAQ.
865
-
866
- ## Required tests
867
-
868
- ### Rate and arithmetic tests
869
-
870
- - 100 mc equals 1 public Credit everywhere.
871
- - All charges use integers and defined ceiling rules.
872
- - Vendor-cost conversion uses exact rational or decimal arithmetic, never binary floating-point ledger math.
873
- - OpenRouter raw cost times 1.5 yields the exact expected mc.
874
- - Plan grants do not alter the number of Credits charged for an identical action.
875
- - MiniMax display estimates are generated from a timestamped rate snapshot.
876
-
877
- ### Model accounting tests
878
-
879
- - One-step result settles once.
880
- - Multi-step result sums every step's usage.cost.
881
- - Top-level final-step metadata alone cannot settle the run.
882
- - meterLlmUsage and pass-through code cannot each debit the same result.
883
- - Missing cost becomes cost_pending and reconciles by generation ID.
884
- - Model failure after incurring cost retains that provider-cost line.
885
-
886
- ### Scheduling tests
887
-
888
- - A new schedule does not require a scheduler subscription.
889
- - One occurrence receives one 75-Credit base.
890
- - Retry and lease replay do not duplicate the base.
891
- - Insufficient Credits before authorization produces a free skip.
892
- - Per-run cap stops later model/provider work.
893
- - Monthly cap pauses future occurrences.
894
- - Unused reservation is released.
895
- - agent and connection_sync modes both produce receipts.
896
- - Existing saved schedules survive entitlement migration.
897
-
898
- ### Connection tests
899
-
900
- - OAuth callback is free.
901
- - Direct reads, enabled actions, exports, and bounded Memory snapshots do not create an integration-operation debit.
902
- - Internal pagination is not separately billed.
903
- - Direct MCP, REST, SDK, Mastra, and background calls publish the same included-use rule.
904
- - Deferred operation tariffs and active-connection minimums are absent from the production registry and public copy.
905
-
906
- ### Ledger tests
907
-
908
- - Globally unique idempotency keys prevent double debit.
909
- - Reservation and settlement are atomic.
910
- - Refunds append compensating events.
911
- - Active reservations reduce available balance.
912
- - Durable outbox survives billing-service interruption.
913
- - No prompt, result body, OAuth token, or billing secret enters billing metadata.
914
-
915
- ### Product-surface tests
916
-
917
- - Pricing page no longer sells Scheduled Actions separately.
918
- - Integrations and Scheduling are in desktop and mobile navigation.
919
- - credits_info, estimator, schedule status, receipts, UI, and SDK agree.
920
- - Public skill and source rate table have generated parity.
921
- - npm, MCPB, hosted MCP, REST, and Vercel production expose the same schemas.
922
-
923
- ## Production proof
924
-
925
- Before marking complete, capture:
926
-
927
- 1. A tiny direct connected-service read and receipt.
928
- 2. A safe approved connected-service write and receipt.
929
- 3. A two-step scheduled agent run proving both OpenRouter step costs settle once.
930
- 4. A deterministic sync with unchanged and changed records proving delta billing.
931
- 5. An insufficient-balance occurrence proving a free skip.
932
- 6. A retry proving no duplicate base or line item.
933
- 7. A failed MCP Scraper execution proving the correct base refund.
934
- 8. A current model-rate endpoint and matching frontend/MCP display.
935
- 9. A migrated scheduler subscription with saved schedule continuity.
936
- 10. Vercel deployment, npm version, MCPB manifest, SDK version, and generated-doc parity.
937
-
938
- Receipts must be sanitized. Do not include prompts, connection tokens, API keys, customer content, raw provider arguments, or signed artifact URLs.
939
-
940
- ## Release blockers
941
-
942
- - Any remaining path that directly mutates Credits outside the main billing service.
943
- - Any duplicate scheduled model debit.
944
- - Settlement based only on final-step metadata.
945
- - Fail-open execution that can incur provider cost without a durable pending charge.
946
- - Missing idempotency across occurrence, tool call, record batch, or artifact.
947
- - The public 1 Credit equals 1,000 mc mismatch.
948
- - Separate scheduling entitlement or 1,000-run quota still enforced on any surface.
949
- - Frontend, hosted MCP, SDK/npm, MCPB, or public docs showing different rates.
950
- - A fixed token rate described as authoritative rather than an estimate.
951
- - Any surface that omits or contradicts the approved $3 plus 2/2/5 connected-account contract.
952
- - Commercial migration without a reconciliation and compensating-credit policy.
953
-
954
- ## Decisions locked by this spec
955
-
956
- - Scheduled Actions is included and metered, not a separate subscription.
957
- - Credits are the primary customer-facing unit.
958
- - OpenRouter actual reported cost is the AI settlement source.
959
- - scheduled_agent_llm uses a 1.5 multiplier.
960
- - Model token tables are estimates.
961
- - The fixed scheduled-occurrence charge is 75 Credits.
962
- - Active Nango connections cost $3/month; usage costs 2 Credits/function execution, 2 Credits/Proxy request, and 5 Credits/compute-second measured from milliseconds.
963
- - The proposed 5/10/15/25 semantic tariffs and 20,000-Credit active-connection minimum are not enabled.
964
- - OAuth is free.
965
- - Main MCP Scraper owns the only mutable Credit ledger.
966
- - Every product and execution surface publishes the same price contract; shared itemized receipt UX remains hardening work.
967
- - Action authorization remains separate from billing.
968
-
969
- ## Decisions that may change only through a rate revision
970
-
971
- - Exact semantic per-read, per-write, per-record, and per-MiB rates beyond the current Nango resource meter.
972
- - Connected-account monthly price and function, Proxy, or compute rates.
973
- - Pay-as-you-go Credit grant per dollar.
974
- - Default per-run and monthly caps.
975
- - Existing non-scheduler AI multipliers.
976
-
977
- Changing one of these does not require a protocol redesign, but it requires a new rate revision, generated-surface parity, tests, and customer notice where applicable.
978
-
979
- ## Source references
980
-
981
- - OpenRouter usage accounting: https://openrouter.ai/docs/cookbook/administration/usage-accounting
982
- - OpenRouter API usage object: https://openrouter.ai/docs/api/reference/overview
983
- - Current MiniMax M3 pricing: https://openrouter.ai/minimax/minimax-m3/pricing
984
- - Current MCP Scraper rate source: src/api/rates.ts
985
- - Current main AI debit route: src/api/server.ts
986
- - Current scheduler billing logic: ../mcp-scraper-scheduler/src/mastra/lib/schedule-billing.ts
987
- - Current scheduled execution path: ../mcp-scraper-scheduler/src/mastra/steps/schedule-execute.ts
988
- - Current schedule entitlement re-export: ../mcp-scraper-scheduler/src/mastra/db/schedule-entitlements.ts
989
- - Current scheduler usage re-export: ../mcp-scraper-scheduler/src/mastra/db/usage.ts
990
- - Installed memory DB entitlement implementation: ../mcp-scraper-scheduler/node_modules/mcpscraper-memory-db/dist/db/schedule-entitlements.js
991
- - Installed memory DB usage and debit implementation: ../mcp-scraper-scheduler/node_modules/mcpscraper-memory-db/dist/db/usage.js
992
-
993
- ## Final acceptance statement
994
-
995
- The implementation is complete only when a customer can connect a service, schedule or directly invoke work, move data into memory, and receive one understandable Credit receipt whose amount is identical across the live ledger, frontend, MCP, REST, Mastra, and SDK. A local code path, pricing-page change, or scheduler-only implementation does not satisfy this spec.