@herdctl/core 5.4.3 → 5.6.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/config/__tests__/schema.test.js +19 -0
- package/dist/config/__tests__/schema.test.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +3 -1
- package/dist/config/index.js.map +1 -1
- package/dist/config/schema.d.ts +10 -18
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +4 -2
- package/dist/config/schema.js.map +1 -1
- package/dist/distribution/__tests__/agent-discovery.test.d.ts +7 -0
- package/dist/distribution/__tests__/agent-discovery.test.d.ts.map +1 -0
- package/dist/distribution/__tests__/agent-discovery.test.js +443 -0
- package/dist/distribution/__tests__/agent-discovery.test.js.map +1 -0
- package/dist/distribution/__tests__/agent-info.test.d.ts +7 -0
- package/dist/distribution/__tests__/agent-info.test.d.ts.map +1 -0
- package/dist/distribution/__tests__/agent-info.test.js +568 -0
- package/dist/distribution/__tests__/agent-info.test.js.map +1 -0
- package/dist/distribution/__tests__/agent-remover.test.d.ts +7 -0
- package/dist/distribution/__tests__/agent-remover.test.d.ts.map +1 -0
- package/dist/distribution/__tests__/agent-remover.test.js +498 -0
- package/dist/distribution/__tests__/agent-remover.test.js.map +1 -0
- package/dist/distribution/__tests__/agent-repo-metadata.test.d.ts +5 -0
- package/dist/distribution/__tests__/agent-repo-metadata.test.d.ts.map +1 -0
- package/dist/distribution/__tests__/agent-repo-metadata.test.js +500 -0
- package/dist/distribution/__tests__/agent-repo-metadata.test.js.map +1 -0
- package/dist/distribution/__tests__/env-scanner.test.d.ts +5 -0
- package/dist/distribution/__tests__/env-scanner.test.d.ts.map +1 -0
- package/dist/distribution/__tests__/env-scanner.test.js +576 -0
- package/dist/distribution/__tests__/env-scanner.test.js.map +1 -0
- package/dist/distribution/__tests__/file-installer.test.d.ts +7 -0
- package/dist/distribution/__tests__/file-installer.test.d.ts.map +1 -0
- package/dist/distribution/__tests__/file-installer.test.js +714 -0
- package/dist/distribution/__tests__/file-installer.test.js.map +1 -0
- package/dist/distribution/__tests__/fleet-config-updater.test.d.ts +7 -0
- package/dist/distribution/__tests__/fleet-config-updater.test.d.ts.map +1 -0
- package/dist/distribution/__tests__/fleet-config-updater.test.js +531 -0
- package/dist/distribution/__tests__/fleet-config-updater.test.js.map +1 -0
- package/dist/distribution/__tests__/installation-metadata.test.d.ts +2 -0
- package/dist/distribution/__tests__/installation-metadata.test.d.ts.map +1 -0
- package/dist/distribution/__tests__/installation-metadata.test.js +292 -0
- package/dist/distribution/__tests__/installation-metadata.test.js.map +1 -0
- package/dist/distribution/__tests__/integration.test.d.ts +10 -0
- package/dist/distribution/__tests__/integration.test.d.ts.map +1 -0
- package/dist/distribution/__tests__/integration.test.js +522 -0
- package/dist/distribution/__tests__/integration.test.js.map +1 -0
- package/dist/distribution/__tests__/repository-fetcher.test.d.ts +5 -0
- package/dist/distribution/__tests__/repository-fetcher.test.d.ts.map +1 -0
- package/dist/distribution/__tests__/repository-fetcher.test.js +386 -0
- package/dist/distribution/__tests__/repository-fetcher.test.js.map +1 -0
- package/dist/distribution/__tests__/repository-validator.test.d.ts +7 -0
- package/dist/distribution/__tests__/repository-validator.test.d.ts.map +1 -0
- package/dist/distribution/__tests__/repository-validator.test.js +447 -0
- package/dist/distribution/__tests__/repository-validator.test.js.map +1 -0
- package/dist/distribution/__tests__/source-specifier.test.d.ts +5 -0
- package/dist/distribution/__tests__/source-specifier.test.d.ts.map +1 -0
- package/dist/distribution/__tests__/source-specifier.test.js +533 -0
- package/dist/distribution/__tests__/source-specifier.test.js.map +1 -0
- package/dist/distribution/agent-discovery.d.ts +81 -0
- package/dist/distribution/agent-discovery.d.ts.map +1 -0
- package/dist/distribution/agent-discovery.js +264 -0
- package/dist/distribution/agent-discovery.js.map +1 -0
- package/dist/distribution/agent-info.d.ts +86 -0
- package/dist/distribution/agent-info.d.ts.map +1 -0
- package/dist/distribution/agent-info.js +225 -0
- package/dist/distribution/agent-info.js.map +1 -0
- package/dist/distribution/agent-remover.d.ts +83 -0
- package/dist/distribution/agent-remover.d.ts.map +1 -0
- package/dist/distribution/agent-remover.js +222 -0
- package/dist/distribution/agent-remover.js.map +1 -0
- package/dist/distribution/agent-repo-metadata.d.ts +181 -0
- package/dist/distribution/agent-repo-metadata.d.ts.map +1 -0
- package/dist/distribution/agent-repo-metadata.js +143 -0
- package/dist/distribution/agent-repo-metadata.js.map +1 -0
- package/dist/distribution/env-scanner.d.ts +78 -0
- package/dist/distribution/env-scanner.d.ts.map +1 -0
- package/dist/distribution/env-scanner.js +144 -0
- package/dist/distribution/env-scanner.js.map +1 -0
- package/dist/distribution/file-installer.d.ts +80 -0
- package/dist/distribution/file-installer.d.ts.map +1 -0
- package/dist/distribution/file-installer.js +268 -0
- package/dist/distribution/file-installer.js.map +1 -0
- package/dist/distribution/fleet-config-updater.d.ts +96 -0
- package/dist/distribution/fleet-config-updater.d.ts.map +1 -0
- package/dist/distribution/fleet-config-updater.js +266 -0
- package/dist/distribution/fleet-config-updater.js.map +1 -0
- package/dist/distribution/index.d.ts +23 -0
- package/dist/distribution/index.d.ts.map +1 -0
- package/dist/distribution/index.js +42 -0
- package/dist/distribution/index.js.map +1 -0
- package/dist/distribution/installation-metadata.d.ts +191 -0
- package/dist/distribution/installation-metadata.d.ts.map +1 -0
- package/dist/distribution/installation-metadata.js +100 -0
- package/dist/distribution/installation-metadata.js.map +1 -0
- package/dist/distribution/repository-fetcher.d.ts +104 -0
- package/dist/distribution/repository-fetcher.d.ts.map +1 -0
- package/dist/distribution/repository-fetcher.js +246 -0
- package/dist/distribution/repository-fetcher.js.map +1 -0
- package/dist/distribution/repository-validator.d.ts +86 -0
- package/dist/distribution/repository-validator.d.ts.map +1 -0
- package/dist/distribution/repository-validator.js +296 -0
- package/dist/distribution/repository-validator.js.map +1 -0
- package/dist/distribution/source-specifier.d.ts +106 -0
- package/dist/distribution/source-specifier.d.ts.map +1 -0
- package/dist/distribution/source-specifier.js +247 -0
- package/dist/distribution/source-specifier.js.map +1 -0
- package/dist/fleet-manager/errors.d.ts +15 -0
- package/dist/fleet-manager/errors.d.ts.map +1 -1
- package/dist/fleet-manager/errors.js +16 -0
- package/dist/fleet-manager/errors.js.map +1 -1
- package/dist/fleet-manager/fleet-manager.d.ts.map +1 -1
- package/dist/fleet-manager/fleet-manager.js +32 -9
- package/dist/fleet-manager/fleet-manager.js.map +1 -1
- package/dist/hooks/types.d.ts +2 -3
- package/dist/hooks/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/runner/job-executor.js +10 -10
- package/dist/runner/job-executor.js.map +1 -1
- package/dist/runner/message-processor.d.ts.map +1 -1
- package/dist/runner/message-processor.js +7 -2
- package/dist/runner/message-processor.js.map +1 -1
- package/dist/runner/runtime/cli-runtime.d.ts +3 -2
- package/dist/runner/runtime/cli-runtime.d.ts.map +1 -1
- package/dist/runner/runtime/cli-session-path.d.ts +0 -20
- package/dist/runner/runtime/cli-session-path.d.ts.map +1 -1
- package/dist/runner/runtime/cli-session-path.js +1 -1
- package/dist/runner/runtime/cli-session-path.js.map +1 -1
- package/dist/runner/runtime/container-manager.js +1 -1
- package/dist/runner/runtime/container-manager.js.map +1 -1
- package/dist/runner/runtime/container-runner.d.ts.map +1 -1
- package/dist/runner/runtime/container-runner.js +5 -1
- package/dist/runner/runtime/container-runner.js.map +1 -1
- package/dist/runner/runtime/factory.d.ts +2 -1
- package/dist/runner/runtime/factory.d.ts.map +1 -1
- package/dist/runner/runtime/index.d.ts +4 -10
- package/dist/runner/runtime/index.d.ts.map +1 -1
- package/dist/runner/runtime/index.js +4 -13
- package/dist/runner/runtime/index.js.map +1 -1
- package/dist/scheduler/errors.d.ts +15 -0
- package/dist/scheduler/errors.d.ts.map +1 -1
- package/dist/state/schemas/session-info.d.ts +2 -1
- package/dist/state/schemas/session-info.d.ts.map +1 -1
- package/dist/state/schemas/session-info.js +1 -1
- package/dist/state/schemas/session-info.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Variable Scanner
|
|
3
|
+
*
|
|
4
|
+
* Scans agent.yaml content (as raw text) and extracts all ${VAR} and ${VAR:-default}
|
|
5
|
+
* references. Used to inform users which environment variables they need to set
|
|
6
|
+
* after installing an agent.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const yamlContent = `
|
|
11
|
+
* name: my-agent
|
|
12
|
+
* env:
|
|
13
|
+
* webhook: \${DISCORD_WEBHOOK_URL}
|
|
14
|
+
* token: \${API_TOKEN:-default-token}
|
|
15
|
+
* `;
|
|
16
|
+
*
|
|
17
|
+
* const result = scanEnvVariables(yamlContent);
|
|
18
|
+
* // result = {
|
|
19
|
+
* // variables: [
|
|
20
|
+
* // { name: "API_TOKEN", defaultValue: "default-token" },
|
|
21
|
+
* // { name: "DISCORD_WEBHOOK_URL" }
|
|
22
|
+
* // ],
|
|
23
|
+
* // required: [{ name: "DISCORD_WEBHOOK_URL" }],
|
|
24
|
+
* // optional: [{ name: "API_TOKEN", defaultValue: "default-token" }]
|
|
25
|
+
* // }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Represents an environment variable reference found in the YAML content.
|
|
30
|
+
*/
|
|
31
|
+
export interface EnvVariable {
|
|
32
|
+
/** The variable name (e.g., "DISCORD_WEBHOOK_URL") */
|
|
33
|
+
name: string;
|
|
34
|
+
/** The default value if specified with :- syntax, or undefined */
|
|
35
|
+
defaultValue?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Result of scanning YAML content for environment variable references.
|
|
39
|
+
*/
|
|
40
|
+
export interface EnvScanResult {
|
|
41
|
+
/** All unique environment variables found, sorted alphabetically */
|
|
42
|
+
variables: EnvVariable[];
|
|
43
|
+
/** Variables that have no default value (user MUST set these) */
|
|
44
|
+
required: EnvVariable[];
|
|
45
|
+
/** Variables that have a default value (optional to set) */
|
|
46
|
+
optional: EnvVariable[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Scans YAML content for environment variable references.
|
|
50
|
+
*
|
|
51
|
+
* This function scans raw text (not parsed YAML) to extract all ${VAR} and
|
|
52
|
+
* ${VAR:-default} patterns. It:
|
|
53
|
+
* - Deduplicates variables (same name only listed once)
|
|
54
|
+
* - Prefers entries with defaults when a variable appears both with and without
|
|
55
|
+
* - Sorts alphabetically by variable name
|
|
56
|
+
* - Partitions into required (no default) and optional (has default) lists
|
|
57
|
+
* - Excludes HERDCTL_* prefixed variables (internal to herdctl)
|
|
58
|
+
*
|
|
59
|
+
* @param yamlContent - The raw YAML file content to scan
|
|
60
|
+
* @returns EnvScanResult with variables, required, and optional arrays
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const result = scanEnvVariables(`
|
|
65
|
+
* webhook: \${WEBHOOK_URL}
|
|
66
|
+
* api_key: \${API_KEY:-sk-default}
|
|
67
|
+
* # Comment with \${COMMENT_VAR}
|
|
68
|
+
* `);
|
|
69
|
+
*
|
|
70
|
+
* // result.variables = [
|
|
71
|
+
* // { name: "API_KEY", defaultValue: "sk-default" },
|
|
72
|
+
* // { name: "COMMENT_VAR" },
|
|
73
|
+
* // { name: "WEBHOOK_URL" }
|
|
74
|
+
* // ]
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function scanEnvVariables(yamlContent: string): EnvScanResult;
|
|
78
|
+
//# sourceMappingURL=env-scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-scanner.d.ts","sourceRoot":"","sources":["../../src/distribution/env-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAMH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,iEAAiE;IACjE,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,4DAA4D;IAC5D,QAAQ,EAAE,WAAW,EAAE,CAAC;CACzB;AAoCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,CAiEnE"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Variable Scanner
|
|
3
|
+
*
|
|
4
|
+
* Scans agent.yaml content (as raw text) and extracts all ${VAR} and ${VAR:-default}
|
|
5
|
+
* references. Used to inform users which environment variables they need to set
|
|
6
|
+
* after installing an agent.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const yamlContent = `
|
|
11
|
+
* name: my-agent
|
|
12
|
+
* env:
|
|
13
|
+
* webhook: \${DISCORD_WEBHOOK_URL}
|
|
14
|
+
* token: \${API_TOKEN:-default-token}
|
|
15
|
+
* `;
|
|
16
|
+
*
|
|
17
|
+
* const result = scanEnvVariables(yamlContent);
|
|
18
|
+
* // result = {
|
|
19
|
+
* // variables: [
|
|
20
|
+
* // { name: "API_TOKEN", defaultValue: "default-token" },
|
|
21
|
+
* // { name: "DISCORD_WEBHOOK_URL" }
|
|
22
|
+
* // ],
|
|
23
|
+
* // required: [{ name: "DISCORD_WEBHOOK_URL" }],
|
|
24
|
+
* // optional: [{ name: "API_TOKEN", defaultValue: "default-token" }]
|
|
25
|
+
* // }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
// =============================================================================
|
|
29
|
+
// Constants
|
|
30
|
+
// =============================================================================
|
|
31
|
+
/**
|
|
32
|
+
* Regular expression to match ${VAR} and ${VAR:-default} patterns.
|
|
33
|
+
* This is the same pattern used in packages/core/src/config/interpolate.ts.
|
|
34
|
+
*
|
|
35
|
+
* Captures:
|
|
36
|
+
* - Group 1: Variable name (letters, numbers, underscores, starting with letter or underscore)
|
|
37
|
+
* - Group 2: Default value (everything after :- if present)
|
|
38
|
+
*/
|
|
39
|
+
const ENV_VAR_PATTERN = /\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-([^}]*))?\}/g;
|
|
40
|
+
/**
|
|
41
|
+
* Variables to exclude from scan results.
|
|
42
|
+
* These are herdctl-internal variables, not agent-specific configuration.
|
|
43
|
+
*/
|
|
44
|
+
const EXCLUDED_PREFIXES = ["HERDCTL_"];
|
|
45
|
+
// =============================================================================
|
|
46
|
+
// Implementation
|
|
47
|
+
// =============================================================================
|
|
48
|
+
/**
|
|
49
|
+
* Checks if a variable name should be excluded from results.
|
|
50
|
+
*
|
|
51
|
+
* @param name - The variable name to check
|
|
52
|
+
* @returns true if the variable should be excluded
|
|
53
|
+
*/
|
|
54
|
+
function shouldExclude(name) {
|
|
55
|
+
return EXCLUDED_PREFIXES.some((prefix) => name.startsWith(prefix));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Scans YAML content for environment variable references.
|
|
59
|
+
*
|
|
60
|
+
* This function scans raw text (not parsed YAML) to extract all ${VAR} and
|
|
61
|
+
* ${VAR:-default} patterns. It:
|
|
62
|
+
* - Deduplicates variables (same name only listed once)
|
|
63
|
+
* - Prefers entries with defaults when a variable appears both with and without
|
|
64
|
+
* - Sorts alphabetically by variable name
|
|
65
|
+
* - Partitions into required (no default) and optional (has default) lists
|
|
66
|
+
* - Excludes HERDCTL_* prefixed variables (internal to herdctl)
|
|
67
|
+
*
|
|
68
|
+
* @param yamlContent - The raw YAML file content to scan
|
|
69
|
+
* @returns EnvScanResult with variables, required, and optional arrays
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const result = scanEnvVariables(`
|
|
74
|
+
* webhook: \${WEBHOOK_URL}
|
|
75
|
+
* api_key: \${API_KEY:-sk-default}
|
|
76
|
+
* # Comment with \${COMMENT_VAR}
|
|
77
|
+
* `);
|
|
78
|
+
*
|
|
79
|
+
* // result.variables = [
|
|
80
|
+
* // { name: "API_KEY", defaultValue: "sk-default" },
|
|
81
|
+
* // { name: "COMMENT_VAR" },
|
|
82
|
+
* // { name: "WEBHOOK_URL" }
|
|
83
|
+
* // ]
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export function scanEnvVariables(yamlContent) {
|
|
87
|
+
// Handle empty or non-string input
|
|
88
|
+
if (!yamlContent || typeof yamlContent !== "string") {
|
|
89
|
+
return {
|
|
90
|
+
variables: [],
|
|
91
|
+
required: [],
|
|
92
|
+
optional: [],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// Map to track unique variables, preferring entries with defaults
|
|
96
|
+
const variableMap = new Map();
|
|
97
|
+
// Reset regex state (global regexes are stateful)
|
|
98
|
+
ENV_VAR_PATTERN.lastIndex = 0;
|
|
99
|
+
// Find all matches
|
|
100
|
+
let match = null;
|
|
101
|
+
while ((match = ENV_VAR_PATTERN.exec(yamlContent)) !== null) {
|
|
102
|
+
const name = match[1];
|
|
103
|
+
const defaultValue = match[2];
|
|
104
|
+
// Skip excluded variables
|
|
105
|
+
if (shouldExclude(name)) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const existing = variableMap.get(name);
|
|
109
|
+
// If variable already exists, prefer the entry with a default value
|
|
110
|
+
if (existing) {
|
|
111
|
+
if (defaultValue !== undefined && existing.defaultValue === undefined) {
|
|
112
|
+
variableMap.set(name, { name, defaultValue });
|
|
113
|
+
}
|
|
114
|
+
// Otherwise keep existing (either already has default, or neither has default)
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
// First occurrence of this variable
|
|
118
|
+
const variable = { name };
|
|
119
|
+
if (defaultValue !== undefined) {
|
|
120
|
+
variable.defaultValue = defaultValue;
|
|
121
|
+
}
|
|
122
|
+
variableMap.set(name, variable);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// Convert to array and sort alphabetically by name
|
|
126
|
+
const variables = Array.from(variableMap.values()).sort((a, b) => a.name.localeCompare(b.name));
|
|
127
|
+
// Partition into required and optional
|
|
128
|
+
const required = [];
|
|
129
|
+
const optional = [];
|
|
130
|
+
for (const variable of variables) {
|
|
131
|
+
if (variable.defaultValue !== undefined) {
|
|
132
|
+
optional.push(variable);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
required.push(variable);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
variables,
|
|
140
|
+
required,
|
|
141
|
+
optional,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=env-scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-scanner.js","sourceRoot":"","sources":["../../src/distribution/env-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AA4BH,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF;;;;;;;GAOG;AACH,MAAM,eAAe,GAAG,+CAA+C,CAAC;AAExE;;;GAGG;AACH,MAAM,iBAAiB,GAAG,CAAC,UAAU,CAAC,CAAC;AAEvC,gFAAgF;AAChF,iBAAiB;AACjB,gFAAgF;AAEhF;;;;;GAKG;AACH,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;AACrE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAmB;IAClD,mCAAm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nD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAEhG,uCAAuC;IACvC,MAAM,QAAQ,GAAkB,EAAE,CAAC;IACnC,MAAM,QAAQ,GAAkB,EAAE,CAAC;IAEnC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,QAAQ,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACxC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1B,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,OAAO;QACL,SAAS;QACT,QAAQ;QACR,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Installation for Agent Distribution
|
|
3
|
+
*
|
|
4
|
+
* Copies agent files from a fetched/temp directory to `./agents/<name>/` in the
|
|
5
|
+
* user's project. Creates the workspace directory and writes installation metadata.
|
|
6
|
+
*/
|
|
7
|
+
import { FleetManagerError, type FleetManagerErrorCode } from "../fleet-manager/errors.js";
|
|
8
|
+
import type { InstallationSource } from "./installation-metadata.js";
|
|
9
|
+
/**
|
|
10
|
+
* Options for installing agent files
|
|
11
|
+
*/
|
|
12
|
+
export interface InstallOptions {
|
|
13
|
+
/** The directory containing the fetched agent repo files */
|
|
14
|
+
sourceDir: string;
|
|
15
|
+
/** The target base directory (where agents/ lives, usually project root) */
|
|
16
|
+
targetBaseDir: string;
|
|
17
|
+
/** The source specifier info for metadata tracking */
|
|
18
|
+
source: InstallationSource;
|
|
19
|
+
/** Optional: override the target path instead of using ./agents/<name>/ */
|
|
20
|
+
targetPath?: string;
|
|
21
|
+
/** If true, remove existing target directory before installing */
|
|
22
|
+
force?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Result of a successful agent file installation
|
|
26
|
+
*/
|
|
27
|
+
export interface InstallResult {
|
|
28
|
+
/** The agent name (from agent.yaml) */
|
|
29
|
+
agentName: string;
|
|
30
|
+
/** The full path to the installed agent directory */
|
|
31
|
+
installPath: string;
|
|
32
|
+
/** List of files that were copied (relative paths) */
|
|
33
|
+
copiedFiles: string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Error codes for agent installation failures
|
|
37
|
+
*/
|
|
38
|
+
export declare const AGENT_ALREADY_EXISTS: FleetManagerErrorCode;
|
|
39
|
+
export declare const INVALID_AGENT_NAME: FleetManagerErrorCode;
|
|
40
|
+
export declare const MISSING_AGENT_YAML: FleetManagerErrorCode;
|
|
41
|
+
export declare const INVALID_AGENT_YAML: FleetManagerErrorCode;
|
|
42
|
+
/**
|
|
43
|
+
* Error thrown when agent file installation fails
|
|
44
|
+
*/
|
|
45
|
+
export declare class AgentInstallError extends FleetManagerError {
|
|
46
|
+
constructor(message: string, code: FleetManagerErrorCode);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Install agent files from a source directory to the target location
|
|
50
|
+
*
|
|
51
|
+
* This function:
|
|
52
|
+
* 1. Reads the agent name from `agent.yaml` in the source directory
|
|
53
|
+
* 2. Validates the agent name against AGENT_NAME_PATTERN
|
|
54
|
+
* 3. Checks that the target directory doesn't already exist
|
|
55
|
+
* 4. Copies all files from source to target, excluding `.git/` and `node_modules/`
|
|
56
|
+
* 5. Creates an empty `workspace/` directory for agent runtime use
|
|
57
|
+
* 6. Writes `metadata.json` with installation tracking information
|
|
58
|
+
*
|
|
59
|
+
* @param options - Installation options
|
|
60
|
+
* @returns Installation result with agent name, install path, and copied files
|
|
61
|
+
* @throws {AgentInstallError} When installation fails
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const result = await installAgentFiles({
|
|
66
|
+
* sourceDir: "/tmp/herdctl-github-xxxxx",
|
|
67
|
+
* targetBaseDir: "/path/to/project",
|
|
68
|
+
* source: {
|
|
69
|
+
* type: "github",
|
|
70
|
+
* url: "https://github.com/user/agent-repo",
|
|
71
|
+
* ref: "v1.0.0"
|
|
72
|
+
* }
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* console.log(`Installed ${result.agentName} to ${result.installPath}`);
|
|
76
|
+
* console.log(`Copied ${result.copiedFiles.length} files`);
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare function installAgentFiles(options: InstallOptions): Promise<InstallResult>;
|
|
80
|
+
//# sourceMappingURL=file-installer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-installer.d.ts","sourceRoot":"","sources":["../../src/distribution/file-installer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,iBAAiB,EAAE,KAAK,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAG3F,OAAO,KAAK,EAAwB,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAQ3F;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,aAAa,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,MAAM,EAAE,kBAAkB,CAAC;IAC3B,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAMD;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,qBAA8C,CAAC;AAClF,eAAO,MAAM,kBAAkB,EAAE,qBAA4C,CAAC;AAC9E,eAAO,MAAM,kBAAkB,EAAE,qBAA4C,CAAC;AAC9E,eAAO,MAAM,kBAAkB,EAAE,qBAA4C,CAAC;AAE9E;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,iBAAiB;gBAC1C,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB;CAIzD;AA8LD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CA+EvF"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Installation for Agent Distribution
|
|
3
|
+
*
|
|
4
|
+
* Copies agent files from a fetched/temp directory to `./agents/<name>/` in the
|
|
5
|
+
* user's project. Creates the workspace directory and writes installation metadata.
|
|
6
|
+
*/
|
|
7
|
+
import { access, cp, mkdir, readdir, readFile, writeFile } from "node:fs/promises";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { parse as parseYaml, YAMLParseError } from "yaml";
|
|
10
|
+
import { FleetManagerError } from "../fleet-manager/errors.js";
|
|
11
|
+
import { createLogger } from "../utils/logger.js";
|
|
12
|
+
import { AGENT_NAME_PATTERN } from "./agent-repo-metadata.js";
|
|
13
|
+
const logger = createLogger("distribution:installer");
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// Error Classes
|
|
16
|
+
// =============================================================================
|
|
17
|
+
/**
|
|
18
|
+
* Error codes for agent installation failures
|
|
19
|
+
*/
|
|
20
|
+
export const AGENT_ALREADY_EXISTS = "AGENT_ALREADY_EXISTS";
|
|
21
|
+
export const INVALID_AGENT_NAME = "INVALID_AGENT_NAME";
|
|
22
|
+
export const MISSING_AGENT_YAML = "MISSING_AGENT_YAML";
|
|
23
|
+
export const INVALID_AGENT_YAML = "INVALID_AGENT_YAML";
|
|
24
|
+
/**
|
|
25
|
+
* Error thrown when agent file installation fails
|
|
26
|
+
*/
|
|
27
|
+
export class AgentInstallError extends FleetManagerError {
|
|
28
|
+
constructor(message, code) {
|
|
29
|
+
super(message, { code });
|
|
30
|
+
this.name = "AgentInstallError";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// =============================================================================
|
|
34
|
+
// Constants
|
|
35
|
+
// =============================================================================
|
|
36
|
+
/**
|
|
37
|
+
* Directories to exclude when copying agent files
|
|
38
|
+
*/
|
|
39
|
+
const EXCLUDED_DIRS = new Set([".git", "node_modules"]);
|
|
40
|
+
/**
|
|
41
|
+
* Metadata file name for installation tracking
|
|
42
|
+
*/
|
|
43
|
+
const METADATA_FILE = "metadata.json";
|
|
44
|
+
/**
|
|
45
|
+
* Workspace directory name (created for agent runtime use)
|
|
46
|
+
*/
|
|
47
|
+
const WORKSPACE_DIR = "workspace";
|
|
48
|
+
// =============================================================================
|
|
49
|
+
// Helper Functions
|
|
50
|
+
// =============================================================================
|
|
51
|
+
/**
|
|
52
|
+
* Check if a path exists
|
|
53
|
+
*/
|
|
54
|
+
async function pathExists(filePath) {
|
|
55
|
+
try {
|
|
56
|
+
await access(filePath);
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Read and parse agent.yaml to extract the agent name
|
|
65
|
+
*/
|
|
66
|
+
async function readAgentName(sourceDir) {
|
|
67
|
+
const agentYamlPath = join(sourceDir, "agent.yaml");
|
|
68
|
+
// Check if agent.yaml exists
|
|
69
|
+
if (!(await pathExists(agentYamlPath))) {
|
|
70
|
+
throw new AgentInstallError(`agent.yaml not found in source directory: ${sourceDir}`, MISSING_AGENT_YAML);
|
|
71
|
+
}
|
|
72
|
+
// Read and parse the file
|
|
73
|
+
let content;
|
|
74
|
+
try {
|
|
75
|
+
content = await readFile(agentYamlPath, "utf-8");
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
const error = err;
|
|
79
|
+
throw new AgentInstallError(`Failed to read agent.yaml: ${error.message}`, MISSING_AGENT_YAML);
|
|
80
|
+
}
|
|
81
|
+
// Parse YAML
|
|
82
|
+
let parsed;
|
|
83
|
+
try {
|
|
84
|
+
parsed = parseYaml(content);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
if (err instanceof YAMLParseError) {
|
|
88
|
+
const position = err.linePos?.[0];
|
|
89
|
+
const locationInfo = position ? ` at line ${position.line}, column ${position.col}` : "";
|
|
90
|
+
throw new AgentInstallError(`Invalid YAML syntax in agent.yaml${locationInfo}: ${err.message}`, INVALID_AGENT_YAML);
|
|
91
|
+
}
|
|
92
|
+
throw new AgentInstallError(`Failed to parse agent.yaml: ${err.message}`, INVALID_AGENT_YAML);
|
|
93
|
+
}
|
|
94
|
+
// Extract and validate name
|
|
95
|
+
if (!parsed || typeof parsed !== "object") {
|
|
96
|
+
throw new AgentInstallError("agent.yaml must contain a valid YAML object with a 'name' field", INVALID_AGENT_YAML);
|
|
97
|
+
}
|
|
98
|
+
const data = parsed;
|
|
99
|
+
const name = data.name;
|
|
100
|
+
if (typeof name !== "string" || name.trim() === "") {
|
|
101
|
+
throw new AgentInstallError("agent.yaml must have a 'name' field with a non-empty string value", INVALID_AGENT_YAML);
|
|
102
|
+
}
|
|
103
|
+
return name;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Validate an agent name against the AGENT_NAME_PATTERN
|
|
107
|
+
*/
|
|
108
|
+
function validateAgentName(name) {
|
|
109
|
+
if (!AGENT_NAME_PATTERN.test(name)) {
|
|
110
|
+
throw new AgentInstallError(`Invalid agent name "${name}". Agent names must start with a letter or number ` +
|
|
111
|
+
`and contain only letters, numbers, underscores, and hyphens.`, INVALID_AGENT_NAME);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Recursively copy directory contents, excluding specified directories.
|
|
116
|
+
* Returns the list of copied files (relative paths).
|
|
117
|
+
*/
|
|
118
|
+
async function copyDirectoryRecursive(sourceDir, targetDir, excludedDirs, relativePath = "") {
|
|
119
|
+
const copiedFiles = [];
|
|
120
|
+
// Create target directory if it doesn't exist
|
|
121
|
+
await mkdir(targetDir, { recursive: true });
|
|
122
|
+
// Read source directory contents
|
|
123
|
+
const entries = await readdir(sourceDir, { withFileTypes: true });
|
|
124
|
+
for (const entry of entries) {
|
|
125
|
+
const sourcePath = join(sourceDir, entry.name);
|
|
126
|
+
const targetPath = join(targetDir, entry.name);
|
|
127
|
+
const entryRelativePath = relativePath ? join(relativePath, entry.name) : entry.name;
|
|
128
|
+
if (entry.isDirectory()) {
|
|
129
|
+
// Skip excluded directories
|
|
130
|
+
if (excludedDirs.has(entry.name)) {
|
|
131
|
+
logger.debug("Skipping excluded directory", { path: entryRelativePath });
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
// Recursively copy subdirectory
|
|
135
|
+
const subFiles = await copyDirectoryRecursive(sourcePath, targetPath, excludedDirs, entryRelativePath);
|
|
136
|
+
copiedFiles.push(...subFiles);
|
|
137
|
+
}
|
|
138
|
+
else if (entry.isFile()) {
|
|
139
|
+
// Copy file
|
|
140
|
+
await cp(sourcePath, targetPath);
|
|
141
|
+
copiedFiles.push(entryRelativePath);
|
|
142
|
+
}
|
|
143
|
+
// Skip symlinks and other special files
|
|
144
|
+
}
|
|
145
|
+
return copiedFiles;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Write installation metadata to metadata.json
|
|
149
|
+
*/
|
|
150
|
+
async function writeMetadata(installPath, source) {
|
|
151
|
+
const metadata = {
|
|
152
|
+
source,
|
|
153
|
+
installed_at: new Date().toISOString(),
|
|
154
|
+
installed_by: `herdctl@${getHerdctlVersion()}`,
|
|
155
|
+
};
|
|
156
|
+
const metadataPath = join(installPath, METADATA_FILE);
|
|
157
|
+
await writeFile(metadataPath, JSON.stringify(metadata, null, 2), "utf-8");
|
|
158
|
+
logger.debug("Wrote metadata.json", { path: metadataPath });
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get herdctl version from package.json (simplified - returns unknown if not found)
|
|
162
|
+
*/
|
|
163
|
+
function getHerdctlVersion() {
|
|
164
|
+
// In a real implementation, this would read from package.json
|
|
165
|
+
// For now, we return a placeholder that will be replaced with actual version
|
|
166
|
+
return "unknown";
|
|
167
|
+
}
|
|
168
|
+
// =============================================================================
|
|
169
|
+
// Main Installer
|
|
170
|
+
// =============================================================================
|
|
171
|
+
/**
|
|
172
|
+
* Install agent files from a source directory to the target location
|
|
173
|
+
*
|
|
174
|
+
* This function:
|
|
175
|
+
* 1. Reads the agent name from `agent.yaml` in the source directory
|
|
176
|
+
* 2. Validates the agent name against AGENT_NAME_PATTERN
|
|
177
|
+
* 3. Checks that the target directory doesn't already exist
|
|
178
|
+
* 4. Copies all files from source to target, excluding `.git/` and `node_modules/`
|
|
179
|
+
* 5. Creates an empty `workspace/` directory for agent runtime use
|
|
180
|
+
* 6. Writes `metadata.json` with installation tracking information
|
|
181
|
+
*
|
|
182
|
+
* @param options - Installation options
|
|
183
|
+
* @returns Installation result with agent name, install path, and copied files
|
|
184
|
+
* @throws {AgentInstallError} When installation fails
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* const result = await installAgentFiles({
|
|
189
|
+
* sourceDir: "/tmp/herdctl-github-xxxxx",
|
|
190
|
+
* targetBaseDir: "/path/to/project",
|
|
191
|
+
* source: {
|
|
192
|
+
* type: "github",
|
|
193
|
+
* url: "https://github.com/user/agent-repo",
|
|
194
|
+
* ref: "v1.0.0"
|
|
195
|
+
* }
|
|
196
|
+
* });
|
|
197
|
+
*
|
|
198
|
+
* console.log(`Installed ${result.agentName} to ${result.installPath}`);
|
|
199
|
+
* console.log(`Copied ${result.copiedFiles.length} files`);
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
export async function installAgentFiles(options) {
|
|
203
|
+
const { sourceDir, targetBaseDir, source, targetPath, force } = options;
|
|
204
|
+
logger.debug("Starting agent file installation", {
|
|
205
|
+
sourceDir,
|
|
206
|
+
targetBaseDir,
|
|
207
|
+
sourceType: source.type,
|
|
208
|
+
targetPath,
|
|
209
|
+
force,
|
|
210
|
+
});
|
|
211
|
+
// ==========================================================================
|
|
212
|
+
// 1. Read agent name from agent.yaml
|
|
213
|
+
// ==========================================================================
|
|
214
|
+
const agentName = await readAgentName(sourceDir);
|
|
215
|
+
logger.debug("Read agent name from agent.yaml", { agentName });
|
|
216
|
+
// ==========================================================================
|
|
217
|
+
// 2. Validate agent name
|
|
218
|
+
// ==========================================================================
|
|
219
|
+
validateAgentName(agentName);
|
|
220
|
+
logger.debug("Agent name validated", { agentName });
|
|
221
|
+
// ==========================================================================
|
|
222
|
+
// 3. Determine target path and check it doesn't exist (unless force)
|
|
223
|
+
// ==========================================================================
|
|
224
|
+
const installPath = targetPath ?? join(targetBaseDir, "agents", agentName);
|
|
225
|
+
if (await pathExists(installPath)) {
|
|
226
|
+
if (force) {
|
|
227
|
+
// Remove existing directory when force is true
|
|
228
|
+
logger.debug("Force mode: removing existing directory", { installPath });
|
|
229
|
+
const { rm } = await import("node:fs/promises");
|
|
230
|
+
await rm(installPath, { recursive: true, force: true });
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
throw new AgentInstallError(`Agent "${agentName}" already exists at ${installPath}. ` +
|
|
234
|
+
`Remove the existing agent first or use a different name.`, AGENT_ALREADY_EXISTS);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
logger.debug("Target path determined", { installPath });
|
|
238
|
+
// ==========================================================================
|
|
239
|
+
// 4. Copy files (excluding .git and node_modules)
|
|
240
|
+
// ==========================================================================
|
|
241
|
+
logger.info("Copying agent files", {
|
|
242
|
+
source: sourceDir,
|
|
243
|
+
destination: installPath,
|
|
244
|
+
});
|
|
245
|
+
const copiedFiles = await copyDirectoryRecursive(sourceDir, installPath, EXCLUDED_DIRS);
|
|
246
|
+
logger.debug("Files copied", { count: copiedFiles.length });
|
|
247
|
+
// ==========================================================================
|
|
248
|
+
// 5. Create workspace directory
|
|
249
|
+
// ==========================================================================
|
|
250
|
+
const workspacePath = join(installPath, WORKSPACE_DIR);
|
|
251
|
+
await mkdir(workspacePath, { recursive: true });
|
|
252
|
+
logger.debug("Created workspace directory", { path: workspacePath });
|
|
253
|
+
// ==========================================================================
|
|
254
|
+
// 6. Write metadata.json
|
|
255
|
+
// ==========================================================================
|
|
256
|
+
await writeMetadata(installPath, source);
|
|
257
|
+
logger.info("Agent installation complete", {
|
|
258
|
+
agentName,
|
|
259
|
+
installPath,
|
|
260
|
+
copiedFiles: copiedFiles.length,
|
|
261
|
+
});
|
|
262
|
+
return {
|
|
263
|
+
agentName,
|
|
264
|
+
installPath,
|
|
265
|
+
copiedFiles,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=file-installer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-installer.js","sourceRoot":"","sources":["../../src/distribution/file-installer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAQ,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAA8B,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D,MAAM,MAAM,GAAG,YAAY,CAAC,wBAAwB,CAAC,CAAC;AAkCtD,gFAAgF;AAChF,gBAA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