@ottimis/jack-provider-sdk 0.3.0 → 0.7.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/src/usage.ts CHANGED
@@ -180,32 +180,60 @@ export type UsageConnectContext = {
180
180
  * Provider-owned usage capability. Optional on {@link JackProvider};
181
181
  * absent = host hides the chip's "Connect" affordance and the
182
182
  * capability flag is `false`.
183
+ *
184
+ * Multi-profile contract (SDK 0.7.0):
185
+ * Every account-level method accepts an optional `profileId`. Providers
186
+ * that ALSO declare `capabilities.profiles=true` MUST honor the param —
187
+ * different profile = different account = different credentials, polled
188
+ * independently. When omitted, the provider resolves to its DEFAULT
189
+ * profile (back-compat with hosts that don't yet thread profileId).
190
+ *
191
+ * Providers without profiles support (`capabilities.profiles=false`)
192
+ * MAY ignore the param and behave as if every call were singleton —
193
+ * the omission stays the canonical caller behavior, the param is just
194
+ * ignored.
195
+ *
196
+ * `formatSessionMetrics` stays profile-agnostic: per-session metrics
197
+ * derive from the live process's context tokens (already pinned to the
198
+ * session's profile via `applyProfile` at spawn time).
183
199
  */
184
200
  export type UsageApi = {
185
- /** Current connection state — used for chip display + gating. */
186
- status(): Promise<UsageStatus>
201
+ /**
202
+ * Current connection state — used for chip display + gating.
203
+ * Profile-aware: omit `profileId` to query the default profile.
204
+ */
205
+ status(profileId?: string): Promise<UsageStatus>
187
206
 
188
207
  /**
189
208
  * Open the provider's connect flow. Whatever modality the provider
190
209
  * needs (login window, API-key picker, OAuth redirect) lives here.
210
+ * Profile-aware: omit `profileId` to bind credentials to the default
211
+ * profile. Different profileIds use isolated storage AND isolated
212
+ * login surfaces (e.g. distinct cookie partitions for Claude) so two
213
+ * accounts can sign in side by side.
191
214
  */
192
- connect(ctx: UsageConnectContext): Promise<UsageConnectResult>
215
+ connect(ctx: UsageConnectContext, profileId?: string): Promise<UsageConnectResult>
193
216
 
194
217
  /**
195
218
  * When `connect()` returned `'choose'`, host calls this with the
196
219
  * user's pick. Optional — providers that never choose omit it.
220
+ * Profile-aware: pass the SAME `profileId` you used for `connect()`.
197
221
  */
198
- selectOption?(optionId: string): Promise<UsageConnectResult>
222
+ selectOption?(optionId: string, profileId?: string): Promise<UsageConnectResult>
199
223
 
200
- /** Drop credentials and stop any provider-side polling. */
201
- disconnect(): Promise<void>
224
+ /**
225
+ * Drop credentials and stop any provider-side polling for the
226
+ * specified profile. Omit `profileId` to disconnect the default profile.
227
+ */
228
+ disconnect(profileId?: string): Promise<void>
202
229
 
203
230
  /**
204
- * Fetch one fresh account-level snapshot. Empty `metrics: []` is
205
- * fine when the provider has no billing surface yet — the capability
206
- * stays `true` for the per-session bridge.
231
+ * Fetch one fresh account-level snapshot for the specified profile.
232
+ * Empty `metrics: []` is fine when the provider has no billing surface
233
+ * yet — the capability stays `true` for the per-session bridge.
234
+ * Omit `profileId` to fetch the default profile.
207
235
  */
208
- fetch(): Promise<UsageSnapshot>
236
+ fetch(profileId?: string): Promise<UsageSnapshot>
209
237
 
210
238
  /**
211
239
  * Recommended poll cadence (seconds). Host clamps to its bounds.