@recombine-ai/platform 0.3.0 → 0.4.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 (155) hide show
  1. package/README.md +1 -1
  2. package/build/bosun-app/frontend/client/_app/immutable/chunks/{B8q_gCwD.js → BEtU89l8.js} +1 -1
  3. package/build/bosun-app/frontend/client/_app/immutable/chunks/BEtU89l8.js.br +0 -0
  4. package/build/bosun-app/frontend/client/_app/immutable/chunks/BEtU89l8.js.gz +0 -0
  5. package/build/bosun-app/frontend/client/_app/immutable/chunks/{BOiOqwrA.js → BOj6p3qj.js} +1 -1
  6. package/build/bosun-app/frontend/client/_app/immutable/chunks/BOj6p3qj.js.br +0 -0
  7. package/build/bosun-app/frontend/client/_app/immutable/chunks/BOj6p3qj.js.gz +0 -0
  8. package/build/bosun-app/frontend/client/_app/immutable/chunks/{DGc0An5V.js → BVp4hYzT.js} +1 -1
  9. package/build/bosun-app/frontend/client/_app/immutable/chunks/BVp4hYzT.js.br +0 -0
  10. package/build/bosun-app/frontend/client/_app/immutable/chunks/BVp4hYzT.js.gz +0 -0
  11. package/build/bosun-app/frontend/client/_app/immutable/chunks/{BKW04JRY.js → CNWRsnQ2.js} +1 -1
  12. package/build/bosun-app/frontend/client/_app/immutable/chunks/CNWRsnQ2.js.br +0 -0
  13. package/build/bosun-app/frontend/client/_app/immutable/chunks/CNWRsnQ2.js.gz +0 -0
  14. package/build/bosun-app/frontend/client/_app/immutable/chunks/{BUkXSKT3.js → zpyNGpfC.js} +1 -1
  15. package/build/bosun-app/frontend/client/_app/immutable/chunks/zpyNGpfC.js.br +0 -0
  16. package/build/bosun-app/frontend/client/_app/immutable/chunks/zpyNGpfC.js.gz +0 -0
  17. package/build/bosun-app/frontend/client/_app/immutable/entry/{app.Bni-2yHM.js → app.DJfhEB0w.js} +2 -2
  18. package/build/bosun-app/frontend/client/_app/immutable/entry/app.DJfhEB0w.js.br +0 -0
  19. package/build/bosun-app/frontend/client/_app/immutable/entry/app.DJfhEB0w.js.gz +0 -0
  20. package/build/bosun-app/frontend/client/_app/immutable/entry/start.CvCep2Ct.js +1 -0
  21. package/build/bosun-app/frontend/client/_app/immutable/entry/start.CvCep2Ct.js.br +0 -0
  22. package/build/bosun-app/frontend/client/_app/immutable/entry/start.CvCep2Ct.js.gz +0 -0
  23. package/build/bosun-app/frontend/client/_app/immutable/nodes/{0.CyFCeOko.js → 0.BrSNCmq3.js} +1 -1
  24. package/build/bosun-app/frontend/client/_app/immutable/nodes/0.BrSNCmq3.js.br +0 -0
  25. package/build/bosun-app/frontend/client/_app/immutable/nodes/0.BrSNCmq3.js.gz +0 -0
  26. package/build/bosun-app/frontend/client/_app/immutable/nodes/{1.D9Za90TC.js → 1.br7GI-g3.js} +1 -1
  27. package/build/bosun-app/frontend/client/_app/immutable/nodes/1.br7GI-g3.js.br +0 -0
  28. package/build/bosun-app/frontend/client/_app/immutable/nodes/1.br7GI-g3.js.gz +0 -0
  29. package/build/bosun-app/frontend/client/_app/immutable/nodes/{10.CQP8ZYdc.js → 10.BI2Z0Is-.js} +1 -1
  30. package/build/bosun-app/frontend/client/_app/immutable/nodes/10.BI2Z0Is-.js.br +0 -0
  31. package/build/bosun-app/frontend/client/_app/immutable/nodes/10.BI2Z0Is-.js.gz +0 -0
  32. package/build/bosun-app/frontend/client/_app/immutable/nodes/{17.C-6g-4TG.js → 17.BpaLQSZh.js} +1 -1
  33. package/build/bosun-app/frontend/client/_app/immutable/nodes/17.BpaLQSZh.js.br +0 -0
  34. package/build/bosun-app/frontend/client/_app/immutable/nodes/17.BpaLQSZh.js.gz +0 -0
  35. package/build/bosun-app/frontend/client/_app/immutable/nodes/{18.CKu_cfLu.js → 18.CYbvSJai.js} +1 -1
  36. package/build/bosun-app/frontend/client/_app/immutable/nodes/18.CYbvSJai.js.br +0 -0
  37. package/build/bosun-app/frontend/client/_app/immutable/nodes/18.CYbvSJai.js.gz +0 -0
  38. package/build/bosun-app/frontend/client/_app/immutable/nodes/{2.lZxPEqtw.js → 2.BYBSEm-Y.js} +1 -1
  39. package/build/bosun-app/frontend/client/_app/immutable/nodes/2.BYBSEm-Y.js.br +0 -0
  40. package/build/bosun-app/frontend/client/_app/immutable/nodes/{2.lZxPEqtw.js.gz → 2.BYBSEm-Y.js.gz} +0 -0
  41. package/build/bosun-app/frontend/client/_app/immutable/nodes/{3.BjH4Ma-k.js → 3.BuP4tAto.js} +1 -1
  42. package/build/bosun-app/frontend/client/_app/immutable/nodes/3.BuP4tAto.js.br +0 -0
  43. package/build/bosun-app/frontend/client/_app/immutable/nodes/3.BuP4tAto.js.gz +0 -0
  44. package/build/bosun-app/frontend/client/_app/immutable/nodes/{4.B_swg0wq.js → 4.Dlg932RB.js} +1 -1
  45. package/build/bosun-app/frontend/client/_app/immutable/nodes/4.Dlg932RB.js.br +0 -0
  46. package/build/bosun-app/frontend/client/_app/immutable/nodes/4.Dlg932RB.js.gz +0 -0
  47. package/build/bosun-app/frontend/client/_app/immutable/nodes/{5.CJfS926N.js → 5.BWt6bVnz.js} +1 -1
  48. package/build/bosun-app/frontend/client/_app/immutable/nodes/5.BWt6bVnz.js.br +0 -0
  49. package/build/bosun-app/frontend/client/_app/immutable/nodes/5.BWt6bVnz.js.gz +0 -0
  50. package/build/bosun-app/frontend/client/_app/immutable/nodes/{6.4aRjHu4u.js → 6.DL1bd1xV.js} +1 -1
  51. package/build/bosun-app/frontend/client/_app/immutable/nodes/6.DL1bd1xV.js.br +0 -0
  52. package/build/bosun-app/frontend/client/_app/immutable/nodes/6.DL1bd1xV.js.gz +0 -0
  53. package/build/bosun-app/frontend/client/_app/immutable/nodes/{8.BZFIHe4g.js → 8.BJXaarvf.js} +1 -1
  54. package/build/bosun-app/frontend/client/_app/immutable/nodes/8.BJXaarvf.js.br +0 -0
  55. package/build/bosun-app/frontend/client/_app/immutable/nodes/8.BJXaarvf.js.gz +0 -0
  56. package/build/bosun-app/frontend/client/_app/immutable/nodes/{9.BYJRzNt4.js → 9.DZnil4g8.js} +1 -1
  57. package/build/bosun-app/frontend/client/_app/immutable/nodes/9.DZnil4g8.js.br +0 -0
  58. package/build/bosun-app/frontend/client/_app/immutable/nodes/9.DZnil4g8.js.gz +0 -0
  59. package/build/bosun-app/frontend/client/_app/version.json +1 -1
  60. package/build/bosun-app/frontend/client/_app/version.json.br +0 -0
  61. package/build/bosun-app/frontend/client/_app/version.json.gz +0 -0
  62. package/build/bosun-app/frontend/handler.js +4 -4
  63. package/build/bosun-app/frontend/index.js +4 -4
  64. package/build/bosun-app/frontend/server/chunks/chunks/{internal.js-V8Wfo1-F.js → internal.js-Bu4L_cnE.js} +2 -2
  65. package/build/bosun-app/frontend/server/chunks/chunks/{internal.js-V8Wfo1-F.js.map → internal.js-Bu4L_cnE.js.map} +1 -1
  66. package/build/bosun-app/frontend/server/chunks/{handler-I7zF-fv9.js → handler-Caqo1h-B.js} +3 -3
  67. package/build/bosun-app/frontend/server/chunks/{handler-I7zF-fv9.js.map → handler-Caqo1h-B.js.map} +1 -1
  68. package/build/bosun-app/frontend/server/chunks/{index.js-Ca0Ef2Tt.js → index.js-B6JFIJIn.js} +2 -2
  69. package/build/bosun-app/frontend/server/chunks/{index.js-Ca0Ef2Tt.js.map → index.js-B6JFIJIn.js.map} +1 -1
  70. package/build/bosun-app/frontend/server/chunks/{manifest.js-D22OChaf.js → manifest.js-BQmpznei.js} +14 -14
  71. package/build/bosun-app/frontend/server/chunks/{manifest.js-D22OChaf.js.map → manifest.js-BQmpznei.js.map} +1 -1
  72. package/build/bosun-app/frontend/server/chunks/nodes/{0.js-CoDyOiLt.js → 0.js-DFPCfgZg.js} +2 -2
  73. package/build/bosun-app/frontend/server/chunks/nodes/{0.js-CoDyOiLt.js.map → 0.js-DFPCfgZg.js.map} +1 -1
  74. package/build/bosun-app/frontend/server/chunks/nodes/{1.js-BesNpd2w.js → 1.js-BujyKhW9.js} +2 -2
  75. package/build/bosun-app/frontend/server/chunks/nodes/{1.js-BesNpd2w.js.map → 1.js-BujyKhW9.js.map} +1 -1
  76. package/build/bosun-app/frontend/server/chunks/nodes/{10.js-DN5elTKV.js → 10.js-Dbiu4FpX.js} +2 -2
  77. package/build/bosun-app/frontend/server/chunks/nodes/{10.js-DN5elTKV.js.map → 10.js-Dbiu4FpX.js.map} +1 -1
  78. package/build/bosun-app/frontend/server/chunks/nodes/{17.js-DExEAB_e.js → 17.js-9Acvxo6X.js} +2 -2
  79. package/build/bosun-app/frontend/server/chunks/nodes/{17.js-DExEAB_e.js.map → 17.js-9Acvxo6X.js.map} +1 -1
  80. package/build/bosun-app/frontend/server/chunks/nodes/{18.js-OLWFvVu0.js → 18.js-D294qrHb.js} +2 -2
  81. package/build/bosun-app/frontend/server/chunks/nodes/{18.js-OLWFvVu0.js.map → 18.js-D294qrHb.js.map} +1 -1
  82. package/build/bosun-app/frontend/server/chunks/nodes/{2.js-DdMhYSQT.js → 2.js-DiVDZRco.js} +2 -2
  83. package/build/bosun-app/frontend/server/chunks/nodes/{2.js-DdMhYSQT.js.map → 2.js-DiVDZRco.js.map} +1 -1
  84. package/build/bosun-app/frontend/server/chunks/nodes/{3.js-DRo_79wF.js → 3.js-DiaPSM0a.js} +2 -2
  85. package/build/bosun-app/frontend/server/chunks/nodes/{3.js-DRo_79wF.js.map → 3.js-DiaPSM0a.js.map} +1 -1
  86. package/build/bosun-app/frontend/server/chunks/nodes/{4.js-Bb8ZnG8K.js → 4.js-DQhC-gZ_.js} +2 -2
  87. package/build/bosun-app/frontend/server/chunks/nodes/{4.js-Bb8ZnG8K.js.map → 4.js-DQhC-gZ_.js.map} +1 -1
  88. package/build/bosun-app/frontend/server/chunks/nodes/{5.js-DNbqpjRZ.js → 5.js-C3vjOcSE.js} +2 -2
  89. package/build/bosun-app/frontend/server/chunks/nodes/{5.js-DNbqpjRZ.js.map → 5.js-C3vjOcSE.js.map} +1 -1
  90. package/build/bosun-app/frontend/server/chunks/nodes/{6.js-MMZWg86o.js → 6.js-DpCeETlI.js} +2 -2
  91. package/build/bosun-app/frontend/server/chunks/nodes/{6.js-MMZWg86o.js.map → 6.js-DpCeETlI.js.map} +1 -1
  92. package/build/bosun-app/frontend/server/chunks/nodes/{8.js-Cs981zJ4.js → 8.js-BjNCuX0D.js} +2 -2
  93. package/build/bosun-app/frontend/server/chunks/nodes/{8.js-Cs981zJ4.js.map → 8.js-BjNCuX0D.js.map} +1 -1
  94. package/build/bosun-app/frontend/server/chunks/nodes/{9.js-h4jeZZT-.js → 9.js-BuUuEII0.js} +2 -2
  95. package/build/bosun-app/frontend/server/chunks/nodes/{9.js-h4jeZZT-.js.map → 9.js-BuUuEII0.js.map} +1 -1
  96. package/build/build/build.d.ts +3 -0
  97. package/build/build/build.d.ts.map +1 -0
  98. package/build/build/build.js +71 -0
  99. package/build/build/cli.d.ts +2 -11
  100. package/build/build/cli.d.ts.map +1 -1
  101. package/build/build/cli.js +19 -81
  102. package/build/build/common.d.ts +5 -9
  103. package/build/build/common.d.ts.map +1 -1
  104. package/build/build/common.js +119 -40
  105. package/build/build/config.d.ts +9 -0
  106. package/build/build/config.d.ts.map +1 -0
  107. package/build/build/config.js +24 -0
  108. package/build/build/index.d.ts +4 -6
  109. package/build/build/index.d.ts.map +1 -1
  110. package/build/build/index.js +3 -3
  111. package/package.json +1 -1
  112. package/build/bosun-app/frontend/client/_app/immutable/chunks/B8q_gCwD.js.br +0 -2
  113. package/build/bosun-app/frontend/client/_app/immutable/chunks/B8q_gCwD.js.gz +0 -0
  114. package/build/bosun-app/frontend/client/_app/immutable/chunks/BKW04JRY.js.br +0 -0
  115. package/build/bosun-app/frontend/client/_app/immutable/chunks/BKW04JRY.js.gz +0 -0
  116. package/build/bosun-app/frontend/client/_app/immutable/chunks/BOiOqwrA.js.br +0 -0
  117. package/build/bosun-app/frontend/client/_app/immutable/chunks/BOiOqwrA.js.gz +0 -0
  118. package/build/bosun-app/frontend/client/_app/immutable/chunks/BUkXSKT3.js.br +0 -0
  119. package/build/bosun-app/frontend/client/_app/immutable/chunks/BUkXSKT3.js.gz +0 -0
  120. package/build/bosun-app/frontend/client/_app/immutable/chunks/DGc0An5V.js.br +0 -0
  121. package/build/bosun-app/frontend/client/_app/immutable/chunks/DGc0An5V.js.gz +0 -0
  122. package/build/bosun-app/frontend/client/_app/immutable/entry/app.Bni-2yHM.js.br +0 -0
  123. package/build/bosun-app/frontend/client/_app/immutable/entry/app.Bni-2yHM.js.gz +0 -0
  124. package/build/bosun-app/frontend/client/_app/immutable/entry/start.Bwh8stkk.js +0 -1
  125. package/build/bosun-app/frontend/client/_app/immutable/entry/start.Bwh8stkk.js.br +0 -0
  126. package/build/bosun-app/frontend/client/_app/immutable/entry/start.Bwh8stkk.js.gz +0 -0
  127. package/build/bosun-app/frontend/client/_app/immutable/nodes/0.CyFCeOko.js.br +0 -0
  128. package/build/bosun-app/frontend/client/_app/immutable/nodes/0.CyFCeOko.js.gz +0 -0
  129. package/build/bosun-app/frontend/client/_app/immutable/nodes/1.D9Za90TC.js.br +0 -0
  130. package/build/bosun-app/frontend/client/_app/immutable/nodes/1.D9Za90TC.js.gz +0 -0
  131. package/build/bosun-app/frontend/client/_app/immutable/nodes/10.CQP8ZYdc.js.br +0 -0
  132. package/build/bosun-app/frontend/client/_app/immutable/nodes/10.CQP8ZYdc.js.gz +0 -0
  133. package/build/bosun-app/frontend/client/_app/immutable/nodes/17.C-6g-4TG.js.br +0 -0
  134. package/build/bosun-app/frontend/client/_app/immutable/nodes/17.C-6g-4TG.js.gz +0 -0
  135. package/build/bosun-app/frontend/client/_app/immutable/nodes/18.CKu_cfLu.js.br +0 -0
  136. package/build/bosun-app/frontend/client/_app/immutable/nodes/18.CKu_cfLu.js.gz +0 -0
  137. package/build/bosun-app/frontend/client/_app/immutable/nodes/2.lZxPEqtw.js.br +0 -0
  138. package/build/bosun-app/frontend/client/_app/immutable/nodes/3.BjH4Ma-k.js.br +0 -0
  139. package/build/bosun-app/frontend/client/_app/immutable/nodes/3.BjH4Ma-k.js.gz +0 -0
  140. package/build/bosun-app/frontend/client/_app/immutable/nodes/4.B_swg0wq.js.br +0 -0
  141. package/build/bosun-app/frontend/client/_app/immutable/nodes/4.B_swg0wq.js.gz +0 -0
  142. package/build/bosun-app/frontend/client/_app/immutable/nodes/5.CJfS926N.js.br +0 -0
  143. package/build/bosun-app/frontend/client/_app/immutable/nodes/5.CJfS926N.js.gz +0 -0
  144. package/build/bosun-app/frontend/client/_app/immutable/nodes/6.4aRjHu4u.js.br +0 -0
  145. package/build/bosun-app/frontend/client/_app/immutable/nodes/6.4aRjHu4u.js.gz +0 -0
  146. package/build/bosun-app/frontend/client/_app/immutable/nodes/8.BZFIHe4g.js.br +0 -0
  147. package/build/bosun-app/frontend/client/_app/immutable/nodes/8.BZFIHe4g.js.gz +0 -0
  148. package/build/bosun-app/frontend/client/_app/immutable/nodes/9.BYJRzNt4.js.br +0 -0
  149. package/build/bosun-app/frontend/client/_app/immutable/nodes/9.BYJRzNt4.js.gz +0 -0
  150. package/build/build/agent-service.d.ts +0 -8
  151. package/build/build/agent-service.d.ts.map +0 -1
  152. package/build/build/agent-service.js +0 -32
  153. package/build/build/text-function.d.ts +0 -6
  154. package/build/build/text-function.d.ts.map +0 -1
  155. package/build/build/text-function.js +0 -55
