claudish 14.7.0 → 14.9.0

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 (2) hide show
  1. package/dist/index.js +111 -35
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -5398,7 +5398,7 @@ var init_onepassword_config = __esm(() => {
5398
5398
  });
5399
5399
 
5400
5400
  // src/version.ts
5401
- var VERSION = "14.7.0";
5401
+ var VERSION = "14.9.0";
5402
5402
 
5403
5403
  // src/redact.ts
5404
5404
  function isPlaceholder(value) {
@@ -16042,7 +16042,7 @@ var init_minimax_model_dialect = __esm(() => {
16042
16042
  });
16043
16043
 
16044
16044
  // src/auth/accounts/allowance-report-schema.ts
16045
- var ALLOWANCE_REPORT_SCHEMA = "claudish.allowance.v1", iso, fraction, finite, nonNegative, quantilesOf = (t) => object({ p10: t, p25: t, p50: t, p75: t, p90: t }), alertLevel, strategyName, evidence, unit, provenance, semantics, gapKind, exactness, accountSchema, remedySchema, alertSchema, historyPoint, trajectorySchema, sessionSchema, allowanceReportSchema, ALLOWANCE_REPORT_SECTIONS, partialReport, allowanceStatusAnswerSchema;
16045
+ var ALLOWANCE_REPORT_SCHEMA = "claudish.allowance.v1", iso, fraction, finite, nonNegative, quantilesOf = (t) => object({ p10: t, p25: t, p50: t, p75: t, p90: t }), alertLevel, strategyName, evidence, unit, provenance, semantics, gapKind, exactness, accountSchema, remedySchema, alertSchema, historyPoint, switchSchema, blockedSchema, trajectorySchema, sessionSchema, allowanceReportSchema, ALLOWANCE_REPORT_SECTIONS, partialReport, allowanceStatusAnswerSchema;
16046
16046
  var init_allowance_report_schema = __esm(() => {
16047
16047
  init_zod();
16048
16048
  iso = exports_iso.datetime({ offset: true });
@@ -16101,19 +16101,31 @@ var init_allowance_report_schema = __esm(() => {
16101
16101
  remaining: finite,
16102
16102
  provenance: _enum(["observed", "reset-inferred"])
16103
16103
  });
16104
+ switchSchema = object({
16105
+ accountId: string2(),
16106
+ soonest: iso,
16107
+ usual: iso,
16108
+ latest: iso,
16109
+ probability: fraction,
16110
+ likelihood: object({
16111
+ start: iso,
16112
+ stepHours: literal(1),
16113
+ p: array(number2().min(0).max(1)).min(1)
16114
+ }).optional()
16115
+ });
16116
+ blockedSchema = object({ from: iso, to: iso, kind: gapKind, probability: fraction });
16104
16117
  trajectorySchema = object({
16105
16118
  history: array(historyPoint),
16106
16119
  historyByAccount: array(object({ accountId: string2(), history: array(historyPoint) })).optional(),
16107
16120
  forecast: array(object({ at: iso, p10: finite, p50: finite, p90: finite, pBlocked: fraction })),
16108
16121
  resets: array(object({ at: iso, account: string2(), window: string2(), projected: boolean2() })),
16109
- blocked: array(object({ from: iso, to: iso, kind: gapKind, probability: fraction })),
16110
- switches: array(object({
16111
- accountId: string2(),
16112
- soonest: iso,
16113
- usual: iso,
16114
- latest: iso,
16115
- probability: fraction
16116
- })).optional(),
16122
+ blocked: array(blockedSchema),
16123
+ switches: array(switchSchema).optional(),
16124
+ slower: object({
16125
+ factor: number2().gt(0).lt(1),
16126
+ switches: array(switchSchema),
16127
+ blocked: array(blockedSchema)
16128
+ }).optional(),
16117
16129
  spark48: string2().regex(/^[\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588\u2592\u2593\u250A ]*$/u)
16118
16130
  });
16119
16131
  sessionSchema = object({
@@ -16646,7 +16658,7 @@ function cuOf(tokens, cfg) {
16646
16658
  const uncached = Math.max(0, tokens.input - tokens.cacheRead - tokens.cacheWrite);
16647
16659
  return uncached + w.cacheRead * tokens.cacheRead + w.cacheWrite * tokens.cacheWrite + w.output * tokens.output;
16648
16660
  }
16649
- var PROVIDER_COST_PRIORS, MINUTE_MS2 = 60000, HOUR_MS2, DEFAULT_ALLOWANCE_CONFIG, LOOKAHEAD_TRAJ_PATHS = 40, MIN_PATH_SHARE = 0.1, PACE_MAX_MULT = 64, PACE_BISECT_STEPS = 4;
16661
+ var PROVIDER_COST_PRIORS, MINUTE_MS2 = 60000, HOUR_MS2, DEFAULT_ALLOWANCE_CONFIG, LOOKAHEAD_TRAJ_PATHS = 40, MIN_PATH_SHARE = 0.1, SLOWER_FACTOR, PACE_MAX_MULT = 64, PACE_BISECT_STEPS = 4;
16650
16662
  var init_constants = __esm(() => {
16651
16663
  PROVIDER_COST_PRIORS = {
16652
16664
  "openai-codex": { cacheRead: 0.1, cacheWrite: 1, output: 4 },
@@ -16709,6 +16721,7 @@ var init_constants = __esm(() => {
16709
16721
  SESSION_TTL_D: 8,
16710
16722
  SESSIONS_MAX: 2048
16711
16723
  };
16724
+ SLOWER_FACTOR = 2 / 3;
16712
16725
  });
16713
16726
 
16714
16727
  // src/auth/accounts/allowance/capacity.ts
@@ -19955,6 +19968,32 @@ function firstTakeovers(r, from, now, end) {
19955
19968
  }
19956
19969
  return taken;
19957
19970
  }
19971
+ function likelihoodOf(times, q, h0, hours) {
19972
+ const x = times.map((t) => (t - h0) / HOUR_MS14);
19973
+ const n = x.length;
19974
+ const mean = x.reduce((a, b) => a + b, 0) / Math.max(1, n);
19975
+ const sd = Math.sqrt(x.reduce((a, b) => a + (b - mean) ** 2, 0) / Math.max(1, n - 1));
19976
+ const iqr = (q.p75 - q.p25) / HOUR_MS14 / 1.34;
19977
+ const spread = iqr > 0 ? Math.min(sd, iqr) : 0;
19978
+ const bandwidth = 0.9 * spread * n ** -0.2;
19979
+ const p = new Array(Math.max(0, hours)).fill(0);
19980
+ if (bandwidth < MIN_BANDWIDTH_H) {
19981
+ for (const xi of x) {
19982
+ const i = Math.floor(xi);
19983
+ if (i >= 0 && i < p.length)
19984
+ p[i] = (p[i] ?? 0) + 1;
19985
+ }
19986
+ } else {
19987
+ for (let i = 0;i < p.length; i++) {
19988
+ let f = 0;
19989
+ for (const xi of x)
19990
+ f += Math.exp(-0.5 * ((i + 0.5 - xi) / bandwidth) ** 2);
19991
+ p[i] = f;
19992
+ }
19993
+ }
19994
+ const peak = Math.max(0, ...p);
19995
+ return peak > 0 ? p.map((v) => v / peak) : p;
19996
+ }
19958
19997
  function switchesOf2(results, views, poolActive, now, end) {
19959
19998
  const order = new Map(views.map((v, i) => [v.account, i]));
19960
19999
  const from = poolActive !== null && order.has(poolActive) ? poolActive : null;
@@ -19967,12 +20006,20 @@ function switchesOf2(results, views, poolActive, now, end) {
19967
20006
  }
19968
20007
  }
19969
20008
  const paths = Math.max(1, results.length);
20009
+ const h0 = hourStart(now);
20010
+ const hours = Math.floor((end - h0) / HOUR_MS14) + 1;
19970
20011
  const out = [];
19971
20012
  for (const [account, list] of times) {
19972
20013
  const probability = list.length / paths;
19973
20014
  if (probability < MIN_PATH_SHARE)
19974
20015
  continue;
19975
- out.push({ account, q: quantilesOf2(list), probability: Math.min(1, probability) });
20016
+ const q = quantilesOf2(list);
20017
+ out.push({
20018
+ account,
20019
+ q,
20020
+ probability: Math.min(1, probability),
20021
+ likelihood: { start: h0, p: likelihoodOf(list, q, h0, hours) }
20022
+ });
19976
20023
  }
19977
20024
  return out.sort((a, b) => a.q.p50 - b.q.p50 || (order.get(a.account) ?? 0) - (order.get(b.account) ?? 0));
19978
20025
  }
@@ -20010,7 +20057,8 @@ function trajectory(s, now, horizonMs, cal, cfg) {
20010
20057
  blocked: [],
20011
20058
  switches: [],
20012
20059
  lostAtReset: {},
20013
- historyByAccount
20060
+ historyByAccount,
20061
+ slower: { factor: SLOWER_FACTOR, switches: [], blocked: [] }
20014
20062
  };
20015
20063
  if (evidenceOf(s, now) === "none" || all.length === 0)
20016
20064
  return empty;
@@ -20023,19 +20071,23 @@ function trajectory(s, now, horizonMs, cal, cfg) {
20023
20071
  const alertCfg = alertModelConfig(cfg);
20024
20072
  const paths = trajPaths(alertCfg);
20025
20073
  const results = [];
20074
+ const slowerResults = [];
20075
+ const run = (drawn, demand) => simulate(drawn, demand, cfg, {
20076
+ now,
20077
+ strategy: STRATEGIES[alertCfg.strategy],
20078
+ thread: { account: null, lastSwitchAt: null, contextTokens: null },
20079
+ poolActive: s.poolActive ?? null,
20080
+ horizonMs
20081
+ });
20026
20082
  for (let p = 0;p < paths; p++) {
20027
20083
  const demand = sampleDemandPath(model, rng);
20028
20084
  const drawn = views.map((v) => drawCapacity(v, rng));
20029
- results.push(simulate(drawn, demand, cfg, {
20030
- now,
20031
- strategy: STRATEGIES[alertCfg.strategy],
20032
- thread: { account: null, lastSwitchAt: null, contextTokens: null },
20033
- poolActive: s.poolActive ?? null,
20034
- horizonMs
20035
- }));
20085
+ results.push(run(drawn, demand));
20086
+ slowerResults.push(run(drawn, demand.map((d) => d * SLOWER_FACTOR)));
20036
20087
  }
20037
20088
  const h0 = hourStart(now);
20038
20089
  const forecast = [];
20090
+ const slowerForecast = [];
20039
20091
  for (let k = 0;k < buckets; k++) {
20040
20092
  const at = h0 + k * HOUR_MS14;
20041
20093
  if (at > end)
@@ -20048,6 +20100,8 @@ function trajectory(s, now, horizonMs, cal, cfg) {
20048
20100
  blocked++;
20049
20101
  }
20050
20102
  forecast.push({ at, q: quantilesOf2(values), pBlocked: blocked / paths });
20103
+ const slowerBlocked = slowerResults.filter((r) => r.blocked[k]?.blocked).length;
20104
+ slowerForecast.push({ at, q: forecast[k].q, pBlocked: slowerBlocked / paths });
20051
20105
  }
20052
20106
  return {
20053
20107
  unit,
@@ -20057,7 +20111,12 @@ function trajectory(s, now, horizonMs, cal, cfg) {
20057
20111
  blocked: blockedRuns(results, forecast),
20058
20112
  switches: switchesOf2(results, views, s.poolActive ?? null, now, end),
20059
20113
  lostAtReset: lostAtResetOf(results, views),
20060
- historyByAccount
20114
+ historyByAccount,
20115
+ slower: {
20116
+ factor: SLOWER_FACTOR,
20117
+ switches: switchesOf2(slowerResults, views, s.poolActive ?? null, now, end),
20118
+ blocked: blockedRuns(slowerResults, slowerForecast)
20119
+ }
20061
20120
  };
20062
20121
  }
20063
20122
  function sparkline(t, cells) {
@@ -20121,7 +20180,7 @@ function sparkline(t, cells) {
20121
20180
  return LEVELS[Math.max(0, level)] ?? " ";
20122
20181
  }).join("");
20123
20182
  }
20124
- var MINUTE_MS10 = 60000, HOUR_MS14 = 3600000, WEEK_MS4, BLOCKED_SHARE = 0.5, WIDE_BAND = 0.15, LEVELS, provenanceOf = (inferred) => inferred ? "reset-inferred" : "observed";
20183
+ var MINUTE_MS10 = 60000, HOUR_MS14 = 3600000, WEEK_MS4, BLOCKED_SHARE = 0.5, WIDE_BAND = 0.15, LEVELS, provenanceOf = (inferred) => inferred ? "reset-inferred" : "observed", MIN_BANDWIDTH_H = 0.5;
20125
20184
  var init_trajectory = __esm(() => {
20126
20185
  init_alerts();
20127
20186
  init_calibrate();
@@ -22769,6 +22828,29 @@ function poolRemaining(views) {
22769
22828
  }
22770
22829
  return { remainingNow: now.value, capacity, unit: now.unit };
22771
22830
  }
22831
+ function likelihoodView(l) {
22832
+ const p = l.p.map((v) => Math.round(Math.min(1, Math.max(0, v)) * 1000) / 1000);
22833
+ const first = p.findIndex((v) => v > 0);
22834
+ if (first < 0)
22835
+ return;
22836
+ let last = p.length - 1;
22837
+ while (last > first && p[last] === 0)
22838
+ last--;
22839
+ return { start: iso2(l.start + first * HOUR_MS16), stepHours: 1, p: p.slice(first, last + 1) };
22840
+ }
22841
+ function switchView(sw) {
22842
+ return {
22843
+ accountId: sw.account,
22844
+ soonest: iso2(sw.q.p10),
22845
+ usual: iso2(sw.q.p50),
22846
+ latest: iso2(sw.q.p90),
22847
+ probability: Math.min(1, Math.max(0, sw.probability)),
22848
+ likelihood: likelihoodView(sw.likelihood)
22849
+ };
22850
+ }
22851
+ function blockedView(b) {
22852
+ return { from: iso2(b.from.p50), to: iso2(b.to.p50), kind: b.kind, probability: b.probability };
22853
+ }
22772
22854
  function sustainableOf(top, pace, burnLong) {
22773
22855
  const long = Number.isFinite(burnLong) ? Math.max(0, burnLong) : 0;
22774
22856
  if (top)
@@ -22895,23 +22977,17 @@ function buildReport(input) {
22895
22977
  window: r.window,
22896
22978
  projected: r.projected
22897
22979
  })),
22898
- blocked: traj.blocked.map((b) => ({
22899
- from: iso2(b.from.p50),
22900
- to: iso2(b.to.p50),
22901
- kind: b.kind,
22902
- probability: b.probability
22903
- })),
22980
+ blocked: traj.blocked.map(blockedView),
22904
22981
  historyByAccount: none ? [] : views.filter((v) => traj.historyByAccount[v.account] !== undefined).map((v) => ({
22905
22982
  accountId: v.account,
22906
22983
  history: (traj.historyByAccount[v.account] ?? []).filter((h) => h.at >= now - 24 * HOUR_MS16).map((h) => ({ at: iso2(h.at), remaining: h.remaining, provenance: h.provenance }))
22907
22984
  })),
22908
- switches: traj.switches.map((sw) => ({
22909
- accountId: sw.account,
22910
- soonest: iso2(sw.q.p10),
22911
- usual: iso2(sw.q.p50),
22912
- latest: iso2(sw.q.p90),
22913
- probability: Math.min(1, Math.max(0, sw.probability))
22914
- })),
22985
+ switches: traj.switches.map(switchView),
22986
+ slower: {
22987
+ factor: Math.round(traj.slower.factor * 1000) / 1000,
22988
+ switches: traj.slower.switches.map(switchView),
22989
+ blocked: traj.slower.blocked.map(blockedView)
22990
+ },
22915
22991
  spark48: sparkline({
22916
22992
  ...traj,
22917
22993
  history: traj.history.filter((h) => h.at >= now - 24 * HOUR_MS16),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudish",
3
- "version": "14.7.0",
3
+ "version": "14.9.0",
4
4
  "description": "Run Claude Code with any model - OpenRouter, Ollama, LM Studio & local models",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -71,10 +71,10 @@
71
71
  "ai"
72
72
  ],
73
73
  "optionalDependencies": {
74
- "@claudish/magmux-darwin-arm64": "14.7.0",
75
- "@claudish/magmux-darwin-x64": "14.7.0",
76
- "@claudish/magmux-linux-arm64": "14.7.0",
77
- "@claudish/magmux-linux-x64": "14.7.0"
74
+ "@claudish/magmux-darwin-arm64": "14.9.0",
75
+ "@claudish/magmux-darwin-x64": "14.9.0",
76
+ "@claudish/magmux-linux-arm64": "14.9.0",
77
+ "@claudish/magmux-linux-x64": "14.9.0"
78
78
  },
79
79
  "author": "Jack Rudenko <i@madappgang.com>",
80
80
  "license": "MIT",