@powerhousedao/reactor-workflow 6.2.3-dev.49 → 6.2.3-dev.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/reactor-workflow",
3
- "version": "6.2.3-dev.49",
3
+ "version": "6.2.3-dev.50",
4
4
  "license": "AGPL-3.0-only",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -29,16 +29,22 @@
29
29
  "./package.json": "./package.json"
30
30
  },
31
31
  "dependencies": {
32
- "@powerhousedao/pieces-framework": "6.2.3-dev.49",
33
- "@powerhousedao/reactor": "6.2.3-dev.49",
34
- "@powerhousedao/shared": "6.2.3-dev.49",
35
- "@powerhousedao/workflow": "6.2.3-dev.49",
32
+ "@opentelemetry/api": "^1.9.1",
33
+ "@powerhousedao/pieces-framework": "6.2.3-dev.50",
34
+ "@powerhousedao/reactor": "6.2.3-dev.50",
35
+ "@powerhousedao/shared": "6.2.3-dev.50",
36
+ "@powerhousedao/workflow": "6.2.3-dev.50",
36
37
  "croner": "10.0.1",
37
- "document-model": "6.2.3-dev.49",
38
+ "document-model": "6.2.3-dev.50",
38
39
  "graphql": "^16"
39
40
  },
40
41
  "devDependencies": {
41
42
  "@electric-sql/pglite": "0.3.15",
43
+ "@opentelemetry/context-async-hooks": "^2.7.1",
44
+ "@opentelemetry/exporter-trace-otlp-http": "^0.218.0",
45
+ "@opentelemetry/resources": "^2.7.1",
46
+ "@opentelemetry/sdk-metrics": "^2.7.1",
47
+ "@opentelemetry/sdk-trace-base": "^2.7.1",
42
48
  "@types/node": "25.2.3",
43
49
  "@types/pg": "8.16.0",
44
50
  "knex": "3.1.0",
@@ -47,7 +53,7 @@
47
53
  "kysely-knex": "0.2.0",
48
54
  "pg": "8.18.0",
49
55
  "tsdown": "0.23.0",
50
- "vitest": "4.1.1"
56
+ "vitest": "5.0.3"
51
57
  },
52
58
  "description": "The Powerhouse workflow engine: the reactor-side runtime that runs workflow documents, and the piece loader, worker pool and executor beneath it.",
53
59
  "keywords": [
@@ -63,6 +69,8 @@
63
69
  "lint": "cd ../.. && oxlint packages/reactor-workflow",
64
70
  "test": "vitest --run",
65
71
  "test:watch": "vitest",
66
- "build": "tsdown"
72
+ "build": "tsdown",
73
+ "bench": "node bench/run.ts",
74
+ "bench:profile": "node bench/profile-summary.ts"
67
75
  }
68
76
  }
