@thinkai/tai-api-contract 2.7.3 → 2.8.1

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.
@@ -471,8 +471,8 @@ paths:
471
471
 
472
472
  **Typical outcomes:** Valid typed sources → `200` with `{ ok: true, workspaceId }`. Missing required
473
473
  fields for a given `type` → `400` with `error` text.
474
- Unknown `type` strings (non-cursor, non-github) currently pass through to storage (lenient compatibility); only `cursor`
475
- entries get strict field validation. Cursor sources enforce strict token shape (no whitespace, no `env:` prefix).
474
+ Unknown `type` strings (non-AI-tool, non-github) currently pass through to storage (lenient compatibility).
475
+ Registered AI tools (`cursor`, `claude`) get strict field validation (no whitespace, no `env:` prefix on tokens).
476
476
  operationId: putTenantSources
477
477
  parameters:
478
478
  - $ref: "#/components/parameters/WorkspaceId"
@@ -489,6 +489,7 @@ paths:
489
489
  items:
490
490
  anyOf:
491
491
  - $ref: "#/components/schemas/CursorSourceDto"
492
+ - $ref: "#/components/schemas/ClaudeSourceDto"
492
493
  - $ref: "#/components/schemas/TenantSourceEntryDto"
493
494
  examples:
494
495
  cursorAndJira:
@@ -564,15 +565,16 @@ paths:
564
565
  200 — upstream auth, rate-limit, and network failures surface as
565
566
  `{ success: false, error }` so the SPA can render an inline error.
566
567
 
567
- Currently only `type: cursor` is verified end-to-end (Cursor Admin API,
568
- HTTP Basic against `https://api.cursor.com`; optional `baseUrl` in the body is deprecated and ignored).
569
- Other types report
568
+ Registered AI tools are verified end-to-end: `cursor` (Cursor Admin API at
569
+ `https://api.cursor.com`, HTTP Basic; optional `baseUrl` is deprecated and ignored) and
570
+ `claude` (Anthropic Admin API at `https://api.anthropic.com`, `X-Api-Key` with an
571
+ organization Admin API key `sk-ant-admin...`). Other types report
570
572
  `{ success: false, error: "unsupported_type" }`. Documented `error`
571
- codes for cursor: `invalid_token`, `rate_limited`, `network_error`.
573
+ codes for AI tool verifiers: `invalid_token`, `rate_limited`, `network_error`.
572
574
 
573
575
  **Typical outcomes:** Malformed body, missing `type`, invalid `type`, or missing required fields for the
574
576
  declared type → `400` with `{ error: "..." }`. Well-formed body with bad credentials or unreachable
575
- service → `200` with `{ success: false, error: "..." }` (Cursor verifier and non-cursor paths as documented above).
577
+ service → `200` with `{ success: false, error: "..." }`.
576
578
  operationId: postTenantSourceTest
577
579
  parameters:
578
580
  - $ref: "#/components/parameters/WorkspaceId"
@@ -583,6 +585,7 @@ paths:
583
585
  schema:
584
586
  anyOf:
585
587
  - $ref: "#/components/schemas/CursorSourceDto"
588
+ - $ref: "#/components/schemas/ClaudeSourceDto"
586
589
  - $ref: "#/components/schemas/TenantSourceEntryDto"
587
590
  examples:
588
591
  cursorValid:
@@ -590,8 +593,13 @@ paths:
590
593
  value:
591
594
  type: cursor
592
595
  token: cursor_api_key_example
596
+ claudeValid:
597
+ summary: Claude (Anthropic Admin API) source for connection test
598
+ value:
599
+ type: claude
600
+ token: sk-ant-admin-example-key
593
601
  githubShape:
594
- summary: GitHub-shaped body (non-cursor types return unsupported_type unless extended)
602
+ summary: GitHub-shaped body (non-AI-tool types return unsupported_type unless extended)
595
603
  value:
596
604
  type: github
597
605
  owner: org
@@ -611,7 +619,7 @@ paths:
611
619
  failure:
612
620
  value:
613
621
  success: false
614
- error: invalid_token
622
+ error: "invalid_token"
615
623
  "400":
616
624
  description: Invalid body or missing env for token refs
617
625
  content:
@@ -1686,7 +1694,7 @@ paths:
1686
1694
  required: true
1687
1695
  schema:
1688
1696
  type: string
