@koda-sl/baker-bridge 0.168.0-dev.d78500250 → 0.171.0-dev.289ff1b9d
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 +27 -18
- package/dist/hono/agent.d.ts.map +1 -1
- package/dist/hono/agent.js +3 -1
- package/dist/hono/agent.js.map +1 -1
- package/dist/hono/agent.test.js +2 -0
- package/dist/hono/agent.test.js.map +1 -1
- package/dist/hono/bridge-job.d.ts +17 -11
- package/dist/hono/bridge-job.d.ts.map +1 -1
- package/dist/hono/bridge-job.js +97 -49
- package/dist/hono/bridge-job.js.map +1 -1
- package/dist/hono/bridge-job.test.js +67 -7
- package/dist/hono/bridge-job.test.js.map +1 -1
- package/dist/hono/model-capabilities.d.ts +1 -0
- package/dist/hono/model-capabilities.d.ts.map +1 -1
- package/dist/hono/model-capabilities.js +4 -0
- package/dist/hono/model-capabilities.js.map +1 -1
- package/dist/hono/openrouter-session.d.ts +3 -0
- package/dist/hono/openrouter-session.d.ts.map +1 -1
- package/dist/hono/openrouter-session.js +3 -0
- package/dist/hono/openrouter-session.js.map +1 -1
- package/dist/hono/relay.d.ts +4 -4
- package/dist/hono/relay.d.ts.map +1 -1
- package/dist/hono/relay.js +1 -1
- package/dist/hono/relay.js.map +1 -1
- package/dist/hono/relay.test.js +10 -4
- package/dist/hono/relay.test.js.map +1 -1
- package/dist/hono/served-model.d.ts +8 -0
- package/dist/hono/served-model.d.ts.map +1 -1
- package/dist/hono/served-model.js +41 -0
- package/dist/hono/served-model.js.map +1 -1
- package/dist/hono/served-model.test.js +19 -1
- package/dist/hono/served-model.test.js.map +1 -1
- package/dist/hono/session-continuity.integration.test.js +2 -0
- package/dist/hono/session-continuity.integration.test.js.map +1 -1
- package/dist/hono/tool-result-ledger.d.ts +2 -0
- package/dist/hono/tool-result-ledger.d.ts.map +1 -1
- package/dist/hono/tool-result-ledger.js +12 -8
- package/dist/hono/tool-result-ledger.js.map +1 -1
- package/dist/hono/turn-route.d.ts +71 -0
- package/dist/hono/turn-route.d.ts.map +1 -0
- package/dist/hono/turn-route.js +112 -0
- package/dist/hono/turn-route.js.map +1 -0
- package/dist/hono/turn-route.test.d.ts +2 -0
- package/dist/hono/turn-route.test.d.ts.map +1 -0
- package/dist/hono/turn-route.test.js +134 -0
- package/dist/hono/turn-route.test.js.map +1 -0
- package/package.json +1 -1
- package/dist/hono/effort-route.d.ts +0 -43
- package/dist/hono/effort-route.d.ts.map +0 -1
- package/dist/hono/effort-route.js +0 -36
- package/dist/hono/effort-route.js.map +0 -1
- package/dist/hono/effort-route.test.d.ts +0 -2
- package/dist/hono/effort-route.test.d.ts.map +0 -1
- package/dist/hono/effort-route.test.js +0 -54
- package/dist/hono/effort-route.test.js.map +0 -1
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_TURN_EFFORT = "medium";
|
|
2
|
-
/** Jev's probability that the turn is small must be at least this… */
|
|
3
|
-
const LOW_EFFORT_MIN_SMALL = 0.75;
|
|
4
|
-
/** …and its probability that the turn needs judgment or several steps at most this. */
|
|
5
|
-
const LOW_EFFORT_MAX_COMPLEX = 0.3;
|
|
6
|
-
/** Text Jev reads, clipped: it sees 32k tokens, and the end of a reply is what the next message answers. */
|
|
7
|
-
const MAX_MESSAGE_CHARS = 3_000;
|
|
8
|
-
const MAX_REPLY_CHARS = 1_500;
|
|
9
|
-
const SMALL = "Read the agent's last reply `previous_reply` (empty when the chat just started) and the marketer's new `message`. Can the agent fully handle `message` with a short answer, a quick lookup of one thing, or one small change the marketer spelled out — with no new or rebuilt page, ad creative, campaign, form, report, document, audit, research or plan?";
|
|
10
|
-
const COMPLEX = "Read the agent's last reply `previous_reply` (empty when the chat just started) and the marketer's new `message`. Does `message` ask for, or say yes to, work that needs judgment or several steps — building or changing a page, ad, campaign, form, report or document; diagnosing why results are poor; research; or a plan or strategy? A short 'yes', 'go ahead' or 'do it' approving something `previous_reply` proposed counts as asking for that work.";
|
|
11
|
-
function questionsFor(message, previousReply) {
|
|
12
|
-
const context = {
|
|
13
|
-
previous_reply: previousReply.slice(-MAX_REPLY_CHARS),
|
|
14
|
-
message: message.slice(0, MAX_MESSAGE_CHARS),
|
|
15
|
-
};
|
|
16
|
-
return [{ instructions: { question: SMALL, ...context } }, { instructions: { question: COMPLEX, ...context } }];
|
|
17
|
-
}
|
|
18
|
-
export async function decideTurnEffort({ message, previousReply, judge, planMode = false, leadingCommand = false, unattended = false, hasAttachments = false, }) {
|
|
19
|
-
if (planMode)
|
|
20
|
-
return { effort: DEFAULT_TURN_EFFORT, reason: "plan" };
|
|
21
|
-
if (leadingCommand)
|
|
22
|
-
return { effort: DEFAULT_TURN_EFFORT, reason: "command" };
|
|
23
|
-
if (unattended)
|
|
24
|
-
return { effort: DEFAULT_TURN_EFFORT, reason: "unattended" };
|
|
25
|
-
if (hasAttachments)
|
|
26
|
-
return { effort: DEFAULT_TURN_EFFORT, reason: "attachments" };
|
|
27
|
-
const answers = await judge(questionsFor(message, previousReply));
|
|
28
|
-
const [small, complex] = answers ?? [];
|
|
29
|
-
if (small === undefined || complex === undefined) {
|
|
30
|
-
return { effort: DEFAULT_TURN_EFFORT, reason: "unjudged" };
|
|
31
|
-
}
|
|
32
|
-
return small >= LOW_EFFORT_MIN_SMALL && complex <= LOW_EFFORT_MAX_COMPLEX
|
|
33
|
-
? { effort: "low", reason: "small", small, complex }
|
|
34
|
-
: { effort: DEFAULT_TURN_EFFORT, reason: "not_small", small, complex };
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=effort-route.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effort-route.js","sourceRoot":"","sources":["../../src/hono/effort-route.ts"],"names":[],"mappings":"AAyBA,MAAM,CAAC,MAAM,mBAAmB,GAAa,QAAQ,CAAC;AAEtD,sEAAsE;AACtE,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,uFAAuF;AACvF,MAAM,sBAAsB,GAAG,GAAG,CAAC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,KAAK,EAAE,OAAO,CAAC,GAAG,OAAO,IAAI,EAAE,CAAC;IACvC,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACjD,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAC7D,CAAC;IACD,OAAO,KAAK,IAAI,oBAAoB,IAAI,OAAO,IAAI,sBAAsB;QACvE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;QACpD,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC3E,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effort-route.test.d.ts","sourceRoot":"","sources":["../../src/hono/effort-route.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { decideTurnEffort } from "./effort-route.js";
|
|
3
|
-
function judgeAnswering(small, complex, asked = []) {
|
|
4
|
-
return async (questions) => {
|
|
5
|
-
asked.push([...questions]);
|
|
6
|
-
return [small, complex];
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
const turn = { message: "¿Cuál fue el CPL de ayer?", previousReply: "Listo, he revisado la campaña." };
|
|
10
|
-
describe("decideTurnEffort", () => {
|
|
11
|
-
it("runs a turn Jev clearly reads as small at low effort", async () => {
|
|
12
|
-
expect(await decideTurnEffort({ ...turn, judge: judgeAnswering(0.9, 0.1) })).toEqual({
|
|
13
|
-
effort: "low",
|
|
14
|
-
reason: "small",
|
|
15
|
-
small: 0.9,
|
|
16
|
-
complex: 0.1,
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
it("keeps medium when the turn might need judgment or several steps", async () => {
|
|
20
|
-
expect(await decideTurnEffort({ ...turn, judge: judgeAnswering(0.8, 0.45) })).toEqual({
|
|
21
|
-
effort: "medium",
|
|
22
|
-
reason: "not_small",
|
|
23
|
-
small: 0.8,
|
|
24
|
-
complex: 0.45,
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
it("keeps medium when Jev cannot answer", async () => {
|
|
28
|
-
expect(await decideTurnEffort({ ...turn, judge: async () => null })).toEqual({
|
|
29
|
-
effort: "medium",
|
|
30
|
-
reason: "unjudged",
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
// A "sí, hazlo" is short, but it approves whatever the last reply proposed.
|
|
34
|
-
it("asks about the message together with the agent's last reply", async () => {
|
|
35
|
-
const asked = [];
|
|
36
|
-
await decideTurnEffort({ ...turn, judge: judgeAnswering(0.9, 0.1, asked) });
|
|
37
|
-
expect(asked[0]).toHaveLength(2);
|
|
38
|
-
for (const question of asked[0] ?? []) {
|
|
39
|
-
expect(question.instructions).toMatchObject({ message: turn.message, previous_reply: turn.previousReply });
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
it.each([
|
|
43
|
-
["plan mode", { planMode: true }, "plan"],
|
|
44
|
-
["a leading command", { leadingCommand: true }, "command"],
|
|
45
|
-
["an unattended run", { unattended: true }, "unattended"],
|
|
46
|
-
["attachments", { hasAttachments: true }, "attachments"],
|
|
47
|
-
])("keeps medium without asking for %s", async (_label, flags, reason) => {
|
|
48
|
-
const asked = [];
|
|
49
|
-
const decision = await decideTurnEffort({ ...turn, ...flags, judge: judgeAnswering(0.99, 0, asked) });
|
|
50
|
-
expect(decision).toEqual({ effort: "medium", reason });
|
|
51
|
-
expect(asked).toHaveLength(0);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
//# sourceMappingURL=effort-route.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effort-route.test.js","sourceRoot":"","sources":["../../src/hono/effort-route.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE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