sprag-cli 3.109.0 → 3.109.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprag-cli",
3
- "version": "3.109.0",
3
+ "version": "3.109.1",
4
4
  "description": "The delegation layer for Claude Code and Codex: each task goes to the model and effort that fits it, down to cheaper models for lookups and up to higher effort when a cheaper run would miss, backed by public replay cases, with a live statusline and team rules for Pro and Enterprise.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,10 +19,17 @@ export async function run({ hasFlag }) {
19
19
  // 호출 횟수도 그만큼 늘어납니다.
20
20
  const key = resolveKey();
21
21
  let next = null;
22
+ if (!key) debug('litellm-budget:no-key', new Error('gateway set but no ANTHROPIC_AUTH_TOKEN, ANTHROPIC_API_KEY or apiKeyHelper key'));
22
23
  if (key) {
23
- next = await refreshBudgetState(process.env, fetch, key);
24
- const { maybeRefreshGatewayModelMap } = await import('../litellm-models.js');
25
- await maybeRefreshGatewayModelMap({ base: gatewayBase(), key });
24
+ // The price table does not depend on the budget: a gateway whose /key/info and
25
+ // /user/info both fail (custom auth, a timeout) still has to get its prices,
26
+ // or every Claude call there stays unpriced.
27
+ try {
28
+ next = await refreshBudgetState(process.env, fetch, key);
29
+ } finally {
30
+ const { maybeRefreshGatewayModelMap } = await import('../litellm-models.js');
31
+ await maybeRefreshGatewayModelMap({ base: gatewayBase(), key });
32
+ }
26
33
  }
27
34
  if (!quiet) console.log(JSON.stringify(next, null, 2));
28
35
  } catch (e) {
package/src/diag-log.js CHANGED
@@ -53,6 +53,7 @@ const EMAIL_RE =/[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2
53
53
  // A file path after the start, a space, a quote, `(` or `=`. `<host>/path` is not
54
54
  // matched (the `>` before it), so a URL keeps its path.
55
55
  const PATH_RE = /(^|[\s'"(=])((?:~|[A-Za-z]:)?[\\/][^\s'"():,]+)/g;
56
+ const FS_ROOT_RE = /^\/(?:Users|home|root|private|var|tmp|opt|usr|Volumes|mnt|media|srv|etc|Library|Applications|System|nix|snap|workspace|workspaces|data|app)(?:\/|$)/;
56
57
 
57
58
  /**
58
59
  * A path without the directories that could name a project: the last segment
@@ -62,6 +63,9 @@ const PATH_RE = /(^|[\s'"(=])((?:~|[A-Za-z]:)?[\\/][^\s'"():,]+)/g;
62
63
  */
63
64
  function shortPath(p) {
64
65
  const root = p.startsWith('~') ? '~' : /^[A-Za-z]:/.test(p) ? p.slice(0, 2) : '';
66
+ // An API path (`/key/info`, `/spend/logs/v2`) names no project and is what tells
67
+ // the failing call apart: only paths under a filesystem root are cut.
68
+ if (!root && !FS_ROOT_RE.test(p)) return p;
65
69
  const sep = p.includes('\\') && !p.includes('/') ? '\\' : '/';
66
70
  const parts = p.slice(root.length).split(/[\\/]/).filter(Boolean);
67
71
  const keep = root === '~' && parts[0]?.startsWith('.') ? Math.min(2, parts.length) : 0;
package/src/team-sync.js CHANGED
@@ -60,6 +60,7 @@ import { codexRequestCost } from './gateway-prices.js';
60
60
  import { codexBudgetProvider } from './codex/budget.js';
61
61
  import { fetchGatewayDailySpend, gatewayDayValue, gatewayEnv } from './gateway-spend.js';
62
62
  import { withClaudeSettingsEnv, gatewayBase } from './gateway-auth.js';
63
+ import { maybeRefreshGatewayModelMap, readGatewayModelMap } from './litellm-models.js';
63
64
  import { recordDiag, readDiag, ackDiag } from './diag-log.js';
64
65
 
65
66
  export const PROMPT_SYNC_INTERVAL_MS = 30 * 60 * 1000;
@@ -1022,7 +1023,20 @@ export async function syncTeam({
1022
1023
  // repriced them) go up again from the earliest one.
1023
1024
  let change = null;
1024
1025
  try { change = changedSinceForSync(); } catch (e) { debug('team-sync', e); }
1025
- const win = ledgerWindow(state, now, { gateway: hasGateway, changedSince: change?.since });
1026
+ // The gateway's price table. Until it is fetched every Claude call on this
1027
+ // gateway is unpriced; the statusline's budget child fetched it only when the
1028
+ // budget calls succeeded. The first table ever re-sends the whole window, so
1029
+ // the days already uploaded as unpriced get their spend.
1030
+ let firstTable = false;
1031
+ if (hasGateway) {
1032
+ try {
1033
+ const g = gatewayEnv(env);
1034
+ const hadTable = !!readGatewayModelMap(env);
1035
+ const fetched = await maybeRefreshGatewayModelMap({ base: g.base, key: g.key, fetchImpl: gatewayFetch, now });
1036
+ firstTable = !hadTable && !!fetched;
1037
+ } catch (e) { debug('team-sync:prices', e); }
1038
+ }
1039
+ const win = ledgerWindow(firstTable ? { ...state, ledgerSyncedThrough: null } : state, now, { gateway: hasGateway, changedSince: change?.since });
1026
1040
  // The gateway's request log is read only from the first day going up.
1027
1041
  let gatewayDaily = null;
1028
1042
  if (hasGateway) gatewayDaily = await fetchGatewayDailySpend({ env, fetchImpl: gatewayFetch, now, from: win.startKey });