@skilder-ai/runtime 0.7.7 → 0.7.9
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 +38 -6
- package/dist/index.js.map +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -137705,8 +137705,14 @@ var NatsCacheService = class NatsCacheService2 extends Service {
|
|
|
137705
137705
|
async put(bucket, key, value) {
|
|
137706
137706
|
const kv = this.getBucket(bucket);
|
|
137707
137707
|
const data = JSON.stringify(value);
|
|
137708
|
-
|
|
137709
|
-
|
|
137708
|
+
try {
|
|
137709
|
+
const revision = await kv.put(key, data);
|
|
137710
|
+
return revision;
|
|
137711
|
+
} catch (error48) {
|
|
137712
|
+
const sizeBytes = new TextEncoder().encode(data).length;
|
|
137713
|
+
this.logger.error({ event: "cache_put_failed", bucket, key, sizeBytes, err: error48.message }, `Failed to put cache entry (${(sizeBytes / 1024).toFixed(1)} KB)`);
|
|
137714
|
+
throw error48;
|
|
137715
|
+
}
|
|
137710
137716
|
}
|
|
137711
137717
|
async delete(bucket, key) {
|
|
137712
137718
|
const kv = this.getBucket(bucket);
|
|
@@ -152421,6 +152427,8 @@ var ToolServerService = class ToolServerService2 extends Service {
|
|
|
152421
152427
|
this.isPythonServer = false;
|
|
152422
152428
|
this.onShutdownCallback = async () => {
|
|
152423
152429
|
};
|
|
152430
|
+
this.debounceTimer = null;
|
|
152431
|
+
this.pendingTools = null;
|
|
152424
152432
|
this.logger.info(`Initializing MCP server service for ${this.config.name}`);
|
|
152425
152433
|
this.client = new Client({
|
|
152426
152434
|
name: this.config.name,
|
|
@@ -152511,12 +152519,28 @@ var ToolServerService = class ToolServerService2 extends Service {
|
|
|
152511
152519
|
throw error48;
|
|
152512
152520
|
}
|
|
152513
152521
|
this.logger.debug("Connected to MCP server");
|
|
152514
|
-
const
|
|
152515
|
-
|
|
152522
|
+
const emitTools = (tools) => {
|
|
152523
|
+
this.pendingTools = tools;
|
|
152524
|
+
if (this.debounceTimer)
|
|
152525
|
+
clearTimeout(this.debounceTimer);
|
|
152526
|
+
this.debounceTimer = setTimeout(() => {
|
|
152527
|
+
if (this.pendingTools) {
|
|
152528
|
+
this.tools.next(this.pendingTools);
|
|
152529
|
+
this.pendingTools = null;
|
|
152530
|
+
}
|
|
152531
|
+
this.debounceTimer = null;
|
|
152532
|
+
}, 200);
|
|
152533
|
+
};
|
|
152516
152534
|
this.client.setNotificationHandler(ToolListChangedNotificationSchema, async () => {
|
|
152517
|
-
|
|
152518
|
-
|
|
152535
|
+
try {
|
|
152536
|
+
const updatedTools = await this.client.listTools();
|
|
152537
|
+
emitTools(updatedTools.tools);
|
|
152538
|
+
} catch (error48) {
|
|
152539
|
+
this.logger.error({ err: error48 }, "Failed to refresh tool list after ToolListChanged notification");
|
|
152540
|
+
}
|
|
152519
152541
|
});
|
|
152542
|
+
const originalTools = await this.client.listTools();
|
|
152543
|
+
emitTools(originalTools.tools);
|
|
152520
152544
|
}
|
|
152521
152545
|
/**
|
|
152522
152546
|
* Extract the most relevant error line from stderr output.
|
|
@@ -152536,6 +152560,14 @@ var ToolServerService = class ToolServerService2 extends Service {
|
|
|
152536
152560
|
}
|
|
152537
152561
|
async shutdown() {
|
|
152538
152562
|
this.logger.info("Stopping");
|
|
152563
|
+
if (this.debounceTimer) {
|
|
152564
|
+
clearTimeout(this.debounceTimer);
|
|
152565
|
+
this.debounceTimer = null;
|
|
152566
|
+
if (this.pendingTools) {
|
|
152567
|
+
this.tools.next(this.pendingTools);
|
|
152568
|
+
this.pendingTools = null;
|
|
152569
|
+
}
|
|
152570
|
+
}
|
|
152539
152571
|
this.tools.complete();
|
|
152540
152572
|
await this.onShutdownCallback();
|
|
152541
152573
|
if (this.transport instanceof StdioClientTransport) {
|