kraken-ai 0.0.5 → 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/README.md +1 -1
- package/dist/{chunk-RBQ2PPDE.js → chunk-3WRAEJP3.js} +1 -0
- package/dist/{chunk-4X5NFWDA.js → chunk-6Q6G4WVJ.js} +1 -1
- package/dist/{chunk-5XNFMNJL.js → chunk-D2AU5FGJ.js} +1 -1
- package/dist/google-W6HDKXTM.js +7 -0
- package/dist/index.cjs +12 -3
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +16 -8
- package/dist/openai-STUANOLN.js +7 -0
- package/package.json +5 -5
- package/dist/google-GNB46G6S.js +0 -7
- package/dist/openai-HXIIBATW.js +0 -7
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ if (result.status === "complete") {
|
|
|
65
65
|
## Requirements
|
|
66
66
|
|
|
67
67
|
- Node.js 18+
|
|
68
|
-
- TypeScript 5+
|
|
68
|
+
- TypeScript 5+ (TypeScript 6 supported; requires tsup patch in monorepos — see [egoist/tsup#1388](https://github.com/egoist/tsup/issues/1388))
|
|
69
69
|
- `zod` 4+ (peer dependency)
|
|
70
70
|
- `@google/genai` 1+ (optional — required for the Google provider)
|
|
71
71
|
|
package/dist/index.cjs
CHANGED
|
@@ -55,6 +55,7 @@ var init_errors = __esm({
|
|
|
55
55
|
this.toolName = toolName;
|
|
56
56
|
this.name = "ToolError";
|
|
57
57
|
}
|
|
58
|
+
toolName;
|
|
58
59
|
};
|
|
59
60
|
ValidationError = class extends KrakenError {
|
|
60
61
|
constructor(message) {
|
|
@@ -458,6 +459,7 @@ var LifecycleManager = class {
|
|
|
458
459
|
constructor(onTransition) {
|
|
459
460
|
this.onTransition = onTransition;
|
|
460
461
|
}
|
|
462
|
+
onTransition;
|
|
461
463
|
_state = "idle";
|
|
462
464
|
_transitions = [];
|
|
463
465
|
get state() {
|
|
@@ -547,6 +549,11 @@ var createRunner = (config2) => {
|
|
|
547
549
|
...config2.thinkingLevel ? { thinkingLevel: config2.thinkingLevel } : {},
|
|
548
550
|
hasOutputSchema: Boolean(config2.responseSchema)
|
|
549
551
|
});
|
|
552
|
+
emitter.emit({
|
|
553
|
+
type: "transcript_init",
|
|
554
|
+
systemPrompt: agent.instructions,
|
|
555
|
+
messages: inputMessages.map((m) => ({ role: m.role, content: m.content }))
|
|
556
|
+
});
|
|
550
557
|
const usage = { inputTokens: 0, outputTokens: 0 };
|
|
551
558
|
const conversationMessages = [...inputMessages];
|
|
552
559
|
let currentRound = 0;
|
|
@@ -582,6 +589,9 @@ var createRunner = (config2) => {
|
|
|
582
589
|
const response = await wrappedGenerate(params);
|
|
583
590
|
usage.inputTokens += response.usage.inputTokens;
|
|
584
591
|
usage.outputTokens += response.usage.outputTokens;
|
|
592
|
+
if (!model.generateStream && response.thoughts) {
|
|
593
|
+
emitter.emit({ type: "thought", text: response.thoughts, callIndex: round });
|
|
594
|
+
}
|
|
585
595
|
emitter.emit({
|
|
586
596
|
type: "llm_call",
|
|
587
597
|
inputTokens: response.usage.inputTokens,
|
|
@@ -592,9 +602,6 @@ var createRunner = (config2) => {
|
|
|
592
602
|
args: tc.args
|
|
593
603
|
}))
|
|
594
604
|
});
|
|
595
|
-
if (!model.generateStream && response.thoughts) {
|
|
596
|
-
emitter.emit({ type: "thought", text: response.thoughts, callIndex: round });
|
|
597
|
-
}
|
|
598
605
|
if (!response.toolCalls?.length) {
|
|
599
606
|
lifecycle.transition("completed");
|
|
600
607
|
return {
|
|
@@ -1014,6 +1021,8 @@ var formatEvent = (e) => {
|
|
|
1014
1021
|
return `${tag} notification: ${e.title}`;
|
|
1015
1022
|
case "structured_output_complete":
|
|
1016
1023
|
return `${tag} structured output complete`;
|
|
1024
|
+
case "transcript_init":
|
|
1025
|
+
return `${tag} transcript: system prompt + ${e.messages.length} message(s)`;
|
|
1017
1026
|
}
|
|
1018
1027
|
};
|
|
1019
1028
|
|
package/dist/index.d.cts
CHANGED
|
@@ -174,6 +174,14 @@ interface AgentConfigEvent extends AgentEventBase {
|
|
|
174
174
|
thinkingLevel?: string;
|
|
175
175
|
hasOutputSchema: boolean;
|
|
176
176
|
}
|
|
177
|
+
interface AgentTranscriptInitEvent extends AgentEventBase {
|
|
178
|
+
type: "transcript_init";
|
|
179
|
+
systemPrompt: string;
|
|
180
|
+
messages: Array<{
|
|
181
|
+
role: string;
|
|
182
|
+
content: string;
|
|
183
|
+
}>;
|
|
184
|
+
}
|
|
177
185
|
interface AgentLifecycleEvent extends AgentEventBase {
|
|
178
186
|
type: "lifecycle";
|
|
179
187
|
from: AgentState;
|
|
@@ -239,7 +247,7 @@ interface AgentStructuredOutputCompleteEvent extends AgentEventBase {
|
|
|
239
247
|
/** All possible agent event type strings. */
|
|
240
248
|
type AgentEventType = AgentEvent["type"];
|
|
241
249
|
/** An event emitted during agent execution. Discriminated union on `type`. */
|
|
242
|
-
type AgentEvent = AgentConfigEvent | AgentLifecycleEvent | AgentLLMCallEvent | AgentThoughtEvent | AgentToolCallEvent | AgentDelegationEvent | AgentInterruptEvent | AgentKillEvent | AgentErrorEvent | AgentNotificationEvent | AgentStructuredOutputCompleteEvent;
|
|
250
|
+
type AgentEvent = AgentConfigEvent | AgentTranscriptInitEvent | AgentLifecycleEvent | AgentLLMCallEvent | AgentThoughtEvent | AgentToolCallEvent | AgentDelegationEvent | AgentInterruptEvent | AgentKillEvent | AgentErrorEvent | AgentNotificationEvent | AgentStructuredOutputCompleteEvent;
|
|
243
251
|
/** Distributive Omit that preserves union variants — strips base fields from each event type. */
|
|
244
252
|
type AgentEventPayload<T = AgentEvent> = T extends AgentEventBase ? Omit<T, keyof AgentEventBase> : never;
|
|
245
253
|
/** Log verbosity level. */
|
|
@@ -367,6 +375,8 @@ interface RunOptions {
|
|
|
367
375
|
thinkingLevel?: ThinkingLevel;
|
|
368
376
|
maxOutputTokens?: number;
|
|
369
377
|
responseSchema?: Record<string, unknown>;
|
|
378
|
+
/** When true, tool calls are logged but not executed. */
|
|
379
|
+
dryRun?: boolean;
|
|
370
380
|
/** @internal Shared map for pre-generated child runIds during delegation. */
|
|
371
381
|
_childRunIds?: Map<string, string[]>;
|
|
372
382
|
}
|
|
@@ -674,4 +684,4 @@ interface ToolConfig<TParams extends z.ZodType, TReturn = unknown> {
|
|
|
674
684
|
*/
|
|
675
685
|
declare const tool: <TParams extends z.ZodType, TReturn>(config: ToolConfig<TParams, TReturn>) => Tool;
|
|
676
686
|
|
|
677
|
-
export { Agent, type AgentConfig, type AgentConfigEvent, type AgentDelegationEvent, type AgentErrorEvent, type AgentEvent, type AgentEventBase, type AgentEventPayload, type AgentEventType, type AgentInterruptEvent, type AgentKillEvent, type AgentLLMCallEvent, type AgentLifecycleEvent, type AgentLike, type AgentNotificationEvent, type AgentRef, type AgentState, type AgentStructuredOutputCompleteEvent, type AgentThoughtEvent, type AgentToolCallEvent, type ExecutionContext, type GenerateParams, type GenerateResponse, type GlobalConfig, type GoogleModelConfig, type GoogleModelId, type HumanDecision, type Interrupt, type Kernel, type KernelSignal, KrakenError, type LogLevel, type Message, type Middleware, type MiddlewareContext, type Model, type ModelParams, type ModelString, type OpenAIModelId, OutputValidationError, ProviderError, type RetryConfig, type RunOptions, type RunResult, type RunnerResponse, type SpawnSpec, type StreamChunk, type TeamAccessor, type ThinkingLevel, type Tool, type ToolCall, type ToolConfig, type ToolDefinition, ToolError, ToolInputValidationError, type ToolResult, type TransitionRecord, type Usage, ValidationError, configure, defineKernel, formatEvent, google, mock, openai, tool };
|
|
687
|
+
export { Agent, type AgentConfig, type AgentConfigEvent, type AgentDelegationEvent, type AgentErrorEvent, type AgentEvent, type AgentEventBase, type AgentEventPayload, type AgentEventType, type AgentInterruptEvent, type AgentKillEvent, type AgentLLMCallEvent, type AgentLifecycleEvent, type AgentLike, type AgentNotificationEvent, type AgentRef, type AgentState, type AgentStructuredOutputCompleteEvent, type AgentThoughtEvent, type AgentToolCallEvent, type AgentTranscriptInitEvent, type ExecutionContext, type GenerateParams, type GenerateResponse, type GlobalConfig, type GoogleModelConfig, type GoogleModelId, type HumanDecision, type Interrupt, type Kernel, type KernelSignal, KrakenError, type LogLevel, type Message, type Middleware, type MiddlewareContext, type Model, type ModelParams, type ModelString, type OpenAIModelId, OutputValidationError, ProviderError, type RetryConfig, type RunOptions, type RunResult, type RunnerResponse, type SpawnSpec, type StreamChunk, type TeamAccessor, type ThinkingLevel, type Tool, type ToolCall, type ToolConfig, type ToolDefinition, ToolError, ToolInputValidationError, type ToolResult, type TransitionRecord, type Usage, ValidationError, configure, defineKernel, formatEvent, google, mock, openai, tool };
|
package/dist/index.d.ts
CHANGED
|
@@ -174,6 +174,14 @@ interface AgentConfigEvent extends AgentEventBase {
|
|
|
174
174
|
thinkingLevel?: string;
|
|
175
175
|
hasOutputSchema: boolean;
|
|
176
176
|
}
|
|
177
|
+
interface AgentTranscriptInitEvent extends AgentEventBase {
|
|
178
|
+
type: "transcript_init";
|
|
179
|
+
systemPrompt: string;
|
|
180
|
+
messages: Array<{
|
|
181
|
+
role: string;
|
|
182
|
+
content: string;
|
|
183
|
+
}>;
|
|
184
|
+
}
|
|
177
185
|
interface AgentLifecycleEvent extends AgentEventBase {
|
|
178
186
|
type: "lifecycle";
|
|
179
187
|
from: AgentState;
|
|
@@ -239,7 +247,7 @@ interface AgentStructuredOutputCompleteEvent extends AgentEventBase {
|
|
|
239
247
|
/** All possible agent event type strings. */
|
|
240
248
|
type AgentEventType = AgentEvent["type"];
|
|
241
249
|
/** An event emitted during agent execution. Discriminated union on `type`. */
|
|
242
|
-
type AgentEvent = AgentConfigEvent | AgentLifecycleEvent | AgentLLMCallEvent | AgentThoughtEvent | AgentToolCallEvent | AgentDelegationEvent | AgentInterruptEvent | AgentKillEvent | AgentErrorEvent | AgentNotificationEvent | AgentStructuredOutputCompleteEvent;
|
|
250
|
+
type AgentEvent = AgentConfigEvent | AgentTranscriptInitEvent | AgentLifecycleEvent | AgentLLMCallEvent | AgentThoughtEvent | AgentToolCallEvent | AgentDelegationEvent | AgentInterruptEvent | AgentKillEvent | AgentErrorEvent | AgentNotificationEvent | AgentStructuredOutputCompleteEvent;
|
|
243
251
|
/** Distributive Omit that preserves union variants — strips base fields from each event type. */
|
|
244
252
|
type AgentEventPayload<T = AgentEvent> = T extends AgentEventBase ? Omit<T, keyof AgentEventBase> : never;
|
|
245
253
|
/** Log verbosity level. */
|
|
@@ -367,6 +375,8 @@ interface RunOptions {
|
|
|
367
375
|
thinkingLevel?: ThinkingLevel;
|
|
368
376
|
maxOutputTokens?: number;
|
|
369
377
|
responseSchema?: Record<string, unknown>;
|
|
378
|
+
/** When true, tool calls are logged but not executed. */
|
|
379
|
+
dryRun?: boolean;
|
|
370
380
|
/** @internal Shared map for pre-generated child runIds during delegation. */
|
|
371
381
|
_childRunIds?: Map<string, string[]>;
|
|
372
382
|
}
|
|
@@ -674,4 +684,4 @@ interface ToolConfig<TParams extends z.ZodType, TReturn = unknown> {
|
|
|
674
684
|
*/
|
|
675
685
|
declare const tool: <TParams extends z.ZodType, TReturn>(config: ToolConfig<TParams, TReturn>) => Tool;
|
|
676
686
|
|
|
677
|
-
export { Agent, type AgentConfig, type AgentConfigEvent, type AgentDelegationEvent, type AgentErrorEvent, type AgentEvent, type AgentEventBase, type AgentEventPayload, type AgentEventType, type AgentInterruptEvent, type AgentKillEvent, type AgentLLMCallEvent, type AgentLifecycleEvent, type AgentLike, type AgentNotificationEvent, type AgentRef, type AgentState, type AgentStructuredOutputCompleteEvent, type AgentThoughtEvent, type AgentToolCallEvent, type ExecutionContext, type GenerateParams, type GenerateResponse, type GlobalConfig, type GoogleModelConfig, type GoogleModelId, type HumanDecision, type Interrupt, type Kernel, type KernelSignal, KrakenError, type LogLevel, type Message, type Middleware, type MiddlewareContext, type Model, type ModelParams, type ModelString, type OpenAIModelId, OutputValidationError, ProviderError, type RetryConfig, type RunOptions, type RunResult, type RunnerResponse, type SpawnSpec, type StreamChunk, type TeamAccessor, type ThinkingLevel, type Tool, type ToolCall, type ToolConfig, type ToolDefinition, ToolError, ToolInputValidationError, type ToolResult, type TransitionRecord, type Usage, ValidationError, configure, defineKernel, formatEvent, google, mock, openai, tool };
|
|
687
|
+
export { Agent, type AgentConfig, type AgentConfigEvent, type AgentDelegationEvent, type AgentErrorEvent, type AgentEvent, type AgentEventBase, type AgentEventPayload, type AgentEventType, type AgentInterruptEvent, type AgentKillEvent, type AgentLLMCallEvent, type AgentLifecycleEvent, type AgentLike, type AgentNotificationEvent, type AgentRef, type AgentState, type AgentStructuredOutputCompleteEvent, type AgentThoughtEvent, type AgentToolCallEvent, type AgentTranscriptInitEvent, type ExecutionContext, type GenerateParams, type GenerateResponse, type GlobalConfig, type GoogleModelConfig, type GoogleModelId, type HumanDecision, type Interrupt, type Kernel, type KernelSignal, KrakenError, type LogLevel, type Message, type Middleware, type MiddlewareContext, type Model, type ModelParams, type ModelString, type OpenAIModelId, OutputValidationError, ProviderError, type RetryConfig, type RunOptions, type RunResult, type RunnerResponse, type SpawnSpec, type StreamChunk, type TeamAccessor, type ThinkingLevel, type Tool, type ToolCall, type ToolConfig, type ToolDefinition, ToolError, ToolInputValidationError, type ToolResult, type TransitionRecord, type Usage, ValidationError, configure, defineKernel, formatEvent, google, mock, openai, tool };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
google
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6Q6G4WVJ.js";
|
|
4
4
|
import {
|
|
5
5
|
openai
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-D2AU5FGJ.js";
|
|
7
7
|
import {
|
|
8
8
|
KrakenError,
|
|
9
9
|
OutputValidationError,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
ToolError,
|
|
12
12
|
ToolInputValidationError,
|
|
13
13
|
ValidationError
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-3WRAEJP3.js";
|
|
15
15
|
|
|
16
16
|
// src/agent.ts
|
|
17
17
|
import * as z2 from "zod";
|
|
@@ -40,10 +40,10 @@ var createLazyModel = (provider, modelId) => {
|
|
|
40
40
|
const ensureResolved = async () => {
|
|
41
41
|
if (resolvedModel) return resolvedModel;
|
|
42
42
|
if (provider === "google") {
|
|
43
|
-
const { google: google2 } = await import("./google-
|
|
43
|
+
const { google: google2 } = await import("./google-W6HDKXTM.js");
|
|
44
44
|
resolvedModel = google2(modelId);
|
|
45
45
|
} else if (provider === "openai") {
|
|
46
|
-
const { openai: openai2 } = await import("./openai-
|
|
46
|
+
const { openai: openai2 } = await import("./openai-STUANOLN.js");
|
|
47
47
|
resolvedModel = openai2(modelId);
|
|
48
48
|
} else {
|
|
49
49
|
throw new ValidationError(`Unknown provider "${provider}".`);
|
|
@@ -141,6 +141,7 @@ var LifecycleManager = class {
|
|
|
141
141
|
constructor(onTransition) {
|
|
142
142
|
this.onTransition = onTransition;
|
|
143
143
|
}
|
|
144
|
+
onTransition;
|
|
144
145
|
_state = "idle";
|
|
145
146
|
_transitions = [];
|
|
146
147
|
get state() {
|
|
@@ -230,6 +231,11 @@ var createRunner = (config2) => {
|
|
|
230
231
|
...config2.thinkingLevel ? { thinkingLevel: config2.thinkingLevel } : {},
|
|
231
232
|
hasOutputSchema: Boolean(config2.responseSchema)
|
|
232
233
|
});
|
|
234
|
+
emitter.emit({
|
|
235
|
+
type: "transcript_init",
|
|
236
|
+
systemPrompt: agent.instructions,
|
|
237
|
+
messages: inputMessages.map((m) => ({ role: m.role, content: m.content }))
|
|
238
|
+
});
|
|
233
239
|
const usage = { inputTokens: 0, outputTokens: 0 };
|
|
234
240
|
const conversationMessages = [...inputMessages];
|
|
235
241
|
let currentRound = 0;
|
|
@@ -265,6 +271,9 @@ var createRunner = (config2) => {
|
|
|
265
271
|
const response = await wrappedGenerate(params);
|
|
266
272
|
usage.inputTokens += response.usage.inputTokens;
|
|
267
273
|
usage.outputTokens += response.usage.outputTokens;
|
|
274
|
+
if (!model.generateStream && response.thoughts) {
|
|
275
|
+
emitter.emit({ type: "thought", text: response.thoughts, callIndex: round });
|
|
276
|
+
}
|
|
268
277
|
emitter.emit({
|
|
269
278
|
type: "llm_call",
|
|
270
279
|
inputTokens: response.usage.inputTokens,
|
|
@@ -275,9 +284,6 @@ var createRunner = (config2) => {
|
|
|
275
284
|
args: tc.args
|
|
276
285
|
}))
|
|
277
286
|
});
|
|
278
|
-
if (!model.generateStream && response.thoughts) {
|
|
279
|
-
emitter.emit({ type: "thought", text: response.thoughts, callIndex: round });
|
|
280
|
-
}
|
|
281
287
|
if (!response.toolCalls?.length) {
|
|
282
288
|
lifecycle.transition("completed");
|
|
283
289
|
return {
|
|
@@ -694,6 +700,8 @@ var formatEvent = (e) => {
|
|
|
694
700
|
return `${tag} notification: ${e.title}`;
|
|
695
701
|
case "structured_output_complete":
|
|
696
702
|
return `${tag} structured output complete`;
|
|
703
|
+
case "transcript_init":
|
|
704
|
+
return `${tag} transcript: system prompt + ${e.messages.length} message(s)`;
|
|
697
705
|
}
|
|
698
706
|
};
|
|
699
707
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kraken-ai",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Kraken AI SDK: a very lightweight, fully-typed multi-model AI agent framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@google/genai": "^1.
|
|
18
|
-
"@types/node": "^25.5.
|
|
17
|
+
"@google/genai": "^1.48.0",
|
|
18
|
+
"@types/node": "^25.5.2",
|
|
19
19
|
"tsup": "^8.5.1",
|
|
20
20
|
"tsx": "^4.21.0",
|
|
21
|
-
"typescript": "^
|
|
22
|
-
"vitest": "^4.1.
|
|
21
|
+
"typescript": "^6.0.2",
|
|
22
|
+
"vitest": "^4.1.3",
|
|
23
23
|
"zod": "^4.3.6"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
package/dist/google-GNB46G6S.js
DELETED