@averagejoeslab/puppuccino-core 0.1.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.
@@ -0,0 +1,980 @@
1
+ import { z, ZodType } from 'zod';
2
+ import * as _ai_sdk_openai from '@ai-sdk/openai';
3
+ import * as _ai_sdk_anthropic from '@ai-sdk/anthropic';
4
+ import { EventEmitter } from 'node:events';
5
+
6
+ /**
7
+ * Configuration management for Puppuccino
8
+ */
9
+
10
+ /**
11
+ * MCP Server configuration
12
+ */
13
+ declare const MCPServerSchema: z.ZodObject<{
14
+ name: z.ZodString;
15
+ transport: z.ZodEnum<["stdio", "http", "sse"]>;
16
+ command: z.ZodOptional<z.ZodString>;
17
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
18
+ url: z.ZodOptional<z.ZodString>;
19
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
20
+ enabled: z.ZodDefault<z.ZodBoolean>;
21
+ }, "strip", z.ZodTypeAny, {
22
+ name: string;
23
+ transport: "stdio" | "http" | "sse";
24
+ enabled: boolean;
25
+ command?: string | undefined;
26
+ args?: string[] | undefined;
27
+ url?: string | undefined;
28
+ env?: Record<string, string> | undefined;
29
+ }, {
30
+ name: string;
31
+ transport: "stdio" | "http" | "sse";
32
+ command?: string | undefined;
33
+ args?: string[] | undefined;
34
+ url?: string | undefined;
35
+ env?: Record<string, string> | undefined;
36
+ enabled?: boolean | undefined;
37
+ }>;
38
+ type MCPServer = z.infer<typeof MCPServerSchema>;
39
+ /**
40
+ * Hook configuration
41
+ */
42
+ declare const HookSchema: z.ZodObject<{
43
+ event: z.ZodEnum<["SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse", "Stop", "PreCompact", "SessionEnd"]>;
44
+ matcher: z.ZodOptional<z.ZodString>;
45
+ type: z.ZodEnum<["command", "prompt", "agent"]>;
46
+ command: z.ZodOptional<z.ZodString>;
47
+ prompt: z.ZodOptional<z.ZodString>;
48
+ agent: z.ZodOptional<z.ZodString>;
49
+ }, "strip", z.ZodTypeAny, {
50
+ type: "command" | "prompt" | "agent";
51
+ event: "SessionStart" | "UserPromptSubmit" | "PreToolUse" | "PostToolUse" | "Stop" | "PreCompact" | "SessionEnd";
52
+ command?: string | undefined;
53
+ matcher?: string | undefined;
54
+ prompt?: string | undefined;
55
+ agent?: string | undefined;
56
+ }, {
57
+ type: "command" | "prompt" | "agent";
58
+ event: "SessionStart" | "UserPromptSubmit" | "PreToolUse" | "PostToolUse" | "Stop" | "PreCompact" | "SessionEnd";
59
+ command?: string | undefined;
60
+ matcher?: string | undefined;
61
+ prompt?: string | undefined;
62
+ agent?: string | undefined;
63
+ }>;
64
+ type Hook = z.infer<typeof HookSchema>;
65
+ /**
66
+ * Permission configuration
67
+ */
68
+ declare const PermissionsSchema: z.ZodObject<{
69
+ allowedTools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
70
+ disallowedTools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
71
+ autoApprove: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
72
+ yolo: z.ZodDefault<z.ZodBoolean>;
73
+ }, "strip", z.ZodTypeAny, {
74
+ yolo: boolean;
75
+ allowedTools?: string[] | undefined;
76
+ disallowedTools?: string[] | undefined;
77
+ autoApprove?: string[] | undefined;
78
+ }, {
79
+ allowedTools?: string[] | undefined;
80
+ disallowedTools?: string[] | undefined;
81
+ autoApprove?: string[] | undefined;
82
+ yolo?: boolean | undefined;
83
+ }>;
84
+ type Permissions = z.infer<typeof PermissionsSchema>;
85
+ /**
86
+ * Full configuration schema
87
+ */
88
+ declare const ConfigSchema: z.ZodObject<{
89
+ provider: z.ZodDefault<z.ZodEnum<["anthropic", "openai", "groq", "local"]>>;
90
+ model: z.ZodDefault<z.ZodString>;
91
+ apiKey: z.ZodOptional<z.ZodString>;
92
+ baseUrl: z.ZodOptional<z.ZodString>;
93
+ mcpServers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
94
+ name: z.ZodString;
95
+ transport: z.ZodEnum<["stdio", "http", "sse"]>;
96
+ command: z.ZodOptional<z.ZodString>;
97
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
98
+ url: z.ZodOptional<z.ZodString>;
99
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
100
+ enabled: z.ZodDefault<z.ZodBoolean>;
101
+ }, "strip", z.ZodTypeAny, {
102
+ name: string;
103
+ transport: "stdio" | "http" | "sse";
104
+ enabled: boolean;
105
+ command?: string | undefined;
106
+ args?: string[] | undefined;
107
+ url?: string | undefined;
108
+ env?: Record<string, string> | undefined;
109
+ }, {
110
+ name: string;
111
+ transport: "stdio" | "http" | "sse";
112
+ command?: string | undefined;
113
+ args?: string[] | undefined;
114
+ url?: string | undefined;
115
+ env?: Record<string, string> | undefined;
116
+ enabled?: boolean | undefined;
117
+ }>>>;
118
+ permissions: z.ZodOptional<z.ZodObject<{
119
+ allowedTools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
120
+ disallowedTools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
121
+ autoApprove: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
122
+ yolo: z.ZodDefault<z.ZodBoolean>;
123
+ }, "strip", z.ZodTypeAny, {
124
+ yolo: boolean;
125
+ allowedTools?: string[] | undefined;
126
+ disallowedTools?: string[] | undefined;
127
+ autoApprove?: string[] | undefined;
128
+ }, {
129
+ allowedTools?: string[] | undefined;
130
+ disallowedTools?: string[] | undefined;
131
+ autoApprove?: string[] | undefined;
132
+ yolo?: boolean | undefined;
133
+ }>>;
134
+ hooks: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
135
+ event: z.ZodEnum<["SessionStart", "UserPromptSubmit", "PreToolUse", "PostToolUse", "Stop", "PreCompact", "SessionEnd"]>;
136
+ matcher: z.ZodOptional<z.ZodString>;
137
+ type: z.ZodEnum<["command", "prompt", "agent"]>;
138
+ command: z.ZodOptional<z.ZodString>;
139
+ prompt: z.ZodOptional<z.ZodString>;
140
+ agent: z.ZodOptional<z.ZodString>;
141
+ }, "strip", z.ZodTypeAny, {
142
+ type: "command" | "prompt" | "agent";
143
+ event: "SessionStart" | "UserPromptSubmit" | "PreToolUse" | "PostToolUse" | "Stop" | "PreCompact" | "SessionEnd";
144
+ command?: string | undefined;
145
+ matcher?: string | undefined;
146
+ prompt?: string | undefined;
147
+ agent?: string | undefined;
148
+ }, {
149
+ type: "command" | "prompt" | "agent";
150
+ event: "SessionStart" | "UserPromptSubmit" | "PreToolUse" | "PostToolUse" | "Stop" | "PreCompact" | "SessionEnd";
151
+ command?: string | undefined;
152
+ matcher?: string | undefined;
153
+ prompt?: string | undefined;
154
+ agent?: string | undefined;
155
+ }>, "many">>>;
156
+ skills: z.ZodOptional<z.ZodObject<{
157
+ enabled: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
158
+ disabled: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
159
+ }, "strip", z.ZodTypeAny, {
160
+ enabled?: string[] | undefined;
161
+ disabled?: string[] | undefined;
162
+ }, {
163
+ enabled?: string[] | undefined;
164
+ disabled?: string[] | undefined;
165
+ }>>;
166
+ session: z.ZodOptional<z.ZodObject<{
167
+ persistHistory: z.ZodDefault<z.ZodBoolean>;
168
+ maxHistoryDays: z.ZodDefault<z.ZodNumber>;
169
+ }, "strip", z.ZodTypeAny, {
170
+ persistHistory: boolean;
171
+ maxHistoryDays: number;
172
+ }, {
173
+ persistHistory?: boolean | undefined;
174
+ maxHistoryDays?: number | undefined;
175
+ }>>;
176
+ theme: z.ZodDefault<z.ZodEnum<["dark", "light", "kaldi"]>>;
177
+ agent: z.ZodOptional<z.ZodObject<{
178
+ maxTokens: z.ZodDefault<z.ZodNumber>;
179
+ maxTurns: z.ZodDefault<z.ZodNumber>;
180
+ systemPrompt: z.ZodOptional<z.ZodString>;
181
+ }, "strip", z.ZodTypeAny, {
182
+ maxTokens: number;
183
+ maxTurns: number;
184
+ systemPrompt?: string | undefined;
185
+ }, {
186
+ maxTokens?: number | undefined;
187
+ maxTurns?: number | undefined;
188
+ systemPrompt?: string | undefined;
189
+ }>>;
190
+ }, "strip", z.ZodTypeAny, {
191
+ provider: "anthropic" | "openai" | "groq" | "local";
192
+ model: string;
193
+ theme: "dark" | "light" | "kaldi";
194
+ agent?: {
195
+ maxTokens: number;
196
+ maxTurns: number;
197
+ systemPrompt?: string | undefined;
198
+ } | undefined;
199
+ apiKey?: string | undefined;
200
+ baseUrl?: string | undefined;
201
+ mcpServers?: Record<string, {
202
+ name: string;
203
+ transport: "stdio" | "http" | "sse";
204
+ enabled: boolean;
205
+ command?: string | undefined;
206
+ args?: string[] | undefined;
207
+ url?: string | undefined;
208
+ env?: Record<string, string> | undefined;
209
+ }> | undefined;
210
+ permissions?: {
211
+ yolo: boolean;
212
+ allowedTools?: string[] | undefined;
213
+ disallowedTools?: string[] | undefined;
214
+ autoApprove?: string[] | undefined;
215
+ } | undefined;
216
+ hooks?: Record<string, {
217
+ type: "command" | "prompt" | "agent";
218
+ event: "SessionStart" | "UserPromptSubmit" | "PreToolUse" | "PostToolUse" | "Stop" | "PreCompact" | "SessionEnd";
219
+ command?: string | undefined;
220
+ matcher?: string | undefined;
221
+ prompt?: string | undefined;
222
+ agent?: string | undefined;
223
+ }[]> | undefined;
224
+ skills?: {
225
+ enabled?: string[] | undefined;
226
+ disabled?: string[] | undefined;
227
+ } | undefined;
228
+ session?: {
229
+ persistHistory: boolean;
230
+ maxHistoryDays: number;
231
+ } | undefined;
232
+ }, {
233
+ agent?: {
234
+ maxTokens?: number | undefined;
235
+ maxTurns?: number | undefined;
236
+ systemPrompt?: string | undefined;
237
+ } | undefined;
238
+ provider?: "anthropic" | "openai" | "groq" | "local" | undefined;
239
+ model?: string | undefined;
240
+ apiKey?: string | undefined;
241
+ baseUrl?: string | undefined;
242
+ mcpServers?: Record<string, {
243
+ name: string;
244
+ transport: "stdio" | "http" | "sse";
245
+ command?: string | undefined;
246
+ args?: string[] | undefined;
247
+ url?: string | undefined;
248
+ env?: Record<string, string> | undefined;
249
+ enabled?: boolean | undefined;
250
+ }> | undefined;
251
+ permissions?: {
252
+ allowedTools?: string[] | undefined;
253
+ disallowedTools?: string[] | undefined;
254
+ autoApprove?: string[] | undefined;
255
+ yolo?: boolean | undefined;
256
+ } | undefined;
257
+ hooks?: Record<string, {
258
+ type: "command" | "prompt" | "agent";
259
+ event: "SessionStart" | "UserPromptSubmit" | "PreToolUse" | "PostToolUse" | "Stop" | "PreCompact" | "SessionEnd";
260
+ command?: string | undefined;
261
+ matcher?: string | undefined;
262
+ prompt?: string | undefined;
263
+ agent?: string | undefined;
264
+ }[]> | undefined;
265
+ skills?: {
266
+ enabled?: string[] | undefined;
267
+ disabled?: string[] | undefined;
268
+ } | undefined;
269
+ session?: {
270
+ persistHistory?: boolean | undefined;
271
+ maxHistoryDays?: number | undefined;
272
+ } | undefined;
273
+ theme?: "dark" | "light" | "kaldi" | undefined;
274
+ }>;
275
+ type Config = z.infer<typeof ConfigSchema>;
276
+ /**
277
+ * Configuration file locations
278
+ */
279
+ declare const CONFIG_PATHS: {
280
+ project: string[];
281
+ user: string[];
282
+ };
283
+ /**
284
+ * Data directory locations
285
+ */
286
+ declare function getDataDir(): string;
287
+ /**
288
+ * Sessions directory
289
+ */
290
+ declare function getSessionsDir(): string;
291
+ /**
292
+ * Load and merge configuration from all sources
293
+ */
294
+ declare function loadConfig(projectDir?: string): Config;
295
+ /**
296
+ * Save configuration to file
297
+ */
298
+ declare function saveConfig(config: Partial<Config>, path: string): void;
299
+ /**
300
+ * Get default user config path
301
+ */
302
+ declare function getUserConfigPath(): string;
303
+
304
+ /**
305
+ * Tool definitions and registry for Puppuccino
306
+ */
307
+
308
+ /**
309
+ * Tool definition
310
+ */
311
+ interface Tool {
312
+ name: string;
313
+ description: string;
314
+ parameters: ZodType;
315
+ execute: (input: Record<string, unknown>) => Promise<string>;
316
+ }
317
+ /**
318
+ * Tool result
319
+ */
320
+ interface ToolResult {
321
+ success: boolean;
322
+ output: string;
323
+ error?: string;
324
+ }
325
+ /**
326
+ * Read tool - Read file contents
327
+ */
328
+ declare const ReadTool: Tool;
329
+ /**
330
+ * Write tool - Write content to a file
331
+ */
332
+ declare const WriteTool: Tool;
333
+ /**
334
+ * Edit tool - Replace text in a file
335
+ */
336
+ declare const EditTool: Tool;
337
+ /**
338
+ * Glob tool - Find files by pattern
339
+ */
340
+ declare const GlobTool: Tool;
341
+ /**
342
+ * Grep tool - Search file contents
343
+ */
344
+ declare const GrepTool: Tool;
345
+ /**
346
+ * Bash tool - Execute shell commands
347
+ */
348
+ declare const BashTool: Tool;
349
+ /**
350
+ * List tool - List directory contents
351
+ */
352
+ declare const ListTool: Tool;
353
+ /**
354
+ * All built-in tools
355
+ */
356
+ declare const BUILTIN_TOOLS: Tool[];
357
+ /**
358
+ * Tool registry
359
+ */
360
+ declare class ToolRegistry {
361
+ private tools;
362
+ constructor();
363
+ /**
364
+ * Register a tool
365
+ */
366
+ register(tool: Tool): void;
367
+ /**
368
+ * Unregister a tool
369
+ */
370
+ unregister(name: string): void;
371
+ /**
372
+ * Get a tool by name
373
+ */
374
+ get(name: string): Tool | undefined;
375
+ /**
376
+ * Get all registered tools
377
+ */
378
+ all(): Tool[];
379
+ /**
380
+ * Check if a tool exists
381
+ */
382
+ has(name: string): boolean;
383
+ /**
384
+ * Execute a tool
385
+ */
386
+ execute(name: string, input: Record<string, unknown>): Promise<ToolResult>;
387
+ }
388
+ /**
389
+ * Create a tool registry instance
390
+ */
391
+ declare function createToolRegistry(): ToolRegistry;
392
+
393
+ /**
394
+ * Provider types
395
+ */
396
+ type ProviderType = 'anthropic' | 'openai' | 'groq' | 'local';
397
+ /**
398
+ * Message types
399
+ */
400
+ interface Message {
401
+ role: 'user' | 'assistant' | 'system';
402
+ content: string | ContentBlock[];
403
+ }
404
+ interface ContentBlock {
405
+ type: 'text' | 'tool_use' | 'tool_result';
406
+ text?: string;
407
+ id?: string;
408
+ name?: string;
409
+ input?: Record<string, unknown>;
410
+ tool_use_id?: string;
411
+ content?: string;
412
+ }
413
+ /**
414
+ * Tool call from LLM
415
+ */
416
+ interface ToolCall {
417
+ id: string;
418
+ name: string;
419
+ input: Record<string, unknown>;
420
+ }
421
+ /**
422
+ * Response from LLM
423
+ */
424
+ interface LLMResponse {
425
+ text: string;
426
+ toolCalls: ToolCall[];
427
+ finishReason: string;
428
+ usage?: {
429
+ promptTokens: number;
430
+ completionTokens: number;
431
+ };
432
+ }
433
+ /**
434
+ * Chat options
435
+ */
436
+ interface ChatOptions {
437
+ model: string;
438
+ messages: Message[];
439
+ tools?: Tool[];
440
+ systemPrompt?: string;
441
+ maxTokens?: number;
442
+ temperature?: number;
443
+ }
444
+ /**
445
+ * Stream event
446
+ */
447
+ interface StreamEvent {
448
+ type: 'text' | 'tool_call_start' | 'tool_call_end' | 'finish';
449
+ text?: string;
450
+ toolCall?: ToolCall;
451
+ finishReason?: string;
452
+ }
453
+ /**
454
+ * Create a provider instance based on config
455
+ */
456
+ declare function createProvider(config: Config): _ai_sdk_anthropic.AnthropicProvider | _ai_sdk_openai.OpenAIProvider;
457
+ /**
458
+ * Provider class for LLM interactions
459
+ */
460
+ declare class Provider {
461
+ private config;
462
+ private sdk;
463
+ constructor(config: Config);
464
+ /**
465
+ * Send a chat request and get a response
466
+ */
467
+ chat(options: ChatOptions): Promise<LLMResponse>;
468
+ /**
469
+ * Stream a chat response
470
+ */
471
+ chatStream(options: ChatOptions): AsyncGenerator<StreamEvent>;
472
+ /**
473
+ * Get current provider type
474
+ */
475
+ get providerType(): ProviderType;
476
+ /**
477
+ * Get current model
478
+ */
479
+ get model(): string;
480
+ }
481
+ /**
482
+ * Create a provider instance
483
+ */
484
+ declare function createProviderInstance(config: Config): Provider;
485
+
486
+ /**
487
+ * Hooks system for lifecycle events
488
+ */
489
+
490
+ /**
491
+ * Hook events
492
+ */
493
+ type HookEvent = 'SessionStart' | 'UserPromptSubmit' | 'PreToolUse' | 'PostToolUse' | 'Stop' | 'PreCompact' | 'SessionEnd';
494
+ /**
495
+ * Hook context passed to hooks
496
+ */
497
+ interface HookContext {
498
+ event: HookEvent;
499
+ [key: string]: unknown;
500
+ }
501
+ /**
502
+ * Hook result
503
+ */
504
+ interface HookResult {
505
+ blocked: boolean;
506
+ reason?: string;
507
+ output?: string;
508
+ }
509
+ /**
510
+ * Hooks runner
511
+ */
512
+ declare class HooksRunner {
513
+ private hooks;
514
+ constructor(hooks?: Record<string, Hook[]>);
515
+ /**
516
+ * Add a hook
517
+ */
518
+ add(event: HookEvent, hook: Hook): void;
519
+ /**
520
+ * Remove all hooks for an event
521
+ */
522
+ clear(event: HookEvent): void;
523
+ /**
524
+ * Run all hooks for an event
525
+ */
526
+ run(event: HookEvent, context?: Partial<HookContext>): Promise<HookResult>;
527
+ /**
528
+ * Get all hooks for an event
529
+ */
530
+ get(event: HookEvent): Hook[];
531
+ }
532
+ /**
533
+ * Create a hooks runner
534
+ */
535
+ declare function createHooksRunner(hooks?: Record<string, Hook[]>): HooksRunner;
536
+
537
+ /**
538
+ * Permission system for tool execution
539
+ */
540
+
541
+ /**
542
+ * Permission check result
543
+ */
544
+ interface PermissionResult {
545
+ permitted: boolean;
546
+ reason?: string;
547
+ requiresConfirmation?: boolean;
548
+ }
549
+ /**
550
+ * Permission checker
551
+ */
552
+ declare class PermissionChecker {
553
+ private config;
554
+ constructor(config?: Permissions);
555
+ /**
556
+ * Check if a tool execution is permitted
557
+ */
558
+ check(toolName: string, input: Record<string, unknown>): Promise<PermissionResult>;
559
+ /**
560
+ * Update configuration
561
+ */
562
+ updateConfig(config: Partial<Permissions>): void;
563
+ /**
564
+ * Enable YOLO mode
565
+ */
566
+ enableYolo(): void;
567
+ /**
568
+ * Disable YOLO mode
569
+ */
570
+ disableYolo(): void;
571
+ /**
572
+ * Add an auto-approve pattern
573
+ */
574
+ addAutoApprove(pattern: string): void;
575
+ }
576
+ /**
577
+ * Create a permission checker
578
+ */
579
+ declare function createPermissionChecker(config?: Permissions): PermissionChecker;
580
+
581
+ /**
582
+ * Agent loop - the core agentic execution engine
583
+ */
584
+
585
+ /**
586
+ * Agent event types
587
+ */
588
+ type AgentEvent = {
589
+ type: 'thinking';
590
+ } | {
591
+ type: 'text';
592
+ content: string;
593
+ } | {
594
+ type: 'text_delta';
595
+ delta: string;
596
+ } | {
597
+ type: 'tool_start';
598
+ name: string;
599
+ input: Record<string, unknown>;
600
+ } | {
601
+ type: 'tool_result';
602
+ name: string;
603
+ result: ToolResult;
604
+ } | {
605
+ type: 'tool_denied';
606
+ name: string;
607
+ reason: string;
608
+ } | {
609
+ type: 'error';
610
+ error: string;
611
+ } | {
612
+ type: 'done';
613
+ response: LLMResponse;
614
+ };
615
+ /**
616
+ * Agent state
617
+ */
618
+ interface AgentState {
619
+ messages: Message[];
620
+ provider: Provider;
621
+ tools: ToolRegistry;
622
+ hooks?: HooksRunner;
623
+ permissions?: PermissionChecker;
624
+ systemPrompt?: string;
625
+ maxTurns?: number;
626
+ onPermissionRequest?: (toolName: string, input: Record<string, unknown>) => Promise<boolean>;
627
+ }
628
+ /**
629
+ * Default system prompt
630
+ */
631
+ declare const DEFAULT_SYSTEM_PROMPT = "You are Kaldi, a helpful AI coding assistant. You're a Great Pyrenees who loves helping developers write great code.\n\nYou have access to tools to read, write, and edit files, search the codebase, and execute commands. Use these tools to help the user with their coding tasks.\n\nWhen making changes:\n- Read files before editing them to understand the context\n- Make minimal, focused changes\n- Explain what you're doing and why\n- Be careful with destructive operations\n\nBe friendly, helpful, and thorough in your responses.";
632
+ /**
633
+ * Run the agent loop
634
+ */
635
+ declare function runAgentLoop(state: AgentState): AsyncGenerator<AgentEvent>;
636
+ /**
637
+ * Simple synchronous agent run (collects all events)
638
+ */
639
+ declare function runAgent(state: AgentState): Promise<{
640
+ events: AgentEvent[];
641
+ messages: Message[];
642
+ }>;
643
+ /**
644
+ * Create an agent state
645
+ */
646
+ declare function createAgentState(provider: Provider, tools: ToolRegistry, options?: Partial<Omit<AgentState, 'provider' | 'tools' | 'messages'>>): AgentState;
647
+
648
+ /**
649
+ * Session management for conversation persistence
650
+ */
651
+
652
+ /**
653
+ * Session metadata
654
+ */
655
+ interface SessionMeta {
656
+ id: string;
657
+ name?: string;
658
+ createdAt: string;
659
+ updatedAt: string;
660
+ projectPath?: string;
661
+ model?: string;
662
+ messageCount: number;
663
+ }
664
+ /**
665
+ * Full session with messages
666
+ */
667
+ interface Session extends SessionMeta {
668
+ messages: Message[];
669
+ }
670
+ /**
671
+ * Create a new session
672
+ */
673
+ declare function createSession(options?: {
674
+ name?: string;
675
+ projectPath?: string;
676
+ model?: string;
677
+ }): Session;
678
+ /**
679
+ * Save a session to disk
680
+ */
681
+ declare function saveSession(session: Session): void;
682
+ /**
683
+ * Append a message to a session
684
+ */
685
+ declare function appendMessage(sessionId: string, message: Message): void;
686
+ /**
687
+ * Load a session from disk
688
+ */
689
+ declare function loadSession(id: string): Session | null;
690
+ /**
691
+ * List all sessions
692
+ */
693
+ declare function listSessions(): SessionMeta[];
694
+ /**
695
+ * Delete a session
696
+ */
697
+ declare function deleteSession(id: string): boolean;
698
+ /**
699
+ * Get the most recent session
700
+ */
701
+ declare function getRecentSession(): Session | null;
702
+ /**
703
+ * Fork a session (create a copy with new ID)
704
+ */
705
+ declare function forkSession(id: string): Session | null;
706
+ /**
707
+ * Session manager class
708
+ */
709
+ declare class SessionManager {
710
+ private currentSession;
711
+ /**
712
+ * Start a new session
713
+ */
714
+ start(options?: Parameters<typeof createSession>[0]): Session;
715
+ /**
716
+ * Resume an existing session
717
+ */
718
+ resume(id: string): Session | null;
719
+ /**
720
+ * Resume the most recent session
721
+ */
722
+ resumeRecent(): Session | null;
723
+ /**
724
+ * Get current session
725
+ */
726
+ get current(): Session | null;
727
+ /**
728
+ * Add a message to current session
729
+ */
730
+ addMessage(message: Message): void;
731
+ /**
732
+ * Save current session
733
+ */
734
+ save(): void;
735
+ /**
736
+ * Clear current session messages
737
+ */
738
+ clear(): void;
739
+ /**
740
+ * End current session
741
+ */
742
+ end(): void;
743
+ }
744
+ /**
745
+ * Create a session manager
746
+ */
747
+ declare function createSessionManager(): SessionManager;
748
+
749
+ /**
750
+ * MCP (Model Context Protocol) client for tool integration
751
+ */
752
+
753
+ /**
754
+ * MCP connection to a single server
755
+ */
756
+ declare class MCPConnection extends EventEmitter {
757
+ private server;
758
+ private process;
759
+ private messageId;
760
+ private pendingRequests;
761
+ private buffer;
762
+ private tools;
763
+ private initialized;
764
+ constructor(server: MCPServer);
765
+ /**
766
+ * Connect to the MCP server
767
+ */
768
+ connect(): Promise<void>;
769
+ /**
770
+ * Handle incoming data
771
+ */
772
+ private handleData;
773
+ /**
774
+ * Send a request and wait for response
775
+ */
776
+ private request;
777
+ /**
778
+ * Initialize the MCP connection
779
+ */
780
+ private initialize;
781
+ /**
782
+ * Get tools from this server
783
+ */
784
+ getTools(): Tool[];
785
+ /**
786
+ * Convert MCP tool to our Tool format
787
+ */
788
+ private convertTool;
789
+ /**
790
+ * Call a tool on this server
791
+ */
792
+ callTool(name: string, input: Record<string, unknown>): Promise<unknown>;
793
+ /**
794
+ * Disconnect from the server
795
+ */
796
+ disconnect(): void;
797
+ /**
798
+ * Check if connected
799
+ */
800
+ get isConnected(): boolean;
801
+ }
802
+ /**
803
+ * MCP client managing multiple servers
804
+ */
805
+ declare class MCPClient {
806
+ private connections;
807
+ /**
808
+ * Add and connect to an MCP server
809
+ */
810
+ addServer(server: MCPServer): Promise<void>;
811
+ /**
812
+ * Remove an MCP server
813
+ */
814
+ removeServer(name: string): void;
815
+ /**
816
+ * Get all tools from all servers
817
+ */
818
+ getTools(): Tool[];
819
+ /**
820
+ * Call a tool (parses the mcp__server__tool format)
821
+ */
822
+ callTool(name: string, input: Record<string, unknown>): Promise<unknown>;
823
+ /**
824
+ * Disconnect all servers
825
+ */
826
+ disconnectAll(): void;
827
+ /**
828
+ * Get connected server names
829
+ */
830
+ get servers(): string[];
831
+ }
832
+ /**
833
+ * Create an MCP client
834
+ */
835
+ declare function createMCPClient(): MCPClient;
836
+
837
+ /**
838
+ * Skills system for reusable prompts and capabilities
839
+ */
840
+ /**
841
+ * Skill metadata from YAML frontmatter
842
+ */
843
+ interface SkillMeta {
844
+ name: string;
845
+ description?: string;
846
+ disableModelInvocation?: boolean;
847
+ userInvocable?: boolean;
848
+ allowedTools?: string[];
849
+ model?: string;
850
+ context?: 'fork' | 'inline';
851
+ agent?: string;
852
+ }
853
+ /**
854
+ * Full skill definition
855
+ */
856
+ interface Skill extends SkillMeta {
857
+ content: string;
858
+ path: string;
859
+ }
860
+ /**
861
+ * Skills loader
862
+ */
863
+ declare class SkillsLoader {
864
+ private skills;
865
+ private projectPath?;
866
+ constructor(projectPath?: string);
867
+ /**
868
+ * Reload all skills
869
+ */
870
+ reload(): void;
871
+ /**
872
+ * Get a skill by name
873
+ */
874
+ get(name: string): Skill | undefined;
875
+ /**
876
+ * Get all skills
877
+ */
878
+ all(): Skill[];
879
+ /**
880
+ * Get user-invocable skills
881
+ */
882
+ userInvocable(): Skill[];
883
+ /**
884
+ * Get model-invocable skills
885
+ */
886
+ modelInvocable(): Skill[];
887
+ /**
888
+ * Check if a skill exists
889
+ */
890
+ has(name: string): boolean;
891
+ /**
892
+ * Expand a skill's content with arguments
893
+ */
894
+ expand(name: string, args?: string): string | null;
895
+ }
896
+ /**
897
+ * Create a skills loader
898
+ */
899
+ declare function createSkillsLoader(projectPath?: string): SkillsLoader;
900
+
901
+ /**
902
+ * Context management for project and memory
903
+ */
904
+ /**
905
+ * Project context information
906
+ */
907
+ interface ProjectContext {
908
+ path: string;
909
+ name: string;
910
+ gitRoot?: string;
911
+ packageJson?: Record<string, unknown>;
912
+ readme?: string;
913
+ structure: string;
914
+ }
915
+ /**
916
+ * Load project context
917
+ */
918
+ declare function loadProjectContext(projectPath: string): ProjectContext;
919
+ /**
920
+ * Format project context as system prompt addition
921
+ */
922
+ declare function formatProjectContext(context: ProjectContext): string;
923
+ /**
924
+ * Memory entry for conversation context
925
+ */
926
+ interface MemoryEntry {
927
+ type: 'summary' | 'fact' | 'preference';
928
+ content: string;
929
+ timestamp: string;
930
+ }
931
+ /**
932
+ * Conversation memory
933
+ */
934
+ declare class Memory {
935
+ private entries;
936
+ private maxEntries;
937
+ /**
938
+ * Add an entry
939
+ */
940
+ add(type: MemoryEntry['type'], content: string): void;
941
+ /**
942
+ * Get all entries
943
+ */
944
+ all(): MemoryEntry[];
945
+ /**
946
+ * Get entries by type
947
+ */
948
+ byType(type: MemoryEntry['type']): MemoryEntry[];
949
+ /**
950
+ * Format memory for system prompt
951
+ */
952
+ format(): string;
953
+ /**
954
+ * Clear all entries
955
+ */
956
+ clear(): void;
957
+ /**
958
+ * Export entries
959
+ */
960
+ export(): MemoryEntry[];
961
+ /**
962
+ * Import entries
963
+ */
964
+ import(entries: MemoryEntry[]): void;
965
+ }
966
+ /**
967
+ * Create a memory instance
968
+ */
969
+ declare function createMemory(): Memory;
970
+
971
+ /**
972
+ * @puppuccino/core - Core engine for Puppuccino AI coding agent
973
+ *
974
+ * This package provides the fundamental building blocks for the Puppuccino
975
+ * coding agent, including the agent loop, tools, providers, and more.
976
+ */
977
+
978
+ declare const VERSION = "0.1.0";
979
+
980
+ export { type AgentEvent, type AgentState, BUILTIN_TOOLS, BashTool, CONFIG_PATHS, type ChatOptions, type Config, ConfigSchema, type ContentBlock, DEFAULT_SYSTEM_PROMPT, EditTool, GlobTool, GrepTool, type Hook, type HookContext, type HookEvent, type HookResult, HookSchema, HooksRunner, type LLMResponse, ListTool, MCPClient, MCPConnection, type MCPServer, MCPServerSchema, Memory, type MemoryEntry, type Message, PermissionChecker, type PermissionResult, type Permissions, PermissionsSchema, type ProjectContext, Provider, type ProviderType, ReadTool, type Session, SessionManager, type SessionMeta, type Skill, type SkillMeta, SkillsLoader, type StreamEvent, type Tool, type ToolCall, ToolRegistry, type ToolResult, VERSION, WriteTool, appendMessage, createAgentState, createHooksRunner, createMCPClient, createMemory, createPermissionChecker, createProvider, createProviderInstance, createSession, createSessionManager, createSkillsLoader, createToolRegistry, deleteSession, forkSession, formatProjectContext, getDataDir, getRecentSession, getSessionsDir, getUserConfigPath, listSessions, loadConfig, loadProjectContext, loadSession, runAgent, runAgentLoop, saveConfig, saveSession };