@thinkai/tai-api-contract 2.8.5 → 2.9.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.8.4
4
+ version: 2.9.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}/...`.
@@ -3142,6 +3142,74 @@ paths:
3142
3142
  schema:
3143
3143
  $ref: "#/components/schemas/ErrorMessageDto"
3144
3144
 
3145
+ /workspaces/{workspaceId}/cursor/platform-key-consent:
3146
+ put:
3147
+ tags: [Integrations]
3148
+ summary: Enable or disable ThinkAI platform Cursor key opt-in
3149
+ description: >
3150
+ Explicitly enable or disable use of ThinkAI's platform Cursor execution key for readiness
3151
+ scans. When enabled and the workspace has no `executionToken` configured, the platform key
3152
+ is used and tracked for billing. Requires workspace editor or admin role.
3153
+ operationId: putCursorPlatformKeyConsent
3154
+ parameters:
3155
+ - $ref: "#/components/parameters/WorkspaceId"
3156
+ requestBody:
3157
+ required: true
3158
+ content:
3159
+ application/json:
3160
+ schema:
3161
+ type: object
3162
+ required: [enabled]
3163
+ properties:
3164
+ enabled:
3165
+ type: boolean
3166
+ description: >
3167
+ true to opt in to ThinkAI platform Cursor key (additional cost applies);
3168
+ false to opt out.
3169
+ responses:
3170
+ "200":
3171
+ description: Consent updated
3172
+ content:
3173
+ application/json:
3174
+ schema:
3175
+ type: object
3176
+ required: [ok]
3177
+ properties:
3178
+ ok:
3179
+ type: boolean
3180
+ "400":
3181
+ description: Invalid request body
3182
+ content:
3183
+ application/json:
3184
+ schema:
3185
+ $ref: "#/components/schemas/ErrorMessageDto"
3186
+ "401":
3187
+ $ref: "#/components/responses/Unauthorized"
3188
+ "403":
3189
+ $ref: "#/components/responses/Forbidden"
3190
+
3191
+ /workspaces/{workspaceId}/readiness/cursor-key-usage:
3192
+ get:
3193
+ tags: [RepositoryReadiness]
3194
+ summary: Get Cursor key usage stats for this workspace
3195
+ description: >
3196
+ Returns per-workspace counts of readiness runs that used the ThinkAI platform Cursor key
3197
+ vs. the workspace's own execution key. Member-level access.
3198
+ operationId: getCursorKeyUsage
3199
+ parameters:
3200
+ - $ref: "#/components/parameters/WorkspaceId"
3201
+ responses:
3202
+ "200":
3203
+ description: Cursor key usage stats
3204
+ content:
3205
+ application/json:
3206
+ schema:
3207
+ $ref: "#/components/schemas/CursorKeyUsageDto"
3208
+ "401":
3209
+ $ref: "#/components/responses/Unauthorized"
3210
+ "403":
3211
+ $ref: "#/components/responses/Forbidden"
3212
+
3145
3213
  /workspaces/{workspaceId}/squad:
3146
3214
  get:
3147
3215
  tags: [SquadProjects]
@@ -4125,11 +4193,13 @@ components:
4125
4193
  CursorSourceDto:
4126
4194
  type: object
4127
4195
  description: >
4128
- Cursor (AI Tools) source entry for `PUT /workspaces/{workspaceId}/sources`
4129
- and `POST /workspaces/{workspaceId}/sources/test`. The `token` field
4130
- carries a literal Cursor API key on writes; reads from
4131
- `GET /workspaces/{workspaceId}/config` redact it to `***`.
4132
- Runtime calls use the Cursor Admin API at `https://api.cursor.com` (HTTP Basic); do not rely on `baseUrl`.
4196
+ Cursor source entry for `PUT /workspaces/{workspaceId}/sources`
4197
+ and `POST /workspaces/{workspaceId}/sources/test`.
4198
+ Two distinct keys: Admin API key (`token`) for insights sync;
4199
+ Execution key (`executionToken`) for readiness scanner and Agent CLI.
4200
+ On writes both fields accept literal key values; reads from
4201
+ `GET /workspaces/{workspaceId}/config` return a `CursorSourceConfigDto`
4202
+ shape (`hasToken` / `hasExecutionToken` booleans) — raw values are never returned.
4133
4203
  required: [type, token]
