@nextclaw/kernel 0.4.1 → 0.4.3
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.d.ts +15 -34
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +117 -146
- package/dist/index.js.map +1 -1
- package/package.json +14 -14
package/dist/index.js
CHANGED
|
@@ -145,43 +145,39 @@ function toLegacyMessages(messages, options = {}) {
|
|
|
145
145
|
return legacyMessages;
|
|
146
146
|
}
|
|
147
147
|
//#endregion
|
|
148
|
-
//#region src/features/context-compaction/utils/context-compaction
|
|
148
|
+
//#region src/features/context-compaction/utils/context-compaction.utils.ts
|
|
149
149
|
const NEXTCLAW_TIMELINE_KIND_METADATA_KEY = "nextclaw_timeline_kind";
|
|
150
150
|
const CONTEXT_COMPACTION_TIMELINE_KIND = "context_compaction";
|
|
151
151
|
function readCheckpointTimelineText(checkpoint) {
|
|
152
152
|
return checkpoint.status === "compressing" ? "正在压缩较早上下文" : "较早上下文已自动压缩";
|
|
153
153
|
}
|
|
154
|
-
function
|
|
155
|
-
|
|
154
|
+
function readContextCompactionCheckpoint(message) {
|
|
155
|
+
const metadata = message.metadata;
|
|
156
|
+
return metadata?.["nextclaw_timeline_kind"] === "context_compaction" ? readCompressedContextCompactionCheckpoint(metadata.checkpoint) : null;
|
|
156
157
|
}
|
|
157
|
-
function
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const checkpoint = metadata.checkpoint && typeof metadata.checkpoint === "object" && !Array.isArray(metadata.checkpoint) ? metadata.checkpoint : null;
|
|
163
|
-
if (!checkpoint) return null;
|
|
164
|
-
return {
|
|
165
|
-
[NEXTCLAW_TIMELINE_KIND_METADATA_KEY]: CONTEXT_COMPACTION_TIMELINE_KIND,
|
|
166
|
-
checkpoint
|
|
167
|
-
};
|
|
158
|
+
function readLatestContextCompactionMarker(sessionMessages) {
|
|
159
|
+
return sessionMessages.reduce((marker, message) => {
|
|
160
|
+
const candidateCheckpoint = readContextCompactionCheckpoint(message);
|
|
161
|
+
return candidateCheckpoint && (!marker || Date.parse(candidateCheckpoint.updatedAt) >= Date.parse(marker.checkpoint.updatedAt)) ? { checkpoint: candidateCheckpoint } : marker;
|
|
162
|
+
}, null);
|
|
168
163
|
}
|
|
169
|
-
function
|
|
170
|
-
const
|
|
164
|
+
function buildContextCompactionSummaryMessage(params) {
|
|
165
|
+
const { checkpoint, sessionId } = params;
|
|
171
166
|
return {
|
|
172
|
-
|
|
173
|
-
|
|
167
|
+
id: `${sessionId}:context-compaction-summary:${checkpoint.id}:${checkpoint.updatedAt}`,
|
|
168
|
+
sessionId,
|
|
169
|
+
role: "user",
|
|
170
|
+
status: "final",
|
|
174
171
|
timestamp: checkpoint.updatedAt,
|
|
175
|
-
|
|
172
|
+
parts: [{
|
|
176
173
|
type: "text",
|
|
177
|
-
text
|
|
178
|
-
}]
|
|
179
|
-
ncp_metadata: {
|
|
180
|
-
[NEXTCLAW_TIMELINE_KIND_METADATA_KEY]: CONTEXT_COMPACTION_TIMELINE_KIND,
|
|
181
|
-
checkpoint
|
|
182
|
-
}
|
|
174
|
+
text: checkpoint.summary
|
|
175
|
+
}]
|
|
183
176
|
};
|
|
184
177
|
}
|
|
178
|
+
function createContextCompactionMessageId() {
|
|
179
|
+
return `context-compaction-message-${randomUUID()}`;
|
|
180
|
+
}
|
|
185
181
|
function buildContextCompactionTimelineNcpMessage(params) {
|
|
186
182
|
const { checkpoint, messageId, sessionId } = params;
|
|
187
183
|
const text = readCheckpointTimelineText(checkpoint);
|
|
@@ -201,70 +197,60 @@ function buildContextCompactionTimelineNcpMessage(params) {
|
|
|
201
197
|
}
|
|
202
198
|
};
|
|
203
199
|
}
|
|
204
|
-
function upsertContextCompactionTimelineMessage(params) {
|
|
205
|
-
const { checkpoint, insertBeforeMessageIds = [], session } = params;
|
|
206
|
-
const nextMessage = buildTimelineMessage(checkpoint);
|
|
207
|
-
for (let index = session.events.length - 1; index >= 0; index -= 1) {
|
|
208
|
-
const event = session.events[index];
|
|
209
|
-
const metadata = readTimelineMetadata(event?.data?.message && typeof event.data.message === "object" && !Array.isArray(event.data.message) ? event.data.message : null);
|
|
210
|
-
if (!metadata) continue;
|
|
211
|
-
event.timestamp = checkpoint.updatedAt;
|
|
212
|
-
event.data.message = nextMessage;
|
|
213
|
-
session.messages = session.messages.map((item) => {
|
|
214
|
-
return readTimelineMetadata(item)?.checkpoint.id === metadata.checkpoint.id ? nextMessage : item;
|
|
215
|
-
});
|
|
216
|
-
session.updatedAt = new Date(checkpoint.updatedAt);
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
const event = {
|
|
220
|
-
seq: session.nextSeq,
|
|
221
|
-
type: "message.service",
|
|
222
|
-
timestamp: checkpoint.updatedAt,
|
|
223
|
-
data: { message: nextMessage }
|
|
224
|
-
};
|
|
225
|
-
session.nextSeq += 1;
|
|
226
|
-
const insertionIds = new Set(insertBeforeMessageIds);
|
|
227
|
-
const messageIndex = session.messages.findIndex((message) => typeof message.ncp_message_id === "string" && insertionIds.has(message.ncp_message_id));
|
|
228
|
-
if (messageIndex >= 0) session.messages.splice(messageIndex, 0, nextMessage);
|
|
229
|
-
else session.messages.push(nextMessage);
|
|
230
|
-
const eventIndex = session.events.findIndex((candidateEvent) => {
|
|
231
|
-
const message = candidateEvent?.data?.message && typeof candidateEvent.data.message === "object" && !Array.isArray(candidateEvent.data.message) ? candidateEvent.data.message : null;
|
|
232
|
-
return typeof message?.ncp_message_id === "string" && insertionIds.has(message.ncp_message_id);
|
|
233
|
-
});
|
|
234
|
-
if (eventIndex >= 0) session.events.splice(eventIndex, 0, event);
|
|
235
|
-
else session.events.push(event);
|
|
236
|
-
session.updatedAt = new Date(checkpoint.updatedAt);
|
|
237
|
-
}
|
|
238
200
|
function isContextCompactionTimelineMessage(message) {
|
|
239
201
|
return message?.metadata?.[NEXTCLAW_TIMELINE_KIND_METADATA_KEY] === CONTEXT_COMPACTION_TIMELINE_KIND;
|
|
240
202
|
}
|
|
241
|
-
//#endregion
|
|
242
|
-
//#region src/features/context-compaction/utils/context-compaction-projection.utils.ts
|
|
243
|
-
function readCompactionCheckpoint(message) {
|
|
244
|
-
const metadata = message.metadata;
|
|
245
|
-
return metadata?.["nextclaw_timeline_kind"] === "context_compaction" ? readCompressedContextCompactionCheckpoint(metadata.checkpoint) : null;
|
|
246
|
-
}
|
|
247
203
|
function readLatestContextCompactionCheckpoint(sessionMessages) {
|
|
248
|
-
return sessionMessages
|
|
249
|
-
const candidateCheckpoint = readCompactionCheckpoint(message);
|
|
250
|
-
return candidateCheckpoint && (!checkpoint || Date.parse(candidateCheckpoint.updatedAt) >= Date.parse(checkpoint.updatedAt)) ? candidateCheckpoint : checkpoint;
|
|
251
|
-
}, null);
|
|
204
|
+
return readLatestContextCompactionMarker(sessionMessages)?.checkpoint ?? null;
|
|
252
205
|
}
|
|
253
|
-
function
|
|
206
|
+
function buildContextCompactionModelInput(params) {
|
|
254
207
|
const { sessionId, sessionMessages } = params;
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
return
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
208
|
+
const marker = readLatestContextCompactionMarker(sessionMessages);
|
|
209
|
+
const regularMessages = sessionMessages.filter((message) => !readContextCompactionCheckpoint(message));
|
|
210
|
+
if (!marker) return regularMessages.map((message) => structuredClone(message));
|
|
211
|
+
const { checkpoint } = marker;
|
|
212
|
+
return [buildContextCompactionSummaryMessage({
|
|
213
|
+
checkpoint,
|
|
214
|
+
sessionId
|
|
215
|
+
}), ...regularMessages.filter((message) => Date.parse(message.timestamp) > Date.parse(checkpoint.updatedAt)).sort((left, right) => Date.parse(left.timestamp) - Date.parse(right.timestamp))].map((message) => structuredClone(message));
|
|
216
|
+
}
|
|
217
|
+
function readContextWindowEventSessionId(event) {
|
|
218
|
+
const payload = "payload" in event ? event.payload : null;
|
|
219
|
+
if (!payload || typeof payload !== "object") return null;
|
|
220
|
+
return "sessionId" in payload && typeof payload.sessionId === "string" ? payload.sessionId.trim() || null : null;
|
|
221
|
+
}
|
|
222
|
+
function isContextWindowSnapshot(value) {
|
|
223
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
224
|
+
}
|
|
225
|
+
function createContextWindowSignature(value) {
|
|
226
|
+
return JSON.stringify(value);
|
|
227
|
+
}
|
|
228
|
+
function shouldRefreshContextWindowDuringStream(event) {
|
|
229
|
+
switch (event.type) {
|
|
230
|
+
case NcpEventType.MessageTextStart:
|
|
231
|
+
case NcpEventType.MessageTextDelta:
|
|
232
|
+
case NcpEventType.MessageTextEnd:
|
|
233
|
+
case NcpEventType.MessageReasoningStart:
|
|
234
|
+
case NcpEventType.MessageReasoningDelta:
|
|
235
|
+
case NcpEventType.MessageReasoningEnd:
|
|
236
|
+
case NcpEventType.MessageToolCallStart:
|
|
237
|
+
case NcpEventType.MessageToolCallArgs:
|
|
238
|
+
case NcpEventType.MessageToolCallArgsDelta:
|
|
239
|
+
case NcpEventType.MessageToolCallEnd:
|
|
240
|
+
case NcpEventType.MessageToolCallResult: return true;
|
|
241
|
+
default: return false;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function shouldRefreshContextWindowImmediately(event) {
|
|
245
|
+
switch (event.type) {
|
|
246
|
+
case NcpEventType.MessageSent:
|
|
247
|
+
case NcpEventType.MessageCompleted:
|
|
248
|
+
case NcpEventType.MessageFailed:
|
|
249
|
+
case NcpEventType.MessageAbort:
|
|
250
|
+
case NcpEventType.RunFinished:
|
|
251
|
+
case NcpEventType.RunError: return true;
|
|
252
|
+
default: return false;
|
|
253
|
+
}
|
|
268
254
|
}
|
|
269
255
|
//#endregion
|
|
270
256
|
//#region src/features/context-compaction/services/context-compaction-preflight.service.ts
|
|
@@ -329,7 +315,7 @@ var ContextCompactionPreflightService = class {
|
|
|
329
315
|
storedAgentId
|
|
330
316
|
});
|
|
331
317
|
const existingCheckpoint = readCompressedContextCompactionCheckpoint(storedMetadata[CONTEXT_COMPACTION_METADATA_KEY]) ?? readLatestContextCompactionCheckpoint(sessionMessages);
|
|
332
|
-
const projectedMessages = existingCheckpoint ?
|
|
318
|
+
const projectedMessages = existingCheckpoint ? buildContextCompactionModelInput({
|
|
333
319
|
sessionId,
|
|
334
320
|
sessionMessages
|
|
335
321
|
}) : sessionMessages.filter((message) => !isContextCompactionTimelineMessage(message));
|
|
@@ -356,7 +342,7 @@ var ContextCompactionPreflightService = class {
|
|
|
356
342
|
sessionMessages
|
|
357
343
|
});
|
|
358
344
|
const existingCheckpoint = readCompressedContextCompactionCheckpoint(storedMetadata[CONTEXT_COMPACTION_METADATA_KEY]) ?? readLatestContextCompactionCheckpoint(ncpMessages);
|
|
359
|
-
const messages = toLegacyMessages(existingCheckpoint ?
|
|
345
|
+
const messages = toLegacyMessages(existingCheckpoint ? buildContextCompactionModelInput({
|
|
360
346
|
sessionId,
|
|
361
347
|
sessionMessages: ncpMessages
|
|
362
348
|
}) : ncpMessages.filter((message) => !isContextCompactionTimelineMessage(message)));
|
|
@@ -366,7 +352,7 @@ var ContextCompactionPreflightService = class {
|
|
|
366
352
|
reservedContextTokens
|
|
367
353
|
});
|
|
368
354
|
const plan = !budget.shouldCompact ? null : this.compactionService.prepareForModelInput({
|
|
369
|
-
messages
|
|
355
|
+
messages,
|
|
370
356
|
contextTokens,
|
|
371
357
|
compactionThresholdTokens: budget.triggerTokens
|
|
372
358
|
});
|
|
@@ -452,15 +438,17 @@ var ContextCompactionPreflightService = class {
|
|
|
452
438
|
role: "system",
|
|
453
439
|
content: [
|
|
454
440
|
"You are NextClaw's context compactor for a coding agent session.",
|
|
455
|
-
"Create a
|
|
456
|
-
"
|
|
441
|
+
"Create a complete compressed working context that will replace all prior conversation messages in a future model request.",
|
|
442
|
+
"The model will not receive a raw recent-message tail, so preserve the latest user intent and recent turns with high fidelity inside the summary.",
|
|
443
|
+
"Preserve user goals, explicit instructions, decisions, files touched or inspected, code changes, commands run, test results, failures, blockers, current task state, and exact next steps.",
|
|
457
444
|
"Do not invent facts. If something is uncertain, mark it as uncertain.",
|
|
458
|
-
"Return Markdown only. Start with '# Compressed
|
|
445
|
+
"Return Markdown only. Start with '# Compressed Working Context'."
|
|
459
446
|
].join("\n")
|
|
460
447
|
}, {
|
|
461
448
|
role: "user",
|
|
462
449
|
content: [
|
|
463
|
-
"Compress these
|
|
450
|
+
"Compress these runtime messages into a reusable working context.",
|
|
451
|
+
"Include a 'Recent High-Fidelity Context' section for the latest important user/assistant turns.",
|
|
464
452
|
"",
|
|
465
453
|
"Messages JSON:",
|
|
466
454
|
stringifyCompactionSource(messages)
|
|
@@ -491,46 +479,6 @@ var ContextWindowPreviewManager = class {
|
|
|
491
479
|
};
|
|
492
480
|
};
|
|
493
481
|
//#endregion
|
|
494
|
-
//#region src/features/context-compaction/utils/context-window-event.utils.ts
|
|
495
|
-
function readContextWindowEventSessionId(event) {
|
|
496
|
-
const payload = "payload" in event ? event.payload : null;
|
|
497
|
-
if (!payload || typeof payload !== "object") return null;
|
|
498
|
-
return "sessionId" in payload && typeof payload.sessionId === "string" ? payload.sessionId.trim() || null : null;
|
|
499
|
-
}
|
|
500
|
-
function isContextWindowSnapshot(value) {
|
|
501
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
502
|
-
}
|
|
503
|
-
function createContextWindowSignature(value) {
|
|
504
|
-
return JSON.stringify(value);
|
|
505
|
-
}
|
|
506
|
-
function shouldRefreshContextWindowDuringStream(event) {
|
|
507
|
-
switch (event.type) {
|
|
508
|
-
case NcpEventType.MessageTextStart:
|
|
509
|
-
case NcpEventType.MessageTextDelta:
|
|
510
|
-
case NcpEventType.MessageTextEnd:
|
|
511
|
-
case NcpEventType.MessageReasoningStart:
|
|
512
|
-
case NcpEventType.MessageReasoningDelta:
|
|
513
|
-
case NcpEventType.MessageReasoningEnd:
|
|
514
|
-
case NcpEventType.MessageToolCallStart:
|
|
515
|
-
case NcpEventType.MessageToolCallArgs:
|
|
516
|
-
case NcpEventType.MessageToolCallArgsDelta:
|
|
517
|
-
case NcpEventType.MessageToolCallEnd:
|
|
518
|
-
case NcpEventType.MessageToolCallResult: return true;
|
|
519
|
-
default: return false;
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
function shouldRefreshContextWindowImmediately(event) {
|
|
523
|
-
switch (event.type) {
|
|
524
|
-
case NcpEventType.MessageSent:
|
|
525
|
-
case NcpEventType.MessageCompleted:
|
|
526
|
-
case NcpEventType.MessageFailed:
|
|
527
|
-
case NcpEventType.MessageAbort:
|
|
528
|
-
case NcpEventType.RunFinished:
|
|
529
|
-
case NcpEventType.RunError: return true;
|
|
530
|
-
default: return false;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
//#endregion
|
|
534
482
|
//#region src/managers/agent-run-context-compaction.manager.ts
|
|
535
483
|
var AgentRunContextCompactionManager = class {
|
|
536
484
|
preflightService;
|
|
@@ -3270,13 +3218,7 @@ function readMessageFromSummaryEvent(event) {
|
|
|
3270
3218
|
if (event.type === NcpEventType.MessageSent || event.type === NcpEventType.MessageCompleted || event.type === "session.snapshot.message") return event.payload.message;
|
|
3271
3219
|
}
|
|
3272
3220
|
//#endregion
|
|
3273
|
-
//#region src/
|
|
3274
|
-
const DEFAULT_SESSION_TYPE = "native";
|
|
3275
|
-
const DEFAULT_LIFECYCLE = "persistent";
|
|
3276
|
-
const SESSION_METADATA_LABEL_KEY = "label";
|
|
3277
|
-
const CHILD_SESSION_PARENT_METADATA_KEY = "parent_session_id";
|
|
3278
|
-
const CHILD_SESSION_REQUEST_METADATA_KEY = "spawned_by_request_id";
|
|
3279
|
-
const CHILD_SESSION_LIFECYCLE_METADATA_KEY = "session_lifecycle";
|
|
3221
|
+
//#region src/utils/session-manager.utils.ts
|
|
3280
3222
|
function normalizeSessionId(sessionId) {
|
|
3281
3223
|
return sessionId.trim();
|
|
3282
3224
|
}
|
|
@@ -3295,6 +3237,37 @@ function readOptionalMetadataString(value) {
|
|
|
3295
3237
|
function readEventSessionId$1(event) {
|
|
3296
3238
|
return "payload" in event && "sessionId" in event.payload ? readOptionalMetadataString(event.payload.sessionId) : void 0;
|
|
3297
3239
|
}
|
|
3240
|
+
//#endregion
|
|
3241
|
+
//#region src/services/session-working-dir-resolver.service.ts
|
|
3242
|
+
var SessionWorkingDirResolver = class {
|
|
3243
|
+
constructor(configManager) {
|
|
3244
|
+
this.configManager = configManager;
|
|
3245
|
+
}
|
|
3246
|
+
withWorkingDir = (summary) => ({
|
|
3247
|
+
...summary,
|
|
3248
|
+
workingDir: this.resolve({
|
|
3249
|
+
agentId: summary.agentId,
|
|
3250
|
+
metadata: summary.metadata
|
|
3251
|
+
})
|
|
3252
|
+
});
|
|
3253
|
+
resolve = (params) => {
|
|
3254
|
+
const config = this.configManager.loadConfig();
|
|
3255
|
+
const defaultAgentId = resolveDefaultAgentProfileId(config);
|
|
3256
|
+
const profile = findEffectiveAgentProfile(config, readOptionalString$7(params.agentId) ?? defaultAgentId) ?? findEffectiveAgentProfile(config, defaultAgentId);
|
|
3257
|
+
return resolveSessionWorkspacePath({
|
|
3258
|
+
sessionMetadata: params.metadata,
|
|
3259
|
+
workspace: profile?.workspace ?? config.agents.defaults.workspace
|
|
3260
|
+
});
|
|
3261
|
+
};
|
|
3262
|
+
};
|
|
3263
|
+
//#endregion
|
|
3264
|
+
//#region src/managers/session.manager.ts
|
|
3265
|
+
const DEFAULT_SESSION_TYPE = "native";
|
|
3266
|
+
const DEFAULT_LIFECYCLE = "persistent";
|
|
3267
|
+
const SESSION_METADATA_LABEL_KEY = "label";
|
|
3268
|
+
const CHILD_SESSION_PARENT_METADATA_KEY = "parent_session_id";
|
|
3269
|
+
const CHILD_SESSION_REQUEST_METADATA_KEY = "spawned_by_request_id";
|
|
3270
|
+
const CHILD_SESSION_LIFECYCLE_METADATA_KEY = "session_lifecycle";
|
|
3298
3271
|
function isDurableSessionEvent(event) {
|
|
3299
3272
|
return event.type !== NcpEventType.ContextWindowUpdated;
|
|
3300
3273
|
}
|
|
@@ -3368,10 +3341,12 @@ function isSessionSummaryRefreshEvent(event) {
|
|
|
3368
3341
|
var SessionManager = class {
|
|
3369
3342
|
cleanups = [];
|
|
3370
3343
|
contextWindowPreview;
|
|
3344
|
+
workingDirResolver;
|
|
3371
3345
|
started = false;
|
|
3372
3346
|
constructor(options) {
|
|
3373
3347
|
this.options = options;
|
|
3374
3348
|
this.contextWindowPreview = new ContextWindowPreviewManager({ configManager: options.configManager });
|
|
3349
|
+
this.workingDirResolver = new SessionWorkingDirResolver(options.configManager);
|
|
3375
3350
|
}
|
|
3376
3351
|
start = () => {
|
|
3377
3352
|
if (this.started) return;
|
|
@@ -3489,7 +3464,7 @@ var SessionManager = class {
|
|
|
3489
3464
|
};
|
|
3490
3465
|
listSessions = async (options) => {
|
|
3491
3466
|
const peerId = readOptionalString$7(options?.peerId);
|
|
3492
|
-
return applyLimit((await this.options.journalStore.listSessionSummaries()).filter((summary) => !peerId || summary.peerId === peerId), options?.limit);
|
|
3467
|
+
return applyLimit((await this.options.journalStore.listSessionSummaries()).filter((summary) => !peerId || summary.peerId === peerId).map(this.workingDirResolver.withWorkingDir), options?.limit);
|
|
3493
3468
|
};
|
|
3494
3469
|
listSessionMessages = async (sessionId, options) => {
|
|
3495
3470
|
const normalizedSessionId = normalizeSessionId(sessionId);
|
|
@@ -3598,7 +3573,7 @@ var SessionManager = class {
|
|
|
3598
3573
|
this.options.eventBus.emit(eventKeys.sessionSummaryDelete, { sessionKey: normalizedSessionKey });
|
|
3599
3574
|
};
|
|
3600
3575
|
createSummaryFromRecord = (record, includeContextWindow = false) => {
|
|
3601
|
-
const summary = createNcpAgentSessionSummary(record);
|
|
3576
|
+
const summary = this.workingDirResolver.withWorkingDir(createNcpAgentSessionSummary(record));
|
|
3602
3577
|
const contextWindow = includeContextWindow ? this.contextWindowPreview.preview({
|
|
3603
3578
|
requestMetadata: record.metadata ?? {},
|
|
3604
3579
|
sessionId: record.sessionId,
|
|
@@ -7622,7 +7597,7 @@ var AgentRuntimeRegistry = class {
|
|
|
7622
7597
|
//#endregion
|
|
7623
7598
|
//#region src/services/agent-run-message-projector.service.ts
|
|
7624
7599
|
var AgentRunMessageProjector = class {
|
|
7625
|
-
project = (params) =>
|
|
7600
|
+
project = (params) => buildContextCompactionModelInput({
|
|
7626
7601
|
sessionId: params.sessionId,
|
|
7627
7602
|
sessionMessages: params.messages
|
|
7628
7603
|
});
|
|
@@ -8130,11 +8105,7 @@ var ProjectContextProvider = class {
|
|
|
8130
8105
|
//#endregion
|
|
8131
8106
|
//#region src/contributions/context-provider/providers/reply-format-context.provider.ts
|
|
8132
8107
|
var ReplyFormatContextProvider = class {
|
|
8133
|
-
provide = (_request) => [[
|
|
8134
|
-
"## Reply Formatting",
|
|
8135
|
-
"- When mentioning a local project file in a user-visible reply, prefer a Markdown link such as `[AGENTS.md](AGENTS.md)` or `[file](packages/example/file.ts)` so the user can open it.",
|
|
8136
|
-
"- Use project-relative links for files under the active/session-bound project root; use absolute links only for files outside it."
|
|
8137
|
-
].join("\n")];
|
|
8108
|
+
provide = (_request) => ["## Reply Formatting Contract\nGoal: local openable files mentioned in user-visible replies must be clickable.\nAllowed form: use Markdown links only, with a plain text label and an openable href: [MEMORY.md](MEMORY.md), [file](packages/example/file.ts), [notes.md](/Users/example/Documents/notes.md).\nPath choice: use project-relative hrefs for files under the active/session project root, and absolute hrefs for local files outside it.\nForbidden forms: bare file names or paths, inline-code file names, bold-only file names, code-styled link labels, code blocks for file references, and unlinked comma-separated file lists.\nExamples: bad `MEMORY.md` -> good [MEMORY.md](MEMORY.md); bad `memory/` -> good [memory/](memory/); bad `2026-03-07.md` / `feishu-notes.md` -> good [2026-03-07.md](memory/2026-03-07.md) / [feishu-notes.md](memory/feishu-notes.md).\nSelf-check before sending: scan the final visible reply for local file names or paths. If every concrete file cannot be linked, remove the exact names and summarize instead."];
|
|
8138
8109
|
};
|
|
8139
8110
|
//#endregion
|
|
8140
8111
|
//#region src/contributions/context-provider/providers/skills-context.provider.ts
|
|
@@ -10210,6 +10181,6 @@ function resolveLegacyEventType(message) {
|
|
|
10210
10181
|
return `message.${role || "other"}`;
|
|
10211
10182
|
}
|
|
10212
10183
|
//#endregion
|
|
10213
|
-
export { AccessManager, AgentManager, AgentRunClient, AgentRuntimeRegistry, AutomationManager, BuiltinNarpRuntimeProviderService, CONTEXT_COMPACTION_TIMELINE_KIND, ChannelManager, CommandRegistry, ConfigManager, ContextCompactionPreflightService, ContextWindowPreviewManager, DEFAULT_AGENT_RUNTIME_ENTRY_ID, DEFAULT_SERVICE_ACTION_RISK, ExtensionManager, GatewayInboundProcessor, LlmProviderManager, LlmUsageManager, LlmUsageStore, McpManager, McpServiceAppRuntimeService, NARP_HTTP_RUNTIME_KIND, NARP_STDIO_RUNTIME_KIND, NEXTCLAW_TIMELINE_KIND_METADATA_KEY, NcpAgentSessionJournalStore, NextclawKernel, PANEL_APP_AGENT_CAPABILITIES, PanelAppAssetTokenService, PanelAppError, PanelAppManager, ProviderManagerNcpLLMApi, SERVICE_APP_MANIFEST_FILE_NAME, ServiceAppError, ServiceAppManager, SessionManager, SessionRequestManager, SkillManager, UpdateManifestReader, buildAgentRunSendPayload, buildContextCompactionTimelineNcpMessage, buildLlmUsageSummary, buildLocalizedTextMap, buildServiceActionId, createAgentRuntimeSessionRequestDispatcher, createAssetTools, createContextCompactionMessageId, createContextWindowSignature, createLlmUsageRecord, dispatchAgentRuntimeSessionRequest, dispatchChannelReplyRoute, dispatchPromptOverNcp, getServiceActionName, getServiceAppManifestPath, getUnsignedUpdateManifest, hasLlmUsageTelemetry, isContextCompactionTimelineMessage, isContextWindowSnapshot, isPanelAppAgentCapability, isPanelAppError, isReplyCapableChannel, isServiceAppError, listExtensionChannelIds, listServiceAppManifestActions, mergeServiceAppRuntimeActions, normalizeAgentRuntimeSessionTypeIcon, normalizeLlmUsageModel, normalizeOptionalString, parseServiceAppManifest, parseSkillFrontmatter,
|
|
10184
|
+
export { AccessManager, AgentManager, AgentRunClient, AgentRuntimeRegistry, AutomationManager, BuiltinNarpRuntimeProviderService, CONTEXT_COMPACTION_TIMELINE_KIND, ChannelManager, CommandRegistry, ConfigManager, ContextCompactionPreflightService, ContextWindowPreviewManager, DEFAULT_AGENT_RUNTIME_ENTRY_ID, DEFAULT_SERVICE_ACTION_RISK, ExtensionManager, GatewayInboundProcessor, LlmProviderManager, LlmUsageManager, LlmUsageStore, McpManager, McpServiceAppRuntimeService, NARP_HTTP_RUNTIME_KIND, NARP_STDIO_RUNTIME_KIND, NEXTCLAW_TIMELINE_KIND_METADATA_KEY, NcpAgentSessionJournalStore, NextclawKernel, PANEL_APP_AGENT_CAPABILITIES, PanelAppAssetTokenService, PanelAppError, PanelAppManager, ProviderManagerNcpLLMApi, SERVICE_APP_MANIFEST_FILE_NAME, ServiceAppError, ServiceAppManager, SessionManager, SessionRequestManager, SkillManager, UpdateManifestReader, buildAgentRunSendPayload, buildContextCompactionModelInput, buildContextCompactionTimelineNcpMessage, buildLlmUsageSummary, buildLocalizedTextMap, buildServiceActionId, createAgentRuntimeSessionRequestDispatcher, createAssetTools, createContextCompactionMessageId, createContextWindowSignature, createLlmUsageRecord, dispatchAgentRuntimeSessionRequest, dispatchChannelReplyRoute, dispatchPromptOverNcp, getServiceActionName, getServiceAppManifestPath, getUnsignedUpdateManifest, hasLlmUsageTelemetry, isContextCompactionTimelineMessage, isContextWindowSnapshot, isPanelAppAgentCapability, isPanelAppError, isReplyCapableChannel, isServiceAppError, listExtensionChannelIds, listServiceAppManifestActions, mergeServiceAppRuntimeActions, normalizeAgentRuntimeSessionTypeIcon, normalizeLlmUsageModel, normalizeOptionalString, parseServiceAppManifest, parseSkillFrontmatter, readContextWindowEventSessionId, readLatestContextCompactionCheckpoint, readLearningLoopRuntimeConfig, readMetadataModel, readMetadataThinking, readServiceAppManifest, resolveAgentRuntimeEntries, resolveChannelReplyRoute, resolveEffectiveModel, resolveLegacyEventType, resolveNextclawNcpRunContext, resolveSessionChannelContext, runGatewayInboundLoop, sanitizeLlmUsage, serializeUnsignedUpdateManifest, shouldRefreshContextWindowDuringStream, shouldRefreshContextWindowImmediately, stripSkillFrontmatter, syncSessionThinkingPreference, toNcpMessages, waitForAgentRuntimeSessionReply };
|
|
10214
10185
|
|
|
10215
10186
|
//# sourceMappingURL=index.js.map
|