mirror of
https://github.com/cloudflare/cloudflare-os.git
synced 2026-11-23 01:58:45 +08:00
The kernel and gatekeeper changes that #860's pnpm cf-os api CLI needs, split out of it so they can be reviewed apart from the CLI and its generator. #860 is stacked on this. New API method Overseer.waitForAgent(chatId) waits for the agent's turn in a chat to end and returns the latest message the agent wrote: its reply, the error that ended the turn, or what it stopped to wait on. A client that drives a chat without subscribing to it, such as a one-shot command, otherwise cannot tell when the reply is in. It is currently only used by the agents driving CLI A CLI limit on deployments cf-os api sends User-Agent: cf-os-api/<version>. This PR makes it so that on a deployment only the deployment administrator can use the CLI in non-dev environments by reading it off the user-agent header. This is really just a best effort check, and obviously wouldn't block someone who just changes the user-agent header, but this is mostly just meant to discourage non administrators from using it. You could easily just hand a browser to your agent, and they can go and interact with the browser and bypass all of our approval policies and stuff anyhow. API docs A pass over api.ts's doc comments, and over the Context Library and Scheduled Tasks app UI interfaces, for readers that know the API only from its docs, such as agents and command-line clients. It also adds JSDoc tags that tools reading the API can act on: @secret, @nullWhen, @reportsId and @appApi. The Scheduled Tasks app's capability gets a ScheduleManagementApi interface, which its RpcTarget implements.