@cognipeer/agent-sdk 0.18.0 → 0.20.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/index.cjs +97 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -8
- package/dist/index.d.ts +67 -8
- package/dist/index.mjs +97 -38
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1248,7 +1248,7 @@ function cacheWriteTokensOf(raw) {
|
|
|
1248
1248
|
init_content();
|
|
1249
1249
|
|
|
1250
1250
|
// src/version.ts
|
|
1251
|
-
var SDK_VERSION = "0.
|
|
1251
|
+
var SDK_VERSION = "0.20.0";
|
|
1252
1252
|
|
|
1253
1253
|
// src/utils/otlp/content.ts
|
|
1254
1254
|
init_content();
|
|
@@ -1742,7 +1742,7 @@ function sessionToOtlp(file, options) {
|
|
|
1742
1742
|
const agentName = file.agent?.name;
|
|
1743
1743
|
const everyEvent = file.events;
|
|
1744
1744
|
const exportedEvents = foldSupersededSpans(everyEvent).filter(
|
|
1745
|
-
(event) => options.terminal || !(event.type === "span" && event.status === "pending")
|
|
1745
|
+
(event) => options.terminal || !(event.type === "span" && (event.status === "pending" || event.status === "running"))
|
|
1746
1746
|
);
|
|
1747
1747
|
const startMs = parseMs(file.startedAt);
|
|
1748
1748
|
const nodes = exportedEvents.map((event) => {
|
|
@@ -3756,7 +3756,9 @@ function foldSupersededSpans(events) {
|
|
|
3756
3756
|
const current = winner.get(id);
|
|
3757
3757
|
if (current === void 0 || rank(events[i], i) >= rank(events[current], current)) winner.set(id, i);
|
|
3758
3758
|
}
|
|
3759
|
-
return events.filter(
|
|
3759
|
+
return events.filter(
|
|
3760
|
+
(event, i) => !(event.spanId && (event.status === "pending" || event.status === "running") && winner.get(event.spanId) !== i)
|
|
3761
|
+
);
|
|
3760
3762
|
}
|
|
3761
3763
|
function recordOrDeferTraceEvent(ctx, event, options) {
|
|
3762
3764
|
const session = ctx?.__traceSession;
|
|
@@ -10534,14 +10536,16 @@ function createAgent(opts) {
|
|
|
10534
10536
|
const startedAt = Date.now();
|
|
10535
10537
|
const recordSpan = (status, extra) => {
|
|
10536
10538
|
if (!traced || !isTraceSessionOpen(parentSession)) return;
|
|
10539
|
+
const running = status === "running";
|
|
10537
10540
|
recordSubagentSpan(parentSession, {
|
|
10538
10541
|
spanId: agentSpanId,
|
|
10539
|
-
|
|
10542
|
+
// The delegating tool_call span only exists once the tool returns.
|
|
10543
|
+
parentSpanId: running ? parentIterationSpanId : context?.traceSpanId ?? parentIterationSpanId,
|
|
10540
10544
|
name: opts.name || "agent",
|
|
10541
10545
|
status,
|
|
10542
|
-
durationMs: Date.now() - startedAt,
|
|
10546
|
+
durationMs: running ? void 0 : Date.now() - startedAt,
|
|
10543
10547
|
error: extra.error,
|
|
10544
|
-
info: { name: opts.name || "agent", mode: "asTool", depth: currentDepth + 1, parentToolCallId: context?.toolCallId, status: status === "success" ? "ok" : "error" },
|
|
10548
|
+
info: { name: opts.name || "agent", mode: "asTool", depth: currentDepth + 1, parentToolCallId: context?.toolCallId, status: running ? "running" : status === "success" ? "ok" : "error" },
|
|
10545
10549
|
task: input,
|
|
10546
10550
|
result: extra.result
|
|
10547
10551
|
});
|
|
@@ -10561,6 +10565,7 @@ function createAgent(opts) {
|
|
|
10561
10565
|
stream: Boolean(parentCtx.__streaming),
|
|
10562
10566
|
cancellationToken: parentCtx.__cancellationToken ?? parentCtx.__abortSignal
|
|
10563
10567
|
};
|
|
10568
|
+
recordSpan("running", {});
|
|
10564
10569
|
let res;
|
|
10565
10570
|
try {
|
|
10566
10571
|
res = await instance.invoke({ messages: childMessages, ctx: childCtx }, childConfig);
|
|
@@ -10860,6 +10865,13 @@ function buildModelMessages(state, config) {
|
|
|
10860
10865
|
var systemMessage = (content) => ({ role: "system", content });
|
|
10861
10866
|
var humanMessage = (content) => ({ role: "user", content });
|
|
10862
10867
|
var LAST_SUMMARIZATION_CALL_KEY = "__lastSummarizationCall";
|
|
10868
|
+
var SUMMARIZATION_TRIGGER_KEY = "__summarizationTrigger";
|
|
10869
|
+
var SUMMARIZATION_TRIGGERS = ["pre_leg", "mid_leg", "post_tools"];
|
|
10870
|
+
var MAX_EVENT_ERROR_CHARS = 300;
|
|
10871
|
+
function eventErrorText(message) {
|
|
10872
|
+
if (!message) return void 0;
|
|
10873
|
+
return message.length > MAX_EVENT_ERROR_CHARS ? `${message.slice(0, MAX_EVENT_ERROR_CHARS - 3)}...` : message;
|
|
10874
|
+
}
|
|
10863
10875
|
var MAX_MESSAGE_CHARS = 2e3;
|
|
10864
10876
|
var MAX_USER_MESSAGE_CHARS = 4e3;
|
|
10865
10877
|
function validateMessageSequence(messages) {
|
|
@@ -11186,7 +11198,7 @@ function repairStructuredSummary(previous, current, integrity) {
|
|
|
11186
11198
|
return { ...current, user_directives: directives, stable_facts: filteredFacts };
|
|
11187
11199
|
}
|
|
11188
11200
|
function createContextSummarizeNode(opts) {
|
|
11189
|
-
|
|
11201
|
+
const summarizePass = async (state, events) => {
|
|
11190
11202
|
const resolved = getResolvedSmartConfig(opts, state.agent);
|
|
11191
11203
|
const config = resolved.summarization;
|
|
11192
11204
|
if (!config.enable) return {};
|
|
@@ -11377,11 +11389,25 @@ ${canonicalFacts.length > 0 ? canonicalFacts.map((fact) => `- ${fact.key}: ${fac
|
|
|
11377
11389
|
...summaryPrompt,
|
|
11378
11390
|
...rawModelOutput !== void 0 ? [{ role: "assistant", content: rawModelOutput, name: "summarization_result" }] : []
|
|
11379
11391
|
]));
|
|
11392
|
+
const summaryToolCallId = `call_summary_${Date.now()}_${nanoid(6)}`;
|
|
11393
|
+
const passNumber = (Array.isArray(state.summaries) ? state.summaries.length : 0) + 1;
|
|
11394
|
+
const rawTrigger = state.ctx?.[SUMMARIZATION_TRIGGER_KEY];
|
|
11395
|
+
const trigger = SUMMARIZATION_TRIGGERS.includes(rawTrigger) ? rawTrigger : void 0;
|
|
11396
|
+
const passIdentity = {
|
|
11397
|
+
id: summaryToolCallId,
|
|
11398
|
+
pass: passNumber,
|
|
11399
|
+
...trigger ? { trigger } : {}
|
|
11400
|
+
};
|
|
11380
11401
|
const startTime = Date.now();
|
|
11381
11402
|
try {
|
|
11382
11403
|
if (!model || typeof model.invoke !== "function") {
|
|
11383
11404
|
throw new Error("Summarization model is unavailable.");
|
|
11384
11405
|
}
|
|
11406
|
+
events.started = passIdentity;
|
|
11407
|
+
try {
|
|
11408
|
+
onEvent?.({ type: "summarization", phase: "start", ...passIdentity, summary: "" });
|
|
11409
|
+
} catch {
|
|
11410
|
+
}
|
|
11385
11411
|
const langchainRunOptions = model?._lc ? { runName: "summarize_context", tags: ["cognipeer:summarization"], metadata: { cognipeer_event: "summarization" } } : void 0;
|
|
11386
11412
|
const response = langchainRunOptions ? await model.invoke(summaryPrompt, langchainRunOptions) : await model.invoke(summaryPrompt);
|
|
11387
11413
|
durationMs = Date.now() - startTime;
|
|
@@ -11423,24 +11449,9 @@ ${canonicalFacts.length > 0 ? canonicalFacts.map((fact) => `- ${fact.key}: ${fac
|
|
|
11423
11449
|
structuredSummary = groundDirectives(structuredSummary);
|
|
11424
11450
|
integrity = noteDroppedDirectives({ passed: true, criticalFactLoss: false, obsoleteFactRevived: false, notes: ["Fallback summary generated locally."] });
|
|
11425
11451
|
summaryText = renderStructuredSummary(structuredSummary);
|
|
11426
|
-
const errorEvent = {
|
|
11427
|
-
type: "summarization",
|
|
11428
|
-
summary: summaryText,
|
|
11429
|
-
messagesCompressed: compressableMessages.length,
|
|
11430
|
-
inputTokens: inputTokensEstimate,
|
|
11431
|
-
outputTokens: countApproxTokens(summaryText),
|
|
11432
|
-
durationMs,
|
|
11433
|
-
previousSummary: previousSummary || void 0,
|
|
11434
|
-
tokenCountBefore,
|
|
11435
|
-
tokenCountAfter: tokenCountBefore,
|
|
11436
|
-
structuredSummary,
|
|
11437
|
-
integrity,
|
|
11438
|
-
...modelName ? { model: modelName } : {},
|
|
11439
|
-
...droppedDirectives.length > 0 ? { droppedDirectives } : {}
|
|
11440
|
-
};
|
|
11441
|
-
onEvent?.(errorEvent);
|
|
11442
11452
|
summarizerError = traceErrorOf(err);
|
|
11443
11453
|
}
|
|
11454
|
+
const eventError = eventErrorText(summarizerError?.message);
|
|
11444
11455
|
const toolCallIdToAssistantIdx = /* @__PURE__ */ new Map();
|
|
11445
11456
|
messages.forEach((m, idx) => {
|
|
11446
11457
|
if (m.role === "assistant" && m.tool_calls && Array.isArray(m.tool_calls)) {
|
|
@@ -11532,10 +11543,19 @@ ${canonicalFacts.length > 0 ? canonicalFacts.map((fact) => `- ${fact.key}: ${fac
|
|
|
11532
11543
|
(m) => m.role === "tool" && isSummarizedToolPlaceholder(m.content) && !messages.some((orig) => orig.tool_call_id === m.tool_call_id && isSummarizedToolPlaceholder(orig.content))
|
|
11533
11544
|
);
|
|
11534
11545
|
if (actuallyCompressed.length === 0) {
|
|
11546
|
+
if (events.started) {
|
|
11547
|
+
events.ended = true;
|
|
11548
|
+
onEvent?.({
|
|
11549
|
+
type: "summarization",
|
|
11550
|
+
phase: "skipped",
|
|
11551
|
+
...passIdentity,
|
|
11552
|
+
summary: "",
|
|
11553
|
+
...fallback ? { status: "fallback", ...eventError ? { error: eventError } : {} } : {}
|
|
11554
|
+
});
|
|
11555
|
+
}
|
|
11535
11556
|
return {};
|
|
11536
11557
|
}
|
|
11537
11558
|
const validatedMessages = validateMessageSequence(newMessages);
|
|
11538
|
-
const summaryToolCallId = `call_summary_${Date.now()}`;
|
|
11539
11559
|
const assistantSummaryCall = {
|
|
11540
11560
|
role: "assistant",
|
|
11541
11561
|
// "assistant"
|
|
@@ -11564,6 +11584,11 @@ ${canonicalFacts.length > 0 ? canonicalFacts.map((fact) => `- ${fact.key}: ${fac
|
|
|
11564
11584
|
const tokenCountAfter = countMessagesTokens(finalMessages);
|
|
11565
11585
|
const summarizationEvent = {
|
|
11566
11586
|
type: "summarization",
|
|
11587
|
+
phase: "done",
|
|
11588
|
+
...passIdentity,
|
|
11589
|
+
status: fallback ? "fallback" : "ok",
|
|
11590
|
+
...fallback && eventError ? { error: eventError } : {},
|
|
11591
|
+
compactedTools: actuallyCompressed.filter((m) => typeof m.tool_call_id === "string" && m.tool_call_id).map((m) => ({ toolCallId: m.tool_call_id, toolName: m.name || "" })),
|
|
11567
11592
|
summary: summaryText,
|
|
11568
11593
|
messagesCompressed: compressableMessages.length,
|
|
11569
11594
|
inputTokens: inputTokensActual ?? inputTokensEstimate,
|
|
@@ -11581,6 +11606,7 @@ ${canonicalFacts.length > 0 ? canonicalFacts.map((fact) => `- ${fact.key}: ${fac
|
|
|
11581
11606
|
...modelName ? { model: modelName } : {},
|
|
11582
11607
|
...droppedDirectives.length > 0 ? { droppedDirectives } : {}
|
|
11583
11608
|
};
|
|
11609
|
+
events.ended = true;
|
|
11584
11610
|
onEvent?.(summarizationEvent);
|
|
11585
11611
|
traceSummarization({
|
|
11586
11612
|
type: "summarization",
|
|
@@ -11643,6 +11669,7 @@ ${canonicalFacts.length > 0 ? canonicalFacts.map((fact) => `- ${fact.key}: ${fac
|
|
|
11643
11669
|
fallback
|
|
11644
11670
|
}
|
|
11645
11671
|
});
|
|
11672
|
+
const { [SUMMARIZATION_TRIGGER_KEY]: _passTrigger, ...carriedCtx } = ctxWithDeferredTrace ?? state.ctx ?? {};
|
|
11646
11673
|
return {
|
|
11647
11674
|
messages: finalMessages,
|
|
11648
11675
|
summaries,
|
|
@@ -11652,7 +11679,7 @@ ${canonicalFacts.length > 0 ? canonicalFacts.map((fact) => `- ${fact.key}: ${fac
|
|
|
11652
11679
|
// held for the next leg. The smart driver merges ctx and removes the
|
|
11653
11680
|
// call record once the hook has seen it.
|
|
11654
11681
|
ctx: {
|
|
11655
|
-
...
|
|
11682
|
+
...carriedCtx,
|
|
11656
11683
|
[LAST_SUMMARIZATION_CALL_KEY]: {
|
|
11657
11684
|
...modelName ? { model: modelName } : {},
|
|
11658
11685
|
durationMs,
|
|
@@ -11670,6 +11697,30 @@ ${canonicalFacts.length > 0 ? canonicalFacts.map((fact) => `- ${fact.key}: ${fac
|
|
|
11670
11697
|
}
|
|
11671
11698
|
};
|
|
11672
11699
|
};
|
|
11700
|
+
return async (state) => {
|
|
11701
|
+
const events = {};
|
|
11702
|
+
try {
|
|
11703
|
+
return await summarizePass(state, events);
|
|
11704
|
+
} catch (err) {
|
|
11705
|
+
if (events.started && !events.ended) {
|
|
11706
|
+
events.ended = true;
|
|
11707
|
+
const onEvent = state.ctx?.__onEvent;
|
|
11708
|
+
const error = eventErrorText(traceErrorOf(err).message);
|
|
11709
|
+
try {
|
|
11710
|
+
onEvent?.({
|
|
11711
|
+
type: "summarization",
|
|
11712
|
+
phase: "skipped",
|
|
11713
|
+
...events.started,
|
|
11714
|
+
summary: "",
|
|
11715
|
+
status: "error",
|
|
11716
|
+
...error ? { error } : {}
|
|
11717
|
+
});
|
|
11718
|
+
} catch {
|
|
11719
|
+
}
|
|
11720
|
+
}
|
|
11721
|
+
throw err;
|
|
11722
|
+
}
|
|
11723
|
+
};
|
|
11673
11724
|
}
|
|
11674
11725
|
|
|
11675
11726
|
// src/index.ts
|
|
@@ -11838,9 +11889,10 @@ function createPlanTool(stateRef, toolName, description) {
|
|
|
11838
11889
|
expectedVersion: z.number().int().min(0).optional(),
|
|
11839
11890
|
todoList: z.array(todoItemWireSchema).optional()
|
|
11840
11891
|
}),
|
|
11841
|
-
func: async ({ operation, expectedVersion, todoList }) => {
|
|
11892
|
+
func: async ({ operation, expectedVersion, todoList }, context) => {
|
|
11842
11893
|
const toolStateRef = manageTodo._stateRef;
|
|
11843
11894
|
const onEvent = toolStateRef?.__onEvent;
|
|
11895
|
+
const toolCallId = context?.toolCallId || toolStateRef?.__currentToolCallId || void 0;
|
|
11844
11896
|
const emitPlanEvent = (list) => {
|
|
11845
11897
|
const version = stateRef.planVersion || 1;
|
|
11846
11898
|
const adherenceScore = stateRef.adherenceScore || 0;
|
|
@@ -11849,7 +11901,8 @@ function createPlanTool(stateRef, toolName, description) {
|
|
|
11849
11901
|
operation,
|
|
11850
11902
|
version,
|
|
11851
11903
|
adherenceScore,
|
|
11852
|
-
count: Array.isArray(list) ? list.length : 0
|
|
11904
|
+
count: Array.isArray(list) ? list.length : 0,
|
|
11905
|
+
...toolCallId ? { toolCallId } : {}
|
|
11853
11906
|
};
|
|
11854
11907
|
onEvent?.({ type: "plan", todoList: list, ...planData });
|
|
11855
11908
|
const traceSession = toolStateRef?.ctx?.__traceSession;
|
|
@@ -12761,14 +12814,16 @@ async function runChild(spec, input, deps, ref, opts) {
|
|
|
12761
12814
|
const traceScope = traced ? createSubagentTraceScope(parentSession, { agentSpanId, name: spec.name, spawnId, mode: spec.mode, hitl: opts.allowHITL, iterations: opts.record?.iterations }) : void 0;
|
|
12762
12815
|
const recordSegment = (status, info) => {
|
|
12763
12816
|
if (!traced || !isTraceSessionOpen(parentSession)) return;
|
|
12817
|
+
const unfinished = status === "pending" || status === "running";
|
|
12764
12818
|
recordSubagentSpan(parentSession, {
|
|
12765
12819
|
spanId: agentSpanId,
|
|
12766
|
-
// The tool_call span only exists once the tool returns; a
|
|
12767
|
-
// has not returned, so its span hangs off the iteration.
|
|
12768
|
-
parentSpanId:
|
|
12820
|
+
// The tool_call span only exists once the tool returns; a running or
|
|
12821
|
+
// paused child has not returned, so its span hangs off the iteration.
|
|
12822
|
+
parentSpanId: unfinished ? parentIterationSpanId : opts.parentSpanId ?? parentIterationSpanId,
|
|
12769
12823
|
name: spec.name,
|
|
12770
12824
|
status,
|
|
12771
|
-
|
|
12825
|
+
// A starting segment has no extent yet; a reader draws it over its children.
|
|
12826
|
+
durationMs: status === "running" ? void 0 : elapsedMs(),
|
|
12772
12827
|
error: info.error,
|
|
12773
12828
|
info: {
|
|
12774
12829
|
id: spawnId,
|
|
@@ -12779,7 +12834,7 @@ async function runChild(spec, input, deps, ref, opts) {
|
|
|
12779
12834
|
parentToolCallId: opts.parentToolCallId,
|
|
12780
12835
|
status: info.subagentStatus,
|
|
12781
12836
|
// Only a run that paused has more than one segment to tell about.
|
|
12782
|
-
...segment > 1 ||
|
|
12837
|
+
...segment > 1 || unfinished ? { segments: segment } : {},
|
|
12783
12838
|
...info.note ? { note: info.note } : {},
|
|
12784
12839
|
...spec.metadata ? { metadata: spec.metadata } : {}
|
|
12785
12840
|
},
|
|
@@ -12903,6 +12958,7 @@ async function runChild(spec, input, deps, ref, opts) {
|
|
|
12903
12958
|
}
|
|
12904
12959
|
if (traceScope) childInput = { ...childInput, ctx: { ...childInput.ctx || {}, __traceSession: traceScope } };
|
|
12905
12960
|
const usageBaseline = childInput.usage?.perRequest?.length ?? 0;
|
|
12961
|
+
recordSegment("running", { subagentStatus: "running", input });
|
|
12906
12962
|
let res;
|
|
12907
12963
|
try {
|
|
12908
12964
|
res = await child.invoke(childInput, childConfig);
|
|
@@ -13507,7 +13563,7 @@ ${pluginAppend}`;
|
|
|
13507
13563
|
const toolCalls = Array.isArray(lastAssistant.tool_calls) ? lastAssistant.tool_calls : [];
|
|
13508
13564
|
return toolCalls.length === 0;
|
|
13509
13565
|
}
|
|
13510
|
-
async function trySummarize(currentState, currentRawMessages, ref) {
|
|
13566
|
+
async function trySummarize(currentState, currentRawMessages, ref, trigger) {
|
|
13511
13567
|
if (!summarizer) return { state: currentState, rawMessages: currentRawMessages, compressed: false };
|
|
13512
13568
|
const compactHost = currentState.ctx?.__plugins;
|
|
13513
13569
|
const tokensBefore = countMessagesTokens(currentState.messages || []);
|
|
@@ -13527,7 +13583,9 @@ ${pluginAppend}`;
|
|
|
13527
13583
|
return { state: { ...currentState, ctx: ctx2 }, rawMessages: currentRawMessages, compressed: false };
|
|
13528
13584
|
}
|
|
13529
13585
|
}
|
|
13530
|
-
const
|
|
13586
|
+
const nodeState = { ...currentState, ctx: { ...currentState.ctx || {}, [SUMMARIZATION_TRIGGER_KEY]: trigger } };
|
|
13587
|
+
const delta = await summarizer(nodeState);
|
|
13588
|
+
if (nodeState.usage !== currentState.usage) currentState.usage = nodeState.usage;
|
|
13531
13589
|
if (!delta || Object.keys(delta).length === 0) {
|
|
13532
13590
|
const ctx2 = {
|
|
13533
13591
|
...currentState.ctx || {},
|
|
@@ -13539,6 +13597,7 @@ ${pluginAppend}`;
|
|
|
13539
13597
|
const ctx = { ...currentState.ctx || {}, ...delta.ctx || {} };
|
|
13540
13598
|
const summarizationCall = ctx[LAST_SUMMARIZATION_CALL_KEY];
|
|
13541
13599
|
delete ctx[LAST_SUMMARIZATION_CALL_KEY];
|
|
13600
|
+
delete ctx[SUMMARIZATION_TRIGGER_KEY];
|
|
13542
13601
|
delete ctx.__summarizationExhausted;
|
|
13543
13602
|
delete ctx.__summarizationExhaustedAtToolCount;
|
|
13544
13603
|
const updated = await persistLatestSummary(syncPlanStateWith(ref, { ...currentState, ...delta, ctx }));
|
|
@@ -13762,7 +13821,7 @@ ${pluginAppend}`;
|
|
|
13762
13821
|
state = syncRuntimeTools({ ...state, messages: rawMessages }, rawMessages, toolSet);
|
|
13763
13822
|
const next = summarizationEnabled ? decideBefore(state) : "agent";
|
|
13764
13823
|
if (next === "contextSummarize" && summarizer) {
|
|
13765
|
-
const result = await trySummarize(state, rawMessages, stateRef);
|
|
13824
|
+
const result = await trySummarize(state, rawMessages, stateRef, "pre_leg");
|
|
13766
13825
|
state = result.state;
|
|
13767
13826
|
rawMessages = result.rawMessages;
|
|
13768
13827
|
noteTraceHandoff(state);
|
|
@@ -13797,7 +13856,7 @@ ${pluginAppend}`;
|
|
|
13797
13856
|
const ctx = { ...state.ctx || {} };
|
|
13798
13857
|
delete ctx.__needsSummarization;
|
|
13799
13858
|
state = { ...state, ctx };
|
|
13800
|
-
const result = await trySummarize(state, rawMessages, stateRef);
|
|
13859
|
+
const result = await trySummarize(state, rawMessages, stateRef, "mid_leg");
|
|
13801
13860
|
state = result.state;
|
|
13802
13861
|
rawMessages = result.rawMessages;
|
|
13803
13862
|
noteTraceHandoff(state);
|
|
@@ -13809,7 +13868,7 @@ ${pluginAppend}`;
|
|
|
13809
13868
|
if (summarizationEnabled) {
|
|
13810
13869
|
const after = decideAfter(state);
|
|
13811
13870
|
if (after === "contextSummarize" && summarizer) {
|
|
13812
|
-
const result = await trySummarize(state, rawMessages, stateRef);
|
|
13871
|
+
const result = await trySummarize(state, rawMessages, stateRef, "post_tools");
|
|
13813
13872
|
state = result.state;
|
|
13814
13873
|
rawMessages = result.rawMessages;
|
|
13815
13874
|
noteTraceHandoff(state);
|
|
@@ -22026,6 +22085,6 @@ function createProvider(config) {
|
|
|
22026
22085
|
}
|
|
22027
22086
|
}
|
|
22028
22087
|
|
|
22029
|
-
export { ASK_USER_TOOL_NAME, AnthropicProvider, AzureProvider, BaseProvider, BedrockProvider, CCRStore, CONSOLE_HOOK_MAP, CONTEXT_PILOT_JSON_MARKER_KEY, CONTROL_PLANE_TOOL_NAMES, DEFAULT_MAX_TOOL_INPUT_FIELD_CHARS, DEFAULT_PROFILE_CONFIGS, DEFAULT_SKILL_POLICY, DEFAULT_SUBAGENT_POLICY, DEFAULT_SUBAGENT_TOOL_NAMES, DEFAULT_TOOL_INPUT_DIGEST_HEAD_CHARS, DELEGATION_TOOL_NAMES, DedupTracker, GENAI_SEMCONV_COMMIT, GuardrailPhase, HOOK_CONTRACT_VERSION, HOOK_NAMES, HookTimeoutError, InMemoryMemoryStore, JevProvider, LAST_SUMMARIZATION_CALL_KEY, MAX_ADJUSTMENTS, MODEL_RULES, ModelRequestError, NativeJsonSchemaStrategy, OpenAICompatibleProvider, OpenAIProvider, PREOPEN_TOOL_CALL_PREFIX, ProviderError, SMALL_TIER_SKILL_POLICY, StructuredOutputManager, TOOL_INPUT_DIGEST_KEY, ToolBasedStrategy, VertexProvider, agentVerdictRule, allowsSampling, appendBoundTools, applyDropParams, asModelRequestError, auditLog, azureContentSafety, bedrockGuardrail, budgetGuard, buildHandoffTools, buildResponseFormatSection, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, buildToolDefinitionsSection, canOpenSkill, canSpawn, captureSnapshot, checkpointing, clearLearnedModelRules, closeTraceContinuation, codePresenceRule, coerceToolArgs, cognipeerGuardrail, cognipeerSink, collectAttachments, collectToolRetentionDeclarations, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, contentPartToText, contentToString, conversationHistory, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createGuardrailPlugin, createJsonGuardrail, createManageTodoListAliasTool, createManageTodoTool, createOpenSkillTool, createOtlpExporter, createParallelTool, createPluginHost, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customGuardrail, customSink, dedupeToolsByName, defaultTokenCounter, defineHook, definePlugin, describeContentPart, detectLanguage, detectTextFormat, detectVolatileContent, digestToolInputArguments, digestToolInputValue, effortBudget, emptyUsage, evaluateGuardrails, extractLatestUserQuery, extractMessageText, fileCheckpointStore, fileSink, findSubagent, foldSupersededSpans, formatTraceparent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getLearnedModelRulePatch, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasMediaPart, hasToolResponseRecoveryReference, httpGuardrail, httpSink, inMemoryCheckpointStore, inMemoryConversationStore, isHookImplemented, isOpenAIHostedEndpoint, isSmartModel, isTraceSessionOpen, isValidIban, isValidLuhn, isValidTckn, jsonSchemaRule, defaultBuildPayload as langfuseDefaultPayload, langfuseTracing, languageGuard, listLearnedModelRules, loadSkillsFromDisk, mapConsoleHookVerdict, mapReasoningEffort, mapTextParts, mcp, mediaKindOf, mediaPolicy, mergeRulePatch, modelIdCandidates, normalizeSmartAgentOptions, normalizeVerdicts, openAIModeration, otelTracing, otlpSink, outputGuard, parseApprovalDecision, parseModelError, parseSkillFrontmatter, parseTraceparent, pathSandbox, piiRedaction, pluginCapabilities, portkeyGateway, portkeyGuardrail, preopenSkills, preopenToolCallId, prepareStrictToolMenu, promptInjectionGuard, rateLimit, readMemoryFacts, readTraceContinuation, recordOrDeferTraceEvent, redactText, regexGuardrail, regexRule, rememberModelRulePatch, replaceTextContent, replayDeferredTraceEvents, resolveAvailableSkills, resolveAvailableSubagents, resolveInputRetention, resolveMemoryStore, resolveModelRule, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveSummarizationRetention, resolveToolApprovalState, resolveUserQuestionState, responseCache, restoreSnapshot, restoreToolCalls, runSmartAgentEvalHarness, runWithModelAdjustments, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, sessionMetrics, setTokenCounter, startStreamingSession, summarizeObject, supportsAdaptiveThinking, textFromContent, toMessageUsage, toModelResult, toStrictCompatible, toStrictToolSchema, tokenize, toolPolicy, traceContinuationOf, traceSectionsFromMessages, traceSessionToOtlp, traceparentOf, validateReasoningConfig, validateToolArgs, webhookApproval, withTools, withinDepth, writeSummaryFactsToMemory };
|
|
22088
|
+
export { ASK_USER_TOOL_NAME, AnthropicProvider, AzureProvider, BaseProvider, BedrockProvider, CCRStore, CONSOLE_HOOK_MAP, CONTEXT_PILOT_JSON_MARKER_KEY, CONTROL_PLANE_TOOL_NAMES, DEFAULT_MAX_TOOL_INPUT_FIELD_CHARS, DEFAULT_PROFILE_CONFIGS, DEFAULT_SKILL_POLICY, DEFAULT_SUBAGENT_POLICY, DEFAULT_SUBAGENT_TOOL_NAMES, DEFAULT_TOOL_INPUT_DIGEST_HEAD_CHARS, DELEGATION_TOOL_NAMES, DedupTracker, GENAI_SEMCONV_COMMIT, GuardrailPhase, HOOK_CONTRACT_VERSION, HOOK_NAMES, HookTimeoutError, InMemoryMemoryStore, JevProvider, LAST_SUMMARIZATION_CALL_KEY, MAX_ADJUSTMENTS, MODEL_RULES, ModelRequestError, NativeJsonSchemaStrategy, OpenAICompatibleProvider, OpenAIProvider, PREOPEN_TOOL_CALL_PREFIX, ProviderError, SMALL_TIER_SKILL_POLICY, SUMMARIZATION_TRIGGER_KEY, StructuredOutputManager, TOOL_INPUT_DIGEST_KEY, ToolBasedStrategy, VertexProvider, agentVerdictRule, allowsSampling, appendBoundTools, applyDropParams, asModelRequestError, auditLog, azureContentSafety, bedrockGuardrail, budgetGuard, buildHandoffTools, buildResponseFormatSection, buildSkillHeaderBlock, buildSubagentCatalogBlock, buildSystemPrompt, buildToolDefinitionsSection, canOpenSkill, canSpawn, captureSnapshot, checkpointing, clearLearnedModelRules, closeTraceContinuation, codePresenceRule, coerceToolArgs, cognipeerGuardrail, cognipeerSink, collectAttachments, collectToolRetentionDeclarations, composeToolSets, compressDiffOutput, compressJsonOutput, compressLogOutput, compressSearchOutput, compressTextOutput, compressToolOutput, contentPartToText, contentToString, conversationHistory, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createAskUserQuestionTool, createBindSkillToolsTool, createCodeGuardrail, createContextPilotRuntime, createContextSummarizeNode, createContextTools, createDelegateTool, createGetToolResponseTool, createGuardrail, createGuardrailPlugin, createJsonGuardrail, createManageTodoListAliasTool, createManageTodoTool, createOpenSkillTool, createOtlpExporter, createParallelTool, createPluginHost, createProvider, createRegexGuardrail, createResolverNode, createSearchSkillsTool, createSkillRegistryRef, createSkillTools, createSmartAgent, createSpawnTool, createSubagentRegistryRef, createSubagentTools, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customGuardrail, customSink, dedupeToolsByName, defaultTokenCounter, defineHook, definePlugin, describeContentPart, detectLanguage, detectTextFormat, detectVolatileContent, digestToolInputArguments, digestToolInputValue, effortBudget, emptyUsage, evaluateGuardrails, extractLatestUserQuery, extractMessageText, fileCheckpointStore, fileSink, findSubagent, foldSupersededSpans, formatTraceparent, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getLearnedModelRulePatch, getModelCapabilities, getNestedValue, getResolvedSmartConfig, getTokenCounter, hasMediaPart, hasToolResponseRecoveryReference, httpGuardrail, httpSink, inMemoryCheckpointStore, inMemoryConversationStore, isHookImplemented, isOpenAIHostedEndpoint, isSmartModel, isTraceSessionOpen, isValidIban, isValidLuhn, isValidTckn, jsonSchemaRule, defaultBuildPayload as langfuseDefaultPayload, langfuseTracing, languageGuard, listLearnedModelRules, loadSkillsFromDisk, mapConsoleHookVerdict, mapReasoningEffort, mapTextParts, mcp, mediaKindOf, mediaPolicy, mergeRulePatch, modelIdCandidates, normalizeSmartAgentOptions, normalizeVerdicts, openAIModeration, otelTracing, otlpSink, outputGuard, parseApprovalDecision, parseModelError, parseSkillFrontmatter, parseTraceparent, pathSandbox, piiRedaction, pluginCapabilities, portkeyGateway, portkeyGuardrail, preopenSkills, preopenToolCallId, prepareStrictToolMenu, promptInjectionGuard, rateLimit, readMemoryFacts, readTraceContinuation, recordOrDeferTraceEvent, redactText, regexGuardrail, regexRule, rememberModelRulePatch, replaceTextContent, replayDeferredTraceEvents, resolveAvailableSkills, resolveAvailableSubagents, resolveInputRetention, resolveMemoryStore, resolveModelRule, resolveReasoning, resolveStrategy, resolveSubagentTools, resolveSummarizationRetention, resolveToolApprovalState, resolveUserQuestionState, responseCache, restoreSnapshot, restoreToolCalls, runSmartAgentEvalHarness, runWithModelAdjustments, scoreItemsByRelevance, searchSkills, seedChildMessages, selectTopIndicesInOrder, sessionMetrics, setTokenCounter, startStreamingSession, summarizeObject, supportsAdaptiveThinking, textFromContent, toMessageUsage, toModelResult, toStrictCompatible, toStrictToolSchema, tokenize, toolPolicy, traceContinuationOf, traceSectionsFromMessages, traceSessionToOtlp, traceparentOf, validateReasoningConfig, validateToolArgs, webhookApproval, withTools, withinDepth, writeSummaryFactsToMemory };
|
|
22030
22089
|
//# sourceMappingURL=index.mjs.map
|
|
22031
22090
|
//# sourceMappingURL=index.mjs.map
|