@koda-sl/baker-bridge 0.194.0-dev.8f5bcdb0e → 0.195.0-dev.a2270c74d

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.
Files changed (67) hide show
  1. package/README.md +66 -28
  2. package/dist/hono/agent.d.ts.map +1 -1
  3. package/dist/hono/agent.js +4 -1
  4. package/dist/hono/agent.js.map +1 -1
  5. package/dist/hono/bridge-job.d.ts +27 -0
  6. package/dist/hono/bridge-job.d.ts.map +1 -1
  7. package/dist/hono/bridge-job.js +93 -19
  8. package/dist/hono/bridge-job.js.map +1 -1
  9. package/dist/hono/bridge-job.test.js +99 -226
  10. package/dist/hono/bridge-job.test.js.map +1 -1
  11. package/dist/hono/chat-language.d.ts +34 -0
  12. package/dist/hono/chat-language.d.ts.map +1 -0
  13. package/dist/hono/chat-language.js +152 -0
  14. package/dist/hono/chat-language.js.map +1 -0
  15. package/dist/hono/chat-language.test.d.ts +2 -0
  16. package/dist/hono/chat-language.test.d.ts.map +1 -0
  17. package/dist/hono/chat-language.test.js +136 -0
  18. package/dist/hono/chat-language.test.js.map +1 -0
  19. package/dist/hono/jev.d.ts +16 -0
  20. package/dist/hono/jev.d.ts.map +1 -1
  21. package/dist/hono/jev.js +44 -21
  22. package/dist/hono/jev.js.map +1 -1
  23. package/dist/hono/model-capabilities.js +3 -3
  24. package/dist/hono/model-capabilities.js.map +1 -1
  25. package/dist/hono/progress-note.d.ts +0 -3
  26. package/dist/hono/progress-note.d.ts.map +1 -1
  27. package/dist/hono/progress-note.js +0 -8
  28. package/dist/hono/progress-note.js.map +1 -1
  29. package/dist/hono/publish-handoff.d.ts +6 -17
  30. package/dist/hono/publish-handoff.d.ts.map +1 -1
  31. package/dist/hono/publish-handoff.js +17 -67
  32. package/dist/hono/publish-handoff.js.map +1 -1
  33. package/dist/hono/publish-handoff.test.js +34 -63
  34. package/dist/hono/publish-handoff.test.js.map +1 -1
  35. package/dist/hono/scripted-publish.d.ts +19 -0
  36. package/dist/hono/scripted-publish.d.ts.map +1 -0
  37. package/dist/hono/scripted-publish.js +219 -0
  38. package/dist/hono/scripted-publish.js.map +1 -0
  39. package/dist/hono/scripted-publish.test.d.ts +2 -0
  40. package/dist/hono/scripted-publish.test.d.ts.map +1 -0
  41. package/dist/hono/scripted-publish.test.js +212 -0
  42. package/dist/hono/scripted-publish.test.js.map +1 -0
  43. package/dist/hono/skill-language.d.ts +16 -40
  44. package/dist/hono/skill-language.d.ts.map +1 -1
  45. package/dist/hono/skill-language.js +39 -168
  46. package/dist/hono/skill-language.js.map +1 -1
  47. package/dist/hono/skill-language.test.js +48 -50
  48. package/dist/hono/skill-language.test.js.map +1 -1
  49. package/dist/hono/subagent-route.test.js +29 -5
  50. package/dist/hono/subagent-route.test.js.map +1 -1
  51. package/dist/hono/types.d.ts +9 -0
  52. package/dist/hono/types.d.ts.map +1 -1
  53. package/dist/review/digest.d.ts +6 -5
  54. package/dist/review/digest.d.ts.map +1 -1
  55. package/dist/review/digest.js +34 -28
  56. package/dist/review/digest.js.map +1 -1
  57. package/dist/review/digest.test.js +42 -177
  58. package/dist/review/digest.test.js.map +1 -1
  59. package/dist/review/evidence-block.js +2 -2
  60. package/dist/review/evidence-block.js.map +1 -1
  61. package/dist/review/reply-language.d.ts +12 -30
  62. package/dist/review/reply-language.d.ts.map +1 -1
  63. package/dist/review/reply-language.js +97 -162
  64. package/dist/review/reply-language.js.map +1 -1
  65. package/dist/review/reply-language.test.js +67 -75
  66. package/dist/review/reply-language.test.js.map +1 -1
  67. package/package.json +1 -2
