(firstName: string | undefined)
| 347 | } |
| 348 | |
| 349 | function dispatcherInstruction(firstName: string | undefined): string { |
| 350 | const raw = firstName?.trim(); |
| 351 | if (!raw) return ""; |
| 352 | // Slack first_name is operator-controlled but not vetted. Strip every |
| 353 | // interpolation hazard once so a `"`, backtick, backslash, or `{{...}}` |
| 354 | // can't malform the prompt, crash renderPromptTemplate's leftover- |
| 355 | // placeholder check, or break the JSON literal the planner copies into |
| 356 | // plan.json. JSON.stringify handles `"` and `\`; the regex covers |
| 357 | // newlines, backticks, and curly braces. |
| 358 | const safe = raw.replace(/[\r\n`{}]/g, " "); |
| 359 | const safeJson = JSON.stringify(safe); |
| 360 | // Leading newline slots this between the summary instruction and the |
| 361 | // bootstrapping paragraph in the rendered kickoff prompt. |
| 362 | return `\n\nOperator: ${safe}. Set \`plan.dispatcher = { firstName: ${safeJson} }\` so the kickoff bot reads ${JSON.stringify(`${safe}'s bot`)}.`; |
| 363 | } |
| 364 | |
| 365 | function slackChannelInstruction(slackChannel: string | undefined): string { |
| 366 | if (!slackChannel) return ""; |
no outgoing calls
no test coverage detected