@inkeep/agents-cli 0.50.6 → 0.52.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 (69) hide show
  1. package/dist/agents-cli/package.js +6 -0
  2. package/dist/commands/config.js +1 -1
  3. package/dist/commands/dev.js +1 -1
  4. package/dist/commands/init.js +1 -1
  5. package/dist/commands/pull-v3/component-parser.js +4 -10
  6. package/dist/commands/pull-v4/agent-generator.js +274 -0
  7. package/dist/commands/pull-v4/artifact-component-generator.js +69 -0
  8. package/dist/commands/pull-v4/context-config-generator.js +264 -0
  9. package/dist/commands/pull-v4/credential-generator.js +30 -0
  10. package/dist/commands/pull-v4/data-component-generator.js +50 -0
  11. package/dist/commands/pull-v4/environment-generator.js +123 -0
  12. package/dist/commands/pull-v4/external-agent-generator.js +56 -0
  13. package/dist/commands/pull-v4/function-tool-generator.js +48 -0
  14. package/dist/commands/pull-v4/introspect/index.js +365 -0
  15. package/dist/commands/pull-v4/introspect/test-helpers.js +143 -0
  16. package/dist/commands/pull-v4/introspect-generator.js +691 -0
  17. package/dist/commands/pull-v4/mcp-tool-generator.js +91 -0
  18. package/dist/commands/pull-v4/module-merge.js +379 -0
  19. package/dist/commands/pull-v4/project-generator.js +101 -0
  20. package/dist/commands/pull-v4/status-component-generator.js +35 -0
  21. package/dist/commands/pull-v4/sub-agent-generator.js +168 -0
  22. package/dist/commands/pull-v4/trigger-generator.js +58 -0
  23. package/dist/commands/pull-v4/utils.js +219 -0
  24. package/dist/commands/push.js +1 -1
  25. package/dist/commands/update.js +2 -2
  26. package/dist/index.js +18 -44
  27. package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/array.js +18 -0
  28. package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/base.js +180 -0
  29. package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/character.js +8 -0
  30. package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/css.js +12 -0
  31. package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/json.js +60 -0
  32. package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/line.js +37 -0
  33. package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/sentence.js +31 -0
  34. package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/word.js +118 -0
  35. package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/index.js +11 -0
  36. package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/patch/create.js +141 -0
  37. package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/util/string.js +63 -0
  38. package/dist/utils/ci-environment.js +1 -1
  39. package/dist/utils/config.js +1 -1
  40. package/dist/utils/environment-loader.js +1 -1
  41. package/dist/utils/file-finder.js +1 -1
  42. package/dist/utils/mcp-runner.js +1 -1
  43. package/dist/utils/profile-config.js +1 -1
  44. package/dist/utils/profiles/profile-manager.js +1 -1
  45. package/dist/utils/project-directory.js +1 -1
  46. package/dist/utils/project-loader.js +1 -1
  47. package/dist/utils/version-check.js +6 -15
  48. package/package.json +5 -4
  49. package/dist/commands/pull-v3/component-updater.js +0 -768
  50. package/dist/commands/pull-v3/components/agent-generator.js +0 -255
  51. package/dist/commands/pull-v3/components/artifact-component-generator.js +0 -143
  52. package/dist/commands/pull-v3/components/context-config-generator.js +0 -190
  53. package/dist/commands/pull-v3/components/credential-generator.js +0 -89
  54. package/dist/commands/pull-v3/components/data-component-generator.js +0 -102
  55. package/dist/commands/pull-v3/components/environment-generator.js +0 -173
  56. package/dist/commands/pull-v3/components/external-agent-generator.js +0 -75
  57. package/dist/commands/pull-v3/components/function-tool-generator.js +0 -92
  58. package/dist/commands/pull-v3/components/mcp-tool-generator.js +0 -86
  59. package/dist/commands/pull-v3/components/project-generator.js +0 -157
  60. package/dist/commands/pull-v3/components/status-component-generator.js +0 -92
  61. package/dist/commands/pull-v3/components/sub-agent-generator.js +0 -295
  62. package/dist/commands/pull-v3/components/trigger-generator.js +0 -185
  63. package/dist/commands/pull-v3/index.js +0 -510
  64. package/dist/commands/pull-v3/introspect-generator.js +0 -286
  65. package/dist/commands/pull-v3/llm-content-merger.js +0 -192
  66. package/dist/commands/pull-v3/new-component-generator.js +0 -279
  67. package/dist/commands/pull-v3/project-index-generator.js +0 -32
  68. package/dist/commands/pull-v3/project-validator.js +0 -358
  69. package/dist/utils/url.js +0 -26