@@ -0,0 +1,34 @@
1
+ import type { Chooser } from "./jev.ts";
2
+ import type { DispatchHistorySnapshot } from "./types.ts";
3
+ /** At or above it, Jev's pick is named to the agent; below it, the language is left unnamed. */
4
+ export declare const LANGUAGE_HELD = 0.8;
5
+ /** The most of the conversation Jev reads, latest first: a few messages carry the language it is in now. */
6
+ export declare const CONVERSATION_MAX = 2400;
7
+ /** What Jev reads to decide: the conversation, and the marketer's latest words that carry a language. */
8
+ export type LanguageConversation = {
9
+ text: string;
10
+ marketer?: string;
11
+ };
12
+ /**
13
+ * The conversation Jev reads, oldest first, each message labelled by whose words it holds and
14
+ * cleaned of what carries no one's language; the latest `CONVERSATION_MAX` characters of it, and
15
+ * the marketer's latest message long enough to carry a language. `current` is what the marketer
16
+ * typed to start the turn running now, which the history leaves out. Empty text when nothing in
17
+ * it carries a language. Pure.
18
+ */
19
+ export declare function languageConversation(history: DispatchHistorySnapshot | undefined, current?: string): LanguageConversation;
20
+ /**
21
+ * The language Baker should answer in, by English name ("Spanish"); undefined when Jev is unsure,
22
+ * or when the marketer's latest words read as another language.
23
+ */
24
+ export type ChatLanguage = (conversation: LanguageConversation) => Promise<string | undefined>;
25
+ /** The question on Jev, a Choice over every language. No answer is no language: never a guess. */
26
+ export declare function jevChatLanguage(choose: Chooser): ChatLanguage;
27
+ /**
28
+ * The language Baker answers this chat in. Once the marketer has written words that carry a
29
+ * language, the one Jev reads from the conversation, else the one a routine's run was told to
30
+ * report in; before that, the routine's, which Baker set and code reads for sure. Undefined when
31
+ * neither says. `prompt` is the turn's own message, which can be a routine's opening brief.
32
+ */
33
+ export declare function answerLanguage(language: ChatLanguage, history: DispatchHistorySnapshot | undefined, current?: string, prompt?: string): Promise<string | undefined>;
34
+ //# sourceMappingURL=chat-language.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-language.d.ts","sourceRoot":"","sources":["../../src/hono/chat-language.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,UAAU,CAAC;AAC3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AA0B1D,gGAAgG;AAChG,eAAO,MAAM,aAAa,MAAM,CAAC;AACjC,4GAA4G;AAC5G,eAAO,MAAM,gBAAgB,OAAQ,CAAC;AAoDtC,yGAAyG;AACzG,MAAM,MAAM,oBAAoB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAIvE;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,uBAAuB,GAAG,SAAS,EAC5C,OAAO,CAAC,EAAE,MAAM,GACf,oBAAoB,CAmBtB;AAED;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,YAAY,EAAE,oBAAoB,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAW/F,kGAAkG;AAClG,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,CAY7D;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,uBAAuB,GAAG,SAAS,EAC5C,OAAO,CAAC,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAa7B"}
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Which language Baker answers a chat's marketer in, decided by Jev (docs/decision-model.md,
3
+ * "Language identification"). Code does only what it knows for sure — whose words each message
4
+ * is, a command, quoted copy, a routine's set language — and Jev answers "which language should
5
+ * the next message be in?" over what is left, the latest words kept. An n-gram detector read
6
+ * Spanish typed without accents as Catalan, and the bridge told a Spanish chat's agent to write
7
+ * Catalan (BAKER-4943). Measured in `scripts/reply-language-evals`.
8
+ */
9
+ import { languageSample, ownWords, runReportLanguage, withoutQuoted } from "../review/reply-language.js";
10
+ const NAMES = new Intl.DisplayNames(["en"], { type: "language", fallback: "none" });
11
+ const LETTERS = "abcdefghijklmnopqrstuvwxyz";
12
+ /**
13
+ * Every language with a canonical ISO 639-1 code `Intl` can name, each name once: a hand-copy of
14
+ * `LANGUAGE_OPTIONS` in `packages/cli/src/engine/scaffold/lib/language.ts`, which the published
15
+ * bridge cannot import. Two "Romanian"s would split Jev's probability and neither would hold.
16
+ */
17
+ const LANGUAGE_OPTIONS = (() => {
18
+ const options = {};
19
+ const named = new Set();
20
+ for (const a of LETTERS) {
21
+ for (const b of LETTERS) {
22
+ const code = `${a}${b}`;
23
+ const name = NAMES.of(code);
24
+ if (!name || name.toLowerCase() === code || named.has(name))
25
+ continue;
26
+ if (Intl.getCanonicalLocales(code)[0] !== code)
27
+ continue;
28
+ named.add(name);
29
+ options[code] = name;
30
+ }
31
+ }
32
+ return options;
33
+ })();
34
+ /** At or above it, Jev's pick is named to the agent; below it, the language is left unnamed. */
35
+ export const LANGUAGE_HELD = 0.8;
36
+ /** The most of the conversation Jev reads, latest first: a few messages carry the language it is in now. */
37
+ export const CONVERSATION_MAX = 2_400;
38
+ /** The most of one message, from its end, so one long reply cannot crowd out the rest. */
39
+ const MESSAGE_MAX = 600;
40
+ /** The most of the marketer's own words Jev is asked about, from their end. */
41
+ const LINE_MAX = 1_200;
42
+ const ANSWER_QUESTION = "Which language should Baker's next message to the marketer be written in? The language the marketer writes in, unless they or a [baker] brief asked for the reports in another one. [baker] messages are Baker's own English templates: their English is not the marketer's choice, and neither is the language of text the marketer pastes for the work.";
43
+ const LINE_QUESTION = "Which language is `text` written in? When it mixes languages, the one most of its words are in. Names of products, pages and tools do not count.";
44
+ // A dashboard mention (`@[title](video:…?thumbnailUrl=…)`): the title is the page's words, not the marketer's.
45
+ const MENTION = /@\[[^\]]*\]\([^)\s]*\)/g;
46
+ // A skill command the marketer typed: its arguments are theirs, the command carries no language.
47
+ const COMMAND = /^\/[^\s/]+\s*([\s\S]*)$/;
48
+ // The history replays each tool call beside a reply as an English line the marketer never read.
49
+ const TOOL_LINE = /^\[(tool\]|\d+ earlier tool call)/;
50
+ /** The last `max` characters of `text`, from a word's start. Pure. */
51
+ function latest(text, max) {
52
+ if (text.length <= max)
53
+ return text;
54
+ const tail = text.slice(-max);
55
+ const start = tail.search(/\s\S/);
56
+ return start === -1 ? tail : tail.slice(start + 1);
57
+ }
58
+ const tidy = (text) => withoutQuoted(text.replace(MENTION, " ")).replace(/\s+/g, " ").trim();
59
+ /** One message as Jev reads it, with whose words it holds; undefined when it carries none. */
60
+ function line(entry) {
61
+ if (entry.role === "assistant") {
62
+ if (entry.subagent)
63
+ return undefined;
64
+ const said = tidy(entry.text
65
+ .split("\n")
66
+ .filter((row) => !TOOL_LINE.test(row.trim()))
67
+ .join("\n"));
68
+ return said ? { said: `[agent] ${latest(said, MESSAGE_MAX)}`, marketer: false } : undefined;
69
+ }
70
+ if (entry.role !== "user")
71
+ return undefined;
72
+ if (entry.bakerWritten) {
73
+ const brief = tidy(entry.text);
74
+ return brief ? { said: `[baker] ${latest(brief, MESSAGE_MAX)}`, marketer: false } : undefined;
75
+ }
76
+ // A kickoff Baker worded in their seat (a plan decision, "Fix this", a setup step) is theirs only in its notes.
77
+ const own = entry.typedText ?? ownWords(entry.text);
78
+ const typed = own?.trim().startsWith("/") ? COMMAND.exec(own.trim())?.[1] : own;
79
+ const said = typed === undefined ? "" : tidy(typed);
80
+ return said ? { said: `[marketer] ${latest(said, MESSAGE_MAX)}`, marketer: true } : undefined;
81
+ }
82
+ const MARKETER_LABEL = "[marketer] ";
83
+ /**
84
+ * The conversation Jev reads, oldest first, each message labelled by whose words it holds and
85
+ * cleaned of what carries no one's language; the latest `CONVERSATION_MAX` characters of it, and
86
+ * the marketer's latest message long enough to carry a language. `current` is what the marketer
87
+ * typed to start the turn running now, which the history leaves out. Empty text when nothing in
88
+ * it carries a language. Pure.
89
+ */
90
+ export function languageConversation(history, current) {
91
+ const entries = [
92
+ ...(history?.entries ?? []),
93
+ ...(current === undefined ? [] : [{ role: "user", text: current, createdAt: Number.POSITIVE_INFINITY }]),
94
+ ];
95
+ const lines = entries.flatMap((entry) => line(entry) ?? []);
96
+ const marketer = lines
97
+ .filter((read) => read.marketer)
98
+ .map((read) => read.said.slice(MARKETER_LABEL.length))
99
+ .filter((said) => languageSample(said) !== undefined)
100
+ .pop();
101
+ const kept = [];
102
+ for (let index = lines.length - 1, length = 0; index >= 0 && length < CONVERSATION_MAX; index--) {
103
+ const said = lines[index]?.said ?? "";
104
+ kept.unshift(said);
105
+ length += said.length;
106
+ }
107
+ const text = latest(kept.join("\n\n"), CONVERSATION_MAX);
108
+ return marketer === undefined ? { text } : { text, marketer };
109
+ }
110
+ const choice = (instructions) => ({
111
+ instructions,
112
+ criteria: { ...LANGUAGE_OPTIONS },
113
+ });
114
+ /** The language Jev picked, when it held its pick at `LANGUAGE_HELD` or more. */
115
+ const held = (pick) => pick && pick.probability >= LANGUAGE_HELD ? LANGUAGE_OPTIONS[pick.choice] : undefined;
116
+ /** The question on Jev, a Choice over every language. No answer is no language: never a guess. */
117
+ export function jevChatLanguage(choose) {
118
+ return async ({ text, marketer }) => {
119
+ if (!text)
120
+ return undefined;
121
+ // Unaccented Portuguese read as a Spanish chat at 0.86: their own words must read the same.
122
+ const sample = marketer === undefined ? undefined : languageSample(marketer);
123
+ const picks = await choose([
124
+ choice({ conversation: text, question: ANSWER_QUESTION }),
125
+ ...(sample === undefined ? [] : [choice({ text: latest(sample, LINE_MAX), question: LINE_QUESTION })]),
126
+ ]);
127
+ const answer = held(picks?.[0]);
128
+ return sample === undefined || held(picks?.[1]) === answer ? answer : undefined;
129
+ };
130
+ }
131
+ /**
132
+ * The language Baker answers this chat in. Once the marketer has written words that carry a
133
+ * language, the one Jev reads from the conversation, else the one a routine's run was told to
134
+ * report in; before that, the routine's, which Baker set and code reads for sure. Undefined when
135
+ * neither says. `prompt` is the turn's own message, which can be a routine's opening brief.
136
+ */
137
+ export async function answerLanguage(language, history, current, prompt) {
138
+ const configured = [
139
+ ...(history?.entries ?? []).filter((entry) => entry.role === "user").map((entry) => entry.text),
140
+ prompt ?? "",
141
+ ]
142
+ .map(runReportLanguage)
143
+ .filter(Boolean)
144
+ .pop();
145
+ const conversation = languageConversation(history, current);
146
+ const asked = () => language(conversation).catch(() => undefined);
147
+ // A marketer who replies to a routine in their own language is answered in it.
148
+ if (conversation.marketer !== undefined)
149
+ return (await asked()) ?? configured;
150
+ return configured ?? (await asked());
151
+ }
152
+ //# sourceMappingURL=chat-language.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-language.js","sourceRoot":"","sources":["../../src/hono/chat-language.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAIzG,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;AACpF,MAAM,OAAO,GAAG,4BAA4B,CAAC;AAE7C;;;;GAIG;AACH,MAAM,gBAAgB,GAAqC,CAAC,GAAG,EAAE;IAC/D,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;YACxB,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;YAC5B,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,SAAS;YACtE,IAAI,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI;gBAAE,SAAS;YACzD,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAChB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACvB,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC,EAAE,CAAC;AAEL,gGAAgG;AAChG,MAAM,CAAC,MAAM,aAAa,GAAG,GAA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 {"version":3,"file":"chat-language.test.d.ts","sourceRoot":"","sources":["../../src/hono/chat-language.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,136 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { answerLanguage, jevChatLanguage, languageConversation } from "./chat-language.js";
3
+ function history(entries) {
4
+ return {
5
+ entries: entries.map((entry, index) => ({ ...entry, createdAt: index })),
6
+ omittedEntryCount: 0,
7
+ truncated: false,
8
+ maxEntries: 50,
9
+ maxTextChars: 10_000,
10
+ renderedContext: "",
11
+ };
12
+ }
13
+ /** Jev, faked: question `n` answers `picks[n]`; every question asked is kept. */
14
+ function jev(...picks) {
15
+ const asked = [];
16
+ const choose = (questions) => {
17
+ asked.push(...questions);
18
+ return Promise.resolve(questions.map((_, index) => {
19
+ const [choice, probability] = picks[index] ?? picks[picks.length - 1] ?? ["en", 0];
20
+ return { choice, probability };
21
+ }));
22
+ };
23
+ return Object.assign(choose, { asked });
24
+ }
25
+ describe("languageConversation", () => {
26
+ // BAKER-4943: the marketer's unaccented Spanish, then `/publish`, which carries no language.
27
+ it("labels whose words each message holds and leaves a bare command out", () => {
28
+ const { text, marketer } = languageConversation(history([
29
+ { role: "user", text: "revisa de punta a punta. testea la landing tambien despues de publicar" },
30
+ { role: "assistant", text: "He revisado todo de punta a punta y está listo para publicar." },
31
+ { role: "user", text: "/publish" },
32
+ ]));
33
+ expect(text).toBe("[marketer] revisa de punta a punta. testea la landing tambien despues de publicar\n\n[agent] He revisado todo de punta a punta y está listo para publicar.");
34
+ expect(marketer).toBe("revisa de punta a punta. testea la landing tambien despues de publicar");
35
+ });
36
+ it("marks what Baker wrote in the marketer's seat as Baker's", () => {
37
+ const { text, marketer } = languageConversation(history([
38
+ { role: "user", text: "Prepárame un plan para la landing del webinar" },
39
+ { role: "user", text: "I approve the plan below. Plan mode is over.", bakerWritten: true },
40
+ ]));
41
+ expect(text).toContain("[baker] I approve the plan below.");
42
+ expect(marketer).toBe("Prepárame un plan para la landing del webinar");
43
+ });
44
+ // A setup step's kickoff is Baker's English around the team's notes.
45
+ it("keeps only the team's notes from a kickoff Baker worded in their seat", () => {
46
+ const kickoff = [
47
+ "Set up our brand.",
48
+ "We are still setting up, before we start working in the account together: change nothing outside Baker.",
49
+ "When this step needs branding, derive colors, fonts, logos, imagery, tone of voice and positioning from our website and public social profiles.",
50
+ "Our notes:\nTenemos una sola marca para todos los públicos y el tono es cercano y tranquilo.",
51
+ ].join("\n\n");
52
+ const { text } = languageConversation(history([{ role: "user", text: kickoff }]));
53
+ expect(text).toContain("Tenemos una sola marca");
54
+ expect(text).not.toContain("We are still setting up");
55
+ });
56
+ it("keeps a typed skill command's arguments, which are the marketer's", () => {
57
+ const { marketer } = languageConversation(undefined, "/creative-canvas-ads haz cuatro anuncios para la campaña");
58
+ expect(marketer).toBe("haz cuatro anuncios para la campaña");
59
+ });
60
+ it("leaves out copy the marketer quotes for a page", () => {
61
+ const { text } = languageConversation(history([{ role: "user", text: "Change the headline to 'Compra ahora y ahorra' and keep the rest" }]));
62
+ expect(text).not.toContain("Compra ahora");
63
+ });
64
+ it("leaves out the tool calls and a subagent's notes the history replays", () => {
65
+ const { text } = languageConversation(history([
66
+ { role: "assistant", text: "Voy a revisar la colección.\n[tool] Bash: baker knowledge collections → ok" },
67
+ { role: "assistant", text: "I found the pricing pages for all three competitors.", subagent: true },
68
+ ]));
69
+ expect(text).toBe("[agent] Voy a revisar la colección.");
70
+ });
71
+ it("keeps the latest of a long conversation", () => {
72
+ const old = {
73
+ role: "assistant",
74
+ text: "Reviso las campañas una a una antes de cambiar nada. ".repeat(20),
75
+ };
76
+ const { text } = languageConversation(history([...Array.from({ length: 10 }, () => old), { role: "user", text: "Ahora cambia el titular" }]));
77
+ expect(text.length).toBeLessThanOrEqual(2_400);
78
+ expect(text.endsWith("[marketer] Ahora cambia el titular")).toBe(true);
79
+ });
80
+ });
81
+ describe("jevChatLanguage", () => {
82
+ const spanishChat = {
83
+ text: "[marketer] revisa de punta a punta. testea la landing tambien despues de publicar",
84
+ marketer: "revisa de punta a punta. testea la landing tambien despues de publicar",
85
+ };
86
+ it("names the language Jev says to answer in, when the marketer's own words read the same", async () => {
87
+ expect(await jevChatLanguage(jev(["es", 0.96], ["es", 0.97]))(spanishChat)).toBe("Spanish");
88
+ });
89
+ // Unaccented Portuguese read as a Spanish chat at 0.86 while its words read as Portuguese.
90
+ it("names no language when the marketer's own words read as another one", async () => {
91
+ expect(await jevChatLanguage(jev(["es", 0.86], ["pt", 0.85]))(spanishChat)).toBeUndefined();
92
+ });
93
+ it("names no language Jev is unsure of", async () => {
94
+ expect(await jevChatLanguage(jev(["es", 0.6], ["es", 0.97]))(spanishChat)).toBeUndefined();
95
+ });
96
+ it("names nothing when Jev does not answer", async () => {
97
+ expect(await jevChatLanguage(() => Promise.resolve(null))(spanishChat)).toBeUndefined();
98
+ });
99
+ it("asks about only the latest of the marketer's own words", async () => {
100
+ const choose = jev(["es", 0.97], ["es", 0.97]);
101
+ const old = "Voy a revisar el esquema de la colección de ideas y luego escribir la nota. ".repeat(100);
102
+ await jevChatLanguage(choose)({
103
+ text: "[marketer] …",
104
+ marketer: `${old}\nHe revisado todo y está listo para publicar.`,
105
+ });
106
+ const asked = choose.asked[1]?.instructions.text ?? "";
107
+ expect(asked.length).toBeLessThanOrEqual(1_200);
108
+ expect(asked.endsWith("está listo para publicar")).toBe(true);
109
+ });
110
+ });
111
+ describe("answerLanguage", () => {
112
+ it("takes the language a routine's run was told to report in, without asking Jev", async () => {
113
+ const asked = [];
114
+ const language = ({ text }) => {
115
+ asked.push(text);
116
+ return Promise.resolve("English");
117
+ };
118
+ const kickoff = {
119
+ role: "user",
120
+ text: "Goal: check the forms.\n\n<run-guidance>\nWrite every message of this run — the lines while you work and the closing summary — in Dutch, as the brief asks; this note is in English only because Baker adds it.\n</run-guidance>",
121
+ bakerWritten: true,
122
+ };
123
+ expect(await answerLanguage(language, history([kickoff]))).toBe("Dutch");
124
+ expect(asked).toEqual([]);
125
+ });
126
+ it("answers in the language the marketer writes in once they reply to a routine set to report in another", async () => {
127
+ const language = () => Promise.resolve("Spanish");
128
+ const kickoff = {
129
+ role: "user",
130
+ text: "Goal: check the forms.\n\n<run-guidance>\nWrite every message of this run — the lines while you work and the closing summary — in English, as the brief asks; this note is in English only because Baker adds it.\n</run-guidance>",
131
+ bakerWritten: true,
132
+ };
133
+ expect(await answerLanguage(language, history([kickoff]), "¿Por qué ha fallado el formulario de contacto esta mañana?")).toBe("Spanish");
134
+ });
135
+ });
136
+ //# sourceMappingURL=chat-language.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-language.test.js","sourceRoot":"","sources":["../../src/hono/chat-language.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAqB,eAAe,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAI9G,SAAS,OAAO,CAAC,OAAuD;IACtE,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;QACxE,iBAAiB,EAAE,CAAC;QACpB,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,EAAE;QACd,YAAY,EAAE,MAAM;QACpB,eAAe,EAAE,EAAE;KACpB,CAAC;AACJ,CAAC;AAED,iFAAiF;AACjF,SAAS,GAAG,CAAC,GAAG,KAA8B;IAC5C,MAAM,KAAK,GAAwB,EAAE,CAAC;IACtC,MAAM,MAAM,GAAY,CAAC,SAAS,EAAE,EAAE;QACpC,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;QACzB,OAAO,OAAO,CAAC,OAAO,CACpB,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YACzB,MAAM,CAA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Q,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,4DAA4D,CAAC,CACjH,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -6,6 +6,20 @@ export type Judge = (questions: ReadonlyArray<JevQuestion>) => Promise<number[]
6
6
  export type JevQuestion = {
7
7
  instructions: Record<string, string>;
8
8
  };
