@thinkai/tai-api-contract 2.240.0 → 2.242.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.
@@ -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;
@@ -12865,10 +12886,16 @@ export interface components {
12865
12886
  sourceReconcile?: components["schemas"]["IngestCoverageSourceReconcileDto"] | null;
12866
12887
  dataTrust: components["schemas"]["DataTrustDto"];
12867
12888
  };
12889
+ /** @description ADR 006: dirty weeks waiting for repo-week facts to merge into tai_workspace_dashboard_metrics (Insights lag behind ledger fetch). */
12890
+ IngestCoverageMetricsRollupDto: {
12891
+ /** @description Number of workspace weeks with pending metrics rollup. */
12892
+ dirtyWeekCount: number;
12893
+ };
12868
12894
  IngestCoverageDto: {
12869
12895
  pipelines: components["schemas"]["IngestCoveragePipelineDto"][];
12870
12896
  /** Format: date-time */
12871
12897
  generatedAt?: string;
12898
+ metricsRollup?: components["schemas"]["IngestCoverageMetricsRollupDto"] | null;
12872
12899
  };
12873
12900
  IngestRunDto: {
12874
12901
  /** Format: uuid */
@@ -13091,6 +13118,45 @@ export interface components {
13091
13118
  estimatedSpendCents: number;
13092
13119
  invocationCount: number;
13093
13120
  };
13121
+ PlatformEcgSpendBucketDto: {
13122
+ /** Format: int64 */
13123
+ calls: number;
13124
+ /** Format: int64 */
13125
+ tokens: number;
13126
+ /**
13127
+ * Format: int64
13128
+ * @description Calls whose token count was estimated because the provider reported none.
13129
+ */
13130
+ estimatedCalls: number;
13131
+ };
13132
+ PlatformEcgSpendSummaryDto: {
13133
+ /** Format: date-time */
13134
+ from: string;
13135
+ /** Format: date-time */
13136
+ to: string;
13137
+ totals: components["schemas"]["PlatformEcgSpendBucketDto"];
13138
+ byKind: (components["schemas"]["PlatformEcgSpendBucketDto"] & {
13139
+ /** @enum {string} */
13140
+ kind: "embed" | "rerank";
13141
+ })[];
13142
+ byChannel: (components["schemas"]["PlatformEcgSpendBucketDto"] & {
13143
+ /** @enum {string} */
13144
+ channel: "web_chat" | "mcp" | "background";
13145
+ })[];
13146
+ /** @description Highest token spend first, at most `workspaceLimit` rows. */
13147
+ byWorkspace: (components["schemas"]["PlatformEcgSpendBucketDto"] & {
13148
+ /**
13149
+ * Format: uuid
13150
+ * @description Null for spend of a workspace that has since been deleted.
13151
+ */
13152
+ workspaceId: string | null;
13153
+ workspaceName: string | null;
13154
+ })[];
13155
+ /** @description Spend of the workspaces not listed in `byWorkspace`. */
13156
+ otherWorkspaces: components["schemas"]["PlatformEcgSpendBucketDto"] & {
13157
+ count: number;
13158
+ };
13159
+ };
13094
13160
  AutomationCostSummaryDto: {
13095
13161
  rows: components["schemas"]["AutomationCostSummaryRowDto"][];
13096
13162
  totals: components["schemas"]["AutomationCostSummaryTotalsDto"];
@@ -16224,6 +16290,7 @@ export type PutStrictInsightsOnTrustDto = components['schemas']['PutStrictInsigh
16224
16290
  export type InsightsStrictTrustHideNotifyDto = components['schemas']['InsightsStrictTrustHideNotifyDto'];
16225
16291
  export type InsightsStrictTrustHideNotifyResultDto = components['schemas']['InsightsStrictTrustHideNotifyResultDto'];
16226
16292
  export type IngestCoveragePipelineDto = components['schemas']['IngestCoveragePipelineDto'];
16293
+ export type IngestCoverageMetricsRollupDto = components['schemas']['IngestCoverageMetricsRollupDto'];
16227
16294
  export type IngestCoverageDto = components['schemas']['IngestCoverageDto'];
16228
16295
  export type IngestRunDto = components['schemas']['IngestRunDto'];
16229
16296
  export type IngestRunListDto = components['schemas']['IngestRunListDto'];
@@ -16250,6 +16317,8 @@ export type ActivityLogPageDto = components['schemas']['ActivityLogPageDto'];
16250
16317
  export type AutomationCostOperationDto = components['schemas']['AutomationCostOperationDto'];
16251
16318
  export type AutomationCostSummaryRowDto = components['schemas']['AutomationCostSummaryRowDto'];
16252
16319
  export type AutomationCostSummaryTotalsDto = components['schemas']['AutomationCostSummaryTotalsDto'];
16320
+ export type PlatformEcgSpendBucketDto = components['schemas']['PlatformEcgSpendBucketDto'];
16321
+ export type PlatformEcgSpendSummaryDto = components['schemas']['PlatformEcgSpendSummaryDto'];
16253
16322
  export type AutomationCostSummaryDto = components['schemas']['AutomationCostSummaryDto'];
16254
16323
  export type AutomationCostBudgetStatusDto = components['schemas']['AutomationCostBudgetStatusDto'];
16255
16324
  export type AutomationCostBudgetViewDto = components['schemas']['AutomationCostBudgetViewDto'];
@@ -17389,6 +17458,75 @@ export interface operations {
17389
17458
  };
17390
17459
  };
17391
17460
  };
17461
+ adminGetEcgPlatformCostSummary: {
17462
+ parameters: {
17463
+ query?: {
17464
+ /** @description Inclusive start (ISO-8601). Defaults to start of current UTC month. */
17465
+ from?: string;
17466
+ /** @description Exclusive end (ISO-8601). Defaults to end of current UTC month. The window may span at most 366 days. */
17467
+ to?: string;
17468
+ /** @description How many workspaces to list in `byWorkspace`. */
17469
+ workspaceLimit?: number;
17470
+ };
17471
+ header?: never;
17472
+ path?: never;
17473
+ cookie?: never;
17474
+ };
17475
+ requestBody?: never;
17476
+ responses: {
17477
+ /** @description Totals and splits (zeros and empty lists when nothing was spent). */
17478
+ 200: {
17479
+ headers: {
17480
+ [name: string]: unknown;
17481
+ };
17482
+ content: {
17483
+ "application/json": components["schemas"]["PlatformEcgSpendSummaryDto"];
17484
+ };
17485
+ };
17486
+ /** @description Unparseable date, backwards or over-wide window, or `workspaceLimit` out of range. */
17487
+ 400: {
17488
+ headers: {
17489
+ [name: string]: unknown;
17490
+ };
17491
+ content: {
17492
+ "application/json": components["schemas"]["ErrorMessageDto"];
17493
+ };
17494
+ };
17495
+ /** @description Missing or invalid JWT. */
17496
+ 401: {
17497
+ headers: {
17498
+ [name: string]: unknown;
17499
+ };
17500
+ content: {
17501
+ "application/json": components["schemas"]["ErrorMessageDto"];
17502
+ };
17503
+ };
17504
+ /** @description Caller is not a platform admin. */
17505
+ 403: {
17506
+ headers: {
17507
+ [name: string]: unknown;
17508
+ };
17509
+ content: {
17510
+ /**
17511
+ * @example {
17512
+ * "error": "Forbidden",
17513
+ * "code": "forbidden"
17514
+ * }
17515
+ */
17516
+ "application/json": components["schemas"]["ErrorMessageDto"];
17517
+ };
17518
+ };
17519
+ /** @description The batch database (`READINESS_DATABASE_URL`) is not configured on this API instance. */
17520
+ 503: {
17521
+ headers: {
17522
+ [name: string]: unknown;
17523
+ };
17524
+ content: {
17525
+ "application/json": components["schemas"]["ErrorMessageDto"];
17526
+ };
17527
+ };
17528
+ };
17529
+ };
17392
17530
  adminGetAutomationCostBudget: {
17393
17531
  parameters: {
17394
17532
  query?: {
package/src/index.ts CHANGED
@@ -1777,10 +1777,17 @@ export interface IngestCoveragePipelineDto {
1777
1777
  dataTrust: DataTrustDto;
1778
1778
  }
1779
1779
 
1780
+ /** ADR 006: dirty-week metrics rollup lag on GET ingest-coverage. */
1781
+ export interface IngestCoverageMetricsRollupDto {
1782
+ dirtyWeekCount: number;
1783
+ }
1784
+
1780
1785
  /** Response body for GET /workspaces/:id/ingest-coverage. */
1781
1786
  export interface IngestCoverageDto {
1782
1787
  pipelines: IngestCoveragePipelineDto[];
1783
1788
  generatedAt?: string;
1789
+ /** Present when at least one week is dirty (or count is 0 after a successful read). */
1790
+ metricsRollup?: IngestCoverageMetricsRollupDto | null;
1784
1791
  }
1785
1792
 
1786
1793
  export type IngestRunKind = Exclude<