@daeda/mcp-pro 0.1.40 → 0.1.42

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 +155 -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
@@ -28192,6 +28192,17 @@ var createEnsureFresh = (deps, options2) => {
28192
28192
  syncEnabled: true
28193
28193
  };
28194
28194
  }
28195
+ if (!deps.isMasterClient()) {
28196
+ if (!deps.hasLocalDatabase(portalId)) {
28197
+ throw new Error(
28198
+ `Portal ${portalId} has no synced data yet. Background sync in progress - retry shortly.`
28199
+ );
28200
+ }
28201
+ return {
28202
+ usedStaleData: true,
28203
+ syncEnabled: true
28204
+ };
28205
+ }
28195
28206
  const drained = await deps.waitForPortalDrain(portalId, queueDrainTimeoutMs);
28196
28207
  if (!drained) {
28197
28208
  throw new Error(`Timed out waiting for portal ${portalId} artifact queue drain.`);
@@ -28258,6 +28269,7 @@ var waitForPortalSyncedAtAfter = (portalFileState, portalId, sinceMs, timeoutMs)
28258
28269
  var makeEnsureFresh = (deps, options2) => createEnsureFresh(
28259
28270
  {
28260
28271
  getSelectedPortalId: deps.getSelectedPortalId,
28272
+ isMasterClient: deps.isMasterClient,
28261
28273
  isPortalSyncEnabled: deps.isPortalSyncEnabled,
28262
28274
  waitForPortalDrain,
28263
28275
  hasLocalDatabase: (portalId) => fs13.existsSync(dbPath(portalId)),
@@ -28307,6 +28319,16 @@ var registerStdioShutdownHooks = ({
28307
28319
  };
28308
28320
  };
28309
28321
 
28322
+ // src/effects/run-manual-plugin-refresh.ts
28323
+ import { Effect as Effect142, pipe as pipe120 } from "effect";
28324
+ var runManualPluginRefresh = (deps, portalId, pluginNames) => pipe120(
28325
+ deps.resetStuckPlugins(portalId),
28326
+ Effect142.catchAll(() => Effect142.void),
28327
+ Effect142.flatMap(
28328
+ () => deps.syncMessagePlugins(portalId, pluginNames, { force: true })
28329
+ )
28330
+ );
28331
+
28310
28332
  // src/index.ts
28311
28333
  process.on("uncaughtException", (err) => {
28312
28334
  console.error("[fatal:uncaughtException]", err);
@@ -28377,7 +28399,7 @@ if (!TEST_HEADLESS_MODE) {
28377
28399
  }
28378
28400
  });
28379
28401
  }
28380
- var mainProgram = Effect142.gen(function* () {
28402
+ var mainProgram = Effect143.gen(function* () {
28381
28403
  const ws = yield* WebSocketService;
28382
28404
  const config = yield* ConfigService;
28383
28405
  const duckDb = yield* DuckDBInterfaceService;
@@ -28385,18 +28407,18 @@ var mainProgram = Effect142.gen(function* () {
28385
28407
  const portalData = yield* PortalDataService;
28386
28408
  const portalFileState = yield* PortalFileStateService;
28387
28409
  const getPortalId = () => getSelectedPortalId(config);
28388
- const getClientState2 = () => Effect142.runSync(config.load());
28410
+ const getClientState2 = () => Effect143.runSync(config.load());
28389
28411
  const saveClientState = (updater) => {
28390
28412
  const nextState = updater(getClientState2());
28391
- Effect142.runSync(config.save(nextState));
28413
+ Effect143.runSync(config.save(nextState));
28392
28414
  return nextState;
28393
28415
  };
28394
- const getPortals = () => Effect142.runSync(ws.getPortals());
28416
+ const getPortals = () => Effect143.runSync(ws.getPortals());
28395
28417
  const isPortalSyncActive = (portalId) => isPortalSyncEnabled(getClientState2(), portalId);
28396
- const getConnectionType = () => Effect142.runSync(
28397
- pipe120(
28418
+ const getConnectionType = () => Effect143.runSync(
28419
+ pipe121(
28398
28420
  duckDb.getConnectionType,
28399
- Effect142.catchAll(() => Effect142.succeed("READ_ONLY"))
28421
+ Effect143.catchAll(() => Effect143.succeed("READ_ONLY"))
28400
28422
  )
28401
28423
  );
28402
28424
  const isMasterClient = () => getConnectionType() === "MASTER";
@@ -28407,6 +28429,7 @@ var mainProgram = Effect142.gen(function* () {
28407
28429
  };
28408
28430
  const ensureFresh = makeEnsureFresh({
28409
28431
  getSelectedPortalId: getPortalId,
28432
+ isMasterClient,
28410
28433
  isPortalSyncEnabled: isPortalSyncActive,
28411
28434
  ws,
28412
28435
  portalData,
@@ -28415,10 +28438,10 @@ var mainProgram = Effect142.gen(function* () {
28415
28438
  const handoffSelectedPortal = (nextPortalId) => {
28416
28439
  const previousPortalId = getSelectedPortalId(config);
28417
28440
  if (previousPortalId !== null && previousPortalId !== nextPortalId) {
28418
- Effect142.runSync(
28419
- pipe120(
28441
+ Effect143.runSync(
28442
+ pipe121(
28420
28443
  ws.sendSyncUnsubscribe(previousPortalId),
28421
- Effect142.catchAll(() => Effect142.void)
28444
+ Effect143.catchAll(() => Effect143.void)
28422
28445
  )
28423
28446
  );
28424
28447
  }
@@ -28430,7 +28453,7 @@ var mainProgram = Effect142.gen(function* () {
28430
28453
  if (!isPortalSyncEnabled(nextState, nextPortalId)) {
28431
28454
  return "stale_local_only";
28432
28455
  }
28433
- Effect142.runFork(pipe120(ws.sendSyncFull(nextPortalId), Effect142.catchAll(() => Effect142.void)));
28456
+ Effect143.runFork(pipe121(ws.sendSyncFull(nextPortalId), Effect143.catchAll(() => Effect143.void)));
28434
28457
  return "syncing";
28435
28458
  };
28436
28459
  registerPortalSelection(server, { ws, config, handoffSelectedPortal });
@@ -28447,15 +28470,15 @@ var mainProgram = Effect142.gen(function* () {
28447
28470
  ensureFresh
28448
28471
  });
28449
28472
  registerStatusTool(server, {
28450
- getConnectionState: () => Effect142.runSync(ws.getState()),
28473
+ getConnectionState: () => Effect143.runSync(ws.getState()),
28451
28474
  isMasterClient,
28452
28475
  getPortals,
28453
28476
  getSelectedPortalId: getPortalId,
28454
28477
  getClientState: getClientState2,
28455
- getPortalState: async (portalId) => Effect142.runPromise(
28456
- pipe120(
28478
+ getPortalState: async (portalId) => Effect143.runPromise(
28479
+ pipe121(
28457
28480
  portalFileState.load(portalId),
28458
- Effect142.catchAll(() => Effect142.succeed(null))
28481
+ Effect143.catchAll(() => Effect143.succeed(null))
28459
28482
  )
28460
28483
  ),
28461
28484
  getClientMetadata: () => STATUS_METADATA,
@@ -28479,7 +28502,7 @@ var mainProgram = Effect142.gen(function* () {
28479
28502
  actions.push(`Removed ${removed} pending portal sync job(s).`);
28480
28503
  }
28481
28504
  if (isSelected) {
28482
- Effect142.runSync(pipe120(ws.sendSyncUnsubscribe(portalId), Effect142.catchAll(() => Effect142.void)));
28505
+ Effect143.runSync(pipe121(ws.sendSyncUnsubscribe(portalId), Effect143.catchAll(() => Effect143.void)));
28483
28506
  actions.push("Stopped real-time subscription for the selected portal.");
28484
28507
  }
28485
28508
  }
@@ -28499,7 +28522,7 @@ var mainProgram = Effect142.gen(function* () {
28499
28522
  }
28500
28523
  if (!previousControl.enabled && nextControl.enabled) {
28501
28524
  if (isMasterClient()) {
28502
- Effect142.runFork(pipe120(ws.sendSyncFull(portalId), Effect142.catchAll(() => Effect142.void)));
28525
+ Effect143.runFork(pipe121(ws.sendSyncFull(portalId), Effect143.catchAll(() => Effect143.void)));
28503
28526
  if (!DISABLE_PLUGIN_SYNC) {
28504
28527
  triggerPluginSync(portalId);
28505
28528
  }
@@ -28509,7 +28532,7 @@ var mainProgram = Effect142.gen(function* () {
28509
28532
  }
28510
28533
  } else if (refreshArtifacts && nextControl.enabled) {
28511
28534
  if (isMasterClient()) {
28512
- Effect142.runFork(pipe120(ws.sendSyncFull(portalId), Effect142.catchAll(() => Effect142.void)));
28535
+ Effect143.runFork(pipe121(ws.sendSyncFull(portalId), Effect143.catchAll(() => Effect143.void)));
28513
28536
  actions.push("Requested fresh artifact manifest.");
28514
28537
  } else {
28515
28538
  actions.push("Refresh requested, but this client is read-only so no sync was started.");
@@ -28517,7 +28540,7 @@ var mainProgram = Effect142.gen(function* () {
28517
28540
  }
28518
28541
  const filtersChanged = previousControl.enabled === nextControl.enabled && previousControl.disabledArtifacts.join("\0") !== nextControl.disabledArtifacts.join("\0");
28519
28542
  if (isSelected && nextControl.enabled && filtersChanged && !refreshArtifacts) {
28520
- Effect142.runSync(pipe120(ws.sendSyncUnsubscribe(portalId), Effect142.catchAll(() => Effect142.void)));
28543
+ Effect143.runSync(pipe121(ws.sendSyncUnsubscribe(portalId), Effect143.catchAll(() => Effect143.void)));
28521
28544
  runDiffFlow(portalId);
28522
28545
  actions.push("Restarted selected portal live sync to apply artifact filters.");
28523
28546
  }
@@ -28542,39 +28565,30 @@ var mainProgram = Effect142.gen(function* () {
28542
28565
  getPortals,
28543
28566
  ws
28544
28567
  });
28545
- const runManualPluginRefresh = async (portalId, pluginNames) => {
28568
+ const runRefreshPlugins = async (portalId, pluginNames) => {
28546
28569
  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
- )
28570
+ await Effect143.runPromise(runManualPluginRefresh({
28571
+ resetStuckPlugins: portalFileState.resetStuckPlugins,
28572
+ syncMessagePlugins: (targetPortalId, targetPluginNames, options2) => pipe121(
28573
+ SyncService,
28574
+ Effect143.flatMap((sync) => sync.syncMessagePlugins(targetPortalId, targetPluginNames, options2)),
28575
+ Effect143.provide(syncLayer)
28558
28576
  )
28559
- );
28560
- await publishReplica({
28561
- masterLock: { isMaster: true },
28562
- portalId
28563
- });
28577
+ }, portalId, pluginNames));
28564
28578
  };
28565
28579
  registerRefreshPluginsTool(server, {
28566
28580
  isMasterClient,
28567
28581
  getSelectedPortalId: getPortalId,
28568
28582
  getPortals,
28569
28583
  getClientState: getClientState2,
28570
- runRefresh: runManualPluginRefresh,
28584
+ runRefresh: runRefreshPlugins,
28571
28585
  requestRefresh: async (portalId, pluginNames) => {
28572
- await Effect142.runPromise(ws.requestPluginRefresh(portalId, pluginNames));
28586
+ await Effect143.runPromise(ws.requestPluginRefresh(portalId, pluginNames));
28573
28587
  },
28574
- getPortalState: async (portalId) => Effect142.runPromise(
28575
- pipe120(
28588
+ getPortalState: async (portalId) => Effect143.runPromise(
28589
+ pipe121(
28576
28590
  portalFileState.load(portalId),
28577
- Effect142.catchAll(() => Effect142.succeed(null))
28591
+ Effect143.catchAll(() => Effect143.succeed(null))
28578
28592
  )
28579
28593
  )
28580
28594
  });
@@ -28582,24 +28596,24 @@ var mainProgram = Effect142.gen(function* () {
28582
28596
  yield* config.save(state);
28583
28597
  setSelectedPortal(state.selectedPortalId);
28584
28598
  if (DISABLE_PLUGIN_SYNC) {
28585
- yield* Effect142.sync(
28599
+ yield* Effect143.sync(
28586
28600
  () => console.error("[startup] Plugin sync disabled via MCP_CLIENT_DISABLE_PLUGIN_SYNC")
28587
28601
  );
28588
28602
  }
28589
28603
  if (DISABLE_DIFF_FOLLOWUP) {
28590
- yield* Effect142.sync(
28604
+ yield* Effect143.sync(
28591
28605
  () => console.error("[startup] Diff follow-up disabled via MCP_CLIENT_DISABLE_DIFF_FOLLOWUP")
28592
28606
  );
28593
28607
  }
28594
28608
  if (TEST_HEADLESS_MODE) {
28595
- yield* Effect142.sync(
28609
+ yield* Effect143.sync(
28596
28610
  () => console.error("[startup] Headless mode enabled via MCP_CLIENT_TEST_HEADLESS")
28597
28611
  );
28598
28612
  }
28599
28613
  if (state.selectedPortalId !== null) {
28600
- const cached = yield* portalFileState.load(state.selectedPortalId).pipe(Effect142.catchAll(() => Effect142.succeed(null)));
28614
+ const cached = yield* portalFileState.load(state.selectedPortalId).pipe(Effect143.catchAll(() => Effect143.succeed(null)));
28601
28615
  if (cached !== null) {
28602
- yield* Effect142.sync(
28616
+ yield* Effect143.sync(
28603
28617
  () => console.error(`[startup] Loaded ${cached.artifacts.length} cached artifacts for portal ${state.selectedPortalId}`)
28604
28618
  );
28605
28619
  }
@@ -28630,24 +28644,24 @@ var mainProgram = Effect142.gen(function* () {
28630
28644
  return;
28631
28645
  }
28632
28646
  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(() => {
28647
+ Effect143.runFork(
28648
+ pipe121(
28649
+ Effect143.promise(() => waitForPortalDrain(portalId, QUEUE_DRAIN_TIMEOUT_MS)),
28650
+ Effect143.flatMap(
28651
+ (drained) => drained ? Effect143.sync(() => {
28638
28652
  console.error(`[live-sync] Queue drained for portal ${portalId} after ${source} \u2014 triggering diff flow`);
28639
28653
  runDiffFlow(portalId);
28640
- }) : Effect142.sync(
28654
+ }) : Effect143.sync(
28641
28655
  () => console.error(`[live-sync] Timed out waiting for portal ${portalId} queue drain after ${source}`)
28642
28656
  )
28643
28657
  ),
28644
- Effect142.ensuring(
28645
- Effect142.sync(() => {
28658
+ Effect143.ensuring(
28659
+ Effect143.sync(() => {
28646
28660
  pendingPortalFollowUps.delete(portalId);
28647
28661
  })
28648
28662
  ),
28649
- Effect142.catchAll(
28650
- (error) => Effect142.sync(() => {
28663
+ Effect143.catchAll(
28664
+ (error) => Effect143.sync(() => {
28651
28665
  console.error(`[live-sync] Failed post-queue follow-up for portal ${portalId}:`, error);
28652
28666
  })
28653
28667
  )
@@ -28666,12 +28680,12 @@ var mainProgram = Effect142.gen(function* () {
28666
28680
  console.error(`[live-sync] Skipping subscribe for portal ${portalId} because portal sync is disabled`);
28667
28681
  return;
28668
28682
  }
28669
- Effect142.runFork(
28670
- pipe120(
28671
- Effect142.all({
28683
+ Effect143.runFork(
28684
+ pipe121(
28685
+ Effect143.all({
28672
28686
  workflowState: duckDb.getWorkflowStateSummary(portalId).pipe(
28673
- Effect142.catchAll(
28674
- (error) => Effect142.sync(() => {
28687
+ Effect143.catchAll(
28688
+ (error) => Effect143.sync(() => {
28675
28689
  console.error(
28676
28690
  `[live-sync] Failed to read workflow state summary for portal ${portalId}; subscribing with empty state:`,
28677
28691
  error
@@ -28681,8 +28695,8 @@ var mainProgram = Effect142.gen(function* () {
28681
28695
  )
28682
28696
  ),
28683
28697
  propertyDefinitionState: duckDb.getPropertyDefinitionStateSummary(portalId).pipe(
28684
- Effect142.catchAll(
28685
- (error) => Effect142.sync(() => {
28698
+ Effect143.catchAll(
28699
+ (error) => Effect143.sync(() => {
28686
28700
  console.error(
28687
28701
  `[live-sync] Failed to read property definition state summary for portal ${portalId}; subscribing with empty state:`,
28688
28702
  error
@@ -28692,8 +28706,8 @@ var mainProgram = Effect142.gen(function* () {
28692
28706
  )
28693
28707
  ),
28694
28708
  objectSyncTimes: portalData.getObjectSyncTimes(portalId).pipe(
28695
- Effect142.catchAll(
28696
- (error) => Effect142.sync(() => {
28709
+ Effect143.catchAll(
28710
+ (error) => Effect143.sync(() => {
28697
28711
  console.error(
28698
28712
  `[live-sync] Failed to read object sync times for portal ${portalId}; subscribing with empty object filter:`,
28699
28713
  error
@@ -28703,7 +28717,7 @@ var mainProgram = Effect142.gen(function* () {
28703
28717
  )
28704
28718
  )
28705
28719
  }),
28706
- Effect142.flatMap(
28720
+ Effect143.flatMap(
28707
28721
  ({ workflowState, propertyDefinitionState, objectSyncTimes }) => ws.sendSyncSubscribe(
28708
28722
  portalId,
28709
28723
  workflowState,
@@ -28711,7 +28725,7 @@ var mainProgram = Effect142.gen(function* () {
28711
28725
  filterEnabledObjectTypes(getClientState2(), portalId, Object.keys(objectSyncTimes))
28712
28726
  )
28713
28727
  ),
28714
- Effect142.catchAll(() => Effect142.void)
28728
+ Effect143.catchAll(() => Effect143.void)
28715
28729
  )
28716
28730
  );
28717
28731
  };
@@ -28724,25 +28738,25 @@ var mainProgram = Effect142.gen(function* () {
28724
28738
  console.error(`[live-sync] Skipping catch-up diff for portal ${portalId} because portal sync is disabled`);
28725
28739
  return;
28726
28740
  }
28727
- pipe120(
28741
+ pipe121(
28728
28742
  portalData.getObjectSyncTimes(portalId),
28729
- Effect142.catchAll(() => Effect142.succeed({})),
28730
- Effect142.flatMap((syncTimes) => {
28743
+ Effect143.catchAll(() => Effect143.succeed({})),
28744
+ Effect143.flatMap((syncTimes) => {
28731
28745
  const filteredSyncTimes = filterEnabledSyncTimes(getClientState2(), portalId, syncTimes);
28732
28746
  const count = Object.keys(filteredSyncTimes).length;
28733
28747
  if (count === 0) {
28734
- return Effect142.sync(() => {
28748
+ return Effect143.sync(() => {
28735
28749
  console.error(`[live-sync] No enabled object watermarks found in DuckDB for portal ${portalId}, skipping diff`);
28736
28750
  });
28737
28751
  }
28738
- return pipe120(
28739
- Effect142.sync(() => {
28752
+ return pipe121(
28753
+ Effect143.sync(() => {
28740
28754
  console.error(`[live-sync] Triggering catch-up diff for portal ${portalId} with ${count} enabled object types: ${JSON.stringify(filteredSyncTimes)}`);
28741
28755
  }),
28742
- Effect142.flatMap(() => pipe120(ws.sendSyncDiff(portalId, filteredSyncTimes), Effect142.catchAll(() => Effect142.void)))
28756
+ Effect143.flatMap(() => pipe121(ws.sendSyncDiff(portalId, filteredSyncTimes), Effect143.catchAll(() => Effect143.void)))
28743
28757
  );
28744
28758
  }),
28745
- Effect142.runFork
28759
+ Effect143.runFork
28746
28760
  );
28747
28761
  };
28748
28762
  const triggerDiffThenSubscribe = (portalId) => {
@@ -28754,26 +28768,26 @@ var mainProgram = Effect142.gen(function* () {
28754
28768
  console.error(`[live-sync] Skipping catch-up diff/subscription for portal ${portalId} because portal sync is disabled`);
28755
28769
  return;
28756
28770
  }
28757
- pipe120(
28771
+ pipe121(
28758
28772
  portalData.getObjectSyncTimes(portalId),
28759
- Effect142.catchAll(() => Effect142.succeed({})),
28760
- Effect142.flatMap((syncTimes) => {
28773
+ Effect143.catchAll(() => Effect143.succeed({})),
28774
+ Effect143.flatMap((syncTimes) => {
28761
28775
  const filteredSyncTimes = filterEnabledSyncTimes(getClientState2(), portalId, syncTimes);
28762
28776
  const count = Object.keys(filteredSyncTimes).length;
28763
28777
  if (count === 0) {
28764
- return Effect142.sync(() => {
28778
+ return Effect143.sync(() => {
28765
28779
  console.error(`[live-sync] No enabled object watermarks found in DuckDB for portal ${portalId}, subscribing directly`);
28766
28780
  subscribeIfStillSelected(portalId);
28767
28781
  });
28768
28782
  }
28769
- return pipe120(
28770
- Effect142.sync(() => {
28783
+ return pipe121(
28784
+ Effect143.sync(() => {
28771
28785
  console.error(`[live-sync] Triggering catch-up diff for portal ${portalId} with ${count} enabled object types: ${JSON.stringify(filteredSyncTimes)}`);
28772
28786
  }),
28773
- Effect142.flatMap(() => pipe120(ws.sendSyncDiff(portalId, filteredSyncTimes), Effect142.catchAll(() => Effect142.void)))
28787
+ Effect143.flatMap(() => pipe121(ws.sendSyncDiff(portalId, filteredSyncTimes), Effect143.catchAll(() => Effect143.void)))
28774
28788
  );
28775
28789
  }),
28776
- Effect142.runFork
28790
+ Effect143.runFork
28777
28791
  );
28778
28792
  };
28779
28793
  const makeSyncLayer = (portalId) => {
@@ -28806,25 +28820,25 @@ var mainProgram = Effect142.gen(function* () {
28806
28820
  return;
28807
28821
  }
28808
28822
  const syncLayer = makeSyncLayer(portalId);
28809
- Effect142.runFork(
28810
- pipe120(
28823
+ Effect143.runFork(
28824
+ pipe121(
28811
28825
  portalFileState.resetStuckPlugins(portalId),
28812
- Effect142.catchAll(() => Effect142.void),
28813
- Effect142.tap(() => Effect142.sync(
28826
+ Effect143.catchAll(() => Effect143.void),
28827
+ Effect143.tap(() => Effect143.sync(
28814
28828
  () => console.error(`[plugin-sync] Starting automatic message plugin sync for portal ${portalId}`)
28815
28829
  )),
28816
- Effect142.flatMap(
28817
- () => pipe120(
28830
+ Effect143.flatMap(
28831
+ () => pipe121(
28818
28832
  SyncService,
28819
- Effect142.flatMap((sync) => sync.syncMessagePlugins(portalId)),
28820
- Effect142.provide(syncLayer)
28833
+ Effect143.flatMap((sync) => sync.syncMessagePlugins(portalId)),
28834
+ Effect143.provide(syncLayer)
28821
28835
  )
28822
28836
  ),
28823
- Effect142.tap(() => Effect142.sync(
28837
+ Effect143.tap(() => Effect143.sync(
28824
28838
  () => console.error(`[plugin-sync] Completed automatic message plugin sync for portal ${portalId}`)
28825
28839
  )),
28826
- Effect142.catchAll(
28827
- (error) => Effect142.sync(
28840
+ Effect143.catchAll(
28841
+ (error) => Effect143.sync(
28828
28842
  () => console.error(`[plugin-sync] Failed for portal ${portalId}:`, error)
28829
28843
  )
28830
28844
  )
@@ -28832,19 +28846,19 @@ var mainProgram = Effect142.gen(function* () {
28832
28846
  );
28833
28847
  };
28834
28848
  configureArtifactQueue(
28835
- (portalId, artifact) => !isMasterClient() ? Effect142.sync(() => {
28849
+ (portalId, artifact) => !isMasterClient() ? Effect143.sync(() => {
28836
28850
  logReadOnlySkip(`artifact queue ingest (${artifact.object_type})`, portalId);
28837
28851
  return true;
28838
- }) : !isArtifactSyncEnabled(getClientState2(), portalId, artifact.object_type) ? Effect142.sync(() => {
28852
+ }) : !isArtifactSyncEnabled(getClientState2(), portalId, artifact.object_type) ? Effect143.sync(() => {
28839
28853
  console.error(
28840
28854
  `[artifact-queue] Skipping ${artifact.object_type} for portal ${portalId} because sync is disabled`
28841
28855
  );
28842
28856
  return true;
28843
- }) : pipe120(
28857
+ }) : pipe121(
28844
28858
  SyncService,
28845
- Effect142.flatMap((sync) => sync.syncArtifacts(portalId, [artifact], [artifact.object_type])),
28846
- Effect142.flatMap(() => portalFileState.get(portalId)),
28847
- Effect142.map((portal) => {
28859
+ Effect143.flatMap((sync) => sync.syncArtifacts(portalId, [artifact], [artifact.object_type])),
28860
+ Effect143.flatMap(() => portalFileState.get(portalId)),
28861
+ Effect143.map((portal) => {
28848
28862
  const status = portal.artifacts.find((a) => a.object_type === artifact.object_type)?.status;
28849
28863
  if (status !== "SYNCED" && status !== "PARTIAL") {
28850
28864
  console.error(
@@ -28853,8 +28867,8 @@ var mainProgram = Effect142.gen(function* () {
28853
28867
  }
28854
28868
  return status === "SYNCED" || status === "PARTIAL";
28855
28869
  }),
28856
- Effect142.catchAll(
28857
- (err) => Effect142.sync(() => {
28870
+ Effect143.catchAll(
28871
+ (err) => Effect143.sync(() => {
28858
28872
  console.error(
28859
28873
  `[artifact-queue] Failed ingest for portal ${portalId} artifact ${artifact.object_type}:`,
28860
28874
  err
@@ -28862,7 +28876,7 @@ var mainProgram = Effect142.gen(function* () {
28862
28876
  return false;
28863
28877
  })
28864
28878
  ),
28865
- Effect142.provide(makeSyncLayer(portalId))
28879
+ Effect143.provide(makeSyncLayer(portalId))
28866
28880
  )
28867
28881
  );
28868
28882
  yield* ws.registerHandlers({
@@ -28872,15 +28886,15 @@ var mainProgram = Effect142.gen(function* () {
28872
28886
  return;
28873
28887
  }
28874
28888
  const incomingWithStatus = artifacts.map((a) => ({ ...a, status: "NOT_STARTED", error: null }));
28875
- const updated = pipe120(
28889
+ const updated = pipe121(
28876
28890
  portalFileState.setArtifacts(portalId, incomingWithStatus),
28877
- Effect142.tap(
28878
- (s) => Effect142.sync(
28891
+ Effect143.tap(
28892
+ (s) => Effect143.sync(
28879
28893
  () => console.error(`[sync:full] Saved ${s.artifacts.length} artifacts for portal ${portalId}`)
28880
28894
  )
28881
28895
  ),
28882
- Effect142.catchAll(() => Effect142.succeed(null)),
28883
- Effect142.runSync
28896
+ Effect143.catchAll(() => Effect143.succeed(null)),
28897
+ Effect143.runSync
28884
28898
  );
28885
28899
  if (!updated) return;
28886
28900
  const enabledArtifacts = filterEnabledArtifacts(getClientState2(), portalId, incomingWithStatus);
@@ -28909,10 +28923,10 @@ var mainProgram = Effect142.gen(function* () {
28909
28923
  const newWithStatus = artifacts.map((a) => ({ ...a, status: "NOT_STARTED", error: null }));
28910
28924
  const enabledArtifacts = filterEnabledArtifacts(getClientState2(), portalId, newWithStatus);
28911
28925
  const objectTypesToSync = enabledArtifacts.map((a) => a.object_type);
28912
- const merged = pipe120(
28926
+ const merged = pipe121(
28913
28927
  portalFileState.mergeArtifacts(portalId, newWithStatus),
28914
- Effect142.catchAll(() => Effect142.succeed(null)),
28915
- Effect142.runSync
28928
+ Effect143.catchAll(() => Effect143.succeed(null)),
28929
+ Effect143.runSync
28916
28930
  );
28917
28931
  if (!merged) return;
28918
28932
  const toSync = filterUnsyncedArtifacts(merged.artifacts, new Set(objectTypesToSync));
@@ -28944,12 +28958,12 @@ var mainProgram = Effect142.gen(function* () {
28944
28958
  console.error(`[diff-sync] No artifact plugin with processDiffBatch for ${batch.object_type}`);
28945
28959
  return;
28946
28960
  }
28947
- pipe120(
28961
+ pipe121(
28948
28962
  plugin.processDiffBatch({ portalData, fileDownload, ws, portalFileState, portalId }, batch),
28949
- Effect142.catchAll(
28950
- (err) => Effect142.sync(() => console.error(`[diff-sync] Error processing batch:`, err))
28963
+ Effect143.catchAll(
28964
+ (err) => Effect143.sync(() => console.error(`[diff-sync] Error processing batch:`, err))
28951
28965
  ),
28952
- Effect142.runFork
28966
+ Effect143.runFork
28953
28967
  );
28954
28968
  },
28955
28969
  onWorkflowDelta: (portalId, payload) => {
@@ -28967,17 +28981,17 @@ var mainProgram = Effect142.gen(function* () {
28967
28981
  );
28968
28982
  return;
28969
28983
  }
28970
- pipe120(
28984
+ pipe121(
28971
28985
  portalData.applyWorkflowDelta({
28972
28986
  portalId,
28973
28987
  upserts: payload.upserts,
28974
28988
  deletedWorkflowIds: payload.deleted_workflow_ids,
28975
28989
  diffCursor: payload.server_time
28976
28990
  }),
28977
- Effect142.catchAll(
28978
- (err) => Effect142.sync(() => console.error(`[workflow-delta] Error processing delta:`, err))
28991
+ Effect143.catchAll(
28992
+ (err) => Effect143.sync(() => console.error(`[workflow-delta] Error processing delta:`, err))
28979
28993
  ),
28980
- Effect142.runFork
28994
+ Effect143.runFork
28981
28995
  );
28982
28996
  },
28983
28997
  onPropertyDefinitionsDelta: (portalId, payload) => {
@@ -28995,7 +29009,7 @@ var mainProgram = Effect142.gen(function* () {
28995
29009
  );
28996
29010
  return;
28997
29011
  }
28998
- pipe120(
29012
+ pipe121(
28999
29013
  portalData.applyPropertyDefinitionsDelta({
29000
29014
  portalId,
29001
29015
  delta: {
@@ -29007,12 +29021,12 @@ var mainProgram = Effect142.gen(function* () {
29007
29021
  serverTime: payload.server_time
29008
29022
  }
29009
29023
  }),
29010
- Effect142.catchAll(
29011
- (err) => Effect142.sync(
29024
+ Effect143.catchAll(
29025
+ (err) => Effect143.sync(
29012
29026
  () => console.error(`[property-definitions-delta] Error processing delta:`, err)
29013
29027
  )
29014
29028
  ),
29015
- Effect142.runFork
29029
+ Effect143.runFork
29016
29030
  );
29017
29031
  },
29018
29032
  onDiffComplete: (portalId, payload) => {
@@ -29024,7 +29038,7 @@ var mainProgram = Effect142.gen(function* () {
29024
29038
  console.error(`[live-sync] Catch-up diff failed for portal ${portalId}: ${payload.error ?? "unknown"}`);
29025
29039
  return;
29026
29040
  }
29027
- Effect142.runFork(pipe120(portalFileState.touchSyncedAt(portalId), Effect142.catchAll(() => Effect142.void)));
29041
+ Effect143.runFork(pipe121(portalFileState.touchSyncedAt(portalId), Effect143.catchAll(() => Effect143.void)));
29028
29042
  if (!isPortalSyncActive(portalId)) {
29029
29043
  console.error(`[live-sync] Catch-up diff complete for portal ${portalId}, but portal sync is disabled so subscription will not restart`);
29030
29044
  return;
@@ -29049,12 +29063,12 @@ var mainProgram = Effect142.gen(function* () {
29049
29063
  logReadOnlySkip("plugin refresh execute", payload.target_portal);
29050
29064
  return;
29051
29065
  }
29052
- Effect142.runFork(
29053
- pipe120(
29054
- Effect142.tryPromise(
29055
- () => runManualPluginRefresh(payload.target_portal, payload.plugin_names)
29066
+ Effect143.runFork(
29067
+ pipe121(
29068
+ Effect143.tryPromise(
29069
+ () => runRefreshPlugins(payload.target_portal, payload.plugin_names)
29056
29070
  ),
29057
- Effect142.match({
29071
+ Effect143.match({
29058
29072
  onFailure: (error) => ws.sendPluginRefreshComplete({
29059
29073
  request_id: payload.request_id,
29060
29074
  target_portal: payload.target_portal,
@@ -29067,8 +29081,8 @@ var mainProgram = Effect142.gen(function* () {
29067
29081
  success: true
29068
29082
  })
29069
29083
  }),
29070
- Effect142.catchAll(
29071
- (error) => Effect142.sync(
29084
+ Effect143.catchAll(
29085
+ (error) => Effect143.sync(
29072
29086
  () => console.error(
29073
29087
  `[plugin-refresh] Failed to send completion for portal ${payload.target_portal}:`,
29074
29088
  error
@@ -29106,7 +29120,7 @@ var mainProgram = Effect142.gen(function* () {
29106
29120
  }
29107
29121
  console.error(`[live-sync] Registration complete \u2014 warming ${warmupPortalIds.length} enabled portal(s): ${warmupPortalIds.join(", ")}`);
29108
29122
  for (const portalId of warmupPortalIds) {
29109
- Effect142.runFork(pipe120(ws.sendSyncFull(portalId), Effect142.catchAll(() => Effect142.void)));
29123
+ Effect143.runFork(pipe121(ws.sendSyncFull(portalId), Effect143.catchAll(() => Effect143.void)));
29110
29124
  }
29111
29125
  if (DISABLE_PLUGIN_SYNC) {
29112
29126
  console.error("[plugin-sync] Skipping plugin warmup sync for enabled portals (disabled by env flag)");
@@ -29142,20 +29156,20 @@ var mainProgram = Effect142.gen(function* () {
29142
29156
  }
29143
29157
  });
29144
29158
  yield* ws.connect().pipe(
29145
- Effect142.catchAll((e) => Effect142.sync(() => console.error("WebSocket error:", e)))
29159
+ Effect143.catchAll((e) => Effect143.sync(() => console.error("WebSocket error:", e)))
29146
29160
  );
29147
29161
  if (!TEST_HEADLESS_MODE) {
29148
29162
  const transport = new StdioServerTransport();
29149
- yield* Effect142.promise(() => server.connect(transport));
29150
- yield* Effect142.sync(() => console.error("MCP Pro Client server started"));
29163
+ yield* Effect143.promise(() => server.connect(transport));
29164
+ yield* Effect143.sync(() => console.error("MCP Pro Client server started"));
29151
29165
  } else {
29152
- yield* Effect142.sync(() => console.error("MCP Pro Client runtime started (headless)"));
29166
+ yield* Effect143.sync(() => console.error("MCP Pro Client runtime started (headless)"));
29153
29167
  }
29154
- yield* Effect142.never;
29168
+ yield* Effect143.never;
29155
29169
  });
29156
- pipe120(
29170
+ pipe121(
29157
29171
  mainProgram,
29158
- Effect142.provide((() => {
29172
+ Effect143.provide((() => {
29159
29173
  const portalDataDependencies = Layer10.mergeAll(
29160
29174
  DuckDBInterfaceLive,
29161
29175
  FileDownloadLive,
@@ -29168,7 +29182,7 @@ pipe120(
29168
29182
  makePortalDataLive(portalDataDependencies)
29169
29183
  );
29170
29184
  })()),
29171
- Effect142.runPromise
29185
+ Effect143.runPromise
29172
29186
  ).catch((error) => {
29173
29187
  console.error("Fatal error:", error);
29174
29188
  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.42",
4
4
  "description": "MCP server for HubSpot CRM — sync, query, and manage your portal data",
5
5
  "type": "module",
6
6
  "bin": {