( opts: BuildMagicContextBlockOptions, )
| 57 | * legacy options are true. |
| 58 | */ |
| 59 | export function buildMagicContextBlock( |
| 60 | opts: BuildMagicContextBlockOptions, |
| 61 | ): string | null { |
| 62 | const existing = opts.existingSystemPrompt ?? ""; |
| 63 | const includeGuidance = |
| 64 | (opts.includeGuidance ?? true) && !existing.includes(MAGIC_CONTEXT_MARKER); |
| 65 | if (!includeGuidance) return null; |
| 66 | |
| 67 | return buildMagicContextSection( |
| 68 | null, |
| 69 | opts.protectedTags ?? 20, |
| 70 | opts.ctxReduceEnabled ?? true, |
| 71 | opts.dreamerEnabled ?? false, |
| 72 | opts.temporalAwarenessEnabled ?? false, |
| 73 | opts.cavemanTextCompressionEnabled ?? false, |
| 74 | false, |
| 75 | opts.language, |
| 76 | // Drop ctx_memory guidance when memory is off (the tool is gated via |
| 77 | // registerMagicContextTools memoryToolEnabled). ctx_search guidance stays. |
| 78 | opts.memoryEnabled !== false, |
| 79 | ); |
| 80 | } |
| 81 | |
| 82 | export interface SystemPromptHashResult { |
| 83 | /** The system prompt to send to the LLM, possibly with date frozen. */ |
no test coverage detected