@mitralab.io/platform-sdk 1.2.0-beta.3 → 1.2.0-beta.4

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,17 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## 1.2.0-beta.4
6
+
7
+ - `agentCredentials` exposes the person's custom providers: `listCustomProviders(options?)`,
8
+ `createCustomProvider(input, options?)` and `deleteCustomProvider(id, options?)`, plain
9
+ passthroughs to `/api/v1/credentials/custom-providers` with the same trailing `{ scope: "ACCOUNT" }`
10
+ the other credential calls take. The Copilot requires `scope: "ACCOUNT"` on an app token. No
11
+ provider guard applies and the provider unions are unchanged. `AgentConnectionCustomProvider`
12
+ and `AgentConnectionCustomProviderInput` are re-exported from the package index.
13
+ - Depend on `@mitralab.io/sdk-core@0.2.7-beta.0`, which adds the three methods to the credential
14
+ module.
15
+
5
16
  ## 1.2.0-beta.3
6
17
 
7
18
  - `session({ create: true })`, `agentTasks.create()` and `session.send()` (with `sendAndWait()`
package/README.md CHANGED
@@ -416,7 +416,7 @@ A chat created with `create: true` over the `auto` or `websocket` transport is b
416
416
 
417
417
  `session({ create: true, agentId, scope: "ACCOUNT" })` and `agentTasks.create({ agentType, agentId, scope: "ACCOUNT" })` send `scope` in the create body, so the chat runs on the credential the person connected to their own account, the one the IDE and the builder read, instead of the agent's connection. The Copilot honors `ACCOUNT` only for apps listed by flag and answers `ACCOUNT_CREDENTIAL_NOT_ALLOWED` otherwise; a turn without a credential on the account fails with `ACCOUNT_CREDENTIAL_MISSING`. Through `agentTasks.session(...)` those refusals reach the session `error` event with the message and code the Copilot sends; through `agentTasks.create()` and the `agentCredentials` methods they reject the promise with a `MitraApiError` carrying status and code. No platform session is involved: the app token is used as always. Without `scope` nothing changes.
418
418
 
419
- `session({ create: true, agentType: "CUSTOM_AI", model })`, `agentTasks.create({ agentType: "CUSTOM_AI", model })` and `session.send(text, { agentType: "CUSTOM_AI", model })` pass `model` through unchanged: in the create body, in the message frame on the box socket and in the `POST /inputs` body. It is the catalog model id `agentCredentials.listModels()` returns, `custom/<providerId>/<model>` for a provider the person added by API, and the Copilot requires it when `agentType` is `CUSTOM_AI`. Those models carry `providerName`, the name the person chose for the provider; it is null on built-in models and absent on an older Copilot. Custom providers are added to a connection server-side with the core SDK; this package does not expose that. Without `model` nothing changes on the wire.
419
+ `session({ create: true, agentType: "CUSTOM_AI", model })`, `agentTasks.create({ agentType: "CUSTOM_AI", model })` and `session.send(text, { agentType: "CUSTOM_AI", model })` pass `model` through unchanged: in the create body, in the message frame on the box socket and in the `POST /inputs` body. It is the catalog model id `agentCredentials.listModels()` returns, `custom/<providerId>/<model>` for a provider the person added by API, and the Copilot requires it when `agentType` is `CUSTOM_AI`. Those models carry `providerName`, the name the person chose for the provider; it is null on built-in models and absent on an older Copilot. A connection's custom providers, the ones an agent's business connection carries, are added server-side with the core SDK and this package does not expose them; the person's own custom providers are managed through `agentCredentials`, described further down in this section. Without `model` nothing changes on the wire.
420
420
 
421
421
  Open an existing task with `session({ taskId })`. The default `auto` transport refreshes before connecting, asks the Copilot once where the chat is served, and opens whichever channel it names: the box that runs the agent when one is offered, `/copilot/ws/tasks/{taskId}` otherwise. The Copilot holds that request while the box boots and answers only once the box is ready or cannot be had; the SDK does not poll. The choice belongs to the server, never to application configuration, so a Copilot that stops offering the box leaves every application on the Copilot socket without a republish. Opening the box never asks it to replay, whether the conversation is new to the session or is being opened again after an idle close: what an idle conversation missed is history, which the application loads over REST. A box socket that drops in the middle of a turn is redialed by the SDK itself, with a bounded backoff (1, 2, 4, 8 and 16 seconds) and the replay from the last position seen on that socket, so the answer keeps streaming; a position taken on one box is forgotten when the Copilot points the conversation to another box; replayed `textChunk` frames reach the `delta` event like live text. While that happens the session emits `raw` events of type `channelReconnecting` (payload `attempt`, `maxAttempts`, `reason`) and `channelConnected` (payload `attempt`); the session `status` stays `streaming`, because Core has no reconnecting status. The disconnect reaches Core, and with it the `error` event, only when the attempts run out or the Copilot no longer offers the box. A drop with no turn in flight, a channel taken over by another tab (close code 4409), and any close of the Copilot socket the session did not ask for are reported at once, whatever the code, so the next send reopens the channel instead of waiting on a socket that is gone. Recovery through persisted history plus the HTTP/SSE channel is unchanged. Set `transport: "http"` when WebSockets are unavailable. Messages sent during a turn enter a FIFO queue with a maximum of 10 items; the session also exposes edit, remove, clear, approval, cancel, history, close, and typed events.
422
422
 
@@ -428,6 +428,8 @@ API keys and removal accept `ANTHROPIC` or `OPENAI`. OAuth accepts only `ANTHROP
428
428
 
429
429
  Every `agentCredentials` method takes a trailing `options` with `scope: "ACCOUNT"`, sent as the `scope` query parameter, so the credential is read from or written to the person's own account instead of the app: `startOAuth("ANTHROPIC", { scope: "ACCOUNT" })`, `exchangeOAuth("ANTHROPIC", input, { scope: "ACCOUNT" })`, `list({ scope: "ACCOUNT" })`. The Copilot honors `ACCOUNT` only for apps listed by flag and answers `ACCOUNT_CREDENTIAL_NOT_ALLOWED` otherwise. No platform session is involved: the app token is used as always. Without `options` the request is the same as before.
430
430
 
431
+ 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>`, the `model` a chat is created with. The Copilot requires `scope: "ACCOUNT"` on an app token. The three methods take no provider argument and no provider guard applies.
432
+
431
433
  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.
432
434
 
433
435
  ## Custom queries
package/dist/index.cjs CHANGED
@@ -2753,7 +2753,10 @@ function createBrowserAgentCredentialsModule(httpClient) {
2753
2753
  pollDeviceAuthorization: (provider, deviceAuthId, options) => {
2754
2754
  requireProvider(provider, ["OPENAI"], "Device authorization");
2755
2755
  return core.pollDeviceAuthorization(provider, deviceAuthId, options);
2756
- }
2756
+ },
2757
+ listCustomProviders: (options) => core.listCustomProviders(options),
2758
+ createCustomProvider: (input, options) => core.createCustomProvider(input, options),
2759
+ deleteCustomProvider: (id, options) => core.deleteCustomProvider(id, options)
2757
2760
  };
