@oxy-hq/cli 0.12.1 → 0.14.0

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.
Files changed (35) hide show
  1. package/README.md +1031 -71
  2. package/dist/main.mjs +21844 -4166
  3. package/dist/main.mjs.map +1 -1
  4. package/dist/{mcp-CJWQm-yd.mjs → mcp-bxf7JBJu.mjs} +2 -2
  5. package/dist/mcp-bxf7JBJu.mjs.map +1 -0
  6. package/json-schemas/agent-test.json +116 -3
  7. package/json-schemas/agentic.json +81 -1
  8. package/json-schemas/config.json +2 -1
  9. package/json-schemas/flow-test.json +11 -2
  10. package/json-schemas/topic.json +252 -0
  11. package/json-schemas/view.json +473 -0
  12. package/package.json +9 -5
  13. package/skills/oxy-agents/SKILL.md +98 -54
  14. package/skills/oxy-agents/references/quick-reference.md +22 -20
  15. package/skills/oxy-agents/templates/agentic-template.yml +34 -90
  16. package/skills/oxy-airway-pipelines/SKILL.md +35 -2
  17. package/skills/oxy-automations/SKILL.md +42 -28
  18. package/skills/oxy-cli/SKILL.md +15 -7
  19. package/skills/oxy-custom-apps/SKILL.md +413 -7
  20. package/skills/oxy-custom-apps/references/app-calls.md +98 -0
  21. package/skills/oxy-custom-apps/references/phone-layout.md +16 -2
  22. package/skills/oxy-custom-apps/references/sandbox-agent-loop.md +8 -8
  23. package/skills/oxy-evals/SKILL.md +112 -46
  24. package/skills/oxy-evals/references/diagnosis.md +18 -21
  25. package/skills/oxy-evals/references/results-json.md +30 -18
  26. package/skills/oxy-evals/references/writing-expected.md +5 -4
  27. package/skills/oxy-experiments/SKILL.md +4 -3
  28. package/skills/oxy-semantic-modeling/SKILL.md +14 -12
  29. package/template/.claude/hooks/oxyc-cloud-session.sh +40 -8
  30. package/template/.github/workflows/publish.yaml +5 -5
  31. package/template/.github/workflows/validate.yaml +125 -199
  32. package/template/README.md +50 -21
  33. package/template/_gitignore +4 -4
  34. package/template/config.yml +2 -2
  35. package/dist/mcp-CJWQm-yd.mjs.map +0 -1
@@ -7,7 +7,7 @@ description: >-
7
7
  file that is silently not an automation, a task that validates but fails with "unknown task
8
8
  type", SQL that receives JSON instead of a table, or an automation run landing
9
9
  `completed_with_errors`. Covers the file-naming trap, task-type gotchas, running SQL and
10
- automations from the `oxy` CLI, and where the authoritative reference lives.
10
+ automations on a deployment with `oxyc run`, and where the authoritative reference lives.
11
11
  ---
12
12
 
13
13
  # Oxy automations
@@ -28,10 +28,15 @@ The canonical extension is **`.automation.yml`**.
28
28
  spreads. One production workspace has 18 automations, and every one of them
29
29
  is still `.procedure.yml`.
30
30
  - `.workflow.yml` is **no longer a recognised file kind at all**. A file with
31
- that name is silently not an automation, and `oxy run` refuses it.
32
- - `oxy migrate-automations` renames legacy files (and rewrites references to
33
- them); `--dry-run` previews. It is the only thing that reads `.workflow.yml`
34
- files for that purpose.
31
+ that name is silently not an automation, and `oxyc run` refuses it.
32
+ - `oxyc migrate-automations [path]` renames legacy files (and rewrites
33
+ references to them in every `.yml` / `.yaml` / `.sql` file); `--dry-run`
34
+ previews. It is local only, needs no login, and is the only thing that reads
35
+ `.workflow.yml` files for that purpose. It never overwrites: a file whose
36
+ `.automation.yml` target already exists, or a `.procedure.yml` beside a
37
+ `.workflow.yml` of the same name, is reported and skipped (still exit 0), so
38
+ read its warnings and resolve those by hand. The Rust
39
+ `oxy migrate-automations` is gone; use this command.
35
40
 
36
41
  **Write new files as `.automation.yml`.** Do not copy the extension from a
37
42
  neighbouring file in the workspace you are editing — that is how the legacy name
@@ -52,7 +57,7 @@ Routes follow the same split: `/automations/:id` is canonical;
52
57
 
53
58
  - **A misspelled `type:` passes validation and fails only at run time.** An
54
59
  unrecognised task type — `type: sql`, `type: execute` — is read as an
55
- "unknown" step rather than rejected, so `oxy validate` reports the file valid
60
+ "unknown" step rather than rejected, so `oxyc validate` reports the file valid
56
61
  and the run fails on that step with `unknown task type`. Check every `type:`
57
62
  against the task-types page by eye, then *run* the automation; validation
