@tobos/cli 0.4.51 → 0.4.52
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/dist/cli.js +9 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -278,7 +278,7 @@ function settings() {
|
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
// src/api.ts
|
|
281
|
-
var VERSION = true ? "0.4.
|
|
281
|
+
var VERSION = true ? "0.4.52" : "dev";
|
|
282
282
|
function newer(a, b) {
|
|
283
283
|
const parse = (v) => /^\d+\.\d+\.\d+/.test(v) ? v.split(".").map((n) => parseInt(n)) : null;
|
|
284
284
|
const x = parse(a);
|
|
@@ -858,7 +858,9 @@ var LOGIN_WAIT_MS = 9e4;
|
|
|
858
858
|
async function login(out, args) {
|
|
859
859
|
const server = (args.values.server || settings().server).replace(/\/$/, "");
|
|
860
860
|
const kept = settings().device;
|
|
861
|
+
const ref = typeof args.values.ref === "string" && args.values.ref ? args.values.ref : void 0;
|
|
861
862
|
let device = kept && kept.server === server && Date.parse(kept.expires) > Date.now() ? kept : void 0;
|
|
863
|
+
if (device && ref && device.ref !== ref) save({ device: device = { ...device, ref } });
|
|
862
864
|
let opened = false;
|
|
863
865
|
if (!device) {
|
|
864
866
|
const started = await api("/oauth/device", {
|
|
@@ -872,7 +874,8 @@ async function login(out, args) {
|
|
|
872
874
|
userCode: started.user_code,
|
|
873
875
|
url: started.verification_uri_complete,
|
|
874
876
|
interval: started.interval,
|
|
875
|
-
expires: new Date(Date.now() + started.expires_in * 1e3).toISOString()
|
|
877
|
+
expires: new Date(Date.now() + started.expires_in * 1e3).toISOString(),
|
|
878
|
+
...ref ? { ref } : {}
|
|
876
879
|
};
|
|
877
880
|
save({ server, device });
|
|
878
881
|
opened = await openUrl(device.url);
|
|
@@ -919,7 +922,8 @@ async function waitForApproval(device, note) {
|
|
|
919
922
|
server: device.server,
|
|
920
923
|
body: {
|
|
921
924
|
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
922
|
-
device_code: device.deviceCode
|
|
925
|
+
device_code: device.deviceCode,
|
|
926
|
+
...device.ref ? { ref: device.ref } : {}
|
|
923
927
|
}
|
|
924
928
|
});
|
|
925
929
|
const answer = await response.json().catch(() => ({}));
|
|
@@ -1610,7 +1614,7 @@ var VERB_ROWS = Object.values(VERBS).flatMap((verb) => verb.cli.map((c) => row(c
|
|
|
1610
1614
|
var HELP = `tobos ${VERSION}: the command line of Tobos, the office suite your coding agent works in.
|
|
1611
1615
|
|
|
1612
1616
|
Account
|
|
1613
|
-
${row("tobos login [--server URL]", "connect this machine: prints an address for the person to open and approve (logging in, or signing up, there); run it again once they did")}
|
|
1617
|
+
${row("tobos login [--server URL] [--ref ID]", "connect this machine: prints an address for the person to open and approve (logging in, or signing up, there); run it again once they did; --ref: the one in the tobos.ai/start address they gave you")}
|
|
1614
1618
|
${row("tobos logout", "forget this machine's token")}
|
|
1615
1619
|
${row("tobos whoami", "who you are, on which server")}
|
|
1616
1620
|
|
|
@@ -1672,7 +1676,7 @@ var COMMON = {
|
|
|
1672
1676
|
var TABLE = {
|
|
1673
1677
|
login: {
|
|
1674
1678
|
run: login,
|
|
1675
|
-
options: { server: { type: "string" } }
|
|
1679
|
+
options: { server: { type: "string" }, ref: { type: "string" } }
|
|
1676
1680
|
},
|
|
1677
1681
|
logout: { run: logout },
|
|
1678
1682
|
whoami: { run: whoami },
|