2758
2761
  }
2759
2762
 
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, PublicFunctionsModule, AgentTasksWithSessions } from '@mitralab.io/sdk-core';
2
- export { 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, 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';
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';
@@ -768,6 +768,9 @@ interface AgentCredentialsModule {
768
768
  exchangeOAuth(provider: AgentOAuthProvider, input: OAuthExchangeInput, options?: AgentCredentialOptions): Promise<AuthenticationResult>;
769
769
  startDeviceAuthorization(provider: AgentDeviceProvider, options?: AgentCredentialOptions): Promise<DeviceAuthorization>;
770
770
  pollDeviceAuthorization(provider: AgentDeviceProvider, deviceAuthId: string, options?: AgentCredentialOptions): Promise<AuthenticationResult>;
771
+ listCustomProviders(options?: AgentCredentialOptions): Promise<AgentConnectionCustomProvider[]>;
772
+ createCustomProvider(input: AgentConnectionCustomProviderInput, options?: AgentCredentialOptions): Promise<AgentConnectionCustomProvider[]>;
773
+ deleteCustomProvider(id: string, options?: AgentCredentialOptions): Promise<void>;
771
774
  }
772
775
 
773
776
  /**
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, PublicFunctionsModule, AgentTasksWithSessions } from '@mitralab.io/sdk-core';
2
- export { 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, 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';
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';
@@ -768,6 +768,9 @@ interface AgentCredentialsModule {
768
768
  exchangeOAuth(provider: AgentOAuthProvider, input: OAuthExchangeInput, options?: AgentCredentialOptions): Promise<AuthenticationResult>;
769
769
  startDeviceAuthorization(provider: AgentDeviceProvider, options?: AgentCredentialOptions): Promise<DeviceAuthorization>;
770
770
  pollDeviceAuthorization(provider: AgentDeviceProvider, deviceAuthId: string, options?: AgentCredentialOptions): Promise<AuthenticationResult>;
771
+ listCustomProviders(options?: AgentCredentialOptions): Promise<AgentConnectionCustomProvider[]>;
772
+ createCustomProvider(input: AgentConnectionCustomProviderInput, options?: AgentCredentialOptions): Promise<AgentConnectionCustomProvider[]>;
773
+ deleteCustomProvider(id: string, options?: AgentCredentialOptions): Promise<void>;
771
774
  }
772
775
 
773
776
  /**
package/dist/index.js CHANGED
@@ -2718,7 +2718,10 @@ function createBrowserAgentCredentialsModule(httpClient) {
2718
2718
  pollDeviceAuthorization: (provider, deviceAuthId, options) => {
2719
2719
  requireProvider(provider, ["OPENAI"], "Device authorization");
2720
2720
  return core.pollDeviceAuthorization(provider, deviceAuthId, options);
2721
- }
2721
+ },
2722
+ listCustomProviders: (options) => core.listCustomProviders(options),
2723
+ createCustomProvider: (input, options) => core.createCustomProvider(input, options),
2724
+ deleteCustomProvider: (id, options) => core.deleteCustomProvider(id, options)
2722
2725
  };
2723
2726
  }
2724
2727
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mitralab.io/platform-sdk",
3
- "version": "1.2.0-beta.3",
3
+ "version": "1.2.0-beta.4",
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.6-beta.0",
65
+ "@mitralab.io/sdk-core": "0.2.7-beta.0",
66
66
  "mitra-interactions-sdk": "1.0.60-beta.48"
67
67
  },
68
68
  "devDependencies": {