9
+ /** One option of `criteria`, keyed by option; `instructions` holds the text and the question. */
10
+ export type JevChoiceQuestion = {
11
+ instructions: Record<string, string>;
12
+ criteria: Record<string, string>;
13
+ };
14
+ /** The option Jev picked and the probability it gave it. */
15
+ export type JevChoice = {
16
+ choice: string;
17
+ probability: number;
18
+ };
19
+ /** Asks each Choice in one request; the pick for each, or null when unanswered. */
20
+ export type Chooser = (questions: ReadonlyArray<JevChoiceQuestion>) => Promise<JevChoice[] | null>;
21
+ /** Each Choice's pick for `ids`, in order; null when the reply does not answer them all. Pure. */
22
+ export declare function readChoices(body: unknown, ids: readonly string[]): JevChoice[] | null;
9
23
  /** Each yes/no answer to `ids`, in order; null when the reply does not answer them all. Pure. */
10
24
  export declare function readNouls(body: unknown, ids: readonly string[]): number[] | null;
11
25
  /**
@@ -16,4 +30,6 @@ export declare function readNouls(body: unknown, ids: readonly string[]): number
16
30
  export declare const jevJudge: (key: string | undefined,
17
31
  /** Where the call comes from, for OpenRouter (`openrouter-attribution.ts`). */
