sinatra.dev 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -3
- package/dist/client.js +10 -2
- package/dist/commands.js +177 -22
- package/dist/index.js +8 -0
- package/dist/recurring.js +132 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -122,7 +122,11 @@ sinatra logout # end the sign-in (or revoke the
|
|
|
122
122
|
| `sinatra repo <owner/name> secrets delete <name>` | `-w`, `--json`, `--yes` / `-y` |
|
|
123
123
|
| `sinatra repo <owner/name> env` | `-w`, `--json`: feature-gated environment status and updates |
|
|
124
124
|
| `sinatra repo <owner/name> capability-requests` | `-w`, `--json`: feature-gated access requests |
|
|
125
|
+
| `sinatra repo <owner/name> capability-requests dismiss <request-id>` | Owner/admin only; `-w`, `--json`, `--yes` / `-y` |
|
|
125
126
|
| `sinatra connect <github\|linear\|slack\|telegram>` | `-w`, `--json`, `--timeout <minutes>` |
|
|
127
|
+
| `sinatra connectors [list]` | `-w`, `--json` |
|
|
128
|
+
| `sinatra connectors connect <connector>` | Owner/admin only; `--project <ref>`, `--name <label>`, `--token` (hidden prompt or stdin only), `--accept`, `-w`, `--json` |
|
|
129
|
+
| `sinatra connectors disconnect <connection-id>` | Owner/admin only; `-w`, `--json`, `--yes` / `-y` |
|
|
126
130
|
| `sinatra model [get]` | `-w`, `--json` |
|
|
127
131
|
| `sinatra model set <model>` | `--engine <engine>` (required), `--effort <effort>` (optional), `-w`, `--json` |
|
|
128
132
|
| `sinatra model clear` | `-w`, `--json`, `--yes` / `-y` |
|
|
@@ -149,6 +153,7 @@ sinatra repo acme/widget secrets update REGISTRY_TOKEN --header Authorization --
|
|
|
149
153
|
sinatra repo acme/widget secrets delete REGISTRY_TOKEN --yes
|
|
150
154
|
sinatra repo acme/widget env --json
|
|
151
155
|
sinatra repo acme/widget capability-requests
|
|
156
|
+
sinatra repo acme/widget capability-requests dismiss <request-id> --yes
|
|
152
157
|
```
|
|
153
158
|
|
|
154
159
|
Repository names resolve within the selected workspace; `repos` prints the same connected
|
|
@@ -159,13 +164,22 @@ The fragment file is a JSON object directly, for example `{ "agent": { "max_turn
|
|
|
159
164
|
Preflight checks it without saving; override set/clear affects only your own preferences.
|
|
160
165
|
Engine and model overrides are not accepted here: use Models settings.
|
|
161
166
|
|
|
162
|
-
Members can read config, secret metadata, environment status and
|
|
163
|
-
manage their own overrides. Secret set, rotate, metadata update and delete
|
|
164
|
-
|
|
167
|
+
Members can read config, secret metadata, environment status and access requests, and
|
|
168
|
+
manage their own overrides. Secret set, rotate, metadata update and delete, and access request
|
|
169
|
+
dismissal require an admin or owner. Dismissal requires confirmation (or `--yes`) and keeps the
|
|
170
|
+
request dismissed on later reports of the same need. Secret values come only from a hidden
|
|
171
|
+
prompt or one line on stdin, never argv or
|
|
165
172
|
flags. Set needs at least one `--host`; rotate preserves omitted metadata. Update changes
|
|
166
173
|
hosts/header/prefix without reading a value. Environment reads retain the workspace feature gate.
|
|
167
174
|
Repository secret input preserves spaces and Unicode; stdin consumes one line without its line delimiter.
|
|
168
175
|
|
|
176
|
+
For each open or repair-needed access request, human output shows the summary, the agent's
|
|
177
|
+
reason, the command that adds the secret (when a secret can satisfy the request) and the
|
|
178
|
+
command that dismisses the request. Run the command in your own terminal; enter the secret at
|
|
179
|
+
the hidden prompt or pipe it on stdin from your secret manager. Never send the value through a
|
|
180
|
+
model, chat, command argument or flag. Tasks keep running without the secret; a saved secret is
|
|
181
|
+
used from the next agent run. A dismissed request does not come back.
|
|
182
|
+
|
|
169
183
|
Clear and delete ask for terminal confirmation; scripts require `--yes` (or `-y`).
|
|
170
184
|
Declining or running noninteractively without explicit consent sends no mutation. Prompts
|
|
171
185
|
go to stderr, including with `--json`, and piped secret input never counts as confirmation.
|
|
@@ -248,6 +262,32 @@ If no browser opens, open the printed URL manually. `--json` prints only the raw
|
|
|
248
262
|
`{ "url": "…" }` response, without opening a browser or polling. Check status separately
|
|
249
263
|
with `sinatra workspace show --json`.
|
|
250
264
|
|
|
265
|
+
### Connectors
|
|
266
|
+
|
|
267
|
+
```sh
|
|
268
|
+
sinatra connectors
|
|
269
|
+
sinatra connectors connect neon --project <project-id>
|
|
270
|
+
echo "$POSTHOG_KEY" | sinatra connectors connect posthog --token --accept
|
|
271
|
+
sinatra connectors disconnect <connection-id>
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Connectors give the workspace's agents read access to services you already use, such as Neon,
|
|
275
|
+
Supabase, PostHog, Sentry, PlanetScale, Cloudflare, Notion and Vercel, through each provider's
|
|
276
|
+
hosted MCP server. `sinatra connectors` lists the services and the workspace's connections; any
|
|
277
|
+
member can read it, and no token is ever shown.
|
|
278
|
+
|
|
279
|
+
For a service you sign in to, `connectors connect` prints a dashboard link. A workspace owner or
|
|
280
|
+
admin opens it, signs in at the provider and accepts the warning there; at a terminal the CLI
|
|
281
|
+
then waits up to 10 minutes for the connection to appear. For a service that takes a token,
|
|
282
|
+
`--token` reads it at a hidden prompt or from stdin, shows the warning and asks you to accept it;
|
|
283
|
+
`--accept` accepts it without a prompt. Never put a token on the command line. Sinatra does not
|
|
284
|
+
guarantee read-only access: what an agent can do is limited by the token or by what you approve
|
|
285
|
+
at the provider.
|
|
286
|
+
|
|
287
|
+
`connectors disconnect` removes the connection and its stored token. For a pasted token, revoke
|
|
288
|
+
it at the provider too; the CLI says when something stays authorized there.
|
|
289
|
+
See [Connectors](https://docs.sinatra.dev/docs/configuration/connectors) for each service.
|
|
290
|
+
|
|
251
291
|
### Workspace access
|
|
252
292
|
|
|
253
293
|
Owners can manage workspace access with the same permissions as the dashboard:
|
package/dist/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The task API (`/v1`) as the CLI uses it. Task mutations carry an Idempotency-Key so retries
|
|
3
|
-
* cannot start duplicate tasks or messages. Workspace access mutations have
|
|
4
|
-
* idempotency contract and are never
|
|
3
|
+
* cannot start duplicate tasks or messages. Workspace access and recurring-task mutations have
|
|
4
|
+
* no server idempotency contract and are never retried after network or server failures.
|
|
5
5
|
*/
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
7
|
import { CLI_VERSION } from "./version.js";
|
|
@@ -106,6 +106,14 @@ export function createClient(options) {
|
|
|
106
106
|
/** Carries a provider token: only in the body, and through the path that keeps no server detail. */
|
|
107
107
|
connectConnector: (workspaceId, body) => keyRequest("POST", `/v1/workspaces/${encodeURIComponent(workspaceId)}/connectors`, body),
|
|
108
108
|
disconnectConnector: (workspaceId, connectionId) => request("DELETE", `/v1/workspaces/${encodeURIComponent(workspaceId)}/connectors/${encodeURIComponent(connectionId)}`, undefined, false),
|
|
109
|
+
listRecurringTasks: (workspaceId) => request("GET", `/v1/workspaces/${encodeURIComponent(workspaceId)}/recurring-tasks`),
|
|
110
|
+
getRecurringTask: (workspaceId, taskId) => request("GET", `/v1/workspaces/${encodeURIComponent(workspaceId)}/recurring-tasks/${encodeURIComponent(taskId)}`),
|
|
111
|
+
createRecurringTask: (workspaceId, body) => request("POST", `/v1/workspaces/${encodeURIComponent(workspaceId)}/recurring-tasks`, body, false),
|
|
112
|
+
updateRecurringTask: (workspaceId, taskId, body) => request("PATCH", `/v1/workspaces/${encodeURIComponent(workspaceId)}/recurring-tasks/${encodeURIComponent(taskId)}`, body, false),
|
|
113
|
+
pauseRecurringTask: (workspaceId, taskId) => request("POST", `/v1/workspaces/${encodeURIComponent(workspaceId)}/recurring-tasks/${encodeURIComponent(taskId)}/pause`, undefined, false),
|
|
114
|
+
resumeRecurringTask: (workspaceId, taskId) => request("POST", `/v1/workspaces/${encodeURIComponent(workspaceId)}/recurring-tasks/${encodeURIComponent(taskId)}/resume`, undefined, false),
|
|
115
|
+
runRecurringTask: (workspaceId, taskId) => request("POST", `/v1/workspaces/${encodeURIComponent(workspaceId)}/recurring-tasks/${encodeURIComponent(taskId)}/run`, undefined, false),
|
|
116
|
+
deleteRecurringTask: (workspaceId, taskId) => request("DELETE", `/v1/workspaces/${encodeURIComponent(workspaceId)}/recurring-tasks/${encodeURIComponent(taskId)}`, undefined, false),
|
|
109
117
|
getModelDefault: (workspaceId) => request("GET", `/v1/workspaces/${encodeURIComponent(workspaceId)}/model-default`),
|
|
110
118
|
setModelDefault: (workspaceId, selection) => request("PUT", `/v1/workspaces/${encodeURIComponent(workspaceId)}/model-default`, selection, false),
|
|
111
119
|
clearModelDefault: (workspaceId) => request("DELETE", `/v1/workspaces/${encodeURIComponent(workspaceId)}/model-default`, undefined, false),
|
package/dist/commands.js
CHANGED
|
@@ -26,10 +26,10 @@ export class UsageError extends Error {
|
|
|
26
26
|
const TASK_ID = /^[a-z0-9][a-z0-9_-]{19,63}$/;
|
|
27
27
|
const SUBSCRIPTIONS_USAGE = "Usage: sinatra subscriptions [list | connect <codex|claude|xai|cursor> | remove <id>] [--json] [-w <id>]. Paste Claude's authorization code at the hidden prompt or through stdin, never on the command line.";
|
|
28
28
|
const CONNECT_USAGE = "Usage: sinatra connect <github|linear|slack|telegram> [-w <id>] [--timeout <minutes>] [--json]. Authorization happens in your browser; never supply secrets on the command line.";
|
|
29
|
-
// Connectors are unlisted: this is the only place the group's usage is said, and USAGE never names it.
|
|
30
29
|
const CONNECTORS_USAGE = "Usage: sinatra connectors [list | connect <connector> [--project <ref>] [--name <label>] [--token] [--accept] | disconnect <connection-id> [--yes]] [-w <id>] [--json]. --project is needed only by services that take a project reference. Without --token or --accept, a service you can sign in to gives a link to the dashboard, where a workspace owner or admin signs in and accepts the warning; --token, or --accept to accept the terms without a prompt, pastes a token instead, for a service that takes one. Paste a token at the hidden prompt or pipe it on stdin, never on the command line.";
|
|
31
30
|
const WORKSPACE_CREATE_USAGE = 'Usage: sinatra workspace create "<name>" [--json]. Quote a name with spaces.';
|
|
32
|
-
const REPO_USAGE = "Usage: sinatra repo <owner/name> config [preflight --file <json>] | override set --file <json> | override clear [--yes] | secrets [list | set <name> --host <host> | rotate <name> | update <name> | delete <name> --yes] | env | capability-requests | review-external-prs [inherit|on|off] [-w <id>] [--json]. Secret values belong only at the hidden prompt or on stdin, never in arguments or flags.";
|
|
31
|
+
const REPO_USAGE = "Usage: sinatra repo <owner/name> config [preflight --file <json>] | override set --file <json> | override clear [--yes] | secrets [list | set <name> --host <host> | rotate <name> | update <name> | delete <name> --yes] | env | capability-requests [dismiss <request-id> [--yes]] | review-external-prs [inherit|on|off] [-w <id>] [--json]. Secret values belong only at the hidden prompt or on stdin, never in arguments or flags.";
|
|
32
|
+
const RECURRING_USAGE = 'Usage: sinatra recurring [list | show <id> | create "<prompt>" --at <HH:MM> [--at <HH:MM> …] | edit <id> [--prompt <prompt>] | pause <id> | resume <id> | run <id> | delete <id> [--yes]] [--weekdays mon,wed | --day-of-month <1-28>] [--timezone <IANA zone>] [--name <name>] [--no-email] [-w <id>] [--json].';
|
|
33
33
|
/** The help text. Unlisted command groups stay out of it. */
|
|
34
34
|
export const USAGE = `Usage:
|
|
35
35
|
sinatra login [--api-url <url>] [-w <id>] [--no-browser | --token]
|
|
@@ -43,7 +43,7 @@ export const USAGE = `Usage:
|
|
|
43
43
|
-f, --file <path> Attach a text file (repeatable, 80KB total)
|
|
44
44
|
-t, --title <title> Task title (default: the prompt's first line)
|
|
45
45
|
-m, --model <model> Model for every agent, such as openai-codex/gpt-6.1-sol
|
|
46
|
-
(default:
|
|
46
|
+
(default: your default or the workspace default)
|
|
47
47
|
--timeout <minutes> Stop following after this long (default 30)
|
|
48
48
|
--no-wait Start it and return
|
|
49
49
|
--json With --no-wait: print the started task as JSON
|
|
@@ -91,12 +91,14 @@ export const USAGE = `Usage:
|
|
|
91
91
|
PATCH metadata without changing the secret value
|
|
92
92
|
--host <host> Allowed host (repeatable; replaces hosts on update)
|
|
93
93
|
--header <header> --prefix <prefix> Optional proxy metadata for set, rotate or update
|
|
94
|
-
--capability-request <id> Fulfill
|
|
94
|
+
--capability-request <id> Fulfill an access request with set or rotate
|
|
95
95
|
sinatra repo <owner/name> secrets delete <name> [--yes]
|
|
96
96
|
Delete a secret (confirmation required)
|
|
97
97
|
sinatra repo <owner/name> env Read the feature-gated repository environment
|
|
98
98
|
sinatra repo <owner/name> capability-requests
|
|
99
|
-
|
|
99
|
+
List access requests
|
|
100
|
+
sinatra repo <owner/name> capability-requests dismiss <request-id> [--yes]
|
|
101
|
+
Dismiss an access request (owner/admin; confirmation required)
|
|
100
102
|
sinatra repo <owner/name> review-external-prs [inherit|on|off]
|
|
101
103
|
Read or set external PR reviews (writes: owner/admin)
|
|
102
104
|
All repos/repo commands take -w and --json
|
|
@@ -119,6 +121,17 @@ export const USAGE = `Usage:
|
|
|
119
121
|
for connection (--json returns only the URL response)
|
|
120
122
|
Browser commands always print the URL; --json returns
|
|
121
123
|
only the response without opening a browser
|
|
124
|
+
sinatra connectors [list] [--json] List the services agents can read through (Neon, Supabase,
|
|
125
|
+
PostHog and more) and the workspace's connections
|
|
126
|
+
sinatra connectors connect <connector> [--project <ref>] [--name <label>]
|
|
127
|
+
Print the dashboard link where you sign in at the provider
|
|
128
|
+
and accept the warning (owner/admin)
|
|
129
|
+
--token Paste a provider token instead, at a hidden prompt or from
|
|
130
|
+
stdin (owner/admin; never on the command line)
|
|
131
|
+
--accept Paste a token and accept the warning without a prompt
|
|
132
|
+
sinatra connectors disconnect <connection-id> [--yes]
|
|
133
|
+
Disconnect a service (owner/admin; confirmation required)
|
|
134
|
+
Connectors commands take -w and --json
|
|
122
135
|
sinatra members list [--json] List members, pending invites and access requests
|
|
123
136
|
sinatra invite <email> --role <role> Invite a member or admin
|
|
124
137
|
sinatra invite resend <invite-id> Resend an invitation
|
|
@@ -132,7 +145,7 @@ export const USAGE = `Usage:
|
|
|
132
145
|
sinatra workspace leave Leave the workspace (confirmation required)
|
|
133
146
|
--role <member|admin> Role to grant; owner is never a grantable role
|
|
134
147
|
--yes, -y Skip confirmation for destructive access actions, model clear,
|
|
135
|
-
keys remove, repo override clear
|
|
148
|
+
keys remove, repo override clear, repo secrets delete or request dismissal;
|
|
136
149
|
never pass keys or secret values in argv
|
|
137
150
|
Access commands take -w and --json; owner-only except leave
|
|
138
151
|
sinatra workspace create "<name>" [--json]
|
|
@@ -146,7 +159,7 @@ export const USAGE = `Usage:
|
|
|
146
159
|
sinatra -v, --version Print the CLI's version
|
|
147
160
|
|
|
148
161
|
-w, --workspace <id> Workspace for task, access, subscription, workspace settings,
|
|
149
|
-
model, keys, repos, repo or
|
|
162
|
+
model, keys, repos, repo, billing or connectors commands, or default to save at login
|
|
150
163
|
(default: yours from login or \`sinatra workspace\`)
|
|
151
164
|
Account and email preferences need no workspace membership or default workspace.
|
|
152
165
|
|
|
@@ -172,6 +185,19 @@ export function parseCommand(positionals) {
|
|
|
172
185
|
}
|
|
173
186
|
return usage("Usage: sinatra workspace review-external-prs [on|off] [-w <id>] [--json]");
|
|
174
187
|
}
|
|
188
|
+
if (first === "recurring") {
|
|
189
|
+
if (rest.length === 0 || (rest.length === 1 && rest[0] === "list"))
|
|
190
|
+
return { name: "recurring", action: "list" };
|
|
191
|
+
const [action, target] = rest;
|
|
192
|
+
if (rest.length === 2 && target?.trim()) {
|
|
193
|
+
if (action === "create")
|
|
194
|
+
return { name: "recurring", action, prompt: target };
|
|
195
|
+
if (action === "show" || action === "edit" || action === "pause" || action === "resume" || action === "run" || action === "delete") {
|
|
196
|
+
return { name: "recurring", action, taskId: target };
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return usage(RECURRING_USAGE);
|
|
200
|
+
}
|
|
175
201
|
// Only the group's own shapes count (`sinatra connectors keep timing out` is still a task), but a
|
|
176
202
|
// malformed connect or disconnect is its usage, never a task: a mistyped connect could carry a token.
|
|
177
203
|
if (first === "connectors" && connectorsShape(rest)) {
|
|
@@ -200,6 +226,9 @@ export function parseCommand(positionals) {
|
|
|
200
226
|
if (rest.length === 2 && ["config", "env", "capability-requests"].includes(section)) {
|
|
201
227
|
return { name: "repo", repoName, action: section };
|
|
202
228
|
}
|
|
229
|
+
if (section === "capability-requests" && action === "dismiss" && rest.length === 4 && secretName?.trim()) {
|
|
230
|
+
return { name: "repo", repoName, action: "capability-dismiss", requestId: secretName };
|
|
231
|
+
}
|
|
203
232
|
if (rest.length === 3 && section === "config" && action === "preflight")
|
|
204
233
|
return { name: "repo", repoName, action: "preflight" };
|
|
205
234
|
if (rest.length === 3 && section === "override" && (action === "set" || action === "clear"))
|
|
@@ -360,7 +389,7 @@ const OPTIONS = {
|
|
|
360
389
|
help: { type: "boolean", short: "h" },
|
|
361
390
|
};
|
|
362
391
|
/**
|
|
363
|
-
* Options only `sinatra connectors` reads. They are parsed only for that
|
|
392
|
+
* Options only `sinatra connectors` reads. They are parsed only for that group, so every
|
|
364
393
|
* other command answers them exactly as it did before (`Unknown option --project.`).
|
|
365
394
|
*/
|
|
366
395
|
const CONNECTOR_OPTIONS = {
|
|
@@ -368,6 +397,15 @@ const CONNECTOR_OPTIONS = {
|
|
|
368
397
|
name: { type: "string" },
|
|
369
398
|
accept: { type: "boolean" },
|
|
370
399
|
};
|
|
400
|
+
const RECURRING_OPTIONS = {
|
|
401
|
+
at: { type: "string", multiple: true },
|
|
402
|
+
weekdays: { type: "string" },
|
|
403
|
+
"day-of-month": { type: "string" },
|
|
404
|
+
timezone: { type: "string" },
|
|
405
|
+
name: { type: "string" },
|
|
406
|
+
prompt: { type: "string" },
|
|
407
|
+
"no-email": { type: "boolean" },
|
|
408
|
+
};
|
|
371
409
|
/** The commands each option means something to; given to any other, it's a mistake. */
|
|
372
410
|
const APPLIES_TO = {
|
|
373
411
|
repo: ["start", "tickets"],
|
|
@@ -375,10 +413,10 @@ const APPLIES_TO = {
|
|
|
375
413
|
file: ["start", "reply", "repo"],
|
|
376
414
|
title: ["start"],
|
|
377
415
|
model: ["start"],
|
|
378
|
-
workspace: ["start", "reply", "show", "workspace-show", "workspace-pr-review", "tasks", "stop", "tickets", "delegate", "login", "access", "subscriptions", "model", "keys", "billing", "connect", "connectors", "repos", "repo"],
|
|
416
|
+
workspace: ["start", "reply", "show", "workspace-show", "workspace-pr-review", "tasks", "stop", "tickets", "delegate", "login", "access", "subscriptions", "model", "keys", "billing", "connect", "connectors", "repos", "repo", "recurring"],
|
|
379
417
|
"no-wait": ["start", "reply"],
|
|
380
418
|
timeout: ["start", "reply", "connect"],
|
|
381
|
-
json: ["whoami", "account", "email-preferences", "tasks", "show", "workspace-show", "workspace-create", "workspace-pr-review", "start", "reply", "tickets", "access", "subscriptions", "model", "keys", "billing", "connect", "connectors", "repos", "repo"],
|
|
419
|
+
json: ["whoami", "account", "email-preferences", "tasks", "show", "workspace-show", "workspace-create", "workspace-pr-review", "start", "reply", "tickets", "access", "subscriptions", "model", "keys", "billing", "connect", "connectors", "repos", "repo", "recurring"],
|
|
382
420
|
"setup-reminders": ["email-preferences"],
|
|
383
421
|
"task-alerts": ["email-preferences"],
|
|
384
422
|
status: ["tasks"],
|
|
@@ -387,7 +425,7 @@ const APPLIES_TO = {
|
|
|
387
425
|
token: ["login", "connectors"],
|
|
388
426
|
"no-browser": ["login", "subscriptions"],
|
|
389
427
|
role: ["access"],
|
|
390
|
-
yes: ["access", "model", "keys", "repo", "connectors"],
|
|
428
|
+
yes: ["access", "model", "keys", "repo", "connectors", "recurring"],
|
|
391
429
|
engine: ["model"],
|
|
392
430
|
effort: ["model"],
|
|
393
431
|
plan: ["billing"],
|
|
@@ -396,15 +434,22 @@ const APPLIES_TO = {
|
|
|
396
434
|
prefix: ["repo"],
|
|
397
435
|
"capability-request": ["repo"],
|
|
398
436
|
project: ["connectors"],
|
|
399
|
-
name: ["connectors"],
|
|
437
|
+
name: ["connectors", "recurring"],
|
|
400
438
|
accept: ["connectors"],
|
|
439
|
+
at: ["recurring"],
|
|
440
|
+
weekdays: ["recurring"],
|
|
441
|
+
"day-of-month": ["recurring"],
|
|
442
|
+
timezone: ["recurring"],
|
|
443
|
+
prompt: ["recurring"],
|
|
444
|
+
"no-email": ["recurring"],
|
|
401
445
|
};
|
|
402
446
|
function requiresConfirmation(command) {
|
|
403
447
|
return (command.name === "access" && ["revoke", "remove", "transfer", "leave"].includes(command.action))
|
|
404
448
|
|| (command.name === "model" && command.action === "clear")
|
|
405
449
|
|| (command.name === "keys" && command.action === "remove")
|
|
406
|
-
|| (command.name === "repo" && (command.action === "override-clear" || command.action === "secrets-delete"))
|
|
407
|
-
|| (command.name === "connectors" && command.action === "disconnect")
|
|
450
|
+
|| (command.name === "repo" && (command.action === "override-clear" || command.action === "secrets-delete" || command.action === "capability-dismiss"))
|
|
451
|
+
|| (command.name === "connectors" && command.action === "disconnect")
|
|
452
|
+
|| (command.name === "recurring" && command.action === "delete");
|
|
408
453
|
}
|
|
409
454
|
/** Refusals fail closed before the caller sends a workspace mutation. */
|
|
410
455
|
export async function confirmWorkspaceMutation(command, options) {
|
|
@@ -420,7 +465,9 @@ export async function confirmWorkspaceMutation(command, options) {
|
|
|
420
465
|
? `${command.action} in ${command.repoName}${"secretName" in command ? ` (${command.secretName})` : ""}`
|
|
421
466
|
: command.name === "connectors"
|
|
422
467
|
? `disconnect connection${"connectionId" in command ? ` ${command.connectionId}` : ""}`
|
|
423
|
-
:
|
|
468
|
+
: command.name === "recurring"
|
|
469
|
+
? `delete recurring task ${command.taskId}`
|
|
470
|
+
: "clear model default";
|
|
424
471
|
const answer = await options.ask(printable(`Confirm ${action} in workspace ${options.workspaceId}? [y/N] `));
|
|
425
472
|
if (!/^(y|yes)$/i.test(answer.trim()))
|
|
426
473
|
throw new UsageError("Cancelled. Nothing changed.");
|
|
@@ -528,15 +575,40 @@ export async function runRepo(client, workspaceId, inv, io) {
|
|
|
528
575
|
case "capability-requests":
|
|
529
576
|
result = await client.repoRequest(workspaceId, repo.id, "capability-requests");
|
|
530
577
|
break;
|
|
578
|
+
case "capability-dismiss":
|
|
579
|
+
result = await client.repoRequest(workspaceId, repo.id, `capability-requests/${encodeURIComponent(command.requestId)}/dismiss`, "POST");
|
|
580
|
+
break;
|
|
531
581
|
}
|
|
532
582
|
if (inv.json)
|
|
533
583
|
io.out(`${JSON.stringify(result, null, 2)}\n`);
|
|
534
|
-
else if (command.action === "override-clear" || command.action === "secrets-delete") {
|
|
535
|
-
io.out(
|
|
584
|
+
else if (command.action === "override-clear" || command.action === "secrets-delete" || command.action === "capability-dismiss") {
|
|
585
|
+
io.out({ "override-clear": "Repository override cleared.\n", "secrets-delete": "Repository secret deleted.\n", "capability-dismiss": "Access request dismissed.\n" }[command.action]);
|
|
586
|
+
}
|
|
587
|
+
else if (command.action === "capability-requests") {
|
|
588
|
+
io.out(printable(`${describeCapabilityRequests(result)}\n`));
|
|
536
589
|
}
|
|
537
590
|
else
|
|
538
591
|
io.out(printable(`${describeRepoResponse(result)}\n`));
|
|
539
592
|
}
|
|
593
|
+
function describeCapabilityRequests(value) {
|
|
594
|
+
if (!value || typeof value !== "object" || !("requests" in value) || !Array.isArray(value.requests)) {
|
|
595
|
+
return describeRepoResponse(value);
|
|
596
|
+
}
|
|
597
|
+
return value.requests.map((request) => {
|
|
598
|
+
if (!request || typeof request !== "object" || !("remediation" in request))
|
|
599
|
+
return describeRepoResponse(request);
|
|
600
|
+
const { remediation } = request;
|
|
601
|
+
if (!remediation || typeof remediation !== "object")
|
|
602
|
+
return describeRepoResponse(request);
|
|
603
|
+
const guidance = remediation;
|
|
604
|
+
const lines = [guidance.summary];
|
|
605
|
+
for (const line of ["reason" in request ? request.reason : null, guidance.supplyCommand, guidance.note, guidance.dismissCommand]) {
|
|
606
|
+
if (typeof line === "string")
|
|
607
|
+
lines.push(` ${line}`);
|
|
608
|
+
}
|
|
609
|
+
return lines.join("\n");
|
|
610
|
+
}).join("\n\n") || "No access requests.";
|
|
611
|
+
}
|
|
540
612
|
/** Keep nested config/environment responses readable without dropping server-owned fields. */
|
|
541
613
|
function describeRepoResponse(value, indent = "") {
|
|
542
614
|
if (value === null)
|
|
@@ -567,7 +639,23 @@ export function parseInvocation(argv) {
|
|
|
567
639
|
return parseArgs({ args: argv, allowPositionals: true, options: OPTIONS });
|
|
568
640
|
}
|
|
569
641
|
catch (error) {
|
|
570
|
-
|
|
642
|
+
let first;
|
|
643
|
+
try {
|
|
644
|
+
[first] = parseArgs({ args: argv, allowPositionals: true, strict: false, options: { ...OPTIONS, ...RECURRING_OPTIONS } }).positionals;
|
|
645
|
+
}
|
|
646
|
+
catch {
|
|
647
|
+
if (argv.includes("recurring"))
|
|
648
|
+
throw new UsageError(RECURRING_USAGE);
|
|
649
|
+
}
|
|
650
|
+
if (first === "recurring") {
|
|
651
|
+
try {
|
|
652
|
+
return parseArgs({ args: argv, allowPositionals: true, options: { ...OPTIONS, ...RECURRING_OPTIONS } });
|
|
653
|
+
}
|
|
654
|
+
catch {
|
|
655
|
+
throw new UsageError(RECURRING_USAGE);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
// The connectors group reads its own options; any other command never sees them.
|
|
571
659
|
if (connectorsInvocation(argv)) {
|
|
572
660
|
try {
|
|
573
661
|
return parseArgs({ args: argv, allowPositionals: true, options: { ...OPTIONS, ...CONNECTOR_OPTIONS } });
|
|
@@ -686,6 +774,7 @@ export function parseInvocation(argv) {
|
|
|
686
774
|
else if (values.plan !== undefined)
|
|
687
775
|
throw new UsageError("--plan only applies to billing upgrade.");
|
|
688
776
|
}
|
|
777
|
+
const recurring = command.name === "recurring" ? recurringInput(command, values) : undefined;
|
|
689
778
|
return {
|
|
690
779
|
command,
|
|
691
780
|
files: values.file ?? [],
|
|
@@ -695,6 +784,7 @@ export function parseInvocation(argv) {
|
|
|
695
784
|
emailPreferences,
|
|
696
785
|
pasteToken: values.token ?? false,
|
|
697
786
|
noBrowser: values["no-browser"] ?? false,
|
|
787
|
+
...(recurring ? { recurring } : {}),
|
|
698
788
|
...(command.name === "repo" ? { secretMetadata: {
|
|
699
789
|
...(values.host !== undefined ? { hosts: values.host } : {}),
|
|
700
790
|
...(values.header !== undefined ? { header: values.header } : {}),
|
|
@@ -722,6 +812,71 @@ export function parseInvocation(argv) {
|
|
|
722
812
|
...(values["api-url"] !== undefined ? { apiUrl: values["api-url"] } : {}),
|
|
723
813
|
};
|
|
724
814
|
}
|
|
815
|
+
function recurringInput(command, values) {
|
|
816
|
+
const fail = (message) => { throw new UsageError(`${message}\n${RECURRING_USAGE}`); };
|
|
817
|
+
const supplied = Object.keys(RECURRING_OPTIONS).some((key) => values[key] !== undefined);
|
|
818
|
+
if (command.action !== "create" && command.action !== "edit") {
|
|
819
|
+
if (supplied)
|
|
820
|
+
fail("Schedule flags only apply to recurring create or edit.");
|
|
821
|
+
return undefined;
|
|
822
|
+
}
|
|
823
|
+
if (values.weekdays !== undefined && values["day-of-month"] !== undefined)
|
|
824
|
+
fail("Choose --weekdays or --day-of-month, not both.");
|
|
825
|
+
if (command.action === "create" && values.prompt !== undefined)
|
|
826
|
+
fail("Supply the create prompt as the quoted argument, not --prompt.");
|
|
827
|
+
const input = {};
|
|
828
|
+
const times = values.at;
|
|
829
|
+
if (command.action === "create" && !times)
|
|
830
|
+
fail("Create requires --at <HH:MM>.");
|
|
831
|
+
if (times && (times.length > 4 || new Set(times).size !== times.length || times.some((time) => !/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(time)))) {
|
|
832
|
+
fail("--at takes one to four distinct times in HH:MM format.");
|
|
833
|
+
}
|
|
834
|
+
const schedule = times ? { times } : {};
|
|
835
|
+
if (values.weekdays !== undefined) {
|
|
836
|
+
const days = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
|
|
837
|
+
const weekdays = values.weekdays.toLowerCase().split(",").map((day) => days.indexOf(day.trim()));
|
|
838
|
+
if (weekdays.some((day) => day < 0) || new Set(weekdays).size !== weekdays.length)
|
|
839
|
+
fail("--weekdays takes distinct days such as mon,wed.");
|
|
840
|
+
schedule.weekdays = weekdays;
|
|
841
|
+
}
|
|
842
|
+
else if (values["day-of-month"] !== undefined) {
|
|
843
|
+
const day = values["day-of-month"];
|
|
844
|
+
if (!/^(?:[1-9]|1\d|2[0-8])$/.test(day))
|
|
845
|
+
fail("--day-of-month takes a whole number from 1 to 28.");
|
|
846
|
+
schedule.dayOfMonth = Number(day);
|
|
847
|
+
}
|
|
848
|
+
else if (command.action === "create")
|
|
849
|
+
schedule.weekdays = [0, 1, 2, 3, 4, 5, 6];
|
|
850
|
+
if (Object.keys(schedule).length)
|
|
851
|
+
input.cadence = schedule;
|
|
852
|
+
const timezone = values.timezone ?? (command.action === "create" ? Intl.DateTimeFormat().resolvedOptions().timeZone : undefined);
|
|
853
|
+
if (timezone !== undefined) {
|
|
854
|
+
try {
|
|
855
|
+
if (!timezone || /^[+-]/.test(timezone))
|
|
856
|
+
throw new RangeError();
|
|
857
|
+
new Intl.DateTimeFormat("en-US", { timeZone: timezone });
|
|
858
|
+
}
|
|
859
|
+
catch {
|
|
860
|
+
fail("--timezone takes an IANA time zone.");
|
|
861
|
+
}
|
|
862
|
+
input.timezone = timezone;
|
|
863
|
+
}
|
|
864
|
+
if (values.name !== undefined) {
|
|
865
|
+
if (!values.name.trim())
|
|
866
|
+
fail("--name must not be empty.");
|
|
867
|
+
input.name = values.name;
|
|
868
|
+
}
|
|
869
|
+
if (values.prompt !== undefined) {
|
|
870
|
+
if (!values.prompt.trim())
|
|
871
|
+
fail("--prompt must not be empty.");
|
|
872
|
+
input.prompt = values.prompt;
|
|
873
|
+
}
|
|
874
|
+
if (values["no-email"] !== undefined)
|
|
875
|
+
input.notifyByEmail = false;
|
|
876
|
+
if (command.action === "edit" && !Object.keys(input).length)
|
|
877
|
+
fail("Edit requires at least one change.");
|
|
878
|
+
return input;
|
|
879
|
+
}
|
|
725
880
|
/** The words after `connectors` that make it the group: none, `list`, or a connect or disconnect. */
|
|
726
881
|
function connectorsShape(rest) {
|
|
727
882
|
return rest.length === 0 || (rest.length === 1 && rest[0] === "list") || rest[0] === "connect" || rest[0] === "disconnect";
|
|
@@ -1145,8 +1300,8 @@ export function explain(error, context = {}) {
|
|
|
1145
1300
|
case "invalid_secret_name": return "That secret name isn't valid. Use the naming rules shown in the dashboard.";
|
|
1146
1301
|
case "invalid_secret_value": return "That secret value isn't valid. Enter a nonempty value through the hidden prompt or stdin.";
|
|
1147
1302
|
case "secret_cap_exceeded": return "This repository has reached its secret limit.";
|
|
1148
|
-
case "capability_request_not_found": return "That
|
|
1149
|
-
case "capability_target_not_authorized": return "The allowed hosts don't
|
|
1303
|
+
case "capability_request_not_found": return "That access request isn't available for this repository.";
|
|
1304
|
+
case "capability_target_not_authorized": return "The allowed hosts don't include the access request's target. Update --host.";
|
|
1150
1305
|
case "repo_environments_not_enabled": return "Repository environments aren't enabled for this workspace.";
|
|
1151
1306
|
case "invalid_model": return "Sinatra doesn't offer that model (see docs.sinatra.dev/docs/configuration/models).";
|
|
1152
1307
|
case "invalid_status": return "That isn't a task status (some are: pending, implementing, replied, pr_open, completed, failed).";
|
|
@@ -1345,7 +1500,7 @@ function connectionLine(connection, projectRefLabel) {
|
|
|
1345
1500
|
].join(" ");
|
|
1346
1501
|
}
|
|
1347
1502
|
/**
|
|
1348
|
-
* `sinatra connectors
|
|
1503
|
+
* `sinatra connectors`. A token is read only through the hidden reader and sent only
|
|
1349
1504
|
* in the connect request's body, through the client path that keeps no server detail.
|
|
1350
1505
|
*/
|
|
1351
1506
|
export async function runConnectors(client, workspaceId, inv, deps) {
|
|
@@ -1451,7 +1606,7 @@ export async function runConnectors(client, workspaceId, inv, deps) {
|
|
|
1451
1606
|
if (!connection)
|
|
1452
1607
|
throw new UsageError(CONNECTORS_USAGE);
|
|
1453
1608
|
const listed = await client.listConnectors(workspaceId);
|
|
1454
|
-
// Off for this workspace
|
|
1609
|
+
// Off for this workspace, the list still answers while connections remain: nothing can be connected.
|
|
1455
1610
|
if (!listed.enabled)
|
|
1456
1611
|
throw new ApiError(404, "not_found");
|
|
1457
1612
|
const entry = listed.catalog.find((row) => row.id === command.connector);
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import { EXIT, followOutcome, followTask } from "./follow.js";
|
|
|
17
17
|
import { browserSignIn, openBrowser, revokeSignIn, SignInError } from "./oauth.js";
|
|
18
18
|
import { ask, askSecret } from "./prompt.js";
|
|
19
19
|
import { credentialsFor } from "./session.js";
|
|
20
|
+
import { runRecurring } from "./recurring.js";
|
|
20
21
|
import { CLI_VERSION } from "./version.js";
|
|
21
22
|
/** How a follow ended, for a task that stopped rather than waiting on you. */
|
|
22
23
|
const ENDINGS = {
|
|
@@ -356,6 +357,13 @@ async function main(argv) {
|
|
|
356
357
|
case "connect":
|
|
357
358
|
await runConnect(client, workspaceOf(config, inv.workspace), { ...inv, command }, { out, openBrowser });
|
|
358
359
|
return;
|
|
360
|
+
case "recurring":
|
|
361
|
+
await runRecurring(client, workspaceOf(config, inv.workspace), { ...inv, command }, {
|
|
362
|
+
out,
|
|
363
|
+
ask: (question) => ask(question, process.stdin, process.stderr),
|
|
364
|
+
interactive: Boolean(process.stdin.isTTY && process.stderr.isTTY),
|
|
365
|
+
});
|
|
366
|
+
return;
|
|
359
367
|
case "connectors":
|
|
360
368
|
await runConnectors(client, workspaceOf(config, inv.workspace), { ...inv, command }, {
|
|
361
369
|
out,
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { ApiError } from "./client.js";
|
|
2
|
+
import { confirmWorkspaceMutation, printable, UsageError } from "./commands.js";
|
|
3
|
+
const WEEKDAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
4
|
+
const list = new Intl.ListFormat("en-US", { style: "long", type: "conjunction" });
|
|
5
|
+
/** Keep the dependency-free CLI's schedule description in local wall-clock time. */
|
|
6
|
+
function cadenceSentence(cadence) {
|
|
7
|
+
const weekdays = [...new Set(cadence.weekdays)].sort((a, b) => a - b);
|
|
8
|
+
const frequency = cadence.dayOfMonth !== undefined
|
|
9
|
+
? `Monthly on day ${cadence.dayOfMonth}`
|
|
10
|
+
: weekdays.length === 7
|
|
11
|
+
? "Daily"
|
|
12
|
+
: weekdays.join(",") === "1,2,3,4,5"
|
|
13
|
+
? "Weekdays"
|
|
14
|
+
: list.format(weekdays.map((day) => WEEKDAYS[day]));
|
|
15
|
+
return `${frequency} at ${list.format([...cadence.times].sort())}`;
|
|
16
|
+
}
|
|
17
|
+
export async function runRecurring(client, workspaceId, inv, io) {
|
|
18
|
+
const { command } = inv;
|
|
19
|
+
const emit = (value) => io.out(`${JSON.stringify(value, null, 2)}\n`);
|
|
20
|
+
const printTask = (task) => io.out(printable(`${task.id} ${task.name}${task.pausedAt ? " (paused)" : ""}\n ${cadenceSentence(task.cadence)}; timezone: ${task.timezone}\n Next run: ${task.nextRunAt ?? (task.pausedAt ? "none (paused)" : "none")}\n`));
|
|
21
|
+
try {
|
|
22
|
+
switch (command.action) {
|
|
23
|
+
case "list": {
|
|
24
|
+
const result = await client.listRecurringTasks(workspaceId);
|
|
25
|
+
if (inv.json)
|
|
26
|
+
return emit(result);
|
|
27
|
+
if (result.tasks.length === 0)
|
|
28
|
+
io.out("No recurring tasks.\n");
|
|
29
|
+
for (const task of result.tasks)
|
|
30
|
+
printTask(task);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
case "show": {
|
|
34
|
+
const result = await client.getRecurringTask(workspaceId, command.taskId);
|
|
35
|
+
if (inv.json)
|
|
36
|
+
return emit(result);
|
|
37
|
+
printTask(result.task);
|
|
38
|
+
io.out(printable(`\nPrompt:\n${result.task.prompt}\n\nRecent runs:\n`));
|
|
39
|
+
if (result.runs.length === 0)
|
|
40
|
+
io.out(" None\n");
|
|
41
|
+
for (const run of result.runs) {
|
|
42
|
+
const task = run.workstreamId ? `; task: ${run.workstreamId}` : "";
|
|
43
|
+
const reason = run.reasonText ?? run.reason;
|
|
44
|
+
io.out(printable(` ${run.id} ${run.scheduledFor} ${run.trigger} ${run.outcome}${task}${reason ? `; ${reason}` : ""}\n`));
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
case "create": {
|
|
49
|
+
const changes = inv.recurring;
|
|
50
|
+
const prompt = command.prompt ?? changes?.prompt;
|
|
51
|
+
if (prompt === undefined || !changes?.cadence?.times || !changes.timezone) {
|
|
52
|
+
throw new UsageError("Creating a recurring task requires a prompt, cadence and timezone.");
|
|
53
|
+
}
|
|
54
|
+
const result = await client.createRecurringTask(workspaceId, {
|
|
55
|
+
prompt,
|
|
56
|
+
cadence: { ...changes.cadence, times: changes.cadence.times },
|
|
57
|
+
timezone: changes.timezone,
|
|
58
|
+
...(changes.name !== undefined ? { name: changes.name } : {}),
|
|
59
|
+
...(changes.notifyByEmail !== undefined ? { notifyByEmail: changes.notifyByEmail } : {}),
|
|
60
|
+
});
|
|
61
|
+
if (inv.json)
|
|
62
|
+
return emit(result);
|
|
63
|
+
io.out("Created recurring task:\n");
|
|
64
|
+
printTask(result.task);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
case "edit": {
|
|
68
|
+
const changes = inv.recurring ?? {};
|
|
69
|
+
const prompt = command.prompt ?? changes.prompt;
|
|
70
|
+
const body = {
|
|
71
|
+
...(changes.name !== undefined ? { name: changes.name } : {}),
|
|
72
|
+
...(prompt !== undefined ? { prompt } : {}),
|
|
73
|
+
...(changes.timezone !== undefined ? { timezone: changes.timezone } : {}),
|
|
74
|
+
...(changes.notifyByEmail !== undefined ? { notifyByEmail: changes.notifyByEmail } : {}),
|
|
75
|
+
};
|
|
76
|
+
if (changes.cadence !== undefined) {
|
|
77
|
+
const { task } = await client.getRecurringTask(workspaceId, command.taskId);
|
|
78
|
+
const cadence = { ...task.cadence, ...changes.cadence };
|
|
79
|
+
if (changes.cadence.dayOfMonth !== undefined)
|
|
80
|
+
delete cadence.weekdays;
|
|
81
|
+
else if (changes.cadence.weekdays !== undefined)
|
|
82
|
+
delete cadence.dayOfMonth;
|
|
83
|
+
body.cadence = cadence;
|
|
84
|
+
}
|
|
85
|
+
const result = await client.updateRecurringTask(workspaceId, command.taskId, body);
|
|
86
|
+
if (inv.json)
|
|
87
|
+
return emit(result);
|
|
88
|
+
io.out("Updated recurring task:\n");
|
|
89
|
+
printTask(result.task);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
case "pause": {
|
|
93
|
+
const result = await client.pauseRecurringTask(workspaceId, command.taskId);
|
|
94
|
+
if (inv.json)
|
|
95
|
+
return emit(result);
|
|
96
|
+
io.out(printable(`Paused recurring task ${command.taskId}.\n`));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
case "resume": {
|
|
100
|
+
const result = await client.resumeRecurringTask(workspaceId, command.taskId);
|
|
101
|
+
if (inv.json)
|
|
102
|
+
return emit(result);
|
|
103
|
+
io.out("Resumed recurring task:\n");
|
|
104
|
+
printTask(result.task);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
case "run": {
|
|
108
|
+
const result = await client.runRecurringTask(workspaceId, command.taskId);
|
|
109
|
+
if (inv.json)
|
|
110
|
+
return emit(result);
|
|
111
|
+
io.out(printable(`Started task ${result.taskId} from recurring task ${command.taskId}${result.run ? ` (run ${result.run.id})` : ""}.\n`));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
case "delete": {
|
|
115
|
+
await confirmWorkspaceMutation(command, { yes: inv.yes ?? false, interactive: io.interactive, workspaceId, ask: io.ask });
|
|
116
|
+
const result = await client.deleteRecurringTask(workspaceId, command.taskId);
|
|
117
|
+
if (inv.json)
|
|
118
|
+
return emit(result);
|
|
119
|
+
io.out(printable(`Deleted recurring task ${command.taskId}.\n`));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
if (error instanceof ApiError && error.status === 404) {
|
|
126
|
+
throw new UsageError(command.taskId
|
|
127
|
+
? `No recurring task ${command.taskId} in this workspace. Run \`sinatra recurring\` to list them.`
|
|
128
|
+
: "Recurring tasks are not available in this workspace.");
|
|
129
|
+
}
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
}
|