@thinkai/tai-api-contract 2.239.0 → 2.241.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.
@@ -242,6 +242,27 @@ export interface paths {
242
242
  patch?: never;
243
243
  trace?: never;
244
244
  };
245
+ "/admin/ecg-platform-cost/summary": {
246
+ parameters: {
247
+ query?: never;
248
+ header?: never;
249
+ path?: never;
250
+ cookie?: never;
251
+ };
252
+ /**
253
+ * ECG spend on ThinkAI-held keys (embeddings, rerank) by workspace
254
+ * @description Rolls up embedding and rerank usage that ThinkAI pays for (the platform keys, not the workspace's own model key) for the given UTC range, defaulting to the current UTC calendar month. Tokens are what the provider reported; calls where it reported nothing are estimated from the characters sent and counted in `estimatedCalls`. `byWorkspace` lists the highest-spending workspaces up to `workspaceLimit`; `otherWorkspaces` is the remainder, so the rows shown plus `otherWorkspaces` always equal `totals`. A deleted workspace's spend is kept and reported with a null workspace.
255
+ * **Authorization:** Bearer JWT required. Caller email must appear in `PLATFORM_ADMIN_EMAILS`. This is ThinkAI's cost and is never returned to workspace members.
256
+ */
257
+ get: operations["adminGetEcgPlatformCostSummary"];
258
+ put?: never;
259
+ post?: never;
260
+ delete?: never;
261
+ options?: never;
262
+ head?: never;
263
+ patch?: never;
264
+ trace?: never;
265
+ };
245
266
  "/admin/workspaces/{workspaceId}/automation-cost/budget": {
246
267
  parameters: {
247
268
  query?: never;
@@ -13090,6 +13111,45 @@ export interface components {
13090
13111
  estimatedSpendCents: number;
13091
13112
  invocationCount: number;
13092
13113
  };
13114
+ PlatformEcgSpendBucketDto: {
13115
+ /** Format: int64 */
13116
+ calls: number;
13117
+ /** Format: int64 */
13118
+ tokens: number;
13119
+ /**
13120
+ * Format: int64
13121
+ * @description Calls whose token count was estimated because the provider reported none.
13122
+ */
13123
+ estimatedCalls: number;
13124
+ };
13125
+ PlatformEcgSpendSummaryDto: {
13126
+ /** Format: date-time */
13127
+ from: string;
13128
+ /** Format: date-time */
13129
+ to: string;
13130
+ totals: components["schemas"]["PlatformEcgSpendBucketDto"];
13131
+ byKind: (components["schemas"]["PlatformEcgSpendBucketDto"] & {
13132
+ /** @enum {string} */
13133
+ kind: "embed" | "rerank";
13134
+ })[];
13135
+ byChannel: (components["schemas"]["PlatformEcgSpendBucketDto"] & {
13136
+ /** @enum {string} */
13137
+ channel: "web_chat" | "mcp" | "background";
13138
+ })[];
13139
+ /** @description Highest token spend first, at most `workspaceLimit` rows. */
13140
+ byWorkspace: (components["schemas"]["PlatformEcgSpendBucketDto"] & {
13141
+ /**
13142
+ * Format: uuid
13143
+ * @description Null for spend of a workspace that has since been deleted.
13144
+ */
13145
+ workspaceId: string | null;
13146
+ workspaceName: string | null;
13147
+ })[];
13148
+ /** @description Spend of the workspaces not listed in `byWorkspace`. */
13149
+ otherWorkspaces: components["schemas"]["PlatformEcgSpendBucketDto"] & {
13150
+ count: number;
13151
+ };
13152
+ };
13093
13153
  AutomationCostSummaryDto: {
13094
13154
  rows: components["schemas"]["AutomationCostSummaryRowDto"][];
13095
13155
  totals: components["schemas"]["AutomationCostSummaryTotalsDto"];
@@ -14497,7 +14557,7 @@ export interface components {
14497
14557
  workspaceContext?: components["schemas"]["WorkspaceContextInsightsDto"];
14498
14558
  };
14499
14559
  CodeIntelligenceUsageDto: {
14500
- /** @description Ledger operation key (code_chat, prd_generate, workspace_kb, wiki, …). Older rows may still say wiki_enrich or wiki_json_outline; clients collapse those into Wiki. */
14560
+ /** @description Ledger operation key (code_chat, mcp_ask, workspace_wiki, prd_generate, workspace_kb, wiki, …). Older rows may still say wiki_enrich or wiki_json_outline; clients collapse those into Wiki. */
14501
14561
  operation: string;
14502
14562
  provider: string;
14503
14563
  model?: string | null;
@@ -14513,6 +14573,17 @@ export interface components {
14513
14573
  estimatedCostUsd: number;
14514
14574
  invocationCount: number;
14515
14575
  };
14576
+ CodeIntelligenceTokenUsageByChannelDto: {
14577
+ /**
14578
+ * @description Surface that spent the tokens: the web app, the hosted MCP endpoint, or a background index or wiki job. `unattributed` holds rows recorded before channels existed.
14579
+ * @enum {string}
14580
+ */
14581
+ channel: "web_chat" | "mcp" | "background" | "unattributed";
14582
+ inputTokens: number;
14583
+ outputTokens: number;
14584
+ estimatedCostUsd: number;
14585
+ invocationCount: number;
14586
+ };
14516
14587
  CodeIntelligenceTokenUsageByRepoDto: {
14517
14588
  /** Format: uuid */
14518
14589
  repoId: string;
@@ -14549,6 +14620,8 @@ export interface components {
14549
14620
  /** @description Rate basis used for the derived cost, for display in tooltips. */
14550
14621
  costBasis?: string | null;
14551
14622
  byOperation: components["schemas"]["CodeIntelligenceTokenUsageByOperationDto"][];
14623
+ /** @description The same total as `byOperation`, split by the surface that spent it. Absent on older servers. */
14624
+ byChannel?: components["schemas"]["CodeIntelligenceTokenUsageByChannelDto"][];
14552
14625
  /** @description Per-repository split (wiki generation, conversations, outline). Calls that were not about a single repository use an empty repoId and a null repoName. */
14553
14626
  byRepo: components["schemas"]["CodeIntelligenceTokenUsageByRepoDto"][];
14554
14627
  };
@@ -16236,6 +16309,8 @@ export type ActivityLogPageDto = components['schemas']['ActivityLogPageDto'];
16236
16309
  export type AutomationCostOperationDto = components['schemas']['AutomationCostOperationDto'];
16237
16310
  export type AutomationCostSummaryRowDto = components['schemas']['AutomationCostSummaryRowDto'];
16238
16311
  export type AutomationCostSummaryTotalsDto = components['schemas']['AutomationCostSummaryTotalsDto'];
16312
+ export type PlatformEcgSpendBucketDto = components['schemas']['PlatformEcgSpendBucketDto'];
16313
+ export type PlatformEcgSpendSummaryDto = components['schemas']['PlatformEcgSpendSummaryDto'];
16239
16314
  export type AutomationCostSummaryDto = components['schemas']['AutomationCostSummaryDto'];
16240
16315
  export type AutomationCostBudgetStatusDto = components['schemas']['AutomationCostBudgetStatusDto'];
16241
16316
  export type AutomationCostBudgetViewDto = components['schemas']['AutomationCostBudgetViewDto'];
@@ -16379,6 +16454,7 @@ export type WorkspaceKnowledgePackPageDto = components['schemas']['WorkspaceKnow
16379
16454
  export type WorkspaceKnowledgePackDto = components['schemas']['WorkspaceKnowledgePackDto'];
16380
16455
  export type CodeIntelligenceUsageDto = components['schemas']['CodeIntelligenceUsageDto'];
16381
16456
  export type CodeIntelligenceTokenUsageByOperationDto = components['schemas']['CodeIntelligenceTokenUsageByOperationDto'];
16457
+ export type CodeIntelligenceTokenUsageByChannelDto = components['schemas']['CodeIntelligenceTokenUsageByChannelDto'];
16382
16458
  export type CodeIntelligenceTokenUsageByRepoDto = components['schemas']['CodeIntelligenceTokenUsageByRepoDto'];
16383
16459
  export type CodeIntelligenceTokenUsageRunDto = components['schemas']['CodeIntelligenceTokenUsageRunDto'];
16384
16460
  export type CodeIntelligenceTokenUsageSummaryDto = components['schemas']['CodeIntelligenceTokenUsageSummaryDto'];
@@ -17374,6 +17450,75 @@ export interface operations {
17374
17450
  };
17375
17451
  };
17376
17452
  };
17453
+ adminGetEcgPlatformCostSummary: {
17454
+ parameters: {
17455
+ query?: {
17456
+ /** @description Inclusive start (ISO-8601). Defaults to start of current UTC month. */
17457
+ from?: string;
17458
+ /** @description Exclusive end (ISO-8601). Defaults to end of current UTC month. The window may span at most 366 days. */
17459
+ to?: string;
17460
+ /** @description How many workspaces to list in `byWorkspace`. */
17461
+ workspaceLimit?: number;
17462
+ };
17463
+ header?: never;
17464
+ path?: never;
17465
+ cookie?: never;
17466
+ };
17467
+ requestBody?: never;
17468
+ responses: {
17469
+ /** @description Totals and splits (zeros and empty lists when nothing was spent). */
17470
+ 200: {
17471
+ headers: {
17472
+ [name: string]: unknown;
17473
+ };
17474
+ content: {
17475
+ "application/json": components["schemas"]["PlatformEcgSpendSummaryDto"];
17476
+ };
17477
+ };
17478
+ /** @description Unparseable date, backwards or over-wide window, or `workspaceLimit` out of range. */
17479
+ 400: {
17480
+ headers: {
17481
+ [name: string]: unknown;
17482
+ };
17483
+ content: {
17484
+ "application/json": components["schemas"]["ErrorMessageDto"];
17485
+ };
17486
+ };
17487
+ /** @description Missing or invalid JWT. */
17488
+ 401: {
17489
+ headers: {
17490
+ [name: string]: unknown;
17491
+ };
17492
+ content: {
17493
+ "application/json": components["schemas"]["ErrorMessageDto"];
17494
+ };
17495
+ };
17496
+ /** @description Caller is not a platform admin. */
17497
+ 403: {
17498
+ headers: {
17499
+ [name: string]: unknown;
17500
+ };
17501
+ content: {
17502
+ /**
17503
+ * @example {
17504
+ * "error": "Forbidden",
17505
+ * "code": "forbidden"
17506
+ * }
17507
+ */
17508
+ "application/json": components["schemas"]["ErrorMessageDto"];
17509
+ };
17510
+ };
17511
+ /** @description The batch database (`READINESS_DATABASE_URL`) is not configured on this API instance. */
17512
+ 503: {
17513
+ headers: {
17514
+ [name: string]: unknown;
17515
+ };
17516
+ content: {
17517
+ "application/json": components["schemas"]["ErrorMessageDto"];
17518
+ };
17519
+ };
17520
+ };
17521
+ };
17377
17522
  adminGetAutomationCostBudget: {
17378
17523
  parameters: {
17379
17524
  query?: {