18
32
  openRouterTags: RuntimeOpenRouterTags) => Judge;
33
+ /** A chooser on `key`: Jev's pick for each Choice, in order, or null when it could not answer. */
34
+ export declare const jevChooser: (key: string | undefined, openRouterTags: RuntimeOpenRouterTags) => Chooser;
19
35
  //# sourceMappingURL=jev.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jev.d.ts","sourceRoot":"","sources":["../../src/hono/jev.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEzE,oFAAo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W,EAAE,MAAM,CAAA;CAAE,CAAC;AAChE,mFAAmF;AACnF,MAAM,MAAM,OAAO,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,iBAAiB,CAAC,KAAK,OAAO,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;AAMnG,kGAAkG;AAClG,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAAE,GAAG,IAAI,CAUrF;AAsBD,iGAAiG;AACjG,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,IAAI,CAUhF;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,QAEZ,MAAM,GAAG,SAAS;AACvB,+EAA+E;gBAC/D,qBAAqB,KACpC,KAUF,CAAC;AAEJ,kGAAkG;AAClG,eAAO,MAAM,UAAU,QACf,MAAM,GAAG,SAAS,kBAAkB,qBAAqB,KAAG,OAYjE,CAAC"}
package/dist/hono/jev.js CHANGED
@@ -13,6 +13,40 @@ const ENDPOINT = "https://openrouter.ai/api/v1/systemone";
13
13
  /** Several times its p50 (about 0.3 s). The guards that call it hold a tool call while it answers. */
