@odla-ai/cli 0.9.0 → 0.10.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.
package/dist/index.js CHANGED
@@ -2,8 +2,16 @@
2
2
  import {
3
3
  AGENT_HARNESSES,
4
4
  CAPABILITIES,
5
+ GOOGLE_CALENDAR_READ_SCOPE,
5
6
  SYSTEM_AI_PURPOSES,
6
7
  adminAi,
8
+ calendarBookingPageUrl,
9
+ calendarCalendars,
10
+ calendarConnect,
11
+ calendarDisconnect,
12
+ calendarResync,
13
+ calendarServiceConfig,
14
+ calendarStatus,
7
15
  connectGitHubSecuritySource,
8
16
  disconnectGitHubSecuritySource,
9
17
  doctor,
@@ -30,12 +38,20 @@ import {
30
38
  secretsSetClerkKey,
31
39
  smoke,
32
40
  startHostedSecurityJob
33
- } from "./chunk-MJYQ7YDH.js";
41
+ } from "./chunk-WDKBW4BE.js";
34
42
  export {
35
43
  AGENT_HARNESSES,
36
44
  CAPABILITIES,
45
+ GOOGLE_CALENDAR_READ_SCOPE,
37
46
  SYSTEM_AI_PURPOSES,
38
47
  adminAi,
48
+ calendarBookingPageUrl,
49
+ calendarCalendars,
50
+ calendarConnect,
51
+ calendarDisconnect,
52
+ calendarResync,
53
+ calendarServiceConfig,
54
+ calendarStatus,
39
55
  connectGitHubSecuritySource,
40
56
  disconnectGitHubSecuritySource,
41
57
  doctor,
package/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # @odla-ai/cli — LLM context
2
2
 
3
- > Agent-operable CLI for odla provisioning, System AI administration, commit-pinned GitHub security jobs, Worker secrets, and smoke checks.
3
+ > Agent-operable CLI for odla provisioning, calendar consent and sync lifecycle, System AI administration, Worker secrets, security jobs, and smoke checks.
4
4
 
5
5
  > ⚠️ **Early access — pre-1.0.** Agents work from bounded runbooks; humans
6
6
  > approve credentials, production changes, releases, and merges. APIs and exact
@@ -10,7 +10,7 @@
10
10
  Project-neutral provisioning CLI for odla apps. It creates and validates an
11
11
  `odla.config.mjs`, then uses that config to register an app, enable services,
12
12
  push odla-db schema/rules, configure per-app BYOK AI, configure Clerk auth, record
13
- deployment links, provision o11y ingest credentials, and transfer local or
13
+ deployment links, connect read-only Google Calendar mirrors, provision o11y ingest credentials, and transfer local or
14
14
  deployed Worker secrets without printing them. It also gives platform admins a
15
15
  scoped System AI control surface and gives app owners a provider-key-free
16
16
  hosted security command.
@@ -31,8 +31,8 @@ For a project you keep working in, install it as a dev dependency so the
31
31
  shorter `npx odla-ai` form works and the version is pinned by your lockfile:
32
32
 
33
33
  ```bash
34
- npm view @odla-ai/cli@0.9.0 version
35
- npm i -D --save-exact @odla-ai/cli@0.9.0
34
+ npm view @odla-ai/cli@0.10.0 version
35
+ npm i -D --save-exact @odla-ai/cli@0.10.0
36
36
  ```
37
37
 
38
38
  ## Prerequisites
@@ -55,6 +55,11 @@ npm i -D --save-exact @odla-ai/cli@0.9.0
55
55
  npx odla-ai setup
56
56
  npx odla-ai init --app-id my-app --name "My App"
57
57
  npx odla-ai doctor
58
+ npx odla-ai calendar status --env dev
59
+ npx odla-ai calendar calendars --env dev
60
+ npx odla-ai calendar connect --env dev
61
+ npx odla-ai calendar resync --env dev
62
+ npx odla-ai calendar disconnect --env dev --yes
58
63
  npx odla-ai capabilities --json
59
64
  # install SDKs, write the Worker, and create wrangler.jsonc before secret push
60
65
  npx odla-ai provision --dry-run
@@ -105,14 +110,18 @@ shown-once credential.
105
110
  non-interactive shell, or `--no-open` to suppress it. Browser launch is
106
111
  best-effort; the printed URL and code always remain the fallback.
107
112
  2. Creates the platform app if needed.
108
- 3. Enables configured services in every configured environment.
113
+ 3. Enables configured services in every configured environment. Calendar
114
+ intent is normalized per env and fixed to Google read-only access.
109
115
  4. Mints or reuses each env's configured service credentials: an odla-db app
110
116
  key for `db` and an ingest token for `o11y`.
111
117
  5. Pushes the configured schema and rules.
112
118
  6. Configures platform AI and stores provider keys in the tenant vault when the
113
119
  configured key env var is set.
114
- 7. Writes `.odla/credentials.local.json` with mode `0600`.
115
- 8. With `--write-dev-vars`, writes the local Worker values to `.dev.vars`; with
120
+ 7. With calendar enabled, starts a separate state-bound Google consent attempt
121
+ when needed and follows it through initial sync. The human completes OAuth;
122
+ codes and tokens never enter the CLI, repository, chat, or app.
123
+ 8. Writes `.odla/credentials.local.json` with mode `0600`.
124
+ 9. With `--write-dev-vars`, writes the local Worker values to `.dev.vars`; with
116
125
  `--push-secrets`, transfers the configured service secrets to the matching
117
126
  deployed Worker environment over Wrangler stdin.
118
127
 
@@ -135,6 +144,39 @@ odla-db schema with the tenant key, compares expected schema entities, and runs
135
144
  a count aggregate against the first entity. It fails early with a clear message
136
145
  when provisioning has not written `.odla/credentials.local.json`.
137
146
 
147
+ ### Read-only Google Calendar
148
+
149
+ Calendar is a platform-custodied connector, not a Google credential stored by
150
+ the application. Enable both `db` and `calendar`, configure calendar ids and an
151
+ optional public Appointment Schedule `bookingPageUrl` per environment, then run
152
+ normal provision. The first run has two human checkpoints: the odla device code
153
+ establishes app-owner authority, then Google grants read-only Calendar scopes.
154
+
155
+ `calendar status --json` returns the safe connection/sync projection.
156
+ `calendar calendars --json` lists ids visible after consent; update checked-in
157
+ config and re-provision. A resulting `needs_sync` state reuses the installed
158
+ provider credential and resyncs without another OAuth attempt; an existing
159
+ authorization or initial sync is awaited rather than duplicated. `calendar
160
+ resync` requests an immediate sync, while
161
+ `calendar disconnect --yes` stops watches and deletes this app/environment
162
+ connection's encrypted platform token and cursors without purging retained
163
+ mirror rows, which therefore become stale. It does not revoke the shared
164
+ user-to-Google-OAuth-project grant, because that could invalidate other odla
165
+ connections for the same user. A future explicitly global revoke command would
166
+ need cross-connection accounting and warning. Production resync requires the
167
+ CLI's explicit `--yes` checkpoint, and disconnect always requires it. None of
168
+ these commands accepts a Google code, client secret, access token, or refresh
169
+ token.
170
+
171
+ The application uses its existing server-side `ODLA_ENDPOINT`, `ODLA_TENANT`,
172
+ and `ODLA_API_KEY`; calendar adds no app Worker secret. Never expose the app key
173
+ to a browser. Provider write actions are outside this read-only slice.
174
+
175
+ These commands operate the current read/embed reconciliation slice. The CLI has
176
+ no native slot-picker or create/reschedule/cancel command, and exposes no
177
+ rolling-window/age-out, quota-backoff, retention/purge, or provider-derived
178
+ mutation-id control. Public health remains aggregate rather than per calendar.
179
+
138
180
  The bundled build/migration skills add a passive pre-ship gate with
139
181
  `@odla-ai/security`: after the exact-version availability check, run
140
182
  `npm i -D --save-exact @odla-ai/security@0.2.2`, then
@@ -342,7 +384,7 @@ export default {
342
384
  dbEndpoint: process.env.ODLA_ENDPOINT ?? process.env.ODLA_DB_ENDPOINT ?? "https://db.odla.ai",
343
385
  app: { id: "my-app", name: "My App" },
344
386
  envs: ["dev"], // add "prod" deliberately; provisioning it requires --yes
345
- services: ["db", "ai", "o11y"],
387
+ services: ["db", "ai", "o11y", "calendar"],
346
388
  db: {
347
389
  schema: "./src/odla/schema.mjs",
348
390
  rules: "./src/odla/rules.mjs",
@@ -353,6 +395,20 @@ export default {
353
395
  provider: process.env.ODLA_AI_PROVIDER ?? "anthropic",
354
396
  keyEnv: "ANTHROPIC_API_KEY",
355
397
  },
398
+ calendar: {
399
+ google: {
400
+ calendars: { dev: ["primary"] },
401
+ bookingPageUrl: {
402
+ dev: "https://calendar.google.com/calendar/appointments/schedules/…",
403
+ },
404
+ match: {
405
+ summaryPrefix: "Intro", // optional
406
+ organizerSelf: true,
407
+ requireAttendees: true,
408
+ },
409
+ attendeePolicy: "full", // or "hashed"
410
+ },
411
+ },
356
412
  auth: {
357
413
  // Publishable key (public). Created + pulled by the Clerk CLI (`npx clerk`);
358
414
  // See the installed odla-migrate phase 3. Inline `pk_…` or "$ENV_VAR".
@@ -375,7 +431,7 @@ If schema is present and rules are omitted, `defaultRules: "deny"` generates
375
431
  deny-all rules for every schema entity. That is the safe default for Workers
376
432
  that mediate reads and writes with an app key.
377
433
 
378
- ## API reference (generated from dist/index.d.ts, v0.9.0)
434
+ ## API reference (generated from dist/index.d.ts, v0.10.0)
379
435
 
380
436
  ```ts
381
437
  import { SecurityReport, PlatformSecurityRun } from '@odla-ai/security';
@@ -471,79 +527,78 @@ declare function adminAi(options: AdminAiOptions): Promise<void>;
471
527
  /** Stable, machine-readable division of work between the CLI, coding agent,
472
528
  * human operator, and Studio. Printed by `odla-ai capabilities --json`. */
473
529
  declare const CAPABILITIES: {
474
- readonly cli: readonly ["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", "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"];
475
- 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"];
476
- readonly human: readonly ["approve the odla device code and one-off third-party logins", "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"];
477
- readonly studio: readonly ["view telemetry and environment state", "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"];
530
+ readonly cli: readonly ["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"];
531
+ 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"];
532
+ readonly human: readonly ["approve the odla device code and one-off third-party logins", "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"];
533
+ readonly studio: readonly ["view telemetry and environment state", "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"];
478
534
  };
479
535
  type Output = Pick<typeof console, "log">;
480
536
  /** Print the stable responsibility boundary for humans or agent tooling. */
481
537
  declare function printCapabilities(json?: boolean, out?: Output): void;
482
538
 
483
- interface DoctorOptions {
484
- configPath: string;
485
- stdout?: Pick<typeof console, "log" | "error">;
539
+ declare const CALENDAR_STATES: readonly ["not_connected", "authorizing", "needs_sync", "initial_sync", "healthy", "degraded", "disconnected", "failed"];
540
+ type CalendarConnectionState = (typeof CALENDAR_STATES)[number];
541
+ /** Owner-visible, secret-free calendar connection and sync health. */
542
+ interface CalendarStatus {
543
+ env: string;
544
+ enabled: boolean;
545
+ /** True when the platform has provider credentials for this connection. */
546
+ connected: boolean;
547
+ provider: "google" | null;
548
+ status: CalendarConnectionState;
549
+ access?: "read";
550
+ calendars: string[];
551
+ attendeePolicy?: "full" | "hashed";
552
+ /** True once a booking projection may have established the DB privacy policy. */
553
+ attendeePolicyLocked?: boolean;
554
+ bookingPageUrl?: string | null;
555
+ grantedScopes: string[];
556
+ attemptId?: string;
557
+ lastSuccessfulSyncAt?: number;
558
+ lastFullSyncAt?: number;
559
+ watchExpiresAt?: number;
560
+ bookingCount?: number;
561
+ error?: {
562
+ code?: string;
563
+ message?: string;
564
+ };
565
+ }
566
+ /** One Google calendar the connected identity may select for mirroring. */
567
+ interface AvailableGoogleCalendar {
568
+ id: string;
569
+ summary?: string;
570
+ primary?: boolean;
571
+ selected?: boolean;
572
+ accessRole?: "freeBusyReader" | "reader" | "writer" | "owner";
486
573
  }
487
- /**
488
- * Validate and summarize an odla project config entirely offline — no network
489
- * calls and no file writes. Loads `configPath`, builds the provision plan, and
490
- * resolves the schema and rules (synthesizing deny-all rules from the schema
491
- * when `db.rules` is omitted and `db.defaultRules` isn't `false`), then prints a
492
- * summary line for the app, envs, services, schema entity count, rules namespace
493
- * count, and AI provider.
494
- *
495
- * It then collects warnings for the mistakes provision can't fix silently: a
496
- * schema with no entities, a rules namespace with no matching entity, the `ai`
497
- * service enabled without an `ai.provider`, `auth.clerk` entries that reference
498
- * an unset env var (`$FOO`), an `ai.keyEnv` that isn't set (provider key upload
499
- * will be skipped), and — when `o11y` is enabled — any env whose local
500
- * credentials lack an ingest token. It also folds in the shared rule linter,
501
- * git-tracked secret-shaped files, and wrangler config warnings. Prints `ok`
502
- * when clean, otherwise the warning list. Purely advisory: never throws on
503
- * warnings and never mutates anything.
504
- *
505
- * @param options.configPath Path to the `odla.config.mjs` to inspect.
506
- * @param options.stdout Optional console-like sink (defaults to `console`).
507
- */
508
- declare function doctor(options: DoctorOptions): Promise<void>;
509
574
 
510
- interface InitOptions {
511
- rootDir?: string;
512
- configPath?: string;
513
- appId: string;
514
- name: string;
515
- envs?: string[];
516
- services?: string[];
517
- aiProvider?: string;
518
- force?: boolean;
575
+ interface CalendarLifecycleOptions {
576
+ configPath: string;
577
+ env?: string;
578
+ token?: string;
579
+ open?: boolean;
580
+ interactive?: boolean;
581
+ yes?: boolean;
582
+ json?: boolean;
583
+ fetch?: typeof fetch;
519
584
  stdout?: Pick<typeof console, "log" | "error">;
585
+ openConsentUrl?: (url: string) => Promise<void>;
586
+ wait?: (milliseconds: number, signal?: AbortSignal) => Promise<void>;
587
+ pollTimeoutMs?: number;
588
+ now?: () => number;
589
+ signal?: AbortSignal;
520
590
  }
521
- /**
522
- * Scaffold a new odla project into `rootDir` (default: cwd). Writes an
523
- * `odla.config.mjs` (default name, overridable via `configPath`) plus starter
524
- * `src/odla/schema.mjs` (a single `notes` entity) and `src/odla/rules.mjs`
525
- * (deny-all), and creates the `src/odla` and `.odla` directories. Also runs
526
- * `ensureGitignore` so the local token/credentials paths are ignored.
527
- *
528
- * Fully local and synchronous — no network calls. The config file is only
529
- * written when it doesn't already exist unless `force` is set (otherwise it
530
- * throws); the schema/rules files are written only when missing (never
531
- * overwritten, even with `force`). `appId` must match `^[a-z0-9][a-z0-9-]*$` or
532
- * it throws. Defaults: `envs` → `["dev"]`, `services` → `["db","ai"]`,
533
- * `aiProvider` → `"anthropic"` (which also picks the `keyEnv`, e.g.
534
- * `ANTHROPIC_API_KEY`/`OPENAI_API_KEY`/`GOOGLE_API_KEY`).
535
- *
536
- * @param options.appId Slug for the app (lowercase alphanumerics and hyphens).
537
- * @param options.name Human-readable app name embedded in the config.
538
- * @param options.rootDir Project root (defaults to `process.cwd()`).
539
- * @param options.configPath Config filename relative to root (default `odla.config.mjs`).
540
- * @param options.envs Environment names (default `["dev"]`; production is an explicit opt-in).
541
- * @param options.services Enabled services (default `["db","ai"]`).
542
- * @param options.aiProvider AI provider slug (default `"anthropic"`).
543
- * @param options.force Overwrite an existing config file instead of throwing.
544
- * @param options.stdout Optional console-like sink (defaults to `console`).
545
- */
546
- declare function initProject(options: InitOptions): void;
591
+ /** Read the owner-visible Google connection and mirror health for one env. */
592
+ declare function calendarStatus(options: CalendarLifecycleOptions): Promise<CalendarStatus>;
593
+ /** List calendars visible to the connected Google identity for config authoring. */
594
+ declare function calendarCalendars(options: CalendarLifecycleOptions): Promise<AvailableGoogleCalendar[]>;
595
+ /** Apply the public booking page setting, then complete Google consent + initial sync. */
596
+ declare function calendarConnect(options: CalendarLifecycleOptions): Promise<CalendarStatus>;
597
+ /** Ask the hosted connector for an immediate incremental/full recovery sync. */
598
+ declare function calendarResync(options: CalendarLifecycleOptions): Promise<CalendarStatus>;
599
+ /** Stop watches and delete this connection's encrypted platform token/cursors
600
+ * without purging the mirror or revoking the shared Google project grant. */
601
+ declare function calendarDisconnect(options: CalendarLifecycleOptions): Promise<CalendarStatus>;
547
602
 
548
603
  interface RunResult {
549
604
  code: number;
@@ -568,6 +623,41 @@ interface ClerkAuthConfig {
568
623
  audience?: string;
569
624
  mode?: "client" | "full";
570
625
  }
626
+ /** Read-only event selection applied by the hosted Google calendar connector. */
627
+ interface GoogleCalendarMatchConfig {
628
+ /** Mirror only events whose summary begins with this value. */
629
+ summaryPrefix?: string;
630
+ /** Require the connected identity to organize the event. Defaults to true. */
631
+ organizerSelf?: boolean;
632
+ /** Require at least one attendee. Defaults to true. */
633
+ requireAttendees?: boolean;
634
+ }
635
+ /** Google Calendar intent. OAuth credentials never belong in this config. */
636
+ interface GoogleCalendarConfig {
637
+ /** One through ten provider calendar ids to mirror in each odla environment. */
638
+ calendars: Record<OdlaEnvName, string[]>;
639
+ /** Public Google Appointment Schedule URL for static embed/link mode. */
640
+ bookingPageUrl?: Record<OdlaEnvName, string | null>;
641
+ match?: GoogleCalendarMatchConfig;
642
+ /** Store normalized attendee addresses, or only SHA-256 match keys. */
643
+ attendeePolicy?: "full" | "hashed";
644
+ }
645
+ interface CalendarConfig {
646
+ google: GoogleCalendarConfig;
647
+ }
648
+ /** Canonical, environment-specific config sent to the calendar controller. */
649
+ interface CalendarServiceConfig extends Record<string, unknown> {
650
+ provider: "google";
651
+ access: "read";
652
+ /** Deduplicated provider ids; the hosted connector accepts at most ten. */
653
+ calendars: string[];
654
+ match: {
655
+ organizerSelf: boolean;
656
+ requireAttendees: boolean;
657
+ summaryPrefix?: string;
658
+ };
659
+ attendeePolicy: "full" | "hashed";
660
+ }
571
661
  /** Authored `odla.config.mjs` contract consumed by doctor and provision. */
572
662
  interface OdlaProjectConfig {
573
663
  platformUrl?: string;
@@ -596,6 +686,7 @@ interface OdlaProjectConfig {
596
686
  /** Vault secret name. Defaults to @odla-ai/ai's provider default. */
597
687
  secretName?: string;
598
688
  };
689
+ calendar?: CalendarConfig;
599
690
  o11y?: {
600
691
  /** This service's name in the collector. Defaults to the app id. */
601
692
  service?: string;
@@ -660,6 +751,10 @@ interface ProvisionOptions {
660
751
  interactive?: boolean;
661
752
  /** Test/embedding override for opening the approval URL. Defaults to the OS browser opener. */
662
753
  openApprovalUrl?: (url: string) => Promise<void>;
754
+ /** Test/embedding override for calendar connection polling. */
755
+ calendarPollWait?: (milliseconds: number, signal?: AbortSignal) => Promise<void>;
756
+ /** Maximum calendar consent + initial-sync wait. Defaults to ten minutes. */
757
+ calendarPollTimeoutMs?: number;
663
758
  /** Explicit consent for a non-dry-run plan containing `prod` or `production`. */
664
759
  yes?: boolean;
665
760
  fetch?: typeof fetch;
@@ -683,10 +778,86 @@ interface ProvisionPlan {
683
778
  interface SmokeOptions {
684
779
  configPath: string;
685
780
  env?: string;
781
+ /** Developer-token override used only for owner-visible calendar health. */
782
+ token?: string;
783
+ open?: boolean;
784
+ interactive?: boolean;
785
+ openApprovalUrl?: (url: string) => Promise<void>;
686
786
  fetch?: typeof fetch;
687
787
  stdout?: Pick<typeof console, "log" | "error">;
688
788
  }
689
789
 
790
+ declare const GOOGLE_CALENDAR_READ_SCOPE = "https://www.googleapis.com/auth/calendar.events.readonly";
791
+ /** Resolve the checked-in calendar block into one controller-safe env payload. */
792
+ declare function calendarServiceConfig(cfg: LoadedProjectConfig, env: string): CalendarServiceConfig;
793
+ /** Public Appointment Schedule URL to apply separately from connector config. */
794
+ declare function calendarBookingPageUrl(cfg: LoadedProjectConfig, env: string): string | null | undefined;
795
+
796
+ interface DoctorOptions {
797
+ configPath: string;
798
+ stdout?: Pick<typeof console, "log" | "error">;
799
+ }
800
+ /**
801
+ * Validate and summarize an odla project config entirely offline — no network
802
+ * calls and no file writes. Loads `configPath`, builds the provision plan, and
803
+ * resolves the schema and rules (synthesizing deny-all rules from the schema
804
+ * when `db.rules` is omitted and `db.defaultRules` isn't `false`), then prints a
805
+ * summary line for the app, envs, services, schema entity count, rules namespace
806
+ * count, and AI provider.
807
+ *
808
+ * It then collects warnings for the mistakes provision can't fix silently: a
809
+ * schema with no entities, a rules namespace with no matching entity, the `ai`
810
+ * service enabled without an `ai.provider`, `auth.clerk` entries that reference
811
+ * an unset env var (`$FOO`), an `ai.keyEnv` that isn't set (provider key upload
812
+ * will be skipped), and — when `o11y` is enabled — any env whose local
813
+ * credentials lack an ingest token. It also folds in the shared rule linter,
814
+ * git-tracked secret-shaped files, and wrangler config warnings. Prints `ok`
815
+ * when clean, otherwise the warning list. Purely advisory: never throws on
816
+ * warnings and never mutates anything.
817
+ *
818
+ * @param options.configPath Path to the `odla.config.mjs` to inspect.
819
+ * @param options.stdout Optional console-like sink (defaults to `console`).
820
+ */
821
+ declare function doctor(options: DoctorOptions): Promise<void>;
822
+
823
+ interface InitOptions {
824
+ rootDir?: string;
825
+ configPath?: string;
826
+ appId: string;
827
+ name: string;
828
+ envs?: string[];
829
+ services?: string[];
830
+ aiProvider?: string;
831
+ force?: boolean;
832
+ stdout?: Pick<typeof console, "log" | "error">;
833
+ }
834
+ /**
835
+ * Scaffold a new odla project into `rootDir` (default: cwd). Writes an
836
+ * `odla.config.mjs` (default name, overridable via `configPath`) plus starter
837
+ * `src/odla/schema.mjs` (a single `notes` entity) and `src/odla/rules.mjs`
838
+ * (deny-all), and creates the `src/odla` and `.odla` directories. Also runs
839
+ * `ensureGitignore` so the local token/credentials paths are ignored.
840
+ *
841
+ * Fully local and synchronous — no network calls. The config file is only
842
+ * written when it doesn't already exist unless `force` is set (otherwise it
843
+ * throws); the schema/rules files are written only when missing (never
844
+ * overwritten, even with `force`). `appId` must match `^[a-z0-9][a-z0-9-]*$` or
845
+ * it throws. Defaults: `envs` → `["dev"]`, `services` → `["db","ai"]`,
846
+ * `aiProvider` → `"anthropic"` (which also picks the `keyEnv`, e.g.
847
+ * `ANTHROPIC_API_KEY`/`OPENAI_API_KEY`/`GOOGLE_API_KEY`).
848
+ *
849
+ * @param options.appId Slug for the app (lowercase alphanumerics and hyphens).
850
+ * @param options.name Human-readable app name embedded in the config.
851
+ * @param options.rootDir Project root (defaults to `process.cwd()`).
852
+ * @param options.configPath Config filename relative to root (default `odla.config.mjs`).
853
+ * @param options.envs Environment names (default `["dev"]`; production is an explicit opt-in).
854
+ * @param options.services Enabled services (default `["db","ai"]`).
855
+ * @param options.aiProvider AI provider slug (default `"anthropic"`).
856
+ * @param options.force Overwrite an existing config file instead of throwing.
857
+ * @param options.stdout Optional console-like sink (defaults to `console`).
858
+ */
859
+ declare function initProject(options: InitOptions): void;
860
+
690
861
  /**
691
862
  * Provision an app end-to-end from its config — the primary deploy path, and
692
863
  * (apart from key rotation) idempotent, so re-running is safe. Obtains a
@@ -1046,5 +1217,5 @@ declare function installSkill(options?: SkillInstallOptions): SkillInstallResult
1046
1217
  */
1047
1218
  declare function smoke(options: SmokeOptions): Promise<void>;
1048
1219
 
1049
- export { AGENT_HARNESSES, type AdminAiOptions, type AgentHarness, type AgentHarnessSelector, CAPABILITIES, type CliDependencies, type ConnectGitHubSecuritySourceOptions, type DisconnectGitHubSecuritySourceOptions, type FollowHostedSecurityJobOptions, type GetHostedSecurityIntentOptions, type GetHostedSecurityJobOptions, 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, 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 };
1220
+ 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 };
1050
1221
  ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@odla-ai/cli",
3
- "version": "0.9.0",
4
- "description": "Agent-operable CLI for odla provisioning, System AI administration, commit-pinned GitHub security jobs, Worker secrets, and smoke checks.",
3
+ "version": "0.10.0",
4
+ "description": "Agent-operable CLI for odla provisioning, calendar consent and sync lifecycle, System AI administration, Worker secrets, security jobs, and smoke checks.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://odla.ai/docs/packages/cli",
7
7
  "repository": {
@@ -60,7 +60,7 @@
60
60
  },
61
61
  "dependencies": {
62
62
  "@odla-ai/ai": "^0.3.3",
63
- "@odla-ai/apps": "^0.7.1",
63
+ "@odla-ai/apps": "^0.8.0",
64
64
  "@odla-ai/db": "^0.6.2",
65
65
  "@odla-ai/security": "^0.2.2"
66
66
  },
@@ -2,7 +2,7 @@
2
2
  name: odla
3
3
  description: >
4
4
  Build a new app on odla — a realtime database (odla-db) plus AI, Clerk auth,
5
- and observability on Cloudflare, provisioned by @odla-ai/cli. Use when the user
5
+ read-only Google Calendar mirrors, and observability on Cloudflare, provisioned by @odla-ai/cli. Use when the user
6
6
  wants to create/scaffold an odla app, add odla-db/ai/auth/o11y to a repo, or
7
7
  "get started with odla". For moving an existing static or GitHub Pages site to
8
8
  odla, use the odla-migrate skill instead.
@@ -15,7 +15,7 @@ runbookOrder:
15
15
 
16
16
  You drive setup and building on **odla** — an agent-operable app platform on
17
17
  Cloudflare: a realtime graph database (**odla-db**), multi-provider **AI**,
18
- **Clerk** auth, and OpenTelemetry **observability**, all provisioned by the
18
+ **Clerk** auth, read-only **Google Calendar** mirrors, and OpenTelemetry **observability**, all provisioned by the
19
19
  `@odla-ai/cli`. The human approves a couple of browser-only checkpoints; you do
20
20
  everything else.
21
21
 
@@ -48,6 +48,9 @@ State which path you're taking and what you'll build in one line; get a nod.
48
48
  4. Never `git add -A` without reading `git status` first. Never run
49
49
  `provision --rotate-keys` or `provision --rotate-o11y-token` unless the human
50
50
  explicitly asks.
51
+ 5. Google OAuth is a distinct human checkpoint. Never request, paste, print, or
52
+ store a Google authorization code/refresh token. Open only the state-bound
53
+ platform/Google consent URL returned by odla; calendar actions remain unavailable in the read-only slice.
51
54
 
52
55
  ## The flow
53
56
 
@@ -67,7 +70,9 @@ guessing which platform/credential steps need manual work. Then:
67
70
  prints; the human approves it at https://odla.ai/studio. It creates the app,
68
71
  enables services, issues or reuses configured credentials (db key + o11y
69
72
  ingest token when enabled), pushes schema + rules, writes `.dev.vars`, and
70
- transfers Worker secrets through Wrangler stdin.
73
+ transfers Worker secrets through Wrangler stdin. With calendar enabled it
74
+ then prints a second, server-issued Google URL; the human grants read-only consent
75
+ and the CLI follows initial sync.
71
76
  4. **run** — `npx wrangler dev` (auto-loads `.dev.vars`); verify locally.
72
77
  5. **security** — run the passive `@odla-ai/security` odla profile; inspect
73
78
  every lead and keep critical candidate gating enabled. If the human approves
@@ -88,6 +93,10 @@ guessing which platform/credential steps need manual work. Then:
88
93
 
89
94
  `npx @odla-ai/cli doctor` is an offline config check anytime;
90
95
  `npx @odla-ai/cli smoke --env dev` verifies a live deployment.
96
+ Use `calendar status --json` for safe connection/sync state and `calendar
97
+ calendars --json` to discover ids after consent; update checked-in config and
98
+ re-provision. Resync production only with `--yes`; disconnect always requires
99
+ `--yes` and leaves retained rows potentially stale.
91
100
 
92
101
  The CLI owns deterministic platform work from `odla.config.mjs`: service
93
102
  enablement, credential issuance/storage, `.dev.vars`, and Wrangler secret
@@ -15,6 +15,13 @@ deny-all rules from the schema. To turn on auth/observability, add `"o11y"` to
15
15
  `services` and an `auth.clerk` block in `odla.config.mjs` (init leaves it
16
16
  commented).
17
17
 
18
+ For a Google booking mirror, include both `"db"` and `"calendar"`. Configure
19
+ `calendar.google.calendars` for every env (start with `"primary"`), optional
20
+ match filters, and `attendeePolicy: "full" | "hashed"`. This release is
21
+ read-only; do not add OAuth credentials or action scopes to config.
22
+ For static Appointment Schedule parity, add the public per-env
23
+ `bookingPageUrl`; it is link/embed configuration, never a credential.
24
+
18
25
  ## 2. Build the Worker shell
19
26
 
20
27
  `npm i` only the SDKs you need and use the local `references/sdks.md` as the
@@ -43,6 +50,13 @@ Local credential files are `0600` and gitignored. Verify with
43
50
  anything unset. `--push-secrets` preflights the Wrangler config and login before
44
51
  issuing or rotating a shown-once credential.
45
52
 
53
+ Calendar adds a second ⏸ checkpoint after the odla device approval: provision
54
+ prints/opens a state-bound Google URL issued by the platform and waits while the human grants
55
+ `calendar.events.readonly` and the hosted connector performs initial sync. The
56
+ CLI never receives the Google callback code or tokens. Once connected, run
57
+ `npx @odla-ai/cli calendar calendars --env dev --json`, refine the checked-in
58
+ calendar ids if needed, re-provision, and verify `calendar status --json`.
59
+
46
60
  The CLI stops at the source boundary: it verifies but does not invent your
47
61
  application semantics. Do not use Studio to mint a routine o11y token. Manual
48
62
  Studio rotation is recovery-only;
@@ -61,6 +75,11 @@ means the namespace has no rule yet — add one in `src/odla/rules.mjs`
61
75
  (deliberately; e.g. `{ notes: { view: "auth.signedIn", create: "auth.signedIn" } }`),
62
76
  re-provision to push it, and retry.
63
77
 
78
+ Calendar uses the same `ODLA_ENDPOINT`, `ODLA_TENANT`, and server-only
79
+ `ODLA_API_KEY`; it adds no Worker secret. Keep `initCalendar` in trusted Worker
80
+ code. Browser code uses db subscriptions under explicit rules or pure
81
+ `@odla-ai/calendar/client` helpers, never the admin key.
82
+
64
83
  ## 5. Security preflight
65
84
 
66
85
  Install the passive harness and scan before any production secret or deploy:
@@ -31,6 +31,35 @@ Worker/admin side: `init({ appId: tenantId, adminToken: env.ODLA_API_KEY, endpoi
31
31
  The publishable key is public; `provision` stores it (`setAuth`). Rules evaluate
32
32
  the signed-in user's JWT as `auth` — e.g. `auth.signedIn`, `auth.email`.
33
33
 
34
+ ## @odla-ai/calendar — read-only Google booking mirror
35
+
36
+ Calendar requires `services: ["db", "calendar"]` plus a `calendar.google`
37
+ block. Normal provision opens a second, state-bound Google checkpoint issued by the platform for the
38
+ human to grant `calendar.events.readonly`; Google tokens stay in the hosted
39
+ connector and never become app/CLI secrets.
40
+
41
+ ```ts
42
+ // Trusted Worker only — the admin key must never enter browser code.
43
+ const calendar = initCalendar({
44
+ appId: env.ODLA_TENANT,
45
+ adminToken: env.ODLA_API_KEY,
46
+ endpoint: env.ODLA_ENDPOINT,
47
+ });
48
+ const next = await calendar.bookings.next("member@example.com");
49
+ ```
50
+
51
+ Browser code may query `$bookings` with `@odla-ai/db/client` only under an
52
+ explicit view rule, and may import pure formatting helpers from
53
+ `@odla-ai/calendar/client`. Do not import `initCalendar` or expose
54
+ `ODLA_API_KEY` in a browser. Provider actions are not part of the read-only
55
+ slice; a `calendar_not_connected`/501 action response is not a reason to widen
56
+ credentials or request a Google token.
57
+
58
+ After consent, use `odla-ai calendar calendars --env dev --json` to discover
59
+ selectable ids, edit the checked-in list, and optionally set a public per-env
60
+ `bookingPageUrl` for Appointment Schedule embed/link mode. Re-provision, then verify with
61
+ `calendar status --json` and `smoke`.
62
+
34
63
  ## @odla-ai/ai — inference (Claude / GPT / Gemini)
35
64
 
36
65
  ```ts