@@ -1,185 +0,0 @@
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
- * New format uses headers array: { headers: [{ name, valueHash, valuePrefix }] }
13
- * We generate code that uses environment variables for the secret values
14
- */
15
- function formatAuthentication(auth, style, indentLevel) {
16
- if (!auth) return "";
17
- const { indentation, quotes } = style;
18
- const q = quotes === "single" ? "'" : "\"";
19
- const indent = indentation.repeat(indentLevel);
20
- const innerIndent = indentation.repeat(indentLevel + 1);
21
- const headerIndent = indentation.repeat(indentLevel + 2);
22
- const lines = [];
23
- if (auth.headers && Array.isArray(auth.headers) && auth.headers.length > 0) {
24
- lines.push(`${indent}authentication: {`);
25
- lines.push(`${innerIndent}headers: [`);
26
- for (const header of auth.headers) {
27
- const envVarName = `TRIGGER_AUTH_${header.name.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`;
28
- lines.push(`${headerIndent}{`);
29
- lines.push(`${headerIndent}${indentation}name: ${q}${header.name}${q},`);
30
- lines.push(`${headerIndent}${indentation}value: process.env.${envVarName} || ${q}${q},`);
31
- lines.push(`${headerIndent}},`);
32
- }
33
- lines.push(`${innerIndent}],`);
34
- lines.push(`${indent}},`);
35
- }
36
- return lines.join("\n");
37
- }
38
- /**
39
- * Format output transform configuration
40
- */
41
- function formatOutputTransform(transform, style, indentLevel) {
42
- if (!transform) return "";
43
- const { indentation } = style;
44
- const indent = indentation.repeat(indentLevel);
45
- const innerIndent = indentation.repeat(indentLevel + 1);
46
- const lines = [];
47
- lines.push(`${indent}outputTransform: {`);
48
- if (transform.jmespath) lines.push(`${innerIndent}jmespath: '${transform.jmespath}',`);
49
- if (transform.objectTransformation) {
50
- const formattedTransform = JSON.stringify(transform.objectTransformation, null, 2).split("\n").map((line, index) => {
51
- if (index === 0) return `${innerIndent}objectTransformation: ${line}`;
52
- return `${innerIndent}${line}`;
53
- }).join("\n");
54
- lines.push(`${formattedTransform},`);
55
- }
56
- if (lines.length > 1 && lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
57
- lines.push(`${indent}},`);
58
- return lines.join("\n");
59
- }
60
- /**
61
- * Format signature verification configuration
62
- * Generates code for signatureVerification object with all nested structures
63
- */
64
- function formatSignatureVerification(config, style, indentLevel) {
65
- if (!config) return "";
66
- const { indentation, quotes } = style;
67
- const q = quotes === "single" ? "'" : "\"";
68
- const indent = indentation.repeat(indentLevel);
69
- const lines = [];
70
- lines.push(`${indent}signatureVerification: {`);
71
- const algorithmIndent = indentation.repeat(indentLevel + 1);
72
- lines.push(`${algorithmIndent}algorithm: ${formatString(config.algorithm, q)},`);
73
- lines.push(`${algorithmIndent}encoding: ${formatString(config.encoding, q)},`);
74
- lines.push(`${algorithmIndent}signature: {`);
75
- const sigIndent = indentation.repeat(indentLevel + 2);
76
- lines.push(`${sigIndent}source: ${formatString(config.signature.source, q)},`);
77
- lines.push(`${sigIndent}key: ${formatString(config.signature.key, q)},`);
78
- if (config.signature.prefix !== void 0 && config.signature.prefix !== null) lines.push(`${sigIndent}prefix: ${formatString(config.signature.prefix, q)},`);
79
- if (config.signature.regex !== void 0 && config.signature.regex !== null) lines.push(`${sigIndent}regex: ${formatString(config.signature.regex, q)},`);
80
- if (lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
81
- lines.push(`${algorithmIndent}},`);
82
- lines.push(`${algorithmIndent}signedComponents: [`);
83
- for (const component of config.signedComponents) {
84
- lines.push(`${sigIndent}{`);
85
- const compIndent = indentation.repeat(indentLevel + 3);
86
- lines.push(`${compIndent}source: ${formatString(component.source, q)},`);
87
- if (component.key !== void 0 && component.key !== null) lines.push(`${compIndent}key: ${formatString(component.key, q)},`);
88
- if (component.value !== void 0 && component.value !== null) lines.push(`${compIndent}value: ${formatString(component.value, q)},`);
89
- if (component.regex !== void 0 && component.regex !== null) lines.push(`${compIndent}regex: ${formatString(component.regex, q)},`);
90
- if (component.required !== void 0 && component.required !== null) lines.push(`${compIndent}required: ${component.required},`);
91
- if (lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
92
- lines.push(`${sigIndent}},`);
93
- }
94
- lines.push(`${algorithmIndent}],`);
95
- lines.push(`${algorithmIndent}componentJoin: {`);
96
- lines.push(`${sigIndent}strategy: ${formatString(config.componentJoin.strategy, q)},`);
97
- lines.push(`${sigIndent}separator: ${formatString(config.componentJoin.separator, q)}`);
98
- lines.push(`${algorithmIndent}},`);
99
- if (config.validation) {
100
- lines.push(`${algorithmIndent}validation: {`);
101
- if (config.validation.headerCaseSensitive !== void 0) lines.push(`${sigIndent}headerCaseSensitive: ${config.validation.headerCaseSensitive},`);
102
- if (config.validation.allowEmptyBody !== void 0) lines.push(`${sigIndent}allowEmptyBody: ${config.validation.allowEmptyBody},`);
103
- if (config.validation.normalizeUnicode !== void 0) lines.push(`${sigIndent}normalizeUnicode: ${config.validation.normalizeUnicode},`);
104
- if (lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
105
- lines.push(`${algorithmIndent}},`);
106
- }
107
- if (lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
108
- lines.push(`${indent}},`);
109
- return lines.join("\n");
110
- }
111
- /**
112
- * Generate Trigger Definition using Trigger class
113
- */
114
- function generateTriggerDefinition(triggerId, triggerData, style = DEFAULT_STYLE, registry) {
115
- if (!triggerId || typeof triggerId !== "string") throw new Error("triggerId is required and must be a string");
116
- if (!triggerData || typeof triggerData !== "object") throw new Error(`triggerData is required for trigger '${triggerId}'`);
117
- const missingFields = ["name", "messageTemplate"].filter((field) => !triggerData[field] || triggerData[field] === null || triggerData[field] === void 0);
118
- if (missingFields.length > 0) throw new Error(`Missing required fields for trigger '${triggerId}': ${missingFields.join(", ")}`);
119
- const { quotes, semicolons, indentation } = style;
120
- const q = quotes === "single" ? "'" : "\"";
121
- const semi = semicolons ? ";" : "";
122
- const triggerVarName = toCamelCase(triggerId);
123
- const lines = [];
124
- lines.push(`export const ${triggerVarName} = new Trigger({`);
125
- lines.push(`${indentation}id: ${formatString(triggerId, q)},`);
126
- lines.push(`${indentation}name: ${formatString(triggerData.name, q)},`);
127
- if (triggerData.description) lines.push(`${indentation}description: ${formatString(triggerData.description, q, true)},`);
128
- if (triggerData.enabled !== void 0 && triggerData.enabled !== null) lines.push(`${indentation}enabled: ${triggerData.enabled},`);
129
- lines.push(`${indentation}messageTemplate: ${formatString(triggerData.messageTemplate, q, true)},`);
130
- if (triggerData.inputSchema) {
131
- const formattedSchema = JSON.stringify(triggerData.inputSchema, null, 2).split("\n").map((line, index) => {
132
- if (index === 0) return `${indentation}inputSchema: ${line}`;
133
- return `${indentation}${line}`;
134
- }).join("\n");
135
- lines.push(`${formattedSchema},`);
136
- }
137
- if (triggerData.outputTransform) {
138
- const outputTransformFormatted = formatOutputTransform(triggerData.outputTransform, style, 1);
139
- if (outputTransformFormatted) lines.push(outputTransformFormatted);
140
- }
141
- if (triggerData.authentication) {
142
- const authFormatted = formatAuthentication(triggerData.authentication, style, 1);
143
- if (authFormatted) lines.push(authFormatted);
144
- }
145
- if (triggerData.signatureVerification) {
146
- const sigVerificationFormatted = formatSignatureVerification(triggerData.signatureVerification, style, 1);
147
- if (sigVerificationFormatted) lines.push(sigVerificationFormatted);
148
- }
149
- if (triggerData.signingSecretCredentialReferenceId) {
150
- if (!registry) throw new Error("Registry is required for signingSecretCredentialReferenceId generation");
151
- const credentialVar = registry.getVariableName(triggerData.signingSecretCredentialReferenceId, "credentials");
152
- if (!credentialVar) throw new Error(`Failed to resolve variable name for credential reference: ${triggerData.signingSecretCredentialReferenceId}`);
153
- lines.push(`${indentation}signingSecretCredentialReference: ${credentialVar},`);
154
- }
155
- if (lines.length > 0 && lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
156
- lines.push(`})${semi}`);
157
- return lines.join("\n");
158
- }
159
- /**
160
- * Generate imports needed for a trigger file
161
- */
162
- function generateTriggerImports(triggerId, triggerData, style = DEFAULT_STYLE, registry) {
163
- const imports = [];
164
- imports.push(generateImport(["Trigger"], "@inkeep/agents-sdk", style));
165
- if (triggerData.signingSecretCredentialReferenceId && typeof triggerData.signingSecretCredentialReferenceId === "string") {
166
- if (!registry) throw new Error("Registry is required for credential reference imports");
167
- const currentFilePath = `agents/triggers/${triggerId}.ts`;
168
- const credentialRefs = [{
169
- id: triggerData.signingSecretCredentialReferenceId,
170
- type: "credentials"
171
- }];
172
- const componentImports = registry.getImportsForFile(currentFilePath, credentialRefs);
173
- imports.push(...componentImports);
174
- }
175
- return imports;
176
- }
177
- /**
178
- * Generate complete trigger file (imports + definition)
179
- */
180
- function generateTriggerFile(triggerId, triggerData, style = DEFAULT_STYLE, registry) {
181
- return generateFileContent(generateTriggerImports(triggerId, triggerData, style, registry), [generateTriggerDefinition(triggerId, triggerData, style, registry)]);
182
- }
183
-
184
- //#endregion
185
- export { generateTriggerDefinition, generateTriggerFile, generateTriggerImports };