@kraken-ai/platform 0.0.4 → 0.0.6
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/{chunk-PPT6GGYL.js → chunk-SL6WL3X6.js} +243 -67
- package/dist/chunk-SL6WL3X6.js.map +1 -0
- package/dist/cli.js +1102 -374
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +415 -240
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1072 -368
- package/dist/index.d.ts +1072 -368
- package/dist/index.js +183 -172
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +219 -45
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +264 -28
- package/dist/server.d.ts +264 -28
- package/dist/server.js +15 -20
- package/dist/server.js.map +1 -1
- package/package.json +20 -16
- package/dist/chunk-PPT6GGYL.js.map +0 -1
- package/dist/types-_lfbhFJH.d.cts +0 -451
- package/dist/types-_lfbhFJH.d.ts +0 -451
package/dist/index.cjs
CHANGED
|
@@ -39,41 +39,24 @@ __export(index_exports, {
|
|
|
39
39
|
PlatformClient: () => PlatformClient,
|
|
40
40
|
PlatformError: () => PlatformError,
|
|
41
41
|
SecurityError: () => SecurityError,
|
|
42
|
-
actionVariantConfigSchema: () => actionVariantConfigSchema,
|
|
43
|
-
actionsConfigSchema: () => actionsConfigSchema,
|
|
44
|
-
agentDefinitionSchema: () => agentDefinitionSchema,
|
|
45
42
|
buildActionOutputSchema: () => buildActionOutputSchema,
|
|
46
|
-
concurrencyPolicySchema: () => concurrencyPolicySchema,
|
|
47
43
|
defineAction: () => defineAction,
|
|
48
|
-
defineActions: () => defineActions,
|
|
49
44
|
defineConnector: () => defineConnector,
|
|
50
45
|
definePlatformAgent: () => definePlatformAgent,
|
|
51
46
|
defineSkill: () => defineSkill,
|
|
52
47
|
defineTool: () => defineTool,
|
|
53
|
-
|
|
54
|
-
identityConfigSchema: () => identityConfigSchema,
|
|
48
|
+
isQualified: () => isQualified,
|
|
55
49
|
isValidActionName: () => isValidActionName,
|
|
56
|
-
jitPolicySchema: () => jitPolicySchema,
|
|
57
50
|
mcpResult: () => mcpResult,
|
|
58
|
-
|
|
51
|
+
parse: () => parse,
|
|
59
52
|
parseManifestFromOutput: () => parseManifestFromOutput,
|
|
60
|
-
|
|
61
|
-
projectManifestSchema: () => projectManifestSchema,
|
|
62
|
-
resourceLimitsSchema: () => resourceLimitsSchema,
|
|
63
|
-
retryPolicySchema: () => retryPolicySchema,
|
|
64
|
-
teamConfigSchema: () => teamConfigSchema,
|
|
65
|
-
triggerConfigSchema: () => triggerConfigSchema,
|
|
53
|
+
qualify: () => qualify,
|
|
66
54
|
wrapToolError: () => wrapToolError,
|
|
67
55
|
wrapToolResult: () => wrapToolResult
|
|
68
56
|
});
|
|
69
57
|
module.exports = __toCommonJS(index_exports);
|
|
70
58
|
|
|
71
|
-
//
|
|
72
|
-
var import_node_crypto = require("crypto");
|
|
73
|
-
var import_node_http = require("http");
|
|
74
|
-
var z = __toESM(require("zod"), 1);
|
|
75
|
-
|
|
76
|
-
// src/agents/errors.ts
|
|
59
|
+
// ../../../private-packages/platform-core/dist/errors.js
|
|
77
60
|
var SecurityError = class extends Error {
|
|
78
61
|
code = "SECURITY_VIOLATION";
|
|
79
62
|
constructor(message) {
|
|
@@ -89,6 +72,221 @@ var ConnectorError = class extends Error {
|
|
|
89
72
|
}
|
|
90
73
|
};
|
|
91
74
|
|
|
75
|
+
// ../../../private-packages/platform-core/dist/qualified-name.js
|
|
76
|
+
var qualify = (repoName, primitiveName) => {
|
|
77
|
+
if (!repoName)
|
|
78
|
+
throw new Error("repoName must not be empty");
|
|
79
|
+
if (!primitiveName)
|
|
80
|
+
throw new Error("primitiveName must not be empty");
|
|
81
|
+
return `${repoName}/${primitiveName}`;
|
|
82
|
+
};
|
|
83
|
+
var parse = (qualified) => {
|
|
84
|
+
const slashIndex = qualified.indexOf("/");
|
|
85
|
+
if (slashIndex === -1) {
|
|
86
|
+
throw new Error(`Expected qualified name with "/" separator, got: "${qualified}"`);
|
|
87
|
+
}
|
|
88
|
+
if (qualified.indexOf("/", slashIndex + 1) !== -1) {
|
|
89
|
+
throw new Error(`Expected exactly one "/" in qualified name, got: "${qualified}"`);
|
|
90
|
+
}
|
|
91
|
+
const repoName = qualified.slice(0, slashIndex);
|
|
92
|
+
const primitiveName = qualified.slice(slashIndex + 1);
|
|
93
|
+
if (!repoName || !primitiveName) {
|
|
94
|
+
throw new Error(`Both repo and primitive segments must be non-empty, got: "${qualified}"`);
|
|
95
|
+
}
|
|
96
|
+
return { repoName, primitiveName };
|
|
97
|
+
};
|
|
98
|
+
var isQualified = (name) => {
|
|
99
|
+
const slashIndex = name.indexOf("/");
|
|
100
|
+
if (slashIndex === -1 || slashIndex === 0 || slashIndex === name.length - 1)
|
|
101
|
+
return false;
|
|
102
|
+
return name.indexOf("/", slashIndex + 1) === -1;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// ../../../private-packages/platform-core/dist/types/action.js
|
|
106
|
+
var ACTION_NAME_REGEX = /^[a-z0-9][a-z0-9-]{0,62}[a-z0-9]$/;
|
|
107
|
+
var isValidActionName = (name) => name.length === 1 ? /^[a-z0-9]$/.test(name) : ACTION_NAME_REGEX.test(name);
|
|
108
|
+
|
|
109
|
+
// ../../../private-packages/platform-core/dist/types/environment.js
|
|
110
|
+
var z = __toESM(require("zod"), 1);
|
|
111
|
+
var environmentSchema = z.enum(["dev", "staging", "prod"]);
|
|
112
|
+
|
|
113
|
+
// ../../../private-packages/platform-core/dist/types/identity.js
|
|
114
|
+
var z2 = __toESM(require("zod"), 1);
|
|
115
|
+
var jitPolicySchema = z2.enum(["auto-approve", "policy-based", "require-approval"]);
|
|
116
|
+
var identityConfigSchema = z2.object({
|
|
117
|
+
basePermissions: z2.array(z2.string()),
|
|
118
|
+
requestablePermissions: z2.array(z2.string()).optional(),
|
|
119
|
+
jitPolicy: jitPolicySchema.optional(),
|
|
120
|
+
maxJitDurationMinutes: z2.number().int().positive().optional()
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// ../../../private-packages/platform-core/dist/types/notifications.js
|
|
124
|
+
var z3 = __toESM(require("zod"), 1);
|
|
125
|
+
var notificationConfigSchema = z3.object({
|
|
126
|
+
slack: z3.string().optional(),
|
|
127
|
+
onSuccess: z3.boolean().optional(),
|
|
128
|
+
onFailure: z3.boolean().optional(),
|
|
129
|
+
onTimeout: z3.boolean().optional()
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// ../../../private-packages/platform-core/dist/types/platform-agent.js
|
|
133
|
+
var z7 = __toESM(require("zod"), 1);
|
|
134
|
+
|
|
135
|
+
// ../../../private-packages/platform-core/dist/validate.js
|
|
136
|
+
var PRIMITIVE_NAME_REGEX = /^[a-z0-9][a-z0-9-]{0,62}[a-z0-9]$/;
|
|
137
|
+
var isValidPrimitiveName = (name) => name.length === 1 ? /^[a-z0-9]$/.test(name) : PRIMITIVE_NAME_REGEX.test(name);
|
|
138
|
+
var SKILL_NAME_REGEX = /^[a-zA-Z0-9][a-zA-Z0-9-]{0,62}[a-zA-Z0-9]$/;
|
|
139
|
+
var isValidSkillName = (basename) => basename.length === 1 ? /^[a-zA-Z0-9]$/.test(basename) : SKILL_NAME_REGEX.test(basename);
|
|
140
|
+
var isValidSkillId = (id) => {
|
|
141
|
+
const base = id.endsWith(".md") ? id.slice(0, -3) : id;
|
|
142
|
+
return isValidSkillName(base);
|
|
143
|
+
};
|
|
144
|
+
var isValidQualifiedName = (name) => {
|
|
145
|
+
if (!isQualified(name))
|
|
146
|
+
return false;
|
|
147
|
+
const { repoName, primitiveName } = parse(name);
|
|
148
|
+
return isValidPrimitiveName(repoName) && isValidPrimitiveName(primitiveName);
|
|
149
|
+
};
|
|
150
|
+
var isValidQualifiedSkillId = (id) => {
|
|
151
|
+
if (!isQualified(id))
|
|
152
|
+
return false;
|
|
153
|
+
const { repoName, primitiveName } = parse(id);
|
|
154
|
+
return isValidPrimitiveName(repoName) && isValidSkillId(primitiveName);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// ../../../private-packages/platform-core/dist/types/resources.js
|
|
158
|
+
var z4 = __toESM(require("zod"), 1);
|
|
159
|
+
var resourceLimitsSchema = z4.object({
|
|
160
|
+
maxTokens: z4.number().int().positive().optional(),
|
|
161
|
+
maxCostUsd: z4.number().positive().optional(),
|
|
162
|
+
timeoutSeconds: z4.number().int().positive().optional()
|
|
163
|
+
});
|
|
164
|
+
var retryPolicySchema = z4.object({
|
|
165
|
+
maxAttempts: z4.number().int().min(1).optional(),
|
|
166
|
+
backoffSeconds: z4.number().positive().optional()
|
|
167
|
+
});
|
|
168
|
+
var concurrencyPolicySchema = z4.object({
|
|
169
|
+
maxParallelRuns: z4.number().int().min(1).optional()
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// ../../../private-packages/platform-core/dist/types/team.js
|
|
173
|
+
var z5 = __toESM(require("zod"), 1);
|
|
174
|
+
var teamConfigSchema = z5.object({
|
|
175
|
+
members: z5.array(z5.string()).min(1),
|
|
176
|
+
maxConcurrentWorkers: z5.number().int().min(1).optional(),
|
|
177
|
+
maxTokenBudgetPerWorker: z5.number().int().positive().optional(),
|
|
178
|
+
maxDurationPerWorker: z5.number().positive().optional()
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// ../../../private-packages/platform-core/dist/types/trigger.js
|
|
182
|
+
var z6 = __toESM(require("zod"), 1);
|
|
183
|
+
var cronTriggerSchema = z6.object({
|
|
184
|
+
type: z6.literal("cron"),
|
|
185
|
+
expression: z6.string(),
|
|
186
|
+
timezone: z6.string().optional()
|
|
187
|
+
});
|
|
188
|
+
var webhookTriggerSchema = z6.object({
|
|
189
|
+
type: z6.literal("webhook"),
|
|
190
|
+
path: z6.string().startsWith("/"),
|
|
191
|
+
method: z6.enum(["POST", "GET"]).optional()
|
|
192
|
+
});
|
|
193
|
+
var eventTriggerSchema = z6.object({
|
|
194
|
+
type: z6.literal("event"),
|
|
195
|
+
source: z6.string(),
|
|
196
|
+
event: z6.string()
|
|
197
|
+
});
|
|
198
|
+
var apiTriggerSchema = z6.object({ type: z6.literal("api") });
|
|
199
|
+
var manualTriggerSchema = z6.object({ type: z6.literal("manual") });
|
|
200
|
+
var triggerConfigSchema = z6.discriminatedUnion("type", [
|
|
201
|
+
cronTriggerSchema,
|
|
202
|
+
webhookTriggerSchema,
|
|
203
|
+
eventTriggerSchema,
|
|
204
|
+
apiTriggerSchema,
|
|
205
|
+
manualTriggerSchema
|
|
206
|
+
]);
|
|
207
|
+
|
|
208
|
+
// ../../../private-packages/platform-core/dist/types/platform-agent.js
|
|
209
|
+
var thinkingLevelSchema = z7.enum(["low", "medium", "high"]);
|
|
210
|
+
var logLevelSchema = z7.enum(["silent", "debug", "info", "warn", "error"]);
|
|
211
|
+
var agentDefinitionSchema = z7.object({
|
|
212
|
+
name: z7.string().min(1),
|
|
213
|
+
model: z7.string().min(1),
|
|
214
|
+
instructions: z7.string().min(1),
|
|
215
|
+
description: z7.string().optional(),
|
|
216
|
+
skills: z7.array(z7.string()).optional(),
|
|
217
|
+
temperature: z7.number().min(0).max(2).optional(),
|
|
218
|
+
allowTemperatureOverride: z7.boolean().optional(),
|
|
219
|
+
maxOutputTokens: z7.number().int().positive().optional(),
|
|
220
|
+
thinkingLevel: thinkingLevelSchema.optional(),
|
|
221
|
+
logLevel: logLevelSchema.optional()
|
|
222
|
+
}).strict();
|
|
223
|
+
var platformAgentConfigSchema = z7.object({
|
|
224
|
+
agent: agentDefinitionSchema,
|
|
225
|
+
connectors: z7.array(z7.string()).optional(),
|
|
226
|
+
triggers: z7.array(triggerConfigSchema),
|
|
227
|
+
identity: identityConfigSchema.optional(),
|
|
228
|
+
resources: resourceLimitsSchema.optional(),
|
|
229
|
+
retries: retryPolicySchema.optional(),
|
|
230
|
+
concurrency: concurrencyPolicySchema.optional(),
|
|
231
|
+
team: teamConfigSchema.optional(),
|
|
232
|
+
notifications: notificationConfigSchema.optional(),
|
|
233
|
+
environment: environmentSchema.optional(),
|
|
234
|
+
actions: z7.array(z7.string()).optional()
|
|
235
|
+
}).strict().superRefine((data, ctx) => {
|
|
236
|
+
for (const member of data.team?.members ?? []) {
|
|
237
|
+
const valid = isQualified(member) ? isValidQualifiedName(member) : isValidPrimitiveName(member);
|
|
238
|
+
if (!valid) {
|
|
239
|
+
ctx.addIssue({
|
|
240
|
+
code: z7.ZodIssueCode.custom,
|
|
241
|
+
path: ["team", "members"],
|
|
242
|
+
message: `Invalid team member name: "${member}"`
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
for (const connector of data.connectors ?? []) {
|
|
247
|
+
const valid = isQualified(connector) ? isValidQualifiedName(connector) : isValidPrimitiveName(connector);
|
|
248
|
+
if (!valid) {
|
|
249
|
+
ctx.addIssue({
|
|
250
|
+
code: z7.ZodIssueCode.custom,
|
|
251
|
+
path: ["connectors"],
|
|
252
|
+
message: `Invalid connector name: "${connector}"`
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
for (const skill of data.agent.skills ?? []) {
|
|
257
|
+
const valid = isQualified(skill) ? isValidQualifiedSkillId(skill) : isValidSkillId(skill);
|
|
258
|
+
if (!valid) {
|
|
259
|
+
ctx.addIssue({
|
|
260
|
+
code: z7.ZodIssueCode.custom,
|
|
261
|
+
path: ["agent", "skills"],
|
|
262
|
+
message: `Invalid skill ID: "${skill}"`
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
for (const action of data.actions ?? []) {
|
|
267
|
+
const valid = isQualified(action) ? isValidQualifiedName(action) : isValidPrimitiveName(action);
|
|
268
|
+
if (!valid) {
|
|
269
|
+
ctx.addIssue({
|
|
270
|
+
code: z7.ZodIssueCode.custom,
|
|
271
|
+
path: ["actions"],
|
|
272
|
+
message: `Invalid action name: "${action}"`
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// ../../../private-packages/platform-core/dist/types/skill.js
|
|
279
|
+
var z8 = __toESM(require("zod"), 1);
|
|
280
|
+
var platformSkillInputSchema = z8.object({
|
|
281
|
+
name: z8.string().min(1),
|
|
282
|
+
description: z8.string().optional()
|
|
283
|
+
}).strict();
|
|
284
|
+
|
|
285
|
+
// src/agents/connector-server.ts
|
|
286
|
+
var import_node_crypto = require("crypto");
|
|
287
|
+
var import_node_http = require("http");
|
|
288
|
+
var z9 = __toESM(require("zod"), 1);
|
|
289
|
+
|
|
92
290
|
// src/agents/connector-wrap.ts
|
|
93
291
|
var MAX_TOOL_RESULT_SIZE = 10 * 1024 * 1024;
|
|
94
292
|
var isMcpContent = (val) => typeof val === "object" && val !== null && "__mcpPassThrough" in val && val.__mcpPassThrough === true;
|
|
@@ -144,132 +342,6 @@ var mcpResult = (content, isError) => ({
|
|
|
144
342
|
// src/agents/connector-server.ts
|
|
145
343
|
var MAX_BODY_SIZE = 10 * 1024 * 1024;
|
|
146
344
|
|
|
147
|
-
// src/agents/types/action.ts
|
|
148
|
-
var z2 = __toESM(require("zod"), 1);
|
|
149
|
-
var ACTION_NAME_REGEX = /^[a-z0-9][a-z0-9-]{0,62}[a-z0-9]$/;
|
|
150
|
-
var isValidActionName = (name) => name.length === 1 ? /^[a-z0-9]$/.test(name) : ACTION_NAME_REGEX.test(name);
|
|
151
|
-
var actionVariantConfigSchema = z2.object({
|
|
152
|
-
schema: z2.record(z2.string(), z2.unknown()),
|
|
153
|
-
webhook: z2.string().url().optional(),
|
|
154
|
-
hasHandler: z2.boolean()
|
|
155
|
-
});
|
|
156
|
-
var actionsConfigSchema = z2.object({
|
|
157
|
-
variants: z2.record(z2.string(), actionVariantConfigSchema)
|
|
158
|
-
}).strict();
|
|
159
|
-
|
|
160
|
-
// src/agents/types/environment.ts
|
|
161
|
-
var z3 = __toESM(require("zod"), 1);
|
|
162
|
-
var environmentSchema = z3.enum(["dev", "staging", "prod"]);
|
|
163
|
-
|
|
164
|
-
// src/agents/types/identity.ts
|
|
165
|
-
var z4 = __toESM(require("zod"), 1);
|
|
166
|
-
var jitPolicySchema = z4.enum(["auto-approve", "policy-based", "require-approval"]);
|
|
167
|
-
var identityConfigSchema = z4.object({
|
|
168
|
-
basePermissions: z4.array(z4.string()),
|
|
169
|
-
requestablePermissions: z4.array(z4.string()).optional(),
|
|
170
|
-
jitPolicy: jitPolicySchema.optional(),
|
|
171
|
-
maxJitDurationMinutes: z4.number().int().positive().optional()
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
// src/agents/types/notifications.ts
|
|
175
|
-
var z5 = __toESM(require("zod"), 1);
|
|
176
|
-
var notificationConfigSchema = z5.object({
|
|
177
|
-
slack: z5.string().optional(),
|
|
178
|
-
onSuccess: z5.boolean().optional(),
|
|
179
|
-
onFailure: z5.boolean().optional(),
|
|
180
|
-
onTimeout: z5.boolean().optional()
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
// src/agents/types/platform-agent.ts
|
|
184
|
-
var z9 = __toESM(require("zod"), 1);
|
|
185
|
-
|
|
186
|
-
// src/agents/types/resources.ts
|
|
187
|
-
var z6 = __toESM(require("zod"), 1);
|
|
188
|
-
var resourceLimitsSchema = z6.object({
|
|
189
|
-
maxTokens: z6.number().int().positive().optional(),
|
|
190
|
-
maxCostUsd: z6.number().positive().optional(),
|
|
191
|
-
timeoutSeconds: z6.number().int().positive().optional()
|
|
192
|
-
});
|
|
193
|
-
var retryPolicySchema = z6.object({
|
|
194
|
-
maxAttempts: z6.number().int().min(1).optional(),
|
|
195
|
-
backoffSeconds: z6.number().positive().optional()
|
|
196
|
-
});
|
|
197
|
-
var concurrencyPolicySchema = z6.object({
|
|
198
|
-
maxParallelRuns: z6.number().int().min(1).optional()
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
// src/agents/types/team.ts
|
|
202
|
-
var z7 = __toESM(require("zod"), 1);
|
|
203
|
-
var teamConfigSchema = z7.object({
|
|
204
|
-
members: z7.array(z7.string()).min(1),
|
|
205
|
-
maxConcurrentWorkers: z7.number().int().min(1).optional(),
|
|
206
|
-
maxTokenBudgetPerWorker: z7.number().int().positive().optional(),
|
|
207
|
-
maxDurationPerWorker: z7.number().positive().optional()
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
// src/agents/types/trigger.ts
|
|
211
|
-
var z8 = __toESM(require("zod"), 1);
|
|
212
|
-
var cronTriggerSchema = z8.object({
|
|
213
|
-
type: z8.literal("cron"),
|
|
214
|
-
expression: z8.string(),
|
|
215
|
-
timezone: z8.string().optional()
|
|
216
|
-
});
|
|
217
|
-
var webhookTriggerSchema = z8.object({
|
|
218
|
-
type: z8.literal("webhook"),
|
|
219
|
-
path: z8.string().startsWith("/"),
|
|
220
|
-
method: z8.enum(["POST", "GET"]).optional()
|
|
221
|
-
});
|
|
222
|
-
var eventTriggerSchema = z8.object({
|
|
223
|
-
type: z8.literal("event"),
|
|
224
|
-
source: z8.string(),
|
|
225
|
-
event: z8.string()
|
|
226
|
-
});
|
|
227
|
-
var apiTriggerSchema = z8.object({ type: z8.literal("api") });
|
|
228
|
-
var manualTriggerSchema = z8.object({ type: z8.literal("manual") });
|
|
229
|
-
var triggerConfigSchema = z8.discriminatedUnion("type", [
|
|
230
|
-
cronTriggerSchema,
|
|
231
|
-
webhookTriggerSchema,
|
|
232
|
-
eventTriggerSchema,
|
|
233
|
-
apiTriggerSchema,
|
|
234
|
-
manualTriggerSchema
|
|
235
|
-
]);
|
|
236
|
-
|
|
237
|
-
// src/agents/types/platform-agent.ts
|
|
238
|
-
var thinkingLevelSchema = z9.enum(["low", "medium", "high"]);
|
|
239
|
-
var logLevelSchema = z9.enum(["silent", "debug", "info", "warn", "error"]);
|
|
240
|
-
var agentDefinitionSchema = z9.object({
|
|
241
|
-
name: z9.string().min(1),
|
|
242
|
-
model: z9.string().min(1),
|
|
243
|
-
instructions: z9.string().min(1),
|
|
244
|
-
description: z9.string().optional(),
|
|
245
|
-
skills: z9.array(z9.string()).optional(),
|
|
246
|
-
temperature: z9.number().min(0).max(2).optional(),
|
|
247
|
-
allowTemperatureOverride: z9.boolean().optional(),
|
|
248
|
-
maxOutputTokens: z9.number().int().positive().optional(),
|
|
249
|
-
thinkingLevel: thinkingLevelSchema.optional(),
|
|
250
|
-
logLevel: logLevelSchema.optional()
|
|
251
|
-
}).strict();
|
|
252
|
-
var platformAgentConfigSchema = z9.object({
|
|
253
|
-
agent: agentDefinitionSchema,
|
|
254
|
-
connectors: z9.array(z9.string()).optional(),
|
|
255
|
-
triggers: z9.array(triggerConfigSchema),
|
|
256
|
-
identity: identityConfigSchema.optional(),
|
|
257
|
-
resources: resourceLimitsSchema.optional(),
|
|
258
|
-
retries: retryPolicySchema.optional(),
|
|
259
|
-
concurrency: concurrencyPolicySchema.optional(),
|
|
260
|
-
team: teamConfigSchema.optional(),
|
|
261
|
-
notifications: notificationConfigSchema.optional(),
|
|
262
|
-
environment: environmentSchema.optional(),
|
|
263
|
-
actions: actionsConfigSchema.optional()
|
|
264
|
-
}).strict();
|
|
265
|
-
|
|
266
|
-
// src/agents/types/skill.ts
|
|
267
|
-
var z10 = __toESM(require("zod"), 1);
|
|
268
|
-
var platformSkillInputSchema = z10.object({
|
|
269
|
-
name: z10.string().min(1),
|
|
270
|
-
description: z10.string().optional()
|
|
271
|
-
}).strict();
|
|
272
|
-
|
|
273
345
|
// src/agents/define.ts
|
|
274
346
|
var FORBIDDEN_AGENT_KEYS = ["tools", "team", "kernel"];
|
|
275
347
|
var isAgentInstance = (value) => value != null && typeof value === "object" && "definition" in value && "name" in value && "run" in value && typeof value.run === "function";
|
|
@@ -290,7 +362,8 @@ var isPlatformAgent = (v) => v != null && typeof v === "object" && v.__type ===
|
|
|
290
362
|
var normalizeSkillRef = (ref) => isPlatformSkill(ref) ? ref.name : ref;
|
|
291
363
|
var normalizeConnectorRef = (ref) => isPlatformConnector(ref) ? ref.name : ref;
|
|
292
364
|
var normalizeTeamMember = (ref) => isPlatformAgent(ref) ? ref.config.agent.name : ref;
|
|
293
|
-
var
|
|
365
|
+
var isPlatformAction = (v) => v != null && typeof v === "object" && v.__type === "PlatformAction";
|
|
366
|
+
var normalizeActionRef = (ref) => isPlatformAction(ref) ? ref.name : ref;
|
|
294
367
|
var definePlatformAgent = (config) => {
|
|
295
368
|
assertNoInjection(config.agent);
|
|
296
369
|
let agentDef;
|
|
@@ -301,7 +374,7 @@ var definePlatformAgent = (config) => {
|
|
|
301
374
|
runtime = config.agent;
|
|
302
375
|
} else {
|
|
303
376
|
const {
|
|
304
|
-
outputSchema:
|
|
377
|
+
outputSchema: os2,
|
|
305
378
|
skills: rawSkills,
|
|
306
379
|
...rest
|
|
307
380
|
} = config.agent;
|
|
@@ -309,26 +382,39 @@ var definePlatformAgent = (config) => {
|
|
|
309
382
|
...rest,
|
|
310
383
|
skills: rawSkills?.map(normalizeSkillRef)
|
|
311
384
|
};
|
|
312
|
-
outputSchema =
|
|
385
|
+
outputSchema = os2;
|
|
313
386
|
}
|
|
314
387
|
const normalizedConnectors = config.connectors?.map(normalizeConnectorRef);
|
|
315
388
|
const normalizedTeam = config.team ? { ...config.team, members: config.team.members.map(normalizeTeamMember) } : void 0;
|
|
316
389
|
const teamAgents = config.team?.members.filter((m) => isPlatformAgent(m));
|
|
317
|
-
|
|
390
|
+
const actionObjects = config.actions?.filter((a) => isPlatformAction(a));
|
|
391
|
+
const normalizedActions = config.actions?.map(normalizeActionRef);
|
|
318
392
|
let actionZodSchemas;
|
|
319
393
|
let actionHandlers;
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
const
|
|
324
|
-
|
|
394
|
+
let actionWebhooks;
|
|
395
|
+
if (actionObjects && actionObjects.length > 0) {
|
|
396
|
+
const schemas = {};
|
|
397
|
+
const handlers = {};
|
|
398
|
+
const webhooks = {};
|
|
399
|
+
for (const action of actionObjects) {
|
|
400
|
+
schemas[action.name] = action.zodSchema;
|
|
401
|
+
if (action.handler) {
|
|
402
|
+
handlers[action.name] = action.handler;
|
|
403
|
+
}
|
|
404
|
+
if (action.config.webhook) {
|
|
405
|
+
webhooks[action.name] = action.config.webhook;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
actionZodSchemas = Object.freeze(schemas);
|
|
409
|
+
actionHandlers = Object.keys(handlers).length > 0 ? Object.freeze(handlers) : void 0;
|
|
410
|
+
actionWebhooks = Object.keys(webhooks).length > 0 ? Object.freeze(webhooks) : void 0;
|
|
325
411
|
}
|
|
326
412
|
const parsed = platformAgentConfigSchema.parse({
|
|
327
413
|
...config,
|
|
328
414
|
agent: agentDef,
|
|
329
415
|
connectors: normalizedConnectors,
|
|
330
416
|
team: normalizedTeam,
|
|
331
|
-
actions:
|
|
417
|
+
actions: normalizedActions
|
|
332
418
|
});
|
|
333
419
|
return {
|
|
334
420
|
__type: "PlatformAgent",
|
|
@@ -337,61 +423,43 @@ var definePlatformAgent = (config) => {
|
|
|
337
423
|
outputSchema,
|
|
338
424
|
actionZodSchemas,
|
|
339
425
|
actionHandlers,
|
|
426
|
+
actionWebhooks,
|
|
340
427
|
teamAgents: teamAgents && teamAgents.length > 0 ? teamAgents : void 0
|
|
341
428
|
};
|
|
342
429
|
};
|
|
343
430
|
|
|
344
431
|
// src/agents/define-actions.ts
|
|
345
|
-
var
|
|
346
|
-
var defineAction = (input) =>
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
352
|
-
if (entries.length > 20) {
|
|
353
|
-
throw new Error("defineActions() supports a maximum of 20 action variants");
|
|
354
|
-
}
|
|
355
|
-
const serialized = {};
|
|
356
|
-
const zodSchemas = {};
|
|
357
|
-
const handlers = {};
|
|
358
|
-
for (const [name, variant] of entries) {
|
|
359
|
-
if (!isValidActionName(name)) {
|
|
360
|
-
throw new Error(
|
|
361
|
-
`Invalid action name "${name}": must be lowercase alphanumeric with hyphens, 1-64 chars`
|
|
362
|
-
);
|
|
363
|
-
}
|
|
364
|
-
const v = variant;
|
|
365
|
-
serialized[name] = {
|
|
366
|
-
schema: z11.toJSONSchema(v.schema, { target: "draft-2020-12" }),
|
|
367
|
-
webhook: v.webhook,
|
|
368
|
-
hasHandler: !!v.handler
|
|
369
|
-
};
|
|
370
|
-
zodSchemas[name] = v.schema;
|
|
371
|
-
if (v.handler) {
|
|
372
|
-
handlers[name] = v.handler;
|
|
373
|
-
}
|
|
432
|
+
var z10 = __toESM(require("zod"), 1);
|
|
433
|
+
var defineAction = (input) => {
|
|
434
|
+
if (!input.name || !isValidActionName(input.name)) {
|
|
435
|
+
throw new Error(
|
|
436
|
+
`Invalid action name "${input.name}": must be lowercase alphanumeric with hyphens, 1-64 chars`
|
|
437
|
+
);
|
|
374
438
|
}
|
|
375
439
|
return Object.freeze({
|
|
376
|
-
__type: "
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
440
|
+
__type: "PlatformAction",
|
|
441
|
+
name: input.name,
|
|
442
|
+
config: Object.freeze({
|
|
443
|
+
schema: z10.toJSONSchema(input.schema, { target: "draft-2020-12" }),
|
|
444
|
+
webhook: input.webhook,
|
|
445
|
+
hasHandler: !!input.handler
|
|
446
|
+
}),
|
|
447
|
+
zodSchema: input.schema,
|
|
448
|
+
handler: input.handler
|
|
380
449
|
});
|
|
381
450
|
};
|
|
382
451
|
var buildActionOutputSchema = (actions) => {
|
|
383
|
-
|
|
384
|
-
if (entries.length === 0) {
|
|
452
|
+
if (actions.length === 0) {
|
|
385
453
|
throw new Error("Cannot build output schema from empty action definitions");
|
|
386
454
|
}
|
|
387
|
-
const variants =
|
|
388
|
-
(
|
|
455
|
+
const variants = actions.map(
|
|
456
|
+
(action) => z10.object({ action: z10.literal(action.name) }).extend(action.zodSchema.shape)
|
|
389
457
|
);
|
|
390
458
|
const [first, ...rest] = variants;
|
|
391
459
|
if (!first) {
|
|
392
460
|
throw new Error("Cannot build output schema from empty action definitions");
|
|
393
461
|
}
|
|
394
|
-
return
|
|
462
|
+
return z10.discriminatedUnion("action", [first, ...rest]);
|
|
395
463
|
};
|
|
396
464
|
|
|
397
465
|
// src/agents/define-connector.ts
|
|
@@ -426,9 +494,10 @@ var defineSkill = (input) => {
|
|
|
426
494
|
|
|
427
495
|
// src/cli/discover.ts
|
|
428
496
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
497
|
+
var import_node_module = require("module");
|
|
429
498
|
var import_node_path = __toESM(require("path"), 1);
|
|
430
499
|
var import_node_url = require("url");
|
|
431
|
-
var
|
|
500
|
+
var z11 = __toESM(require("zod"), 1);
|
|
432
501
|
|
|
433
502
|
// src/cli/log.ts
|
|
434
503
|
var supportsColor = !("NO_COLOR" in process.env) && process.env.FORCE_COLOR !== "0" && (process.stderr.isTTY ?? false);
|
|
@@ -447,24 +516,65 @@ var cyan = code(36, 39);
|
|
|
447
516
|
// src/cli/discover.ts
|
|
448
517
|
var MANIFEST_START = "---KRAKEN-MANIFEST-START---";
|
|
449
518
|
var MANIFEST_END = "---KRAKEN-MANIFEST-END---";
|
|
450
|
-
var skillEntrySchema =
|
|
451
|
-
name:
|
|
452
|
-
path:
|
|
453
|
-
content:
|
|
519
|
+
var skillEntrySchema = z11.object({
|
|
520
|
+
name: z11.string().min(1),
|
|
521
|
+
path: z11.string().min(1),
|
|
522
|
+
content: z11.string()
|
|
523
|
+
});
|
|
524
|
+
var toolSpecSchema = z11.object({
|
|
525
|
+
name: z11.string(),
|
|
526
|
+
description: z11.string(),
|
|
527
|
+
parameters: z11.record(z11.string(), z11.unknown()).default({}),
|
|
528
|
+
annotations: z11.object({
|
|
529
|
+
readOnlyHint: z11.boolean().optional(),
|
|
530
|
+
destructiveHint: z11.boolean().optional(),
|
|
531
|
+
idempotentHint: z11.boolean().optional()
|
|
532
|
+
}).optional()
|
|
454
533
|
});
|
|
455
|
-
var
|
|
456
|
-
name:
|
|
457
|
-
|
|
534
|
+
var resourceSpecSchema = z11.object({
|
|
535
|
+
name: z11.string(),
|
|
536
|
+
uri: z11.string(),
|
|
537
|
+
description: z11.string(),
|
|
538
|
+
mimeType: z11.string().optional()
|
|
458
539
|
});
|
|
459
|
-
var
|
|
460
|
-
name:
|
|
461
|
-
|
|
540
|
+
var promptSpecSchema = z11.object({
|
|
541
|
+
name: z11.string(),
|
|
542
|
+
description: z11.string(),
|
|
543
|
+
arguments: z11.array(
|
|
544
|
+
z11.object({
|
|
545
|
+
name: z11.string(),
|
|
546
|
+
description: z11.string().optional(),
|
|
547
|
+
required: z11.boolean().optional()
|
|
548
|
+
})
|
|
549
|
+
).optional()
|
|
550
|
+
});
|
|
551
|
+
var connectorEntrySchema = z11.object({
|
|
552
|
+
name: z11.string().min(1),
|
|
553
|
+
path: z11.string().min(1),
|
|
554
|
+
toolSpecs: z11.array(toolSpecSchema).default([]),
|
|
555
|
+
resourceSpecs: z11.array(resourceSpecSchema).default([]),
|
|
556
|
+
promptSpecs: z11.array(promptSpecSchema).default([])
|
|
557
|
+
});
|
|
558
|
+
var agentEntrySchema = z11.object({
|
|
559
|
+
name: z11.string().min(1),
|
|
560
|
+
entryPoint: z11.string().min(1),
|
|
462
561
|
config: platformAgentConfigSchema
|
|
463
562
|
});
|
|
464
|
-
var
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
563
|
+
var actionConfigSchema = z11.object({
|
|
564
|
+
schema: z11.record(z11.string(), z11.unknown()),
|
|
565
|
+
webhook: z11.string().url().optional(),
|
|
566
|
+
hasHandler: z11.boolean()
|
|
567
|
+
});
|
|
568
|
+
var actionEntrySchema = z11.object({
|
|
569
|
+
name: z11.string().min(1),
|
|
570
|
+
entryPoint: z11.string().min(1),
|
|
571
|
+
config: actionConfigSchema
|
|
572
|
+
});
|
|
573
|
+
var projectManifestSchema = z11.object({
|
|
574
|
+
agents: z11.array(agentEntrySchema),
|
|
575
|
+
skills: z11.array(skillEntrySchema),
|
|
576
|
+
connectors: z11.array(connectorEntrySchema),
|
|
577
|
+
actions: z11.array(actionEntrySchema).default([])
|
|
468
578
|
});
|
|
469
579
|
var MAX_SKILL_SIZE = 100 * 1024;
|
|
470
580
|
var parseManifestFromOutput = (stdout) => {
|
|
@@ -487,6 +597,31 @@ var parseManifestFromOutput = (stdout) => {
|
|
|
487
597
|
return result.data;
|
|
488
598
|
};
|
|
489
599
|
|
|
600
|
+
// src/internal/secret-string.ts
|
|
601
|
+
var import_node_util = require("util");
|
|
602
|
+
var SecretString = class {
|
|
603
|
+
#value;
|
|
604
|
+
constructor(value) {
|
|
605
|
+
this.#value = value;
|
|
606
|
+
}
|
|
607
|
+
unmasked() {
|
|
608
|
+
return this.#value;
|
|
609
|
+
}
|
|
610
|
+
toJSON() {
|
|
611
|
+
return "[REDACTED]";
|
|
612
|
+
}
|
|
613
|
+
toString() {
|
|
614
|
+
return "[REDACTED]";
|
|
615
|
+
}
|
|
616
|
+
[Symbol.toPrimitive]() {
|
|
617
|
+
return "[REDACTED]";
|
|
618
|
+
}
|
|
619
|
+
[import_node_util.inspect.custom]() {
|
|
620
|
+
return "SecretString([REDACTED])";
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
var unwrapSecret = (value) => value instanceof SecretString ? value.unmasked() : value;
|
|
624
|
+
|
|
490
625
|
// src/platform/http.ts
|
|
491
626
|
var PlatformError = class extends Error {
|
|
492
627
|
constructor(message, status) {
|
|
@@ -494,6 +629,7 @@ var PlatformError = class extends Error {
|
|
|
494
629
|
this.status = status;
|
|
495
630
|
this.name = "PlatformError";
|
|
496
631
|
}
|
|
632
|
+
status;
|
|
497
633
|
};
|
|
498
634
|
var HttpClient = class {
|
|
499
635
|
baseUrlForStream;
|
|
@@ -502,7 +638,7 @@ var HttpClient = class {
|
|
|
502
638
|
constructor(config) {
|
|
503
639
|
this.baseUrl = config.baseUrl.replace(/\/+$/, "");
|
|
504
640
|
this.baseUrlForStream = this.baseUrl;
|
|
505
|
-
this.apiKey = config.apiKey;
|
|
641
|
+
this.apiKey = new SecretString(config.apiKey);
|
|
506
642
|
const isLocalhost = this.baseUrl.includes("localhost") || this.baseUrl.includes("127.0.0.1");
|
|
507
643
|
if (this.baseUrl.startsWith("http://") && !isLocalhost) {
|
|
508
644
|
console.warn(
|
|
@@ -510,24 +646,24 @@ var HttpClient = class {
|
|
|
510
646
|
);
|
|
511
647
|
}
|
|
512
648
|
}
|
|
513
|
-
async get(
|
|
514
|
-
const url = this.buildUrl(
|
|
649
|
+
async get(path3, params) {
|
|
650
|
+
const url = this.buildUrl(path3, params);
|
|
515
651
|
const response = await fetch(url, {
|
|
516
652
|
method: "GET",
|
|
517
653
|
headers: this.authHeaders()
|
|
518
654
|
});
|
|
519
655
|
return this.handleResponse(response);
|
|
520
656
|
}
|
|
521
|
-
async post(
|
|
522
|
-
const response = await fetch(this.buildUrl(
|
|
657
|
+
async post(path3, body) {
|
|
658
|
+
const response = await fetch(this.buildUrl(path3), {
|
|
523
659
|
method: "POST",
|
|
524
660
|
headers: { ...this.authHeaders(), "Content-Type": "application/json" },
|
|
525
661
|
body: body ? JSON.stringify(body) : void 0
|
|
526
662
|
});
|
|
527
663
|
return this.handleResponse(response);
|
|
528
664
|
}
|
|
529
|
-
async postStream(
|
|
530
|
-
const response = await fetch(this.buildUrl(
|
|
665
|
+
async postStream(path3, body, signal) {
|
|
666
|
+
const response = await fetch(this.buildUrl(path3), {
|
|
531
667
|
method: "POST",
|
|
532
668
|
headers: {
|
|
533
669
|
...this.authHeaders(),
|
|
@@ -543,14 +679,14 @@ var HttpClient = class {
|
|
|
543
679
|
}
|
|
544
680
|
return response;
|
|
545
681
|
}
|
|
546
|
-
buildUrl(
|
|
547
|
-
const url = `${this.baseUrl}${
|
|
682
|
+
buildUrl(path3, params) {
|
|
683
|
+
const url = `${this.baseUrl}${path3}`;
|
|
548
684
|
if (!params || Object.keys(params).length === 0) return url;
|
|
549
685
|
const qs = new URLSearchParams(params).toString();
|
|
550
686
|
return `${url}?${qs}`;
|
|
551
687
|
}
|
|
552
688
|
authHeaders() {
|
|
553
|
-
return { Authorization: `Bearer ${this.apiKey}` };
|
|
689
|
+
return { Authorization: `Bearer ${unwrapSecret(this.apiKey)}` };
|
|
554
690
|
}
|
|
555
691
|
async handleResponse(response) {
|
|
556
692
|
if (!response.ok) {
|
|
@@ -631,6 +767,8 @@ var AgentHandle = class {
|
|
|
631
767
|
this.agentId = agentId;
|
|
632
768
|
this.threadId = opts?.threadId;
|
|
633
769
|
}
|
|
770
|
+
http;
|
|
771
|
+
agentId;
|
|
634
772
|
actionHandlers = /* @__PURE__ */ new Map();
|
|
635
773
|
threadId;
|
|
636
774
|
onAction(name, handler) {
|
|
@@ -723,6 +861,9 @@ var AgentThread = class {
|
|
|
723
861
|
this.agentId = agentId;
|
|
724
862
|
this.threadId = threadId;
|
|
725
863
|
}
|
|
864
|
+
http;
|
|
865
|
+
agentId;
|
|
866
|
+
threadId;
|
|
726
867
|
async sendMessage(content, opts) {
|
|
727
868
|
const response = await this.http.postStream(
|
|
728
869
|
`/api/v1/agents/${this.agentId}/threads/${this.threadId}/messages`,
|
|
@@ -743,6 +884,7 @@ var AgentsNamespace = class {
|
|
|
743
884
|
constructor(http) {
|
|
744
885
|
this.http = http;
|
|
745
886
|
}
|
|
887
|
+
http;
|
|
746
888
|
async list() {
|
|
747
889
|
const result = await this.http.get("/api/v1/agents");
|
|
748
890
|
return result.data;
|
|
@@ -768,11 +910,39 @@ var buildPaginationQuery = (params) => {
|
|
|
768
910
|
return Object.keys(qs).length > 0 ? qs : void 0;
|
|
769
911
|
};
|
|
770
912
|
|
|
913
|
+
// src/cli/credentials.ts
|
|
914
|
+
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
915
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
916
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
917
|
+
var credentialsDir = () => import_node_path2.default.join(import_node_os.default.homedir(), ".kraken-ai");
|
|
918
|
+
var credentialsPath = () => import_node_path2.default.join(credentialsDir(), "credentials.json");
|
|
919
|
+
var loadCredentials = () => {
|
|
920
|
+
const filePath = credentialsPath();
|
|
921
|
+
let creds = null;
|
|
922
|
+
if (import_node_fs2.default.existsSync(filePath)) {
|
|
923
|
+
try {
|
|
924
|
+
creds = JSON.parse(import_node_fs2.default.readFileSync(filePath, "utf-8"));
|
|
925
|
+
} catch {
|
|
926
|
+
return null;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
const envKey = process.env.KRAKEN_API_KEY;
|
|
930
|
+
const envUrl = process.env.KRAKEN_BASE_URL;
|
|
931
|
+
if (envKey || envUrl) {
|
|
932
|
+
return {
|
|
933
|
+
apiKey: envKey ?? creds?.apiKey ?? "",
|
|
934
|
+
baseUrl: envUrl ?? creds?.baseUrl ?? ""
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
return creds;
|
|
938
|
+
};
|
|
939
|
+
|
|
771
940
|
// src/platform/data.ts
|
|
772
941
|
var DataNamespace = class {
|
|
773
942
|
constructor(http) {
|
|
774
943
|
this.http = http;
|
|
775
944
|
}
|
|
945
|
+
http;
|
|
776
946
|
async list() {
|
|
777
947
|
const result = await this.http.get("/api/v1/data/queries");
|
|
778
948
|
return result.data;
|
|
@@ -789,18 +959,19 @@ var DataNamespace = class {
|
|
|
789
959
|
};
|
|
790
960
|
|
|
791
961
|
// src/platform/pipelines.ts
|
|
792
|
-
var
|
|
962
|
+
var z12 = __toESM(require("zod"), 1);
|
|
793
963
|
var PipelinesNamespace = class {
|
|
794
964
|
constructor(http) {
|
|
795
965
|
this.http = http;
|
|
796
966
|
}
|
|
967
|
+
http;
|
|
797
968
|
async query(pipeline, queryName, schema, params) {
|
|
798
969
|
const result = await this.http.post(
|
|
799
970
|
`/api/v1/pipelines/${encodeURIComponent(pipeline)}/queries/${encodeURIComponent(queryName)}`,
|
|
800
971
|
params
|
|
801
972
|
);
|
|
802
973
|
try {
|
|
803
|
-
return
|
|
974
|
+
return z12.array(schema.returns).parse(result.rows);
|
|
804
975
|
} catch (e) {
|
|
805
976
|
throw new Error(
|
|
806
977
|
`Pipeline schema may have changed \u2014 run 'kraken generate' to update types.
|
|
@@ -816,6 +987,7 @@ var RunsNamespace = class {
|
|
|
816
987
|
constructor(http) {
|
|
817
988
|
this.http = http;
|
|
818
989
|
}
|
|
990
|
+
http;
|
|
819
991
|
async start(params) {
|
|
820
992
|
return this.http.post("/api/v1/runs", params);
|
|
821
993
|
}
|
|
@@ -870,6 +1042,22 @@ var RunsNamespace = class {
|
|
|
870
1042
|
};
|
|
871
1043
|
|
|
872
1044
|
// src/platform/client.ts
|
|
1045
|
+
var resolveConfig = (config) => {
|
|
1046
|
+
const creds = loadCredentials();
|
|
1047
|
+
const baseUrl = config?.baseUrl ?? creds?.baseUrl;
|
|
1048
|
+
const apiKey = config?.apiKey ?? creds?.apiKey;
|
|
1049
|
+
if (!baseUrl) {
|
|
1050
|
+
throw new Error(
|
|
1051
|
+
"No Kraken platform endpoint configured.\n\nEither:\n 1. Log in via the CLI: npx kraken login\n 2. Set the environment variable: export KRAKEN_BASE_URL=https://your-platform-url\n 3. Pass baseUrl to PlatformClient: new PlatformClient({ baseUrl: '...' })\n"
|
|
1052
|
+
);
|
|
1053
|
+
}
|
|
1054
|
+
if (!apiKey) {
|
|
1055
|
+
throw new Error(
|
|
1056
|
+
"No Kraken API key configured.\n\nEither:\n 1. Log in via the CLI: npx kraken login\n 2. Set the environment variable: export KRAKEN_API_KEY=your-api-key\n 3. Pass apiKey to PlatformClient: new PlatformClient({ apiKey: '...' })\n"
|
|
1057
|
+
);
|
|
1058
|
+
}
|
|
1059
|
+
return { baseUrl, apiKey };
|
|
1060
|
+
};
|
|
873
1061
|
var PlatformClient = class {
|
|
874
1062
|
agents;
|
|
875
1063
|
data;
|
|
@@ -877,9 +1065,8 @@ var PlatformClient = class {
|
|
|
877
1065
|
runs;
|
|
878
1066
|
http;
|
|
879
1067
|
constructor(config) {
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
this.http = new HttpClient(config);
|
|
1068
|
+
const resolved = resolveConfig(config);
|
|
1069
|
+
this.http = new HttpClient(resolved);
|
|
883
1070
|
this.agents = new AgentsNamespace(this.http);
|
|
884
1071
|
this.data = new DataNamespace(this.http);
|
|
885
1072
|
this.pipelines = new PipelinesNamespace(this.http);
|
|
@@ -905,30 +1092,18 @@ var PlatformClient = class {
|
|
|
905
1092
|
PlatformClient,
|
|
906
1093
|
PlatformError,
|
|
907
1094
|
SecurityError,
|
|
908
|
-
actionVariantConfigSchema,
|
|
909
|
-
actionsConfigSchema,
|
|
910
|
-
agentDefinitionSchema,
|
|
911
1095
|
buildActionOutputSchema,
|
|
912
|
-
concurrencyPolicySchema,
|
|
913
1096
|
defineAction,
|
|
914
|
-
defineActions,
|
|
915
1097
|
defineConnector,
|
|
916
1098
|
definePlatformAgent,
|
|
917
1099
|
defineSkill,
|
|
918
1100
|
defineTool,
|
|
919
|
-
|
|
920
|
-
identityConfigSchema,
|
|
1101
|
+
isQualified,
|
|
921
1102
|
isValidActionName,
|
|
922
|
-
jitPolicySchema,
|
|
923
1103
|
mcpResult,
|
|
924
|
-
|
|
1104
|
+
parse,
|
|
925
1105
|
parseManifestFromOutput,
|
|
926
|
-
|
|
927
|
-
projectManifestSchema,
|
|
928
|
-
resourceLimitsSchema,
|
|
929
|
-
retryPolicySchema,
|
|
930
|
-
teamConfigSchema,
|
|
931
|
-
triggerConfigSchema,
|
|
1106
|
+
qualify,
|
|
932
1107
|
wrapToolError,
|
|
933
1108
|
wrapToolResult
|
|
934
1109
|
});
|