@markus-global/cli 0.4.7 → 0.4.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/markus.mjs CHANGED
@@ -50156,39 +50156,43 @@ Known issues: ${knownIssues}` : ""}`
50156
50156
  agent.injectSkillInstructions(skillName, instructions);
50157
50157
  }
50158
50158
  }
50159
+ const mcpConnections = [];
50159
50160
  for (const skillName of config.skills) {
50160
50161
  const skill = this.skillRegistry.get(skillName);
50161
50162
  if (skill?.manifest.mcpServers) {
50162
50163
  const isolated = skill.manifest.isolation === "per-agent";
50163
50164
  for (const [serverName, serverConfig] of Object.entries(skill.manifest.mcpServers)) {
50164
- try {
50165
- let mcpTools;
50166
- if (isolated) {
50167
- await this.mcpManager.connectServerScoped(serverName, serverConfig, id);
50168
- mcpTools = this.mcpManager.getToolHandlersScoped(serverName, id);
50169
- mcpTools = this.browserSessionManager.wrapToolHandlers(mcpTools, id);
50170
- } else {
50171
- await this.mcpManager.connectServer(serverName, serverConfig);
50172
- mcpTools = this.mcpManager.getToolHandlers(serverName);
50173
- }
50174
- const toolNames = [];
50175
- for (const tool of mcpTools) {
50176
- agent.registerTool(tool);
50177
- toolNames.push(tool.name);
50165
+ mcpConnections.push((async () => {
50166
+ try {
50167
+ let mcpTools;
50168
+ if (isolated) {
50169
+ await this.mcpManager.connectServerScoped(serverName, serverConfig, id);
50170
+ mcpTools = this.mcpManager.getToolHandlersScoped(serverName, id);
50171
+ mcpTools = this.browserSessionManager.wrapToolHandlers(mcpTools, id);
50172
+ } else {
50173
+ await this.mcpManager.connectServer(serverName, serverConfig);
50174
+ mcpTools = this.mcpManager.getToolHandlers(serverName);
50175
+ }
50176
+ const toolNames = [];
50177
+ for (const tool of mcpTools) {
50178
+ agent.registerTool(tool);
50179
+ toolNames.push(tool.name);
50180
+ }
50181
+ agent.activateTools(toolNames);
50182
+ log28.info(`Skill ${skillName} MCP server ${serverName} restored for agent ${id}`, {
50183
+ toolCount: mcpTools.length,
50184
+ isolated
50185
+ });
50186
+ } catch (error) {
50187
+ log28.warn(`Failed to restore skill ${skillName} MCP server ${serverName} for agent ${id}`, {
50188
+ error: String(error)
50189
+ });
50178
50190
  }
50179
- agent.activateTools(toolNames);
50180
- log28.info(`Skill ${skillName} MCP server ${serverName} restored for agent ${id}`, {
50181
- toolCount: mcpTools.length,
50182
- isolated
50183
- });
50184
- } catch (error) {
50185
- log28.warn(`Failed to restore skill ${skillName} MCP server ${serverName} for agent ${id}`, {
50186
- error: String(error)
50187
- });
50188
- }
50191
+ })());
50189
50192
  }
50190
50193
  }
50191
50194
  }
50195
+ await Promise.all(mcpConnections);
50192
50196
  }
50193
50197
  agent.setSkillMcpActivator(async (skillName, mcpServers) => {
50194
50198
  let tools2 = [];
@@ -55931,24 +55935,25 @@ var init_org_service = __esm({
55931
55935
  this.pendingAgentStartIds = [];
55932
55936
  try {
55933
55937
  const agentRows = await this.storage.agentRepo.findByOrgId(orgId2);
55934
- let restoredCount = 0;
55935
- for (const row of agentRows) {
55936
- if (this.agentManager.hasAgent(row.id))
55937
- continue;
55938
+ const toRestore = agentRows.filter((row) => !this.agentManager.hasAgent(row.id));
55939
+ const restorePromises = toRestore.map(async (row) => {
55938
55940
  try {
55939
55941
  await this.agentManager.restoreAgent(row);
55940
55942
  this.pendingAgentStartIds.push(row.id);
55941
- restoredCount++;
55942
55943
  if (row.teamId) {
55943
55944
  const team = this.teams.get(row.teamId);
55944
55945
  if (team && !team.memberAgentIds.includes(row.id)) {
55945
55946
  team.memberAgentIds.push(row.id);
55946
55947
  }
55947
55948
  }
55949
+ return true;
55948
55950
  } catch (agentErr) {
55949
55951
  log46.warn(`Failed to restore agent ${row.id}`, { error: String(agentErr) });
55952
+ return false;
55950
55953
  }
55951
- }
55954
+ });
55955
+ const results = await Promise.all(restorePromises);
55956
+ const restoredCount = results.filter(Boolean).length;
55952
55957
  log46.info(`Restored ${restoredCount} agents from DB`);
55953
55958
  } catch (error) {
55954
55959
  log46.warn("Failed to restore agents from DB", { error: String(error) });
@@ -78469,7 +78474,7 @@ var init_marketplace_rating_repo = __esm({
78469
78474
  });
78470
78475
 
78471
78476
  // ../storage/dist/sqlite-storage.js
78472
- import Database from "better-sqlite3";
78477
+ import { DatabaseSync } from "node:sqlite";
78473
78478
  import { randomUUID } from "node:crypto";
78474
78479
  import { mkdirSync as mkdirSync18 } from "node:fs";
78475
78480
  import { dirname as dirname7 } from "node:path";
@@ -78493,10 +78498,10 @@ function openSqlite(dbPath) {
78493
78498
  if (_db)
78494
78499
  return _db;
78495
78500
  mkdirSync18(dirname7(dbPath), { recursive: true });
78496
- _db = new Database(dbPath);
78497
- _db.pragma("journal_mode = WAL");
78498
- _db.pragma("foreign_keys = ON");
78499
- _db.pragma("busy_timeout = 5000");
78501
+ _db = new DatabaseSync(dbPath);
78502
+ _db.exec("PRAGMA journal_mode = WAL");
78503
+ _db.exec("PRAGMA foreign_keys = ON");
78504
+ _db.exec("PRAGMA busy_timeout = 5000");
78500
78505
  for (const stmt of SCHEMA_SQL.split(";").map((s) => s.trim()).filter(Boolean)) {
78501
78506
  _db.exec(stmt);
78502
78507
  }
@@ -78520,7 +78525,7 @@ function openSqlite(dbPath) {
78520
78525
  { table: "task_comments", column: "mentions", sql: "ALTER TABLE task_comments ADD COLUMN mentions TEXT DEFAULT '[]'" }
78521
78526
  ];
78522
78527
  for (const m of migrations) {
78523
- const cols = _db.pragma(`table_info(${m.table})`);
78528
+ const cols = _db.prepare(`PRAGMA table_info(${m.table})`).all();
78524
78529
  if (!cols.some((c) => c.name === m.column)) {
78525
78530
  _db.exec(m.sql);
78526
78531
  log66.info(`Migration: added column ${m.column} to ${m.table}`);