@skilder-ai/runtime 0.7.2 → 0.7.3
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 +41 -46
- package/dist/index.js.map +3 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -137966,7 +137966,7 @@ var RuntimeCallToolResponse = class extends NatsResponse {
|
|
|
137966
137966
|
this.type = type7;
|
|
137967
137967
|
}
|
|
137968
137968
|
validate(data) {
|
|
137969
|
-
return data.result !== void 0 && data.
|
|
137969
|
+
return data.result !== void 0 && data.executedBy !== void 0;
|
|
137970
137970
|
}
|
|
137971
137971
|
};
|
|
137972
137972
|
NatsMessage.register(RuntimeCallToolResponse);
|
|
@@ -138347,7 +138347,6 @@ __export(dgraph_resolvers_types_exports, {
|
|
|
138347
138347
|
OAuthProviderType: () => OAuthProviderType,
|
|
138348
138348
|
OnboardingStepStatus: () => OnboardingStepStatus,
|
|
138349
138349
|
OnboardingStepType: () => OnboardingStepType,
|
|
138350
|
-
RuntimeType: () => RuntimeType,
|
|
138351
138350
|
ScriptType: () => ScriptType,
|
|
138352
138351
|
ToolCallStatus: () => ToolCallStatus,
|
|
138353
138352
|
WorkspaceRole: () => WorkspaceRole
|
|
@@ -138443,11 +138442,6 @@ var OnboardingStepType = /* @__PURE__ */ ((OnboardingStepType2) => {
|
|
|
138443
138442
|
OnboardingStepType2["Onboarding"] = "ONBOARDING";
|
|
138444
138443
|
return OnboardingStepType2;
|
|
138445
138444
|
})(OnboardingStepType || {});
|
|
138446
|
-
var RuntimeType = /* @__PURE__ */ ((RuntimeType2) => {
|
|
138447
|
-
RuntimeType2["Edge"] = "EDGE";
|
|
138448
|
-
RuntimeType2["Mcp"] = "MCP";
|
|
138449
|
-
return RuntimeType2;
|
|
138450
|
-
})(RuntimeType || {});
|
|
138451
138445
|
var ScriptType = /* @__PURE__ */ ((ScriptType3) => {
|
|
138452
138446
|
ScriptType3["Bash"] = "BASH";
|
|
138453
138447
|
ScriptType3["Javascript"] = "JAVASCRIPT";
|
|
@@ -145842,10 +145836,6 @@ var McpStdioService = class McpStdioService2 extends Service {
|
|
|
145842
145836
|
if (!identity || !identity.name) {
|
|
145843
145837
|
throw new Error("Cannot start MCP server: identity not found or incomplete");
|
|
145844
145838
|
}
|
|
145845
|
-
this.clientInfo = {
|
|
145846
|
-
name: request.params.clientInfo.name,
|
|
145847
|
-
version: request.params.clientInfo.version
|
|
145848
|
-
};
|
|
145849
145839
|
this.logger.info(`Setting MCP client name to ${request.params.clientInfo.name}`);
|
|
145850
145840
|
if (request.params.capabilities.roots) {
|
|
145851
145841
|
this.clientCapabilities.roots = { listChanged: request.params.capabilities.roots.listChanged ?? false };
|
|
@@ -145922,7 +145912,6 @@ var McpStdioService = class McpStdioService2 extends Service {
|
|
|
145922
145912
|
}
|
|
145923
145913
|
this.server = void 0;
|
|
145924
145914
|
this.transport = void 0;
|
|
145925
|
-
this.clientInfo = void 0;
|
|
145926
145915
|
}
|
|
145927
145916
|
getClientRoots() {
|
|
145928
145917
|
return this.clientRoots.getValue();
|
|
@@ -152626,7 +152615,6 @@ var ToolService = class ToolService2 extends Service {
|
|
|
152626
152615
|
this.oauthTokenService = oauthTokenService;
|
|
152627
152616
|
this.oauthClientInfoService = oauthClientInfoService;
|
|
152628
152617
|
this.mcpStdioService = mcpStdioService;
|
|
152629
|
-
this.runtimeExecutionId = runtimeExecutionId;
|
|
152630
152618
|
this.scriptExecutorService = scriptExecutorService;
|
|
152631
152619
|
this.delegateService = delegateService;
|
|
152632
152620
|
this.name = "tool";
|
|
@@ -152731,27 +152719,29 @@ var ToolService = class ToolService2 extends Service {
|
|
|
152731
152719
|
const identity = this.authService.getIdentity();
|
|
152732
152720
|
if (!identity?.workspaceId || !identity?.id) {
|
|
152733
152721
|
this.logger.warn(`Cannot stop observing configured MCPServers for tool runtime: workspaceId or id not found`);
|
|
152734
|
-
|
|
152735
|
-
|
|
152736
|
-
|
|
152737
|
-
|
|
152738
|
-
|
|
152739
|
-
|
|
152740
|
-
|
|
152722
|
+
} else {
|
|
152723
|
+
this.logger.debug(`Stopping to observe configured MCPServers for tool runtime ${identity.workspaceId} - ${identity.id}`);
|
|
152724
|
+
const drainPromises = this.natsSubscriptions.map(async (subscription) => {
|
|
152725
|
+
try {
|
|
152726
|
+
if (!subscription.isClosed?.()) {
|
|
152727
|
+
await subscription.drain();
|
|
152728
|
+
}
|
|
152729
|
+
} catch (error48) {
|
|
152730
|
+
this.logger.warn(`Failed to drain subscription: ${error48}`);
|
|
152741
152731
|
}
|
|
152742
|
-
}
|
|
152743
|
-
|
|
152732
|
+
});
|
|
152733
|
+
await Promise.allSettled(drainPromises);
|
|
152734
|
+
this.natsSubscriptions = [];
|
|
152735
|
+
for (const subscription of this.cacheSubscriptions) {
|
|
152736
|
+
subscription.unsubscribe();
|
|
152744
152737
|
}
|
|
152745
|
-
|
|
152746
|
-
await Promise.allSettled(drainPromises);
|
|
152747
|
-
this.natsSubscriptions = [];
|
|
152748
|
-
for (const subscription of this.cacheSubscriptions) {
|
|
152749
|
-
subscription.unsubscribe();
|
|
152738
|
+
this.cacheSubscriptions = [];
|
|
152750
152739
|
}
|
|
152751
|
-
this.cacheSubscriptions = [];
|
|
152752
152740
|
const serverIds = Array.from(this.mcpServers.keys());
|
|
152753
152741
|
for (const mcpServerId of serverIds) {
|
|
152754
152742
|
const service = this.mcpServers.get(mcpServerId);
|
|
152743
|
+
if (!service)
|
|
152744
|
+
continue;
|
|
152755
152745
|
await this.stopMCPServer({ id: mcpServerId, name: service.getName() });
|
|
152756
152746
|
}
|
|
152757
152747
|
}
|
|
@@ -152874,7 +152864,7 @@ var ToolService = class ToolService2 extends Service {
|
|
|
152874
152864
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
152875
152865
|
async handleToolCall(subscription) {
|
|
152876
152866
|
const identity = this.authService.getIdentity();
|
|
152877
|
-
const
|
|
152867
|
+
const executedBy = identity?.nature === "runtime" ? identity.id : "AGENT";
|
|
152878
152868
|
for await (const msg of subscription) {
|
|
152879
152869
|
if (msg instanceof SkillCallToolRequest) {
|
|
152880
152870
|
const logData = { ...msg.data, userKey: msg.data.userKey ? "[REDACTED]" : void 0 };
|
|
@@ -152888,7 +152878,7 @@ var ToolService = class ToolService2 extends Service {
|
|
|
152888
152878
|
}
|
|
152889
152879
|
if (msg.isScript()) {
|
|
152890
152880
|
try {
|
|
152891
|
-
await this.handleScriptExecution(msg,
|
|
152881
|
+
await this.handleScriptExecution(msg, executedBy);
|
|
152892
152882
|
} catch (error48) {
|
|
152893
152883
|
this.logger.error({ error: error48, scriptId: msg.data.scriptId }, "Unhandled error in script execution");
|
|
152894
152884
|
msg.respond(new ErrorResponse({ error: "Script execution failed unexpectedly" }));
|
|
@@ -152941,7 +152931,7 @@ var ToolService = class ToolService2 extends Service {
|
|
|
152941
152931
|
],
|
|
152942
152932
|
isError: true
|
|
152943
152933
|
},
|
|
152944
|
-
|
|
152934
|
+
executedBy
|
|
152945
152935
|
}));
|
|
152946
152936
|
toolCalled = true;
|
|
152947
152937
|
continue;
|
|
@@ -152958,7 +152948,7 @@ var ToolService = class ToolService2 extends Service {
|
|
|
152958
152948
|
],
|
|
152959
152949
|
isError: true
|
|
152960
152950
|
},
|
|
152961
|
-
|
|
152951
|
+
executedBy
|
|
152962
152952
|
}));
|
|
152963
152953
|
toolCalled = true;
|
|
152964
152954
|
continue;
|
|
@@ -152989,7 +152979,7 @@ var ToolService = class ToolService2 extends Service {
|
|
|
152989
152979
|
],
|
|
152990
152980
|
isError: true
|
|
152991
152981
|
},
|
|
152992
|
-
|
|
152982
|
+
executedBy
|
|
152993
152983
|
}));
|
|
152994
152984
|
toolCalled = true;
|
|
152995
152985
|
continue;
|
|
@@ -153034,7 +153024,7 @@ var ToolService = class ToolService2 extends Service {
|
|
|
153034
153024
|
}
|
|
153035
153025
|
msg.respond(new RuntimeCallToolResponse({
|
|
153036
153026
|
result,
|
|
153037
|
-
|
|
153027
|
+
executedBy
|
|
153038
153028
|
}));
|
|
153039
153029
|
} catch (callError) {
|
|
153040
153030
|
this.logger.error(`Tool call ${tool2.name} failed: ${callError}`);
|
|
@@ -153057,7 +153047,7 @@ var ToolService = class ToolService2 extends Service {
|
|
|
153057
153047
|
* Handle script execution requests on EDGE runtime.
|
|
153058
153048
|
* Fetches script code via NATS and executes using ScriptExecutorService.
|
|
153059
153049
|
*/
|
|
153060
|
-
async handleScriptExecution(msg,
|
|
153050
|
+
async handleScriptExecution(msg, executedBy) {
|
|
153061
153051
|
const { scriptId, scriptName, workspaceId, arguments: toolArgs } = msg.data;
|
|
153062
153052
|
const args = toolArgs?.args || [];
|
|
153063
153053
|
this.logger.info({ scriptId, scriptName, argsCount: args.length }, "Handling script execution request");
|
|
@@ -153080,7 +153070,7 @@ var ToolService = class ToolService2 extends Service {
|
|
|
153080
153070
|
],
|
|
153081
153071
|
isError: true
|
|
153082
153072
|
},
|
|
153083
|
-
|
|
153073
|
+
executedBy
|
|
153084
153074
|
}));
|
|
153085
153075
|
return;
|
|
153086
153076
|
}
|
|
@@ -153090,7 +153080,7 @@ var ToolService = class ToolService2 extends Service {
|
|
|
153090
153080
|
content: [{ type: "text", text: `Error: ${fetchResponse.data.error}` }],
|
|
153091
153081
|
isError: true
|
|
153092
153082
|
},
|
|
153093
|
-
|
|
153083
|
+
executedBy
|
|
153094
153084
|
}));
|
|
153095
153085
|
return;
|
|
153096
153086
|
}
|
|
@@ -153100,7 +153090,7 @@ var ToolService = class ToolService2 extends Service {
|
|
|
153100
153090
|
content: [{ type: "text", text: "Error: Invalid response from backend" }],
|
|
153101
153091
|
isError: true
|
|
153102
153092
|
},
|
|
153103
|
-
|
|
153093
|
+
executedBy
|
|
153104
153094
|
}));
|
|
153105
153095
|
return;
|
|
153106
153096
|
}
|
|
@@ -153110,7 +153100,7 @@ var ToolService = class ToolService2 extends Service {
|
|
|
153110
153100
|
content: [{ type: "text", text: `Error: ${fetchResponse.data.error}` }],
|
|
153111
153101
|
isError: true
|
|
153112
153102
|
},
|
|
153113
|
-
|
|
153103
|
+
executedBy
|
|
153114
153104
|
}));
|
|
153115
153105
|
return;
|
|
153116
153106
|
}
|
|
@@ -153122,7 +153112,7 @@ var ToolService = class ToolService2 extends Service {
|
|
|
153122
153112
|
content: [{ type: "text", text: "Error: Script has no type defined (expected Python, Bash, Javascript, or Typescript)" }],
|
|
153123
153113
|
isError: true
|
|
153124
153114
|
},
|
|
153125
|
-
|
|
153115
|
+
executedBy
|
|
153126
153116
|
}));
|
|
153127
153117
|
return;
|
|
153128
153118
|
}
|
|
@@ -153158,7 +153148,7 @@ ${result.stderr}`;
|
|
|
153158
153148
|
result: {
|
|
153159
153149
|
content: [{ type: "text", text: output || "(Script executed successfully with no output)" }]
|
|
153160
153150
|
},
|
|
153161
|
-
|
|
153151
|
+
executedBy
|
|
153162
153152
|
}));
|
|
153163
153153
|
} else {
|
|
153164
153154
|
const errorOutput = result.stderr || result.error || "Unknown error";
|
|
@@ -153173,7 +153163,7 @@ ${errorOutput}`;
|
|
|
153173
153163
|
content: [{ type: "text", text: fullOutput }],
|
|
153174
153164
|
isError: true
|
|
153175
153165
|
},
|
|
153176
|
-
|
|
153166
|
+
executedBy
|
|
153177
153167
|
}));
|
|
153178
153168
|
}
|
|
153179
153169
|
}
|
|
@@ -153691,10 +153681,15 @@ var MainService = class MainService2 extends Service {
|
|
|
153691
153681
|
process.kill(process.pid, "SIGKILL");
|
|
153692
153682
|
}, 1e4);
|
|
153693
153683
|
this.logger.info(`Graceful shutdown: ${signal}`);
|
|
153694
|
-
|
|
153695
|
-
|
|
153696
|
-
|
|
153697
|
-
|
|
153684
|
+
try {
|
|
153685
|
+
await this.stop("index");
|
|
153686
|
+
} catch (error48) {
|
|
153687
|
+
this.logger.error({ event: "shutdown_error", err: error48 }, "Error during shutdown");
|
|
153688
|
+
} finally {
|
|
153689
|
+
clearInterval(keepAlive);
|
|
153690
|
+
clearInterval(forceKill);
|
|
153691
|
+
process.exit(0);
|
|
153692
|
+
}
|
|
153698
153693
|
}
|
|
153699
153694
|
logActiveServices(numberOfExpectedAlive = 0) {
|
|
153700
153695
|
const activeServices = Service.getActiveServices();
|