@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.js
CHANGED
|
@@ -2,129 +2,18 @@ import {
|
|
|
2
2
|
ACTION_NAME_REGEX,
|
|
3
3
|
ConnectorError,
|
|
4
4
|
SecurityError,
|
|
5
|
-
actionVariantConfigSchema,
|
|
6
|
-
actionsConfigSchema,
|
|
7
5
|
buildActionOutputSchema,
|
|
8
6
|
defineAction,
|
|
9
|
-
|
|
7
|
+
isQualified,
|
|
10
8
|
isValidActionName,
|
|
11
9
|
mcpResult,
|
|
10
|
+
parse,
|
|
11
|
+
platformAgentConfigSchema,
|
|
12
|
+
platformSkillInputSchema,
|
|
13
|
+
qualify,
|
|
12
14
|
wrapToolError,
|
|
13
15
|
wrapToolResult
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
|
|
16
|
-
// src/agents/types/environment.ts
|
|
17
|
-
import * as z from "zod";
|
|
18
|
-
var environmentSchema = z.enum(["dev", "staging", "prod"]);
|
|
19
|
-
|
|
20
|
-
// src/agents/types/identity.ts
|
|
21
|
-
import * as z2 from "zod";
|
|
22
|
-
var jitPolicySchema = z2.enum(["auto-approve", "policy-based", "require-approval"]);
|
|
23
|
-
var identityConfigSchema = z2.object({
|
|
24
|
-
basePermissions: z2.array(z2.string()),
|
|
25
|
-
requestablePermissions: z2.array(z2.string()).optional(),
|
|
26
|
-
jitPolicy: jitPolicySchema.optional(),
|
|
27
|
-
maxJitDurationMinutes: z2.number().int().positive().optional()
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// src/agents/types/notifications.ts
|
|
31
|
-
import * as z3 from "zod";
|
|
32
|
-
var notificationConfigSchema = z3.object({
|
|
33
|
-
slack: z3.string().optional(),
|
|
34
|
-
onSuccess: z3.boolean().optional(),
|
|
35
|
-
onFailure: z3.boolean().optional(),
|
|
36
|
-
onTimeout: z3.boolean().optional()
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// src/agents/types/platform-agent.ts
|
|
40
|
-
import * as z7 from "zod";
|
|
41
|
-
|
|
42
|
-
// src/agents/types/resources.ts
|
|
43
|
-
import * as z4 from "zod";
|
|
44
|
-
var resourceLimitsSchema = z4.object({
|
|
45
|
-
maxTokens: z4.number().int().positive().optional(),
|
|
46
|
-
maxCostUsd: z4.number().positive().optional(),
|
|
47
|
-
timeoutSeconds: z4.number().int().positive().optional()
|
|
48
|
-
});
|
|
49
|
-
var retryPolicySchema = z4.object({
|
|
50
|
-
maxAttempts: z4.number().int().min(1).optional(),
|
|
51
|
-
backoffSeconds: z4.number().positive().optional()
|
|
52
|
-
});
|
|
53
|
-
var concurrencyPolicySchema = z4.object({
|
|
54
|
-
maxParallelRuns: z4.number().int().min(1).optional()
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// src/agents/types/team.ts
|
|
58
|
-
import * as z5 from "zod";
|
|
59
|
-
var teamConfigSchema = z5.object({
|
|
60
|
-
members: z5.array(z5.string()).min(1),
|
|
61
|
-
maxConcurrentWorkers: z5.number().int().min(1).optional(),
|
|
62
|
-
maxTokenBudgetPerWorker: z5.number().int().positive().optional(),
|
|
63
|
-
maxDurationPerWorker: z5.number().positive().optional()
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
// src/agents/types/trigger.ts
|
|
67
|
-
import * as z6 from "zod";
|
|
68
|
-
var cronTriggerSchema = z6.object({
|
|
69
|
-
type: z6.literal("cron"),
|
|
70
|
-
expression: z6.string(),
|
|
71
|
-
timezone: z6.string().optional()
|
|
72
|
-
});
|
|
73
|
-
var webhookTriggerSchema = z6.object({
|
|
74
|
-
type: z6.literal("webhook"),
|
|
75
|
-
path: z6.string().startsWith("/"),
|
|
76
|
-
method: z6.enum(["POST", "GET"]).optional()
|
|
77
|
-
});
|
|
78
|
-
var eventTriggerSchema = z6.object({
|
|
79
|
-
type: z6.literal("event"),
|
|
80
|
-
source: z6.string(),
|
|
81
|
-
event: z6.string()
|
|
82
|
-
});
|
|
83
|
-
var apiTriggerSchema = z6.object({ type: z6.literal("api") });
|
|
84
|
-
var manualTriggerSchema = z6.object({ type: z6.literal("manual") });
|
|
85
|
-
var triggerConfigSchema = z6.discriminatedUnion("type", [
|
|
86
|
-
cronTriggerSchema,
|
|
87
|
-
webhookTriggerSchema,
|
|
88
|
-
eventTriggerSchema,
|
|
89
|
-
apiTriggerSchema,
|
|
90
|
-
manualTriggerSchema
|
|
91
|
-
]);
|
|
92
|
-
|
|
93
|
-
// src/agents/types/platform-agent.ts
|
|
94
|
-
var thinkingLevelSchema = z7.enum(["low", "medium", "high"]);
|
|
95
|
-
var logLevelSchema = z7.enum(["silent", "debug", "info", "warn", "error"]);
|
|
96
|
-
var agentDefinitionSchema = z7.object({
|
|
97
|
-
name: z7.string().min(1),
|
|
98
|
-
model: z7.string().min(1),
|
|
99
|
-
instructions: z7.string().min(1),
|
|
100
|
-
description: z7.string().optional(),
|
|
101
|
-
skills: z7.array(z7.string()).optional(),
|
|
102
|
-
temperature: z7.number().min(0).max(2).optional(),
|
|
103
|
-
allowTemperatureOverride: z7.boolean().optional(),
|
|
104
|
-
maxOutputTokens: z7.number().int().positive().optional(),
|
|
105
|
-
thinkingLevel: thinkingLevelSchema.optional(),
|
|
106
|
-
logLevel: logLevelSchema.optional()
|
|
107
|
-
}).strict();
|
|
108
|
-
var platformAgentConfigSchema = z7.object({
|
|
109
|
-
agent: agentDefinitionSchema,
|
|
110
|
-
connectors: z7.array(z7.string()).optional(),
|
|
111
|
-
triggers: z7.array(triggerConfigSchema),
|
|
112
|
-
identity: identityConfigSchema.optional(),
|
|
113
|
-
resources: resourceLimitsSchema.optional(),
|
|
114
|
-
retries: retryPolicySchema.optional(),
|
|
115
|
-
concurrency: concurrencyPolicySchema.optional(),
|
|
116
|
-
team: teamConfigSchema.optional(),
|
|
117
|
-
notifications: notificationConfigSchema.optional(),
|
|
118
|
-
environment: environmentSchema.optional(),
|
|
119
|
-
actions: actionsConfigSchema.optional()
|
|
120
|
-
}).strict();
|
|
121
|
-
|
|
122
|
-
// src/agents/types/skill.ts
|
|
123
|
-
import * as z8 from "zod";
|
|
124
|
-
var platformSkillInputSchema = z8.object({
|
|
125
|
-
name: z8.string().min(1),
|
|
126
|
-
description: z8.string().optional()
|
|
127
|
-
}).strict();
|
|
16
|
+
} from "./chunk-SL6WL3X6.js";
|
|
128
17
|
|
|
129
18
|
// src/agents/define.ts
|
|
130
19
|
var FORBIDDEN_AGENT_KEYS = ["tools", "team", "kernel"];
|
|
@@ -146,7 +35,8 @@ var isPlatformAgent = (v) => v != null && typeof v === "object" && v.__type ===
|
|
|
146
35
|
var normalizeSkillRef = (ref) => isPlatformSkill(ref) ? ref.name : ref;
|
|
147
36
|
var normalizeConnectorRef = (ref) => isPlatformConnector(ref) ? ref.name : ref;
|
|
148
37
|
var normalizeTeamMember = (ref) => isPlatformAgent(ref) ? ref.config.agent.name : ref;
|
|
149
|
-
var
|
|
38
|
+
var isPlatformAction = (v) => v != null && typeof v === "object" && v.__type === "PlatformAction";
|
|
39
|
+
var normalizeActionRef = (ref) => isPlatformAction(ref) ? ref.name : ref;
|
|
150
40
|
var definePlatformAgent = (config) => {
|
|
151
41
|
assertNoInjection(config.agent);
|
|
152
42
|
let agentDef;
|
|
@@ -157,7 +47,7 @@ var definePlatformAgent = (config) => {
|
|
|
157
47
|
runtime = config.agent;
|
|
158
48
|
} else {
|
|
159
49
|
const {
|
|
160
|
-
outputSchema:
|
|
50
|
+
outputSchema: os2,
|
|
161
51
|
skills: rawSkills,
|
|
162
52
|
...rest
|
|
163
53
|
} = config.agent;
|
|
@@ -165,26 +55,39 @@ var definePlatformAgent = (config) => {
|
|
|
165
55
|
...rest,
|
|
166
56
|
skills: rawSkills?.map(normalizeSkillRef)
|
|
167
57
|
};
|
|
168
|
-
outputSchema =
|
|
58
|
+
outputSchema = os2;
|
|
169
59
|
}
|
|
170
60
|
const normalizedConnectors = config.connectors?.map(normalizeConnectorRef);
|
|
171
61
|
const normalizedTeam = config.team ? { ...config.team, members: config.team.members.map(normalizeTeamMember) } : void 0;
|
|
172
62
|
const teamAgents = config.team?.members.filter((m) => isPlatformAgent(m));
|
|
173
|
-
|
|
63
|
+
const actionObjects = config.actions?.filter((a) => isPlatformAction(a));
|
|
64
|
+
const normalizedActions = config.actions?.map(normalizeActionRef);
|
|
174
65
|
let actionZodSchemas;
|
|
175
66
|
let actionHandlers;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const
|
|
180
|
-
|
|
67
|
+
let actionWebhooks;
|
|
68
|
+
if (actionObjects && actionObjects.length > 0) {
|
|
69
|
+
const schemas = {};
|
|
70
|
+
const handlers = {};
|
|
71
|
+
const webhooks = {};
|
|
72
|
+
for (const action of actionObjects) {
|
|
73
|
+
schemas[action.name] = action.zodSchema;
|
|
74
|
+
if (action.handler) {
|
|
75
|
+
handlers[action.name] = action.handler;
|
|
76
|
+
}
|
|
77
|
+
if (action.config.webhook) {
|
|
78
|
+
webhooks[action.name] = action.config.webhook;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
actionZodSchemas = Object.freeze(schemas);
|
|
82
|
+
actionHandlers = Object.keys(handlers).length > 0 ? Object.freeze(handlers) : void 0;
|
|
83
|
+
actionWebhooks = Object.keys(webhooks).length > 0 ? Object.freeze(webhooks) : void 0;
|
|
181
84
|
}
|
|
182
85
|
const parsed = platformAgentConfigSchema.parse({
|
|
183
86
|
...config,
|
|
184
87
|
agent: agentDef,
|
|
185
88
|
connectors: normalizedConnectors,
|
|
186
89
|
team: normalizedTeam,
|
|
187
|
-
actions:
|
|
90
|
+
actions: normalizedActions
|
|
188
91
|
});
|
|
189
92
|
return {
|
|
190
93
|
__type: "PlatformAgent",
|
|
@@ -193,6 +96,7 @@ var definePlatformAgent = (config) => {
|
|
|
193
96
|
outputSchema,
|
|
194
97
|
actionZodSchemas,
|
|
195
98
|
actionHandlers,
|
|
99
|
+
actionWebhooks,
|
|
196
100
|
teamAgents: teamAgents && teamAgents.length > 0 ? teamAgents : void 0
|
|
197
101
|
};
|
|
198
102
|
};
|
|
@@ -229,29 +133,71 @@ var defineSkill = (input) => {
|
|
|
229
133
|
|
|
230
134
|
// src/cli/discover.ts
|
|
231
135
|
import fs from "fs";
|
|
136
|
+
import { createRequire } from "module";
|
|
232
137
|
import path from "path";
|
|
233
138
|
import { pathToFileURL } from "url";
|
|
234
|
-
import * as
|
|
139
|
+
import * as z from "zod";
|
|
235
140
|
var MANIFEST_START = "---KRAKEN-MANIFEST-START---";
|
|
236
141
|
var MANIFEST_END = "---KRAKEN-MANIFEST-END---";
|
|
237
|
-
var skillEntrySchema =
|
|
238
|
-
name:
|
|
239
|
-
path:
|
|
240
|
-
content:
|
|
142
|
+
var skillEntrySchema = z.object({
|
|
143
|
+
name: z.string().min(1),
|
|
144
|
+
path: z.string().min(1),
|
|
145
|
+
content: z.string()
|
|
146
|
+
});
|
|
147
|
+
var toolSpecSchema = z.object({
|
|
148
|
+
name: z.string(),
|
|
149
|
+
description: z.string(),
|
|
150
|
+
parameters: z.record(z.string(), z.unknown()).default({}),
|
|
151
|
+
annotations: z.object({
|
|
152
|
+
readOnlyHint: z.boolean().optional(),
|
|
153
|
+
destructiveHint: z.boolean().optional(),
|
|
154
|
+
idempotentHint: z.boolean().optional()
|
|
155
|
+
}).optional()
|
|
241
156
|
});
|
|
242
|
-
var
|
|
243
|
-
name:
|
|
244
|
-
|
|
157
|
+
var resourceSpecSchema = z.object({
|
|
158
|
+
name: z.string(),
|
|
159
|
+
uri: z.string(),
|
|
160
|
+
description: z.string(),
|
|
161
|
+
mimeType: z.string().optional()
|
|
245
162
|
});
|
|
246
|
-
var
|
|
247
|
-
name:
|
|
248
|
-
|
|
163
|
+
var promptSpecSchema = z.object({
|
|
164
|
+
name: z.string(),
|
|
165
|
+
description: z.string(),
|
|
166
|
+
arguments: z.array(
|
|
167
|
+
z.object({
|
|
168
|
+
name: z.string(),
|
|
169
|
+
description: z.string().optional(),
|
|
170
|
+
required: z.boolean().optional()
|
|
171
|
+
})
|
|
172
|
+
).optional()
|
|
173
|
+
});
|
|
174
|
+
var connectorEntrySchema = z.object({
|
|
175
|
+
name: z.string().min(1),
|
|
176
|
+
path: z.string().min(1),
|
|
177
|
+
toolSpecs: z.array(toolSpecSchema).default([]),
|
|
178
|
+
resourceSpecs: z.array(resourceSpecSchema).default([]),
|
|
179
|
+
promptSpecs: z.array(promptSpecSchema).default([])
|
|
180
|
+
});
|
|
181
|
+
var agentEntrySchema = z.object({
|
|
182
|
+
name: z.string().min(1),
|
|
183
|
+
entryPoint: z.string().min(1),
|
|
249
184
|
config: platformAgentConfigSchema
|
|
250
185
|
});
|
|
251
|
-
var
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
186
|
+
var actionConfigSchema = z.object({
|
|
187
|
+
schema: z.record(z.string(), z.unknown()),
|
|
188
|
+
webhook: z.string().url().optional(),
|
|
189
|
+
hasHandler: z.boolean()
|
|
190
|
+
});
|
|
191
|
+
var actionEntrySchema = z.object({
|
|
192
|
+
name: z.string().min(1),
|
|
193
|
+
entryPoint: z.string().min(1),
|
|
194
|
+
config: actionConfigSchema
|
|
195
|
+
});
|
|
196
|
+
var projectManifestSchema = z.object({
|
|
197
|
+
agents: z.array(agentEntrySchema),
|
|
198
|
+
skills: z.array(skillEntrySchema),
|
|
199
|
+
connectors: z.array(connectorEntrySchema),
|
|
200
|
+
actions: z.array(actionEntrySchema).default([])
|
|
255
201
|
});
|
|
256
202
|
var MAX_SKILL_SIZE = 100 * 1024;
|
|
257
203
|
var parseManifestFromOutput = (stdout) => {
|
|
@@ -274,6 +220,31 @@ var parseManifestFromOutput = (stdout) => {
|
|
|
274
220
|
return result.data;
|
|
275
221
|
};
|
|
276
222
|
|
|
223
|
+
// src/internal/secret-string.ts
|
|
224
|
+
import { inspect } from "util";
|
|
225
|
+
var SecretString = class {
|
|
226
|
+
#value;
|
|
227
|
+
constructor(value) {
|
|
228
|
+
this.#value = value;
|
|
229
|
+
}
|
|
230
|
+
unmasked() {
|
|
231
|
+
return this.#value;
|
|
232
|
+
}
|
|
233
|
+
toJSON() {
|
|
234
|
+
return "[REDACTED]";
|
|
235
|
+
}
|
|
236
|
+
toString() {
|
|
237
|
+
return "[REDACTED]";
|
|
238
|
+
}
|
|
239
|
+
[Symbol.toPrimitive]() {
|
|
240
|
+
return "[REDACTED]";
|
|
241
|
+
}
|
|
242
|
+
[inspect.custom]() {
|
|
243
|
+
return "SecretString([REDACTED])";
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
var unwrapSecret = (value) => value instanceof SecretString ? value.unmasked() : value;
|
|
247
|
+
|
|
277
248
|
// src/platform/http.ts
|
|
278
249
|
var PlatformError = class extends Error {
|
|
279
250
|
constructor(message, status) {
|
|
@@ -281,6 +252,7 @@ var PlatformError = class extends Error {
|
|
|
281
252
|
this.status = status;
|
|
282
253
|
this.name = "PlatformError";
|
|
283
254
|
}
|
|
255
|
+
status;
|
|
284
256
|
};
|
|
285
257
|
var HttpClient = class {
|
|
286
258
|
baseUrlForStream;
|
|
@@ -289,7 +261,7 @@ var HttpClient = class {
|
|
|
289
261
|
constructor(config) {
|
|
290
262
|
this.baseUrl = config.baseUrl.replace(/\/+$/, "");
|
|
291
263
|
this.baseUrlForStream = this.baseUrl;
|
|
292
|
-
this.apiKey = config.apiKey;
|
|
264
|
+
this.apiKey = new SecretString(config.apiKey);
|
|
293
265
|
const isLocalhost = this.baseUrl.includes("localhost") || this.baseUrl.includes("127.0.0.1");
|
|
294
266
|
if (this.baseUrl.startsWith("http://") && !isLocalhost) {
|
|
295
267
|
console.warn(
|
|
@@ -297,24 +269,24 @@ var HttpClient = class {
|
|
|
297
269
|
);
|
|
298
270
|
}
|
|
299
271
|
}
|
|
300
|
-
async get(
|
|
301
|
-
const url = this.buildUrl(
|
|
272
|
+
async get(path3, params) {
|
|
273
|
+
const url = this.buildUrl(path3, params);
|
|
302
274
|
const response = await fetch(url, {
|
|
303
275
|
method: "GET",
|
|
304
276
|
headers: this.authHeaders()
|
|
305
277
|
});
|
|
306
278
|
return this.handleResponse(response);
|
|
307
279
|
}
|
|
308
|
-
async post(
|
|
309
|
-
const response = await fetch(this.buildUrl(
|
|
280
|
+
async post(path3, body) {
|
|
281
|
+
const response = await fetch(this.buildUrl(path3), {
|
|
310
282
|
method: "POST",
|
|
311
283
|
headers: { ...this.authHeaders(), "Content-Type": "application/json" },
|
|
312
284
|
body: body ? JSON.stringify(body) : void 0
|
|
313
285
|
});
|
|
314
286
|
return this.handleResponse(response);
|
|
315
287
|
}
|
|
316
|
-
async postStream(
|
|
317
|
-
const response = await fetch(this.buildUrl(
|
|
288
|
+
async postStream(path3, body, signal) {
|
|
289
|
+
const response = await fetch(this.buildUrl(path3), {
|
|
318
290
|
method: "POST",
|
|
319
291
|
headers: {
|
|
320
292
|
...this.authHeaders(),
|
|
@@ -330,14 +302,14 @@ var HttpClient = class {
|
|
|
330
302
|
}
|
|
331
303
|
return response;
|
|
332
304
|
}
|
|
333
|
-
buildUrl(
|
|
334
|
-
const url = `${this.baseUrl}${
|
|
305
|
+
buildUrl(path3, params) {
|
|
306
|
+
const url = `${this.baseUrl}${path3}`;
|
|
335
307
|
if (!params || Object.keys(params).length === 0) return url;
|
|
336
308
|
const qs = new URLSearchParams(params).toString();
|
|
337
309
|
return `${url}?${qs}`;
|
|
338
310
|
}
|
|
339
311
|
authHeaders() {
|
|
340
|
-
return { Authorization: `Bearer ${this.apiKey}` };
|
|
312
|
+
return { Authorization: `Bearer ${unwrapSecret(this.apiKey)}` };
|
|
341
313
|
}
|
|
342
314
|
async handleResponse(response) {
|
|
343
315
|
if (!response.ok) {
|
|
@@ -418,6 +390,8 @@ var AgentHandle = class {
|
|
|
418
390
|
this.agentId = agentId;
|
|
419
391
|
this.threadId = opts?.threadId;
|
|
420
392
|
}
|
|
393
|
+
http;
|
|
394
|
+
agentId;
|
|
421
395
|
actionHandlers = /* @__PURE__ */ new Map();
|
|
422
396
|
threadId;
|
|
423
397
|
onAction(name, handler) {
|
|
@@ -510,6 +484,9 @@ var AgentThread = class {
|
|
|
510
484
|
this.agentId = agentId;
|
|
511
485
|
this.threadId = threadId;
|
|
512
486
|
}
|
|
487
|
+
http;
|
|
488
|
+
agentId;
|
|
489
|
+
threadId;
|
|
513
490
|
async sendMessage(content, opts) {
|
|
514
491
|
const response = await this.http.postStream(
|
|
515
492
|
`/api/v1/agents/${this.agentId}/threads/${this.threadId}/messages`,
|
|
@@ -530,6 +507,7 @@ var AgentsNamespace = class {
|
|
|
530
507
|
constructor(http) {
|
|
531
508
|
this.http = http;
|
|
532
509
|
}
|
|
510
|
+
http;
|
|
533
511
|
async list() {
|
|
534
512
|
const result = await this.http.get("/api/v1/agents");
|
|
535
513
|
return result.data;
|
|
@@ -555,11 +533,39 @@ var buildPaginationQuery = (params) => {
|
|
|
555
533
|
return Object.keys(qs).length > 0 ? qs : void 0;
|
|
556
534
|
};
|
|
557
535
|
|
|
536
|
+
// src/cli/credentials.ts
|
|
537
|
+
import fs2 from "fs";
|
|
538
|
+
import os from "os";
|
|
539
|
+
import path2 from "path";
|
|
540
|
+
var credentialsDir = () => path2.join(os.homedir(), ".kraken-ai");
|
|
541
|
+
var credentialsPath = () => path2.join(credentialsDir(), "credentials.json");
|
|
542
|
+
var loadCredentials = () => {
|
|
543
|
+
const filePath = credentialsPath();
|
|
544
|
+
let creds = null;
|
|
545
|
+
if (fs2.existsSync(filePath)) {
|
|
546
|
+
try {
|
|
547
|
+
creds = JSON.parse(fs2.readFileSync(filePath, "utf-8"));
|
|
548
|
+
} catch {
|
|
549
|
+
return null;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
const envKey = process.env.KRAKEN_API_KEY;
|
|
553
|
+
const envUrl = process.env.KRAKEN_BASE_URL;
|
|
554
|
+
if (envKey || envUrl) {
|
|
555
|
+
return {
|
|
556
|
+
apiKey: envKey ?? creds?.apiKey ?? "",
|
|
557
|
+
baseUrl: envUrl ?? creds?.baseUrl ?? ""
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
return creds;
|
|
561
|
+
};
|
|
562
|
+
|
|
558
563
|
// src/platform/data.ts
|
|
559
564
|
var DataNamespace = class {
|
|
560
565
|
constructor(http) {
|
|
561
566
|
this.http = http;
|
|
562
567
|
}
|
|
568
|
+
http;
|
|
563
569
|
async list() {
|
|
564
570
|
const result = await this.http.get("/api/v1/data/queries");
|
|
565
571
|
return result.data;
|
|
@@ -576,18 +582,19 @@ var DataNamespace = class {
|
|
|
576
582
|
};
|
|
577
583
|
|
|
578
584
|
// src/platform/pipelines.ts
|
|
579
|
-
import * as
|
|
585
|
+
import * as z2 from "zod";
|
|
580
586
|
var PipelinesNamespace = class {
|
|
581
587
|
constructor(http) {
|
|
582
588
|
this.http = http;
|
|
583
589
|
}
|
|
590
|
+
http;
|
|
584
591
|
async query(pipeline, queryName, schema, params) {
|
|
585
592
|
const result = await this.http.post(
|
|
586
593
|
`/api/v1/pipelines/${encodeURIComponent(pipeline)}/queries/${encodeURIComponent(queryName)}`,
|
|
587
594
|
params
|
|
588
595
|
);
|
|
589
596
|
try {
|
|
590
|
-
return
|
|
597
|
+
return z2.array(schema.returns).parse(result.rows);
|
|
591
598
|
} catch (e) {
|
|
592
599
|
throw new Error(
|
|
593
600
|
`Pipeline schema may have changed \u2014 run 'kraken generate' to update types.
|
|
@@ -603,6 +610,7 @@ var RunsNamespace = class {
|
|
|
603
610
|
constructor(http) {
|
|
604
611
|
this.http = http;
|
|
605
612
|
}
|
|
613
|
+
http;
|
|
606
614
|
async start(params) {
|
|
607
615
|
return this.http.post("/api/v1/runs", params);
|
|
608
616
|
}
|
|
@@ -657,6 +665,22 @@ var RunsNamespace = class {
|
|
|
657
665
|
};
|
|
658
666
|
|
|
659
667
|
// src/platform/client.ts
|
|
668
|
+
var resolveConfig = (config) => {
|
|
669
|
+
const creds = loadCredentials();
|
|
670
|
+
const baseUrl = config?.baseUrl ?? creds?.baseUrl;
|
|
671
|
+
const apiKey = config?.apiKey ?? creds?.apiKey;
|
|
672
|
+
if (!baseUrl) {
|
|
673
|
+
throw new Error(
|
|
674
|
+
"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"
|
|
675
|
+
);
|
|
676
|
+
}
|
|
677
|
+
if (!apiKey) {
|
|
678
|
+
throw new Error(
|
|
679
|
+
"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"
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
return { baseUrl, apiKey };
|
|
683
|
+
};
|
|
660
684
|
var PlatformClient = class {
|
|
661
685
|
agents;
|
|
662
686
|
data;
|
|
@@ -664,9 +688,8 @@ var PlatformClient = class {
|
|
|
664
688
|
runs;
|
|
665
689
|
http;
|
|
666
690
|
constructor(config) {
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
this.http = new HttpClient(config);
|
|
691
|
+
const resolved = resolveConfig(config);
|
|
692
|
+
this.http = new HttpClient(resolved);
|
|
670
693
|
this.agents = new AgentsNamespace(this.http);
|
|
671
694
|
this.data = new DataNamespace(this.http);
|
|
672
695
|
this.pipelines = new PipelinesNamespace(this.http);
|
|
@@ -691,30 +714,18 @@ export {
|
|
|
691
714
|
PlatformClient,
|
|
692
715
|
PlatformError,
|
|
693
716
|
SecurityError,
|
|
694
|
-
actionVariantConfigSchema,
|
|
695
|
-
actionsConfigSchema,
|
|
696
|
-
agentDefinitionSchema,
|
|
697
717
|
buildActionOutputSchema,
|
|
698
|
-
concurrencyPolicySchema,
|
|
699
718
|
defineAction,
|
|
700
|
-
defineActions,
|
|
701
719
|
defineConnector,
|
|
702
720
|
definePlatformAgent,
|
|
703
721
|
defineSkill,
|
|
704
722
|
defineTool,
|
|
705
|
-
|
|
706
|
-
identityConfigSchema,
|
|
723
|
+
isQualified,
|
|
707
724
|
isValidActionName,
|
|
708
|
-
jitPolicySchema,
|
|
709
725
|
mcpResult,
|
|
710
|
-
|
|
726
|
+
parse,
|
|
711
727
|
parseManifestFromOutput,
|
|
712
|
-
|
|
713
|
-
projectManifestSchema,
|
|
714
|
-
resourceLimitsSchema,
|
|
715
|
-
retryPolicySchema,
|
|
716
|
-
teamConfigSchema,
|
|
717
|
-
triggerConfigSchema,
|
|
728
|
+
qualify,
|
|
718
729
|
wrapToolError,
|
|
719
730
|
wrapToolResult
|
|
720
731
|
};
|