@thinkai/tai-api-contract 2.184.0 → 2.186.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.184.0
4
+ version: 2.186.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}/...`.
@@ -1069,6 +1069,269 @@ paths:
1069
1069
  error: Forbidden
1070
1070
  code: forbidden
1071
1071
 
1072
+ /admin/automation-cost/summary:
1073
+ get:
1074
+ tags: [PlatformAdmin]
1075
+ summary: Estimated Agent automation spend by workspace and operation
1076
+ operationId: adminGetAutomationCostSummary
1077
+ description: >
1078
+ Rolls up `tai_readiness_token_usage` for the given UTC range (defaults to the current
1079
+ UTC calendar month when `from`/`to` are omitted). Each row is one
1080
+ `(workspaceId, operation)` with token totals, invocation count, and
1081
+ `estimatedSpendCents` from `workers.automationCost.pricing` (Cursor Auto pool list-rate
1082
+ defaults when keys are missing). Portfolio `totals` are sums of the returned rows.
1083
+
1084
+ **Authorization:** Bearer JWT required. Caller email must appear in `PLATFORM_ADMIN_EMAILS`.
1085
+ Separate from customer Insights AI Usage & Spend / `ai_cost_budget`.
1086
+ parameters:
1087
+ - name: workspaceId
1088
+ in: query
1089
+ required: false
1090
+ schema:
1091
+ type: string
1092
+ format: uuid
1093
+ description: Filter by workspace UUID.
1094
+ - name: from
1095
+ in: query
1096
+ required: false
1097
+ schema:
1098
+ type: string
1099
+ format: date-time
1100
+ description: Inclusive start (ISO-8601). Defaults to start of current UTC month.
1101
+ - name: to
1102
+ in: query
1103
+ required: false
1104
+ schema:
1105
+ type: string
1106
+ format: date-time
1107
+ description: Inclusive end (ISO-8601). Defaults to end of current UTC month.
1108
+ responses:
1109
+ "200":
1110
+ description: Summary rows and portfolio totals (empty rows / zero totals when no usage).
1111
+ content:
1112
+ application/json:
1113
+ schema:
1114
+ $ref: "#/components/schemas/AutomationCostSummaryDto"
1115
+ "401":
1116
+ description: Missing or invalid JWT.
1117
+ content:
1118
+ application/json:
1119
+ schema:
1120
+ $ref: "#/components/schemas/ErrorMessageDto"
1121
+ "403":
1122
+ description: Caller is not a platform admin.
1123
+ content:
1124
+ application/json:
1125
+ schema:
1126
+ $ref: "#/components/schemas/ErrorMessageDto"
1127
+ example:
1128
+ error: Forbidden
1129
+ code: forbidden
1130
+
1131
+ /admin/workspaces/{workspaceId}/automation-cost/budget:
1132
+ get:
1133
+ tags: [PlatformAdmin]
1134
+ summary: Get automation-cost budget and month status for a workspace
1135
+ operationId: adminGetAutomationCostBudget
1136
+ description: >
1137
+ Returns budget rows for `readiness_analysis` and/or `readiness_fix` with
1138
+ `monthSpendCents` (estimated from token rows in the current UTC month) and
1139
+ `status` (`ok` | `warn` | `hard_stopped` | `paused`). When no budget is configured,
1140
+ `monthlyBudgetCents` is null and status is `ok` (unlimited) unless paused.
1141
+
1142
+ **Authorization:** Bearer JWT + `PLATFORM_ADMIN_EMAILS`.
1143
+ parameters:
1144
+ - $ref: "#/components/parameters/WorkspaceId"
1145
+ - name: operation
1146
+ in: query
1147
+ required: false
1148
+ schema:
1149
+ type: string
1150
+ enum: [readiness_analysis, readiness_fix]
1151
+ description: Limit to one operation; omit for both.
1152
+ responses:
1153
+ "200":
1154
+ description: Budget views for the requested operations.
1155
+ content:
1156
+ application/json:
1157
+ schema:
1158
+ $ref: "#/components/schemas/AutomationCostBudgetListDto"
1159
+ "401":
1160
+ description: Missing or invalid JWT.
1161
+ content:
1162
+ application/json:
1163
+ schema:
1164
+ $ref: "#/components/schemas/ErrorMessageDto"
1165
+ "403":
1166
+ description: Caller is not a platform admin.
1167
+ content:
1168
+ application/json:
1169
+ schema:
1170
+ $ref: "#/components/schemas/ErrorMessageDto"
1171
+ example:
1172
+ error: Forbidden
1173
+ code: forbidden
1174
+ "404":
1175
+ description: Workspace not found.
1176
+ content:
1177
+ application/json:
1178
+ schema:
1179
+ $ref: "#/components/schemas/ErrorMessageDto"
1180
+ example:
1181
+ error: Workspace not found
1182
+ code: workspace_not_found
1183
+ put:
1184
+ tags: [PlatformAdmin]
1185
+ summary: Upsert automation-cost budget for one operation
1186
+ operationId: adminPutAutomationCostBudget
1187
+ description: >
1188
+ Upserts `{ operation, monthlyBudgetCents, warnThresholdPct, hardEnabled }` into
1189
+ workspace `automation_cost_budget` (not `ai_cost_budget`). Default `warnThresholdPct`
1190
+ is 80. `monthlyBudgetCents: 0` with `hardEnabled: true` is an immediate hard stop.
1191
+ Returns the refreshed budget view for that operation.
1192
+
1193
+ **Authorization:** Bearer JWT + `PLATFORM_ADMIN_EMAILS`.
1194
+ parameters:
1195
+ - $ref: "#/components/parameters/WorkspaceId"
1196
+ requestBody:
1197
+ required: true
1198
+ content:
1199
+ application/json:
1200
+ schema:
1201
+ $ref: "#/components/schemas/AutomationCostBudgetUpsertDto"
1202
+ responses:
1203
+ "200":
1204
+ description: Updated budget view(s).
1205
+ content:
1206
+ application/json:
1207
+ schema:
1208
+ $ref: "#/components/schemas/AutomationCostBudgetListDto"
1209
+ "400":
1210
+ description: Invalid body.
1211
+ content:
1212
+ application/json:
1213
+ schema:
1214
+ $ref: "#/components/schemas/ErrorMessageDto"
1215
+ "401":
1216
+ description: Missing or invalid JWT.
1217
+ content:
1218
+ application/json:
1219
+ schema:
1220
+ $ref: "#/components/schemas/ErrorMessageDto"
1221
+ "403":
1222
+ description: Caller is not a platform admin.
1223
+ content:
1224
+ application/json:
1225
+ schema:
1226
+ $ref: "#/components/schemas/ErrorMessageDto"
1227
+ example:
1228
+ error: Forbidden
1229
+ code: forbidden
1230
+ "404":
1231
+ description: Workspace not found.
1232
+ content:
1233
+ application/json:
1234
+ schema:
1235
+ $ref: "#/components/schemas/ErrorMessageDto"
1236
+ example:
1237
+ error: Workspace not found
1238
+ code: workspace_not_found
1239
+
1240
+ /admin/workspaces/{workspaceId}/automation-cost/pause:
1241
+ post:
1242
+ tags: [PlatformAdmin]
1243
+ summary: Pause Agent automation for selected operations
1244
+ operationId: adminPostAutomationCostPause
1245
+ description: >
1246
+ Sets a per-workspace pause kill-switch for the listed operations. Workers honor pause
1247
+ the same as a hard budget stop (enforcement is a follow-up slice). Empty `operations`
1248
+ → `400`.
1249
+
1250
+ **Authorization:** Bearer JWT + `PLATFORM_ADMIN_EMAILS`.
1251
+ parameters:
1252
+ - $ref: "#/components/parameters/WorkspaceId"
1253
+ requestBody:
1254
+ required: true
1255
+ content:
1256
+ application/json:
1257
+ schema:
1258
+ $ref: "#/components/schemas/AutomationCostPauseBodyDto"
1259
+ responses:
1260
+ "200":
1261
+ description: Pause state stored.
1262
+ content:
1263
+ application/json:
1264
+ schema:
1265
+ $ref: "#/components/schemas/AutomationCostPauseResponseDto"
1266
+ "400":
1267
+ description: Empty or invalid operations list.
1268
+ content:
1269
+ application/json:
1270
+ schema:
1271
+ $ref: "#/components/schemas/ErrorMessageDto"
1272
+ "401":
1273
+ description: Missing or invalid JWT.
1274
+ content:
1275
+ application/json:
1276
+ schema:
1277
+ $ref: "#/components/schemas/ErrorMessageDto"
1278
+ "403":
1279
+ description: Caller is not a platform admin.
1280
+ content:
1281
+ application/json:
1282
+ schema:
1283
+ $ref: "#/components/schemas/ErrorMessageDto"
1284
+ example:
1285
+ error: Forbidden
1286
+ code: forbidden
1287
+ "404":
1288
+ description: Workspace not found.
1289
+ content:
1290
+ application/json:
1291
+ schema:
1292
+ $ref: "#/components/schemas/ErrorMessageDto"
1293
+ example:
1294
+ error: Workspace not found
1295
+ code: workspace_not_found
1296
+ delete:
1297
+ tags: [PlatformAdmin]
1298
+ summary: Clear automation-cost pause for a workspace
1299
+ operationId: adminDeleteAutomationCostPause
1300
+ description: >
1301
+ Clears `automation_cost_pause` for the workspace so workers may resume when under hard
1302
+ cap.
1303
+
1304
+ **Authorization:** Bearer JWT + `PLATFORM_ADMIN_EMAILS`.
1305
+ parameters:
1306
+ - $ref: "#/components/parameters/WorkspaceId"
1307
+ responses:
1308
+ "204":
1309
+ description: Pause cleared.
1310
+ "401":
1311
+ description: Missing or invalid JWT.
1312
+ content:
1313
+ application/json:
1314
+ schema:
1315
+ $ref: "#/components/schemas/ErrorMessageDto"
1316
+ "403":
1317
+ description: Caller is not a platform admin.
1318
+ content:
1319
+ application/json:
1320
+ schema:
1321
+ $ref: "#/components/schemas/ErrorMessageDto"
1322
+ example:
1323
+ error: Forbidden
1324
+ code: forbidden
1325
+ "404":
1326
+ description: Workspace not found.
1327
+ content:
1328
+ application/json:
1329
+ schema:
1330
+ $ref: "#/components/schemas/ErrorMessageDto"
1331
+ example:
1332
+ error: Workspace not found
1333
+ code: workspace_not_found
1334
+
1072
1335
  /privacy-requests:
1073
1336
  post:
1074
1337
  tags: [PrivacyRequests]
@@ -6371,6 +6634,76 @@ paths:
6371
6634
  schema:
6372
6635
  $ref: "#/components/schemas/GrafanaTriggerSyncResultDto"
6373
6636
 
6637
+ /workspaces/{workspaceId}/integrations/datadog:
6638
+ get:
6639
+ tags: [Integrations]
6640
+ summary: Datadog monitoring integration status
6641
+ operationId: getWorkspaceDatadogIntegrationStatus
6642
+ description: >
6643
+ Returns whether Datadog is connected for the workspace (site + dual keys) and the last
6644
+ monitoring ingest sync outcome (incidents/deployments pulled into Quality and DORA metrics).
6645
+ parameters:
6646
+ - $ref: "#/components/parameters/WorkspaceId"
6647
+ responses:
6648
+ "200":
6649
+ description: Datadog integration status
6650
+ content:
6651
+ application/json:
6652
+ schema:
6653
+ $ref: "#/components/schemas/DatadogIntegrationStatusDto"
6654
+ "401":
6655
+ $ref: "#/components/responses/Unauthorized"
6656
+ "403":
6657
+ $ref: "#/components/responses/Forbidden"
6658
+ "404":
6659
+ description: Workspace does not exist or malformed workspaceId
6660
+ content:
6661
+ application/json:
6662
+ schema:
6663
+ $ref: "#/components/schemas/ErrorMessageDto"
6664
+
6665
+ /workspaces/{workspaceId}/integrations/datadog/sync:
6666
+ post:
6667
+ tags: [Integrations]
6668
+ summary: Trigger Datadog monitoring ingest now
6669
+ operationId: postWorkspaceDatadogIntegrationSync
6670
+ description: >
6671
+ Manually polls Datadog for incidents and deployment-tagged events, persists canonical
6672
+ monitoring events, and refreshes org-level Quality/DORA dashboard buckets. Requires editor role.
6673
+ security:
6674
+ - bearerAuth: []
6675
+ parameters:
6676
+ - $ref: "#/components/parameters/WorkspaceId"
6677
+ responses:
6678
+ "200":
6679
+ description: Sync completed
6680
+ content:
6681
+ application/json:
6682
+ schema:
6683
+ $ref: "#/components/schemas/DatadogTriggerSyncResultDto"
6684
+ "401":
6685
+ $ref: "#/components/responses/Unauthorized"
6686
+ "403":
6687
+ $ref: "#/components/responses/Forbidden"
6688
+ "404":
6689
+ description: Workspace does not exist or malformed workspaceId
6690
+ content:
6691
+ application/json:
6692
+ schema:
6693
+ $ref: "#/components/schemas/ErrorMessageDto"
6694
+ "422":
6695
+ description: Datadog is not connected on this workspace
6696
+ content:
6697
+ application/json:
6698
+ schema:
6699
+ $ref: "#/components/schemas/DatadogTriggerSyncResultDto"
6700
+ "503":
6701
+ description: Sync failed (Datadog API or persistence error)
6702
+ content:
6703
+ application/json:
6704
+ schema:
6705
+ $ref: "#/components/schemas/DatadogTriggerSyncResultDto"
6706
+
6374
6707
  /integrations/github/webhook:
6375
6708
  post:
6376
6709
  tags: [Integrations]
@@ -19374,6 +19707,80 @@ components:
19374
19707
  error:
19375
19708
  type: string
19376
19709
 
19710
+ DatadogIntegrationStatusDto:
19711
+ type: object
19712
+ additionalProperties: false
19713
+ required: [connected, status]
19714
+ properties:
19715
+ connected:
19716
+ type: boolean
19717
+ description: "True when a type:datadog workspace source is configured."
19718
+ site:
19719
+ type: string
19720
+ enum:
19721
+ - datadoghq.com
19722
+ - us3.datadoghq.com
19723
+ - us5.datadoghq.com
19724
+ - datadoghq.eu
19725
+ - ap1.datadoghq.com
19726
+ description: Configured Datadog site when connected.
19727
+ orgName:
19728
+ type: string
19729
+ description: Org display name when known from the last successful verify.
19730
+ lastSyncAt:
19731
+ type: string
19732
+ format: date-time
19733
+ nullable: true
19734
+ description: Timestamp of the last monitoring ingest attempt (success or failure).
19735
+ status:
19736
+ type: string
19737
+ enum: [ok, error, never]
19738
+ description: Outcome of the most recent sync (`never` when not yet synced).
19739
+ lastError:
19740
+ type: string
19741
+ nullable: true
19742
+ issueCount:
19743
+ type: integer
19744
+ nullable: true
19745
+ description: Incidents fetched on the last successful sync (30d lookback).
19746
+ deploymentCount:
19747
+ type: integer
19748
+ nullable: true
19749
+ description: Deployment-tagged events fetched on the last successful sync (30d lookback).
19750
+ eventCount:
19751
+ type: integer
19752
+ nullable: true
19753
+ description: Canonical monitoring events upserted on the last successful sync.
19754
+
19755
+ DatadogTriggerSyncResultDto:
19756
+ type: object
19757
+ additionalProperties: false
19758
+ required: [status]
19759
+ properties:
19760
+ status:
19761
+ type: string
19762
+ enum: [ok, skipped, error]
19763
+ code:
19764
+ type: string
19765
+ description: Stable machine-readable code (e.g. `datadog_not_connected`).
19766
+ reason:
19767
+ type: string
19768
+ description: Human-readable skip reason when status is skipped.
19769
+ issueCount:
19770
+ type: integer
19771
+ deploymentCount:
19772
+ type: integer
19773
+ eventCount:
19774
+ type: integer
19775
+ bucketsWritten:
19776
+ type: integer
19777
+ description: Weekly dashboard metric buckets updated from monitoring events.
19778
+ durationMs:
19779
+ type: integer
19780
+ error:
19781
+ type: string
19782
+ description: Error message when status is error.
19783
+
19377
19784
  GithubActionsEnableResponseDto:
19378
19785
  type: object
19379
19786
  additionalProperties: false
@@ -23329,6 +23736,10 @@ components:
23329
23736
  - integrations.grafana.removed
23330
23737
  - integrations.grafana.sync_completed
23331
23738
  - integrations.grafana.sync_failed
23739
+ - integrations.datadog.added
23740
+ - integrations.datadog.removed
23741
+ - integrations.datadog.sync_completed
23742
+ - integrations.datadog.sync_failed
23332
23743
  - integrations.zelt.added
23333
23744
  - integrations.zelt.removed
23334
23745
  - report.exported
@@ -23739,7 +24150,7 @@ components:
23739
24150
  properties:
23740
24151
  version:
23741
24152
  type: string
23742
- enum: ["2026-10-24.1"]
24153
+ enum: ["2026-10-25.1"]
23743
24154
  periodDays:
23744
24155
  type: integer
23745
24156
  enum: [90]
@@ -23825,12 +24236,12 @@ components:
23825
24236
  enum: [jira]
23826
24237
  incident:
23827
24238
  type: array
23828
- minItems: 6
23829
- maxItems: 6
24239
+ minItems: 7
24240
+ maxItems: 7
23830
24241
  uniqueItems: true
23831
24242
  items:
23832
24243
  type: string
23833
- enum: [pagerduty, opsgenie, goalert, newrelic, prometheus, grafana]
24244
+ enum: [pagerduty, opsgenie, goalert, newrelic, prometheus, grafana, datadog]
23834
24245
  selfManagedGit:
23835
24246
  type: object
23836
24247
  additionalProperties: false
@@ -25252,6 +25663,186 @@ components:
25252
25663
  items:
25253
25664
  $ref: "#/components/schemas/ActivityLogEntryDto"
25254
25665
 
25666
+ AutomationCostOperationDto:
25667
+ type: string
25668
+ enum: [readiness_analysis, readiness_fix]
25669
+ description: Platform Agent job type in the readiness token ledger.
25670
+
25671
+ AutomationCostSummaryRowDto:
25672
+ type: object
25673
+ required:
25674
+ - workspaceId
25675
+ - operation
25676
+ - inputTokens
25677
+ - outputTokens
25678
+ - cacheReadTokens
25679
+ - cacheWriteTokens
25680
+ - estimatedSpendCents
25681
+ - invocationCount
25682
+ properties:
25683
+ workspaceId:
25684
+ type: string
25685
+ format: uuid
25686
+ operation:
25687
+ $ref: "#/components/schemas/AutomationCostOperationDto"
25688
+ inputTokens:
25689
+ type: integer
25690
+ format: int64
25691
+ outputTokens:
25692
+ type: integer
25693
+ format: int64
25694
+ cacheReadTokens:
25695
+ type: integer
25696
+ format: int64
25697
+ cacheWriteTokens:
25698
+ type: integer
25699
+ format: int64
25700
+ estimatedSpendCents:
25701
+ type: integer
25702
+ description: Ops estimate from token totals × runtime-config pricing (integer cents).
25703
+ invocationCount:
25704
+ type: integer
25705
+
25706
+ AutomationCostSummaryTotalsDto:
25707
+ type: object
25708
+ required:
25709
+ - inputTokens
25710
+ - outputTokens
25711
+ - cacheReadTokens
25712
+ - cacheWriteTokens
25713
+ - estimatedSpendCents
25714
+ - invocationCount
25715
+ properties:
25716
+ inputTokens:
25717
+ type: integer
25718
+ format: int64
25719
+ outputTokens:
25720
+ type: integer
25721
+ format: int64
25722
+ cacheReadTokens:
25723
+ type: integer
25724
+ format: int64
25725
+ cacheWriteTokens:
25726
+ type: integer
25727
+ format: int64
25728
+ estimatedSpendCents:
25729
+ type: integer
25730
+ invocationCount:
25731
+ type: integer
25732
+
25733
+ AutomationCostSummaryDto:
25734
+ type: object
25735
+ required: [rows, totals]
25736
+ properties:
25737
+ rows:
25738
+ type: array
25739
+ items:
25740
+ $ref: "#/components/schemas/AutomationCostSummaryRowDto"
25741
+ totals:
25742
+ $ref: "#/components/schemas/AutomationCostSummaryTotalsDto"
25743
+
25744
+ AutomationCostBudgetStatusDto:
25745
+ type: string
25746
+ enum: [ok, warn, hard_stopped, paused]
25747
+
25748
+ AutomationCostBudgetViewDto:
25749
+ type: object
25750
+ required:
25751
+ - operation
25752
+ - monthlyBudgetCents
25753
+ - warnThresholdPct
25754
+ - hardEnabled
25755
+ - monthSpendCents
25756
+ - status
25757
+ - paused
25758
+ properties:
25759
+ operation:
25760
+ $ref: "#/components/schemas/AutomationCostOperationDto"
25761
+ monthlyBudgetCents:
25762
+ type: integer
25763
+ nullable: true
25764
+ description: Null when no budget is configured (unlimited).
25765
+ warnThresholdPct:
25766
+ type: integer
25767
+ minimum: 0
25768
+ maximum: 100
25769
+ hardEnabled:
25770
+ type: boolean
25771
+ monthSpendCents:
25772
+ type: integer
25773
+ description: Estimated spend for this operation in the current UTC calendar month.
25774
+ status:
25775
+ $ref: "#/components/schemas/AutomationCostBudgetStatusDto"
25776
+ paused:
25777
+ type: boolean
25778
+ pauseReason:
25779
+ type: string
25780
+ nullable: true
25781
+
25782
+ AutomationCostBudgetListDto:
25783
+ type: object
25784
+ required: [budgets]
25785
+ properties:
25786
+ budgets:
25787
+ type: array
25788
+ items:
25789
+ $ref: "#/components/schemas/AutomationCostBudgetViewDto"
25790
+
25791
+ AutomationCostBudgetUpsertDto:
25792
+ type: object
25793
+ required: [operation, monthlyBudgetCents]
25794
+ properties:
25795
+ operation:
25796
+ $ref: "#/components/schemas/AutomationCostOperationDto"
25797
+ monthlyBudgetCents:
25798
+ type: integer
25799
+ minimum: 0
25800
+ warnThresholdPct:
25801
+ type: integer
25802
+ minimum: 0
25803
+ maximum: 100
25804
+ default: 80
25805
+ hardEnabled:
25806
+ type: boolean
25807
+ default: false
25808
+
25809
+ AutomationCostPauseBodyDto:
25810
+ type: object
25811
+ required: [operations, reason]
25812
+ properties:
25813
+ operations:
25814
+ type: array
25815
+ minItems: 1
25816
+ items:
25817
+ $ref: "#/components/schemas/AutomationCostOperationDto"
25818
+ reason:
25819
+ type: string
25820
+
25821
+ AutomationCostPauseStateDto:
25822
+ type: object
25823
+ required: [operations, reason, pausedAt]
25824
+ properties:
25825
+ operations:
25826
+ type: array
25827
+ items:
25828
+ $ref: "#/components/schemas/AutomationCostOperationDto"
25829
+ reason:
25830
+ type: string
25831
+ pausedAt:
25832
+ type: string
25833
+ format: date-time
25834
+ pausedBy:
25835
+ type: string
25836
+ nullable: true
25837
+ description: Platform admin email that set the pause, when known.
25838
+
25839
+ AutomationCostPauseResponseDto:
25840
+ type: object
25841
+ required: [pause]
25842
+ properties:
25843
+ pause:
25844
+ $ref: "#/components/schemas/AutomationCostPauseStateDto"
25845
+
25255
25846
  ReadinessTokenUsageRowDto:
25256
25847
  type: object
25257
25848
  required:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkai/tai-api-contract",
3
- "version": "2.184.0",
3
+ "version": "2.186.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",