14
14
  const TIMEOUT_MS = 2_000;
15
15
  const Reply = z.object({ answers: z.record(z.string(), z.object({ noul: z.number() })) });
16
+ const ChoiceReply = z.object({
17
+ answers: z.record(z.string(), z.object({ choice: z.string(), probabilities: z.record(z.string(), z.number()) })),
18
+ });
19
+ /** Each Choice's pick for `ids`, in order; null when the reply does not answer them all. Pure. */
20
+ export function readChoices(body, ids) {
21
+ const parsed = ChoiceReply.safeParse(body);
22
+ if (!parsed.success)
23
+ return null;
24
+ const picks = [];
25
+ for (const id of ids) {
26
+ const answer = parsed.data.answers[id];
27
+ if (answer === undefined)
28
+ return null;
29
+ picks.push({ choice: answer.choice, probability: answer.probabilities[answer.choice] ?? 0 });
30
+ }
31
+ return picks;
32
+ }
33
+ /** Posts `questions` to Jev; the parsed reply's body, or null on no key, a timeout or an outage. */
34
+ async function ask(key, openRouterTags, questions) {
35
+ if (!key)
36
+ return null;
37
+ try {
38
+ const response = await fetch(ENDPOINT, {
39
+ method: "POST",
40
+ headers: { ...openRouterTags.headers, authorization: `Bearer ${key}`, "content-type": "application/json" },
41
+ body: JSON.stringify({ ...openRouterTags.fields, model: JEV_MODEL, state: {}, questions }),
42
+ signal: AbortSignal.timeout(TIMEOUT_MS),
43
+ });
44
+ return response.ok ? await response.json() : null;
45
+ }
46
+ catch {
47
+ return null;
48
+ }
49
+ }
16
50
  /** Each yes/no answer to `ids`, in order; null when the reply does not answer them all. Pure. */
