cdk-insights 1.14.0 → 1.16.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.
- package/dist/cli/analysisJob.d.ts +17 -1
- package/dist/cli/config/aiModel.d.ts +77 -0
- package/dist/cli/config/aiModel.test.d.ts +1 -0
- package/dist/cli/types/cli.types.d.ts +11 -0
- package/dist/entry.js +186 -186
- package/dist/helpers/analyzeResource/analyzeResource.d.ts +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +136 -136
- package/package.json +1 -1
|
@@ -9,6 +9,14 @@ interface ConcurrencyConfig {
|
|
|
9
9
|
retryDelay: number;
|
|
10
10
|
timeoutMs: number;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Replace the plaintext logical ID inside a relationship summary entry
|
|
14
|
+
* (`"MyTable (Table)"`) with a deterministic hash of that ID, preserving
|
|
15
|
+
* the trailing `(TypeShort)` suffix so the AI still has resource-type
|
|
16
|
+
* context. Used to scrub user-chosen naming out of dependency lists
|
|
17
|
+
* before they're sent to the AI service.
|
|
18
|
+
*/
|
|
19
|
+
export declare const redactRelationshipEntry: (entry: string, stackName: string) => string;
|
|
12
20
|
export interface CreateResourceAnalyzerParams {
|
|
13
21
|
analyzeResource: AnalyzeResourceFn;
|
|
14
22
|
redactionMapping: Record<string, string>;
|
|
@@ -30,6 +38,8 @@ export interface CreateResourceAnalyzerParams {
|
|
|
30
38
|
dependents: string[];
|
|
31
39
|
usageDescription?: string;
|
|
32
40
|
}>;
|
|
41
|
+
/** Resolved Bedrock model ID — forwarded to backend per request. */
|
|
42
|
+
aiModelId?: string;
|
|
33
43
|
}
|
|
34
44
|
export interface ResourceAnalyzerParams {
|
|
35
45
|
redactedId: string;
|
|
@@ -61,6 +71,12 @@ export interface ResourceHandlerParams {
|
|
|
61
71
|
ttl: number;
|
|
62
72
|
maxSize: number;
|
|
63
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* Resolved Bedrock model ID for AI insights. Forwarded to the backend
|
|
76
|
+
* which routes the analysis through the chosen model. `undefined` =
|
|
77
|
+
* backend picks its tier default.
|
|
78
|
+
*/
|
|
79
|
+
aiModelId?: string;
|
|
64
80
|
}
|
|
65
|
-
export declare const createResourceHandler: ({ analyzeResource, redactResources, config, }: CreateResourceHandlerParams) => ({ stackName, resources, authToken, existingFindingsMap, pathToLogicalId, fingerprint, noCache, cacheConfig, }: ResourceHandlerParams) => Promise<ImportedAnalysisResult>;
|
|
81
|
+
export declare const createResourceHandler: ({ analyzeResource, redactResources, config, }: CreateResourceHandlerParams) => ({ stackName, resources, authToken, existingFindingsMap, pathToLogicalId, fingerprint, noCache, cacheConfig, aiModelId, }: ResourceHandlerParams) => Promise<ImportedAnalysisResult>;
|
|
66
82
|
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Model selection — three-level resolution.
|
|
3
|
+
*
|
|
4
|
+
* The user can pick which Bedrock model handles their AI insights via
|
|
5
|
+
* (in order of precedence):
|
|
6
|
+
*
|
|
7
|
+
* 1. `--model <alias>` CLI flag
|
|
8
|
+
* 2. `cdkInsights:aiModel` context entry in `cdk.json`
|
|
9
|
+
* 3. `ai.model` field in `.cdk-insights.json` user config
|
|
10
|
+
* 4. Server-side default (no modelId sent → backend picks)
|
|
11
|
+
*
|
|
12
|
+
* Aliases are friendly names like `mistral-14b` rather than raw Bedrock
|
|
13
|
+
* IDs (`mistral.ministral-3-14b-instruct`); the resolver translates the
|
|
14
|
+
* alias to the Bedrock ID on the way out so the wire format stays stable.
|
|
15
|
+
*
|
|
16
|
+
* Tier gating: each model is gated to one of `free` / `pro` / `team`.
|
|
17
|
+
* If the resolved alias is above the user's tier, the resolver returns
|
|
18
|
+
* the tier's default with a warning rather than failing — the analysis
|
|
19
|
+
* still runs, just on a model the user is allowed to use.
|
|
20
|
+
*/
|
|
21
|
+
import type { Tier } from '../../config/featureGating';
|
|
22
|
+
export type AiModelAlias = 'nova-lite' | 'mistral-14b' | 'llama-3-3-70b' | 'haiku-4-5' | 'sonnet-4-6';
|
|
23
|
+
export interface AiModelDefinition {
|
|
24
|
+
/** Friendly alias used in flags and config */
|
|
25
|
+
alias: AiModelAlias;
|
|
26
|
+
/** AWS Bedrock model identifier sent on the wire */
|
|
27
|
+
bedrockModelId: string;
|
|
28
|
+
/** Human-readable name shown in CLI output */
|
|
29
|
+
displayName: string;
|
|
30
|
+
/** Lowest tier that may select this model */
|
|
31
|
+
minTier: Tier;
|
|
32
|
+
/**
|
|
33
|
+
* Quota multiplier. A model with multiplier 2 deducts 2 insights per
|
|
34
|
+
* call from the user's monthly quota. Keeps the per-insight unit cost
|
|
35
|
+
* roughly aligned across the registry — Pro user's 5,000 insights can
|
|
36
|
+
* be spent as 5K × Mistral or 1.25K × Haiku, their choice.
|
|
37
|
+
*/
|
|
38
|
+
quotaMultiplier: number;
|
|
39
|
+
/** Short description for CLI help / model picker */
|
|
40
|
+
description: string;
|
|
41
|
+
}
|
|
42
|
+
export declare const AI_MODEL_REGISTRY: Record<AiModelAlias, AiModelDefinition>;
|
|
43
|
+
export declare const TIER_DEFAULT_MODEL: Record<Tier, AiModelAlias>;
|
|
44
|
+
export declare const isAiModelAlias: (value: unknown) => value is AiModelAlias;
|
|
45
|
+
export interface ResolveAiModelArgs {
|
|
46
|
+
/** `--model` flag, if any */
|
|
47
|
+
flag?: string;
|
|
48
|
+
/** `cdkInsights:aiModel` from cdk.json, if any */
|
|
49
|
+
cdkContext?: string;
|
|
50
|
+
/** `ai.model` from .cdk-insights.json user config */
|
|
51
|
+
userConfig?: string;
|
|
52
|
+
/** User's current tier — gates which models are allowed */
|
|
53
|
+
tier?: Tier;
|
|
54
|
+
}
|
|
55
|
+
export interface ResolvedAiModel {
|
|
56
|
+
/** Resolved model alias */
|
|
57
|
+
alias: AiModelAlias;
|
|
58
|
+
/** Bedrock ID to send on the wire */
|
|
59
|
+
bedrockModelId: string;
|
|
60
|
+
/** Source of the resolution, for logging */
|
|
61
|
+
source: 'flag' | 'cdkContext' | 'userConfig' | 'tierDefault';
|
|
62
|
+
/** True if the user's preference was downgraded due to tier gating */
|
|
63
|
+
downgradedFromTierGate: boolean;
|
|
64
|
+
/** Original alias the user tried to pick (only set when downgraded) */
|
|
65
|
+
requestedAlias?: AiModelAlias;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Walk the resolution sources in precedence order, validate each candidate
|
|
69
|
+
* against tier gating, and return the resolved model. Falls back to the
|
|
70
|
+
* tier default (or `mistral-14b` if no tier supplied) when nothing matches.
|
|
71
|
+
*/
|
|
72
|
+
export declare const resolveAiModel: (args: ResolveAiModelArgs) => ResolvedAiModel;
|
|
73
|
+
/**
|
|
74
|
+
* Lists the models the given tier is allowed to use, sorted by min-tier
|
|
75
|
+
* then by quota multiplier. Used by the CLI to render help text.
|
|
76
|
+
*/
|
|
77
|
+
export declare const getAvailableModelsForTier: (tier: Tier) => AiModelDefinition[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -23,6 +23,7 @@ export interface AnalyzeCommandArgs {
|
|
|
23
23
|
local?: boolean;
|
|
24
24
|
warnSensitive?: boolean;
|
|
25
25
|
prComment?: boolean;
|
|
26
|
+
model?: string;
|
|
26
27
|
cache?: {
|
|
27
28
|
enabled?: boolean;
|
|
28
29
|
ttl?: number;
|
|
@@ -83,6 +84,16 @@ export interface UserConfig {
|
|
|
83
84
|
ttl?: number;
|
|
84
85
|
maxSize?: number;
|
|
85
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* AI analysis configuration. The `model` field selects which Bedrock
|
|
89
|
+
* model handles AI insights — see `cli/config/aiModel.ts` for the
|
|
90
|
+
* registry of available aliases. Resolution precedence is
|
|
91
|
+
* `--model` flag → `cdk.json` `cdkInsights:aiModel` context →
|
|
92
|
+
* this user config → tier default.
|
|
93
|
+
*/
|
|
94
|
+
ai?: {
|
|
95
|
+
model?: string;
|
|
96
|
+
};
|
|
86
97
|
[key: string]: unknown;
|
|
87
98
|
}
|
|
88
99
|
export interface AnalysisSuccess {
|