feat(kernel): complete tree-first graph tasks 074-080
This commit is contained in:
@@ -43,6 +43,10 @@ type RequestPayload = {
|
||||
mindmapId?: string;
|
||||
selectedUids?: string[];
|
||||
documentBlocks?: unknown;
|
||||
node?: unknown;
|
||||
subtree?: unknown;
|
||||
outline?: unknown;
|
||||
evidence?: unknown;
|
||||
};
|
||||
options?: {
|
||||
searxng?: boolean;
|
||||
@@ -85,6 +89,18 @@ const makeRunId = () => {
|
||||
return `run_${Date.now()}_${Math.random().toString(16).slice(2, 10)}`;
|
||||
};
|
||||
|
||||
const serializeContextSnapshot = (label: string, value: unknown, limit: number) => {
|
||||
if (value === undefined) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
const text = JSON.stringify(value);
|
||||
return `${label}=${text.slice(0, limit)}`;
|
||||
} catch {
|
||||
return `${label}=provided`;
|
||||
}
|
||||
};
|
||||
|
||||
const clampSteps = (raw: unknown) => {
|
||||
const parsed = Number(raw ?? DEFAULT_AGENT_MAX_STEPS);
|
||||
if (!Number.isFinite(parsed)) return DEFAULT_AGENT_MAX_STEPS;
|
||||
@@ -157,12 +173,19 @@ const buildHermesInstructions = (
|
||||
lines.push(`selectedUids=${selectedUids.join(",")}`);
|
||||
}
|
||||
if (payload.context?.documentBlocks !== undefined) {
|
||||
try {
|
||||
const snapshot = JSON.stringify(payload.context.documentBlocks);
|
||||
lines.push(`documentBlocksSnapshot=${snapshot.slice(0, 4000)}`);
|
||||
} catch {
|
||||
lines.push("documentBlocksSnapshot=provided");
|
||||
}
|
||||
lines.push(serializeContextSnapshot("documentBlocksSnapshot", payload.context.documentBlocks, 4000) ?? "documentBlocksSnapshot=provided");
|
||||
}
|
||||
if (payload.context?.node !== undefined) {
|
||||
lines.push(serializeContextSnapshot("kernelNode", payload.context.node, 1800) ?? "kernelNode=provided");
|
||||
}
|
||||
if (payload.context?.subtree !== undefined) {
|
||||
lines.push(serializeContextSnapshot("kernelSubtree", payload.context.subtree, 5000) ?? "kernelSubtree=provided");
|
||||
}
|
||||
if (payload.context?.outline !== undefined) {
|
||||
lines.push(serializeContextSnapshot("kernelOutline", payload.context.outline, 2500) ?? "kernelOutline=provided");
|
||||
}
|
||||
if (payload.context?.evidence !== undefined) {
|
||||
lines.push(serializeContextSnapshot("kernelEvidence", payload.context.evidence, 2500) ?? "kernelEvidence=provided");
|
||||
}
|
||||
if (attachments.length > 0) {
|
||||
lines.push(
|
||||
|
||||
Reference in New Issue
Block a user