17
51
  export function readNouls(body, ids) {
18
52
  const parsed = Reply.safeParse(body);
@@ -37,27 +71,16 @@ export const jevJudge = (key,
37
71
  openRouterTags) => async (questions) => {
38
72
  if (questions.length === 0)
39
73
  return [];
40
- if (!key)
41
- return null;
42
74
  const ids = questions.map((_, i) => `q${i}`);
43
- try {
44
- const response = await fetch(ENDPOINT, {
45
- method: "POST",
46
- headers: { ...openRouterTags.headers, authorization: `Bearer ${key}`, "content-type": "application/json" },
47
- body: JSON.stringify({
48
- ...openRouterTags.fields,
49
- model: JEV_MODEL,
50
- state: {},
51
- questions: Object.fromEntries(questions.map((q, i) => [ids[i], { type: "noul", instructions: q.instructions }])),
52
- }),
53
- signal: AbortSignal.timeout(TIMEOUT_MS),
54
- });
55
- if (!response.ok)
56
- return null;
57
- return readNouls(await response.json(), ids);
58
- }
59
- catch {
60
- return null;
61
- }
75
+ const body = await ask(key, openRouterTags, Object.fromEntries(questions.map((q, i) => [ids[i], { type: "noul", instructions: q.instructions }])));
76
+ return body === null ? null : readNouls(body, ids);
77
+ };
78
+ /** A chooser on `key`: Jev's pick for each Choice, in order, or null when it could not answer. */
79
+ export const jevChooser = (key, openRouterTags) => async (questions) => {
80
+ if (questions.length === 0)
81
+ return [];
82
+ const ids = questions.map((_, i) => `q${i}`);
83
+ const body = await ask(key, openRouterTags, Object.fromEntries(questions.map((q, i) => [ids[i], { type: "choice", instructions: q.instructions, criteria: q.criteria }])));
84
+ return body === null ? null : readChoices(body, ids);
62
85
  };
63
86
  //# sourceMappingURL=jev.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"jev.js","sourceRoot":"","sources":["../../src/hono/jev.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,oFAAoF;AACpF,MAAM,CAAC,MAAM,SAAS,GAAG,mBAAmB,CAAC;AAC7C,MAAM,QAAQ,GAAG,wCAAwC,CAAC;AAC1D,sGAAsG;AACtG,MAAM,UAAU,GAAG,KAAK,CAAC;AAMzB,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AAE1F,iGAAiG;AACjG,MAAM,UAAU,SAAS,CAAC,IAAa,EAAE,GAAsB;IAC7D,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IACjC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACrB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC;QAC3C,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;QACpC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,M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AAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,MAAM,GAAG,CACpB,GAAG,EACH,cAAc,EACd,MAAM,CAAC,WAAW,CAChB,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAC1G,CACF,CAAC;IACF,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACvD,CAAC,CAAC"}
@@ -7,9 +7,9 @@
7
7
  //
8
8
  // The blast radius is contained on two sides: the main thread runs at
9
9
  // `medium` effort (see `bridge-job.ts`), and the shared subagents pin their own
10
- // model in frontmatter rather than inheriting this: Sonnet 5.5 for the ones that
11
- // read and check, Opus 5.5 only for `creative-producer`, which writes the ad's
12
- // concept and copy. Without a pin every fan-out worker would follow the chat.
10
+ // model in frontmatter rather than inheriting this: Sonnet 5.5 by default, with
11
+ // the spawn router (`subagent-route.ts`) moving a brief that needs deep judgment
12
+ // up to Opus 5.5. Without a pin every fan-out worker would follow the chat.
13
13
  //
14
14
  // The Session review runs on the same id (`REVIEW_MODEL` in the backend's
15
15
  // `chatReview/constants.ts`); `scripts/review-model-parity.test.mjs` pins the pair.
@@ -1 +1 @@
1
- {"version":3,"file":"model-capabilities.js","sourceRoot":"","sources":["../../src/hono/model-capabilities.ts"],"names":[],"mappings":"AAEA,wFAAwF;AACxF,mFAAmF;AACnF,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAChF,gCAAgC;AAChC,EAAE;AACF,sEAAsE;AACtE,gFAAgF;AAChF,iFAAiF;AACjF,+EAA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CAAC,GAAG,GAAsB,OAAO,CAAC,GAAG;IACrE,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC;IACzC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AAClF,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,iBAAiB,CAAC,GAAG,GAAsB,OAAO,CAAC,GAAG;IACpE,OAAO,kBAAkB,CAAC,GAAG,CAAC,IAAI,aAAa,CAAC;AAClD,CAAC"}
1
+ {"version":3,"file":"model-capabilities.js","sourceRoot":"","sources":["../../src/hono/model-capabilities.ts"],"names":[],"mappings":"AAEA,wFAAwF;AACxF,mFAAmF;AACnF,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAChF,gCAAgC;AAChC,EAAE;AACF,sEAAsE;AACtE,gFAAgF;AAChF,gFAAgF;AAChF,iFAAiF;AACjF,4EAA4E;AAC5E,EAAE;AACF,0EAA0E;AAC1E,oFAAoF;AACpF,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAE/C,uFAAuF;AACvF,oFAAoF;AACpF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAEjD,8EAA8E;AAC9E,8EAA8E;AAC9E,6FAA6F;AAC7F,gBAAgB;AAChB,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AAEjD,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAClC,IAAI,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC;IAC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C;AAClD,CAAC"}
@@ -1,6 +1,3 @@
1
1
  /** Whether a non-empty `thinking` block from this model is a note for the user. */
2
2
  export declare function writesProgressNotes(model: unknown): boolean;
3
- export declare function progressNoteText(block: {
4
- thinking?: unknown;
5
- }, model: unknown): string | null;
6
3
  //# sourceMappingURL=progress-note.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"progress-note.d.ts","sourceRoot":"","sources":["../../src/hono/progress-note.ts"],"names":[],"mappings":"AAgBA,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE3D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAI7F"}
1
+ {"version":3,"file":"progress-note.d.ts","sourceRoot":"","sources":["../../src/hono/progress-note.ts"],"names":[],"mappings":"AAaA,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE3D"}
@@ -10,16 +10,8 @@
10
10
  * `progressNoteText`).
