nestor-sh 2.0.5 → 2.0.6

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/nestor.mjs CHANGED
@@ -1976,6 +1976,7 @@ var init_store = __esm({
1976
1976
  db;
1977
1977
  dbPath;
1978
1978
  fts5Available = false;
1979
+ _inTransaction = false;
1979
1980
  encryptor;
1980
1981
  static sqlJsPromise = null;
1981
1982
  /**
@@ -2054,6 +2055,8 @@ var init_store = __esm({
2054
2055
  * Save the database to disk (no-op for in-memory databases).
2055
2056
  */
2056
2057
  save() {
2058
+ if (this._inTransaction)
2059
+ return;
2057
2060
  if (this.dbPath) {
2058
2061
  const data = this.db.export();
2059
2062
  fs.writeFileSync(this.dbPath, Buffer.from(data));
@@ -2067,14 +2070,20 @@ var init_store = __esm({
2067
2070
  * Run a function inside a transaction. Rolls back on error.
2068
2071
  */
2069
2072
  transaction(fn) {
2073
+ this._inTransaction = true;
2070
2074
  this.db.run("BEGIN TRANSACTION");
2071
2075
  try {
2072
2076
  const result = fn();
2073
2077
  this.db.run("COMMIT");
2078
+ this._inTransaction = false;
2074
2079
  this.save();
2075
2080
  return result;
2076
2081
  } catch (err) {
2077
- this.db.run("ROLLBACK");
2082
+ try {
2083
+ this.db.run("ROLLBACK");
2084
+ } catch {
2085
+ }
2086
+ this._inTransaction = false;
2078
2087
  throw err;
2079
2088
  }
2080
2089
  }
@@ -6189,6 +6198,7 @@ function csrfProtection(options = {}) {
6189
6198
  const secret = options.secret ?? randomBytes3(32).toString("hex");
6190
6199
  const skipPaths = new Set(options.skipPaths ?? []);
6191
6200
  const skipBearerAuth = options.skipBearerAuth ?? true;
6201
+ const skipLocalhost = options.skipLocalhost ?? false;
6192
6202
  function generateToken() {
6193
6203
  const nonce = randomBytes3(16).toString("hex");
6194
6204
  const signature = createHmac("sha256", secret).update(nonce).digest("hex");
@@ -6225,6 +6235,10 @@ function csrfProtection(options = {}) {
6225
6235
  next();
6226
6236
  return;
6227
6237
  }
6238
+ if (skipLocalhost) {
6239
+ next();
6240
+ return;
6241
+ }
6228
6242
  if (skipPaths.has(req.path)) {
6229
6243
  next();
6230
6244
  return;
@@ -10024,7 +10038,7 @@ var SERVER_VERSION, startTime;
10024
10038
  var init_health = __esm({
10025
10039
  "../server/dist/routes/health.js"() {
10026
10040
  "use strict";
10027
- SERVER_VERSION = "0.1.0";
10041
+ SERVER_VERSION = "2.0.6";
10028
10042
  startTime = Date.now();
10029
10043
  }
10030
10044
  });
@@ -142945,9 +142959,11 @@ function createApp(config2) {
142945
142959
  app.use(securityHeaders());
142946
142960
  app.use(apiVersion("1"));
142947
142961
  app.use(rateLimit({ windowMs: 6e4, max: 60 }));
142962
+ const isLocalhost = !config2.host || config2.host === "127.0.0.1" || config2.host === "localhost";
142948
142963
  app.use(csrfProtection({
142949
142964
  skipPaths: ["/api/auth/token", "/api/health"],
142950
- skipBearerAuth: true
142965
+ skipBearerAuth: true,
142966
+ skipLocalhost: isLocalhost
142951
142967
  }));
142952
142968
  app.use(otelTracingMiddleware());
142953
142969
  app.use((req, res, next) => {
@@ -143129,6 +143145,7 @@ function createApp(config2) {
143129
143145
  res.sendFile(join16(studioDistDir, "index.html"));
143130
143146
  });
143131
143147
  app.use("/studio", express.static(studioDistDir, { index: false }));
143148
+ app.use(express.static(studioDistDir, { index: false }));
143132
143149
  app.get("/studio/*", (req, res) => {
143133
143150
  if (!studioState.enabled) {
143134
143151
  return res.status(403).json({ error: { code: "STUDIO_DISABLED", message: "Studio is disabled." } });
@@ -143153,6 +143170,17 @@ function createApp(config2) {
143153
143170
  });
143154
143171
  });
143155
143172
  }
143173
+ if (studioDistDir) {
143174
+ app.get("*", (req, res, next) => {
143175
+ if (req.path.startsWith("/api/") || req.path.startsWith("/ws")) {
143176
+ return next();
143177
+ }
143178
+ if (!studioState.enabled) {
143179
+ return res.status(403).json({ error: { code: "STUDIO_DISABLED", message: "Studio is disabled." } });
143180
+ }
143181
+ res.sendFile(join16(studioDistDir, "index.html"));
143182
+ });
143183
+ }
143156
143184
  app.use(errorHandler());
143157
143185
  return app;
143158
143186
  }
@@ -157417,7 +157445,7 @@ var init_server = __esm({
157417
157445
  MCP_PROTOCOL_VERSION = "2024-11-05";
157418
157446
  SERVER_INFO = {
157419
157447
  name: "nestor",
157420
- version: "0.1.0"
157448
+ version: "2.0.6"
157421
157449
  };
157422
157450
  SERVER_CAPABILITIES = {
157423
157451
  tools: { listChanged: false },
@@ -163659,7 +163687,7 @@ if (command2 && !["--help", "-h", "--version", "-V", "install"].includes(command
163659
163687
  }
163660
163688
  }
163661
163689
  var program = new Command();
163662
- program.name("nestor-sh").description("Nestor AI Agent Platform \u2014 orchestrate, secure and monitor AI agents").version("2.0.5");
163690
+ program.name("nestor-sh").description("Nestor AI Agent Platform \u2014 orchestrate, secure and monitor AI agents").version("2.0.6");
163663
163691
  registerStartCommand(program);
163664
163692
  registerInstallCommand(program);
163665
163693
  registerAgentCommand(program);