Skip to content

feat: support polling straight from auth login#78

Open
kreese-stripe wants to merge 2 commits into
mainfrom
kreese/auth-polling
Open

feat: support polling straight from auth login#78
kreese-stripe wants to merge 2 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants