@bian-womp/spark-remote 0.3.19 → 0.3.21

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/lib/cjs/index.cjs CHANGED
@@ -520,6 +520,25 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
520
520
  });
521
521
  await originalAdapter.setExtData(payload.extData || {});
522
522
  },
523
+ convertSnapshot: async (converterConfig, options) => {
524
+ const snapshot = await originalAdapter.snapshotFull();
525
+ const converter = sparkGraph.buildValueConverter(converterConfig);
526
+ const converted = sparkGraph.convertSnapshot(snapshot, converter);
527
+ await originalAdapter.applySnapshotFull(converted, {
528
+ skipBuild: true,
529
+ });
530
+ return converted;
531
+ },
532
+ pause: async () => {
533
+ if (!graphRuntime)
534
+ return;
535
+ graphRuntime.pause();
536
+ },
537
+ resume: async () => {
538
+ if (!graphRuntime)
539
+ return;
540
+ graphRuntime.resume();
541
+ },
523
542
  cancelNodeRuns: (nodeIds) => {
524
543
  if (!graphRuntime)
525
544
  return;
@@ -623,7 +642,7 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
623
642
  }
624
643
  // Create new engine using shared factory
625
644
  engine = new sparkGraph.LocalEngine(graphRuntime, opts?.runMode);
626
- engine.launch(opts?.invalidate);
645
+ engine.launch(opts?.invalidate, opts?.runMode, opts?.startPaused);
627
646
  },
628
647
  setRunMode: (runMode) => {
629
648
  if (!engine)
@@ -696,6 +715,7 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
696
715
  snapshot: wrapMethod("snapshot", originalAdapter.snapshot),
697
716
  snapshotFull: wrapMethod("snapshotFull", originalAdapter.snapshotFull),
698
717
  applySnapshotFull: wrapMethod("applySnapshotFull", originalAdapter.applySnapshotFull),
718
+ convertSnapshot: wrapMethod("convertSnapshot", originalAdapter.convertSnapshot),
699
719
  describeRegistry: wrapMethod("describeRegistry", originalAdapter.describeRegistry),
700
720
  update: wrapMethod("update", originalAdapter.update),
701
721
  setEnvironment: wrapMethod("setEnvironment", originalAdapter.setEnvironment),
@@ -703,6 +723,8 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
703
723
  commit: wrapMethod("commit", originalAdapter.commit),
704
724
  undo: wrapMethod("undo", originalAdapter.undo),
705
725
  redo: wrapMethod("redo", originalAdapter.redo),
726
+ pause: wrapMethod("pause", originalAdapter.pause),
727
+ resume: wrapMethod("resume", originalAdapter.resume),
706
728
  launch: wrapMethod("launch", originalAdapter.launch),
707
729
  // Engine methods
708
730
  setInputs: wrapMethod("setInputs", originalAdapter.setInputs),
@@ -926,6 +948,23 @@ class RemoteGraphLifecycleApi {
926
948
  },
927
949
  });
928
950
  }
951
+ async convertSnapshot(converterConfig, options) {
952
+ const transport = await this.ensureConnected();
953
+ const res = await transport.request({
954
+ message: {
955
+ type: "ConvertSnapshot",
956
+ payload: { converterConfig },
957
+ dry: options?.dry,
958
+ },
959
+ });
960
+ const payload = res?.message || {};
961
+ return (payload.snapshot || {
962
+ def: undefined,
963
+ environment: {},
964
+ inputs: {},
965
+ outputs: {},
966
+ });
967
+ }
929
968
  async describeRegistry() {
930
969
  const transport = await this.ensureConnected();
931
970
  const res = await transport.request({
@@ -1014,6 +1053,18 @@ class RemoteGraphLifecycleApi {
1014
1053
  const payload = res?.message || {};
1015
1054
  return payload.success ?? false;
1016
1055
  }
1056
+ async pause() {
1057
+ const transport = await this.ensureConnected();
1058
+ await transport.request({
1059
+ message: { type: "Pause" },
1060
+ });
1061
+ }
1062
+ async resume() {
1063
+ const transport = await this.ensureConnected();
1064
+ await transport.request({
1065
+ message: { type: "Resume" },
1066
+ });
1067
+ }
1017
1068
  }
1018
1069
 
1019
1070
  // Node-only transport using a UNIX domain socket.
@@ -1504,6 +1555,14 @@ class ServerCommandHandler {
1504
1555
  ack();
1505
1556
  break;
1506
1557
  }
1558
+ case "ConvertSnapshot": {
1559
+ const converterConfig = msg.payload.converterConfig;
1560
+ const dry = msg.dry;
1561
+ this.logCommand("ConvertSnapshot", env, { dry });
1562
+ const converted = await this.adapter.convertSnapshot(converterConfig, { dry });
1563
+ ack({ snapshot: converted });
1564
+ break;
1565
+ }
1507
1566
  case "Coerce": {
1508
1567
  this.logCommand("Coerce", env, {
1509
1568
  from: msg.payload.from,
@@ -1559,6 +1618,18 @@ class ServerCommandHandler {
1559
1618
  ack({ success });
1560
1619
  break;
1561
1620
  }
1621
+ case "Pause": {
1622
+ this.logCommand("Pause", env);
1623
+ await this.adapter.pause();
1624
+ ack();
1625
+ break;
1626
+ }
1627
+ case "Resume": {
1628
+ this.logCommand("Resume", env);
1629
+ await this.adapter.resume();
1630
+ ack();
1631
+ break;
1632
+ }
1562
1633
  default: {
1563
1634
  this.logCommand("Unknown type", env);
1564
1635
  ack();
@@ -1592,7 +1663,7 @@ class ServerCommandHandler {
1592
1663
  * not node execution errors.
1593
1664
  */
1594
1665
  handleError(env, err) {
1595
- const errorMessage = `error handling command: ${String(err)}`;
1666
+ const errorMessage = `error handling command(${env.message.type}): ${String(err)}`;
1596
1667
  if (this.options?.logHandler) {
1597
1668
  this.options.logHandler("error", errorMessage, {
1598
1669
  seq: env.seq,