@nuvin/nuvin-core 1.1.0 → 1.1.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 +17 -3
- package/dist/index.js +40 -10
- package/package.json +7 -2
package/dist/VERSION
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -349,15 +349,29 @@ type ToolDefinition = {
|
|
|
349
349
|
type ToolInvocation = {
|
|
350
350
|
id: string;
|
|
351
351
|
name: string;
|
|
352
|
-
parameters: Record<string,
|
|
352
|
+
parameters: Record<string, unknown>;
|
|
353
353
|
};
|
|
354
|
+
declare enum ErrorReason {
|
|
355
|
+
Aborted = "aborted",
|
|
356
|
+
Denied = "denied",
|
|
357
|
+
Timeout = "timeout",
|
|
358
|
+
NotFound = "not_found",
|
|
359
|
+
PermissionDenied = "permission_denied",
|
|
360
|
+
InvalidInput = "invalid_input",
|
|
361
|
+
NetworkError = "network_error",
|
|
362
|
+
RateLimit = "rate_limit",
|
|
363
|
+
ToolNotFound = "tool_not_found",
|
|
364
|
+
Unknown = "unknown"
|
|
365
|
+
}
|
|
354
366
|
type ToolExecutionResult = {
|
|
355
367
|
id: string;
|
|
356
368
|
name: string;
|
|
357
369
|
status: 'success' | 'error';
|
|
358
370
|
type: 'text' | 'json';
|
|
359
371
|
result: string | object;
|
|
360
|
-
metadata?: Record<string, unknown
|
|
372
|
+
metadata?: Record<string, unknown> & {
|
|
373
|
+
errorReason?: ErrorReason;
|
|
374
|
+
};
|
|
361
375
|
durationMs?: number;
|
|
362
376
|
};
|
|
363
377
|
interface ToolPort {
|
|
@@ -1328,4 +1342,4 @@ declare function resolveBackspaces(s: string): string;
|
|
|
1328
1342
|
declare function stripAnsiAndControls(s: string): string;
|
|
1329
1343
|
declare function canonicalizeTerminalPaste(raw: string): string;
|
|
1330
1344
|
|
|
1331
|
-
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, CompositeToolPort, type Conversation, ConversationContext, type ConversationMetadata, type ConversationSnapshot, ConversationStore, CoreMCPClient, DefaultDelegationPolicy, DefaultDelegationResultFormatter, DefaultDelegationService, DefaultSpecialistAgentFactory, type DelegationService, type DelegationServiceConfig, DelegationServiceFactory, 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 };
|
|
1345
|
+
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, 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 };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
// ports.ts
|
|
2
|
+
var ErrorReason = /* @__PURE__ */ ((ErrorReason2) => {
|
|
3
|
+
ErrorReason2["Aborted"] = "aborted";
|
|
4
|
+
ErrorReason2["Denied"] = "denied";
|
|
5
|
+
ErrorReason2["Timeout"] = "timeout";
|
|
6
|
+
ErrorReason2["NotFound"] = "not_found";
|
|
7
|
+
ErrorReason2["PermissionDenied"] = "permission_denied";
|
|
8
|
+
ErrorReason2["InvalidInput"] = "invalid_input";
|
|
9
|
+
ErrorReason2["NetworkError"] = "network_error";
|
|
10
|
+
ErrorReason2["RateLimit"] = "rate_limit";
|
|
11
|
+
ErrorReason2["ToolNotFound"] = "tool_not_found";
|
|
12
|
+
ErrorReason2["Unknown"] = "unknown";
|
|
13
|
+
return ErrorReason2;
|
|
14
|
+
})(ErrorReason || {});
|
|
2
15
|
var MessageRoles = {
|
|
3
16
|
System: "system",
|
|
4
17
|
User: "user",
|
|
@@ -1860,8 +1873,9 @@ import * as path3 from "path";
|
|
|
1860
1873
|
function ok(result, metadata) {
|
|
1861
1874
|
return { status: "success", type: "text", result, metadata };
|
|
1862
1875
|
}
|
|
1863
|
-
function err(result, metadata) {
|
|
1864
|
-
|
|
1876
|
+
function err(result, metadata, errorReason) {
|
|
1877
|
+
const finalMetadata = errorReason ? { ...metadata, errorReason } : metadata;
|
|
1878
|
+
return { status: "error", type: "text", result, metadata: finalMetadata };
|
|
1865
1879
|
}
|
|
1866
1880
|
|
|
1867
1881
|
// tools/FileReadTool.ts
|
|
@@ -2288,15 +2302,15 @@ var BashTool = class {
|
|
|
2288
2302
|
return await this.execOnce(p, ctx?.signal);
|
|
2289
2303
|
} catch (e) {
|
|
2290
2304
|
if (e instanceof Error && e.name === "AbortError") {
|
|
2291
|
-
return err("Command execution aborted by user");
|
|
2305
|
+
return err("Command execution aborted by user", void 0, "aborted" /* Aborted */);
|
|
2292
2306
|
}
|
|
2293
2307
|
const message = e instanceof Error ? e.message : String(e);
|
|
2294
|
-
return err(message);
|
|
2308
|
+
return err(message, void 0, "unknown" /* Unknown */);
|
|
2295
2309
|
}
|
|
2296
2310
|
}
|
|
2297
2311
|
async execOnce(p, signal) {
|
|
2298
2312
|
if (signal?.aborted) {
|
|
2299
|
-
return err("Command execution aborted by user");
|
|
2313
|
+
return err("Command execution aborted by user", void 0, "aborted" /* Aborted */);
|
|
2300
2314
|
}
|
|
2301
2315
|
const { cmd, cwd = process.cwd(), timeoutMs = DEFAULTS.timeoutMs } = p;
|
|
2302
2316
|
const maxOutputBytes = DEFAULTS.maxOutputBytes;
|
|
@@ -2314,7 +2328,7 @@ var BashTool = class {
|
|
|
2314
2328
|
});
|
|
2315
2329
|
} catch (error) {
|
|
2316
2330
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
2317
|
-
return err(`Shell not found: ${executable}
|
|
2331
|
+
return err(`Shell not found: ${executable}`, void 0, "not_found" /* NotFound */);
|
|
2318
2332
|
}
|
|
2319
2333
|
throw error;
|
|
2320
2334
|
}
|
|
@@ -2324,8 +2338,10 @@ var BashTool = class {
|
|
|
2324
2338
|
}
|
|
2325
2339
|
});
|
|
2326
2340
|
let timer = null;
|
|
2341
|
+
let timedOut = false;
|
|
2327
2342
|
const deadline = new Promise((_, rej) => {
|
|
2328
2343
|
timer = setTimeout(() => {
|
|
2344
|
+
timedOut = true;
|
|
2329
2345
|
try {
|
|
2330
2346
|
child.kill("SIGKILL");
|
|
2331
2347
|
} catch {
|
|
@@ -2383,10 +2399,17 @@ var BashTool = class {
|
|
|
2383
2399
|
const partialOutput = output ? `
|
|
2384
2400
|
Output before abort:
|
|
2385
2401
|
${output}` : "";
|
|
2386
|
-
return err(`Command execution aborted by user${partialOutput}
|
|
2402
|
+
return err(`Command execution aborted by user${partialOutput}`, { cwd }, "aborted" /* Aborted */);
|
|
2387
2403
|
}
|
|
2388
2404
|
if (code !== 0) {
|
|
2389
|
-
|
|
2405
|
+
const metadata = { code, signal: exitSignal, cwd };
|
|
2406
|
+
if (output.toLowerCase().includes("permission denied")) {
|
|
2407
|
+
return err(output, { ...metadata, errorReason: "permission_denied" /* PermissionDenied */ });
|
|
2408
|
+
}
|
|
2409
|
+
if (output.toLowerCase().includes("command not found") || output.toLowerCase().includes("not found")) {
|
|
2410
|
+
return err(output, { ...metadata, errorReason: "not_found" /* NotFound */ });
|
|
2411
|
+
}
|
|
2412
|
+
return err(output, metadata);
|
|
2390
2413
|
}
|
|
2391
2414
|
return ok(output, { code, signal: exitSignal, cwd });
|
|
2392
2415
|
} catch (e) {
|
|
@@ -2399,9 +2422,12 @@ ${output}` : "";
|
|
|
2399
2422
|
const partialOutput = output ? `
|
|
2400
2423
|
Output before abort:
|
|
2401
2424
|
${output}` : "";
|
|
2402
|
-
return err(`Command execution aborted by user${partialOutput}
|
|
2425
|
+
return err(`Command execution aborted by user${partialOutput}`, { cwd }, "aborted" /* Aborted */);
|
|
2403
2426
|
}
|
|
2404
|
-
|
|
2427
|
+
if (timedOut) {
|
|
2428
|
+
return err(message, { cwd }, "timeout" /* Timeout */);
|
|
2429
|
+
}
|
|
2430
|
+
return err(message, { cwd }, "unknown" /* Unknown */);
|
|
2405
2431
|
}
|
|
2406
2432
|
}
|
|
2407
2433
|
defaultShell() {
|
|
@@ -3423,6 +3449,7 @@ var ToolRegistry = class {
|
|
|
3423
3449
|
status: "error",
|
|
3424
3450
|
type: "text",
|
|
3425
3451
|
result: "Tool execution aborted by user",
|
|
3452
|
+
metadata: { errorReason: "aborted" /* Aborted */ },
|
|
3426
3453
|
durationMs: 0
|
|
3427
3454
|
});
|
|
3428
3455
|
}
|
|
@@ -3438,6 +3465,7 @@ var ToolRegistry = class {
|
|
|
3438
3465
|
status: "error",
|
|
3439
3466
|
type: "text",
|
|
3440
3467
|
result: "Tool execution aborted by user",
|
|
3468
|
+
metadata: { errorReason: "aborted" /* Aborted */ },
|
|
3441
3469
|
durationMs: 0
|
|
3442
3470
|
};
|
|
3443
3471
|
}
|
|
@@ -3451,6 +3479,7 @@ var ToolRegistry = class {
|
|
|
3451
3479
|
status: "error",
|
|
3452
3480
|
type: "text",
|
|
3453
3481
|
result: `Tool '${c.name}' not found`,
|
|
3482
|
+
metadata: { errorReason: "tool_not_found" /* ToolNotFound */ },
|
|
3454
3483
|
durationMs: durationMs2
|
|
3455
3484
|
};
|
|
3456
3485
|
}
|
|
@@ -5443,6 +5472,7 @@ export {
|
|
|
5443
5472
|
DefaultDelegationService,
|
|
5444
5473
|
DefaultSpecialistAgentFactory,
|
|
5445
5474
|
DelegationServiceFactory,
|
|
5475
|
+
ErrorReason,
|
|
5446
5476
|
GithubLLM,
|
|
5447
5477
|
InMemoryMemory,
|
|
5448
5478
|
InMemoryMetadata,
|
package/package.json
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuvin/nuvin-core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"type": "module",
|
|
9
|
+
"author": "Marsch Huynh <marsch.huynh@gmail.com>",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/marschhuynh/nuvin-cli.git",
|
|
13
|
+
"directory": "packages/nuvin-core"
|
|
14
|
+
},
|
|
9
15
|
"files": [
|
|
10
16
|
"dist"
|
|
11
17
|
],
|
|
@@ -19,7 +25,6 @@
|
|
|
19
25
|
"access": "public"
|
|
20
26
|
},
|
|
21
27
|
"keywords": [],
|
|
22
|
-
"author": "Marsch Huynh <marsch.huynh@gmail.com>",
|
|
23
28
|
"license": "Apache-2.0",
|
|
24
29
|
"dependencies": {
|
|
25
30
|
"@ai-sdk/anthropic": "^2.0.30",
|