@odla-ai/cli 0.10.1 → 0.10.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/llms.txt DELETED
@@ -1,1270 +0,0 @@
1
- # @odla-ai/cli — LLM context
2
-
3
- > Agent-operable CLI for odla provisioning, calendar consent and sync lifecycle, System AI administration, Worker secrets, security jobs, and smoke checks.
4
-
5
- > ⚠️ **Early access — pre-1.0.** Agents work from bounded runbooks; humans
6
- > approve credentials, production changes, releases, and merges. APIs and exact
7
- > package availability can change. Review the documented guarantees and
8
- > limitations; this software is MIT-licensed and provided without warranty.
9
-
10
- Project-neutral provisioning CLI for odla apps. It creates and validates an
11
- `odla.config.mjs`, then uses that config to register an app, enable services,
12
- push odla-db schema/rules, configure per-app BYOK AI, configure Clerk auth, record
13
- deployment links, connect read-only Google Calendar mirrors, provision o11y ingest credentials, and transfer local or
14
- deployed Worker secrets without printing them. It also gives platform admins a
15
- scoped System AI control surface and gives app owners a provider-key-free
16
- hosted security command.
17
-
18
- It does not know about any specific app. App identity, environments, services,
19
- schema, rules, auth, AI provider, and links all come from config.
20
-
21
- ## Install
22
-
23
- No install needed — the package ships a single `odla-ai` binary, so npx can run
24
- it directly:
25
-
26
- ```bash
27
- npx @odla-ai/cli init --app-id my-app --name "My App"
28
- ```
29
-
30
- For a project you keep working in, install it as a dev dependency so the
31
- shorter `npx odla-ai` form works and the version is pinned by your lockfile:
32
-
33
- ```bash
34
- npm view @odla-ai/cli@0.10.1 version
35
- npm i -D --save-exact @odla-ai/cli@0.10.1
36
- ```
37
-
38
- ## Prerequisites
39
-
40
- - Node.js 20 or newer (`node --version`).
41
- - An existing odla account that has signed in at least once. For any command
42
- that may need a fresh device grant, pass `--email <account>` or set
43
- `ODLA_USER_EMAIL`. This value identifies who may review the request; it is not
44
- a password or session credential, and an agent must never ask for either.
45
- - odla apps usually deploy as Cloudflare Workers. If you have never used
46
- Cloudflare:
47
- 1. Create a free account at <https://dash.cloudflare.com/sign-up>.
48
- 2. You do not need to install anything: `npx wrangler login` opens the
49
- browser once to link your account, `npx wrangler dev` runs a Worker
50
- locally, and `npx wrangler deploy` ships it.
51
- 3. The `.dev.vars` file this CLI writes with `provision --write-dev-vars` is
52
- wrangler's local secrets file — `wrangler dev` picks it up automatically.
53
- It is chmod `0600` and gitignored; never commit it or paste its contents
54
- into `wrangler.toml`.
55
-
56
- ## Commands
57
-
58
- ```bash
59
- npx odla-ai setup
60
- npx odla-ai init --app-id my-app --name "My App"
61
- npx odla-ai doctor
62
- npx odla-ai calendar status --env dev
63
- npx odla-ai calendar calendars --env dev
64
- npx odla-ai calendar connect --env dev
65
- npx odla-ai calendar resync --env dev
66
- npx odla-ai calendar disconnect --env dev --yes
67
- npx odla-ai capabilities --json
68
- # install SDKs, write the Worker, and create wrangler.jsonc before secret push
69
- npx odla-ai provision --dry-run
70
- npx odla-ai provision --email owner@example.com --write-dev-vars --push-secrets
71
- npx odla-ai smoke --env dev
72
- npx odla-ai secrets push --env dev
73
- npx odla-ai secrets set clerk_webhook_secret --env dev --stdin
74
- npx odla-ai secrets set-clerk-key --env dev --from-env CLERK_SECRET_KEY
75
- npx @odla-ai/cli security run . --env dev --ack-redacted-source
76
- npx @odla-ai/cli security github connect --env dev # infers owner/name from git origin
77
- npx @odla-ai/cli security plan --env dev
78
- npx @odla-ai/cli security sources --env dev
79
- npx @odla-ai/cli security run --source <source-id> --ref main --env dev --plan-digest <digest-from-security-plan> --ack-redacted-source
80
- npx @odla-ai/cli security status <job-id>
81
- npx @odla-ai/cli security report <job-id>
82
- npx odla-ai admin ai show --email owner@example.com
83
- npx odla-ai admin ai models
84
- npx odla-ai admin ai set security --discovery-provider anthropic --discovery-model claude-opus-4-8 --validation-provider openai --validation-model gpt-5.5 --enabled
85
- npx odla-ai admin ai credentials
86
- npx odla-ai admin ai credential set anthropic --from-env ANTHROPIC_API_KEY
87
- npx odla-ai admin ai usage --app-id my-app --env prod --limit 50
88
- npx odla-ai admin ai audit --limit 25
89
- npx odla-ai skill install
90
- npx odla-ai version
91
- ```
92
-
93
- `init` writes:
94
-
95
- - `odla.config.mjs`
96
- - `src/odla/schema.mjs`
97
- - `src/odla/rules.mjs`
98
- - `.gitignore` entries for local credentials
99
-
100
- New configs contain only the `dev` environment. Add `prod` explicitly after
101
- the development flow is healthy; `provision` refuses to mutate `prod` or
102
- `production` without `--yes` and supports `--dry-run` for review.
103
-
104
- `provision` performs the standard safe setup flow:
105
-
106
- When using `--push-secrets`, create the Worker and its Wrangler config first.
107
- The CLI checks that config and `wrangler whoami` before it issues or rotates a
108
- shown-once credential.
109
-
110
- 1. Gets an `odla_dev_...` token by email-bound device handshake, or reuses
111
- `ODLA_DEV_TOKEN` / `.odla/dev-token.json`. A fresh handshake requires
112
- `--email <account>` or `ODLA_USER_EMAIL`; the matching existing account must
113
- sign in, review the exact code, and approve it. Opening the URL alone does
114
- not claim the request.
115
- In an interactive terminal it opens the approval page in your browser when
116
- the code is displayed. Pass `--open` to force browser launch from a
117
- non-interactive shell, or `--no-open` to suppress it. Browser launch is
118
- best-effort; the printed URL and code always remain the fallback.
119
- 2. Creates the platform app if needed.
120
- 3. Enables configured services in every configured environment. Calendar
121
- intent is normalized per env and fixed to Google read-only access.
122
- 4. Mints or reuses each env's configured service credentials: an odla-db app
123
- key for `db` and an ingest token for `o11y`.
124
- 5. Pushes the configured schema and rules.
125
- 6. Configures platform AI and stores provider keys in the tenant vault when the
126
- configured key env var is set.
127
- 7. With calendar enabled, starts a separate state-bound Google consent attempt
128
- when needed and follows it through initial sync. The human completes OAuth;
129
- codes and tokens never enter the CLI, repository, chat, or app.
130
- 8. Writes `.odla/credentials.local.json` with mode `0600`.
131
- 9. With `--write-dev-vars`, writes the local Worker values to `.dev.vars`; with
132
- `--push-secrets`, transfers the configured service secrets to the matching
133
- deployed Worker environment over Wrangler stdin.
134
-
135
- Plain reruns are idempotent. Pass `--rotate-o11y-token` only when deliberately
136
- invalidating and replacing the o11y token; combine it with `--push-secrets` so
137
- the replacement reaches the Worker in the same run. `--rotate-keys` remains the
138
- broader credential rotation. Production mutation or secret transfer requires
139
- `--yes`. Pass `--no-write-credentials` to skip writing the local credentials
140
- file; it cannot be combined with an operation that would issue a shown-once
141
- credential.
142
-
143
- Rotation and Wrangler secret replacement are not a distributed transaction.
144
- The CLI preflights Wrangler first and persists the replacement before pushing;
145
- if that final push still fails, follow the printed `secrets push --env ...`
146
- retry. Do not run the rotation flag again.
147
-
148
- ### Device-grant security and recovery
149
-
150
- The account email sent during a fresh handshake is a non-secret identity hint,
151
- not proof of identity. Unknown or never-signed-in accounts never produce a
152
- claimable Studio request, and the public start/poll shape intentionally does not
153
- reveal whether an account exists. The signed-in matching user must explicitly
154
- review the exact code before it becomes pending, and only one claimed pending
155
- or approved-but-uncollected request can be active for that user.
156
-
157
- Developer grants are tracked by id, owner, label, scopes, creation/expiry,
158
- last use, and revocation state. The plaintext token is delivered once to the
159
- polling client and is never available from the inventory. Every signed-in user
160
- can inspect and revoke their own grants under **Your agent credentials** in
161
- Studio; platform admins additionally see the global token inventory and
162
- metadata-only attempt evidence. Future requests with a revoked token fail.
163
- Deleting
164
- `.odla/dev-token.json` or `.odla/admin-token.local.json` removes the local copy
165
- but does not revoke a token already copied elsewhere, so use Studio revocation
166
- when compromise or accidental approval is possible.
167
-
168
- `smoke` verifies a provisioned environment from local credentials. It fetches
169
- the platform public config, checks the configured AI provider, fetches the live
170
- odla-db schema with the tenant key, compares expected schema entities, and runs
171
- a count aggregate against the first entity. It fails early with a clear message
172
- when provisioning has not written `.odla/credentials.local.json`.
173
-
174
- ### Read-only Google Calendar
175
-
176
- Calendar is a platform-custodied connector, not a Google credential stored by
177
- the application. Enable both `db` and `calendar`, configure calendar ids and an
178
- optional public Appointment Schedule `bookingPageUrl` per environment, then run
179
- normal provision. The first run has two human checkpoints: the odla device code
180
- establishes app-owner authority, then Google grants read-only Calendar scopes.
181
-
182
- `calendar status --json` returns the safe connection/sync projection.
183
- `calendar calendars --json` lists ids visible after consent; update checked-in
184
- config and re-provision. A resulting `needs_sync` state reuses the installed
185
- provider credential and resyncs without another OAuth attempt; an existing
186
- authorization or initial sync is awaited rather than duplicated. `calendar
187
- resync` requests an immediate sync, while
188
- `calendar disconnect --yes` stops watches and deletes this app/environment
189
- connection's encrypted platform token and cursors without purging retained
190
- mirror rows, which therefore become stale. It does not revoke the shared
191
- user-to-Google-OAuth-project grant, because that could invalidate other odla
192
- connections for the same user. A future explicitly global revoke command would
193
- need cross-connection accounting and warning. Production resync requires the
194
- CLI's explicit `--yes` checkpoint, and disconnect always requires it. None of
195
- these commands accepts a Google code, client secret, access token, or refresh
196
- token.
197
-
198
- The application uses its existing server-side `ODLA_ENDPOINT`, `ODLA_TENANT`,
199
- and `ODLA_API_KEY`; calendar adds no app Worker secret. Never expose the app key
200
- to a browser. Provider write actions are outside this read-only slice.
201
-
202
- These commands operate the current read/embed reconciliation slice. The CLI has
203
- no native slot-picker or create/reschedule/cancel command, and exposes no
204
- rolling-window/age-out, quota-backoff, retention/purge, or provider-derived
205
- mutation-id control. Public health remains aggregate rather than per calendar.
206
-
207
- The bundled build/migration skills add a passive pre-ship gate with
208
- `@odla-ai/security`: after the exact-version availability check, run
209
- `npm i -D --save-exact @odla-ai/security@0.2.2`, then
210
- `npx odla-security scan . --profile odla --out .odla/security/pre-ship --fail-on high --fail-on-candidates critical`.
211
- The passive scan remains a separate binary: it makes no model calls and does
212
- not execute target code. After explicit redacted-source approval,
213
- `odla-ai security run . --env dev --ack-redacted-source` adds hosted discovery
214
- and independent validation. The CLI obtains/reuses app-owner auth and the
215
- platform supplies bounded role grants; it never requests provider keys.
216
- The CLI schedules within those grants: recon consumes one discovery call,
217
- first-pass hunts are capped before retries, and validation handles the
218
- highest-risk candidates first. Used/skipped role calls appear in the summary
219
- and report. Budget-limited coverage is explicitly incomplete and still fails
220
- the default gate unless `--allow-incomplete` is supplied after review.
221
- All hosted-security network calls target the configured odla platform origin.
222
- The CLI transmits typed redacted security operations only and never contacts a
223
- model-provider host; odla.ai owns the prompts/schemas, route, credential,
224
- provider call, attribution, and receipt. Cached/environment tokens are bound to
225
- their canonical platform audience and are rejected before disclosure on a
226
- different origin. For a non-default platform, set the matching
227
- `ODLA_DEV_TOKEN_AUDIENCE` with `ODLA_DEV_TOKEN`.
228
- Early-access run ceilings are rolling. A platform-ceiling `429` always carries
229
- a conservative `Retry-After`. A provider-side `429` uses the sanitized
230
- `provider_rate_limited` code after the provider SDK's bounded retries and
231
- carries a bounded `Retry-After` only when the upstream supplied one. The CLI
232
- does not echo arbitrary response text or silently change the admin-selected
233
- model.
234
- Before installing the exact release, require
235
- `npm view @odla-ai/security@0.2.2 version` to succeed before installation. An
236
- exact-version `E404` means the release is unavailable, not that the security
237
- preflight passed, and does not prove the package name is absent. odla's own
238
- engineering environment uses an equivalent internal gate; customer projects
239
- should use the published `odla-security` command above.
240
-
241
- For a server-side, commit-pinned review, connect one repository through odla's
242
- GitHub App. Contents and Metadata access are read-only; optional Checks write
243
- access publishes only a best-effort summary. The CLI infers `owner/name` from a
244
- safe GitHub HTTPS or SSH `origin`; pass `--repo owner/name` when it cannot. It
245
- opens GitHub's installation/authorization page and polls that exact odla
246
- attempt. Finish each browser stage within its displayed 15-minute window:
247
-
248
- ```bash
249
- npx @odla-ai/cli security github connect --env dev
250
- npx @odla-ai/cli security plan --env dev
251
- npx @odla-ai/cli security sources --env dev
252
- npx @odla-ai/cli security run --source <source-id> --ref main --env dev --plan-digest <digest-from-security-plan> --ack-redacted-source
253
- ```
254
-
255
- The source job follows by default, renders the normalized report, and applies
256
- the same confirmed/candidate/incomplete gates; `--no-follow` only enqueues.
257
- `security status` and `security report` inspect prior jobs, while `security
258
- github disconnect --source <source-id> --env dev --yes` revokes the saved
259
- source without requiring a GitHub-side uninstall. A source id belongs to one
260
- app/environment; reconnect separately for another environment. Disconnect
261
- cancels nonterminal work, while terminal reports remain until normal expiry.
262
- The App is not subscribed to Push; an unexpectedly delivered Push event is
263
- ignored and never starts a job. Source jobs default to `cloudflare-app`;
264
- local-path jobs default to `odla`.
265
-
266
- Clients send only an opaque odla source id, ref, profile, and explicit redacted
267
- disclosure acknowledgement—never a PAT, installation id, provider key, or
268
- provider/model selection override. The CLI deliberately displays the read-only
269
- route identities in the consent preflight. odla.ai verifies access, pins the ref to a commit SHA,
270
- fetches the bounded snapshot server-side, and uses the admin-selected System AI
271
- routes. `security plan` shows both provider/model routes, exact policy
272
- revisions and bounds, prompt/redaction/report contracts, readiness, retention,
273
- and the no-execution boundary before consent. Each job requires
274
- `--plan-digest` and binds acknowledgement to that complete digest; any covered
275
- change requires a refreshed plan and acknowledgement.
276
-
277
- After validating that plan digest, the CLI fetches and prints the atomic
278
- server-authored execution intent for the exact app/environment, opaque source,
279
- ref (or default branch), profile, redacted disclosure, and plan digest. Its
280
- `executionDigest` is persisted with the job and sent back as
281
- `expectedExecutionDigest`; a changed selection fails with `intent_conflict`
282
- instead of running under generic consent. Repository display text is not digest
283
- authority.
284
- An omitted `--ref` is canonicalized to the source's current default-branch name
285
- during preview. A branch-default change before enqueue invalidates the intent
286
- instead of changing what the Workflow will acquire.
287
-
288
- GitHub read access is not disclosure consent. No raw archive, file body, or
289
- explicit source excerpt is deliberately persisted in the hosted report or
290
- Workflow checkpoints. The private report may keep bounded,
291
- best-effort credential-pattern-redacted model-derived prose and repository-relative paths for up to
292
- 90 days; treat it as sensitive because it may reveal source semantics.
293
- Provider/GitHub terms are separate.
294
-
295
- The archive envelope is 16 MiB compressed, 48 MiB decompressed, 20,000 entries,
296
- 10,000 files, 2 MiB per file, and 16 MiB aggregate file bytes. Links, special
297
- entries, unsafe redirects, duplicate paths, and escaping paths are rejected.
298
- The combined acquire/analyze step has zero automatic retries; after a terminal
299
- failure, correct the ref/access/archive shape or wait for service recovery and
300
- explicitly start a new job.
301
-
302
- Checks are optional, best-effort summaries, use fixed conclusion semantics, and
303
- are not the configurable CLI gate. Target code is not executed. Without an
304
- injected isolated executor, hosted inference cannot mechanically confirm a
305
- finding; critical candidates and incomplete coverage remain the operative
306
- gates, and a clean result is not proof of security.
307
-
308
- `admin ai show|models|set|credentials|credential set|usage|audit` manages platform-funded System
309
- AI (`o11y.triage`, `security.discovery`, `security.validation`). It uses a
310
- separate, mode-`0600` `.odla/admin-token.local.json` cache. Studio displays the
311
- exact scope, only an admin can approve it, and it expires after ~15 minutes;
312
- policy, credential, and usage capabilities are separate and cannot act as the
313
- approver on ordinary app/db/o11y routes. `admin ai models` reads the server
314
- catalog. `admin ai set security` updates discovery and independent validation
315
- together with expected revisions; a concurrent edit returns 409 and reloads
316
- instead of being overwritten. `admin ai usage` requests its own read-only
317
- capability and lists metadata-only events and status aggregates; filter by
318
- `--app-id`, `--env`, `--run-id`, and `--limit`, or emit `--json`. Prompts,
319
- repository source, model output, reports, and provider credentials are never in
320
- that response.
321
- `admin ai audit` uses its own read capability for immutable, metadata-only
322
- policy and credential change events with actor attribution; credential values
323
- never enter that trail. Credential writes accept only
324
- `--from-env <NAME>` or `--stdin` and never place the value in argv, output, or
325
- the cache. System AI and each app's BYOK AI are separate vault/funding paths.
326
- Admin bounds can only narrow hard ceilings of 64 calls per role/run and, for
327
- each call, 512 KiB input and 32,768 output tokens. A non-default platform environment token
328
- must declare the matching `ODLA_ADMIN_TOKEN_AUDIENCE`.
329
-
330
- `secrets push --env <env>` is the narrower recovery/retry command. It moves the
331
- configured env's odla-db key and/or o11y ingest token from
332
- `.odla/credentials.local.json` into the deployed Worker by piping each value
333
- over stdin to `wrangler secret put`; values never appear on argv, in output, or
334
- in an agent's transcript. It preflights `wrangler whoami` and the presence of a
335
- wrangler config file. The env `prod`/`production` targets the top-level
336
- wrangler environment (no `--env` flag is passed to Wrangler) and requires
337
- `--yes`; every other env maps to `wrangler --env <name>`. `--dry-run` prints a
338
- redacted plan without spawning anything. For the normal path, use
339
- `provision --write-dev-vars --push-secrets` so service enablement, credential
340
- issuance, local config, and deployed secret transfer stay one composition.
341
-
342
- `secrets set <name> --env <env>` stores one named secret in that env's tenant
343
- vault — the same write-only slot Studio's Secrets panel fills (for example
344
- `clerk_webhook_secret` for synced auth). The value may come only from
345
- `--from-env <NAME>` or `--stdin`, so a producer command pipes straight into the
346
- vault without the secret ever appearing on argv, in output, or in an agent's
347
- transcript; it is encrypted at rest and readable back only by that tenant's
348
- app API key, never by the CLI, Studio, or the developer token. `$`-prefixed
349
- names are platform-reserved. `secrets set-clerk-key --env <env>` stores the
350
- app's Clerk secret key in the reserved `$clerk_secret` slot so the platform can
351
- resolve the app's users (invites, member lookups); reserved secrets are never
352
- readable by app keys. It refuses an `sk_test_` key for a prod-named env and
353
- requires `--yes` to put an `sk_live_` key into a non-prod env, since live users
354
- would sync into a non-prod tenant. Both commands authenticate with the
355
- developer token (`$ODLA_DEV_TOKEN`, the cached token, or a fresh device
356
- approval), and prod-named envs require `--yes`, matching `secrets push`.
357
-
358
- ## Who does what
359
-
360
- If a change is deterministic from `odla.config.mjs`, the CLI owns it: app and
361
- service enablement, credential issuance and local persistence, `.dev.vars`,
362
- schema/rules/auth/AI configuration, and Wrangler secret transfer. The coding
363
- agent owns application semantics: installing `@odla-ai/o11y`, wrapping the
364
- Worker with `withObservability`, and choosing useful spans, metrics, errors, and
365
- LLM-usage records. The human owns the device approval, production consent, and
366
- explicit destructive rotation. Studio is where people view telemetry and
367
- perform manual recovery, configure System AI, and inspect app/run-attributed
368
- platform usage; its o11y token control is not the normal setup path.
369
- Run `npx odla-ai capabilities` for the human-readable contract or add `--json`
370
- when an agent or tool needs to branch on it without scraping prose.
371
-
372
- `setup` (and `skill install`) installs one complete offline runbook bundle at
373
- `.agents/skills/`, then adds thin native adapters for Claude Code
374
- (`.claude/skills/`), Codex, Cursor (`.cursor/rules/`), GitHub Copilot
375
- (`.github/copilot-instructions.md`), Gemini CLI (`GEMINI.md`), and portable
376
- `AGENTS.md` agents. The default is `--agent all`; select one or more with
377
- `--agent claude,codex` or repeated `--agent` flags. A global install supports
378
- the native Claude and Codex roots only.
379
-
380
- Existing `AGENTS.md`, `GEMINI.md`, and Copilot instructions are preserved. The
381
- installer appends a bounded odla-managed section, is idempotent, refuses
382
- symlink-redirection and locally changed managed content, and lets `--force`
383
- replace only odla-owned content. The local bundle includes build, migration,
384
- and observability-debug procedures plus every reference they need; agents do
385
- not need online docs or access to odla's private service source after setup.
386
-
387
- After running setup, the whole prompt can be: “Set up odla in this repo using
388
- the installed local odla runbook. Decide whether this is a new app or an
389
- existing site to migrate, then drive it end to end. Ask me only for the device
390
- approval and other human-only checkpoints.”
391
-
392
- For programmatic callers, `installSkill()` keeps `targetDir`, `written`, and
393
- `unchanged` as one unambiguous primary-root view: the latter two contain paths
394
- relative to `targetDir` only. Use the additive absolute `writtenPaths` and
395
- `unchangedPaths` fields to inspect every shared-bundle and adapter artifact.
396
-
397
- `doctor` also lints for common footguns: permission rules that are literally
398
- `"true"` (public writes always warn; a public `view` warns unless the
399
- namespace is listed in `db.publicRead`), schema entities missing from the
400
- rules map, credential files (`.dev.vars`, `.odla/*`) tracked by git, a
401
- wrangler assets directory pointed at the project root or at a directory
402
- containing `node_modules` (the `wrangler dev` "spawn EBADF" footgun),
403
- secret-shaped values in wrangler `vars`, and a package.json script literally
404
- named `deploy` (CI may auto-deploy it).
405
-
406
- ## Config
407
-
408
- ```js
409
- export default {
410
- platformUrl: process.env.ODLA_PLATFORM_URL ?? "https://odla.ai",
411
- dbEndpoint: process.env.ODLA_ENDPOINT ?? process.env.ODLA_DB_ENDPOINT ?? "https://db.odla.ai",
412
- app: { id: "my-app", name: "My App" },
413
- envs: ["dev"], // add "prod" deliberately; provisioning it requires --yes
414
- services: ["db", "ai", "o11y", "calendar"],
415
- db: {
416
- schema: "./src/odla/schema.mjs",
417
- rules: "./src/odla/rules.mjs",
418
- defaultRules: "deny",
419
- publicRead: [], // namespaces where a `view: "true"` rule is intentional
420
- },
421
- ai: {
422
- provider: process.env.ODLA_AI_PROVIDER ?? "anthropic",
423
- keyEnv: "ANTHROPIC_API_KEY",
424
- },
425
- calendar: {
426
- google: {
427
- calendars: { dev: ["primary"] },
428
- bookingPageUrl: {
429
- dev: "https://calendar.google.com/calendar/appointments/schedules/…",
430
- },
431
- match: {
432
- summaryPrefix: "Intro", // optional
433
- organizerSelf: true,
434
- requireAttendees: true,
435
- },
436
- attendeePolicy: "full", // or "hashed"
437
- },
438
- },
439
- auth: {
440
- // Publishable key (public). Created + pulled by the Clerk CLI (`npx clerk`);
441
- // See the installed odla-migrate phase 3. Inline `pk_…` or "$ENV_VAR".
442
- clerk: {
443
- dev: "$CLERK_PUBLISHABLE_KEY",
444
- prod: "$CLERK_PUBLISHABLE_KEY",
445
- },
446
- },
447
- links: {
448
- dev: "https://dev.example.com",
449
- prod: "https://example.com",
450
- },
451
- };
452
- ```
453
-
454
- `db.schema` and `db.rules` may be inline objects, JSON files, or JS modules
455
- exporting `default`, `schema` / `SCHEMA`, or `rules` / `RULES`.
456
-
457
- If schema is present and rules are omitted, `defaultRules: "deny"` generates
458
- deny-all rules for every schema entity. That is the safe default for Workers
459
- that mediate reads and writes with an app key.
460
-
461
- ## API reference (generated from dist/index.d.ts, v0.10.1)
462
-
463
- ```ts
464
- import { SecurityReport, PlatformSecurityRun } from '@odla-ai/security';
465
- import { HostedSecurityJob, GitHubConnectionStatus, GitHubSecuritySource, HostedSecurityIntentResponse, HostedSecurityPlan, HostedSecurityReport, HostedSecurityJobStatus } from '@odla-ai/security/hosted';
466
- export { GitHubConnectionAttempt, GitHubConnectionStatus, GitHubSecuritySource, HostedSecurityCounts, HostedSecurityCoverage, HostedSecurityIntent, HostedSecurityIntentResponse, HostedSecurityJob, HostedSecurityJobStatus, HostedSecurityPlan, HostedSecurityPlanRoute, HostedSecurityReport, HostedSecurityReportFinding, HostedSecurityRoute } from '@odla-ai/security/hosted';
467
-
468
- /** Injectable side-effect boundaries used to run and test the command dispatcher. */
469
- interface CliDependencies {
470
- fetch?: typeof fetch;
471
- openUrl?: (url: string) => Promise<void>;
472
- pollWait?: (milliseconds: number, signal?: AbortSignal) => Promise<void>;
473
- readGitOrigin?: (cwd: string) => Promise<string>;
474
- confirm?: (message: string) => Promise<boolean>;
475
- stdout?: Pick<typeof console, "log" | "error">;
476
- }
477
- /**
478
- * Parse CLI arguments and dispatch the matching odla command.
479
- *
480
- * The dispatcher covers project setup, platform AI administration, hosted and
481
- * local security, provisioning, smoke checks, skill installation, and secret
482
- * pushes. It rejects unknown commands, unsupported options, extra positionals,
483
- * missing values, and errors returned by the selected command.
484
- *
485
- * @param argv Argument vector without the node/script prefix.
486
- * @param dependencies Optional side-effect overrides for embedding and tests.
487
- */
488
- declare function runCli(argv?: string[], dependencies?: CliDependencies): Promise<void>;
489
-
490
- /** One exact platform scope obtainable through the admin device flow. */
491
- type ScopedPlatformScope = "platform:ai:policy:read" | "platform:ai:policy:write" | "platform:ai:credential:read" | "platform:ai:credential:write" | "platform:ai:usage:read" | "platform:ai:audit:read" | "platform:security:self";
492
- /** Inputs for obtaining one short-lived, exact-scope platform device grant. */
493
- interface ScopedPlatformTokenOptions {
494
- platform: string;
495
- scope: ScopedPlatformScope;
496
- /** Existing odla account email used only when a fresh handshake is required. */
497
- email?: string;
498
- open?: boolean;
499
- fetch?: typeof fetch;
500
- stdout?: Pick<typeof console, "log">;
501
- openApprovalUrl?: (url: string) => Promise<void>;
502
- tokenFile?: string;
503
- }
504
- /** Obtain/cache one exact platform scope without granting ambient admin. */
505
- declare function getScopedPlatformToken(options: ScopedPlatformTokenOptions): Promise<string>;
506
-
507
- /** Hosted platform purposes whose provider, model, and budgets an admin may route. */
508
- declare const SYSTEM_AI_PURPOSES: readonly ["o11y.triage", "security.discovery", "security.validation"];
509
- /** One catalog-validated, platform-funded System AI purpose. */
510
- type SystemAiPurpose = (typeof SYSTEM_AI_PURPOSES)[number];
511
-
512
- /** Inputs for one System AI policy/catalog read, policy update,
513
- * credential-status read, write-only credential transfer, or metadata-only
514
- * usage or admin-audit read. Provider values may come only from a named environment variable
515
- * or stdin. */
516
- interface AdminAiOptions {
517
- action: "show" | "models" | "set" | "credentials" | "credential-set" | "usage" | "audit";
518
- purpose?: string;
519
- provider?: string;
520
- model?: string;
521
- enabled?: boolean;
522
- maxInputBytes?: number;
523
- maxOutputTokens?: number;
524
- maxCallsPerRun?: number;
525
- platform?: string;
526
- token?: string;
527
- /** Existing odla account email used only when a fresh handshake is required. */
528
- email?: string;
529
- json?: boolean;
530
- open?: boolean;
531
- fetch?: typeof fetch;
532
- stdout?: Pick<typeof console, "log">;
533
- openApprovalUrl?: (url: string) => Promise<void>;
534
- credentialProvider?: string;
535
- fromEnv?: string;
536
- stdin?: boolean;
537
- readStdin?: () => Promise<string>;
538
- discoveryProvider?: string;
539
- discoveryModel?: string;
540
- validationProvider?: string;
541
- validationModel?: string;
542
- /** Optional metadata-only usage filters. */
543
- appId?: string;
544
- env?: string;
545
- runId?: string;
546
- limit?: number;
547
- /** Separate short-lived admin-token cache; never reuses the app developer-token file. */
548
- tokenFile?: string;
549
- }
550
- /** Read or update platform-funded AI routing and inspect attributed usage.
551
- * Authentication is a short-lived,
552
- * explicitly scoped device grant; ordinary app developer tokens never become
553
- * platform admins. Credential writes accept values only from a named env var
554
- * or stdin, transfer them once, and never place them in argv, output, or the
555
- * scoped-token cache. */
556
- declare function adminAi(options: AdminAiOptions): Promise<void>;
557
-
558
- /** Stable, machine-readable division of work between the CLI, coding agent,
559
- * human operator, and Studio. Printed by `odla-ai capabilities --json`. */
560
- declare const CAPABILITIES: {
561
- readonly cli: readonly ["start an email-bound device request without accepting a password or user session token", "register the app and enable configured services per environment", "issue, persist, and explicitly rotate configured service credentials", "write local Worker values and push deployed Worker secrets through Wrangler stdin", "store tenant-vault secrets (including the Clerk webhook secret and reserved Clerk secret key) write-only from stdin or an env var", "push db schema/rules and configure platform AI, auth, and deployment links", "apply read-only Google calendar mirror and public booking-page config, then drive state-bound consent, status, discovery, resync, and disconnect flows", "validate config offline and smoke-test a provisioned db environment", "run app-attributed hosted security discovery and independent validation without provider keys", "connect/revoke source-read-only GitHub sources and drive commit-pinned hosted security jobs without PATs or provider keys", "let admins manage system AI policy and credentials, inspect attributed usage, and read immutable admin changes through separate short-lived capability-only approvals"];
562
- readonly agent: readonly ["install and import the selected odla SDKs", "wrap the Worker with withObservability and choose useful telemetry", "make application-specific schema, rules, auth, UI, and migration decisions", "wire @odla-ai/calendar into trusted Worker code and keep the app admin key out of browsers"];
563
- readonly human: readonly ["provide the existing odla account email, then sign in and explicitly review/approve the exact device code", "review mirrored calendar/attendee disclosure and complete the server-issued Google consent flow", "consent to production changes with --yes", "request destructive credential rotation explicitly", "review application semantics, security findings, releases, and merges", "approve redacted-source disclosure before hosted security reasoning", "approve GitHub App repository access separately from redacted-snippet disclosure"];
564
- readonly studio: readonly ["view telemetry and environment state", "let signed-in users inventory/revoke their own agent grants and admins audit/global-revoke them", "review calendar connection, granted read scope, selected calendars, and sync health without exposing provider tokens", "perform manual credential recovery when the CLI's local shown-once copy is unavailable", "configure system AI purposes and view app/environment/run-attributed usage", "connect/revoke GitHub security sources and inspect ref-to-SHA jobs, routes, retention, coverage, and normalized reports"];
565
- };
566
- type Output = Pick<typeof console, "log">;
567
- /** Print the stable responsibility boundary for humans or agent tooling. */
568
- declare function printCapabilities(json?: boolean, out?: Output): void;
569
-
570
- declare const CALENDAR_STATES: readonly ["not_connected", "authorizing", "needs_sync", "initial_sync", "healthy", "degraded", "disconnected", "failed"];
571
- /** Connection lifecycle reported by the registry; mirrors the platform's calendar states. */
572
- type CalendarConnectionState = (typeof CALENDAR_STATES)[number];
573
- /** Owner-visible, secret-free calendar connection and sync health. */
574
- interface CalendarStatus {
575
- env: string;
576
- enabled: boolean;
577
- /** True when the platform has provider credentials for this connection. */
578
- connected: boolean;
579
- provider: "google" | null;
580
- status: CalendarConnectionState;
581
- access?: "read";
582
- calendars: string[];
583
- attendeePolicy?: "full" | "hashed";
584
- /** True once a booking projection may have established the DB privacy policy. */
585
- attendeePolicyLocked?: boolean;
586
- bookingPageUrl?: string | null;
587
- grantedScopes: string[];
588
- attemptId?: string;
589
- lastSuccessfulSyncAt?: number;
590
- lastFullSyncAt?: number;
591
- watchExpiresAt?: number;
592
- bookingCount?: number;
593
- error?: {
594
- code?: string;
595
- message?: string;
596
- };
597
- }
598
- /** One Google calendar the connected identity may select for mirroring. */
599
- interface AvailableGoogleCalendar {
600
- id: string;
601
- summary?: string;
602
- primary?: boolean;
603
- selected?: boolean;
604
- accessRole?: "freeBusyReader" | "reader" | "writer" | "owner";
605
- }
606
-
607
- /** Shared inputs for the calendar lifecycle commands (status, connect,
608
- * calendars, resync, disconnect): the project config path and env, plus
609
- * injectable token, output, browser, clock, and polling hooks so agents and
610
- * tests can drive the flow deterministically. */
611
- interface CalendarLifecycleOptions {
612
- /** Path to the checked-in odla project config. */ configPath: string;
613
- /** Configured environment; defaults to dev when present. */ env?: string;
614
- /** Existing developer-token override. */ token?: string;
615
- /** Existing odla account email used only for a fresh handshake. */ email?: string;
616
- open?: boolean;
617
- interactive?: boolean;
618
- yes?: boolean;
619
- json?: boolean;
620
- fetch?: typeof fetch;
621
- stdout?: Pick<typeof console, "log" | "error">;
622
- openConsentUrl?: (url: string) => Promise<void>;
623
- wait?: (milliseconds: number, signal?: AbortSignal) => Promise<void>;
624
- pollTimeoutMs?: number;
625
- now?: () => number;
626
- signal?: AbortSignal;
627
- }
628
- /** Read the owner-visible Google connection and mirror health for one env. */
629
- declare function calendarStatus(options: CalendarLifecycleOptions): Promise<CalendarStatus>;
630
- /** List calendars visible to the connected Google identity for config authoring. */
631
- declare function calendarCalendars(options: CalendarLifecycleOptions): Promise<AvailableGoogleCalendar[]>;
632
- /** Apply the public booking page setting, then complete Google consent + initial sync. */
633
- declare function calendarConnect(options: CalendarLifecycleOptions): Promise<CalendarStatus>;
634
- /** Ask the hosted connector for an immediate incremental/full recovery sync. */
635
- declare function calendarResync(options: CalendarLifecycleOptions): Promise<CalendarStatus>;
636
- /** Stop watches and delete this connection's encrypted platform token/cursors
637
- * without purging the mirror or revoking the shared Google project grant. */
638
- declare function calendarDisconnect(options: CalendarLifecycleOptions): Promise<CalendarStatus>;
639
-
640
- interface RunResult {
641
- code: number;
642
- stdout: string;
643
- stderr: string;
644
- }
645
- /** Subprocess seam: injectable in tests, `defaultRunner` in production. */
646
- type CommandRunner = (cmd: string, args: string[], opts?: {
647
- input?: string;
648
- cwd?: string;
649
- }) => Promise<RunResult>;
650
-
651
- type OdlaEnvName = string;
652
- type AppRules = Record<string, {
653
- view?: string;
654
- create?: string;
655
- update?: string;
656
- delete?: string;
657
- }>;
658
- interface ClerkAuthConfig {
659
- publishableKey?: string;
660
- audience?: string;
661
- mode?: "client" | "full";
662
- }
663
- /** Read-only event selection applied by the hosted Google calendar connector. */
664
- interface GoogleCalendarMatchConfig {
665
- /** Mirror only events whose summary begins with this value. */
666
- summaryPrefix?: string;
667
- /** Require the connected identity to organize the event. Defaults to true. */
668
- organizerSelf?: boolean;
669
- /** Require at least one attendee. Defaults to true. */
670
- requireAttendees?: boolean;
671
- }
672
- /** Google Calendar intent. OAuth credentials never belong in this config. */
673
- interface GoogleCalendarConfig {
674
- /** One through ten provider calendar ids to mirror in each odla environment. */
675
- calendars: Record<OdlaEnvName, string[]>;
676
- /** Public Google Appointment Schedule URL for static embed/link mode. */
677
- bookingPageUrl?: Record<OdlaEnvName, string | null>;
678
- match?: GoogleCalendarMatchConfig;
679
- /** Store normalized attendee addresses, or only SHA-256 match keys. */
680
- attendeePolicy?: "full" | "hashed";
681
- }
682
- /** The `calendar` block of `odla.config.mjs` — the Google read-mirror
683
- * settings; valid only alongside the db service. */
684
- interface CalendarConfig {
685
- google: GoogleCalendarConfig;
686
- }
687
- /** Canonical, environment-specific config sent to the calendar controller. */
688
- interface CalendarServiceConfig extends Record<string, unknown> {
689
- provider: "google";
690
- access: "read";
691
- /** Deduplicated provider ids; the hosted connector accepts at most ten. */
692
- calendars: string[];
693
- match: {
694
- organizerSelf: boolean;
695
- requireAttendees: boolean;
696
- summaryPrefix?: string;
697
- };
698
- attendeePolicy: "full" | "hashed";
699
- }
700
- /** Authored `odla.config.mjs` contract consumed by doctor and provision. */
701
- interface OdlaProjectConfig {
702
- platformUrl?: string;
703
- dbEndpoint?: string;
704
- app: {
705
- id: string;
706
- name: string;
707
- };
708
- envs?: OdlaEnvName[];
709
- services?: string[];
710
- db?: {
711
- /** Inline SerializedSchema, JSON file, or JS module path exporting default/schema. */
712
- schema?: unknown;
713
- /** Inline rule map, JSON file, or JS module path exporting default/rules. */
714
- rules?: AppRules | string;
715
- /** Generate deny-all rules from schema when rules are omitted. Defaults to true when schema exists. */
716
- defaultRules?: "deny" | false;
717
- /** Namespaces where a literal `view: "true"` rule is intentional (public content). */
718
- publicRead?: string[];
719
- };
720
- ai?: {
721
- provider?: string;
722
- model?: string;
723
- /** Env var containing the provider key to store in the platform vault. */
724
- keyEnv?: string;
725
- /** Vault secret name. Defaults to @odla-ai/ai's provider default. */
726
- secretName?: string;
727
- };
728
- calendar?: CalendarConfig;
729
- o11y?: {
730
- /** This service's name in the collector. Defaults to the app id. */
731
- service?: string;
732
- /** Collector base URL. Defaults to https://o11y.odla.ai. */
733
- endpoint?: string;
734
- /** Release tag stamped on emitted signals. */
735
- version?: string;
736
- };
737
- auth?: {
738
- clerk?: Record<OdlaEnvName, ClerkAuthConfig | string | null | undefined>;
739
- };
740
- links?: Record<OdlaEnvName, string | null | undefined>;
741
- local?: {
742
- tokenFile?: string;
743
- credentialsFile?: string;
744
- devVarsFile?: string;
745
- gitignore?: boolean;
746
- };
747
- }
748
- /** Normalized project config with resolved paths, endpoints, envs, and services. */
749
- interface LoadedProjectConfig extends OdlaProjectConfig {
750
- configPath: string;
751
- rootDir: string;
752
- platformUrl: string;
753
- dbEndpoint: string;
754
- envs: OdlaEnvName[];
755
- services: string[];
756
- local: {
757
- tokenFile: string;
758
- credentialsFile: string;
759
- devVarsFile: string;
760
- gitignore: boolean;
761
- };
762
- }
763
- /** Private mode-0600 local state written by provision and never committed. */
764
- interface LocalCredentials {
765
- appId: string;
766
- platformUrl: string;
767
- dbEndpoint: string;
768
- updatedAt: string;
769
- envs: Record<string, {
770
- tenantId: string;
771
- dbKey?: string;
772
- o11yToken?: string;
773
- }>;
774
- }
775
- /** Controls one dev-first provisioning run; production mutation requires `yes`. */
776
- interface ProvisionOptions {
777
- configPath: string;
778
- dryRun?: boolean;
779
- rotateKeys?: boolean;
780
- /** Rotate only the o11y ingest token; leaves db keys unchanged. */
781
- rotateO11yToken?: boolean;
782
- /** Push configured Worker secrets to every configured env after provisioning. */
783
- pushSecrets?: boolean;
784
- writeCredentials?: boolean;
785
- writeDevVars?: string | boolean;
786
- token?: string;
787
- /** Existing odla account email used only when a fresh device handshake is required. */
788
- email?: string;
789
- /** true forces browser launch, false disables it, undefined auto-opens only for interactive terminals. */
790
- open?: boolean;
791
- /** Test/embedding override for terminal interactivity. Defaults to stdin/stdout TTY detection. */
792
- interactive?: boolean;
793
- /** Test/embedding override for opening the approval URL. Defaults to the OS browser opener. */
794
- openApprovalUrl?: (url: string) => Promise<void>;
795
- /** Test/embedding override for calendar connection polling. */
796
- calendarPollWait?: (milliseconds: number, signal?: AbortSignal) => Promise<void>;
797
- /** Maximum calendar consent + initial-sync wait. Defaults to ten minutes. */
798
- calendarPollTimeoutMs?: number;
799
- /** Explicit consent for a non-dry-run plan containing `prod` or `production`. */
800
- yes?: boolean;
801
- fetch?: typeof fetch;
802
- /** Test/embedding override for Wrangler subprocesses used by `pushSecrets`. */
803
- secretRunner?: CommandRunner;
804
- stdout?: Pick<typeof console, "log" | "error">;
805
- }
806
- /** Human-reviewable, secret-free plan printed by `provision({ dryRun: true })`. */
807
- interface ProvisionPlan {
808
- appId: string;
809
- appName: string;
810
- platformUrl: string;
811
- dbEndpoint: string;
812
- envs: string[];
813
- services: string[];
814
- hasSchema: boolean;
815
- hasRules: boolean;
816
- aiProvider?: string;
817
- }
818
- /** Inputs for a read-only live environment smoke check. */
819
- interface SmokeOptions {
820
- configPath: string;
821
- env?: string;
822
- /** Developer-token override used only for owner-visible calendar health. */
823
- token?: string;
824
- /** Existing odla account email used only when a fresh device handshake is required. */
825
- email?: string;
826
- open?: boolean;
827
- interactive?: boolean;
828
- openApprovalUrl?: (url: string) => Promise<void>;
829
- fetch?: typeof fetch;
830
- stdout?: Pick<typeof console, "log" | "error">;
831
- }
832
-
833
- /** The only Google OAuth scope the platform ever requests: read-only calendar events. */
834
- declare const GOOGLE_CALENDAR_READ_SCOPE = "https://www.googleapis.com/auth/calendar.events.readonly";
835
- /** Resolve the checked-in calendar block into one controller-safe env payload. */
836
- declare function calendarServiceConfig(cfg: LoadedProjectConfig, env: string): CalendarServiceConfig;
837
- /** Public Appointment Schedule URL to apply separately from connector config. */
838
- declare function calendarBookingPageUrl(cfg: LoadedProjectConfig, env: string): string | null | undefined;
839
-
840
- interface DoctorOptions {
841
- configPath: string;
842
- stdout?: Pick<typeof console, "log" | "error">;
843
- }
844
- /**
845
- * Validate and summarize an odla project config entirely offline — no network
846
- * calls and no file writes. Loads `configPath`, builds the provision plan, and
847
- * resolves the schema and rules (synthesizing deny-all rules from the schema
848
- * when `db.rules` is omitted and `db.defaultRules` isn't `false`), then prints a
849
- * summary line for the app, envs, services, schema entity count, rules namespace
850
- * count, and AI provider.
851
- *
852
- * It then collects warnings for the mistakes provision can't fix silently: a
853
- * schema with no entities, a rules namespace with no matching entity, the `ai`
854
- * service enabled without an `ai.provider`, `auth.clerk` entries that reference
855
- * an unset env var (`$FOO`), an `ai.keyEnv` that isn't set (provider key upload
856
- * will be skipped), and — when `o11y` is enabled — any env whose local
857
- * credentials lack an ingest token. It also folds in the shared rule linter,
858
- * git-tracked secret-shaped files, and wrangler config warnings. Prints `ok`
859
- * when clean, otherwise the warning list. Purely advisory: never throws on
860
- * warnings and never mutates anything.
861
- *
862
- * @param options.configPath Path to the `odla.config.mjs` to inspect.
863
- * @param options.stdout Optional console-like sink (defaults to `console`).
864
- */
865
- declare function doctor(options: DoctorOptions): Promise<void>;
866
-
867
- interface InitOptions {
868
- rootDir?: string;
869
- configPath?: string;
870
- appId: string;
871
- name: string;
872
- envs?: string[];
873
- services?: string[];
874
- aiProvider?: string;
875
- force?: boolean;
876
- stdout?: Pick<typeof console, "log" | "error">;
877
- }
878
- /**
879
- * Scaffold a new odla project into `rootDir` (default: cwd). Writes an
880
- * `odla.config.mjs` (default name, overridable via `configPath`) plus starter
881
- * `src/odla/schema.mjs` (a single `notes` entity) and `src/odla/rules.mjs`
882
- * (deny-all), and creates the `src/odla` and `.odla` directories. Also runs
883
- * `ensureGitignore` so the local token/credentials paths are ignored.
884
- *
885
- * Fully local and synchronous — no network calls. The config file is only
886
- * written when it doesn't already exist unless `force` is set (otherwise it
887
- * throws); the schema/rules files are written only when missing (never
888
- * overwritten, even with `force`). `appId` must match `^[a-z0-9][a-z0-9-]*$` or
889
- * it throws. Defaults: `envs` → `["dev"]`, `services` → `["db","ai"]`,
890
- * `aiProvider` → `"anthropic"` (which also picks the `keyEnv`, e.g.
891
- * `ANTHROPIC_API_KEY`/`OPENAI_API_KEY`/`GOOGLE_API_KEY`).
892
- *
893
- * @param options.appId Slug for the app (lowercase alphanumerics and hyphens).
894
- * @param options.name Human-readable app name embedded in the config.
895
- * @param options.rootDir Project root (defaults to `process.cwd()`).
896
- * @param options.configPath Config filename relative to root (default `odla.config.mjs`).
897
- * @param options.envs Environment names (default `["dev"]`; production is an explicit opt-in).
898
- * @param options.services Enabled services (default `["db","ai"]`).
899
- * @param options.aiProvider AI provider slug (default `"anthropic"`).
900
- * @param options.force Overwrite an existing config file instead of throwing.
901
- * @param options.stdout Optional console-like sink (defaults to `console`).
902
- */
903
- declare function initProject(options: InitOptions): void;
904
-
905
- /**
906
- * Provision an app end-to-end from its config — the primary deploy path, and
907
- * (apart from key rotation) idempotent, so re-running is safe. Obtains a
908
- * developer token, creates the registry app when absent, enables each service
909
- * per env (AI also gets `setAi` with the configured provider/model), configures
910
- * Clerk auth and links, then per env mints or reuses credentials only for the
911
- * configured services, pushes the schema with the db key and the
912
- * rules with the developer token, and stores the provider key in the tenant
913
- * vault when `ai.keyEnv` is set and present. Finally writes the credentials file
914
- * (mode 0600, gitignored) and, when requested, `.dev.vars`.
915
- *
916
- * The developer token comes from (in order) `options.token`, `$ODLA_DEV_TOKEN`,
917
- * the cached `.odla` token, or a fresh email-bound device handshake — which
918
- * prints a user code for the same signed-in account to review and, in
919
- * interactive terminals, auto-opens the browser
920
- * (`open: true`/`false` forces/suppresses it). Network error bodies pass through
921
- * `redactSecrets` before display.
922
- *
923
- * @param options.dryRun Print the resolved plan and return before any network call/write.
924
- * @param options.rotateKeys Rotate db keys and o11y tokens.
925
- * @param options.rotateO11yToken Rotate only the o11y token.
926
- * @param options.email Existing odla account email for a fresh handshake;
927
- * this is an identity hint, never a password or session credential.
928
- * @param options.pushSecrets Preflight Wrangler, then push each env's configured
929
- * Worker secrets immediately after credential provisioning.
930
- * @param options.writeDevVars `true`/a path writes `.dev.vars`; `writeCredentials: false` skips the creds file.
931
- * @param options.yes Required for a non-dry-run plan containing `prod` or
932
- * `production`; callers must show and review `dryRun` output first.
933
- * @throws When a production plan is executed without `yes`, configuration is
934
- * invalid, authorization fails, or a provisioning operation fails.
935
- */
936
- declare function provision(options: ProvisionOptions): Promise<void>;
937
-
938
- /**
939
- * Return `value` with every secret-shaped substring replaced by a `[redacted]`
940
- * placeholder that keeps the identifying prefix (e.g. `sk_live_[redacted]`).
941
- * Matches odla db keys (`odla_sk_`/`odla_dev_`), Clerk secret keys
942
- * (`sk_live_`/`sk_test_`), OpenAI keys (`sk-`), webhook signing secrets
943
- * (`whsec_`), o11y tokens (`o11y_`), GitHub tokens (`ghp_`/`gho_`/`github_pat_`),
944
- * and AWS access-key ids (`AKIA…`). Clerk publishable keys (`pk_test_`/
945
- * `pk_live_`) are public by design and intentionally left untouched. Used to
946
- * sanitize anything the CLI echoes (notably network error bodies) before it
947
- * reaches stdout/stderr. Non-matching input is returned unchanged.
948
- */
949
- declare function redactSecrets(value: string): string;
950
-
951
- /** Moves locally stored configured service credentials to one Wrangler environment over stdin. */
952
- interface SecretsPushOptions {
953
- configPath: string;
954
- env: string;
955
- dryRun?: boolean;
956
- /** Required to push to a prod-named env; the visible consent token in agent transcripts. */
957
- yes?: boolean;
958
- runner?: CommandRunner;
959
- stdout?: Pick<typeof console, "log" | "error">;
960
- }
961
- /**
962
- * Moves the env's configured db and/or o11y credentials from the private local
963
- * credentials file into the Worker, piping values over stdin so they never
964
- * appear on argv, in output, or in the conversation transcript.
965
- */
966
- declare function secretsPush(options: SecretsPushOptions): Promise<void>;
967
-
968
- /**
969
- * Inputs for one write-only tenant-vault transfer (`secrets set` /
970
- * `secrets set-clerk-key`). Values may come only from a named environment
971
- * variable or stdin, so a producer command can be piped straight into the
972
- * vault without the secret ever being displayed or stored on disk.
973
- */
974
- interface SecretsSetOptions {
975
- configPath: string;
976
- env: string;
977
- /** Vault secret name (`secrets set` only; `$`-prefixed names are reserved). */
978
- name?: string;
979
- fromEnv?: string;
980
- stdin?: boolean;
981
- /** Explicit consent for a prod-named env (and for sk_live_ into a non-prod env). */
982
- yes?: boolean;
983
- /** Developer token override; defaults to $ODLA_DEV_TOKEN, the cached token, or a device handshake. */
984
- token?: string;
985
- /** Existing odla account email used only when a fresh handshake is required. */
986
- email?: string;
987
- open?: boolean;
988
- interactive?: boolean;
989
- openApprovalUrl?: (url: string) => Promise<void>;
990
- fetch?: typeof fetch;
991
- readStdin?: () => Promise<string>;
992
- stdout?: Pick<typeof console, "log" | "error">;
993
- }
994
- /**
995
- * Store one named secret in the env's tenant vault (the same write-only slot
996
- * Studio's Secrets panel fills), e.g. `clerk_webhook_secret` for synced auth.
997
- * The value is encrypted at rest and can be read back only by that tenant's
998
- * app API key — never by this CLI, Studio, or the developer token.
999
- */
1000
- declare function secretsSet(options: SecretsSetOptions): Promise<void>;
1001
- /**
1002
- * Store the app's Clerk secret key under the reserved `$clerk_secret` slot so
1003
- * odla-db can resolve the app's users (invites, member lookups). Reserved
1004
- * secrets are never readable by app keys; the dedicated endpoint is the only
1005
- * way to set one. Guards against instance/env mismatches: an sk_test_ key
1006
- * never belongs in a prod-named env, and an sk_live_ key entering a non-prod
1007
- * env requires `--yes` (live users would sync into a non-prod tenant).
1008
- */
1009
- declare function secretsSetClerkKey(options: SecretsSetOptions): Promise<void>;
1010
-
1011
- /** Built-in security coverage profile selected for a hosted reasoning run. */
1012
- type HostedSecurityProfile = "odla" | "cloudflare-app" | "generic";
1013
- /** Exact attribution and authorization need supplied to a lazy token callback. */
1014
- interface HostedSecurityTokenRequest {
1015
- platform: string;
1016
- appId: string;
1017
- env: string;
1018
- selfAudit: boolean;
1019
- /** Self-audit asks the caller for an explicitly scoped platform credential. */
1020
- /** Ordinary app runs use owner authority and therefore request no platform scope. */
1021
- scope: "platform:security:self" | null;
1022
- }
1023
- /** Local snapshot/orchestration controls for an app-attributed hosted security
1024
- * run. The platform supplies model routes and provider credentials. */
1025
- interface RunHostedSecurityOptions {
1026
- /** Project config; loaded for customer-app runs and ignored for self-audit. */
1027
- configPath?: string;
1028
- /** Scan odla itself under the protected odla-ai/prod identity. */
1029
- selfAudit?: boolean;
1030
- /** Repository directory to snapshot. Defaults to the config root or cwd for self-audit. */
1031
- target?: string;
1032
- /** Private artifact directory. Defaults to `<target>/.odla/security/hosted`. */
1033
- out?: string;
1034
- /** Customer environment. Must be declared in config. Self-audit always uses prod. */
1035
- env?: string;
1036
- profile?: HostedSecurityProfile;
1037
- maxHuntTasks?: number;
1038
- /** Exact acknowledgement required before any source capture or network call. */
1039
- sourceDisclosureAck?: "redacted";
1040
- /** Optional client correlation id; the platform returns the authoritative run id. */
1041
- runId?: string;
1042
- /** Platform override. Customer runs otherwise use config.platformUrl. */
1043
- platform?: string;
1044
- /** Injected app credential; for self-audit this must be explicitly scoped by the caller. */
1045
- token?: string;
1046
- /** Lazy token acquisition. Receives the exact app/env and required scope. */
1047
- getToken?: (request: HostedSecurityTokenRequest) => string | Promise<string>;
1048
- fetch?: typeof fetch;
1049
- signal?: AbortSignal;
1050
- stdout?: Pick<typeof console, "log" | "error">;
1051
- }
1052
- /** Completed local report, public platform run metadata, and private artifact path. */
1053
- interface HostedSecurityResult {
1054
- report: SecurityReport;
1055
- run: Readonly<PlatformSecurityRun>;
1056
- output: string;
1057
- }
1058
- /**
1059
- * Run the hosted, redacted-source security harness for an odla app or odla's
1060
- * protected self-audit identity. Provider/model selection and provider secrets
1061
- * remain platform-owned; this function accepts only an app/scoped bearer and
1062
- * the opaque role grants remain inside @odla-ai/security's reasoner closures.
1063
- */
1064
- declare function runHostedSecurity(options: RunHostedSecurityOptions): Promise<HostedSecurityResult>;
1065
-
1066
- /**
1067
- * The hosted-security client surface. The WIRE types live in @odla-ai/security/hosted — one
1068
- * definition shared with the dashboard and the server that produces them. Re-exported here so
1069
- * this module stays the single import path for the rest of the CLI.
1070
- *
1071
- * What remains below is what is genuinely the CLI's own: transport controls (platform origin,
1072
- * token, fetch, AbortSignal) that no other client shares.
1073
- */
1074
-
1075
- /** Common authenticated transport controls for hosted-security requests. */
1076
- interface HostedSecurityRequestOptions {
1077
- platform: string;
1078
- token: string;
1079
- fetch?: typeof fetch;
1080
- signal?: AbortSignal;
1081
- }
1082
- /** Options for browser-mediated connection of one exact GitHub repository. */
1083
- interface ConnectGitHubSecuritySourceOptions extends HostedSecurityRequestOptions {
1084
- appId: string;
1085
- env: string;
1086
- /** Exact owner/name repository requested before GitHub approval. */
1087
- repository: string;
1088
- /** false prints but does not launch the install URL. Defaults to true. */
1089
- open?: boolean;
1090
- openInstallUrl?: (url: string) => Promise<void>;
1091
- /** Poll interval. The server attempt expiry remains authoritative. */
1092
- pollIntervalMs?: number;
1093
- pollTimeoutMs?: number;
1094
- wait?: (milliseconds: number, signal?: AbortSignal) => Promise<void>;
1095
- now?: () => number;
1096
- stdout?: Pick<typeof console, "log">;
1097
- }
1098
- /** Options for listing GitHub sources or reading the plan for one app environment. */
1099
- interface ListGitHubSecuritySourcesOptions extends HostedSecurityRequestOptions {
1100
- appId: string;
1101
- env: string;
1102
- }
1103
- /** Inputs for fetching the server-authored execution preview before enqueue. */
1104
- interface GetHostedSecurityIntentOptions extends HostedSecurityRequestOptions {
1105
- appId: string;
1106
- env: string;
1107
- sourceId: string;
1108
- ref?: string;
1109
- profile?: "odla" | "cloudflare-app" | "generic";
1110
- }
1111
- /** Options for revoking odla access to one saved GitHub source. */
1112
- interface DisconnectGitHubSecuritySourceOptions extends HostedSecurityRequestOptions {
1113
- appId: string;
1114
- sourceId: string;
1115
- }
1116
- /** Options for enqueueing a commit-pinned hosted security review. */
1117
- interface StartHostedSecurityJobOptions extends HostedSecurityRequestOptions {
1118
- appId: string;
1119
- env: string;
1120
- sourceId: string;
1121
- ref?: string;
1122
- profile?: "odla" | "cloudflare-app" | "generic";
1123
- clientRequestId?: string;
1124
- /** Versions shown in the disclosure preflight. The server rejects stale consent. */
1125
- expectedPolicyVersions: {
1126
- discovery: number;
1127
- validation: number;
1128
- };
1129
- /** Digest copied from the plan the app owner explicitly reviewed. */
1130
- expectedPlanDigest: `sha256:${string}`;
1131
- /** Digest copied from the exact server-authored source/ref/profile preview. */
1132
- expectedExecutionDigest: `sha256:${string}`;
1133
- /** Explicit disclosure acknowledgement; GitHub read access alone is not consent. */
1134
- sourceDisclosureAck?: "redacted";
1135
- }
1136
- /** Options for reading one hosted security job or its report. */
1137
- interface GetHostedSecurityJobOptions extends HostedSecurityRequestOptions {
1138
- appId: string;
1139
- jobId: string;
1140
- }
1141
- /** Options for listing hosted security jobs in one app environment. */
1142
- interface ListHostedSecurityJobsOptions extends HostedSecurityRequestOptions {
1143
- appId: string;
1144
- env: string;
1145
- }
1146
- /** Polling controls for following one hosted job to a terminal state. */
1147
- interface FollowHostedSecurityJobOptions extends GetHostedSecurityJobOptions {
1148
- pollIntervalMs?: number;
1149
- pollTimeoutMs?: number;
1150
- wait?: (milliseconds: number, signal?: AbortSignal) => Promise<void>;
1151
- now?: () => number;
1152
- onUpdate?: (job: Readonly<HostedSecurityJob>) => void;
1153
- }
1154
-
1155
- /** Begin GitHub App installation, launch its server-issued GitHub URL, and
1156
- * poll the exact attempt until the callback has connected a source. */
1157
- declare function connectGitHubSecuritySource(options: ConnectGitHubSecuritySourceOptions): Promise<GitHubConnectionStatus>;
1158
- /** List repository sources the current app owner connected for one environment. */
1159
- declare function listGitHubSecuritySources(options: ListGitHubSecuritySourcesOptions): Promise<GitHubSecuritySource[]>;
1160
- /** Revoke odla's use of one saved source without requiring a GitHub-side App
1161
- * uninstall. The server marks the source deleted and rejects new jobs. */
1162
- declare function disconnectGitHubSecuritySource(options: DisconnectGitHubSecuritySourceOptions): Promise<void>;
1163
- /** Parse an HTTPS, ssh://, or git@github.com origin without retaining embedded
1164
- * credentials. Only github.com owner/name remotes are accepted. */
1165
- declare function repositoryFromGitRemote(remoteInput: string): string;
1166
- /** Read the current repository's origin without invoking a shell. */
1167
- declare function inferGitHubRepository(cwd?: string, readOrigin?: (cwd: string) => Promise<string>): Promise<string>;
1168
-
1169
- /** Fetch the atomic processing-plan and source/ref/profile execution preview. */
1170
- declare function getHostedSecurityIntent(options: GetHostedSecurityIntentOptions): Promise<HostedSecurityIntentResponse>;
1171
-
1172
- /** Read the admin-selected routes, budgets, readiness, disclosure boundary,
1173
- * and digest that must be acknowledged when a hosted review is enqueued. */
1174
- declare function getHostedSecurityPlan(options: ListGitHubSecuritySourcesOptions): Promise<HostedSecurityPlan>;
1175
- /** Enqueue a commit-pinned server-side review. The server resolves sourceId to
1176
- * its saved GitHub App installation; clients cannot choose an installation or
1177
- * pass a PAT. */
1178
- declare function startHostedSecurityJob(options: StartHostedSecurityJobOptions): Promise<HostedSecurityJob>;
1179
- /** Read one bounded hosted job status without an archive or explicit source excerpt. */
1180
- declare function getHostedSecurityJob(options: GetHostedSecurityJobOptions): Promise<HostedSecurityJob>;
1181
- /** List bounded, newest-first job metadata for an app environment. */
1182
- declare function listHostedSecurityJobs(options: ListHostedSecurityJobsOptions): Promise<HostedSecurityJob[]>;
1183
- /** Poll one exact job until it reaches a terminal state. */
1184
- declare function followHostedSecurityJob(options: FollowHostedSecurityJobOptions): Promise<HostedSecurityJob>;
1185
- /** Fetch the bounded normalized report projection for a completed hosted job. */
1186
- declare function getHostedSecurityReport(options: GetHostedSecurityJobOptions): Promise<HostedSecurityReport>;
1187
- /** Return whether a hosted job status can no longer transition. */
1188
- declare function isTerminalHostedSecurityStatus(status: HostedSecurityJobStatus): boolean;
1189
-
1190
- /** Agent harnesses with a first-class local adapter. */
1191
- declare const AGENT_HARNESSES: readonly ["claude", "codex", "cursor", "copilot", "gemini", "agents"];
1192
- /** A supported coding-agent harness. `agents` is the portable `AGENTS.md` adapter. */
1193
- type AgentHarness = (typeof AGENT_HARNESSES)[number];
1194
- /** A harness name accepted by setup; `all` expands to every project-local adapter. */
1195
- type AgentHarnessSelector = AgentHarness | "all";
1196
- /** Controls project-local or global installation of the bundled agent runbooks. */
1197
- interface SkillInstallOptions {
1198
- /** Project directory receiving the shared runbooks and harness adapters. Defaults to cwd. */
1199
- dir?: string;
1200
- /** Install user-wide Claude and/or Codex skills instead of project adapters. */
1201
- global?: boolean;
1202
- /** Harnesses to install. The programmatic compatibility default is `claude`; the CLI passes `all`. */
1203
- harnesses?: AgentHarnessSelector[];
1204
- /** Overwrite locally modified odla-managed files or managed instruction sections. */
1205
- force?: boolean;
1206
- /** Test/embedding override for the home directory. */
1207
- homeDir?: string;
1208
- /** Test/embedding override for `$CODEX_HOME`. */
1209
- codexHomeDir?: string;
1210
- /** Test/embedding override for the bundled skills directory. */
1211
- sourceDir?: string;
1212
- stdout?: Pick<typeof console, "log" | "error">;
1213
- }
1214
- /** One harness adapter and the directories or files through which it discovers odla. */
1215
- interface HarnessInstallResult {
1216
- harness: AgentHarness;
1217
- targets: string[];
1218
- }
1219
- /** Files written or left unchanged by an idempotent agent-runbook installation. */
1220
- interface SkillInstallResult {
1221
- /** Primary native skill directory, retained for compatibility with earlier callers. */
1222
- targetDir: string;
1223
- /** Files changed directly under `targetDir`, relative to that directory. */
1224
- written: string[];
1225
- /** Files already current directly under `targetDir`, relative to that directory. */
1226
- unchanged: string[];
1227
- /** Absolute paths of every changed shared-runbook or adapter file. */
1228
- writtenPaths: string[];
1229
- /** Absolute paths of every already-current shared-runbook or adapter file. */
1230
- unchangedPaths: string[];
1231
- harnesses: HarnessInstallResult[];
1232
- }
1233
- /**
1234
- * Installs one shared offline runbook tree plus thin native adapters for the
1235
- * selected coding-agent harnesses. Project installs use `.agents/skills/` as
1236
- * the canonical bundle; Claude Code, Cursor, Copilot, Gemini, and generic
1237
- * `AGENTS.md` adapters point to it. Global installs support the native Claude
1238
- * and Codex skill roots only.
1239
- *
1240
- * Installation is idempotent and planned before any write: an odla-managed
1241
- * file changed by the user aborts the whole operation unless `force` is set.
1242
- * Existing `AGENTS.md`, `GEMINI.md`, and Copilot instructions are preserved;
1243
- * only the bounded odla-managed section is appended or replaced.
1244
- */
1245
- declare function installSkill(options?: SkillInstallOptions): SkillInstallResult;
1246
-
1247
- /**
1248
- * Verify a live, already-provisioned environment end-to-end. Resolves the target
1249
- * env (`options.env`, else `dev`, else the first declared env) and requires it to
1250
- * be declared in the config. Reads the local credentials file and checks that it
1251
- * belongs to this app and holds a `tenantId` + `dbKey` for the env — otherwise it
1252
- * throws pointing the user at `odla-ai provision --write-dev-vars`.
1253
- *
1254
- * It then makes real network calls: fetches the registry public-config (and, when
1255
- * `ai.provider` is configured, asserts the live provider matches), fetches the
1256
- * live db schema with the db key and asserts every entity from the local schema
1257
- * is present, and runs a `count` aggregate against the first entity to confirm
1258
- * the db answers queries. Progress lines are printed and it ends with `ok`.
1259
- * Read-only — it writes nothing and throws on the first mismatch or failed
1260
- * request.
1261
- *
1262
- * @param options.configPath Path to the `odla.config.mjs`.
1263
- * @param options.env Env to check (default `dev`, else the first declared env).
1264
- * @param options.fetch Injectable `fetch` (for tests/embedding).
1265
- * @param options.stdout Optional console-like sink (defaults to `console`).
1266
- */
1267
- declare function smoke(options: SmokeOptions): Promise<void>;
1268
-
1269
- export { AGENT_HARNESSES, type AdminAiOptions, type AgentHarness, type AgentHarnessSelector, type AvailableGoogleCalendar, CAPABILITIES, type CalendarConfig, type CalendarConnectionState, type CalendarLifecycleOptions, type CalendarServiceConfig, type CalendarStatus, type CliDependencies, type ConnectGitHubSecuritySourceOptions, type DisconnectGitHubSecuritySourceOptions, type FollowHostedSecurityJobOptions, GOOGLE_CALENDAR_READ_SCOPE, type GetHostedSecurityIntentOptions, type GetHostedSecurityJobOptions, type GoogleCalendarConfig, type GoogleCalendarMatchConfig, type HarnessInstallResult, type HostedSecurityProfile, type HostedSecurityResult, type HostedSecurityTokenRequest, type ListGitHubSecuritySourcesOptions, type ListHostedSecurityJobsOptions, type LoadedProjectConfig, type LocalCredentials, type OdlaProjectConfig, type ProvisionOptions, type ProvisionPlan, type RunHostedSecurityOptions, SYSTEM_AI_PURPOSES, type ScopedPlatformTokenOptions, type SecretsPushOptions, type SecretsSetOptions, type SkillInstallOptions, type SkillInstallResult, type SmokeOptions, type StartHostedSecurityJobOptions, type SystemAiPurpose, adminAi, calendarBookingPageUrl, calendarCalendars, calendarConnect, calendarDisconnect, calendarResync, calendarServiceConfig, calendarStatus, connectGitHubSecuritySource, disconnectGitHubSecuritySource, doctor, followHostedSecurityJob, getHostedSecurityIntent, getHostedSecurityJob, getHostedSecurityPlan, getHostedSecurityReport, getScopedPlatformToken, inferGitHubRepository, initProject, installSkill, isTerminalHostedSecurityStatus, listGitHubSecuritySources, listHostedSecurityJobs, printCapabilities, provision, redactSecrets, repositoryFromGitRemote, runCli, runHostedSecurity, secretsPush, secretsSet, secretsSetClerkKey, smoke, startHostedSecurityJob };
1270
- ```