@anvia/core 0.15.0 → 0.17.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/agent/index.d.ts +14 -13
- package/dist/agent/index.js +8 -8
- package/dist/{agent-C1yoidvI.d.ts → agent-Cg0UigNK.d.ts} +9 -7
- package/dist/audio-generation/index.d.ts +1 -1
- package/dist/{chunk-BPU264XB.js → chunk-54S4I3SX.js} +7 -7
- package/dist/chunk-54S4I3SX.js.map +1 -0
- package/dist/{chunk-DC2GJDPR.js → chunk-77D7XBWL.js} +2 -2
- package/dist/{chunk-GCZIIYZW.js → chunk-BQCTJSNL.js} +7 -5
- package/dist/chunk-BQCTJSNL.js.map +1 -0
- package/dist/{chunk-I7TM7TKX.js → chunk-F3C5653H.js} +4 -4
- package/dist/{chunk-QTZHDPQX.js → chunk-GCED5ZNM.js} +16 -4
- package/dist/chunk-GCED5ZNM.js.map +1 -0
- package/dist/{chunk-CNANX5OL.js → chunk-OPAEENGD.js} +141 -25
- package/dist/chunk-OPAEENGD.js.map +1 -0
- package/dist/{chunk-TIV3WFSR.js → chunk-PJDL5UT2.js} +84 -5
- package/dist/chunk-PJDL5UT2.js.map +1 -0
- package/dist/{chunk-7NULHGAO.js → chunk-RWAOHGRL.js} +16 -5
- package/dist/chunk-RWAOHGRL.js.map +1 -0
- package/dist/{chunk-MEUZ4NBO.js → chunk-SWUH4G2I.js} +2 -2
- package/dist/{chunk-BIYXGG33.js → chunk-SWUIBS4N.js} +6 -6
- package/dist/completion/index.d.ts +6 -5
- package/dist/completion/index.js +4 -2
- package/dist/evals/index.d.ts +8 -8
- package/dist/evals/index.js +9 -9
- package/dist/extractor/index.d.ts +8 -8
- package/dist/extractor/index.js +9 -9
- package/dist/guardrails/index.d.ts +1 -1
- package/dist/hooks/index.d.ts +3 -3
- package/dist/image-generation/index.d.ts +1 -1
- package/dist/{index-VH93vDXo.d.ts → index-XTUEMWhU.d.ts} +36 -8
- package/dist/index.d.ts +12 -12
- package/dist/index.js +14 -12
- package/dist/internal/agent.d.ts +8 -8
- package/dist/internal/agent.js +7 -7
- package/dist/{json-CaCUxJqG.d.ts → json-D9IvOgx_.d.ts} +2 -2
- package/dist/loaders/index.d.ts +1 -1
- package/dist/mcp/index.d.ts +4 -4
- package/dist/memory/index.d.ts +3 -3
- package/dist/{middleware-CGEYQndv.d.ts → middleware-Cp0tm6zE.d.ts} +3 -3
- package/dist/observability/index.d.ts +3 -3
- package/dist/observability/index.js.map +1 -1
- package/dist/pipeline/index.d.ts +8 -8
- package/dist/request/index.d.ts +8 -8
- package/dist/request/index.js +6 -6
- package/dist/skills/index.d.ts +4 -4
- package/dist/skills/index.js +5 -5
- package/dist/{think-tool-DABDgW_E.d.ts → think-tool-CpCKo8Q8.d.ts} +1 -1
- package/dist/tool/index.d.ts +5 -5
- package/dist/tool/index.js +5 -5
- package/dist/{tool-tHPNeWMR.d.ts → tool-Dhwg__1L.d.ts} +1 -1
- package/dist/transcription/index.d.ts +1 -1
- package/dist/{types-BbLcbRqM.d.ts → types-BBEf34DP.d.ts} +2 -2
- package/dist/{types-D78Vnorg.d.ts → types-BCA8p0sb.d.ts} +1 -1
- package/dist/{types-DPYoqg8M.d.ts → types-CBmhLT_r.d.ts} +1 -1
- package/dist/{types-BHxJcHMk.d.ts → types-DMGvEFRf.d.ts} +1 -1
- package/dist/{types-Byo50mwr.d.ts → types-XjIh933x.d.ts} +49 -1
- package/dist/{types-DW1Va3vx.d.ts → types-fBv8mhvP.d.ts} +1 -1
- 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 +2 -2
- package/package.json +1 -1
- package/dist/chunk-7NULHGAO.js.map +0 -1
- package/dist/chunk-BPU264XB.js.map +0 -1
- package/dist/chunk-CNANX5OL.js.map +0 -1
- package/dist/chunk-GCZIIYZW.js.map +0 -1
- package/dist/chunk-QTZHDPQX.js.map +0 -1
- package/dist/chunk-TIV3WFSR.js.map +0 -1
- /package/dist/{chunk-DC2GJDPR.js.map → chunk-77D7XBWL.js.map} +0 -0
- /package/dist/{chunk-I7TM7TKX.js.map → chunk-F3C5653H.js.map} +0 -0
- /package/dist/{chunk-MEUZ4NBO.js.map → chunk-SWUH4G2I.js.map} +0 -0
- /package/dist/{chunk-BIYXGG33.js.map → chunk-SWUIBS4N.js.map} +0 -0
|
@@ -4,26 +4,27 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
parseToolArgs,
|
|
6
6
|
toolResultContentToText
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-SWUIBS4N.js";
|
|
8
8
|
import {
|
|
9
9
|
runControl,
|
|
10
10
|
toolCallControl
|
|
11
11
|
} from "./chunk-2ODTMRHP.js";
|
|
12
|
+
import {
|
|
13
|
+
mapWithConcurrency
|
|
14
|
+
} from "./chunk-OIMLU4SF.js";
|
|
12
15
|
import {
|
|
13
16
|
CompletionRequestBuilder,
|
|
14
17
|
isStreamingCompletionModel
|
|
15
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-GCED5ZNM.js";
|
|
16
19
|
import {
|
|
17
20
|
AssistantContent,
|
|
18
21
|
Message,
|
|
19
22
|
ToolContent,
|
|
20
23
|
Usage,
|
|
21
24
|
assertCompletionRequestSupported,
|
|
25
|
+
getAssistantGenerationMetadata,
|
|
22
26
|
textFromAssistantContent
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import {
|
|
25
|
-
mapWithConcurrency
|
|
26
|
-
} from "./chunk-OIMLU4SF.js";
|
|
27
|
+
} from "./chunk-PJDL5UT2.js";
|
|
27
28
|
import {
|
|
28
29
|
appendGuardrailPolicies,
|
|
29
30
|
hasEnforcedOutputGuardrails,
|
|
@@ -293,6 +294,8 @@ var CompletionStreamAccumulator = class {
|
|
|
293
294
|
reasoningByKey = /* @__PURE__ */ new Map();
|
|
294
295
|
reasoningKeyById = /* @__PURE__ */ new Map();
|
|
295
296
|
toolCalls = /* @__PURE__ */ new Map();
|
|
297
|
+
sources = /* @__PURE__ */ new Map();
|
|
298
|
+
providerToolCalls = /* @__PURE__ */ new Map();
|
|
296
299
|
finalResponse;
|
|
297
300
|
messageId;
|
|
298
301
|
nextTextKey = 0;
|
|
@@ -325,6 +328,14 @@ var CompletionStreamAccumulator = class {
|
|
|
325
328
|
this.upsertToolCall(event.toolCall);
|
|
326
329
|
return { type: "tool_call", toolCall: event.toolCall };
|
|
327
330
|
}
|
|
331
|
+
if (event.type === "source") {
|
|
332
|
+
this.sources.set(sourceKey(event.source), event.source);
|
|
333
|
+
return { type: "source", source: event.source };
|
|
334
|
+
}
|
|
335
|
+
if (event.type === "provider_tool_call") {
|
|
336
|
+
this.providerToolCalls.set(event.toolCall.id, event.toolCall);
|
|
337
|
+
return { type: "provider_tool_call", toolCall: event.toolCall };
|
|
338
|
+
}
|
|
328
339
|
if (event.type === "message_id") {
|
|
329
340
|
this.messageId = event.id;
|
|
330
341
|
return void 0;
|
|
@@ -339,7 +350,7 @@ var CompletionStreamAccumulator = class {
|
|
|
339
350
|
const accumulatedResponse = this.buildAccumulatedResponse();
|
|
340
351
|
if (this.finalResponse !== void 0) {
|
|
341
352
|
if (accumulatedResponse.choice.length === 0) {
|
|
342
|
-
return this.
|
|
353
|
+
return this.withAccumulatedArtifacts(this.finalResponse, accumulatedResponse);
|
|
343
354
|
}
|
|
344
355
|
return this.mergeFinalResponse(accumulatedResponse, this.finalResponse);
|
|
345
356
|
}
|
|
@@ -377,6 +388,14 @@ var CompletionStreamAccumulator = class {
|
|
|
377
388
|
if (this.messageId !== void 0) {
|
|
378
389
|
response.messageId = this.messageId;
|
|
379
390
|
}
|
|
391
|
+
const sources = [...this.sources.values()];
|
|
392
|
+
if (sources.length > 0) {
|
|
393
|
+
response.sources = sources;
|
|
394
|
+
}
|
|
395
|
+
const providerToolCalls = [...this.providerToolCalls.values()];
|
|
396
|
+
if (providerToolCalls.length > 0) {
|
|
397
|
+
response.providerToolCalls = providerToolCalls;
|
|
398
|
+
}
|
|
380
399
|
return response;
|
|
381
400
|
}
|
|
382
401
|
upsertToolCall(toolCall) {
|
|
@@ -409,7 +428,7 @@ var CompletionStreamAccumulator = class {
|
|
|
409
428
|
if (finalResponse.messageId !== void 0) {
|
|
410
429
|
mergedResponse.messageId = finalResponse.messageId;
|
|
411
430
|
}
|
|
412
|
-
return this.
|
|
431
|
+
return this.withAccumulatedArtifacts(mergedResponse, accumulatedResponse);
|
|
413
432
|
}
|
|
414
433
|
const finalById = /* @__PURE__ */ new Map();
|
|
415
434
|
const finalByCallId = /* @__PURE__ */ new Map();
|
|
@@ -442,7 +461,7 @@ var CompletionStreamAccumulator = class {
|
|
|
442
461
|
choice.push(content);
|
|
443
462
|
}
|
|
444
463
|
}
|
|
445
|
-
return this.
|
|
464
|
+
return this.withAccumulatedArtifacts({ ...finalResponse, choice }, accumulatedResponse);
|
|
446
465
|
}
|
|
447
466
|
appendText(delta) {
|
|
448
467
|
const lastPart = this.orderedParts.at(-1);
|
|
@@ -501,6 +520,19 @@ var CompletionStreamAccumulator = class {
|
|
|
501
520
|
}
|
|
502
521
|
return { ...response, messageId: accumulatedResponse.messageId };
|
|
503
522
|
}
|
|
523
|
+
withAccumulatedArtifacts(response, accumulatedResponse) {
|
|
524
|
+
const withMessageId = this.withMessageIdFallback(response, accumulatedResponse);
|
|
525
|
+
const sources = mergeSources(accumulatedResponse.sources, response.sources);
|
|
526
|
+
const providerToolCalls = mergeProviderToolCalls(
|
|
527
|
+
accumulatedResponse.providerToolCalls,
|
|
528
|
+
response.providerToolCalls
|
|
529
|
+
);
|
|
530
|
+
return {
|
|
531
|
+
...withMessageId,
|
|
532
|
+
...sources.length === 0 ? {} : { sources },
|
|
533
|
+
...providerToolCalls.length === 0 ? {} : { providerToolCalls }
|
|
534
|
+
};
|
|
535
|
+
}
|
|
504
536
|
createTextKey() {
|
|
505
537
|
this.nextTextKey += 1;
|
|
506
538
|
return `text_${this.nextTextKey.toString()}`;
|
|
@@ -547,6 +579,23 @@ var CompletionStreamAccumulator = class {
|
|
|
547
579
|
reasoning.content.push({ type: "redacted", data: event.delta });
|
|
548
580
|
}
|
|
549
581
|
};
|
|
582
|
+
function sourceKey(source) {
|
|
583
|
+
return `${source.url}\0${source.startIndex ?? ""}\0${source.endIndex ?? ""}`;
|
|
584
|
+
}
|
|
585
|
+
function mergeSources(accumulated, final) {
|
|
586
|
+
const sources = /* @__PURE__ */ new Map();
|
|
587
|
+
for (const source of [...accumulated ?? [], ...final ?? []]) {
|
|
588
|
+
sources.set(sourceKey(source), source);
|
|
589
|
+
}
|
|
590
|
+
return [...sources.values()];
|
|
591
|
+
}
|
|
592
|
+
function mergeProviderToolCalls(accumulated, final) {
|
|
593
|
+
const toolCalls = /* @__PURE__ */ new Map();
|
|
594
|
+
for (const toolCall of [...accumulated ?? [], ...final ?? []]) {
|
|
595
|
+
toolCalls.set(toolCall.id, toolCall);
|
|
596
|
+
}
|
|
597
|
+
return [...toolCalls.values()];
|
|
598
|
+
}
|
|
550
599
|
function reasoningContent(reasoning) {
|
|
551
600
|
const content = reasoning.content === void 0 ? { type: "reasoning", text: reasoning.text } : { type: "reasoning", text: reasoning.text, content: reasoning.content };
|
|
552
601
|
return reasoning.id === void 0 ? content : { ...content, id: reasoning.id };
|
|
@@ -642,6 +691,12 @@ function addTurn(turn, event) {
|
|
|
642
691
|
if (event.signature !== void 0) mapped.signature = event.signature;
|
|
643
692
|
return mapped;
|
|
644
693
|
}
|
|
694
|
+
if (event.type === "source") {
|
|
695
|
+
return { type: "source", turn, source: event.source };
|
|
696
|
+
}
|
|
697
|
+
if (event.type === "provider_tool_call") {
|
|
698
|
+
return { type: "provider_tool_call", turn, toolCall: event.toolCall };
|
|
699
|
+
}
|
|
645
700
|
return { type: "tool_call", turn, toolCall: event.toolCall };
|
|
646
701
|
}
|
|
647
702
|
function addTurnToToolCallDelta(turn, event) {
|
|
@@ -658,7 +713,7 @@ function addTurnToToolCallDelta(turn, event) {
|
|
|
658
713
|
return mapped;
|
|
659
714
|
}
|
|
660
715
|
function isGenerationDeltaEvent(type) {
|
|
661
|
-
return type === "text_delta" || type === "reasoning_delta" || type === "tool_call_delta" || type === "tool_call";
|
|
716
|
+
return type === "text_delta" || type === "reasoning_delta" || type === "tool_call_delta" || type === "tool_call" || type === "source" || type === "provider_tool_call";
|
|
662
717
|
}
|
|
663
718
|
|
|
664
719
|
// src/internal/prompt-runtime/tool-execution.ts
|
|
@@ -1589,7 +1644,7 @@ var PromptRequest = class _PromptRequest {
|
|
|
1589
1644
|
const ragText = extractRagText(prompt);
|
|
1590
1645
|
const dynamicContext = await fetchDynamicContext(this.agent, ragText);
|
|
1591
1646
|
const toolDefs = await fetchToolDefinitions(this.agent, ragText);
|
|
1592
|
-
let request = new CompletionRequestBuilder(this.agent.model, prompt).instructions(this.agent.instructions).messages(historyForRequest).documents([...this.agent.staticContext, ...dynamicContext]).tools(toolDefs).temperature(this.agent.temperature).maxTokens(this.agent.maxTokens).additionalParams(this.agent.additionalParams).toolChoice(this.agent.toolChoice).outputSchema(this.agent.outputSchema).build();
|
|
1647
|
+
let request = new CompletionRequestBuilder(this.agent.model, prompt).instructions(this.agent.instructions).messages(historyForRequest).documents([...this.agent.staticContext, ...dynamicContext]).tools([...toolDefs, ...this.agent.providerTools]).temperature(this.agent.temperature).maxTokens(this.agent.maxTokens).additionalParams(this.agent.additionalParams).toolChoice(this.agent.toolChoice).outputSchema(this.agent.outputSchema).build();
|
|
1593
1648
|
request = await this.runCompletionRequestMiddlewares(
|
|
1594
1649
|
request,
|
|
1595
1650
|
currentTurns
|
|
@@ -1644,7 +1699,8 @@ var PromptRequest = class _PromptRequest {
|
|
|
1644
1699
|
usage,
|
|
1645
1700
|
messages: [...newMessages],
|
|
1646
1701
|
trace: runObservers.trace,
|
|
1647
|
-
guardrails: [...this.guardrailDecisions]
|
|
1702
|
+
guardrails: [...this.guardrailDecisions],
|
|
1703
|
+
...generationArtifacts(newMessages)
|
|
1648
1704
|
};
|
|
1649
1705
|
await this.runRunEndHook(result, newMessages);
|
|
1650
1706
|
await runObservers.end(result);
|
|
@@ -1767,18 +1823,27 @@ var PromptRequest = class _PromptRequest {
|
|
|
1767
1823
|
const ragText = extractRagText(prompt);
|
|
1768
1824
|
const dynamicContext = await fetchDynamicContext(this.agent, ragText);
|
|
1769
1825
|
const toolDefs = await fetchToolDefinitions(this.agent, ragText);
|
|
1770
|
-
let request = new CompletionRequestBuilder(this.agent.model, prompt).instructions(this.agent.instructions).messages(historyForRequest).documents([...this.agent.staticContext, ...dynamicContext]).tools(toolDefs).temperature(this.agent.temperature).maxTokens(this.agent.maxTokens).additionalParams(this.agent.additionalParams).toolChoice(this.agent.toolChoice).outputSchema(this.agent.outputSchema).build();
|
|
1826
|
+
let request = new CompletionRequestBuilder(this.agent.model, prompt).instructions(this.agent.instructions).messages(historyForRequest).documents([...this.agent.staticContext, ...dynamicContext]).tools([...toolDefs, ...this.agent.providerTools]).temperature(this.agent.temperature).maxTokens(this.agent.maxTokens).additionalParams(this.agent.additionalParams).toolChoice(this.agent.toolChoice).outputSchema(this.agent.outputSchema).build();
|
|
1771
1827
|
request = await this.runCompletionRequestMiddlewares(
|
|
1772
1828
|
request,
|
|
1773
1829
|
currentTurns
|
|
1774
1830
|
);
|
|
1775
1831
|
assertCompletionRequestSupported(this.agent.model, request, { streaming: true });
|
|
1776
1832
|
const providerRequest = this.providerTraceRequest(request, { stream: true });
|
|
1777
|
-
const
|
|
1778
|
-
|
|
1833
|
+
const generationStartArgs = this.generationStartArgs(
|
|
1834
|
+
currentTurns,
|
|
1835
|
+
request,
|
|
1836
|
+
providerRequest
|
|
1779
1837
|
);
|
|
1780
|
-
const
|
|
1838
|
+
const generationObservers = await runObservers.startGeneration(generationStartArgs);
|
|
1781
1839
|
const generationStartedAt = Date.now();
|
|
1840
|
+
yield await emit({
|
|
1841
|
+
type: "generation_start",
|
|
1842
|
+
turn: currentTurns,
|
|
1843
|
+
request,
|
|
1844
|
+
modelInfo: generationStartArgs.modelInfo
|
|
1845
|
+
});
|
|
1846
|
+
const accumulator = new CompletionStreamAccumulator();
|
|
1782
1847
|
let firstDeltaMs;
|
|
1783
1848
|
const bufferResponseEvents = this.shouldBufferStreamResponseEvents();
|
|
1784
1849
|
const emittedToolCallIds = /* @__PURE__ */ new Set();
|
|
@@ -1860,7 +1925,12 @@ var PromptRequest = class _PromptRequest {
|
|
|
1860
1925
|
yield await emit(event);
|
|
1861
1926
|
}
|
|
1862
1927
|
}
|
|
1863
|
-
yield await emit({
|
|
1928
|
+
yield await emit({
|
|
1929
|
+
type: "turn_end",
|
|
1930
|
+
turn: currentTurns,
|
|
1931
|
+
response,
|
|
1932
|
+
firstDeltaMs
|
|
1933
|
+
});
|
|
1864
1934
|
emittedTurnEnd = true;
|
|
1865
1935
|
}
|
|
1866
1936
|
if (this.steeringMessages.length > 0) {
|
|
@@ -1895,19 +1965,29 @@ var PromptRequest = class _PromptRequest {
|
|
|
1895
1965
|
pendingTurnMessages
|
|
1896
1966
|
);
|
|
1897
1967
|
if (!emittedTurnEnd && (bufferResponseEvents || bufferOutputDeltas)) {
|
|
1898
|
-
for (const event of responseStreamEvents(
|
|
1968
|
+
for (const event of responseStreamEvents(
|
|
1969
|
+
currentTurns,
|
|
1970
|
+
response,
|
|
1971
|
+
bufferResponseEvents
|
|
1972
|
+
)) {
|
|
1899
1973
|
yield await emit(event);
|
|
1900
1974
|
}
|
|
1901
1975
|
}
|
|
1902
1976
|
if (!emittedTurnEnd) {
|
|
1903
|
-
yield await emit({
|
|
1977
|
+
yield await emit({
|
|
1978
|
+
type: "turn_end",
|
|
1979
|
+
turn: currentTurns,
|
|
1980
|
+
response,
|
|
1981
|
+
firstDeltaMs
|
|
1982
|
+
});
|
|
1904
1983
|
}
|
|
1905
1984
|
const result = {
|
|
1906
1985
|
output: guardedOutput.output,
|
|
1907
1986
|
usage,
|
|
1908
1987
|
messages: [...newMessages],
|
|
1909
1988
|
trace: runObservers.trace,
|
|
1910
|
-
guardrails: [...this.guardrailDecisions]
|
|
1989
|
+
guardrails: [...this.guardrailDecisions],
|
|
1990
|
+
...generationArtifacts(newMessages)
|
|
1911
1991
|
};
|
|
1912
1992
|
await this.runRunEndHook(result, newMessages);
|
|
1913
1993
|
await runObservers.end(result);
|
|
@@ -1925,7 +2005,9 @@ var PromptRequest = class _PromptRequest {
|
|
|
1925
2005
|
usage: result.usage,
|
|
1926
2006
|
messages: result.messages,
|
|
1927
2007
|
trace: result.trace,
|
|
1928
|
-
guardrails: result.guardrails
|
|
2008
|
+
guardrails: result.guardrails,
|
|
2009
|
+
sources: result.sources,
|
|
2010
|
+
providerToolCalls: result.providerToolCalls
|
|
1929
2011
|
});
|
|
1930
2012
|
return;
|
|
1931
2013
|
}
|
|
@@ -1946,7 +2028,12 @@ var PromptRequest = class _PromptRequest {
|
|
|
1946
2028
|
[assistantMessage],
|
|
1947
2029
|
pendingTurnMessages
|
|
1948
2030
|
);
|
|
1949
|
-
yield await emit({
|
|
2031
|
+
yield await emit({
|
|
2032
|
+
type: "turn_end",
|
|
2033
|
+
turn: currentTurns,
|
|
2034
|
+
response,
|
|
2035
|
+
firstDeltaMs
|
|
2036
|
+
});
|
|
1950
2037
|
const toolResultEvents = createAsyncQueue();
|
|
1951
2038
|
const toolResultsPromise = this.executeToolCalls(
|
|
1952
2039
|
runId,
|
|
@@ -2042,7 +2129,9 @@ var PromptRequest = class _PromptRequest {
|
|
|
2042
2129
|
generation: {
|
|
2043
2130
|
provider: this.agent.model.provider,
|
|
2044
2131
|
model: request.model ?? this.agent.model.defaultModel,
|
|
2045
|
-
usage: { ...response.usage }
|
|
2132
|
+
usage: { ...response.usage },
|
|
2133
|
+
...response.sources === void 0 ? {} : { sources: response.sources },
|
|
2134
|
+
...response.providerToolCalls === void 0 ? {} : { providerToolCalls: response.providerToolCalls }
|
|
2046
2135
|
}
|
|
2047
2136
|
}
|
|
2048
2137
|
};
|
|
@@ -2177,6 +2266,7 @@ var PromptRequest = class _PromptRequest {
|
|
|
2177
2266
|
agentDescription: this.agent.description,
|
|
2178
2267
|
instructions: this.agent.instructions,
|
|
2179
2268
|
trace: this.traceOptions,
|
|
2269
|
+
promptRef: this.traceOptions?.promptRef,
|
|
2180
2270
|
prompt: this.promptMessage,
|
|
2181
2271
|
history: this.chatHistory,
|
|
2182
2272
|
maxTurns: this.maxTurnCount
|
|
@@ -2386,7 +2476,7 @@ function normalizeSteeringInput(input) {
|
|
|
2386
2476
|
}
|
|
2387
2477
|
return Array.isArray(input) ? [...input] : [input];
|
|
2388
2478
|
}
|
|
2389
|
-
function responseStreamEvents(turn, response) {
|
|
2479
|
+
function responseStreamEvents(turn, response, includeProviderArtifacts = true) {
|
|
2390
2480
|
const events = [];
|
|
2391
2481
|
for (const item of response.choice) {
|
|
2392
2482
|
if (item.type === "text") {
|
|
@@ -2418,8 +2508,34 @@ function responseStreamEvents(turn, response) {
|
|
|
2418
2508
|
events.push({ type: "tool_call", turn, toolCall: item });
|
|
2419
2509
|
}
|
|
2420
2510
|
}
|
|
2511
|
+
if (includeProviderArtifacts) {
|
|
2512
|
+
for (const source of response.sources ?? []) {
|
|
2513
|
+
events.push({ type: "source", turn, source });
|
|
2514
|
+
}
|
|
2515
|
+
for (const toolCall of response.providerToolCalls ?? []) {
|
|
2516
|
+
events.push({ type: "provider_tool_call", turn, toolCall });
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2421
2519
|
return events;
|
|
2422
2520
|
}
|
|
2521
|
+
function generationArtifacts(messages) {
|
|
2522
|
+
const sources = /* @__PURE__ */ new Map();
|
|
2523
|
+
const providerToolCalls = /* @__PURE__ */ new Map();
|
|
2524
|
+
for (const message of messages) {
|
|
2525
|
+
const metadata = getAssistantGenerationMetadata(message);
|
|
2526
|
+
for (const source of metadata?.sources ?? []) {
|
|
2527
|
+
const key = `${source.url}\0${source.startIndex ?? ""}\0${source.endIndex ?? ""}`;
|
|
2528
|
+
sources.set(key, source);
|
|
2529
|
+
}
|
|
2530
|
+
for (const toolCall of metadata?.providerToolCalls ?? []) {
|
|
2531
|
+
providerToolCalls.set(toolCall.id, toolCall);
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
return {
|
|
2535
|
+
...sources.size === 0 ? {} : { sources: [...sources.values()] },
|
|
2536
|
+
...providerToolCalls.size === 0 ? {} : { providerToolCalls: [...providerToolCalls.values()] }
|
|
2537
|
+
};
|
|
2538
|
+
}
|
|
2423
2539
|
function reasoningDeltaEvent2(turn, delta, details = {}) {
|
|
2424
2540
|
const event = {
|
|
2425
2541
|
type: "reasoning_delta",
|
|
@@ -2477,4 +2593,4 @@ export {
|
|
|
2477
2593
|
extractRagText,
|
|
2478
2594
|
PromptRequest
|
|
2479
2595
|
};
|
|
2480
|
-
//# sourceMappingURL=chunk-
|
|
2596
|
+
//# sourceMappingURL=chunk-OPAEENGD.js.map
|