|
2 | 2 | * JSON code fields (a `code` subBlock holding JSON text: an agent's `responseFormat`, table row |
3 | 3 | * `data`, a response body) written as object literals with typed references at their leaves. |
4 | 4 | * |
5 | | - * The executor resolves a reference inside such text by splicing the value's text where the token |
6 | | - * stands (`resolveTemplate` → `formatValueForBlock`): a string goes in raw, any other value as its |
7 | | - * JSON. So a token keeps its value's type only when it sits bare for a non-string value |
8 | | - * (`"n": <score.value>` → `"n": 3`) and quoted for a string (`"s": "<ticket.subject>"`). A bare |
9 | | - * reference in a literal is stored by its output type: quoted when the catalog types it `string`, |
10 | | - * bare otherwise, and an untyped one bare with `W_JSON_REF_UNTYPED`, since a string there would |
11 | | - * break the JSON. A string in the literal (`` t`Hi ${x.name}` ``, `'plain'`) is always a JSON |
| 5 | + * The executor resolves a reference inside such text where the token stands (`resolveTemplate`): |
| 6 | + * inside a JSON string it splices the value escaped as string content; bare, it splices the value |
| 7 | + * as JSON, a string as a JSON string unless the string already reads as JSON. So a token keeps a |
| 8 | + * string value as text only when it sits quoted (`"s": "<ticket.subject>"`): bare, text that reads |
| 9 | + * as JSON (`123`, `true`) turns into that value. A bare reference in a literal is stored by its |
| 10 | + * output type: quoted when the catalog types it `string`, bare otherwise, and an untyped one bare |
| 11 | + * with `W_JSON_REF_UNTYPED`, since text there may not stay text. A string in the literal (`` t`Hi ${x.name}` ``, `'plain'`) is always a JSON |
12 | 12 | * string, which is how a value is turned into text on purpose. |
13 | 13 | * |
14 | 14 | * The printer writes stored text back as a literal only when serializing that literal reproduces |
@@ -274,8 +274,8 @@ export function refValueKind( |
274 | 274 | * Whether a stored token is a string by declaration (the catalog, a variable's type, an input or |
275 | 275 | * response format, an environment variable), not only by what a Function's code or a child |
276 | 276 | * workflow's Response infers. Only such a token prints as a bare reference where it is stored |
277 | | - * quoted: a bare reference typed by inference would compile bare, and break the JSON, once an edit |
278 | | - * to that other code leaves its type unreadable, so the printer writes it as `` t`${ref}` ``, |
| 277 | + * quoted: a bare reference typed by inference would compile bare, and stop storing text as text, |
| 278 | + * once an edit to that other code leaves its type unreadable, so the printer writes it as `` t`${ref}` ``, |
279 | 279 | * which is text whatever the code returns. |
280 | 280 | */ |
281 | 281 | export function refDeclaresString(token: string, scope: RefTypeScope): boolean { |
|
0 commit comments