@@ -0,0 +1,3 @@
1
+ import type { RcBuildConfig } from './config';
2
+ export declare function rcBuild(config: RcBuildConfig): Promise<void>;
3
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/build/build.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAkC7C,wBAAsB,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA0DlE"}
@@ -0,0 +1,71 @@
1
+ import { glob } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { build } from 'esbuild';
4
+ import { ESM_COMPATIBILITY_BANNER, assertNoBosunPaths, auditBundledInputs, copyExternalDependencies, copyPromptFiles, writeMetafile, } from './common';
5
+ const DEFAULT_EXTERNAL = ['fsevents', 'pino'];
6
+ const NEVER_COPIED = new Set(['fsevents']);
7
+ async function expandEntries(patterns) {
8
+ const entries = [];
9
+ for (const pattern of patterns) {
10
+ if (!/[*?[]/.test(pattern)) {
11
+ entries.push(pattern);
12
+ continue;
13
+ }
14
+ for await (const match of glob(pattern)) {
15
+ entries.push(match);
16
+ }
17
+ }
18
+ return entries.sort();
19
+ }
20
+ function bundleName(entry) {
21
+ const stem = path.basename(entry, path.extname(entry));
22
+ return stem === 'index' ? path.basename(path.dirname(entry)) : stem;
23
+ }
24
+ export async function rcBuild(config) {
25
+ const patterns = Array.isArray(config.entries) ? config.entries : [config.entries];
26
+ const entries = await expandEntries(patterns);
27
+ if (entries.length === 0) {
28
+ throw new Error(`No entries match: ${patterns.join(', ')}`);
29
+ }
30
+ const out = path.resolve(config.out);
31
+ const external = [...DEFAULT_EXTERNAL, ...(config.external ?? [])];
32
+ const names = new Set();
33
+ const metafiles = [];
34
+ for (const entry of entries) {
35
+ const name = bundleName(entry);
36
+ if (names.has(name)) {
37
+ throw new Error(`Two entries make a bundle named "${name}"`);
38
+ }
39
+ names.add(name);
40
+ const outDir = path.join(out, name);
41
+ const result = await build({
42
+ entryPoints: [path.resolve(entry)],
43
+ bundle: true,
44
+ absWorkingDir: process.cwd(),
45
+ outfile: path.join(outDir, 'index.mjs'),
46
+ platform: 'node',
47
+ target: 'node24',
48
+ format: 'esm',
49
+ banner: { js: ESM_COMPATIBILITY_BANNER },
50
+ sourcemap: true,
51
+ minify: config.minify ?? process.env.NODE_ENV === 'production',
52
+ keepNames: true,
53
+ treeShaking: true,
54
+ metafile: true,
55
+ charset: 'utf8',
56
+ logLevel: 'info',
57
+ define: {
58
+ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV ?? 'production'),
59
+ },
60
+ external,
61
+ });
62
+ await writeMetafile(result.metafile, outDir);
63
+ assertNoBosunPaths(result.metafile, name);
64
+ for (const warning of await auditBundledInputs(result.metafile)) {
65
+ console.warn(`rc-build: ${warning}`);
66
+ }
67
+ metafiles.push(result.metafile);
68
+ }
69
+ await copyPromptFiles(config.promptDirs ?? ['src/agents'], out);
70
+ await copyExternalDependencies(metafiles, out, external.filter((name) => !NEVER_COPIED.has(name)));
71
+ }
@@ -1,13 +1,4 @@
1
- import { type AgentServiceOptions } from './agent-service';
2
- import { type TextFunctionOptions } from './text-function';
3
- export declare const USAGE = "Usage:\n rc-build agent-service [--entry src/main.ts] [--out build] [--bundle <pkg>]... [--external <pkg>]... [--prompt-dir <dir>]... [--minify|--no-minify]\n rc-build text-function --entries <file-or-glob> [--entries <glob>]... [--out build/functions] [--external <pkg>]... [--minify|--no-minify]";
4
- export type CliCommand = {
5
- profile: 'agent-service';
6
- options: AgentServiceOptions;
7
- } | {
8
- profile: 'text-function';
9
- options: TextFunctionOptions;
10
- };
11
- export declare function parseArgs(argv: string[]): CliCommand;
1
+ export declare const USAGE = "Usage: rc-build --config <file>";
2
+ export declare function parseArgs(argv: string[]): string;
12
3
  export declare function runCli(argv: string[]): Promise<void>;
