@anvia/core 0.12.8 → 0.13.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/agent/index.d.ts +11 -11
- package/dist/agent/index.js +10 -11
- package/dist/{agent-BB9vVH6P.d.ts → agent-3qSfIKIj.d.ts} +8 -7
- package/dist/audio-generation/index.d.ts +1 -1
- package/dist/{chunk-NPZDYOE6.js → chunk-2ODTMRHP.js} +11 -10
- package/dist/chunk-2ODTMRHP.js.map +1 -0
- package/dist/{chunk-IN5NPAWL.js → chunk-CLFDBOH3.js} +6 -6
- package/dist/{chunk-QVFOCNF6.js → chunk-CNTGKNZ3.js} +99 -10
- package/dist/chunk-CNTGKNZ3.js.map +1 -0
- package/dist/chunk-CQNNSZPG.js +9 -0
- package/dist/chunk-CQNNSZPG.js.map +1 -0
- package/dist/{chunk-HF4KHHNM.js → chunk-DC2GJDPR.js} +5 -5
- package/dist/chunk-DC2GJDPR.js.map +1 -0
- package/dist/{chunk-IZM6FNCT.js → chunk-I7TM7TKX.js} +48 -42
- package/dist/chunk-I7TM7TKX.js.map +1 -0
- package/dist/{chunk-WRNPY5C6.js → chunk-KXXFWLKP.js} +3 -3
- package/dist/{chunk-2STANSN6.js → chunk-L52YHJ5L.js} +23 -20
- package/dist/chunk-L52YHJ5L.js.map +1 -0
- package/dist/{chunk-UDISNNKR.js → chunk-NS7W4G26.js} +70 -21
- package/dist/chunk-NS7W4G26.js.map +1 -0
- package/dist/{chunk-SHORX7TZ.js → chunk-WHHQWT7D.js} +12 -13
- package/dist/chunk-WHHQWT7D.js.map +1 -0
- package/dist/{chunk-EGZCTSEW.js → chunk-WWNXZWST.js} +208 -132
- package/dist/chunk-WWNXZWST.js.map +1 -0
- package/dist/{chunk-JS5MGVNM.js → chunk-YBBD4HZ3.js} +8 -7
- package/dist/{chunk-JS5MGVNM.js.map → chunk-YBBD4HZ3.js.map} +1 -1
- package/dist/{chunk-FUJ3POKH.js → chunk-YTF65GYU.js} +2 -2
- package/dist/completion/index.d.ts +3 -3
- package/dist/completion/index.js +4 -2
- package/dist/embeddings/index.js +1 -1
- package/dist/evals/index.d.ts +8 -8
- package/dist/evals/index.js +59 -36
- package/dist/evals/index.js.map +1 -1
- package/dist/extractor/index.d.ts +8 -8
- package/dist/extractor/index.js +11 -12
- package/dist/guardrails/index.d.ts +1 -1
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/index.js +1 -2
- package/dist/image-generation/index.d.ts +1 -1
- package/dist/{index-CM-V4LS3.d.ts → index-ZQAiHW5Q.d.ts} +2 -2
- package/dist/index.d.ts +12 -12
- package/dist/index.js +16 -14
- package/dist/internal/agent.d.ts +8 -8
- package/dist/internal/agent.js +9 -10
- package/dist/{create-completion-CC8-Ep3w.d.ts → json-C5a6auAm.d.ts} +4 -2
- package/dist/loaders/index.d.ts +1 -1
- package/dist/mcp/index.d.ts +4 -4
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/memory/index.d.ts +3 -3
- package/dist/{middleware-i-jLsLom.d.ts → middleware-Cc_-sosu.d.ts} +3 -3
- package/dist/observability/index.d.ts +3 -3
- package/dist/pipeline/index.d.ts +8 -8
- package/dist/pipeline/index.js +34 -19
- package/dist/pipeline/index.js.map +1 -1
- package/dist/request/index.d.ts +8 -8
- package/dist/request/index.js +8 -9
- package/dist/skills/index.d.ts +4 -4
- package/dist/skills/index.js +7 -7
- package/dist/{think-tool-BKDCOJh5.d.ts → think-tool-DvhOlrL8.d.ts} +1 -1
- package/dist/tool/index.d.ts +5 -5
- package/dist/tool/index.js +5 -6
- package/dist/{tool-f2stpvUP.d.ts → tool-6f9bK92X.d.ts} +1 -1
- package/dist/transcription/index.d.ts +1 -1
- package/dist/{types-5JgWDgaM.d.ts → types-BG3s2WzI.d.ts} +2 -2
- package/dist/{types-b6fOVoW1.d.ts → types-BZQlZ4Vs.d.ts} +1 -1
- package/dist/{types-Dh7gfoGw.d.ts → types-BaYwqozV.d.ts} +1 -1
- package/dist/{types-DmvXANwl.d.ts → types-C708DOhL.d.ts} +1 -1
- package/dist/{types-bNDxj4Tt.d.ts → types-CNeDsGjw.d.ts} +1 -1
- package/dist/{types-C15r7N_4.d.ts → types-DzdJOf35.d.ts} +17 -6
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +2 -2
- package/dist/vector-store/index.d.ts +4 -4
- package/dist/vector-store/index.js +3 -4
- package/package.json +1 -1
- package/dist/chunk-2STANSN6.js.map +0 -1
- package/dist/chunk-EGZCTSEW.js.map +0 -1
- package/dist/chunk-HF4KHHNM.js.map +0 -1
- package/dist/chunk-IZM6FNCT.js.map +0 -1
- package/dist/chunk-MMHG7WAM.js +0 -19
- package/dist/chunk-MMHG7WAM.js.map +0 -1
- package/dist/chunk-NPZDYOE6.js.map +0 -1
- package/dist/chunk-QVFOCNF6.js.map +0 -1
- package/dist/chunk-SHORX7TZ.js.map +0 -1
- package/dist/chunk-UDISNNKR.js.map +0 -1
- /package/dist/{chunk-IN5NPAWL.js.map → chunk-CLFDBOH3.js.map} +0 -0
- /package/dist/{chunk-WRNPY5C6.js.map → chunk-KXXFWLKP.js.map} +0 -0
- /package/dist/{chunk-FUJ3POKH.js.map → chunk-YTF65GYU.js.map} +0 -0
|
@@ -4,21 +4,15 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
parseToolArgs,
|
|
6
6
|
toolResultContentToText
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-WHHQWT7D.js";
|
|
8
8
|
import {
|
|
9
9
|
runControl,
|
|
10
10
|
toolCallControl
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import {
|
|
13
|
-
compact
|
|
14
|
-
} from "./chunk-MMHG7WAM.js";
|
|
15
|
-
import {
|
|
16
|
-
mapWithConcurrency
|
|
17
|
-
} from "./chunk-OIMLU4SF.js";
|
|
11
|
+
} from "./chunk-2ODTMRHP.js";
|
|
18
12
|
import {
|
|
19
13
|
CompletionRequestBuilder,
|
|
20
14
|
isStreamingCompletionModel
|
|
21
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-YTF65GYU.js";
|
|
22
16
|
import {
|
|
23
17
|
AssistantContent,
|
|
24
18
|
Message,
|
|
@@ -26,7 +20,10 @@ import {
|
|
|
26
20
|
Usage,
|
|
27
21
|
assertCompletionRequestSupported,
|
|
28
22
|
textFromAssistantContent
|
|
29
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-CNTGKNZ3.js";
|
|
24
|
+
import {
|
|
25
|
+
mapWithConcurrency
|
|
26
|
+
} from "./chunk-OIMLU4SF.js";
|
|
30
27
|
import {
|
|
31
28
|
appendGuardrailPolicies,
|
|
32
29
|
hasEnforcedOutputGuardrails,
|
|
@@ -245,13 +242,14 @@ async function fetchDynamicContext(agent, ragText) {
|
|
|
245
242
|
documents.push(formatted);
|
|
246
243
|
} else {
|
|
247
244
|
const metadata = formatMetadata(result.metadata);
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
245
|
+
const document = {
|
|
246
|
+
id: result.id,
|
|
247
|
+
text: typeof result.document === "string" ? result.document : JSON.stringify(result.document, null, 2)
|
|
248
|
+
};
|
|
249
|
+
if (metadata !== void 0) {
|
|
250
|
+
document.additionalProps = metadata;
|
|
251
|
+
}
|
|
252
|
+
documents.push(document);
|
|
255
253
|
}
|
|
256
254
|
}
|
|
257
255
|
}
|
|
@@ -397,15 +395,15 @@ var CompletionStreamAccumulator = class {
|
|
|
397
395
|
}
|
|
398
396
|
mergeFinalResponse(accumulatedResponse, finalResponse) {
|
|
399
397
|
if (finalResponse.choice.length === 0) {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
);
|
|
398
|
+
const mergedResponse = {
|
|
399
|
+
...accumulatedResponse,
|
|
400
|
+
usage: finalResponse.usage,
|
|
401
|
+
rawResponse: finalResponse.rawResponse
|
|
402
|
+
};
|
|
403
|
+
if (finalResponse.messageId !== void 0) {
|
|
404
|
+
mergedResponse.messageId = finalResponse.messageId;
|
|
405
|
+
}
|
|
406
|
+
return this.withMessageIdFallback(mergedResponse, accumulatedResponse);
|
|
409
407
|
}
|
|
410
408
|
const finalById = /* @__PURE__ */ new Map();
|
|
411
409
|
const finalByCallId = /* @__PURE__ */ new Map();
|
|
@@ -666,18 +664,23 @@ var ToolCallExecutor = class {
|
|
|
666
664
|
(definition) => definition.name === toolCall.function.name
|
|
667
665
|
);
|
|
668
666
|
const toolMetadata = toolTraceMetadata(tool);
|
|
669
|
-
const
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
667
|
+
const toolStartArgs = {
|
|
668
|
+
turn: observation?.turn ?? 0,
|
|
669
|
+
toolCall,
|
|
670
|
+
toolName: toolCall.function.name,
|
|
671
|
+
internalCallId,
|
|
672
|
+
args
|
|
673
|
+
};
|
|
674
|
+
if (toolCall.callId !== void 0) {
|
|
675
|
+
toolStartArgs.toolCallId = toolCall.callId;
|
|
676
|
+
}
|
|
677
|
+
if (toolDefinition !== void 0) {
|
|
678
|
+
toolStartArgs.toolDefinition = toolDefinition;
|
|
679
|
+
}
|
|
680
|
+
if (toolMetadata !== void 0) {
|
|
681
|
+
toolStartArgs.toolMetadata = toolMetadata;
|
|
682
|
+
}
|
|
683
|
+
const toolObservers = await observation?.runObservers.startTool(toolStartArgs);
|
|
681
684
|
let output;
|
|
682
685
|
let skipped = false;
|
|
683
686
|
let effectiveArgs = args;
|
|
@@ -805,17 +808,18 @@ var ToolCallExecutor = class {
|
|
|
805
808
|
try {
|
|
806
809
|
return await this.agent.callTool(toolCall.function.name, middlewareArgs, {
|
|
807
810
|
emitStreamEvent: async (event) => {
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
811
|
+
const streamEventArgs = {
|
|
812
|
+
turn: observation?.turn ?? 0,
|
|
813
|
+
toolCall,
|
|
814
|
+
toolName: toolCall.function.name,
|
|
815
|
+
internalCallId: hookArgs.internalCallId,
|
|
816
|
+
args: middlewareArgs,
|
|
817
|
+
event
|
|
818
|
+
};
|
|
819
|
+
if (toolCall.callId !== void 0) {
|
|
820
|
+
streamEventArgs.toolCallId = toolCall.callId;
|
|
821
|
+
}
|
|
822
|
+
await toolObservers?.streamEvent(streamEventArgs);
|
|
819
823
|
const payload = agentToolEventPayload(toolCall, hookArgs.internalCallId, event);
|
|
820
824
|
if (payload !== void 0) {
|
|
821
825
|
onStreamEvent?.(payload);
|
|
@@ -829,15 +833,15 @@ var ToolCallExecutor = class {
|
|
|
829
833
|
error,
|
|
830
834
|
run: runControl
|
|
831
835
|
});
|
|
832
|
-
await toolObservers?.error(
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
836
|
+
await toolObservers?.error(
|
|
837
|
+
toolErrorArgs(
|
|
838
|
+
observation?.turn ?? 0,
|
|
839
|
+
toolCall,
|
|
840
|
+
hookArgs.internalCallId,
|
|
841
|
+
middlewareArgs,
|
|
842
|
+
error
|
|
843
|
+
)
|
|
844
|
+
);
|
|
841
845
|
if (errorAction?.type === "terminate") {
|
|
842
846
|
throw this.cancel(errorAction.reason);
|
|
843
847
|
}
|
|
@@ -907,14 +911,28 @@ var ToolCallExecutor = class {
|
|
|
907
911
|
}
|
|
908
912
|
const reason = await resolveApprovalText(policy.reason, context);
|
|
909
913
|
const rejectMessage = await resolveApprovalText(policy.rejectMessage, context);
|
|
910
|
-
|
|
914
|
+
const options = {};
|
|
915
|
+
if (reason !== void 0) {
|
|
916
|
+
options.reason = reason;
|
|
917
|
+
}
|
|
918
|
+
if (rejectMessage !== void 0) {
|
|
919
|
+
options.rejectMessage = rejectMessage;
|
|
920
|
+
}
|
|
921
|
+
return this.requestApproval(tool, hookArgs, options);
|
|
911
922
|
}
|
|
912
923
|
async requestApproval(tool, hookArgs, options) {
|
|
913
|
-
const request =
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
924
|
+
const request = approvalContext(
|
|
925
|
+
tool,
|
|
926
|
+
hookArgs,
|
|
927
|
+
this.agent,
|
|
928
|
+
this.runContext
|
|
929
|
+
);
|
|
930
|
+
if (options.reason !== void 0) {
|
|
931
|
+
request.reason = options.reason;
|
|
932
|
+
}
|
|
933
|
+
if (options.rejectMessage !== void 0) {
|
|
934
|
+
request.rejectMessage = options.rejectMessage;
|
|
935
|
+
}
|
|
918
936
|
if (this.approvals === void 0) {
|
|
919
937
|
throw new ToolApprovalRequiredError(request);
|
|
920
938
|
}
|
|
@@ -931,19 +949,27 @@ var ToolCallExecutor = class {
|
|
|
931
949
|
function approvalContext(tool, hookArgs, agent, run) {
|
|
932
950
|
const rawParsedArgs = parseToolArgs(hookArgs.args);
|
|
933
951
|
const parsedArgs = tool?.parseApprovalArgs?.(rawParsedArgs) ?? rawParsedArgs;
|
|
934
|
-
|
|
952
|
+
const approvalRun = {
|
|
953
|
+
agentId: agent.id,
|
|
954
|
+
runId: run.runId
|
|
955
|
+
};
|
|
956
|
+
if (run.sessionId !== void 0) {
|
|
957
|
+
approvalRun.sessionId = run.sessionId;
|
|
958
|
+
}
|
|
959
|
+
if (run.metadata !== void 0) {
|
|
960
|
+
approvalRun.metadata = run.metadata;
|
|
961
|
+
}
|
|
962
|
+
const context = {
|
|
935
963
|
toolName: hookArgs.toolName,
|
|
936
964
|
args: parsedArgs,
|
|
937
965
|
rawArgs: hookArgs.args,
|
|
938
|
-
toolCallId: hookArgs.toolCallId,
|
|
939
966
|
internalCallId: hookArgs.internalCallId,
|
|
940
|
-
run:
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
});
|
|
967
|
+
run: approvalRun
|
|
968
|
+
};
|
|
969
|
+
if (hookArgs.toolCallId !== void 0) {
|
|
970
|
+
context.toolCallId = hookArgs.toolCallId;
|
|
971
|
+
}
|
|
972
|
+
return context;
|
|
947
973
|
}
|
|
948
974
|
function normalizeApprovalDecision(decision) {
|
|
949
975
|
if (typeof decision === "boolean") {
|
|
@@ -966,10 +992,27 @@ function toolTraceMetadata(tool) {
|
|
|
966
992
|
}
|
|
967
993
|
const metadata = tool[MCP_TOOL_METADATA_KEY];
|
|
968
994
|
const mcpMetadata = typeof metadata === "object" && metadata !== null ? metadata : void 0;
|
|
969
|
-
|
|
970
|
-
approvalRequired: tool.approval !== void 0
|
|
971
|
-
...typeof mcpMetadata?.serverName === "string" && mcpMetadata.serverName.length > 0 ? { mcpServerName: mcpMetadata.serverName } : {}
|
|
995
|
+
const result = {
|
|
996
|
+
approvalRequired: tool.approval !== void 0
|
|
972
997
|
};
|
|
998
|
+
if (typeof mcpMetadata?.serverName === "string" && mcpMetadata.serverName.length > 0) {
|
|
999
|
+
result.mcpServerName = mcpMetadata.serverName;
|
|
1000
|
+
}
|
|
1001
|
+
return result;
|
|
1002
|
+
}
|
|
1003
|
+
function toolErrorArgs(turn, toolCall, internalCallId, args, error) {
|
|
1004
|
+
const observerArgs = {
|
|
1005
|
+
turn,
|
|
1006
|
+
toolCall,
|
|
1007
|
+
toolName: toolCall.function.name,
|
|
1008
|
+
internalCallId,
|
|
1009
|
+
args,
|
|
1010
|
+
error
|
|
1011
|
+
};
|
|
1012
|
+
if (toolCall.callId !== void 0) {
|
|
1013
|
+
observerArgs.toolCallId = toolCall.callId;
|
|
1014
|
+
}
|
|
1015
|
+
return observerArgs;
|
|
973
1016
|
}
|
|
974
1017
|
async function recordToolError(toolObservers, turn, toolCall, internalCallId, args, error) {
|
|
975
1018
|
await toolObservers?.error({
|
|
@@ -992,15 +1035,20 @@ function agentToolEventPayload(toolCall, internalCallId, event) {
|
|
|
992
1035
|
if (typeof event.agentId !== "string" || event.agentId.length === 0) {
|
|
993
1036
|
return void 0;
|
|
994
1037
|
}
|
|
995
|
-
|
|
1038
|
+
const payload = {
|
|
996
1039
|
type: "agent_tool_event",
|
|
997
1040
|
toolName: toolCall.function.name,
|
|
998
|
-
toolCallId: toolCall.callId,
|
|
999
1041
|
internalCallId,
|
|
1000
1042
|
agentId: event.agentId,
|
|
1001
|
-
agentName: event.agentName,
|
|
1002
1043
|
event: event.event
|
|
1003
|
-
}
|
|
1044
|
+
};
|
|
1045
|
+
if (toolCall.callId !== void 0) {
|
|
1046
|
+
payload.toolCallId = toolCall.callId;
|
|
1047
|
+
}
|
|
1048
|
+
if (event.agentName !== void 0) {
|
|
1049
|
+
payload.agentName = event.agentName;
|
|
1050
|
+
}
|
|
1051
|
+
return payload;
|
|
1004
1052
|
}
|
|
1005
1053
|
|
|
1006
1054
|
// src/internal/rag-text.ts
|
|
@@ -1528,16 +1576,7 @@ var PromptRequest = class _PromptRequest {
|
|
|
1528
1576
|
assertCompletionRequestSupported(this.agent.model, request, { streaming: true });
|
|
1529
1577
|
const providerRequest = this.providerTraceRequest(request, { stream: true });
|
|
1530
1578
|
const generationObservers = await runObservers.startGeneration(
|
|
1531
|
-
|
|
1532
|
-
turn: currentTurns,
|
|
1533
|
-
request,
|
|
1534
|
-
providerRequest,
|
|
1535
|
-
modelInfo: {
|
|
1536
|
-
provider: this.agent.model.provider,
|
|
1537
|
-
defaultModel: this.agent.model.defaultModel,
|
|
1538
|
-
capabilities: this.agent.model.capabilities
|
|
1539
|
-
}
|
|
1540
|
-
})
|
|
1579
|
+
this.generationStartArgs(currentTurns, request, providerRequest)
|
|
1541
1580
|
);
|
|
1542
1581
|
const accumulator = new CompletionStreamAccumulator();
|
|
1543
1582
|
const generationStartedAt = Date.now();
|
|
@@ -1570,13 +1609,14 @@ var PromptRequest = class _PromptRequest {
|
|
|
1570
1609
|
throw error;
|
|
1571
1610
|
}
|
|
1572
1611
|
let response = accumulator.response();
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1612
|
+
const generationEndArgs = {
|
|
1613
|
+
turn: currentTurns,
|
|
1614
|
+
response
|
|
1615
|
+
};
|
|
1616
|
+
if (firstDeltaMs !== void 0) {
|
|
1617
|
+
generationEndArgs.firstDeltaMs = firstDeltaMs;
|
|
1618
|
+
}
|
|
1619
|
+
await generationObservers.end(generationEndArgs);
|
|
1580
1620
|
response = await this.runCompletionResponseMiddlewares(request, response, currentTurns);
|
|
1581
1621
|
usage = Usage.add(usage, response.usage);
|
|
1582
1622
|
await this.runCompletionResponseHook(prompt, response, newMessages);
|
|
@@ -1734,16 +1774,7 @@ var PromptRequest = class _PromptRequest {
|
|
|
1734
1774
|
assertCompletionRequestSupported(this.agent.model, request);
|
|
1735
1775
|
const providerRequest = this.providerTraceRequest(request);
|
|
1736
1776
|
const generationObservers = await runObservers.startGeneration(
|
|
1737
|
-
|
|
1738
|
-
turn,
|
|
1739
|
-
request,
|
|
1740
|
-
providerRequest,
|
|
1741
|
-
modelInfo: {
|
|
1742
|
-
provider: this.agent.model.provider,
|
|
1743
|
-
defaultModel: this.agent.model.defaultModel,
|
|
1744
|
-
capabilities: this.agent.model.capabilities
|
|
1745
|
-
}
|
|
1746
|
-
})
|
|
1777
|
+
this.generationStartArgs(turn, request, providerRequest)
|
|
1747
1778
|
);
|
|
1748
1779
|
try {
|
|
1749
1780
|
const response = await this.agent.model.completion(request);
|
|
@@ -1763,6 +1794,21 @@ var PromptRequest = class _PromptRequest {
|
|
|
1763
1794
|
};
|
|
1764
1795
|
}
|
|
1765
1796
|
}
|
|
1797
|
+
generationStartArgs(turn, request, providerRequest) {
|
|
1798
|
+
const args = {
|
|
1799
|
+
turn,
|
|
1800
|
+
request,
|
|
1801
|
+
modelInfo: {
|
|
1802
|
+
provider: this.agent.model.provider,
|
|
1803
|
+
defaultModel: this.agent.model.defaultModel,
|
|
1804
|
+
capabilities: this.agent.model.capabilities
|
|
1805
|
+
}
|
|
1806
|
+
};
|
|
1807
|
+
if (providerRequest !== void 0) {
|
|
1808
|
+
args.providerRequest = providerRequest;
|
|
1809
|
+
}
|
|
1810
|
+
return args;
|
|
1811
|
+
}
|
|
1766
1812
|
async executeToolCalls(runId, toolCalls, newMessages, onResult, onStreamEvent, observation) {
|
|
1767
1813
|
const executor = new ToolCallExecutor(
|
|
1768
1814
|
this.agent,
|
|
@@ -1812,12 +1858,17 @@ var PromptRequest = class _PromptRequest {
|
|
|
1812
1858
|
});
|
|
1813
1859
|
}
|
|
1814
1860
|
guardrailRunContext(runId) {
|
|
1815
|
-
|
|
1861
|
+
const context = {
|
|
1816
1862
|
agentId: this.agent.id,
|
|
1817
|
-
runId
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1863
|
+
runId
|
|
1864
|
+
};
|
|
1865
|
+
if (this.memoryContext !== void 0) {
|
|
1866
|
+
context.sessionId = this.memoryContext.sessionId;
|
|
1867
|
+
if (this.memoryContext.metadata !== void 0) {
|
|
1868
|
+
context.metadata = this.memoryContext.metadata;
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
return context;
|
|
1821
1872
|
}
|
|
1822
1873
|
async startRunObservers() {
|
|
1823
1874
|
const failOnObserverError = this.traceOptions?.failOnObserverError === true || this.agent.observers.some((registration) => registration.failOnObserverError === true);
|
|
@@ -1846,17 +1897,25 @@ var PromptRequest = class _PromptRequest {
|
|
|
1846
1897
|
const turn = "turn" in event ? event.turn : void 0;
|
|
1847
1898
|
const agentId = event.type === "agent_tool_event" ? event.agentId : this.agent.id;
|
|
1848
1899
|
const agentName = event.type === "agent_tool_event" ? event.agentName : this.agent.name;
|
|
1849
|
-
|
|
1900
|
+
const input = {
|
|
1850
1901
|
runId,
|
|
1851
1902
|
agentId,
|
|
1852
|
-
...compact({ agentName, turn }),
|
|
1853
|
-
...event.type === "agent_tool_event" ? compact({
|
|
1854
|
-
toolName: event.toolName,
|
|
1855
|
-
toolCallId: event.toolCallId,
|
|
1856
|
-
internalCallId: event.internalCallId
|
|
1857
|
-
}) : {},
|
|
1858
1903
|
event
|
|
1859
|
-
}
|
|
1904
|
+
};
|
|
1905
|
+
if (agentName !== void 0) {
|
|
1906
|
+
input.agentName = agentName;
|
|
1907
|
+
}
|
|
1908
|
+
if (turn !== void 0) {
|
|
1909
|
+
input.turn = turn;
|
|
1910
|
+
}
|
|
1911
|
+
if (event.type === "agent_tool_event") {
|
|
1912
|
+
input.toolName = event.toolName;
|
|
1913
|
+
input.internalCallId = event.internalCallId;
|
|
1914
|
+
if (event.toolCallId !== void 0) {
|
|
1915
|
+
input.toolCallId = event.toolCallId;
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
await registration.store.append(input);
|
|
1860
1919
|
}
|
|
1861
1920
|
async runCompletionCallHook(prompt, history, newMessages) {
|
|
1862
1921
|
const action = await this.activeHook?.onCompletionCall?.({
|
|
@@ -2041,19 +2100,14 @@ function responseStreamEvents(turn, response) {
|
|
|
2041
2100
|
if (item.type === "reasoning") {
|
|
2042
2101
|
if (item.content === void 0) {
|
|
2043
2102
|
if (item.text.length > 0) {
|
|
2044
|
-
events.push(
|
|
2045
|
-
compact({ type: "reasoning_delta", turn, delta: item.text, id: item.id })
|
|
2046
|
-
);
|
|
2103
|
+
events.push(reasoningDeltaEvent2(turn, item.text, { id: item.id }));
|
|
2047
2104
|
}
|
|
2048
2105
|
continue;
|
|
2049
2106
|
}
|
|
2050
2107
|
for (const content of item.content) {
|
|
2051
2108
|
const delta = content.type === "encrypted" || content.type === "redacted" ? content.data : content.text;
|
|
2052
2109
|
events.push(
|
|
2053
|
-
|
|
2054
|
-
type: "reasoning_delta",
|
|
2055
|
-
turn,
|
|
2056
|
-
delta,
|
|
2110
|
+
reasoningDeltaEvent2(turn, delta, {
|
|
2057
2111
|
id: item.id,
|
|
2058
2112
|
contentType: content.type,
|
|
2059
2113
|
signature: content.type === "text" ? content.signature : void 0
|
|
@@ -2068,6 +2122,23 @@ function responseStreamEvents(turn, response) {
|
|
|
2068
2122
|
}
|
|
2069
2123
|
return events;
|
|
2070
2124
|
}
|
|
2125
|
+
function reasoningDeltaEvent2(turn, delta, details = {}) {
|
|
2126
|
+
const event = {
|
|
2127
|
+
type: "reasoning_delta",
|
|
2128
|
+
turn,
|
|
2129
|
+
delta
|
|
2130
|
+
};
|
|
2131
|
+
if (details.id !== void 0) {
|
|
2132
|
+
event.id = details.id;
|
|
2133
|
+
}
|
|
2134
|
+
if (details.contentType !== void 0) {
|
|
2135
|
+
event.contentType = details.contentType;
|
|
2136
|
+
}
|
|
2137
|
+
if (details.signature !== void 0) {
|
|
2138
|
+
event.signature = details.signature;
|
|
2139
|
+
}
|
|
2140
|
+
return event;
|
|
2141
|
+
}
|
|
2071
2142
|
function textFromMessage(message) {
|
|
2072
2143
|
if (message.role === "system") {
|
|
2073
2144
|
return message.content;
|
|
@@ -2083,17 +2154,22 @@ function textFromMessage(message) {
|
|
|
2083
2154
|
}).join("\n");
|
|
2084
2155
|
}
|
|
2085
2156
|
function guardrailDecisionAttributes(decision) {
|
|
2086
|
-
|
|
2157
|
+
const attributes = {
|
|
2087
2158
|
policyId: decision.policyId,
|
|
2088
2159
|
guardrailId: decision.guardrailId,
|
|
2089
2160
|
boundary: decision.boundary,
|
|
2090
2161
|
mode: decision.mode,
|
|
2091
2162
|
action: decision.action,
|
|
2092
2163
|
applied: decision.applied,
|
|
2093
|
-
reason: decision.reason,
|
|
2094
|
-
message: decision.message,
|
|
2095
2164
|
latencyMs: decision.latencyMs
|
|
2096
|
-
}
|
|
2165
|
+
};
|
|
2166
|
+
if (decision.reason !== void 0) {
|
|
2167
|
+
attributes.reason = decision.reason;
|
|
2168
|
+
}
|
|
2169
|
+
if (decision.message !== void 0) {
|
|
2170
|
+
attributes.message = decision.message;
|
|
2171
|
+
}
|
|
2172
|
+
return attributes;
|
|
2097
2173
|
}
|
|
2098
2174
|
|
|
2099
2175
|
export {
|
|
@@ -2103,4 +2179,4 @@ export {
|
|
|
2103
2179
|
extractRagText,
|
|
2104
2180
|
PromptRequest
|
|
2105
2181
|
};
|
|
2106
|
-
//# sourceMappingURL=chunk-
|
|
2182
|
+
//# sourceMappingURL=chunk-WWNXZWST.js.map
|