@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.
@@ -1,7 +1,7 @@
1
1
  openapi: 3.0.3
2
2
  info:
3
3
  title: ThinkAI API
4
- version: 2.239.0
4
+ version: 2.241.0
5
5
  description: >
6
6
  Contract surface for the AI Driven SDLC backend used by ThinkAI.
7
7
  Workspace-scoped routes use `/workspaces/{workspaceId}/...`.
@@ -1141,6 +1141,81 @@ paths:
1141
1141
  error: Forbidden
1142
1142
  code: forbidden
1143
1143
 
1144
+ /admin/ecg-platform-cost/summary:
1145
+ get:
1146
+ tags: [PlatformAdmin]
1147
+ summary: ECG spend on ThinkAI-held keys (embeddings, rerank) by workspace
1148
+ operationId: adminGetEcgPlatformCostSummary
1149
+ description: >
1150
+ Rolls up embedding and rerank usage that ThinkAI pays for (the platform keys, not the
1151
+ workspace's own model key) for the given UTC range, defaulting to the current UTC
1152
+ calendar month. Tokens are what the provider reported; calls where it reported nothing
1153
+ are estimated from the characters sent and counted in `estimatedCalls`.
1154
+ `byWorkspace` lists the highest-spending workspaces up to `workspaceLimit`;
1155
+ `otherWorkspaces` is the remainder, so the rows shown plus `otherWorkspaces` always
1156
+ equal `totals`. A deleted workspace's spend is kept and reported with a null workspace.
1157
+
1158
+ **Authorization:** Bearer JWT required. Caller email must appear in `PLATFORM_ADMIN_EMAILS`.
1159
+ This is ThinkAI's cost and is never returned to workspace members.
1160
+ parameters:
1161
+ - name: from
1162
+ in: query
1163
+ required: false
1164
+ schema:
1165
+ type: string
1166
+ format: date-time
1167
+ description: Inclusive start (ISO-8601). Defaults to start of current UTC month.
1168
+ - name: to
1169
+ in: query
1170
+ required: false
1171
+ schema:
1172
+ type: string
1173
+ format: date-time
1174
+ description: Exclusive end (ISO-8601). Defaults to end of current UTC month. The window may span at most 366 days.
1175
+ - name: workspaceLimit
1176
+ in: query
1177
+ required: false
1178
+ schema:
1179
+ type: integer
1180
+ minimum: 1
1181
+ maximum: 100
1182
+ default: 25
1183
+ description: How many workspaces to list in `byWorkspace`.
1184
+ responses:
1185
+ "200":
1186
+ description: Totals and splits (zeros and empty lists when nothing was spent).
1187
+ content:
1188
+ application/json:
1189
+ schema:
1190
+ $ref: "#/components/schemas/PlatformEcgSpendSummaryDto"
1191
+ "400":
1192
+ description: Unparseable date, backwards or over-wide window, or `workspaceLimit` out of range.
1193
+ content:
1194
+ application/json:
1195
+ schema:
1196
+ $ref: "#/components/schemas/ErrorMessageDto"
1197
+ "401":
1198
+ description: Missing or invalid JWT.
1199
+ content:
1200
+ application/json:
1201
+ schema:
1202
+ $ref: "#/components/schemas/ErrorMessageDto"
1203
+ "403":
1204
+ description: Caller is not a platform admin.
1205
+ content:
1206
+ application/json:
1207
+ schema:
1208
+ $ref: "#/components/schemas/ErrorMessageDto"
1209
+ example:
1210
+ error: Forbidden
1211
+ code: forbidden
1212
+ "503":
1213
+ description: The batch database (`READINESS_DATABASE_URL`) is not configured on this API instance.
1214
+ content:
1215
+ application/json:
1216
+ schema:
1217
+ $ref: "#/components/schemas/ErrorMessageDto"
1218
+
1144
1219
  /admin/workspaces/{workspaceId}/automation-cost/budget:
1145
1220
  get:
1146
1221
  tags: [PlatformAdmin]
@@ -31530,6 +31605,82 @@ components:
31530
31605
  invocationCount:
31531
31606
  type: integer
31532
31607
 
31608
+ PlatformEcgSpendBucketDto:
31609
+ type: object
31610
+ required: [calls, tokens, estimatedCalls]
31611
+ properties:
31612
+ calls:
31613
+ type: integer
31614
+ format: int64
31615
+ tokens:
31616
+ type: integer
31617
+ format: int64
31618
+ estimatedCalls:
31619
+ type: integer
31620
+ format: int64
31621
+ description: Calls whose token count was estimated because the provider reported none.
31622
+
31623
+ PlatformEcgSpendSummaryDto:
31624
+ type: object
31625
+ required: [from, to, totals, byKind, byChannel, byWorkspace, otherWorkspaces]
31626
+ properties:
31627
+ from:
31628
+ type: string
31629
+ format: date-time
31630
+ to:
31631
+ type: string
31632
+ format: date-time
31633
+ totals:
31634
+ $ref: "#/components/schemas/PlatformEcgSpendBucketDto"
31635
+ byKind:
31636
+ type: array
31637
+ items:
31638
+ allOf:
31639
+ - $ref: "#/components/schemas/PlatformEcgSpendBucketDto"
31640
+ - type: object
31641
+ required: [kind]
31642
+ properties:
31643
+ kind:
31644
+ type: string
31645
+ enum: [embed, rerank]
31646
+ byChannel:
31647
+ type: array
31648
+ items:
31649
+ allOf:
31650
+ - $ref: "#/components/schemas/PlatformEcgSpendBucketDto"
31651
+ - type: object
31652
+ required: [channel]
31653
+ properties:
31654
+ channel:
31655
+ type: string
31656
+ enum: [web_chat, mcp, background]
31657
+ byWorkspace:
31658
+ type: array
31659
+ description: Highest token spend first, at most `workspaceLimit` rows.
31660
+ items:
31661
+ allOf:
31662
+ - $ref: "#/components/schemas/PlatformEcgSpendBucketDto"
31663
+ - type: object
31664
+ required: [workspaceId, workspaceName]
31665
+ properties:
31666
+ workspaceId:
31667
+ type: string
31668
+ format: uuid
31669
+ nullable: true
31670
+ description: Null for spend of a workspace that has since been deleted.
31671
+ workspaceName:
31672
+ type: string
31673
+ nullable: true
31674
+ otherWorkspaces:
31675
+ description: Spend of the workspaces not listed in `byWorkspace`.
31676
+ allOf:
31677
+ - $ref: "#/components/schemas/PlatformEcgSpendBucketDto"
31678
+ - type: object
31679
+ required: [count]
31680
+ properties:
31681
+ count:
31682
+ type: integer
31683
+
31533
31684
  AutomationCostSummaryDto:
31534
31685
  type: object
31535
31686
  required: [rows, totals]
@@ -34195,7 +34346,7 @@ components:
34195
34346
  properties:
34196
34347
  operation:
34197
34348
  type: string
34198
- 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.
34349
+ 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.
34199
34350
  provider: { type: string }
34200
34351
  model: { type: string, nullable: true }
34201
34352
  inputTokens: { type: integer, minimum: 0 }
@@ -34213,6 +34364,21 @@ components:
34213
34364
  estimatedCostUsd: { type: number }
34214
34365
  invocationCount: { type: integer, minimum: 0 }
34215
34366
 
34367
+ CodeIntelligenceTokenUsageByChannelDto:
34368
+ type: object
34369
+ required: [channel, inputTokens, outputTokens, estimatedCostUsd, invocationCount]
34370
+ properties:
34371
+ channel:
34372
+ type: string
34373
+ enum: [web_chat, mcp, background, unattributed]
34374
+ description: >-
34375
+ Surface that spent the tokens: the web app, the hosted MCP endpoint, or a
34376
+ background index or wiki job. `unattributed` holds rows recorded before channels existed.
34377
+ inputTokens: { type: integer, minimum: 0 }
34378
+ outputTokens: { type: integer, minimum: 0 }
34379
+ estimatedCostUsd: { type: number }
34380
+ invocationCount: { type: integer, minimum: 0 }
34381
+
34216
34382
  CodeIntelligenceTokenUsageByRepoDto:
34217
34383
  type: object
34218
34384
  required:
@@ -34288,6 +34454,11 @@ components:
34288
34454
  byOperation:
34289
34455
  type: array
34290
34456
  items: { $ref: "#/components/schemas/CodeIntelligenceTokenUsageByOperationDto" }
34457
+ byChannel:
34458
+ type: array
34459
+ description: >-
34460
+ The same total as `byOperation`, split by the surface that spent it. Absent on older servers.
34461
+ items: { $ref: "#/components/schemas/CodeIntelligenceTokenUsageByChannelDto" }
34291
34462
  byRepo:
34292
34463
  type: array
34293
34464
  description: >-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkai/tai-api-contract",
3
- "version": "2.239.0",
3
+ "version": "2.241.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -243,6 +243,27 @@ export interface paths {
243
243
  patch?: never;
244
244
  trace?: never;
245
245
  };
