cloudflare / cloudflare/agents

gitTools support for lazy auth

Open
#1,574 0 comments 0 reactions 1 assignee Claimed by @aron-cf View on GitHub
enhancement
Dominant language
TypeScript
Stars
5.6k
Forks
711
Avg merge
1d 20h
Merged PRs (30d)
53

Description

It would be nice to be able to do something like this:

```ts
gitTools(workspace, {
auth: async ({ command, url, remote, dir }) => {
const repo = command === "clone"
? parseRepoFromUrl(url)
: await parseRepoFromRemote(dir, remote ?? "origin");

if (!repo || !allowedRepos.has(repo)) return null;

return { token: await issueFreshInstallationToken(repo) };
},
});
```

Right now `gitTools()` accepts static `token` / `auth` when the provider is created:

https://github.com/cloudflare/agents/blob/main/packages/shell/src/git/provider.ts#L144-L162

That makes GitHub App installation tokens awkward for long-running Think agents. The token is async to issue, short-lived, and repo-scoped. We also don't want to put it in model-visible tool arguments.

It would be nice if this basically worked like git credential-helper behavior: the model calls `git.clone`, `git.fetch`, or `git.push` normally, and the runtime provides the right credential at the time of the operation.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.