@scotthamilton77/sidekick 0.1.29 → 0.1.31
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.
|
@@ -124,3 +124,8 @@ settings:
|
|
|
124
124
|
# When non-off, the persona-voice reminder is replaced by a compact caveman
|
|
125
125
|
# directive and the statusline shows the level.
|
|
126
126
|
cavemanMode: "off"
|
|
127
|
+
# Inject persona/caveman into non-interactive (claude -p) sessions. Default
|
|
128
|
+
# false — no human reads a programmatic session, so the voice is wasted tokens.
|
|
129
|
+
# Set true to opt back in.
|
|
130
|
+
injectPersonaIntoNonInteractiveSessions: false
|
|
131
|
+
injectCavemanIntoNonInteractiveSessions: false
|
package/dist/bin.js
CHANGED
|
@@ -47579,7 +47579,7 @@ var require_build_identity = __commonJS({
|
|
|
47579
47579
|
var path_1 = __importDefault2(require("path"));
|
|
47580
47580
|
var DEV_PREFIX = "dev:";
|
|
47581
47581
|
var NO_DIST_SENTINEL = "nodist";
|
|
47582
|
-
function computeBuildIdentity(injectedVersion = true ? "0.1.
|
|
47582
|
+
function computeBuildIdentity(injectedVersion = true ? "0.1.31" : void 0, devFingerprint = computeDevFingerprint) {
|
|
47583
47583
|
return injectedVersion !== void 0 ? injectedVersion : DEV_PREFIX + devFingerprint();
|
|
47584
47584
|
}
|
|
47585
47585
|
function computeDevFingerprint() {
|
|
@@ -61989,7 +61989,7 @@ var require_transcript_metrics_engine = __commonJS({
|
|
|
61989
61989
|
exports2.isExcludedBuiltinCommandInvocation = isExcludedBuiltinCommandInvocation;
|
|
61990
61990
|
exports2.updateToolsPerTurn = updateToolsPerTurn;
|
|
61991
61991
|
var transcript_helpers_js_1 = require_transcript_helpers();
|
|
61992
|
-
async function processEntry(entry, lineNumber, metrics, toolUseIdToName, emitEvent) {
|
|
61992
|
+
async function processEntry(entry, lineNumber, metrics, toolUseIdToName, emitEvent, signalCompaction) {
|
|
61993
61993
|
const entryType = entry.type;
|
|
61994
61994
|
switch (entryType) {
|
|
61995
61995
|
case "user": {
|
|
@@ -62018,8 +62018,13 @@ var require_transcript_metrics_engine = __commonJS({
|
|
|
62018
62018
|
await emitEvent("AssistantMessage", entry, lineNumber);
|
|
62019
62019
|
await processNestedToolUses(entry, lineNumber, metrics, toolUseIdToName, emitEvent);
|
|
62020
62020
|
break;
|
|
62021
|
-
case "system":
|
|
62021
|
+
case "system": {
|
|
62022
|
+
const subtype = entry.subtype;
|
|
62023
|
+
if (subtype === "compact_boundary") {
|
|
62024
|
+
await signalCompaction?.(lineNumber);
|
|
62025
|
+
}
|
|
62022
62026
|
break;
|
|
62027
|
+
}
|
|
62023
62028
|
}
|
|
62024
62029
|
}
|
|
62025
62030
|
function extractTokenUsage(entry, metrics) {
|
|
@@ -64477,10 +64482,12 @@ var require_transcript_service = __commonJS({
|
|
|
64477
64482
|
// ============================================================================
|
|
64478
64483
|
// Compaction Management
|
|
64479
64484
|
// ============================================================================
|
|
64480
|
-
async signalCompaction() {
|
|
64485
|
+
async signalCompaction(lineNumber) {
|
|
64486
|
+
if (this.metrics.isPostCompactIndeterminate)
|
|
64487
|
+
return;
|
|
64481
64488
|
this.metrics.currentContextTokens = null;
|
|
64482
64489
|
this.metrics.isPostCompactIndeterminate = true;
|
|
64483
|
-
await this.emitEvent("Compact", {}, this.metrics.lastProcessedLine);
|
|
64490
|
+
await this.emitEvent("Compact", {}, lineNumber ?? this.metrics.lastProcessedLine);
|
|
64484
64491
|
this.notifyMetricsChange();
|
|
64485
64492
|
this.schedulePersistence();
|
|
64486
64493
|
}
|
|
@@ -64538,7 +64545,7 @@ var require_transcript_service = __commonJS({
|
|
|
64538
64545
|
return;
|
|
64539
64546
|
const self = this;
|
|
64540
64547
|
await (0, transcript_file_watcher_js_1.processTranscriptFile)(this.transcriptPath, this.streamingState, this.metrics, async (entry, lineNumber) => {
|
|
64541
|
-
await (0, transcript_metrics_engine_js_1.processEntry)(entry, lineNumber, this.metrics, this.toolUseIdToName, (eventType, e, ln) => this.emitEvent(eventType, e, ln));
|
|
64548
|
+
await (0, transcript_metrics_engine_js_1.processEntry)(entry, lineNumber, this.metrics, this.toolUseIdToName, (eventType, e, ln) => this.emitEvent(eventType, e, ln), (ln) => this.signalCompaction(ln));
|
|
64542
64549
|
}, async (lineNumber, _durationMs) => {
|
|
64543
64550
|
await this.emitEvent("BulkProcessingComplete", {}, lineNumber);
|
|
64544
64551
|
}, this.options.logger, this.sessionId, {
|
|
@@ -76837,7 +76844,9 @@ var require_types3 = __commonJS({
|
|
|
76837
76844
|
llmProfiles: {},
|
|
76838
76845
|
weights: {},
|
|
76839
76846
|
persistThroughClear: true,
|
|
76840
|
-
cavemanMode: "off"
|
|
76847
|
+
cavemanMode: "off",
|
|
76848
|
+
injectPersonaIntoNonInteractiveSessions: false,
|
|
76849
|
+
injectCavemanIntoNonInteractiveSessions: false
|
|
76841
76850
|
}
|
|
76842
76851
|
};
|
|
76843
76852
|
exports2.RESUME_MIN_CONFIDENCE = 0.7;
|
|
@@ -77776,6 +77785,10 @@ var require_update_summary = __commonJS({
|
|
|
77776
77785
|
ctx.logger.debug("Session summary disabled; skipping analysis", { sessionId, reason });
|
|
77777
77786
|
return;
|
|
77778
77787
|
}
|
|
77788
|
+
if (ctx.sessionType === "non-interactive") {
|
|
77789
|
+
ctx.logger.debug("Non-interactive session; skipping summary analysis", { sessionId, reason });
|
|
77790
|
+
return;
|
|
77791
|
+
}
|
|
77779
77792
|
try {
|
|
77780
77793
|
const countdown = await loadCountdownState(summaryState, sessionId);
|
|
77781
77794
|
const startTime = Date.now();
|
|
@@ -78155,7 +78168,6 @@ var require_stage_persona_reminders = __commonJS({
|
|
|
78155
78168
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
78156
78169
|
exports2.restagePersonaRemindersForActiveSessions = restagePersonaRemindersForActiveSessions;
|
|
78157
78170
|
exports2.stagePersonaRemindersForSession = stagePersonaRemindersForSession;
|
|
78158
|
-
exports2.resolvePersonaContextForSnapshot = resolvePersonaContextForSnapshot;
|
|
78159
78171
|
exports2.registerStagePersonaReminders = registerStagePersonaReminders;
|
|
78160
78172
|
var core_1 = require_dist4();
|
|
78161
78173
|
var feature_session_summary_1 = require_dist5();
|
|
@@ -78375,20 +78387,6 @@ var require_stage_persona_reminders = __commonJS({
|
|
|
78375
78387
|
includeChanged: options?.includeChangedReminder ?? false
|
|
78376
78388
|
});
|
|
78377
78389
|
}
|
|
78378
|
-
async function resolvePersonaContextForSnapshot(ctx, sessionId) {
|
|
78379
|
-
if (!isPersonaInjectionEnabled(ctx))
|
|
78380
|
-
return void 0;
|
|
78381
|
-
const persona = await loadPersonaForSession(ctx, sessionId);
|
|
78382
|
-
if (!persona)
|
|
78383
|
-
return void 0;
|
|
78384
|
-
const templateContext = buildPersonaTemplateContext(persona);
|
|
78385
|
-
const reminder = (0, reminder_utils_js_1.resolveReminder)(types_js_1.ReminderIds.REMEMBER_YOUR_PERSONA, {
|
|
78386
|
-
context: templateContext,
|
|
78387
|
-
assets: ctx.assets,
|
|
78388
|
-
logger: ctx.logger
|
|
78389
|
-
});
|
|
78390
|
-
return reminder?.additionalContext ?? void 0;
|
|
78391
|
-
}
|
|
78392
78390
|
function registerStagePersonaReminders(context) {
|
|
78393
78391
|
if (!(0, types_1.isDaemonContext)(context))
|
|
78394
78392
|
return;
|
|
@@ -78417,7 +78415,6 @@ var require_stage_user_profile_reminders = __commonJS({
|
|
|
78417
78415
|
"use strict";
|
|
78418
78416
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
78419
78417
|
exports2.stageUserProfileRemindersForSession = stageUserProfileRemindersForSession;
|
|
78420
|
-
exports2.resolveUserProfileContextForSnapshot = resolveUserProfileContextForSnapshot;
|
|
78421
78418
|
exports2.registerStageUserProfileReminders = registerStageUserProfileReminders;
|
|
78422
78419
|
var core_1 = require_dist4();
|
|
78423
78420
|
var events_js_1 = require_events2();
|
|
@@ -78457,21 +78454,6 @@ var require_stage_user_profile_reminders = __commonJS({
|
|
|
78457
78454
|
ctx.logger.warn("Failed to resolve user-profile reminder", { sessionId });
|
|
78458
78455
|
}
|
|
78459
78456
|
}
|
|
78460
|
-
function resolveUserProfileContextForSnapshot(ctx) {
|
|
78461
|
-
const profile = (0, core_1.loadUserProfile)({ logger: ctx.logger });
|
|
78462
|
-
if (!profile)
|
|
78463
|
-
return void 0;
|
|
78464
|
-
const templateContext = {
|
|
78465
|
-
user_name: profile.name,
|
|
78466
|
-
user_role: profile.role,
|
|
78467
|
-
user_interests: profile.interests.join(", ")
|
|
78468
|
-
};
|
|
78469
|
-
const reminder = (0, reminder_utils_js_1.resolveReminder)(types_js_1.ReminderIds.USER_PROFILE, {
|
|
78470
|
-
context: templateContext,
|
|
78471
|
-
assets: ctx.assets
|
|
78472
|
-
});
|
|
78473
|
-
return reminder?.additionalContext ?? void 0;
|
|
78474
|
-
}
|
|
78475
78457
|
function registerStageUserProfileReminders(context) {
|
|
78476
78458
|
if (!(0, types_1.isDaemonContext)(context))
|
|
78477
78459
|
return;
|
|
@@ -78763,6 +78745,28 @@ var require_cli_staging_reader = __commonJS({
|
|
|
78763
78745
|
}
|
|
78764
78746
|
});
|
|
78765
78747
|
|
|
78748
|
+
// ../feature-reminders/dist/handlers/consumption/session-type-gate.js
|
|
78749
|
+
var require_session_type_gate = __commonJS({
|
|
78750
|
+
"../feature-reminders/dist/handlers/consumption/session-type-gate.js"(exports2) {
|
|
78751
|
+
"use strict";
|
|
78752
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
78753
|
+
exports2.suppressReminderForSessionType = suppressReminderForSessionType;
|
|
78754
|
+
var types_js_1 = require_types2();
|
|
78755
|
+
var PERSONA_REMINDERS = /* @__PURE__ */ new Set([types_js_1.ReminderIds.REMEMBER_YOUR_PERSONA, types_js_1.ReminderIds.PERSONA_CHANGED]);
|
|
78756
|
+
function suppressReminderForSessionType(reminderName, sessionType, config) {
|
|
78757
|
+
if (sessionType !== "non-interactive")
|
|
78758
|
+
return false;
|
|
78759
|
+
if (PERSONA_REMINDERS.has(reminderName)) {
|
|
78760
|
+
return config.injectPersonaIntoNonInteractiveSessions !== true;
|
|
78761
|
+
}
|
|
78762
|
+
if (reminderName === types_js_1.ReminderIds.CAVEMAN_MODE) {
|
|
78763
|
+
return config.injectCavemanIntoNonInteractiveSessions !== true;
|
|
78764
|
+
}
|
|
78765
|
+
return false;
|
|
78766
|
+
}
|
|
78767
|
+
}
|
|
78768
|
+
});
|
|
78769
|
+
|
|
78766
78770
|
// ../feature-reminders/dist/handlers/consumption/consumption-handler-factory.js
|
|
78767
78771
|
var require_consumption_handler_factory = __commonJS({
|
|
78768
78772
|
"../feature-reminders/dist/handlers/consumption/consumption-handler-factory.js"(exports2) {
|
|
@@ -78774,6 +78778,7 @@ var require_consumption_handler_factory = __commonJS({
|
|
|
78774
78778
|
var events_js_1 = require_events2();
|
|
78775
78779
|
var types_1 = require_dist();
|
|
78776
78780
|
var cli_staging_reader_js_1 = require_cli_staging_reader();
|
|
78781
|
+
var session_type_gate_js_1 = require_session_type_gate();
|
|
78777
78782
|
function buildDefaultResponse(reminder, supportsBlocking) {
|
|
78778
78783
|
const response = {};
|
|
78779
78784
|
if (supportsBlocking && reminder.blocking) {
|
|
@@ -78807,7 +78812,8 @@ var require_consumption_handler_factory = __commonJS({
|
|
|
78807
78812
|
paths: cliCtx.paths,
|
|
78808
78813
|
sessionId
|
|
78809
78814
|
});
|
|
78810
|
-
const
|
|
78815
|
+
const personaConfig = cliCtx.config.getFeature("session-summary").settings?.personas ?? {};
|
|
78816
|
+
const reminders = reader.listReminders(hook).filter((r) => !(0, session_type_gate_js_1.suppressReminderForSessionType)(r.name, event.context.sessionType, personaConfig));
|
|
78811
78817
|
if (reminders.length === 0) {
|
|
78812
78818
|
return { response: {} };
|
|
78813
78819
|
}
|
|
@@ -79073,22 +79079,6 @@ var require_inject_session_start = __commonJS({
|
|
|
79073
79079
|
}
|
|
79074
79080
|
});
|
|
79075
79081
|
|
|
79076
|
-
// ../feature-reminders/dist/handlers/consumption/inject-post-compact.js
|
|
79077
|
-
var require_inject_post_compact = __commonJS({
|
|
79078
|
-
"../feature-reminders/dist/handlers/consumption/inject-post-compact.js"(exports2) {
|
|
79079
|
-
"use strict";
|
|
79080
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
79081
|
-
exports2.registerInjectPostCompact = registerInjectPostCompact;
|
|
79082
|
-
var consumption_handler_factory_js_1 = require_consumption_handler_factory();
|
|
79083
|
-
function registerInjectPostCompact(context) {
|
|
79084
|
-
(0, consumption_handler_factory_js_1.createConsumptionHandler)(context, {
|
|
79085
|
-
id: "reminders:inject-post-compact",
|
|
79086
|
-
hook: "PostCompact"
|
|
79087
|
-
});
|
|
79088
|
-
}
|
|
79089
|
-
}
|
|
79090
|
-
});
|
|
79091
|
-
|
|
79092
79082
|
// ../feature-reminders/dist/handlers/consumption/index.js
|
|
79093
79083
|
var require_consumption = __commonJS({
|
|
79094
79084
|
"../feature-reminders/dist/handlers/consumption/index.js"(exports2) {
|
|
@@ -79100,14 +79090,12 @@ var require_consumption = __commonJS({
|
|
|
79100
79090
|
var inject_post_tool_use_1 = require_inject_post_tool_use();
|
|
79101
79091
|
var inject_stop_1 = require_inject_stop();
|
|
79102
79092
|
var inject_session_start_1 = require_inject_session_start();
|
|
79103
|
-
var inject_post_compact_js_1 = require_inject_post_compact();
|
|
79104
79093
|
function registerConsumptionHandlers(context) {
|
|
79105
79094
|
(0, inject_user_prompt_submit_1.registerInjectUserPromptSubmit)(context);
|
|
79106
79095
|
(0, inject_pre_tool_use_1.registerInjectPreToolUse)(context);
|
|
79107
79096
|
(0, inject_post_tool_use_1.registerInjectPostToolUse)(context);
|
|
79108
79097
|
(0, inject_stop_1.registerInjectStop)(context);
|
|
79109
79098
|
(0, inject_session_start_1.registerInjectSessionStart)(context);
|
|
79110
|
-
(0, inject_post_compact_js_1.registerInjectPostCompact)(context);
|
|
79111
79099
|
}
|
|
79112
79100
|
}
|
|
79113
79101
|
});
|
|
@@ -79552,7 +79540,7 @@ var require_dist6 = __commonJS({
|
|
|
79552
79540
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
79553
79541
|
};
|
|
79554
79542
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
79555
|
-
exports2.createRemindersState = exports2.ReminderOrchestrator = exports2.ReminderEvents = exports2.handleVCUnverifiedClear = exports2.handleVCUnverifiedSet = exports2.handleReminderConsumed = exports2.classifyCompletion = exports2.
|
|
79543
|
+
exports2.createRemindersState = exports2.ReminderOrchestrator = exports2.ReminderEvents = exports2.handleVCUnverifiedClear = exports2.handleVCUnverifiedSet = exports2.handleReminderConsumed = exports2.classifyCompletion = exports2.restagePersonaRemindersForActiveSessions = exports2.stagePersonaRemindersForSession = exports2.registerStagingHandlers = exports2.registerConsumptionHandlers = exports2.manifest = void 0;
|
|
79556
79544
|
exports2.register = register;
|
|
79557
79545
|
var staging_1 = require_staging2();
|
|
79558
79546
|
var consumption_1 = require_consumption();
|
|
@@ -79586,13 +79574,6 @@ var require_dist6 = __commonJS({
|
|
|
79586
79574
|
Object.defineProperty(exports2, "restagePersonaRemindersForActiveSessions", { enumerable: true, get: function() {
|
|
79587
79575
|
return stage_persona_reminders_1.restagePersonaRemindersForActiveSessions;
|
|
79588
79576
|
} });
|
|
79589
|
-
Object.defineProperty(exports2, "resolvePersonaContextForSnapshot", { enumerable: true, get: function() {
|
|
79590
|
-
return stage_persona_reminders_1.resolvePersonaContextForSnapshot;
|
|
79591
|
-
} });
|
|
79592
|
-
var stage_user_profile_reminders_1 = require_stage_user_profile_reminders();
|
|
79593
|
-
Object.defineProperty(exports2, "resolveUserProfileContextForSnapshot", { enumerable: true, get: function() {
|
|
79594
|
-
return stage_user_profile_reminders_1.resolveUserProfileContextForSnapshot;
|
|
79595
|
-
} });
|
|
79596
79577
|
var completion_classifier_1 = require_completion_classifier();
|
|
79597
79578
|
Object.defineProperty(exports2, "classifyCompletion", { enumerable: true, get: function() {
|
|
79598
79579
|
return completion_classifier_1.classifyCompletion;
|
|
@@ -79879,7 +79860,8 @@ var require_hook = __commonJS({
|
|
|
79879
79860
|
timestamp: Date.now(),
|
|
79880
79861
|
correlationId,
|
|
79881
79862
|
...input.agentId !== void 0 && { agentId: input.agentId },
|
|
79882
|
-
...input.agentType !== void 0 && { agentType: input.agentType }
|
|
79863
|
+
...input.agentType !== void 0 && { agentType: input.agentType },
|
|
79864
|
+
sessionType: input.sessionType
|
|
79883
79865
|
};
|
|
79884
79866
|
switch (hookName) {
|
|
79885
79867
|
case "SessionStart":
|
|
@@ -80143,12 +80125,6 @@ var require_hook_command = __commonJS({
|
|
|
80143
80125
|
}
|
|
80144
80126
|
function translatePostCompact(internal) {
|
|
80145
80127
|
const response = {};
|
|
80146
|
-
if (internal.additionalContext) {
|
|
80147
|
-
response.hookSpecificOutput = {
|
|
80148
|
-
hookEventName: "PostCompact",
|
|
80149
|
-
additionalContext: internal.additionalContext
|
|
80150
|
-
};
|
|
80151
|
-
}
|
|
80152
80128
|
addUserMessage(response, internal.userMessage);
|
|
80153
80129
|
return response;
|
|
80154
80130
|
}
|
|
@@ -87523,6 +87499,7 @@ var require_cli = __commonJS({
|
|
|
87523
87499
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
87524
87500
|
exports2.UnknownOptionError = void 0;
|
|
87525
87501
|
exports2.parseArgs = parseArgs;
|
|
87502
|
+
exports2.resolveSessionType = resolveSessionType;
|
|
87526
87503
|
exports2.parseHookInput = parseHookInput;
|
|
87527
87504
|
exports2.initializeRuntime = initializeRuntime;
|
|
87528
87505
|
exports2.initializeSession = initializeSession;
|
|
@@ -87531,7 +87508,7 @@ var require_cli = __commonJS({
|
|
|
87531
87508
|
var promises_12 = require("node:fs/promises");
|
|
87532
87509
|
var node_stream_1 = require("node:stream");
|
|
87533
87510
|
var yargs_parser_1 = __importDefault2(require_build());
|
|
87534
|
-
var VERSION = true ? "0.1.
|
|
87511
|
+
var VERSION = true ? "0.1.31" : "dev";
|
|
87535
87512
|
var SANDBOX_ERROR_MESSAGE = `Error: Daemon commands cannot run in sandbox mode.
|
|
87536
87513
|
|
|
87537
87514
|
Claude Code's sandbox blocks Unix socket operations required for daemon IPC.
|
|
@@ -87661,7 +87638,14 @@ Example: { "command": "pnpm sidekick daemon status", "dangerouslyDisableSandbox"
|
|
|
87661
87638
|
writeStatus: Boolean(parsed["write-status"])
|
|
87662
87639
|
};
|
|
87663
87640
|
}
|
|
87664
|
-
function
|
|
87641
|
+
function resolveSessionType(agentId, entrypoint) {
|
|
87642
|
+
if (agentId)
|
|
87643
|
+
return "agent";
|
|
87644
|
+
if (entrypoint === "sdk-cli")
|
|
87645
|
+
return "non-interactive";
|
|
87646
|
+
return "interactive";
|
|
87647
|
+
}
|
|
87648
|
+
function parseHookInput(stdinData, entrypoint) {
|
|
87665
87649
|
if (!stdinData?.trim()) {
|
|
87666
87650
|
return void 0;
|
|
87667
87651
|
}
|
|
@@ -87686,6 +87670,7 @@ Example: { "command": "pnpm sidekick daemon status", "dangerouslyDisableSandbox"
|
|
|
87686
87670
|
permissionMode,
|
|
87687
87671
|
agentId,
|
|
87688
87672
|
agentType,
|
|
87673
|
+
sessionType: resolveSessionType(agentId, entrypoint),
|
|
87689
87674
|
raw
|
|
87690
87675
|
};
|
|
87691
87676
|
} catch {
|
|
@@ -87696,7 +87681,7 @@ Example: { "command": "pnpm sidekick daemon status", "dangerouslyDisableSandbox"
|
|
|
87696
87681
|
const stderr = options.stderr ?? new node_stream_1.PassThrough();
|
|
87697
87682
|
const parsed = parseArgs(options.argv);
|
|
87698
87683
|
const homeDir = options.homeDir ?? options.env?.HOME;
|
|
87699
|
-
const hookInput = parseHookInput(options.stdinData);
|
|
87684
|
+
const hookInput = parseHookInput(options.stdinData, options.env?.CLAUDE_CODE_ENTRYPOINT);
|
|
87700
87685
|
const runtime = (0, runtime_1.bootstrapRuntime)({
|
|
87701
87686
|
projectDir: parsed.projectDir,
|
|
87702
87687
|
logLevel: parsed.logLevel,
|
package/dist/daemon.js
CHANGED
|
@@ -46603,7 +46603,7 @@ var require_build_identity = __commonJS({
|
|
|
46603
46603
|
var path_1 = __importDefault(require("path"));
|
|
46604
46604
|
var DEV_PREFIX = "dev:";
|
|
46605
46605
|
var NO_DIST_SENTINEL = "nodist";
|
|
46606
|
-
function computeBuildIdentity(injectedVersion = true ? "0.1.
|
|
46606
|
+
function computeBuildIdentity(injectedVersion = true ? "0.1.31" : void 0, devFingerprint = computeDevFingerprint) {
|
|
46607
46607
|
return injectedVersion !== void 0 ? injectedVersion : DEV_PREFIX + devFingerprint();
|
|
46608
46608
|
}
|
|
46609
46609
|
function computeDevFingerprint() {
|
|
@@ -61013,7 +61013,7 @@ var require_transcript_metrics_engine = __commonJS({
|
|
|
61013
61013
|
exports2.isExcludedBuiltinCommandInvocation = isExcludedBuiltinCommandInvocation;
|
|
61014
61014
|
exports2.updateToolsPerTurn = updateToolsPerTurn;
|
|
61015
61015
|
var transcript_helpers_js_1 = require_transcript_helpers();
|
|
61016
|
-
async function processEntry(entry, lineNumber, metrics, toolUseIdToName, emitEvent) {
|
|
61016
|
+
async function processEntry(entry, lineNumber, metrics, toolUseIdToName, emitEvent, signalCompaction) {
|
|
61017
61017
|
const entryType = entry.type;
|
|
61018
61018
|
switch (entryType) {
|
|
61019
61019
|
case "user": {
|
|
@@ -61042,8 +61042,13 @@ var require_transcript_metrics_engine = __commonJS({
|
|
|
61042
61042
|
await emitEvent("AssistantMessage", entry, lineNumber);
|
|
61043
61043
|
await processNestedToolUses(entry, lineNumber, metrics, toolUseIdToName, emitEvent);
|
|
61044
61044
|
break;
|
|
61045
|
-
case "system":
|
|
61045
|
+
case "system": {
|
|
61046
|
+
const subtype = entry.subtype;
|
|
61047
|
+
if (subtype === "compact_boundary") {
|
|
61048
|
+
await signalCompaction?.(lineNumber);
|
|
61049
|
+
}
|
|
61046
61050
|
break;
|
|
61051
|
+
}
|
|
61047
61052
|
}
|
|
61048
61053
|
}
|
|
61049
61054
|
function extractTokenUsage(entry, metrics) {
|
|
@@ -63501,10 +63506,12 @@ var require_transcript_service = __commonJS({
|
|
|
63501
63506
|
// ============================================================================
|
|
63502
63507
|
// Compaction Management
|
|
63503
63508
|
// ============================================================================
|
|
63504
|
-
async signalCompaction() {
|
|
63509
|
+
async signalCompaction(lineNumber) {
|
|
63510
|
+
if (this.metrics.isPostCompactIndeterminate)
|
|
63511
|
+
return;
|
|
63505
63512
|
this.metrics.currentContextTokens = null;
|
|
63506
63513
|
this.metrics.isPostCompactIndeterminate = true;
|
|
63507
|
-
await this.emitEvent("Compact", {}, this.metrics.lastProcessedLine);
|
|
63514
|
+
await this.emitEvent("Compact", {}, lineNumber ?? this.metrics.lastProcessedLine);
|
|
63508
63515
|
this.notifyMetricsChange();
|
|
63509
63516
|
this.schedulePersistence();
|
|
63510
63517
|
}
|
|
@@ -63562,7 +63569,7 @@ var require_transcript_service = __commonJS({
|
|
|
63562
63569
|
return;
|
|
63563
63570
|
const self = this;
|
|
63564
63571
|
await (0, transcript_file_watcher_js_1.processTranscriptFile)(this.transcriptPath, this.streamingState, this.metrics, async (entry, lineNumber) => {
|
|
63565
|
-
await (0, transcript_metrics_engine_js_1.processEntry)(entry, lineNumber, this.metrics, this.toolUseIdToName, (eventType, e, ln) => this.emitEvent(eventType, e, ln));
|
|
63572
|
+
await (0, transcript_metrics_engine_js_1.processEntry)(entry, lineNumber, this.metrics, this.toolUseIdToName, (eventType, e, ln) => this.emitEvent(eventType, e, ln), (ln) => this.signalCompaction(ln));
|
|
63566
63573
|
}, async (lineNumber, _durationMs) => {
|
|
63567
63574
|
await this.emitEvent("BulkProcessingComplete", {}, lineNumber);
|
|
63568
63575
|
}, this.options.logger, this.sessionId, {
|
|
@@ -75601,7 +75608,9 @@ var require_types3 = __commonJS({
|
|
|
75601
75608
|
llmProfiles: {},
|
|
75602
75609
|
weights: {},
|
|
75603
75610
|
persistThroughClear: true,
|
|
75604
|
-
cavemanMode: "off"
|
|
75611
|
+
cavemanMode: "off",
|
|
75612
|
+
injectPersonaIntoNonInteractiveSessions: false,
|
|
75613
|
+
injectCavemanIntoNonInteractiveSessions: false
|
|
75605
75614
|
}
|
|
75606
75615
|
};
|
|
75607
75616
|
exports2.RESUME_MIN_CONFIDENCE = 0.7;
|
|
@@ -76540,6 +76549,10 @@ var require_update_summary = __commonJS({
|
|
|
76540
76549
|
ctx.logger.debug("Session summary disabled; skipping analysis", { sessionId, reason });
|
|
76541
76550
|
return;
|
|
76542
76551
|
}
|
|
76552
|
+
if (ctx.sessionType === "non-interactive") {
|
|
76553
|
+
ctx.logger.debug("Non-interactive session; skipping summary analysis", { sessionId, reason });
|
|
76554
|
+
return;
|
|
76555
|
+
}
|
|
76543
76556
|
try {
|
|
76544
76557
|
const countdown = await loadCountdownState(summaryState, sessionId);
|
|
76545
76558
|
const startTime = Date.now();
|
|
@@ -76919,7 +76932,6 @@ var require_stage_persona_reminders = __commonJS({
|
|
|
76919
76932
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
76920
76933
|
exports2.restagePersonaRemindersForActiveSessions = restagePersonaRemindersForActiveSessions;
|
|
76921
76934
|
exports2.stagePersonaRemindersForSession = stagePersonaRemindersForSession;
|
|
76922
|
-
exports2.resolvePersonaContextForSnapshot = resolvePersonaContextForSnapshot;
|
|
76923
76935
|
exports2.registerStagePersonaReminders = registerStagePersonaReminders;
|
|
76924
76936
|
var core_1 = require_dist4();
|
|
76925
76937
|
var feature_session_summary_1 = require_dist5();
|
|
@@ -77139,20 +77151,6 @@ var require_stage_persona_reminders = __commonJS({
|
|
|
77139
77151
|
includeChanged: options?.includeChangedReminder ?? false
|
|
77140
77152
|
});
|
|
77141
77153
|
}
|
|
77142
|
-
async function resolvePersonaContextForSnapshot(ctx, sessionId) {
|
|
77143
|
-
if (!isPersonaInjectionEnabled(ctx))
|
|
77144
|
-
return void 0;
|
|
77145
|
-
const persona = await loadPersonaForSession(ctx, sessionId);
|
|
77146
|
-
if (!persona)
|
|
77147
|
-
return void 0;
|
|
77148
|
-
const templateContext = buildPersonaTemplateContext(persona);
|
|
77149
|
-
const reminder = (0, reminder_utils_js_1.resolveReminder)(types_js_1.ReminderIds.REMEMBER_YOUR_PERSONA, {
|
|
77150
|
-
context: templateContext,
|
|
77151
|
-
assets: ctx.assets,
|
|
77152
|
-
logger: ctx.logger
|
|
77153
|
-
});
|
|
77154
|
-
return reminder?.additionalContext ?? void 0;
|
|
77155
|
-
}
|
|
77156
77154
|
function registerStagePersonaReminders(context) {
|
|
77157
77155
|
if (!(0, types_1.isDaemonContext)(context))
|
|
77158
77156
|
return;
|
|
@@ -77181,7 +77179,6 @@ var require_stage_user_profile_reminders = __commonJS({
|
|
|
77181
77179
|
"use strict";
|
|
77182
77180
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
77183
77181
|
exports2.stageUserProfileRemindersForSession = stageUserProfileRemindersForSession;
|
|
77184
|
-
exports2.resolveUserProfileContextForSnapshot = resolveUserProfileContextForSnapshot;
|
|
77185
77182
|
exports2.registerStageUserProfileReminders = registerStageUserProfileReminders;
|
|
77186
77183
|
var core_1 = require_dist4();
|
|
77187
77184
|
var events_js_1 = require_events2();
|
|
@@ -77221,21 +77218,6 @@ var require_stage_user_profile_reminders = __commonJS({
|
|
|
77221
77218
|
ctx.logger.warn("Failed to resolve user-profile reminder", { sessionId });
|
|
77222
77219
|
}
|
|
77223
77220
|
}
|
|
77224
|
-
function resolveUserProfileContextForSnapshot(ctx) {
|
|
77225
|
-
const profile = (0, core_1.loadUserProfile)({ logger: ctx.logger });
|
|
77226
|
-
if (!profile)
|
|
77227
|
-
return void 0;
|
|
77228
|
-
const templateContext = {
|
|
77229
|
-
user_name: profile.name,
|
|
77230
|
-
user_role: profile.role,
|
|
77231
|
-
user_interests: profile.interests.join(", ")
|
|
77232
|
-
};
|
|
77233
|
-
const reminder = (0, reminder_utils_js_1.resolveReminder)(types_js_1.ReminderIds.USER_PROFILE, {
|
|
77234
|
-
context: templateContext,
|
|
77235
|
-
assets: ctx.assets
|
|
77236
|
-
});
|
|
77237
|
-
return reminder?.additionalContext ?? void 0;
|
|
77238
|
-
}
|
|
77239
77221
|
function registerStageUserProfileReminders(context) {
|
|
77240
77222
|
if (!(0, types_1.isDaemonContext)(context))
|
|
77241
77223
|
return;
|
|
@@ -77527,6 +77509,28 @@ var require_cli_staging_reader = __commonJS({
|
|
|
77527
77509
|
}
|
|
77528
77510
|
});
|
|
77529
77511
|
|
|
77512
|
+
// ../feature-reminders/dist/handlers/consumption/session-type-gate.js
|
|
77513
|
+
var require_session_type_gate = __commonJS({
|
|
77514
|
+
"../feature-reminders/dist/handlers/consumption/session-type-gate.js"(exports2) {
|
|
77515
|
+
"use strict";
|
|
77516
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
77517
|
+
exports2.suppressReminderForSessionType = suppressReminderForSessionType;
|
|
77518
|
+
var types_js_1 = require_types2();
|
|
77519
|
+
var PERSONA_REMINDERS = /* @__PURE__ */ new Set([types_js_1.ReminderIds.REMEMBER_YOUR_PERSONA, types_js_1.ReminderIds.PERSONA_CHANGED]);
|
|
77520
|
+
function suppressReminderForSessionType(reminderName, sessionType, config) {
|
|
77521
|
+
if (sessionType !== "non-interactive")
|
|
77522
|
+
return false;
|
|
77523
|
+
if (PERSONA_REMINDERS.has(reminderName)) {
|
|
77524
|
+
return config.injectPersonaIntoNonInteractiveSessions !== true;
|
|
77525
|
+
}
|
|
77526
|
+
if (reminderName === types_js_1.ReminderIds.CAVEMAN_MODE) {
|
|
77527
|
+
return config.injectCavemanIntoNonInteractiveSessions !== true;
|
|
77528
|
+
}
|
|
77529
|
+
return false;
|
|
77530
|
+
}
|
|
77531
|
+
}
|
|
77532
|
+
});
|
|
77533
|
+
|
|
77530
77534
|
// ../feature-reminders/dist/handlers/consumption/consumption-handler-factory.js
|
|
77531
77535
|
var require_consumption_handler_factory = __commonJS({
|
|
77532
77536
|
"../feature-reminders/dist/handlers/consumption/consumption-handler-factory.js"(exports2) {
|
|
@@ -77538,6 +77542,7 @@ var require_consumption_handler_factory = __commonJS({
|
|
|
77538
77542
|
var events_js_1 = require_events2();
|
|
77539
77543
|
var types_1 = require_dist();
|
|
77540
77544
|
var cli_staging_reader_js_1 = require_cli_staging_reader();
|
|
77545
|
+
var session_type_gate_js_1 = require_session_type_gate();
|
|
77541
77546
|
function buildDefaultResponse(reminder, supportsBlocking) {
|
|
77542
77547
|
const response = {};
|
|
77543
77548
|
if (supportsBlocking && reminder.blocking) {
|
|
@@ -77571,7 +77576,8 @@ var require_consumption_handler_factory = __commonJS({
|
|
|
77571
77576
|
paths: cliCtx.paths,
|
|
77572
77577
|
sessionId
|
|
77573
77578
|
});
|
|
77574
|
-
const
|
|
77579
|
+
const personaConfig = cliCtx.config.getFeature("session-summary").settings?.personas ?? {};
|
|
77580
|
+
const reminders = reader.listReminders(hook).filter((r) => !(0, session_type_gate_js_1.suppressReminderForSessionType)(r.name, event.context.sessionType, personaConfig));
|
|
77575
77581
|
if (reminders.length === 0) {
|
|
77576
77582
|
return { response: {} };
|
|
77577
77583
|
}
|
|
@@ -77837,22 +77843,6 @@ var require_inject_session_start = __commonJS({
|
|
|
77837
77843
|
}
|
|
77838
77844
|
});
|
|
77839
77845
|
|
|
77840
|
-
// ../feature-reminders/dist/handlers/consumption/inject-post-compact.js
|
|
77841
|
-
var require_inject_post_compact = __commonJS({
|
|
77842
|
-
"../feature-reminders/dist/handlers/consumption/inject-post-compact.js"(exports2) {
|
|
77843
|
-
"use strict";
|
|
77844
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
77845
|
-
exports2.registerInjectPostCompact = registerInjectPostCompact;
|
|
77846
|
-
var consumption_handler_factory_js_1 = require_consumption_handler_factory();
|
|
77847
|
-
function registerInjectPostCompact(context) {
|
|
77848
|
-
(0, consumption_handler_factory_js_1.createConsumptionHandler)(context, {
|
|
77849
|
-
id: "reminders:inject-post-compact",
|
|
77850
|
-
hook: "PostCompact"
|
|
77851
|
-
});
|
|
77852
|
-
}
|
|
77853
|
-
}
|
|
77854
|
-
});
|
|
77855
|
-
|
|
77856
77846
|
// ../feature-reminders/dist/handlers/consumption/index.js
|
|
77857
77847
|
var require_consumption = __commonJS({
|
|
77858
77848
|
"../feature-reminders/dist/handlers/consumption/index.js"(exports2) {
|
|
@@ -77864,14 +77854,12 @@ var require_consumption = __commonJS({
|
|
|
77864
77854
|
var inject_post_tool_use_1 = require_inject_post_tool_use();
|
|
77865
77855
|
var inject_stop_1 = require_inject_stop();
|
|
77866
77856
|
var inject_session_start_1 = require_inject_session_start();
|
|
77867
|
-
var inject_post_compact_js_1 = require_inject_post_compact();
|
|
77868
77857
|
function registerConsumptionHandlers(context) {
|
|
77869
77858
|
(0, inject_user_prompt_submit_1.registerInjectUserPromptSubmit)(context);
|
|
77870
77859
|
(0, inject_pre_tool_use_1.registerInjectPreToolUse)(context);
|
|
77871
77860
|
(0, inject_post_tool_use_1.registerInjectPostToolUse)(context);
|
|
77872
77861
|
(0, inject_stop_1.registerInjectStop)(context);
|
|
77873
77862
|
(0, inject_session_start_1.registerInjectSessionStart)(context);
|
|
77874
|
-
(0, inject_post_compact_js_1.registerInjectPostCompact)(context);
|
|
77875
77863
|
}
|
|
77876
77864
|
}
|
|
77877
77865
|
});
|
|
@@ -78316,7 +78304,7 @@ var require_dist6 = __commonJS({
|
|
|
78316
78304
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
78317
78305
|
};
|
|
78318
78306
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
78319
|
-
exports2.createRemindersState = exports2.ReminderOrchestrator = exports2.ReminderEvents = exports2.handleVCUnverifiedClear = exports2.handleVCUnverifiedSet = exports2.handleReminderConsumed = exports2.classifyCompletion = exports2.
|
|
78307
|
+
exports2.createRemindersState = exports2.ReminderOrchestrator = exports2.ReminderEvents = exports2.handleVCUnverifiedClear = exports2.handleVCUnverifiedSet = exports2.handleReminderConsumed = exports2.classifyCompletion = exports2.restagePersonaRemindersForActiveSessions = exports2.stagePersonaRemindersForSession = exports2.registerStagingHandlers = exports2.registerConsumptionHandlers = exports2.manifest = void 0;
|
|
78320
78308
|
exports2.register = register;
|
|
78321
78309
|
var staging_1 = require_staging2();
|
|
78322
78310
|
var consumption_1 = require_consumption();
|
|
@@ -78350,13 +78338,6 @@ var require_dist6 = __commonJS({
|
|
|
78350
78338
|
Object.defineProperty(exports2, "restagePersonaRemindersForActiveSessions", { enumerable: true, get: function() {
|
|
78351
78339
|
return stage_persona_reminders_1.restagePersonaRemindersForActiveSessions;
|
|
78352
78340
|
} });
|
|
78353
|
-
Object.defineProperty(exports2, "resolvePersonaContextForSnapshot", { enumerable: true, get: function() {
|
|
78354
|
-
return stage_persona_reminders_1.resolvePersonaContextForSnapshot;
|
|
78355
|
-
} });
|
|
78356
|
-
var stage_user_profile_reminders_1 = require_stage_user_profile_reminders();
|
|
78357
|
-
Object.defineProperty(exports2, "resolveUserProfileContextForSnapshot", { enumerable: true, get: function() {
|
|
78358
|
-
return stage_user_profile_reminders_1.resolveUserProfileContextForSnapshot;
|
|
78359
|
-
} });
|
|
78360
78341
|
var completion_classifier_1 = require_completion_classifier();
|
|
78361
78342
|
Object.defineProperty(exports2, "classifyCompletion", { enumerable: true, get: function() {
|
|
78362
78343
|
return completion_classifier_1.classifyCompletion;
|
|
@@ -80018,12 +79999,18 @@ var require_daemon_helpers = __commonJS({
|
|
|
80018
79999
|
"use strict";
|
|
80019
80000
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
80020
80001
|
exports2.REGISTRY_HEARTBEAT_INTERVAL_MS = exports2.EVICTION_INTERVAL_MS = exports2.HEARTBEAT_INTERVAL_MS = exports2.IDLE_CHECK_INTERVAL_MS = exports2.VERSION = void 0;
|
|
80002
|
+
exports2.nextStoredSessionType = nextStoredSessionType;
|
|
80021
80003
|
exports2.diffConfigs = diffConfigs;
|
|
80022
80004
|
exports2.resolveTranscriptPath = resolveTranscriptPath;
|
|
80023
80005
|
exports2.shouldRunStartupCleanup = shouldRunStartupCleanup;
|
|
80024
80006
|
exports2.getPersonaInjectionEnabled = getPersonaInjectionEnabled;
|
|
80025
80007
|
exports2.getCavemanConfigDefault = getCavemanConfigDefault;
|
|
80026
80008
|
var core_1 = require_dist4();
|
|
80009
|
+
function nextStoredSessionType(current, incoming) {
|
|
80010
|
+
if (incoming && incoming !== "agent")
|
|
80011
|
+
return incoming;
|
|
80012
|
+
return current;
|
|
80013
|
+
}
|
|
80027
80014
|
exports2.VERSION = (0, core_1.computeBuildIdentity)();
|
|
80028
80015
|
exports2.IDLE_CHECK_INTERVAL_MS = 30 * 1e3;
|
|
80029
80016
|
exports2.HEARTBEAT_INTERVAL_MS = 5 * 1e3;
|
|
@@ -80661,8 +80648,13 @@ var require_daemon = __commonJS({
|
|
|
80661
80648
|
registryService;
|
|
80662
80649
|
timerManager;
|
|
80663
80650
|
sessionLogWriter;
|
|
80664
|
-
/**
|
|
80665
|
-
|
|
80651
|
+
/**
|
|
80652
|
+
* Parent session type keyed by sessionId. Only updated by parent hooks
|
|
80653
|
+
* (interactive/non-interactive); subagent 'agent' hooks share the parent
|
|
80654
|
+
* sessionId and are ignored so they cannot flip the stored type. Surfaced onto
|
|
80655
|
+
* DaemonContext.sessionType to gate expensive session-summary work.
|
|
80656
|
+
*/
|
|
80657
|
+
sessionTypes = /* @__PURE__ */ new Map();
|
|
80666
80658
|
/** Cache persona for handoff on clear. */
|
|
80667
80659
|
cachePersonaForClear(personaId) {
|
|
80668
80660
|
this.lastClearedPersona = { personaId, timestamp: Date.now() };
|
|
@@ -81026,6 +81018,10 @@ var require_daemon = __commonJS({
|
|
|
81026
81018
|
* Uses the same infrastructure as the IPC handlers for message generation.
|
|
81027
81019
|
*/
|
|
81028
81020
|
async regenerateMessagesForSession(sessionId) {
|
|
81021
|
+
if (this.sessionTypes.get(sessionId) === "non-interactive") {
|
|
81022
|
+
this.logger.debug("Non-interactive session; skipping message regeneration", { sessionId });
|
|
81023
|
+
return;
|
|
81024
|
+
}
|
|
81029
81025
|
this.logger.info("Regenerating messages after persona change", { sessionId });
|
|
81030
81026
|
try {
|
|
81031
81027
|
await (0, persona_transition_js_1.stagePersonaTransition)(this.stateService, sessionId);
|
|
@@ -81111,6 +81107,11 @@ var require_daemon = __commonJS({
|
|
|
81111
81107
|
throw new Error("hook.invoke requires hook and event parameters");
|
|
81112
81108
|
}
|
|
81113
81109
|
const { sessionId, correlationId } = event.context ?? {};
|
|
81110
|
+
if (sessionId) {
|
|
81111
|
+
const next = (0, daemon_helpers_js_1.nextStoredSessionType)(this.sessionTypes.get(sessionId), event.context?.sessionType);
|
|
81112
|
+
if (next !== void 0)
|
|
81113
|
+
this.sessionTypes.set(sessionId, next);
|
|
81114
|
+
}
|
|
81114
81115
|
const requestLogger = this.logger.child({
|
|
81115
81116
|
context: { sessionId, correlationId }
|
|
81116
81117
|
});
|
|
@@ -81132,36 +81133,29 @@ var require_daemon = __commonJS({
|
|
|
81132
81133
|
if (hook === "UserPromptSubmit") {
|
|
81133
81134
|
await this.handleUserPromptSubmitCleanup(event, { logger: requestLogger });
|
|
81134
81135
|
}
|
|
81135
|
-
if (hook === "PreCompact") {
|
|
81136
|
-
await this.handlePreCompact(event, { logger: requestLogger });
|
|
81137
|
-
}
|
|
81138
|
-
let postCompactResponse;
|
|
81139
81136
|
if (hook === "PostCompact") {
|
|
81140
|
-
|
|
81137
|
+
await this.handlePostCompact(event, { logger: requestLogger });
|
|
81141
81138
|
}
|
|
81142
81139
|
if (sessionId && !this.logMetrics.hasSession(sessionId)) {
|
|
81143
81140
|
await this.logMetrics.initSessionCounters(sessionId, false);
|
|
81144
81141
|
requestLogger.debug("Log counters initialized from file for hook", { hook });
|
|
81145
81142
|
}
|
|
81146
|
-
|
|
81147
|
-
if (postCompactResponse?.additionalContext) {
|
|
81148
|
-
const registryContext = response.additionalContext;
|
|
81149
|
-
response.additionalContext = registryContext ? `${registryContext}
|
|
81150
|
-
|
|
81151
|
-
${postCompactResponse.additionalContext}` : postCompactResponse.additionalContext;
|
|
81152
|
-
}
|
|
81153
|
-
return response;
|
|
81143
|
+
return this.handlerRegistry.invokeHook(hook, event, { logger: requestLogger });
|
|
81154
81144
|
}
|
|
81155
81145
|
/**
|
|
81156
|
-
* Handle PostCompact: signal compaction to the session's TranscriptService
|
|
81157
|
-
*
|
|
81146
|
+
* Handle PostCompact: signal compaction to the session's TranscriptService.
|
|
81147
|
+
*
|
|
81148
|
+
* PostCompact does not re-inject session context: Claude Code's PostCompact hook-output
|
|
81149
|
+
* schema has no additionalContext variant, so any snapshot would be rejected. Persona and
|
|
81150
|
+
* user-profile context are re-established after compaction via the SessionStart:compact
|
|
81151
|
+
* staging path instead.
|
|
81158
81152
|
*/
|
|
81159
81153
|
async handlePostCompact(event, options) {
|
|
81160
81154
|
const log = options?.logger ?? this.logger;
|
|
81161
81155
|
const sessionId = event.context?.sessionId;
|
|
81162
81156
|
if (!sessionId) {
|
|
81163
81157
|
log.warn("PostCompact event missing sessionId");
|
|
81164
|
-
return
|
|
81158
|
+
return;
|
|
81165
81159
|
}
|
|
81166
81160
|
const transcriptService = this.serviceFactory.getTranscriptService(sessionId);
|
|
81167
81161
|
if (transcriptService) {
|
|
@@ -81170,81 +81164,6 @@ ${postCompactResponse.additionalContext}` : postCompactResponse.additionalContex
|
|
|
81170
81164
|
} else {
|
|
81171
81165
|
log.warn("PostCompact: no transcript service for session", { sessionId });
|
|
81172
81166
|
}
|
|
81173
|
-
const snapshot = this.compactionSnapshots.get(sessionId);
|
|
81174
|
-
if (snapshot) {
|
|
81175
|
-
this.compactionSnapshots.delete(sessionId);
|
|
81176
|
-
log.info("PostCompact: re-injecting compaction snapshot", {
|
|
81177
|
-
sessionId,
|
|
81178
|
-
snapshotLength: snapshot.length
|
|
81179
|
-
});
|
|
81180
|
-
return { additionalContext: snapshot };
|
|
81181
|
-
}
|
|
81182
|
-
return {};
|
|
81183
|
-
}
|
|
81184
|
-
/**
|
|
81185
|
-
* Handle PreCompact: capture staged SessionStart reminders as a compaction snapshot.
|
|
81186
|
-
* The snapshot is returned by the next PostCompact call for context re-injection.
|
|
81187
|
-
*/
|
|
81188
|
-
async handlePreCompact(event, options) {
|
|
81189
|
-
const log = options?.logger ?? this.logger;
|
|
81190
|
-
const sessionId = event.context?.sessionId;
|
|
81191
|
-
if (!sessionId)
|
|
81192
|
-
return;
|
|
81193
|
-
try {
|
|
81194
|
-
const minimalCtx = {
|
|
81195
|
-
role: "daemon",
|
|
81196
|
-
config: {
|
|
81197
|
-
core: {
|
|
81198
|
-
logging: {
|
|
81199
|
-
level: this.configService.core.logging.level,
|
|
81200
|
-
components: this.configService.core.logging.components
|
|
81201
|
-
},
|
|
81202
|
-
development: { enabled: this.configService.core.development.enabled }
|
|
81203
|
-
},
|
|
81204
|
-
llm: {
|
|
81205
|
-
defaultProfile: this.configService.llm.defaultProfile,
|
|
81206
|
-
defaultFallbackProfileId: this.configService.llm.defaultFallbackProfileId,
|
|
81207
|
-
profiles: this.configService.llm.profiles,
|
|
81208
|
-
fallbackProfiles: this.configService.llm.fallbackProfiles
|
|
81209
|
-
},
|
|
81210
|
-
getAll: () => this.configService.getAll(),
|
|
81211
|
-
getFeature: (name) => this.configService.getFeature(name)
|
|
81212
|
-
},
|
|
81213
|
-
logger: log,
|
|
81214
|
-
assets: this.assetResolver,
|
|
81215
|
-
paths: this.buildRuntimePaths(),
|
|
81216
|
-
stateService: this.stateService,
|
|
81217
|
-
// Remaining DaemonContext fields are not needed by the resolve functions
|
|
81218
|
-
handlers: this.handlerRegistry,
|
|
81219
|
-
staging: this.serviceFactory.getStagingService(sessionId),
|
|
81220
|
-
transcript: void 0,
|
|
81221
|
-
llm: void 0,
|
|
81222
|
-
profileFactory: void 0,
|
|
81223
|
-
orchestrator: this.orchestrator,
|
|
81224
|
-
personaClearCache: { consume: () => this.consumeCachedPersona() }
|
|
81225
|
-
};
|
|
81226
|
-
const [personaContext, userProfileContext] = await Promise.all([
|
|
81227
|
-
(0, feature_reminders_1.resolvePersonaContextForSnapshot)(minimalCtx, sessionId),
|
|
81228
|
-
Promise.resolve((0, feature_reminders_1.resolveUserProfileContextForSnapshot)(minimalCtx))
|
|
81229
|
-
]);
|
|
81230
|
-
const contextParts = [personaContext, userProfileContext].filter((c) => typeof c === "string" && c.trim().length > 0);
|
|
81231
|
-
if (contextParts.length === 0) {
|
|
81232
|
-
log.debug("PreCompact: no context to snapshot", { sessionId });
|
|
81233
|
-
return;
|
|
81234
|
-
}
|
|
81235
|
-
const snapshot = ["Context was compacted. Re-establishing session context:", "", ...contextParts].join("\n");
|
|
81236
|
-
this.compactionSnapshots.set(sessionId, snapshot);
|
|
81237
|
-
log.info("PreCompact: compaction snapshot captured", {
|
|
81238
|
-
sessionId,
|
|
81239
|
-
reminderCount: contextParts.length,
|
|
81240
|
-
snapshotLength: snapshot.length
|
|
81241
|
-
});
|
|
81242
|
-
} catch (err) {
|
|
81243
|
-
log.warn("PreCompact: failed to capture snapshot", {
|
|
81244
|
-
sessionId,
|
|
81245
|
-
error: (0, core_1.toErrorMessage)(err)
|
|
81246
|
-
});
|
|
81247
|
-
}
|
|
81248
81167
|
}
|
|
81249
81168
|
/**
|
|
81250
81169
|
* Handle SessionStart-specific logic: clear staging on startup/clear.
|
|
@@ -81290,6 +81209,7 @@ ${postCompactResponse.additionalContext}` : postCompactResponse.additionalContex
|
|
|
81290
81209
|
const log = options?.logger ?? this.logger;
|
|
81291
81210
|
const sessionId = event.context?.sessionId;
|
|
81292
81211
|
if (sessionId) {
|
|
81212
|
+
this.sessionTypes.delete(sessionId);
|
|
81293
81213
|
const payload = event.payload;
|
|
81294
81214
|
log.info("[persona-lifecycle] ClearHandoff: handleSessionEnd entered", {
|
|
81295
81215
|
sessionId,
|
|
@@ -81329,7 +81249,6 @@ ${postCompactResponse.additionalContext}` : postCompactResponse.additionalContex
|
|
|
81329
81249
|
}
|
|
81330
81250
|
await this.llmManager.shutdownSessionProvider(sessionId, log);
|
|
81331
81251
|
this.logMetrics.deleteSessionCounters(sessionId);
|
|
81332
|
-
this.compactionSnapshots.delete(sessionId);
|
|
81333
81252
|
await this.serviceFactory.shutdownSession(sessionId);
|
|
81334
81253
|
await this.sessionLogWriter.closeSession(sessionId);
|
|
81335
81254
|
log.info("Session ended");
|
|
@@ -81668,7 +81587,8 @@ ${postCompactResponse.additionalContext}` : postCompactResponse.additionalContex
|
|
|
81668
81587
|
orchestrator: this.orchestrator,
|
|
81669
81588
|
personaClearCache: {
|
|
81670
81589
|
consume: () => this.consumeCachedPersona()
|
|
81671
|
-
}
|
|
81590
|
+
},
|
|
81591
|
+
sessionType: this.sessionTypes.get(sessionId) ?? "interactive"
|
|
81672
81592
|
};
|
|
81673
81593
|
this.handlerRegistry.updateSession({ sessionId, transcriptPath });
|
|
81674
81594
|
this.handlerRegistry.setStagingProvider(() => stagingService);
|