@tobos/cli 0.4.30 → 0.4.31

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.
@@ -5,7 +5,7 @@ import {
5
5
  init_define_TOBOS_PRESENT_TYPES,
6
6
  init_define_TOBOS_SKILL,
7
7
  init_define_TOBOS_TOOLCHAIN
8
- } from "./chunk-QZRWMMBR.js";
8
+ } from "./chunk-XG2KKGXE.js";
9
9
 
10
10
  // ../deck/src/deck-json.ts
11
11
  init_define_TOBOS_PRESENT_TYPES();
@@ -116,7 +116,7 @@ export declare const JoinCode: Component<JoinCodeProps>;
116
116
  var define_TOBOS_SKILL_default;
117
117
  var init_define_TOBOS_SKILL = __esm({
118
118
  "<define:TOBOS_SKILL>"() {
119
- define_TOBOS_SKILL_default = { "SKILL.md": "---\nname: tobos-present\ndescription: Build presentations as code with Tobos Present. Use when the user wants a talk, lecture, pitch or slide deck made, changed, rendered, presented or exported as a PDF, or mentions Tobos or `tobos`.\n---\n\n<!-- Installed by the `tobos` CLI and overwritten when it updates, so changes made here don't last. -->\n\n# Tobos Present\n\nTobos hosts presentations written as code: a deck is a folder of files, one Svelte 5 file per scene, advancing one beat per click. You build it with the `tobos` command, which needs no git; Tobos checks every push, keeps every version, hosts the deck and puts it on stage. `tobos --help` lists every command, and each takes `--json`.\n\n## Get to the deck\n\n- `tobos ls` lists the decks and templates the person can work on, by id. `tobos pull <id>` gets one; `tobos new \"Title\"` starts one and pulls it.\n- A new deck starts from Tobos simple. The person's own templates, their house styles, are in `tobos ls`: start from one with `--from <id>`, and ask which when there are several.\n- Then read the deck's `AGENTS.md`: it points to the loop, the format and the deck's slide master.\n- The person's decks are in folders, which `tobos --help` lists the commands for.\n\nExit code 3 means no one is logged in. Ask the person for their e-mail address and run `tobos login <email>`. Then ask, in one line, for the 6-digit code it mailed them (it may be in spam, and using it accepts https://tobos.ai/terms), and run `tobos login --code <code>`. In CI or a sandbox with no one to ask, `TOBOS_TOKEN` and `TOBOS_SERVER` stand in for the login.\n\n## Follow the person\n\nThey decide what to make and how much of it you build: one scene at a time, or the whole deck at once. Build what they ask, at the size they ask, from what they have told you about the talk. When they ask how Tobos works or where to start, give them the tour, https://tobos.ai/tour, and nothing of your own: no explanation, no deck to try.\n\n## Folders\n\n- Look at the person's folders before you make or move a deck, and file it under a folder name they have already, as they wrote it, rather than a new one that means the same.\n- File every deck you make: once it is made, move it into the folder it belongs in.\n- Before you move more than a handful of decks, show the person the tree you propose, and make it once they say yes.\n- A reorganisation is taken back by moving the decks back where they were: note where they were before you move them.\n- A folder goes when it empties, by a move or a deck's deletion: there is no removing one. A folder with only archived decks in it isn't empty.\n\n## What stays the person's\n\n- **Exit code 5** is a plan's limit or an archived deck. Show the person the message as it is, which says what they can do, and wait for their answer. The deck stays in Tobos: a deck built elsewhere to upload later, media shrunk or hosted elsewhere to fit, or someone else's account would decide for them what is theirs to decide.\n- **Archiving, opening again and deleting** a deck, and deleting a session's answers, are done by the person on the deck's page, also in a browser `tobos open` logged in.\n- **Who is on a deck, and its link,** are the person's, on the deck's page: they put people on it, change what each may do, take them off, and turn the link on or off there. You neither see nor change any of it: `tobos ls` tells you only what you may do on each deck and whose it is. Can edit builds it with their own agent, can present presents it with its notes and polls, and can view sees the slides; on a template, can edit and can use.\n- **The URL `tobos open` prints** is the deck's page, where the person watches it, presents it and shares it; `--presenter` gives a presenter's link instead, which opens once, for whoever opens it first.\n\n## The story\n\nA deck's story is the talk as the speaker tells it, in paragraphs. What follows a mention of a scene, `[Title](scene:<id>)` or one of its beats, `[Title](scene:<id>/<beat>)`, up to the next mention, is that scene's: the presenter sees it as speaker notes. The server holds the story, not git: the person types in it on the deck's page, and you change it with `tobos story`.\n\n- Read it again right before each change: the person may be typing.\n- Change what the person asked, and keep the rest of their words as they are.\n- An edit is anchored on exact text that occurs once in its paragraph. Exit code 4 means the paragraph changed meanwhile: anchor on it as the reply gives it, and try again.\n- Set `TOBOS_AGENT` to your name (`claude`, `codex`), so the page shows what you wrote.\n" };
119
+ define_TOBOS_SKILL_default = { "SKILL.md": "---\nname: tobos-present\ndescription: Build presentations as code with Tobos Present. Use when the user wants a talk, lecture, pitch or slide deck made, changed, rendered, presented or exported as a PDF, or mentions Tobos or `tobos`.\n---\n\n<!-- Installed by the `tobos` CLI and overwritten when it updates, so changes made here don't last. -->\n\n# Tobos Present\n\nTobos hosts presentations written as code: a deck is a folder of files, one Svelte 5 file per scene, advancing one beat per click. You build it with the `tobos` command, which needs no git; Tobos checks every push, keeps every version, hosts the deck and puts it on stage. `tobos --help` lists every command, and each takes `--json`.\n\n## Get to the deck\n\n- `tobos ls` lists the decks and templates the person can work on, by id. `tobos pull <id>` gets one; `tobos new \"Title\"` starts one and pulls it.\n- A new deck starts from Tobos simple. The person's own templates, their house styles, are in `tobos ls`: start from one with `--from <id>`, and ask which when there are several.\n- Then read the deck's `AGENTS.md`: it points to the loop, the format and the deck's slide master.\n- The person's decks are in folders, which `tobos --help` lists the commands for.\n\nExit code 3 means this machine isn't connected to the person's account. Run `tobos login`: it prints an address, which the person opens on any device, logs in at (a first login signs them up, and accepts https://tobos.ai/terms) and approves this machine. Give it to them in one line, then, once they did, run `tobos login` again. In CI or a sandbox with no one to ask, `TOBOS_TOKEN` and `TOBOS_SERVER` stand in for the login.\n\n## Follow the person\n\nThey decide what to make and how much of it you build: one scene at a time, or the whole deck at once. Build what they ask, at the size they ask, from what they have told you about the talk. When they ask how Tobos works or where to start, give them the tour, https://tobos.ai/tour, and nothing of your own: no explanation, no deck to try.\n\n## Folders\n\n- Look at the person's folders before you make or move a deck, and file it under a folder name they have already, as they wrote it, rather than a new one that means the same.\n- File every deck you make: once it is made, move it into the folder it belongs in.\n- Before you move more than a handful of decks, show the person the tree you propose, and make it once they say yes.\n- A reorganisation is taken back by moving the decks back where they were: note where they were before you move them.\n- A folder goes when it empties, by a move or a deck's deletion: there is no removing one. A folder with only archived decks in it isn't empty.\n\n## What stays the person's\n\n- **Exit code 5** is a plan's limit or an archived deck. Show the person the message as it is, which says what they can do, and wait for their answer. The deck stays in Tobos: a deck built elsewhere to upload later, media shrunk or hosted elsewhere to fit, or someone else's account would decide for them what is theirs to decide.\n- **Archiving, opening again and deleting** a deck, and deleting a session's answers, are done by the person on the deck's page, in their own browser.\n- **Who is on a deck, and its link,** are the person's, on the deck's page: they put people on it, change what each may do, take them off, and turn the link on or off there. You neither see nor change any of it: `tobos ls` tells you only what you may do on each deck and whose it is. Can edit builds it with their own agent, can present presents it with its notes and polls, and can view sees the slides; on a template, can edit and can use.\n- **The URL `tobos open` prints** is the deck's page, where the person watches it, presents it and shares it; `--presenter` gives a presenter's link instead, which opens once, for whoever opens it first.\n\n## The story\n\nA deck's story is the talk as the speaker tells it, in paragraphs. What follows a mention of a scene, `[Title](scene:<id>)` or one of its beats, `[Title](scene:<id>/<beat>)`, up to the next mention, is that scene's: the presenter sees it as speaker notes. The server holds the story, not git: the person types in it on the deck's page, and you change it with `tobos story`.\n\n- Read it again right before each change: the person may be typing.\n- Change what the person asked, and keep the rest of their words as they are.\n- An edit is anchored on exact text that occurs once in its paragraph. Exit code 4 means the paragraph changed meanwhile: anchor on it as the reply gives it, and try again.\n- Set `TOBOS_AGENT` to your name (`claude`, `codex`), so the page shows what you wrote.\n" };
120
120
  }
121
121
  });
