@oxy-hq/cli 0.11.0 → 0.12.1
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 +406 -16
- package/dist/main.mjs +6563 -8427
- package/dist/main.mjs.map +1 -1
- package/dist/{mcp-B2KBWNOU.mjs → mcp-CJWQm-yd.mjs} +147 -190
- package/dist/mcp-CJWQm-yd.mjs.map +1 -0
- package/json-schemas/config.json +26 -45
- package/json-schemas/workflow.json +0 -17
- package/package.json +6 -5
- package/skills/oxy-agents/SKILL.md +15 -4
- package/skills/oxy-agents/references/quick-reference.md +1 -1
- package/skills/oxy-automations/SKILL.md +1 -1
- package/skills/oxy-cli/SKILL.md +91 -4
- package/skills/oxy-custom-apps/SKILL.md +233 -13
- package/skills/oxy-custom-apps/references/environment-branches.md +172 -0
- package/skills/oxy-custom-apps/references/phone-layout.md +88 -0
- package/skills/oxy-custom-apps/references/reading-data.md +4 -6
- package/skills/oxy-custom-apps/references/sandbox-agent-loop.md +120 -17
- package/skills/oxy-custom-apps/references/verifying-in-the-browser.md +19 -9
- package/skills/oxy-evals/SKILL.md +1 -1
- package/skills/oxy-experiments/SKILL.md +245 -0
- package/skills/oxy-semantic-modeling/SKILL.md +2 -2
- package/template/.github/workflows/publish.yaml +1 -1
- package/dist/mcp-B2KBWNOU.mjs.map +0 -1
- package/json-schemas/app.json +0 -1884
- package/skills/oxy-data-apps/SKILL.md +0 -362
- package/skills/oxy-data-apps/references/examples.md +0 -263
- package/skills/oxy-data-apps/references/quick-reference.md +0 -171
- package/skills/oxy-data-apps/templates/dashboard-with-controls.app.yml +0 -128
- package/skills/oxy-data-apps/templates/simple-dashboard.app.yml +0 -102
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Environment branches: test any part of an app on its own copy
|
|
2
|
+
|
|
3
|
+
A non-production environment (`staging`, or a `dev-<handle>` sandbox) is a
|
|
4
|
+
**branch** of the app, the way a database branch is. It has:
|
|
5
|
+
|
|
6
|
+
- a **parent**: the environment it was created `--from`. Only the build comes
|
|
7
|
+
from the parent. Data planes always fork from **production**, never from
|
|
8
|
+
another sandbox;
|
|
9
|
+
- a **fork point** (`--at`): the moment production's data is copied from;
|
|
10
|
+
- a **mode per plane**: for each part of the app's state, how isolated this
|
|
11
|
+
environment is.
|
|
12
|
+
|
|
13
|
+
The defaults keep a sandbox's old behaviour: reads hit production, and writes
|
|
14
|
+
are isolated or held. Turn on more isolation only for the parts you are testing.
|
|
15
|
+
|
|
16
|
+
Every command below takes the usual `--env <deployment>` (and `--token-env
|
|
17
|
+
OXY_TOKEN` for an agent; see [sandbox-agent-loop.md](sandbox-agent-loop.md)).
|
|
18
|
+
|
|
19
|
+
## Pick the modes by what you are testing
|
|
20
|
+
|
|
21
|
+
| You want to test | Use |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| A migration, or a function that edits records, against production's real rows | `--plane oltp=branch` (add `--at <ts>` for an exact moment) |
|
|
24
|
+
| A migration against production's structure with no rows | `--plane oltp=empty` |
|
|
25
|
+
| A function that appends Airhouse facts and reads them back | `--plane airhouse=branch` |
|
|
26
|
+
| A test that must see the same Airhouse rows every run | `--plane airhouse=snapshot` |
|
|
27
|
+
| What an email or notification would say, without sending it | `--plane messages=capture`, then `oxyc env outbox` |
|
|
28
|
+
| That the app works with none of staging's or production's secrets | `--plane secrets=empty`, then `env secret set` what it needs |
|
|
29
|
+
| That the app copes with no files yet | `--plane storage=empty` |
|
|
30
|
+
| A real write to a third-party **sandbox** account (Stripe test keys, a QuickBooks sandbox company, Square sandbox …) | `--fetch-host <host>` (repeatable; implies `fetch=allow`) |
|
|
31
|
+
| Writes to a warehouse database of the sandbox's own | `--destination <db>=<mapped>` |
|
|
32
|
+
| A semantic-model change on a git branch | `--plane semantic=branch:<branch>` |
|
|
33
|
+
| An automation the bundle starts, without its side effects | `--plane workspace-actions=preview` |
|
|
34
|
+
| As much isolation as has shipped, in one flag | `--preset full` |
|
|
35
|
+
|
|
36
|
+
Combine as many as you need. A choice you name always wins over the preset.
|
|
37
|
+
|
|
38
|
+
## The planes
|
|
39
|
+
|
|
40
|
+
| Plane (`key`) | Default | Other modes |
|
|
41
|
+
| --- | --- | --- |
|
|
42
|
+
| `build` | `own`: what you publish to it; `--from` starts it on the parent's build | — |
|
|
43
|
+
| `semantic` | `build-pin`: the model the build was published with | `branch:<b>`: the head of a workspace git branch, re-pinned on every push |
|
|
44
|
+
| `reads` (`ctx.query`, `ctx.warehouse.query`) | `live`: production, read-only | — (customer warehouses are never copied) |
|
|
45
|
+
| `oltp` (`ctx.oltp`) | `schema`: the app's schema in the org's shared staging branch | `branch`: its own database branch, production's tables **and rows** at the fork point · `empty`: its own branch, structure only |
|
|
46
|
+
| `airhouse` (`ctx.airhouse`) | `write-only`: writes go to a sibling schema, queries read production | `branch`: queries see the sandbox's own writes first, then production live · `snapshot`: the same, with the rest pinned to the fork point |
|
|
47
|
+
| `warehouse` (`ctx.warehouse` writes) | `mapped`: the manifest's `nonProduction.destinations` | per-environment overrides with `--destination` |
|
|
48
|
+
| `storage` (`ctx.storage`) | `branch`: its own files, and reads fall back to production's same key | `empty`: its own files only |
|
|
49
|
+
| `secrets` (`ctx.env`) | `inherit`: its own value, then staging's, then production's `shared` | `empty`: its own value only |
|
|
50
|
+
| `messages` (`ctx.email.send`, `ctx.notify`) | `invoker`: sent to the caller only, subject prefixed with the environment | `capture`: sent to nobody, kept in the outbox |
|
|
51
|
+
| `fetch` (mutating `ctx.fetch`) | `held-writes`: recorded, not sent | `allow` + a host list of registered provider sandboxes |
|
|
52
|
+
| `schedules` | `switch`: off until `oxyc env schedules <app> <env> --on` | — |
|
|
53
|
+
| `workspace-actions` (agent asks, automation runs) | `held` | `refused`: `403` · `preview`: an automation run executes as a held dry run |
|
|
54
|
+
|
|
55
|
+
`--preset full` sets `oltp=branch`, `secrets=empty`, `messages=capture`,
|
|
56
|
+
`airhouse=branch` and `workspace-actions=preview`. It never sets `fetch`
|
|
57
|
+
(opening third-party writes is a per-host decision) or `semantic` (a preset
|
|
58
|
+
cannot pick your branch). `storage` stays `branch`; add `--plane storage=empty`
|
|
59
|
+
too if you want it.
|
|
60
|
+
|
|
61
|
+
Fixed, whatever the modes:
|
|
62
|
+
|
|
63
|
+
- **Production has no planes.** No mode, preset or override writes to production.
|
|
64
|
+
- `ctx.airway.run` is refused in every non-production environment.
|
|
65
|
+
- `oltp=branch|empty` and `airhouse=branch|snapshot` are **sandbox-only**.
|
|
66
|
+
Staging refuses them, so `--preset full` on staging is refused.
|
|
67
|
+
- `oltp=branch|empty` needs an org with an OLTP database. Without one, pass
|
|
68
|
+
`--plane oltp=schema` with `--preset full`.
|
|
69
|
+
|
|
70
|
+
## The lifecycle
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Create: a branch of production's data, as of an hour ago, on staging's build
|
|
74
|
+
oxyc env create acme/store dev-x --from staging --at 2026-11-03T08:00:00Z --preset full --json
|
|
75
|
+
oxyc env show acme/store dev-x # the planes line: each mode, and where it came from
|
|
76
|
+
oxyc publish --app-env dev-x --json # or skip it: --from already gave it staging's build
|
|
77
|
+
|
|
78
|
+
# Change one plane later (=default clears it; --replace sends exactly these flags)
|
|
79
|
+
oxyc env update acme/store dev-x --plane storage=empty
|
|
80
|
+
oxyc env update acme/store dev-x --plane fetch=allow --fetch-host connect.squareupsandbox.com
|
|
81
|
+
|
|
82
|
+
# Read what it did
|
|
83
|
+
oxyc env outbox acme/store dev-x --json # what a capture environment kept
|
|
84
|
+
oxyc invocations held acme/store <invocation-id> # what a call held, or sent under fetch=allow
|
|
85
|
+
oxyc env diff acme/store dev-x --json # its OLTP schema against production's
|
|
86
|
+
|
|
87
|
+
# Start a plane over
|
|
88
|
+
oxyc env reset acme/store dev-x --plane storage,secrets,messages # each answers done
|
|
89
|
+
oxyc env reset acme/store dev-x --plane oltp --at <ts> # re-cuts: queued, poll env show
|
|
90
|
+
oxyc env reset acme/store dev-x --plane airhouse # drops its copies, re-pins to now
|
|
91
|
+
|
|
92
|
+
oxyc env delete acme/store dev-x --yes --wait # tears its branches down
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
- **`--at`** is not in the future and is within the last 24 hours (the
|
|
96
|
+
database's history window; Airhouse keeps snapshots one day too).
|
|
97
|
+
- **An OLTP branch is cut in the background.** `env show` reports
|
|
98
|
+
`oltp_branch.status`: `cutting`, `migrating`, `ready`, `resetting` or `failed`.
|
|
99
|
+
A reset that is queued but not started still reads `ready`, with
|
|
100
|
+
`oltp_branch.recut_queued: true`, so wait for that to be `false` too.
|
|
101
|
+
`ctx.oltp` is refused, with the reason, until it is `ready`. It is never
|
|
102
|
+
routed to staging or production in the meantime, so poll before the first call.
|
|
103
|
+
- **Reset** puts a plane back to a clean copy of its source. A sandbox resets
|
|
104
|
+
`oltp`, `airhouse`, `storage`, `secrets` and `messages`. Staging resets
|
|
105
|
+
`messages` only, because the team shares the rest. A sandbox on
|
|
106
|
+
`oltp=schema` has nothing to reset: publish again to re-seed it.
|
|
107
|
+
- **Expiry.** A sandbox is deleted after 7 idle days. One holding a copy of
|
|
108
|
+
production's rows (`oltp=branch`, or `airhouse=branch|snapshot`) is also
|
|
109
|
+
deleted 30 days after its fork point, however busy it is; `env show` gives
|
|
110
|
+
the day as `copies_expire_at`. `env reset` of that plane starts the 30 days
|
|
111
|
+
again, and so does turning such a plane on for a sandbox that held no copy.
|
|
112
|
+
Moving `airhouse` back to `write-only` keeps the rows it copied, still on the
|
|
113
|
+
same clock: `env reset --plane airhouse` drops them. `oltp=empty` holds no
|
|
114
|
+
rows and is not deleted for age.
|
|
115
|
+
- **Entering `airhouse=snapshot`** on an existing sandbox pins the snapshot to
|
|
116
|
+
that moment.
|
|
117
|
+
- **Limits.** 20 sandboxes per app. A per-org cap on OLTP branches (8 by
|
|
118
|
+
default): delete sandboxes you are done with.
|
|
119
|
+
|
|
120
|
+
## The two workspace planes
|
|
121
|
+
|
|
122
|
+
- **`semantic=branch:<b>`**:
|
|
123
|
+
- The branch must exist on the workspace's remote.
|
|
124
|
+
- The write compiles the branch head and pins the environment to it, and a
|
|
125
|
+
later push recompiles and moves the pin. Until a compile is ready, data
|
|
126
|
+
requests answer `503 semantic_branch_not_ready` and functions are refused.
|
|
127
|
+
Retry; never fall back to production's model. Repointing to another branch
|
|
128
|
+
is `503` until the new one compiles.
|
|
129
|
+
- If the deployment does not follow pushes, run the same command again to
|
|
130
|
+
re-pin to the head.
|
|
131
|
+
- `--plane semantic=default` returns to the build's own pin, and a build
|
|
132
|
+
published with `--semantic-branch` wins over the plane.
|
|
133
|
+
- `semantic=release:staging` does not exist yet. Don't promise it.
|
|
134
|
+
- **`workspace-actions=preview`**:
|
|
135
|
+
- An automation run the bundle starts executes as a held dry run: writes are
|
|
136
|
+
held, Airhouse writes go to an overlay shared by that environment's runs,
|
|
137
|
+
and `http_request` is GET-only.
|
|
138
|
+
- It answers `202 {run_id, mode: "preview"}`; poll it like any run.
|
|
139
|
+
- An agent ask the bundle starts is still held.
|
|
140
|
+
|
|
141
|
+
## When it refuses
|
|
142
|
+
|
|
143
|
+
| Answer | Means | Do |
|
|
144
|
+
| --- | --- | --- |
|
|
145
|
+
| `400 invalid_planes` | the choice cannot be stored. The message says why: unknown plane or mode, a sandbox-only mode on staging, no OLTP database, the branch cap, `fetch=allow` with no host or an unregistered one, a semantic branch that does not exist, a warehouse override naming production | fix what it names |
|
|
146
|
+
| `400 invalid_parent` | `--from` names an environment you may not fork, or one that does not exist | fork from a sandbox you created (or staging, if your token allows it) |
|
|
147
|
+
| `409 plane_not_resettable` | nothing to reset there (`oltp=schema`, or a shared plane on staging) | publish again, or reset a sandbox instead |
|
|
148
|
+
| `409 environment_busy` | a teardown or migration holds it | retry |
|
|
149
|
+
| `409 oltp_branch_unready` | `env diff` before the branch is `ready`, or cut in the other mode | wait for `ready` |
|
|
150
|
+
| `503 semantic_branch_not_ready` (`Retry-After: 5`) | the branch is still compiling | retry. It is never answered from production's model |
|
|
151
|
+
| `409 preview_runs_disabled` | the deployment has preview runs off | report it. No live run happened |
|
|
152
|
+
| a host call inside the function answers `409` (held) | the write was recorded, not performed. The function itself still runs | read `oxyc invocations held`. The `note` names the mode or host that would let it through |
|
|
153
|
+
|
|
154
|
+
## A worked example: a payment flow, end to end
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
oxyc env create acme/store dev-pay --from staging --preset full --json
|
|
158
|
+
oxyc env update acme/store dev-pay --fetch-host connect.squareupsandbox.com
|
|
159
|
+
oxyc env secret set acme/store SQUARE_TOKEN --app-env dev-pay --value-env SQUARE_SANDBOX_TOKEN
|
|
160
|
+
oxyc fn call acme/store checkout --app-env dev-pay --data '{"cart":"c1"}' --json
|
|
161
|
+
oxyc invocations list acme/store --app-env dev-pay --function checkout --limit 1 --json
|
|
162
|
+
oxyc invocations held acme/store <id> --json # fetch POST connect.squareupsandbox.com/v2/payments → 200 (sent)
|
|
163
|
+
oxyc env outbox acme/store dev-pay --json # the receipt email it would have sent
|
|
164
|
+
oxyc env diff acme/store dev-pay --json # what its migration changed, before promoting
|
|
165
|
+
oxyc env delete acme/store dev-pay --yes --wait
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
The order rows land in the sandbox's own copy of production's database, and
|
|
169
|
+
the Airhouse facts in its overlay. The receipt email is kept, not sent. The
|
|
170
|
+
Square call goes to Square's sandbox, using the sandbox's own token. Nothing
|
|
171
|
+
reaches production. To ship, a person runs `oxyc promote <app> --from dev-pay`
|
|
172
|
+
(the build becomes staging's), checks it there, then promotes to production.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Phone layout
|
|
2
|
+
|
|
3
|
+
A desktop layout squeezed into one column passes a "nothing is broken" check and
|
|
4
|
+
still fails a person holding a phone. The usual failures: a table you scroll
|
|
5
|
+
sideways to reach the column that matters, two rows of tabs cut mid-word, the
|
|
6
|
+
answer below a map or a wall of filters, a row tap that opens its detail in a side
|
|
7
|
+
panel off the screen, and explanations that only open on hover, which a touch
|
|
8
|
+
screen never does.
|
|
9
|
+
|
|
10
|
+
The fix is a **phone view**: a second presentation of the same screen, made from
|
|
11
|
+
the phone kit in `@oxy-hq/sdk/shell` (`@oxy-hq/sdk` 2.27.0 and later). It is styled by `@oxy-hq/sdk/shell.css`, which the
|
|
12
|
+
app already imports for the shell.
|
|
13
|
+
|
|
14
|
+
## When to build one
|
|
15
|
+
|
|
16
|
+
Build a phone view for any screen people open on a phone: anything with a table
|
|
17
|
+
wider than a phone, more than about five tabs or sections, a map, side panels, or
|
|
18
|
+
hover tooltips. A screen that is already a single column of text and buttons only
|
|
19
|
+
needs the floor below (text ≥ 13px, labels ≥ 11px, actions ≥ 44px, fields ≥ 16px).
|
|
20
|
+
|
|
21
|
+
## The pattern
|
|
22
|
+
|
|
23
|
+
Keep the desktop component exactly as it is. Render the phone view beside it, fed
|
|
24
|
+
by the same hooks and actions; only the presentation changes.
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { usePhoneLayout } from "@oxy-hq/sdk/shell";
|
|
28
|
+
|
|
29
|
+
export function Orders() {
|
|
30
|
+
const data = useOrders(); // the hooks the desktop already uses
|
|
31
|
+
const phone = usePhoneLayout(); // a phone upright, or on its side
|
|
32
|
+
return phone ? <OrdersPhone {...data} /> : <OrdersDesktop {...data} />;
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`usePhoneLayout()` is true below 640px wide, and on a touch screen no taller than
|
|
37
|
+
500px (a phone on its side); it re-renders when that changes and is `false` on the
|
|
38
|
+
server. Do not branch on the user agent, and do not restyle the desktop component
|
|
39
|
+
with breakpoints until it "fits": the desktop and TV layout must not move.
|
|
40
|
+
|
|
41
|
+
## What each desktop part becomes
|
|
42
|
+
|
|
43
|
+
| On desktop | On the phone |
|
|
44
|
+
| --- | --- |
|
|
45
|
+
| Tabs, a sidebar, a section switcher | `PhoneTabBar` at the bottom: up to five; past five it shows four and a More sheet |
|
|
46
|
+
| The page | `PhonePage` with `tabBar` (and `stickyAction`); pass the tab id as `scrollKey` |
|
|
47
|
+
| KPI cards | `PhoneKpiStrip`, two per row, first on the screen |
|
|
48
|
+
| A table | `PhoneCardList` of `PhoneCard`s: the row's name, a status pill, two or three key figures; a `summary` line on top. **Never a sideways-scrolling table.** |
|
|
49
|
+
| A row's action button (Post, Approve) | the card's `trailing`, or `PhoneStickyAction` for the screen's one main action |
|
|
50
|
+
| A detail panel, drawer or modal | `PhoneSheet` (full screen, Back). The phone's Back closes it through `onClose` and the page stays put; a sheet that opened by pushing its own entry (a route, `?item=`) passes `historyEntry={false}` |
|
|
51
|
+
| A list of things that need someone | `PhoneSection` of `PhoneRow`s with a `tone` dot |
|
|
52
|
+
| A row of filter selects | one `PhoneFilterChip` opening a `PhoneSheet` of filters |
|
|
53
|
+
| List / Map, Day / Week | `PhoneSegmented` |
|
|
54
|
+
| A hover tooltip or footnote | `PhoneHint`, an ⓘ that opens on a tap |
|
|
55
|
+
| A map beside or above the content | its own tab, or a sheet, filling the screen; never a fixed half above the numbers |
|
|
56
|
+
| Device-frame previews, wide editors, fullscreen/kiosk buttons, keyboard hints | left out of the phone view |
|
|
57
|
+
|
|
58
|
+
## The first screen answers the job
|
|
59
|
+
|
|
60
|
+
Decide what someone opens this screen for on a phone: "is anything on fire", "what
|
|
61
|
+
do I need to post today", "how did yesterday go". That answer goes first, visible
|
|
62
|
+
without scrolling: a status row and the KPI strip, then the "needs you" rows. Maps,
|
|
63
|
+
history and settings come after, or behind a tab.
|
|
64
|
+
|
|
65
|
+
## Rules of thumb
|
|
66
|
+
|
|
67
|
+
- One page scroller. `PhonePage` scrolls with the shell's main area; never put a
|
|
68
|
+
fixed-height box that scrolls inside it. Its dock reaches the bottom of the screen
|
|
69
|
+
through wrappers, but padding on a wrapper insets it: for an edge-to-edge tab bar,
|
|
70
|
+
render `PhonePage` without a padded `<main>` around it.
|
|
71
|
+
- Everything a person can tap is at least 44px; the kit's pieces already are.
|
|
72
|
+
- Text in a phone view is 13px or more, labels 11px or more, numbers in tabular
|
|
73
|
+
figures. Fields are 16px or more, or iOS zooms the page when one is focused: the
|
|
74
|
+
kit raises `text-sm` and smaller and fields with no size, and leaves larger ones
|
|
75
|
+
alone. It cannot raise `text-[11px]` or your own small `font-size`, so don't set
|
|
76
|
+
those on a field.
|
|
77
|
+
- Explanations a tap away (`PhoneHint`), never hover-only.
|
|
78
|
+
- Use the kit's colours (it follows your theme tokens and a `.dark` ancestor)
|
|
79
|
+
rather than hard-coded ones, so light and dark both work. Its corners follow
|
|
80
|
+
`--radius` (at `0`, square, with only status dots round) and its text `--font-sans`.
|
|
81
|
+
|
|
82
|
+
## Checking it
|
|
83
|
+
|
|
84
|
+
Look at it, don't only test it. With the browser at 390×844 and again at 844×390,
|
|
85
|
+
touch emulation on, light and dark: screenshot every tab at the top and after each
|
|
86
|
+
screenful of scrolling, open a detail sheet, and read each screenshot as someone who
|
|
87
|
+
opened the app to get something done. Then load the desktop at 1440×900 and compare
|
|
88
|
+
it with the published version: it must be unchanged.
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
You don't need an `X-API-Key` to poke at the data API by hand — a bearer
|
|
4
4
|
token works, and **`oxyc`** (`npm i -g @oxy-hq/cli`) is the client that sends
|
|
5
|
-
it for you. **
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
existing login still works.
|
|
5
|
+
it for you. **Every command that talks to a deployment's HTTP API is `oxyc`**;
|
|
6
|
+
the `oxy` binary has none. It reads the same `credentials.json` an older
|
|
7
|
+
`oxy login` wrote, so an existing login still works.
|
|
9
8
|
|
|
10
9
|
The bearer is `OXY_TOKEN` (or the variable `--token-env` names), else the
|
|
11
10
|
`oxyc login` cache for that deployment.
|
|
@@ -71,8 +70,7 @@ oxyc api projects/<projectId>/query --env local -f sql='select 1' --md
|
|
|
71
70
|
401 that reads like an expired session is usually a dev call made with a
|
|
72
71
|
prod token — check the `--env`. A `200` with a `null` body is the *other*
|
|
73
72
|
expired-token shape; `oxyc whoami` tells them apart.
|
|
74
|
-
- For a raw `curl`, `oxyc token` prints the resolved bearer
|
|
75
|
-
--print-token` went with the rest of that command):
|
|
73
|
+
- For a raw `curl`, `oxyc token` prints the resolved bearer:
|
|
76
74
|
|
|
77
75
|
```bash
|
|
78
76
|
curl -H "Authorization: Bearer $(oxyc token --env local)" \
|
|
@@ -6,6 +6,23 @@ a report its engineer can act on. What a sandbox is, and the same loop as a
|
|
|
6
6
|
person runs it, are in
|
|
7
7
|
[SKILL.md → Sandboxes](../SKILL.md#sandboxes--try-a-change-on-real-data-before-shipping-it).
|
|
8
8
|
|
|
9
|
+
## The whole loop at a glance
|
|
10
|
+
|
|
11
|
+
Everything up to shipping is yours; shipping is a person's.
|
|
12
|
+
|
|
13
|
+
| Step | Do | Proves |
|
|
14
|
+
| --- | --- | --- |
|
|
15
|
+
| 1. Build locally | `oxyc publish --build-only`, `oxyc fn dev <fn>` | it builds, and a function runs, before any approval |
|
|
16
|
+
| 2. Get a token | `oxyc tokens create --sandbox-agent --app <org>/<app>` — your engineer approves once | you act as yourself, on those apps only |
|
|
17
|
+
| 3. Make a sandbox | `oxyc env create … dev-x` (planes for what you test: [environment-branches.md](environment-branches.md)) | a copy of the app nobody else uses |
|
|
18
|
+
| 4. Publish into it | `oxyc publish --app-env dev-x` | the build the sandbox serves |
|
|
19
|
+
| 5. Exercise it | `fn call`, `fn run --as-schedule`, `checks run` | the functions, on production's reads |
|
|
20
|
+
| 6. Check the page | `checks run --browser`, `oxyc proxy --app-env dev-x` + a browser tool | what a person sees |
|
|
21
|
+
| 7. Read back | `invocations list` / `held`, `logs`, `env outbox`, `env diff` | what ran, held, would have been sent, and changed |
|
|
22
|
+
| 8. Iterate | edit, back to 4 | |
|
|
23
|
+
| 9. Hand back, clean up | the report below; `env delete --wait`, then `tokens revoke --current` | |
|
|
24
|
+
| 10. Ship | **your engineer:** `oxyc promote <app> --from dev-x`, check staging, `oxyc promote <app>` | |
|
|
25
|
+
|
|
9
26
|
## An agent's own credential: the sandbox agent token
|
|
10
27
|
|
|
11
28
|
**If you are an AI agent, you do not work on your engineer's login.** A login
|
|
@@ -30,8 +47,9 @@ oxyc tokens create --sandbox-agent --app <org>/<app> --env <deployment>
|
|
|
30
47
|
in, type the code the terminal shows, and approve. The token is printed
|
|
31
48
|
exactly as above. The rule does not change: never open or approve that page
|
|
32
49
|
yourself, with a browser tool or any other way.
|
|
33
|
-
- **Name who approves with `--approver <email>`** (or `OXY_APPROVER
|
|
34
|
-
with `--no-browser
|
|
50
|
+
- **Name who approves with `--approver <email>`** (or `OXY_APPROVER`, which
|
|
51
|
+
counts with `--no-browser`, `oxyc login --no-wait` or in a cloud session, never
|
|
52
|
+
where oxyc only detected SSH or a Codespace), with the device code: the engineer is told by push, email and Slack; they type
|
|
35
53
|
the code from your output on the page. Use the email your engineer gave you,
|
|
36
54
|
and still show them the code `oxyc` printed, since the notice does not carry
|
|
37
55
|
it. Only that person can open the request: if you were given no address, omit
|
|
@@ -78,9 +96,11 @@ token, `oxyc tokens create --agent`: see [reading-data.md](reading-data.md).
|
|
|
78
96
|
## What it reaches
|
|
79
97
|
|
|
80
98
|
One to five named apps, and only `dev-<handle>` sandboxes it created itself —
|
|
81
|
-
three at a time at most, counting ones still being deleted.
|
|
82
|
-
|
|
83
|
-
|
|
99
|
+
three at a time at most, counting ones still being deleted. In those it runs
|
|
100
|
+
the loop below and loads the app's page ([Check its page](#check-its-page)).
|
|
101
|
+
Everything else answers `404`: production and staging, another app, someone
|
|
102
|
+
else's sandbox, `/admin`, a secret's value, and the deployment's own `/api`
|
|
103
|
+
data routes. A publish to a channel (staging, production) or a
|
|
84
104
|
promote answers `403`. `oxyc` refuses those two, and `oxyc api`, `oxyc apps`
|
|
85
105
|
and `oxyc login-link`, before any request (exit `2`). **Shipping stays with a
|
|
86
106
|
person.**
|
|
@@ -103,6 +123,8 @@ oxyc env secret set <org>/<app> KEY --app-env dev-x --value-env VAR --env <deplo
|
|
|
103
123
|
# 3. Call what you changed. Success: exit 0 and "ok":true. Then run the app's checks.
|
|
104
124
|
oxyc fn call <org>/<app> <function> --app-env dev-x --data '{}' --env <deployment> --token-env OXY_TOKEN --json
|
|
105
125
|
oxyc checks run <org>/<app> --app-env dev-x --env <deployment> --token-env OXY_TOKEN --json
|
|
126
|
+
# 3b. Changed something a person sees? Check the page (see "Check its page").
|
|
127
|
+
oxyc checks run <org>/<app> --app-env dev-x --browser --expect-selector '<css>' --env <deployment> --token-env OXY_TOKEN --json
|
|
106
128
|
# 4. Read back: what ran (a row's id is `id`), what it held instead of writing, its logs.
|
|
107
129
|
oxyc invocations list <org>/<app> --app-env dev-x --env <deployment> --token-env OXY_TOKEN --json
|
|
108
130
|
oxyc invocations held <org>/<app> <invocation-id> --env <deployment> --token-env OXY_TOKEN --json
|
|
@@ -145,7 +167,11 @@ Reads hit production data. A write lands in a home of the sandbox's own, or it
|
|
|
145
167
|
is *held*: recorded in `invocations held` and not performed. A held write is
|
|
146
168
|
the expected answer outside production. Report it. Unless the task asks for
|
|
147
169
|
it, do not edit `nonProduction` in the manifest to make the write land:
|
|
148
|
-
staging and every other sandbox share that map.
|
|
170
|
+
staging and every other sandbox share that map. To make it land in this
|
|
171
|
+
sandbox alone, override the destination (`env update --destination`, below). A mutating `ctx.fetch` is held
|
|
172
|
+
the same way unless staff set the environment's `fetch` plane to `allow` for
|
|
173
|
+
registered provider sandboxes (`env update --fetch-host <host>`); a call sent that way shows in `invocations held`
|
|
174
|
+
as `(sent)`. Do not set it yourself. A sandbox's schedules are off
|
|
149
175
|
unless staff turned them on, and your token cannot turn them on: to test a
|
|
150
176
|
scheduled function, run it once as its schedule would — `oxyc fn run
|
|
151
177
|
<org>/<app> <function> --app-env dev-x --as-schedule --env <deployment>
|
|
@@ -206,14 +232,41 @@ Branch on the exit code and the JSON fields, not on the text:
|
|
|
206
232
|
day after its token ends, and your engineer can delete it sooner with the
|
|
207
233
|
`env delete` command on their own login.
|
|
208
234
|
|
|
209
|
-
##
|
|
235
|
+
## Check its page
|
|
236
|
+
|
|
237
|
+
The token loads your own sandbox's page — its HTML, assets and `/fn` calls —
|
|
238
|
+
when it rides as a header with `X-Oxy-App-Env: dev-x`. It never becomes a
|
|
239
|
+
browser cookie, so you reach the page in one of two ways, both on the token:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
# 1. Assert it mounted: one more entry in checks[], "kind": "browser".
|
|
243
|
+
oxyc checks run <org>/<app> --app-env dev-x --browser --expect-selector '<css>' \
|
|
244
|
+
--env <deployment> --token-env OXY_TOKEN --json
|
|
245
|
+
# 2. Drive it yourself: a local proxy that adds the token and the header.
|
|
246
|
+
oxyc proxy --app <org>/<app> --app-env dev-x --port 3000 \
|
|
247
|
+
--env <deployment> --token-env OXY_TOKEN # in the background; leave it running
|
|
248
|
+
# then, with a browser tool: http://127.0.0.1:3000/customer-apps/<org>/<app>/
|
|
249
|
+
```
|
|
210
250
|
|
|
211
|
-
The
|
|
212
|
-
|
|
213
|
-
`
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
251
|
+
- **The browser check** passes when the page names `dev-x` and the build `env
|
|
252
|
+
show` reports, sends its ready beacon, throws nothing, and shows the
|
|
253
|
+
`--expect-selector` element. It needs Playwright resolvable from the
|
|
254
|
+
working directory. Over MCP it is `oxy_checks_run` with `browser: true`
|
|
255
|
+
(and `expectSelector`).
|
|
256
|
+
- **The proxy** serves the deployment at `http://127.0.0.1:<port>`, adding the
|
|
257
|
+
token and `X-Oxy-App-Env` to requests under the app's path only. Open that
|
|
258
|
+
path with a browser tool (`browser_navigate`, `browser_click`,
|
|
259
|
+
`browser_take_screenshot`, `browser_evaluate` to measure) and click through
|
|
260
|
+
what you changed. In a sandbox it forwards writes: they land in the
|
|
261
|
+
sandbox's homes or are held, as a `fn call`'s are. Stop it when you are done.
|
|
262
|
+
- **What it cannot show:** the page's own calls to the deployment's `/api`
|
|
263
|
+
(an SDK `useQuery` or semantic query) answer `404` to your token, so a card
|
|
264
|
+
fed that way renders empty or errors. `/fn` calls work. Report which cards
|
|
265
|
+
you could not see with data; do not reach for another credential.
|
|
266
|
+
|
|
267
|
+
Do not log in to get a session, and do not drive the app's production URL
|
|
268
|
+
instead: it does not serve your build. How to drive and measure a page is in
|
|
269
|
+
[verifying-in-the-browser.md](verifying-in-the-browser.md).
|
|
217
270
|
|
|
218
271
|
## What to hand back
|
|
219
272
|
|
|
@@ -226,7 +279,10 @@ Whether the task worked or not:
|
|
|
226
279
|
- each function you called, with its input and whether it was `ok`; each
|
|
227
280
|
check's name and `passed`, or that the app declares no checks;
|
|
228
281
|
- every held write (`op`, `plane`, `table`, `note`);
|
|
229
|
-
-
|
|
282
|
+
- the page: the browser check's result, and what you clicked through the
|
|
283
|
+
proxy, with screenshots;
|
|
284
|
+
- what you did not verify: cards fed by the deployment's `/api` (they answer
|
|
285
|
+
`404` to your token), and anything you did not open;
|
|
230
286
|
- the cleanup: the sandbox deleted or still up, and the token revoked.
|
|
231
287
|
|
|
232
288
|
Copy what you need out of `invocations` and `logs` into the report before you
|
|
@@ -266,10 +322,11 @@ cases:
|
|
|
266
322
|
|
|
267
323
|
If your runtime speaks MCP, `oxyc mcp --env <deployment>` serves the same loop
|
|
268
324
|
as tools — `oxy_env_create` / `oxy_env_list` / `oxy_env_show` /
|
|
269
|
-
`oxy_env_delete`, `
|
|
325
|
+
`oxy_env_delete`, `oxy_env_update`, `oxy_env_reset`, `oxy_env_outbox`,
|
|
326
|
+
`oxy_publish_sandbox`, `oxy_fn_call`, `oxy_fn_run`, `oxy_checks_run`,
|
|
270
327
|
`oxy_invocations_list` / `oxy_invocations_held`, `oxy_logs`. It reads its
|
|
271
328
|
credential from `OXY_TOKEN` and nowhere else (a person on their own login
|
|
272
|
-
adds `--login`). With a sandbox agent token the list is those
|
|
329
|
+
adds `--login`). With a sandbox agent token the list is those fourteen,
|
|
273
330
|
`oxy_whoami`, `oxy_env_secret_list` / `_set` / `_delete` and
|
|
274
331
|
`oxy_token_revoke` (`confirm: true`) — and no `oxy_request`. Prefer them to
|
|
275
332
|
shelling out: each calls its verb's own request-building code, so the result
|
|
@@ -279,9 +336,51 @@ with the class at the end of its text (`[exit 5 NOT_FOUND]`, plus `server
|
|
|
279
336
|
code: <code>` when the server sent one) — branch on that the way you would
|
|
280
337
|
on the exit code. `oxy_fn_call` and `oxy_checks_run` set `isError` when the
|
|
281
338
|
function or a check failed, with the full document still in the result.
|
|
339
|
+
`oxy_checks_run` takes `browser: true` and `expectSelector` for the page
|
|
340
|
+
check. The proxy has no tool: run `oxyc proxy` in the background.
|
|
282
341
|
`oxy_env_delete` needs `confirm: true`. `oxy_publish_sandbox` takes only a
|
|
283
342
|
`dev-<handle>` and cannot reach staging or production.
|
|
284
343
|
|
|
344
|
+
## Planes, the outbox, reset and `--from`
|
|
345
|
+
|
|
346
|
+
A sandbox's planes say how isolated it is (every plane, mode and refusal is in [environment-branches.md](environment-branches.md)). Every
|
|
347
|
+
command below takes `--env <deployment> --token-env OXY_TOKEN` like the rest.
|
|
348
|
+
|
|
349
|
+
- **Read what a `capture` sandbox would have sent:** `oxyc env outbox <app> dev-x
|
|
350
|
+
[--limit N] [--json]` (over MCP `oxy_env_outbox`), newest first, 50 by default,
|
|
351
|
+
200 at most. Each message has `kind` (`email` or `notify`), `to`, `subject` or
|
|
352
|
+
`title`, `body`, `invocation_id`, `function`, `captured_at`. Your token sees
|
|
353
|
+
only what was captured since *this* sandbox began, so a name you re-create
|
|
354
|
+
starts empty. Assert on it after `fn call`.
|
|
355
|
+
- **Write to a database of its own:** `env update <app> dev-x --destination
|
|
356
|
+
<db>=<mapped>` writes `<mapped>` instead of production's `<db>` in this sandbox
|
|
357
|
+
only, over the manifest's `nonProduction.destinations` (`--clear-destination
|
|
358
|
+
<db>` removes it; both repeat, and `env create` takes `--destination`). The
|
|
359
|
+
mapped name may not be the production database or itself overridden: `400
|
|
360
|
+
invalid_planes`. Prefer this to editing the manifest, which every non-production
|
|
361
|
+
environment shares. Over MCP, pass `planes: {"warehouse": {"mode": "mapped",
|
|
362
|
+
"destinations": {"<db>": "<mapped>"}}}`.
|
|
363
|
+
- **Start clean:** `env reset <app> dev-x --plane storage,secrets,messages` empties
|
|
364
|
+
those planes; each answers `done`. `--plane oltp [--at <ts>]` re-cuts a sandbox's
|
|
365
|
+
own OLTP branch (`oltp=branch|empty`) from production: it answers `queued` with a
|
|
366
|
+
`run_id`, not `done`, so poll `env show` for `oltp_branch.status == "ready"` before
|
|
367
|
+
the next call. A sandbox on the default `oltp=schema` has nothing to reset
|
|
368
|
+
(`409 plane_not_resettable`): publish again to re-seed it. A second reset while
|
|
369
|
+
a teardown or migration holds the sandbox is `409 environment_busy`: retry. On `staging` only `messages`
|
|
370
|
+
resets (`409 plane_not_resettable` for the others: the team shares them).
|
|
371
|
+
- **Start on a build:** `env create dev-x --from <env>` points the new sandbox at
|
|
372
|
+
the parent's build and queues that build's migrations, so you can `fn call`
|
|
373
|
+
without publishing. A parent with no build gives a sandbox with none. Your token
|
|
374
|
+
may fork only from a sandbox it created, or from staging if it was minted with
|
|
375
|
+
the staging option: `--from production` (and `--from staging` without that
|
|
376
|
+
option) answers `400 invalid_parent`, as does a name that does not exist. A person can
|
|
377
|
+
fork any environment they may open.
|
|
378
|
+
|
|
379
|
+
Over MCP these are `oxy_env_outbox`, `oxy_env_update`, `oxy_env_reset` and
|
|
380
|
+
`oxy_env_create` (`from`, `at`, `preset`, `planes`). An outbox only fills when
|
|
381
|
+
the sandbox's `messages` plane is `capture`: check `oxyc env show` (`set:`)
|
|
382
|
+
before you read an empty one as "nothing was sent".
|
|
383
|
+
|
|
285
384
|
## A sandbox isolates the app, not the workspace
|
|
286
385
|
|
|
287
386
|
The semantic model, automations and Airway pipelines a sandbox reads are
|
|
@@ -304,4 +403,8 @@ when what it waited for ended `failed` or `cancelled`, `7` past its deadline.
|
|
|
304
403
|
Over MCP the same verbs are `oxy_preview_create` / `_list` / `_show` /
|
|
305
404
|
`_delete` (`confirm: true`) / `_checks` / `_run` / `_runs_list` / `_run_show`.
|
|
306
405
|
To make a sandbox read the branch's semantic model, publish to it with
|
|
307
|
-
`--semantic-branch <branch
|
|
406
|
+
`--semantic-branch <branch>`, or pin the environment itself with
|
|
407
|
+
`oxyc env update <app> dev-<handle> --plane semantic=branch:<branch>` (it
|
|
408
|
+
recompiles on a push; `503 semantic_branch_not_ready` until the first compile
|
|
409
|
+
lands — retry). To run an automation your bundle starts as a dry run, set
|
|
410
|
+
`--plane workspace-actions=preview`. `release:staging` is not available.
|
|
@@ -5,14 +5,23 @@ a card rendering a red error banner, a grid with ragged rows, a button wired to
|
|
|
5
5
|
nothing, or a component misreading its function's response shape. **The build is
|
|
6
6
|
not the check — driving the published app is.**
|
|
7
7
|
|
|
8
|
-
## An agent on a sandbox agent token
|
|
8
|
+
## An agent on a sandbox agent token: through `oxyc proxy`
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
host (the `url` from `env create`)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
The token signs no browser in, so a browser tool cannot open the sandbox's
|
|
11
|
+
own host (the `url` from `env create`). Put the proxy in between instead. It
|
|
12
|
+
holds the token, adds `X-Oxy-App-Env`, and serves your sandbox's page on
|
|
13
|
+
localhost:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
oxyc proxy --app <org>/<app> --app-env dev-x --port 3000 --env <deployment> --token-env OXY_TOKEN # background
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Then drive `http://127.0.0.1:3000/customer-apps/<org>/<app>/` as below. For a
|
|
20
|
+
plain "did it mount" assertion, `oxyc checks run … --browser` needs no proxy.
|
|
21
|
+
Cards fed by the deployment's `/api` answer `404` to the token, so they render
|
|
22
|
+
without data; say which ones in your report
|
|
23
|
+
([Check its page](sandbox-agent-loop.md#check-its-page)). A person on their own
|
|
24
|
+
login opens the sandbox's `url` directly.
|
|
16
25
|
|
|
17
26
|
## Drive the page
|
|
18
27
|
|
|
@@ -21,7 +30,7 @@ fits. After `oxyc publish`, for anything touching `src/**` or a function a
|
|
|
21
30
|
card calls:
|
|
22
31
|
|
|
23
32
|
```
|
|
24
|
-
browser_navigate → the published /customer-apps/<org>/<slug>/ URL
|
|
33
|
+
browser_navigate → the published /customer-apps/<org>/<slug>/ URL (the proxy's, for an agent)
|
|
25
34
|
browser_find → locate a control by its text, get its ref
|
|
26
35
|
browser_click → drive it
|
|
27
36
|
browser_evaluate → MEASURE (grid widths, computed styles, element counts)
|
|
@@ -52,7 +61,8 @@ for (const el of grid.children) {
|
|
|
52
61
|
## Two prerequisites that bite
|
|
53
62
|
|
|
54
63
|
- **The app is behind auth.** The browser must hold a session for the target
|
|
55
|
-
Oxy deployment — sign in there first
|
|
64
|
+
Oxy deployment — sign in there first — or go through `oxyc proxy`, which
|
|
65
|
+
carries the credential for it.
|
|
56
66
|
- **`pnpm dev` against cloud data returns `origin not allowed`** — the data API
|
|
57
67
|
rejects a localhost origin for a published app. Drive the published URL, or
|
|
58
68
|
run the `oxyc proxy` sidecar
|
|
@@ -315,7 +315,7 @@ all of them. Preserve the file's existing style. Explain the root cause alongsid
|
|
|
315
315
|
### 5. Validate
|
|
316
316
|
|
|
317
317
|
There's no build step. `oxy test` reloads the agent file, its context and its semantic files
|
|
318
|
-
from disk on every run, and `oxy build` (
|
|
318
|
+
from disk on every run, and `oxy build` (which does nothing any more) plays no part. Check
|
|
319
319
|
the files you edited, then re-run:
|
|
320
320
|
|
|
321
321
|
```bash
|