@koda-sl/baker-bridge 0.162.0 → 0.164.0-dev.d9feffe34

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 (35) hide show
  1. package/README.md +1 -0
  2. package/dist/hono/bridge-job.d.ts +2 -0
  3. package/dist/hono/bridge-job.d.ts.map +1 -1
  4. package/dist/hono/bridge-job.js +21 -2
  5. package/dist/hono/bridge-job.js.map +1 -1
  6. package/dist/hono/bridge-job.test.js +28 -1
  7. package/dist/hono/bridge-job.test.js.map +1 -1
  8. package/dist/hono/jev.d.ts +4 -1
  9. package/dist/hono/jev.d.ts.map +1 -1
  10. package/dist/hono/jev.js +5 -2
  11. package/dist/hono/jev.js.map +1 -1
  12. package/dist/hono/jev.test.js +2 -1
  13. package/dist/hono/jev.test.js.map +1 -1
  14. package/dist/hono/openrouter-attribution.d.ts +31 -0
  15. package/dist/hono/openrouter-attribution.d.ts.map +1 -0
  16. package/dist/hono/openrouter-attribution.js +70 -0
  17. package/dist/hono/openrouter-attribution.js.map +1 -0
  18. package/dist/hono/openrouter-attribution.test.d.ts +2 -0
  19. package/dist/hono/openrouter-attribution.test.d.ts.map +1 -0
  20. package/dist/hono/openrouter-attribution.test.js +48 -0
  21. package/dist/hono/openrouter-attribution.test.js.map +1 -0
  22. package/dist/hono/openrouter-session.d.ts +11 -5
  23. package/dist/hono/openrouter-session.d.ts.map +1 -1
  24. package/dist/hono/openrouter-session.js +9 -5
  25. package/dist/hono/openrouter-session.js.map +1 -1
  26. package/dist/hono/openrouter-session.test.js +9 -0
  27. package/dist/hono/openrouter-session.test.js.map +1 -1
  28. package/dist/hono/prompt-context.d.ts.map +1 -1
  29. package/dist/hono/prompt-context.js +4 -1
  30. package/dist/hono/prompt-context.js.map +1 -1
  31. package/dist/hono/prompt-context.test.js +9 -0
  32. package/dist/hono/prompt-context.test.js.map +1 -1
  33. package/dist/hono/types.d.ts +2 -0
  34. package/dist/hono/types.d.ts.map +1 -1
  35. package/package.json +1 -1
@@ -18,7 +18,7 @@ vi.mock("./runtime-files.ts", async (importOriginal) => {
18
18
  });
19
19
  import { AVATAR_CASTING_TOOL_NAME } from "./avatar-casting.js";
20
20
  import { FACE_PICK_QUESTION } from "./avatar-face-question.js";
21
- import { BridgeJobExecutor, createStallDetector, isContextOverflowRefusal, isControlChannelDeny, parsePlanDecision, remapAnswersToQuestionText, } from "./bridge-job.js";
21
+ import { agentFeature, BridgeJobExecutor, createStallDetector, isContextOverflowRefusal, isControlChannelDeny, parsePlanDecision, remapAnswersToQuestionText, } from "./bridge-job.js";
22
22
  import { CONNECTION_INPUT_TOOL_NAME } from "./connection-input.js";
23
23
  import { CREDENTIAL_INPUT_TOOL_NAME } from "./credential-input.js";
24
24
  import { FLOW_INPUT_TOOL_NAME } from "./flow-input.js";
@@ -1244,6 +1244,9 @@ describe("BridgeJobExecutor", () => {
1244
1244
  });
1245
1245
  it("propagates the inherited process env (OpenRouter routing) to the agent subprocess", async () => {
1246
1246
  vi.stubEnv("ANTHROPIC_AUTH_TOKEN", "sk-or-test-key");
1247
+ vi.stubEnv("BAKER_ENVIRONMENT", "production");
1248
+ vi.stubEnv("BAKER_RUNTIME_COMPANY_ID", "company_env");
1249
+ vi.stubEnv("BAKER_CHAT_ID", "chat_env");
1247
1250
  const queryInputs = [];
1248
1251
  const executor = createExecutor({
1249
1252
  queryInputs,
@@ -1265,8 +1268,25 @@ describe("BridgeJobExecutor", () => {
1265
1268
  allow_fallbacks: true,
1266
1269
  },
1267
1270
  session_id: "thread_env",
1271
+ user: "agent.turn | company:company_env | chat:chat_env",
1272
+ trace: {
1273
+ trace_name: "agent.turn",
1274
+ generation_name: "agent.turn",
1275
+ feature: "agent.turn",
1276
+ service: "agent",
1277
+ environment: "production",
1278
+ company_id: "company_env",
1279
+ chat_id: "chat_env",
1280
+ },
1268
1281
  plugins: [{ id: "web", enabled: false }],
1269
1282
  });
1283
+ // The same tag as headers, which is what names the app in OpenRouter.
1284
+ expect(env?.ANTHROPIC_CUSTOM_HEADERS).toBe([
1285
+ "HTTP-Referer: https://agent.production.withbaker.com",
1286
+ "X-OpenRouter-Title: Baker agent (production)",
1287
+ "X-Title: Baker agent (production)",
1288
+ "x-session-id: thread_env",
1289
+ ].join("\n"));
1270
1290
  });
1271
1291
  // OpenRouter has no Bedrock endpoint for a per-message effort, so while the CLI
1272
1292
  // sends one every Opus 5.5 request skips Bedrock and bills OpenRouter credits.
@@ -4966,4 +4986,11 @@ describe("BridgeJobExecutor model refusals", () => {
4966
4986
  expect(outcome).toMatchObject({ kind: "completed" });
4967
4987
  });
4968
4988
  });
4989
+ describe("agentFeature", () => {
4990
+ it("tells OpenRouter a Session review, a plan and a chat turn apart", () => {
4991
+ expect(agentFeature({ review: {} })).toBe("chatReview.session");
4992
+ expect(agentFeature({ planMode: true })).toBe("agent.plan");
4993
+ expect(agentFeature({})).toBe("agent.turn");
4994
+ });
4995
+ });
4969
4996
  //# sourceMappingURL=bridge-job.test.js.map