11
11
  */
12
12
  const PROGRESS_NOTE_MODEL = /(opus|sonnet)-5[.-]5/;
13
- /** What the API writes in place of a note the response was cut off before finishing. */
14
- const INTERRUPTED_PROGRESS_NOTE = "This part of the response was interrupted before it finished.";
15
13
  /** Whether a non-empty `thinking` block from this model is a note for the user. */
16
14
  export function writesProgressNotes(model) {
17
15
  return typeof model === "string" && PROGRESS_NOTE_MODEL.test(model);
18
16
  }
19
- export function progressNoteText(block, model) {
20
- if (!writesProgressNotes(model))
21
- return null;
22
- const text = typeof block.thinking === "string" ? block.thinking.trim() : "";
23
- return text && text !== INTERRUPTED_PROGRESS_NOTE ? text : null;
24
- }
25
17
  //# sourceMappingURL=progress-note.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"progress-note.js","sourceRoot":"","sources":["../../src/hono/progress-note.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AAEnD,wFAAwF;AACxF,MAAM,yBAAyB,GAAG,+DAA+D,CAAC;AAElG,mFAAmF;AACnF,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAA6B,EAAE,KAAc;IAC5E,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7C,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7E,OAAO,IAAI,IAAI,IAAI,KAAK,yBAAyB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAClE,CAAC"}