4134
4204
  additionalProperties: false
4135
4205
  properties:
@@ -4140,7 +4210,18 @@ components:
4140
4210
  type: string
4141
4211
  minLength: 1
4142
4212
  maxLength: 256
4143
- description: Cursor API key (literal). Whitespace and `env:` prefix are rejected.
4213
+ description: >
4214
+ Cursor Admin API key (literal). Used for seats/spend/usage insights sync only.
4215
+ Whitespace and `env:` prefix are rejected.
4216
+ executionToken:
4217
+ type: string
4218
+ minLength: 1
4219
+ maxLength: 256
4220
+ description: >
4221
+ Cursor execution key (literal). Used for the readiness scanner and Agent CLI.
4222
+ This is a Cursor user API key or service account key — NOT the Admin API key.
4223
+ Omit if using the ThinkAI platform key (requires `cursorPlatformKeyEnabled` on the workspace).
4224
+ Whitespace and `env:` prefix are rejected.
4144
4225
  baseUrl:
4145
4226
  type: string
4146
4227
  deprecated: true
@@ -4149,6 +4230,28 @@ components:
4149
4230
  and always uses the Cursor Admin API host. Kept so older clients can submit payloads unchanged.
4150
4231
  default: "https://api.cursor.com"
4151
4232
 
4233
+ CursorSourceConfigDto:
4234
+ type: object
4235
+ description: >
4236
+ Redacted Cursor source returned by `GET /workspaces/{workspaceId}/config`.
4237
+ `hasToken` and `hasExecutionToken` indicate which keys are stored.
4238
+ Raw values are never returned.
4239
+ required: [type, hasToken, hasExecutionToken]
4240
+ additionalProperties: false
4241
+ properties:
4242
+ type:
4243
+ type: string
4244
+ enum: [cursor]
4245
+ hasToken:
4246
+ type: boolean
4247
+ description: Whether the Admin API key (`token`) is stored for this workspace.
4248
+ hasExecutionToken:
4249
+ type: boolean
4250
+ description: >
4251
+ Whether the execution key is stored. If false and `cursorPlatformKeyEnabled` is true
4252
+ in `WorkspaceConfigDto`, the platform key will be used for readiness runs
4253
+ (additional cost applies).
4254
+
4152
4255
  ClaudeSourceDto:
4153
4256
  type: object
4154
4257
  description: >
@@ -4188,6 +4291,12 @@ components:
4188
4291
  type: string
4189
4292
  nullable: true
4190
4293
  enum: [us, eu, me]
4294
+ cursorPlatformKeyEnabled:
4295
+ type: boolean
4296
+ description: >
4297
+ When true, readiness runs may use the ThinkAI platform Cursor key if this
4298
+ workspace has no `executionToken` configured. Additional cost applies.
4299
+ Requires explicit opt-in via `PUT /workspaces/{workspaceId}/cursor/platform-key-consent`.
4191
4300
 
4192
4301
  TestConnectionResponseDto:
4193
4302
  type: object
@@ -4197,6 +4306,35 @@ components:
4197
4306
  type: boolean
4198
4307
  error:
4199
4308
  type: string
4309
+ executionKeyValid:
4310
+ type: boolean
4311
+ nullable: true
4312
+ description: >
4313
+ Present when `executionToken` was included in the test request.
4314
+ `true` = key passed save-time validation (format + not-admin-key check).
4315
+ `false` = key failed validation (see `executionKeyError` for detail).
4316
+ `null` = `executionToken` was not provided.
4317
+ executionKeyError:
4318
+ type: string
4319
+ nullable: true
4320
+ description: Error detail when `executionKeyValid` is false.
4321
+
4322
+ CursorKeyUsageDto:
4323
+ type: object
4324
+ required: [platformKeyRunsThisMonth, platformKeyRunsTotal, workspaceKeyRunsTotal]
4325
+ properties:
4326
+ platformKeyRunsThisMonth:
4327
+ type: integer
4328
+ minimum: 0
4329
+ description: Readiness runs this calendar month that used the ThinkAI platform Cursor key.
4330
+ platformKeyRunsTotal:
4331
+ type: integer
4332
+ minimum: 0
4333
+ description: All-time readiness runs that used the ThinkAI platform Cursor key.
4334
+ workspaceKeyRunsTotal:
4335
+ type: integer
4336
+ minimum: 0
4337
+ description: All-time readiness runs that used the workspace's own execution key.
4200
4338
 
