@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
@@ -0,0 +1,168 @@
1
+ import { addReferenceGetterProperty, addStringProperty, addValueToObject, collectTemplateVariableNames, convertNullToUndefined, createFactoryDefinition, formatInlineLiteral, formatTemplate, hasReferences, isPlainObject, resolveReferenceName, toCamelCase } from "./utils.js";
2
+ import { FullAgentAgentInsertSchema } from "@inkeep/agents-core";
3
+ import { z } from "zod";
4
+ import { SyntaxKind } from "ts-morph";
5
+
6
+ //#region src/commands/pull-v4/sub-agent-generator.ts
7
+ const ReferenceNameByIdSchema = z.record(z.string(), z.string().nonempty());
8
+ const ReferenceOverridesSchema = z.object({
9
+ tools: ReferenceNameByIdSchema.optional(),
10
+ subAgents: ReferenceNameByIdSchema.optional(),
11
+ agents: ReferenceNameByIdSchema.optional(),
12
+ externalAgents: ReferenceNameByIdSchema.optional(),
13
+ dataComponents: ReferenceNameByIdSchema.optional(),
14
+ artifactComponents: ReferenceNameByIdSchema.optional()
15
+ });
16
+ const ContextTemplateReferenceSchema = z.object({
17
+ name: z.string().nonempty(),
18
+ local: z.boolean().optional()
19
+ });
20
+ const SubAgentSchema = FullAgentAgentInsertSchema.pick({
21
+ id: true,
22
+ description: true,
23
+ prompt: true
24
+ }).extend({
25
+ name: z.string().optional(),
26
+ stopWhen: z.preprocess(convertNullToUndefined, FullAgentAgentInsertSchema.shape.stopWhen),
27
+ models: z.preprocess(convertNullToUndefined, z.looseObject({}).optional()),
28
+ skills: z.array(z.unknown()).optional(),
29
+ canUse: z.array(z.unknown()).optional(),
30
+ canDelegateTo: z.array(z.unknown()).optional(),
31
+ canTransferTo: z.array(z.string()).optional(),
32
+ dataComponents: z.array(z.string()).optional(),
33
+ artifactComponents: z.array(z.string()).optional(),
34
+ referenceOverrides: ReferenceOverridesSchema.optional(),
35
+ contextConfigId: z.string().nonempty().optional(),
36
+ contextConfigReference: ContextTemplateReferenceSchema.optional(),
37
+ contextConfigHeadersReference: ContextTemplateReferenceSchema.optional()
38
+ });
39
+ function generateSubAgentDefinition(data) {
40
+ const result = SubAgentSchema.safeParse(data);
41
+ if (!result.success) throw new Error(`Validation failed for sub-agent:\n${z.prettifyError(result.error)}`);
42
+ const parsed = result.data;
43
+ const { sourceFile, configObject } = createFactoryDefinition({
44
+ importName: "subAgent",
45
+ variableName: toCamelCase(parsed.id)
46
+ });
47
+ const promptTemplateVariables = typeof parsed.prompt === "string" ? collectTemplateVariableNames(parsed.prompt) : [];
48
+ const hasContextTemplateVariables = promptTemplateVariables.some((variableName) => !variableName.startsWith("headers."));
49
+ const hasHeadersTemplateVariables = promptTemplateVariables.some((variableName) => variableName.startsWith("headers."));
50
+ const namedImports = [];
51
+ if (hasContextTemplateVariables && parsed.contextConfigId && parsed.contextConfigReference && parsed.contextConfigReference.local !== true) namedImports.push(parsed.contextConfigReference.name);
52
+ if (hasHeadersTemplateVariables && parsed.contextConfigId && parsed.contextConfigHeadersReference && parsed.contextConfigHeadersReference.local !== true) namedImports.push(parsed.contextConfigHeadersReference.name);
53
+ if (namedImports.length > 0 && parsed.contextConfigId) sourceFile.addImportDeclaration({
54
+ namedImports: [...new Set(namedImports)],
55
+ moduleSpecifier: `../context-configs/${parsed.contextConfigId}`
56
+ });
57
+ writeSubAgentConfig(configObject, {
58
+ contextReference: parsed.contextConfigReference?.name,
59
+ headersReference: parsed.contextConfigHeadersReference?.name
60
+ }, parsed);
61
+ return sourceFile;
62
+ }
63
+ function writeSubAgentConfig(configObject, templateReferences, { dataComponents, name, canDelegateTo, canTransferTo, skills, artifactComponents, canUse, referenceOverrides, contextConfigId: _contextConfigId, contextConfigReference: _contextConfigReference, contextConfigHeadersReference: _contextConfigHeadersReference, ...rest }) {
64
+ rest = { ...rest };
65
+ rest.prompt &&= formatTemplate(rest.prompt, templateReferences);
66
+ for (const [k, v] of Object.entries(rest)) addValueToObject(configObject, k, v);
67
+ addStringProperty(configObject, "name", resolveSubAgentName(rest.id, name));
68
+ const canUseReferences = collectCanUseReferences(canUse, referenceOverrides?.tools);
69
+ if (canUseReferences.length) addReferenceGetterProperty(configObject, "canUse", canUseReferences);
70
+ const canDelegateToReferences = collectCanDelegateToReferences(canDelegateTo, {
71
+ subAgents: referenceOverrides?.subAgents,
72
+ agents: referenceOverrides?.agents,
73
+ externalAgents: referenceOverrides?.externalAgents
74
+ });
75
+ if (canDelegateToReferences.length) addReferenceGetterProperty(configObject, "canDelegateTo", canDelegateToReferences);
76
+ if (hasReferences(canTransferTo)) addReferenceGetterProperty(configObject, "canTransferTo", canTransferTo.map((id) => resolveReferenceName(id, [
77
+ referenceOverrides?.subAgents,
78
+ referenceOverrides?.agents,
79
+ referenceOverrides?.externalAgents
80
+ ])));
81
+ if (hasReferences(dataComponents)) addReferenceGetterProperty(configObject, "dataComponents", dataComponents.map((id) => resolveReferenceName(id, [referenceOverrides?.dataComponents])));
82
+ if (hasReferences(artifactComponents)) addReferenceGetterProperty(configObject, "artifactComponents", artifactComponents.map((id) => resolveReferenceName(id, [referenceOverrides?.artifactComponents])));
83
+ const collectedSkills = collectSkills(skills);
84
+ if (collectedSkills.length > 0) {
85
+ const skillsArray = configObject.addPropertyAssignment({
86
+ name: "skills",
87
+ initializer: "() => []"
88
+ }).getInitializerIfKindOrThrow(SyntaxKind.ArrowFunction).getBody().asKindOrThrow(SyntaxKind.ArrayLiteralExpression);
89
+ for (const skill of collectedSkills) skillsArray.addElement(skill);
90
+ }
91
+ }
92
+ function resolveSubAgentName(subAgentId, name) {
93
+ if (name !== void 0) return name;
94
+ return subAgentId.replace(/[-_]/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (char) => char.toUpperCase());
95
+ }
96
+ function collectCanUseReferences(canUse, toolReferenceOverrides) {
97
+ if (!Array.isArray(canUse)) return [];
98
+ const references = [];
99
+ for (const item of canUse) {
100
+ if (typeof item === "string") {
101
+ references.push(resolveReferenceName(item, [toolReferenceOverrides]));
102
+ continue;
103
+ }
104
+ if (!isPlainObject(item)) continue;
105
+ const toolId = typeof item.toolId === "string" ? item.toolId : void 0;
106
+ if (!toolId) continue;
107
+ const toolReference = resolveReferenceName(toolId, [toolReferenceOverrides]);
108
+ const withConfig = {};
109
+ const selectedTools = Array.isArray(item.toolSelection) && item.toolSelection.length ? item.toolSelection : Array.isArray(item.selectedTools) && item.selectedTools.length ? item.selectedTools : void 0;
110
+ if (selectedTools) withConfig.selectedTools = selectedTools;
111
+ if (isPlainObject(item.headers) && Object.keys(item.headers).length) withConfig.headers = item.headers;
112
+ if (isPlainObject(item.toolPolicies) && Object.keys(item.toolPolicies).length) withConfig.toolPolicies = item.toolPolicies;
113
+ if (Object.keys(withConfig).length > 0) {
114
+ references.push(`${toolReference}.with(${formatInlineLiteral(withConfig)})`);
115
+ continue;
116
+ }
117
+ references.push(toolReference);
118
+ }
119
+ return references;
120
+ }
121
+ function collectCanDelegateToReferences(canDelegateTo, referenceOverrides) {
122
+ if (!Array.isArray(canDelegateTo)) return [];
123
+ const references = [];
124
+ for (const item of canDelegateTo) {
125
+ if (typeof item === "string") {
126
+ references.push(resolveReferenceName(item, [
127
+ referenceOverrides.subAgents,
128
+ referenceOverrides.agents,
129
+ referenceOverrides.externalAgents
130
+ ]));
131
+ continue;
132
+ }
133
+ if (!isPlainObject(item)) continue;
134
+ const subAgentId = typeof item.subAgentId === "string" ? item.subAgentId : void 0;
135
+ const agentId = typeof item.agentId === "string" ? item.agentId : void 0;
136
+ const externalAgentId = typeof item.externalAgentId === "string" ? item.externalAgentId : void 0;
137
+ const targetId = subAgentId || agentId || externalAgentId;
138
+ if (!targetId) continue;
139
+ const targetReference = subAgentId ? resolveReferenceName(subAgentId, [referenceOverrides.subAgents]) : agentId ? resolveReferenceName(agentId, [referenceOverrides.agents]) : resolveReferenceName(targetId, [referenceOverrides.externalAgents]);
140
+ if (isPlainObject(item.headers) && Object.keys(item.headers).length > 0) {
141
+ references.push(`${targetReference}.with(${formatInlineLiteral({ headers: item.headers })})`);
142
+ continue;
143
+ }
144
+ references.push(targetReference);
145
+ }
146
+ return references;
147
+ }
148
+ function collectSkills(skills) {
149
+ if (!Array.isArray(skills)) return [];
150
+ const formattedSkills = [];
151
+ for (const skill of skills) {
152
+ if (typeof skill === "string") {
153
+ formattedSkills.push(formatInlineLiteral(skill));
154
+ continue;
155
+ }
156
+ if (!isPlainObject(skill)) continue;
157
+ const skillId = typeof skill.id === "string" ? skill.id : typeof skill.skillId === "string" ? skill.skillId : void 0;
158
+ if (!skillId) continue;
159
+ const formattedSkill = { id: skillId };
160
+ if (typeof skill.index === "number" && Number.isInteger(skill.index)) formattedSkill.index = skill.index;
161
+ if (typeof skill.alwaysLoaded === "boolean") formattedSkill.alwaysLoaded = skill.alwaysLoaded;
162
+ formattedSkills.push(formatInlineLiteral(formattedSkill));
163
+ }
164
+ return formattedSkills;
165
+ }
166
+
167
+ //#endregion
168
+ export { generateSubAgentDefinition };
@@ -0,0 +1,58 @@
1
+ import { addValueToObject, createFactoryDefinition, toCamelCase } from "./utils.js";
2
+ import { z } from "zod";
3
+ import { SyntaxKind } from "ts-morph";
4
+
5
+ //#region src/commands/pull-v4/trigger-generator.ts
6
+ const TriggerSchema = z.looseObject({
7
+ triggerId: z.string().nonempty(),
8
+ name: z.string().nonempty(),
9
+ description: z.string().optional(),
10
+ enabled: z.boolean().optional(),
11
+ messageTemplate: z.string().nonempty(),
12
+ inputSchema: z.unknown().optional(),
13
+ outputTransform: z.looseObject({
14
+ jmespath: z.string().optional(),
15
+ objectTransformation: z.unknown().optional()
16
+ }).optional(),
17
+ authentication: z.looseObject({ headers: z.array(z.looseObject({})).optional() }).optional(),
18
+ signatureVerification: z.looseObject({
19
+ algorithm: z.string().optional(),
20
+ encoding: z.string().optional(),
21
+ signature: z.looseObject({}).optional(),
22
+ signedComponents: z.array(z.looseObject({})).optional(),
23
+ componentJoin: z.looseObject({}).optional(),
24
+ validation: z.looseObject({}).optional()
25
+ }).optional(),
26
+ signingSecretCredentialReferenceId: z.string().optional(),
27
+ signingSecretCredentialReference: z.union([z.string(), z.looseObject({ id: z.string().optional() })]).optional()
28
+ });
29
+ function generateTriggerDefinition(data) {
30
+ const result = TriggerSchema.safeParse(data);
31
+ if (!result.success) throw new Error(`Validation failed for trigger:\n${z.prettifyError(result.error)}`);
32
+ const parsed = result.data;
33
+ const { sourceFile, configObject } = createFactoryDefinition({
34
+ importName: "Trigger",
35
+ variableName: toCamelCase(parsed.triggerId),
36
+ syntaxKind: SyntaxKind.NewExpression
37
+ });
38
+ const { triggerId, signingSecretCredentialReferenceId, ...rest } = parsed;
39
+ for (const [key, value] of Object.entries({
40
+ id: triggerId,
41
+ ...rest
42
+ })) addValueToObject(configObject, key, value);
43
+ if (signingSecretCredentialReferenceId) {
44
+ const varName = toCamelCase(signingSecretCredentialReferenceId);
45
+ sourceFile.addImportDeclaration({
46
+ namedImports: [varName],
47
+ moduleSpecifier: `../../credentials/${signingSecretCredentialReferenceId}`
48
+ });
49
+ configObject.addPropertyAssignment({
50
+ name: "signingSecretCredentialReference",
51
+ initializer: varName
52
+ });
53
+ }
54
+ return sourceFile;
55
+ }
56
+
57
+ //#endregion
58
+ export { generateTriggerDefinition };
@@ -0,0 +1,219 @@
1
+ import path from "node:path";
2
+ import { IndentationText, NewLineKind, Project, QuoteKind, SyntaxKind, VariableDeclarationKind } from "ts-morph";
3
+ import { jsonSchemaToZod } from "json-schema-to-zod";
4
+
5
+ //#region src/commands/pull-v4/utils.ts
6
+ function createInMemoryProject() {
7
+ return new Project({
8
+ useInMemoryFileSystem: true,
9
+ skipLoadingLibFiles: true,
10
+ manipulationSettings: {
11
+ indentationText: IndentationText.TwoSpaces,
12
+ quoteKind: QuoteKind.Single,
13
+ newLineKind: NewLineKind.LineFeed,
14
+ useTrailingCommas: true
15
+ }
16
+ });
17
+ }
18
+ /**
19
+ * Create variable in following pattern
20
+ *
21
+ * (export)? const VARIABLE_NAME = (new)?IMPORT_NAME({})
22
+ */
23
+ function addFactoryConfigVariable({ sourceFile, importName, variableName, isExported, syntaxKind = SyntaxKind.CallExpression }) {
24
+ const initializer = `${syntaxKind === SyntaxKind.NewExpression ? "new " : ""}${importName}({})`;
25
+ const [declaration] = sourceFile.addVariableStatement({
26
+ declarationKind: VariableDeclarationKind.Const,
27
+ isExported,
28
+ declarations: [{
29
+ name: variableName,
30
+ initializer
31
+ }]
32
+ }).getDeclarations();
33
+ const [configArg] = declaration.getInitializerIfKindOrThrow(syntaxKind).getArguments();
34
+ return { configObject: configArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression) };
35
+ }
36
+ function createFactoryDefinition({ importName, variableName: name, fileName = "definition.ts", moduleSpecifier = "@inkeep/agents-sdk", syntaxKind }) {
37
+ const sourceFile = createInMemoryProject().createSourceFile(fileName, "", { overwrite: true });
38
+ sourceFile.addImportDeclaration({
39
+ namedImports: [importName],
40
+ moduleSpecifier
41
+ });
42
+ const { configObject } = addFactoryConfigVariable({
43
+ sourceFile,
44
+ importName,
45
+ variableName: name,
46
+ isExported: true,
47
+ syntaxKind
48
+ });
49
+ return {
50
+ sourceFile,
51
+ configObject
52
+ };
53
+ }
54
+ function toCamelCase(input) {
55
+ const result = input.replace(/[^a-zA-Z0-9](.)/g, (_, char) => char.toUpperCase()).replace(/^[0-9]/, "_$&");
56
+ return result.charAt(0).toLowerCase() + result.slice(1);
57
+ }
58
+ function resolveReferenceName(referenceId, referenceOverrides) {
59
+ for (const overrideMap of referenceOverrides) {
60
+ const overrideName = overrideMap?.[referenceId];
61
+ if (overrideName) return overrideName;
62
+ }
63
+ return toCamelCase(referenceId);
64
+ }
65
+ function convertJsonSchemaToZodSafe(schema, options) {
66
+ if (!isPlainObject(schema)) {
67
+ console.warn("Schema conversion skipped: non-object schema provided, using z.any()");
68
+ return "z.any()";
69
+ }
70
+ try {
71
+ return jsonSchemaToZod(schema, options?.conversionOptions);
72
+ } catch (error) {
73
+ console.warn(`Schema conversion failed: ${error instanceof Error ? error.message : String(error)}. Falling back to z.any()`);
74
+ return "z.any()";
75
+ }
76
+ }
77
+ function isPlainObject(value) {
78
+ return typeof value === "object" && value !== null && !Array.isArray(value);
79
+ }
80
+ const QUOTE = Object.freeze({
81
+ single: "'",
82
+ double: "\"",
83
+ template: "`"
84
+ });
85
+ const TEMPLATE_VARIABLE_REGEX = /\{\{(?!\{)(?<variableName>[^{}]+)}}/g;
86
+ function formatStringLiteral(value) {
87
+ const hasSingleQuote = value.includes(QUOTE.single);
88
+ const hasDoubleQuote = value.includes(QUOTE.double);
89
+ return escapeStringLiteral(value, value.includes("\n") || value.includes("${") || hasSingleQuote && hasDoubleQuote ? QUOTE.template : hasSingleQuote ? QUOTE.double : QUOTE.single);
90
+ }
91
+ function collectTemplateVariableNames(value) {
92
+ const variables = [];
93
+ for (const match of value.matchAll(TEMPLATE_VARIABLE_REGEX)) {
94
+ const variableName = match.groups?.variableName?.trim();
95
+ if (variableName) variables.push(variableName);
96
+ }
97
+ return variables;
98
+ }
99
+ function formatTemplate(value, references) {
100
+ if (!value.length) return value;
101
+ let didReplace = false;
102
+ const rewrittenValue = value.replace(TEMPLATE_VARIABLE_REGEX, (match, ...args) => {
103
+ const maybeGroups = args.at(-1);
104
+ const variableName = isPlainObject(maybeGroups) && typeof maybeGroups.variableName === "string" ? maybeGroups.variableName.trim() : void 0;
105
+ if (!variableName) return match;
106
+ if (variableName.startsWith("headers.")) {
107
+ const headerPath = variableName.slice(8);
108
+ if (!headerPath || !references.headersReference) return match;
109
+ didReplace = true;
110
+ return `\${${references.headersReference}.toTemplate(${JSON.stringify(headerPath)})}`;
111
+ }
112
+ if (!references.contextReference) return match;
113
+ didReplace = true;
114
+ return `\${${references.contextReference}.toTemplate(${JSON.stringify(variableName)})}`;
115
+ });
116
+ return didReplace ? rewrittenValue : value;
117
+ }
118
+ function escapeStringLiteral(value, quote) {
119
+ return [
120
+ quote,
121
+ value.replaceAll("\\", "\\\\").replaceAll(quote, `\\${quote}`),
122
+ quote
123
+ ].join("");
124
+ }
125
+ function formatPropertyName(key) {
126
+ if (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key)) return key;
127
+ return formatStringLiteral(key);
128
+ }
129
+ function formatInlineLiteral(value) {
130
+ if (typeof value === "string") return formatStringLiteral(value);
131
+ if (typeof value === "number" || typeof value === "bigint") return String(value);
132
+ if (typeof value === "boolean") return value ? "true" : "false";
133
+ if (value === null) return "null";
134
+ if (Array.isArray(value)) return `[${value.map((item) => formatInlineLiteral(item)).join(", ")}]`;
135
+ if (isPlainObject(value)) {
136
+ const entries = Object.entries(value).filter(([, entryValue]) => entryValue !== void 0);
137
+ if (!entries.length) return "{}";
138
+ return `{ ${entries.map(([key, entryValue]) => `${formatPropertyName(key)}: ${formatInlineLiteral(entryValue)}`).join(", ")} }`;
139
+ }
140
+ return "undefined";
141
+ }
142
+ function addReferenceGetterProperty(configObject, key, refs) {
143
+ configObject.addPropertyAssignment({
144
+ name: key,
145
+ initializer: "() => []"
146
+ }).getInitializerIfKindOrThrow(SyntaxKind.ArrowFunction).getBody().asKindOrThrow(SyntaxKind.ArrayLiteralExpression).addElements(refs);
147
+ }
148
+ function addObjectEntries(target, value) {
149
+ for (const [key, entryValue] of Object.entries(value)) {
150
+ if (entryValue === void 0) continue;
151
+ if (isPlainObject(entryValue)) {
152
+ addObjectEntries(target.addPropertyAssignment({
153
+ name: formatPropertyName(key),
154
+ initializer: "{}"
155
+ }).getInitializerIfKindOrThrow(SyntaxKind.ObjectLiteralExpression), entryValue);
156
+ continue;
157
+ }
158
+ target.addPropertyAssignment({
159
+ name: formatPropertyName(key),
160
+ initializer: formatInlineLiteral(entryValue)
161
+ });
162
+ }
163
+ }
164
+ function addStringProperty(configObject, key, value) {
165
+ configObject.addPropertyAssignment({
166
+ name: key,
167
+ initializer: formatStringLiteral(value)
168
+ });
169
+ }
170
+ function addValueToObject(obj, key, value) {
171
+ if (value === void 0) return;
172
+ if (isPlainObject(value)) {
173
+ const child = obj.addPropertyAssignment({
174
+ name: formatPropertyName(key),
175
+ initializer: "{}"
176
+ }).getInitializerIfKindOrThrow(SyntaxKind.ObjectLiteralExpression);
177
+ for (const [k, v] of Object.entries(value)) addValueToObject(child, k, v);
178
+ return;
179
+ }
180
+ if (Array.isArray(value)) {
181
+ const arr = obj.addPropertyAssignment({
182
+ name: formatPropertyName(key),
183
+ initializer: "[]"
184
+ }).getInitializerIfKindOrThrow(SyntaxKind.ArrayLiteralExpression);
185
+ for (const item of value) addValueToArray(arr, item);
186
+ return;
187
+ }
188
+ obj.addPropertyAssignment({
189
+ name: formatPropertyName(key),
190
+ initializer: formatInlineLiteral(value)
191
+ });
192
+ }
193
+ function addValueToArray(arr, value) {
194
+ if (isPlainObject(value)) {
195
+ const child = arr.addElement("{}").asKindOrThrow(SyntaxKind.ObjectLiteralExpression);
196
+ for (const [k, v] of Object.entries(value)) addValueToObject(child, k, v);
197
+ return;
198
+ }
199
+ if (Array.isArray(value)) {
200
+ const child = arr.addElement("[]").asKindOrThrow(SyntaxKind.ArrayLiteralExpression);
201
+ for (const item of value) addValueToArray(child, item);
202
+ return;
203
+ }
204
+ arr.addElement(formatInlineLiteral(value));
205
+ }
206
+ async function expectSnapshots(definitionV4) {
207
+ const { currentTestName, snapshotState } = expect.getState();
208
+ const snapshotDir = path.basename(snapshotState.testFilePath).replace("-generator.test.ts", "");
209
+ await expect(definitionV4).toMatchFileSnapshot(`__snapshots__/${snapshotDir}/${currentTestName}-v4.txt`);
210
+ }
211
+ function convertNullToUndefined(v) {
212
+ return v == null ? void 0 : v;
213
+ }
214
+ function hasReferences(references) {
215
+ return Array.isArray(references) && references.length > 0;
216
+ }
217
+
218
+ //#endregion
219
+ export { TEMPLATE_VARIABLE_REGEX, addFactoryConfigVariable, addObjectEntries, addReferenceGetterProperty, addStringProperty, addValueToObject, collectTemplateVariableNames, convertJsonSchemaToZodSafe, convertNullToUndefined, createFactoryDefinition, createInMemoryProject, expectSnapshots, formatInlineLiteral, formatPropertyName, formatStringLiteral, formatTemplate, hasReferences, isPlainObject, resolveReferenceName, toCamelCase };
@@ -4,10 +4,10 @@ import { initializeCommand } from "../utils/cli-pipeline.js";
4
4
  import { performBackgroundVersionCheck } from "../utils/background-version-check.js";