13
4
  //# sourceMappingURL=cli.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/build/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAqB,MAAM,iBAAiB,CAAA;AAC7E,OAAO,EAAE,KAAK,mBAAmB,EAAsB,MAAM,iBAAiB,CAAA;AAE9E,eAAO,MAAM,KAAK,gTAE2H,CAAA;AAE7I,MAAM,MAAM,UAAU,GAChB;IAAE,OAAO,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,mBAAmB,CAAA;CAAE,GAC1D;IAAE,OAAO,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,mBAAmB,CAAA;CAAE,CAAA;AAWhE,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CA8EpD;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB1D"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/build/cli.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK,oCAAoC,CAAA;AAKtD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAoBhD;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAW1D"}
@@ -1,92 +1,35 @@
1
- import { buildAgentService } from './agent-service';
2
- import { buildTextFunctions } from './text-function';
3
- export const USAGE = `Usage:
4
- rc-build agent-service [--entry src/main.ts] [--out build] [--bundle <pkg>]... [--external <pkg>]... [--prompt-dir <dir>]... [--minify|--no-minify]
5
- rc-build text-function --entries <file-or-glob> [--entries <glob>]... [--out build/functions] [--external <pkg>]... [--minify|--no-minify]`;
1
+ import { rcBuild } from './build';
2
+ import { loadConfig } from './config';
3
+ export const USAGE = 'Usage: rc-build --config <file>';
6
4
  class CliError extends Error {
7
5
  }
