@thinkai/tai-api-contract 2.78.0 → 2.80.0-pr.976.4c124f8a

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.
@@ -1203,6 +1203,66 @@ export interface paths {
1203
1203
  patch?: never;
1204
1204
  trace?: never;
1205
1205
  };
1206
+ "/workspaces/{workspaceId}/insights/code/summary": {
1207
+ parameters: {
1208
+ query?: never;
1209
+ header?: never;
1210
+ path?: never;
1211
+ cookie?: never;
1212
+ };
1213
+ /**
1214
+ * Code Insights — org summary
1215
+ * @description Org-level Code Insights summary for `/insights/code`. Aggregates each active repo's **latest** deterministic metrics row (unweighted medians — mega-repos are not down-weighted, by design), findings counts by severity across latest scans, the org top-10 complexity hotspots, and org-level SonarQube coverage/tech-debt-ratio when a SonarQube source is connected (per-repo Sonar mapping is v2). Reads stored scan outputs only — never recomputes on request.
1216
+ */
1217
+ get: operations["getCodeInsightsSummary"];
1218
+ put?: never;
1219
+ post?: never;
1220
+ delete?: never;
1221
+ options?: never;
1222
+ head?: never;
1223
+ patch?: never;
1224
+ trace?: never;
1225
+ };
1226
+ "/workspaces/{workspaceId}/insights/code/repos": {
1227
+ parameters: {
1228
+ query?: never;
1229
+ header?: never;
1230
+ path?: never;
1231
+ cookie?: never;
1232
+ };
1233
+ /**
1234
+ * Code Insights — per-repo metrics list (paginated)
1235
+ * @description Page of active (not user-archived) repos with their latest code-quality metrics, threshold badges, and finding counts. Repos without a completed metrics scan appear with `metricsStatus` absent/`null` ("pending first scan").
1236
+ */
1237
+ get: operations["listCodeInsightsRepos"];
1238
+ put?: never;
1239
+ post?: never;
1240
+ delete?: never;
1241
+ options?: never;
1242
+ head?: never;
1243
+ patch?: never;
1244
+ trace?: never;
1245
+ };
1246
+ "/workspaces/{workspaceId}/insights/code/repos/{repoId}": {
1247
+ parameters: {
1248
+ query?: never;
1249
+ header?: never;
1250
+ path?: never;
1251
+ cookie?: never;
1252
+ };
1253
+ /**
1254
+ * Code Insights — repo detail (metrics, hotspots, findings)
1255
+ * @description Single-repo Code Insights detail: latest metrics row with per-metric provenance, current hotspot snapshot (top-N worst files), and the findings computed by the latest scan. `metrics` is `null` when the repo is pending its first metrics scan.
1256
+ */
1257
+ get: operations["getCodeInsightsRepoDetail"];
1258
+ put?: never;
1259
+ post?: never;
1260
+ delete?: never;
1261
+ options?: never;
1262
+ head?: never;
1263
+ patch?: never;
1264
+ trace?: never;
1265
+ };
1206
1266
  "/workspaces/{workspaceId}/integrations/ai-tool/{provider}/members": {
1207
1267
  parameters: {
1208
1268
  query?: never;
@@ -7520,6 +7580,172 @@ export interface components {
7520
7580
  }[];
7521
7581
  snippets: string[];
7522
7582
  };
7583
+ /**
7584
+ * @description Where a metric value came from: `measured` (direct tool output), `derived` (computed from measured inputs, e.g. the maintainability band), `estimated` (heuristic proxy, e.g. test-to-source ratio), or `unavailable` (tool missing/failed, or the language is unsupported). Keyed per metric in `CodeInsightsMetricsDto.provenance`.
7585
+ * @enum {string}
7586
+ */
7587
+ CodeInsightsMetricProvenance: "measured" | "derived" | "estimated" | "unavailable";
7588
+ /**
7589
+ * @description CC/LOC-derived maintainability band (documented heuristic, not Halstead MI).
7590
+ * @enum {string}
7591
+ */
7592
+ CodeInsightsMaintainabilityBand: "green" | "yellow" | "red";
7593
+ /**
7594
+ * @description Outcome of the repo's latest metrics scan: `ok` (at least one tool measured), `failed` (every tool failed — metric fields are null with `unavailable` provenance), `skipped` (stage ran but found no measurable source).
7595
+ * @enum {string}
7596
+ */
7597
+ CodeInsightsMetricsStatus: "ok" | "failed" | "skipped";
7598
+ /** @enum {string} */
7599
+ CodeInsightsFindingSeverity: "critical" | "high" | "medium" | "low";
7600
+ /**
7601
+ * @description Deterministic categories (`duplication`, `complexity`, `proliferation`, `coverage`) plus LLM semantic detectors (`anemic_domain`, `context_leak`, `tx_boundary`, `error_handling`).
7602
+ * @enum {string}
7603
+ */
7604
+ CodeInsightsFindingCategory: "duplication" | "complexity" | "proliferation" | "coverage" | "anemic_domain" | "context_leak" | "tx_boundary" | "error_handling";
7605
+ /**
7606
+ * @description `deterministic` = measured Code Insights rules; `llm` = AI-detected semantic findings (separate agent pass; never blended in scoring).
7607
+ * @enum {string}
7608
+ */
7609
+ CodeInsightsFindingSource: "deterministic" | "llm";
7610
+ CodeInsightsMetricsDto: {
7611
+ /** @description Readiness run that produced this metrics row. */
7612
+ runId: string;
7613
+ /** Format: date-time */
7614
+ measuredAt: string;
7615
+ metricsStatus: components["schemas"]["CodeInsightsMetricsStatus"];
7616
+ locTotal?: number | null;
7617
+ filesTotal?: number | null;
7618
+ /** @description Mean cyclomatic complexity across analyzed functions. */
7619
+ ccAvg?: number | null;
7620
+ ccMax?: number | null;
7621
+ /** @description 90th percentile function cyclomatic complexity (nearest-rank). */
7622
+ ccP90?: number | null;
7623
+ /** @description Duplicated lines as a percentage of analyzed lines (0–100). */
7624
+ dupPct?: number | null;
7625
+ maintainabilityBand?: components["schemas"]["CodeInsightsMaintainabilityBand"] | null;
7626
+ /** @description Reserved for per-repo SonarQube enrichment (v2); null in v1. */
7627
+ coveragePct?: number | null;
7628
+ /** @description Reserved for per-repo SonarQube enrichment (v2); null in v1. */
7629
+ debtRatio?: number | null;
7630
+ /** @description Heuristic structure counters: dto/mapper/config/exception file + LOC counts, test/source LOC split, per-language LOC, functions_analyzed, test_ratio, dto_mapper_share_pct. */
7631
+ structureCounts: {
7632
+ [key: string]: unknown;
7633
+ };
7634
+ /** @description Per-metric provenance keyed by DTO field name (e.g. `ccAvg`, `dupPct`, `testRatio`). */
7635
+ provenance: {
7636
+ [key: string]: components["schemas"]["CodeInsightsMetricProvenance"];
7637
+ };
7638
+ /** @description Tool name → version string for the tools that produced this row. */
7639
+ toolVersions: {
7640
+ [key: string]: string;
7641
+ };
7642
+ };
7643
+ CodeInsightsHotspotDto: {
7644
+ /** @description Repo-relative file path. */
7645
+ filePath: string;
7646
+ loc?: number | null;
7647
+ /** @description Max function cyclomatic complexity in the file. */
7648
+ ccMax?: number | null;
7649
+ paramsMax?: number | null;
7650
+ /** @description Max nested control structures (null when the analyzer does not report nesting). */
7651
+ nestingMax?: number | null;
7652
+ /** @description Estimated per-file duplicated line share (0–100). */
7653
+ dupPct?: number | null;
7654
+ /** @description Subset of `god_file`, `high_cc`, `long_params`, `deep_nesting`. */
7655
+ flags: string[];
7656
+ };
7657
+ CodeInsightsFindingDto: {
7658
+ /** Format: uuid */
7659
+ id: string;
7660
+ severity: components["schemas"]["CodeInsightsFindingSeverity"];
7661
+ category: components["schemas"]["CodeInsightsFindingCategory"];
7662
+ title: string;
7663
+ explanation: string;
7664
+ /** @description Measured values and thresholds backing the finding. */
7665
+ evidence: {
7666
+ [key: string]: unknown;
7667
+ };
7668
+ remediation?: string | null;
7669
+ source: components["schemas"]["CodeInsightsFindingSource"];
7670
+ runId: string;
7671
+ /** Format: date-time */
7672
+ createdAt: string;
7673
+ };
7674
+ CodeInsightsFindingsBySeverityDto: {
7675
+ critical: number;
7676
+ high: number;
7677
+ medium: number;
7678
+ low: number;
7679
+ };
7680
+ CodeInsightsRepoListItemDto: {
7681
+ /** Format: uuid */
7682
+ repoId: string;
7683
+ repoName: string;
7684
+ language: string;
7685
+ /** @description owner/repo on the VCS provider. */
7686
+ providerSlug: string;
7687
+ webUrl: string;
7688
+ /**
7689
+ * Format: date-time
7690
+ * @description Null when the repo is pending its first metrics scan.
7691
+ */
7692
+ lastMeasuredAt?: string | null;
7693
+ metricsStatus?: components["schemas"]["CodeInsightsMetricsStatus"] | null;
7694
+ locTotal?: number | null;
7695
+ ccAvg?: number | null;
7696
+ ccMax?: number | null;
7697
+ dupPct?: number | null;
7698
+ maintainabilityBand?: components["schemas"]["CodeInsightsMaintainabilityBand"] | null;
7699
+ /** @description Active threshold badges from the latest scan: subset of `god_files`, `high_complexity`, `duplication`, `proliferation`, `low_test_ratio`. */
7700
+ badges: string[];
7701
+ findingsBySeverity: components["schemas"]["CodeInsightsFindingsBySeverityDto"];
7702
+ provenance: {
7703
+ [key: string]: components["schemas"]["CodeInsightsMetricProvenance"];
7704
+ };
7705
+ };
7706
+ CodeInsightsRepoListDto: components["schemas"]["PageMetaDto"] & {
7707
+ items: components["schemas"]["CodeInsightsRepoListItemDto"][];
7708
+ };
7709
+ CodeInsightsRepoDetailDto: {
7710
+ /** Format: uuid */
7711
+ repoId: string;
7712
+ repoName: string;
7713
+ language: string;
7714
+ providerSlug: string;
7715
+ webUrl: string;
7716
+ /** @description Null when the repo is pending its first metrics scan. */
7717
+ metrics: components["schemas"]["CodeInsightsMetricsDto"] | null;
7718
+ hotspots: components["schemas"]["CodeInsightsHotspotDto"][];
7719
+ /** @description Findings from the latest scan only (history is retention-bounded). */
7720
+ findings: components["schemas"]["CodeInsightsFindingDto"][];
7721
+ };
7722
+ CodeInsightsOrgHotspotDto: components["schemas"]["CodeInsightsHotspotDto"] & {
7723
+ /** Format: uuid */
7724
+ repoId: string;
7725
+ repoName: string;
7726
+ };
7727
+ CodeInsightsSonarDto: {
7728
+ /** @description Whether a SonarQube source is configured for the workspace. */
7729
+ connected: boolean;
7730
+ /** @description Org-level SonarQube coverage from the latest precomputed quality snapshot. */
7731
+ coveragePct?: number | null;
7732
+ /** @description Org-level SonarQube SQALE technical debt ratio from the latest quality snapshot. */
7733
+ techDebtRatioPct?: number | null;
7734
+ };
7735
+ CodeInsightsSummaryDto: {
7736
+ /** @description Active repos whose latest metrics scan completed (`ok`). */
7737
+ reposMeasured: number;
7738
+ /** @description Active repos without a completed metrics scan (never scanned, or only failed/skipped). */
7739
+ reposPending: number;
7740
+ /** @description Unweighted median of latest `ccAvg` across measured repos (null when none measured). */
7741
+ ccAvgMedian?: number | null;
7742
+ /** @description Unweighted median of latest `dupPct` across measured repos (null when none measured). */
7743
+ dupPctMedian?: number | null;
7744
+ findingsBySeverity: components["schemas"]["CodeInsightsFindingsBySeverityDto"];
7745
+ /** @description Org top-10 complexity hotspots by `ccMax` (current per-repo snapshots). */
7746
+ topHotspots: components["schemas"]["CodeInsightsOrgHotspotDto"][];
7747
+ sonar: components["schemas"]["CodeInsightsSonarDto"];
7748
+ };
7523
7749
  };