122
122
 
package/dist/cli.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  mergeText,
8
8
  parseMediaJson,
9
9
  unpackTar
10
- } from "./chunk-67QAOIEN.js";
10
+ } from "./chunk-T2JISWY5.js";
11
11
  import {
12
12
  ASK_THE_PERSON,
13
13
  CliError,
@@ -19,7 +19,7 @@ import {
19
19
  init_define_TOBOS_TOOLCHAIN,
20
20
  offerUpdate,
21
21
  update
22
- } from "./chunk-QZRWMMBR.js";
22
+ } from "./chunk-XG2KKGXE.js";
23
23
 
24
24
  // src/main.ts
25
25
  init_define_TOBOS_PRESENT_TYPES();
@@ -68,7 +68,10 @@ function write(stored) {
68
68
  renameSync(next, file);
69
69
  }
70
70
  function save(update2) {
71
- write({ ...read(), ...update2 });
71
+ const stored = read();
72
+ const elsewhere = update2.server !== void 0 && update2.server !== stored.server;
73
+ const kept = elsewhere ? { server: stored.server } : stored;
74
+ write({ ...kept, ...update2 });
72
75
  }
73
76
  function forget() {
74
77
  write({ server: read().server });
@@ -80,16 +83,18 @@ function settings() {
80
83
  } catch (error) {
81
84
  if (!process.env.TOBOS_SERVER || !process.env.TOBOS_TOKEN) throw error;
82
85
  }
86
+ const server = (process.env.TOBOS_SERVER || stored.server || DEFAULT_SERVER).replace(/\/$/, "");
87
+ const own = (stored.server || DEFAULT_SERVER).replace(/\/$/, "") === server;
83
88
  return {
84
- server: (process.env.TOBOS_SERVER || stored.server || DEFAULT_SERVER).replace(/\/$/, ""),
85
- token: process.env.TOBOS_TOKEN || stored.token,
86
- email: stored.email,
87
- pending: stored.pending
89
+ server,
90
+ token: process.env.TOBOS_TOKEN || (own ? stored.token : void 0),
91
+ email: own ? stored.email : void 0,
92
+ device: stored.device
88
93
  };
89
94
  }
