@odla-ai/chapter 0.40.1 → 0.40.3

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
@@ -1213,6 +1213,9 @@ interface BuilderLibraryValidationOptions {
1213
1213
  sourceType?: BuilderLibrarySourceType;
1214
1214
  sourceAppId?: string;
1215
1215
  targetAppId?: string;
1216
+ /** Chapter IDs a Built Not Found document may address. An empty or omitted
1217
+ * allowlist keeps the historical global-or-private-only behavior. */
1218
+ allowedChapterIds?: readonly string[];
1216
1219
  }
1217
1220
  /** A validated document or actionable strict-contract errors. */
1218
1221
  type BuilderLibraryValidationResult = {
@@ -1260,7 +1263,8 @@ interface BuilderLibraryReceipt {
1260
1263
  declare function canViewBuilderLibraryResource(resource: BuilderLibraryResource, viewer: BuilderLibraryViewer): boolean;
1261
1264
  /** Produce deterministic, published-only input for a site-building agent. */
1262
1265
  declare function buildBuilderLibraryManifest(documents: readonly BuilderLibraryDocument[], viewer: BuilderLibraryViewer, generatedAt?: number, limit?: number): BuilderLibraryManifest;
1263
- /** Build the exact signed layer for one peer; BNF-only material never crosses to a Chapter. */
1266
+ /** Build the exact signed layer for one peer; private and sibling material
1267
+ * never crosses to a Chapter. */
1264
1268
  declare function projectBuilderLibraryDelivery(document: BuilderLibraryDocument, target: BuilderLibraryTarget): BuilderLibraryDocument;
1265
1269
  /** Copy a Chapter item into global authority while preserving its exact origin. */
1266
1270
  declare function promoteBuilderLibraryResource(input: {
@@ -2103,6 +2107,8 @@ declare function stripeCall(sk: string, method: "GET" | "POST" | "DELETE", path:
2103
2107
  interface ClerkResult {
2104
2108
  ok: boolean;
2105
2109
  status: number;
2110
+ /** Stable Clerk user id returned by a successful fresh account create. */
2111
+ userId?: string;
2106
2112
  existed?: boolean;
2107
2113
  /** Set when an `existed` heal also refreshed the account's metadata. */
2108
2114
  refreshed?: boolean;
@@ -2221,14 +2227,16 @@ interface IntegrationSetting {
2221
2227
  /**
2222
2228
  * A secret the capability needs, held in the tenant vault.
2223
2229
  *
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
2230
+ * Structurally the odla CLI's `IntegrationSecret`: `name` is the effective
2231
+ * runtime vault name, so `odla-ai doctor`, `odla-ai secrets status`, and the
2226
2232
  * 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.
2233
+ * package requests. The Clerk backend key is stored once in the reserved
2234
+ * `$clerk_secret` slot and odla-db resolves its released `clerk_secret_key`
2235
+ * compatibility name. `mode` is chapter's own addition and the CLI ignores it.
2229
2236
  */
2230
2237
  interface IntegrationSecret {
2231
- /** Vault name, exactly as `odla-ai secrets set <name>` writes it. */
2238
+ /** Effective runtime vault name. Dedicated platform commands may keep the
2239
+ * canonical value in a reserved slot and resolve this compatibility name. */
2232
2240
  name: string;
2233
2241
  description: string;
2234
2242
  pattern?: string;
package/dist/index.d.ts CHANGED
@@ -1213,6 +1213,9 @@ interface BuilderLibraryValidationOptions {
1213
1213
  sourceType?: BuilderLibrarySourceType;
1214
1214
  sourceAppId?: string;
1215
1215
  targetAppId?: string;
1216
+ /** Chapter IDs a Built Not Found document may address. An empty or omitted
1217
+ * allowlist keeps the historical global-or-private-only behavior. */
1218
+ allowedChapterIds?: readonly string[];
1216
1219
  }
1217
1220
  /** A validated document or actionable strict-contract errors. */
1218
1221
  type BuilderLibraryValidationResult = {
@@ -1260,7 +1263,8 @@ interface BuilderLibraryReceipt {
1260
1263
  declare function canViewBuilderLibraryResource(resource: BuilderLibraryResource, viewer: BuilderLibraryViewer): boolean;
1261
1264
  /** Produce deterministic, published-only input for a site-building agent. */
1262
1265
  declare function buildBuilderLibraryManifest(documents: readonly BuilderLibraryDocument[], viewer: BuilderLibraryViewer, generatedAt?: number, limit?: number): BuilderLibraryManifest;
1263
- /** Build the exact signed layer for one peer; BNF-only material never crosses to a Chapter. */
1266
+ /** Build the exact signed layer for one peer; private and sibling material
1267
+ * never crosses to a Chapter. */
1264
1268
  declare function projectBuilderLibraryDelivery(document: BuilderLibraryDocument, target: BuilderLibraryTarget): BuilderLibraryDocument;
1265
1269
  /** Copy a Chapter item into global authority while preserving its exact origin. */
1266
1270
  declare function promoteBuilderLibraryResource(input: {
@@ -2103,6 +2107,8 @@ declare function stripeCall(sk: string, method: "GET" | "POST" | "DELETE", path:
2103
2107
  interface ClerkResult {
2104
2108
  ok: boolean;
2105
2109
  status: number;
2110
+ /** Stable Clerk user id returned by a successful fresh account create. */
2111
+ userId?: string;
2106
2112
  existed?: boolean;
2107
2113
  /** Set when an `existed` heal also refreshed the account's metadata. */
2108
2114
  refreshed?: boolean;
@@ -2221,14 +2227,16 @@ interface IntegrationSetting {
2221
2227
  /**
2222
2228
  * A secret the capability needs, held in the tenant vault.
2223
2229
  *
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
2230
+ * Structurally the odla CLI's `IntegrationSecret`: `name` is the effective
2231
+ * runtime vault name, so `odla-ai doctor`, `odla-ai secrets status`, and the
2226
2232
  * 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.
2233
+ * package requests. The Clerk backend key is stored once in the reserved
2234
+ * `$clerk_secret` slot and odla-db resolves its released `clerk_secret_key`
2235
+ * compatibility name. `mode` is chapter's own addition and the CLI ignores it.
2229
2236
  */
2230
2237
  interface IntegrationSecret {
2231
- /** Vault name, exactly as `odla-ai secrets set <name>` writes it. */
2238
+ /** Effective runtime vault name. Dedicated platform commands may keep the
2239
+ * canonical value in a reserved slot and resolve this compatibility name. */
2232
2240
  name: string;
2233
2241
  description: string;
2234
2242
  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
@@ -2455,8 +2462,8 @@ function validateBuilderLibraryDocument(value, options = {}) {
2455
2462
  if (sourceType === "chapter" && (resource.scope.kind !== "chapter" || resource.scope.chapterId !== sourceAppId)) {
2456
2463
  errors.push(`document.resources.${resource.id}: Chapter sources may author only their own chapter scope`);
2457
2464
  }
2458
- if (sourceType === "built_not_found" && resource.scope.kind === "chapter") {
2459
- errors.push(`document.resources.${resource.id}: Built Not Found sources may author only built_not_found or global scope`);
2465
+ if (sourceType === "built_not_found" && resource.scope.kind === "chapter" && !(options.allowedChapterIds ?? []).includes(resource.scope.chapterId)) {
2466
+ errors.push(`document.resources.${resource.id}: Built Not Found may target only configured Chapters`);
2460
2467
  }
2461
2468
  }
2462
2469
  if (errors.length) return { ok: false, errors };
@@ -2488,7 +2495,7 @@ function projectBuilderLibraryDelivery(document, target) {
2488
2495
  return {
2489
2496
  ...document,
2490
2497
  target,
2491
- resources: document.source.type === "built_not_found" ? document.resources.filter((resource) => resource.scope.kind === "global") : document.resources
2498
+ resources: document.source.type === "built_not_found" ? document.resources.filter((resource) => resource.scope.kind === "global" || resource.scope.kind === "chapter" && resource.scope.chapterId === target.appId) : document.resources
2492
2499
  };
2493
2500
  }
2494
2501
  function promoteBuilderLibraryResource(input) {
@@ -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
  };