Add session mode: signing in and adding to the cart.

With cart_mode = "session", dibs signs in to the shop's account and puts
an item in the cart when it fires. The account's cookies are kept apart
from the watcher's and stored encrypted, with the key in the OS keyring.
Without a keyring, they're stored in a file only you can read.

An alert now goes out right away, without a cart link, and a second one
follows once the item is in the cart. If adding fails, the second alert
carries the cart link instead.

Amazon only accepts additions its page scripts have seen, so plugins can
now press a button in headless Chrome with ctx:click.

The TUI asks for one-time codes and shows the plugin's warning about
account locks in a modal. 'dibs login' signs in from a terminal, or
with --browser in a Chrome window, and 'dibs logout' deletes the cookies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
OverlordandClaude Bot committed 2026-10-14 17:26:26 +02:00
1 parent e2cbc1a55c
commit 15a34e1f84
39 files changed
+3529 -163

No files matched your search

+1 -19
View File
@@ -3,7 +3,6 @@ package watch
import (
"context"
"errors"
"fmt"
"math/rand/v2"
"net/url"
@@ -263,7 +262,7 @@ func (s *Scheduler) check(ctx context.Context, t *target) {
resp, err := s.fetcher.Get(ctx, fetchURL)
if ctx.Err() != nil { return }
backoff := RecordOutcome(s.limiter, t.host, resp, err)
backoff := fetch.RecordOutcome(s.limiter, t.host, resp, err)
var report *plugin.Report
if err == nil { report, err = plugin.Evaluate(ctx, p, rawURL, resp) }
@@ -286,23 +285,6 @@ func (s *Scheduler) check(ctx context.Context, t *target) {
}
}
// RecordOutcome tells the limiter how a request to host went: bot checks,
// refusals and failed requests back the host off, anything else clears its
// backoff. It returns the backoff, or 0.
func RecordOutcome(l *ratelimit.Limiter, host string, resp *fetch.Response, err error) time.Duration {
switch {
case errors.Is(err, context.Canceled):
return 0
case err != nil:
return l.Failure(host)
case resp.Verdict == fetch.Challenge || resp.Verdict == fetch.NeedsHuman || resp.Verdict == fetch.Blocked || resp.Verdict == fetch.HTTPError:
return l.Failure(host)
default:
l.Success(host)
return 0
}
}
// Pause pauses or resumes the item called name. It reports whether there is
// such an item.
func (s *Scheduler) Pause(name string, paused bool) bool {