5
5
  import { loadProject } from "../utils/project-loader.js";
6
6
  import { loadEnvironmentCredentials } from "../utils/environment-loader.js";
7
- import { existsSync, readdirSync, statSync } from "node:fs";
8
7
  import { basename, dirname, join, resolve } from "node:path";
9
8
  import * as p from "@clack/prompts";
10
9
  import chalk from "chalk";
10
+ import { existsSync, readdirSync, statSync } from "node:fs";
11
11
 
12
12
  //#region src/commands/push.ts
13
13
  async function pushCommand(options) {
@@ -1,4 +1,4 @@
1
- import { checkForUpdate, getChangelogUrl } from "../utils/version-check.js";
1
+ import { PACKAGE_CHANGELOG, checkForUpdate } from "../utils/version-check.js";
2
2
  import { detectPackageManager, executeUpdate } from "../utils/package-manager.js";
3
3
  import * as p from "@clack/prompts";
4
4
  import chalk from "chalk";
@@ -29,7 +29,7 @@ async function updateCommand(options = {}) {
29
29
  }
30
30
  if (!versionInfo.needsUpdate && options.force) console.log(chalk.yellow("\n⚠️ Forcing reinstall of current version..."));
31
31
  console.log(chalk.cyan("\n📖 Changelog:"));
32
- console.log(chalk.gray(` • ${getChangelogUrl()}`));
32
+ console.log(chalk.gray(` • ${PACKAGE_CHANGELOG}`));
33
33
  s.start("Detecting package manager...");
34
34
  const detectedManager = await detectPackageManager();
35
35
  s.stop();
package/dist/index.js CHANGED
@@ -9,32 +9,28 @@ import { initCommand } from "./commands/init.js";
9
9
  import { listAgentsCommand } from "./commands/list-agents.js";
10
10
  import { logoutCommand } from "./commands/logout.js";
11
11
  import { profileAddCommand, profileCurrentCommand, profileListCommand, profileRemoveCommand, profileUseCommand } from "./commands/profile.js";
12
- import { pullV3Command } from "./commands/pull-v3/index.js";
12
+ import { PACKAGE_VERSION } from "./utils/version-check.js";
13
+ import { pullV4Command } from "./commands/pull-v4/introspect/index.js";
13
14
  import { pushCommand } from "./commands/push.js";
14
15
  import { statusCommand } from "./commands/status.js";
15
16
  import { updateCommand } from "./commands/update.js";
16
17
  import { whoamiCommand } from "./commands/whoami.js";
17
18
  import { getLogger } from "@inkeep/agents-core";
18
- import { readFileSync } from "node:fs";
19
- import { dirname, join } from "node:path";
20
- import { fileURLToPath } from "node:url";
21
19
  import { Command } from "commander";
22
20
 
23
21
  //#region src/index.ts
24
22
  getLogger("config").updateOptions({ level: "silent" });
25
- const packageJsonPath = join(dirname(fileURLToPath(import.meta.url)), "..", "package.json");
26
- const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
27
23
  const program = new Command();
28
- program.name("inkeep").description("CLI tool for Inkeep Agent Framework").version(packageJson.version);
24
+ program.name("inkeep").description("CLI tool for Inkeep Agent Framework").version(PACKAGE_VERSION);
29
25
  program.command("add [template]").description("Add a new template to the project").option("--project <template>", "Project template to add").option("--mcp <template>", "MCP template to add").option("--ui [component-id]", "Add UI component(s) to apps/agents-ui/src/ui (omit id to add all)").option("--list", "List available UI components (use with --ui)").option("--target-path <path>", "Target path to add the template to").option("--local-prefix <path_prefix>", "Use local templates from the given path prefix").option("--config <path>", "Path to configuration file").option("--profile <name>", "Profile to use for authentication").option("--quiet", "Suppress profile/config logging").action(async (template, options) => {
30
26
  await addCommand({
31
27
  template,
32
28
  ...options
33
29
  });
34
30
  });
35
- program.command("init [path]").description("Initialize a new Inkeep project (runs cloud onboarding wizard by default)").option("--local", "Use local/self-hosted mode instead of cloud onboarding").option("--no-interactive", "Skip interactive prompts").option("--config <path>", "Path to use as template for new configuration").action(async (path$1, options) => {
31
+ program.command("init [path]").description("Initialize a new Inkeep project (runs cloud onboarding wizard by default)").option("--local", "Use local/self-hosted mode instead of cloud onboarding").option("--no-interactive", "Skip interactive prompts").option("--config <path>", "Path to use as template for new configuration").action(async (path, options) => {
36
32
  await initCommand({
37
- path: path$1,
33
+ path,
38
34
  ...options
39
35
  });
40
36
  });
@@ -48,11 +44,9 @@ configCommand.command("set <key> <value>").description("Set a configuration valu
48
44
  configCommand.command("list").description("List all configuration values").option("--config <path>", "Path to configuration file").option("--config-file-path <path>", "Path to configuration file (deprecated, use --config)").action(async (options) => {
49
45
  await configListCommand({ config: options.config || options.configFilePath });
50
46
  });
51
- program.command("push").description("Push a project configuration to the backend").option("--project <project-id>", "Project ID or path to project directory").option("--config <path>", "Path to configuration file").option("--profile <name>", "Profile to use for remote URLs and authentication").option("--tenant-id <id>", "Override tenant ID").option("--agents-api-url <url>", "Override agents API URL").option("--env <environment>", "Environment to use for credential resolution (e.g., development, production)").option("--json", "Generate project data JSON file instead of pushing to backend").option("--all", "Push all projects found in current directory tree").option("--tag <tag>", "Use tagged config file (e.g., --tag prod loads prod.__inkeep.config.ts__)").option("--quiet", "Suppress profile/config logging").action(async (options) => {
52
- await pushCommand(options);
53
- });
54
- program.command("pull").description("Pull project configuration with clean, efficient code generation").option("--project <project-id>", "Project ID to pull (or path to project directory). If in project directory, validates against local project ID.").option("--config <path>", "Path to configuration file").option("--profile <name>", "Profile to use for remote URLs and authentication").option("--env <environment>", "Environment file to generate (development, staging, production). Defaults to development").option("--json", "Output project data as JSON instead of generating files").option("--debug", "Enable debug logging").option("--verbose", "Enable verbose logging").option("--force", "Force regeneration even if no changes detected").option("--introspect", "Completely regenerate all files from scratch (no comparison needed)").option("--all", "Pull all projects for current tenant").option("--tag <tag>", "Use tagged config file (e.g., --tag prod loads prod.__inkeep.config.ts__)").option("--quiet", "Suppress profile/config logging").action(async (options) => {
55
- await pullV3Command(options);
47
+ program.command("push").description("Push a project configuration to the backend").option("--project <project-id>", "Project ID or path to project directory").option("--config <path>", "Path to configuration file").option("--profile <name>", "Profile to use for remote URLs and authentication").option("--tenant-id <id>", "Override tenant ID").option("--agents-api-url <url>", "Override agents API URL").option("--env <environment>", "Environment to use for credential resolution (e.g., development, production)").option("--json", "Generate project data JSON file instead of pushing to backend").option("--all", "Push all projects found in current directory tree").option("--tag <tag>", "Use tagged config file (e.g., --tag prod loads prod.__inkeep.config.ts__)").option("--quiet", "Suppress profile/config logging").action(pushCommand);
48
+ program.command("pull").description("Pull project configuration with clean, efficient code generation").option("--project <project-id>", "Project ID to pull (or path to project directory). If in project directory, validates against local project ID.").option("--config <path>", "Path to configuration file").option("--profile <name>", "Profile to use for remote URLs and authentication").option("--env <environment>", "Environment file to generate (development, staging, production). Defaults to development").option("--json", "Output project data as JSON instead of generating files").option("--debug", "Enable debug logging").option("--verbose", "Enable verbose logging").option("--force", "Force regeneration even if no changes detected").option("--all", "Pull all projects for current tenant").option("--tag <tag>", "Use tagged config file (e.g., --tag prod loads prod.__inkeep.config.ts__)").option("--quiet", "Suppress profile/config logging").action(async (options) => {
49
+ await pullV4Command(options);
56
50
  });
57
51
  program.command("list-agent").description("List all available agents for a specific project").requiredOption("--project <project-id>", "Project ID to list agent for").option("--tenant-id <tenant-id>", "Tenant ID").option("--agents-api-url <url>", "Agents API URL").option("--config <path>", "Path to configuration file").option("--config-file-path <path>", "Path to configuration file (deprecated, use --config)").action(async (options) => {
58
52
  const config = options.config || options.configFilePath;
@@ -72,37 +66,17 @@ program.command("dev").description("Start the Inkeep dashboard server").option("
72
66
  openBrowser: options.openBrowser
73
67
  });
74
68
  });
75
- program.command("update").description("Update @inkeep/agents-cli to the latest version").option("--check", "Check for updates without installing").option("--force", "Force update even if already on latest version").action(async (options) => {
76
- await updateCommand(options);
77
- });
78
- program.command("login").description("Authenticate with Inkeep Cloud").option("--profile <name>", "Profile to authenticate (defaults to active profile)").action(async (options) => {
79
- await loginCommand(options);
80
- });
81
- program.command("logout").description("Log out of Inkeep Cloud").option("--profile <name>", "Profile to log out (defaults to active profile)").action(async (options) => {
82
- await logoutCommand(options);
83
- });
84
- program.command("status").description("Show current profile, authentication state, and remote URLs").option("--profile <name>", "Profile to show status for (defaults to active profile)").action(async (options) => {
85
- await statusCommand(options);
86
- });
87
- program.command("whoami").description("Display current authentication status (alias for status)").action(async () => {
88
- await whoamiCommand();
89
- });
69
+ program.command("update").description("Update @inkeep/agents-cli to the latest version").option("--check", "Check for updates without installing").option("--force", "Force update even if already on latest version").action(updateCommand);
70
+ program.command("login").description("Authenticate with Inkeep Cloud").option("--profile <name>", "Profile to authenticate (defaults to active profile)").action(loginCommand);
71
+ program.command("logout").description("Log out of Inkeep Cloud").option("--profile <name>", "Profile to log out (defaults to active profile)").action(logoutCommand);
72
+ program.command("status").description("Show current profile, authentication state, and remote URLs").option("--profile <name>", "Profile to show status for (defaults to active profile)").action(statusCommand);
73
+ program.command("whoami").description("Display current authentication status (alias for status)").action(whoamiCommand);
90
74
  const profileCommand = program.command("profile").description("Manage CLI profiles for connecting to different remotes");
91
- profileCommand.command("list").description("List all profiles").action(async () => {
92
- await profileListCommand();
93
- });
94
- profileCommand.command("add [name]").description("Add a new profile").action(async (name) => {
95
- await profileAddCommand(name);
96
- });
97
- profileCommand.command("use <name>").description("Set the active profile").action(async (name) => {
98
- await profileUseCommand(name);
99
- });
100
- profileCommand.command("current").description("Display the active profile details").action(async () => {
101
- await profileCurrentCommand();
102
- });
103
- profileCommand.command("remove <name>").description("Remove a profile").action(async (name) => {
104
- await profileRemoveCommand(name);
105
- });
75
+ profileCommand.command("list").description("List all profiles").action(profileListCommand);
76
+ profileCommand.command("add [name]").description("Add a new profile").action(profileAddCommand);
77
+ profileCommand.command("use <name>").description("Set the active profile").action(profileUseCommand);
78
+ profileCommand.command("current").description("Display the active profile details").action(profileCurrentCommand);
79
+ profileCommand.command("remove <name>").description("Remove a profile").action(profileRemoveCommand);
106
80
  program.parse();
107
81
 
108
82
  //#endregion
@@ -0,0 +1,18 @@
1
+ import Diff from "./base.js";
2
+
3
+ //#region ../node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/array.js
4
+ var ArrayDiff = class extends Diff {
5
+ tokenize(value) {
6
+ return value.slice();
7
+ }
8
+ join(value) {
9
+ return value;
10
+ }
11
+ removeEmpty(value) {
12
+ return value;
13
+ }
14
+ };
15
+ const arrayDiff = new ArrayDiff();
16
+
17
+ //#endregion
18
+ export { };