@kraken-ai/platform 0.0.1 → 0.0.3

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/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { M as McpContent, P as PlatformConnector, C as ConnectorDefinition, a as ConnectorToolDef } from './connector-CumEDPfS.js';
2
- export { b as ConnectorHandlerContext, c as ConnectorHandlerResult, d as ConnectorPromptDef, e as ConnectorResourceDef, G as GetPromptResult, f as PromptMessageContent, R as ReadResourceResult, g as ResourceContent, T as ToolAnnotations } from './connector-CumEDPfS.js';
1
+ import { M as McpContent, P as PlatformConnector, C as ConnectorId, S as SkillId, a as PlatformAgentConfig, T as TeamMember, b as PlatformActions, c as PlatformAgent, A as ActionVariantInput, d as ConnectorDefinition, e as ConnectorToolDef, f as PlatformClientConfig, g as AgentEvent, h as PaginationParams, i as PaginatedResponse, j as ThreadMessage, k as AgentInfo, l as ThreadInfo, Q as QueryInfo, m as QueryResult, n as StartRunParams, R as RunRecord, o as RunEvent } from './types-CkknNKNr.js';
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-CkknNKNr.js';
3
3
  import * as z from 'zod';
4
4
  import { ZodType } from 'zod';
5
- import { ModelString, ToolDefinition } from 'kraken-ai';
5
+ import 'kraken-ai';
6
6
 
