@nuvin/nuvin-core 1.6.2 → 1.7.1
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 +9 -3
- package/dist/index.js +43 -10
- package/package.json +1 -1
package/dist/VERSION
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ type AgentTemplate = {
|
|
|
17
17
|
topP?: number;
|
|
18
18
|
timeoutMs?: number;
|
|
19
19
|
shareContext?: boolean;
|
|
20
|
+
stream?: boolean;
|
|
20
21
|
metadata?: Record<string, unknown>;
|
|
21
22
|
};
|
|
22
23
|
/**
|
|
@@ -40,6 +41,7 @@ type SpecialistAgentConfig = {
|
|
|
40
41
|
topP?: number;
|
|
41
42
|
timeoutMs?: number;
|
|
42
43
|
shareContext?: boolean;
|
|
44
|
+
stream?: boolean;
|
|
43
45
|
delegatingMemory?: Message[];
|
|
44
46
|
delegationDepth: number;
|
|
45
47
|
conversationId?: string;
|
|
@@ -1691,6 +1693,7 @@ type FileNewSuccessResult$1 = {
|
|
|
1691
1693
|
metadata: {
|
|
1692
1694
|
file_path: string;
|
|
1693
1695
|
bytes: number;
|
|
1696
|
+
lines: number;
|
|
1694
1697
|
created: string;
|
|
1695
1698
|
overwritten?: boolean;
|
|
1696
1699
|
};
|
|
@@ -2056,12 +2059,15 @@ type ModelInfo = {
|
|
|
2056
2059
|
id: string;
|
|
2057
2060
|
name?: string;
|
|
2058
2061
|
limits?: ModelLimits;
|
|
2059
|
-
[key: string]: unknown;
|
|
2062
|
+
[key: string]: string | number | ModelLimits | undefined | unknown;
|
|
2063
|
+
};
|
|
2064
|
+
type RawModelResponse = {
|
|
2065
|
+
[key: string]: string | number | undefined | unknown;
|
|
2060
2066
|
};
|
|
2061
|
-
type RawModelResponse = Record<string, unknown>;
|
|
2062
2067
|
declare function normalizeModelLimits(provider: string, model: RawModelResponse): ModelLimits | null;
|
|
2063
2068
|
declare function getFallbackLimits(provider: string, model: string): ModelLimits | null;
|
|
2064
2069
|
declare function normalizeModelInfo(provider: string, model: RawModelResponse): ModelInfo;
|
|
2070
|
+
declare function deduplicateModels(models: ModelInfo[]): ModelInfo[];
|
|
2065
2071
|
|
|
2066
2072
|
type GithubOptions = {
|
|
2067
2073
|
apiKey?: string;
|
|
@@ -2243,4 +2249,4 @@ declare function resolveBackspaces(s: string): string;
|
|
|
2243
2249
|
declare function stripAnsiAndControls(s: string): string;
|
|
2244
2250
|
declare function canonicalizeTerminalPaste(raw: string): string;
|
|
2245
2251
|
|
|
2246
|
-
export { AGENT_CREATOR_SYSTEM_PROMPT, AbortError, type AgentAwareToolPort, type AgentCatalog, type AgentConfig, type AgentEvent, AgentEventTypes, AgentFilePersistence, AgentManager, AgentManagerCommandRunner, AgentOrchestrator, AgentRegistry, type AgentTemplate, AnthropicAISDKLLM, type AssignErrorResult, type AssignParams, type AssignResult, type AssignSuccessResult$1 as AssignSuccessResult, type AssignTaskArgs, type AssignTaskMetadata, type BaseLLMOptions, type BashErrorResult, type BashParams, type BashResult, type BashSuccessResult$1 as BashSuccessResult, BashTool, type BashToolArgs, type BashToolMetadata, type CommandMetadata, type CompleteAgent, CompositeToolPort, type Conversation, ConversationContext, type ConversationMetadata, type ConversationSnapshot, ConversationStore, CoreMCPClient, DEFAULT_RETRY_CONFIG, DefaultDelegationPolicy, DefaultDelegationResultFormatter, DefaultDelegationService, DefaultSpecialistAgentFactory, type DelegationMetadata, type DelegationService, type DelegationServiceConfig, DelegationServiceFactory, type DirEntry, type DirLsArgs, type DirLsMetadata, type DirLsParams, type DirLsResult, type DirLsSuccessResult$1 as DirLsSuccessResult, type ErrorMetadata, ErrorReason, type ExecResult, type ExecResultError, type ExecResultSuccess, type FileEditArgs, type FileEditMetadata, type FileEditResult, type FileEditSuccessResult$1 as FileEditSuccessResult, type FileMetadata, type FileNewArgs, type FileNewMetadata, type FileNewParams, type FileNewResult, type FileNewSuccessResult$1 as FileNewSuccessResult, type FileReadArgs, type FileReadErrorResult, type FileReadMetadata, type FileReadParams, type FileReadResult, type FileReadSuccessResult$1 as FileReadSuccessResult, type FolderTreeOptions, type FunctionTool, GithubLLM, InMemoryMemory, InMemoryMetadata, InMemoryMetricsPort, JsonFileMemoryPersistence, type LLMConfig, LLMError, type LLMFactory, type LLMOptions, type LLMPort, LLMResolver, type LineRangeMetadata, 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, type ParseResult, PersistedMemory, PersistingConsoleEventPort, type RetryConfig, RetryTransport, RuntimeEnv, type SendMessageOptions, SimpleContextBuilder, SimpleCost, SimpleId, type SpecialistAgentConfig, type SpecialistAgentResult, type SubAgentState, type SubAgentToolCall, SystemClock, type TodoWriteArgs, type TodoWriteMetadata, type TodoWriteResult, type TodoWriteSuccessResult$1 as TodoWriteSuccessResult, type ToolApprovalDecision, type ToolArguments, type ToolCall, type ToolCallValidation, type ToolErrorMetadata, type ToolExecutionContext, type ToolExecutionResult, type ToolMetadataMap, type ToolName, type ToolParameterMap, type ToolPort, ToolRegistry, type ToolValidator, type TypedToolInvocation, type UsageData, type UserAttachment, type UserMessagePayload, type ValidationResult, type WebFetchArgs, type WebFetchMetadata, type WebFetchParams, type WebFetchResult, type WebFetchSuccessResult$1 as WebFetchSuccessResult, type WebSearchArgs, type WebSearchMetadata, type WebSearchParams, type WebSearchResult, type WebSearchSuccessResult$1 as WebSearchSuccessResult, type WebSearchToolResult, buildAgentCreationPrompt, buildInjectedSystem, canonicalizeTerminalPaste, convertToolCall, convertToolCalls, createEmptySnapshot, createLLM, err, generateFolderTree, getAvailableProviders, getFallbackLimits, getProviderLabel, isAssignResult, isAssignSuccess, isAssignTaskArgs, isBashResult, isBashSuccess, isBashToolArgs, isDirLsArgs, isDirLsResult, isDirLsSuccess, isError, isFileEditArgs, isFileEditResult, isFileEditSuccess, isFileNewArgs, isFileNewResult, isFileNewSuccess, isFileReadArgs, isFileReadResult, isFileReadSuccess, isJsonResult, isRetryableError, isRetryableStatusCode, isSuccess, isSuccessJson, isSuccessText, isTextResult, isTodoWriteArgs, isTodoWriteResult, isTodoWriteSuccess, isWebFetchArgs, isWebFetchResult, isWebFetchSuccess, isWebSearchArgs, isWebSearchResult, isWebSearchSuccess, loadMCPConfig, normalizeModelInfo, normalizeModelLimits, normalizeNewlines, okJson, okText, parseJSON, parseSubAgentToolCallArguments, parseToolArguments, renderTemplate, resolveBackspaces, resolveCarriageReturns, stripAnsiAndControls, supportsGetModels, toolValidators };
|
|
2252
|
+
export { AGENT_CREATOR_SYSTEM_PROMPT, AbortError, type AgentAwareToolPort, type AgentCatalog, type AgentConfig, type AgentEvent, AgentEventTypes, AgentFilePersistence, AgentManager, AgentManagerCommandRunner, AgentOrchestrator, AgentRegistry, type AgentTemplate, AnthropicAISDKLLM, type AssignErrorResult, type AssignParams, type AssignResult, type AssignSuccessResult$1 as AssignSuccessResult, type AssignTaskArgs, type AssignTaskMetadata, type BaseLLMOptions, type BashErrorResult, type BashParams, type BashResult, type BashSuccessResult$1 as BashSuccessResult, BashTool, type BashToolArgs, type BashToolMetadata, type CommandMetadata, type CompleteAgent, CompositeToolPort, type Conversation, ConversationContext, type ConversationMetadata, type ConversationSnapshot, ConversationStore, CoreMCPClient, DEFAULT_RETRY_CONFIG, DefaultDelegationPolicy, DefaultDelegationResultFormatter, DefaultDelegationService, DefaultSpecialistAgentFactory, type DelegationMetadata, type DelegationService, type DelegationServiceConfig, DelegationServiceFactory, type DirEntry, type DirLsArgs, type DirLsMetadata, type DirLsParams, type DirLsResult, type DirLsSuccessResult$1 as DirLsSuccessResult, type ErrorMetadata, ErrorReason, type ExecResult, type ExecResultError, type ExecResultSuccess, type FileEditArgs, type FileEditMetadata, type FileEditResult, type FileEditSuccessResult$1 as FileEditSuccessResult, type FileMetadata, type FileNewArgs, type FileNewMetadata, type FileNewParams, type FileNewResult, type FileNewSuccessResult$1 as FileNewSuccessResult, type FileReadArgs, type FileReadErrorResult, type FileReadMetadata, type FileReadParams, type FileReadResult, type FileReadSuccessResult$1 as FileReadSuccessResult, type FolderTreeOptions, type FunctionTool, GithubLLM, InMemoryMemory, InMemoryMetadata, InMemoryMetricsPort, JsonFileMemoryPersistence, type LLMConfig, LLMError, type LLMFactory, type LLMOptions, type LLMPort, LLMResolver, type LineRangeMetadata, 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, type ParseResult, PersistedMemory, PersistingConsoleEventPort, type RetryConfig, RetryTransport, RuntimeEnv, type SendMessageOptions, SimpleContextBuilder, SimpleCost, SimpleId, type SpecialistAgentConfig, type SpecialistAgentResult, type SubAgentState, type SubAgentToolCall, SystemClock, type TodoWriteArgs, type TodoWriteMetadata, type TodoWriteResult, type TodoWriteSuccessResult$1 as TodoWriteSuccessResult, type ToolApprovalDecision, type ToolArguments, type ToolCall, type ToolCallValidation, type ToolErrorMetadata, type ToolExecutionContext, type ToolExecutionResult, type ToolMetadataMap, type ToolName, type ToolParameterMap, type ToolPort, ToolRegistry, type ToolValidator, type TypedToolInvocation, type UsageData, type UserAttachment, type UserMessagePayload, type ValidationResult, type WebFetchArgs, type WebFetchMetadata, type WebFetchParams, type WebFetchResult, type WebFetchSuccessResult$1 as WebFetchSuccessResult, type WebSearchArgs, type WebSearchMetadata, type WebSearchParams, type WebSearchResult, type WebSearchSuccessResult$1 as WebSearchSuccessResult, type WebSearchToolResult, buildAgentCreationPrompt, buildInjectedSystem, canonicalizeTerminalPaste, convertToolCall, convertToolCalls, createEmptySnapshot, createLLM, deduplicateModels, err, generateFolderTree, getAvailableProviders, getFallbackLimits, getProviderLabel, isAssignResult, isAssignSuccess, isAssignTaskArgs, isBashResult, isBashSuccess, isBashToolArgs, isDirLsArgs, isDirLsResult, isDirLsSuccess, isError, isFileEditArgs, isFileEditResult, isFileEditSuccess, isFileNewArgs, isFileNewResult, isFileNewSuccess, isFileReadArgs, isFileReadResult, isFileReadSuccess, isJsonResult, isRetryableError, isRetryableStatusCode, isSuccess, isSuccessJson, isSuccessText, isTextResult, isTodoWriteArgs, isTodoWriteResult, isTodoWriteSuccess, isWebFetchArgs, isWebFetchResult, isWebFetchSuccess, isWebSearchArgs, isWebSearchResult, isWebSearchSuccess, loadMCPConfig, normalizeModelInfo, normalizeModelLimits, normalizeNewlines, okJson, okText, parseJSON, parseSubAgentToolCallArguments, parseToolArguments, renderTemplate, resolveBackspaces, resolveCarriageReturns, stripAnsiAndControls, supportsGetModels, toolValidators };
|
package/dist/index.js
CHANGED
|
@@ -964,6 +964,20 @@ var AgentOrchestrator = class {
|
|
|
964
964
|
};
|
|
965
965
|
turnHistory.push(toolMsg);
|
|
966
966
|
toolResultMsgs.push(toolMsg);
|
|
967
|
+
await this.events?.emit({
|
|
968
|
+
type: AgentEventTypes.ToolResult,
|
|
969
|
+
conversationId,
|
|
970
|
+
messageId,
|
|
971
|
+
result: {
|
|
972
|
+
id: toolCall.id,
|
|
973
|
+
name: toolCall.function.name,
|
|
974
|
+
status: "error",
|
|
975
|
+
type: "text",
|
|
976
|
+
result: toolDenialResult,
|
|
977
|
+
durationMs: 0,
|
|
978
|
+
metadata: { errorReason: "denied" /* Denied */ }
|
|
979
|
+
}
|
|
980
|
+
});
|
|
967
981
|
}
|
|
968
982
|
await this.memory.append(conversationId, [assistantMsg, ...toolResultMsgs]);
|
|
969
983
|
await this.events?.emit({
|
|
@@ -2651,10 +2665,12 @@ var FileNewTool = class {
|
|
|
2651
2665
|
const existsBefore = await fs4.stat(abs).then(() => true).catch(() => false);
|
|
2652
2666
|
await fs4.mkdir(path4.dirname(abs), { recursive: true });
|
|
2653
2667
|
const bytes = Buffer.from(p.content, "utf8");
|
|
2668
|
+
const lines = p.content.split(/\r?\n/).length;
|
|
2654
2669
|
await this.writeAtomic(abs, bytes);
|
|
2655
2670
|
return okText(`File written at ${p.file_path}.`, {
|
|
2656
2671
|
file_path: p.file_path,
|
|
2657
2672
|
bytes: bytes.length,
|
|
2673
|
+
lines,
|
|
2658
2674
|
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2659
2675
|
overwritten: existsBefore
|
|
2660
2676
|
});
|
|
@@ -3674,6 +3690,7 @@ var DefaultSpecialistAgentFactory = class {
|
|
|
3674
3690
|
topP: template.topP,
|
|
3675
3691
|
timeoutMs: template.timeoutMs,
|
|
3676
3692
|
shareContext: template.shareContext ?? false,
|
|
3693
|
+
stream: template.stream ?? true,
|
|
3677
3694
|
delegatingMemory: void 0,
|
|
3678
3695
|
// TODO: provide delegating memory when available
|
|
3679
3696
|
delegationDepth: input.currentDepth + 1,
|
|
@@ -3830,7 +3847,7 @@ var AgentManager = class {
|
|
|
3830
3847
|
this.activeAgents.set(agentId, specialistOrchestrator);
|
|
3831
3848
|
try {
|
|
3832
3849
|
const timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
3833
|
-
const response = await this.executeWithTimeout(specialistOrchestrator, config.taskDescription, timeoutMs, signal);
|
|
3850
|
+
const response = await this.executeWithTimeout(specialistOrchestrator, config.taskDescription, timeoutMs, signal, config.stream);
|
|
3834
3851
|
const executionTimeMs = Date.now() - startTime;
|
|
3835
3852
|
const conversationHistory = await memory.get("default");
|
|
3836
3853
|
const toolCallsExecuted = events.filter((e) => e.type === "tool_calls").length;
|
|
@@ -3912,7 +3929,7 @@ var AgentManager = class {
|
|
|
3912
3929
|
/**
|
|
3913
3930
|
* Execute agent task with timeout
|
|
3914
3931
|
*/
|
|
3915
|
-
async executeWithTimeout(orchestrator, taskDescription, timeoutMs, signal) {
|
|
3932
|
+
async executeWithTimeout(orchestrator, taskDescription, timeoutMs, signal, stream) {
|
|
3916
3933
|
const timeoutController = new AbortController();
|
|
3917
3934
|
const combinedSignal = signal ? AbortSignal.any([signal, timeoutController.signal]) : timeoutController.signal;
|
|
3918
3935
|
let timer;
|
|
@@ -3920,7 +3937,8 @@ var AgentManager = class {
|
|
|
3920
3937
|
return await Promise.race([
|
|
3921
3938
|
orchestrator.send(taskDescription, {
|
|
3922
3939
|
conversationId: "default",
|
|
3923
|
-
signal: combinedSignal
|
|
3940
|
+
signal: combinedSignal,
|
|
3941
|
+
stream
|
|
3924
3942
|
}),
|
|
3925
3943
|
new Promise((_, reject) => {
|
|
3926
3944
|
if (signal?.aborted) {
|
|
@@ -4725,9 +4743,9 @@ var BaseLLM = class {
|
|
|
4725
4743
|
model: enhancedParams.model,
|
|
4726
4744
|
messages: enhancedParams.messages,
|
|
4727
4745
|
temperature: enhancedParams.temperature,
|
|
4728
|
-
max_tokens: enhancedParams.maxTokens,
|
|
4729
4746
|
top_p: enhancedParams.topP,
|
|
4730
4747
|
stream: false,
|
|
4748
|
+
...enhancedParams.maxTokens !== void 0 && { max_tokens: enhancedParams.maxTokens },
|
|
4731
4749
|
...enhancedParams.reasoning && { reasoning: enhancedParams.reasoning },
|
|
4732
4750
|
...enhancedParams.usage && { usage: enhancedParams.usage }
|
|
4733
4751
|
};
|
|
@@ -4751,9 +4769,9 @@ var BaseLLM = class {
|
|
|
4751
4769
|
model: enhancedParams.model,
|
|
4752
4770
|
messages: enhancedParams.messages,
|
|
4753
4771
|
temperature: enhancedParams.temperature,
|
|
4754
|
-
max_tokens: enhancedParams.maxTokens,
|
|
4755
4772
|
top_p: enhancedParams.topP,
|
|
4756
4773
|
stream: true,
|
|
4774
|
+
...enhancedParams.maxTokens !== void 0 && { max_tokens: enhancedParams.maxTokens },
|
|
4757
4775
|
...enhancedParams.reasoning && { reasoning: enhancedParams.reasoning },
|
|
4758
4776
|
...enhancedParams.usage && { usage: enhancedParams.usage }
|
|
4759
4777
|
};
|
|
@@ -5790,6 +5808,15 @@ function normalizeModelInfo(provider, model) {
|
|
|
5790
5808
|
...limits ? { limits } : {}
|
|
5791
5809
|
};
|
|
5792
5810
|
}
|
|
5811
|
+
function deduplicateModels(models) {
|
|
5812
|
+
const uniqueModels = /* @__PURE__ */ new Map();
|
|
5813
|
+
for (const model of models) {
|
|
5814
|
+
if (!uniqueModels.has(model.id)) {
|
|
5815
|
+
uniqueModels.set(model.id, model);
|
|
5816
|
+
}
|
|
5817
|
+
}
|
|
5818
|
+
return Array.from(uniqueModels.values());
|
|
5819
|
+
}
|
|
5793
5820
|
|
|
5794
5821
|
// src/llm-providers/llm-github.ts
|
|
5795
5822
|
var GithubLLM = class extends BaseLLM {
|
|
@@ -5834,7 +5861,8 @@ var GithubLLM = class extends BaseLLM {
|
|
|
5834
5861
|
throw new LLMError(text || `Failed to fetch models: ${res.status}`, res.status);
|
|
5835
5862
|
}
|
|
5836
5863
|
const body = await res.json();
|
|
5837
|
-
|
|
5864
|
+
const models = body.data.map((m) => normalizeModelInfo("github", m));
|
|
5865
|
+
return deduplicateModels(models);
|
|
5838
5866
|
}
|
|
5839
5867
|
handleError(error, model) {
|
|
5840
5868
|
if (error instanceof LLMError) {
|
|
@@ -6271,7 +6299,8 @@ var AnthropicAISDKLLM = class {
|
|
|
6271
6299
|
throw new LLMError(text || `Failed to fetch models: ${res.status}`, res.status);
|
|
6272
6300
|
}
|
|
6273
6301
|
const data = await res.json();
|
|
6274
|
-
|
|
6302
|
+
const models = data.data.map((model) => normalizeModelInfo("anthropic", model));
|
|
6303
|
+
return deduplicateModels(models);
|
|
6275
6304
|
} catch (error) {
|
|
6276
6305
|
if (error instanceof LLMError) {
|
|
6277
6306
|
throw error;
|
|
@@ -6381,10 +6410,11 @@ var GenericLLM = class extends BaseLLM {
|
|
|
6381
6410
|
throw new Error("Provider does not support getModels");
|
|
6382
6411
|
}
|
|
6383
6412
|
if (Array.isArray(this.modelConfig)) {
|
|
6384
|
-
|
|
6413
|
+
const models2 = this.modelConfig.map((m) => {
|
|
6385
6414
|
const raw = typeof m === "string" ? { id: m } : m;
|
|
6386
6415
|
return normalizeModelInfo(this.providerName, raw);
|
|
6387
6416
|
});
|
|
6417
|
+
return deduplicateModels(models2);
|
|
6388
6418
|
}
|
|
6389
6419
|
if (typeof this.modelConfig === "string") {
|
|
6390
6420
|
const transport2 = this.createTransport();
|
|
@@ -6394,7 +6424,8 @@ var GenericLLM = class extends BaseLLM {
|
|
|
6394
6424
|
throw new Error(`Failed to fetch models: ${res2.status} ${text}`);
|
|
6395
6425
|
}
|
|
6396
6426
|
const data2 = await res2.json();
|
|
6397
|
-
|
|
6427
|
+
const models2 = data2.data.map((m) => normalizeModelInfo(this.providerName, m));
|
|
6428
|
+
return deduplicateModels(models2);
|
|
6398
6429
|
}
|
|
6399
6430
|
const transport = this.createTransport();
|
|
6400
6431
|
const res = await transport.get("/models", void 0, signal);
|
|
@@ -6403,7 +6434,8 @@ var GenericLLM = class extends BaseLLM {
|
|
|
6403
6434
|
throw new Error(`Failed to fetch models: ${res.status} ${text}`);
|
|
6404
6435
|
}
|
|
6405
6436
|
const data = await res.json();
|
|
6406
|
-
|
|
6437
|
+
const models = data.data.map((m) => normalizeModelInfo(this.providerName, m));
|
|
6438
|
+
return deduplicateModels(models);
|
|
6407
6439
|
}
|
|
6408
6440
|
async generateCompletion(params, signal) {
|
|
6409
6441
|
let enhancedParams = params;
|
|
@@ -6812,6 +6844,7 @@ export {
|
|
|
6812
6844
|
convertToolCalls,
|
|
6813
6845
|
createEmptySnapshot,
|
|
6814
6846
|
createLLM,
|
|
6847
|
+
deduplicateModels,
|
|
6815
6848
|
err,
|
|
6816
6849
|
generateFolderTree,
|
|
6817
6850
|
getAvailableProviders,
|