Skip to content

feat: support polling straight from auth login#78

Merged
kreese-stripe merged 3 commits into
mainfrom
kreese/auth-polling
May 21, 2026
Merged

feat: support polling straight from auth login#78
kreese-stripe merged 3 commits into
mainfrom
kreese/auth-polling

Conversation

@kreese-stripe
Copy link
Copy Markdown
Collaborator

@kreese-stripe kreese-stripe commented May 6, 2026

We received feedback (from an agent using link-cli!) that the auth status --interval N --max-attempts M is a long-running blocking command that blocked the agent's I/O, and so they weren't able to relay the code to the human until they stopped polling.

To fix this, we instead allow starting the polling straight from the auth login command

Test Plan:

Old behavior - no changes
Screenshot 2026-05-14 at 10 20 26 AM

Old behavior - no format -> interactive mode
Screenshot 2026-05-14 at 10 22 26 AM

New Behavior - outputs as JSON when formatted
Screenshot 2026-05-14 at 10 20 55 AM
Screenshot 2026-05-14 at 10 23 07 AM

@kreese-stripe kreese-stripe requested a review from a team as a code owner May 6, 2026 18:44

```bash
link-cli auth login --client-name "<your-agent-name>"
link-cli auth login --client-name "<your-agent-name>" --interval 5 --timeout 300
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should make this the default behavior. Agents seem good with the _next output?

const deadline = Date.now() + c.options.timeout * 1000;
let attempts = 0;

while (true) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this code repeated in the other auth polling command?


// Inline polling: emit code to stderr (visible immediately even while
// stdout is buffered), then yield it as structured output for MCP streaming.
process.stderr.write(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be json output/respect the output format

@kreese-stripe kreese-stripe force-pushed the kreese/auth-polling branch from dfcbadf to 734e30c Compare May 12, 2026 17:19
Comment on lines +79 to +86
if (c.format === 'json') {
process.stderr.write(
`${JSON.stringify({ verification_url: authRequest.verification_url_complete, phrase: authRequest.user_code })}\n`,
);
} else {
process.stderr.write(
`\nVerification URL: ${authRequest.verification_url_complete}\nPhrase: ${authRequest.user_code}\n\nOpen the URL, log in to Link, and enter the phrase to approve.\nPolling for approval...\n\n`,
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need this? incur should handle the output format for you, you just need to return the object

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or yield the object

Copy link
Copy Markdown
Contributor

@danhill-stripe danhill-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think we need the sanitizeDeep on the output too

@kreese-stripe kreese-stripe force-pushed the kreese/auth-polling branch from 734e30c to 589b444 Compare May 21, 2026 15:22
timeout: number;
}

async function* pollAuthStatus(
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the same code that was used for auth status as well, just abstracting it into a shared function so the login polling can do the same

@kreese-stripe kreese-stripe merged commit 27b3de9 into main May 21, 2026
5 checks passed
@kreese-stripe kreese-stripe deleted the kreese/auth-polling branch May 21, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants