sprag-cli 3.119.0 → 3.121.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.
package/docs/TEAM.md CHANGED
@@ -136,8 +136,27 @@ Sprag writes the rules to `~/.claude/ratchet-team.md` (Codex: `<CODEX_HOME>/ratc
136
136
  | `sprag team sync [--force] [--rules-only]` | Upload now and pull rules. `--force` ignores the 5-minute interval; `--rules-only` pulls the organization and team rules and uploads nothing |
137
137
  | `sprag team rules` | Show the cached organization and team rules |
138
138
  | `sprag team propose "<text>" [--scope ratchet\|model]` | Propose a rule to the team |
139
+ | `sprag team town [--no-open]` | Open the read-only town in your browser (see "Town for members") |
139
140
  | `sprag team leave` | Leave the team and stop uploading |
140
141
 
142
+ ## Town for members
143
+
144
+ Members never sign in to the dashboard, but they can see the team as a small 3D town. Run:
145
+
146
+ ```bash
147
+ sprag team town # prints the link and opens it in your browser
148
+ sprag team town --no-open # prints the link only
149
+ ```
150
+
151
+ The command asks the team server for a link with `town_view_link` (it sends your member key and nothing else) and opens `https://sprag.io/town/#t=<token>`. The token is valid for 12 hours and the command prints the expiry in your local time. Asking for links too often is refused for a while ("too many town links"). The token sits in the part of the address after `#`, so the web server never receives it, and the page removes it from the address bar after reading it. When it expires, or after you leave the team, the page asks you to run the command again. `SPRAG_TOWN_URL` points the link at another page (for local tests).
152
+
153
+ What the town shows:
154
+
155
+ - You: your own numbers in full, as an owner sees them in the dashboard's town (spend, savings, delegation, your machines, prompt counts when capture is on), plus your rank and what the next species takes.
156
+ - Everyone else in the organization: only the character. That is the name, the species and tier, the crown, the team, the OS and whether uploads are on, late or paused.
157
+
158
+ What it never shows about other people: any figure (spend, savings, delegation share, rank), their machines, their prompts or their activity. The server enforces this. `town_view` returns no numbers for anyone but the token's owner, so a modified page or a copied link cannot reveal them. The page has no admin action and no link to the dashboard, and it is excluded from search engines (`robots.txt` and a `noindex` tag).
159
+
141
160
  ## Organizations and seats
142
161
 
143
162
  Every team belongs to an organization, and seats are bought per organization, not per team. Only Sprag opens organizations: write to support@sprag.io, and the superuser opens one at sprag.io/ops/ and names its first owner by email. The owner email is required, and the owner does not need an account yet: if the email has never signed in, Sprag keeps it as an invite, and the person becomes the owner the first time they sign in at https://sprag.io/team/ with that email. Owners and admins then create teams inside it.
@@ -227,4 +246,5 @@ Owners and admins of an Enterprise organization get a Prompts tab on sprag.io/te
227
246
  | `~/.claude/ratchet-team.md` | Approved organization and team rules for Claude Code, imported from `~/.claude/CLAUDE.md` |
228
247
  | `<CODEX_HOME>/ratchet-team.md` | The same rules for Codex |
229
248
  | `SPRAG_TEAM_TOKEN` | Invite token; enrolls the machine at the next session start |
249
+ | `SPRAG_TOWN_URL` | Page that `sprag team town` opens (default `https://sprag.io/town/`); for local tests only |
230
250
  | `SPRAG_NO_TEAM_SYNC=1` | Stops every usage upload. A joined machine sends only one status-only call when it first sees the switch on and when it is off again (old name `CTS_NO_TEAM_SYNC` still read) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprag-cli",
3
- "version": "3.119.0",
3
+ "version": "3.121.0",
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": {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * team — `sprag team <create|join|name|leave|status|sync|rules|propose>`.
2
+ * team — `sprag team <create|join|name|leave|status|sync|rules|propose|town>`.
3
3
  *
4
4
  * The opt-in team layer. `join` shows exactly what will be uploaded (daily
5
5
  * aggregates and a delegation rule summary) and asks before enrolling. `sync --background` is what the
@@ -24,6 +24,7 @@ import {
24
24
  } from '../team-sync.js';
25
25
  import { standingGuideLines } from '../team-standing.js';
26
26
  import { readDiag } from '../diag-log.js';
27
+ import { envVar } from '../env.js';
27
28
 
28
29
  const T = {
29
30
  en: {
@@ -38,6 +39,7 @@ const T = {
38
39
  ' (--rules-only: pull organization and team rules only, upload nothing)',
39
40
  ' rules show cached organization and team rules',
40
41
  ' propose <text> [--scope ratchet|model] propose a rule to the team',
42
+ ' town [--no-open] open the read-only town in your browser (link valid 12 hours)',
41
43
  ].join('\n'),
42
44
  willSend: 'Joining uploads aggregates only. Per local day:\n - spend (USD)\n - savings (USD)\n - delegation run counts\n - model-family share\nAnd one summary of your delegation rules, per category and tier:\n - category, tier, delegation count, failure rate, savings (USD)\nError messages from sprag itself (to fix problems on your machine). Home paths, host names and secrets are masked.\nNo prompts, rule text, examples, file paths or transcripts are sent.',
43
45
  rulesPayload: 'delegation rule summary (member_rules_report)',
@@ -107,6 +109,11 @@ const T = {
107
109
  dashboard: (e) => `Dashboard: https://sprag.io/team/ (sign in with ${e})`,
108
110
  noJoinNote: 'This machine did not join (--no-join).',
109
111
  syncFailed: (e) => `Team created, but the first sync failed: ${e}`,
112
+ townLink: (u) => `Town link: ${u}`,
113
+ townExpiry: (when) => `Valid until ${when} (12 hours). It shows your own numbers in full; other people appear only as characters, with no figures.`,
114
+ townRate: 'Too many town links in a short time. Wait a few minutes and try again.',
115
+ townBadReply: 'The team server sent no usable town link. Try again later.',
116
+ townUnsupported: 'The team server does not support the member town yet. Try again after it is updated.',
110
117
  },
111
118
  ko: {
112
119
  usage: [
@@ -120,6 +127,7 @@ const T = {
120
127
  ' (--rules-only: 조직·팀 규칙만 받고 아무것도 올리지 않음)',
121
128
  ' rules 받아 둔 조직·팀 규칙 보기',
122
129
  ' propose <내용> [--scope ratchet|model] 팀에 규칙 제안',
130
+ ' town [--no-open] 읽기 전용 타운을 브라우저로 열기 (링크 12시간 유효)',
123
131
  ].join('\n'),
124
132
  willSend: '참여하면 집계만 올라갑니다. 로컬 날짜별로는 다음과 같습니다.\n - 지출(USD)\n - 절감(USD)\n - 위임 실행 횟수\n - 모델 계열 비중\n위임 룰은 카테고리와 티어별 요약 한 벌이 올라갑니다.\n - 카테고리, 티어, 위임 횟수, 실패율, 절감액(USD)\nsprag 자체의 오류 메시지(이 기기의 문제를 고치는 데 씁니다). 홈 경로, 호스트 이름, 비밀 값은 가려서 보냅니다.\n프롬프트, 룰 본문, 예시, 파일 경로, 대화 기록은 보내지 않습니다.',
125
133
  rulesPayload: '위임 룰 요약 (member_rules_report)',
@@ -189,6 +197,11 @@ const T = {
189
197
  dashboard: (e) => `대시보드: https://sprag.io/team/ (${e} 로 로그인)`,
190
198
  noJoinNote: '이 PC는 참여하지 않았습니다 (--no-join)',
191
199
  syncFailed: (e) => `팀은 만들어졌지만 첫 동기화에 실패했습니다: ${e}`,
200
+ townLink: (u) => `타운 링크: ${u}`,
201
+ townExpiry: (when) => `${when}까지 유효합니다(12시간). 내 수치는 자세히 보이고 다른 사람은 수치 없이 캐릭터로만 나옵니다.`,
202
+ townRate: '타운 링크를 짧은 시간에 너무 많이 만들었습니다. 몇 분 뒤에 다시 시도하세요.',
203
+ townBadReply: '팀 서버가 쓸 수 있는 타운 링크를 주지 않았습니다. 잠시 뒤에 다시 시도하세요.',
204
+ townUnsupported: '팀 서버가 아직 멤버 타운을 지원하지 않습니다. 서버가 갱신된 뒤 다시 시도하세요.',
192
205
  },
193
206
  };
194
207
 
@@ -233,6 +246,10 @@ function openInBrowser(url) {
233
246
  } catch { /* no opener on this machine */ }
234
247
  }
235
248
  const CODE_RE = /^\d{6}$/;
249
+ /** Where the member town lives. SPRAG_TOWN_URL points it at a local server (site/ served by scripts/serve-site.mjs). */
250
+ export const TOWN_URL = 'https://sprag.io/town/';
251
+ export const townUrl = (env = process.env) => envVar('TOWN_URL', env) || TOWN_URL;
252
+ const TOWN_TOKEN_RE = /^stv_[0-9a-f]{64}$/;
236
253
  // The default display name is the machine id; `status` and `join` then point at `team name`.
237
254
  const MACHINE_NAME_RE = /^member-[0-9a-f]{8}$/;
238
255
 
@@ -431,6 +448,29 @@ export async function run({ args, hasFlag, getArg, version, fetch, interactive,
431
448
  out(m.proposed(id));
432
449
  return undefined;
433
450
  }
451
+ case 'town': {
452
+ const st = loadTeamState();
453
+ if (!isJoined(st)) { console.error(m.needJoin); return process.exit(1); }
454
+ if (teamSyncDisabled()) { out(m.disabled); return undefined; }
455
+ let reply;
456
+ try {
457
+ reply = await rpc('town_view_link', { member_key: st.memberKey }, { fetch });
458
+ } catch (e) {
459
+ const msg = String(e && e.message);
460
+ if (/too many town links/i.test(msg)) { console.error(m.townRate); return process.exit(1); }
461
+ if (/Could not find the function|PGRST202/i.test(msg)) { console.error(m.townUnsupported); return process.exit(1); }
462
+ throw e;
463
+ }
464
+ const token = reply && typeof reply.token === 'string' ? reply.token : '';
465
+ if (!TOWN_TOKEN_RE.test(token)) { console.error(m.townBadReply); return process.exit(1); }
466
+ // The token rides in the fragment: the browser never sends it to the web server, and the page strips it from the address bar.
467
+ const url = `${townUrl()}#t=${token}`;
468
+ const when = new Date(reply.expires_at);
469
+ out(m.townLink(url));
470
+ if (!Number.isNaN(when.getTime())) out(m.townExpiry(when.toLocaleString()));
471
+ if (!hasFlag('--no-open')) (openUrl || openInBrowser)(url);
472
+ return undefined;
473
+ }
434
474
  default:
435
475
  out(m.usage);
436
476
  return verb && verb !== 'help' ? process.exit(2) : undefined;