@kraken-ai/platform 0.0.4 → 0.0.7
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-FTLOWV2N.js} +244 -67
- package/dist/chunk-FTLOWV2N.js.map +1 -0
- package/dist/cli.js +1103 -374
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +416 -240
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1107 -368
- package/dist/index.d.ts +1107 -368
- package/dist/index.js +183 -172
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +220 -45
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +265 -28
- package/dist/server.d.ts +265 -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/server.cjs
CHANGED
|
@@ -39,9 +39,9 @@ module.exports = __toCommonJS(server_exports);
|
|
|
39
39
|
// src/agents/connector-server.ts
|
|
40
40
|
var import_node_crypto = require("crypto");
|
|
41
41
|
var import_node_http = require("http");
|
|
42
|
-
var
|
|
42
|
+
var z9 = __toESM(require("zod"), 1);
|
|
43
43
|
|
|
44
|
-
//
|
|
44
|
+
// ../../../private-packages/platform-core/dist/errors.js
|
|
45
45
|
var ConnectorError = class extends Error {
|
|
46
46
|
code = "CONNECTOR_ERROR";
|
|
47
47
|
constructor(message) {
|
|
@@ -50,6 +50,206 @@ var ConnectorError = class extends Error {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
// ../../../private-packages/platform-core/dist/qualified-name.js
|
|
54
|
+
var parse = (qualified) => {
|
|
55
|
+
const slashIndex = qualified.indexOf("/");
|
|
56
|
+
if (slashIndex === -1) {
|
|
57
|
+
throw new Error(`Expected qualified name with "/" separator, got: "${qualified}"`);
|
|
58
|
+
}
|
|
59
|
+
if (qualified.indexOf("/", slashIndex + 1) !== -1) {
|
|
60
|
+
throw new Error(`Expected exactly one "/" in qualified name, got: "${qualified}"`);
|
|
61
|
+
}
|
|
62
|
+
const repoName = qualified.slice(0, slashIndex);
|
|
63
|
+
const primitiveName = qualified.slice(slashIndex + 1);
|
|
64
|
+
if (!repoName || !primitiveName) {
|
|
65
|
+
throw new Error(`Both repo and primitive segments must be non-empty, got: "${qualified}"`);
|
|
66
|
+
}
|
|
67
|
+
return { repoName, primitiveName };
|
|
68
|
+
};
|
|
69
|
+
var isQualified = (name) => {
|
|
70
|
+
const slashIndex = name.indexOf("/");
|
|
71
|
+
if (slashIndex === -1 || slashIndex === 0 || slashIndex === name.length - 1)
|
|
72
|
+
return false;
|
|
73
|
+
return name.indexOf("/", slashIndex + 1) === -1;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// ../../../private-packages/platform-core/dist/types/environment.js
|
|
77
|
+
var z = __toESM(require("zod"), 1);
|
|
78
|
+
var environmentSchema = z.enum(["dev", "staging", "prod"]);
|
|
79
|
+
|
|
80
|
+
// ../../../private-packages/platform-core/dist/types/identity.js
|
|
81
|
+
var z2 = __toESM(require("zod"), 1);
|
|
82
|
+
var jitPolicySchema = z2.enum(["auto-approve", "policy-based", "require-approval"]);
|
|
83
|
+
var identityConfigSchema = z2.object({
|
|
84
|
+
basePermissions: z2.array(z2.string()),
|
|
85
|
+
requestablePermissions: z2.array(z2.string()).optional(),
|
|
86
|
+
jitPolicy: jitPolicySchema.optional(),
|
|
87
|
+
maxJitDurationMinutes: z2.number().int().positive().optional()
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// ../../../private-packages/platform-core/dist/types/notifications.js
|
|
91
|
+
var z3 = __toESM(require("zod"), 1);
|
|
92
|
+
var notificationConfigSchema = z3.object({
|
|
93
|
+
slack: z3.string().optional(),
|
|
94
|
+
onSuccess: z3.boolean().optional(),
|
|
95
|
+
onFailure: z3.boolean().optional(),
|
|
96
|
+
onTimeout: z3.boolean().optional()
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// ../../../private-packages/platform-core/dist/types/platform-agent.js
|
|
100
|
+
var z7 = __toESM(require("zod"), 1);
|
|
101
|
+
|
|
102
|
+
// ../../../private-packages/platform-core/dist/validate.js
|
|
103
|
+
var PRIMITIVE_NAME_REGEX = /^[a-z0-9][a-z0-9-]{0,62}[a-z0-9]$/;
|
|
104
|
+
var isValidPrimitiveName = (name) => name.length === 1 ? /^[a-z0-9]$/.test(name) : PRIMITIVE_NAME_REGEX.test(name);
|
|
105
|
+
var SKILL_NAME_REGEX = /^[a-zA-Z0-9][a-zA-Z0-9-]{0,62}[a-zA-Z0-9]$/;
|
|
106
|
+
var isValidSkillName = (basename) => basename.length === 1 ? /^[a-zA-Z0-9]$/.test(basename) : SKILL_NAME_REGEX.test(basename);
|
|
107
|
+
var isValidSkillId = (id) => {
|
|
108
|
+
const base = id.endsWith(".md") ? id.slice(0, -3) : id;
|
|
109
|
+
return isValidSkillName(base);
|
|
110
|
+
};
|
|
111
|
+
var isValidQualifiedName = (name) => {
|
|
112
|
+
if (!isQualified(name))
|
|
113
|
+
return false;
|
|
114
|
+
const { repoName, primitiveName } = parse(name);
|
|
115
|
+
return isValidPrimitiveName(repoName) && isValidPrimitiveName(primitiveName);
|
|
116
|
+
};
|
|
117
|
+
var isValidQualifiedSkillId = (id) => {
|
|
118
|
+
if (!isQualified(id))
|
|
119
|
+
return false;
|
|
120
|
+
const { repoName, primitiveName } = parse(id);
|
|
121
|
+
return isValidPrimitiveName(repoName) && isValidSkillId(primitiveName);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// ../../../private-packages/platform-core/dist/types/resources.js
|
|
125
|
+
var z4 = __toESM(require("zod"), 1);
|
|
126
|
+
var resourceLimitsSchema = z4.object({
|
|
127
|
+
maxTokens: z4.number().int().positive().optional(),
|
|
128
|
+
maxCostUsd: z4.number().positive().optional(),
|
|
129
|
+
timeoutSeconds: z4.number().int().positive().optional()
|
|
130
|
+
});
|
|
131
|
+
var retryPolicySchema = z4.object({
|
|
132
|
+
maxAttempts: z4.number().int().min(1).optional(),
|
|
133
|
+
backoffSeconds: z4.number().positive().optional()
|
|
134
|
+
});
|
|
135
|
+
var concurrencyPolicySchema = z4.object({
|
|
136
|
+
maxParallelRuns: z4.number().int().min(1).optional()
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// ../../../private-packages/platform-core/dist/types/team.js
|
|
140
|
+
var z5 = __toESM(require("zod"), 1);
|
|
141
|
+
var teamConfigSchema = z5.object({
|
|
142
|
+
members: z5.array(z5.string()).min(1),
|
|
143
|
+
maxConcurrentWorkers: z5.number().int().min(1).optional(),
|
|
144
|
+
maxTokenBudgetPerWorker: z5.number().int().positive().optional(),
|
|
145
|
+
maxDurationPerWorker: z5.number().positive().optional()
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// ../../../private-packages/platform-core/dist/types/trigger.js
|
|
149
|
+
var z6 = __toESM(require("zod"), 1);
|
|
150
|
+
var cronTriggerSchema = z6.object({
|
|
151
|
+
type: z6.literal("cron"),
|
|
152
|
+
expression: z6.string(),
|
|
153
|
+
timezone: z6.string().optional()
|
|
154
|
+
});
|
|
155
|
+
var webhookTriggerSchema = z6.object({
|
|
156
|
+
type: z6.literal("webhook"),
|
|
157
|
+
path: z6.string().startsWith("/"),
|
|
158
|
+
method: z6.enum(["POST", "GET"]).optional()
|
|
159
|
+
});
|
|
160
|
+
var eventTriggerSchema = z6.object({
|
|
161
|
+
type: z6.literal("event"),
|
|
162
|
+
source: z6.string(),
|
|
163
|
+
event: z6.string()
|
|
164
|
+
});
|
|
165
|
+
var apiTriggerSchema = z6.object({ type: z6.literal("api") });
|
|
166
|
+
var manualTriggerSchema = z6.object({ type: z6.literal("manual") });
|
|
167
|
+
var triggerConfigSchema = z6.discriminatedUnion("type", [
|
|
168
|
+
cronTriggerSchema,
|
|
169
|
+
webhookTriggerSchema,
|
|
170
|
+
eventTriggerSchema,
|
|
171
|
+
apiTriggerSchema,
|
|
172
|
+
manualTriggerSchema
|
|
173
|
+
]);
|
|
174
|
+
|
|
175
|
+
// ../../../private-packages/platform-core/dist/types/platform-agent.js
|
|
176
|
+
var thinkingLevelSchema = z7.enum(["low", "medium", "high"]);
|
|
177
|
+
var logLevelSchema = z7.enum(["silent", "debug", "info", "warn", "error"]);
|
|
178
|
+
var agentDefinitionSchema = z7.object({
|
|
179
|
+
name: z7.string().min(1),
|
|
180
|
+
model: z7.string().min(1),
|
|
181
|
+
instructions: z7.string().min(1),
|
|
182
|
+
description: z7.string().optional(),
|
|
183
|
+
skills: z7.array(z7.string()).optional(),
|
|
184
|
+
temperature: z7.number().min(0).max(2).optional(),
|
|
185
|
+
allowTemperatureOverride: z7.boolean().optional(),
|
|
186
|
+
maxOutputTokens: z7.number().int().positive().optional(),
|
|
187
|
+
thinkingLevel: thinkingLevelSchema.optional(),
|
|
188
|
+
logLevel: logLevelSchema.optional()
|
|
189
|
+
}).strict();
|
|
190
|
+
var platformAgentConfigSchema = z7.object({
|
|
191
|
+
agent: agentDefinitionSchema,
|
|
192
|
+
connectors: z7.array(z7.string()).optional(),
|
|
193
|
+
triggers: z7.array(triggerConfigSchema),
|
|
194
|
+
identity: identityConfigSchema.optional(),
|
|
195
|
+
resources: resourceLimitsSchema.optional(),
|
|
196
|
+
retries: retryPolicySchema.optional(),
|
|
197
|
+
concurrency: concurrencyPolicySchema.optional(),
|
|
198
|
+
fast: z7.boolean().optional(),
|
|
199
|
+
team: teamConfigSchema.optional(),
|
|
200
|
+
notifications: notificationConfigSchema.optional(),
|
|
201
|
+
environment: environmentSchema.optional(),
|
|
202
|
+
actions: z7.array(z7.string()).optional()
|
|
203
|
+
}).strict().superRefine((data, ctx) => {
|
|
204
|
+
for (const member of data.team?.members ?? []) {
|
|
205
|
+
const valid = isQualified(member) ? isValidQualifiedName(member) : isValidPrimitiveName(member);
|
|
206
|
+
if (!valid) {
|
|
207
|
+
ctx.addIssue({
|
|
208
|
+
code: z7.ZodIssueCode.custom,
|
|
209
|
+
path: ["team", "members"],
|
|
210
|
+
message: `Invalid team member name: "${member}"`
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
for (const connector of data.connectors ?? []) {
|
|
215
|
+
const valid = isQualified(connector) ? isValidQualifiedName(connector) : isValidPrimitiveName(connector);
|
|
216
|
+
if (!valid) {
|
|
217
|
+
ctx.addIssue({
|
|
218
|
+
code: z7.ZodIssueCode.custom,
|
|
219
|
+
path: ["connectors"],
|
|
220
|
+
message: `Invalid connector name: "${connector}"`
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
for (const skill of data.agent.skills ?? []) {
|
|
225
|
+
const valid = isQualified(skill) ? isValidQualifiedSkillId(skill) : isValidSkillId(skill);
|
|
226
|
+
if (!valid) {
|
|
227
|
+
ctx.addIssue({
|
|
228
|
+
code: z7.ZodIssueCode.custom,
|
|
229
|
+
path: ["agent", "skills"],
|
|
230
|
+
message: `Invalid skill ID: "${skill}"`
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
for (const action of data.actions ?? []) {
|
|
235
|
+
const valid = isQualified(action) ? isValidQualifiedName(action) : isValidPrimitiveName(action);
|
|
236
|
+
if (!valid) {
|
|
237
|
+
ctx.addIssue({
|
|
238
|
+
code: z7.ZodIssueCode.custom,
|
|
239
|
+
path: ["actions"],
|
|
240
|
+
message: `Invalid action name: "${action}"`
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// ../../../private-packages/platform-core/dist/types/skill.js
|
|
247
|
+
var z8 = __toESM(require("zod"), 1);
|
|
248
|
+
var platformSkillInputSchema = z8.object({
|
|
249
|
+
name: z8.string().min(1),
|
|
250
|
+
description: z8.string().optional()
|
|
251
|
+
}).strict();
|
|
252
|
+
|
|
53
253
|
// src/agents/connector-wrap.ts
|
|
54
254
|
var MAX_TOOL_RESULT_SIZE = 10 * 1024 * 1024;
|
|
55
255
|
var isMcpContent = (val) => typeof val === "object" && val !== null && "__mcpPassThrough" in val && val.__mcpPassThrough === true;
|
|
@@ -125,7 +325,7 @@ var buildPromptArgsSchema = (def) => {
|
|
|
125
325
|
if (!def.arguments?.length) return void 0;
|
|
126
326
|
const shape = {};
|
|
127
327
|
for (const arg of def.arguments) {
|
|
128
|
-
shape[arg.name] = arg.required ?
|
|
328
|
+
shape[arg.name] = arg.required ? z9.string() : z9.string().optional();
|
|
129
329
|
}
|
|
130
330
|
return shape;
|
|
131
331
|
};
|
|
@@ -317,33 +517,19 @@ var import_node_readline = require("readline");
|
|
|
317
517
|
var import_kraken_ai2 = require("kraken-ai");
|
|
318
518
|
|
|
319
519
|
// src/agents/define-actions.ts
|
|
320
|
-
var
|
|
321
|
-
|
|
322
|
-
// src/agents/types/action.ts
|
|
323
|
-
var z2 = __toESM(require("zod"), 1);
|
|
324
|
-
var actionVariantConfigSchema = z2.object({
|
|
325
|
-
schema: z2.record(z2.string(), z2.unknown()),
|
|
326
|
-
webhook: z2.string().url().optional(),
|
|
327
|
-
hasHandler: z2.boolean()
|
|
328
|
-
});
|
|
329
|
-
var actionsConfigSchema = z2.object({
|
|
330
|
-
variants: z2.record(z2.string(), actionVariantConfigSchema)
|
|
331
|
-
}).strict();
|
|
332
|
-
|
|
333
|
-
// src/agents/define-actions.ts
|
|
520
|
+
var z10 = __toESM(require("zod"), 1);
|
|
334
521
|
var buildActionOutputSchema = (actions) => {
|
|
335
|
-
|
|
336
|
-
if (entries.length === 0) {
|
|
522
|
+
if (actions.length === 0) {
|
|
337
523
|
throw new Error("Cannot build output schema from empty action definitions");
|
|
338
524
|
}
|
|
339
|
-
const variants =
|
|
340
|
-
(
|
|
525
|
+
const variants = actions.map(
|
|
526
|
+
(action) => z10.object({ action: z10.literal(action.name) }).extend(action.zodSchema.shape)
|
|
341
527
|
);
|
|
342
528
|
const [first, ...rest] = variants;
|
|
343
529
|
if (!first) {
|
|
344
530
|
throw new Error("Cannot build output schema from empty action definitions");
|
|
345
531
|
}
|
|
346
|
-
return
|
|
532
|
+
return z10.discriminatedUnion("action", [first, ...rest]);
|
|
347
533
|
};
|
|
348
534
|
|
|
349
535
|
// src/cli/log.ts
|
|
@@ -409,15 +595,9 @@ var dispatchDevAction = async (output, zodSchemas, handlers, webhooks) => {
|
|
|
409
595
|
// src/dev-connectors.ts
|
|
410
596
|
var import_node_path = require("path");
|
|
411
597
|
var import_kraken_ai = require("kraken-ai");
|
|
412
|
-
|
|
413
|
-
// src/cli/validate.ts
|
|
414
|
-
var ENTITY_NAME_REGEX = /^[a-z0-9][a-z0-9-]{0,62}[a-z0-9]$/;
|
|
415
|
-
var isValidEntityName = (name) => name.length === 1 ? /^[a-z0-9]$/.test(name) : ENTITY_NAME_REGEX.test(name);
|
|
416
|
-
|
|
417
|
-
// src/dev-connectors.ts
|
|
418
598
|
var isPlatformConnector = (v) => v != null && typeof v === "object" && v.__type === "PlatformConnector";
|
|
419
599
|
var importConnector = async (name, projectRoot) => {
|
|
420
|
-
const basePath = (0, import_node_path.resolve)(projectRoot, "connectors", name, "index");
|
|
600
|
+
const basePath = (0, import_node_path.resolve)(projectRoot, "src", "connectors", name, "index");
|
|
421
601
|
for (const ext of [".ts", ".js"]) {
|
|
422
602
|
try {
|
|
423
603
|
const mod = await import(`${basePath}${ext}`);
|
|
@@ -542,9 +722,9 @@ var loadConnectorTools = async (connectorNames, projectRoot) => {
|
|
|
542
722
|
const root = projectRoot ?? process.cwd();
|
|
543
723
|
const connectors = [];
|
|
544
724
|
for (const name of connectorNames) {
|
|
545
|
-
if (!
|
|
725
|
+
if (!isValidPrimitiveName(name)) {
|
|
546
726
|
console.warn(
|
|
547
|
-
`[connector] Invalid connector name "${name}" \u2014 must match ${
|
|
727
|
+
`[connector] Invalid connector name "${name}" \u2014 must match ${PRIMITIVE_NAME_REGEX}. Skipping.`
|
|
548
728
|
);
|
|
549
729
|
continue;
|
|
550
730
|
}
|
|
@@ -577,7 +757,7 @@ var loadDotenv = () => {
|
|
|
577
757
|
var FRONTMATTER_RE = /^---\n[\s\S]*?\n---\n([\s\S]*)$/;
|
|
578
758
|
var resolveSkillContent = (refs) => refs.map((ref) => {
|
|
579
759
|
try {
|
|
580
|
-
return (0, import_node_fs.readFileSync)(`skills/${ref}`, "utf-8");
|
|
760
|
+
return (0, import_node_fs.readFileSync)(`src/skills/${ref}`, "utf-8");
|
|
581
761
|
} catch {
|
|
582
762
|
return ref;
|
|
583
763
|
}
|
|
@@ -620,12 +800,13 @@ ${connectorInstructions.join("\n\n")}`;
|
|
|
620
800
|
|
|
621
801
|
${actionInstructions}`;
|
|
622
802
|
}
|
|
623
|
-
|
|
624
|
-
__type: "
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
});
|
|
803
|
+
const actions = Object.entries(pa.actionZodSchemas).map(([name2, zodSchema]) => ({
|
|
804
|
+
__type: "PlatformAction",
|
|
805
|
+
name: name2,
|
|
806
|
+
config: { schema: {}, hasHandler: false },
|
|
807
|
+
zodSchema
|
|
808
|
+
}));
|
|
809
|
+
outputSchema = buildActionOutputSchema(actions);
|
|
629
810
|
}
|
|
630
811
|
let team;
|
|
631
812
|
if (pa.teamAgents && pa.teamAgents.length > 0) {
|
|
@@ -705,18 +886,12 @@ var runDev = async (agent) => {
|
|
|
705
886
|
if (result.status === "complete") {
|
|
706
887
|
const output = typeof result.output === "string" ? result.output : JSON.stringify(result.output, null, 2);
|
|
707
888
|
if (hasActions && agent.actionZodSchemas && result.output != null && typeof result.output === "object" && "action" in result.output) {
|
|
708
|
-
const webhooks = {};
|
|
709
|
-
if (agent.config.actions?.variants) {
|
|
710
|
-
for (const [k, v] of Object.entries(agent.config.actions.variants)) {
|
|
711
|
-
webhooks[k] = v.webhook;
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
889
|
try {
|
|
715
890
|
const dispatched = await dispatchDevAction(
|
|
716
891
|
result.output,
|
|
717
892
|
agent.actionZodSchemas,
|
|
718
893
|
agent.actionHandlers,
|
|
719
|
-
|
|
894
|
+
agent.actionWebhooks ?? {}
|
|
720
895
|
);
|
|
721
896
|
console.log(`
|
|
722
897
|
${cyan("Action:")} ${green(dispatched.actionName)}`);
|