@makaio/framework 1.0.0-dev-1781729394463 → 1.0.0-dev-1781766035621
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/.makaio-build.json +2 -2
- package/dist/{adapter-B5I7Wp4y.mjs → adapter-BmdC3QwV.mjs} +1 -1
- package/dist/adapters/index.d.mts +1 -1
- package/dist/adapters/stream-session/index.d.mts +2 -0
- package/dist/await-trigger-DwVldnMt.mjs +1 -0
- package/dist/bus/index.d.mts +20 -20
- package/dist/bus/index.mjs +1 -1
- package/dist/{canonical-model-BWGkgf3v.mjs → canonical-model-BM5WAnQW.mjs} +1 -1
- package/dist/compression-CXEHx0rS.mjs +1 -0
- package/dist/contracts/adapter/index.d.mts +2 -2
- package/dist/contracts/adapter/index.mjs +1 -1
- package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
- package/dist/contracts/artifact/index.d.mts +1 -1
- package/dist/contracts/canonical-model/index.d.mts +1 -1
- package/dist/contracts/canonical-model/index.mjs +1 -1
- package/dist/contracts/client/index.d.mts +1 -1
- package/dist/contracts/extension/index.d.mts +2 -2
- package/dist/contracts/facet/index.d.mts +1 -1
- package/dist/contracts/harness/index.d.mts +1 -1
- package/dist/contracts/index.d.mts +175 -170
- package/dist/contracts/index.mjs +1 -1
- package/dist/contracts/materialization/index.d.mts +3 -3
- package/dist/contracts/session/index.d.mts +2 -2
- package/dist/contracts/session/index.mjs +1 -1
- package/dist/contracts/variant/index.d.mts +1 -1
- package/dist/contracts/workflow/index.d.mts +2 -2
- package/dist/{definition-b9jyJqPD.d.mts → definition-D_3U4OLJ.d.mts} +1 -1
- package/dist/{index-BEzRpWsS.d.mts → index-61LNzR4E.d.mts} +394 -394
- package/dist/{index-kwq54nx4.d.mts → index-B08YYzYZ.d.mts} +24 -24
- package/dist/{index-CmHdpW0E.d.mts → index-BN95duxC.d.mts} +8 -8
- package/dist/{index-DKNmj2sa.d.mts → index-B_FtZ3Gn.d.mts} +15 -15
- package/dist/{index-DWKCb-eJ.d.mts → index-BwZpSUql.d.mts} +28 -28
- package/dist/{index-DMz-2ACU.d.mts → index-ByDySw3V.d.mts} +100 -100
- package/dist/{index-Dw7ErgWU.d.mts → index-CewENhZO.d.mts} +8 -8
- package/dist/{index-CZJc-V9L.d.mts → index-Ch8A757m.d.mts} +17 -17
- package/dist/{index-mU2lnU7O.d.mts → index-CqCe7Phc.d.mts} +6 -6
- package/dist/{index-aciWhUWw.d.mts → index-DCDZrmkB.d.mts} +342 -342
- package/dist/{index-D1KPCXBN.d.mts → index-UKndP4iV.d.mts} +1 -1
- package/dist/{index-CW_LbXdg.d.mts → index-Y2r0Zvcm.d.mts} +8 -8
- package/dist/{index-Cjo24O5I.d.mts → index-YoTbsavl.d.mts} +39 -39
- package/dist/{index-BWIkf5oJ.d.mts → index-mpYmdMt9.d.mts} +9 -9
- package/dist/{index-DTBQOCar.d.mts → index-xyXYG5WO.d.mts} +16 -16
- package/dist/kernel/extension/index.d.mts +1 -1
- package/dist/kernel/index.d.mts +2 -2
- package/dist/kernel/observability/index.d.mts +1 -1
- package/dist/loop-gate-handlers-BLoGCWMQ.mjs +1 -0
- package/dist/mcp-http-server/index.mjs +1 -1
- package/dist/{namespace-KMxsPJwm.d.mts → namespace-BeMGmLrp.d.mts} +9 -9
- package/dist/{namespace-65uwTpbg.d.mts → namespace-Cir7d-vM.d.mts} +6 -6
- package/dist/{namespace-COEUMuHL.d.mts → namespace-Ct8ipis5.d.mts} +154 -154
- package/dist/{namespace-6sIu5nBI2.d.mts → namespace-D8P8Sxce2.d.mts} +2 -2
- package/dist/{namespace-DYJZAGzR.d.mts → namespace-Da5Ip_ru.d.mts} +58 -58
- package/dist/{package-rdrXr17q.mjs → package-B1AXe-oz.mjs} +1 -1
- package/dist/package.json +1 -1
- package/dist/runtime-node/index.mjs +1 -1
- package/dist/runtime-node/workflow-worker/index.mjs +1 -1
- package/dist/runtime-node/workflow-worker/worker-entry.mjs +1 -1
- package/dist/{schema-B2bO5Yui.d.mts → schema-TNNx-dYQ.d.mts} +3 -3
- package/dist/{schemas-D4zaFE2p.d.mts → schemas-C_gGGevw.d.mts} +6 -6
- package/dist/{schemas-CDBn9MTz.d.mts → schemas-CarFhw0P.d.mts} +154 -154
- package/dist/{schemas-ByssHRGU2.d.mts → schemas-DF_RgKLw2.d.mts} +11 -11
- package/dist/{schemas-DMMWmWjq.d.mts → schemas-DXjyGVpx.d.mts} +4 -4
- package/dist/{schemas-BWasvfw2.mjs → schemas-yNBjlOKi.mjs} +1 -1
- package/dist/services/agent-runtime/index.d.mts +2 -2
- package/dist/services/agent-runtime/namespace.d.mts +1 -1
- package/dist/services/agent-runtime/schemas.d.mts +1 -1
- package/dist/services/context-rules/index.d.mts +3 -3
- package/dist/services/execution-target/index.d.mts +3 -3
- package/dist/services/execution-target/namespace.d.mts +1 -1
- package/dist/services/execution-target/schemas.d.mts +1 -1
- package/dist/services/filesystem/namespace.d.mts +6 -6
- package/dist/services/filesystem/schemas.d.mts +3 -3
- package/dist/services/git/namespace.d.mts +2 -2
- package/dist/services/git/schemas.d.mts +1 -1
- package/dist/services/harness/index.d.mts +6 -6
- package/dist/services/index.d.mts +110 -110
- package/dist/services/index.mjs +1 -1
- package/dist/services/session/index.d.mts +4 -4
- package/dist/services/session/session-events/namespace.d.mts +1 -1
- package/dist/services/session/storage/namespace.d.mts +1 -1
- package/dist/services/session/storage/schema.d.mts +1 -1
- package/dist/services/settings/namespace.d.mts +8 -8
- package/dist/services/settings/storage/extension-configs/namespace.d.mts +3 -3
- package/dist/services/subagent-template/index.d.mts +2 -2
- package/dist/services/subagent-template/namespace.d.mts +1 -1
- package/dist/services/subagent-template/schemas.d.mts +1 -1
- package/dist/services/tools/index.mjs +1 -1
- package/dist/{session-Bey-bzcX.mjs → session-DLTZOum3.mjs} +1 -1
- package/dist/{session-lineage-Cht4jbvV.d.mts → session-lineage-5-wRBzuC.d.mts} +1 -1
- package/dist/tools/index.d.mts +8 -0
- package/dist/{tools-uAgIrqan.mjs → tools-DFOsOboy.mjs} +1 -1
- package/dist/{transition-Coowd2dA.d.mts → transition-ByWf06n-.d.mts} +1 -1
- package/dist/{types-Cagp7JXb.d.mts → types-D2Q9qI-a.d.mts} +282 -282
- package/dist/workflow-engine/index.d.mts +32 -32
- package/dist/workflow-engine/index.mjs +1 -1
- package/dist/workflow-engine/package.mjs +1 -1
- package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
- package/dist/{workflow-worker-CojIlB6k.mjs → workflow-worker-BIpYi6o7.mjs} +1 -1
- package/package.json +5 -1
- package/dist/await-trigger-DcMVmNW5.mjs +0 -1
- package/dist/compression-DMoeVgKx.mjs +0 -1
- package/dist/loop-gate-handlers-CwU5zAGs.mjs +0 -1
|
@@ -423,9 +423,9 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
423
423
|
pending: "pending";
|
|
424
424
|
completed: "completed";
|
|
425
425
|
cancelled: "cancelled";
|
|
426
|
-
running: "running";
|
|
427
426
|
failed: "failed";
|
|
428
427
|
paused: "paused";
|
|
428
|
+
running: "running";
|
|
429
429
|
}>;
|
|
430
430
|
inputs: z.ZodType<_$_makaio_contracts0.JsonValue, unknown, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, unknown>>;
|
|
431
431
|
config: z.ZodOptional<z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>>;
|
|
@@ -464,9 +464,9 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
464
464
|
pending: "pending";
|
|
465
465
|
completed: "completed";
|
|
466
466
|
cancelled: "cancelled";
|
|
467
|
-
running: "running";
|
|
468
467
|
failed: "failed";
|
|
469
468
|
paused: "paused";
|
|
469
|
+
running: "running";
|
|
470
470
|
}>;
|
|
471
471
|
inputs: z.ZodType<_$_makaio_contracts0.JsonValue, unknown, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, unknown>>;
|
|
472
472
|
config: z.ZodOptional<z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>>;
|
|
@@ -512,9 +512,9 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
512
512
|
pending: "pending";
|
|
513
513
|
completed: "completed";
|
|
514
514
|
cancelled: "cancelled";
|
|
515
|
-
running: "running";
|
|
516
515
|
failed: "failed";
|
|
517
516
|
paused: "paused";
|
|
517
|
+
running: "running";
|
|
518
518
|
}>;
|
|
519
519
|
inputs: z.ZodType<_$_makaio_contracts0.JsonValue, unknown, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, unknown>>;
|
|
520
520
|
config: z.ZodOptional<z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>>;
|
|
@@ -758,9 +758,9 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
758
758
|
pending: "pending";
|
|
759
759
|
completed: "completed";
|
|
760
760
|
cancelled: "cancelled";
|
|
761
|
-
running: "running";
|
|
762
761
|
failed: "failed";
|
|
763
762
|
paused: "paused";
|
|
763
|
+
running: "running";
|
|
764
764
|
}>>;
|
|
765
765
|
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
766
766
|
reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -827,9 +827,9 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
827
827
|
pending: "pending";
|
|
828
828
|
completed: "completed";
|
|
829
829
|
cancelled: "cancelled";
|
|
830
|
-
running: "running";
|
|
831
830
|
failed: "failed";
|
|
832
831
|
paused: "paused";
|
|
832
|
+
running: "running";
|
|
833
833
|
}>>;
|
|
834
834
|
artifactRef: z.ZodOptional<z.ZodObject<{
|
|
835
835
|
kind: z.ZodString;
|
|
@@ -850,9 +850,9 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
850
850
|
pending: "pending";
|
|
851
851
|
completed: "completed";
|
|
852
852
|
cancelled: "cancelled";
|
|
853
|
-
running: "running";
|
|
854
853
|
failed: "failed";
|
|
855
854
|
paused: "paused";
|
|
855
|
+
running: "running";
|
|
856
856
|
}>;
|
|
857
857
|
inputs: z.ZodType<_$_makaio_contracts0.JsonValue, unknown, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, unknown>>;
|
|
858
858
|
config: z.ZodOptional<z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>>;
|
|
@@ -902,9 +902,9 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
902
902
|
pending: "pending";
|
|
903
903
|
completed: "completed";
|
|
904
904
|
cancelled: "cancelled";
|
|
905
|
-
running: "running";
|
|
906
905
|
failed: "failed";
|
|
907
906
|
paused: "paused";
|
|
907
|
+
running: "running";
|
|
908
908
|
}>;
|
|
909
909
|
inputs: z.ZodType<_$_makaio_contracts0.JsonValue, unknown, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, unknown>>;
|
|
910
910
|
config: z.ZodOptional<z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>>;
|
|
@@ -962,8 +962,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
962
962
|
pending: "pending";
|
|
963
963
|
completed: "completed";
|
|
964
964
|
cancelled: "cancelled";
|
|
965
|
-
running: "running";
|
|
966
965
|
failed: "failed";
|
|
966
|
+
running: "running";
|
|
967
967
|
waiting: "waiting";
|
|
968
968
|
skipped: "skipped";
|
|
969
969
|
}>;
|
|
@@ -1008,8 +1008,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
1008
1008
|
pending: "pending";
|
|
1009
1009
|
completed: "completed";
|
|
1010
1010
|
cancelled: "cancelled";
|
|
1011
|
-
running: "running";
|
|
1012
1011
|
failed: "failed";
|
|
1012
|
+
running: "running";
|
|
1013
1013
|
waiting: "waiting";
|
|
1014
1014
|
skipped: "skipped";
|
|
1015
1015
|
}>;
|
|
@@ -1051,8 +1051,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
1051
1051
|
pending: "pending";
|
|
1052
1052
|
completed: "completed";
|
|
1053
1053
|
cancelled: "cancelled";
|
|
1054
|
-
running: "running";
|
|
1055
1054
|
failed: "failed";
|
|
1055
|
+
running: "running";
|
|
1056
1056
|
waiting: "waiting";
|
|
1057
1057
|
skipped: "skipped";
|
|
1058
1058
|
}>;
|
|
@@ -1319,8 +1319,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
1319
1319
|
}>;
|
|
1320
1320
|
status: z.ZodEnum<{
|
|
1321
1321
|
completed: "completed";
|
|
1322
|
-
running: "running";
|
|
1323
1322
|
failed: "failed";
|
|
1323
|
+
running: "running";
|
|
1324
1324
|
skipped: "skipped";
|
|
1325
1325
|
}>;
|
|
1326
1326
|
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1355,8 +1355,8 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
1355
1355
|
}>;
|
|
1356
1356
|
status: z.ZodEnum<{
|
|
1357
1357
|
completed: "completed";
|
|
1358
|
-
running: "running";
|
|
1359
1358
|
failed: "failed";
|
|
1359
|
+
running: "running";
|
|
1360
1360
|
skipped: "skipped";
|
|
1361
1361
|
}>;
|
|
1362
1362
|
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
@@ -2482,7 +2482,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
2482
2482
|
tableName: "workflow_executions";
|
|
2483
2483
|
dataType: "string";
|
|
2484
2484
|
columnType: "SQLiteText";
|
|
2485
|
-
data: "pending" | "completed" | "cancelled" | "
|
|
2485
|
+
data: "pending" | "completed" | "cancelled" | "failed" | "paused" | "running";
|
|
2486
2486
|
driverParam: string;
|
|
2487
2487
|
notNull: true;
|
|
2488
2488
|
hasDefault: false;
|
|
@@ -2771,7 +2771,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
2771
2771
|
tableName: "workflow_execution_frames";
|
|
2772
2772
|
dataType: "string";
|
|
2773
2773
|
columnType: "SQLiteText";
|
|
2774
|
-
data: "pending" | "completed" | "cancelled" | "
|
|
2774
|
+
data: "pending" | "completed" | "cancelled" | "failed" | "running" | "waiting" | "skipped";
|
|
2775
2775
|
driverParam: string;
|
|
2776
2776
|
notNull: true;
|
|
2777
2777
|
hasDefault: true;
|
|
@@ -2784,7 +2784,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
2784
2784
|
generated: undefined;
|
|
2785
2785
|
}, {}, {
|
|
2786
2786
|
length: number | undefined;
|
|
2787
|
-
$type: "pending" | "completed" | "cancelled" | "
|
|
2787
|
+
$type: "pending" | "completed" | "cancelled" | "failed" | "running" | "waiting" | "skipped";
|
|
2788
2788
|
}>;
|
|
2789
2789
|
attempt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
|
|
2790
2790
|
name: string;
|
|
@@ -3282,7 +3282,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
3282
3282
|
tableName: "workflow_step_spans";
|
|
3283
3283
|
dataType: "string";
|
|
3284
3284
|
columnType: "SQLiteText";
|
|
3285
|
-
data: "completed" | "
|
|
3285
|
+
data: "completed" | "failed" | "running" | "skipped";
|
|
3286
3286
|
driverParam: string;
|
|
3287
3287
|
notNull: true;
|
|
3288
3288
|
hasDefault: false;
|
|
@@ -3295,7 +3295,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
3295
3295
|
generated: undefined;
|
|
3296
3296
|
}, {}, {
|
|
3297
3297
|
length: number | undefined;
|
|
3298
|
-
$type: "completed" | "
|
|
3298
|
+
$type: "completed" | "failed" | "running" | "skipped";
|
|
3299
3299
|
}>;
|
|
3300
3300
|
startedAt: _$drizzle_orm_sqlite_core0.SQLiteColumn<{
|
|
3301
3301
|
name: string;
|
|
@@ -4329,7 +4329,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
4329
4329
|
tableName: "worklog_summaries";
|
|
4330
4330
|
dataType: "string";
|
|
4331
4331
|
columnType: "SQLiteText";
|
|
4332
|
-
data: "pending" | "completed" | "cancelled" | "
|
|
4332
|
+
data: "pending" | "completed" | "cancelled" | "failed" | "paused" | "running";
|
|
4333
4333
|
driverParam: string;
|
|
4334
4334
|
notNull: true;
|
|
4335
4335
|
hasDefault: false;
|
|
@@ -4591,7 +4591,7 @@ declare const WorkflowStorageNamespace: _$_makaio_storage_core0.StorageNamespace
|
|
|
4591
4591
|
tableName: "worklog_frame_entries";
|
|
4592
4592
|
dataType: "string";
|
|
4593
4593
|
columnType: "SQLiteText";
|
|
4594
|
-
data: "pending" | "completed" | "cancelled" | "
|
|
4594
|
+
data: "pending" | "completed" | "cancelled" | "failed" | "running" | "waiting" | "skipped";
|
|
4595
4595
|
driverParam: string;
|
|
4596
4596
|
notNull: true;
|
|
4597
4597
|
hasDefault: false;
|
|
@@ -5685,9 +5685,9 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
|
|
|
5685
5685
|
pending: "pending";
|
|
5686
5686
|
completed: "completed";
|
|
5687
5687
|
cancelled: "cancelled";
|
|
5688
|
-
running: "running";
|
|
5689
5688
|
failed: "failed";
|
|
5690
5689
|
paused: "paused";
|
|
5690
|
+
running: "running";
|
|
5691
5691
|
}>;
|
|
5692
5692
|
inputs: z.ZodType<_$_makaio_contracts0.JsonValue, unknown, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, unknown>>;
|
|
5693
5693
|
config: z.ZodOptional<z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>>;
|
|
@@ -5726,9 +5726,9 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
|
|
|
5726
5726
|
pending: "pending";
|
|
5727
5727
|
completed: "completed";
|
|
5728
5728
|
cancelled: "cancelled";
|
|
5729
|
-
running: "running";
|
|
5730
5729
|
failed: "failed";
|
|
5731
5730
|
paused: "paused";
|
|
5731
|
+
running: "running";
|
|
5732
5732
|
}>;
|
|
5733
5733
|
inputs: z.ZodType<_$_makaio_contracts0.JsonValue, unknown, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, unknown>>;
|
|
5734
5734
|
config: z.ZodOptional<z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>>;
|
|
@@ -5774,9 +5774,9 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
|
|
|
5774
5774
|
pending: "pending";
|
|
5775
5775
|
completed: "completed";
|
|
5776
5776
|
cancelled: "cancelled";
|
|
5777
|
-
running: "running";
|
|
5778
5777
|
failed: "failed";
|
|
5779
5778
|
paused: "paused";
|
|
5779
|
+
running: "running";
|
|
5780
5780
|
}>;
|
|
5781
5781
|
inputs: z.ZodType<_$_makaio_contracts0.JsonValue, unknown, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, unknown>>;
|
|
5782
5782
|
config: z.ZodOptional<z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>>;
|
|
@@ -6020,9 +6020,9 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
|
|
|
6020
6020
|
pending: "pending";
|
|
6021
6021
|
completed: "completed";
|
|
6022
6022
|
cancelled: "cancelled";
|
|
6023
|
-
running: "running";
|
|
6024
6023
|
failed: "failed";
|
|
6025
6024
|
paused: "paused";
|
|
6025
|
+
running: "running";
|
|
6026
6026
|
}>>;
|
|
6027
6027
|
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
6028
6028
|
reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -6089,9 +6089,9 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
|
|
|
6089
6089
|
pending: "pending";
|
|
6090
6090
|
completed: "completed";
|
|
6091
6091
|
cancelled: "cancelled";
|
|
6092
|
-
running: "running";
|
|
6093
6092
|
failed: "failed";
|
|
6094
6093
|
paused: "paused";
|
|
6094
|
+
running: "running";
|
|
6095
6095
|
}>>;
|
|
6096
6096
|
artifactRef: z.ZodOptional<z.ZodObject<{
|
|
6097
6097
|
kind: z.ZodString;
|
|
@@ -6112,9 +6112,9 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
|
|
|
6112
6112
|
pending: "pending";
|
|
6113
6113
|
completed: "completed";
|
|
6114
6114
|
cancelled: "cancelled";
|
|
6115
|
-
running: "running";
|
|
6116
6115
|
failed: "failed";
|
|
6117
6116
|
paused: "paused";
|
|
6117
|
+
running: "running";
|
|
6118
6118
|
}>;
|
|
6119
6119
|
inputs: z.ZodType<_$_makaio_contracts0.JsonValue, unknown, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, unknown>>;
|
|
6120
6120
|
config: z.ZodOptional<z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>>;
|
|
@@ -6164,9 +6164,9 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
|
|
|
6164
6164
|
pending: "pending";
|
|
6165
6165
|
completed: "completed";
|
|
6166
6166
|
cancelled: "cancelled";
|
|
6167
|
-
running: "running";
|
|
6168
6167
|
failed: "failed";
|
|
6169
6168
|
paused: "paused";
|
|
6169
|
+
running: "running";
|
|
6170
6170
|
}>;
|
|
6171
6171
|
inputs: z.ZodType<_$_makaio_contracts0.JsonValue, unknown, z.core.$ZodTypeInternals<_$_makaio_contracts0.JsonValue, unknown>>;
|
|
6172
6172
|
config: z.ZodOptional<z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>>;
|
|
@@ -6224,8 +6224,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
|
|
|
6224
6224
|
pending: "pending";
|
|
6225
6225
|
completed: "completed";
|
|
6226
6226
|
cancelled: "cancelled";
|
|
6227
|
-
running: "running";
|
|
6228
6227
|
failed: "failed";
|
|
6228
|
+
running: "running";
|
|
6229
6229
|
waiting: "waiting";
|
|
6230
6230
|
skipped: "skipped";
|
|
6231
6231
|
}>;
|
|
@@ -6270,8 +6270,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
|
|
|
6270
6270
|
pending: "pending";
|
|
6271
6271
|
completed: "completed";
|
|
6272
6272
|
cancelled: "cancelled";
|
|
6273
|
-
running: "running";
|
|
6274
6273
|
failed: "failed";
|
|
6274
|
+
running: "running";
|
|
6275
6275
|
waiting: "waiting";
|
|
6276
6276
|
skipped: "skipped";
|
|
6277
6277
|
}>;
|
|
@@ -6313,8 +6313,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
|
|
|
6313
6313
|
pending: "pending";
|
|
6314
6314
|
completed: "completed";
|
|
6315
6315
|
cancelled: "cancelled";
|
|
6316
|
-
running: "running";
|
|
6317
6316
|
failed: "failed";
|
|
6317
|
+
running: "running";
|
|
6318
6318
|
waiting: "waiting";
|
|
6319
6319
|
skipped: "skipped";
|
|
6320
6320
|
}>;
|
|
@@ -6581,8 +6581,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
|
|
|
6581
6581
|
}>;
|
|
6582
6582
|
status: z.ZodEnum<{
|
|
6583
6583
|
completed: "completed";
|
|
6584
|
-
running: "running";
|
|
6585
6584
|
failed: "failed";
|
|
6585
|
+
running: "running";
|
|
6586
6586
|
skipped: "skipped";
|
|
6587
6587
|
}>;
|
|
6588
6588
|
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
@@ -6617,8 +6617,8 @@ declare const WorkflowStorageSubjects: _$_makaio_core0.BusSubjects<_$_makaio_cor
|
|
|
6617
6617
|
}>;
|
|
6618
6618
|
status: z.ZodEnum<{
|
|
6619
6619
|
completed: "completed";
|
|
6620
|
-
running: "running";
|
|
6621
6620
|
failed: "failed";
|
|
6621
|
+
running: "running";
|
|
6622
6622
|
skipped: "skipped";
|
|
6623
6623
|
}>;
|
|
6624
6624
|
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
@@ -7394,7 +7394,7 @@ declare const workflowStepSpansDual: _$_makaio_storage_drizzle0.DualTable<"workf
|
|
|
7394
7394
|
frameId: _$_makaio_storage_drizzle0.DualBuilder<_$drizzle_orm0.NotNull<_$drizzle_orm_sqlite_core0.SQLiteTextBuilderInitial<"frame_id", [string, ...string[]], number | undefined>>, _$drizzle_orm0.NotNull<_$drizzle_orm_pg_core0.PgTextBuilderInitial<"frame_id", [string, ...string[]]>>>; /** Step identifier within the workflow definition. */
|
|
7395
7395
|
stepId: _$_makaio_storage_drizzle0.DualBuilder<_$drizzle_orm0.NotNull<_$drizzle_orm_sqlite_core0.SQLiteTextBuilderInitial<"step_id", [string, ...string[]], number | undefined>>, _$drizzle_orm0.NotNull<_$drizzle_orm_pg_core0.PgTextBuilderInitial<"step_id", [string, ...string[]]>>>; /** Step type discriminant. */
|
|
7396
7396
|
stepType: _$_makaio_storage_drizzle0.DualBuilder<_$drizzle_orm0.NotNull<_$drizzle_orm_sqlite_core0.SQLiteTextBuilderInitial<"step_type", [string, ...string[]], number | undefined>>, _$drizzle_orm0.NotNull<_$drizzle_orm_pg_core0.PgTextBuilderInitial<"step_type", [string, ...string[]]>>>; /** Current span status. */
|
|
7397
|
-
status: _$_makaio_storage_drizzle0.DualBuilder<_$drizzle_orm0.NotNull<_$drizzle_orm0.$Type<_$drizzle_orm_sqlite_core0.SQLiteTextBuilderInitial<"status", [string, ...string[]], number | undefined>, "completed" | "
|
|
7397
|
+
status: _$_makaio_storage_drizzle0.DualBuilder<_$drizzle_orm0.NotNull<_$drizzle_orm0.$Type<_$drizzle_orm_sqlite_core0.SQLiteTextBuilderInitial<"status", [string, ...string[]], number | undefined>, "completed" | "failed" | "running" | "skipped">>, _$drizzle_orm0.NotNull<_$drizzle_orm0.$Type<_$drizzle_orm_pg_core0.PgTextBuilderInitial<"status", [string, ...string[]]>, "completed" | "failed" | "running" | "skipped">>>; /** Step start timestamp (epoch ms). */
|
|
7398
7398
|
startedAt: _$_makaio_storage_drizzle0.DualBuilder<_$drizzle_orm_sqlite_core0.SQLiteIntegerBuilderInitial<string>, _$drizzle_orm_pg_core0.PgBigInt53BuilderInitial<string>>; /** Step completion timestamp (epoch ms). */
|
|
7399
7399
|
completedAt: _$_makaio_storage_drizzle0.DualBuilder<_$drizzle_orm_sqlite_core0.SQLiteIntegerBuilderInitial<string>, _$drizzle_orm_pg_core0.PgBigInt53BuilderInitial<string>>; /** Wall-clock duration in milliseconds. */
|
|
7400
7400
|
durationMs: _$_makaio_storage_drizzle0.DualBuilder<_$drizzle_orm_sqlite_core0.SQLiteIntegerBuilderInitial<string>, _$drizzle_orm_pg_core0.PgIntegerBuilderInitial<string>>; /** Input tokens consumed (agent steps). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,B as t,J as n,M as r,P as i,S as a,W as o,f as s,w as c,x as l}from"../loop-gate-handlers-
|
|
1
|
+
import{A as e,B as t,J as n,M as r,P as i,S as a,W as o,f as s,w as c,x as l}from"../loop-gate-handlers-BLoGCWMQ.mjs";import{a as u,c as d,i as f,l as p,n as m,o as h,r as g,s as _,t as v}from"../package-B1AXe-oz.mjs";import{JsonValueSchema as y,WorkflowFrameStateSchema as b}from"@makaio/framework/contracts";const x=new Set([...b.shape.status.options]);function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function C(e){if(!S(e))return!1;for(let t of Object.values(e))if(!S(t)||typeof t.status!=`string`||!x.has(t.status)||`result`in t&&t.result!==void 0&&!y.safeParse(t.result).success)return!1;return!0}function w(e){let t={trigger:S(e.trigger)?e.trigger:{},steps:C(e.steps)?e.steps:{},inputs:y.safeParse(e.inputs).success?e.inputs:{}};return`item`in e&&(t.item=e.item),typeof e.index==`number`&&(t.index=e.index),t}export{f as WorkflowEngineService,v as WorkflowEngineToken,u as WorkflowExecutor,l as WorkflowStorageNamespace,a as WorkflowStorageSubjects,w as buildWorkflowExpressionContextFromResolvedInputs,m as createWorkflowEnginePackage,_ as getWorkflowState,d as initializeWorkflowState,p as patchWorkflowState,h as registerDrizzleWorkflowStorage,s as runShellStep,c as workflowDefinitionsDual,g as workflowEnginePackage,e as workflowExecutionStateDual,r as workflowExecutionStateEventsDual,i as workflowExecutionsDual,t as workflowStepSpansDual,o as worklogFrameEntriesDual,n as worklogSummariesDual};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"../package-
|
|
1
|
+
import{n as e,r as t,t as n}from"../package-B1AXe-oz.mjs";export{n as WorkflowEngineToken,e as createWorkflowEnginePackage,t as workflowEnginePackage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,Y as t,a as n,h as r,i,n as a,o,s,t as c,y as l}from"../loop-gate-handlers-
|
|
1
|
+
import{S as e,Y as t,a as n,h as r,i,n as a,o,s,t as c,y as l}from"../loop-gate-handlers-BLoGCWMQ.mjs";import{WORKFLOW_CANCELLED_REASON as u}from"@makaio/framework/contracts";async function d(n,r,i,a){let o=await g(n,r,i);return await n.request(e.setExecution,{execution:o}),i===`completed`?await n.emit(t.execution.completed,{executionId:r.executionId,workflowId:r.workflowId,totalDuration:0,completedAt:o.completedAt}):await n.emit(t.execution.cancelled,{executionId:r.executionId,workflowId:r.workflowId,reason:a,completedAt:o.completedAt}),i===`cancelled`?{executionId:r.executionId,workflowId:r.workflowId,status:`cancelled`,...a===void 0?{}:{reason:a}}:{executionId:r.executionId,workflowId:r.workflowId,status:`completed`}}function f(e,t){return t.status===`completed`?{executionId:e.executionId,workflowId:e.workflowId,status:`completed`,...t.artifact===void 0?{}:{artifact:t.artifact}}:t.status===`cancelled`?{executionId:e.executionId,workflowId:e.workflowId,status:`cancelled`,...t.reason===void 0?{}:{reason:t.reason}}:t.status===`paused`?{executionId:e.executionId,workflowId:e.workflowId,status:`paused`,pausedAtGateId:t.pausedAtGateId,pausedAtFrameId:t.pausedAtFrameId}:{executionId:e.executionId,workflowId:e.workflowId,status:`failed`,error:t.error}}function p(e){let t,n=()=>{t=r({bus:e.bus,activeExecutions:e.activeExecutions,shellAbortControllers:e.shellAbortControllers,activeRunnerSteps:e.activeRunnerSteps,cancelTimeoutMs:l.cancelTimeoutMs},e.executionId,u).catch(t=>(console.error(`[WorkflowOrchestrator] Failed to persist cancellation for ${e.executionId}:`,t),!1))};return e.signal.addEventListener(`abort`,n,{once:!0}),e.signal.aborted&&n(),async()=>(e.signal.removeEventListener(`abort`,n),t??!1)}async function m(t,n){let r=await t.requestOptional(e.getExecution,{executionId:n});return r.handled?r.data.execution?.startedAt??void 0:void 0}async function h(e,t){return{id:t.executionId,workflowId:t.workflowId,coordinatorSessionId:t.coordinatorSessionId,status:`running`,inputs:t.inputs,config:t.config??{},startedAt:await m(e,t.executionId)??Date.now(),triggerPayload:t.triggerPayload,...t.artifactRef===void 0?{}:{artifactRef:t.artifactRef},scope:t.scope}}async function g(e,t,n){let r=Date.now();return{id:t.executionId,workflowId:t.workflowId,coordinatorSessionId:t.coordinatorSessionId,status:n,inputs:t.inputs,config:t.config??{},startedAt:await m(e,t.executionId)??r,completedAt:r,triggerPayload:t.triggerPayload,...t.artifactRef===void 0?{}:{artifactRef:t.artifactRef},scope:t.scope}}async function _(e,t,r,i,s,c,l,d,f){let p=e.suspensionStrategy===`wait-in-process`?void 0:await v(e.executionId,l,{required:!0}),m=await n({definition:t,execution:r,runContext:i,zodSchema:f?.artifact,bus:l}),h=new o(e.executionId,e.workflowId,t,r,s,l,d,void 0,m,{context:e.context,env:e.env},{suspensionStrategy:e.suspensionStrategy,resumeFrames:p,runtimeLoopGates:c}),g=h.buildExpressionContext(),_=await a(t.root,h,g);return _.status===`failed`?{status:`failed`,error:_.error}:_.status===`paused`?{status:`paused`,pausedAtGateId:_.pausedAtGateId,pausedAtFrameId:_.pausedAtFrameId}:_.status===`cancelled`||d.aborted?{status:`cancelled`,reason:u}:{status:`completed`,artifact:m?.current}}async function v(t,n,r={}){try{let a=await n.requestOptional(e.listFrames,{executionId:t});if(!a.handled){if(r.required===!0)throw Error(`Frame storage handler is required to resume execution '${t}'.`);return}return a.data.frames.length===0?void 0:i(a.data.frames)}catch(e){if(r.required===!0)throw e;return}}function y(e,t){return{executionId:e.executionId,workflowId:e.workflowId,source:e.source,definitionSnapshot:e.source.kind===`definition`?e.definition??t:t,workerManifest:{packages:[]},inputs:e.inputs,config:e.config??{},scope:e.scope,triggerPayload:e.triggerPayload,...e.artifactRef===void 0?{}:{artifactRef:e.artifactRef},...e.executionHints===void 0?{}:{executionHints:e.executionHints},coordinatorSessionId:e.coordinatorSessionId,cancelSubject:e.cancelSubject,context:e.context,env:e.env,createdAt:Date.now(),suspensionStrategy:e.suspensionStrategy}}async function b(n,r,i,a,o){i.status=`paused`,await n.request(e.setExecution,{execution:i}),await n.emit(t.execution.paused,{executionId:r.executionId,workflowId:r.workflowId,pausedAtGateId:a,pausedAtFrameId:o})}async function x(e,n,r,i,a,o){r===`completed`?await e.emit(t.execution.completed,{executionId:n.executionId,workflowId:n.workflowId,totalDuration:a-i.startedAt,completedAt:a}):r===`cancelled`?await e.emit(t.execution.cancelled,{executionId:n.executionId,workflowId:n.workflowId,reason:u,completedAt:a}):await e.emit(t.execution.failed,{executionId:n.executionId,workflowId:n.workflowId,error:o??`Workflow execution failed`,completedAt:a})}async function S(t){let{config:n,loaded:r,bus:i,signal:a}=t,{definition:o}=r;if(a.aborted)return d(i,n,`cancelled`,u);let l=await h(i,n),m=y(n,o);await s(i,l,m,o);let g=new Map(r.runtimeHandlers),v=r.runtimeLoopGates??new Map,S=new Map,C=new Map,w=new Map;S.set(n.executionId,{execution:l,workflow:o,runContext:m,runtimeHandlers:g,runtimeLoopGates:new Map(v)});let T=p({signal:a,executionId:n.executionId,bus:i,activeExecutions:S,shellAbortControllers:C,activeRunnerSteps:w}),E={status:`completed`},D=!1;try{o.root.nodes.length>0&&(c(o,v),E=await _(n,o,l,m,g,v,i,a,r.zodSchemas))}catch(e){E={status:`failed`,error:e instanceof Error?e.message:String(e)}}finally{D=await T(),S.clear()}if(D)return f(n,{status:`cancelled`,reason:u});if((a.aborted||l.status===`cancelled`)&&(E={status:`cancelled`,reason:u}),E.status===`paused`)return await b(i,n,l,E.pausedAtGateId,E.pausedAtFrameId),f(n,E);let O=Date.now(),k=E.status===`failed`?E.error:void 0;return l.status=E.status,l.completedAt=O,l.error=k,await i.request(e.setExecution,{execution:l}),await x(i,n,E.status,l,O,k),f(n,E)}export{S as runWorkflowOrchestrator};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{n as r,o as i,t as a}from"./await-trigger-DcMVmNW5.mjs";import{basename as o,join as s}from"node:path";import{WorkerNodeCapabilitiesSchema as c,WorkerNodeSubjects as l,WorkflowWorkerConfigSchema as u}from"@makaio/framework/contracts";import{runWorkflowOrchestrator as d}from"@makaio/framework/workflow-engine/workflow-orchestrator";var f=n(((e,t)=>{t.exports={name:`piscina`,version:`5.1.4`,description:`A fast, efficient Node.js Worker Thread Pool implementation`,main:`./dist/main.js`,types:`./dist/index.d.ts`,exports:{types:`./dist/index.d.ts`,import:`./dist/esm-wrapper.mjs`,require:`./dist/main.js`},engines:{node:`>=20.x`},scripts:{build:`tsc && gen-esm-wrapper . dist/esm-wrapper.mjs`,lint:`eslint`,test:`node scripts/run-tests.js --pattern='test/**/*test.ts'`,"test:ci":`npm run lint && npm run build && npm run test:coverage`,"test:coverage":`node scripts/run-tests.js --coverage --pattern='test/**/*test.ts'`,prepack:`npm run build`,benchmark:`node --allow-natives-syntax benchmark/index.js --scope all`,"benchmark:ci":`node --allow-natives-syntax benchmark/index.js --scope all --reporter json | jq '.[] | .name, .opsSec'`,"benchmark:simple":`node --allow-natives-syntax benchmark/index.js --scope simple:all`,"benchmark:simple:default":`node --allow-natives-syntax benchmark/index.js --scope simple`,"benchmark:simple:async":`node --allow-natives-syntax benchmark/index.js --scope simple:async`,"benchmark:startup":`node --allow-natives-syntax benchmark/index.js --scope startup`,"benchmark:queue":`node --allow-natives-syntax benchmark/index.js --scope queue`},repository:{type:`git`,url:`git+https://github.com/piscinajs/piscina.git`},keywords:[`fast`,`worker threads`,`thread pool`,`wade wilson`],author:`James M Snell <jasnell@gmail.com>`,contributors:[`Anna Henningsen <anna@addaleax.net>`,`Matteo Collina <matteo.collina@gmail.com>`,`Carlos Fuentes <me@metcoder.dev>`],license:`MIT`,devDependencies:{"@types/node":`^22.4.1`,"abort-controller":`^3.0.0`,"bench-node":`^0.7.0`,"concat-stream":`^2.0.0`,eslint:`^9.16.0`,"gen-esm-wrapper":`^1.1.1`,glob:`^11.0.2`,neostandard:`^0.12.0`,tsx:`^4.20.3`,typescript:`5.8.3`},optionalDependencies:{"@napi-rs/nice":`^1.0.4`},bugs:{url:`https://github.com/piscinajs/piscina/issues`},homepage:`https://github.com/piscinajs/piscina#readme`,directories:{example:`examples`,test:`test`}}})),p=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.kFieldCount=e.kResponseCountField=e.kRequestCountField=e.kQueueOptions=e.kValue=e.kTransferable=e.kWorkerData=e.kMovable=void 0,e.kMovable=Symbol(`Piscina.kMovable`),e.kWorkerData=Symbol(`Piscina.kWorkerData`),e.kTransferable=Symbol.for(`Piscina.transferable`),e.kValue=Symbol.for(`Piscina.valueOf`),e.kQueueOptions=Symbol.for(`Piscina.queueOptions`),e.kRequestCountField=0,e.kResponseCountField=1,e.kFieldCount=2})),m=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.AbortError=void 0,e.onabort=t,e.AbortError=class extends Error{constructor(e){super(`The task has been aborted`,{cause:e})}get name(){return`AbortError`}};function t(e,t){return`addEventListener`in e?(e.addEventListener(`abort`,t,{once:!0}),()=>e.removeEventListener(`abort`,t)):(e.once(`abort`,t),()=>e.removeListener(`abort`,t))}})),h=n((t=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.commonState=t.READY=void 0,t.isTransferable=a,t.isMovable=o,t.markMovable=s,t.maybeFileURLToPath=c,t.getAvailableParallelism=l,t.promiseResolvers=u;let n=e(`node:url`),r=e(`node:os`),i=p();t.READY=`_WORKER_READY`;function a(e){return typeof e==`object`&&!!e&&i.kTransferable in e&&i.kValue in e}function o(e){return a(e)&&e[i.kMovable]===!0}function s(e){Object.defineProperty(e,i.kMovable,{enumerable:!1,configurable:!0,writable:!0,value:!0})}t.commonState={isWorkerThread:!1,workerData:void 0};function c(e){return e.startsWith(`file:`)?(0,n.fileURLToPath)(new n.URL(e)):e}function l(){return(0,r.availableParallelism)()}function u(){if(Promise.withResolvers!=null)return Promise.withResolvers();let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}})),g=n((t=>{var n=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,`__esModule`,{value:!0}),t.ArrayTaskQueue=void 0;let r=n(e(`node:assert`));t.ArrayTaskQueue=class{constructor(){this.tasks=[]}get size(){return this.tasks.length}shift(){return this.tasks.shift()??null}push(e){this.tasks.push(e)}remove(e){let t=this.tasks.indexOf(e);r.default.notStrictEqual(t,-1),this.tasks.splice(t,1)}}})),_=n((t=>{var n=t&&t.__classPrivateFieldGet||function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},r=t&&t.__classPrivateFieldSet||function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},i=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},a;Object.defineProperty(t,`__esModule`,{value:!0}),t.FixedQueue=void 0;let o=i(e(`node:assert`)),s=2048,c=s-1;var l=class{constructor(){this.bottom=0,this.top=0,this.list=Array(s),this.next=null}isEmpty(){return this.top===this.bottom}isFull(){return(this.top+1&c)===this.bottom}push(e){this.list[this.top]=e,this.top=this.top+1&c}shift(){let e=this.list[this.bottom];return e===void 0?null:(this.list[this.bottom]=void 0,this.bottom=this.bottom+1&c,e)}remove(e){let t=this.list.indexOf(e);o.default.notStrictEqual(t,-1);let n=t;for(;;){let e=n+1&c;if(this.list[n]=this.list[e],this.list[n]===void 0)break;if(e===t){this.list[n]=void 0;break}n=e}this.top=this.top-1&c}};t.FixedQueue=class{constructor(){a.set(this,0),this.head=this.tail=new l}isEmpty(){return this.head.isEmpty()}push(e){var t;this.head.isFull()&&(this.head=this.head.next=new l),this.head.push(e),r(this,a,(t=n(this,a,`f`),t++,t),`f`)}shift(){var e;let t=this.tail,i=t.shift();return i!==null&&r(this,a,(e=n(this,a,`f`),e--,e),`f`),t.isEmpty()&&t.next!==null&&(this.tail=t.next,t.next=null),i}remove(e){var t;let i=null,o=this.tail;for(;;){if(o.list.includes(e)){o.remove(e),r(this,a,(t=n(this,a,`f`),t--,t),`f`);break}if(o.next===null)break;i=o,o=o.next}o.isEmpty()&&(i===null?o.next!==null&&(this.tail=o.next):o.next===null?this.head=i:i.next=o.next)}get size(){return n(this,a,`f`)}},a=new WeakMap})),v=n((t=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.TaskInfo=t.FixedQueue=t.ArrayTaskQueue=void 0,t.isTaskQueue=l;let n=e(`node:perf_hooks`),r=e(`node:async_hooks`),i=m(),a=h(),o=p();var s=g();Object.defineProperty(t,`ArrayTaskQueue`,{enumerable:!0,get:function(){return s.ArrayTaskQueue}});var c=_();Object.defineProperty(t,`FixedQueue`,{enumerable:!0,get:function(){return c.FixedQueue}});function l(e){return typeof e==`object`&&!!e&&`size`in e&&typeof e.shift==`function`&&typeof e.remove==`function`&&typeof e.push==`function`}let u=0;t.TaskInfo=class extends r.AsyncResource{constructor({task:e,transferList:t,filename:r,name:i,abortSignal:s,triggerAsyncId:c},l){super(`Piscina.Task`,{requireManualDestroy:!0,triggerAsyncId:c}),this.workerInfo=null,this.aborted=!1,this._abortListener=()=>{this.aborted=!0},this._abortCleaner=null,this.callback=l,this.task=e,this.transferList=t,(0,a.isMovable)(e)&&(this.transferList??=[],this.transferList=this.transferList.concat(e[o.kTransferable]),this.task=e[o.kValue]),this.filename=r,this.name=i,this.taskId=u++,this.abortSignal=s,this.created=n.performance.now(),this.started=0}onAbort(e){this._abortListener=()=>{this.aborted=!0,e()}}setAbortListener(e){this._abortCleaner=(0,i.onabort)(e,this._abortListener)}releaseTask(){let e=this.task;return this.task=null,e}onResponse(e){}done(e,t){var n;this.runInAsyncScope(this.callback,null,e,t),this.emitDestroy(),(n=this._abortCleaner)==null||n.call(this)}get[o.kQueueOptions](){return this.task?.[o.kQueueOptions]??null}get interface(){return{taskId:this.taskId,filename:this.filename,name:this.name,created:this.created,isAbortable:this.abortSignal!==null,[o.kQueueOptions]:this[o.kQueueOptions]}}}})),y=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Errors=void 0,e.Errors={ThreadTermination:()=>Error(`Terminating worker thread`),FilenameNotProvided:()=>Error(`filename must be provided to run() or in options object`),TaskQueueAtLimit:()=>Error(`Task queue is at limit`),NoTaskQueueAvailable:()=>Error(`No task queue available and all Workers are busy`),CloseTimeout:()=>Error(`Close operation timed out`)}})),b=n((t=>{var n=t&&t.__classPrivateFieldSet||function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},r=t&&t.__classPrivateFieldGet||function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},i,a;Object.defineProperty(t,`__esModule`,{value:!0}),t.PiscinaHistogramHandler=void 0;let o=e(`node:perf_hooks`);t.PiscinaHistogramHandler=class e{constructor(){i.set(this,void 0),a.set(this,void 0),n(this,i,(0,o.createHistogram)(),`f`),n(this,a,(0,o.createHistogram)(),`f`)}get runTimeSummary(){return e.createHistogramSummary(r(this,i,`f`))}get waitTimeSummary(){return e.createHistogramSummary(r(this,a,`f`))}get runTimeCount(){return r(this,i,`f`).count}recordRunTime(t){r(this,i,`f`).record(e.toHistogramIntegerNano(t))}recordWaitTime(t){r(this,a,`f`).record(e.toHistogramIntegerNano(t))}resetWaitTime(){r(this,a,`f`).reset()}resetRunTime(){r(this,i,`f`).reset()}static createHistogramSummary(e){let{mean:t,stddev:n,min:r,max:i}=e;return{average:t/1e3,mean:t/1e3,stddev:n/1e3,min:r/1e3,max:i/1e3,p0_001:e.percentile(.001)/1e3,p0_01:e.percentile(.01)/1e3,p0_1:e.percentile(.1)/1e3,p1:e.percentile(1)/1e3,p2_5:e.percentile(2.5)/1e3,p10:e.percentile(10)/1e3,p25:e.percentile(25)/1e3,p50:e.percentile(50)/1e3,p75:e.percentile(75)/1e3,p90:e.percentile(90)/1e3,p97_5:e.percentile(97.5)/1e3,p99:e.percentile(99)/1e3,p99_9:e.percentile(99.9)/1e3,p99_99:e.percentile(99.99)/1e3,p99_999:e.percentile(99.999)/1e3}}static toHistogramIntegerNano(e){return Math.max(1,Math.trunc(e*1e3))}},i=new WeakMap,a=new WeakMap})),x=n((t=>{var n=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,`__esModule`,{value:!0}),t.AsynchronouslyCreatedResourcePool=t.AsynchronouslyCreatedResource=void 0;let r=n(e(`node:assert`));t.AsynchronouslyCreatedResource=class{constructor(){this.onreadyListeners=[],this.ondestroyListeners=[]}markAsReady(){let e=this.onreadyListeners;(0,r.default)(e!=null),this.onreadyListeners=null;for(let t of e)t()}isReady(){return this.onreadyListeners==null}onReady(e){if(this.onreadyListeners==null){e();return}this.onreadyListeners.push(e)}onDestroy(e){this.ondestroyListeners!=null&&this.ondestroyListeners.push(e)}markAsDestroyed(){let e=this.ondestroyListeners;(0,r.default)(e!=null),this.ondestroyListeners=null;for(let t of e)t()}isDestroyed(){return this.ondestroyListeners==null}},t.AsynchronouslyCreatedResourcePool=class{constructor(e){this.pendingItems=new Set,this.readyItems=new Set,this.maximumUsage=e,this.onAvailableListeners=[],this.onTaskDoneListeners=[]}add(e){this.pendingItems.add(e),e.onReady(()=>{this.pendingItems.has(e)&&(this.pendingItems.delete(e),this.readyItems.add(e),this.maybeAvailable(e))})}delete(e){this.pendingItems.delete(e),this.readyItems.delete(e)}*[Symbol.iterator](){yield*this.pendingItems,yield*this.readyItems}get size(){return this.pendingItems.size+this.readyItems.size}maybeAvailable(e){if(e.currentUsage()<this.maximumUsage)for(let t of this.onAvailableListeners)t(e)}onAvailable(e){this.onAvailableListeners.push(e)}taskDone(e){for(let t=0;t<this.onTaskDoneListeners.length;t++)this.onTaskDoneListeners[t](e)}onTaskDone(e){this.onTaskDoneListeners.push(e)}getCurrentUsage(){let e=0;for(let t of this.readyItems){let n=t.currentUsage();Number.isFinite(n)&&(e+=n)}return e}}})),S=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.LeastBusyBalancer=t;function t(e){let{maximumUsage:t}=e;return(e,n)=>{let r=null,i=t;for(let t of n){if(t.currentUsage===0){r=t;break}t.isRunningAbortableTask||e.isAbortable===!1&&t.currentUsage<i&&(r=t,i=t.currentUsage)}return r}}})),C=n((t=>{var n=t&&t.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=t&&t.__exportStar||function(e,t){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(t,r)&&n(t,e,r)},i=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,`__esModule`,{value:!0}),t.AsynchronouslyCreatedResourcePool=t.WorkerInfo=void 0;let a=e(`node:worker_threads`),o=e(`node:perf_hooks`),s=i(e(`node:assert`)),c=y(),l=p(),u=b(),d=x();Object.defineProperty(t,`AsynchronouslyCreatedResourcePool`,{enumerable:!0,get:function(){return d.AsynchronouslyCreatedResourcePool}}),r(S(),t),t.WorkerInfo=class extends d.AsynchronouslyCreatedResource{constructor({worker:e,port:t,enableHistogram:n},r){super(),this.idleTimeout=null,this.lastSeenResponseCount=0,this.terminating=!1,this.destroyed=!1;let{filename:i,...s}=e;this.worker=new a.Worker(i,s),this.port=t,this.onMessage=r,this.port.on(`message`,this._handleResponse.bind(this)),this.taskInfos=new Map,this.sharedBuffer=new Int32Array(new SharedArrayBuffer(l.kFieldCount*Int32Array.BYTES_PER_ELEMENT)),this.histogram=n?(0,o.createHistogram)():null}get id(){return this.worker.threadId}onWorkerMessage(e){this.worker.on(`message`,e)}onWorkerError(e){this.worker.on(`error`,e)}onWorkerExit(e){this.worker.on(`exit`,e)}onPortClose(e){this.port.on(`close`,e)}init(e,t){return this.worker.postMessage(e,t),this}workerRef(){return this.worker.ref(),this}workerUnref(){return this.worker.unref(),this}destroy(){if(!(this.terminating||this.destroyed)){this.terminating=!0,this.clearIdleTimeout(),this.worker.terminate(),this.port.close();for(let e of this.taskInfos.values())e.done(c.Errors.ThreadTermination());this.taskInfos.clear(),this.terminating=!1,this.destroyed=!0,this.markAsDestroyed()}}setIdleTimeout(e,t,...n){this.idleTimeout=setTimeout(e,t,...n).unref()}clearIdleTimeout(){this.idleTimeout!=null&&(clearTimeout(this.idleTimeout),this.idleTimeout=null)}ref(){return this.port.ref(),this}unref(){return this.port.unref(),this}_handleResponse(e){var t;(t=this.histogram)==null||t.record(u.PiscinaHistogramHandler.toHistogramIntegerNano(e?.time)),this.onMessage(e),this.taskInfos.size===0&&this.unref()}postTask(e){(0,s.default)(!this.taskInfos.has(e.taskId)),(0,s.default)(!this.terminating&&!this.destroyed);let t={task:e.releaseTask(),taskId:e.taskId,filename:e.filename,name:e.name,histogramEnabled:this.histogram==null?0:1};try{this.port.postMessage(t,e.transferList),queueMicrotask(()=>this.clearIdleTimeout()),e.workerInfo=this,this.taskInfos.set(e.taskId,e),this.ref(),Atomics.add(this.sharedBuffer,l.kRequestCountField,1),Atomics.notify(this.sharedBuffer,l.kRequestCountField,1)}catch(t){e.done(t)}}processPendingMessages(){if(this.destroyed)return;let e=Atomics.load(this.sharedBuffer,l.kResponseCountField);if(e!==this.lastSeenResponseCount){this.lastSeenResponseCount=e;let t;for(;(t=(0,a.receiveMessageOnPort)(this.port))!=null;)this._handleResponse(t.message)}}isRunningAbortableTask(){if(this.taskInfos.size!==1)return!1;let[[,e]]=this.taskInfos;return e.abortSignal!=null}currentUsage(){return this.isRunningAbortableTask()?1/0:this.taskInfos.size}popTask(e){let t=this.taskInfos.get(e)??null;return t!=null&&this.taskInfos.delete(e),t}get interface(){let e=this;return{get id(){return e.worker.threadId},get currentUsage(){return e.currentUsage()},get isRunningAbortableTask(){return e.isRunningAbortableTask()},get histogram(){return e.histogram==null?null:u.PiscinaHistogramHandler.createHistogramSummary(e.histogram)},get terminating(){return e.terminating},get destroyed(){return e.destroyed},[l.kWorkerData]:e}}}})),w=n((t=>{var n=t&&t.__classPrivateFieldSet||function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},r=t&&t.__classPrivateFieldGet||function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},i,a,o,s;Object.defineProperty(t,`__esModule`,{value:!0}),t.ArrayTaskQueue=t.FixedQueue=t.version=t.queueOptionsSymbol=t.valueSymbol=t.transferableSymbol=t.Piscina=t.workerData=t.isWorkerThread=t.move=void 0;let c=e(`node:worker_threads`),l=e(`node:events`),u=e(`node:path`),d=e(`node:util`),g=e(`node:perf_hooks`),_=e(`node:timers/promises`),x=f();Object.defineProperty(t,`version`,{enumerable:!0,get:function(){return x.version}});let S=p();Object.defineProperty(t,`queueOptionsSymbol`,{enumerable:!0,get:function(){return S.kQueueOptions}}),Object.defineProperty(t,`transferableSymbol`,{enumerable:!0,get:function(){return S.kTransferable}}),Object.defineProperty(t,`valueSymbol`,{enumerable:!0,get:function(){return S.kValue}});let w=v();Object.defineProperty(t,`ArrayTaskQueue`,{enumerable:!0,get:function(){return w.ArrayTaskQueue}}),Object.defineProperty(t,`FixedQueue`,{enumerable:!0,get:function(){return w.FixedQueue}});let T=C(),E=m(),D=b(),O=y(),k=h(),A=(0,k.getAvailableParallelism)(),j={filename:null,name:`default`,minThreads:Math.max(Math.floor(A/2),1),maxThreads:A*1.5,idleTimeout:0,maxQueue:1/0,concurrentTasksPerWorker:1,atomics:`sync`,taskQueue:new w.ArrayTaskQueue,niceIncrement:0,trackUnmanagedFds:!0,closeTimeout:3e4,recordTiming:!0,workerHistogram:!1},M={transferList:void 0,filename:null,signal:null,name:null},N={force:!1};var P=class{constructor(e){i.set(this,void 0),n(this,i,e,`f`)}get[(i=new WeakMap,S.kTransferable)](){return r(this,i,`f`)}get[S.kValue](){return r(this,i,`f`)}},F=class{constructor(e){a.set(this,void 0),n(this,a,e,`f`)}get[(a=new WeakMap,S.kTransferable)](){return r(this,a,`f`).buffer}get[S.kValue](){return r(this,a,`f`)}},I=class{constructor(e,t){this.skipQueue=[],this.completed=0,this.histogram=null,this.start=g.performance.now(),this.inProcessPendingMessages=!1,this.startingUp=!1,this.closingUp=!1,this.workerFailsDuringBootstrap=!1,this.destroying=!1,this.publicInterface=e,this.taskQueue=t.taskQueue??new w.FixedQueue;let n=t.filename?(0,k.maybeFileURLToPath)(t.filename):null;this.options={...j,...t,filename:n,maxQueue:0},this.options.recordTiming&&(this.histogram=new D.PiscinaHistogramHandler),t.maxThreads!==void 0&&this.options.minThreads>=t.maxThreads&&(this.options.minThreads=t.maxThreads),t.minThreads!==void 0&&this.options.maxThreads<=t.minThreads&&(this.options.maxThreads=t.minThreads),t.maxQueue===`auto`?this.options.maxQueue=this.options.maxThreads**2:this.options.maxQueue=t.maxQueue??j.maxQueue,this.balancer=this.options.loadBalancer??(0,T.LeastBusyBalancer)({maximumUsage:this.options.concurrentTasksPerWorker}),this.workers=new T.AsynchronouslyCreatedResourcePool(this.options.concurrentTasksPerWorker),this.workers.onTaskDone(this._onWorkerTaskDone.bind(this)),this.maxCapacity=this.options.maxThreads*this.options.concurrentTasksPerWorker,this.startingUp=!0,this._ensureMinimumWorkers(),this.startingUp=!1,this._needsDrain=!1}_ensureMinimumWorkers(){if(!(this.closingUp||this.destroying))for(;this.workers.size<this.options.minThreads;)this._addNewWorker()}_addNewWorker(){if(this.closingUp===!0)return;let{port1:e,port2:t}=new c.MessageChannel,n=new T.WorkerInfo({worker:{filename:(0,u.resolve)(__dirname,`worker.js`),env:this.options.env,argv:this.options.argv,execArgv:this.options.execArgv,resourceLimits:this.options.resourceLimits,workerData:this.options.workerData,trackUnmanagedFds:this.options.trackUnmanagedFds},port:e,enableHistogram:this.options.workerHistogram},i.bind(this)),r={filename:this.options.filename,name:this.options.name,port:t,sharedBuffer:n.sharedBuffer,atomics:this.options.atomics,niceIncrement:this.options.niceIncrement};n.onDestroy(()=>{this.publicInterface.emit(`workerDestroy`,n.interface)}),n.onWorkerMessage(s.bind(this)),n.onWorkerError(l.bind(this)),n.onWorkerExit(f.bind(this)),n.onPortClose(()=>{n.workerRef()}),this.startingUp===!0?(n.markAsReady(),queueMicrotask(()=>{this.publicInterface.emit(`workerCreate`,n.interface),this._onWorkerReady(n)})):n.onReady(()=>{this.publicInterface.emit(`workerCreate`,n.interface),this._onWorkerReady(n)}),n.init(r,[t]).workerUnref(),this.workers.add(n);function i(e){let{taskId:t,result:r}=e,i=n.popTask(t);if(this.workers.taskDone(n),i==null){let t=Error(`Unexpected message from Worker: ${(0,d.inspect)(e)}`);this.publicInterface.emit(`error`,t)}else i.done(e.error,r);this._processPendingMessages()}function a(){n.currentUsage()===0&&n.unref(),n.isReady()===!1&&n.markAsReady()}function o(e){this.publicInterface.emit(`message`,e)}function s(e){e instanceof Object&&k.READY in e?a():o.call(this,e)}function l(e){this._onError(n,e,!1)}function f(e){if(this.destroying===!1){let t=Error(`worker exited with code: ${e}`);this._onError(n,t,!0)}}}_onError(e,t,n){let r=[...e.taskInfos.values()];if(e.taskInfos.clear(),this._removeWorker(e),e.isReady()&&!this.workerFailsDuringBootstrap?this._ensureMinimumWorkers():this.workerFailsDuringBootstrap=!0,r.length>0)for(let e of r)e.done(t,null);else n||this.publicInterface.emit(`error`,t)}_processPendingMessages(){if(!(this.inProcessPendingMessages||this.options.atomics===`disabled`)){this.inProcessPendingMessages=!0;try{for(let e of this.workers)e.processPendingMessages()}finally{this.inProcessPendingMessages=!1}}}_removeWorker(e){e.destroy(),this.workers.delete(e)}_onWorkerReady(e){this._onWorkerAvailable(e)}_onWorkerTaskDone(e){this._onWorkerAvailable(e)}_onWorkerAvailable(e){let t=null;for(;this.taskQueue.size>0||this.skipQueue.length>0;){let e=this.skipQueue.shift()||this.taskQueue.shift();if(t??=[...this.workers].map(e=>e.interface),!this._distributeTask(e,t))if(this.workers.size<this.options.maxThreads){this._addNewWorker();continue}else break}this.options.idleTimeout!==1/0&&e.currentUsage()===0&&this.workers.size>this.options.minThreads&&e.setIdleTimeout(()=>{e.currentUsage()===0&&this.workers.size>this.options.minThreads&&this._removeWorker(e)},this.options.idleTimeout)}_distributeTask(e,t){var n;if(e.aborted)return!0;let r=this.balancer(e.interface,t);if(r!=null&&r[S.kWorkerData]!=null){let t=g.performance.now();return(n=this.histogram)==null||n.recordWaitTime(t-e.created),e.started=t,r[S.kWorkerData].postTask(e),queueMicrotask(()=>this._maybeDrain()),!0}return e.abortSignal==null?this.taskQueue.push(e):this.skipQueue.push(e),!1}runTask(e,t){let{filename:n,name:r}=t,{transferList:i=[]}=t;if(n??=this.options.filename,r??=this.options.name,typeof n!=`string`)return Promise.reject(O.Errors.FilenameNotProvided());n=(0,k.maybeFileURLToPath)(n);let a;if(this.closingUp||this.destroying){let e=new AbortController;e.abort(`queue is being terminated`),a=e.signal}else a=t.signal??null;let{promise:o,resolve:s,reject:c}=(0,k.promiseResolvers)(),l=new w.TaskInfo({task:e,transferList:i,filename:n,name:r,abortSignal:a,triggerAsyncId:this.publicInterface.asyncResource.asyncId()},(e,t)=>{var n;this.completed++,l.started&&((n=this.histogram)==null||n.recordRunTime(g.performance.now()-l.started)),e===null?s(t):c(e),queueMicrotask(this._maybeDrain.bind(this))});if(a!=null){if(a.aborted)return c(new E.AbortError(a.reason)),o;l.onAbort(()=>{c(new E.AbortError(a.reason)),l.workerInfo==null?this.taskQueue.remove(l):(this._removeWorker(l.workerInfo),this._ensureMinimumWorkers())}),l.setAbortListener(a)}if(this.taskQueue.size>0){let e=this.options.maxQueue+this.pendingCapacity();return this.taskQueue.size>=e?this.options.maxQueue===0?c(O.Errors.NoTaskQueueAvailable()):c(O.Errors.TaskQueueAtLimit()):this.taskQueue.push(l),queueMicrotask(this._maybeDrain.bind(this)),o}let u=[...this.workers.readyItems].map(e=>e.interface);return this._distributeTask(l,u)||(this.workers.size<this.options.maxThreads&&this._addNewWorker(),this.options.maxQueue<=0&&this.pendingCapacity()===0&&c(O.Errors.NoTaskQueueAvailable())),queueMicrotask(this._maybeDrain.bind(this)),o}pendingCapacity(){return this.workers.pendingItems.size*this.options.concurrentTasksPerWorker}_maybeDrain(){let{maxCapacity:e}=this,t=this.workers.getCurrentUsage();e===t?(this._needsDrain=!0,queueMicrotask(()=>this.publicInterface.emit(`needsDrain`))):e>t&&this._needsDrain&&(this._needsDrain=!1,queueMicrotask(()=>this.publicInterface.emit(`drain`)))}async destroy(){for(this.destroying=!0;this.skipQueue.length>0;)this.skipQueue.shift().done(Error(`Terminating worker thread`));for(;this.taskQueue.size>0;)this.taskQueue.shift().done(Error(`Terminating worker thread`));let e=[];for(;this.workers.size>0;){let[t]=this.workers;e.push((0,l.once)(t.worker,`exit`)),this._removeWorker(t)}await Promise.allSettled(e),this.destroying=!1}async close(e){if(this.closingUp=!0,e.force){let e=this.skipQueue.length;for(let t=0;t<e;t++){let e=this.skipQueue.shift();e.workerInfo===null?e.done(new E.AbortError(`pool is closed`)):this.skipQueue.push(e)}let t=this.taskQueue.size;for(let e=0;e<t;e++){let e=this.taskQueue.shift();e.workerInfo===null?e.done(new E.AbortError(`pool is closed`)):this.taskQueue.push(e)}}let t=()=>new Promise(e=>{let t=this.workers.size;if(t===0){e();return}let n=0,r=r=>{r.taskInfos.size===0&&n++,t===n&&e()};this.workers.onTaskDone(r);for(let e of this.workers)r(e),this.workers.onTaskDone(r)}),n=async e=>{throw await(0,_.setTimeout)(e,null,{ref:!1}),O.Errors.CloseTimeout()};try{await Promise.race([t(),n(this.options.closeTimeout)])}catch(e){this.publicInterface.emit(`error`,e)}finally{await this.destroy(),this.publicInterface.emit(`close`),this.closingUp=!1}}},L=class e extends l.EventEmitterAsyncResource{constructor(e={}){if(super({...e,name:`Piscina`}),o.set(this,void 0),s.set(this,null),typeof e.filename!=`string`&&e.filename!=null)throw TypeError(`options.filename must be a string or null`);if(typeof e.name!=`string`&&e.name!=null)throw TypeError(`options.name must be a string or null`);if(e.minThreads!==void 0&&(typeof e.minThreads!=`number`||e.minThreads<0))throw TypeError(`options.minThreads must be a non-negative integer`);if(e.maxThreads!==void 0&&(typeof e.maxThreads!=`number`||e.maxThreads<1))throw TypeError(`options.maxThreads must be a positive integer`);if(e.minThreads!==void 0&&e.maxThreads!==void 0&&e.minThreads>e.maxThreads)throw RangeError(`options.minThreads and options.maxThreads must not conflict`);if(e.idleTimeout!==void 0&&(typeof e.idleTimeout!=`number`||e.idleTimeout<0))throw TypeError(`options.idleTimeout must be a non-negative integer`);if(e.maxQueue!==void 0&&e.maxQueue!==`auto`&&(typeof e.maxQueue!=`number`||e.maxQueue<0))throw TypeError(`options.maxQueue must be a non-negative integer`);if(e.concurrentTasksPerWorker!==void 0&&(typeof e.concurrentTasksPerWorker!=`number`||e.concurrentTasksPerWorker<1))throw TypeError(`options.concurrentTasksPerWorker must be a positive integer`);if(e.atomics!=null&&(typeof e.atomics!=`string`||![`sync`,`async`,`disabled`].includes(e.atomics)))throw TypeError(`options.atomics should be a value of sync, sync or disabled.`);if(e.resourceLimits!==void 0&&(typeof e.resourceLimits!=`object`||e.resourceLimits===null))throw TypeError(`options.resourceLimits must be an object`);if(e.taskQueue!==void 0&&!(0,w.isTaskQueue)(e.taskQueue))throw TypeError(`options.taskQueue must be a TaskQueue object`);if(e.niceIncrement!==void 0&&(typeof e.niceIncrement!=`number`||e.niceIncrement<0&&process.platform!==`win32`))throw TypeError(`options.niceIncrement must be a non-negative integer on Unix systems`);if(e.trackUnmanagedFds!==void 0&&typeof e.trackUnmanagedFds!=`boolean`)throw TypeError(`options.trackUnmanagedFds must be a boolean value`);if(e.closeTimeout!==void 0&&(typeof e.closeTimeout!=`number`||e.closeTimeout<0))throw TypeError(`options.closeTimeout must be a non-negative integer`);if(e.loadBalancer!==void 0&&(typeof e.loadBalancer!=`function`||e.loadBalancer.length<1))throw TypeError(`options.loadBalancer must be a function with at least two args`);if(e.workerHistogram!==void 0&&typeof e.workerHistogram!=`boolean`)throw TypeError(`options.workerHistogram must be a boolean`);n(this,o,new I(this,e),`f`)}run(e,t=M){if(typeof t!=`object`||!t)return Promise.reject(TypeError(`options must be an object`));let{transferList:n,filename:i,name:a,signal:s}=t;return n!==void 0&&!Array.isArray(n)?Promise.reject(TypeError(`transferList argument must be an Array`)):i!=null&&typeof i!=`string`?Promise.reject(TypeError(`filename argument must be a string`)):a!=null&&typeof a!=`string`?Promise.reject(TypeError(`name argument must be a string`)):s!=null&&typeof s!=`object`?Promise.reject(TypeError(`signal argument must be an object`)):r(this,o,`f`).runTask(e,{transferList:n,filename:i,name:a,signal:s})}async close(e=N){if(typeof e!=`object`||!e)throw TypeError(`options must be an object`);let{force:t}=e;return t!==void 0&&typeof t!=`boolean`?Promise.reject(TypeError(`force argument must be a boolean`)):(t??=N.force,r(this,o,`f`).close({force:t}))}destroy(){return r(this,o,`f`).destroy()}[(o=new WeakMap,s=new WeakMap,Symbol.dispose)](){this.close()}[Symbol.asyncDispose](){return this.close()}get maxThreads(){return r(this,o,`f`).options.maxThreads}get minThreads(){return r(this,o,`f`).options.minThreads}get options(){return r(this,o,`f`).options}get threads(){let e=[];for(let t of r(this,o,`f`).workers)e.push(t.worker);return e}get queueSize(){let e=r(this,o,`f`);return Math.max(e.taskQueue.size-e.pendingCapacity(),0)}get completed(){return r(this,o,`f`).completed}get histogram(){if(r(this,s,`f`)==null){let e={get runTime(){return this.histogram?.runTimeSummary},get waitTime(){return this.histogram?.waitTimeSummary},resetRunTime(){var e;(e=this.histogram)==null||e.resetRunTime()},resetWaitTime(){var e;(e=this.histogram)==null||e.resetWaitTime()}};Object.defineProperty(e,`histogram`,{value:r(this,o,`f`).histogram,writable:!1,enumerable:!1,configurable:!1}),n(this,s,e,`f`)}return r(this,s,`f`)}get utilization(){if(r(this,o,`f`).histogram==null)return 0;let e=r(this,o,`f`).histogram.runTimeCount;if(e===0)return 0;let t=this.duration*r(this,o,`f`).options.maxThreads;return r(this,o,`f`).histogram.runTimeSummary.mean/1e3*e/t}get duration(){return g.performance.now()-r(this,o,`f`).start}get needsDrain(){return r(this,o,`f`)._needsDrain}static get isWorkerThread(){return k.commonState.isWorkerThread}static get workerData(){return k.commonState.workerData}static get version(){return x.version}static get Piscina(){return e}static get FixedQueue(){return w.FixedQueue}static get ArrayTaskQueue(){return w.ArrayTaskQueue}static move(e){return typeof e==`object`&&e&&typeof e!=`function`&&((0,k.isTransferable)(e)||(e=d.types.isArrayBufferView(e)?new F(e):new P(e)),(0,k.markMovable)(e)),e}static get transferableSymbol(){return S.kTransferable}static get valueSymbol(){return S.kValue}static get queueOptionsSymbol(){return S.kQueueOptions}};t.default=L,t.Piscina=L,t.move=L.move,t.isWorkerThread=L.isWorkerThread,t.workerData=L.workerData})),T=t(n(((e,t)=>{t.exports=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(w()).default}))(),1),E=T.default;T.default.ArrayTaskQueue,T.default.FixedQueue,T.default.Piscina,T.default.isWorkerThread,T.default.move,T.default.queueOptionsSymbol,T.default.transferableSymbol,T.default.valueSymbol,T.default.version,T.default.workerData;var D=class{pool;constructor(e){this.pool=new E({filename:e.workerEntry,maxThreads:e.maxConcurrency??4,idleTimeout:e.idleTimeoutMs??3e4})}async run(e,t){return this.pool.run(e,{signal:t})}onMessage(e){return this.pool.on(`message`,e),()=>this.pool.off(`message`,e)}async dispose(){await this.pool.destroy()}},O=class{options;manifest;pool;constructor(e){this.options=e,this.manifest=e.manifest}async run(e,t,n){return this.pool??=new D(this.options),this.pool.run({config:e,manifest:n??this.manifest},t)}runWithReadiness(e,t,n){this.pool??=new D(this.options);let r=this.pool,a,o=!1,s,c=new Promise((t,n)=>{s=n,a=r.onMessage(n=>{i(n)&&(n.executionId!==e.executionId||n.cancelSubject!==e.cancelSubject||(o=!0,a?.(),t(n)))})}),l=r.run({config:e,manifest:n??this.manifest},t);return l.then(()=>{o||(o=!0,a?.(),s(Error(`Workflow worker completed before ready signal: ${e.executionId}`)))},e=>{o||(o=!0,a?.(),s(e instanceof Error?e:Error(String(e))))}),{result:l,ready:c}}async dispose(){await this.pool?.dispose()}};function k(e){return e.mode===`source`?s(e.moduleDir,`workflow-worker`,`worker-entry.ts`):s(e.moduleDir,`workflow-worker`,`worker-entry.mjs`)}function A(e,t){let n=t.executionHints?.requirements?.capabilities??[];if(n.length===0)return e;let r=e?.customCapabilities??[];return{...e,customCapabilities:[...new Set([...r,...n])]}}var j=class{options;constructor(e){this.options=e}run(e,t,n,r){let i=n??this.options.manifest,a=A(this.options.requirements,e),o=r?.dispatchMetadata;return this.options.dispatch({config:e,...i!==void 0&&{manifest:i},...a!==void 0&&{requirements:a},...o!==void 0&&{metadata:o}},t)}},M=class{#e;constructor(e){this.#e=e.bus}async run(e,t,n){let i=u.parse(e),o=await r(i);return d({config:await a(i,o,this.#e,t),loaded:o,bus:this.#e,signal:t})}};function N(){return{packages:[]}}function P(e){let t=o(e.runtimeModuleDir)===`src`?`source`:`dist`,n=F({moduleDir:e.runtimeModuleDir,defaultWorkerEntryMode:t,runner:e.workflowRunner,bus:e.bus});return{...n!==void 0&&{workflowRunner:n},executorConfig:{busUrl:e.busUrl,busAuth:{kind:`none`},platformDefaults:e.platformDefaults,makaioHome:e.makaioHome}}}function F(e){let{runner:t}=e;if(t)switch(t.mode){case void 0:case`in-process`:if(e.bus===void 0)throw Error(`InProcessWorkflowRunner requires a bus instance. Pass 'bus' to createNodeWorkflowRunner when runner.mode is 'in-process'.`);return new M({bus:e.bus});case`worker-node`:{let n=e.bus,r=t.dispatch??(n===void 0?void 0:(e,t)=>n.request(l.dispatch,{config:e.config,manifest:e.manifest,requirements:e.requirements,metadata:e.metadata},{signal:t}));if(r===void 0)throw Error(`WorkerNodeRunner requires either a dispatch function or a bus instance. Pass 'bus' to createNodeWorkflowRunner when runner.mode is 'worker-node'.`);return new j({dispatch:r,...t.manifest!==void 0&&{manifest:t.manifest},...t.requirements!==void 0&&{requirements:t.requirements}})}case`piscina`:return new O({workerEntry:t.workerEntry??k({moduleDir:e.moduleDir,mode:t.workerEntryMode??e.defaultWorkerEntryMode}),manifest:t.manifest??N(),maxConcurrency:t.maxConcurrency,idleTimeoutMs:t.idleTimeoutMs})}}function I(e){return e instanceof Error?e:Error(String(e??`WorkerNode wait aborted`))}function L(e){return typeof e.runWithReadiness==`function`}const R={persistentStorage:!0,customCapabilities:[`workflow.local-runtime`,`workflow.thin-runner`],suspensionStrategy:`wait-in-process`};var z=class{options;environment=`piscina`;baseCapabilities;constructor(e){this.options=e,this.baseCapabilities=c.parse({...R,...e.baseCapabilities,suspensionStrategy:e.baseCapabilities?.suspensionStrategy??R.suspensionStrategy})}get id(){return this.options.id}get displayName(){return this.options.displayName}async provision(e){let t=new AbortController,n=L(this.options.runner)?this.options.runner.runWithReadiness(e.workerConfig,t.signal,e.workerManifest):{result:this.options.runner.run(e.workerConfig,t.signal,e.workerManifest),ready:void 0},r=n.result,i=n.ready?.then(e=>({adapters:e.adapters}));return i?.catch(()=>void 0),r.catch(()=>void 0),{nodeId:e.nodeId,...i!==void 0&&{ready:i},waitForResult:async e=>{if(e.aborted)return t.abort(e.reason),Promise.reject(I(e.reason));let n,i=new Promise((e,t)=>{n=t}),a=()=>{t.abort(e.reason),n(I(e.reason))};e.addEventListener(`abort`,a,{once:!0});try{return await Promise.race([r,i])}finally{e.removeEventListener(`abort`,a)}},cancel:e=>(t.abort(e??`WorkerNode cancelled`),Promise.resolve()),terminate:()=>(t.abort(`WorkerNode terminated`),Promise.resolve())}}};export{j as a,M as i,F as n,k as o,P as r,O as s,z as t};
|
|
1
|
+
import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{n as r,o as i,t as a}from"./await-trigger-DwVldnMt.mjs";import{basename as o,join as s}from"node:path";import{WorkerNodeCapabilitiesSchema as c,WorkerNodeSubjects as l,WorkflowWorkerConfigSchema as u}from"@makaio/framework/contracts";import{runWorkflowOrchestrator as d}from"@makaio/framework/workflow-engine/workflow-orchestrator";var f=n(((e,t)=>{t.exports={name:`piscina`,version:`5.1.4`,description:`A fast, efficient Node.js Worker Thread Pool implementation`,main:`./dist/main.js`,types:`./dist/index.d.ts`,exports:{types:`./dist/index.d.ts`,import:`./dist/esm-wrapper.mjs`,require:`./dist/main.js`},engines:{node:`>=20.x`},scripts:{build:`tsc && gen-esm-wrapper . dist/esm-wrapper.mjs`,lint:`eslint`,test:`node scripts/run-tests.js --pattern='test/**/*test.ts'`,"test:ci":`npm run lint && npm run build && npm run test:coverage`,"test:coverage":`node scripts/run-tests.js --coverage --pattern='test/**/*test.ts'`,prepack:`npm run build`,benchmark:`node --allow-natives-syntax benchmark/index.js --scope all`,"benchmark:ci":`node --allow-natives-syntax benchmark/index.js --scope all --reporter json | jq '.[] | .name, .opsSec'`,"benchmark:simple":`node --allow-natives-syntax benchmark/index.js --scope simple:all`,"benchmark:simple:default":`node --allow-natives-syntax benchmark/index.js --scope simple`,"benchmark:simple:async":`node --allow-natives-syntax benchmark/index.js --scope simple:async`,"benchmark:startup":`node --allow-natives-syntax benchmark/index.js --scope startup`,"benchmark:queue":`node --allow-natives-syntax benchmark/index.js --scope queue`},repository:{type:`git`,url:`git+https://github.com/piscinajs/piscina.git`},keywords:[`fast`,`worker threads`,`thread pool`,`wade wilson`],author:`James M Snell <jasnell@gmail.com>`,contributors:[`Anna Henningsen <anna@addaleax.net>`,`Matteo Collina <matteo.collina@gmail.com>`,`Carlos Fuentes <me@metcoder.dev>`],license:`MIT`,devDependencies:{"@types/node":`^22.4.1`,"abort-controller":`^3.0.0`,"bench-node":`^0.7.0`,"concat-stream":`^2.0.0`,eslint:`^9.16.0`,"gen-esm-wrapper":`^1.1.1`,glob:`^11.0.2`,neostandard:`^0.12.0`,tsx:`^4.20.3`,typescript:`5.8.3`},optionalDependencies:{"@napi-rs/nice":`^1.0.4`},bugs:{url:`https://github.com/piscinajs/piscina/issues`},homepage:`https://github.com/piscinajs/piscina#readme`,directories:{example:`examples`,test:`test`}}})),p=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.kFieldCount=e.kResponseCountField=e.kRequestCountField=e.kQueueOptions=e.kValue=e.kTransferable=e.kWorkerData=e.kMovable=void 0,e.kMovable=Symbol(`Piscina.kMovable`),e.kWorkerData=Symbol(`Piscina.kWorkerData`),e.kTransferable=Symbol.for(`Piscina.transferable`),e.kValue=Symbol.for(`Piscina.valueOf`),e.kQueueOptions=Symbol.for(`Piscina.queueOptions`),e.kRequestCountField=0,e.kResponseCountField=1,e.kFieldCount=2})),m=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.AbortError=void 0,e.onabort=t,e.AbortError=class extends Error{constructor(e){super(`The task has been aborted`,{cause:e})}get name(){return`AbortError`}};function t(e,t){return`addEventListener`in e?(e.addEventListener(`abort`,t,{once:!0}),()=>e.removeEventListener(`abort`,t)):(e.once(`abort`,t),()=>e.removeListener(`abort`,t))}})),h=n((t=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.commonState=t.READY=void 0,t.isTransferable=a,t.isMovable=o,t.markMovable=s,t.maybeFileURLToPath=c,t.getAvailableParallelism=l,t.promiseResolvers=u;let n=e(`node:url`),r=e(`node:os`),i=p();t.READY=`_WORKER_READY`;function a(e){return typeof e==`object`&&!!e&&i.kTransferable in e&&i.kValue in e}function o(e){return a(e)&&e[i.kMovable]===!0}function s(e){Object.defineProperty(e,i.kMovable,{enumerable:!1,configurable:!0,writable:!0,value:!0})}t.commonState={isWorkerThread:!1,workerData:void 0};function c(e){return e.startsWith(`file:`)?(0,n.fileURLToPath)(new n.URL(e)):e}function l(){return(0,r.availableParallelism)()}function u(){if(Promise.withResolvers!=null)return Promise.withResolvers();let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}})),g=n((t=>{var n=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,`__esModule`,{value:!0}),t.ArrayTaskQueue=void 0;let r=n(e(`node:assert`));t.ArrayTaskQueue=class{constructor(){this.tasks=[]}get size(){return this.tasks.length}shift(){return this.tasks.shift()??null}push(e){this.tasks.push(e)}remove(e){let t=this.tasks.indexOf(e);r.default.notStrictEqual(t,-1),this.tasks.splice(t,1)}}})),_=n((t=>{var n=t&&t.__classPrivateFieldGet||function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},r=t&&t.__classPrivateFieldSet||function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},i=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},a;Object.defineProperty(t,`__esModule`,{value:!0}),t.FixedQueue=void 0;let o=i(e(`node:assert`)),s=2048,c=s-1;var l=class{constructor(){this.bottom=0,this.top=0,this.list=Array(s),this.next=null}isEmpty(){return this.top===this.bottom}isFull(){return(this.top+1&c)===this.bottom}push(e){this.list[this.top]=e,this.top=this.top+1&c}shift(){let e=this.list[this.bottom];return e===void 0?null:(this.list[this.bottom]=void 0,this.bottom=this.bottom+1&c,e)}remove(e){let t=this.list.indexOf(e);o.default.notStrictEqual(t,-1);let n=t;for(;;){let e=n+1&c;if(this.list[n]=this.list[e],this.list[n]===void 0)break;if(e===t){this.list[n]=void 0;break}n=e}this.top=this.top-1&c}};t.FixedQueue=class{constructor(){a.set(this,0),this.head=this.tail=new l}isEmpty(){return this.head.isEmpty()}push(e){var t;this.head.isFull()&&(this.head=this.head.next=new l),this.head.push(e),r(this,a,(t=n(this,a,`f`),t++,t),`f`)}shift(){var e;let t=this.tail,i=t.shift();return i!==null&&r(this,a,(e=n(this,a,`f`),e--,e),`f`),t.isEmpty()&&t.next!==null&&(this.tail=t.next,t.next=null),i}remove(e){var t;let i=null,o=this.tail;for(;;){if(o.list.includes(e)){o.remove(e),r(this,a,(t=n(this,a,`f`),t--,t),`f`);break}if(o.next===null)break;i=o,o=o.next}o.isEmpty()&&(i===null?o.next!==null&&(this.tail=o.next):o.next===null?this.head=i:i.next=o.next)}get size(){return n(this,a,`f`)}},a=new WeakMap})),v=n((t=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.TaskInfo=t.FixedQueue=t.ArrayTaskQueue=void 0,t.isTaskQueue=l;let n=e(`node:perf_hooks`),r=e(`node:async_hooks`),i=m(),a=h(),o=p();var s=g();Object.defineProperty(t,`ArrayTaskQueue`,{enumerable:!0,get:function(){return s.ArrayTaskQueue}});var c=_();Object.defineProperty(t,`FixedQueue`,{enumerable:!0,get:function(){return c.FixedQueue}});function l(e){return typeof e==`object`&&!!e&&`size`in e&&typeof e.shift==`function`&&typeof e.remove==`function`&&typeof e.push==`function`}let u=0;t.TaskInfo=class extends r.AsyncResource{constructor({task:e,transferList:t,filename:r,name:i,abortSignal:s,triggerAsyncId:c},l){super(`Piscina.Task`,{requireManualDestroy:!0,triggerAsyncId:c}),this.workerInfo=null,this.aborted=!1,this._abortListener=()=>{this.aborted=!0},this._abortCleaner=null,this.callback=l,this.task=e,this.transferList=t,(0,a.isMovable)(e)&&(this.transferList??=[],this.transferList=this.transferList.concat(e[o.kTransferable]),this.task=e[o.kValue]),this.filename=r,this.name=i,this.taskId=u++,this.abortSignal=s,this.created=n.performance.now(),this.started=0}onAbort(e){this._abortListener=()=>{this.aborted=!0,e()}}setAbortListener(e){this._abortCleaner=(0,i.onabort)(e,this._abortListener)}releaseTask(){let e=this.task;return this.task=null,e}onResponse(e){}done(e,t){var n;this.runInAsyncScope(this.callback,null,e,t),this.emitDestroy(),(n=this._abortCleaner)==null||n.call(this)}get[o.kQueueOptions](){return this.task?.[o.kQueueOptions]??null}get interface(){return{taskId:this.taskId,filename:this.filename,name:this.name,created:this.created,isAbortable:this.abortSignal!==null,[o.kQueueOptions]:this[o.kQueueOptions]}}}})),y=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Errors=void 0,e.Errors={ThreadTermination:()=>Error(`Terminating worker thread`),FilenameNotProvided:()=>Error(`filename must be provided to run() or in options object`),TaskQueueAtLimit:()=>Error(`Task queue is at limit`),NoTaskQueueAvailable:()=>Error(`No task queue available and all Workers are busy`),CloseTimeout:()=>Error(`Close operation timed out`)}})),b=n((t=>{var n=t&&t.__classPrivateFieldSet||function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},r=t&&t.__classPrivateFieldGet||function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},i,a;Object.defineProperty(t,`__esModule`,{value:!0}),t.PiscinaHistogramHandler=void 0;let o=e(`node:perf_hooks`);t.PiscinaHistogramHandler=class e{constructor(){i.set(this,void 0),a.set(this,void 0),n(this,i,(0,o.createHistogram)(),`f`),n(this,a,(0,o.createHistogram)(),`f`)}get runTimeSummary(){return e.createHistogramSummary(r(this,i,`f`))}get waitTimeSummary(){return e.createHistogramSummary(r(this,a,`f`))}get runTimeCount(){return r(this,i,`f`).count}recordRunTime(t){r(this,i,`f`).record(e.toHistogramIntegerNano(t))}recordWaitTime(t){r(this,a,`f`).record(e.toHistogramIntegerNano(t))}resetWaitTime(){r(this,a,`f`).reset()}resetRunTime(){r(this,i,`f`).reset()}static createHistogramSummary(e){let{mean:t,stddev:n,min:r,max:i}=e;return{average:t/1e3,mean:t/1e3,stddev:n/1e3,min:r/1e3,max:i/1e3,p0_001:e.percentile(.001)/1e3,p0_01:e.percentile(.01)/1e3,p0_1:e.percentile(.1)/1e3,p1:e.percentile(1)/1e3,p2_5:e.percentile(2.5)/1e3,p10:e.percentile(10)/1e3,p25:e.percentile(25)/1e3,p50:e.percentile(50)/1e3,p75:e.percentile(75)/1e3,p90:e.percentile(90)/1e3,p97_5:e.percentile(97.5)/1e3,p99:e.percentile(99)/1e3,p99_9:e.percentile(99.9)/1e3,p99_99:e.percentile(99.99)/1e3,p99_999:e.percentile(99.999)/1e3}}static toHistogramIntegerNano(e){return Math.max(1,Math.trunc(e*1e3))}},i=new WeakMap,a=new WeakMap})),x=n((t=>{var n=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,`__esModule`,{value:!0}),t.AsynchronouslyCreatedResourcePool=t.AsynchronouslyCreatedResource=void 0;let r=n(e(`node:assert`));t.AsynchronouslyCreatedResource=class{constructor(){this.onreadyListeners=[],this.ondestroyListeners=[]}markAsReady(){let e=this.onreadyListeners;(0,r.default)(e!=null),this.onreadyListeners=null;for(let t of e)t()}isReady(){return this.onreadyListeners==null}onReady(e){if(this.onreadyListeners==null){e();return}this.onreadyListeners.push(e)}onDestroy(e){this.ondestroyListeners!=null&&this.ondestroyListeners.push(e)}markAsDestroyed(){let e=this.ondestroyListeners;(0,r.default)(e!=null),this.ondestroyListeners=null;for(let t of e)t()}isDestroyed(){return this.ondestroyListeners==null}},t.AsynchronouslyCreatedResourcePool=class{constructor(e){this.pendingItems=new Set,this.readyItems=new Set,this.maximumUsage=e,this.onAvailableListeners=[],this.onTaskDoneListeners=[]}add(e){this.pendingItems.add(e),e.onReady(()=>{this.pendingItems.has(e)&&(this.pendingItems.delete(e),this.readyItems.add(e),this.maybeAvailable(e))})}delete(e){this.pendingItems.delete(e),this.readyItems.delete(e)}*[Symbol.iterator](){yield*this.pendingItems,yield*this.readyItems}get size(){return this.pendingItems.size+this.readyItems.size}maybeAvailable(e){if(e.currentUsage()<this.maximumUsage)for(let t of this.onAvailableListeners)t(e)}onAvailable(e){this.onAvailableListeners.push(e)}taskDone(e){for(let t=0;t<this.onTaskDoneListeners.length;t++)this.onTaskDoneListeners[t](e)}onTaskDone(e){this.onTaskDoneListeners.push(e)}getCurrentUsage(){let e=0;for(let t of this.readyItems){let n=t.currentUsage();Number.isFinite(n)&&(e+=n)}return e}}})),S=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.LeastBusyBalancer=t;function t(e){let{maximumUsage:t}=e;return(e,n)=>{let r=null,i=t;for(let t of n){if(t.currentUsage===0){r=t;break}t.isRunningAbortableTask||e.isAbortable===!1&&t.currentUsage<i&&(r=t,i=t.currentUsage)}return r}}})),C=n((t=>{var n=t&&t.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=t&&t.__exportStar||function(e,t){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(t,r)&&n(t,e,r)},i=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,`__esModule`,{value:!0}),t.AsynchronouslyCreatedResourcePool=t.WorkerInfo=void 0;let a=e(`node:worker_threads`),o=e(`node:perf_hooks`),s=i(e(`node:assert`)),c=y(),l=p(),u=b(),d=x();Object.defineProperty(t,`AsynchronouslyCreatedResourcePool`,{enumerable:!0,get:function(){return d.AsynchronouslyCreatedResourcePool}}),r(S(),t),t.WorkerInfo=class extends d.AsynchronouslyCreatedResource{constructor({worker:e,port:t,enableHistogram:n},r){super(),this.idleTimeout=null,this.lastSeenResponseCount=0,this.terminating=!1,this.destroyed=!1;let{filename:i,...s}=e;this.worker=new a.Worker(i,s),this.port=t,this.onMessage=r,this.port.on(`message`,this._handleResponse.bind(this)),this.taskInfos=new Map,this.sharedBuffer=new Int32Array(new SharedArrayBuffer(l.kFieldCount*Int32Array.BYTES_PER_ELEMENT)),this.histogram=n?(0,o.createHistogram)():null}get id(){return this.worker.threadId}onWorkerMessage(e){this.worker.on(`message`,e)}onWorkerError(e){this.worker.on(`error`,e)}onWorkerExit(e){this.worker.on(`exit`,e)}onPortClose(e){this.port.on(`close`,e)}init(e,t){return this.worker.postMessage(e,t),this}workerRef(){return this.worker.ref(),this}workerUnref(){return this.worker.unref(),this}destroy(){if(!(this.terminating||this.destroyed)){this.terminating=!0,this.clearIdleTimeout(),this.worker.terminate(),this.port.close();for(let e of this.taskInfos.values())e.done(c.Errors.ThreadTermination());this.taskInfos.clear(),this.terminating=!1,this.destroyed=!0,this.markAsDestroyed()}}setIdleTimeout(e,t,...n){this.idleTimeout=setTimeout(e,t,...n).unref()}clearIdleTimeout(){this.idleTimeout!=null&&(clearTimeout(this.idleTimeout),this.idleTimeout=null)}ref(){return this.port.ref(),this}unref(){return this.port.unref(),this}_handleResponse(e){var t;(t=this.histogram)==null||t.record(u.PiscinaHistogramHandler.toHistogramIntegerNano(e?.time)),this.onMessage(e),this.taskInfos.size===0&&this.unref()}postTask(e){(0,s.default)(!this.taskInfos.has(e.taskId)),(0,s.default)(!this.terminating&&!this.destroyed);let t={task:e.releaseTask(),taskId:e.taskId,filename:e.filename,name:e.name,histogramEnabled:this.histogram==null?0:1};try{this.port.postMessage(t,e.transferList),queueMicrotask(()=>this.clearIdleTimeout()),e.workerInfo=this,this.taskInfos.set(e.taskId,e),this.ref(),Atomics.add(this.sharedBuffer,l.kRequestCountField,1),Atomics.notify(this.sharedBuffer,l.kRequestCountField,1)}catch(t){e.done(t)}}processPendingMessages(){if(this.destroyed)return;let e=Atomics.load(this.sharedBuffer,l.kResponseCountField);if(e!==this.lastSeenResponseCount){this.lastSeenResponseCount=e;let t;for(;(t=(0,a.receiveMessageOnPort)(this.port))!=null;)this._handleResponse(t.message)}}isRunningAbortableTask(){if(this.taskInfos.size!==1)return!1;let[[,e]]=this.taskInfos;return e.abortSignal!=null}currentUsage(){return this.isRunningAbortableTask()?1/0:this.taskInfos.size}popTask(e){let t=this.taskInfos.get(e)??null;return t!=null&&this.taskInfos.delete(e),t}get interface(){let e=this;return{get id(){return e.worker.threadId},get currentUsage(){return e.currentUsage()},get isRunningAbortableTask(){return e.isRunningAbortableTask()},get histogram(){return e.histogram==null?null:u.PiscinaHistogramHandler.createHistogramSummary(e.histogram)},get terminating(){return e.terminating},get destroyed(){return e.destroyed},[l.kWorkerData]:e}}}})),w=n((t=>{var n=t&&t.__classPrivateFieldSet||function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},r=t&&t.__classPrivateFieldGet||function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},i,a,o,s;Object.defineProperty(t,`__esModule`,{value:!0}),t.ArrayTaskQueue=t.FixedQueue=t.version=t.queueOptionsSymbol=t.valueSymbol=t.transferableSymbol=t.Piscina=t.workerData=t.isWorkerThread=t.move=void 0;let c=e(`node:worker_threads`),l=e(`node:events`),u=e(`node:path`),d=e(`node:util`),g=e(`node:perf_hooks`),_=e(`node:timers/promises`),x=f();Object.defineProperty(t,`version`,{enumerable:!0,get:function(){return x.version}});let S=p();Object.defineProperty(t,`queueOptionsSymbol`,{enumerable:!0,get:function(){return S.kQueueOptions}}),Object.defineProperty(t,`transferableSymbol`,{enumerable:!0,get:function(){return S.kTransferable}}),Object.defineProperty(t,`valueSymbol`,{enumerable:!0,get:function(){return S.kValue}});let w=v();Object.defineProperty(t,`ArrayTaskQueue`,{enumerable:!0,get:function(){return w.ArrayTaskQueue}}),Object.defineProperty(t,`FixedQueue`,{enumerable:!0,get:function(){return w.FixedQueue}});let T=C(),E=m(),D=b(),O=y(),k=h(),A=(0,k.getAvailableParallelism)(),j={filename:null,name:`default`,minThreads:Math.max(Math.floor(A/2),1),maxThreads:A*1.5,idleTimeout:0,maxQueue:1/0,concurrentTasksPerWorker:1,atomics:`sync`,taskQueue:new w.ArrayTaskQueue,niceIncrement:0,trackUnmanagedFds:!0,closeTimeout:3e4,recordTiming:!0,workerHistogram:!1},M={transferList:void 0,filename:null,signal:null,name:null},N={force:!1};var P=class{constructor(e){i.set(this,void 0),n(this,i,e,`f`)}get[(i=new WeakMap,S.kTransferable)](){return r(this,i,`f`)}get[S.kValue](){return r(this,i,`f`)}},F=class{constructor(e){a.set(this,void 0),n(this,a,e,`f`)}get[(a=new WeakMap,S.kTransferable)](){return r(this,a,`f`).buffer}get[S.kValue](){return r(this,a,`f`)}},I=class{constructor(e,t){this.skipQueue=[],this.completed=0,this.histogram=null,this.start=g.performance.now(),this.inProcessPendingMessages=!1,this.startingUp=!1,this.closingUp=!1,this.workerFailsDuringBootstrap=!1,this.destroying=!1,this.publicInterface=e,this.taskQueue=t.taskQueue??new w.FixedQueue;let n=t.filename?(0,k.maybeFileURLToPath)(t.filename):null;this.options={...j,...t,filename:n,maxQueue:0},this.options.recordTiming&&(this.histogram=new D.PiscinaHistogramHandler),t.maxThreads!==void 0&&this.options.minThreads>=t.maxThreads&&(this.options.minThreads=t.maxThreads),t.minThreads!==void 0&&this.options.maxThreads<=t.minThreads&&(this.options.maxThreads=t.minThreads),t.maxQueue===`auto`?this.options.maxQueue=this.options.maxThreads**2:this.options.maxQueue=t.maxQueue??j.maxQueue,this.balancer=this.options.loadBalancer??(0,T.LeastBusyBalancer)({maximumUsage:this.options.concurrentTasksPerWorker}),this.workers=new T.AsynchronouslyCreatedResourcePool(this.options.concurrentTasksPerWorker),this.workers.onTaskDone(this._onWorkerTaskDone.bind(this)),this.maxCapacity=this.options.maxThreads*this.options.concurrentTasksPerWorker,this.startingUp=!0,this._ensureMinimumWorkers(),this.startingUp=!1,this._needsDrain=!1}_ensureMinimumWorkers(){if(!(this.closingUp||this.destroying))for(;this.workers.size<this.options.minThreads;)this._addNewWorker()}_addNewWorker(){if(this.closingUp===!0)return;let{port1:e,port2:t}=new c.MessageChannel,n=new T.WorkerInfo({worker:{filename:(0,u.resolve)(__dirname,`worker.js`),env:this.options.env,argv:this.options.argv,execArgv:this.options.execArgv,resourceLimits:this.options.resourceLimits,workerData:this.options.workerData,trackUnmanagedFds:this.options.trackUnmanagedFds},port:e,enableHistogram:this.options.workerHistogram},i.bind(this)),r={filename:this.options.filename,name:this.options.name,port:t,sharedBuffer:n.sharedBuffer,atomics:this.options.atomics,niceIncrement:this.options.niceIncrement};n.onDestroy(()=>{this.publicInterface.emit(`workerDestroy`,n.interface)}),n.onWorkerMessage(s.bind(this)),n.onWorkerError(l.bind(this)),n.onWorkerExit(f.bind(this)),n.onPortClose(()=>{n.workerRef()}),this.startingUp===!0?(n.markAsReady(),queueMicrotask(()=>{this.publicInterface.emit(`workerCreate`,n.interface),this._onWorkerReady(n)})):n.onReady(()=>{this.publicInterface.emit(`workerCreate`,n.interface),this._onWorkerReady(n)}),n.init(r,[t]).workerUnref(),this.workers.add(n);function i(e){let{taskId:t,result:r}=e,i=n.popTask(t);if(this.workers.taskDone(n),i==null){let t=Error(`Unexpected message from Worker: ${(0,d.inspect)(e)}`);this.publicInterface.emit(`error`,t)}else i.done(e.error,r);this._processPendingMessages()}function a(){n.currentUsage()===0&&n.unref(),n.isReady()===!1&&n.markAsReady()}function o(e){this.publicInterface.emit(`message`,e)}function s(e){e instanceof Object&&k.READY in e?a():o.call(this,e)}function l(e){this._onError(n,e,!1)}function f(e){if(this.destroying===!1){let t=Error(`worker exited with code: ${e}`);this._onError(n,t,!0)}}}_onError(e,t,n){let r=[...e.taskInfos.values()];if(e.taskInfos.clear(),this._removeWorker(e),e.isReady()&&!this.workerFailsDuringBootstrap?this._ensureMinimumWorkers():this.workerFailsDuringBootstrap=!0,r.length>0)for(let e of r)e.done(t,null);else n||this.publicInterface.emit(`error`,t)}_processPendingMessages(){if(!(this.inProcessPendingMessages||this.options.atomics===`disabled`)){this.inProcessPendingMessages=!0;try{for(let e of this.workers)e.processPendingMessages()}finally{this.inProcessPendingMessages=!1}}}_removeWorker(e){e.destroy(),this.workers.delete(e)}_onWorkerReady(e){this._onWorkerAvailable(e)}_onWorkerTaskDone(e){this._onWorkerAvailable(e)}_onWorkerAvailable(e){let t=null;for(;this.taskQueue.size>0||this.skipQueue.length>0;){let e=this.skipQueue.shift()||this.taskQueue.shift();if(t??=[...this.workers].map(e=>e.interface),!this._distributeTask(e,t))if(this.workers.size<this.options.maxThreads){this._addNewWorker();continue}else break}this.options.idleTimeout!==1/0&&e.currentUsage()===0&&this.workers.size>this.options.minThreads&&e.setIdleTimeout(()=>{e.currentUsage()===0&&this.workers.size>this.options.minThreads&&this._removeWorker(e)},this.options.idleTimeout)}_distributeTask(e,t){var n;if(e.aborted)return!0;let r=this.balancer(e.interface,t);if(r!=null&&r[S.kWorkerData]!=null){let t=g.performance.now();return(n=this.histogram)==null||n.recordWaitTime(t-e.created),e.started=t,r[S.kWorkerData].postTask(e),queueMicrotask(()=>this._maybeDrain()),!0}return e.abortSignal==null?this.taskQueue.push(e):this.skipQueue.push(e),!1}runTask(e,t){let{filename:n,name:r}=t,{transferList:i=[]}=t;if(n??=this.options.filename,r??=this.options.name,typeof n!=`string`)return Promise.reject(O.Errors.FilenameNotProvided());n=(0,k.maybeFileURLToPath)(n);let a;if(this.closingUp||this.destroying){let e=new AbortController;e.abort(`queue is being terminated`),a=e.signal}else a=t.signal??null;let{promise:o,resolve:s,reject:c}=(0,k.promiseResolvers)(),l=new w.TaskInfo({task:e,transferList:i,filename:n,name:r,abortSignal:a,triggerAsyncId:this.publicInterface.asyncResource.asyncId()},(e,t)=>{var n;this.completed++,l.started&&((n=this.histogram)==null||n.recordRunTime(g.performance.now()-l.started)),e===null?s(t):c(e),queueMicrotask(this._maybeDrain.bind(this))});if(a!=null){if(a.aborted)return c(new E.AbortError(a.reason)),o;l.onAbort(()=>{c(new E.AbortError(a.reason)),l.workerInfo==null?this.taskQueue.remove(l):(this._removeWorker(l.workerInfo),this._ensureMinimumWorkers())}),l.setAbortListener(a)}if(this.taskQueue.size>0){let e=this.options.maxQueue+this.pendingCapacity();return this.taskQueue.size>=e?this.options.maxQueue===0?c(O.Errors.NoTaskQueueAvailable()):c(O.Errors.TaskQueueAtLimit()):this.taskQueue.push(l),queueMicrotask(this._maybeDrain.bind(this)),o}let u=[...this.workers.readyItems].map(e=>e.interface);return this._distributeTask(l,u)||(this.workers.size<this.options.maxThreads&&this._addNewWorker(),this.options.maxQueue<=0&&this.pendingCapacity()===0&&c(O.Errors.NoTaskQueueAvailable())),queueMicrotask(this._maybeDrain.bind(this)),o}pendingCapacity(){return this.workers.pendingItems.size*this.options.concurrentTasksPerWorker}_maybeDrain(){let{maxCapacity:e}=this,t=this.workers.getCurrentUsage();e===t?(this._needsDrain=!0,queueMicrotask(()=>this.publicInterface.emit(`needsDrain`))):e>t&&this._needsDrain&&(this._needsDrain=!1,queueMicrotask(()=>this.publicInterface.emit(`drain`)))}async destroy(){for(this.destroying=!0;this.skipQueue.length>0;)this.skipQueue.shift().done(Error(`Terminating worker thread`));for(;this.taskQueue.size>0;)this.taskQueue.shift().done(Error(`Terminating worker thread`));let e=[];for(;this.workers.size>0;){let[t]=this.workers;e.push((0,l.once)(t.worker,`exit`)),this._removeWorker(t)}await Promise.allSettled(e),this.destroying=!1}async close(e){if(this.closingUp=!0,e.force){let e=this.skipQueue.length;for(let t=0;t<e;t++){let e=this.skipQueue.shift();e.workerInfo===null?e.done(new E.AbortError(`pool is closed`)):this.skipQueue.push(e)}let t=this.taskQueue.size;for(let e=0;e<t;e++){let e=this.taskQueue.shift();e.workerInfo===null?e.done(new E.AbortError(`pool is closed`)):this.taskQueue.push(e)}}let t=()=>new Promise(e=>{let t=this.workers.size;if(t===0){e();return}let n=0,r=r=>{r.taskInfos.size===0&&n++,t===n&&e()};this.workers.onTaskDone(r);for(let e of this.workers)r(e),this.workers.onTaskDone(r)}),n=async e=>{throw await(0,_.setTimeout)(e,null,{ref:!1}),O.Errors.CloseTimeout()};try{await Promise.race([t(),n(this.options.closeTimeout)])}catch(e){this.publicInterface.emit(`error`,e)}finally{await this.destroy(),this.publicInterface.emit(`close`),this.closingUp=!1}}},L=class e extends l.EventEmitterAsyncResource{constructor(e={}){if(super({...e,name:`Piscina`}),o.set(this,void 0),s.set(this,null),typeof e.filename!=`string`&&e.filename!=null)throw TypeError(`options.filename must be a string or null`);if(typeof e.name!=`string`&&e.name!=null)throw TypeError(`options.name must be a string or null`);if(e.minThreads!==void 0&&(typeof e.minThreads!=`number`||e.minThreads<0))throw TypeError(`options.minThreads must be a non-negative integer`);if(e.maxThreads!==void 0&&(typeof e.maxThreads!=`number`||e.maxThreads<1))throw TypeError(`options.maxThreads must be a positive integer`);if(e.minThreads!==void 0&&e.maxThreads!==void 0&&e.minThreads>e.maxThreads)throw RangeError(`options.minThreads and options.maxThreads must not conflict`);if(e.idleTimeout!==void 0&&(typeof e.idleTimeout!=`number`||e.idleTimeout<0))throw TypeError(`options.idleTimeout must be a non-negative integer`);if(e.maxQueue!==void 0&&e.maxQueue!==`auto`&&(typeof e.maxQueue!=`number`||e.maxQueue<0))throw TypeError(`options.maxQueue must be a non-negative integer`);if(e.concurrentTasksPerWorker!==void 0&&(typeof e.concurrentTasksPerWorker!=`number`||e.concurrentTasksPerWorker<1))throw TypeError(`options.concurrentTasksPerWorker must be a positive integer`);if(e.atomics!=null&&(typeof e.atomics!=`string`||![`sync`,`async`,`disabled`].includes(e.atomics)))throw TypeError(`options.atomics should be a value of sync, sync or disabled.`);if(e.resourceLimits!==void 0&&(typeof e.resourceLimits!=`object`||e.resourceLimits===null))throw TypeError(`options.resourceLimits must be an object`);if(e.taskQueue!==void 0&&!(0,w.isTaskQueue)(e.taskQueue))throw TypeError(`options.taskQueue must be a TaskQueue object`);if(e.niceIncrement!==void 0&&(typeof e.niceIncrement!=`number`||e.niceIncrement<0&&process.platform!==`win32`))throw TypeError(`options.niceIncrement must be a non-negative integer on Unix systems`);if(e.trackUnmanagedFds!==void 0&&typeof e.trackUnmanagedFds!=`boolean`)throw TypeError(`options.trackUnmanagedFds must be a boolean value`);if(e.closeTimeout!==void 0&&(typeof e.closeTimeout!=`number`||e.closeTimeout<0))throw TypeError(`options.closeTimeout must be a non-negative integer`);if(e.loadBalancer!==void 0&&(typeof e.loadBalancer!=`function`||e.loadBalancer.length<1))throw TypeError(`options.loadBalancer must be a function with at least two args`);if(e.workerHistogram!==void 0&&typeof e.workerHistogram!=`boolean`)throw TypeError(`options.workerHistogram must be a boolean`);n(this,o,new I(this,e),`f`)}run(e,t=M){if(typeof t!=`object`||!t)return Promise.reject(TypeError(`options must be an object`));let{transferList:n,filename:i,name:a,signal:s}=t;return n!==void 0&&!Array.isArray(n)?Promise.reject(TypeError(`transferList argument must be an Array`)):i!=null&&typeof i!=`string`?Promise.reject(TypeError(`filename argument must be a string`)):a!=null&&typeof a!=`string`?Promise.reject(TypeError(`name argument must be a string`)):s!=null&&typeof s!=`object`?Promise.reject(TypeError(`signal argument must be an object`)):r(this,o,`f`).runTask(e,{transferList:n,filename:i,name:a,signal:s})}async close(e=N){if(typeof e!=`object`||!e)throw TypeError(`options must be an object`);let{force:t}=e;return t!==void 0&&typeof t!=`boolean`?Promise.reject(TypeError(`force argument must be a boolean`)):(t??=N.force,r(this,o,`f`).close({force:t}))}destroy(){return r(this,o,`f`).destroy()}[(o=new WeakMap,s=new WeakMap,Symbol.dispose)](){this.close()}[Symbol.asyncDispose](){return this.close()}get maxThreads(){return r(this,o,`f`).options.maxThreads}get minThreads(){return r(this,o,`f`).options.minThreads}get options(){return r(this,o,`f`).options}get threads(){let e=[];for(let t of r(this,o,`f`).workers)e.push(t.worker);return e}get queueSize(){let e=r(this,o,`f`);return Math.max(e.taskQueue.size-e.pendingCapacity(),0)}get completed(){return r(this,o,`f`).completed}get histogram(){if(r(this,s,`f`)==null){let e={get runTime(){return this.histogram?.runTimeSummary},get waitTime(){return this.histogram?.waitTimeSummary},resetRunTime(){var e;(e=this.histogram)==null||e.resetRunTime()},resetWaitTime(){var e;(e=this.histogram)==null||e.resetWaitTime()}};Object.defineProperty(e,`histogram`,{value:r(this,o,`f`).histogram,writable:!1,enumerable:!1,configurable:!1}),n(this,s,e,`f`)}return r(this,s,`f`)}get utilization(){if(r(this,o,`f`).histogram==null)return 0;let e=r(this,o,`f`).histogram.runTimeCount;if(e===0)return 0;let t=this.duration*r(this,o,`f`).options.maxThreads;return r(this,o,`f`).histogram.runTimeSummary.mean/1e3*e/t}get duration(){return g.performance.now()-r(this,o,`f`).start}get needsDrain(){return r(this,o,`f`)._needsDrain}static get isWorkerThread(){return k.commonState.isWorkerThread}static get workerData(){return k.commonState.workerData}static get version(){return x.version}static get Piscina(){return e}static get FixedQueue(){return w.FixedQueue}static get ArrayTaskQueue(){return w.ArrayTaskQueue}static move(e){return typeof e==`object`&&e&&typeof e!=`function`&&((0,k.isTransferable)(e)||(e=d.types.isArrayBufferView(e)?new F(e):new P(e)),(0,k.markMovable)(e)),e}static get transferableSymbol(){return S.kTransferable}static get valueSymbol(){return S.kValue}static get queueOptionsSymbol(){return S.kQueueOptions}};t.default=L,t.Piscina=L,t.move=L.move,t.isWorkerThread=L.isWorkerThread,t.workerData=L.workerData})),T=t(n(((e,t)=>{t.exports=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(w()).default}))(),1),E=T.default;T.default.ArrayTaskQueue,T.default.FixedQueue,T.default.Piscina,T.default.isWorkerThread,T.default.move,T.default.queueOptionsSymbol,T.default.transferableSymbol,T.default.valueSymbol,T.default.version,T.default.workerData;var D=class{pool;constructor(e){this.pool=new E({filename:e.workerEntry,maxThreads:e.maxConcurrency??4,idleTimeout:e.idleTimeoutMs??3e4})}async run(e,t){return this.pool.run(e,{signal:t})}onMessage(e){return this.pool.on(`message`,e),()=>this.pool.off(`message`,e)}async dispose(){await this.pool.destroy()}},O=class{options;manifest;pool;constructor(e){this.options=e,this.manifest=e.manifest}async run(e,t,n){return this.pool??=new D(this.options),this.pool.run({config:e,manifest:n??this.manifest},t)}runWithReadiness(e,t,n){this.pool??=new D(this.options);let r=this.pool,a,o=!1,s,c=new Promise((t,n)=>{s=n,a=r.onMessage(n=>{i(n)&&(n.executionId!==e.executionId||n.cancelSubject!==e.cancelSubject||(o=!0,a?.(),t(n)))})}),l=r.run({config:e,manifest:n??this.manifest},t);return l.then(()=>{o||(o=!0,a?.(),s(Error(`Workflow worker completed before ready signal: ${e.executionId}`)))},e=>{o||(o=!0,a?.(),s(e instanceof Error?e:Error(String(e))))}),{result:l,ready:c}}async dispose(){await this.pool?.dispose()}};function k(e){return e.mode===`source`?s(e.moduleDir,`workflow-worker`,`worker-entry.ts`):s(e.moduleDir,`workflow-worker`,`worker-entry.mjs`)}function A(e,t){let n=t.executionHints?.requirements?.capabilities??[];if(n.length===0)return e;let r=e?.customCapabilities??[];return{...e,customCapabilities:[...new Set([...r,...n])]}}var j=class{options;constructor(e){this.options=e}run(e,t,n,r){let i=n??this.options.manifest,a=A(this.options.requirements,e),o=r?.dispatchMetadata;return this.options.dispatch({config:e,...i!==void 0&&{manifest:i},...a!==void 0&&{requirements:a},...o!==void 0&&{metadata:o}},t)}},M=class{#e;constructor(e){this.#e=e.bus}async run(e,t,n){let i=u.parse(e),o=await r(i);return d({config:await a(i,o,this.#e,t),loaded:o,bus:this.#e,signal:t})}};function N(){return{packages:[]}}function P(e){let t=o(e.runtimeModuleDir)===`src`?`source`:`dist`,n=F({moduleDir:e.runtimeModuleDir,defaultWorkerEntryMode:t,runner:e.workflowRunner,bus:e.bus});return{...n!==void 0&&{workflowRunner:n},executorConfig:{busUrl:e.busUrl,busAuth:{kind:`none`},platformDefaults:e.platformDefaults,makaioHome:e.makaioHome}}}function F(e){let{runner:t}=e;if(t)switch(t.mode){case void 0:case`in-process`:if(e.bus===void 0)throw Error(`InProcessWorkflowRunner requires a bus instance. Pass 'bus' to createNodeWorkflowRunner when runner.mode is 'in-process'.`);return new M({bus:e.bus});case`worker-node`:{let n=e.bus,r=t.dispatch??(n===void 0?void 0:(e,t)=>n.request(l.dispatch,{config:e.config,manifest:e.manifest,requirements:e.requirements,metadata:e.metadata},{signal:t}));if(r===void 0)throw Error(`WorkerNodeRunner requires either a dispatch function or a bus instance. Pass 'bus' to createNodeWorkflowRunner when runner.mode is 'worker-node'.`);return new j({dispatch:r,...t.manifest!==void 0&&{manifest:t.manifest},...t.requirements!==void 0&&{requirements:t.requirements}})}case`piscina`:return new O({workerEntry:t.workerEntry??k({moduleDir:e.moduleDir,mode:t.workerEntryMode??e.defaultWorkerEntryMode}),manifest:t.manifest??N(),maxConcurrency:t.maxConcurrency,idleTimeoutMs:t.idleTimeoutMs})}}function I(e){return e instanceof Error?e:Error(String(e??`WorkerNode wait aborted`))}function L(e){return typeof e.runWithReadiness==`function`}const R={persistentStorage:!0,customCapabilities:[`workflow.local-runtime`,`workflow.thin-runner`],suspensionStrategy:`wait-in-process`};var z=class{options;environment=`piscina`;baseCapabilities;constructor(e){this.options=e,this.baseCapabilities=c.parse({...R,...e.baseCapabilities,suspensionStrategy:e.baseCapabilities?.suspensionStrategy??R.suspensionStrategy})}get id(){return this.options.id}get displayName(){return this.options.displayName}async provision(e){let t=new AbortController,n=L(this.options.runner)?this.options.runner.runWithReadiness(e.workerConfig,t.signal,e.workerManifest):{result:this.options.runner.run(e.workerConfig,t.signal,e.workerManifest),ready:void 0},r=n.result,i=n.ready?.then(e=>({adapters:e.adapters}));return i?.catch(()=>void 0),r.catch(()=>void 0),{nodeId:e.nodeId,...i!==void 0&&{ready:i},waitForResult:async e=>{if(e.aborted)return t.abort(e.reason),Promise.reject(I(e.reason));let n,i=new Promise((e,t)=>{n=t}),a=()=>{t.abort(e.reason),n(I(e.reason))};e.addEventListener(`abort`,a,{once:!0});try{return await Promise.race([r,i])}finally{e.removeEventListener(`abort`,a)}},cancel:e=>(t.abort(e??`WorkerNode cancelled`),Promise.resolve()),terminate:()=>(t.abort(`WorkerNode terminated`),Promise.resolve())}}};export{j as a,M as i,F as n,k as o,P as r,O as s,z as t};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makaio/framework",
|
|
3
|
-
"version": "1.0.0-dev-
|
|
3
|
+
"version": "1.0.0-dev-1781766035621",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/makaio-ai/makaio-framework.git",
|
|
@@ -511,6 +511,10 @@
|
|
|
511
511
|
"types": "./dist/utils/health-probe.d.mts",
|
|
512
512
|
"default": "./dist/utils/health-probe.mjs"
|
|
513
513
|
},
|
|
514
|
+
"./utils/package-root": {
|
|
515
|
+
"types": "./dist/utils/resolve-package-root.d.mts",
|
|
516
|
+
"default": "./dist/utils/resolve-package-root.mjs"
|
|
517
|
+
},
|
|
514
518
|
"./utils/project-manifest": {
|
|
515
519
|
"types": "./dist/utils/project-manifest.d.mts",
|
|
516
520
|
"default": "./dist/utils/project-manifest.mjs"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{pathToFileURL as e}from"node:url";import{mkdir as t,rm as n,writeFile as r}from"node:fs/promises";import{basename as i,join as a}from"node:path";import{randomBytes as o}from"node:crypto";import{WorkflowDefinitionSchema as s,WorkflowError as c,WorkflowErrorCode as l}from"@makaio/framework/contracts";import{tmpdir as u}from"node:os";function d(e,t,n=[]){return{type:`makaio.workflow-worker.ready`,executionId:e,cancelSubject:t,adapters:n}}function f(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`makaio.workflow-worker.ready`&&typeof t.executionId==`string`&&typeof t.cancelSubject==`string`&&Array.isArray(t.adapters)&&t.adapters.every(e=>typeof e==`string`)}function p(e){if(typeof e!=`object`||!e)throw new c(l.NOT_EXECUTABLE,`Invalid workflow module default export: expected an object with 'definition' and 'runtimeHandlers', got ${typeof e}.`);let t=e;if(!(t.runtimeHandlers instanceof Map))throw new c(l.NOT_EXECUTABLE,`Invalid workflow module default export: 'runtimeHandlers' must be a Map instance.`);let n=s.safeParse(t.definition);if(!n.success)throw new c(l.NOT_EXECUTABLE,`Invalid workflow module default export: 'definition' must satisfy WorkflowDefinitionSchema. `+n.error.message);let r=m(t.zodSchemas)?t.zodSchemas:void 0,i=t.runtimeLoopGates instanceof Map?t.runtimeLoopGates:void 0;return{definition:n.data,runtimeHandlers:t.runtimeHandlers,...r===void 0?{}:{zodSchemas:r},...i===void 0?{}:{runtimeLoopGates:i}}}function m(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&`gates`in e}async function h(e,s){let c=i(e);if(!c||c===`.`||c===`..`)throw Error(`Invalid workflow source filename: ${e}`);let l=a(u(),`makaio-wf-${o(6).toString(`hex`)}`);await t(l,{recursive:!0});let d=a(l,c.endsWith(`.mjs`)?c:`${c}.mjs`);try{await r(d,s,`utf8`)}catch(e){throw await n(l,{recursive:!0,force:!0}).catch(()=>{}),e}return{tempDir:l,tempPath:d}}function g(e){return typeof e==`object`&&e&&Array.isArray(e.workflows)?e.workflows.map(p):[p(e)]}async function _(t){if(t.kind===`path`)return g((await import(e(t.path).href)).default);let{tempDir:r,tempPath:i}=await h(t.filename,t.source);try{return g((await import(e(i).href)).default)}finally{await n(r,{recursive:!0,force:!0})}}async function v(e){if(e.kind===`definition`)throw new c(l.NOT_EXECUTABLE,`Definition-sourced workers are handled by the workflow executor, not the file loader. Received source: ${JSON.stringify(e)}`);let t=await _(e);if(t.length!==1)throw new c(l.NOT_EXECUTABLE,`loadWorkflowModule expects a single workflow export, but the module exported ${String(t.length)} workflows. Use loadWorkflowModules for bundle exports.`);return t[0]}async function y(e){if(e.source.kind===`definition`){if(e.definition===void 0)throw Error(`Definition-sourced worker config for workflowId "${e.source.workflowId}" is missing the required 'definition' field. Ensure the executor populates WorkflowWorkerConfig.definition before dispatching.`);return{definition:e.definition,runtimeHandlers:new Map}}let t=await v(e.source);return b(e,t),e.definition===void 0?t:{...t,definition:e.definition}}function b(e,t){if(e.workflowId!==e.executionId&&t.definition.id!==e.workflowId)throw new c(l.SOURCE_MISMATCH,`Source-backed workflow for logical workflow '${e.workflowId}' loaded definition '${t.definition.id}'.`)}function x(e){let t=e.indexOf(`.`);if(t<=0||t===e.length-1)throw Error(`Invalid trigger subject: ${e}`);return{subject:e.slice(t+1),$meta:{namespace:e.slice(0,t),isRequest:!1,payload:{},local:!1,channel:!1}}}function S(e,t,n){return new Promise((r,i)=>{if(n.aborted){i(n.reason??Error(`Await-trigger aborted`));return}let a=[];function o(){for(let e of a)e();a.length=0}let s=()=>{o(),i(n.reason??Error(`Await-trigger aborted`))};n.addEventListener(`abort`,s,{once:!0}),a.push(()=>n.removeEventListener(`abort`,s));try{for(let n of t){let t=x(n.subject),i=e.on(t,e=>{o(),r(e.payload)},n.filter?{filter:n.filter}:void 0);a.push(i)}}catch(e){o(),i(e)}})}async function C(e,t,n,r){let i=(t.definition.triggers??[]).filter(e=>e.type===`bus-event`);if(Object.keys(e.triggerPayload).length!==0||i.length===0)return e;let a=await S(n,i,r);return{...e,triggerPayload:a}}export{d as a,_ as i,y as n,f as o,v as r,C as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./json-value-CmhSGMLv.mjs";import{a as t}from"./visibility-Cb62p9bv.mjs";import"./credential-ref-YWQQENEo.mjs";import{f as n}from"./shared-DpOEfD8F.mjs";import{z as r}from"zod";const i=`adapter identity must be provided at the top level; contextOverrides cannot supply adapter identity`;function a(e){let t={adapterId:e.adapterId,adapterName:e.adapterName},n={adapterId:e.contextOverrides?.adapterId,adapterName:e.contextOverrides?.adapterName},r=[];!o(t)&&o(n)&&(n.adapterId!==void 0&&r.push({field:`adapterId`,message:i}),n.adapterName!==void 0&&r.push({field:`adapterName`,message:i}));for(let e of[`adapterId`,`adapterName`]){let i=n[e];if(i===void 0)continue;let a=t[e];if(a===void 0){o(t)&&r.push({field:e,message:`contextOverrides.${e} cannot supply adapter identity when top-level adapter identity is present`});continue}a!==i&&r.push({field:e,message:`contextOverrides.${e} must match top-level ${e} when both are provided`})}return{issues:r,effectiveIdentity:{adapterId:t.adapterId??n.adapterId,adapterName:t.adapterName??n.adapterName}}}function o(e){return e.adapterId!==void 0||e.adapterName!==void 0}const s=r.object({readOnly:r.boolean().optional(),destructive:r.boolean().optional(),idempotent:r.boolean().optional(),requiresApproval:r.boolean().optional()}),c=r.object({name:r.string(),description:r.string(),annotations:s.optional(),toolsetName:r.string()}),l=r.object({code:r.string(),message:r.string(),details:r.unknown().optional()}),u=r.object({toolName:r.string(),toolsetName:r.string()}),d=c.extend({inputSchema:r.record(r.string(),r.unknown()).optional()}),f=r.object({name:r.string(),description:r.string(),version:r.string(),toolCount:r.number(),configSchema:r.record(r.string(),r.unknown()).optional()}),p=r.object({cwd:r.string().optional(),env:r.record(r.string(),r.string()).optional(),sessionId:r.string().optional(),agentId:r.string().optional(),adapterId:r.string().optional(),adapterName:r.string().optional(),turnId:r.string().optional(),turnContext:r.record(r.string(),r.unknown()).optional(),reasoning:r.string().optional(),toolCallId:r.string().optional(),constraints:r.record(r.string(),r.unknown()).optional()});function m(e,t){let{issues:n}=a(e);for(let e of n)t.addIssue({code:r.ZodIssueCode.custom,message:e.message,path:[`contextOverrides`,e.field]})}const h=r.object({toolName:r.string(),input:r.unknown(),adapterId:r.string().optional(),adapterName:r.string().optional(),contextOverrides:p.optional()}).superRefine(m),g={list:{request:r.object({toolsetName:r.string().optional(),adapterId:r.string().optional(),adapterName:r.string().optional()}),response:r.object({tools:r.array(d),toolsets:r.array(f)})},execute:{request:h,response:r.discriminatedUnion(`success`,[r.object({success:r.literal(!0),data:r.unknown()}),r.object({success:r.literal(!1),error:l})])},registered:r.object({toolsetName:r.string(),toolsetVersion:r.string(),toolNames:r.array(r.string())}),started:u.extend({executionId:r.string(),timestamp:r.number()}),completed:u.extend({executionId:r.string(),timestamp:r.number(),durationMs:r.number()}),error:u.extend({executionId:r.string(),timestamp:r.number(),error:l}),registryChanged:r.object({revision:r.number().int().positive(),reason:r.enum([`toolset-registered`,`toolset-unregistered`,`plugin-loaded`,`plugin-unloaded`]),toolsetName:r.string()})},_=r.object({name:r.string(),permission_policy:r.enum([`always_allow`,`always_ask`,`always_deny`])}),v=r.array(_).superRefine((e,t)=>{let n=new Set;e.forEach((e,i)=>{if(n.has(e.name)){t.addIssue({code:r.ZodIssueCode.custom,path:[i,`name`],message:`Duplicate MCP tool policy name "${e.name}"`});return}n.add(e.name)})}),y=r.object({type:r.literal(`stdio`),command:r.string(),args:r.array(r.string()).optional(),env:r.record(r.string(),r.string()).optional(),alwaysLoad:r.boolean().optional()}),b=r.object({url:r.string().url(),headers:r.record(r.string(),r.string()).optional(),tools:v.optional(),alwaysLoad:r.boolean().optional()}),x=b.extend({type:r.literal(`sse`)}),S=b.extend({type:r.literal(`http`)}),C=r.discriminatedUnion(`type`,[y,x,S]),w=r.enum([`direct`,`discovery`,`hidden`]),T=w.exclude([`hidden`]),E=r.record(r.string(),w).optional(),D=r.string().max(256).refine(e=>(e.match(/\*/g)?.length??0)<=10,{message:`Pattern must contain at most 10 wildcard characters`}),O=r.object({transport:C,exposureMode:T.optional(),toolExposure:E}),k=r.object({enabled:r.boolean(),maxAttempts:r.number().int().positive(),baseDelayMs:r.number().int().positive(),maxDelayMs:r.number().int().positive()}).refine(e=>e.maxDelayMs>=e.baseDelayMs,{message:`maxDelayMs must be >= baseDelayMs`,path:[`maxDelayMs`]});r.object({servers:r.record(r.string(),O),hideTools:r.array(D).optional(),exposeTools:r.array(D).optional(),defaultExposureMode:T.optional(),autoReconnect:k.optional()}),r.object({servers:r.array(r.string()).optional(),exposeTools:r.array(D).optional(),hideTools:r.array(D).optional(),serverOverrides:r.record(r.string(),r.object({exposureMode:T.optional(),toolExposure:E})).optional()});const A=r.object({directTools:r.array(D).optional(),discoveryTools:r.array(D).optional(),toolExposure:E}),j=r.object({name:r.string(),transport:C,exposureMode:T}),M=r.object({fullName:r.string(),originalName:r.string(),serverName:r.string(),description:r.string().optional(),inputSchema:r.record(r.string(),r.unknown()),exposureMode:w,enabled:r.boolean(),enabledBy:r.enum([`discovery`,`toolset`]).optional(),enabledAt:r.number().int().nonnegative().optional(),exposed:r.boolean()}),N=r.object({sessionId:r.string(),projectId:r.string().nullable(),profileId:r.string().nullable(),servers:r.array(j),directTools:r.array(M),discoverableTools:r.array(M)}),P=N.omit({projectId:!0,profileId:!0}),F=r.object({agentId:r.string(),adapterId:r.string(),adapterName:r.string(),adapterSessionId:r.string(),sessionId:r.string()}),I={"server.connected":r.object({serverName:r.string(),toolCount:r.number().int().nonnegative()}),"server.disconnected":r.object({serverName:r.string(),reason:r.string()}),"server.reconnecting":r.object({serverName:r.string(),attempt:r.number().int().positive()}),"server.error":r.object({serverName:r.string(),error:r.string()}),"tools.updated":r.object({added:r.array(r.string()),removed:r.array(r.string())}),"tools.enabled":r.object({tools:r.array(r.string()),source:r.enum([`discovery`,`toolset`])}),"session.resolve":{request:r.object({sessionId:r.string(),profileId:r.string().nullable(),projectId:r.string().nullable(),profileMcpConfig:A.optional()}),response:N},"session.register":{request:F.extend({contextOverrides:p,pinned:r.boolean().optional()}),response:r.object({port:r.number().int().positive()})},"session.unregister":{request:r.object({adapterSessionId:r.string()}),response:r.object({})}},L=r.looseObject({kind:r.string(),providerConfigId:r.string().optional(),model:r.string().optional(),reasoningEffort:t.optional(),cwd:r.string().optional(),systemPrompt:n.optional(),allowedTools:r.array(r.string()).optional(),disallowedTools:r.array(r.string()).optional(),env:r.record(r.string(),r.string()).optional(),mcpSessionContext:P.optional(),allowedDirectories:r.array(r.string()).optional(),adapterConfig:e.optional()}),R=L.extend({kind:r.literal(`adapter`),adapterName:r.string().trim().min(1).optional(),adapterId:r.string().trim().min(1).optional()}).refine(e=>!!e.adapterName||!!e.adapterId,{message:`AdapterSelection requires at least one of 'adapterName' or 'adapterId'`}),z=L,B=L.safeExtend({kind:r.literal(`canonical-model`),model:r.string().trim().min(1)}),V=r.enum([`auto`,`manual`,`off`]);export{z as a,T as c,I as d,N as f,a as g,g as h,L as i,A as l,C as m,B as n,k as o,D as p,R as r,w as s,V as t,P as u};
|