@porte/cli 0.1.4 → 0.1.5

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/main.js CHANGED
@@ -11,7 +11,7 @@ setLogSink((_level, line) => {
11
11
  });
12
12
  const verbose = process.argv.includes("--verbose") || process.argv.includes("-v");
13
13
  process.env.LOG_LEVEL ??= verbose ? "DEBUG" : "WARN";
14
- const { run } = await import("./run-cli-DanRHSxL.js");
14
+ const { run } = await import("./run-cli-cm8fOj7d.js");
15
15
  const code = await run(process.argv.slice(2), {
16
16
  stdout: process.stdout,
17
17
  stderr: process.stderr,
@@ -168,7 +168,7 @@ var WebSocketHandlerError = class extends h("WebSocketHandlerError") {
168
168
  //#endregion
169
169
  //#region src/entrypoints/cli/version.ts
170
170
  /** Package version. Source is `package.json`. */
171
- const VERSION = "0.1.4";
171
+ const VERSION = "0.1.5";
172
172
  //#endregion
173
173
  //#region src/entrypoints/cli/cli-error.ts
174
174
  /** Bad arguments or missing required flags. */
@@ -373,9 +373,11 @@ async function pairHost(input) {
373
373
  async function waitForApproval(input, grant) {
374
374
  const deadline = input.now() + grant.expiresInSeconds * 1e3;
375
375
  let intervalSeconds = grant.intervalSeconds;
376
+ let attempt = 0;
376
377
  while (input.now() < deadline) {
377
378
  await input.sleep(intervalSeconds * 1e3);
378
379
  const answer = await input.authorizer.poll(grant.deviceCode);
380
+ attempt += 1;
379
381
  if (answer.status === "granted") return {
380
382
  status: "paired",
381
383
  token: answer.token
@@ -383,6 +385,10 @@ async function waitForApproval(input, grant) {
383
385
  if (answer.status === "denied") return { status: "denied" };
384
386
  if (answer.status === "expired") return { status: "expired" };
385
387
  if (answer.status === "slow-down") intervalSeconds += answer.intervalSeconds;
388
+ input.onPoll?.({
389
+ attempt,
390
+ intervalSeconds
391
+ });
386
392
  }
387
393
  return { status: "expired" };
388
394
  }
@@ -717,20 +723,26 @@ async function runPairCommand(input) {
717
723
  const { code, url, quiet, strong, ok } = output.emphasis;
718
724
  const interactive = process.stdin.isTTY;
719
725
  let stopWatching;
726
+ let showingWait = false;
727
+ let lastPoll;
728
+ const waiting = (poll) => quiet(poll === void 0 ? `Waiting for approval — checking with Porte… ${WAITING_EMOJI}` : `Waiting for approval — checking with Porte every ${String(poll.intervalSeconds)}s (${String(poll.attempt)} so far) ${WAITING_EMOJI}`);
720
729
  const paired = await pairHost({
721
730
  authorizer: resources.authorizer,
722
731
  credentials: resources.credentials,
723
732
  baseUrl: input.config.baseUrl,
724
733
  host: describeThisMachine(),
734
+ onPoll: (poll) => {
735
+ lastPoll = poll;
736
+ if (showingWait) output.status(waiting(poll));
737
+ },
725
738
  onPrompt: (prompt) => {
726
739
  const shown = formatPairingCode(prompt.userCode);
727
- const waiting = `Waiting for approval — the code expires in ${String(Math.round(prompt.expiresInSeconds / 60))} minutes. ${WAITING_EMOJI}`;
728
740
  output.title("Pair this machine with Porte", PAIR_EMOJI);
729
741
  if (!interactive) {
730
742
  output.raw(`First copy your pairing code: ${code(shown)}`);
731
743
  output.raw(`Then open ${url(prompt.verificationUri)} in your browser.`);
732
744
  output.blank();
733
- output.raw(quiet(waiting));
745
+ output.raw(waiting(void 0));
734
746
  return;
735
747
  }
736
748
  const codeLine = (hint) => `First copy your pairing code: ${code(shown)} ${hint}`;
@@ -742,7 +754,8 @@ async function runPairCommand(input) {
742
754
  stopWatching?.();
743
755
  output.blank();
744
756
  output.blank();
745
- output.raw(quiet(waiting));
757
+ showingWait = true;
758
+ output.status(waiting(lastPoll));
746
759
  openUrl(prompt.verificationUri);
747
760
  return;
748
761
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://www.schemastore.org/package.json",
3
3
  "name": "@porte/cli",
4
- "version": "0.1.4",
4
+ "version": "0.1.5",
5
5
  "description": "Run your local Grok sessions from your phone. The daemon that pairs a machine with useporte.dev.",
6
6
  "keywords": [
7
7
  "acp",