@nuvin/nuvin-core 1.8.0 → 1.9.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 +73 -92
- package/dist/index.js +59 -6
- package/package.json +1 -1
package/dist/VERSION
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -352,47 +352,71 @@ type FileReadMetadata = FileMetadata & {
|
|
|
352
352
|
bomStripped?: boolean;
|
|
353
353
|
};
|
|
354
354
|
type FileEditMetadata = FileMetadata & {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
355
|
+
eol: 'lf' | 'crlf';
|
|
356
|
+
oldTextLength: number;
|
|
357
|
+
newTextLength: number;
|
|
358
|
+
bytesWritten: number;
|
|
359
|
+
beforeSha: string;
|
|
360
|
+
afterSha: string;
|
|
361
|
+
dryRun: boolean;
|
|
362
|
+
lineNumbers: {
|
|
363
|
+
oldStartLine: number;
|
|
364
|
+
oldEndLine: number;
|
|
365
|
+
newStartLine: number;
|
|
366
|
+
newEndLine: number;
|
|
367
|
+
oldLineCount: number;
|
|
368
|
+
newLineCount: number;
|
|
363
369
|
};
|
|
370
|
+
noChange?: boolean;
|
|
364
371
|
};
|
|
365
|
-
type FileNewMetadata =
|
|
372
|
+
type FileNewMetadata = {
|
|
373
|
+
file_path: string;
|
|
374
|
+
bytes: number;
|
|
375
|
+
lines: number;
|
|
376
|
+
created: string;
|
|
366
377
|
overwritten?: boolean;
|
|
367
378
|
};
|
|
368
379
|
type DirLsMetadata = {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
entriesReturned?: number;
|
|
372
|
-
truncated?: boolean;
|
|
380
|
+
limit: number;
|
|
381
|
+
includeHidden: boolean;
|
|
373
382
|
};
|
|
374
383
|
type WebSearchMetadata = {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
searchTime?: number;
|
|
379
|
-
provider?: string;
|
|
384
|
+
offset: number;
|
|
385
|
+
totalRequested: number;
|
|
386
|
+
hydrated: boolean;
|
|
380
387
|
};
|
|
381
388
|
type WebFetchMetadata = {
|
|
382
389
|
url: string;
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
390
|
+
contentType: string;
|
|
391
|
+
statusCode: number;
|
|
392
|
+
format: 'markdown' | 'json' | 'text';
|
|
393
|
+
size: number;
|
|
394
|
+
fetchedAt: string;
|
|
388
395
|
};
|
|
389
396
|
type TodoWriteMetadata = {
|
|
390
397
|
todosWritten: number;
|
|
391
|
-
conversationId
|
|
398
|
+
conversationId: string;
|
|
399
|
+
recentChanges: boolean;
|
|
400
|
+
progress: string;
|
|
401
|
+
allCompleted: boolean;
|
|
402
|
+
items: Array<{
|
|
403
|
+
id: string;
|
|
404
|
+
content: string;
|
|
405
|
+
status: 'pending' | 'in_progress' | 'completed';
|
|
406
|
+
priority: 'high' | 'medium' | 'low';
|
|
407
|
+
createdAt: string;
|
|
408
|
+
}>;
|
|
409
|
+
stats: {
|
|
410
|
+
total: number;
|
|
411
|
+
pending: number;
|
|
412
|
+
inProgress: number;
|
|
413
|
+
completed: number;
|
|
414
|
+
};
|
|
392
415
|
};
|
|
393
416
|
type AssignTaskMetadata = DelegationMetadata;
|
|
394
417
|
type ToolErrorMetadata = {
|
|
395
418
|
errorReason?: ErrorReason;
|
|
419
|
+
editInstruction?: string;
|
|
396
420
|
path?: string;
|
|
397
421
|
agentId?: string;
|
|
398
422
|
code?: string | number;
|
|
@@ -418,6 +442,7 @@ type ToolCall = {
|
|
|
418
442
|
name: string;
|
|
419
443
|
arguments: string;
|
|
420
444
|
};
|
|
445
|
+
editInstruction?: string;
|
|
421
446
|
};
|
|
422
447
|
type TextContentPart = {
|
|
423
448
|
type: 'text';
|
|
@@ -586,46 +611,57 @@ type ToolInvocation = {
|
|
|
586
611
|
id: string;
|
|
587
612
|
name: 'bash_tool';
|
|
588
613
|
parameters: BashToolArgs;
|
|
614
|
+
editInstruction?: string;
|
|
589
615
|
} | {
|
|
590
616
|
id: string;
|
|
591
617
|
name: 'file_read';
|
|
592
618
|
parameters: FileReadArgs;
|
|
619
|
+
editInstruction?: string;
|
|
593
620
|
} | {
|
|
594
621
|
id: string;
|
|
595
622
|
name: 'file_edit';
|
|
596
623
|
parameters: FileEditArgs;
|
|
624
|
+
editInstruction?: string;
|
|
597
625
|
} | {
|
|
598
626
|
id: string;
|
|
599
627
|
name: 'file_new';
|
|
600
628
|
parameters: FileNewArgs;
|
|
629
|
+
editInstruction?: string;
|
|
601
630
|
} | {
|
|
602
631
|
id: string;
|
|
603
632
|
name: 'dir_ls';
|
|
604
633
|
parameters: DirLsArgs;
|
|
634
|
+
editInstruction?: string;
|
|
605
635
|
} | {
|
|
606
636
|
id: string;
|
|
607
637
|
name: 'web_search';
|
|
608
638
|
parameters: WebSearchArgs;
|
|
639
|
+
editInstruction?: string;
|
|
609
640
|
} | {
|
|
610
641
|
id: string;
|
|
611
642
|
name: 'web_fetch';
|
|
612
643
|
parameters: WebFetchArgs;
|
|
644
|
+
editInstruction?: string;
|
|
613
645
|
} | {
|
|
614
646
|
id: string;
|
|
615
647
|
name: 'todo_write';
|
|
616
648
|
parameters: TodoWriteArgs;
|
|
649
|
+
editInstruction?: string;
|
|
617
650
|
} | {
|
|
618
651
|
id: string;
|
|
619
652
|
name: 'assign_task';
|
|
620
653
|
parameters: AssignTaskArgs;
|
|
654
|
+
editInstruction?: string;
|
|
621
655
|
} | {
|
|
622
656
|
id: string;
|
|
623
657
|
name: string;
|
|
624
658
|
parameters: Record<string, unknown>;
|
|
659
|
+
editInstruction?: string;
|
|
625
660
|
};
|
|
626
661
|
declare enum ErrorReason {
|
|
627
662
|
Aborted = "aborted",
|
|
628
663
|
Denied = "denied",
|
|
664
|
+
Edited = "edited",
|
|
629
665
|
Timeout = "timeout",
|
|
630
666
|
NotFound = "not_found",
|
|
631
667
|
PermissionDenied = "permission_denied",
|
|
@@ -841,7 +877,7 @@ declare const AgentEventTypes: {
|
|
|
841
877
|
readonly SubAgentCompleted: "sub_agent_completed";
|
|
842
878
|
readonly SubAgentMetrics: "sub_agent_metrics";
|
|
843
879
|
};
|
|
844
|
-
type ToolApprovalDecision = 'approve' | 'deny' | 'approve_all';
|
|
880
|
+
type ToolApprovalDecision = 'approve' | 'deny' | 'approve_all' | 'edit';
|
|
845
881
|
type AgentEvent = {
|
|
846
882
|
type: typeof AgentEventTypes.MessageStarted;
|
|
847
883
|
conversationId: string;
|
|
@@ -868,6 +904,7 @@ type AgentEvent = {
|
|
|
868
904
|
approvalId: string;
|
|
869
905
|
decision: ToolApprovalDecision;
|
|
870
906
|
approvedCalls?: ToolCall[];
|
|
907
|
+
editInstruction?: string;
|
|
871
908
|
} | {
|
|
872
909
|
type: typeof AgentEventTypes.ToolResult;
|
|
873
910
|
conversationId: string;
|
|
@@ -1034,7 +1071,7 @@ declare class AgentOrchestrator {
|
|
|
1034
1071
|
private processToolApproval;
|
|
1035
1072
|
send(content: UserMessagePayload, opts?: SendMessageOptions): Promise<MessageResponse>;
|
|
1036
1073
|
private waitForToolApproval;
|
|
1037
|
-
handleToolApproval(approvalId: string, decision: ToolApprovalDecision, approvedCalls?: ToolCall[]): void;
|
|
1074
|
+
handleToolApproval(approvalId: string, decision: ToolApprovalDecision, approvedCalls?: ToolCall[], editInstruction?: string): void;
|
|
1038
1075
|
private toInvocations;
|
|
1039
1076
|
}
|
|
1040
1077
|
|
|
@@ -1532,14 +1569,10 @@ type BashSuccessResult$1 = {
|
|
|
1532
1569
|
status: 'success';
|
|
1533
1570
|
type: 'text';
|
|
1534
1571
|
result: string;
|
|
1535
|
-
metadata?:
|
|
1536
|
-
stdout?: string;
|
|
1537
|
-
stderr?: string;
|
|
1538
|
-
stripped?: boolean;
|
|
1539
|
-
};
|
|
1572
|
+
metadata?: BashToolMetadata;
|
|
1540
1573
|
};
|
|
1541
1574
|
type BashErrorResult = ExecResultError & {
|
|
1542
|
-
metadata?:
|
|
1575
|
+
metadata?: BashToolMetadata & {
|
|
1543
1576
|
errorReason?: ErrorReason;
|
|
1544
1577
|
};
|
|
1545
1578
|
};
|
|
@@ -1643,11 +1676,7 @@ type FileReadSuccessResult$1 = {
|
|
|
1643
1676
|
status: 'success';
|
|
1644
1677
|
type: 'text';
|
|
1645
1678
|
result: string;
|
|
1646
|
-
metadata?:
|
|
1647
|
-
lineRange?: LineRangeMetadata;
|
|
1648
|
-
encoding?: string;
|
|
1649
|
-
bomStripped?: boolean;
|
|
1650
|
-
};
|
|
1679
|
+
metadata?: FileReadMetadata;
|
|
1651
1680
|
};
|
|
1652
1681
|
type FileReadErrorResult = ExecResultError & {
|
|
1653
1682
|
metadata?: {
|
|
@@ -1661,24 +1690,7 @@ type FileEditSuccessResult$1 = {
|
|
|
1661
1690
|
status: 'success';
|
|
1662
1691
|
type: 'text';
|
|
1663
1692
|
result: string;
|
|
1664
|
-
metadata:
|
|
1665
|
-
eol: 'lf' | 'crlf';
|
|
1666
|
-
oldTextLength: number;
|
|
1667
|
-
newTextLength: number;
|
|
1668
|
-
bytesWritten: number;
|
|
1669
|
-
beforeSha: string;
|
|
1670
|
-
afterSha: string;
|
|
1671
|
-
dryRun: boolean;
|
|
1672
|
-
lineNumbers: {
|
|
1673
|
-
oldStartLine: number;
|
|
1674
|
-
oldEndLine: number;
|
|
1675
|
-
newStartLine: number;
|
|
1676
|
-
newEndLine: number;
|
|
1677
|
-
oldLineCount: number;
|
|
1678
|
-
newLineCount: number;
|
|
1679
|
-
};
|
|
1680
|
-
noChange?: boolean;
|
|
1681
|
-
};
|
|
1693
|
+
metadata: FileEditMetadata;
|
|
1682
1694
|
};
|
|
1683
1695
|
type FileEditResult = FileEditSuccessResult$1 | ExecResultError;
|
|
1684
1696
|
|
|
@@ -1690,13 +1702,7 @@ type FileNewSuccessResult$1 = {
|
|
|
1690
1702
|
status: 'success';
|
|
1691
1703
|
type: 'text';
|
|
1692
1704
|
result: string;
|
|
1693
|
-
metadata:
|
|
1694
|
-
file_path: string;
|
|
1695
|
-
bytes: number;
|
|
1696
|
-
lines: number;
|
|
1697
|
-
created: string;
|
|
1698
|
-
overwritten?: boolean;
|
|
1699
|
-
};
|
|
1705
|
+
metadata: FileNewMetadata;
|
|
1700
1706
|
};
|
|
1701
1707
|
type FileNewResult = FileNewSuccessResult$1 | ExecResultError;
|
|
1702
1708
|
|
|
@@ -1721,10 +1727,7 @@ type DirLsSuccessResult$1 = {
|
|
|
1721
1727
|
truncated: boolean;
|
|
1722
1728
|
total: number;
|
|
1723
1729
|
};
|
|
1724
|
-
metadata?:
|
|
1725
|
-
limit: number;
|
|
1726
|
-
includeHidden: boolean;
|
|
1727
|
-
};
|
|
1730
|
+
metadata?: DirLsMetadata;
|
|
1728
1731
|
};
|
|
1729
1732
|
type DirLsResult = DirLsSuccessResult$1 | ExecResultError;
|
|
1730
1733
|
|
|
@@ -1775,11 +1778,7 @@ type WebSearchSuccessResult$1 = {
|
|
|
1775
1778
|
region?: string;
|
|
1776
1779
|
};
|
|
1777
1780
|
};
|
|
1778
|
-
metadata?:
|
|
1779
|
-
offset: number;
|
|
1780
|
-
totalRequested: number;
|
|
1781
|
-
hydrated: boolean;
|
|
1782
|
-
};
|
|
1781
|
+
metadata?: WebSearchMetadata;
|
|
1783
1782
|
};
|
|
1784
1783
|
type WebSearchToolResult = WebSearchSuccessResult$1 | ExecResultError;
|
|
1785
1784
|
|
|
@@ -1790,14 +1789,7 @@ type WebFetchSuccessResult$1 = {
|
|
|
1790
1789
|
status: 'success';
|
|
1791
1790
|
type: 'text';
|
|
1792
1791
|
result: string;
|
|
1793
|
-
metadata:
|
|
1794
|
-
url: string;
|
|
1795
|
-
contentType: string;
|
|
1796
|
-
statusCode: number;
|
|
1797
|
-
format: 'markdown' | 'json' | 'text';
|
|
1798
|
-
size: number;
|
|
1799
|
-
fetchedAt: string;
|
|
1800
|
-
};
|
|
1792
|
+
metadata: WebFetchMetadata;
|
|
1801
1793
|
};
|
|
1802
1794
|
type WebFetchResult = WebFetchSuccessResult$1 | ExecResultError;
|
|
1803
1795
|
|
|
@@ -1805,18 +1797,7 @@ type TodoWriteSuccessResult$1 = {
|
|
|
1805
1797
|
status: 'success';
|
|
1806
1798
|
type: 'text';
|
|
1807
1799
|
result: string;
|
|
1808
|
-
metadata:
|
|
1809
|
-
recentChanges: boolean;
|
|
1810
|
-
stats: {
|
|
1811
|
-
total: number;
|
|
1812
|
-
pending: number;
|
|
1813
|
-
inProgress: number;
|
|
1814
|
-
completed: number;
|
|
1815
|
-
};
|
|
1816
|
-
progress: string;
|
|
1817
|
-
allCompleted: boolean;
|
|
1818
|
-
conversationId: string;
|
|
1819
|
-
};
|
|
1800
|
+
metadata: TodoWriteMetadata;
|
|
1820
1801
|
};
|
|
1821
1802
|
type TodoWriteResult = TodoWriteSuccessResult$1 | ExecResultError;
|
|
1822
1803
|
|
|
@@ -1824,7 +1805,7 @@ type AssignSuccessResult$1 = {
|
|
|
1824
1805
|
status: 'success';
|
|
1825
1806
|
type: 'text';
|
|
1826
1807
|
result: string;
|
|
1827
|
-
metadata:
|
|
1808
|
+
metadata: AssignTaskMetadata;
|
|
1828
1809
|
};
|
|
1829
1810
|
type AssignErrorResult = ExecResultError & {
|
|
1830
1811
|
metadata?: {
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
var ErrorReason = /* @__PURE__ */ ((ErrorReason2) => {
|
|
3
3
|
ErrorReason2["Aborted"] = "aborted";
|
|
4
4
|
ErrorReason2["Denied"] = "denied";
|
|
5
|
+
ErrorReason2["Edited"] = "edited";
|
|
5
6
|
ErrorReason2["Timeout"] = "timeout";
|
|
6
7
|
ErrorReason2["NotFound"] = "not_found";
|
|
7
8
|
ErrorReason2["PermissionDenied"] = "permission_denied";
|
|
@@ -734,7 +735,8 @@ function convertToolCall(toolCall, options = {}) {
|
|
|
734
735
|
invocation: {
|
|
735
736
|
id: toolCall.id,
|
|
736
737
|
name: toolCall.function.name,
|
|
737
|
-
parameters
|
|
738
|
+
parameters,
|
|
739
|
+
editInstruction: toolCall.editInstruction
|
|
738
740
|
}
|
|
739
741
|
};
|
|
740
742
|
}
|
|
@@ -752,7 +754,8 @@ function convertToolCalls(toolCalls, options = {}) {
|
|
|
752
754
|
invocations.push({
|
|
753
755
|
id: result.callId,
|
|
754
756
|
name: result.toolName,
|
|
755
|
-
parameters: {}
|
|
757
|
+
parameters: {},
|
|
758
|
+
editInstruction: tc.editInstruction
|
|
756
759
|
});
|
|
757
760
|
} else {
|
|
758
761
|
invocations.push(result.invocation);
|
|
@@ -998,8 +1001,16 @@ var AgentOrchestrator = class {
|
|
|
998
1001
|
return { approvedCalls: callsToAutoApprove, wasDenied: false };
|
|
999
1002
|
}
|
|
1000
1003
|
try {
|
|
1001
|
-
const
|
|
1002
|
-
|
|
1004
|
+
const result = await this.waitForToolApproval(callsNeedingApproval, conversationId, messageId);
|
|
1005
|
+
if ("editInstruction" in result) {
|
|
1006
|
+
const editInstruction = result.editInstruction;
|
|
1007
|
+
const editedCalls = toolCalls.map((call) => ({
|
|
1008
|
+
...call,
|
|
1009
|
+
editInstruction
|
|
1010
|
+
}));
|
|
1011
|
+
return { approvedCalls: editedCalls, wasDenied: false };
|
|
1012
|
+
}
|
|
1013
|
+
return { approvedCalls: [...result, ...callsToAutoApprove], wasDenied: false };
|
|
1003
1014
|
} catch (err2) {
|
|
1004
1015
|
const errorMsg = err2 instanceof Error ? err2.message : "Tool approval failed";
|
|
1005
1016
|
const denialMessage = `Tool execution was not approved: ${errorMsg}`;
|
|
@@ -1372,7 +1383,7 @@ var AgentOrchestrator = class {
|
|
|
1372
1383
|
});
|
|
1373
1384
|
});
|
|
1374
1385
|
}
|
|
1375
|
-
handleToolApproval(approvalId, decision, approvedCalls) {
|
|
1386
|
+
handleToolApproval(approvalId, decision, approvedCalls, editInstruction) {
|
|
1376
1387
|
const approval = this.pendingApprovals.get(approvalId);
|
|
1377
1388
|
if (!approval) {
|
|
1378
1389
|
console.warn(`[Orchestrator] Received approval for unknown or already processed ID: ${approvalId}`);
|
|
@@ -1381,6 +1392,8 @@ var AgentOrchestrator = class {
|
|
|
1381
1392
|
this.pendingApprovals.delete(approvalId);
|
|
1382
1393
|
if (decision === "deny") {
|
|
1383
1394
|
approval.reject(new Error("Tool execution denied by user"));
|
|
1395
|
+
} else if (decision === "edit" && editInstruction) {
|
|
1396
|
+
approval.resolve({ editInstruction });
|
|
1384
1397
|
} else if (decision === "approve_all" || decision === "approve") {
|
|
1385
1398
|
approval.resolve(approvedCalls || []);
|
|
1386
1399
|
} else {
|
|
@@ -2116,7 +2129,15 @@ Your todo list has changed. DO NOT mention this explicitly to the user. Latest c
|
|
|
2116
2129
|
stats,
|
|
2117
2130
|
progress: `${progress}%`,
|
|
2118
2131
|
allCompleted,
|
|
2119
|
-
conversationId
|
|
2132
|
+
conversationId,
|
|
2133
|
+
items: items.map((item) => ({
|
|
2134
|
+
id: item.id,
|
|
2135
|
+
content: item.content,
|
|
2136
|
+
status: item.status,
|
|
2137
|
+
priority: item.priority,
|
|
2138
|
+
createdAt: item.createdAt || nowIso
|
|
2139
|
+
})),
|
|
2140
|
+
todosWritten: items.length
|
|
2120
2141
|
});
|
|
2121
2142
|
}
|
|
2122
2143
|
};
|
|
@@ -4223,6 +4244,22 @@ var ToolRegistry = class {
|
|
|
4223
4244
|
durationMs: 0
|
|
4224
4245
|
};
|
|
4225
4246
|
}
|
|
4247
|
+
if (c.editInstruction) {
|
|
4248
|
+
const editResult = `${c.editInstruction}
|
|
4249
|
+
<system-reminder>
|
|
4250
|
+
This is not a result from the tool call. The user wants something else. Please follow the user's instruction.
|
|
4251
|
+
DO NOT mention this explicitly to the user.
|
|
4252
|
+
</system-reminder>`;
|
|
4253
|
+
return {
|
|
4254
|
+
id: c.id,
|
|
4255
|
+
name: c.name,
|
|
4256
|
+
status: "error",
|
|
4257
|
+
type: "text",
|
|
4258
|
+
result: editResult,
|
|
4259
|
+
metadata: { errorReason: "edited" /* Edited */, editInstruction: c.editInstruction },
|
|
4260
|
+
durationMs: 0
|
|
4261
|
+
};
|
|
4262
|
+
}
|
|
4226
4263
|
const startTime = performance.now();
|
|
4227
4264
|
const impl = this.tools.get(c.name);
|
|
4228
4265
|
if (!impl) {
|
|
@@ -6876,6 +6913,22 @@ var MCPToolPort = class {
|
|
|
6876
6913
|
result: "Tool execution aborted by user"
|
|
6877
6914
|
};
|
|
6878
6915
|
}
|
|
6916
|
+
if (c.editInstruction) {
|
|
6917
|
+
const editResult = `${c.editInstruction}
|
|
6918
|
+
<system-reminder>
|
|
6919
|
+
This is not a result from the tool call. The user wants something else. Please follow the user's instruction.
|
|
6920
|
+
DO NOT mention this explicitly to the user.
|
|
6921
|
+
</system-reminder>`;
|
|
6922
|
+
return {
|
|
6923
|
+
id: c.id,
|
|
6924
|
+
name: c.name,
|
|
6925
|
+
status: "error",
|
|
6926
|
+
type: "text",
|
|
6927
|
+
result: editResult,
|
|
6928
|
+
metadata: { errorReason: "edited" /* Edited */, editInstruction: c.editInstruction },
|
|
6929
|
+
durationMs: 0
|
|
6930
|
+
};
|
|
6931
|
+
}
|
|
6879
6932
|
const original = this.map.get(c.name);
|
|
6880
6933
|
if (!original) {
|
|
6881
6934
|
return { id: c.id, name: c.name, status: "error", type: "text", result: `Unknown MCP tool: ${c.name}` };
|