246
+ "/admin/ecg-platform-cost/summary": {
247
+ parameters: {
248
+ query?: never;
249
+ header?: never;
250
+ path?: never;
251
+ cookie?: never;
252
+ };
253
+ /**
254
+ * ECG spend on ThinkAI-held keys (embeddings, rerank) by workspace
255
+ * @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.
256
+ * **Authorization:** Bearer JWT required. Caller email must appear in `PLATFORM_ADMIN_EMAILS`. This is ThinkAI's cost and is never returned to workspace members.
257
+ */
258
+ get: operations["adminGetEcgPlatformCostSummary"];
259
+ put?: never;
260
+ post?: never;
261
+ delete?: never;
262
+ options?: never;
263
+ head?: never;
264
+ patch?: never;
265
+ trace?: never;
266
+ };
246
267
  "/admin/workspaces/{workspaceId}/automation-cost/budget": {
247
268
  parameters: {
248
269
  query?: never;
@@ -13091,6 +13112,45 @@ export interface components {
13091
13112
  estimatedSpendCents: number;
13092
13113
  invocationCount: number;
13093
13114
  };
13115
+ PlatformEcgSpendBucketDto: {
13116
+ /** Format: int64 */
13117
+ calls: number;
13118
+ /** Format: int64 */
13119
+ tokens: number;
13120
+ /**
13121
+ * Format: int64
13122
+ * @description Calls whose token count was estimated because the provider reported none.
13123
+ */
13124
+ estimatedCalls: number;
13125
+ };
13126
+ PlatformEcgSpendSummaryDto: {
13127
+ /** Format: date-time */
13128
+ from: string;
13129
+ /** Format: date-time */
13130
+ to: string;
13131
+ totals: components["schemas"]["PlatformEcgSpendBucketDto"];
13132
+ byKind: (components["schemas"]["PlatformEcgSpendBucketDto"] & {
13133
+ /** @enum {string} */
13134
+ kind: "embed" | "rerank";
13135
+ })[];
13136
+ byChannel: (components["schemas"]["PlatformEcgSpendBucketDto"] & {
13137
+ /** @enum {string} */
13138
+ channel: "web_chat" | "mcp" | "background";
13139
+ })[];
13140
+ /** @description Highest token spend first, at most `workspaceLimit` rows. */
13141
+ byWorkspace: (components["schemas"]["PlatformEcgSpendBucketDto"] & {
13142
+ /**
13143
+ * Format: uuid
13144
+ * @description Null for spend of a workspace that has since been deleted.
13145
+ */
13146
+ workspaceId: string | null;
13147
+ workspaceName: string | null;
13148
+ })[];
13149
+ /** @description Spend of the workspaces not listed in `byWorkspace`. */
13150
+ otherWorkspaces: components["schemas"]["PlatformEcgSpendBucketDto"] & {
13151
+ count: number;
13152
+ };
13153
+ };
13094
13154
  AutomationCostSummaryDto: {
13095
13155
  rows: components["schemas"]["AutomationCostSummaryRowDto"][];
13096
13156
  totals: components["schemas"]["AutomationCostSummaryTotalsDto"];
@@ -14498,7 +14558,7 @@ export interface components {
14498
14558
  workspaceContext?: components["schemas"]["WorkspaceContextInsightsDto"];
14499
14559
  };
14500
14560
  CodeIntelligenceUsageDto: {
14501
- /** @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. */
14561
+ /** @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. */
14502
14562
  operation: string;
14503
14563
  provider: string;
14504
14564
  model?: string | null;
@@ -14514,6 +14574,17 @@ export interface components {
14514
14574
  estimatedCostUsd: number;
14515
14575
  invocationCount: number;
14516
14576
  };
14577
+ CodeIntelligenceTokenUsageByChannelDto: {
14578
+ /**
14579
+ * @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.
14580
+ * @enum {string}
14581
+ */
14582
+ channel: "web_chat" | "mcp" | "background" | "unattributed";
14583
+ inputTokens: number;
14584
+ outputTokens: number;
14585
+ estimatedCostUsd: number;
14586
+ invocationCount: number;
14587
+ };
14517
14588
  CodeIntelligenceTokenUsageByRepoDto: {
14518
14589
  /** Format: uuid */
14519
14590
  repoId: string;
@@ -14550,6 +14621,8 @@ export interface components {
14550
14621
  /** @description Rate basis used for the derived cost, for display in tooltips. */
14551
14622
  costBasis?: string | null;
14552
14623
  byOperation: components["schemas"]["CodeIntelligenceTokenUsageByOperationDto"][];
14624
+ /** @description The same total as `byOperation`, split by the surface that spent it. Absent on older servers. */
14625
+ byChannel?: components["schemas"]["CodeIntelligenceTokenUsageByChannelDto"][];
14553
14626
  /** @description Per-repository split (wiki generation, conversations, outline). Calls that were not about a single repository use an empty repoId and a null repoName. */
14554
14627
  byRepo: components["schemas"]["CodeIntelligenceTokenUsageByRepoDto"][];
14555
14628
  };
@@ -16237,6 +16310,8 @@ export type ActivityLogPageDto = components['schemas']['ActivityLogPageDto'];
16237
16310
  export type AutomationCostOperationDto = components['schemas']['AutomationCostOperationDto'];
16238
16311
  export type AutomationCostSummaryRowDto = components['schemas']['AutomationCostSummaryRowDto'];
16239
16312
  export type AutomationCostSummaryTotalsDto = components['schemas']['AutomationCostSummaryTotalsDto'];
16313
+ export type PlatformEcgSpendBucketDto = components['schemas']['PlatformEcgSpendBucketDto'];
16314
+ export type PlatformEcgSpendSummaryDto = components['schemas']['PlatformEcgSpendSummaryDto'];
16240
16315
  export type AutomationCostSummaryDto = components['schemas']['AutomationCostSummaryDto'];
16241
16316
  export type AutomationCostBudgetStatusDto = components['schemas']['AutomationCostBudgetStatusDto'];
16242
16317
  export type AutomationCostBudgetViewDto = components['schemas']['AutomationCostBudgetViewDto'];
@@ -16380,6 +16455,7 @@ export type WorkspaceKnowledgePackPageDto = components['schemas']['WorkspaceKnow
16380
16455
  export type WorkspaceKnowledgePackDto = components['schemas']['WorkspaceKnowledgePackDto'];
16381
16456
  export type CodeIntelligenceUsageDto = components['schemas']['CodeIntelligenceUsageDto'];
16382
16457
  export type CodeIntelligenceTokenUsageByOperationDto = components['schemas']['CodeIntelligenceTokenUsageByOperationDto'];
16458
+ export type CodeIntelligenceTokenUsageByChannelDto = components['schemas']['CodeIntelligenceTokenUsageByChannelDto'];
16383
16459
  export type CodeIntelligenceTokenUsageByRepoDto = components['schemas']['CodeIntelligenceTokenUsageByRepoDto'];
16384
16460
  export type CodeIntelligenceTokenUsageRunDto = components['schemas']['CodeIntelligenceTokenUsageRunDto'];
16385
16461
  export type CodeIntelligenceTokenUsageSummaryDto = components['schemas']['CodeIntelligenceTokenUsageSummaryDto'];
@@ -17375,6 +17451,75 @@ export interface operations {
17375
17451
  };
17376
17452
  };
17377
17453
  };
17454
+ adminGetEcgPlatformCostSummary: {
17455
+ parameters: {
17456
+ query?: {
17457
+ /** @description Inclusive start (ISO-8601). Defaults to start of current UTC month. */
17458
+ from?: string;
17459
+ /** @description Exclusive end (ISO-8601). Defaults to end of current UTC month. The window may span at most 366 days. */
17460
+ to?: string;
17461
+ /** @description How many workspaces to list in `byWorkspace`. */
17462
+ workspaceLimit?: number;
17463
+ };
17464
+ header?: never;
17465
+ path?: never;
17466
+ cookie?: never;
17467
+ };
17468
+ requestBody?: never;
17469
+ responses: {
17470
+ /** @description Totals and splits (zeros and empty lists when nothing was spent). */
17471
+ 200: {
17472
+ headers: {
17473
+ [name: string]: unknown;
17474
+ };
17475
+ content: {
17476
+ "application/json": components["schemas"]["PlatformEcgSpendSummaryDto"];
17477
+ };
17478
+ };
17479
+ /** @description Unparseable date, backwards or over-wide window, or `workspaceLimit` out of range. */
17480
+ 400: {
17481
+ headers: {
17482
+ [name: string]: unknown;
17483
+ };
17484
+ content: {
17485
+ "application/json": components["schemas"]["ErrorMessageDto"];
17486
+ };
17487
+ };
17488
+ /** @description Missing or invalid JWT. */
17489
+ 401: {
17490
+ headers: {
17491
+ [name: string]: unknown;
17492
+ };
17493
+ content: {
17494
+ "application/json": components["schemas"]["ErrorMessageDto"];
17495
+ };
17496
+ };
17497
+ /** @description Caller is not a platform admin. */
17498
+ 403: {
17499
+ headers: {
17500
+ [name: string]: unknown;
17501
+ };
17502
+ content: {
17503
+ /**
17504
+ * @example {
17505
+ * "error": "Forbidden",
17506
+ * "code": "forbidden"
17507
+ * }
17508
+ */
17509
+ "application/json": components["schemas"]["ErrorMessageDto"];
17510
+ };
17511
+ };
17512
+ /** @description The batch database (`READINESS_DATABASE_URL`) is not configured on this API instance. */
17513
+ 503: {
17514
+ headers: {
17515
+ [name: string]: unknown;
17516
+ };
17517
+ content: {
17518
+ "application/json": components["schemas"]["ErrorMessageDto"];
17519
+ };
17520
+ };
17521
+ };
17522
+ };
17378
17523
  adminGetAutomationCostBudget: {
17379
17524
  parameters: {
17380
17525
  query?: {