1689
- enum: [cursor]
1697
+ enum: [cursor, claude]
1690
1698
  responses:
1691
1699
  "200":
1692
1700
  description: Refresh result
@@ -1698,7 +1706,7 @@ paths:
1698
1706
  ok:
1699
1707
  value: { ok: true }
1700
1708
  invalid_token:
1701
- value: { ok: false, error: invalid_token }
1709
+ value: { ok: false, error: "invalid_token" }
1702
1710
  "401":
1703
1711
  $ref: "#/components/responses/Unauthorized"
1704
1712
  "403":
@@ -1711,7 +1719,7 @@ paths:
1711
1719
  $ref: "#/components/schemas/AiToolRefreshResponseDto"
1712
1720
  example:
1713
1721
  ok: false
1714
- error: no_source
1722
+ error: "no_source"
1715
1723
  "409":
1716
1724
  description: Refresh already in progress
1717
1725
  content:
@@ -1720,7 +1728,7 @@ paths:
1720
1728
  $ref: "#/components/schemas/AiToolRefreshResponseDto"
1721
1729
  example:
1722
1730
  ok: false
1723
- error: already_in_progress
1731
+ error: "already_in_progress"
1724
1732
 
1725
1733
  /workspaces/{workspaceId}/integrations/ai-tool/{provider}/seats:
1726
1734
  get:
@@ -1734,7 +1742,7 @@ paths:
1734
1742
  required: true
1735
1743
  schema:
1736
1744
  type: string
1737
- enum: [cursor]
1745
+ enum: [cursor, claude]
1738
1746
  responses:
1739
1747
  "200":
1740
1748
  description: Seats
@@ -1765,7 +1773,7 @@ paths:
1765
1773
  required: true
1766
1774
  schema:
1767
1775
  type: string
1768
- enum: [cursor]
1776
+ enum: [cursor, claude]
1769
1777
  - name: from
1770
1778
  in: query
1771
1779
  required: false
@@ -1813,7 +1821,7 @@ paths:
1813
1821
  required: true
1814
1822
  schema:
1815
1823
  type: string
1816
- enum: [cursor]
1824
+ enum: [cursor, claude]
1817
1825
  - name: cycleStartMs
1818
1826
  in: query
1819
1827
  required: false
@@ -1850,7 +1858,7 @@ paths:
1850
1858
  required: true
1851
1859
  schema:
1852
1860
  type: string
1853
- enum: [cursor]
1861
+ enum: [cursor, claude]
1854
1862
  responses:
1855
1863
  "200":
1856
1864
  description: Refresh status
@@ -1874,7 +1882,7 @@ paths:
1874
1882
  $ref: "#/components/schemas/AiToolRefreshResponseDto"
1875
1883
  example:
1876
1884
  ok: false
1877
- error: no_source
1885
+ error: "no_source"
1878
1886
 
1879
1887
  /integrations/github/callback:
1880
1888
  get:
@@ -2348,6 +2356,109 @@ paths:
2348
2356
  schema:
2349
2357
  $ref: "#/components/schemas/ErrorMessageDto"
2350
2358
 