1
+ {"version":3,"file":"progress-note.js","sourceRoot":"","sources":["../../src/hono/progress-note.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AAEnD,mFAAmF;AACnF,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC"}
@@ -1,23 +1,12 @@
1
+ import { type ChatLanguage } from "./chat-language.ts";
1
2
  import type { DispatchHistorySnapshot, PublishStanding } from "./types.ts";
2
3
  /**
3
- * What the marketer last typed themselves, back to the first message long enough
4
- * to carry a language and far enough for it to be read, oldest first. A slash command (`/publish`) and a message
5
- * Baker wrote in their seat (a plan approval) carry none. `current` is what they
6
- * typed to start the turn running now, which the history leaves out.
4
+ * The language a publish run reports in, decided once from the chat's conversation
5
+ * (`chat-language.ts`). The run sees only `/publish`, so without a note it guessed, often English
6
+ * to a Spanish chat. The language is named, never anybody's words quoted: the run read a quoted
7
+ * message as feedback still owed and answered it (BAKER-3389). Nothing is said when Jev is unsure.
7
8
  */
8
- export declare function lastTypedMessages(history: DispatchHistorySnapshot | undefined, current?: string): {
9
- quoted: string;
10
- whole: string;
11
- }[];
12
- /**
13
- * The language a publish run reports in. CLAUDE.md says to write in the language
14
- * of the last message the marketer typed, and a run whose only user message is
15
- * `/publish` has none in view — so it guessed, often English to a Spanish chat.
16
- * The language is named, never their words quoted: the run sees nothing else of
17
- * the conversation, and read a quoted message as feedback still open or a
18
- * question still owed, then answered it in the closing line (BAKER-3389).
19
- */
20
- export declare function publishLanguageReminder(history: DispatchHistorySnapshot | undefined): string | undefined;
9
+ export declare function publishLanguageReminder(history: DispatchHistorySnapshot | undefined, language: ChatLanguage): Promise<string | undefined>;
21
10
  /**
22
11
  * What Publish told the user, when the last thing the user sent before this turn
23
12
  * was `/publish`. The chat resumes a session that never saw the run, so without
@@ -1 +1 @@
1
- {"version":3,"file":"publish-handoff.d.ts","sourceRoot":"","sources":["../../src/hono/publish-handoff.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA8B3E;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,uBAAuB,GAAG,SAAS,EAC5C,OAAO,CAAC,EAAE,MAAM,GACf;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CAmBrC;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,uBAAuB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAuBxG;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,uBAAuB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAoBnG;AAiDD;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