@codemieai/cdk 0.1.270
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/README.md +2856 -0
- package/dist/cli/index.js +3482 -0
- package/dist/index.d.ts +584 -0
- package/dist/index.js +3247 -0
- package/package.json +63 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Integration, BaseDataSourceCreateParams, BaseCodeParams, DataSourceType, BaseConfluenceParams, BaseJiraParams, BaseGoogleParams, BaseFileParams, AssistantCreateParams, ToolKitDetails, ToolDetails, MCPServerDetails, WorkflowCreateParams, CodeMieClient } from 'codemie-sdk';
|
|
3
|
+
|
|
4
|
+
declare const appConfigSchema: z.ZodObject<{
|
|
5
|
+
rootDir: z.ZodString;
|
|
6
|
+
codemieConfig: z.ZodString;
|
|
7
|
+
codemieState: z.ZodString;
|
|
8
|
+
backupsDirectory: z.ZodString;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
type AppConfig = z.infer<typeof appConfigSchema>;
|
|
11
|
+
|
|
12
|
+
interface CodemieConfig {
|
|
13
|
+
version: string;
|
|
14
|
+
project: {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
environment: {
|
|
19
|
+
codemie_api_url: string;
|
|
20
|
+
auth_server_url: string;
|
|
21
|
+
auth_realm_name: string;
|
|
22
|
+
client_id?: string;
|
|
23
|
+
client_secret?: string;
|
|
24
|
+
username?: string;
|
|
25
|
+
password?: string;
|
|
26
|
+
};
|
|
27
|
+
imported: {
|
|
28
|
+
assistants: ImportedResource[];
|
|
29
|
+
datasources: ImportedResource[];
|
|
30
|
+
integrations: IntegrationDefinition[];
|
|
31
|
+
};
|
|
32
|
+
tool_definitions?: {
|
|
33
|
+
[alias: string]: ToolDefinition;
|
|
34
|
+
};
|
|
35
|
+
datasource_defaults?: {
|
|
36
|
+
[type: string]: Partial<DatasourceResource>;
|
|
37
|
+
};
|
|
38
|
+
resources: {
|
|
39
|
+
assistants?: AssistantResource[];
|
|
40
|
+
datasources?: DatasourceResource[];
|
|
41
|
+
workflows?: WorkflowResource[];
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
type IntegrationDefinition = Integration;
|
|
45
|
+
/**
|
|
46
|
+
* Reference to a named integration in IaC config
|
|
47
|
+
*/
|
|
48
|
+
interface IntegrationRef {
|
|
49
|
+
$ref: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Integration reference for IaC configurations
|
|
53
|
+
* Can be:
|
|
54
|
+
* - { $ref: string } - Reference to named integration
|
|
55
|
+
* - Integration - Full integration object from SDK
|
|
56
|
+
* - null
|
|
57
|
+
*/
|
|
58
|
+
type IntegrationReference = IntegrationRef | Integration | null;
|
|
59
|
+
/**
|
|
60
|
+
* IaC representation of a tool (extends SDK ToolDetails)
|
|
61
|
+
* Override: settings can be $ref, settings_config optional
|
|
62
|
+
*/
|
|
63
|
+
interface IaCTool extends Omit<ToolDetails, 'settings' | 'settings_config'> {
|
|
64
|
+
settings_config?: boolean;
|
|
65
|
+
settings?: IntegrationReference;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* IaC representation of a toolkit (extends SDK ToolKitDetails)
|
|
69
|
+
* Override: settings can be $ref, tools use IaCTool, some fields optional
|
|
70
|
+
*/
|
|
71
|
+
interface IaCToolkit extends Omit<ToolKitDetails, 'settings' | 'tools' | 'settings_config' | 'is_external'> {
|
|
72
|
+
settings_config?: boolean;
|
|
73
|
+
is_external?: boolean;
|
|
74
|
+
tools: IaCTool[];
|
|
75
|
+
settings?: IntegrationReference;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* IaC representation of MCP server (extends SDK MCPServerDetails)
|
|
79
|
+
* Override: settings/mcp_connect_auth_token can be $ref, enabled optional
|
|
80
|
+
*/
|
|
81
|
+
interface IaCMcpServer extends Omit<MCPServerDetails, 'settings' | 'mcp_connect_auth_token' | 'enabled'> {
|
|
82
|
+
enabled?: boolean;
|
|
83
|
+
settings?: IntegrationReference;
|
|
84
|
+
mcp_connect_auth_token?: IntegrationReference;
|
|
85
|
+
}
|
|
86
|
+
interface ToolDefinition {
|
|
87
|
+
$ref: string;
|
|
88
|
+
name: string;
|
|
89
|
+
label?: string;
|
|
90
|
+
settings_config?: boolean;
|
|
91
|
+
user_description?: string;
|
|
92
|
+
settings?: IntegrationReference;
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
}
|
|
95
|
+
interface ImportedResource {
|
|
96
|
+
name: string;
|
|
97
|
+
id: string;
|
|
98
|
+
type?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Assistant resource configuration (IaC layer)
|
|
102
|
+
* Combines IaC-specific fields with all SDK AssistantCreateParams fields
|
|
103
|
+
* Automatically inherits all new fields from SDK
|
|
104
|
+
*/
|
|
105
|
+
interface AssistantResource extends Partial<Omit<AssistantCreateParams, 'project' | 'system_prompt' | 'llm_model_type' | 'toolkits' | 'mcp_servers'>> {
|
|
106
|
+
name: string;
|
|
107
|
+
description: string;
|
|
108
|
+
prompt: string;
|
|
109
|
+
model: string;
|
|
110
|
+
toolkits?: IaCToolkit[];
|
|
111
|
+
mcp_servers?: IaCMcpServer[];
|
|
112
|
+
config?: string;
|
|
113
|
+
sub_assistants?: string[];
|
|
114
|
+
datasource_names?: string[];
|
|
115
|
+
categories?: string[];
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Base datasource configuration (IaC-specific fields only)
|
|
119
|
+
*/
|
|
120
|
+
interface BaseIaCDatasourceConfig {
|
|
121
|
+
name: string;
|
|
122
|
+
description: string;
|
|
123
|
+
$ref?: string;
|
|
124
|
+
force_reindex?: boolean;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Base configuration for all datasource types (IaC + SDK fields)
|
|
128
|
+
* Extends SDK BaseDataSourceCreateParams + adds IaC-specific fields
|
|
129
|
+
*/
|
|
130
|
+
interface BaseDatasourceConfig extends BaseIaCDatasourceConfig, Partial<Omit<BaseDataSourceCreateParams, 'project_name' | 'name' | 'description'>> {
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Code datasource configuration (GitHub/GitLab/Bitbucket repositories)
|
|
134
|
+
* Automatically inherits all new fields from SDK BaseCodeParams
|
|
135
|
+
*/
|
|
136
|
+
interface CodeDatasourceResource extends BaseDatasourceConfig, Partial<BaseCodeParams> {
|
|
137
|
+
type: typeof DataSourceType.CODE;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Confluence datasource configuration
|
|
141
|
+
* Automatically inherits all new fields from SDK BaseConfluenceParams
|
|
142
|
+
*/
|
|
143
|
+
interface ConfluenceDatasourceResource extends BaseDatasourceConfig, Partial<BaseConfluenceParams> {
|
|
144
|
+
type: typeof DataSourceType.CONFLUENCE;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Jira datasource configuration
|
|
148
|
+
* Automatically inherits all new fields from SDK BaseJiraParams
|
|
149
|
+
*/
|
|
150
|
+
interface JiraDatasourceResource extends BaseDatasourceConfig, Partial<BaseJiraParams> {
|
|
151
|
+
type: typeof DataSourceType.JIRA;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Google Docs datasource configuration
|
|
155
|
+
* Automatically inherits all new fields from SDK BaseGoogleParams
|
|
156
|
+
*/
|
|
157
|
+
interface GoogleDatasourceResource extends BaseDatasourceConfig, Partial<BaseGoogleParams> {
|
|
158
|
+
type: typeof DataSourceType.GOOGLE;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* File datasource configuration (uploaded files)
|
|
162
|
+
* Automatically inherits all new fields from SDK BaseFileParams
|
|
163
|
+
*/
|
|
164
|
+
interface FileDatasourceResource extends BaseDatasourceConfig, Partial<BaseFileParams> {
|
|
165
|
+
type: typeof DataSourceType.FILE;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Other/generic datasource configuration (for any other SDK datasource types)
|
|
169
|
+
*/
|
|
170
|
+
interface OtherDatasourceResource extends BaseDatasourceConfig {
|
|
171
|
+
type?: typeof DataSourceType.BEDROCK | typeof DataSourceType.CHUNK_SUMMARY | typeof DataSourceType.JSON | typeof DataSourceType.PROVIDER | typeof DataSourceType.SUMMARY;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Discriminated union of all datasource types
|
|
175
|
+
* Mirrors SDK DataSourceCreateParams structure
|
|
176
|
+
* New datasource types in SDK will be automatically supported
|
|
177
|
+
*/
|
|
178
|
+
type DatasourceResource = CodeDatasourceResource | ConfluenceDatasourceResource | JiraDatasourceResource | GoogleDatasourceResource | FileDatasourceResource | OtherDatasourceResource;
|
|
179
|
+
/**
|
|
180
|
+
* Base Workflow configuration (IaC-specific fields only)
|
|
181
|
+
*/
|
|
182
|
+
interface BaseWorkflowConfig {
|
|
183
|
+
name: string;
|
|
184
|
+
description: string;
|
|
185
|
+
definition: string;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Workflow resource configuration (IaC layer)
|
|
189
|
+
* Combines IaC-specific fields with all SDK WorkflowCreateParams fields
|
|
190
|
+
* Automatically inherits all new fields from SDK
|
|
191
|
+
*/
|
|
192
|
+
interface WorkflowResource extends BaseWorkflowConfig, Partial<Omit<WorkflowCreateParams, 'project' | 'name' | 'description' | 'yaml_config'>> {
|
|
193
|
+
}
|
|
194
|
+
interface AssistantConfig {
|
|
195
|
+
includes?: string[];
|
|
196
|
+
placeholders?: Record<string, unknown>;
|
|
197
|
+
validation?: {
|
|
198
|
+
max_length?: number;
|
|
199
|
+
required_sections?: string[];
|
|
200
|
+
};
|
|
201
|
+
metadata?: Record<string, unknown>;
|
|
202
|
+
}
|
|
203
|
+
interface StateFile {
|
|
204
|
+
version: string;
|
|
205
|
+
project: string;
|
|
206
|
+
lastSync: string | null;
|
|
207
|
+
resources: {
|
|
208
|
+
assistants: Record<string, AssistantState>;
|
|
209
|
+
datasources: Record<string, DatasourceState>;
|
|
210
|
+
workflows: Record<string, WorkflowState>;
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
interface AssistantState {
|
|
214
|
+
id: string;
|
|
215
|
+
lastDeployed: string;
|
|
216
|
+
promptChecksum: string;
|
|
217
|
+
configChecksum: string;
|
|
218
|
+
}
|
|
219
|
+
interface DatasourceState {
|
|
220
|
+
id: string;
|
|
221
|
+
lastDeployed: string;
|
|
222
|
+
configChecksum: string;
|
|
223
|
+
}
|
|
224
|
+
interface WorkflowState {
|
|
225
|
+
id: string;
|
|
226
|
+
lastDeployed: string;
|
|
227
|
+
workflowYamlChecksum: string;
|
|
228
|
+
configChecksum: string;
|
|
229
|
+
}
|
|
230
|
+
interface WorkflowYaml {
|
|
231
|
+
assistants: WorkflowAssistantReference[];
|
|
232
|
+
states: WorkflowStateDefinition[];
|
|
233
|
+
}
|
|
234
|
+
interface WorkflowAssistantReference {
|
|
235
|
+
id: string;
|
|
236
|
+
assistant_id?: string;
|
|
237
|
+
assistant_name?: string;
|
|
238
|
+
model?: string;
|
|
239
|
+
name?: string;
|
|
240
|
+
system_prompt?: string;
|
|
241
|
+
}
|
|
242
|
+
interface WorkflowStateDefinition {
|
|
243
|
+
id: string;
|
|
244
|
+
assistant_id: string;
|
|
245
|
+
task: string;
|
|
246
|
+
output_schema: string;
|
|
247
|
+
next?: {
|
|
248
|
+
state_id: string;
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
interface Change {
|
|
252
|
+
type: 'create' | 'update' | 'no-change' | 'delete';
|
|
253
|
+
resourceType: 'assistant' | 'datasource' | 'workflow';
|
|
254
|
+
name: string;
|
|
255
|
+
details?: string;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
declare class CodemieConfigLoader {
|
|
259
|
+
private readonly appConfig;
|
|
260
|
+
constructor(appConfig: AppConfig);
|
|
261
|
+
/**
|
|
262
|
+
* Load and parse the main codemie.yaml configuration file
|
|
263
|
+
*/
|
|
264
|
+
loadConfig(): CodemieConfig;
|
|
265
|
+
/**
|
|
266
|
+
* Load assistant prompt file
|
|
267
|
+
*/
|
|
268
|
+
loadPrompt(promptPath: string): string;
|
|
269
|
+
/**
|
|
270
|
+
* Load assistant configuration file
|
|
271
|
+
*/
|
|
272
|
+
loadAssistantConfig(configPath: string): AssistantConfig;
|
|
273
|
+
/**
|
|
274
|
+
* Validate that all referenced files exist
|
|
275
|
+
*/
|
|
276
|
+
validateFiles(config: CodemieConfig): {
|
|
277
|
+
valid: boolean;
|
|
278
|
+
errors: string[];
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Resolve $import directives recursively
|
|
282
|
+
* Automatically handles:
|
|
283
|
+
* 1. Single resource import (object)
|
|
284
|
+
* 2. Multiple resources import (array)
|
|
285
|
+
* 3. Mixed inline + imports
|
|
286
|
+
* Includes circular import detection to prevent infinite recursion
|
|
287
|
+
*/
|
|
288
|
+
private resolveImports;
|
|
289
|
+
/**
|
|
290
|
+
* Resolve imports in arrays
|
|
291
|
+
* Intelligently handles:
|
|
292
|
+
* - Inline objects (keep as-is)
|
|
293
|
+
* - $import with single object (add to array)
|
|
294
|
+
* - $import with array (flatten into parent array)
|
|
295
|
+
* Includes circular import detection
|
|
296
|
+
*/
|
|
297
|
+
private resolveArrayImports;
|
|
298
|
+
/**
|
|
299
|
+
* Load YAML file with error handling
|
|
300
|
+
*/
|
|
301
|
+
private loadYamlFile;
|
|
302
|
+
/**
|
|
303
|
+
* Recursively resolve all $ref in an object/array structure
|
|
304
|
+
* Handles both object references { $ref: "path" } and string references "$ref:path"
|
|
305
|
+
*
|
|
306
|
+
* @param current - Current node being processed (starts with root config, then recurses into children)
|
|
307
|
+
* @param rootConfig - Root config object (constant reference for resolving paths like "imported.integrations.xxx")
|
|
308
|
+
* @param path - Current path in config tree (for error messages, e.g., "resources.assistants[0].toolkits")
|
|
309
|
+
*/
|
|
310
|
+
private resolveReferencesRecursive;
|
|
311
|
+
/**
|
|
312
|
+
* Resolve $ref items in arrays and flatten if they point to arrays
|
|
313
|
+
* Example: [{ $ref: "context_definitions.repos" }] where repos is [item1, item2]
|
|
314
|
+
* becomes [item1, item2]
|
|
315
|
+
*/
|
|
316
|
+
private resolveArrayReferences;
|
|
317
|
+
/**
|
|
318
|
+
* Resolve object reference: { $ref: "path" }
|
|
319
|
+
* Replaces object with resolved data (in-place mutation)
|
|
320
|
+
*/
|
|
321
|
+
private resolveObjectReference;
|
|
322
|
+
/**
|
|
323
|
+
* Resolve object properties recursively
|
|
324
|
+
* Handles both nested objects and "$ref:path" string references
|
|
325
|
+
*/
|
|
326
|
+
private resolveObjectProperties;
|
|
327
|
+
/**
|
|
328
|
+
* Validate that datasource setting_id fields are strings (not objects)
|
|
329
|
+
* For datasources, setting_id must reference a string UUID, not an integration object
|
|
330
|
+
* Users should use .id suffix: $ref:imported.integrations.git_conn.id
|
|
331
|
+
*/
|
|
332
|
+
private validateDatasourceIntegrationReferences;
|
|
333
|
+
/**
|
|
334
|
+
* Resolve a reference path like "imported.integrations.jira_main" or "tool_definitions.jira_tool"
|
|
335
|
+
* Supports nested paths like "imported.integrations.jira_main.id" to access specific fields
|
|
336
|
+
* Returns the referenced object or value from config
|
|
337
|
+
*
|
|
338
|
+
* Special handling for arrays:
|
|
339
|
+
* - imported.integrations (array): searches by 'alias' field
|
|
340
|
+
* - imported.assistants (array): searches by 'name' field
|
|
341
|
+
* - imported.datasources (array): searches by 'name' field
|
|
342
|
+
*/
|
|
343
|
+
private resolveReference;
|
|
344
|
+
/**
|
|
345
|
+
* Apply datasource defaults based on $ref or type
|
|
346
|
+
* Priority: $ref (explicit) > type (fallback)
|
|
347
|
+
*/
|
|
348
|
+
private applyDatasourceDefaults;
|
|
349
|
+
/**
|
|
350
|
+
* Type guard to check if value is a plain object (not array, not null)
|
|
351
|
+
*/
|
|
352
|
+
private isPlainObject;
|
|
353
|
+
private isRefObject;
|
|
354
|
+
/**
|
|
355
|
+
* Substitute environment variables in configuration
|
|
356
|
+
* Supports syntax:
|
|
357
|
+
* - ${VAR_NAME} - required variable (throws if not set)
|
|
358
|
+
* - ${VAR_NAME:-default} - optional with default value (shell-style)
|
|
359
|
+
* - ${VAR_NAME:default} - optional with default value (simplified)
|
|
360
|
+
* - ${VAR_NAME:-} or ${VAR_NAME:} - optional with empty string default
|
|
361
|
+
*/
|
|
362
|
+
private substituteEnvVars;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
declare class StateManager {
|
|
366
|
+
private readonly statePath;
|
|
367
|
+
constructor(appConfig: AppConfig);
|
|
368
|
+
/**
|
|
369
|
+
* Load state file
|
|
370
|
+
*/
|
|
371
|
+
loadState(): StateFile;
|
|
372
|
+
/**
|
|
373
|
+
* Save state file
|
|
374
|
+
*/
|
|
375
|
+
saveState(state: StateFile): void;
|
|
376
|
+
/**
|
|
377
|
+
* Create empty state structure
|
|
378
|
+
*/
|
|
379
|
+
private createEmptyState;
|
|
380
|
+
/**
|
|
381
|
+
* Update assistant state (keyed by NAME)
|
|
382
|
+
* @param name
|
|
383
|
+
* @param id
|
|
384
|
+
* @param promptContent
|
|
385
|
+
* @param assistantResource - The assistant resource object (used to calculate consistent checksum)
|
|
386
|
+
* @param buildConfig - Optional build-time configuration
|
|
387
|
+
*/
|
|
388
|
+
updateAssistantState(name: string, id: string, promptContent: string, assistantResource: AssistantResource, buildConfig?: unknown): void;
|
|
389
|
+
/**
|
|
390
|
+
* Get assistant state by NAME
|
|
391
|
+
*/
|
|
392
|
+
getAssistantState(name: string): AssistantState | undefined;
|
|
393
|
+
/**
|
|
394
|
+
* Delete assistant state by NAME
|
|
395
|
+
*/
|
|
396
|
+
deleteAssistantState(name: string): void;
|
|
397
|
+
/**
|
|
398
|
+
* Update datasource state (keyed by NAME)
|
|
399
|
+
* @param datasourceResource - The datasource resource object (used to calculate consistent checksum)
|
|
400
|
+
*/
|
|
401
|
+
updateDatasourceState(name: string, id: string, datasourceResource: DatasourceResource): void;
|
|
402
|
+
/**
|
|
403
|
+
* Get datasource state by NAME
|
|
404
|
+
*/
|
|
405
|
+
getDatasourceState(name: string): DatasourceState | undefined;
|
|
406
|
+
/**
|
|
407
|
+
* Delete datasource state by NAME
|
|
408
|
+
*/
|
|
409
|
+
deleteDatasourceState(name: string): void;
|
|
410
|
+
/**
|
|
411
|
+
* Update workflow state (keyed by NAME)
|
|
412
|
+
*/
|
|
413
|
+
updateWorkflowState(name: string, id: string, workflowYamlChecksum: string, configChecksum: string): void;
|
|
414
|
+
/**
|
|
415
|
+
* Get workflow state by NAME
|
|
416
|
+
*/
|
|
417
|
+
getWorkflowState(name: string): WorkflowState | undefined;
|
|
418
|
+
/**
|
|
419
|
+
* Delete workflow state by NAME
|
|
420
|
+
*/
|
|
421
|
+
deleteWorkflowState(name: string): void;
|
|
422
|
+
/**
|
|
423
|
+
* Get all managed resources (for cleanup/destroy)
|
|
424
|
+
* Returns: { assistants: [name1, name2], datasources: [name1], workflows: [name1] }
|
|
425
|
+
*/
|
|
426
|
+
getAllManagedResources(): {
|
|
427
|
+
assistants: string[];
|
|
428
|
+
datasources: string[];
|
|
429
|
+
workflows: string[];
|
|
430
|
+
};
|
|
431
|
+
/**
|
|
432
|
+
* Check if a resource is managed by IaC (exists in state.json)
|
|
433
|
+
* @param type Resource type ('assistant', 'datasource', 'workflow')
|
|
434
|
+
* @param name Resource name
|
|
435
|
+
*/
|
|
436
|
+
isManagedResource(type: 'assistant' | 'datasource' | 'workflow', name: string): boolean;
|
|
437
|
+
/**
|
|
438
|
+
* Get ID by name for a specific resource type
|
|
439
|
+
*/
|
|
440
|
+
getIdByName(type: 'assistant' | 'datasource' | 'workflow', name: string): string | undefined;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Creates and initializes a Codemie API client from config
|
|
445
|
+
*
|
|
446
|
+
* This factory function centralizes client creation to avoid code duplication
|
|
447
|
+
* across multiple scripts (apply, preview, destroy, validate).
|
|
448
|
+
*
|
|
449
|
+
* @param config - Codemie IaC configuration containing environment settings
|
|
450
|
+
* @returns Initialized CodeMieClient ready for API calls
|
|
451
|
+
*/
|
|
452
|
+
declare function createClient(config: CodemieConfig): Promise<CodeMieClient>;
|
|
453
|
+
|
|
454
|
+
interface CleanupResult {
|
|
455
|
+
deleted: {
|
|
456
|
+
assistants: string[];
|
|
457
|
+
datasources: string[];
|
|
458
|
+
workflows: string[];
|
|
459
|
+
};
|
|
460
|
+
errors: Array<{
|
|
461
|
+
type: 'assistant' | 'datasource' | 'workflow';
|
|
462
|
+
name: string;
|
|
463
|
+
error: string;
|
|
464
|
+
}>;
|
|
465
|
+
}
|
|
466
|
+
declare class CleanupManager {
|
|
467
|
+
private client;
|
|
468
|
+
private stateManager;
|
|
469
|
+
constructor(client: CodeMieClient, stateManager: StateManager);
|
|
470
|
+
/**
|
|
471
|
+
* Check if an error indicates that a resource was not found on the platform
|
|
472
|
+
* Handles both proper 404 responses
|
|
473
|
+
*/
|
|
474
|
+
private isNotFoundError;
|
|
475
|
+
/**
|
|
476
|
+
* Delete a resource with graceful handling for "not found" errors
|
|
477
|
+
* Returns true if deleted or not found, false if other error occurred
|
|
478
|
+
*/
|
|
479
|
+
private deleteResourceSafely;
|
|
480
|
+
/**
|
|
481
|
+
* Find orphaned resources (in state but not in config)
|
|
482
|
+
* These are resources that were managed by IaC but removed from codemie.yaml
|
|
483
|
+
* Returns resource NAMES, not IDs
|
|
484
|
+
*/
|
|
485
|
+
findOrphanedResources(config: CodemieConfig): {
|
|
486
|
+
assistants: string[];
|
|
487
|
+
datasources: string[];
|
|
488
|
+
workflows: string[];
|
|
489
|
+
};
|
|
490
|
+
/**
|
|
491
|
+
* Delete orphaned resources from platform
|
|
492
|
+
* SAFETY: Only deletes resources that are in state.json (managed by IaC)
|
|
493
|
+
* @param orphaned Object with resource NAMES (not IDs)
|
|
494
|
+
*/
|
|
495
|
+
deleteOrphanedResources(orphaned: {
|
|
496
|
+
assistants: string[];
|
|
497
|
+
datasources: string[];
|
|
498
|
+
workflows: string[];
|
|
499
|
+
}): Promise<CleanupResult>;
|
|
500
|
+
/**
|
|
501
|
+
* Get summary of orphaned resources
|
|
502
|
+
*/
|
|
503
|
+
getOrphanedSummary(orphaned: {
|
|
504
|
+
assistants: string[];
|
|
505
|
+
datasources: string[];
|
|
506
|
+
workflows: string[];
|
|
507
|
+
}): string;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
declare enum LogLevel {
|
|
511
|
+
DEBUG = 0,
|
|
512
|
+
INFO = 1,
|
|
513
|
+
WARN = 2,
|
|
514
|
+
ERROR = 3,
|
|
515
|
+
SILENT = 4
|
|
516
|
+
}
|
|
517
|
+
declare class Logger {
|
|
518
|
+
private static instance;
|
|
519
|
+
private level;
|
|
520
|
+
private constructor();
|
|
521
|
+
static getInstance(): Logger;
|
|
522
|
+
setLevel(level: LogLevel): void;
|
|
523
|
+
debug(message: string, ...args: unknown[]): void;
|
|
524
|
+
info(message: string, ...args: unknown[]): void;
|
|
525
|
+
warn(message: string, ...args: unknown[]): void;
|
|
526
|
+
error(message: string, ...args: unknown[]): void;
|
|
527
|
+
}
|
|
528
|
+
declare const logger: Logger;
|
|
529
|
+
|
|
530
|
+
interface DeploymentStats {
|
|
531
|
+
created: number;
|
|
532
|
+
updated: number;
|
|
533
|
+
unchanged: number;
|
|
534
|
+
failed: number;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Deploy all assistants from configuration
|
|
538
|
+
* Extracted from main() for better maintainability
|
|
539
|
+
*/
|
|
540
|
+
declare function deployAssistants(config: ReturnType<CodemieConfigLoader['loadConfig']>, client: Awaited<ReturnType<typeof createClient>>, loader: CodemieConfigLoader, stateManager: StateManager): Promise<DeploymentStats>;
|
|
541
|
+
/**
|
|
542
|
+
* Deploy all datasources from configuration
|
|
543
|
+
* Extracted from main() for better maintainability
|
|
544
|
+
*/
|
|
545
|
+
declare function deployDatasources(config: ReturnType<CodemieConfigLoader['loadConfig']>, client: Awaited<ReturnType<typeof createClient>>, stateManager: StateManager): Promise<DeploymentStats>;
|
|
546
|
+
/**
|
|
547
|
+
* Deploy all workflows from configuration
|
|
548
|
+
* Extracted from main() for better maintainability
|
|
549
|
+
*/
|
|
550
|
+
declare function deployWorkflows(config: ReturnType<CodemieConfigLoader['loadConfig']>, client: Awaited<ReturnType<typeof createClient>>, stateManager: StateManager, rootDir?: string): Promise<DeploymentStats>;
|
|
551
|
+
declare function deployResources(options: {
|
|
552
|
+
appConfig: AppConfig;
|
|
553
|
+
prune?: boolean;
|
|
554
|
+
}): Promise<void>;
|
|
555
|
+
|
|
556
|
+
declare function validateConfig(options: {
|
|
557
|
+
appConfig: AppConfig;
|
|
558
|
+
checkApi?: boolean;
|
|
559
|
+
}): Promise<{
|
|
560
|
+
success: boolean;
|
|
561
|
+
errors: string[];
|
|
562
|
+
}>;
|
|
563
|
+
|
|
564
|
+
declare function previewChanges(appConfig: AppConfig, existingClient?: CodeMieClient): Promise<{
|
|
565
|
+
changes: Change[];
|
|
566
|
+
summary: {
|
|
567
|
+
deleted: number;
|
|
568
|
+
created: number;
|
|
569
|
+
updated: number;
|
|
570
|
+
unchanged: number;
|
|
571
|
+
total: number;
|
|
572
|
+
};
|
|
573
|
+
}>;
|
|
574
|
+
|
|
575
|
+
declare function backupResources(options: {
|
|
576
|
+
appConfig: AppConfig;
|
|
577
|
+
}): Promise<void>;
|
|
578
|
+
|
|
579
|
+
declare function destroyResources(options: {
|
|
580
|
+
appConfig: AppConfig;
|
|
581
|
+
force?: boolean;
|
|
582
|
+
}): Promise<void>;
|
|
583
|
+
|
|
584
|
+
export { type AssistantConfig, type AssistantResource, type AssistantState, type Change, CleanupManager, type CodeDatasourceResource, type CodemieConfig, CodemieConfigLoader, type ConfluenceDatasourceResource, type DatasourceResource, type DatasourceState, type FileDatasourceResource, type GoogleDatasourceResource, type IaCMcpServer, type IaCTool, type IaCToolkit, type ImportedResource, type IntegrationDefinition, type IntegrationRef, type IntegrationReference, type JiraDatasourceResource, LogLevel, type OtherDatasourceResource, type StateFile, StateManager, type ToolDefinition, type WorkflowAssistantReference, type WorkflowResource, type WorkflowState, type WorkflowStateDefinition, type WorkflowYaml, backupResources, createClient, deployAssistants, deployDatasources, deployResources, deployWorkflows, destroyResources, logger, previewChanges, validateConfig };
|