2359
+ /workspaces/{workspaceId}/readiness/repos/{repoId}/runs:
2360
+ get:
2361
+ tags: [RepositoryReadiness]
2362
+ summary: Paginated readiness run history for one repository
2363
+ description: >
2364
+ Append-only scan history for charts on repo detail. Ordered by scan finish time
2365
+ (or `createdAt` when still in progress). Use `cursor` from the previous response for
2366
+ the next page. Failed and `partial_failed` runs are included with nullable `overallScore`.
2367
+ operationId: listReadinessRepoRuns
2368
+ parameters:
2369
+ - $ref: "#/components/parameters/WorkspaceId"
2370
+ - $ref: "#/components/parameters/RepoId"
2371
+ - name: limit
2372
+ in: query
2373
+ schema:
2374
+ type: integer
2375
+ minimum: 1
2376
+ maximum: 100
2377
+ default: 25
2378
+ - name: order
2379
+ in: query
2380
+ schema:
2381
+ type: string
2382
+ enum: [asc, desc]
2383
+ default: desc
2384
+ - name: cursor
2385
+ in: query
2386
+ description: Opaque cursor from a prior response `nextCursor` field.
2387
+ schema:
2388
+ type: string
2389
+ responses:
2390
+ "200":
2391
+ description: Run history page
2392
+ content:
2393
+ application/json:
2394
+ schema:
2395
+ $ref: "#/components/schemas/ReadinessRepoRunListDto"
2396
+ "400":
2397
+ description: Invalid pagination query
2398
+ content:
2399
+ application/json:
2400
+ schema:
2401
+ $ref: "#/components/schemas/ErrorMessageDto"
2402
+ "401":
2403
+ $ref: "#/components/responses/Unauthorized"
2404
+ "403":
2405
+ $ref: "#/components/responses/Forbidden"
2406
+ "404":
2407
+ description: Workspace or repository not found
2408
+ content:
2409
+ application/json:
2410
+ schema:
2411
+ $ref: "#/components/schemas/ErrorMessageDto"
2412
+
2413
+ /workspaces/{workspaceId}/readiness/score-history:
2414
+ get:
2415
+ tags: [RepositoryReadiness]
2416
+ summary: Workspace score time-series for all repositories
2417
+ description: >
2418
+ Returns succeeded runs with stored `overallScore` per repo in one call (avoids N+1).
2419
+ Points are ordered ascending by `finishedAt` within each repo. Omit failed and
2420
+ `partial_failed` runs. Use `since` to bound the window; `limitPerRepo` caps points per repo
2421
+ (most recent first, then returned oldest-to-newest within the cap).
2422
+ operationId: getReadinessScoreHistory
2423
+ parameters:
2424
+ - $ref: "#/components/parameters/WorkspaceId"
2425
+ - name: since
2426
+ in: query
2427
+ description: ISO-8601 lower bound on `finishedAt` (inclusive).
2428
+ schema:
2429
+ type: string
2430
+ format: date-time
2431
+ - name: limitPerRepo
2432
+ in: query
2433
+ schema:
2434
+ type: integer
2435
+ minimum: 1
2436
+ maximum: 200
2437
+ default: 50
2438
+ responses:
2439
+ "200":
2440
+ description: Score history grouped by repository
2441
+ content:
2442
+ application/json:
2443
+ schema:
2444
+ $ref: "#/components/schemas/WorkspaceReadinessScoreHistoryDto"
2445
+ "400":
2446
+ description: Invalid query
2447
+ content:
2448
+ application/json:
2449
+ schema:
2450
+ $ref: "#/components/schemas/ErrorMessageDto"
2451
+ "401":
2452
+ $ref: "#/components/responses/Unauthorized"
2453
+ "403":
2454
+ $ref: "#/components/responses/Forbidden"
2455
+ "404":
2456
+ description: Workspace does not exist
2457
+ content:
2458
+ application/json:
2459
+ schema:
2460
+ $ref: "#/components/schemas/ErrorMessageDto"
2461
+
2351
2462
  /workspaces/{workspaceId}/agentic-foundation/dashboard:
2352
2463
  get:
2353
2464
  tags: [AgenticFoundation]
@@ -2439,6 +2550,7 @@ paths:
2439
2550
  maxScore: 3
2440
2551
  issues: []
2441
2552
  lastAnalyzed: "2026-05-12T12:00:00.000Z"
2553
+ connectedAt: "2026-05-01T10:00:00.000Z"
2442
2554
  teamId: null
2443
2555
  provider:
2444
2556
  kind: github
@@ -3929,6 +4041,29 @@ components:
3929
4041
  and always uses the Cursor Admin API host. Kept so older clients can submit payloads unchanged.
3930
4042
  default: "https://api.cursor.com"
3931
4043
 
4044
+ ClaudeSourceDto:
4045
+ type: object
4046
+ description: >
4047
+ Claude (Anthropic) source entry for `PUT /workspaces/{workspaceId}/sources`
4048
+ and `POST /workspaces/{workspaceId}/sources/test`. The `token` field
4049
+ carries a literal Organization Admin API key on writes (`sk-ant-admin...`);
4050
+ reads from `GET /workspaces/{workspaceId}/config` redact it to `***`.
4051
+ Runtime calls use the Anthropic Admin API at `https://api.anthropic.com`.
4052
+ Provision keys in Claude Console → Organization settings (admin role required).
4053
+ required: [type, token]
4054
+ additionalProperties: false
4055
+ properties:
4056
+ type:
4057
+ type: string
4058
+ enum: [claude]
4059
+ token:
4060
+ type: string
4061
+ minLength: 1
4062
+ maxLength: 512
4063
+ description: >
4064
+ Anthropic Organization Admin API key (literal, must start with sk-ant-admin).
4065
+ Standard API keys (sk-ant-api...) are rejected. Whitespace and `env:` prefix are rejected.
4066
+
3932
4067
  WorkspaceConfigDto:
