@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.d.cts
CHANGED
|
@@ -1,441 +1,1145 @@
|
|
|
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
|
+
team: z.ZodOptional<z.ZodObject<{
|
|
288
|
+
members: z.ZodArray<z.ZodString>;
|
|
289
|
+
maxConcurrentWorkers: z.ZodOptional<z.ZodNumber>;
|
|
290
|
+
maxTokenBudgetPerWorker: z.ZodOptional<z.ZodNumber>;
|
|
291
|
+
maxDurationPerWorker: z.ZodOptional<z.ZodNumber>;
|
|
292
|
+
}, z.core.$strip>>;
|
|
293
|
+
notifications: z.ZodOptional<z.ZodObject<{
|
|
294
|
+
slack: z.ZodOptional<z.ZodString>;
|
|
295
|
+
onSuccess: z.ZodOptional<z.ZodBoolean>;
|
|
296
|
+
onFailure: z.ZodOptional<z.ZodBoolean>;
|
|
297
|
+
onTimeout: z.ZodOptional<z.ZodBoolean>;
|
|
298
|
+
}, z.core.$strip>>;
|
|
299
|
+
environment: z.ZodOptional<z.ZodEnum<{
|
|
300
|
+
dev: "dev";
|
|
301
|
+
staging: "staging";
|
|
302
|
+
prod: "prod";
|
|
303
|
+
}>>;
|
|
304
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
305
|
+
}, z.core.$strict>;
|
|
306
|
+
export type PlatformAgentConfig = Omit<z.infer<typeof platformAgentConfigSchema>, "agent"> & {
|
|
307
|
+
agent: AgentDefinition;
|
|
308
|
+
};
|
|
309
|
+
export interface PlatformAgent {
|
|
310
|
+
readonly __type: "PlatformAgent";
|
|
311
|
+
readonly config: PlatformAgentConfig;
|
|
312
|
+
readonly runtime?: unknown;
|
|
313
|
+
/** In-memory schemas for action variants. Not serialized — runtime use only. */
|
|
314
|
+
readonly actionZodSchemas?: Record<string, import("zod").ZodObject<import("zod").ZodRawShape>>;
|
|
315
|
+
/** Action handler functions. Not serialized — runtime use only. */
|
|
316
|
+
readonly actionHandlers?: Readonly<Record<string, (payload: unknown) => Promise<void>>>;
|
|
317
|
+
/** Action webhook URLs. Not serialized — runtime use only. */
|
|
318
|
+
readonly actionWebhooks?: Readonly<Record<string, string | undefined>>;
|
|
319
|
+
/** Team member PlatformAgent objects. Not serialized — runtime use only (dev mode delegation). */
|
|
320
|
+
readonly teamAgents?: readonly PlatformAgent[];
|
|
59
321
|
}
|
|
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
322
|
declare const resourceLimitsSchema: z.ZodObject<{
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
323
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
324
|
+
maxCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
325
|
+
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
70
326
|
}, z.core.$strip>;
|
|
71
|
-
type ResourceLimits = z.infer<typeof resourceLimitsSchema>;
|
|
327
|
+
export type ResourceLimits = z.infer<typeof resourceLimitsSchema>;
|
|
72
328
|
declare const retryPolicySchema: z.ZodObject<{
|
|
73
|
-
|
|
74
|
-
|
|
329
|
+
maxAttempts: z.ZodOptional<z.ZodNumber>;
|
|
330
|
+
backoffSeconds: z.ZodOptional<z.ZodNumber>;
|
|
75
331
|
}, z.core.$strip>;
|
|
76
|
-
type RetryPolicy = z.infer<typeof retryPolicySchema>;
|
|
332
|
+
export type RetryPolicy = z.infer<typeof retryPolicySchema>;
|
|
77
333
|
declare const concurrencyPolicySchema: z.ZodObject<{
|
|
78
|
-
|
|
334
|
+
maxParallelRuns: z.ZodOptional<z.ZodNumber>;
|
|
79
335
|
}, z.core.$strip>;
|
|
80
|
-
type ConcurrencyPolicy = z.infer<typeof concurrencyPolicySchema>;
|
|
81
|
-
|
|
336
|
+
export type ConcurrencyPolicy = z.infer<typeof concurrencyPolicySchema>;
|
|
337
|
+
export interface PlatformSkill {
|
|
338
|
+
readonly __type: "PlatformSkill";
|
|
339
|
+
readonly name: string;
|
|
340
|
+
readonly description?: string;
|
|
341
|
+
}
|
|
82
342
|
declare const teamConfigSchema: z.ZodObject<{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
343
|
+
members: z.ZodArray<z.ZodString>;
|
|
344
|
+
maxConcurrentWorkers: z.ZodOptional<z.ZodNumber>;
|
|
345
|
+
maxTokenBudgetPerWorker: z.ZodOptional<z.ZodNumber>;
|
|
346
|
+
maxDurationPerWorker: z.ZodOptional<z.ZodNumber>;
|
|
87
347
|
}, 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
|
-
|
|
348
|
+
export type TeamConfig = z.infer<typeof teamConfigSchema>;
|
|
349
|
+
declare const triggerConfigSchema: z.ZodDiscriminatedUnion<[
|
|
350
|
+
z.ZodObject<{
|
|
351
|
+
type: z.ZodLiteral<"cron">;
|
|
352
|
+
expression: z.ZodString;
|
|
353
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
354
|
+
}, z.core.$strip>,
|
|
355
|
+
z.ZodObject<{
|
|
356
|
+
type: z.ZodLiteral<"webhook">;
|
|
357
|
+
path: z.ZodString;
|
|
358
|
+
method: z.ZodOptional<z.ZodEnum<{
|
|
359
|
+
POST: "POST";
|
|
360
|
+
GET: "GET";
|
|
361
|
+
}>>;
|
|
362
|
+
}, z.core.$strip>,
|
|
363
|
+
z.ZodObject<{
|
|
364
|
+
type: z.ZodLiteral<"event">;
|
|
365
|
+
source: z.ZodString;
|
|
366
|
+
event: z.ZodString;
|
|
367
|
+
}, z.core.$strip>,
|
|
368
|
+
z.ZodObject<{
|
|
369
|
+
type: z.ZodLiteral<"api">;
|
|
370
|
+
}, z.core.$strip>,
|
|
371
|
+
z.ZodObject<{
|
|
372
|
+
type: z.ZodLiteral<"manual">;
|
|
373
|
+
}, z.core.$strip>
|
|
374
|
+
], "type">;
|
|
375
|
+
export type TriggerConfig = z.infer<typeof triggerConfigSchema>;
|
|
376
|
+
export interface ToolResultContent {
|
|
377
|
+
readonly type: string;
|
|
378
|
+
[key: string]: unknown;
|
|
379
|
+
}
|
|
380
|
+
export interface ToolResult {
|
|
381
|
+
readonly content: ReadonlyArray<ToolResultContent>;
|
|
382
|
+
readonly isError?: boolean;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Wrap a tool handler's return value into MCP `CallToolResult` format.
|
|
386
|
+
*
|
|
387
|
+
* Automatically converts primitives to `{ type: "text" }` content and
|
|
388
|
+
* serializes objects to JSON. Pass-through {@link McpContent} values
|
|
389
|
+
* (created with {@link mcpResult}) are forwarded as-is.
|
|
390
|
+
*
|
|
391
|
+
* @param value - The handler's return value (string, number, boolean,
|
|
392
|
+
* object, {@link McpContent}, or `null`/`undefined`).
|
|
393
|
+
* @returns An MCP-compatible tool result.
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* ```ts
|
|
397
|
+
* wrapToolResult("done"); // { content: [{ type: "text", text: "done" }] }
|
|
398
|
+
* wrapToolResult({ id: 1 }); // { content: [{ type: "text", text: '{\n "id": 1\n}' }] }
|
|
399
|
+
* wrapToolResult(null); // { content: [] }
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
export declare const wrapToolResult: (value: unknown) => ToolResult;
|
|
403
|
+
/**
|
|
404
|
+
* Wrap a thrown error into MCP `CallToolResult` format with `isError: true`.
|
|
405
|
+
*
|
|
406
|
+
* {@link ConnectorError} messages are forwarded to the agent as-is (they
|
|
407
|
+
* are user-facing). All other errors are replaced with a generic
|
|
408
|
+
* "Internal handler error" message and logged to stderr.
|
|
409
|
+
*
|
|
410
|
+
* @param error - The caught error.
|
|
411
|
+
* @returns An MCP-compatible error result.
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
* ```ts
|
|
415
|
+
* try {
|
|
416
|
+
* return wrapToolResult(await handler(args));
|
|
417
|
+
* } catch (err) {
|
|
418
|
+
* return wrapToolError(err);
|
|
419
|
+
* }
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
422
|
+
export declare const wrapToolError: (error: unknown) => ToolResult;
|
|
423
|
+
/**
|
|
424
|
+
* Create an explicit MCP content pass-through result.
|
|
425
|
+
*
|
|
426
|
+
* Use this when you need full control over the MCP response — for
|
|
427
|
+
* example, returning an image alongside text or marking a multi-part
|
|
428
|
+
* response as an error.
|
|
429
|
+
*
|
|
430
|
+
* @param content - Array of MCP content blocks (`{ type: "text", text }`,
|
|
431
|
+
* `{ type: "image", data, mimeType }`, etc.).
|
|
432
|
+
* @param isError - If `true`, the result is marked as an error.
|
|
433
|
+
* @returns An {@link McpContent} object that {@link wrapToolResult}
|
|
434
|
+
* forwards without modification.
|
|
435
|
+
*
|
|
436
|
+
* @example
|
|
437
|
+
* ```ts
|
|
438
|
+
* import { mcpResult } from "@kraken-ai/platform";
|
|
439
|
+
*
|
|
440
|
+
* const screenshot = defineTool({
|
|
441
|
+
* description: "Take a screenshot",
|
|
442
|
+
* input: z.object({ url: z.string().url() }),
|
|
443
|
+
* handler: async ({ url }) =>
|
|
444
|
+
* mcpResult([
|
|
445
|
+
* { type: "text", text: `Screenshot of ${url}` },
|
|
446
|
+
* { type: "image", data: base64png, mimeType: "image/png" },
|
|
447
|
+
* ]),
|
|
448
|
+
* });
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
export declare const mcpResult: (content: McpContent["content"], isError?: boolean) => McpContent;
|
|
452
|
+
/**
|
|
453
|
+
* Type registry populated by `kraken generate` via module augmentation.
|
|
454
|
+
*
|
|
455
|
+
* Before generating, all ID types resolve to an error-message string —
|
|
456
|
+
* only local typed refs (PlatformAgent, PlatformSkill, PlatformConnector) compile.
|
|
457
|
+
*
|
|
458
|
+
* After `kraken generate`, the generated `.kraken-ai/platform-types.d.ts` augments
|
|
459
|
+
* this interface with `agentId`, `connectorId`, and `skillId` string unions,
|
|
460
|
+
* enabling autocomplete on remote IDs.
|
|
461
|
+
*
|
|
462
|
+
* @example
|
|
463
|
+
* ```ts
|
|
464
|
+
* // .kraken-ai/platform-types.d.ts (generated)
|
|
465
|
+
* declare module "@kraken-ai/platform" {
|
|
466
|
+
* interface KrakenTypeRegistry {
|
|
467
|
+
* agentId: "analyst" | "writer";
|
|
468
|
+
* connectorId: "slack" | "jira";
|
|
469
|
+
* skillId: "competitor-deep-dive";
|
|
470
|
+
* }
|
|
471
|
+
* }
|
|
472
|
+
* ```
|
|
473
|
+
*/
|
|
474
|
+
export interface KrakenTypeRegistry {
|
|
475
|
+
}
|
|
476
|
+
/** Remote agent IDs. Resolves to an error hint before `kraken generate`. */
|
|
477
|
+
export type AgentId = KrakenTypeRegistry extends {
|
|
478
|
+
agentId: infer T extends string;
|
|
479
|
+
} ? T : "ERROR: Run 'kraken generate' to unlock agent IDs";
|
|
480
|
+
/** Remote connector IDs. Resolves to an error hint before `kraken generate`. */
|
|
481
|
+
export type ConnectorId = KrakenTypeRegistry extends {
|
|
482
|
+
connectorId: infer T extends string;
|
|
483
|
+
} ? T : "ERROR: Run 'kraken generate' to unlock connector IDs";
|
|
484
|
+
/** Remote skill IDs. Resolves to an error hint before `kraken generate`. */
|
|
485
|
+
export type SkillId = KrakenTypeRegistry extends {
|
|
486
|
+
skillId: infer T extends string;
|
|
487
|
+
} ? T : "ERROR: Run 'kraken generate' to unlock skill IDs";
|
|
488
|
+
/** Remote action IDs. Resolves to an error hint before `kraken generate`. */
|
|
489
|
+
export type ActionId = KrakenTypeRegistry extends {
|
|
490
|
+
actionId: infer T extends string;
|
|
491
|
+
} ? T : "ERROR: Run 'kraken generate' to unlock action IDs";
|
|
492
|
+
/** Skill reference: local PlatformSkill object or remote SkillId (populated by `kraken generate`). */
|
|
493
|
+
export type SkillRef = PlatformSkill | SkillId;
|
|
494
|
+
/** Connector reference: local PlatformConnector object or remote ConnectorId (populated by `kraken generate`). */
|
|
495
|
+
export type ConnectorRef = PlatformConnector | ConnectorId;
|
|
496
|
+
/** Action reference: local PlatformAction object or remote ActionId (populated by `kraken generate`). */
|
|
497
|
+
export type ActionRef = PlatformAction | ActionId;
|
|
498
|
+
export type TeamMember = PlatformAgent | AgentId;
|
|
499
|
+
export type AgentInputField = (Omit<PlatformAgentConfig["agent"], "skills"> & {
|
|
500
|
+
outputSchema?: ZodType;
|
|
501
|
+
skills?: SkillRef[];
|
|
115
502
|
}) | {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
503
|
+
definition: Record<string, unknown>;
|
|
504
|
+
name: string;
|
|
505
|
+
run: (...args: unknown[]) => unknown;
|
|
119
506
|
};
|
|
120
|
-
interface PlatformAgentInputConfig extends Omit<PlatformAgentConfig, "agent" | "connectors" | "team" | "actions"> {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
507
|
+
export interface PlatformAgentInputConfig extends Omit<PlatformAgentConfig, "agent" | "connectors" | "team" | "actions"> {
|
|
508
|
+
agent: AgentInputField;
|
|
509
|
+
connectors?: ConnectorRef[];
|
|
510
|
+
team?: Omit<PlatformAgentConfig["team"] & object, "members"> & {
|
|
511
|
+
members: TeamMember[];
|
|
512
|
+
};
|
|
513
|
+
actions?: ActionRef[];
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Define a platform agent with its model, triggers, connectors, and
|
|
517
|
+
* governance configuration.
|
|
518
|
+
*
|
|
519
|
+
* This is the main entry point for declaring an agent. The config is
|
|
520
|
+
* validated at definition time (via Zod) and the returned object is
|
|
521
|
+
* ready to be registered with the platform server.
|
|
522
|
+
*
|
|
523
|
+
* @param config - Agent definition and platform configuration.
|
|
524
|
+
* @returns A frozen {@link PlatformAgent} object.
|
|
525
|
+
* @throws {SecurityError} If `agent` contains forbidden keys (`tools`,
|
|
526
|
+
* `team`, `kernel`) — those are platform-managed.
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* ```ts
|
|
530
|
+
* import { definePlatformAgent } from "@kraken-ai/platform";
|
|
531
|
+
*
|
|
532
|
+
* export default definePlatformAgent({
|
|
533
|
+
* agent: {
|
|
534
|
+
* name: "market-intel",
|
|
535
|
+
* model: "anthropic/claude-sonnet-4-20250514",
|
|
536
|
+
* instructions: "You are a market research analyst.",
|
|
537
|
+
* temperature: 0.3,
|
|
538
|
+
* },
|
|
539
|
+
* triggers: [{ type: "manual" }],
|
|
540
|
+
* connectors: [jiraConnector, slackConnector],
|
|
541
|
+
* resources: { maxTokens: 100_000, maxCostUsd: 5 },
|
|
542
|
+
* });
|
|
543
|
+
* ```
|
|
544
|
+
*
|
|
545
|
+
* @example
|
|
546
|
+
* With skills, team, and actions:
|
|
547
|
+
* ```ts
|
|
548
|
+
* export default definePlatformAgent({
|
|
549
|
+
* agent: {
|
|
550
|
+
* name: "research-lead",
|
|
551
|
+
* model: "anthropic/claude-sonnet-4-20250514",
|
|
552
|
+
* instructions: "Coordinate research across the team.",
|
|
553
|
+
* skills: [deepDiveSkill],
|
|
554
|
+
* },
|
|
555
|
+
* triggers: [
|
|
556
|
+
* { type: "cron", expression: "0 9 * * MON" },
|
|
557
|
+
* { type: "webhook", path: "/research", method: "POST" },
|
|
558
|
+
* ],
|
|
559
|
+
* team: { members: [analystAgent, writerAgent], maxConcurrentWorkers: 2 },
|
|
560
|
+
* actions,
|
|
561
|
+
* environment: "prod",
|
|
562
|
+
* });
|
|
563
|
+
* ```
|
|
564
|
+
*/
|
|
565
|
+
export declare const definePlatformAgent: <TOutput extends ZodType = ZodType>(config: PlatformAgentInputConfig & {
|
|
566
|
+
agent: AgentInputField & {
|
|
567
|
+
outputSchema?: TOutput;
|
|
568
|
+
};
|
|
132
569
|
}) => PlatformAgent & {
|
|
133
|
-
|
|
570
|
+
outputSchema?: TOutput;
|
|
134
571
|
};
|
|
135
|
-
|
|
136
572
|
/**
|
|
137
|
-
* Define
|
|
573
|
+
* Define a standalone action with a name, Zod schema, optional webhook, and
|
|
574
|
+
* optional handler.
|
|
138
575
|
*
|
|
139
|
-
*
|
|
576
|
+
* Actions are the agent's typed terminal outputs — each action is a possible
|
|
577
|
+
* decision the agent can make. The handler's payload type is inferred from
|
|
578
|
+
* the schema, giving you end-to-end type safety.
|
|
579
|
+
*
|
|
580
|
+
* @param input - Action name, schema, optional webhook URL, and optional handler.
|
|
581
|
+
* @returns A frozen {@link PlatformAction} object.
|
|
582
|
+
* @throws If `name` is empty, invalid, or longer than 64 chars.
|
|
140
583
|
*
|
|
141
584
|
* @example
|
|
142
585
|
* ```ts
|
|
143
|
-
* defineAction
|
|
144
|
-
*
|
|
586
|
+
* import { defineAction } from "@kraken-ai/platform";
|
|
587
|
+
* import { z } from "zod";
|
|
588
|
+
*
|
|
589
|
+
* export default defineAction({
|
|
590
|
+
* name: "approve",
|
|
591
|
+
* schema: z.object({ reason: z.string(), confidence: z.number() }),
|
|
145
592
|
* handler: async (payload) => {
|
|
146
|
-
* payload.reason;
|
|
593
|
+
* payload.reason; // string
|
|
594
|
+
* payload.confidence; // number
|
|
147
595
|
* },
|
|
148
596
|
* });
|
|
149
597
|
* ```
|
|
150
598
|
*/
|
|
151
|
-
declare const defineAction: <S extends z.ZodObject<z.ZodRawShape>>(input: ActionVariantInput<S>) =>
|
|
599
|
+
export declare const defineAction: <S extends z.ZodObject<z.ZodRawShape>>(input: ActionVariantInput<S>) => PlatformAction;
|
|
152
600
|
/**
|
|
153
|
-
*
|
|
154
|
-
* outputs — the agent's final decision as structured output.
|
|
601
|
+
* Build a discriminated-union Zod schema from action definitions.
|
|
155
602
|
*
|
|
156
|
-
* Each
|
|
157
|
-
*
|
|
158
|
-
* in
|
|
603
|
+
* Each action becomes `z.object({ action: z.literal(name), ...fields })`,
|
|
604
|
+
* and the union discriminates on the `action` key. Pass the result as
|
|
605
|
+
* `outputSchema` in {@link definePlatformAgent} to constrain the agent's
|
|
606
|
+
* structured output to exactly one of the defined actions.
|
|
159
607
|
*
|
|
160
|
-
*
|
|
608
|
+
* @param actions - Array of {@link PlatformAction} objects returned by {@link defineAction}.
|
|
609
|
+
* @returns A `z.ZodDiscriminatedUnion` schema.
|
|
610
|
+
* @throws If `actions` is empty.
|
|
161
611
|
*
|
|
162
612
|
* @example
|
|
163
613
|
* ```ts
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* },
|
|
171
|
-
* reject: { schema: z.object({ reason: z.string(), severity: z.number() }) },
|
|
614
|
+
* import { defineAction, buildActionOutputSchema } from "@kraken-ai/platform";
|
|
615
|
+
* import { z } from "zod";
|
|
616
|
+
*
|
|
617
|
+
* const approve = defineAction({
|
|
618
|
+
* name: "approve",
|
|
619
|
+
* schema: z.object({ reason: z.string() }),
|
|
172
620
|
* });
|
|
621
|
+
* const reject = defineAction({
|
|
622
|
+
* name: "reject",
|
|
623
|
+
* schema: z.object({ reason: z.string() }),
|
|
624
|
+
* });
|
|
625
|
+
*
|
|
626
|
+
* const outputSchema = buildActionOutputSchema([approve, reject]);
|
|
627
|
+
* // Accepts: { action: "approve", reason: "..." }
|
|
628
|
+
* // or: { action: "reject", reason: "..." }
|
|
173
629
|
* ```
|
|
174
630
|
*/
|
|
175
|
-
declare const
|
|
631
|
+
export declare const buildActionOutputSchema: (actions: PlatformAction[]) => z.ZodDiscriminatedUnion<[
|
|
632
|
+
z.ZodObject<{
|
|
633
|
+
readonly [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
634
|
+
}, z.core.$strip>,
|
|
635
|
+
...z.ZodObject<{
|
|
636
|
+
readonly [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
637
|
+
}, z.core.$strip>[]
|
|
638
|
+
], "action">;
|
|
176
639
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
640
|
+
* Define a single tool for use inside a connector.
|
|
641
|
+
*
|
|
642
|
+
* Accepts a Zod schema as `input` and infers the handler's argument types
|
|
643
|
+
* from it, giving you end-to-end type safety from schema to handler.
|
|
644
|
+
*
|
|
645
|
+
* @example
|
|
646
|
+
* ```ts
|
|
647
|
+
* const add = defineTool({
|
|
648
|
+
* description: "Add two numbers",
|
|
649
|
+
* input: z.object({ a: z.number(), b: z.number() }),
|
|
650
|
+
* handler: ({ a, b }) => a + b,
|
|
651
|
+
* });
|
|
652
|
+
* ```
|
|
180
653
|
*/
|
|
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
|
-
|
|
654
|
+
export declare const defineTool: <T extends ZodType>(def: ConnectorToolDef<T>) => ConnectorToolDef<T>;
|
|
187
655
|
/**
|
|
188
|
-
* Define a connector
|
|
656
|
+
* Define a connector that exposes tools, resources, and prompts to AI agents
|
|
657
|
+
* through the Kraken platform.
|
|
658
|
+
*
|
|
659
|
+
* A connector is the primary building block for extending agent capabilities.
|
|
660
|
+
* Each connector is served as an MCP server and can provide:
|
|
189
661
|
*
|
|
190
|
-
*
|
|
662
|
+
* - **Tools** — functions the agent can call (defined with {@link defineTool})
|
|
663
|
+
* - **Resources** — data the agent can read (files, database rows, API responses)
|
|
664
|
+
* - **Prompts** — reusable prompt templates the agent can invoke
|
|
665
|
+
*
|
|
666
|
+
* The returned object is deeply frozen and ready to be passed to the platform
|
|
667
|
+
* server builder.
|
|
668
|
+
*
|
|
669
|
+
* @param input - The connector definition including a unique name and optional
|
|
670
|
+
* tools, resources, and prompts.
|
|
671
|
+
* @returns A frozen {@link PlatformConnector} object.
|
|
672
|
+
* @throws If `name` is empty.
|
|
673
|
+
*
|
|
674
|
+
* @example
|
|
675
|
+
* ```ts
|
|
676
|
+
* import { defineConnector, defineTool } from "@kraken-ai/platform";
|
|
677
|
+
* import { z } from "zod";
|
|
678
|
+
*
|
|
679
|
+
* export default defineConnector({
|
|
680
|
+
* name: "math",
|
|
681
|
+
* description: "Basic math operations",
|
|
682
|
+
* tools: {
|
|
683
|
+
* add: defineTool({
|
|
684
|
+
* description: "Add two numbers",
|
|
685
|
+
* input: z.object({ a: z.number(), b: z.number() }),
|
|
686
|
+
* handler: ({ a, b }) => a + b,
|
|
687
|
+
* }),
|
|
688
|
+
* },
|
|
689
|
+
* });
|
|
690
|
+
* ```
|
|
191
691
|
*/
|
|
192
|
-
declare const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
692
|
+
export declare const defineConnector: <const T extends ConnectorDefinition>(input: T) => PlatformConnector;
|
|
693
|
+
/**
|
|
694
|
+
* Define a reusable skill that can be attached to one or more agents.
|
|
695
|
+
*
|
|
696
|
+
* A skill is a named capability (e.g. "competitor-deep-dive") that the
|
|
697
|
+
* platform resolves into the appropriate prompt and tool set at runtime.
|
|
698
|
+
* Skills are referenced by agents via the `skills` array in
|
|
699
|
+
* {@link definePlatformAgent}.
|
|
700
|
+
*
|
|
701
|
+
* @param input - Skill name and optional description.
|
|
702
|
+
* @returns A frozen {@link PlatformSkill} object.
|
|
703
|
+
* @throws If `name` is empty.
|
|
704
|
+
*
|
|
705
|
+
* @example
|
|
706
|
+
* ```ts
|
|
707
|
+
* import { defineSkill, definePlatformAgent } from "@kraken-ai/platform";
|
|
708
|
+
*
|
|
709
|
+
* const deepDive = defineSkill({
|
|
710
|
+
* name: "competitor-deep-dive",
|
|
711
|
+
* description: "In-depth competitor analysis with market sizing",
|
|
712
|
+
* });
|
|
713
|
+
*
|
|
714
|
+
* export default definePlatformAgent({
|
|
715
|
+
* agent: {
|
|
716
|
+
* name: "analyst",
|
|
717
|
+
* model: "anthropic/claude-sonnet-4-20250514",
|
|
718
|
+
* instructions: "You are a competitive analyst.",
|
|
719
|
+
* skills: [deepDive],
|
|
720
|
+
* },
|
|
721
|
+
* triggers: [{ type: "manual" }],
|
|
722
|
+
* });
|
|
723
|
+
* ```
|
|
724
|
+
*/
|
|
725
|
+
export declare const defineSkill: (input: {
|
|
726
|
+
name: string;
|
|
727
|
+
description?: string;
|
|
198
728
|
}) => 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---";
|
|
729
|
+
export declare const MANIFEST_START = "---KRAKEN-MANIFEST-START---";
|
|
730
|
+
export declare const MANIFEST_END = "---KRAKEN-MANIFEST-END---";
|
|
211
731
|
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
|
-
|
|
732
|
+
agents: z.ZodArray<z.ZodObject<{
|
|
733
|
+
name: z.ZodString;
|
|
734
|
+
entryPoint: z.ZodString;
|
|
735
|
+
config: z.ZodObject<{
|
|
736
|
+
agent: z.ZodObject<{
|
|
737
|
+
name: z.ZodString;
|
|
738
|
+
model: z.ZodString;
|
|
739
|
+
instructions: z.ZodString;
|
|
740
|
+
description: z.ZodOptional<z.ZodString>;
|
|
741
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
742
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
743
|
+
allowTemperatureOverride: z.ZodOptional<z.ZodBoolean>;
|
|
744
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
745
|
+
thinkingLevel: z.ZodOptional<z.ZodEnum<{
|
|
746
|
+
low: "low";
|
|
747
|
+
medium: "medium";
|
|
748
|
+
high: "high";
|
|
749
|
+
}>>;
|
|
750
|
+
logLevel: z.ZodOptional<z.ZodEnum<{
|
|
751
|
+
error: "error";
|
|
752
|
+
silent: "silent";
|
|
753
|
+
debug: "debug";
|
|
754
|
+
info: "info";
|
|
755
|
+
warn: "warn";
|
|
756
|
+
}>>;
|
|
757
|
+
}, z.core.$strict>;
|
|
758
|
+
connectors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
759
|
+
triggers: z.ZodArray<z.ZodDiscriminatedUnion<[
|
|
760
|
+
z.ZodObject<{
|
|
761
|
+
type: z.ZodLiteral<"cron">;
|
|
762
|
+
expression: z.ZodString;
|
|
763
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
764
|
+
}, z.core.$strip>,
|
|
765
|
+
z.ZodObject<{
|
|
766
|
+
type: z.ZodLiteral<"webhook">;
|
|
767
|
+
path: z.ZodString;
|
|
768
|
+
method: z.ZodOptional<z.ZodEnum<{
|
|
769
|
+
POST: "POST";
|
|
770
|
+
GET: "GET";
|
|
771
|
+
}>>;
|
|
772
|
+
}, z.core.$strip>,
|
|
773
|
+
z.ZodObject<{
|
|
774
|
+
type: z.ZodLiteral<"event">;
|
|
775
|
+
source: z.ZodString;
|
|
776
|
+
event: z.ZodString;
|
|
777
|
+
}, z.core.$strip>,
|
|
778
|
+
z.ZodObject<{
|
|
779
|
+
type: z.ZodLiteral<"api">;
|
|
780
|
+
}, z.core.$strip>,
|
|
781
|
+
z.ZodObject<{
|
|
782
|
+
type: z.ZodLiteral<"manual">;
|
|
783
|
+
}, z.core.$strip>
|
|
784
|
+
], "type">>;
|
|
785
|
+
identity: z.ZodOptional<z.ZodObject<{
|
|
786
|
+
basePermissions: z.ZodArray<z.ZodString>;
|
|
787
|
+
requestablePermissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
788
|
+
jitPolicy: z.ZodOptional<z.ZodEnum<{
|
|
789
|
+
"auto-approve": "auto-approve";
|
|
790
|
+
"policy-based": "policy-based";
|
|
791
|
+
"require-approval": "require-approval";
|
|
792
|
+
}>>;
|
|
793
|
+
maxJitDurationMinutes: z.ZodOptional<z.ZodNumber>;
|
|
794
|
+
}, z.core.$strip>>;
|
|
795
|
+
resources: z.ZodOptional<z.ZodObject<{
|
|
796
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
797
|
+
maxCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
798
|
+
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
799
|
+
}, z.core.$strip>>;
|
|
800
|
+
retries: z.ZodOptional<z.ZodObject<{
|
|
801
|
+
maxAttempts: z.ZodOptional<z.ZodNumber>;
|
|
802
|
+
backoffSeconds: z.ZodOptional<z.ZodNumber>;
|
|
803
|
+
}, z.core.$strip>>;
|
|
804
|
+
concurrency: z.ZodOptional<z.ZodObject<{
|
|
805
|
+
maxParallelRuns: z.ZodOptional<z.ZodNumber>;
|
|
806
|
+
}, z.core.$strip>>;
|
|
807
|
+
team: z.ZodOptional<z.ZodObject<{
|
|
808
|
+
members: z.ZodArray<z.ZodString>;
|
|
809
|
+
maxConcurrentWorkers: z.ZodOptional<z.ZodNumber>;
|
|
810
|
+
maxTokenBudgetPerWorker: z.ZodOptional<z.ZodNumber>;
|
|
811
|
+
maxDurationPerWorker: z.ZodOptional<z.ZodNumber>;
|
|
812
|
+
}, z.core.$strip>>;
|
|
813
|
+
notifications: z.ZodOptional<z.ZodObject<{
|
|
814
|
+
slack: z.ZodOptional<z.ZodString>;
|
|
815
|
+
onSuccess: z.ZodOptional<z.ZodBoolean>;
|
|
816
|
+
onFailure: z.ZodOptional<z.ZodBoolean>;
|
|
817
|
+
onTimeout: z.ZodOptional<z.ZodBoolean>;
|
|
818
|
+
}, z.core.$strip>>;
|
|
819
|
+
environment: z.ZodOptional<z.ZodEnum<{
|
|
820
|
+
dev: "dev";
|
|
821
|
+
staging: "staging";
|
|
822
|
+
prod: "prod";
|
|
823
|
+
}>>;
|
|
824
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
825
|
+
}, z.core.$strict>;
|
|
826
|
+
}, z.core.$strip>>;
|
|
827
|
+
skills: z.ZodArray<z.ZodObject<{
|
|
828
|
+
name: z.ZodString;
|
|
829
|
+
path: z.ZodString;
|
|
830
|
+
content: z.ZodString;
|
|
831
|
+
}, z.core.$strip>>;
|
|
832
|
+
connectors: z.ZodArray<z.ZodObject<{
|
|
833
|
+
name: z.ZodString;
|
|
834
|
+
path: z.ZodString;
|
|
835
|
+
toolSpecs: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
836
|
+
name: z.ZodString;
|
|
837
|
+
description: z.ZodString;
|
|
838
|
+
parameters: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
839
|
+
annotations: z.ZodOptional<z.ZodObject<{
|
|
840
|
+
readOnlyHint: z.ZodOptional<z.ZodBoolean>;
|
|
841
|
+
destructiveHint: z.ZodOptional<z.ZodBoolean>;
|
|
842
|
+
idempotentHint: z.ZodOptional<z.ZodBoolean>;
|
|
843
|
+
}, z.core.$strip>>;
|
|
844
|
+
}, z.core.$strip>>>;
|
|
845
|
+
resourceSpecs: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
846
|
+
name: z.ZodString;
|
|
847
|
+
uri: z.ZodString;
|
|
848
|
+
description: z.ZodString;
|
|
849
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
850
|
+
}, z.core.$strip>>>;
|
|
851
|
+
promptSpecs: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
852
|
+
name: z.ZodString;
|
|
853
|
+
description: z.ZodString;
|
|
854
|
+
arguments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
855
|
+
name: z.ZodString;
|
|
856
|
+
description: z.ZodOptional<z.ZodString>;
|
|
857
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
858
|
+
}, z.core.$strip>>>;
|
|
859
|
+
}, z.core.$strip>>>;
|
|
860
|
+
}, z.core.$strip>>;
|
|
861
|
+
actions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
862
|
+
name: z.ZodString;
|
|
863
|
+
entryPoint: z.ZodString;
|
|
864
|
+
config: z.ZodObject<{
|
|
865
|
+
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
866
|
+
webhook: z.ZodOptional<z.ZodString>;
|
|
867
|
+
hasHandler: z.ZodBoolean;
|
|
868
|
+
}, z.core.$strip>;
|
|
869
|
+
}, z.core.$strip>>>;
|
|
316
870
|
}, z.core.$strip>;
|
|
317
|
-
type ProjectManifest = z.infer<typeof projectManifestSchema>;
|
|
871
|
+
export type ProjectManifest = z.infer<typeof projectManifestSchema>;
|
|
318
872
|
/** 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);
|
|
873
|
+
export declare const parseManifestFromOutput: (stdout: string) => ProjectManifest;
|
|
874
|
+
export declare class PlatformError extends Error {
|
|
875
|
+
readonly status: number;
|
|
876
|
+
constructor(message: string, status: number);
|
|
324
877
|
}
|
|
325
878
|
declare class HttpClient {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
879
|
+
readonly baseUrlForStream: string;
|
|
880
|
+
private readonly baseUrl;
|
|
881
|
+
private readonly apiKey;
|
|
882
|
+
constructor(config: {
|
|
883
|
+
baseUrl: string;
|
|
884
|
+
apiKey: string;
|
|
885
|
+
});
|
|
886
|
+
get<T>(path: string, params?: Record<string, string>): Promise<T>;
|
|
887
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
888
|
+
postStream(path: string, body: unknown, signal?: AbortSignal): Promise<Response>;
|
|
889
|
+
private buildUrl;
|
|
890
|
+
authHeaders(): Record<string, string>;
|
|
891
|
+
private handleResponse;
|
|
336
892
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
893
|
+
export interface PlatformClientConfig {
|
|
894
|
+
baseUrl?: string;
|
|
895
|
+
apiKey?: string;
|
|
896
|
+
}
|
|
897
|
+
export interface PaginationParams {
|
|
898
|
+
cursor?: string;
|
|
899
|
+
limit?: number;
|
|
900
|
+
}
|
|
901
|
+
export interface PaginatedResponse<T> {
|
|
902
|
+
data: T[];
|
|
903
|
+
cursor: string | null;
|
|
904
|
+
hasMore: boolean;
|
|
905
|
+
}
|
|
906
|
+
export type AgentEvent = {
|
|
907
|
+
type: "text";
|
|
908
|
+
content: string;
|
|
909
|
+
} | {
|
|
910
|
+
type: "tool_call";
|
|
911
|
+
name: string;
|
|
912
|
+
args: Record<string, unknown>;
|
|
913
|
+
} | {
|
|
914
|
+
type: "tool_result";
|
|
915
|
+
name: string;
|
|
916
|
+
result: unknown;
|
|
917
|
+
} | {
|
|
918
|
+
type: "thinking";
|
|
919
|
+
content: string;
|
|
920
|
+
} | {
|
|
921
|
+
type: "action";
|
|
922
|
+
name: string;
|
|
923
|
+
payload: Record<string, unknown>;
|
|
924
|
+
actionExecutionId: string;
|
|
925
|
+
} | {
|
|
926
|
+
type: "done";
|
|
927
|
+
output: string;
|
|
928
|
+
usage?: {
|
|
929
|
+
tokens: number;
|
|
930
|
+
};
|
|
931
|
+
} | {
|
|
932
|
+
type: "error";
|
|
933
|
+
message: string;
|
|
934
|
+
code: string;
|
|
935
|
+
};
|
|
936
|
+
export interface AgentInfo {
|
|
937
|
+
id: string;
|
|
938
|
+
name: string;
|
|
939
|
+
description?: string;
|
|
940
|
+
}
|
|
941
|
+
export interface ThreadInfo {
|
|
942
|
+
id: string;
|
|
943
|
+
agentId: string;
|
|
944
|
+
createdAt: string;
|
|
945
|
+
updatedAt: string;
|
|
946
|
+
}
|
|
947
|
+
export interface ThreadMessage {
|
|
948
|
+
id: string;
|
|
949
|
+
threadId: string;
|
|
950
|
+
role: "user" | "assistant";
|
|
951
|
+
content: string;
|
|
952
|
+
toolCalls?: Array<{
|
|
953
|
+
name: string;
|
|
954
|
+
args: Record<string, unknown>;
|
|
955
|
+
result: unknown;
|
|
956
|
+
}>;
|
|
957
|
+
createdAt: string;
|
|
958
|
+
usage?: {
|
|
959
|
+
tokens: number;
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
export interface QueryInfo {
|
|
963
|
+
name: string;
|
|
964
|
+
description?: string;
|
|
965
|
+
params: Record<string, unknown>;
|
|
966
|
+
columns: QueryColumn[];
|
|
967
|
+
}
|
|
968
|
+
export interface QueryColumn {
|
|
969
|
+
name: string;
|
|
970
|
+
type: string;
|
|
971
|
+
description?: string;
|
|
972
|
+
}
|
|
973
|
+
export interface QueryResult<TRow = Record<string, unknown>> {
|
|
974
|
+
rows: TRow[];
|
|
975
|
+
cursor: string | null;
|
|
976
|
+
hasMore: boolean;
|
|
977
|
+
}
|
|
978
|
+
export type RunState = "QUEUED" | "PROVISIONING" | "RUNNING" | "DRAINING" | "COMPLETED" | "FAILED" | "AWAITING_APPROVAL" | "RETRYING";
|
|
979
|
+
export interface RunRecord {
|
|
980
|
+
runId: string;
|
|
981
|
+
agentId: string;
|
|
982
|
+
input: string;
|
|
983
|
+
state: RunState;
|
|
984
|
+
exitCode?: number;
|
|
985
|
+
createdAt: string;
|
|
986
|
+
updatedAt: string;
|
|
987
|
+
retryCount: number;
|
|
988
|
+
error?: string;
|
|
989
|
+
}
|
|
990
|
+
export interface StartRunParams {
|
|
991
|
+
agentId: string;
|
|
992
|
+
tag?: string;
|
|
993
|
+
environment?: "dev" | "staging" | "prod";
|
|
994
|
+
input: string;
|
|
995
|
+
connectors?: string[];
|
|
996
|
+
envVars?: Record<string, string>;
|
|
997
|
+
/** When true, tool calls are logged but not executed. */
|
|
998
|
+
dryRun?: boolean;
|
|
999
|
+
}
|
|
1000
|
+
export interface RunEvent {
|
|
1001
|
+
eventId: string;
|
|
1002
|
+
eventType: string;
|
|
1003
|
+
payload: Record<string, unknown>;
|
|
1004
|
+
}
|
|
1005
|
+
export interface AgentSchema {
|
|
1006
|
+
id: string;
|
|
1007
|
+
name: string;
|
|
1008
|
+
input: Record<string, unknown>;
|
|
1009
|
+
output: Record<string, unknown>;
|
|
1010
|
+
actions?: Record<string, Record<string, unknown>>;
|
|
1011
|
+
config?: {
|
|
1012
|
+
actions?: string[];
|
|
1013
|
+
[key: string]: unknown;
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
export interface QuerySchema {
|
|
1017
|
+
name: string;
|
|
1018
|
+
params: Record<string, unknown>;
|
|
1019
|
+
columns: QueryColumn[];
|
|
1020
|
+
}
|
|
1021
|
+
export interface ConnectorSchema {
|
|
1022
|
+
id: string;
|
|
1023
|
+
tools: Array<{
|
|
1024
|
+
name: string;
|
|
1025
|
+
description: string;
|
|
1026
|
+
parameters: Record<string, unknown>;
|
|
1027
|
+
}>;
|
|
1028
|
+
}
|
|
1029
|
+
export interface SkillSchema {
|
|
1030
|
+
id: string;
|
|
1031
|
+
name: string;
|
|
1032
|
+
description?: string;
|
|
1033
|
+
}
|
|
1034
|
+
export interface ActionSchema {
|
|
1035
|
+
id: string;
|
|
1036
|
+
name: string;
|
|
1037
|
+
schema: Record<string, unknown>;
|
|
1038
|
+
hasHandler: boolean;
|
|
1039
|
+
}
|
|
1040
|
+
export interface AgentRegistryEntry {
|
|
1041
|
+
input: unknown;
|
|
1042
|
+
output: unknown;
|
|
1043
|
+
actions: Record<string, unknown>;
|
|
342
1044
|
}
|
|
343
1045
|
/**
|
|
344
1046
|
* Augmentable agent registry — `kraken generate` populates this via
|
|
345
1047
|
* `declare module "@kraken-ai/platform" { interface AgentRegistry { ... } }`.
|
|
346
1048
|
* When populated, `client.agent("id")` infers input/output/actions automatically.
|
|
347
1049
|
*/
|
|
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>>;
|
|
1050
|
+
export interface AgentRegistry {
|
|
367
1051
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
1052
|
+
export interface GenerateOpts {
|
|
1053
|
+
signal?: AbortSignal;
|
|
1054
|
+
}
|
|
1055
|
+
export interface GenerateResult<T extends AgentRegistryEntry> {
|
|
1056
|
+
readonly threadId: string;
|
|
1057
|
+
stream(): AsyncIterable<AgentEvent>;
|
|
1058
|
+
readonly result: Promise<T["output"]>;
|
|
1059
|
+
}
|
|
1060
|
+
export declare class AgentHandle<T extends AgentRegistryEntry> {
|
|
1061
|
+
private readonly http;
|
|
1062
|
+
private readonly agentId;
|
|
1063
|
+
private readonly actionHandlers;
|
|
1064
|
+
private threadId;
|
|
1065
|
+
constructor(http: HttpClient, agentId: string, opts?: {
|
|
1066
|
+
threadId?: string;
|
|
1067
|
+
});
|
|
1068
|
+
onAction<K extends keyof T["actions"] & string>(name: K, handler: (payload: T["actions"][K]) => void | Promise<void>): void;
|
|
1069
|
+
generate(input: T["input"], opts?: GenerateOpts): Promise<GenerateResult<T>>;
|
|
1070
|
+
}
|
|
1071
|
+
export declare class AgentThread {
|
|
1072
|
+
private readonly http;
|
|
1073
|
+
private readonly agentId;
|
|
1074
|
+
readonly threadId: string;
|
|
1075
|
+
constructor(http: HttpClient, agentId: string, threadId: string);
|
|
1076
|
+
sendMessage(content: string, opts?: {
|
|
1077
|
+
signal?: AbortSignal;
|
|
1078
|
+
}): Promise<AsyncIterable<AgentEvent>>;
|
|
1079
|
+
getMessages(params?: PaginationParams): Promise<PaginatedResponse<ThreadMessage>>;
|
|
378
1080
|
}
|
|
379
1081
|
declare class AgentsNamespace {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
1082
|
+
private readonly http;
|
|
1083
|
+
constructor(http: HttpClient);
|
|
1084
|
+
list(): Promise<AgentInfo[]>;
|
|
1085
|
+
createThread(agentId: string): Promise<AgentThread>;
|
|
1086
|
+
getThread(agentId: string, threadId: string): Promise<AgentThread>;
|
|
1087
|
+
listThreads(agentId: string, params?: PaginationParams): Promise<PaginatedResponse<ThreadInfo>>;
|
|
386
1088
|
}
|
|
387
|
-
|
|
388
1089
|
declare class DataNamespace {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
1090
|
+
private readonly http;
|
|
1091
|
+
constructor(http: HttpClient);
|
|
1092
|
+
list(): Promise<QueryInfo[]>;
|
|
1093
|
+
describe(queryName: string): Promise<QueryInfo>;
|
|
1094
|
+
query<TRow = Record<string, unknown>>(queryName: string, params?: Record<string, unknown>, pagination?: PaginationParams): Promise<QueryResult<TRow>>;
|
|
394
1095
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
returns: R;
|
|
1096
|
+
export interface PipelineQueryDef<P extends ZodType, R extends ZodType> {
|
|
1097
|
+
params: P;
|
|
1098
|
+
returns: R;
|
|
399
1099
|
}
|
|
400
1100
|
declare class PipelinesNamespace {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
1101
|
+
private readonly http;
|
|
1102
|
+
constructor(http: HttpClient);
|
|
1103
|
+
query<P extends ZodType, R extends ZodType>(pipeline: string, queryName: string, schema: PipelineQueryDef<P, R>, params: z.infer<P>): Promise<z.infer<R>[]>;
|
|
404
1104
|
}
|
|
405
|
-
|
|
406
1105
|
declare class RunsNamespace {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
1106
|
+
private readonly http;
|
|
1107
|
+
constructor(http: HttpClient);
|
|
1108
|
+
start(params: StartRunParams): Promise<{
|
|
1109
|
+
runId: string;
|
|
1110
|
+
}>;
|
|
1111
|
+
get(runId: string): Promise<RunRecord>;
|
|
1112
|
+
cancel(runId: string): Promise<{
|
|
1113
|
+
success: boolean;
|
|
1114
|
+
}>;
|
|
1115
|
+
getEvents(runId: string, opts?: {
|
|
1116
|
+
afterEventId?: string;
|
|
1117
|
+
}): Promise<{
|
|
1118
|
+
events: RunEvent[];
|
|
1119
|
+
}>;
|
|
1120
|
+
streamEvents(runId: string, opts?: {
|
|
1121
|
+
signal?: AbortSignal;
|
|
1122
|
+
}): AsyncGenerator<RunEvent>;
|
|
424
1123
|
}
|
|
425
|
-
|
|
1124
|
+
/** When AgentRegistry is populated (after `kraken generate`), constrain to known keys for autocomplete. Otherwise accept any string. */
|
|
1125
|
+
export type AgentIdConstraint = keyof AgentRegistry extends never ? string : keyof AgentRegistry;
|
|
426
1126
|
/** 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
|
-
|
|
1127
|
+
export type ResolveAgent<K extends string> = K extends keyof AgentRegistry ? AgentRegistry[K] : AgentRegistryEntry;
|
|
1128
|
+
export declare class PlatformClient {
|
|
1129
|
+
readonly agents: AgentsNamespace;
|
|
1130
|
+
readonly data: DataNamespace;
|
|
1131
|
+
readonly pipelines: PipelinesNamespace;
|
|
1132
|
+
readonly runs: RunsNamespace;
|
|
1133
|
+
private readonly http;
|
|
1134
|
+
constructor(config?: PlatformClientConfig);
|
|
1135
|
+
agent<K extends AgentIdConstraint>(id: K, opts?: {
|
|
1136
|
+
mode?: "local" | "remote";
|
|
1137
|
+
threadId?: string;
|
|
1138
|
+
}): AgentHandle<ResolveAgent<K>>;
|
|
439
1139
|
}
|
|
440
1140
|
|
|
441
|
-
export {
|
|
1141
|
+
export {
|
|
1142
|
+
z,
|
|
1143
|
+
};
|
|
1144
|
+
|
|
1145
|
+
export {};
|