@alvera-ai/platform-sdk 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/.agent/AGENTS.md +82 -144
  2. package/.agent/account_management.md +2 -2
  3. package/.agent/action_logs.md +4 -4
  4. package/.agent/ai_agents.md +28 -21
  5. package/.agent/ai_sandbox.md +49 -39
  6. package/.agent/connected_apps.md +3 -3
  7. package/.agent/cookbook/_fixtures/README.md +1 -1
  8. package/.agent/cookbook/_fixtures/{foundation → organic-marketing}/_lead_submissions_foundation_generic_table.liquid +1 -1
  9. package/.agent/cookbook/_fixtures/organic-marketing/_lead_submissions_foundation_legal_entity.liquid +80 -0
  10. package/.agent/cookbook/_fixtures/{foundation → organic-marketing}/_lead_submissions_foundation_mdm.liquid +2 -1
  11. package/.agent/cookbook/_fixtures/payments-compliance/_compliance_screenings_generic_table.liquid +57 -0
  12. package/.agent/cookbook/_fixtures/payments-compliance/_compliance_screenings_legal_entity.liquid +30 -0
  13. package/.agent/cookbook/_fixtures/payments-compliance/_compliance_screenings_mdm.liquid +44 -0
  14. package/.agent/cookbook/_fixtures/payments-compliance/_payment_accounts_generic_table.liquid +57 -0
  15. package/.agent/cookbook/_fixtures/payments-compliance/_payment_accounts_legal_entity.liquid +36 -0
  16. package/.agent/cookbook/_fixtures/payments-compliance/_payment_accounts_mdm.liquid +41 -0
  17. package/.agent/cookbook/_fixtures/primary-care-feedback/_cahps_appointments_generic_table.liquid +70 -0
  18. package/.agent/cookbook/_fixtures/primary-care-feedback/_cahps_appointments_legal_entity.liquid +52 -0
  19. package/.agent/cookbook/_fixtures/primary-care-feedback/_cahps_appointments_mdm.liquid +42 -0
  20. package/.agent/cookbook/_fixtures/subscription-saas/_customers_subscription_generic_table.liquid +38 -0
  21. package/.agent/cookbook/_fixtures/subscription-saas/_customers_subscription_legal_entity.liquid +48 -0
  22. package/.agent/cookbook/_fixtures/subscription-saas/_customers_subscription_mdm.liquid +49 -0
  23. package/.agent/cookbook/organic-marketing.md +2801 -0
  24. package/.agent/cookbook/payments-compliance.md +2180 -0
  25. package/.agent/cookbook/primary-care.md +2175 -0
  26. package/.agent/cookbook/subscription-saas.md +2403 -0
  27. package/.agent/data_activation_clients.md +65 -52
  28. package/.agent/datalakes.md +338 -171
  29. package/.agent/errors.md +3 -3
  30. package/.agent/generic_tables.md +151 -62
  31. package/.agent/interoperability_contracts.md +57 -22
  32. package/.agent/mdm.md +136 -153
  33. package/.agent/messages.md +36 -34
  34. package/.agent/mock-services.md +1 -1
  35. package/.agent/mutations.md +2 -2
  36. package/.agent/templates.md +14 -13
  37. package/.agent/tools.md +63 -21
  38. package/.agent/type_naming.md +13 -13
  39. package/.agent/workflows.md +99 -53
  40. package/README.md +2 -2
  41. package/dist/bin/platform-sdk.mjs +33 -47
  42. package/dist/bin/platform-sdk.mjs.map +1 -1
  43. package/dist/index.d.mts +565 -379
  44. package/dist/index.d.mts.map +1 -1
  45. package/dist/index.mjs +494 -59
  46. package/dist/index.mjs.map +1 -1
  47. package/package.json +4 -3
  48. package/.agent/cookbook/_fixtures/foundation/_lead_submissions_foundation_legal_entity.liquid +0 -88
  49. package/.agent/cookbook/_fixtures/healthcare/_cahps_appointments_healthcare_appointment.liquid +0 -47
  50. package/.agent/cookbook/_fixtures/healthcare/_cahps_appointments_healthcare_mdm.liquid +0 -24
  51. package/.agent/cookbook/_fixtures/healthcare/_cahps_appointments_healthcare_patient.liquid +0 -38
  52. package/.agent/cookbook/_fixtures/payments/_compliance_screenings_payments_compliance_screening.liquid +0 -59
  53. package/.agent/cookbook/_fixtures/payments/_compliance_screenings_payments_mdm.liquid +0 -36
  54. package/.agent/cookbook/_fixtures/payments/_payment_accounts_payments_mdm.liquid +0 -30
  55. package/.agent/cookbook/_fixtures/payments/_payment_accounts_payments_payment_account.liquid +0 -55
  56. package/.agent/cookbook/_fixtures/subscription/_customers_subscription_mdm.liquid +0 -20
  57. package/.agent/cookbook/_setup/foundation.md +0 -359
  58. package/.agent/cookbook/_setup/healthcare.md +0 -361
  59. package/.agent/cookbook/_setup/payments.md +0 -365
  60. package/.agent/cookbook/_setup/subscription.md +0 -364
  61. package/.agent/cookbook/action-status-updaters.md +0 -278
  62. package/.agent/cookbook/ai-agent-invoke.md +0 -279
  63. package/.agent/cookbook/appointment-review-sms-workflow.md +0 -801
  64. package/.agent/cookbook/birthday-greeting-sms-trigger.md +0 -696
  65. package/.agent/cookbook/bulk-ingest.md +0 -302
  66. package/.agent/cookbook/contact-us-triage-with-llm.md +0 -663
  67. package/.agent/cookbook/dunning-sms-for-delinquent.md +0 -659
  68. package/.agent/cookbook/generic-tables.md +0 -244
  69. package/.agent/cookbook/invite-team.md +0 -200
  70. package/.agent/cookbook/kyc-notification-on-account-activation.md +0 -661
  71. package/.agent/cookbook/marketing-campaign-send.md +0 -1044
  72. package/.agent/cookbook/paginated-restapi-poller.md +0 -383
  73. package/.agent/cookbook/rest-fetch.md +0 -273
  74. package/.agent/cookbook/sanctions-screening-with-agent-review.md +0 -773
  75. package/.agent/cookbook/score-leads-with-llm-categorization.md +0 -665
  76. package/.agent/cookbook/system-templates.md +0 -165
  77. package/.agent/cookbook/talk-to-data.md +0 -178
  78. package/.agent/cookbook/triage-prospects-by-priority.md +0 -571
  79. package/.agent/cookbook/welcome-sms-for-customers.md +0 -647
  80. /package/.agent/cookbook/_fixtures/{healthcare → primary-care-feedback}/memorandum-of-association-01.png +0 -0
  81. /package/.agent/cookbook/_fixtures/{healthcare → primary-care-feedback}/sample_two_page.pdf +0 -0
  82. /package/.agent/cookbook/_fixtures/{subscription → subscription-saas}/_customers_subscription_customer.liquid +0 -0
  83. /package/.agent/cookbook/_fixtures/{subscription → subscription-saas}/stripe_customers_batch1.csv +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"platform-sdk.mjs","names":[],"sources":["../../src/llm-export.ts","../../src/bin/platform-sdk.ts"],"sourcesContent":["// Consumer-facing agent-docs injector — the SDK-bin home of\n// `llm-export`. Writes a managed block into <cwd>/AGENTS.md that POINTS\n// at this package's shipped `.agent/` corpus (predictable npm path), and\n// ensures <cwd>/CLAUDE.md imports AGENTS.md.\n//\n// This writer is DUPLICATED in the CLI (packages/cli/src/cli/llm-export.ts)\n// for the brew `alvera llm-export` path. The two copies must emit a\n// byte-identical block — `buildManagedBlock()` below is kept verbatim in\n// both, and each package snapshot-tests its own output (architecture-\n// decisions §2.10.13). They are not shared via import: the CLI's tsconfig\n// rootDir forbids importing SDK source, a public SDK export was rejected\n// to keep the surface lean (CLAUDE.md #6), and the sharing would be\n// throwaway under a future Go CLI anyway.\n//\n// Unlike the CLI copy, this one is a LIBRARY module: it throws on damaged\n// markers rather than calling process.exit — the bin entry catches and\n// exits.\nimport { existsSync, readFileSync, writeFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nconst MARKER_BEGIN = '<!-- @alvera-ai/platform-sdk:BEGIN -->'\nconst MARKER_END = '<!-- @alvera-ai/platform-sdk:END -->'\nconst CLAUDE_IMPORT_LINE = '@AGENTS.md'\nconst SDK_PACKAGE_NAME = '@alvera-ai/platform-sdk'\n\nexport interface LlmExportResult {\n agentsMdPath: string\n claudeMdPath: string\n managedBlockBytes: number\n claudeImportWritten: boolean\n}\n\n// Pure + deterministic. MUST stay byte-identical to the CLI copy's\n// buildManagedBlock (§2.10.13 drift guard).\nexport function buildManagedBlock(): string {\n const corpus = `node_modules/${SDK_PACKAGE_NAME}/.agent`\n const lines: string[] = [\n MARKER_BEGIN,\n '',\n '<!-- Managed by `alvera llm-export` — do not edit by hand. -->',\n '<!-- Re-running the command replaces only this block. -->',\n '',\n `## \\`${SDK_PACKAGE_NAME}\\` corpus`,\n '',\n 'The SDK ships an agent-docs corpus next to its npm install. Read the',\n 'corpus index first (Claude Code inlines this import):',\n '',\n `@${corpus}/AGENTS.md`,\n '',\n `Cookbook recipes live under \\`${corpus}/cookbook/\\`, indexed below —`,\n 'each recipe is anchored to a green end-to-end test and carries the',\n 'verified call sequence for one scenario. **Cookbook-first:** before',\n 'composing API calls for a scenario from primitives, start from the',\n 'closest recipe and diverge only with a stated reason.',\n '',\n '### Recipes by use case',\n '',\n '**Healthcare**',\n '',\n `- \\`${corpus}/cookbook/appointment-review-sms-workflow.md\\` — send a`,\n ' patient review-request SMS after a fulfilled appointment,',\n ' deep-linked to a connected-app feedback form.',\n `- \\`${corpus}/cookbook/contact-us-triage-with-llm.md\\` — triage inbound`,\n ' contact-us messages into three priority buckets (appointment /',\n ' job-application / spam) via an LLM agent, route each to a tailored',\n ' SMS action.',\n '',\n '**Subscription**',\n '',\n `- \\`${corpus}/cookbook/welcome-sms-for-customers.md\\` — send a welcome`,\n ' SMS to newly contracted customers with a self-serve billing-portal',\n ' link.',\n `- \\`${corpus}/cookbook/dunning-sms-for-delinquent.md\\` — send a`,\n ' payment-reminder SMS to delinquent customers (filtered on',\n ' phone-on-file and tax-id-verified) with a pay-invoice link.',\n `- \\`${corpus}/cookbook/triage-prospects-by-priority.md\\` — triage`,\n ' inbound AR customers into priority bands (high / medium / low) via',\n ' an LLM agent, route each band to a tailored SMS action.',\n '',\n '**Payments**',\n '',\n `- \\`${corpus}/cookbook/kyc-notification-on-account-activation.md\\` —`,\n ' send a KYC-notification SMS when a payment account transitions to',\n ' active status.',\n `- \\`${corpus}/cookbook/sanctions-screening-with-agent-review.md\\` —`,\n ' disambiguate gray-zone sanctions screenings via an LLM agent, route',\n ' confirmed-clean and confirmed-block outcomes to distinct SMS',\n ' actions.',\n '',\n '**Foundation**',\n '',\n `- \\`${corpus}/cookbook/birthday-greeting-sms-trigger.md\\` — send a`,\n \" happy-birthday SMS on each contact's next birthday using a\",\n ' pure-Liquid trigger (year-roll math).',\n `- \\`${corpus}/cookbook/score-leads-with-llm-categorization.md\\` — score`,\n ' inbound leads into four bands (hot / warm / cold / spam) via an LLM',\n ' agent, route each band to a tailored SMS action.',\n `- \\`${corpus}/cookbook/marketing-campaign-send.md\\` — send an A/B`,\n ' marketing campaign across SMS and email: the suppression and',\n ' reachability gates and the A/B split all live in the workflow, each',\n ' send carries a per-recipient short link, and the reply re-attaches',\n ' to the customer who sent it.',\n '',\n '### Top-3 consumer gotchas',\n '',\n '1. **`update()` replaces the whole resource.** There is no partial',\n ` update — resupply the full body. See \\`${corpus}/mutations.md\\`.`,\n '2. **Paginated catalogs return `{ data, meta }`.** Catalog endpoints',\n ' (`tools.list`, `dataSources.list`, etc.) wrap rows in `data` with a',\n ' `meta` envelope — destructure, do not iterate the response directly.',\n '3. **Resources are datalake-slug-scoped.** Every nested URL takes both',\n ' `tenantSlug` and `datalakeSlug` — never a single slug. The datalake',\n \" slug comes from the server (`api.datalakes.create`'s response).\",\n '',\n MARKER_END,\n ]\n return lines.join('\\n')\n}\n\nexport function upsertManagedBlock(target: string, block: string): string {\n const beginIdx = target.indexOf(MARKER_BEGIN)\n const endIdx = target.indexOf(MARKER_END)\n\n if (beginIdx === -1 && endIdx === -1) {\n const tail =\n target.length === 0\n ? ''\n : target.endsWith('\\n\\n')\n ? ''\n : target.endsWith('\\n')\n ? '\\n'\n : '\\n\\n'\n return target + tail + block + '\\n'\n }\n\n if (beginIdx === -1 || endIdx === -1 || endIdx < beginIdx) {\n throw new Error(\n `AGENTS.md: managed-block markers are damaged ` +\n `(BEGIN at ${beginIdx}, END at ${endIdx}). ` +\n `Fix by hand or remove both markers, then re-run llm-export.`,\n )\n }\n\n const before = target.slice(0, beginIdx)\n const after = target.slice(endIdx + MARKER_END.length)\n return before + block + after\n}\n\nexport function upsertClaudeImport(target: string): { next: string; written: boolean } {\n const already = target.split('\\n').some((line) => line.trim() === CLAUDE_IMPORT_LINE)\n if (already) return { next: target, written: false }\n const tail =\n target.length === 0\n ? ''\n : target.endsWith('\\n\\n')\n ? ''\n : target.endsWith('\\n')\n ? '\\n'\n : '\\n\\n'\n return { next: target + tail + CLAUDE_IMPORT_LINE + '\\n', written: true }\n}\n\nfunction readOrEmpty(path: string): string {\n return existsSync(path) ? readFileSync(path, 'utf8') : ''\n}\n\nexport function runLlmExport(cwd: string = process.cwd()): LlmExportResult {\n const block = buildManagedBlock()\n\n const agentsMdPath = join(cwd, 'AGENTS.md')\n writeFileSync(agentsMdPath, upsertManagedBlock(readOrEmpty(agentsMdPath), block), 'utf8')\n\n const claudeMdPath = join(cwd, 'CLAUDE.md')\n const { next: claudeAfter, written: claudeImportWritten } = upsertClaudeImport(\n readOrEmpty(claudeMdPath),\n )\n writeFileSync(claudeMdPath, claudeAfter, 'utf8')\n\n return {\n agentsMdPath,\n claudeMdPath,\n managedBlockBytes: block.length,\n claudeImportWritten,\n }\n}\n","#!/usr/bin/env node\n// The SDK's single bin (Stripe multi-subcommand pattern). Today the only\n// subcommand is `llm-export`, the consumer-facing agent-docs injector —\n// so an npm-only consumer runs `npx @alvera-ai/platform-sdk llm-export`\n// with no brew CLI install (architecture-decisions §2.10.13). The bin is\n// the ONLY thing reversed from inv #21; the SDK stays sub-export-less and\n// declares no postinstall.\nimport { runLlmExport } from '../llm-export.js'\n\nfunction usage(): void {\n process.stderr.write(\n 'Usage: npx @alvera-ai/platform-sdk <command>\\n\\n' +\n 'Commands:\\n' +\n ' llm-export Write a managed AGENTS.md block pointing at the\\n' +\n ' SDK agent-docs corpus in node_modules; ensure\\n' +\n ' CLAUDE.md imports AGENTS.md. Idempotent.\\n',\n )\n}\n\nfunction main(): void {\n const command = process.argv[2]\n\n if (command === undefined || command === '--help' || command === '-h') {\n usage()\n process.exit(command === undefined ? 1 : 0)\n }\n\n if (command === 'llm-export') {\n try {\n const result = runLlmExport(process.cwd())\n process.stderr.write(\n `✓ ${result.agentsMdPath} (${result.managedBlockBytes} bytes in managed block)\\n`,\n )\n process.stderr.write(\n `✓ ${result.claudeMdPath}` +\n `${result.claudeImportWritten ? ' (added @AGENTS.md import)' : ' (@AGENTS.md import already present)'}\\n`,\n )\n return\n } catch (err) {\n process.stderr.write(`llm-export failed: ${err instanceof Error ? err.message : String(err)}\\n`)\n process.exit(1)\n }\n }\n\n process.stderr.write(`unknown command \"${command}\".\\n\\n`)\n usage()\n process.exit(1)\n}\n\nmain()\n"],"mappings":";;;;;AAoBA,MAAM,eAAe;AACrB,MAAM,aAAa;AACnB,MAAM,qBAAqB;AAC3B,MAAM,mBAAmB;AAWzB,SAAgB,oBAA4B;CAC1C,MAAM,SAAS,gBAAgB,iBAAiB;AAiFhD,QAhFwB;EACtB;EACA;EACA;EACA;EACA;EACA,QAAQ,iBAAiB;EACzB;EACA;EACA;EACA;EACA,IAAI,OAAO;EACX;EACA,iCAAiC,OAAO;EACxC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OAAO,OAAO;EACd;EACA;EACA,OAAO,OAAO;EACd;EACA;EACA;EACA;EACA;EACA;EACA,OAAO,OAAO;EACd;EACA;EACA,OAAO,OAAO;EACd;EACA;EACA,OAAO,OAAO;EACd;EACA;EACA;EACA;EACA;EACA,OAAO,OAAO;EACd;EACA;EACA,OAAO,OAAO;EACd;EACA;EACA;EACA;EACA;EACA;EACA,OAAO,OAAO;EACd;EACA;EACA,OAAO,OAAO;EACd;EACA;EACA,OAAO,OAAO;EACd;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,6CAA6C,OAAO;EACpD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CACY,KAAK,KAAK;;AAGzB,SAAgB,mBAAmB,QAAgB,OAAuB;CACxE,MAAM,WAAW,OAAO,QAAQ,aAAa;CAC7C,MAAM,SAAS,OAAO,QAAQ,WAAW;AAEzC,KAAI,aAAa,MAAM,WAAW,GAShC,QAAO,UAPL,OAAO,WAAW,IACd,KACA,OAAO,SAAS,OAAO,GACrB,KACA,OAAO,SAAS,KAAK,GACnB,OACA,UACa,QAAQ;AAGjC,KAAI,aAAa,MAAM,WAAW,MAAM,SAAS,SAC/C,OAAM,IAAI,MACR,0DACe,SAAS,WAAW,OAAO,gEAE3C;CAGH,MAAM,SAAS,OAAO,MAAM,GAAG,SAAS;CACxC,MAAM,QAAQ,OAAO,MA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ACZ,UAAQ,OAAO,MAAM,sBAAsB,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,CAAC,IAAI;AAChG,UAAQ,KAAK,EAAE;;AAInB,SAAQ,OAAO,MAAM,oBAAoB,QAAQ,QAAQ;AACzD,QAAO;AACP,SAAQ,KAAK,EAAE;;AAGjB,MAAM"}
