@tuttiai/core 0.7.0 → 0.8.0
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 +97 -4
- package/dist/index.js +440 -105
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,88 @@
|
|
|
1
|
+
import { TuttiHooks, TelemetryConfig, TuttiEventType, TuttiEvent, ScoreConfig, AgentResult, Session, LLMProvider, SessionStore, AgentConfig, ChatMessage, Voice, Permission, BudgetConfig, ChatRequest, ChatResponse, StreamChunk } from '@tuttiai/types';
|
|
2
|
+
export { AgentConfig, AgentMemoryConfig, AgentResult, BudgetConfig, ChatMessage, ChatRequest, ChatResponse, ContentBlock, HookContext, LLMProvider, MemoryConfig, Permission, ScoreConfig, Session, SessionStore, StopReason, StreamChunk, TelemetryConfig, TextBlock, TokenUsage, Tool, ToolContext, ToolDefinition, ToolMemoryHelpers, ToolResult, ToolResultBlock, ToolUseBlock, TuttiEvent, TuttiEventHandler, TuttiEventType, TuttiHooks, Voice, VoiceContext } from '@tuttiai/types';
|
|
1
3
|
import pino from 'pino';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Typed error hierarchy for Tutti. All errors extend TuttiError.
|
|
7
|
+
*/
|
|
8
|
+
declare class TuttiError extends Error {
|
|
9
|
+
readonly code: string;
|
|
10
|
+
readonly context: Record<string, unknown>;
|
|
11
|
+
constructor(code: string, message: string, context?: Record<string, unknown>);
|
|
12
|
+
}
|
|
13
|
+
declare class ScoreValidationError extends TuttiError {
|
|
14
|
+
constructor(message: string, context?: {
|
|
15
|
+
field?: string;
|
|
16
|
+
value?: unknown;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
declare class AgentNotFoundError extends TuttiError {
|
|
20
|
+
constructor(agentId: string, available: string[]);
|
|
21
|
+
}
|
|
22
|
+
declare class PermissionError extends TuttiError {
|
|
23
|
+
constructor(voice: string, required: string[], granted: string[]);
|
|
24
|
+
}
|
|
25
|
+
declare class BudgetExceededError extends TuttiError {
|
|
26
|
+
constructor(tokens: number, costUsd: number, limit: string);
|
|
27
|
+
}
|
|
28
|
+
declare class ToolTimeoutError extends TuttiError {
|
|
29
|
+
constructor(tool: string, timeoutMs: number);
|
|
30
|
+
}
|
|
31
|
+
declare class ProviderError extends TuttiError {
|
|
32
|
+
constructor(message: string, context?: {
|
|
33
|
+
provider: string;
|
|
34
|
+
status?: number;
|
|
35
|
+
} & Record<string, unknown>);
|
|
36
|
+
}
|
|
37
|
+
declare class AuthenticationError extends ProviderError {
|
|
38
|
+
constructor(provider: string);
|
|
39
|
+
}
|
|
40
|
+
declare class RateLimitError extends ProviderError {
|
|
41
|
+
readonly retryAfter?: number;
|
|
42
|
+
constructor(provider: string, retryAfter?: number);
|
|
43
|
+
}
|
|
44
|
+
declare class ContextWindowError extends ProviderError {
|
|
45
|
+
readonly maxTokens?: number;
|
|
46
|
+
constructor(provider: string, maxTokens?: number);
|
|
47
|
+
}
|
|
48
|
+
declare class VoiceError extends TuttiError {
|
|
49
|
+
constructor(message: string, context: {
|
|
50
|
+
voice: string;
|
|
51
|
+
tool?: string;
|
|
52
|
+
} & Record<string, unknown>);
|
|
53
|
+
}
|
|
54
|
+
declare class PathTraversalError extends VoiceError {
|
|
55
|
+
constructor(path: string);
|
|
56
|
+
}
|
|
57
|
+
declare class UrlValidationError extends VoiceError {
|
|
58
|
+
constructor(url: string);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Built-in hook factories for common patterns.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Logs all LLM calls and tool executions via a pino logger.
|
|
67
|
+
*/
|
|
68
|
+
declare function createLoggingHook(log: pino.Logger): TuttiHooks;
|
|
69
|
+
/**
|
|
70
|
+
* Caches tool results by tool name + input hash.
|
|
71
|
+
* The `store` is a simple Map or any get/set interface.
|
|
72
|
+
*/
|
|
73
|
+
declare function createCacheHook(store: {
|
|
74
|
+
get(key: string): string | undefined;
|
|
75
|
+
set(key: string, value: string): void;
|
|
76
|
+
}): TuttiHooks;
|
|
77
|
+
/**
|
|
78
|
+
* Blocks specific tool names from being called.
|
|
79
|
+
*/
|
|
80
|
+
declare function createBlocklistHook(blockedTools: string[]): TuttiHooks;
|
|
81
|
+
/**
|
|
82
|
+
* Blocks LLM calls once estimated cost exceeds the given USD limit.
|
|
83
|
+
* Tracks cost across the lifetime of the hook instance.
|
|
84
|
+
*/
|
|
85
|
+
declare function createMaxCostHook(maxUsd: number): TuttiHooks;
|
|
4
86
|
|
|
5
87
|
declare const createLogger: (name: string) => pino.Logger<never, boolean>;
|
|
6
88
|
declare const logger: pino.Logger<never, boolean>;
|
|
@@ -74,6 +156,11 @@ declare class TuttiRuntime {
|
|
|
74
156
|
* Optionally pass a session_id to continue a conversation.
|
|
75
157
|
*/
|
|
76
158
|
run(agent_name: string, input: string, session_id?: string): Promise<AgentResult>;
|
|
159
|
+
/**
|
|
160
|
+
* Provide an answer to a pending human-in-the-loop request.
|
|
161
|
+
* Call this when a `hitl:requested` event fires to resume the agent.
|
|
162
|
+
*/
|
|
163
|
+
answer(sessionId: string, answer: string): void;
|
|
77
164
|
/** Retrieve an existing session. */
|
|
78
165
|
getSession(id: string): Session | undefined;
|
|
79
166
|
}
|
|
@@ -83,10 +170,16 @@ declare class AgentRunner {
|
|
|
83
170
|
private events;
|
|
84
171
|
private sessions;
|
|
85
172
|
private semanticMemory?;
|
|
86
|
-
|
|
173
|
+
private globalHooks?;
|
|
174
|
+
private pendingHitl;
|
|
175
|
+
constructor(provider: LLMProvider, events: EventBus, sessions: SessionStore, semanticMemory?: SemanticMemoryStore | undefined, globalHooks?: TuttiHooks | undefined);
|
|
176
|
+
private safeHook;
|
|
177
|
+
/** Resolve a pending human-in-the-loop request for a session. */
|
|
178
|
+
answer(sessionId: string, answer: string): void;
|
|
87
179
|
run(agent: AgentConfig, input: string, session_id?: string): Promise<AgentResult>;
|
|
88
180
|
private executeWithTimeout;
|
|
89
181
|
private streamToResponse;
|
|
182
|
+
private createHitlTool;
|
|
90
183
|
private executeTool;
|
|
91
184
|
}
|
|
92
185
|
|
|
@@ -243,4 +336,4 @@ declare class GeminiProvider implements LLMProvider {
|
|
|
243
336
|
stream(request: ChatRequest): AsyncGenerator<StreamChunk>;
|
|
244
337
|
}
|
|
245
338
|
|
|
246
|
-
export { AgentRouter, AgentRunner, AnthropicProvider, type AnthropicProviderOptions, EventBus, GeminiProvider, type GeminiProviderOptions, InMemorySemanticStore, InMemorySessionStore, type MemoryEntry, OpenAIProvider, type OpenAIProviderOptions, PermissionGuard, PostgresSessionStore, PromptGuard, ScoreLoader, SecretsManager, type SemanticMemoryStore, TokenBudget, TuttiRuntime, TuttiTracer, createLogger, defineScore, initTelemetry, logger, shutdownTelemetry, validateScore };
|
|
339
|
+
export { AgentNotFoundError, AgentRouter, AgentRunner, AnthropicProvider, type AnthropicProviderOptions, AuthenticationError, BudgetExceededError, ContextWindowError, EventBus, GeminiProvider, type GeminiProviderOptions, InMemorySemanticStore, InMemorySessionStore, type MemoryEntry, OpenAIProvider, type OpenAIProviderOptions, PathTraversalError, PermissionError, PermissionGuard, PostgresSessionStore, PromptGuard, ProviderError, RateLimitError, ScoreLoader, ScoreValidationError, SecretsManager, type SemanticMemoryStore, TokenBudget, ToolTimeoutError, TuttiError, TuttiRuntime, TuttiTracer, UrlValidationError, VoiceError, createBlocklistHook, createCacheHook, createLogger, createLoggingHook, createMaxCostHook, defineScore, initTelemetry, logger, shutdownTelemetry, validateScore };
|