@inkeep/agents-cli 0.42.0 → 0.43.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.
package/dist/commands/init.js
CHANGED
|
@@ -88,7 +88,7 @@ async function cloudInitCommand(options) {
|
|
|
88
88
|
let selectedTenantId;
|
|
89
89
|
let selectedTenantName;
|
|
90
90
|
try {
|
|
91
|
-
const response = await fetch("https://
|
|
91
|
+
const response = await fetch("https://api.pilot.inkeep.com/manage/api/cli/me", { headers: { Authorization: `Bearer ${credentials?.accessToken}` } });
|
|
92
92
|
if (!response.ok) {
|
|
93
93
|
s.stop("Failed to fetch organizations");
|
|
94
94
|
console.error(chalk.red("Could not fetch your organizations. Please try logging in again."));
|
|
@@ -13,7 +13,7 @@ async function listAgentsCommand(options) {
|
|
|
13
13
|
logConfig: true
|
|
14
14
|
});
|
|
15
15
|
console.log();
|
|
16
|
-
const api = await ManagementApiClient.create(config.agentsApiUrl, configPath, config.tenantId, options.project);
|
|
16
|
+
const api = await ManagementApiClient.create(config.agentsApiUrl, configPath, config.tenantId, options.project, void 0, config.agentsApiKey);
|
|
17
17
|
const s = p.spinner();
|
|
18
18
|
s.start("Fetching agent...");
|
|
19
19
|
try {
|
package/dist/commands/login.js
CHANGED
|
@@ -55,7 +55,7 @@ async function fetchUserInfo(cloudUrl, accessToken) {
|
|
|
55
55
|
if (!sessionResponse.ok) throw new Error("Failed to fetch user session");
|
|
56
56
|
const user = (await sessionResponse.json()).user;
|
|
57
57
|
if (!user) throw new Error("No user found in session");
|
|
58
|
-
const orgResponse = await fetch(`${cloudUrl}/api/cli/me`, { headers: { Authorization: `Bearer ${accessToken}` } });
|
|
58
|
+
const orgResponse = await fetch(`${cloudUrl}/manage/api/cli/me`, { headers: { Authorization: `Bearer ${accessToken}` } });
|
|
59
59
|
if (!orgResponse.ok) throw new Error("Failed to fetch organization info. Please ensure that you are a member of an organization.");
|
|
60
60
|
const orgData = await orgResponse.json();
|
|
61
61
|
return {
|
|
@@ -58,9 +58,60 @@ function formatOutputTransform(transform, style, indentLevel) {
|
|
|
58
58
|
return lines.join("\n");
|
|
59
59
|
}
|
|
60
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
|
+
/**
|
|
61
112
|
* Generate Trigger Definition using Trigger class
|
|
62
113
|
*/
|
|
63
|
-
function generateTriggerDefinition(triggerId, triggerData, style = DEFAULT_STYLE) {
|
|
114
|
+
function generateTriggerDefinition(triggerId, triggerData, style = DEFAULT_STYLE, registry) {
|
|
64
115
|
if (!triggerId || typeof triggerId !== "string") throw new Error("triggerId is required and must be a string");
|
|
65
116
|
if (!triggerData || typeof triggerData !== "object") throw new Error(`triggerData is required for trigger '${triggerId}'`);
|
|
66
117
|
const missingFields = ["name", "messageTemplate"].filter((field) => !triggerData[field] || triggerData[field] === null || triggerData[field] === void 0);
|
|
@@ -91,6 +142,16 @@ function generateTriggerDefinition(triggerId, triggerData, style = DEFAULT_STYLE
|
|
|
91
142
|
const authFormatted = formatAuthentication(triggerData.authentication, style, 1);
|
|
92
143
|
if (authFormatted) lines.push(authFormatted);
|
|
93
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
|
+
}
|
|
94
155
|
if (lines.length > 0 && lines[lines.length - 1].endsWith(",")) lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
|
|
95
156
|
lines.push(`})${semi}`);
|
|
96
157
|
return lines.join("\n");
|
|
@@ -98,16 +159,26 @@ function generateTriggerDefinition(triggerId, triggerData, style = DEFAULT_STYLE
|
|
|
98
159
|
/**
|
|
99
160
|
* Generate imports needed for a trigger file
|
|
100
161
|
*/
|
|
101
|
-
function generateTriggerImports(style = DEFAULT_STYLE) {
|
|
162
|
+
function generateTriggerImports(triggerId, triggerData, style = DEFAULT_STYLE, registry) {
|
|
102
163
|
const imports = [];
|
|
103
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
|
+
}
|
|
104
175
|
return imports;
|
|
105
176
|
}
|
|
106
177
|
/**
|
|
107
178
|
* Generate complete trigger file (imports + definition)
|
|
108
179
|
*/
|
|
109
|
-
function generateTriggerFile(triggerId, triggerData, style = DEFAULT_STYLE) {
|
|
110
|
-
return generateFileContent(generateTriggerImports(style), [generateTriggerDefinition(triggerId, triggerData, style)]);
|
|
180
|
+
function generateTriggerFile(triggerId, triggerData, style = DEFAULT_STYLE, registry) {
|
|
181
|
+
return generateFileContent(generateTriggerImports(triggerId, triggerData, style, registry), [generateTriggerDefinition(triggerId, triggerData, style, registry)]);
|
|
111
182
|
}
|
|
112
183
|
|
|
113
184
|
//#endregion
|
|
@@ -222,7 +222,7 @@ async function introspectGenerate(project, paths, environment, debug, options =
|
|
|
222
222
|
generatedFiles.push(agentFile);
|
|
223
223
|
if (agentData.triggers && Object.keys(agentData.triggers).length > 0) for (const [triggerId, triggerData] of Object.entries(agentData.triggers)) {
|
|
224
224
|
const triggerFile = join(paths.agentsDir, "triggers", `${triggerId}.ts`);
|
|
225
|
-
const triggerContent = generateTriggerFile(triggerId, triggerData, style);
|
|
225
|
+
const triggerContent = generateTriggerFile(triggerId, triggerData, style, registry);
|
|
226
226
|
ensureDir(triggerFile);
|
|
227
227
|
writeFileSync(triggerFile, triggerContent, "utf-8");
|
|
228
228
|
generatedFiles.push(triggerFile);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.0",
|
|
4
4
|
"description": "Inkeep CLI tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -34,15 +34,14 @@
|
|
|
34
34
|
"find-up": "^7.0.0",
|
|
35
35
|
"fs-extra": "^11.2.0",
|
|
36
36
|
"json-schema-to-zod": "^2.6.1",
|
|
37
|
-
"keytar": "^7.9.0",
|
|
38
37
|
"langfuse-vercel": "^3.38.6",
|
|
39
38
|
"open": "^10.2.0",
|
|
40
39
|
"ts-morph": "^26.0.0",
|
|
41
40
|
"tsx": "^4.20.5",
|
|
42
41
|
"yaml": "^2.7.0",
|
|
43
42
|
"zod": "^4.1.11",
|
|
44
|
-
"@inkeep/agents-core": "^0.
|
|
45
|
-
"@inkeep/agents-sdk": "^0.
|
|
43
|
+
"@inkeep/agents-core": "^0.43.0",
|
|
44
|
+
"@inkeep/agents-sdk": "^0.43.0"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
47
|
"@types/degit": "^2.8.6",
|
|
@@ -76,7 +75,6 @@
|
|
|
76
75
|
"lint:fix": "biome check --write",
|
|
77
76
|
"build": "tsdown",
|
|
78
77
|
"cli": "node ./dist/index.js",
|
|
79
|
-
"postinstall": "node scripts/ensure-keytar.mjs || true",
|
|
80
78
|
"dev": "pnpm build --watch",
|
|
81
79
|
"test": "node -e \"process.exit(process.env.CI ? 0 : 1)\" && vitest --run --config vitest.config.ci.ts || vitest --run",
|
|
82
80
|
"test:debug": "vitest --run --reporter=verbose --no-coverage",
|