Let scheduled jobs call connector tools the owner approved

Aperta
#132 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
github, go, kubernetes

Direzione di ricerca

Start with the connector token policy in internal/connectors/caller.go:44-50 and decision D15 in docs/superpowers/plans/2026-11-26-connectors.md:86, then trace job token creation in internal/gateway/jobs/jobs.go and internal/controller/jobs/reconciler.go. The issue proposes per-job grants approved in a plan, scoped to admin-approved read tools, plus clear failures and notices when a connection needs reauthorization. Done means the acceptance flow works with one approval and run history reports connector failures.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

type: enhancement 💅🏼

Summary

A user who has connected the GitHub connector should be able to say "every night at 3am, refresh my checklist with my GitHub reviews", approve one plan, and have it run as a normal job with run history and failure notices. Today they can't, because a scheduled job cannot call a connector tool.

We tried this on powershift (2026-12-04) with a pi coding agent. It worked only because a platform admin drove it. The workaround is a sync script that calls github__search_issues through the agent helper, plus a home-made 03:00 daemon with a lock file, started by a pi extension inside an interactive app that has to stay up. A non-technical user could not have built that, and its failures never reach the Jobs UI.

What the code says today (checked on main at c7fa2b9)

Claim from the session Verdict Where
Jobs cannot call connectors Confirmed, and it's on purpose. Caller.MayUseConnectors accepts only a personal token or a coding agent app's token. Job tokens are refused because "the job's code could make it act". internal/connectors/caller.go:44-50, decision D15 in docs/superpowers/plans/2026-11-26-connectors.md:86
JobBody has no apiAccess, so jobs never get a token Partly wrong. There's no per-job field, but a job gets its owner's API token when its template sets apiToken: true (model.DefaultAPIAccess). jobs-python doesn't set it. Only backup, chat, claude-code and pi do. A job token still could not reach connectors (row above). internal/gateway/jobs/jobs.go:80-100, internal/controller/jobs/reconciler.go:1034-1040, deploy/helm/javo/files/templates/*.yaml
No REST route calls a connector tool; only the in-pod helper at 127.0.0.1:7690/mcp does Wrong. The gateway serves connector tools on its own /mcp endpoint (internal/mcp). The agent helper just forwards to it with the app's JAVO_TOKEN. The real limit is which token is accepted, not where the endpoint is. internal/agenthelper/agenthelper.go:40-41, internal/mcp/server.go:45
The helper uses the offline token Tapas collects at sign-in Wrong. Connector calls use the person's own OAuth connection to that connector, sealed in the vault and refreshed with its refresh token. The sign-in offline token (agenttoken broker, /api/auth/agent-access) is used for platform services such as Frames, not for connectors. So a nightly run's lifetime depends on the GitHub connection's refresh token, not on the person's Tapas sign-in. internal/connectors/broker/token.go:28-38, internal/connectors/vault/vault.go:171-182, internal/gateway/agenttoken/agenttoken.go
No one can see whether the credential will still work at 03:00 Mostly wrong, for connectors. GET /api/connectors shows the person's connection status (active or needs_reauth). It doesn't show the expiry, and nothing alerts anyone when a scheduled use fails. /api/auth/agent-access is browser-session only, as reported, but connectors don't depend on it. internal/gateway/connectors/member.go:54, internal/gateway/authn/agentaccess.go:99-125
Agents can't attach secrets, and starting an app that holds a token needs a plan Confirmed, by design. MsgAgentNeedsPerson in internal/reasons/messages.go:721
Read-only tools like get_me and list_pull_requests asked for approval while search_issues didn't Confirmed, and it's configuration. A tool runs without approval only if an admin set it to read. Any tool without a mode defaults to write. The server's ReadOnlyHint only prefills the admin's choice. On powershift the GitHub connector's tool modes are incomplete. internal/connectors/connectors.go:18-38, 93-98
The agent guide says nothing about connectors in jobs Confirmed. "Jobs and schedules" covers cron jobs only, and no section mentions connectors. internal/controller/workspace/agents_guide.md:237-253
node missing from custom and jobs-python, and backend-node treats file as the script Not checked in the code. Reported from failed runs.

The core gap

D15 refuses job tokens for a good reason: if any job token could call connectors, any code in a job could act through the owner's connections. Closing this gap needs a narrower grant that the owner approves for a specific job, not a reversal of D15.

Proposed direction (for discussion)

  1. Connector grants for each job, approved in a plan. Add an optional field to the job, for example connectors: [{connector: "github", tools: ["search_issues"]}], limited to tools the admin has set to read. Approving the plan that creates or changes the job approves the grant. The job's token may then call exactly those tools on the gateway /mcp endpoint, as the owner, and nothing else. This keeps jobs as the only scheduler.
    • Changing the grant invalidates the approval, like changing a secret does today.
    • Runs record which tools were called.
  2. Fail runs clearly when the connection lapses. A run that gets ErrNotConnected or needs_reauth fails with a specific reason (for example ConnectorNotConnected) and uses the job's existing notify path, saying "reconnect GitHub at /settings/connections". Show the dependency on the job page.
  3. Docs and smaller fixes.
    • Add a section to agents_guide.md on scheduled work that uses connectors, once (1) exists.
    • Admin guidance or a default for read-only tool modes (for example, accept ReadOnlyHint for well-known connectors), so read calls don't leave stray approval requests.
    • Return connector rate limits (GitHub search allows 30 a minute) as a structured error, not a bare 403.
    • Check whether node belongs in a jobs template, and document what file means for backend-node.

Out of scope for now: a general "scheduled agent prompt" (headless pi -p on a schedule). It's more general but spends model tokens on every run, and (1) covers this use case with a plain script.

Acceptance

A user with GitHub connected sets up the nightly sync with:

  • no PAT and no secret
  • no folder grants
  • no long-running app
  • exactly one approval

Run history is visible in the Jobs UI, and a lapsed GitHub connection shows up there as a clear failure with a notice.

Lingua principale
Go
Stelle
5
Fork
0
Merge medio
21h 13m
PR unite (30g)
53

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nebari-dev/tapas

Tutte le issue di nebari-dev/tapas

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.