@blinkdotnew/cli 0.3.5 → 0.3.6

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/AGENTS.md CHANGED
@@ -38,6 +38,7 @@ packages/cli/
38
38
  │ │ ├── db.ts # blink db query/exec/list → core.blink.new
39
39
  │ │ ├── deploy.ts # blink deploy / deployments / rollback → blink.new
40
40
  │ │ ├── notify.ts # blink notify email → core.blink.new
41
+ │ │ ├── sms.ts # blink sms send → core.blink.new
41
42
  │ │ ├── project.ts # blink project / blink link / blink status → blink.new
42
43
  │ │ ├── rag.ts # blink rag search/upload/collections → core.blink.new
43
44
  │ │ ├── realtime.ts # blink realtime publish → core.blink.new
@@ -144,6 +145,14 @@ blink notify email <project_id> <to> <subject> [body]
144
145
  blink notify email <to> <subject> --file ./body.html
145
146
  ```
146
147
 
148
+ ### SMS (→ core.blink.new /api/v1/sms/send)
149
+ ```bash
150
+ blink sms send <to> <message> # Send SMS from workspace primary number
151
+ blink sms send <to> <message> --from <number> # Send from specific workspace number
152
+ blink sms send <to> <message> --json # Machine-readable output
153
+ ```
154
+ Requires a provisioned workspace phone number (`blink phone buy`). 0.1 credits/message.
155
+
147
156
  ### Connectors (→ core.blink.new /api/v1/connectors/[provider]/execute)
148
157
  ```bash
149
158
  blink connector exec <provider> <action> [params-json] [--account <id>] [--method POST]
package/dist/cli.js CHANGED
@@ -1726,6 +1726,53 @@ The number is permanently returned to the carrier pool. This action cannot be un
1726
1726
  });
1727
1727
  }
1728
1728
 
1729
+ // src/commands/sms.ts
1730
+ function formatPhone2(num) {
1731
+ const m = num.match(/^\+1(\d{3})(\d{3})(\d{4})$/);
1732
+ return m ? `+1 (${m[1]}) ${m[2]}-${m[3]}` : num;
1733
+ }
1734
+ function registerSmsCommands(program2) {
1735
+ const sms = program2.command("sms").description("Send SMS messages from your workspace phone number").addHelpText("after", `
1736
+ Commands:
1737
+ send Send an SMS text message to any phone number
1738
+
1739
+ Examples:
1740
+ $ blink sms send "+14155551234" "Your order is ready!"
1741
+ $ blink sms send "+14155551234" "Code: 492817" --from "+19143720262"
1742
+ $ blink sms send "+447911123456" "Your appointment is confirmed."
1743
+ $ blink sms send "+14155551234" "Hello" --json
1744
+
1745
+ Requires a provisioned workspace phone number (blink phone list / blink phone buy).
1746
+ 0.1 credits per message. Credits charged immediately on send.
1747
+ `).action(() => sms.help());
1748
+ sms.command("send <to> <message>").description("Send an SMS message (0.1 credits per message)").option("--from <number>", "Specific sender number (default: workspace primary)").addHelpText("after", `
1749
+ Examples:
1750
+ $ blink sms send "+14155551234" "Your appointment is confirmed for tomorrow at 2pm."
1751
+ $ blink sms send "+447911123456" "Your order #1042 has shipped!"
1752
+ $ blink sms send "+14155551234" "Code: 492817" --from "+19143720262"
1753
+ $ blink sms send "+14155551234" "Hello" --json
1754
+
1755
+ Phone numbers must be in E.164 format (+14155551234).
1756
+ Messages over 160 characters count as multiple segments (still 0.1 credits).
1757
+ Requires a provisioned workspace phone number: blink phone buy
1758
+ `).action(async (to, message, opts) => {
1759
+ requireToken();
1760
+ const body = { to, message };
1761
+ if (opts.from?.trim()) body.from = opts.from.trim();
1762
+ const result = await withSpinner(
1763
+ `Sending SMS to ${to}...`,
1764
+ () => resourcesRequest("/api/v1/sms/send", { body })
1765
+ );
1766
+ if (isJsonMode()) return printJson(result);
1767
+ console.log(`\u2713 SMS sent`);
1768
+ console.log(` To ${formatPhone2(result.to)}`);
1769
+ console.log(` From ${formatPhone2(result.from)}`);
1770
+ if (result.segment_count > 1) console.log(` Segments ${result.segment_count}`);
1771
+ console.log(` ID ${result.message_id}`);
1772
+ console.log(` Credits ${result.credits_charged}`);
1773
+ });
1774
+ }
1775
+
1729
1776
  // src/lib/api-app.ts
1730
1777
  var BASE_URL2 = process.env.BLINK_APP_URL ?? "https://blink.new";
