@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/index.d.cts
CHANGED
|
@@ -1,441 +1,1180 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { p as ACTION_NAME_REGEX, q as ActionVariantConfig, r as AgentDefinition, s as AgentId, t as AgentSchema, u as ConnectorHandlerContext, v as ConnectorHandlerResult, w as ConnectorPromptDef, x as ConnectorResourceDef, y as ConnectorSchema, G as GetPromptResult, K as KrakenTypeRegistry, z as PlatformActionsConfig, B as PromptMessageContent, D as QueryColumn, E as QuerySchema, F as ReadResourceResult, H as ResourceContent, I as RunState, J as SkillSchema, L as ToolAnnotations, N as actionVariantConfigSchema, O as actionsConfigSchema, U as agentDefinitionSchema, V as isValidActionName, W as platformAgentConfigSchema } from './types-_lfbhFJH.cjs';
|
|
3
|
-
import * as z from 'zod';
|
|
4
|
-
import { ZodType } from 'zod';
|
|
5
|
-
import 'kraken-ai';
|
|
6
|
-
|
|
7
|
-
interface ToolResultContent {
|
|
8
|
-
readonly type: string;
|
|
9
|
-
[key: string]: unknown;
|
|
10
|
-
}
|
|
11
|
-
interface ToolResult {
|
|
12
|
-
readonly content: ReadonlyArray<ToolResultContent>;
|
|
13
|
-
readonly isError?: boolean;
|
|
14
|
-
}
|
|
15
|
-
/** Wrap a handler return value into MCP CallToolResult format */
|
|
16
|
-
declare const wrapToolResult: (value: unknown) => ToolResult;
|
|
17
|
-
/** Wrap a thrown error into MCP CallToolResult format with isError: true */
|
|
18
|
-
declare const wrapToolError: (error: unknown) => ToolResult;
|
|
19
|
-
/** Create an explicit MCP content pass-through result */
|
|
20
|
-
declare const mcpResult: (content: McpContent["content"], isError?: boolean) => McpContent;
|
|
1
|
+
import { ZodType, z } from 'zod';
|
|
21
2
|
|
|
3
|
+
export declare class SecurityError extends Error {
|
|
4
|
+
readonly code = "SECURITY_VIOLATION";
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class ConnectorError extends Error {
|
|
8
|
+
readonly code = "CONNECTOR_ERROR";
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Joins a repo name and primitive name into the qualified `repo/primitive` form.
|
|
13
|
+
* Throws if either segment is empty.
|
|
14
|
+
*/
|
|
15
|
+
export declare const qualify: (repoName: string, primitiveName: string) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Splits a qualified name into its repo and primitive components.
|
|
18
|
+
* Requires exactly one `/` with non-empty segments on both sides.
|
|
19
|
+
*/
|
|
20
|
+
export declare const parse: (qualified: string) => {
|
|
21
|
+
repoName: string;
|
|
22
|
+
primitiveName: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Returns true if the name is in qualified `repo/entity` form —
|
|
26
|
+
* exactly one `/` with non-empty segments on both sides.
|
|
27
|
+
* Purely structural; no format validation.
|
|
28
|
+
*/
|
|
29
|
+
export declare const isQualified: (name: string) => boolean;
|
|
30
|
+
/** Action names follow entity naming convention: lowercase alphanumeric with hyphens, 1-64 chars. */
|
|
31
|
+
export declare const ACTION_NAME_REGEX: RegExp;
|
|
32
|
+
/** Validates an action name (allows single-char names like "a"). */
|
|
33
|
+
export declare const isValidActionName: (name: string) => boolean;
|
|
34
|
+
/** Input for a single action in defineAction(). */
|
|
35
|
+
export interface ActionVariantInput<S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>> {
|
|
36
|
+
name: string;
|
|
37
|
+
schema: S;
|
|
38
|
+
webhook?: string;
|
|
39
|
+
handler?(payload: z.infer<S>): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/** Serializable config for a single action (stored in manifest/DB). */
|
|
42
|
+
export interface ActionConfig {
|
|
43
|
+
schema: Record<string, unknown>;
|
|
44
|
+
webhook?: string;
|
|
45
|
+
hasHandler: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** Branded action type returned by defineAction(). */
|
|
48
|
+
export interface PlatformAction {
|
|
49
|
+
readonly __type: "PlatformAction";
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly config: ActionConfig;
|
|
52
|
+
readonly zodSchema: z.ZodObject<z.ZodRawShape>;
|
|
53
|
+
readonly handler?: (payload: unknown) => Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
/** MCP tool annotations per the MCP spec (v1.27.1) */
|
|
56
|
+
export interface ToolAnnotations {
|
|
57
|
+
readonly readOnlyHint?: boolean;
|
|
58
|
+
readonly destructiveHint?: boolean;
|
|
59
|
+
readonly idempotentHint?: boolean;
|
|
60
|
+
readonly openWorldHint?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/** Explicit MCP content pass-through (returned by mcpResult() helper) */
|
|
63
|
+
export interface McpContent {
|
|
64
|
+
readonly __mcpPassThrough: true;
|
|
65
|
+
readonly content: ReadonlyArray<{
|
|
66
|
+
readonly type: string;
|
|
67
|
+
[key: string]: unknown;
|
|
68
|
+
}>;
|
|
69
|
+
readonly isError?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Union of valid handler return types.
|
|
73
|
+
* Prevents returning unsupported types at compile time.
|
|
74
|
+
*/
|
|
75
|
+
export type ConnectorHandlerResult = string | number | boolean | Record<string, unknown> | ReadonlyArray<unknown> | McpContent | null | undefined;
|
|
76
|
+
/** Minimal context passed to resource/prompt handlers — business logic only */
|
|
77
|
+
export interface ConnectorHandlerContext {
|
|
78
|
+
readonly signal: AbortSignal;
|
|
79
|
+
}
|
|
80
|
+
/** MCP-native resource content (text or binary) */
|
|
81
|
+
export type ResourceContent = {
|
|
82
|
+
readonly uri: string;
|
|
83
|
+
readonly mimeType?: string;
|
|
84
|
+
readonly text: string;
|
|
85
|
+
} | {
|
|
86
|
+
readonly uri: string;
|
|
87
|
+
readonly mimeType?: string;
|
|
88
|
+
readonly blob: string;
|
|
89
|
+
};
|
|
90
|
+
/** MCP-native ReadResourceResult — returned by resource read handlers */
|
|
91
|
+
export interface ReadResourceResult {
|
|
92
|
+
readonly contents: ReadonlyArray<ResourceContent>;
|
|
93
|
+
}
|
|
94
|
+
/** MCP-native prompt message content */
|
|
95
|
+
export type PromptMessageContent = {
|
|
96
|
+
readonly type: "text";
|
|
97
|
+
readonly text: string;
|
|
98
|
+
} | {
|
|
99
|
+
readonly type: "image";
|
|
100
|
+
readonly data: string;
|
|
101
|
+
readonly mimeType: string;
|
|
102
|
+
};
|
|
103
|
+
/** MCP-native GetPromptResult — returned by prompt get handlers */
|
|
104
|
+
export interface GetPromptResult {
|
|
105
|
+
readonly description?: string;
|
|
106
|
+
readonly messages: ReadonlyArray<{
|
|
107
|
+
readonly role: "user" | "assistant";
|
|
108
|
+
readonly content: PromptMessageContent;
|
|
109
|
+
}>;
|
|
110
|
+
}
|
|
111
|
+
/** A tool definition within a connector */
|
|
112
|
+
export interface ConnectorToolDef<TInput extends ZodType = ZodType> {
|
|
113
|
+
readonly description: string;
|
|
114
|
+
readonly input: TInput;
|
|
115
|
+
readonly annotations?: ToolAnnotations;
|
|
116
|
+
handler(args: z.infer<TInput>): Promise<ConnectorHandlerResult> | ConnectorHandlerResult;
|
|
117
|
+
}
|
|
118
|
+
/** A resource definition within a connector */
|
|
119
|
+
export interface ConnectorResourceDef {
|
|
120
|
+
readonly description: string;
|
|
121
|
+
readonly uri: string;
|
|
122
|
+
readonly mimeType?: string;
|
|
123
|
+
read(ctx: ConnectorHandlerContext): Promise<ReadResourceResult> | ReadResourceResult;
|
|
124
|
+
}
|
|
125
|
+
/** A prompt definition within a connector */
|
|
126
|
+
export interface ConnectorPromptDef {
|
|
127
|
+
readonly description: string;
|
|
128
|
+
readonly arguments?: ReadonlyArray<{
|
|
129
|
+
readonly name: string;
|
|
130
|
+
readonly description?: string;
|
|
131
|
+
readonly required?: boolean;
|
|
132
|
+
}>;
|
|
133
|
+
get(args: Record<string, string>, ctx: ConnectorHandlerContext): Promise<GetPromptResult> | GetPromptResult;
|
|
134
|
+
}
|
|
135
|
+
/** Input to defineConnector() */
|
|
136
|
+
export interface ConnectorDefinition {
|
|
137
|
+
readonly name: string;
|
|
138
|
+
readonly description?: string;
|
|
139
|
+
readonly instructions?: string;
|
|
140
|
+
readonly tools?: Record<string, ConnectorToolDef>;
|
|
141
|
+
readonly resources?: Record<string, ConnectorResourceDef>;
|
|
142
|
+
readonly prompts?: Record<string, ConnectorPromptDef>;
|
|
143
|
+
}
|
|
144
|
+
/** Output of defineConnector() — frozen, carries handlers for server builder */
|
|
145
|
+
export interface PlatformConnector {
|
|
146
|
+
readonly __type: "PlatformConnector";
|
|
147
|
+
readonly name: string;
|
|
148
|
+
readonly description?: string;
|
|
149
|
+
readonly instructions?: string;
|
|
150
|
+
readonly tools?: Readonly<Record<string, ConnectorToolDef>>;
|
|
151
|
+
readonly resources?: Readonly<Record<string, ConnectorResourceDef>>;
|
|
152
|
+
readonly prompts?: Readonly<Record<string, ConnectorPromptDef>>;
|
|
153
|
+
}
|
|
22
154
|
declare const environmentSchema: z.ZodEnum<{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
155
|
+
dev: "dev";
|
|
156
|
+
staging: "staging";
|
|
157
|
+
prod: "prod";
|
|
26
158
|
}>;
|
|
27
|
-
type Environment = z.infer<typeof environmentSchema>;
|
|
28
|
-
|
|
159
|
+
export type Environment = z.infer<typeof environmentSchema>;
|
|
29
160
|
declare const jitPolicySchema: z.ZodEnum<{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
161
|
+
"auto-approve": "auto-approve";
|
|
162
|
+
"policy-based": "policy-based";
|
|
163
|
+
"require-approval": "require-approval";
|
|
33
164
|
}>;
|
|
34
|
-
type JitPolicy = z.infer<typeof jitPolicySchema>;
|
|
165
|
+
export type JitPolicy = z.infer<typeof jitPolicySchema>;
|
|
35
166
|
declare const identityConfigSchema: z.ZodObject<{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
167
|
+
basePermissions: z.ZodArray<z.ZodString>;
|
|
168
|
+
requestablePermissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
169
|
+
jitPolicy: z.ZodOptional<z.ZodEnum<{
|
|
170
|
+
"auto-approve": "auto-approve";
|
|
171
|
+
"policy-based": "policy-based";
|
|
172
|
+
"require-approval": "require-approval";
|
|
173
|
+
}>>;
|
|
174
|
+
maxJitDurationMinutes: z.ZodOptional<z.ZodNumber>;
|
|
44
175
|
}, z.core.$strip>;
|
|
45
|
-
type IdentityConfig = z.infer<typeof identityConfigSchema>;
|
|
46
|
-
|
|
176
|
+
export type IdentityConfig = z.infer<typeof identityConfigSchema>;
|
|
47
177
|
declare const notificationConfigSchema: z.ZodObject<{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
178
|
+
slack: z.ZodOptional<z.ZodString>;
|
|
179
|
+
onSuccess: z.ZodOptional<z.ZodBoolean>;
|
|
180
|
+
onFailure: z.ZodOptional<z.ZodBoolean>;
|
|
181
|
+
onTimeout: z.ZodOptional<z.ZodBoolean>;
|
|
52
182
|
}, z.core.$strip>;
|
|
53
|
-
type NotificationConfig = z.infer<typeof notificationConfigSchema>;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
183
|
+
export type NotificationConfig = z.infer<typeof notificationConfigSchema>;
|
|
184
|
+
/** Google model ID. */
|
|
185
|
+
export type GoogleModelId = "gemini-3.1-pro-preview" | "gemini-3-flash-preview";
|
|
186
|
+
/** OpenAI model ID. */
|
|
187
|
+
export type OpenAIModelId = "gpt-5.4" | "gpt-4o" | "gpt-4o-mini";
|
|
188
|
+
/** A provider-qualified model string (e.g. `"google/gemini-3.1-pro-preview"`). */
|
|
189
|
+
export type ModelString = `google/${GoogleModelId}` | `openai/${OpenAIModelId}`;
|
|
190
|
+
declare const agentDefinitionSchema: z.ZodObject<{
|
|
191
|
+
name: z.ZodString;
|
|
192
|
+
model: z.ZodString;
|
|
193
|
+
instructions: z.ZodString;
|
|
194
|
+
description: z.ZodOptional<z.ZodString>;
|
|
195
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
196
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
197
|
+
allowTemperatureOverride: z.ZodOptional<z.ZodBoolean>;
|
|
198
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
199
|
+
thinkingLevel: z.ZodOptional<z.ZodEnum<{
|
|
200
|
+
low: "low";
|
|
201
|
+
medium: "medium";
|
|
202
|
+
high: "high";
|
|
203
|
+
}>>;
|
|
204
|
+
logLevel: z.ZodOptional<z.ZodEnum<{
|
|
205
|
+
error: "error";
|
|
206
|
+
silent: "silent";
|
|
207
|
+
debug: "debug";
|
|
208
|
+
info: "info";
|
|
209
|
+
warn: "warn";
|
|
210
|
+
}>>;
|
|
211
|
+
}, z.core.$strict>;
|
|
212
|
+
export type AgentDefinition = Omit<z.infer<typeof agentDefinitionSchema>, "model"> & {
|
|
213
|
+
model: ModelString;
|
|
214
|
+
};
|
|
215
|
+
declare const platformAgentConfigSchema: z.ZodObject<{
|
|
216
|
+
agent: z.ZodObject<{
|
|
217
|
+
name: z.ZodString;
|
|
218
|
+
model: z.ZodString;
|
|
219
|
+
instructions: z.ZodString;
|
|
220
|
+
description: z.ZodOptional<z.ZodString>;
|
|
221
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
222
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
223
|
+
allowTemperatureOverride: z.ZodOptional<z.ZodBoolean>;
|
|
224
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
225
|
+
thinkingLevel: z.ZodOptional<z.ZodEnum<{
|
|
226
|
+
low: "low";
|
|
227
|
+
medium: "medium";
|
|
228
|
+
high: "high";
|
|
229
|
+
}>>;
|
|
230
|
+
logLevel: z.ZodOptional<z.ZodEnum<{
|
|
231
|
+
error: "error";
|
|
232
|
+
silent: "silent";
|
|
233
|
+
debug: "debug";
|
|
234
|
+
info: "info";
|
|
235
|
+
warn: "warn";
|
|
236
|
+
}>>;
|
|
237
|
+
}, z.core.$strict>;
|
|
238
|
+
connectors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
239
|
+
triggers: z.ZodArray<z.ZodDiscriminatedUnion<[
|
|
240
|
+
z.ZodObject<{
|
|
241
|
+
type: z.ZodLiteral<"cron">;
|
|
242
|
+
expression: z.ZodString;
|
|
243
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
244
|
+
}, z.core.$strip>,
|
|
245
|
+
z.ZodObject<{
|
|
246
|
+
type: z.ZodLiteral<"webhook">;
|
|
247
|
+
path: z.ZodString;
|
|
248
|
+
method: z.ZodOptional<z.ZodEnum<{
|
|
249
|
+
POST: "POST";
|
|
250
|
+
GET: "GET";
|
|
251
|
+
}>>;
|
|
252
|
+
}, z.core.$strip>,
|
|
253
|
+
z.ZodObject<{
|
|
254
|
+
type: z.ZodLiteral<"event">;
|
|
255
|
+
source: z.ZodString;
|
|
256
|
+
event: z.ZodString;
|
|
257
|
+
}, z.core.$strip>,
|
|
258
|
+
z.ZodObject<{
|
|
259
|
+
type: z.ZodLiteral<"api">;
|
|
260
|
+
}, z.core.$strip>,
|
|
261
|
+
z.ZodObject<{
|
|
262
|
+
type: z.ZodLiteral<"manual">;
|
|
263
|
+
}, z.core.$strip>
|
|
264
|
+
], "type">>;
|
|
265
|
+
identity: z.ZodOptional<z.ZodObject<{
|
|
266
|
+
basePermissions: z.ZodArray<z.ZodString>;
|
|
267
|
+
requestablePermissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
268
|
+
jitPolicy: z.ZodOptional<z.ZodEnum<{
|
|
269
|
+
"auto-approve": "auto-approve";
|
|
270
|
+
"policy-based": "policy-based";
|
|
271
|
+
"require-approval": "require-approval";
|
|
272
|
+
}>>;
|
|
273
|
+
maxJitDurationMinutes: z.ZodOptional<z.ZodNumber>;
|
|
274
|
+
}, z.core.$strip>>;
|
|
275
|
+
resources: z.ZodOptional<z.ZodObject<{
|
|
276
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
277
|
+
maxCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
278
|
+
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
279
|
+
}, z.core.$strip>>;
|
|
280
|
+
retries: z.ZodOptional<z.ZodObject<{
|
|
281
|
+
maxAttempts: z.ZodOptional<z.ZodNumber>;
|
|
282
|
+
backoffSeconds: z.ZodOptional<z.ZodNumber>;
|
|
283
|
+
}, z.core.$strip>>;
|
|
284
|
+
concurrency: z.ZodOptional<z.ZodObject<{
|
|
285
|
+
maxParallelRuns: z.ZodOptional<z.ZodNumber>;
|
|
286
|
+
}, z.core.$strip>>;
|
|
287
|
+
fast: z.ZodOptional<z.ZodBoolean>;
|
|
288
|
+
team: z.ZodOptional<z.ZodObject<{
|
|
289
|
+
members: z.ZodArray<z.ZodString>;
|
|
290
|
+
maxConcurrentWorkers: z.ZodOptional<z.ZodNumber>;
|
|
291
|
+
maxTokenBudgetPerWorker: z.ZodOptional<z.ZodNumber>;
|
|
292
|
+
maxDurationPerWorker: z.ZodOptional<z.ZodNumber>;
|
|
293
|
+
}, z.core.$strip>>;
|
|
294
|
+
notifications: z.ZodOptional<z.ZodObject<{
|
|
295
|
+
slack: z.ZodOptional<z.ZodString>;
|
|
296
|
+
onSuccess: z.ZodOptional<z.ZodBoolean>;
|
|
297
|
+
onFailure: z.ZodOptional<z.ZodBoolean>;
|
|
298
|
+
onTimeout: z.ZodOptional<z.ZodBoolean>;
|
|
299
|
+
}, z.core.$strip>>;
|
|
300
|
+
environment: z.ZodOptional<z.ZodEnum<{
|
|
301
|
+
dev: "dev";
|
|
302
|
+
staging: "staging";
|
|
303
|
+
prod: "prod";
|
|
304
|
+
}>>;
|
|
305
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
306
|
+
}, z.core.$strict>;
|
|
307
|
+
export type PlatformAgentConfig = Omit<z.infer<typeof platformAgentConfigSchema>, "agent"> & {
|
|
308
|
+
agent: AgentDefinition;
|
|
309
|
+
};
|
|
310
|
+
export interface PlatformAgent {
|
|
311
|
+
readonly __type: "PlatformAgent";
|
|
312
|
+
readonly config: PlatformAgentConfig;
|
|
313
|
+
readonly runtime?: unknown;
|
|
314
|
+
/** In-memory schemas for action variants. Not serialized — runtime use only. */
|
|
315
|
+
readonly actionZodSchemas?: Record<string, import("zod").ZodObject<import("zod").ZodRawShape>>;
|
|
316
|
+
/** Action handler functions. Not serialized — runtime use only. */
|
|
317
|
+
readonly actionHandlers?: Readonly<Record<string, (payload: unknown) => Promise<void>>>;
|
|
318
|
+
/** Action webhook URLs. Not serialized — runtime use only. */
|
|
319
|
+
readonly actionWebhooks?: Readonly<Record<string, string | undefined>>;
|
|
320
|
+
/** Team member PlatformAgent objects. Not serialized — runtime use only (dev mode delegation). */
|
|
321
|
+
readonly teamAgents?: readonly PlatformAgent[];
|
|
59
322
|
}
|
|
60
|
-
|
|
61
|
-
/** Skill reference: local PlatformSkill object or remote SkillId (populated by `kraken generate`). */
|
|
62
|
-
type SkillRef = PlatformSkill | SkillId;
|
|
63
|
-
/** Connector reference: local PlatformConnector, remote ConnectorId, or connector name string. */
|
|
64
|
-
type ConnectorRef = PlatformConnector | ConnectorId | (string & {});
|
|
65
|
-
|
|
66
323
|
declare const resourceLimitsSchema: z.ZodObject<{
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
324
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
325
|
+
maxCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
326
|
+
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
70
327
|
}, z.core.$strip>;
|
|
71
|
-
type ResourceLimits = z.infer<typeof resourceLimitsSchema>;
|
|
328
|
+
export type ResourceLimits = z.infer<typeof resourceLimitsSchema>;
|
|
72
329
|
declare const retryPolicySchema: z.ZodObject<{
|
|
73
|
-
|
|
74
|
-
|
|
330
|
+
maxAttempts: z.ZodOptional<z.ZodNumber>;
|
|
331
|
+
backoffSeconds: z.ZodOptional<z.ZodNumber>;
|
|
75
332
|
}, z.core.$strip>;
|
|
76
|
-
type RetryPolicy = z.infer<typeof retryPolicySchema>;
|
|
333
|
+
export type RetryPolicy = z.infer<typeof retryPolicySchema>;
|
|
77
334
|
declare const concurrencyPolicySchema: z.ZodObject<{
|
|
78
|
-
|
|
335
|
+
maxParallelRuns: z.ZodOptional<z.ZodNumber>;
|
|
79
336
|
}, z.core.$strip>;
|
|
80
|
-
type ConcurrencyPolicy = z.infer<typeof concurrencyPolicySchema>;
|
|
81
|
-
|
|
337
|
+
export type ConcurrencyPolicy = z.infer<typeof concurrencyPolicySchema>;
|
|
338
|
+
export interface PlatformSkill {
|
|
339
|
+
readonly __type: "PlatformSkill";
|
|
340
|
+
readonly name: string;
|
|
341
|
+
readonly description?: string;
|
|
342
|
+
}
|
|
82
343
|
declare const teamConfigSchema: z.ZodObject<{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
344
|
+
members: z.ZodArray<z.ZodString>;
|
|
345
|
+
maxConcurrentWorkers: z.ZodOptional<z.ZodNumber>;
|
|
346
|
+
maxTokenBudgetPerWorker: z.ZodOptional<z.ZodNumber>;
|
|
347
|
+
maxDurationPerWorker: z.ZodOptional<z.ZodNumber>;
|
|
87
348
|
}, z.core.$strip>;
|
|
88
|
-
type TeamConfig = z.infer<typeof teamConfigSchema>;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}, z.core.$strip>,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}, z.core.$strip>,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
type
|
|
113
|
-
|
|
114
|
-
|
|
349
|
+
export type TeamConfig = z.infer<typeof teamConfigSchema>;
|
|
350
|
+
declare const triggerConfigSchema: z.ZodDiscriminatedUnion<[
|
|
351
|
+
z.ZodObject<{
|
|
352
|
+
type: z.ZodLiteral<"cron">;
|
|
353
|
+
expression: z.ZodString;
|
|
354
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
355
|
+
}, z.core.$strip>,
|
|
356
|
+
z.ZodObject<{
|
|
357
|
+
type: z.ZodLiteral<"webhook">;
|
|
358
|
+
path: z.ZodString;
|
|
359
|
+
method: z.ZodOptional<z.ZodEnum<{
|
|
360
|
+
POST: "POST";
|
|
361
|
+
GET: "GET";
|
|
362
|
+
}>>;
|
|
363
|
+
}, z.core.$strip>,
|
|
364
|
+
z.ZodObject<{
|
|
365
|
+
type: z.ZodLiteral<"event">;
|
|
366
|
+
source: z.ZodString;
|
|
367
|
+
event: z.ZodString;
|
|
368
|
+
}, z.core.$strip>,
|
|
369
|
+
z.ZodObject<{
|
|
370
|
+
type: z.ZodLiteral<"api">;
|
|
371
|
+
}, z.core.$strip>,
|
|
372
|
+
z.ZodObject<{
|
|
373
|
+
type: z.ZodLiteral<"manual">;
|
|
374
|
+
}, z.core.$strip>
|
|
375
|
+
], "type">;
|
|
376
|
+
export type TriggerConfig = z.infer<typeof triggerConfigSchema>;
|
|
377
|
+
export interface ToolResultContent {
|
|
378
|
+
readonly type: string;
|
|
379
|
+
[key: string]: unknown;
|
|
380
|
+
}
|
|
381
|
+
export interface ToolResult {
|
|
382
|
+
readonly content: ReadonlyArray<ToolResultContent>;
|
|
383
|
+
readonly isError?: boolean;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Wrap a tool handler's return value into MCP `CallToolResult` format.
|
|
387
|
+
*
|
|
388
|
+
* Automatically converts primitives to `{ type: "text" }` content and
|
|
389
|
+
* serializes objects to JSON. Pass-through {@link McpContent} values
|
|
390
|
+
* (created with {@link mcpResult}) are forwarded as-is.
|
|
391
|
+
*
|
|
392
|
+
* @param value - The handler's return value (string, number, boolean,
|
|
393
|
+
* object, {@link McpContent}, or `null`/`undefined`).
|
|
394
|
+
* @returns An MCP-compatible tool result.
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* ```ts
|
|
398
|
+
* wrapToolResult("done"); // { content: [{ type: "text", text: "done" }] }
|
|
399
|
+
* wrapToolResult({ id: 1 }); // { content: [{ type: "text", text: '{\n "id": 1\n}' }] }
|
|
400
|
+
* wrapToolResult(null); // { content: [] }
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
export declare const wrapToolResult: (value: unknown) => ToolResult;
|
|
404
|
+
/**
|
|
405
|
+
* Wrap a thrown error into MCP `CallToolResult` format with `isError: true`.
|
|
406
|
+
*
|
|
407
|
+
* {@link ConnectorError} messages are forwarded to the agent as-is (they
|
|
408
|
+
* are user-facing). All other errors are replaced with a generic
|
|
409
|
+
* "Internal handler error" message and logged to stderr.
|
|
410
|
+
*
|
|
411
|
+
* @param error - The caught error.
|
|
412
|
+
* @returns An MCP-compatible error result.
|
|
413
|
+
*
|
|
414
|
+
* @example
|
|
415
|
+
* ```ts
|
|
416
|
+
* try {
|
|
417
|
+
* return wrapToolResult(await handler(args));
|
|
418
|
+
* } catch (err) {
|
|
419
|
+
* return wrapToolError(err);
|
|
420
|
+
* }
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
export declare const wrapToolError: (error: unknown) => ToolResult;
|
|
424
|
+
/**
|
|
425
|
+
* Create an explicit MCP content pass-through result.
|
|
426
|
+
*
|
|
427
|
+
* Use this when you need full control over the MCP response — for
|
|
428
|
+
* example, returning an image alongside text or marking a multi-part
|
|
429
|
+
* response as an error.
|
|
430
|
+
*
|
|
431
|
+
* @param content - Array of MCP content blocks (`{ type: "text", text }`,
|
|
432
|
+
* `{ type: "image", data, mimeType }`, etc.).
|
|
433
|
+
* @param isError - If `true`, the result is marked as an error.
|
|
434
|
+
* @returns An {@link McpContent} object that {@link wrapToolResult}
|
|
435
|
+
* forwards without modification.
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* ```ts
|
|
439
|
+
* import { mcpResult } from "@kraken-ai/platform";
|
|
440
|
+
*
|
|
441
|
+
* const screenshot = defineTool({
|
|
442
|
+
* description: "Take a screenshot",
|
|
443
|
+
* input: z.object({ url: z.string().url() }),
|
|
444
|
+
* handler: async ({ url }) =>
|
|
445
|
+
* mcpResult([
|
|
446
|
+
* { type: "text", text: `Screenshot of ${url}` },
|
|
447
|
+
* { type: "image", data: base64png, mimeType: "image/png" },
|
|
448
|
+
* ]),
|
|
449
|
+
* });
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
452
|
+
export declare const mcpResult: (content: McpContent["content"], isError?: boolean) => McpContent;
|
|
453
|
+
/**
|
|
454
|
+
* Type registry populated by `kraken generate` via module augmentation.
|
|
455
|
+
*
|
|
456
|
+
* Before generating, all ID types resolve to an error-message string —
|
|
457
|
+
* only local typed refs (PlatformAgent, PlatformSkill, PlatformConnector) compile.
|
|
458
|
+
*
|
|
459
|
+
* After `kraken generate`, the generated `.kraken-ai/platform-types.d.ts` augments
|
|
460
|
+
* this interface with `agentId`, `connectorId`, and `skillId` string unions,
|
|
461
|
+
* enabling autocomplete on remote IDs.
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* ```ts
|
|
465
|
+
* // .kraken-ai/platform-types.d.ts (generated)
|
|
466
|
+
* declare module "@kraken-ai/platform" {
|
|
467
|
+
* interface KrakenTypeRegistry {
|
|
468
|
+
* agentId: "analyst" | "writer";
|
|
469
|
+
* connectorId: "slack" | "jira";
|
|
470
|
+
* skillId: "competitor-deep-dive";
|
|
471
|
+
* }
|
|
472
|
+
* }
|
|
473
|
+
* ```
|
|
474
|
+
*/
|
|
475
|
+
export interface KrakenTypeRegistry {
|
|
476
|
+
}
|
|
477
|
+
/** Remote agent IDs. Resolves to an error hint before `kraken generate`. */
|
|
478
|
+
export type AgentId = KrakenTypeRegistry extends {
|
|
479
|
+
agentId: infer T extends string;
|
|
480
|
+
} ? T : "ERROR: Run 'kraken generate' to unlock agent IDs";
|
|
481
|
+
/** Remote connector IDs. Resolves to an error hint before `kraken generate`. */
|
|
482
|
+
export type ConnectorId = KrakenTypeRegistry extends {
|
|
483
|
+
connectorId: infer T extends string;
|
|
484
|
+
} ? T : "ERROR: Run 'kraken generate' to unlock connector IDs";
|
|
485
|
+
/** Remote skill IDs. Resolves to an error hint before `kraken generate`. */
|
|
486
|
+
export type SkillId = KrakenTypeRegistry extends {
|
|
487
|
+
skillId: infer T extends string;
|
|
488
|
+
} ? T : "ERROR: Run 'kraken generate' to unlock skill IDs";
|
|
489
|
+
/** Remote action IDs. Resolves to an error hint before `kraken generate`. */
|
|
490
|
+
export type ActionId = KrakenTypeRegistry extends {
|
|
491
|
+
actionId: infer T extends string;
|
|
492
|
+
} ? T : "ERROR: Run 'kraken generate' to unlock action IDs";
|
|
493
|
+
/** Skill reference: local PlatformSkill object or remote SkillId (populated by `kraken generate`). */
|
|
494
|
+
export type SkillRef = PlatformSkill | SkillId;
|
|
495
|
+
/** Connector reference: local PlatformConnector object or remote ConnectorId (populated by `kraken generate`). */
|
|
496
|
+
export type ConnectorRef = PlatformConnector | ConnectorId;
|
|
497
|
+
/** Action reference: local PlatformAction object or remote ActionId (populated by `kraken generate`). */
|
|
498
|
+
export type ActionRef = PlatformAction | ActionId;
|
|
499
|
+
export type TeamMember = PlatformAgent | AgentId;
|
|
500
|
+
export type AgentInputField = (Omit<PlatformAgentConfig["agent"], "skills"> & {
|
|
501
|
+
outputSchema?: ZodType;
|
|
502
|
+
skills?: SkillRef[];
|
|
115
503
|
}) | {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
504
|
+
definition: Record<string, unknown>;
|
|
505
|
+
name: string;
|
|
506
|
+
run: (...args: unknown[]) => unknown;
|
|
119
507
|
};
|
|
120
|
-
interface PlatformAgentInputConfig extends Omit<PlatformAgentConfig, "agent" | "connectors" | "team" | "actions"> {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
508
|
+
export interface PlatformAgentInputConfig extends Omit<PlatformAgentConfig, "agent" | "connectors" | "team" | "actions"> {
|
|
509
|
+
agent: AgentInputField;
|
|
510
|
+
connectors?: ConnectorRef[];
|
|
511
|
+
team?: Omit<PlatformAgentConfig["team"] & object, "members"> & {
|
|
512
|
+
members: TeamMember[];
|
|
513
|
+
};
|
|
514
|
+
actions?: ActionRef[];
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Define a platform agent. Validates at definition time and returns a
|
|
518
|
+
* frozen {@link PlatformAgent} ready for registration.
|
|
519
|
+
*
|
|
520
|
+
* ## Config shape
|
|
521
|
+
*
|
|
522
|
+
* ```
|
|
523
|
+
* {
|
|
524
|
+
* agent: { // REQUIRED — the agent itself
|
|
525
|
+
* name: string // REQUIRED — unique agent name
|
|
526
|
+
* model: ModelString // REQUIRED — "provider/model-id"
|
|
527
|
+
* instructions: string // REQUIRED — system prompt
|
|
528
|
+
* description?: string // shown to orchestrator agents
|
|
529
|
+
* skills?: SkillRef[] // skill objects or IDs
|
|
530
|
+
* temperature?: number // 0–2 (default: model default)
|
|
531
|
+
* allowTemperatureOverride?: boolean // let callers override temperature
|
|
532
|
+
* maxOutputTokens?: number // cap output length
|
|
533
|
+
* thinkingLevel?: "low"|"medium"|"high" // reasoning depth
|
|
534
|
+
* logLevel?: "silent"|"debug"|"info"|"warn"|"error"
|
|
535
|
+
* outputSchema?: ZodType // typed structured output
|
|
536
|
+
* }
|
|
537
|
+
* triggers: TriggerConfig[] // REQUIRED — how runs start
|
|
538
|
+
* | { type: "manual" }
|
|
539
|
+
* | { type: "api" }
|
|
540
|
+
* | { type: "cron", expression: string, timezone?: string }
|
|
541
|
+
* | { type: "webhook", path: string, method?: "POST"|"GET" }
|
|
542
|
+
* | { type: "event", source: string, event: string }
|
|
543
|
+
* connectors?: ConnectorRef[] // connector objects or IDs
|
|
544
|
+
* actions?: ActionRef[] // action objects or IDs
|
|
545
|
+
* team?: { // multi-agent delegation
|
|
546
|
+
* members: TeamMember[] // REQUIRED — agent objects or IDs
|
|
547
|
+
* maxConcurrentWorkers?: number // parallel worker cap
|
|
548
|
+
* maxTokenBudgetPerWorker?: number // token limit per worker
|
|
549
|
+
* maxDurationPerWorker?: number // seconds per worker
|
|
550
|
+
* }
|
|
551
|
+
* identity?: { // JIT permission escalation
|
|
552
|
+
* basePermissions: string[] // REQUIRED — default permissions
|
|
553
|
+
* requestablePermissions?: string[] // permissions the agent can request
|
|
554
|
+
* jitPolicy?: "auto-approve"|"policy-based"|"require-approval"
|
|
555
|
+
* maxJitDurationMinutes?: number
|
|
556
|
+
* }
|
|
557
|
+
* resources?: { // cost & runtime guardrails
|
|
558
|
+
* maxTokens?: number
|
|
559
|
+
* maxCostUsd?: number
|
|
560
|
+
* timeoutSeconds?: number
|
|
561
|
+
* }
|
|
562
|
+
* retries?: { // automatic retry on failure
|
|
563
|
+
* maxAttempts?: number
|
|
564
|
+
* backoffSeconds?: number
|
|
565
|
+
* }
|
|
566
|
+
* concurrency?: { // run-level concurrency
|
|
567
|
+
* maxParallelRuns?: number
|
|
568
|
+
* }
|
|
569
|
+
* notifications?: { // Slack alerts
|
|
570
|
+
* slack?: string // channel or webhook URL
|
|
571
|
+
* onSuccess?: boolean
|
|
572
|
+
* onFailure?: boolean
|
|
573
|
+
* onTimeout?: boolean
|
|
574
|
+
* }
|
|
575
|
+
* fast?: boolean // pre-provision connectors for low latency
|
|
576
|
+
* environment?: "dev"|"staging"|"prod"
|
|
577
|
+
* }
|
|
578
|
+
* ```
|
|
579
|
+
*
|
|
580
|
+
* @returns A frozen {@link PlatformAgent} object.
|
|
581
|
+
* @throws {SecurityError} If `agent` contains forbidden keys (`tools`,
|
|
582
|
+
* `team`, `kernel`) — those are platform-managed.
|
|
583
|
+
*
|
|
584
|
+
* @example
|
|
585
|
+
* ```ts
|
|
586
|
+
* export default definePlatformAgent({
|
|
587
|
+
* agent: {
|
|
588
|
+
* name: "market-intel",
|
|
589
|
+
* model: "openai/gpt-4o",
|
|
590
|
+
* instructions: "You are a market research analyst.",
|
|
591
|
+
* temperature: 0.3,
|
|
592
|
+
* },
|
|
593
|
+
* triggers: [{ type: "manual" }],
|
|
594
|
+
* connectors: [jiraConnector, slackConnector],
|
|
595
|
+
* resources: { maxTokens: 100_000, maxCostUsd: 5 },
|
|
596
|
+
* });
|
|
597
|
+
* ```
|
|
598
|
+
*/
|
|
599
|
+
export declare const definePlatformAgent: <TOutput extends ZodType = ZodType>(config: PlatformAgentInputConfig & {
|
|
600
|
+
agent: AgentInputField & {
|
|
601
|
+
outputSchema?: TOutput;
|
|
602
|
+
};
|
|
132
603
|
}) => PlatformAgent & {
|
|
133
|
-
|
|
604
|
+
outputSchema?: TOutput;
|
|
134
605
|
};
|
|
135
|
-
|
|
136
606
|
/**
|
|
137
|
-
* Define
|
|
607
|
+
* Define a standalone action with a name, Zod schema, optional webhook, and
|
|
608
|
+
* optional handler.
|
|
138
609
|
*
|
|
139
|
-
*
|
|
610
|
+
* Actions are the agent's typed terminal outputs — each action is a possible
|
|
611
|
+
* decision the agent can make. The handler's payload type is inferred from
|
|
612
|
+
* the schema, giving you end-to-end type safety.
|
|
613
|
+
*
|
|
614
|
+
* @param input - Action name, schema, optional webhook URL, and optional handler.
|
|
615
|
+
* @returns A frozen {@link PlatformAction} object.
|
|
616
|
+
* @throws If `name` is empty, invalid, or longer than 64 chars.
|
|
140
617
|
*
|
|
141
618
|
* @example
|
|
142
619
|
* ```ts
|
|
143
|
-
* defineAction
|
|
144
|
-
*
|
|
620
|
+
* import { defineAction } from "@kraken-ai/platform";
|
|
621
|
+
* import { z } from "zod";
|
|
622
|
+
*
|
|
623
|
+
* export default defineAction({
|
|
624
|
+
* name: "approve",
|
|
625
|
+
* schema: z.object({ reason: z.string(), confidence: z.number() }),
|
|
145
626
|
* handler: async (payload) => {
|
|
146
|
-
* payload.reason;
|
|
627
|
+
* payload.reason; // string
|
|
628
|
+
* payload.confidence; // number
|
|
147
629
|
* },
|
|
148
630
|
* });
|
|
149
631
|
* ```
|
|
150
632
|
*/
|
|
151
|
-
declare const defineAction: <S extends z.ZodObject<z.ZodRawShape>>(input: ActionVariantInput<S>) =>
|
|
633
|
+
export declare const defineAction: <S extends z.ZodObject<z.ZodRawShape>>(input: ActionVariantInput<S>) => PlatformAction;
|
|
152
634
|
/**
|
|
153
|
-
*
|
|
154
|
-
* outputs — the agent's final decision as structured output.
|
|
635
|
+
* Build a discriminated-union Zod schema from action definitions.
|
|
155
636
|
*
|
|
156
|
-
* Each
|
|
157
|
-
*
|
|
158
|
-
* in
|
|
637
|
+
* Each action becomes `z.object({ action: z.literal(name), ...fields })`,
|
|
638
|
+
* and the union discriminates on the `action` key. Pass the result as
|
|
639
|
+
* `outputSchema` in {@link definePlatformAgent} to constrain the agent's
|
|
640
|
+
* structured output to exactly one of the defined actions.
|
|
159
641
|
*
|
|
160
|
-
*
|
|
642
|
+
* @param actions - Array of {@link PlatformAction} objects returned by {@link defineAction}.
|
|
643
|
+
* @returns A `z.ZodDiscriminatedUnion` schema.
|
|
644
|
+
* @throws If `actions` is empty.
|
|
161
645
|
*
|
|
162
646
|
* @example
|
|
163
647
|
* ```ts
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
648
|
+
* import { defineAction, buildActionOutputSchema } from "@kraken-ai/platform";
|
|
649
|
+
* import { z } from "zod";
|
|
650
|
+
*
|
|
651
|
+
* const approve = defineAction({
|
|
652
|
+
* name: "approve",
|
|
653
|
+
* schema: z.object({ reason: z.string() }),
|
|
654
|
+
* });
|
|
655
|
+
* const reject = defineAction({
|
|
656
|
+
* name: "reject",
|
|
657
|
+
* schema: z.object({ reason: z.string() }),
|
|
172
658
|
* });
|
|
659
|
+
*
|
|
660
|
+
* const outputSchema = buildActionOutputSchema([approve, reject]);
|
|
661
|
+
* // Accepts: { action: "approve", reason: "..." }
|
|
662
|
+
* // or: { action: "reject", reason: "..." }
|
|
173
663
|
* ```
|
|
174
664
|
*/
|
|
175
|
-
declare const
|
|
665
|
+
export declare const buildActionOutputSchema: (actions: PlatformAction[]) => z.ZodDiscriminatedUnion<[
|
|
666
|
+
z.ZodObject<{
|
|
667
|
+
readonly [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
668
|
+
}, z.core.$strip>,
|
|
669
|
+
...z.ZodObject<{
|
|
670
|
+
readonly [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
671
|
+
}, z.core.$strip>[]
|
|
672
|
+
], "action">;
|
|
176
673
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
674
|
+
* Define a single tool for use inside a connector.
|
|
675
|
+
*
|
|
676
|
+
* Accepts a Zod schema as `input` and infers the handler's argument types
|
|
677
|
+
* from it, giving you end-to-end type safety from schema to handler.
|
|
678
|
+
*
|
|
679
|
+
* @example
|
|
680
|
+
* ```ts
|
|
681
|
+
* const add = defineTool({
|
|
682
|
+
* description: "Add two numbers",
|
|
683
|
+
* input: z.object({ a: z.number(), b: z.number() }),
|
|
684
|
+
* handler: ({ a, b }) => a + b,
|
|
685
|
+
* });
|
|
686
|
+
* ```
|
|
180
687
|
*/
|
|
181
|
-
declare const
|
|
182
|
-
readonly [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
183
|
-
}, z.core.$strip>, ...z.ZodObject<{
|
|
184
|
-
readonly [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
185
|
-
}, z.core.$strip>[]], "action">;
|
|
186
|
-
|
|
688
|
+
export declare const defineTool: <T extends ZodType>(def: ConnectorToolDef<T>) => ConnectorToolDef<T>;
|
|
187
689
|
/**
|
|
188
|
-
* Define a connector
|
|
690
|
+
* Define a connector that exposes tools, resources, and prompts to AI agents
|
|
691
|
+
* through the Kraken platform.
|
|
692
|
+
*
|
|
693
|
+
* A connector is the primary building block for extending agent capabilities.
|
|
694
|
+
* Each connector is served as an MCP server and can provide:
|
|
695
|
+
*
|
|
696
|
+
* - **Tools** — functions the agent can call (defined with {@link defineTool})
|
|
697
|
+
* - **Resources** — data the agent can read (files, database rows, API responses)
|
|
698
|
+
* - **Prompts** — reusable prompt templates the agent can invoke
|
|
699
|
+
*
|
|
700
|
+
* The returned object is deeply frozen and ready to be passed to the platform
|
|
701
|
+
* server builder.
|
|
702
|
+
*
|
|
703
|
+
* @param input - The connector definition including a unique name and optional
|
|
704
|
+
* tools, resources, and prompts.
|
|
705
|
+
* @returns A frozen {@link PlatformConnector} object.
|
|
706
|
+
* @throws If `name` is empty.
|
|
707
|
+
*
|
|
708
|
+
* @example
|
|
709
|
+
* ```ts
|
|
710
|
+
* import { defineConnector, defineTool } from "@kraken-ai/platform";
|
|
711
|
+
* import { z } from "zod";
|
|
189
712
|
*
|
|
190
|
-
*
|
|
713
|
+
* export default defineConnector({
|
|
714
|
+
* name: "math",
|
|
715
|
+
* description: "Basic math operations",
|
|
716
|
+
* tools: {
|
|
717
|
+
* add: defineTool({
|
|
718
|
+
* description: "Add two numbers",
|
|
719
|
+
* input: z.object({ a: z.number(), b: z.number() }),
|
|
720
|
+
* handler: ({ a, b }) => a + b,
|
|
721
|
+
* }),
|
|
722
|
+
* },
|
|
723
|
+
* });
|
|
724
|
+
* ```
|
|
191
725
|
*/
|
|
192
|
-
declare const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
726
|
+
export declare const defineConnector: <const T extends ConnectorDefinition>(input: T) => PlatformConnector;
|
|
727
|
+
/**
|
|
728
|
+
* Define a reusable skill that can be attached to one or more agents.
|
|
729
|
+
*
|
|
730
|
+
* A skill is a named capability (e.g. "competitor-deep-dive") that the
|
|
731
|
+
* platform resolves into the appropriate prompt and tool set at runtime.
|
|
732
|
+
* Skills are referenced by agents via the `skills` array in
|
|
733
|
+
* {@link definePlatformAgent}.
|
|
734
|
+
*
|
|
735
|
+
* @param input - Skill name and optional description.
|
|
736
|
+
* @returns A frozen {@link PlatformSkill} object.
|
|
737
|
+
* @throws If `name` is empty.
|
|
738
|
+
*
|
|
739
|
+
* @example
|
|
740
|
+
* ```ts
|
|
741
|
+
* import { defineSkill, definePlatformAgent } from "@kraken-ai/platform";
|
|
742
|
+
*
|
|
743
|
+
* const deepDive = defineSkill({
|
|
744
|
+
* name: "competitor-deep-dive",
|
|
745
|
+
* description: "In-depth competitor analysis with market sizing",
|
|
746
|
+
* });
|
|
747
|
+
*
|
|
748
|
+
* export default definePlatformAgent({
|
|
749
|
+
* agent: {
|
|
750
|
+
* name: "analyst",
|
|
751
|
+
* model: "anthropic/claude-sonnet-4-20250514",
|
|
752
|
+
* instructions: "You are a competitive analyst.",
|
|
753
|
+
* skills: [deepDive],
|
|
754
|
+
* },
|
|
755
|
+
* triggers: [{ type: "manual" }],
|
|
756
|
+
* });
|
|
757
|
+
* ```
|
|
758
|
+
*/
|
|
759
|
+
export declare const defineSkill: (input: {
|
|
760
|
+
name: string;
|
|
761
|
+
description?: string;
|
|
198
762
|
}) => PlatformSkill;
|
|
199
|
-
|
|
200
|
-
declare
|
|
201
|
-
readonly code = "SECURITY_VIOLATION";
|
|
202
|
-
constructor(message: string);
|
|
203
|
-
}
|
|
204
|
-
declare class ConnectorError extends Error {
|
|
205
|
-
readonly code = "CONNECTOR_ERROR";
|
|
206
|
-
constructor(message: string);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
declare const MANIFEST_START = "---KRAKEN-MANIFEST-START---";
|
|
210
|
-
declare const MANIFEST_END = "---KRAKEN-MANIFEST-END---";
|
|
763
|
+
export declare const MANIFEST_START = "---KRAKEN-MANIFEST-START---";
|
|
764
|
+
export declare const MANIFEST_END = "---KRAKEN-MANIFEST-END---";
|
|
211
765
|
declare const projectManifestSchema: z.ZodObject<{
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
766
|
+
agents: z.ZodArray<z.ZodObject<{
|
|
767
|
+
name: z.ZodString;
|
|
768
|
+
entryPoint: z.ZodString;
|
|
769
|
+
config: z.ZodObject<{
|
|
770
|
+
agent: z.ZodObject<{
|
|
771
|
+
name: z.ZodString;
|
|
772
|
+
model: z.ZodString;
|
|
773
|
+
instructions: z.ZodString;
|
|
774
|
+
description: z.ZodOptional<z.ZodString>;
|
|
775
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
776
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
777
|
+
allowTemperatureOverride: z.ZodOptional<z.ZodBoolean>;
|
|
778
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
779
|
+
thinkingLevel: z.ZodOptional<z.ZodEnum<{
|
|
780
|
+
low: "low";
|
|
781
|
+
medium: "medium";
|
|
782
|
+
high: "high";
|
|
783
|
+
}>>;
|
|
784
|
+
logLevel: z.ZodOptional<z.ZodEnum<{
|
|
785
|
+
error: "error";
|
|
786
|
+
silent: "silent";
|
|
787
|
+
debug: "debug";
|
|
788
|
+
info: "info";
|
|
789
|
+
warn: "warn";
|
|
790
|
+
}>>;
|
|
791
|
+
}, z.core.$strict>;
|
|
792
|
+
connectors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
793
|
+
triggers: z.ZodArray<z.ZodDiscriminatedUnion<[
|
|
794
|
+
z.ZodObject<{
|
|
795
|
+
type: z.ZodLiteral<"cron">;
|
|
796
|
+
expression: z.ZodString;
|
|
797
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
798
|
+
}, z.core.$strip>,
|
|
799
|
+
z.ZodObject<{
|
|
800
|
+
type: z.ZodLiteral<"webhook">;
|
|
801
|
+
path: z.ZodString;
|
|
802
|
+
method: z.ZodOptional<z.ZodEnum<{
|
|
803
|
+
POST: "POST";
|
|
804
|
+
GET: "GET";
|
|
805
|
+
}>>;
|
|
806
|
+
}, z.core.$strip>,
|
|
807
|
+
z.ZodObject<{
|
|
808
|
+
type: z.ZodLiteral<"event">;
|
|
809
|
+
source: z.ZodString;
|
|
810
|
+
event: z.ZodString;
|
|
811
|
+
}, z.core.$strip>,
|
|
812
|
+
z.ZodObject<{
|
|
813
|
+
type: z.ZodLiteral<"api">;
|
|
814
|
+
}, z.core.$strip>,
|
|
815
|
+
z.ZodObject<{
|
|
816
|
+
type: z.ZodLiteral<"manual">;
|
|
817
|
+
}, z.core.$strip>
|
|
818
|
+
], "type">>;
|
|
819
|
+
identity: z.ZodOptional<z.ZodObject<{
|
|
820
|
+
basePermissions: z.ZodArray<z.ZodString>;
|
|
821
|
+
requestablePermissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
822
|
+
jitPolicy: z.ZodOptional<z.ZodEnum<{
|
|
823
|
+
"auto-approve": "auto-approve";
|
|
824
|
+
"policy-based": "policy-based";
|
|
825
|
+
"require-approval": "require-approval";
|
|
826
|
+
}>>;
|
|
827
|
+
maxJitDurationMinutes: z.ZodOptional<z.ZodNumber>;
|
|
828
|
+
}, z.core.$strip>>;
|
|
829
|
+
resources: z.ZodOptional<z.ZodObject<{
|
|
830
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
831
|
+
maxCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
832
|
+
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
833
|
+
}, z.core.$strip>>;
|
|
834
|
+
retries: z.ZodOptional<z.ZodObject<{
|
|
835
|
+
maxAttempts: z.ZodOptional<z.ZodNumber>;
|
|
836
|
+
backoffSeconds: z.ZodOptional<z.ZodNumber>;
|
|
837
|
+
}, z.core.$strip>>;
|
|
838
|
+
concurrency: z.ZodOptional<z.ZodObject<{
|
|
839
|
+
maxParallelRuns: z.ZodOptional<z.ZodNumber>;
|
|
840
|
+
}, z.core.$strip>>;
|
|
841
|
+
fast: z.ZodOptional<z.ZodBoolean>;
|
|
842
|
+
team: z.ZodOptional<z.ZodObject<{
|
|
843
|
+
members: z.ZodArray<z.ZodString>;
|
|
844
|
+
maxConcurrentWorkers: z.ZodOptional<z.ZodNumber>;
|
|
845
|
+
maxTokenBudgetPerWorker: z.ZodOptional<z.ZodNumber>;
|
|
846
|
+
maxDurationPerWorker: z.ZodOptional<z.ZodNumber>;
|
|
847
|
+
}, z.core.$strip>>;
|
|
848
|
+
notifications: z.ZodOptional<z.ZodObject<{
|
|
849
|
+
slack: z.ZodOptional<z.ZodString>;
|
|
850
|
+
onSuccess: z.ZodOptional<z.ZodBoolean>;
|
|
851
|
+
onFailure: z.ZodOptional<z.ZodBoolean>;
|
|
852
|
+
onTimeout: z.ZodOptional<z.ZodBoolean>;
|
|
853
|
+
}, z.core.$strip>>;
|
|
854
|
+
environment: z.ZodOptional<z.ZodEnum<{
|
|
855
|
+
dev: "dev";
|
|
856
|
+
staging: "staging";
|
|
857
|
+
prod: "prod";
|
|
858
|
+
}>>;
|
|
859
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
860
|
+
}, z.core.$strict>;
|
|
861
|
+
}, z.core.$strip>>;
|
|
862
|
+
skills: z.ZodArray<z.ZodObject<{
|
|
863
|
+
name: z.ZodString;
|
|
864
|
+
path: z.ZodString;
|
|
865
|
+
content: z.ZodString;
|
|
866
|
+
}, z.core.$strip>>;
|
|
867
|
+
connectors: z.ZodArray<z.ZodObject<{
|
|
868
|
+
name: z.ZodString;
|
|
869
|
+
path: z.ZodString;
|
|
870
|
+
toolSpecs: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
871
|
+
name: z.ZodString;
|
|
872
|
+
description: z.ZodString;
|
|
873
|
+
parameters: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
874
|
+
annotations: z.ZodOptional<z.ZodObject<{
|
|
875
|
+
readOnlyHint: z.ZodOptional<z.ZodBoolean>;
|
|
876
|
+
destructiveHint: z.ZodOptional<z.ZodBoolean>;
|
|
877
|
+
idempotentHint: z.ZodOptional<z.ZodBoolean>;
|
|
878
|
+
}, z.core.$strip>>;
|
|
879
|
+
}, z.core.$strip>>>;
|
|
880
|
+
resourceSpecs: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
881
|
+
name: z.ZodString;
|
|
882
|
+
uri: z.ZodString;
|
|
883
|
+
description: z.ZodString;
|
|
884
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
885
|
+
}, z.core.$strip>>>;
|
|
886
|
+
promptSpecs: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
887
|
+
name: z.ZodString;
|
|
888
|
+
description: z.ZodString;
|
|
889
|
+
arguments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
890
|
+
name: z.ZodString;
|
|
891
|
+
description: z.ZodOptional<z.ZodString>;
|
|
892
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
893
|
+
}, z.core.$strip>>>;
|
|
894
|
+
}, z.core.$strip>>>;
|
|
895
|
+
}, z.core.$strip>>;
|
|
896
|
+
actions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
897
|
+
name: z.ZodString;
|
|
898
|
+
entryPoint: z.ZodString;
|
|
899
|
+
config: z.ZodObject<{
|
|
900
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
901
|
+
webhook: z.ZodOptional<z.ZodString>;
|
|
902
|
+
hasHandler: z.ZodBoolean;
|
|
903
|
+
}, z.core.$strip>;
|
|
904
|
+
}, z.core.$strip>>>;
|
|
316
905
|
}, z.core.$strip>;
|
|
317
|
-
type ProjectManifest = z.infer<typeof projectManifestSchema>;
|
|
906
|
+
export type ProjectManifest = z.infer<typeof projectManifestSchema>;
|
|
318
907
|
/** Parse manifest from stdout that may contain noise before/after sentinel markers. */
|
|
319
|
-
declare const parseManifestFromOutput: (stdout: string) => ProjectManifest;
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
constructor(message: string, status: number);
|
|
908
|
+
export declare const parseManifestFromOutput: (stdout: string) => ProjectManifest;
|
|
909
|
+
export declare class PlatformError extends Error {
|
|
910
|
+
readonly status: number;
|
|
911
|
+
constructor(message: string, status: number);
|
|
324
912
|
}
|
|
325
913
|
declare class HttpClient {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
914
|
+
readonly baseUrlForStream: string;
|
|
915
|
+
private readonly baseUrl;
|
|
916
|
+
private readonly apiKey;
|
|
917
|
+
constructor(config: {
|
|
918
|
+
baseUrl: string;
|
|
919
|
+
apiKey: string;
|
|
920
|
+
});
|
|
921
|
+
get<T>(path: string, params?: Record<string, string>): Promise<T>;
|
|
922
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
923
|
+
postStream(path: string, body: unknown, signal?: AbortSignal): Promise<Response>;
|
|
924
|
+
private buildUrl;
|
|
925
|
+
authHeaders(): Record<string, string>;
|
|
926
|
+
private handleResponse;
|
|
336
927
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
928
|
+
export interface PlatformClientConfig {
|
|
929
|
+
baseUrl?: string;
|
|
930
|
+
apiKey?: string;
|
|
931
|
+
}
|
|
932
|
+
export interface PaginationParams {
|
|
933
|
+
cursor?: string;
|
|
934
|
+
limit?: number;
|
|
935
|
+
}
|
|
936
|
+
export interface PaginatedResponse<T> {
|
|
937
|
+
data: T[];
|
|
938
|
+
cursor: string | null;
|
|
939
|
+
hasMore: boolean;
|
|
940
|
+
}
|
|
941
|
+
export type AgentEvent = {
|
|
942
|
+
type: "text";
|
|
943
|
+
content: string;
|
|
944
|
+
} | {
|
|
945
|
+
type: "tool_call";
|
|
946
|
+
name: string;
|
|
947
|
+
args: Record<string, unknown>;
|
|
948
|
+
} | {
|
|
949
|
+
type: "tool_result";
|
|
950
|
+
name: string;
|
|
951
|
+
result: unknown;
|
|
952
|
+
} | {
|
|
953
|
+
type: "thinking";
|
|
954
|
+
content: string;
|
|
955
|
+
} | {
|
|
956
|
+
type: "action";
|
|
957
|
+
name: string;
|
|
958
|
+
payload: Record<string, unknown>;
|
|
959
|
+
actionExecutionId: string;
|
|
960
|
+
} | {
|
|
961
|
+
type: "done";
|
|
962
|
+
output: string;
|
|
963
|
+
usage?: {
|
|
964
|
+
tokens: number;
|
|
965
|
+
};
|
|
966
|
+
} | {
|
|
967
|
+
type: "error";
|
|
968
|
+
message: string;
|
|
969
|
+
code: string;
|
|
970
|
+
};
|
|
971
|
+
export interface AgentInfo {
|
|
972
|
+
id: string;
|
|
973
|
+
name: string;
|
|
974
|
+
description?: string;
|
|
975
|
+
}
|
|
976
|
+
export interface ThreadInfo {
|
|
977
|
+
id: string;
|
|
978
|
+
agentId: string;
|
|
979
|
+
createdAt: string;
|
|
980
|
+
updatedAt: string;
|
|
981
|
+
}
|
|
982
|
+
export interface ThreadMessage {
|
|
983
|
+
id: string;
|
|
984
|
+
threadId: string;
|
|
985
|
+
role: "user" | "assistant";
|
|
986
|
+
content: string;
|
|
987
|
+
toolCalls?: Array<{
|
|
988
|
+
name: string;
|
|
989
|
+
args: Record<string, unknown>;
|
|
990
|
+
result: unknown;
|
|
991
|
+
}>;
|
|
992
|
+
createdAt: string;
|
|
993
|
+
usage?: {
|
|
994
|
+
tokens: number;
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
export interface QueryInfo {
|
|
998
|
+
name: string;
|
|
999
|
+
description?: string;
|
|
1000
|
+
params: Record<string, unknown>;
|
|
1001
|
+
columns: QueryColumn[];
|
|
1002
|
+
}
|
|
1003
|
+
export interface QueryColumn {
|
|
1004
|
+
name: string;
|
|
1005
|
+
type: string;
|
|
1006
|
+
description?: string;
|
|
1007
|
+
}
|
|
1008
|
+
export interface QueryResult<TRow = Record<string, unknown>> {
|
|
1009
|
+
rows: TRow[];
|
|
1010
|
+
cursor: string | null;
|
|
1011
|
+
hasMore: boolean;
|
|
1012
|
+
}
|
|
1013
|
+
export type RunState = "QUEUED" | "PROVISIONING" | "RUNNING" | "DRAINING" | "COMPLETED" | "FAILED" | "AWAITING_APPROVAL" | "RETRYING";
|
|
1014
|
+
export interface RunRecord {
|
|
1015
|
+
runId: string;
|
|
1016
|
+
agentId: string;
|
|
1017
|
+
input: string;
|
|
1018
|
+
state: RunState;
|
|
1019
|
+
exitCode?: number;
|
|
1020
|
+
createdAt: string;
|
|
1021
|
+
updatedAt: string;
|
|
1022
|
+
retryCount: number;
|
|
1023
|
+
error?: string;
|
|
1024
|
+
}
|
|
1025
|
+
export interface StartRunParams {
|
|
1026
|
+
agentId: string;
|
|
1027
|
+
tag?: string;
|
|
1028
|
+
environment?: "dev" | "staging" | "prod";
|
|
1029
|
+
input: string;
|
|
1030
|
+
connectors?: string[];
|
|
1031
|
+
envVars?: Record<string, string>;
|
|
1032
|
+
/** When true, tool calls are logged but not executed. */
|
|
1033
|
+
dryRun?: boolean;
|
|
1034
|
+
}
|
|
1035
|
+
export interface RunEvent {
|
|
1036
|
+
eventId: string;
|
|
1037
|
+
eventType: string;
|
|
1038
|
+
payload: Record<string, unknown>;
|
|
1039
|
+
}
|
|
1040
|
+
export interface AgentSchema {
|
|
1041
|
+
id: string;
|
|
1042
|
+
name: string;
|
|
1043
|
+
input: Record<string, unknown>;
|
|
1044
|
+
output: Record<string, unknown>;
|
|
1045
|
+
actions?: Record<string, Record<string, unknown>>;
|
|
1046
|
+
config?: {
|
|
1047
|
+
actions?: string[];
|
|
1048
|
+
[key: string]: unknown;
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
export interface QuerySchema {
|
|
1052
|
+
name: string;
|
|
1053
|
+
params: Record<string, unknown>;
|
|
1054
|
+
columns: QueryColumn[];
|
|
1055
|
+
}
|
|
1056
|
+
export interface ConnectorSchema {
|
|
1057
|
+
id: string;
|
|
1058
|
+
tools: Array<{
|
|
1059
|
+
name: string;
|
|
1060
|
+
description: string;
|
|
1061
|
+
parameters: Record<string, unknown>;
|
|
1062
|
+
}>;
|
|
1063
|
+
}
|
|
1064
|
+
export interface SkillSchema {
|
|
1065
|
+
id: string;
|
|
1066
|
+
name: string;
|
|
1067
|
+
description?: string;
|
|
1068
|
+
}
|
|
1069
|
+
export interface ActionSchema {
|
|
1070
|
+
id: string;
|
|
1071
|
+
name: string;
|
|
1072
|
+
schema: Record<string, unknown>;
|
|
1073
|
+
hasHandler: boolean;
|
|
1074
|
+
}
|
|
1075
|
+
export interface AgentRegistryEntry {
|
|
1076
|
+
input: unknown;
|
|
1077
|
+
output: unknown;
|
|
1078
|
+
actions: Record<string, unknown>;
|
|
342
1079
|
}
|
|
343
1080
|
/**
|
|
344
1081
|
* Augmentable agent registry — `kraken generate` populates this via
|
|
345
1082
|
* `declare module "@kraken-ai/platform" { interface AgentRegistry { ... } }`.
|
|
346
1083
|
* When populated, `client.agent("id")` infers input/output/actions automatically.
|
|
347
1084
|
*/
|
|
348
|
-
|
|
349
|
-
interface GenerateOpts {
|
|
350
|
-
signal?: AbortSignal;
|
|
351
|
-
}
|
|
352
|
-
interface GenerateResult<T extends AgentRegistryEntry> {
|
|
353
|
-
readonly threadId: string;
|
|
354
|
-
stream(): AsyncIterable<AgentEvent>;
|
|
355
|
-
readonly result: Promise<T["output"]>;
|
|
356
|
-
}
|
|
357
|
-
declare class AgentHandle<T extends AgentRegistryEntry> {
|
|
358
|
-
private readonly http;
|
|
359
|
-
private readonly agentId;
|
|
360
|
-
private readonly actionHandlers;
|
|
361
|
-
private threadId;
|
|
362
|
-
constructor(http: HttpClient, agentId: string, opts?: {
|
|
363
|
-
threadId?: string;
|
|
364
|
-
});
|
|
365
|
-
onAction<K extends keyof T["actions"] & string>(name: K, handler: (payload: T["actions"][K]) => void | Promise<void>): void;
|
|
366
|
-
generate(input: T["input"], opts?: GenerateOpts): Promise<GenerateResult<T>>;
|
|
1085
|
+
export interface AgentRegistry {
|
|
367
1086
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
1087
|
+
export interface GenerateOpts {
|
|
1088
|
+
signal?: AbortSignal;
|
|
1089
|
+
}
|
|
1090
|
+
export interface GenerateResult<T extends AgentRegistryEntry> {
|
|
1091
|
+
readonly threadId: string;
|
|
1092
|
+
stream(): AsyncIterable<AgentEvent>;
|
|
1093
|
+
readonly result: Promise<T["output"]>;
|
|
1094
|
+
}
|
|
1095
|
+
export declare class AgentHandle<T extends AgentRegistryEntry> {
|
|
1096
|
+
private readonly http;
|
|
1097
|
+
private readonly agentId;
|
|
1098
|
+
private readonly actionHandlers;
|
|
1099
|
+
private threadId;
|
|
1100
|
+
constructor(http: HttpClient, agentId: string, opts?: {
|
|
1101
|
+
threadId?: string;
|
|
1102
|
+
});
|
|
1103
|
+
onAction<K extends keyof T["actions"] & string>(name: K, handler: (payload: T["actions"][K]) => void | Promise<void>): void;
|
|
1104
|
+
generate(input: T["input"], opts?: GenerateOpts): Promise<GenerateResult<T>>;
|
|
1105
|
+
}
|
|
1106
|
+
export declare class AgentThread {
|
|
1107
|
+
private readonly http;
|
|
1108
|
+
private readonly agentId;
|
|
1109
|
+
readonly threadId: string;
|
|
1110
|
+
constructor(http: HttpClient, agentId: string, threadId: string);
|
|
1111
|
+
sendMessage(content: string, opts?: {
|
|
1112
|
+
signal?: AbortSignal;
|
|
1113
|
+
}): Promise<AsyncIterable<AgentEvent>>;
|
|
1114
|
+
getMessages(params?: PaginationParams): Promise<PaginatedResponse<ThreadMessage>>;
|
|
378
1115
|
}
|
|
379
1116
|
declare class AgentsNamespace {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
1117
|
+
private readonly http;
|
|
1118
|
+
constructor(http: HttpClient);
|
|
1119
|
+
list(): Promise<AgentInfo[]>;
|
|
1120
|
+
createThread(agentId: string): Promise<AgentThread>;
|
|
1121
|
+
getThread(agentId: string, threadId: string): Promise<AgentThread>;
|
|
1122
|
+
listThreads(agentId: string, params?: PaginationParams): Promise<PaginatedResponse<ThreadInfo>>;
|
|
386
1123
|
}
|
|
387
|
-
|
|
388
1124
|
declare class DataNamespace {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
1125
|
+
private readonly http;
|
|
1126
|
+
constructor(http: HttpClient);
|
|
1127
|
+
list(): Promise<QueryInfo[]>;
|
|
1128
|
+
describe(queryName: string): Promise<QueryInfo>;
|
|
1129
|
+
query<TRow = Record<string, unknown>>(queryName: string, params?: Record<string, unknown>, pagination?: PaginationParams): Promise<QueryResult<TRow>>;
|
|
394
1130
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
returns: R;
|
|
1131
|
+
export interface PipelineQueryDef<P extends ZodType, R extends ZodType> {
|
|
1132
|
+
params: P;
|
|
1133
|
+
returns: R;
|
|
399
1134
|
}
|
|
400
1135
|
declare class PipelinesNamespace {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
1136
|
+
private readonly http;
|
|
1137
|
+
constructor(http: HttpClient);
|
|
1138
|
+
query<P extends ZodType, R extends ZodType>(pipeline: string, queryName: string, schema: PipelineQueryDef<P, R>, params: z.infer<P>): Promise<z.infer<R>[]>;
|
|
404
1139
|
}
|
|
405
|
-
|
|
406
1140
|
declare class RunsNamespace {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
1141
|
+
private readonly http;
|
|
1142
|
+
constructor(http: HttpClient);
|
|
1143
|
+
start(params: StartRunParams): Promise<{
|
|
1144
|
+
runId: string;
|
|
1145
|
+
}>;
|
|
1146
|
+
get(runId: string): Promise<RunRecord>;
|
|
1147
|
+
cancel(runId: string): Promise<{
|
|
1148
|
+
success: boolean;
|
|
1149
|
+
}>;
|
|
1150
|
+
getEvents(runId: string, opts?: {
|
|
1151
|
+
afterEventId?: string;
|
|
1152
|
+
}): Promise<{
|
|
1153
|
+
events: RunEvent[];
|
|
1154
|
+
}>;
|
|
1155
|
+
streamEvents(runId: string, opts?: {
|
|
1156
|
+
signal?: AbortSignal;
|
|
1157
|
+
}): AsyncGenerator<RunEvent>;
|
|
424
1158
|
}
|
|
425
|
-
|
|
1159
|
+
/** When AgentRegistry is populated (after `kraken generate`), constrain to known keys for autocomplete. Otherwise accept any string. */
|
|
1160
|
+
export type AgentIdConstraint = keyof AgentRegistry extends never ? string : keyof AgentRegistry;
|
|
426
1161
|
/** Resolve agent type: if K is a known key in AgentRegistry use it, otherwise fall back to AgentRegistryEntry. */
|
|
427
|
-
type ResolveAgent<K extends string> = K extends keyof AgentRegistry ? AgentRegistry[K] : AgentRegistryEntry;
|
|
428
|
-
declare class PlatformClient {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
1162
|
+
export type ResolveAgent<K extends string> = K extends keyof AgentRegistry ? AgentRegistry[K] : AgentRegistryEntry;
|
|
1163
|
+
export declare class PlatformClient {
|
|
1164
|
+
readonly agents: AgentsNamespace;
|
|
1165
|
+
readonly data: DataNamespace;
|
|
1166
|
+
readonly pipelines: PipelinesNamespace;
|
|
1167
|
+
readonly runs: RunsNamespace;
|
|
1168
|
+
private readonly http;
|
|
1169
|
+
constructor(config?: PlatformClientConfig);
|
|
1170
|
+
agent<K extends AgentIdConstraint>(id: K, opts?: {
|
|
1171
|
+
mode?: "local" | "remote";
|
|
1172
|
+
threadId?: string;
|
|
1173
|
+
}): AgentHandle<ResolveAgent<K>>;
|
|
439
1174
|
}
|
|
440
1175
|
|
|
441
|
-
export {
|
|
1176
|
+
export {
|
|
1177
|
+
z,
|
|
1178
|
+
};
|
|
1179
|
+
|
|
1180
|
+
export {};
|