@proveanything/smartlinks 2.2.11 → 2.2.13

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.
@@ -75,6 +75,11 @@ export var guide;
75
75
  },
76
76
  tool: (name, args, sessionId) => post(`${base(collectionId)}/tool`, { name, args, sessionId }),
77
77
  event: (event) => { void post(`${base(collectionId)}/event`, event).catch(() => undefined); },
78
+ // What each reply used: the business is charged for it. One retry; a repeat is counted once.
79
+ usage: (report) => {
80
+ const send = () => post(`${base(collectionId)}/usage`, report);
81
+ void send().catch(() => new Promise((r) => setTimeout(r, 3000)).then(send)).catch(() => undefined);
82
+ },
78
83
  },
79
84
  onToolReply: async (_name, reply) => {
80
85
  var _a, _b;
@@ -1,4 +1,4 @@
1
- import type { PaymentsPublicConfig, PaymentIntentInput, PaymentIntentResult, PaymentsStatus, PaymentsConnectInput, PaymentListParams, PaymentList, PaymentSyncInput, PaymentSyncResult, PaymentDomainResult } from '../types/payments.js';
1
+ import type { PaymentsPublicConfig, PaymentIntentInput, PaymentIntentResult, PaymentsStatus, PaymentsConnectInput, PaymentListParams, PaymentList, PaymentSyncInput, PaymentSyncResult, PaymentDomainResult, PaymentSetupRequest, PaymentSetupRequestInput } from '../types/payments.js';
2
2
  export declare namespace payments {
3
3
  /**
4
4
  * Can this business take payments, and what Stripe.js needs. `ready` is false until the business has
@@ -52,6 +52,21 @@ export declare namespace payments {
52
52
  connected: false;
53
53
  disconnectedAccountId: string | null;
54
54
  }>;
55
+ /**
56
+ * Ask someone outside Studio (the finance team, the client a business was built for) to connect the
57
+ * business's Stripe account. SmartLinks emails them a link to a page that starts Stripe's set-up: no
58
+ * SmartLinks login, nothing else in reach. The link works for 7 days; a new request replaces it. The
59
+ * admin who sent it is emailed when it's done (naming the Stripe account) or if the person wasn't
60
+ * expecting it. Refused (409 ALREADY_CONNECTED) once payments are set up: disconnect first.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * await payments.admin.requestSetup(collectionId, { email: 'finance@example.org', name: 'Sam' })
65
+ * ```
66
+ */
67
+ function requestSetup(collectionId: string, input: PaymentSetupRequestInput): Promise<PaymentSetupRequest>;
68
+ /** Cancel the waiting set-up request: its link stops working. → the request, or null when there was none. */
69
+ function cancelSetupRequest(collectionId: string): Promise<PaymentSetupRequest | null>;
55
70
  /** An app's in-page payments on the business's account, newest first (for reconciling). */
56
71
  function intents(collectionId: string, params?: PaymentListParams): Promise<PaymentList>;
57
72
  /**
@@ -3,7 +3,7 @@
3
3
  // takes money on it: no Stripe keys in apps. Pages use `payments.config` and `payments.createIntent` for
4
4
  // in-page payments (Payment Element, Apple Pay, Google Pay); Studio and admin screens use `payments.admin`.
5
5
  // Fixed-price sales use a hosted checkout instead: `shop.checkout`, `memberships`.
6
- import { request, post } from '../http.js';
6
+ import { request, post, del } from '../http.js';
7
7
  const pub = (collectionId) => `/public/collection/${encodeURIComponent(collectionId)}/payments`;
8
8
  const adm = (collectionId) => `/admin/collection/${encodeURIComponent(collectionId)}/payments`;
9
9
  export var payments;
@@ -70,6 +70,27 @@ export var payments;
70
70
  return post(`${adm(collectionId)}/disconnect`, {});
71
71
  }
72
72
  admin.disconnect = disconnect;
73
+ /**
74
+ * Ask someone outside Studio (the finance team, the client a business was built for) to connect the
75
+ * business's Stripe account. SmartLinks emails them a link to a page that starts Stripe's set-up: no
76
+ * SmartLinks login, nothing else in reach. The link works for 7 days; a new request replaces it. The
77
+ * admin who sent it is emailed when it's done (naming the Stripe account) or if the person wasn't
78
+ * expecting it. Refused (409 ALREADY_CONNECTED) once payments are set up: disconnect first.
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * await payments.admin.requestSetup(collectionId, { email: 'finance@example.org', name: 'Sam' })
83
+ * ```
84
+ */
85
+ async function requestSetup(collectionId, input) {
86
+ return post(`${adm(collectionId)}/setup-request`, input);
87
+ }
88
+ admin.requestSetup = requestSetup;
89
+ /** Cancel the waiting set-up request: its link stops working. → the request, or null when there was none. */
90
+ async function cancelSetupRequest(collectionId) {
91
+ return del(`${adm(collectionId)}/setup-request`);
92
+ }
93
+ admin.cancelSetupRequest = cancelSetupRequest;
73
94
  /** An app's in-page payments on the business's account, newest first (for reconciling). */
74
95
  async function intents(collectionId, params) {
75
96
  const q = new URLSearchParams();
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 2.2.11 | Generated: 2026-12-05T10:45:08.620Z
3
+ Version: 2.2.13 | Generated: 2026-12-05T16:00:35.255Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -11673,12 +11673,41 @@ interface PaymentIntentResult {
11673
11673
  interface PaymentsStatus {
11674
11674
  connected: boolean
11675
11675
  accountId?: string
11676
+ name?: string | null
11676
11677
  chargesEnabled?: boolean | null
11677
11678
  detailsSubmitted?: boolean | null
11678
11679
  payoutsEnabled?: boolean | null
11679
11680
  platformReady: boolean
11680
11681
  publishableKeySet: boolean
11681
11682
  fees: Array<{ appId: string; bps: number; percent: number }>
11683
+ setupRequest?: PaymentSetupRequest | null
11684
+ }
11685
+ ```
11686
+
11687
+ **PaymentSetupRequest** (interface)
11688
+ ```typescript
11689
+ interface PaymentSetupRequest {
11690
+ id: string
11691
+ email: string
11692
+ name: string | null
11693
+ note: string | null
11694
+ sentByEmail: string | null
11695
+ sentByName: string | null
11696
+ sentAt: string
11697
+ expiresAt: string
11698
+ status: 'pending' | 'expired' | 'done' | 'cancelled' | 'reported'
11699
+ startedAt: string | null
11700
+ finishedAt: string | null
11701
+ stripeAccountName: string | null
11702
+ }
11703
+ ```
11704
+
11705
+ **PaymentSetupRequestInput** (interface)
11706
+ ```typescript
11707
+ interface PaymentSetupRequestInput {
11708
+ email: string
11709
+ name?: string
11710
+ note?: string
11682
11711
  }
11683
11712
  ```
11684
11713
 
@@ -16469,6 +16498,12 @@ Stripe's page to connect (or finish connecting) the business's Stripe account. S
16469
16498
  **disconnect**(collectionId: string) → `Promise<`
16470
16499
  Stop using the business's Stripe account. SmartLinks forgets it (apps can no longer take payments until one is connected again); the Stripe account itself stays the business's own, with the payments already in it. Connecting again makes a new account.
16471
16500
 
16501
+ **requestSetup**(collectionId: string, input: PaymentSetupRequestInput) → `Promise<PaymentSetupRequest>`
16502
+ Ask someone outside Studio (the finance team, the client a business was built for) to connect the business's Stripe account. SmartLinks emails them a link to a page that starts Stripe's set-up: no SmartLinks login, nothing else in reach. The link works for 7 days; a new request replaces it. The admin who sent it is emailed when it's done (naming the Stripe account) or if the person wasn't expecting it. Refused (409 ALREADY_CONNECTED) once payments are set up: disconnect first. ```typescript await payments.admin.requestSetup(collectionId, { email: 'finance@example.org', name: 'Sam' }) ```
16503
+
16504
+ **cancelSetupRequest**(collectionId: string) → `Promise<PaymentSetupRequest | null>`
16505
+ Cancel the waiting set-up request: its link stops working. → the request, or null when there was none.
16506
+
16472
16507
  **intents**(collectionId: string, params?: PaymentListParams) → `Promise<PaymentList>`
16473
16508
  An app's in-page payments on the business's account, newest first (for reconciling).
16474
16509
 
@@ -1,70 +1,74 @@
1
- # The customer guide
2
-
3
- A business's assistant for its visitors, in Portal and the Hub, by voice or by text. It knows the business
4
- (a brief written for visitors), where the visitor is (the product, the item scanned, the app on screen) and
5
- what that screen says, and it can open another app for them. The business switches it on and shapes it in
6
- Studio (Configure → Guide). Design: prove `server/docs/design/customer-assistant.md`.
7
-
8
- Everything that shapes the guide — its instructions, voice, tools and limits — is fixed by SmartLinks when a
9
- conversation starts. A page only says where the visitor is and what is on their screen.
10
-
11
- ---
12
-
13
- ## For a host (Portal, the Hub, a custom site)
14
-
15
- ```ts
16
- import * as SL from '@proveanything/smartlinks'
17
-
18
- const info = await SL.ai.guide.get(collectionId, 'portal') // { enabled, name, modes, suggestions, handoff }
19
- if (!info.enabled) return
20
-
21
- const chat = await SL.ai.guide.start(collectionId, {
22
- surface: 'portal', // or 'hub'
23
- mode: info.modes.start, // 'voice' or 'text'
24
- productId, proofId,
25
- apps: [{ id: 'recipes', title: 'Recipes' }], // the apps on the visitor's page: their pages come from the deep-link registry
26
- where: { appId: 'recipes', path: '/method' }, // where the visitor is now
27
- screen: await SL.ai.content.request({ frame: appIframe.contentWindow }),
28
- showApp: (appId) => openApp(appId),
29
- openPage: ({ appId, path, params }) => openApp(appId, path, params), // a page the guide chose (look_in → open_page)
30
- goTo: (productId) => openProduct(productId), // another product it found (find → go_to)
31
- onShow: (card) => showFound(card), // what find found, rows with goTo
32
- offerPerson: (handoff) => showContact(handoff),
33
- onState: setState, // idle | connecting | listening | hearing | thinking | speaking | paused | error
34
- onCaption: setCaption, // what it is saying or writing, as it goes
35
- onError: setError,
36
- })
37
-
38
- chat.pause(); chat.resume(); chat.stop()
39
- chat.send('What is it made of?') // text mode (works in voice mode too)
40
- chat.note('The visitor is now on Dishwasher DW-60 (product id p9), in Manual at /troubleshooting.') // where they are; it doesn't answer
41
- ```
42
-
43
- The guide knows the pages around the visitor from SmartLinks' deep-link registry (`linkable` in each app's
44
- manifest, and each app's config `linkable` per collection and per product; see deep-link-discovery.md).
45
- Register your pages there and the guide can open them by name.
46
-
47
- - Voice needs the microphone; ask for it on a tap (browsers require it).
48
- - A signed-in visitor (Auth Kit bearer on the SDK) owns their conversation; otherwise it is anonymous.
49
- - The guide's `read_screen` tool asks the app on screen what it shows (below). Pass `readScreen` to answer
50
- it yourself.
51
- - Limits per visitor and per business are set in Studio; a refusal comes back as `GUIDE_LIMIT` (429).
52
-
53
- ## For an app: say what your screen shows
54
-
55
- ```ts
56
- useEffect(() => SL.ai.content.provide(() => ({
57
- appId: 'pages',
58
- title: page.title,
59
- content: page.text, // plain words: the exhibit, the recipe, what this form is for
60
- })), [page])
61
- ```
62
-
63
- `provide` works the same in an iframe (the host asks by message) and as a direct component. Return what a
64
- person reading the screen would take in, not markup. Without it, a host may fall back to the page's text.
65
-
66
- ## Your own live conversation
67
-
68
- `SL.ai.live.start({ endpoints: { mint, tool, event }, mode, screenTools, … })` is the client the guide and the
69
- Studio assistant use: WebRTC straight to the realtime service with a key your server minted, tools split
70
- between the page (`screenTools`) and your server (`endpoints.tool`). See `src/live.ts`.
1
+ # The customer guide
2
+
3
+ A business's assistant for its visitors, in Portal and the Hub, by voice or by text. It knows the business
4
+ (a brief written for visitors), where the visitor is (the product, the item scanned, the app on screen) and
5
+ what that screen says, and it can open another app for them. The business switches it on and shapes it in
6
+ Studio (Configure → Guide). Design: prove `server/docs/design/customer-assistant.md`.
7
+
8
+ Everything that shapes the guide — its instructions, voice, tools and limits — is fixed by SmartLinks when a
9
+ conversation starts. A page only says where the visitor is and what is on their screen.
10
+
11
+ ---
12
+
13
+ ## For a host (Portal, the Hub, a custom site)
14
+
15
+ ```ts
16
+ import * as SL from '@proveanything/smartlinks'
17
+
18
+ const info = await SL.ai.guide.get(collectionId, 'portal') // { enabled, name, modes, suggestions, handoff }
19
+ if (!info.enabled) return
20
+
21
+ const chat = await SL.ai.guide.start(collectionId, {
22
+ surface: 'portal', // or 'hub'
23
+ mode: info.modes.start, // 'voice' or 'text'
24
+ productId, proofId,
25
+ apps: [{ id: 'recipes', title: 'Recipes' }], // the apps on the visitor's page: their pages come from the deep-link registry
26
+ where: { appId: 'recipes', path: '/method' }, // where the visitor is now
27
+ screen: await SL.ai.content.request({ frame: appIframe.contentWindow }),
28
+ showApp: (appId) => openApp(appId),
29
+ openPage: ({ appId, path, params }) => openApp(appId, path, params), // a page the guide chose (look_in → open_page)
30
+ goTo: (productId) => openProduct(productId), // another product it found (find → go_to)
31
+ onShow: (card) => showFound(card), // what find found, rows with goTo
32
+ offerPerson: (handoff) => showContact(handoff),
33
+ onState: setState, // idle | connecting | listening | hearing | thinking | speaking | paused | error
34
+ onCaption: setCaption, // what it is saying or writing, as it goes
35
+ onError: setError,
36
+ })
37
+
38
+ chat.pause(); chat.resume(); chat.stop()
39
+ chat.send('What is it made of?') // text mode (works in voice mode too)
40
+ chat.note('The visitor is now on Dishwasher DW-60 (product id p9), in Manual at /troubleshooting.') // where they are; it doesn't answer
41
+ ```
42
+
43
+ The guide knows the pages around the visitor from SmartLinks' deep-link registry (`linkable` in each app's
44
+ manifest, and each app's config `linkable` per collection and per product; see deep-link-discovery.md).
45
+ Register your pages there and the guide can open them by name.
46
+
47
+ - Voice needs the microphone; ask for it on a tap (browsers require it).
48
+ - A signed-in visitor (Auth Kit bearer on the SDK) owns their conversation; otherwise it is anonymous.
49
+ - The guide's `read_screen` tool asks the app on screen what it shows (below). Pass `readScreen` to answer
50
+ it yourself.
51
+ - Limits per visitor and per business are set in Studio; a refusal comes back as `GUIDE_LIMIT` (429).
52
+ - Conversations run on the business's AI credits. With none left the guide doesn't start: `GUIDE_PAUSED`
53
+ (402), with a plain message to show. Each reply's usage is passed back to SmartLinks for charging
54
+ automatically (`ai.guide.start` does this; a custom client built on `startLive` should set
55
+ `endpoints.usage`).
56
+
57
+ ## For an app: say what your screen shows
58
+
59
+ ```ts
60
+ useEffect(() => SL.ai.content.provide(() => ({
61
+ appId: 'pages',
62
+ title: page.title,
63
+ content: page.text, // plain words: the exhibit, the recipe, what this form is for
64
+ })), [page])
65
+ ```
66
+
67
+ `provide` works the same in an iframe (the host asks by message) and as a direct component. Return what a
68
+ person reading the screen would take in, not markup. Without it, a host may fall back to the page's text.
69
+
70
+ ## Your own live conversation
71
+
72
+ `SL.ai.live.start({ endpoints: { mint, tool, event }, mode, screenTools, … })` is the client the guide and the
73
+ Studio assistant use: WebRTC straight to the realtime service with a key your server minted, tools split
74
+ between the page (`screenTools`) and your server (`endpoints.tool`). See `src/live.ts`.
@@ -82,6 +82,23 @@ await payments.admin.disconnect(collectionId) // → { connected: false, discon
82
82
  Disconnecting stops every app taking payments until an account is connected again. SmartLinks forgets the
83
83
  account; the Stripe account stays the business's own, with its payments. Connecting again makes a new one.
84
84
 
85
+ ### Asking someone else to set it up
86
+
87
+ Often the person with the business's Stripe login isn't the one in Studio: the finance team, or the client
88
+ a business was built for. Email them a link instead of giving them a login:
89
+
90
+ ```typescript
91
+ await payments.admin.requestSetup(collectionId, { email: 'finance@example.org', name: 'Sam', note: 'For the donations page' })
92
+ // status(…).setupRequest → { email, status: 'pending' | 'expired' | 'done' | 'cancelled' | 'reported', stripeAccountName, … }
93
+ await payments.admin.cancelSetupRequest(collectionId) // the link stops working
94
+ ```
95
+
96
+ SmartLinks sends the email. Its link opens a SmartLinks page that only starts Stripe's set-up for this
97
+ business, with no login. It works for 7 days, and a new request replaces it. It can't be used once payments
98
+ are set up, and `requestSetup` is refused then (409 `ALREADY_CONNECTED`): disconnect first. The admin who
99
+ sent it is emailed when it's done, naming the Stripe account now taking the money, or if the person says
100
+ they weren't expecting it (which cancels it).
101
+
85
102
  ### Reconciling an app's payments
86
103
 
87
104
  ```typescript
package/dist/index.d.ts CHANGED
@@ -24,7 +24,7 @@ export { normaliseAdminCardPayload, ADMIN_CARD_MAX_BYTES } from './adminCardPayl
24
24
  export { SHARED_DEPENDENCY_CONTRACT_VERSION, SHARED_DEPENDENCIES, SHARED_DEPENDENCY_SPECIFIERS, importMapPathFor, getHostSharedDependencies, } from './shared-dependencies.js';
25
25
  export type { SharedDependency, HostSharedDependencies } from './shared-dependencies.js';
26
26
  export type { GuideSurface, GuideInfo, ScreenContent, GuideWhere, GuideNavigate, GuideCard, GuideStartOptions } from './api/aiGuide.js';
27
- export type { LiveState, LiveHandle, LiveOptions, LiveEndpoints, LiveEvent, LiveMintReply, LiveToolReply, LiveToolHandler } from './live.js';
27
+ export type { LiveState, LiveHandle, LiveOptions, LiveEndpoints, LiveEvent, LiveMintReply, LiveToolReply, LiveToolHandler, LiveUsageReport } from './live.js';
28
28
  export { API_VERSION, SDK_VERSION, API_VERSION_HEADER, SDK_HEADER, APP_HEADER, CLIENT_HEADER_NAMES } from './apiVersion.js';
29
29
  export { AI_TOOL_NAMES, BUILTIN_AI_TOOLS, getBuiltinAiTool } from './ai-tools.js';
30
30
  export type { BuiltinAiToolDescriptor } from './ai-tools.js';
package/dist/live.d.ts CHANGED
@@ -37,6 +37,20 @@ export interface LiveEndpoints {
37
37
  tool: (name: string, args: Record<string, unknown>, sessionId: string | null) => Promise<LiveToolReply>;
38
38
  /** Log what happened here, into SmartLinks' logs. Fire and forget. */
39
39
  event?: (event: LiveEvent) => void;
40
+ /**
41
+ * What one reply used, as the provider reported it at the end of the reply (`response.usage`).
42
+ * SmartLinks charges live conversations from these reports, so every client should pass them on.
43
+ * Fire and forget; a repeated report of the same reply is counted once.
44
+ */
45
+ usage?: (report: LiveUsageReport) => void;
46
+ }
47
+ /** One reply's usage, passed on for charging. */
48
+ export interface LiveUsageReport {
49
+ sessionId: string;
50
+ /** The provider's id for the reply: each is counted once. */
51
+ responseId: string;
52
+ /** The provider's usage numbers for the reply, as given. */
53
+ usage: Record<string, unknown>;
40
54
  }
41
55
  export interface LiveOptions {
42
56
  endpoints: LiveEndpoints;
package/dist/live.js CHANGED
@@ -124,12 +124,12 @@ export async function startLive(opts) {
124
124
  send({ type: 'conversation.item.create', item: { type: 'function_call_output', call_id: call.call_id, output: JSON.stringify(output !== null && output !== void 0 ? output : {}) } });
125
125
  }
126
126
  dc.onmessage = (e) => {
127
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
127
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
128
128
  let ev;
129
129
  try {
130
130
  ev = JSON.parse(String(e.data));
131
131
  }
132
- catch (_l) {
132
+ catch (_o) {
133
133
  return;
134
134
  }
135
135
  const type = String((_a = ev['type']) !== null && _a !== void 0 ? _a : '');
@@ -161,7 +161,14 @@ export async function startLive(opts) {
161
161
  log({ kind: 'reply', detail: caption.trim().slice(0, 300) });
162
162
  }
163
163
  const response = ((_e = ev['response']) !== null && _e !== void 0 ? _e : {});
164
- const calls = ((_f = response.output) !== null && _f !== void 0 ? _f : []).filter((o) => o['type'] === 'function_call');
164
+ // Every reply (finished or cut short) is charged from what the provider says it used.
165
+ if (sessionId && typeof response.id === 'string' && response.usage && typeof response.usage === 'object') {
166
+ try {
167
+ (_g = (_f = opts.endpoints).usage) === null || _g === void 0 ? void 0 : _g.call(_f, { sessionId, responseId: response.id, usage: response.usage });
168
+ }
169
+ catch ( /* never stops the conversation */_p) { /* never stops the conversation */ }
170
+ }
171
+ const calls = ((_h = response.output) !== null && _h !== void 0 ? _h : []).filter((o) => o['type'] === 'function_call');
165
172
  if (calls.length) {
166
173
  setState('thinking');
167
174
  void Promise.all(calls.map((c) => { var _a, _b, _c; return runTool({ name: String((_a = c['name']) !== null && _a !== void 0 ? _a : ''), call_id: String((_b = c['call_id']) !== null && _b !== void 0 ? _b : ''), arguments: String((_c = c['arguments']) !== null && _c !== void 0 ? _c : '') }); }))
@@ -174,13 +181,13 @@ export async function startLive(opts) {
174
181
  setState('listening');
175
182
  }
176
183
  else if (type === 'error') {
177
- const err = ((_g = ev['error']) !== null && _g !== void 0 ? _g : {});
178
- const message = String((_h = err['message']) !== null && _h !== void 0 ? _h : 'The assistant hit a problem');
184
+ const err = ((_j = ev['error']) !== null && _j !== void 0 ? _j : {});
185
+ const message = String((_k = err['message']) !== null && _k !== void 0 ? _k : 'The assistant hit a problem');
179
186
  // "Nothing to cancel" (a pause or a stop between replies) is not a problem: say nothing.
180
- if (HARMLESS.test(String((_j = err['code']) !== null && _j !== void 0 ? _j : '')) || HARMLESS.test(message))
187
+ if (HARMLESS.test(String((_l = err['code']) !== null && _l !== void 0 ? _l : '')) || HARMLESS.test(message))
181
188
  return;
182
189
  log({ kind: 'error', error: message, detail: 'realtime service' });
183
- (_k = opts.onError) === null || _k === void 0 ? void 0 : _k.call(opts, message);
190
+ (_m = opts.onError) === null || _m === void 0 ? void 0 : _m.call(opts, message);
184
191
  }
185
192
  };
186
193
  pc.onconnectionstatechange = () => {
package/dist/openapi.yaml CHANGED
@@ -36561,6 +36561,8 @@ components:
36561
36561
  type: boolean
36562
36562
  accountId:
36563
36563
  type: string
36564
+ name:
36565
+ type: string
36564
36566
  chargesEnabled:
36565
36567
  type: boolean
36566
36568
  detailsSubmitted:
@@ -36576,11 +36578,70 @@ components:
36576
36578
  items:
36577
36579
  type: object
36578
36580
  additionalProperties: true
36581
+ setupRequest:
36582
+ $ref: "#/components/schemas/PaymentSetupRequest"
36579
36583
  required:
36580
36584
  - connected
36581
36585
  - platformReady
36582
36586
  - publishableKeySet
36583
36587
  - fees
36588
+ PaymentSetupRequest:
36589
+ type: object
36590
+ properties:
36591
+ id:
36592
+ type: string
36593
+ email:
36594
+ type: string
36595
+ name:
36596
+ type: string
36597
+ note:
36598
+ type: string
36599
+ sentByEmail:
36600
+ type: string
36601
+ sentByName:
36602
+ type: string
36603
+ sentAt:
36604
+ type: string
36605
+ expiresAt:
36606
+ type: string
36607
+ status:
36608
+ type: string
36609
+ enum:
36610
+ - pending
36611
+ - expired
36612
+ - done
36613
+ - cancelled
36614
+ - reported
36615
+ startedAt:
36616
+ type: string
36617
+ finishedAt:
36618
+ type: string
36619
+ stripeAccountName:
36620
+ type: string
36621
+ required:
36622
+ - id
36623
+ - email
36624
+ - name
36625
+ - note
36626
+ - sentByEmail
36627
+ - sentByName
36628
+ - sentAt
36629
+ - expiresAt
36630
+ - status
36631
+ - startedAt
36632
+ - finishedAt
36633
+ - stripeAccountName
36634
+ PaymentSetupRequestInput:
36635
+ type: object
36636
+ properties:
36637
+ email:
36638
+ type: string
36639
+ name:
36640
+ type: string
36641
+ note:
36642
+ type: string
36643
+ required:
36644
+ - email
36584
36645
  PaymentsConnectInput:
36585
36646
  type: object
36586
36647
  properties:
@@ -42,6 +42,8 @@ export interface PaymentIntentResult {
42
42
  export interface PaymentsStatus {
43
43
  connected: boolean;
44
44
  accountId?: string;
45
+ /** The connected Stripe account's business name, when Stripe has one. */
46
+ name?: string | null;
45
47
  /** Stripe can take payments for this business. Null when this server can't ask Stripe. */
46
48
  chargesEnabled?: boolean | null;
47
49
  /** The business has given Stripe all it asked for. */
@@ -58,6 +60,39 @@ export interface PaymentsStatus {
58
60
  bps: number;
59
61
  percent: number;
60
62
  }>;
63
+ /** The latest request for someone else to set up payments (`payments.admin.requestSetup`), if any. */
64
+ setupRequest?: PaymentSetupRequest | null;
65
+ }
66
+ /**
67
+ * A request for someone outside Studio (the finance team, the client) to connect the business's Stripe
68
+ * account. They get an email from SmartLinks with a link that works for 7 days and needs no login.
69
+ *
70
+ * status: `pending` (waiting), `expired`, `done` (connected; `stripeAccountName` is the account they chose),
71
+ * `cancelled` (by an admin, a newer request, or payments set up another way), `reported` (the person said
72
+ * they weren't expecting it).
73
+ */
74
+ export interface PaymentSetupRequest {
75
+ id: string;
76
+ email: string;
77
+ name: string | null;
78
+ note: string | null;
79
+ sentByEmail: string | null;
80
+ sentByName: string | null;
81
+ sentAt: string;
82
+ expiresAt: string;
83
+ status: 'pending' | 'expired' | 'done' | 'cancelled' | 'reported';
84
+ /** When they first went on to Stripe. */
85
+ startedAt: string | null;
86
+ finishedAt: string | null;
87
+ stripeAccountName: string | null;
88
+ }
89
+ export interface PaymentSetupRequestInput {
90
+ /** Who will set up payments. */
91
+ email: string;
92
+ /** Their name, for the email's greeting. */
93
+ name?: string;
94
+ /** A short note shown in the email and on the set-up page (up to 500 characters). */
95
+ note?: string;
61
96
  }
62
97
  export interface PaymentsConnectInput {
63
98
  /** Where Stripe sends the person back when they finish (or stop): check `payments.admin.status`. */
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.2.11";
1
+ export declare const SDK_VERSION = "2.2.13";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by scripts/write-version.mjs from package.json. Do not edit.
2
- export const SDK_VERSION = "2.2.11";
2
+ export const SDK_VERSION = "2.2.13";
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 2.2.11 | Generated: 2026-12-05T10:45:08.620Z
3
+ Version: 2.2.13 | Generated: 2026-12-05T16:00:35.255Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -11673,12 +11673,41 @@ interface PaymentIntentResult {
11673
11673
  interface PaymentsStatus {
11674
11674
  connected: boolean
11675
11675
  accountId?: string
11676
+ name?: string | null
11676
11677
  chargesEnabled?: boolean | null
11677
11678
  detailsSubmitted?: boolean | null
11678
11679
  payoutsEnabled?: boolean | null
11679
11680
  platformReady: boolean
11680
11681
  publishableKeySet: boolean
11681
11682
  fees: Array<{ appId: string; bps: number; percent: number }>
11683
+ setupRequest?: PaymentSetupRequest | null
11684
+ }
11685
+ ```
11686
+
11687
+ **PaymentSetupRequest** (interface)
11688
+ ```typescript
11689
+ interface PaymentSetupRequest {
11690
+ id: string
11691
+ email: string
11692
+ name: string | null
11693
+ note: string | null
11694
+ sentByEmail: string | null
11695
+ sentByName: string | null
11696
+ sentAt: string
11697
+ expiresAt: string
11698
+ status: 'pending' | 'expired' | 'done' | 'cancelled' | 'reported'
11699
+ startedAt: string | null
11700
+ finishedAt: string | null
11701
+ stripeAccountName: string | null
11702
+ }
11703
+ ```
11704
+
11705
+ **PaymentSetupRequestInput** (interface)
11706
+ ```typescript
11707
+ interface PaymentSetupRequestInput {
11708
+ email: string
11709
+ name?: string
11710
+ note?: string
11682
11711
  }
11683
11712
  ```
11684
11713
 
@@ -16469,6 +16498,12 @@ Stripe's page to connect (or finish connecting) the business's Stripe account. S
16469
16498
  **disconnect**(collectionId: string) → `Promise<`
16470
16499
  Stop using the business's Stripe account. SmartLinks forgets it (apps can no longer take payments until one is connected again); the Stripe account itself stays the business's own, with the payments already in it. Connecting again makes a new account.
16471
16500
 
16501
+ **requestSetup**(collectionId: string, input: PaymentSetupRequestInput) → `Promise<PaymentSetupRequest>`
16502
+ Ask someone outside Studio (the finance team, the client a business was built for) to connect the business's Stripe account. SmartLinks emails them a link to a page that starts Stripe's set-up: no SmartLinks login, nothing else in reach. The link works for 7 days; a new request replaces it. The admin who sent it is emailed when it's done (naming the Stripe account) or if the person wasn't expecting it. Refused (409 ALREADY_CONNECTED) once payments are set up: disconnect first. ```typescript await payments.admin.requestSetup(collectionId, { email: 'finance@example.org', name: 'Sam' }) ```
16503
+
16504
+ **cancelSetupRequest**(collectionId: string) → `Promise<PaymentSetupRequest | null>`
16505
+ Cancel the waiting set-up request: its link stops working. → the request, or null when there was none.
16506
+
16472
16507
  **intents**(collectionId: string, params?: PaymentListParams) → `Promise<PaymentList>`
16473
16508
  An app's in-page payments on the business's account, newest first (for reconciling).
16474
16509
 
@@ -1,70 +1,74 @@
1
- # The customer guide
2
-
3
- A business's assistant for its visitors, in Portal and the Hub, by voice or by text. It knows the business
4
- (a brief written for visitors), where the visitor is (the product, the item scanned, the app on screen) and
5
- what that screen says, and it can open another app for them. The business switches it on and shapes it in
6
- Studio (Configure → Guide). Design: prove `server/docs/design/customer-assistant.md`.
7
-
8
- Everything that shapes the guide — its instructions, voice, tools and limits — is fixed by SmartLinks when a
9
- conversation starts. A page only says where the visitor is and what is on their screen.
10
-
11
- ---
12
-
13
- ## For a host (Portal, the Hub, a custom site)
14
-
15
- ```ts
16
- import * as SL from '@proveanything/smartlinks'
17
-
18
- const info = await SL.ai.guide.get(collectionId, 'portal') // { enabled, name, modes, suggestions, handoff }
19
- if (!info.enabled) return
20
-
21
- const chat = await SL.ai.guide.start(collectionId, {
22
- surface: 'portal', // or 'hub'
23
- mode: info.modes.start, // 'voice' or 'text'
24
- productId, proofId,
25
- apps: [{ id: 'recipes', title: 'Recipes' }], // the apps on the visitor's page: their pages come from the deep-link registry
26
- where: { appId: 'recipes', path: '/method' }, // where the visitor is now
27
- screen: await SL.ai.content.request({ frame: appIframe.contentWindow }),
28
- showApp: (appId) => openApp(appId),
29
- openPage: ({ appId, path, params }) => openApp(appId, path, params), // a page the guide chose (look_in → open_page)
30
- goTo: (productId) => openProduct(productId), // another product it found (find → go_to)
31
- onShow: (card) => showFound(card), // what find found, rows with goTo
32
- offerPerson: (handoff) => showContact(handoff),
33
- onState: setState, // idle | connecting | listening | hearing | thinking | speaking | paused | error
34
- onCaption: setCaption, // what it is saying or writing, as it goes
35
- onError: setError,
36
- })
37
-
38
- chat.pause(); chat.resume(); chat.stop()
39
- chat.send('What is it made of?') // text mode (works in voice mode too)
40
- chat.note('The visitor is now on Dishwasher DW-60 (product id p9), in Manual at /troubleshooting.') // where they are; it doesn't answer
41
- ```
42
-
43
- The guide knows the pages around the visitor from SmartLinks' deep-link registry (`linkable` in each app's
44
- manifest, and each app's config `linkable` per collection and per product; see deep-link-discovery.md).
45
- Register your pages there and the guide can open them by name.
46
-
47
- - Voice needs the microphone; ask for it on a tap (browsers require it).
48
- - A signed-in visitor (Auth Kit bearer on the SDK) owns their conversation; otherwise it is anonymous.
49
- - The guide's `read_screen` tool asks the app on screen what it shows (below). Pass `readScreen` to answer
50
- it yourself.
51
- - Limits per visitor and per business are set in Studio; a refusal comes back as `GUIDE_LIMIT` (429).
52
-
53
- ## For an app: say what your screen shows
54
-
55
- ```ts
56
- useEffect(() => SL.ai.content.provide(() => ({
57
- appId: 'pages',
58
- title: page.title,
59
- content: page.text, // plain words: the exhibit, the recipe, what this form is for
60
- })), [page])
61
- ```
62
-
63
- `provide` works the same in an iframe (the host asks by message) and as a direct component. Return what a
64
- person reading the screen would take in, not markup. Without it, a host may fall back to the page's text.
65
-
66
- ## Your own live conversation
67
-
68
- `SL.ai.live.start({ endpoints: { mint, tool, event }, mode, screenTools, … })` is the client the guide and the
69
- Studio assistant use: WebRTC straight to the realtime service with a key your server minted, tools split
70
- between the page (`screenTools`) and your server (`endpoints.tool`). See `src/live.ts`.
1
+ # The customer guide
2
+
3
+ A business's assistant for its visitors, in Portal and the Hub, by voice or by text. It knows the business
4
+ (a brief written for visitors), where the visitor is (the product, the item scanned, the app on screen) and
5
+ what that screen says, and it can open another app for them. The business switches it on and shapes it in
6
+ Studio (Configure → Guide). Design: prove `server/docs/design/customer-assistant.md`.
7
+
8
+ Everything that shapes the guide — its instructions, voice, tools and limits — is fixed by SmartLinks when a
9
+ conversation starts. A page only says where the visitor is and what is on their screen.
10
+
11
+ ---
12
+
13
+ ## For a host (Portal, the Hub, a custom site)
14
+
15
+ ```ts
16
+ import * as SL from '@proveanything/smartlinks'
17
+
18
+ const info = await SL.ai.guide.get(collectionId, 'portal') // { enabled, name, modes, suggestions, handoff }
19
+ if (!info.enabled) return
20
+
21
+ const chat = await SL.ai.guide.start(collectionId, {
22
+ surface: 'portal', // or 'hub'
23
+ mode: info.modes.start, // 'voice' or 'text'
24
+ productId, proofId,
25
+ apps: [{ id: 'recipes', title: 'Recipes' }], // the apps on the visitor's page: their pages come from the deep-link registry
26
+ where: { appId: 'recipes', path: '/method' }, // where the visitor is now
27
+ screen: await SL.ai.content.request({ frame: appIframe.contentWindow }),
28
+ showApp: (appId) => openApp(appId),
29
+ openPage: ({ appId, path, params }) => openApp(appId, path, params), // a page the guide chose (look_in → open_page)
30
+ goTo: (productId) => openProduct(productId), // another product it found (find → go_to)
31
+ onShow: (card) => showFound(card), // what find found, rows with goTo
32
+ offerPerson: (handoff) => showContact(handoff),
33
+ onState: setState, // idle | connecting | listening | hearing | thinking | speaking | paused | error
34
+ onCaption: setCaption, // what it is saying or writing, as it goes
35
+ onError: setError,
36
+ })
37
+
38
+ chat.pause(); chat.resume(); chat.stop()
39
+ chat.send('What is it made of?') // text mode (works in voice mode too)
40
+ chat.note('The visitor is now on Dishwasher DW-60 (product id p9), in Manual at /troubleshooting.') // where they are; it doesn't answer
41
+ ```
42
+
43
+ The guide knows the pages around the visitor from SmartLinks' deep-link registry (`linkable` in each app's
44
+ manifest, and each app's config `linkable` per collection and per product; see deep-link-discovery.md).
45
+ Register your pages there and the guide can open them by name.
46
+
47
+ - Voice needs the microphone; ask for it on a tap (browsers require it).
48
+ - A signed-in visitor (Auth Kit bearer on the SDK) owns their conversation; otherwise it is anonymous.
49
+ - The guide's `read_screen` tool asks the app on screen what it shows (below). Pass `readScreen` to answer
50
+ it yourself.
51
+ - Limits per visitor and per business are set in Studio; a refusal comes back as `GUIDE_LIMIT` (429).
52
+ - Conversations run on the business's AI credits. With none left the guide doesn't start: `GUIDE_PAUSED`
53
+ (402), with a plain message to show. Each reply's usage is passed back to SmartLinks for charging
54
+ automatically (`ai.guide.start` does this; a custom client built on `startLive` should set
55
+ `endpoints.usage`).
56
+
57
+ ## For an app: say what your screen shows
58
+
59
+ ```ts
60
+ useEffect(() => SL.ai.content.provide(() => ({
61
+ appId: 'pages',
62
+ title: page.title,
63
+ content: page.text, // plain words: the exhibit, the recipe, what this form is for
64
+ })), [page])
65
+ ```
66
+
67
+ `provide` works the same in an iframe (the host asks by message) and as a direct component. Return what a
68
+ person reading the screen would take in, not markup. Without it, a host may fall back to the page's text.
69
+
70
+ ## Your own live conversation
71
+
72
+ `SL.ai.live.start({ endpoints: { mint, tool, event }, mode, screenTools, … })` is the client the guide and the
73
+ Studio assistant use: WebRTC straight to the realtime service with a key your server minted, tools split
74
+ between the page (`screenTools`) and your server (`endpoints.tool`). See `src/live.ts`.
package/docs/payments.md CHANGED
@@ -82,6 +82,23 @@ await payments.admin.disconnect(collectionId) // → { connected: false, discon
82
82
  Disconnecting stops every app taking payments until an account is connected again. SmartLinks forgets the
83
83
  account; the Stripe account stays the business's own, with its payments. Connecting again makes a new one.
84
84
 
85
+ ### Asking someone else to set it up
86
+
87
+ Often the person with the business's Stripe login isn't the one in Studio: the finance team, or the client
88
+ a business was built for. Email them a link instead of giving them a login:
89
+
90
+ ```typescript
91
+ await payments.admin.requestSetup(collectionId, { email: 'finance@example.org', name: 'Sam', note: 'For the donations page' })
92
+ // status(…).setupRequest → { email, status: 'pending' | 'expired' | 'done' | 'cancelled' | 'reported', stripeAccountName, … }
93
+ await payments.admin.cancelSetupRequest(collectionId) // the link stops working
94
+ ```
95
+
96
+ SmartLinks sends the email. Its link opens a SmartLinks page that only starts Stripe's set-up for this
97
+ business, with no login. It works for 7 days, and a new request replaces it. It can't be used once payments
98
+ are set up, and `requestSetup` is refused then (409 `ALREADY_CONNECTED`): disconnect first. The admin who
99
+ sent it is emailed when it's done, naming the Stripe account now taking the money, or if the person says
100
+ they weren't expecting it (which cancels it).
101
+
85
102
  ### Reconciling an app's payments
86
103
 
87
104
  ```typescript
package/openapi.yaml CHANGED
@@ -36561,6 +36561,8 @@ components:
36561
36561
  type: boolean
36562
36562
  accountId:
36563
36563
  type: string
36564
+ name:
36565
+ type: string
36564
36566
  chargesEnabled:
36565
36567
  type: boolean
36566
36568
  detailsSubmitted:
@@ -36576,11 +36578,70 @@ components:
36576
36578
  items:
36577
36579
  type: object
36578
36580
  additionalProperties: true
36581
+ setupRequest:
36582
+ $ref: "#/components/schemas/PaymentSetupRequest"
36579
36583
  required:
36580
36584
  - connected
36581
36585
  - platformReady
36582
36586
  - publishableKeySet
36583
36587
  - fees
36588
+ PaymentSetupRequest:
36589
+ type: object
36590
+ properties:
36591
+ id:
36592
+ type: string
36593
+ email:
36594
+ type: string
36595
+ name:
36596
+ type: string
36597
+ note:
36598
+ type: string
36599
+ sentByEmail:
36600
+ type: string
36601
+ sentByName:
36602
+ type: string
36603
+ sentAt:
36604
+ type: string
36605
+ expiresAt:
36606
+ type: string
36607
+ status:
36608
+ type: string
36609
+ enum:
36610
+ - pending
36611
+ - expired
36612
+ - done
36613
+ - cancelled
36614
+ - reported
36615
+ startedAt:
36616
+ type: string
36617
+ finishedAt:
36618
+ type: string
36619
+ stripeAccountName:
36620
+ type: string
36621
+ required:
36622
+ - id
36623
+ - email
36624
+ - name
36625
+ - note
36626
+ - sentByEmail
36627
+ - sentByName
36628
+ - sentAt
36629
+ - expiresAt
36630
+ - status
36631
+ - startedAt
36632
+ - finishedAt
36633
+ - stripeAccountName
36634
+ PaymentSetupRequestInput:
36635
+ type: object
36636
+ properties:
36637
+ email:
36638
+ type: string
36639
+ name:
36640
+ type: string
36641
+ note:
36642
+ type: string
36643
+ required:
36644
+ - email
36584
36645
  PaymentsConnectInput:
36585
36646
  type: object
36586
36647
  properties:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "2.2.11",
3
+ "version": "2.2.13",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",