4201
4339
  AiToolSeatDto:
4202
4340
  type: object
@@ -5897,6 +6035,15 @@ components:
5897
6035
  type: string
5898
6036
  format: date-time
5899
6037
  nullable: true
6038
+ cursorKeySource:
6039
+ type: string
6040
+ nullable: true
6041
+ enum: [workspace_execution_token, platform_env_key]
6042
+ description: >
6043
+ Which Cursor execution key was used for this run.
6044
+ `workspace_execution_token`: workspace provided its own execution key.
6045
+ `platform_env_key`: ThinkAI platform key was used (opt-in required; additional cost applies).
6046
+ `null`: run did not reach the Cursor agent stage.
5900
6047
 
5901
6048
  ReadinessCriteriaSummaryDto:
5902
6049
  type: object
@@ -6030,6 +6177,18 @@ components:
6030
6177
  nullable: true
6031
6178
  description: Pass as `cursor` query param to fetch the next page; null when no more rows.
6032
6179
 
6180
+ ReadinessScoreHistoryDimensionScoreDto:
6181
+ type: object
6182
+ required: [dimensionId, scorePercent]
6183
+ properties:
6184
+ dimensionId:
6185
+ $ref: "#/components/schemas/ReadinessDimensionId"
6186
+ scorePercent:
6187
+ type: integer
6188
+ minimum: 0
6189
+ maximum: 100
6190
+ description: Dimension score as a percentage (0–100) for this scan run.
6191
+
6033
6192
  ReadinessScoreHistoryPointDto:
6034
6193
  type: object
6035
6194
  required: [finishedAt, overallScore]
@@ -6041,6 +6200,11 @@ components:
6041
6200
  type: integer
6042
6201
  minimum: 0
6043
6202
  maximum: 100
6203
+ dimensionScores:
6204
+ type: array
6205
+ items:
6206
+ $ref: "#/components/schemas/ReadinessScoreHistoryDimensionScoreDto"
6207
+ description: Per-dimension percentages captured on this scan run.
6044
6208
 
6045
6209
  ReadinessRepoScoreHistoryDto:
6046
6210
  type: object
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkai/tai-api-contract",
3
- "version": "2.8.5",
3
+ "version": "2.9.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1239,6 +1239,46 @@ export interface paths {
1239
1239
  patch?: never;
1240
1240
  trace?: never;
1241
1241
  };
