@daeda/mcp-pro 0.1.40 → 0.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +142 -141
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // src/index.ts
4
4
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
5
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
6
- import { Effect as Effect142, Layer as Layer10, pipe as pipe120 } from "effect";
6
+ import { Effect as Effect143, Layer as Layer10, pipe as pipe121 } from "effect";
7
7
  import { createRequire as createRequire2 } from "module";
8
8
 
9
9
  // src/plugins/crm-data.ts
@@ -28307,6 +28307,16 @@ var registerStdioShutdownHooks = ({
28307
28307
  };
28308
28308
  };
28309
28309
 
28310
+ // src/effects/run-manual-plugin-refresh.ts
28311
+ import { Effect as Effect142, pipe as pipe120 } from "effect";
28312
+ var runManualPluginRefresh = (deps, portalId, pluginNames) => pipe120(
28313
+ deps.resetStuckPlugins(portalId),
28314
+ Effect142.catchAll(() => Effect142.void),
28315
+ Effect142.flatMap(
28316
+ () => deps.syncMessagePlugins(portalId, pluginNames, { force: true })
28317
+ )
28318
+ );
28319
+
28310
28320
  // src/index.ts
28311
28321
  process.on("uncaughtException", (err) => {
28312
28322
  console.error("[fatal:uncaughtException]", err);
@@ -28377,7 +28387,7 @@ if (!TEST_HEADLESS_MODE) {
28377
28387
  }
28378
28388
  });
28379
28389
  }
