@mitralab.io/platform-sdk 1.3.0-beta.0 → 1.4.0-beta.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 +16 -0
- package/README.md +7 -0
- package/dist/index.cjs +4 -0
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +4 -0
- package/package.json +2 -2
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-beta.0
|
|
6
|
+
|
|
7
|
+
- `agentCredentials.usage("ANTHROPIC" | "OPENAI", { scope })` reads the last subscription reading
|
|
8
|
+
a chat on that credential reported, with no chat open: `{ harness, observedAt, status, windows:
|
|
9
|
+
[{ kind, usedPercent, resetsAt, windowSeconds }] }`, or `null` while none has. The session emits
|
|
10
|
+
the same reading as `providerUsage` during a turn on the box.
|
|
11
|
+
- Depend on `@mitralab.io/sdk-core@0.2.10-beta.0` and export `CredentialUsage`,
|
|
12
|
+
`CredentialUsageWindow` and `AgentProviderUsage`.
|
|
13
|
+
|
|
14
|
+
## 1.3.0
|
|
15
|
+
|
|
16
|
+
Stable release of the 1.3.0-beta.0 line, already on the `beta` tag. It pins
|
|
17
|
+
`@mitralab.io/sdk-core` to `0.2.9`, the stable release of the `0.2.9-beta.1` surface this line
|
|
18
|
+
already followed. No code change since 1.3.0-beta.0; the entry below describes what moves from
|
|
19
|
+
1.2.0.
|
|
20
|
+
|
|
5
21
|
## 1.3.0-beta.0
|
|
6
22
|
|
|
7
23
|
- The direct channel to the chat's box now comes from `@mitralab.io/sdk-core@0.2.9-beta.1`. This
|
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
|
+
"version": "1.4.0-beta.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.
|
|
65
|
+
"@mitralab.io/sdk-core": "0.2.10-beta.0",
|
|
66
66
|
"mitra-interactions-sdk": "1.0.60-beta.48"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|