@skilder-ai/runtime 0.5.0 → 0.5.1
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 +24 -19
- package/dist/index.js.map +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -118836,7 +118836,7 @@ var SessionAuthService = class {
|
|
|
118836
118836
|
* Authenticate via handshake and return the session identity
|
|
118837
118837
|
*/
|
|
118838
118838
|
async authenticateViaHandshake(headers) {
|
|
118839
|
-
const { userKey, skillIds, hatIds, publishAllTools
|
|
118839
|
+
const { userKey, skillIds, hatIds, publishAllTools } = headers;
|
|
118840
118840
|
if (!userKey) {
|
|
118841
118841
|
throw new Error("USER_KEY is required for authentication");
|
|
118842
118842
|
}
|
|
@@ -118867,8 +118867,6 @@ var SessionAuthService = class {
|
|
|
118867
118867
|
this.logger.info(
|
|
118868
118868
|
`Successfully authenticated user: ${response.data.name} (${response.data.id}) in workspace ${response.data.workspaceId}`
|
|
118869
118869
|
);
|
|
118870
|
-
const mergedPreloadSkillIds = [...skillIds || [], ...preloadSkillIds || []];
|
|
118871
|
-
const mergedPreloadHatIds = [...hatIds || [], ...preloadHatIds || []];
|
|
118872
118870
|
this.identity = {
|
|
118873
118871
|
nature: "user",
|
|
118874
118872
|
id: response.data.id,
|
|
@@ -118876,9 +118874,8 @@ var SessionAuthService = class {
|
|
|
118876
118874
|
workspaceId: response.data.workspaceId,
|
|
118877
118875
|
runtimeExecutionId: this.runtimeExecutionId,
|
|
118878
118876
|
// Preloaded IDs are kept locally - not sent to backend
|
|
118879
|
-
|
|
118880
|
-
|
|
118881
|
-
preloadedHatIds: mergedPreloadHatIds.length > 0 ? [...new Set(mergedPreloadHatIds)] : void 0,
|
|
118877
|
+
preloadedSkillIds: skillIds && skillIds.length > 0 ? skillIds : void 0,
|
|
118878
|
+
preloadedHatIds: hatIds && hatIds.length > 0 ? hatIds : void 0,
|
|
118882
118879
|
publishAllTools
|
|
118883
118880
|
};
|
|
118884
118881
|
return this.identity;
|
|
@@ -118895,29 +118892,23 @@ var SessionAuthService = class {
|
|
|
118895
118892
|
function extractAuthHeaders(request) {
|
|
118896
118893
|
const headers = request.headers;
|
|
118897
118894
|
const query = request.query;
|
|
118895
|
+
const publishAllTools = query?.publishAllTools === "true";
|
|
118898
118896
|
const skillIds = query?.skillIds?.split(",").filter(Boolean);
|
|
118899
118897
|
const hatIds = query?.hatIds?.split(",").filter(Boolean);
|
|
118900
|
-
const publishAllTools = query?.publishAllTools === "true";
|
|
118901
|
-
const preloadSkillIds = query?.preloadSkillIds?.split(",").filter(Boolean);
|
|
118902
|
-
const preloadHatIds = query?.preloadHatIds?.split(",").filter(Boolean);
|
|
118903
118898
|
const queryKey = query?.key;
|
|
118904
118899
|
if (queryKey) {
|
|
118905
118900
|
return {
|
|
118906
118901
|
userKey: queryKey,
|
|
118907
|
-
skillIds: skillIds && skillIds.length > 0 ? skillIds : void 0,
|
|
118908
|
-
hatIds: hatIds && hatIds.length > 0 ? hatIds : void 0,
|
|
118909
118902
|
publishAllTools: publishAllTools || void 0,
|
|
118910
|
-
|
|
118911
|
-
|
|
118903
|
+
skillIds: skillIds && skillIds.length > 0 ? skillIds : void 0,
|
|
118904
|
+
hatIds: hatIds && hatIds.length > 0 ? hatIds : void 0
|
|
118912
118905
|
};
|
|
118913
118906
|
}
|
|
118914
118907
|
return {
|
|
118915
118908
|
userKey: typeof headers["user_key"] === "string" ? headers["user_key"] : void 0,
|
|
118916
|
-
skillIds: skillIds && skillIds.length > 0 ? skillIds : void 0,
|
|
118917
|
-
hatIds: hatIds && hatIds.length > 0 ? hatIds : void 0,
|
|
118918
118909
|
publishAllTools: publishAllTools || void 0,
|
|
118919
|
-
|
|
118920
|
-
|
|
118910
|
+
skillIds: skillIds && skillIds.length > 0 ? skillIds : void 0,
|
|
118911
|
+
hatIds: hatIds && hatIds.length > 0 ? hatIds : void 0
|
|
118921
118912
|
};
|
|
118922
118913
|
}
|
|
118923
118914
|
async function authenticateSession(request, loggerService, natsService, runtimeExecutionId) {
|
|
@@ -123821,6 +123812,8 @@ var ToolService = class ToolService2 extends Service {
|
|
|
123821
123812
|
const subscription = await this.cacheService.watch(CACHE_BUCKETS.EPHEMERAL, { key: subject });
|
|
123822
123813
|
this.cacheSubscriptions.push(subscription);
|
|
123823
123814
|
for await (const event of subscription) {
|
|
123815
|
+
if (this.state === "STOPPING")
|
|
123816
|
+
break;
|
|
123824
123817
|
if (event.operation !== "PUT" || !event.value)
|
|
123825
123818
|
continue;
|
|
123826
123819
|
const msg = NatsMessage.fromRawData(event.value);
|
|
@@ -123892,8 +123885,13 @@ var ToolService = class ToolService2 extends Service {
|
|
|
123892
123885
|
this.logger.debug(`MCPServer ${mcpServer.name} already running -> shutting down`);
|
|
123893
123886
|
await this.stopMCPServer(mcpServer);
|
|
123894
123887
|
}
|
|
123895
|
-
await this.startService(mcpServerService);
|
|
123896
123888
|
this.mcpServers.set(mcpServer.id, mcpServerService);
|
|
123889
|
+
try {
|
|
123890
|
+
await this.startService(mcpServerService);
|
|
123891
|
+
} catch (error48) {
|
|
123892
|
+
this.mcpServers.delete(mcpServer.id);
|
|
123893
|
+
throw error48;
|
|
123894
|
+
}
|
|
123897
123895
|
mcpServerService.observeTools().subscribe((tools2) => {
|
|
123898
123896
|
this.logger.debug(`Updating tools for MCP Server ${mcpServer.id} with ${tools2.length} tools`);
|
|
123899
123897
|
const message = RuntimeDiscoveredToolsPublish.create({
|
|
@@ -124072,6 +124070,8 @@ var ToolService = class ToolService2 extends Service {
|
|
|
124072
124070
|
const subscription = await this.cacheService.watch(CACHE_BUCKETS.EPHEMERAL, { key: subject });
|
|
124073
124071
|
this.cacheSubscriptions.push(subscription);
|
|
124074
124072
|
for await (const event of subscription) {
|
|
124073
|
+
if (this.state === "STOPPING")
|
|
124074
|
+
break;
|
|
124075
124075
|
if (event.operation !== "PUT" || !event.value)
|
|
124076
124076
|
continue;
|
|
124077
124077
|
const msg = NatsMessage.fromRawData(event.value);
|
|
@@ -124126,8 +124126,13 @@ var ToolService = class ToolService2 extends Service {
|
|
|
124126
124126
|
this.logger.debug(`Smart skill ${skill.name} already running -> shutting down`);
|
|
124127
124127
|
await this.stopSmartSkill({ id: skill.id, name: skill.name });
|
|
124128
124128
|
}
|
|
124129
|
-
await this.startService(skillService);
|
|
124130
124129
|
this.smartSkills.set(skill.id, skillService);
|
|
124130
|
+
try {
|
|
124131
|
+
await this.startService(skillService);
|
|
124132
|
+
} catch (error48) {
|
|
124133
|
+
this.smartSkills.delete(skill.id);
|
|
124134
|
+
throw error48;
|
|
124135
|
+
}
|
|
124131
124136
|
if (!this.smartSkillSubscriptions.has(skill.id)) {
|
|
124132
124137
|
this.logger.debug(`Subscribing to tool calls for smart skill ${skill.name} (${skill.id})`);
|
|
124133
124138
|
const subscription = this.subscribeToSmartSkillTool(skill);
|