@alvera-ai/platform-sdk 0.10.0-rc.2 → 0.10.0-rc.21

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 (55) hide show
  1. package/.agent/AGENTS.md +440 -0
  2. package/.agent/account_management.md +455 -0
  3. package/.agent/action_status_updaters.md +262 -0
  4. package/.agent/ai_agents.md +423 -0
  5. package/.agent/ai_sandbox.md +265 -0
  6. package/.agent/async.md +111 -0
  7. package/.agent/connected_apps.md +407 -0
  8. package/.agent/cookbook/_fixtures/README.md +99 -0
  9. package/.agent/cookbook/_fixtures/accounts_receivable/_customers_accounts_receivable_customer.liquid +32 -0
  10. package/.agent/cookbook/_fixtures/accounts_receivable/_customers_accounts_receivable_mdm.liquid +20 -0
  11. package/.agent/cookbook/_fixtures/foundation/_lead_submissions_foundation_generic_table.liquid +33 -0
  12. package/.agent/cookbook/_fixtures/foundation/_lead_submissions_foundation_legal_entity.liquid +88 -0
  13. package/.agent/cookbook/_fixtures/foundation/_lead_submissions_foundation_mdm.liquid +48 -0
  14. package/.agent/cookbook/_fixtures/healthcare/_cahps_appointments_healthcare_appointment.liquid +47 -0
  15. package/.agent/cookbook/_fixtures/healthcare/_cahps_appointments_healthcare_mdm.liquid +24 -0
  16. package/.agent/cookbook/_fixtures/healthcare/_cahps_appointments_healthcare_patient.liquid +38 -0
  17. package/.agent/cookbook/_fixtures/payment_risk/_compliance_screenings_payment_risk_compliance_screening.liquid +59 -0
  18. package/.agent/cookbook/_fixtures/payment_risk/_compliance_screenings_payment_risk_mdm.liquid +36 -0
  19. package/.agent/cookbook/_fixtures/payment_risk/_payment_accounts_payment_risk_mdm.liquid +30 -0
  20. package/.agent/cookbook/_fixtures/payment_risk/_payment_accounts_payment_risk_payment_account.liquid +55 -0
  21. package/.agent/cookbook/_setup/accounts_receivable.md +282 -0
  22. package/.agent/cookbook/_setup/foundation.md +277 -0
  23. package/.agent/cookbook/_setup/healthcare.md +279 -0
  24. package/.agent/cookbook/_setup/payment_risk.md +283 -0
  25. package/.agent/cookbook/appointment-review-sms-workflow.md +761 -0
  26. package/.agent/cookbook/birthday-greeting-sms-trigger.md +656 -0
  27. package/.agent/cookbook/contact-us-triage-with-llm.md +603 -0
  28. package/.agent/cookbook/dunning-sms-for-delinquent.md +619 -0
  29. package/.agent/cookbook/kyc-notification-on-account-activation.md +619 -0
  30. package/.agent/cookbook/sanctions-screening-with-agent-review.md +711 -0
  31. package/.agent/cookbook/score-leads-with-llm-categorization.md +602 -0
  32. package/.agent/cookbook/welcome-sms-for-customers.md +607 -0
  33. package/.agent/data_activation_clients.md +557 -0
  34. package/.agent/data_sources.md +234 -0
  35. package/.agent/datalakes.md +712 -0
  36. package/.agent/debugging.md +137 -0
  37. package/.agent/errors.md +196 -0
  38. package/.agent/generic_tables.md +351 -0
  39. package/.agent/interoperability_contracts.md +351 -0
  40. package/.agent/mdm.md +293 -0
  41. package/.agent/mutations.md +152 -0
  42. package/.agent/templates.md +98 -0
  43. package/.agent/tool-call-configs.md +90 -0
  44. package/.agent/tools.md +546 -0
  45. package/.agent/type_naming.md +131 -0
  46. package/.agent/workflows.md +601 -0
  47. package/README.md +46 -0
  48. package/dist/bin/platform-sdk.d.mts +1 -0
  49. package/dist/bin/platform-sdk.mjs +106 -0
  50. package/dist/bin/platform-sdk.mjs.map +1 -0
  51. package/dist/index.d.mts +1200 -43201
  52. package/dist/index.d.mts.map +1 -1
  53. package/dist/index.mjs +1859 -7319
  54. package/dist/index.mjs.map +1 -1
  55. package/package.json +19 -10
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env node
2
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { join } from "node:path";
4
+
5
+ //#region src/llm-export.ts
6
+ const MARKER_BEGIN = "<!-- @alvera-ai/platform-sdk:BEGIN -->";
7
+ const MARKER_END = "<!-- @alvera-ai/platform-sdk:END -->";
8
+ const CLAUDE_IMPORT_LINE = "@AGENTS.md";
9
+ const SDK_PACKAGE_NAME = "@alvera-ai/platform-sdk";
10
+ function buildManagedBlock() {
11
+ const corpus = `node_modules/${SDK_PACKAGE_NAME}/.agent`;
12
+ return [
13
+ MARKER_BEGIN,
14
+ "",
15
+ "<!-- Managed by `alvera llm-export` — do not edit by hand. -->",
16
+ "<!-- Re-running the command replaces only this block. -->",
17
+ "",
18
+ `## \`${SDK_PACKAGE_NAME}\` corpus`,
19
+ "",
20
+ "The SDK ships an agent-docs corpus next to its npm install. Read the",
21
+ "corpus index first (Claude Code inlines this import):",
22
+ "",
23
+ `@${corpus}/AGENTS.md`,
24
+ "",
25
+ `Cookbook recipes live under \`${corpus}/cookbook/\`.`,
26
+ "",
27
+ "### Top-3 consumer gotchas",
28
+ "",
29
+ "1. **Updates use PUT, not PATCH.** The SDK exposes no PATCH method;",
30
+ ` mutations replace the resource whole. See \`${corpus}/mutations.md\`.`,
31
+ "2. **Paginated catalogs return `{ data, meta }`.** Catalog endpoints",
32
+ " (`tools.list`, `dataSources.list`, etc.) wrap rows in `data` with a",
33
+ " `meta` envelope — destructure, do not iterate the response directly.",
34
+ "3. **Resources are datalake-slug-scoped.** Every nested URL takes both",
35
+ " `tenantSlug` and `datalakeSlug` — never a single slug. The datalake",
36
+ " slug comes from the server (`api.datalakes.create`'s response).",
37
+ "",
38
+ MARKER_END
39
+ ].join("\n");
40
+ }
41
+ function upsertManagedBlock(target, block) {
42
+ const beginIdx = target.indexOf(MARKER_BEGIN);
43
+ const endIdx = target.indexOf(MARKER_END);
44
+ if (beginIdx === -1 && endIdx === -1) return target + (target.length === 0 ? "" : target.endsWith("\n\n") ? "" : target.endsWith("\n") ? "\n" : "\n\n") + block + "\n";
45
+ if (beginIdx === -1 || endIdx === -1 || endIdx < beginIdx) throw new Error(`AGENTS.md: managed-block markers are damaged (BEGIN at ${beginIdx}, END at ${endIdx}). Fix by hand or remove both markers, then re-run llm-export.`);
46
+ const before = target.slice(0, beginIdx);
47
+ const after = target.slice(endIdx + 36);
48
+ return before + block + after;
49
+ }
50
+ function upsertClaudeImport(target) {
51
+ if (target.split("\n").some((line) => line.trim() === CLAUDE_IMPORT_LINE)) return {
52
+ next: target,
53
+ written: false
54
+ };
55
+ return {
56
+ next: target + (target.length === 0 ? "" : target.endsWith("\n\n") ? "" : target.endsWith("\n") ? "\n" : "\n\n") + CLAUDE_IMPORT_LINE + "\n",
57
+ written: true
58
+ };
59
+ }
60
+ function readOrEmpty(path) {
61
+ return existsSync(path) ? readFileSync(path, "utf8") : "";
62
+ }
63
+ function runLlmExport(cwd = process.cwd()) {
64
+ const block = buildManagedBlock();
65
+ const agentsMdPath = join(cwd, "AGENTS.md");
66
+ writeFileSync(agentsMdPath, upsertManagedBlock(readOrEmpty(agentsMdPath), block), "utf8");
67
+ const claudeMdPath = join(cwd, "CLAUDE.md");
68
+ const { next: claudeAfter, written: claudeImportWritten } = upsertClaudeImport(readOrEmpty(claudeMdPath));
69
+ writeFileSync(claudeMdPath, claudeAfter, "utf8");
70
+ return {
71
+ agentsMdPath,
72
+ claudeMdPath,
73
+ managedBlockBytes: block.length,
74
+ claudeImportWritten
75
+ };
76
+ }
77
+
78
+ //#endregion
79
+ //#region src/bin/platform-sdk.ts
80
+ function usage() {
81
+ process.stderr.write("Usage: npx @alvera-ai/platform-sdk <command>\n\nCommands:\n llm-export Write a managed AGENTS.md block pointing at the\n SDK agent-docs corpus in node_modules; ensure\n CLAUDE.md imports AGENTS.md. Idempotent.\n");
82
+ }
83
+ function main() {
84
+ const command = process.argv[2];
85
+ if (command === void 0 || command === "--help" || command === "-h") {
86
+ usage();
87
+ process.exit(command === void 0 ? 1 : 0);
88
+ }
89
+ if (command === "llm-export") try {
90
+ const result = runLlmExport(process.cwd());
91
+ process.stderr.write(`✓ ${result.agentsMdPath} (${result.managedBlockBytes} bytes in managed block)\n`);
92
+ process.stderr.write(`✓ ${result.claudeMdPath}${result.claudeImportWritten ? " (added @AGENTS.md import)" : " (@AGENTS.md import already present)"}\n`);
93
+ return;
94
+ } catch (err) {
95
+ process.stderr.write(`llm-export failed: ${err instanceof Error ? err.message : String(err)}\n`);
96
+ process.exit(1);
97
+ }
98
+ process.stderr.write(`unknown command "${command}".\n\n`);
99
+ usage();
100
+ process.exit(1);
101
+ }
102
+ main();
103
+
104
+ //#endregion
105
+ export { };
106
+ //# sourceMappingURL=platform-sdk.mjs.map
@@ -0,0 +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/\\`.`,\n '',\n '### Top-3 consumer gotchas',\n '',\n '1. **Updates use PUT, not PATCH.** The SDK exposes no PATCH method;',\n ` mutations replace the resource whole. 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;AA6BhD,QA5BwB;EACtB;EACA;EACA;EACA;EACA;EACA,QAAQ,iBAAiB;EACzB;EACA;EACA;EACA;EACA,IAAI,OAAO;EACX;EACA,iCAAiC,OAAO;EACxC;EACA;EACA;EACA;EACA,kDAAkD,OAAO;EACzD;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,KAAK,CAAC,MAAM,SAAS,KAAK,MAAM,KAAK,mBAAm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