@koda-sl/baker-bridge 0.124.0 → 0.125.0-dev.ee2f8e252
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/broker/credential-cache.d.ts.map +1 -1
- package/dist/broker/credential-cache.js +1 -8
- package/dist/broker/credential-cache.js.map +1 -1
- package/dist/broker/credential-cache.test.js +0 -16
- package/dist/broker/credential-cache.test.js.map +1 -1
- package/dist/hono/avatar-accent.d.ts +23 -5
- package/dist/hono/avatar-accent.d.ts.map +1 -1
- package/dist/hono/avatar-accent.js +54 -63
- package/dist/hono/avatar-accent.js.map +1 -1
- package/dist/hono/avatar-accent.test.js +64 -35
- package/dist/hono/avatar-accent.test.js.map +1 -1
- package/dist/hono/avatar-face-question.d.ts +23 -6
- package/dist/hono/avatar-face-question.d.ts.map +1 -1
- package/dist/hono/avatar-face-question.js +48 -59
- package/dist/hono/avatar-face-question.js.map +1 -1
- package/dist/hono/avatar-face-question.test.js +46 -101
- package/dist/hono/avatar-face-question.test.js.map +1 -1
- package/dist/hono/bridge-job.d.ts +4 -0
- package/dist/hono/bridge-job.d.ts.map +1 -1
- package/dist/hono/bridge-job.js +9 -6
- package/dist/hono/bridge-job.js.map +1 -1
- package/dist/hono/bridge-job.test.js +3 -0
- package/dist/hono/bridge-job.test.js.map +1 -1
- package/dist/hono/credential-scrub.d.ts +1 -2
- package/dist/hono/credential-scrub.d.ts.map +1 -1
- package/dist/hono/credential-scrub.js +2 -23
- package/dist/hono/credential-scrub.js.map +1 -1
- package/dist/hono/credential-scrub.test.js +0 -25
- package/dist/hono/credential-scrub.test.js.map +1 -1
- package/dist/hono/jev.d.ts +16 -0
- package/dist/hono/jev.d.ts.map +1 -0
- package/dist/hono/jev.js +60 -0
- package/dist/hono/jev.js.map +1 -0
- package/dist/hono/jev.test.d.ts +2 -0
- package/dist/hono/jev.test.d.ts.map +1 -0
- package/dist/hono/jev.test.js +15 -0
- package/dist/hono/jev.test.js.map +1 -0
- package/dist/review/digest.d.ts +8 -1
- package/dist/review/digest.d.ts.map +1 -1
- package/dist/review/digest.js +10 -43
- package/dist/review/digest.js.map +1 -1
- package/dist/review/digest.test.js +11 -6
- package/dist/review/digest.test.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,6 +43,7 @@ await server.start();
|
|
|
43
43
|
| `INTERNAL_SECRET_KEY` | AES key for encrypting flow `_data.json` config at rest |
|
|
44
44
|
| `ANTHROPIC_API_KEY` | Anthropic API key (required by the Agent SDK) |
|
|
45
45
|
| `ANTHROPIC_BASE_URL` / `ANTHROPIC_AUTH_TOKEN` | OpenRouter routing (base URL + per-org key) injected into the sandbox. Forwarded to the Agent SDK subprocess so the agent can reach its model |
|
|
46
|
+
| `OPENROUTER_API_KEY` | The same per-org key under its own name. The bridge reads the user's and the agent's words with it before letting two kinds of call through: a question asking the user to pick an avatar's face (the casting picker shows real portraits), and an avatar accent in a language nobody asked for. Unset or unreachable, both calls go through unchecked |
|
|
46
47
|
| `CLAUDE_CODE_EXTRA_BODY` | Optional JSON merged by the CLI into every model request body. The bridge sets/extends it per turn with a per-thread `session_id` so OpenRouter sticky-routes the whole conversation to one provider instance and its instance-scoped prompt cache is re-read across the turn's many tool-call requests (see [Prompt-cache pinning](#prompt-cache-pinning)). It also defaults `provider` to Bedrock first (see [Bedrock is the preferred provider](#bedrock-is-the-preferred-provider)). Any inherited value is merged; our `session_id` and the `web`-plugin opt-out win (see [OpenRouter web plugin is forced off](#openrouter-web-plugin-is-forced-off)). An inherited `provider` replaces the Bedrock default |
|
|
47
48
|
| `BAKER_CHAT_ID` | Present only when running inside a chat sandbox. When set, the bridge relocates Claude Code auto-memory into the cloned repo (`.claude/memory`) — see [Session journal](#session-journal-agent-memory) |
|
|
48
49
|
| `BAKER_ACTING_USER_ID` | Injected into the Agent SDK subprocess env per turn (when the turn's sender is known) so in-sandbox `baker` CLI calls can scope work to the acting user — e.g. `baker mcp add --scope user` |
|
|
@@ -70,7 +71,7 @@ A second bin, run as root in the sandbox before the agent starts, so the agent c
|
|
|
70
71
|
|
|
71
72
|
The agent's processes get `agentProxyEnv()`: `HTTP(S)_PROXY` pointing at the broker, `NO_PROXY` for loopback plus the model gateway, `NODE_USE_ENV_PROXY=1`, `NODE_EXTRA_CA_CERTS` set to the broker's CA, and `REQUESTS_CA_BUNDLE` / `SSL_CERT_FILE` / `CURL_CA_BUNDLE` set to the system bundle.
|
|
72
73
|
|
|
73
|
-
Security model: a value is only substituted over https, and only for a host the user allowed for that credential. A placeholder in the URL or a header that is not allowed for the host, or that names no stored credential, is refused (403 / 404, or 503 while credentials can't be fetched) before anything leaves the sandbox. A placeholder that appears only in the body is left as plain text unless it names a credential allowed for that host. Response headers and text bodies up to 10 MB are scrubbed back to placeholders; those responses arrive buffered rather than streamed. The socket never returns a value.
|
|
74
|
+
Security model: a value is only substituted over https, and only for a host the user allowed for that credential. A placeholder in the URL or a header that is not allowed for the host, or that names no stored credential, is refused (403 / 404, or 503 while credentials can't be fetched) before anything leaves the sandbox. A placeholder that appears only in the body is left as plain text unless it names a credential allowed for that host. Response headers and text bodies up to 10 MB are scrubbed back to placeholders; those responses arrive buffered rather than streamed. The socket never returns a value.
|
|
74
75
|
|
|
75
76
|
## Session surface
|
|
76
77
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-cache.d.ts","sourceRoot":"","sources":["../../src/broker/credential-cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"credential-cache.d.ts","sourceRoot":"","sources":["../../src/broker/credential-cache.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,eAAO,MAAM,iBAAiB,QAAS,CAAC;AACxC,6GAA6G;AAC7G,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;AAEnE,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,IAAI,OAAO,CAAC,kBAAkB,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5C,+EAA+E;IAC/E,UAAU,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC5C;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC;IACnB,yEAAyE;IACzE,IAAI,IAAI,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAC7C,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,GAAG,eAAe,CAsDlB"}
|
|
@@ -6,9 +6,6 @@
|
|
|
6
6
|
* has succeeded there is no table (null), which callers must treat as
|
|
7
7
|
* "credentials unavailable", not "no credentials".
|
|
8
8
|
*
|
|
9
|
-
* A scrub uses the last good table while a refresh is in flight, so a slow
|
|
10
|
-
* Baker never holds a tool result back once one fetch has succeeded.
|
|
11
|
-
*
|
|
12
9
|
* A value that leaves the table — refused or removed — may still be on its
|
|
13
10
|
* way back in a response to a request that carried it, so `scrubbable()`
|
|
14
11
|
* keeps scrubbing it for the broker's lifetime. It is never sent again.
|
|
@@ -55,11 +52,7 @@ export function createCredentialCache(options) {
|
|
|
55
52
|
return {
|
|
56
53
|
get,
|
|
57
54
|
async scrubbable() {
|
|
58
|
-
|
|
59
|
-
// A scrub never waits on a refresh it can do without: the last good table
|
|
60
|
-
// still covers every value the proxy could have sent.
|
|
61
|
-
const table = lastGood ?? (await pending);
|
|
62
|
-
return [...(table ?? []), ...retired.values()];
|
|
55
|
+
return [...((await get()) ?? []), ...retired.values()];
|
|
63
56
|
},
|
|
64
57
|
refresh() {
|
|
65
58
|
if (now() - lastRefreshAt < MIN_REFRESH_INTERVAL_MS)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-cache.js","sourceRoot":"","sources":["../../src/broker/credential-cache.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"credential-cache.js","sourceRoot":"","sources":["../../src/broker/credential-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACxC,6GAA6G;AAC7G,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAiB7C,MAAM,UAAU,qBAAqB,CAAC,OAKrC;IACC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;IACpC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,iBAAiB,CAAC;IACjD,IAAI,KAAK,GAAuE,IAAI,CAAC;IACrF,IAAI,QAAQ,GAAgC,IAAI,CAAC;IACjD,IAAI,aAAa,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAC7C,MAAM,OAAO,GAAG,IAAI,GAAG,EAA8B,CAAC;IAEtD,SAAS,YAAY,CAAC,IAAiC;QACrD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;QAClE,KAAK,MAAM,UAAU,IAAI,QAAQ,IAAI,EAAE,EAAE,CAAC;YACxC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC;gBAAE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAC7E,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,IAAI;YAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAChD,QAAQ,GAAG,IAAI,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CAAC;QACD,IAAI;YACF,OAAO,QAAQ,EAAE,MAAM,IAAI,CAAC,CAAC;QAC/B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -92,22 +92,6 @@ describe("createCredentialCache", () => {
|
|
|
92
92
|
expect(afterRefusal.sort()).toEqual(["ads-secret-value", "shop-secret-value"]);
|
|
93
93
|
expect(await cache.get()).toBeNull();
|
|
94
94
|
});
|
|
95
|
-
it("scrubs with the last good table while a slow refresh is still in flight", async () => {
|
|
96
|
-
let clock = 0;
|
|
97
|
-
let hang = false;
|
|
98
|
-
const cache = createCredentialCache({
|
|
99
|
-
fetchCredentials: () => hang
|
|
100
|
-
? new Promise(() => {
|
|
101
|
-
// Baker never answers.
|
|
102
|
-
})
|
|
103
|
-
: Promise.resolve([{ name: "shop", value: "secret-value", allowedHosts: ["api.example.com"] }]),
|
|
104
|
-
now: () => clock,
|
|
105
|
-
});
|
|
106
|
-
await cache.get();
|
|
107
|
-
hang = true;
|
|
108
|
-
clock = 10_000;
|
|
109
|
-
expect((await cache.scrubbable()).map((credential) => credential.name)).toEqual(["shop"]);
|
|
110
|
-
});
|
|
111
95
|
it("fetches again on the next read after a refresh", async () => {
|
|
112
96
|
const source = fetcher();
|
|
113
97
|
const cache = createCredentialCache({ fetchCredentials: source.fetchCredentials, now: () => 0 });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-cache.test.js","sourceRoot":"","sources":["../../src/broker/credential-cache.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,SAAS,OAAO;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAAO;QACL,IAAI,KAAK;YACP,OAAO,KAAK,CAAC;QACf,CAAC;QACD,gB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S,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAChC,MAAM,KAAK,CAAC,GAAG,EAAE,CAAC;QACpB,CAAC;QACD,KAAK,GAAG,KAAK,CAAC;QACd,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAChC,MAAM,KAAK,CAAC,GAAG,EAAE,CAAC;QAElB,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAClD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -13,11 +13,29 @@
|
|
|
13
13
|
* own description, in the creation hint and in the family doc by now, so this is the
|
|
14
14
|
* layer left.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* language
|
|
19
|
-
*
|
|
16
|
+
* Whether the accent fits is read by Jev from what the user said, in whatever language
|
|
17
|
+
* they write, and from the company's own Knowledge (COMPANY.md): their own language, the
|
|
18
|
+
* language the company's content is written in, a regional accent of either, or a language
|
|
19
|
+
* or market they asked for all fit. An agency member writing in English for a
|
|
20
|
+
* Spanish-market client wants a Spanish presenter. A wrong refusal leaves the user nothing
|
|
21
|
+
* to type, so a judge that cannot answer, or a company whose Knowledge cannot be read, lets
|
|
22
|
+
* the command through.
|
|
20
23
|
*/
|
|
24
|
+
import type { Judge } from "./jev.ts";
|
|
25
|
+
/**
|
|
26
|
+
* Three judgments, each its own Noul in one request: an accent fits when the user writes in
|
|
27
|
+
* its language, or asked for it, or it names no language at all. Asked as one question, a
|
|
28
|
+
* face ("eher südländischer Typ") read as a request for Italian (0.79). Re-run
|
|
29
|
+
* `scripts/avatar-guard-evals` after changing any of them.
|
|
30
|
+
*/
|
|
31
|
+
export declare const ACCENT_WRITTEN_IN_QUESTION: string;
|
|
32
|
+
export declare const ACCENT_ASKED_FOR_QUESTION: string;
|
|
33
|
+
export declare const ACCENT_COMPANY_LANGUAGE_QUESTION: string;
|
|
34
|
+
export declare const ACCENT_NAMES_LANGUAGE_QUESTION = "Does `accent` name a language, a country or a regional accent?";
|
|
35
|
+
/** Each answer is a yes at or above this. Measured in `scripts/avatar-guard-evals`. */
|
|
36
|
+
export declare const ACCENT_HELD = 0.5;
|
|
37
|
+
/** The company's own description (COMPANY.md in the Company Workspace), or undefined when unreadable. */
|
|
38
|
+
export type CompanyText = () => Promise<string | undefined>;
|
|
21
39
|
/** The `--accent` value in a `baker avatars create|update` command, if it has one. */
|
|
22
40
|
export declare function accentFrom(command: string): string | null;
|
|
23
41
|
/** The refusal, or null when the accent is consistent with what the user asked for. */
|
|
@@ -30,5 +48,5 @@ export declare function accentContradictsUser(command: string | undefined, userT
|
|
|
30
48
|
* the UK, in English" — and writes the next in Spanish had their own decision refused,
|
|
31
49
|
* with nothing they could type to get past it short of repeating themselves every time.
|
|
32
50
|
*/
|
|
33
|
-
priorUserText?:
|
|
51
|
+
priorUserText: string | undefined, judge: Judge, companyText?: CompanyText): Promise<string | null>;
|
|
34
52
|
//# sourceMappingURL=avatar-accent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar-accent.d.ts","sourceRoot":"","sources":["../../src/hono/avatar-accent.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"avatar-accent.d.ts","sourceRoot":"","sources":["../../src/hono/avatar-accent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAGtC;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,QAES,CAAC;AACjD,eAAO,MAAM,yBAAyB,QAG6E,CAAC;AACpH,eAAO,MAAM,gCAAgC,QAEwD,CAAC;AACtG,eAAO,MAAM,8BAA8B,mEAAmE,CAAC;AAC/G,uFAAuF;AACvF,eAAO,MAAM,WAAW,MAAM,CAAC;AAM/B,yGAAyG;AACzG,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAO5D,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIzD;AAED,uFAAuF;AACvF,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,QAAQ,EAAE,MAAM,GAAG,SAAS;AAC5B;;;;;;;GAOG;AACH,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,KAAK,EAAE,KAAK,EACZ,WAAW,GAAE,WAA6B,GACzC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAqCxB"}
|
|
@@ -1,51 +1,28 @@
|
|
|
1
|
+
import { bridgeRuntimeFiles, runtimeFileStore } from "./runtime-files.js";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* a row, each from the same Spanish sentence asking for "aspecto europeo" — a face:
|
|
7
|
-
*
|
|
8
|
-
* --accent "Dutch, neutral European accent"
|
|
9
|
-
* --accent "German, clear and authoritative"
|
|
10
|
-
* --accent "English from UK, Southern England accent"
|
|
11
|
-
*
|
|
12
|
-
* The first shipped: a Spanish client's ad, spoken in German. The rule is in the flag's
|
|
13
|
-
* own description, in the creation hint and in the family doc by now, so this is the
|
|
14
|
-
* layer left.
|
|
15
|
-
*
|
|
16
|
-
* Narrow by construction — it only fires when the user is clearly writing Spanish AND
|
|
17
|
-
* the accent clearly names another language AND nothing the user said asks for that
|
|
18
|
-
* language or market. An ad a Spaniard genuinely wants in English says so, and then
|
|
19
|
-
* this stays out of the way.
|
|
3
|
+
* Three judgments, each its own Noul in one request: an accent fits when the user writes in
|
|
4
|
+
* its language, or asked for it, or it names no language at all. Asked as one question, a
|
|
5
|
+
* face ("eher südländischer Typ") read as a request for Italian (0.79). Re-run
|
|
6
|
+
* `scripts/avatar-guard-evals` after changing any of them.
|
|
20
7
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
justification: /\b(holand[ée]s|neerland[ée]s|pa[íi]ses bajos|holanda|b[ée]lgica)\b/i,
|
|
40
|
-
},
|
|
41
|
-
{ name: "Italian", accent: /\b(italian)\b/i, justification: /\b(italiano|italiana|italia)\b/i },
|
|
42
|
-
{ name: "Portuguese", accent: /\b(portuguese|brazilian)\b/i, justification: /\b(portugu[ée]s|portugal|brasil)\b/i },
|
|
43
|
-
];
|
|
44
|
-
/** Enough Spanish function words that the user is plainly writing Spanish. */
|
|
45
|
-
const SPANISH_CONFIDENCE = 3;
|
|
46
|
-
function writesSpanish(text) {
|
|
47
|
-
return (text.match(SPANISH_MARKERS) ?? []).length >= SPANISH_CONFIDENCE;
|
|
48
|
-
}
|
|
8
|
+
export const ACCENT_WRITTEN_IN_QUESTION = "`accent` is how an ad's presenter will speak. Is `conversation` written in the language `accent` names? " +
|
|
9
|
+
"Any regional accent of that language counts.";
|
|
10
|
+
export const ACCENT_ASKED_FOR_QUESTION = "`accent` is how an ad's presenter will speak. Does `conversation` ask for the ad or presenter in the language " +
|
|
11
|
+
"`accent` names, or for a country, region or market where that language is spoken? Asking for how the " +
|
|
12
|
+
"presenter should look (a European, Nordic, Asian, Mediterranean or American look) is not asking for a language.";
|
|
13
|
+
export const ACCENT_COMPANY_LANGUAGE_QUESTION = "`accent` is how an ad's presenter will speak. `company` is the company's own description of itself. " +
|
|
14
|
+
"Is `company` written in the language `accent` names? Any regional accent of that language counts.";
|
|
15
|
+
export const ACCENT_NAMES_LANGUAGE_QUESTION = "Does `accent` name a language, a country or a regional accent?";
|
|
16
|
+
/** Each answer is a yes at or above this. Measured in `scripts/avatar-guard-evals`. */
|
|
17
|
+
export const ACCENT_HELD = 0.5;
|
|
18
|
+
/** The most of the conversation read, from its end: the latest turns carry the decision. */
|
|
19
|
+
const CONVERSATION_CHARS = 12_000;
|
|
20
|
+
/** The most of the company's Knowledge read, from its start: enough to tell its language. */
|
|
21
|
+
const COMPANY_CHARS = 4_000;
|
|
22
|
+
const readCompanyFile = async () => {
|
|
23
|
+
const read = await runtimeFileStore.readText(bridgeRuntimeFiles.companyFile());
|
|
24
|
+
return read.ok ? read.value : undefined;
|
|
25
|
+
};
|
|
49
26
|
/** The `--accent` value in a `baker avatars create|update` command, if it has one. */
|
|
50
27
|
export function accentFrom(command) {
|
|
51
28
|
if (!/\bbaker\s+avatars\s+(create|update)\b/.test(command))
|
|
@@ -54,7 +31,7 @@ export function accentFrom(command) {
|
|
|
54
31
|
return match ? (match[2] ?? match[3] ?? match[4] ?? null) : null;
|
|
55
32
|
}
|
|
56
33
|
/** The refusal, or null when the accent is consistent with what the user asked for. */
|
|
57
|
-
export function accentContradictsUser(command, userText,
|
|
34
|
+
export async function accentContradictsUser(command, userText,
|
|
58
35
|
/**
|
|
59
36
|
* What the user said EARLIER in the same conversation.
|
|
60
37
|
*
|
|
@@ -63,24 +40,38 @@ export function accentContradictsUser(command, userText,
|
|
|
63
40
|
* the UK, in English" — and writes the next in Spanish had their own decision refused,
|
|
64
41
|
* with nothing they could type to get past it short of repeating themselves every time.
|
|
65
42
|
*/
|
|
66
|
-
priorUserText) {
|
|
67
|
-
const said = [priorUserText ?? "", userText ?? ""].join("
|
|
68
|
-
|
|
43
|
+
priorUserText, judge, companyText = readCompanyFile) {
|
|
44
|
+
const said = [priorUserText ?? "", userText ?? ""].join("\n").trim().slice(-CONVERSATION_CHARS);
|
|
45
|
+
const accent = command ? accentFrom(command) : null;
|
|
46
|
+
if (!accent || !said)
|
|
47
|
+
return null;
|
|
48
|
+
const company = (await companyText())?.trim().slice(0, COMPANY_CHARS);
|
|
49
|
+
if (!company)
|
|
69
50
|
return null;
|
|
70
|
-
const
|
|
71
|
-
|
|
51
|
+
const answers = await judge([
|
|
52
|
+
...[ACCENT_WRITTEN_IN_QUESTION, ACCENT_ASKED_FOR_QUESTION, ACCENT_NAMES_LANGUAGE_QUESTION].map((question) => ({
|
|
53
|
+
instructions: { accent, conversation: said, question },
|
|
54
|
+
})),
|
|
55
|
+
{ instructions: { accent, company, question: ACCENT_COMPANY_LANGUAGE_QUESTION } },
|
|
56
|
+
]);
|
|
57
|
+
const [writtenIn, askedFor, namesLanguage, companyWritesIt] = answers ?? [];
|
|
58
|
+
if (writtenIn === undefined ||
|
|
59
|
+
askedFor === undefined ||
|
|
60
|
+
namesLanguage === undefined ||
|
|
61
|
+
companyWritesIt === undefined) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
if (writtenIn >= ACCENT_HELD ||
|
|
65
|
+
askedFor >= ACCENT_HELD ||
|
|
66
|
+
companyWritesIt >= ACCENT_HELD ||
|
|
67
|
+
namesLanguage < ACCENT_HELD) {
|
|
72
68
|
return null;
|
|
73
|
-
for (const language of FOREIGN_LANGUAGES) {
|
|
74
|
-
if (!language.accent.test(accent))
|
|
75
|
-
continue;
|
|
76
|
-
if (language.justification.test(said))
|
|
77
|
-
return null;
|
|
78
|
-
return (`Blocked: --accent "${accent}" makes this avatar speak ${language.name}, and the user is writing to you in ` +
|
|
79
|
-
`Spanish without asking for ${language.name} anywhere. --accent sets the LANGUAGE of every clip, not the ` +
|
|
80
|
-
`person's looks — "aspecto europeo", "Nordic" and "Mediterranean" describe a FACE and belong in --subject. ` +
|
|
81
|
-
`Use the user's own language (e.g. --accent "Spanish from Spain, Madrid accent"). If the ad really is for a ` +
|
|
82
|
-
`${language.name}-speaking market, ask them first and say so in the same turn.`);
|
|
83
69
|
}
|
|
84
|
-
return
|
|
70
|
+
return (`Blocked: --accent "${accent}" sets the language this avatar speaks, and nothing points to it: it is not the ` +
|
|
71
|
+
`language the user writes to you in, nor one they asked for, nor the language the company's own content is ` +
|
|
72
|
+
`written in. --accent sets the LANGUAGE of every clip, not the person's looks — "aspecto europeo", "Nordic" ` +
|
|
73
|
+
`and "Mediterranean" describe a FACE and belong in --subject. Use the language of the market the ad is for: ` +
|
|
74
|
+
`the user's own, or the company's. If the ad really is for a market that speaks another language, ask them ` +
|
|
75
|
+
`first and say so in the same turn.`);
|
|
85
76
|
}
|
|
86
77
|
//# sourceMappingURL=avatar-accent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar-accent.js","sourceRoot":"","sources":["../../src/hono/avatar-accent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"avatar-accent.js","sourceRoot":"","sources":["../../src/hono/avatar-accent.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GACrC,0GAA0G;IAC1G,8CAA8C,CAAC;AACjD,MAAM,CAAC,MAAM,yBAAyB,GACpC,gHAAgH;IAChH,uGAAuG;IACvG,iHAAiH,CAAC;AACpH,MAAM,CAAC,MAAM,gCAAgC,GAC3C,sGAAsG;IACtG,mGAAmG,CAAC;AACtG,MAAM,CAAC,MAAM,8BAA8B,GAAG,gEAAgE,CAAC;AAC/G,uFAAuF;AACvF,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC;AAC/B,4FAA4F;AAC5F,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,6FAA6F;AAC7F,MAAM,aAAa,GAAG,KAAK,CAAC;AAK5B,MAAM,eAAe,GAAgB,KAAK,IAAI,EAAE;IAC9C,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,QAAQ,CAAC,kBAAkB,CAAC,WAAW,EAAE,CAAC,CAAC;IAC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AAE,yBAAyB,EAAE,8BAA8B,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC5G,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE;SACvD,CAAC,CAAC;QACH,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,gCAAgC,EAAE,EAAE;KAClF,CAAC,CAAC;IACH,MAAM,CAAC,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,CAAC,GAAG,OAAO,IAAI,EAAE,CAAC;IAC5E,IACE,SAAS,KAAK,SAAS;QACvB,QAAQ,KAAK,SAAS;QACtB,aAAa,KAAK,SAAS;QAC3B,eAAe,KAAK,SAAS,EAC7B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IACE,SAAS,IAAI,WAAW;QACxB,QAAQ,IAAI,WAAW;QACvB,eAAe,IAAI,WAAW;QAC9B,aAAa,GAAG,WAAW,EAC3B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CACL,sBAAsB,MAAM,kFAAkF;QAC9G,4GAA4G;QAC5G,6GAA6G;QAC7G,6GAA6G;QAC7G,4GAA4G;QAC5G,oCAAoC,CACrC,CAAC;AACJ,CAAC"}
|
|
@@ -1,48 +1,77 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { accentContradictsUser, accentFrom } from "./avatar-accent.js";
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
import { ACCENT_ASKED_FOR_QUESTION, ACCENT_NAMES_LANGUAGE_QUESTION, accentContradictsUser, accentFrom, } from "./avatar-accent.js";
|
|
3
|
+
const CREATE = (accent) => `baker avatars create --name "X" --accent "${accent}"`;
|
|
4
|
+
/** A company whose Knowledge `fitsWhen` never reads as written in the accent's language. */
|
|
5
|
+
const COMPANY = async () => "# Słoneczne Panele\n\nMontujemy panele słoneczne w Polsce.";
|
|
6
|
+
/**
|
|
7
|
+
* A judge that reads every accent as naming a language unless it mentions `noLanguage`, and
|
|
8
|
+
* holds it asked for only when the conversation mentions `marker`. The user never writes in it.
|
|
9
|
+
*/
|
|
10
|
+
function fitsWhen(marker, noLanguage = "warm") {
|
|
11
|
+
return async (questions) => questions.map(({ instructions }) => {
|
|
12
|
+
if (instructions.question === ACCENT_NAMES_LANGUAGE_QUESTION) {
|
|
13
|
+
return instructions.accent?.includes(noLanguage) ? 0.02 : 0.9;
|
|
14
|
+
}
|
|
15
|
+
if (instructions.question === ACCENT_ASKED_FOR_QUESTION) {
|
|
16
|
+
return instructions.conversation?.includes(marker) ? 0.9 : 0.1;
|
|
13
17
|
}
|
|
18
|
+
return 0.05;
|
|
14
19
|
});
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
}
|
|
21
|
+
describe("accentContradictsUser", () => {
|
|
22
|
+
it("refuses an accent the judge reads as a language nobody asked for, in any language the user writes", async () => {
|
|
23
|
+
const refusal = await accentContradictsUser(CREATE("Swedish, neutral"), "Zrób awatara do reklamy na TikToka o panelach słonecznych, ma wyglądać skandynawsko.", undefined, fitsWhen("po szwedzku"), COMPANY);
|
|
24
|
+
expect(refusal).toContain("--accent sets the LANGUAGE");
|
|
25
|
+
expect(refusal).toContain("the market the ad is for");
|
|
17
26
|
});
|
|
18
|
-
it("
|
|
19
|
-
|
|
20
|
-
expect(
|
|
27
|
+
it("lets the command through when the company's Knowledge cannot be read, rather than refuse on a guess", async () => {
|
|
28
|
+
const refusal = await accentContradictsUser(CREATE("Swedish, neutral"), "Zrób awatara do reklamy na TikToka o panelach słonecznych.", undefined, fitsWhen("po szwedzku"), async () => undefined);
|
|
29
|
+
expect(refusal).toBeNull();
|
|
21
30
|
});
|
|
22
|
-
it("
|
|
23
|
-
|
|
31
|
+
it("allows the language the company's own Knowledge is written in, when the conversation is in another", async () => {
|
|
32
|
+
// An agency member writing in English for a Spanish-market client: the ad is for the
|
|
33
|
+
// client's market, so its presenter speaks the client's language.
|
|
34
|
+
const companyWritesIt = async (questions) => questions.map(({ instructions }) => {
|
|
35
|
+
if (instructions.question === ACCENT_NAMES_LANGUAGE_QUESTION)
|
|
36
|
+
return 0.9;
|
|
37
|
+
return instructions.company?.includes("Clínica dental en Valencia") ? 0.95 : 0.05;
|
|
38
|
+
});
|
|
39
|
+
const refusal = await accentContradictsUser(CREATE("Spanish from Spain"), "UGC ad for our summer promo", undefined, companyWritesIt, async () => "# Sonrisa\n\nClínica dental en Valencia con tres sedes.");
|
|
40
|
+
expect(refusal).toBeNull();
|
|
24
41
|
});
|
|
25
|
-
it("
|
|
26
|
-
|
|
27
|
-
expect(
|
|
42
|
+
it("allows an accent the judge reads as asked for", async () => {
|
|
43
|
+
const refusal = await accentContradictsUser(CREATE("German, standard"), "Reklama jest na rynek niemiecki, awatar ma mówić po niemiecku.", undefined, fitsWhen("po niemiecku"), COMPANY);
|
|
44
|
+
expect(refusal).toBeNull();
|
|
28
45
|
});
|
|
29
|
-
it("reads the
|
|
30
|
-
|
|
31
|
-
|
|
46
|
+
it("reads what the user said in an earlier turn on the same footing as this one", async () => {
|
|
47
|
+
// A user who settles the market in one turn and writes the next in Spanish had their
|
|
48
|
+
// own decision refused, with nothing they could type short of repeating it every time.
|
|
49
|
+
const refusal = await accentContradictsUser(CREATE("English from UK, Southern England accent"), "Crea el avatar y empieza con el primer clip.", "La campaña es para UK y el anuncio va en inglés.", fitsWhen("para UK"), COMPANY);
|
|
50
|
+
expect(refusal).toBeNull();
|
|
32
51
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// The gate reads the turn in front of it. A user who settles the market in one turn —
|
|
37
|
-
// "the campaign is for the UK, in English" — and then writes the next one in Spanish
|
|
38
|
-
// got their own decision refused, with nothing they could type to get past it short of
|
|
39
|
-
// repeating themselves in every message.
|
|
40
|
-
const refusal = accentContradictsUser('baker avatars create --name "X" --accent "English from UK, Southern England accent"', "Crea el avatar y empieza con el primer clip.", "La campaña es para UK y el anuncio va en inglés.");
|
|
52
|
+
it("allows the language the user writes in, which nobody has to ask for", async () => {
|
|
53
|
+
const writesIt = async (questions) => questions.map(({ instructions }) => (instructions.question === ACCENT_ASKED_FOR_QUESTION ? 0.1 : 0.95));
|
|
54
|
+
const refusal = await accentContradictsUser(CREATE("Polish, Warsaw"), "Zrób awatara do reklamy.", undefined, writesIt, COMPANY);
|
|
41
55
|
expect(refusal).toBeNull();
|
|
42
56
|
});
|
|
43
|
-
it("
|
|
44
|
-
const refusal = accentContradictsUser(
|
|
45
|
-
expect(refusal).
|
|
57
|
+
it("lets an accent that names no language through: it cannot contradict anything", async () => {
|
|
58
|
+
const refusal = await accentContradictsUser(CREATE("warm and friendly"), "Crea un avatar para la clínica dental.", undefined, fitsWhen("nothing asked"), COMPANY);
|
|
59
|
+
expect(refusal).toBeNull();
|
|
60
|
+
});
|
|
61
|
+
it("lets the command through when the judge cannot answer, rather than refuse on a guess", async () => {
|
|
62
|
+
expect(await accentContradictsUser(CREATE("German"), "Hazme un avatar", undefined, async () => null, COMPANY)).toBeNull();
|
|
63
|
+
});
|
|
64
|
+
it("ignores commands that set no accent, without asking the judge", async () => {
|
|
65
|
+
const unreachable = () => Promise.reject(new Error("the judge should not be asked"));
|
|
66
|
+
expect(await accentContradictsUser("grep -rn -- --accent docs/", "Hazme un avatar", undefined, unreachable)).toBeNull();
|
|
67
|
+
expect(await accentContradictsUser('baker avatars create --name "X"', "Hazme un avatar", undefined, unreachable)).toBeNull();
|
|
68
|
+
expect(await accentContradictsUser(undefined, "Hazme un avatar", undefined, unreachable)).toBeNull();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe("accentFrom", () => {
|
|
72
|
+
it("reads the accent however it was quoted", () => {
|
|
73
|
+
expect(accentFrom('baker avatars create --accent "German, firm"')).toBe("German, firm");
|
|
74
|
+
expect(accentFrom("baker avatars update marta --accent='British English'")).toBe("British English");
|
|
46
75
|
});
|
|
47
76
|
});
|
|
48
77
|
//# sourceMappingURL=avatar-accent.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar-accent.test.js","sourceRoot":"","sources":["../../src/hono/avatar-accent.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,
|
|
1
|
+
{"version":3,"file":"avatar-accent.test.js","sourceRoot":"","sources":["../../src/hono/avatar-accent.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,yBAAyB,EACzB,8BAA8B,EAC9B,qBAAqB,EACrB,UAAU,GACX,MAAM,oBAAoB,CAAC;AAG5B,MAAM,MAAM,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,6CAA6C,MAAM,GAAG,CAAC;AAC1F,4FAA4F;AAC5F,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE,CAAC,4DAA4D,CAAC;AAEzF;;;GAGG;AACH,SAAS,QAAQ,CAAC,MAAc,EAAE,UAAU,GAAG,MAAM;IACnD,OAAO,KAAK,EAAE,SAAS,EAAE,EAAE,CACzB,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE;QACjC,IAAI,YAAY,CAAC,QAAQ,KAAK,8BAA8B,EAAE,CAAC;YAC7D,OAAO,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;QAChE,CAAC;QACD,IAAI,YAAY,CAAC,QAAQ,KAAK,yBAAyB,EAAE,CAAC;YACxD,OAAO,YAAY,CAAC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,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,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAChD,MAAM,CAAC,UAAU,CAAC,8CAA8C,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACxF,MAAM,CAAC,UAAU,CAAC,uDAAuD,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACtG,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -11,15 +11,32 @@
|
|
|
11
11
|
* before asking anyway — three times, in both casting modes. A rule that survives being
|
|
12
12
|
* read needs a gate, and `routeToolUse` is the one path every question travels.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* Read by Jev, so a face asked for in any language or wording is caught, with no list of
|
|
15
|
+
* face words to fall out of date. Its own module, with the judge as a parameter, so it can be
|
|
16
|
+
* tested without the network or the bridge's environment.
|
|
16
17
|
*/
|
|
18
|
+
import type { Judge } from "./jev.ts";
|
|
19
|
+
/**
|
|
20
|
+
* The two questions Jev answers about each question the agent asks, as the user would read
|
|
21
|
+
* it: is it a face pick, and is it about a page. A presenter section on a landing is a photo
|
|
22
|
+
* the user already has, which the casting picker cannot offer, and asked in one question it
|
|
23
|
+
* read as a face pick (0.81). Kept word for word in step with the scaffold's
|
|
24
|
+
* guard-avatar-face-question hook, the same rule one layer in. Re-run
|
|
25
|
+
* `scripts/avatar-guard-evals` after changing either.
|
|
26
|
+
*/
|
|
27
|
+
export declare const FACE_PICK_QUESTION: string;
|
|
28
|
+
export declare const ON_A_PAGE_QUESTION = "Does `asked` mention a website, a landing page or a section of a web page?";
|
|
29
|
+
/** At or above, a face pick; below, not about a page. Measured in `scripts/avatar-guard-evals`. */
|
|
30
|
+
export declare const FACE_PICK_HELD = 0.5;
|
|
31
|
+
export declare const ON_A_PAGE_HELD = 0.5;
|
|
17
32
|
/** What the agent is told when this is refused — names both ways out. */
|
|
18
33
|
export declare const FACE_QUESTION_MESSAGE: string;
|
|
34
|
+
/** One question as the user would read it: header, question, then each option. Pure. */
|
|
35
|
+
export declare function questionText(question: unknown): string;
|
|
19
36
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
37
|
+
* Whether any question asks the user to pick a face. Each question is put to the judge as
|
|
38
|
+
* two Nouls, all in one request. A wrong refusal costs the user a real question, so a judge that
|
|
39
|
+
* cannot answer lets every question through.
|
|
23
40
|
*/
|
|
24
|
-
export declare function asksForAvatarFace(input: Record<string, unknown> | undefined): boolean
|
|
41
|
+
export declare function asksForAvatarFace(input: Record<string, unknown> | undefined, judge: Judge): Promise<boolean>;
|
|
25
42
|
//# sourceMappingURL=avatar-face-question.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar-face-question.d.ts","sourceRoot":"","sources":["../../src/hono/avatar-face-question.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"avatar-face-question.d.ts","sourceRoot":"","sources":["../../src/hono/avatar-face-question.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEtC;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,QAKpB,CAAC;AACZ,eAAO,MAAM,kBAAkB,+EAA+E,CAAC;AAC/G,mGAAmG;AACnG,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC,yEAAyE;AACzE,eAAO,MAAM,qBAAqB,QAK4B,CAAC;AAE/D,wFAAwF;AACxF,wBAAgB,YAAY,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAWtD;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAalH"}
|