1242
+ "/workspaces/{workspaceId}/cursor/platform-key-consent": {
1243
+ parameters: {
1244
+ query?: never;
1245
+ header?: never;
1246
+ path?: never;
1247
+ cookie?: never;
1248
+ };
1249
+ get?: never;
1250
+ /**
1251
+ * Enable or disable ThinkAI platform Cursor key opt-in
1252
+ * @description Explicitly enable or disable use of ThinkAI's platform Cursor execution key for readiness scans. When enabled and the workspace has no `executionToken` configured, the platform key is used and tracked for billing. Requires workspace editor or admin role.
1253
+ */
1254
+ put: operations["putCursorPlatformKeyConsent"];
1255
+ post?: never;
1256
+ delete?: never;
1257
+ options?: never;
1258
+ head?: never;
1259
+ patch?: never;
1260
+ trace?: never;
1261
+ };
1262
+ "/workspaces/{workspaceId}/readiness/cursor-key-usage": {
1263
+ parameters: {
1264
+ query?: never;
1265
+ header?: never;
1266
+ path?: never;
1267
+ cookie?: never;
1268
+ };
1269
+ /**
1270
+ * Get Cursor key usage stats for this workspace
1271
+ * @description Returns per-workspace counts of readiness runs that used the ThinkAI platform Cursor key vs. the workspace's own execution key. Member-level access.
1272
+ */
1273
+ get: operations["getCursorKeyUsage"];
1274
+ put?: never;
1275
+ post?: never;
1276
+ delete?: never;
1277
+ options?: never;
1278
+ head?: never;
1279
+ patch?: never;
1280
+ trace?: never;
1281
+ };
1242
1282
  "/workspaces/{workspaceId}/squad": {
1243
1283
  parameters: {
1244
1284
  query?: never;
@@ -1653,12 +1693,14 @@ export interface components {
1653
1693
  } & {
1654
1694
  [key: string]: unknown;
1655
1695
  };
1656
- /** @description Cursor (AI Tools) source entry for `PUT /workspaces/{workspaceId}/sources` and `POST /workspaces/{workspaceId}/sources/test`. The `token` field carries a literal Cursor API key on writes; reads from `GET /workspaces/{workspaceId}/config` redact it to `***`. Runtime calls use the Cursor Admin API at `https://api.cursor.com` (HTTP Basic); do not rely on `baseUrl`. */
1696
+ /** @description Cursor source entry for `PUT /workspaces/{workspaceId}/sources` and `POST /workspaces/{workspaceId}/sources/test`. Two distinct keys: Admin API key (`token`) for insights sync; Execution key (`executionToken`) for readiness scanner and Agent CLI. On writes both fields accept literal key values; reads from `GET /workspaces/{workspaceId}/config` return a `CursorSourceConfigDto` shape (`hasToken` / `hasExecutionToken` booleans) raw values are never returned. */
1657
1697
  CursorSourceDto: {
1658
1698
  /** @enum {string} */
1659
1699
  type: "cursor";
1660
- /** @description Cursor API key (literal). Whitespace and `env:` prefix are rejected. */
1700
+ /** @description Cursor Admin API key (literal). Used for seats/spend/usage insights sync only. Whitespace and `env:` prefix are rejected. */
1661
1701
  token: string;
1702
+ /** @description Cursor execution key (literal). Used for the readiness scanner and Agent CLI. This is a Cursor user API key or service account key — NOT the Admin API key. Omit if using the ThinkAI platform key (requires `cursorPlatformKeyEnabled` on the workspace). Whitespace and `env:` prefix are rejected. */
1703
+ executionToken?: string;
1662
1704
  /**
1663
1705
  * @deprecated
1664
1706
  * @description Deprecated. Historically suggested an API base URL; the server ignores this field and always uses the Cursor Admin API host. Kept so older clients can submit payloads unchanged.
@@ -1666,6 +1708,15 @@ export interface components {
1666
1708
  */
1667
1709
  baseUrl: string;
1668
1710
  };
1711
+ /** @description Redacted Cursor source returned by `GET /workspaces/{workspaceId}/config`. `hasToken` and `hasExecutionToken` indicate which keys are stored. Raw values are never returned. */
1712
+ CursorSourceConfigDto: {
1713
+ /** @enum {string} */
1714
+ type: "cursor";
1715
+ /** @description Whether the Admin API key (`token`) is stored for this workspace. */
1716
+ hasToken: boolean;
1717
+ /** @description Whether the execution key is stored. If false and `cursorPlatformKeyEnabled` is true in `WorkspaceConfigDto`, the platform key will be used for readiness runs (additional cost applies). */
1718
+ hasExecutionToken: boolean;
1719
+ };
1669
1720
  /** @description Claude (Anthropic) source entry for `PUT /workspaces/{workspaceId}/sources` and `POST /workspaces/{workspaceId}/sources/test`. The `token` field carries a literal Organization Admin API key on writes (`sk-ant-admin...`); reads from `GET /workspaces/{workspaceId}/config` redact it to `***`. Runtime calls use the Anthropic Admin API at `https://api.anthropic.com`. Provision keys in Claude Console → Organization settings (admin role required). */
1670
1721
  ClaudeSourceDto: {
1671
1722
  /** @enum {string} */
@@ -1678,10 +1729,24 @@ export interface components {
1678
1729
  orgChart?: components["schemas"]["ScoringOrgChartDto"] | null;
1679
1730
  /** @enum {string|null} */
1680
1731
  region?: "us" | "eu" | "me" | null;
1732
+ /** @description When true, readiness runs may use the ThinkAI platform Cursor key if this workspace has no `executionToken` configured. Additional cost applies. Requires explicit opt-in via `PUT /workspaces/{workspaceId}/cursor/platform-key-consent`. */
1733
+ cursorPlatformKeyEnabled?: boolean;
1681
1734
  };
1682
1735
  TestConnectionResponseDto: {
1683
1736
  success: boolean;
1684
1737
  error?: string;
1738
+ /** @description Present when `executionToken` was included in the test request. `true` = key passed save-time validation (format + not-admin-key check). `false` = key failed validation (see `executionKeyError` for detail). `null` = `executionToken` was not provided. */
1739
+ executionKeyValid?: boolean | null;
1740
+ /** @description Error detail when `executionKeyValid` is false. */
1741
+ executionKeyError?: string | null;
1742
+ };
1743
+ CursorKeyUsageDto: {
1744
+ /** @description Readiness runs this calendar month that used the ThinkAI platform Cursor key. */
1745
+ platformKeyRunsThisMonth: number;
1746
+ /** @description All-time readiness runs that used the ThinkAI platform Cursor key. */
1747
+ platformKeyRunsTotal: number;
1748
+ /** @description All-time readiness runs that used the workspace's own execution key. */
1749
+ workspaceKeyRunsTotal: number;
1685
1750
  };
1686
1751
  AiToolSeatDto: {
1687
1752
  externalId: string;
@@ -2449,6 +2514,11 @@ export interface components {
2449
2514
  createdAt: string;
2450
2515
  /** Format: date-time */
2451
2516
  finishedAt: string | null;
2517
+ /**
2518
+ * @description Which Cursor execution key was used for this run. `workspace_execution_token`: workspace provided its own execution key. `platform_env_key`: ThinkAI platform key was used (opt-in required; additional cost applies). `null`: run did not reach the Cursor agent stage.
2519
+ * @enum {string|null}
2520
+ */
2521
+ cursorKeySource?: "workspace_execution_token" | "platform_env_key" | null;
2452
2522
  };
2453
2523
  ReadinessCriteriaSummaryDto: {
2454
2524
  total: number;
@@ -2505,10 +2575,17 @@ export interface components {
2505
2575
  /** @description Pass as `cursor` query param to fetch the next page; null when no more rows. */
2506
2576
  nextCursor: string | null;
2507
2577
  };
2578
+ ReadinessScoreHistoryDimensionScoreDto: {
2579
+ dimensionId: components["schemas"]["ReadinessDimensionId"];
2580
+ /** @description Dimension score as a percentage (0–100) for this scan run. */
2581
+ scorePercent: number;
2582
+ };
2508
2583
  ReadinessScoreHistoryPointDto: {
2509
2584
  /** Format: date-time */
2510
2585
  finishedAt: string;
2511
2586
  overallScore: number;
2587
+ /** @description Per-dimension percentages captured on this scan run. */
2588
+ dimensionScores?: components["schemas"]["ReadinessScoreHistoryDimensionScoreDto"][];
2512
2589
  };
2513
2590
  ReadinessRepoScoreHistoryDto: {
2514
2591
  /** Format: uuid */
@@ -3031,9 +3108,11 @@ export type OrgChartImportResultDto = components['schemas']['OrgChartImportResul
3031
3108
  export type OrgChartSaveResultDto = components['schemas']['OrgChartSaveResultDto'];
3032
3109
  export type TenantSourceEntryDto = components['schemas']['TenantSourceEntryDto'];
3033
3110
  export type CursorSourceDto = components['schemas']['CursorSourceDto'];
3111
+ export type CursorSourceConfigDto = components['schemas']['CursorSourceConfigDto'];
3034
3112
  export type ClaudeSourceDto = components['schemas']['ClaudeSourceDto'];
3035
3113
  export type WorkspaceConfigDto = components['schemas']['WorkspaceConfigDto'];
3036
3114
  export type TestConnectionResponseDto = components['schemas']['TestConnectionResponseDto'];
3115
+ export type CursorKeyUsageDto = components['schemas']['CursorKeyUsageDto'];
3037
3116
  export type AiToolSeatDto = components['schemas']['AiToolSeatDto'];
3038
3117
  export type AiToolDailyUsageRowDto = components['schemas']['AiToolDailyUsageRowDto'];
3039
3118
  export type AiToolSpendRowDto = components['schemas']['AiToolSpendRowDto'];
@@ -3118,6 +3197,7 @@ export type ReadinessIssueDto = components['schemas']['ReadinessIssueDto'];
3118
3197
  export type DimensionScoreDto = components['schemas']['DimensionScoreDto'];
3119
3198
  export type ReadinessRepoRunHistoryItemDto = components['schemas']['ReadinessRepoRunHistoryItemDto'];
3120
3199
  export type ReadinessRepoRunListDto = components['schemas']['ReadinessRepoRunListDto'];
3200
+ export type ReadinessScoreHistoryDimensionScoreDto = components['schemas']['ReadinessScoreHistoryDimensionScoreDto'];
3121
3201
  export type ReadinessScoreHistoryPointDto = components['schemas']['ReadinessScoreHistoryPointDto'];
3122
3202
  export type ReadinessRepoScoreHistoryDto = components['schemas']['ReadinessRepoScoreHistoryDto'];
3123
3203
  export type WorkspaceReadinessScoreHistoryDto = components['schemas']['WorkspaceReadinessScoreHistoryDto'];
@@ -6362,6 +6442,72 @@ export interface operations {
6362
6442
  };
6363
6443
  };
6364
6444
  };
6445
+ putCursorPlatformKeyConsent: {
6446
+ parameters: {
6447
+ query?: never;
6448
+ header?: never;
6449
+ path: {
6450
+ workspaceId: components["parameters"]["WorkspaceId"];
6451
+ };
6452
+ cookie?: never;
6453
+ };
6454
+ requestBody: {
6455
+ content: {
6456
+ "application/json": {
6457
+ /** @description true to opt in to ThinkAI platform Cursor key (additional cost applies); false to opt out. */
6458
+ enabled: boolean;
6459
+ };
6460
+ };
6461
+ };
6462
+ responses: {
6463
+ /** @description Consent updated */
6464
+ 200: {
6465
+ headers: {
6466
+ [name: string]: unknown;
6467
+ };
6468
+ content: {
6469
+ "application/json": {
6470
+ ok: boolean;
6471
+ };
6472
+ };
6473
+ };
6474
+ /** @description Invalid request body */
6475
+ 400: {
6476
+ headers: {
6477
+ [name: string]: unknown;
6478
+ };
6479
+ content: {
6480
+ "application/json": components["schemas"]["ErrorMessageDto"];
6481
+ };
6482
+ };
6483
+ 401: components["responses"]["Unauthorized"];
6484
+ 403: components["responses"]["Forbidden"];
6485
+ };
6486
+ };
6487
+ getCursorKeyUsage: {
6488
+ parameters: {
6489
+ query?: never;
6490
+ header?: never;
6491
+ path: {
6492
+ workspaceId: components["parameters"]["WorkspaceId"];
6493
+ };
6494
+ cookie?: never;
6495
+ };
6496
+ requestBody?: never;
6497
+ responses: {
6498
+ /** @description Cursor key usage stats */
6499
+ 200: {
6500
+ headers: {
6501
+ [name: string]: unknown;
6502
+ };
6503
+ content: {
6504
+ "application/json": components["schemas"]["CursorKeyUsageDto"];
6505
+ };
6506
+ };
6507
+ 401: components["responses"]["Unauthorized"];
6508
+ 403: components["responses"]["Forbidden"];
6509
+ };
6510
+ };
6365
6511
  getSquad: {
6366
6512
  parameters: {
6367
6513
  query?: never;