8
- const SINGLE_FLAGS = ['entry', 'out'];
9
- const REPEATED_FLAGS = ['entries', 'bundle', 'external', 'prompt-dir'];
10
- const FLAGS_BY_PROFILE = {
11
- 'agent-service': ['entry', 'out', 'bundle', 'external', 'prompt-dir', 'minify'],
12
- 'text-function': ['entries', 'out', 'external', 'minify'],
13
- };
14
6
  export function parseArgs(argv) {
15
- const [profile, ...rest] = argv;
16
- if (profile !== 'agent-service' && profile !== 'text-function') {
17
- throw new CliError(profile ? `Unknown profile: ${profile}` : 'No profile given');
18
- }
19
- const single = {};
20
- const repeated = {
21
- entries: [],
22
- bundle: [],
23
- external: [],
24
- 'prompt-dir': [],
25
- };
26
- let minify;
27
- for (let i = 0; i < rest.length; i += 1) {
28
- const arg = rest[i];
29
- if (!arg.startsWith('--')) {
30
- throw new CliError(`Unexpected argument: ${arg}`);
31
- }
32
- const eq = arg.indexOf('=');
33
- const flag = eq === -1 ? arg.slice(2) : arg.slice(2, eq);
34
- if (flag === 'minify' || flag === 'no-minify') {
35
- if (eq !== -1) {
36
- throw new CliError(`--${flag} takes no value`);
37
- }
38
- minify = flag === 'minify';
39
- continue;
40
- }
41
- if (!FLAGS_BY_PROFILE[profile].includes(flag)) {
42
- throw new CliError(`Unknown flag for ${profile}: --${flag}`);
43
- }
44
- let value;
45
- if (eq !== -1) {
46
- value = arg.slice(eq + 1);
47
- }
48
- else {
7
+ let file;
8
+ for (let i = 0; i < argv.length; i += 1) {
9
+ const arg = argv[i];
10
+ if (arg === '--config') {
49
11
  i += 1;
50
- if (i === rest.length) {
51
- throw new CliError(`--${flag} needs a value`);
12
+ if (i === argv.length) {
13
+ throw new CliError('--config needs a value');
52
14
  }
53
- value = rest[i];
54
- }
55
- if (REPEATED_FLAGS.includes(flag)) {
56
- repeated[flag].push(value);
15
+ file = argv[i];
57
16
  }
58
- else if (single[flag] !== undefined) {
59
- throw new CliError(`--${flag} given twice`);
17
+ else if (arg.startsWith('--config=')) {
18
+ file = arg.slice('--config='.length);
60
19
  }
61
20
  else {
62
- single[flag] = value;
21
+ throw new CliError(`Unexpected argument: ${arg}`);
63
22
  }
64
23
  }
65
- const shared = {
66
- out: single.out,
67
- external: repeated.external.length > 0 ? repeated.external : undefined,
68
- minify,
69
- };
70
- if (profile === 'agent-service') {
71
- return {
72
- profile,
73
- options: {
74
- ...shared,
75
- entry: single.entry,
76
- bundle: repeated.bundle.length > 0 ? repeated.bundle : undefined,
77
- promptDirs: repeated['prompt-dir'].length > 0 ? repeated['prompt-dir'] : undefined,
78
- },
79
- };
24
+ if (file === undefined || file === '') {
25
+ throw new CliError('--config is required');
80
26
  }
81
- if (repeated.entries.length === 0) {
82
- throw new CliError('text-function needs at least one --entries');
83
- }
84
- return { profile, options: { ...shared, entries: repeated.entries } };
27
+ return file;
85
28
  }
86
29
  export async function runCli(argv) {
87
- let command;
30
+ let file;
88
31
  try {
89
- command = parseArgs(argv);
32
+ file = parseArgs(argv);
90
33
  }
91
34
  catch (error) {
92
35
  if (error instanceof CliError) {
@@ -94,10 +37,5 @@ export async function runCli(argv) {
94
37
  }
95
38
  throw error;
96
39
  }
97
- if (command.profile === 'agent-service') {
98
- await buildAgentService(command.options);
99
- }
100
- else {
101
- await buildTextFunctions(command.options);
102
- }
40
+ await rcBuild(await loadConfig(file));
103
41
  }
@@ -1,12 +1,8 @@
1
- import type { Metafile, Plugin } from 'esbuild';
2
- export interface ProfileOptions {
3
- out?: string;
4
- external?: string[];
5
- minify?: boolean;
6
- }
7
- export declare function shouldMinify(options: ProfileOptions): boolean;
8
- export declare function externalizeDependencies(bundle: string[], external: string[]): Plugin;
9
- export declare function copyPromptFiles(promptDirs: string[], outDir: string): Plugin;
1
+ import type { Metafile } from 'esbuild';
2
+ export declare const ESM_COMPATIBILITY_BANNER: string;
3
+ export declare function copyExternalDependencies(metafiles: Metafile[], outDir: string, names: string[]): Promise<void>;
4
+ export declare function copyPromptFiles(promptDirs: string[], outDir: string): Promise<void>;
10
5
  export declare function assertNoBosunPaths(metafile: Metafile, bundleName: string): void;
6
+ export declare function auditBundledInputs(metafile: Metafile): Promise<string[]>;
11
7
  export declare function writeMetafile(metafile: Metafile, outDir: string): Promise<void>;
12
8
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/build/common.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAG/C,MAAM,WAAW,cAAc;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,MAAM,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAE7D;AAaD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAgBpF;AAyBD,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAqB5E;AAQD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAO/E;AAGD,wBAAsB,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGrF"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/build/common.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAYvC,eAAO,MAAM,wBAAwB,QAOzB,CAAA;AA6BZ,wBAAsB,wBAAwB,CAC1C,SAAS,EAAE,QAAQ,EAAE,EACrB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,IAAI,CAAC,CA0Df;AAyBD,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAWzF;AAQD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAO/E;AAsBD,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAyB9E;AAGD,wBAAsB,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGrF"}
@@ -1,28 +1,82 @@
1
- import { copyFile, mkdir, readdir, writeFile } from 'node:fs/promises';
1
+ import { existsSync, realpathSync } from 'node:fs';
2
+ import { copyFile, cp, mkdir, readFile, readdir, writeFile } from 'node:fs/promises';
3
+ import { builtinModules } from 'node:module';
2
4
  import path from 'node:path';
3
- export function shouldMinify(options) {
4
- return options.minify ?? process.env.NODE_ENV === 'production';
5
- }
6
5
  function packageName(specifier) {
7
6
  const parts = specifier.split('/');
8
7
  return specifier.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];
9
8
  }
10
- export function externalizeDependencies(bundle, external) {
11
- return {
12
- name: 'externalize-dependencies',
13
- setup(build) {
14
- build.onResolve({ filter: /^[^./]/ }, (args) => {
15
- const name = packageName(args.path);
16
- if (external.includes(name)) {
17
- return { path: args.path, external: true };
9
+ export const ESM_COMPATIBILITY_BANNER = [
10
+ "import { createRequire as __rcbCreateRequire } from 'node:module'",
11
+ "import { fileURLToPath as __rcbFileURLToPath } from 'node:url'",
12
+ "import { dirname as __rcbDirname } from 'node:path'",
13
+ 'const require = __rcbCreateRequire(import.meta.url)',
14
+ 'const __filename = __rcbFileURLToPath(import.meta.url)',
15
+ 'const __dirname = __rcbDirname(__filename)',
16
+ ].join('\n');
17
+ function isBuiltin(specifier) {
18
+ return specifier.startsWith('node:') || builtinModules.includes(packageName(specifier));
19
+ }
20
+ function findPackageDir(fromDir, name) {
21
+ let dir = fromDir;
22
+ for (;;) {
23
+ const candidate = path.join(dir, 'node_modules', name);
24
+ if (existsSync(path.join(candidate, 'package.json'))) {
25
+ return candidate;
26
+ }
27
+ const parent = path.dirname(dir);
28
+ if (parent === dir) {
29
+ return undefined;
30
+ }
31
+ dir = parent;
32
+ }
33
+ }
34
+ export async function copyExternalDependencies(metafiles, outDir, names) {
35
+ const queue = [];
36
+ for (const metafile of metafiles) {
37
+ for (const [input, data] of Object.entries(metafile.inputs)) {
38
+ for (const imported of data.imports) {
39
+ if (!imported.external || !names.includes(packageName(imported.path))) {
40
+ continue;
18
41
  }
19
- if (name.startsWith('@recombine-ai/') || bundle.includes(name)) {
20
- return null;
42
+ queue.push({
43
+ name: packageName(imported.path),
44
+ fromDir: path.dirname(path.resolve(input)),
45
+ required: true,
46
+ });
47
+ }
48
+ }
49
+ }
50
+ const copied = new Set();
51
+ while (queue.length > 0) {
52
+ const { name, fromDir, required } = queue.shift();
53
+ if (copied.has(name)) {
54
+ continue;
55
+ }
56
+ const pkgDir = findPackageDir(realpathSync(fromDir), name);
57
+ if (pkgDir === undefined) {
58
+ if (required) {
59
+ throw new Error(`Cannot find the external package "${name}" from ${fromDir}`);
60
+ }
61
+ continue;
62
+ }
63
+ copied.add(name);
64
+ await cp(pkgDir, path.resolve(outDir, 'node_modules', name), {
65
+ recursive: true,
66
+ dereference: true,
67
+ });
68
+ const manifest = JSON.parse(await readFile(path.join(pkgDir, 'package.json'), 'utf8'));
69
+ const add = (dependencies, required) => {
70
+ for (const dependency of dependencies) {
71
+ if (!isBuiltin(dependency) && dependency !== 'fsevents') {
72
+ queue.push({ name: dependency, fromDir: pkgDir, required });
21
73
  }
22
- return { path: args.path, external: true };
23
- });
24
- },
25
- };
74
+ }
75
+ };
76
+ add(Object.keys(manifest.dependencies ?? {}), true);
77
+ add(Object.keys(manifest.peerDependencies ?? {}), false);
78
+ add(Object.keys(manifest.optionalDependencies ?? {}), false);
79
+ }
26
80
  }
27
81
  const PROMPT_FILE = /\.(md|txt|njk)$/;
28
82
  async function copyMatchingFiles(srcDir, destDir) {
@@ -39,28 +93,18 @@ async function copyMatchingFiles(srcDir, destDir) {
39
93
  }
40
94
  }
41
95
  }
42
- export function copyPromptFiles(promptDirs, outDir) {
43
- return {
44
- name: 'copy-prompt-files',
45
- setup(build) {
46
- build.onEnd(async (result) => {
47
- if (result.errors.length > 0) {
48
- return;
49
- }
50
- for (const dir of promptDirs) {
51
- try {
52
- await copyMatchingFiles(path.resolve(dir), path.resolve(outDir, dir));
53
- }
54
- catch (error) {
55
- if (error.code !== 'ENOENT') {
56
- throw error;
57
- }
58
- console.warn(`rc-build: no prompt directory at ${dir}, skipped`);
59
- }
60
- }
61
- });
62
- },
63
- };
96
+ export async function copyPromptFiles(promptDirs, outDir) {
97
+ for (const dir of promptDirs) {
98
+ try {
99
+ await copyMatchingFiles(path.resolve(dir), path.resolve(outDir, dir));
100
+ }
101
+ catch (error) {
102
+ if (error.code !== 'ENOENT') {
103
+ throw error;
104
+ }
105
+ console.warn(`rc-build: no prompt directory at ${dir}, skipped`);
106
+ }
107
+ }
64
108
  }
65
109
  const BOSUN_PATH = /(^|\/)(bosun-app|src\/bosun|build\/bosun)\//;
66
110
  export function assertNoBosunPaths(metafile, bundleName) {
@@ -69,6 +113,41 @@ export function assertNoBosunPaths(metafile, bundleName) {
69
113
  throw new Error(`The ${bundleName} bundle holds Bosun code:\n ${offenders.slice(0, 20).join('\n ')}`);
70
114
  }
71
115
  }
116
+ const HAZARD_PATTERNS = [
117
+ [/__dirname/, 'uses __dirname'],
118
+ [/\(\s*__filename/, 'uses __filename'],
119
+ [/new Worker\(/, 'starts a worker thread'],
120
+ ];
121
+ const NATIVE_FILE = /\.(node|wasm)$/;
122
+ function bundledPackageName(input) {
123
+ const marker = 'node_modules/';
124
+ return packageName(input.slice(input.lastIndexOf(marker) + marker.length));
125
+ }
126
+ export async function auditBundledInputs(metafile) {
127
+ const warnings = new Map();
128
+ const warn = (input, reason) => {
129
+ const key = `${bundledPackageName(input)} ${reason}`;
130
+ if (!warnings.has(key)) {
131
+ warnings.set(key, `${key} (${input}). Consider adding it to "external".`);
132
+ }
133
+ };
134
+ for (const input of Object.keys(metafile.inputs)) {
135
+ if (!input.includes('node_modules/')) {
136
+ continue;
137
+ }
138
+ if (NATIVE_FILE.test(input)) {
139
+ warn(input, 'holds a native file');
140
+ continue;
141
+ }
142
+ const source = await readFile(input, 'utf8');
143
+ for (const [pattern, reason] of HAZARD_PATTERNS) {
144
+ if (pattern.test(source)) {
145
+ warn(input, reason);
146
+ }
147
+ }
148
+ }
149
+ return [...warnings.values()];
150
+ }
72
151
  export async function writeMetafile(metafile, outDir) {
73
152
  await mkdir(outDir, { recursive: true });
74
153
  await writeFile(path.join(outDir, 'meta.json'), JSON.stringify(metafile));
@@ -0,0 +1,9 @@
1
+ export interface RcBuildConfig {
2
+ entries: string | string[];
3
+ out: string;
4
+ promptDirs?: string[];
5
+ external?: string[];
6
+ minify?: boolean;
7
+ }
8
+ export declare function loadConfig(file: string): Promise<RcBuildConfig>;
9
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/build/config.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,aAAa;IAE1B,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAE1B,GAAG,EAAE,MAAM,CAAA;IAEX,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IAErB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IAEnB,MAAM,CAAC,EAAE,OAAO,CAAA;CACnB;AAWD,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAcrE"}
@@ -0,0 +1,24 @@
1
+ import { existsSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { pathToFileURL } from 'node:url';
4
+ import { z } from 'zod';
5
+ const RcBuildConfigSchema = z.strictObject({
6
+ entries: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]),
7
+ out: z.string().min(1),
8
+ promptDirs: z.array(z.string().min(1)).optional(),
9
+ external: z.array(z.string().min(1)).optional(),
10
+ minify: z.boolean().optional(),
11
+ });
12
+ export async function loadConfig(file) {
13
+ const configPath = path.resolve(file);
14
+ if (!existsSync(configPath)) {
15
+ throw new Error(`No config file at ${configPath}`);
16
+ }
17
+ const module = await import(pathToFileURL(configPath).href);
18
+ const result = RcBuildConfigSchema.safeParse(module.default);
19
+ if (!result.success) {
20
+ const issues = result.error.issues.map((issue) => `${issue.path.join('.') || 'default export'}: ${issue.message}`);
21
+ throw new Error(`Invalid config ${file}:\n ${issues.join('\n ')}`);
22
+ }
23
+ return result.data;
24
+ }
@@ -1,7 +1,5 @@
1
- export { buildAgentService } from './agent-service';
2
- export type { AgentServiceOptions } from './agent-service';
3
- export { buildTextFunctions } from './text-function';
4
- export type { TextFunctionOptions } from './text-function';
5
- export { USAGE, parseArgs, runCli } from './cli';
6
- export type { CliCommand } from './cli';
1
+ export { rcBuild } from './build';
2
+ export { loadConfig } from './config';
3
+ export type { RcBuildConfig } from './config';
4
+ export { runCli } from './cli';
7
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/build/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAChD,YAAY,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/build/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA"}
@@ -1,3 +1,3 @@
1
- export { buildAgentService } from './agent-service';
2
- export { buildTextFunctions } from './text-function';
3
- export { USAGE, parseArgs, runCli } from './cli';
1
+ export { rcBuild } from './build';
2
+ export { loadConfig } from './config';
3
+ export { runCli } from './cli';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@recombine-ai/platform",
3
3
  "type": "module",
4
- "version": "0.3.0",
4
+ "version": "0.4.0",
5
5
  "description": "The Recombine platform: engine, telescope, dockyard, call control, the voice agent API, and the Bosun bindings in one package",
6
6
  "license": "EULA",
7
7
  "author": "recombine.ai",
@@ -1,2 +0,0 @@
1
- 1@dkN_�rU��!�1���N!�2kۅ�c���@�B�]5��|Zȓh
2
- ���n��_Z���W���ݝ6ۀ��� ��}� �����M����D�/��KD2�d"�� ��u�H$m�q��8�]�d�r��/ͧ+�/��<��I
@@ -1 +0,0 @@
1
- import{a as r}from"../chunks/DGc0An5V.js";import{y as t}from"../chunks/BKW04JRY.js";export{t as load_css,r as start};
@@ -1,8 +0,0 @@
1
- import { type ProfileOptions } from './common';
2
- export interface AgentServiceOptions extends ProfileOptions {
3
- entry?: string;
4
- bundle?: string[];
5
- promptDirs?: string[];
6
- }
7
- export declare function buildAgentService(options?: AgentServiceOptions): Promise<void>;
8
- //# sourceMappingURL=agent-service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-service.d.ts","sourceRoot":"","sources":["../../src/build/agent-service.ts"],"names":[],"mappings":"AAIA,OAAO,EACH,KAAK,cAAc,EAMtB,MAAM,UAAU,CAAA;AAEjB,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACvD,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CACxB;AAOD,wBAAsB,iBAAiB,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BxF"}