90
95
 
91
96
  // src/api.ts
92
- var VERSION = true ? "0.4.30" : "dev";
97
+ var VERSION = true ? "0.4.31" : "dev";
93
98
  function newer(a, b) {
94
99
  const parse = (v) => /^\d+\.\d+\.\d+/.test(v) ? v.split(".").map((n) => parseInt(n)) : null;
95
100
  const x = parse(a);
@@ -132,12 +137,12 @@ async function request(path, options = {}) {
132
137
  if (!options.anonymous) {
133
138
  if (!token)
134
139
  throw new CliError(
135
- "Not logged in. Ask the person you work for for their e-mail address, then run `tobos login <email>`.",
140
+ "Not logged in: run `tobos login`, and give the person the address it prints.",
136
141
  EXIT.auth
137
142
  );
138
143
  if (new URL(target).origin !== new URL(server).origin)
139
144
  throw new CliError(
140
- `This deck is on ${target}, but you are logged in to ${server}, and the token goes only there. Log in to the deck's server with \`tobos login <email> --server ${target}\`.`,
145
+ `This deck is on ${target}, but you are logged in to ${server}, and the token goes only there. Log in to the deck's server with \`tobos login --server ${target}\`.`,
141
146
  EXIT.auth
142
147
  );
143
148
  headers.authorization = `Bearer ${token}`;
@@ -626,40 +631,94 @@ function installed(dir2) {
626
631
  }
627
632
 
628
633
  // src/commands.ts
629
- var TERMS_NOTICE = "If the address is new, using the code accepts https://tobos.ai/terms.";
634
+ var LOGIN_WAIT_MS = 9e4;
630
635
  async function login(out, args) {
631
636
  const server = (args.values.server || settings().server).replace(/\/$/, "");
632
- const client = `the tobos CLI on ${hostname()}`;
633
- const email = args.positionals[0]?.trim().toLowerCase();
634
- const code = args.values.code;
635
- if (!code) {
636
- if (!email)
637
- throw new CliError(
638
- "Log in with the e-mail address of the person you work for: `tobos login <email>`."
637
+ const kept = settings().device;
638
+ let device = kept && kept.server === server && Date.parse(kept.expires) > Date.now() ? kept : void 0;
639
+ let opened = false;
640
+ if (!device) {
641
+ const started = await api("/oauth/device", {
642
+ anonymous: true,
643
+ server,
644
+ body: { label: `the tobos CLI on ${hostname()}` }
645
+ });
646
+ device = {
647
+ server,
648
+ deviceCode: started.device_code,
649
+ userCode: started.user_code,
650
+ url: started.verification_uri_complete,
651
+ interval: started.interval,
652
+ expires: new Date(Date.now() + started.expires_in * 1e3).toISOString()
653
+ };
654
+ save({ server, device });
655
+ opened = await openUrl(device.url);
656
+ if (!opened) {
657
+ out.result(
658
+ { waiting: true, url: device.url, code: device.userCode, next: "tobos login" },
659
+ () => `Give the person this address, to open where they like, a phone too: they log in there and approve this machine (a first login signs them up, and accepts https://tobos.ai/terms).
660
+
661
+ ${device.url}
662
+
663
+ The page shows the code ${device.userCode}. Once they approved it, run \`tobos login\` again.`
639
664
  );
640
- await api("/api/login", { anonymous: true, server, body: { email, client } });
641
- save({ server, pending: email });
665
+ process.exitCode = EXIT.auth;
666
+ return;
667
+ }
668
+ out.note(`Opened ${device.url} in the browser: approve the code ${device.userCode} there.`);
669
+ }
670
+ const token = await waitForApproval(device, (m) => out.note(m));
671
+ if (!token) {
642
672
  out.result(
643
- { sent: email, next: "tobos login --code <code>", terms: TERMS_NOTICE },
644
- () => `Sent a 6-digit code to ${email}; it works for 10 minutes. Ask the person for it in one line: check the inbox, or spam, and paste the code here. ${TERMS_NOTICE} Then run:
673
+ { waiting: true, url: device.url, code: device.userCode, next: "tobos login" },
674
+ () => [
675
+ `Not approved yet. The person approves this machine at
645
676
 
646
- tobos login --code <code>`
677
+ ${device.url}`,
678
+ `where the page shows the code ${device.userCode}. Then run \`tobos login\` again.`
679
+ ].join("\n\n")
647
680
  );
681
+ process.exitCode = EXIT.auth;
648
682
  return;
649
683
  }
650
- const address = email ?? settings().pending;
651
- if (!address)
652
- throw new CliError("Which address got the code? `tobos login <email> --code <code>`.");
653
- const { token } = await api("/api/login/verify", {
654
- anonymous: true,
655
- server,
656
- body: { email: address, code, client }
657
- });
658
- save({ server, token, pending: void 0 });
684
+ save({ server, token, device: void 0 });
659
685
  const me = await api("/api/me", { server });
660
686
  save({ email: me.email });
661
687
  out.result({ email: me.email, server }, () => `Logged in as ${me.email}.`);
662
688
  }
689
+ async function waitForApproval(device, note) {
690
+ const until = Date.now() + LOGIN_WAIT_MS;
691
+ let interval = device.interval * 1e3;
692
+ note(`waiting for the person to approve ${device.userCode}\u2026`);
693
+ while (Date.now() < until) {
694
+ const response = await request("/oauth/token", {
695
+ anonymous: true,
696
+ server: device.server,
697
+ body: {
698
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
699
+ device_code: device.deviceCode
700
+ }
701
+ });
702
+ const answer = await response.json().catch(() => ({}));
703
+ if (answer.access_token) return answer.access_token;
704
+ if (answer.error === "slow_down") interval += 5e3;
705
+ else if (answer.error === "access_denied") {
706
+ save({ device: void 0 });
707
+ throw new CliError("The person chose not to connect this machine.", EXIT.auth);
708
+ } else if (answer.error === "expired_token" || answer.error === "invalid_grant") {
709
+ save({ device: void 0 });
710
+ throw new CliError(
711
+ "The code expired before the person approved it. Run `tobos login` again for a new one.",
712
+ EXIT.auth
713
+ );
714
+ } else if (answer.error !== "authorization_pending")
715
+ throw new CliError(
716
+ `${device.server} answered ${response.status} rather than whether the person approved. Run \`tobos login\` again: it waits on the same code.`
717
+ );
718
+ await new Promise((done) => setTimeout(done, interval));
719
+ }
720
+ return void 0;
721
+ }
663
722
  async function logout(out) {
664
723
  let revoked = false;
665
724
  if (settings().token)
@@ -815,7 +874,7 @@ async function check(out, args) {
815
874
  );
816
875
  const problems = [...written.problems];
817
876
  if (args.values.types) {
818
- const { checkTypes } = await import("./types-YY3IZCJO.js");
877
+ const { checkTypes } = await import("./types-XT3SUHKX.js");
819
878
  problems.push(...await checkTypes(copy.root, (m) => out.note(m)));
820
879
  }
821
880
  const { errors, warnings } = problemSummary(problems);
@@ -895,16 +954,9 @@ async function open(out, args) {
895
954
  out.result({ url: full, opened, pushed }, () => full);
896
955
  }
897
956
  async function openApp(out) {
898
- const { url, code } = await api("/api/login/browser", {
899
- method: "POST"
900
- });
901
- const page = `${new URL(url).origin}/login`;
902
- out.result(
903
- { url, code, page },
904
- () => code ? `Open this link, or enter ${code} at ${page}. It works once, within 10 minutes.
905
- ${url}` : `Open this link. It works once, within 10 minutes.
906
- ${url}`
907
- );
957
+ const url = `${settings().server}/`;
958
+ const opened = await openUrl(url);
959
+ out.result({ url, opened }, () => url);
908
960
  }
909
961
  async function storyTx(id, ops) {
910
962
  try {
@@ -967,7 +1019,7 @@ async function story(out, args) {
967
1019
  throw new CliError(`No \`tobos story ${action}\`: edit, add or delete.`);
968
1020
  }
969
1021
  async function render(out, args) {
970
- const { renderBeats } = await import("./render-WZUAK4TK.js");
1022
+ const { renderBeats } = await import("./render-RISSGSJN.js");
971
1023
  const copy = findCopy();
972
1024
  const deck = copy?.base ? { id: copy.base.deck, root: copy.root } : void 0;
973
1025
  const id = typeof args.values.deck === "string" ? parseId(args.values.deck) : deck?.id;
@@ -1036,8 +1088,9 @@ async function skill(out, args) {
1036
1088
  var HELP = `tobos ${VERSION}: the command line of Tobos, the office suite your coding agent works in.
1037
1089
 
1038
1090
  Account
1039
- tobos login <email> [--server URL] e-mail a login code to the person (signs them up if new)
1040
- tobos login --code <code> finish: the code they read from the mail
1091
+ tobos login [--server URL] connect this machine: prints an address for the
1092
+ person to open and approve (logging in, or signing
1093
+ up, there); run it again once they did
1041
1094
  tobos logout forget this machine's token
1042
1095
  tobos whoami who you are, on which server
1043
1096
  tobos ls [/path] your decks and templates, by id, each in its folder,
@@ -1069,8 +1122,7 @@ from anywhere)
1069
1122
  tobos open [scene/beat] [--presenter] the deck's page in a browser (--presenter: a
1070
1123
  [--print] presenter's link, which opens once); --print: print
1071
1124
  the URL only, open nothing
1072
- tobos open outside a deck: a link, or its code for /login,
1073
- that logs a browser in once; show the person both
1125
+ tobos open outside a deck: the person's decks, in Tobos
1074
1126
 
1075
1127
  The story (what the speaker says, held by the server; a scene mentioned: [Title](scene:<id>),
1076
1128
  a beat: [Title](scene:<id>/<beat>))
@@ -1091,7 +1143,7 @@ Templates (decks people start from: a new deck copies a template's master/)
1091
1143
  tobos new "Our brand" --template a new template: a copy of Tobos simple (or of --from)
1092
1144
 
1093
1145
  Every command takes --json and then prints one JSON object.
1094
- Exit codes: 0 ok, 1 error, 2 the deck has problems, 3 not logged in, 4 a conflict: someone
1146
+ Exit codes: 0 ok, 1 error, 2 the deck has problems, 3 not logged in (or not yet approved), 4 a conflict: someone
1095
1147
  changed the same lines (pull, resolve, push again; for the story, the reply has the paragraph as
1096
1148
  it is now), 5 a plan's limit or an archived deck: the person decides what to do, so show them the
1097
1149
  message and wait.
@@ -1103,7 +1155,7 @@ var COMMON = {
1103
1155
  var TABLE = {
1104
1156
  login: {
1105
1157
  run: login,
1106
- options: { server: { type: "string" }, code: { type: "string" } }
1158
+ options: { server: { type: "string" } }
1107
1159
  },
1108
1160
  logout: { run: logout },
1109
1161
  whoami: { run: whoami },
@@ -6,7 +6,7 @@ import {
6
6
  init_define_TOBOS_PRESENT_TYPES,
7
7
  init_define_TOBOS_SKILL,
8
8
  init_define_TOBOS_TOOLCHAIN
9
- } from "./chunk-QZRWMMBR.js";
9
+ } from "./chunk-XG2KKGXE.js";
10
10
 
11
11
  // src/render.ts
12
12
  init_define_TOBOS_PRESENT_TYPES();
@@ -3,7 +3,7 @@ import { createRequire as __tobosRequire } from 'node:module';
3
3
  const require = __tobosRequire(import.meta.url);
4
4
  import {
5
5
  parseDeckJson
6
- } from "./chunk-67QAOIEN.js";
6
+ } from "./chunk-T2JISWY5.js";
7
7
  import {
8
8
  CliError,
9
9
  __commonJS,
@@ -14,7 +14,7 @@ import {
14
14
  init_define_TOBOS_PRESENT_TYPES,
15
15
  init_define_TOBOS_SKILL,
16
16
  init_define_TOBOS_TOOLCHAIN
17
- } from "./chunk-QZRWMMBR.js";
17
+ } from "./chunk-XG2KKGXE.js";
18
18
 
19
19
  // ../node_modules/.pnpm/aria-query@5.3.1/node_modules/aria-query/lib/util/iteratorProxy.js
20
20
  var require_iteratorProxy = __commonJS({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tobos/cli",
3
- "version": "0.4.30",
3
+ "version": "0.4.31",
4
4
  "description": "The command line of Tobos: https://tobos.ai",
5
5
  "type": "module",
6
6
  "license": "FSL-1.1-ALv2",