@descix/platform-api 4.0.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descix/platform-api",
3
- "version": "4.0.1",
3
+ "version": "5.0.0",
4
4
  "description": "Shared platform infrastructure: Firestore models, auth/session, permissions, entitlements, email",
5
5
  "repository": {
6
6
  "type": "git",
@@ -177,70 +177,6 @@ export async function sendVerificationEmail(toEmail, code, expiryMinutes = 15) {
177
177
  await sendEmail(toEmail, subject, body);
178
178
  }
179
179
 
180
- /**
181
- * Send payment pending notification with deposit instructions.
182
- *
183
- * @param {Object} quote - The payment quote object
184
- * @param {string} quote.quote_id - Unique quote identifier
185
- * @param {string} quote.deposit_address - Deposit address
186
- * @param {string} quote.amount_formatted - Formatted amount (e.g., "0.5 ETH")
187
- * @param {string} quote.usd_amount_formatted - Formatted USD amount (e.g., "$10.00")
188
- * @param {string} quote.chain_name - Chain name (e.g., "Polygon")
189
- * @param {string} quote.expires_at - ISO timestamp when quote expires
190
- * @param {string} recipientEmail - Recipient email address
191
- * @returns {Promise<void>}
192
- */
193
- export async function sendPaymentPending(quote, recipientEmail) {
194
- const utils = getCloudConfig();
195
- const subject = `Payment Instructions - ${quote.usd_amount_formatted || `$${quote.usd_amount}`} via ${quote.chain_name || quote.chain}`;
196
-
197
- const expiryDate = new Date(quote.expires_at);
198
- const expiryStr = expiryDate.toLocaleString();
199
-
200
- const body = `Hello,
201
-
202
- You've initiated a crypto payment on DeSciX. Please complete your payment using the instructions below:
203
-
204
- ═══════════════════════════════════════════════
205
- PAYMENT DETAILS
206
- ═══════════════════════════════════════════════
207
-
208
- Quote ID: ${quote.quote_id}
209
- Amount: ${quote.amount_formatted}
210
- USD Value: ${quote.usd_amount_formatted || `$${quote.usd_amount}`}
211
- Chain: ${quote.chain_name || quote.chain?.toUpperCase()}
212
-
213
- DEPOSIT ADDRESS:
214
- ${quote.deposit_address}
215
-
216
- ⚠️ IMPORTANT: Send exactly ${quote.amount_formatted} to the address above.
217
- Sending the wrong amount may result in processing issues.
218
-
219
- Expires: ${expiryStr}
220
-
221
- ═══════════════════════════════════════════════
222
-
223
- Once your payment is confirmed on the blockchain, we'll send you a confirmation email.
224
-
225
- If you did not initiate this payment, please ignore this email.
226
-
227
- — The DeSciX Team
228
- `;
229
-
230
- // Send to user
231
- await sendEmail(recipientEmail, subject, body);
232
-
233
- // CC admin group if configured
234
- const adminGroup = utils.DESCIX_ADMIN_GROUP;
235
- if (adminGroup) {
236
- try {
237
- await sendEmail(adminGroup, `[ADMIN CC] ${subject}`, `Payment pending for: ${recipientEmail}\n\n${body}`);
238
- } catch (error) {
239
- console.warn(`Failed to send admin CC email: ${error.message}`);
240
- }
241
- }
242
- }
243
-
244
180
  /**
245
181
  * Render the receipt for a queued airdrop-wallet migration (the `pending_migrations` lane).
246
182
  *
@@ -305,74 +241,3 @@ export async function sendMigrationQueued(migration, recipientEmail) {
305
241
  await sendEmail(recipientEmail, subject, body);
306
242
  }
307
243
 
308
- /**
309
- * Send payment confirmation notification.
310
- *
311
- * @param {Object} quote - The fulfilled quote object
312
- * @param {string} quote.quote_id - Unique quote identifier
313
- * @param {string} quote.usd_amount - USD amount
314
- * @param {string} quote.chain - Chain identifier
315
- * @param {string} quote.payment_tx_hash - Transaction hash
316
- * @param {Object} fulfillment - Fulfillment details
317
- * @param {string} fulfillment.type - Fulfillment type (usdcx_credit or token_mint)
318
- * @param {number} [fulfillment.usdcx_credited] - USDCX amount credited
319
- * @param {number} [fulfillment.tokens_minted] - Tokens minted
320
- * @param {string} [fulfillment.token_symbol] - Token symbol
321
- * @param {string} recipientEmail - Recipient email address
322
- * @returns {Promise<void>}
323
- */
324
- export async function sendPaymentConfirmation(quote, fulfillment, recipientEmail) {
325
- const utils = getCloudConfig();
326
- const usdAmountFormatted = quote.usd_amount_formatted || `$${quote.usd_amount}`;
327
- const chainName = quote.chain_name || quote.chain?.toUpperCase();
328
-
329
- let subject, creditsText;
330
-
331
- if (fulfillment.type === 'usdcx_credit') {
332
- subject = `Payment Confirmed - ${usdAmountFormatted} USDCX Credited`;
333
- creditsText = `USDCX Credited: ${fulfillment.usdcx_credited?.toFixed(2) || quote.usd_amount}`;
334
- } else if (fulfillment.type === 'token_mint') {
335
- subject = `Payment Confirmed - ${fulfillment.tokens_minted} ${fulfillment.token_symbol} Tokens`;
336
- creditsText = `Tokens Received: ${fulfillment.tokens_minted} ${fulfillment.token_symbol}`;
337
- } else {
338
- subject = `Payment Confirmed - ${usdAmountFormatted}`;
339
- creditsText = `Amount: ${usdAmountFormatted}`;
340
- }
341
-
342
- const body = `Hello,
343
-
344
- Your crypto payment has been confirmed!
345
-
346
- ═══════════════════════════════════════════════
347
- PAYMENT CONFIRMATION
348
- ═══════════════════════════════════════════════
349
-
350
- Quote ID: ${quote.quote_id}
351
- Status: CONFIRMED
352
- Chain: ${chainName}
353
- ${creditsText}
354
-
355
- ${quote.payment_tx_hash ? `Transaction: ${quote.payment_tx_hash}` : ''}
356
-
357
- ═══════════════════════════════════════════════
358
-
359
- Your account has been updated with the purchased credits/tokens.
360
-
361
- Thank you for using DeSciX!
362
-
363
- — The DeSciX Team
364
- `;
365
-
366
- // Send to user
367
- await sendEmail(recipientEmail, subject, body);
368
-
369
- // CC admin group if configured
370
- const adminGroup = utils.DESCIX_ADMIN_GROUP;
371
- if (adminGroup) {
372
- try {
373
- await sendEmail(adminGroup, `[ADMIN CC] ${subject}`, `Payment confirmed for: ${recipientEmail}\n\n${body}`);
374
- } catch (error) {
375
- console.warn(`Failed to send admin CC email: ${error.message}`);
376
- }
377
- }
378
- }
package/src/index.js CHANGED
@@ -46,8 +46,6 @@ export {
46
46
  export {
47
47
  sendEmail,
48
48
  sendVerificationEmail,
49
- sendPaymentPending,
50
- sendPaymentConfirmation,
51
49
  renderMigrationQueuedEmail,
52
50
  sendMigrationQueued,
53
51
  normalizeEmail,
@@ -505,85 +505,6 @@
505
505
  ],
506
506
  "runbookAnchor": null
507
507
  },
508
- {
509
- "verbPath": "buy chains",
510
- "description": "List supported blockchains for payments",
511
- "arguments": [],
512
- "options": [],
513
- "runbookAnchor": null
514
- },
515
- {
516
- "verbPath": "buy poll",
517
- "description": "Poll for quote status until completed (with exponential backoff)",
518
- "arguments": [
519
- {
520
- "name": "quoteId",
521
- "required": true,
522
- "variadic": false,
523
- "description": ""
524
- }
525
- ],
526
- "options": [
527
- {
528
- "flags": "--max <attempts>",
529
- "description": "Maximum poll attempts",
530
- "required": false
531
- },
532
- {
533
- "flags": "--interval <ms>",
534
- "description": "Initial poll interval in ms",
535
- "required": false
536
- }
537
- ],
538
- "runbookAnchor": null
539
- },
540
- {
541
- "verbPath": "buy quote",
542
- "description": "Create a crypto payment quote",
543
- "arguments": [],
544
- "options": [
545
- {
546
- "flags": "-a, --amount <usd>",
547
- "description": "USD amount to purchase",
548
- "required": true
549
- },
550
- {
551
- "flags": "-c, --chain <chain>",
552
- "description": "Blockchain to use (polygon, ethereum, bnb)",
553
- "required": true
554
- },
555
- {
556
- "flags": "-t, --type <type>",
557
- "description": "Purchase type: usdcx or community_token",
558
- "required": false
559
- },
560
- {
561
- "flags": "-e, --email <email>",
562
- "description": "Email for claim link (guest mode)",
563
- "required": false
564
- },
565
- {
566
- "flags": "--community <id>",
567
- "description": "Community ID for community token purchase",
568
- "required": false
569
- }
570
- ],
571
- "runbookAnchor": null
572
- },
573
- {
574
- "verbPath": "buy status",
575
- "description": "Check status of a payment quote",
576
- "arguments": [
577
- {
578
- "name": "quoteId",
579
- "required": true,
580
- "variadic": false,
581
- "description": ""
582
- }
583
- ],
584
- "options": [],
585
- "runbookAnchor": null
586
- },
587
508
  {
588
509
  "verbPath": "chat",
589
510
  "description": "Chat with an app agent. Usage: descix chat \"Your question\" or descix chat -q \"Your question\"",
@@ -1046,18 +967,13 @@
1046
967
  },
1047
968
  {
1048
969
  "verbPath": "credits buy",
1049
- "description": "Buy AI credits with USD (Stripe checkout)",
970
+ "description": "Buy AI credits: starts a Powch checkout and prints its Stripe Checkout URL (the Powch Buy menu is the same purchase)",
1050
971
  "arguments": [],
1051
972
  "options": [
1052
973
  {
1053
974
  "flags": "--usd <amount>",
1054
- "description": "USD amount of credits to buy",
975
+ "description": "USD amount of credits to buy: a listed bundle (`descix credits balance` lists them)",
1055
976
  "required": true
1056
- },
1057
- {
1058
- "flags": "--return-base <url>",
1059
- "description": "Base URL for the checkout success/cancel landing (default: the API origin in use)",
1060
- "required": false
1061
977
  }
1062
978
  ],
1063
979
  "runbookAnchor": null
@@ -1951,12 +1867,12 @@
1951
1867
  },
1952
1868
  {
1953
1869
  "flags": "-a, --app <id>",
1954
- "description": "App ID (auto-detects from context)",
1870
+ "description": "App ID (auto-detects from context; in a gateway workspace, the listed repo holding this app supplies the manifest and files)",
1955
1871
  "required": false
1956
1872
  },
1957
1873
  {
1958
1874
  "flags": "-p, --path <localPath>",
1959
- "description": "Local directory to deploy (ignored when site manifest exists)",
1875
+ "description": "Local directory to deploy (ignored when site manifest exists; in a gateway workspace only an explicit -p counts, and it uploads that directory for an app no listed repo holds)",
1960
1876
  "required": false
1961
1877
  },
1962
1878
  {
@@ -799,7 +799,7 @@ export const NATIVE_MCP_TOOLS = Object.freeze([
799
799
  // Read-only; the METERED RAG/agent surface (WS-A3) debits this balance per call.
800
800
  // NEVER exposes pricing internals — USD balance figures only.
801
801
  name: 'get_credit_balance',
802
- description: 'Get your platform-wide AI-credits balance in USD. Metered AI calls (RAG chat / agents, e.g. ask_question_to_app and query_knowledge_base) debit this balance. At a $0 balance a free daily credit auto-applies to your first metered call each day, so metered tools are usable without buying anything first (the response reports daily_free_credit_usd and daily_free_credit_available_today). Buy more credits with the descix CLI (`descix credits buy`) or the platform store. Programmatic purchase: create_stripe_checkout_session with purchase_type "ai_credits" and amount_usd returns a Stripe checkout URL.',
802
+ description: 'Get your platform-wide AI-credits balance in USD. Metered AI calls (RAG chat / agents, e.g. ask_question_to_app and query_knowledge_base) debit this balance. At a $0 balance a free daily credit auto-applies to your first metered call each day, so metered tools are usable without buying anything first (the response reports daily_free_credit_usd and daily_free_credit_available_today). Buy more credits in the Powch Buy menu or with the descix CLI (`descix credits buy --usd <amount>`). Programmatic purchase: the Powch command create_checkout_session (through execute_remote_command) with purchase_type "ai_credits" and amount_usd (a listed bundle from purchase_catalogue in this response) returns a Stripe Checkout url.',
803
803
  mutating: false,
804
804
  oauthReadonly: true,
805
805
  inputSchema: {
@@ -109,7 +109,7 @@ const FIRST_CONTACT_SCRIPT = Object.freeze([
109
109
  // starting contribution/airdrop-eligibility position finishing setup confers. Dollar figures are
110
110
  // the current launch values (config-driven server-side: PATRONAGE_SETUP_BONUS_USD /
111
111
  // SPONSORED_CREDITS_USER_DAILY_CAP_USD) — named here as the current amounts, not authoritative.
112
- do: 'Now explain the tokenomics model: metering is the default for platform AI services, exactly like the Claude API itself. RAG calls draw on a shared USD AI-credit balance by actual usage; get_credit_balance shows the balance any time (and whether today\'s free daily credit is still available), and credits can be bought with the descix CLI or the platform store. Two distinct things keep first contact free — keep them separate: (1) a ONE-TIME welcome credit (currently $10) is added to your balance when you finish this setup — a grant to explore with, NOT earned and NOT a community token; (2) SEPARATELY, a free daily credit (currently $10/day) auto-applies to your first metered call each day and renews every day. Earning is different again: contributions, disputatio participation, and airdrops can earn community tokens — and finishing setup also gives you a small starting contribution position, so you land already eligible to accrue toward airdrops (claiming a community\'s airdrop still needs that community\'s membership). Setup is where this is explained once — the tools themselves do not nag about cost.',
112
+ do: 'Now explain the tokenomics model: metering is the default for platform AI services, exactly like the Claude API itself. RAG calls draw on a shared USD AI-credit balance by actual usage; get_credit_balance shows the balance any time (and whether today\'s free daily credit is still available), and credits can be bought in the Powch Buy menu or with the descix CLI (`descix credits buy`). Two distinct things keep first contact free — keep them separate: (1) a ONE-TIME welcome credit (currently $10) is added to your balance when you finish this setup — a grant to explore with, NOT earned and NOT a community token; (2) SEPARATELY, a free daily credit (currently $10/day) auto-applies to your first metered call each day and renews every day. Earning is different again: contributions, disputatio participation, and airdrops can earn community tokens — and finishing setup also gives you a small starting contribution position, so you land already eligible to accrue toward airdrops (claiming a community\'s airdrop still needs that community\'s membership). Setup is where this is explained once — the tools themselves do not nag about cost.',
113
113
  }),
114
114
  Object.freeze({
115
115
  step: 'verify_settlement',