@nuvin/nuvin-core 1.2.0 → 1.3.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/VERSION +2 -2
- package/dist/index.d.ts +111 -24
- package/dist/index.js +796 -519
- package/package.json +1 -1
package/dist/VERSION
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -341,6 +341,10 @@ interface LLMPort {
|
|
|
341
341
|
}, signal?: AbortSignal): Promise<CompletionResult>;
|
|
342
342
|
getModels?(signal?: AbortSignal): Promise<Array<{
|
|
343
343
|
id: string;
|
|
344
|
+
limits?: {
|
|
345
|
+
contextWindow: number;
|
|
346
|
+
maxOutput?: number;
|
|
347
|
+
};
|
|
344
348
|
[key: string]: unknown;
|
|
345
349
|
}>>;
|
|
346
350
|
}
|
|
@@ -440,6 +444,33 @@ interface Clock {
|
|
|
440
444
|
interface CostCalculator {
|
|
441
445
|
estimate(model: string, usage?: UsageData): number | undefined;
|
|
442
446
|
}
|
|
447
|
+
type MetricsSnapshot = {
|
|
448
|
+
totalTokens: number;
|
|
449
|
+
totalPromptTokens: number;
|
|
450
|
+
totalCompletionTokens: number;
|
|
451
|
+
totalCachedTokens: number;
|
|
452
|
+
totalReasoningTokens: number;
|
|
453
|
+
requestCount: number;
|
|
454
|
+
llmCallCount: number;
|
|
455
|
+
toolCallCount: number;
|
|
456
|
+
totalTimeMs: number;
|
|
457
|
+
totalCost: number;
|
|
458
|
+
currentTokens: number;
|
|
459
|
+
currentPromptTokens: number;
|
|
460
|
+
currentCompletionTokens: number;
|
|
461
|
+
currentCachedTokens: number;
|
|
462
|
+
currentCost: number;
|
|
463
|
+
contextWindowLimit?: number;
|
|
464
|
+
contextWindowUsage?: number;
|
|
465
|
+
};
|
|
466
|
+
interface MetricsPort {
|
|
467
|
+
recordLLMCall(usage: UsageData, cost?: number): void;
|
|
468
|
+
recordToolCall(): void;
|
|
469
|
+
recordRequestComplete(responseTimeMs: number): void;
|
|
470
|
+
setContextWindow(limit: number, usage: number): void;
|
|
471
|
+
reset(): void;
|
|
472
|
+
getSnapshot(): MetricsSnapshot;
|
|
473
|
+
}
|
|
443
474
|
type AgentConfig = {
|
|
444
475
|
id: string;
|
|
445
476
|
systemPrompt: string;
|
|
@@ -583,17 +614,27 @@ interface EventPort {
|
|
|
583
614
|
|
|
584
615
|
declare class AgentOrchestrator {
|
|
585
616
|
private cfg;
|
|
586
|
-
private deps;
|
|
587
617
|
private pendingApprovals;
|
|
618
|
+
private context;
|
|
619
|
+
private ids;
|
|
620
|
+
private clock;
|
|
621
|
+
private cost;
|
|
622
|
+
private reminders;
|
|
623
|
+
private metrics;
|
|
624
|
+
private events?;
|
|
625
|
+
private llm?;
|
|
626
|
+
private tools;
|
|
627
|
+
private memory;
|
|
588
628
|
constructor(cfg: AgentConfig, deps: {
|
|
589
629
|
memory: MemoryPort<Message>;
|
|
590
|
-
llm: LLMPort;
|
|
591
630
|
tools: ToolPort;
|
|
592
|
-
context
|
|
593
|
-
ids
|
|
594
|
-
clock
|
|
595
|
-
cost
|
|
596
|
-
reminders
|
|
631
|
+
context?: ContextBuilder;
|
|
632
|
+
ids?: IdGenerator$1;
|
|
633
|
+
clock?: Clock;
|
|
634
|
+
cost?: CostCalculator;
|
|
635
|
+
reminders?: RemindersPort;
|
|
636
|
+
llm?: LLMPort;
|
|
637
|
+
metrics?: MetricsPort;
|
|
597
638
|
events?: EventPort;
|
|
598
639
|
});
|
|
599
640
|
/**
|
|
@@ -618,7 +659,7 @@ declare class AgentOrchestrator {
|
|
|
618
659
|
/**
|
|
619
660
|
* Gets the current LLM port.
|
|
620
661
|
*/
|
|
621
|
-
getLLM(): LLMPort;
|
|
662
|
+
getLLM(): LLMPort | undefined;
|
|
622
663
|
/**
|
|
623
664
|
* Gets the current agent configuration.
|
|
624
665
|
*/
|
|
@@ -634,6 +675,14 @@ declare class AgentOrchestrator {
|
|
|
634
675
|
* This is useful when switching to a new session with a different event log file.
|
|
635
676
|
*/
|
|
636
677
|
setEvents(newEvents: EventPort): void;
|
|
678
|
+
/**
|
|
679
|
+
* Updates the metrics port without reinitializing the entire orchestrator.
|
|
680
|
+
*/
|
|
681
|
+
setMetrics(newMetrics: MetricsPort): void;
|
|
682
|
+
/**
|
|
683
|
+
* Gets the current metrics port.
|
|
684
|
+
*/
|
|
685
|
+
getMetrics(): MetricsPort | undefined;
|
|
637
686
|
/**
|
|
638
687
|
* Determines if a tool should bypass approval requirements.
|
|
639
688
|
* Read-only tools and todo management tools are auto-approved.
|
|
@@ -780,6 +829,10 @@ type ConversationMetadata = {
|
|
|
780
829
|
promptTokens?: number;
|
|
781
830
|
completionTokens?: number;
|
|
782
831
|
contextWindow?: TokenUsage;
|
|
832
|
+
requestCount?: number;
|
|
833
|
+
toolCallCount?: number;
|
|
834
|
+
totalTimeMs?: number;
|
|
835
|
+
totalPrice?: number;
|
|
783
836
|
};
|
|
784
837
|
type Conversation = {
|
|
785
838
|
messages: Message[];
|
|
@@ -795,6 +848,14 @@ declare class ConversationStore {
|
|
|
795
848
|
appendMessages(conversationId: string, messages: Message[]): Promise<void>;
|
|
796
849
|
updateMetadata(conversationId: string, updates: Partial<ConversationMetadata>): Promise<void>;
|
|
797
850
|
incrementTokens(conversationId: string, tokenUsage: TokenUsage): Promise<void>;
|
|
851
|
+
recordRequestMetrics(conversationId: string, metrics: {
|
|
852
|
+
promptTokens?: number;
|
|
853
|
+
completionTokens?: number;
|
|
854
|
+
totalTokens?: number;
|
|
855
|
+
toolCalls?: number;
|
|
856
|
+
responseTimeMs?: number;
|
|
857
|
+
cost?: number;
|
|
858
|
+
}): Promise<ConversationMetadata>;
|
|
798
859
|
updateTopic(conversationId: string, topic: string): Promise<void>;
|
|
799
860
|
deleteConversation(conversationId: string): Promise<void>;
|
|
800
861
|
listConversations(): Promise<{
|
|
@@ -813,6 +874,30 @@ declare class ConversationContext {
|
|
|
813
874
|
private slugify;
|
|
814
875
|
}
|
|
815
876
|
|
|
877
|
+
declare const createEmptySnapshot: () => MetricsSnapshot;
|
|
878
|
+
declare class NoopMetricsPort implements MetricsPort {
|
|
879
|
+
recordLLMCall(_usage: UsageData, _cost?: number): void;
|
|
880
|
+
recordToolCall(): void;
|
|
881
|
+
recordRequestComplete(_responseTimeMs: number): void;
|
|
882
|
+
setContextWindow(_limit: number, _usage: number): void;
|
|
883
|
+
reset(): void;
|
|
884
|
+
getSnapshot(): MetricsSnapshot;
|
|
885
|
+
}
|
|
886
|
+
type MetricsChangeHandler = (snapshot: MetricsSnapshot) => void;
|
|
887
|
+
declare class InMemoryMetricsPort implements MetricsPort {
|
|
888
|
+
private snapshot;
|
|
889
|
+
private onChange?;
|
|
890
|
+
constructor(onChange?: MetricsChangeHandler);
|
|
891
|
+
private emit;
|
|
892
|
+
recordLLMCall(usage: UsageData, cost?: number): void;
|
|
893
|
+
recordToolCall(): void;
|
|
894
|
+
recordRequestComplete(responseTimeMs: number): void;
|
|
895
|
+
setContextWindow(limit: number, usage: number): void;
|
|
896
|
+
reset(): void;
|
|
897
|
+
getSnapshot(): MetricsSnapshot;
|
|
898
|
+
setOnChange(fn: MetricsChangeHandler): void;
|
|
899
|
+
}
|
|
900
|
+
|
|
816
901
|
declare class SimpleId implements IdGenerator$1 {
|
|
817
902
|
uuid(): string;
|
|
818
903
|
}
|
|
@@ -1192,31 +1277,32 @@ declare abstract class BaseLLM implements LLMPort {
|
|
|
1192
1277
|
}, signal?: AbortSignal): Promise<CompletionResult>;
|
|
1193
1278
|
}
|
|
1194
1279
|
|
|
1280
|
+
type ModelLimits = {
|
|
1281
|
+
contextWindow: number;
|
|
1282
|
+
maxOutput?: number;
|
|
1283
|
+
};
|
|
1284
|
+
type ModelInfo = {
|
|
1285
|
+
id: string;
|
|
1286
|
+
name?: string;
|
|
1287
|
+
limits?: ModelLimits;
|
|
1288
|
+
[key: string]: unknown;
|
|
1289
|
+
};
|
|
1290
|
+
type RawModelResponse = Record<string, unknown>;
|
|
1291
|
+
declare function normalizeModelLimits(provider: string, model: RawModelResponse): ModelLimits | null;
|
|
1292
|
+
declare function getFallbackLimits(provider: string, model: string): ModelLimits | null;
|
|
1293
|
+
declare function normalizeModelInfo(provider: string, model: RawModelResponse): ModelInfo;
|
|
1294
|
+
|
|
1195
1295
|
type GithubOptions = {
|
|
1196
1296
|
apiKey?: string;
|
|
1197
1297
|
accessToken?: string;
|
|
1198
1298
|
apiUrl?: string;
|
|
1199
1299
|
httpLogFile?: string;
|
|
1200
1300
|
};
|
|
1201
|
-
type GithubModel = {
|
|
1202
|
-
id: string;
|
|
1203
|
-
name: string;
|
|
1204
|
-
capable_endpoints?: string[];
|
|
1205
|
-
supported_endpoints?: string[];
|
|
1206
|
-
capabilities: {
|
|
1207
|
-
family: string;
|
|
1208
|
-
type: string;
|
|
1209
|
-
limits?: {
|
|
1210
|
-
max_context_window_tokens?: number;
|
|
1211
|
-
max_output_tokens?: number;
|
|
1212
|
-
};
|
|
1213
|
-
};
|
|
1214
|
-
};
|
|
1215
1301
|
declare class GithubLLM extends BaseLLM implements LLMPort {
|
|
1216
1302
|
private readonly opts;
|
|
1217
1303
|
constructor(opts?: GithubOptions);
|
|
1218
1304
|
protected createTransport(): GithubAuthTransport;
|
|
1219
|
-
getModels(signal?: AbortSignal): Promise<
|
|
1305
|
+
getModels(signal?: AbortSignal): Promise<ModelInfo[]>;
|
|
1220
1306
|
private handleError;
|
|
1221
1307
|
generateCompletion(params: CompletionParams, signal?: AbortSignal): Promise<CompletionResult>;
|
|
1222
1308
|
streamCompletion(params: CompletionParams, handlers?: {
|
|
@@ -1278,6 +1364,7 @@ interface LLMOptions {
|
|
|
1278
1364
|
enablePromptCaching?: boolean;
|
|
1279
1365
|
includeUsage?: boolean;
|
|
1280
1366
|
version?: string;
|
|
1367
|
+
providerName?: string;
|
|
1281
1368
|
}
|
|
1282
1369
|
interface CustomProviderDefinition {
|
|
1283
1370
|
type?: 'openai-compat' | 'anthropic';
|
|
@@ -1378,4 +1465,4 @@ declare function resolveBackspaces(s: string): string;
|
|
|
1378
1465
|
declare function stripAnsiAndControls(s: string): string;
|
|
1379
1466
|
declare function canonicalizeTerminalPaste(raw: string): string;
|
|
1380
1467
|
|
|
1381
|
-
export { AGENT_CREATOR_SYSTEM_PROMPT, type AgentAwareToolPort, type AgentCatalog, type AgentConfig, type AgentEvent, AgentEventTypes, AgentFilePersistence, AgentManager, AgentManagerCommandRunner, AgentOrchestrator, AgentRegistry, type AgentTemplate, AnthropicAISDKLLM, type AssignParams, BashTool, type CompleteAgent, CompositeToolPort, type Conversation, ConversationContext, type ConversationMetadata, type ConversationSnapshot, ConversationStore, CoreMCPClient, DefaultDelegationPolicy, DefaultDelegationResultFormatter, DefaultDelegationService, DefaultSpecialistAgentFactory, type DelegationService, type DelegationServiceConfig, DelegationServiceFactory, ErrorReason, type FolderTreeOptions, GithubLLM, InMemoryMemory, InMemoryMetadata, JsonFileMemoryPersistence, type LLMConfig, LLMError, type LLMFactory, type LLMOptions, type LLMPort, LLMResolver, type MCPConfig, type MCPServerConfig, MCPToolPort, type MemoryPort, MemoryPortMetadataAdapter, type Message, type MessageContent, type MessageContentPart, type MetadataPort, NoopReminders, type OrchestratorAwareToolPort, PersistedMemory, PersistingConsoleEventPort, RuntimeEnv, type SendMessageOptions, SimpleContextBuilder, SimpleCost, SimpleId, type SpecialistAgentConfig, type SpecialistAgentResult, SystemClock, type ToolApprovalDecision, type ToolCall, type ToolExecutionResult, type ToolPort, ToolRegistry, type UserAttachment, type UserMessagePayload, buildAgentCreationPrompt, buildInjectedSystem, canonicalizeTerminalPaste, createLLM, generateFolderTree, getAvailableProviders, loadMCPConfig, normalizeNewlines, renderTemplate, resolveBackspaces, resolveCarriageReturns, stripAnsiAndControls, supportsGetModels };
|
|
1468
|
+
export { AGENT_CREATOR_SYSTEM_PROMPT, type AgentAwareToolPort, type AgentCatalog, type AgentConfig, type AgentEvent, AgentEventTypes, AgentFilePersistence, AgentManager, AgentManagerCommandRunner, AgentOrchestrator, AgentRegistry, type AgentTemplate, AnthropicAISDKLLM, type AssignParams, BashTool, type CompleteAgent, CompositeToolPort, type Conversation, ConversationContext, type ConversationMetadata, type ConversationSnapshot, ConversationStore, CoreMCPClient, DefaultDelegationPolicy, DefaultDelegationResultFormatter, DefaultDelegationService, DefaultSpecialistAgentFactory, type DelegationService, type DelegationServiceConfig, DelegationServiceFactory, ErrorReason, type FolderTreeOptions, GithubLLM, InMemoryMemory, InMemoryMetadata, InMemoryMetricsPort, JsonFileMemoryPersistence, type LLMConfig, LLMError, type LLMFactory, type LLMOptions, type LLMPort, LLMResolver, type MCPConfig, type MCPServerConfig, MCPToolPort, type MemoryPort, MemoryPortMetadataAdapter, type Message, type MessageContent, type MessageContentPart, type MetadataPort, type MetricsChangeHandler, type MetricsPort, type MetricsSnapshot, type ModelInfo, type ModelLimits, NoopMetricsPort, NoopReminders, type OrchestratorAwareToolPort, PersistedMemory, PersistingConsoleEventPort, RuntimeEnv, type SendMessageOptions, SimpleContextBuilder, SimpleCost, SimpleId, type SpecialistAgentConfig, type SpecialistAgentResult, SystemClock, type ToolApprovalDecision, type ToolCall, type ToolExecutionResult, type ToolPort, ToolRegistry, type UsageData, type UserAttachment, type UserMessagePayload, buildAgentCreationPrompt, buildInjectedSystem, canonicalizeTerminalPaste, createEmptySnapshot, createLLM, generateFolderTree, getAvailableProviders, getFallbackLimits, loadMCPConfig, normalizeModelInfo, normalizeModelLimits, normalizeNewlines, renderTemplate, resolveBackspaces, resolveCarriageReturns, stripAnsiAndControls, supportsGetModels };
|