Merge pull request #1125 from thedotmack/feat/session-start-system-message
feat: SessionStart systemMessage + cleaner defaults
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -17,7 +17,11 @@ export const claudeCodeAdapter: PlatformAdapter = {
|
|||||||
},
|
},
|
||||||
formatOutput(result) {
|
formatOutput(result) {
|
||||||
if (result.hookSpecificOutput) {
|
if (result.hookSpecificOutput) {
|
||||||
return { hookSpecificOutput: result.hookSpecificOutput };
|
const output: Record<string, unknown> = { hookSpecificOutput: result.hookSpecificOutput };
|
||||||
|
if (result.systemMessage) {
|
||||||
|
output.systemMessage = result.systemMessage;
|
||||||
|
}
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
return { continue: result.continue ?? true, suppressOutput: result.suppressOutput ?? true };
|
return { continue: result.continue ?? true, suppressOutput: result.suppressOutput ?? true };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,12 @@ export const contextHandler: EventHandler = {
|
|||||||
// Note: Removed AbortSignal.timeout due to Windows Bun cleanup issue (libuv assertion)
|
// Note: Removed AbortSignal.timeout due to Windows Bun cleanup issue (libuv assertion)
|
||||||
// Worker service has its own timeouts, so client-side timeout is redundant
|
// Worker service has its own timeouts, so client-side timeout is redundant
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url);
|
// Fetch both markdown (for Claude context) and colored (for user display) truly in parallel
|
||||||
|
const colorUrl = `${url}&colors=true`;
|
||||||
|
const [response, colorResponse] = await Promise.all([
|
||||||
|
fetch(url),
|
||||||
|
fetch(colorUrl).catch(() => null)
|
||||||
|
]);
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
// Log but don't throw — context fetch failure should not block session start
|
// Log but don't throw — context fetch failure should not block session start
|
||||||
@@ -48,14 +53,23 @@ export const contextHandler: EventHandler = {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await response.text();
|
const [contextResult, colorResult] = await Promise.all([
|
||||||
const additionalContext = result.trim();
|
response.text(),
|
||||||
|
colorResponse?.ok ? colorResponse.text() : Promise.resolve('')
|
||||||
|
]);
|
||||||
|
|
||||||
|
const additionalContext = contextResult.trim();
|
||||||
|
const coloredTimeline = colorResult.trim();
|
||||||
|
const systemMessage = coloredTimeline
|
||||||
|
? `${coloredTimeline}\n\nView Observations Live @ http://localhost:${port}`
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hookSpecificOutput: {
|
hookSpecificOutput: {
|
||||||
hookEventName: 'SessionStart',
|
hookEventName: 'SessionStart',
|
||||||
additionalContext
|
additionalContext
|
||||||
}
|
},
|
||||||
|
systemMessage
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Worker unreachable — return empty context gracefully
|
// Worker unreachable — return empty context gracefully
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export interface HookResult {
|
|||||||
continue?: boolean;
|
continue?: boolean;
|
||||||
suppressOutput?: boolean;
|
suppressOutput?: boolean;
|
||||||
hookSpecificOutput?: { hookEventName: string; additionalContext: string };
|
hookSpecificOutput?: { hookEventName: string; additionalContext: string };
|
||||||
|
systemMessage?: string;
|
||||||
exitCode?: number;
|
exitCode?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,15 +95,15 @@ export class SettingsDefaultsManager {
|
|||||||
CLAUDE_CODE_PATH: '', // Empty means auto-detect via 'which claude'
|
CLAUDE_CODE_PATH: '', // Empty means auto-detect via 'which claude'
|
||||||
CLAUDE_MEM_MODE: 'code', // Default mode profile
|
CLAUDE_MEM_MODE: 'code', // Default mode profile
|
||||||
// Token Economics
|
// Token Economics
|
||||||
CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS: 'true',
|
CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS: 'false',
|
||||||
CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS: 'true',
|
CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS: 'false',
|
||||||
CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT: 'true',
|
CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT: 'false',
|
||||||
CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT: 'true',
|
CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT: 'true',
|
||||||
// Observation Filtering
|
// Observation Filtering
|
||||||
CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES: DEFAULT_OBSERVATION_TYPES_STRING,
|
CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES: DEFAULT_OBSERVATION_TYPES_STRING,
|
||||||
CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS: DEFAULT_OBSERVATION_CONCEPTS_STRING,
|
CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS: DEFAULT_OBSERVATION_CONCEPTS_STRING,
|
||||||
// Display Configuration
|
// Display Configuration
|
||||||
CLAUDE_MEM_CONTEXT_FULL_COUNT: '5',
|
CLAUDE_MEM_CONTEXT_FULL_COUNT: '0',
|
||||||
CLAUDE_MEM_CONTEXT_FULL_FIELD: 'narrative',
|
CLAUDE_MEM_CONTEXT_FULL_FIELD: 'narrative',
|
||||||
CLAUDE_MEM_CONTEXT_SESSION_COUNT: '10',
|
CLAUDE_MEM_CONTEXT_SESSION_COUNT: '10',
|
||||||
// Feature Toggles
|
// Feature Toggles
|
||||||
|
|||||||
Reference in New Issue
Block a user