7
7
  interface ToolResultContent {
8
8
  readonly type: string;
@@ -19,46 +19,6 @@ declare const wrapToolError: (error: unknown) => ToolResult;
19
19
  /** Create an explicit MCP content pass-through result */
20
20
  declare const mcpResult: (content: McpContent["content"], isError?: boolean) => McpContent;
21
21
 
22
- /** Action names follow entity naming convention: lowercase alphanumeric with hyphens, 1-64 chars. */
23
- declare const ACTION_NAME_REGEX: RegExp;
24
- /** Validates an action name (allows single-char names like "a"). */
25
- declare const isValidActionName: (name: string) => boolean;
26
- /** Input for a single action variant in defineActions(). */
27
- interface ActionVariantInput<S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>> {
28
- schema: S;
29
- webhook?: string;
30
- handler?(payload: z.infer<S>): Promise<void>;
31
- }
32
- /** Serializable config for a single action variant (stored in manifest/DB). */
33
- interface ActionVariantConfig {
34
- schema: Record<string, unknown>;
35
- webhook?: string;
36
- hasHandler: boolean;
37
- }
38
- /** Serializable portion of action definitions (stored in agent config). */
39
- interface PlatformActionsConfig {
40
- variants: Record<string, ActionVariantConfig>;
41
- }
42
- /** Full action definitions including in-memory schemas and handlers for runtime use. */
43
- interface PlatformActions {
44
- readonly __type: "PlatformActions";
45
- readonly config: PlatformActionsConfig;
46
- readonly zodSchemas: Record<string, z.ZodObject<z.ZodRawShape>>;
47
- readonly handlers: Readonly<Record<string, (payload: unknown) => Promise<void>>>;
48
- }
49
- declare const actionVariantConfigSchema: z.ZodObject<{
50
- schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
51
- webhook: z.ZodOptional<z.ZodString>;
52
- hasHandler: z.ZodBoolean;
53
- }, z.core.$strip>;
54
- declare const actionsConfigSchema: z.ZodObject<{
55
- variants: z.ZodRecord<z.ZodString, z.ZodObject<{
56
- schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
57
- webhook: z.ZodOptional<z.ZodString>;
58
- hasHandler: z.ZodBoolean;
59
- }, z.core.$strip>>;
60
- }, z.core.$strict>;
61
-
62
22
  declare const environmentSchema: z.ZodEnum<{
63
23
  dev: "dev";
64
24
  staging: "staging";
@@ -92,177 +52,6 @@ declare const notificationConfigSchema: z.ZodObject<{
92
52
  }, z.core.$strip>;
93
53
  type NotificationConfig = z.infer<typeof notificationConfigSchema>;
94
54
 
95
- /**
96
- * Type registry populated by `kraken generate` via module augmentation.
97
- *
98
- * Before generating, all ID types resolve to an error-message string —
99
- * only local typed refs (PlatformAgent, PlatformSkill, PlatformConnector) compile.
100
- *
101
- * After `kraken generate`, the generated `.kraken-ai/platform-types.d.ts` augments
102
- * this interface with `agentId`, `connectorId`, and `skillId` string unions,
103
- * enabling autocomplete on remote IDs.
104
- *
105
- * @example
106
- * ```ts
107
- * // .kraken-ai/platform-types.d.ts (generated)
108
- * declare module "@kraken-ai/platform" {
109
- * interface KrakenTypeRegistry {
110
- * agentId: "analyst" | "writer";
111
- * connectorId: "slack" | "jira";
112
- * skillId: "competitor-deep-dive";
113
- * }
114
- * }
115
- * ```
116
- */
117
- interface KrakenTypeRegistry {
118
- }
119
- /** Remote agent IDs. Resolves to an error hint before `kraken generate`. */
120
- type AgentId = KrakenTypeRegistry extends {
121
- agentId: infer T extends string;
122
- } ? T : "ERROR: Run 'kraken generate' to unlock agent IDs";
123
- /** Remote connector IDs. Resolves to an error hint before `kraken generate`. */
124
- type ConnectorId = KrakenTypeRegistry extends {
125
- connectorId: infer T extends string;
126
- } ? T : "ERROR: Run 'kraken generate' to unlock connector IDs";
127
- /** Remote skill IDs. Resolves to an error hint before `kraken generate`. */
128
- type SkillId = KrakenTypeRegistry extends {
129
- skillId: infer T extends string;
130
- } ? T : "ERROR: Run 'kraken generate' to unlock skill IDs";
131
-
132
- declare const agentDefinitionSchema: z.ZodObject<{
133
- name: z.ZodString;
134
- model: z.ZodString;
135
- instructions: z.ZodString;
136
- description: z.ZodOptional<z.ZodString>;
137
- skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
138
- temperature: z.ZodOptional<z.ZodNumber>;
139
- allowTemperatureOverride: z.ZodOptional<z.ZodBoolean>;
140
- maxOutputTokens: z.ZodOptional<z.ZodNumber>;
141
- thinkingLevel: z.ZodOptional<z.ZodEnum<{
142
- low: "low";
143
- medium: "medium";
144
- high: "high";
145
- }>>;
146
- logLevel: z.ZodOptional<z.ZodEnum<{
147
- error: "error";
148
- silent: "silent";
149
- debug: "debug";
150
- info: "info";
151
- warn: "warn";
152
- }>>;
153
- }, z.core.$strict>;
154
- type AgentDefinition = Omit<z.infer<typeof agentDefinitionSchema>, "model"> & {
155
- model: ModelString;
156
- };
157
- declare const platformAgentConfigSchema: z.ZodObject<{
158
- agent: z.ZodObject<{
159
- name: z.ZodString;
160
- model: z.ZodString;
161
- instructions: z.ZodString;
162
- description: z.ZodOptional<z.ZodString>;
163
- skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
164
- temperature: z.ZodOptional<z.ZodNumber>;
165
- allowTemperatureOverride: z.ZodOptional<z.ZodBoolean>;
166
- maxOutputTokens: z.ZodOptional<z.ZodNumber>;
167
- thinkingLevel: z.ZodOptional<z.ZodEnum<{
168
- low: "low";
169
- medium: "medium";
170
- high: "high";
171
- }>>;
172
- logLevel: z.ZodOptional<z.ZodEnum<{
173
- error: "error";
174
- silent: "silent";
175
- debug: "debug";
176
- info: "info";
177
- warn: "warn";
178
- }>>;
179
- }, z.core.$strict>;
180
- connectors: z.ZodOptional<z.ZodArray<z.ZodString>>;
181
- trigger: z.ZodDiscriminatedUnion<[z.ZodObject<{
182
- type: z.ZodLiteral<"cron">;
183
- expression: z.ZodString;
184
- timezone: z.ZodOptional<z.ZodString>;
185
- }, z.core.$strip>, z.ZodObject<{
186
- type: z.ZodLiteral<"webhook">;
187
- path: z.ZodString;
188
- method: z.ZodOptional<z.ZodEnum<{
189
- GET: "GET";
190
- POST: "POST";
191
- }>>;
192
- }, z.core.$strip>, z.ZodObject<{
193
- type: z.ZodLiteral<"event">;
194
- source: z.ZodString;
195
- event: z.ZodString;
196
- }, z.core.$strip>, z.ZodObject<{
197
- type: z.ZodLiteral<"api">;
198
- }, z.core.$strip>, z.ZodObject<{
199
- type: z.ZodLiteral<"manual">;
200
- }, z.core.$strip>], "type">;
201
- identity: z.ZodOptional<z.ZodObject<{
202
- basePermissions: z.ZodArray<z.ZodString>;
203
- requestablePermissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
204
- jitPolicy: z.ZodOptional<z.ZodEnum<{
205
- "auto-approve": "auto-approve";
206
- "policy-based": "policy-based";
207
- "require-approval": "require-approval";
208
- }>>;
209
- maxJitDurationMinutes: z.ZodOptional<z.ZodNumber>;
210
- }, z.core.$strip>>;
211
- resources: z.ZodOptional<z.ZodObject<{
212
- maxTokens: z.ZodOptional<z.ZodNumber>;
213
- maxCostUsd: z.ZodOptional<z.ZodNumber>;
214
- timeoutSeconds: z.ZodOptional<z.ZodNumber>;
215
- }, z.core.$strip>>;
216
- retries: z.ZodOptional<z.ZodObject<{
217
- maxAttempts: z.ZodOptional<z.ZodNumber>;
218
- backoffSeconds: z.ZodOptional<z.ZodNumber>;
219
- }, z.core.$strip>>;
220
- concurrency: z.ZodOptional<z.ZodObject<{
221
- maxParallelRuns: z.ZodOptional<z.ZodNumber>;
222
- }, z.core.$strip>>;
223
- team: z.ZodOptional<z.ZodObject<{
224
- members: z.ZodArray<z.ZodString>;
225
- maxConcurrentWorkers: z.ZodOptional<z.ZodNumber>;
226
- maxTokenBudgetPerWorker: z.ZodOptional<z.ZodNumber>;
227
- maxDurationPerWorker: z.ZodOptional<z.ZodNumber>;
228
- }, z.core.$strip>>;
229
- notifications: z.ZodOptional<z.ZodObject<{
230
- slack: z.ZodOptional<z.ZodString>;
231
- onSuccess: z.ZodOptional<z.ZodBoolean>;
232
- onFailure: z.ZodOptional<z.ZodBoolean>;
233
- onTimeout: z.ZodOptional<z.ZodBoolean>;
234
- }, z.core.$strip>>;
235
- environment: z.ZodOptional<z.ZodEnum<{
236
- dev: "dev";
237
- staging: "staging";
238
- prod: "prod";
239
- }>>;
240
- actions: z.ZodOptional<z.ZodObject<{
241
- variants: z.ZodRecord<z.ZodString, z.ZodObject<{
242
- schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
243
- webhook: z.ZodOptional<z.ZodString>;
244
- hasHandler: z.ZodBoolean;
245
- }, z.core.$strip>>;
246
- }, z.core.$strict>>;
247
- }, z.core.$strict>;
248
- type PlatformAgentConfig = Omit<z.infer<typeof platformAgentConfigSchema>, "agent" | "actions"> & {
249
- agent: AgentDefinition;
250
- actions?: PlatformActionsConfig;
251
- };
252
- interface PlatformAgent {
253
- readonly __type: "PlatformAgent";
254
- readonly config: PlatformAgentConfig;
255
- readonly runtime?: unknown;
256
- /** In-memory schemas for action variants. Not serialized — runtime use only. */
257
- readonly actionZodSchemas?: Record<string, z.ZodObject<z.ZodRawShape>>;
258
- /** Action handler functions. Not serialized — runtime use only. */
259
- readonly actionHandlers?: Readonly<Record<string, (payload: unknown) => Promise<void>>>;
260
- /** Team member PlatformAgent objects. Not serialized — runtime use only (dev mode delegation). */
261
- readonly teamAgents?: readonly PlatformAgent[];
262
- }
263
- /** Team member reference: local PlatformAgent or remote AgentId string. */
264
- type TeamMember = PlatformAgent | AgentId;
265
-
266
55
  interface PlatformSkill {
267
56
  readonly __type: "PlatformSkill";
268
57
  readonly name: string;
@@ -529,158 +318,6 @@ type ProjectManifest = z.infer<typeof projectManifestSchema>;
529
318
  /** Parse manifest from stdout that may contain noise before/after sentinel markers. */
530
319
  declare const parseManifestFromOutput: (stdout: string) => ProjectManifest;
531
320
 
532
- declare const runDev: (agent: PlatformAgent) => Promise<never>;
533
-
534
- interface PlatformClientConfig {
535
- baseUrl: string;
536
- apiKey: string;
537
- }
538
- interface PaginationParams {
539
- cursor?: string;
540
- limit?: number;
541
- }
542
- interface PaginatedResponse<T> {
543
- data: T[];
544
- cursor: string | null;
545
- hasMore: boolean;
546
- }
547
- type AgentEvent = {
548
- type: "text";
549
- content: string;
550
- } | {
551
- type: "tool_call";
552
- name: string;
553
- args: Record<string, unknown>;
554
- } | {
555
- type: "tool_result";
556
- name: string;
557
- result: unknown;
558
- } | {
559
- type: "thinking";
560
- content: string;
561
- } | {
562
- type: "action";
563
- name: string;
564
- payload: Record<string, unknown>;
565
- actionExecutionId: string;
566
- } | {
567
- type: "done";
568
- output: string;
569
- usage?: {
570
- tokens: number;
571
- };
572
- } | {
573
- type: "error";
574
- message: string;
575
- code: string;
576
- };
577
- interface AgentInfo {
578
- id: string;
579
- name: string;
580
- description?: string;
581
- }
582
- interface ThreadInfo {
583
- id: string;
584
- agentId: string;
585
- createdAt: string;
586
- updatedAt: string;
587
- }
588
- interface ThreadMessage {
589
- id: string;
590
- threadId: string;
591
- role: "user" | "assistant";
592
- content: string;
593
- toolCalls?: Array<{
594
- name: string;
595
- args: Record<string, unknown>;
596
- result: unknown;
597
- }>;
598
- createdAt: string;
599
- usage?: {
600
- tokens: number;
601
- };
602
- }
603
- interface QueryInfo {
604
- name: string;
605
- description?: string;
606
- params: Record<string, unknown>;
607
- columns: QueryColumn[];
608
- }
609
- interface QueryColumn {
610
- name: string;
611
- type: string;
612
- description?: string;
613
- }
614
- interface QueryResult<TRow = Record<string, unknown>> {
615
- rows: TRow[];
616
- cursor: string | null;
617
- hasMore: boolean;
618
- }
619
- type RunState = "QUEUED" | "PROVISIONING" | "RUNNING" | "DRAINING" | "COMPLETED" | "FAILED" | "AWAITING_APPROVAL" | "RETRYING";
620
- interface RunRecord {
621
- runId: string;
622
- agentId: string;
623
- input: string;
624
- state: RunState;
625
- exitCode?: number;
626
- createdAt: string;
627
- updatedAt: string;
628
- retryCount: number;
629
- error?: string;
630
- }
631
- interface StartRunParams {
632
- agentId: string;
633
- tag?: string;
634
- environment?: "dev" | "staging" | "prod";
635
- input: string;
636
- connectors?: string[];
637
- envVars?: Record<string, string>;
638
- }
639
- interface RunEvent {
640
- eventId: string;
641
- eventType: string;
642
- payload: Record<string, unknown>;
643
- }
644
- interface AgentSchema {
645
- id: string;
646
- name: string;
647
- input: Record<string, unknown>;
648
- output: Record<string, unknown>;
649
- actions?: Record<string, Record<string, unknown>>;
650
- }
651
- interface QuerySchema$1 {
652
- name: string;
653
- params: Record<string, unknown>;
654
- columns: QueryColumn[];
655
- }
656
- interface ConnectorSchema {
657
- id: string;
658
- tools: Array<{
659
- name: string;
660
- description: string;
661
- parameters: Record<string, unknown>;
662
- }>;
663
- }
664
- interface SkillSchema {
665
- id: string;
666
- name: string;
667
- description?: string;
668
- }
669
-
670
- type ToolOverride = (args: Record<string, unknown>) => Promise<unknown> | unknown;
671
- declare class MockToolSet {
672
- private readonly defs;
673
- private readonly overrides;
674
- private readonly toolNames;
675
- constructor(tools: ToolDefinition[], overrides?: Record<string, ToolOverride>);
676
- static fromConnectors(connectors: ConnectorSchema[], opts?: {
677
- include?: string[];
678
- overrides?: Record<string, ToolOverride>;
679
- }): MockToolSet;
680
- definitions(): ToolDefinition[];
681
- call(name: string, params: Record<string, unknown>): Promise<unknown>;
682
- }
683
-
684
321
  declare class PlatformError extends Error {
685
322
  readonly status: number;
686
323
  constructor(message: string, status: number);
@@ -703,6 +340,12 @@ interface AgentRegistryEntry {
703
340
  output: unknown;
704
341
  actions: Record<string, unknown>;
705
342
  }
343
+ /**
344
+ * Augmentable agent registry — `kraken generate` populates this via
345
+ * `declare module "@kraken-ai/platform" { interface AgentRegistry { ... } }`.
346
+ * When populated, `client.agent("id")` infers input/output/actions automatically.
347
+ */
348
+ type AgentRegistry = {};
706
349
  interface GenerateOpts {
707
350
  signal?: AbortSignal;
708
351
  }
@@ -780,6 +423,8 @@ declare class RunsNamespace {
780
423
  }): AsyncGenerator<RunEvent>;
781
424
  }
782
425
 
426
+ /** 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;
783
428
  declare class PlatformClient {
784
429
  readonly agents: AgentsNamespace;
785
430
  readonly data: DataNamespace;
@@ -787,10 +432,10 @@ declare class PlatformClient {
787
432
  readonly runs: RunsNamespace;
788
433
  private readonly http;
789
434
  constructor(config: PlatformClientConfig);
790
- agent<T extends AgentRegistryEntry = AgentRegistryEntry>(id: string, opts?: {
435
+ agent<K extends string>(id: K, opts?: {
791
436
  mode?: "local" | "remote";
792
437
  threadId?: string;
793
- }): AgentHandle<T>;
438
+ }): AgentHandle<ResolveAgent<K>>;
794
439
  }
795
440
 
796
- export { ACTION_NAME_REGEX, type ActionVariantConfig, type ActionVariantInput, type AgentDefinition, type AgentEvent, AgentHandle, type AgentId, type AgentInfo, type AgentRegistryEntry, type AgentSchema, AgentThread, type ConcurrencyPolicy, ConnectorDefinition, ConnectorError, type ConnectorId, type ConnectorRef, type ConnectorSchema, ConnectorToolDef, type Environment, type GenerateOpts, type GenerateResult, type IdentityConfig, type JitPolicy, type KrakenTypeRegistry, MANIFEST_END, MANIFEST_START, McpContent, MockToolSet, type NotificationConfig, type PaginatedResponse, type PaginationParams, type PlatformActions, type PlatformActionsConfig, type PlatformAgent, type PlatformAgentConfig, PlatformClient, type PlatformClientConfig, PlatformConnector, PlatformError, type PlatformSkill, type ProjectManifest, type QueryColumn, type QueryInfo, type QueryResult, type QuerySchema$1 as QuerySchema, type ResourceLimits, type RetryPolicy, type RunEvent, type RunRecord, type RunState, SecurityError, type SkillId, type SkillRef, type SkillSchema, type StartRunParams, type TeamConfig, type TeamMember, type ThreadInfo, type ThreadMessage, type TriggerConfig, actionVariantConfigSchema, actionsConfigSchema, agentDefinitionSchema, buildActionOutputSchema, concurrencyPolicySchema, defineAction, defineActions, defineConnector, definePlatformAgent, defineSkill, defineTool, environmentSchema, identityConfigSchema, isValidActionName, jitPolicySchema, mcpResult, notificationConfigSchema, parseManifestFromOutput, platformAgentConfigSchema, projectManifestSchema, resourceLimitsSchema, retryPolicySchema, runDev, teamConfigSchema, triggerConfigSchema, wrapToolError, wrapToolResult };
441
+ export { ActionVariantInput, AgentEvent, AgentHandle, AgentInfo, type AgentRegistry, type AgentRegistryEntry, AgentThread, type ConcurrencyPolicy, ConnectorDefinition, ConnectorError, ConnectorId, type ConnectorRef, ConnectorToolDef, type Environment, type GenerateOpts, type GenerateResult, type IdentityConfig, type JitPolicy, MANIFEST_END, MANIFEST_START, McpContent, type NotificationConfig, PaginatedResponse, PaginationParams, PlatformActions, PlatformAgent, PlatformAgentConfig, PlatformClient, PlatformClientConfig, PlatformConnector, PlatformError, type PlatformSkill, type ProjectManifest, QueryInfo, QueryResult, type ResourceLimits, type RetryPolicy, RunEvent, RunRecord, SecurityError, SkillId, type SkillRef, StartRunParams, type TeamConfig, TeamMember, ThreadInfo, ThreadMessage, type TriggerConfig, buildActionOutputSchema, concurrencyPolicySchema, defineAction, defineActions, defineConnector, definePlatformAgent, defineSkill, defineTool, environmentSchema, identityConfigSchema, jitPolicySchema, mcpResult, notificationConfigSchema, parseManifestFromOutput, projectManifestSchema, resourceLimitsSchema, retryPolicySchema, teamConfigSchema, triggerConfigSchema, wrapToolError, wrapToolResult };