@inkeep/agents-cli 0.0.0-dev-20260120175022 → 0.0.0-dev-20260120193424
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/pull-v3/components/agent-generator.js +14 -0
- package/dist/commands/pull-v3/components/trigger-generator.js +101 -0
- package/dist/commands/pull-v3/introspect-generator.js +8 -0
- package/dist/commands/pull-v3/utils/component-registry.js +5 -0
- package/dist/utils/config.js +2 -1
- package/package.json +5 -5
|
@@ -173,6 +173,13 @@ function generateAgentDefinition(agentId, agentData, style = DEFAULT_STYLE, regi
|
|
|
173
173
|
}).join(", ")}]`;
|
|
174
174
|
lines.push(`${indentation}credentials: () => ${credentialsArray},`);
|
|
175
175
|
}
|
|
176
|
+
if (agentData.triggers && typeof agentData.triggers === "object" && Object.keys(agentData.triggers).length > 0) {
|
|
177
|
+
if (!registry) throw new Error("Registry is required for triggers generation");
|
|
178
|
+
const triggerIds = Object.keys(agentData.triggers);
|
|
179
|
+
const triggersArray = registry.formatReferencesForCode(triggerIds, "triggers", style, 2);
|
|
180
|
+
if (!triggersArray) throw new Error(`Failed to resolve variable names for triggers: ${triggerIds.join(", ")}`);
|
|
181
|
+
lines.push(`${indentation}triggers: () => ${triggersArray},`);
|
|
182
|
+
}
|
|
176
183
|
if (agentData.stopWhen) {
|
|
177
184
|
const stopWhenFormatted = formatStopWhen(agentData.stopWhen, style, 1);
|
|
178
185
|
if (stopWhenFormatted) lines.push(stopWhenFormatted);
|
|
@@ -225,6 +232,13 @@ function generateAgentImports(agentId, agentData, style = DEFAULT_STYLE, registr
|
|
|
225
232
|
id: agentData.defaultSubAgentId,
|
|
226
233
|
type: "subAgents"
|
|
227
234
|
});
|
|
235
|
+
if (agentData.triggers && typeof agentData.triggers === "object") {
|
|
236
|
+
const triggerIds = Object.keys(agentData.triggers);
|
|
237
|
+
referencedComponents.push(...triggerIds.map((id) => ({
|
|
238
|
+
id,
|
|
239
|
+
type: "triggers"
|
|
240
|
+
})));
|
|
241
|
+
}
|
|
228
242
|
const componentImports = registry.getImportsForFile(currentFilePath, referencedComponents);
|
|
229
243
|
imports.push(...componentImports);
|
|
230
244
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { DEFAULT_STYLE, formatString, generateFileContent, generateImport, toCamelCase } from "../utils/generator-utils.js";
|
|
2
|
+
|
|
3
|
+
//#region src/commands/pull-v3/components/trigger-generator.ts
|
|
4
|
+
/**
|
|
5
|
+
* Trigger Generator - Generate trigger definitions
|
|
6
|
+
*
|
|
7
|
+
* Generates triggers using the Trigger class from @inkeep/agents-sdk
|
|
8
|
+
* Triggers are webhooks that can invoke agent conversations
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Format authentication configuration
|
|
12
|
+
*/
|
|
13
|
+
function formatAuthentication(auth, style, indentLevel) {
|
|
14
|
+
if (!auth) return "";
|
|
15
|
+
const { indentation } = style;
|
|
16
|
+
const indent = indentation.repeat(indentLevel);
|
|
17
|
+
const innerIndent = indentation.repeat(indentLevel + 1);
|
|
18
|
+
const lines = [];
|
|
19
|
+
lines.push(`${indent}authentication: {`);
|
|
20
|
+
if (auth.type) lines.push(`${innerIndent}type: '${auth.type}',`);
|
|
21
|
+
if (lines.length > 1 && lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
|
|
22
|
+
lines.push(`${indent}},`);
|
|
23
|
+
return lines.join("\n");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Format output transform configuration
|
|
27
|
+
*/
|
|
28
|
+
function formatOutputTransform(transform, style, indentLevel) {
|
|
29
|
+
if (!transform) return "";
|
|
30
|
+
const { indentation } = style;
|
|
31
|
+
const indent = indentation.repeat(indentLevel);
|
|
32
|
+
const innerIndent = indentation.repeat(indentLevel + 1);
|
|
33
|
+
const lines = [];
|
|
34
|
+
lines.push(`${indent}outputTransform: {`);
|
|
35
|
+
if (transform.jmespath) lines.push(`${innerIndent}jmespath: '${transform.jmespath}',`);
|
|
36
|
+
if (transform.objectTransformation) {
|
|
37
|
+
const formattedTransform = JSON.stringify(transform.objectTransformation, null, 2).split("\n").map((line, index) => {
|
|
38
|
+
if (index === 0) return `${innerIndent}objectTransformation: ${line}`;
|
|
39
|
+
return `${innerIndent}${line}`;
|
|
40
|
+
}).join("\n");
|
|
41
|
+
lines.push(`${formattedTransform},`);
|
|
42
|
+
}
|
|
43
|
+
if (lines.length > 1 && lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
|
|
44
|
+
lines.push(`${indent}},`);
|
|
45
|
+
return lines.join("\n");
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Generate Trigger Definition using Trigger class
|
|
49
|
+
*/
|
|
50
|
+
function generateTriggerDefinition(triggerId, triggerData, style = DEFAULT_STYLE) {
|
|
51
|
+
if (!triggerId || typeof triggerId !== "string") throw new Error("triggerId is required and must be a string");
|
|
52
|
+
if (!triggerData || typeof triggerData !== "object") throw new Error(`triggerData is required for trigger '${triggerId}'`);
|
|
53
|
+
const missingFields = ["name", "messageTemplate"].filter((field) => !triggerData[field] || triggerData[field] === null || triggerData[field] === void 0);
|
|
54
|
+
if (missingFields.length > 0) throw new Error(`Missing required fields for trigger '${triggerId}': ${missingFields.join(", ")}`);
|
|
55
|
+
const { quotes, semicolons, indentation } = style;
|
|
56
|
+
const q = quotes === "single" ? "'" : "\"";
|
|
57
|
+
const semi = semicolons ? ";" : "";
|
|
58
|
+
const triggerVarName = toCamelCase(triggerId);
|
|
59
|
+
const lines = [];
|
|
60
|
+
lines.push(`export const ${triggerVarName} = new Trigger({`);
|
|
61
|
+
lines.push(`${indentation}id: ${formatString(triggerId, q)},`);
|
|
62
|
+
lines.push(`${indentation}name: ${formatString(triggerData.name, q)},`);
|
|
63
|
+
if (triggerData.description) lines.push(`${indentation}description: ${formatString(triggerData.description, q, true)},`);
|
|
64
|
+
if (triggerData.enabled !== void 0 && triggerData.enabled !== null) lines.push(`${indentation}enabled: ${triggerData.enabled},`);
|
|
65
|
+
lines.push(`${indentation}messageTemplate: ${formatString(triggerData.messageTemplate, q, true)},`);
|
|
66
|
+
if (triggerData.inputSchema) {
|
|
67
|
+
const formattedSchema = JSON.stringify(triggerData.inputSchema, null, 2).split("\n").map((line, index) => {
|
|
68
|
+
if (index === 0) return `${indentation}inputSchema: ${line}`;
|
|
69
|
+
return `${indentation}${line}`;
|
|
70
|
+
}).join("\n");
|
|
71
|
+
lines.push(`${formattedSchema},`);
|
|
72
|
+
}
|
|
73
|
+
if (triggerData.outputTransform) {
|
|
74
|
+
const outputTransformFormatted = formatOutputTransform(triggerData.outputTransform, style, 1);
|
|
75
|
+
if (outputTransformFormatted) lines.push(outputTransformFormatted);
|
|
76
|
+
}
|
|
77
|
+
if (triggerData.authentication) {
|
|
78
|
+
const authFormatted = formatAuthentication(triggerData.authentication, style, 1);
|
|
79
|
+
if (authFormatted) lines.push(authFormatted);
|
|
80
|
+
}
|
|
81
|
+
if (lines.length > 0 && lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
|
|
82
|
+
lines.push(`})${semi}`);
|
|
83
|
+
return lines.join("\n");
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Generate imports needed for a trigger file
|
|
87
|
+
*/
|
|
88
|
+
function generateTriggerImports(style = DEFAULT_STYLE) {
|
|
89
|
+
const imports = [];
|
|
90
|
+
imports.push(generateImport(["Trigger"], "@inkeep/agents-sdk", style));
|
|
91
|
+
return imports;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Generate complete trigger file (imports + definition)
|
|
95
|
+
*/
|
|
96
|
+
function generateTriggerFile(triggerId, triggerData, style = DEFAULT_STYLE) {
|
|
97
|
+
return generateFileContent(generateTriggerImports(style), [generateTriggerDefinition(triggerId, triggerData, style)]);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
export { generateTriggerDefinition, generateTriggerFile, generateTriggerImports };
|
|
@@ -12,6 +12,7 @@ import { generateProjectFile } from "./components/project-generator.js";
|
|
|
12
12
|
import { generateStatusComponentFile } from "./components/status-component-generator.js";
|
|
13
13
|
import { generateSubAgentFile } from "./components/sub-agent-generator.js";
|
|
14
14
|
import { ComponentRegistry, registerAllComponents } from "./utils/component-registry.js";
|
|
15
|
+
import { generateTriggerFile } from "./components/trigger-generator.js";
|
|
15
16
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
16
17
|
import { dirname, join } from "node:path";
|
|
17
18
|
import chalk from "chalk";
|
|
@@ -219,6 +220,13 @@ async function introspectGenerate(project, paths, environment, debug, options =
|
|
|
219
220
|
ensureDir(agentFile);
|
|
220
221
|
writeFileSync(agentFile, agentContent, "utf-8");
|
|
221
222
|
generatedFiles.push(agentFile);
|
|
223
|
+
if (agentData.triggers && Object.keys(agentData.triggers).length > 0) for (const [triggerId, triggerData] of Object.entries(agentData.triggers)) {
|
|
224
|
+
const triggerFile = join(paths.agentsDir, "triggers", `${triggerId}.ts`);
|
|
225
|
+
const triggerContent = generateTriggerFile(triggerId, triggerData, style);
|
|
226
|
+
ensureDir(triggerFile);
|
|
227
|
+
writeFileSync(triggerFile, triggerContent, "utf-8");
|
|
228
|
+
generatedFiles.push(triggerFile);
|
|
229
|
+
}
|
|
222
230
|
}
|
|
223
231
|
const projectDataForGenerator = {
|
|
224
232
|
...project,
|
|
@@ -199,6 +199,7 @@ var ComponentRegistry = class {
|
|
|
199
199
|
case "fetchDefinitions": return "fetch";
|
|
200
200
|
case "headers": return "header";
|
|
201
201
|
case "models": return "model";
|
|
202
|
+
case "triggers": return "trigger";
|
|
202
203
|
case "project": return "project";
|
|
203
204
|
default: return "comp";
|
|
204
205
|
}
|
|
@@ -295,6 +296,10 @@ function registerAllComponents(project, registry) {
|
|
|
295
296
|
const statusComponents = extractStatusComponents(project);
|
|
296
297
|
for (const statusId of Object.keys(statusComponents)) registry.register(statusId, "statusComponents", `status-components/${statusId}.ts`);
|
|
297
298
|
if (project.agents) for (const agentId of Object.keys(project.agents)) registry.register(agentId, "agents", `agents/${agentId}.ts`);
|
|
299
|
+
if (project.agents) for (const agentData of Object.values(project.agents)) {
|
|
300
|
+
const agentTriggers = agentData.triggers;
|
|
301
|
+
if (agentTriggers) for (const triggerId of Object.keys(agentTriggers)) registry.register(triggerId, "triggers", `agents/triggers/${triggerId}.ts`);
|
|
302
|
+
}
|
|
298
303
|
const subAgents = extractSubAgents(project);
|
|
299
304
|
for (const subAgentId of Object.keys(subAgents)) registry.register(subAgentId, "subAgents", `agents/sub-agents/${subAgentId}.ts`);
|
|
300
305
|
const contextConfigs = extractContextConfigs(project);
|
package/dist/utils/config.js
CHANGED
|
@@ -242,7 +242,7 @@ async function validateConfiguration(configPath, tag) {
|
|
|
242
242
|
const config = await loadConfig(configPath, tag);
|
|
243
243
|
const actualConfigFile = configPath || findConfigFile(process.cwd(), tag);
|
|
244
244
|
let cliCredentials = null;
|
|
245
|
-
try {
|
|
245
|
+
if (!(process.env.CI === "true" || process.env.CI === "1" || !!process.env.GITHUB_ACTIONS)) try {
|
|
246
246
|
const credentials = await loadCredentials();
|
|
247
247
|
if (credentials?.accessToken && credentials.organizationId) {
|
|
248
248
|
cliCredentials = {
|
|
@@ -254,6 +254,7 @@ async function validateConfiguration(configPath, tag) {
|
|
|
254
254
|
} catch {
|
|
255
255
|
logger.debug({}, "Could not load CLI credentials");
|
|
256
256
|
}
|
|
257
|
+
else logger.debug({}, "Skipping keychain credential loading in CI environment");
|
|
257
258
|
if (!config.agentsManageApiKey && cliCredentials) {
|
|
258
259
|
config.agentsManageApiKey = cliCredentials.accessToken;
|
|
259
260
|
logger.info({}, "Using CLI session token as API key");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-cli",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20260120193424",
|
|
4
4
|
"description": "Inkeep CLI tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -40,8 +40,9 @@
|
|
|
40
40
|
"ts-morph": "^26.0.0",
|
|
41
41
|
"tsx": "^4.20.5",
|
|
42
42
|
"yaml": "^2.7.0",
|
|
43
|
-
"
|
|
44
|
-
"@inkeep/agents-
|
|
43
|
+
"zod": "^4.1.11",
|
|
44
|
+
"@inkeep/agents-core": "^0.0.0-dev-20260120193424",
|
|
45
|
+
"@inkeep/agents-sdk": "^0.0.0-dev-20260120193424"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@types/degit": "^2.8.6",
|
|
@@ -52,8 +53,7 @@
|
|
|
52
53
|
"vitest": "^3.2.4"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
55
|
-
"@inkeep/agents-manage-ui": "0.0.0-dev-
|
|
56
|
-
"zod": "^4.1.11"
|
|
56
|
+
"@inkeep/agents-manage-ui": "0.0.0-dev-20260120193424"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public",
|