@skilder-ai/runtime 0.9.5 → 0.9.7

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 CHANGED
@@ -21889,7 +21889,7 @@ var require_transport = __commonJS({
21889
21889
  "use strict";
21890
21890
  var { createRequire: createRequire2 } = require("module");
21891
21891
  var getCallers = require_caller();
21892
- var { join: join6, isAbsolute: isAbsolute3, sep: sep3 } = require("node:path");
21892
+ var { join: join6, isAbsolute: isAbsolute4, sep: sep3 } = require("node:path");
21893
21893
  var sleep = require_atomic_sleep();
21894
21894
  var onExit = require_on_exit_leak_free();
21895
21895
  var ThreadStream = require_thread_stream();
@@ -21988,7 +21988,7 @@ var require_transport = __commonJS({
21988
21988
  return buildStream(fixTarget(target), options, worker, sync);
21989
21989
  function fixTarget(origin) {
21990
21990
  origin = bundlerOverrides[origin] || origin;
21991
- if (isAbsolute3(origin) || origin.indexOf("file://") === 0) {
21991
+ if (isAbsolute4(origin) || origin.indexOf("file://") === 0) {
21992
21992
  return origin;
21993
21993
  }
21994
21994
  if (origin === "pino/file") {
@@ -87950,7 +87950,13 @@ async function executeGraphQL(query, variables, userKey, logger) {
87950
87950
  });
87951
87951
  if (!response.ok) {
87952
87952
  const hint = getHttpErrorHint(response.status);
87953
- throw new Error(`HTTP error: ${response.status} ${response.statusText}${hint}`);
87953
+ let detail = "";
87954
+ try {
87955
+ const text2 = await response.text();
87956
+ if (text2) detail = `. Response: ${text2.length > 500 ? text2.slice(0, 500) + "\u2026" : text2}`;
87957
+ } catch {
87958
+ }
87959
+ throw new Error(`HTTP error: ${response.status} ${response.statusText}${hint}${detail}`);
87954
87960
  }
87955
87961
  const result = await response.json();
87956
87962
  if (result.errors && result.errors.length > 0) {
@@ -111000,7 +111006,6 @@ var NatsMessage = class {
111000
111006
  }
111001
111007
  return message;
111002
111008
  }
111003
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
111004
111009
  validate(_data) {
111005
111010
  throw new Error("validate method not implemented.");
111006
111011
  }
@@ -138862,6 +138867,7 @@ var OAuthProviderType = /* @__PURE__ */ ((OAuthProviderType2) => {
138862
138867
  OAuthProviderType2["GithubSignin"] = "GITHUB_SIGNIN";
138863
138868
  OAuthProviderType2["Google"] = "GOOGLE";
138864
138869
  OAuthProviderType2["GoogleSignin"] = "GOOGLE_SIGNIN";
138870
+ OAuthProviderType2["Infomaniak"] = "INFOMANIAK";
138865
138871
  OAuthProviderType2["McpOauth"] = "MCP_OAUTH";
138866
138872
  OAuthProviderType2["Microsoft"] = "MICROSOFT";
138867
138873
  OAuthProviderType2["Zoho"] = "ZOHO";
@@ -145847,6 +145853,13 @@ To execute this script:
145847
145853
  }
145848
145854
  if (!response.ok) {
145849
145855
  if (response.status === 404) {
145856
+ const parsed = await response.clone().json().catch(() => null);
145857
+ if (parsed?.code === "ASSET_NO_FILE_ATTACHED") {
145858
+ throw new DownloadAssetError(
145859
+ `Error: Asset "${item.name}" has no file attached yet. Ask the user to upload one in the Skilder editor before retrying.`,
145860
+ skill.id
145861
+ );
145862
+ }
145850
145863
  throw new DownloadAssetError(
145851
145864
  `Error: Asset "${item.name}" has not been uploaded yet, or no longer exists.`,
145852
145865
  skill.id
@@ -153626,15 +153639,14 @@ var ToolServerService = class ToolServerService2 extends LifecycleService {
153626
153639
  * while Node.js errors appear on the first line.
153627
153640
  */
153628
153641
  extractStderrMessage(stderr) {
153629
- const lines = stderr.split("\n");
153642
+ const lines = stderr.split("\n").map((l2) => l2.trim()).filter(Boolean);
153643
+ if (lines.length === 0)
153644
+ return "";
153630
153645
  if (this.isPythonServer) {
153631
- for (let i2 = lines.length - 1; i2 >= 0; i2--) {
153632
- const line = lines[i2].trim();
153633
- if (line)
153634
- return line;
153635
- }
153646
+ return lines[lines.length - 1];
153636
153647
  }
153637
- return lines[0].trim();
153648
+ const messageLine = lines.find((l2) => /^(?:[A-Z][\w]*Error|Error)\b/.test(l2));
153649
+ return messageLine ?? lines[0];
153638
153650
  }
153639
153651
  async shutdown() {
153640
153652
  this.logger.info("Stopping");
@@ -154743,14 +154755,27 @@ var ToolService = class ToolService2 extends LifecycleService {
154743
154755
  this.mcpTools.delete(mcpServerId);
154744
154756
  this.mcpServerWorkspaces.delete(mcpServerId);
154745
154757
  }
154746
- // Subscribe to a tool and return the subscription
154747
- subscribeToTool(tool2, workspaceId) {
154758
+ // Subscribe to a tool and return the subscription.
154759
+ // Self-heal: if the consumer loop exits (normally or via throw), drop our
154760
+ // bookkeeping entry so the next ensureToolsSubscribed() reconcile re-subscribes
154761
+ // instead of skipping the tool as "already subscribed" while no one reads from
154762
+ // the subject — that mismatch causes silent NATS request timeouts on the caller.
154763
+ subscribeToTool(tool2, workspaceId, mcpServerId) {
154748
154764
  const subject = SkillCallToolRequest.subscribeToTool(tool2.id, workspaceId);
154749
154765
  this.logger.debug(`Subscribing to tool ${tool2.id} on subject: ${subject}`);
154750
154766
  const subscription = this.natsService.subscribe(subject);
154751
- this.handleToolCall(subscription).catch((err) => {
154752
- this.logger.error({ event: "tool_call_subscription_died", toolId: tool2.id, err }, "Tool call subscription loop terminated unexpectedly");
154753
- });
154767
+ const onLoopEnd = (err) => {
154768
+ if (err) {
154769
+ this.logger.error({ event: "tool_call_subscription_died", toolId: tool2.id, mcpServerId, err }, "Tool call subscription loop terminated unexpectedly");
154770
+ } else {
154771
+ this.logger.debug({ event: "tool_call_subscription_ended", toolId: tool2.id, mcpServerId }, "Tool call subscription loop ended");
154772
+ }
154773
+ const serverToolSubs = this.toolSubscriptions.get(mcpServerId);
154774
+ if (serverToolSubs && serverToolSubs.get(tool2.id) === subscription) {
154775
+ serverToolSubs.delete(tool2.id);
154776
+ }
154777
+ };
154778
+ this.handleToolCall(subscription).then(() => onLoopEnd(), (err) => onLoopEnd(err));
154754
154779
  return subscription;
154755
154780
  }
154756
154781
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -155605,7 +155630,7 @@ ${result.stdout}
155605
155630
  for (const tool2 of tools) {
155606
155631
  if (tool2 && !serverToolSubs.has(tool2.id)) {
155607
155632
  this.logger.debug(`Subscribing to tool ${tool2.name} (${tool2.id})`);
155608
- const subscription = this.subscribeToTool(tool2, workspaceId);
155633
+ const subscription = this.subscribeToTool(tool2, workspaceId, mcpServerId);
155609
155634
  serverToolSubs.set(tool2.id, subscription);
155610
155635
  } else if (tool2) {
155611
155636
  this.logger.debug(`Tool ${tool2.name} (${tool2.id}) already subscribed -> skipping`);
@@ -156458,6 +156483,9 @@ var start = () => {
156458
156483
  var projectRoot = (0, import_path4.resolve)(__dirname, "../../..");
156459
156484
  var packagePath = (0, import_path4.resolve)(__dirname, "../");
156460
156485
  loadEnv(projectRoot, packagePath, process.env.FORWARD_STDERR !== "false");
156486
+ if (process.env.MCP_SERVERS_PATH && !(0, import_path4.isAbsolute)(process.env.MCP_SERVERS_PATH)) {
156487
+ process.env.MCP_SERVERS_PATH = (0, import_path4.resolve)(process.cwd(), process.env.MCP_SERVERS_PATH);
156488
+ }
156461
156489
  start();
156462
156490
  var mainService = container.get(MainService);
156463
156491
  mainService.start("index");