28380
- var mainProgram = Effect142.gen(function* () {
28390
+ var mainProgram = Effect143.gen(function* () {
28381
28391
  const ws = yield* WebSocketService;
28382
28392
  const config = yield* ConfigService;
28383
28393
  const duckDb = yield* DuckDBInterfaceService;
@@ -28385,18 +28395,18 @@ var mainProgram = Effect142.gen(function* () {
28385
28395
  const portalData = yield* PortalDataService;
28386
28396
  const portalFileState = yield* PortalFileStateService;
28387
28397
  const getPortalId = () => getSelectedPortalId(config);
28388
- const getClientState2 = () => Effect142.runSync(config.load());
28398
+ const getClientState2 = () => Effect143.runSync(config.load());
28389
28399
  const saveClientState = (updater) => {
28390
28400
  const nextState = updater(getClientState2());
28391
- Effect142.runSync(config.save(nextState));
28401
+ Effect143.runSync(config.save(nextState));
28392
28402
  return nextState;
28393
28403
  };
28394
- const getPortals = () => Effect142.runSync(ws.getPortals());
28404
+ const getPortals = () => Effect143.runSync(ws.getPortals());
28395
28405
  const isPortalSyncActive = (portalId) => isPortalSyncEnabled(getClientState2(), portalId);
28396
- const getConnectionType = () => Effect142.runSync(
28397
- pipe120(
28406
+ const getConnectionType = () => Effect143.runSync(
28407
+ pipe121(
28398
28408
  duckDb.getConnectionType,
28399
- Effect142.catchAll(() => Effect142.succeed("READ_ONLY"))
28409
+ Effect143.catchAll(() => Effect143.succeed("READ_ONLY"))
28400
28410
  )
28401
28411
  );
28402
28412
  const isMasterClient = () => getConnectionType() === "MASTER";
@@ -28415,10 +28425,10 @@ var mainProgram = Effect142.gen(function* () {
28415
28425
  const handoffSelectedPortal = (nextPortalId) => {
28416
28426
  const previousPortalId = getSelectedPortalId(config);
28417
28427
  if (previousPortalId !== null && previousPortalId !== nextPortalId) {
28418
- Effect142.runSync(
28419
- pipe120(
28428
+ Effect143.runSync(
28429
+ pipe121(
28420
28430
  ws.sendSyncUnsubscribe(previousPortalId),
28421
- Effect142.catchAll(() => Effect142.void)
28431
+ Effect143.catchAll(() => Effect143.void)
28422
28432
  )
28423
28433
  );
28424
28434
  }
@@ -28430,7 +28440,7 @@ var mainProgram = Effect142.gen(function* () {
28430
28440
  if (!isPortalSyncEnabled(nextState, nextPortalId)) {
28431
28441
  return "stale_local_only";
28432
28442
  }
28433
- Effect142.runFork(pipe120(ws.sendSyncFull(nextPortalId), Effect142.catchAll(() => Effect142.void)));
28443
+ Effect143.runFork(pipe121(ws.sendSyncFull(nextPortalId), Effect143.catchAll(() => Effect143.void)));
28434
28444
  return "syncing";
28435
28445
  };
28436
28446
  registerPortalSelection(server, { ws, config, handoffSelectedPortal });
@@ -28447,15 +28457,15 @@ var mainProgram = Effect142.gen(function* () {
28447
28457
  ensureFresh
28448
28458
  });
28449
28459
  registerStatusTool(server, {
28450
- getConnectionState: () => Effect142.runSync(ws.getState()),
28460
+ getConnectionState: () => Effect143.runSync(ws.getState()),
28451
28461
  isMasterClient,
28452
28462
  getPortals,
28453
28463
  getSelectedPortalId: getPortalId,
28454
28464
  getClientState: getClientState2,
28455
- getPortalState: async (portalId) => Effect142.runPromise(
28456
- pipe120(
28465
+ getPortalState: async (portalId) => Effect143.runPromise(
28466
+ pipe121(
28457
28467
  portalFileState.load(portalId),
28458
- Effect142.catchAll(() => Effect142.succeed(null))
28468
+ Effect143.catchAll(() => Effect143.succeed(null))
28459
28469
  )
28460
28470
  ),
28461
28471
  getClientMetadata: () => STATUS_METADATA,
@@ -28479,7 +28489,7 @@ var mainProgram = Effect142.gen(function* () {
28479
28489
  actions.push(`Removed ${removed} pending portal sync job(s).`);
28480
28490
  }
28481
28491
  if (isSelected) {
28482
- Effect142.runSync(pipe120(ws.sendSyncUnsubscribe(portalId), Effect142.catchAll(() => Effect142.void)));
28492
+ Effect143.runSync(pipe121(ws.sendSyncUnsubscribe(portalId), Effect143.catchAll(() => Effect143.void)));
28483
28493
  actions.push("Stopped real-time subscription for the selected portal.");
28484
28494
  }
28485
28495
  }
@@ -28499,7 +28509,7 @@ var mainProgram = Effect142.gen(function* () {
28499
28509
  }
28500
28510
  if (!previousControl.enabled && nextControl.enabled) {
28501
28511
  if (isMasterClient()) {
28502
- Effect142.runFork(pipe120(ws.sendSyncFull(portalId), Effect142.catchAll(() => Effect142.void)));
28512
+ Effect143.runFork(pipe121(ws.sendSyncFull(portalId), Effect143.catchAll(() => Effect143.void)));
28503
28513
  if (!DISABLE_PLUGIN_SYNC) {
28504
28514
  triggerPluginSync(portalId);
28505
28515
  }
@@ -28509,7 +28519,7 @@ var mainProgram = Effect142.gen(function* () {
28509
28519
  }
28510
28520
  } else if (refreshArtifacts && nextControl.enabled) {
28511
28521
  if (isMasterClient()) {
28512
- Effect142.runFork(pipe120(ws.sendSyncFull(portalId), Effect142.catchAll(() => Effect142.void)));
28522
+ Effect143.runFork(pipe121(ws.sendSyncFull(portalId), Effect143.catchAll(() => Effect143.void)));
28513
28523
  actions.push("Requested fresh artifact manifest.");
28514
28524
  } else {
28515
28525
  actions.push("Refresh requested, but this client is read-only so no sync was started.");
@@ -28517,7 +28527,7 @@ var mainProgram = Effect142.gen(function* () {
28517
28527
  }
28518
28528
  const filtersChanged = previousControl.enabled === nextControl.enabled && previousControl.disabledArtifacts.join("\0") !== nextControl.disabledArtifacts.join("\0");
28519
28529
  if (isSelected && nextControl.enabled && filtersChanged && !refreshArtifacts) {
28520
- Effect142.runSync(pipe120(ws.sendSyncUnsubscribe(portalId), Effect142.catchAll(() => Effect142.void)));
28530
+ Effect143.runSync(pipe121(ws.sendSyncUnsubscribe(portalId), Effect143.catchAll(() => Effect143.void)));
28521
28531
  runDiffFlow(portalId);
28522
28532
  actions.push("Restarted selected portal live sync to apply artifact filters.");
28523
28533
  }
@@ -28542,39 +28552,30 @@ var mainProgram = Effect142.gen(function* () {
28542
28552
  getPortals,
28543
28553
  ws
28544
28554
  });
28545
- const runManualPluginRefresh = async (portalId, pluginNames) => {
28555
+ const runRefreshPlugins = async (portalId, pluginNames) => {
28546
28556
  const syncLayer = makeSyncLayer(portalId);
28547
- await Effect142.runPromise(
28548
- pipe120(
28549
- portalFileState.resetStuckPlugins(portalId),
28550
- Effect142.catchAll(() => Effect142.void),
28551
- Effect142.flatMap(
28552
- () => pipe120(
28553
- SyncService,
28554
- Effect142.flatMap((sync) => sync.syncMessagePlugins(portalId, pluginNames, { force: true })),
28555
- Effect142.provide(syncLayer)
28556
- )
28557
- )
28557
+ await Effect143.runPromise(runManualPluginRefresh({
28558
+ resetStuckPlugins: portalFileState.resetStuckPlugins,
28559
+ syncMessagePlugins: (targetPortalId, targetPluginNames, options2) => pipe121(
28560
+ SyncService,
28561
+ Effect143.flatMap((sync) => sync.syncMessagePlugins(targetPortalId, targetPluginNames, options2)),
28562
+ Effect143.provide(syncLayer)
28558
28563
  )
28559
- );
28560
- await publishReplica({
28561
- masterLock: { isMaster: true },
28562
- portalId
28563
- });
28564
+ }, portalId, pluginNames));
28564
28565
  };
28565
28566
  registerRefreshPluginsTool(server, {
28566
28567
  isMasterClient,
28567
28568
  getSelectedPortalId: getPortalId,
28568
28569
  getPortals,
28569
28570
  getClientState: getClientState2,
28570
- runRefresh: runManualPluginRefresh,
28571
+ runRefresh: runRefreshPlugins,
28571
28572
  requestRefresh: async (portalId, pluginNames) => {
28572
- await Effect142.runPromise(ws.requestPluginRefresh(portalId, pluginNames));
28573
+ await Effect143.runPromise(ws.requestPluginRefresh(portalId, pluginNames));
28573
28574
  },
28574
- getPortalState: async (portalId) => Effect142.runPromise(
28575
- pipe120(
28575
+ getPortalState: async (portalId) => Effect143.runPromise(
28576
+ pipe121(
28576
28577
  portalFileState.load(portalId),
28577
- Effect142.catchAll(() => Effect142.succeed(null))
28578
+ Effect143.catchAll(() => Effect143.succeed(null))
28578
28579
  )
28579
28580
  )
28580
28581
  });
@@ -28582,24 +28583,24 @@ var mainProgram = Effect142.gen(function* () {
28582
28583
  yield* config.save(state);
28583
28584
  setSelectedPortal(state.selectedPortalId);
28584
28585
  if (DISABLE_PLUGIN_SYNC) {
28585
- yield* Effect142.sync(
28586
+ yield* Effect143.sync(
28586
28587
  () => console.error("[startup] Plugin sync disabled via MCP_CLIENT_DISABLE_PLUGIN_SYNC")
28587
28588
  );
28588
28589
  }
28589
28590
  if (DISABLE_DIFF_FOLLOWUP) {
28590
- yield* Effect142.sync(
28591
+ yield* Effect143.sync(
28591
28592
  () => console.error("[startup] Diff follow-up disabled via MCP_CLIENT_DISABLE_DIFF_FOLLOWUP")
28592
28593
  );
28593
28594
  }
28594
28595
  if (TEST_HEADLESS_MODE) {
28595
- yield* Effect142.sync(
28596
+ yield* Effect143.sync(
28596
28597
  () => console.error("[startup] Headless mode enabled via MCP_CLIENT_TEST_HEADLESS")
28597
28598
  );
28598
28599
  }
28599
28600
  if (state.selectedPortalId !== null) {
28600
- const cached = yield* portalFileState.load(state.selectedPortalId).pipe(Effect142.catchAll(() => Effect142.succeed(null)));
28601
+ const cached = yield* portalFileState.load(state.selectedPortalId).pipe(Effect143.catchAll(() => Effect143.succeed(null)));
28601
28602
  if (cached !== null) {
28602
- yield* Effect142.sync(
28603
+ yield* Effect143.sync(
28603
28604
  () => console.error(`[startup] Loaded ${cached.artifacts.length} cached artifacts for portal ${state.selectedPortalId}`)
28604
28605
  );
28605
28606
  }
@@ -28630,24 +28631,24 @@ var mainProgram = Effect142.gen(function* () {
28630
28631
  return;
28631
28632
  }
28632
28633
  pendingPortalFollowUps.add(portalId);
28633
- Effect142.runFork(
28634
- pipe120(
28635
- Effect142.promise(() => waitForPortalDrain(portalId, QUEUE_DRAIN_TIMEOUT_MS)),
28636
- Effect142.flatMap(
28637
- (drained) => drained ? Effect142.sync(() => {
28634
+ Effect143.runFork(
28635
+ pipe121(
28636
+ Effect143.promise(() => waitForPortalDrain(portalId, QUEUE_DRAIN_TIMEOUT_MS)),
28637
+ Effect143.flatMap(
28638
+ (drained) => drained ? Effect143.sync(() => {
28638
28639
  console.error(`[live-sync] Queue drained for portal ${portalId} after ${source} \u2014 triggering diff flow`);
28639
28640
  runDiffFlow(portalId);
28640
- }) : Effect142.sync(
28641
+ }) : Effect143.sync(
28641
28642
  () => console.error(`[live-sync] Timed out waiting for portal ${portalId} queue drain after ${source}`)
28642
28643
  )
28643
28644
  ),
28644
- Effect142.ensuring(
28645
- Effect142.sync(() => {
28645
+ Effect143.ensuring(
28646
+ Effect143.sync(() => {
28646
28647
  pendingPortalFollowUps.delete(portalId);
28647
28648
  })
28648
28649
  ),
28649
- Effect142.catchAll(
28650
- (error) => Effect142.sync(() => {
28650
+ Effect143.catchAll(
28651
+ (error) => Effect143.sync(() => {
28651
28652
  console.error(`[live-sync] Failed post-queue follow-up for portal ${portalId}:`, error);
28652
28653
  })
28653
28654
  )
@@ -28666,12 +28667,12 @@ var mainProgram = Effect142.gen(function* () {
28666
28667
  console.error(`[live-sync] Skipping subscribe for portal ${portalId} because portal sync is disabled`);
28667
28668
  return;
28668
28669
  }
28669
- Effect142.runFork(
28670
- pipe120(
28671
- Effect142.all({
28670
+ Effect143.runFork(
28671
+ pipe121(
28672
+ Effect143.all({
28672
28673
  workflowState: duckDb.getWorkflowStateSummary(portalId).pipe(
28673
- Effect142.catchAll(
28674
- (error) => Effect142.sync(() => {
28674
+ Effect143.catchAll(
28675
+ (error) => Effect143.sync(() => {
28675
28676
  console.error(
28676
28677
  `[live-sync] Failed to read workflow state summary for portal ${portalId}; subscribing with empty state:`,
28677
28678
  error
@@ -28681,8 +28682,8 @@ var mainProgram = Effect142.gen(function* () {
28681
28682
  )
28682
28683
  ),
28683
28684
  propertyDefinitionState: duckDb.getPropertyDefinitionStateSummary(portalId).pipe(
28684
- Effect142.catchAll(
28685
- (error) => Effect142.sync(() => {
28685
+ Effect143.catchAll(
28686
+ (error) => Effect143.sync(() => {
28686
28687
  console.error(
28687
28688
  `[live-sync] Failed to read property definition state summary for portal ${portalId}; subscribing with empty state:`,
28688
28689
  error
@@ -28692,8 +28693,8 @@ var mainProgram = Effect142.gen(function* () {
28692
28693
  )
28693
28694
  ),
28694
28695
  objectSyncTimes: portalData.getObjectSyncTimes(portalId).pipe(
28695
- Effect142.catchAll(
28696
- (error) => Effect142.sync(() => {
28696
+ Effect143.catchAll(
28697
+ (error) => Effect143.sync(() => {
28697
28698
  console.error(
28698
28699
  `[live-sync] Failed to read object sync times for portal ${portalId}; subscribing with empty object filter:`,
28699
28700
  error
@@ -28703,7 +28704,7 @@ var mainProgram = Effect142.gen(function* () {
28703
28704
  )
28704
28705
  )
28705
28706
  }),
28706
- Effect142.flatMap(
28707
+ Effect143.flatMap(
28707
28708
  ({ workflowState, propertyDefinitionState, objectSyncTimes }) => ws.sendSyncSubscribe(
28708
28709
  portalId,
28709
28710
  workflowState,
@@ -28711,7 +28712,7 @@ var mainProgram = Effect142.gen(function* () {
28711
28712
  filterEnabledObjectTypes(getClientState2(), portalId, Object.keys(objectSyncTimes))
28712
28713
  )
28713
28714
  ),
28714
- Effect142.catchAll(() => Effect142.void)
28715
+ Effect143.catchAll(() => Effect143.void)
28715
28716
  )
28716
28717
  );
28717
28718
  };
@@ -28724,25 +28725,25 @@ var mainProgram = Effect142.gen(function* () {
28724
28725
  console.error(`[live-sync] Skipping catch-up diff for portal ${portalId} because portal sync is disabled`);
28725
28726
  return;
28726
28727
  }
28727
- pipe120(
28728
+ pipe121(
28728
28729
  portalData.getObjectSyncTimes(portalId),
28729
- Effect142.catchAll(() => Effect142.succeed({})),
28730
- Effect142.flatMap((syncTimes) => {
28730
+ Effect143.catchAll(() => Effect143.succeed({})),
28731
+ Effect143.flatMap((syncTimes) => {
28731
28732
  const filteredSyncTimes = filterEnabledSyncTimes(getClientState2(), portalId, syncTimes);
28732
28733
  const count = Object.keys(filteredSyncTimes).length;
28733
28734
  if (count === 0) {
28734
- return Effect142.sync(() => {
28735
+ return Effect143.sync(() => {
28735
28736
  console.error(`[live-sync] No enabled object watermarks found in DuckDB for portal ${portalId}, skipping diff`);
28736
28737
  });
28737
28738
  }
28738
- return pipe120(
28739
- Effect142.sync(() => {
28739
+ return pipe121(
28740
+ Effect143.sync(() => {
28740
28741
  console.error(`[live-sync] Triggering catch-up diff for portal ${portalId} with ${count} enabled object types: ${JSON.stringify(filteredSyncTimes)}`);
28741
28742
  }),
28742
- Effect142.flatMap(() => pipe120(ws.sendSyncDiff(portalId, filteredSyncTimes), Effect142.catchAll(() => Effect142.void)))
28743
+ Effect143.flatMap(() => pipe121(ws.sendSyncDiff(portalId, filteredSyncTimes), Effect143.catchAll(() => Effect143.void)))
28743
28744
  );
28744
28745
  }),
28745
- Effect142.runFork
28746
+ Effect143.runFork
28746
28747
  );
28747
28748
  };
28748
28749
  const triggerDiffThenSubscribe = (portalId) => {
@@ -28754,26 +28755,26 @@ var mainProgram = Effect142.gen(function* () {
28754
28755
  console.error(`[live-sync] Skipping catch-up diff/subscription for portal ${portalId} because portal sync is disabled`);
28755
28756
  return;
28756
28757
  }
28757
- pipe120(
28758
+ pipe121(
28758
28759
  portalData.getObjectSyncTimes(portalId),
28759
- Effect142.catchAll(() => Effect142.succeed({})),
28760
- Effect142.flatMap((syncTimes) => {
28760
+ Effect143.catchAll(() => Effect143.succeed({})),
28761
+ Effect143.flatMap((syncTimes) => {
28761
28762
  const filteredSyncTimes = filterEnabledSyncTimes(getClientState2(), portalId, syncTimes);
28762
28763
  const count = Object.keys(filteredSyncTimes).length;
28763
28764
  if (count === 0) {
28764
- return Effect142.sync(() => {
28765
+ return Effect143.sync(() => {
28765
28766
  console.error(`[live-sync] No enabled object watermarks found in DuckDB for portal ${portalId}, subscribing directly`);
28766
28767
  subscribeIfStillSelected(portalId);
28767
28768
  });
28768
28769
  }
28769
- return pipe120(
28770
- Effect142.sync(() => {
28770
+ return pipe121(
28771
+ Effect143.sync(() => {
28771
28772
  console.error(`[live-sync] Triggering catch-up diff for portal ${portalId} with ${count} enabled object types: ${JSON.stringify(filteredSyncTimes)}`);
28772
28773
  }),
28773
- Effect142.flatMap(() => pipe120(ws.sendSyncDiff(portalId, filteredSyncTimes), Effect142.catchAll(() => Effect142.void)))
28774
+ Effect143.flatMap(() => pipe121(ws.sendSyncDiff(portalId, filteredSyncTimes), Effect143.catchAll(() => Effect143.void)))
28774
28775
  );
28775
28776
  }),
28776
- Effect142.runFork
28777
+ Effect143.runFork
28777
28778
  );
28778
28779
  };
28779
28780
  const makeSyncLayer = (portalId) => {
@@ -28806,25 +28807,25 @@ var mainProgram = Effect142.gen(function* () {
28806
28807
  return;
28807
28808
  }
28808
28809
  const syncLayer = makeSyncLayer(portalId);
28809
- Effect142.runFork(
28810
- pipe120(
28810
+ Effect143.runFork(
28811
+ pipe121(
28811
28812
  portalFileState.resetStuckPlugins(portalId),
28812
- Effect142.catchAll(() => Effect142.void),
28813
- Effect142.tap(() => Effect142.sync(
28813
+ Effect143.catchAll(() => Effect143.void),
28814
+ Effect143.tap(() => Effect143.sync(
28814
28815
  () => console.error(`[plugin-sync] Starting automatic message plugin sync for portal ${portalId}`)
28815
28816
  )),
28816
- Effect142.flatMap(
28817
- () => pipe120(
28817
+ Effect143.flatMap(
28818
+ () => pipe121(
28818
28819
  SyncService,
28819
- Effect142.flatMap((sync) => sync.syncMessagePlugins(portalId)),
28820
- Effect142.provide(syncLayer)
28820
+ Effect143.flatMap((sync) => sync.syncMessagePlugins(portalId)),
28821
+ Effect143.provide(syncLayer)
28821
28822
  )
28822
28823
  ),
28823
- Effect142.tap(() => Effect142.sync(
28824
+ Effect143.tap(() => Effect143.sync(
28824
28825
  () => console.error(`[plugin-sync] Completed automatic message plugin sync for portal ${portalId}`)
28825
28826
  )),
28826
- Effect142.catchAll(
28827
- (error) => Effect142.sync(
28827
+ Effect143.catchAll(
28828
+ (error) => Effect143.sync(
28828
28829
  () => console.error(`[plugin-sync] Failed for portal ${portalId}:`, error)
28829
28830
  )
28830
28831
  )
@@ -28832,19 +28833,19 @@ var mainProgram = Effect142.gen(function* () {
28832
28833
  );
28833
28834
  };
28834
28835
  configureArtifactQueue(
28835
- (portalId, artifact) => !isMasterClient() ? Effect142.sync(() => {
28836
+ (portalId, artifact) => !isMasterClient() ? Effect143.sync(() => {
28836
28837
  logReadOnlySkip(`artifact queue ingest (${artifact.object_type})`, portalId);
28837
28838
  return true;
28838
- }) : !isArtifactSyncEnabled(getClientState2(), portalId, artifact.object_type) ? Effect142.sync(() => {
28839
+ }) : !isArtifactSyncEnabled(getClientState2(), portalId, artifact.object_type) ? Effect143.sync(() => {
28839
28840
  console.error(
28840
28841
  `[artifact-queue] Skipping ${artifact.object_type} for portal ${portalId} because sync is disabled`
28841
28842
  );
28842
28843
  return true;
28843
- }) : pipe120(
28844
+ }) : pipe121(
28844
28845
  SyncService,
28845
- Effect142.flatMap((sync) => sync.syncArtifacts(portalId, [artifact], [artifact.object_type])),
28846
- Effect142.flatMap(() => portalFileState.get(portalId)),
28847
- Effect142.map((portal) => {
28846
+ Effect143.flatMap((sync) => sync.syncArtifacts(portalId, [artifact], [artifact.object_type])),
28847
+ Effect143.flatMap(() => portalFileState.get(portalId)),
28848
+ Effect143.map((portal) => {
28848
28849
  const status = portal.artifacts.find((a) => a.object_type === artifact.object_type)?.status;
28849
28850
  if (status !== "SYNCED" && status !== "PARTIAL") {
28850
28851
  console.error(
@@ -28853,8 +28854,8 @@ var mainProgram = Effect142.gen(function* () {
28853
28854
  }
28854
28855
  return status === "SYNCED" || status === "PARTIAL";
28855
28856
  }),
28856
- Effect142.catchAll(
28857
- (err) => Effect142.sync(() => {
28857
+ Effect143.catchAll(
28858
+ (err) => Effect143.sync(() => {
28858
28859
  console.error(
28859
28860
  `[artifact-queue] Failed ingest for portal ${portalId} artifact ${artifact.object_type}:`,
28860
28861
  err
@@ -28862,7 +28863,7 @@ var mainProgram = Effect142.gen(function* () {
28862
28863
  return false;
28863
28864
  })
28864
28865
  ),
28865
- Effect142.provide(makeSyncLayer(portalId))
28866
+ Effect143.provide(makeSyncLayer(portalId))
28866
28867
  )
28867
28868
  );
28868
28869
  yield* ws.registerHandlers({
@@ -28872,15 +28873,15 @@ var mainProgram = Effect142.gen(function* () {
28872
28873
  return;
28873
28874
  }
28874
28875
  const incomingWithStatus = artifacts.map((a) => ({ ...a, status: "NOT_STARTED", error: null }));
28875
- const updated = pipe120(
28876
+ const updated = pipe121(
28876
28877
  portalFileState.setArtifacts(portalId, incomingWithStatus),
28877
- Effect142.tap(
28878
- (s) => Effect142.sync(
28878
+ Effect143.tap(
28879
+ (s) => Effect143.sync(
28879
28880
  () => console.error(`[sync:full] Saved ${s.artifacts.length} artifacts for portal ${portalId}`)
28880
28881
  )
28881
28882
  ),
28882
- Effect142.catchAll(() => Effect142.succeed(null)),
28883
- Effect142.runSync
28883
+ Effect143.catchAll(() => Effect143.succeed(null)),
28884
+ Effect143.runSync
28884
28885
  );
28885
28886
  if (!updated) return;
28886
28887
  const enabledArtifacts = filterEnabledArtifacts(getClientState2(), portalId, incomingWithStatus);
@@ -28909,10 +28910,10 @@ var mainProgram = Effect142.gen(function* () {
28909
28910
  const newWithStatus = artifacts.map((a) => ({ ...a, status: "NOT_STARTED", error: null }));
28910
28911
  const enabledArtifacts = filterEnabledArtifacts(getClientState2(), portalId, newWithStatus);
28911
28912
  const objectTypesToSync = enabledArtifacts.map((a) => a.object_type);
28912
- const merged = pipe120(
28913
+ const merged = pipe121(
28913
28914
  portalFileState.mergeArtifacts(portalId, newWithStatus),
28914
- Effect142.catchAll(() => Effect142.succeed(null)),
28915
- Effect142.runSync
28915
+ Effect143.catchAll(() => Effect143.succeed(null)),
28916
+ Effect143.runSync
28916
28917
  );
28917
28918
  if (!merged) return;
28918
28919
  const toSync = filterUnsyncedArtifacts(merged.artifacts, new Set(objectTypesToSync));
@@ -28944,12 +28945,12 @@ var mainProgram = Effect142.gen(function* () {
28944
28945
  console.error(`[diff-sync] No artifact plugin with processDiffBatch for ${batch.object_type}`);
28945
28946
  return;
28946
28947
  }
28947
- pipe120(
28948
+ pipe121(
28948
28949
  plugin.processDiffBatch({ portalData, fileDownload, ws, portalFileState, portalId }, batch),
28949
- Effect142.catchAll(
28950
- (err) => Effect142.sync(() => console.error(`[diff-sync] Error processing batch:`, err))
28950
+ Effect143.catchAll(
28951
+ (err) => Effect143.sync(() => console.error(`[diff-sync] Error processing batch:`, err))
28951
28952
  ),
28952
- Effect142.runFork
28953
+ Effect143.runFork
28953
28954
  );
28954
28955
  },
28955
28956
  onWorkflowDelta: (portalId, payload) => {
@@ -28967,17 +28968,17 @@ var mainProgram = Effect142.gen(function* () {
28967
28968
  );
28968
28969
  return;
28969
28970
  }
28970
- pipe120(
28971
+ pipe121(
28971
28972
  portalData.applyWorkflowDelta({
28972
28973
  portalId,
28973
28974
  upserts: payload.upserts,
28974
28975
  deletedWorkflowIds: payload.deleted_workflow_ids,
28975
28976
  diffCursor: payload.server_time
28976
28977
  }),
28977
- Effect142.catchAll(
28978
- (err) => Effect142.sync(() => console.error(`[workflow-delta] Error processing delta:`, err))
28978
+ Effect143.catchAll(
28979
+ (err) => Effect143.sync(() => console.error(`[workflow-delta] Error processing delta:`, err))
28979
28980
  ),
28980
- Effect142.runFork
28981
+ Effect143.runFork
28981
28982
  );
28982
28983
  },
28983
28984
  onPropertyDefinitionsDelta: (portalId, payload) => {
@@ -28995,7 +28996,7 @@ var mainProgram = Effect142.gen(function* () {
28995
28996
  );
28996
28997
  return;
28997
28998
  }
28998
- pipe120(
28999
+ pipe121(
28999
29000
  portalData.applyPropertyDefinitionsDelta({
29000
29001
  portalId,
29001
29002
  delta: {
@@ -29007,12 +29008,12 @@ var mainProgram = Effect142.gen(function* () {
29007
29008
  serverTime: payload.server_time
29008
29009
  }
29009
29010
  }),
29010
- Effect142.catchAll(
29011
- (err) => Effect142.sync(
29011
+ Effect143.catchAll(
29012
+ (err) => Effect143.sync(
29012
29013
  () => console.error(`[property-definitions-delta] Error processing delta:`, err)
29013
29014
  )
29014
29015
  ),
29015
- Effect142.runFork
29016
+ Effect143.runFork
29016
29017
  );
29017
29018
  },
29018
29019
  onDiffComplete: (portalId, payload) => {
@@ -29024,7 +29025,7 @@ var mainProgram = Effect142.gen(function* () {
29024
29025
  console.error(`[live-sync] Catch-up diff failed for portal ${portalId}: ${payload.error ?? "unknown"}`);
29025
29026
  return;
29026
29027
  }
29027
- Effect142.runFork(pipe120(portalFileState.touchSyncedAt(portalId), Effect142.catchAll(() => Effect142.void)));
29028
+ Effect143.runFork(pipe121(portalFileState.touchSyncedAt(portalId), Effect143.catchAll(() => Effect143.void)));
29028
29029
  if (!isPortalSyncActive(portalId)) {
29029
29030
  console.error(`[live-sync] Catch-up diff complete for portal ${portalId}, but portal sync is disabled so subscription will not restart`);
29030
29031
  return;
@@ -29049,12 +29050,12 @@ var mainProgram = Effect142.gen(function* () {
29049
29050
  logReadOnlySkip("plugin refresh execute", payload.target_portal);
29050
29051
  return;
29051
29052
  }
29052
- Effect142.runFork(
29053
- pipe120(
29054
- Effect142.tryPromise(
29055
- () => runManualPluginRefresh(payload.target_portal, payload.plugin_names)
29053
+ Effect143.runFork(
29054
+ pipe121(
29055
+ Effect143.tryPromise(
29056
+ () => runRefreshPlugins(payload.target_portal, payload.plugin_names)
29056
29057
  ),
29057
- Effect142.match({
29058
+ Effect143.match({
29058
29059
  onFailure: (error) => ws.sendPluginRefreshComplete({
29059
29060
  request_id: payload.request_id,
29060
29061
  target_portal: payload.target_portal,
@@ -29067,8 +29068,8 @@ var mainProgram = Effect142.gen(function* () {
29067
29068
  success: true
29068
29069
  })
29069
29070
  }),
29070
- Effect142.catchAll(
29071
- (error) => Effect142.sync(
29071
+ Effect143.catchAll(
29072
+ (error) => Effect143.sync(
29072
29073
  () => console.error(
29073
29074
  `[plugin-refresh] Failed to send completion for portal ${payload.target_portal}:`,
29074
29075
  error
@@ -29106,7 +29107,7 @@ var mainProgram = Effect142.gen(function* () {
29106
29107
  }
29107
29108
  console.error(`[live-sync] Registration complete \u2014 warming ${warmupPortalIds.length} enabled portal(s): ${warmupPortalIds.join(", ")}`);
29108
29109
  for (const portalId of warmupPortalIds) {
29109
- Effect142.runFork(pipe120(ws.sendSyncFull(portalId), Effect142.catchAll(() => Effect142.void)));
29110
+ Effect143.runFork(pipe121(ws.sendSyncFull(portalId), Effect143.catchAll(() => Effect143.void)));
29110
29111
  }
29111
29112
  if (DISABLE_PLUGIN_SYNC) {
29112
29113
  console.error("[plugin-sync] Skipping plugin warmup sync for enabled portals (disabled by env flag)");
@@ -29142,20 +29143,20 @@ var mainProgram = Effect142.gen(function* () {
29142
29143
  }
29143
29144
  });
29144
29145
  yield* ws.connect().pipe(
29145
- Effect142.catchAll((e) => Effect142.sync(() => console.error("WebSocket error:", e)))
29146
+ Effect143.catchAll((e) => Effect143.sync(() => console.error("WebSocket error:", e)))
29146
29147
  );
29147
29148
  if (!TEST_HEADLESS_MODE) {
29148
29149
  const transport = new StdioServerTransport();
29149
- yield* Effect142.promise(() => server.connect(transport));
29150
- yield* Effect142.sync(() => console.error("MCP Pro Client server started"));
29150
+ yield* Effect143.promise(() => server.connect(transport));
29151
+ yield* Effect143.sync(() => console.error("MCP Pro Client server started"));
29151
29152
  } else {
29152
- yield* Effect142.sync(() => console.error("MCP Pro Client runtime started (headless)"));
29153
+ yield* Effect143.sync(() => console.error("MCP Pro Client runtime started (headless)"));
29153
29154
  }
29154
- yield* Effect142.never;
29155
+ yield* Effect143.never;
29155
29156
  });
29156
- pipe120(
29157
+ pipe121(
29157
29158
  mainProgram,
29158
- Effect142.provide((() => {
29159
+ Effect143.provide((() => {
29159
29160
  const portalDataDependencies = Layer10.mergeAll(
29160
29161
  DuckDBInterfaceLive,
29161
29162
  FileDownloadLive,
@@ -29168,7 +29169,7 @@ pipe120(
29168
29169
  makePortalDataLive(portalDataDependencies)
29169
29170
  );
29170
29171
  })()),
29171
- Effect142.runPromise
29172
+ Effect143.runPromise
29172
29173
  ).catch((error) => {
29173
29174
  console.error("Fatal error:", error);
29174
29175
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daeda/mcp-pro",
3
- "version": "0.1.40",
3
+ "version": "0.1.41",
4
4
  "description": "MCP server for HubSpot CRM — sync, query, and manage your portal data",
5
5
  "type": "module",
6
6
  "bin": {