58
63
  alone proves nothing here. (A wrong *field* inside a known type, such as
@@ -73,28 +78,37 @@ Routes follow the same split: `/automations/:id` is canonical;
73
78
  as `completed_with_errors`, not as a failed run. Code and dashboards that only
74
79
  check for "failed" will report it as a success.
75
80
 
76
- ## Running locally with `oxy run`
77
-
78
- `oxy run <file>` takes a `.sql` file, an `.automation.yml`, or a
79
- `.procedure.yml` — nothing else.
80
-
81
- - **SQL files:** `oxy run report.sql --database warehouse -v start=2024-01-01
82
- -v region=west`. `--database` picks a database from `config.yml` (default:
83
- the configured default database). `-v` / `--variables` fills Jinja
84
- placeholders, and those `-v` values are the **entire** template context —
85
- nothing else (no database or schema objects) is available inside the SQL.
86
- `--dry-run` previews the rendered SQL without executing it.
87
- - **No `-v` means no rendering at all.** Run a templated `.sql` file without a
88
- single `-v` and its `{{ … }}` placeholders reach the warehouse literally, as
89
- a syntax error. Pass at least one variable whenever the file has
90
- placeholders.
91
- - **`--dry-run` and `-v` are ignored for automations.** Both apply to `.sql`
92
- files only. `oxy run x.automation.yml --dry-run` executes the automation for
93
- real — every write, every `http_request` — and uses the file's own
94
- `variables:` defaults whatever `-v` says. To check an automation without side
95
- effects, run its SQL files individually with `--dry-run`.
96
- - `--retry` and `--retry-from <step>` are accepted but currently have no effect
97
- on an automation run; a failed run is re-run from the top.
81
+ ## Running one with `oxyc run`
82
+
83
+ `oxyc run <file> --workspace <id>` (`npm i -g @oxy-hq/cli`) takes a `.sql` file,
84
+ an `.automation.yml`, or a `.procedure.yml` — nothing else. It runs **on the
85
+ deployment**, never on this machine. The Rust `oxy run` is gone; use
86
+ `oxyc run`.
87
+
88
+ - **An automation runs what is deployed, not your edit.** The server runs the
89
+ definition it has compiled for the workspace's served revision, on the worker
90
+ fleet. Push the change first, or try a branch with
91
+ `oxyc preview run <branch> procedure <ref> --workspace <id>` (its writes are
92
+ held). An automation the deployment does not have exits `5` before anything
93
+ starts.
94
+ - **`-v name=value` sets the run's variables**, overriding the file's own
95
+ `variables:` defaults. Every value arrives as a string.
96
+ - **SQL files:** `oxyc run report.sql --database warehouse -v start=2024-01-01
97
+ region=west --workspace <id>`. The file's text is sent, and runs against the
98
+ deployed database of that name with the workspace's secrets and your
99
+ identity. `--database` is required when the workspace has more than one
100
+ database (`config.yml`'s `defaults.database` is not visible to `oxyc`).
101
+ - **`-v` renders only `{{ name }}`, and only when given.** Any other Jinja
102
+ (`{% … %}`, filters, expressions) or a placeholder with no value exits `2`
103
+ and sends nothing. Run a templated file without a single `-v` and its
104
+ `{{ … }}` reach the warehouse literally, as a syntax error.
105
+ - **There is no dry run.** `--dry-run`, `--retry` and `--retry-from` are gone.
106
+ A run executes for real — every write, every `http_request`. To try an
107
+ automation without side effects, use the branch preview above.
108
+ - A result stops at 10,000 rows. `--json` prints the rows (header row first)
109
+ or the run's final snapshot. Exit `1` the run failed, was cancelled or timed
110
+ out, or `--timeout` ran out (the run carries on: re-running starts a second
111
+ one); `6` the query failed; `7` retryable, before anything started.
98
112
 
99
113
  ## Before you write one
100
114
 
@@ -76,6 +76,11 @@ never sent to the server as a literal.
76
76
  oxyc flags list # feature flags: kill switch, per-org overrides, A/B splits (staff)
77
77
  oxyc login-link --next /ide # one-time URL that signs a browser in as your token
78
78
  oxyc workspace clone <id> # clone the workspace's repository to edit locally; push to deploy
79
+ oxyc airway run <ref> --workspace <id> # run a deployed pipeline and stream it; also backfill, coverage, leases
80
+ oxyc sync [db] --workspace <id> # write .databases/ schema files into the checkout (server introspects the deployed config)
81
+ oxyc looker test <name> --workspace <id> # check a Looker integration's credentials; exit 9 when they fail
82
+ oxyc evals run <file> --workspace <id> # LLM-judged evals on the deployment; exit 9 under --min-accuracy
83
+ oxyc agentic run <agent> -q "<q>" --workspace <id> # ask a deployed agent, stream the run; also answer, events, list
79
84
  oxyc guide # this page, to paste into a context file
80
85
 
81
86
  `oxyc workspace clone <workspace-id>` is how you change a workspace: authoring
@@ -85,16 +90,19 @@ subdirectory when the workspace lives in one), and opens it in VS Code or Cursor
85
90
  only from an interactive terminal (`--open code|cursor|none`; an agent gets the
86
91
  command printed instead). Edit, commit, push: **a push to the default branch
87
92
  compiles and deploys**; to try a branch first, `oxyc preview create <branch>
88
- --workspace <id> --wait` (staff). Exit `5` means the workspace has no repository
93
+ --workspace <id> --wait` (staff). To check a pushed branch compiles without
94
+ serving it, `oxyc compile <branch> --workspace <id> --wait` (exit `9` on file
95
+ failures, `--json` for the `failures` array) — what a customer repo's CI runs. Exit `5` means the workspace has no repository
89
96
  yet (connect one in Settings), `6` a failed `git clone`, `8` a non-empty `--dir`.
90
97
 
91
98
  `oxyc validate` is the one command that works entirely offline. It checks
92
- `config.yml`, `.automation.yml`, `.agentic.yml` and
93
- `.agent.test.yml` against the schemas the Rust config types generate. It is
94
- STRUCTURAL only — `oxy validate` additionally checks an automation's
95
- `database:` names against `config.yml`, but it too is structural for
96
- `.agentic.yml` (`databases:` and `llm.ref` are not resolved), so an agent both
97
- accept can still fail at run time.
99
+ `config.yml`, `.automation.yml`, `.agentic.yml`, `.agent.test.yml`, `.view.yml`
100
+ and `.topic.yml` against the schemas the Rust types generate, then as the
101
+ runtime does once a file loads: an automation's `database:` and `integration:`
102
+ names and an agent's `databases:` and `llm.ref` against `config.yml`, an
103
+ automation's rules (non-empty `tasks:`, timeouts, export formats), and a view's
104
+ removed features and `{{variables.x}}` syntax. Exit `9` on any finding. It
105
+ replaced `oxy validate`, which now only prints the `oxyc` command.
98
106
 
99
107
  To look at a deployed environment in a browser, navigate your browser tool to
100
108
  `$(oxyc login-link --env dev --next /ide)`. It is a one-time link that signs
@@ -213,6 +213,23 @@ indexes or foreign keys — publish refuses a migration carrying one. So:
213
213
  statements that must land together go in one `ctx.oltp.tx`. The store is
214
214
  provisioned per org by an operator; until then calls fail naming that step.
215
215
 
216
+ **Where `ctx.env` comes from.** The app's own secrets (its Secrets panel,
217
+ `oxyc env secret set`), plus any shared secret an admin has shared with the
218
+ app in Settings → Organization → Secrets — read under the secret's own name, so one
219
+ `SLACK_BOT_TOKEN` can serve every app that needs it and rotates once. The app's
220
+ own value of a key wins over a shared one. Nothing else of the workspace is
221
+ visible, and the manifest cannot ask for more: declaring a key in `env` only
222
+ makes it show as missing until someone sets or shares it. `ctx.secrets.set`
223
+ refuses a key the run read from a shared workspace secret; rotate it in Settings.
224
+
225
+ **A function that calls Oxygen's own org routes** (kiosks at
226
+ `/api/orgs/{org}/frontline/devices`, members, apps) holds an organization's
227
+ service-account token in a secret, never a person's: `oxyc tokens create
228
+ --org-service-account <org>/<account> --role admin --set-app-secret <org>/<app>
229
+ --key <KEY> --env <env>`. An owner or admin of the org approves it in the
230
+ browser, and the token goes into the app's secret without being printed. Legacy
231
+ `oxy_…` API keys authenticate nothing.
232
+
216
233
  **Not a store:** `ctx.secrets` holds credentials you rotate. A cursor, a
217
234
  counter or a JSON blob is a record. `oxyc validate` warns about it, about
218
235
  keys in Airhouse migrations, and lists every customer-warehouse write exception.
@@ -230,6 +247,91 @@ async function completeChecklist(ctx, runId: string, storeGuid: string) {
230
247
  }
231
248
  ```
232
249
 
250
+ **Records in Airhouse, with their history (`oltpChanges`).** Declare tables
251
+ at the app level, beside `migrations`:
252
+
253
+ ```jsonc
254
+ "oltpChanges": { "tables": { "leases": {}, "landlords": { "exclude": ["contact_email"] } } }
255
+ ```
256
+
257
+ Every committed change to a declared table lands in the workspace's Airhouse
258
+ as `oltp_<writer>.<table>__changes` (`_op`, `_changed_at`, `_actor`, `_seq`
259
+ beside the row's columns), with the current state in the view
260
+ `oltp_<writer>.<table>`; `jsonb` and arrays land as JSON text. Your app code
261
+ does not change: capture runs in the same transaction as the write.
262
+
263
+ - A declared table needs a primary key. `exclude` columns never leave
264
+ Postgres, and nothing in Airhouse is purged, so personal data and free
265
+ text belong in `exclude`.
266
+ - Only ever add columns to a captured table. A rename or retype holds that
267
+ table until staff resync it.
268
+ - Only production ships, and only once staff turn `oltp_changes` on for the
269
+ org. The cadence is near real time unless staff pace the org
270
+ (`oxyc oltp changes interval`); staff also have `sync` (a pass now),
271
+ `status` (lag and holds) and `resync`.
272
+
273
+ ## Asking another app
274
+
275
+ To use another app's data or rule, call its function (`ctx.apps.call`) instead of copying its tables; both manifests declare it. See [references/app-calls.md](references/app-calls.md).
276
+
277
+ ## React when a table changes
278
+
279
+ A function can run when an Airhouse table changes, with no one calling it:
280
+
281
+ ```jsonc
282
+ "functions": {
283
+ "on-lines-changed": {
284
+ "route": false,
285
+ "on": { "table": "pokehouse:bookkeeping.platform_report_lines" }
286
+ }
287
+ }
288
+ ```
289
+
290
+ The table is `<database>:<schema>.<table>`; leave the database out for your own
291
+ `app_<writer>` schema. It fires once per **snapshot** that inserted into or
292
+ deleted from the table, so a pipeline that writes the table fires it, as does
293
+ `ctx.airhouse`. Wrap the handler in `onEvent` from `@oxy-hq/sdk/events` and
294
+ narrow with `isTableChange(event)`:
295
+
296
+ ```ts
297
+ export default onEvent(async (event, ctx) => {
298
+ if (!isTableChange(event)) return;
299
+ const { snapshotId, inserted, deleted, updated, rows } = event.data; // row-image counts (`updated` counts pre/post-image pairs), rows when small
300
+ const page = rows ?? (await ctx.tables.changes(event)); // { inserted, deleted, hasMore }
301
+ // Re-derive what you keep from the table.
302
+ });
303
+ ```
304
+
305
+ - **Inserts and deletes both fire**, and an update arrives as a pre-image/post-image
306
+ pair. A table that replaces rows (delete a period, insert it again) fires for
307
+ both statements, so a handler that adds up `inserted` double counts. Treat an
308
+ event as "this table changed, re-derive", not as a delta, unless the table is
309
+ append-only. Delivery is at least once.
310
+ - `rows` is there up to 1,000 rows and 64 KB; past that, call
311
+ `ctx.tables.changes(event, { limit, offset })` (10,000 a side a call, `hasMore`).
312
+ It answers only for the event that started this run.
313
+ - **Do not write the table you watch.** The host refuses a write to it from that
314
+ function with an `EventLoop` error. A loop through two tables is caught by a
315
+ circuit breaker that pauses a subscription over 150 deliveries in 5 minutes and
316
+ pages; `oxyc events resync <org>/<app> <function>` resumes it (and skips what
317
+ changed meanwhile).
318
+ - **Compaction is not a change.** Airhouse's compactor writes snapshots; only
319
+ inserts and deletes fire.
320
+ - **The table's columns are a contract.** Removing, renaming or retyping one marks
321
+ the watch broken (it pages and stops delivering until it holds again), and an
322
+ `airhouseMigrations` file that does so to a table a production function watches
323
+ is refused at publish. Adding a column is fine. `resync` clears broken and
324
+ `behind_horizon` (the next snapshot expired); `--backfill` runs the handler once
325
+ with `event.data.backfill === true`.
326
+ - **Environments.** A watch reads the environment's own `app_<writer>__<env>`
327
+ copy when it has the table, else production's, read-only. A non-production watch
328
+ records nothing until the environment's events switch is on (then it starts
329
+ from now). Airhouse caches snapshot reads up to a minute, so an event can lag
330
+ a write by that much.
331
+ `oxyc events ls` shows each watch's cursor, lag and state.
332
+ - Unit test with `createTestEvents().tableChange({ table, snapshotId, inserted,
333
+ deleted })` and `createTestContext(manifest, { tableChanges: { [event.id]: { inserted: [...] } } })`.
334
+
233
335
  ## Telling people something
234
336
 
235
337
  Name **people**; the platform reaches them. Don't build a recipient table, a
@@ -292,12 +394,154 @@ by, so declare it with the first `ctx.notify`, not later:
292
394
  undeclared function, a misspelt field and any `oxy.` kind — every problem at
293
395
  once; a catalogue kind no function sends is a warning.
294
396
 
397
+ **Acting in Oxygen itself: `ctx.oxygen`, never a stored key.** A function that
398
+ needs the platform (the org's kiosk devices, a source upload) asks for it under
399
+ `"oxygen"` in its manifest entry and calls `ctx.oxygen.*`:
400
+
401
+ ```jsonc
402
+ "tablets": { "route": true, "oxygen": { "frontline": { "devices": "manage" } } },
403
+ "webhook": { "oxygen": { "sourceUploads": { "pipelines": ["ubereats_transactions"] } } }
404
+ ```
405
+
406
+ ```ts
407
+ const link = await ctx.oxygen.frontline.devices.create({ name, locationId, returnTo });
408
+ await ctx.oxygen.sourceUploads.report({ file, fileName, pipeline: "ubereats_transactions", workflowId });
409
+ ```
410
+
411
+ - **The manifest asks; an org owner or admin approves**, under Apps in the organization's
412
+ API tokens settings, or on the page `/<org>/oxygen-access/<appId>`. Until then the call
413
+ throws `AppAccessNotApproved`: show the user that, never a stack trace. Publishing never
414
+ waits for the approval.
415
+ - **An upload names its pipeline**, as the manifest lists it; each pipeline is approved on
416
+ its own, and Oxygen finds where it lives. Never name a workspace.
417
+ - **No key, no network.** The host does it in-process as the app's own service account,
418
+ with no token for the app to hold. Never put an Oxygen API token in an app secret to
419
+ call Oxygen's API from a function: that is what this replaced.
420
+ - **Production only** (`EnvironmentRefused` elsewhere). Any trigger may call it; the
421
+ audit row records the app, the function, the trigger and the person when there is one.
422
+ - **Oxygen checks the app, not the person.** Anyone the function serves can reach the
423
+ action through it, so the function decides who may ask (as Store Ops' `tablets` does
424
+ with `reachOf`).
425
+
295
426
  **The dock.** Wrap the app in `<OxyShell>` (every `create-oxy-app` template
296
- does) so it shows Oxygen's rail: HQ, Chat and the viewer's other apps, each
297
- opening in this tab and warmed on hover. Pass `hideTopBar` if the app draws its
298
- own header. Link to another app with a plain `<a href>`, never `target="_blank"`;
427
+ does) so it shows Oxygen's rail and top bar: Home and the viewer's apps, each drawn as its
428
+ grey mark, opening in this tab and warmed on hover. From SDK 2.34.0 the shell has no
429
+ Chat entry and no Ask (no top-bar button, no ⌘K), as Oxygen's own chrome has none. Pass `hideTopBar` if the app draws its
430
+ own header. From SDK 2.33.0 the viewer opens and closes the rail from its
431
+ toggle, and the app's column narrows by 176px while it is open: lay screens out
432
+ to shrink (`min-width: 0` on flex children), never for a fixed width. Link to another app with a plain `<a href>`, never `target="_blank"`;
299
433
  moving between apps is meant to feel like one product.
300
434
 
435
+ **Look.** The design standard for every custom app is the oxygen reference app
436
+ (`oxy-hq/reference-app`; on SDK 2.31.0 from `reference-app@35c2bf5`, oxy-hq/reference-app#20).
437
+ Import `@oxy-hq/sdk/theme.css` (SDK ≥ 2.29) above your own CSS to get it: its palette, square
438
+ corners, frame and control lines, the system face and 44px touch targets, which the shell and
439
+ the phone kit read too. Its selectors weigh nothing, so your own token declarations still win;
440
+ adopting it means deleting them, and deleting any `--oxy-shell-*` or `!important` rules aimed
441
+ at the shell or kit. Without the import, nothing about the app's look changes.
442
+
443
+ **The desk UI comes from the SDK, never copied** (SDK ≥ 2.30). The reference app's
444
+ components, patterns and recipes ship in `@oxy-hq/sdk/ui` with `@oxy-hq/sdk/ui.css`, imported
445
+ after `theme.css` and `shell.css`: `import { SidePanel, LoadError, DefaultTabs, ui } from
446
+ "@oxy-hq/sdk/ui"`. A Tailwind app imports `@oxy-hq/sdk/tailwind.css` before
447
+ `@import "tailwindcss"` so its utilities read the theme. Money, percent, dates and CSV come from
448
+ `@oxy-hq/sdk/format`, which runs in a Function too. Run `checkThemeCss()` from
449
+ `@oxy-hq/sdk/testing` in the app's tests: it fails on CSS that restates an SDK token or keys its
450
+ own mode. Run `expect(formatSdkUiCopies(checkSdkUiCopies("src"))).toBe("")` there too (SDK ≥
451
+ 2.31): it reports each component in `src/` named like an SDK piece, with the import to use. A
452
+ variant kept on purpose says why in the file that defines it, `// oxy-ui-local: <Name> -- <why>`
453
+ (the reason is required). A local that only holds a component (`const Glyph = app.glyph`)
454
+ defines nothing and passes from SDK 2.31.1; 2.31.0 reported it, so rename it there. A piece the SDK lacks is built in the app from the `ui` recipes; a
455
+ defect in a shared piece is fixed in the SDK, so every app gets it. Every `create-oxy-app`
456
+ template starts this way, and its `pnpm test` runs both checks.
457
+
458
+ SDK 2.31 adds, each opt-in: `Panel`'s fold (`foldable`, `open`, `defaultOpen`), `header`,
459
+ optional `title`, landmark (`as`, `label`, `headingLevel`) and `density="compact"`;
460
+ `Sparkline`'s one series (`sparkPoints`), `width` / `height`, `fluid`, `area`, `color`, `x` and
461
+ `readout`; `StatusDot wordHidden`; `DefaultTabs`' `disabled`, `stretch` and per-tab `hint`;
462
+ `HoverHint focusable`; `Stat`'s `tipMark` and `valueAt`; `MetricCell`'s `quiet` step;
463
+ `TryAgainButton`; `useModalFocus(ref, open, { auto: true })`; `topBarFrom` `sm` / `lg` / `2xl`;
464
+ `useOxyMode()` in `@oxy-hq/sdk/shell`. An app that kept its own panel fold, KPI tile, dot-only
465
+ status or Try again for want of one imports the SDK's and deletes its copy.
466
+
467
+ SDK 2.32 adds, each opt-in: `PanelTable`'s `phoneCard` (each row a card on a phone: title,
468
+ status and chevron on one line, subtitle, every figure, a column's `phoneWide` across) and
469
+ `rowProps` (per-row `data-*`, `title`, `tabIndex` and handlers); `Subnav`'s `showHeadings` and
470
+ `header`; `StatGrid phonePairs` and `PhoneKpiStrip oddLastAcross` (two to a row, an odd last
471
+ tile across); `AlertStrip`'s per-alert `hint` and `check` tone (the theme's `--status-check`);
472
+ `Sparkline`'s `domain`, `band`, `reference` (with `from`), `baseline` and `endTone`. An app that
473
+ kept a local PanelTable, Subnav, StatGrid, KPI row, AlertStrip or Sparkline for one of these
474
+ imports the SDK's and deletes its copy.
475
+
476
+ SDK 2.35 adds: `ParentTabs` (top bar included) puts the `data-*` props it is given on its root
477
+ `<nav>` (`data-placement` stays its own), and `Panel` puts them on its root. An app that kept a
478
+ local ParentTabs or Panel for a `data-testid` or a guided tour's `data-tour` marker imports the
479
+ SDK's and deletes its copy.
480
+
481
+ What the pieces settle, so an app doesn't override them (decisions 81–93):
482
+
483
+ - `SidePanel` keeps its overlay shadow; drop any `shadow-none` (81).
484
+ - One type scale, the reference's: take the closest step; no hand-set sizes, and no redefining
485
+ the size names (82).
486
+ - Hint bubbles open leftward, where `HoverHint` puts them (84).
487
+ - A failed read's message is 13px at either `LoadError` size; drop overrides of it (85).
488
+ - A `Stat` with a `tip` shows its ⓘ on the desk, a Tab stop; `tipMark={false}` only where the
489
+ tip restates what the screen already says (89). On a phone inside `OxyShell` it is the kit's
490
+ tap ⓘ after the label with no `TapHintFrame` from the app (SDK ≥ 2.31.1).
491
+ - A KPI tile is `Stat boxed` in a `StatGrid`; a critical one keeps its error edge (90).
492
+ - Waiting is counted: `LoadingBar` with the read count, `Loading` for a single read; never a
493
+ sweeping bar (91).
494
+ - `TrendChart` labels hold 12px on screen at any width (92).
495
+ - Two warning tiers are `MetricCell`'s `quiet` (the warning tint at 400) and `warning` (600),
496
+ `error` above them (93).
497
+
498
+ Six rules of the design system go beyond the reference:
499
+
500
+ - **Overlays blur the page behind them** (`--scrim`, and `--scrim-blur`, 8px; 0px under
501
+ reduced transparency). A modal `<dialog>` gets the blur from the theme on its own; give
502
+ its `::backdrop` the colour `var(--scrim)`. On any other scrim (a fixed div, a Radix or
503
+ shadcn overlay) put the class `oxy-scrim` and remove its own `bg-*`.
504
+ - **A button the app puts in the top bar (`topBarExtra`) is the reference's secondary**
505
+ (`btnCompactSecondary`: the `--btn-surface` fill, `--border-subtle` edge, full ink,
506
+ `--btn-surface-hover` on hover).
507
+ - **An attention strip on a page whose ground is not the card** insets its label 13px (a
508
+ tile's 1px frame + `--padding-sm-x`, 12px), so it lines up with the tiles below rather than
509
+ sitting on the box's edge; the SDK's `AlertStrip` draws it so.
510
+ - **A side panel on the desk runs the whole window's height and is modal.** A right-hand
511
+ detail panel (the reference's `SidePanel`) runs from the top of the window to the bottom
512
+ (`fixed`, `top: 0`, `bottom: 0`), over the top bar rather than under it, as Store Ops'
513
+ sheet does. While it is open the whole window behind it, the top bar included, is
514
+ scrimmed and blurred as above and inert; focus moves into it, Esc or a click on the scrim
515
+ closes it, and focus returns to the row that opened it. On a phone it stays a
516
+ full-screen view with no scrim.
517
+ - **On a phone, the bottom tab bar's current tab is the accent blue**, icon and label, in
518
+ light and dark, with the label at 600 weight. `PhoneTabBar` draws it in the theme's
519
+ `--link`, which holds 4.5:1 for the label and 3:1 for the icon on the bar. It is the only
520
+ selection drawn in blue: desk navigation, tabs and segmented controls keep the design
521
+ system's monochrome selection. Leave that colour to the kit (give a tab icon no colour
522
+ of its own, so it follows the slot), and a bottom bar the app draws itself follows the
523
+ same rule.
524
+ - **Square corners are for controls and surfaces, not for marks drawn on a map or a
525
+ chart.** A map marker or cell, a pin, and a chart's points and lines keep their own
526
+ shape. Everything else follows the design system, status dots (round, always with a
527
+ word) and count badges (square) included. Where the words beside a dot already say the
528
+ state, `StatusDot wordHidden` shows the dot alone and keeps the word for assistive tech.
529
+
530
+ **Light and dark.** With the theme, the app has both modes and shows the signed-in
531
+ person's, the one Oxygen home shows: `OxyShell` applies it and puts one Light / Dark /
532
+ System switch at the bottom of the rail (the nav sheet's bottom on a phone), and a change
533
+ there changes Oxygen too. Write every colour from the theme's tokens so both modes work;
534
+ never set `.dark` on `<html>` yourself. A screen that must not move, such as a store's
535
+ shared tablet, pins one: `<OxyShell modePin="light">`, `useOxyModePin("light")`, or
536
+ `<html data-oxy-mode-pin="light">` for the whole app. A crew sign-in has no mode and no
537
+ switch. On a staging or sandbox host the switch works for that preview only: it is kept on
538
+ that origin and never changes the person's real mode. The shell keeps
539
+ `<meta name="theme-color">` on the mode's ground, so the app needs no hook of its own for it.
540
+ `--chart-1…5` are the reference's sequential blue ramp; series that are categories take
541
+ `--chart-cat-*`. On a touch screen the shell's own chrome answers taps within 44px; a store's
542
+ enrolled tablet turns that off with `useOxyTouchTargets(false)` (or
543
+ `<OxyShell touchTargets={false}>`).
544
+
301
545
  **Motion.** `shell.css` loads `@oxy-hq/sdk/motion.css` (SDK ≥ 2.24), Oxygen's
302
546
  own motion language, so shadcn dialogs, menus and tooltips already open and
303
547
  close like Oxygen's. Time your own transitions with its tokens
@@ -307,6 +551,7 @@ are 120–240 ms), and give every slide or zoom a `motion-reduce:` counterpart.
307
551
 
308
552
  ```tsx
309
553
  import { OxyShell } from "@oxy-hq/sdk/shell";
554
+ import "@oxy-hq/sdk/theme.css";
310
555
  import "@oxy-hq/sdk/shell.css";
311
556
 
312
557
  <OxyAppProvider>
@@ -571,6 +816,25 @@ oxyc fn dev report --read-through --env dev # reads hit that deployment; wri
571
816
  `createTestContext` from `@oxy-hq/sdk/testing` in vitest, as the functions
572
817
  template does.
573
818
 
819
+ ### Say what a function takes and returns
820
+
821
+ Declare an `Input` (and `Output`) type in the function's entry file, or cast the
822
+ body (`JSON.parse(req.body) as Body`) and annotate the handler's return type.
823
+ `oxyc publish` turns them into the function's `inputSchema` / `outputSchema` in
824
+ the uploaded manifest. The staff console shows them as a field table, and Run now
825
+ checks its input against `inputSchema` before sending it. JSDoc becomes the field
826
+ description, and `@minimum`, `@maxLength`, `@pattern`, `@format` and
827
+ `@asType integer` become constraints.
828
+
829
+ - **Plain data types only:** interfaces, aliases, literals, unions, arrays,
830
+ `Record`, `Date`, relative type imports. A generic, intersection or tuple is a
831
+ publish **warning** naming the line, and that function ships without a schema.
832
+ - **A schema written in `oxy-app.json` wins**, and `null` turns generation off.
833
+ It must use the JSON Schema 2020-12 subset `OxyAppJsonSchema` lists (no
834
+ `$ref`) and stay under 16 KiB, or the publish is refused (`oxyc validate` says
835
+ so first).
836
+ - **Advisory:** a call that does not fit still runs.
837
+
574
838
  ## Publishing
575
839
 
576
840
  **These commands are a person's, or an agent's on a token that person
@@ -607,6 +871,32 @@ first and refuse on a blocker: `staging_never_served`, `required_secrets_unset`
607
871
  `oxyc publish --promote` still works and warns that it is deprecated: it shows
608
872
  nobody the plan.
609
873
 
874
+ **An org can hold Promote on a build's checks** (Oxy turns this on per org).
875
+ The plan then lists each check of the build, the required ones marked, and
876
+ three more blockers can refuse a promote to production:
877
+
878
+ - `checks_not_passed`: a required check failed, could not run, or never ran.
879
+ By default the required ones are: its `"check": true` functions pass, it
880
+ loads on desk and phone, it follows the design system, and every screen
881
+ opens. Fix what the check found and publish again; `oxyc checks show <app>
882
+ --build <id>` prints each finding.
883
+ - `checks_running`: a required check has no verdict yet. `oxyc checks show
884
+ <app> --build <id> --wait`, then promote again.
885
+ - `changes_not_seen`: the app is set to need a person to look at the screens
886
+ that changed. They mark them seen on the app's Builds page.
887
+
888
+ To promote past a failed check, an owner or admin of the app's org passes
889
+ `--override-checks "<why>"` (10 characters or more; it is audited, and it
890
+ clears those three blockers only). A publish token, a CI token and a service
891
+ account cannot. **As an agent, never pass `--override-checks` on your own**:
892
+ report the failed check and let a person decide. A rollback is never held by
893
+ the checks.
894
+
895
+ After a promote that is checked, `oxyc promote` waits up to 5 minutes while
896
+ the platform opens every screen on production, and **exits `9` if that found
897
+ something the move broke** (production has moved; `oxyc rollback <app>
898
+ --app-env production` moves it back). `--no-wait` skips the wait.
899
+
610
900
  - **Identity**, for each half, is `--app` / `--org`, then `OXY_APP` /
611
901
  `OXY_ORG`, then the manifest's `slug` + `orgSlug`, then an
612
902
  `apps/<org>/<app>/` working directory. `--org` takes a slug or a UUID; pass
@@ -650,7 +940,12 @@ nobody the plan.
650
940
  retargets a publish.
651
941
  - **Credential:** `OXY_TOKEN`, then `oxyc login`'s cache — or, in a GitHub
652
942
  Actions job with `id-token: write`, the job's OIDC identity.
653
- `oxyc init-ci` writes a workflow that publishes with no stored secret.
943
+ `oxyc init-ci` writes a workflow that publishes with no stored secret, and
944
+ has an org owner or admin approve its service account and trust policy once.
945
+ In a Claude Code remote session it asks and exits (`--no-wait` is the default
946
+ there): relay the link it prints — add `--approver <their email>` so they are
947
+ pushed it — end the turn, and run `oxyc init-ci --force` once they have
948
+ approved. A run that finds both in place asks nobody.
654
949
  - Promote / roll back / unpublish from the oxy admin app-detail console;
655
950
  every publish is audited (who shipped each build, when).
656
951
  - **What is live now:** `oxyc apps show <org>/<app>` prints the live build, the
@@ -707,9 +1002,53 @@ approves once, from any device.
707
1002
  every later command. To iterate in a sandbox, mint
708
1003
  `--sandbox-agent --app <org>/<app>` into the same file instead. A token
709
1004
  lasts 8 hours by default (`--hours`, up to 168). On exit `4`, mint again.
1005
+
1006
+ **Or a network secret, which nobody approves per session.** The
1007
+ environment's owner adds one in its settings: Allowed websites
1008
+ `app.oxygen-hq.com` (and `*.oxy.tech`), header `Authorization`, prefix
1009
+ `Bearer`, and a personal access token or service account token as the
1010
+ value. They also set `OXY_TOKEN=from-proxy` in its environment variables.
1011
+ The proxy then adds the token to each request after it leaves the VM, so it
1012
+ is never in a file, a variable or your context, and `oxyc` sends none.
1013
+ The hook checks it with `oxyc whoami` and says if it is not attached. On
1014
+ exit `4`, report it: the secret's hosts, header or token are wrong, and
1015
+ only the owner can fix them. Do not mint a token over it unasked. A sandbox
1016
+ still needs an `--sandbox-agent` token minted into the file, which replaces
1017
+ the sentinel.
710
1018
  4. **Ship** with the commands above, each with `--token-env OXY_TOKEN`.
711
1019
  `promote` and `rollback` need `--yes`, because there is no terminal to ask.
712
1020
 
1021
+ **Sharing the setup with a team.** The repo already shares what it can: the
1022
+ hook and its settings entry reach every teammate who clones it. The cloud
1023
+ environment cannot be shared that way. Claude Code has no file that defines
1024
+ an environment's network access, variables or secrets. The way to share one
1025
+ is an **organization environment**, which only an Owner of the team's Claude
1026
+ organization creates (claude.ai admin settings → Cloud environments). Members
1027
+ can read its variables but not its secrets, and one secret value serves
1028
+ everyone who uses it. So set it up in two layers:
1029
+
1030
+ - **One shared environment, with no token in it.** The Owner creates an
1031
+ organization environment with **Limited** network access. It allows
1032
+ `app.oxygen-hq.com`, `*.oxy.tech` and the default package managers, and its
1033
+ setup script runs `npm install -g @oxy-hq/cli`. Teammates pick it, and each
1034
+ session gets its credential from step 3: the person approves their own
1035
+ token, which ends in hours and is recorded as theirs.
1036
+ - **A personal environment, for someone who wants no approval per session.**
1037
+ They create their own environment with the same network access. They add
1038
+ their own network secret, with their own personal access token (`oxy_pat_…`,
1039
+ from Settings → Organization → API tokens → Personal access tokens), and
1040
+ `OXY_TOKEN=from-proxy`. What
1041
+ they do is still recorded as them.
1042
+
1043
+ Two things to avoid:
1044
+
1045
+ - **A network secret on the shared environment.** Every member's session then
1046
+ acts as whoever owns that token, staff access included, and Oxy's audit log
1047
+ shows all of it as that one person.
1048
+ - **A browser session token as a secret's value.** If `oxyc whoami` says the
1049
+ credential is "a browser session", the secret holds a session token, which
1050
+ expires much sooner than a personal access token. Replace it.
1051
+
713
1052
  **A token approved by device code never carries staff or partner access.**
714
1053
  `--standing --no-browser` is a usage error (exit `2`). The token from step 3
715
1054
  reaches only what the approver's org memberships do. That is enough when they
@@ -729,9 +1068,10 @@ belong to the app's org. Staff shipping a customer's app have three ways:
729
1068
  plan, the deprecated promoting publish.
730
1069
  - **Mint the standing token where a browser opens.** On the engineer's own
731
1070
  machine, run `oxyc tokens create --agent --standing --hours <n>`. They put
732
- the value in the cloud environment's variables as `OXY_TOKEN`. Anyone who
733
- uses that environment can read it, so keep `--hours` short and revoke the
734
- token when the task is done.
1071
+ the value in the cloud environment as a network secret, with
1072
+ `OXY_TOKEN=from-proxy` (step 3). As a plain `OXY_TOKEN` variable instead,
1073
+ anyone who uses that environment can read it. Either way, keep `--hours`
1074
+ short and revoke the token when the task is done.
735
1075
  - **Leave the ship step to the engineer.** Hand back the sandbox's build and
736
1076
  the `oxyc promote --from dev-<handle>` command.
737
1077
 
@@ -803,6 +1143,71 @@ Staff only (needs `develop_apps` + `manage_apps`) — or a sandbox agent token
803
1143
  such staff approved; a publish token is refused on every sandbox operation,
804
1144
  so CI cannot use one.
805
1145
 
1146
+ **What the checks found on staging's build.** Every build that reaches
1147
+ staging is checked: it builds and validates, its `"check": true` functions
1148
+ pass, it loads on desk and phone, it follows the design system. The platform
1149
+ starts a GitHub Actions run that does it and keeps the results on the build.
1150
+ The page is opened as a reader: a `/fn` call or any other write it makes while
1151
+ it mounts does not go through and shows as a warning, so the first screen has
1152
+ to mount without one. **It is also given nothing from another host**: a font,
1153
+ a script, an image or a tag another origin serves is not loaded while the
1154
+ build is checked, and no WebSocket is opened (each a warning). So ship fonts
1155
+ and libraries in the app's own bundle, and load anything optional from
1156
+ elsewhere so that its absence throws nothing: an app that cannot mount
1157
+ without a script from a CDN fails the check, and the failure names what was
1158
+ not sent. `oxyc checks show <app> --env dev` prints the
1159
+ results: who ran them, then one line per check with the findings (`file:line
1160
+ message`) under any that failed; `--build <id>` reads another build, `--wait`
1161
+ polls until none is running, and `--json` gives the server's body. Exit `9`
1162
+ means they failed, `0` passed, running or none run. If it says the runner did
1163
+ not answer, run the checks again from the app's Builds page. It needs a
1164
+ person's login: a sandbox agent token is refused, here and on `oxyc checks run
1165
+ --build`, which is the command that run executes. Whether a promote waits on
1166
+ them is the org's setting (above): `oxyc promote <app> --dry-run` says which
1167
+ checks are required.
1168
+
1169
+ **Every screen, and what changed.** Where the org holds Promote on the checks,
1170
+ two more run on staging's build. **Every screen opens**: each screen at desk
1171
+ (1440x900) and phone (390x844) width has to render and throw nothing. **What
1172
+ changed**: each screen is pictured on staging and on production and the two
1173
+ are compared, so a person sees which screens differ before promoting (it
1174
+ informs, and never fails a build). The same reader opens them, so every
1175
+ screen has to render **without a write, without a `/fn` call, and without
1176
+ anything from another host**. `useQuery`
1177
+ and `useSemanticQuery` go through; a screen that loads its data through an Oxy
1178
+ Function sees that call refused (a warning, not a failure), so it must still
1179
+ render and throw nothing: an empty or error state is enough.
1180
+
1181
+ - **Which screens.** Declare them in `oxy-app.json`: `"checks": { "screens":
1182
+ ["", "stores", "reorder/plans"] }`, app-relative paths, `""` for the root.
1183
+ With none declared, the checker reads the ready root page's `<a href>`
1184
+ links to other screens of the app (at most 30) and **clicks nothing**: a
1185
+ screen reached only by a button or a tab is not found, so declare its path.
1186
+ **An app that picks its screen by a query declares the query**:
1187
+ `"?module=waste"`, `"stores?tab=open"`. Without it the checker opens such
1188
+ an app's root and nothing else, because a link's query is dropped when the
1189
+ screens are read off the root page. A screen that exists only as a hash
1190
+ route (`#/plans`) cannot be declared and is not opened: the checker drops
1191
+ the hash.
1192
+ - **Keep `checks.screens` in step with the router, in the same change.** When
1193
+ you add, rename or remove a route, open the app's route table and rewrite
1194
+ the list from it: every static path, the root first, then the order of the
1195
+ navigation, at most 30. Do it without being asked: a screen missing from
1196
+ the list is a screen no check opens, and nothing fails to tell anyone.
1197
+ Leave out a route that only redirects, and say in your summary which
1198
+ routes you left out and why.
1199
+ - **A screen that needs data to exist** (a detail page for one record) should
1200
+ be declared with a path that exists on staging and on production, or left
1201
+ out. Never invent a record id: ask the person for one that exists in both,
1202
+ or leave the route out and say so.
1203
+ - **What the list misses is reported.** The checker reads the links of every
1204
+ screen it opens, and `oxyc checks show <app>` prints, under **Every screen
1205
+ opens**, `! 3 linked screens not opened: /plans, …` (the app's Builds page
1206
+ says the same; `--json` has them as `detail.screens_unlisted`). Declare the
1207
+ ones that matter and publish again.
1208
+ - **`oxyc checks show <app> --environment production`** prints the check that
1209
+ ran on production after a promote.
1210
+
806
1211
  **An agent runs this loop on its own sandbox agent token**, never a person's
807
1212
  login, with `--token-env OXY_TOKEN` on every command — up to the page:
808
1213
  `checks run --browser` and `oxyc proxy --app <org>/<app> --app-env dev-x` let
@@ -826,5 +1231,6 @@ the sandbox with `--semantic-branch <branch>`, or set the planes above — see
826
1231
  | [references/verifying-in-the-browser.md](references/verifying-in-the-browser.md) | You changed something a person sees (`src/**`, or a function a card calls) and need to prove it on the published page. |
827
1232
  | [references/reading-data.md](references/reading-data.md) | You need a deployment's live data while building: an agent's own `--agent` token, `oxyc api` / `routes` / `schema`, and `oxyc proxy` for `pnpm dev` against cloud data. |
828
1233
  | [references/performance-and-usage.md](references/performance-and-usage.md) | You write an Oxy Function, a bulk action, caching or idempotency keys — or need to know what Oxy does for load speed and usage tracking, and the opt-outs. |
1234
+ | [references/app-calls.md](references/app-calls.md) | One app needs another app's data or rule: `callable`, `calls`, `ctx.apps.call` / `send`, `ctx.caller`, `AppCallError`, the same-environment rule, limits and testing. |
829
1235
  | [references/phone-layout.md](references/phone-layout.md) | A screen people open on a phone: when to build a phone view, the `usePhoneLayout()` pattern, what each desktop part becomes, and how to check it. |
830
1236
  | [references/minimal-starter.md](references/minimal-starter.md) | You are writing an app by hand instead of scaffolding it, or need the smallest correct layout. |