3933
4068
  type: object
3934
4069
  required: [sources]
@@ -5658,6 +5793,92 @@ components:
5658
5793
  items:
5659
5794
  $ref: "#/components/schemas/ReadinessIssueDto"
5660
5795
 
5796
+ ReadinessRepoRunHistoryItemDto:
5797
+ type: object
5798
+ required: [runId, status, overallScore, createdAt, finishedAt]
5799
+ properties:
5800
+ runId:
5801
+ type: string
5802
+ format: uuid
5803
+ status:
5804
+ $ref: "#/components/schemas/ReadinessRunStatusDto"
5805
+ overallScore:
5806
+ type: integer
5807
+ minimum: 0
5808
+ maximum: 100
5809
+ nullable: true
5810
+ description: Present for succeeded runs after migration 050; null otherwise.
5811
+ createdAt:
5812
+ type: string
5813
+ format: date-time
5814
+ finishedAt:
5815
+ type: string
5816
+ format: date-time
5817
+ nullable: true
5818
+
5819
+ ReadinessRepoRunListDto:
5820
+ type: object
5821
+ required: [items, limit, nextCursor]
5822
+ properties:
5823
+ items:
5824
+ type: array
5825
+ items:
5826
+ $ref: "#/components/schemas/ReadinessRepoRunHistoryItemDto"
5827
+ limit:
5828
+ type: integer
5829
+ minimum: 1
5830
+ maximum: 100
5831
+ nextCursor:
5832
+ type: string
5833
+ nullable: true
5834
+ description: Pass as `cursor` query param to fetch the next page; null when no more rows.
5835
+
5836
+ ReadinessScoreHistoryPointDto:
5837
+ type: object
5838
+ required: [finishedAt, overallScore]
5839
+ properties:
5840
+ finishedAt:
5841
+ type: string
5842
+ format: date-time
5843
+ overallScore:
5844
+ type: integer
5845
+ minimum: 0
5846
+ maximum: 100
5847
+
5848
+ ReadinessRepoScoreHistoryDto:
5849
+ type: object
5850
+ required: [repoId, repoName, connectedAt, points]
5851
+ properties:
5852
+ repoId:
5853
+ type: string
5854
+ format: uuid
5855
+ repoName:
5856
+ type: string
5857
+ maxLength: 256
5858
+ connectedAt:
5859
+ type: string
5860
+ format: date-time
5861
+ description: When the repository was first materialized in the workspace (GitHub connect).
5862
+ points:
5863
+ type: array
5864
+ items:
5865
+ $ref: "#/components/schemas/ReadinessScoreHistoryPointDto"
5866
+
5867
+ WorkspaceReadinessScoreHistoryDto:
5868
+ type: object
5869
+ required: [workspaceId, generatedAt, repos]
5870
+ properties:
5871
+ workspaceId:
5872
+ type: string
5873
+ format: uuid
5874
+ generatedAt:
5875
+ type: string
5876
+ format: date-time
5877
+ repos:
5878
+ type: array
5879
+ items:
5880
+ $ref: "#/components/schemas/ReadinessRepoScoreHistoryDto"
5881
+
5661
5882
  RepoReadinessScoreDto:
5662
5883
  type: object
5663
5884
  required:
@@ -5667,6 +5888,7 @@ components:
5667
5888
  - overallScore
5668
5889
  - dimensions
5669
5890
  - lastAnalyzed
5891
+ - connectedAt
5670
5892
  - provider
5671
5893
  - analysisStatus
5672
5894
  properties:
@@ -5691,6 +5913,10 @@ components:
5691
5913
  lastAnalyzed:
5692
5914
  type: string
5693
5915
  format: date-time
5916
+ connectedAt:
5917
+ type: string
5918
+ format: date-time
5919
+ description: First time this repository was materialized in the workspace (GitHub connect).
5694
5920
  teamId:
5695
5921
  type: string
5696
5922
  format: uuid
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkai/tai-api-contract",
3
- "version": "2.7.3",
3
+ "version": "2.8.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",