@mitralab.io/sdk-core 0.2.9-beta.1 → 0.2.10-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 +18 -0
- package/README.md +9 -1
- package/contracts/README.md +9 -0
- package/contracts/manifest.json +11 -1
- package/contracts/v0.2.10-beta.0/sdk-parity.json +2902 -0
- package/contracts/v0.2.9/sdk-parity.json +2902 -0
- package/dist/index.cjs +59 -0
- package/dist/index.d.cts +48 -1
- package/dist/index.d.ts +48 -1
- package/dist/index.js +59 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1038,6 +1038,34 @@ function expectCredentialStatus(value, context, errors = defaultSdkCoreErrorFact
|
|
|
1038
1038
|
}
|
|
1039
1039
|
return status;
|
|
1040
1040
|
}
|
|
1041
|
+
function expectCredentialUsage(value, context, errors = defaultSdkCoreErrorFactory) {
|
|
1042
|
+
const usage = expectObject(value, context, errors);
|
|
1043
|
+
if (typeof usage.harness !== "string") invalidField(context, "harness", errors);
|
|
1044
|
+
if (typeof usage.observedAt !== "string") invalidField(context, "observedAt", errors);
|
|
1045
|
+
if (!isNullableString(usage.status)) invalidField(context, "status", errors);
|
|
1046
|
+
if (!Array.isArray(usage.windows)) invalidField(context, "windows", errors);
|
|
1047
|
+
for (const window of usage.windows) {
|
|
1048
|
+
if (!isObject(window) || typeof window.kind !== "string")
|
|
1049
|
+
invalidField(context, "windows.kind", errors);
|
|
1050
|
+
if (!isInteger(window.usedPercent)) invalidField(context, "windows.usedPercent", errors);
|
|
1051
|
+
if (!isNullableString(window.resetsAt)) invalidField(context, "windows.resetsAt", errors);
|
|
1052
|
+
if (window.windowSeconds !== null && !isInteger(window.windowSeconds)) {
|
|
1053
|
+
invalidField(context, "windows.windowSeconds", errors);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
return usage;
|
|
1057
|
+
}
|
|
1058
|
+
var CREDENTIAL_USAGE_NOT_FOUND = "CREDENTIAL_USAGE_NOT_FOUND";
|
|
1059
|
+
async function readCredentialUsage(request, context, errors = defaultSdkCoreErrorFactory) {
|
|
1060
|
+
let value;
|
|
1061
|
+
try {
|
|
1062
|
+
value = await request;
|
|
1063
|
+
} catch (error) {
|
|
1064
|
+
if (error?.code === CREDENTIAL_USAGE_NOT_FOUND) return null;
|
|
1065
|
+
throw error;
|
|
1066
|
+
}
|
|
1067
|
+
return expectCredentialUsage(value, context, errors);
|
|
1068
|
+
}
|
|
1041
1069
|
function expectOAuthStartResult(value, context, errors = defaultSdkCoreErrorFactory) {
|
|
1042
1070
|
const result = expectObject(value, context, errors);
|
|
1043
1071
|
if (typeof result.authUrl !== "string") invalidField(context, "authUrl", errors);
|
|
@@ -1168,6 +1196,13 @@ function createAgentConnectionsModule(transport, errors = defaultSdkCoreErrorFac
|
|
|
1168
1196
|
errors
|
|
1169
1197
|
);
|
|
1170
1198
|
},
|
|
1199
|
+
async usage(id, provider) {
|
|
1200
|
+
return readCredentialUsage(
|
|
1201
|
+
transport.request(`${providerPath(id, provider)}/usage`, { method: "GET" }),
|
|
1202
|
+
"Connection usage response",
|
|
1203
|
+
errors
|
|
1204
|
+
);
|
|
1205
|
+
},
|
|
1171
1206
|
async create(name) {
|
|
1172
1207
|
return expectAgentConnection(
|
|
1173
1208
|
await transport.request("/api/v1/connections", {
|
|
@@ -1308,6 +1343,16 @@ function createAgentCredentialsModule(transport, errors = defaultSdkCoreErrorFac
|
|
|
1308
1343
|
expectAgentModel
|
|
1309
1344
|
);
|
|
1310
1345
|
},
|
|
1346
|
+
async usage(provider, options) {
|
|
1347
|
+
return readCredentialUsage(
|
|
1348
|
+
transport.request(`/api/v1/credentials/${providerSegment(provider)}/usage`, {
|
|
1349
|
+
method: "GET",
|
|
1350
|
+
...scopeParams(options)
|
|
1351
|
+
}),
|
|
1352
|
+
"Credential usage response",
|
|
1353
|
+
errors
|
|
1354
|
+
);
|
|
1355
|
+
},
|
|
1311
1356
|
async saveApiKey(provider, apiKey, options) {
|
|
1312
1357
|
expectEmpty(
|
|
1313
1358
|
await transport.request(
|
|
@@ -3877,6 +3922,15 @@ var AgentDirectChannel = class {
|
|
|
3877
3922
|
var AGENT_QUEUE_LIMIT = 10;
|
|
3878
3923
|
var CANCEL_SAFETY_MS = 1e4;
|
|
3879
3924
|
var RECONCILE_DELAY_MS = 1e3;
|
|
3925
|
+
function providerUsageOf(payload) {
|
|
3926
|
+
if (!payload) return null;
|
|
3927
|
+
try {
|
|
3928
|
+
const { harness, observedAt, status, windows } = expectCredentialUsage(payload, "providerUsage");
|
|
3929
|
+
return { harness, observedAt, status, windows };
|
|
3930
|
+
} catch {
|
|
3931
|
+
return null;
|
|
3932
|
+
}
|
|
3933
|
+
}
|
|
3880
3934
|
function asObject2(value) {
|
|
3881
3935
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
3882
3936
|
}
|
|
@@ -4330,6 +4384,11 @@ var CoreAgentTaskSession = class {
|
|
|
4330
4384
|
case "workspace":
|
|
4331
4385
|
this.emit("workspace", { payload: event.payload, timestamp: event.timestamp });
|
|
4332
4386
|
break;
|
|
4387
|
+
case "providerUsage": {
|
|
4388
|
+
const usage = providerUsageOf(payload);
|
|
4389
|
+
if (usage) this.emit("providerUsage", usage);
|
|
4390
|
+
break;
|
|
4391
|
+
}
|
|
4333
4392
|
case "stepFinish": {
|
|
4334
4393
|
const reason = typeof payload?.reason === "string" ? payload.reason : "unknown";
|
|
4335
4394
|
const lifecycle = payload?.lifecycle;
|
package/dist/index.d.cts
CHANGED
|
@@ -1118,6 +1118,33 @@ interface CredentialStatus {
|
|
|
1118
1118
|
accountEmail: string | null;
|
|
1119
1119
|
maskedApiKey: string | null;
|
|
1120
1120
|
}
|
|
1121
|
+
/** One window of a provider subscription. `resetsAt` and `windowSeconds` are null when the harness did not state them. */
|
|
1122
|
+
interface CredentialUsageWindow {
|
|
1123
|
+
/**
|
|
1124
|
+
* Stable name in UPPER_SNAKE: FIVE_HOUR, WEEKLY, WEEKLY_OPUS, or the provider's own. A Codex
|
|
1125
|
+
* bucket other than the account's own carries its limit id as a suffix (FIVE_HOUR_GPT_5_5_PRO).
|
|
1126
|
+
*/
|
|
1127
|
+
kind: string;
|
|
1128
|
+
/** Share of the window already consumed, 0 to 100. */
|
|
1129
|
+
usedPercent: number;
|
|
1130
|
+
/** ISO instant the window resets. */
|
|
1131
|
+
resetsAt: string | null;
|
|
1132
|
+
windowSeconds: number | null;
|
|
1133
|
+
}
|
|
1134
|
+
/**
|
|
1135
|
+
* Every window of a provider subscription as chats on that credential last reported it, with the
|
|
1136
|
+
* provider's own status (Claude: `allowed`, `allowed_warning` or `rejected`; Codex: the limit it
|
|
1137
|
+
* says was reached, or null). Claude reports every window at once. Codex reports only what changed,
|
|
1138
|
+
* so each of its windows is the last one reported for that kind, a window past its reset is dropped,
|
|
1139
|
+
* and the status is the one of the last event, whichever bucket sent it.
|
|
1140
|
+
*/
|
|
1141
|
+
interface CredentialUsage {
|
|
1142
|
+
harness: "claude" | "codex" | (string & {});
|
|
1143
|
+
/** ISO instant the harness reported this reading. */
|
|
1144
|
+
observedAt: string;
|
|
1145
|
+
status: string | null;
|
|
1146
|
+
windows: CredentialUsageWindow[];
|
|
1147
|
+
}
|
|
1121
1148
|
interface OAuthStartResult {
|
|
1122
1149
|
authUrl: string;
|
|
1123
1150
|
state: string;
|
|
@@ -1206,6 +1233,11 @@ interface AgentConnectionsModule {
|
|
|
1206
1233
|
/** Lists app connections with safe per-provider status and no credentials. */
|
|
1207
1234
|
list(): Promise<AgentConnection[]>;
|
|
1208
1235
|
get(id: string): Promise<AgentConnection>;
|
|
1236
|
+
/**
|
|
1237
|
+
* The last subscription window a chat on this connection's provider login reported. Null until
|
|
1238
|
+
* one has.
|
|
1239
|
+
*/
|
|
1240
|
+
usage(id: string, provider: CopilotProvider): Promise<CredentialUsage | null>;
|
|
1209
1241
|
/** Creates an unauthenticated provider container. */
|
|
1210
1242
|
create(name: string): Promise<AgentConnection>;
|
|
1211
1243
|
/**
|
|
@@ -1240,6 +1272,12 @@ interface AgentCredentialsModule {
|
|
|
1240
1272
|
list(options?: AgentCredentialOptions): Promise<CredentialStatus[]>;
|
|
1241
1273
|
/** Lists models backed by a usable credential, optionally through a business agent connection. */
|
|
1242
1274
|
listModels(agentId?: string, options?: AgentCredentialOptions): Promise<AgentModel[]>;
|
|
1275
|
+
/**
|
|
1276
|
+
* The last subscription window a chat on this credential reported, readable with no chat open.
|
|
1277
|
+
* Resolves to null until a turn on the provider's subscription login has reported one; an API
|
|
1278
|
+
* key never has a window.
|
|
1279
|
+
*/
|
|
1280
|
+
usage(provider: CopilotProvider, options?: AgentCredentialOptions): Promise<CredentialUsage | null>;
|
|
1243
1281
|
/** Validates and stores a write-only API key. */
|
|
1244
1282
|
saveApiKey(provider: CopilotProvider, apiKey: string, options?: AgentCredentialOptions): Promise<void>;
|
|
1245
1283
|
/** Permanently removes the current credential for a provider. */
|
|
@@ -1953,8 +1991,17 @@ interface AgentTaskSessionEventMap {
|
|
|
1953
1991
|
code?: string;
|
|
1954
1992
|
error: string;
|
|
1955
1993
|
};
|
|
1994
|
+
/**
|
|
1995
|
+
* The subscription window the chat's harness reported during a turn. It comes only on the
|
|
1996
|
+
* direct channel of a business agent chat, and only when the turn runs on the person's or the
|
|
1997
|
+
* connection's own login; the Copilot stream a chat falls back to never carries it. The Copilot
|
|
1998
|
+
* keeps the last reading, which `agentCredentials.usage` reads with no chat open.
|
|
1999
|
+
*/
|
|
2000
|
+
providerUsage: AgentProviderUsage;
|
|
1956
2001
|
raw: AgentTaskEvent;
|
|
1957
2002
|
}
|
|
2003
|
+
/** The same shape `agentCredentials.usage` answers with. */
|
|
2004
|
+
type AgentProviderUsage = CredentialUsage;
|
|
1958
2005
|
interface AgentTaskSession {
|
|
1959
2006
|
readonly taskId: string | null;
|
|
1960
2007
|
readonly task: AgentTask | null;
|
|
@@ -2044,4 +2091,4 @@ declare function expectPage<T extends object>(value: unknown, context: string, e
|
|
|
2044
2091
|
declare function expectLegacyPage<T extends object>(value: unknown, context: string, errors?: SdkCoreErrorFactory, validateItem?: (value: unknown, context: string, errors: SdkCoreErrorFactory) => T): LegacyPage<T>;
|
|
2045
2092
|
declare function expectEmpty(value: unknown, context: string, errors?: SdkCoreErrorFactory): void;
|
|
2046
2093
|
|
|
2047
|
-
export { API_KEY_EXCHANGE_PATH, type AgentBulkDeleteResult, type AgentConnection, type AgentConnectionCreateInput, type AgentConnectionCustomProvider, type AgentConnectionCustomProviderInput, type AgentConnectionsModule, type AgentCredentialOptions, type AgentCredentialScope, type AgentCredentialsModule, type AgentDefinition, type AgentDirectChannelOptions, type AgentFetch, type AgentFetchResponse, type AgentInput, type AgentMessage, type AgentModel, type AgentQueueItem, type AgentSendAndWaitOptions, type AgentSendOptions, type AgentSessionTransport, type AgentTask, type AgentTaskChannel, type AgentTaskCreateInput, type AgentTaskEvent, type AgentTaskEventConnection, type AgentTaskEventObserver, type AgentTaskEventSource, type AgentTaskInput, type AgentTaskListOptions, type AgentTaskRuntime, type AgentTaskSession, type AgentTaskSessionEventMap, type AgentTaskSessionManager, type AgentTaskSessionManagerOptions, type AgentTaskSessionOptions, type AgentTaskSessionStatus, AgentTaskTurnError, type AgentTasksModule, type AgentTasksWithSessions, type AgentTimelineItem, type AgentToolEvent, type AgentTurnResult, type AgentUpdateItem, type AgentWebSocket, type AgentWebSocketConstructor, type AgentsModule, type ApiKeyExchangeCaller, type AppColor, type AppContext, type AppCreateInput, type AppDefinition, type AppDeploy, type AppDomain, type AppFiles, type AppGetOptions, type AppListOptions, type AppMember, type AppPublishOptions, type AppSummary, type AppUpdateInput, type AppVersion, type AppVersionStatus, type AppsModule, type AuthModule, type AuthenticationResult, type BatchExecution, type BatchStatementResult, type BulkUnsubscribeResult, type ColumnInput, type ConnectionConfig, type ConnectionConfigResponse, type ConnectionTestResult, type ContextModule, type ContextModuleDependencies, type CopilotProvider, type CredentialStatus, type CustomQueriesModule, type CustomQueryDefinition, type CustomQueryInput, type CustomQuerySummary, type CustomQueryUpdateInput, type DataSourceBulkItemResult, type DataSourceBulkResult, type DataSourceCreateInput, type DataSourceDbType, type DataSourceDefinition, type DataSourceInstanceType, type DataSourceUpdateInput, type DataSourcesModule, type DdlStatement, type DeviceAuthorization, type DmlStatement, type EmptyFunctionInput, type EntitiesModule, type EntitiesProxy, type EntityListOptions, type EntityListResponse, type EntityTable, type ExistingAgentTaskSessionOptions, type FunctionBulkCreateInput, type FunctionBulkDeleteInput, type FunctionBulkDeleteResult, type FunctionBulkPatchInput, type FunctionBulkPatchItem, type FunctionBulkUpdateItem, type FunctionCreateInput, type FunctionDefinition, type FunctionExecution, type FunctionListOptions, type FunctionPatchInput, type FunctionRuntime, type FunctionSecrets, type FunctionSummary, type FunctionUpdateInput, type FunctionVersion, type FunctionVersionListOptions, type FunctionVisibility, type FunctionsAdminModule, type FunctionsModule, type FunctionsModuleOptions, type HttpMethod, type ImportColumnMapping, type ImportDefinition, type ImportExecution, type ImportExecutionListOptions, type ImportInput, type ImportProcessing, type ImportSchedule, type ImportSource, type ImportSourceResponse, type ImportTarget, type ImportsModule, type IntegrationAdminModule, type IntegrationConnectionStatus, type IntegrationCredentialRule, type IntegrationExecution, type IntegrationFieldSchema, type IntegrationFieldSchemaInput, type IntegrationLoginConfig, type IntegrationModule, type IntegrationProxyMode, type IntegrationRequestConfig, type IntegrationResource, type IntegrationResourceInput, type IntegrationResourceParam, type IntegrationResourceSummary, type IntegrationResourceUpdateInput, type IntegrationResourcesModule, type IntegrationTemplate, type IntegrationTemplateSummary, type IntegrationTemplateType, type IntegrationTemplatesModule, type IntegrationTokenExtraction, type InviteAppUserInput, type InvocationType, type JsonValue, type LegacyPage, type ListTablesOptions, type ListTemplateConfigsOptions, type MembersModule, type MessageAccepted, type MessengerModule, type NewAgentTaskSessionOptions, type OAuthExchangeInput, type OAuthStartResult, type Page, type PageOptions, type PlanPrice, type ProviderCredentialStatus, type ProxyInput, type ProxyResult, type PublicFunctionAsyncResult, type PublicFunctionResult, type PublicFunctionsModule, type QueriesModule, type QueryParamPrimitive, type QueryParamValue, type QueryResult, type SchemaModule, type SchemaScope, type SchemaTables, type SdkCore, SdkCoreConfigurationError, type SdkCoreErrorFactory, type SdkCoreOptions, SdkCoreResponseError, type SdkCoreTransports, type SqlModule, type TableColumn, type TableDefinition, type TableForeignKey, type TemplateConfig, type TemplateConfigBulkItemResult, type TemplateConfigBulkResult, type TemplateConfigCreateInput, type TemplateConfigPage, type TemplateConfigSummary, type TemplateConfigUpdateInput, type Tenant, type TestCredentialsInput, type Transport, type TransportRequestOptions, type User, type UserPlan, type WorkflowDefinition, type WorkflowExecution, type WorkflowInput, type WorkflowSummary, type WorkflowsModule, appAccessTokenPath, createAgentConnectionsModule, createAgentCredentialsModule, createAgentTaskSessionManager, createAgentTasksModule, createAgentsModule, createAppsModule, createAuthModule, createContextModule, createCustomQueriesModule, createDataSourcesModule, createEntitiesModule, createFunctionsAdminModule, createFunctionsModule, createImportsModule, createIntegrationAdminModule, createIntegrationModule, createIntegrationResourcesModule, createIntegrationTemplatesModule, createMembersModule, createMessengerModule, createPublicFunctionsModule, createQueriesModule, createSchemaModule, createSdkCore, createSqlModule, createWorkflowsModule, defaultSdkCoreErrorFactory, encodePathSegment, expectEmpty, expectLegacyPage, expectNullableObject, expectObject, expectObjectArray, expectPage, expectStringArray, isWorkspaceSession, readTokenAppId, readTokenExpiry, resolveApiKeyToken, toAgentTimelineItem, tokenAuthorizesApp, withAgentTaskSessions };
|
|
2094
|
+
export { API_KEY_EXCHANGE_PATH, type AgentBulkDeleteResult, type AgentConnection, type AgentConnectionCreateInput, type AgentConnectionCustomProvider, type AgentConnectionCustomProviderInput, type AgentConnectionsModule, type AgentCredentialOptions, type AgentCredentialScope, type AgentCredentialsModule, type AgentDefinition, type AgentDirectChannelOptions, type AgentFetch, type AgentFetchResponse, type AgentInput, type AgentMessage, type AgentModel, type AgentProviderUsage, type AgentQueueItem, type AgentSendAndWaitOptions, type AgentSendOptions, type AgentSessionTransport, type AgentTask, type AgentTaskChannel, type AgentTaskCreateInput, type AgentTaskEvent, type AgentTaskEventConnection, type AgentTaskEventObserver, type AgentTaskEventSource, type AgentTaskInput, type AgentTaskListOptions, type AgentTaskRuntime, type AgentTaskSession, type AgentTaskSessionEventMap, type AgentTaskSessionManager, type AgentTaskSessionManagerOptions, type AgentTaskSessionOptions, type AgentTaskSessionStatus, AgentTaskTurnError, type AgentTasksModule, type AgentTasksWithSessions, type AgentTimelineItem, type AgentToolEvent, type AgentTurnResult, type AgentUpdateItem, type AgentWebSocket, type AgentWebSocketConstructor, type AgentsModule, type ApiKeyExchangeCaller, type AppColor, type AppContext, type AppCreateInput, type AppDefinition, type AppDeploy, type AppDomain, type AppFiles, type AppGetOptions, type AppListOptions, type AppMember, type AppPublishOptions, type AppSummary, type AppUpdateInput, type AppVersion, type AppVersionStatus, type AppsModule, type AuthModule, type AuthenticationResult, type BatchExecution, type BatchStatementResult, type BulkUnsubscribeResult, type ColumnInput, type ConnectionConfig, type ConnectionConfigResponse, type ConnectionTestResult, type ContextModule, type ContextModuleDependencies, type CopilotProvider, type CredentialStatus, type CredentialUsage, type CredentialUsageWindow, type CustomQueriesModule, type CustomQueryDefinition, type CustomQueryInput, type CustomQuerySummary, type CustomQueryUpdateInput, type DataSourceBulkItemResult, type DataSourceBulkResult, type DataSourceCreateInput, type DataSourceDbType, type DataSourceDefinition, type DataSourceInstanceType, type DataSourceUpdateInput, type DataSourcesModule, type DdlStatement, type DeviceAuthorization, type DmlStatement, type EmptyFunctionInput, type EntitiesModule, type EntitiesProxy, type EntityListOptions, type EntityListResponse, type EntityTable, type ExistingAgentTaskSessionOptions, type FunctionBulkCreateInput, type FunctionBulkDeleteInput, type FunctionBulkDeleteResult, type FunctionBulkPatchInput, type FunctionBulkPatchItem, type FunctionBulkUpdateItem, type FunctionCreateInput, type FunctionDefinition, type FunctionExecution, type FunctionListOptions, type FunctionPatchInput, type FunctionRuntime, type FunctionSecrets, type FunctionSummary, type FunctionUpdateInput, type FunctionVersion, type FunctionVersionListOptions, type FunctionVisibility, type FunctionsAdminModule, type FunctionsModule, type FunctionsModuleOptions, type HttpMethod, type ImportColumnMapping, type ImportDefinition, type ImportExecution, type ImportExecutionListOptions, type ImportInput, type ImportProcessing, type ImportSchedule, type ImportSource, type ImportSourceResponse, type ImportTarget, type ImportsModule, type IntegrationAdminModule, type IntegrationConnectionStatus, type IntegrationCredentialRule, type IntegrationExecution, type IntegrationFieldSchema, type IntegrationFieldSchemaInput, type IntegrationLoginConfig, type IntegrationModule, type IntegrationProxyMode, type IntegrationRequestConfig, type IntegrationResource, type IntegrationResourceInput, type IntegrationResourceParam, type IntegrationResourceSummary, type IntegrationResourceUpdateInput, type IntegrationResourcesModule, type IntegrationTemplate, type IntegrationTemplateSummary, type IntegrationTemplateType, type IntegrationTemplatesModule, type IntegrationTokenExtraction, type InviteAppUserInput, type InvocationType, type JsonValue, type LegacyPage, type ListTablesOptions, type ListTemplateConfigsOptions, type MembersModule, type MessageAccepted, type MessengerModule, type NewAgentTaskSessionOptions, type OAuthExchangeInput, type OAuthStartResult, type Page, type PageOptions, type PlanPrice, type ProviderCredentialStatus, type ProxyInput, type ProxyResult, type PublicFunctionAsyncResult, type PublicFunctionResult, type PublicFunctionsModule, type QueriesModule, type QueryParamPrimitive, type QueryParamValue, type QueryResult, type SchemaModule, type SchemaScope, type SchemaTables, type SdkCore, SdkCoreConfigurationError, type SdkCoreErrorFactory, type SdkCoreOptions, SdkCoreResponseError, type SdkCoreTransports, type SqlModule, type TableColumn, type TableDefinition, type TableForeignKey, type TemplateConfig, type TemplateConfigBulkItemResult, type TemplateConfigBulkResult, type TemplateConfigCreateInput, type TemplateConfigPage, type TemplateConfigSummary, type TemplateConfigUpdateInput, type Tenant, type TestCredentialsInput, type Transport, type TransportRequestOptions, type User, type UserPlan, type WorkflowDefinition, type WorkflowExecution, type WorkflowInput, type WorkflowSummary, type WorkflowsModule, appAccessTokenPath, createAgentConnectionsModule, createAgentCredentialsModule, createAgentTaskSessionManager, createAgentTasksModule, createAgentsModule, createAppsModule, createAuthModule, createContextModule, createCustomQueriesModule, createDataSourcesModule, createEntitiesModule, createFunctionsAdminModule, createFunctionsModule, createImportsModule, createIntegrationAdminModule, createIntegrationModule, createIntegrationResourcesModule, createIntegrationTemplatesModule, createMembersModule, createMessengerModule, createPublicFunctionsModule, createQueriesModule, createSchemaModule, createSdkCore, createSqlModule, createWorkflowsModule, defaultSdkCoreErrorFactory, encodePathSegment, expectEmpty, expectLegacyPage, expectNullableObject, expectObject, expectObjectArray, expectPage, expectStringArray, isWorkspaceSession, readTokenAppId, readTokenExpiry, resolveApiKeyToken, toAgentTimelineItem, tokenAuthorizesApp, withAgentTaskSessions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1118,6 +1118,33 @@ interface CredentialStatus {
|
|
|
1118
1118
|
accountEmail: string | null;
|
|
1119
1119
|
maskedApiKey: string | null;
|
|
1120
1120
|
}
|
|
1121
|
+
/** One window of a provider subscription. `resetsAt` and `windowSeconds` are null when the harness did not state them. */
|
|
1122
|
+
interface CredentialUsageWindow {
|
|
1123
|
+
/**
|
|
1124
|
+
* Stable name in UPPER_SNAKE: FIVE_HOUR, WEEKLY, WEEKLY_OPUS, or the provider's own. A Codex
|
|
1125
|
+
* bucket other than the account's own carries its limit id as a suffix (FIVE_HOUR_GPT_5_5_PRO).
|
|
1126
|
+
*/
|
|
1127
|
+
kind: string;
|
|
1128
|
+
/** Share of the window already consumed, 0 to 100. */
|
|
1129
|
+
usedPercent: number;
|
|
1130
|
+
/** ISO instant the window resets. */
|
|
1131
|
+
resetsAt: string | null;
|
|
1132
|
+
windowSeconds: number | null;
|
|
1133
|
+
}
|
|
1134
|
+
/**
|
|
1135
|
+
* Every window of a provider subscription as chats on that credential last reported it, with the
|
|
1136
|
+
* provider's own status (Claude: `allowed`, `allowed_warning` or `rejected`; Codex: the limit it
|
|
1137
|
+
* says was reached, or null). Claude reports every window at once. Codex reports only what changed,
|
|
1138
|
+
* so each of its windows is the last one reported for that kind, a window past its reset is dropped,
|
|
1139
|
+
* and the status is the one of the last event, whichever bucket sent it.
|
|
1140
|
+
*/
|
|
1141
|
+
interface CredentialUsage {
|
|
1142
|
+
harness: "claude" | "codex" | (string & {});
|
|
1143
|
+
/** ISO instant the harness reported this reading. */
|
|
1144
|
+
observedAt: string;
|
|
1145
|
+
status: string | null;
|
|
1146
|
+
windows: CredentialUsageWindow[];
|
|
1147
|
+
}
|
|
1121
1148
|
interface OAuthStartResult {
|
|
1122
1149
|
authUrl: string;
|
|
1123
1150
|
state: string;
|
|
@@ -1206,6 +1233,11 @@ interface AgentConnectionsModule {
|
|
|
1206
1233
|
/** Lists app connections with safe per-provider status and no credentials. */
|
|
1207
1234
|
list(): Promise<AgentConnection[]>;
|
|
1208
1235
|
get(id: string): Promise<AgentConnection>;
|
|
1236
|
+
/**
|
|
1237
|
+
* The last subscription window a chat on this connection's provider login reported. Null until
|
|
1238
|
+
* one has.
|
|
1239
|
+
*/
|
|
1240
|
+
usage(id: string, provider: CopilotProvider): Promise<CredentialUsage | null>;
|
|
1209
1241
|
/** Creates an unauthenticated provider container. */
|
|
1210
1242
|
create(name: string): Promise<AgentConnection>;
|
|
1211
1243
|
/**
|
|
@@ -1240,6 +1272,12 @@ interface AgentCredentialsModule {
|
|
|
1240
1272
|
list(options?: AgentCredentialOptions): Promise<CredentialStatus[]>;
|
|
1241
1273
|
/** Lists models backed by a usable credential, optionally through a business agent connection. */
|
|
1242
1274
|
listModels(agentId?: string, options?: AgentCredentialOptions): Promise<AgentModel[]>;
|
|
1275
|
+
/**
|
|
1276
|
+
* The last subscription window a chat on this credential reported, readable with no chat open.
|
|
1277
|
+
* Resolves to null until a turn on the provider's subscription login has reported one; an API
|
|
1278
|
+
* key never has a window.
|
|
1279
|
+
*/
|
|
1280
|
+
usage(provider: CopilotProvider, options?: AgentCredentialOptions): Promise<CredentialUsage | null>;
|
|
1243
1281
|
/** Validates and stores a write-only API key. */
|
|
1244
1282
|
saveApiKey(provider: CopilotProvider, apiKey: string, options?: AgentCredentialOptions): Promise<void>;
|
|
1245
1283
|
/** Permanently removes the current credential for a provider. */
|
|
@@ -1953,8 +1991,17 @@ interface AgentTaskSessionEventMap {
|
|
|
1953
1991
|
code?: string;
|
|
1954
1992
|
error: string;
|
|
1955
1993
|
};
|
|
1994
|
+
/**
|
|
1995
|
+
* The subscription window the chat's harness reported during a turn. It comes only on the
|
|
1996
|
+
* direct channel of a business agent chat, and only when the turn runs on the person's or the
|
|
1997
|
+
* connection's own login; the Copilot stream a chat falls back to never carries it. The Copilot
|
|
1998
|
+
* keeps the last reading, which `agentCredentials.usage` reads with no chat open.
|
|
1999
|
+
*/
|
|
2000
|
+
providerUsage: AgentProviderUsage;
|
|
1956
2001
|
raw: AgentTaskEvent;
|
|
1957
2002
|
}
|
|
2003
|
+
/** The same shape `agentCredentials.usage` answers with. */
|
|
2004
|
+
type AgentProviderUsage = CredentialUsage;
|
|
1958
2005
|
interface AgentTaskSession {
|
|
1959
2006
|
readonly taskId: string | null;
|
|
1960
2007
|
readonly task: AgentTask | null;
|
|
@@ -2044,4 +2091,4 @@ declare function expectPage<T extends object>(value: unknown, context: string, e
|
|
|
2044
2091
|
declare function expectLegacyPage<T extends object>(value: unknown, context: string, errors?: SdkCoreErrorFactory, validateItem?: (value: unknown, context: string, errors: SdkCoreErrorFactory) => T): LegacyPage<T>;
|
|
2045
2092
|
declare function expectEmpty(value: unknown, context: string, errors?: SdkCoreErrorFactory): void;
|
|
2046
2093
|
|
|
2047
|
-
export { API_KEY_EXCHANGE_PATH, type AgentBulkDeleteResult, type AgentConnection, type AgentConnectionCreateInput, type AgentConnectionCustomProvider, type AgentConnectionCustomProviderInput, type AgentConnectionsModule, type AgentCredentialOptions, type AgentCredentialScope, type AgentCredentialsModule, type AgentDefinition, type AgentDirectChannelOptions, type AgentFetch, type AgentFetchResponse, type AgentInput, type AgentMessage, type AgentModel, type AgentQueueItem, type AgentSendAndWaitOptions, type AgentSendOptions, type AgentSessionTransport, type AgentTask, type AgentTaskChannel, type AgentTaskCreateInput, type AgentTaskEvent, type AgentTaskEventConnection, type AgentTaskEventObserver, type AgentTaskEventSource, type AgentTaskInput, type AgentTaskListOptions, type AgentTaskRuntime, type AgentTaskSession, type AgentTaskSessionEventMap, type AgentTaskSessionManager, type AgentTaskSessionManagerOptions, type AgentTaskSessionOptions, type AgentTaskSessionStatus, AgentTaskTurnError, type AgentTasksModule, type AgentTasksWithSessions, type AgentTimelineItem, type AgentToolEvent, type AgentTurnResult, type AgentUpdateItem, type AgentWebSocket, type AgentWebSocketConstructor, type AgentsModule, type ApiKeyExchangeCaller, type AppColor, type AppContext, type AppCreateInput, type AppDefinition, type AppDeploy, type AppDomain, type AppFiles, type AppGetOptions, type AppListOptions, type AppMember, type AppPublishOptions, type AppSummary, type AppUpdateInput, type AppVersion, type AppVersionStatus, type AppsModule, type AuthModule, type AuthenticationResult, type BatchExecution, type BatchStatementResult, type BulkUnsubscribeResult, type ColumnInput, type ConnectionConfig, type ConnectionConfigResponse, type ConnectionTestResult, type ContextModule, type ContextModuleDependencies, type CopilotProvider, type CredentialStatus, type CustomQueriesModule, type CustomQueryDefinition, type CustomQueryInput, type CustomQuerySummary, type CustomQueryUpdateInput, type DataSourceBulkItemResult, type DataSourceBulkResult, type DataSourceCreateInput, type DataSourceDbType, type DataSourceDefinition, type DataSourceInstanceType, type DataSourceUpdateInput, type DataSourcesModule, type DdlStatement, type DeviceAuthorization, type DmlStatement, type EmptyFunctionInput, type EntitiesModule, type EntitiesProxy, type EntityListOptions, type EntityListResponse, type EntityTable, type ExistingAgentTaskSessionOptions, type FunctionBulkCreateInput, type FunctionBulkDeleteInput, type FunctionBulkDeleteResult, type FunctionBulkPatchInput, type FunctionBulkPatchItem, type FunctionBulkUpdateItem, type FunctionCreateInput, type FunctionDefinition, type FunctionExecution, type FunctionListOptions, type FunctionPatchInput, type FunctionRuntime, type FunctionSecrets, type FunctionSummary, type FunctionUpdateInput, type FunctionVersion, type FunctionVersionListOptions, type FunctionVisibility, type FunctionsAdminModule, type FunctionsModule, type FunctionsModuleOptions, type HttpMethod, type ImportColumnMapping, type ImportDefinition, type ImportExecution, type ImportExecutionListOptions, type ImportInput, type ImportProcessing, type ImportSchedule, type ImportSource, type ImportSourceResponse, type ImportTarget, type ImportsModule, type IntegrationAdminModule, type IntegrationConnectionStatus, type IntegrationCredentialRule, type IntegrationExecution, type IntegrationFieldSchema, type IntegrationFieldSchemaInput, type IntegrationLoginConfig, type IntegrationModule, type IntegrationProxyMode, type IntegrationRequestConfig, type IntegrationResource, type IntegrationResourceInput, type IntegrationResourceParam, type IntegrationResourceSummary, type IntegrationResourceUpdateInput, type IntegrationResourcesModule, type IntegrationTemplate, type IntegrationTemplateSummary, type IntegrationTemplateType, type IntegrationTemplatesModule, type IntegrationTokenExtraction, type InviteAppUserInput, type InvocationType, type JsonValue, type LegacyPage, type ListTablesOptions, type ListTemplateConfigsOptions, type MembersModule, type MessageAccepted, type MessengerModule, type NewAgentTaskSessionOptions, type OAuthExchangeInput, type OAuthStartResult, type Page, type PageOptions, type PlanPrice, type ProviderCredentialStatus, type ProxyInput, type ProxyResult, type PublicFunctionAsyncResult, type PublicFunctionResult, type PublicFunctionsModule, type QueriesModule, type QueryParamPrimitive, type QueryParamValue, type QueryResult, type SchemaModule, type SchemaScope, type SchemaTables, type SdkCore, SdkCoreConfigurationError, type SdkCoreErrorFactory, type SdkCoreOptions, SdkCoreResponseError, type SdkCoreTransports, type SqlModule, type TableColumn, type TableDefinition, type TableForeignKey, type TemplateConfig, type TemplateConfigBulkItemResult, type TemplateConfigBulkResult, type TemplateConfigCreateInput, type TemplateConfigPage, type TemplateConfigSummary, type TemplateConfigUpdateInput, type Tenant, type TestCredentialsInput, type Transport, type TransportRequestOptions, type User, type UserPlan, type WorkflowDefinition, type WorkflowExecution, type WorkflowInput, type WorkflowSummary, type WorkflowsModule, appAccessTokenPath, createAgentConnectionsModule, createAgentCredentialsModule, createAgentTaskSessionManager, createAgentTasksModule, createAgentsModule, createAppsModule, createAuthModule, createContextModule, createCustomQueriesModule, createDataSourcesModule, createEntitiesModule, createFunctionsAdminModule, createFunctionsModule, createImportsModule, createIntegrationAdminModule, createIntegrationModule, createIntegrationResourcesModule, createIntegrationTemplatesModule, createMembersModule, createMessengerModule, createPublicFunctionsModule, createQueriesModule, createSchemaModule, createSdkCore, createSqlModule, createWorkflowsModule, defaultSdkCoreErrorFactory, encodePathSegment, expectEmpty, expectLegacyPage, expectNullableObject, expectObject, expectObjectArray, expectPage, expectStringArray, isWorkspaceSession, readTokenAppId, readTokenExpiry, resolveApiKeyToken, toAgentTimelineItem, tokenAuthorizesApp, withAgentTaskSessions };
|
|
2094
|
+
export { API_KEY_EXCHANGE_PATH, type AgentBulkDeleteResult, type AgentConnection, type AgentConnectionCreateInput, type AgentConnectionCustomProvider, type AgentConnectionCustomProviderInput, type AgentConnectionsModule, type AgentCredentialOptions, type AgentCredentialScope, type AgentCredentialsModule, type AgentDefinition, type AgentDirectChannelOptions, type AgentFetch, type AgentFetchResponse, type AgentInput, type AgentMessage, type AgentModel, type AgentProviderUsage, type AgentQueueItem, type AgentSendAndWaitOptions, type AgentSendOptions, type AgentSessionTransport, type AgentTask, type AgentTaskChannel, type AgentTaskCreateInput, type AgentTaskEvent, type AgentTaskEventConnection, type AgentTaskEventObserver, type AgentTaskEventSource, type AgentTaskInput, type AgentTaskListOptions, type AgentTaskRuntime, type AgentTaskSession, type AgentTaskSessionEventMap, type AgentTaskSessionManager, type AgentTaskSessionManagerOptions, type AgentTaskSessionOptions, type AgentTaskSessionStatus, AgentTaskTurnError, type AgentTasksModule, type AgentTasksWithSessions, type AgentTimelineItem, type AgentToolEvent, type AgentTurnResult, type AgentUpdateItem, type AgentWebSocket, type AgentWebSocketConstructor, type AgentsModule, type ApiKeyExchangeCaller, type AppColor, type AppContext, type AppCreateInput, type AppDefinition, type AppDeploy, type AppDomain, type AppFiles, type AppGetOptions, type AppListOptions, type AppMember, type AppPublishOptions, type AppSummary, type AppUpdateInput, type AppVersion, type AppVersionStatus, type AppsModule, type AuthModule, type AuthenticationResult, type BatchExecution, type BatchStatementResult, type BulkUnsubscribeResult, type ColumnInput, type ConnectionConfig, type ConnectionConfigResponse, type ConnectionTestResult, type ContextModule, type ContextModuleDependencies, type CopilotProvider, type CredentialStatus, type CredentialUsage, type CredentialUsageWindow, type CustomQueriesModule, type CustomQueryDefinition, type CustomQueryInput, type CustomQuerySummary, type CustomQueryUpdateInput, type DataSourceBulkItemResult, type DataSourceBulkResult, type DataSourceCreateInput, type DataSourceDbType, type DataSourceDefinition, type DataSourceInstanceType, type DataSourceUpdateInput, type DataSourcesModule, type DdlStatement, type DeviceAuthorization, type DmlStatement, type EmptyFunctionInput, type EntitiesModule, type EntitiesProxy, type EntityListOptions, type EntityListResponse, type EntityTable, type ExistingAgentTaskSessionOptions, type FunctionBulkCreateInput, type FunctionBulkDeleteInput, type FunctionBulkDeleteResult, type FunctionBulkPatchInput, type FunctionBulkPatchItem, type FunctionBulkUpdateItem, type FunctionCreateInput, type FunctionDefinition, type FunctionExecution, type FunctionListOptions, type FunctionPatchInput, type FunctionRuntime, type FunctionSecrets, type FunctionSummary, type FunctionUpdateInput, type FunctionVersion, type FunctionVersionListOptions, type FunctionVisibility, type FunctionsAdminModule, type FunctionsModule, type FunctionsModuleOptions, type HttpMethod, type ImportColumnMapping, type ImportDefinition, type ImportExecution, type ImportExecutionListOptions, type ImportInput, type ImportProcessing, type ImportSchedule, type ImportSource, type ImportSourceResponse, type ImportTarget, type ImportsModule, type IntegrationAdminModule, type IntegrationConnectionStatus, type IntegrationCredentialRule, type IntegrationExecution, type IntegrationFieldSchema, type IntegrationFieldSchemaInput, type IntegrationLoginConfig, type IntegrationModule, type IntegrationProxyMode, type IntegrationRequestConfig, type IntegrationResource, type IntegrationResourceInput, type IntegrationResourceParam, type IntegrationResourceSummary, type IntegrationResourceUpdateInput, type IntegrationResourcesModule, type IntegrationTemplate, type IntegrationTemplateSummary, type IntegrationTemplateType, type IntegrationTemplatesModule, type IntegrationTokenExtraction, type InviteAppUserInput, type InvocationType, type JsonValue, type LegacyPage, type ListTablesOptions, type ListTemplateConfigsOptions, type MembersModule, type MessageAccepted, type MessengerModule, type NewAgentTaskSessionOptions, type OAuthExchangeInput, type OAuthStartResult, type Page, type PageOptions, type PlanPrice, type ProviderCredentialStatus, type ProxyInput, type ProxyResult, type PublicFunctionAsyncResult, type PublicFunctionResult, type PublicFunctionsModule, type QueriesModule, type QueryParamPrimitive, type QueryParamValue, type QueryResult, type SchemaModule, type SchemaScope, type SchemaTables, type SdkCore, SdkCoreConfigurationError, type SdkCoreErrorFactory, type SdkCoreOptions, SdkCoreResponseError, type SdkCoreTransports, type SqlModule, type TableColumn, type TableDefinition, type TableForeignKey, type TemplateConfig, type TemplateConfigBulkItemResult, type TemplateConfigBulkResult, type TemplateConfigCreateInput, type TemplateConfigPage, type TemplateConfigSummary, type TemplateConfigUpdateInput, type Tenant, type TestCredentialsInput, type Transport, type TransportRequestOptions, type User, type UserPlan, type WorkflowDefinition, type WorkflowExecution, type WorkflowInput, type WorkflowSummary, type WorkflowsModule, appAccessTokenPath, createAgentConnectionsModule, createAgentCredentialsModule, createAgentTaskSessionManager, createAgentTasksModule, createAgentsModule, createAppsModule, createAuthModule, createContextModule, createCustomQueriesModule, createDataSourcesModule, createEntitiesModule, createFunctionsAdminModule, createFunctionsModule, createImportsModule, createIntegrationAdminModule, createIntegrationModule, createIntegrationResourcesModule, createIntegrationTemplatesModule, createMembersModule, createMessengerModule, createPublicFunctionsModule, createQueriesModule, createSchemaModule, createSdkCore, createSqlModule, createWorkflowsModule, defaultSdkCoreErrorFactory, encodePathSegment, expectEmpty, expectLegacyPage, expectNullableObject, expectObject, expectObjectArray, expectPage, expectStringArray, isWorkspaceSession, readTokenAppId, readTokenExpiry, resolveApiKeyToken, toAgentTimelineItem, tokenAuthorizesApp, withAgentTaskSessions };
|
package/dist/index.js
CHANGED
|
@@ -966,6 +966,34 @@ function expectCredentialStatus(value, context, errors = defaultSdkCoreErrorFact
|
|
|
966
966
|
}
|
|
967
967
|
return status;
|
|
968
968
|
}
|
|
969
|
+
function expectCredentialUsage(value, context, errors = defaultSdkCoreErrorFactory) {
|
|
970
|
+
const usage = expectObject(value, context, errors);
|
|
971
|
+
if (typeof usage.harness !== "string") invalidField(context, "harness", errors);
|
|
972
|
+
if (typeof usage.observedAt !== "string") invalidField(context, "observedAt", errors);
|
|
973
|
+
if (!isNullableString(usage.status)) invalidField(context, "status", errors);
|
|
974
|
+
if (!Array.isArray(usage.windows)) invalidField(context, "windows", errors);
|
|
975
|
+
for (const window of usage.windows) {
|
|
976
|
+
if (!isObject(window) || typeof window.kind !== "string")
|
|
977
|
+
invalidField(context, "windows.kind", errors);
|
|
978
|
+
if (!isInteger(window.usedPercent)) invalidField(context, "windows.usedPercent", errors);
|
|
979
|
+
if (!isNullableString(window.resetsAt)) invalidField(context, "windows.resetsAt", errors);
|
|
980
|
+
if (window.windowSeconds !== null && !isInteger(window.windowSeconds)) {
|
|
981
|
+
invalidField(context, "windows.windowSeconds", errors);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
return usage;
|
|
985
|
+
}
|
|
986
|
+
var CREDENTIAL_USAGE_NOT_FOUND = "CREDENTIAL_USAGE_NOT_FOUND";
|
|
987
|
+
async function readCredentialUsage(request, context, errors = defaultSdkCoreErrorFactory) {
|
|
988
|
+
let value;
|
|
989
|
+
try {
|
|
990
|
+
value = await request;
|
|
991
|
+
} catch (error) {
|
|
992
|
+
if (error?.code === CREDENTIAL_USAGE_NOT_FOUND) return null;
|
|
993
|
+
throw error;
|
|
994
|
+
}
|
|
995
|
+
return expectCredentialUsage(value, context, errors);
|
|
996
|
+
}
|
|
969
997
|
function expectOAuthStartResult(value, context, errors = defaultSdkCoreErrorFactory) {
|
|
970
998
|
const result = expectObject(value, context, errors);
|
|
971
999
|
if (typeof result.authUrl !== "string") invalidField(context, "authUrl", errors);
|
|
@@ -1096,6 +1124,13 @@ function createAgentConnectionsModule(transport, errors = defaultSdkCoreErrorFac
|
|
|
1096
1124
|
errors
|
|
1097
1125
|
);
|
|
1098
1126
|
},
|
|
1127
|
+
async usage(id, provider) {
|
|
1128
|
+
return readCredentialUsage(
|
|
1129
|
+
transport.request(`${providerPath(id, provider)}/usage`, { method: "GET" }),
|
|
1130
|
+
"Connection usage response",
|
|
1131
|
+
errors
|
|
1132
|
+
);
|
|
1133
|
+
},
|
|
1099
1134
|
async create(name) {
|
|
1100
1135
|
return expectAgentConnection(
|
|
1101
1136
|
await transport.request("/api/v1/connections", {
|
|
@@ -1236,6 +1271,16 @@ function createAgentCredentialsModule(transport, errors = defaultSdkCoreErrorFac
|
|
|
1236
1271
|
expectAgentModel
|
|
1237
1272
|
);
|
|
1238
1273
|
},
|
|
1274
|
+
async usage(provider, options) {
|
|
1275
|
+
return readCredentialUsage(
|
|
1276
|
+
transport.request(`/api/v1/credentials/${providerSegment(provider)}/usage`, {
|
|
1277
|
+
method: "GET",
|
|
1278
|
+
...scopeParams(options)
|
|
1279
|
+
}),
|
|
1280
|
+
"Credential usage response",
|
|
1281
|
+
errors
|
|
1282
|
+
);
|
|
1283
|
+
},
|
|
1239
1284
|
async saveApiKey(provider, apiKey, options) {
|
|
1240
1285
|
expectEmpty(
|
|
1241
1286
|
await transport.request(
|
|
@@ -3805,6 +3850,15 @@ var AgentDirectChannel = class {
|
|
|
3805
3850
|
var AGENT_QUEUE_LIMIT = 10;
|
|
3806
3851
|
var CANCEL_SAFETY_MS = 1e4;
|
|
3807
3852
|
var RECONCILE_DELAY_MS = 1e3;
|
|
3853
|
+
function providerUsageOf(payload) {
|
|
3854
|
+
if (!payload) return null;
|
|
3855
|
+
try {
|
|
3856
|
+
const { harness, observedAt, status, windows } = expectCredentialUsage(payload, "providerUsage");
|
|
3857
|
+
return { harness, observedAt, status, windows };
|
|
3858
|
+
} catch {
|
|
3859
|
+
return null;
|
|
3860
|
+
}
|
|
3861
|
+
}
|
|
3808
3862
|
function asObject2(value) {
|
|
3809
3863
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
3810
3864
|
}
|
|
@@ -4258,6 +4312,11 @@ var CoreAgentTaskSession = class {
|
|
|
4258
4312
|
case "workspace":
|
|
4259
4313
|
this.emit("workspace", { payload: event.payload, timestamp: event.timestamp });
|
|
4260
4314
|
break;
|
|
4315
|
+
case "providerUsage": {
|
|
4316
|
+
const usage = providerUsageOf(payload);
|
|
4317
|
+
if (usage) this.emit("providerUsage", usage);
|
|
4318
|
+
break;
|
|
4319
|
+
}
|
|
4261
4320
|
case "stepFinish": {
|
|
4262
4321
|
const reason = typeof payload?.reason === "string" ? payload.reason : "unknown";
|
|
4263
4322
|
const lifecycle = payload?.lifecycle;
|