@@ -1,91 +0,0 @@
1
- import { createRequire } from "node:module";
2
- import { readFileSync, realpathSync } from "node:fs";
3
- import path from "node:path";
4
- import { pathToFileURL } from "node:url";
5
- //#region src/pieces/activepieces/loader.ts
6
- function resolveEntry(pieceDir) {
7
- const raw = readFileSync(path.join(pieceDir, "package.json"), "utf8");
8
- const pkg = JSON.parse(raw);
9
- const dotExport = pkg.exports?.["."];
10
- const candidates = [];
11
- if (typeof dotExport === "string") candidates.push(dotExport);
12
- if (dotExport && typeof dotExport === "object") {
13
- const cond = dotExport;
14
- for (const key of [
15
- "import",
16
- "require",
17
- "default"
18
- ]) {
19
- const value = cond[key];
20
- if (typeof value === "string") candidates.push(value);
21
- }
22
- }
23
- candidates.push(pkg.main, pkg.module, "src/index.js", "index.js", "main.js");
24
- const root = realpathSync(pieceDir);
25
- const rootWithSep = root + path.sep;
26
- for (const candidate of candidates) {
27
- if (!candidate) continue;
28
- const abs = path.resolve(pieceDir, candidate);
29
- let real;
30
- try {
31
- real = realpathSync(abs);
32
- } catch {
33
- continue;
34
- }
35
- if (real !== root && !real.startsWith(rootWithSep)) continue;
36
- return abs;
37
- }
38
- throw new Error(`No entry file found for piece bundle at ${pieceDir}`);
39
- }
40
- function isRecord(value) {
41
- return typeof value === "object" && value !== null;
42
- }
43
- function findPiece(mod) {
44
- const candidates = [
45
- ...Object.values(mod),
46
- ...isRecord(mod.default) ? Object.values(mod.default) : [],
47
- mod.default
48
- ];
49
- for (const candidate of candidates) if (isRecord(candidate) && candidate.constructor?.name === "Piece") return {
50
- piece: candidate,
51
- check: "constructor-name"
52
- };
53
- for (const candidate of candidates) if (isRecord(candidate) && typeof candidate.displayName === "string" && (isRecord(candidate.actions) || typeof candidate.actions === "function" || typeof candidate.getAction === "function")) return {
54
- piece: candidate,
55
- check: "structural"
56
- };
57
- }
58
- function missingModule(entryPath, error) {
59
- const code = error?.code;
60
- if (code !== "ERR_MODULE_NOT_FOUND" && code !== "MODULE_NOT_FOUND") return;
61
- const detail = error instanceof Error ? error.message : String(error);
62
- return /* @__PURE__ */ new Error(`Piece at ${entryPath} could not be loaded: it imports a module that is not there. Its dependencies are installed with lifecycle scripts disabled, so one that compiles or downloads on install -- a native addon, a browser download -- cannot be prepared here. ${detail}`);
63
- }
64
- async function loadPiece(entryPath) {
65
- let mod;
66
- try {
67
- mod = await import(
68
- /* @vite-ignore */
69
- pathToFileURL(entryPath).href
70
- );
71
- } catch (imported) {
72
- try {
73
- mod = createRequire(import.meta.url)(entryPath);
74
- } catch (required) {
75
- throw missingModule(entryPath, imported) ?? missingModule(entryPath, required) ?? required;
76
- }
77
- }
78
- const found = findPiece(mod);
79
- if (!found) throw new Error(`No Piece export found in ${entryPath}. Export keys: ${Object.keys(mod).join(", ")}`);
80
- return {
81
- ...found,
82
- entryPath
83
- };
84
- }
85
- async function loadPieceFromDir(pieceDir) {
86
- return loadPiece(resolveEntry(pieceDir));
87
- }
88
- //#endregion
89
- export { loadPieceFromDir as n, loadPiece as t };
90
-
91
- //# sourceMappingURL=loader-Gkx6I_Bo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loader-Gkx6I_Bo.js","names":[],"sources":["../src/pieces/activepieces/loader.ts"],"sourcesContent":["import { readFileSync, realpathSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { ApPiece } from \"./types.js\";\n\nexport interface LoadedPiece {\n piece: ApPiece;\n entryPath: string;\n // Which duck-type check identified the export.\n check: \"constructor-name\" | \"structural\";\n}\n\n// Resolves a bundle's entry file. Published bundles typically carry only\n// `main` (no `exports`, no `type` — they are CJS).\nexport function resolveEntry(pieceDir: string): string {\n const raw = readFileSync(path.join(pieceDir, \"package.json\"), \"utf8\");\n const pkg = JSON.parse(raw) as {\n main?: string;\n module?: string;\n exports?: Record<string, unknown>;\n };\n const dotExport = pkg.exports?.[\".\"];\n const candidates: (string | undefined)[] = [];\n if (typeof dotExport === \"string\") candidates.push(dotExport);\n if (dotExport && typeof dotExport === \"object\") {\n const cond = dotExport as Record<string, unknown>;\n for (const key of [\"import\", \"require\", \"default\"]) {\n const value = cond[key];\n if (typeof value === \"string\") candidates.push(value);\n }\n }\n candidates.push(pkg.main, pkg.module, \"src/index.js\", \"index.js\", \"main.js\");\n // A bundle's manifest (or a symlink inside it) must not point the entry\n // outside pieceDir; realpath so a symlink can't launder the escape.\n const root = realpathSync(pieceDir);\n const rootWithSep = root + path.sep;\n for (const candidate of candidates) {\n if (!candidate) continue;\n const abs = path.resolve(pieceDir, candidate);\n let real: string;\n try {\n real = realpathSync(abs);\n } catch {\n continue; // candidate doesn't exist; try the next one\n }\n if (real !== root && !real.startsWith(rootWithSep)) continue;\n return abs;\n }\n throw new Error(`No entry file found for piece bundle at ${pieceDir}`);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\n// Identify the piece by constructor name (their own loader's check), falling\n// back to structure for bundles minified without keepNames. No `instanceof`.\nfunction findPiece(\n mod: Record<string, unknown>,\n): Pick<LoadedPiece, \"piece\" | \"check\"> | undefined {\n const candidates: unknown[] = [\n ...Object.values(mod),\n ...(isRecord(mod.default) ? Object.values(mod.default) : []),\n mod.default,\n ];\n for (const candidate of candidates) {\n // `constructor?.name`: a bundle may export an Object.create(null), and the\n // real piece is usually beside it in the same module.\n if (isRecord(candidate) && candidate.constructor?.name === \"Piece\") {\n return {\n piece: candidate as unknown as ApPiece,\n check: \"constructor-name\",\n };\n }\n }\n for (const candidate of candidates) {\n if (\n isRecord(candidate) &&\n typeof candidate.displayName === \"string\" &&\n (isRecord(candidate.actions) ||\n typeof candidate.actions === \"function\" ||\n typeof candidate.getAction === \"function\")\n ) {\n return { piece: candidate as unknown as ApPiece, check: \"structural\" };\n }\n }\n return undefined;\n}\n\n// A module the piece names and node cannot find. Dependencies are installed\n// with scripts disabled, so a native or downloaded one looks like this.\nfunction missingModule(entryPath: string, error: unknown): Error | undefined {\n const code = (error as { code?: unknown } | null)?.code;\n if (code !== \"ERR_MODULE_NOT_FOUND\" && code !== \"MODULE_NOT_FOUND\") {\n return undefined;\n }\n const detail = error instanceof Error ? error.message : String(error);\n return new Error(\n `Piece at ${entryPath} could not be loaded: it imports a module that is ` +\n `not there. Its dependencies are installed with lifecycle scripts ` +\n `disabled, so one that compiles or downloads on install -- a native ` +\n `addon, a browser download -- cannot be prepared here. ${detail}`,\n );\n}\n\n// ESM-first `import()` — Node's CJS interop handles the typical CJS bundle —\n// with a `require` fallback.\nexport async function loadPiece(entryPath: string): Promise<LoadedPiece> {\n let mod: Record<string, unknown>;\n try {\n mod = (await import(\n /* @vite-ignore */ pathToFileURL(entryPath).href\n )) as Record<string, unknown>;\n } catch (imported) {\n try {\n const require = createRequire(import.meta.url);\n mod = require(entryPath) as Record<string, unknown>;\n } catch (required) {\n // The import's error names the missing module; require's often names\n // only the entry it was handed.\n throw (\n missingModule(entryPath, imported) ??\n missingModule(entryPath, required) ??\n required\n );\n }\n }\n const found = findPiece(mod);\n if (!found) {\n throw new Error(\n `No Piece export found in ${entryPath}. Export keys: ${Object.keys(mod).join(\", \")}`,\n );\n }\n return { ...found, entryPath };\n}\n\nexport async function loadPieceFromDir(pieceDir: string): Promise<LoadedPiece> {\n return loadPiece(resolveEntry(pieceDir));\n}\n"],"mappings":";;;;;AAeA,SAAgB,aAAa,UAA0B;CACrD,MAAM,MAAM,aAAa,KAAK,KAAK,UAAU,cAAc,GAAG,MAAM;CACpE,MAAM,MAAM,KAAK,MAAM,GAAG;CAK1B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