@weavelogic/knowledge-graph-agent 0.9.0 → 0.10.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,1054 @@
1
+ /**
2
+ * Claude Interaction Storage Schema
3
+ *
4
+ * Hierarchical storage schema for storing Claude prompts, outputs, and tool calls
5
+ * in a knowledge graph. Supports hierarchical nesting from sessions down to
6
+ * individual tool calls and sub-agent operations.
7
+ *
8
+ * @module claude/types
9
+ */
10
+ import { z } from 'zod';
11
+ /**
12
+ * Unique identifier types for different hierarchy levels
13
+ */
14
+ export type SessionId = `session_${string}`;
15
+ export type ConversationId = `conv_${string}`;
16
+ export type MessageId = `msg_${string}`;
17
+ export type ToolCallId = `tool_${string}`;
18
+ export type SubAgentId = `agent_${string}`;
19
+ export type SwarmId = `swarm_${string}`;
20
+ export type WorkflowId = `wf_${string}`;
21
+ /**
22
+ * Claude model identifiers
23
+ */
24
+ export type ClaudeModel = 'claude-opus-4-5-20251101' | 'claude-sonnet-4-20250514' | 'claude-3-5-sonnet-20241022' | 'claude-3-opus-20240229' | 'claude-3-sonnet-20240229' | 'claude-3-haiku-20240307' | string;
25
+ /**
26
+ * Message role in conversation
27
+ */
28
+ export type MessageRole = 'user' | 'assistant' | 'system';
29
+ /**
30
+ * Status of a hierarchical node
31
+ */
32
+ export type ExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timeout';
33
+ /**
34
+ * Agent type classification for sub-agents and swarm members
35
+ */
36
+ export type ClaudeAgentType = 'researcher' | 'coder' | 'tester' | 'analyst' | 'architect' | 'reviewer' | 'coordinator' | 'optimizer' | 'documenter' | 'planner' | 'custom';
37
+ /**
38
+ * Swarm topology types from claude-flow
39
+ */
40
+ export type SwarmTopology = 'mesh' | 'hierarchical' | 'ring' | 'star';
41
+ /**
42
+ * Swarm execution strategy
43
+ */
44
+ export type SwarmStrategy = 'parallel' | 'sequential' | 'adaptive';
45
+ /**
46
+ * Token usage metrics for cost tracking and optimization
47
+ */
48
+ export interface TokenUsage {
49
+ /** Input tokens consumed */
50
+ inputTokens: number;
51
+ /** Output tokens generated */
52
+ outputTokens: number;
53
+ /** Cache read tokens (if using prompt caching) */
54
+ cacheReadTokens?: number;
55
+ /** Cache write tokens (if using prompt caching) */
56
+ cacheWriteTokens?: number;
57
+ /** Total tokens (computed) */
58
+ totalTokens: number;
59
+ /** Estimated cost in USD (based on model pricing) */
60
+ estimatedCostUsd?: number;
61
+ }
62
+ /**
63
+ * Aggregated token usage across multiple operations
64
+ */
65
+ export interface AggregatedTokenUsage extends TokenUsage {
66
+ /** Number of operations aggregated */
67
+ operationCount: number;
68
+ /** Breakdown by model if multiple models used */
69
+ byModel?: Record<ClaudeModel, TokenUsage>;
70
+ /** Breakdown by operation type */
71
+ byOperationType?: Record<string, TokenUsage>;
72
+ }
73
+ /**
74
+ * Common metadata for all hierarchical nodes
75
+ */
76
+ export interface BaseMetadata {
77
+ /** Creation timestamp */
78
+ createdAt: Date;
79
+ /** Last update timestamp */
80
+ updatedAt: Date;
81
+ /** User-defined tags for categorization */
82
+ tags: string[];
83
+ /** Custom key-value metadata */
84
+ custom?: Record<string, unknown>;
85
+ }
86
+ /**
87
+ * Session represents a complete interaction session with Claude
88
+ *
89
+ * Sessions are the top level of the hierarchy and contain multiple conversations.
90
+ * They track overall context, purpose, and aggregated metrics.
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * const session: ClaudeSession = {
95
+ * id: 'session_abc123',
96
+ * name: 'Feature Development Session',
97
+ * purpose: 'Implement user authentication feature',
98
+ * startedAt: new Date('2024-01-15T10:00:00Z'),
99
+ * status: 'running',
100
+ * conversationIds: ['conv_xyz789'],
101
+ * tokenUsage: { inputTokens: 5000, outputTokens: 3000, totalTokens: 8000 },
102
+ * metadata: { tags: ['auth', 'feature'], createdAt: new Date() },
103
+ * };
104
+ * ```
105
+ */
106
+ export interface ClaudeSession {
107
+ /** Unique session identifier */
108
+ id: SessionId;
109
+ /** Human-readable session name */
110
+ name: string;
111
+ /** Purpose or goal of the session */
112
+ purpose?: string;
113
+ /** When the session started */
114
+ startedAt: Date;
115
+ /** When the session ended (if completed) */
116
+ endedAt?: Date;
117
+ /** Current session status */
118
+ status: ExecutionStatus;
119
+ /** IDs of conversations in this session */
120
+ conversationIds: ConversationId[];
121
+ /** IDs of swarms spawned during this session */
122
+ swarmIds?: SwarmId[];
123
+ /** IDs of workflows executed during this session */
124
+ workflowIds?: WorkflowId[];
125
+ /** Aggregated token usage for the entire session */
126
+ tokenUsage: AggregatedTokenUsage;
127
+ /** Environment context (working directory, git branch, etc.) */
128
+ environment?: SessionEnvironment;
129
+ /** Session metadata */
130
+ metadata: BaseMetadata;
131
+ }
132
+ /**
133
+ * Environment context captured at session start
134
+ */
135
+ export interface SessionEnvironment {
136
+ /** Working directory path */
137
+ workingDirectory: string;
138
+ /** Git branch if in a repository */
139
+ gitBranch?: string;
140
+ /** Git commit hash at session start */
141
+ gitCommit?: string;
142
+ /** Platform (linux, darwin, win32) */
143
+ platform: string;
144
+ /** Node.js version if applicable */
145
+ nodeVersion?: string;
146
+ /** Claude Code version */
147
+ claudeCodeVersion?: string;
148
+ /** Active MCP servers */
149
+ mcpServers?: string[];
150
+ }
151
+ /**
152
+ * Conversation represents a single thread of messages with Claude
153
+ *
154
+ * Conversations are contained within sessions and contain ordered messages.
155
+ * They track the flow of interaction including tool calls and responses.
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * const conversation: ClaudeConversation = {
160
+ * id: 'conv_xyz789',
161
+ * sessionId: 'session_abc123',
162
+ * title: 'Implement login endpoint',
163
+ * model: 'claude-opus-4-5-20251101',
164
+ * messageIds: ['msg_001', 'msg_002'],
165
+ * status: 'completed',
166
+ * tokenUsage: { inputTokens: 2000, outputTokens: 1500, totalTokens: 3500 },
167
+ * metadata: { tags: ['api', 'auth'] },
168
+ * };
169
+ * ```
170
+ */
171
+ export interface ClaudeConversation {
172
+ /** Unique conversation identifier */
173
+ id: ConversationId;
174
+ /** Parent session ID */
175
+ sessionId: SessionId;
176
+ /** Conversation title or topic */
177
+ title?: string;
178
+ /** Primary model used in this conversation */
179
+ model: ClaudeModel;
180
+ /** System prompt used (if any) */
181
+ systemPrompt?: string;
182
+ /** Ordered list of message IDs */
183
+ messageIds: MessageId[];
184
+ /** Sub-agent IDs spawned from this conversation */
185
+ subAgentIds?: SubAgentId[];
186
+ /** Current conversation status */
187
+ status: ExecutionStatus;
188
+ /** When conversation started */
189
+ startedAt: Date;
190
+ /** When conversation ended */
191
+ endedAt?: Date;
192
+ /** Total token usage for this conversation */
193
+ tokenUsage: TokenUsage;
194
+ /** Conversation context (file paths, topics, etc.) */
195
+ context?: ConversationContext;
196
+ /** Conversation metadata */
197
+ metadata: BaseMetadata;
198
+ }
199
+ /**
200
+ * Context information for a conversation
201
+ */
202
+ export interface ConversationContext {
203
+ /** Primary files being discussed or edited */
204
+ primaryFiles?: string[];
205
+ /** Related knowledge graph node IDs */
206
+ relatedNodeIds?: string[];
207
+ /** Topic keywords extracted from conversation */
208
+ topics?: string[];
209
+ /** User intent classification */
210
+ intent?: 'query' | 'task' | 'debug' | 'refactor' | 'document' | 'review' | 'other';
211
+ }
212
+ /**
213
+ * Message represents a single prompt or response in a conversation
214
+ *
215
+ * Messages are the core unit of interaction and contain the actual content
216
+ * exchanged between user and Claude, including any tool calls made.
217
+ *
218
+ * @example
219
+ * ```typescript
220
+ * const message: ClaudeMessage = {
221
+ * id: 'msg_001',
222
+ * conversationId: 'conv_xyz789',
223
+ * role: 'user',
224
+ * content: 'Create a login endpoint with JWT authentication',
225
+ * timestamp: new Date(),
226
+ * tokenUsage: { inputTokens: 50, outputTokens: 0, totalTokens: 50 },
227
+ * metadata: { tags: ['request'] },
228
+ * };
229
+ * ```
230
+ */
231
+ export interface ClaudeMessage {
232
+ /** Unique message identifier */
233
+ id: MessageId;
234
+ /** Parent conversation ID */
235
+ conversationId: ConversationId;
236
+ /** Message role (user prompt or assistant response) */
237
+ role: MessageRole;
238
+ /** Text content of the message */
239
+ content: string;
240
+ /** Structured content blocks (for complex responses) */
241
+ contentBlocks?: MessageContentBlock[];
242
+ /** Tool calls made in this message (assistant only) */
243
+ toolCallIds?: ToolCallId[];
244
+ /** Tool results included in this message (user only, as tool_result) */
245
+ toolResultIds?: ToolCallId[];
246
+ /** When the message was created */
247
+ timestamp: Date;
248
+ /** Token usage for this message */
249
+ tokenUsage: TokenUsage;
250
+ /** Stop reason (for assistant messages) */
251
+ stopReason?: 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use';
252
+ /** Message metadata */
253
+ metadata: BaseMetadata;
254
+ }
255
+ /**
256
+ * Content block types for structured message content
257
+ */
258
+ export type MessageContentBlock = TextContentBlock | CodeContentBlock | ToolUseContentBlock | ToolResultContentBlock | ThinkingContentBlock;
259
+ /**
260
+ * Plain text content block
261
+ */
262
+ export interface TextContentBlock {
263
+ type: 'text';
264
+ text: string;
265
+ }
266
+ /**
267
+ * Code content block with language identification
268
+ */
269
+ export interface CodeContentBlock {
270
+ type: 'code';
271
+ language: string;
272
+ code: string;
273
+ /** File path if this code is for a specific file */
274
+ filePath?: string;
275
+ }
276
+ /**
277
+ * Tool use content block
278
+ */
279
+ export interface ToolUseContentBlock {
280
+ type: 'tool_use';
281
+ toolCallId: ToolCallId;
282
+ toolName: string;
283
+ input: Record<string, unknown>;
284
+ }
285
+ /**
286
+ * Tool result content block
287
+ */
288
+ export interface ToolResultContentBlock {
289
+ type: 'tool_result';
290
+ toolCallId: ToolCallId;
291
+ content: string;
292
+ isError?: boolean;
293
+ }
294
+ /**
295
+ * Extended thinking content block (for extended thinking mode)
296
+ */
297
+ export interface ThinkingContentBlock {
298
+ type: 'thinking';
299
+ thinking: string;
300
+ /** Summary of the thinking (for display) */
301
+ summary?: string;
302
+ }
303
+ /**
304
+ * Tool call represents a single tool invocation by Claude
305
+ *
306
+ * Tool calls are made by assistant messages and track the full lifecycle
307
+ * from invocation through execution to result.
308
+ *
309
+ * @example
310
+ * ```typescript
311
+ * const toolCall: ClaudeToolCall = {
312
+ * id: 'tool_abc123',
313
+ * messageId: 'msg_002',
314
+ * toolName: 'Edit',
315
+ * toolCategory: 'file',
316
+ * input: { file_path: '/src/auth.ts', old_string: '...', new_string: '...' },
317
+ * output: { success: true },
318
+ * status: 'completed',
319
+ * executionTimeMs: 150,
320
+ * metadata: { tags: ['edit'] },
321
+ * };
322
+ * ```
323
+ */
324
+ export interface ClaudeToolCall {
325
+ /** Unique tool call identifier */
326
+ id: ToolCallId;
327
+ /** Parent message ID (the assistant message that made this call) */
328
+ messageId: MessageId;
329
+ /** Name of the tool invoked */
330
+ toolName: string;
331
+ /** Category of tool (for grouping and analysis) */
332
+ toolCategory: ToolCategory;
333
+ /** Input parameters passed to the tool */
334
+ input: Record<string, unknown>;
335
+ /** Output/result from the tool */
336
+ output?: unknown;
337
+ /** Error information if tool call failed */
338
+ error?: ToolCallError;
339
+ /** Execution status */
340
+ status: ExecutionStatus;
341
+ /** When the tool call started */
342
+ startedAt: Date;
343
+ /** When the tool call completed */
344
+ completedAt?: Date;
345
+ /** Total execution time in milliseconds */
346
+ executionTimeMs?: number;
347
+ /** Files affected by this tool call */
348
+ affectedFiles?: string[];
349
+ /** Tool call metadata */
350
+ metadata: BaseMetadata;
351
+ }
352
+ /**
353
+ * Tool categories for grouping and analysis
354
+ */
355
+ export type ToolCategory = 'file' | 'bash' | 'search' | 'mcp' | 'task' | 'notebook' | 'todo' | 'skill' | 'other';
356
+ /**
357
+ * Error information for failed tool calls
358
+ */
359
+ export interface ToolCallError {
360
+ /** Error type/code */
361
+ type: string;
362
+ /** Human-readable error message */
363
+ message: string;
364
+ /** Additional error details */
365
+ details?: Record<string, unknown>;
366
+ /** Whether the error is recoverable */
367
+ recoverable?: boolean;
368
+ }
369
+ /**
370
+ * Sub-agent represents an agent spawned via the Task tool
371
+ *
372
+ * Sub-agents are child agents created during a conversation to handle
373
+ * specific tasks. They have their own conversation context and can
374
+ * spawn further sub-agents.
375
+ *
376
+ * @example
377
+ * ```typescript
378
+ * const subAgent: ClaudeSubAgent = {
379
+ * id: 'agent_def456',
380
+ * parentConversationId: 'conv_xyz789',
381
+ * parentMessageId: 'msg_002',
382
+ * agentType: 'coder',
383
+ * name: 'Backend Implementation Agent',
384
+ * task: 'Implement the login endpoint with proper validation',
385
+ * model: 'claude-sonnet-4-20250514',
386
+ * conversationId: 'conv_sub001',
387
+ * status: 'completed',
388
+ * result: { success: true, filesCreated: ['src/auth.ts'] },
389
+ * tokenUsage: { inputTokens: 1000, outputTokens: 800, totalTokens: 1800 },
390
+ * metadata: { tags: ['backend'] },
391
+ * };
392
+ * ```
393
+ */
394
+ export interface ClaudeSubAgent {
395
+ /** Unique sub-agent identifier */
396
+ id: SubAgentId;
397
+ /** Parent conversation that spawned this agent */
398
+ parentConversationId: ConversationId;
399
+ /** Specific message that spawned this agent */
400
+ parentMessageId: MessageId;
401
+ /** Tool call ID that created this agent */
402
+ toolCallId: ToolCallId;
403
+ /** Agent type/specialization */
404
+ agentType: ClaudeAgentType;
405
+ /** Agent name (for identification) */
406
+ name: string;
407
+ /** Task description given to the agent */
408
+ task: string;
409
+ /** Model used by this sub-agent */
410
+ model: ClaudeModel;
411
+ /** Conversation ID for this agent's work */
412
+ conversationId?: ConversationId;
413
+ /** Child sub-agent IDs spawned by this agent */
414
+ childAgentIds?: SubAgentId[];
415
+ /** Execution status */
416
+ status: ExecutionStatus;
417
+ /** When the agent started */
418
+ startedAt: Date;
419
+ /** When the agent completed */
420
+ completedAt?: Date;
421
+ /** Result/output from the agent */
422
+ result?: SubAgentResult;
423
+ /** Token usage for this agent's work */
424
+ tokenUsage: TokenUsage;
425
+ /** Agent metadata */
426
+ metadata: BaseMetadata;
427
+ }
428
+ /**
429
+ * Result from a sub-agent execution
430
+ */
431
+ export interface SubAgentResult {
432
+ /** Whether the task was successful */
433
+ success: boolean;
434
+ /** Summary of what was accomplished */
435
+ summary?: string;
436
+ /** Files created by the agent */
437
+ filesCreated?: string[];
438
+ /** Files modified by the agent */
439
+ filesModified?: string[];
440
+ /** Files deleted by the agent */
441
+ filesDeleted?: string[];
442
+ /** Error message if failed */
443
+ error?: string;
444
+ /** Structured output data */
445
+ data?: unknown;
446
+ }
447
+ /**
448
+ * Swarm represents a claude-flow swarm coordination
449
+ *
450
+ * Swarms are multi-agent orchestrations that coordinate multiple agents
451
+ * working together on complex tasks.
452
+ *
453
+ * @example
454
+ * ```typescript
455
+ * const swarm: ClaudeSwarm = {
456
+ * id: 'swarm_ghi789',
457
+ * sessionId: 'session_abc123',
458
+ * name: 'Full Stack Development Swarm',
459
+ * topology: 'mesh',
460
+ * strategy: 'adaptive',
461
+ * maxAgents: 5,
462
+ * agentIds: ['agent_001', 'agent_002', 'agent_003'],
463
+ * task: 'Implement complete user management module',
464
+ * status: 'running',
465
+ * tokenUsage: { inputTokens: 10000, outputTokens: 8000, totalTokens: 18000, operationCount: 5 },
466
+ * metadata: { tags: ['fullstack'] },
467
+ * };
468
+ * ```
469
+ */
470
+ export interface ClaudeSwarm {
471
+ /** Unique swarm identifier */
472
+ id: SwarmId;
473
+ /** Parent session ID */
474
+ sessionId: SessionId;
475
+ /** Swarm name */
476
+ name: string;
477
+ /** Network topology */
478
+ topology: SwarmTopology;
479
+ /** Execution strategy */
480
+ strategy: SwarmStrategy;
481
+ /** Maximum agents in the swarm */
482
+ maxAgents: number;
483
+ /** IDs of agents in this swarm */
484
+ agentIds: SubAgentId[];
485
+ /** High-level task for the swarm */
486
+ task: string;
487
+ /** Execution status */
488
+ status: ExecutionStatus;
489
+ /** When the swarm was initialized */
490
+ startedAt: Date;
491
+ /** When the swarm completed */
492
+ completedAt?: Date;
493
+ /** Aggregated result from all agents */
494
+ result?: SwarmResult;
495
+ /** Aggregated token usage */
496
+ tokenUsage: AggregatedTokenUsage;
497
+ /** MCP tool calls made for swarm coordination */
498
+ coordinationCallIds?: ToolCallId[];
499
+ /** Swarm metadata */
500
+ metadata: BaseMetadata;
501
+ }
502
+ /**
503
+ * Aggregated result from a swarm execution
504
+ */
505
+ export interface SwarmResult {
506
+ /** Overall success status */
507
+ success: boolean;
508
+ /** Summary of swarm accomplishments */
509
+ summary?: string;
510
+ /** Individual agent results */
511
+ agentResults: Record<SubAgentId, SubAgentResult>;
512
+ /** Total files affected */
513
+ totalFilesAffected: number;
514
+ /** Metrics about the swarm execution */
515
+ metrics?: SwarmMetrics;
516
+ }
517
+ /**
518
+ * Metrics for swarm execution
519
+ */
520
+ export interface SwarmMetrics {
521
+ /** Number of agents that completed successfully */
522
+ successfulAgents: number;
523
+ /** Number of agents that failed */
524
+ failedAgents: number;
525
+ /** Total execution time in milliseconds */
526
+ totalExecutionTimeMs: number;
527
+ /** Average time per agent */
528
+ avgAgentTimeMs: number;
529
+ /** Coordination overhead time */
530
+ coordinationOverheadMs?: number;
531
+ }
532
+ /**
533
+ * Workflow represents a script or structured workflow execution
534
+ *
535
+ * Workflows are structured sequences of operations that may involve
536
+ * multiple tools, agents, or manual steps.
537
+ *
538
+ * @example
539
+ * ```typescript
540
+ * const workflow: ClaudeWorkflow = {
541
+ * id: 'wf_jkl012',
542
+ * sessionId: 'session_abc123',
543
+ * name: 'CI/CD Pipeline Setup',
544
+ * type: 'skill',
545
+ * skillName: 'github-workflow-automation',
546
+ * steps: [...],
547
+ * status: 'completed',
548
+ * tokenUsage: { inputTokens: 3000, outputTokens: 2000, totalTokens: 5000, operationCount: 3 },
549
+ * metadata: { tags: ['ci', 'github'] },
550
+ * };
551
+ * ```
552
+ */
553
+ export interface ClaudeWorkflow {
554
+ /** Unique workflow identifier */
555
+ id: WorkflowId;
556
+ /** Parent session ID */
557
+ sessionId: SessionId;
558
+ /** Workflow name */
559
+ name: string;
560
+ /** Type of workflow */
561
+ type: 'skill' | 'script' | 'manual' | 'automated';
562
+ /** Skill name if type is 'skill' */
563
+ skillName?: string;
564
+ /** Script path if type is 'script' */
565
+ scriptPath?: string;
566
+ /** Workflow steps */
567
+ steps: WorkflowStep[];
568
+ /** Current step index (if running) */
569
+ currentStepIndex?: number;
570
+ /** Execution status */
571
+ status: ExecutionStatus;
572
+ /** When workflow started */
573
+ startedAt: Date;
574
+ /** When workflow completed */
575
+ completedAt?: Date;
576
+ /** Workflow result */
577
+ result?: WorkflowResult;
578
+ /** Aggregated token usage */
579
+ tokenUsage: AggregatedTokenUsage;
580
+ /** Related conversation IDs */
581
+ conversationIds?: ConversationId[];
582
+ /** Related tool call IDs */
583
+ toolCallIds?: ToolCallId[];
584
+ /** Workflow metadata */
585
+ metadata: BaseMetadata;
586
+ }
587
+ /**
588
+ * Individual step in a workflow
589
+ */
590
+ export interface WorkflowStep {
591
+ /** Step index (0-based) */
592
+ index: number;
593
+ /** Step name */
594
+ name: string;
595
+ /** Step description */
596
+ description?: string;
597
+ /** Type of step */
598
+ type: 'tool' | 'agent' | 'manual' | 'condition' | 'loop';
599
+ /** Tool name if type is 'tool' */
600
+ toolName?: string;
601
+ /** Tool call ID if executed */
602
+ toolCallId?: ToolCallId;
603
+ /** Agent ID if type is 'agent' */
604
+ agentId?: SubAgentId;
605
+ /** Step status */
606
+ status: ExecutionStatus;
607
+ /** Step input */
608
+ input?: unknown;
609
+ /** Step output */
610
+ output?: unknown;
611
+ /** Execution time in milliseconds */
612
+ executionTimeMs?: number;
613
+ /** Error if failed */
614
+ error?: string;
615
+ }
616
+ /**
617
+ * Result from a workflow execution
618
+ */
619
+ export interface WorkflowResult {
620
+ /** Overall success */
621
+ success: boolean;
622
+ /** Summary of workflow completion */
623
+ summary?: string;
624
+ /** Number of steps completed */
625
+ stepsCompleted: number;
626
+ /** Total steps in workflow */
627
+ totalSteps: number;
628
+ /** Output data */
629
+ data?: unknown;
630
+ /** Error if failed */
631
+ error?: string;
632
+ }
633
+ /**
634
+ * Edge types for hierarchical relationships in the knowledge graph
635
+ */
636
+ export type ClaudeGraphEdgeType = 'session_contains_conversation' | 'session_contains_swarm' | 'session_contains_workflow' | 'conversation_contains_message' | 'conversation_spawns_agent' | 'message_contains_tool_call' | 'message_has_tool_result' | 'agent_has_conversation' | 'agent_spawns_child' | 'swarm_contains_agent' | 'workflow_contains_step' | 'workflow_uses_tool' | 'workflow_uses_agent' | 'references_file' | 'references_node' | 'related_to';
637
+ /**
638
+ * Graph edge for Claude interaction hierarchy
639
+ */
640
+ export interface ClaudeGraphEdge {
641
+ /** Source node ID */
642
+ source: string;
643
+ /** Target node ID */
644
+ target: string;
645
+ /** Relationship type */
646
+ type: ClaudeGraphEdgeType;
647
+ /** Edge weight (for relevance scoring) */
648
+ weight: number;
649
+ /** Additional context about the relationship */
650
+ context?: string;
651
+ /** When this relationship was created */
652
+ createdAt: Date;
653
+ }
654
+ /**
655
+ * Filter options for querying Claude interactions
656
+ */
657
+ export interface ClaudeInteractionFilter {
658
+ /** Filter by session IDs */
659
+ sessionIds?: SessionId[];
660
+ /** Filter by conversation IDs */
661
+ conversationIds?: ConversationId[];
662
+ /** Filter by date range */
663
+ dateRange?: {
664
+ start?: Date;
665
+ end?: Date;
666
+ };
667
+ /** Filter by status */
668
+ status?: ExecutionStatus[];
669
+ /** Filter by tags */
670
+ tags?: string[];
671
+ /** Filter by model */
672
+ models?: ClaudeModel[];
673
+ /** Filter by agent type */
674
+ agentTypes?: ClaudeAgentType[];
675
+ /** Filter by tool names */
676
+ toolNames?: string[];
677
+ /** Full-text search query */
678
+ textQuery?: string;
679
+ /** Minimum token count */
680
+ minTokens?: number;
681
+ /** Maximum token count */
682
+ maxTokens?: number;
683
+ }
684
+ /**
685
+ * Sort options for query results
686
+ */
687
+ export interface ClaudeInteractionSort {
688
+ /** Field to sort by */
689
+ field: 'createdAt' | 'updatedAt' | 'tokenUsage' | 'executionTime';
690
+ /** Sort direction */
691
+ direction: 'asc' | 'desc';
692
+ }
693
+ /**
694
+ * Pagination options
695
+ */
696
+ export interface PaginationOptions {
697
+ /** Number of items per page */
698
+ limit: number;
699
+ /** Offset for pagination */
700
+ offset: number;
701
+ }
702
+ /**
703
+ * Analytics summary for Claude interactions
704
+ */
705
+ export interface ClaudeAnalyticsSummary {
706
+ /** Total sessions */
707
+ totalSessions: number;
708
+ /** Total conversations */
709
+ totalConversations: number;
710
+ /** Total messages */
711
+ totalMessages: number;
712
+ /** Total tool calls */
713
+ totalToolCalls: number;
714
+ /** Total sub-agents spawned */
715
+ totalSubAgents: number;
716
+ /** Total swarms */
717
+ totalSwarms: number;
718
+ /** Total workflows */
719
+ totalWorkflows: number;
720
+ /** Aggregated token usage */
721
+ tokenUsage: AggregatedTokenUsage;
722
+ /** Breakdown by model */
723
+ byModel: Record<ClaudeModel, {
724
+ count: number;
725
+ tokenUsage: TokenUsage;
726
+ }>;
727
+ /** Breakdown by tool category */
728
+ byToolCategory: Record<ToolCategory, {
729
+ count: number;
730
+ avgExecutionTimeMs: number;
731
+ }>;
732
+ /** Success rate */
733
+ successRate: number;
734
+ /** Date range of data */
735
+ dateRange: {
736
+ earliest: Date;
737
+ latest: Date;
738
+ };
739
+ }
740
+ /**
741
+ * Zod schema for token usage validation
742
+ */
743
+ export declare const TokenUsageSchema: z.ZodObject<{
744
+ inputTokens: z.ZodNumber;
745
+ outputTokens: z.ZodNumber;
746
+ cacheReadTokens: z.ZodOptional<z.ZodNumber>;
747
+ cacheWriteTokens: z.ZodOptional<z.ZodNumber>;
748
+ totalTokens: z.ZodNumber;
749
+ estimatedCostUsd: z.ZodOptional<z.ZodNumber>;
750
+ }, "strip", z.ZodTypeAny, {
751
+ inputTokens: number;
752
+ outputTokens: number;
753
+ totalTokens: number;
754
+ cacheReadTokens?: number | undefined;
755
+ cacheWriteTokens?: number | undefined;
756
+ estimatedCostUsd?: number | undefined;
757
+ }, {
758
+ inputTokens: number;
759
+ outputTokens: number;
760
+ totalTokens: number;
761
+ cacheReadTokens?: number | undefined;
762
+ cacheWriteTokens?: number | undefined;
763
+ estimatedCostUsd?: number | undefined;
764
+ }>;
765
+ /**
766
+ * Zod schema for base metadata validation
767
+ */
768
+ export declare const BaseMetadataSchema: z.ZodObject<{
769
+ createdAt: z.ZodDate;
770
+ updatedAt: z.ZodDate;
771
+ tags: z.ZodArray<z.ZodString, "many">;
772
+ custom: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
773
+ }, "strip", z.ZodTypeAny, {
774
+ tags: string[];
775
+ createdAt: Date;
776
+ updatedAt: Date;
777
+ custom?: Record<string, unknown> | undefined;
778
+ }, {
779
+ tags: string[];
780
+ createdAt: Date;
781
+ updatedAt: Date;
782
+ custom?: Record<string, unknown> | undefined;
783
+ }>;
784
+ /**
785
+ * Zod schema for session validation
786
+ */
787
+ export declare const ClaudeSessionSchema: z.ZodObject<{
788
+ id: z.ZodString;
789
+ name: z.ZodString;
790
+ purpose: z.ZodOptional<z.ZodString>;
791
+ startedAt: z.ZodDate;
792
+ endedAt: z.ZodOptional<z.ZodDate>;
793
+ status: z.ZodEnum<["pending", "running", "completed", "failed", "cancelled", "timeout"]>;
794
+ conversationIds: z.ZodArray<z.ZodString, "many">;
795
+ swarmIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
796
+ workflowIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
797
+ tokenUsage: z.ZodObject<{
798
+ inputTokens: z.ZodNumber;
799
+ outputTokens: z.ZodNumber;
800
+ cacheReadTokens: z.ZodOptional<z.ZodNumber>;
801
+ cacheWriteTokens: z.ZodOptional<z.ZodNumber>;
802
+ totalTokens: z.ZodNumber;
803
+ estimatedCostUsd: z.ZodOptional<z.ZodNumber>;
804
+ } & {
805
+ operationCount: z.ZodNumber;
806
+ byModel: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
807
+ inputTokens: z.ZodNumber;
808
+ outputTokens: z.ZodNumber;
809
+ cacheReadTokens: z.ZodOptional<z.ZodNumber>;
810
+ cacheWriteTokens: z.ZodOptional<z.ZodNumber>;
811
+ totalTokens: z.ZodNumber;
812
+ estimatedCostUsd: z.ZodOptional<z.ZodNumber>;
813
+ }, "strip", z.ZodTypeAny, {
814
+ inputTokens: number;
815
+ outputTokens: number;
816
+ totalTokens: number;
817
+ cacheReadTokens?: number | undefined;
818
+ cacheWriteTokens?: number | undefined;
819
+ estimatedCostUsd?: number | undefined;
820
+ }, {
821
+ inputTokens: number;
822
+ outputTokens: number;
823
+ totalTokens: number;
824
+ cacheReadTokens?: number | undefined;
825
+ cacheWriteTokens?: number | undefined;
826
+ estimatedCostUsd?: number | undefined;
827
+ }>>>;
828
+ byOperationType: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
829
+ inputTokens: z.ZodNumber;
830
+ outputTokens: z.ZodNumber;
831
+ cacheReadTokens: z.ZodOptional<z.ZodNumber>;
832
+ cacheWriteTokens: z.ZodOptional<z.ZodNumber>;
833
+ totalTokens: z.ZodNumber;
834
+ estimatedCostUsd: z.ZodOptional<z.ZodNumber>;
835
+ }, "strip", z.ZodTypeAny, {
836
+ inputTokens: number;
837
+ outputTokens: number;
838
+ totalTokens: number;
839
+ cacheReadTokens?: number | undefined;
840
+ cacheWriteTokens?: number | undefined;
841
+ estimatedCostUsd?: number | undefined;
842
+ }, {
843
+ inputTokens: number;
844
+ outputTokens: number;
845
+ totalTokens: number;
846
+ cacheReadTokens?: number | undefined;
847
+ cacheWriteTokens?: number | undefined;
848
+ estimatedCostUsd?: number | undefined;
849
+ }>>>;
850
+ }, "strip", z.ZodTypeAny, {
851
+ inputTokens: number;
852
+ outputTokens: number;
853
+ totalTokens: number;
854
+ operationCount: number;
855
+ cacheReadTokens?: number | undefined;
856
+ cacheWriteTokens?: number | undefined;
857
+ estimatedCostUsd?: number | undefined;
858
+ byModel?: Record<string, {
859
+ inputTokens: number;
860
+ outputTokens: number;
861
+ totalTokens: number;
862
+ cacheReadTokens?: number | undefined;
863
+ cacheWriteTokens?: number | undefined;
864
+ estimatedCostUsd?: number | undefined;
865
+ }> | undefined;
866
+ byOperationType?: Record<string, {
867
+ inputTokens: number;
868
+ outputTokens: number;
869
+ totalTokens: number;
870
+ cacheReadTokens?: number | undefined;
871
+ cacheWriteTokens?: number | undefined;
872
+ estimatedCostUsd?: number | undefined;
873
+ }> | undefined;
874
+ }, {
875
+ inputTokens: number;
876
+ outputTokens: number;
877
+ totalTokens: number;
878
+ operationCount: number;
879
+ cacheReadTokens?: number | undefined;
880
+ cacheWriteTokens?: number | undefined;
881
+ estimatedCostUsd?: number | undefined;
882
+ byModel?: Record<string, {
883
+ inputTokens: number;
884
+ outputTokens: number;
885
+ totalTokens: number;
886
+ cacheReadTokens?: number | undefined;
887
+ cacheWriteTokens?: number | undefined;
888
+ estimatedCostUsd?: number | undefined;
889
+ }> | undefined;
890
+ byOperationType?: Record<string, {
891
+ inputTokens: number;
892
+ outputTokens: number;
893
+ totalTokens: number;
894
+ cacheReadTokens?: number | undefined;
895
+ cacheWriteTokens?: number | undefined;
896
+ estimatedCostUsd?: number | undefined;
897
+ }> | undefined;
898
+ }>;
899
+ metadata: z.ZodObject<{
900
+ createdAt: z.ZodDate;
901
+ updatedAt: z.ZodDate;
902
+ tags: z.ZodArray<z.ZodString, "many">;
903
+ custom: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
904
+ }, "strip", z.ZodTypeAny, {
905
+ tags: string[];
906
+ createdAt: Date;
907
+ updatedAt: Date;
908
+ custom?: Record<string, unknown> | undefined;
909
+ }, {
910
+ tags: string[];
911
+ createdAt: Date;
912
+ updatedAt: Date;
913
+ custom?: Record<string, unknown> | undefined;
914
+ }>;
915
+ }, "strip", z.ZodTypeAny, {
916
+ status: "timeout" | "pending" | "running" | "completed" | "failed" | "cancelled";
917
+ id: string;
918
+ name: string;
919
+ metadata: {
920
+ tags: string[];
921
+ createdAt: Date;
922
+ updatedAt: Date;
923
+ custom?: Record<string, unknown> | undefined;
924
+ };
925
+ startedAt: Date;
926
+ tokenUsage: {
927
+ inputTokens: number;
928
+ outputTokens: number;
929
+ totalTokens: number;
930
+ operationCount: number;
931
+ cacheReadTokens?: number | undefined;
932
+ cacheWriteTokens?: number | undefined;
933
+ estimatedCostUsd?: number | undefined;
934
+ byModel?: Record<string, {
935
+ inputTokens: number;
936
+ outputTokens: number;
937
+ totalTokens: number;
938
+ cacheReadTokens?: number | undefined;
939
+ cacheWriteTokens?: number | undefined;
940
+ estimatedCostUsd?: number | undefined;
941
+ }> | undefined;
942
+ byOperationType?: Record<string, {
943
+ inputTokens: number;
944
+ outputTokens: number;
945
+ totalTokens: number;
946
+ cacheReadTokens?: number | undefined;
947
+ cacheWriteTokens?: number | undefined;
948
+ estimatedCostUsd?: number | undefined;
949
+ }> | undefined;
950
+ };
951
+ conversationIds: string[];
952
+ purpose?: string | undefined;
953
+ endedAt?: Date | undefined;
954
+ swarmIds?: string[] | undefined;
955
+ workflowIds?: string[] | undefined;
956
+ }, {
957
+ status: "timeout" | "pending" | "running" | "completed" | "failed" | "cancelled";
958
+ id: string;
959
+ name: string;
960
+ metadata: {
961
+ tags: string[];
962
+ createdAt: Date;
963
+ updatedAt: Date;
964
+ custom?: Record<string, unknown> | undefined;
965
+ };
966
+ startedAt: Date;
967
+ tokenUsage: {
968
+ inputTokens: number;
969
+ outputTokens: number;
970
+ totalTokens: number;
971
+ operationCount: number;
972
+ cacheReadTokens?: number | undefined;
973
+ cacheWriteTokens?: number | undefined;
974
+ estimatedCostUsd?: number | undefined;
975
+ byModel?: Record<string, {
976
+ inputTokens: number;
977
+ outputTokens: number;
978
+ totalTokens: number;
979
+ cacheReadTokens?: number | undefined;
980
+ cacheWriteTokens?: number | undefined;
981
+ estimatedCostUsd?: number | undefined;
982
+ }> | undefined;
983
+ byOperationType?: Record<string, {
984
+ inputTokens: number;
985
+ outputTokens: number;
986
+ totalTokens: number;
987
+ cacheReadTokens?: number | undefined;
988
+ cacheWriteTokens?: number | undefined;
989
+ estimatedCostUsd?: number | undefined;
990
+ }> | undefined;
991
+ };
992
+ conversationIds: string[];
993
+ purpose?: string | undefined;
994
+ endedAt?: Date | undefined;
995
+ swarmIds?: string[] | undefined;
996
+ workflowIds?: string[] | undefined;
997
+ }>;
998
+ /**
999
+ * Generate a unique session ID
1000
+ */
1001
+ export declare function createSessionId(): SessionId;
1002
+ /**
1003
+ * Generate a unique conversation ID
1004
+ */
1005
+ export declare function createConversationId(): ConversationId;
1006
+ /**
1007
+ * Generate a unique message ID
1008
+ */
1009
+ export declare function createMessageId(): MessageId;
1010
+ /**
1011
+ * Generate a unique tool call ID
1012
+ */
1013
+ export declare function createToolCallId(): ToolCallId;
1014
+ /**
1015
+ * Generate a unique sub-agent ID
1016
+ */
1017
+ export declare function createSubAgentId(): SubAgentId;
1018
+ /**
1019
+ * Generate a unique swarm ID
1020
+ */
1021
+ export declare function createSwarmId(): SwarmId;
1022
+ /**
1023
+ * Generate a unique workflow ID
1024
+ */
1025
+ export declare function createWorkflowId(): WorkflowId;
1026
+ /**
1027
+ * Type guard for ClaudeSession
1028
+ */
1029
+ export declare function isClaudeSession(obj: unknown): obj is ClaudeSession;
1030
+ /**
1031
+ * Type guard for ClaudeConversation
1032
+ */
1033
+ export declare function isClaudeConversation(obj: unknown): obj is ClaudeConversation;
1034
+ /**
1035
+ * Type guard for ClaudeMessage
1036
+ */
1037
+ export declare function isClaudeMessage(obj: unknown): obj is ClaudeMessage;
1038
+ /**
1039
+ * Type guard for ClaudeToolCall
1040
+ */
1041
+ export declare function isClaudeToolCall(obj: unknown): obj is ClaudeToolCall;
1042
+ /**
1043
+ * Type guard for ClaudeSubAgent
1044
+ */
1045
+ export declare function isClaudeSubAgent(obj: unknown): obj is ClaudeSubAgent;
1046
+ /**
1047
+ * Type guard for ClaudeSwarm
1048
+ */
1049
+ export declare function isClaudeSwarm(obj: unknown): obj is ClaudeSwarm;
1050
+ /**
1051
+ * Type guard for ClaudeWorkflow
1052
+ */
1053
+ export declare function isClaudeWorkflow(obj: unknown): obj is ClaudeWorkflow;
1054
+ //# sourceMappingURL=types.d.ts.map