@thinkai/tai-api-contract 2.186.0 → 2.188.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.
@@ -3344,6 +3344,46 @@ export interface paths {
3344
3344
  patch?: never;
3345
3345
  trace?: never;
3346
3346
  };
3347
+ "/workspaces/{workspaceId}/rules-skills/validate": {
3348
+ parameters: {
3349
+ query?: never;
3350
+ header?: never;
3351
+ path?: never;
3352
+ cookie?: never;
3353
+ };
3354
+ get?: never;
3355
+ put?: never;
3356
+ /**
3357
+ * Validate agent rules and skills for a repository
3358
+ * @description Clones the connected GitHub repository via the workspace GitHub App installation and runs the shared Rules & Skills validate engine (structural + soft quality). Assessed tools come from the latest **succeeded** readiness scan (`agent_tool_assessed`: `cursor` | `claude-code` | `both`). Returns draft `proposedFiles` for review (not committed). Workspace member auth; write permissions are not required for validate-only.
3359
+ */
3360
+ post: operations["postRulesSkillsValidate"];
3361
+ delete?: never;
3362
+ options?: never;
3363
+ head?: never;
3364
+ patch?: never;
3365
+ trace?: never;
3366
+ };
3367
+ "/workspaces/{workspaceId}/rules-skills/pull-requests": {
3368
+ parameters: {
3369
+ query?: never;
3370
+ header?: never;
3371
+ path?: never;
3372
+ cookie?: never;
3373
+ };
3374
+ get?: never;
3375
+ put?: never;
3376
+ /**
3377
+ * Open a Rules & Skills remediation pull request
3378
+ * @description Applies `proposedFiles` (or a future create-mode session) onto a non-default branch via the Automations GitHub App installation and opens a pull request. Never pushes to the default branch. PR title/body identify the change as platform-generated and link back to `/agentic-foundation/rules-skills`. Requires workspace editor or admin. Same write-permission gate as readiness fixes.
3379
+ */
3380
+ post: operations["postRulesSkillsPullRequest"];
3381
+ delete?: never;
3382
+ options?: never;
3383
+ head?: never;
3384
+ patch?: never;
3385
+ trace?: never;
3386
+ };
3347
3387
  "/workspaces/{workspaceId}/readiness/issues/{issueId}/fix-guide": {
3348
3388
  parameters: {
3349
3389
  query?: never;
@@ -6956,13 +6996,52 @@ export interface components {
6956
6996
  generatedAt: string;
6957
6997
  contributors: components["schemas"]["AiUsageSpendAggregatedContributorRowDto"][];
6958
6998
  };
6999
+ /** @description Numeric evidence for `id=model_right_sizing` (Cost-to-Value insight #2). Premium share is `premiumSpendCents / totalModelSpendCents` against `thresholdPct` (Phase A default 40). */
7000
+ AiUsageSpendKeyInsightModelRightSizingEvidenceDto: {
7001
+ /** @description Premium-model share of model spend in the window (0–100). */
7002
+ premiumSharePct: number;
7003
+ /** @description Sum of spend_cents on premium-classified models (cents). */
7004
+ premiumSpendCents: number;
7005
+ /** @description Sum of spend_cents across all models in the window (cents). */
7006
+ totalModelSpendCents: number;
7007
+ /** @description Effective premium-share threshold used for this card (0–100). */
7008
+ thresholdPct: number;
7009
+ /** @description Distinct mapped person_id rows contributing to this card's sample (workspace rollup or the single person for a person-scoped card). */
7010
+ personCount: number;
7011
+ };
7012
+ /** @description Optional member drill-down for person-scoped `model_right_sizing` cards. Links to `GET …/integrations/ai-tool/{provider}/members/{externalId}`. */
7013
+ AiUsageSpendKeyInsightDrilldownDto: {
7014
+ /**
7015
+ * @description AI tool provider for the member detail route.
7016
+ * @enum {string}
7017
+ */
7018
+ provider: "cursor" | "claude";
7019
+ /** @description Provider member external id for the member detail route. */
7020
+ externalId: string;
7021
+ };
7022
+ /** @description One Key Insights panel card. Base fields (`id`, `tone`, `text`) apply to all insights. When `id` is `model_right_sizing`, clients MUST treat `dataQuality`, `limitation`, `recommendedAction`, and `evidence` as required; `scope` and `drilldown` are optional (person cards may set both). */
6959
7023
  AiUsageSpendKeyInsightItemDto: {
6960
- /** @description Stable insight key (e.g. spend-leader, spend-vs-output). */
7024
+ /** @description Stable insight key (e.g. spend-leader, spend-vs-output, model_right_sizing). */
6961
7025
  id: string;
6962
7026
  /** @enum {string} */
6963
7027
  tone: "positive" | "warning" | "neutral";
6964
7028
  /** @description Human-readable insight sentence for the UI panel. */
6965
7029
  text: string;
7030
+ /** @description Required when `id=model_right_sizing`. Phase A/B always `estimated` (model-mix heuristic; no task-complexity telemetry until Phase 3). */
7031
+ dataQuality?: components["schemas"]["AiAssistedCodeDataQuality"];
7032
+ /** @description Required when `id=model_right_sizing`. Fixed honesty string that the model mix is heuristic and does not encode task complexity. */
7033
+ limitation?: string;
7034
+ /** @description Required when `id=model_right_sizing`. Coaching copy for the card CTA (advisory only; not vendor enforcement). */
7035
+ recommendedAction?: string;
7036
+ /** @description Required when `id=model_right_sizing`. */
7037
+ evidence?: components["schemas"]["AiUsageSpendKeyInsightModelRightSizingEvidenceDto"];
7038
+ /**
7039
+ * @description Optional scope for `model_right_sizing` cards. Workspace default vs per-person personalized item.
7040
+ * @enum {string}
7041
+ */
7042
+ scope?: "workspace" | "person";
7043
+ /** @description Optional when `scope=person` for `model_right_sizing`; omitted on workspace cards. */
7044
+ drilldown?: components["schemas"]["AiUsageSpendKeyInsightDrilldownDto"];
6966
7045
  };
6967
7046
  AiUsageSpendKeyInsightsDto: {
6968
7047
  /** Format: uuid */
@@ -9204,6 +9283,80 @@ export interface components {
9204
9283
  /** @description Required when the issue has unresolvedChoices. Must be one of those labels. Stored on the fix row and stated in the worker prompt. */
9205
9284
  patternChoice?: string;
9206
9285
  };
9286
+ /**
9287
+ * @description From the latest succeeded readiness scan (`agent_tool_assessed`). Never invent `both` without scan evidence.
9288
+ * @enum {string}
9289
+ */
9290
+ RulesSkillsAssessedTools: "cursor" | "claude-code" | "both";
9291
+ RulesSkillsValidateRequestDto: {
9292
+ /** Format: uuid */
9293
+ repoId: string;
9294
+ /** @description Optional relative path prefixes limiting the validate walk. */
9295
+ pathPrefixes?: string[];
9296
+ };
9297
+ RulesSkillsFindingDto: {
9298
+ id: string;
9299
+ /** @enum {string} */
9300
+ kind: "structural" | "soft";
9301
+ /** @enum {string} */
9302
+ severity: "fail" | "warn";
9303
+ code: string;
9304
+ path: string;
9305
+ message: string;
9306
+ /** @description Empty when unmapped structural noise. */
9307
+ criterionIds: ("A1" | "A2" | "A3" | "A3a" | "A3b" | "A3c" | "A11")[];
9308
+ };
9309
+ RulesSkillsSoftQualityCheckDto: {
9310
+ code: string;
9311
+ /** @enum {string} */
9312
+ status: "pass" | "fail" | "warn" | "skip";
9313
+ message?: string;
9314
+ path?: string;
9315
+ };
9316
+ RulesSkillsSoftQualitySummaryDto: {
9317
+ /** @description True when there are no soft-quality fail findings (warns allowed). */
9318
+ passed: boolean;
9319
+ failCount: number;
9320
+ warnCount: number;
9321
+ checks: components["schemas"]["RulesSkillsSoftQualityCheckDto"][];
9322
+ };
9323
+ RulesSkillsProposedFileDto: {
9324
+ path: string;
9325
+ /** @enum {string} */
9326
+ action: "create" | "update" | "delete" | "rename";
9327
+ /** @description Full file contents for create/update/rename target. */
9328
+ content?: string;
9329
+ /** @description Source path when action is rename. */
9330
+ previousPath?: string;
9331
+ };
9332
+ RulesSkillsValidateResponseDto: {
9333
+ assessedTools: components["schemas"]["RulesSkillsAssessedTools"];
9334
+ findings: components["schemas"]["RulesSkillsFindingDto"][];
9335
+ softQualitySummary: components["schemas"]["RulesSkillsSoftQualitySummaryDto"];
9336
+ proposedFiles: components["schemas"]["RulesSkillsProposedFileDto"][];
9337
+ /** @description Quiet-case note (e.g. empty tree under pathPrefixes). */
9338
+ note?: string;
9339
+ };
9340
+ RulesSkillsOpenPullRequestRequestDto: {
9341
+ /** Format: uuid */
9342
+ repoId: string;
9343
+ /** @enum {string} */
9344
+ mode: "validate" | "create";
9345
+ /**
9346
+ * Format: uuid
9347
+ * @description Reserved for Create-mode sessions; validate mode uses proposedFiles.
9348
+ */
9349
+ sessionId?: string;
9350
+ proposedFiles?: components["schemas"]["RulesSkillsProposedFileDto"][];
9351
+ title?: string;
9352
+ body?: string;
9353
+ };
9354
+ RulesSkillsOpenPullRequestResponseDto: {
9355
+ /** Format: uri */
9356
+ prUrl: string;
9357
+ prNumber: number;
9358
+ branchName: string;
9359
+ };
9207
9360
  PhaseRoleDto: {
9208
9361
  phase: string;
9209
9362
  /** @enum {string} */
@@ -12901,6 +13054,8 @@ export type AiUsageSpendAggregatedTeamsDto = components['schemas']['AiUsageSpend
12901
13054
  export type AiUsageSpendAggregatedContributorRowDto = components['schemas']['AiUsageSpendAggregatedContributorRowDto'];
12902
13055
  export type AiUsageSpendAggregatedContributorsDto = components['schemas']['AiUsageSpendAggregatedContributorsDto'];
12903
13056
  export type AiUsageSpendContributorToolHeatmapDto = components['schemas']['AiUsageSpendContributorToolHeatmapDto'];
13057
+ export type AiUsageSpendKeyInsightModelRightSizingEvidenceDto = components['schemas']['AiUsageSpendKeyInsightModelRightSizingEvidenceDto'];
13058
+ export type AiUsageSpendKeyInsightDrilldownDto = components['schemas']['AiUsageSpendKeyInsightDrilldownDto'];
12904
13059
  export type AiUsageSpendKeyInsightItemDto = components['schemas']['AiUsageSpendKeyInsightItemDto'];
12905
13060
  export type AiUsageSpendKeyInsightsDto = components['schemas']['AiUsageSpendKeyInsightsDto'];
12906
13061
  export type AiAssistedCodeDataQuality = components['schemas']['AiAssistedCodeDataQuality'];
@@ -13091,6 +13246,15 @@ export type ReadinessFixGuideDto = components['schemas']['ReadinessFixGuideDto']
13091
13246
  export type FixRetryableErrorCode = components['schemas']['FixRetryableErrorCode'];
13092
13247
  export type FixNonRetryableErrorCode = components['schemas']['FixNonRetryableErrorCode'];
13093
13248
  export type CreateFixRequestBodyDto = components['schemas']['CreateFixRequestBodyDto'];
13249
+ export type RulesSkillsAssessedTools = components['schemas']['RulesSkillsAssessedTools'];
13250
+ export type RulesSkillsValidateRequestDto = components['schemas']['RulesSkillsValidateRequestDto'];
13251
+ export type RulesSkillsFindingDto = components['schemas']['RulesSkillsFindingDto'];
13252
+ export type RulesSkillsSoftQualityCheckDto = components['schemas']['RulesSkillsSoftQualityCheckDto'];
13253
+ export type RulesSkillsSoftQualitySummaryDto = components['schemas']['RulesSkillsSoftQualitySummaryDto'];
13254
+ export type RulesSkillsProposedFileDto = components['schemas']['RulesSkillsProposedFileDto'];
13255
+ export type RulesSkillsValidateResponseDto = components['schemas']['RulesSkillsValidateResponseDto'];
13256
+ export type RulesSkillsOpenPullRequestRequestDto = components['schemas']['RulesSkillsOpenPullRequestRequestDto'];
13257
+ export type RulesSkillsOpenPullRequestResponseDto = components['schemas']['RulesSkillsOpenPullRequestResponseDto'];
13094
13258
  export type PhaseRoleDto = components['schemas']['PhaseRoleDto'];
13095
13259
  export type SquadMemberDto = components['schemas']['SquadMemberDto'];
13096
13260
  export type CustomWorkStreamTaskDto = components['schemas']['CustomWorkStreamTaskDto'];
@@ -22827,6 +22991,134 @@ export interface operations {
22827
22991
  };
22828
22992
  };
22829
22993
  };
22994
+ postRulesSkillsValidate: {
22995
+ parameters: {
22996
+ query?: never;
22997
+ header?: never;
22998
+ path: {
22999
+ workspaceId: components["parameters"]["WorkspaceId"];
23000
+ };
23001
+ cookie?: never;
23002
+ };
23003
+ requestBody: {
23004
+ content: {
23005
+ "application/json": components["schemas"]["RulesSkillsValidateRequestDto"];
23006
+ };
23007
+ };
23008
+ responses: {
23009
+ /** @description Validation result with findings and draft proposed files */
23010
+ 200: {
23011
+ headers: {
23012
+ [name: string]: unknown;
23013
+ };
23014
+ content: {
23015
+ "application/json": components["schemas"]["RulesSkillsValidateResponseDto"];
23016
+ };
23017
+ };
23018
+ /** @description Invalid body (e.g. malformed repoId) */
23019
+ 400: {
23020
+ headers: {
23021
+ [name: string]: unknown;
23022
+ };
23023
+ content: {
23024
+ "application/json": components["schemas"]["ErrorMessageDto"];
23025
+ };
23026
+ };
23027
+ 401: components["responses"]["Unauthorized"];
23028
+ 403: components["responses"]["Forbidden"];
23029
+ /** @description Workspace or repository not found / not connected */
23030
+ 404: {
23031
+ headers: {
23032
+ [name: string]: unknown;
23033
+ };
23034
+ content: {
23035
+ "application/json": components["schemas"]["ErrorMessageDto"];
23036
+ };
23037
+ };
23038
+ /** @description No succeeded readiness scan for the repo (`code: readiness_scan_required`), or repository is not a GitHub-connected readiness repo. */
23039
+ 422: {
23040
+ headers: {
23041
+ [name: string]: unknown;
23042
+ };
23043
+ content: {
23044
+ "application/json": components["schemas"]["ErrorMessageDto"];
23045
+ };
23046
+ };
23047
+ /** @description Clone or GitHub App configuration failed */
23048
+ 503: {
23049
+ headers: {
23050
+ [name: string]: unknown;
23051
+ };
23052
+ content: {
23053
+ "application/json": components["schemas"]["ErrorMessageDto"];
23054
+ };
23055
+ };
23056
+ };
23057
+ };
23058
+ postRulesSkillsPullRequest: {
23059
+ parameters: {
23060
+ query?: never;
23061
+ header?: never;
23062
+ path: {
23063
+ workspaceId: components["parameters"]["WorkspaceId"];
23064
+ };
23065
+ cookie?: never;
23066
+ };
23067
+ requestBody: {
23068
+ content: {
23069
+ "application/json": components["schemas"]["RulesSkillsOpenPullRequestRequestDto"];
23070
+ };
23071
+ };
23072
+ responses: {
23073
+ /** @description Pull request created */
23074
+ 200: {
23075
+ headers: {
23076
+ [name: string]: unknown;
23077
+ };
23078
+ content: {
23079
+ "application/json": components["schemas"]["RulesSkillsOpenPullRequestResponseDto"];
23080
+ };
23081
+ };
23082
+ /** @description Missing proposed files or invalid body (`code: proposed_files_required`). */
23083
+ 400: {
23084
+ headers: {
23085
+ [name: string]: unknown;
23086
+ };
23087
+ content: {
23088
+ "application/json": components["schemas"]["ErrorMessageDto"];
23089
+ };
23090
+ };
23091
+ 401: components["responses"]["Unauthorized"];
23092
+ 403: components["responses"]["Forbidden"];
23093
+ /** @description Workspace or repository not found */
23094
+ 404: {
23095
+ headers: {
23096
+ [name: string]: unknown;
23097
+ };
23098
+ content: {
23099
+ "application/json": components["schemas"]["ErrorMessageDto"];
23100
+ };
23101
+ };
23102
+ /** @description GitHub installation lacks write permissions required for automated PRs */
23103
+ 422: {
23104
+ headers: {
23105
+ [name: string]: unknown;
23106
+ };
23107
+ content: {
23108
+ "application/json": components["schemas"]["GithubWritePermissionsRequiredErrorDto"];
23109
+ };
23110
+ };
23111
+ /** @description GitHub installation permissions could not be verified, or PR create failed */
23112
+ 503: {
23113
+ headers: {
23114
+ [name: string]: unknown;
23115
+ };
23116
+ content: {
23117
+ "application/json": components["schemas"]["GithubPermissionsCheckFailedErrorDto"] | components["schemas"]["ErrorMessageDto"];
23118
+ };
23119
+ };
23120
+ };
23121
+ };
22830
23122
  getReadinessIssueFixGuide: {
22831
23123
  parameters: {
22832
23124
  query?: never;
package/src/index.ts CHANGED
@@ -884,11 +884,45 @@ export interface AiUsageSpendContributorToolHeatmapDto {
884
884
  contributors: AiUsageSpendAggregatedContributorRowDto[];
885
885
  }
886
886
 
887
- /** One card in the AI usage & spend key insights panel. */
887
+ /**
888
+ * Numeric evidence for `id=model_right_sizing` (Cost-to-Value insight #2).
889
+ * Premium share is premiumSpendCents / totalModelSpendCents against thresholdPct.
890
+ */
891
+ export interface AiUsageSpendKeyInsightModelRightSizingEvidenceDto {
892
+ premiumSharePct: number;
893
+ premiumSpendCents: number;
894
+ totalModelSpendCents: number;
895
+ thresholdPct: number;
896
+ personCount: number;
897
+ }
898
+
899
+ /** Optional member drill-down for person-scoped model_right_sizing cards. */
900
+ export interface AiUsageSpendKeyInsightDrilldownDto {
901
+ provider: "cursor" | "claude";
902
+ externalId: string;
903
+ }
904
+
905
+ /**
906
+ * One card in the AI usage & spend key insights panel.
907
+ * When `id` is `model_right_sizing`, `dataQuality`, `limitation`,
908
+ * `recommendedAction`, and `evidence` are required; `scope` / `drilldown` optional.
909
+ */
888
910
  export interface AiUsageSpendKeyInsightItemDto {
889
911
  id: string;
890
912
  tone: "positive" | "warning" | "neutral";
891
913
  text: string;
914
+ /** Required when id=model_right_sizing; Phase A/B always `estimated`. */
915
+ dataQuality?: AiAssistedCodeDataQuality;
916
+ /** Required when id=model_right_sizing; heuristic honesty string. */
917
+ limitation?: string;
918
+ /** Required when id=model_right_sizing; advisory coaching CTA copy. */
919
+ recommendedAction?: string;
920
+ /** Required when id=model_right_sizing. */
921
+ evidence?: AiUsageSpendKeyInsightModelRightSizingEvidenceDto;
922
+ /** Optional scope for model_right_sizing (workspace default vs person). */
923
+ scope?: "workspace" | "person";
924
+ /** Optional person drill-down when scope=person. */
925
+ drilldown?: AiUsageSpendKeyInsightDrilldownDto;
892
926
  }
893
927
 
894
928
  /** Response for GET /workspaces/:workspaceId/insights/ai-usage-spend/key-insights */