@inkeep/agents-cli 0.53.10 → 0.53.12
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.
|
@@ -52,7 +52,7 @@ function generateSubAgentDefinition(data) {
|
|
|
52
52
|
if (hasHeadersTemplateVariables && parsed.contextConfigId && parsed.contextConfigHeadersReference && parsed.contextConfigHeadersReference.local !== true) namedImports.push(parsed.contextConfigHeadersReference.name);
|
|
53
53
|
if (namedImports.length > 0 && parsed.contextConfigId) sourceFile.addImportDeclaration({
|
|
54
54
|
namedImports: [...new Set(namedImports)],
|
|
55
|
-
moduleSpecifier:
|
|
55
|
+
moduleSpecifier: `../../context-configs/${parsed.contextConfigId}`
|
|
56
56
|
});
|
|
57
57
|
addCanUseToolImports(sourceFile, parsed.canUse, parsed.referenceOverrides?.tools);
|
|
58
58
|
addDataComponentImports(sourceFile, parsed.dataComponents, parsed.referenceOverrides?.dataComponents);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { collectTemplateVariableNames, createInMemoryProject, isPlainObject, toCamelCase } from "./utils.js";
|
|
1
|
+
import { buildComponentFileName, collectTemplateVariableNames, createInMemoryProject, isPlainObject, toCamelCase } from "./utils.js";
|
|
2
2
|
import { buildComponentRegistryFromParsing } from "./component-parser.js";
|
|
3
3
|
import { generateAgentDefinition } from "./generators/agent-generator.js";
|
|
4
4
|
import { generateArtifactComponentDefinition } from "./generators/artifact-component-generator.js";
|
|
@@ -109,7 +109,7 @@ function collectCredentialRecords(context) {
|
|
|
109
109
|
if (!context.project.credentialReferences) return [];
|
|
110
110
|
return Object.entries(context.project.credentialReferences).map(([credentialId, credentialData]) => ({
|
|
111
111
|
id: credentialId,
|
|
112
|
-
filePath: resolveRecordFilePath(context, "credentials", credentialId, join(context.paths.credentialsDir,
|
|
112
|
+
filePath: resolveRecordFilePath(context, "credentials", credentialId, join(context.paths.credentialsDir, buildComponentFileName(credentialId, credentialData.name ?? void 0))),
|
|
113
113
|
payload: {
|
|
114
114
|
credentialId,
|
|
115
115
|
...credentialData
|
|
@@ -120,7 +120,7 @@ function collectArtifactComponentRecords(context) {
|
|
|
120
120
|
if (!context.project.artifactComponents) return [];
|
|
121
121
|
return Object.entries(context.project.artifactComponents).map(([artifactComponentId, artifactComponentData]) => ({
|
|
122
122
|
id: artifactComponentId,
|
|
123
|
-
filePath: resolveRecordFilePath(context, "artifactComponents", artifactComponentId, join(context.paths.artifactComponentsDir,
|
|
123
|
+
filePath: resolveRecordFilePath(context, "artifactComponents", artifactComponentId, join(context.paths.artifactComponentsDir, buildComponentFileName(artifactComponentId, artifactComponentData.name ?? void 0))),
|
|
124
124
|
payload: {
|
|
125
125
|
artifactComponentId,
|
|
126
126
|
...artifactComponentData
|
|
@@ -131,7 +131,7 @@ function collectDataComponentRecords(context) {
|
|
|
131
131
|
if (!context.project.dataComponents) return [];
|
|
132
132
|
return Object.entries(context.project.dataComponents).map(([dataComponentId, dataComponent]) => ({
|
|
133
133
|
id: dataComponentId,
|
|
134
|
-
filePath: resolveRecordFilePath(context, "dataComponents", dataComponentId, join(context.paths.dataComponentsDir,
|
|
134
|
+
filePath: resolveRecordFilePath(context, "dataComponents", dataComponentId, join(context.paths.dataComponentsDir, buildComponentFileName(dataComponentId, dataComponent.name ?? void 0))),
|
|
135
135
|
payload: {
|
|
136
136
|
dataComponentId,
|
|
137
137
|
...dataComponent
|
|
@@ -169,7 +169,7 @@ function collectContextConfigRecords(context) {
|
|
|
169
169
|
function collectToolRecords(context) {
|
|
170
170
|
return Object.entries(context.project.tools ?? {}).map(([toolId, toolData]) => ({
|
|
171
171
|
id: toolId,
|
|
172
|
-
filePath: resolveRecordFilePath(context, "tools", toolId, join(context.paths.toolsDir,
|
|
172
|
+
filePath: resolveRecordFilePath(context, "tools", toolId, join(context.paths.toolsDir, buildComponentFileName(toolId, toolData.name ?? void 0))),
|
|
173
173
|
payload: {
|
|
174
174
|
mcpToolId: toolId,
|
|
175
175
|
...toolData
|
|
@@ -228,7 +228,7 @@ function collectTriggerRecords(context) {
|
|
|
228
228
|
if (!agentData?.triggers) continue;
|
|
229
229
|
for (const [triggerId, triggerData] of Object.entries(agentData.triggers)) records.push({
|
|
230
230
|
id: triggerId,
|
|
231
|
-
filePath: resolveRecordFilePath(context, "triggers", triggerId, join(context.paths.agentsDir, "triggers",
|
|
231
|
+
filePath: resolveRecordFilePath(context, "triggers", triggerId, join(context.paths.agentsDir, "triggers", buildComponentFileName(triggerId, triggerData.name ?? void 0))),
|
|
232
232
|
payload: {
|
|
233
233
|
triggerId,
|
|
234
234
|
...triggerData
|
|
@@ -245,7 +245,7 @@ function collectScheduledTriggerRecords(context) {
|
|
|
245
245
|
if (!agentData?.scheduledTriggers) continue;
|
|
246
246
|
for (const [scheduledTriggerId, scheduledTriggerData] of Object.entries(agentData.scheduledTriggers)) records.push({
|
|
247
247
|
id: scheduledTriggerId,
|
|
248
|
-
filePath: resolveRecordFilePath(context, "scheduledTriggers", scheduledTriggerId, join(context.paths.agentsDir, "scheduled-triggers",
|
|
248
|
+
filePath: resolveRecordFilePath(context, "scheduledTriggers", scheduledTriggerId, join(context.paths.agentsDir, "scheduled-triggers", buildComponentFileName(scheduledTriggerId, scheduledTriggerData.name ?? void 0))),
|
|
249
249
|
payload: {
|
|
250
250
|
scheduledTriggerId,
|
|
251
251
|
...scheduledTriggerData
|
|
@@ -260,7 +260,8 @@ function collectAgentRecords(context) {
|
|
|
260
260
|
for (const agentId of context.completeAgentIds) {
|
|
261
261
|
const agentData = context.project.agents[agentId];
|
|
262
262
|
if (!agentData) continue;
|
|
263
|
-
const
|
|
263
|
+
const agentName = typeof agentData.name === "string" ? agentData.name : void 0;
|
|
264
|
+
const agentFilePath = resolveRecordFilePath(context, "agents", agentId, join(context.paths.agentsDir, buildComponentFileName(agentId, agentName)));
|
|
264
265
|
const existingAgent = context.existingComponentRegistry?.get(agentId, "agents");
|
|
265
266
|
const subAgentReferences = collectSubAgentReferenceOverrides(context, agentData, agentFilePath);
|
|
266
267
|
const statusUpdates = asRecord(agentData.statusUpdates);
|
|
@@ -291,7 +292,8 @@ function collectSubAgentRecords(context) {
|
|
|
291
292
|
const payload = asRecord(subAgentData);
|
|
292
293
|
if (!payload) continue;
|
|
293
294
|
const referenceOverrides = collectSubAgentDependencyReferenceOverrides(context, payload);
|
|
294
|
-
const
|
|
295
|
+
const subAgentName = typeof payload.name === "string" ? payload.name : void 0;
|
|
296
|
+
const subAgentFilePath = resolveRecordFilePath(context, "subAgents", subAgentId, join(context.paths.agentsDir, "sub-agents", buildComponentFileName(subAgentId, subAgentName)));
|
|
295
297
|
const contextTemplateReferences = collectContextTemplateReferences(context, agentData, subAgentFilePath, [typeof payload.prompt === "string" ? payload.prompt : void 0]);
|
|
296
298
|
records.push({
|
|
297
299
|
id: subAgentId,
|
|
@@ -323,9 +325,10 @@ function collectStatusComponentRecords(context) {
|
|
|
323
325
|
if (!payload) continue;
|
|
324
326
|
const statusComponentId = resolveStatusComponentId(payload);
|
|
325
327
|
if (!statusComponentId || statusComponentRecordsById.has(statusComponentId)) continue;
|
|
328
|
+
const statusComponentName = typeof payload.name === "string" ? payload.name : void 0;
|
|
326
329
|
statusComponentRecordsById.set(statusComponentId, {
|
|
327
330
|
id: statusComponentId,
|
|
328
|
-
filePath: resolveRecordFilePath(context, "statusComponents", statusComponentId, join(context.paths.statusComponentsDir,
|
|
331
|
+
filePath: resolveRecordFilePath(context, "statusComponents", statusComponentId, join(context.paths.statusComponentsDir, buildComponentFileName(statusComponentId, statusComponentName))),
|
|
329
332
|
payload: {
|
|
330
333
|
statusComponentId,
|
|
331
334
|
...payload
|
|
@@ -55,6 +55,29 @@ function toCamelCase(input) {
|
|
|
55
55
|
const result = input.replace(/[^a-zA-Z0-9](.)/g, (_, char) => char.toUpperCase()).replace(/^[0-9]/, "_$&");
|
|
56
56
|
return result.charAt(0).toLowerCase() + result.slice(1);
|
|
57
57
|
}
|
|
58
|
+
function toKebabCase(input) {
|
|
59
|
+
return input.trim().replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase();
|
|
60
|
+
}
|
|
61
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
62
|
+
const CUID_RE = /^c[a-z0-9]{24,}$/;
|
|
63
|
+
const NANOID_RE = /^[a-z0-9]{16,}$/;
|
|
64
|
+
function isHumanReadableId(id) {
|
|
65
|
+
if (UUID_RE.test(id) || CUID_RE.test(id) || NANOID_RE.test(id)) return false;
|
|
66
|
+
const segments = id.split(/[-_]/);
|
|
67
|
+
if (segments.length === 1 && id.length > 8) {
|
|
68
|
+
const hasLetters = /[a-zA-Z]/.test(id);
|
|
69
|
+
const hasDigits = /[0-9]/.test(id);
|
|
70
|
+
if (hasLetters && hasDigits) return false;
|
|
71
|
+
}
|
|
72
|
+
return segments.filter((s) => /^[a-zA-Z]+\d{0,2}$/.test(s)).length / segments.length >= .5;
|
|
73
|
+
}
|
|
74
|
+
const ID_SUFFIX_LENGTH = 8;
|
|
75
|
+
function buildComponentFileName(id, name) {
|
|
76
|
+
if (!name || isHumanReadableId(id)) return `${id}.ts`;
|
|
77
|
+
const kebabName = toKebabCase(name);
|
|
78
|
+
if (!kebabName || kebabName === id) return `${id}.ts`;
|
|
79
|
+
return `${kebabName}-${id.slice(-ID_SUFFIX_LENGTH)}.ts`;
|
|
80
|
+
}
|
|
58
81
|
function createUniqueReferenceName(baseName, reservedNames, conflictSuffix) {
|
|
59
82
|
if (!reservedNames.has(baseName)) {
|
|
60
83
|
reservedNames.add(baseName);
|
|
@@ -232,4 +255,4 @@ function hasReferences(references) {
|
|
|
232
255
|
}
|
|
233
256
|
|
|
234
257
|
//#endregion
|
|
235
|
-
export { TEMPLATE_VARIABLE_REGEX, addFactoryConfigVariable, addObjectEntries, addReferenceGetterProperty, addStringProperty, addValueToObject, collectTemplateVariableNames, convertJsonSchemaToZodSafe, convertNullToUndefined, createFactoryDefinition, createInMemoryProject, createUniqueReferenceName, expectSnapshots, formatInlineLiteral, formatPropertyName, formatStringLiteral, formatTemplate, hasReferences, isPlainObject, resolveReferenceName, toCamelCase };
|
|
258
|
+
export { TEMPLATE_VARIABLE_REGEX, addFactoryConfigVariable, addObjectEntries, addReferenceGetterProperty, addStringProperty, addValueToObject, buildComponentFileName, collectTemplateVariableNames, convertJsonSchemaToZodSafe, convertNullToUndefined, createFactoryDefinition, createInMemoryProject, createUniqueReferenceName, expectSnapshots, formatInlineLiteral, formatPropertyName, formatStringLiteral, formatTemplate, hasReferences, isHumanReadableId, isPlainObject, resolveReferenceName, toCamelCase, toKebabCase };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-cli",
|
|
3
|
-
"version": "0.53.
|
|
3
|
+
"version": "0.53.12",
|
|
4
4
|
"description": "Inkeep CLI tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"tsx": "^4.20.5",
|
|
38
38
|
"yaml": "^2.7.0",
|
|
39
39
|
"zod": "^4.3.6",
|
|
40
|
-
"@inkeep/agents-core": "^0.53.
|
|
41
|
-
"@inkeep/agents-sdk": "^0.53.
|
|
40
|
+
"@inkeep/agents-core": "^0.53.12",
|
|
41
|
+
"@inkeep/agents-sdk": "^0.53.12"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"diff": "^8.0.3",
|