@koda-sl/baker-bridge 0.92.2-dev.bb28562ac → 0.92.3-dev.bb28562ac

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.
@@ -17,6 +17,22 @@ export type AvatarCastingRequest = {
17
17
  };
18
18
  /** `canUseTool` sees RAW model input; a leading `@` is tolerated because that is how the handle reads. */
19
19
  export declare function normalizeAvatarCastingToolInput(input: unknown): AvatarCastingRequest | null;
20
+ /**
21
+ * What the agent reads when the picker closes.
22
+ *
23
+ * A decline used to come back as the bare `{"status":"declined"}` object, and the
24
+ * remedy for it lived only in the tool description — thousands of tokens up the
25
+ * context, written before the turn began. Measured on a real session, the agent read
26
+ * that object and replied "the casting portraits should be showing on your screen
27
+ * right now — just pick the one that looks right", to a user who had just rejected
28
+ * all four and whose picker was gone. That is a dead end: the avatar has no face, the
29
+ * turn is over, and the only instruction on screen cannot be followed.
30
+ *
31
+ * So the remedy travels with the result. Same reasoning as a CLI `error.fix`: a
32
+ * failure the agent has to act on carries its own next step, rather than relying on
33
+ * it remembering one.
34
+ */
35
+ export declare function avatarCastingToolText(resolution: unknown): string;
20
36
  export declare function createAvatarCastingTool(): import("@anthropic-ai/claude-agent-sdk").SdkMcpToolDefinition<{
21
37
  avatarHandle: z.ZodString;
22
38
  resolution: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -1 +1 @@
1
- {"version":3,"file":"avatar-casting.d.ts","sourceRoot":"","sources":["../../src/hono/avatar-casting.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,wBAAwB,0CAA0C,CAAC;AAahF,eAAO,MAAM,yBAAyB;;;;;;;;6BAGpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,sFAAsF;AACtF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,GAAG,IAAI,CAGnF;AAED,MAAM,MAAM,oBAAoB,GAAG;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5D,0GAA0G;AAC1G,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,GAAG,IAAI,CAU3F;AAUD,wBAAgB,uBAAuB;;;GAUtC"}
1
+ {"version":3,"file":"avatar-casting.d.ts","sourceRoot":"","sources":["../../src/hono/avatar-casting.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,wBAAwB,0CAA0C,CAAC;AAahF,eAAO,MAAM,yBAAyB;;;;;;;;6BAGpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,sFAAsF;AACtF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,GAAG,IAAI,CAGnF;AAED,MAAM,MAAM,oBAAoB,GAAG;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5D,0GAA0G;AAC1G,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,GAAG,IAAI,CAU3F;AAUD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,OAAO,GAAG,MAAM,CAgBjE;AAED,wBAAgB,uBAAuB;;;GAUtC"}
@@ -50,10 +50,41 @@ const AVATAR_CASTING_TOOL_DESCRIPTION = [
50
50
  "Not for an avatar built from photographs of a real person: that face already exists and there is nothing to choose between.",
51
51
  "You cannot see the candidates and must not choose for the user. If they decline them all, sharpen the subject description with `baker avatars update` and call it again.",
52
52
  ].join(" ");
53
+ /**
54
+ * What the agent reads when the picker closes.
55
+ *
56
+ * A decline used to come back as the bare `{"status":"declined"}` object, and the
57
+ * remedy for it lived only in the tool description — thousands of tokens up the
58
+ * context, written before the turn began. Measured on a real session, the agent read
59
+ * that object and replied "the casting portraits should be showing on your screen
60
+ * right now — just pick the one that looks right", to a user who had just rejected
61
+ * all four and whose picker was gone. That is a dead end: the avatar has no face, the
62
+ * turn is over, and the only instruction on screen cannot be followed.
63
+ *
64
+ * So the remedy travels with the result. Same reasoning as a CLI `error.fix`: a
65
+ * failure the agent has to act on carries its own next step, rather than relying on
66
+ * it remembering one.
67
+ */
68
+ export function avatarCastingToolText(resolution) {
69
+ const payload = JSON.stringify(resolution);
70
+ const parsed = avatarCastingResultSchema.safeParse(resolution);
71
+ if (!parsed.success || parsed.data.status !== "declined") {
72
+ return payload;
73
+ }
74
+ const { avatarHandle, reason } = parsed.data;
75
+ return [
76
+ payload,
77
+ "",
78
+ `The user turned down every casting portrait for @${avatarHandle}${reason ? `: ${reason}` : "."}`,
79
+ "The picker is gone from their screen — asking them to pick one of those faces is a dead end, and so is saying the avatar is waiting on them.",
80
+ `Sharpen the look with \`baker avatars update --handle ${avatarHandle} --subject "..."\` using whatever they said was wrong, then call request_avatar_casting again for the same handle.`,
81
+ "If they gave no reason, ask them what to change before recasting — do not spend another round guessing.",
82
+ ].join("\n");
83
+ }
53
84
  export function createAvatarCastingTool() {
54
85
  return tool("request_avatar_casting", AVATAR_CASTING_TOOL_DESCRIPTION, avatarCastingToolShape, (args) => {
55
86
  const resolution = args.resolution ?? { status: "declined" };
56
- return Promise.resolve({ content: [{ type: "text", text: JSON.stringify(resolution) }] });
87
+ return Promise.resolve({ content: [{ type: "text", text: avatarCastingToolText(resolution) }] });
57
88
  });
58
89
  }
59
90
  //# sourceMappingURL=avatar-casting.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"avatar-casting.js","sourceRoot":"","sources":["../../src/hono/avatar-casting.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,K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AAU,EAAE,CAAC;QAC7D,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACnG,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=avatar-casting.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar-casting.test.d.ts","sourceRoot":"","sources":["../../src/hono/avatar-casting.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { avatarCastingToolText } from "./avatar-casting.js";
3
+ describe("avatarCastingToolText", () => {
4
+ it("tells the agent to recast rather than to ask again for a picker that is gone", () => {
5
+ const text = avatarCastingToolText({ status: "declined", avatarHandle: "marcos" });
6
+ expect(text).toContain('"status":"declined"');
7
+ expect(text).toContain("baker avatars update");
8
+ expect(text).toContain("request_avatar_casting");
9
+ expect(text).toContain("marcos");
10
+ });
11
+ it("carries the reason the faces were turned down so the next round can use it", () => {
12
+ const text = avatarCastingToolText({
13
+ status: "declined",
14
+ avatarHandle: "marcos",
15
+ reason: "all four looked too young",
16
+ });
17
+ expect(text).toContain("all four looked too young");
18
+ });
19
+ it("says nothing extra once a face has been cast", () => {
20
+ const text = avatarCastingToolText({ status: "cast", avatarHandle: "marcos", imageId: "img_1" });
21
+ expect(text).toBe(JSON.stringify({ status: "cast", avatarHandle: "marcos", imageId: "img_1" }));
22
+ });
23
+ });
24
+ //# sourceMappingURL=avatar-casting.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar-casting.test.js","sourceRoot":"","sources":["../../src/hono/avatar-casting.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,qBAAq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2
2
  "name": "@koda-sl/baker-bridge",
3
- "version": "0.92.2-dev.bb28562ac",
3
+ "version": "0.92.3-dev.bb28562ac",
4
4
  "description": "HTTP server wrapping the Claude Agent SDK. Persists chat events to Convex; the dashboard subscribes via Convex realtime",
5
5
  "license": "MIT",
6
6
  "type": "module",