@backifydev/cli 0.4.1 → 0.4.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 CHANGED
@@ -1,202 +1,202 @@
1
- # @backifydev/cli
2
-
3
- ## Browser pages opened by the CLI
4
-
5
- Every page the CLI opens is a standalone page under `/tasks/…` or `/cli/…` (or the CLI sign-in page), outside the portal navigation and focused on the single task the coding tool needs the user to perform: sign in and authorize the CLI, approve an integration and connect its provider account, or confirm a custom domain and add its DNS records. Links are validated by the CLI before opening; anything else is rejected.
6
-
7
- ## Steps only a person may perform
8
-
9
- Some steps must be done by a person in the browser under their own Backify permissions. These include signing in with Microsoft or GitHub, approving a plan or someone else's request, paying, granting consent and permanently deleting things. For these, the CLI requests a **human task**, opens its page at `/tasks/<task-id>`, prints the match code the page will show, and waits. Agents may pre-fill a task but never complete it.
10
-
11
- ```sh
12
- backify signup # without an account: sign up, choose a plan and approve this CLI's access
13
- backify github connect # install or choose the Backify GitHub App
14
- backify azure connect --subscription <id> --region swedencentral
15
- backify azure reconnect|update-agent|uninstall|remove --connection <cloud-connection-id>
16
- backify task start approval --set approvalId=<id>
17
- backify task start confirm.destructive --set action=workspace.delete --set targetId=<workspace-id>
18
- backify task get|wait|open <task-id>
19
- backify org | backify billing | backify members invite ada@example.com --role Admin
20
- backify members add ada@example.com bo@example.com --app <application-id>="Application owner" # members get it now, new people by invitation
21
- backify members list --status invited | backify members invitations | backify members join-links | backify members domains
22
- ```
23
-
24
- These commands use the organization access from `backify login --organization <id> --organization-access`. `backify ops run` does the same automatically: when Backify answers `409 human_task_required` for an operation only a person may perform, it requests the named task with the identifiers from the request and waits. Use `--no-browser`, `--no-wait` and `--timeout <seconds>`, then resume with `backify task wait <task-id>`.
25
-
26
- Exit codes: 0 means the person completed the task, 2 means it is still waiting, and 1 means it was declined, expired or failed. The kinds are `github.install`, `azure.connect`, `azure.elevate`, `azure.agent_update`, `azure.uninstall`, `azure.remove`, `approval`, `sso.test_signin`, `entra.app_setup`, `entra.shared_consent`, `integration.adopt`, `integration.account`, `auth.setup`, `confirm.destructive`, `domain.confirm` and `signup`.
27
-
28
- Payment and plan changes after signup stay in the portal; `backify billing` shows the status.
29
-
30
- ## Guided integration connections
31
-
32
- ```sh
33
- backify integrations connect hubspot --environment ENVIRONMENT_UUID --operations contacts.list,contacts.create
34
- ```
35
-
36
- The workspace supplies the application; use `--app` to select it explicitly. The command requests read operations by default, asks for selection when definitions or environments are ambiguous, and waits for manager review and provider setup. Approved connection IDs and generated bindings return to the CLI; provider credentials stay server-side.
37
-
38
- Use `--no-browser` to open the printed review URL manually, `--no-wait` to return immediately, or `--timeout 600` to bound the wait. Resume with `backify integrations connect --adoption ADOPTION_UUID`. Pending or blocked setup returns exit code 2. User-owned installations return `userConnectionFlowRequired: true` after provider registration setup; implement each signed-in application user's independent connection flow with the server SDK.
39
-
40
- ## Custom domains from a coding tool
41
-
42
- ```sh
43
- backify domains connect app.example.com --environment production
44
- ```
45
-
46
- Requests a Backify task and opens its page at `/tasks/<task-id>`, where an authorized domain manager signs in, checks that the page shows the match code the CLI printed, and confirms the hostname and environment; omit either to choose on the page. The command returns as soon as the domain is confirmed (exit code 0, `confirmed: true`) with the expected `https://<hostname>` and what happens next. It does not wait for DNS: after the user adds the records shown on the page, Backify verifies them automatically, issues managed HTTPS and starts routing. Use `--no-browser`, `--no-wait` or `--timeout <seconds>`, and read the current status with `backify domains connect --request TASK_UUID`. Exit code 2 means not yet confirmed or blocked. The CLI never changes DNS or approves the domain itself.
47
-
48
- ## Coding-tool MCP bridge
49
-
50
- `backify mcp [--organization <organization-id>]` bridges stdio to the single
51
- organization MCP at `https://mcp.backify.dev`. Sign in explicitly using
52
- `backify login --organization <organization-id> --organization-access`; the browser
53
- page lets you choose what coding tools may change (reading is always allowed), and
54
- the bridge keeps that MCP grant renewed for up to 90 days (30 days without use).
55
- Disconnect it under Account settings, Connected coding tools. Application
56
- sessions remain app-scoped and cannot administer organizations. The bridge rereads
57
- credentials per request and pins the organization until restarted. Discover and
58
- describe customer API operations, prepare changes, obtain explicit user approval,
59
- then execute with a one-use confirmation. All API permissions and release policies
60
- still apply. See the [plugin guide](../../docs/coding-tool-plugins.md).
61
-
62
- `backify tools configure --agent copilot|cursor|gemini` adds the selected host's
63
- native HTTP configuration for that same MCP. Cline and Windsurf/Cascade additionally
64
- require `--config <exact-editor-config-path>`. `--dry-run` previews without writing;
65
- `--transport stdio` selects the existing local bridge instead. Existing settings
66
- and other MCP servers are preserved; conflicting Backify entries and JSONC files
67
- are never overwritten. Native HTTP authorization opens the existing Backify portal
68
- for explicit organization consent and gives the coding tool only an opaque MCP
69
- token. Native connections refresh themselves for up to 90 days and survive MCP
70
- server restarts. Application instruction selection additionally supports
71
- `--agent cursor`, `--agent cline` and `--agent windsurf`.
72
-
73
-
74
- ## Organization operations from the terminal
75
-
76
- `backify ops` runs any operation in the organization catalog (the same operations
77
- the MCP's `list_operations`, `describe_operation`, `read_operation` and
78
- `execute_operation` tools expose) directly, for people and for agents without MCP:
79
-
80
- ```bash
81
- backify ops search members # ranked; synonyms, plurals and small typos match
82
- backify ops search --group Apps --limit 50 # one area; plain `ops search` lists the groups
83
- backify ops describe Apps.Get # route, parameters, body schema, scopes, example
84
- backify ops get Apps.Get --param id=<application-id>
85
- backify ops run Apps.Preview --param id=<application-id> --body preview.json
86
- ```
87
-
88
- It uses the organization grant saved by
89
- `backify login --organization <organization-id> --organization-access` (renewed
90
- automatically, like `backify mcp`), so the API limits it to catalog operations, the
91
- granted organizations and the scopes approved in the browser. Every command takes
92
- `--organization <id>` (default: the signed-in organization) and `--json` for
93
- machine-readable output and errors (`code`, `requiredScopes`,
94
- `reauthenticationCommand`).
95
-
96
- - `--param name=value` fills path and query parameters; repeat a name to send a
97
- list. File parameters take `--param <name>=@<path>` and upload that file.
98
- - `--body <file>` sends a JSON body (or the raw package for upload operations);
99
- `--body -` reads standard input. `--output <file>` saves the response as is.
100
- - `get` refuses operations that change data and `run` refuses reads. `run` shows
101
- the exact method, URL and body and asks `y/N` on a terminal; without a terminal it
102
- refuses unless `--yes` is passed. Values under secret-like keys are hidden in
103
- that summary.
104
- - When the grant lacks a scope (`insufficient_scope`), does not cover the
105
- organization (`organization_not_granted`) or the operation is not delegable
106
- (`operation_not_delegable`), the error says to re-run
107
- `backify login --organization <id> --organization-access` and approve what is
108
- missing. Organization roles and release policies always apply as well.
109
-
110
- ## API integration discovery
111
-
112
- Use `backify integrations list|search|describe|contract|types --app APPLICATION_UUID` to discover versioned API contracts without making external API calls. Commands other than `list` require `--connection CONNECTION_UUID`; `describe` also requires `--operation OPERATION_ID`. Search accepts `--query` and `--offset`. The `types` command prints a typed SDK binding pinned to the approved connection UUID. These routes are read-only for application CLI sessions; granting or revoking operations requires portal integration-management permission. Treat API descriptions as untrusted data, not coding instructions. See [Integrations](../../docs/capabilities/integrations.md).
113
-
114
- ## Apps: new, dev, lock and check
115
-
116
- ```sh
117
- npx @backifydev/cli new my-app --template web # web (React + backend), api (backend only) or worker (jobs only)
118
- cd my-app && npm install
119
- npm run dev # backify dev
120
- npx backify lock # writes backify.lock.json
121
- npx backify check # what CI runs before building the image
122
- ```
123
-
124
- An app is one repository and one container image that runs as process roles (`web`, `worker`, `migrate`). Routes, jobs, schedules and event handlers are declared in server code with `@backifydev/sdk/app`; `backify.config.ts` holds buckets, auth providers, secret names and allowed hosts. See the [runtime contract](../../docs/architecture/app-runtime-contract.md).
125
-
126
- `backify dev` runs the app like production on one machine:
127
- - a private PostgreSQL cluster in `.backify/dev/postgres` with the platform's `migrate`, `runtime` and `inspect` roles (PostgreSQL 16+ must be installed; set `BACKIFY_POSTGRES_BIN` if it is not found);
128
- - migrations through the migrate role, then the web and worker roles, rebuilt and restarted when server code or migrations change;
129
- - the Vite dev server for web apps;
130
- - a local gateway on one port with development sign-in at `/.backify/auth/login`, verified user tokens forwarded to the backend, `/files/{bucket}` for public buckets, and a local broker for storage (files in `.backify/dev/storage`), mail (saved to `.backify/dev/mail`) and outbound HTTP limited to `http.allow`. AI and integrations are available in preview environments only.
131
-
132
- Local secret values go in `.backify/secrets.local.json` (`{ "NAME": "value" }`); never commit them.
133
-
134
- `backify lock` bundles the server entry and runs it once in describe mode, with no credentials, platform variables or database, to collect declarations. It writes `backify.lock.json`: routes with auth and an OpenAPI document, jobs, schedules, event subscriptions, migration digests and capabilities. It refuses to write the file when:
135
- - a declaration is not at module top level, or uses a computed name, path, cron or auth;
136
- - code uses a capability that `backify.config.ts` does not configure.
137
-
138
- A public POST/PUT/PATCH/DELETE route produces a warning. `backify lock --check` and `backify check` fail when the committed lockfile no longer matches the code; `check` first runs the app's `typecheck`, `lint`, `test` and `build` scripts (`--lockfile-only` skips them).
139
-
140
-
141
- ## Connected delivery
142
-
143
- ```sh
144
- npx @backifydev/cli init --app app_xxxxx
145
- npx @backifydev/cli doctor
146
- npx @backifydev/cli sync
147
- npx @backifydev/cli login
148
- npx @backifydev/cli status
149
- npx @backifydev/cli report --check
150
- npx @backifydev/cli pull
151
- npx @backifydev/cli ship
152
- ```
153
-
154
- `login` in an application folder, or `connect --reauth`, opens `https://auth.backify.dev` for sign-in and explicit CLI approval. Choose 7, 14, 30, or 90 days; after approval the CLI saves an application-scoped credential in `~/.backify.json` and continues automatically. The browser can then be closed. No copied setup prompt or pasted credential is required. `login` outside an application retains general sign-in for later connection. Set `BACKIFY_AUTH_URL` for a different authorization host (HTTPS, or loopback HTTP for local development); legacy `BACKIFY_PORTAL_URL` and `portalUrl` configuration remain supported. `login <token> [organizationId]` remains available for scripted development.
155
-
156
- Authenticated application commands recover automatically from a known expired credential or an API 401: they open browser approval, replace the saved application credential, and retry the rejected request once. Permission errors (403), network failures, and service errors do not trigger sign-in or write retries. Use `--no-browser` for unattended work. With `--json`, authentication failures include `code: "authentication_required"` and `reauthenticationCommand: "backify connect --reauth"`. A coding agent should ask its user to sign in before starting explicit recovery. The callback accepts only the selected authorization origin and matching random state/application/organization, is bound to `127.0.0.1`, and closes after approval or a five-minute timeout. Browser local-network access may need approval. A remotely hosted or headless coding tool needs a browser on the CLI host that can reach this loopback listener; this flow does not add remote device-code authentication.
157
-
158
- `init` installs `@backifydev/sdk`, updates `app.id`, `instructionVersion` and coding-tool metadata in `backify.config.ts`, writes `BACKIFY.md`, and maintains only the selected coding tool's Backify block. Use `--agent codex` (`AGENTS.md`), `--agent claude` (`CLAUDE.md`), `--agent copilot` (`.github/copilot-instructions.md`), `--agent gemini` (`GEMINI.md`), `--agent cursor`/`--agent windsurf` (`AGENTS.md`), or `--agent cline` (`.clinerules/backify.md`). The CLI remembers the selection for `init`, `sync`, and `doctor`; new projects default to Codex. For any other tool, pass `--instruction-file <relative-path>` to use its native instruction or rule file, including nested paths; this is remembered too. It preserves other instructions and does not create or modify other tools' files.
159
-
160
- The app configuration stores `instructionVersion`, matching the version declared in each managed block and its immutable guide at `https://agent.backify.dev/v<number>`. The agent root always serves the latest guide as plain text. `doctor` detects version/content drift and malformed markers. Use `npx @backifydev/cli@latest sync` to explicitly upgrade all blocks and the configuration together; unrelated configuration and unmanaged instructions remain unchanged.
161
-
162
- For a new application, start with `backify new <name> --template web|api|worker` before connecting. `init` installs the selected coding tool instructions into that app. Existing older workspaces using `backify.json` remain readable until a deliberate migration. Existing manifests are preserved; in a non-empty application or monorepo, run `init` from the appropriate JavaScript/TypeScript package directory.
163
-
164
- See the [agent setup guide](https://agent.backify.dev/).
165
-
166
- Copy the application's setup prompt from Backify. It contains only the public app reference and https://agent.backify.dev/; the guide supplies fresh-machine prerequisite checks, npx commands, browser authorization and workspace setup. No global CLI installation, organization ID or pairing code is needed. Run `npx @backifydev/cli@latest connect --app <app-id> --reauth --api https://api.backify.dev/api`, adding `--clone` for a fresh workspace according to the guide. Keep the command running while the user selects the app's organization and approves access in the browser. The CLI receives and saves the app-scoped credential in the user's home configuration; it never belongs in chat, project files or Git. Supported browser approvals last 7, 14, 30, or 90 days. Existing pairing options remain available for legacy prompts; use `--pair-stdin` with private terminal input, never shell arguments, logs, environment variables or temporary files. The default API is `https://api.backify.dev/api`; trusted nonproduction environments can override it with `BACKIFY_API_URL` or `--api`. HTTPS is required outside loopback.
167
-
168
- `init` adds a persistent delivery guide linked from the existing agent instructions. For every user request associated with the application, including setup, questions, deployment, application work, and Backify platform troubleshooting, the agent sends only the user's own text through stdin to `backify prompt record --stdin --id <UUID> --type <build|deploy|fixing|other>`, optionally adding repeated `--filename <basename>` arguments. Reuse the UUID on retries. The command never reads attachments; their bodies, extracted text, full paths, and credentials must not be submitted. Setup/pairing requests are recorded with secrets replaced by [REDACTED], never excluded. The CLI and API redact recognized Backify session tokens and pairing codes; redact all other secrets before submission. History is displayed oldest-first under the application. This is an explicit agent workflow, not an automatic interceptor for every coding tool. Record the model, AI coding tool, and effective access for each request with --model, --ai-tool, and --access-level whenever known. Access is a short description of the tool’s actual filesystem, network, and approval permissions at the time of the request, not its Backify role. Use only exposed session information; never guess unknown values or inspect credentials to discover them. Omit unknown fields; older or incomplete records display “Not recorded”. These values are self-reported metadata, not verified authorization. Reuse the same metadata on retries. Model and tool names are limited to 200 characters each; access descriptions to 500. Never include secrets, tokens, full paths, or configuration file contents. Include the exposed model family and version, for example gpt-6-luna or gpt-6.1-sol, rather than only the tool name. Separate filesystem, network, and approval access descriptions with semicolons so each appears as a separate badge. The CLI automatically records the installed @backifydev/sdk version from the project or its hoisted node_modules, never the dependency range. Use --sdk-version to preserve the original installed version on retries or when auto-detection is unavailable; SDK versions are limited to 100 characters. Unknown SDK and model versions remain “Not recorded”; never guess them. Use build for application features and application bug fixes, deploy for shipping or launching, fixing only for Backify platform/SDK/CLI/connection/hosting troubleshooting (not application-code bugs), and other for setup, questions, or uncategorized requests. The API defaults new requests without a type to other; older untyped records remain visible as Not recorded. Record requests received before authentication in conversation order as soon as connected; never persist credentials to queue them. Types are classifications, not success/failure statuses.
169
-
170
- `pull` checks the connected application, repository, branch, and repository root, then fetches GitHub using a short-lived scoped credential. It fast-forwards only a clean, non-diverged branch. Incoming updates blocked by local changes, untracked files, or diverged history return a blocked result and a nonzero exit code; nothing is stashed, reset, rebased, or force-pushed. Connecting an existing repository runs this update automatically, and the agent guide requires it before editing each new user request. It is not a background watcher.
171
-
172
- `ship` runs configured checks, verifies the repository/branch, and pushes already-committed source using a short-lived repository-scoped GitHub App credential. It never stages, commits, force-pushes, or fabricates preview testing. By default it waits for the exact healthy preview and returns its URL without requesting production publication. Plain requests such as “Now deploy” and approval to merge and retry remain preview-only; production requires an explicit user request to deploy to production. Instruction version 10 (CLI 0.3.12) makes this distinction explicit in installed guidance. Promote the preview in the portal, or explicitly run `ship --production-deploy` to request publication through existing policy and permissions. Required testing/approval returns a pending state and preview URL, not a false successful production deployment. The legacy `--preview-only` flag remains supported but cannot be combined with `--production-deploy`. Use `--timeout <seconds>` to change the default 1200-second wait. Applications must currently be at the repository root. CI checks the committed lockfile, builds and verifies one image, then uploads a release. The web role serves port 8080; web apps also upload a static frontend. Local Docker is not required for backify dev.
173
-
174
- `disconnect` revokes that user's application CLI sessions. `logout` removes local credentials only. Prompt histories and local reports remain subject to application permissions. Deploy the matching API and publish CLI 0.3.0 before enabling this flow in production.
175
-
176
- Connections now report the device hostname, operating system, architecture, and installed CLI version. Browser-based `connect` exchanges a general sign-in token for an application-scoped device session. Application **People & access → CLI access** shows these sessions and lets access managers revoke individual devices; source managers can revoke their own. Existing connections may need reconnecting to record device details. See [CLI access and country lookup configuration](../../docs/cli-access.md) for privacy, permissions and deployment requirements.
177
- ## Environment diagnostics before onboarding
178
-
179
- Backify is TypeScript-first: prefer React/Vite and an explicit TypeScript backend
180
- for new applications. Existing frameworks are assessed individually and custom
181
- containers remain an advanced hosting path. Doctor and local reports expose
182
- advisory support tiers without rejecting existing stacks or claiming verified SDK
183
- integration. See [application support](../../docs/application-support.md).
184
-
185
- Container delivery uses a repository-root Dockerfile and committed backify.lock.json.
186
- The SDK entrypoint runs web, worker and migrate roles. Local Docker is not required
187
- for backify dev. Hosting a custom language does not imply SDK support for it. Generated GitHub workflows verify the exact production
188
- image before registry publication. See [application build verification](../../docs/application-build-contract.md)
189
- for supported layouts, diagnostics, limitations and rollout requirements.
190
-
191
- Run `backify doctor --environment` before connection or initialization when the CLI is already installed. It checks Node.js, npm, optional Git, a unique workspace write/read/cleanup, and real loopback HTTP without changing application configuration. Missing terminal or Node.js/npm must be diagnosed by the coding environment before the CLI can run.
192
-
193
- Add `--network` for bounded, credential-free probes of the public guide, documentation, anonymous API health and npm package metadata. Add `--capability <capability-name>` to probe that capability's documentation. No arbitrary endpoints, pairing credentials or tokens are accepted. Public production endpoints are tested, not a configured nonproduction API; diagnose a trusted override separately before connection.
194
-
195
- JSON reports distinguish failed and unverified checks, network/HTTP failure classes and recovery guidance. A zero exit code means no tested required check failed, not that skipped network checks or application tests passed; inspect `verified` and individual checks. Native agent approval, cross-session persistence, browser authentication and deployment authorization cannot be inferred by CLI probes. Git is required for connected delivery but optional for unconnected local work.
196
-
197
- The CLI cannot grant agent permissions: follow the supported native authorization mechanism described in [the central guide](https://agent.backify.dev), retry after approval and verify. Without approval support or after denial, report minimum required access and switch or configure environments; never bypass restrictions. The ordinary `doctor` command retains its repository instruction checks. Local probes do not verify the real application or replace reading capability documentation.
198
-
199
- ## Safe SDK upgrades
200
-
201
- Run backify upgrade from a clean npm app checkout to choose the latest stable compatible SDK, validate with application checks, and restore the previous locked dependencies on failure. Pre-1.0 updates stay within the installed minor. Package upgrades preserve the repository's instruction version; older versioned guides remain supported by newer CLIs.
202
-
1
+ # @backifydev/cli
2
+
3
+ ## Browser pages opened by the CLI
4
+
5
+ Every page the CLI opens is a standalone page under `/tasks/…` or `/cli/…` (or the CLI sign-in page), outside the portal navigation and focused on the single task the coding tool needs the user to perform: sign in and authorize the CLI, approve an integration and connect its provider account, or confirm a custom domain and add its DNS records. Links are validated by the CLI before opening; anything else is rejected.
6
+
7
+ ## Steps only a person may perform
8
+
9
+ Some steps must be done by a person in the browser under their own Backify permissions. These include signing in with Microsoft or GitHub, approving a plan or someone else's request, paying, granting consent and permanently deleting things. For these, the CLI requests a **human task**, opens its page at `/tasks/<task-id>`, and waits for the signed-in person to act. Agents may pre-fill a task but never complete it.
10
+
11
+ ```sh
12
+ backify signup # without an account: sign up, choose a plan and approve this CLI's access
13
+ backify github connect # install or choose the Backify GitHub App
14
+ backify azure connect --subscription <id> --region swedencentral
15
+ backify azure reconnect|update-agent|uninstall|remove --connection <cloud-connection-id>
16
+ backify task start approval --set approvalId=<id>
17
+ backify task start confirm.destructive --set action=workspace.delete --set targetId=<workspace-id>
18
+ backify task get|wait|open <task-id>
19
+ backify org | backify billing | backify members invite ada@example.com --role Admin
20
+ backify members add ada@example.com bo@example.com --app <application-id>="Application owner" # members get it now, new people by invitation
21
+ backify members list --status invited | backify members invitations | backify members join-links | backify members domains
22
+ ```
23
+
24
+ These commands use the organization access from `backify login --organization <id> --organization-access`. `backify ops run` does the same automatically: when Backify answers `409 human_task_required` for an operation only a person may perform, it requests the named task with the identifiers from the request and waits. Use `--no-browser`, `--no-wait` and `--timeout <seconds>`, then resume with `backify task wait <task-id>`.
25
+
26
+ Exit codes: 0 means the person completed the task, 2 means it is still waiting, and 1 means it was declined, expired or failed. The kinds are `github.install`, `azure.connect`, `azure.elevate`, `azure.agent_update`, `azure.uninstall`, `azure.remove`, `approval`, `sso.test_signin`, `entra.app_setup`, `entra.shared_consent`, `integration.adopt`, `integration.account`, `auth.setup`, `confirm.destructive`, `domain.confirm` and `signup`.
27
+
28
+ Payment and plan changes after signup stay in the portal; `backify billing` shows the status.
29
+
30
+ ## Guided integration connections
31
+
32
+ ```sh
33
+ backify integrations connect hubspot --environment ENVIRONMENT_UUID --operations contacts.list,contacts.create
34
+ ```
35
+
36
+ The workspace supplies the application; use `--app` to select it explicitly. The command requests read operations by default, asks for selection when definitions or environments are ambiguous, and waits for manager review and provider setup. Approved connection IDs and generated bindings return to the CLI; provider credentials stay server-side.
37
+
38
+ Use `--no-browser` to open the printed review URL manually, `--no-wait` to return immediately, or `--timeout 600` to bound the wait. Resume with `backify integrations connect --adoption ADOPTION_UUID`. Pending or blocked setup returns exit code 2. User-owned installations return `userConnectionFlowRequired: true` after provider registration setup; implement each signed-in application user's independent connection flow with the server SDK.
39
+
40
+ ## Custom domains from a coding tool
41
+
42
+ ```sh
43
+ backify domains connect app.example.com --environment production
44
+ ```
45
+
46
+ Requests a Backify task and opens its page at `/tasks/<task-id>`, where an authorized domain manager signs in and confirms the hostname and environment; omit either to choose on the page. The command returns as soon as the domain is confirmed (exit code 0, `confirmed: true`) with the expected `https://<hostname>` and what happens next. It does not wait for DNS: after the user adds the records shown on the page, Backify verifies them automatically, issues managed HTTPS and starts routing. Use `--no-browser`, `--no-wait` or `--timeout <seconds>`, and read the current status with `backify domains connect --request TASK_UUID`. Exit code 2 means not yet confirmed or blocked. The CLI never changes DNS or approves the domain itself.
47
+
48
+ ## Coding-tool MCP bridge
49
+
50
+ `backify mcp [--organization <organization-id>]` bridges stdio to the single
51
+ organization MCP at `https://mcp.backify.dev`. Sign in explicitly using
52
+ `backify login --organization <organization-id> --organization-access`; the browser
53
+ page lets you choose what coding tools may change (reading is always allowed), and
54
+ the bridge keeps that MCP grant renewed for up to 90 days (30 days without use).
55
+ Disconnect it under Account settings, Connected coding tools. Application
56
+ sessions remain app-scoped and cannot administer organizations. The bridge rereads
57
+ credentials per request and pins the organization until restarted. Discover and
58
+ describe customer API operations, prepare changes, obtain explicit user approval,
59
+ then execute with a one-use confirmation. All API permissions and release policies
60
+ still apply. See the [plugin guide](../../docs/coding-tool-plugins.md).
61
+
62
+ `backify tools configure --agent copilot|cursor|gemini` adds the selected host's
63
+ native HTTP configuration for that same MCP. Cline and Windsurf/Cascade additionally
64
+ require `--config <exact-editor-config-path>`. `--dry-run` previews without writing;
65
+ `--transport stdio` selects the existing local bridge instead. Existing settings
66
+ and other MCP servers are preserved; conflicting Backify entries and JSONC files
67
+ are never overwritten. Native HTTP authorization opens the existing Backify portal
68
+ for explicit organization consent and gives the coding tool only an opaque MCP
69
+ token. Native connections refresh themselves for up to 90 days and survive MCP
70
+ server restarts. Application instruction selection additionally supports
71
+ `--agent cursor`, `--agent cline` and `--agent windsurf`.
72
+
73
+
74
+ ## Organization operations from the terminal
75
+
76
+ `backify ops` runs any operation in the organization catalog (the same operations
77
+ the MCP's `list_operations`, `describe_operation`, `read_operation` and
78
+ `execute_operation` tools expose) directly, for people and for agents without MCP:
79
+
80
+ ```bash
81
+ backify ops search members # ranked; synonyms, plurals and small typos match
82
+ backify ops search --group Apps --limit 50 # one area; plain `ops search` lists the groups
83
+ backify ops describe Apps.Get # route, parameters, body schema, scopes, example
84
+ backify ops get Apps.Get --param id=<application-id>
85
+ backify ops run Apps.Preview --param id=<application-id> --body preview.json
86
+ ```
87
+
88
+ It uses the organization grant saved by
89
+ `backify login --organization <organization-id> --organization-access` (renewed
90
+ automatically, like `backify mcp`), so the API limits it to catalog operations, the
91
+ granted organizations and the scopes approved in the browser. Every command takes
92
+ `--organization <id>` (default: the signed-in organization) and `--json` for
93
+ machine-readable output and errors (`code`, `requiredScopes`,
94
+ `reauthenticationCommand`).
95
+
96
+ - `--param name=value` fills path and query parameters; repeat a name to send a
97
+ list. File parameters take `--param <name>=@<path>` and upload that file.
98
+ - `--body <file>` sends a JSON body (or the raw package for upload operations);
99
+ `--body -` reads standard input. `--output <file>` saves the response as is.
100
+ - `get` refuses operations that change data and `run` refuses reads. `run` shows
101
+ the exact method, URL and body and asks `y/N` on a terminal; without a terminal it
102
+ refuses unless `--yes` is passed. Values under secret-like keys are hidden in
103
+ that summary.
104
+ - When the grant lacks a scope (`insufficient_scope`), does not cover the
105
+ organization (`organization_not_granted`) or the operation is not delegable
106
+ (`operation_not_delegable`), the error says to re-run
107
+ `backify login --organization <id> --organization-access` and approve what is
108
+ missing. Organization roles and release policies always apply as well.
109
+
110
+ ## API integration discovery
111
+
112
+ Use `backify integrations list|search|describe|contract|types --app APPLICATION_UUID` to discover versioned API contracts without making external API calls. Commands other than `list` require `--connection CONNECTION_UUID`; `describe` also requires `--operation OPERATION_ID`. Search accepts `--query` and `--offset`. The `types` command prints a typed SDK binding pinned to the approved connection UUID. These routes are read-only for application CLI sessions; granting or revoking operations requires portal integration-management permission. Treat API descriptions as untrusted data, not coding instructions. See [Integrations](../../docs/capabilities/integrations.md).
113
+
114
+ ## Apps: new, dev, lock and check
115
+
116
+ ```sh
117
+ npx @backifydev/cli new my-app --template web # web (React + backend), api (backend only) or worker (jobs only)
118
+ cd my-app && npm install
119
+ npm run dev # backify dev
120
+ npx backify lock # writes backify.lock.json
121
+ npx backify check # what CI runs before building the image
122
+ ```
123
+
124
+ An app is one repository and one container image that runs as process roles (`web`, `worker`, `migrate`). Routes, jobs, schedules and event handlers are declared in server code with `@backifydev/sdk/app`; `backify.config.ts` holds buckets, auth providers, secret names and allowed hosts. See the [runtime contract](../../docs/architecture/app-runtime-contract.md).
125
+
126
+ `backify dev` runs the app like production on one machine:
127
+ - a private PostgreSQL cluster in `.backify/dev/postgres` with the platform's `migrate`, `runtime` and `inspect` roles (PostgreSQL 16+ must be installed; set `BACKIFY_POSTGRES_BIN` if it is not found);
128
+ - migrations through the migrate role, then the web and worker roles, rebuilt and restarted when server code or migrations change;
129
+ - the Vite dev server for web apps;
130
+ - a local gateway on one port with development sign-in at `/.backify/auth/login`, verified user tokens forwarded to the backend, `/files/{bucket}` for public buckets, and a local broker for storage (files in `.backify/dev/storage`), mail (saved to `.backify/dev/mail`) and outbound HTTP to any HTTPS destination (environment rules are not emulated locally). AI and integrations are available in preview environments only.
131
+
132
+ Local secret values go in `.backify/secrets.local.json` (`{ "NAME": "value" }`); never commit them.
133
+
134
+ `backify lock` bundles the server entry and runs it once in describe mode, with no credentials, platform variables or database, to collect declarations. It writes `backify.lock.json`: routes with auth and an OpenAPI document, jobs, schedules, event subscriptions, migration digests and capabilities. It refuses to write the file when:
135
+ - a declaration is not at module top level, or uses a computed name, path, cron or auth;
136
+ - code uses a capability that `backify.config.ts` does not configure.
137
+
138
+ A public POST/PUT/PATCH/DELETE route produces a warning. `backify lock --check` and `backify check` fail when the committed lockfile no longer matches the code; `check` first runs the app's `typecheck`, `lint`, `test` and `build` scripts (`--lockfile-only` skips them).
139
+
140
+
141
+ ## Connected delivery
142
+
143
+ ```sh
144
+ npx @backifydev/cli init --app app_xxxxx
145
+ npx @backifydev/cli doctor
146
+ npx @backifydev/cli sync
147
+ npx @backifydev/cli login
148
+ npx @backifydev/cli status
149
+ npx @backifydev/cli report --check
150
+ npx @backifydev/cli pull
151
+ npx @backifydev/cli ship
152
+ ```
153
+
154
+ `login` in an application folder, or `connect --reauth`, opens `https://auth.backify.dev` for sign-in and explicit CLI approval. Choose 7, 14, 30, or 90 days; after approval the CLI saves an application-scoped credential in `~/.backify.json` and continues automatically. The browser can then be closed. No copied setup prompt or pasted credential is required. `login` outside an application retains general sign-in for later connection. Set `BACKIFY_AUTH_URL` for a different authorization host (HTTPS, or loopback HTTP for local development); legacy `BACKIFY_PORTAL_URL` and `portalUrl` configuration remain supported. `login <token> [organizationId]` remains available for scripted development.
155
+
156
+ Authenticated application commands recover automatically from a known expired credential or an API 401: they open browser approval, replace the saved application credential, and retry the rejected request once. Permission errors (403), network failures, and service errors do not trigger sign-in or write retries. Use `--no-browser` for unattended work. With `--json`, authentication failures include `code: "authentication_required"` and `reauthenticationCommand: "backify connect --reauth"`. A coding agent should ask its user to sign in before starting explicit recovery. The callback accepts only the selected authorization origin and matching random state/application/organization, is bound to `127.0.0.1`, and closes after approval or a five-minute timeout. Browser local-network access may need approval. A remotely hosted or headless coding tool needs a browser on the CLI host that can reach this loopback listener; this flow does not add remote device-code authentication.
157
+
158
+ `init` installs `@backifydev/sdk`, updates `app.id`, `instructionVersion` and coding-tool metadata in `backify.config.ts`, writes `BACKIFY.md`, and maintains only the selected coding tool's Backify block. Use `--agent codex` (`AGENTS.md`), `--agent claude` (`CLAUDE.md`), `--agent copilot` (`.github/copilot-instructions.md`), `--agent gemini` (`GEMINI.md`), `--agent cursor`/`--agent windsurf` (`AGENTS.md`), or `--agent cline` (`.clinerules/backify.md`). The CLI remembers the selection for `init`, `sync`, and `doctor`; new projects default to Codex. For any other tool, pass `--instruction-file <relative-path>` to use its native instruction or rule file, including nested paths; this is remembered too. It preserves other instructions and does not create or modify other tools' files.
159
+
160
+ The app configuration stores `instructionVersion`, matching the version declared in each managed block and its immutable guide at `https://agent.backify.dev/v<number>`. The agent root always serves the latest guide as plain text. `doctor` detects version/content drift and malformed markers. Use `npx @backifydev/cli@latest sync` to explicitly upgrade all blocks and the configuration together; unrelated configuration and unmanaged instructions remain unchanged.
161
+
162
+ For a new application, start with `backify new <name> --template web|api|worker` before connecting. `init` installs the selected coding tool instructions into that app. Existing older workspaces using `backify.json` remain readable until a deliberate migration. Existing manifests are preserved; in a non-empty application or monorepo, run `init` from the appropriate JavaScript/TypeScript package directory.
163
+
164
+ See the [agent setup guide](https://agent.backify.dev/).
165
+
166
+ Copy the application's setup prompt from Backify. It contains only the public app reference and https://agent.backify.dev/; the guide supplies fresh-machine prerequisite checks, npx commands, browser authorization and workspace setup. No global CLI installation, organization ID or pairing code is needed. Run `npx @backifydev/cli@latest connect --app <app-id> --reauth --api https://api.backify.dev/api`, adding `--clone` for a fresh workspace according to the guide. Keep the command running while the user selects the app's organization and approves access in the browser. The CLI receives and saves the app-scoped credential in the user's home configuration; it never belongs in chat, project files or Git. Supported browser approvals last 7, 14, 30, or 90 days. Existing pairing options remain available for legacy prompts; use `--pair-stdin` with private terminal input, never shell arguments, logs, environment variables or temporary files. The default API is `https://api.backify.dev/api`; trusted nonproduction environments can override it with `BACKIFY_API_URL` or `--api`. HTTPS is required outside loopback.
167
+
168
+ `init` adds a persistent delivery guide linked from the existing agent instructions. For every user request associated with the application, including setup, questions, deployment, application work, and Backify platform troubleshooting, the agent sends only the user's own text through stdin to `backify prompt record --stdin --id <UUID> --type <build|deploy|fixing|other>`, optionally adding repeated `--filename <basename>` arguments. Reuse the UUID on retries. The command never reads attachments; their bodies, extracted text, full paths, and credentials must not be submitted. Setup/pairing requests are recorded with secrets replaced by [REDACTED], never excluded. The CLI and API redact recognized Backify session tokens and pairing codes; redact all other secrets before submission. History is displayed oldest-first under the application. This is an explicit agent workflow, not an automatic interceptor for every coding tool. Record the model, AI coding tool, and effective access for each request with --model, --ai-tool, and --access-level whenever known. Access is a short description of the tool’s actual filesystem, network, and approval permissions at the time of the request, not its Backify role. Use only exposed session information; never guess unknown values or inspect credentials to discover them. Omit unknown fields; older or incomplete records display “Not recorded”. These values are self-reported metadata, not verified authorization. Reuse the same metadata on retries. Model and tool names are limited to 200 characters each; access descriptions to 500. Never include secrets, tokens, full paths, or configuration file contents. Include the exposed model family and version, for example gpt-6-luna or gpt-6.1-sol, rather than only the tool name. Separate filesystem, network, and approval access descriptions with semicolons so each appears as a separate badge. The CLI automatically records the installed @backifydev/sdk version from the project or its hoisted node_modules, never the dependency range. Use --sdk-version to preserve the original installed version on retries or when auto-detection is unavailable; SDK versions are limited to 100 characters. Unknown SDK and model versions remain “Not recorded”; never guess them. Use build for application features and application bug fixes, deploy for shipping or launching, fixing only for Backify platform/SDK/CLI/connection/hosting troubleshooting (not application-code bugs), and other for setup, questions, or uncategorized requests. The API defaults new requests without a type to other; older untyped records remain visible as Not recorded. Record requests received before authentication in conversation order as soon as connected; never persist credentials to queue them. Types are classifications, not success/failure statuses.
169
+
170
+ `pull` checks the connected application, repository, branch, and repository root, then fetches GitHub using a short-lived scoped credential. It fast-forwards only a clean, non-diverged branch. Incoming updates blocked by local changes, untracked files, or diverged history return a blocked result and a nonzero exit code; nothing is stashed, reset, rebased, or force-pushed. Connecting an existing repository runs this update automatically, and the agent guide requires it before editing each new user request. It is not a background watcher.
171
+
172
+ `ship` runs configured checks, verifies the repository/branch, and pushes already-committed source using a short-lived repository-scoped GitHub App credential. It never stages, commits, force-pushes, or fabricates preview testing. By default it waits for the exact healthy preview and returns its URL without requesting production publication. Plain requests such as “Now deploy” and approval to merge and retry remain preview-only; production requires an explicit user request to deploy to production. Instruction version 10 (CLI 0.3.12) makes this distinction explicit in installed guidance. Promote the preview in the portal, or explicitly run `ship --production-deploy` to request publication through existing policy and permissions. Required testing/approval returns a pending state and preview URL, not a false successful production deployment. The legacy `--preview-only` flag remains supported but cannot be combined with `--production-deploy`. Use `--timeout <seconds>` to change the default 1200-second wait. Applications must currently be at the repository root. CI checks the committed lockfile, builds and verifies one image, then uploads a release. The web role serves port 8080; web apps also upload a static frontend. Local Docker is not required for backify dev.
173
+
174
+ `disconnect` revokes that user's application CLI sessions. `logout` removes local credentials only. Prompt histories and local reports remain subject to application permissions. Deploy the matching API and publish CLI 0.3.0 before enabling this flow in production.
175
+
176
+ Connections now report the device hostname, operating system, architecture, and installed CLI version. Browser-based `connect` exchanges a general sign-in token for an application-scoped device session. Application **People & access → CLI access** shows these sessions and lets access managers revoke individual devices; source managers can revoke their own. Existing connections may need reconnecting to record device details. See [CLI access and country lookup configuration](../../docs/cli-access.md) for privacy, permissions and deployment requirements.
177
+ ## Environment diagnostics before onboarding
178
+
179
+ Backify is TypeScript-first: prefer React/Vite and an explicit TypeScript backend
180
+ for new applications. Existing frameworks are assessed individually and custom
181
+ containers remain an advanced hosting path. Doctor and local reports expose
182
+ advisory support tiers without rejecting existing stacks or claiming verified SDK
183
+ integration. See [application support](../../docs/application-support.md).
184
+
185
+ Container delivery uses a repository-root Dockerfile and committed backify.lock.json.
186
+ The SDK entrypoint runs web, worker and migrate roles. Local Docker is not required
187
+ for backify dev. Hosting a custom language does not imply SDK support for it. Generated GitHub workflows verify the exact production
188
+ image before registry publication. See [application build verification](../../docs/application-build-contract.md)
189
+ for supported layouts, diagnostics, limitations and rollout requirements.
190
+
191
+ Run `backify doctor --environment` before connection or initialization when the CLI is already installed. It checks Node.js, npm, optional Git, a unique workspace write/read/cleanup, and real loopback HTTP without changing application configuration. Missing terminal or Node.js/npm must be diagnosed by the coding environment before the CLI can run.
192
+
193
+ Add `--network` for bounded, credential-free probes of the public guide, documentation, anonymous API health and npm package metadata. Add `--capability <capability-name>` to probe that capability's documentation. No arbitrary endpoints, pairing credentials or tokens are accepted. Public production endpoints are tested, not a configured nonproduction API; diagnose a trusted override separately before connection.
194
+
195
+ JSON reports distinguish failed and unverified checks, network/HTTP failure classes and recovery guidance. A zero exit code means no tested required check failed, not that skipped network checks or application tests passed; inspect `verified` and individual checks. Native agent approval, cross-session persistence, browser authentication and deployment authorization cannot be inferred by CLI probes. Git is required for connected delivery but optional for unconnected local work.
196
+
197
+ The CLI cannot grant agent permissions: follow the supported native authorization mechanism described in [the central guide](https://agent.backify.dev), retry after approval and verify. Without approval support or after denial, report minimum required access and switch or configure environments; never bypass restrictions. The ordinary `doctor` command retains its repository instruction checks. Local probes do not verify the real application or replace reading capability documentation.
198
+
199
+ ## Safe SDK upgrades
200
+
201
+ Run backify upgrade from a clean npm app checkout to choose the latest stable compatible SDK, validate with application checks, and restore the previous locked dependencies on failure. Pre-1.0 updates stay within the installed minor. Package upgrades preserve the repository's instruction version; older versioned guides remain supported by newer CLIs.
202
+
package/dist/index.js CHANGED
@@ -46,12 +46,12 @@ var init_delivery = __esm({
46
46
  "use strict";
47
47
  deliveryInstructions = `# Backify application delivery and prompt history
48
48
 
49
- Instruction version: 18
50
- Versioned guide: https://agent.backify.dev/v18/delivery.md
49
+ Instruction version: 19
50
+ Versioned guide: https://agent.backify.dev/v19/delivery.md
51
51
 
52
52
  ## Environment and documentation prerequisites
53
53
 
54
- Before installation or connection, read https://agent.backify.dev/v18 for execution capability checks, required endpoints (including https://docs.backify.dev), native permission requests, verified retries and fallback guidance. Follow the current tool's supported approval mechanism; never bypass restrictions. Read relevant capability documentation before implementation. Local validation must not depend on cloud deployment.
54
+ Before installation or connection, read https://agent.backify.dev/v19 for execution capability checks, required endpoints (including https://docs.backify.dev), native permission requests, verified retries and fallback guidance. Follow the current tool's supported approval mechanism; never bypass restrictions. Read relevant capability documentation before implementation. Local validation must not depend on cloud deployment.
55
55
 
56
56
  Before application implementation, all required setup checks and connected status must be verified OK. If any required check fails or remains unverified after supported recovery, stop setup and implementation; do not build a local website, minimal shell, placeholder, dependency-free fallback, or downloadable application archive. Report the blockers and recommend running the setup prompt in an AI coding tool such as Codex, Claude Code, or VS Code with GitHub Copilot agent mode, with terminal access, a persistent writable workspace, package installation, outbound HTTPS/DNS, and test execution enabled. Tool names alone do not guarantee readiness. Do not ask the application requirements question while setup is blocked. Later preview approval or deployment failures do not invalidate an already verified setup gate.
57
57
 
@@ -63,7 +63,7 @@ The minimal setup prompt supplies only this guide reference and a public app ref
63
63
 
64
64
  npx @backifydev/cli@latest connect --app <app-id> --reauth --api https://api.backify.dev/api
65
65
 
66
- Add --clone according to the workspace rules below. Keep the CLI running while the user signs in at https://auth.backify.dev, selects the app's organization and explicitly approves application-scoped device access. The CLI receives the organization and credential directly; never ask for tokens or organization IDs in chat. Check the completed command result and retrieve app context using CLI status. Browser approval does not authorize production deployment. If authorization is cancelled, denied or times out, report the blocker and use only supported recovery.
66
+ Add --clone according to the workspace rules below. Keep the CLI running while the user signs in at https://auth.backify.dev, selects the app's organization and explicitly approves application-scoped device access. The CLI receives the organization and credential directly; never ask for tokens or organization IDs in chat. Browser approval is a status update, not a question: tell the user what to approve in a progress message and keep waiting for the command. Do not use a question or input-request tool, end the turn, or ask the user to reply in chat; the CLI continues automatically. The same applies to every CLI command that waits for a person in the browser. Check the completed command result and retrieve app context using CLI status. Browser approval does not authorize production deployment. If authorization is cancelled, denied or times out, report the blocker and use only supported recovery.
67
67
 
68
68
  For compatibility, legacy prompts may supply App Id, Organization, and Pair. Substitute those values for <app-id>, <organization-id>, and <pairing-code> below; never invent them. Use npx @backifydev/cli@latest so tool-specific setup and metadata-preserving cloning are available. The public API URL is https://api.backify.dev/api. For a nonproduction environment, replace the --api value with an explicitly trusted endpoint, or omit --api when using a trusted BACKIFY_API_URL override; never send a pairing code to an unverified endpoint.
69
69
 
@@ -77,7 +77,7 @@ Initialize using App Id from the copied prompt and the current tool selection:
77
77
 
78
78
  npx @backifydev/cli@latest init --app <app-id> --agent <current-tool>
79
79
 
80
- For a tool without a built-in preset, replace --agent <current-tool> with --instruction-file <relative-path>. Read BACKIFY.md and the instruction file used by the current AI coding tool before changing application code. Create or update only instruction files used by that tool; never create files for other coding tools. Use --agent for a built-in tool preset or --instruction-file <relative-path> for the current tool's native instruction file, as described in the setup guide. Initialization installs this workflow alongside the persistent SDK instructions. Follow https://agent.backify.dev/v18 for rebuilt applications; use the guide matching instructionVersion in backify.config.ts (or the existing older workspace metadata). Do not silently upgrade its managed instruction version or overwrite instructions outside the managed block.
80
+ For a tool without a built-in preset, replace --agent <current-tool> with --instruction-file <relative-path>. Read BACKIFY.md and the instruction file used by the current AI coding tool before changing application code. Create or update only instruction files used by that tool; never create files for other coding tools. Use --agent for a built-in tool preset or --instruction-file <relative-path> for the current tool's native instruction file, as described in the setup guide. Initialization installs this workflow alongside the persistent SDK instructions. Follow https://agent.backify.dev/v19 for rebuilt applications; use the guide matching instructionVersion in backify.config.ts (or the existing older workspace metadata). Do not silently upgrade its managed instruction version or overwrite instructions outside the managed block.
81
81
 
82
82
  Run the following to discover the connected hosting target, repository, branch, reports, releases, and deployment failures:
83
83
 
@@ -1769,7 +1769,7 @@ var init_dist = __esm({
1769
1769
  init_protection();
1770
1770
  init_auth_setup();
1771
1771
  init_operations();
1772
- INSTRUCTION_VERSION = 18;
1772
+ INSTRUCTION_VERSION = 19;
1773
1773
  SDK_PACKAGE = "@backifydev/sdk";
1774
1774
  DOCS_URL = "https://docs.backify.dev";
1775
1775
  MAIL_LIMITS = Object.freeze({
@@ -1953,7 +1953,7 @@ Check that the page shows the code ${status.matchCode}.` : ""));
1953
1953
  }
1954
1954
  }
1955
1955
  if (options.noWait) return { status, link, reason: "waiting_in_browser" };
1956
- options.progress?.("Waiting for you in the browser\u2026");
1956
+ options.progress?.("Waiting for you in the browser; no reply is needed in chat. The CLI continues automatically.\nCoding agents: tell the user this as a status update, not a question or input request, and keep waiting for this command to finish.");
1957
1957
  while (true) {
1958
1958
  if (status.state !== "pending") {
1959
1959
  options.progress?.(status.nextAction);
@@ -1994,7 +1994,7 @@ var init_package = __esm({
1994
1994
  "package.json"() {
1995
1995
  package_default = {
1996
1996
  name: "@backifydev/cli",
1997
- version: "0.4.1",
1997
+ version: "0.4.2",
1998
1998
  description: "Command-line setup and diagnostics for Backify applications",
1999
1999
  type: "module",
2000
2000
  bin: {
@@ -3996,7 +3996,7 @@ function datetime(args2) {
3996
3996
  const timeRegex = args2.local ? `${qualified}|${timeSource({ precision: args2.precision })}` : qualified;
3997
3997
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
3998
3998
  }
3999
- var cuid, cuid2, ulid, xid, ksuid, nanoid, duration, guid2, uuid7, email, _emoji, ipv4, ipv6, cidrv4, cidrv6, base642, base64url, httpProtocol, e164, dateSource, date, anyString, bigint, integer, number, boolean, _null, lowercase, uppercase;
3999
+ var cuid, cuid2, ulid, xid, ksuid, nanoid, duration, guid3, uuid7, email, _emoji, ipv4, ipv6, cidrv4, cidrv6, base642, base64url, httpProtocol, e164, dateSource, date, anyString, bigint, integer, number, boolean, _null, lowercase, uppercase;
4000
4000
  var init_regexes = __esm({
4001
4001
  "../../node_modules/zod/v4/core/regexes.js"() {
4002
4002
  cuid = /^[cC][0-9a-z]{6,}$/;
@@ -4006,7 +4006,7 @@ var init_regexes = __esm({
4006
4006
  ksuid = /^[A-Za-z0-9]{27}$/;
4007
4007
  nanoid = /^[a-zA-Z0-9_-]{21}$/;
4008
4008
  duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
4009
- guid2 = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
4009
+ guid3 = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
4010
4010
  uuid7 = (version2) => {
4011
4011
  if (!version2)
4012
4012
  return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
@@ -5021,7 +5021,7 @@ var init_schemas = __esm({
5021
5021
  $ZodString.init(inst, def);
5022
5022
  });
5023
5023
  $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
5024
- def.pattern ?? (def.pattern = guid2);
5024
+ def.pattern ?? (def.pattern = guid3);
5025
5025
  $ZodStringFormat.init(inst, def);
5026
5026
  });
5027
5027
  $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
@@ -23713,7 +23713,7 @@ async function follow(call2, initial, options, context2) {
23713
23713
  now: context2.now,
23714
23714
  intervalMs: context2.intervalMs
23715
23715
  }, purposes[initial.kind] ?? "complete the request");
23716
- const value = { taskId: status.id, kind: status.kind, state: status.state, url: link, matchCode: initial.matchCode ?? void 0, nextAction: status.nextAction, result: status.result, ...reason ? { waiting: reason } : {} };
23716
+ const value = { taskId: status.id, kind: status.kind, state: status.state, url: link, nextAction: status.nextAction, result: status.result, ...reason ? { waiting: reason } : {} };
23717
23717
  const exitCode = status.state === "completed" ? 0 : status.state === "pending" ? 2 : 1;
23718
23718
  const text2 = status.state === "pending" ? `The task is waiting for a person: ${link}` + (reason === "timed_out" ? "\nStopped waiting. Resume with backify task wait " + status.id : "") : `${status.state}: ${status.nextAction}` + (status.result ? "\n" + JSON.stringify(status.result, null, 2) : "");
23719
23719
  return { value, text: text2, exitCode };
@@ -30616,8 +30616,7 @@ function startGateway(options) {
30616
30616
  }
30617
30617
  if (path === "/v1/http/fetch") {
30618
30618
  const target = new URL(String(body.url));
30619
- const allowed = (config2.http?.allow ?? []).some((host) => host.startsWith("*.") ? target.hostname.endsWith(host.slice(1)) : target.hostname === host);
30620
- if (!allowed || target.protocol !== "https:") return brokerError(res, 403, "host_not_allowed", `${target.hostname} is not in backify.config.ts http.allow (https only)`);
30619
+ if (target.protocol !== "https:") return brokerError(res, 403, "https_required", `Outbound HTTP to ${target.hostname} must use https`);
30621
30620
  const response = await fetch(target, { method: String(body.method ?? "GET"), headers: body.headers, body: body.body, signal: AbortSignal.timeout(Number(body.timeoutSeconds ?? 30) * 1e3) });
30622
30621
  const bytes = Buffer.from(await response.arrayBuffer());
30623
30622
  return json(res, 200, { status: response.status, headers: Object.fromEntries(response.headers), body: bytes.toString("base64"), encoding: "base64" });
@@ -31235,7 +31234,7 @@ import { domainToASCII } from "node:url";
31235
31234
  var domainConnectHelp = `backify domains connect [hostname] [--app <application>] [--environment preview|production]
31236
31235
  backify domains connect --request <UUID> [--app <application>]
31237
31236
  Options: --hostname <hostname> --no-browser --no-wait --timeout <seconds, 1-3600> --json
31238
- Requests a Backify task and opens its page, where an authorized user signs in, checks the match code the CLI prints
31237
+ Requests a Backify task and opens its page, where an authorized user signs in
31239
31238
  and confirms the hostname and environment. Returns as soon as the domain is confirmed. It does not wait for DNS: Backify verifies the DNS records, issues managed HTTPS and starts
31240
31239
  routing automatically once the user adds them. Exit code 0 means confirmed; 2 means not yet confirmed or blocked.
31241
31240
  Re-run with --request <task-id> to read the current status without reopening the browser.`;
@@ -31279,7 +31278,6 @@ async function connectDomain(call2, options) {
31279
31278
  certificateStatus: status?.certificateStatus ?? null,
31280
31279
  bindingStatus: status?.bindingStatus ?? null,
31281
31280
  setupUrl: link,
31282
- matchCode: initial.matchCode ?? null,
31283
31281
  nextAction: task.nextAction,
31284
31282
  // The address the domain will serve once DNS is verified; `url` is set only when it already does.
31285
31283
  expectedUrl: status?.hostname ? "https://" + status.hostname : null,
@@ -31474,6 +31472,63 @@ function privacyRequestCall(appId, args2) {
31474
31472
  }
31475
31473
  }
31476
31474
 
31475
+ // src/outbound-http.ts
31476
+ var outboundHttpUsage = [
31477
+ "Use backify outbound <action> --environment <UUID> [--app <application-id>]:",
31478
+ " show default action and rules",
31479
+ " default allow|deny what happens to destinations no rule matches (allow is the default)",
31480
+ " allow|block <pattern> allow or block a host (api.example.com), a wildcard ('*.example.com')",
31481
+ " or an HTTPS URL (https://api.example.com/v1/*); a block always wins",
31482
+ " remove <rule-id>",
31483
+ " destinations [--search <text>] URLs requested in the last 30 days with what the rules decide now",
31484
+ " requests [--search <text>] [--outcome allowed|blocked|not-allowed]",
31485
+ "List environments with backify events environments. Quote wildcards so your shell does not expand them."
31486
+ ].join("\n");
31487
+ var guid2 = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
31488
+ function outboundHttpCall(appId, args2) {
31489
+ const option2 = (name2) => {
31490
+ const index = args2.indexOf(name2);
31491
+ return index >= 0 ? args2[index + 1] : void 0;
31492
+ };
31493
+ const [action, value] = args2;
31494
+ const environment = option2("--environment");
31495
+ if (!action || !environment || !guid2.test(environment)) throw new Error(outboundHttpUsage);
31496
+ const base = `/apps/${appId}/outbound-http/environments/${environment}`;
31497
+ const query = (names) => {
31498
+ const params = new URLSearchParams();
31499
+ for (const name2 of names) {
31500
+ const item = option2("--" + name2);
31501
+ if (item) params.set(name2, item);
31502
+ }
31503
+ const text2 = params.toString();
31504
+ return text2 ? "?" + text2 : "";
31505
+ };
31506
+ const positional = value !== void 0 && !value.startsWith("--") ? value : void 0;
31507
+ switch (action) {
31508
+ case "show":
31509
+ return { method: "GET", path: base };
31510
+ case "default":
31511
+ if (positional !== "allow" && positional !== "deny") throw new Error("Use backify outbound default allow|deny --environment <UUID>.");
31512
+ return { method: "PUT", path: base + "/default", body: { action: positional } };
31513
+ case "allow":
31514
+ case "block":
31515
+ if (!positional) throw new Error(`Give a host, wildcard or HTTPS URL: backify outbound ${action} <pattern> --environment <UUID>.`);
31516
+ return { method: "POST", path: base + "/rules", body: { pattern: positional, action } };
31517
+ case "remove":
31518
+ if (!positional || !guid2.test(positional)) throw new Error("Give the rule ID from backify outbound show: backify outbound remove <rule-id> --environment <UUID>.");
31519
+ return { method: "DELETE", path: `${base}/rules/${positional}` };
31520
+ case "destinations":
31521
+ return { method: "GET", path: base + "/destinations" + query(["search"]) };
31522
+ case "requests": {
31523
+ const outcome = option2("--outcome");
31524
+ if (outcome !== void 0 && !["allowed", "blocked", "not-allowed"].includes(outcome)) throw new Error("--outcome must be allowed, blocked or not-allowed.");
31525
+ return { method: "GET", path: base + "/requests" + query(["search", "outcome"]) };
31526
+ }
31527
+ default:
31528
+ throw new Error(outboundHttpUsage);
31529
+ }
31530
+ }
31531
+
31477
31532
  // src/pairing.ts
31478
31533
  async function pairingCode(args2, input) {
31479
31534
  const stdinCount = args2.filter((value) => value === "--pair-stdin").length;
@@ -31676,7 +31731,7 @@ var help = [
31676
31731
  "Org tasks: task start <kind> [--draft <json>] | task get|wait|open <id> | github connect | azure connect|reconnect|update-agent|uninstall|remove | org | billing | members add|invite|list|invitations|join-links|domains (backify task --help)",
31677
31732
  "Delivery: pull | report [--check] | ship [--production-deploy|--preview-only] [--dry-run] | deploy [<application-id>] [<source-revision>] | request",
31678
31733
  " prompt record --stdin --id <UUID>",
31679
- "Platform: database extensions|insights --environment <UUID> [--hours <n>] | privacy requests list|show|create|update|close|preview | events environments|inspect|test | auth setup [--providers <list>] | domains connect [hostname] | integrations connect <provider>|discover|prepare|status|list|catalog|search|describe|contract|types",
31734
+ "Platform: database extensions|insights --environment <UUID> [--hours <n>] | privacy requests list|show|create|update|close|preview | events environments|inspect|test | outbound show|default|allow|block|remove|destinations|requests --environment <UUID> | auth setup [--providers <list>] | domains connect [hostname] | integrations connect <provider>|discover|prepare|status|list|catalog|search|describe|contract|types",
31680
31735
  "",
31681
31736
  "Docs: https://docs.backify.dev/"
31682
31737
  ].join("\n");
@@ -31693,7 +31748,7 @@ async function browserLogin(appId, organizationId, apiUrl) {
31693
31748
  if (args.includes("--no-browser")) throw new CliAuthenticationRequired();
31694
31749
  const address = apiAddress(apiUrl ?? process.env.BACKIFY_API_URL ?? userConfig.apiUrl ?? "https://api.backify.dev/api");
31695
31750
  return browserAuthenticate({ authUrl, apiUrl: address, applicationId: appId ? applicationGuid(appId) : void 0, organizationId, mcp: appId ? void 0 : { endpoint: process.env.BACKIFY_MCP_URL ?? "https://mcp.backify.dev" }, openBrowser: (url2) => {
31696
- console.error("Sign in to authorize Backify CLI access. Choose the expiration in your browser; the CLI will continue automatically.\n" + url2);
31751
+ console.error("Waiting for browser approval; no reply is needed in chat. Sign in, choose the organization and expiration, and approve Backify CLI access. The CLI continues automatically after approval.\n" + url2 + "\nCoding agents: tell the user this as a status update, not a question or input request, and keep waiting for this command to finish.");
31697
31752
  openBrowser(url2);
31698
31753
  }, save: (session, mcp) => {
31699
31754
  if (appId) {
@@ -32101,6 +32156,17 @@ Next: cd ${directory} && npm install && npm run dev`);
32101
32156
  console.log(JSON.stringify(await call(request.path, { method: request.method, body: request.body ? JSON.stringify(request.body) : void 0 }), null, 2));
32102
32157
  break;
32103
32158
  }
32159
+ case "outbound": {
32160
+ if (!args.length || args.includes("--help")) {
32161
+ console.log(outboundHttpUsage);
32162
+ if (!args.length) process.exitCode = 2;
32163
+ break;
32164
+ }
32165
+ const request = outboundHttpCall(applicationGuid(option("--app") ?? projectApplication()), args);
32166
+ const result = await call(request.path, { method: request.method, body: request.body ? JSON.stringify(request.body) : void 0 });
32167
+ console.log(request.method === "DELETE" ? "Removed the rule." : JSON.stringify(result, null, 2));
32168
+ break;
32169
+ }
32104
32170
  case "events": {
32105
32171
  const appId = applicationGuid(option("--app") ?? projectApplication());
32106
32172
  const prefix = "/apps/" + appId + "/events";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backifydev/cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Command-line setup and diagnostics for Backify applications",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  import { defineConfig } from "@backifydev/sdk/config";
2
2
 
3
3
  export default defineConfig({
4
- instructionVersion: 18,
4
+ instructionVersion: 19,
5
5
  app: { name: "{{name}}" },
6
6
  kind: "api",
7
7
  server: { entry: "server/index.ts" },
@@ -1,7 +1,7 @@
1
1
  import { defineConfig } from "@backifydev/sdk/config";
2
2
 
3
3
  export default defineConfig({
4
- instructionVersion: 18,
4
+ instructionVersion: 19,
5
5
  app: { name: "{{name}}" },
6
6
  kind: "web",
7
7
  server: { entry: "server/index.ts" },
@@ -1,7 +1,7 @@
1
1
  import { defineConfig } from "@backifydev/sdk/config";
2
2
 
3
3
  export default defineConfig({
4
- instructionVersion: 18,
4
+ instructionVersion: 19,
5
5
  app: { name: "{{name}}" },
6
6
  kind: "worker",
7
7
  server: { entry: "server/index.ts" },