@daeda/mcp-pro 0.1.12 → 0.1.13
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/index.js +79 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -121,7 +121,11 @@ var EXPORT_NAME_TO_OBJECT_TYPE = {
|
|
|
121
121
|
NOTE: "notes",
|
|
122
122
|
TASK: "tasks",
|
|
123
123
|
COMMUNICATION: "communications",
|
|
124
|
-
POSTAL_MAIL: "postal_mail"
|
|
124
|
+
POSTAL_MAIL: "postal_mail",
|
|
125
|
+
"0-421": "appointments",
|
|
126
|
+
"0-420": "listings",
|
|
127
|
+
"0-970": "projects",
|
|
128
|
+
"0-162": "services"
|
|
125
129
|
};
|
|
126
130
|
var resolveObjectTypeName = (exportName) => EXPORT_NAME_TO_OBJECT_TYPE[exportName] ?? exportName.toLowerCase();
|
|
127
131
|
var normalizeAssociationLabel = (value) => {
|
|
@@ -2123,6 +2127,13 @@ var mergePluginsByName = (existing, incoming) => {
|
|
|
2123
2127
|
}
|
|
2124
2128
|
return Array.from(merged.values());
|
|
2125
2129
|
};
|
|
2130
|
+
var resetStuckPlugins = (plugins) => {
|
|
2131
|
+
const hasStuck = plugins.some((p) => p.status === "SYNCING");
|
|
2132
|
+
if (!hasStuck) return plugins;
|
|
2133
|
+
return plugins.map(
|
|
2134
|
+
(p) => p.status === "SYNCING" ? { ...p, status: "NOT_STARTED", error: null } : p
|
|
2135
|
+
);
|
|
2136
|
+
};
|
|
2126
2137
|
var updatePluginStatus = (plugins, name, status, error, lastSynced) => plugins.map(
|
|
2127
2138
|
(p) => p.name === name ? {
|
|
2128
2139
|
...p,
|
|
@@ -2248,6 +2259,12 @@ var PortalStateLive = Layer3.effect(
|
|
|
2248
2259
|
};
|
|
2249
2260
|
return [void 0, next];
|
|
2250
2261
|
}).pipe(Effect21.asVoid),
|
|
2262
|
+
resetStuckPlugins: (portalId) => modifyAndPersist(portalId, (sa) => {
|
|
2263
|
+
const fixed = resetStuckPlugins(sa.plugins);
|
|
2264
|
+
if (fixed === sa.plugins) return [void 0, sa];
|
|
2265
|
+
const next = { ...sa, plugins: fixed };
|
|
2266
|
+
return [void 0, next];
|
|
2267
|
+
}).pipe(Effect21.asVoid),
|
|
2251
2268
|
touchSyncedAt: (portalId) => modifyAndPersist(portalId, (current) => {
|
|
2252
2269
|
const next = { ...current, syncedAt: /* @__PURE__ */ new Date() };
|
|
2253
2270
|
return [void 0, next];
|
|
@@ -11945,6 +11962,16 @@ var makeEnsureFresh = (deps, options2) => createEnsureFresh(
|
|
|
11945
11962
|
options2
|
|
11946
11963
|
);
|
|
11947
11964
|
|
|
11965
|
+
// src/pure/plugin-sync-gate.ts
|
|
11966
|
+
var PLUGIN_SYNC_DEBOUNCE_MS = 30 * 60 * 1e3;
|
|
11967
|
+
var LAST_PLUGIN_SYNC_ALL_KEY = "last_plugin_sync_all";
|
|
11968
|
+
var shouldRunPluginSync = (lastSyncAllRaw) => {
|
|
11969
|
+
if (!lastSyncAllRaw) return true;
|
|
11970
|
+
const parsed = Date.parse(lastSyncAllRaw);
|
|
11971
|
+
if (Number.isNaN(parsed)) return true;
|
|
11972
|
+
return Date.now() - parsed >= PLUGIN_SYNC_DEBOUNCE_MS;
|
|
11973
|
+
};
|
|
11974
|
+
|
|
11948
11975
|
// src/index.ts
|
|
11949
11976
|
var server = new McpServer({
|
|
11950
11977
|
name: "mcp-pro-client",
|
|
@@ -12132,6 +12159,54 @@ var mainProgram = Effect93.gen(function* () {
|
|
|
12132
12159
|
Layer6.provide(Layer6.mergeAll(wsLayer, dbLayer, configLayer, portalStateLayer))
|
|
12133
12160
|
);
|
|
12134
12161
|
};
|
|
12162
|
+
const triggerPluginSync = (portalId) => {
|
|
12163
|
+
const syncLayer = makeSyncLayer(portalId);
|
|
12164
|
+
const dbLayer = makeDatabaseLive(portalId, getEncryptionKey());
|
|
12165
|
+
Effect93.runFork(
|
|
12166
|
+
pipe78(
|
|
12167
|
+
DatabaseService,
|
|
12168
|
+
Effect93.flatMap((db) => db.getMetadata(LAST_PLUGIN_SYNC_ALL_KEY)),
|
|
12169
|
+
Effect93.provide(dbLayer),
|
|
12170
|
+
Effect93.catchAll(() => Effect93.succeed(null)),
|
|
12171
|
+
Effect93.flatMap((lastSyncAll) => {
|
|
12172
|
+
if (!shouldRunPluginSync(lastSyncAll)) {
|
|
12173
|
+
return Effect93.sync(
|
|
12174
|
+
() => console.error(`[plugin-sync] Skipping plugin sync for portal ${portalId} (debounce \u2014 last sync: ${lastSyncAll})`)
|
|
12175
|
+
);
|
|
12176
|
+
}
|
|
12177
|
+
return pipe78(
|
|
12178
|
+
portalState.resetStuckPlugins(portalId),
|
|
12179
|
+
Effect93.catchAll(() => Effect93.void),
|
|
12180
|
+
Effect93.tap(() => Effect93.sync(
|
|
12181
|
+
() => console.error(`[plugin-sync] Starting message plugin sync for portal ${portalId}`)
|
|
12182
|
+
)),
|
|
12183
|
+
Effect93.flatMap(
|
|
12184
|
+
() => pipe78(
|
|
12185
|
+
SyncService,
|
|
12186
|
+
Effect93.flatMap((sync) => sync.syncMessagePlugins(portalId)),
|
|
12187
|
+
Effect93.provide(syncLayer)
|
|
12188
|
+
)
|
|
12189
|
+
),
|
|
12190
|
+
Effect93.flatMap(
|
|
12191
|
+
() => pipe78(
|
|
12192
|
+
DatabaseService,
|
|
12193
|
+
Effect93.flatMap((db) => db.setMetadata(LAST_PLUGIN_SYNC_ALL_KEY, (/* @__PURE__ */ new Date()).toISOString())),
|
|
12194
|
+
Effect93.provide(dbLayer)
|
|
12195
|
+
)
|
|
12196
|
+
),
|
|
12197
|
+
Effect93.tap(() => Effect93.sync(
|
|
12198
|
+
() => console.error(`[plugin-sync] Completed message plugin sync for portal ${portalId}`)
|
|
12199
|
+
)),
|
|
12200
|
+
Effect93.catchAll(
|
|
12201
|
+
(error) => Effect93.sync(
|
|
12202
|
+
() => console.error(`[plugin-sync] Failed for portal ${portalId}:`, error)
|
|
12203
|
+
)
|
|
12204
|
+
)
|
|
12205
|
+
);
|
|
12206
|
+
})
|
|
12207
|
+
)
|
|
12208
|
+
);
|
|
12209
|
+
};
|
|
12135
12210
|
configureArtifactQueue(
|
|
12136
12211
|
(portalId, artifact) => pipe78(
|
|
12137
12212
|
SyncService,
|
|
@@ -12268,6 +12343,9 @@ var mainProgram = Effect93.gen(function* () {
|
|
|
12268
12343
|
for (const portalId of warmupPortalIds) {
|
|
12269
12344
|
Effect93.runFork(pipe78(ws.sendSyncFull(portalId), Effect93.catchAll(() => Effect93.void)));
|
|
12270
12345
|
}
|
|
12346
|
+
for (const portalId of warmupPortalIds) {
|
|
12347
|
+
triggerPluginSync(portalId);
|
|
12348
|
+
}
|
|
12271
12349
|
},
|
|
12272
12350
|
onSyncDiffNeeded: (portalId) => {
|
|
12273
12351
|
const selectedPortalId2 = getSelectedPortalId(config);
|