1731
1778
  async function appRequest(path, opts = {}) {
@@ -2372,6 +2419,7 @@ registerNotifyCommands(program);
2372
2419
  registerConnectorCommands(program);
2373
2420
  registerLinkedInCommands(program);
2374
2421
  registerPhoneCommands(program);
2422
+ registerSmsCommands(program);
2375
2423
  program.command("use <project_id>").description("Set active project for this shell session (alternative to blink link)").option("--export", "Output a shell export statement \u2014 use with eval to actually set it").addHelpText("after", `
2376
2424
  Examples:
2377
2425
  $ blink use proj_xxx Shows the export command to run
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blinkdotnew/cli",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Blink platform CLI — deploy apps, manage databases, generate AI content",
5
5
  "bin": {
6
6
  "blink": "dist/cli.js"
package/src/cli.ts CHANGED
@@ -11,6 +11,7 @@ import { registerNotifyCommands } from './commands/notify.js'
11
11
  import { registerConnectorCommands } from './commands/connector.js'
12
12
  import { registerLinkedInCommands } from './commands/linkedin.js'
13
13
  import { registerPhoneCommands } from './commands/phone.js'
14
+ import { registerSmsCommands } from './commands/sms.js'
14
15
  import { registerDeployCommands } from './commands/deploy.js'
15
16
  import { registerProjectCommands } from './commands/project.js'
16
17
  import { registerAuthCommands } from './commands/auth.js'
@@ -150,6 +151,7 @@ registerNotifyCommands(program)
150
151
  registerConnectorCommands(program)
151
152
  registerLinkedInCommands(program)
152
153
  registerPhoneCommands(program)
154
+ registerSmsCommands(program)
153
155
 
154
156
  program.command('use <project_id>')
155
157
  .description('Set active project for this shell session (alternative to blink link)')
@@ -0,0 +1,71 @@
1
+ import { Command } from 'commander'
2
+ import { resourcesRequest } from '../lib/api-resources.js'
3
+ import { requireToken } from '../lib/auth.js'
4
+ import { printJson, isJsonMode, withSpinner } from '../lib/output.js'
5
+
6
+ interface SmsResult {
7
+ message_id: string
8
+ twilio_sid: string
9
+ status: string
10
+ to: string
11
+ from: string
12
+ segment_count: number
13
+ credits_charged: number
14
+ }
15
+
16
+ function formatPhone(num: string): string {
17
+ const m = num.match(/^\+1(\d{3})(\d{3})(\d{4})$/)
18
+ return m ? `+1 (${m[1]}) ${m[2]}-${m[3]}` : num
19
+ }
20
+
21
+ export function registerSmsCommands(program: Command) {
22
+ const sms = program.command('sms')
23
+ .description('Send SMS messages from your workspace phone number')
24
+ .addHelpText('after', `
25
+ Commands:
26
+ send Send an SMS text message to any phone number
27
+
28
+ Examples:
29
+ $ blink sms send "+14155551234" "Your order is ready!"
30
+ $ blink sms send "+14155551234" "Code: 492817" --from "+19143720262"
31
+ $ blink sms send "+447911123456" "Your appointment is confirmed."
32
+ $ blink sms send "+14155551234" "Hello" --json
33
+
34
+ Requires a provisioned workspace phone number (blink phone list / blink phone buy).
35
+ 0.1 credits per message. Credits charged immediately on send.
36
+ `)
37
+ .action(() => sms.help())
38
+
39
+ sms.command('send <to> <message>')
40
+ .description('Send an SMS message (0.1 credits per message)')
41
+ .option('--from <number>', 'Specific sender number (default: workspace primary)')
42
+ .addHelpText('after', `
43
+ Examples:
44
+ $ blink sms send "+14155551234" "Your appointment is confirmed for tomorrow at 2pm."
45
+ $ blink sms send "+447911123456" "Your order #1042 has shipped!"
46
+ $ blink sms send "+14155551234" "Code: 492817" --from "+19143720262"
47
+ $ blink sms send "+14155551234" "Hello" --json
48
+
49
+ Phone numbers must be in E.164 format (+14155551234).
50
+ Messages over 160 characters count as multiple segments (still 0.1 credits).
51
+ Requires a provisioned workspace phone number: blink phone buy
52
+ `)
53
+ .action(async (to: string, message: string, opts) => {
54
+ requireToken()
55
+ const body: Record<string, string> = { to, message }
56
+ if (opts.from?.trim()) body.from = opts.from.trim()
57
+
58
+ const result = await withSpinner(`Sending SMS to ${to}...`, () =>
59
+ resourcesRequest('/api/v1/sms/send', { body })
60
+ ) as SmsResult
61
+
62
+ if (isJsonMode()) return printJson(result)
63
+
64
+ console.log(`✓ SMS sent`)
65
+ console.log(` To ${formatPhone(result.to)}`)
66
+ console.log(` From ${formatPhone(result.from)}`)
67
+ if (result.segment_count > 1) console.log(` Segments ${result.segment_count}`)
68
+ console.log(` ID ${result.message_id}`)
69
+ console.log(` Credits ${result.credits_charged}`)
70
+ })
71
+ }