@revoengine/cli 1.0.20 → 1.0.21
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 +33 -8
- package/dist/src/cli.js +5 -1
- package/dist/src/client.d.ts +14 -1
- package/dist/src/client.js +44 -0
- package/dist/src/commands/agents.d.ts +2 -0
- package/dist/src/commands/agents.js +56 -0
- package/dist/src/commands/component.js +2 -0
- package/dist/src/commands/index.d.ts +1 -0
- package/dist/src/commands/index.js +1 -0
- package/dist/src/commands/migrate.js +14 -2
- package/dist/src/component-lock.d.ts +2 -0
- package/dist/src/component-lock.js +38 -0
- package/dist/src/metadata-backfill.js +39 -1
- package/dist/src/migration.d.ts +9 -2
- package/dist/src/migration.js +59 -0
- package/dist/src/resource-inventory.d.ts +4 -2
- package/dist/src/resource-inventory.js +11 -1
- package/dist/src/resource-syncs/agent-sync.d.ts +98 -0
- package/dist/src/resource-syncs/agent-sync.js +586 -0
- package/dist/src/tracked-resources.d.ts +1 -1
- package/dist/src/tracked-resources.js +4 -2
- package/dist/src/types.d.ts +12 -0
- package/dist/src/ui.js +5 -1
- package/dist/src/workspace-diff.js +2 -0
- package/dist/src/workspace-prune.js +38 -2
- package/package.json +2 -2
|
@@ -0,0 +1,586 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { hashStable, readComponentLock, writeComponentLock } from "../component-lock.js";
|
|
4
|
+
import { describeFieldChanges } from "../diff-details.js";
|
|
5
|
+
import { readConfiguredResourceMetadataStableKey, sanitizeUserMetadata } from "../resource-metadata.js";
|
|
6
|
+
import { readResourceInventory, resourceIdOf } from "../resource-inventory.js";
|
|
7
|
+
import { sanitizeSegment } from "../utils.js";
|
|
8
|
+
import { accountPrincipal, readPortableOwner, resolveExecutionPrincipal, resolvePortableOwner, ownerIsAvailable } from "./account-principal.js";
|
|
9
|
+
import { findManifestFiles, isRecord, requireProjectLayout, stableKeySuffix, toPortableRelativePath, unwrapData, writePulledManifest } from "./util.js";
|
|
10
|
+
export const AGENT_LAYOUT = { agent: ['Agents', 'agent.json', 'agents'], 'agent-plugin': ['AgentPlugins', 'agent-plugin.json', 'agentPlugins'] };
|
|
11
|
+
const pluginFields = ['id', 'kind', 'name', 'description', 'routing', 'executionMode', 'componentDigest', 'componentToolset', 'mcpToolset', 'inputSchema', 'outputSchema', 'approvalPolicy', 'mutationIntent', 'reversibility', 'targetScope', 'sideEffectSummary', 'sideEffectCategories', 'timeoutMs', 'resultMaxBytes', 'autoDiscovery'];
|
|
12
|
+
const configFields = ['model', 'reasoningEffort', 'executionMode', 'planningPolicy', 'workMode', 'persona', 'systemInstructions', 'definition', 'memoryPolicy', 'cheapTurn', 'toolNames', 'maxActiveRootRuns', 'maxChildRuns', 'maxConcurrentChildRuns', 'maxTicks', 'childFailureMode'];
|
|
13
|
+
const policyFields = ['defaultToolPermission', 'toolPermissions', 'toolNames', 'maxActiveRootRuns', 'maxChildRuns', 'maxConcurrentChildRuns', 'maxTicks', 'childFailureMode'];
|
|
14
|
+
const mcpFields = ['transport', 'url', 'networkAccess', 'authMode', 'manifestTtlMs', 'connectTimeoutMs', 'toolNamePrefix'];
|
|
15
|
+
function pick(value, fields) { return Object.fromEntries(fields.filter(k => value[k] !== undefined && value[k] !== null).map(k => [k, structuredClone(value[k])])); }
|
|
16
|
+
function record(value) { if (!isRecord(value))
|
|
17
|
+
throw new Error('Expected definition object.'); return value; }
|
|
18
|
+
function strings(value) { if (value === undefined)
|
|
19
|
+
return []; if (!Array.isArray(value) || value.some(v => typeof v !== 'string' || !v.trim()))
|
|
20
|
+
throw new Error('Expected non-empty dependency keys.'); return value; }
|
|
21
|
+
function active(value) { return !value.deletedAt && !value.deletedBy; }
|
|
22
|
+
async function inventory(client, family) {
|
|
23
|
+
const entries = [];
|
|
24
|
+
for await (const { resource, listedId } of readResourceInventory(client, family)) {
|
|
25
|
+
if (!listedId || resourceIdOf(resource) !== listedId)
|
|
26
|
+
throw new Error(`Incomplete ${family} inventory.`);
|
|
27
|
+
if (active(resource))
|
|
28
|
+
entries.push(resource);
|
|
29
|
+
}
|
|
30
|
+
return entries;
|
|
31
|
+
}
|
|
32
|
+
async function dependencyKey(client, family, id, keyName) {
|
|
33
|
+
const value = unwrapData(family === 'component' ? await client.getComponent(id) : await client.getAgentPlugin(id));
|
|
34
|
+
const key = active(value) && readConfiguredResourceMetadataStableKey(value, keyName);
|
|
35
|
+
if (!key)
|
|
36
|
+
throw new Error(`${family} dependency has no active Stable Key.`);
|
|
37
|
+
return key;
|
|
38
|
+
}
|
|
39
|
+
function portableToolContracts(value) {
|
|
40
|
+
if (Array.isArray(value))
|
|
41
|
+
return value.map(portableToolContracts);
|
|
42
|
+
if (!isRecord(value))
|
|
43
|
+
return value;
|
|
44
|
+
if (value.$vault || value.vault || value.rollbackToSnapshotId)
|
|
45
|
+
throw new Error('Tool input Vault bindings and rollout snapshots require target-local configuration; cannot export instance IDs.');
|
|
46
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, key === 'approvalPolicy' && isRecord(child)
|
|
47
|
+
? pick(child, ['mode', 'safetyTier', 'condition']) : portableToolContracts(child)]));
|
|
48
|
+
}
|
|
49
|
+
async function portablePlugin(client, config, keyName) {
|
|
50
|
+
const result = record(portableToolContracts(pick(config, pluginFields)));
|
|
51
|
+
result.description = typeof config.description === 'string' ? config.description : '';
|
|
52
|
+
if (config.componentVersion != null && !config.componentDigest)
|
|
53
|
+
throw new Error('Legacy componentVersion pin requires a portable componentDigest before export.');
|
|
54
|
+
if (config.componentId)
|
|
55
|
+
result.componentStableKey = await dependencyKey(client, 'component', String(config.componentId), keyName);
|
|
56
|
+
if (config.mcpServer) {
|
|
57
|
+
const mcp = record(config.mcpServer);
|
|
58
|
+
// URLs with embedded credentials or query values are never committed implicitly.
|
|
59
|
+
const url = new URL(String(mcp.url));
|
|
60
|
+
if (url.username || url.password || url.search || url.hash)
|
|
61
|
+
throw new Error('MCP URL contains credentials, query or fragment; use a public URL and target-local authentication.');
|
|
62
|
+
result.mcpServer = pick(mcp, mcpFields);
|
|
63
|
+
}
|
|
64
|
+
for (const kind of ['skill', 'package'])
|
|
65
|
+
if (config[kind]) {
|
|
66
|
+
const content = record(config[kind]);
|
|
67
|
+
result[kind] = { ...pick(content, ['format', 'content', 'maxPromptTokens', ...(kind === 'package' ? ['externalId'] : [])]),
|
|
68
|
+
pluginStableKeys: await Promise.all(strings(content.pluginIds).map(id => dependencyKey(client, 'agent-plugin', id, keyName))) };
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
async function portableAgentSection(client, section, keyName, policy) {
|
|
73
|
+
const result = pick(section, policy ? policyFields : configFields);
|
|
74
|
+
for (const [source, target] of [['pluginIds', 'pluginStableKeys'], ['eagerPluginIds', 'eagerPluginStableKeys']]) {
|
|
75
|
+
if (!policy || source === 'pluginIds')
|
|
76
|
+
result[target] = await Promise.all(strings(section[source]).map(id => dependencyKey(client, 'agent-plugin', id, keyName)));
|
|
77
|
+
}
|
|
78
|
+
result.plugins = [];
|
|
79
|
+
if (section.plugins !== undefined) {
|
|
80
|
+
if (!Array.isArray(section.plugins))
|
|
81
|
+
throw new Error('Inline plugins must be an array.');
|
|
82
|
+
result.plugins = await Promise.all(section.plugins.map(async (value) => ({ ...await portablePlugin(client, record(value), keyName), ...pick(record(value), ['enabled']) })));
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
export async function agentManifestFromRecord(input, value) {
|
|
87
|
+
const stableKey = readConfiguredResourceMetadataStableKey(value, input.stableKeyName);
|
|
88
|
+
if (!stableKey)
|
|
89
|
+
return null;
|
|
90
|
+
const base = { kind: input.family, stableKey, name: String(value.name || ''), metadata: sanitizeUserMetadata(value.metadata) };
|
|
91
|
+
if (input.family === 'agent-plugin')
|
|
92
|
+
return { ...base, definition: { ...await portablePlugin(input.client, record(value.config), input.stableKeyName), ...pick(value, ['category', 'active']) } };
|
|
93
|
+
const executionPrincipal = await accountPrincipal(input.client, String(value.serviceAccountUserId || ''), input.stableKeyName);
|
|
94
|
+
if (!executionPrincipal)
|
|
95
|
+
throw new Error('Agent execution account requires a managed Service Account Stable Key.');
|
|
96
|
+
const config = await portableAgentSection(input.client, record(value.config || {}), input.stableKeyName, false);
|
|
97
|
+
const policy = await portableAgentSection(input.client, record(value.policy || {}), input.stableKeyName, true);
|
|
98
|
+
// Inherited eager attachments become explicit so portability does not depend on tenant defaults.
|
|
99
|
+
const attached = new Set([...strings(config.pluginStableKeys), ...strings(policy.pluginStableKeys)]);
|
|
100
|
+
config.pluginStableKeys = [...strings(config.pluginStableKeys), ...strings(config.eagerPluginStableKeys).filter(key => !attached.has(key))];
|
|
101
|
+
return { ...base, executionPrincipal, owner: await readPortableOwner(input.client, value, input.stableKeyName), definition: {
|
|
102
|
+
desc: typeof value.desc === 'string' ? value.desc : '', config, policy,
|
|
103
|
+
} };
|
|
104
|
+
}
|
|
105
|
+
function comparableAgent(desired, current) {
|
|
106
|
+
return desired.kind === 'agent' && desired.owner && !['group', 'service-account', 'system'].includes(desired.owner.type)
|
|
107
|
+
? { ...current, owner: desired.owner } : current;
|
|
108
|
+
}
|
|
109
|
+
export function hashPortableAgent(manifest) {
|
|
110
|
+
const { owner, ...rest } = manifest;
|
|
111
|
+
return hashStable({ ...rest, ...((owner && ['group', 'service-account', 'system'].includes(owner.type)) ? { owner } : {}) });
|
|
112
|
+
}
|
|
113
|
+
export function readWorkspaceAgents(cwd, family) {
|
|
114
|
+
const { workspaceRoot } = requireProjectLayout(cwd, family);
|
|
115
|
+
const [directory, file] = AGENT_LAYOUT[family];
|
|
116
|
+
return findManifestFiles(path.join(workspaceRoot, directory), file).map(manifestPath => ({ manifestPath, manifest: JSON.parse(fs.readFileSync(manifestPath, 'utf8')) }));
|
|
117
|
+
}
|
|
118
|
+
function manifestPath(cwd, manifest) {
|
|
119
|
+
const { workspaceRoot } = requireProjectLayout(cwd, manifest.kind);
|
|
120
|
+
const [directory, file] = AGENT_LAYOUT[manifest.kind];
|
|
121
|
+
return path.join(workspaceRoot, directory, `${sanitizeSegment(manifest.name)}-${stableKeySuffix(manifest.stableKey)}`, file);
|
|
122
|
+
}
|
|
123
|
+
function pluginDependencies(definition) {
|
|
124
|
+
const refs = [];
|
|
125
|
+
if (definition.componentStableKey)
|
|
126
|
+
refs.push(['component', String(definition.componentStableKey)]);
|
|
127
|
+
for (const kind of ['skill', 'package'])
|
|
128
|
+
if (definition[kind])
|
|
129
|
+
for (const key of strings(record(definition[kind]).pluginStableKeys))
|
|
130
|
+
refs.push(['agent-plugin', key]);
|
|
131
|
+
return refs;
|
|
132
|
+
}
|
|
133
|
+
export function agentDependencies(manifest) {
|
|
134
|
+
if (manifest.kind === 'agent-plugin')
|
|
135
|
+
return pluginDependencies(manifest.definition);
|
|
136
|
+
const refs = [];
|
|
137
|
+
if (manifest.executionPrincipal?.kind === 'service-account')
|
|
138
|
+
refs.push(['service-account', manifest.executionPrincipal.stableKey]);
|
|
139
|
+
if (manifest.owner?.type === 'group' || manifest.owner?.type === 'service-account')
|
|
140
|
+
refs.push([manifest.owner.type, manifest.owner.stableKey]);
|
|
141
|
+
for (const key of ['config', 'policy']) {
|
|
142
|
+
const section = record(manifest.definition[key]);
|
|
143
|
+
for (const field of ['pluginStableKeys', 'eagerPluginStableKeys'])
|
|
144
|
+
for (const value of strings(section[field]))
|
|
145
|
+
refs.push(['agent-plugin', value]);
|
|
146
|
+
if (Array.isArray(section.plugins))
|
|
147
|
+
for (const plugin of section.plugins)
|
|
148
|
+
refs.push(...pluginDependencies(record(plugin)));
|
|
149
|
+
}
|
|
150
|
+
return refs;
|
|
151
|
+
}
|
|
152
|
+
function validatePlugin(value, inline = false) {
|
|
153
|
+
const permitted = [...pluginFields, 'componentStableKey', 'mcpServer', 'skill', 'package', ...(inline ? ['enabled'] : ['category', 'active'])];
|
|
154
|
+
if (Object.keys(value).some(k => !permitted.includes(k)))
|
|
155
|
+
throw new Error('Unsupported or instance-local plugin field in manifest.');
|
|
156
|
+
if (!['tools', 'mcp_server', 'skill', 'package'].includes(String(value.kind)) || typeof value.id !== 'string' || !/^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*$/.test(value.id) || !value.name)
|
|
157
|
+
throw new Error('Plugin kind, slug and name are required.');
|
|
158
|
+
if (hashStable(portableToolContracts(value)) !== hashStable(value))
|
|
159
|
+
throw new Error('Derived approval fields are not accepted in portable plugin contracts.');
|
|
160
|
+
if (value.kind === 'tools' && !value.componentStableKey)
|
|
161
|
+
throw new Error('Tools plugin needs componentStableKey.');
|
|
162
|
+
if (value.kind === 'mcp_server') {
|
|
163
|
+
const mcp = record(value.mcpServer);
|
|
164
|
+
if (Object.keys(mcp).some(k => !mcpFields.includes(k)))
|
|
165
|
+
throw new Error('MCP credentials and Vault UUIDs are target-local.');
|
|
166
|
+
const url = new URL(String(mcp.url));
|
|
167
|
+
if (url.protocol !== 'https:' || url.username || url.password || url.search || url.hash)
|
|
168
|
+
throw new Error('MCP URL must be public HTTPS without credentials or query.');
|
|
169
|
+
}
|
|
170
|
+
for (const kind of ['skill', 'package'])
|
|
171
|
+
if (value[kind]) {
|
|
172
|
+
const content = record(value[kind]);
|
|
173
|
+
if (Object.keys(content).some(k => !['format', 'content', 'maxPromptTokens', 'pluginStableKeys', ...(kind === 'package' ? ['externalId'] : [])].includes(k)))
|
|
174
|
+
throw new Error('Unsupported or read-only content plugin field.');
|
|
175
|
+
if (typeof content.content !== 'string')
|
|
176
|
+
throw new Error('Plugin Markdown content is required.');
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function validate(manifest, input) {
|
|
180
|
+
if (!isRecord(manifest) || manifest.kind !== input.family || typeof manifest.stableKey !== 'string' || !manifest.stableKey.trim() || !manifest.name || !isRecord(manifest.metadata) || manifest.metadata[input.stableKeyName] !== manifest.stableKey || !isRecord(manifest.definition))
|
|
181
|
+
throw new Error('Invalid agent manifest identity, metadata or definition.');
|
|
182
|
+
if (Object.keys(manifest).some(k => !['kind', 'stableKey', 'name', 'metadata', 'definition', 'owner', 'executionPrincipal'].includes(k)))
|
|
183
|
+
throw new Error('Unsupported manifest field.');
|
|
184
|
+
if (manifest.kind === 'agent-plugin') {
|
|
185
|
+
validatePlugin(manifest.definition);
|
|
186
|
+
if (manifest.definition.name !== manifest.name)
|
|
187
|
+
throw new Error('Manifest name must match plugin definition name.');
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
if (!manifest.executionPrincipal || !['system', 'service-account'].includes(manifest.executionPrincipal.kind))
|
|
191
|
+
throw new Error('Agent requires executionPrincipal.');
|
|
192
|
+
for (const field of ['config', 'policy']) {
|
|
193
|
+
const section = record(manifest.definition[field]);
|
|
194
|
+
const allowed = [...(field === 'config' ? [...configFields, 'eagerPluginStableKeys'] : policyFields), 'pluginStableKeys', 'plugins'];
|
|
195
|
+
if (Object.keys(section).some(k => !allowed.includes(k)))
|
|
196
|
+
throw new Error('Memory, terminal IDs and other instance-local agent settings cannot appear in a portable manifest.');
|
|
197
|
+
if (Array.isArray(section.plugins))
|
|
198
|
+
for (const plugin of section.plugins)
|
|
199
|
+
validatePlugin(record(plugin), true);
|
|
200
|
+
}
|
|
201
|
+
if (Object.keys(manifest.definition).some(k => !['desc', 'config', 'policy'].includes(k)))
|
|
202
|
+
throw new Error('Unsupported Agent definition field.');
|
|
203
|
+
}
|
|
204
|
+
if (manifest.kind === 'agent') {
|
|
205
|
+
const principal = record(manifest.executionPrincipal);
|
|
206
|
+
if (Object.keys(principal).some(k => !['kind', 'stableKey'].includes(k)) || (principal.kind === 'service-account' && (typeof principal.stableKey !== 'string' || !principal.stableKey.trim())) || (principal.kind === 'system' && principal.stableKey !== undefined))
|
|
207
|
+
throw new Error('Invalid portable execution principal.');
|
|
208
|
+
const owner = record(manifest.owner);
|
|
209
|
+
if (owner.type === 'system' && Object.keys(owner).length !== 1)
|
|
210
|
+
throw new Error('System owner cannot contain instance fields.');
|
|
211
|
+
if (owner.type === 'unresolved')
|
|
212
|
+
throw new Error('Agent owner is unresolved; assign a managed owner or explicit manual-user policy.');
|
|
213
|
+
if (!['group', 'service-account', 'system', 'manual-user', 'unresolved'].includes(String(owner.type)) || Object.keys(owner).some(k => !['type', 'stableKey', 'reason'].includes(k)))
|
|
214
|
+
throw new Error('Invalid portable Agent owner.');
|
|
215
|
+
if (['group', 'service-account'].includes(String(owner.type)) && (typeof owner.stableKey !== 'string' || !owner.stableKey.trim()))
|
|
216
|
+
throw new Error('Owner Stable Key required.');
|
|
217
|
+
}
|
|
218
|
+
agentDependencies(manifest);
|
|
219
|
+
}
|
|
220
|
+
function pathIdentity(filename) { return path.resolve(filename).normalize('NFC').split(path.sep).map(v => v.replace(/[. ]+$/g, '').toLowerCase()).join('/'); }
|
|
221
|
+
function unique(entries) {
|
|
222
|
+
const keys = new Set();
|
|
223
|
+
for (const { manifest } of entries) {
|
|
224
|
+
if (keys.has(manifest.stableKey))
|
|
225
|
+
throw new Error(`Duplicate Stable Key "${manifest.stableKey}".`);
|
|
226
|
+
keys.add(manifest.stableKey);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
export function orderAgentPlugins(entries) {
|
|
230
|
+
unique(entries);
|
|
231
|
+
const byKey = new Map(entries.map(entry => [entry.manifest.stableKey, entry]));
|
|
232
|
+
const visiting = new Set();
|
|
233
|
+
const done = new Set();
|
|
234
|
+
const ordered = [];
|
|
235
|
+
function visit(key) {
|
|
236
|
+
if (done.has(key))
|
|
237
|
+
return;
|
|
238
|
+
if (visiting.has(key))
|
|
239
|
+
throw new Error(`Plugin dependency cycle at "${key}".`);
|
|
240
|
+
const entry = byKey.get(key);
|
|
241
|
+
if (!entry)
|
|
242
|
+
return;
|
|
243
|
+
visiting.add(key);
|
|
244
|
+
for (const [family, dependency] of agentDependencies(entry.manifest))
|
|
245
|
+
if (family === 'agent-plugin') {
|
|
246
|
+
if (entry.manifest.definition.kind === 'package' && byKey.get(dependency)?.manifest.definition.kind === 'package')
|
|
247
|
+
throw new Error('Packages cannot depend on packages.');
|
|
248
|
+
visit(dependency);
|
|
249
|
+
}
|
|
250
|
+
visiting.delete(key);
|
|
251
|
+
done.add(key);
|
|
252
|
+
ordered.push(entry);
|
|
253
|
+
}
|
|
254
|
+
for (const key of [...byKey.keys()].sort())
|
|
255
|
+
visit(key);
|
|
256
|
+
return ordered;
|
|
257
|
+
}
|
|
258
|
+
export async function pullAgentsToWorkspace(input) {
|
|
259
|
+
const entries = [];
|
|
260
|
+
const skipped = [];
|
|
261
|
+
const values = await inventory(input.client, input.family);
|
|
262
|
+
for (const value of values) {
|
|
263
|
+
const manifest = await agentManifestFromRecord(input, value);
|
|
264
|
+
if (!manifest) {
|
|
265
|
+
skipped.push({ name: String(value.name || ''), targetPath: '', reason: 'Missing Stable Key; unmanaged.' });
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
validate(manifest, input);
|
|
269
|
+
entries.push({ manifest });
|
|
270
|
+
}
|
|
271
|
+
unique(entries);
|
|
272
|
+
const existing = readWorkspaceAgents(input.cwd, input.family);
|
|
273
|
+
unique(existing);
|
|
274
|
+
const paths = new Set();
|
|
275
|
+
for (const { manifest } of entries) {
|
|
276
|
+
const filename = manifestPath(input.cwd, manifest);
|
|
277
|
+
const key = pathIdentity(filename);
|
|
278
|
+
if (paths.has(key))
|
|
279
|
+
throw new Error('Agent manifest filesystem path collision.');
|
|
280
|
+
paths.add(key);
|
|
281
|
+
const local = existing.find(v => v.manifest.stableKey === manifest.stableKey);
|
|
282
|
+
if (local && hashPortableAgent(local.manifest) !== hashPortableAgent(manifest) && !input.force)
|
|
283
|
+
throw new Error(`Local ${input.family} "${manifest.stableKey}" differs; use --force to replace.`);
|
|
284
|
+
if (fs.existsSync(filename) && (!local || pathIdentity(local.manifestPath) !== key))
|
|
285
|
+
throw new Error('Agent manifest path is occupied by another resource.');
|
|
286
|
+
}
|
|
287
|
+
const { projectRoot } = requireProjectLayout(input.cwd, input.family);
|
|
288
|
+
const lock = readComponentLock(projectRoot);
|
|
289
|
+
const field = AGENT_LAYOUT[input.family][2];
|
|
290
|
+
if (input.pruneOrphans && skipped.length && existing.some(local => !entries.some(e => e.manifest.stableKey === local.manifest.stableKey)))
|
|
291
|
+
throw new Error('Cannot prune local Agent manifests while source inventory contains unmanaged resources.');
|
|
292
|
+
const pulled = [];
|
|
293
|
+
const pruned = [];
|
|
294
|
+
for (const { manifest } of entries) {
|
|
295
|
+
const filename = manifestPath(input.cwd, manifest);
|
|
296
|
+
writePulledManifest({ filePath: filename, manifest, root: path.dirname(filename) });
|
|
297
|
+
const local = existing.find(v => v.manifest.stableKey === manifest.stableKey);
|
|
298
|
+
if (local && local.manifestPath !== filename)
|
|
299
|
+
fs.unlinkSync(local.manifestPath);
|
|
300
|
+
const hash = hashPortableAgent(manifest);
|
|
301
|
+
const prior = lock[field][manifest.stableKey];
|
|
302
|
+
lock[field][manifest.stableKey] = { stableKey: manifest.stableKey, path: toPortableRelativePath(projectRoot, filename), sourceHash: hash, environments: { ...prior?.environments, [input.envName]: { remoteHash: hash, syncedAt: new Date().toISOString() } } };
|
|
303
|
+
pulled.push({ manifest, targetPath: path.relative(input.cwd, filename) });
|
|
304
|
+
}
|
|
305
|
+
if (input.pruneOrphans)
|
|
306
|
+
for (const local of existing)
|
|
307
|
+
if (!entries.some(e => e.manifest.stableKey === local.manifest.stableKey)) {
|
|
308
|
+
// Resources that remain visible but unmanaged must never cause deletion of a tracked local definition.
|
|
309
|
+
fs.unlinkSync(local.manifestPath);
|
|
310
|
+
delete lock[field][local.manifest.stableKey];
|
|
311
|
+
pruned.push({ stableKey: local.manifest.stableKey, targetPath: path.relative(input.cwd, local.manifestPath) });
|
|
312
|
+
}
|
|
313
|
+
writeComponentLock(projectRoot, lock);
|
|
314
|
+
return { pulled, pruned, skipped };
|
|
315
|
+
}
|
|
316
|
+
function dependencyRecords(input, family, cache) {
|
|
317
|
+
let pending = cache.get(family);
|
|
318
|
+
if (!pending) {
|
|
319
|
+
pending = family === 'service-account' ? input.client.listAllServiceAccounts().then(v => v.serviceAccounts)
|
|
320
|
+
: family === 'group' ? input.client.listAllGroups().then(v => v.groups) : inventory(input.client, family);
|
|
321
|
+
cache.set(family, pending);
|
|
322
|
+
}
|
|
323
|
+
return pending;
|
|
324
|
+
}
|
|
325
|
+
async function resolveKey(input, family, key, cache = new Map()) {
|
|
326
|
+
const values = await dependencyRecords(input, family, cache);
|
|
327
|
+
const matches = values.filter(value => active(value) && readConfiguredResourceMetadataStableKey(value, input.stableKeyName) === key);
|
|
328
|
+
if (matches.length !== 1)
|
|
329
|
+
throw new Error(`${family} "${key}" must resolve to exactly one active target resource.`);
|
|
330
|
+
if (family === 'service-account' && (matches[0].serviceAccount !== true || ![0, 'ACTIVE'].includes(matches[0].status)))
|
|
331
|
+
throw new Error('Agent execution Service Account must be active.');
|
|
332
|
+
return resourceIdOf(matches[0]);
|
|
333
|
+
}
|
|
334
|
+
function requireMcpAuthentication(desired, current) {
|
|
335
|
+
const mode = desired.authMode || 'none';
|
|
336
|
+
if (mode === 'none')
|
|
337
|
+
return;
|
|
338
|
+
const local = isRecord(current) ? current : {};
|
|
339
|
+
const ready = mode === 'bearer' ? Boolean(local.bearerSecretId)
|
|
340
|
+
: mode === 'basic' ? Boolean(local.basicUsername && local.basicPasswordSecretId)
|
|
341
|
+
: mode === 'header' ? Array.isArray(local.headers) && local.headers.length > 0 : false;
|
|
342
|
+
if (!ready)
|
|
343
|
+
throw new Error('Authenticated MCP requires matching target-local authentication bindings before deployment.');
|
|
344
|
+
}
|
|
345
|
+
async function pluginPayload(input, definition, current, cache = new Map()) {
|
|
346
|
+
const result = pick(definition, [...pluginFields, 'category', 'active', 'enabled']);
|
|
347
|
+
if (definition.kind === 'tools' && current)
|
|
348
|
+
result.componentDigest = definition.componentDigest ?? null;
|
|
349
|
+
if (definition.componentStableKey)
|
|
350
|
+
result.componentId = await resolveKey(input, 'component', String(definition.componentStableKey), cache);
|
|
351
|
+
if (definition.mcpServer) {
|
|
352
|
+
const mcp = record(definition.mcpServer);
|
|
353
|
+
const local = isRecord(current?.mcpServer) ? current.mcpServer : {};
|
|
354
|
+
requireMcpAuthentication(mcp, local);
|
|
355
|
+
result.mcpServer = { ...local, ...mcp };
|
|
356
|
+
}
|
|
357
|
+
for (const kind of ['skill', 'package'])
|
|
358
|
+
if (definition[kind]) {
|
|
359
|
+
const { pluginStableKeys, ...content } = record(definition[kind]);
|
|
360
|
+
result[kind] = { ...content, pluginIds: await Promise.all(strings(pluginStableKeys).map(key => resolveKey(input, 'agent-plugin', key, cache))) };
|
|
361
|
+
}
|
|
362
|
+
return result;
|
|
363
|
+
}
|
|
364
|
+
async function writePayload(input, manifest, current) {
|
|
365
|
+
const cache = new Map();
|
|
366
|
+
if (manifest.kind === 'agent-plugin')
|
|
367
|
+
return { ...await pluginPayload(input, manifest.definition, isRecord(current?.config) ? current.config : undefined, cache), metadata: manifest.metadata };
|
|
368
|
+
if (manifest.executionPrincipal?.kind === 'service-account') {
|
|
369
|
+
const id = await resolveKey(input, 'service-account', manifest.executionPrincipal.stableKey, cache);
|
|
370
|
+
if ((await input.client.getServiceAccount(id)).platformAccess !== true)
|
|
371
|
+
throw new Error('Agent Service Account requires target platform access.');
|
|
372
|
+
}
|
|
373
|
+
const result = { name: manifest.name, desc: manifest.definition.desc || '', metadata: manifest.metadata,
|
|
374
|
+
serviceAccountUserId: await resolveExecutionPrincipal(input.client, manifest.executionPrincipal, input.stableKeyName) };
|
|
375
|
+
if (manifest.owner && ['group', 'service-account', 'system'].includes(manifest.owner.type))
|
|
376
|
+
Object.assign(result, await resolvePortableOwner(input.client, manifest.owner, input.stableKeyName));
|
|
377
|
+
for (const field of ['config', 'policy']) {
|
|
378
|
+
const section = record(manifest.definition[field]);
|
|
379
|
+
const local = isRecord(current?.[field]) ? current[field] : {};
|
|
380
|
+
// Replacements preserve target memory, terminal selection, automation recipients and rollout receipts.
|
|
381
|
+
const targetLocal = Object.fromEntries(Object.entries(local).filter(([k]) => !(field === 'config' ? configFields : policyFields).includes(k) && !['pluginIds', 'eagerPluginIds', 'plugins'].includes(k)));
|
|
382
|
+
const replacement = { ...targetLocal, ...pick(section, field === 'config' ? configFields : policyFields) };
|
|
383
|
+
for (const [portable, actual] of [['pluginStableKeys', 'pluginIds'], ...(field === 'config' ? [['eagerPluginStableKeys', 'eagerPluginIds']] : [])])
|
|
384
|
+
replacement[actual] = await Promise.all(strings(section[portable]).map(key => resolveKey(input, 'agent-plugin', key, cache)));
|
|
385
|
+
if (section.plugins)
|
|
386
|
+
replacement.plugins = await Promise.all(section.plugins.map(value => {
|
|
387
|
+
const plugin = record(value);
|
|
388
|
+
const previous = Array.isArray(local.plugins) ? local.plugins.find(v => isRecord(v) && v.id === plugin.id) : undefined;
|
|
389
|
+
return pluginPayload(input, plugin, isRecord(previous) ? previous : undefined, cache);
|
|
390
|
+
}));
|
|
391
|
+
else
|
|
392
|
+
replacement.plugins = [];
|
|
393
|
+
result[field] = replacement;
|
|
394
|
+
}
|
|
395
|
+
return result;
|
|
396
|
+
}
|
|
397
|
+
export async function buildAgentsPlan(input) {
|
|
398
|
+
const plan = { resourceType: input.family, env: input.envName, items: [], counts: { clean: 0, create: 0, 'safe-update': 0, 'remote-changed': 0, conflict: 0, 'missing-lock': 0, orphan: 0, skipped: 0, collision: 0 }, blockers: [], warnings: [], exclusions: ['Agent memory, sessions, workspace files, terminals, automation recipients, avatars and MCP secrets remain target-local.'] };
|
|
399
|
+
const locals = readWorkspaceAgents(input.cwd, input.family);
|
|
400
|
+
if (input.family === 'agent-plugin')
|
|
401
|
+
input = { ...input, projected: { ...input.projected, 'agent-plugin': [...(input.projected?.['agent-plugin'] || []), ...locals.map(e => e.manifest.stableKey)] } };
|
|
402
|
+
const values = await inventory(input.client, input.family);
|
|
403
|
+
const { projectRoot } = requireProjectLayout(input.cwd, input.family);
|
|
404
|
+
const lock = readComponentLock(projectRoot)[AGENT_LAYOUT[input.family][2]];
|
|
405
|
+
try {
|
|
406
|
+
unique(locals);
|
|
407
|
+
if (input.family === 'agent-plugin')
|
|
408
|
+
orderAgentPlugins(locals);
|
|
409
|
+
}
|
|
410
|
+
catch (error) {
|
|
411
|
+
plan.blockers.push(String(error));
|
|
412
|
+
}
|
|
413
|
+
const cache = new Map();
|
|
414
|
+
if (input.family === 'agent-plugin')
|
|
415
|
+
cache.set('agent-plugin', Promise.resolve(values));
|
|
416
|
+
const remoteKeys = new Set();
|
|
417
|
+
for (const value of values) {
|
|
418
|
+
const key = readConfiguredResourceMetadataStableKey(value, input.stableKeyName);
|
|
419
|
+
if (key && remoteKeys.has(key))
|
|
420
|
+
plan.blockers.push(`Duplicate target Stable Key "${key}".`);
|
|
421
|
+
if (key)
|
|
422
|
+
remoteKeys.add(key);
|
|
423
|
+
}
|
|
424
|
+
if (input.family === 'agent-plugin' && locals.length) {
|
|
425
|
+
try {
|
|
426
|
+
const graph = [...locals];
|
|
427
|
+
const visited = new Set(locals.map(v => v.manifest.stableKey));
|
|
428
|
+
// Inspect only retained dependencies reachable from desired definitions.
|
|
429
|
+
// An unrelated target-only prompt plugin may remain unmanaged/WIP.
|
|
430
|
+
for (let index = 0; index < graph.length; index++) {
|
|
431
|
+
for (const [family, key] of agentDependencies(graph[index].manifest)) {
|
|
432
|
+
if (family !== 'agent-plugin' || visited.has(key))
|
|
433
|
+
continue;
|
|
434
|
+
visited.add(key);
|
|
435
|
+
const value = values.find(v => readConfiguredResourceMetadataStableKey(v, input.stableKeyName) === key);
|
|
436
|
+
if (!value)
|
|
437
|
+
continue;
|
|
438
|
+
const manifest = await agentManifestFromRecord(input, value);
|
|
439
|
+
if (manifest)
|
|
440
|
+
graph.push({ manifestPath: '', manifest });
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
orderAgentPlugins(graph);
|
|
444
|
+
}
|
|
445
|
+
catch (error) {
|
|
446
|
+
plan.blockers.push(error instanceof Error ? error.message : String(error));
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
const slugs = new Set();
|
|
450
|
+
for (const { manifest } of locals) {
|
|
451
|
+
const item = { name: manifest.name, stableKey: manifest.stableKey, status: 'collision' };
|
|
452
|
+
plan.items.push(item);
|
|
453
|
+
try {
|
|
454
|
+
validate(manifest, input);
|
|
455
|
+
if (input.family === 'agent-plugin') {
|
|
456
|
+
const slug = String(manifest.definition.id);
|
|
457
|
+
if (slugs.has(slug))
|
|
458
|
+
throw new Error(`Duplicate local plugin slug "${slug}".`);
|
|
459
|
+
slugs.add(slug);
|
|
460
|
+
}
|
|
461
|
+
const target = values.find(v => readConfiguredResourceMetadataStableKey(v, input.stableKeyName) === manifest.stableKey);
|
|
462
|
+
if (target && input.family === 'agent-plugin' && target.pluginSlug !== manifest.definition.id)
|
|
463
|
+
throw new Error('Plugin slug is immutable; target Stable Key belongs to a different slug.');
|
|
464
|
+
const nameCollision = values.some(v => v !== target && (input.family === 'agent-plugin' ? v.pluginSlug === manifest.definition.id : String(v.name).trim().toLowerCase() === manifest.name.trim().toLowerCase()));
|
|
465
|
+
if (nameCollision)
|
|
466
|
+
throw new Error('Unmanaged or differently keyed target with the same name/slug; refusing adoption.');
|
|
467
|
+
for (const [family, key] of agentDependencies(manifest)) {
|
|
468
|
+
// A projected create can fill an absent dependency, never hide duplicate target identities.
|
|
469
|
+
const candidates = await dependencyRecords(input, family, cache);
|
|
470
|
+
const matches = candidates.filter(value => active(value) && readConfiguredResourceMetadataStableKey(value, input.stableKeyName) === key);
|
|
471
|
+
if (matches.length === 0 && input.projected?.[family]?.includes(key))
|
|
472
|
+
continue;
|
|
473
|
+
await resolveKey(input, family, key, cache);
|
|
474
|
+
}
|
|
475
|
+
if (manifest.owner?.type === 'system' && !await ownerIsAvailable(input.client, manifest.owner, input.stableKeyName))
|
|
476
|
+
throw new Error('System owner unavailable.');
|
|
477
|
+
if (manifest.executionPrincipal?.kind === 'service-account' && !input.projected?.['service-account']?.includes(manifest.executionPrincipal.stableKey)) {
|
|
478
|
+
const id = await resolveKey(input, 'service-account', manifest.executionPrincipal.stableKey, cache);
|
|
479
|
+
if ((await input.client.getServiceAccount(id)).platformAccess !== true)
|
|
480
|
+
throw new Error('Agent Service Account requires target platform access.');
|
|
481
|
+
}
|
|
482
|
+
if (manifest.executionPrincipal?.kind === 'system')
|
|
483
|
+
await resolveExecutionPrincipal(input.client, manifest.executionPrincipal, input.stableKeyName);
|
|
484
|
+
for (const field of ['config', 'policy']) {
|
|
485
|
+
const section = manifest.definition[field];
|
|
486
|
+
if (isRecord(section) && Array.isArray(section.plugins))
|
|
487
|
+
for (const inline of section.plugins) {
|
|
488
|
+
const plugin = record(inline);
|
|
489
|
+
const localSection = target?.[field];
|
|
490
|
+
const match = isRecord(localSection) && Array.isArray(localSection.plugins) ? localSection.plugins.find(v => isRecord(v) && v.id === plugin.id) : undefined;
|
|
491
|
+
if (isRecord(plugin.mcpServer))
|
|
492
|
+
requireMcpAuthentication(plugin.mcpServer, isRecord(match) ? match.mcpServer : undefined);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
const mcp = manifest.definition.mcpServer;
|
|
496
|
+
if (isRecord(mcp))
|
|
497
|
+
requireMcpAuthentication(mcp, isRecord(target?.config) ? target.config.mcpServer : undefined);
|
|
498
|
+
const current = target ? await agentManifestFromRecord(input, target) : null;
|
|
499
|
+
// Human ownership stays local and cannot create drift.
|
|
500
|
+
if (current && manifest.owner?.type === 'manual-user')
|
|
501
|
+
current.owner = manifest.owner;
|
|
502
|
+
item.desiredHash = hashPortableAgent(manifest);
|
|
503
|
+
item.currentHash = current ? hashPortableAgent(current) : undefined;
|
|
504
|
+
item.baselineHash = lock[manifest.stableKey]?.environments[input.envName]?.remoteHash;
|
|
505
|
+
item.status = !target ? 'create' : item.desiredHash === item.currentHash ? 'clean' : !item.baselineHash ? 'missing-lock' : item.currentHash === item.baselineHash ? 'safe-update' : item.desiredHash === item.baselineHash ? 'remote-changed' : 'conflict';
|
|
506
|
+
if (current && item.desiredHash !== item.currentHash) {
|
|
507
|
+
item.changedFields = Object.keys(manifest).filter(k => hashStable(manifest[k]) !== hashStable(current[k]));
|
|
508
|
+
item.fieldChanges = describeFieldChanges(manifest, current, item.changedFields);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
catch (error) {
|
|
512
|
+
item.reason = error instanceof Error ? error.message : String(error);
|
|
513
|
+
item.blocked = true;
|
|
514
|
+
plan.blockers.push(`${input.family} "${manifest.stableKey}": ${item.reason}`);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
for (const value of values) {
|
|
518
|
+
const key = readConfiguredResourceMetadataStableKey(value, input.stableKeyName);
|
|
519
|
+
if (!key) {
|
|
520
|
+
plan.items.push({ status: 'skipped', name: String(value.name || ''), reason: 'Unmanaged target.' });
|
|
521
|
+
continue;
|
|
522
|
+
}
|
|
523
|
+
if (!locals.some(e => e.manifest.stableKey === key))
|
|
524
|
+
plan.items.push({ status: 'orphan', stableKey: key, name: String(value.name || ''), reason: 'Target-only resource is retained.' });
|
|
525
|
+
}
|
|
526
|
+
for (const item of plan.items)
|
|
527
|
+
plan.counts[item.status]++;
|
|
528
|
+
return plan;
|
|
529
|
+
}
|
|
530
|
+
export async function pushAgents(input) {
|
|
531
|
+
const plan = await buildAgentsPlan(input);
|
|
532
|
+
const results = [];
|
|
533
|
+
if (plan.blockers.length)
|
|
534
|
+
throw new Error(plan.blockers.join(' '));
|
|
535
|
+
const locals = readWorkspaceAgents(input.cwd, input.family);
|
|
536
|
+
const ordered = input.family === 'agent-plugin' ? orderAgentPlugins(locals) : locals;
|
|
537
|
+
for (const { manifest, manifestPath: filename } of ordered) {
|
|
538
|
+
const item = plan.items.find(v => v.stableKey === manifest.stableKey);
|
|
539
|
+
const output = { stableKey: manifest.stableKey, action: item.status === 'create' ? 'create' : item.status === 'clean' ? 'noop' : 'update', status: 'failed', targetPath: path.relative(input.cwd, filename) };
|
|
540
|
+
try {
|
|
541
|
+
if (['conflict', 'remote-changed', 'missing-lock'].includes(item.status) && !input.force)
|
|
542
|
+
throw new Error('Target drift requires --force after reviewing the plan.');
|
|
543
|
+
// Rebuild and fence immediately before each write; do not apply stale payloads to newer state.
|
|
544
|
+
const values = await inventory(input.client, input.family);
|
|
545
|
+
const targets = values.filter(v => readConfiguredResourceMetadataStableKey(v, input.stableKeyName) === manifest.stableKey);
|
|
546
|
+
if (targets.length > 1)
|
|
547
|
+
throw new Error('Duplicate target Stable Key before write.');
|
|
548
|
+
const target = targets[0];
|
|
549
|
+
const current = target ? await agentManifestFromRecord(input, target) : null;
|
|
550
|
+
if ((current ? hashPortableAgent(comparableAgent(manifest, current)) : undefined) !== item.currentHash)
|
|
551
|
+
throw new Error('Target definition changed after planning.');
|
|
552
|
+
let written = target;
|
|
553
|
+
if (item.desiredHash !== item.currentHash) {
|
|
554
|
+
const payload = await writePayload(input, manifest, target);
|
|
555
|
+
if (target && !Number.isInteger(target.version))
|
|
556
|
+
throw new Error('Target version is required.');
|
|
557
|
+
if (target) {
|
|
558
|
+
payload.version = target.version;
|
|
559
|
+
if (input.family === 'agent-plugin')
|
|
560
|
+
delete payload.id;
|
|
561
|
+
}
|
|
562
|
+
written = unwrapData(input.family === 'agent' ? target ? await input.client.updateAgent(resourceIdOf(target), payload) : await input.client.createAgent(payload) : target ? await input.client.updateAgentPlugin(resourceIdOf(target), payload) : await input.client.createAgentPlugin(payload));
|
|
563
|
+
}
|
|
564
|
+
if (!written || !resourceIdOf(written))
|
|
565
|
+
throw new Error('Write returned no resource identity.');
|
|
566
|
+
const verified = unwrapData(input.family === 'agent' ? await input.client.getAgent(resourceIdOf(written)) : await input.client.getAgentPlugin(resourceIdOf(written)));
|
|
567
|
+
const readback = await agentManifestFromRecord(input, verified);
|
|
568
|
+
if (!readback || hashPortableAgent(comparableAgent(manifest, readback)) !== item.desiredHash)
|
|
569
|
+
throw new Error('Portable readback differs; baseline not recorded.');
|
|
570
|
+
const { projectRoot } = requireProjectLayout(input.cwd, input.family);
|
|
571
|
+
const lock = readComponentLock(projectRoot);
|
|
572
|
+
const field = AGENT_LAYOUT[input.family][2];
|
|
573
|
+
const prior = lock[field][manifest.stableKey];
|
|
574
|
+
lock[field][manifest.stableKey] = { stableKey: manifest.stableKey, path: toPortableRelativePath(projectRoot, filename), sourceHash: item.desiredHash, environments: { ...prior?.environments, [input.envName]: { remoteHash: item.desiredHash, syncedAt: new Date().toISOString() } } };
|
|
575
|
+
writeComponentLock(projectRoot, lock);
|
|
576
|
+
output.status = 'deployed';
|
|
577
|
+
}
|
|
578
|
+
catch (error) {
|
|
579
|
+
output.error = error instanceof Error ? error.message : String(error);
|
|
580
|
+
}
|
|
581
|
+
results.push(output);
|
|
582
|
+
if (output.status === 'failed')
|
|
583
|
+
break;
|
|
584
|
+
}
|
|
585
|
+
return { plan, results };
|
|
586
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const TRACK_ALL_RESOURCES = "all";
|
|
2
|
-
export declare const TRACKABLE_RESOURCE_TYPES: readonly ["component", "endpoint", "group", "role-group", "job-template", "schedule", "event", "database-table", "database-view", "service-account"];
|
|
2
|
+
export declare const TRACKABLE_RESOURCE_TYPES: readonly ["component", "endpoint", "group", "role-group", "job-template", "schedule", "event", "database-table", "database-view", "service-account", "agent-plugin", "agent"];
|
|
3
3
|
export type TrackableResourceType = typeof TRACKABLE_RESOURCE_TYPES[number];
|
|
4
4
|
export type TrackedResource = typeof TRACK_ALL_RESOURCES | TrackableResourceType;
|
|
5
5
|
export declare function normalizeTrackedResources(value: string | string[] | null | undefined): TrackedResource[];
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export const TRACK_ALL_RESOURCES = 'all';
|
|
2
|
-
export const TRACKABLE_RESOURCE_TYPES = ['component', 'endpoint', 'group', 'role-group', 'job-template', 'schedule', 'event', 'database-table', 'database-view', 'service-account'];
|
|
2
|
+
export const TRACKABLE_RESOURCE_TYPES = ['component', 'endpoint', 'group', 'role-group', 'job-template', 'schedule', 'event', 'database-table', 'database-view', 'service-account', 'agent-plugin', 'agent'];
|
|
3
3
|
const RESOURCE_ALIASES = {
|
|
4
4
|
'service-account': 'service-account',
|
|
5
5
|
'service-accounts': 'service-account',
|
|
6
6
|
serviceaccount: 'service-account',
|
|
7
7
|
serviceaccounts: 'service-account',
|
|
8
|
+
agent: 'agent', agents: 'agent',
|
|
9
|
+
'agent-plugin': 'agent-plugin', 'agent-plugins': 'agent-plugin',
|
|
8
10
|
all: TRACK_ALL_RESOURCES,
|
|
9
11
|
'*': TRACK_ALL_RESOURCES,
|
|
10
12
|
component: 'component',
|
|
@@ -47,7 +49,7 @@ export function normalizeTrackedResources(value) {
|
|
|
47
49
|
}
|
|
48
50
|
const resource = RESOURCE_ALIASES[key];
|
|
49
51
|
if (!resource) {
|
|
50
|
-
throw new Error(`Unsupported tracked resource "${part.trim()}". Supported values: all, component, endpoint, group, role-group, job-template, schedule, event, database-table, database-view.`);
|
|
52
|
+
throw new Error(`Unsupported tracked resource "${part.trim()}". Supported values: all, component, endpoint, group, role-group, job-template, schedule, event, database-table, database-view, service-account, agent-plugin, agent.`);
|
|
51
53
|
}
|
|
52
54
|
if (!normalized.includes(resource)) {
|
|
53
55
|
normalized.push(resource);
|
package/dist/src/types.d.ts
CHANGED
|
@@ -16,6 +16,18 @@ export type CommandContext = {
|
|
|
16
16
|
error: (message: string) => void;
|
|
17
17
|
warn?: (message: string) => void;
|
|
18
18
|
};
|
|
19
|
+
export type AgentRecord = ComponentRecord & {
|
|
20
|
+
agentId?: string;
|
|
21
|
+
serviceAccountUserId?: string;
|
|
22
|
+
config?: Record<string, unknown>;
|
|
23
|
+
policy?: Record<string, unknown>;
|
|
24
|
+
};
|
|
25
|
+
export type AgentPluginRecord = ComponentRecord & {
|
|
26
|
+
agentPluginId?: string;
|
|
27
|
+
pluginSlug?: string;
|
|
28
|
+
kind?: string;
|
|
29
|
+
config?: Record<string, unknown>;
|
|
30
|
+
};
|
|
19
31
|
export type ComponentElementRecord = {
|
|
20
32
|
componentElementId?: string;
|
|
21
33
|
key: string;
|