@odla-ai/chapter 0.40.1 → 0.40.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/dist/index.d.cts CHANGED
@@ -2103,6 +2103,8 @@ declare function stripeCall(sk: string, method: "GET" | "POST" | "DELETE", path:
2103
2103
  interface ClerkResult {
2104
2104
  ok: boolean;
2105
2105
  status: number;
2106
+ /** Stable Clerk user id returned by a successful fresh account create. */
2107
+ userId?: string;
2106
2108
  existed?: boolean;
2107
2109
  /** Set when an `existed` heal also refreshed the account's metadata. */
2108
2110
  refreshed?: boolean;
@@ -2221,14 +2223,16 @@ interface IntegrationSetting {
2221
2223
  /**
2222
2224
  * A secret the capability needs, held in the tenant vault.
2223
2225
  *
2224
- * Structurally the odla CLI's `IntegrationSecret`: `name` is the vault name
2225
- * byte-for-byte, so `odla-ai doctor`, `odla-ai secrets status`, and the
2226
+ * Structurally the odla CLI's `IntegrationSecret`: `name` is the effective
2227
+ * runtime vault name, so `odla-ai doctor`, `odla-ai secrets status`, and the
2226
2228
  * repo's `check:secrets` gate can hold this declaration against the name the
2227
- * platform actually reads. `mode` is chapter's own addition and the CLI
2228
- * ignores it.
2229
+ * package requests. The Clerk backend key is stored once in the reserved
2230
+ * `$clerk_secret` slot and odla-db resolves its released `clerk_secret_key`
2231
+ * compatibility name. `mode` is chapter's own addition and the CLI ignores it.
2229
2232
  */
2230
2233
  interface IntegrationSecret {
2231
- /** Vault name, exactly as `odla-ai secrets set <name>` writes it. */
2234
+ /** Effective runtime vault name. Dedicated platform commands may keep the
2235
+ * canonical value in a reserved slot and resolve this compatibility name. */
2232
2236
  name: string;
2233
2237
  description: string;
2234
2238
  pattern?: string;
package/dist/index.d.ts CHANGED
@@ -2103,6 +2103,8 @@ declare function stripeCall(sk: string, method: "GET" | "POST" | "DELETE", path:
2103
2103
  interface ClerkResult {
2104
2104
  ok: boolean;
2105
2105
  status: number;
2106
+ /** Stable Clerk user id returned by a successful fresh account create. */
2107
+ userId?: string;
2106
2108
  existed?: boolean;
2107
2109
  /** Set when an `existed` heal also refreshed the account's metadata. */
2108
2110
  refreshed?: boolean;
@@ -2221,14 +2223,16 @@ interface IntegrationSetting {
2221
2223
  /**
2222
2224
  * A secret the capability needs, held in the tenant vault.
2223
2225
  *
2224
- * Structurally the odla CLI's `IntegrationSecret`: `name` is the vault name
2225
- * byte-for-byte, so `odla-ai doctor`, `odla-ai secrets status`, and the
2226
+ * Structurally the odla CLI's `IntegrationSecret`: `name` is the effective
2227
+ * runtime vault name, so `odla-ai doctor`, `odla-ai secrets status`, and the
2226
2228
  * repo's `check:secrets` gate can hold this declaration against the name the
2227
- * platform actually reads. `mode` is chapter's own addition and the CLI
2228
- * ignores it.
2229
+ * package requests. The Clerk backend key is stored once in the reserved
2230
+ * `$clerk_secret` slot and odla-db resolves its released `clerk_secret_key`
2231
+ * compatibility name. `mode` is chapter's own addition and the CLI ignores it.
2229
2232
  */
2230
2233
  interface IntegrationSecret {
2231
- /** Vault name, exactly as `odla-ai secrets set <name>` writes it. */
2234
+ /** Effective runtime vault name. Dedicated platform commands may keep the
2235
+ * canonical value in a reserved slot and resolve this compatibility name. */
2232
2236
  name: string;
2233
2237
  description: string;
2234
2238
  pattern?: string;
package/dist/index.js CHANGED
@@ -1955,7 +1955,14 @@ function createChapterIntegration(chapter, options = {}) {
1955
1955
  },
1956
1956
  rules: { ...crmDesc.rules, ...chapter.rules },
1957
1957
  seeds,
1958
- secrets: [],
1958
+ secrets: chapter.account === "none" ? [] : [{
1959
+ // Released Chapter workers request this effective name. odla-db maps
1960
+ // it to the canonical reserved `$clerk_secret` value written by
1961
+ // `odla-ai secrets set-clerk-key`.
1962
+ name: "clerk_secret_key",
1963
+ description: "Clerk backend key (set with odla-ai secrets set-clerk-key) required by the configured Chapter account model.",
1964
+ required: true
1965
+ }],
1959
1966
  probes: [
1960
1967
  ...crmDesc.probes ?? [],
1961
1968
  // The snapshot route is deliberately private. A credential-free smoke
@@ -3465,7 +3472,14 @@ async function createClerkUser(secretKey, input, fetchImpl = fetch) {
3465
3472
  headers: { authorization: `Bearer ${secretKey}`, "content-type": "application/json" },
3466
3473
  body: JSON.stringify(body)
3467
3474
  });
3468
- if (res.ok) return { ok: true, status: res.status };
3475
+ if (res.ok) {
3476
+ const body2 = typeof res.json === "function" ? await res.json().catch(() => null) : null;
3477
+ return {
3478
+ ok: true,
3479
+ status: res.status,
3480
+ ...typeof body2?.id === "string" && body2.id ? { userId: body2.id } : {}
3481
+ };
3482
+ }
3469
3483
  const healed = heal(res.status);
3470
3484
  const repair = input.repairMetadata ?? {
3471
3485
  ...input.publicMetadata !== void 0 ? { publicMetadata: input.publicMetadata } : {},
@@ -3567,7 +3581,7 @@ var clerkIntegration = {
3567
3581
  },
3568
3582
  {
3569
3583
  name: "clerk_secret_key",
3570
- description: "Clerk backend key (sk_*) \u2014 powers account creation, the public role claim, and backend-only private profile signals; it also lets odla-db resolve user email/name via the Clerk API.",
3584
+ description: "Effective Clerk backend key (sk_*), stored canonically by set-clerk-key in reserved $clerk_secret \u2014 powers account creation, the public role claim, backend-only private profile signals, and odla-db user resolution.",
3571
3585
  pattern: "sk_",
3572
3586
  mode: "full",
3573
3587
  required: false
@@ -3600,15 +3614,16 @@ var clerkIntegration = {
3600
3614
  provision: {
3601
3615
  human: [
3602
3616
  "Run `npx clerk auth login` \u2014 the one interactive step; the agent then creates + configures the Clerk app with the Clerk CLI (no pk_ to hand-paste).",
3603
- 'For auth mode "full": create the Clerk user-sync webhook and store its whsec_, plus the sk_ as clerk_secret_key, in the tenant vault (Studio, write-only).'
3617
+ 'For auth mode "full": create the Clerk user-sync webhook, store its whsec_, and transfer the sk_ with `odla-ai secrets set-clerk-key --env <env> --stdin` (write-only).'
3604
3618
  ],
3605
3619
  cli: [
3606
3620
  "Clerk CLI (`npx clerk apps create/link/config patch`) creates + configures the instance and pulls the pk_.",
3607
- "odla `provision` records it: setAuth(env, publishableKey) -> apps-registry (issuer/JWKS derived from the key)."
3621
+ "odla `provision` records it: setAuth(env, publishableKey) -> apps-registry (issuer/JWKS derived from the key).",
3622
+ "odla `secrets set-clerk-key` stores one environment-scoped reserved credential consumed by odla-db and Chapter."
3608
3623
  ],
3609
3624
  doctor: [
3610
3625
  "registry auth[env] present when the app mounts <SignIn>?",
3611
- 'auth mode "full" => whsec_ and clerk_secret_key present in the tenant vault?'
3626
+ 'auth mode "full" => whsec_ present and the effective clerk_secret_key reports set via the reserved Clerk credential status?'
3612
3627
  ]
3613
3628
  }
3614
3629
  };