@powerhousedao/reactor-workflow 6.2.3-dev.79 → 6.2.3-dev.81

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/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as sourcedResolver, D as PackagePiece, E as LocalPiece, L as PieceDescriptor, M as RecordedSchedule, N as extractDedupeKey, O as PieceResolver, R as buildDescriptor, a as runWorkflow, c as CompositeBlockExecutor, d as InMemorySecretProvider, g as PieceWorker, k as PieceTarget, m as IPieceWorker, o as ActivepiecesBlockExecutor, p as PieceWorkerPool, s as AttachmentPort, t as PieceRegistry, u as StaticConnectionResolver, w as WorkflowRunResult, x as BlockExecution, y as WorkflowTelemetry, z as loadPieceFromDir } from "./piece-registry-BbeuE8TB.js";
1
+ import { A as PieceTarget, B as loadPieceFromDir, D as LocalPiece, N as RecordedSchedule, O as PackagePiece, P as extractDedupeKey, R as PieceDescriptor, S as BlockExecution, T as WorkflowRunResult, _ as PieceWorker, a as runWorkflow, b as WorkflowTelemetry, c as CompositeBlockExecutor, d as InMemorySecretProvider, h as IPieceWorker, j as sourcedResolver, k as PieceResolver, m as PieceWorkerPool, o as ActivepiecesBlockExecutor, s as AttachmentPort, t as PieceRegistry, u as StaticConnectionResolver, z as buildDescriptor } from "./piece-registry-ByALLpvA.js";
2
2
  //#region src/pieces/activepieces/fetch.d.ts
3
3
  interface FetchPieceBundleOptions {
4
4
  name: string;
package/dist/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import { G as PieceWorkerPool, K as PieceWorker, M as StaticConnectionResolver, R as InMemorySecretProvider, a as PieceRegistry, d as runWorkflow, gt as fetchPieceBundle, ht as ensurePieceBundle, it as extractDedupeKey, lt as sourcedResolver, n as WorkflowTelemetry, ut as buildDescriptor, v as ActivepiecesBlockExecutor, y as CompositeBlockExecutor } from "./telemetry-CJd29LsN.js";
1
+ import { J as PieceWorker, M as StaticConnectionResolver, R as InMemorySecretProvider, _t as ensurePieceBundle, a as PieceRegistry, d as runWorkflow, dt as sourcedResolver, ft as buildDescriptor, n as WorkflowTelemetry, ot as extractDedupeKey, q as PieceWorkerPool, v as ActivepiecesBlockExecutor, vt as fetchPieceBundle, y as CompositeBlockExecutor } from "./telemetry-DE0ALzOJ.js";
2
2
  import { createRequire } from "node:module";
3
3
  import { readFileSync, realpathSync } from "node:fs";
4
4
  import path from "node:path";
@@ -13,6 +13,7 @@ import dgram from "node:dgram";
13
13
  import dns from "node:dns";
14
14
  import net, { isIP } from "node:net";
15
15
  import { AsyncLocalStorage } from "node:async_hooks";
16
+ import tls from "node:tls";
16
17
  //#region \0rolldown/runtime.js
17
18
  var __create = Object.create;
18
19
  var __defProp = Object.defineProperty;
@@ -618,6 +619,21 @@ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
618
619
  };
619
620
  };
620
621
  const safeParseAsync = /* @__PURE__*/ _safeParseAsync($ZodRealError);
622
+ const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
623
+ function timeSource(args) {
624
+ const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
625
+ return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : args.seconds ? `${hhmm}:[0-5]\\d(?:\\.\\d+)?` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
626
+ }
627
+ function datetime$1(args) {
628
+ const opts = ["Z"];
629
+ if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
630
+ const qualified = `${timeSource({
631
+ precision: args.precision,
632
+ seconds: true
633
+ })}(?:${opts.join("|")})`;
634
+ const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
635
+ return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
636
+ }
621
637
  const anyString = /^[\s\S]{0,}$/;
622
638
  const number$2 = /^-?\d+(?:\.\d+)?$/;
623
639
  const boolean$1 = /^(?:true|false)$/i;
