@rotifer/playground 0.8.5 → 0.9.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 (119) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/README.md +39 -23
  3. package/README.zh.md +38 -22
  4. package/dist/cloud/auth.d.ts +14 -4
  5. package/dist/cloud/auth.d.ts.map +1 -1
  6. package/dist/cloud/auth.js +19 -7
  7. package/dist/cloud/auth.js.map +1 -1
  8. package/dist/cloud/badge.d.ts +42 -0
  9. package/dist/cloud/badge.d.ts.map +1 -0
  10. package/dist/cloud/badge.js +67 -0
  11. package/dist/cloud/badge.js.map +1 -0
  12. package/dist/cloud/client.d.ts +14 -0
  13. package/dist/cloud/client.d.ts.map +1 -1
  14. package/dist/cloud/client.js +54 -13
  15. package/dist/cloud/client.js.map +1 -1
  16. package/dist/cloud/gene-ref.d.ts +41 -0
  17. package/dist/cloud/gene-ref.d.ts.map +1 -0
  18. package/dist/cloud/gene-ref.js +45 -0
  19. package/dist/cloud/gene-ref.js.map +1 -0
  20. package/dist/cloud/index.d.ts +1 -0
  21. package/dist/cloud/index.d.ts.map +1 -1
  22. package/dist/cloud/index.js +1 -0
  23. package/dist/cloud/index.js.map +1 -1
  24. package/dist/cloud/types.d.ts +2 -0
  25. package/dist/cloud/types.d.ts.map +1 -1
  26. package/dist/cloud/types.js +2 -1
  27. package/dist/cloud/types.js.map +1 -1
  28. package/dist/commands/agent-list.d.ts.map +1 -1
  29. package/dist/commands/agent-list.js +8 -1
  30. package/dist/commands/agent-list.js.map +1 -1
  31. package/dist/commands/agent-run.d.ts.map +1 -1
  32. package/dist/commands/agent-run.js +12 -8
  33. package/dist/commands/agent-run.js.map +1 -1
  34. package/dist/commands/arena-submit.d.ts.map +1 -1
  35. package/dist/commands/arena-submit.js +2 -8
  36. package/dist/commands/arena-submit.js.map +1 -1
  37. package/dist/commands/compile.d.ts.map +1 -1
  38. package/dist/commands/compile.js +35 -20
  39. package/dist/commands/compile.js.map +1 -1
  40. package/dist/commands/doctor.d.ts +3 -0
  41. package/dist/commands/doctor.d.ts.map +1 -0
  42. package/dist/commands/doctor.js +58 -0
  43. package/dist/commands/doctor.js.map +1 -0
  44. package/dist/commands/hello.d.ts.map +1 -1
  45. package/dist/commands/hello.js +45 -6
  46. package/dist/commands/hello.js.map +1 -1
  47. package/dist/commands/init.d.ts.map +1 -1
  48. package/dist/commands/init.js +11 -9
  49. package/dist/commands/init.js.map +1 -1
  50. package/dist/commands/list.js +3 -3
  51. package/dist/commands/list.js.map +1 -1
  52. package/dist/commands/network.d.ts.map +1 -1
  53. package/dist/commands/network.js +172 -64
  54. package/dist/commands/network.js.map +1 -1
  55. package/dist/commands/publish.d.ts.map +1 -1
  56. package/dist/commands/publish.js +72 -0
  57. package/dist/commands/publish.js.map +1 -1
  58. package/dist/commands/reputation.d.ts.map +1 -1
  59. package/dist/commands/reputation.js +51 -10
  60. package/dist/commands/reputation.js.map +1 -1
  61. package/dist/commands/run.d.ts.map +1 -1
  62. package/dist/commands/run.js +13 -4
  63. package/dist/commands/run.js.map +1 -1
  64. package/dist/commands/test.d.ts.map +1 -1
  65. package/dist/commands/test.js +9 -4
  66. package/dist/commands/test.js.map +1 -1
  67. package/dist/commands/user-config.js +2 -2
  68. package/dist/commands/user-config.js.map +1 -1
  69. package/dist/commands/versions.d.ts.map +1 -1
  70. package/dist/commands/versions.js +34 -3
  71. package/dist/commands/versions.js.map +1 -1
  72. package/dist/commands/vg.d.ts.map +1 -1
  73. package/dist/commands/vg.js +7 -25
  74. package/dist/commands/vg.js.map +1 -1
  75. package/dist/commands/whoami.d.ts.map +1 -1
  76. package/dist/commands/whoami.js +7 -1
  77. package/dist/commands/whoami.js.map +1 -1
  78. package/dist/commands/wrap.d.ts.map +1 -1
  79. package/dist/commands/wrap.js +25 -2
  80. package/dist/commands/wrap.js.map +1 -1
  81. package/dist/index.js +2 -0
  82. package/dist/index.js.map +1 -1
  83. package/dist/types/phenotype.d.ts +181 -0
  84. package/dist/types/phenotype.d.ts.map +1 -0
  85. package/dist/types/phenotype.js +87 -0
  86. package/dist/types/phenotype.js.map +1 -0
  87. package/dist/utils/binding.d.ts +28 -3
  88. package/dist/utils/binding.d.ts.map +1 -1
  89. package/dist/utils/binding.js +61 -18
  90. package/dist/utils/binding.js.map +1 -1
  91. package/dist/utils/config.js +1 -1
  92. package/dist/utils/config.js.map +1 -1
  93. package/dist/utils/detect-source-language.d.ts +20 -0
  94. package/dist/utils/detect-source-language.d.ts.map +1 -0
  95. package/dist/utils/detect-source-language.js +83 -0
  96. package/dist/utils/detect-source-language.js.map +1 -0
  97. package/dist/utils/javy-compiler.d.ts +32 -1
  98. package/dist/utils/javy-compiler.d.ts.map +1 -1
  99. package/dist/utils/javy-compiler.js +137 -12
  100. package/dist/utils/javy-compiler.js.map +1 -1
  101. package/dist/utils/p2p-daemon.d.ts +30 -0
  102. package/dist/utils/p2p-daemon.d.ts.map +1 -0
  103. package/dist/utils/p2p-daemon.js +199 -0
  104. package/dist/utils/p2p-daemon.js.map +1 -0
  105. package/dist/utils/phenotype-validator.d.ts.map +1 -1
  106. package/dist/utils/phenotype-validator.js +197 -2
  107. package/dist/utils/phenotype-validator.js.map +1 -1
  108. package/dist/utils/project-root.js +1 -1
  109. package/dist/utils/project-root.js.map +1 -1
  110. package/dist/utils/sandbox-defaults.d.ts +9 -0
  111. package/dist/utils/sandbox-defaults.d.ts.map +1 -0
  112. package/dist/utils/sandbox-defaults.js +12 -0
  113. package/dist/utils/sandbox-defaults.js.map +1 -0
  114. package/dist/utils/user-config.d.ts +2 -0
  115. package/dist/utils/user-config.d.ts.map +1 -1
  116. package/dist/utils/user-config.js +12 -2
  117. package/dist/utils/user-config.js.map +1 -1
  118. package/package.json +15 -6
  119. package/scripts/postinstall.js +2 -2