7524
7750
  responses: {
7525
7751
  /** @description Missing or invalid bearer token */
@@ -7603,6 +7829,10 @@ export interface components {
7603
7829
  PaginationOrder: "asc" | "desc";
7604
7830
  /** @description Allowlisted repository sort field. */
7605
7831
  ReadinessRepoSort: "repoName" | "overallScore" | "lastAnalyzed" | "language";
7832
+ /** @description Allowlisted Code Insights repo sort field. */
7833
+ CodeInsightsRepoSort: "repoName" | "locTotal" | "ccAvg" | "dupPct" | "lastMeasuredAt";
7834
+ /** @description Case-insensitive substring filter on repo name / provider slug. */
7835
+ CodeInsightsRepoSearch: string;
7606
7836
  /** @description Case-insensitive filter on repository name, language, or provider slug. */
7607
7837
  ReadinessRepoSearch: string;
7608
7838
  /** @description Exact language filter (e.g. `typescript`). */
@@ -8013,6 +8243,22 @@ export type CodeChatCrossEdgesBodyDto = components['schemas']['CodeChatCrossEdge
8013
8243
  export type CodeChatCrossEdgesResultDto = components['schemas']['CodeChatCrossEdgesResultDto'];
8014
8244
  export type CodeChatContextPackBodyDto = components['schemas']['CodeChatContextPackBodyDto'];
8015
8245
  export type CodeChatContextPackDto = components['schemas']['CodeChatContextPackDto'];
8246
+ export type CodeInsightsMetricProvenance = components['schemas']['CodeInsightsMetricProvenance'];
8247
+ export type CodeInsightsMaintainabilityBand = components['schemas']['CodeInsightsMaintainabilityBand'];
8248
+ export type CodeInsightsMetricsStatus = components['schemas']['CodeInsightsMetricsStatus'];
8249
+ export type CodeInsightsFindingSeverity = components['schemas']['CodeInsightsFindingSeverity'];
8250
+ export type CodeInsightsFindingCategory = components['schemas']['CodeInsightsFindingCategory'];
8251
+ export type CodeInsightsFindingSource = components['schemas']['CodeInsightsFindingSource'];
8252
+ export type CodeInsightsMetricsDto = components['schemas']['CodeInsightsMetricsDto'];
8253
+ export type CodeInsightsHotspotDto = components['schemas']['CodeInsightsHotspotDto'];
8254
+ export type CodeInsightsFindingDto = components['schemas']['CodeInsightsFindingDto'];
8255
+ export type CodeInsightsFindingsBySeverityDto = components['schemas']['CodeInsightsFindingsBySeverityDto'];
8256
+ export type CodeInsightsRepoListItemDto = components['schemas']['CodeInsightsRepoListItemDto'];
8257
+ export type CodeInsightsRepoListDto = components['schemas']['CodeInsightsRepoListDto'];
8258
+ export type CodeInsightsRepoDetailDto = components['schemas']['CodeInsightsRepoDetailDto'];
8259
+ export type CodeInsightsOrgHotspotDto = components['schemas']['CodeInsightsOrgHotspotDto'];
8260
+ export type CodeInsightsSonarDto = components['schemas']['CodeInsightsSonarDto'];
8261
+ export type CodeInsightsSummaryDto = components['schemas']['CodeInsightsSummaryDto'];
8016
8262
  export type ResponseUnauthorized = components['responses']['Unauthorized'];
8017
8263
  export type ResponseForbidden = components['responses']['Forbidden'];
8018
8264
  export type ResponseZenHrSyncInProgress = components['responses']['ZenHrSyncInProgress'];
@@ -8042,6 +8288,8 @@ export type ParameterPaginationLimit = components['parameters']['PaginationLimit
8042
8288
  export type ParameterPaginationOffset = components['parameters']['PaginationOffset'];
8043
8289
  export type ParameterPaginationOrder = components['parameters']['PaginationOrder'];
8044
8290
  export type ParameterReadinessRepoSort = components['parameters']['ReadinessRepoSort'];
8291
+ export type ParameterCodeInsightsRepoSort = components['parameters']['CodeInsightsRepoSort'];
8292
+ export type ParameterCodeInsightsRepoSearch = components['parameters']['CodeInsightsRepoSearch'];
8045
8293
  export type ParameterReadinessRepoSearch = components['parameters']['ReadinessRepoSearch'];
8046
8294
  export type ParameterReadinessRepoLanguage = components['parameters']['ReadinessRepoLanguage'];
8047
8295
  export type ParameterReadinessFixSort = components['parameters']['ReadinessFixSort'];
@@ -11384,6 +11632,135 @@ export interface operations {
11384
11632
  };
11385
11633
  };
11386
11634
  };
11635
+ getCodeInsightsSummary: {
11636
+ parameters: {
11637
+ query?: never;
11638
+ header?: never;
11639
+ path: {
11640
+ workspaceId: components["parameters"]["WorkspaceId"];
11641
+ };
11642
+ cookie?: never;
11643
+ };
11644
+ requestBody?: never;
11645
+ responses: {
11646
+ /** @description Code Insights org summary payload */
11647
+ 200: {
11648
+ headers: {
11649
+ [name: string]: unknown;
11650
+ };
11651
+ content: {
11652
+ "application/json": components["schemas"]["CodeInsightsSummaryDto"];
11653
+ };
11654
+ };
11655
+ 401: components["responses"]["Unauthorized"];
11656
+ 403: components["responses"]["Forbidden"];
11657
+ /** @description Workspace does not exist or malformed workspaceId */
11658
+ 404: {
11659
+ headers: {
11660
+ [name: string]: unknown;
11661
+ };
11662
+ content?: never;
11663
+ };
11664
+ };
11665
+ };
11666
+ listCodeInsightsRepos: {
11667
+ parameters: {
11668
+ query?: {
11669
+ /** @description Page size (default 25, max 100). */
11670
+ limit?: components["parameters"]["PaginationLimit"];
11671
+ /** @description Zero-based row offset into the filtered, sorted result set. */
11672
+ offset?: components["parameters"]["PaginationOffset"];
11673
+ /** @description Allowlisted Code Insights repo sort field. */
11674
+ sort?: components["parameters"]["CodeInsightsRepoSort"];
11675
+ /** @description Sort direction. */
11676
+ order?: components["parameters"]["PaginationOrder"];
11677
+ /** @description Case-insensitive substring filter on repo name / provider slug. */
11678
+ search?: components["parameters"]["CodeInsightsRepoSearch"];
11679
+ };
11680
+ header?: never;
11681
+ path: {
11682
+ workspaceId: components["parameters"]["WorkspaceId"];
11683
+ };
11684
+ cookie?: never;
11685
+ };
11686
+ requestBody?: never;
11687
+ responses: {
11688
+ /** @description Paginated repo code-quality metrics */
11689
+ 200: {
11690
+ headers: {
11691
+ [name: string]: unknown;
11692
+ };
11693
+ content: {
11694
+ "application/json": components["schemas"]["CodeInsightsRepoListDto"];
11695
+ };
11696
+ };
11697
+ /** @description Invalid pagination or sort query */
11698
+ 400: {
11699
+ headers: {
11700
+ [name: string]: unknown;
11701
+ };
11702
+ content: {
11703
+ "application/json": components["schemas"]["ErrorMessageDto"];
11704
+ };
11705
+ };
11706
+ 401: components["responses"]["Unauthorized"];
11707
+ 403: components["responses"]["Forbidden"];
11708
+ /** @description Workspace does not exist or malformed workspaceId */
11709
+ 404: {
11710
+ headers: {
11711
+ [name: string]: unknown;
11712
+ };
11713
+ content?: never;
11714
+ };
11715
+ };
11716
+ };
11717
+ getCodeInsightsRepoDetail: {
11718
+ parameters: {
11719
+ query?: {
11720
+ /** @description Optional filter for findings by source. Omit to return both deterministic and llm findings. */
11721
+ source?: components["schemas"]["CodeInsightsFindingSource"];
11722
+ };
11723
+ header?: never;
11724
+ path: {
11725
+ workspaceId: components["parameters"]["WorkspaceId"];
11726
+ /** @description Internal repo UUID (`tai_workspace_repos.id`). */
11727
+ repoId: string;
11728
+ };
11729
+ cookie?: never;
11730
+ };
11731
+ requestBody?: never;
11732
+ responses: {
11733
+ /** @description Repo code-quality detail payload */
11734
+ 200: {
11735
+ headers: {
11736
+ [name: string]: unknown;
11737
+ };
11738
+ content: {
11739
+ "application/json": components["schemas"]["CodeInsightsRepoDetailDto"];
11740
+ };
11741
+ };
11742
+ /** @description Malformed repoId */
11743
+ 400: {
11744
+ headers: {
11745
+ [name: string]: unknown;
11746
+ };
11747
+ content: {
11748
+ "application/json": components["schemas"]["ErrorMessageDto"];
11749
+ };
11750
+ };
11751
+ 401: components["responses"]["Unauthorized"];
11752
+ 403: components["responses"]["Forbidden"];
11753
+ /** @description Workspace or repo does not exist */
11754
+ 404: {
11755
+ headers: {
11756
+ [name: string]: unknown;
11757
+ };
11758
+ content: {
11759
+ "application/json": components["schemas"]["ErrorMessageDto"];
11760
+ };
11761
+ };
11762
+ };
11763
+ };
11387
11764
  getAiToolMembers: {
11388
11765
  parameters: {
11389
11766
  query?: {
package/src/index.ts CHANGED
@@ -328,6 +328,8 @@ export interface DashboardProductivityMetricsDto {
328
328
  }[];
329
329
  avgTimeToFixBuildHours?: number;
330
330
  testCoveragePercent?: number;
331
+ /** Technical debt ratio (SQALE, from SonarQube) as a percentage. */
332
+ techDebtRatioPercent?: number;
331
333
  escapedBugsCount?: number;
332
334
  /** Avg cyclomatic complexity (from SonarQube). */
333
335
  complexityAvg?: number;