@yagni-app/code-staging 0.2.0-staging.1025.1 → 0.2.0-staging.1026.1

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.
@@ -27,14 +27,6 @@ export type HeaderMap = Record<string, string | undefined>;
27
27
  * can honestly claim).
28
28
  */
29
29
  export declare function parseReroute(headers: HeaderMap): Reroute | null;
30
- /**
31
- * Dedupe wrapper around {@link parseReroute}: `observe` returns the notice
32
- * message at most once per distinct from->to pair for the life of the
33
- * instance (i.e. per session), and null otherwise (absent, malformed, or
34
- * already-seen). Returning the message rather than taking a notify callback
35
- * keeps the caller in charge of the ctx it has on hand at call time, instead
36
- * of this class holding a stale reference across calls.
37
- */
38
30
  export declare class RerouteNotifier {
39
31
  private readonly seen;
40
32
  observe(headers: HeaderMap): string | null;
@@ -40,6 +40,13 @@ export function parseReroute(headers) {
40
40
  * keeps the caller in charge of the ctx it has on hand at call time, instead
41
41
  * of this class holding a stale reference across calls.
42
42
  */
43
+ /**
44
+ * The concrete tier ladder cheapest-first, mirroring the proxy's
45
+ * VISION_REROUTE_LADDER (yagniCodeV1.ts). Used only to tell an upgrade
46
+ * reroute from a downgrade so the "Billed as" clause names the tier the
47
+ * proxy actually bills.
48
+ */
49
+ const TIER_LADDER = ["efficient", "standard", "advanced", "peak"];
43
50
  export class RerouteNotifier {
44
51
  seen = new Set();
45
52
  observe(headers) {
@@ -54,13 +61,18 @@ export class RerouteNotifier {
54
61
  // assertBillableTier throws if it ever reaches pricing) — for a balanced
55
62
  // reroute the bill IS the resolved tier (`reroute.to`; yagniCodeV1.ts's
56
63
  // `billedTier` takes its `effectiveModel` arm here), so a "Billed as
57
- // balanced" clause would name a non-price. Only a CONCRETE from-tier
58
- // still bills at its own pre-reroute rate (Task 3's invariant: a re-route
59
- // never moves anyone's price), so only then is a distinct "Billed as X"
60
- // line honest.
64
+ // balanced" clause would name a non-price.
61
65
  if (reroute.from === "balanced") {
62
66
  return `Your image was handled on the ${reroute.to} tier.`;
63
67
  }
68
+ // Concrete tiers bill the CHEAPER of requested and served (yagniCodeV1.ts's
69
+ // billedTier): an UPGRADE still bills the pre-reroute tier, so a distinct
70
+ // "Billed as X" line is honest; a DOWNGRADE bills the served tier, where
71
+ // that clause would name a price the proxy did not charge.
72
+ const downgraded = TIER_LADDER.indexOf(reroute.to) < TIER_LADDER.indexOf(reroute.from);
73
+ if (downgraded) {
74
+ return `Your image was handled on the ${reroute.to} tier. Billed as ${reroute.to}.`;
75
+ }
64
76
  return `Your image was handled on the ${reroute.to} tier. Billed as ${reroute.from}.`;
65
77
  }
66
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yagni-app/code-staging",
3
- "version": "0.2.0-staging.1025.1",
3
+ "version": "0.2.0-staging.1026.1",
4
4
  "description": "YAGNI Code: a terminal coding agent that already knows your company. One YAGNI login routes the model and grounds the agent in your team's context.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "YAGNI, Inc. <jack@yagni.app> (https://yagni.app)",
@@ -38,5 +38,5 @@
38
38
  "@earendil-works/pi-tui": "0.83.0",
39
39
  "typebox": "^1.1.38"
40
40
  },
41
- "yagniSourceSha": "ad43200e08a990ead4d891e469d4b88e338b070a"
41
+ "yagniSourceSha": "c35ebbf707db0a8b9aee87f10a12e922221581b8"
42
42
  }