@herdctl/core 5.5.0 → 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.
Files changed (119) hide show
  1. package/dist/config/index.d.ts +1 -1
  2. package/dist/config/index.d.ts.map +1 -1
  3. package/dist/config/index.js +3 -1
  4. package/dist/config/index.js.map +1 -1
  5. package/dist/distribution/__tests__/agent-discovery.test.d.ts +7 -0
  6. package/dist/distribution/__tests__/agent-discovery.test.d.ts.map +1 -0
  7. package/dist/distribution/__tests__/agent-discovery.test.js +443 -0
  8. package/dist/distribution/__tests__/agent-discovery.test.js.map +1 -0
  9. package/dist/distribution/__tests__/agent-info.test.d.ts +7 -0
  10. package/dist/distribution/__tests__/agent-info.test.d.ts.map +1 -0
  11. package/dist/distribution/__tests__/agent-info.test.js +568 -0
  12. package/dist/distribution/__tests__/agent-info.test.js.map +1 -0
  13. package/dist/distribution/__tests__/agent-remover.test.d.ts +7 -0
  14. package/dist/distribution/__tests__/agent-remover.test.d.ts.map +1 -0
  15. package/dist/distribution/__tests__/agent-remover.test.js +498 -0
  16. package/dist/distribution/__tests__/agent-remover.test.js.map +1 -0
  17. package/dist/distribution/__tests__/agent-repo-metadata.test.d.ts +5 -0
  18. package/dist/distribution/__tests__/agent-repo-metadata.test.d.ts.map +1 -0
  19. package/dist/distribution/__tests__/agent-repo-metadata.test.js +500 -0
  20. package/dist/distribution/__tests__/agent-repo-metadata.test.js.map +1 -0
  21. package/dist/distribution/__tests__/env-scanner.test.d.ts +5 -0
  22. package/dist/distribution/__tests__/env-scanner.test.d.ts.map +1 -0
  23. package/dist/distribution/__tests__/env-scanner.test.js +576 -0
  24. package/dist/distribution/__tests__/env-scanner.test.js.map +1 -0
  25. package/dist/distribution/__tests__/file-installer.test.d.ts +7 -0
  26. package/dist/distribution/__tests__/file-installer.test.d.ts.map +1 -0
  27. package/dist/distribution/__tests__/file-installer.test.js +714 -0
  28. package/dist/distribution/__tests__/file-installer.test.js.map +1 -0
  29. package/dist/distribution/__tests__/fleet-config-updater.test.d.ts +7 -0
  30. package/dist/distribution/__tests__/fleet-config-updater.test.d.ts.map +1 -0
  31. package/dist/distribution/__tests__/fleet-config-updater.test.js +531 -0
  32. package/dist/distribution/__tests__/fleet-config-updater.test.js.map +1 -0
  33. package/dist/distribution/__tests__/installation-metadata.test.d.ts +2 -0
  34. package/dist/distribution/__tests__/installation-metadata.test.d.ts.map +1 -0
  35. package/dist/distribution/__tests__/installation-metadata.test.js +292 -0
  36. package/dist/distribution/__tests__/installation-metadata.test.js.map +1 -0
  37. package/dist/distribution/__tests__/integration.test.d.ts +10 -0
  38. package/dist/distribution/__tests__/integration.test.d.ts.map +1 -0
  39. package/dist/distribution/__tests__/integration.test.js +522 -0
  40. package/dist/distribution/__tests__/integration.test.js.map +1 -0
  41. package/dist/distribution/__tests__/repository-fetcher.test.d.ts +5 -0
  42. package/dist/distribution/__tests__/repository-fetcher.test.d.ts.map +1 -0
  43. package/dist/distribution/__tests__/repository-fetcher.test.js +386 -0
  44. package/dist/distribution/__tests__/repository-fetcher.test.js.map +1 -0
  45. package/dist/distribution/__tests__/repository-validator.test.d.ts +7 -0
  46. package/dist/distribution/__tests__/repository-validator.test.d.ts.map +1 -0
  47. package/dist/distribution/__tests__/repository-validator.test.js +447 -0
  48. package/dist/distribution/__tests__/repository-validator.test.js.map +1 -0
  49. package/dist/distribution/__tests__/source-specifier.test.d.ts +5 -0
  50. package/dist/distribution/__tests__/source-specifier.test.d.ts.map +1 -0
  51. package/dist/distribution/__tests__/source-specifier.test.js +533 -0
  52. package/dist/distribution/__tests__/source-specifier.test.js.map +1 -0
  53. package/dist/distribution/agent-discovery.d.ts +81 -0
  54. package/dist/distribution/agent-discovery.d.ts.map +1 -0
  55. package/dist/distribution/agent-discovery.js +264 -0
  56. package/dist/distribution/agent-discovery.js.map +1 -0
  57. package/dist/distribution/agent-info.d.ts +86 -0
  58. package/dist/distribution/agent-info.d.ts.map +1 -0
  59. package/dist/distribution/agent-info.js +225 -0
  60. package/dist/distribution/agent-info.js.map +1 -0
  61. package/dist/distribution/agent-remover.d.ts +83 -0
  62. package/dist/distribution/agent-remover.d.ts.map +1 -0
  63. package/dist/distribution/agent-remover.js +222 -0
  64. package/dist/distribution/agent-remover.js.map +1 -0
  65. package/dist/distribution/agent-repo-metadata.d.ts +181 -0
  66. package/dist/distribution/agent-repo-metadata.d.ts.map +1 -0
  67. package/dist/distribution/agent-repo-metadata.js +143 -0
  68. package/dist/distribution/agent-repo-metadata.js.map +1 -0
  69. package/dist/distribution/env-scanner.d.ts +78 -0
  70. package/dist/distribution/env-scanner.d.ts.map +1 -0
  71. package/dist/distribution/env-scanner.js +144 -0
  72. package/dist/distribution/env-scanner.js.map +1 -0
  73. package/dist/distribution/file-installer.d.ts +80 -0
  74. package/dist/distribution/file-installer.d.ts.map +1 -0
  75. package/dist/distribution/file-installer.js +268 -0
  76. package/dist/distribution/file-installer.js.map +1 -0
  77. package/dist/distribution/fleet-config-updater.d.ts +96 -0
  78. package/dist/distribution/fleet-config-updater.d.ts.map +1 -0
  79. package/dist/distribution/fleet-config-updater.js +266 -0
  80. package/dist/distribution/fleet-config-updater.js.map +1 -0
  81. package/dist/distribution/index.d.ts +23 -0
  82. package/dist/distribution/index.d.ts.map +1 -0
  83. package/dist/distribution/index.js +42 -0
  84. package/dist/distribution/index.js.map +1 -0
  85. package/dist/distribution/installation-metadata.d.ts +191 -0
  86. package/dist/distribution/installation-metadata.d.ts.map +1 -0
  87. package/dist/distribution/installation-metadata.js +100 -0
  88. package/dist/distribution/installation-metadata.js.map +1 -0
  89. package/dist/distribution/repository-fetcher.d.ts +104 -0
  90. package/dist/distribution/repository-fetcher.d.ts.map +1 -0
  91. package/dist/distribution/repository-fetcher.js +246 -0
  92. package/dist/distribution/repository-fetcher.js.map +1 -0
  93. package/dist/distribution/repository-validator.d.ts +86 -0
  94. package/dist/distribution/repository-validator.d.ts.map +1 -0
  95. package/dist/distribution/repository-validator.js +296 -0
  96. package/dist/distribution/repository-validator.js.map +1 -0
  97. package/dist/distribution/source-specifier.d.ts +106 -0
  98. package/dist/distribution/source-specifier.d.ts.map +1 -0
  99. package/dist/distribution/source-specifier.js +247 -0
  100. package/dist/distribution/source-specifier.js.map +1 -0
  101. package/dist/fleet-manager/errors.d.ts +15 -0
  102. package/dist/fleet-manager/errors.d.ts.map +1 -1
  103. package/dist/fleet-manager/errors.js +16 -0
  104. package/dist/fleet-manager/errors.js.map +1 -1
  105. package/dist/fleet-manager/fleet-manager.d.ts.map +1 -1
  106. package/dist/fleet-manager/fleet-manager.js +31 -9
  107. package/dist/fleet-manager/fleet-manager.js.map +1 -1
  108. package/dist/index.d.ts +1 -0
  109. package/dist/index.d.ts.map +1 -1
  110. package/dist/index.js +2 -0
  111. package/dist/index.js.map +1 -1
  112. package/dist/runner/message-processor.d.ts.map +1 -1
  113. package/dist/runner/message-processor.js +7 -2
  114. package/dist/runner/message-processor.js.map +1 -1
  115. package/dist/runner/runtime/container-manager.js +1 -1
  116. package/dist/runner/runtime/container-manager.js.map +1 -1
  117. package/dist/scheduler/errors.d.ts +15 -0
  118. package/dist/scheduler/errors.d.ts.map +1 -1
  119. package/package.json +1 -1
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Fleet Config Updater for Agent Distribution
3
+ *
4
+ * Programmatically updates herdctl.yaml to add or remove agent references.
5
+ * Preserves comments and formatting by using yaml's parseDocument approach.
6
+ */
7
+ import { FleetManagerError, type FleetManagerErrorCode } from "../fleet-manager/errors.js";
8
+ /**
9
+ * Options for fleet config operations
10
+ */
11
+ export interface FleetConfigUpdateOptions {
12
+ /** Path to the herdctl.yaml file */
13
+ configPath: string;
14
+ /** Relative path to the agent's yaml file (e.g., "./agents/my-agent/agent.yaml") */
15
+ agentPath: string;
16
+ }
17
+ /**
18
+ * Result of a fleet config update operation
19
+ */
20
+ export interface FleetConfigUpdateResult {
21
+ /** Whether the config was actually modified */
22
+ modified: boolean;
23
+ /** The agent path that was added or removed */
24
+ agentPath: string;
25
+ /** Whether this agent was already referenced (for add) or not found (for remove) */
26
+ alreadyExists: boolean;
27
+ }
28
+ /** Error code: herdctl.yaml doesn't exist */
29
+ export declare const CONFIG_NOT_FOUND: FleetManagerErrorCode;
30
+ /** Error code: herdctl.yaml is invalid YAML */
31
+ export declare const CONFIG_PARSE_ERROR: FleetManagerErrorCode;
32
+ /** Error code: couldn't write the updated config */
33
+ export declare const CONFIG_WRITE_ERROR: FleetManagerErrorCode;
34
+ /**
35
+ * Error thrown when fleet config operations fail
36
+ */
37
+ export declare class FleetConfigError extends FleetManagerError {
38
+ constructor(message: string, code: FleetManagerErrorCode);
39
+ }
40
+ /**
41
+ * Add an agent reference to the fleet config's agents array
42
+ *
43
+ * This function:
44
+ * 1. Reads the herdctl.yaml file, preserving comments and formatting
45
+ * 2. Checks if the agent path already exists in the agents array
46
+ * 3. If not, appends a new entry to the agents array
47
+ * 4. Writes the updated config back to disk
48
+ *
49
+ * @param options - Update options including config path and agent path
50
+ * @returns Result indicating if the config was modified
51
+ * @throws {FleetConfigError} When the operation fails
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const result = await addAgentToFleetConfig({
56
+ * configPath: "/path/to/herdctl.yaml",
57
+ * agentPath: "./agents/my-agent/agent.yaml"
58
+ * });
59
+ *
60
+ * if (result.modified) {
61
+ * console.log(`Added agent reference: ${result.agentPath}`);
62
+ * } else if (result.alreadyExists) {
63
+ * console.log(`Agent already referenced: ${result.agentPath}`);
64
+ * }
65
+ * ```
66
+ */
67
+ export declare function addAgentToFleetConfig(options: FleetConfigUpdateOptions): Promise<FleetConfigUpdateResult>;
68
+ /**
69
+ * Remove an agent reference from the fleet config's agents array
70
+ *
71
+ * This function:
72
+ * 1. Reads the herdctl.yaml file, preserving comments and formatting
73
+ * 2. Finds the agent path in the agents array
74
+ * 3. If found, removes the entry from the agents array
75
+ * 4. Writes the updated config back to disk
76
+ *
77
+ * @param options - Update options including config path and agent path
78
+ * @returns Result indicating if the config was modified
79
+ * @throws {FleetConfigError} When the operation fails
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * const result = await removeAgentFromFleetConfig({
84
+ * configPath: "/path/to/herdctl.yaml",
85
+ * agentPath: "./agents/my-agent/agent.yaml"
86
+ * });
87
+ *
88
+ * if (result.modified) {
89
+ * console.log(`Removed agent reference: ${result.agentPath}`);
90
+ * } else if (!result.alreadyExists) {
91
+ * console.log(`Agent was not referenced: ${result.agentPath}`);
92
+ * }
93
+ * ```
94
+ */
95
+ export declare function removeAgentFromFleetConfig(options: FleetConfigUpdateOptions): Promise<FleetConfigUpdateResult>;
96
+ //# sourceMappingURL=fleet-config-updater.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fleet-config-updater.d.ts","sourceRoot":"","sources":["../../src/distribution/fleet-config-updater.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAE,iBAAiB,EAAE,KAAK,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAS3F;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,oFAAoF;IACpF,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,+CAA+C;IAC/C,QAAQ,EAAE,OAAO,CAAC;IAClB,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,oFAAoF;IACpF,aAAa,EAAE,OAAO,CAAC;CACxB;AAMD,6CAA6C;AAC7C,eAAO,MAAM,gBAAgB,EAAE,qBAA0C,CAAC;AAE1E,+CAA+C;AAC/C,eAAO,MAAM,kBAAkB,EAAE,qBAA4C,CAAC;AAE9E,oDAAoD;AACpD,eAAO,MAAM,kBAAkB,EAAE,qBAA4C,CAAC;AAE9E;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,iBAAiB;gBACzC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB;CAIzD;AAyID;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CA6ClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CA+ClC"}
@@ -0,0 +1,266 @@
1
+ /**
2
+ * Fleet Config Updater for Agent Distribution
3
+ *
4
+ * Programmatically updates herdctl.yaml to add or remove agent references.
5
+ * Preserves comments and formatting by using yaml's parseDocument approach.
6
+ */
7
+ import * as fs from "node:fs/promises";
8
+ import { isMap, isSeq, parseDocument, YAMLParseError } from "yaml";
9
+ import { FleetManagerError } from "../fleet-manager/errors.js";
10
+ import { createLogger } from "../utils/logger.js";
11
+ const logger = createLogger("distribution:fleet-config");
12
+ // =============================================================================
13
+ // Error Classes
14
+ // =============================================================================
15
+ /** Error code: herdctl.yaml doesn't exist */
16
+ export const CONFIG_NOT_FOUND = "CONFIG_NOT_FOUND";
17
+ /** Error code: herdctl.yaml is invalid YAML */
18
+ export const CONFIG_PARSE_ERROR = "CONFIG_PARSE_ERROR";
19
+ /** Error code: couldn't write the updated config */
20
+ export const CONFIG_WRITE_ERROR = "CONFIG_WRITE_ERROR";
21
+ /**
22
+ * Error thrown when fleet config operations fail
23
+ */
24
+ export class FleetConfigError extends FleetManagerError {
25
+ constructor(message, code) {
26
+ super(message, { code });
27
+ this.name = "FleetConfigError";
28
+ }
29
+ }
30
+ // =============================================================================
31
+ // Helper Functions
32
+ // =============================================================================
33
+ /**
34
+ * Check if a file exists
35
+ */
36
+ async function fileExists(filePath) {
37
+ try {
38
+ await fs.access(filePath);
39
+ return true;
40
+ }
41
+ catch {
42
+ return false;
43
+ }
44
+ }
45
+ /**
46
+ * Read and parse the fleet config file, preserving document structure
47
+ */
48
+ async function readFleetConfig(configPath) {
49
+ // Check if file exists
50
+ if (!(await fileExists(configPath))) {
51
+ throw new FleetConfigError(`Fleet config not found at ${configPath}. Run 'herdctl init fleet' to create one.`, CONFIG_NOT_FOUND);
52
+ }
53
+ // Read file content
54
+ let content;
55
+ try {
56
+ content = await fs.readFile(configPath, "utf-8");
57
+ }
58
+ catch (err) {
59
+ const error = err;
60
+ throw new FleetConfigError(`Failed to read fleet config: ${error.message}`, CONFIG_NOT_FOUND);
61
+ }
62
+ // Parse YAML preserving document structure
63
+ try {
64
+ const doc = parseDocument(content);
65
+ // parseDocument may not throw but can store errors in doc.errors
66
+ if (doc.errors && doc.errors.length > 0) {
67
+ const firstError = doc.errors[0];
68
+ const position = firstError.linePos?.[0];
69
+ const locationInfo = position ? ` at line ${position.line}, column ${position.col}` : "";
70
+ throw new FleetConfigError(`Invalid YAML syntax in fleet config${locationInfo}: ${firstError.message}`, CONFIG_PARSE_ERROR);
71
+ }
72
+ return doc;
73
+ }
74
+ catch (err) {
75
+ // Re-throw FleetConfigError as-is
76
+ if (err instanceof FleetConfigError) {
77
+ throw err;
78
+ }
79
+ if (err instanceof YAMLParseError) {
80
+ const position = err.linePos?.[0];
81
+ const locationInfo = position ? ` at line ${position.line}, column ${position.col}` : "";
82
+ throw new FleetConfigError(`Invalid YAML syntax in fleet config${locationInfo}: ${err.message}`, CONFIG_PARSE_ERROR);
83
+ }
84
+ throw new FleetConfigError(`Failed to parse fleet config: ${err.message}`, CONFIG_PARSE_ERROR);
85
+ }
86
+ }
87
+ /**
88
+ * Write the fleet config back to disk
89
+ */
90
+ async function writeFleetConfig(configPath, doc) {
91
+ try {
92
+ await fs.writeFile(configPath, doc.toString(), "utf-8");
93
+ }
94
+ catch (err) {
95
+ const error = err;
96
+ throw new FleetConfigError(`Failed to write fleet config: ${error.message}`, CONFIG_WRITE_ERROR);
97
+ }
98
+ }
99
+ /**
100
+ * Check if an agent path already exists in the agents array
101
+ */
102
+ function findAgentInArray(agentsNode, agentPath) {
103
+ if (!isSeq(agentsNode)) {
104
+ return -1;
105
+ }
106
+ for (let i = 0; i < agentsNode.items.length; i++) {
107
+ const item = agentsNode.items[i];
108
+ // Handle both object form { path: "..." } and string form "..."
109
+ if (isMap(item)) {
110
+ const pathNode = item.get("path");
111
+ if (typeof pathNode === "string" && pathNode === agentPath) {
112
+ return i;
113
+ }
114
+ }
115
+ else if (typeof item === "string" && item === agentPath) {
116
+ return i;
117
+ }
118
+ // Also check the JSON value if it's a scalar node
119
+ const itemValue = item && typeof item === "object" && "toJSON" in item
120
+ ? item.toJSON()
121
+ : item;
122
+ if (typeof itemValue === "object" && itemValue !== null && "path" in itemValue) {
123
+ if (itemValue.path === agentPath) {
124
+ return i;
125
+ }
126
+ }
127
+ if (typeof itemValue === "string" && itemValue === agentPath) {
128
+ return i;
129
+ }
130
+ }
131
+ return -1;
132
+ }
133
+ // =============================================================================
134
+ // Main Functions
135
+ // =============================================================================
136
+ /**
137
+ * Add an agent reference to the fleet config's agents array
138
+ *
139
+ * This function:
140
+ * 1. Reads the herdctl.yaml file, preserving comments and formatting
141
+ * 2. Checks if the agent path already exists in the agents array
142
+ * 3. If not, appends a new entry to the agents array
143
+ * 4. Writes the updated config back to disk
144
+ *
145
+ * @param options - Update options including config path and agent path
146
+ * @returns Result indicating if the config was modified
147
+ * @throws {FleetConfigError} When the operation fails
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * const result = await addAgentToFleetConfig({
152
+ * configPath: "/path/to/herdctl.yaml",
153
+ * agentPath: "./agents/my-agent/agent.yaml"
154
+ * });
155
+ *
156
+ * if (result.modified) {
157
+ * console.log(`Added agent reference: ${result.agentPath}`);
158
+ * } else if (result.alreadyExists) {
159
+ * console.log(`Agent already referenced: ${result.agentPath}`);
160
+ * }
161
+ * ```
162
+ */
163
+ export async function addAgentToFleetConfig(options) {
164
+ const { configPath, agentPath } = options;
165
+ logger.debug("Adding agent to fleet config", { configPath, agentPath });
166
+ // Read and parse the config
167
+ const doc = await readFleetConfig(configPath);
168
+ // Get the agents node
169
+ const agentsNode = doc.get("agents", true);
170
+ // Check for duplicate
171
+ if (findAgentInArray(agentsNode, agentPath) !== -1) {
172
+ logger.debug("Agent already exists in fleet config", { agentPath });
173
+ return {
174
+ modified: false,
175
+ agentPath,
176
+ alreadyExists: true,
177
+ };
178
+ }
179
+ // Create the new agent reference node
180
+ const agentRef = doc.createNode({ path: agentPath });
181
+ // Add to agents array
182
+ if (isSeq(agentsNode)) {
183
+ // Already a sequence ([] or block) - append to it
184
+ agentsNode.items.push(agentRef);
185
+ logger.debug("Appended agent to existing agents array", { agentPath });
186
+ }
187
+ else {
188
+ // No agents key or it's not a sequence - set it
189
+ doc.set("agents", doc.createNode([{ path: agentPath }]));
190
+ logger.debug("Created agents array with agent", { agentPath });
191
+ }
192
+ // Write the updated config
193
+ await writeFleetConfig(configPath, doc);
194
+ logger.info("Added agent to fleet config", { configPath, agentPath });
195
+ return {
196
+ modified: true,
197
+ agentPath,
198
+ alreadyExists: false,
199
+ };
200
+ }
201
+ /**
202
+ * Remove an agent reference from the fleet config's agents array
203
+ *
204
+ * This function:
205
+ * 1. Reads the herdctl.yaml file, preserving comments and formatting
206
+ * 2. Finds the agent path in the agents array
207
+ * 3. If found, removes the entry from the agents array
208
+ * 4. Writes the updated config back to disk
209
+ *
210
+ * @param options - Update options including config path and agent path
211
+ * @returns Result indicating if the config was modified
212
+ * @throws {FleetConfigError} When the operation fails
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * const result = await removeAgentFromFleetConfig({
217
+ * configPath: "/path/to/herdctl.yaml",
218
+ * agentPath: "./agents/my-agent/agent.yaml"
219
+ * });
220
+ *
221
+ * if (result.modified) {
222
+ * console.log(`Removed agent reference: ${result.agentPath}`);
223
+ * } else if (!result.alreadyExists) {
224
+ * console.log(`Agent was not referenced: ${result.agentPath}`);
225
+ * }
226
+ * ```
227
+ */
228
+ export async function removeAgentFromFleetConfig(options) {
229
+ const { configPath, agentPath } = options;
230
+ logger.debug("Removing agent from fleet config", { configPath, agentPath });
231
+ // Read and parse the config
232
+ const doc = await readFleetConfig(configPath);
233
+ // Get the agents node
234
+ const agentsNode = doc.get("agents", true);
235
+ // Check if agents array exists and is a sequence
236
+ if (!isSeq(agentsNode)) {
237
+ logger.debug("No agents array in fleet config", { agentPath });
238
+ return {
239
+ modified: false,
240
+ agentPath,
241
+ alreadyExists: false,
242
+ };
243
+ }
244
+ // Find the agent in the array
245
+ const index = findAgentInArray(agentsNode, agentPath);
246
+ if (index === -1) {
247
+ logger.debug("Agent not found in fleet config", { agentPath });
248
+ return {
249
+ modified: false,
250
+ agentPath,
251
+ alreadyExists: false,
252
+ };
253
+ }
254
+ // Remove the agent from the array
255
+ agentsNode.items.splice(index, 1);
256
+ logger.debug("Removed agent from agents array", { agentPath, index });
257
+ // Write the updated config
258
+ await writeFleetConfig(configPath, doc);
259
+ logger.info("Removed agent from fleet config", { configPath, agentPath });
260
+ return {
261
+ modified: true,
262
+ agentPath,
263
+ alreadyExists: true,
264
+ };
265
+ }
266
+ //# sourceMappingURL=fleet-config-updater.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fleet-config-updater.js","sourceRoot":"","sources":["../../src/distribution/fleet-config-updater.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAA8B,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,MAAM,GAAG,YAAY,CAAC,2BAA2B,CAAC,CAAC;AA4BzD,gFAAgF;AAChF,gBAAgB;AAChB,gFAAgF;AAEhF,6CAA6C;AAC7C,MAAM,CAAC,MAAM,gBAAgB,GAA0B,kBAAkB,CAAC;AAE1E,+CAA+C;AAC/C,MAAM,CAAC,MAAM,kBAAkB,GAA0B,oBAAoB,CAAC;AA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AAU,EAAE,SAAS,CAAC,CAAC;IAEtD,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACjB,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;QAC/D,OAAO;YACL,QAAQ,EAAE,KAAK;YACf,SAAS;YACT,aAAa,EAAE,KAAK;SACrB,CAAC;IACJ,CAAC;IAED,kCAAkC;IAClC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAClC,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;IAEtE,2BAA2B;IAC3B,MAAM,gBAAgB,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAExC,MAAM,CAAC,IAAI,CAAC,iCAAiC,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC;IAE1E,OAAO;QACL,QAAQ,EAAE,IAAI;QACd,SAAS;QACT,aAAa,EAAE,IAAI;KACpB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Distribution module for herdctl
3
+ *
4
+ * Provides schemas and utilities for the agent distribution system:
5
+ * - Agent repository metadata validation (herdctl.json)
6
+ * - Installation metadata tracking (metadata.json)
7
+ * - Source specifier parsing and repository fetching
8
+ * - Agent discovery and listing
9
+ * - Agent detailed information
10
+ * - Agent removal
11
+ */
12
+ export { AgentDiscoveryError, DISCOVERY_CONFIG_INVALID, DISCOVERY_CONFIG_NOT_FOUND, type DiscoveredAgent, type DiscoveryOptions, type DiscoveryResult, discoverAgents, } from "./agent-discovery.js";
13
+ export { type AgentDetailedInfo, type AgentInfoOptions, getAgentInfo, } from "./agent-info.js";
14
+ export { AGENT_NOT_FOUND, AgentRemoveError, type RemoveOptions, type RemoveResult, removeAgent, } from "./agent-remover.js";
15
+ export { AGENT_NAME_PATTERN, type AgentRepoMetadata, AgentRepoMetadataSchema, type AgentRequires, AgentRequiresSchema, } from "./agent-repo-metadata.js";
16
+ export { type EnvScanResult, type EnvVariable, scanEnvVariables, } from "./env-scanner.js";
17
+ export { AGENT_ALREADY_EXISTS, AgentInstallError, INVALID_AGENT_NAME, INVALID_AGENT_YAML as INSTALLER_INVALID_AGENT_YAML, type InstallOptions, type InstallResult, installAgentFiles, MISSING_AGENT_YAML as INSTALLER_MISSING_AGENT_YAML, } from "./file-installer.js";
18
+ export { addAgentToFleetConfig, CONFIG_NOT_FOUND, CONFIG_PARSE_ERROR, CONFIG_WRITE_ERROR, FleetConfigError, type FleetConfigUpdateOptions, type FleetConfigUpdateResult, removeAgentFromFleetConfig, } from "./fleet-config-updater.js";
19
+ export { type InstallationMetadata, InstallationMetadataSchema, type InstallationSource, InstallationSourceSchema, ISO8601TimestampSchema, type SourceType, SourceTypeSchema, } from "./installation-metadata.js";
20
+ export { type FetchSource, fetchRepository, GitHubCloneAuthError, type GitHubFetchSource, GitHubRepoNotFoundError, type LocalFetchSource, LocalPathError, NetworkError, RepositoryFetchError, type RepositoryFetchResult, } from "./repository-fetcher.js";
21
+ export { DOCKER_NETWORK_NONE, INVALID_AGENT_YAML, INVALID_HERDCTL_JSON, JSON_PARSE_ERROR, MISSING_AGENT_YAML, MISSING_CLAUDE_MD, MISSING_HERDCTL_JSON, MISSING_README, NAME_MISMATCH, type ValidationMessage, type ValidationResult, validateRepository, YAML_PARSE_ERROR, } from "./repository-validator.js";
22
+ export { type GitHubSource, isGitHubSource, isLocalSource, type LocalSource, parseSourceSpecifier, SourceParseError, type SourceSpecifier, stringifySourceSpecifier, } from "./source-specifier.js";
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/distribution/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAC1B,KAAK,eAAe,EACpB,KAAK,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B,oBAAoB,EACpB,gBAAgB,EAEhB,kBAAkB,EAClB,iBAAiB,EAEjB,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,KAAK,YAAY,EACjB,cAAc,EACd,aAAa,EACb,KAAK,WAAW,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,KAAK,eAAe,EACpB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Distribution module for herdctl
3
+ *
4
+ * Provides schemas and utilities for the agent distribution system:
5
+ * - Agent repository metadata validation (herdctl.json)
6
+ * - Installation metadata tracking (metadata.json)
7
+ * - Source specifier parsing and repository fetching
8
+ * - Agent discovery and listing
9
+ * - Agent detailed information
10
+ * - Agent removal
11
+ */
12
+ // Agent Discovery
13
+ export { AgentDiscoveryError, DISCOVERY_CONFIG_INVALID, DISCOVERY_CONFIG_NOT_FOUND, discoverAgents, } from "./agent-discovery.js";
14
+ // Agent Info
15
+ export { getAgentInfo, } from "./agent-info.js";
16
+ // Agent Remover
17
+ export { AGENT_NOT_FOUND, AgentRemoveError, removeAgent, } from "./agent-remover.js";
18
+ // Agent Repository Metadata (herdctl.json)
19
+ export { AGENT_NAME_PATTERN, AgentRepoMetadataSchema, AgentRequiresSchema, } from "./agent-repo-metadata.js";
20
+ // Environment Variable Scanner
21
+ export { scanEnvVariables, } from "./env-scanner.js";
22
+ // File Installation
23
+ export {
24
+ // Error codes
25
+ AGENT_ALREADY_EXISTS, AgentInstallError, INVALID_AGENT_NAME, INVALID_AGENT_YAML as INSTALLER_INVALID_AGENT_YAML, installAgentFiles, MISSING_AGENT_YAML as INSTALLER_MISSING_AGENT_YAML, } from "./file-installer.js";
26
+ // Fleet Config Updater
27
+ export { addAgentToFleetConfig, CONFIG_NOT_FOUND, CONFIG_PARSE_ERROR, CONFIG_WRITE_ERROR, FleetConfigError, removeAgentFromFleetConfig, } from "./fleet-config-updater.js";
28
+ // Installation Metadata (metadata.json)
29
+ export { InstallationMetadataSchema, InstallationSourceSchema, ISO8601TimestampSchema, SourceTypeSchema, } from "./installation-metadata.js";
30
+ // Repository Fetching
31
+ export { fetchRepository,
32
+ // Error classes
33
+ GitHubCloneAuthError, GitHubRepoNotFoundError, LocalPathError, NetworkError, RepositoryFetchError, } from "./repository-fetcher.js";
34
+ // Repository Validation
35
+ export { DOCKER_NETWORK_NONE, INVALID_AGENT_YAML, INVALID_HERDCTL_JSON, JSON_PARSE_ERROR,
36
+ // Error codes
37
+ MISSING_AGENT_YAML, MISSING_CLAUDE_MD,
38
+ // Warning codes
39
+ MISSING_HERDCTL_JSON, MISSING_README, NAME_MISMATCH, validateRepository, YAML_PARSE_ERROR, } from "./repository-validator.js";
40
+ // Source Specifier Parsing
41
+ export { isGitHubSource, isLocalSource, parseSourceSpecifier, SourceParseError, stringifySourceSpecifier, } from "./source-specifier.js";
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/distribution/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,kBAAkB;AAClB,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAI1B,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,aAAa;AACb,OAAO,EAGL,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,gBAAgB;AAChB,OAAO,EACL,eAAe,EACf,gBAAgB,EAGhB,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,2CAA2C;AAC3C,OAAO,EACL,kBAAkB,EAElB,uBAAuB,EAEvB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,+BAA+B;AAC/B,OAAO,EAGL,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,oBAAoB;AACpB,OAAO;AACL,cAAc;AACd,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,IAAI,4BAA4B,EAGlD,iBAAiB,EACjB,kBAAkB,IAAI,4BAA4B,GACnD,MAAM,qBAAqB,CAAC;AAC7B,uBAAuB;AACvB,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAGhB,0BAA0B,GAC3B,MAAM,2BAA2B,CAAC;AACnC,wCAAwC;AACxC,OAAO,EAEL,0BAA0B,EAE1B,wBAAwB,EACxB,sBAAsB,EAEtB,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AACpC,sBAAsB;AACtB,OAAO,EAEL,eAAe;AACf,gBAAgB;AAChB,oBAAoB,EAEpB,uBAAuB,EAEvB,cAAc,EACd,YAAY,EACZ,oBAAoB,GAErB,MAAM,yBAAyB,CAAC;AACjC,wBAAwB;AACxB,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB;AAChB,cAAc;AACd,kBAAkB,EAClB,iBAAiB;AACjB,gBAAgB;AAChB,oBAAoB,EACpB,cAAc,EACd,aAAa,EAGb,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AACnC,2BAA2B;AAC3B,OAAO,EAEL,cAAc,EACd,aAAa,EAEb,oBAAoB,EACpB,gBAAgB,EAEhB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Installation metadata schema for agent distribution
3
+ *
4
+ * Validates the `metadata.json` file that lives in each installed agent's
5
+ * directory root. This file tracks where an agent was installed from and when.
6
+ *
7
+ * The schema is intentionally extensible (no .strict()) to support future
8
+ * features like agentic initialization without breaking existing installs.
9
+ */
10
+ import { z } from "zod";
11
+ /**
12
+ * Source types for installed agents
13
+ *
14
+ * - `github`: Installed from a GitHub repository
15
+ * - `local`: Installed from a local filesystem path
16
+ */
17
+ export declare const SourceTypeSchema: z.ZodEnum<["github", "local"]>;
18
+ /** Union type of valid source types */
19
+ export type SourceType = z.infer<typeof SourceTypeSchema>;
20
+ /**
21
+ * Source information schema
22
+ *
23
+ * Tracks the origin of an installed agent. The `type` field is required,
24
+ * while other fields are optional and depend on the source type:
25
+ *
26
+ * - `url`: The original source URL or path (GitHub URL, local path)
27
+ * - `ref`: Git reference (tag, branch, commit SHA) for GitHub sources
28
+ * - `version`: Version from herdctl.json at install time
29
+ */
30
+ export declare const InstallationSourceSchema: z.ZodObject<{
31
+ /** The type of source (github or local) */
32
+ type: z.ZodEnum<["github", "local"]>;
33
+ /** The original source URL or path */
34
+ url: z.ZodOptional<z.ZodString>;
35
+ /** Git reference (tag, branch, commit) for version-controlled sources */
36
+ ref: z.ZodOptional<z.ZodString>;
37
+ /** Version from herdctl.json at install time */
38
+ version: z.ZodOptional<z.ZodString>;
39
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
40
+ /** The type of source (github or local) */
41
+ type: z.ZodEnum<["github", "local"]>;
42
+ /** The original source URL or path */
43
+ url: z.ZodOptional<z.ZodString>;
44
+ /** Git reference (tag, branch, commit) for version-controlled sources */
45
+ ref: z.ZodOptional<z.ZodString>;
46
+ /** Version from herdctl.json at install time */
47
+ version: z.ZodOptional<z.ZodString>;
48
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
49
+ /** The type of source (github or local) */
50
+ type: z.ZodEnum<["github", "local"]>;
51
+ /** The original source URL or path */
52
+ url: z.ZodOptional<z.ZodString>;
53
+ /** Git reference (tag, branch, commit) for version-controlled sources */
54
+ ref: z.ZodOptional<z.ZodString>;
55
+ /** Version from herdctl.json at install time */
56
+ version: z.ZodOptional<z.ZodString>;
57
+ }, z.ZodTypeAny, "passthrough">>;
58
+ /** Type for installation source information */
59
+ export type InstallationSource = z.infer<typeof InstallationSourceSchema>;
60
+ /**
61
+ * Schema for ISO 8601 formatted timestamps
62
+ */
63
+ export declare const ISO8601TimestampSchema: z.ZodString;
64
+ /**
65
+ * Installation metadata schema
66
+ *
67
+ * This schema validates the `metadata.json` file that tracks installation
68
+ * information for each agent. It is intentionally extensible (uses default
69
+ * Zod behavior, not .strict()) to allow adding future fields like
70
+ * `initialization` without breaking existing installs.
71
+ *
72
+ * @example
73
+ * ```json
74
+ * {
75
+ * "source": {
76
+ * "type": "github",
77
+ * "url": "https://github.com/user/agent-repo",
78
+ * "ref": "v1.0.0",
79
+ * "version": "1.0.0"
80
+ * },
81
+ * "installed_at": "2024-01-15T10:30:00Z",
82
+ * "installed_by": "herdctl@0.5.0"
83
+ * }
84
+ * ```
85
+ */
86
+ export declare const InstallationMetadataSchema: z.ZodObject<{
87
+ /** Source information - where the agent was installed from */
88
+ source: z.ZodObject<{
89
+ /** The type of source (github or local) */
90
+ type: z.ZodEnum<["github", "local"]>;
91
+ /** The original source URL or path */
92
+ url: z.ZodOptional<z.ZodString>;
93
+ /** Git reference (tag, branch, commit) for version-controlled sources */
94
+ ref: z.ZodOptional<z.ZodString>;
95
+ /** Version from herdctl.json at install time */
96
+ version: z.ZodOptional<z.ZodString>;
97
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
98
+ /** The type of source (github or local) */
99
+ type: z.ZodEnum<["github", "local"]>;
100
+ /** The original source URL or path */
101
+ url: z.ZodOptional<z.ZodString>;
102
+ /** Git reference (tag, branch, commit) for version-controlled sources */
103
+ ref: z.ZodOptional<z.ZodString>;
104
+ /** Version from herdctl.json at install time */
105
+ version: z.ZodOptional<z.ZodString>;
106
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
107
+ /** The type of source (github or local) */
108
+ type: z.ZodEnum<["github", "local"]>;
109
+ /** The original source URL or path */
110
+ url: z.ZodOptional<z.ZodString>;
111
+ /** Git reference (tag, branch, commit) for version-controlled sources */
112
+ ref: z.ZodOptional<z.ZodString>;
113
+ /** Version from herdctl.json at install time */
114
+ version: z.ZodOptional<z.ZodString>;
115
+ }, z.ZodTypeAny, "passthrough">>;
116
+ /** ISO 8601 timestamp of when the agent was installed */
117
+ installed_at: z.ZodString;
118
+ /** herdctl version that performed the installation (e.g., "herdctl@0.5.0") */
119
+ installed_by: z.ZodOptional<z.ZodString>;
120
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
121
+ /** Source information - where the agent was installed from */
122
+ source: z.ZodObject<{
123
+ /** The type of source (github or local) */
124
+ type: z.ZodEnum<["github", "local"]>;
125
+ /** The original source URL or path */
126
+ url: z.ZodOptional<z.ZodString>;
127
+ /** Git reference (tag, branch, commit) for version-controlled sources */
128
+ ref: z.ZodOptional<z.ZodString>;
129
+ /** Version from herdctl.json at install time */
130
+ version: z.ZodOptional<z.ZodString>;
131
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
132
+ /** The type of source (github or local) */
133
+ type: z.ZodEnum<["github", "local"]>;
134
+ /** The original source URL or path */
135
+ url: z.ZodOptional<z.ZodString>;
136
+ /** Git reference (tag, branch, commit) for version-controlled sources */
137
+ ref: z.ZodOptional<z.ZodString>;
138
+ /** Version from herdctl.json at install time */
139
+ version: z.ZodOptional<z.ZodString>;
140
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
141
+ /** The type of source (github or local) */
142
+ type: z.ZodEnum<["github", "local"]>;
143
+ /** The original source URL or path */
144
+ url: z.ZodOptional<z.ZodString>;
145
+ /** Git reference (tag, branch, commit) for version-controlled sources */
146
+ ref: z.ZodOptional<z.ZodString>;
147
+ /** Version from herdctl.json at install time */
148
+ version: z.ZodOptional<z.ZodString>;
149
+ }, z.ZodTypeAny, "passthrough">>;
150
+ /** ISO 8601 timestamp of when the agent was installed */
151
+ installed_at: z.ZodString;
152
+ /** herdctl version that performed the installation (e.g., "herdctl@0.5.0") */
153
+ installed_by: z.ZodOptional<z.ZodString>;
154
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
155
+ /** Source information - where the agent was installed from */
156
+ source: z.ZodObject<{
157
+ /** The type of source (github or local) */
158
+ type: z.ZodEnum<["github", "local"]>;
159
+ /** The original source URL or path */
160
+ url: z.ZodOptional<z.ZodString>;
161
+ /** Git reference (tag, branch, commit) for version-controlled sources */
162
+ ref: z.ZodOptional<z.ZodString>;
163
+ /** Version from herdctl.json at install time */
164
+ version: z.ZodOptional<z.ZodString>;
165
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
166
+ /** The type of source (github or local) */
167
+ type: z.ZodEnum<["github", "local"]>;
168
+ /** The original source URL or path */
169
+ url: z.ZodOptional<z.ZodString>;
170
+ /** Git reference (tag, branch, commit) for version-controlled sources */
171
+ ref: z.ZodOptional<z.ZodString>;
172
+ /** Version from herdctl.json at install time */
173
+ version: z.ZodOptional<z.ZodString>;
174
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
175
+ /** The type of source (github or local) */
176
+ type: z.ZodEnum<["github", "local"]>;
177
+ /** The original source URL or path */
178
+ url: z.ZodOptional<z.ZodString>;
179
+ /** Git reference (tag, branch, commit) for version-controlled sources */
180
+ ref: z.ZodOptional<z.ZodString>;
181
+ /** Version from herdctl.json at install time */
182
+ version: z.ZodOptional<z.ZodString>;
183
+ }, z.ZodTypeAny, "passthrough">>;
184
+ /** ISO 8601 timestamp of when the agent was installed */
185
+ installed_at: z.ZodString;
186
+ /** herdctl version that performed the installation (e.g., "herdctl@0.5.0") */
187
+ installed_by: z.ZodOptional<z.ZodString>;
188
+ }, z.ZodTypeAny, "passthrough">>;
189
+ /** Type for installation metadata */
190
+ export type InstallationMetadata = z.infer<typeof InstallationMetadataSchema>;
191
+ //# sourceMappingURL=installation-metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installation-metadata.d.ts","sourceRoot":"","sources":["../../src/distribution/installation-metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,gCAA8B,CAAC;AAE5D,uCAAuC;AACvC,MAAM,MAAM,UAAU,GAAG,CAAC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