{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../src/watchdog/scope.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kCAAkC,eAAiD,CAAC;AAMjG,MAAM,WAAW,kBAAkB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,qBAAqB;IACjC,OAAO,CAAC,OAAO,CAA4B;IAE3C,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,IAAI,CAQpE;IAED,KAAK,IAAI,IAAI,CAEZ;IAED,QAAQ,IAAI,kBAAkB,EAAE,CAE/B;IAED,MAAM,IAAI,MAAM,CASf;IAED,OAAO,CAAC,IAAI;CAQZ;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMvE;AAED,wBAAgB,iCAAiC,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAG/E","sourcesContent":["export const WATCHDOG_AUTO_FOLLOW_PROMPT_MARKER = Symbol(\"subagent-watchdog-auto-follow-prompt\");\n\nconst MAX_SCOPE_ENTRIES = 8;\nconst MAX_SCOPE_ENTRY_CHARS = 2_000;\nconst MAX_SCOPE_TOTAL_CHARS = 16_000;\n\nexport interface WatchdogScopeEntry {\n\tprompt: string;\n\tcreatedAt: string;\n}\n\nexport class WatchdogScopeArtifact {\n\tprivate entries: WatchdogScopeEntry[] = [];\n\n\taddPrompt(prompt: string, options: { createdAt?: string } = {}): void {\n\t\tconst normalized = prompt.trim();\n\t\tif (!normalized) return;\n\t\tthis.entries.push({\n\t\t\tprompt: normalized.length > MAX_SCOPE_ENTRY_CHARS ? normalized.slice(0, MAX_SCOPE_ENTRY_CHARS) : normalized,\n\t\t\tcreatedAt: options.createdAt ?? new Date().toISOString(),\n\t\t});\n\t\tthis.trim();\n\t}\n\n\treset(): void {\n\t\tthis.entries = [];\n\t}\n\n\tsnapshot(): WatchdogScopeEntry[] {\n\t\treturn this.entries.map((entry) => ({ ...entry }));\n\t}\n\n\trender(): string {\n\t\tif (!this.entries.length) return \"\";\n\t\treturn [\n\t\t\t\"Current scope:\",\n\t\t\t\"The following real user prompts are the current scope record, newest last. Newer prompts supersede and mutate older prompts: they may add, modify, or remove requirements. Flag work that serves no current scope item as category 'scope-drift'.\",\n\t\t\t...this.entries.map((entry, index) =>\n\t\t\t\t[`Scope prompt ${index + 1} (${entry.createdAt}):`, entry.prompt].join(\"\\n\"),\n\t\t\t),\n\t\t].join(\"\\n\\n\");\n\t}\n\n\tprivate trim(): void {\n\t\twhile (this.entries.length > MAX_SCOPE_ENTRIES) this.entries.shift();\n\t\tlet total = this.entries.reduce((sum, entry) => sum + entry.prompt.length, 0);\n\t\twhile (this.entries.length > 1 && total > MAX_SCOPE_TOTAL_CHARS) {\n\t\t\tconst removed = this.entries.shift();\n\t\t\tif (removed) total -= removed.prompt.length;\n\t\t}\n\t}\n}\n\nexport function isWatchdogAutoFollowPromptEvent(event: unknown): boolean {\n\treturn Boolean(\n\t\tevent &&\n\t\t\ttypeof event === \"object\" &&\n\t\t\t(event as { [WATCHDOG_AUTO_FOLLOW_PROMPT_MARKER]?: unknown })[WATCHDOG_AUTO_FOLLOW_PROMPT_MARKER],\n\t);\n}\n\nexport function markWatchdogAutoFollowPromptEvent<T extends object>(event: T): T {\n\tObject.defineProperty(event, WATCHDOG_AUTO_FOLLOW_PROMPT_MARKER, { value: true });\n\treturn event;\n}\n"]}