@mitralab.io/platform-sdk 1.3.0 → 1.4.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/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## 1.4.0
6
+
7
+ Stable release of the 1.4.0-beta.0 line, already on the `beta` tag. It pins
8
+ `@mitralab.io/sdk-core` to `0.2.10`, the stable release of the `0.2.10-beta.0` surface this line
9
+ already followed. No code change since 1.4.0-beta.0; the entry below describes what moves from
10
+ 1.3.0.
11
+
12
+ ## 1.4.0-beta.0
13
+
14
+ - `agentCredentials.usage("ANTHROPIC" | "OPENAI", { scope })` reads the last subscription reading
15
+ a chat on that credential reported, with no chat open: `{ harness, observedAt, status, windows:
16
+ [{ kind, usedPercent, resetsAt, windowSeconds }] }`, or `null` while none has. The session emits
17
+ the same reading as `providerUsage` during a turn on the box.
18
+ - Depend on `@mitralab.io/sdk-core@0.2.10-beta.0` and export `CredentialUsage`,
19
+ `CredentialUsageWindow` and `AgentProviderUsage`.
20
+
5
21
  ## 1.3.0
6
22
 
7
23
  Stable release of the 1.3.0-beta.0 line, already on the `beta` tag. It pins
package/README.md CHANGED
@@ -435,6 +435,13 @@ Every `agentCredentials` method takes a trailing `options` with `scope: "ACCOUNT
435
435
 
436
436
  A custom provider the person adds by API is a credential like the others, managed on `/api/v1/credentials/custom-providers` with the same trailing `options`: `listCustomProviders({ scope: "ACCOUNT" })` returns the person's OpenAI-compatible providers with the API key masked, `createCustomProvider({ name, baseUrl, apiKey, models }, { scope: "ACCOUNT" })` adds one under a name the person chooses and returns the list after creation, and `deleteCustomProvider(id, { scope: "ACCOUNT" })` removes it for good. The API key is write-only and `models` takes 1 to 32 model ids; each joins the catalog `listModels()` returns as `custom/<providerId>/<model>`, and a chat runs on one of them by sending the `agentType` that catalog row returns, the same way a built-in model is chosen. The Copilot requires `scope: "ACCOUNT"` on an app token. The three methods take no provider argument and no provider guard applies.
437
437
 
438
+ The subscription usage, the meters behind the bar the IDE shows for a Claude or ChatGPT login, is readable with no chat open: `usage("ANTHROPIC")` (or `"OPENAI"`, with the same trailing `options`) resolves to `{ harness, observedAt, status, windows: [{ kind, usedPercent, resetsAt, windowSeconds }] }`, the last reading a chat on that credential reported, or `null` while none has. `windows` carries every window the provider reports (Claude: `FIVE_HOUR`, `WEEKLY`, `WEEKLY_OPUS` and any other it sends; Codex: primary and secondary, named by duration) and `status` is the provider's own (Claude: `allowed`, `allowed_warning`, `rejected`). Only a turn on the person's own subscription login, or the agent connection's, reports a window; an API key, a custom provider and the included AI never do. During a turn on the box the session emits the same reading live, in the same shape, as `providerUsage`, and the Copilot keeps it for the next `usage()`:
439
+
440
+ ```typescript
441
+ session.on("providerUsage", ({ status, windows }) => console.log(status, windows))
442
+ const usage = await mitra.agentCredentials.usage("ANTHROPIC")
443
+ ```
444
+
438
445
  The browser token roles expose Agent tasks, credential status, and model discovery. Administrative business-Agent CRUD is intentionally not exposed by this adapter because the `USE` app role does not carry `AGENT_*` authority.
439
446
 
440
447
  ## Custom queries
package/dist/index.cjs CHANGED
@@ -2504,6 +2504,10 @@ function createBrowserAgentCredentialsModule(httpClient) {
2504
2504
  return {
2505
2505
  list: (options) => core.list(options),
2506
2506
  listModels: (agentId, options) => core.listModels(agentId, options),
2507
+ usage: (provider, options) => {
2508
+ requireProvider(provider, ["ANTHROPIC", "OPENAI"], "Subscription usage");
2509
+ return core.usage(provider, options);
2510
+ },
2507
2511
  saveApiKey: (provider, apiKey, options) => {
2508
2512
  requireProvider(provider, ["ANTHROPIC", "OPENAI"], "API key authentication");
2509
2513
  return core.saveApiKey(provider, apiKey, options);
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { Transport, TransportRequestOptions, QueryParamValue, EntityTable, FunctionExecution, ListTemplateConfigsOptions, TemplateConfigPage, ProxyResult, ProxyInput, QueryResult, AgentCredentialOptions, CredentialStatus, AgentModel as AgentModel$1, OAuthStartResult, OAuthExchangeInput, AuthenticationResult, DeviceAuthorization, AgentConnectionCustomProvider, AgentConnectionCustomProviderInput, PublicFunctionsModule, AgentTasksWithSessions } from '@mitralab.io/sdk-core';
2
- export { AgentConnectionCustomProvider, AgentConnectionCustomProviderInput, AgentCredentialOptions, AgentCredentialScope, AgentQueueItem, AgentSendAndWaitOptions, AgentSendOptions, AgentSessionTransport, AgentTask, AgentTaskCreateInput, AgentTaskInput, AgentTaskListOptions, AgentTaskRuntime, AgentTaskSessionEventMap, AgentTaskSessionOptions, AgentTaskSessionStatus, AgentTurnResult, AuthenticationResult, CredentialStatus, DeviceAuthorization, EntityListOptions, EntityTable, ExistingAgentTaskSessionOptions, FunctionExecution, ListTemplateConfigsOptions, AgentMessage as NativeAgentMessage, AgentModel as NativeAgentModel, AgentTaskSession as NativeAgentTaskSession, AgentTimelineItem as NativeAgentTimelineItem, AgentToolEvent as NativeAgentToolEvent, NewAgentTaskSessionOptions, OAuthExchangeInput, OAuthStartResult, Page, PageOptions, ProxyInput, ProxyResult, PublicFunctionAsyncResult, PublicFunctionResult, PublicFunctionsModule, QueryResult, TemplateConfigPage } from '@mitralab.io/sdk-core';
1
+ import { Transport, TransportRequestOptions, QueryParamValue, EntityTable, FunctionExecution, ListTemplateConfigsOptions, TemplateConfigPage, ProxyResult, ProxyInput, QueryResult, AgentCredentialOptions, CredentialStatus, AgentModel as AgentModel$1, CredentialUsage, OAuthStartResult, OAuthExchangeInput, AuthenticationResult, DeviceAuthorization, AgentConnectionCustomProvider, AgentConnectionCustomProviderInput, PublicFunctionsModule, AgentTasksWithSessions } from '@mitralab.io/sdk-core';
2
+ export { AgentConnectionCustomProvider, AgentConnectionCustomProviderInput, AgentCredentialOptions, AgentCredentialScope, AgentProviderUsage, AgentQueueItem, AgentSendAndWaitOptions, AgentSendOptions, AgentSessionTransport, AgentTask, AgentTaskCreateInput, AgentTaskInput, AgentTaskListOptions, AgentTaskRuntime, AgentTaskSessionEventMap, AgentTaskSessionOptions, AgentTaskSessionStatus, AgentTurnResult, AuthenticationResult, CredentialStatus, CredentialUsage, CredentialUsageWindow, DeviceAuthorization, EntityListOptions, EntityTable, ExistingAgentTaskSessionOptions, FunctionExecution, ListTemplateConfigsOptions, AgentMessage as NativeAgentMessage, AgentModel as NativeAgentModel, AgentTaskSession as NativeAgentTaskSession, AgentTimelineItem as NativeAgentTimelineItem, AgentToolEvent as NativeAgentToolEvent, NewAgentTaskSessionOptions, OAuthExchangeInput, OAuthStartResult, Page, PageOptions, ProxyInput, ProxyResult, PublicFunctionAsyncResult, PublicFunctionResult, PublicFunctionsModule, QueryResult, TemplateConfigPage } from '@mitralab.io/sdk-core';
3
3
  import * as LegacyTypes from 'mitra-interactions-sdk';
4
4
  import { exchangeSsoCodeMitra as exchangeSsoCodeMitra$1, loginMitra as loginMitra$1, loginWithGoogleMitra as loginWithGoogleMitra$1, loginWithMicrosoftMitra as loginWithMicrosoftMitra$1 } from 'mitra-interactions-sdk';
5
5
  export { callIntegrationMitra, configureSdkMitra, createMitraInstance, createRecordMitra, createRecordsBatchMitra, deleteRecordMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getPublicServerFunctionExecutionMitra, getRecordMitra, listIntegrationsMitra, listRecordsMitra, manageAgentChatMitra, manageAgentCredentialMitra, patchRecordMitra, refreshTokenSilently, resolveProjectId, stopServerFunctionExecutionMitra, updateRecordMitra } from 'mitra-interactions-sdk';
@@ -762,6 +762,11 @@ type AgentDeviceProvider = 'OPENAI';
762
762
  interface AgentCredentialsModule {
763
763
  list(options?: AgentCredentialOptions): Promise<CredentialStatus[]>;
764
764
  listModels(agentId?: string, options?: AgentCredentialOptions): Promise<AgentModel$1[]>;
765
+ /**
766
+ * The last subscription window a chat on this credential reported, readable with no chat open.
767
+ * `null` until a turn on the provider's subscription login has reported one.
768
+ */
769
+ usage(provider: AgentCredentialProvider, options?: AgentCredentialOptions): Promise<CredentialUsage | null>;
765
770
  saveApiKey(provider: AgentCredentialProvider, apiKey: string, options?: AgentCredentialOptions): Promise<void>;
766
771
  remove(provider: AgentCredentialProvider, options?: AgentCredentialOptions): Promise<void>;
767
772
  startOAuth(provider: AgentOAuthProvider, options?: AgentCredentialOptions): Promise<OAuthStartResult>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Transport, TransportRequestOptions, QueryParamValue, EntityTable, FunctionExecution, ListTemplateConfigsOptions, TemplateConfigPage, ProxyResult, ProxyInput, QueryResult, AgentCredentialOptions, CredentialStatus, AgentModel as AgentModel$1, OAuthStartResult, OAuthExchangeInput, AuthenticationResult, DeviceAuthorization, AgentConnectionCustomProvider, AgentConnectionCustomProviderInput, PublicFunctionsModule, AgentTasksWithSessions } from '@mitralab.io/sdk-core';
2
- export { AgentConnectionCustomProvider, AgentConnectionCustomProviderInput, AgentCredentialOptions, AgentCredentialScope, AgentQueueItem, AgentSendAndWaitOptions, AgentSendOptions, AgentSessionTransport, AgentTask, AgentTaskCreateInput, AgentTaskInput, AgentTaskListOptions, AgentTaskRuntime, AgentTaskSessionEventMap, AgentTaskSessionOptions, AgentTaskSessionStatus, AgentTurnResult, AuthenticationResult, CredentialStatus, DeviceAuthorization, EntityListOptions, EntityTable, ExistingAgentTaskSessionOptions, FunctionExecution, ListTemplateConfigsOptions, AgentMessage as NativeAgentMessage, AgentModel as NativeAgentModel, AgentTaskSession as NativeAgentTaskSession, AgentTimelineItem as NativeAgentTimelineItem, AgentToolEvent as NativeAgentToolEvent, NewAgentTaskSessionOptions, OAuthExchangeInput, OAuthStartResult, Page, PageOptions, ProxyInput, ProxyResult, PublicFunctionAsyncResult, PublicFunctionResult, PublicFunctionsModule, QueryResult, TemplateConfigPage } from '@mitralab.io/sdk-core';
1
+ import { Transport, TransportRequestOptions, QueryParamValue, EntityTable, FunctionExecution, ListTemplateConfigsOptions, TemplateConfigPage, ProxyResult, ProxyInput, QueryResult, AgentCredentialOptions, CredentialStatus, AgentModel as AgentModel$1, CredentialUsage, OAuthStartResult, OAuthExchangeInput, AuthenticationResult, DeviceAuthorization, AgentConnectionCustomProvider, AgentConnectionCustomProviderInput, PublicFunctionsModule, AgentTasksWithSessions } from '@mitralab.io/sdk-core';
2
+ export { AgentConnectionCustomProvider, AgentConnectionCustomProviderInput, AgentCredentialOptions, AgentCredentialScope, AgentProviderUsage, AgentQueueItem, AgentSendAndWaitOptions, AgentSendOptions, AgentSessionTransport, AgentTask, AgentTaskCreateInput, AgentTaskInput, AgentTaskListOptions, AgentTaskRuntime, AgentTaskSessionEventMap, AgentTaskSessionOptions, AgentTaskSessionStatus, AgentTurnResult, AuthenticationResult, CredentialStatus, CredentialUsage, CredentialUsageWindow, DeviceAuthorization, EntityListOptions, EntityTable, ExistingAgentTaskSessionOptions, FunctionExecution, ListTemplateConfigsOptions, AgentMessage as NativeAgentMessage, AgentModel as NativeAgentModel, AgentTaskSession as NativeAgentTaskSession, AgentTimelineItem as NativeAgentTimelineItem, AgentToolEvent as NativeAgentToolEvent, NewAgentTaskSessionOptions, OAuthExchangeInput, OAuthStartResult, Page, PageOptions, ProxyInput, ProxyResult, PublicFunctionAsyncResult, PublicFunctionResult, PublicFunctionsModule, QueryResult, TemplateConfigPage } from '@mitralab.io/sdk-core';
3
3
  import * as LegacyTypes from 'mitra-interactions-sdk';
4
4
  import { exchangeSsoCodeMitra as exchangeSsoCodeMitra$1, loginMitra as loginMitra$1, loginWithGoogleMitra as loginWithGoogleMitra$1, loginWithMicrosoftMitra as loginWithMicrosoftMitra$1 } from 'mitra-interactions-sdk';
5
5
  export { callIntegrationMitra, configureSdkMitra, createMitraInstance, createRecordMitra, createRecordsBatchMitra, deleteRecordMitra, executePublicServerFunctionAsyncMitra, executePublicServerFunctionMitra, executeServerFunctionAsyncMitra, executeServerFunctionMitra, getAgentTaskMitra, getConfig, getPublicServerFunctionExecutionMitra, getRecordMitra, listIntegrationsMitra, listRecordsMitra, manageAgentChatMitra, manageAgentCredentialMitra, patchRecordMitra, refreshTokenSilently, resolveProjectId, stopServerFunctionExecutionMitra, updateRecordMitra } from 'mitra-interactions-sdk';
@@ -762,6 +762,11 @@ type AgentDeviceProvider = 'OPENAI';
762
762
  interface AgentCredentialsModule {
763
763
  list(options?: AgentCredentialOptions): Promise<CredentialStatus[]>;
764
764
  listModels(agentId?: string, options?: AgentCredentialOptions): Promise<AgentModel$1[]>;
765
+ /**
766
+ * The last subscription window a chat on this credential reported, readable with no chat open.
767
+ * `null` until a turn on the provider's subscription login has reported one.
768
+ */
769
+ usage(provider: AgentCredentialProvider, options?: AgentCredentialOptions): Promise<CredentialUsage | null>;
765
770
  saveApiKey(provider: AgentCredentialProvider, apiKey: string, options?: AgentCredentialOptions): Promise<void>;
766
771
  remove(provider: AgentCredentialProvider, options?: AgentCredentialOptions): Promise<void>;
767
772
  startOAuth(provider: AgentOAuthProvider, options?: AgentCredentialOptions): Promise<OAuthStartResult>;
package/dist/index.js CHANGED
@@ -2469,6 +2469,10 @@ function createBrowserAgentCredentialsModule(httpClient) {
2469
2469
  return {
2470
2470
  list: (options) => core.list(options),
2471
2471
  listModels: (agentId, options) => core.listModels(agentId, options),
2472
+ usage: (provider, options) => {
2473
+ requireProvider(provider, ["ANTHROPIC", "OPENAI"], "Subscription usage");
2474
+ return core.usage(provider, options);
2475
+ },
2472
2476
  saveApiKey: (provider, apiKey, options) => {
2473
2477
  requireProvider(provider, ["ANTHROPIC", "OPENAI"], "API key authentication");
2474
2478
  return core.saveApiKey(provider, apiKey, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mitralab.io/platform-sdk",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "JavaScript/TypeScript SDK for building apps on the Mitra Platform",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -62,7 +62,7 @@
62
62
  "url": "https://github.com/mitralab-dev/mitra-platform-sdk/issues"
63
63
  },
64
64
  "dependencies": {
65
- "@mitralab.io/sdk-core": "0.2.9",
65
+ "@mitralab.io/sdk-core": "0.2.10",
66
66
  "mitra-interactions-sdk": "1.0.60-beta.48"
67
67
  },
68
68
  "devDependencies": {