@@ -1,38 +1,58 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tryLoadBinding = tryLoadBinding;
4
+ exports.loadP2pNode = loadP2pNode;
4
5
  exports.isNativeAvailable = isNativeAvailable;
5
6
  const node_path_1 = require("node:path");
6
7
  const node_fs_1 = require("node:fs");
7
8
  const private_fs_js_1 = require("./private-fs.js");
8
9
  let _binding = null;
9
10
  let _hasLoadAttempted = false;
11
+ let _rawModule = null;
12
+ let _hasModuleLoadAttempted = false;
13
+ const PLATFORM_PACKAGE_MAP = {
14
+ "darwin-arm64": "@rotifer/playground-darwin-arm64",
15
+ "darwin-x64": "@rotifer/playground-darwin-x64",
16
+ "linux-x64": "@rotifer/playground-linux-x64-gnu",
17
+ "win32-x64": "@rotifer/playground-win32-x64-msvc",
18
+ };
19
+ function initBinding(mod) {
20
+ if (!mod.PlaygroundBinding)
21
+ return null;
22
+ const tmpDir = (0, node_path_1.join)(process.env.HOME || process.env.USERPROFILE || "/tmp", ".rotifer", "napi-binding");
23
+ (0, private_fs_js_1.ensurePrivateDir)(tmpDir);
24
+ return new mod.PlaygroundBinding(tmpDir);
25
+ }
10
26
  /**
11
27
  * Try to load the napi native addon.
28
+ * Strategy: platform npm package first, then local .node file fallback.
12
29
  * Returns null if the addon is not available (fallback to pure-TS path).
13
30
  */
