@inkeep/agents-cli 0.51.0 → 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,89 +0,0 @@
1
- //#region src/commands/pull-v3/components/credential-generator.ts
2
- const DEFAULT_STYLE = {
3
- quotes: "single",
4
- semicolons: true,
5
- indentation: " "
6
- };
7
- /**
8
- * Utility functions
9
- */
10
- function toCamelCase(str) {
11
- return str.toLowerCase().replace(/[-_](.)/g, (_, char) => char.toUpperCase()).replace(/[^a-zA-Z0-9]/g, "").replace(/^[0-9]/, "_$&");
12
- }
13
- function formatString(str, quote = "'", multiline = false) {
14
- if (!str) return `${quote}${quote}`;
15
- if (multiline && (str.includes("\n") || str.length > 80)) return `\`${str.replace(/`/g, "\\`")}\``;
16
- return `${quote}${str.replace(new RegExp(quote, "g"), `\\${quote}`)}${quote}`;
17
- }
18
- /**
19
- * Format retrieval params object
20
- */
21
- function formatRetrievalParams(retrievalParams, style, indentLevel) {
22
- if (!retrievalParams || typeof retrievalParams !== "object") return "{}";
23
- const { quotes, indentation } = style;
24
- const q = quotes === "single" ? "'" : "\"";
25
- const baseIndent = indentation.repeat(indentLevel);
26
- const indent = indentation.repeat(indentLevel + 1);
27
- const lines = ["{"];
28
- for (const [key, value] of Object.entries(retrievalParams)) {
29
- const formattedKey = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? key : `${q}${key}${q}`;
30
- if (typeof value === "string") lines.push(`${indent}${formattedKey}: ${formatString(value, q)},`);
31
- else if (typeof value === "number" || typeof value === "boolean") lines.push(`${indent}${formattedKey}: ${JSON.stringify(value)},`);
32
- else if (typeof value === "object" && value !== null) lines.push(`${indent}${formattedKey}: ${formatRetrievalParams(value, style, indentLevel + 1)},`);
33
- }
34
- if (lines.length > 1 && lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
35
- lines.push(`${baseIndent}}`);
36
- return lines.join("\n");
37
- }
38
- /**
39
- * Generate Credential Definition using credential() builder function
40
- */
41
- function generateCredentialDefinition(credentialId, credentialData, style = DEFAULT_STYLE) {
42
- const { quotes, semicolons, indentation } = style;
43
- const q = quotes === "single" ? "'" : "\"";
44
- const semi = semicolons ? ";" : "";
45
- const credentialVarName = toCamelCase(credentialId);
46
- const lines = [];
47
- lines.push(`export const ${credentialVarName} = credential({`);
48
- lines.push(`${indentation}id: ${formatString(credentialId, q)},`);
49
- const missingFields = [
50
- "name",
51
- "type",
52
- "credentialStoreId"
53
- ].filter((field) => !credentialData[field] || credentialData[field] === null || credentialData[field] === void 0);
54
- if (missingFields.length > 0) throw new Error(`Missing required fields for credential '${credentialId}': ${missingFields.join(", ")}`);
55
- lines.push(`${indentation}name: ${formatString(credentialData.name, q)},`);
56
- lines.push(`${indentation}type: ${formatString(credentialData.type, q)},`);
57
- lines.push(`${indentation}credentialStoreId: ${formatString(credentialData.credentialStoreId, q)},`);
58
- if (credentialData.description) lines.push(`${indentation}description: ${formatString(credentialData.description, q, true)},`);
59
- if (credentialData.retrievalParams) {
60
- const formattedParams = formatRetrievalParams(credentialData.retrievalParams, style, 1);
61
- if (formattedParams.includes("\n")) lines.push(`${indentation}retrievalParams: ${formattedParams},`);
62
- else lines.push(`${indentation}retrievalParams: ${formattedParams},`);
63
- }
64
- if (lines.length > 0 && lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
65
- lines.push(`})${semi}`);
66
- return lines.join("\n");
67
- }
68
- /**
69
- * Generate imports needed for a credential file
70
- */
71
- function generateCredentialImports(style = DEFAULT_STYLE) {
72
- const { quotes, semicolons } = style;
73
- const q = quotes === "single" ? "'" : "\"";
74
- const semi = semicolons ? ";" : "";
75
- const imports = [];
76
- imports.push(`import { credential } from ${q}@inkeep/agents-sdk${q}${semi}`);
77
- return imports;
78
- }
79
- /**
80
- * Generate complete credential file (imports + definition)
81
- */
82
- function generateCredentialFile(credentialId, credentialData, style = DEFAULT_STYLE) {
83
- const imports = generateCredentialImports(style);
84
- const definition = generateCredentialDefinition(credentialId, credentialData, style);
85
- return `${imports.join("\n")}\n\n${definition}\n`;
86
- }
87
-
88
- //#endregion
89
- export { generateCredentialDefinition, generateCredentialFile, generateCredentialImports };
@@ -1,102 +0,0 @@
1
- import { jsonSchemaToZod } from "json-schema-to-zod";
2
-
3
- //#region src/commands/pull-v3/components/data-component-generator.ts
4
- /**
5
- * Data Component Generator - Generate data component definitions
6
- *
7
- * Generates data components using the dataComponent() builder function from @inkeep/agents-sdk
8
- */
9
- const DEFAULT_STYLE = {
10
- quotes: "single",
11
- semicolons: true,
12
- indentation: " "
13
- };
14
- /**
15
- * Utility functions
16
- */
17
- function toCamelCase(str) {
18
- return str.toLowerCase().replace(/[-_](.)/g, (_, char) => char.toUpperCase()).replace(/[^a-zA-Z0-9]/g, "").replace(/^[0-9]/, "_$&");
19
- }
20
- function formatString(str, quote = "'", multiline = false) {
21
- if (!str) return `${quote}${quote}`;
22
- if (multiline && (str.includes("\n") || str.length > 80)) return `\`${str.replace(/`/g, "\\`")}\``;
23
- return `${quote}${str.replace(new RegExp(quote, "g"), `\\${quote}`)}${quote}`;
24
- }
25
- /**
26
- * Convert JSON Schema to Zod schema using existing utility
27
- */
28
- function convertJsonSchemaToZod(schema) {
29
- if (!schema || typeof schema !== "object") return "z.any()";
30
- try {
31
- return jsonSchemaToZod(schema);
32
- } catch (error) {
33
- console.warn("Failed to convert JSON schema to Zod:", error);
34
- return "z.any()";
35
- }
36
- }
37
- /**
38
- * Generate Data Component Definition using dataComponent() builder function
39
- */
40
- function generateDataComponentDefinition(componentId, componentData, style = DEFAULT_STYLE) {
41
- if (!componentId || typeof componentId !== "string") throw new Error("componentId is required and must be a string");
42
- if (!componentData || typeof componentData !== "object") throw new Error(`componentData is required for data component '${componentId}'`);
43
- const missingFields = ["name"].filter((field) => !componentData[field] || componentData[field] === null || componentData[field] === void 0);
44
- if (!componentData.props) missingFields.push("props");
45
- if (missingFields.length > 0) throw new Error(`Missing required fields for data component '${componentId}': ${missingFields.join(", ")}`);
46
- const { quotes, semicolons, indentation } = style;
47
- const q = quotes === "single" ? "'" : "\"";
48
- const semi = semicolons ? ";" : "";
49
- const componentVarName = toCamelCase(componentId);
50
- const lines = [];
51
- lines.push(`export const ${componentVarName} = dataComponent({`);
52
- lines.push(`${indentation}id: ${formatString(componentId, q)},`);
53
- lines.push(`${indentation}name: ${formatString(componentData.name, q)},`);
54
- lines.push(`${indentation}description: ${formatString(componentData.description, q, true)},`);
55
- const schema = componentData.props || componentData.schema;
56
- if (schema) {
57
- const zodSchema = convertJsonSchemaToZod(schema);
58
- lines.push(`${indentation}props: ${zodSchema},`);
59
- }
60
- if (componentData.render && typeof componentData.render === "object") {
61
- const render = componentData.render;
62
- if (render.component && typeof render.component === "string") {
63
- lines.push(`${indentation}render: {`);
64
- const componentString = JSON.stringify(render.component);
65
- lines.push(`${indentation}${indentation}component: ${componentString},`);
66
- if (render.mockData && typeof render.mockData === "object") {
67
- const formattedMockData = JSON.stringify(render.mockData, null, 2).split("\n").map((line, index) => {
68
- if (index === 0) return line;
69
- return `${indentation}${indentation}${line}`;
70
- }).join("\n");
71
- lines.push(`${indentation}${indentation}mockData: ${formattedMockData},`);
72
- }
73
- lines.push(`${indentation}},`);
74
- }
75
- }
76
- if (lines.length > 0 && lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
77
- lines.push(`})${semi}`);
78
- return lines.join("\n");
79
- }
80
- /**
81
- * Generate imports needed for a data component file
82
- */
83
- function generateDataComponentImports(componentData, style = DEFAULT_STYLE) {
84
- const { quotes, semicolons } = style;
85
- const q = quotes === "single" ? "'" : "\"";
86
- const semi = semicolons ? ";" : "";
87
- const imports = [];
88
- imports.push(`import { dataComponent } from ${q}@inkeep/agents-sdk${q}${semi}`);
89
- if (componentData.props || componentData.schema) imports.push(`import { z } from ${q}zod${q}${semi}`);
90
- return imports;
91
- }
92
- /**
93
- * Generate complete data component file (imports + definition)
94
- */
95
- function generateDataComponentFile(componentId, componentData, style = DEFAULT_STYLE) {
96
- const imports = generateDataComponentImports(componentData, style);
97
- const definition = generateDataComponentDefinition(componentId, componentData, style);
98
- return `${imports.join("\n")}\n\n${definition}\n`;
99
- }
100
-
101
- //#endregion
102
- export { generateDataComponentDefinition, generateDataComponentFile, generateDataComponentImports };
@@ -1,173 +0,0 @@
1
- //#region src/commands/pull-v3/components/environment-generator.ts
2
- const DEFAULT_STYLE = {
3
- quotes: "single",
4
- semicolons: true,
5
- indentation: " "
6
- };
7
- /**
8
- * Utility functions
9
- */
10
- function formatString(str, quote = "'", multiline = false) {
11
- if (!str) return `${quote}${quote}`;
12
- if (multiline && (str.includes("\n") || str.length > 80)) return `\`${str.replace(/`/g, "\\`")}\``;
13
- return `${quote}${str.replace(new RegExp(quote, "g"), `\\${quote}`)}${quote}`;
14
- }
15
- /**
16
- * Format credentials object for environment settings
17
- */
18
- function formatCredentialsObject(credentials, style, indentLevel) {
19
- if (!credentials || typeof credentials !== "object") return "{}";
20
- const { quotes, indentation } = style;
21
- const q = quotes === "single" ? "'" : "\"";
22
- const baseIndent = indentation.repeat(indentLevel);
23
- const indent = indentation.repeat(indentLevel + 1);
24
- const nestedIndent = indentation.repeat(indentLevel + 2);
25
- const lines = ["{"];
26
- for (const [key, credentialData] of Object.entries(credentials)) {
27
- lines.push(`${indent}${formatString(key, q)}: {`);
28
- if (credentialData.id) lines.push(`${nestedIndent}id: ${formatString(credentialData.id, q)},`);
29
- if (credentialData.name) lines.push(`${nestedIndent}name: ${formatString(credentialData.name, q)},`);
30
- if (credentialData.type) if (typeof credentialData.type === "string") {
31
- const enumValue = credentialData.type === "memory" ? "CredentialStoreType.memory" : credentialData.type === "env" ? "CredentialStoreType.env" : credentialData.type === "keychain" ? "CredentialStoreType.keychain" : formatString(credentialData.type, q);
32
- lines.push(`${nestedIndent}type: ${enumValue},`);
33
- } else lines.push(`${nestedIndent}type: ${credentialData.type},`);
34
- if (credentialData.credentialStoreId) lines.push(`${nestedIndent}credentialStoreId: ${formatString(credentialData.credentialStoreId, q)},`);
35
- if (credentialData.description) lines.push(`${nestedIndent}description: ${formatString(credentialData.description, q)},`);
36
- if (credentialData.retrievalParams) {
37
- lines.push(`${nestedIndent}retrievalParams: {`);
38
- for (const [paramKey, paramValue] of Object.entries(credentialData.retrievalParams)) {
39
- if (paramValue === null || paramValue === void 0) continue;
40
- if (typeof paramValue === "string") lines.push(`${nestedIndent}${indent}${paramKey}: ${formatString(paramValue, q)},`);
41
- else lines.push(`${nestedIndent}${indent}${paramKey}: ${JSON.stringify(paramValue)},`);
42
- }
43
- const lastLineIndex = lines.length - 1;
44
- if (lines[lastLineIndex].endsWith(",")) lines[lastLineIndex] = lines[lastLineIndex].slice(0, -1);
45
- lines.push(`${nestedIndent}},`);
46
- }
47
- const lastPropIndex = lines.length - 1;
48
- if (lines[lastPropIndex].endsWith(",")) lines[lastPropIndex] = lines[lastPropIndex].slice(0, -1);
49
- lines.push(`${indent}},`);
50
- }
51
- if (lines.length > 1 && lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
52
- lines.push(`${baseIndent}}`);
53
- return lines.join("\n");
54
- }
55
- /**
56
- * Generate Individual Environment Settings Definition (development.env.ts, production.env.ts)
57
- */
58
- function generateEnvironmentSettingsDefinition(environmentName, environmentData, style = DEFAULT_STYLE) {
59
- if (!environmentName || typeof environmentName !== "string") throw new Error("environmentName is required and must be a string");
60
- if (!environmentData || typeof environmentData !== "object") throw new Error(`environmentData is required for environment '${environmentName}'`);
61
- const { semicolons, indentation } = style;
62
- const semi = semicolons ? ";" : "";
63
- const lines = [];
64
- lines.push(`export const ${environmentName} = registerEnvironmentSettings({`);
65
- if (environmentData.credentials && Object.keys(environmentData.credentials).length > 0) {
66
- const formattedCredentials = formatCredentialsObject(environmentData.credentials, style, 1);
67
- lines.push(`${indentation}credentials: ${formattedCredentials},`);
68
- } else lines.push(`${indentation}credentials: {},`);
69
- if (lines.length > 1 && lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
70
- lines.push(`})${semi}`);
71
- return lines.join("\n");
72
- }
73
- /**
74
- * Generate Main Environment Settings Index (index.ts)
75
- */
76
- function generateEnvironmentIndexDefinition(environments, style = DEFAULT_STYLE) {
77
- const { semicolons, indentation } = style;
78
- const semi = semicolons ? ";" : "";
79
- const lines = [];
80
- lines.push(`export const envSettings = createEnvironmentSettings({`);
81
- for (const envName of environments) lines.push(`${indentation}${envName},`);
82
- if (lines.length > 1 && lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
83
- lines.push(`})${semi}`);
84
- return lines.join("\n");
85
- }
86
- /**
87
- * Generate imports for individual environment settings file
88
- */
89
- function generateEnvironmentSettingsImports(environmentData, style = DEFAULT_STYLE) {
90
- const { quotes, semicolons } = style;
91
- const q = quotes === "single" ? "'" : "\"";
92
- const semi = semicolons ? ";" : "";
93
- const imports = [];
94
- imports.push(`import { registerEnvironmentSettings } from ${q}@inkeep/agents-sdk${q}${semi}`);
95
- if (environmentData.credentials && Object.values(environmentData.credentials).some((cred) => typeof cred.type === "string" && [
96
- "memory",
97
- "env",
98
- "keychain"
99
- ].includes(cred.type))) imports.push(`import { CredentialStoreType } from ${q}@inkeep/agents-core${q}${semi}`);
100
- return imports;
101
- }
102
- /**
103
- * Generate imports for main environment index file
104
- */
105
- function generateEnvironmentIndexImports(environments, style = DEFAULT_STYLE) {
106
- const { quotes, semicolons } = style;
107
- const q = quotes === "single" ? "'" : "\"";
108
- const semi = semicolons ? ";" : "";
109
- const imports = [];
110
- imports.push(`import { createEnvironmentSettings } from ${q}@inkeep/agents-sdk${q}${semi}`);
111
- for (const envName of environments) imports.push(`import { ${envName} } from ${q}./${envName}.env${q}${semi}`);
112
- return imports;
113
- }
114
- /**
115
- * Generate complete environment settings file
116
- */
117
- function generateEnvironmentSettingsFile(environmentName, environmentData, style = DEFAULT_STYLE) {
118
- const imports = generateEnvironmentSettingsImports(environmentData, style);
119
- const definition = generateEnvironmentSettingsDefinition(environmentName, environmentData, style);
120
- return `${imports.join("\n")}\n\n${definition}\n`;
121
- }
122
- /**
123
- * Generate complete environment index file
124
- */
125
- function generateEnvironmentIndexFile(environments, style = DEFAULT_STYLE) {
126
- const imports = generateEnvironmentIndexImports(environments, style);
127
- const definition = generateEnvironmentIndexDefinition(environments, style);
128
- return `${imports.join("\n")}\n\n${definition}\n`;
129
- }
130
- /**
131
- * Generate environment file (alias for generateEnvironmentSettingsFile)
132
- * This is the main function used by introspect-generator
133
- */
134
- function generateEnvironmentFile(environmentName, environmentData, style = DEFAULT_STYLE, registry) {
135
- if (registry && environmentData.credentials && Array.isArray(environmentData.credentials)) {
136
- const { quotes, semicolons, indentation } = style;
137
- const q = quotes === "single" ? "'" : "\"";
138
- const semi = semicolons ? ";" : "";
139
- const imports = [];
140
- const credentialRefs = [];
141
- imports.push(`import { registerEnvironmentSettings } from ${q}@inkeep/agents-sdk${q}${semi}`);
142
- for (const credentialId of environmentData.credentials) {
143
- const credentialComponent = registry.get(credentialId, "credentials");
144
- if (credentialComponent) {
145
- const relativePath = `../credentials/${credentialId}`;
146
- imports.push(`import { ${credentialComponent.name} } from ${q}${relativePath}${q}${semi}`);
147
- credentialRefs.push(credentialComponent.name);
148
- }
149
- }
150
- const lines = [];
151
- lines.push(...imports);
152
- lines.push("");
153
- lines.push(`export const ${environmentName} = registerEnvironmentSettings({`);
154
- if (credentialRefs.length > 0) {
155
- lines.push(`${indentation}credentials: {`);
156
- for (let i = 0; i < environmentData.credentials.length; i++) {
157
- const credentialId = environmentData.credentials[i];
158
- const credentialVarName = credentialRefs[i];
159
- const isLast = i === credentialRefs.length - 1;
160
- const validKey = registry.getVariableName(credentialId, "credentials");
161
- lines.push(`${indentation}${indentation}${validKey}: ${credentialVarName}${isLast ? "" : ","}`);
162
- }
163
- lines.push(`${indentation}}`);
164
- } else lines.push(`${indentation}credentials: {}`);
165
- lines.push(`})${semi}`);
166
- lines.push("");
167
- return lines.join("\n");
168
- }
169
- return generateEnvironmentSettingsFile(environmentName, environmentData, style);
170
- }
171
-
172
- //#endregion
173
- export { generateEnvironmentFile, generateEnvironmentIndexDefinition, generateEnvironmentIndexFile, generateEnvironmentIndexImports, generateEnvironmentSettingsDefinition, generateEnvironmentSettingsFile, generateEnvironmentSettingsImports };
@@ -1,75 +0,0 @@
1
- import { DEFAULT_STYLE, formatString, generateFileContent, generateImport, removeTrailingComma, toCamelCase } from "../utils/generator-utils.js";
2
-
3
- //#region src/commands/pull-v3/components/external-agent-generator.ts
4
- /**
5
- * Generate External Agent Definition using externalAgent() builder function
6
- */
7
- function generateExternalAgentDefinition(agentId, agentData, style = DEFAULT_STYLE, registry) {
8
- if (!agentId || typeof agentId !== "string") throw new Error("agentId is required and must be a string");
9
- if (!agentData || typeof agentData !== "object") throw new Error(`agentData is required for external agent '${agentId}'`);
10
- const missingFields = ["name", "baseUrl"].filter((field) => !agentData[field] || agentData[field] === null || agentData[field] === void 0);
11
- if (missingFields.length > 0) throw new Error(`Missing required fields for external agent '${agentId}': ${missingFields.join(", ")}`);
12
- const { quotes, semicolons, indentation } = style;
13
- const q = quotes === "single" ? "'" : "\"";
14
- const semi = semicolons ? ";" : "";
15
- let agentVarName = toCamelCase(agentId);
16
- if (registry) {
17
- const registryVarName = registry.getVariableName(agentId, "externalAgents");
18
- if (registryVarName) agentVarName = registryVarName;
19
- }
20
- const lines = [];
21
- lines.push(`export const ${agentVarName} = externalAgent({`);
22
- lines.push(`${indentation}id: ${formatString(agentId, q)},`);
23
- if (agentData.name !== void 0 && agentData.name !== null) lines.push(`${indentation}name: ${formatString(agentData.name, q)},`);
24
- else lines.push(`${indentation}name: ${formatString(agentId, q)},`);
25
- if (agentData.description !== void 0 && agentData.description !== null) lines.push(`${indentation}description: ${formatString(agentData.description, q, true)},`);
26
- else lines.push(`${indentation}description: ${formatString(`External agent ${agentId}`, q)},`);
27
- if (agentData.baseUrl !== void 0 && agentData.baseUrl !== null) lines.push(`${indentation}baseUrl: ${formatString(agentData.baseUrl, q)},`);
28
- if (agentData.credentialReference) {
29
- if (typeof agentData.credentialReference === "string") {
30
- if (!registry) throw new Error("Registry is required for credentialReference generation");
31
- const credentialVar = registry.getVariableName(agentData.credentialReference, "credentials");
32
- if (!credentialVar) throw new Error(`Failed to resolve variable name for credential reference: ${agentData.credentialReference}`);
33
- lines.push(`${indentation}credentialReference: ${credentialVar},`);
34
- } else if (typeof agentData.credentialReference === "object") {
35
- const credLines = [];
36
- if (agentData.credentialReference.id) credLines.push(`${indentation}${indentation}id: ${formatString(agentData.credentialReference.id, q)},`);
37
- if (agentData.credentialReference.name) credLines.push(`${indentation}${indentation}name: ${formatString(agentData.credentialReference.name, q)},`);
38
- if (agentData.credentialReference.description) credLines.push(`${indentation}${indentation}description: ${formatString(agentData.credentialReference.description, q)},`);
39
- if (credLines.length > 0 && credLines[credLines.length - 1].endsWith(",")) credLines[credLines.length - 1] = credLines[credLines.length - 1].slice(0, -1);
40
- lines.push(`${indentation}credentialReference: {`);
41
- lines.push(...credLines);
42
- lines.push(`${indentation}},`);
43
- }
44
- }
45
- removeTrailingComma(lines);
46
- lines.push(`})${semi}`);
47
- return lines.join("\n");
48
- }
49
- /**
50
- * Generate imports needed for an external agent file
51
- */
52
- function generateExternalAgentImports(agentId, agentData, style = DEFAULT_STYLE, registry) {
53
- const imports = [];
54
- imports.push(generateImport(["externalAgent"], "@inkeep/agents-sdk", style));
55
- if (agentData.credentialReference && typeof agentData.credentialReference === "string") {
56
- if (!registry) throw new Error("Registry is required for credential reference imports");
57
- const currentFilePath = `external-agents/${agentId}.ts`;
58
- const credentialRefs = [{
59
- id: agentData.credentialReference,
60
- type: "credentials"
61
- }];
62
- const componentImports = registry.getImportsForFile(currentFilePath, credentialRefs);
63
- imports.push(...componentImports);
64
- }
65
- return imports;
66
- }
67
- /**
68
- * Generate complete external agent file (imports + definition)
69
- */
70
- function generateExternalAgentFile(agentId, agentData, style = DEFAULT_STYLE, registry) {
71
- return generateFileContent(generateExternalAgentImports(agentId, agentData, style, registry), [generateExternalAgentDefinition(agentId, agentData, style, registry)]);
72
- }
73
-
74
- //#endregion
75
- export { generateExternalAgentDefinition, generateExternalAgentFile, generateExternalAgentImports };
@@ -1,92 +0,0 @@
1
- //#region src/commands/pull-v3/components/function-tool-generator.ts
2
- const DEFAULT_STYLE = {
3
- quotes: "single",
4
- semicolons: true,
5
- indentation: " "
6
- };
7
- /**
8
- * Utility functions
9
- */
10
- function toCamelCase(str) {
11
- return str.toLowerCase().replace(/[-_](.)/g, (_, char) => char.toUpperCase()).replace(/[^a-zA-Z0-9]/g, "").replace(/^[0-9]/, "_$&");
12
- }
13
- function formatString(str, quote = "'", multiline = false) {
14
- if (!str) return `${quote}${quote}`;
15
- if (multiline && (str.includes("\n") || str.length > 80)) return `\`${str.replace(/`/g, "\\`")}\``;
16
- return `${quote}${str.replace(new RegExp(quote, "g"), `\\${quote}`)}${quote}`;
17
- }
18
- /**
19
- * Format JavaScript function code with proper indentation
20
- */
21
- function formatExecuteFunction(executeCode, indentation) {
22
- if (!executeCode || typeof executeCode !== "string") return `async ({}) => {\n${indentation} // TODO: Implement function logic\n${indentation} return {};\n${indentation}}`;
23
- const trimmedCode = executeCode.trim();
24
- if (trimmedCode.includes("\n")) return trimmedCode.split("\n").map((line, index) => {
25
- if (index === 0) return line;
26
- return indentation + line;
27
- }).join("\n");
28
- if (trimmedCode.startsWith("async") || trimmedCode.startsWith("function")) return trimmedCode;
29
- return `async ({}) => {\n${indentation} ${executeCode.replace(/\n/g, `\n${indentation} `)}\n${indentation}}`;
30
- }
31
- /**
32
- * Generate Function Tool Definition using functionTool() builder function
33
- */
34
- function generateFunctionToolDefinition(toolId, toolData, style = DEFAULT_STYLE) {
35
- if (!toolId || typeof toolId !== "string") throw new Error("toolId is required and must be a string");
36
- if (!toolData || typeof toolData !== "object") throw new Error(`toolData is required for function tool '${toolId}'`);
37
- const missingFields = ["name"].filter((field) => !toolData[field] || toolData[field] === null || toolData[field] === void 0);
38
- if (!toolData.inputSchema && !toolData.schema) missingFields.push("inputSchema");
39
- if (!toolData.executeCode && !toolData.execute) missingFields.push("executeCode");
40
- if (missingFields.length > 0) throw new Error(`Missing required fields for function tool '${toolId}': ${missingFields.join(", ")}`);
41
- const { quotes, semicolons, indentation } = style;
42
- const q = quotes === "single" ? "'" : "\"";
43
- const semi = semicolons ? ";" : "";
44
- const toolVarName = toCamelCase(toolId);
45
- const lines = [];
46
- lines.push(`export const ${toolVarName} = functionTool({`);
47
- lines.push(`${indentation}name: ${formatString(toolData.name, q)},`);
48
- if (toolData.description) lines.push(`${indentation}description: ${formatString(toolData.description, q, true)},`);
49
- const inputSchema = toolData.inputSchema || toolData.schema;
50
- if (inputSchema) {
51
- const formattedSchema = JSON.stringify(inputSchema, null, 2).split("\n").map((line, index) => {
52
- if (index === 0) return `${indentation}inputSchema: ${line}`;
53
- return `${indentation}${line}`;
54
- }).join("\n");
55
- lines.push(`${formattedSchema},`);
56
- }
57
- const executeCode = toolData.executeCode || toolData.execute;
58
- if (executeCode) {
59
- const executeFunc = formatExecuteFunction(executeCode, indentation);
60
- lines.push(`${indentation}execute: ${executeFunc},`);
61
- } else {
62
- lines.push(`${indentation}execute: async ({}) => {`);
63
- lines.push(`${indentation} // TODO: Implement function logic`);
64
- lines.push(`${indentation} return {};`);
65
- lines.push(`${indentation}},`);
66
- }
67
- if (lines.length > 0 && lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
68
- lines.push(`})${semi}`);
69
- return lines.join("\n");
70
- }
71
- /**
72
- * Generate imports needed for a function tool file
73
- */
74
- function generateFunctionToolImports(style = DEFAULT_STYLE) {
75
- const { quotes, semicolons } = style;
76
- const q = quotes === "single" ? "'" : "\"";
77
- const semi = semicolons ? ";" : "";
78
- const imports = [];
79
- imports.push(`import { functionTool } from ${q}@inkeep/agents-sdk${q}${semi}`);
80
- return imports;
81
- }
82
- /**
83
- * Generate complete function tool file (imports + definition)
84
- */
85
- function generateFunctionToolFile(toolId, toolData, style = DEFAULT_STYLE) {
86
- const imports = generateFunctionToolImports(style);
87
- const definition = generateFunctionToolDefinition(toolId, toolData, style);
88
- return `${imports.join("\n")}\n\n${definition}\n`;
89
- }
90
-
91
- //#endregion
92
- export { generateFunctionToolDefinition, generateFunctionToolFile, generateFunctionToolImports };
@@ -1,86 +0,0 @@
1
- //#region src/commands/pull-v3/components/mcp-tool-generator.ts
2
- const DEFAULT_STYLE = {
3
- quotes: "single",
4
- semicolons: true,
5
- indentation: " "
6
- };
7
- /**
8
- * Utility functions
9
- */
10
- function toCamelCase(str) {
11
- return str.toLowerCase().replace(/[-_](.)/g, (_, char) => char.toUpperCase()).replace(/[^a-zA-Z0-9]/g, "").replace(/^[0-9]/, "_$&");
12
- }
13
- function formatString(str, quote = "'", multiline = false) {
14
- if (!str) return `${quote}${quote}`;
15
- if (multiline && (str.includes("\n") || str.length > 80)) return `\`${str.replace(/`/g, "\\`")}\``;
16
- return `${quote}${str.replace(new RegExp(quote, "g"), `\\${quote}`)}${quote}`;
17
- }
18
- /**
19
- * Generate MCP Tool Definition using mcpTool() builder function
20
- */
21
- function generateMcpToolDefinition(toolId, toolData, style = DEFAULT_STYLE, registry) {
22
- if (!toolId || typeof toolId !== "string") throw new Error("toolId is required and must be a string");
23
- if (!toolData || typeof toolData !== "object") throw new Error(`toolData is required for MCP tool '${toolId}'`);
24
- const requiredFields = ["name"];
25
- const serverUrl = toolData.config?.mcp?.server?.url || toolData.serverUrl;
26
- const missingFields = requiredFields.filter((field) => !toolData[field] || toolData[field] === null || toolData[field] === void 0);
27
- if (!serverUrl) missingFields.push("serverUrl (from config.mcp.server.url or serverUrl)");
28
- if (missingFields.length > 0) throw new Error(`Missing required fields for MCP tool '${toolId}': ${missingFields.join(", ")}`);
29
- const { quotes, semicolons, indentation } = style;
30
- const q = quotes === "single" ? "'" : "\"";
31
- const semi = semicolons ? ";" : "";
32
- const toolVarName = toCamelCase(toolId);
33
- const lines = [];
34
- lines.push(`export const ${toolVarName} = mcpTool({`);
35
- lines.push(`${indentation}id: ${formatString(toolId, q)},`);
36
- lines.push(`${indentation}name: ${formatString(toolData.name, q)},`);
37
- if (toolData.config?.mcp && typeof toolData.config.mcp === "object") {
38
- const mcpConfig = toolData.config.mcp;
39
- lines.push(`${indentation}serverUrl: ${formatString(mcpConfig.server?.url, q)},`);
40
- if (mcpConfig.transport) lines.push(`${indentation}transport: ${JSON.stringify(mcpConfig.transport, null, 2)},`);
41
- if (mcpConfig.activeTools && Array.isArray(mcpConfig.activeTools)) lines.push(`${indentation}activeTools: ${JSON.stringify(mcpConfig.activeTools)},`);
42
- }
43
- if (toolData.description) lines.push(`${indentation}description: ${formatString(toolData.description, q, true)},`);
44
- if (toolData.imageUrl) lines.push(`${indentation}imageUrl: ${formatString(toolData.imageUrl, q)},`);
45
- if (toolData.headers && typeof toolData.headers === "object") {
46
- const formattedHeaders = JSON.stringify(toolData.headers, null, 2).split("\n").map((line, index) => {
47
- if (index === 0) return `${indentation}headers: ${line}`;
48
- return `${indentation}${line}`;
49
- }).join("\n");
50
- lines.push(`${formattedHeaders},`);
51
- }
52
- if (toolData.credential) if (typeof toolData.credential === "object") {
53
- const credentialStr = JSON.stringify(toolData.credential);
54
- lines.push(`${indentation}credential: ${credentialStr},`);
55
- } else lines.push(`${indentation}credential: ${toolData.credential},`);
56
- else if (toolData.credentialReferenceId && registry) {
57
- const validKey = registry.getVariableName(toolData.credentialReferenceId, "credentials");
58
- lines.push(`${indentation}credential: envSettings.getEnvironmentCredential(${formatString(validKey, q)}),`);
59
- }
60
- if (lines.length > 0 && lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
61
- lines.push(`})${semi}`);
62
- return lines.join("\n");
63
- }
64
- /**
65
- * Generate imports needed for an MCP tool file
66
- */
67
- function generateMcpToolImports(toolData, style = DEFAULT_STYLE) {
68
- const { quotes, semicolons } = style;
69
- const q = quotes === "single" ? "'" : "\"";
70
- const semi = semicolons ? ";" : "";
71
- const imports = [];
72
- imports.push(`import { mcpTool } from ${q}@inkeep/agents-sdk${q}${semi}`);
73
- if (toolData.credentialReferenceId) imports.push(`import { envSettings } from ${q}../environments${q}${semi}`);
74
- return imports;
75
- }
76
- /**
77
- * Generate complete MCP tool file (imports + definition)
78
- */
79
- function generateMcpToolFile(toolId, toolData, style = DEFAULT_STYLE, registry) {
80
- const imports = generateMcpToolImports(toolData, style);
81
- const definition = generateMcpToolDefinition(toolId, toolData, style, registry);
82
- return `${imports.join("\n")}\n\n${definition}\n`;
83
- }
84
-
85
- //#endregion
86
- export { generateMcpToolDefinition, generateMcpToolFile, generateMcpToolImports };