@@ -827,6 +843,14 @@ const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
827
843
  return payload;
828
844
  };
829
845
  });
846
+ const $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (inst, def) => {
847
+ $ZodCheckStringFormat.init(inst, def);
848
+ $ZodString.init(inst, def);
849
+ });
850
+ const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
851
+ def.pattern ?? (def.pattern = datetime$1(def));
852
+ $ZodStringFormat.init(inst, def);
853
+ });
830
854
  const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
831
855
  $ZodType.init(inst, def);
832
856
  inst._zod.pattern = number$2;
@@ -1430,6 +1454,18 @@ function _string(Class, params) {
1430
1454
  }));
1431
1455
  }
1432
1456
  // @__NO_SIDE_EFFECTS__
1457
+ function _isoDateTime(Class, params) {
1458
+ return new Class({
1459
+ type: "string",
1460
+ format: "datetime",
1461
+ check: "string_format",
1462
+ offset: false,
1463
+ local: false,
1464
+ precision: null,
1465
+ ...normalizeParams(params)
1466
+ });
1467
+ }
1468
+ // @__NO_SIDE_EFFECTS__
1433
1469
  function _number(Class, params) {
1434
1470
  return new Class(snapshotChecks({
1435
1471
  type: "number",
@@ -1487,6 +1523,15 @@ function _custom(Class, fn, _params) {
1487
1523
  ...norm
1488
1524
  });
1489
1525
  }
1526
+ // @__NO_SIDE_EFFECTS__
1527
+ function _refine(Class, fn, _params) {
1528
+ return new Class({
1529
+ type: "custom",
1530
+ check: "custom",
1531
+ fn,
1532
+ ...normalizeParams(_params)
1533
+ });
1534
+ }
1490
1535
  //#endregion
1491
1536
  //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/mini/schemas.js
1492
1537
  const ZodMiniType = /*@__PURE__*/ $constructor("ZodMiniType", (inst, def) => {
@@ -1546,6 +1591,10 @@ const ZodMiniString = /*@__PURE__*/ $constructor("ZodMiniString", (inst, def) =>
1546
1591
  function string(params) {
1547
1592
  return /* @__PURE__ */ _string(ZodMiniString, params);
1548
1593
  }
1594
+ const ZodMiniStringFormat = /*@__PURE__*/ $constructor("ZodMiniStringFormat", (inst, def) => {
1595
+ $ZodStringFormat.init(inst, def);
1596
+ ZodMiniString.init(inst, def);
1597
+ });
1549
1598
  const ZodMiniNumber = /*@__PURE__*/ $constructor("ZodMiniNumber", (inst, def) => {
1550
1599
  $ZodNumber.init(inst, def);
1551
1600
  ZodMiniType.init(inst, def);
@@ -1722,6 +1771,20 @@ const ZodMiniCustom = /*@__PURE__*/ $constructor("ZodMiniCustom", (inst, def) =>
1722
1771
  function custom(fn, _params) {
1723
1772
  return /* @__PURE__ */ _custom(ZodMiniCustom, fn ?? (() => true), _params);
1724
1773
  }
1774
+ // @__NO_SIDE_EFFECTS__
1775
+ function refine(fn, _params = {}) {
1776
+ return /* @__PURE__ */ _refine(ZodMiniCustom, fn, _params);
1777
+ }
1778
+ //#endregion
1779
+ //#region ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/mini/iso.js
1780
+ const ZodMiniISODateTime = /*@__PURE__*/ $constructor("ZodMiniISODateTime", (inst, def) => {
1781
+ $ZodISODateTime.init(inst, def);
1782
+ ZodMiniStringFormat.init(inst, def);
1783
+ });
1784
+ // @__NO_SIDE_EFFECTS__
1785
+ function datetime(params) {
1786
+ return /* @__PURE__ */ _isoDateTime(ZodMiniISODateTime, params);
1787
+ }
1725
1788
  //#endregion
1726
1789
  //#region ../pieces-framework/dist/markdown-property-DMfHjEiL.js
1727
1790
  const BasePropertySchema = /* @__PURE__ */ object({
@@ -2307,6 +2370,7 @@ const BaseModelSchema = {
2307
2370
  updated: DateOrString
2308
2371
  };
2309
2372
  const Nullable = (schema) => /* @__PURE__ */ optional$1(/* @__PURE__ */ nullable(schema));
2373
+ (/* @__PURE__ */ datetime({ offset: true })).check(/* @__PURE__ */ refine((val) => val.slice(0, 4) !== "0000"));
2310
2374
  let ToolCallStatus = /* @__PURE__ */ function(ToolCallStatus) {
2311
2375
  ToolCallStatus["IN_PROGRESS"] = "in-progress";
2312
2376
  ToolCallStatus["COMPLETED"] = "completed";
@@ -5779,6 +5843,27 @@ function declaredPorts(ports) {
5779
5843
  function declaredReactor(value) {
5780
5844
  return value === "read" || value === "write" ? value : void 0;
5781
5845
  }
5846
+ function declaredTimeout(value) {
5847
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
5848
+ }
5849
+ function declaredRetry(value) {
5850
+ if (typeof value !== "object" || value === null) return void 0;
5851
+ const record = value;
5852
+ const attempts = record.maxAttempts;
5853
+ if (typeof attempts !== "number" || !Number.isInteger(attempts)) return;
5854
+ if (attempts < 1) return void 0;
5855
+ const seconds = (key) => typeof record[key] === "number" && Number.isFinite(record[key]) ? { [key]: record[key] } : {};
5856
+ return {
5857
+ maxAttempts: attempts,
5858
+ ...record.backoff === "FIXED" || record.backoff === "EXPONENTIAL" ? { backoff: record.backoff } : {},
5859
+ ...seconds("initialDelaySeconds"),
5860
+ ...seconds("maxDelaySeconds"),
5861
+ ...Array.isArray(record.retryOn) ? { retryOn: record.retryOn.filter((entry) => typeof entry === "string") } : {}
5862
+ };
5863
+ }
5864
+ function suggestedRetry(options) {
5865
+ return options?.retryOnFailure?.defaultValue === true ? { maxAttempts: 3 } : void 0;
5866
+ }
5782
5867
  function buildDescriptor(piece, source, options = {}) {
5783
5868
  const actions = Object.entries(getActions(piece)).map(([actionName, action]) => ({
5784
5869
  name: action.name ?? actionName,
@@ -5786,6 +5871,8 @@ function buildDescriptor(piece, source, options = {}) {
5786
5871
  description: action.description,
5787
5872
  requireAuth: action.requireAuth ?? false,
5788
5873
  ...optional("requireReactor", declaredReactor(action.requireReactor)),
5874
+ ...optional("defaultTimeoutSeconds", declaredTimeout(action.defaultTimeoutSeconds)),
5875
+ ...optional("defaultRetry", declaredRetry(action.defaultRetry) ?? suggestedRetry(action.errorHandlingOptions)),
5789
5876
  ports: (options.routed ? declaredPorts(action.ports) : void 0) ?? PIECE_ACTION_PORTS,
5790
5877
  props: describeProperties(action.props, (propName) => `activepieces:${source.packageName}#${actionName}.${propName}`),
5791
5878
  ...action.outputSchema !== void 0 ? { outputSchema: action.outputSchema } : {},
@@ -6186,6 +6273,30 @@ function installEgressGuard() {
6186
6273
  refuseResolvers(dns.promises.Resolver.prototype, true);
6187
6274
  }
6188
6275
  //#endregion
6276
+ //#region src/pieces/activepieces/worker/tls-guard.ts
6277
+ /** Defaults rejectUnauthorized to true on every tls.connect; returns the undo. */
6278
+ function installTlsGuard() {
6279
+ const original = tls.connect;
6280
+ const guarded = function(...args) {
6281
+ const index = args.findIndex((a) => a !== null && typeof a === "object" && !Array.isArray(a));
6282
+ if (index === -1) {
6283
+ const at = args.findIndex((a) => typeof a === "function");
6284
+ args.splice(at === -1 ? args.length : at, 0, { rejectUnauthorized: true });
6285
+ } else {
6286
+ const options = args[index];
6287
+ if (options.rejectUnauthorized === void 0) args[index] = {
6288
+ ...options,
6289
+ rejectUnauthorized: true
6290
+ };
6291
+ }
6292
+ return original.apply(this, args);
6293
+ };
6294
+ tls.connect = guarded;
6295
+ return () => {
6296
+ if (tls.connect === guarded) tls.connect = original;
6297
+ };
6298
+ }
6299
+ //#endregion
6189
6300
  //#region src/pieces/activepieces/worker/timings.ts
6190
6301
  const ANCHOR_MS = 1e3;
6191
6302
  const STEP_MS = 5;
@@ -6296,6 +6407,7 @@ function errorName(error, fallback) {
6296
6407
  if (typeof error !== "object" || error === null) return fallback || "Error";
6297
6408
  const named = error.name;
6298
6409
  if (typeof named === "string" && REACTOR_ERROR_NAMES.has(named)) return named;
6410
+ if (typeof named === "string" && named && named !== "Error") return named;
6299
6411
  return error.constructor.name || fallback || "Error";
6300
6412
  }
6301
6413
  function serializeError(error, values = []) {
@@ -6594,6 +6706,7 @@ function dispatch(message) {
6594
6706
  }
6595
6707
  function startPieceWorker() {
6596
6708
  installEgressGuard();
6709
+ installTlsGuard();
6597
6710
  process.on("message", onMessage);
6598
6711
  markWorkerReady();
6599
6712
  }
@@ -6763,14 +6876,15 @@ var RequestGuard = class {
6763
6876
  } catch (error) {
6764
6877
  return Promise.reject(error);
6765
6878
  }
6766
- return Promise.race([result.then((value) => this.paged(value)), this.whenClosed]);
6879
+ return Promise.race([result.then((value) => this.wrap(value)), this.whenClosed]);
6767
6880
  }
6768
6881
  close() {
6769
6882
  this.closed = true;
6770
6883
  this.rejectClosed(requestClosed());
6771
6884
  }
6772
- paged(value) {
6885
+ wrap(value) {
6773
6886
  if (typeof value !== "object" || value === null) return value;
6887
+ if (isWriteHandle(value)) return this.handle(value);
6774
6888
  const next = value.next;
6775
6889
  if (typeof next !== "function") return value;
6776
6890
  return {
@@ -6778,7 +6892,17 @@ var RequestGuard = class {
6778
6892
  next: () => this.call(() => next.call(value))
6779
6893
  };
6780
6894
  }
6895
+ handle(handle) {
6896
+ return new Proxy(handle, { get: (target, prop) => {
6897
+ if (prop === "readable" || prop === "written") return this.call(() => target[prop]);
6898
+ if (prop === "document") return (...args) => this.call(() => target.document(...args));
6899
+ return Reflect.get(target, prop, target);
6900
+ } });
6901
+ }
6781
6902
  };
6903
+ function isWriteHandle(value) {
6904
+ return typeof value.document === "function" && "readable" in value && "written" in value;
6905
+ }
6782
6906
  const SERVED_DRIVES = {
6783
6907
  getNode: true,
6784
6908
  listNodes: true,
@@ -6793,16 +6917,67 @@ const REFUSED_DRIVES = {
6793
6917
  copyNode: true,
6794
6918
  setPreferredEditorOnNode: true
6795
6919
  };
6796
- function sessionDrives(proxy, guard) {
6797
- const remote = proxy.drives;
6798
- const drives = Object.create(null);
6799
- for (const name of Object.keys(SERVED_DRIVES)) drives[name] = (...args) => guard.call(() => remote[name](...args));
6800
- for (const name of Object.keys(REFUSED_DRIVES)) drives[name] = () => {
6801
- throw named(ReactorAccessDeniedError, `drives.${name} is not available to workflow pieces`);
6920
+ const SERVED_WRITE = {
6921
+ create: true,
6922
+ createEmpty: true,
6923
+ execute: true,
6924
+ deleteDocument: true
6925
+ };
6926
+ const SERVED_DRIVE_WRITES = {
6927
+ addFile: true,
6928
+ addFolder: true
6929
+ };
6930
+ const REFUSED_WRITE = {
6931
+ isDocumentIdTaken: true,
6932
+ describe: true,
6933
+ evaluateActions: true,
6934
+ upgradeDocument: true,
6935
+ executeBatch: true,
6936
+ rename: true,
6937
+ setPreferredEditor: true,
6938
+ addRelationship: true,
6939
+ updateRelationship: true,
6940
+ removeRelationship: true,
6941
+ moveRelationship: true,
6942
+ deleteDocuments: true,
6943
+ loadBatch: true
6944
+ };
6945
+ function guarded(remote, guard, serve, refuse, prefix) {
6946
+ const methods = Object.create(null);
6947
+ for (const name of Object.keys(serve)) methods[name] = (...args) => guard.call(() => remote[name](...args));
6948
+ refuseAll(methods, refuse, (name) => `${prefix}${name} is not available to workflow pieces`);
6949
+ return methods;
6950
+ }
6951
+ function refuseAll(methods, names, message) {
6952
+ for (const name of Object.keys(names)) methods[name] = () => {
6953
+ throw named(ReactorAccessDeniedError, message(name));
6802
6954
  };
6803
- return drives;
6804
6955
  }
6805
- function sessionClient(rt, proxy, guard) {
6956
+ function sessionDrives(proxy, guard) {
6957
+ return guarded(proxy.drives, guard, SERVED_DRIVES, REFUSED_DRIVES, "drives.");
6958
+ }
6959
+ function sessionWrite(proxy, guard) {
6960
+ const remote = proxy.write;
6961
+ const write = guarded(remote, guard, SERVED_WRITE, REFUSED_WRITE, "write.");
6962
+ write.drives = guarded(remote.drives, guard, SERVED_DRIVE_WRITES, REFUSED_DRIVES, "write.drives.");
6963
+ return write;
6964
+ }
6965
+ function readOnlyWrite() {
6966
+ const readOnly = (prefix) => (name) => `${prefix}${name} writes, and this step declares read access only`;
6967
+ const write = Object.create(null);
6968
+ refuseAll(write, {
6969
+ ...SERVED_WRITE,
6970
+ ...REFUSED_WRITE
6971
+ }, readOnly("write."));
6972
+ const drives = Object.create(null);
6973
+ refuseAll(drives, {
6974
+ ...SERVED_DRIVE_WRITES,
6975
+ ...REFUSED_DRIVES
6976
+ }, readOnly("write.drives."));
6977
+ write.drives = drives;
6978
+ return write;
6979
+ }
6980
+ function sessionClient(rt, proxy, guard, requireReactor = "read") {
6806
6981
  const local = {
6807
6982
  getDocumentModelModule: (documentType) => guard.call(async () => {
6808
6983
  const type = String(documentType);
@@ -6826,9 +7001,12 @@ function sessionClient(rt, proxy, guard) {
6826
7001
  }
6827
7002
  };
6828
7003
  const drives = sessionDrives(proxy, guard);
7004
+ const write = requireReactor === "write" ? sessionWrite(proxy, guard) : readOnlyWrite();
6829
7005
  return new Proxy({}, { get: (_target, prop) => {
6830
7006
  if (typeof prop !== "string" || prop === "then") return void 0;
6831
7007
  if (prop === "drives") return drives;
7008
+ if (prop === "write") return write;
7009
+ if (prop === "read") return void 0;
6832
7010
  if (prop in local) return local[prop];
6833
7011
  return (...args) => guard.call(() => proxy[prop](...args));
6834
7012
  } });
@@ -6840,7 +7018,7 @@ async function openSession(binding, requireReactor) {
6840
7018
  router.attach(transport);
6841
7019
  const proxy = rt.rpc.createReactorClientProxy(router, { registry: rt.registry });
6842
7020
  const guard = new RequestGuard();
6843
- const client = sessionClient(rt, proxy, guard);
7021
+ const client = sessionClient(rt, proxy, guard, requireReactor);
6844
7022
  const close = () => {
6845
7023
  guard.close();
6846
7024
  router.detach();