14
- function tryLoadBinding() {
15
- if (_hasLoadAttempted)
16
- return _binding;
17
- _hasLoadAttempted = true;
18
- const candidates = [
19
- (0, node_path_1.join)(__dirname, "..", "..", "index.darwin-arm64.node"),
20
- (0, node_path_1.join)(__dirname, "..", "..", "index.darwin-x64.node"),
21
- (0, node_path_1.join)(__dirname, "..", "..", "index.linux-x64-gnu.node"),
22
- (0, node_path_1.join)(__dirname, "..", "..", "index.win32-x64-msvc.node"),
31
+ function loadRawModule() {
32
+ if (_hasModuleLoadAttempted)
33
+ return _rawModule;
34
+ _hasModuleLoadAttempted = true;
35
+ const platformKey = `${process.platform}-${process.arch}`;
36
+ const pkgName = PLATFORM_PACKAGE_MAP[platformKey];
37
+ if (pkgName) {
38
+ try {
39
+ _rawModule = require(pkgName);
40
+ return _rawModule;
41
+ }
42
+ catch {
43
+ // platform package not installed — fall through to local search
44
+ }
45
+ }
46
+ const localCandidates = [
47
+ (0, node_path_1.join)(__dirname, "..", "..", `index.${platformKey}.node`),
48
+ (0, node_path_1.join)(__dirname, "..", "..", `index.${process.platform}-${process.arch}.node`),
23
49
  (0, node_path_1.join)(__dirname, "..", "..", `rotifer-napi.${process.platform}-${process.arch}.node`),
24
50
  ];
25
- for (const candidate of candidates) {
51
+ for (const candidate of localCandidates) {
26
52
  if ((0, node_fs_1.existsSync)(candidate)) {
27
53
  try {
28
- const mod = require(candidate);
29
- if (mod.PlaygroundBinding) {
30
- const tmpDir = (0, node_path_1.join)(process.env.HOME || process.env.USERPROFILE || "/tmp", ".rotifer", "napi-binding");
31
- (0, private_fs_js_1.ensurePrivateDir)(tmpDir);
32
- const instance = new mod.PlaygroundBinding(tmpDir);
33
- _binding = instance;
34
- return _binding;
35
- }
54
+ _rawModule = require(candidate);
55
+ return _rawModule;
36
56
  }
37
57
  catch {
38
58
  // addon exists but failed to load — continue
@@ -41,6 +61,29 @@ function tryLoadBinding() {
41
61
  }
42
62
  return null;
43
63
  }
64
+ function tryLoadBinding() {
65
+ if (_hasLoadAttempted)
66
+ return _binding;
67
+ _hasLoadAttempted = true;
68
+ const mod = loadRawModule();
69
+ if (mod)
70
+ _binding = initBinding(mod);
71
+ return _binding;
72
+ }
73
+ /**
74
+ * Construct a native libp2p P2P node. Returns null when the native addon is
75
+ * unavailable (e.g. a pure-TS environment without the compiled `.node`), so
76
+ * callers can degrade gracefully.
77
+ */
78
+ function loadP2pNode(listenHost, listenPort, bootstrapPeers) {
79
+ const mod = loadRawModule();
80
+ // napi renders the Rust `P2pNode` as `P2PNode` (it uppercases the "p2p"
81
+ // acronym); accept either spelling so both the raw addon and any JS wrapper work.
82
+ const Ctor = (mod?.P2PNode ?? mod?.P2pNode);
83
+ if (typeof Ctor !== "function")
84
+ return null;
85
+ return new Ctor(listenHost, listenPort, bootstrapPeers);
86
+ }
44
87
  function isNativeAvailable() {
45
88
  return tryLoadBinding() !== null;
46
89
  }
@@ -1 +1 @@
1
- {"version":3,"file":"binding.js","sourceRoot":"","sources":["../../src/utils/binding.ts"],"names":[],"mappings":";;AAwEA,wCAkCC;AAED,8CAEC;AA9GD,yCAAiC;AACjC,qCAAqC;AACrC,mDAAmD;AA+DnD,IAAI,QAAQ,GAAyB,IAAI,CAAC;AAC1C,IAAI,iBAAiB,GAAG,KAAK,CAAC;AAE9B;;;GAGG;AACH,SAAgB,cAAc;IAC5B,IAAI,iBAAiB;QAAE,OAAO,QAAQ,CAAC;IACvC,iBAAiB,GAAG,IAAI,CAAC;IAEzB,MAAM,UAAU,GAAG;QACjB,IAAA,gBAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,yBAAyB,CAAC;QACtD,IAAA,gBAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,uBAAuB,CAAC;QACpD,IAAA,gBAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,0BAA0B,CAAC;QACvD,IAAA,gBAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,2BAA2B,CAAC;QACxD,IAAA,gBAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,OAAO,CAAC;KACrF,CAAC;IAEF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,IAAA,oBAAU,EAAC,SAAS,CAAC,EAAE,CAAC;YAC1B,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;gBAC/B,IAAI,GAAG,CAAC,iBAAiB,EAAE,CAAC;oBAC1B,MAAM,MAAM,GAAG,IAAA,gBAAI,EACjB,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,MAAM,EACrD,UAAU,EACV,cAAc,CACf,CAAC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AAE,CAAC;IAC5B,IAAI,GAAG;QAAE,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IACrC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAiCD;;;;GAIG;AACH,SAAgB,WAAW,CACzB,UAAkB,EAClB,UAAkB,EAClB,cAAwB;IAExB,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;IAC5B,wEAAwE;IACxE,kFAAkF;IAClF,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,IAAI,GAAG,EAAE,OAAO,CAE7B,CAAC;IACd,IAAI,OAAO,IAAI,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC;IAC5C,OAAO,IAAI,IAAI,CAAC,UAAU,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;AAC1D,CAAC;AAED,SAAgB,iBAAiB;IAC/B,OAAO,cAAc,EAAE,KAAK,IAAI,CAAC;AACnC,CAAC"}
@@ -33,7 +33,7 @@ function saveConfig(config, projectDir) {
33
33
  function getProjectRoot() {
34
34
  const root = findProjectRoot();
35
35
  if (!root) {
36
- throw new Error(`No ${CONFIG_FILE} found. Run 'rotifer init' to create a new project.`);
36
+ throw new Error(`No ${CONFIG_FILE} found. Run 'rotifer init' to create a new Agent workspace.`);
37
37
  }
38
38
  return root;
39
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":";;AAaA,0CASC;AAED,gCAWC;AAED,gCAGC;AAED,wCAQC;AAlDD,qCAAkE;AAClE,yCAAiC;AAUjC,MAAM,WAAW,GAAG,cAAc,CAAC;AAEnC,SAAgB,eAAe,CAAC,WAAmB,OAAO,CAAC,GAAG,EAAE;IAC9D,IAAI,GAAG,GAAG,QAAQ,CAAC;IACnB,OAAO,GAAG,KAAK,GAAG,EAAE,CAAC;QACnB,IAAI,IAAA,oBAAU,EAAC,IAAA,gBAAI,EAAC,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC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 @@
1
+ export type SourceLanguage = "typescript" | "rust" | "assemblyscript" | "go" | "c" | "external" | "unknown";
2
+ export declare function isValidSourceLanguage(value: string): value is SourceLanguage;
3
+ /**
4
+ * Detect the source language of a gene by inspecting its directory.
5
+ *
6
+ * Detection rules (in priority order):
7
+ * 1. `index.ts` or `index.js` → "typescript"
8
+ * 2. `Cargo.toml` → "rust"
9
+ * 3. `assembly/index.ts` or
10
+ * `asconfig.json` (without index.ts) → "assemblyscript"
11
+ * 4. `go.mod` → "go"
12
+ * 5. Any `.c`/`.cpp`/`.cc`/`.h` at root → "c"
13
+ * 6. `gene.wasm` exists but no source → "external"
14
+ * 7. Nothing matches → "unknown"
15
+ *
16
+ * The detection is best-effort and intentionally conservative — when ambiguous,
17
+ * callers should let the user override with the `--lang` flag.
18
+ */
19
+ export declare function detectSourceLanguage(geneDir: string): SourceLanguage;
20
+ //# sourceMappingURL=detect-source-language.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-source-language.d.ts","sourceRoot":"","sources":["../../src/utils/detect-source-language.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,cAAc,GACtB,YAAY,GACZ,MAAM,GACN,gBAAgB,GAChB,IAAI,GACJ,GAAG,GACH,UAAU,GACV,SAAS,CAAC;AAYd,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,cAAc,CAE5E;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CA6BpE"}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidSourceLanguage = isValidSourceLanguage;
4
+ exports.detectSourceLanguage = detectSourceLanguage;
5
+ const node_fs_1 = require("node:fs");
6
+ const node_path_1 = require("node:path");
7
+ const VALID_LANGUAGES = new Set([
8
+ "typescript",
9
+ "rust",
10
+ "assemblyscript",
11
+ "go",
12
+ "c",
13
+ "external",
14
+ "unknown",
15
+ ]);
16
+ function isValidSourceLanguage(value) {
17
+ return VALID_LANGUAGES.has(value);
18
+ }
19
+ /**
20
+ * Detect the source language of a gene by inspecting its directory.
21
+ *
22
+ * Detection rules (in priority order):
23
+ * 1. `index.ts` or `index.js` → "typescript"
24
+ * 2. `Cargo.toml` → "rust"
25
+ * 3. `assembly/index.ts` or
26
+ * `asconfig.json` (without index.ts) → "assemblyscript"
27
+ * 4. `go.mod` → "go"
28
+ * 5. Any `.c`/`.cpp`/`.cc`/`.h` at root → "c"
29
+ * 6. `gene.wasm` exists but no source → "external"
30
+ * 7. Nothing matches → "unknown"
31
+ *
32
+ * The detection is best-effort and intentionally conservative — when ambiguous,
33
+ * callers should let the user override with the `--lang` flag.
34
+ */
35
+ function detectSourceLanguage(geneDir) {
36
+ if ((0, node_fs_1.existsSync)((0, node_path_1.join)(geneDir, "index.ts")) ||
37
+ (0, node_fs_1.existsSync)((0, node_path_1.join)(geneDir, "index.js"))) {
38
+ return "typescript";
39
+ }
40
+ if ((0, node_fs_1.existsSync)((0, node_path_1.join)(geneDir, "Cargo.toml"))) {
41
+ return "rust";
42
+ }
43
+ if ((0, node_fs_1.existsSync)((0, node_path_1.join)(geneDir, "assembly", "index.ts")) ||
44
+ (0, node_fs_1.existsSync)((0, node_path_1.join)(geneDir, "asconfig.json"))) {
45
+ return "assemblyscript";
46
+ }
47
+ if ((0, node_fs_1.existsSync)((0, node_path_1.join)(geneDir, "go.mod"))) {
48
+ return "go";
49
+ }
50
+ if (hasCSourceAtRoot(geneDir)) {
51
+ return "c";
52
+ }
53
+ if ((0, node_fs_1.existsSync)((0, node_path_1.join)(geneDir, "gene.wasm")) ||
54
+ (0, node_fs_1.existsSync)((0, node_path_1.join)(geneDir, "gene.ir.wasm"))) {
55
+ return "external";
56
+ }
57
+ return "unknown";
58
+ }
59
+ function hasCSourceAtRoot(dir) {
60
+ if (!(0, node_fs_1.existsSync)(dir))
61
+ return false;
62
+ try {
63
+ const fs = require("node:fs");
64
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
65
+ for (const entry of entries) {
66
+ if (!entry.isFile())
67
+ continue;
68
+ const lower = entry.name.toLowerCase();
69
+ if (lower.endsWith(".c") ||
70
+ lower.endsWith(".cpp") ||
71
+ lower.endsWith(".cc") ||
72
+ lower.endsWith(".h") ||
73
+ lower.endsWith(".hpp")) {
74
+ return true;
75
+ }
76
+ }
77
+ }
78
+ catch {
79
+ // ignore
80
+ }
81
+ return false;
82
+ }
83
+ //# sourceMappingURL=detect-source-language.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-source-language.js","sourceRoot":"","sources":["../../src/utils/detect-source-language.ts"],"names":[],"mappings":";;AAsBA,sDAEC;AAkBD,oDA6BC;AAvED,qCAAqC;AACrC,yCAAiC;AAWjC,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC;IACnD,YAAY;IACZ,MAAM;IACN,gBAAgB;IAChB,IAAI;IACJ,GAAG;IACH,UAAU;IACV,SAAS;CACV,CAAC,CAAC;AAEH,SAAgB,qBAAqB,CAAC,KAAa;IACjD,OAAO,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,oBAAoB,CAAC,OAAe;IAClD,IACE,IAAA,oBAAU,EAAC,IAAA,gBAAI,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACrC,IAAA,oBAAU,EAAC,IAAA,gBAAI,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC,EACrC,CAAC;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,IAAI,IAAA,oBAAU,EAAC,IAAA,gBAAI,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC;QAC5C,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IACE,IAAA,oBAAU,EAAC,IAAA,gBAAI,EAAC,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;QACjD,IAA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MAAM,CAAC,EACtB,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,3 +1,33 @@
1
+ /** Gene source declares an async/Promise-returning express() — incompatible with Javy/QuickJS (#57). */
2
+ export declare class AsyncExpressError extends Error {
3
+ name: string;
4
+ }
5
+ /** TS→WASM toolchain (esbuild / javy) unavailable; message carries the full diagnosis (#58). */
6
+ export declare class ToolchainError extends Error {
7
+ name: string;
8
+ }
9
+ /**
10
+ * Detect an async/Promise-returning express() in gene source.
11
+ * Returns a human-readable description of the offending shape, or null if clean.
12
+ */
13
+ export declare function detectAsyncExpress(source: string): string | null;
14
+ type Command = string[];
15
+ export interface ToolchainStatus {
16
+ esbuild: Command | null;
17
+ javy: Command | null;
18
+ }
19
+ /** Resolve the TS→WASM toolchain without ever hitting the network. */
20
+ export declare function preflightToolchain(): ToolchainStatus;
21
+ /** Full diagnosis for a failed preflight: per-tool status, environment, exact fixes. */
22
+ /** Resolve the active `npx` path (impure: PATH lookup). Returns "not found" if absent. */
23
+ export declare function resolveActiveNpxPath(): string;
24
+ /** True when both tools resolved. */
25
+ export declare function toolchainOk(status: ToolchainStatus): boolean;
26
+ /** Per-tool status + environment, as report lines. Pure (no I/O — pass npxPath in). */
27
+ export declare function formatToolchainReport(status: ToolchainStatus, npxPath: string): string[];
28
+ export declare function buildToolchainErrorMessage(status: ToolchainStatus): string;
29
+ /** True when the gene source has been edited after the WASM was last compiled (#58). */
30
+ export declare function isWasmStale(wasmPath: string, sourcePath: string): boolean;
1
31
  export interface JavyCompileResult {
2
32
  wasmPath: string;
3
33
  bundleSize: number;
@@ -11,7 +41,7 @@ export interface JavyCompileResult {
11
41
  */
12
42
  export declare function compileTypeScriptToWasm(geneSrcPath: string, outputWasmPath: string): JavyCompileResult;
13
43
  /**
14
- * Check whether the Javy CLI is available.
44
+ * Check whether the Javy CLI is available (offline check; never hits the registry).
15
45
  */
16
46
  export declare function isJavyAvailable(): boolean;
17
47
  /**
@@ -19,4 +49,5 @@ export declare function isJavyAvailable(): boolean;
19
49
  * Returns the path to `index.ts` or `index.js` if found.
20
50
  */
21
51
  export declare function findGeneSource(geneDir: string): string | null;
52
+ export {};
22
53
  //# sourceMappingURL=javy-compiler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"javy-compiler.d.ts","sourceRoot":"","sources":["../../src/utils/javy-compiler.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACrB,iBAAiB,CA0CnB;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAOzC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM7D"}
1
+ {"version":3,"file":"javy-compiler.d.ts","sourceRoot":"","sources":["../../src/utils/javy-compiler.ts"],"names":[],"mappings":"AAKA,wGAAwG;AACxG,qBAAa,iBAAkB,SAAQ,KAAK;IACjC,IAAI,SAAuB;CACrC;AAED,gGAAgG;AAChG,qBAAa,cAAe,SAAQ,KAAK;IAC9B,IAAI,SAAoB;CAClC;AAUD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKhE;AAED,KAAK,OAAO,GAAG,MAAM,EAAE,CAAC;AA8BxB,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;CACtB;AAED,sEAAsE;AACtE,wBAAgB,kBAAkB,IAAI,eAAe,CAKpD;AAED,wFAAwF;AACxF,0FAA0F;AAC1F,wBAAgB,oBAAoB,IAAI,MAAM,CAQ7C;AAED,qCAAqC;AACrC,wBAAgB,WAAW,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAE5D;AAED,uFAAuF;AACvF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAOxF;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAS1E;AAED,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAOzE;AAcD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACrB,iBAAiB,CA6DnB;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM7D"}
@@ -33,6 +33,14 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ToolchainError = exports.AsyncExpressError = void 0;
37
+ exports.detectAsyncExpress = detectAsyncExpress;
38
+ exports.preflightToolchain = preflightToolchain;
39
+ exports.resolveActiveNpxPath = resolveActiveNpxPath;
40
+ exports.toolchainOk = toolchainOk;
41
+ exports.formatToolchainReport = formatToolchainReport;
42
+ exports.buildToolchainErrorMessage = buildToolchainErrorMessage;
43
+ exports.isWasmStale = isWasmStale;
36
44
  exports.compileTypeScriptToWasm = compileTypeScriptToWasm;
37
45
  exports.isJavyAvailable = isJavyAvailable;
38
46
  exports.findGeneSource = findGeneSource;
@@ -40,6 +48,114 @@ const node_child_process_1 = require("node:child_process");
40
48
  const node_fs_1 = require("node:fs");
41
49
  const node_path_1 = require("node:path");
42
50
  const display = __importStar(require("./display.js"));
51
+ /** Gene source declares an async/Promise-returning express() — incompatible with Javy/QuickJS (#57). */
52
+ class AsyncExpressError extends Error {
53
+ name = "AsyncExpressError";
54
+ }
55
+ exports.AsyncExpressError = AsyncExpressError;
56
+ /** TS→WASM toolchain (esbuild / javy) unavailable; message carries the full diagnosis (#58). */
57
+ class ToolchainError extends Error {
58
+ name = "ToolchainError";
59
+ }
60
+ exports.ToolchainError = ToolchainError;
61
+ // High-confidence shapes only — the runtime guard in WASI_SHIM_FOOTER backstops
62
+ // anything the static patterns miss (e.g. a sync express() returning a Promise value).
63
+ const ASYNC_EXPRESS_PATTERNS = [
64
+ [/\basync\s+function\s+express\b/, "async function express"],
65
+ [/\bexpress\s*=\s*async\b/, "express = async (…)"],
66
+ [/\bfunction\s+express\s*\([^)]*\)\s*:\s*Promise\s*</, "express() declared to return Promise<…>"],
67
+ ];
68
+ /**
69
+ * Detect an async/Promise-returning express() in gene source.
70
+ * Returns a human-readable description of the offending shape, or null if clean.
71
+ */
72
+ function detectAsyncExpress(source) {
73
+ for (const [pattern, label] of ASYNC_EXPRESS_PATTERNS) {
74
+ if (pattern.test(source))
75
+ return label;
76
+ }
77
+ return null;
78
+ }
79
+ // Bare binaries first: a PATH lookup is instant (covers global installs and
80
+ // node_modules/.bin when invoked via npm scripts). `npx --no-install` is the
81
+ // fallback for project-local installs — it never touches the npm registry, so a
82
+ // missing tool fails fast instead of hanging on a blocked proxy (#58:
83
+ // `spawnSync npx ETIMEDOUT`). javy-cli@3 installs its binary as `javy`.
84
+ const ESBUILD_CANDIDATES = [["esbuild"], ["npx", "--no-install", "esbuild"]];
85
+ const JAVY_CANDIDATES = [
86
+ ["javy"],
87
+ ["npx", "--no-install", "javy-cli"],
88
+ ["npx", "--no-install", "javy"],
89
+ ];
90
+ function canRun(command) {
91
+ try {
92
+ (0, node_child_process_1.execFileSync)(command[0], [...command.slice(1), "--version"], { stdio: "pipe", timeout: 10_000 });
93
+ return true;
94
+ }
95
+ catch {
96
+ return false;
97
+ }
98
+ }
99
+ function resolveCommand(candidates) {
100
+ for (const candidate of candidates) {
101
+ if (canRun(candidate))
102
+ return candidate;
103
+ }
104
+ return null;
105
+ }
106
+ /** Resolve the TS→WASM toolchain without ever hitting the network. */
107
+ function preflightToolchain() {
108
+ return {
109
+ esbuild: resolveCommand(ESBUILD_CANDIDATES),
110
+ javy: resolveCommand(JAVY_CANDIDATES),
111
+ };
112
+ }
113
+ /** Full diagnosis for a failed preflight: per-tool status, environment, exact fixes. */
114
+ /** Resolve the active `npx` path (impure: PATH lookup). Returns "not found" if absent. */
115
+ function resolveActiveNpxPath() {
116
+ try {
117
+ return (0, node_child_process_1.execFileSync)(process.platform === "win32" ? "where" : "which", ["npx"], {
118
+ stdio: "pipe", timeout: 5_000,
119
+ }).toString().trim().split("\n")[0];
120
+ }
121
+ catch {
122
+ return "not found";
123
+ }
124
+ }
125
+ /** True when both tools resolved. */
126
+ function toolchainOk(status) {
127
+ return status.esbuild !== null && status.javy !== null;
128
+ }
129
+ /** Per-tool status + environment, as report lines. Pure (no I/O — pass npxPath in). */
130
+ function formatToolchainReport(status, npxPath) {
131
+ return [
132
+ ` esbuild: ${status.esbuild ? "ok (" + status.esbuild.join(" ") + ")" : "missing (tried: esbuild on PATH, npx --no-install esbuild)"}`,
133
+ ` javy: ${status.javy ? "ok (" + status.javy.join(" ") + ")" : "missing (tried: javy on PATH, npx --no-install javy-cli / javy)"}`,
134
+ ` active npx: ${npxPath}`,
135
+ ` node: ${process.execPath}`,
136
+ ];
137
+ }
138
+ function buildToolchainErrorMessage(status) {
139
+ return [
140
+ "TypeScript → WASM toolchain unavailable:",
141
+ ...formatToolchainReport(status, resolveActiveNpxPath()),
142
+ "",
143
+ "Install: npm i -g esbuild javy-cli (javy-cli installs a binary named `javy` — both are detected)",
144
+ "If already installed: make sure the Node prefix that owns `rotifer` is first in PATH;",
145
+ "an `npx` from another Node installation may try the npm registry and time out behind a proxy.",
146
+ ].join("\n");
147
+ }
148
+ /** True when the gene source has been edited after the WASM was last compiled (#58). */
149
+ function isWasmStale(wasmPath, sourcePath) {
150
+ if (!(0, node_fs_1.existsSync)(wasmPath) || !(0, node_fs_1.existsSync)(sourcePath))
151
+ return false;
152
+ try {
153
+ return (0, node_fs_1.statSync)(sourcePath).mtimeMs > (0, node_fs_1.statSync)(wasmPath).mtimeMs;
154
+ }
155
+ catch {
156
+ return false;
157
+ }
158
+ }
43
159
  const WASI_SHIM_HEADER = `\
44
160
  function __readStdin(){var s=1024,c=[],t=0;while(1){var b=new Uint8Array(s);var r=Javy.IO.readSync(0,b);t+=r;if(r===0)break;c.push(b.subarray(0,r))}var o=new Uint8Array(t);var p=0;for(var i=0;i<c.length;i++){o.set(c[i],p);p+=c[i].length}return JSON.parse(new TextDecoder().decode(o))}
45
161
  function __writeStdout(v){var b=new TextEncoder().encode(JSON.stringify(v));Javy.IO.writeSync(1,b)}
@@ -47,6 +163,7 @@ function __writeStdout(v){var b=new TextEncoder().encode(JSON.stringify(v));Javy
47
163
  const WASI_SHIM_FOOTER = `\
48
164
  var __input=__readStdin();
49
165
  var __result=__gene.express(__input);
166
+ if(__result&&typeof __result.then==="function"){throw new Error("Async express() is not supported in Javy/WASM runtime; use a synchronous gene or run without sandbox")}
50
167
  __writeStdout(__result);
51
168
  `;
52
169
  /**
@@ -56,14 +173,28 @@ __writeStdout(__result);
56
173
  */
57
174
  function compileTypeScriptToWasm(geneSrcPath, outputWasmPath) {
58
175
  const startTime = Date.now();
176
+ // #57: fail at compile time with an actionable message — the runtime guard's
177
+ // error is thrown inside QuickJS and surfaces as an opaque WASM backtrace.
178
+ const asyncShape = detectAsyncExpress((0, node_fs_1.readFileSync)(geneSrcPath, "utf-8"));
179
+ if (asyncShape) {
180
+ throw new AsyncExpressError(`Native (Javy/QuickJS) WASM Genes must export a synchronous express(input) — ` +
181
+ `found ${asyncShape} in ${geneSrcPath}. Make express() synchronous, or keep it ` +
182
+ `async and run via Node (--no-sandbox) / a Hybrid Gene for async I/O.`);
183
+ }
184
+ // #58: preflight the toolchain offline; a missing tool gets a diagnosis instead
185
+ // of `spawnSync npx ETIMEDOUT` from npx hitting the registry through a proxy.
186
+ const toolchain = preflightToolchain();
187
+ if (!toolchain.esbuild || !toolchain.javy) {
188
+ throw new ToolchainError(buildToolchainErrorMessage(toolchain));
189
+ }
59
190
  const tmpDir = (0, node_path_1.join)((0, node_path_1.dirname)(outputWasmPath), ".rotifer-build");
60
191
  (0, node_fs_1.mkdirSync)(tmpDir, { recursive: true });
61
192
  const bundlePath = (0, node_path_1.join)(tmpDir, "bundle.js");
62
193
  const shimPath = (0, node_path_1.join)(tmpDir, "gene-shim.js");
63
194
  try {
64
195
  display.info(" Step 1/3: TypeScript → JavaScript (esbuild)");
65
- (0, node_child_process_1.execFileSync)("npx", [
66
- "esbuild", geneSrcPath,
196
+ (0, node_child_process_1.execFileSync)(toolchain.esbuild[0], [
197
+ ...toolchain.esbuild.slice(1), geneSrcPath,
67
198
  "--bundle", "--format=iife", "--global-name=__gene",
68
199
  `--outfile=${bundlePath}`, "--log-level=warning",
69
200
  ], { stdio: "pipe", timeout: 30_000 });
@@ -74,8 +205,8 @@ function compileTypeScriptToWasm(geneSrcPath, outputWasmPath) {
74
205
  const shimCode = WASI_SHIM_HEADER + bundleCode + "\n" + WASI_SHIM_FOOTER;
75
206
  (0, node_fs_1.writeFileSync)(shimPath, shimCode);
76
207
  display.info(" Step 3/3: JavaScript → WASM (Javy / QuickJS)");
77
- (0, node_child_process_1.execFileSync)("npx", [
78
- "javy-cli", "compile", shimPath, "-o", outputWasmPath,
208
+ (0, node_child_process_1.execFileSync)(toolchain.javy[0], [
209
+ ...toolchain.javy.slice(1), "compile", shimPath, "-o", outputWasmPath,
79
210
  ], { stdio: "pipe", timeout: 60_000 });
80
211
  const wasmSize = (0, node_fs_1.readFileSync)(outputWasmPath).length;
81
212
  const durationMs = Date.now() - startTime;
@@ -98,16 +229,10 @@ function compileTypeScriptToWasm(geneSrcPath, outputWasmPath) {
98
229
  }
99
230
  }
100
231
  /**
101
- * Check whether the Javy CLI is available.
232
+ * Check whether the Javy CLI is available (offline check; never hits the registry).
102
233
  */
103
234
  function isJavyAvailable() {
104
- try {
105
- (0, node_child_process_1.execFileSync)("npx", ["javy-cli", "--version"], { stdio: "pipe", timeout: 30_000 });
106
- return true;
107
- }
108
- catch {
109
- return false;
110
- }
235
+ return resolveCommand(JAVY_CANDIDATES) !== null;
111
236
  }
112
237
  /**
113
238
  * Detect the gene source file in a gene directory.
@@ -1 +1 @@
1
- {"version":3,"file":"javy-compiler.js","sourceRoot":"","sources":["../../src/utils/javy-compiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,0DA6CC;AAKD,0CAOC;AAMD,wCAMC;AAjGD,2DAAkD;AAClD,qCAAyF;AACzF,yCAA0C;AAC1C,sDAAwC;AAExC,MAAM,gBAAgB,GAAG;;;CAGxB,CAAC;AAEF,MAAM,gBAAgB,GAAG;;;;CAIxB,CAAC;AASF;;;;GAIG;AACH,SAAgB,uBAAuB,CACrC,WAAmB,EACnB,cAAsB;IAEtB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,IAAA,gBAAI,EAAC,IAAA,mBAAO,EAAC,cAAc,CAAC,EAAE,gBAAgB,CAAC,CAAC;IAC/D,IAAA,mBAAS,EAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEvC,MAAM,UAAU,GAAG,IAAA,gBAAI,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC7C,MAAM,QAA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AC;QAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;QACtD,IAAI,CAAC;YAAC,IAAA,oBAAU,EAAC,QAAQ,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;QACpD,IAAI,CAAC;YAAC,OAAO,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;IACtE,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe;IAC7B,OAAO,cAAc,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,SAAgB,cAAc,CAAC,OAAe;IAC5C,KAAK,MAAM,IAAI,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,CAAC;QAC5C,MAAM,CAAC,GAAG,IAAA,gBAAI,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC9B,IAAI,IAAA,oBAAU,EAAC,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,30 @@
1
+ export interface DaemonState {
2
+ pid: number;
3
+ /** Loopback control-server port (OS-assigned). */
4
+ port: number;
5
+ /** Per-daemon bearer token for the control endpoints. */
6
+ token: string;
7
+ peerId: string;
8
+ startedAt: number;
9
+ }
10
+ export declare function readDaemonState(): DaemonState | null;
11
+ export declare function clearDaemonState(): void;
12
+ export interface ControlResult {
13
+ ok: boolean;
14
+ status: number;
15
+ body: unknown;
16
+ }
17
+ /**
18
+ * Send a control request to the running daemon. Returns null when no daemon is
19
+ * recorded or it is unreachable (so callers can report "not running").
20
+ */
21
+ export declare function controlRequest(method: string, path: string, body?: unknown): Promise<ControlResult | null>;
22
+ /** Whether a daemon is recorded and answering its control server. */
23
+ export declare function isDaemonRunning(): Promise<boolean>;
24
+ /**
25
+ * Run the daemon: start the libp2p node, expose a token-gated loopback control
26
+ * server, record the state file, and stay alive until stopped. Called from the
27
+ * hidden `network __daemon` subcommand in a detached process.
28
+ */
29
+ export declare function runDaemon(listenHost: string, listenPort: number, bootstrapPeers: string[]): Promise<void>;
30
+ //# sourceMappingURL=p2p-daemon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"p2p-daemon.d.ts","sourceRoot":"","sources":["../../src/utils/p2p-daemon.ts"],"names":[],"mappings":"AA4BA,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,eAAe,IAAI,WAAW,GAAG,IAAI,CAOpD;AAQD,wBAAgB,gBAAgB,IAAI,IAAI,CAMvC;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,GACb,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CA6C/B;AAED,qEAAqE;AACrE,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAGxD;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAC7B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EAAE,GACvB,OAAO,CAAC,IAAI,CAAC,CAwFf"}