@pagelines/sdk 1.0.878 → 1.0.879
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/README.md +68 -68
- package/dist/BotProvider.js +777 -0
- package/dist/BotProvider.js.map +1 -0
- package/dist/{AgentWidgetInline.js → BotWidgetInline.js} +8 -8
- package/dist/BotWidgetInline.js.map +1 -0
- package/dist/{AgentWidgetModal.js → BotWidgetModal.js} +7 -7
- package/dist/BotWidgetModal.js.map +1 -0
- package/dist/{AgentWrap.js → BotWrap.js} +1174 -1145
- package/dist/BotWrap.js.map +1 -0
- package/dist/{agent/AgentController.d.ts → bot/BotController.d.ts} +35 -18
- package/dist/bot/index.d.ts +14 -0
- package/dist/{agent → bot}/schema.d.ts +6 -6
- package/dist/{agent/ui/AgentAvatar.vue.d.ts → bot/ui/BotAvatar.vue.d.ts} +6 -6
- package/dist/{agent/ui/AgentChat.vue.d.ts → bot/ui/BotChat.vue.d.ts} +5 -5
- package/dist/{agent/ui/AgentProvider.vue.d.ts → bot/ui/BotProvider.vue.d.ts} +3 -3
- package/dist/{agent/ui/AgentWrap.vue.d.ts → bot/ui/BotWrap.vue.d.ts} +3 -4
- package/dist/{agent/ui/ElAgentAbout.vue.d.ts → bot/ui/ElBotAbout.vue.d.ts} +2 -2
- package/dist/{agent/ui/ElAgentChat.vue.d.ts → bot/ui/ElBotChat.vue.d.ts} +5 -5
- package/dist/{agent/ui/ElAgentChatPreview.vue.d.ts → bot/ui/ElBotChatPreview.vue.d.ts} +1 -1
- package/dist/{agent/ui/ElAgentHeader.vue.d.ts → bot/ui/ElBotHeader.vue.d.ts} +2 -2
- package/dist/{agent/ui/ElAgentModeSidebar.vue.d.ts → bot/ui/ElBotModeSidebar.vue.d.ts} +2 -2
- package/dist/{agent/ui/ElAgentSidebar.vue.d.ts → bot/ui/ElBotSidebar.vue.d.ts} +2 -2
- package/dist/bot/ui/ElCreateBot.vue.d.ts +12 -0
- package/dist/{agent → bot}/ui/ElModeHeader.vue.d.ts +2 -2
- package/dist/{agent → bot}/ui/ElProvisioningStatus.vue.d.ts +1 -1
- package/dist/{agent → bot}/ui/VoiceMode.vue.d.ts +4 -4
- package/dist/{agent → bot}/utils.d.ts +5 -5
- package/dist/{agent → bot}/voice/provider.d.ts +2 -2
- package/dist/{agent → bot}/voice/providers/livekit/provider.d.ts +4 -4
- package/dist/{agent → bot}/voice/voice-session-client.d.ts +1 -1
- package/dist/{agent → bot}/work-journal.d.ts +1 -1
- package/dist/{agent.js → bot.js} +83 -80
- package/dist/bot.js.map +1 -0
- package/dist/clients/BillingClient.d.ts +1 -1
- package/dist/clients/BotClient.d.ts +26 -0
- package/dist/clients/ChatClient.d.ts +6 -5
- package/dist/clients/ComputerClient.d.ts +16 -0
- package/dist/clients/UserClient.d.ts +4 -7
- package/dist/clients/types.d.ts +7 -2
- package/dist/contract/build.d.ts +1 -2
- package/dist/index.d.ts +3 -2
- package/dist/provider.js +1 -1
- package/dist/provider.js.map +1 -1
- package/dist/provider2.js +14 -14
- package/dist/provider2.js.map +1 -1
- package/dist/sdk.css +1 -1
- package/dist/sdk.js +4 -4
- package/dist/sdkClient.d.ts +33 -376
- package/dist/sdkClient.js +168 -170
- package/dist/sdkClient.js.map +1 -1
- package/dist/useWidgetState.js +9 -9
- package/dist/useWidgetState.js.map +1 -1
- package/dist/widget/PLWidget.d.ts +6 -6
- package/dist/widget/composables/useWidgetState.d.ts +3 -402
- package/dist/widget/index.d.ts +2 -2
- package/dist/widget/mode.d.ts +2 -2
- package/dist/widget/ui/{AgentWidgetInline.vue.d.ts → BotWidgetInline.vue.d.ts} +2 -2
- package/dist/widget/ui/{AgentWidgetModal.vue.d.ts → BotWidgetModal.vue.d.ts} +2 -2
- package/dist/widget/ui/{AgentWidgetPopup.vue.d.ts → BotWidgetPopup.vue.d.ts} +4 -4
- package/dist/widget.js +206 -206
- package/dist/widget.js.map +1 -1
- package/package.json +5 -5
- package/dist/AgentProvider.js +0 -764
- package/dist/AgentProvider.js.map +0 -1
- package/dist/AgentWidgetInline.js.map +0 -1
- package/dist/AgentWidgetModal.js.map +0 -1
- package/dist/AgentWrap.js.map +0 -1
- package/dist/agent/index.d.ts +0 -14
- package/dist/agent/ui/ElCreateAgent.vue.d.ts +0 -277
- package/dist/agent.js.map +0 -1
- package/dist/clients/AgentClient.d.ts +0 -48
- /package/dist/{agent → bot}/VoiceRecorderController.d.ts +0 -0
- /package/dist/{agent/ui/AgentInputEmail.vue.d.ts → bot/ui/BotInputEmail.vue.d.ts} +0 -0
- /package/dist/{agent/ui/AgentInputOneTimeCode.vue.d.ts → bot/ui/BotInputOneTimeCode.vue.d.ts} +0 -0
- /package/dist/{agent/ui/AgentSidebarClose.vue.d.ts → bot/ui/BotSidebarClose.vue.d.ts} +0 -0
- /package/dist/{agent/ui/AgentToolActivityGroup.vue.d.ts → bot/ui/BotToolActivityGroup.vue.d.ts} +0 -0
- /package/dist/{agent/ui/AgentWidget.vue.d.ts → bot/ui/BotWidget.vue.d.ts} +0 -0
- /package/dist/{agent → bot}/ui/ChatCardBlock.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/ChatRichText.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/ChatScroller.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/ChatVisualBlock.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/ElAuthGate.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/ElAuthPanel.vue.d.ts +0 -0
- /package/dist/{agent/ui/ElAgentButton.vue.d.ts → bot/ui/ElBotButton.vue.d.ts} +0 -0
- /package/dist/{agent → bot}/ui/ElSidebar.vue.d.ts +0 -0
- /package/dist/{agent → bot}/ui/VoiceHistogramController.d.ts +0 -0
- /package/dist/{agent → bot}/ui/chat-diagram-layout.d.ts +0 -0
- /package/dist/{agent → bot}/ui/chat-visual-format.d.ts +0 -0
- /package/dist/{agent → bot}/ui/voice-mode-presentation.d.ts +0 -0
- /package/dist/{agent → bot}/voice/voice-error-copy.d.ts +0 -0
- /package/dist/{agent → bot}/voice/voice-work-state.d.ts +0 -0
- /package/dist/widget/ui/{AgentWidgetOnboard.vue.d.ts → BotWidgetOnboard.vue.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# PageLines SDK
|
|
2
2
|
|
|
3
|
-
Lightweight client library for PageLines
|
|
3
|
+
Lightweight client library for PageLines bot integration. Built for PageLines-owned properties (app, www, widget).
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -16,8 +16,8 @@ import { PageLinesSDK } from '@pagelines/sdk'
|
|
|
16
16
|
// Singleton pattern - shares state across your app
|
|
17
17
|
const sdk = PageLinesSDK.getInstance({ isDev: true })
|
|
18
18
|
|
|
19
|
-
// Get public
|
|
20
|
-
const
|
|
19
|
+
// Get public bot
|
|
20
|
+
const bot = await sdk.getPublicBot({ handle: 'andrew' })
|
|
21
21
|
|
|
22
22
|
// Authenticate user
|
|
23
23
|
await sdk.requestAuthCode({ email: 'user@example.com' })
|
|
@@ -25,7 +25,7 @@ await sdk.loginWithCode({ email: 'user@example.com', code: '123456' })
|
|
|
25
25
|
|
|
26
26
|
// Access reactive state
|
|
27
27
|
console.log(sdk.activeUser.value)
|
|
28
|
-
console.log(sdk.
|
|
28
|
+
console.log(sdk.currentBot.value)
|
|
29
29
|
console.log(sdk.currentOrg.value)
|
|
30
30
|
```
|
|
31
31
|
|
|
@@ -33,7 +33,7 @@ console.log(sdk.currentOrg.value)
|
|
|
33
33
|
|
|
34
34
|
**Minimal API Surface**: Clean wrapper methods hide internal complexity. No direct `apiClient` exposure prevents type generation issues.
|
|
35
35
|
|
|
36
|
-
**
|
|
36
|
+
**Bot-First Architecture**: Bots are primary entities. Organization context derived from bot, not passed redundantly.
|
|
37
37
|
|
|
38
38
|
**Singleton by Default**: Browser-only singleton prevents duplicate API calls and separate reactive state. Multiple `getInstance()` calls return same instance.
|
|
39
39
|
|
|
@@ -63,14 +63,14 @@ const user = await sdk.getCurrentUser()
|
|
|
63
63
|
await sdk.logout()
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
###
|
|
66
|
+
### Bot Access
|
|
67
67
|
|
|
68
68
|
```typescript
|
|
69
|
-
// Public
|
|
70
|
-
const
|
|
69
|
+
// Public bot by handle (no auth)
|
|
70
|
+
const bot = await sdk.getPublicBot({ handle: 'andrew' })
|
|
71
71
|
|
|
72
|
-
// Public
|
|
73
|
-
const
|
|
72
|
+
// Public bot by email (no auth)
|
|
73
|
+
const bot = await sdk.getBotByEmail({ email: 'andrew@pagelines.com' })
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
### Usage Tracking
|
|
@@ -78,7 +78,7 @@ const agent = await sdk.getAgentByEmail({ email: 'andrew@pagelines.com' })
|
|
|
78
78
|
```typescript
|
|
79
79
|
// Unified tracking method
|
|
80
80
|
await sdk.trackUsage({
|
|
81
|
-
|
|
81
|
+
botId: 'agt_456', // Bot contains orgId
|
|
82
82
|
type: 'voice', // 'voice' | 'chat'
|
|
83
83
|
quantity: 45, // Seconds for voice, characters for chat
|
|
84
84
|
participantId: 'usr_123' // Optional: conversation participant
|
|
@@ -95,7 +95,7 @@ sdk.loading.value // boolean
|
|
|
95
95
|
sdk.error.value // string | null
|
|
96
96
|
|
|
97
97
|
// Computed properties (auto-derived from activeUser)
|
|
98
|
-
sdk.
|
|
98
|
+
sdk.currentBot.value // Bot | undefined
|
|
99
99
|
sdk.currentOrg.value // OrgInfo | undefined
|
|
100
100
|
```
|
|
101
101
|
|
|
@@ -166,12 +166,12 @@ const testSDK = PageLinesSDK.getInstance({
|
|
|
166
166
|
import { PageLinesSDK } from '@pagelines/sdk'
|
|
167
167
|
|
|
168
168
|
const sdk = PageLinesSDK.getInstance({ isDev: import.meta.env.DEV })
|
|
169
|
-
const
|
|
169
|
+
const authorBot = await sdk.getBotByEmail({ email: 'andrew@pagelines.com' })
|
|
170
170
|
|
|
171
|
-
// Use
|
|
172
|
-
const authorAvatar =
|
|
173
|
-
const authorName =
|
|
174
|
-
const authorBio =
|
|
171
|
+
// Use bot data instead of static strings
|
|
172
|
+
const authorAvatar = authorBot?.avatar?.url
|
|
173
|
+
const authorName = authorBot?.name
|
|
174
|
+
const authorBio = authorBot?.summary
|
|
175
175
|
```
|
|
176
176
|
|
|
177
177
|
### Widget Integration
|
|
@@ -181,14 +181,14 @@ import { PLWidget } from '@pagelines/sdk/widget'
|
|
|
181
181
|
|
|
182
182
|
const widget = new PLWidget({
|
|
183
183
|
mode: 'modal', // 'inline' | 'popup' | 'modal'
|
|
184
|
-
handle: 'andrew', // Or provide
|
|
185
|
-
context: 'support', // Optional:
|
|
184
|
+
handle: 'andrew', // Or provide bot object directly
|
|
185
|
+
context: 'support', // Optional: bot context override
|
|
186
186
|
firstMessage: 'Hi!' // Optional: custom greeting
|
|
187
187
|
})
|
|
188
188
|
|
|
189
189
|
// Update without re-mount
|
|
190
190
|
widget.update({
|
|
191
|
-
|
|
191
|
+
bot: newBot,
|
|
192
192
|
context: 'sales'
|
|
193
193
|
})
|
|
194
194
|
|
|
@@ -199,17 +199,17 @@ widget.destroy()
|
|
|
199
199
|
### Profile Page
|
|
200
200
|
|
|
201
201
|
```typescript
|
|
202
|
-
import {
|
|
202
|
+
import { BotChat } from '@pagelines/sdk/bot'
|
|
203
203
|
|
|
204
204
|
const sdk = PageLinesSDK.getInstance({ isDev: true })
|
|
205
|
-
const
|
|
205
|
+
const bot = await sdk.getPublicBot({ handle: 'andrew' })
|
|
206
206
|
```
|
|
207
207
|
|
|
208
208
|
```vue
|
|
209
209
|
<template>
|
|
210
|
-
<
|
|
210
|
+
<BotChat
|
|
211
211
|
:sdk="sdk"
|
|
212
|
-
:
|
|
212
|
+
:bot="bot"
|
|
213
213
|
theme-color="#3b82f6"
|
|
214
214
|
/>
|
|
215
215
|
</template>
|
|
@@ -220,10 +220,10 @@ const agent = await sdk.getPublicAgent({ handle: 'andrew' })
|
|
|
220
220
|
All wrapper methods return `undefined` on error (no exceptions thrown). Check reactive error state for details.
|
|
221
221
|
|
|
222
222
|
```typescript
|
|
223
|
-
const
|
|
223
|
+
const bot = await sdk.getPublicBot({ handle: 'nonexistent' })
|
|
224
224
|
|
|
225
|
-
if (!
|
|
226
|
-
console.error(sdk.error.value) // '
|
|
225
|
+
if (!bot) {
|
|
226
|
+
console.error(sdk.error.value) // 'Bot not found'
|
|
227
227
|
}
|
|
228
228
|
```
|
|
229
229
|
|
|
@@ -244,12 +244,12 @@ if (!agent) {
|
|
|
244
244
|
```typescript
|
|
245
245
|
// ✅ Correct - Use bundled entry points
|
|
246
246
|
import { PageLinesSDK } from '@pagelines/sdk'
|
|
247
|
-
import {
|
|
247
|
+
import { BotChat, BotProvider } from '@pagelines/sdk/bot'
|
|
248
248
|
import { PLWidget } from '@pagelines/sdk/widget'
|
|
249
249
|
|
|
250
250
|
// ❌ Wrong - Deep imports don't work
|
|
251
251
|
import { PageLinesSDK } from '@pagelines/sdk/PageLinesSDK'
|
|
252
|
-
import
|
|
252
|
+
import BotChat from '@pagelines/sdk/bot/ui/BotChat.vue'
|
|
253
253
|
```
|
|
254
254
|
|
|
255
255
|
## Package Exports
|
|
@@ -261,9 +261,9 @@ import AgentChat from '@pagelines/sdk/agent/ui/AgentChat.vue'
|
|
|
261
261
|
"import": "./dist/sdk.js",
|
|
262
262
|
"types": "./dist/sdk.d.ts"
|
|
263
263
|
},
|
|
264
|
-
"./
|
|
265
|
-
"import": "./dist/
|
|
266
|
-
"types": "./dist/
|
|
264
|
+
"./bot": {
|
|
265
|
+
"import": "./dist/bot.js",
|
|
266
|
+
"types": "./dist/bot.d.ts"
|
|
267
267
|
},
|
|
268
268
|
"./widget": {
|
|
269
269
|
"import": "./dist/widget.js",
|
|
@@ -273,22 +273,22 @@ import AgentChat from '@pagelines/sdk/agent/ui/AgentChat.vue'
|
|
|
273
273
|
}
|
|
274
274
|
```
|
|
275
275
|
|
|
276
|
-
##
|
|
276
|
+
## Bot-First Architecture
|
|
277
277
|
|
|
278
|
-
|
|
278
|
+
Bots are primary entities that determine organizational context.
|
|
279
279
|
|
|
280
280
|
```typescript
|
|
281
|
-
// ✅
|
|
281
|
+
// ✅ Bot contains all context
|
|
282
282
|
await sdk.trackUsage({
|
|
283
|
-
|
|
283
|
+
botId: 'agt_456', // Includes orgId internally
|
|
284
284
|
type: 'voice',
|
|
285
285
|
quantity: 45
|
|
286
286
|
})
|
|
287
287
|
|
|
288
288
|
// ❌ Don't pass redundant orgId
|
|
289
289
|
await sdk.trackUsage({
|
|
290
|
-
orgId: 'org_123', // Redundant - derived from
|
|
291
|
-
|
|
290
|
+
orgId: 'org_123', // Redundant - derived from botId
|
|
291
|
+
botId: 'agt_456',
|
|
292
292
|
type: 'voice',
|
|
293
293
|
quantity: 45
|
|
294
294
|
})
|
|
@@ -296,7 +296,7 @@ await sdk.trackUsage({
|
|
|
296
296
|
|
|
297
297
|
**Benefits**:
|
|
298
298
|
- Simpler APIs (fewer parameters)
|
|
299
|
-
- Single source of truth (
|
|
299
|
+
- Single source of truth (bot determines org)
|
|
300
300
|
- Automatic context resolution
|
|
301
301
|
- Consistent across all SDK methods
|
|
302
302
|
|
|
@@ -314,20 +314,20 @@ sdk.loading.value // Updated during API calls
|
|
|
314
314
|
sdk.error.value // Updated on errors
|
|
315
315
|
|
|
316
316
|
// Computed properties (auto-derived)
|
|
317
|
-
sdk.
|
|
317
|
+
sdk.currentBot.value = computed(() => {
|
|
318
318
|
const user = sdk.activeUser.value
|
|
319
|
-
if (!user?.
|
|
319
|
+
if (!user?.bots) return undefined
|
|
320
320
|
|
|
321
|
-
const
|
|
322
|
-
return user.
|
|
321
|
+
const botId = user.primaryBotId || user.bots[0]?.botId
|
|
322
|
+
return user.bots.find(a => a.botId === botId)
|
|
323
323
|
})
|
|
324
324
|
|
|
325
325
|
sdk.currentOrg.value = computed(() => {
|
|
326
|
-
const
|
|
327
|
-
if (!
|
|
326
|
+
const bot = sdk.currentBot.value
|
|
327
|
+
if (!bot?.orgId) return undefined
|
|
328
328
|
|
|
329
329
|
return sdk.activeUser.value?.orgs.find(org =>
|
|
330
|
-
org.orgId ===
|
|
330
|
+
org.orgId === bot.orgId
|
|
331
331
|
)
|
|
332
332
|
})
|
|
333
333
|
```
|
|
@@ -336,7 +336,7 @@ sdk.currentOrg.value = computed(() => {
|
|
|
336
336
|
- Components auto-update when user changes
|
|
337
337
|
- No manual state management needed
|
|
338
338
|
- Consistent with PageLines app patterns
|
|
339
|
-
-
|
|
339
|
+
- Bot-first architecture (org derived from bot)
|
|
340
340
|
|
|
341
341
|
## Component Integration
|
|
342
342
|
|
|
@@ -347,16 +347,16 @@ SDK components accept `sdk` prop instead of using global services.
|
|
|
347
347
|
```vue
|
|
348
348
|
<script setup>
|
|
349
349
|
import { PageLinesSDK } from '@pagelines/sdk'
|
|
350
|
-
import {
|
|
350
|
+
import { BotChat } from '@pagelines/sdk/bot'
|
|
351
351
|
|
|
352
352
|
const sdk = PageLinesSDK.getInstance({ isDev: true })
|
|
353
|
-
const
|
|
353
|
+
const bot = await sdk.getPublicBot({ handle: 'andrew' })
|
|
354
354
|
</script>
|
|
355
355
|
|
|
356
356
|
<template>
|
|
357
|
-
<
|
|
357
|
+
<BotChat
|
|
358
358
|
:sdk="sdk"
|
|
359
|
-
:
|
|
359
|
+
:bot="bot"
|
|
360
360
|
theme-color="#3b82f6"
|
|
361
361
|
/>
|
|
362
362
|
</template>
|
|
@@ -364,20 +364,20 @@ const agent = await sdk.getPublicAgent({ handle: 'andrew' })
|
|
|
364
364
|
|
|
365
365
|
### Available Components
|
|
366
366
|
|
|
367
|
-
**
|
|
368
|
-
**
|
|
369
|
-
**
|
|
370
|
-
**
|
|
371
|
-
**
|
|
372
|
-
**
|
|
367
|
+
**BotChat** - Main bot interface (chat/voice)
|
|
368
|
+
**BotProvider** - Handle → bot resolver wrapper
|
|
369
|
+
**ElBotAbout** - Profile information display
|
|
370
|
+
**ElBotChat** - Text chat interface
|
|
371
|
+
**ElBotVoice** - Voice call interface
|
|
372
|
+
**ElBotSidebar** - Navigation sidebar
|
|
373
373
|
|
|
374
374
|
## Security Model
|
|
375
375
|
|
|
376
|
-
**Public-Only Access**: `
|
|
376
|
+
**Public-Only Access**: `getPublicBot()` and `getBotByEmail()` only return bots with `visibility: 'public'`.
|
|
377
377
|
|
|
378
378
|
**Authentication Required**: User operations require a valid opaque session token in `sdk.token.value`.
|
|
379
379
|
|
|
380
|
-
**Rate Limiting**: Widget includes 10 comments/hour per
|
|
380
|
+
**Rate Limiting**: Widget includes 10 comments/hour per bot, 100 likes/hour (future).
|
|
381
381
|
|
|
382
382
|
## Performance Optimization
|
|
383
383
|
|
|
@@ -395,16 +395,16 @@ const agent = await sdk.getPublicAgent({ handle: 'andrew' })
|
|
|
395
395
|
|
|
396
396
|
**Wrapper Method Pattern**: Clean function signatures serialize perfectly to `.d.ts` files.
|
|
397
397
|
|
|
398
|
-
**No Complex Types**: Simple `Promise<
|
|
398
|
+
**No Complex Types**: Simple `Promise<Bot | undefined>` instead of Hono RPC types.
|
|
399
399
|
|
|
400
400
|
```typescript
|
|
401
401
|
// Clean wrapper method
|
|
402
|
-
async
|
|
402
|
+
async getPublicBot(args: {
|
|
403
403
|
handle: string
|
|
404
|
-
}): Promise<
|
|
404
|
+
}): Promise<Bot | undefined>
|
|
405
405
|
|
|
406
406
|
// Internal complexity hidden
|
|
407
|
-
const response = await this.api.
|
|
407
|
+
const response = await this.api.bot.public[':handle'].$get({
|
|
408
408
|
param: { handle: args.handle }
|
|
409
409
|
})
|
|
410
410
|
```
|
|
@@ -445,20 +445,20 @@ afterEach(() => {
|
|
|
445
445
|
**4. Check Error State**: Methods return `undefined` on error.
|
|
446
446
|
|
|
447
447
|
```typescript
|
|
448
|
-
const
|
|
449
|
-
if (!
|
|
448
|
+
const bot = await sdk.getPublicBot({ handle: 'test' })
|
|
449
|
+
if (!bot) {
|
|
450
450
|
console.error(sdk.error.value)
|
|
451
451
|
}
|
|
452
452
|
```
|
|
453
453
|
|
|
454
|
-
**5.
|
|
454
|
+
**5. Bot-First APIs**: Pass `botId`, let SDK resolve `orgId`.
|
|
455
455
|
|
|
456
456
|
```typescript
|
|
457
457
|
// ✅ Minimal args
|
|
458
|
-
await sdk.trackUsage({
|
|
458
|
+
await sdk.trackUsage({ botId, type, quantity })
|
|
459
459
|
|
|
460
460
|
// ❌ Redundant args
|
|
461
|
-
await sdk.trackUsage({ orgId,
|
|
461
|
+
await sdk.trackUsage({ orgId, botId, type, quantity })
|
|
462
462
|
```
|
|
463
463
|
|
|
464
464
|
## Architecture Principles
|