@mnmal-ai/substrate-tui 1.0.0-beta.17 → 1.0.0-beta.19

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.
@@ -2780,17 +2780,31 @@ function readInviteTtl(text) {
2780
2780
  if (ttlMs === void 0) return {};
2781
2781
  return ttlMs > MAX_INVITE_TTL_MS ? { error: "at most 30 days" } : { ttlMs };
2782
2782
  }
2783
+ /** The server's rule for a named invite's kid (substrate-compose `kidProblem`), which still decides. */
2784
+ const INVITE_KID = /^[A-Za-z0-9][A-Za-z0-9._-]*(@[A-Za-z0-9][A-Za-z0-9._-]*)?$/;
2785
+ /** The invite-kid prompt's reading: a kid (absent for a random one), or why not. */
2786
+ function readInviteKid(text) {
2787
+ const kid = text.trim();
2788
+ if (kid === "") return {};
2789
+ return kid.length <= 128 && INVITE_KID.test(kid) ? { kid } : { error: "name or name@host, of letters, digits, '.', '_' and '-'" };
2790
+ }
2783
2791
  const NS_NAME = /^(\*|[A-Za-z0-9_.-]+)$/;
2784
2792
  const refusal = (text) => ({ error: text });
2785
- /** As the shared toned lines: a refusal in the error tone, anything else untoned. */
2786
- const toned = (lines) => lines.map((l) => typeof l === "string" ? { text: l } : {
2793
+ /** As the shared toned lines: a refusal in the error tone, a heading bold, anything else untoned. */
2794
+ const toned = (lines) => lines.map((l) => typeof l === "string" ? { text: l } : "error" in l ? {
2787
2795
  text: l.error,
2788
2796
  tone: "error"
2797
+ } : {
2798
+ text: l.bold,
2799
+ parts: [{
2800
+ text: l.bold,
2801
+ bold: true
2802
+ }]
2789
2803
  });
2790
2804
  function promptView(s, glyph) {
2791
2805
  return [
2792
2806
  `${glyph.title} keys › ${sanitise(s.label)}`,
2793
- ...s.kid !== void 0 ? [` ${sanitise(s.kid)}`] : [],
2807
+ ...s.kid !== void 0 ? [{ bold: ` ${sanitise(s.kid)}` }] : [],
2794
2808
  ...s.algorithm !== void 0 && s.fingerprint !== void 0 ? [` ${s.algorithm} · ${s.fingerprint}`] : [],
2795
2809
  ...s.error !== null ? [refusal(` ${sanitise(s.error)}`)] : [],
2796
2810
  " enter accept · esc back"
@@ -2823,13 +2837,14 @@ function verdictOf(deps, s, next) {
2823
2837
  adminCapability
2824
2838
  });
2825
2839
  }
2826
- function reviewOf(s, next, verdict, ttlMs) {
2840
+ function reviewOf(s, next, verdict, ttlMs, inviteKid) {
2827
2841
  return {
2828
2842
  flow: s.flow,
2829
2843
  edit: s,
2830
2844
  next,
2831
2845
  verdict,
2832
2846
  ...ttlMs !== void 0 ? { ttlMs } : {},
2847
+ ...inviteKid !== void 0 ? { inviteKid } : {},
2833
2848
  stage: "review",
2834
2849
  error: null,
2835
2850
  mismatch: false,
@@ -2887,7 +2902,7 @@ function reviewView(s, glyph, armed, size) {
2887
2902
  body.push(` register ${f.kid} · ${f.algorithm} · ${f.fingerprint}`, ` grant ${grantLine(next)}`);
2888
2903
  break;
2889
2904
  case "invite":
2890
- body.push(` invite for ${grantLine(next)}`, ` expires in ${s.ttlMs !== void 0 ? ttlText(s.ttlMs) : "the server default"}`);
2905
+ body.push(s.inviteKid !== void 0 ? ` invite for ${s.inviteKid} · ${grantLine(next)}` : ` invite for ${grantLine(next)}`, ` expires in ${s.ttlMs !== void 0 ? ttlText(s.ttlMs) : "the server default"}`);
2891
2906
  break;
2892
2907
  case "revoke": body.push(` ${f.row.kid} loses access immediately`);
2893
2908
  }
@@ -2908,14 +2923,15 @@ function reviewView(s, glyph, armed, size) {
2908
2923
  " esc back"
2909
2924
  ];
2910
2925
  break;
2911
- case "done": tail = s.inviteCode !== void 0 ? [
2912
- ...wrapCode(sanitise(s.inviteCode), w),
2913
- " give it to the invitee; it is not shown again",
2926
+ case "done": tail = s.inviteToken !== void 0 ? [
2927
+ ...wrapCode(sanitise(s.inviteToken), w),
2928
+ ` redeems at ${sanitise(s.inviteOrigin ?? "")} — the invitee's machine must reach that URL`,
2929
+ " give it to the invitee to paste into substrate federate join; it is not shown again",
2914
2930
  " esc close"
2915
2931
  ] : [" esc close"];
2916
2932
  }
2917
2933
  const head = fit(`${glyph.title} keys › ${target} · review`);
2918
- const fitLine = (l) => typeof l === "string" ? fit(l) : refusal(fit(l.error));
2934
+ const fitLine = (l) => typeof l === "string" ? fit(l) : "error" in l ? refusal(fit(l.error)) : { bold: fit(l.bold) };
2919
2935
  return [
2920
2936
  head,
2921
2937
  ...body.map(fit),
@@ -2990,7 +3006,7 @@ function editView(s, glyph, size) {
2990
3006
  const label = (ns) => ns === "*" ? "* every namespace" : ns;
2991
3007
  const nsW = Math.min(24, Math.max(9, ...m.rows.map((ns) => label(ns).length)) + 2);
2992
3008
  const granted = result(m);
2993
- const visible = Math.max(1, size.rows - 6);
3009
+ const visible = Math.max(1, size.rows - 7);
2994
3010
  const start = Math.max(0, Math.min(m.row - visible + 1, m.rows.length - visible));
2995
3011
  const grid = m.rows.slice(start, start + visible).map((ns, k) => {
2996
3012
  const at = start + k === m.row;
@@ -3007,7 +3023,8 @@ function editView(s, glyph, size) {
3007
3023
  const foot = s.note !== null ? [s.note === EMPTY_NOTE ? refusal(fit(` ${s.note}`)) : fit(` ${s.note}`)] : s.discardArmed ? [" discard changes? esc again"] : [];
3008
3024
  return [
3009
3025
  fit(`${glyph.title} keys › ${subject} · editing`),
3010
- fit(` ${"namespace".padEnd(nsW)} r m a`),
3026
+ " ",
3027
+ { bold: fit(` ${"namespace".padEnd(nsW)} r m a`) },
3011
3028
  ...grid,
3012
3029
  fit(` before ${before}`),
3013
3030
  fit(` after ${grantLine(granted)}`),
@@ -3015,11 +3032,11 @@ function editView(s, glyph, size) {
3015
3032
  fit(" ↑↓←→ move · space toggle · + add namespace · enter review · esc discard")
3016
3033
  ];
3017
3034
  }
3018
- /** Every keys panel: a one-column inset on a raised ground, set apart from the input band. */
3035
+ /** Every keys panel: two columns and one row of inset on a raised ground, set apart from the input band. */
3019
3036
  const KEYS_CHROME = {
3020
3037
  inset: {
3021
- x: 1,
3022
- y: 0
3038
+ x: 2,
3039
+ y: 1
3023
3040
  },
3024
3041
  ground: marathon.color.raised
3025
3042
  };
@@ -3100,8 +3117,8 @@ function editorPanels(deps) {
3100
3117
  };
3101
3118
  if (s.flow.kind === "invite") {
3102
3119
  switchTo(ctx, deps, "prompt", {
3103
- purpose: "invite-ttl",
3104
- label: "expires in (e.g. 30m, 12h, 7d; enter for the server default)",
3120
+ purpose: "invite-kid",
3121
+ label: "key name (e.g. repo-claude@host-a; enter for a random one)",
3105
3122
  error: null,
3106
3123
  back: s,
3107
3124
  table: s.table
@@ -3198,6 +3215,23 @@ function editorPanels(deps) {
3198
3215
  ...text !== "" ? { name: text } : {}
3199
3216
  }, s.table, "prompt");
3200
3217
  return;
3218
+ case "invite-kid": {
3219
+ if (s.back === null) return void 0;
3220
+ const named = readInviteKid(line);
3221
+ if ("error" in named) return {
3222
+ ...s,
3223
+ error: named.error
3224
+ };
3225
+ switchTo(ctx, deps, "prompt", {
3226
+ purpose: "invite-ttl",
3227
+ label: "expires in (e.g. 30m, 12h, 7d; enter for the server default)",
3228
+ error: null,
3229
+ back: s.back,
3230
+ ...named.kid !== void 0 ? { kid: named.kid } : {},
3231
+ table: s.table
3232
+ });
3233
+ return;
3234
+ }
3201
3235
  case "invite-ttl": {
3202
3236
  if (s.back === null) return void 0;
3203
3237
  const ttl = readInviteTtl(line);
@@ -3206,7 +3240,7 @@ function editorPanels(deps) {
3206
3240
  error: ttl.error
3207
3241
  };
3208
3242
  const next = result(s.back.matrix);
3209
- switchTo(ctx, deps, "review", reviewOf(s.back, next, verdictOf(deps, s.back, next), ttl.ttlMs));
3243
+ switchTo(ctx, deps, "review", reviewOf(s.back, next, verdictOf(deps, s.back, next), ttl.ttlMs, s.kid));
3210
3244
  return;
3211
3245
  }
3212
3246
  }
@@ -3381,27 +3415,29 @@ function editorPanels(deps) {
3381
3415
  }
3382
3416
  const out = await client.admin.invite({
3383
3417
  ...w,
3384
- ...s.ttlMs !== void 0 ? { ttlMs: s.ttlMs } : {}
3418
+ ...s.ttlMs !== void 0 ? { ttlMs: s.ttlMs } : {},
3419
+ ...s.inviteKid !== void 0 ? { kid: s.inviteKid } : {}
3385
3420
  });
3386
3421
  return {
3387
- line: `✓ invite minted for ${shown}, expires ${out.expiresAt}`,
3388
- code: out.code
3422
+ line: `✓ invite minted for ${s.inviteKid !== void 0 ? `${s.inviteKid} ${shown}` : shown}, expires ${out.expiresAt}`,
3423
+ token: out.token
3389
3424
  };
3390
3425
  }).then((r) => {
3391
3426
  ctx.print(sanitise(`${r.line} (admin: ${who})`), "ok");
3392
3427
  let open = false;
3393
3428
  ctx.update("review", (x) => {
3394
3429
  open = true;
3395
- return r.code !== void 0 ? {
3430
+ return r.token !== void 0 ? {
3396
3431
  ...x,
3397
3432
  stage: "done",
3398
- inviteCode: r.code
3433
+ inviteToken: r.token,
3434
+ inviteOrigin: deps.endpoint
3399
3435
  } : {
3400
3436
  ...x,
3401
3437
  stage: "done"
3402
3438
  };
3403
3439
  });
3404
- if (open && r.code === void 0 && deps.admin.unlocked()) loadKeys(ctx, deps, r.select);
3440
+ if (open && r.token === void 0 && deps.admin.unlocked()) loadKeys(ctx, deps, r.select);
3405
3441
  }, (err) => {
3406
3442
  const error = refusalOf(err);
3407
3443
  let open = false;
@@ -3954,7 +3990,7 @@ function keysModule(deps) {
3954
3990
  "prompt",
3955
3991
  "review"
3956
3992
  ]) ctx.update(p, (x) => {
3957
- if (!(p === "review" && "inviteCode" in x && x.inviteCode !== void 0)) adminOpen = true;
3993
+ if (!(p === "review" && "inviteToken" in x && x.inviteToken !== void 0)) adminOpen = true;
3958
3994
  return x;
3959
3995
  });
3960
3996
  if (adminOpen) {
@@ -51,7 +51,7 @@ async function main() {
51
51
  }
52
52
  Object.assign(process.env, colorDepthEnv(process.env));
53
53
  const [{ createTui }, { makeDeps }, { prepareTerminal }, { terminalOptions }] = await Promise.all([
54
- import("../app-Cj1astMb.js"),
54
+ import("../app-79WsRXNr.js"),
55
55
  import("../deps-CMPHUv70.js"),
56
56
  import("@mnmal-ai/surface-core/pure"),
57
57
  import("../terminal-BAd8sH3d.js")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mnmal-ai/substrate-tui",
3
- "version": "1.0.0-beta.17",
3
+ "version": "1.0.0-beta.19",
4
4
  "description": "Terminal UI for Substrate: ask in natural language, browse the schema, see the service status.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -20,8 +20,8 @@
20
20
  "access": "public"
21
21
  },
22
22
  "dependencies": {
23
- "@mnmal-ai/substrate": "1.0.0-beta.17",
24
- "@mnmal-ai/substrate-nl": "1.0.0-beta.17",
23
+ "@mnmal-ai/substrate": "1.0.0-beta.19",
24
+ "@mnmal-ai/substrate-nl": "1.0.0-beta.19",
25
25
  "@mnmal-ai/surface-core": "0.17.1",
26
26
  "@mnmal-ai/surface-kit": "0.17.1",
27
27
  "@mnmal-ai/surface-theme": "0.17.1",
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "@biomejs/biome": "2.6.4",
33
- "@mnmal-ai/substrate-config": "1.0.0-beta.17",
33
+ "@mnmal-ai/substrate-config": "1.0.0-beta.19",
34
34
  "@types/node": "^26.6.4",
35
35
  "@types/react": "^19.2.0",
36
36
  "ink-testing-library": "^4.0.0",