@nuvin/nuvin-core 1.8.0 → 1.9.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 +16 -2
- package/dist/index.js +50 -5
- package/package.json +1 -1
package/dist/VERSION
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -393,6 +393,7 @@ type TodoWriteMetadata = {
|
|
|
393
393
|
type AssignTaskMetadata = DelegationMetadata;
|
|
394
394
|
type ToolErrorMetadata = {
|
|
395
395
|
errorReason?: ErrorReason;
|
|
396
|
+
editInstruction?: string;
|
|
396
397
|
path?: string;
|
|
397
398
|
agentId?: string;
|
|
398
399
|
code?: string | number;
|
|
@@ -418,6 +419,7 @@ type ToolCall = {
|
|
|
418
419
|
name: string;
|
|
419
420
|
arguments: string;
|
|
420
421
|
};
|
|
422
|
+
editInstruction?: string;
|
|
421
423
|
};
|
|
422
424
|
type TextContentPart = {
|
|
423
425
|
type: 'text';
|
|
@@ -586,46 +588,57 @@ type ToolInvocation = {
|
|
|
586
588
|
id: string;
|
|
587
589
|
name: 'bash_tool';
|
|
588
590
|
parameters: BashToolArgs;
|
|
591
|
+
editInstruction?: string;
|
|
589
592
|
} | {
|
|
590
593
|
id: string;
|
|
591
594
|
name: 'file_read';
|
|
592
595
|
parameters: FileReadArgs;
|
|
596
|
+
editInstruction?: string;
|
|
593
597
|
} | {
|
|
594
598
|
id: string;
|
|
595
599
|
name: 'file_edit';
|
|
596
600
|
parameters: FileEditArgs;
|
|
601
|
+
editInstruction?: string;
|
|
597
602
|
} | {
|
|
598
603
|
id: string;
|
|
599
604
|
name: 'file_new';
|
|
600
605
|
parameters: FileNewArgs;
|
|
606
|
+
editInstruction?: string;
|
|
601
607
|
} | {
|
|
602
608
|
id: string;
|
|
603
609
|
name: 'dir_ls';
|
|
604
610
|
parameters: DirLsArgs;
|
|
611
|
+
editInstruction?: string;
|
|
605
612
|
} | {
|
|
606
613
|
id: string;
|
|
607
614
|
name: 'web_search';
|
|
608
615
|
parameters: WebSearchArgs;
|
|
616
|
+
editInstruction?: string;
|
|
609
617
|
} | {
|
|
610
618
|
id: string;
|
|
611
619
|
name: 'web_fetch';
|
|
612
620
|
parameters: WebFetchArgs;
|
|
621
|
+
editInstruction?: string;
|
|
613
622
|
} | {
|
|
614
623
|
id: string;
|
|
615
624
|
name: 'todo_write';
|
|
616
625
|
parameters: TodoWriteArgs;
|
|
626
|
+
editInstruction?: string;
|
|
617
627
|
} | {
|
|
618
628
|
id: string;
|
|
619
629
|
name: 'assign_task';
|
|
620
630
|
parameters: AssignTaskArgs;
|
|
631
|
+
editInstruction?: string;
|
|
621
632
|
} | {
|
|
622
633
|
id: string;
|
|
623
634
|
name: string;
|
|
624
635
|
parameters: Record<string, unknown>;
|
|
636
|
+
editInstruction?: string;
|
|
625
637
|
};
|
|
626
638
|
declare enum ErrorReason {
|
|
627
639
|
Aborted = "aborted",
|
|
628
640
|
Denied = "denied",
|
|
641
|
+
Edited = "edited",
|
|
629
642
|
Timeout = "timeout",
|
|
630
643
|
NotFound = "not_found",
|
|
631
644
|
PermissionDenied = "permission_denied",
|
|
@@ -841,7 +854,7 @@ declare const AgentEventTypes: {
|
|
|
841
854
|
readonly SubAgentCompleted: "sub_agent_completed";
|
|
842
855
|
readonly SubAgentMetrics: "sub_agent_metrics";
|
|
843
856
|
};
|
|
844
|
-
type ToolApprovalDecision = 'approve' | 'deny' | 'approve_all';
|
|
857
|
+
type ToolApprovalDecision = 'approve' | 'deny' | 'approve_all' | 'edit';
|
|
845
858
|
type AgentEvent = {
|
|
846
859
|
type: typeof AgentEventTypes.MessageStarted;
|
|
847
860
|
conversationId: string;
|
|
@@ -868,6 +881,7 @@ type AgentEvent = {
|
|
|
868
881
|
approvalId: string;
|
|
869
882
|
decision: ToolApprovalDecision;
|
|
870
883
|
approvedCalls?: ToolCall[];
|
|
884
|
+
editInstruction?: string;
|
|
871
885
|
} | {
|
|
872
886
|
type: typeof AgentEventTypes.ToolResult;
|
|
873
887
|
conversationId: string;
|
|
@@ -1034,7 +1048,7 @@ declare class AgentOrchestrator {
|
|
|
1034
1048
|
private processToolApproval;
|
|
1035
1049
|
send(content: UserMessagePayload, opts?: SendMessageOptions): Promise<MessageResponse>;
|
|
1036
1050
|
private waitForToolApproval;
|
|
1037
|
-
handleToolApproval(approvalId: string, decision: ToolApprovalDecision, approvedCalls?: ToolCall[]): void;
|
|
1051
|
+
handleToolApproval(approvalId: string, decision: ToolApprovalDecision, approvedCalls?: ToolCall[], editInstruction?: string): void;
|
|
1038
1052
|
private toInvocations;
|
|
1039
1053
|
}
|
|
1040
1054
|
|
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 {
|
|
@@ -4223,6 +4236,22 @@ var ToolRegistry = class {
|
|
|
4223
4236
|
durationMs: 0
|
|
4224
4237
|
};
|
|
4225
4238
|
}
|
|
4239
|
+
if (c.editInstruction) {
|
|
4240
|
+
const editResult = `${c.editInstruction}
|
|
4241
|
+
<system-reminder>
|
|
4242
|
+
This is not a result from the tool call. The user wants something else. Please follow the user's instruction.
|
|
4243
|
+
DO NOT mention this explicitly to the user.
|
|
4244
|
+
</system-reminder>`;
|
|
4245
|
+
return {
|
|
4246
|
+
id: c.id,
|
|
4247
|
+
name: c.name,
|
|
4248
|
+
status: "error",
|
|
4249
|
+
type: "text",
|
|
4250
|
+
result: editResult,
|
|
4251
|
+
metadata: { errorReason: "edited" /* Edited */, editInstruction: c.editInstruction },
|
|
4252
|
+
durationMs: 0
|
|
4253
|
+
};
|
|
4254
|
+
}
|
|
4226
4255
|
const startTime = performance.now();
|
|
4227
4256
|
const impl = this.tools.get(c.name);
|
|
4228
4257
|
if (!impl) {
|
|
@@ -6876,6 +6905,22 @@ var MCPToolPort = class {
|
|
|
6876
6905
|
result: "Tool execution aborted by user"
|
|
6877
6906
|
};
|
|
6878
6907
|
}
|
|
6908
|
+
if (c.editInstruction) {
|
|
6909
|
+
const editResult = `${c.editInstruction}
|
|
6910
|
+
<system-reminder>
|
|
6911
|
+
This is not a result from the tool call. The user wants something else. Please follow the user's instruction.
|
|
6912
|
+
DO NOT mention this explicitly to the user.
|
|
6913
|
+
</system-reminder>`;
|
|
6914
|
+
return {
|
|
6915
|
+
id: c.id,
|
|
6916
|
+
name: c.name,
|
|
6917
|
+
status: "error",
|
|
6918
|
+
type: "text",
|
|
6919
|
+
result: editResult,
|
|
6920
|
+
metadata: { errorReason: "edited" /* Edited */, editInstruction: c.editInstruction },
|
|
6921
|
+
durationMs: 0
|
|
6922
|
+
};
|
|
6923
|
+
}
|
|
6879
6924
|
const original = this.map.get(c.name);
|
|
6880
6925
|
if (!original) {
|
|
6881
6926
|
return { id: c.id, name: c.name, status: "error", type: "text", result: `Unknown MCP tool: ${c.name}` };
|