{"version":3,"file":"btw-command.d.ts","sourceRoot":"","sources":["../../src/core/btw-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,eAAO,MAAM,gBAAgB,SAAS,CAAC;AACvC,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AACtD,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,gBAAgB;IAChC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,uBAAuB,IAAI,SAAS,MAAM,EAAE,CAAC;CAC7C;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQhE;AAED,wBAAgB,wBAAwB,CACvC,IAAI,EAAE,MAAM,GACV,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC,CAUvF;AAED,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC,GAC7D,MAAM,GAAG,SAAS,CAWpB;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAO5E","sourcesContent":["import type { CustomMessage } from \"./messages.js\";\n\nexport const BTW_COMMAND_NAME = \"/btw\";\nexport const BTW_COMMAND_USAGE = \"Usage: /btw <note>\";\nexport const BTW_CUSTOM_TYPE = \"btw\";\n\nexport interface BtwNoteDetails {\n\tnote: string;\n}\n\nexport interface BtwCommandTarget {\n\tqueueByTheWay(note: string): void;\n\tgetPendingByTheWayNotes(): readonly string[];\n}\n\nexport function parseBtwCommand(text: string): string | undefined {\n\tconst trimmed = text.trim();\n\tif (!trimmed.toLowerCase().startsWith(`${BTW_COMMAND_NAME} `)) {\n\t\treturn undefined;\n\t}\n\n\tconst note = trimmed.slice(BTW_COMMAND_NAME.length).trim();\n\treturn note.length > 0 ? note : undefined;\n}\n\nexport function createBtwNextTurnMessage(\n\tnote: string,\n): Pick<CustomMessage<BtwNoteDetails>, \"customType\" | \"content\" | \"display\" | \"details\"> {\n\treturn {\n\t\tcustomType: BTW_CUSTOM_TYPE,\n\t\tcontent:\n\t\t\t`<system-reminder>By the way from the operator for the next turn only. ` +\n\t\t\t`Treat this as additional guidance that should inform the next response, but do not treat it as persisted memory or a new standalone task by itself unless the next user message asks for that. ` +\n\t\t\t`This note is runtime-only and should be consumed once on the next turn.</system-reminder>\\n\\n${note}`,\n\t\tdisplay: false,\n\t\tdetails: { note },\n\t};\n}\n\nexport function getBtwNoteFromMessage(\n\tmessage: Pick<CustomMessage<unknown>, \"customType\" | \"details\">,\n): string | undefined {\n\tif (message.customType !== BTW_CUSTOM_TYPE) {\n\t\treturn undefined;\n\t}\n\n\tif (!message.details || typeof message.details !== \"object\" || !Object.hasOwn(message.details, \"note\")) {\n\t\treturn undefined;\n\t}\n\n\tconst { note } = message.details as { note?: unknown };\n\treturn typeof note === \"string\" ? note : undefined;\n}\n\nexport function runBtwCommand(target: BtwCommandTarget, note: string): string {\n\ttarget.queueByTheWay(note);\n\tconst pendingCount = target.getPendingByTheWayNotes().length;\n\treturn (\n\t\t`Queued by-the-way guidance for the next turn only (runtime-only). ` +\n\t\t`It will be injected with the next real prompt and then cleared. Pending BTW notes: ${pendingCount}.`\n\t);\n}\n"]}