@nextclaw/kernel 0.19.9 → 0.19.10
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/app/worker/index.d.ts +1 -1
- package/dist/app/worker/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{nextclaw-harness.manager-BDFxf9mf.d.ts → nextclaw-harness.manager-DNikX-6b.d.ts} +2 -2
- package/dist/nextclaw-harness.manager-DNikX-6b.d.ts.map +1 -0
- package/dist/{nextclaw-harness.manager-CjDdaCHx.js → nextclaw-harness.manager-DxFwGy-d.js} +45 -19
- package/dist/nextclaw-harness.manager-DxFwGy-d.js.map +1 -0
- package/package.json +8 -8
- package/dist/nextclaw-harness.manager-BDFxf9mf.d.ts.map +0 -1
- package/dist/nextclaw-harness.manager-CjDdaCHx.js.map +0 -1
|
@@ -763,6 +763,7 @@ function decodeNcpAgentSessionMessageCursor(cursor, maximumBoundary) {
|
|
|
763
763
|
if (!Number.isSafeInteger(ordinal) || ordinal < 1 || ordinal > maximumBoundary) throw new SessionMessageCursorError();
|
|
764
764
|
return ordinal;
|
|
765
765
|
}
|
|
766
|
+
const SESSION_RUN_BYTES = 8 * 1024 * 1024;
|
|
766
767
|
/** Serialize JSON without allocating another complete copy of a giant string/part. */
|
|
767
768
|
function* sessionJsonFragments(value, sortedKeys = false) {
|
|
768
769
|
if (typeof value === "string") {
|
|
@@ -810,6 +811,14 @@ function* sessionJsonChunks(value) {
|
|
|
810
811
|
}
|
|
811
812
|
if (chunk) yield chunk;
|
|
812
813
|
}
|
|
814
|
+
function measureSessionJsonBytes(value, limit = SESSION_RUN_BYTES) {
|
|
815
|
+
let bytes = 0;
|
|
816
|
+
for (const fragment of sessionJsonFragments(value)) {
|
|
817
|
+
bytes += Buffer.byteLength(fragment);
|
|
818
|
+
if (bytes > limit) break;
|
|
819
|
+
}
|
|
820
|
+
return bytes;
|
|
821
|
+
}
|
|
813
822
|
function preview(value, remaining, depth = 0) {
|
|
814
823
|
if (remaining.chars <= 0) return "[archived; read source]";
|
|
815
824
|
if (typeof value === "string") {
|
|
@@ -834,18 +843,18 @@ function buildSessionValuePreview(value) {
|
|
|
834
843
|
return preview(value, { chars: 8192 });
|
|
835
844
|
}
|
|
836
845
|
function previewMessagePart(part, budget) {
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
const
|
|
840
|
-
const
|
|
846
|
+
if (part.type !== "tool-invocation") return preview(part, budget);
|
|
847
|
+
const result = part.result !== void 0 ? preview(part.result, budget) : void 0;
|
|
848
|
+
const args = part.args !== void 0 ? preview(part.args, budget) : void 0;
|
|
849
|
+
const items = preview(part.resultContentItems, budget);
|
|
850
|
+
const contentItems = Array.isArray(items) ? items.filter((item) => item !== null && typeof item === "object" && (item.type === "input_text" && typeof item.text === "string" || item.type === "input_image" && typeof item.imageUrl === "string" && !item.imageUrl.includes("[archived; read source]"))) : void 0;
|
|
841
851
|
return {
|
|
842
852
|
type: "tool-invocation",
|
|
843
853
|
toolName: part.toolName,
|
|
844
854
|
toolCallId: part.toolCallId,
|
|
845
855
|
state: part.state,
|
|
846
|
-
|
|
847
|
-
...part.
|
|
848
|
-
...part.result !== void 0 ? { result: fields.result !== void 0 ? fields.result : "[archived; read source]" } : {},
|
|
856
|
+
...part.args !== void 0 ? { args: part.args && typeof part.args === "object" && typeof args !== "object" ? {} : args ?? {} } : {},
|
|
857
|
+
...part.result !== void 0 ? { result } : {},
|
|
849
858
|
...contentItems ? { resultContentItems: contentItems } : {},
|
|
850
859
|
...part.execution ? { execution: part.execution } : {}
|
|
851
860
|
};
|
|
@@ -871,6 +880,8 @@ function buildSessionMessageDescriptor(message, revision) {
|
|
|
871
880
|
}
|
|
872
881
|
}
|
|
873
882
|
};
|
|
883
|
+
const offsets = message.metadata?.[MODEL_ROUND_PART_OFFSETS];
|
|
884
|
+
if (Array.isArray(offsets)) descriptor.metadata[MODEL_ROUND_PART_OFFSETS] = offsets.slice(-1024);
|
|
874
885
|
if (message.metadata?.nextclaw_timeline_kind === "context_compaction") descriptor.metadata = {
|
|
875
886
|
...message.metadata,
|
|
876
887
|
nextclaw_source: descriptor.metadata?.nextclaw_source
|
|
@@ -1526,7 +1537,7 @@ var SessionMessageSqlProjectionStore = class {
|
|
|
1526
1537
|
const row = database.prepare("SELECT value FROM projection_meta WHERE id=1").get();
|
|
1527
1538
|
if (!row) return null;
|
|
1528
1539
|
const meta = JSON.parse(row.value);
|
|
1529
|
-
return meta.version ===
|
|
1540
|
+
return meta.version === 13 && meta.sessionId === sessionId && (preparing || !meta.preparation || meta.preparation.status === "ready") ? meta : null;
|
|
1530
1541
|
};
|
|
1531
1542
|
readMeta = async (sessionId, preparing = false) => {
|
|
1532
1543
|
const database = await this.database(sessionId);
|
|
@@ -1688,7 +1699,7 @@ var SessionMessageSqlProjectionStore = class {
|
|
|
1688
1699
|
try {
|
|
1689
1700
|
database.exec("DELETE FROM messages; DELETE FROM part_fields; DELETE FROM part_chunks; DELETE FROM part_previews; DELETE FROM tool_owners; DELETE FROM settled_tools; DELETE FROM session_questions; DELETE FROM session_interruptions; DELETE FROM interruption_fields; DELETE FROM interruption_chunks;");
|
|
1690
1701
|
const meta = {
|
|
1691
|
-
version:
|
|
1702
|
+
version: 13,
|
|
1692
1703
|
sessionId: params.sessionId,
|
|
1693
1704
|
total: 0,
|
|
1694
1705
|
dataBytes: 0,
|
|
@@ -7880,13 +7891,9 @@ var SessionRun = class {
|
|
|
7880
7891
|
this.applyRunEvents(events);
|
|
7881
7892
|
let archived = false;
|
|
7882
7893
|
const conversationEvents = events.filter(isConversationStateEvent).map((event) => {
|
|
7883
|
-
|
|
7884
|
-
for (const fragment of sessionJsonFragments(event)) {
|
|
7885
|
-
bytes += Buffer.byteLength(fragment);
|
|
7886
|
-
if (bytes > 64 * 1024) break;
|
|
7887
|
-
}
|
|
7894
|
+
const bytes = measureSessionJsonBytes(event);
|
|
7888
7895
|
this.windowGrowthBytes += bytes;
|
|
7889
|
-
if (bytes <=
|
|
7896
|
+
if (bytes <= 8388608) return event;
|
|
7890
7897
|
archived = true;
|
|
7891
7898
|
if (event.type === NcpEventType.MessageSent || event.type === NcpEventType.MessageCompleted) return {
|
|
7892
7899
|
...event,
|
|
@@ -7911,15 +7918,19 @@ var SessionRun = class {
|
|
|
7911
7918
|
const start = message.role === "assistant" ? Math.max(0, message.parts.length - 16) : 0;
|
|
7912
7919
|
const descriptor = buildSessionMessageDescriptor({
|
|
7913
7920
|
...message,
|
|
7914
|
-
parts:
|
|
7921
|
+
parts: []
|
|
7915
7922
|
}, "runtime");
|
|
7923
|
+
descriptor.parts = message.parts.slice(start, start + 16).map((part) => buildSessionMessageDescriptor({
|
|
7924
|
+
...message,
|
|
7925
|
+
parts: [part]
|
|
7926
|
+
}, "runtime").parts[0]);
|
|
7916
7927
|
const offsets = message.metadata?.[MODEL_ROUND_PART_OFFSETS];
|
|
7917
7928
|
return {
|
|
7918
7929
|
...descriptor,
|
|
7919
7930
|
metadata: {
|
|
7920
7931
|
...descriptor.metadata,
|
|
7921
7932
|
nextclaw_archived_body: true,
|
|
7922
|
-
...Array.isArray(offsets) ? { [MODEL_ROUND_PART_OFFSETS]: offsets.map((offset) => Number(offset) - start).filter((offset) => offset
|
|
7933
|
+
...Array.isArray(offsets) ? { [MODEL_ROUND_PART_OFFSETS]: offsets.map((offset) => Number(offset) - start).filter((offset) => offset > 0 && offset <= descriptor.parts.length) } : {},
|
|
7923
7934
|
...message.role === "assistant" ? {
|
|
7924
7935
|
nextclaw_partial_projection: true,
|
|
7925
7936
|
[CONTEXT_COMPACTION_PART_START]: base + start
|
|
@@ -7936,7 +7947,21 @@ var SessionRun = class {
|
|
|
7936
7947
|
const state = this.stateManager.getSnapshot();
|
|
7937
7948
|
const messages = this.getSnapshot().messages;
|
|
7938
7949
|
const checkpoint = messages.filter((message) => message.metadata?.nextclaw_timeline_kind === "context_compaction").at(-1);
|
|
7939
|
-
const
|
|
7950
|
+
const regular = messages.filter((message) => message.metadata?.nextclaw_timeline_kind !== "context_compaction");
|
|
7951
|
+
const tail = [];
|
|
7952
|
+
let bytes = checkpoint ? measureSessionJsonBytes(checkpoint) : 0;
|
|
7953
|
+
let parts = checkpoint?.parts.length ?? 0;
|
|
7954
|
+
for (const message of regular.slice(-254).reverse()) {
|
|
7955
|
+
const size = measureSessionJsonBytes(message);
|
|
7956
|
+
const keepComplete = bytes + size <= 8388608 - 64 * 1024 && parts + message.parts.length <= 1024;
|
|
7957
|
+
const view = keepComplete ? message : this.archiveMessageView(message);
|
|
7958
|
+
const viewBytes = keepComplete ? size : measureSessionJsonBytes(view);
|
|
7959
|
+
if (bytes + viewBytes > 8388608 || parts + view.parts.length > 1024) break;
|
|
7960
|
+
tail.unshift(view);
|
|
7961
|
+
bytes += viewBytes;
|
|
7962
|
+
parts += view.parts.length;
|
|
7963
|
+
}
|
|
7964
|
+
if (regular.length > tail.length && tail.length && !tail.some((message) => message.metadata?.nextclaw_archived_body)) tail[0] = this.archiveMessageView(tail[0]);
|
|
7940
7965
|
if (checkpoint) tail.push(checkpoint);
|
|
7941
7966
|
this.stateManager.hydrate({
|
|
7942
7967
|
sessionId: this.sessionId,
|
|
@@ -7990,6 +8015,7 @@ var SessionRun = class {
|
|
|
7990
8015
|
metadata: {
|
|
7991
8016
|
...streaming.metadata,
|
|
7992
8017
|
nextclaw_partial_projection: true,
|
|
8018
|
+
[MODEL_ROUND_PART_OFFSETS]: [],
|
|
7993
8019
|
[CONTEXT_COMPACTION_PART_START]: end,
|
|
7994
8020
|
nextclaw_source: {
|
|
7995
8021
|
messageId: streaming.id,
|
|
@@ -9629,4 +9655,4 @@ var NextclawHarness = class {
|
|
|
9629
9655
|
//#endregion
|
|
9630
9656
|
export { SessionMessageSqlProjectionStore as $, ContextProviderRunContextService as A, normalizeOptionalString$2 as B, ToolProviderRunContextService as C, readProjectId as D, createAgentToolRunTriggerInput as E, CurrentSessionContextProvider as F, syncSessionThinkingPreference as G, readMetadataThinking as H, AgentBootstrapContextProvider as I, describeAgentRuntimeSessionTypes as J, appendCurrentTimeContextTail as K, renderAgentBootstrapContext as L, ExecutionPolicyContextProvider as M, renderAgentSafetyContext as N, readProjectRoot as O, renderSystemExecutionPolicy as P, SessionMessagePreparationStore as Q, truncateContextText as R, AgentManager as S, attachSourceToolCall as T, resolveEffectiveModel as U, readMetadataModel as V, resolveSessionChannelContext as W, resolveAgentRuntimeEntries as X, normalizeAgentRuntimeSessionTypeIcon as Y, readSessionJournalFailureContext as Z, createQuestionMessage as _, AgentRunClient as _t, dispatchAgentRuntimeSessionRequest as a, isSessionSettingsError as at, SessionManager as b, Contribution$1 as c, assertObservationJsonValue as ct, dispatchPromptOverNcpResult as d, evaluateObservationEventAdmission as dt, SessionEventProjectionStore as et, startPromptOverNcpExecution as f, matchesObservationPredicate as ft, USER_QUESTION_EXTENSION_TYPE as g, DEFAULT_AGENT_RUNTIME_ENTRY_ID as gt, UserQuestionManager as h, toBoundedJson as ht, createAgentRuntimeSessionRequestSourceNotifier as i, isSessionMessageCursorError as it, WorkspaceMemoryContextProvider as j, buildRunMetadata as k, NextclawHarnessError as l, assertObservationPredicate as lt, UserQuestionError as m, readJsonPointer as mt, buildSessionRequestCompletionMessage as n, SessionMessageCursorError as nt, waitForAgentRuntimeSessionReply as o, applyNcpAgentRunLifecycleEvent as ot, buildAgentRunSendPayload as p, parseObservationDuration as pt, serializeModelInputTail as q, createAgentRuntimeSessionRequestDispatcher as r, SessionSettingsError as rt, SessionRequestManager as s, isNcpAgentRunLifecycleEvent as st, NextclawHarness as t, sessionJsonChunks as tt, dispatchPromptOverNcp as u, buildObservationEventModelMessage as ut, createQuestionResolutionMessage as v, CommandRegistry as vt, createShowContentTools as w, createWorkspaceByteTools as x, projectUserQuestions as y, buildNextclawNcpRunContext as z };
|
|
9631
9657
|
|
|
9632
|
-
//# sourceMappingURL=nextclaw-harness.manager-
|
|
9658
|
+
//# sourceMappingURL=nextclaw-harness.manager-DxFwGy-d.js.map
|