1
+ {"version":3,"file":"platform-sdk.mjs","names":[],"sources":["../../src/llm-export.ts","../../src/bin/platform-sdk.ts"],"sourcesContent":["// Consumer-facing agent-docs injector — the SDK-bin home of\n// `llm-export`. Writes a managed block into <cwd>/AGENTS.md that POINTS\n// at this package's shipped `.agent/` corpus (predictable npm path), and\n// ensures <cwd>/CLAUDE.md imports AGENTS.md.\n//\n// This writer is DUPLICATED in the CLI (packages/cli/src/cli/llm-export.ts)\n// for the brew `alvera llm-export` path. The two copies must emit a\n// byte-identical block — `buildManagedBlock()` below is kept verbatim in\n// both, and each package snapshot-tests its own output (architecture-\n// decisions §2.10.13). They are not shared via import: the CLI's tsconfig\n// rootDir forbids importing SDK source, a public SDK export was rejected\n// to keep the surface lean (CLAUDE.md #6), and the sharing would be\n// throwaway under a future Go CLI anyway.\n//\n// Unlike the CLI copy, this one is a LIBRARY module: it throws on damaged\n// markers rather than calling process.exit — the bin entry catches and\n// exits.\nimport { existsSync, readFileSync, writeFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nconst MARKER_BEGIN = '<!-- @alvera-ai/platform-sdk:BEGIN -->'\nconst MARKER_END = '<!-- @alvera-ai/platform-sdk:END -->'\nconst CLAUDE_IMPORT_LINE = '@AGENTS.md'\nconst SDK_PACKAGE_NAME = '@alvera-ai/platform-sdk'\n\nexport interface LlmExportResult {\n agentsMdPath: string\n claudeMdPath: string\n managedBlockBytes: number\n claudeImportWritten: boolean\n}\n\n// Pure + deterministic. MUST stay byte-identical to the CLI copy's\n// buildManagedBlock (§2.10.13 drift guard).\nexport function buildManagedBlock(): string {\n const corpus = `node_modules/${SDK_PACKAGE_NAME}/.agent`\n const lines: string[] = [\n MARKER_BEGIN,\n '',\n '<!-- Managed by `alvera llm-export` — do not edit by hand. -->',\n '<!-- Re-running the command replaces only this block. -->',\n '',\n `## \\`${SDK_PACKAGE_NAME}\\` corpus`,\n '',\n 'The SDK ships an agent-docs corpus next to its npm install. Read the',\n 'corpus index first (Claude Code inlines this import):',\n '',\n `@${corpus}/AGENTS.md`,\n '',\n `Cookbook recipes live under \\`${corpus}/cookbook/\\`, indexed below —`,\n 'each recipe is anchored to a green end-to-end test and carries the',\n 'verified call sequence for one scenario. **Cookbook-first:** before',\n 'composing API calls for a scenario from primitives, start from the',\n 'closest recipe and diverge only with a stated reason.',\n '',\n '### The four cookbooks',\n '',\n 'One per use case. Each stands up its own tenant, datalake and',\n 'resources and shares nothing with the others — read one end to end',\n 'and you need no second file. Duplication between them is deliberate.',\n '',\n `- \\`${corpus}/cookbook/organic-marketing.md\\` — score inbound leads`,\n ' into four bands with an LLM agent, schedule a birthday greeting a',\n ' year out with a pure-Liquid trigger, and run an A/B campaign whose',\n ' suppression gates and split live in the workflow. Ends with',\n ' delivery reconciliation and a natural-language read of the lake.',\n ' One raw datalake.',\n `- \\`${corpus}/cookbook/payments-compliance.md\\` — disambiguate`,\n ' gray-zone sanctions screenings with an LLM agent that never sees',\n ' who was screened, and fire a KYC notification on account',\n ' activation. Ends by reading one row through raw, tokenized and',\n ' redacted to show what each reader gets. Three datalakes.',\n `- \\`${corpus}/cookbook/subscription-saas.md\\` — one customers table`,\n ' and three workflows over it: a welcome SMS gated on reachability,',\n ' a dunning reminder gated on reachability AND KYC, and an LLM agent',\n ' banding accounts by priority. Then the same table filled three',\n ' more ways — inline, bulk CSV, REST fetch — and a teammate invited',\n ' onto the tenant. One raw datalake.',\n `- \\`${corpus}/cookbook/primary-care.md\\` — a review request that only`,\n ' reaches patients whose visit actually happened, an LLM agent',\n ' triaging inbound messages off the tokenized projection, and a',\n ' vision agent reading a scanned document. Three datalakes.',\n '',\n '**Capabilities are inside the cookbooks, not beside them.** Bulk',\n 'upload, REST fetch, team invitations, action status updaters,',\n 'paginated pollers, text-to-SQL and agent file-invocation each live in',\n 'the cookbook whose use case motivates them, as numbered steps. There',\n 'is no separate per-capability file to consult.',\n '',\n '### Top-3 consumer gotchas',\n '',\n '1. **`update()` replaces the whole resource.** There is no partial',\n ` update — resupply the full body. See \\`${corpus}/mutations.md\\`.`,\n '2. **Paginated catalogs return `{ data, meta }`.** Catalog endpoints',\n ' (`tools.list`, `dataSources.list`, etc.) wrap rows in `data` with a',\n ' `meta` envelope — destructure, do not iterate the response directly.',\n '3. **Resources are datalake-slug-scoped.** Every nested URL takes both',\n ' `tenantSlug` and `datalakeSlug` — never a single slug. The datalake',\n \" slug comes from the server (`api.datalakes.create`'s response).\",\n '',\n MARKER_END,\n ]\n return lines.join('\\n')\n}\n\nexport function upsertManagedBlock(target: string, block: string): string {\n const beginIdx = target.indexOf(MARKER_BEGIN)\n const endIdx = target.indexOf(MARKER_END)\n\n if (beginIdx === -1 && endIdx === -1) {\n const tail =\n target.length === 0\n ? ''\n : target.endsWith('\\n\\n')\n ? ''\n : target.endsWith('\\n')\n ? '\\n'\n : '\\n\\n'\n return target + tail + block + '\\n'\n }\n\n if (beginIdx === -1 || endIdx === -1 || endIdx < beginIdx) {\n throw new Error(\n `AGENTS.md: managed-block markers are damaged ` +\n `(BEGIN at ${beginIdx}, END at ${endIdx}). ` +\n `Fix by hand or remove both markers, then re-run llm-export.`,\n )\n }\n\n const before = target.slice(0, beginIdx)\n const after = target.slice(endIdx + MARKER_END.length)\n return before + block + after\n}\n\nexport function upsertClaudeImport(target: string): { next: string; written: boolean } {\n const already = target.split('\\n').some((line) => line.trim() === CLAUDE_IMPORT_LINE)\n if (already) return { next: target, written: false }\n const tail =\n target.length === 0\n ? ''\n : target.endsWith('\\n\\n')\n ? ''\n : target.endsWith('\\n')\n ? '\\n'\n : '\\n\\n'\n return { next: target + tail + CLAUDE_IMPORT_LINE + '\\n', written: true }\n}\n\nfunction readOrEmpty(path: string): string {\n return existsSync(path) ? readFileSync(path, 'utf8') : ''\n}\n\nexport function runLlmExport(cwd: string = process.cwd()): LlmExportResult {\n const block = buildManagedBlock()\n\n const agentsMdPath = join(cwd, 'AGENTS.md')\n writeFileSync(agentsMdPath, upsertManagedBlock(readOrEmpty(agentsMdPath), block), 'utf8')\n\n const claudeMdPath = join(cwd, 'CLAUDE.md')\n const { next: claudeAfter, written: claudeImportWritten } = upsertClaudeImport(\n readOrEmpty(claudeMdPath),\n )\n writeFileSync(claudeMdPath, claudeAfter, 'utf8')\n\n return {\n agentsMdPath,\n claudeMdPath,\n managedBlockBytes: block.length,\n claudeImportWritten,\n }\n}\n","#!/usr/bin/env node\n// The SDK's single bin (Stripe multi-subcommand pattern). Today the only\n// subcommand is `llm-export`, the consumer-facing agent-docs injector —\n// so an npm-only consumer runs `npx @alvera-ai/platform-sdk llm-export`\n// with no brew CLI install (architecture-decisions §2.10.13). The bin is\n// the ONLY thing reversed from inv #21; the SDK stays sub-export-less and\n// declares no postinstall.\nimport { runLlmExport } from '../llm-export.js'\n\nfunction usage(): void {\n process.stderr.write(\n 'Usage: npx @alvera-ai/platform-sdk <command>\\n\\n' +\n 'Commands:\\n' +\n ' llm-export Write a managed AGENTS.md block pointing at the\\n' +\n ' SDK agent-docs corpus in node_modules; ensure\\n' +\n ' CLAUDE.md imports AGENTS.md. Idempotent.\\n',\n )\n}\n\nfunction main(): void {\n const command = process.argv[2]\n\n if (command === undefined || command === '--help' || command === '-h') {\n usage()\n process.exit(command === undefined ? 1 : 0)\n }\n\n if (command === 'llm-export') {\n try {\n const result = runLlmExport(process.cwd())\n process.stderr.write(\n `✓ ${result.agentsMdPath} (${result.managedBlockBytes} bytes in managed block)\\n`,\n )\n process.stderr.write(\n `✓ ${result.claudeMdPath}` +\n `${result.claudeImportWritten ? ' (added @AGENTS.md import)' : ' (@AGENTS.md import already present)'}\\n`,\n )\n return\n } catch (err) {\n process.stderr.write(`llm-export failed: ${err instanceof Error ? err.message : String(err)}\\n`)\n process.exit(1)\n }\n }\n\n process.stderr.write(`unknown command \"${command}\".\\n\\n`)\n usage()\n process.exit(1)\n}\n\nmain()\n"],"mappings":";;;;;AAoBA,MAAM,eAAe;AACrB,MAAM,aAAa;AACnB,MAAM,qBAAqB;AAC3B,MAAM,mBAAmB;AAWzB,SAAgB,oBAA4B;CAC1C,MAAM,SAAS,gBAAgB,iBAAiB;AAmEhD,QAlEwB;EACtB;EACA;EACA;EACA;EACA;EACA,QAAQ,iBAAiB;EACzB;EACA;EACA;EACA;EACA,IAAI,OAAO;EACX;EACA,iCAAiC,OAAO;EACxC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OAAO,OAAO;EACd;EACA;EACA;EACA;EACA;EACA,OAAO,OAAO;EACd;EACA;EACA;EACA;EACA,OAAO,OAAO;EACd;EACA;EACA;EACA;EACA;EACA,OAAO,OAAO;EACd;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,6CAA6C,OAAO;EACpD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CACY,KAAK,KAAK;;AAGzB,SAAgB,mBAAmB,QAAgB,OAAuB;CACxE,MAAM,WAAW,OAAO,QAAQ,aAAa;CAC7C,MAAM,SAAS,OAAO,QAAQ,WAAW;AAEzC,KAAI,aAAa,MAAM,WAAW,GAShC,QAAO,UAPL,OAAO,WAAW,IACd,KACA,OAAO,SAAS,OAAO,GACrB,KACA,OAAO,SAAS,KAAK,GACnB,OACA,UACa,QAAQ;AAGjC,KAAI,aAAa,MAAM,WAAW,MAAM,SAAS,SAC/C,OAAM,IAAI,MACR,0DACe,SAAS,WAAW,OAAO,gEAE3C;CAGH,MAAM,SAAS,OAAO,MAAM,GAAG,SAAS;CACxC,MAAM,QAAQ,OAAO,MAAM,SAAS,GAAkB;AACtD,QAAO,SAAS,QAAQ;;AAG1B,SAAgB,mBAAmB,QAAoD;AAErF,KADgB,OAAO,MAAM,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