import { APIResource } from "../core/resource.js"; import * as AnalysisAPI from "./analysis.js"; import * as RepositoriesAPI from "./repositories/repositories.js"; import { APIPromise } from "../core/api-promise.js"; import { RequestOptions } from "../internal/request-options.js"; export declare class AnalysisResource extends APIResource { /** * Creates a new code analysis session * * @example * ```ts * const analysis = await client.analysis.create({ * type: 'repository', * }); * ``` */ create(params: AnalysisCreateParams, options?: RequestOptions): APIPromise; /** * Returns the analysis object * * @example * ```ts * const analysis = await client.analysis.retrieve('id'); * ``` */ retrieve(id: string, options?: RequestOptions): APIPromise; /** * Retrieves a paginated list of analysis runs in your workspace * * @example * ```ts * const analyses = await client.analysis.list(); * ``` */ list(query?: AnalysisListParams | null | undefined, options?: RequestOptions): APIPromise; /** * Cancels a running analysis * * @example * ```ts * const analysis = await client.analysis.cancel('id'); * ``` */ cancel(id: string, options?: RequestOptions): APIPromise; /** * Retrieves a paginated list of all individual fixes generated in an analysis * * @example * ```ts * const response = await client.analysis.listFixes('id'); * ``` */ listFixes(id: string, query?: AnalysisListFixesParams | null | undefined, options?: RequestOptions): APIPromise; /** * Retrieves a paginated list of all issues detected in an analysis * * @example * ```ts * const response = await client.analysis.listIssues('id'); * ``` */ listIssues(id: string, query?: AnalysisListIssuesParams | null | undefined, options?: RequestOptions): APIPromise; } export interface Analysis { /** * Unique identifier of the analysis */ id?: string; /** * Code for standalone analysis */ code?: string | null; /** * Unix timestamp when the analysis completed */ completed_at?: number | null; cost?: Analysis.Cost; /** * Unix timestamp when the analysis was created */ created_at?: number; detection?: Array<'security' | 'secrets' | 'dependencies'>; detection_result?: Analysis.DetectionResult; /** * Filename of the code snippet (only present if type is file) */ filename?: string | null; fix?: Array<'security' | 'secrets' | 'dependencies'>; fix_result?: Analysis.FixResult; /** * Beginning git reference */ from_ref?: string | null; /** * Language of the code snippet (only present if type is file) */ language?: Language; object?: 'analysis'; /** * Git patch to apply before analysis */ patch?: string | null; /** * Repository this analysis belongs to */ repository?: string | null; /** * Current status of the analysis */ status?: 'queued' | 'in_progress' | 'completed' | 'canceled'; /** * End git reference */ to_ref?: string | null; /** * Type of analysis performed */ type?: 'repository' | 'file'; /** * Unix timestamp when the analysis was last updated */ updated_at?: number; /** * Workspace this analysis belongs to */ workspace?: string; } export declare namespace Analysis { interface Cost { /** * Lines of code analyzed */ input_loc?: number; /** * Rate per input line of code in cents */ input_loc_rate?: number; object?: 'result.cost'; /** * Lines of code generated in fixes */ output_fix_loc?: number; /** * Rate per output fix line of code in cents */ output_fix_rate?: number; /** * Total cost in cents (input_loc _ input_loc_rate + output_fix_loc _ * output_fix_rate) */ total?: number; } interface DetectionResult { /** * True if there are more than 50 issues */ has_more?: boolean; /** * First 50 detected issues */ issues?: Array; /** * Issues by category (e.g., {"security": 65, "secrets": 22}) */ issues_detected_by_category?: { [key: string]: number; }; /** * Issues by language (e.g., {"python": 11, "typescript": 12}) */ issues_detected_by_language?: { [key: string]: number; }; /** * Total number of issues detected */ issues_detected_count?: number; object?: 'result.detection'; /** * URL to access the paginated list of all issues */ url?: string; } interface FixResult { /** * First 50 individual fixes */ fixes?: Array; /** * True if there are more than 50 fixes */ has_more?: boolean; /** * Issues fixed by category (e.g., {"security": 8, "secrets": 2}) */ issues_fixed_by_category?: { [key: string]: number; }; /** * Total number of issues fixed */ issues_fixed_count?: number; object?: 'result.fix'; /** * Unified git patch ready to apply to the repository */ patch?: string; /** * URL to access the paginated list of all fixes */ url?: string; } } export interface Fix { /** * The agent that generated this fix */ category?: 'security' | 'secrets' | 'dependencies'; /** * Explanation of what this fix does */ explanation?: string; object?: 'result.fix.item'; /** * Individual git patch for this fix */ patch?: string; } export interface Issue { /** * Sub-agent that raised this issue */ category?: 'security' | 'secrets' | 'dependencies'; /** * Detailed explanation of the issue */ explanation?: string; /** * File path relative to repository root */ file?: string; object?: 'result.detection.issue'; position?: Issue.Position; } export declare namespace Issue { interface Position { begin?: Position.Begin; end?: Position.End; } namespace Position { interface Begin { column?: number; line?: number; } interface End { column?: number; line?: number; } } } /** * Programming language slug supported for anlaysis */ export type Language = 'python' | 'javascript' | 'java' | 'go' | 'csharp' | 'ansible' | 'c' | 'cpp' | 'docker' | 'kotlin' | 'php' | 'ruby' | 'rust' | 'scala' | 'shell' | 'sql' | 'swift' | 'terraform'; export interface AnalysisListResponse extends RepositoriesAPI.PaginatedList { data?: Array; } export interface AnalysisListFixesResponse extends RepositoriesAPI.PaginatedList { data?: Array; } export interface AnalysisListIssuesResponse extends RepositoriesAPI.PaginatedList { data?: Array; } export interface AnalysisCreateParams { /** * Body param: Type of analysis to perform */ type: 'repository' | 'file'; /** * Body param: Standalone code to analyze (required if type is file) */ code?: string; /** * Body param: Controls what kind of analysis to perform (defaults to repository's * detection setting) */ detection?: Array<'security' | 'secrets' | 'dependencies'>; /** * Body param: Filename for the code snippet (optional if type is file) */ filename?: string; /** * Body param: Controls which issues are fixed (defaults to repository's fix * setting) */ fix?: Array<'security' | 'secrets' | 'dependencies'>; /** * Body param: Beginning git reference for repository analysis (required if type is * repository) */ from_ref?: string; /** * Body param: Explicit language override (optional if type is file) */ language?: Language; /** * Body param: Git patch to apply before analysis (optional if type is repository) */ patch?: string; /** * Body param: Repository ID or external:{external_id} (required if type is * repository) */ repository_id?: string; /** * Body param: End git reference for repository analysis (optional if type is * repository) */ to_ref?: string; /** * Header param: Idempotency key for safely retrying operations */ 'Idempotency-Key'?: string; } export interface AnalysisListParams { /** * Cursor for pagination (object ID) */ after?: string; /** * Cursor for pagination (object ID) */ before?: string; /** * Number of items to return */ limit?: number; /** * Filter by repository (supports external: format) */ repository_id?: string; status?: 'queued' | 'in_progress' | 'completed'; } export interface AnalysisListFixesParams { /** * Cursor for pagination (object ID) */ after?: string; /** * Cursor for pagination (object ID) */ before?: string; /** * Filter by fix category */ category?: 'security' | 'secrets' | 'dependencies'; /** * Number of items to return */ limit?: number; } export interface AnalysisListIssuesParams { /** * Cursor for pagination (object ID) */ after?: string; /** * Cursor for pagination (object ID) */ before?: string; /** * Filter by issue category */ category?: 'security' | 'secrets' | 'dependencies'; /** * Filter by file path */ file?: string; /** * Filter by programming language */ language?: Language; /** * Number of items to return */ limit?: number; } export declare namespace AnalysisResource { export { type Analysis as Analysis, type Fix as Fix, type Issue as Issue, type Language as Language, type AnalysisListResponse as AnalysisListResponse, type AnalysisListFixesResponse as AnalysisListFixesResponse, type AnalysisListIssuesResponse as AnalysisListIssuesResponse, type AnalysisCreateParams as AnalysisCreateParams, type AnalysisListParams as AnalysisListParams, type AnalysisListFixesParams as AnalysisListFixesParams, type AnalysisListIssuesParams as AnalysisListIssuesParams, }; } //# sourceMappingURL=analysis.d.ts.map