@amigo-ai/platform-sdk 0.15.1 → 0.16.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/README.md CHANGED
@@ -87,11 +87,51 @@ const stats = await client.analytics.getCalls({ days: 30 })
87
87
  console.log(stats.total_calls, stats.avg_duration_seconds)
88
88
  ```
89
89
 
90
+ ## Authentication
91
+
92
+ ### API key (server-to-server)
93
+
94
+ Pass `apiKey` and `workspaceId` to `AmigoClient`. Best for backend services and scripts.
95
+
96
+ ### Device code flow (CLI and desktop apps)
97
+
98
+ For interactive apps where users sign in via the browser, use `loginWithDeviceCode`:
99
+
100
+ ```typescript
101
+ import {
102
+ loginWithDeviceCode,
103
+ openBrowser,
104
+ formatDeviceCodeInstructions,
105
+ TokenManager,
106
+ FileTokenStorage,
107
+ } from '@amigo-ai/platform-sdk'
108
+
109
+ const result = await loginWithDeviceCode({
110
+ onCode: async (issuance) => {
111
+ console.log(formatDeviceCodeInstructions(issuance))
112
+ await openBrowser(issuance.verification_uri_complete)
113
+ },
114
+ onWorkspaceRequired: async (workspaces) => {
115
+ // Prompt user to pick a workspace
116
+ return workspaces[0].workspace_id
117
+ },
118
+ })
119
+
120
+ // Persist credentials across runs
121
+ const tokens = new TokenManager({ storage: new FileTokenStorage() })
122
+ await tokens.store(result)
123
+
124
+ // Use the token
125
+ const client = new AmigoClient({ apiKey: result.accessToken, workspaceId: result.workspaceId })
126
+ ```
127
+
128
+ See [`examples/auth/device-code-login.ts`](./examples/auth/device-code-login.ts) for a complete working example.
129
+
90
130
  ## Configuration
91
131
 
92
132
  | Option | Type | Required | Description |
93
133
  | ------------- | -------------- | -------- | -------------------------------------------------------------------- |
94
- | `apiKey` | `string` | Yes | Your Platform API key create one at Workspace Settings > API Keys |
134
+ | `apiKey` | `string` | Yes | API key or JWT from device code flow (Bearer auth) |
95
135
  | `workspaceId` | `string` | Yes | Your workspace ID — all resource operations are scoped to this |
96
136
  | `baseUrl` | `string` | No | Override the API base URL (default: `https://api.platform.amigo.ai`) |
97
137
  | `retry` | `RetryOptions` | No | Retry configuration for transient failures |
package/dist/index.cjs CHANGED
@@ -1970,15 +1970,12 @@ var ConversationsResource = class extends WorkspaceScopedResource {
1970
1970
  }
1971
1971
  async createTurn(conversationId, request) {
1972
1972
  return extractData(
1973
- await this.client.POST(
1974
- "/v1/{workspace_id}/conversations/{conversation_id}/turns",
1975
- {
1976
- params: {
1977
- path: { workspace_id: this.workspaceId, conversation_id: conversationId }
1978
- },
1979
- body: request
1980
- }
1981
- )
1973
+ await this.client.POST("/v1/{workspace_id}/conversations/{conversation_id}/turns", {
1974
+ params: {
1975
+ path: { workspace_id: this.workspaceId, conversation_id: conversationId }
1976
+ },
1977
+ body: request
1978
+ })
1982
1979
  );
1983
1980
  }
1984
1981
  /** Build the real-time text WebSocket URL for browser or custom clients. */